This commit is contained in:
tamaina 2023-05-10 16:55:36 +00:00
parent ad6c5275ec
commit 56a1e436f3
3 changed files with 192 additions and 196 deletions

View file

@ -64,19 +64,19 @@ export const refs = {
EmojiSimple: packedEmojiSimpleSchema, EmojiSimple: packedEmojiSimpleSchema,
EmojiDetailed: packedEmojiDetailedSchema, EmojiDetailed: packedEmojiDetailedSchema,
Flash: packedFlashSchema, Flash: packedFlashSchema,
} as const /*satisfies { [x: string]: JSONSchema7Definition }*/; } as const satisfies { [x: string]: JSONSchema7Definition };
type Refs = typeof packedAntennaSchema | typeof packedNoteSchema; // TODO: typeof refs[keyof typeof refs]; type Refs = typeof refs[keyof typeof refs];
export type References = [ export type References = [
typeof IdSchema, typeof IdSchema,
typeof packedAntennaSchema, ...UnionToArray<Refs>,
typeof packedNoteSchema,
]; ];
export type Packed<x extends GetKeys<References, 'https://misskey-hub.net/api/schemas/'>> = GetDef<References, x, 'https://misskey-hub.net/api/schemas/'>; export type Packed<x extends GetKeys<References, 'https://misskey-hub.net/api/schemas/'>> = GetDef<References, x, 'https://misskey-hub.net/api/schemas/'>;
export type Def<x extends GetKeys<References>> = GetDef<References, x>; export type Def<x extends GetKeys<References>> = GetDef<References, x>;
export type PackedNote = Packed<'Note'>; export type PackedNote = Packed<'Note'>;
export type PackedUser = Packed<'User'>;
export type DefNote = Def<'https://misskey-hub.net/api/schemas/Note'>; export type DefNote = Def<'https://misskey-hub.net/api/schemas/Note'>;
let renote: PackedNote['reply']; let renote: PackedNote['reply'];

View file

@ -1,4 +1,4 @@
import type { JSONSchema7Definition } from 'schema-type'; import type { JSONSchema7, JSONSchema7Definition } from 'schema-type';
export const packedUserLiteSchema = { export const packedUserLiteSchema = {
$id: 'https://misskey-hub.net/api/schemas/UserLite', $id: 'https://misskey-hub.net/api/schemas/UserLite',
@ -63,6 +63,7 @@ export const packedUserLiteSchema = {
export const packedUserDetailedNotMeOnlySchema = { export const packedUserDetailedNotMeOnlySchema = {
$id: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly', $id: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly',
type: 'object',
oneOf: [{ oneOf: [{
$ref: '#/$defs/base', $ref: '#/$defs/base',
}, { }, {
@ -297,204 +298,199 @@ export const packedUserDetailedNotMeOnlySchema = {
} as const satisfies JSONSchema7Definition; } as const satisfies JSONSchema7Definition;
export const packedMeDetailedOnlySchema = { export const packedMeDetailedOnlySchema = {
$id: 'https://misskey-hub.net/api/schemas/MeDetailedOnly',
type: 'object',
oneOf: [{
$ref: '#/$defs/base',
}, {
allOf: [{ $ref: '#/$defs/base' }, { $ref: '#/$defs/secrets' }],
}],
$defs: {
base: {
type: 'object', type: 'object',
properties: { properties: {
avatarId: { avatarId: {
type: 'string', oneOf: [{
nullable: true, optional: false, $ref: 'https://misskey-hub.net/api/schemas/Id',
format: 'id', }, {
type: 'null',
}],
}, },
bannerId: { bannerId: {
type: 'string', oneOf: [{
nullable: true, optional: false, $ref: 'https://misskey-hub.net/api/schemas/Id',
format: 'id', }, {
type: 'null',
}],
}, },
injectFeaturedNote: { injectFeaturedNote: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
receiveAnnouncementEmail: { receiveAnnouncementEmail: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
alwaysMarkNsfw: { alwaysMarkNsfw: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
autoSensitive: { autoSensitive: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
carefulBot: { carefulBot: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
autoAcceptFollowed: { autoAcceptFollowed: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
noCrawle: { noCrawle: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: false,
}, },
preventAiLarning: { preventAiLarning: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
isExplorable: { isExplorable: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
isDeleted: { isDeleted: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hideOnlineStatus: { hideOnlineStatus: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hasUnreadSpecifiedNotes: { hasUnreadSpecifiedNotes: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hasUnreadMentions: { hasUnreadMentions: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hasUnreadAnnouncement: { hasUnreadAnnouncement: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hasUnreadAntenna: { hasUnreadAntenna: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hasUnreadNotification: { hasUnreadNotification: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
hasPendingReceivedFollowRequest: { hasPendingReceivedFollowRequest: {
type: 'boolean', type: 'boolean',
nullable: false, optional: false,
}, },
mutedWords: { mutedWords: {
type: 'array', type: 'array',
nullable: false, optional: false,
items: { items: {
type: 'array', type: 'array',
nullable: false, optional: false,
items: { items: {
type: 'string', type: 'string',
nullable: false, optional: false,
}, },
}, },
}, },
mutedInstances: { mutedInstances: {
oneOf: [{
type: 'array', type: 'array',
nullable: true, optional: false,
items: { items: {
type: 'string', type: 'string',
nullable: false, optional: false,
}, },
}, {
type: 'null',
}],
}, },
mutingNotificationTypes: { mutingNotificationTypes: {
oneOf: [{
type: 'array', type: 'array',
nullable: true, optional: false,
items: { items: {
type: 'string', type: 'string',
nullable: false, optional: false,
}, },
}, {
type: 'null',
}],
}, },
emailNotificationTypes: { emailNotificationTypes: {
oneOf: [{
type: 'array', type: 'array',
nullable: true, optional: false,
items: { items: {
type: 'string', type: 'string',
nullable: false, optional: false, },
}, {
type: 'null',
}],
}, },
}, },
//#region secrets },
secrets: {
type: 'object',
properties: {
email: { email: {
type: 'string', type: ['string', 'null'],
nullable: true, optional: true,
}, },
emailVerified: { emailVerified: {
type: 'boolean', type: ['boolean', 'null'],
nullable: true, optional: true,
}, },
securityKeysList: { securityKeysList: {
type: 'array', type: 'array',
nullable: false, optional: true,
items: { items: {
type: 'object', type: 'object',
nullable: false, optional: false, additionalProperties: true,
}, },
}, },
//#endregion
}, },
} as const; required: [
'email',
'emailVerified',
'securityKeysList',
],
},
},
} as const satisfies JSONSchema7Definition;
export const packedUserDetailedNotMeSchema = { export const packedUserDetailedNotMeSchema = {
$id: 'https://misskey-hub.net/api/schemas/UserDetailedNotMe',
type: 'object', type: 'object',
allOf: [ allOf: [{
{ $ref: 'https://misskey-hub.net/api/schemas/UserLite',
type: 'object', }, {
ref: 'UserLite', $ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly',
}, }],
{ } as const satisfies JSONSchema7Definition;
type: 'object',
ref: 'UserDetailedNotMeOnly',
},
],
} as const;
export const packedMeDetailedSchema = { export const packedMeDetailedSchema = {
$id: 'https://misskey-hub.net/api/schemas/MeDetailed',
type: 'object', type: 'object',
allOf: [ allOf: [{
{ $ref: 'https://misskey-hub.net/api/schemas/UserLite',
type: 'object', }, {
ref: 'UserLite', $ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly',
}, }, {
{ $ref: 'https://misskey-hub.net/api/schemas/MeDetailedOnly',
type: 'object', }],
ref: 'UserDetailedNotMeOnly', } as const satisfies JSONSchema7Definition;
},
{
type: 'object',
ref: 'MeDetailedOnly',
},
],
} as const;
export const packedUserDetailedSchema = { export const packedUserDetailedSchema = {
oneOf: [ $id: 'https://misskey-hub.net/api/schemas/UserDetailed',
{
type: 'object', type: 'object',
ref: 'UserDetailedNotMe', oneOf: [{
}, $ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMe',
{ }, {
type: 'object', $ref: 'https://misskey-hub.net/api/schemas/MeDetailed',
ref: 'MeDetailed', }],
}, } as const satisfies JSONSchema7Definition;
],
} as const;
export const packedUserSchema = { export const packedUserSchema = {
oneOf: [ $id: 'https://misskey-hub.net/api/schemas/User',
{
type: 'object',
ref: 'UserLite',
},
{
type: 'object',
ref: 'UserDetailed',
},
],
} as const;
export const localUsernameSchema = { type: 'string', pattern: /^\w{1,20}$/.toString().slice(1, -1) } as const; type: 'object',
export const passwordSchema = { type: 'string', minLength: 1 } as const; oneOf: [{
export const nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const; $ref: 'https://misskey-hub.net/api/schemas/UserLite',
export const descriptionSchema = { type: 'string', minLength: 1, maxLength: 1500 } as const; }, {
export const locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const; $ref: 'https://misskey-hub.net/api/schemas/UserDetailed',
export const birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const; }],
} as const satisfies JSONSchema7Definition;
export const localUsernameSchema = { type: 'string', pattern: /^\w{1,20}$/.toString().slice(1, -1) } as const satisfies JSONSchema7;
export const passwordSchema = { type: 'string', minLength: 1 } as const satisfies JSONSchema7;
export const nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const satisfies JSONSchema7;
export const descriptionSchema = { type: 'string', minLength: 1, maxLength: 1500 } as const satisfies JSONSchema7;
export const locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const satisfies JSONSchema7;
export const birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const satisfies JSONSchema7;

View file

@ -348,7 +348,7 @@ importers:
version: 2.1.0 version: 2.1.0
summaly: summaly:
specifier: github:misskey-dev/summaly specifier: github:misskey-dev/summaly
version: github.com/misskey-dev/summaly/2d63e2a0066f89871e777cc81d43c1ade8c97517 version: github.com/misskey-dev/summaly/77dd5654bb82280b38c1f50e51a771c33f3df503
systeminformation: systeminformation:
specifier: 5.17.12 specifier: 5.17.12
version: 5.17.12 version: 5.17.12
@ -984,7 +984,7 @@ importers:
version: github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640(@storybook/blocks@7.0.7)(@storybook/components@7.0.7)(@storybook/core-events@7.0.7)(@storybook/manager-api@7.0.7)(@storybook/preview-api@7.0.7)(@storybook/theming@7.0.7)(@storybook/types@7.0.7)(react-dom@18.2.0)(react@18.2.0) version: github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640(@storybook/blocks@7.0.7)(@storybook/components@7.0.7)(@storybook/core-events@7.0.7)(@storybook/manager-api@7.0.7)(@storybook/preview-api@7.0.7)(@storybook/theming@7.0.7)(@storybook/types@7.0.7)(react-dom@18.2.0)(react@18.2.0)
summaly: summaly:
specifier: github:misskey-dev/summaly specifier: github:misskey-dev/summaly
version: github.com/misskey-dev/summaly/2d63e2a0066f89871e777cc81d43c1ade8c97517 version: github.com/misskey-dev/summaly/77dd5654bb82280b38c1f50e51a771c33f3df503
vite-plugin-turbosnap: vite-plugin-turbosnap:
specifier: 1.0.2 specifier: 1.0.2
version: 1.0.2 version: 1.0.2
@ -1020,7 +1020,7 @@ importers:
version: 4.4.0 version: 4.4.0
schema-type: schema-type:
specifier: github:misskey-dev/schema-type specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854(typescript@5.0.4) version: github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b(typescript@5.0.4)
ts-essentials: ts-essentials:
specifier: ^9.3.2 specifier: ^9.3.2
version: 9.3.2(typescript@5.0.4) version: 9.3.2(typescript@5.0.4)
@ -20321,9 +20321,9 @@ packages:
version: 2.2.1-misskey.3 version: 2.2.1-misskey.3
dev: false dev: false
github.com/misskey-dev/schema-type/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854(typescript@5.0.4): github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854} resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/c771673a44d514658d4d5a4dd2c201b2294f225b}
id: github.com/misskey-dev/schema-type/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854 id: github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b
name: schema-type name: schema-type
version: 1.0.0 version: 1.0.0
dependencies: dependencies:
@ -20376,8 +20376,8 @@ packages:
react-dom: 18.2.0(react@18.2.0) react-dom: 18.2.0(react@18.2.0)
dev: true dev: true
github.com/misskey-dev/summaly/2d63e2a0066f89871e777cc81d43c1ade8c97517: github.com/misskey-dev/summaly/77dd5654bb82280b38c1f50e51a771c33f3df503:
resolution: {tarball: https://codeload.github.com/misskey-dev/summaly/tar.gz/2d63e2a0066f89871e777cc81d43c1ade8c97517} resolution: {tarball: https://codeload.github.com/misskey-dev/summaly/tar.gz/77dd5654bb82280b38c1f50e51a771c33f3df503}
name: summaly name: summaly
version: 4.0.2 version: 4.0.2
dependencies: dependencies: