diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index 164ce7b5f..bbeaaf864 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -1,4 +1,4 @@ -import { localUsernameSchema, passwordSchema } from "./schema/user"; +import { localUsernameSchema, passwordSchema } from "./schemas/user"; export type RolePolicies = { gtlAvailable: boolean; diff --git a/packages/misskey-js/src/schema/note.ts b/packages/misskey-js/src/schema/note.ts deleted file mode 100644 index 58ef425dc..000000000 --- a/packages/misskey-js/src/schema/note.ts +++ /dev/null @@ -1,174 +0,0 @@ -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', - }, - deletedAt: { - type: 'string', - optional: true, nullable: true, - 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, - }, - reactionAcceptance: { - 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/misskey-js/src/schema/antenna.ts b/packages/misskey-js/src/schemas/antenna.ts similarity index 80% rename from packages/misskey-js/src/schema/antenna.ts rename to packages/misskey-js/src/schemas/antenna.ts index d0c7e7c23..ac7ea65b3 100644 --- a/packages/misskey-js/src/schema/antenna.ts +++ b/packages/misskey-js/src/schemas/antenna.ts @@ -1,4 +1,6 @@ export const packedAntennaSchema = { + $id: '/schemas/Antenna', + type: 'object', properties: { id: { @@ -69,21 +71,21 @@ export const packedAntennaSchema = { type: 'boolean', default: false, }, - required: [ - 'id', - 'createdAt', - 'name', - 'keywords', - 'excludeKeywords', - 'src', - 'userListId', - 'users', - 'caseSensitive', - 'notify', - 'withReplies', - 'withFile', - 'isActive', - 'hasUnreadNote', - ], }, + required: [ + 'id', + 'createdAt', + 'name', + 'keywords', + 'excludeKeywords', + 'src', + 'userListId', + 'users', + 'caseSensitive', + 'notify', + 'withReplies', + 'withFile', + 'isActive', + 'hasUnreadNote', + ], } as const; diff --git a/packages/misskey-js/src/schema/app.ts b/packages/misskey-js/src/schemas/app.ts similarity index 100% rename from packages/misskey-js/src/schema/app.ts rename to packages/misskey-js/src/schemas/app.ts diff --git a/packages/misskey-js/src/schema/blocking.ts b/packages/misskey-js/src/schemas/blocking.ts similarity index 100% rename from packages/misskey-js/src/schema/blocking.ts rename to packages/misskey-js/src/schemas/blocking.ts diff --git a/packages/misskey-js/src/schema/channel.ts b/packages/misskey-js/src/schemas/channel.ts similarity index 100% rename from packages/misskey-js/src/schema/channel.ts rename to packages/misskey-js/src/schemas/channel.ts diff --git a/packages/misskey-js/src/schema/clip.ts b/packages/misskey-js/src/schemas/clip.ts similarity index 100% rename from packages/misskey-js/src/schema/clip.ts rename to packages/misskey-js/src/schemas/clip.ts diff --git a/packages/misskey-js/src/schema/drive-file.ts b/packages/misskey-js/src/schemas/drive-file.ts similarity index 100% rename from packages/misskey-js/src/schema/drive-file.ts rename to packages/misskey-js/src/schemas/drive-file.ts diff --git a/packages/misskey-js/src/schema/drive-folder.ts b/packages/misskey-js/src/schemas/drive-folder.ts similarity index 100% rename from packages/misskey-js/src/schema/drive-folder.ts rename to packages/misskey-js/src/schemas/drive-folder.ts diff --git a/packages/misskey-js/src/schema/emoji.ts b/packages/misskey-js/src/schemas/emoji.ts similarity index 100% rename from packages/misskey-js/src/schema/emoji.ts rename to packages/misskey-js/src/schemas/emoji.ts diff --git a/packages/misskey-js/src/schema/federation-instance.ts b/packages/misskey-js/src/schemas/federation-instance.ts similarity index 100% rename from packages/misskey-js/src/schema/federation-instance.ts rename to packages/misskey-js/src/schemas/federation-instance.ts diff --git a/packages/misskey-js/src/schema/flash.ts b/packages/misskey-js/src/schemas/flash.ts similarity index 100% rename from packages/misskey-js/src/schema/flash.ts rename to packages/misskey-js/src/schemas/flash.ts diff --git a/packages/misskey-js/src/schema/following.ts b/packages/misskey-js/src/schemas/following.ts similarity index 100% rename from packages/misskey-js/src/schema/following.ts rename to packages/misskey-js/src/schemas/following.ts diff --git a/packages/misskey-js/src/schema/gallery-post.ts b/packages/misskey-js/src/schemas/gallery-post.ts similarity index 100% rename from packages/misskey-js/src/schema/gallery-post.ts rename to packages/misskey-js/src/schemas/gallery-post.ts diff --git a/packages/misskey-js/src/schema/hashtag.ts b/packages/misskey-js/src/schemas/hashtag.ts similarity index 100% rename from packages/misskey-js/src/schema/hashtag.ts rename to packages/misskey-js/src/schemas/hashtag.ts diff --git a/packages/misskey-js/src/schemas/id.ts b/packages/misskey-js/src/schemas/id.ts new file mode 100644 index 000000000..810767eac --- /dev/null +++ b/packages/misskey-js/src/schemas/id.ts @@ -0,0 +1,6 @@ +export const IdSchema = { + $id: '/schemas/Id', + type: 'string', + format: 'id', + example: 'xxxxxxxxxx', +}; diff --git a/packages/misskey-js/src/schema/muting.ts b/packages/misskey-js/src/schemas/muting.ts similarity index 100% rename from packages/misskey-js/src/schema/muting.ts rename to packages/misskey-js/src/schemas/muting.ts diff --git a/packages/misskey-js/src/schema/note-favorite.ts b/packages/misskey-js/src/schemas/note-favorite.ts similarity index 100% rename from packages/misskey-js/src/schema/note-favorite.ts rename to packages/misskey-js/src/schemas/note-favorite.ts diff --git a/packages/misskey-js/src/schema/note-reaction.ts b/packages/misskey-js/src/schemas/note-reaction.ts similarity index 100% rename from packages/misskey-js/src/schema/note-reaction.ts rename to packages/misskey-js/src/schemas/note-reaction.ts diff --git a/packages/misskey-js/src/schemas/note.ts b/packages/misskey-js/src/schemas/note.ts new file mode 100644 index 000000000..82c8b36cd --- /dev/null +++ b/packages/misskey-js/src/schemas/note.ts @@ -0,0 +1,159 @@ +export const packedNoteSchema = { + $id: '/schemas/Note', + + type: 'object', + properties: { + id: { + type: 'string', + $ref: '/schemas/Id', + }, + createdAt: { + type: 'string', + format: 'date-time', + }, + deletedAt: { + oneOf: [{ + type: 'string', + format: 'date-time', + }, { type: 'null' }], + }, + text: { + type: 'string', + optional: false, nullable: true, + }, + cw: { + oneOf: [{ type: 'string' }, { type: 'null' }], + }, + userId: { + type: 'string', + $ref: '/schemas/Id', + }, + user: { + type: 'object', + $ref: '/schemas/UserLite', + }, + replyId: { + oneOf: [{ + type: 'string', + $ref: '/schemas/Id', + }, { type: 'null' }], + }, + renoteId: { + oneOf: [{ + type: 'string', + $ref: '/schemas/Id', + }, { type: 'null' }], + }, + reply: { + oneOf: [{ + $ref: '/schemas/Note', + }, { type: 'null' }], + }, + renote: { + oneOf: [{ + $ref: '/schemas/Note', + }, { type: 'null' }], + }, + isHidden: { + type: 'boolean', + }, + visibility: { + type: 'string', + }, + mentions: { + type: 'array', + items: { + type: 'string', + $ref: '/schemas/Id', + }, + }, + visibleUserIds: { + type: 'array', + items: { + type: 'string', + $ref: '/schemas/Id', + }, + }, + fileIds: { + type: 'array', + items: { + type: 'string', + $ref: '/schemas/Id', + }, + }, + files: { + type: 'array', + items: { + $ref: '/schemas/DriveFile', + }, + }, + tags: { + type: 'array', + items: { + type: 'string', + }, + }, + poll: { + oneOf: [{ + type: 'object', + $ref: '/schemas/Poll', + }, { type: 'null' }], + }, + channelId: { + oneOf: [{ + type: 'string', + $ref: '/schemas/Id', + }, { type: 'null' }], + }, + channel: { + oneOf: [{ + type: 'object', + properties: { + id: { type: 'string' }, + name: { type: 'string' }, + color: { type: 'string' }, + }, + required: ['id', 'name', 'color'], + }, { type: 'null' }], + }, + localOnly: { + type: 'boolean', + }, + reactionAcceptance: { + oneOf: [{ + enum: ['likeOnly', 'likeOnlyForRemote'] + }, { type: 'null' }], + }, + reactions: { + type: 'object', + }, + renoteCount: { + type: 'number', + optional: false, nullable: false, + }, + repliesCount: { + type: 'number', + }, + uri: { + type: 'string', + }, + url: { + type: 'string', + }, + myReaction: { + type: 'object', + }, + }, + required: [ + 'id', + 'createdAt', + 'text', + 'userId', + 'user', + 'visibility', + 'reactionAcceptance', + 'reactions', + 'renoteCount', + 'repliesCount', + ], +} as const; diff --git a/packages/misskey-js/src/schema/notification.ts b/packages/misskey-js/src/schemas/notification.ts similarity index 100% rename from packages/misskey-js/src/schema/notification.ts rename to packages/misskey-js/src/schemas/notification.ts diff --git a/packages/misskey-js/src/schema/page.ts b/packages/misskey-js/src/schemas/page.ts similarity index 100% rename from packages/misskey-js/src/schema/page.ts rename to packages/misskey-js/src/schemas/page.ts diff --git a/packages/misskey-js/src/schema/queue.ts b/packages/misskey-js/src/schemas/queue.ts similarity index 100% rename from packages/misskey-js/src/schema/queue.ts rename to packages/misskey-js/src/schemas/queue.ts diff --git a/packages/misskey-js/src/schema/renote-muting.ts b/packages/misskey-js/src/schemas/renote-muting.ts similarity index 100% rename from packages/misskey-js/src/schema/renote-muting.ts rename to packages/misskey-js/src/schemas/renote-muting.ts diff --git a/packages/misskey-js/src/schema/user-list.ts b/packages/misskey-js/src/schemas/user-list.ts similarity index 100% rename from packages/misskey-js/src/schema/user-list.ts rename to packages/misskey-js/src/schemas/user-list.ts diff --git a/packages/misskey-js/src/schema/user.ts b/packages/misskey-js/src/schemas/user.ts similarity index 100% rename from packages/misskey-js/src/schema/user.ts rename to packages/misskey-js/src/schemas/user.ts