
interface LibRequestOptions extends LibRequestConfig,LibRequestInstructionsOptions{

    url:string,

    data?:Record<string, any> | LibDataArray,

    formData?:Record<string, any>,

    success?:Function,

    fail?:Function,

    file?:Boolean,

    login?:boolean,

    name?:string,

    entrust?:Record<string, any>,

    header?:Record<string, string>,

    merge?:LibRequestMerge,

    // 是否代理
    agent?:boolean,

    // 模式
    mode?:Mode

}

interface LibRequestMerge {
    start:number,
    end:number
}
//
// declare const enum LibRequestMergeType {
//     start:
// }

interface LibRequestConfig {

    // 请求前缀
    baseURL?:string,

    // 请求头配置
    header?:Record<string, string>,

    // 默认的请求方式
    method?: 'GET' | 'POST',

    // 超时时间
    timeout?:number

}

interface LibRequestResponseData {
    data:ResponseData;
    status: number;
    statusText: string;
    headers: any;
    config: AxiosRequestConfig;
    request?: any;
}

interface LibRequestContext {

    // 请求Data
    requestData: LibRequestOptions,

    // 响应Data
    responseData?: LibRequestResponseData,

    // 执行针
    execContext?:boolean,

    // 退出执行针
    exit?:(message:string,fail?:boolean)=>void,

    // 设置运行成功
    resolve:(data?:Record<string, any>)=>void,

    // 设置运行错误
    reject:(data?:any)=>void,

    // 当前状态
    status: LibRequestStatus,

    // 本次请求的唯一值
    sign?: string,

    // 成功
    success?:(data:LibRequestResponseData)=>any,

    // 失败
    fail?:(data:any)=>any
}

interface InstructionsExitStatus {
    status: number,
    exit:boolean,
    msg:string
}

type LibRequestOptionsKeyOf = 'triggerType' | 'where' | 'zIndex';

interface LibRequestInstructionsFunction {
    (data:LibRequestContext):void
    // 自定义配置
    [propName:string]:any
}

interface InstructionsWhereFunction {
    (data: LibRequestContext): boolean
}

interface LibRequestInstructionsObject {
    // 执行函数
    trigger?: LibRequestInstructionsFunction,
    // 执行类型
    triggerType?: InstructionsTypes | any,
    // 执行条件
    where?: InstructionsWhere | any,
    // 触发条件
    whereTrigger?:InstructionsWhereFunction,
    // 执行顺序
    zIndex?:number,
    // 自定义配置
    [propName:string]:any
}

type LibRequestInstructions = LibRequestInstructionsObject | LibRequestInstructionsFunction;

type InstructionsTypeConfigWhere = { [key in InstructionsWhere]?:Array<string> };

interface InstructionsTypeConfig {
    // [propName:number]: InstructionsTypeConfigWhere
    orderObject?: Record<string, number>,
    unshiftObject?: Record<string,number>,
    notHas?:Array<string>,
}


interface ResponseData {

    code:number,

    msg: string,

    time:number,

    data:any,

    // 是否为成功的状态码
    isSuccess:boolean,

    // 是否属于缓存
    isCache:boolean,

    [propName:string]:any

}