/** * 高德地图 Web API HTTP 客户端 */ import { type ErrorInfo } from './errorCodes'; /** * 从核心包解析 getWebKey(运行时解析,避免类型导出时序问题) */ export declare function resolveWebKey(): string | undefined; /** * 高德地图 API 错误类 */ export declare class GaodeAPIError extends Error { /** 错误码 */ readonly code: string; /** 官方错误信息 */ readonly info: string; /** 友好的错误描述 */ readonly description: string; /** 问题排查建议 */ readonly suggestion: string; /** 错误类型 */ readonly type: ErrorInfo['type']; /** API 响应状态 */ readonly status: string; constructor(status: string, info: string, infocode: string); /** * 获取完整的错误信息(用于日志记录) */ toJSON(): { name: string; code: string; info: string; description: string; suggestion: string; type: "success" | "key_error" | "param_error" | "route_error" | "service_error" | "quota_error"; status: string; }; /** * 获取用户友好的错误提示 */ getUserMessage(): string; } /** * @deprecated 使用 GaodeAPIError 代替 */ export interface APIError { status: string; info: string; infocode: string; } /** * HTTP 客户端配置 */ export interface ClientConfig { /** 高德地图 Web API Key ,默认可以通过 getWebKey 获取,所以不再是必传*/ key?: string; /** 基础 URL,默认:https://restapi.amap.com */ baseURL?: string; /** 请求超时时间(毫秒),默认:10000 */ timeout?: number; /** 最大重试次数,默认:3 */ maxRetries?: number; /** 重试延迟(毫秒),默认:1000 */ retryDelay?: number; /** 是否启用缓存,默认:false */ enableCache?: boolean; /** 缓存容量,默认:100 */ cacheCapacity?: number; } /** * 请求选项 */ export interface RequestOptions { /** 请求参数 */ params?: object; /** AbortSignal 用于取消请求 */ signal?: AbortSignal; /** 是否使用缓存(仅当全局启用缓存时有效),默认:true */ useCache?: boolean; } /** * 高德地图 Web API HTTP 客户端 */ export declare class GaodeWebAPIClient { private key; private baseURL; private timeout; private maxRetries; private retryDelay; private cache?; constructor(config: ClientConfig); /** * 发起 HTTP 请求 */ request(path: string, options?: RequestOptions): Promise; /** * 判断是否为可重试的错误码 */ private shouldRetry; /** * 判断是否为可重试的异常 */ private isRetryableError; /** * 更新 API Key */ setKey(key: string): void; /** * 获取当前 API Key */ getKey(): string; }