From 952789cc1eb77e2f2d54b489c016b56bac812ab7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 27 Jun 2019 18:04:09 +0900 Subject: [PATCH] Use as const #5089 --- package.json | 2 +- src/misc/schema.ts | 14 -- src/models/repositories/app.ts | 30 ++-- src/models/repositories/blocking.ts | 22 +-- src/models/repositories/drive-file.ts | 42 +++--- src/models/repositories/drive-folder.ts | 34 ++--- src/models/repositories/following.ts | 30 ++-- src/models/repositories/hashtag.ts | 34 ++--- src/models/repositories/messaging-message.ts | 62 ++++----- src/models/repositories/muting.ts | 22 +-- src/models/repositories/note-favorite.ts | 21 ++- src/models/repositories/note-reaction.ts | 22 +-- src/models/repositories/note.ts | 106 +++++++------- src/models/repositories/notification.ts | 26 ++-- src/models/repositories/page.ts | 46 +++---- src/models/repositories/user-group.ts | 30 ++-- src/models/repositories/user-list.ts | 26 ++-- src/models/repositories/user.ts | 122 ++++++++-------- src/server/api/endpoints/app/create.ts | 5 +- src/server/api/endpoints/app/show.ts | 5 +- .../api/endpoints/auth/session/generate.ts | 13 +- .../api/endpoints/auth/session/userkey.ts | 13 +- src/server/api/endpoints/blocking/list.ts | 9 +- src/server/api/endpoints/drive.ts | 13 +- src/server/api/endpoints/drive/files.ts | 9 +- .../endpoints/drive/files/attached-notes.ts | 9 +- .../endpoints/drive/files/check-existence.ts | 5 +- .../api/endpoints/drive/files/create.ts | 5 +- .../api/endpoints/drive/files/find-by-hash.ts | 9 +- src/server/api/endpoints/drive/files/find.ts | 9 +- src/server/api/endpoints/drive/files/show.ts | 5 +- src/server/api/endpoints/drive/folders.ts | 9 +- .../api/endpoints/drive/folders/find.ts | 9 +- .../api/endpoints/drive/folders/show.ts | 5 +- src/server/api/endpoints/drive/stream.ts | 9 +- src/server/api/endpoints/hashtags/list.ts | 9 +- src/server/api/endpoints/hashtags/search.ts | 9 +- src/server/api/endpoints/hashtags/show.ts | 5 +- src/server/api/endpoints/hashtags/trend.ts | 25 ++-- src/server/api/endpoints/hashtags/users.ts | 9 +- src/server/api/endpoints/i.ts | 5 +- src/server/api/endpoints/i/favorites.ts | 9 +- src/server/api/endpoints/i/notifications.ts | 9 +- src/server/api/endpoints/messaging/history.ts | 9 +- .../api/endpoints/messaging/messages.ts | 9 +- .../endpoints/messaging/messages/create.ts | 5 +- src/server/api/endpoints/meta.ts | 49 ++++--- src/server/api/endpoints/mute/list.ts | 9 +- src/server/api/endpoints/notes.ts | 9 +- src/server/api/endpoints/notes/children.ts | 9 +- .../api/endpoints/notes/conversation.ts | 9 +- src/server/api/endpoints/notes/create.ts | 9 +- src/server/api/endpoints/notes/featured.ts | 9 +- .../api/endpoints/notes/global-timeline.ts | 9 +- .../api/endpoints/notes/hybrid-timeline.ts | 9 +- .../api/endpoints/notes/local-timeline.ts | 9 +- src/server/api/endpoints/notes/mentions.ts | 9 +- src/server/api/endpoints/notes/reactions.ts | 9 +- src/server/api/endpoints/notes/renotes.ts | 9 +- src/server/api/endpoints/notes/replies.ts | 9 +- .../api/endpoints/notes/search-by-tag.ts | 9 +- src/server/api/endpoints/notes/search.ts | 9 +- src/server/api/endpoints/notes/show.ts | 5 +- src/server/api/endpoints/notes/timeline.ts | 9 +- .../api/endpoints/notes/user-list-timeline.ts | 9 +- src/server/api/endpoints/pages/create.ts | 5 +- src/server/api/endpoints/pages/show.ts | 5 +- src/server/api/endpoints/pinned-users.ts | 9 +- src/server/api/endpoints/stats.ts | 25 ++-- src/server/api/endpoints/users.ts | 9 +- src/server/api/endpoints/users/followers.ts | 9 +- src/server/api/endpoints/users/following.ts | 9 +- .../users/get-frequently-replied-users.ts | 9 +- .../api/endpoints/users/groups/create.ts | 5 +- .../api/endpoints/users/groups/joined.ts | 9 +- .../api/endpoints/users/groups/owned.ts | 9 +- src/server/api/endpoints/users/groups/show.ts | 5 +- .../api/endpoints/users/groups/transfer.ts | 5 +- .../api/endpoints/users/groups/update.ts | 5 +- .../api/endpoints/users/lists/create.ts | 5 +- src/server/api/endpoints/users/lists/list.ts | 9 +- src/server/api/endpoints/users/lists/show.ts | 5 +- src/server/api/endpoints/users/notes.ts | 9 +- .../api/endpoints/users/recommendation.ts | 9 +- src/server/api/endpoints/users/search.ts | 9 +- src/server/api/endpoints/users/show.ts | 5 +- .../chart/charts/schemas/active-users.ts | 18 ++- src/services/chart/charts/schemas/drive.ts | 38 +++-- .../chart/charts/schemas/federation.ts | 22 ++- src/services/chart/charts/schemas/hashtag.ts | 18 ++- src/services/chart/charts/schemas/instance.ts | 130 +++++++++--------- src/services/chart/charts/schemas/network.ts | 26 ++-- src/services/chart/charts/schemas/notes.ts | 42 +++--- .../chart/charts/schemas/per-user-drive.ts | 30 ++-- .../charts/schemas/per-user-following.ts | 46 +++---- .../chart/charts/schemas/per-user-notes.ts | 34 +++-- .../charts/schemas/per-user-reactions.ts | 18 ++- .../chart/charts/schemas/test-grouped.ts | 22 ++- .../chart/charts/schemas/test-unique.ts | 10 +- src/services/chart/charts/schemas/test.ts | 22 ++- src/services/chart/charts/schemas/users.ts | 26 ++-- src/services/chart/core.ts | 6 +- 102 files changed, 853 insertions(+), 966 deletions(-) diff --git a/package.json b/package.json index 264b50d66352..7943d8187eb8 100644 --- a/package.json +++ b/package.json @@ -226,7 +226,7 @@ "tslint": "5.15.0", "tslint-sonarts": "1.9.0", "typeorm": "0.2.16-rc.1", - "typescript": "3.3.3333", + "typescript": "3.5.2", "typescript-eslint-parser": "22.0.0", "uglify-es": "3.3.9", "ulid": "2.3.0", diff --git a/src/misc/schema.ts b/src/misc/schema.ts index 442c95ad9881..e14e6e0dd79f 100644 --- a/src/misc/schema.ts +++ b/src/misc/schema.ts @@ -1,17 +1,3 @@ -export const types = { - boolean: 'boolean' as 'boolean', - string: 'string' as 'string', - number: 'number' as 'number', - array: 'array' as 'array', - object: 'object' as 'object', - any: 'any' as 'any', -}; - -export const bool = { - true: true as true, - false: false as false, -}; - export type Schema = { type: 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any'; nullable: boolean; diff --git a/src/models/repositories/app.ts b/src/models/repositories/app.ts index 6562a470be69..45d8d16c516e 100644 --- a/src/models/repositories/app.ts +++ b/src/models/repositories/app.ts @@ -2,7 +2,7 @@ import { EntityRepository, Repository } from 'typeorm'; import { App } from '../entities/app'; import { AccessTokens } from '..'; import { ensure } from '../../prelude/ensure'; -import { types, bool, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedApp = SchemaType; @@ -42,37 +42,37 @@ export class AppRepository extends Repository { } export const packedAppSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this Note.', example: 'xxxxxxxxxx', }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'アプリケーションの名前' }, callbackUrl: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, description: 'コールバックするURL' }, permission: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, } }, secret: { - type: types.string, - optional: bool.true, nullable: bool.false, + type: 'string' as const, + optional: true as const, nullable: false as const, description: 'アプリケーションのシークレットキー' } }, diff --git a/src/models/repositories/blocking.ts b/src/models/repositories/blocking.ts index 6ee31cece82f..9ebe6bbf59bc 100644 --- a/src/models/repositories/blocking.ts +++ b/src/models/repositories/blocking.ts @@ -3,7 +3,7 @@ import { Users } from '..'; import { Blocking } from '../entities/blocking'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; -import { SchemaType, types, bool } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedBlocking = SchemaType; @@ -34,30 +34,30 @@ export class BlockingRepository extends Repository { } export const packedBlockingSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this blocking.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the blocking was created.' }, blockeeId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, blockee: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', description: 'The blockee.' }, diff --git a/src/models/repositories/drive-file.ts b/src/models/repositories/drive-file.ts index 5e7e1d40f482..702f195e9da8 100644 --- a/src/models/repositories/drive-file.ts +++ b/src/models/repositories/drive-file.ts @@ -5,7 +5,7 @@ import { User } from '../entities/user'; import { toPuny } from '../../misc/convert-host'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; -import { types, bool, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedDriveFile = SchemaType; @@ -114,63 +114,63 @@ export class DriveFileRepository extends Repository { } export const packedDriveFileSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this Drive file.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the Drive file was created on Misskey.' }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The file name with extension.', example: 'lenna.jpg' }, type: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The MIME type of this Drive file.', example: 'image/jpeg' }, md5: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'md5', description: 'The MD5 hash of this Drive file.', example: '15eca7fba0480996e2245f5185bf39f2' }, size: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'The size of this Drive file. (bytes)', example: 51469 }, url: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, format: 'url', description: 'The URL of this Drive file.', }, folderId: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, format: 'id', description: 'The parent folder ID of this Drive file.', example: 'xxxxxxxxxx', }, isSensitive: { - type: types.boolean, - optional: bool.false, nullable: bool.false, + type: 'boolean' as const, + optional: false as const, nullable: false as const, description: 'Whether this Drive file is sensitive.', }, }, diff --git a/src/models/repositories/drive-folder.ts b/src/models/repositories/drive-folder.ts index ef920c432683..dee424cccbc8 100644 --- a/src/models/repositories/drive-folder.ts +++ b/src/models/repositories/drive-folder.ts @@ -3,7 +3,7 @@ import { DriveFolders, DriveFiles } from '..'; import { DriveFolder } from '../entities/drive-folder'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; -import { SchemaType, types, bool } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedDriveFolder = SchemaType; @@ -53,47 +53,47 @@ export class DriveFolderRepository extends Repository { } export const packedDriveFolderSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this Drive folder.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the Drive folder was created.' }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The folder name.', }, foldersCount: { - type: types.number, - optional: bool.true, nullable: bool.false, + type: 'number' as const, + optional: true as const, nullable: false as const, description: 'The count of child folders.', }, filesCount: { - type: types.number, - optional: bool.true, nullable: bool.false, + type: 'number' as const, + optional: true as const, nullable: false as const, description: 'The count of child files.', }, parentId: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, format: 'id', description: 'The parent folder ID of this folder.', example: 'xxxxxxxxxx', }, parent: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, ref: 'DriveFolder' }, }, diff --git a/src/models/repositories/following.ts b/src/models/repositories/following.ts index 88fee749ae8e..58728a338043 100644 --- a/src/models/repositories/following.ts +++ b/src/models/repositories/following.ts @@ -3,7 +3,7 @@ import { Users } from '..'; import { Following } from '../entities/following'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; -import { SchemaType, types, bool } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; type LocalFollowerFollowing = Following & { followerHost: null; @@ -88,41 +88,41 @@ export class FollowingRepository extends Repository { } export const packedFollowingSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this following.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the following was created.' }, followeeId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, followee: { - type: types.object, - optional: bool.true, nullable: bool.false, + type: 'object' as const, + optional: true as const, nullable: false as const, ref: 'User', description: 'The followee.' }, followerId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, follower: { - type: types.object, - optional: bool.true, nullable: bool.false, + type: 'object' as const, + optional: true as const, nullable: false as const, ref: 'User', description: 'The follower.' }, diff --git a/src/models/repositories/hashtag.ts b/src/models/repositories/hashtag.ts index a990fa3dcff2..fb54a12e1368 100644 --- a/src/models/repositories/hashtag.ts +++ b/src/models/repositories/hashtag.ts @@ -1,6 +1,6 @@ import { EntityRepository, Repository } from 'typeorm'; import { Hashtag } from '../entities/hashtag'; -import { SchemaType, types, bool } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedHashtag = SchemaType; @@ -28,43 +28,43 @@ export class HashtagRepository extends Repository { } export const packedHashtagSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { tag: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The hashtag name. No # prefixed.', example: 'misskey', }, mentionedUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Number of all users using this hashtag.' }, mentionedLocalUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Number of local users using this hashtag.' }, mentionedRemoteUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Number of remote users using this hashtag.' }, attachedUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Number of all users who attached this hashtag to profile.' }, attachedLocalUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Number of local users who attached this hashtag to profile.' }, attachedRemoteUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Number of remote users who attached this hashtag to profile.' }, } diff --git a/src/models/repositories/messaging-message.ts b/src/models/repositories/messaging-message.ts index 7f0b2047ad27..d70e95bc122d 100644 --- a/src/models/repositories/messaging-message.ts +++ b/src/models/repositories/messaging-message.ts @@ -2,7 +2,7 @@ import { EntityRepository, Repository } from 'typeorm'; import { MessagingMessage } from '../entities/messaging-message'; import { Users, DriveFiles, UserGroups } from '..'; import { ensure } from '../../prelude/ensure'; -import { types, bool, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedMessagingMessage = SchemaType; @@ -46,76 +46,76 @@ export class MessagingMessageRepository extends Repository { } export const packedMessagingMessageSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this MessagingMessage.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the MessagingMessage was created.' }, userId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, user: { - type: types.object, + type: 'object' as const, ref: 'User', - optional: bool.true, nullable: bool.false, + optional: true as const, nullable: false as const, }, text: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, }, fileId: { - type: types.string, - optional: bool.true, nullable: bool.true, + type: 'string' as const, + optional: true as const, nullable: true as const, format: 'id', }, file: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, ref: 'DriveFile', }, recipientId: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, format: 'id', }, recipient: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, ref: 'User' }, groupId: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, format: 'id', }, group: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, ref: 'UserGroup' }, isRead: { - type: types.boolean, - optional: bool.true, nullable: bool.false, + type: 'boolean' as const, + optional: true as const, nullable: false as const, }, reads: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id' } }, diff --git a/src/models/repositories/muting.ts b/src/models/repositories/muting.ts index 9d99e08a7c8a..763e04bb3d79 100644 --- a/src/models/repositories/muting.ts +++ b/src/models/repositories/muting.ts @@ -3,7 +3,7 @@ import { Users } from '..'; import { Muting } from '../entities/muting'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; -import { types, bool, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedMuting = SchemaType; @@ -34,30 +34,30 @@ export class MutingRepository extends Repository { } export const packedMutingSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this muting.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the muting was created.' }, muteeId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, mutee: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', description: 'The mutee.' }, diff --git a/src/models/repositories/note-favorite.ts b/src/models/repositories/note-favorite.ts index 01064f306536..37cfbc0025b1 100644 --- a/src/models/repositories/note-favorite.ts +++ b/src/models/repositories/note-favorite.ts @@ -2,7 +2,6 @@ import { EntityRepository, Repository } from 'typeorm'; import { NoteFavorite } from '../entities/note-favorite'; import { Notes } from '..'; import { ensure } from '../../prelude/ensure'; -import { types, bool } from '../../misc/schema'; @EntityRepository(NoteFavorite) export class NoteFavoriteRepository extends Repository { @@ -29,30 +28,30 @@ export class NoteFavoriteRepository extends Repository { } export const packedNoteFavoriteSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this favorite.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the favorite was created.' }, note: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', }, noteId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, }, diff --git a/src/models/repositories/note-reaction.ts b/src/models/repositories/note-reaction.ts index 85e5b6b0a1f1..79b4989a2085 100644 --- a/src/models/repositories/note-reaction.ts +++ b/src/models/repositories/note-reaction.ts @@ -2,7 +2,7 @@ import { EntityRepository, Repository } from 'typeorm'; import { NoteReaction } from '../entities/note-reaction'; import { Users } from '..'; import { ensure } from '../../prelude/ensure'; -import { types, bool, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedNoteReaction = SchemaType; @@ -24,31 +24,31 @@ export class NoteReactionRepository extends Repository { } export const packedNoteReactionSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this reaction.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the reaction was created.' }, user: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', description: 'User who performed this reaction.' }, type: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The reaction type.' }, }, diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index e5bf8d3f3a71..3ac490b0016a 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -5,7 +5,7 @@ import { unique, concat } from '../../prelude/array'; import { nyaize } from '../../misc/nyaize'; import { Emojis, Users, Apps, PollVotes, DriveFiles, NoteReactions, Followings, Polls } from '..'; import { ensure } from '../../prelude/ensure'; -import { SchemaType, types, bool } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; import { awaitAll } from '../../prelude/await-all'; export type PackedNote = SchemaType; @@ -218,125 +218,125 @@ export class NoteRepository extends Repository { } export const packedNoteSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this Note.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the Note was created on Misskey.' }, text: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, }, cw: { - type: types.string, - optional: bool.true, nullable: bool.true, + type: 'string' as const, + optional: true as const, nullable: true as const, }, userId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, user: { - type: types.object, + type: 'object' as const, ref: 'User', - optional: bool.false, nullable: bool.false, + optional: false as const, nullable: false as const, }, replyId: { - type: types.string, - optional: bool.true, nullable: bool.true, + type: 'string' as const, + optional: true as const, nullable: true as const, format: 'id', example: 'xxxxxxxxxx', }, renoteId: { - type: types.string, - optional: bool.true, nullable: bool.true, + type: 'string' as const, + optional: true as const, nullable: true as const, format: 'id', example: 'xxxxxxxxxx', }, reply: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, ref: 'Note' }, renote: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, ref: 'Note' }, viaMobile: { - type: types.boolean, - optional: bool.true, nullable: bool.false, + type: 'boolean' as const, + optional: true as const, nullable: false as const, }, isHidden: { - type: types.boolean, - optional: bool.true, nullable: bool.false, + type: 'boolean' as const, + optional: true as const, nullable: false as const, }, visibility: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, }, mentions: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id' } }, visibleUserIds: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id' } }, fileIds: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id' } }, files: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile' } }, tags: { - type: types.array, - optional: bool.true, nullable: bool.false, + type: 'array' as const, + optional: true as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, } }, poll: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, }, geo: { - type: types.object, - optional: bool.true, nullable: bool.true, + type: 'object' as const, + optional: true as const, nullable: true as const, }, }, }; diff --git a/src/models/repositories/notification.ts b/src/models/repositories/notification.ts index 54eec87cfff3..96293d4a68c3 100644 --- a/src/models/repositories/notification.ts +++ b/src/models/repositories/notification.ts @@ -3,7 +3,7 @@ import { Users, Notes } from '..'; import { Notification } from '../entities/notification'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; -import { types, bool, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedNotification = SchemaType; @@ -51,37 +51,37 @@ export class NotificationRepository extends Repository { } export const packedNotificationSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this notification.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the notification was created.' }, type: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, enum: ['follow', 'receiveFollowRequest', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote'], description: 'The type of the notification.' }, userId: { - type: types.string, - optional: bool.true, nullable: bool.true, + type: 'string' as const, + optional: true as const, nullable: true as const, format: 'id', }, user: { - type: types.object, + type: 'object' as const, ref: 'User', - optional: bool.true, nullable: bool.true, + optional: true as const, nullable: true as const, }, } }; diff --git a/src/models/repositories/page.ts b/src/models/repositories/page.ts index 3b4142002545..33126274a11a 100644 --- a/src/models/repositories/page.ts +++ b/src/models/repositories/page.ts @@ -1,6 +1,6 @@ import { EntityRepository, Repository } from 'typeorm'; import { Page } from '../entities/page'; -import { SchemaType, types, bool } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; import { Users, DriveFiles, PageLikes } from '..'; import { awaitAll } from '../../prelude/await-all'; import { DriveFile } from '../entities/drive-file'; @@ -89,54 +89,54 @@ export class PageRepository extends Repository { } export const packedPageSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', }, updatedAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', }, title: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, }, summary: { - type: types.string, - optional: bool.false, nullable: bool.true, + type: 'string' as const, + optional: false as const, nullable: true as const, }, content: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, }, variables: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, }, userId: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', }, user: { - type: types.object, + type: 'object' as const, ref: 'User', - optional: bool.false, nullable: bool.false, + optional: false as const, nullable: false as const, }, } }; diff --git a/src/models/repositories/user-group.ts b/src/models/repositories/user-group.ts index 38174ce235fd..5ff75047c876 100644 --- a/src/models/repositories/user-group.ts +++ b/src/models/repositories/user-group.ts @@ -2,7 +2,7 @@ import { EntityRepository, Repository } from 'typeorm'; import { UserGroup } from '../entities/user-group'; import { ensure } from '../../prelude/ensure'; import { UserGroupJoinings } from '..'; -import { bool, types, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedUserGroup = SchemaType; @@ -28,38 +28,38 @@ export class UserGroupRepository extends Repository { } export const packedUserGroupSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this UserGroup.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the UserGroup was created.' }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The name of the UserGroup.' }, ownerId: { - type: types.string, - nullable: bool.false, optional: bool.false, + type: 'string' as const, + nullable: false as const, optional: false as const, format: 'id', }, userIds: { - type: types.array, - nullable: bool.false, optional: bool.true, + type: 'array' as const, + nullable: false as const, optional: true as const, items: { - type: types.string, - nullable: bool.false, optional: bool.false, + type: 'string' as const, + nullable: false as const, optional: false as const, format: 'id', } }, diff --git a/src/models/repositories/user-list.ts b/src/models/repositories/user-list.ts index 54231c7f851e..8842118be44e 100644 --- a/src/models/repositories/user-list.ts +++ b/src/models/repositories/user-list.ts @@ -2,7 +2,7 @@ import { EntityRepository, Repository } from 'typeorm'; import { UserList } from '../entities/user-list'; import { ensure } from '../../prelude/ensure'; import { UserListJoinings } from '..'; -import { bool, types, SchemaType } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; export type PackedUserList = SchemaType; @@ -27,33 +27,33 @@ export class UserListRepository extends Repository { } export const packedUserListSchema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { id: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'id', description: 'The unique identifier for this UserList.', example: 'xxxxxxxxxx', }, createdAt: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'date-time', description: 'The date that the UserList was created.' }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The name of the UserList.' }, userIds: { - type: types.array, - nullable: bool.false, optional: bool.true, + type: 'array' as const, + nullable: false as const, optional: true as const, items: { - type: types.string, - nullable: bool.false, optional: bool.false, + type: 'string' as const, + nullable: false as const, optional: false as const, format: 'id', } }, diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index bd48f04ea3d5..5da7ee783277 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -4,7 +4,7 @@ import { User, ILocalUser, IRemoteUser } from '../entities/user'; import { Emojis, Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserGroupJoinings } from '..'; import { ensure } from '../../prelude/ensure'; import config from '../../config'; -import { SchemaType, bool, types } from '../../misc/schema'; +import { SchemaType } from '../../misc/schema'; import { awaitAll } from '../../prelude/await-all'; export type PackedUser = SchemaType; @@ -243,150 +243,150 @@ export class UserRepository extends Repository { } export const packedUserSchema = { - type: types.object, - nullable: bool.false, optional: bool.false, + type: 'object' as const, + nullable: false as const, optional: false as const, properties: { id: { - type: types.string, - nullable: bool.false, optional: bool.false, + type: 'string' as const, + nullable: false as const, optional: false as const, format: 'id', description: 'The unique identifier for this User.', example: 'xxxxxxxxxx', }, username: { - type: types.string, - nullable: bool.false, optional: bool.false, + type: 'string' as const, + nullable: false as const, optional: false as const, description: 'The screen name, handle, or alias that this user identifies themselves with.', example: 'ai' }, name: { - type: types.string, - nullable: bool.true, optional: bool.false, + type: 'string' as const, + nullable: true as const, optional: false as const, description: 'The name of the user, as they’ve defined it.', example: '藍' }, url: { - type: types.string, + type: 'string' as const, format: 'url', - nullable: bool.true, optional: bool.true, + nullable: true as const, optional: true as const, }, avatarUrl: { - type: types.string, + type: 'string' as const, format: 'url', - nullable: bool.true, optional: bool.false, + nullable: true as const, optional: false as const, }, avatarColor: { - type: types.any, - nullable: bool.true, optional: bool.false, + type: 'any' as const, + nullable: true as const, optional: false as const, }, bannerUrl: { - type: types.string, + type: 'string' as const, format: 'url', - nullable: bool.true, optional: bool.true, + nullable: true as const, optional: true as const, }, bannerColor: { - type: types.any, - nullable: bool.true, optional: bool.true, + type: 'any' as const, + nullable: true as const, optional: true as const, }, emojis: { - type: types.any, - nullable: bool.true, optional: bool.false, + type: 'any' as const, + nullable: true as const, optional: false as const, }, host: { - type: types.string, - nullable: bool.true, optional: bool.false, + type: 'string' as const, + nullable: true as const, optional: false as const, example: 'misskey.example.com' }, description: { - type: types.string, - nullable: bool.true, optional: bool.true, + type: 'string' as const, + nullable: true as const, optional: true as const, description: 'The user-defined UTF-8 string describing their account.', example: 'Hi masters, I am Ai!' }, birthday: { - type: types.string, - nullable: bool.true, optional: bool.true, + type: 'string' as const, + nullable: true as const, optional: true as const, example: '2018-03-12' }, createdAt: { - type: types.string, - nullable: bool.false, optional: bool.true, + type: 'string' as const, + nullable: false as const, optional: true as const, format: 'date-time', description: 'The date that the user account was created on Misskey.' }, updatedAt: { - type: types.string, - nullable: bool.true, optional: bool.true, + type: 'string' as const, + nullable: true as const, optional: true as const, format: 'date-time', }, location: { - type: types.string, - nullable: bool.true, optional: bool.true, + type: 'string' as const, + nullable: true as const, optional: true as const, }, followersCount: { - type: types.number, - nullable: bool.false, optional: bool.true, + type: 'number' as const, + nullable: false as const, optional: true as const, description: 'The number of followers this account currently has.' }, followingCount: { - type: types.number, - nullable: bool.false, optional: bool.true, + type: 'number' as const, + nullable: false as const, optional: true as const, description: 'The number of users this account is following.' }, notesCount: { - type: types.number, - nullable: bool.false, optional: bool.true, + type: 'number' as const, + nullable: false as const, optional: true as const, description: 'The number of Notes (including renotes) issued by the user.' }, isBot: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, description: 'Whether this account is a bot.' }, pinnedNoteIds: { - type: types.array, - nullable: bool.false, optional: bool.true, + type: 'array' as const, + nullable: false as const, optional: true as const, items: { - type: types.string, - nullable: bool.false, optional: bool.false, + type: 'string' as const, + nullable: false as const, optional: false as const, format: 'id', } }, pinnedNotes: { - type: types.array, - nullable: bool.false, optional: bool.true, + type: 'array' as const, + nullable: false as const, optional: true as const, items: { - type: types.object, - nullable: bool.false, optional: bool.false, + type: 'object' as const, + nullable: false as const, optional: false as const, ref: 'Note' } }, isCat: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, description: 'Whether this account is a cat.' }, isAdmin: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, description: 'Whether this account is the admin.' }, isModerator: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, description: 'Whether this account is a moderator.' }, isLocked: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, }, hasUnreadSpecifiedNotes: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, }, hasUnreadMentions: { - type: types.boolean, - nullable: bool.false, optional: bool.true, + type: 'boolean' as const, + nullable: false as const, optional: true as const, }, }, }; diff --git a/src/server/api/endpoints/app/create.ts b/src/server/api/endpoints/app/create.ts index 833d5060c502..81c851f3a3ab 100644 --- a/src/server/api/endpoints/app/create.ts +++ b/src/server/api/endpoints/app/create.ts @@ -4,7 +4,6 @@ import define from '../../define'; import { Apps } from '../../../../models'; import { genId } from '../../../../misc/gen-id'; import { unique } from '../../../../prelude/array'; -import { types, bool } from '../../../../misc/schema'; export const meta = { tags: ['app'], @@ -53,8 +52,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'App', }, }; diff --git a/src/server/api/endpoints/app/show.ts b/src/server/api/endpoints/app/show.ts index e7d3e84388a6..2c8cdbe39633 100644 --- a/src/server/api/endpoints/app/show.ts +++ b/src/server/api/endpoints/app/show.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { ApiError } from '../../error'; import { Apps } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { tags: ['app'], @@ -15,8 +14,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'App', }, diff --git a/src/server/api/endpoints/auth/session/generate.ts b/src/server/api/endpoints/auth/session/generate.ts index 9bf27c8e77c6..b38c275deb3f 100644 --- a/src/server/api/endpoints/auth/session/generate.ts +++ b/src/server/api/endpoints/auth/session/generate.ts @@ -5,7 +5,6 @@ import define from '../../../define'; import { ApiError } from '../../../error'; import { Apps, AuthSessions } from '../../../../../models'; import { genId } from '../../../../../misc/gen-id'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { tags: ['auth'], @@ -28,17 +27,17 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { token: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'セッションのトークン' }, url: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, format: 'url', description: 'セッションのURL' }, diff --git a/src/server/api/endpoints/auth/session/userkey.ts b/src/server/api/endpoints/auth/session/userkey.ts index b7a58c475039..1dc78eeabd75 100644 --- a/src/server/api/endpoints/auth/session/userkey.ts +++ b/src/server/api/endpoints/auth/session/userkey.ts @@ -3,7 +3,6 @@ import define from '../../../define'; import { ApiError } from '../../../error'; import { Apps, AuthSessions, AccessTokens, Users } from '../../../../../models'; import { ensure } from '../../../../../prelude/ensure'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { tags: ['auth'], @@ -29,18 +28,18 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { accessToken: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'ユーザーのアクセストークン', }, user: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', description: '認証したユーザー' }, diff --git a/src/server/api/endpoints/blocking/list.ts b/src/server/api/endpoints/blocking/list.ts index 5ff1dc0c49ec..c99ba09df0a4 100644 --- a/src/server/api/endpoints/blocking/list.ts +++ b/src/server/api/endpoints/blocking/list.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { Blockings } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -33,11 +32,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Blocking', } }, diff --git a/src/server/api/endpoints/drive.ts b/src/server/api/endpoints/drive.ts index 4d4516bd8030..bb85bab148f1 100644 --- a/src/server/api/endpoints/drive.ts +++ b/src/server/api/endpoints/drive.ts @@ -1,7 +1,6 @@ import define from '../define'; import { fetchMeta } from '../../../misc/fetch-meta'; import { DriveFiles } from '../../../models'; -import { types, bool } from '../../../misc/schema'; export const meta = { desc: { @@ -16,16 +15,16 @@ export const meta = { kind: 'read:drive', res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { capacity: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, }, usage: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, } } } diff --git a/src/server/api/endpoints/drive/files.ts b/src/server/api/endpoints/drive/files.ts index d10c2a3ef46c..77cefdfbe35d 100644 --- a/src/server/api/endpoints/drive/files.ts +++ b/src/server/api/endpoints/drive/files.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { DriveFiles } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -42,11 +41,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile', } }, diff --git a/src/server/api/endpoints/drive/files/attached-notes.ts b/src/server/api/endpoints/drive/files/attached-notes.ts index f770bc7136d6..2b84e114b373 100644 --- a/src/server/api/endpoints/drive/files/attached-notes.ts +++ b/src/server/api/endpoints/drive/files/attached-notes.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { ApiError } from '../../../error'; import { DriveFiles, Notes } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { stability: 'stable', @@ -30,11 +29,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/drive/files/check-existence.ts b/src/server/api/endpoints/drive/files/check-existence.ts index ab19566f1cef..a6cd14caf2ba 100644 --- a/src/server/api/endpoints/drive/files/check-existence.ts +++ b/src/server/api/endpoints/drive/files/check-existence.ts @@ -1,7 +1,6 @@ import $ from 'cafy'; import define from '../../../define'; import { DriveFiles } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -25,8 +24,8 @@ export const meta = { }, res: { - type: types.boolean, - optional: bool.false, nullable: bool.false, + type: 'boolean' as const, + optional: false as const, nullable: false as const, }, }; diff --git a/src/server/api/endpoints/drive/files/create.ts b/src/server/api/endpoints/drive/files/create.ts index 0f81a1da9922..664a2b87b2e8 100644 --- a/src/server/api/endpoints/drive/files/create.ts +++ b/src/server/api/endpoints/drive/files/create.ts @@ -6,7 +6,6 @@ import define from '../../../define'; import { apiLogger } from '../../../logger'; import { ApiError } from '../../../error'; import { DriveFiles } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -57,8 +56,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile', }, diff --git a/src/server/api/endpoints/drive/files/find-by-hash.ts b/src/server/api/endpoints/drive/files/find-by-hash.ts index d56e63bc59c5..84cc4f92b10a 100644 --- a/src/server/api/endpoints/drive/files/find-by-hash.ts +++ b/src/server/api/endpoints/drive/files/find-by-hash.ts @@ -1,7 +1,6 @@ import $ from 'cafy'; import define from '../../../define'; import { DriveFiles } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -24,11 +23,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile', } }, diff --git a/src/server/api/endpoints/drive/files/find.ts b/src/server/api/endpoints/drive/files/find.ts index 82b9a97b6d55..732596a33feb 100644 --- a/src/server/api/endpoints/drive/files/find.ts +++ b/src/server/api/endpoints/drive/files/find.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { DriveFiles } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { requireCredential: true, @@ -26,11 +25,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile', } }, diff --git a/src/server/api/endpoints/drive/files/show.ts b/src/server/api/endpoints/drive/files/show.ts index 8e74361f9ce1..4384b2114dbd 100644 --- a/src/server/api/endpoints/drive/files/show.ts +++ b/src/server/api/endpoints/drive/files/show.ts @@ -4,7 +4,6 @@ import define from '../../../define'; import { ApiError } from '../../../error'; import { DriveFile } from '../../../../../models/entities/drive-file'; import { DriveFiles } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { stability: 'stable', @@ -39,8 +38,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile', }, diff --git a/src/server/api/endpoints/drive/folders.ts b/src/server/api/endpoints/drive/folders.ts index dc3174cd2a09..e2d22e708117 100644 --- a/src/server/api/endpoints/drive/folders.ts +++ b/src/server/api/endpoints/drive/folders.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { DriveFolders } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -38,11 +37,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFolder', } }, diff --git a/src/server/api/endpoints/drive/folders/find.ts b/src/server/api/endpoints/drive/folders/find.ts index 0368d026c3b5..04bec1b170d7 100644 --- a/src/server/api/endpoints/drive/folders/find.ts +++ b/src/server/api/endpoints/drive/folders/find.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { DriveFolders } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { tags: ['drive'], @@ -26,11 +25,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFolder', } }, diff --git a/src/server/api/endpoints/drive/folders/show.ts b/src/server/api/endpoints/drive/folders/show.ts index a020b46aa93c..f48f21d73027 100644 --- a/src/server/api/endpoints/drive/folders/show.ts +++ b/src/server/api/endpoints/drive/folders/show.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { ApiError } from '../../../error'; import { DriveFolders } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { stability: 'stable', @@ -30,8 +29,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFolder', }, diff --git a/src/server/api/endpoints/drive/stream.ts b/src/server/api/endpoints/drive/stream.ts index f75c4273c344..b93ee11a141f 100644 --- a/src/server/api/endpoints/drive/stream.ts +++ b/src/server/api/endpoints/drive/stream.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { DriveFiles } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { tags: ['drive'], @@ -32,11 +31,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'DriveFile', } }, diff --git a/src/server/api/endpoints/hashtags/list.ts b/src/server/api/endpoints/hashtags/list.ts index 9023f1191365..9bc267779322 100644 --- a/src/server/api/endpoints/hashtags/list.ts +++ b/src/server/api/endpoints/hashtags/list.ts @@ -1,7 +1,6 @@ import $ from 'cafy'; import define from '../../define'; import { Hashtags } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { tags: ['hashtags'], @@ -48,11 +47,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Hashtag', } }, diff --git a/src/server/api/endpoints/hashtags/search.ts b/src/server/api/endpoints/hashtags/search.ts index 0d2704d01c04..7caaf3484647 100644 --- a/src/server/api/endpoints/hashtags/search.ts +++ b/src/server/api/endpoints/hashtags/search.ts @@ -1,7 +1,6 @@ import $ from 'cafy'; import define from '../../define'; import { Hashtags } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -38,11 +37,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, } }, }; diff --git a/src/server/api/endpoints/hashtags/show.ts b/src/server/api/endpoints/hashtags/show.ts index 72a4cc7c876e..5de906fb1f89 100644 --- a/src/server/api/endpoints/hashtags/show.ts +++ b/src/server/api/endpoints/hashtags/show.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import define from '../../define'; import { ApiError } from '../../error'; import { Hashtags } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -24,8 +23,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Hashtag', }, diff --git a/src/server/api/endpoints/hashtags/trend.ts b/src/server/api/endpoints/hashtags/trend.ts index 53a351471814..3154461e5a32 100644 --- a/src/server/api/endpoints/hashtags/trend.ts +++ b/src/server/api/endpoints/hashtags/trend.ts @@ -2,7 +2,6 @@ import define from '../../define'; import { fetchMeta } from '../../../../misc/fetch-meta'; import { Notes } from '../../../../models'; import { Note } from '../../../../models/entities/note'; -import { types, bool } from '../../../../misc/schema'; /* トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要 @@ -24,27 +23,27 @@ export const meta = { requireCredential: false, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { tag: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, }, chart: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, } }, usersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, } } } diff --git a/src/server/api/endpoints/hashtags/users.ts b/src/server/api/endpoints/hashtags/users.ts index b842f9de6438..59210f4604e7 100644 --- a/src/server/api/endpoints/hashtags/users.ts +++ b/src/server/api/endpoints/hashtags/users.ts @@ -1,7 +1,6 @@ import $ from 'cafy'; import define from '../../define'; import { Users } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { requireCredential: false, @@ -48,11 +47,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', } }, diff --git a/src/server/api/endpoints/i.ts b/src/server/api/endpoints/i.ts index 4ecd507e165f..20a0c604f673 100644 --- a/src/server/api/endpoints/i.ts +++ b/src/server/api/endpoints/i.ts @@ -1,6 +1,5 @@ import define from '../define'; import { Users } from '../../../models'; -import { types, bool } from '../../../misc/schema'; export const meta = { stability: 'stable', @@ -16,8 +15,8 @@ export const meta = { params: {}, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', }, }; diff --git a/src/server/api/endpoints/i/favorites.ts b/src/server/api/endpoints/i/favorites.ts index d1e90dd15c9e..1bbc16256a7a 100644 --- a/src/server/api/endpoints/i/favorites.ts +++ b/src/server/api/endpoints/i/favorites.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { NoteFavorites } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -33,11 +32,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'NoteFavorite', } }, diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts index 41513e5daa0f..aa72e9a176f9 100644 --- a/src/server/api/endpoints/i/notifications.ts +++ b/src/server/api/endpoints/i/notifications.ts @@ -4,7 +4,6 @@ import { readNotification } from '../../common/read-notification'; import define from '../../define'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notifications, Followings, Mutings } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -54,11 +53,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Notification', } }, diff --git a/src/server/api/endpoints/messaging/history.ts b/src/server/api/endpoints/messaging/history.ts index 833ec37e4cf4..2c143c26b5bb 100644 --- a/src/server/api/endpoints/messaging/history.ts +++ b/src/server/api/endpoints/messaging/history.ts @@ -3,7 +3,6 @@ import define from '../../define'; import { MessagingMessage } from '../../../../models/entities/messaging-message'; import { MessagingMessages, Mutings, UserGroupJoinings } from '../../../../models'; import { Brackets } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -30,11 +29,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'MessagingMessage', } }, diff --git a/src/server/api/endpoints/messaging/messages.ts b/src/server/api/endpoints/messaging/messages.ts index ffd58c714e65..b0b3e20d02ed 100644 --- a/src/server/api/endpoints/messaging/messages.ts +++ b/src/server/api/endpoints/messaging/messages.ts @@ -5,7 +5,6 @@ import { ApiError } from '../../error'; import { getUser } from '../../common/getters'; import { MessagingMessages, UserGroups, UserGroupJoinings } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; -import { types, bool } from '../../../../misc/schema'; import { Brackets } from 'typeorm'; import { readUserMessagingMessage, readGroupMessagingMessage } from '../../common/read-messaging-message'; @@ -58,11 +57,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'MessagingMessage', } }, diff --git a/src/server/api/endpoints/messaging/messages/create.ts b/src/server/api/endpoints/messaging/messages/create.ts index feffc9a0c606..d0c1ee49410b 100644 --- a/src/server/api/endpoints/messaging/messages/create.ts +++ b/src/server/api/endpoints/messaging/messages/create.ts @@ -9,7 +9,6 @@ import { getUser } from '../../../common/getters'; import { MessagingMessages, DriveFiles, Mutings, UserGroups, UserGroupJoinings } from '../../../../../models'; import { MessagingMessage } from '../../../../../models/entities/messaging-message'; import { genId } from '../../../../../misc/gen-id'; -import { types, bool } from '../../../../../misc/schema'; import { User } from '../../../../../models/entities/user'; import { UserGroup } from '../../../../../models/entities/user-group'; import { Not } from 'typeorm'; @@ -53,8 +52,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'MessagingMessage', }, diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 1aa9a855ddb2..a3390a011d3f 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -5,7 +5,6 @@ import define from '../define'; import { fetchMeta } from '../../../misc/fetch-meta'; import * as pkg from '../../../../package.json'; import { Emojis } from '../../../models'; -import { types, bool } from '../../../misc/schema'; import { getConnection } from 'typeorm'; import redis from '../../../db/redis'; @@ -29,40 +28,40 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { version: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The version of Misskey of this instance.', example: pkg.version }, name: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The name of this instance.', }, description: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The description of this instance.', }, announcements: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { title: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The title of the announcement.', }, text: { - type: types.string, - optional: bool.false, nullable: bool.false, + type: 'string' as const, + optional: false as const, nullable: false as const, description: 'The text of the announcement. (can be HTML)', }, } @@ -70,23 +69,23 @@ export const meta = { description: 'The announcements of this instance.', }, disableRegistration: { - type: types.boolean, - optional: bool.false, nullable: bool.false, + type: 'boolean' as const, + optional: false as const, nullable: false as const, description: 'Whether disabled open registration.', }, disableLocalTimeline: { - type: types.boolean, - optional: bool.false, nullable: bool.false, + type: 'boolean' as const, + optional: false as const, nullable: false as const, description: 'Whether disabled LTL and STL.', }, disableGlobalTimeline: { - type: types.boolean, - optional: bool.false, nullable: bool.false, + type: 'boolean' as const, + optional: false as const, nullable: false as const, description: 'Whether disabled GTL.', }, enableEmojiReaction: { - type: types.boolean, - optional: bool.false, nullable: bool.false, + type: 'boolean' as const, + optional: false as const, nullable: false as const, description: 'Whether enabled emoji reaction.', }, } diff --git a/src/server/api/endpoints/mute/list.ts b/src/server/api/endpoints/mute/list.ts index f9ea380c7627..1afc120f5f12 100644 --- a/src/server/api/endpoints/mute/list.ts +++ b/src/server/api/endpoints/mute/list.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Mutings } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -33,11 +32,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Muting', } }, diff --git a/src/server/api/endpoints/notes.ts b/src/server/api/endpoints/notes.ts index 7aa19c9a2b02..fab8455d78b4 100644 --- a/src/server/api/endpoints/notes.ts +++ b/src/server/api/endpoints/notes.ts @@ -3,7 +3,6 @@ import { ID } from '../../../misc/cafy-id'; import define from '../define'; import { makePaginationQuery } from '../common/make-pagination-query'; import { Notes } from '../../../models'; -import { types, bool } from '../../../misc/schema'; export const meta = { desc: { @@ -63,11 +62,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/children.ts b/src/server/api/endpoints/notes/children.ts index e8861eafa136..bc8407f31ca4 100644 --- a/src/server/api/endpoints/notes/children.ts +++ b/src/server/api/endpoints/notes/children.ts @@ -6,7 +6,6 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query' import { generateMuteQuery } from '../../common/generate-mute-query'; import { Brackets } from 'typeorm'; import { Notes } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -42,11 +41,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/conversation.ts b/src/server/api/endpoints/notes/conversation.ts index acd3ac75ef1d..245d427923f0 100644 --- a/src/server/api/endpoints/notes/conversation.ts +++ b/src/server/api/endpoints/notes/conversation.ts @@ -5,7 +5,6 @@ import { ApiError } from '../../error'; import { getNote } from '../../common/getters'; import { Note } from '../../../../models/entities/note'; import { Notes } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -38,11 +37,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/create.ts b/src/server/api/endpoints/notes/create.ts index 46db2745815d..1650de90719d 100644 --- a/src/server/api/endpoints/notes/create.ts +++ b/src/server/api/endpoints/notes/create.ts @@ -10,7 +10,6 @@ import { User } from '../../../../models/entities/user'; import { Users, DriveFiles, Notes } from '../../../../models'; import { DriveFile } from '../../../../models/entities/drive-file'; import { Note } from '../../../../models/entities/note'; -import { types, bool } from '../../../../misc/schema'; let maxNoteTextLength = 1000; @@ -175,12 +174,12 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { createdNote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', description: '作成した投稿' } diff --git a/src/server/api/endpoints/notes/featured.ts b/src/server/api/endpoints/notes/featured.ts index 64750815b0b7..0a1d8668b0c4 100644 --- a/src/server/api/endpoints/notes/featured.ts +++ b/src/server/api/endpoints/notes/featured.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import define from '../../define'; import { generateMuteQuery } from '../../common/generate-mute-query'; import { Notes } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -25,11 +24,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/global-timeline.ts b/src/server/api/endpoints/notes/global-timeline.ts index f46fa208df53..8654cf889a42 100644 --- a/src/server/api/endpoints/notes/global-timeline.ts +++ b/src/server/api/endpoints/notes/global-timeline.ts @@ -7,7 +7,6 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notes } from '../../../../models'; import { generateMuteQuery } from '../../common/generate-mute-query'; import { activeUsersChart } from '../../../../services/chart'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -47,11 +46,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/hybrid-timeline.ts b/src/server/api/endpoints/notes/hybrid-timeline.ts index 7be13fc47f98..8c4c7a60b98e 100644 --- a/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -9,7 +9,6 @@ import { Brackets } from 'typeorm'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { generateMuteQuery } from '../../common/generate-mute-query'; import { activeUsersChart } from '../../../../services/chart'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -90,11 +89,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts index 73cbebace25a..c688b9325e96 100644 --- a/src/server/api/endpoints/notes/local-timeline.ts +++ b/src/server/api/endpoints/notes/local-timeline.ts @@ -9,7 +9,6 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { activeUsersChart } from '../../../../services/chart'; import { Brackets } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -64,11 +63,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index 02e44492ba3e..fd3767f63298 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -7,7 +7,6 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query' import { generateMuteQuery } from '../../common/generate-mute-query'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Brackets } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -44,11 +43,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/reactions.ts b/src/server/api/endpoints/notes/reactions.ts index 0773b4faa27a..7bea24d316a7 100644 --- a/src/server/api/endpoints/notes/reactions.ts +++ b/src/server/api/endpoints/notes/reactions.ts @@ -4,7 +4,6 @@ import define from '../../define'; import { getNote } from '../../common/getters'; import { ApiError } from '../../error'; import { NoteReactions } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -45,11 +44,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'NoteReaction', } }, diff --git a/src/server/api/endpoints/notes/renotes.ts b/src/server/api/endpoints/notes/renotes.ts index 00dfac377095..a5db706e3228 100644 --- a/src/server/api/endpoints/notes/renotes.ts +++ b/src/server/api/endpoints/notes/renotes.ts @@ -7,7 +7,6 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query' import { generateMuteQuery } from '../../common/generate-mute-query'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notes } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -43,11 +42,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/replies.ts b/src/server/api/endpoints/notes/replies.ts index 5fb0fd989fd0..cd38d41652c8 100644 --- a/src/server/api/endpoints/notes/replies.ts +++ b/src/server/api/endpoints/notes/replies.ts @@ -5,7 +5,6 @@ import { Notes } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { generateMuteQuery } from '../../common/generate-mute-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -47,11 +46,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/search-by-tag.ts b/src/server/api/endpoints/notes/search-by-tag.ts index 0b49f896ad6c..7f53b269956a 100644 --- a/src/server/api/endpoints/notes/search-by-tag.ts +++ b/src/server/api/endpoints/notes/search-by-tag.ts @@ -6,7 +6,6 @@ import { Notes } from '../../../../models'; import { generateMuteQuery } from '../../common/generate-mute-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { Brackets } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -82,11 +81,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index 65ce20074acb..d3fb33c420aa 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -4,7 +4,6 @@ import define from '../../define'; import { ApiError } from '../../error'; import { Notes } from '../../../../models'; import { In } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; import { ID } from '../../../../misc/cafy-id'; export const meta = { @@ -44,11 +43,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/show.ts b/src/server/api/endpoints/notes/show.ts index 54b420813d3f..75abbae55fb1 100644 --- a/src/server/api/endpoints/notes/show.ts +++ b/src/server/api/endpoints/notes/show.ts @@ -4,7 +4,6 @@ import define from '../../define'; import { getNote } from '../../common/getters'; import { ApiError } from '../../error'; import { Notes } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { stability: 'stable', @@ -29,8 +28,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', }, diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts index f9442f8b9068..25876f655a49 100644 --- a/src/server/api/endpoints/notes/timeline.ts +++ b/src/server/api/endpoints/notes/timeline.ts @@ -7,7 +7,6 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query' import { generateMuteQuery } from '../../common/generate-mute-query'; import { activeUsersChart } from '../../../../services/chart'; import { Brackets } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -89,11 +88,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/notes/user-list-timeline.ts b/src/server/api/endpoints/notes/user-list-timeline.ts index c16018d434e2..f66221537d20 100644 --- a/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/src/server/api/endpoints/notes/user-list-timeline.ts @@ -6,7 +6,6 @@ import { UserLists, UserListJoinings, Notes } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { activeUsersChart } from '../../../../services/chart'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -95,11 +94,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/pages/create.ts b/src/server/api/endpoints/pages/create.ts index e6b813648b9b..ffe0d38ea691 100644 --- a/src/server/api/endpoints/pages/create.ts +++ b/src/server/api/endpoints/pages/create.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import * as ms from 'ms'; import define from '../../define'; import { ID } from '../../../../misc/cafy-id'; -import { types, bool } from '../../../../misc/schema'; import { Pages, DriveFiles } from '../../../../models'; import { genId } from '../../../../misc/gen-id'; import { Page } from '../../../../models/entities/page'; @@ -61,8 +60,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Page', }, diff --git a/src/server/api/endpoints/pages/show.ts b/src/server/api/endpoints/pages/show.ts index e3d6e6a15ff4..84808418f3a8 100644 --- a/src/server/api/endpoints/pages/show.ts +++ b/src/server/api/endpoints/pages/show.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import define from '../../define'; import { ApiError } from '../../error'; import { Pages, Users } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; import { ID } from '../../../../misc/cafy-id'; import { Page } from '../../../../models/entities/page'; @@ -34,8 +33,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Page', }, diff --git a/src/server/api/endpoints/pinned-users.ts b/src/server/api/endpoints/pinned-users.ts index de0e17a2ecc9..853e1cd4b8bc 100644 --- a/src/server/api/endpoints/pinned-users.ts +++ b/src/server/api/endpoints/pinned-users.ts @@ -1,6 +1,5 @@ import define from '../define'; import { Users } from '../../../models'; -import { types, bool } from '../../../misc/schema'; import { fetchMeta } from '../../../misc/fetch-meta'; import parseAcct from '../../../misc/acct/parse'; import { User } from '../../../models/entities/user'; @@ -14,11 +13,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', } }, diff --git a/src/server/api/endpoints/stats.ts b/src/server/api/endpoints/stats.ts index 4dca62445ff4..c86d893d5ec2 100644 --- a/src/server/api/endpoints/stats.ts +++ b/src/server/api/endpoints/stats.ts @@ -1,7 +1,6 @@ import define from '../define'; import { Notes, Users } from '../../../models'; import { federationChart, driveChart } from '../../../services/chart'; -import { bool, types } from '../../../misc/schema'; export const meta = { requireCredential: false, @@ -16,32 +15,32 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { notesCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'The count of all (local/remote) notes of this instance.', }, originalNotesCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'The count of all local notes of this instance.', }, usersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'The count of all (local/remote) accounts of this instance.', }, originalUsersCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'The count of all local accounts of this instance.', }, instances: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'The count of federated instances.', }, } diff --git a/src/server/api/endpoints/users.ts b/src/server/api/endpoints/users.ts index 539f2ef897a9..93cf01a6f866 100644 --- a/src/server/api/endpoints/users.ts +++ b/src/server/api/endpoints/users.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import define from '../define'; import { Users } from '../../../models'; import { generateMuteQueryForUsers } from '../common/generate-mute-query'; -import { types, bool } from '../../../misc/schema'; export const meta = { tags: ['users'], @@ -53,11 +52,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', } }, diff --git a/src/server/api/endpoints/users/followers.ts b/src/server/api/endpoints/users/followers.ts index 465b71e2e6e3..68c32fe983ee 100644 --- a/src/server/api/endpoints/users/followers.ts +++ b/src/server/api/endpoints/users/followers.ts @@ -5,7 +5,6 @@ import { ApiError } from '../../error'; import { Users, Followings } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { toPunyNullable } from '../../../../misc/convert-host'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -49,11 +48,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Following', } }, diff --git a/src/server/api/endpoints/users/following.ts b/src/server/api/endpoints/users/following.ts index 2a7748ac64b6..eb699b29037f 100644 --- a/src/server/api/endpoints/users/following.ts +++ b/src/server/api/endpoints/users/following.ts @@ -5,7 +5,6 @@ import { ApiError } from '../../error'; import { Users, Followings } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { toPunyNullable } from '../../../../misc/convert-host'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -49,11 +48,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Following', } }, diff --git a/src/server/api/endpoints/users/get-frequently-replied-users.ts b/src/server/api/endpoints/users/get-frequently-replied-users.ts index 24d1bd194cd1..1a17b488f09a 100644 --- a/src/server/api/endpoints/users/get-frequently-replied-users.ts +++ b/src/server/api/endpoints/users/get-frequently-replied-users.ts @@ -6,7 +6,6 @@ import { ApiError } from '../../error'; import { getUser } from '../../common/getters'; import { Not, In, IsNull } from 'typeorm'; import { Notes, Users } from '../../../../models'; -import { types, bool } from '../../../../misc/schema'; export const meta = { tags: ['users'], @@ -29,11 +28,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', } }, diff --git a/src/server/api/endpoints/users/groups/create.ts b/src/server/api/endpoints/users/groups/create.ts index ee6cade8d07f..2a6e5135e557 100644 --- a/src/server/api/endpoints/users/groups/create.ts +++ b/src/server/api/endpoints/users/groups/create.ts @@ -3,7 +3,6 @@ import define from '../../../define'; import { UserGroups, UserGroupJoinings } from '../../../../../models'; import { genId } from '../../../../../misc/gen-id'; import { UserGroup } from '../../../../../models/entities/user-group'; -import { types, bool } from '../../../../../misc/schema'; import { UserGroupJoining } from '../../../../../models/entities/user-group-joining'; export const meta = { @@ -25,8 +24,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserGroup', }, }; diff --git a/src/server/api/endpoints/users/groups/joined.ts b/src/server/api/endpoints/users/groups/joined.ts index 97d168e52736..c60ba57c0912 100644 --- a/src/server/api/endpoints/users/groups/joined.ts +++ b/src/server/api/endpoints/users/groups/joined.ts @@ -1,6 +1,5 @@ import define from '../../../define'; import { UserGroups, UserGroupJoinings } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; import { Not, In } from 'typeorm'; export const meta = { @@ -15,11 +14,11 @@ export const meta = { kind: 'read:user-groups', res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserGroup', } }, diff --git a/src/server/api/endpoints/users/groups/owned.ts b/src/server/api/endpoints/users/groups/owned.ts index 6cf39a142b7d..e2c0bf2fc180 100644 --- a/src/server/api/endpoints/users/groups/owned.ts +++ b/src/server/api/endpoints/users/groups/owned.ts @@ -1,6 +1,5 @@ import define from '../../../define'; import { UserGroups } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -14,11 +13,11 @@ export const meta = { kind: 'read:user-groups', res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserGroup', } }, diff --git a/src/server/api/endpoints/users/groups/show.ts b/src/server/api/endpoints/users/groups/show.ts index 4f8374a22234..643f1acf7a61 100644 --- a/src/server/api/endpoints/users/groups/show.ts +++ b/src/server/api/endpoints/users/groups/show.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { ApiError } from '../../../error'; import { UserGroups, UserGroupJoinings } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -24,8 +23,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserGroup', }, diff --git a/src/server/api/endpoints/users/groups/transfer.ts b/src/server/api/endpoints/users/groups/transfer.ts index b4284ab48458..012f9f4ef375 100644 --- a/src/server/api/endpoints/users/groups/transfer.ts +++ b/src/server/api/endpoints/users/groups/transfer.ts @@ -4,7 +4,6 @@ import define from '../../../define'; import { ApiError } from '../../../error'; import { getUser } from '../../../common/getters'; import { UserGroups, UserGroupJoinings } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -33,8 +32,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserGroup', }, diff --git a/src/server/api/endpoints/users/groups/update.ts b/src/server/api/endpoints/users/groups/update.ts index bc974621a34f..2fc0a803a194 100644 --- a/src/server/api/endpoints/users/groups/update.ts +++ b/src/server/api/endpoints/users/groups/update.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { ApiError } from '../../../error'; import { UserGroups } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -36,8 +35,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserGroup', }, diff --git a/src/server/api/endpoints/users/lists/create.ts b/src/server/api/endpoints/users/lists/create.ts index 79efffbf9ec3..28af3c8d86e9 100644 --- a/src/server/api/endpoints/users/lists/create.ts +++ b/src/server/api/endpoints/users/lists/create.ts @@ -3,7 +3,6 @@ import define from '../../../define'; import { UserLists } from '../../../../../models'; import { genId } from '../../../../../misc/gen-id'; import { UserList } from '../../../../../models/entities/user-list'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -24,8 +23,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserList', }, }; diff --git a/src/server/api/endpoints/users/lists/list.ts b/src/server/api/endpoints/users/lists/list.ts index 684086b5c6c7..7b89d34314f1 100644 --- a/src/server/api/endpoints/users/lists/list.ts +++ b/src/server/api/endpoints/users/lists/list.ts @@ -1,6 +1,5 @@ import define from '../../../define'; import { UserLists } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -14,11 +13,11 @@ export const meta = { kind: 'read:account', res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserList', } }, diff --git a/src/server/api/endpoints/users/lists/show.ts b/src/server/api/endpoints/users/lists/show.ts index 395f9352d42e..01d03d1bfb48 100644 --- a/src/server/api/endpoints/users/lists/show.ts +++ b/src/server/api/endpoints/users/lists/show.ts @@ -3,7 +3,6 @@ import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { ApiError } from '../../../error'; import { UserLists } from '../../../../../models'; -import { types, bool } from '../../../../../misc/schema'; export const meta = { desc: { @@ -24,8 +23,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'UserList', }, diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index fdc50e4dae55..ef564b3c3457 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -8,7 +8,6 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query' import { Notes } from '../../../../models'; import { generateMuteQuery } from '../../common/generate-mute-query'; import { Brackets } from 'typeorm'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -120,11 +119,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'Note', } }, diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index 38b420c332f4..73d8fe6208f5 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -3,7 +3,6 @@ import $ from 'cafy'; import define from '../../define'; import { Users, Followings } from '../../../../models'; import { generateMuteQueryForUsers } from '../../common/generate-mute-query'; -import { types, bool } from '../../../../misc/schema'; export const meta = { desc: { @@ -29,11 +28,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', } }, diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts index 5c413defbcd9..9aa9e398e31e 100644 --- a/src/server/api/endpoints/users/search.ts +++ b/src/server/api/endpoints/users/search.ts @@ -2,7 +2,6 @@ import $ from 'cafy'; import define from '../../define'; import { Users } from '../../../../models'; import { User } from '../../../../models/entities/user'; -import { bool, types } from '../../../../misc/schema'; export const meta = { desc: { @@ -55,11 +54,11 @@ export const meta = { }, res: { - type: types.array, - optional: bool.false, nullable: bool.false, + type: 'array' as const, + optional: false as const, nullable: false as const, items: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', } }, diff --git a/src/server/api/endpoints/users/show.ts b/src/server/api/endpoints/users/show.ts index 820c44e81ba8..30660aed3af9 100644 --- a/src/server/api/endpoints/users/show.ts +++ b/src/server/api/endpoints/users/show.ts @@ -6,7 +6,6 @@ import { ApiError } from '../../error'; import { ID } from '../../../../misc/cafy-id'; import { Users } from '../../../../models'; import { In } from 'typeorm'; -import { bool, types } from '../../../../misc/schema'; export const meta = { desc: { @@ -43,8 +42,8 @@ export const meta = { }, res: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, ref: 'User', }, diff --git a/src/services/chart/charts/schemas/active-users.ts b/src/services/chart/charts/schemas/active-users.ts index f10393bc36db..6e26bb469815 100644 --- a/src/services/chart/charts/schemas/active-users.ts +++ b/src/services/chart/charts/schemas/active-users.ts @@ -1,12 +1,10 @@ -import { types, bool } from '../../../../misc/schema'; - export const logSchema = { /** * アクティブユーザー数 */ count: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'アクティブユーザー数', }, }; @@ -15,17 +13,17 @@ export const logSchema = { * アクティブユーザーに関するチャート */ export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/charts/schemas/drive.ts b/src/services/chart/charts/schemas/drive.ts index 3327950635de..dcc50df8cf98 100644 --- a/src/services/chart/charts/schemas/drive.ts +++ b/src/services/chart/charts/schemas/drive.ts @@ -1,12 +1,10 @@ -import { types, bool } from '../../../../misc/schema'; - const logSchema = { /** * 集計期間時点での、全ドライブファイル数 */ totalCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ドライブファイル数' }, @@ -14,8 +12,8 @@ const logSchema = { * 集計期間時点での、全ドライブファイルの合計サイズ */ totalSize: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ドライブファイルの合計サイズ' }, @@ -23,8 +21,8 @@ const logSchema = { * 増加したドライブファイル数 */ incCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したドライブファイル数' }, @@ -32,8 +30,8 @@ const logSchema = { * 増加したドライブ使用量 */ incSize: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したドライブ使用量' }, @@ -41,8 +39,8 @@ const logSchema = { * 減少したドライブファイル数 */ decCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したドライブファイル数' }, @@ -50,24 +48,24 @@ const logSchema = { * 減少したドライブ使用量 */ decSize: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したドライブ使用量' }, }; export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/charts/schemas/federation.ts b/src/services/chart/charts/schemas/federation.ts index 41ae977cbd20..2f2d22c0d385 100644 --- a/src/services/chart/charts/schemas/federation.ts +++ b/src/services/chart/charts/schemas/federation.ts @@ -1,29 +1,27 @@ -import { types, bool } from '../../../../misc/schema'; - /** * フェデレーションに関するチャート */ export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { instance: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'インスタンス数の合計' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加インスタンス数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少インスタンス数' }, } diff --git a/src/services/chart/charts/schemas/hashtag.ts b/src/services/chart/charts/schemas/hashtag.ts index 918242f66e3c..4dfd61c97fe6 100644 --- a/src/services/chart/charts/schemas/hashtag.ts +++ b/src/services/chart/charts/schemas/hashtag.ts @@ -1,12 +1,10 @@ -import { types, bool } from '../../../../misc/schema'; - export const logSchema = { /** * 投稿された数 */ count: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '投稿された数', }, }; @@ -15,17 +13,17 @@ export const logSchema = { * ハッシュタグに関するチャート */ export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/charts/schemas/instance.ts b/src/services/chart/charts/schemas/instance.ts index d97f49ea7226..d2152a4ae7b5 100644 --- a/src/services/chart/charts/schemas/instance.ts +++ b/src/services/chart/charts/schemas/instance.ts @@ -1,73 +1,71 @@ -import { types, bool } from '../../../../misc/schema'; - /** * インスタンスごとのチャート */ export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { requests: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { failed: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '失敗したリクエスト数' }, succeeded: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '成功したリクエスト数' }, received: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '受信したリクエスト数' }, } }, notes: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全投稿数' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加した投稿数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少した投稿数' }, diffs: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { normal: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '通常の投稿数の差分' }, reply: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'リプライの投稿数の差分' }, renote: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Renoteの投稿数の差分' }, } @@ -76,103 +74,103 @@ export const schema = { }, users: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ユーザー数' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したユーザー数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したユーザー数' }, } }, following: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全フォロー数' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したフォロー数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したフォロー数' }, } }, followers: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全フォロワー数' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したフォロワー数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したフォロワー数' }, } }, drive: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { totalFiles: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ドライブファイル数' }, totalUsage: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ドライブファイルの合計サイズ' }, incFiles: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したドライブファイル数' }, incUsage: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したドライブ使用量' }, decFiles: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したドライブファイル数' }, decUsage: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したドライブ使用量' }, } diff --git a/src/services/chart/charts/schemas/network.ts b/src/services/chart/charts/schemas/network.ts index 819e2a145e78..30123c5d904d 100644 --- a/src/services/chart/charts/schemas/network.ts +++ b/src/services/chart/charts/schemas/network.ts @@ -1,35 +1,33 @@ -import { types, bool } from '../../../../misc/schema'; - /** * ネットワークに関するチャート */ export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { incomingRequests: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '受信したリクエスト数' }, outgoingRequests: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '送信したリクエスト数' }, totalTime: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '応答時間の合計' // TIP: (totalTime / incomingRequests) でひとつのリクエストに平均でどれくらいの時間がかかったか知れる }, incomingBytes: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '合計受信データ量' }, outgoingBytes: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '合計送信データ量' }, } diff --git a/src/services/chart/charts/schemas/notes.ts b/src/services/chart/charts/schemas/notes.ts index aabe49edd91f..6dbf321b7c2e 100644 --- a/src/services/chart/charts/schemas/notes.ts +++ b/src/services/chart/charts/schemas/notes.ts @@ -1,43 +1,41 @@ -import { types, bool } from '../../../../misc/schema'; - const logSchema = { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全投稿数' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加した投稿数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少した投稿数' }, diffs: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { normal: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '通常の投稿数の差分' }, reply: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'リプライの投稿数の差分' }, renote: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Renoteの投稿数の差分' }, } @@ -45,17 +43,17 @@ const logSchema = { }; export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/charts/schemas/per-user-drive.ts b/src/services/chart/charts/schemas/per-user-drive.ts index 62e77951677b..21312e82d875 100644 --- a/src/services/chart/charts/schemas/per-user-drive.ts +++ b/src/services/chart/charts/schemas/per-user-drive.ts @@ -1,15 +1,13 @@ -import { types, bool } from '../../../../misc/schema'; - export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { /** * 集計期間時点での、全ドライブファイル数 */ totalCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ドライブファイル数' }, @@ -17,8 +15,8 @@ export const schema = { * 集計期間時点での、全ドライブファイルの合計サイズ */ totalSize: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ドライブファイルの合計サイズ' }, @@ -26,8 +24,8 @@ export const schema = { * 増加したドライブファイル数 */ incCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したドライブファイル数' }, @@ -35,8 +33,8 @@ export const schema = { * 増加したドライブ使用量 */ incSize: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したドライブ使用量' }, @@ -44,8 +42,8 @@ export const schema = { * 減少したドライブファイル数 */ decCount: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したドライブファイル数' }, @@ -53,8 +51,8 @@ export const schema = { * 減少したドライブ使用量 */ decSize: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したドライブ使用量' }, } diff --git a/src/services/chart/charts/schemas/per-user-following.ts b/src/services/chart/charts/schemas/per-user-following.ts index e57869e79a99..dffd9c257217 100644 --- a/src/services/chart/charts/schemas/per-user-following.ts +++ b/src/services/chart/charts/schemas/per-user-following.ts @@ -1,19 +1,17 @@ -import { types, bool } from '../../../../misc/schema'; - export const logSchema = { /** * フォローしている */ followings: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { /** * フォローしている合計 */ total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'フォローしている合計', }, @@ -21,8 +19,8 @@ export const logSchema = { * フォローした数 */ inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'フォローした数', }, @@ -30,8 +28,8 @@ export const logSchema = { * フォロー解除した数 */ dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'フォロー解除した数', }, } @@ -41,15 +39,15 @@ export const logSchema = { * フォローされている */ followers: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { /** * フォローされている合計 */ total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'フォローされている合計', }, @@ -57,8 +55,8 @@ export const logSchema = { * フォローされた数 */ inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'フォローされた数', }, @@ -66,8 +64,8 @@ export const logSchema = { * フォロー解除された数 */ dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'フォロー解除された数', }, } @@ -75,17 +73,17 @@ export const logSchema = { }; export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/charts/schemas/per-user-notes.ts b/src/services/chart/charts/schemas/per-user-notes.ts index 76324500739f..778f498c6e82 100644 --- a/src/services/chart/charts/schemas/per-user-notes.ts +++ b/src/services/chart/charts/schemas/per-user-notes.ts @@ -1,46 +1,44 @@ -import { types, bool } from '../../../../misc/schema'; - export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全投稿数' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加した投稿数' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少した投稿数' }, diffs: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { normal: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '通常の投稿数の差分' }, reply: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'リプライの投稿数の差分' }, renote: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'Renoteの投稿数の差分' }, } diff --git a/src/services/chart/charts/schemas/per-user-reactions.ts b/src/services/chart/charts/schemas/per-user-reactions.ts index df7d5a6dbb11..d103124ccba1 100644 --- a/src/services/chart/charts/schemas/per-user-reactions.ts +++ b/src/services/chart/charts/schemas/per-user-reactions.ts @@ -1,12 +1,10 @@ -import { types, bool } from '../../../../misc/schema'; - export const logSchema = { /** * フォローしている合計 */ count: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: 'リアクションされた数', }, }; @@ -15,17 +13,17 @@ export const logSchema = { * ユーザーごとのリアクションに関するチャート */ export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/charts/schemas/test-grouped.ts b/src/services/chart/charts/schemas/test-grouped.ts index 893458e90a17..163ec5bba377 100644 --- a/src/services/chart/charts/schemas/test-grouped.ts +++ b/src/services/chart/charts/schemas/test-grouped.ts @@ -1,28 +1,26 @@ -import { types, bool } from '../../../../misc/schema'; - export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { foo: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, } diff --git a/src/services/chart/charts/schemas/test-unique.ts b/src/services/chart/charts/schemas/test-unique.ts index 2b3f445ff02e..075a8092d943 100644 --- a/src/services/chart/charts/schemas/test-unique.ts +++ b/src/services/chart/charts/schemas/test-unique.ts @@ -1,12 +1,10 @@ -import { types, bool } from '../../../../misc/schema'; - export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { foo: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, } diff --git a/src/services/chart/charts/schemas/test.ts b/src/services/chart/charts/schemas/test.ts index 9bdc05990b6a..6142434a89cc 100644 --- a/src/services/chart/charts/schemas/test.ts +++ b/src/services/chart/charts/schemas/test.ts @@ -1,28 +1,26 @@ -import { types, bool } from '../../../../misc/schema'; - export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { foo: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '' }, } diff --git a/src/services/chart/charts/schemas/users.ts b/src/services/chart/charts/schemas/users.ts index 6ae61333503d..115336998362 100644 --- a/src/services/chart/charts/schemas/users.ts +++ b/src/services/chart/charts/schemas/users.ts @@ -1,12 +1,10 @@ -import { types, bool } from '../../../../misc/schema'; - const logSchema = { /** * 集計期間時点での、全ユーザー数 */ total: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '集計期間時点での、全ユーザー数' }, @@ -14,8 +12,8 @@ const logSchema = { * 増加したユーザー数 */ inc: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '増加したユーザー数' }, @@ -23,24 +21,24 @@ const logSchema = { * 減少したユーザー数 */ dec: { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, description: '減少したユーザー数' }, }; export const schema = { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: { local: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, remote: { - type: types.object, - optional: bool.false, nullable: bool.false, + type: 'object' as const, + optional: false as const, nullable: false as const, properties: logSchema }, } diff --git a/src/services/chart/core.ts b/src/services/chart/core.ts index 6564ef781395..d5fd9a5c5cc2 100644 --- a/src/services/chart/core.ts +++ b/src/services/chart/core.ts @@ -8,7 +8,7 @@ import * as moment from 'moment'; import * as nestedProperty from 'nested-property'; import autobind from 'autobind-decorator'; import Logger from '../logger'; -import { Schema, bool, types } from '../../misc/schema'; +import { Schema } from '../../misc/schema'; import { EntitySchema, getRepository, Repository, LessThan, MoreThanOrEqual } from 'typeorm'; import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-error'; @@ -462,8 +462,8 @@ export function convertLog(logSchema: Schema): Schema { if (v.type === 'number') { v.type = 'array'; v.items = { - type: types.number, - optional: bool.false, nullable: bool.false, + type: 'number' as const, + optional: false as const, nullable: false as const, }; } else if (v.type === 'object') { for (const k of Object.keys(v.properties!)) {