From fad2ec56413174b1807d9666a83002cc2b6b588a Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 20:46:55 +0900 Subject: [PATCH 01/12] =?UTF-8?q?chore(misskey-js):=20Unchanged=20files=20?= =?UTF-8?q?with=20check=20annotations=E3=81=A7=E7=B4=9B=E3=82=89=E3=82=8F?= =?UTF-8?q?=E3=81=97=E3=81=84=E9=83=A8=E5=88=86=E3=81=AE=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E3=82=92=E6=8A=91=E5=88=B6=20=E3=83=AD=E3=82=B8=E3=83=83?= =?UTF-8?q?=E3=82=AF=E9=9D=A2=E3=81=AF=E5=BE=8C=E3=81=A7=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/misskey-js/eslint.config.js | 1 + packages/misskey-js/src/acct.ts | 1 + packages/misskey-js/src/api.ts | 3 +++ packages/misskey-js/src/api.types.ts | 2 ++ packages/misskey-js/src/consts.ts | 3 +++ 5 files changed, 10 insertions(+) diff --git a/packages/misskey-js/eslint.config.js b/packages/misskey-js/eslint.config.js index e34e7510b29e..d8173f30e9ac 100644 --- a/packages/misskey-js/eslint.config.js +++ b/packages/misskey-js/eslint.config.js @@ -1,6 +1,7 @@ import tsParser from '@typescript-eslint/parser'; import sharedConfig from '../shared/eslint.config.js'; +// eslint-disable-next-line import/no-default-export export default [ ...sharedConfig, { diff --git a/packages/misskey-js/src/acct.ts b/packages/misskey-js/src/acct.ts index b25bc564ea7d..a80534b8fa18 100644 --- a/packages/misskey-js/src/acct.ts +++ b/packages/misskey-js/src/acct.ts @@ -4,6 +4,7 @@ export type Acct = { }; export function parse(acct: string): Acct { + // eslint-disable-next-line no-param-reassign if (acct.startsWith('@')) acct = acct.substring(1); const split = acct.split('@', 2); return { username: split[0], host: split[1] || null }; diff --git a/packages/misskey-js/src/api.ts b/packages/misskey-js/src/api.ts index 76d055cbe4ed..ea1df57f3d77 100644 --- a/packages/misskey-js/src/api.ts +++ b/packages/misskey-js/src/api.ts @@ -14,6 +14,7 @@ export type APIError = { code: string; message: string; kind: 'client' | 'server'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any info: Record; }; @@ -29,6 +30,7 @@ export type FetchLike = (input: string, init?: { headers: { [key in string]: string } }) => Promise<{ status: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any json(): Promise; }>; @@ -49,6 +51,7 @@ export class APIClient { this.fetch = opts.fetch ?? ((...args) => fetch(...args)); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any private assertIsRecord(obj: T): obj is T & Record { return obj !== null && typeof obj === 'object' && !Array.isArray(obj); } diff --git a/packages/misskey-js/src/api.types.ts b/packages/misskey-js/src/api.types.ts index 8c403639b788..5ee4194db213 100644 --- a/packages/misskey-js/src/api.types.ts +++ b/packages/misskey-js/src/api.types.ts @@ -28,11 +28,13 @@ type StrictExtract = Cond extends Union ? Union : never; type IsCaseMatched = Endpoints[E]['res'] extends SwitchCase + // eslint-disable-next-line @typescript-eslint/no-explicit-any ? IsNeverType> extends false ? true : false : false type GetCaseResult = Endpoints[E]['res'] extends SwitchCase + // eslint-disable-next-line @typescript-eslint/no-explicit-any ? StrictExtract[1] : never diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index 03b906929006..a6a90fa84adc 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -137,7 +137,9 @@ export const moderationLogTypes = [ export type ModerationLogPayloads = { updateServerSettings: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any before: any | null; + // eslint-disable-next-line @typescript-eslint/no-explicit-any after: any | null; }; suspend: { @@ -159,6 +161,7 @@ export type ModerationLogPayloads = { }; addCustomEmoji: { emojiId: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any emoji: any; }; updateCustomEmoji: { From 67072e3ca6e3e16342ca3b35feadcb41afcbe04f Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 20:53:37 +0900 Subject: [PATCH 02/12] dummy change to see if the feature do not report them (to be reverted after the check) --- packages/misskey-js/eslint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/misskey-js/eslint.config.js b/packages/misskey-js/eslint.config.js index d8173f30e9ac..cf8d112b7b28 100644 --- a/packages/misskey-js/eslint.config.js +++ b/packages/misskey-js/eslint.config.js @@ -27,3 +27,4 @@ export default [ }, }, ]; + From c22dd6358ba4e068c49be033a07d9fbb001f2347 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 21:13:55 +0900 Subject: [PATCH 03/12] =?UTF-8?q?refactor:=20=E5=9E=8B=E5=90=88=E3=82=8F?= =?UTF-8?q?=E3=81=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/misskey-js/src/consts.ts | 95 ++++++++++++++++++------------- 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index a6a90fa84adc..63e05f2d68d1 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -1,3 +1,13 @@ +import type { + AbuseReportNotificationRecipient, Ad, + Announcement, + EmojiDetailed, InviteCode, + MetaDetailed, + Note, + Role, SystemWebhook, UserLite +} from "./autogen/models.js"; +import { operations } from './autogen/types.js'; + export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'roleAssigned', 'achievementEarned'] as const; export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const; @@ -135,12 +145,18 @@ export const moderationLogTypes = [ 'unsetUserBanner', ] as const; +type AvatarDecoration = UserLite['avatarDecorations'][number]; + +type ReceivedAbuseReport = { + reportId: AbuseReportNotificationRecipient['id']; + report: operations['admin___abuse-user-reports']['responses'][200]['content']['application/json']; + forwarded: boolean; +}; + export type ModerationLogPayloads = { updateServerSettings: { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - before: any | null; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - after: any | null; + before: MetaDetailed | null; + after: MetaDetailed | null; }; suspend: { userId: string; @@ -161,17 +177,16 @@ export type ModerationLogPayloads = { }; addCustomEmoji: { emojiId: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - emoji: any; + emoji: EmojiDetailed; }; updateCustomEmoji: { emojiId: string; - before: any; - after: any; + before: EmojiDetailed; + after: EmojiDetailed; }; deleteCustomEmoji: { emojiId: string; - emoji: any; + emoji: EmojiDetailed; }; assignRole: { userId: string; @@ -190,16 +205,16 @@ export type ModerationLogPayloads = { }; createRole: { roleId: string; - role: any; + role: Role; }; updateRole: { roleId: string; - before: any; - after: any; + before: Role; + after: Role; }; deleteRole: { roleId: string; - role: any; + role: Role; }; clearQueue: Record; promoteQueue: Record; @@ -214,39 +229,39 @@ export type ModerationLogPayloads = { noteUserId: string; noteUserUsername: string; noteUserHost: string | null; - note: any; + note: Note; }; createGlobalAnnouncement: { announcementId: string; - announcement: any; + announcement: Announcement; }; createUserAnnouncement: { announcementId: string; - announcement: any; + announcement: Announcement; userId: string; userUsername: string; userHost: string | null; }; updateGlobalAnnouncement: { announcementId: string; - before: any; - after: any; + before: Announcement; + after: Announcement; }; updateUserAnnouncement: { announcementId: string; - before: any; - after: any; + before: Announcement; + after: Announcement; userId: string; userUsername: string; userHost: string | null; }; deleteGlobalAnnouncement: { announcementId: string; - announcement: any; + announcement: Announcement; }; deleteUserAnnouncement: { announcementId: string; - announcement: any; + announcement: Announcement; userId: string; userUsername: string; userHost: string | null; @@ -284,37 +299,37 @@ export type ModerationLogPayloads = { }; resolveAbuseReport: { reportId: string; - report: any; + report: ReceivedAbuseReport; forwarded: boolean; }; createInvitation: { - invitations: any[]; + invitations: InviteCode[]; }; createAd: { adId: string; - ad: any; + ad: Ad; }; updateAd: { adId: string; - before: any; - after: any; + before: Ad; + after: Ad; }; deleteAd: { adId: string; - ad: any; + ad: Ad; }; createAvatarDecoration: { avatarDecorationId: string; - avatarDecoration: any; + avatarDecoration: AvatarDecoration; }; updateAvatarDecoration: { avatarDecorationId: string; - before: any; - after: any; + before: AvatarDecoration; + after: AvatarDecoration; }; deleteAvatarDecoration: { avatarDecorationId: string; - avatarDecoration: any; + avatarDecoration: AvatarDecoration; }; unsetUserAvatar: { userId: string; @@ -330,28 +345,28 @@ export type ModerationLogPayloads = { }; createSystemWebhook: { systemWebhookId: string; - webhook: any; + webhook: SystemWebhook; }; updateSystemWebhook: { systemWebhookId: string; - before: any; - after: any; + before: SystemWebhook; + after: SystemWebhook; }; deleteSystemWebhook: { systemWebhookId: string; - webhook: any; + webhook: SystemWebhook; }; createAbuseReportNotificationRecipient: { recipientId: string; - recipient: any; + recipient: AbuseReportNotificationRecipient; }; updateAbuseReportNotificationRecipient: { recipientId: string; - before: any; - after: any; + before: AbuseReportNotificationRecipient; + after: AbuseReportNotificationRecipient; }; deleteAbuseReportNotificationRecipient: { recipientId: string; - recipient: any; + recipient: AbuseReportNotificationRecipient; }; }; From e31401ccf3a4cdf8729d40e72299f25811eddb9b Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 21:16:47 +0900 Subject: [PATCH 04/12] refactor: fix warnings from c22dd6358ba4e068c49be033a07d9fbb001f2347 --- packages/misskey-js/src/consts.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index 63e05f2d68d1..71de2e98dfc1 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -1,12 +1,12 @@ +import type { operations } from './autogen/types.js'; import type { AbuseReportNotificationRecipient, Ad, Announcement, EmojiDetailed, InviteCode, MetaDetailed, Note, - Role, SystemWebhook, UserLite -} from "./autogen/models.js"; -import { operations } from './autogen/types.js'; + Role, SystemWebhook, UserLite, +} from './autogen/models.js'; export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'roleAssigned', 'achievementEarned'] as const; From b2bac0ec22bc00e62df74c0b7aa14b4c70f9c5f6 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 21:30:13 +0900 Subject: [PATCH 05/12] lint --- packages/misskey-js/src/entities.ts | 3 ++- packages/misskey-js/src/streaming.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 7331a55a1cac..ce58fb29709a 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -7,7 +7,7 @@ import { Role, RolePolicies, User, - UserDetailedNotMe + UserDetailedNotMe, } from './autogen/models.js'; export * from './autogen/entities.js'; @@ -19,6 +19,7 @@ export type DateString = string; export type PageEvent = { pageId: Page['id']; event: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any var: any; userId: User['id']; user: User; diff --git a/packages/misskey-js/src/streaming.ts b/packages/misskey-js/src/streaming.ts index 83930e621c66..c862aceacba0 100644 --- a/packages/misskey-js/src/streaming.ts +++ b/packages/misskey-js/src/streaming.ts @@ -15,7 +15,7 @@ export function urlQuery(obj: Record> = T[keyof T]; +type AnyOf> = T[keyof T]; type StreamEvents = { _connected_: void; @@ -25,6 +25,7 @@ type StreamEvents = { /** * Misskey stream connection */ +// eslint-disable-next-line import/no-default-export export default class Stream extends EventEmitter { private stream: _ReconnectingWebsocket.default; public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing'; @@ -51,6 +52,7 @@ export default class Stream extends EventEmitter { this.send = this.send.bind(this); this.close = this.close.bind(this); + // eslint-disable-next-line no-param-reassign options = options ?? { }; const query = urlQuery({ From 9faa07377f7e2b33d5c29fe81369c1cf0410387a Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 21:55:46 +0900 Subject: [PATCH 06/12] =?UTF-8?q?=E5=9E=8B=E5=90=88=E3=82=8F=E3=81=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/misskey-js/src/streaming.ts | 17 +++++++++-------- packages/misskey-js/src/streaming.types.ts | 6 ++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/misskey-js/src/streaming.ts b/packages/misskey-js/src/streaming.ts index c862aceacba0..93da5109a271 100644 --- a/packages/misskey-js/src/streaming.ts +++ b/packages/misskey-js/src/streaming.ts @@ -35,6 +35,7 @@ export default class Stream extends EventEmitter { private idCounter = 0; constructor(origin: string, user: { token: string; } | null, options?: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any WebSocket?: any; }) { super(); @@ -93,7 +94,7 @@ export default class Stream extends EventEmitter { this.sharedConnectionPools.push(pool); } - const connection = new SharedConnection(this, channel, pool, name); + const connection = new SharedConnection(this, channel, pool, name); this.sharedConnections.push(connection); return connection; } @@ -176,9 +177,9 @@ export default class Stream extends EventEmitter { * ! ストリーム上のやり取りはすべてJSONで行われます ! */ public send(typeOrPayload: string): void - public send(typeOrPayload: string, payload: any): void - public send(typeOrPayload: Record | any[]): void - public send(typeOrPayload: string | Record | any[], payload?: any): void { + public send(typeOrPayload: string, payload: unknown): void + public send(typeOrPayload: Record | unknown[]): void + public send(typeOrPayload: string | Record | unknown[], payload?: unknown): void { if (typeof typeOrPayload === 'string') { this.stream.send(JSON.stringify({ type: typeOrPayload, @@ -213,7 +214,7 @@ class Pool { public id: string; protected stream: Stream; public users = 0; - private disposeTimerId: any; + private disposeTimerId: ReturnType | null = null; private isConnected = false; constructor(stream: Stream, channel: string, id: string) { @@ -277,7 +278,7 @@ class Pool { } } -export abstract class Connection = any> extends EventEmitter { +export abstract class Connection = AnyOf> extends EventEmitter { public channel: string; protected stream: Stream; public abstract id: string; @@ -311,7 +312,7 @@ export abstract class Connection = any> extends public abstract dispose(): void; } -class SharedConnection = any> extends Connection { +class SharedConnection = AnyOf> extends Connection { private pool: Pool; public get id(): string { @@ -334,7 +335,7 @@ class SharedConnection = any> extends Connection } } -class NonSharedConnection = any> extends Connection { +class NonSharedConnection = AnyOf> extends Connection { public id: string; protected params: Channel['params']; diff --git a/packages/misskey-js/src/streaming.types.ts b/packages/misskey-js/src/streaming.types.ts index 9a86e03d69f6..fc49573a3819 100644 --- a/packages/misskey-js/src/streaming.types.ts +++ b/packages/misskey-js/src/streaming.types.ts @@ -51,6 +51,7 @@ export type Channels = { registryUpdated: (payload: { scope?: string[]; key: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any value: any | null; }) => void; driveFileCreated: (payload: DriveFile) => void; @@ -208,8 +209,8 @@ export type Channels = { ended: (payload: { winnerId: User['id'] | null; game: ReversiGameDetailed; }) => void; canceled: (payload: { userId: User['id']; }) => void; changeReadyStates: (payload: { user1: boolean; user2: boolean; }) => void; - updateSettings: (payload: { userId: User['id']; key: string; value: any; }) => void; - log: (payload: Record) => void; + updateSettings: (payload: { userId: User['id']; key: string; value: unknown; }) => void; + log: (payload: Record) => void; }; receives: { putStone: { @@ -220,6 +221,7 @@ export type Channels = { cancel: null | Record; updateSettings: { key: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any value: any; }; claimTimeIsUp: null | Record; From 8449c6ea3ddfa73cc88424a4fbd77a6bb6eb6715 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 21:56:06 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/misskey-js/src/streaming.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/misskey-js/src/streaming.ts b/packages/misskey-js/src/streaming.ts index 93da5109a271..d73e7161f650 100644 --- a/packages/misskey-js/src/streaming.ts +++ b/packages/misskey-js/src/streaming.ts @@ -95,7 +95,7 @@ export default class Stream extends EventEmitter { } const connection = new SharedConnection(this, channel, pool, name); - this.sharedConnections.push(connection); + this.sharedConnections.push(connection as unknown as SharedConnection); return connection; } @@ -109,7 +109,7 @@ export default class Stream extends EventEmitter { private connectToChannel(channel: C, params: Channels[C]['params']): NonSharedConnection { const connection = new NonSharedConnection(this, channel, this.genId(), params); - this.nonSharedConnections.push(connection); + this.nonSharedConnections.push(connection as unknown as NonSharedConnection); return connection; } @@ -331,7 +331,7 @@ class SharedConnection = AnyOf> extend public dispose(): void { this.pool.dec(); this.removeAllListeners(); - this.stream.removeSharedConnection(this); + this.stream.removeSharedConnection(this as unknown as SharedConnection); } } @@ -362,6 +362,6 @@ class NonSharedConnection = AnyOf> ext public dispose(): void { this.removeAllListeners(); this.stream.send('disconnect', { id: this.id }); - this.stream.disconnectToChannel(this); + this.stream.disconnectToChannel(this as unknown as NonSharedConnection); } } From 4a0042697c6f3282960883017fb8b5c70d22ed00 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 22:03:18 +0900 Subject: [PATCH 08/12] pnpm build-misskey-js-with-types --- packages/misskey-js/etc/misskey-js.api.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index d11d2a4f0617..509e80e44b58 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -551,7 +551,7 @@ type Channel = components['schemas']['Channel']; // Warning: (ae-forgotten-export) The symbol "AnyOf" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export abstract class ChannelConnection = any> extends EventEmitter { +export abstract class ChannelConnection = AnyOf> extends EventEmitter { constructor(stream: Stream, channel: string, name?: string); // (undocumented) channel: string; @@ -774,9 +774,9 @@ export type Channels = { updateSettings: (payload: { userId: User['id']; key: string; - value: any; + value: unknown; }) => void; - log: (payload: Record) => void; + log: (payload: Record) => void; }; receives: { putStone: { @@ -2992,9 +2992,9 @@ export class Stream extends EventEmitter { // (undocumented) send(typeOrPayload: string): void; // (undocumented) - send(typeOrPayload: string, payload: any): void; + send(typeOrPayload: string, payload: unknown): void; // (undocumented) - send(typeOrPayload: Record | any[]): void; + send(typeOrPayload: Record | unknown[]): void; // (undocumented) state: 'initializing' | 'reconnecting' | 'connected'; // (undocumented) @@ -3229,7 +3229,7 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody'][' // Warnings were encountered during analysis: // -// src/entities.ts:34:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts +// src/entities.ts:35:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) From 65405b906dd5f84a566f781de59dd3bb662a1e04 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Thu, 18 Jul 2024 22:09:45 +0900 Subject: [PATCH 09/12] Revert "dummy change to see if the feature do not report them (to be reverted after the check)" This reverts commit 67072e3ca6e3e16342ca3b35feadcb41afcbe04f. --- packages/misskey-js/eslint.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/misskey-js/eslint.config.js b/packages/misskey-js/eslint.config.js index cf8d112b7b28..d8173f30e9ac 100644 --- a/packages/misskey-js/eslint.config.js +++ b/packages/misskey-js/eslint.config.js @@ -27,4 +27,3 @@ export default [ }, }, ]; - From a581426d4790ad4b13767bd3d4de6a3c970109b0 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:46:11 +0900 Subject: [PATCH 10/12] eliminate reversiGame any --- packages/misskey-js/etc/misskey-js.api.md | 16 +++++++++------- packages/misskey-js/src/entities.ts | 3 +++ packages/misskey-js/src/streaming.types.ts | 14 ++++++++------ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 509e80e44b58..daecf908d8a5 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -771,10 +771,10 @@ export type Channels = { user1: boolean; user2: boolean; }) => void; - updateSettings: (payload: { + updateSettings: (payload: { userId: User['id']; - key: string; - value: unknown; + key: K; + value: ReversiGameDetailed[K]; }) => void; log: (payload: Record) => void; }; @@ -785,10 +785,7 @@ export type Channels = { }; ready: boolean; cancel: null | Record; - updateSettings: { - key: string; - value: any; - }; + updateSettings: ReversiUpdateSettings; claimTimeIsUp: null | Record; }; }; @@ -1191,6 +1188,7 @@ declare namespace entities { SignupPendingResponse, SigninRequest, SigninResponse, + ReversiUpdateKey, PartialRolePolicyOverride, EmptyRequest, EmptyResponse, @@ -2832,6 +2830,9 @@ type ReversiShowGameResponse = operations['reversi___show-game']['responses']['2 // @public (undocumented) type ReversiSurrenderRequest = operations['reversi___surrender']['requestBody']['content']['application/json']; +// @public (undocumented) +type ReversiUpdateKey = 'map' | 'bw' | 'isLlotheo' | 'canPutEverywhere' | 'loopedBoard' | 'timeLimitForEachTurn'; + // @public (undocumented) type ReversiVerifyRequest = operations['reversi___verify']['requestBody']['content']['application/json']; @@ -3230,6 +3231,7 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody'][' // Warnings were encountered during analysis: // // src/entities.ts:35:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts +// src/streaming.types.ts:228:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index ce58fb29709a..6b45530c0bc8 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -247,6 +247,9 @@ export type SigninResponse = { i: string, }; +// See: packages/backend/src/core/ReversiService.ts@L410 +export type ReversiUpdateKey = 'map' | 'bw' | 'isLlotheo' | 'canPutEverywhere' | 'loopedBoard' | 'timeLimitForEachTurn'; + type Values> = T[keyof T]; export type PartialRolePolicyOverride = Partial<{[k in keyof RolePolicies]: Omit, 'value'> & { value: RolePolicies[k] }}>; diff --git a/packages/misskey-js/src/streaming.types.ts b/packages/misskey-js/src/streaming.types.ts index fc49573a3819..0fff259553ee 100644 --- a/packages/misskey-js/src/streaming.types.ts +++ b/packages/misskey-js/src/streaming.types.ts @@ -20,8 +20,14 @@ import { ServerStats, ServerStatsLog, ReversiGameDetailed, + ReversiUpdateKey, } from './entities.js'; +type ReversiUpdateSettings = { + key: K; + value: ReversiGameDetailed[K]; +}; + export type Channels = { main: { params: null; @@ -209,7 +215,7 @@ export type Channels = { ended: (payload: { winnerId: User['id'] | null; game: ReversiGameDetailed; }) => void; canceled: (payload: { userId: User['id']; }) => void; changeReadyStates: (payload: { user1: boolean; user2: boolean; }) => void; - updateSettings: (payload: { userId: User['id']; key: string; value: unknown; }) => void; + updateSettings: (payload: { userId: User['id']; key: K; value: ReversiGameDetailed[K]; }) => void; log: (payload: Record) => void; }; receives: { @@ -219,11 +225,7 @@ export type Channels = { }; ready: boolean; cancel: null | Record; - updateSettings: { - key: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - value: any; - }; + updateSettings: ReversiUpdateSettings; claimTimeIsUp: null | Record; } } From b1c1e9453919cea2e038af404a062b59ca4618cd Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:54:03 +0900 Subject: [PATCH 11/12] move reversiGame types --- packages/misskey-js/etc/misskey-js.api.md | 7 ++----- packages/misskey-js/src/consts.ts | 12 ++++++++++++ packages/misskey-js/src/entities.ts | 3 --- packages/misskey-js/src/streaming.types.ts | 4 +++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index daecf908d8a5..7bd6bec6ea2e 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -1188,7 +1188,6 @@ declare namespace entities { SignupPendingResponse, SigninRequest, SigninResponse, - ReversiUpdateKey, PartialRolePolicyOverride, EmptyRequest, EmptyResponse, @@ -2830,9 +2829,6 @@ type ReversiShowGameResponse = operations['reversi___show-game']['responses']['2 // @public (undocumented) type ReversiSurrenderRequest = operations['reversi___surrender']['requestBody']['content']['application/json']; -// @public (undocumented) -type ReversiUpdateKey = 'map' | 'bw' | 'isLlotheo' | 'canPutEverywhere' | 'loopedBoard' | 'timeLimitForEachTurn'; - // @public (undocumented) type ReversiVerifyRequest = operations['reversi___verify']['requestBody']['content']['application/json']; @@ -3231,7 +3227,8 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody'][' // Warnings were encountered during analysis: // // src/entities.ts:35:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts -// src/streaming.types.ts:228:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts +// src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts +// src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index 71de2e98dfc1..2863e7978dfe 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -145,6 +145,18 @@ export const moderationLogTypes = [ 'unsetUserBanner', ] as const; +// See: packages/backend/src/core/ReversiService.ts@L410 +export const reversiUpdateKeys = [ + 'map', + 'bw', + 'isLlotheo', + 'canPutEverywhere', + 'loopedBoard', + 'timeLimitForEachTurn' +] as const; + +export type ReversiUpdateKey = typeof reversiUpdateKeys[number]; + type AvatarDecoration = UserLite['avatarDecorations'][number]; type ReceivedAbuseReport = { diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 6b45530c0bc8..ce58fb29709a 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -247,9 +247,6 @@ export type SigninResponse = { i: string, }; -// See: packages/backend/src/core/ReversiService.ts@L410 -export type ReversiUpdateKey = 'map' | 'bw' | 'isLlotheo' | 'canPutEverywhere' | 'loopedBoard' | 'timeLimitForEachTurn'; - type Values> = T[keyof T]; export type PartialRolePolicyOverride = Partial<{[k in keyof RolePolicies]: Omit, 'value'> & { value: RolePolicies[k] }}>; diff --git a/packages/misskey-js/src/streaming.types.ts b/packages/misskey-js/src/streaming.types.ts index 0fff259553ee..4447a2e8fc14 100644 --- a/packages/misskey-js/src/streaming.types.ts +++ b/packages/misskey-js/src/streaming.types.ts @@ -20,8 +20,10 @@ import { ServerStats, ServerStatsLog, ReversiGameDetailed, - ReversiUpdateKey, } from './entities.js'; +import { + ReversiUpdateKey, +} from './consts.js'; type ReversiUpdateSettings = { key: K; From 49c87ee684e1261165522c37ed70bd7c5e1d9cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:59:02 +0900 Subject: [PATCH 12/12] lint --- packages/misskey-js/src/consts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index 2863e7978dfe..b509d3280cf0 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -152,7 +152,7 @@ export const reversiUpdateKeys = [ 'isLlotheo', 'canPutEverywhere', 'loopedBoard', - 'timeLimitForEachTurn' + 'timeLimitForEachTurn', ] as const; export type ReversiUpdateKey = typeof reversiUpdateKeys[number];