This commit is contained in:
parent
887f57e682
commit
7105b4db18
|
@ -136,18 +136,19 @@ type PartialIntersection<T> = Partial<UnionToIntersection<T>>;
|
||||||
// https://github.com/misskey-dev/misskey/pull/8144#discussion_r785287552
|
// https://github.com/misskey-dev/misskey/pull/8144#discussion_r785287552
|
||||||
// To get union, we use `Foo extends any ? Hoge<Foo> : never`
|
// To get union, we use `Foo extends any ? Hoge<Foo> : never`
|
||||||
type UnionSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? SchemaType<X> : never;
|
type UnionSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? SchemaType<X> : never;
|
||||||
type UnionObjectSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? ObjectSchemaType<X> : never;
|
//type UnionObjectSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? ObjectSchemaType<X> : never;
|
||||||
|
type UnionObjType<s extends Obj, a extends readonly any[], X extends ReadonlyArray<keyof s> = a[number]> = X extends any ? ObjType<s, X> : never;
|
||||||
type ArrayUnion<T> = T extends any ? Array<T> : never;
|
type ArrayUnion<T> = T extends any ? Array<T> : never;
|
||||||
|
|
||||||
type ObjectSchemaTypeDef<p extends Schema> =
|
type ObjectSchemaTypeDef<p extends Schema> =
|
||||||
p['ref'] extends keyof typeof refs ? Packed<p['ref']> :
|
p['ref'] extends keyof typeof refs ? Packed<p['ref']> :
|
||||||
p['properties'] extends NonNullable<Obj> ?
|
p['properties'] extends NonNullable<Obj> ?
|
||||||
p['anyOf'] extends ReadonlyArray<Schema> ? p['anyOf'][number]['required'] extends ReadonlyArray<keyof p['properties']> ?
|
p['anyOf'] extends ReadonlyArray<Schema> ? p['anyOf'][number]['required'] extends ReadonlyArray<keyof p['properties']> ?
|
||||||
ObjType<p['properties'], NonNullable<p['anyOf'][number]['required']>> & ObjType<p['properties'], NonNullable<p['required']>>
|
UnionObjType<p['properties'], NonNullable<p['anyOf'][number]['required']>> & ObjType<p['properties'], NonNullable<p['required']>>
|
||||||
: never
|
: never
|
||||||
: ObjType<p['properties'], NonNullable<p['required']>>
|
: ObjType<p['properties'], NonNullable<p['required']>>
|
||||||
:
|
:
|
||||||
p['anyOf'] extends ReadonlyArray<Schema> ? UnionObjectSchemaType<p['anyOf']> & PartialIntersection<UnionObjectSchemaType<p['anyOf']>> :
|
p['anyOf'] extends ReadonlyArray<Schema> ? never : // see CONTRIBUTING.md
|
||||||
p['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :
|
p['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :
|
||||||
any
|
any
|
||||||
|
|
||||||
|
|
|
@ -138,19 +138,13 @@ export const meta = {
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
fileId: { type: 'string', format: 'misskey:id' },
|
||||||
|
url: { type: 'string' },
|
||||||
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['fileId'] },
|
||||||
properties: {
|
{ required: ['url'] },
|
||||||
fileId: { type: 'string', format: 'misskey:id' },
|
|
||||||
},
|
|
||||||
required: ['fileId'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
url: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['url'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -39,19 +39,13 @@ export const meta = {
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
fileId: { type: 'string', format: 'misskey:id' },
|
||||||
|
url: { type: 'string' },
|
||||||
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['fileId'] },
|
||||||
properties: {
|
{ required: ['url'] },
|
||||||
fileId: { type: 'string', format: 'misskey:id' },
|
|
||||||
},
|
|
||||||
required: ['fileId'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
url: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['url'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -36,32 +36,25 @@ export const paramDef = {
|
||||||
sinceId: { type: 'string', format: 'misskey:id' },
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
untilId: { type: 'string', format: 'misskey:id' },
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
|
||||||
|
tag: { type: 'string', minLength: 1 },
|
||||||
|
query: {
|
||||||
|
type: 'array',
|
||||||
|
description: 'The outer arrays are chained with OR, the inner arrays are chained with AND.',
|
||||||
|
items: {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'string',
|
||||||
|
minLength: 1,
|
||||||
|
},
|
||||||
|
minItems: 1,
|
||||||
|
},
|
||||||
|
minItems: 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['tag'] },
|
||||||
properties: {
|
{ required: ['query'] },
|
||||||
tag: { type: 'string', minLength: 1 },
|
|
||||||
},
|
|
||||||
required: ['tag'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
query: {
|
|
||||||
type: 'array',
|
|
||||||
description: 'The outer arrays are chained with OR, the inner arrays are chained with AND.',
|
|
||||||
items: {
|
|
||||||
type: 'array',
|
|
||||||
items: {
|
|
||||||
type: 'string',
|
|
||||||
minLength: 1,
|
|
||||||
},
|
|
||||||
minItems: 1,
|
|
||||||
},
|
|
||||||
minItems: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['query'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -29,20 +29,14 @@ export const meta = {
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
pageId: { type: 'string', format: 'misskey:id' },
|
||||||
|
name: { type: 'string' },
|
||||||
|
username: { type: 'string' },
|
||||||
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['pageId'] },
|
||||||
properties: {
|
{ required: ['name', 'username'] },
|
||||||
pageId: { type: 'string', format: 'misskey:id' },
|
|
||||||
},
|
|
||||||
required: ['pageId'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
name: { type: 'string' },
|
|
||||||
username: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['name', 'username'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -46,25 +46,18 @@ export const paramDef = {
|
||||||
sinceId: { type: 'string', format: 'misskey:id' },
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
untilId: { type: 'string', format: 'misskey:id' },
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
|
||||||
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
|
username: { type: 'string' },
|
||||||
|
host: {
|
||||||
|
type: 'string',
|
||||||
|
nullable: true,
|
||||||
|
description: 'The local host is represented with `null`.',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['userId'] },
|
||||||
properties: {
|
{ required: ['username', 'host'] },
|
||||||
userId: { type: 'string', format: 'misskey:id' },
|
|
||||||
},
|
|
||||||
required: ['userId'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
username: { type: 'string' },
|
|
||||||
host: {
|
|
||||||
type: 'string',
|
|
||||||
nullable: true,
|
|
||||||
description: 'The local host is represented with `null`.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['username', 'host'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -46,25 +46,18 @@ export const paramDef = {
|
||||||
sinceId: { type: 'string', format: 'misskey:id' },
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
untilId: { type: 'string', format: 'misskey:id' },
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
|
||||||
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
|
username: { type: 'string' },
|
||||||
|
host: {
|
||||||
|
type: 'string',
|
||||||
|
nullable: true,
|
||||||
|
description: 'The local host is represented with `null`.',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['userId'] },
|
||||||
properties: {
|
{ required: ['username', 'host'] },
|
||||||
userId: { type: 'string', format: 'misskey:id' },
|
|
||||||
},
|
|
||||||
required: ['userId'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
username: { type: 'string' },
|
|
||||||
host: {
|
|
||||||
type: 'string',
|
|
||||||
nullable: true,
|
|
||||||
description: 'The local host is represented with `null`.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['username', 'host'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -31,20 +31,13 @@ export const paramDef = {
|
||||||
properties: {
|
properties: {
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
detail: { type: 'boolean', default: true },
|
detail: { type: 'boolean', default: true },
|
||||||
|
|
||||||
|
username: { type: 'string', nullable: true },
|
||||||
|
host: { type: 'string', nullable: true },
|
||||||
},
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['username'] },
|
||||||
properties: {
|
{ required: ['host'] },
|
||||||
username: { type: 'string', nullable: true },
|
|
||||||
},
|
|
||||||
required: ['username'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
host: { type: 'string', nullable: true },
|
|
||||||
},
|
|
||||||
required: ['host'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -54,32 +54,22 @@ export const meta = {
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
|
userIds: { type: 'array', uniqueItems: true, items: {
|
||||||
|
type: 'string', format: 'misskey:id',
|
||||||
|
} },
|
||||||
|
username: { type: 'string' },
|
||||||
|
host: {
|
||||||
|
type: 'string',
|
||||||
|
nullable: true,
|
||||||
|
description: 'The local host is represented with `null`.',
|
||||||
|
},
|
||||||
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{ required: ['userId'] },
|
||||||
properties: {
|
{ required: ['userIds'] },
|
||||||
userId: { type: 'string', format: 'misskey:id' },
|
{ required: ['username'] },
|
||||||
},
|
|
||||||
required: ['userId'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
userIds: { type: 'array', uniqueItems: true, items: {
|
|
||||||
type: 'string', format: 'misskey:id',
|
|
||||||
} },
|
|
||||||
},
|
|
||||||
required: ['userIds'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
username: { type: 'string' },
|
|
||||||
host: {
|
|
||||||
type: 'string',
|
|
||||||
nullable: true,
|
|
||||||
description: 'The local host is represented with `null`.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['username'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue