rezo 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +352 -9
  2. package/dist/adapters/curl.cjs +796 -0
  3. package/dist/adapters/curl.js +796 -0
  4. package/dist/adapters/entries/curl.d.ts +2407 -20
  5. package/dist/adapters/entries/fetch.d.ts +364 -20
  6. package/dist/adapters/entries/http.d.ts +364 -20
  7. package/dist/adapters/entries/http2.d.ts +364 -20
  8. package/dist/adapters/entries/react-native.d.ts +364 -20
  9. package/dist/adapters/entries/xhr.d.ts +364 -20
  10. package/dist/adapters/index.cjs +6 -6
  11. package/dist/adapters/picker.cjs +2 -2
  12. package/dist/adapters/picker.js +2 -2
  13. package/dist/cache/index.cjs +13 -13
  14. package/dist/core/hooks.cjs +2 -0
  15. package/dist/core/hooks.js +2 -0
  16. package/dist/core/rezo.cjs +2 -2
  17. package/dist/core/rezo.js +2 -2
  18. package/dist/crawler.d.ts +366 -22
  19. package/dist/entries/crawler.cjs +5 -5
  20. package/dist/index.cjs +23 -18
  21. package/dist/index.d.ts +631 -20
  22. package/dist/index.js +1 -0
  23. package/dist/platform/browser.d.ts +364 -20
  24. package/dist/platform/bun.d.ts +364 -20
  25. package/dist/platform/deno.d.ts +364 -20
  26. package/dist/platform/node.d.ts +364 -20
  27. package/dist/platform/react-native.d.ts +364 -20
  28. package/dist/platform/worker.d.ts +364 -20
  29. package/dist/plugin/crawler-options.cjs +1 -1
  30. package/dist/plugin/crawler-options.js +1 -1
  31. package/dist/plugin/crawler.cjs +2 -2
  32. package/dist/plugin/crawler.js +2 -2
  33. package/dist/plugin/index.cjs +36 -36
  34. package/dist/proxy/index.cjs +2 -2
  35. package/dist/proxy/manager.cjs +57 -2
  36. package/dist/proxy/manager.js +57 -2
  37. package/dist/queue/http-queue.cjs +313 -0
  38. package/dist/queue/http-queue.js +312 -0
  39. package/dist/queue/index.cjs +8 -0
  40. package/dist/queue/index.js +6 -0
  41. package/dist/queue/queue.cjs +346 -0
  42. package/dist/queue/queue.js +344 -0
  43. package/dist/queue/types.cjs +17 -0
  44. package/dist/queue/types.js +17 -0
  45. package/dist/types/curl-options.cjs +25 -0
  46. package/dist/types/curl-options.js +25 -0
  47. package/dist/utils/http-config.cjs +0 -15
  48. package/dist/utils/http-config.js +0 -15
  49. package/package.json +1 -2
package/dist/index.d.ts CHANGED
@@ -6,9 +6,6 @@ import { Agent as HttpsAgent } from 'node:https';
6
6
  import { Socket } from 'node:net';
7
7
  import { Readable, Writable, WritableOptions } from 'node:stream';
8
8
  import { SecureContext, TLSSocket } from 'node:tls';
9
- import PQueue from 'p-queue';
10
- import { Options as Options$1, QueueAddOptions } from 'p-queue';
11
- import PriorityQueue from 'p-queue/dist/priority-queue';
12
9
  import { Cookie as TouchCookie, CookieJar as TouchCookieJar, CreateCookieOptions } from 'tough-cookie';
13
10
 
14
11
  export interface RezoHttpHeaders {
@@ -972,8 +969,17 @@ export interface ProxyCooldownConfig {
972
969
  * Complete configuration for proxy rotation, filtering, and failure handling
973
970
  */
974
971
  export interface ProxyManagerBaseConfig {
975
- /** Array of proxies to manage */
976
- proxies: ProxyInfo[];
972
+ /**
973
+ * Array of proxies to manage
974
+ * Accepts ProxyInfo objects or proxy URL strings (parsed via parseProxyString)
975
+ * @example
976
+ * proxies: [
977
+ * { protocol: 'http', host: '127.0.0.1', port: 8080 },
978
+ * 'socks5://user:pass@proxy.example.com:1080',
979
+ * 'http://proxy.example.com:3128'
980
+ * ]
981
+ */
982
+ proxies: (ProxyInfo | string)[];
977
983
  /**
978
984
  * Whitelist patterns for URLs that should use proxy
979
985
  * - String: exact domain match (e.g., 'api.example.com') or subdomain match (e.g., 'example.com' matches '*.example.com')
@@ -1185,6 +1191,35 @@ export interface AfterProxyEnableContext {
1185
1191
  /** Reason for enabling */
1186
1192
  reason: "cooldown-expired" | "manual";
1187
1193
  }
1194
+ /**
1195
+ * Context for onNoProxiesAvailable hook
1196
+ * Triggered when no proxies are available and an error would be thrown
1197
+ */
1198
+ export interface OnNoProxiesAvailableContext {
1199
+ /** Request URL that needed a proxy */
1200
+ url: string;
1201
+ /** The error that will be thrown */
1202
+ error: Error;
1203
+ /** All proxies (including disabled ones) */
1204
+ allProxies: ProxyState[];
1205
+ /** Number of active proxies (should be 0) */
1206
+ activeCount: number;
1207
+ /** Number of disabled proxies */
1208
+ disabledCount: number;
1209
+ /** Number of proxies in cooldown */
1210
+ cooldownCount: number;
1211
+ /** Reasons why proxies are unavailable */
1212
+ disabledReasons: {
1213
+ /** Proxies disabled due to failures */
1214
+ dead: number;
1215
+ /** Proxies disabled due to request limit */
1216
+ limitReached: number;
1217
+ /** Proxies manually disabled */
1218
+ manual: number;
1219
+ };
1220
+ /** Timestamp when this event occurred */
1221
+ timestamp: number;
1222
+ }
1188
1223
  /**
1189
1224
  * Context provided to beforeRequest hook
1190
1225
  * Contains metadata about the current request state
@@ -1503,6 +1538,16 @@ export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void |
1503
1538
  * Use for notifications, logging
1504
1539
  */
1505
1540
  export type AfterProxyEnableHook = (context: AfterProxyEnableContext) => void | Promise<void>;
1541
+ /**
1542
+ * Hook called when no proxies are available and an error is about to be thrown
1543
+ * Use for alerting, logging exhausted proxy pools, or triggering proxy refresh
1544
+ * This hook is called just before the error is thrown, allowing you to:
1545
+ * - Log the exhaustion event for monitoring
1546
+ * - Trigger external proxy pool refresh
1547
+ * - Send alerts to monitoring systems
1548
+ * - Record statistics about proxy pool health
1549
+ */
1550
+ export type OnNoProxiesAvailableHook = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
1506
1551
  /**
1507
1552
  * Collection of all hook types
1508
1553
  * All hooks are arrays to allow multiple handlers
@@ -1527,6 +1572,7 @@ export interface RezoHooks {
1527
1572
  afterProxyDisable: AfterProxyDisableHook[];
1528
1573
  afterProxyRotate: AfterProxyRotateHook[];
1529
1574
  afterProxyEnable: AfterProxyEnableHook[];
1575
+ onNoProxiesAvailable: OnNoProxiesAvailableHook[];
1530
1576
  onSocket: OnSocketHook[];
1531
1577
  onDns: OnDnsHook[];
1532
1578
  onTls: OnTlsHook[];
@@ -1983,6 +2029,401 @@ export declare class RezoError<T = any> extends Error {
1983
2029
  toString(): string;
1984
2030
  getFullDetails(): string;
1985
2031
  }
2032
+ /**
2033
+ * RezoQueue - High-performance task queue with priority, concurrency, and HTTP-aware features
2034
+ * @module queue/types
2035
+ */
2036
+ /**
2037
+ * Priority levels for queue ordering (higher = runs first)
2038
+ */
2039
+ export declare const Priority: {
2040
+ readonly LOWEST: 0;
2041
+ readonly LOW: 25;
2042
+ readonly NORMAL: 50;
2043
+ readonly HIGH: 75;
2044
+ readonly HIGHEST: 100;
2045
+ readonly CRITICAL: 1000;
2046
+ };
2047
+ /**
2048
+ * HTTP method priority presets
2049
+ */
2050
+ export declare const HttpMethodPriority: Record<string, number>;
2051
+ /**
2052
+ * Queue configuration options
2053
+ */
2054
+ export interface QueueConfig {
2055
+ /** Maximum concurrent tasks (default: Infinity) */
2056
+ concurrency?: number;
2057
+ /** Auto-start processing when tasks are added (default: true) */
2058
+ autoStart?: boolean;
2059
+ /** Timeout per task in milliseconds (default: none) */
2060
+ timeout?: number;
2061
+ /** Throw on timeout vs silently fail (default: true) */
2062
+ throwOnTimeout?: boolean;
2063
+ /** Interval between task starts in ms for rate limiting */
2064
+ interval?: number;
2065
+ /** Max tasks to start per interval (default: Infinity) */
2066
+ intervalCap?: number;
2067
+ /** Carry over unused interval capacity to next interval */
2068
+ carryoverConcurrencyCount?: boolean;
2069
+ }
2070
+ /**
2071
+ * HTTP-specific queue configuration
2072
+ */
2073
+ export interface HttpQueueConfig extends QueueConfig {
2074
+ /** Per-domain concurrency limits */
2075
+ domainConcurrency?: number | Record<string, number>;
2076
+ /** Global requests per second limit */
2077
+ requestsPerSecond?: number;
2078
+ /** Respect Retry-After headers automatically */
2079
+ respectRetryAfter?: boolean;
2080
+ /** Respect X-RateLimit-* headers automatically */
2081
+ respectRateLimitHeaders?: boolean;
2082
+ /** Retry failed tasks automatically */
2083
+ autoRetry?: boolean;
2084
+ /** Max retry attempts for auto-retry */
2085
+ maxRetries?: number;
2086
+ /** Delay between retries (supports backoff function) */
2087
+ retryDelay?: number | ((attempt: number) => number);
2088
+ /** Status codes that trigger retry */
2089
+ retryStatusCodes?: number[];
2090
+ }
2091
+ /**
2092
+ * Task options when adding to queue
2093
+ */
2094
+ export interface TaskOptions {
2095
+ /** Task priority (higher runs first, default: 0) */
2096
+ priority?: number;
2097
+ /** Task-specific timeout (overrides queue default) */
2098
+ timeout?: number;
2099
+ /** Unique ID for tracking/cancellation */
2100
+ id?: string;
2101
+ /** Signal for external cancellation */
2102
+ signal?: AbortSignal;
2103
+ }
2104
+ /**
2105
+ * HTTP-specific task options
2106
+ */
2107
+ export interface HttpTaskOptions extends TaskOptions {
2108
+ /** Domain for per-domain limiting (auto-extracted if not provided) */
2109
+ domain?: string;
2110
+ /** HTTP method for method-based priority */
2111
+ method?: string;
2112
+ /** Retry this specific task on failure */
2113
+ retry?: boolean | number;
2114
+ /** Custom retry delay for this task */
2115
+ retryDelay?: number;
2116
+ }
2117
+ /**
2118
+ * Current queue state
2119
+ */
2120
+ export interface QueueState {
2121
+ /** Number of tasks currently running */
2122
+ pending: number;
2123
+ /** Number of tasks waiting in queue */
2124
+ size: number;
2125
+ /** Total tasks (pending + size) */
2126
+ total: number;
2127
+ /** Is queue paused */
2128
+ isPaused: boolean;
2129
+ /** Is queue idle (no tasks) */
2130
+ isIdle: boolean;
2131
+ }
2132
+ /**
2133
+ * Queue statistics
2134
+ */
2135
+ export interface QueueStats {
2136
+ /** Total tasks added since creation */
2137
+ added: number;
2138
+ /** Total tasks processed (started) */
2139
+ processed: number;
2140
+ /** Total successful completions */
2141
+ completed: number;
2142
+ /** Total failures */
2143
+ failed: number;
2144
+ /** Total timeouts */
2145
+ timedOut: number;
2146
+ /** Total cancellations */
2147
+ cancelled: number;
2148
+ /** Average task duration (ms) */
2149
+ averageDuration: number;
2150
+ /** Tasks per second (rolling average) */
2151
+ throughput: number;
2152
+ }
2153
+ /**
2154
+ * HTTP-specific statistics
2155
+ */
2156
+ export interface HttpQueueStats extends QueueStats {
2157
+ /** Stats per domain */
2158
+ byDomain: Record<string, {
2159
+ pending: number;
2160
+ completed: number;
2161
+ failed: number;
2162
+ rateLimited: number;
2163
+ }>;
2164
+ /** Total retries performed */
2165
+ retries: number;
2166
+ /** Rate limit events */
2167
+ rateLimitHits: number;
2168
+ }
2169
+ /**
2170
+ * Domain-specific state
2171
+ */
2172
+ export interface DomainState {
2173
+ /** Number of tasks currently running for domain */
2174
+ pending: number;
2175
+ /** Number of tasks waiting for domain */
2176
+ size: number;
2177
+ /** Is domain paused */
2178
+ isPaused: boolean;
2179
+ /** Rate limit until timestamp (if rate limited) */
2180
+ rateLimitedUntil?: number;
2181
+ }
2182
+ /**
2183
+ * Queue event types
2184
+ */
2185
+ export interface QueueEvents {
2186
+ /** Task added to queue */
2187
+ add: {
2188
+ id: string;
2189
+ priority: number;
2190
+ };
2191
+ /** Task started executing */
2192
+ start: {
2193
+ id: string;
2194
+ };
2195
+ /** Task completed successfully */
2196
+ completed: {
2197
+ id: string;
2198
+ result: any;
2199
+ duration: number;
2200
+ };
2201
+ /** Task failed with error */
2202
+ error: {
2203
+ id: string;
2204
+ error: Error;
2205
+ };
2206
+ /** Task timed out */
2207
+ timeout: {
2208
+ id: string;
2209
+ };
2210
+ /** Task cancelled */
2211
+ cancelled: {
2212
+ id: string;
2213
+ };
2214
+ /** Queue became active (was idle, now processing) */
2215
+ active: undefined;
2216
+ /** Queue became idle (all tasks done) */
2217
+ idle: undefined;
2218
+ /** Queue was paused */
2219
+ paused: undefined;
2220
+ /** Queue was resumed */
2221
+ resumed: undefined;
2222
+ /** Next task about to run */
2223
+ next: undefined;
2224
+ /** Queue was emptied (no pending tasks) */
2225
+ empty: undefined;
2226
+ }
2227
+ /**
2228
+ * HTTP-specific events
2229
+ */
2230
+ export interface HttpQueueEvents extends QueueEvents {
2231
+ /** Rate limit hit for a domain */
2232
+ rateLimited: {
2233
+ domain: string;
2234
+ retryAfter: number;
2235
+ };
2236
+ /** Domain queue became available */
2237
+ domainAvailable: {
2238
+ domain: string;
2239
+ };
2240
+ /** Task being retried */
2241
+ retry: {
2242
+ id: string;
2243
+ attempt: number;
2244
+ error: Error;
2245
+ };
2246
+ }
2247
+ /**
2248
+ * Event handler type
2249
+ */
2250
+ export type EventHandler<T> = (data: T) => void;
2251
+ /**
2252
+ * Task function type
2253
+ */
2254
+ export type TaskFunction<T> = () => Promise<T>;
2255
+ /**
2256
+ * RezoQueue - A high-performance task queue with priority and concurrency control
2257
+ *
2258
+ * Features:
2259
+ * - Priority-based task ordering (higher priority runs first)
2260
+ * - Configurable concurrency limits
2261
+ * - Task timeout support
2262
+ * - Pause/resume functionality
2263
+ * - Interval-based rate limiting
2264
+ * - Task cancellation by ID
2265
+ * - Comprehensive event system
2266
+ * - Detailed statistics tracking
2267
+ *
2268
+ * @example
2269
+ * ```typescript
2270
+ * const queue = new RezoQueue({ concurrency: 5 });
2271
+ *
2272
+ * // Add tasks with priority
2273
+ * const result = await queue.add(() => fetchData(), { priority: 100 });
2274
+ *
2275
+ * // Wait for all tasks to complete
2276
+ * await queue.onIdle();
2277
+ * ```
2278
+ */
2279
+ export declare class RezoQueue<T = any> {
2280
+ private queue;
2281
+ private pendingCount;
2282
+ private isPausedFlag;
2283
+ private intervalId?;
2284
+ private intervalCount;
2285
+ private intervalStart;
2286
+ private eventHandlers;
2287
+ private statsData;
2288
+ private totalDuration;
2289
+ private throughputWindow;
2290
+ private readonly throughputWindowSize;
2291
+ private idlePromise?;
2292
+ private emptyPromise?;
2293
+ readonly config: Required<QueueConfig>;
2294
+ /**
2295
+ * Create a new RezoQueue
2296
+ * @param config - Queue configuration options
2297
+ */
2298
+ constructor(config?: QueueConfig);
2299
+ /**
2300
+ * Get current queue state
2301
+ */
2302
+ get state(): QueueState;
2303
+ /**
2304
+ * Get queue statistics
2305
+ */
2306
+ get stats(): QueueStats;
2307
+ /**
2308
+ * Get/set concurrency limit
2309
+ */
2310
+ get concurrency(): number;
2311
+ set concurrency(value: number);
2312
+ /**
2313
+ * Number of pending (running) tasks
2314
+ */
2315
+ get pending(): number;
2316
+ /**
2317
+ * Number of tasks waiting in queue
2318
+ */
2319
+ get size(): number;
2320
+ /**
2321
+ * Check if queue is paused
2322
+ */
2323
+ get isPaused(): boolean;
2324
+ /**
2325
+ * Add a task to the queue
2326
+ * @param fn - Async function to execute
2327
+ * @param options - Task options
2328
+ * @returns Promise resolving to task result
2329
+ */
2330
+ add<R = T>(fn: TaskFunction<R>, options?: TaskOptions): Promise<R>;
2331
+ /**
2332
+ * Add multiple tasks to the queue
2333
+ * @param fns - Array of async functions
2334
+ * @param options - Task options (applied to all)
2335
+ * @returns Promise resolving to array of results
2336
+ */
2337
+ addAll<R = T>(fns: TaskFunction<R>[], options?: TaskOptions): Promise<R[]>;
2338
+ /**
2339
+ * Pause queue processing (running tasks continue)
2340
+ */
2341
+ pause(): void;
2342
+ /**
2343
+ * Resume queue processing
2344
+ */
2345
+ start(): void;
2346
+ /**
2347
+ * Clear all pending tasks from queue
2348
+ */
2349
+ clear(): void;
2350
+ /**
2351
+ * Cancel a specific task by ID
2352
+ * @param id - Task ID to cancel
2353
+ * @returns true if task was found and cancelled
2354
+ */
2355
+ cancel(id: string): boolean;
2356
+ /**
2357
+ * Cancel all tasks matching a predicate
2358
+ * @param predicate - Function to test each task
2359
+ * @returns Number of tasks cancelled
2360
+ */
2361
+ cancelBy(predicate: (task: {
2362
+ id: string;
2363
+ priority: number;
2364
+ }) => boolean): number;
2365
+ /**
2366
+ * Wait for queue to become idle (no running or pending tasks)
2367
+ */
2368
+ onIdle(): Promise<void>;
2369
+ /**
2370
+ * Wait for queue to be empty (no pending tasks, but may have running)
2371
+ */
2372
+ onEmpty(): Promise<void>;
2373
+ /**
2374
+ * Wait for queue size to be less than limit
2375
+ * @param limit - Size threshold
2376
+ */
2377
+ onSizeLessThan(limit: number): Promise<void>;
2378
+ /**
2379
+ * Register an event handler
2380
+ * @param event - Event name
2381
+ * @param handler - Handler function
2382
+ */
2383
+ on<E extends keyof QueueEvents>(event: E, handler: EventHandler<QueueEvents[E]>): void;
2384
+ /**
2385
+ * Remove an event handler
2386
+ * @param event - Event name
2387
+ * @param handler - Handler function to remove
2388
+ */
2389
+ off<E extends keyof QueueEvents>(event: E, handler: EventHandler<QueueEvents[E]>): void;
2390
+ /**
2391
+ * Destroy the queue and cleanup resources
2392
+ */
2393
+ destroy(): void;
2394
+ /**
2395
+ * Insert task into queue maintaining priority order (highest first)
2396
+ */
2397
+ private insertByPriority;
2398
+ /**
2399
+ * Try to run next task if capacity available
2400
+ */
2401
+ private tryRunNext;
2402
+ /**
2403
+ * Execute a task
2404
+ */
2405
+ private runTask;
2406
+ /**
2407
+ * Record task duration for statistics
2408
+ */
2409
+ private recordDuration;
2410
+ /**
2411
+ * Start interval-based rate limiting
2412
+ */
2413
+ private startInterval;
2414
+ /**
2415
+ * Emit an event
2416
+ */
2417
+ protected emit<E extends keyof QueueEvents>(event: E, data: QueueEvents[E]): void;
2418
+ /**
2419
+ * Check if queue became empty
2420
+ */
2421
+ private checkEmpty;
2422
+ /**
2423
+ * Check if queue became idle
2424
+ */
2425
+ private checkIdle;
2426
+ }
1986
2427
  type ProxyProtocol$1 = "http" | "https" | "socks4" | "socks5";
1987
2428
  /**
1988
2429
  * Configuration options for proxy connections
@@ -2104,7 +2545,7 @@ export interface RezoRequestConfig<D = any> {
2104
2545
  /**
2105
2546
  * Queue to use for request execution
2106
2547
  */
2107
- queue?: PQueue | null;
2548
+ queue?: RezoQueue | null;
2108
2549
  /**
2109
2550
  * Controls how the response body is parsed and returned in `response.data`.
2110
2551
  *
@@ -2194,10 +2635,6 @@ export interface RezoRequestConfig<D = any> {
2194
2635
  autoSetOrigin?: boolean;
2195
2636
  treat302As303?: boolean;
2196
2637
  startNewRequest?: boolean;
2197
- /** Whether to use HTTP/2 protocol */
2198
- http2?: boolean;
2199
- /** Whether to use cURL adapter */
2200
- curl?: boolean;
2201
2638
  /**
2202
2639
  * DNS cache configuration for faster repeated requests.
2203
2640
  *
@@ -2301,6 +2738,12 @@ export interface RezoRequestConfig<D = any> {
2301
2738
  withCredentials?: boolean;
2302
2739
  /** Proxy configuration (URL string or detailed options) */
2303
2740
  proxy?: string | ProxyOptions;
2741
+ /**
2742
+ * Whether to use ProxyManager for this request
2743
+ * Set to false to bypass ProxyManager even when one is configured
2744
+ * @default true (uses ProxyManager if configured)
2745
+ */
2746
+ useProxyManager?: boolean;
2304
2747
  /** Whether to enable automatic cookie handling */
2305
2748
  useCookies?: boolean;
2306
2749
  /** Custom cookie jar for managing cookies */
@@ -2322,8 +2765,6 @@ export interface RezoRequestConfig<D = any> {
2322
2765
  transformRequest?: Array<(data: any, headers: RezoHeaders) => any>;
2323
2766
  /** Array of functions to transform response data */
2324
2767
  transformResponse?: Array<(data: any) => any>;
2325
- /** Adapter to use for the request (name or custom function) */
2326
- adapter?: string | ((config: RezoRequestConfig) => Promise<any>);
2327
2768
  /** AbortSignal to cancel the request */
2328
2769
  signal?: AbortSignal;
2329
2770
  /** File path to save the response to (for downloads) */
@@ -2540,6 +2981,7 @@ type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean
2540
2981
  type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
2541
2982
  type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
2542
2983
  type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
2984
+ type OnNoProxiesAvailableHook$1 = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
2543
2985
  /**
2544
2986
  * Proxy hooks collection for ProxyManager events
2545
2987
  */
@@ -2552,6 +2994,8 @@ export interface ProxyHooks {
2552
2994
  afterProxyDisable: AfterProxyDisableHook$1[];
2553
2995
  afterProxyRotate: AfterProxyRotateHook$1[];
2554
2996
  afterProxyEnable: AfterProxyEnableHook$1[];
2997
+ /** Hook triggered when no proxies are available */
2998
+ onNoProxiesAvailable: OnNoProxiesAvailableHook$1[];
2555
2999
  }
2556
3000
  /**
2557
3001
  * ProxyManager - Advanced proxy rotation and pool management
@@ -2706,8 +3150,40 @@ export declare class ProxyManager {
2706
3150
  private runAfterProxyRotateHooks;
2707
3151
  private runAfterProxyDisableHooks;
2708
3152
  private runAfterProxyEnableHooks;
3153
+ /**
3154
+ * Run onNoProxiesAvailable hooks synchronously
3155
+ * Called when no proxies are available and an error is about to be thrown
3156
+ */
3157
+ private runOnNoProxiesAvailableHooksSync;
3158
+ /**
3159
+ * Run onNoProxiesAvailable hooks asynchronously
3160
+ * Called when no proxies are available and an error is about to be thrown
3161
+ */
3162
+ runOnNoProxiesAvailableHooks(context: OnNoProxiesAvailableContext): Promise<void>;
3163
+ /**
3164
+ * Notify that no proxies are available and trigger hooks
3165
+ * This method is called when proxy selection fails due to pool exhaustion
3166
+ *
3167
+ * @param url - The request URL that needed a proxy
3168
+ * @param error - The error that will be thrown
3169
+ * @returns The context object with detailed information about the proxy pool state
3170
+ *
3171
+ * @example
3172
+ * ```typescript
3173
+ * manager.hooks.onNoProxiesAvailable.push((context) => {
3174
+ * console.error(`No proxies available for ${context.url}`);
3175
+ * console.log(`Dead: ${context.disabledReasons.dead}, Limit: ${context.disabledReasons.limitReached}`);
3176
+ * // Trigger external alert or proxy refresh
3177
+ * alertSystem.notify('Proxy pool exhausted', context);
3178
+ * });
3179
+ *
3180
+ * // Called internally or by adapters when no proxies are available
3181
+ * const context = manager.notifyNoProxiesAvailable('https://api.example.com', new Error('No proxies'));
3182
+ * ```
3183
+ */
3184
+ notifyNoProxiesAvailable(url: string, error: Error): OnNoProxiesAvailableContext;
2709
3185
  }
2710
- export type queueOptions = Options$1<PriorityQueue, QueueAddOptions>;
3186
+ export type queueOptions = QueueConfig;
2711
3187
  export interface CacheConfig {
2712
3188
  /** Response cache configuration */
2713
3189
  response?: boolean | ResponseCacheConfig;
@@ -2766,10 +3242,6 @@ export interface RezoDefaultOptions {
2766
3242
  keepAlive?: boolean;
2767
3243
  /** Whether to detect and prevent redirect cycles */
2768
3244
  enableRedirectCycleDetection?: boolean;
2769
- /** Whether to use HTTP/2 protocol */
2770
- http2?: boolean;
2771
- /** Whether to use cURL adapter */
2772
- curl?: boolean;
2773
3245
  /** Whether to send cookies and authorization headers with cross-origin requests */
2774
3246
  withCredentials?: boolean;
2775
3247
  /** Proxy configuration (URL string or detailed options) */
@@ -2808,8 +3280,6 @@ export interface RezoDefaultOptions {
2808
3280
  transformRequest?: RezoHttpRequest["transformRequest"];
2809
3281
  /** Array of functions to transform response data */
2810
3282
  transformResponse?: RezoHttpRequest["transformResponse"];
2811
- /** Adapter to use for the request (name or custom function) */
2812
- adapter?: RezoHttpRequest["adapter"];
2813
3283
  /** Browser simulation configuration for user agent spoofing */
2814
3284
  browser?: RezoHttpRequest["browser"];
2815
3285
  /** Enable debug logging for the request */
@@ -3712,7 +4182,7 @@ export type AdapterFunction<T = any> = (options: RezoRequestConfig, defaultOptio
3712
4182
  * Main Rezo class - Enterprise-grade HTTP client with advanced features
3713
4183
  */
3714
4184
  export declare class Rezo {
3715
- protected queue: PQueue | null;
4185
+ protected queue: RezoQueue | null;
3716
4186
  protected isQueueEnabled: boolean;
3717
4187
  defaults: RezoDefaultOptions;
3718
4188
  hooks: RezoHooks;
@@ -3868,6 +4338,147 @@ export declare function createRezoInstance(adapter: AdapterFunction, config?: Re
3868
4338
  * Will throw if no global adapter has been set.
3869
4339
  */
3870
4340
  export declare function createDefaultInstance(config?: RezoDefaultOptions): RezoInstance;
4341
+ /**
4342
+ * HttpQueue - An HTTP-aware task queue with advanced features
4343
+ *
4344
+ * Features:
4345
+ * - Per-domain concurrency limiting
4346
+ * - Automatic rate limit header parsing (Retry-After, X-RateLimit-*)
4347
+ * - Automatic retry with exponential backoff
4348
+ * - HTTP method-based priority
4349
+ * - Domain pause/resume
4350
+ * - Rate limit event handling
4351
+ *
4352
+ * @example
4353
+ * ```typescript
4354
+ * const queue = new HttpQueue({
4355
+ * concurrency: 10,
4356
+ * domainConcurrency: 2,
4357
+ * respectRetryAfter: true,
4358
+ * autoRetry: true,
4359
+ * maxRetries: 3
4360
+ * });
4361
+ *
4362
+ * await queue.add(() => fetch('https://api.example.com/data'), {
4363
+ * domain: 'api.example.com'
4364
+ * });
4365
+ * ```
4366
+ */
4367
+ export declare class HttpQueue extends RezoQueue<any> {
4368
+ private domainQueues;
4369
+ private domainPending;
4370
+ private domainPaused;
4371
+ private domainRateLimited;
4372
+ private domainConcurrencyLimits;
4373
+ private httpStatsData;
4374
+ private httpEventHandlers;
4375
+ readonly httpConfig: Required<HttpQueueConfig>;
4376
+ /**
4377
+ * Create a new HttpQueue
4378
+ * @param config - HTTP queue configuration
4379
+ */
4380
+ constructor(config?: HttpQueueConfig);
4381
+ /**
4382
+ * Resume queue processing (overrides base to also process HTTP tasks)
4383
+ */
4384
+ start(): void;
4385
+ /**
4386
+ * Get HTTP-specific statistics
4387
+ */
4388
+ get httpStats(): HttpQueueStats;
4389
+ /**
4390
+ * Add an HTTP task to the queue
4391
+ * @param fn - Async function to execute
4392
+ * @param options - HTTP task options
4393
+ * @returns Promise resolving to task result
4394
+ */
4395
+ addHttp<R = any>(fn: TaskFunction<R>, options?: HttpTaskOptions): Promise<R>;
4396
+ /**
4397
+ * Pause requests to specific domain
4398
+ * @param domain - Domain to pause
4399
+ */
4400
+ pauseDomain(domain: string): void;
4401
+ /**
4402
+ * Resume requests to specific domain
4403
+ * @param domain - Domain to resume
4404
+ */
4405
+ resumeDomain(domain: string): void;
4406
+ /**
4407
+ * Set per-domain concurrency limit
4408
+ * @param domain - Domain to configure
4409
+ * @param limit - Concurrency limit
4410
+ */
4411
+ setDomainConcurrency(domain: string, limit: number): void;
4412
+ /**
4413
+ * Get domain-specific state
4414
+ * @param domain - Domain to query
4415
+ */
4416
+ getDomainState(domain: string): DomainState;
4417
+ /**
4418
+ * Handle rate limit response
4419
+ * @param domain - Domain that was rate limited
4420
+ * @param retryAfter - Seconds until retry is allowed
4421
+ */
4422
+ handleRateLimit(domain: string, retryAfter: number): void;
4423
+ /**
4424
+ * Cancel an HTTP task by ID
4425
+ * @param id - Task ID to cancel
4426
+ * @returns true if task was found and cancelled
4427
+ */
4428
+ cancelHttp(id: string): boolean;
4429
+ /**
4430
+ * Register an HTTP event handler
4431
+ * @param event - Event name
4432
+ * @param handler - Handler function
4433
+ */
4434
+ onHttp<E extends keyof HttpQueueEvents>(event: E, handler: EventHandler<HttpQueueEvents[E]>): void;
4435
+ /**
4436
+ * Remove an HTTP event handler
4437
+ * @param event - Event name
4438
+ * @param handler - Handler function to remove
4439
+ */
4440
+ offHttp<E extends keyof HttpQueueEvents>(event: E, handler: EventHandler<HttpQueueEvents[E]>): void;
4441
+ /**
4442
+ * Clear all HTTP tasks
4443
+ */
4444
+ clearHttp(): void;
4445
+ /**
4446
+ * Destroy the queue and cleanup resources
4447
+ */
4448
+ destroy(): void;
4449
+ /**
4450
+ * Insert HTTP task maintaining priority order
4451
+ */
4452
+ private insertHttpTask;
4453
+ /**
4454
+ * Get domain concurrency limit
4455
+ */
4456
+ private getDomainLimit;
4457
+ /**
4458
+ * Check if domain can accept more tasks
4459
+ */
4460
+ private canRunDomain;
4461
+ /**
4462
+ * Try to run next HTTP task
4463
+ */
4464
+ private tryRunHttpNext;
4465
+ /**
4466
+ * Execute an HTTP task
4467
+ */
4468
+ private runHttpTask;
4469
+ /**
4470
+ * Calculate retry delay for task
4471
+ */
4472
+ private getRetryDelay;
4473
+ /**
4474
+ * Ensure domain stats exist
4475
+ */
4476
+ private ensureDomainStats;
4477
+ /**
4478
+ * Emit an HTTP event
4479
+ */
4480
+ private emitHttp;
4481
+ }
3871
4482
  export declare const isRezoError: typeof RezoError.isRezoError;
3872
4483
  export declare const Cancel: typeof RezoError;
3873
4484
  export declare const CancelToken: {