@nahkies/typescript-axios-runtime
Version:
Runtime package for code generated by @nahkies/openapi-code-generator using the typescript-axios template
50 lines (49 loc) • 2.16 kB
TypeScript
import { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse, type RawAxiosRequestHeaders } from "axios";
import { type Encoding } from "./request-bodies/url-search-params";
export type QueryParams = {
[name: string]: string | number | number[] | boolean | string[] | undefined | null | QueryParams | QueryParams[];
};
export type HeaderParams = Record<string, string | number | boolean | undefined | null> | [string, string | number | boolean | undefined | null][] | Headers;
export type Server<T> = string & {
__server__: T;
};
export interface AbstractAxiosConfig {
axios?: AxiosInstance;
basePath: string;
defaultHeaders?: Record<string, string>;
defaultTimeout?: number;
}
export declare abstract class AbstractAxiosClient {
protected readonly axios: AxiosInstance;
protected readonly basePath: string;
protected readonly defaultHeaders: Record<string, string>;
protected readonly defaultTimeout: number | undefined;
protected constructor(config: AbstractAxiosConfig);
protected _request<R extends AxiosResponse>(opts: AxiosRequestConfig): Promise<R>;
protected _query(params: QueryParams): string;
/**
* Combines headers for a request, with precedence
* 1. default headers
* 2. route level header parameters
* 3. raw request config (escape hatch)
*
* following these rules:
* - header values of `undefined` are skipped
* - header values of `null` will remove/delete any previously set headers
*
* Eg:
* Passing `Authorization: null` as a parameter, will clear out any
* default `Authorization` header.
*
* But passing `Authorization: undefined` as parameter will fallthrough
* to the default `Authorization` header.
*
* @param paramHeaders
* @param optsHeaders
* @protected
*/
protected _headers(paramHeaders?: HeaderParams, optsHeaders?: AxiosRequestConfig["headers"]): RawAxiosRequestHeaders;
protected _requestBodyToUrlSearchParams(obj: Record<string, unknown>, encoding?: Record<string, Encoding>): URLSearchParams;
private setHeaders;
private headersAsArray;
}