import 'reflect-metadata'; import { CircuitBreakerConfig, HttpClientConfig, RetryConfig } from '../interfaces/http-client-config.interface'; export declare const HTTP_CLIENT_OPTIONS_KEY = "http_client_options"; export declare const RETRY_OPTIONS_KEY = "http_retry_options"; export declare const CIRCUIT_BREAKER_OPTIONS_KEY = "http_circuit_breaker_options"; export declare const LOGGING_OPTIONS_KEY = "http_logging_options"; export declare const TIMEOUT_OPTIONS_KEY = "http_timeout_options"; export declare const PROXY_OPTIONS_KEY = "http_proxy_options"; export declare const CALL_INFO_KEY = "http_call_info"; /** * HTTP客户端装饰器 * 类似Spring Boot的@RestClient注解 */ export declare const HttpClient: (options?: HttpClientConfig) => (target: any) => void; /** * 重试装饰器 * 基于axios-retry库 */ export declare const HttpRetry: (options?: { enabled?: boolean; retries?: number; retryDelay?: (retryCount: number) => number; retryCondition?: (error: any) => boolean; shouldResetTimeout?: boolean; onRetry?: (retryCount: number, error: any, requestConfig: any) => void; }) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * 熔断器装饰器 * 类似Spring Cloud CircuitBreaker的@CircuitBreaker注解 */ export declare const HttpCircuitBreaker: (options?: { failureThreshold?: number; recoveryTimeoutMs?: number; monitoringPeriodMs?: number; minimumThroughputThreshold?: number; }) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * 请求日志装饰器 * 类似Spring Boot的@LogRequest注解 */ export declare const HttpLogRequest: (options?: { logHeaders?: boolean; logBody?: boolean; sanitize?: string[]; databaseLog?: boolean; logLevel?: "debug" | "info" | "warn" | "error"; serviceClass?: string; methodName?: string; operationName?: string; }) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * 超时装饰器 * 类似Spring的@Timeout注解 */ export declare const HttpTimeout: (timeoutMs: number) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * 代理装饰器 */ export declare const HttpUseProxy: (options: { enabled?: boolean; fromEnvironment?: boolean; host?: string; port?: number; protocol?: "http" | "https"; auth?: { username: string; password: string; }; }) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * 装饰器工具函数 */ export declare class HttpDecoratorUtils { /** * 获取方法上的重试配置 */ static getRetryOptions(target: any, propertyKey: string): RetryConfig | undefined; /** * 获取方法上的熔断器配置 */ static getCircuitBreakerOptions(target: any, propertyKey: string): CircuitBreakerConfig | undefined; /** * 获取方法上的日志配置 */ static getLoggingOptions(target: any, propertyKey: string): any; /** * 获取方法上的超时配置 */ static getTimeoutOptions(target: any, propertyKey: string): number | undefined; /** * 获取方法上的代理配置 */ static getProxyOptions(target: any, propertyKey: string): any; /** * 获取类上的HTTP客户端配置 */ static getHttpClientOptions(target: any): HttpClientConfig; /** * 获取方法上的调用信息配置 */ static getCallInfoOptions(target: any, propertyKey: string): any; /** * 获取所有装饰器配置 */ static getAllDecoratorConfigs(target: any, propertyKey: string): { retry?: RetryConfig; circuitBreaker?: CircuitBreakerConfig; logging?: any; timeout?: number; proxy?: any; httpClient?: HttpClientConfig; callInfo?: any; }; }