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
@Injectable()
export default class extends Endpoint<'admin/queue/inboc-delayed'> {
name = 'admin/queue/inboc-delayed' as const;
export default class extends Endpoint<'admin/queue/inbox-delayed'> {
name = 'admin/queue/inbox-delayed' as const;
constructor(
@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'],
requireCredential: true,

View File

@ -24,10 +24,31 @@ export type RolePolicies = {
};
export type EndpointDefines = ReadonlyArray<{
/**
* JSON Schema
* undefined
* $refは使えない(ajv由来)
*/
req: DeepOmit<JSONSchema7, { $ref: never }> | undefined;
/**
* JSON Schema
* 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 {
readonly stability?: 'deprecated' | 'experimental' | 'stable';
@ -127,9 +148,4 @@ export interface IEndpointMeta {
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;