import { Dispatcher, Agent } from "undici"; export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; export type THttpOk = { ok: true; status: number; data: T; headers: Record; }; export type THttpErr = { ok: false; status?: number; error: E; details?: any; }; export type THttpResult = THttpOk | THttpErr; export type THttpOutgoingLogItem = { id: number; created: number; time: number; method: HttpMethod; url: string; status?: number; ok: boolean; attempts: number; request: any; response: any; error?: string; }; export type THttpHostStats = { host: string; count: number; errors: number; timeouts: number; retries: number; avgMs: number; minMs: number; maxMs: number; p50Ms: number; p95Ms: number; p99Ms: number; totalTimeMs: number; inFlight: number; byStatus: { s2xx: number; s3xx: number; s4xx: number; s5xx: number; other: number; networkErrors: number; }; lastRequestAt: number; }; export type THttpStatusDistribution = { s2xx: number; s3xx: number; s4xx: number; s5xx: number; other: number; networkErrors: number; timeouts: number; }; export type THttpStatsSnapshot = { totalRequests: number; inFlight: { current: number; peak: number; byHost: Record; }; statusDistribution: THttpStatusDistribution; perHost: THttpHostStats[]; topSlow: THttpOutgoingLogItem[]; }; export type TRetryPolicy = { enabled?: boolean; maxAttempts?: number; baseDelayMs?: number; maxDelayMs?: number; retryOnStatuses?: number[]; retryOnNetworkErrors?: boolean; }; export type THttpConfig = { baseUrl?: string; dispatcher?: Dispatcher; timeoutMs?: number; headers?: Record; retry?: TRetryPolicy; onRequest?: (ctx: { method: HttpMethod; url: string; attempt: number; }) => void; onResponse?: (ctx: { method: HttpMethod; url: string; attempt: number; status: number; ms: number; }) => void; onError?: (ctx: { method: HttpMethod; url: string; attempt: number; ms: number; err: unknown; }) => void; }; export type TRequestOptions = { method: HttpMethod; url: string; query?: Record; headers?: Record; body?: any; timeoutMs?: number; dispatcher?: Dispatcher; responseType?: "json" | "text" | "raw"; throwOnJsonParseError?: boolean; retry?: TRetryPolicy; allowBody?: boolean; }; export declare class Http { private static _inited; private static config; private static _sharedAgent; private static _dcEnabled; private static _dcConnectedChannel; private static _dcListener; private static _activeConnectionsTotal; private static _activeConnectionsByHost; private static _countedSockets; private static _socketHostKey; private static _outgoingLog; private static _nextOutgoingLogID; private static _outgoingLogLimit; private static _truncate; private static _pushOutgoingLog; static getOutgoingLogSnapshot(): THttpOutgoingLogItem[]; private static _totalRequests; private static _inFlight; private static _peakInFlight; private static _inFlightByHost; private static _statusDist; private static _perHost; private static _topSlow; private static _topSlowLimit; private static _hostFromUrl; private static _isTimeoutError; private static _incInFlight; private static _decInFlight; private static _updateStats; private static _LAT_CAP; private static _latency; private static _recordLatency; private static _percentiles; private static _pushToTopSlow; static getHttpStats(): THttpStatsSnapshot; private static ensureInit; static configure(partial: Partial): void; static createAgent(opts?: ConstructorParameters[0]): Agent; static closeSharedAgent(): void; static basicAuth(username: string, password: string): string; static bearer(token: string): string; static enableConnectionCounterByHost(): void; static disableConnectionCounterByHost(options?: { reset?: boolean; }): void; private static _makeHostKey; static getActiveConnectionsTotal(): number; static getActiveConnectionsByHost(): Map; static getActiveConnectionsSnapshot(): { total: number; byHost: Record; }; static request(opts: TRequestOptions): Promise>; static get(url: string, opts?: Omit): Promise>; static post(url: string, body?: any, opts?: Omit): Promise>; static put(url: string, body?: any, opts?: Omit): Promise>; static patch(url: string, body?: any, opts?: Omit): Promise>; static delete(url: string, opts?: Omit): Promise>; }