This commit is contained in:
tamaina 2023-05-10 19:18:48 +00:00
parent ac99cdce8b
commit 4f5d77391f
50 changed files with 218 additions and 171 deletions

View file

@ -10,7 +10,7 @@ import { isUserRelated } from '@/misc/is-user-related.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { PushNotificationService } from '@/core/PushNotificationService.js';
import * as Acct from '@/misc/acct.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { DI } from '@/di-symbols.js';
import type { MutingsRepository, NotesRepository, AntennasRepository, UserListJoiningsRepository } from '@/models/index.js';
import { UtilityService } from '@/core/UtilityService.js';

View file

@ -16,7 +16,7 @@ import type {
UserListStreamTypes,
RoleTimelineStreamTypes,
} from '@/server/api/stream/types.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import { bindThis } from '@/decorators.js';

View file

@ -3,7 +3,7 @@ import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import { In } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { User } from '@/models/entities/User.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { Note } from '@/models/entities/Note.js';
import { IdService } from '@/core/IdService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';

View file

@ -3,7 +3,7 @@ import push from 'web-push';
import * as Redis from 'ioredis';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import type { Packed } from '@/misc/json-schema';
import type { Packed } from 'misskey-js';
import { getNoteSummary } from '@/misc/get-note-summary.js';
import type { SwSubscription, SwSubscriptionsRepository } from '@/models/index.js';
import { MetaService } from '@/core/MetaService.js';

View file

@ -13,7 +13,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { StreamMessages } from '@/server/api/stream/types.js';
import { IdService } from '@/core/IdService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import type { Packed } from '@/misc/json-schema';
import type { Packed } from 'misskey-js';
import type { OnApplicationShutdown } from '@nestjs/common';
export type RolePolicies = {

View file

@ -107,7 +107,10 @@ export class UserBlockingService implements OnModuleInit {
if (this.userEntityService.isLocalUser(followee)) {
this.userEntityService.pack(followee, followee, {
detail: true,
}).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed));
}).then(packed => {
this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed);
return packed; // somehow this is needed by typescript
});
}
if (this.userEntityService.isLocalUser(follower) && !silent) {
@ -122,6 +125,8 @@ export class UserBlockingService implements OnModuleInit {
user: packed,
});
}
return packed; // somehow this is needed by typescript
});
}

View file

@ -7,7 +7,7 @@ import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { IdService } from '@/core/IdService.js';
import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import InstanceChart from '@/core/chart/charts/instance.js';
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
import { WebhookService } from '@/core/WebhookService.js';
@ -267,7 +267,7 @@ export class UserFollowingService implements OnModuleInit {
this.userEntityService.pack(followee.id, follower, {
detail: true,
}).then(async packed => {
this.globalEventService.publishMainStream(follower.id, 'follow', packed as Packed<'UserDetailedNotMe'>);
this.globalEventService.publishMainStream(follower.id, 'follow', packed);
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow'));
for (const webhook of webhooks) {

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AntennasRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { Antenna } from '@/models/entities/Antenna.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AccessTokensRepository, AppsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { App } from '@/models/entities/App.js';
import type { User } from '@/models/entities/User.js';
import { bindThis } from '@/decorators.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { BlockingsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { Blocking } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,7 +1,7 @@
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { Channel } from '@/models/entities/Channel.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { Clip } from '@/models/entities/Clip.js';
import { bindThis } from '@/decorators.js';

View file

@ -3,7 +3,7 @@ import { DataSource, In } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { NotesRepository, DriveFilesRepository } from '@/models/index.js';
import type { Config } from '@/config.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { User } from '@/models/entities/User.js';
import type { DriveFile } from '@/models/entities/DriveFile.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { DriveFolder } from '@/models/entities/DriveFolder.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { EmojisRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.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

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { Flash } from '@/models/entities/Flash.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { Following } from '@/models/entities/Following.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { GalleryPost } from '@/models/entities/GalleryPost.js';

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { HashtagsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.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';

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { InstancesRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { Instance } from '@/models/entities/Instance.js';
import { MetaService } from '@/core/MetaService.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { Muting } from '@/models/entities/Muting.js';

View file

@ -3,7 +3,7 @@ import { DataSource, In } from 'typeorm';
import * as mfm from 'mfm-js';
import { ModuleRef } from '@nestjs/core';
import { DI } from '@/di-symbols.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { nyaize } from '@/misc/nyaize.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { User } from '@/models/entities/User.js';

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { NoteReactionsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { bindThis } from '@/decorators.js';
import type { OnModuleInit } from '@nestjs/common';
import type { } from '@/models/entities/Blocking.js';

View file

@ -6,7 +6,7 @@ import type { AccessTokensRepository, FollowRequestsRepository, NoteReactionsRep
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { bindThis } from '@/decorators.js';
import { isNotNull } from '@/misc/is-not-null.js';
import { notificationTypes } from 'misskey-js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { Page } from '@/models/entities/Page.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { RenoteMuting } from '@/models/entities/RenoteMuting.js';

View file

@ -5,7 +5,7 @@ import Ajv from 'ajv';
import { ModuleRef } from '@nestjs/core';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
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';
@ -28,7 +28,7 @@ type IsMeAndIsUserDetailed<ExpectsMe extends boolean | null, Detailed extends bo
Detailed extends true ?
ExpectsMe extends true ? Packed<'MeDetailed'> :
ExpectsMe extends false ? Packed<'UserDetailedNotMe'> :
Packed<'UserDetailed'> :
(Packed<'MeDetailed'> | Packed<'UserDetailedNotMe'>) :
Packed<'UserLite'>;
const ajv = new Ajv();
@ -290,7 +290,7 @@ export class UserEntityService implements OnModuleInit {
return `${this.config.url}/users/${userId}`;
}
public async pack<ExpectsMe extends boolean | null = null, D extends boolean = false>(
public async pack<ExpectsMe extends boolean | null = null, D extends boolean = false, R = IsMeAndIsUserDetailed<ExpectsMe, D>>(
src: User['id'] | User,
me?: { id: User['id']; } | null | undefined,
options?: {
@ -298,7 +298,7 @@ export class UserEntityService implements OnModuleInit {
includeSecrets?: boolean,
userProfile?: UserProfile,
},
): Promise<IsMeAndIsUserDetailed<ExpectsMe, D>> {
): Promise<R> {
const opts = Object.assign({
detail: false,
includeSecrets: false,
@ -499,19 +499,19 @@ export class UserEntityService implements OnModuleInit {
isMuted: relation.isMuted,
isRenoteMuted: relation.isRenoteMuted,
} : {}),
} as Promiseable<Packed<'User'>> as Promiseable<IsMeAndIsUserDetailed<ExpectsMe, D>>;
} as Promiseable<R>;
return await awaitAll(packed);
}
public packMany<D extends boolean = false>(
public packMany<D extends boolean = false, R = IsUserDetailed<D>>(
users: (User['id'] | User)[],
me?: { id: User['id'] } | null | undefined,
options?: {
detail?: D,
includeSecrets?: boolean,
},
): Promise<IsUserDetailed<D>[]> {
return Promise.all(users.map(u => this.pack(u, me, options)));
): Promise<R[]> {
return Promise.all(users.map(u => this.pack<null, D, R>(u, me, options)));
}
}

View file

@ -1,7 +1,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 '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { } from '@/models/entities/Blocking.js';
import type { UserList } from '@/models/entities/UserList.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,4 +1,4 @@
import type { Packed } from './json-schema.js';
import type { Packed } from 'misskey-js';
/**
* 稿

View file

@ -1,4 +1,4 @@
import type { Packed } from './json-schema.js';
import type { Packed } from 'misskey-js';
export function isInstanceMuted(note: Packed<'Note'>, mutedInstances: Set<string>): boolean {
if (mutedInstances.has(note.user.host ?? '')) return true;

View file

@ -1,4 +1,4 @@
import { notificationTypes } from 'misskey-js';
import { ACHIEVEMENT_TYPES, notificationTypes } from 'misskey-js';
import { User } from './User.js';
import { Note } from './Note.js';
import { FollowRequest } from './FollowRequest.js';
@ -39,7 +39,7 @@ export type Notification = {
choice: number | null;
achievement: string | null;
achievement: typeof ACHIEVEMENT_TYPES[number] | null;
/**
* body

View file

@ -1,4 +1,4 @@
import type { Schema } from '@/misc/json-schema.js';
import type { JSONSchema7 } from 'schema-type';
import { RolePolicies } from '@/core/RoleService.js';
import * as ep___admin_meta from './endpoints/admin/meta.js';
@ -686,7 +686,7 @@ export interface IEndpointMeta {
};
};
readonly res?: Schema;
readonly res?: JSONSchema7;
/**
*
@ -775,7 +775,7 @@ export interface IEndpointMeta {
export interface IEndpoint {
name: string;
meta: IEndpointMeta;
params: Schema;
params: JSONSchema7;
}
const endpoints: IEndpoint[] = (eps as [string, any]).map(([name, ep]) => {

View file

@ -1,7 +1,7 @@
import type { Schema } from '@/misc/json-schema.js';
import type { JSONSchema7 } from 'schema-type';
import { refs } from 'misskey-js';
export function convertSchemaToOpenApiSchema(schema: Schema) {
export function convertSchemaToOpenApiSchema(schema: JSONSchema7) {
const res: any = schema;
if (schema.type === 'object' && schema.properties) {

View file

@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { isUserRelated } from '@/misc/is-user-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';
import Channel from '../channel.js';

View file

@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { checkWordMute } from '@/misc/check-word-mute.js';
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { MetaService } from '@/core/MetaService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';
import Channel from '../channel.js';

View file

@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { checkWordMute } from '@/misc/check-word-mute.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';
import Channel from '../channel.js';

View file

@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { checkWordMute } from '@/misc/check-word-mute.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { MetaService } from '@/core/MetaService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { checkWordMute } from '@/misc/check-word-mute.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { MetaService } from '@/core/MetaService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { isUserRelated } from '@/misc/is-user-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';
import Channel from '../channel.js';

View file

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
import type { UserListJoiningsRepository, UserListsRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';

View file

@ -1,6 +1,6 @@
import type { User } from '@/models/entities/User.js';
import type { AccessToken } from '@/models/entities/AccessToken.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { NoteReadService } from '@/core/NoteReadService.js';
import type { NotificationService } from '@/core/NotificationService.js';
import { bindThis } from '@/decorators.js';

View file

@ -9,7 +9,7 @@ import type { UserList } from '@/models/entities/UserList.js';
import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js';
import type { Signin } from '@/models/entities/Signin.js';
import type { Page } from '@/models/entities/Page.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import type { Webhook } from '@/models/entities/Webhook.js';
import type { Meta } from '@/models/entities/Meta.js';
import { Role, RoleAssignment } from '@/models';

View file

@ -3,7 +3,7 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import { JTDDataType } from 'ajv/dist/jtd';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import { paramDef as CreateParamDef } from '@/server/api/endpoints/clips/create.js';
import { paramDef as UpdateParamDef } from '@/server/api/endpoints/clips/update.js';
import { paramDef as DeleteParamDef } from '@/server/api/endpoints/clips/delete.js';

View file

@ -3,7 +3,7 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import { inspect } from 'node:util';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Packed } from 'misskey-js';
import {
signup,
post,

View file

@ -8,10 +8,13 @@ import {
packedUserDetailedSchema,
packedUserSchema,
} from './schemas/user.js';
import {
packedNotificationSchema,
packedNotificationStrictSchema,
} from './schemas/notification.js';
import { packedNoteSchema } from './schemas/note.js';
import { packedUserListSchema } from './schemas/user-list.js';
import { packedAppSchema } from './schemas/app.js';
import { packedNotificationSchema } from './schemas/notification.js';
import { packedDriveFileSchema } from './schemas/drive-file.js';
import { packedDriveFolderSchema } from './schemas/drive-folder.js';
import { packedFollowingSchema } from './schemas/following.js';
@ -49,6 +52,7 @@ export const refs = {
NoteReaction: packedNoteReactionSchema,
NoteFavorite: packedNoteFavoriteSchema,
Notification: packedNotificationSchema,
NotificationStrict: packedNotificationStrictSchema,
DriveFile: packedDriveFileSchema,
DriveFolder: packedDriveFolderSchema,
Following: packedFollowingSchema,

View file

@ -111,7 +111,7 @@ export const packedDriveFileSchema = {
'md5',
'size',
'isSensitive',
'burlhash',
'blurhash',
'properties',
'url',
'thumbnailUrl',

View file

@ -17,10 +17,10 @@ export const packedNoteSchema = {
}, { type: 'null' }],
},
text: {
type: 'string',
type: ['string', 'null'],
},
cw: {
oneOf: [{ type: 'string' }, { type: 'null' }],
type: ['string', 'null'],
},
userId: {
$ref: 'https://misskey-hub.net/api/schemas/Id',

View file

@ -1,117 +1,155 @@
import type { JSONSchema7Definition } from 'schema-type';
import { ACHIEVEMENT_TYPES } from '../consts';
import { ACHIEVEMENT_TYPES, notificationTypes } from '../consts';
export const packedNotificationSchema = {
$id: 'https://misskey-hub.net/api/schemas/Notification',
type: 'object',
properties: {
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
createdAt: {
type: 'string',
format: 'date-time',
},
type: {
type: 'string',
enum: [...notificationTypes],
},
userId: {
oneOf: [
{ $ref: 'https://misskey-hub.net/api/schemas/Id' },
{ type: 'null' },
]
},
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
reaction: { type: ['string', 'null'] },
achievement: {
oneOf: [
{ enum: [...ACHIEVEMENT_TYPES] },
{ type: 'null' },
],
},
header: { type: ['string', 'null'] },
body: { type: ['string', 'null'] },
icon: { type: ['string', 'null'] },
},
required: ['id', 'createdAt'],
} as const satisfies JSONSchema7Definition;
export const packedNotificationStrictSchema = {
$id: 'https://misskey-hub.net/api/schemas/PackedNotificationStrict',
type: 'object',
allOf: [{
type: 'object',
properties: {
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
createdAt: {
type: 'string',
format: 'date-time',
},
},
required: ['id', 'createdAt'],
}, {
oneOf: [
allOf: [
{
type: 'object',
properties: {
type: { const: 'follow' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
createdAt: {
type: 'string',
format: 'date-time',
},
},
required: ['type', 'userId', 'user'],
}, {
required: ['id', 'createdAt'],
},
{
type: 'object',
properties: {
type: { const: 'mention' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'reply' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'renote' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'quote' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'reaction' },
reaction: { type: 'string' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'reaction', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'pollEnded' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'receiveFollowRequest' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
},
required: ['type', 'userId', 'user'],
}, {
type: 'object',
properties: {
type: { const: 'followRequestAccepted' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
},
required: ['type', 'userId', 'user'],
}, {
type: 'object',
properties: {
type: { const: 'achievementEarned' },
achievement: { enum: [...ACHIEVEMENT_TYPES] },
},
required: ['type', 'achievement'],
}, {
type: 'object',
properties: {
type: { const: 'app' },
header: { type: ['string', 'null'] },
body: { type: 'string' },
icon: { type: ['string', 'null'] },
},
required: ['type'],
}],
}],
oneOf: [{
type: 'object',
properties: {
type: { const: 'follow' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
},
required: ['type', 'userId', 'user'],
}, {
type: 'object',
properties: {
type: { const: 'mention' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'reply' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'renote' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'quote' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'reaction' },
reaction: { type: 'string' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'reaction', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'pollEnded' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
},
required: ['type', 'userId', 'user', 'note'],
}, {
type: 'object',
properties: {
type: { const: 'receiveFollowRequest' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
},
required: ['type', 'userId', 'user'],
}, {
type: 'object',
properties: {
type: { const: 'followRequestAccepted' },
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
},
required: ['type', 'userId', 'user'],
}, {
type: 'object',
properties: {
type: { const: 'achievementEarned' },
achievement: { enum: [...ACHIEVEMENT_TYPES] },
},
required: ['type', 'achievement'],
}, {
type: 'object',
properties: {
type: { const: 'app' },
header: { type: ['string', 'null'] },
body: { type: 'string' },
icon: { type: ['string', 'null'] },
},
required: ['type'],
}],
},
],
} as const satisfies JSONSchema7Definition;

View file

@ -623,7 +623,7 @@ importers:
version: 29.5.0
schema-type:
specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b(typescript@5.0.4)
version: github.com/misskey-dev/schema-type/95e048769927fe897731f4c4f2c9a4fefeded5fc(typescript@5.0.4)
packages/frontend:
dependencies:
@ -1023,7 +1023,7 @@ importers:
version: 4.4.0
schema-type:
specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b(typescript@5.0.4)
version: github.com/misskey-dev/schema-type/95e048769927fe897731f4c4f2c9a4fefeded5fc(typescript@5.0.4)
ts-essentials:
specifier: ^9.3.2
version: 9.3.2(typescript@5.0.4)
@ -20323,9 +20323,9 @@ packages:
version: 2.2.1-misskey.3
dev: false
github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/c771673a44d514658d4d5a4dd2c201b2294f225b}
id: github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b
github.com/misskey-dev/schema-type/95e048769927fe897731f4c4f2c9a4fefeded5fc(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/95e048769927fe897731f4c4f2c9a4fefeded5fc}
id: github.com/misskey-dev/schema-type/95e048769927fe897731f4c4f2c9a4fefeded5fc
name: schema-type
version: 1.0.0
dependencies: