import type { LoggerImplement, ResponseData } from "@iflyrpa/share"; import { type AxiosRequestConfig, type AxiosResponse, type CreateAxiosDefaults } from "axios"; /** * 判断是否为本机地址(localhost / 回环 IP / .local 等)。 * * 本机地址上的失败来自本地服务或单元测试,不是线上问题,不该进告警群。 * 用 URL 解析而非字符串包含匹配:`https://api.example.com/?cb=localhost` 这类 * 参数里带 localhost 的线上地址不能被误判成本机。 */ export declare function isLocalAddress(url: string): boolean; export declare class Http { private readonly apiClient; logger?: LoggerImplement; proxyInfo?: string; private readonly platform?; private readonly agentPromise?; static handleApiError(error: unknown): ResponseData; constructor(config?: CreateAxiosDefaults, logger?: LoggerImplement, addr?: string | null, accountId?: number, platform?: string); clearResponseInterceptors(): void; addResponseInterceptor(findError: (response: AxiosResponse) => ResponseData | undefined): void; /** * 请求最终失败(重试耗尽或错误不可重试)后上报飞书告警。 * 告警所需的 status / axios error code 由响应拦截器写入 error.extra。 * * 两类请求不上报:本机地址(localhost / 127.0.0.1 等)与拿不到 URL 的错误。 * 前者是本地服务或测试用例,后者没有目标地址无法定位,都属于告警噪音。 */ private reportRequestFailure; api(config: AxiosRequestConfig, options?: { retries?: number; retryDelay?: number; timeout?: number; onUploadProgress?: (progressEvent: any) => void; /** * 外部取消信号(用于用户主动取消上传等场景)。 * 注意:不能直接用 config.signal —— 下面会用内部 AbortController 覆盖它做超时兜底, * 所以外部信号必须在这里传入,由内部 controller 代理转发。 */ signal?: AbortSignal; }): Promise; }