diff --git a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts index 9bc47a90a..8ce75c917 100644 --- a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts +++ b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts @@ -6,7 +6,6 @@ import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js'; import { UserEntityService } from './UserEntityService.js'; import { bindThis } from '@/decorators.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; @Injectable() export class AbuseUserReportEntityService { @@ -21,7 +20,7 @@ export class AbuseUserReportEntityService { @bindThis public async pack( src: AbuseUserReport['id'] | AbuseUserReport, - ): Promise>> { + ): Promise> { const report = typeof src === 'object' ? src : await this.abuseUserReportsRepository.findOneByOrFail({ id: src }); return await awaitAll({ @@ -48,7 +47,7 @@ export class AbuseUserReportEntityService { @bindThis public packMany( reports: any[], - ): Promise>[]> { + ): Promise[]> { return Promise.all(reports.map(x => this.pack(x))); } } diff --git a/packages/backend/src/core/entities/AntennaEntityService.ts b/packages/backend/src/core/entities/AntennaEntityService.ts index c99a99d52..f6c1bbbc5 100644 --- a/packages/backend/src/core/entities/AntennaEntityService.ts +++ b/packages/backend/src/core/entities/AntennaEntityService.ts @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { AntennasRepository } from '@/models/index.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { Antenna } from '@/models/entities/Antenna.js'; import { bindThis } from '@/decorators.js'; @@ -17,7 +16,7 @@ export class AntennaEntityService { @bindThis public async pack( src: Antenna['id'] | Antenna, - ): Promise>> { + ): Promise> { const antenna = typeof src === 'object' ? src : await this.antennasRepository.findOneByOrFail({ id: src }); return { diff --git a/packages/backend/src/core/entities/BlockingEntityService.ts b/packages/backend/src/core/entities/BlockingEntityService.ts index 92a792aee..ae62f320c 100644 --- a/packages/backend/src/core/entities/BlockingEntityService.ts +++ b/packages/backend/src/core/entities/BlockingEntityService.ts @@ -23,7 +23,7 @@ export class BlockingEntityService { public async pack( src: Blocking['id'] | Blocking, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const blocking = typeof src === 'object' ? src : await this.blockingsRepository.findOneByOrFail({ id: src }); return await awaitAll({ @@ -40,7 +40,7 @@ export class BlockingEntityService { public packMany( blockings: any[], me: { id: User['id'] }, - ): Promise>[]> { + ): Promise[]> { return Promise.all(blockings.map(x => this.pack(x, me))); } } diff --git a/packages/backend/src/core/entities/ChannelEntityService.ts b/packages/backend/src/core/entities/ChannelEntityService.ts index 8e0be563e..e31ad17b2 100644 --- a/packages/backend/src/core/entities/ChannelEntityService.ts +++ b/packages/backend/src/core/entities/ChannelEntityService.ts @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { ChannelFavoritesRepository, ChannelFollowingsRepository, ChannelsRepository, DriveFilesRepository, NoteUnreadsRepository, NotesRepository } from '@/models/index.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { Channel } from '@/models/entities/Channel.js'; import { bindThis } from '@/decorators.js'; @@ -41,7 +40,7 @@ export class ChannelEntityService { src: Channel['id'] | Channel, me?: { id: User['id'] } | null | undefined, detailed?: boolean, - ): Promise>> { + ): Promise> { const channel = typeof src === 'object' ? src : await this.channelsRepository.findOneByOrFail({ id: src }); const meId = me ? me.id : null; diff --git a/packages/backend/src/core/entities/ClipEntityService.ts b/packages/backend/src/core/entities/ClipEntityService.ts index 3e686f5a1..4d10707cf 100644 --- a/packages/backend/src/core/entities/ClipEntityService.ts +++ b/packages/backend/src/core/entities/ClipEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { ClipFavoritesRepository, ClipsRepository, User } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { Clip } from '@/models/entities/Clip.js'; import { bindThis } from '@/decorators.js'; import { UserEntityService } from './UserEntityService.js'; @@ -25,7 +24,7 @@ export class ClipEntityService { public async pack( src: Clip['id'] | Clip, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const meId = me ? me.id : null; const clip = typeof src === 'object' ? src : await this.clipsRepository.findOneByOrFail({ id: src }); @@ -47,7 +46,7 @@ export class ClipEntityService { public packMany( clips: Clip[], me?: { id: User['id'] } | null | undefined, - ): Promise>[]> { + ): Promise[]> { return Promise.all(clips.map(x => this.pack(x, me))); } } diff --git a/packages/backend/src/core/entities/DriveFileEntityService.ts b/packages/backend/src/core/entities/DriveFileEntityService.ts index bcb6a2bf9..11b52ae4c 100644 --- a/packages/backend/src/core/entities/DriveFileEntityService.ts +++ b/packages/backend/src/core/entities/DriveFileEntityService.ts @@ -4,7 +4,6 @@ import { DI } from '@/di-symbols.js'; import type { NotesRepository, DriveFilesRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { User } from '@/models/entities/User.js'; import type { DriveFile } from '@/models/entities/DriveFile.js'; @@ -188,7 +187,7 @@ export class DriveFileEntityService { public async pack( src: DriveFile['id'] | DriveFile, options?: PackOptions, - ): Promise>> { + ): Promise> { const opts = Object.assign({ detail: false, self: false, @@ -196,7 +195,7 @@ export class DriveFileEntityService { const file = typeof src === 'object' ? src : await this.driveFilesRepository.findOneByOrFail({ id: src }); - return await awaitAll>>({ + return await awaitAll>({ id: file.id, createdAt: file.createdAt.toISOString(), name: file.name, @@ -222,7 +221,7 @@ export class DriveFileEntityService { public async packNullable( src: DriveFile['id'] | DriveFile, options?: PackOptions, - ): Promise> | null> { + ): Promise | null> { const opts = Object.assign({ detail: false, self: false, @@ -231,7 +230,7 @@ export class DriveFileEntityService { const file = typeof src === 'object' ? src : await this.driveFilesRepository.findOneBy({ id: src }); if (file == null) return null; - return await awaitAll>>({ + return await awaitAll>({ id: file.id, createdAt: file.createdAt.toISOString(), name: file.name, @@ -257,20 +256,20 @@ export class DriveFileEntityService { public async packMany( files: DriveFile[], options?: PackOptions, - ): Promise>[]> { + ): Promise[]> { const items = await Promise.all(files.map(f => this.packNullable(f, options))); - return items.filter((x): x is Serialized> => x != null); + return items.filter((x): x is Packed<'DriveFile'> => x != null); } @bindThis public async packManyByIdsMap( fileIds: DriveFile['id'][], options?: PackOptions, - ): Promise>['id'], Serialized> | null>> { + ): Promise>['id'], Serialized | null>> { if (fileIds.length === 0) return new Map(); const files = await this.driveFilesRepository.findBy({ id: In(fileIds) }); const packedFiles = await this.packMany(files, options); - const map = new Map>['id'], Serialized> | null>(packedFiles.map(f => [f.id, f])); + const map = new Map>['id'], Serialized | null>(packedFiles.map(f => [f.id, f])); for (const id of fileIds) { if (!map.has(id)) map.set(id, null); } @@ -281,7 +280,7 @@ export class DriveFileEntityService { public async packManyByIds( fileIds: DriveFile['id'][], options?: PackOptions, - ): Promise>[]> { + ): Promise[]> { if (fileIds.length === 0) return []; const filesMap = await this.packManyByIdsMap(fileIds, options); return fileIds.map(id => filesMap.get(id)).filter(isNotNull); diff --git a/packages/backend/src/core/entities/DriveFolderEntityService.ts b/packages/backend/src/core/entities/DriveFolderEntityService.ts index 8ee5ff528..9bd9c0e6f 100644 --- a/packages/backend/src/core/entities/DriveFolderEntityService.ts +++ b/packages/backend/src/core/entities/DriveFolderEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { DriveFilesRepository, DriveFoldersRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { DriveFolder } from '@/models/entities/DriveFolder.js'; import { bindThis } from '@/decorators.js'; @@ -24,7 +23,7 @@ export class DriveFolderEntityService { options?: { detail: boolean }, - ): Promise>> { + ): Promise> { const opts = Object.assign({ detail: false, }, options); diff --git a/packages/backend/src/core/entities/FlashEntityService.ts b/packages/backend/src/core/entities/FlashEntityService.ts index 05e366bec..3240e8649 100644 --- a/packages/backend/src/core/entities/FlashEntityService.ts +++ b/packages/backend/src/core/entities/FlashEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { FlashsRepository, FlashLikesRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { Flash } from '@/models/entities/Flash.js'; import { bindThis } from '@/decorators.js'; @@ -26,7 +25,7 @@ export class FlashEntityService { public async pack( src: Flash['id'] | Flash, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const meId = me ? me.id : null; const flash = typeof src === 'object' ? src : await this.flashsRepository.findOneByOrFail({ id: src }); diff --git a/packages/backend/src/core/entities/FollowingEntityService.ts b/packages/backend/src/core/entities/FollowingEntityService.ts index cb04da239..d09655599 100644 --- a/packages/backend/src/core/entities/FollowingEntityService.ts +++ b/packages/backend/src/core/entities/FollowingEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { FollowingsRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { Following } from '@/models/entities/Following.js'; import { bindThis } from '@/decorators.js'; @@ -71,7 +70,7 @@ export class FollowingEntityService { populateFollowee?: boolean; populateFollower?: boolean; }, - ): Promise>> { + ): Promise> { const following = typeof src === 'object' ? src : await this.followingsRepository.findOneByOrFail({ id: src }); if (opts == null) opts = {}; diff --git a/packages/backend/src/core/entities/GalleryPostEntityService.ts b/packages/backend/src/core/entities/GalleryPostEntityService.ts index e2308f66c..dd2eaf395 100644 --- a/packages/backend/src/core/entities/GalleryPostEntityService.ts +++ b/packages/backend/src/core/entities/GalleryPostEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { GalleryLikesRepository, GalleryPostsRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { GalleryPost } from '@/models/entities/GalleryPost.js'; import { bindThis } from '@/decorators.js'; @@ -28,7 +27,7 @@ export class GalleryPostEntityService { public async pack( src: GalleryPost['id'] | GalleryPost, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const meId = me ? me.id : null; const post = typeof src === 'object' ? src : await this.galleryPostsRepository.findOneByOrFail({ id: src }); diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index 3e8f1c594..32ff4f1fc 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { InstancesRepository } from '@/models/index.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { Instance } from '@/models/entities/Instance.js'; import { MetaService } from '@/core/MetaService.js'; import { bindThis } from '@/decorators.js'; @@ -23,7 +22,7 @@ export class InstanceEntityService { @bindThis public async pack( instance: Instance, - ): Promise>> { + ): Promise> { const meta = await this.metaService.fetch(); return { id: instance.id, diff --git a/packages/backend/src/core/entities/ModerationLogEntityService.ts b/packages/backend/src/core/entities/ModerationLogEntityService.ts index ea54e1259..76e248f73 100644 --- a/packages/backend/src/core/entities/ModerationLogEntityService.ts +++ b/packages/backend/src/core/entities/ModerationLogEntityService.ts @@ -6,7 +6,6 @@ import type { ModerationLog } from '@/models/entities/ModerationLog.js'; import { UserEntityService } from './UserEntityService.js'; import { bindThis } from '@/decorators.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; @Injectable() export class ModerationLogEntityService { @@ -21,7 +20,7 @@ export class ModerationLogEntityService { @bindThis public async pack( src: ModerationLog['id'] | ModerationLog, - ): Promise>> { + ): Promise> { const log = typeof src === 'object' ? src : await this.moderationLogsRepository.findOneByOrFail({ id: src }); return await awaitAll({ @@ -39,7 +38,7 @@ export class ModerationLogEntityService { @bindThis public packMany( reports: any[], - ): Promise>[]> { + ): Promise[]> { return Promise.all(reports.map(x => this.pack(x))); } } diff --git a/packages/backend/src/core/entities/MutingEntityService.ts b/packages/backend/src/core/entities/MutingEntityService.ts index 7a02a1328..94297aa32 100644 --- a/packages/backend/src/core/entities/MutingEntityService.ts +++ b/packages/backend/src/core/entities/MutingEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { MutingsRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { Muting } from '@/models/entities/Muting.js'; import { bindThis } from '@/decorators.js'; @@ -23,7 +22,7 @@ export class MutingEntityService { public async pack( src: Muting['id'] | Muting, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const muting = typeof src === 'object' ? src : await this.mutingsRepository.findOneByOrFail({ id: src }); return await awaitAll({ diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 2ef11840d..7337e3358 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -4,7 +4,6 @@ import * as mfm from 'mfm-js'; import { ModuleRef } from '@nestjs/core'; import { DI } from '@/di-symbols.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import { nyaize } from '@/misc/nyaize.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { User } from '@/models/entities/User.js'; @@ -71,7 +70,7 @@ export class NoteEntityService implements OnModuleInit { } @bindThis - private async hideNote(packedNote: Serialized>, meId: User['id'] | null) { + private async hideNote(packedNote: Packed<'Note'>, meId: User['id'] | null) { // TODO: isVisibleForMe を使うようにしても良さそう(型違うけど) let hide = false; @@ -256,7 +255,7 @@ export class NoteEntityService implements OnModuleInit { } @bindThis - public async packAttachedFiles(fileIds: Note['fileIds'], packedFiles: Map> | null>): Promise>[]> { + public async packAttachedFiles(fileIds: Note['fileIds'], packedFiles: Map | null>): Promise[]> { const missingIds = []; for (const id of fileIds) { if (!packedFiles.has(id)) missingIds.push(id); @@ -279,10 +278,10 @@ export class NoteEntityService implements OnModuleInit { skipHide?: boolean; _hint_?: { myReactions: Map; - packedFiles: Map> | null>; + packedFiles: Map | null>; }; }, - ): Promise>> { + ): Promise> { const opts = Object.assign({ detail: true, skipHide: false, @@ -309,7 +308,7 @@ export class NoteEntityService implements OnModuleInit { .map(x => this.reactionService.decodeReaction(x).reaction.replaceAll(':', '')); const packedFiles = options?._hint_?.packedFiles; - const packed: Serialized> = await awaitAll({ + const packed: Packed<'Note'> = await awaitAll({ id: note.id, createdAt: note.createdAt.toISOString(), userId: note.userId, diff --git a/packages/backend/src/core/entities/NoteFavoriteEntityService.ts b/packages/backend/src/core/entities/NoteFavoriteEntityService.ts index 4563e8998..510201224 100644 --- a/packages/backend/src/core/entities/NoteFavoriteEntityService.ts +++ b/packages/backend/src/core/entities/NoteFavoriteEntityService.ts @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { NoteFavoritesRepository } from '@/models/index.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { NoteFavorite } from '@/models/entities/NoteFavorite.js'; import { NoteEntityService } from './NoteEntityService.js'; @@ -22,7 +21,7 @@ export class NoteFavoriteEntityService { public async pack( src: NoteFavorite['id'] | NoteFavorite, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const favorite = typeof src === 'object' ? src : await this.noteFavoritesRepository.findOneByOrFail({ id: src }); return { diff --git a/packages/backend/src/core/entities/NoteReactionEntityService.ts b/packages/backend/src/core/entities/NoteReactionEntityService.ts index 3105ebc99..38c410d3a 100644 --- a/packages/backend/src/core/entities/NoteReactionEntityService.ts +++ b/packages/backend/src/core/entities/NoteReactionEntityService.ts @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { NoteReactionsRepository } from '@/models/index.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import { bindThis } from '@/decorators.js'; import type { OnModuleInit } from '@nestjs/common'; import type { User } from '@/models/entities/User.js'; @@ -43,7 +42,7 @@ export class NoteReactionEntityService implements OnModuleInit { options?: { withNote: boolean; }, - ): Promise>> { + ): Promise> { const opts = Object.assign({ withNote: false, }, options); diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index af1f5a171..a5f2fe624 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -7,7 +7,6 @@ import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Notification } from '@/models/entities/Notification.js'; import type { Note } from '@/models/entities/Note.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import { bindThis } from '@/decorators.js'; import { isNotNull } from '@/misc/is-not-null.js'; import { notificationTypes } from 'misskey-js'; @@ -63,10 +62,10 @@ export class NotificationEntityService implements OnModuleInit { }, hint?: { - packedNotes: Map>>; - packedUsers: Map>>; + packedNotes: Map>; + packedUsers: Map>; }, - ): Promise>> { + ): Promise> { const notification = src; const token = notification.appAccessTokenId ? await this.accessTokensRepository.findOneByOrFail({ id: notification.appAccessTokenId }) : null; const noteIfNeed = NOTE_REQUIRED_NOTIFICATION_TYPES.has(notification.type) && notification.noteId != null ? ( diff --git a/packages/backend/src/core/entities/PageEntityService.ts b/packages/backend/src/core/entities/PageEntityService.ts index b12e70426..ec9d66991 100644 --- a/packages/backend/src/core/entities/PageEntityService.ts +++ b/packages/backend/src/core/entities/PageEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { DriveFilesRepository, PagesRepository, PageLikesRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { Page } from '@/models/entities/Page.js'; import type { DriveFile } from '@/models/entities/DriveFile.js'; @@ -32,7 +31,7 @@ export class PageEntityService { public async pack( src: Page['id'] | Page, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const meId = me ? me.id : null; const page = typeof src === 'object' ? src : await this.pagesRepository.findOneByOrFail({ id: src }); diff --git a/packages/backend/src/core/entities/RenoteMutingEntityService.ts b/packages/backend/src/core/entities/RenoteMutingEntityService.ts index 5bdf80463..1a7777fc7 100644 --- a/packages/backend/src/core/entities/RenoteMutingEntityService.ts +++ b/packages/backend/src/core/entities/RenoteMutingEntityService.ts @@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js'; import type { RenoteMutingsRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { User } from '@/models/entities/User.js'; import type { RenoteMuting } from '@/models/entities/RenoteMuting.js'; import { bindThis } from '@/decorators.js'; @@ -23,7 +22,7 @@ export class RenoteMutingEntityService { public async pack( src: RenoteMuting['id'] | RenoteMuting, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const muting = typeof src === 'object' ? src : await this.renoteMutingsRepository.findOneByOrFail({ id: src }); return await awaitAll({ diff --git a/packages/backend/src/core/entities/RoleEntityService.ts b/packages/backend/src/core/entities/RoleEntityService.ts index 716ff671e..be8b12e85 100644 --- a/packages/backend/src/core/entities/RoleEntityService.ts +++ b/packages/backend/src/core/entities/RoleEntityService.ts @@ -9,7 +9,6 @@ import { bindThis } from '@/decorators.js'; import { DEFAULT_POLICIES } from '@/core/RoleService.js'; import { UserEntityService } from './UserEntityService.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; @Injectable() export class RoleEntityService { @@ -28,7 +27,7 @@ export class RoleEntityService { public async pack( src: Role['id'] | Role, me?: { id: User['id'] } | null | undefined, - ): Promise>> { + ): Promise> { const role = typeof src === 'object' ? src : await this.rolesRepository.findOneByOrFail({ id: src }); const assignedCount = await this.roleAssignmentsRepository.createQueryBuilder('assign') @@ -74,7 +73,7 @@ export class RoleEntityService { public packMany( roles: any[], me: { id: User['id'] }, - ): Promise>[]> { + ): Promise[]> { return Promise.all(roles.map(x => this.pack(x, me))); } } diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index a12d2b526..0ff08ef67 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -6,7 +6,6 @@ import { ModuleRef } from '@nestjs/core'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { Promiseable } from '@/misc/prelude/await-all.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js'; @@ -24,13 +23,13 @@ import type { NoteEntityService } from './NoteEntityService.js'; import type { DriveFileEntityService } from './DriveFileEntityService.js'; import type { PageEntityService } from './PageEntityService.js'; -type IsUserDetailed = Detailed extends true ? Serialized> : Serialized>; +type IsUserDetailed = Detailed extends true ? Packed<'UserDetailed'> : Packed<'UserLite'>; type IsMeAndIsUserDetailed = Detailed extends true ? - ExpectsMe extends true ? Serialized> : - ExpectsMe extends false ? Serialized> : - (Packed<'MeDetailed'> | Serialized>) : - Serialized>; + ExpectsMe extends true ? Packed<'MeDetailed'> : + ExpectsMe extends false ? Packed<'UserDetailedNotMe'> : + (Packed<'MeDetailed'> | Packed<'UserDetailedNotMe'>) : + Packed<'UserLite'>; const ajv = new Ajv(); diff --git a/packages/backend/src/core/entities/UserListEntityService.ts b/packages/backend/src/core/entities/UserListEntityService.ts index 60a6a112e..5086296cc 100644 --- a/packages/backend/src/core/entities/UserListEntityService.ts +++ b/packages/backend/src/core/entities/UserListEntityService.ts @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { UserListJoiningsRepository, UserListsRepository } from '@/models/index.js'; import type { Packed } from 'misskey-js'; -import type { Serialized } from 'schema-type'; import type { UserList } from '@/models/entities/UserList.js'; import { bindThis } from '@/decorators.js'; import { UserEntityService } from './UserEntityService.js'; @@ -23,7 +22,7 @@ export class UserListEntityService { @bindThis public async pack( src: UserList['id'] | UserList, - ): Promise>> { + ): Promise> { const userList = typeof src === 'object' ? src : await this.userListsRepository.findOneByOrFail({ id: src }); const users = await this.userListJoiningsRepository.findBy({ diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts index 03884ecc1..aa8f2fdea 100644 --- a/packages/backend/src/server/api/stream/types.ts +++ b/packages/backend/src/server/api/stream/types.ts @@ -227,7 +227,7 @@ export type StreamMessages = { }; notes: { name: 'notesStream'; - payload: Serialized>; + payload: Packed<'Note'>; }; }; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 0bf1d0147..16860b4f6 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -1,4 +1,3 @@ -import { Serialized } from "schema-type"; import { Packed } from "./schemas"; export type ID = Packed<'Id'>; @@ -7,21 +6,21 @@ export type DateString = string; type TODO = Record; // NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように -export type User = Serialized>; +export type User = Packed<'User'>; -export type UserLite = Serialized>; -export type UserDetailed = Serialized>; -export type UserList = Serialized>; -export type MeDetailed = Serialized>; -export type DriveFile = Serialized>; -export type DriveFolder = Serialized>; -export type GalleryPost = Serialized>; -export type Note = Serialized>; -export type NoteReaction = Serialized>; -export type NoteFavorite = Serialized>; -export type Notification = Serialized>; -export type CustomEmoji = Serialized | Packed<'EmojiDetailed'>>; -export type Page = Serialized>; +export type UserLite = Packed<'UserLite'>; +export type UserDetailed = Packed<'UserDetailed'>; +export type UserList = Packed<'UserList'>; +export type MeDetailed = Packed<'MeDetailed'>; +export type DriveFile = Packed<'DriveFile'>; +export type DriveFolder = Packed<'DriveFolder'>; +export type GalleryPost = Packed<'GalleryPost'>; +export type Note = Packed<'Note'>; +export type NoteReaction = Packed<'NoteReaction'>; +export type NoteFavorite = Packed<'NoteFavorite'>; +export type Notification = Packed<'NotificationStrict'>; +export type CustomEmoji = Packed<'EmojiSimple'> | Packed<'EmojiDetailed'>; +export type Page = Packed<'Page'>; export type PageEvent = { pageId: Page['id']; @@ -31,19 +30,19 @@ export type PageEvent = { user: User; }; -export type Announcement = Serialized>; -export type Antenna = Serialized>; -export type App = Serialized>; -export type Ad = Serialized>; -export type Clip = Serialized>; -export type Channel = Serialized>; -export type Following = Serialized>; -export type Blocking = Serialized>; -export type Relay = Serialized>; -export type Role = Serialized>; -export type RoleAssign = Serialized>; -export type RolePolicy = Serialized>; -export type RoleCondFormula = Serialized>; +export type Announcement = Packed<'Announcement'>; +export type Antenna = Packed<'Antenna'>; +export type App = Packed<'App'>; +export type Ad = Packed<'Ad'>; +export type Clip = Packed<'Clip'>; +export type Channel = Packed<'Channel'>; +export type Following = Packed<'Following'>; +export type Blocking = Packed<'Blocking'>; +export type Relay = Packed<'Relay'>; +export type Role = Packed<'Role'>; +export type RoleAssign = Packed<'RoleAssign'>; +export type RolePolicy = Packed<'RolePolicy'>; +export type RoleCondFormula = Packed<'RoleCondFormula'>; export type LiteInstanceMetadata = { maintainerName: string | null; @@ -107,7 +106,7 @@ export type DetailedInstanceMetadata = LiteInstanceMetadata & { export type InstanceMetadata = LiteInstanceMetadata | DetailedInstanceMetadata; -export type ServerInfo = Serialized>; +export type ServerInfo = Packed<'ServerInfo'>; export type Stats = { notesCount: number; @@ -119,7 +118,7 @@ export type Stats = { driveUsageRemote: number; }; -export type AuthSession = Serialized>; +export type AuthSession = Packed<'AuthSession'>; export type FollowRequest = { id: ID; @@ -164,7 +163,7 @@ export type Instance = { infoUpdatedAt: DateString | null; }; -export type Signin = Serialized>; +export type Signin = Packed<'SignIn'>; export type UserSorting = | '+follower' diff --git a/packages/misskey-js/src/schemas.ts b/packages/misskey-js/src/schemas.ts index 759bcd736..83272bb3d 100644 --- a/packages/misskey-js/src/schemas.ts +++ b/packages/misskey-js/src/schemas.ts @@ -58,7 +58,7 @@ import { import { packedModerationLogSchema } from './schemas/moderation-log.js'; import { packedAuthSessionSchema } from './schemas/auth-session.js'; import { Error, ApiError } from './schemas/error.js'; -import type { JSONSchema7, JSONSchema7Definition, GetDef, GetRefs, GetKeys, UnionToArray } from 'schema-type'; +import type { JSONSchema7, JSONSchema7Definition, GetDef, GetRefs, GetKeys, UnionToArray, Serialized } from 'schema-type'; export const refs = { Id: IdSchema, @@ -118,5 +118,5 @@ export const refs = { export type References = GetRefs; -export type Packed> = GetDef; +export type Packed> = Serialized>; export type Def> = GetDef;