import { Void } from "./_api.js"; import * as MO from "./_schema.js"; import type { AnyRecord, AnyRecordSchema, GetProps, Model, PropsExtensions, StringRecord } from "./Model.js"; export type StringRecordSchema = MO.Schema; export declare const GET = "GET"; export type GET = typeof GET; export declare const POST = "POST"; export type POST = typeof POST; export declare const PUT = "PUT"; export type PUT = typeof PUT; export declare const PATCH = "PATCH"; export type PATCH = typeof PATCH; export declare const DELETE = "DELETE"; export type DELETE = typeof DELETE; export declare const UPDATE = "UPDATE"; export type UPDATE = typeof UPDATE; export declare const OPTIONS = "OPTIONS"; export type OPTIONS = typeof OPTIONS; export declare const HEAD = "HEAD"; export type HEAD = typeof HEAD; export declare const TRACE = "TRACE"; export type TRACE = typeof TRACE; export type ReadMethods = GET; export type WriteMethods = POST | PUT | PATCH | DELETE; export type Methods = ReadMethods | WriteMethods; export declare const reqBrand: unique symbol; export interface QueryRequest extends Model, PropsExtensions> { Body: undefined; Path: Path; Query: Query; Headers: Headers; path: string; method: ReadMethods; [reqBrand]: typeof reqBrand; } export interface BodyRequest extends Model, PropsExtensions> { Path: Path; Body: Body; Query: Query; Headers: Headers; path: string; method: WriteMethods; [reqBrand]: typeof reqBrand; } type ResponseString = "Response" | `${string}Response`; type RequestString = "Request" | "default" | `${string}Request`; type FilterRequest = U extends RequestString ? U : never; export type GetRequestKey> = FilterRequest; export type GetRequest> = FilterRequest extends never ? never : U[FilterRequest]; type FilterResponse = U extends ResponseString ? U : never; export type GetResponseKey> = FilterResponse; export type GetResponse> = FilterResponse extends never ? typeof Void : U[FilterResponse]; export declare function extractRequest>(h: TModule): GetRequest; export declare function extractResponse>(h: TModule): GetResponse | typeof Void; export declare const reqId: MO.Annotation; export declare function QueryRequest(__name?: string): { (method: ReadMethods, path: string, _: { headers?: Headers | undefined; }): QueryRequest; (method: ReadMethods, path: string, _: { headers?: Headers_1 | undefined; path: Path_1; }): QueryRequest; (method: ReadMethods, path: string, { headers, query }: { headers?: Headers_2 | undefined; query: Query; }): QueryRequest; (method: ReadMethods, path: string, _: { headers?: Headers_3 | undefined; path: MO.Schema; query: MO.Schema; }): QueryRequest, MO.Schema, Headers_3, MO.Schema>; }; export declare function BodyRequest(__name?: string): { (method: WriteMethods, path: string, _: { headers?: Headers | undefined; }): BodyRequest; (method: WriteMethods, path: string, _: { headers?: Headers_1 | undefined; path: Path_1; }): BodyRequest; (method: WriteMethods, path: string, _: { headers?: Headers_2 | undefined; body: Body; }): BodyRequest; (method: WriteMethods, path: string, _: { headers?: Headers_3 | undefined; body: MO.Schema; query: MO.Schema; }): BodyRequest, MO.Schema, Headers_3, MO.Schema>; (method: WriteMethods, path: string, _: { headers?: Headers_4 | undefined; path: MO.Schema; query: MO.Schema; }): BodyRequest, MO.Schema, undefined, Headers_4, MO.Schema>; (method: WriteMethods, path: string, _: { headers?: Headers_5 | undefined; path: MO.Schema; body: MO.Schema; }): BodyRequest, MO.Schema, undefined, Headers_5, MO.Schema>; (method: WriteMethods, path: string, _: { headers?: Headers_6 | undefined; path: MO.Schema; body: MO.Schema; query: MO.Schema; }): BodyRequest, MO.Schema, MO.Schema, Headers_6, MO.Schema>; }; export interface Request extends Model { method: Method; path: Path; } type Separator = "/" | "&" | "?.js"; export type PathParams = Path extends `:${infer Param}${Separator}${infer Rest}` ? Param | PathParams : Path extends `:${infer Param}` ? Param : Path extends `${infer _Prefix}:${infer Rest}` ? PathParams<`:${Rest}`> : never; export type IfPathPropsProvided = PathParams extends never ? C : PathParams extends keyof B ? C : ["You must specify the properties that you expect in the path", never]; /** * See {@link Req} but with Props */ export declare function ReqProps(): { (method: Method, path: Path_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (method: Method_1, path: Path_2, props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; /** * DELETE http method. * Input parameters other than Path, will be sent as QueryString. * Path parameters (specified with `:param_name`) must be present in the provided Schema. */ export declare function Delete(path: Path): (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties>>; }; export declare function DeleteSpecial(path: Path): (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; /** * PUT http method. * Input parameters other than Path, will be sent as Body. * Path parameters (specified with `:param_name`) must be present in the provided Schema. */ export declare function Put(path: Path): (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function PutSpecial(path: Path): (__name?: string | undefined) => (self: MO.SchemaProperties) => IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; /** * GET http method. * Input parameters other than Path, will be sent as QueryString. * Path parameters (specified with `:param_name`) must be present in the provided Schema. */ export declare function Get(path: Path): (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties>>; }; export declare function GetSpecial(path: Path): (__name?: string | undefined) => (self: MO.SchemaProperties) => IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties>>; /** * PATCH http method. * Input parameters other than Path, will be sent as Body. * Path parameters (specified with `:param_name`) must be present in the provided Schema. */ export declare function Patch(path: Path): (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function PatchSpecial(path: Path): (__name?: string | undefined) => (self: MO.SchemaProperties) => IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; /** * POST http method. * Input parameters other than Path, will be sent as Body. * Path parameters (specified with `:param_name`) must be present in the provided Schema. */ export declare function Post(path: Path): (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function PostSpecial(path: Path): (__name?: string | undefined) => (self: MO.SchemaProperties) => IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; export declare function MethodReqProps2(method: Method): (path: Path_1) => (__name?: string | undefined) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function MethodReqProps2_(method: Method, path: Path): (__name?: string) => { (): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function MethodReqProps(method: Method): () => { (path: Path_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (path: Path_2, props: Props_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function MethodReq_(method: Method, path: Path): (__name?: string) => (self: MO.SchemaProperties) => IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; /** * Automatically picks path, query and body, based on Path params and Request Method. */ export declare function Req(__name?: string): { (method: Method, path: Path_1): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; (method: Method_1, path: Path_2, self: MO.SchemaProperties): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; }; export declare function parsePathParams(path: Path): PathParams[]; type BuildRequest = IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; export declare function makeRequest(method: Method, path: Path, self: MO.SchemaProperties, __name?: string): BuildRequest; export declare function adaptRequest(req: Request, Path, Method>): IfPathPropsProvided>>, MO.SchemaProperties>>, undefined, MO.SchemaProperties> : BodyRequest>>, MO.SchemaProperties>>, undefined, undefined, MO.SchemaProperties>>; export type Meta = { description?: string; summary?: string; openapiRef?: string; }; export declare const metaIdentifier: MO.Annotation; export declare function meta(meta: Meta): (self: MO.Schema) => MO.Schema; export declare const metaC: (m: Meta) => (cls: any) => any; export type ReqRes = MO.Schema; export type ReqResSchemed = { new (...args: any[]): any; Encoder: MO.Encoder.Encoder; Model: ReqRes; }; export type RequestSchemed = ReqResSchemed & { method: Methods; path: string; }; export declare function extractSchema(Res_: ReqRes | ReqResSchemed): ReqRes; export {}; //# sourceMappingURL=REST.d.ts.map