UNPKG

fets

Version:

TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience

33 lines (32 loc) 1.25 kB
import { HTTPMethod } from '../typed-fetch.js'; import { OpenAPIDocument, Router } from '../types.js'; import { ClientOptions, OASClient } from './types.js'; export declare class ClientValidationError extends Error implements AggregateError { readonly path: string; readonly method: HTTPMethod; errors: any[]; response: Response; constructor(path: string, method: HTTPMethod, errors: any[], response: Response); [Symbol.iterator](): IterableIterator<any>; } export declare function createClient<TOAS extends OpenAPIDocument>(options: Omit<ClientOptions, 'endpoint'> & (TOAS extends { servers: { url: infer TEndpoint extends string; }[]; } ? { /** * The base URL of the API defined in the OAS document. * * @see https://swagger.io/docs/specification/api-host-and-base-path/ */ endpoint: TEndpoint; } : TOAS extends { host: infer THost extends string; basePath: infer TBasePath extends string; schemes: (infer TProtocol extends string)[]; } ? { endpoint: `${TProtocol}://${THost}${TBasePath}`; } : { endpoint?: string; })): OASClient<TOAS>; export declare function createClient<TRouter extends Router<any, any, any>>(options: ClientOptions): TRouter['__client'];