diff --git a/packages/misskey-js/src/api.types.ts b/packages/misskey-js/src/api.types.ts index cc88c4b1a4..d9004be266 100644 --- a/packages/misskey-js/src/api.types.ts +++ b/packages/misskey-js/src/api.types.ts @@ -2,7 +2,7 @@ import type { Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance, LiteInstanceMetadata, MeDetailed, - Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage, + Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage, } from './entities.js'; type TODO = Record | null; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 04065c51c9..dba7993fa4 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -1,77 +1,14 @@ +import { Packed } from "./schemas"; + export type ID = string; export type DateString = string; type TODO = Record; // NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように -export type User = UserLite | UserDetailed; - -export type UserLite = { - id: ID; - username: string; - host: string | null; - name: string; - onlineStatus: 'online' | 'active' | 'offline' | 'unknown'; - avatarUrl: string; - avatarBlurhash: string; - emojis: { - name: string; - url: string; - }[]; - instance?: { - name: Instance['name']; - softwareName: Instance['softwareName']; - softwareVersion: Instance['softwareVersion']; - iconUrl: Instance['iconUrl']; - faviconUrl: Instance['faviconUrl']; - themeColor: Instance['themeColor']; - }; -}; - -export type UserDetailed = UserLite & { - alsoKnownAs: string[]; - bannerBlurhash: string | null; - bannerColor: string | null; - bannerUrl: string | null; - birthday: string | null; - createdAt: DateString; - description: string | null; - ffVisibility: 'public' | 'followers' | 'private'; - fields: {name: string; value: string}[]; - followersCount: number; - followingCount: number; - hasPendingFollowRequestFromYou: boolean; - hasPendingFollowRequestToYou: boolean; - isAdmin: boolean; - isBlocked: boolean; - isBlocking: boolean; - isBot: boolean; - isCat: boolean; - isFollowed: boolean; - isFollowing: boolean; - isLocked: boolean; - isModerator: boolean; - isMuted: boolean; - isSilenced: boolean; - isSuspended: boolean; - lang: string | null; - lastFetchedAt?: DateString; - location: string | null; - movedTo: string; - notesCount: number; - pinnedNoteIds: ID[]; - pinnedNotes: Note[]; - pinnedPage: Page | null; - pinnedPageId: string | null; - publicReactions: boolean; - securityKeys: boolean; - twoFactorEnabled: boolean; - updatedAt: DateString | null; - uri: string | null; - url: string | null; -}; - -export type UserGroup = TODO; +export type User = Packed<'User'>; +export type UserLite = Packed<'UserLite'>; +export type UserDetailed = Packed<'UserDetailed'>; export type UserList = { id: ID; @@ -231,11 +168,6 @@ export type Notification = { type: 'receiveFollowRequest'; user: User; userId: User['id']; -} | { - type: 'groupInvited'; - invitation: UserGroup; - user: User; - userId: User['id']; } | { type: 'app'; header?: string | null; diff --git a/packages/misskey-js/src/schemas/notification.ts b/packages/misskey-js/src/schemas/notification.ts index ca13ade2f9..d01c8579c8 100644 --- a/packages/misskey-js/src/schemas/notification.ts +++ b/packages/misskey-js/src/schemas/notification.ts @@ -37,7 +37,7 @@ export const packedNotificationSchema = { } as const satisfies JSONSchema7Definition; export const packedNotificationStrictSchema = { - $id: 'https://misskey-hub.net/api/schemas/PackedNotificationStrict', + $id: 'https://misskey-hub.net/api/schemas/NotificationStrict', type: 'object', allOf: [ diff --git a/packages/misskey-js/src/streaming.types.ts b/packages/misskey-js/src/streaming.types.ts index 96ac7787e1..465683fd7a 100644 --- a/packages/misskey-js/src/streaming.types.ts +++ b/packages/misskey-js/src/streaming.types.ts @@ -1,4 +1,4 @@ -import type { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User, UserGroup } from './entities.js'; +import type { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User } from './entities.js'; type FIXME = any; @@ -70,23 +70,6 @@ export type Channels = { }; receives: null; }; - messaging: { - params: { - otherparty?: User['id'] | null; - group?: UserGroup['id'] | null; - }; - events: { - message: (payload: MessagingMessage) => void; - deleted: (payload: MessagingMessage['id']) => void; - read: (payload: MessagingMessage['id'][]) => void; - typers: (payload: User[]) => void; - }; - receives: { - read: { - id: MessagingMessage['id']; - }; - }; - }; serverStats: { params: null; events: { diff --git a/packages/misskey-js/test-d/schemas.ts b/packages/misskey-js/test-d/schemas.ts index 007ed91042..af2f5dceb0 100644 --- a/packages/misskey-js/test-d/schemas.ts +++ b/packages/misskey-js/test-d/schemas.ts @@ -1,10 +1,9 @@ import { Packed, Def } from '../src/schemas'; -// import { expectType } from 'tsd'; +import { expectType } from 'tsd'; describe('schemas', () => { test('user', () => { type UserLite = Packed<'UserLite'>; - /* Error: is declared too wide for argument type expectType({ id: 'string', name: null, @@ -18,7 +17,6 @@ describe('schemas', () => { isCat: false, onlineStatus: null, }); - */ type UserDetailedNotMeOnly = Packed<'UserDetailedNotMeOnly'>; type UserDetailedNotMe = Packed<'UserDetailedNotMe'>; type MeDetailed = Packed<'MeDetailed'>; @@ -42,6 +40,7 @@ describe('schemas', () => { }); test('notification', () => { type Notification = Packed<'Notification'>; + type NotificationStrict = Packed<'NotificationStrict'>; }); test('drive file', () => { type DriveFile = Packed<'DriveFile'>;