import { Path } from '../structures/path/index.js'; import { EndpointMethods } from './methods.js'; import type { IEndpointInfo } from './endpoint.types.js'; /** @import { buildApiCaller } from "./call" */ export type { IEndpointInfo }; /** * Defines REST API endpoint. * * Endpoint object can be used in a caller method (see {@link buildApiCaller}) to make a request. * * Basic definition {@link IEndpointInfo} which can be extended with additional properties and chaining mutation methods, see {@link IEndpointInfo.IForm} for example. */ export interface ApiEndpoint extends IEndpointInfo.Base { /** Applies specified HTTP method */ withMethod(method: EndpointMethods): this; /** Applies GET HTTP method and specifies output type */ get(): this & IEndpointInfo.IOut; /** Applies PUT HTTP method and specifies input and output types */ put(): this & IEndpointInfo.IIn & IEndpointInfo.IOut; /** Applies PATCH HTTP method and specifies input and output types */ patch(): this & IEndpointInfo.IIn & IEndpointInfo.IOut; /** Applies POST HTTP method and specifies input and output types */ post(): this & IEndpointInfo.IIn & IEndpointInfo.IOut; /** Applies DELETE HTTP method and specifies output type */ delete(): this & IEndpointInfo.IOut; /** Applies a type based on {@link Path.IBuilder} type by accepting arguments for {@link Path.construct} function */ withPath

(...path: P): this & IEndpointInfo.IPath>; /** Applies query type and also store query keys to make api caller be able to distinguish which keys should be ejected from request body. */ withQuery(...queryKeys: (string & keyof TQ)[]): this & IEndpointInfo.IQuery; /** Applies error type, optionally stores error processor. */ withErrors(errorProcessor?: (err: TErr) => void): this & IEndpointInfo.IErrors; /** Applies headers type. */ withHeaders(_headersMarker?: THeads): this & IEndpointInfo.IHeaders; /** Helper chain method for finalizing the type. Can make some runtime optimizations as well. */ finalize(): IEndpointInfo.Finalized; } export declare namespace ApiEndpoint { function isEndpoint(obj: any): obj is IEndpointInfo; interface IBuilder { (displayName?: string): T; extend(extender: (base: T) => T & TExt): IBuilder; } type IBuilderExtender = (base: TBase) => TBase & T; const create: IBuilder; }