/* eslint-disable @typescript-eslint/no-explicit-any */ import type { AxiosHeaders, AxiosRequestConfig, HeadersDefaults, AxiosDefaults, Axios, InternalAxiosRequestConfig, AxiosResponse, } from 'axios' import type { AnyFunc } from '@/types/modules/utils' export type AxiosHeaderValue = | AxiosHeaders | string | string[] | number | boolean | null export interface RequestHeaderOptions { key: string value: AxiosHeaderValue } export interface AxiosInstanceExpand extends Axios { (config: AxiosRequestConfig): Promise (url: string, config?: AxiosRequestConfig): Promise getUri(config?: AxiosRequestConfig): string request(config: AxiosRequestConfig): Promise get(url: string, config?: AxiosRequestConfig): Promise delete( url: string, config?: AxiosRequestConfig, ): Promise head( url: string, config?: AxiosRequestConfig, ): Promise options( url: string, config?: AxiosRequestConfig, ): Promise post( url: string, data?: D, config?: AxiosRequestConfig, ): Promise put( url: string, data?: D, config?: AxiosRequestConfig, ): Promise patch( url: string, data?: D, config?: AxiosRequestConfig, ): Promise postForm( url: string, data?: D, config?: AxiosRequestConfig, ): Promise putForm( url: string, data?: D, config?: AxiosRequestConfig, ): Promise patchForm( url: string, data?: D, config?: AxiosRequestConfig, ): Promise defaults: Omit & { headers: HeadersDefaults & { [key: string]: AxiosHeaderValue } } } export type RequestInterceptorConfig = InternalAxiosRequestConfig export type ResponseInterceptorConfig = AxiosResponse export interface ImplementQueue { implementRequestInterceptorArray: AnyFunc[] implementResponseInterceptorArray: AnyFunc[] } export interface ErrorImplementQueue { implementRequestInterceptorErrorArray: AnyFunc[] implementResponseInterceptorErrorArray: AnyFunc[] } export type BeforeFetchFunction< T = RequestInterceptorConfig | ResponseInterceptorConfig, > = (ins: K, mode: string) => void export type FetchType = 'ok' | 'error' export type FetchErrorFunction = ( error: K, mode: string, ) => void export interface AxiosFetchInstance { requestInstance: RequestInterceptorConfig | null responseInstance: ResponseInterceptorConfig | null } export interface AxiosFetchError { requestError: T | null responseError: T | null }