import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios' export interface initializeContainerProps { containerList: C[] } export type customConfiguration = AxiosRequestConfig & T export declare enum decisionInstaller { installReqSuc = 'installReqSuc', // 安装请求成功拦截器 installReqFail = 'installReqFail', // 安装请求失败拦截器 installResSuc = 'installResSuc', // 安装响应成功拦截器 installResFail = 'installResFail', // 安装响应失败拦截器 } export type instanceConfig = Partial<{ config?: customConfiguration interceptor: { request: { successCb?: interceptorsRequestSuccessTypes failCb?: interceptorsRequestFailTypes } response: { successCb?: interceptorsResponseSuccessTypes failCb?: interceptorsResponseFailTypes } } }> /** * @description 拦截器联合类型 */ export type interceptorCollectionTypes = interceptorsResponseFailTypes | interceptorsResponseSuccessTypes | interceptorsRequestFailTypes | interceptorsRequestSuccessTypes /** * @description 安装器联合类型 */ export type installerCollectionTypes = mergeErrorInstaller | mergeSuccessfulInstaller> | mergeSuccessfulInstaller export type mergeErrorInstaller = (err: any) => boolean export type mergeSuccessfulInstaller = (conf: T) => boolean export type checkDynamicModuleSuccessInstallType = T extends decisionInstaller.installReqSuc ? mergeSuccessfulInstaller> : mergeSuccessfulInstaller> export type dynamicPluginConfig = Partial<{ priority: number | keyof typeof priority interceptor: instanceConfig['interceptor'] installer: { [decisionInstaller.installReqSuc]?: mergeSuccessfulInstaller> [decisionInstaller.installReqFail]?: mergeErrorInstaller [decisionInstaller.installResSuc]?: mergeSuccessfulInstaller [decisionInstaller.installResFail]?: mergeErrorInstaller } }> export declare enum instanceAlias { firstInstance, secondInstance, thirdInstance, fourthInstance, fifthInstance, sixthInstance, } // 优先级 export declare enum priority { LOWEST = 'LOWEST', INTERMEDIATE = 'INTERMEDIATE', TOP = 'TOP', } /** * @description 初始化实例配置,并且获取所有拦截器 */ export declare function initializationAxios(conf?: customConfiguration): (target: Function) => void export type interceptorsResponseSuccessTypes = (conf: AxiosResponse) => Promise export declare function interceptorsResponseSuccess(): (target: Function, key: string, desc: TypedPropertyDescriptor) => TypedPropertyDescriptor export type interceptorsResponseFailTypes = (error: any, instance: AxiosInstance) => any export declare function interceptorsResponseFail(): (target: Function, key: string, desc: TypedPropertyDescriptor) => TypedPropertyDescriptor export type interceptorsRequestSuccessTypes = (conf: customConfiguration) => customConfiguration export function interceptorsRequestSuccess(): (target: Function, key: string, desc: TypedPropertyDescriptor>) => TypedPropertyDescriptor> export type interceptorsRequestFailTypes = (error: any) => any export declare function interceptorsRequestFail(): (target: Function, key: string, desc: TypedPropertyDescriptor) => TypedPropertyDescriptor type moduleTypes = Object[] export declare function Module(modules: moduleTypes): (target: Object) => void export declare function dynamicModule(conf: Omit, 'interceptor' | 'installer'>): (target: Object) => void export declare function dynamicModuleErrorInstall( type: decisionInstaller.installReqFail | decisionInstaller.installResFail ): (target: Object, key: string, desc: TypedPropertyDescriptor) => TypedPropertyDescriptor export declare function dynamicModuleSuccessInstall( type: T ): (target: Object, key: string, desc: TypedPropertyDescriptor>) => TypedPropertyDescriptor> export type instanceConfigReturns = { instance: AxiosInstance; conf: instanceConfig; pluginList: dynamicPluginConfig[] } export type filterEmptyInterceptorReturns = { requestSuccessCbList: interceptorsRequestSuccessTypes[] requestFailCbList: interceptorsRequestFailTypes[] responseSuccessCbList: interceptorsResponseSuccessTypes[] responseFailCbList: interceptorsResponseFailTypes[] } & instanceConfigReturns export interface DebuggerProps { debugger?: boolean debugPlugInNameOnly?: string } export interface InitializeContainerProps extends DebuggerProps { } declare class InitializeContainerUtils { /** * @description 实例化 * @param List * @returns */ protected initializationList(List: initializeContainerProps['containerList']): instanceConfigReturns[] /** * @description 检查安装器 * 1. 插件有拦截器 主体没有拦截器 即插件拦截器生效 * */ protected checkTheInstaller(List: instanceConfigReturns[]): instanceConfigReturns[] /** * @description 解析拦截器 * @param List * @returns */ protected filterEmptyInterceptor(List: instanceConfigReturns[]): filterEmptyInterceptorReturns[] /** * @description 绑定拦截器 * @param List */ protected bindingInterceptor(List: filterEmptyInterceptorReturns[]): filterEmptyInterceptorReturns[] } export declare class InitializeContainer extends InitializeContainerUtils { protected instanceList: filterEmptyInterceptorReturns[] collect(List: initializeContainerProps['containerList']): this protected checkEmptyList(): void get(index: number): AxiosInstance delete(index: number): filterEmptyInterceptorReturns[] } // 执行阶段 export declare enum executionPhase { checkTheInstallerStage = 'checkTheInstallerStage', // 检查安装器阶段 executeTheInstallerPhase = 'executeTheInstallerPhase', // 执行安装器阶段 checkTheInterceptorPhase = 'checkTheInterceptorPhase', // 检查拦截器阶段 executeTheTnterceptorPhase = 'executeTheTnterceptorPhase' // 执行拦截器阶段 } export declare enum interceptorsKey { interceptorsRequestSuccess = 'interceptorsRequestSuccess', interceptorsRequestFail = 'interceptorsRequestFail', responseSuccess = 'responseSuccess', responseFail = 'responseFail', }