import { H as HttpClient, P as PaginationOptions } from './shared/zap.517fde6c.js'; export { A as AfterResponseHook, ac as AggregatedMetrics, a8 as AuthOptions, K as BackgroundSyncConfig, z as BackgroundSyncManager, l as BeforeErrorHook, B as BeforeRequestHook, m as BeforeRetryHook, s as BufferPool, C as CANCEL_RETRY, o as CacheManager, y as CachePrewarmer, p as ChunkedTransferManager, D as DownloadStreamManager, a as HTTPError, L as LinkHeader, a6 as LoggerOptions, aa as MetricsOptions, M as MultiLayerCache, u as MultiSizeBufferPool, N as NetworkError, O as OAuthManager, c as PaginationState, G as PerformanceManager, d as Plugin, g as PluginConfig, i as PluginContext, k as PluginErrorContext, e as PluginFactory, h as PluginHooks, b as PluginManager, f as PluginMetadata, j as PluginResponseContext, w as PoolConfig, F as PrefetchManager, I as PrewarmConfig, J as PrewarmEndpoint, W as RateLimiter, r as RequestDeduplicator, ab as RequestMetrics, R as RequestSigner, q as ResumableDownloadManager, V as RetryManager, ae as RetryPluginOptions, S as SSRFProtection, Q as SWRConfig, E as SWRManager, n as SecretsManager, T as TimeoutError, U as UploadStreamManager, a7 as authPlugin, t as bufferPool, X as buildURL, a3 as findLinkByRel, a4 as getNextPageUrl, a5 as loggerPlugin, _ as mergeHeaders, a9 as metricsPlugin, v as multiSizeBufferPool, Z as normalizeHeaders, a2 as parseLinkHeader, a0 as parseResponseBody, Y as parseURL, ad as retryPlugin, $ as serializeBody, x as urlCache, a1 as validateResponse } from './shared/zap.517fde6c.js'; import { R as RequestOptions, H as HttpMethod, a as HttpResponse } from './shared/zap.81717526.js'; export { l as CacheConfig, C as CacheOptions, w as CircuitBreakerConfig, m as CompressionConfig, D as DeduplicationConfig, E as ErrorInterceptorContext, b as HeadersInit, j as Hooks, e as HttpError, I as InterceptorContext, q as OAuthConfig, i as OnRequestErrorInterceptor, O as OnRequestInterceptor, h as OnResponseErrorInterceptor, g as OnResponseInterceptor, n as ProgressCallback, P as ProgressInfo, Q as QueryParams, v as RateLimitConfig, t as ResilienceConfig, f as ResponseInterceptorContext, c as ResponseType, u as RetryConfig, k as RetryContext, d as RetryOptions, r as SSRFConfig, s as SecretsConfig, o as SecurityConfig, p as SigningConfig, S as StreamConfig, T as TLSConfig } from './shared/zap.81717526.js'; import { Dispatcher, Agent } from 'undici'; import 'zod'; /** * Compression algorithms */ type CompressionAlgorithm = 'gzip' | 'br' | 'zstd' | 'deflate'; /** * Compression configuration */ interface CompressionConfig { enabled: boolean; threshold: number; preferredAlgorithms: CompressionAlgorithm[]; level?: number; compressRequest: boolean; requestTypes?: string[]; decompressResponse: boolean; } /** * Compression manager */ declare class CompressionManager { private config; private readonly DEFAULT_COMPRESSIBLE_TYPES; constructor(config: CompressionConfig); /** * Compress request body */ compressRequest(body: string | ArrayBuffer, contentType?: string): Promise<{ data: ArrayBuffer; encoding: CompressionAlgorithm; } | null>; /** * Decompress response body */ decompressResponse(body: ArrayBuffer, encoding: string): Promise; /** * Get Accept-Encoding header value */ getAcceptEncoding(): string; /** * Compress data */ private compress; private compressSync; /** * Decompress data */ private decompress; /** * Create streaming decompressor for ReadableStream * More efficient for large payloads */ createStreamingDecompressor(encoding: string): TransformStream | null; /** * Decompress streaming response (async generator) * Best for very large payloads */ decompressStream(stream: ReadableStream, encoding: string): AsyncGenerator; private readStream; /** * Check if content type is compressible */ private isCompressible; /** * Normalize encoding name */ private normalizeEncoding; /** * Get encoding name for header */ private getEncodingName; } /** * Content negotiation helper */ declare class ContentNegotiation { /** * Parse Accept-Encoding header from server */ static parseAcceptEncoding(header: string): CompressionAlgorithm[]; /** * Select best compression algorithm */ static selectBestEncoding(supported: CompressionAlgorithm[], accepted: CompressionAlgorithm[]): CompressionAlgorithm | null; private static normalizeAlgorithm; } /** * Chunked Stream Manager * * Prometheus-inspired frame-based streaming with constant memory usage * Based on: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/ * * Benefits: * - Constant memory (max 10MB vs unbounded) * - Immediate streaming start (no buffering) * - 2.5x latency reduction * - 2x CPU usage reduction */ interface ChunkedStreamConfig { /** * Frame size in bytes (default: 1MB like Prometheus) */ frameSize?: number; /** * Enable buffer pooling for frame assembly */ useBufferPool?: boolean; /** * Callback on frame ready */ onFrame?: (frame: Uint8Array, frameNumber: number) => void; /** * Callback on stream complete */ onComplete?: (totalFrames: number, totalBytes: number) => void; } /** * Chunked Stream Manager * * Processes large responses in fixed-size frames to maintain constant memory */ declare class ChunkedStreamManager { private readonly frameSize; private readonly useBufferPool; private readonly onFrame?; private readonly onComplete?; constructor(config?: ChunkedStreamConfig); /** * Stream response in fixed-size frames * Memory usage: O(frameSize) - constant */ streamResponse(response: Response): AsyncGenerator; /** * Assemble frame from buffer chunks */ private assembleFrame; /** * Extract remainder after frame assembly */ private extractRemainder; /** * Get stats about current streaming session */ getStats(): { frameSize: number; useBufferPool: boolean; }; } /** * Helper: Convert chunked stream to single buffer * Use for small responses only! */ declare function streamToBuffer(stream: AsyncGenerator): Promise; /** * Helper: Convert stream to text with constant memory */ declare function streamToText(stream: AsyncGenerator): Promise; /** * Helper: Process stream with callback (memory-efficient) */ declare function processStream(stream: AsyncGenerator, processor: (chunk: Uint8Array) => void | Promise): Promise; /** * Adaptive Connection Pool * * Redis-inspired dynamic connection pool with auto-scaling * Based on: Redis connection pool management patterns * * Features: * - Dynamic pool sizing (10-512 connections) * - Auto-scaling based on utilization * - Lock-free request tracking with Atomics * - HTTP/2 multiplexing support */ interface AdaptivePoolConfig { /** * Minimum connections to maintain */ minConnections?: number; /** * Maximum connections allowed */ maxConnections?: number; /** * Utilization threshold to scale up (0-1) */ scaleUpThreshold?: number; /** * Utilization threshold to scale down (0-1) */ scaleDownThreshold?: number; /** * Interval to check and adjust pool size (ms) */ adjustmentInterval?: number; /** * Enable HTTP/2 multiplexing */ enableHTTP2?: boolean; /** * Callback on pool resize */ onResize?: (oldSize: number, newSize: number, utilization: number) => void; } interface PoolStats { currentConnections: number; activeRequests: number; availableCapacity: number; utilization: number; totalAdjustments: number; scaleUpCount: number; scaleDownCount: number; } type AgentType = Agent | Dispatcher; /** * Adaptive Connection Pool * * Automatically adjusts pool size based on real-time utilization metrics */ declare class AdaptiveConnectionPool { private agent; private currentSize; private readonly config; private adjustmentTimer; private readonly activeRequestsBuffer; private readonly activeRequestsView; private static readonly ACTIVE_REQUESTS_INDEX; private readonly stats; constructor(config?: AdaptivePoolConfig); /** * Create Undici agent with specified connection pool size */ private createAgent; /** * Start automatic pool size adjustment */ private startAutoAdjustment; /** * Adjust pool size based on current utilization */ private adjustPoolSize; /** * Track request start (lock-free atomic increment) */ private incrementActiveRequests; /** * Track request end (lock-free atomic decrement) */ private decrementActiveRequests; /** * Get current active requests count (lock-free atomic read) */ private getActiveRequests; /** * Get Undici agent */ getAgent(): AgentType; /** * Get current pool statistics */ getStats(): PoolStats; /** * Manually adjust pool size */ resize(newSize: number): Promise; /** * Make HTTP request with automatic request tracking */ request(options: Dispatcher.RequestOptions): Promise; /** * Stream HTTP request with automatic request tracking */ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise; /** * Close the pool and cleanup */ close(): Promise; } /** * Get or create global adaptive pool */ declare function getGlobalAdaptivePool(config?: AdaptivePoolConfig): AdaptiveConnectionPool; /** * Reset global adaptive pool */ declare function resetGlobalAdaptivePool(): Promise; interface EventLoopLagSnapshot { min: number; max: number; mean: number; p50: number; p95: number; p99: number; } declare class EventLoopMonitor { private histogram?; private started; static isSupported(): boolean; start(resolution?: number): void; stop(): void; reset(): void; snapshot(): EventLoopLagSnapshot | null; } type AgentOptions = ConstructorParameters[0]; /** * Get or create the global singleton dispatcher for Node.js. * Reuses connections across all requests for optimal keep-alive and pipelining. */ declare function getGlobalDispatcher(options?: Partial): Agent; /** * Reset global dispatcher (useful for tests or custom tuning) */ declare function resetGlobalDispatcher(): void; /** * Legacy: Create a new dispatcher instance (not recommended for production) * @deprecated Use getGlobalDispatcher() for better connection pooling */ declare function createNodeDispatcher(options?: Partial): Agent; /** * Default HTTP client instance */ declare const http: HttpClient; /** * Convenience exports */ declare const get: (url: string | URL, options?: RequestOptions) => Promise; declare const post: (url: string | URL, body?: unknown, options?: RequestOptions) => Promise; declare const put: (url: string | URL, body?: unknown, options?: RequestOptions) => Promise; declare const patch: (url: string | URL, body?: unknown, options?: RequestOptions) => Promise; declare const del: (url: string | URL, options?: RequestOptions) => Promise; declare const head: (url: string | URL, options?: RequestOptions) => Promise; declare const options: (url: string | URL, options?: RequestOptions) => Promise; declare const create: (options?: RequestOptions) => HttpClient; declare const raw: (method: HttpMethod, url: string | URL, options?: RequestOptions) => Promise>; declare const paginate: (url: string | URL, options?: RequestOptions & { pagination?: PaginationOptions; }) => AsyncIterableIterator; export { AdaptiveConnectionPool, ChunkedStreamManager, CompressionManager, ContentNegotiation, EventLoopMonitor, HttpClient, HttpMethod, HttpResponse, PaginationOptions, RequestOptions, create, createNodeDispatcher, HttpClient as default, del, get, getGlobalAdaptivePool, getGlobalDispatcher, head, http, options, paginate, patch, post, processStream, put, raw, resetGlobalAdaptivePool, resetGlobalDispatcher, streamToBuffer, streamToText }; export type { AdaptivePoolConfig, ChunkedStreamConfig, PoolStats };