import type { AxiosRequestConfig } from 'axios'

declare global {
    type Recordable<T = any> = Record<string, T>
    type Nullable<T> = T | null
    type NonNullable<T> = T extends null | undefined ? never : T

    interface ImportMetaEnv extends ViteEnv {
        __: unknown
    }

    interface ViteEnv {
        // APP 名称
        VITE_GLOB_APP_NAME: string
        // APP 描述
        VITE_GLOB_APP_DESCRIPTION?: string
        // API 接口地址
        VITE_GLOB_API_URL: string
        // API 接口地址前缀
        VITE_GLOB_API_URL_PREFIX?: string
        // 公共文件上传 API URL
        VITE_GLOB_UPLOAD_URL?: string
    }

    // 扩展类型，用于在 pont 生成的 api.d.ts 内部使用
    namespace http {
        declare interface RequestOptions {
            // Splicing request parameters to url
            joinParamsToUrl?: boolean
            // Format request parameter time
            formatDate?: boolean
            // Whether to process the request result
            isTransformResponse?: boolean
            // Whether to return native response headers
            // For example: use this attribute when you need to get the response headers
            isReturnNativeResponse?: boolean
            // Whether to join url
            joinPrefix?: boolean
            // Interface address, use the default apiUrl if you leave it blank
            apiUrl?: string
            // 请求拼接路径
            urlPrefix?: string
            // Error message prompt type
            errorMessageMode?: ErrorMessageMode
            // Whether to add a timestamp
            joinTime?: boolean
            ignoreCancelToken?: boolean
            // Whether to send token in header
            withToken?: boolean
            // 请求重试机制
            retryRequest?: RetryRequest
        }

        type RequestConfig<T = any> = AxiosRequestConfig<T>
    }
}

export {}
