import { a as HttpResponse, R as RequestOptions, e as HttpError, H as HttpMethod, p as SigningConfig, q as OAuth2Config, r as SSRFProtectionConfig, s as SecretsConfig, l as CacheConfig, S as StreamConfig, n as ProgressCallback, D as DeduplicationConfig, u as RetryConfig, v as RateLimitConfig, Q as QueryParams, b as HeadersInit } from './zap.81717526.mjs'; import { z } from 'zod'; /** * Pagination configuration */ interface PaginationOptions { /** * Transform response body to items array * Default: returns response body as-is */ transform?: (response: HttpResponse) => R[]; /** * Determine next page URL/options * Return false to stop pagination */ paginate?: (context: { response: HttpResponse; currentItems: R[]; allItems: R[]; }) => false | { url?: string | URL; options?: RequestOptions; }; /** * Filter items (return false to exclude) * Default: include all items */ filter?: (item: R, index: number, allItems: R[]) => boolean; /** * Should pagination continue? * Default: continue until paginate returns false */ shouldContinue?: (context: { response: HttpResponse; currentItems: R[]; allItems: R[]; }) => boolean; /** * Maximum number of items to return * Default: Infinity */ countLimit?: number; /** * Maximum number of requests to make * Default: 10000 */ requestLimit?: number; /** * Delay between requests (ms) * Default: 0 */ backoff?: number; /** * Stack all items in memory * Default: false (stream items one by one) */ stackAllItems?: boolean; } /** * Link header entry */ interface LinkHeader { url: string; rel: string; [key: string]: string; } /** * Pagination state */ interface PaginationState { currentUrl: string | URL; currentOptions: RequestOptions; allItems: R[]; requestCount: number; isComplete: boolean; } /** * Plugin context provided to hooks */ interface PluginContext { request: Request; options: RequestOptions; } /** * Plugin response context */ interface PluginResponseContext extends PluginContext { response: HttpResponse; } /** * Plugin error context */ interface PluginErrorContext extends PluginContext { error: Error | HttpError; retryCount?: number; } /** * Plugin hook types */ type BeforeRequestHook = (context: PluginContext) => void | Promise | Request | Promise; type AfterResponseHook = (context: PluginResponseContext) => void | Promise | T | Promise; type BeforeErrorHook = (context: PluginErrorContext) => Error | Promise; type BeforeRetryHook = (context: PluginErrorContext) => void | boolean | symbol | Promise; /** * Plugin lifecycle hooks */ interface PluginHooks { /** * Called before request is sent * Can modify request or return new Request */ beforeRequest?: BeforeRequestHook | BeforeRequestHook[]; /** * Called after response is received * Can transform response data */ afterResponse?: AfterResponseHook | AfterResponseHook[]; /** * Called when error occurs * Can transform or handle error */ beforeError?: BeforeErrorHook | BeforeErrorHook[]; /** * Called before retry attempt * Return false or symbol to cancel retry */ beforeRetry?: BeforeRetryHook | BeforeRetryHook[]; } /** * Plugin metadata */ interface PluginMetadata { /** * Plugin name (unique identifier) */ name: string; /** * Plugin version */ version?: string; /** * Plugin description */ description?: string; /** * Plugin author */ author?: string; /** * Plugin dependencies (other plugin names) */ dependencies?: string[]; } /** * Plugin configuration */ interface PluginConfig { /** * Plugin is enabled/disabled */ enabled?: boolean; /** * Plugin-specific options */ options?: Record; } /** * Plugin interface */ interface Plugin { /** * Plugin metadata */ metadata: PluginMetadata; /** * Plugin lifecycle hooks */ hooks?: PluginHooks; /** * Plugin initialization * Called when plugin is registered */ init?: (config?: PluginConfig) => void | Promise; /** * Plugin cleanup * Called when plugin is unregistered */ destroy?: () => void | Promise; } /** * Plugin factory function */ type PluginFactory = (options?: T) => Plugin; /** * Symbol to cancel retry */ declare const CANCEL_RETRY: unique symbol; /** * Plugin Manager * Manages plugin lifecycle and hook execution */ declare class PluginManager { private plugins; private pluginOrder; /** * Register a plugin */ register(plugin: Plugin, config?: PluginConfig): Promise; /** * Unregister a plugin */ unregister(name: string): Promise; /** * Get registered plugin */ get(name: string): Plugin | undefined; /** * Check if plugin is registered */ has(name: string): boolean; /** * Get all registered plugins */ all(): Plugin[]; /** * Execute beforeRequest hooks */ executeBeforeRequest(context: PluginContext): Promise; /** * Execute afterResponse hooks */ executeAfterResponse(context: PluginResponseContext): Promise; /** * Execute beforeError hooks */ executeBeforeError(context: PluginErrorContext): Promise; /** * Execute beforeRetry hooks */ executeBeforeRetry(context: PluginErrorContext): Promise; /** * Clear all plugins */ clear(): Promise; } /** * HTTP Client ana class */ declare class HttpClient { private defaultOptions; private retryManager?; private rateLimiter?; private pluginManager; private hasFastPath; constructor(options?: RequestOptions); /** * Yeni bir instance oluştur (`.create()`) */ create(options?: RequestOptions): HttpClient; /** * Register a plugin */ use(plugin: Plugin, config?: PluginConfig): Promise; /** * Get plugin manager (for advanced plugin management) */ get plugins(): PluginManager; /** * Generic request method */ request(method: HttpMethod, url: string | URL, options?: RequestOptions): Promise; /** * Raw response döndür (with optional retry) */ raw(method: HttpMethod, url: string | URL, options?: RequestOptions): Promise>; /** * Execute HTTP request (actual implementation) */ private executeRequest; /** * GET request */ get(url: string | URL, options?: RequestOptions): Promise; /** * POST request */ post(url: string | URL, body?: unknown, options?: RequestOptions): Promise; /** * PUT request */ put(url: string | URL, body?: unknown, options?: RequestOptions): Promise; /** * PATCH request */ patch(url: string | URL, body?: unknown, options?: RequestOptions): Promise; /** * DELETE request */ delete(url: string | URL, options?: RequestOptions): Promise; /** * HEAD request */ head(url: string | URL, options?: RequestOptions): Promise; /** * OPTIONS request */ options(url: string | URL, options?: RequestOptions): Promise; /** * Response interceptor'ları çalıştır */ /** * Paginate through API responses (Got-style async iterator) * @example * ```ts * const pagination = client.paginate('https://api.github.com/repos/user/repo/commits', { * pagination: { countLimit: 10 } * }); * * for await (const commit of pagination) { * console.log(commit.message); * } * ``` */ paginate(url: string | URL, options?: RequestOptions & { pagination?: PaginationOptions; }): AsyncIterableIterator; /** * Default pagination function (uses Link header) */ private defaultPaginate; } /** * HTTP Error * Non-OK response'lar için özel error class */ declare class HTTPError extends Error implements HttpError { readonly name = "HttpError"; readonly request: Request; readonly response: Response; readonly options: RequestOptions; readonly status: number; readonly statusText: string; data?: unknown; constructor(request: Request, response: Response, options: RequestOptions, data?: unknown); /** * Error'ı JSON'a serialize et */ toJSON(): Record; } /** * Timeout Error */ declare class TimeoutError extends Error { readonly name = "TimeoutError"; readonly request: Request; constructor(request: Request, timeout: number); } /** * Network Error */ declare class NetworkError extends Error { readonly name = "NetworkError"; readonly request: Request; constructor(request: Request, cause?: Error); } /** * Request signer - AWS Signature v4 style HMAC signing */ declare class RequestSigner { private config; constructor(config: SigningConfig); /** * Sign a request */ signRequest(request: Request): Promise; /** * Create canonical request */ private createCanonicalRequest; /** * Get canonical URI */ private getCanonicalUri; /** * Get canonical query string */ private getCanonicalQueryString; /** * Get canonical headers */ private getCanonicalHeaders; /** * Get signed headers */ private getSignedHeaders; /** * Get body hash (SHA256) */ private getBodyHash; /** * Create string to sign */ private createStringToSign; /** * Calculate signature */ private calculateSignature; /** * Derive signing key */ private deriveSigningKey; /** * Create authorization header */ private createAuthorizationHeader; /** * SHA256 hash */ private sha256; /** * HMAC signature (returns hex) */ private hmac; /** * HMAC signature (returns buffer) */ private hmacBuffer; /** * Convert buffer to hex string */ private bufferToHex; } /** * OAuth 2.0 client * Desteklenen flow'lar: client_credentials, authorization_code, password, refresh_token */ declare class OAuth2Client { private config; private storage; private refreshPromise; private refreshTimer; constructor(config: OAuth2Config); /** * Access token al (cache'den veya yeni acquire) */ getAccessToken(): Promise; /** * Yeni token acquire et */ private acquireToken; /** * Token acquisition işlemi */ private performTokenAcquisition; /** * Client Credentials Flow */ private clientCredentialsFlow; /** * Password Flow (Resource Owner Password Credentials) */ private passwordFlow; /** * Refresh Access Token */ private refreshAccessToken; /** * Token response'u parse et */ private parseTokenResponse; /** * Token expired mi? */ private isTokenExpired; /** * Token refresh edilmeli mi? */ private shouldRefreshToken; /** * Token refresh'i schedule et */ private scheduleTokenRefresh; /** * Token'ı manuel clear et */ clearToken(): Promise; /** * Cleanup */ destroy(): void; } /** * SSRF Protection - URL validation ve private network blocking */ declare class SSRFProtection { private config; constructor(config: SSRFProtectionConfig); /** * URL'i validate et */ validateURL(url: string | URL): Promise; /** * Scheme validation (http/https only) */ private validateScheme; /** * Hostname validation (allowlist/blocklist) */ private validateHostname; /** * Port validation */ private validatePort; /** * IP address validation */ private validateIPAddress; /** * Hostname matching (supports wildcards) */ private matchHostname; /** * IP address matching (supports CIDR notation) */ private matchIPAddress; /** * CIDR matching (basit implementation) */ private matchCIDR; /** * Check if address is private network */ private checkPrivateNetwork; /** * DNS rebinding protection */ private checkDNSRebinding; /** * Check if IP is private */ private isPrivateIP; /** * Check if address is loopback */ private isLoopbackAddress; /** * Check if address is link-local */ private isLinkLocalAddress; /** * Check if hostname is known private */ private isKnownPrivateHostname; /** * Check if string is IP address */ private isIPAddress; /** * Check if string is IPv4 */ private isIPv4; /** * Check if string is IPv6 */ private isIPv6; /** * Convert IPv4 to integer */ private ipToInt; /** * Get default port for protocol */ private getDefaultPort; } /** * Secrets Manager - HashiCorp Vault, AWS Secrets Manager, environment variables */ declare class SecretsManager { private config; private secrets; private rotationTimer; constructor(config: SecretsConfig); /** * Initialize secrets manager */ initialize(): Promise; /** * Secret al */ getSecret(key: string): Promise; /** * Secret set et (manual) */ setSecret(key: string, value: string, version?: string): void; /** * Secret sil */ deleteSecret(key: string): void; /** * Tüm secrets'i clear et */ clearAll(): void; /** * Environment variables'dan load */ private loadFromEnv; /** * HashiCorp Vault'tan load */ private loadFromVault; /** * AWS Secrets Manager'dan load */ private loadFromAWS; /** * Custom provider ile secret load */ private loadSecret; /** * Secret rotation check başlat */ private startRotationCheck; /** * Secret rotation check */ private checkAndRotate; /** * Cleanup */ destroy(): void; } declare class CacheManager { private config; private cache; private totalBytes; private tags; constructor(config: CacheConfig); get(key: string): Promise; set(key: string, data: T, options?: { ttl?: number; tags?: string[]; size?: number; }): Promise; delete(key: string): boolean; invalidateByTags(tags: string[]): Promise; clear(): void; getStats(): { size: number; bytes: number; maxSize: number; maxBytes: number; }; private estimateSize; private evictToMakeSpace; } declare class MultiLayerCache { private l1; private l2?; constructor(l1Config: CacheConfig, l2Config?: CacheConfig); get(key: string): Promise; set(key: string, data: T, options?: { ttl?: number; tags?: string[]; }): Promise; delete(key: string): Promise; invalidateByTags(tags: string[]): Promise; clear(): void; } declare class UploadStreamManager { private config; private onProgress?; private startTime; private lastTime; private lastLoaded; constructor(config: StreamConfig, onProgress?: ProgressCallback | undefined); streamUpload(data: ReadableStream | Blob | ArrayBuffer, total: number): Promise; private createProgressStream; private reportProgress; } declare class DownloadStreamManager { private config; private onProgress?; private startTime; private lastTime; private lastLoaded; constructor(config: StreamConfig, onProgress?: ProgressCallback | undefined); streamDownload(response: Response): Promise>; private createProgressStream; downloadWithResume(url: string, options: RequestInit, resumeFrom?: number): Promise; private getContentLength; private reportProgress; } declare class ChunkedTransferManager { readChunks(stream: ReadableStream, chunkSize?: number): AsyncGenerator; readChunksPooled(stream: ReadableStream): AsyncGenerator; streamToArrayBuffer(stream: ReadableStream, usePooling?: boolean): Promise; streamToString(stream: ReadableStream): Promise; } declare class ResumableDownloadManager { private config; private states; constructor(config: StreamConfig); download(url: string, onProgress?: ProgressCallback): Promise; private combineChunks; cancelDownload(url: string): void; getProgress(url: string): number; } declare class DeduplicationManager { private config; private storage; private cleanupTimer; private allowed; private hitCount; private missCount; private adaptiveTTL; constructor(config: DeduplicationConfig); executeWithDeduplication(request: Request, operation: () => Promise): Promise; private generateKey; private startCleanup; private startAdaptiveTTL; clear(): Promise; destroy(): void; } /** * Generic object pool implementation * Reduces GC pressure by reusing objects */ interface PoolConfig { maxSize: number; factory: () => T; reset: (obj: T) => void; } /** * Buffer pool for streaming operations */ declare class BufferPool { private pool; private maxSize; private bufferSize; constructor(bufferSize?: number); /** * Acquire buffer from pool */ acquire(): Uint8Array; /** * Release buffer back to pool */ release(buffer: Uint8Array): void; /** * Clear pool */ clear(): void; } declare const bufferPool: BufferPool; /** * Multi-size buffer pool for optimal memory usage * Supports multiple buffer sizes to reduce fragmentation */ declare class MultiSizeBufferPool { private pools; private stats; private bucketSizes; private maxPoolSizePerBucket; /** * Acquire buffer of requested size */ acquire(requestedSize: number): Uint8Array; /** * Release buffer back to pool */ release(buffer: Uint8Array): void; /** * Find appropriate bucket size for requested size */ private findBucketSize; /** * Get pool statistics */ getStats(): { hitRate: string; pools: { size: string; count: number; }[]; acquired: number; released: number; poolHits: number; poolMisses: number; }; /** * Clear all pools */ clear(): void; } declare const multiSizeBufferPool: MultiSizeBufferPool; /** * URL parsing cache * Reduces URL parsing overhead for repeated requests */ declare class URLCache { private cache; private maxSize; private ttl; /** * Get cached URL or parse and cache */ get(urlString: string): URL; /** * Clear cache */ clear(): void; /** * Get cache stats */ get stats(): { size: number; maxSize: number; }; } declare const urlCache: URLCache; /** * Cache Pre-warming and Background Sync Manager * Enterprise-grade performance optimization for cold starts */ interface PrewarmConfig { enabled: boolean; endpoints: PrewarmEndpoint[]; strategy?: 'parallel' | 'sequential' | 'adaptive'; priority?: 'high' | 'normal' | 'low'; timeout?: number; retryOnFail?: boolean; } interface PrewarmEndpoint { url: string; method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; priority?: number; ttl?: number; tags?: string[]; prefetch?: boolean; } interface BackgroundSyncConfig { enabled: boolean; interval: number; endpoints?: string[]; onUpdate?: (url: string, data: unknown) => void; retryAttempts?: number; adaptive?: boolean; } interface SWRConfig { enabled: boolean; staleTime: number; revalidateTime: number; onStale?: (url: string) => void; onRevalidate?: (url: string) => void; } /** * Cache Pre-warmer * Warms up cache on app startup for critical endpoints */ declare class CachePrewarmer { private client; private config; private isWarming; private warmingPromise; constructor(client: HttpClient, config: PrewarmConfig); warmup(): Promise; private executeWarmup; private warmupSingle; isWarmingUp(): boolean; } /** * Background Sync Manager * Automatically refreshes cache in background */ declare class BackgroundSyncManager { private client; private config; private intervalId; private isRunning; constructor(client: HttpClient, config: BackgroundSyncConfig); start(): void; stop(): void; private sync; private delay; isActive(): boolean; } /** * Stale-While-Revalidate (SWR) Manager * Returns stale cache immediately, revalidates in background */ declare class SWRManager { private client; private config; private revalidationQueue; private isRevalidating; constructor(client: HttpClient, config: SWRConfig); get(url: string, fetchFn?: () => Promise): Promise; private scheduleRevalidation; private revalidate; clearQueue(): void; getQueueSize(): number; } /** * Prefetch Manager * Prefetches next page/data before user requests */ declare class PrefetchManager { private client; private prefetchQueue; private maxConcurrent; private currentConcurrent; constructor(client: HttpClient, maxConcurrent?: number); prefetch(url: string, priority?: number): Promise; private executePrefetch; private processQueue; private delay; prefetchNext(currentPage: number, urlPattern: (page: number) => string, lookahead?: number): Promise; clear(): void; getPendingCount(): number; } /** * Combined Performance Manager * Orchestrates all performance optimization features */ declare class PerformanceManager { private client; private prewarm; private backgroundSync; private swr; private prefetch; constructor(client: HttpClient); enablePrewarming(config: PrewarmConfig): this; enableBackgroundSync(config: BackgroundSyncConfig): this; enableSWR(config: SWRConfig): this; enablePrefetch(maxConcurrent?: number): this; initialize(): Promise; shutdown(): void; getPrewarmer(): CachePrewarmer | null; getBackgroundSync(): BackgroundSyncManager | null; getSWR(): SWRManager | null; getPrefetch(): PrefetchManager | null; } /** * Retry Manager * Production-grade retry with exponential backoff + jitter */ declare class RetryManager { private config; private retryCount; private totalRequests; private totalRetries; private lastWindowReset; constructor(config: RetryConfig); /** * Retry-able bir işlemi execute et */ executeWithRetry(operation: () => Promise, context: { method: string; url: string; attempt?: number; }): Promise; /** * Retry yapılmalı mı? */ private shouldRetry; /** * Method idempotent mi? */ private isIdempotentMethod; /** * Network error mi? */ private isNetworkError; /** * Retry delay hesapla (jitter ile) */ private calculateDelay; /** * Jitter uygula */ private applyJitter; /** * Decorrelated jitter (AWS recommended) */ private decorrelatedJitter; /** * Fibonacci sequence */ private fibonacci; /** * Retry budget check */ private canRetry; /** * Retry count operations */ private getRetryCount; private incrementRetryCount; private resetRetryCount; /** * Sleep helper */ private sleep; /** * Stats */ getStats(): { totalRequests: number; totalRetries: number; retryRate: number; }; /** * Reset stats */ resetStats(): void; } declare class RateLimiterManager { private config; private limiters; private queues; private queueTimers; constructor(config: RateLimitConfig); acquire(endpoint: string): Promise; private acquireWithQueue; private processQueue; private getNextQueueItem; private getLimiter; private getQueue; private getRetryAfter; reset(endpoint?: string): void; destroy(): void; } /** * URL'i oluştur (baseURL + path + query params) */ declare function buildURL(input: string | URL, baseURL?: string, query?: QueryParams): string; /** * Parse URL (with caching for repeated URLs) */ declare function parseURL(url: string | URL): URL; /** * Headers'ı normalize et */ declare function normalizeHeaders(headers?: HeadersInit): Headers; /** * Merge headers */ declare function mergeHeaders(...headersList: Array): Headers; /** * Body'yi serialize et */ declare function serializeBody(body: unknown): string | FormData | URLSearchParams | ReadableStream | null; /** * Content-Type'a göre body parse et */ declare function parseResponseBody(response: Response, responseType?: string): Promise; /** * Response'u schema ile validate et */ declare function validateResponse(data: unknown, schema?: z.ZodSchema): Promise; /** * Parse Link header (RFC 5988) * Example: ; rel="next", ; rel="last" */ declare function parseLinkHeader(header: string): LinkHeader[]; /** * Find link by rel */ declare function findLinkByRel(links: LinkHeader[], rel: string): LinkHeader | undefined; /** * Extract next page URL from Link header */ declare function getNextPageUrl(linkHeader: string): string | null; /** * Logger plugin options */ interface LoggerOptions { /** * Enable request logging */ logRequests?: boolean; /** * Enable response logging */ logResponses?: boolean; /** * Enable error logging */ logErrors?: boolean; /** * Custom logger function */ logger?: (level: 'info' | 'error', message: string, data?: unknown) => void; /** * Include headers in logs */ includeHeaders?: boolean; /** * Include body in logs */ includeBody?: boolean; /** * Maximum body length to log (prevent huge logs) */ maxBodyLength?: number; } /** * Logger Plugin * Logs HTTP requests, responses, and errors * * @example * ```ts * import { http } from '@ahmetshbz/zap'; * import { loggerPlugin } from '@ahmetshbz/zap/plugins'; * * await http.use(loggerPlugin({ * logRequests: true, * logResponses: true, * includeHeaders: true, * })); * ``` */ declare const loggerPlugin: PluginFactory; /** * Auth plugin options */ interface AuthOptions { /** * Auth type */ type: 'bearer' | 'basic' | 'apiKey' | 'custom'; /** * Token for bearer auth */ token?: string | (() => string | Promise); /** * Username for basic auth */ username?: string; /** * Password for basic auth */ password?: string; /** * API key value */ apiKey?: string; /** * API key header name (default: 'X-API-Key') */ apiKeyHeader?: string; /** * Custom auth header name */ customHeader?: string; /** * Custom auth header value */ customValue?: string | (() => string | Promise); /** * Token refresh function * Called when 401 error occurs */ refreshToken?: () => string | Promise; /** * Skip auth for specific URLs (regex patterns) */ skipUrls?: RegExp[]; } /** * Auth Plugin * Automatically injects authentication headers * * @example * ```ts * import { http } from '@ahmetshbz/zap'; * import { authPlugin } from '@ahmetshbz/zap/plugins'; * * // Bearer token * await http.use(authPlugin({ * type: 'bearer', * token: 'your-token-here', * })); * * // Basic auth * await http.use(authPlugin({ * type: 'basic', * username: 'user', * password: 'pass', * })); * * // API Key * await http.use(authPlugin({ * type: 'apiKey', * apiKey: 'your-api-key', * apiKeyHeader: 'X-API-Key', * })); * ``` */ declare const authPlugin: PluginFactory; /** * Request metrics */ interface RequestMetrics { url: string; method: string; status?: number; duration: number; timestamp: number; error?: string; } /** * Aggregated metrics */ interface AggregatedMetrics { totalRequests: number; successfulRequests: number; failedRequests: number; averageDuration: number; minDuration: number; maxDuration: number; requestsByMethod: Record; requestsByStatus: Record; errorsByType: Record; } /** * Metrics plugin options */ interface MetricsOptions { /** * Callback for each request metric */ onMetric?: (metric: RequestMetrics) => void; /** * Enable aggregated metrics */ enableAggregation?: boolean; /** * Collect metrics for specific URLs only (regex patterns) */ includeUrls?: RegExp[]; /** * Exclude metrics for specific URLs (regex patterns) */ excludeUrls?: RegExp[]; } /** * Metrics Plugin * Collects and tracks HTTP request metrics * * @example * ```ts * import { http } from '@ahmetshbz/zap'; * import { metricsPlugin } from '@ahmetshbz/zap/plugins'; * * const metrics = metricsPlugin({ * enableAggregation: true, * onMetric: (metric) => { * console.log(`${metric.method} ${metric.url} - ${metric.duration}ms`); * }, * }); * * await http.use(metrics); * * // Get aggregated metrics * const stats = metrics.getMetrics(); * console.log(`Average duration: ${stats.averageDuration}ms`); * ``` */ declare const metricsPlugin: PluginFactory & { getMetrics?: () => AggregatedMetrics; reset?: () => void; }; /** * Retry plugin options */ interface RetryPluginOptions { /** * Maximum retry attempts */ maxAttempts?: number; /** * Initial delay in milliseconds */ initialDelay?: number; /** * Maximum delay in milliseconds */ maxDelay?: number; /** * Backoff multiplier */ multiplier?: number; /** * Status codes to retry on */ statusCodes?: number[]; /** * HTTP methods to retry */ methods?: string[]; /** * Custom retry condition */ shouldRetry?: (context: { error: Error; attempt: number; request: Request; }) => boolean | Promise; /** * Callback before each retry */ onRetry?: (context: { error: Error; attempt: number; delay: number; request: Request; }) => void | Promise; } /** * Retry Plugin * Advanced retry mechanism with exponential backoff * * @example * ```ts * import { http } from '@ahmetshbz/zap'; * import { retryPlugin } from '@ahmetshbz/zap/plugins'; * * await http.use(retryPlugin({ * maxAttempts: 3, * initialDelay: 100, * maxDelay: 5000, * statusCodes: [408, 429, 500, 502, 503, 504], * onRetry: ({ attempt, delay }) => { * console.log(`Retry attempt ${attempt} after ${delay}ms`); * }, * })); * ``` */ declare const retryPlugin: PluginFactory; export { serializeBody as $, CANCEL_RETRY as C, DownloadStreamManager as D, SWRManager as E, PrefetchManager as F, PerformanceManager as G, HttpClient as H, MultiLayerCache as M, NetworkError as N, OAuth2Client as O, RequestSigner as R, SSRFProtection as S, TimeoutError as T, UploadStreamManager as U, RetryManager as V, RateLimiterManager as W, buildURL as X, parseURL as Y, normalizeHeaders as Z, mergeHeaders as _, HTTPError as a, parseResponseBody as a0, validateResponse as a1, parseLinkHeader as a2, findLinkByRel as a3, getNextPageUrl as a4, loggerPlugin as a5, authPlugin as a7, metricsPlugin as a9, retryPlugin as ad, PluginManager as b, SecretsManager as n, CacheManager as o, ChunkedTransferManager as p, ResumableDownloadManager as q, DeduplicationManager as r, BufferPool as s, bufferPool as t, MultiSizeBufferPool as u, multiSizeBufferPool as v, urlCache as x, CachePrewarmer as y, BackgroundSyncManager as z }; export type { AfterResponseHook as A, BeforeRequestHook as B, PrewarmConfig as I, PrewarmEndpoint as J, BackgroundSyncConfig as K, LinkHeader as L, PaginationOptions as P, SWRConfig as Q, LoggerOptions as a6, AuthOptions as a8, MetricsOptions as aa, RequestMetrics as ab, AggregatedMetrics as ac, RetryPluginOptions as ae, PaginationState as c, Plugin as d, PluginFactory as e, PluginMetadata as f, PluginConfig as g, PluginHooks as h, PluginContext as i, PluginResponseContext as j, PluginErrorContext as k, BeforeErrorHook as l, BeforeRetryHook as m, PoolConfig as w };