type AuthToken = string | undefined; interface Auth { /** * Which part of the request do we use to send the auth? * * @default 'header' */ in?: 'header' | 'query' | 'cookie'; /** * Header or query parameter name. * * @default 'Authorization' */ name?: string; scheme?: 'basic' | 'bearer'; type: 'apiKey' | 'http'; } interface SerializerOptions { /** * @default true */ explode: boolean; style: T; } type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; type ObjectStyle = 'form' | 'deepObject'; type QuerySerializer = (query: Record) => string; type BodySerializer = (body: any) => any; interface QuerySerializerOptions { allowReserved?: boolean; array?: SerializerOptions; object?: SerializerOptions; } declare const formDataBodySerializer: { bodySerializer: | Array>>(body: T) => FormData; }; declare const jsonBodySerializer: { bodySerializer: (body: T) => string; }; declare const urlSearchParamsBodySerializer: { bodySerializer: | Array>>(body: T) => string; }; type Slot = 'body' | 'headers' | 'path' | 'query'; type Field = { in: Exclude; key: string; map?: string; } | { in: Extract; key?: string; map?: string; }; interface Fields { allowExtra?: Partial>; args?: ReadonlyArray; } type FieldsConfig = ReadonlyArray; interface Params { body: unknown; headers: Record; path: Record; query: Record; } declare const buildClientParams: (args: ReadonlyArray, fields: FieldsConfig) => Params; interface Client$1 { /** * Returns the final request URL. */ buildUrl: BuildUrlFn; connect: MethodFn; delete: MethodFn; get: MethodFn; getConfig: () => Config; head: MethodFn; options: MethodFn; patch: MethodFn; post: MethodFn; put: MethodFn; request: RequestFn; setConfig: (config: Config) => Config; trace: MethodFn; } interface Config$1 { /** * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ bodySerializer?: BodySerializer | null; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. * * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: RequestInit['headers'] | Record; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE'; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject * style, and reserved characters are percent-encoded. * * This method will have no effect if the native `paramsSerializer()` Axios * API function is used. * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ responseTransformer?: (data: unknown) => Promise; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ responseValidator?: (data: unknown) => Promise; } type ErrInterceptor = (error: Err, response: Res, request: Req, options: Options) => Err | Promise; type ReqInterceptor = (request: Req, options: Options) => Req | Promise; type ResInterceptor = (response: Res, request: Req, options: Options) => Res | Promise; declare class Interceptors { _fns: (Interceptor | null)[]; constructor(); clear(): void; getInterceptorIndex(id: number | Interceptor): number; exists(id: number | Interceptor): boolean; eject(id: number | Interceptor): void; update(id: number | Interceptor, fn: Interceptor): number | false | Interceptor; use(fn: Interceptor): number; } interface Middleware { error: Pick>, 'eject' | 'use'>; request: Pick>, 'eject' | 'use'>; response: Pick>, 'eject' | 'use'>; } declare const createConfig: (override?: Config & T>) => Config & T>; type ResponseStyle = 'data' | 'fields'; interface Config extends Omit, Config$1 { /** * Base URL for all requests made by this client. */ baseUrl?: T['baseUrl']; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: (request: Request) => ReturnType; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. * * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. */ next?: never; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. * You can override this behavior with any of the {@link Body} methods. * Select `stream` if you don't want to parse response data at all. * * @default 'auto' */ parseAs?: Exclude | 'auto' | 'stream'; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ responseStyle?: ResponseStyle; /** * Throw an error instead of returning it in the response? * * @default false */ throwOnError?: T['throwOnError']; } interface RequestOptions extends Config<{ responseStyle: TResponseStyle; throwOnError: ThrowOnError; }> { /** * Any body that you want to add to your request. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ body?: unknown; path?: Record; query?: Record; /** * Security mechanism(s) to use for the request. */ security?: ReadonlyArray; url: Url; } type RequestResult = ThrowOnError extends true ? Promise ? TData[keyof TData] : TData : { data: TData extends Record ? TData[keyof TData] : TData; request: Request; response: Response; }> : Promise ? TData[keyof TData] : TData) | undefined : ({ data: TData extends Record ? TData[keyof TData] : TData; error: undefined; } | { data: undefined; error: TError extends Record ? TError[keyof TError] : TError; }) & { request: Request; response: Response; }>; interface ClientOptions { baseUrl?: string; responseStyle?: ResponseStyle; throwOnError?: boolean; } type MethodFn = (options: Omit, 'method'>) => RequestResult; type RequestFn = (options: Omit, 'method'> & Pick>, 'method'>) => RequestResult; type BuildUrlFn = ; query?: Record; url: string; }>(options: Pick & Options) => string; type Client = Client$1 & { interceptors: Middleware; }; /** * The `createClientConfig()` function will be called on client initialization * and the returned object will become the client's initial configuration. * * You may want to initialize your client this way instead of calling * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ type CreateClientConfig = (override?: Config) => Config & T>; interface TDataShape { body?: unknown; headers?: unknown; path?: unknown; query?: unknown; url: string; } type OmitKeys = Pick>; type Options = OmitKeys, 'body' | 'path' | 'query' | 'url'> & Omit; type OptionsLegacyParser = TData extends { body?: any; } ? TData extends { headers?: any; } ? OmitKeys, 'body' | 'headers' | 'url'> & TData : OmitKeys, 'body' | 'url'> & TData & Pick, 'headers'> : TData extends { headers?: any; } ? OmitKeys, 'headers' | 'url'> & TData & Pick, 'body'> : OmitKeys, 'url'> & TData; declare const createClient: (config?: Config) => Client; export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type ResponseStyle, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };