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