From e17c3d1ef917cec659a735a98cfe2ac6436c4700 Mon Sep 17 00:00:00 2001 From: MomentQYC <“zixipersonal@gmail.com”> Date: Mon, 7 Oct 2024 09:04:06 +0800 Subject: [PATCH] style --- .../backend/src/core/WebhookTestService.ts | 2 ++ .../backend/src/models/json-schema/role.ts | 2 +- .../src/server/api/endpoints/notes/tts.ts | 18 +++++----- .../src/pages/admin/external-services.vue | 8 ++--- .../frontend/src/scripts/get-note-menu.ts | 2 +- packages/misskey-js/etc/misskey-js.api.md | 8 ++--- .../misskey-js/src/autogen/apiClientJSDoc.ts | 11 +++++++ packages/misskey-js/src/autogen/endpoint.ts | 6 ++-- packages/misskey-js/src/autogen/entities.ts | 4 +-- packages/misskey-js/src/autogen/types.ts | 33 +++++++++++++++---- 10 files changed, 64 insertions(+), 30 deletions(-) diff --git a/packages/backend/src/core/WebhookTestService.ts b/packages/backend/src/core/WebhookTestService.ts index 4c45b95a64..6c1d9ea86c 100644 --- a/packages/backend/src/core/WebhookTestService.ts +++ b/packages/backend/src/core/WebhookTestService.ts @@ -78,6 +78,7 @@ function generateDummyUser(override?: Partial): MiUser { isLocked: false, isBot: false, isCat: true, + isVI: false, isRoot: false, isExplorable: true, isHibernated: false, @@ -197,6 +198,7 @@ function toPackedUserLite(user: MiUser, override?: Packed<'UserLite'>): Packed<' })), isBot: user.isBot, isCat: user.isCat, + isVI: user.isVI, emojis: user.emojis, onlineStatus: 'active', badgeRoles: [], diff --git a/packages/backend/src/models/json-schema/role.ts b/packages/backend/src/models/json-schema/role.ts index 0f86c763a7..dd479e527b 100644 --- a/packages/backend/src/models/json-schema/role.ts +++ b/packages/backend/src/models/json-schema/role.ts @@ -66,7 +66,7 @@ export const packedRoleCondFormulaValueUserSettingBooleanSchema = { type: { type: 'string', nullable: false, optional: false, - enum: ['isSuspended', 'isLocked', 'isBot', 'isCat','isVI' , 'isExplorable'], + enum: ['isSuspended', 'isLocked', 'isBot', 'isCat', 'isVI', 'isExplorable'], }, }, } as const; diff --git a/packages/backend/src/server/api/endpoints/notes/tts.ts b/packages/backend/src/server/api/endpoints/notes/tts.ts index c337c2b93e..e214a675a3 100644 --- a/packages/backend/src/server/api/endpoints/notes/tts.ts +++ b/packages/backend/src/server/api/endpoints/notes/tts.ts @@ -102,7 +102,7 @@ export default class extends Endpoint { // eslint- try { const example = await fetch(instance.hfexampleAudioURL || ''); exampleAudio = await example.blob(); - } catch { + } catch (e) { throw new ApiError(meta.errors.unavailable); } @@ -112,7 +112,7 @@ export default class extends Endpoint { // eslint- try { app = await Client.connect(instance.hfSpaceName, { hf_token: instance.hfAuthKey }); - } catch { + } catch (e) { throw new ApiError(meta.errors.unavailable); } @@ -135,19 +135,19 @@ export default class extends Endpoint { // eslint- instance.hfdas, ]); } catch (e) { - console.error("An error occurred during prediction:", e); - const responseMessage = (e as any).message || ((e as any).original_msg && (e as any).original_msg.message); if (responseMessage && responseMessage.includes('You have exceeded your GPU quota')) { outofQuota = true; - console.log("Fallback to Inference API"); + console.info("Fallback to Inference API"); + notcontinue = true; + } else { + throw new ApiError(meta.errors.unavailable); } - notcontinue = true; } if (!notcontinue) { - let resurl = result.data[0].url; + const resurl = result.data[0].url; const res = await this.httpRequestService.send(resurl, { method: 'GET', @@ -157,7 +157,7 @@ export default class extends Endpoint { // eslint- timeout: 60000, }); - let contentType = res.headers.get('Content-Type') || 'application/octet-stream'; + const contentType = res.headers.get('Content-Type') || 'application/octet-stream'; if (contentType === 'audio/x-wav') { return res.body; @@ -183,7 +183,7 @@ export default class extends Endpoint { // eslint- timeout: 60000, }); - let contentType = res.headers.get('Content-Type') || 'application/octet-stream'; + const contentType = res.headers.get('Content-Type') || 'application/octet-stream'; if (contentType === 'audio/flac') { return res.body; diff --git a/packages/frontend/src/pages/admin/external-services.vue b/packages/frontend/src/pages/admin/external-services.vue index ee3e524a8b..780cb2a077 100644 --- a/packages/frontend/src/pages/admin/external-services.vue +++ b/packages/frontend/src/pages/admin/external-services.vue @@ -80,16 +80,16 @@ SPDX-License-Identifier: AGPL-3.0-only - + - + - + - + diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index d8bfea8f69..db6970aa6a 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -176,7 +176,7 @@ export function getNoteMenu(props: { note: Misskey.entities.Note; translation: Ref; translating: Ref; - convert: Ref; + convert: Ref; converting: Ref; isDeleted: Ref; currentClip?: Misskey.entities.Clip; diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 5e20ffd50f..e7434301ab 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -1671,8 +1671,8 @@ declare namespace entities { NotesTimelineResponse, NotesTranslateRequest, NotesTranslateResponse, - NotesTTSRequest, - NotesTTSResponse, + NotesTtsRequest, + NotesTtsResponse, NotesUnrenoteRequest, NotesUserListTimelineRequest, NotesUserListTimelineResponse, @@ -2788,10 +2788,10 @@ type NotesTranslateRequest = operations['notes___translate']['requestBody']['con type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json']; // @public (undocumented) -type NotesTTSRequest = operations['notes___tts']['requestBody']['content']['application/json']; +type NotesTtsRequest = operations['notes___tts']['requestBody']['content']['application/json']; // @public (undocumented) -type NotesTTSResponse = unknown; +type NotesTtsResponse = operations['notes___tts']['responses']['200']['content']['application/json']; // @public (undocumented) type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index e2c7cbba52..bda52d1587 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -3339,6 +3339,17 @@ declare module '../api.js' { credential?: string | null, ): Promise>; + /** + * No description provided. + * + * **Credential required**: *Yes* / **Permission**: *read:account* + */ + request( + endpoint: E, + params: P, + credential?: string | null, + ): Promise>; + /** * No description provided. * diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index 3b0572e4da..2695185747 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -450,8 +450,8 @@ import type { NotesTimelineResponse, NotesTranslateRequest, NotesTranslateResponse, - NotesTTSRequest, - NotesTTSResponse, + NotesTtsRequest, + NotesTtsResponse, NotesUnrenoteRequest, NotesUserListTimelineRequest, NotesUserListTimelineResponse, @@ -880,7 +880,7 @@ export type Endpoints = { 'notes/thread-muting/delete': { req: NotesThreadMutingDeleteRequest; res: EmptyResponse }; 'notes/timeline': { req: NotesTimelineRequest; res: NotesTimelineResponse }; 'notes/translate': { req: NotesTranslateRequest; res: NotesTranslateResponse }; - 'notes/tts': { req: NotesTTSRequest; res: NotesTTSResponse }; + 'notes/tts': { req: NotesTtsRequest; res: NotesTtsResponse }; 'notes/unrenote': { req: NotesUnrenoteRequest; res: EmptyResponse }; 'notes/user-list-timeline': { req: NotesUserListTimelineRequest; res: NotesUserListTimelineResponse }; 'notifications/create': { req: NotificationsCreateRequest; res: EmptyResponse }; diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index 63d9c6134f..590f877ad4 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -453,8 +453,8 @@ export type NotesTimelineRequest = operations['notes___timeline']['requestBody'] export type NotesTimelineResponse = operations['notes___timeline']['responses']['200']['content']['application/json']; export type NotesTranslateRequest = operations['notes___translate']['requestBody']['content']['application/json']; export type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json']; -export type NotesTTSRequest = operations['notes___tts']['requestBody']['content']['application/json']; -export type NotesTTSResponse = unknown; +export type NotesTtsRequest = operations['notes___tts']['requestBody']['content']['application/json']; +export type NotesTtsResponse = operations['notes___tts']['responses']['200']['content']['application/json']; export type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json']; export type NotesUserListTimelineRequest = operations['notes___user-list-timeline']['requestBody']['content']['application/json']; export type NotesUserListTimelineResponse = operations['notes___user-list-timeline']['responses']['200']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 04feb72f21..c1d6ed4110 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -3745,6 +3745,7 @@ export type components = { }[]; isBot?: boolean; isCat?: boolean; + isVI?: boolean; instance?: { name: string | null; softwareName: string | null; @@ -4777,7 +4778,7 @@ export type components = { RoleCondFormulaValueUserSettingBooleanSchema: { id: string; /** @enum {string} */ - type: 'isSuspended' | 'isLocked' | 'isBot' | 'isCat' | 'isExplorable'; + type: 'isSuspended' | 'isLocked' | 'isBot' | 'isCat' | 'isVI' | 'isExplorable'; }; RoleCondFormulaValueAssignedRole: { id: string; @@ -5010,7 +5011,7 @@ export type components = { enableEmail: boolean; enableServiceWorker: boolean; translatorAvailable: boolean; - TTSAvailable: boolean; + ttsAvailable: boolean; mediaProxy: string; enableUrlPreview: boolean; backgroundImageUrl: string | null; @@ -5126,7 +5127,7 @@ export type operations = { enableEmail: boolean; enableServiceWorker: boolean; translatorAvailable: boolean; - TTSAvailable: boolean; + ttsAvailable: boolean; silencedHosts?: string[]; mediaSilencedHosts: string[]; pinnedUsers: string[]; @@ -9516,6 +9517,27 @@ export type operations = { langs?: string[]; deeplAuthKey?: string | null; deeplIsPro?: boolean; + hfAuthKey?: string | null; + /** @default false */ + hfSpace?: boolean; + hfSpaceName?: string | null; + hfexampleAudioURL?: string | null; + hfexampleText?: string | null; + hfexampleLang?: string | null; + /** @default Slice once every 4 sentences */ + hfslice?: string | null; + /** @default 15 */ + hftopK?: number; + /** @default 100 */ + hftopP?: number; + /** @default 100 */ + hfTemperature?: number; + /** @default false */ + hfnrm?: boolean; + /** @default 125 */ + hfSpeedRate?: number; + /** @default false */ + hfdas?: boolean; enableEmail?: boolean; email?: string | null; smtpSecure?: boolean; @@ -19851,6 +19873,7 @@ export type operations = { preventAiLearning?: boolean; isBot?: boolean; isCat?: boolean; + isVI?: boolean; injectFeaturedNote?: boolean; receiveAnnouncementEmail?: boolean; alwaysMarkNsfw?: boolean; @@ -23031,9 +23054,7 @@ export type operations = { /** @description OK (with results) */ 200: { content: { - 'audio/flac': { - blob: Blob; - }; + 'application/json': string; }; }; /** @description OK (without any results) */