import type { AxiosStatic, AxiosRequestConfig, RawAxiosResponseHeaders, AxiosResponseHeaders, RawAxiosRequestHeaders, AxiosRequestHeaders } from 'axios'; export type ParsedError = { name: T; message: string; stack: string; status: number; data?: any; }; export type ResponseData = { code: number | `${number}` | string; data: T; msg: null | string; }; export type CustomResponseData = T extends 'custom' ? CheckAny extends false ? unknown extends U ? CheckAny extends false ? ResponseData : U : U : ResponseData : ResponseData; export type CheckNever = T extends never ? true : false; export type CheckAny = CheckNever extends false ? false : true; export type WithFailureData = T extends null ? null | undefined : T | null | undefined; export interface ChainName { all: ChainName['success'] | ChainName['failure'] | ChainName['error'] | ChainName['login'] | ChainName['timeout']; success: 'success'; failure: 'failure'; error: 'error'; login: 'login'; timeout: 'timeout'; withoutS: Exclude; withoutF: Exclude; withoutE: Exclude; withoutL: Exclude; withoutT: Exclude; withoutSF: Exclude; withoutSE: Exclude; withoutSL: Exclude; withoutST: Exclude; withoutFE: Exclude; withoutFL: Exclude; withoutFT: Exclude; withoutEL: Exclude; withoutET: Exclude; withoutLT: Exclude; withSF: ChainName['success'] | ChainName['failure']; withSE: ChainName['success'] | ChainName['error']; withSL: ChainName['success'] | ChainName['login']; withST: ChainName['success'] | ChainName['timeout']; withFE: ChainName['failure'] | ChainName['error']; withFL: ChainName['failure'] | ChainName['login']; withFT: ChainName['failure'] | ChainName['timeout']; withEL: ChainName['error'] | ChainName['login']; withET: ChainName['error'] | ChainName['timeout']; withLT: ChainName['login'] | ChainName['timeout']; } export interface ChainReturn { success: CustomResponseData; failure: CustomResponseData; error: ParsedError; login: CustomResponseData | ParsedError; timeout: ParsedError<'timeout'>; successOrFailure: CustomResponseData>; all: CustomResponseData> | ParsedError | ParsedError<'timeout'>; } export type AxiosReqHeaders = RawAxiosRequestHeaders | AxiosRequestHeaders; export type AxiosResHeaders = RawAxiosResponseHeaders | AxiosResponseHeaders; export interface InitConfig { onSuccess?: (res: ChainReturn['success'], headers: AxiosResHeaders) => any; onFailure?: (res: ChainReturn['failure'], headers: AxiosResHeaders) => any; onLogin?: (res: ChainReturn['login'], headers: AxiosResHeaders) => any; onError?: (res: ChainReturn['error'], headers: AxiosReqHeaders | AxiosResHeaders) => any; onTimeout?: (e: ChainReturn['timeout'], headers: AxiosReqHeaders) => any; isSuccess?: (res: ResponseData>, status: number, headers: AxiosResHeaders) => boolean; isLogin?: (res: ResponseData>, status: number, headers: AxiosResHeaders) => boolean; timeout?: number; baseURL?: string; } export interface Options extends InitConfig, AxiosRequestConfig { } export type FactoryType = 'success' | 'failure' | 'error' | 'login'; export type ErrorParams = { status: number; netWorkError: boolean; data: Record; }; export interface ErrorData extends Record { status: number; } export type ErrorRes = { message: string; data: ErrorData; }; export type RestScopeName = ChainName['all']; export type RestScope = Readonly<[RestScopeName, RestScopeName?, RestScopeName?, RestScopeName?, RestScopeName?]>; type Tuple2Record = { [Value in T[number]]: Value; }; export interface PromiseWrapper['success'], TFail = ChainReturn['failure'], TErr = ChainReturn['error'], TLogin = ChainReturn['login'], TTime = ChainReturn['timeout'], HadCall extends string = ''> { success(onSuccess?: (res: ChainReturn['success'], headers: AxiosResHeaders) => TRes): Omit, ChainName['withoutS'] extends HadCall ? Delete | 'rest' : Delete> & Promise; failure(onFailure?: (res: ChainReturn['failure'], headers: AxiosResHeaders) => TRes): Omit, ChainName['withoutF'] extends HadCall ? Delete | 'rest' : Delete> & Promise; error(onError?: (err: ChainReturn['error'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes): Omit, ChainName['withoutE'] extends HadCall ? Delete | 'rest' : Delete> & Promise; login(onLogin?: (res: ChainReturn['login'], headers: AxiosResHeaders) => TRes): Omit, ChainName['withoutL'] extends HadCall ? Delete | 'rest' : Delete> & Promise; timeout(onTimeout?: (err: ChainReturn['timeout'], headers: AxiosReqHeaders) => TRes): Omit, ChainName['withoutT'] extends HadCall ? Delete | 'rest' : Delete> & Promise; rest, undefined>, THadCallWithNotInScope extends string = HadCall | Exclude, Delete extends string = HadCall | TRestScopeName | 'rest'>(onRest?: (val: ChainName['all'] extends THadCallWithNotInScope ? unknown : ChainName['withoutS'] extends THadCallWithNotInScope ? ChainReturn['success'] : ChainName['withoutF'] extends THadCallWithNotInScope ? ChainReturn['failure'] : ChainName['withoutE'] extends THadCallWithNotInScope ? ChainReturn['error'] : ChainName['withoutL'] extends THadCallWithNotInScope ? ChainReturn['login'] : ChainName['withoutT'] extends THadCallWithNotInScope ? ChainReturn['timeout'] : ChainName['withoutSF'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure'] : ChainName['withoutSE'] extends THadCallWithNotInScope ? ChainReturn['success' | 'error'] : ChainName['withoutSL'] extends THadCallWithNotInScope ? ChainReturn['success' | 'login'] : ChainName['withoutST'] extends THadCallWithNotInScope ? ChainReturn['success' | 'timeout'] : ChainName['withoutFE'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'error'] : ChainName['withoutFL'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'login'] : ChainName['withoutFT'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'timeout'] : ChainName['withoutEL'] extends THadCallWithNotInScope ? ChainReturn['error' | 'login'] : ChainName['withoutET'] extends THadCallWithNotInScope ? ChainReturn['error' | 'timeout'] : ChainName['withoutLT'] extends THadCallWithNotInScope ? ChainReturn['login' | 'timeout'] : ChainName['withSF'] extends THadCallWithNotInScope ? ChainReturn['error' | 'login' | 'timeout'] : ChainName['withSE'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'login' | 'timeout'] : ChainName['withSL'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'error' | 'timeout'] : ChainName['withST'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'error' | 'login'] : ChainName['withFE'] extends THadCallWithNotInScope ? ChainReturn['success' | 'login' | 'timeout'] : ChainName['withFL'] extends THadCallWithNotInScope ? ChainReturn['success' | 'error' | 'timeout'] : ChainName['withFT'] extends THadCallWithNotInScope ? ChainReturn['success' | 'error' | 'login'] : ChainName['withEL'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure' | 'timeout'] : ChainName['withET'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure' | 'login'] : ChainName['withLT'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure' | 'error'] : ChainName['success'] extends THadCallWithNotInScope ? ChainReturn['failure' | 'error' | 'login' | 'timeout'] : ChainName['failure'] extends THadCallWithNotInScope ? ChainReturn['success' | 'error' | 'login' | 'timeout'] : ChainName['error'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure' | 'login' | 'timeout'] : ChainName['login'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure' | 'error' | 'timeout'] : ChainName['timeout'] extends THadCallWithNotInScope ? ChainReturn['successOrFailure' | 'error' | 'login'] : ChainReturn['all'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes, scope?: TRestScope): Omit, Delete> & Promise; } export declare class Request { private _config; axios: AxiosStatic; constructor(config?: InitConfig); private parseError; setting(config: InitConfig): void; request(options: Options): PromiseWrapper & Promise>>; } export default Request;