Use Serialized in EntityService

This commit is contained in:
tamaina 2023-06-04 18:26:05 +00:00
parent a1b243bbda
commit 4a104af304
34 changed files with 82 additions and 78 deletions

View File

@ -5,8 +5,8 @@ import { awaitAll } from '@/misc/prelude/await-all.js';
import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js';
import { UserEntityService } from './UserEntityService.js';
import { bindThis } from '@/decorators.js';
import { Packed } from 'misskey-js';
import { Serialized } from 'schema-type';
import type { Packed } from 'misskey-js';
import type { Serialized } from 'schema-type';
@Injectable()
export class AbuseUserReportEntityService {

View File

@ -2,6 +2,7 @@ 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';
@ -16,7 +17,7 @@ export class AntennaEntityService {
@bindThis
public async pack(
src: Antenna['id'] | Antenna,
): Promise<Packed<'Antenna'>> {
): Promise<Serialized<Packed<'Antenna'>>> {
const antenna = typeof src === 'object' ? src : await this.antennasRepository.findOneByOrFail({ id: src });
return {

View File

@ -6,7 +6,7 @@ import type { AuthSession } from '@/models/entities/AuthSession.js';
import type { User } from '@/models/entities/User.js';
import { AppEntityService } from './AppEntityService.js';
import { bindThis } from '@/decorators.js';
import { Packed } from 'misskey-js';
import type { Packed } from 'misskey-js';
@Injectable()
export class AuthSessionEntityService {

View File

@ -7,7 +7,7 @@ import type { Blocking } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
import { Serialized } from 'schema-type';
import type { Serialized } from 'schema-type';
@Injectable()
export class BlockingEntityService {

View File

@ -3,7 +3,6 @@ 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 { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { Channel } from '@/models/entities/Channel.js';
import { bindThis } from '@/decorators.js';

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +25,7 @@ export class ClipEntityService {
public async pack(
src: Clip['id'] | Clip,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'Clip'>> {
): Promise<Serialized<Packed<'Clip'>>> {
const meId = me ? me.id : null;
const clip = typeof src === 'object' ? src : await this.clipsRepository.findOneByOrFail({ id: src });
@ -47,7 +47,7 @@ export class ClipEntityService {
public packMany(
clips: Clip[],
me?: { id: User['id'] } | null | undefined,
) {
): Promise<Serialized<Packed<'Clip'>>[]> {
return Promise.all(clips.map(x => this.pack(x, me)));
}
}

View File

@ -4,6 +4,7 @@ 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';
@ -187,7 +188,7 @@ export class DriveFileEntityService {
public async pack(
src: DriveFile['id'] | DriveFile,
options?: PackOptions,
): Promise<Packed<'DriveFile'>> {
): Promise<Serialized<Packed<'DriveFile'>>> {
const opts = Object.assign({
detail: false,
self: false,
@ -195,7 +196,7 @@ export class DriveFileEntityService {
const file = typeof src === 'object' ? src : await this.driveFilesRepository.findOneByOrFail({ id: src });
return await awaitAll<Packed<'DriveFile'>>({
return await awaitAll<Serialized<Packed<'DriveFile'>>>({
id: file.id,
createdAt: file.createdAt.toISOString(),
name: file.name,
@ -221,7 +222,7 @@ export class DriveFileEntityService {
public async packNullable(
src: DriveFile['id'] | DriveFile,
options?: PackOptions,
): Promise<Packed<'DriveFile'> | null> {
): Promise<Serialized<Packed<'DriveFile'>> | null> {
const opts = Object.assign({
detail: false,
self: false,
@ -230,7 +231,7 @@ export class DriveFileEntityService {
const file = typeof src === 'object' ? src : await this.driveFilesRepository.findOneBy({ id: src });
if (file == null) return null;
return await awaitAll<Packed<'DriveFile'>>({
return await awaitAll<Serialized<Packed<'DriveFile'>>>({
id: file.id,
createdAt: file.createdAt.toISOString(),
name: file.name,
@ -256,20 +257,20 @@ export class DriveFileEntityService {
public async packMany(
files: DriveFile[],
options?: PackOptions,
): Promise<Packed<'DriveFile'>[]> {
): Promise<Serialized<Packed<'DriveFile'>>[]> {
const items = await Promise.all(files.map(f => this.packNullable(f, options)));
return items.filter((x): x is Packed<'DriveFile'> => x != null);
return items.filter((x): x is Serialized<Packed<'DriveFile'>> => x != null);
}
@bindThis
public async packManyByIdsMap(
fileIds: DriveFile['id'][],
options?: PackOptions,
): Promise<Map<Packed<'DriveFile'>['id'], Packed<'DriveFile'> | null>> {
): Promise<Map<Serialized<Packed<'DriveFile'>>['id'], Serialized<Packed<'DriveFile'>> | 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<Packed<'DriveFile'>['id'], Packed<'DriveFile'> | null>(packedFiles.map(f => [f.id, f]));
const map = new Map<Serialized<Packed<'DriveFile'>>['id'], Serialized<Packed<'DriveFile'>> | null>(packedFiles.map(f => [f.id, f]));
for (const id of fileIds) {
if (!map.has(id)) map.set(id, null);
}
@ -280,7 +281,7 @@ export class DriveFileEntityService {
public async packManyByIds(
fileIds: DriveFile['id'][],
options?: PackOptions,
): Promise<Packed<'DriveFile'>[]> {
): Promise<Serialized<Packed<'DriveFile'>>[]> {
if (fileIds.length === 0) return [];
const filesMap = await this.packManyByIdsMap(fileIds, options);
return fileIds.map(id => filesMap.get(id)).filter(isNotNull);

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.js';
import type { Serialized } from 'schema-type';
import type { DriveFolder } from '@/models/entities/DriveFolder.js';
import { bindThis } from '@/decorators.js';
@ -24,7 +24,7 @@ export class DriveFolderEntityService {
options?: {
detail: boolean
},
): Promise<Packed<'DriveFolder'>> {
): Promise<Serialized<Packed<'DriveFolder'>>> {
const opts = Object.assign({
detail: false,
}, options);

View File

@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { EmojisRepository } from '@/models/index.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { Emoji } from '@/models/entities/Emoji.js';
import { bindThis } from '@/decorators.js';

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +26,7 @@ export class FlashEntityService {
public async pack(
src: Flash['id'] | Flash,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'Flash'>> {
): Promise<Serialized<Packed<'Flash'>>> {
const meId = me ? me.id : null;
const flash = typeof src === 'object' ? src : await this.flashsRepository.findOneByOrFail({ id: src });

View File

@ -1,7 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { FlashLikesRepository } from '@/models/index.js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { FlashLike } from '@/models/entities/FlashLike.js';
import { bindThis } from '@/decorators.js';

View File

@ -1,7 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { FollowRequestsRepository } from '@/models/index.js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { FollowRequest } from '@/models/entities/FollowRequest.js';
import { UserEntityService } from './UserEntityService.js';

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +71,7 @@ export class FollowingEntityService {
populateFollowee?: boolean;
populateFollower?: boolean;
},
): Promise<Packed<'Following'>> {
): Promise<Serialized<Packed<'Following'>>> {
const following = typeof src === 'object' ? src : await this.followingsRepository.findOneByOrFail({ id: src });
if (opts == null) opts = {};

View File

@ -1,7 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { GalleryLikesRepository } from '@/models/index.js';
import type { } from '@/models/entities/Blocking.js';
import type { GalleryLike } from '@/models/entities/GalleryLike.js';
import { GalleryPostEntityService } from './GalleryPostEntityService.js';
import { bindThis } from '@/decorators.js';

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +28,7 @@ export class GalleryPostEntityService {
public async pack(
src: GalleryPost['id'] | GalleryPost,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'GalleryPost'>> {
): Promise<Serialized<Packed<'GalleryPost'>>> {
const meId = me ? me.id : null;
const post = typeof src === 'object' ? src : await this.galleryPostsRepository.findOneByOrFail({ id: src });

View File

@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { HashtagsRepository } from '@/models/index.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { Hashtag } from '@/models/entities/Hashtag.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';

View File

@ -2,7 +2,7 @@ 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 { } from '@/models/entities/Blocking.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 +23,7 @@ export class InstanceEntityService {
@bindThis
public async pack(
instance: Instance,
): Promise<Packed<'FederationInstance'>> {
): Promise<Serialized<Packed<'FederationInstance'>>> {
const meta = await this.metaService.fetch();
return {
id: instance.id,

View File

@ -2,12 +2,11 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { ModerationLogsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { } from '@/models/entities/Blocking.js';
import type { ModerationLog } from '@/models/entities/ModerationLog.js';
import { UserEntityService } from './UserEntityService.js';
import { bindThis } from '@/decorators.js';
import { Serialized } from 'schema-type';
import { Packed } from 'misskey-js';
import type { Packed } from 'misskey-js';
import type { Serialized } from 'schema-type';
@Injectable()
export class ModerationLogEntityService {

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +23,7 @@ export class MutingEntityService {
public async pack(
src: Muting['id'] | Muting,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'Muting'>> {
): Promise<Serialized<Packed<'Muting'>>> {
const muting = typeof src === 'object' ? src : await this.mutingsRepository.findOneByOrFail({ id: src });
return await awaitAll({

View File

@ -4,6 +4,7 @@ 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';
@ -70,7 +71,7 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
private async hideNote(packedNote: Packed<'Note'>, meId: User['id'] | null) {
private async hideNote(packedNote: Serialized<Packed<'Note'>>, meId: User['id'] | null) {
// TODO: isVisibleForMe を使うようにしても良さそう(型違うけど)
let hide = false;
@ -255,7 +256,7 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
public async packAttachedFiles(fileIds: Note['fileIds'], packedFiles: Map<Note['fileIds'][number], Packed<'DriveFile'> | null>): Promise<Packed<'DriveFile'>[]> {
public async packAttachedFiles(fileIds: Note['fileIds'], packedFiles: Map<Note['fileIds'][number], Serialized<Packed<'DriveFile'>> | null>): Promise<Serialized<Packed<'DriveFile'>>[]> {
const missingIds = [];
for (const id of fileIds) {
if (!packedFiles.has(id)) missingIds.push(id);
@ -278,10 +279,10 @@ export class NoteEntityService implements OnModuleInit {
skipHide?: boolean;
_hint_?: {
myReactions: Map<Note['id'], NoteReaction | null>;
packedFiles: Map<Note['fileIds'][number], Packed<'DriveFile'> | null>;
packedFiles: Map<Note['fileIds'][number], Serialized<Packed<'DriveFile'>> | null>;
};
},
): Promise<Packed<'Note'>> {
): Promise<Serialized<Packed<'Note'>>> {
const opts = Object.assign({
detail: true,
skipHide: false,
@ -308,7 +309,7 @@ export class NoteEntityService implements OnModuleInit {
.map(x => this.reactionService.decodeReaction(x).reaction.replaceAll(':', ''));
const packedFiles = options?._hint_?.packedFiles;
const packed: Packed<'Note'> = await awaitAll({
const packed: Serialized<Packed<'Note'>> = await awaitAll({
id: note.id,
createdAt: note.createdAt.toISOString(),
userId: note.userId,

View File

@ -1,7 +1,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { NoteFavoritesRepository } from '@/models/index.js';
import type { } from '@/models/entities/Blocking.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';
@ -21,7 +22,7 @@ export class NoteFavoriteEntityService {
public async pack(
src: NoteFavorite['id'] | NoteFavorite,
me?: { id: User['id'] } | null | undefined,
) {
): Promise<Serialized<Packed<'NoteFavorite'>>> {
const favorite = typeof src === 'object' ? src : await this.noteFavoritesRepository.findOneByOrFail({ id: src });
return {

View File

@ -2,9 +2,9 @@ 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 { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { NoteReaction } from '@/models/entities/NoteReaction.js';
import type { ReactionService } from '../ReactionService.js';
@ -43,7 +43,7 @@ export class NoteReactionEntityService implements OnModuleInit {
options?: {
withNote: boolean;
},
): Promise<Packed<'NoteReaction'>> {
): Promise<Serialized<Packed<'NoteReaction'>>> {
const opts = Object.assign({
withNote: false,
}, options);

View File

@ -7,6 +7,7 @@ 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';
@ -62,10 +63,10 @@ export class NotificationEntityService implements OnModuleInit {
},
hint?: {
packedNotes: Map<Note['id'], Packed<'Note'>>;
packedUsers: Map<User['id'], Packed<'User'>>;
packedNotes: Map<Note['id'], Serialized<Packed<'Note'>>>;
packedUsers: Map<User['id'], Serialized<Packed<'User'>>>;
},
): Promise<Packed<'Notification'>> {
): Promise<Serialized<Packed<'Notification'>>> {
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 ? (

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +32,7 @@ export class PageEntityService {
public async pack(
src: Page['id'] | Page,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'Page'>> {
): Promise<Serialized<Packed<'Page'>>> {
const meId = me ? me.id : null;
const page = typeof src === 'object' ? src : await this.pagesRepository.findOneByOrFail({ id: src });

View File

@ -1,7 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { PageLikesRepository } from '@/models/index.js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { PageLike } from '@/models/entities/PageLike.js';
import { PageEntityService } from './PageEntityService.js';

View File

@ -3,7 +3,7 @@ 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 { } from '@/models/entities/Blocking.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 +23,7 @@ export class RenoteMutingEntityService {
public async pack(
src: RenoteMuting['id'] | RenoteMuting,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'RenoteMuting'>> {
): Promise<Serialized<Packed<'RenoteMuting'>>> {
const muting = typeof src === 'object' ? src : await this.renoteMutingsRepository.findOneByOrFail({ id: src });
return await awaitAll({

View File

@ -8,8 +8,8 @@ import type { Role } from '@/models/entities/Role.js';
import { bindThis } from '@/decorators.js';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import { UserEntityService } from './UserEntityService.js';
import { Packed } from 'misskey-js';
import { Serialized } from 'schema-type';
import type { Packed } from 'misskey-js';
import type { Serialized } from 'schema-type';
@Injectable()
export class RoleEntityService {

View File

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { SigninsRepository } from '@/models/index.js';
import type { } from '@/models/entities/Blocking.js';
import type { Packed } from 'misskey-js';
import type { Signin } from '@/models/entities/Signin.js';
import { UserEntityService } from './UserEntityService.js';
import { bindThis } from '@/decorators.js';
@ -19,8 +19,7 @@ export class SigninEntityService {
@bindThis
public async pack(
src: Signin,
) {
): Promise<Packed<'SignIn'>> {
return src;
}
}

View File

@ -6,6 +6,7 @@ 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';
@ -23,13 +24,13 @@ import type { NoteEntityService } from './NoteEntityService.js';
import type { DriveFileEntityService } from './DriveFileEntityService.js';
import type { PageEntityService } from './PageEntityService.js';
type IsUserDetailed<Detailed extends boolean> = Detailed extends true ? Packed<'UserDetailed'> : Packed<'UserLite'>;
type IsUserDetailed<Detailed extends boolean> = Detailed extends true ? Serialized<Packed<'UserDetailed'>> : Serialized<Packed<'UserLite'>>;
type IsMeAndIsUserDetailed<ExpectsMe extends boolean | null, Detailed extends boolean> =
Detailed extends true ?
ExpectsMe extends true ? Packed<'MeDetailed'> :
ExpectsMe extends false ? Packed<'UserDetailedNotMe'> :
(Packed<'MeDetailed'> | Packed<'UserDetailedNotMe'>) :
Packed<'UserLite'>;
ExpectsMe extends true ? Serialized<Packed<'MeDetailed'>> :
ExpectsMe extends false ? Serialized<Packed<'UserDetailedNotMe'>> :
(Packed<'MeDetailed'> | Serialized<Packed<'UserDetailedNotMe'>>) :
Serialized<Packed<'UserLite'>>;
const ajv = new Ajv();

View File

@ -2,7 +2,7 @@ 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 { } from '@/models/entities/Blocking.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 +23,7 @@ export class UserListEntityService {
@bindThis
public async pack(
src: UserList['id'] | UserList,
): Promise<Packed<'UserList'>> {
): Promise<Serialized<Packed<'UserList'>>> {
const userList = typeof src === 'object' ? src : await this.userListsRepository.findOneByOrFail({ id: src });
const users = await this.userListJoiningsRepository.findBy({
@ -39,4 +39,3 @@ export class UserListEntityService {
};
}
}

View File

@ -88,7 +88,7 @@ export const packedNoteSchema = {
},
reactionAcceptance: {
oneOf: [{
enum: ['likeOnly', 'likeOnlyForRemote']
enum: ['likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote']
}, { type: 'null' }],
},
reactions: {
@ -107,7 +107,7 @@ export const packedNoteSchema = {
type: 'string',
},
myReaction: {
type: 'object',
type: 'string',
},
},
required: [

View File

@ -25,6 +25,9 @@ export const packedPageSchema = {
},
content: {
type: 'array',
items: {
type: 'object',
},
},
variables: {
type: 'array',

View File

@ -17,10 +17,15 @@ export const packedUserListSchema = {
type: 'array',
items: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
},
isPublic: {
type: 'boolean',
},
},
required: [
'id',
'createdAt',
'name',
'userIds',
'isPublic',
],
} as const satisfies JSONSchema7Definition;

View File

@ -630,7 +630,7 @@ importers:
version: 29.5.0
schema-type:
specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.1.3)
version: github.com/misskey-dev/schema-type/82e703e9b263916e8a1a6453384f41e378a24e3e(typescript@5.1.3)
packages/frontend:
dependencies:
@ -1036,7 +1036,7 @@ importers:
version: 4.4.0
schema-type:
specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4)
version: github.com/misskey-dev/schema-type/82e703e9b263916e8a1a6453384f41e378a24e3e(typescript@5.0.4)
ts-essentials:
specifier: ^9.3.2
version: 9.3.2(typescript@5.0.4)
@ -21755,9 +21755,9 @@ packages:
version: 0.0.0
dev: false
github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/65413af4ef676dafb5d06ebc04dce39c74b3a8f9}
id: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9
github.com/misskey-dev/schema-type/82e703e9b263916e8a1a6453384f41e378a24e3e(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/82e703e9b263916e8a1a6453384f41e378a24e3e}
id: github.com/misskey-dev/schema-type/82e703e9b263916e8a1a6453384f41e378a24e3e
name: schema-type
version: 1.0.0
dependencies:
@ -21768,9 +21768,9 @@ packages:
- typescript
dev: false
github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.1.3):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/65413af4ef676dafb5d06ebc04dce39c74b3a8f9}
id: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9
github.com/misskey-dev/schema-type/82e703e9b263916e8a1a6453384f41e378a24e3e(typescript@5.1.3):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/82e703e9b263916e8a1a6453384f41e378a24e3e}
id: github.com/misskey-dev/schema-type/82e703e9b263916e8a1a6453384f41e378a24e3e
name: schema-type
version: 1.0.0
dependencies: