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,
EmojiDetailed: packedEmojiDetailedSchema,
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 = [
typeof IdSchema,
typeof packedAntennaSchema,
typeof packedNoteSchema,
...UnionToArray<Refs>,
];
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 PackedNote = Packed<'Note'>;
export type PackedUser = Packed<'User'>;
export type DefNote = Def<'https://misskey-hub.net/api/schemas/Note'>;
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 = {
$id: 'https://misskey-hub.net/api/schemas/UserLite',
@ -63,6 +63,7 @@ export const packedUserLiteSchema = {
export const packedUserDetailedNotMeOnlySchema = {
$id: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly',
type: 'object',
oneOf: [{
$ref: '#/$defs/base',
}, {
@ -297,204 +298,199 @@ export const packedUserDetailedNotMeOnlySchema = {
} as const satisfies JSONSchema7Definition;
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',
properties: {
avatarId: {
type: 'string',
nullable: true, optional: false,
format: 'id',
oneOf: [{
$ref: 'https://misskey-hub.net/api/schemas/Id',
}, {
type: 'null',
}],
},
bannerId: {
type: 'string',
nullable: true, optional: false,
format: 'id',
oneOf: [{
$ref: 'https://misskey-hub.net/api/schemas/Id',
}, {
type: 'null',
}],
},
injectFeaturedNote: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
receiveAnnouncementEmail: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
alwaysMarkNsfw: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
autoSensitive: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
carefulBot: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
autoAcceptFollowed: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
noCrawle: {
type: 'boolean',
nullable: true, optional: false,
type: ['boolean', 'null'],
},
preventAiLarning: {
type: 'boolean',
nullable: false, 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,
},
hasUnreadNotification: {
type: 'boolean',
nullable: false, optional: false,
},
hasPendingReceivedFollowRequest: {
type: 'boolean',
nullable: false, optional: false,
},
mutedWords: {
type: 'array',
nullable: false, optional: false,
items: {
type: 'array',
nullable: false, optional: false,
items: {
type: 'string',
nullable: false, optional: false,
},
},
},
mutedInstances: {
oneOf: [{
type: 'array',
nullable: true, optional: false,
items: {
type: 'string',
nullable: false, optional: false,
},
}, {
type: 'null',
}],
},
mutingNotificationTypes: {
oneOf: [{
type: 'array',
nullable: true, optional: false,
items: {
type: 'string',
nullable: false, optional: false,
},
}, {
type: 'null',
}],
},
emailNotificationTypes: {
oneOf: [{
type: 'array',
nullable: true, optional: false,
items: {
type: 'string',
nullable: false, optional: false,
},
}, {
type: 'null',
}],
},
},
//#region secrets
},
secrets: {
type: 'object',
properties: {
email: {
type: 'string',
nullable: true, optional: true,
type: ['string', 'null'],
},
emailVerified: {
type: 'boolean',
nullable: true, optional: true,
type: ['boolean', 'null'],
},
securityKeysList: {
type: 'array',
nullable: false, optional: true,
items: {
type: 'object',
nullable: false, optional: false,
additionalProperties: true,
},
},
//#endregion
},
} as const;
required: [
'email',
'emailVerified',
'securityKeysList',
],
},
},
} as const satisfies JSONSchema7Definition;
export const packedUserDetailedNotMeSchema = {
$id: 'https://misskey-hub.net/api/schemas/UserDetailedNotMe',
type: 'object',
allOf: [
{
type: 'object',
ref: 'UserLite',
},
{
type: 'object',
ref: 'UserDetailedNotMeOnly',
},
],
} as const;
allOf: [{
$ref: 'https://misskey-hub.net/api/schemas/UserLite',
}, {
$ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly',
}],
} as const satisfies JSONSchema7Definition;
export const packedMeDetailedSchema = {
$id: 'https://misskey-hub.net/api/schemas/MeDetailed',
type: 'object',
allOf: [
{
type: 'object',
ref: 'UserLite',
},
{
type: 'object',
ref: 'UserDetailedNotMeOnly',
},
{
type: 'object',
ref: 'MeDetailedOnly',
},
],
} as const;
allOf: [{
$ref: 'https://misskey-hub.net/api/schemas/UserLite',
}, {
$ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMeOnly',
}, {
$ref: 'https://misskey-hub.net/api/schemas/MeDetailedOnly',
}],
} as const satisfies JSONSchema7Definition;
export const packedUserDetailedSchema = {
oneOf: [
{
$id: 'https://misskey-hub.net/api/schemas/UserDetailed',
type: 'object',
ref: 'UserDetailedNotMe',
},
{
type: 'object',
ref: 'MeDetailed',
},
],
} as const;
oneOf: [{
$ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMe',
}, {
$ref: 'https://misskey-hub.net/api/schemas/MeDetailed',
}],
} as const satisfies JSONSchema7Definition;
export const packedUserSchema = {
oneOf: [
{
type: 'object',
ref: 'UserLite',
},
{
type: 'object',
ref: 'UserDetailed',
},
],
} as const;
$id: 'https://misskey-hub.net/api/schemas/User',
export const localUsernameSchema = { type: 'string', pattern: /^\w{1,20}$/.toString().slice(1, -1) } as const;
export const passwordSchema = { type: 'string', minLength: 1 } as const;
export const nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
export const descriptionSchema = { type: 'string', minLength: 1, maxLength: 1500 } as const;
export const locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
export const birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const;
type: 'object',
oneOf: [{
$ref: 'https://misskey-hub.net/api/schemas/UserLite',
}, {
$ref: 'https://misskey-hub.net/api/schemas/UserDetailed',
}],
} 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
summaly:
specifier: github:misskey-dev/summaly
version: github.com/misskey-dev/summaly/2d63e2a0066f89871e777cc81d43c1ade8c97517
version: github.com/misskey-dev/summaly/77dd5654bb82280b38c1f50e51a771c33f3df503
systeminformation:
specifier: 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)
summaly:
specifier: github:misskey-dev/summaly
version: github.com/misskey-dev/summaly/2d63e2a0066f89871e777cc81d43c1ade8c97517
version: github.com/misskey-dev/summaly/77dd5654bb82280b38c1f50e51a771c33f3df503
vite-plugin-turbosnap:
specifier: 1.0.2
version: 1.0.2
@ -1020,7 +1020,7 @@ importers:
version: 4.4.0
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:
specifier: ^9.3.2
version: 9.3.2(typescript@5.0.4)
@ -20321,9 +20321,9 @@ packages:
version: 2.2.1-misskey.3
dev: false
github.com/misskey-dev/schema-type/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854}
id: github.com/misskey-dev/schema-type/d50e5ea86b7aeb3a6ddfba0717e44c016ac42854
github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/c771673a44d514658d4d5a4dd2c201b2294f225b}
id: github.com/misskey-dev/schema-type/c771673a44d514658d4d5a4dd2c201b2294f225b
name: schema-type
version: 1.0.0
dependencies:
@ -20376,8 +20376,8 @@ packages:
react-dom: 18.2.0(react@18.2.0)
dev: true
github.com/misskey-dev/summaly/2d63e2a0066f89871e777cc81d43c1ade8c97517:
resolution: {tarball: https://codeload.github.com/misskey-dev/summaly/tar.gz/2d63e2a0066f89871e777cc81d43c1ade8c97517}
github.com/misskey-dev/summaly/77dd5654bb82280b38c1f50e51a771c33f3df503:
resolution: {tarball: https://codeload.github.com/misskey-dev/summaly/tar.gz/77dd5654bb82280b38c1f50e51a771c33f3df503}
name: summaly
version: 4.0.2
dependencies: