This commit is contained in:
tamaina 2023-05-26 07:48:48 +00:00
parent 82a17ea427
commit b14d3cdc32
3 changed files with 24 additions and 8 deletions

View file

@ -5,8 +5,8 @@ import type { InboxQueue } from '@/core/QueueModule.js';
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
@Injectable() @Injectable()
export default class extends Endpoint<'admin/queue/inboc-delayed'> { export default class extends Endpoint<'admin/queue/inbox-delayed'> {
name = 'admin/queue/inboc-delayed' as const; name = 'admin/queue/inbox-delayed' as const;
constructor( constructor(
@Inject('queue:inbox') public inboxQueue: InboxQueue, @Inject('queue:inbox') public inboxQueue: InboxQueue,
) { ) {

View file

@ -930,7 +930,7 @@ export const endpoints = {
}, },
}], }],
}, },
'admin/queue/inboc-delayed': { 'admin/queue/inbox-delayed': {
tags: ['admin'], tags: ['admin'],
requireCredential: true, requireCredential: true,

View file

@ -24,10 +24,31 @@ export type RolePolicies = {
}; };
export type EndpointDefines = ReadonlyArray<{ export type EndpointDefines = ReadonlyArray<{
/**
* JSON Schema
* undefined
* $refは使えない(ajv由来)
*/
req: DeepOmit<JSONSchema7, { $ref: never }> | undefined; req: DeepOmit<JSONSchema7, { $ref: never }> | undefined;
/**
* JSON Schema
* undefined
*/
res: JSONSchema7 | undefined; res: JSONSchema7 | undefined;
}>; }>;
/**
* JSON Schemaのとき型に変換しundefinedのときvoid | Record<string, never>
*/
export type SchemaOrUndefined<T extends JSONSchema7 | undefined, IsResponse extends boolean = false> = T extends JSONSchema7 ? SchemaType<T, References, IsResponse> : (void | Record<string, never>);
/**
* reqからresを推論する
*/
export type ResponseOf<D extends IEndpointMeta, P, IsResponse extends boolean = false, DD extends D['defines'][number] = D['defines'][number]> =
P extends SchemaOrUndefined<DD['req'], IsResponse> ? SchemaOrUndefined<DD['res']> : never;
export interface IEndpointMeta { export interface IEndpointMeta {
readonly stability?: 'deprecated' | 'experimental' | 'stable'; readonly stability?: 'deprecated' | 'experimental' | 'stable';
@ -127,9 +148,4 @@ export interface IEndpointMeta {
readonly cacheSec?: number; readonly cacheSec?: number;
} }
export type SchemaOrUndefined<T extends JSONSchema7 | undefined, IsResponse extends boolean = false> = T extends JSONSchema7 ? SchemaType<T, References, IsResponse> : (void | Record<string, never>);
export type ResponseOf<D extends IEndpointMeta, P, IsResponse extends boolean = false, DD extends D['defines'][number] = D['defines'][number]> =
P extends SchemaOrUndefined<DD['req'], IsResponse> ? SchemaOrUndefined<DD['res']> : never;
export type Endpoints = typeof endpoints; export type Endpoints = typeof endpoints;