/** * This file has helper types that map from the specfication type to handler function types. */ import { ResponsesSpec, ContentsSpec, RootSpec, PathsSpec, OperationsSpec, OperationSpec, RequestBodySpec } from "./spec-types"; /** * From the root of the spec, create a type for an object with handler functions */ export declare type HandlerFnsFromRootSpec = HandlerFnsFromPathsSpec; /** * From the paths of the spec, create a type for an object with handler functions for each path and operation */ export declare type HandlerFnsFromPathsSpec = { readonly [K in keyof T]: HandlerFnsFromOperationsSpec; }; /** * From the operations spec, create function types */ export declare type HandlerFnsFromOperationsSpec = { readonly [K in keyof T]: HandlerFnFromOperationSpec; }; /** * Create a handler function from the operation spec. */ export declare type HandlerFnFromOperationSpec = HandlerFn : {}, HandlerResponseFromSpec>; /** * From the specification, create a union type of possible response types */ export declare type HandlerResponseFromSpec = { readonly [K in keyof T]: { readonly httpCode: K; } & (T[K]["content"] extends {} ? HandlerContentFromSpec : {}); }[keyof T]; /** * From the specification, create a union type of possible content types */ export declare type HandlerContentFromSpec = { readonly [K in keyof T]: { readonly contentType: K; readonly content: T[K]; }; }[keyof T]; /** * A general description of a handler function */ export declare type HandlerFn, RequestBody extends ContentWithType, Response extends HandlerResponse> = (ctx: Context, parameters: Parameters, requestBody: RequestBody) => Promise; /** * A general description of a handler function response */ export declare type HandlerResponse = { readonly httpCode: HttpCode; } & ContentWithType; export declare type ContentWithType = { readonly contentType?: ContentType; readonly content?: Content; }; export declare type ParamSet = { readonly [key: string]: unknown; }; export declare type HandlerParameters = { readonly path: PathParams; readonly query: QueryParams; readonly header: HeaderParams; readonly cookie: CookieParams; }; /** * A general description of a handler object with functions for each path/operation */ export declare type HandlerFns = { readonly [path: string]: { readonly [op: string]: HandlerFn, ContentWithType, HandlerResponse>; }; }; //# sourceMappingURL=type-mappers.d.ts.map