From 59a5d00d6b9d46e09eb4b024e5135246853dff5c Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 14 Jan 2022 03:16:39 +0900 Subject: [PATCH] Delete SimpleSchema/SimpleObj and Move schemas to dedicated files --- packages/backend/src/misc/schema.ts | 59 ++-- packages/backend/src/misc/simple-schema.ts | 15 - .../src/models/repositories/antenna.ts | 91 ----- .../backend/src/models/repositories/app.ts | 35 -- .../src/models/repositories/blocking.ts | 28 -- .../src/models/repositories/channel.ts | 53 --- .../backend/src/models/repositories/clip.ts | 39 --- .../src/models/repositories/drive-file.ts | 109 ------ .../src/models/repositories/drive-folder.ts | 41 --- .../backend/src/models/repositories/emoji.ts | 38 --- .../repositories/federation-instance.ts | 104 ------ .../src/models/repositories/following.ts | 38 --- .../src/models/repositories/gallery-post.ts | 71 ---- .../src/models/repositories/hashtag.ts | 36 -- .../models/repositories/messaging-message.ts | 75 ----- .../backend/src/models/repositories/muting.ts | 28 -- .../src/models/repositories/note-favorite.ts | 28 -- .../src/models/repositories/note-reaction.ts | 27 -- .../backend/src/models/repositories/note.ts | 185 ----------- .../src/models/repositories/notification.ts | 66 ---- .../backend/src/models/repositories/page.ts | 53 --- .../src/models/repositories/user-group.ts | 36 -- .../src/models/repositories/user-list.ts | 31 -- .../backend/src/models/repositories/user.ts | 310 ------------------ packages/backend/src/models/schema/antenna.ts | 90 +++++ packages/backend/src/models/schema/app.ts | 34 ++ .../backend/src/models/schema/blocking.ts | 27 ++ packages/backend/src/models/schema/channel.ts | 52 +++ packages/backend/src/models/schema/clip.ts | 39 +++ .../backend/src/models/schema/drive-file.ts | 108 ++++++ .../backend/src/models/schema/drive-folder.ts | 40 +++ packages/backend/src/models/schema/emoji.ts | 37 +++ .../src/models/schema/federation-instance.ts | 106 ++++++ .../backend/src/models/schema/following.ts | 37 +++ .../backend/src/models/schema/gallery-post.ts | 70 ++++ packages/backend/src/models/schema/hashtag.ts | 35 ++ .../src/models/schema/messaging-message.ts | 74 +++++ packages/backend/src/models/schema/muting.ts | 27 ++ .../src/models/schema/note-favorite.ts | 27 ++ .../src/models/schema/note-reaction.ts | 26 ++ packages/backend/src/models/schema/note.ts | 184 +++++++++++ .../backend/src/models/schema/notification.ts | 67 ++++ packages/backend/src/models/schema/page.ts | 52 +++ .../models/{repositories => schema}/queue.ts | 0 .../backend/src/models/schema/user-group.ts | 35 ++ .../backend/src/models/schema/user-list.ts | 30 ++ packages/backend/src/models/schema/user.ts | 309 +++++++++++++++++ packages/backend/src/services/chart/core.ts | 14 +- 48 files changed, 1546 insertions(+), 1570 deletions(-) delete mode 100644 packages/backend/src/misc/simple-schema.ts create mode 100644 packages/backend/src/models/schema/antenna.ts create mode 100644 packages/backend/src/models/schema/app.ts create mode 100644 packages/backend/src/models/schema/blocking.ts create mode 100644 packages/backend/src/models/schema/channel.ts create mode 100644 packages/backend/src/models/schema/clip.ts create mode 100644 packages/backend/src/models/schema/drive-file.ts create mode 100644 packages/backend/src/models/schema/drive-folder.ts create mode 100644 packages/backend/src/models/schema/emoji.ts create mode 100644 packages/backend/src/models/schema/federation-instance.ts create mode 100644 packages/backend/src/models/schema/following.ts create mode 100644 packages/backend/src/models/schema/gallery-post.ts create mode 100644 packages/backend/src/models/schema/hashtag.ts create mode 100644 packages/backend/src/models/schema/messaging-message.ts create mode 100644 packages/backend/src/models/schema/muting.ts create mode 100644 packages/backend/src/models/schema/note-favorite.ts create mode 100644 packages/backend/src/models/schema/note-reaction.ts create mode 100644 packages/backend/src/models/schema/note.ts create mode 100644 packages/backend/src/models/schema/notification.ts create mode 100644 packages/backend/src/models/schema/page.ts rename packages/backend/src/models/{repositories => schema}/queue.ts (100%) create mode 100644 packages/backend/src/models/schema/user-group.ts create mode 100644 packages/backend/src/models/schema/user-list.ts create mode 100644 packages/backend/src/models/schema/user.ts diff --git a/packages/backend/src/misc/schema.ts b/packages/backend/src/misc/schema.ts index ae6f1bac86..3dbc0239ca 100644 --- a/packages/backend/src/misc/schema.ts +++ b/packages/backend/src/misc/schema.ts @@ -1,27 +1,26 @@ -import { SimpleObj, SimpleSchema } from './simple-schema'; -import { packedUserSchema } from '@/models/repositories/user'; -import { packedNoteSchema } from '@/models/repositories/note'; -import { packedUserListSchema } from '@/models/repositories/user-list'; -import { packedAppSchema } from '@/models/repositories/app'; -import { packedMessagingMessageSchema } from '@/models/repositories/messaging-message'; -import { packedNotificationSchema } from '@/models/repositories/notification'; -import { packedDriveFileSchema } from '@/models/repositories/drive-file'; -import { packedDriveFolderSchema } from '@/models/repositories/drive-folder'; -import { packedFollowingSchema } from '@/models/repositories/following'; -import { packedMutingSchema } from '@/models/repositories/muting'; -import { packedBlockingSchema } from '@/models/repositories/blocking'; -import { packedNoteReactionSchema } from '@/models/repositories/note-reaction'; -import { packedHashtagSchema } from '@/models/repositories/hashtag'; -import { packedPageSchema } from '@/models/repositories/page'; -import { packedUserGroupSchema } from '@/models/repositories/user-group'; -import { packedNoteFavoriteSchema } from '@/models/repositories/note-favorite'; -import { packedChannelSchema } from '@/models/repositories/channel'; -import { packedAntennaSchema } from '@/models/repositories/antenna'; -import { packedClipSchema } from '@/models/repositories/clip'; -import { packedFederationInstanceSchema } from '@/models/repositories/federation-instance'; -import { packedQueueCountSchema } from '@/models/repositories/queue'; -import { packedGalleryPostSchema } from '@/models/repositories/gallery-post'; -import { packedEmojiSchema } from '@/models/repositories/emoji'; +import { packedUserSchema } from '@/models/schema/user'; +import { packedNoteSchema } from '@/models/schema/note'; +import { packedUserListSchema } from '@/models/schema/user-list'; +import { packedAppSchema } from '@/models/schema/app'; +import { packedMessagingMessageSchema } from '@/models/schema/messaging-message'; +import { packedNotificationSchema } from '@/models/schema/notification'; +import { packedDriveFileSchema } from '@/models/schema/drive-file'; +import { packedDriveFolderSchema } from '@/models/schema/drive-folder'; +import { packedFollowingSchema } from '@/models/schema/following'; +import { packedMutingSchema } from '@/models/schema/muting'; +import { packedBlockingSchema } from '@/models/schema/blocking'; +import { packedNoteReactionSchema } from '@/models/schema/note-reaction'; +import { packedHashtagSchema } from '@/models/schema/hashtag'; +import { packedPageSchema } from '@/models/schema/page'; +import { packedUserGroupSchema } from '@/models/schema/user-group'; +import { packedNoteFavoriteSchema } from '@/models/schema/note-favorite'; +import { packedChannelSchema } from '@/models/schema/channel'; +import { packedAntennaSchema } from '@/models/schema/antenna'; +import { packedClipSchema } from '@/models/schema/clip'; +import { packedFederationInstanceSchema } from '@/models/schema/federation-instance'; +import { packedQueueCountSchema } from '@/models/schema/queue'; +import { packedGalleryPostSchema } from '@/models/schema/gallery-post'; +import { packedEmojiSchema } from '@/models/schema/emoji'; export const refs = { User: packedUserSchema, @@ -51,10 +50,18 @@ export const refs = { export type Packed = ObjType<(typeof refs[x])['properties']>; -export interface Schema extends SimpleSchema { +export interface Schema { + type: 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any'; + nullable: boolean; + optional: boolean; items?: Schema; properties?: Obj; + description?: string; + example?: any; + format?: string; ref?: keyof typeof refs; + enum?: string[]; + default?: boolean | null; } type NonUndefinedPropertyNames = { @@ -68,7 +75,7 @@ type UndefinedPropertyNames = { type OnlyRequired = Pick>; type OnlyOptional = Pick>; -export interface Obj extends SimpleObj { [key: string]: Schema; } +export interface Obj { [key: string]: Schema; } export type ObjType = { [P in keyof OnlyOptional]?: SchemaType } & diff --git a/packages/backend/src/misc/simple-schema.ts b/packages/backend/src/misc/simple-schema.ts deleted file mode 100644 index abbb348e24..0000000000 --- a/packages/backend/src/misc/simple-schema.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface SimpleSchema { - type: 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any'; - nullable: boolean; - optional: boolean; - items?: SimpleSchema; - properties?: SimpleObj; - description?: string; - example?: any; - format?: string; - ref?: string; - enum?: string[]; - default?: boolean | null; -} - -export interface SimpleObj { [key: string]: SimpleSchema; } diff --git a/packages/backend/src/models/repositories/antenna.ts b/packages/backend/src/models/repositories/antenna.ts index 548f44f1b7..3bf0645a7f 100644 --- a/packages/backend/src/models/repositories/antenna.ts +++ b/packages/backend/src/models/repositories/antenna.ts @@ -31,94 +31,3 @@ export class AntennaRepository extends Repository { }; } } - -export const packedAntennaSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - keywords: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - }, - excludeKeywords: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - }, - src: { - type: 'string' as const, - optional: false as const, nullable: false as const, - enum: ['home', 'all', 'users', 'list', 'group'], - }, - userListId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - userGroupId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - users: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - caseSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - default: false, - }, - notify: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - withReplies: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - default: false, - }, - withFile: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - hasUnreadNote: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - default: false, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/app.ts b/packages/backend/src/models/repositories/app.ts index bec0765ac2..6bac4d9598 100644 --- a/packages/backend/src/models/repositories/app.ts +++ b/packages/backend/src/models/repositories/app.ts @@ -38,38 +38,3 @@ export class AppRepository extends Repository { }; } } - -export const packedAppSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - callbackUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - permission: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - secret: { - type: 'string' as const, - optional: true as const, nullable: false as const, - }, - isAuthorized: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/blocking.ts b/packages/backend/src/models/repositories/blocking.ts index a6895eabf4..c20b02f501 100644 --- a/packages/backend/src/models/repositories/blocking.ts +++ b/packages/backend/src/models/repositories/blocking.ts @@ -30,31 +30,3 @@ export class BlockingRepository extends Repository { return Promise.all(blockings.map(x => this.pack(x, me))); } } - -export const packedBlockingSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - blockeeId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - blockee: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/channel.ts b/packages/backend/src/models/repositories/channel.ts index 0a6b02f495..b3afb823ab 100644 --- a/packages/backend/src/models/repositories/channel.ts +++ b/packages/backend/src/models/repositories/channel.ts @@ -40,56 +40,3 @@ export class ChannelRepository extends Repository { }; } } - -export const packedChannelSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - lastNotedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - description: { - type: 'string' as const, - nullable: true as const, optional: false as const, - }, - bannerUrl: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: false as const, - }, - notesCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, - }, - usersCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, - }, - isFollowing: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - userId: { - type: 'string' as const, - nullable: true as const, optional: false as const, - format: 'id', - }, - }, -}; diff --git a/packages/backend/src/models/repositories/clip.ts b/packages/backend/src/models/repositories/clip.ts index 7892811d48..6f9ceeb50a 100644 --- a/packages/backend/src/models/repositories/clip.ts +++ b/packages/backend/src/models/repositories/clip.ts @@ -29,42 +29,3 @@ export class ClipRepository extends Repository { } } -export const packedClipSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - description: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - isPublic: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/drive-file.ts b/packages/backend/src/models/repositories/drive-file.ts index 79b890aa6e..413c4ae639 100644 --- a/packages/backend/src/models/repositories/drive-file.ts +++ b/packages/backend/src/models/repositories/drive-file.ts @@ -156,112 +156,3 @@ export class DriveFileRepository extends Repository { return items.filter(x => x != null); } } - -export const packedDriveFileSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'lenna.jpg', - }, - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'image/jpeg', - }, - md5: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'md5', - example: '15eca7fba0480996e2245f5185bf39f2', - }, - size: { - type: 'number' as const, - optional: false as const, nullable: false as const, - example: 51469, - }, - isSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - blurhash: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - properties: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - width: { - type: 'number' as const, - optional: true as const, nullable: false as const, - example: 1280, - }, - height: { - type: 'number' as const, - optional: true as const, nullable: false as const, - example: 720, - }, - orientation: { - type: 'number' as const, - optional: true as const, nullable: false as const, - example: 8, - }, - avgColor: { - type: 'string' as const, - optional: true as const, nullable: false as const, - example: 'rgb(40,65,87)', - }, - }, - }, - url: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'url', - }, - thumbnailUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'url', - }, - comment: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - folderId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - folder: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'DriveFolder' as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - user: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/drive-folder.ts b/packages/backend/src/models/repositories/drive-folder.ts index 4ee4a68e08..b2e6cee9b8 100644 --- a/packages/backend/src/models/repositories/drive-folder.ts +++ b/packages/backend/src/models/repositories/drive-folder.ts @@ -48,44 +48,3 @@ export class DriveFolderRepository extends Repository { }); } } - -export const packedDriveFolderSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - foldersCount: { - type: 'number' as const, - optional: true as const, nullable: false as const, - }, - filesCount: { - type: 'number' as const, - optional: true as const, nullable: false as const, - }, - parentId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - parent: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'DriveFolder' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/emoji.ts b/packages/backend/src/models/repositories/emoji.ts index b7529595a9..9d63ced811 100644 --- a/packages/backend/src/models/repositories/emoji.ts +++ b/packages/backend/src/models/repositories/emoji.ts @@ -25,41 +25,3 @@ export class EmojiRepository extends Repository { return Promise.all(emojis.map(x => this.pack(x))); } } - -export const packedEmojiSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - aliases: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - category: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - host: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - url: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/federation-instance.ts b/packages/backend/src/models/repositories/federation-instance.ts index 90dbbaab1c..426fd5bfc3 100644 --- a/packages/backend/src/models/repositories/federation-instance.ts +++ b/packages/backend/src/models/repositories/federation-instance.ts @@ -1,106 +1,2 @@ import config from '@/config/index'; -export const packedFederationInstanceSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - caughtAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - host: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'misskey.example.com', - }, - usersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - notesCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - followingCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - followersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - driveUsage: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - driveFiles: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - latestRequestSentAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'date-time', - }, - lastCommunicatedAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - isNotResponding: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - isSuspended: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - softwareName: { - type: 'string' as const, - optional: false as const, nullable: true as const, - example: 'misskey', - }, - softwareVersion: { - type: 'string' as const, - optional: false as const, nullable: true as const, - example: config.version, - }, - openRegistrations: { - type: 'boolean' as const, - optional: false as const, nullable: true as const, - example: true, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - description: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - maintainerName: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - maintainerEmail: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - iconUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'url', - }, - infoUpdatedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'date-time', - }, - }, -}; diff --git a/packages/backend/src/models/repositories/following.ts b/packages/backend/src/models/repositories/following.ts index 1dfaaf908a..9d20f442df 100644 --- a/packages/backend/src/models/repositories/following.ts +++ b/packages/backend/src/models/repositories/following.ts @@ -84,41 +84,3 @@ export class FollowingRepository extends Repository { return Promise.all(followings.map(x => this.pack(x, me, opts))); } } - -export const packedFollowingSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - followeeId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - followee: { - type: 'object' as const, - optional: true as const, nullable: false as const, - ref: 'User' as const, - }, - followerId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - follower: { - type: 'object' as const, - optional: true as const, nullable: false as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/gallery-post.ts b/packages/backend/src/models/repositories/gallery-post.ts index 6d37e3120e..e9233bb91e 100644 --- a/packages/backend/src/models/repositories/gallery-post.ts +++ b/packages/backend/src/models/repositories/gallery-post.ts @@ -38,74 +38,3 @@ export class GalleryPostRepository extends Repository { return Promise.all(posts.map(x => this.pack(x, me))); } } - -export const packedGalleryPostSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - updatedAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - title: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - description: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - fileIds: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - files: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'DriveFile' as const, - }, - }, - tags: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - isSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/hashtag.ts b/packages/backend/src/models/repositories/hashtag.ts index 6e513c7ebb..c4b8d50c4e 100644 --- a/packages/backend/src/models/repositories/hashtag.ts +++ b/packages/backend/src/models/repositories/hashtag.ts @@ -24,39 +24,3 @@ export class HashtagRepository extends Repository { return Promise.all(hashtags.map(x => this.pack(x))); } } - -export const packedHashtagSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - tag: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'misskey', - }, - mentionedUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - mentionedLocalUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - mentionedRemoteUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - attachedUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - attachedLocalUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - attachedRemoteUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/messaging-message.ts b/packages/backend/src/models/repositories/messaging-message.ts index 1b2dd3a246..0a342430b9 100644 --- a/packages/backend/src/models/repositories/messaging-message.ts +++ b/packages/backend/src/models/repositories/messaging-message.ts @@ -42,78 +42,3 @@ export class MessagingMessageRepository extends Repository { }; } } - -export const packedMessagingMessageSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: true as const, nullable: false as const, - }, - text: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - fileId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - }, - file: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'DriveFile' as const, - }, - recipientId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - recipient: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'User' as const, - }, - groupId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - group: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'UserGroup' as const, - }, - isRead: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - reads: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/muting.ts b/packages/backend/src/models/repositories/muting.ts index b82d1f0daa..bdbe9b47da 100644 --- a/packages/backend/src/models/repositories/muting.ts +++ b/packages/backend/src/models/repositories/muting.ts @@ -30,31 +30,3 @@ export class MutingRepository extends Repository { return Promise.all(mutings.map(x => this.pack(x, me))); } } - -export const packedMutingSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - muteeId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - mutee: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/note-favorite.ts b/packages/backend/src/models/repositories/note-favorite.ts index 47586a9116..c5de55c0c0 100644 --- a/packages/backend/src/models/repositories/note-favorite.ts +++ b/packages/backend/src/models/repositories/note-favorite.ts @@ -26,31 +26,3 @@ export class NoteFavoriteRepository extends Repository { return Promise.all(favorites.map(x => this.pack(x, me))); } } - -export const packedNoteFavoriteSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - note: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'Note' as const, - }, - noteId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, -}; diff --git a/packages/backend/src/models/repositories/note-reaction.ts b/packages/backend/src/models/repositories/note-reaction.ts index dfb25cbea1..097574effa 100644 --- a/packages/backend/src/models/repositories/note-reaction.ts +++ b/packages/backend/src/models/repositories/note-reaction.ts @@ -31,30 +31,3 @@ export class NoteReactionRepository extends Repository { }; } } - -export const packedNoteReactionSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - user: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User' as const, - }, - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 96dfad70e9..dc3a4c7cba 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -320,188 +320,3 @@ export class NoteRepository extends Repository { }))); } } - -export const packedNoteSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - text: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - cw: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - replyId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - renoteId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - reply: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'Note' as const, - }, - renote: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'Note' as const, - }, - isHidden: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - visibility: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - mentions: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - visibleUserIds: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - fileIds: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - files: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'DriveFile' as const, - }, - }, - tags: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - poll: { - type: 'object' as const, - optional: true as const, nullable: true as const, - }, - channelId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - channel: { - type: 'object' as const, - optional: true as const, nullable: true as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - }, - }, - }, - localOnly: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - emojis: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - url: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - }, - }, - }, - reactions: { - type: 'object' as const, - optional: false as const, nullable: false as const, - }, - renoteCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - repliesCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - uri: { - type: 'string' as const, - optional: true as const, nullable: false as const, - }, - url: { - type: 'string' as const, - optional: true as const, nullable: false as const, - }, - - myReaction: { - type: 'object' as const, - optional: true as const, nullable: true as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/notification.ts b/packages/backend/src/models/repositories/notification.ts index 47d569ed21..5e42798898 100644 --- a/packages/backend/src/models/repositories/notification.ts +++ b/packages/backend/src/models/repositories/notification.ts @@ -107,69 +107,3 @@ export class NotificationRepository extends Repository { }))); } } - -export const packedNotificationSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - isRead: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - enum: [...notificationTypes], - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: true as const, nullable: true as const, - }, - userId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - }, - note: { - type: 'object' as const, - ref: 'Note' as const, - optional: true as const, nullable: true as const, - }, - reaction: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - choice: { - type: 'number' as const, - optional: true as const, nullable: true as const, - }, - invitation: { - type: 'object' as const, - optional: true as const, nullable: true as const, - }, - body: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - header: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - icon: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/page.ts b/packages/backend/src/models/repositories/page.ts index 46b453cad9..ec76c2e418 100644 --- a/packages/backend/src/models/repositories/page.ts +++ b/packages/backend/src/models/repositories/page.ts @@ -87,56 +87,3 @@ export class PageRepository extends Repository { return Promise.all(pages.map(x => this.pack(x, me))); } } - -export const packedPageSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - updatedAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - title: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - summary: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - content: { - type: 'array' as const, - optional: false as const, nullable: false as const, - }, - variables: { - type: 'array' as const, - optional: false as const, nullable: false as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/user-group.ts b/packages/backend/src/models/repositories/user-group.ts index 02a0348885..3ed37ca0ed 100644 --- a/packages/backend/src/models/repositories/user-group.ts +++ b/packages/backend/src/models/repositories/user-group.ts @@ -23,39 +23,3 @@ export class UserGroupRepository extends Repository { }; } } - -export const packedUserGroupSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - ownerId: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - userIds: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/user-list.ts b/packages/backend/src/models/repositories/user-list.ts index 792a17cb49..a2bffe8357 100644 --- a/packages/backend/src/models/repositories/user-list.ts +++ b/packages/backend/src/models/repositories/user-list.ts @@ -22,34 +22,3 @@ export class UserListRepository extends Repository { }; } } - -export const packedUserListSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - userIds: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 3dc7c67ec2..38c9685036 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -352,313 +352,3 @@ export class UserRepository extends Repository { public validateBirthday = $.str.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/); //#endregion } - -export const packedUserSchema = { - type: 'object' as const, - nullable: false as const, optional: false as const, - properties: { - id: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - name: { - type: 'string' as const, - nullable: true as const, optional: false as const, - example: '藍', - }, - username: { - type: 'string' as const, - nullable: false as const, optional: false as const, - example: 'ai', - }, - host: { - type: 'string' as const, - nullable: true as const, optional: false as const, - example: 'misskey.example.com', - }, - avatarUrl: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: false as const, - }, - avatarBlurhash: { - type: 'any' as const, - nullable: true as const, optional: false as const, - }, - avatarColor: { - type: 'any' as const, - nullable: true as const, optional: false as const, - default: null, - }, - isAdmin: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - isModerator: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - isBot: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - isCat: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - emojis: { - type: 'array' as const, - nullable: false as const, optional: false as const, - items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - properties: { - name: { - type: 'string' as const, - nullable: false as const, optional: false as const, - }, - url: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'url', - }, - }, - }, - }, - url: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: true as const, - }, - createdAt: { - type: 'string' as const, - nullable: false as const, optional: true as const, - format: 'date-time', - }, - updatedAt: { - type: 'string' as const, - nullable: true as const, optional: true as const, - format: 'date-time', - }, - bannerUrl: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: true as const, - }, - bannerBlurhash: { - type: 'any' as const, - nullable: true as const, optional: true as const, - }, - bannerColor: { - type: 'any' as const, - nullable: true as const, optional: true as const, - default: null, - }, - isLocked: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - isSuspended: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - example: false, - }, - description: { - type: 'string' as const, - nullable: true as const, optional: true as const, - example: 'Hi masters, I am Ai!', - }, - location: { - type: 'string' as const, - nullable: true as const, optional: true as const, - }, - birthday: { - type: 'string' as const, - nullable: true as const, optional: true as const, - example: '2018-03-12', - }, - fields: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - properties: { - name: { - type: 'string' as const, - nullable: false as const, optional: false as const, - }, - value: { - type: 'string' as const, - nullable: false as const, optional: false as const, - }, - }, - maxLength: 4, - }, - }, - followersCount: { - type: 'number' as const, - nullable: false as const, optional: true as const, - }, - followingCount: { - type: 'number' as const, - nullable: false as const, optional: true as const, - }, - notesCount: { - type: 'number' as const, - nullable: false as const, optional: true as const, - }, - pinnedNoteIds: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - }, - pinnedNotes: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - ref: 'Note' as const, - }, - }, - pinnedPageId: { - type: 'string' as const, - nullable: true as const, optional: true as const, - }, - pinnedPage: { - type: 'object' as const, - nullable: true as const, optional: true as const, - ref: 'Page' as const, - }, - twoFactorEnabled: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - usePasswordLessLogin: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - securityKeys: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - avatarId: { - type: 'string' as const, - nullable: true as const, optional: true as const, - format: 'id', - }, - bannerId: { - type: 'string' as const, - nullable: true as const, optional: true as const, - format: 'id', - }, - autoWatch: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - injectFeaturedNote: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - alwaysMarkNsfw: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - carefulBot: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - autoAcceptFollowed: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadSpecifiedNotes: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadMentions: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadAnnouncement: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadAntenna: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadChannel: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadMessagingMessage: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadNotification: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasPendingReceivedFollowRequest: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - integrations: { - type: 'object' as const, - nullable: false as const, optional: true as const, - }, - mutedWords: { - type: 'array' as const, - nullable: false as const, optional: true as const, - }, - mutedInstances: { - type: 'array' as const, - nullable: false as const, optional: true as const, - }, - mutingNotificationTypes: { - type: 'array' as const, - nullable: false as const, optional: true as const, - }, - isFollowing: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - hasPendingFollowRequestFromYou: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - hasPendingFollowRequestToYou: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isFollowed: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isBlocking: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isBlocked: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isMuted: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/schema/antenna.ts b/packages/backend/src/models/schema/antenna.ts new file mode 100644 index 0000000000..e2fe300f2b --- /dev/null +++ b/packages/backend/src/models/schema/antenna.ts @@ -0,0 +1,90 @@ +export const packedAntennaSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + keywords: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, + }, + excludeKeywords: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, + }, + src: { + type: 'string' as const, + optional: false as const, nullable: false as const, + enum: ['home', 'all', 'users', 'list', 'group'], + }, + userListId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + }, + userGroupId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + }, + users: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, + caseSensitive: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + default: false, + }, + notify: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + withReplies: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + default: false, + }, + withFile: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + hasUnreadNote: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + default: false, + }, + }, +}; diff --git a/packages/backend/src/models/schema/app.ts b/packages/backend/src/models/schema/app.ts new file mode 100644 index 0000000000..c7c151606f --- /dev/null +++ b/packages/backend/src/models/schema/app.ts @@ -0,0 +1,34 @@ +export const packedAppSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + callbackUrl: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + permission: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, + secret: { + type: 'string' as const, + optional: true as const, nullable: false as const, + }, + isAuthorized: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/blocking.ts b/packages/backend/src/models/schema/blocking.ts new file mode 100644 index 0000000000..9bbce7c7a4 --- /dev/null +++ b/packages/backend/src/models/schema/blocking.ts @@ -0,0 +1,27 @@ +export const packedBlockingSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + blockeeId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + blockee: { + type: 'object' as const, + optional: false as const, nullable: false as const, + ref: 'User' as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/channel.ts b/packages/backend/src/models/schema/channel.ts new file mode 100644 index 0000000000..47a3755eda --- /dev/null +++ b/packages/backend/src/models/schema/channel.ts @@ -0,0 +1,52 @@ +export const packedChannelSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + lastNotedAt: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'date-time', + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + description: { + type: 'string' as const, + nullable: true as const, optional: false as const, + }, + bannerUrl: { + type: 'string' as const, + format: 'url', + nullable: true as const, optional: false as const, + }, + notesCount: { + type: 'number' as const, + nullable: false as const, optional: false as const, + }, + usersCount: { + type: 'number' as const, + nullable: false as const, optional: false as const, + }, + isFollowing: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + userId: { + type: 'string' as const, + nullable: true as const, optional: false as const, + format: 'id', + }, + }, +}; diff --git a/packages/backend/src/models/schema/clip.ts b/packages/backend/src/models/schema/clip.ts new file mode 100644 index 0000000000..34ba773c7e --- /dev/null +++ b/packages/backend/src/models/schema/clip.ts @@ -0,0 +1,39 @@ +export const packedClipSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + userId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + user: { + type: 'object' as const, + ref: 'User' as const, + optional: false as const, nullable: false as const, + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + description: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + isPublic: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/drive-file.ts b/packages/backend/src/models/schema/drive-file.ts new file mode 100644 index 0000000000..25576f75c3 --- /dev/null +++ b/packages/backend/src/models/schema/drive-file.ts @@ -0,0 +1,108 @@ +export const packedDriveFileSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + example: 'lenna.jpg', + }, + type: { + type: 'string' as const, + optional: false as const, nullable: false as const, + example: 'image/jpeg', + }, + md5: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'md5', + example: '15eca7fba0480996e2245f5185bf39f2', + }, + size: { + type: 'number' as const, + optional: false as const, nullable: false as const, + example: 51469, + }, + isSensitive: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + blurhash: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + properties: { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + width: { + type: 'number' as const, + optional: true as const, nullable: false as const, + example: 1280, + }, + height: { + type: 'number' as const, + optional: true as const, nullable: false as const, + example: 720, + }, + orientation: { + type: 'number' as const, + optional: true as const, nullable: false as const, + example: 8, + }, + avgColor: { + type: 'string' as const, + optional: true as const, nullable: false as const, + example: 'rgb(40,65,87)', + }, + }, + }, + url: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'url', + }, + thumbnailUrl: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'url', + }, + comment: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + folderId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + folder: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'DriveFolder' as const, + }, + userId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + user: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'User' as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/drive-folder.ts b/packages/backend/src/models/schema/drive-folder.ts new file mode 100644 index 0000000000..64c23dd75c --- /dev/null +++ b/packages/backend/src/models/schema/drive-folder.ts @@ -0,0 +1,40 @@ +export const packedDriveFolderSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + foldersCount: { + type: 'number' as const, + optional: true as const, nullable: false as const, + }, + filesCount: { + type: 'number' as const, + optional: true as const, nullable: false as const, + }, + parentId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + parent: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'DriveFolder' as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/emoji.ts b/packages/backend/src/models/schema/emoji.ts new file mode 100644 index 0000000000..08a8ae8392 --- /dev/null +++ b/packages/backend/src/models/schema/emoji.ts @@ -0,0 +1,37 @@ +export const packedEmojiSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + aliases: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + category: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + host: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + url: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/federation-instance.ts b/packages/backend/src/models/schema/federation-instance.ts new file mode 100644 index 0000000000..ea2e77140b --- /dev/null +++ b/packages/backend/src/models/schema/federation-instance.ts @@ -0,0 +1,106 @@ +import config from "@/config"; + +export const packedFederationInstanceSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + caughtAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + host: { + type: 'string' as const, + optional: false as const, nullable: false as const, + example: 'misskey.example.com', + }, + usersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + notesCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + followingCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + followersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + driveUsage: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + driveFiles: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + latestRequestSentAt: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'date-time', + }, + lastCommunicatedAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + isNotResponding: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + isSuspended: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + softwareName: { + type: 'string' as const, + optional: false as const, nullable: true as const, + example: 'misskey', + }, + softwareVersion: { + type: 'string' as const, + optional: false as const, nullable: true as const, + example: config.version, + }, + openRegistrations: { + type: 'boolean' as const, + optional: false as const, nullable: true as const, + example: true, + }, + name: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + description: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + maintainerName: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + maintainerEmail: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + iconUrl: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'url', + }, + infoUpdatedAt: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'date-time', + }, + }, +}; diff --git a/packages/backend/src/models/schema/following.ts b/packages/backend/src/models/schema/following.ts new file mode 100644 index 0000000000..f82ae68cb6 --- /dev/null +++ b/packages/backend/src/models/schema/following.ts @@ -0,0 +1,37 @@ +export const packedFollowingSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + followeeId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + followee: { + type: 'object' as const, + optional: true as const, nullable: false as const, + ref: 'User' as const, + }, + followerId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + follower: { + type: 'object' as const, + optional: true as const, nullable: false as const, + ref: 'User' as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/gallery-post.ts b/packages/backend/src/models/schema/gallery-post.ts new file mode 100644 index 0000000000..e45c60f136 --- /dev/null +++ b/packages/backend/src/models/schema/gallery-post.ts @@ -0,0 +1,70 @@ +export const packedGalleryPostSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + updatedAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + title: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + description: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + userId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + user: { + type: 'object' as const, + ref: 'User' as const, + optional: false as const, nullable: false as const, + }, + fileIds: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, + files: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'object' as const, + optional: false as const, nullable: false as const, + ref: 'DriveFile' as const, + }, + }, + tags: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, + isSensitive: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/hashtag.ts b/packages/backend/src/models/schema/hashtag.ts new file mode 100644 index 0000000000..910a55e9cc --- /dev/null +++ b/packages/backend/src/models/schema/hashtag.ts @@ -0,0 +1,35 @@ +export const packedHashtagSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + tag: { + type: 'string' as const, + optional: false as const, nullable: false as const, + example: 'misskey', + }, + mentionedUsersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + mentionedLocalUsersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + mentionedRemoteUsersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + attachedUsersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + attachedLocalUsersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + attachedRemoteUsersCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/messaging-message.ts b/packages/backend/src/models/schema/messaging-message.ts new file mode 100644 index 0000000000..f85f859173 --- /dev/null +++ b/packages/backend/src/models/schema/messaging-message.ts @@ -0,0 +1,74 @@ +export const packedMessagingMessageSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + userId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + user: { + type: 'object' as const, + ref: 'User' as const, + optional: true as const, nullable: false as const, + }, + text: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + fileId: { + type: 'string' as const, + optional: true as const, nullable: true as const, + format: 'id', + }, + file: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'DriveFile' as const, + }, + recipientId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + }, + recipient: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'User' as const, + }, + groupId: { + type: 'string' as const, + optional: false as const, nullable: true as const, + format: 'id', + }, + group: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'UserGroup' as const, + }, + isRead: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + reads: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, + }, +}; diff --git a/packages/backend/src/models/schema/muting.ts b/packages/backend/src/models/schema/muting.ts new file mode 100644 index 0000000000..ecab528129 --- /dev/null +++ b/packages/backend/src/models/schema/muting.ts @@ -0,0 +1,27 @@ +export const packedMutingSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + muteeId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + mutee: { + type: 'object' as const, + optional: false as const, nullable: false as const, + ref: 'User' as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/note-favorite.ts b/packages/backend/src/models/schema/note-favorite.ts new file mode 100644 index 0000000000..e5bc748a39 --- /dev/null +++ b/packages/backend/src/models/schema/note-favorite.ts @@ -0,0 +1,27 @@ +export const packedNoteFavoriteSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + note: { + type: 'object' as const, + optional: false as const, nullable: false as const, + ref: 'Note' as const, + }, + noteId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, +}; diff --git a/packages/backend/src/models/schema/note-reaction.ts b/packages/backend/src/models/schema/note-reaction.ts new file mode 100644 index 0000000000..cf8f48375e --- /dev/null +++ b/packages/backend/src/models/schema/note-reaction.ts @@ -0,0 +1,26 @@ +export const packedNoteReactionSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + user: { + type: 'object' as const, + optional: false as const, nullable: false as const, + ref: 'User' as const, + }, + type: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/note.ts b/packages/backend/src/models/schema/note.ts new file mode 100644 index 0000000000..554b176928 --- /dev/null +++ b/packages/backend/src/models/schema/note.ts @@ -0,0 +1,184 @@ +export const packedNoteSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + text: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + cw: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + userId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + user: { + type: 'object' as const, + ref: 'User' as const, + optional: false as const, nullable: false as const, + }, + replyId: { + type: 'string' as const, + optional: true as const, nullable: true as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + renoteId: { + type: 'string' as const, + optional: true as const, nullable: true as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + reply: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'Note' as const, + }, + renote: { + type: 'object' as const, + optional: true as const, nullable: true as const, + ref: 'Note' as const, + }, + isHidden: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + visibility: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + mentions: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, + visibleUserIds: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, + fileIds: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + }, + files: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'object' as const, + optional: false as const, nullable: false as const, + ref: 'DriveFile' as const, + }, + }, + tags: { + type: 'array' as const, + optional: true as const, nullable: false as const, + items: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + }, + poll: { + type: 'object' as const, + optional: true as const, nullable: true as const, + }, + channelId: { + type: 'string' as const, + optional: true as const, nullable: true as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + channel: { + type: 'object' as const, + optional: true as const, nullable: true as const, + items: { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + name: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + }, + }, + }, + localOnly: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + emojis: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + url: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + }, + }, + }, + reactions: { + type: 'object' as const, + optional: false as const, nullable: false as const, + }, + renoteCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + repliesCount: { + type: 'number' as const, + optional: false as const, nullable: false as const, + }, + uri: { + type: 'string' as const, + optional: true as const, nullable: false as const, + }, + url: { + type: 'string' as const, + optional: true as const, nullable: false as const, + }, + + myReaction: { + type: 'object' as const, + optional: true as const, nullable: true as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/notification.ts b/packages/backend/src/models/schema/notification.ts new file mode 100644 index 0000000000..4afb17c35b --- /dev/null +++ b/packages/backend/src/models/schema/notification.ts @@ -0,0 +1,67 @@ +import { notificationTypes } from "@/types"; + +export const packedNotificationSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + isRead: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, + type: { + type: 'string' as const, + optional: false as const, nullable: false as const, + enum: [...notificationTypes], + }, + user: { + type: 'object' as const, + ref: 'User' as const, + optional: true as const, nullable: true as const, + }, + userId: { + type: 'string' as const, + optional: true as const, nullable: true as const, + format: 'id', + }, + note: { + type: 'object' as const, + ref: 'Note' as const, + optional: true as const, nullable: true as const, + }, + reaction: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + choice: { + type: 'number' as const, + optional: true as const, nullable: true as const, + }, + invitation: { + type: 'object' as const, + optional: true as const, nullable: true as const, + }, + body: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + header: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + icon: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + }, +}; diff --git a/packages/backend/src/models/schema/page.ts b/packages/backend/src/models/schema/page.ts new file mode 100644 index 0000000000..262f83da2f --- /dev/null +++ b/packages/backend/src/models/schema/page.ts @@ -0,0 +1,52 @@ +export const packedPageSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + updatedAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + title: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + summary: { + type: 'string' as const, + optional: false as const, nullable: true as const, + }, + content: { + type: 'array' as const, + optional: false as const, nullable: false as const, + }, + variables: { + type: 'array' as const, + optional: false as const, nullable: false as const, + }, + userId: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + }, + user: { + type: 'object' as const, + ref: 'User' as const, + optional: false as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/models/repositories/queue.ts b/packages/backend/src/models/schema/queue.ts similarity index 100% rename from packages/backend/src/models/repositories/queue.ts rename to packages/backend/src/models/schema/queue.ts diff --git a/packages/backend/src/models/schema/user-group.ts b/packages/backend/src/models/schema/user-group.ts new file mode 100644 index 0000000000..895da141e2 --- /dev/null +++ b/packages/backend/src/models/schema/user-group.ts @@ -0,0 +1,35 @@ +export const packedUserGroupSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + ownerId: { + type: 'string' as const, + nullable: false as const, optional: false as const, + format: 'id', + }, + userIds: { + type: 'array' as const, + nullable: false as const, optional: true as const, + items: { + type: 'string' as const, + nullable: false as const, optional: false as const, + format: 'id', + }, + }, + }, +}; diff --git a/packages/backend/src/models/schema/user-list.ts b/packages/backend/src/models/schema/user-list.ts new file mode 100644 index 0000000000..75965f8258 --- /dev/null +++ b/packages/backend/src/models/schema/user-list.ts @@ -0,0 +1,30 @@ +export const packedUserListSchema = { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + id: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'date-time', + }, + name: { + type: 'string' as const, + optional: false as const, nullable: false as const, + }, + userIds: { + type: 'array' as const, + nullable: false as const, optional: true as const, + items: { + type: 'string' as const, + nullable: false as const, optional: false as const, + format: 'id', + }, + }, + }, +}; diff --git a/packages/backend/src/models/schema/user.ts b/packages/backend/src/models/schema/user.ts new file mode 100644 index 0000000000..89e33e8510 --- /dev/null +++ b/packages/backend/src/models/schema/user.ts @@ -0,0 +1,309 @@ +export const packedUserSchema = { + type: 'object' as const, + nullable: false as const, optional: false as const, + properties: { + id: { + type: 'string' as const, + nullable: false as const, optional: false as const, + format: 'id', + example: 'xxxxxxxxxx', + }, + name: { + type: 'string' as const, + nullable: true as const, optional: false as const, + example: '藍', + }, + username: { + type: 'string' as const, + nullable: false as const, optional: false as const, + example: 'ai', + }, + host: { + type: 'string' as const, + nullable: true as const, optional: false as const, + example: 'misskey.example.com', + }, + avatarUrl: { + type: 'string' as const, + format: 'url', + nullable: true as const, optional: false as const, + }, + avatarBlurhash: { + type: 'any' as const, + nullable: true as const, optional: false as const, + }, + avatarColor: { + type: 'any' as const, + nullable: true as const, optional: false as const, + default: null, + }, + isAdmin: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + default: false, + }, + isModerator: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + default: false, + }, + isBot: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + isCat: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + emojis: { + type: 'array' as const, + nullable: false as const, optional: false as const, + items: { + type: 'object' as const, + nullable: false as const, optional: false as const, + properties: { + name: { + type: 'string' as const, + nullable: false as const, optional: false as const, + }, + url: { + type: 'string' as const, + nullable: false as const, optional: false as const, + format: 'url', + }, + }, + }, + }, + url: { + type: 'string' as const, + format: 'url', + nullable: true as const, optional: true as const, + }, + createdAt: { + type: 'string' as const, + nullable: false as const, optional: true as const, + format: 'date-time', + }, + updatedAt: { + type: 'string' as const, + nullable: true as const, optional: true as const, + format: 'date-time', + }, + bannerUrl: { + type: 'string' as const, + format: 'url', + nullable: true as const, optional: true as const, + }, + bannerBlurhash: { + type: 'any' as const, + nullable: true as const, optional: true as const, + }, + bannerColor: { + type: 'any' as const, + nullable: true as const, optional: true as const, + default: null, + }, + isLocked: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + isSuspended: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + example: false, + }, + description: { + type: 'string' as const, + nullable: true as const, optional: true as const, + example: 'Hi masters, I am Ai!', + }, + location: { + type: 'string' as const, + nullable: true as const, optional: true as const, + }, + birthday: { + type: 'string' as const, + nullable: true as const, optional: true as const, + example: '2018-03-12', + }, + fields: { + type: 'array' as const, + nullable: false as const, optional: true as const, + items: { + type: 'object' as const, + nullable: false as const, optional: false as const, + properties: { + name: { + type: 'string' as const, + nullable: false as const, optional: false as const, + }, + value: { + type: 'string' as const, + nullable: false as const, optional: false as const, + }, + }, + maxLength: 4, + }, + }, + followersCount: { + type: 'number' as const, + nullable: false as const, optional: true as const, + }, + followingCount: { + type: 'number' as const, + nullable: false as const, optional: true as const, + }, + notesCount: { + type: 'number' as const, + nullable: false as const, optional: true as const, + }, + pinnedNoteIds: { + type: 'array' as const, + nullable: false as const, optional: true as const, + items: { + type: 'string' as const, + nullable: false as const, optional: false as const, + format: 'id', + }, + }, + pinnedNotes: { + type: 'array' as const, + nullable: false as const, optional: true as const, + items: { + type: 'object' as const, + nullable: false as const, optional: false as const, + ref: 'Note' as const, + }, + }, + pinnedPageId: { + type: 'string' as const, + nullable: true as const, optional: true as const, + }, + pinnedPage: { + type: 'object' as const, + nullable: true as const, optional: true as const, + ref: 'Page' as const, + }, + twoFactorEnabled: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + default: false, + }, + usePasswordLessLogin: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + default: false, + }, + securityKeys: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + default: false, + }, + avatarId: { + type: 'string' as const, + nullable: true as const, optional: true as const, + format: 'id', + }, + bannerId: { + type: 'string' as const, + nullable: true as const, optional: true as const, + format: 'id', + }, + autoWatch: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + injectFeaturedNote: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + alwaysMarkNsfw: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + carefulBot: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + autoAcceptFollowed: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadSpecifiedNotes: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadMentions: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadAnnouncement: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadAntenna: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadChannel: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadMessagingMessage: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasUnreadNotification: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + hasPendingReceivedFollowRequest: { + type: 'boolean' as const, + nullable: false as const, optional: true as const, + }, + integrations: { + type: 'object' as const, + nullable: false as const, optional: true as const, + }, + mutedWords: { + type: 'array' as const, + nullable: false as const, optional: true as const, + }, + mutedInstances: { + type: 'array' as const, + nullable: false as const, optional: true as const, + }, + mutingNotificationTypes: { + type: 'array' as const, + nullable: false as const, optional: true as const, + }, + isFollowing: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + hasPendingFollowRequestFromYou: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + hasPendingFollowRequestToYou: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + isFollowed: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + isBlocking: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + isBlocked: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + isMuted: { + type: 'boolean' as const, + optional: true as const, nullable: false as const, + }, + }, +}; diff --git a/packages/backend/src/services/chart/core.ts b/packages/backend/src/services/chart/core.ts index f97fa521d3..e406449f4f 100644 --- a/packages/backend/src/services/chart/core.ts +++ b/packages/backend/src/services/chart/core.ts @@ -7,7 +7,7 @@ import * as nestedProperty from 'nested-property'; import autobind from 'autobind-decorator'; import Logger from '../logger'; -import { SimpleSchema } from '@/misc/simple-schema'; +import { Schema } from '@/misc/schema'; import { EntitySchema, getRepository, Repository, LessThan, Between } from 'typeorm'; import { dateUTC, isTimeSame, isTimeBefore, subtractTime, addTime } from '@/prelude/time'; import { getChartInsertLock } from '@/misc/app-lock'; @@ -57,7 +57,7 @@ export default abstract class Chart> { diff: DeepPartial; group: string | null; }[] = []; - public schema: SimpleSchema; + public schema: Schema; protected repositoryForHour: Repository; protected repositoryForDay: Repository; @@ -71,7 +71,7 @@ export default abstract class Chart> { protected abstract fetchActual(group: string | null): Promise>; @autobind - private static convertSchemaToFlatColumnDefinitions(schema: SimpleSchema) { + private static convertSchemaToFlatColumnDefinitions(schema: Schema) { const columns = {} as Record; const flatColumns = (x: Obj, path?: string) => { for (const [k, v] of Object.entries(x)) { @@ -183,7 +183,7 @@ export default abstract class Chart> { } @autobind - public static schemaToEntity(name: string, schema: SimpleSchema, grouped = false): { + public static schemaToEntity(name: string, schema: Schema, grouped = false): { hour: EntitySchema, day: EntitySchema, } { @@ -233,7 +233,7 @@ export default abstract class Chart> { }; } - constructor(name: string, schema: SimpleSchema, grouped = false) { + constructor(name: string, schema: Schema, grouped = false) { this.name = name; this.schema = schema; @@ -573,8 +573,8 @@ export default abstract class Chart> { } } -export function convertLog(logSchema: SimpleSchema): SimpleSchema { - const v: SimpleSchema = JSON.parse(JSON.stringify(logSchema)); // copy +export function convertLog(logSchema: Schema): Schema { + const v: Schema = JSON.parse(JSON.stringify(logSchema)); // copy if (v.type === 'number') { v.type = 'array'; v.items = {