From f3bc232419c29618d613b23397c55e319b95af09 Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 10 May 2023 15:12:37 +0000 Subject: [PATCH] wip --- packages/misskey-js/src/schemas/hashtag.ts | 24 +++++++---- packages/misskey-js/src/schemas/muting.ts | 42 +++++++++---------- .../misskey-js/src/schemas/note-favorite.ts | 32 +++++++------- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/packages/misskey-js/src/schemas/hashtag.ts b/packages/misskey-js/src/schemas/hashtag.ts index 98f882764..50769306a 100644 --- a/packages/misskey-js/src/schemas/hashtag.ts +++ b/packages/misskey-js/src/schemas/hashtag.ts @@ -1,34 +1,40 @@ +import type { JSONSchema7Definition } from 'schema-type'; + export const packedHashtagSchema = { + $id: 'https://misskey-hub.net/api/schemas/Hashtag', + type: 'object', properties: { tag: { type: 'string', - optional: false, nullable: false, - example: 'misskey', + examples: '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; + required: [ + 'tag', + 'mentionedUsersCount', + 'mentionedLocalUsersCount', + 'mentionedRemoteUsersCount', + 'attachedUsersCount', + 'attachedLocalUsersCount', + 'attachedRemoteUsersCount', + ], +} as const satisfies JSONSchema7Definition; diff --git a/packages/misskey-js/src/schemas/muting.ts b/packages/misskey-js/src/schemas/muting.ts index 3ab99e17e..d38447b9e 100644 --- a/packages/misskey-js/src/schemas/muting.ts +++ b/packages/misskey-js/src/schemas/muting.ts @@ -1,31 +1,31 @@ +import type { JSONSchema7Definition } from 'schema-type'; + export const packedMutingSchema = { + $id: 'https://misskey-hub.net/api/schemas/Muting', + type: 'object', properties: { - id: { - type: 'string', - optional: false, nullable: false, - format: 'id', - example: 'xxxxxxxxxx', - }, + id: { $ref: 'https://misskey-hub.net/api/schemas/Id' }, createdAt: { type: 'string', - optional: false, nullable: false, format: 'date-time', }, expiresAt: { - type: 'string', - optional: false, nullable: true, - format: 'date-time', - }, - muteeId: { - type: 'string', - optional: false, nullable: false, - format: 'id', - }, - mutee: { - type: 'object', - optional: false, nullable: false, - ref: 'UserDetailed', + oneOf: [{ + type: 'string', + format: 'date-time', + }, { + type: 'null', + }], }, + muteeId: { $ref: 'https://misskey-hub.net/api/schemas/Id' }, + mutee: { $ref: 'https://misskey-hub.net/api/schemas/UserDetailed' }, }, -} as const; + required: [ + 'id', + 'createdAt', + 'expiresAt', + 'muteeId', + 'mutee', + ], +} as const satisfies JSONSchema7Definition; diff --git a/packages/misskey-js/src/schemas/note-favorite.ts b/packages/misskey-js/src/schemas/note-favorite.ts index d133f7367..89f435103 100644 --- a/packages/misskey-js/src/schemas/note-favorite.ts +++ b/packages/misskey-js/src/schemas/note-favorite.ts @@ -1,26 +1,22 @@ +import type { JSONSchema7Definition } from 'schema-type'; + export const packedNoteFavoriteSchema = { + $id: 'https://misskey-hub.net/api/schemas/NoteFavorite', + type: 'object', properties: { - id: { - type: 'string', - optional: false, nullable: false, - format: 'id', - example: 'xxxxxxxxxx', - }, + id: { $ref: 'https://misskey-hub.net/api/schemas/Id' }, 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', - }, + noteId: { $ref: 'https://misskey-hub.net/api/schemas/Id' }, + note: { $ref: 'https://misskey-hub.net/api/schemas/Note' }, }, -} as const; + required: [ + 'id', + 'createdAt', + 'note', + 'noteId', + ] +} as const satisfies JSONSchema7Definition;