fets
Version:
TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience
58 lines (57 loc) • 2.3 kB
text/typescript
import { HTTPMethod } from '../typed-fetch.cjs';
import { OpenAPIDocument, Router, SecurityScheme } from '../types.cjs';
import { ClientOptions, ClientOptionsWithStrictEndpoint, OASClient, OASSecurityParams } from './types.cjs';
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](): ArrayIterator<any>;
}
/**
* Create a client for an OpenAPI document
* You need to pass the imported OpenAPI document as a generic
*
* We recommend using the `NormalizeOAS` type to normalize the OpenAPI document
*
* @see https://the-guild.dev/openapi/fets/client/quick-start#usage-with-existing-rest-api
*
* @example
* ```ts
* import { createClient, type NormalizeOAS } from 'fets';
* import type oas from './oas.ts';
*
* const client = createClient<NormalizeOAS<typeof oas>>({});
* ```
*/
export declare function createClient<const TOAS extends OpenAPIDocument & {
components: {
securitySchemes: Record<string, SecurityScheme>;
};
}>(options: Omit<ClientOptionsWithStrictEndpoint<TOAS>, 'globalParams'> & {
globalParams: OASSecurityParams<TOAS['components']['securitySchemes'][keyof TOAS['components']['securitySchemes']]>;
}): OASClient<TOAS, false>;
/**
* Create a client for an OpenAPI document
* You need to pass the imported OpenAPI document as a generic
*
* We recommend using the `NormalizeOAS` type to normalize the OpenAPI document
*
* @see https://the-guild.dev/openapi/fets/client/quick-start#usage-with-existing-rest-api
*
* @example
* ```ts
* import { createClient, type NormalizeOAS } from 'fets';
* import type oas from './oas.ts';
*
* const client = createClient<NormalizeOAS<typeof oas>>({});
* ```
*/
export declare function createClient<const TOAS extends OpenAPIDocument>(options: ClientOptionsWithStrictEndpoint<TOAS>): OASClient<TOAS>;
/**
* Create a client from a typed `Router`
*
* @see https://the-guild.dev/openapi/fets/client/quick-start#usage-with-fets-server
*/
export declare function createClient<const TRouter extends Router<any, any, any>>(options: ClientOptions): TRouter['__client'];