@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
105 lines (104 loc) • 3.28 kB
TypeScript
import { Type } from "@tsed/core";
import { type JsonClassStore } from "./JsonClassStore.js";
import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore.js";
import { JsonOperation } from "./JsonOperation.js";
import { type JsonParameterStore } from "./JsonParameterStore.js";
import { JsonSchema } from "./JsonSchema.js";
export interface JsonViewOptions {
path: string;
options: any;
}
export interface JsonRedirectOptions {
status: number | undefined;
url: string;
}
export declare class JsonMethodStore extends JsonEntityStore {
readonly parent: JsonClassStore;
middlewares: any[];
beforeMiddlewares: any[];
afterMiddlewares: any[];
/**
* Ref to JsonOperation when the decorated object is a method.
*/
readonly operation: JsonOperation;
/**
* List of children JsonEntityStore (properties or methods or params)
*/
readonly children: Map<string | number, JsonParameterStore>;
constructor(options: JsonEntityStoreOptions);
get params(): JsonParameterStore[];
get view(): JsonViewOptions;
set view(view: JsonViewOptions);
get acceptMimes(): string[];
set acceptMimes(mimes: string[]);
get parameters(): JsonParameterStore[];
get operationPaths(): Map<string, import("./JsonOperation.js").JsonMethodPath>;
get collectionType(): Type<any>;
set collectionType(type: Type<any>);
get isCollection(): boolean;
get schema(): JsonSchema;
/**
* Get an endpoint.
* @param target
* @param propertyKey
* @param descriptor
*/
static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore;
/**
* TODO must be located on JsonOperation level directly
* @param status
* @param contentType
* @param includes
*/
getResponseOptions(status: number, { contentType, includes }?: {
contentType?: string;
includes?: string[];
}): undefined | any;
/**
* Append middlewares to the beforeMiddlewares list.
* @param args
* @returns {EndpointMetadata}
*/
before(args: Function[]): this;
/**
* Append middlewares to the afterMiddlewares list.
* @param args
* @returns {EndpointMetadata}
*/
after(args: Function[]): this;
/**
* Store all arguments collected via Annotation.
* @param args
*/
use(args: Function[]): this;
/**
* Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.
*
* @param key
* @returns {any}
*/
get<T = any>(key: any): T;
getParamTypes(): Record<string, boolean>;
protected build(): void;
}
/**
* EndpointMetadata contains metadata about a controller and his method.
* Each annotation (@Get, @Body...) attached to a method are stored into endpoint.
* EndpointMetadata converts this metadata to an array which contain arguments to call an Express method.
*
* Example :
*
*```ts
* @Controller("/my-path")
* provide MyClass {
*
* @Get("/")
* @Authenticated()
* public myMethod(){}
* }
*```
*
* @alias JsonMethodStore
*/
export type EndpointMetadata = JsonMethodStore;
export declare const EndpointMetadata: typeof JsonMethodStore;