From efb0ffc4ec1e0b9f6af922cee11481c28dd9a8d6 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 18 Jan 2022 22:27:10 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20API=E3=82=A8=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E5=AE=9A=E7=BE=A9=E3=82=92=E8=89=AF=E3=81=84?= =?UTF-8?q?=E6=84=9F=E3=81=98=E3=81=AB=E3=81=99=E3=82=8B=20(#8154)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix API Schema Error * Delete SimpleSchema/SimpleObj and Move schemas to dedicated files * Userのスキーマを分割してみる * define packMany type * add , * Ensure enum schema and Make "as const" put once * test? * Revert "test?" This reverts commit 97dc9bfa70851bfb7d1cf38e883f8df20fb78b79. * Revert "Fix API Schema Error" This reverts commit 21b6176d974ed8e3eb73723ad21a105c5d297323. * :v: * clean up * test? * wip * wip * better schema def * :v: * fix * add minLength property * wip * wip * wip * anyOf/oneOf/allOfに対応? ~ relation.ts * refactor! * Define MinimumSchema * wip * wip * anyOf/oneOf/allOfが動作するようにUnionSchemaTypeを修正 * anyOf/oneOf/allOfが動作するようにUnionSchemaTypeを修正 * Update packages/backend/src/misc/schema.ts Co-authored-by: Acid Chicken (硫酸鶏) * fix * array oneOfをより正確な型に * array oneOfをより正確な型に * wip * :v: * なんかもういろいろ * remove * very good schema * api schema * wip * refactor: awaitAllの型定義を変えてみる * fix * specify types in awaitAll * specify types in awaitAll * :v: * wip * ... * :v: * AllowDateはやめておく * 不必要なoptional: false, nullable: falseを廃止 * Packedが展開されないように * 続packed * wip * define note type * wip * UserDetailedをMeDetailedかUserDetailedNotMeかを区別できるように * wip * wip * wip specify user type of other schemas * ok * convertSchemaToOpenApiSchemaを改修 * convertSchemaToOpenApiSchemaを改修 * Fix * fix * :v: * wip * 分割代入ではなくallOfで定義するように Co-authored-by: Acid Chicken (硫酸鶏) --- packages/backend/src/misc/schema.ts | 173 +++++-- packages/backend/src/misc/simple-schema.ts | 15 - .../src/models/repositories/antenna.ts | 91 ---- .../backend/src/models/repositories/app.ts | 35 -- .../src/models/repositories/blocking.ts | 28 -- .../src/models/repositories/channel.ts | 53 -- .../backend/src/models/repositories/clip.ts | 39 -- .../src/models/repositories/drive-file.ts | 113 +---- .../src/models/repositories/drive-folder.ts | 41 -- .../backend/src/models/repositories/emoji.ts | 38 -- .../repositories/federation-instance.ts | 104 ---- .../src/models/repositories/following.ts | 38 -- .../src/models/repositories/gallery-post.ts | 71 --- .../src/models/repositories/hashtag.ts | 36 -- .../models/repositories/messaging-message.ts | 75 --- .../backend/src/models/repositories/muting.ts | 28 -- .../src/models/repositories/note-favorite.ts | 28 -- .../src/models/repositories/note-reaction.ts | 27 - .../backend/src/models/repositories/note.ts | 187 +------ .../src/models/repositories/notification.ts | 66 --- .../backend/src/models/repositories/page.ts | 53 -- .../backend/src/models/repositories/queue.ts | 30 -- .../src/models/repositories/user-group.ts | 36 -- .../src/models/repositories/user-list.ts | 31 -- .../backend/src/models/repositories/user.ts | 348 +------------ packages/backend/src/models/schema/antenna.ts | 89 ++++ packages/backend/src/models/schema/app.ts | 33 ++ .../backend/src/models/schema/blocking.ts | 26 + packages/backend/src/models/schema/channel.ts | 51 ++ packages/backend/src/models/schema/clip.ts | 38 ++ .../backend/src/models/schema/drive-file.ts | 107 ++++ .../backend/src/models/schema/drive-folder.ts | 39 ++ packages/backend/src/models/schema/emoji.ts | 36 ++ .../src/models/schema/federation-instance.ts | 105 ++++ .../backend/src/models/schema/following.ts | 36 ++ .../backend/src/models/schema/gallery-post.ts | 69 +++ packages/backend/src/models/schema/hashtag.ts | 34 ++ .../src/models/schema/messaging-message.ts | 73 +++ packages/backend/src/models/schema/muting.ts | 26 + .../src/models/schema/note-favorite.ts | 26 + .../src/models/schema/note-reaction.ts | 25 + packages/backend/src/models/schema/note.ts | 183 +++++++ .../backend/src/models/schema/notification.ts | 66 +++ packages/backend/src/models/schema/page.ts | 51 ++ packages/backend/src/models/schema/queue.ts | 25 + .../backend/src/models/schema/user-group.ts | 34 ++ .../backend/src/models/schema/user-list.ts | 29 ++ packages/backend/src/models/schema/user.ts | 467 ++++++++++++++++++ packages/backend/src/prelude/await-all.ts | 14 +- packages/backend/src/server/api/endpoints.ts | 44 +- .../api/endpoints/admin/abuse-user-reports.ts | 52 +- .../api/endpoints/admin/accounts/create.ts | 10 +- .../api/endpoints/admin/accounts/delete.ts | 4 +- .../server/api/endpoints/admin/ad/create.ts | 4 +- .../server/api/endpoints/admin/ad/delete.ts | 4 +- .../src/server/api/endpoints/admin/ad/list.ts | 4 +- .../server/api/endpoints/admin/ad/update.ts | 4 +- .../endpoints/admin/announcements/create.ts | 32 +- .../endpoints/admin/announcements/delete.ts | 4 +- .../api/endpoints/admin/announcements/list.ts | 40 +- .../endpoints/admin/announcements/update.ts | 4 +- .../admin/delete-all-files-of-a-user.ts | 4 +- .../server/api/endpoints/admin/delete-logs.ts | 14 - .../admin/drive/clean-remote-files.ts | 4 +- .../api/endpoints/admin/drive/cleanup.ts | 4 +- .../server/api/endpoints/admin/drive/files.ts | 12 +- .../api/endpoints/admin/drive/show-file.ts | 112 ++--- .../endpoints/admin/emoji/add-aliases-bulk.ts | 4 +- .../server/api/endpoints/admin/emoji/add.ts | 4 +- .../server/api/endpoints/admin/emoji/copy.ts | 12 +- .../api/endpoints/admin/emoji/delete-bulk.ts | 4 +- .../api/endpoints/admin/emoji/delete.ts | 4 +- .../api/endpoints/admin/emoji/import-zip.ts | 4 +- .../api/endpoints/admin/emoji/list-remote.ts | 40 +- .../server/api/endpoints/admin/emoji/list.ts | 40 +- .../admin/emoji/remove-aliases-bulk.ts | 4 +- .../endpoints/admin/emoji/set-aliases-bulk.ts | 4 +- .../admin/emoji/set-category-bulk.ts | 4 +- .../api/endpoints/admin/emoji/update.ts | 4 +- .../admin/federation/delete-all-files.ts | 4 +- .../refresh-remote-instance-metadata.ts | 4 +- .../admin/federation/remove-all-following.ts | 4 +- .../admin/federation/update-instance.ts | 4 +- .../api/endpoints/admin/get-index-stats.ts | 4 +- .../api/endpoints/admin/get-table-stats.ts | 8 +- .../src/server/api/endpoints/admin/invite.ts | 12 +- .../api/endpoints/admin/moderators/add.ts | 4 +- .../api/endpoints/admin/moderators/remove.ts | 4 +- .../api/endpoints/admin/promo/create.ts | 4 +- .../server/api/endpoints/admin/queue/clear.ts | 4 +- .../endpoints/admin/queue/deliver-delayed.ts | 16 +- .../endpoints/admin/queue/inbox-delayed.ts | 16 +- .../server/api/endpoints/admin/queue/jobs.ts | 32 +- .../server/api/endpoints/admin/queue/stats.ts | 12 +- .../server/api/endpoints/admin/relays/add.ts | 22 +- .../server/api/endpoints/admin/relays/list.ts | 26 +- .../api/endpoints/admin/relays/remove.ts | 6 +- .../api/endpoints/admin/reset-password.ts | 12 +- .../admin/resolve-abuse-user-report.ts | 4 +- .../api/endpoints/admin/resync-chart.ts | 4 +- .../server/api/endpoints/admin/send-email.ts | 4 +- .../server/api/endpoints/admin/server-info.ts | 64 +-- .../endpoints/admin/show-moderation-logs.ts | 38 +- .../server/api/endpoints/admin/show-user.ts | 136 ++--- .../server/api/endpoints/admin/show-users.ts | 14 +- .../api/endpoints/admin/silence-user.ts | 4 +- .../api/endpoints/admin/suspend-user.ts | 4 +- .../api/endpoints/admin/unsilence-user.ts | 4 +- .../api/endpoints/admin/unsuspend-user.ts | 4 +- .../server/api/endpoints/admin/update-meta.ts | 4 +- .../src/server/api/endpoints/admin/vacuum.ts | 4 +- .../src/server/api/endpoints/announcements.ts | 40 +- .../server/api/endpoints/antennas/create.ts | 8 +- .../server/api/endpoints/antennas/delete.ts | 4 +- .../src/server/api/endpoints/antennas/list.ts | 12 +- .../server/api/endpoints/antennas/notes.ts | 12 +- .../src/server/api/endpoints/antennas/show.ts | 8 +- .../server/api/endpoints/antennas/update.ts | 8 +- .../src/server/api/endpoints/ap/get.ts | 8 +- .../src/server/api/endpoints/ap/show.ts | 57 ++- .../src/server/api/endpoints/app/create.ts | 8 +- .../src/server/api/endpoints/app/show.ts | 12 +- .../src/server/api/endpoints/auth/accept.ts | 4 +- .../api/endpoints/auth/session/generate.ts | 16 +- .../server/api/endpoints/auth/session/show.ts | 20 +- .../api/endpoints/auth/session/userkey.ts | 18 +- .../server/api/endpoints/blocking/create.ts | 10 +- .../server/api/endpoints/blocking/delete.ts | 10 +- .../src/server/api/endpoints/blocking/list.ts | 12 +- .../server/api/endpoints/channels/create.ts | 8 +- .../server/api/endpoints/channels/featured.ts | 12 +- .../server/api/endpoints/channels/follow.ts | 4 +- .../server/api/endpoints/channels/followed.ts | 12 +- .../server/api/endpoints/channels/owned.ts | 12 +- .../src/server/api/endpoints/channels/show.ts | 8 +- .../server/api/endpoints/channels/timeline.ts | 12 +- .../server/api/endpoints/channels/unfollow.ts | 4 +- .../server/api/endpoints/channels/update.ts | 8 +- .../api/endpoints/charts/active-users.ts | 2 +- .../src/server/api/endpoints/charts/drive.ts | 2 +- .../server/api/endpoints/charts/federation.ts | 2 +- .../server/api/endpoints/charts/hashtag.ts | 2 +- .../server/api/endpoints/charts/instance.ts | 2 +- .../server/api/endpoints/charts/network.ts | 2 +- .../src/server/api/endpoints/charts/notes.ts | 2 +- .../server/api/endpoints/charts/user/drive.ts | 2 +- .../api/endpoints/charts/user/following.ts | 2 +- .../server/api/endpoints/charts/user/notes.ts | 2 +- .../api/endpoints/charts/user/reactions.ts | 2 +- .../src/server/api/endpoints/charts/users.ts | 2 +- .../server/api/endpoints/clips/add-note.ts | 4 +- .../src/server/api/endpoints/clips/create.ts | 8 +- .../src/server/api/endpoints/clips/delete.ts | 4 +- .../src/server/api/endpoints/clips/list.ts | 12 +- .../src/server/api/endpoints/clips/notes.ts | 12 +- .../src/server/api/endpoints/clips/show.ts | 8 +- .../src/server/api/endpoints/clips/update.ts | 8 +- .../backend/src/server/api/endpoints/drive.ts | 16 +- .../src/server/api/endpoints/drive/files.ts | 12 +- .../endpoints/drive/files/attached-notes.ts | 12 +- .../endpoints/drive/files/check-existence.ts | 8 +- .../api/endpoints/drive/files/create.ts | 8 +- .../api/endpoints/drive/files/delete.ts | 4 +- .../api/endpoints/drive/files/find-by-hash.ts | 12 +- .../server/api/endpoints/drive/files/find.ts | 12 +- .../server/api/endpoints/drive/files/show.ts | 8 +- .../api/endpoints/drive/files/update.ts | 8 +- .../endpoints/drive/files/upload-from-url.ts | 4 +- .../src/server/api/endpoints/drive/folders.ts | 12 +- .../api/endpoints/drive/folders/create.ts | 4 +- .../api/endpoints/drive/folders/delete.ts | 4 +- .../api/endpoints/drive/folders/find.ts | 12 +- .../api/endpoints/drive/folders/show.ts | 8 +- .../api/endpoints/drive/folders/update.ts | 8 +- .../src/server/api/endpoints/drive/stream.ts | 12 +- .../api/endpoints/email-address/available.ts | 16 +- .../src/server/api/endpoints/endpoint.ts | 4 +- .../src/server/api/endpoints/endpoints.ts | 12 +- .../api/endpoints/export-custom-emojis.ts | 4 +- .../api/endpoints/federation/followers.ts | 12 +- .../api/endpoints/federation/following.ts | 12 +- .../api/endpoints/federation/instances.ts | 12 +- .../api/endpoints/federation/show-instance.ts | 8 +- .../federation/update-remote-user.ts | 4 +- .../server/api/endpoints/federation/users.ts | 14 +- .../server/api/endpoints/following/create.ts | 10 +- .../server/api/endpoints/following/delete.ts | 10 +- .../api/endpoints/following/invalidate.ts | 10 +- .../endpoints/following/requests/accept.ts | 4 +- .../endpoints/following/requests/cancel.ts | 10 +- .../api/endpoints/following/requests/list.ts | 28 +- .../endpoints/following/requests/reject.ts | 4 +- .../server/api/endpoints/gallery/featured.ts | 12 +- .../server/api/endpoints/gallery/popular.ts | 12 +- .../src/server/api/endpoints/gallery/posts.ts | 10 +- .../api/endpoints/gallery/posts/create.ts | 8 +- .../api/endpoints/gallery/posts/delete.ts | 4 +- .../api/endpoints/gallery/posts/like.ts | 4 +- .../api/endpoints/gallery/posts/show.ts | 8 +- .../api/endpoints/gallery/posts/unlike.ts | 4 +- .../api/endpoints/gallery/posts/update.ts | 8 +- .../api/endpoints/get-online-users-count.ts | 4 +- .../src/server/api/endpoints/hashtags/list.ts | 12 +- .../server/api/endpoints/hashtags/search.ts | 12 +- .../src/server/api/endpoints/hashtags/show.ts | 8 +- .../server/api/endpoints/hashtags/trend.ts | 28 +- .../server/api/endpoints/hashtags/users.ts | 14 +- .../backend/src/server/api/endpoints/i.ts | 12 +- .../src/server/api/endpoints/i/2fa/done.ts | 4 +- .../server/api/endpoints/i/2fa/key-done.ts | 4 +- .../api/endpoints/i/2fa/password-less.ts | 4 +- .../api/endpoints/i/2fa/register-key.ts | 4 +- .../server/api/endpoints/i/2fa/register.ts | 4 +- .../server/api/endpoints/i/2fa/remove-key.ts | 4 +- .../server/api/endpoints/i/2fa/unregister.ts | 4 +- .../src/server/api/endpoints/i/apps.ts | 4 +- .../server/api/endpoints/i/authorized-apps.ts | 4 +- .../server/api/endpoints/i/change-password.ts | 4 +- .../server/api/endpoints/i/delete-account.ts | 4 +- .../server/api/endpoints/i/export-blocking.ts | 4 +- .../api/endpoints/i/export-following.ts | 4 +- .../src/server/api/endpoints/i/export-mute.ts | 4 +- .../server/api/endpoints/i/export-notes.ts | 4 +- .../api/endpoints/i/export-user-lists.ts | 4 +- .../src/server/api/endpoints/i/favorites.ts | 12 +- .../server/api/endpoints/i/gallery/likes.ts | 16 +- .../server/api/endpoints/i/gallery/posts.ts | 12 +- .../endpoints/i/get-word-muted-notes-count.ts | 12 +- .../server/api/endpoints/i/import-blocking.ts | 4 +- .../api/endpoints/i/import-following.ts | 4 +- .../server/api/endpoints/i/import-muting.ts | 4 +- .../api/endpoints/i/import-user-lists.ts | 4 +- .../server/api/endpoints/i/notifications.ts | 12 +- .../src/server/api/endpoints/i/page-likes.ts | 16 +- .../src/server/api/endpoints/i/pages.ts | 12 +- .../backend/src/server/api/endpoints/i/pin.ts | 12 +- .../i/read-all-messaging-messages.ts | 4 +- .../api/endpoints/i/read-all-unread-notes.ts | 4 +- .../api/endpoints/i/read-announcement.ts | 4 +- .../api/endpoints/i/regenerate-token.ts | 4 +- .../api/endpoints/i/registry/get-all.ts | 4 +- .../api/endpoints/i/registry/get-detail.ts | 4 +- .../server/api/endpoints/i/registry/get.ts | 4 +- .../endpoints/i/registry/keys-with-type.ts | 4 +- .../server/api/endpoints/i/registry/keys.ts | 4 +- .../server/api/endpoints/i/registry/remove.ts | 4 +- .../server/api/endpoints/i/registry/scopes.ts | 4 +- .../server/api/endpoints/i/registry/set.ts | 4 +- .../server/api/endpoints/i/revoke-token.ts | 4 +- .../server/api/endpoints/i/signin-history.ts | 4 +- .../src/server/api/endpoints/i/unpin.ts | 12 +- .../server/api/endpoints/i/update-email.ts | 4 +- .../src/server/api/endpoints/i/update.ts | 12 +- .../api/endpoints/i/user-group-invites.ts | 20 +- .../server/api/endpoints/messaging/history.ts | 12 +- .../api/endpoints/messaging/messages.ts | 12 +- .../endpoints/messaging/messages/create.ts | 8 +- .../endpoints/messaging/messages/delete.ts | 4 +- .../api/endpoints/messaging/messages/read.ts | 4 +- .../backend/src/server/api/endpoints/meta.ts | 408 +++++++-------- .../server/api/endpoints/miauth/gen-token.ts | 12 +- .../src/server/api/endpoints/mute/create.ts | 4 +- .../src/server/api/endpoints/mute/delete.ts | 4 +- .../src/server/api/endpoints/mute/list.ts | 12 +- .../src/server/api/endpoints/my/apps.ts | 48 +- .../backend/src/server/api/endpoints/notes.ts | 10 +- .../server/api/endpoints/notes/children.ts | 12 +- .../src/server/api/endpoints/notes/clips.ts | 14 +- .../api/endpoints/notes/conversation.ts | 12 +- .../src/server/api/endpoints/notes/create.ts | 12 +- .../src/server/api/endpoints/notes/delete.ts | 4 +- .../api/endpoints/notes/favorites/create.ts | 4 +- .../api/endpoints/notes/favorites/delete.ts | 4 +- .../server/api/endpoints/notes/featured.ts | 12 +- .../api/endpoints/notes/global-timeline.ts | 10 +- .../api/endpoints/notes/hybrid-timeline.ts | 12 +- .../api/endpoints/notes/local-timeline.ts | 10 +- .../server/api/endpoints/notes/mentions.ts | 12 +- .../endpoints/notes/polls/recommendation.ts | 12 +- .../server/api/endpoints/notes/polls/vote.ts | 4 +- .../server/api/endpoints/notes/reactions.ts | 12 +- .../api/endpoints/notes/reactions/create.ts | 4 +- .../api/endpoints/notes/reactions/delete.ts | 4 +- .../src/server/api/endpoints/notes/renotes.ts | 12 +- .../src/server/api/endpoints/notes/replies.ts | 12 +- .../api/endpoints/notes/search-by-tag.ts | 10 +- .../src/server/api/endpoints/notes/search.ts | 12 +- .../src/server/api/endpoints/notes/show.ts | 8 +- .../src/server/api/endpoints/notes/state.ts | 20 +- .../endpoints/notes/thread-muting/create.ts | 4 +- .../endpoints/notes/thread-muting/delete.ts | 4 +- .../server/api/endpoints/notes/timeline.ts | 12 +- .../server/api/endpoints/notes/translate.ts | 8 +- .../server/api/endpoints/notes/unrenote.ts | 4 +- .../api/endpoints/notes/user-list-timeline.ts | 12 +- .../api/endpoints/notes/watching/create.ts | 4 +- .../api/endpoints/notes/watching/delete.ts | 4 +- .../api/endpoints/notifications/create.ts | 4 +- .../notifications/mark-all-as-read.ts | 4 +- .../api/endpoints/notifications/read.ts | 4 +- .../src/server/api/endpoints/page-push.ts | 4 +- .../src/server/api/endpoints/pages/create.ts | 8 +- .../src/server/api/endpoints/pages/delete.ts | 4 +- .../server/api/endpoints/pages/featured.ts | 12 +- .../src/server/api/endpoints/pages/like.ts | 4 +- .../src/server/api/endpoints/pages/show.ts | 8 +- .../src/server/api/endpoints/pages/unlike.ts | 4 +- .../src/server/api/endpoints/pages/update.ts | 4 +- .../backend/src/server/api/endpoints/ping.ts | 12 +- .../src/server/api/endpoints/pinned-users.ts | 14 +- .../src/server/api/endpoints/promo/read.ts | 4 +- .../api/endpoints/request-reset-password.ts | 4 +- .../src/server/api/endpoints/reset-db.ts | 4 +- .../server/api/endpoints/reset-password.ts | 4 +- .../src/server/api/endpoints/server-info.ts | 4 +- .../backend/src/server/api/endpoints/stats.ts | 36 +- .../src/server/api/endpoints/sw/register.ts | 16 +- .../src/server/api/endpoints/sw/unregister.ts | 4 +- .../api/endpoints/username/available.ts | 12 +- .../backend/src/server/api/endpoints/users.ts | 14 +- .../src/server/api/endpoints/users/clips.ts | 2 +- .../server/api/endpoints/users/followers.ts | 12 +- .../server/api/endpoints/users/following.ts | 12 +- .../api/endpoints/users/gallery/posts.ts | 2 +- .../users/get-frequently-replied-users.ts | 24 +- .../api/endpoints/users/groups/create.ts | 8 +- .../api/endpoints/users/groups/delete.ts | 4 +- .../users/groups/invitations/accept.ts | 4 +- .../users/groups/invitations/reject.ts | 4 +- .../api/endpoints/users/groups/invite.ts | 4 +- .../api/endpoints/users/groups/joined.ts | 12 +- .../api/endpoints/users/groups/leave.ts | 4 +- .../api/endpoints/users/groups/owned.ts | 12 +- .../server/api/endpoints/users/groups/pull.ts | 4 +- .../server/api/endpoints/users/groups/show.ts | 8 +- .../api/endpoints/users/groups/transfer.ts | 8 +- .../api/endpoints/users/groups/update.ts | 8 +- .../api/endpoints/users/lists/create.ts | 8 +- .../api/endpoints/users/lists/delete.ts | 4 +- .../server/api/endpoints/users/lists/list.ts | 12 +- .../server/api/endpoints/users/lists/pull.ts | 4 +- .../server/api/endpoints/users/lists/push.ts | 4 +- .../server/api/endpoints/users/lists/show.ts | 8 +- .../api/endpoints/users/lists/update.ts | 8 +- .../src/server/api/endpoints/users/notes.ts | 10 +- .../src/server/api/endpoints/users/pages.ts | 2 +- .../server/api/endpoints/users/reactions.ts | 12 +- .../api/endpoints/users/recommendation.ts | 14 +- .../server/api/endpoints/users/relation.ts | 79 ++- .../api/endpoints/users/report-abuse.ts | 4 +- .../users/search-by-username-and-host.ts | 14 +- .../src/server/api/endpoints/users/search.ts | 12 +- .../src/server/api/endpoints/users/show.ts | 23 +- .../src/server/api/endpoints/users/stats.ts | 4 +- .../backend/src/server/api/openapi/schemas.ts | 8 +- .../backend/src/server/api/stream/types.ts | 4 +- packages/backend/src/services/chart/core.ts | 14 +- .../backend/src/services/following/create.ts | 5 +- 358 files changed, 3623 insertions(+), 3417 deletions(-) delete mode 100644 packages/backend/src/misc/simple-schema.ts delete mode 100644 packages/backend/src/models/repositories/queue.ts create mode 100644 packages/backend/src/models/schema/antenna.ts create mode 100644 packages/backend/src/models/schema/app.ts create mode 100644 packages/backend/src/models/schema/blocking.ts create mode 100644 packages/backend/src/models/schema/channel.ts create mode 100644 packages/backend/src/models/schema/clip.ts create mode 100644 packages/backend/src/models/schema/drive-file.ts create mode 100644 packages/backend/src/models/schema/drive-folder.ts create mode 100644 packages/backend/src/models/schema/emoji.ts create mode 100644 packages/backend/src/models/schema/federation-instance.ts create mode 100644 packages/backend/src/models/schema/following.ts create mode 100644 packages/backend/src/models/schema/gallery-post.ts create mode 100644 packages/backend/src/models/schema/hashtag.ts create mode 100644 packages/backend/src/models/schema/messaging-message.ts create mode 100644 packages/backend/src/models/schema/muting.ts create mode 100644 packages/backend/src/models/schema/note-favorite.ts create mode 100644 packages/backend/src/models/schema/note-reaction.ts create mode 100644 packages/backend/src/models/schema/note.ts create mode 100644 packages/backend/src/models/schema/notification.ts create mode 100644 packages/backend/src/models/schema/page.ts create mode 100644 packages/backend/src/models/schema/queue.ts create mode 100644 packages/backend/src/models/schema/user-group.ts create mode 100644 packages/backend/src/models/schema/user-list.ts create mode 100644 packages/backend/src/models/schema/user.ts delete mode 100644 packages/backend/src/server/api/endpoints/admin/delete-logs.ts diff --git a/packages/backend/src/misc/schema.ts b/packages/backend/src/misc/schema.ts index ae6f1bac8..2dae954af 100644 --- a/packages/backend/src/misc/schema.ts +++ b/packages/backend/src/misc/schema.ts @@ -1,30 +1,44 @@ -import { SimpleObj, SimpleSchema } from './simple-schema'; -import { packedUserSchema } from '@/models/repositories/user'; -import { packedNoteSchema } from '@/models/repositories/note'; -import { packedUserListSchema } from '@/models/repositories/user-list'; -import { packedAppSchema } from '@/models/repositories/app'; -import { packedMessagingMessageSchema } from '@/models/repositories/messaging-message'; -import { packedNotificationSchema } from '@/models/repositories/notification'; -import { packedDriveFileSchema } from '@/models/repositories/drive-file'; -import { packedDriveFolderSchema } from '@/models/repositories/drive-folder'; -import { packedFollowingSchema } from '@/models/repositories/following'; -import { packedMutingSchema } from '@/models/repositories/muting'; -import { packedBlockingSchema } from '@/models/repositories/blocking'; -import { packedNoteReactionSchema } from '@/models/repositories/note-reaction'; -import { packedHashtagSchema } from '@/models/repositories/hashtag'; -import { packedPageSchema } from '@/models/repositories/page'; -import { packedUserGroupSchema } from '@/models/repositories/user-group'; -import { packedNoteFavoriteSchema } from '@/models/repositories/note-favorite'; -import { packedChannelSchema } from '@/models/repositories/channel'; -import { packedAntennaSchema } from '@/models/repositories/antenna'; -import { packedClipSchema } from '@/models/repositories/clip'; -import { packedFederationInstanceSchema } from '@/models/repositories/federation-instance'; -import { packedQueueCountSchema } from '@/models/repositories/queue'; -import { packedGalleryPostSchema } from '@/models/repositories/gallery-post'; -import { packedEmojiSchema } from '@/models/repositories/emoji'; +import { + packedUserLiteSchema, + packedUserDetailedNotMeOnlySchema, + packedMeDetailedOnlySchema, + packedUserDetailedNotMeSchema, + packedMeDetailedSchema, + packedUserDetailedSchema, + packedUserSchema, +} from '@/models/schema/user'; +import { packedNoteSchema } from '@/models/schema/note'; +import { packedUserListSchema } from '@/models/schema/user-list'; +import { packedAppSchema } from '@/models/schema/app'; +import { packedMessagingMessageSchema } from '@/models/schema/messaging-message'; +import { packedNotificationSchema } from '@/models/schema/notification'; +import { packedDriveFileSchema } from '@/models/schema/drive-file'; +import { packedDriveFolderSchema } from '@/models/schema/drive-folder'; +import { packedFollowingSchema } from '@/models/schema/following'; +import { packedMutingSchema } from '@/models/schema/muting'; +import { packedBlockingSchema } from '@/models/schema/blocking'; +import { packedNoteReactionSchema } from '@/models/schema/note-reaction'; +import { packedHashtagSchema } from '@/models/schema/hashtag'; +import { packedPageSchema } from '@/models/schema/page'; +import { packedUserGroupSchema } from '@/models/schema/user-group'; +import { packedNoteFavoriteSchema } from '@/models/schema/note-favorite'; +import { packedChannelSchema } from '@/models/schema/channel'; +import { packedAntennaSchema } from '@/models/schema/antenna'; +import { packedClipSchema } from '@/models/schema/clip'; +import { packedFederationInstanceSchema } from '@/models/schema/federation-instance'; +import { packedQueueCountSchema } from '@/models/schema/queue'; +import { packedGalleryPostSchema } from '@/models/schema/gallery-post'; +import { packedEmojiSchema } from '@/models/schema/emoji'; export const refs = { + UserLite: packedUserLiteSchema, + UserDetailedNotMeOnly: packedUserDetailedNotMeOnlySchema, + MeDetailedOnly: packedMeDetailedOnlySchema, + UserDetailedNotMe: packedUserDetailedNotMeSchema, + MeDetailed: packedMeDetailedSchema, + UserDetailed: packedUserDetailedSchema, User: packedUserSchema, + UserList: packedUserListSchema, UserGroup: packedUserGroupSchema, App: packedAppSchema, @@ -49,12 +63,50 @@ export const refs = { Emoji: packedEmojiSchema, }; -export type Packed = ObjType<(typeof refs[x])['properties']>; +// Packed = SchemaTypeDef; とすると展開されてマウスホバー時に型表示が使い物にならなくなる +// ObjTypeを指定すると(なぜか)展開されずにPacked<'Hoge'>と表示される +type PackedDef; allOf?: ReadonlyArray }> = + r['allOf'] extends ReadonlyArray ? UnionToIntersection> : + r['oneOf'] extends ReadonlyArray ? UnionSchemaType : + r['properties'] extends Obj ? ObjType : + never; +export type Packed = PackedDef; -export interface Schema extends SimpleSchema { - items?: Schema; - properties?: Obj; - ref?: keyof typeof refs; +type TypeStringef = 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any'; +type StringDefToType = + T extends 'boolean' ? boolean : + T extends 'number' ? number : + T extends 'string' ? string | Date : + T extends 'array' ? ReadonlyArray : + T extends 'object' ? Record : + any; + +// https://swagger.io/specification/?sbsearch=optional#schema-object +type OfSchema = { + readonly anyOf?: ReadonlyArray; + readonly oneOf?: ReadonlyArray; + readonly allOf?: ReadonlyArray; +} + +export interface MinimumSchema extends OfSchema { + readonly type?: TypeStringef; + readonly nullable?: boolean; + readonly optional?: boolean; + readonly items?: MinimumSchema; + readonly properties?: Obj; + readonly description?: string; + readonly example?: any; + readonly format?: string; + readonly ref?: keyof typeof refs; + readonly enum?: ReadonlyArray; + readonly default?: (this['type'] extends TypeStringef ? StringDefToType : any) | null; + readonly maxLength?: number; + readonly minLength?: number; +} + +export interface Schema extends MinimumSchema { + readonly nullable: boolean; + readonly optional: boolean; } type NonUndefinedPropertyNames = { @@ -65,22 +117,13 @@ type UndefinedPropertyNames = { [K in keyof T]: T[K]['optional'] extends true ? K : never }[keyof T]; -type OnlyRequired = Pick>; -type OnlyOptional = Pick>; - -export interface Obj extends SimpleObj { [key: string]: Schema; } +export interface Obj { [key: string]: Schema; } export type ObjType = - { [P in keyof OnlyOptional]?: SchemaType } & - { [P in keyof OnlyRequired]: SchemaType }; + { -readonly [P in UndefinedPropertyNames]?: SchemaType } & + { -readonly [P in NonUndefinedPropertyNames]: SchemaType }; -// https://qiita.com/hrsh7th@github/items/84e8968c3601009cdcf2 -type MyType = { - 0: any; - 1: SchemaType; -}[T extends Schema ? 1 : 0]; - -type NullOrUndefined

= +type NullOrUndefined

= p['nullable'] extends true ? p['optional'] extends true ? (T | null | undefined) @@ -89,15 +132,41 @@ type NullOrUndefined

= ? (T | undefined) : T; -export type SchemaType

= - p['type'] extends 'number' ? NullOrUndefined : - p['type'] extends 'string' ? NullOrUndefined : - p['type'] extends 'boolean' ? NullOrUndefined : - p['type'] extends 'array' ? NullOrUndefined>[]> : - p['type'] extends 'object' ? ( - p['ref'] extends keyof typeof refs - ? NullOrUndefined> - : NullOrUndefined>> +// 共用体型を交差型にする型 https://stackoverflow.com/questions/54938141/typescript-convert-union-to-intersection +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; + +// https://github.com/misskey-dev/misskey/pull/8144#discussion_r785287552 +// 単純にSchemaTypeDefで判定するだけではダメ +type UnionSchemaType = X extends any ? SchemaType : never; +type ArrayUnion = T extends any ? Array : never; + +export type SchemaTypeDef

= + p['type'] extends 'number' ? number : + p['type'] extends 'string' ? ( + p['enum'] extends readonly string[] ? + p['enum'][number] : + p['format'] extends 'date-time' ? string : // Dateにする?? + string ) : - p['type'] extends 'any' ? NullOrUndefined : + p['type'] extends 'boolean' ? boolean : + p['type'] extends 'object' ? ( + p['ref'] extends keyof typeof refs ? Packed : + p['properties'] extends NonNullable ? ObjType : + p['anyOf'] extends ReadonlyArray ? UnionSchemaType & Partial>> : + p['allOf'] extends ReadonlyArray ? UnionToIntersection> : + any + ) : + p['type'] extends 'array' ? ( + p['items'] extends OfSchema ? ( + p['items']['anyOf'] extends ReadonlyArray ? UnionSchemaType>[] : + p['items']['oneOf'] extends ReadonlyArray ? ArrayUnion>> : + p['items']['allOf'] extends ReadonlyArray ? UnionToIntersection>>[] : + never + ) : + p['items'] extends NonNullable ? SchemaTypeDef[] : + any[] + ) : + p['oneOf'] extends ReadonlyArray ? UnionSchemaType : any; + +export type SchemaType

= NullOrUndefined>; diff --git a/packages/backend/src/misc/simple-schema.ts b/packages/backend/src/misc/simple-schema.ts deleted file mode 100644 index abbb348e2..000000000 --- a/packages/backend/src/misc/simple-schema.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface SimpleSchema { - type: 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any'; - nullable: boolean; - optional: boolean; - items?: SimpleSchema; - properties?: SimpleObj; - description?: string; - example?: any; - format?: string; - ref?: string; - enum?: string[]; - default?: boolean | null; -} - -export interface SimpleObj { [key: string]: SimpleSchema; } diff --git a/packages/backend/src/models/repositories/antenna.ts b/packages/backend/src/models/repositories/antenna.ts index 548f44f1b..3bf0645a7 100644 --- a/packages/backend/src/models/repositories/antenna.ts +++ b/packages/backend/src/models/repositories/antenna.ts @@ -31,94 +31,3 @@ export class AntennaRepository extends Repository { }; } } - -export const packedAntennaSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - keywords: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - }, - excludeKeywords: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - }, - src: { - type: 'string' as const, - optional: false as const, nullable: false as const, - enum: ['home', 'all', 'users', 'list', 'group'], - }, - userListId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - userGroupId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - users: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - caseSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - default: false, - }, - notify: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - withReplies: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - default: false, - }, - withFile: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - hasUnreadNote: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - default: false, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/app.ts b/packages/backend/src/models/repositories/app.ts index bec0765ac..6bac4d959 100644 --- a/packages/backend/src/models/repositories/app.ts +++ b/packages/backend/src/models/repositories/app.ts @@ -38,38 +38,3 @@ export class AppRepository extends Repository { }; } } - -export const packedAppSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - callbackUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - permission: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - secret: { - type: 'string' as const, - optional: true as const, nullable: false as const, - }, - isAuthorized: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/blocking.ts b/packages/backend/src/models/repositories/blocking.ts index a6895eabf..c20b02f50 100644 --- a/packages/backend/src/models/repositories/blocking.ts +++ b/packages/backend/src/models/repositories/blocking.ts @@ -30,31 +30,3 @@ export class BlockingRepository extends Repository { return Promise.all(blockings.map(x => this.pack(x, me))); } } - -export const packedBlockingSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - blockeeId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - blockee: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/channel.ts b/packages/backend/src/models/repositories/channel.ts index 0a6b02f49..b3afb823a 100644 --- a/packages/backend/src/models/repositories/channel.ts +++ b/packages/backend/src/models/repositories/channel.ts @@ -40,56 +40,3 @@ export class ChannelRepository extends Repository { }; } } - -export const packedChannelSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - lastNotedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - description: { - type: 'string' as const, - nullable: true as const, optional: false as const, - }, - bannerUrl: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: false as const, - }, - notesCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, - }, - usersCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, - }, - isFollowing: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - userId: { - type: 'string' as const, - nullable: true as const, optional: false as const, - format: 'id', - }, - }, -}; diff --git a/packages/backend/src/models/repositories/clip.ts b/packages/backend/src/models/repositories/clip.ts index 7892811d4..6f9ceeb50 100644 --- a/packages/backend/src/models/repositories/clip.ts +++ b/packages/backend/src/models/repositories/clip.ts @@ -29,42 +29,3 @@ export class ClipRepository extends Repository { } } -export const packedClipSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - description: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - isPublic: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/drive-file.ts b/packages/backend/src/models/repositories/drive-file.ts index 79b890aa6..44db9a0a5 100644 --- a/packages/backend/src/models/repositories/drive-file.ts +++ b/packages/backend/src/models/repositories/drive-file.ts @@ -3,7 +3,7 @@ import { DriveFile } from '@/models/entities/drive-file'; import { Users, DriveFolders } from '../index'; import { User } from '@/models/entities/user'; import { toPuny } from '@/misc/convert-host'; -import { awaitAll } from '@/prelude/await-all'; +import { awaitAll, Promiseable } from '@/prelude/await-all'; import { Packed } from '@/misc/schema'; import config from '@/config/index'; import { query, appendQuery } from '@/prelude/url'; @@ -126,7 +126,7 @@ export class DriveFileRepository extends Repository { const meta = await fetchMeta(); - return await awaitAll({ + return await awaitAll>({ id: file.id, createdAt: file.createdAt.toISOString(), name: file.name, @@ -156,112 +156,3 @@ export class DriveFileRepository extends Repository { return items.filter(x => x != null); } } - -export const packedDriveFileSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'lenna.jpg', - }, - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'image/jpeg', - }, - md5: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'md5', - example: '15eca7fba0480996e2245f5185bf39f2', - }, - size: { - type: 'number' as const, - optional: false as const, nullable: false as const, - example: 51469, - }, - isSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - blurhash: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - properties: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - width: { - type: 'number' as const, - optional: true as const, nullable: false as const, - example: 1280, - }, - height: { - type: 'number' as const, - optional: true as const, nullable: false as const, - example: 720, - }, - orientation: { - type: 'number' as const, - optional: true as const, nullable: false as const, - example: 8, - }, - avgColor: { - type: 'string' as const, - optional: true as const, nullable: false as const, - example: 'rgb(40,65,87)', - }, - }, - }, - url: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'url', - }, - thumbnailUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'url', - }, - comment: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - folderId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - folder: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'DriveFolder' as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - user: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/drive-folder.ts b/packages/backend/src/models/repositories/drive-folder.ts index 4ee4a68e0..b2e6cee9b 100644 --- a/packages/backend/src/models/repositories/drive-folder.ts +++ b/packages/backend/src/models/repositories/drive-folder.ts @@ -48,44 +48,3 @@ export class DriveFolderRepository extends Repository { }); } } - -export const packedDriveFolderSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - foldersCount: { - type: 'number' as const, - optional: true as const, nullable: false as const, - }, - filesCount: { - type: 'number' as const, - optional: true as const, nullable: false as const, - }, - parentId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - parent: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'DriveFolder' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/emoji.ts b/packages/backend/src/models/repositories/emoji.ts index b7529595a..9d63ced81 100644 --- a/packages/backend/src/models/repositories/emoji.ts +++ b/packages/backend/src/models/repositories/emoji.ts @@ -25,41 +25,3 @@ export class EmojiRepository extends Repository { return Promise.all(emojis.map(x => this.pack(x))); } } - -export const packedEmojiSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - aliases: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - category: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - host: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - url: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/federation-instance.ts b/packages/backend/src/models/repositories/federation-instance.ts index 90dbbaab1..426fd5bfc 100644 --- a/packages/backend/src/models/repositories/federation-instance.ts +++ b/packages/backend/src/models/repositories/federation-instance.ts @@ -1,106 +1,2 @@ import config from '@/config/index'; -export const packedFederationInstanceSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - caughtAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - host: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'misskey.example.com', - }, - usersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - notesCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - followingCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - followersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - driveUsage: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - driveFiles: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - latestRequestSentAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'date-time', - }, - lastCommunicatedAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - isNotResponding: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - isSuspended: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - softwareName: { - type: 'string' as const, - optional: false as const, nullable: true as const, - example: 'misskey', - }, - softwareVersion: { - type: 'string' as const, - optional: false as const, nullable: true as const, - example: config.version, - }, - openRegistrations: { - type: 'boolean' as const, - optional: false as const, nullable: true as const, - example: true, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - description: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - maintainerName: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - maintainerEmail: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - iconUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'url', - }, - infoUpdatedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'date-time', - }, - }, -}; diff --git a/packages/backend/src/models/repositories/following.ts b/packages/backend/src/models/repositories/following.ts index 1dfaaf908..9d20f442d 100644 --- a/packages/backend/src/models/repositories/following.ts +++ b/packages/backend/src/models/repositories/following.ts @@ -84,41 +84,3 @@ export class FollowingRepository extends Repository { return Promise.all(followings.map(x => this.pack(x, me, opts))); } } - -export const packedFollowingSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - followeeId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - followee: { - type: 'object' as const, - optional: true as const, nullable: false as const, - ref: 'User' as const, - }, - followerId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - follower: { - type: 'object' as const, - optional: true as const, nullable: false as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/gallery-post.ts b/packages/backend/src/models/repositories/gallery-post.ts index 6d37e3120..e9233bb91 100644 --- a/packages/backend/src/models/repositories/gallery-post.ts +++ b/packages/backend/src/models/repositories/gallery-post.ts @@ -38,74 +38,3 @@ export class GalleryPostRepository extends Repository { return Promise.all(posts.map(x => this.pack(x, me))); } } - -export const packedGalleryPostSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - updatedAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - title: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - description: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - fileIds: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - files: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'DriveFile' as const, - }, - }, - tags: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - isSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/hashtag.ts b/packages/backend/src/models/repositories/hashtag.ts index 6e513c7eb..c4b8d50c4 100644 --- a/packages/backend/src/models/repositories/hashtag.ts +++ b/packages/backend/src/models/repositories/hashtag.ts @@ -24,39 +24,3 @@ export class HashtagRepository extends Repository { return Promise.all(hashtags.map(x => this.pack(x))); } } - -export const packedHashtagSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - tag: { - type: 'string' as const, - optional: false as const, nullable: false as const, - example: 'misskey', - }, - mentionedUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - mentionedLocalUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - mentionedRemoteUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - attachedUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - attachedLocalUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - attachedRemoteUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/messaging-message.ts b/packages/backend/src/models/repositories/messaging-message.ts index 1b2dd3a24..0a342430b 100644 --- a/packages/backend/src/models/repositories/messaging-message.ts +++ b/packages/backend/src/models/repositories/messaging-message.ts @@ -42,78 +42,3 @@ export class MessagingMessageRepository extends Repository { }; } } - -export const packedMessagingMessageSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: true as const, nullable: false as const, - }, - text: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - fileId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - }, - file: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'DriveFile' as const, - }, - recipientId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - recipient: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'User' as const, - }, - groupId: { - type: 'string' as const, - optional: false as const, nullable: true as const, - format: 'id', - }, - group: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'UserGroup' as const, - }, - isRead: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - reads: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/muting.ts b/packages/backend/src/models/repositories/muting.ts index b82d1f0da..bdbe9b47d 100644 --- a/packages/backend/src/models/repositories/muting.ts +++ b/packages/backend/src/models/repositories/muting.ts @@ -30,31 +30,3 @@ export class MutingRepository extends Repository { return Promise.all(mutings.map(x => this.pack(x, me))); } } - -export const packedMutingSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - muteeId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - mutee: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User' as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/note-favorite.ts b/packages/backend/src/models/repositories/note-favorite.ts index 47586a911..c5de55c0c 100644 --- a/packages/backend/src/models/repositories/note-favorite.ts +++ b/packages/backend/src/models/repositories/note-favorite.ts @@ -26,31 +26,3 @@ export class NoteFavoriteRepository extends Repository { return Promise.all(favorites.map(x => this.pack(x, me))); } } - -export const packedNoteFavoriteSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - note: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'Note' as const, - }, - noteId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, -}; diff --git a/packages/backend/src/models/repositories/note-reaction.ts b/packages/backend/src/models/repositories/note-reaction.ts index dfb25cbea..097574eff 100644 --- a/packages/backend/src/models/repositories/note-reaction.ts +++ b/packages/backend/src/models/repositories/note-reaction.ts @@ -31,30 +31,3 @@ export class NoteReactionRepository extends Repository { }; } } - -export const packedNoteReactionSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - user: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User' as const, - }, - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 96dfad70e..9a7fef497 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -218,7 +218,7 @@ export class NoteRepository extends Repository { const reactionEmojiNames = Object.keys(note.reactions).filter(x => x?.startsWith(':')).map(x => decodeReaction(x).reaction).map(x => x.replace(/:/g, '')); - const packed = await awaitAll({ + const packed: Packed<'Note'> = await awaitAll({ id: note.id, createdAt: note.createdAt.toISOString(), userId: note.userId, @@ -320,188 +320,3 @@ export class NoteRepository extends Repository { }))); } } - -export const packedNoteSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - text: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - cw: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - replyId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - renoteId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - reply: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'Note' as const, - }, - renote: { - type: 'object' as const, - optional: true as const, nullable: true as const, - ref: 'Note' as const, - }, - isHidden: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - visibility: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - mentions: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - visibleUserIds: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - fileIds: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - }, - files: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'DriveFile' as const, - }, - }, - tags: { - type: 'array' as const, - optional: true as const, nullable: false as const, - items: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - }, - poll: { - type: 'object' as const, - optional: true as const, nullable: true as const, - }, - channelId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - channel: { - type: 'object' as const, - optional: true as const, nullable: true as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - }, - }, - }, - localOnly: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - emojis: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - url: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - }, - }, - }, - reactions: { - type: 'object' as const, - optional: false as const, nullable: false as const, - }, - renoteCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - repliesCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - uri: { - type: 'string' as const, - optional: true as const, nullable: false as const, - }, - url: { - type: 'string' as const, - optional: true as const, nullable: false as const, - }, - - myReaction: { - type: 'object' as const, - optional: true as const, nullable: true as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/notification.ts b/packages/backend/src/models/repositories/notification.ts index 47d569ed2..5e4279889 100644 --- a/packages/backend/src/models/repositories/notification.ts +++ b/packages/backend/src/models/repositories/notification.ts @@ -107,69 +107,3 @@ export class NotificationRepository extends Repository { }))); } } - -export const packedNotificationSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - isRead: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, - }, - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - enum: [...notificationTypes], - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: true as const, nullable: true as const, - }, - userId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', - }, - note: { - type: 'object' as const, - ref: 'Note' as const, - optional: true as const, nullable: true as const, - }, - reaction: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - choice: { - type: 'number' as const, - optional: true as const, nullable: true as const, - }, - invitation: { - type: 'object' as const, - optional: true as const, nullable: true as const, - }, - body: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - header: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - icon: { - type: 'string' as const, - optional: true as const, nullable: true as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/page.ts b/packages/backend/src/models/repositories/page.ts index 46b453cad..ec76c2e41 100644 --- a/packages/backend/src/models/repositories/page.ts +++ b/packages/backend/src/models/repositories/page.ts @@ -87,56 +87,3 @@ export class PageRepository extends Repository { return Promise.all(pages.map(x => this.pack(x, me))); } } - -export const packedPageSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - updatedAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - title: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - summary: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - content: { - type: 'array' as const, - optional: false as const, nullable: false as const, - }, - variables: { - type: 'array' as const, - optional: false as const, nullable: false as const, - }, - userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - }, - user: { - type: 'object' as const, - ref: 'User' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/queue.ts b/packages/backend/src/models/repositories/queue.ts deleted file mode 100644 index 521c63439..000000000 --- a/packages/backend/src/models/repositories/queue.ts +++ /dev/null @@ -1,30 +0,0 @@ -export const packedQueueCountSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - waiting: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - active: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - completed: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - failed: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - delayed: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - paused: { - type: 'number' as const, - optional: false as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/user-group.ts b/packages/backend/src/models/repositories/user-group.ts index 02a034888..3ed37ca0e 100644 --- a/packages/backend/src/models/repositories/user-group.ts +++ b/packages/backend/src/models/repositories/user-group.ts @@ -23,39 +23,3 @@ export class UserGroupRepository extends Repository { }; } } - -export const packedUserGroupSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - ownerId: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - userIds: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/user-list.ts b/packages/backend/src/models/repositories/user-list.ts index 792a17cb4..a2bffe835 100644 --- a/packages/backend/src/models/repositories/user-list.ts +++ b/packages/backend/src/models/repositories/user-list.ts @@ -22,34 +22,3 @@ export class UserListRepository extends Repository { }; } } - -export const packedUserListSchema = { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'date-time', - }, - name: { - type: 'string' as const, - optional: false as const, nullable: false as const, - }, - userIds: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - }, - }, -}; diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 85141cdc4..2b8398832 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -4,11 +4,19 @@ import { User, ILocalUser, IRemoteUser } from '@/models/entities/user'; import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, Antennas, AntennaNotes, ChannelFollowings, Instances } from '../index'; import config from '@/config/index'; import { Packed } from '@/misc/schema'; -import { awaitAll } from '@/prelude/await-all'; +import { awaitAll, Promiseable } from '@/prelude/await-all'; import { populateEmojis } from '@/misc/populate-emojis'; import { getAntennas } from '@/misc/antenna-cache'; import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const'; +type IsUserDetailed = Detailed extends true ? Packed<'UserDetailed'> : Packed<'UserLite'>; +type IsMeAndIsUserDetailed = + Detailed extends true ? + ExpectsMe extends true ? Packed<'MeDetailed'> : + ExpectsMe extends false ? Packed<'UserDetailedNotMe'> : + Packed<'UserDetailed'> : + Packed<'UserLite'>; + @EntityRepository(User) export class UserRepository extends Repository { public async getRelation(me: User['id'], target: User['id']) { @@ -144,7 +152,7 @@ export class UserRepository extends Repository { return count > 0; } - public getOnlineStatus(user: User): string { + public getOnlineStatus(user: User): 'unknown' | 'online' | 'active' | 'offline' { if (user.hideOnlineStatus) return 'unknown'; if (user.lastActiveDate == null) return 'unknown'; const elapsed = Date.now() - user.lastActiveDate.getTime(); @@ -163,14 +171,14 @@ export class UserRepository extends Repository { } } - public async pack( + public async pack( src: User['id'] | User, me?: { id: User['id'] } | null | undefined, options?: { - detail?: boolean, + detail?: D, includeSecrets?: boolean, } - ): Promise> { + ): Promise> { const opts = Object.assign({ detail: false, includeSecrets: false, @@ -178,8 +186,9 @@ export class UserRepository extends Repository { const user = typeof src === 'object' ? src : await this.findOneOrFail(src); const meId = me ? me.id : null; + const isMe = meId === user.id; - const relation = meId && (meId !== user.id) && opts.detail ? await this.getRelation(meId, user.id) : null; + const relation = meId && !isMe && opts.detail ? await this.getRelation(meId, user.id) : null; const pins = opts.detail ? await UserNotePinings.createQueryBuilder('pin') .where('pin.userId = :userId', { userId: user.id }) .innerJoinAndSelect('pin.note', 'note') @@ -188,12 +197,12 @@ export class UserRepository extends Repository { const profile = opts.detail ? await UserProfiles.findOneOrFail(user.id) : null; const followingCount = profile == null ? null : - (profile.ffVisibility === 'public') || (meId === user.id) ? user.followingCount : + (profile.ffVisibility === 'public') || isMe ? user.followingCount : (profile.ffVisibility === 'followers') && (relation && relation.isFollowing) ? user.followingCount : null; const followersCount = profile == null ? null : - (profile.ffVisibility === 'public') || (meId === user.id) ? user.followersCount : + (profile.ffVisibility === 'public') || isMe ? user.followersCount : (profile.ffVisibility === 'followers') && (relation && relation.isFollowing) ? user.followersCount : null; @@ -227,12 +236,11 @@ export class UserRepository extends Repository { uri: user.uri, createdAt: user.createdAt.toISOString(), updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null, - lastFetchedAt: user.lastFetchedAt?.toISOString(), + lastFetchedAt: user.lastFetchedAt ? user.lastFetchedAt.toISOString() : null, bannerUrl: user.bannerUrl, bannerBlurhash: user.bannerBlurhash, bannerColor: null, // 後方互換性のため isLocked: user.isLocked, - isModerator: user.isModerator || falsy, isSilenced: user.isSilenced || falsy, isSuspended: user.isSuspended || falsy, description: profile!.description, @@ -260,7 +268,7 @@ export class UserRepository extends Repository { : false, } : {}), - ...(opts.detail && meId === user.id ? { + ...(opts.detail && isMe ? { avatarId: user.avatarId, bannerId: user.bannerId, injectFeaturedNote: profile!.injectFeaturedNote, @@ -315,19 +323,19 @@ export class UserRepository extends Repository { isBlocked: relation.isBlocked, isMuted: relation.isMuted, } : {}), - }; + } as Promiseable> as Promiseable>; return await awaitAll(packed); } - public packMany( + public packMany( users: (User['id'] | User)[], me?: { id: User['id'] } | null | undefined, options?: { - detail?: boolean, + detail?: D, includeSecrets?: boolean, } - ) { + ): Promise[]> { return Promise.all(users.map(u => this.pack(u, me, options))); } @@ -352,313 +360,3 @@ export class UserRepository extends Repository { public validateBirthday = $.str.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/); //#endregion } - -export const packedUserSchema = { - type: 'object' as const, - nullable: false as const, optional: false as const, - properties: { - id: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - example: 'xxxxxxxxxx', - }, - name: { - type: 'string' as const, - nullable: true as const, optional: false as const, - example: '藍', - }, - username: { - type: 'string' as const, - nullable: false as const, optional: false as const, - example: 'ai', - }, - host: { - type: 'string' as const, - nullable: true as const, optional: false as const, - example: 'misskey.example.com', - }, - avatarUrl: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: false as const, - }, - avatarBlurhash: { - type: 'any' as const, - nullable: true as const, optional: false as const, - }, - avatarColor: { - type: 'any' as const, - nullable: true as const, optional: false as const, - default: null, - }, - isAdmin: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - isModerator: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - isBot: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - isCat: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - emojis: { - type: 'array' as const, - nullable: false as const, optional: false as const, - items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - properties: { - name: { - type: 'string' as const, - nullable: false as const, optional: false as const, - }, - url: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'url', - }, - }, - }, - }, - url: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: true as const, - }, - createdAt: { - type: 'string' as const, - nullable: false as const, optional: true as const, - format: 'date-time', - }, - updatedAt: { - type: 'string' as const, - nullable: true as const, optional: true as const, - format: 'date-time', - }, - bannerUrl: { - type: 'string' as const, - format: 'url', - nullable: true as const, optional: true as const, - }, - bannerBlurhash: { - type: 'any' as const, - nullable: true as const, optional: true as const, - }, - bannerColor: { - type: 'any' as const, - nullable: true as const, optional: true as const, - default: null, - }, - isLocked: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - isSuspended: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - example: false, - }, - description: { - type: 'string' as const, - nullable: true as const, optional: true as const, - example: 'Hi masters, I am Ai!', - }, - location: { - type: 'string' as const, - nullable: true as const, optional: true as const, - }, - birthday: { - type: 'string' as const, - nullable: true as const, optional: true as const, - example: '2018-03-12', - }, - fields: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - properties: { - name: { - type: 'string' as const, - nullable: false as const, optional: false as const, - }, - value: { - type: 'string' as const, - nullable: false as const, optional: false as const, - }, - }, - maxLength: 4, - }, - }, - followersCount: { - type: 'number' as const, - nullable: false as const, optional: true as const, - }, - followingCount: { - type: 'number' as const, - nullable: false as const, optional: true as const, - }, - notesCount: { - type: 'number' as const, - nullable: false as const, optional: true as const, - }, - pinnedNoteIds: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'string' as const, - nullable: false as const, optional: false as const, - format: 'id', - }, - }, - pinnedNotes: { - type: 'array' as const, - nullable: false as const, optional: true as const, - items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - ref: 'Note' as const, - }, - }, - pinnedPageId: { - type: 'string' as const, - nullable: true as const, optional: true as const, - }, - pinnedPage: { - type: 'object' as const, - nullable: true as const, optional: true as const, - ref: 'Page' as const, - }, - twoFactorEnabled: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - usePasswordLessLogin: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - securityKeys: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - default: false, - }, - avatarId: { - type: 'string' as const, - nullable: true as const, optional: true as const, - format: 'id', - }, - bannerId: { - type: 'string' as const, - nullable: true as const, optional: true as const, - format: 'id', - }, - autoWatch: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - injectFeaturedNote: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - alwaysMarkNsfw: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - carefulBot: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - autoAcceptFollowed: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadSpecifiedNotes: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadMentions: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadAnnouncement: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadAntenna: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadChannel: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadMessagingMessage: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasUnreadNotification: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - hasPendingReceivedFollowRequest: { - type: 'boolean' as const, - nullable: false as const, optional: true as const, - }, - integrations: { - type: 'object' as const, - nullable: false as const, optional: true as const, - }, - mutedWords: { - type: 'array' as const, - nullable: false as const, optional: true as const, - }, - mutedInstances: { - type: 'array' as const, - nullable: false as const, optional: true as const, - }, - mutingNotificationTypes: { - type: 'array' as const, - nullable: false as const, optional: true as const, - }, - isFollowing: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - hasPendingFollowRequestFromYou: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - hasPendingFollowRequestToYou: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isFollowed: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isBlocking: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isBlocked: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - isMuted: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, - }, - }, -}; diff --git a/packages/backend/src/models/schema/antenna.ts b/packages/backend/src/models/schema/antenna.ts new file mode 100644 index 000000000..9cf522802 --- /dev/null +++ b/packages/backend/src/models/schema/antenna.ts @@ -0,0 +1,89 @@ +export const packedAntennaSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + keywords: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + }, + excludeKeywords: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + }, + src: { + type: 'string', + optional: false, nullable: false, + enum: ['home', 'all', 'users', 'list', 'group'], + }, + userListId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + }, + userGroupId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + }, + users: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + caseSensitive: { + type: 'boolean', + optional: false, nullable: false, + default: false, + }, + notify: { + type: 'boolean', + optional: false, nullable: false, + }, + withReplies: { + type: 'boolean', + optional: false, nullable: false, + default: false, + }, + withFile: { + type: 'boolean', + optional: false, nullable: false, + }, + hasUnreadNote: { + type: 'boolean', + optional: false, nullable: false, + default: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/app.ts b/packages/backend/src/models/schema/app.ts new file mode 100644 index 000000000..c80dc81c3 --- /dev/null +++ b/packages/backend/src/models/schema/app.ts @@ -0,0 +1,33 @@ +export const packedAppSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + callbackUrl: { + type: 'string', + optional: false, nullable: true, + }, + permission: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + secret: { + type: 'string', + optional: true, nullable: false, + }, + isAuthorized: { + type: 'boolean', + optional: true, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/blocking.ts b/packages/backend/src/models/schema/blocking.ts new file mode 100644 index 000000000..553232242 --- /dev/null +++ b/packages/backend/src/models/schema/blocking.ts @@ -0,0 +1,26 @@ +export const packedBlockingSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + blockeeId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + blockee: { + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/channel.ts b/packages/backend/src/models/schema/channel.ts new file mode 100644 index 000000000..7f4f2a48b --- /dev/null +++ b/packages/backend/src/models/schema/channel.ts @@ -0,0 +1,51 @@ +export const packedChannelSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + lastNotedAt: { + type: 'string', + optional: false, nullable: true, + format: 'date-time', + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + description: { + type: 'string', + nullable: true, optional: false, + }, + bannerUrl: { + type: 'string', + format: 'url', + nullable: true, optional: false, + }, + notesCount: { + type: 'number', + nullable: false, optional: false, + }, + usersCount: { + type: 'number', + nullable: false, optional: false, + }, + isFollowing: { + type: 'boolean', + optional: true, nullable: false, + }, + userId: { + type: 'string', + nullable: true, optional: false, + format: 'id', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/clip.ts b/packages/backend/src/models/schema/clip.ts new file mode 100644 index 000000000..f0ee2ce0c --- /dev/null +++ b/packages/backend/src/models/schema/clip.ts @@ -0,0 +1,38 @@ +export const packedClipSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + userId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + user: { + type: 'object', + ref: 'UserLite', + optional: false, nullable: false, + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + description: { + type: 'string', + optional: false, nullable: true, + }, + isPublic: { + type: 'boolean', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/drive-file.ts b/packages/backend/src/models/schema/drive-file.ts new file mode 100644 index 000000000..435907661 --- /dev/null +++ b/packages/backend/src/models/schema/drive-file.ts @@ -0,0 +1,107 @@ +export const packedDriveFileSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + name: { + type: 'string', + optional: false, nullable: false, + example: 'lenna.jpg', + }, + type: { + type: 'string', + optional: false, nullable: false, + example: 'image/jpeg', + }, + md5: { + type: 'string', + optional: false, nullable: false, + format: 'md5', + example: '15eca7fba0480996e2245f5185bf39f2', + }, + size: { + type: 'number', + optional: false, nullable: false, + example: 51469, + }, + isSensitive: { + type: 'boolean', + optional: false, nullable: false, + }, + blurhash: { + type: 'string', + optional: false, nullable: true, + }, + properties: { + type: 'object', + optional: false, nullable: false, + properties: { + width: { + type: 'number', + optional: true, nullable: false, + example: 1280, + }, + height: { + type: 'number', + optional: true, nullable: false, + example: 720, + }, + orientation: { + type: 'number', + optional: true, nullable: false, + example: 8, + }, + avgColor: { + type: 'string', + optional: true, nullable: false, + example: 'rgb(40,65,87)', + }, + }, + }, + url: { + type: 'string', + optional: false, nullable: true, + format: 'url', + }, + thumbnailUrl: { + type: 'string', + optional: false, nullable: true, + format: 'url', + }, + comment: { + type: 'string', + optional: false, nullable: true, + }, + folderId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + example: 'xxxxxxxxxx', + }, + folder: { + type: 'object', + optional: true, nullable: true, + ref: 'DriveFolder', + }, + userId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + example: 'xxxxxxxxxx', + }, + user: { + type: 'object', + optional: true, nullable: true, + ref: 'UserLite', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/drive-folder.ts b/packages/backend/src/models/schema/drive-folder.ts new file mode 100644 index 000000000..88cb8ab4a --- /dev/null +++ b/packages/backend/src/models/schema/drive-folder.ts @@ -0,0 +1,39 @@ +export const packedDriveFolderSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + foldersCount: { + type: 'number', + optional: true, nullable: false, + }, + filesCount: { + type: 'number', + optional: true, nullable: false, + }, + parentId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + example: 'xxxxxxxxxx', + }, + parent: { + type: 'object', + optional: true, nullable: true, + ref: 'DriveFolder', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/emoji.ts b/packages/backend/src/models/schema/emoji.ts new file mode 100644 index 000000000..5f9af88db --- /dev/null +++ b/packages/backend/src/models/schema/emoji.ts @@ -0,0 +1,36 @@ +export const packedEmojiSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + aliases: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + category: { + type: 'string', + optional: false, nullable: true, + }, + host: { + type: 'string', + optional: false, nullable: true, + }, + url: { + type: 'string', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/federation-instance.ts b/packages/backend/src/models/schema/federation-instance.ts new file mode 100644 index 000000000..eef2f9e24 --- /dev/null +++ b/packages/backend/src/models/schema/federation-instance.ts @@ -0,0 +1,105 @@ +import config from "@/config"; + +export const packedFederationInstanceSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + caughtAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + host: { + type: 'string', + optional: false, nullable: false, + example: 'misskey.example.com', + }, + usersCount: { + type: 'number', + optional: false, nullable: false, + }, + notesCount: { + type: 'number', + optional: false, nullable: false, + }, + followingCount: { + type: 'number', + optional: false, nullable: false, + }, + followersCount: { + type: 'number', + optional: false, nullable: false, + }, + driveUsage: { + type: 'number', + optional: false, nullable: false, + }, + driveFiles: { + type: 'number', + optional: false, nullable: false, + }, + latestRequestSentAt: { + type: 'string', + optional: false, nullable: true, + format: 'date-time', + }, + lastCommunicatedAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + isNotResponding: { + type: 'boolean', + optional: false, nullable: false, + }, + isSuspended: { + type: 'boolean', + optional: false, nullable: false, + }, + softwareName: { + type: 'string', + optional: false, nullable: true, + example: 'misskey', + }, + softwareVersion: { + type: 'string', + optional: false, nullable: true, + example: config.version, + }, + openRegistrations: { + type: 'boolean', + optional: false, nullable: true, + example: true, + }, + name: { + type: 'string', + optional: false, nullable: true, + }, + description: { + type: 'string', + optional: false, nullable: true, + }, + maintainerName: { + type: 'string', + optional: false, nullable: true, + }, + maintainerEmail: { + type: 'string', + optional: false, nullable: true, + }, + iconUrl: { + type: 'string', + optional: false, nullable: true, + format: 'url', + }, + infoUpdatedAt: { + type: 'string', + optional: false, nullable: true, + format: 'date-time', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/following.ts b/packages/backend/src/models/schema/following.ts new file mode 100644 index 000000000..2bcffbfc4 --- /dev/null +++ b/packages/backend/src/models/schema/following.ts @@ -0,0 +1,36 @@ +export const packedFollowingSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + followeeId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + followee: { + type: 'object', + optional: true, nullable: false, + ref: 'UserDetailed', + }, + followerId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + follower: { + type: 'object', + optional: true, nullable: false, + ref: 'UserDetailed', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/gallery-post.ts b/packages/backend/src/models/schema/gallery-post.ts new file mode 100644 index 000000000..fc503d4a6 --- /dev/null +++ b/packages/backend/src/models/schema/gallery-post.ts @@ -0,0 +1,69 @@ +export const packedGalleryPostSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + updatedAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + title: { + type: 'string', + optional: false, nullable: false, + }, + description: { + type: 'string', + optional: false, nullable: true, + }, + userId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + user: { + type: 'object', + ref: 'UserLite', + optional: false, nullable: false, + }, + fileIds: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, + files: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + ref: 'DriveFile', + }, + }, + tags: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + isSensitive: { + type: 'boolean', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/hashtag.ts b/packages/backend/src/models/schema/hashtag.ts new file mode 100644 index 000000000..98f882764 --- /dev/null +++ b/packages/backend/src/models/schema/hashtag.ts @@ -0,0 +1,34 @@ +export const packedHashtagSchema = { + type: 'object', + properties: { + tag: { + type: 'string', + optional: false, nullable: false, + example: 'misskey', + }, + mentionedUsersCount: { + type: 'number', + optional: false, nullable: false, + }, + mentionedLocalUsersCount: { + type: 'number', + optional: false, nullable: false, + }, + mentionedRemoteUsersCount: { + type: 'number', + optional: false, nullable: false, + }, + attachedUsersCount: { + type: 'number', + optional: false, nullable: false, + }, + attachedLocalUsersCount: { + type: 'number', + optional: false, nullable: false, + }, + attachedRemoteUsersCount: { + type: 'number', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/messaging-message.ts b/packages/backend/src/models/schema/messaging-message.ts new file mode 100644 index 000000000..b1ffa4595 --- /dev/null +++ b/packages/backend/src/models/schema/messaging-message.ts @@ -0,0 +1,73 @@ +export const packedMessagingMessageSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + userId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + user: { + type: 'object', + ref: 'UserLite', + optional: true, nullable: false, + }, + text: { + type: 'string', + optional: false, nullable: true, + }, + fileId: { + type: 'string', + optional: true, nullable: true, + format: 'id', + }, + file: { + type: 'object', + optional: true, nullable: true, + ref: 'DriveFile', + }, + recipientId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + }, + recipient: { + type: 'object', + optional: true, nullable: true, + ref: 'UserLite', + }, + groupId: { + type: 'string', + optional: false, nullable: true, + format: 'id', + }, + group: { + type: 'object', + optional: true, nullable: true, + ref: 'UserGroup', + }, + isRead: { + type: 'boolean', + optional: true, nullable: false, + }, + reads: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/muting.ts b/packages/backend/src/models/schema/muting.ts new file mode 100644 index 000000000..d75a4fbfe --- /dev/null +++ b/packages/backend/src/models/schema/muting.ts @@ -0,0 +1,26 @@ +export const packedMutingSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + muteeId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + mutee: { + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/note-favorite.ts b/packages/backend/src/models/schema/note-favorite.ts new file mode 100644 index 000000000..d133f7367 --- /dev/null +++ b/packages/backend/src/models/schema/note-favorite.ts @@ -0,0 +1,26 @@ +export const packedNoteFavoriteSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + note: { + type: 'object', + optional: false, nullable: false, + ref: 'Note', + }, + noteId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/note-reaction.ts b/packages/backend/src/models/schema/note-reaction.ts new file mode 100644 index 000000000..0d8fc5449 --- /dev/null +++ b/packages/backend/src/models/schema/note-reaction.ts @@ -0,0 +1,25 @@ +export const packedNoteReactionSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + user: { + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', + }, + type: { + type: 'string', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/note.ts b/packages/backend/src/models/schema/note.ts new file mode 100644 index 000000000..cdf4b9a54 --- /dev/null +++ b/packages/backend/src/models/schema/note.ts @@ -0,0 +1,183 @@ +export const packedNoteSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + text: { + type: 'string', + optional: false, nullable: true, + }, + cw: { + type: 'string', + optional: true, nullable: true, + }, + userId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + user: { + type: 'object', + ref: 'UserLite', + optional: false, nullable: false, + }, + replyId: { + type: 'string', + optional: true, nullable: true, + format: 'id', + example: 'xxxxxxxxxx', + }, + renoteId: { + type: 'string', + optional: true, nullable: true, + format: 'id', + example: 'xxxxxxxxxx', + }, + reply: { + type: 'object', + optional: true, nullable: true, + ref: 'Note', + }, + renote: { + type: 'object', + optional: true, nullable: true, + ref: 'Note', + }, + isHidden: { + type: 'boolean', + optional: true, nullable: false, + }, + visibility: { + type: 'string', + optional: false, nullable: false, + }, + mentions: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, + visibleUserIds: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, + fileIds: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + }, + files: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + ref: 'DriveFile', + }, + }, + tags: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + poll: { + type: 'object', + optional: true, nullable: true, + }, + channelId: { + type: 'string', + optional: true, nullable: true, + format: 'id', + example: 'xxxxxxxxxx', + }, + channel: { + type: 'object', + optional: true, nullable: true, + items: { + type: 'object', + optional: false, nullable: false, + properties: { + id: { + type: 'string', + optional: false, nullable: false, + }, + name: { + type: 'string', + optional: false, nullable: true, + }, + }, + }, + }, + localOnly: { + type: 'boolean', + optional: true, nullable: false, + }, + emojis: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + properties: { + name: { + type: 'string', + optional: false, nullable: false, + }, + url: { + type: 'string', + optional: false, nullable: true, + }, + }, + }, + }, + reactions: { + type: 'object', + optional: false, nullable: false, + }, + renoteCount: { + type: 'number', + optional: false, nullable: false, + }, + repliesCount: { + type: 'number', + optional: false, nullable: false, + }, + uri: { + type: 'string', + optional: true, nullable: false, + }, + url: { + type: 'string', + optional: true, nullable: false, + }, + + myReaction: { + type: 'object', + optional: true, nullable: true, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/notification.ts b/packages/backend/src/models/schema/notification.ts new file mode 100644 index 000000000..f3c293c48 --- /dev/null +++ b/packages/backend/src/models/schema/notification.ts @@ -0,0 +1,66 @@ +import { notificationTypes } from "@/types"; + +export const packedNotificationSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + isRead: { + type: 'boolean', + optional: false, nullable: false, + }, + type: { + type: 'string', + optional: false, nullable: false, + enum: [...notificationTypes], + }, + user: { + type: 'object', + ref: 'UserLite', + optional: true, nullable: true, + }, + userId: { + type: 'string', + optional: true, nullable: true, + format: 'id', + }, + note: { + type: 'object', + ref: 'Note', + optional: true, nullable: true, + }, + reaction: { + type: 'string', + optional: true, nullable: true, + }, + choice: { + type: 'number', + optional: true, nullable: true, + }, + invitation: { + type: 'object', + optional: true, nullable: true, + }, + body: { + type: 'string', + optional: true, nullable: true, + }, + header: { + type: 'string', + optional: true, nullable: true, + }, + icon: { + type: 'string', + optional: true, nullable: true, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/page.ts b/packages/backend/src/models/schema/page.ts new file mode 100644 index 000000000..55ba3ce7f --- /dev/null +++ b/packages/backend/src/models/schema/page.ts @@ -0,0 +1,51 @@ +export const packedPageSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + updatedAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + title: { + type: 'string', + optional: false, nullable: false, + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + summary: { + type: 'string', + optional: false, nullable: true, + }, + content: { + type: 'array', + optional: false, nullable: false, + }, + variables: { + type: 'array', + optional: false, nullable: false, + }, + userId: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + user: { + type: 'object', + ref: 'UserLite', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/queue.ts b/packages/backend/src/models/schema/queue.ts new file mode 100644 index 000000000..7ceeda26a --- /dev/null +++ b/packages/backend/src/models/schema/queue.ts @@ -0,0 +1,25 @@ +export const packedQueueCountSchema = { + type: 'object', + properties: { + waiting: { + type: 'number', + optional: false, nullable: false, + }, + active: { + type: 'number', + optional: false, nullable: false, + }, + completed: { + type: 'number', + optional: false, nullable: false, + }, + failed: { + type: 'number', + optional: false, nullable: false, + }, + delayed: { + type: 'number', + optional: false, nullable: false, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/user-group.ts b/packages/backend/src/models/schema/user-group.ts new file mode 100644 index 000000000..a73bf82bb --- /dev/null +++ b/packages/backend/src/models/schema/user-group.ts @@ -0,0 +1,34 @@ +export const packedUserGroupSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + ownerId: { + type: 'string', + nullable: false, optional: false, + format: 'id', + }, + userIds: { + type: 'array', + nullable: false, optional: true, + items: { + type: 'string', + nullable: false, optional: false, + format: 'id', + }, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/user-list.ts b/packages/backend/src/models/schema/user-list.ts new file mode 100644 index 000000000..3ba5dc4a8 --- /dev/null +++ b/packages/backend/src/models/schema/user-list.ts @@ -0,0 +1,29 @@ +export const packedUserListSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + userIds: { + type: 'array', + nullable: false, optional: true, + items: { + type: 'string', + nullable: false, optional: false, + format: 'id', + }, + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/user.ts b/packages/backend/src/models/schema/user.ts new file mode 100644 index 000000000..616bedc0d --- /dev/null +++ b/packages/backend/src/models/schema/user.ts @@ -0,0 +1,467 @@ +export const packedUserLiteSchema = { + type: 'object', + properties: { + id: { + type: 'string', + nullable: false, optional: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + name: { + type: 'string', + nullable: true, optional: false, + example: '藍', + }, + username: { + type: 'string', + nullable: false, optional: false, + example: 'ai', + }, + host: { + type: 'string', + nullable: true, optional: false, + example: 'misskey.example.com', + }, + avatarUrl: { + type: 'string', + format: 'url', + nullable: true, optional: false, + }, + avatarBlurhash: { + type: 'any', + nullable: true, optional: false, + }, + avatarColor: { + type: 'any', + nullable: true, optional: false, + default: null, + }, + isAdmin: { + type: 'boolean', + nullable: false, optional: true, + default: false, + }, + isModerator: { + type: 'boolean', + nullable: false, optional: true, + default: false, + }, + isBot: { + type: 'boolean', + nullable: false, optional: true, + }, + isCat: { + type: 'boolean', + nullable: false, optional: true, + }, + emojis: { + type: 'array', + nullable: false, optional: false, + items: { + type: 'object', + nullable: false, optional: false, + properties: { + name: { + type: 'string', + nullable: false, optional: false, + }, + url: { + type: 'string', + nullable: false, optional: false, + format: 'url', + }, + }, + }, + }, + onlineStatus: { + type: 'string', + format: 'url', + nullable: true, optional: false, + enum: ['unknown', 'online', 'active', 'offline'], + }, + }, +} as const; + +export const packedUserDetailedNotMeOnlySchema = { + type: 'object', + properties: { + url: { + type: 'string', + format: 'url', + nullable: true, optional: false, + }, + uri: { + type: 'string', + format: 'uri', + nullable: true, optional: false, + }, + createdAt: { + type: 'string', + nullable: false, optional: false, + format: 'date-time', + }, + updatedAt: { + type: 'string', + nullable: true, optional: false, + format: 'date-time', + }, + lastFetchedAt: { + type: 'string', + nullable: true, optional: false, + format: 'date-time', + }, + bannerUrl: { + type: 'string', + format: 'url', + nullable: true, optional: false, + }, + bannerBlurhash: { + type: 'any', + nullable: true, optional: false, + }, + bannerColor: { + type: 'any', + nullable: true, optional: false, + default: null, + }, + isLocked: { + type: 'boolean', + nullable: false, optional: false, + }, + isSilenced: { + type: 'boolean', + nullable: false, optional: false, + }, + isSuspended: { + type: 'boolean', + nullable: false, optional: false, + example: false, + }, + description: { + type: 'string', + nullable: true, optional: false, + example: 'Hi masters, I am Ai!', + }, + location: { + type: 'string', + nullable: true, optional: false, + }, + birthday: { + type: 'string', + nullable: true, optional: false, + example: '2018-03-12', + }, + lang: { + type: 'string', + nullable: true, optional: false, + example: 'ja-JP', + }, + fields: { + type: 'array', + nullable: false, optional: false, + items: { + type: 'object', + nullable: false, optional: false, + properties: { + name: { + type: 'string', + nullable: false, optional: false, + }, + value: { + type: 'string', + nullable: false, optional: false, + }, + }, + maxLength: 4, + }, + }, + followersCount: { + type: 'number', + nullable: false, optional: false, + }, + followingCount: { + type: 'number', + nullable: false, optional: false, + }, + notesCount: { + type: 'number', + nullable: false, optional: false, + }, + pinnedNoteIds: { + type: 'array', + nullable: false, optional: false, + items: { + type: 'string', + nullable: false, optional: false, + format: 'id', + }, + }, + pinnedNotes: { + type: 'array', + nullable: false, optional: false, + items: { + type: 'object', + nullable: false, optional: false, + ref: 'Note', + }, + }, + pinnedPageId: { + type: 'string', + nullable: true, optional: false, + }, + pinnedPage: { + type: 'object', + nullable: true, optional: false, + ref: 'Page', + }, + publicReactions: { + type: 'boolean', + nullable: false, optional: false, + }, + twoFactorEnabled: { + type: 'boolean', + nullable: false, optional: false, + default: false, + }, + usePasswordLessLogin: { + type: 'boolean', + nullable: false, optional: false, + default: false, + }, + securityKeys: { + type: 'boolean', + nullable: false, optional: false, + default: false, + }, + //#region relations + isFollowing: { + type: 'boolean', + nullable: false, optional: true, + }, + isFollowed: { + type: 'boolean', + nullable: false, optional: true, + }, + hasPendingFollowRequestFromYou: { + type: 'boolean', + nullable: false, optional: true, + }, + hasPendingFollowRequestToYou: { + type: 'boolean', + nullable: false, optional: true, + }, + isBlocking: { + type: 'boolean', + nullable: false, optional: true, + }, + isBlocked: { + type: 'boolean', + nullable: false, optional: true, + }, + isMuted: { + type: 'boolean', + nullable: false, optional: true, + }, + //#endregion + }, +} as const; + +export const packedMeDetailedOnlySchema = { + type: 'object', + properties: { + avatarId: { + type: 'string', + nullable: true, optional: false, + format: 'id', + }, + bannerId: { + type: 'string', + nullable: true, optional: false, + format: 'id', + }, + injectFeaturedNote: { + type: 'boolean', + nullable: true, optional: false, + }, + receiveAnnouncementEmail: { + type: 'boolean', + nullable: true, optional: false, + }, + alwaysMarkNsfw: { + type: 'boolean', + nullable: true, optional: false, + }, + carefulBot: { + type: 'boolean', + nullable: true, optional: false, + }, + autoAcceptFollowed: { + type: 'boolean', + nullable: true, optional: false, + }, + noCrawle: { + type: 'boolean', + nullable: true, optional: false, + }, + isExplorable: { + type: 'boolean', + nullable: false, optional: false, + }, + isDeleted: { + type: 'boolean', + nullable: false, optional: false, + }, + hideOnlineStatus: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadSpecifiedNotes: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadMentions: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadAnnouncement: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadAntenna: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadChannel: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadMessagingMessage: { + type: 'boolean', + nullable: false, optional: false, + }, + hasUnreadNotification: { + type: 'boolean', + nullable: false, optional: false, + }, + hasPendingReceivedFollowRequest: { + type: 'boolean', + nullable: false, optional: false, + }, + integrations: { + type: 'object', + nullable: true, optional: false, + }, + mutedWords: { + type: 'array', + nullable: false, optional: false, + items: { + type: 'array', + nullable: false, optional: false, + items: { + type: 'string', + nullable: false, optional: false, + }, + }, + }, + mutedInstances: { + type: 'array', + nullable: true, optional: false, + items: { + type: 'string', + nullable: false, optional: false, + }, + }, + mutingNotificationTypes: { + type: 'array', + nullable: true, optional: false, + items: { + type: 'string', + nullable: false, optional: false, + }, + }, + emailNotificationTypes: { + type: 'array', + nullable: true, optional: false, + items: { + type: 'string', + nullable: false, optional: false, + }, + }, + //#region secrets + email: { + type: 'string', + nullable: true, optional: true, + }, + emailVerified: { + type: 'boolean', + nullable: true, optional: true, + }, + securityKeysList: { + type: 'array', + nullable: false, optional: true, + items: { + type: 'object', + nullable: false, optional: false, + }, + }, + //#endregion + }, +} as const; + +export const packedUserDetailedNotMeSchema = { + type: 'object', + allOf: [ + { + type: 'object', + ref: 'UserLite', + }, + { + type: 'object', + ref: 'UserDetailedNotMeOnly', + }, + ], +} as const; + +export const packedMeDetailedSchema = { + type: 'object', + allOf: [ + { + type: 'object', + ref: 'UserLite', + }, + { + type: 'object', + ref: 'UserDetailedNotMeOnly', + }, + { + type: 'object', + ref: 'MeDetailedOnly', + }, + ], +} as const; + +export const packedUserDetailedSchema = { + oneOf: [ + { + type: 'object', + ref: 'UserDetailedNotMe', + }, + { + type: 'object', + ref: 'MeDetailed', + }, + ], +} as const; + +export const packedUserSchema = { + oneOf: [ + { + type: 'object', + ref: 'UserLite', + }, + { + type: 'object', + ref: 'UserDetailed', + }, + ], +} as const; diff --git a/packages/backend/src/prelude/await-all.ts b/packages/backend/src/prelude/await-all.ts index 24795f3ae..b955c3a5d 100644 --- a/packages/backend/src/prelude/await-all.ts +++ b/packages/backend/src/prelude/await-all.ts @@ -1,13 +1,11 @@ -type Await = T extends Promise ? U : T; - -type AwaitAll = { - [P in keyof T]: Await; +export type Promiseable = { + [K in keyof T]: Promise | T[K]; }; -export async function awaitAll(obj: T): Promise> { - const target = {} as any; - const keys = Object.keys(obj); - const values = Object.values(obj); +export async function awaitAll(obj: Promiseable): Promise { + const target = {} as T; + const keys = Object.keys(obj) as unknown as (keyof T)[]; + const values = Object.values(obj) as any[]; const resolvedValues = await Promise.all(values.map(value => (!value || !value.constructor || value.constructor.name !== 'Object') diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index a61b3f564..bb4e972b8 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -3,7 +3,7 @@ import { dirname } from 'path'; import { Context } from 'cafy'; import * as path from 'path'; import * as glob from 'glob'; -import { SimpleSchema } from '@/misc/simple-schema'; +import { Schema } from '@/misc/schema'; //const _filename = fileURLToPath(import.meta.url); const _filename = __filename; @@ -18,87 +18,87 @@ export type Param = { }; export interface IEndpointMeta { - stability?: string; //'deprecated' | 'experimental' | 'stable'; + readonly stability?: 'deprecated' | 'experimental' | 'stable'; - tags?: string[]; + readonly tags?: ReadonlyArray; - params?: { - [key: string]: Param; + readonly params?: { + readonly [key: string]: Param; }; - errors?: { - [key: string]: { - message: string; - code: string; - id: string; + readonly errors?: { + readonly [key: string]: { + readonly message: string; + readonly code: string; + readonly id: string; }; }; - res?: SimpleSchema; + readonly res?: Schema; /** * このエンドポイントにリクエストするのにユーザー情報が必須か否か * 省略した場合は false として解釈されます。 */ - requireCredential?: boolean; + readonly requireCredential?: boolean; /** * 管理者のみ使えるエンドポイントか否か */ - requireAdmin?: boolean; + readonly requireAdmin?: boolean; /** * 管理者またはモデレーターのみ使えるエンドポイントか否か */ - requireModerator?: boolean; + readonly requireModerator?: boolean; /** * エンドポイントのリミテーションに関するやつ * 省略した場合はリミテーションは無いものとして解釈されます。 * また、withCredential が false の場合はリミテーションを行うことはできません。 */ - limit?: { + readonly limit?: { /** * 複数のエンドポイントでリミットを共有したい場合に指定するキー */ - key?: string; + readonly key?: string; /** * リミットを適用する期間(ms) * このプロパティを設定する場合、max プロパティも設定する必要があります。 */ - duration?: number; + readonly duration?: number; /** * durationで指定した期間内にいくつまでリクエストできるのか * このプロパティを設定する場合、duration プロパティも設定する必要があります。 */ - max?: number; + readonly max?: number; /** * 最低でもどれくらいの間隔を開けてリクエストしなければならないか(ms) */ - minInterval?: number; + readonly minInterval?: number; }; /** * ファイルの添付を必要とするか否か * 省略した場合は false として解釈されます。 */ - requireFile?: boolean; + readonly requireFile?: boolean; /** * サードパーティアプリからはリクエストすることができないか否か * 省略した場合は false として解釈されます。 */ - secure?: boolean; + readonly secure?: boolean; /** * エンドポイントの種類 * パーミッションの実現に利用されます。 */ - kind?: string; + readonly kind?: string; } export interface IEndpoint { diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts index 5d4cc2c04..807afd269 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -49,66 +49,66 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, format: 'id', example: 'xxxxxxxxxx', }, createdAt: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, format: 'date-time', }, comment: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, }, resolved: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, example: false, }, reporterId: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, format: 'id', }, targetUserId: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, format: 'id', }, assigneeId: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, format: 'id', }, reporter: { - type: 'object' as const, - nullable: false as const, optional: false as const, + type: 'object', + nullable: false, optional: false, ref: 'User', }, targetUser: { - type: 'object' as const, - nullable: false as const, optional: false as const, + type: 'object', + nullable: false, optional: false, ref: 'User', }, assignee: { - type: 'object' as const, - nullable: true as const, optional: true as const, + type: 'object', + nullable: true, optional: true, ref: 'User', }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts index edfac244f..20f123295 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts @@ -16,17 +16,17 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'User', properties: { token: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, _me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts index 3ed6ac2f3..1701c1e3a 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts @@ -9,7 +9,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -17,7 +17,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts index 3388ef272..00ad2012f 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/create.ts @@ -6,7 +6,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -32,7 +32,7 @@ export const meta = { validator: $.str.min(1), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts index ab0458af6..c0124e248 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts @@ -7,7 +7,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -23,7 +23,7 @@ export const meta = { id: 'ccac9863-3a03-416e-b899-8a64041118b1', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/ad/list.ts b/packages/backend/src/server/api/endpoints/admin/ad/list.ts index 04597ec7b..7a83637f3 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/list.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -24,7 +24,7 @@ export const meta = { validator: $.optional.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/ad/update.ts b/packages/backend/src/server/api/endpoints/admin/ad/update.ts index 7fab745ef..c2b09ab9c 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/update.ts @@ -7,7 +7,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -44,7 +44,7 @@ export const meta = { id: 'b7aa1727-1354-47bc-a182-3a9c3973d300', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts index 7d169d6ca..24c4caa37 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts @@ -6,7 +6,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -22,40 +22,40 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', example: 'xxxxxxxxxx', }, createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'date-time', }, updatedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'date-time', }, title: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, text: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, imageUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts b/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts index 81dd8cfc5..5548f9900 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts @@ -7,7 +7,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -23,7 +23,7 @@ export const meta = { id: 'ecad8040-a276-4e85-bda9-015a708d291e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts index f6ad6d36f..e5cc53ccd 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -26,48 +26,48 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', example: 'xxxxxxxxxx', }, createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'date-time', }, updatedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'date-time', }, text: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, title: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, imageUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, reads: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts index 6fb4b571a..f66293bb1 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts @@ -7,7 +7,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -32,7 +32,7 @@ export const meta = { id: 'd3aae5a7-6372-4cb4-b61c-f511ffc2d7cc', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts b/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts index 82cbe7b19..249e63a0f 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts @@ -7,7 +7,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -15,7 +15,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/delete-logs.ts b/packages/backend/src/server/api/endpoints/admin/delete-logs.ts deleted file mode 100644 index 197ad01cb..000000000 --- a/packages/backend/src/server/api/endpoints/admin/delete-logs.ts +++ /dev/null @@ -1,14 +0,0 @@ -import define from '../../define'; -import { Logs } from '@/models/index'; - -export const meta = { - tags: ['admin'], - - requireCredential: true as const, - requireModerator: true, -}; - -// eslint-disable-next-line import/no-default-export -export default define(meta, async (ps) => { - await Logs.clear(); // TRUNCATE -}); diff --git a/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts b/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts index 518535fdd..acabbfef5 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts @@ -4,9 +4,9 @@ import { createCleanRemoteFilesJob } from '@/queue/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts b/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts index a523c5b39..452e7069a 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts @@ -6,9 +6,9 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/drive/files.ts b/packages/backend/src/server/api/endpoints/admin/drive/files.ts index b90ad9044..264f54986 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/files.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/files.ts @@ -7,7 +7,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['admin'], - requireCredential: false as const, + requireCredential: false, requireModerator: true, params: { @@ -44,15 +44,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts b/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts index bc0857588..5d9a1f270 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts @@ -7,7 +7,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -29,137 +29,137 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', example: 'xxxxxxxxxx', }, createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'date-time', }, userId: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'id', example: 'xxxxxxxxxx', }, userHost: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, md5: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'md5', example: '15eca7fba0480996e2245f5185bf39f2', }, name: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, example: 'lenna.jpg', }, type: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, example: 'image/jpeg', }, size: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, example: 51469, }, comment: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, blurhash: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, properties: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { width: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, example: 1280, }, height: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, example: 720, }, avgColor: { - type: 'string' as const, - optional: true as const, nullable: false as const, + type: 'string', + optional: true, nullable: false, example: 'rgb(40,65,87)', }, }, }, storedInternal: { - type: 'boolean' as const, - optional: false as const, nullable: true as const, + type: 'boolean', + optional: false, nullable: true, example: true, }, url: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'url', }, thumbnailUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'url', }, webpublicUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'url', }, accessKey: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, thumbnailAccessKey: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, webpublicAccessKey: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, uri: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, src: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, folderId: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'id', example: 'xxxxxxxxxx', }, isSensitive: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isLink: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts index ef0f31502..f0fd73c27 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -20,7 +20,7 @@ export const meta = { validator: $.arr($.str), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts index f7a0fdb87..72adda9dc 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts @@ -12,7 +12,7 @@ import { publishBroadcastStream } from '@/services/stream'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -28,7 +28,7 @@ export const meta = { id: 'fc46b5a4-6b92-4c33-ac66-b806659bb5cf', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts index 6dc7d1bd9..de239c4f0 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts @@ -12,7 +12,7 @@ import { publishBroadcastStream } from '@/services/stream'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -30,17 +30,17 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts index a99cd3c97..797a5de67 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts @@ -9,7 +9,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -17,7 +17,7 @@ export const meta = { validator: $.arr($.type(ID)), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts index 870245ac9..158043902 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts @@ -9,7 +9,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -25,7 +25,7 @@ export const meta = { id: 'be83669b-773a-44b7-b1f8-e5e5170ac3c2', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts index 04895b8f2..8856a38f2 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts @@ -6,14 +6,14 @@ import { ID } from '@/misc/cafy-id'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { fileId: { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts index 42b6cb1fc..6e502547f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts @@ -8,7 +8,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -37,45 +37,45 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, aliases: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, name: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, category: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, host: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, url: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts index 5026af914..76ef190f9 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts @@ -8,7 +8,7 @@ import { Emoji } from '@/models/entities/emoji'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -32,45 +32,45 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, aliases: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, name: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, category: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, host: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, url: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts index 4c771b4e4..c49f84b7f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -20,7 +20,7 @@ export const meta = { validator: $.arr($.str), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts index 33dccbc64..06197820f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -20,7 +20,7 @@ export const meta = { validator: $.arr($.str), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts index d40ed52da..f0645f111 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -20,7 +20,7 @@ export const meta = { validator: $.optional.nullable.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts index 391887257..54a2cf951 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -36,7 +36,7 @@ export const meta = { id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts b/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts index 904619683..db023c6f0 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts @@ -6,7 +6,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -14,7 +14,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts b/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts index d9e3900a2..b68252ef2 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts @@ -7,7 +7,7 @@ import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -15,7 +15,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts index 485bbe7d5..4de8ad133 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts @@ -6,7 +6,7 @@ import { Followings, Users } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -14,7 +14,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts b/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts index 3ddccecc6..6ac2f1f46 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts @@ -6,7 +6,7 @@ import { toPuny } from '@/misc/convert-host'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -18,7 +18,7 @@ export const meta = { validator: $.bool, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts index 877e67aa7..9a2bccec7 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts @@ -2,14 +2,14 @@ import define from '../../define'; import { getConnection } from 'typeorm'; export const meta = { - requireCredential: true as const, + requireCredential: true, requireModerator: true, tags: ['admin'], params: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts index 5d4ea9c44..1c5f25067 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts @@ -2,7 +2,7 @@ import define from '../../define'; import { getConnection } from 'typeorm'; export const meta = { - requireCredential: true as const, + requireCredential: true, requireModerator: true, tags: ['admin'], @@ -11,8 +11,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, example: { migrations: { count: 66, @@ -20,7 +20,7 @@ export const meta = { }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/admin/invite.ts b/packages/backend/src/server/api/endpoints/admin/invite.ts index 1c8c51434..3428709c0 100644 --- a/packages/backend/src/server/api/endpoints/admin/invite.ts +++ b/packages/backend/src/server/api/endpoints/admin/invite.ts @@ -6,25 +6,25 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: {}, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { code: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, example: '2ERUA5VR', maxLength: 8, minLength: 8, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts index ea795895f..0308cf276 100644 --- a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts @@ -6,7 +6,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireAdmin: true, params: { @@ -14,7 +14,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts index 25f237d81..bdb976e9e 100644 --- a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts +++ b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts @@ -6,7 +6,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireAdmin: true, params: { @@ -14,7 +14,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/promo/create.ts b/packages/backend/src/server/api/endpoints/admin/promo/create.ts index 1bd54ba89..f2735ac9f 100644 --- a/packages/backend/src/server/api/endpoints/admin/promo/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/promo/create.ts @@ -8,7 +8,7 @@ import { PromoNotes } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -34,7 +34,7 @@ export const meta = { id: 'ae427aa2-7a41-484f-a18c-2c1104051604', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/clear.ts b/packages/backend/src/server/api/endpoints/admin/queue/clear.ts index 8a91168ec..3c8e7a27a 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/clear.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/clear.ts @@ -5,11 +5,11 @@ import { insertModerationLog } from '@/services/insert-moderation-log'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: {}, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts b/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts index 2c867463e..4760e2c31 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts @@ -5,25 +5,25 @@ import define from '../../../define'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { anyOf: [ { - type: 'string' as const, + type: 'string', }, { - type: 'number' as const, + type: 'number', }, ], }, @@ -33,7 +33,7 @@ export const meta = { 12, ]], }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts b/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts index 974e68012..a95aabc50 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts @@ -5,25 +5,25 @@ import { inboxQueue } from '@/queue/queues'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { anyOf: [ { - type: 'string' as const, + type: 'string', }, { - type: 'number' as const, + type: 'number', }, ], }, @@ -33,7 +33,7 @@ export const meta = { 12, ]], }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts b/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts index 70649e067..df0b4a8f1 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts @@ -5,7 +5,7 @@ import define from '../../../define'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -24,37 +24,37 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, data: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, }, attempts: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, maxAttempts: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, timestamp: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/queue/stats.ts b/packages/backend/src/server/api/endpoints/admin/queue/stats.ts index 5de871a60..dab0be5db 100644 --- a/packages/backend/src/server/api/endpoints/admin/queue/stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/queue/stats.ts @@ -4,30 +4,34 @@ import define from '../../../define'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: {}, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { deliver: { + optional: false, nullable: false, ref: 'QueueCount', }, inbox: { + optional: false, nullable: false, ref: 'QueueCount', }, db: { + optional: false, nullable: false, ref: 'QueueCount', }, objectStorage: { + optional: false, nullable: false, ref: 'QueueCount', }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/relays/add.ts b/packages/backend/src/server/api/endpoints/admin/relays/add.ts index c4a0f1302..65890a00f 100644 --- a/packages/backend/src/server/api/endpoints/admin/relays/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/relays/add.ts @@ -7,8 +7,8 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['admin'], - requireCredential: true as const, - requireModerator: true as const, + requireCredential: true, + requireModerator: true, params: { inbox: { @@ -25,22 +25,22 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, inbox: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', }, status: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, default: 'requesting', enum: [ 'requesting', @@ -50,7 +50,7 @@ export const meta = { }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/admin/relays/list.ts b/packages/backend/src/server/api/endpoints/admin/relays/list.ts index 1e8afd783..bdddf1337 100644 --- a/packages/backend/src/server/api/endpoints/admin/relays/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/relays/list.ts @@ -4,32 +4,32 @@ import { listRelay } from '@/services/relay'; export const meta = { tags: ['admin'], - requireCredential: true as const, - requireModerator: true as const, + requireCredential: true, + requireModerator: true, params: { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, inbox: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', }, status: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, default: 'requesting', enum: [ 'requesting', @@ -40,7 +40,7 @@ export const meta = { }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/admin/relays/remove.ts b/packages/backend/src/server/api/endpoints/admin/relays/remove.ts index 293de2b91..4b04e620c 100644 --- a/packages/backend/src/server/api/endpoints/admin/relays/remove.ts +++ b/packages/backend/src/server/api/endpoints/admin/relays/remove.ts @@ -5,15 +5,15 @@ import { removeRelay } from '@/services/relay'; export const meta = { tags: ['admin'], - requireCredential: true as const, - requireModerator: true as const, + requireCredential: true, + requireModerator: true, params: { inbox: { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/admin/reset-password.ts b/packages/backend/src/server/api/endpoints/admin/reset-password.ts index 227bcbab9..b6cf1ee2d 100644 --- a/packages/backend/src/server/api/endpoints/admin/reset-password.ts +++ b/packages/backend/src/server/api/endpoints/admin/reset-password.ts @@ -8,7 +8,7 @@ import { Users, UserProfiles } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -18,18 +18,18 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { password: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, minLength: 8, maxLength: 8, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts index a189c3e99..3b47d7d35 100644 --- a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts +++ b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts @@ -6,7 +6,7 @@ import { AbuseUserReports } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -14,7 +14,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/resync-chart.ts b/packages/backend/src/server/api/endpoints/admin/resync-chart.ts index 49d41cd8c..d80d2b042 100644 --- a/packages/backend/src/server/api/endpoints/admin/resync-chart.ts +++ b/packages/backend/src/server/api/endpoints/admin/resync-chart.ts @@ -5,9 +5,9 @@ import { insertModerationLog } from '@/services/insert-moderation-log'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/send-email.ts b/packages/backend/src/server/api/endpoints/admin/send-email.ts index 74ec98f75..c2972c35f 100644 --- a/packages/backend/src/server/api/endpoints/admin/send-email.ts +++ b/packages/backend/src/server/api/endpoints/admin/send-email.ts @@ -5,7 +5,7 @@ import { sendEmail } from '@/services/send-email'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -19,7 +19,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/server-info.ts b/packages/backend/src/server/api/endpoints/admin/server-info.ts index 9346c5dd2..cd282e364 100644 --- a/packages/backend/src/server/api/endpoints/admin/server-info.ts +++ b/packages/backend/src/server/api/endpoints/admin/server-info.ts @@ -5,7 +5,7 @@ import define from '../../define'; import { redisClient } from '../../../../db/redis'; export const meta = { - requireCredential: true as const, + requireCredential: true, requireModerator: true, tags: ['admin', 'meta'], @@ -14,81 +14,81 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { machine: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, os: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, example: 'linux', }, node: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, psql: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, cpu: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { model: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, cores: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, mem: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { total: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, format: 'bytes', }, }, }, fs: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { total: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, format: 'bytes', }, used: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, format: 'bytes', }, }, }, net: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { interface: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, example: 'eth0', }, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts index 0d3759a84..84e2b84bb 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -26,44 +26,44 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'date-time', }, type: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, info: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, }, userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, user: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts index 7ac922ca7..c2a6a294b 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts @@ -6,7 +6,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -16,148 +16,148 @@ export const meta = { }, res: { - type: 'object' as const, - nullable: false as const, optional: false as const, + type: 'object', + nullable: false, optional: false, properties: { id: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, format: 'id', }, createdAt: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, format: 'date-time', }, updatedAt: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, format: 'date-time', }, lastFetchedAt: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, username: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, }, name: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, folowersCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, + type: 'number', + nullable: false, optional: true, }, followingCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, + type: 'number', + nullable: false, optional: false, }, notesCount: { - type: 'number' as const, - nullable: false as const, optional: false as const, + type: 'number', + nullable: false, optional: false, }, avatarId: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, bannerId: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, tags: { - type: 'array' as const, - nullable: false as const, optional: false as const, + type: 'array', + nullable: false, optional: false, items: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, }, }, avatarUrl: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, format: 'url', }, bannerUrl: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, format: 'url', }, avatarBlurhash: { - type: 'any' as const, - nullable: true as const, optional: false as const, + type: 'any', + nullable: true, optional: false, default: null, }, bannerBlurhash: { - type: 'any' as const, - nullable: true as const, optional: false as const, + type: 'any', + nullable: true, optional: false, default: null, }, isSuspended: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, isSilenced: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, isLocked: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, isBot: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, isCat: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, isAdmin: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, isModerator: { - type: 'boolean' as const, - nullable: false as const, optional: false as const, + type: 'boolean', + nullable: false, optional: false, }, emojis: { - type: 'array' as const, - nullable: false as const, optional: false as const, + type: 'array', + nullable: false, optional: false, items: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: false, optional: false, }, }, host: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, inbox: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, sharedInbox: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, featured: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, uri: { - type: 'string' as const, - nullable: true as const, optional: false as const, + type: 'string', + nullable: true, optional: false, }, token: { - type: 'string' as const, - nullable: false as const, optional: false as const, + type: 'string', + nullable: true, optional: false, default: '', }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index 507183e87..d3dde99b7 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -5,7 +5,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -64,15 +64,15 @@ export const meta = { }, res: { - type: 'array' as const, - nullable: false as const, optional: false as const, + type: 'array', + nullable: false, optional: false, items: { - type: 'object' as const, - nullable: false as const, optional: false as const, - ref: 'User', + type: 'object', + nullable: false, optional: false, + ref: 'UserDetailed', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/silence-user.ts b/packages/backend/src/server/api/endpoints/admin/silence-user.ts index b4a1ddcc0..872bd2a6a 100644 --- a/packages/backend/src/server/api/endpoints/admin/silence-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/silence-user.ts @@ -7,7 +7,7 @@ import { insertModerationLog } from '@/services/insert-moderation-log'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -15,7 +15,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts index 95771e0c3..2bb1875fc 100644 --- a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts @@ -11,7 +11,7 @@ import { publishUserEvent } from '@/services/stream'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -19,7 +19,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts index e04960a4e..a4c6ff2ad 100644 --- a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts @@ -7,7 +7,7 @@ import { insertModerationLog } from '@/services/insert-moderation-log'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -15,7 +15,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts index 0a6ceadab..5ab56d51c 100644 --- a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts @@ -8,7 +8,7 @@ import { doPostUnsuspend } from '@/services/unsuspend-user'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -16,7 +16,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 0d5455cd3..aa2d1222f 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -9,7 +9,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireAdmin: true, params: { @@ -297,7 +297,7 @@ export const meta = { validator: $.optional.bool, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/admin/vacuum.ts b/packages/backend/src/server/api/endpoints/admin/vacuum.ts index 798a51acc..4229ef0d2 100644 --- a/packages/backend/src/server/api/endpoints/admin/vacuum.ts +++ b/packages/backend/src/server/api/endpoints/admin/vacuum.ts @@ -6,7 +6,7 @@ import { insertModerationLog } from '@/services/insert-moderation-log'; export const meta = { tags: ['admin'], - requireCredential: true as const, + requireCredential: true, requireModerator: true, params: { @@ -17,7 +17,7 @@ export const meta = { validator: $.bool, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/announcements.ts b/packages/backend/src/server/api/endpoints/announcements.ts index 122d04f17..0bd29607d 100644 --- a/packages/backend/src/server/api/endpoints/announcements.ts +++ b/packages/backend/src/server/api/endpoints/announcements.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../common/make-pagination-query'; export const meta = { tags: ['meta'], - requireCredential: false as const, + requireCredential: false, params: { limit: { @@ -30,48 +30,48 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', example: 'xxxxxxxxxx', }, createdAt: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'date-time', }, updatedAt: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, format: 'date-time', }, text: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, title: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, imageUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, isRead: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index b3276bd9c..2092d177b 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -9,7 +9,7 @@ import { publishInternalEvent } from '@/services/stream'; export const meta = { tags: ['antennas'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -74,11 +74,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Antenna', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/antennas/delete.ts b/packages/backend/src/server/api/endpoints/antennas/delete.ts index c6da54540..b2793fc70 100644 --- a/packages/backend/src/server/api/endpoints/antennas/delete.ts +++ b/packages/backend/src/server/api/endpoints/antennas/delete.ts @@ -8,7 +8,7 @@ import { publishInternalEvent } from '@/services/stream'; export const meta = { tags: ['antennas'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -25,7 +25,7 @@ export const meta = { id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/antennas/list.ts b/packages/backend/src/server/api/endpoints/antennas/list.ts index 1f24e0fb9..bb5891261 100644 --- a/packages/backend/src/server/api/endpoints/antennas/list.ts +++ b/packages/backend/src/server/api/endpoints/antennas/list.ts @@ -4,20 +4,20 @@ import { Antennas } from '@/models/index'; export const meta = { tags: ['antennas', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Antenna', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts index 09500a38d..eb7de901c 100644 --- a/packages/backend/src/server/api/endpoints/antennas/notes.ts +++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts @@ -12,7 +12,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['antennas', 'account', 'notes'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', @@ -52,15 +52,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/antennas/show.ts b/packages/backend/src/server/api/endpoints/antennas/show.ts index a02c44ac2..a37d37d31 100644 --- a/packages/backend/src/server/api/endpoints/antennas/show.ts +++ b/packages/backend/src/server/api/endpoints/antennas/show.ts @@ -7,7 +7,7 @@ import { Antennas } from '@/models/index'; export const meta = { tags: ['antennas', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', @@ -26,11 +26,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Antenna', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 968f761a3..900f72550 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -8,7 +8,7 @@ import { publishInternalEvent } from '@/services/stream'; export const meta = { tags: ['antennas'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -83,11 +83,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Antenna', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/ap/get.ts b/packages/backend/src/server/api/endpoints/ap/get.ts index 0acce9bdb..ff8c677b9 100644 --- a/packages/backend/src/server/api/endpoints/ap/get.ts +++ b/packages/backend/src/server/api/endpoints/ap/get.ts @@ -7,7 +7,7 @@ import ms from 'ms'; export const meta = { tags: ['federation'], - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), @@ -24,10 +24,10 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index e4e13117e..7d17d8edc 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -12,11 +12,12 @@ import { User } from '@/models/entities/user'; import { fetchMeta } from '@/misc/fetch-meta'; import { isActor, isPost, getApId } from '@/remote/activitypub/type'; import ms from 'ms'; +import { SchemaType } from '@/misc/schema'; export const meta = { tags: ['federation'], - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), @@ -38,21 +39,41 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - type: { - type: 'string' as const, - optional: false as const, nullable: false as const, - enum: ['User', 'Note'], + optional: false, nullable: false, + oneOf: [ + { + type: 'object', + properties: { + type: { + type: 'string', + optional: false, nullable: false, + enum: ['User'], + }, + object: { + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailedNotMe', + } + } }, - object: { - type: 'object' as const, - optional: false as const, nullable: false as const, - }, - }, + { + type: 'object', + properties: { + type: { + type: 'string', + optional: false, nullable: false, + enum: ['Note'], + }, + object: { + type: 'object', + optional: false, nullable: false, + ref: 'Note', + } + } + } + ], }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { @@ -67,7 +88,7 @@ export default define(meta, async (ps) => { /*** * URIからUserかNoteを解決する */ -async function fetchAny(uri: string) { +async function fetchAny(uri: string): Promise | null> { // URIがこのサーバーを指しているなら、ローカルユーザーIDとしてDBからフェッチ if (uri.startsWith(config.url + '/')) { const parts = uri.split('/'); @@ -96,8 +117,8 @@ async function fetchAny(uri: string) { } // ブロックしてたら中断 - const meta = await fetchMeta(); - if (meta.blockedHosts.includes(extractDbHost(uri))) return null; + const fetchedMeta = await fetchMeta(); + if (fetchedMeta.blockedHosts.includes(extractDbHost(uri))) return null; // URI(AP Object id)としてDB検索 { @@ -172,7 +193,7 @@ async function fetchAny(uri: string) { return null; } -async function mergePack(user: User | null | undefined, note: Note | null | undefined) { +async function mergePack(user: User | null | undefined, note: Note | null | undefined): Promise | null> { if (user != null) { return { type: 'User', diff --git a/packages/backend/src/server/api/endpoints/app/create.ts b/packages/backend/src/server/api/endpoints/app/create.ts index 88e5d866c..838cbf606 100644 --- a/packages/backend/src/server/api/endpoints/app/create.ts +++ b/packages/backend/src/server/api/endpoints/app/create.ts @@ -8,7 +8,7 @@ import { secureRndstr } from '@/misc/secure-rndstr'; export const meta = { tags: ['app'], - requireCredential: false as const, + requireCredential: false, params: { name: { @@ -31,11 +31,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'App', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/app/show.ts b/packages/backend/src/server/api/endpoints/app/show.ts index 701a23b22..9f4777b38 100644 --- a/packages/backend/src/server/api/endpoints/app/show.ts +++ b/packages/backend/src/server/api/endpoints/app/show.ts @@ -13,12 +13,6 @@ export const meta = { }, }, - res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'App', - }, - errors: { noSuchApp: { message: 'No such app.', @@ -28,11 +22,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'App', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user, token) => { diff --git a/packages/backend/src/server/api/endpoints/auth/accept.ts b/packages/backend/src/server/api/endpoints/auth/accept.ts index 6b2b0bc70..f028135ca 100644 --- a/packages/backend/src/server/api/endpoints/auth/accept.ts +++ b/packages/backend/src/server/api/endpoints/auth/accept.ts @@ -9,7 +9,7 @@ import { secureRndstr } from '@/misc/secure-rndstr'; export const meta = { tags: ['auth'], - requireCredential: true as const, + requireCredential: true, secure: true, @@ -26,7 +26,7 @@ export const meta = { id: '9c72d8de-391a-43c1-9d06-08d29efde8df', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/auth/session/generate.ts b/packages/backend/src/server/api/endpoints/auth/session/generate.ts index b9e5e84f6..98987eba5 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/generate.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/generate.ts @@ -9,7 +9,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['auth'], - requireCredential: false as const, + requireCredential: false, params: { appSecret: { @@ -18,16 +18,16 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { token: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, url: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', }, }, @@ -40,7 +40,7 @@ export const meta = { id: '92f93e63-428e-4f2f-a5a4-39e1407fe998', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/auth/session/show.ts b/packages/backend/src/server/api/endpoints/auth/session/show.ts index 3a32b5e54..ae0d016ce 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/show.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/show.ts @@ -6,7 +6,7 @@ import { AuthSessions } from '@/models/index'; export const meta = { tags: ['auth'], - requireCredential: false as const, + requireCredential: false, params: { token: { @@ -23,26 +23,26 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, app: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'App', }, token: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts index 131cdf3df..fe0211ebe 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts @@ -6,7 +6,7 @@ import { Apps, AuthSessions, AccessTokens, Users } from '@/models/index'; export const meta = { tags: ['auth'], - requireCredential: false as const, + requireCredential: false, params: { appSecret: { @@ -19,18 +19,18 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { accessToken: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, user: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailedNotMe', }, }, }, @@ -54,7 +54,7 @@ export const meta = { id: '8c8a4145-02cc-4cca-8e66-29ba60445a8e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/blocking/create.ts b/packages/backend/src/server/api/endpoints/blocking/create.ts index f718bcd20..6d555ff56 100644 --- a/packages/backend/src/server/api/endpoints/blocking/create.ts +++ b/packages/backend/src/server/api/endpoints/blocking/create.ts @@ -15,7 +15,7 @@ export const meta = { max: 100, }, - requireCredential: true as const, + requireCredential: true, kind: 'write:blocks', @@ -46,11 +46,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailedNotMe', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/blocking/delete.ts b/packages/backend/src/server/api/endpoints/blocking/delete.ts index e56311741..942cddaed 100644 --- a/packages/backend/src/server/api/endpoints/blocking/delete.ts +++ b/packages/backend/src/server/api/endpoints/blocking/delete.ts @@ -15,7 +15,7 @@ export const meta = { max: 100, }, - requireCredential: true as const, + requireCredential: true, kind: 'write:blocks', @@ -46,11 +46,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailedNotMe', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/blocking/list.ts b/packages/backend/src/server/api/endpoints/blocking/list.ts index f1f4b1699..9a4f66214 100644 --- a/packages/backend/src/server/api/endpoints/blocking/list.ts +++ b/packages/backend/src/server/api/endpoints/blocking/list.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:blocks', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Blocking', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/channels/create.ts b/packages/backend/src/server/api/endpoints/channels/create.ts index 9c88231dd..48be728d9 100644 --- a/packages/backend/src/server/api/endpoints/channels/create.ts +++ b/packages/backend/src/server/api/endpoints/channels/create.ts @@ -9,7 +9,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['channels'], - requireCredential: true as const, + requireCredential: true, kind: 'write:channels', @@ -28,8 +28,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Channel', }, @@ -40,7 +40,7 @@ export const meta = { id: 'cd1e9f3e-5a12-4ab4-96f6-5d0a2cc32050', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/channels/featured.ts b/packages/backend/src/server/api/endpoints/channels/featured.ts index cec14cda1..ceadde907 100644 --- a/packages/backend/src/server/api/endpoints/channels/featured.ts +++ b/packages/backend/src/server/api/endpoints/channels/featured.ts @@ -4,18 +4,18 @@ import { Channels } from '@/models/index'; export const meta = { tags: ['channels'], - requireCredential: false as const, + requireCredential: false, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Channel', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/channels/follow.ts b/packages/backend/src/server/api/endpoints/channels/follow.ts index 3f4904f71..bf580eea6 100644 --- a/packages/backend/src/server/api/endpoints/channels/follow.ts +++ b/packages/backend/src/server/api/endpoints/channels/follow.ts @@ -9,7 +9,7 @@ import { publishUserEvent } from '@/services/stream'; export const meta = { tags: ['channels'], - requireCredential: true as const, + requireCredential: true, kind: 'write:channels', @@ -26,7 +26,7 @@ export const meta = { id: 'c0031718-d573-4e85-928e-10039f1fbb68', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/channels/followed.ts b/packages/backend/src/server/api/endpoints/channels/followed.ts index 82ae1a3af..9e4c942af 100644 --- a/packages/backend/src/server/api/endpoints/channels/followed.ts +++ b/packages/backend/src/server/api/endpoints/channels/followed.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['channels', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:channels', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Channel', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/channels/owned.ts b/packages/backend/src/server/api/endpoints/channels/owned.ts index 128ea4115..5473636a8 100644 --- a/packages/backend/src/server/api/endpoints/channels/owned.ts +++ b/packages/backend/src/server/api/endpoints/channels/owned.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['channels', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:channels', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Channel', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/channels/show.ts b/packages/backend/src/server/api/endpoints/channels/show.ts index 28cb92764..598a87ec4 100644 --- a/packages/backend/src/server/api/endpoints/channels/show.ts +++ b/packages/backend/src/server/api/endpoints/channels/show.ts @@ -7,7 +7,7 @@ import { Channels } from '@/models/index'; export const meta = { tags: ['channels'], - requireCredential: false as const, + requireCredential: false, params: { channelId: { @@ -16,8 +16,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Channel', }, @@ -28,7 +28,7 @@ export const meta = { id: '6f6c314b-7486-4897-8966-c04a66a02923', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts index ec60e5f23..927ce7c74 100644 --- a/packages/backend/src/server/api/endpoints/channels/timeline.ts +++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts @@ -9,7 +9,7 @@ import { activeUsersChart } from '@/services/chart/index'; export const meta = { tags: ['notes', 'channels'], - requireCredential: false as const, + requireCredential: false, params: { channelId: { @@ -39,11 +39,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -55,7 +55,7 @@ export const meta = { id: '4d0eeeba-a02c-4c3c-9966-ef60d38d2e7f', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/channels/unfollow.ts b/packages/backend/src/server/api/endpoints/channels/unfollow.ts index 1472aa045..ada0cb29f 100644 --- a/packages/backend/src/server/api/endpoints/channels/unfollow.ts +++ b/packages/backend/src/server/api/endpoints/channels/unfollow.ts @@ -8,7 +8,7 @@ import { publishUserEvent } from '@/services/stream'; export const meta = { tags: ['channels'], - requireCredential: true as const, + requireCredential: true, kind: 'write:channels', @@ -25,7 +25,7 @@ export const meta = { id: '19959ee9-0153-4c51-bbd9-a98c49dc59d6', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/channels/update.ts b/packages/backend/src/server/api/endpoints/channels/update.ts index fee79df2f..1f7108a1c 100644 --- a/packages/backend/src/server/api/endpoints/channels/update.ts +++ b/packages/backend/src/server/api/endpoints/channels/update.ts @@ -7,7 +7,7 @@ import { Channels, DriveFiles } from '@/models/index'; export const meta = { tags: ['channels'], - requireCredential: true as const, + requireCredential: true, kind: 'write:channels', @@ -30,8 +30,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Channel', }, @@ -54,7 +54,7 @@ export const meta = { id: 'e86c14a4-0da2-4032-8df3-e737a04c7f3b', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/charts/active-users.ts b/packages/backend/src/server/api/endpoints/charts/active-users.ts index ac77f8f1d..f7eadc708 100644 --- a/packages/backend/src/server/api/endpoints/charts/active-users.ts +++ b/packages/backend/src/server/api/endpoints/charts/active-users.ts @@ -23,7 +23,7 @@ export const meta = { }, res: convertLog(activeUsersChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/drive.ts b/packages/backend/src/server/api/endpoints/charts/drive.ts index 7f15467e7..364279da9 100644 --- a/packages/backend/src/server/api/endpoints/charts/drive.ts +++ b/packages/backend/src/server/api/endpoints/charts/drive.ts @@ -23,7 +23,7 @@ export const meta = { }, res: convertLog(driveChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/federation.ts b/packages/backend/src/server/api/endpoints/charts/federation.ts index 677c28c1e..6feb82b6d 100644 --- a/packages/backend/src/server/api/endpoints/charts/federation.ts +++ b/packages/backend/src/server/api/endpoints/charts/federation.ts @@ -23,7 +23,7 @@ export const meta = { }, res: convertLog(federationChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/hashtag.ts b/packages/backend/src/server/api/endpoints/charts/hashtag.ts index aa41bcf90..99dc77998 100644 --- a/packages/backend/src/server/api/endpoints/charts/hashtag.ts +++ b/packages/backend/src/server/api/endpoints/charts/hashtag.ts @@ -27,7 +27,7 @@ export const meta = { }, res: convertLog(hashtagChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/instance.ts b/packages/backend/src/server/api/endpoints/charts/instance.ts index 2ac415464..23e6fbf2b 100644 --- a/packages/backend/src/server/api/endpoints/charts/instance.ts +++ b/packages/backend/src/server/api/endpoints/charts/instance.ts @@ -27,7 +27,7 @@ export const meta = { }, res: convertLog(instanceChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/network.ts b/packages/backend/src/server/api/endpoints/charts/network.ts index 4056becad..c5a39bbd7 100644 --- a/packages/backend/src/server/api/endpoints/charts/network.ts +++ b/packages/backend/src/server/api/endpoints/charts/network.ts @@ -23,7 +23,7 @@ export const meta = { }, res: convertLog(networkChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/notes.ts b/packages/backend/src/server/api/endpoints/charts/notes.ts index 00d6e0aa6..dcbd80c3e 100644 --- a/packages/backend/src/server/api/endpoints/charts/notes.ts +++ b/packages/backend/src/server/api/endpoints/charts/notes.ts @@ -23,7 +23,7 @@ export const meta = { }, res: convertLog(notesChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/user/drive.ts b/packages/backend/src/server/api/endpoints/charts/user/drive.ts index 462fb5879..94787b4a5 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/drive.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/drive.ts @@ -28,7 +28,7 @@ export const meta = { }, res: convertLog(perUserDriveChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/user/following.ts b/packages/backend/src/server/api/endpoints/charts/user/following.ts index 3aee237d8..effe0c54b 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/following.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/following.ts @@ -28,7 +28,7 @@ export const meta = { }, res: convertLog(perUserFollowingChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/user/notes.ts b/packages/backend/src/server/api/endpoints/charts/user/notes.ts index 3536e7b77..df68a5fe5 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/notes.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/notes.ts @@ -28,7 +28,7 @@ export const meta = { }, res: convertLog(perUserNotesChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/user/reactions.ts b/packages/backend/src/server/api/endpoints/charts/user/reactions.ts index 9c5515f0b..dcd067305 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/reactions.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/reactions.ts @@ -28,7 +28,7 @@ export const meta = { }, res: convertLog(perUserReactionsChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/charts/users.ts b/packages/backend/src/server/api/endpoints/charts/users.ts index d8bbb8300..d32e14ad6 100644 --- a/packages/backend/src/server/api/endpoints/charts/users.ts +++ b/packages/backend/src/server/api/endpoints/charts/users.ts @@ -23,7 +23,7 @@ export const meta = { }, res: convertLog(usersChart.schema), -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/clips/add-note.ts b/packages/backend/src/server/api/endpoints/clips/add-note.ts index 992ba0edd..4a740b6cf 100644 --- a/packages/backend/src/server/api/endpoints/clips/add-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/add-note.ts @@ -9,7 +9,7 @@ import { getNote } from '../../common/getters'; export const meta = { tags: ['account', 'notes', 'clips'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -42,7 +42,7 @@ export const meta = { id: '734806c4-542c-463a-9311-15c512803965', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/clips/create.ts b/packages/backend/src/server/api/endpoints/clips/create.ts index e9900247a..852e66c9e 100644 --- a/packages/backend/src/server/api/endpoints/clips/create.ts +++ b/packages/backend/src/server/api/endpoints/clips/create.ts @@ -6,7 +6,7 @@ import { Clips } from '@/models/index'; export const meta = { tags: ['clips'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -25,11 +25,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Clip', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/clips/delete.ts b/packages/backend/src/server/api/endpoints/clips/delete.ts index b7d16322d..85c64a115 100644 --- a/packages/backend/src/server/api/endpoints/clips/delete.ts +++ b/packages/backend/src/server/api/endpoints/clips/delete.ts @@ -7,7 +7,7 @@ import { Clips } from '@/models/index'; export const meta = { tags: ['clips'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -24,7 +24,7 @@ export const meta = { id: '70ca08ba-6865-4630-b6fb-8494759aa754', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/clips/list.ts b/packages/backend/src/server/api/endpoints/clips/list.ts index 8388438bd..d88897d16 100644 --- a/packages/backend/src/server/api/endpoints/clips/list.ts +++ b/packages/backend/src/server/api/endpoints/clips/list.ts @@ -4,20 +4,20 @@ import { Clips } from '@/models/index'; export const meta = { tags: ['clips', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Clip', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/clips/notes.ts b/packages/backend/src/server/api/endpoints/clips/notes.ts index c8871cd3f..eeb20631c 100644 --- a/packages/backend/src/server/api/endpoints/clips/notes.ts +++ b/packages/backend/src/server/api/endpoints/clips/notes.ts @@ -11,7 +11,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['account', 'notes', 'clips'], - requireCredential: false as const, + requireCredential: false, kind: 'read:account', @@ -43,15 +43,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/clips/show.ts b/packages/backend/src/server/api/endpoints/clips/show.ts index ce65abd65..0a4567201 100644 --- a/packages/backend/src/server/api/endpoints/clips/show.ts +++ b/packages/backend/src/server/api/endpoints/clips/show.ts @@ -7,7 +7,7 @@ import { Clips } from '@/models/index'; export const meta = { tags: ['clips', 'account'], - requireCredential: false as const, + requireCredential: false, kind: 'read:account', @@ -26,11 +26,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Clip', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/clips/update.ts b/packages/backend/src/server/api/endpoints/clips/update.ts index 44e8fe33e..795483d5b 100644 --- a/packages/backend/src/server/api/endpoints/clips/update.ts +++ b/packages/backend/src/server/api/endpoints/clips/update.ts @@ -7,7 +7,7 @@ import { Clips } from '@/models/index'; export const meta = { tags: ['clips'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -38,11 +38,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Clip', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive.ts b/packages/backend/src/server/api/endpoints/drive.ts index 35ac98bdf..d9ab9883c 100644 --- a/packages/backend/src/server/api/endpoints/drive.ts +++ b/packages/backend/src/server/api/endpoints/drive.ts @@ -5,25 +5,25 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['drive', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { capacity: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, usage: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files.ts b/packages/backend/src/server/api/endpoints/drive/files.ts index 7a577bce6..a5c0a626a 100644 --- a/packages/backend/src/server/api/endpoints/drive/files.ts +++ b/packages/backend/src/server/api/endpoints/drive/files.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -36,15 +36,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts index a02ac3eef..835dde805 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts @@ -7,7 +7,7 @@ import { DriveFiles, Notes } from '@/models/index'; export const meta = { tags: ['drive', 'notes'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -18,11 +18,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -34,7 +34,7 @@ export const meta = { id: 'c118ece3-2e4b-4296-99d1-51756e32d232', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts b/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts index 14517ab4b..a45d357ee 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts @@ -5,7 +5,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -16,10 +16,10 @@ export const meta = { }, res: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index 640b62c6e..f598f18ed 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -10,7 +10,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), @@ -46,8 +46,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, @@ -58,7 +58,7 @@ export const meta = { id: 'f449b209-0c60-4e51-84d5-29486263bfd4', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user, _, file, cleanup) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/delete.ts b/packages/backend/src/server/api/endpoints/drive/files/delete.ts index 2e32e6879..308beb58a 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/delete.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/delete.ts @@ -9,7 +9,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'write:drive', @@ -32,7 +32,7 @@ export const meta = { id: '5eb8d909-2540-4970-90b8-dd6f86088121', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts b/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts index 5617769a9..dc74dcb7e 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts @@ -5,7 +5,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -16,15 +16,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/find.ts b/packages/backend/src/server/api/endpoints/drive/files/find.ts index 415ab7961..2244df13c 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/find.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/find.ts @@ -4,7 +4,7 @@ import define from '../../../define'; import { DriveFiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, tags: ['drive'], @@ -22,15 +22,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/show.ts b/packages/backend/src/server/api/endpoints/drive/files/show.ts index 4a8830e9c..18b17c465 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/show.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/show.ts @@ -8,7 +8,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -23,8 +23,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, @@ -47,7 +47,7 @@ export const meta = { id: '89674805-722c-440c-8d88-5641830dc3e4', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/update.ts b/packages/backend/src/server/api/endpoints/drive/files/update.ts index 329e959c5..b7ca80e83 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/update.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/update.ts @@ -9,7 +9,7 @@ import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'write:drive', @@ -60,11 +60,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts index 7e3ffd881..6ab1ca137 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts @@ -15,7 +15,7 @@ export const meta = { max: 60, }, - requireCredential: true as const, + requireCredential: true, kind: 'write:drive', @@ -50,7 +50,7 @@ export const meta = { default: false, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/folders.ts b/packages/backend/src/server/api/endpoints/drive/folders.ts index 85938e7b5..8f8d1d2c0 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -32,15 +32,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFolder', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/folders/create.ts b/packages/backend/src/server/api/endpoints/drive/folders/create.ts index 401b59152..38ed17e0e 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/create.ts @@ -9,7 +9,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'write:drive', @@ -37,7 +37,7 @@ export const meta = { optional: false as const, nullable: false as const, ref: 'DriveFolder', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/folders/delete.ts b/packages/backend/src/server/api/endpoints/drive/folders/delete.ts index 2360a3abf..13716fcce 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/delete.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/delete.ts @@ -8,7 +8,7 @@ import { DriveFolders, DriveFiles } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'write:drive', @@ -31,7 +31,7 @@ export const meta = { id: 'b0fc8a17-963c-405d-bfbc-859a487295e1', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/folders/find.ts b/packages/backend/src/server/api/endpoints/drive/folders/find.ts index 47e45a23f..911f51d78 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/find.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/find.ts @@ -6,7 +6,7 @@ import { DriveFolders } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -22,15 +22,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFolder', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/folders/show.ts b/packages/backend/src/server/api/endpoints/drive/folders/show.ts index d6eac59fe..58a6dd3c0 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/show.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/show.ts @@ -7,7 +7,7 @@ import { DriveFolders } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -18,8 +18,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFolder', }, @@ -30,7 +30,7 @@ export const meta = { id: 'd74ab9eb-bb09-4bba-bf24-fb58f761e1e9', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/folders/update.ts b/packages/backend/src/server/api/endpoints/drive/folders/update.ts index 5ae5424fb..5b0cccd1c 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/update.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/update.ts @@ -8,7 +8,7 @@ import { DriveFolders } from '@/models/index'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'write:drive', @@ -47,11 +47,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFolder', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/drive/stream.ts b/packages/backend/src/server/api/endpoints/drive/stream.ts index 675e3225f..9ba780494 100644 --- a/packages/backend/src/server/api/endpoints/drive/stream.ts +++ b/packages/backend/src/server/api/endpoints/drive/stream.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['drive'], - requireCredential: true as const, + requireCredential: true, kind: 'read:drive', @@ -31,15 +31,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'DriveFile', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/email-address/available.ts b/packages/backend/src/server/api/endpoints/email-address/available.ts index 5e8f1706f..19f9b7ccd 100644 --- a/packages/backend/src/server/api/endpoints/email-address/available.ts +++ b/packages/backend/src/server/api/endpoints/email-address/available.ts @@ -5,7 +5,7 @@ import { validateEmailForAccount } from '@/services/validate-email-for-account'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { emailAddress: { @@ -14,20 +14,20 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { available: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, reason: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/endpoint.ts b/packages/backend/src/server/api/endpoints/endpoint.ts index 597911da8..42fd46883 100644 --- a/packages/backend/src/server/api/endpoints/endpoint.ts +++ b/packages/backend/src/server/api/endpoints/endpoint.ts @@ -3,7 +3,7 @@ import define from '../define'; import endpoints from '../endpoints'; export const meta = { - requireCredential: false as const, + requireCredential: false, tags: ['meta'], @@ -12,7 +12,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/endpoints.ts b/packages/backend/src/server/api/endpoints/endpoints.ts index 4e304dbeb..ebb78de33 100644 --- a/packages/backend/src/server/api/endpoints/endpoints.ts +++ b/packages/backend/src/server/api/endpoints/endpoints.ts @@ -2,7 +2,7 @@ import define from '../define'; import endpoints from '../endpoints'; export const meta = { - requireCredential: false as const, + requireCredential: false, tags: ['meta'], @@ -10,11 +10,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, example: [ 'admin/abuse-user-reports', @@ -23,7 +23,7 @@ export const meta = { '...', ], }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts index 8b7e8a049..24c9f56aa 100644 --- a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts +++ b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts @@ -5,12 +5,12 @@ import ms from 'ms'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), max: 1, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/federation/followers.ts b/packages/backend/src/server/api/endpoints/federation/followers.ts index a44b0aecf..c0a85f166 100644 --- a/packages/backend/src/server/api/endpoints/federation/followers.ts +++ b/packages/backend/src/server/api/endpoints/federation/followers.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['federation'], - requireCredential: false as const, + requireCredential: false, params: { host: { @@ -29,15 +29,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Following', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/federation/following.ts b/packages/backend/src/server/api/endpoints/federation/following.ts index c10e25864..147f0aedb 100644 --- a/packages/backend/src/server/api/endpoints/federation/following.ts +++ b/packages/backend/src/server/api/endpoints/federation/following.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['federation'], - requireCredential: false as const, + requireCredential: false, params: { host: { @@ -29,15 +29,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Following', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index e73d0e5ad..11df7ed6b 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -7,7 +7,7 @@ import { fetchMeta } from '@/misc/fetch-meta'; export const meta = { tags: ['federation'], - requireCredential: false as const, + requireCredential: false, params: { host: { @@ -54,15 +54,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'FederationInstance', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/federation/show-instance.ts b/packages/backend/src/server/api/endpoints/federation/show-instance.ts index 15b4f3151..6f13b28ca 100644 --- a/packages/backend/src/server/api/endpoints/federation/show-instance.ts +++ b/packages/backend/src/server/api/endpoints/federation/show-instance.ts @@ -6,7 +6,7 @@ import { toPuny } from '@/misc/convert-host'; export const meta = { tags: ['federation'], - requireCredential: false as const, + requireCredential: false, params: { host: { @@ -15,11 +15,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: true, nullable: false, ref: 'FederationInstance', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts b/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts index 371859345..092f805bc 100644 --- a/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts +++ b/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts @@ -7,14 +7,14 @@ import { updatePerson } from '@/remote/activitypub/models/person'; export const meta = { tags: ['federation'], - requireCredential: true as const, + requireCredential: true, params: { userId: { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/federation/users.ts b/packages/backend/src/server/api/endpoints/federation/users.ts index 8372169d6..9a8f74993 100644 --- a/packages/backend/src/server/api/endpoints/federation/users.ts +++ b/packages/backend/src/server/api/endpoints/federation/users.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['federation'], - requireCredential: false as const, + requireCredential: false, params: { host: { @@ -29,15 +29,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailedNotMe', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/following/create.ts b/packages/backend/src/server/api/endpoints/following/create.ts index 951cf8fa2..96aede455 100644 --- a/packages/backend/src/server/api/endpoints/following/create.ts +++ b/packages/backend/src/server/api/endpoints/following/create.ts @@ -15,7 +15,7 @@ export const meta = { max: 100, }, - requireCredential: true as const, + requireCredential: true, kind: 'write:following', @@ -58,11 +58,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/following/delete.ts b/packages/backend/src/server/api/endpoints/following/delete.ts index de43fa438..4cd0c4945 100644 --- a/packages/backend/src/server/api/endpoints/following/delete.ts +++ b/packages/backend/src/server/api/endpoints/following/delete.ts @@ -15,7 +15,7 @@ export const meta = { max: 100, }, - requireCredential: true as const, + requireCredential: true, kind: 'write:following', @@ -46,11 +46,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/following/invalidate.ts b/packages/backend/src/server/api/endpoints/following/invalidate.ts index 388ddda79..92e887e00 100644 --- a/packages/backend/src/server/api/endpoints/following/invalidate.ts +++ b/packages/backend/src/server/api/endpoints/following/invalidate.ts @@ -15,7 +15,7 @@ export const meta = { max: 100, }, - requireCredential: true as const, + requireCredential: true, kind: 'write:following', @@ -46,11 +46,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/following/requests/accept.ts b/packages/backend/src/server/api/endpoints/following/requests/accept.ts index 29f0ace2a..7e7c056f5 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/accept.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/accept.ts @@ -8,7 +8,7 @@ import { getUser } from '../../../common/getters'; export const meta = { tags: ['following', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:following', @@ -30,7 +30,7 @@ export const meta = { id: 'bcde4f8b-0913-4614-8881-614e522fb041', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/following/requests/cancel.ts b/packages/backend/src/server/api/endpoints/following/requests/cancel.ts index d5281c468..19ed02c15 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/cancel.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/cancel.ts @@ -9,7 +9,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['following', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:following', @@ -34,11 +34,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/following/requests/list.ts b/packages/backend/src/server/api/endpoints/following/requests/list.ts index bfd793faf..ec0c76502 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/list.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/list.ts @@ -4,36 +4,36 @@ import { FollowRequests } from '@/models/index'; export const meta = { tags: ['following', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:following', res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, follower: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', }, followee: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserLite', }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/following/requests/reject.ts b/packages/backend/src/server/api/endpoints/following/requests/reject.ts index 77a14af1f..a5ce1e7c7 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/reject.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/reject.ts @@ -8,7 +8,7 @@ import { getUser } from '../../../common/getters'; export const meta = { tags: ['following', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:following', @@ -25,7 +25,7 @@ export const meta = { id: 'abc2ffa6-25b2-4380-ba99-321ff3a94555', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/featured.ts b/packages/backend/src/server/api/endpoints/gallery/featured.ts index a6ca95692..ff7c16889 100644 --- a/packages/backend/src/server/api/endpoints/gallery/featured.ts +++ b/packages/backend/src/server/api/endpoints/gallery/featured.ts @@ -4,18 +4,18 @@ import { GalleryPosts } from '@/models/index'; export const meta = { tags: ['gallery'], - requireCredential: false as const, + requireCredential: false, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/popular.ts b/packages/backend/src/server/api/endpoints/gallery/popular.ts index efd1f7605..2c3368a19 100644 --- a/packages/backend/src/server/api/endpoints/gallery/popular.ts +++ b/packages/backend/src/server/api/endpoints/gallery/popular.ts @@ -4,18 +4,18 @@ import { GalleryPosts } from '@/models/index'; export const meta = { tags: ['gallery'], - requireCredential: false as const, + requireCredential: false, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts.ts b/packages/backend/src/server/api/endpoints/gallery/posts.ts index 1b1368b06..9d2601c7e 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts.ts @@ -23,15 +23,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts index 1a75ba2cb..e9d5df1ab 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts @@ -11,7 +11,7 @@ import { DriveFile } from '@/models/entities/drive-file'; export const meta = { tags: ['gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'write:gallery', @@ -40,15 +40,15 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts index dbf7b2f9c..2a13b9ed5 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts @@ -7,7 +7,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'write:gallery', @@ -24,7 +24,7 @@ export const meta = { id: 'ae52f367-4bd7-4ecd-afc6-5672fff427f5', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts index 2f98f41fa..0fb408fa5 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts @@ -8,7 +8,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'write:gallery-likes', @@ -37,7 +37,7 @@ export const meta = { id: '40e9ed56-a59c-473a-bf3f-f289c54fb5a7', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/show.ts b/packages/backend/src/server/api/endpoints/gallery/posts/show.ts index 7044f948f..4325d2ad3 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/show.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/show.ts @@ -7,7 +7,7 @@ import { GalleryPosts } from '@/models/index'; export const meta = { tags: ['gallery'], - requireCredential: false as const, + requireCredential: false, params: { postId: { @@ -24,11 +24,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts index 8cf4f3425..9cca09bdd 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts @@ -7,7 +7,7 @@ import { GalleryPosts, GalleryLikes } from '@/models/index'; export const meta = { tags: ['gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'write:gallery-likes', @@ -30,7 +30,7 @@ export const meta = { id: 'e3e8e06e-be37-41f7-a5b4-87a8250288f0', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts index 67028125d..c35e1bbf5 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts @@ -10,7 +10,7 @@ import { DriveFile } from '@/models/entities/drive-file'; export const meta = { tags: ['gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'write:gallery', @@ -43,15 +43,15 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/get-online-users-count.ts b/packages/backend/src/server/api/endpoints/get-online-users-count.ts index b429eacef..5b13d5a3b 100644 --- a/packages/backend/src/server/api/endpoints/get-online-users-count.ts +++ b/packages/backend/src/server/api/endpoints/get-online-users-count.ts @@ -6,11 +6,11 @@ import define from '../define'; export const meta = { tags: ['meta'], - requireCredential: false as const, + requireCredential: false, params: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/hashtags/list.ts b/packages/backend/src/server/api/endpoints/hashtags/list.ts index 3900fdcc4..9fa9b3edc 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/list.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/list.ts @@ -5,7 +5,7 @@ import { Hashtags } from '@/models/index'; export const meta = { tags: ['hashtags'], - requireCredential: false as const, + requireCredential: false, params: { limit: { @@ -47,15 +47,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Hashtag', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/hashtags/search.ts b/packages/backend/src/server/api/endpoints/hashtags/search.ts index 8642bb39f..0d646c64f 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/search.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/search.ts @@ -5,7 +5,7 @@ import { Hashtags } from '@/models/index'; export const meta = { tags: ['hashtags'], - requireCredential: false as const, + requireCredential: false, params: { limit: { @@ -24,14 +24,14 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/hashtags/show.ts b/packages/backend/src/server/api/endpoints/hashtags/show.ts index 454b98e5a..242cef99d 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/show.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/show.ts @@ -7,7 +7,7 @@ import { normalizeForSearch } from '@/misc/normalize-for-search'; export const meta = { tags: ['hashtags'], - requireCredential: false as const, + requireCredential: false, params: { tag: { @@ -16,8 +16,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Hashtag', }, @@ -28,7 +28,7 @@ export const meta = { id: '110ee688-193e-4a3a-9ecf-c167b2e6981e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts index e02666a88..be964ad63 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts @@ -23,35 +23,35 @@ const max = 5; export const meta = { tags: ['hashtags'], - requireCredential: false as const, + requireCredential: false, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { tag: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, chart: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, usersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/hashtags/users.ts b/packages/backend/src/server/api/endpoints/hashtags/users.ts index 6bbe87a0d..2158dc434 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/users.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/users.ts @@ -4,7 +4,7 @@ import { Users } from '@/models/index'; import { normalizeForSearch } from '@/misc/normalize-for-search'; export const meta = { - requireCredential: false as const, + requireCredential: false, tags: ['hashtags', 'users'], @@ -48,15 +48,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/i.ts b/packages/backend/src/server/api/endpoints/i.ts index e5a2c9d2f..d69c118cf 100644 --- a/packages/backend/src/server/api/endpoints/i.ts +++ b/packages/backend/src/server/api/endpoints/i.ts @@ -4,23 +4,23 @@ import { Users } from '@/models/index'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, params: {}, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'MeDetailed', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user, token) => { const isSecure = token == null; // ここで渡ってきている user はキャッシュされていて古い可能性もあるので id だけ渡す - return await Users.pack(user.id, user, { + return await Users.pack(user.id, user, { detail: true, includeSecrets: isSecure, }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/done.ts b/packages/backend/src/server/api/endpoints/i/2fa/done.ts index f6c5ac33a..485390869 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/done.ts @@ -4,7 +4,7 @@ import define from '../../../define'; import { UserProfiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -13,7 +13,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts index cd1f16e54..271632d36 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts @@ -16,7 +16,7 @@ import { publishMainStream } from '@/services/stream'; const cborDecodeFirst = promisify(cbor.decodeFirst) as any; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -37,7 +37,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; const rpIdHashReal = hash(Buffer.from(config.hostname, 'utf-8')); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts index 9eecbb3dc..854848a43 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts @@ -3,7 +3,7 @@ import define from '../../../define'; import { UserProfiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -12,7 +12,7 @@ export const meta = { validator: $.boolean, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts index 19294d15a..b6b0fd50b 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts @@ -10,7 +10,7 @@ import { hash } from '../../../2fa'; const randomBytes = promisify(crypto.randomBytes); export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -19,7 +19,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register.ts b/packages/backend/src/server/api/endpoints/i/2fa/register.ts index 0fe824a6e..c5cfb9dfa 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/register.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/register.ts @@ -7,7 +7,7 @@ import define from '../../../define'; import { UserProfiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -16,7 +16,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts index b9a635423..03e1d0434 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts @@ -5,7 +5,7 @@ import { UserProfiles, UserSecurityKeys, Users } from '@/models/index'; import { publishMainStream } from '@/services/stream'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -17,7 +17,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts index 0e7014d3f..a19ad6810 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts @@ -4,7 +4,7 @@ import define from '../../../define'; import { UserProfiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -13,7 +13,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/apps.ts b/packages/backend/src/server/api/endpoints/i/apps.ts index 6c71a071f..63999b098 100644 --- a/packages/backend/src/server/api/endpoints/i/apps.ts +++ b/packages/backend/src/server/api/endpoints/i/apps.ts @@ -3,7 +3,7 @@ import define from '../../define'; import { AccessTokens } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -17,7 +17,7 @@ export const meta = { ]), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts index 127a272c4..52122b851 100644 --- a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts +++ b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts @@ -3,7 +3,7 @@ import define from '../../define'; import { AccessTokens, Apps } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -23,7 +23,7 @@ export const meta = { default: 'desc', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/change-password.ts b/packages/backend/src/server/api/endpoints/i/change-password.ts index 5ba7a2a87..7b6c13773 100644 --- a/packages/backend/src/server/api/endpoints/i/change-password.ts +++ b/packages/backend/src/server/api/endpoints/i/change-password.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { UserProfiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -17,7 +17,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/delete-account.ts b/packages/backend/src/server/api/endpoints/i/delete-account.ts index bfbf2e5e5..e1eee949f 100644 --- a/packages/backend/src/server/api/endpoints/i/delete-account.ts +++ b/packages/backend/src/server/api/endpoints/i/delete-account.ts @@ -7,7 +7,7 @@ import { publishUserEvent } from '@/services/stream'; import { createDeleteAccountJob } from '@/queue'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -16,7 +16,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/export-blocking.ts b/packages/backend/src/server/api/endpoints/i/export-blocking.ts index 4f2143475..44d8a1cb3 100644 --- a/packages/backend/src/server/api/endpoints/i/export-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/export-blocking.ts @@ -4,12 +4,12 @@ import ms from 'ms'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), max: 1, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/export-following.ts b/packages/backend/src/server/api/endpoints/i/export-following.ts index 4b2f4c86a..5d1617d57 100644 --- a/packages/backend/src/server/api/endpoints/i/export-following.ts +++ b/packages/backend/src/server/api/endpoints/i/export-following.ts @@ -5,7 +5,7 @@ import ms from 'ms'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), max: 1, @@ -20,7 +20,7 @@ export const meta = { default: false, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/export-mute.ts b/packages/backend/src/server/api/endpoints/i/export-mute.ts index 1f655c511..27ce8f0b2 100644 --- a/packages/backend/src/server/api/endpoints/i/export-mute.ts +++ b/packages/backend/src/server/api/endpoints/i/export-mute.ts @@ -4,12 +4,12 @@ import ms from 'ms'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), max: 1, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/export-notes.ts b/packages/backend/src/server/api/endpoints/i/export-notes.ts index aa3d7955f..25b1849e8 100644 --- a/packages/backend/src/server/api/endpoints/i/export-notes.ts +++ b/packages/backend/src/server/api/endpoints/i/export-notes.ts @@ -4,12 +4,12 @@ import ms from 'ms'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1day'), max: 1, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts index e135ba103..d28b699c5 100644 --- a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts @@ -4,12 +4,12 @@ import ms from 'ms'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1min'), max: 1, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/favorites.ts b/packages/backend/src/server/api/endpoints/i/favorites.ts index 2ae5aa87a..92c767876 100644 --- a/packages/backend/src/server/api/endpoints/i/favorites.ts +++ b/packages/backend/src/server/api/endpoints/i/favorites.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['account', 'notes', 'favorites'], - requireCredential: true as const, + requireCredential: true, kind: 'read:favorites', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'NoteFavorite', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts index ebcb459c6..f1c576359 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query'; export const meta = { tags: ['account', 'gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'read:gallery-likes', @@ -27,22 +27,22 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, page: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts index bb77484da..d46d42f63 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query'; export const meta = { tags: ['account', 'gallery'], - requireCredential: true as const, + requireCredential: true, kind: 'read:gallery', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'GalleryPost', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts b/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts index 93c832116..4e1a4d3db 100644 --- a/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts +++ b/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts @@ -4,7 +4,7 @@ import { MutedNotes } from '@/models/index'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', @@ -12,16 +12,16 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { count: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/import-blocking.ts b/packages/backend/src/server/api/endpoints/i/import-blocking.ts index 6b5100c21..acc579742 100644 --- a/packages/backend/src/server/api/endpoints/i/import-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/import-blocking.ts @@ -8,7 +8,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), @@ -46,7 +46,7 @@ export const meta = { id: '6f3a4dcc-f060-a707-4950-806fbdbe60d6', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/import-following.ts b/packages/backend/src/server/api/endpoints/i/import-following.ts index a0ab45b0a..35006746f 100644 --- a/packages/backend/src/server/api/endpoints/i/import-following.ts +++ b/packages/backend/src/server/api/endpoints/i/import-following.ts @@ -8,7 +8,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), max: 1, @@ -45,7 +45,7 @@ export const meta = { id: '31a1b42c-06f7-42ae-8a38-a661c5c9f691', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/import-muting.ts b/packages/backend/src/server/api/endpoints/i/import-muting.ts index b5878f4f5..7bbb2e008 100644 --- a/packages/backend/src/server/api/endpoints/i/import-muting.ts +++ b/packages/backend/src/server/api/endpoints/i/import-muting.ts @@ -8,7 +8,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), @@ -46,7 +46,7 @@ export const meta = { id: 'd2f12af1-e7b4-feac-86a3-519548f2728e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts index 563ecf38e..759d41b6c 100644 --- a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts @@ -8,7 +8,7 @@ import { DriveFiles } from '@/models/index'; export const meta = { secure: true, - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), max: 1, @@ -45,7 +45,7 @@ export const meta = { id: '99efe367-ce6e-4d44-93f8-5fae7b040356', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/notifications.ts b/packages/backend/src/server/api/endpoints/i/notifications.ts index f02e94f32..59efd32bb 100644 --- a/packages/backend/src/server/api/endpoints/i/notifications.ts +++ b/packages/backend/src/server/api/endpoints/i/notifications.ts @@ -12,7 +12,7 @@ import { Brackets } from 'typeorm'; export const meta = { tags: ['account', 'notifications'], - requireCredential: true as const, + requireCredential: true, kind: 'read:notifications', @@ -55,15 +55,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Notification', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/page-likes.ts b/packages/backend/src/server/api/endpoints/i/page-likes.ts index 7b8f4864f..59239c744 100644 --- a/packages/backend/src/server/api/endpoints/i/page-likes.ts +++ b/packages/backend/src/server/api/endpoints/i/page-likes.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['account', 'pages'], - requireCredential: true as const, + requireCredential: true, kind: 'read:page-likes', @@ -27,22 +27,22 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, page: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Page', }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/pages.ts b/packages/backend/src/server/api/endpoints/i/pages.ts index 78de9e2bf..bef775d06 100644 --- a/packages/backend/src/server/api/endpoints/i/pages.ts +++ b/packages/backend/src/server/api/endpoints/i/pages.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['account', 'pages'], - requireCredential: true as const, + requireCredential: true, kind: 'read:pages', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Page', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/pin.ts b/packages/backend/src/server/api/endpoints/i/pin.ts index 9fc73908a..a940d1b99 100644 --- a/packages/backend/src/server/api/endpoints/i/pin.ts +++ b/packages/backend/src/server/api/endpoints/i/pin.ts @@ -8,7 +8,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['account', 'notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -39,11 +39,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'MeDetailed', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { @@ -54,7 +54,7 @@ export default define(meta, async (ps, user) => { throw e; }); - return await Users.pack(user.id, user, { + return await Users.pack(user.id, user, { detail: true, }); }); diff --git a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts index 26c1abced..4e4fb3840 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts @@ -5,13 +5,13 @@ import { MessagingMessages, UserGroupJoinings } from '@/models/index'; export const meta = { tags: ['account', 'messaging'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', params: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts index 44c32a9ee..99f17ddfc 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts @@ -5,13 +5,13 @@ import { NoteUnreads } from '@/models/index'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', params: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/read-announcement.ts b/packages/backend/src/server/api/endpoints/i/read-announcement.ts index 5814c5c3c..e9bb66264 100644 --- a/packages/backend/src/server/api/endpoints/i/read-announcement.ts +++ b/packages/backend/src/server/api/endpoints/i/read-announcement.ts @@ -9,7 +9,7 @@ import { publishMainStream } from '@/services/stream'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -26,7 +26,7 @@ export const meta = { id: '184663db-df88-4bc2-8b52-fb85f0681939', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts index 13dbd7bd5..a20719363 100644 --- a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts +++ b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts @@ -6,7 +6,7 @@ import define from '../../define'; import { Users, UserProfiles } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -15,7 +15,7 @@ export const meta = { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-all.ts b/packages/backend/src/server/api/endpoints/i/registry/get-all.ts index 0f36d3f50..2941b441e 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get-all.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get-all.ts @@ -3,7 +3,7 @@ import define from '../../../define'; import { RegistryItems } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -13,7 +13,7 @@ export const meta = { default: [], }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts b/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts index 36d845207..51371353c 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts @@ -4,7 +4,7 @@ import { RegistryItems } from '@/models/index'; import { ApiError } from '../../../error'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -26,7 +26,7 @@ export const meta = { id: '97a1e8e7-c0f7-47d2-957a-92e61256e01a', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/get.ts b/packages/backend/src/server/api/endpoints/i/registry/get.ts index e1b80035b..ac617defb 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/get.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/get.ts @@ -4,7 +4,7 @@ import { RegistryItems } from '@/models/index'; import { ApiError } from '../../../error'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -26,7 +26,7 @@ export const meta = { id: 'ac3ed68a-62f0-422b-a7bc-d5e09e8f6a6a', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts b/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts index 53ff7b136..044592218 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts @@ -3,7 +3,7 @@ import define from '../../../define'; import { RegistryItems } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -13,7 +13,7 @@ export const meta = { default: [], }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/keys.ts b/packages/backend/src/server/api/endpoints/i/registry/keys.ts index 40ae094d5..a3c9d0e5e 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/keys.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/keys.ts @@ -3,7 +3,7 @@ import define from '../../../define'; import { RegistryItems } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -13,7 +13,7 @@ export const meta = { default: [], }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/remove.ts b/packages/backend/src/server/api/endpoints/i/registry/remove.ts index bea9be73e..08185f224 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/remove.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/remove.ts @@ -4,7 +4,7 @@ import { RegistryItems } from '@/models/index'; import { ApiError } from '../../../error'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -26,7 +26,7 @@ export const meta = { id: '1fac4e8a-a6cd-4e39-a4a5-3a7e11f1b019', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/scopes.ts b/packages/backend/src/server/api/endpoints/i/registry/scopes.ts index c7596f48f..9de68ac6e 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/scopes.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/scopes.ts @@ -2,13 +2,13 @@ import define from '../../../define'; import { RegistryItems } from '@/models/index'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, params: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/set.ts b/packages/backend/src/server/api/endpoints/i/registry/set.ts index c373b1a21..27884046b 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/set.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/set.ts @@ -5,7 +5,7 @@ import { RegistryItems } from '@/models/index'; import { genId } from '@/misc/gen-id'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -23,7 +23,7 @@ export const meta = { default: [], }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/revoke-token.ts b/packages/backend/src/server/api/endpoints/i/revoke-token.ts index acef3a58e..51721c5b5 100644 --- a/packages/backend/src/server/api/endpoints/i/revoke-token.ts +++ b/packages/backend/src/server/api/endpoints/i/revoke-token.ts @@ -5,7 +5,7 @@ import { ID } from '@/misc/cafy-id'; import { publishUserEvent } from '@/services/stream'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -14,7 +14,7 @@ export const meta = { validator: $.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/signin-history.ts b/packages/backend/src/server/api/endpoints/i/signin-history.ts index deb131547..796e2ec30 100644 --- a/packages/backend/src/server/api/endpoints/i/signin-history.ts +++ b/packages/backend/src/server/api/endpoints/i/signin-history.ts @@ -5,7 +5,7 @@ import { Signins } from '@/models/index'; import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -23,7 +23,7 @@ export const meta = { validator: $.optional.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/unpin.ts b/packages/backend/src/server/api/endpoints/i/unpin.ts index 8182254ac..9c82b7496 100644 --- a/packages/backend/src/server/api/endpoints/i/unpin.ts +++ b/packages/backend/src/server/api/endpoints/i/unpin.ts @@ -8,7 +8,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['account', 'notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -27,11 +27,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'MeDetailed', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { @@ -40,7 +40,7 @@ export default define(meta, async (ps, user) => { throw e; }); - return await Users.pack(user.id, user, { + return await Users.pack(user.id, user, { detail: true, }); }); diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts index 19bf80248..b4479aa50 100644 --- a/packages/backend/src/server/api/endpoints/i/update-email.ts +++ b/packages/backend/src/server/api/endpoints/i/update-email.ts @@ -11,7 +11,7 @@ import { ApiError } from '../../error'; import { validateEmailForAccount } from '@/services/validate-email-for-account'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, @@ -43,7 +43,7 @@ export const meta = { id: 'a2defefb-f220-8849-0af6-17f816099323', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 3c6050efd..6b7e53aa1 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -19,7 +19,7 @@ import { normalizeForSearch } from '@/misc/normalize-for-search'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -162,11 +162,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'MeDetailed', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, _user, token) => { @@ -279,7 +279,7 @@ export default define(meta, async (ps, _user, token) => { if (Object.keys(updates).length > 0) await Users.update(user.id, updates); if (Object.keys(profileUpdates).length > 0) await UserProfiles.update(user.id, profileUpdates); - const iObj = await Users.pack(user.id, user, { + const iObj = await Users.pack(user.id, user, { detail: true, includeSecrets: isSecure, }); diff --git a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts index cbe3f64a2..76a3131e6 100644 --- a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts +++ b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['account', 'groups'], - requireCredential: true as const, + requireCredential: true, kind: 'read:user-groups', @@ -27,26 +27,26 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, group: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/messaging/history.ts b/packages/backend/src/server/api/endpoints/messaging/history.ts index ca5b1d06a..5ac49cf96 100644 --- a/packages/backend/src/server/api/endpoints/messaging/history.ts +++ b/packages/backend/src/server/api/endpoints/messaging/history.ts @@ -7,7 +7,7 @@ import { Brackets } from 'typeorm'; export const meta = { tags: ['messaging'], - requireCredential: true as const, + requireCredential: true, kind: 'read:messaging', @@ -24,15 +24,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'MessagingMessage', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/messaging/messages.ts b/packages/backend/src/server/api/endpoints/messaging/messages.ts index 9332695fd..7dbddd80e 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages.ts @@ -11,7 +11,7 @@ import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivit export const meta = { tags: ['messaging'], - requireCredential: true as const, + requireCredential: true, kind: 'read:messaging', @@ -44,11 +44,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'MessagingMessage', }, }, @@ -72,7 +72,7 @@ export const meta = { id: 'a053a8dd-a491-4718-8f87-50775aad9284', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts index 609274667..5ec16f5e5 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts @@ -11,7 +11,7 @@ import { createMessage } from '@/services/messages/create'; export const meta = { tags: ['messaging'], - requireCredential: true as const, + requireCredential: true, kind: 'write:messaging', @@ -34,8 +34,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'MessagingMessage', }, @@ -82,7 +82,7 @@ export const meta = { id: 'c15a5199-7422-4968-941a-2a462c478f7d', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts index 7362f705e..2975419ce 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts @@ -9,7 +9,7 @@ import { deleteMessage } from '@/services/messages/delete'; export const meta = { tags: ['messaging'], - requireCredential: true as const, + requireCredential: true, kind: 'write:messaging', @@ -32,7 +32,7 @@ export const meta = { id: '54b5b326-7925-42cf-8019-130fda8b56af', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/read.ts b/packages/backend/src/server/api/endpoints/messaging/messages/read.ts index c698f3979..42c3f49f6 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/read.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/read.ts @@ -8,7 +8,7 @@ import { readUserMessagingMessage, readGroupMessagingMessage } from '../../../co export const meta = { tags: ['messaging'], - requireCredential: true as const, + requireCredential: true, kind: 'write:messaging', @@ -25,7 +25,7 @@ export const meta = { id: '86d56a2f-a9c3-4afb-b13c-3e9bfef9aa14', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 6b07011fd..693a7a04e 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -9,7 +9,7 @@ import { MoreThan } from 'typeorm'; export const meta = { tags: ['meta'], - requireCredential: false as const, + requireCredential: false, params: { detail: { @@ -19,434 +19,434 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { maintainerName: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, maintainerEmail: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, version: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, example: config.version, }, name: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, uri: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', example: 'https://misskey.example.com', }, description: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, langs: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, tosUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, repositoryUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, default: 'https://github.com/misskey-dev/misskey', }, feedbackUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, default: 'https://github.com/misskey-dev/misskey/issues/new', }, secure: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, default: false, }, disableRegistration: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, disableLocalTimeline: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, disableGlobalTimeline: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, driveCapacityPerLocalUserMb: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, driveCapacityPerRemoteUserMb: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, cacheRemoteFiles: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, proxyRemoteFiles: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, emailRequiredForSignup: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, enableHcaptcha: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, hcaptchaSiteKey: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, enableRecaptcha: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, recaptchaSiteKey: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, swPublickey: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, mascotImageUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, default: '/assets/ai.png', }, bannerUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, errorImageUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, default: 'https://xn--931a.moe/aiart/yubitun.png', }, iconUrl: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, maxNoteTextLength: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, default: 500, }, emojis: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, aliases: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, category: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, host: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, url: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', }, }, }, }, ads: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { place: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, url: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', }, imageUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'url', }, }, }, }, requireSetup: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, example: false, }, enableEmail: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, enableTwitterIntegration: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, enableGithubIntegration: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, enableDiscordIntegration: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, enableServiceWorker: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, translatorAvailable: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, proxyAccountName: { - type: 'string' as const, - optional: false as const, nullable: true as const, + type: 'string', + optional: false, nullable: true, }, features: { - type: 'object' as const, - optional: true as const, nullable: false as const, + type: 'object', + optional: true, nullable: false, properties: { registration: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, localTimeLine: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, globalTimeLine: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, elasticsearch: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, hcaptcha: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, recaptcha: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, objectStorage: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, twitter: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, github: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, discord: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, serviceWorker: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, miauth: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, default: true, }, }, }, userStarForReactionFallback: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, pinnedUsers: { - type: 'array' as const, - optional: true as const, nullable: false as const, + type: 'array', + optional: true, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, hiddenTags: { - type: 'array' as const, - optional: true as const, nullable: false as const, + type: 'array', + optional: true, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, blockedHosts: { - type: 'array' as const, - optional: true as const, nullable: false as const, + type: 'array', + optional: true, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, hcaptchaSecretKey: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, recaptchaSecretKey: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, proxyAccountId: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, format: 'id', }, twitterConsumerKey: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, twitterConsumerSecret: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, githubClientId: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, githubClientSecret: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, discordClientId: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, discordClientSecret: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, summaryProxy: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, email: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, smtpSecure: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, smtpHost: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, smtpPort: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, smtpUser: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, smtpPass: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, swPrivateKey: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, useObjectStorage: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, objectStorageBaseUrl: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStorageBucket: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStoragePrefix: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStorageEndpoint: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStorageRegion: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStoragePort: { - type: 'number' as const, - optional: true as const, nullable: true as const, + type: 'number', + optional: true, nullable: true, }, objectStorageAccessKey: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStorageSecretKey: { - type: 'string' as const, - optional: true as const, nullable: true as const, + type: 'string', + optional: true, nullable: true, }, objectStorageUseSSL: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, objectStorageUseProxy: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, objectStorageSetPublicRead: { - type: 'boolean' as const, - optional: true as const, nullable: false as const, + type: 'boolean', + optional: true, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts index cc739a51e..158c8877e 100644 --- a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts +++ b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts @@ -7,7 +7,7 @@ import { secureRndstr } from '@/misc/secure-rndstr'; export const meta = { tags: ['auth'], - requireCredential: true as const, + requireCredential: true, secure: true, @@ -34,16 +34,16 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { token: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/mute/create.ts b/packages/backend/src/server/api/endpoints/mute/create.ts index 000e48dde..6ba5a453c 100644 --- a/packages/backend/src/server/api/endpoints/mute/create.ts +++ b/packages/backend/src/server/api/endpoints/mute/create.ts @@ -11,7 +11,7 @@ import { publishUserEvent } from '@/services/stream'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:mutes', @@ -40,7 +40,7 @@ export const meta = { id: '7e7359cb-160c-4956-b08f-4d1c653cd007', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/mute/delete.ts b/packages/backend/src/server/api/endpoints/mute/delete.ts index c204add1b..21948dc3d 100644 --- a/packages/backend/src/server/api/endpoints/mute/delete.ts +++ b/packages/backend/src/server/api/endpoints/mute/delete.ts @@ -9,7 +9,7 @@ import { publishUserEvent } from '@/services/stream'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:mutes', @@ -38,7 +38,7 @@ export const meta = { id: '5467d020-daa9-4553-81e1-135c0c35a96d', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/mute/list.ts b/packages/backend/src/server/api/endpoints/mute/list.ts index a736161b9..4c6a81b63 100644 --- a/packages/backend/src/server/api/endpoints/mute/list.ts +++ b/packages/backend/src/server/api/endpoints/mute/list.ts @@ -7,7 +7,7 @@ import { Mutings } from '@/models/index'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:mutes', @@ -27,15 +27,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Muting', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/my/apps.ts b/packages/backend/src/server/api/endpoints/my/apps.ts index d9443d38d..42bd5c5f7 100644 --- a/packages/backend/src/server/api/endpoints/my/apps.ts +++ b/packages/backend/src/server/api/endpoints/my/apps.ts @@ -5,7 +5,7 @@ import { Apps } from '@/models/index'; export const meta = { tags: ['account', 'app'], - requireCredential: true as const, + requireCredential: true, params: { limit: { @@ -20,54 +20,54 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, name: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, callbackUrl: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, permission: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, secret: { - type: 'string' as const, - optional: true as const, nullable: false as const, + type: 'string', + optional: true, nullable: false, }, isAuthorized: { - type: 'object' as const, - optional: true as const, nullable: false as const, + type: 'object', + optional: true, nullable: false, properties: { appId: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, userId: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes.ts b/packages/backend/src/server/api/endpoints/notes.ts index c853996a4..9edc6cb11 100644 --- a/packages/backend/src/server/api/endpoints/notes.ts +++ b/packages/backend/src/server/api/endpoints/notes.ts @@ -43,15 +43,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/notes/children.ts b/packages/backend/src/server/api/endpoints/notes/children.ts index d6062f4eb..088ef65e9 100644 --- a/packages/backend/src/server/api/endpoints/notes/children.ts +++ b/packages/backend/src/server/api/endpoints/notes/children.ts @@ -12,7 +12,7 @@ import { generateMutedInstanceQuery } from '../../common/generate-muted-instance export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -34,15 +34,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/clips.ts b/packages/backend/src/server/api/endpoints/notes/clips.ts index 67bac3670..b89c6db4a 100644 --- a/packages/backend/src/server/api/endpoints/notes/clips.ts +++ b/packages/backend/src/server/api/endpoints/notes/clips.ts @@ -9,7 +9,7 @@ import { In } from 'typeorm'; export const meta = { tags: ['clips', 'notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -18,12 +18,12 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'Note', + type: 'object', + optional: false, nullable: false, + ref: 'Clip', }, }, @@ -34,7 +34,7 @@ export const meta = { id: '47db1a1c-b0af-458d-8fb4-986e4efafe1e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/notes/conversation.ts b/packages/backend/src/server/api/endpoints/notes/conversation.ts index a465b08d3..4bd89c32e 100644 --- a/packages/backend/src/server/api/endpoints/notes/conversation.ts +++ b/packages/backend/src/server/api/endpoints/notes/conversation.ts @@ -9,7 +9,7 @@ import { Notes } from '@/models/index'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -28,11 +28,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -44,7 +44,7 @@ export const meta = { id: 'e1035875-9551-45ec-afa8-1ded1fcb53c8', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index ec05e5ea9..6adbc821e 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -25,7 +25,7 @@ setInterval(() => { export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, limit: { duration: ms('1hour'), @@ -113,12 +113,12 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { createdNote: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -173,7 +173,7 @@ export const meta = { id: 'b390d7e1-8a5e-46ed-b625-06271cafd3d3', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/delete.ts b/packages/backend/src/server/api/endpoints/notes/delete.ts index 0f6f99c7c..9e080d9e9 100644 --- a/packages/backend/src/server/api/endpoints/notes/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/delete.ts @@ -10,7 +10,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:notes', @@ -39,7 +39,7 @@ export const meta = { id: 'fe8d7103-0ea8-4ec3-814d-f8b401dc69e9', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts index d5d39c304..78da6a3b0 100644 --- a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts @@ -9,7 +9,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['notes', 'favorites'], - requireCredential: true as const, + requireCredential: true, kind: 'write:favorites', @@ -32,7 +32,7 @@ export const meta = { id: 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts b/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts index 62f32633b..3f3d50f0d 100644 --- a/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts @@ -8,7 +8,7 @@ import { NoteFavorites } from '@/models/index'; export const meta = { tags: ['notes', 'favorites'], - requireCredential: true as const, + requireCredential: true, kind: 'write:favorites', @@ -31,7 +31,7 @@ export const meta = { id: 'b625fc69-635e-45e9-86f4-dbefbef35af5', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts index 8f45b541d..5a47fb9e0 100644 --- a/packages/backend/src/server/api/endpoints/notes/featured.ts +++ b/packages/backend/src/server/api/endpoints/notes/featured.ts @@ -7,7 +7,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { limit: { @@ -22,15 +22,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts index 14831a127..cac8b7d8a 100644 --- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts @@ -43,11 +43,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -59,7 +59,7 @@ export const meta = { id: '0332fc13-6ab2-4427-ae80-a9fadffd1a6b', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index bac243705..9683df461 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -18,7 +18,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, params: { limit: { @@ -63,11 +63,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -79,7 +79,7 @@ export const meta = { id: '620763f4-f621-4533-ab33-0577a1a3c342', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index 334e754d0..777664412 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -54,11 +54,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -70,7 +70,7 @@ export const meta = { id: '45a6eb02-7695-4393-b023-dd3be9aaaefd', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts index 8ae90233a..81b384436 100644 --- a/packages/backend/src/server/api/endpoints/notes/mentions.ts +++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts @@ -13,7 +13,7 @@ import { generateMutedNoteThreadQuery } from '../../common/generate-muted-note-t export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, params: { following: { @@ -40,15 +40,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts index 7562c6d7f..79b558e65 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts @@ -6,7 +6,7 @@ import { Brackets, In } from 'typeorm'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, params: { limit: { @@ -21,15 +21,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index a08709e32..77387cacb 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -17,7 +17,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:votes', @@ -68,7 +68,7 @@ export const meta = { id: '85a5377e-b1e9-4617-b0b9-5bea73331e49', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/reactions.ts b/packages/backend/src/server/api/endpoints/notes/reactions.ts index d29893e20..5205a7817 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions.ts @@ -10,7 +10,7 @@ import { NoteReaction } from '@/models/entities/note-reaction'; export const meta = { tags: ['notes', 'reactions'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -41,11 +41,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'NoteReaction', }, }, @@ -57,7 +57,7 @@ export const meta = { id: '263fff3d-d0e1-4af4-bea7-8408059b451a', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts index 28403d821..1b42781ce 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['reactions', 'notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:reactions', @@ -41,7 +41,7 @@ export const meta = { id: '20ef5475-9f38-4e4c-bd33-de6d979498ec', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts index 2b1ce1e21..1d686b597 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts @@ -9,7 +9,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['reactions', 'notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:reactions', @@ -38,7 +38,7 @@ export const meta = { id: '92f4426d-4196-4125-aa5b-02943e2ec8fc', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/renotes.ts b/packages/backend/src/server/api/endpoints/notes/renotes.ts index abfd928db..f71d23146 100644 --- a/packages/backend/src/server/api/endpoints/notes/renotes.ts +++ b/packages/backend/src/server/api/endpoints/notes/renotes.ts @@ -12,7 +12,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -34,11 +34,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -50,7 +50,7 @@ export const meta = { id: '12908022-2e21-46cd-ba6a-3edaf6093f46', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/replies.ts b/packages/backend/src/server/api/endpoints/notes/replies.ts index 12efe94be..62c56534e 100644 --- a/packages/backend/src/server/api/endpoints/notes/replies.ts +++ b/packages/backend/src/server/api/endpoints/notes/replies.ts @@ -10,7 +10,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -32,15 +32,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts index 85daf7e48..87eaffe2f 100644 --- a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts +++ b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts @@ -56,15 +56,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts index 5ff325895..e75212b14 100644 --- a/packages/backend/src/server/api/endpoints/notes/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/search.ts @@ -13,7 +13,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { query: { @@ -50,18 +50,18 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/notes/show.ts b/packages/backend/src/server/api/endpoints/notes/show.ts index b645f8679..feb94be1a 100644 --- a/packages/backend/src/server/api/endpoints/notes/show.ts +++ b/packages/backend/src/server/api/endpoints/notes/show.ts @@ -8,7 +8,7 @@ import { Notes } from '@/models/index'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -17,8 +17,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, @@ -29,7 +29,7 @@ export const meta = { id: '24fcbfc6-2e37-42b6-8388-c29b3861a08d', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/state.ts b/packages/backend/src/server/api/endpoints/notes/state.ts index 5bbe3ec86..c3e9090bb 100644 --- a/packages/backend/src/server/api/endpoints/notes/state.ts +++ b/packages/backend/src/server/api/endpoints/notes/state.ts @@ -6,7 +6,7 @@ import { NoteFavorites, Notes, NoteThreadMutings, NoteWatchings } from '@/models export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, params: { noteId: { @@ -15,24 +15,24 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { isFavorited: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isWatching: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isMutedThread: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts index 0bd55f898..a8b50d90f 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts @@ -10,7 +10,7 @@ import readNote from '@/services/note/read'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -27,7 +27,7 @@ export const meta = { id: '5ff67ada-ed3b-2e71-8e87-a1a421e177d2', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts index 756f1b9fd..f76b526ce 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts @@ -8,7 +8,7 @@ import { NoteThreadMutings } from '@/models'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -25,7 +25,7 @@ export const meta = { id: 'bddd57ac-ceb3-b29d-4334-86ea5fae481a', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index 4acfed35e..8be2861ae 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -16,7 +16,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, params: { limit: { @@ -61,15 +61,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index 98a45ace1..ed069cb75 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -13,7 +13,7 @@ import { Notes } from '@/models'; export const meta = { tags: ['notes'], - requireCredential: false as const, + requireCredential: false, params: { noteId: { @@ -25,8 +25,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, }, errors: { @@ -36,7 +36,7 @@ export const meta = { id: 'bea9b03f-36e0-49c5-a4db-627a029f8971', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/unrenote.ts b/packages/backend/src/server/api/endpoints/notes/unrenote.ts index 2c1e1c739..8db543d32 100644 --- a/packages/backend/src/server/api/endpoints/notes/unrenote.ts +++ b/packages/backend/src/server/api/endpoints/notes/unrenote.ts @@ -10,7 +10,7 @@ import { Notes, Users } from '@/models/index'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:notes', @@ -33,7 +33,7 @@ export const meta = { id: 'efd4a259-2442-496b-8dd7-b255aa1a160f', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts index c3b273937..89de73fb9 100644 --- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts @@ -11,7 +11,7 @@ import { Brackets } from 'typeorm'; export const meta = { tags: ['notes', 'lists'], - requireCredential: true as const, + requireCredential: true, params: { listId: { @@ -60,11 +60,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -76,7 +76,7 @@ export const meta = { id: '8fb1fbd5-e476-4c37-9fb0-43d55b63a2ff', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/watching/create.ts b/packages/backend/src/server/api/endpoints/notes/watching/create.ts index d55ae2002..6433c6bc2 100644 --- a/packages/backend/src/server/api/endpoints/notes/watching/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/watching/create.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -25,7 +25,7 @@ export const meta = { id: 'ea0e37a6-90a3-4f58-ba6b-c328ca206fc7', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notes/watching/delete.ts b/packages/backend/src/server/api/endpoints/notes/watching/delete.ts index 522ae6360..3e9faa2b2 100644 --- a/packages/backend/src/server/api/endpoints/notes/watching/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/watching/delete.ts @@ -8,7 +8,7 @@ import { ApiError } from '../../../error'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -25,7 +25,7 @@ export const meta = { id: '09b3695c-f72c-4731-a428-7cff825fc82e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notifications/create.ts b/packages/backend/src/server/api/endpoints/notifications/create.ts index f78c6e121..bd8a7ba1b 100644 --- a/packages/backend/src/server/api/endpoints/notifications/create.ts +++ b/packages/backend/src/server/api/endpoints/notifications/create.ts @@ -5,7 +5,7 @@ import { createNotification } from '@/services/create-notification'; export const meta = { tags: ['notifications'], - requireCredential: true as const, + requireCredential: true, kind: 'write:notifications', @@ -25,7 +25,7 @@ export const meta = { errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user, token) => { diff --git a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts index f14a91a3d..4cec38a95 100644 --- a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts +++ b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts @@ -5,10 +5,10 @@ import { Notifications } from '@/models/index'; export const meta = { tags: ['notifications', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:notifications', -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/notifications/read.ts b/packages/backend/src/server/api/endpoints/notifications/read.ts index 891bfd30d..7e23bc234 100644 --- a/packages/backend/src/server/api/endpoints/notifications/read.ts +++ b/packages/backend/src/server/api/endpoints/notifications/read.ts @@ -9,7 +9,7 @@ import { ApiError } from '../../error'; export const meta = { tags: ['notifications', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'write:notifications', @@ -26,7 +26,7 @@ export const meta = { id: 'efa929d5-05b5-47d1-beec-e6a4dbed011e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/page-push.ts b/packages/backend/src/server/api/endpoints/page-push.ts index f5da35e78..61c0160f8 100644 --- a/packages/backend/src/server/api/endpoints/page-push.ts +++ b/packages/backend/src/server/api/endpoints/page-push.ts @@ -6,7 +6,7 @@ import { Users, Pages } from '@/models/index'; import { ApiError } from '../error'; export const meta = { - requireCredential: true as const, + requireCredential: true, secure: true, params: { @@ -30,7 +30,7 @@ export const meta = { id: '4a13ad31-6729-46b4-b9af-e86b265c2e74', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/pages/create.ts b/packages/backend/src/server/api/endpoints/pages/create.ts index dcf916909..7ee50fbdf 100644 --- a/packages/backend/src/server/api/endpoints/pages/create.ts +++ b/packages/backend/src/server/api/endpoints/pages/create.ts @@ -10,7 +10,7 @@ import { ApiError } from '../../error'; export const meta = { tags: ['pages'], - requireCredential: true as const, + requireCredential: true, kind: 'write:pages', @@ -65,8 +65,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Page', }, @@ -82,7 +82,7 @@ export const meta = { id: '4650348e-301c-499a-83c9-6aa988c66bc1', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/pages/delete.ts b/packages/backend/src/server/api/endpoints/pages/delete.ts index b3a37446d..aeda823e5 100644 --- a/packages/backend/src/server/api/endpoints/pages/delete.ts +++ b/packages/backend/src/server/api/endpoints/pages/delete.ts @@ -7,7 +7,7 @@ import { ID } from '@/misc/cafy-id'; export const meta = { tags: ['pages'], - requireCredential: true as const, + requireCredential: true, kind: 'write:pages', @@ -30,7 +30,7 @@ export const meta = { id: '8b741b3e-2c22-44b3-a15f-29949aa1601e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/pages/featured.ts b/packages/backend/src/server/api/endpoints/pages/featured.ts index b32964c49..7f0d58b35 100644 --- a/packages/backend/src/server/api/endpoints/pages/featured.ts +++ b/packages/backend/src/server/api/endpoints/pages/featured.ts @@ -4,18 +4,18 @@ import { Pages } from '@/models/index'; export const meta = { tags: ['pages'], - requireCredential: false as const, + requireCredential: false, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Page', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/pages/like.ts b/packages/backend/src/server/api/endpoints/pages/like.ts index deff8cc02..c479f637a 100644 --- a/packages/backend/src/server/api/endpoints/pages/like.ts +++ b/packages/backend/src/server/api/endpoints/pages/like.ts @@ -8,7 +8,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['pages'], - requireCredential: true as const, + requireCredential: true, kind: 'write:page-likes', @@ -37,7 +37,7 @@ export const meta = { id: 'cc98a8a2-0dc3-4123-b198-62c71df18ed3', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/pages/show.ts b/packages/backend/src/server/api/endpoints/pages/show.ts index 4a98ec073..5cda5386d 100644 --- a/packages/backend/src/server/api/endpoints/pages/show.ts +++ b/packages/backend/src/server/api/endpoints/pages/show.ts @@ -8,7 +8,7 @@ import { Page } from '@/models/entities/page'; export const meta = { tags: ['pages'], - requireCredential: false as const, + requireCredential: false, params: { pageId: { @@ -25,8 +25,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Page', }, @@ -37,7 +37,7 @@ export const meta = { id: '222120c0-3ead-4528-811b-b96f233388d7', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/pages/unlike.ts b/packages/backend/src/server/api/endpoints/pages/unlike.ts index f6e74dcf1..cca5e5b5a 100644 --- a/packages/backend/src/server/api/endpoints/pages/unlike.ts +++ b/packages/backend/src/server/api/endpoints/pages/unlike.ts @@ -7,7 +7,7 @@ import { Pages, PageLikes } from '@/models/index'; export const meta = { tags: ['pages'], - requireCredential: true as const, + requireCredential: true, kind: 'write:page-likes', @@ -30,7 +30,7 @@ export const meta = { id: 'f5e586b0-ce93-4050-b0e3-7f31af5259ee', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/pages/update.ts b/packages/backend/src/server/api/endpoints/pages/update.ts index 06c63706a..991085ee0 100644 --- a/packages/backend/src/server/api/endpoints/pages/update.ts +++ b/packages/backend/src/server/api/endpoints/pages/update.ts @@ -9,7 +9,7 @@ import { Not } from 'typeorm'; export const meta = { tags: ['pages'], - requireCredential: true as const, + requireCredential: true, kind: 'write:pages', @@ -88,7 +88,7 @@ export const meta = { id: '2298a392-d4a1-44c5-9ebb-ac1aeaa5a9ab', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/ping.ts b/packages/backend/src/server/api/endpoints/ping.ts index 2130ce54e..3eab70ae2 100644 --- a/packages/backend/src/server/api/endpoints/ping.ts +++ b/packages/backend/src/server/api/endpoints/ping.ts @@ -1,7 +1,7 @@ import define from '../define'; export const meta = { - requireCredential: false as const, + requireCredential: false, tags: ['meta'], @@ -9,16 +9,16 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { pong: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/pinned-users.ts b/packages/backend/src/server/api/endpoints/pinned-users.ts index 548871a02..ff0e22555 100644 --- a/packages/backend/src/server/api/endpoints/pinned-users.ts +++ b/packages/backend/src/server/api/endpoints/pinned-users.ts @@ -7,21 +7,21 @@ import { User } from '@/models/entities/user'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/promo/read.ts b/packages/backend/src/server/api/endpoints/promo/read.ts index 271d88789..8d8c60d75 100644 --- a/packages/backend/src/server/api/endpoints/promo/read.ts +++ b/packages/backend/src/server/api/endpoints/promo/read.ts @@ -9,7 +9,7 @@ import { genId } from '@/misc/gen-id'; export const meta = { tags: ['notes'], - requireCredential: true as const, + requireCredential: true, params: { noteId: { @@ -24,7 +24,7 @@ export const meta = { id: 'd785b897-fcd3-4fe9-8fc3-b85c26e6c932', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts index 2a29e5891..af1aeb431 100644 --- a/packages/backend/src/server/api/endpoints/request-reset-password.ts +++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts @@ -11,7 +11,7 @@ import { genId } from '@/misc/gen-id'; import { IsNull } from 'typeorm'; export const meta = { - requireCredential: false as const, + requireCredential: false, limit: { duration: ms('1hour'), @@ -31,7 +31,7 @@ export const meta = { errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/reset-db.ts b/packages/backend/src/server/api/endpoints/reset-db.ts index caae137d7..e99dc9db1 100644 --- a/packages/backend/src/server/api/endpoints/reset-db.ts +++ b/packages/backend/src/server/api/endpoints/reset-db.ts @@ -4,7 +4,7 @@ import { ApiError } from '../error'; import { resetDb } from '@/db/postgre'; export const meta = { - requireCredential: false as const, + requireCredential: false, params: { }, @@ -12,7 +12,7 @@ export const meta = { errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/reset-password.ts b/packages/backend/src/server/api/endpoints/reset-password.ts index 3cf89f375..a7366584b 100644 --- a/packages/backend/src/server/api/endpoints/reset-password.ts +++ b/packages/backend/src/server/api/endpoints/reset-password.ts @@ -6,7 +6,7 @@ import { Users, UserProfiles, PasswordResetRequests } from '@/models/index'; import { ApiError } from '../error'; export const meta = { - requireCredential: false as const, + requireCredential: false, params: { token: { @@ -21,7 +21,7 @@ export const meta = { errors: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts index 2613416ee..1ad2c54ab 100644 --- a/packages/backend/src/server/api/endpoints/server-info.ts +++ b/packages/backend/src/server/api/endpoints/server-info.ts @@ -3,7 +3,7 @@ import * as si from 'systeminformation'; import define from '../define'; export const meta = { - requireCredential: false as const, + requireCredential: false, desc: { }, @@ -12,7 +12,7 @@ export const meta = { params: { }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/stats.ts b/packages/backend/src/server/api/endpoints/stats.ts index 75f7a9498..9879ef2ad 100644 --- a/packages/backend/src/server/api/endpoints/stats.ts +++ b/packages/backend/src/server/api/endpoints/stats.ts @@ -3,7 +3,7 @@ import { NoteReactions, Notes, Users } from '@/models/index'; import { federationChart, driveChart } from '@/services/chart/index'; export const meta = { - requireCredential: false as const, + requireCredential: false, tags: ['meta'], @@ -11,40 +11,40 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { notesCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, originalNotesCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, usersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, originalUsersCount: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, instances: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, driveUsageLocal: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, driveUsageRemote: { - type: 'number' as const, - optional: false as const, nullable: false as const, + type: 'number', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async () => { diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts index 8657a0b77..ae3e9ce77 100644 --- a/packages/backend/src/server/api/endpoints/sw/register.ts +++ b/packages/backend/src/server/api/endpoints/sw/register.ts @@ -7,7 +7,7 @@ import { SwSubscriptions } from '@/models/index'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, params: { endpoint: { @@ -24,21 +24,21 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { state: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, enum: ['already-subscribed', 'subscribed'], }, key: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/sw/unregister.ts b/packages/backend/src/server/api/endpoints/sw/unregister.ts index 67a2ed0a9..6f569e941 100644 --- a/packages/backend/src/server/api/endpoints/sw/unregister.ts +++ b/packages/backend/src/server/api/endpoints/sw/unregister.ts @@ -5,14 +5,14 @@ import { SwSubscriptions } from '../../../../models'; export const meta = { tags: ['account'], - requireCredential: true as const, + requireCredential: true, params: { endpoint: { validator: $.str, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/username/available.ts b/packages/backend/src/server/api/endpoints/username/available.ts index ede03eeb1..74120fc40 100644 --- a/packages/backend/src/server/api/endpoints/username/available.ts +++ b/packages/backend/src/server/api/endpoints/username/available.ts @@ -5,7 +5,7 @@ import { Users, UsedUsernames } from '@/models/index'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { username: { @@ -14,16 +14,16 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { available: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps) => { diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index fdcf59f77..6b11ec0f0 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -7,7 +7,7 @@ import { generateBlockQueryForUsers } from '../common/generate-block-query'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { limit: { @@ -53,15 +53,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/clips.ts b/packages/backend/src/server/api/endpoints/users/clips.ts index 91da853e6..d4152fbf5 100644 --- a/packages/backend/src/server/api/endpoints/users/clips.ts +++ b/packages/backend/src/server/api/endpoints/users/clips.ts @@ -25,7 +25,7 @@ export const meta = { validator: $.optional.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/followers.ts b/packages/backend/src/server/api/endpoints/users/followers.ts index d9c0ed762..6214ab40b 100644 --- a/packages/backend/src/server/api/endpoints/users/followers.ts +++ b/packages/backend/src/server/api/endpoints/users/followers.ts @@ -9,7 +9,7 @@ import { toPunyNullable } from '@/misc/convert-host'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { userId: { @@ -39,11 +39,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Following', }, }, @@ -61,7 +61,7 @@ export const meta = { id: '3c6a84db-d619-26af-ca14-06232a21df8a', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/following.ts b/packages/backend/src/server/api/endpoints/users/following.ts index a77fedd68..76112eab2 100644 --- a/packages/backend/src/server/api/endpoints/users/following.ts +++ b/packages/backend/src/server/api/endpoints/users/following.ts @@ -9,7 +9,7 @@ import { toPunyNullable } from '@/misc/convert-host'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { userId: { @@ -39,11 +39,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Following', }, }, @@ -61,7 +61,7 @@ export const meta = { id: 'f6cdb0df-c19f-ec5c-7dbb-0ba84a1f92ba', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts index bffa4a502..c5f08b4c9 100644 --- a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts @@ -25,7 +25,7 @@ export const meta = { validator: $.optional.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts index 5852da184..d886d3355 100644 --- a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts +++ b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts @@ -10,7 +10,7 @@ import { Notes, Users } from '@/models/index'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { userId: { @@ -24,12 +24,22 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + properties: { + user: { + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', + }, + weight: { + type: 'number', + optional: false, nullable: false, + }, + }, }, }, @@ -40,7 +50,7 @@ export const meta = { id: 'e6965129-7b2a-40a4-bae2-cd84cd434822', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/create.ts b/packages/backend/src/server/api/endpoints/users/groups/create.ts index bbe041122..25e29de01 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/create.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/create.ts @@ -8,7 +8,7 @@ import { UserGroupJoining } from '@/models/entities/user-group-joining'; export const meta = { tags: ['groups'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -19,11 +19,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/delete.ts b/packages/backend/src/server/api/endpoints/users/groups/delete.ts index 5a38428ca..f30ab78ca 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/delete.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/delete.ts @@ -7,7 +7,7 @@ import { UserGroups } from '@/models/index'; export const meta = { tags: ['groups'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -24,7 +24,7 @@ export const meta = { id: '63dbd64c-cd77-413f-8e08-61781e210b38', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts index 45b6c39dc..7061db538 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts @@ -9,7 +9,7 @@ import { UserGroupJoining } from '@/models/entities/user-group-joining'; export const meta = { tags: ['groups', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -26,7 +26,7 @@ export const meta = { id: '98c11eca-c890-4f42-9806-c8c8303ebb5e', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts index 03ce90aa3..f5ca3dec8 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts @@ -7,7 +7,7 @@ import { UserGroupInvitations } from '@/models/index'; export const meta = { tags: ['groups', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -24,7 +24,7 @@ export const meta = { id: 'ad7471d4-2cd9-44b4-ac68-e7136b4ce656', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/invite.ts b/packages/backend/src/server/api/endpoints/users/groups/invite.ts index 68ce0f1ad..3b7a4edb8 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invite.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invite.ts @@ -11,7 +11,7 @@ import { createNotification } from '@/services/create-notification'; export const meta = { tags: ['groups', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -50,7 +50,7 @@ export const meta = { id: 'ee0f58b4-b529-4d13-b761-b9a3e69f97e6', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/joined.ts b/packages/backend/src/server/api/endpoints/users/groups/joined.ts index ad18a2f12..ab48b1910 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/joined.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/joined.ts @@ -5,20 +5,20 @@ import { Not, In } from 'typeorm'; export const meta = { tags: ['groups', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:user-groups', res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/leave.ts b/packages/backend/src/server/api/endpoints/users/groups/leave.ts index af259d28e..d2fcdab30 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/leave.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/leave.ts @@ -7,7 +7,7 @@ import { UserGroups, UserGroupJoinings } from '@/models/index'; export const meta = { tags: ['groups', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -30,7 +30,7 @@ export const meta = { id: 'b6d6e0c2-ef8a-9bb8-653d-79f4a3107c69', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/owned.ts b/packages/backend/src/server/api/endpoints/users/groups/owned.ts index d11d04b84..6193a7101 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/owned.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/owned.ts @@ -4,20 +4,20 @@ import { UserGroups } from '@/models/index'; export const meta = { tags: ['groups', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:user-groups', res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/pull.ts b/packages/backend/src/server/api/endpoints/users/groups/pull.ts index e4c5d1f9e..785bea140 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/pull.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/pull.ts @@ -8,7 +8,7 @@ import { UserGroups, UserGroupJoinings } from '@/models/index'; export const meta = { tags: ['groups', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -41,7 +41,7 @@ export const meta = { id: '1546eed5-4414-4dea-81c1-b0aec4f6d2af', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/show.ts b/packages/backend/src/server/api/endpoints/users/groups/show.ts index 55b86d0e5..eb26eac2a 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/show.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/show.ts @@ -7,7 +7,7 @@ import { UserGroups, UserGroupJoinings } from '@/models/index'; export const meta = { tags: ['groups', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:user-groups', @@ -18,8 +18,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, @@ -30,7 +30,7 @@ export const meta = { id: 'ea04751e-9b7e-487b-a509-330fb6bd6b9b', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts index 6795f1dd2..4b1c8fbbd 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts @@ -8,7 +8,7 @@ import { UserGroups, UserGroupJoinings } from '@/models/index'; export const meta = { tags: ['groups', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -23,8 +23,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, @@ -47,7 +47,7 @@ export const meta = { id: 'd31bebee-196d-42c2-9a3e-9474d4be6cc4', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/groups/update.ts b/packages/backend/src/server/api/endpoints/users/groups/update.ts index 0d188af73..6caf90355 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/update.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/update.ts @@ -7,7 +7,7 @@ import { UserGroups } from '@/models/index'; export const meta = { tags: ['groups'], - requireCredential: true as const, + requireCredential: true, kind: 'write:user-groups', @@ -22,8 +22,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserGroup', }, @@ -34,7 +34,7 @@ export const meta = { id: '9081cda3-7a9e-4fac-a6ce-908d70f282f6', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/create.ts b/packages/backend/src/server/api/endpoints/users/lists/create.ts index 4c89d1b7e..945b51162 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/create.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/create.ts @@ -7,7 +7,7 @@ import { UserList } from '@/models/entities/user-list'; export const meta = { tags: ['lists'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -18,11 +18,11 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserList', }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/delete.ts b/packages/backend/src/server/api/endpoints/users/lists/delete.ts index 0f2495dc2..3183d2a09 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/delete.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/delete.ts @@ -7,7 +7,7 @@ import { UserLists } from '@/models/index'; export const meta = { tags: ['lists'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -24,7 +24,7 @@ export const meta = { id: '78436795-db79-42f5-b1e2-55ea2cf19166', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/list.ts b/packages/backend/src/server/api/endpoints/users/lists/list.ts index 4cf7db69a..ae66b0aac 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/list.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/list.ts @@ -4,20 +4,20 @@ import { UserLists } from '@/models/index'; export const meta = { tags: ['lists', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserList', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/pull.ts b/packages/backend/src/server/api/endpoints/users/lists/pull.ts index 980d90c61..4c74aefa8 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/pull.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/pull.ts @@ -9,7 +9,7 @@ import { UserLists, UserListJoinings, Users } from '@/models/index'; export const meta = { tags: ['lists', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -36,7 +36,7 @@ export const meta = { id: '588e7f72-c744-4a61-b180-d354e912bda2', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/push.ts b/packages/backend/src/server/api/endpoints/users/lists/push.ts index a0ca314f3..8b50c475b 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/push.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/push.ts @@ -9,7 +9,7 @@ import { UserLists, UserListJoinings, Blockings } from '@/models/index'; export const meta = { tags: ['lists', 'users'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -48,7 +48,7 @@ export const meta = { id: '990232c5-3f9d-4d83-9f3f-ef27b6332a4b', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/show.ts b/packages/backend/src/server/api/endpoints/users/lists/show.ts index 5822c0697..06555c1a8 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/show.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/show.ts @@ -7,7 +7,7 @@ import { UserLists } from '@/models/index'; export const meta = { tags: ['lists', 'account'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', @@ -18,8 +18,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserList', }, @@ -30,7 +30,7 @@ export const meta = { id: '7bc05c21-1d7a-41ae-88f1-66820f4dc686', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/lists/update.ts b/packages/backend/src/server/api/endpoints/users/lists/update.ts index 50fcf6ff5..02b0d5fe1 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/update.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/update.ts @@ -7,7 +7,7 @@ import { UserLists } from '@/models/index'; export const meta = { tags: ['lists'], - requireCredential: true as const, + requireCredential: true, kind: 'write:account', @@ -22,8 +22,8 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'UserList', }, @@ -34,7 +34,7 @@ export const meta = { id: '796666fe-3dff-4d39-becb-8a5932c1d5b7', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 2069eb60a..99158fb0a 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -66,11 +66,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'Note', }, }, @@ -82,7 +82,7 @@ export const meta = { id: '27e494ba-2ac2-48e8-893b-10d4d8c2387b', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/pages.ts b/packages/backend/src/server/api/endpoints/users/pages.ts index 9fb985dc1..6e003dd1a 100644 --- a/packages/backend/src/server/api/endpoints/users/pages.ts +++ b/packages/backend/src/server/api/endpoints/users/pages.ts @@ -25,7 +25,7 @@ export const meta = { validator: $.optional.type(ID), }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, user) => { diff --git a/packages/backend/src/server/api/endpoints/users/reactions.ts b/packages/backend/src/server/api/endpoints/users/reactions.ts index 6f68aca18..312d4dbf2 100644 --- a/packages/backend/src/server/api/endpoints/users/reactions.ts +++ b/packages/backend/src/server/api/endpoints/users/reactions.ts @@ -9,7 +9,7 @@ import { ApiError } from '../../error'; export const meta = { tags: ['users', 'reactions'], - requireCredential: false as const, + requireCredential: false, params: { userId: { @@ -39,11 +39,11 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'NoteReaction', }, }, @@ -55,7 +55,7 @@ export const meta = { id: '673a7dd2-6924-1093-e0c0-e68456ceae5c', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/recommendation.ts b/packages/backend/src/server/api/endpoints/users/recommendation.ts index 5e640330c..9ea39eb2d 100644 --- a/packages/backend/src/server/api/endpoints/users/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/users/recommendation.ts @@ -8,7 +8,7 @@ import { generateBlockedUserQuery, generateBlockQueryForUsers } from '../../comm export const meta = { tags: ['users'], - requireCredential: true as const, + requireCredential: true, kind: 'read:account', @@ -25,15 +25,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + type: 'object', + optional: false, nullable: false, + ref: 'UserDetailed', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/relation.ts b/packages/backend/src/server/api/endpoints/users/relation.ts index 629c1d0c1..7e319ca10 100644 --- a/packages/backend/src/server/api/endpoints/users/relation.ts +++ b/packages/backend/src/server/api/endpoints/users/relation.ts @@ -6,7 +6,7 @@ import { Users } from '@/models/index'; export const meta = { tags: ['users'], - requireCredential: true as const, + requireCredential: true, params: { userId: { @@ -15,92 +15,91 @@ export const meta = { }, res: { + optional: false, nullable: false, oneOf: [ { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, isFollowing: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, hasPendingFollowRequestFromYou: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, hasPendingFollowRequestToYou: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isFollowed: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isBlocking: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isBlocked: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isMuted: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, }, }, { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, properties: { id: { - type: 'string' as const, - optional: false as const, nullable: false as const, + type: 'string', + optional: false, nullable: false, format: 'id', }, isFollowing: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, hasPendingFollowRequestFromYou: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, hasPendingFollowRequestToYou: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isFollowed: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isBlocking: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isBlocked: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, isMuted: { - type: 'boolean' as const, - optional: false as const, nullable: false as const, + type: 'boolean', + optional: false, nullable: false, }, }, }, }, ], }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts index bd80710fe..ed2aa7bb2 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -13,7 +13,7 @@ import { fetchMeta } from '@/misc/fetch-meta'; export const meta = { tags: ['users'], - requireCredential: true as const, + requireCredential: true, params: { userId: { @@ -44,7 +44,7 @@ export const meta = { id: '35e166f5-05fb-4f87-a2d5-adb42676d48f', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts index b9cf332f4..d67625e62 100644 --- a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts +++ b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts @@ -8,7 +8,7 @@ import { User } from '@/models/entities/user'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { username: { @@ -31,15 +31,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'User', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { @@ -112,6 +112,6 @@ export default define(meta, async (ps, me) => { .getMany(); } - return await Users.packMany(users, me, { detail: ps.detail }); + return await Users.packMany(users, me, { detail: !!ps.detail }); } }); diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index 35f1988fc..26f818afc 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -7,7 +7,7 @@ import { Brackets } from 'typeorm'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { query: { @@ -36,15 +36,15 @@ export const meta = { }, res: { - type: 'array' as const, - optional: false as const, nullable: false as const, + type: 'array', + optional: false, nullable: false, items: { - type: 'object' as const, - optional: false as const, nullable: false as const, + type: 'object', + optional: false, nullable: false, ref: 'User', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts index e8b2a781f..92910e9ed 100644 --- a/packages/backend/src/server/api/endpoints/users/show.ts +++ b/packages/backend/src/server/api/endpoints/users/show.ts @@ -11,7 +11,7 @@ import { User } from '@/models/entities/user'; export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { userId: { @@ -32,9 +32,20 @@ export const meta = { }, res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - ref: 'User', + optional: false, nullable: false, + oneOf: [ + { + type: 'object', + ref: 'UserDetailed', + }, + { + type: 'array', + items: { + type: 'object', + ref: 'UserDetailed', + } + }, + ] }, errors: { @@ -42,7 +53,7 @@ export const meta = { message: 'Failed to resolve remote user.', code: 'FAILED_TO_RESOLVE_REMOTE_USER', id: 'ef7b9be4-9cba-4e6f-ab41-90ed171c7d3c', - kind: 'server' as const, + kind: 'server', }, noSuchUser: { @@ -51,7 +62,7 @@ export const meta = { id: '4362f8dc-731f-4ad8-a694-be5a88922a24', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/endpoints/users/stats.ts b/packages/backend/src/server/api/endpoints/users/stats.ts index 84bbd16f0..381e43347 100644 --- a/packages/backend/src/server/api/endpoints/users/stats.ts +++ b/packages/backend/src/server/api/endpoints/users/stats.ts @@ -7,7 +7,7 @@ import { DriveFiles, Followings, NoteFavorites, NoteReactions, Notes, PageLikes, export const meta = { tags: ['users'], - requireCredential: false as const, + requireCredential: false, params: { userId: { @@ -22,7 +22,7 @@ export const meta = { id: '9e638e45-3b25-4ef7-8f95-07e8498f1819', }, }, -}; +} as const; // eslint-disable-next-line import/no-default-export export default define(meta, async (ps, me) => { diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index 723b3e884..eb42667fd 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -1,6 +1,6 @@ -import { refs, Schema } from '@/misc/schema'; +import { refs, MinimumSchema } from '@/misc/schema'; -export function convertSchemaToOpenApiSchema(schema: Schema) { +export function convertSchemaToOpenApiSchema(schema: MinimumSchema) { const res: any = schema; if (schema.type === 'object' && schema.properties) { @@ -15,6 +15,10 @@ export function convertSchemaToOpenApiSchema(schema: Schema) { res.items = convertSchemaToOpenApiSchema(schema.items); } + if (schema.anyOf) res.anyOf = schema.anyOf.map(convertSchemaToOpenApiSchema); + if (schema.oneOf) res.oneOf = schema.oneOf.map(convertSchemaToOpenApiSchema); + if (schema.allOf) res.allOf = schema.allOf.map(convertSchemaToOpenApiSchema); + if (schema.ref) { res.$ref = `#/components/schemas/${schema.ref}`; } diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts index 168f1b344..e70c26f5e 100644 --- a/packages/backend/src/server/api/stream/types.ts +++ b/packages/backend/src/server/api/stream/types.ts @@ -36,7 +36,7 @@ export interface UserStreamTypes { updateUserProfile: UserProfile; mute: User; unmute: User; - follow: Packed<'User'>; + follow: Packed<'UserDetailedNotMe'>; unfollow: Packed<'User'>; userAdded: Packed<'User'>; } @@ -46,7 +46,7 @@ export interface MainStreamTypes { mention: Packed<'Note'>; reply: Packed<'Note'>; renote: Packed<'Note'>; - follow: Packed<'User'>; + follow: Packed<'UserDetailedNotMe'>; followed: Packed<'User'>; unfollow: Packed<'User'>; meUpdated: Packed<'User'>; diff --git a/packages/backend/src/services/chart/core.ts b/packages/backend/src/services/chart/core.ts index f97fa521d..e406449f4 100644 --- a/packages/backend/src/services/chart/core.ts +++ b/packages/backend/src/services/chart/core.ts @@ -7,7 +7,7 @@ import * as nestedProperty from 'nested-property'; import autobind from 'autobind-decorator'; import Logger from '../logger'; -import { SimpleSchema } from '@/misc/simple-schema'; +import { Schema } from '@/misc/schema'; import { EntitySchema, getRepository, Repository, LessThan, Between } from 'typeorm'; import { dateUTC, isTimeSame, isTimeBefore, subtractTime, addTime } from '@/prelude/time'; import { getChartInsertLock } from '@/misc/app-lock'; @@ -57,7 +57,7 @@ export default abstract class Chart> { diff: DeepPartial; group: string | null; }[] = []; - public schema: SimpleSchema; + public schema: Schema; protected repositoryForHour: Repository; protected repositoryForDay: Repository; @@ -71,7 +71,7 @@ export default abstract class Chart> { protected abstract fetchActual(group: string | null): Promise>; @autobind - private static convertSchemaToFlatColumnDefinitions(schema: SimpleSchema) { + private static convertSchemaToFlatColumnDefinitions(schema: Schema) { const columns = {} as Record; const flatColumns = (x: Obj, path?: string) => { for (const [k, v] of Object.entries(x)) { @@ -183,7 +183,7 @@ export default abstract class Chart> { } @autobind - public static schemaToEntity(name: string, schema: SimpleSchema, grouped = false): { + public static schemaToEntity(name: string, schema: Schema, grouped = false): { hour: EntitySchema, day: EntitySchema, } { @@ -233,7 +233,7 @@ export default abstract class Chart> { }; } - constructor(name: string, schema: SimpleSchema, grouped = false) { + constructor(name: string, schema: Schema, grouped = false) { this.name = name; this.schema = schema; @@ -573,8 +573,8 @@ export default abstract class Chart> { } } -export function convertLog(logSchema: SimpleSchema): SimpleSchema { - const v: SimpleSchema = JSON.parse(JSON.stringify(logSchema)); // copy +export function convertLog(logSchema: Schema): Schema { + const v: Schema = JSON.parse(JSON.stringify(logSchema)); // copy if (v.type === 'number') { v.type = 'array'; v.items = { diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index 45bd22658..bc5ac275b 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -14,6 +14,7 @@ import { instanceChart, perUserFollowingChart } from '@/services/chart/index'; import { genId } from '@/misc/gen-id'; import { createNotification } from '../create-notification'; import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error'; +import { Packed } from '@/misc/schema'; const logger = new Logger('following/create'); @@ -89,8 +90,8 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[ Users.pack(followee.id, follower, { detail: true, }).then(packed => { - publishUserEvent(follower.id, 'follow', packed); - publishMainStream(follower.id, 'follow', packed); + publishUserEvent(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">); + publishMainStream(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">); }); }