import { AxiosError, AxiosHeaderValue, AxiosInstance, AxiosRequestConfig } from 'axios'; import { AxiosCacheInstance } from 'axios-cache-interceptor'; export declare const DEFAULT_HEADERS: { Accept: string; 'Content-Type': string; }; export declare const NONE: null; export declare const CLIENT_ERROR = "CLIENT_ERROR"; export declare const SERVER_ERROR = "SERVER_ERROR"; export declare const TIMEOUT_ERROR = "TIMEOUT_ERROR"; export declare const CONNECTION_ERROR = "CONNECTION_ERROR"; export declare const NETWORK_ERROR = "NETWORK_ERROR"; export declare const UNKNOWN_ERROR = "UNKNOWN_ERROR"; export declare const CANCEL_ERROR = "CANCEL_ERROR"; type StatusCodes = undefined | number; type PROBLEM_CODE = 'CLIENT_ERROR' | 'SERVER_ERROR' | 'TIMEOUT_ERROR' | 'CONNECTION_ERROR' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR' | 'CANCEL_ERROR'; /** * Given a HTTP status code, return back the appropriate problem enum. */ export declare const getProblemFromStatus: (status: StatusCodes) => PROBLEM_CODE | null; /** * Determines the problem from an Axios error. */ export declare const getProblemFromError: (error: AxiosError) => PROBLEM_CODE; export interface ApiErrorResponse { ok: false; problem: PROBLEM_CODE; originalError: AxiosError; data?: U; status?: number; headers?: Record; config?: AxiosRequestConfig; duration?: number; } export interface ApiOkResponse { ok: true; problem: null; originalError: null; data?: T; status?: number; headers?: Record; config?: AxiosRequestConfig; duration?: number; } export type ApiResponse = ApiErrorResponse | ApiOkResponse; export interface ApisauceConfig extends AxiosRequestConfig { baseURL: string | undefined; axiosInstance?: AxiosInstance; } export type Monitor = (response: ApiResponse) => void; export type RequestTransform = (request: AxiosRequestConfig) => void; export type AsyncRequestTransform = (request: AxiosRequestConfig) => Promise | ((request: AxiosRequestConfig) => Promise); export type ResponseTransform = (response: ApiResponse) => void; export type AsyncResponseTransform = (response: ApiResponse) => Promise | ((response: ApiResponse) => Promise); export interface ApisauceInstance { axiosInstance: AxiosInstance | AxiosCacheInstance; monitors: ((response: ApiResponse) => void)[]; addMonitor: (monitor: (response: ApiResponse) => void) => void; requestTransforms: RequestTransform[]; asyncRequestTransforms: AsyncRequestTransform[]; responseTransforms: ResponseTransform[]; asyncResponseTransforms: AsyncResponseTransform[]; addRequestTransform: (transform: RequestTransform) => void; addAsyncRequestTransform: (transform: AsyncRequestTransform) => void; addResponseTransform: (transform: ResponseTransform) => void; addAsyncResponseTransform: (transform: AsyncResponseTransform) => void; headers: Record; setHeader: (key: string, value: string) => AxiosInstance; setHeaders: (headers: Record) => AxiosInstance; deleteHeader: (name: string) => AxiosInstance; setBaseURL: (baseUrl: string) => AxiosInstance; getBaseURL: () => string; any: (config: AxiosRequestConfig) => Promise>; get: (url: string, params?: object, axiosConfig?: AxiosRequestConfig) => Promise>; delete: (url: string, params?: object, axiosConfig?: AxiosRequestConfig) => Promise>; post: (url: string, data?: object, axiosConfig?: AxiosRequestConfig) => Promise>; put: (url: string, data?: object, axiosConfig?: AxiosRequestConfig) => Promise>; patch: (url: string, data?: object, axiosConfig?: AxiosRequestConfig) => Promise>; } /** * Creates an instance of our API using the configuration. */ export declare const create: (config: ApisauceConfig) => ApisauceInstance; export declare const isCancel: typeof import("axios").isCancel, CancelToken: import("axios").CancelTokenStatic; declare const _default: { DEFAULT_HEADERS: { Accept: string; 'Content-Type': string; }; NONE: null; CLIENT_ERROR: string; SERVER_ERROR: string; TIMEOUT_ERROR: string; CONNECTION_ERROR: string; NETWORK_ERROR: string; UNKNOWN_ERROR: string; create: (config: ApisauceConfig) => ApisauceInstance; isCancel: typeof import("axios").isCancel; CancelToken: import("axios").CancelTokenStatic; }; export default _default;