@nahkies/typescript-axios-runtime
Version:
Runtime package for code generated by @nahkies/openapi-code-generator using the typescript-axios template
69 lines (68 loc) • 2.86 kB
text/typescript
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from "axios";
//#region ../typescript-common-runtime/dist/esm/request-bodies/url-search-params.d.mts
//#region src/request-bodies/url-search-params.d.ts
type Style = "deepObject" | "form" | "pipeDelimited" | "spaceDelimited";
interface Encoding {
explode?: boolean;
style?: Style;
}
/**
* Serializes a request body as `application/x-www-form-urlencoded` with the exact
* semantics defined by the provided encodings, falling back to the default encoding
* specified by the OAI specification.
*/
//#endregion
//#region ../typescript-common-runtime/dist/esm/types.d.mts
type QueryParams = {
[name: string]: string | number | number[] | boolean | string[] | undefined | null | QueryParams | QueryParams[];
};
type HeaderParams = Record<string, string | number | boolean | undefined | null> | [string, string | number | boolean | undefined | null][] | Headers;
type Server<T> = string & {
__server__: T;
};
//#endregion
//#region src/main.d.ts
interface AbstractAxiosConfig {
axios?: AxiosInstance | undefined;
basePath: string;
defaultHeaders?: Record<string, string> | undefined;
defaultTimeout?: number | undefined;
}
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, encodings?: Record<string, Encoding>): 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;
protected _parseBlobResponse(res: AxiosResponse): import("buffer").Blob;
private setHeaders;
private headersAsArray;
}
//#endregion
export { AbstractAxiosClient, AbstractAxiosConfig, type HeaderParams, type QueryParams, type Server };
//# sourceMappingURL=main.d.mts.map