rezo 1.0.4 → 1.0.6

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 (47) 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 +2332 -20
  5. package/dist/adapters/entries/fetch.d.ts +289 -20
  6. package/dist/adapters/entries/http.d.ts +289 -20
  7. package/dist/adapters/entries/http2.d.ts +289 -20
  8. package/dist/adapters/entries/react-native.d.ts +289 -20
  9. package/dist/adapters/entries/xhr.d.ts +289 -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/rezo.cjs +2 -2
  15. package/dist/core/rezo.js +2 -2
  16. package/dist/crawler.d.ts +291 -22
  17. package/dist/entries/crawler.cjs +5 -5
  18. package/dist/index.cjs +23 -18
  19. package/dist/index.d.ts +556 -20
  20. package/dist/index.js +1 -0
  21. package/dist/platform/browser.d.ts +289 -20
  22. package/dist/platform/bun.d.ts +289 -20
  23. package/dist/platform/deno.d.ts +289 -20
  24. package/dist/platform/node.d.ts +289 -20
  25. package/dist/platform/react-native.d.ts +289 -20
  26. package/dist/platform/worker.d.ts +289 -20
  27. package/dist/plugin/crawler-options.cjs +1 -1
  28. package/dist/plugin/crawler-options.js +1 -1
  29. package/dist/plugin/crawler.cjs +2 -2
  30. package/dist/plugin/crawler.js +2 -2
  31. package/dist/plugin/index.cjs +36 -36
  32. package/dist/proxy/index.cjs +2 -2
  33. package/dist/proxy/manager.cjs +14 -1
  34. package/dist/proxy/manager.js +14 -1
  35. package/dist/queue/http-queue.cjs +313 -0
  36. package/dist/queue/http-queue.js +312 -0
  37. package/dist/queue/index.cjs +8 -0
  38. package/dist/queue/index.js +6 -0
  39. package/dist/queue/queue.cjs +346 -0
  40. package/dist/queue/queue.js +344 -0
  41. package/dist/queue/types.cjs +17 -0
  42. package/dist/queue/types.js +17 -0
  43. package/dist/types/curl-options.cjs +25 -0
  44. package/dist/types/curl-options.js +25 -0
  45. package/dist/utils/http-config.cjs +0 -15
  46. package/dist/utils/http-config.js +0 -15
  47. 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')
@@ -1983,6 +1989,401 @@ export declare class RezoError<T = any> extends Error {
1983
1989
  toString(): string;
1984
1990
  getFullDetails(): string;
1985
1991
  }
1992
+ /**
1993
+ * RezoQueue - High-performance task queue with priority, concurrency, and HTTP-aware features
1994
+ * @module queue/types
1995
+ */
1996
+ /**
1997
+ * Priority levels for queue ordering (higher = runs first)
1998
+ */
1999
+ export declare const Priority: {
2000
+ readonly LOWEST: 0;
2001
+ readonly LOW: 25;
2002
+ readonly NORMAL: 50;
2003
+ readonly HIGH: 75;
2004
+ readonly HIGHEST: 100;
2005
+ readonly CRITICAL: 1000;
2006
+ };
2007
+ /**
2008
+ * HTTP method priority presets
2009
+ */
2010
+ export declare const HttpMethodPriority: Record<string, number>;
2011
+ /**
2012
+ * Queue configuration options
2013
+ */
2014
+ export interface QueueConfig {
2015
+ /** Maximum concurrent tasks (default: Infinity) */
2016
+ concurrency?: number;
2017
+ /** Auto-start processing when tasks are added (default: true) */
2018
+ autoStart?: boolean;
2019
+ /** Timeout per task in milliseconds (default: none) */
2020
+ timeout?: number;
2021
+ /** Throw on timeout vs silently fail (default: true) */
2022
+ throwOnTimeout?: boolean;
2023
+ /** Interval between task starts in ms for rate limiting */
2024
+ interval?: number;
2025
+ /** Max tasks to start per interval (default: Infinity) */
2026
+ intervalCap?: number;
2027
+ /** Carry over unused interval capacity to next interval */
2028
+ carryoverConcurrencyCount?: boolean;
2029
+ }
2030
+ /**
2031
+ * HTTP-specific queue configuration
2032
+ */
2033
+ export interface HttpQueueConfig extends QueueConfig {
2034
+ /** Per-domain concurrency limits */
2035
+ domainConcurrency?: number | Record<string, number>;
2036
+ /** Global requests per second limit */
2037
+ requestsPerSecond?: number;
2038
+ /** Respect Retry-After headers automatically */
2039
+ respectRetryAfter?: boolean;
2040
+ /** Respect X-RateLimit-* headers automatically */
2041
+ respectRateLimitHeaders?: boolean;
2042
+ /** Retry failed tasks automatically */
2043
+ autoRetry?: boolean;
2044
+ /** Max retry attempts for auto-retry */
2045
+ maxRetries?: number;
2046
+ /** Delay between retries (supports backoff function) */
2047
+ retryDelay?: number | ((attempt: number) => number);
2048
+ /** Status codes that trigger retry */
2049
+ retryStatusCodes?: number[];
2050
+ }
2051
+ /**
2052
+ * Task options when adding to queue
2053
+ */
2054
+ export interface TaskOptions {
2055
+ /** Task priority (higher runs first, default: 0) */
2056
+ priority?: number;
2057
+ /** Task-specific timeout (overrides queue default) */
2058
+ timeout?: number;
2059
+ /** Unique ID for tracking/cancellation */
2060
+ id?: string;
2061
+ /** Signal for external cancellation */
2062
+ signal?: AbortSignal;
2063
+ }
2064
+ /**
2065
+ * HTTP-specific task options
2066
+ */
2067
+ export interface HttpTaskOptions extends TaskOptions {
2068
+ /** Domain for per-domain limiting (auto-extracted if not provided) */
2069
+ domain?: string;
2070
+ /** HTTP method for method-based priority */
2071
+ method?: string;
2072
+ /** Retry this specific task on failure */
2073
+ retry?: boolean | number;
2074
+ /** Custom retry delay for this task */
2075
+ retryDelay?: number;
2076
+ }
2077
+ /**
2078
+ * Current queue state
2079
+ */
2080
+ export interface QueueState {
2081
+ /** Number of tasks currently running */
2082
+ pending: number;
2083
+ /** Number of tasks waiting in queue */
2084
+ size: number;
2085
+ /** Total tasks (pending + size) */
2086
+ total: number;
2087
+ /** Is queue paused */
2088
+ isPaused: boolean;
2089
+ /** Is queue idle (no tasks) */
2090
+ isIdle: boolean;
2091
+ }
2092
+ /**
2093
+ * Queue statistics
2094
+ */
2095
+ export interface QueueStats {
2096
+ /** Total tasks added since creation */
2097
+ added: number;
2098
+ /** Total tasks processed (started) */
2099
+ processed: number;
2100
+ /** Total successful completions */
2101
+ completed: number;
2102
+ /** Total failures */
2103
+ failed: number;
2104
+ /** Total timeouts */
2105
+ timedOut: number;
2106
+ /** Total cancellations */
2107
+ cancelled: number;
2108
+ /** Average task duration (ms) */
2109
+ averageDuration: number;
2110
+ /** Tasks per second (rolling average) */
2111
+ throughput: number;
2112
+ }
2113
+ /**
2114
+ * HTTP-specific statistics
2115
+ */
2116
+ export interface HttpQueueStats extends QueueStats {
2117
+ /** Stats per domain */
2118
+ byDomain: Record<string, {
2119
+ pending: number;
2120
+ completed: number;
2121
+ failed: number;
2122
+ rateLimited: number;
2123
+ }>;
2124
+ /** Total retries performed */
2125
+ retries: number;
2126
+ /** Rate limit events */
2127
+ rateLimitHits: number;
2128
+ }
2129
+ /**
2130
+ * Domain-specific state
2131
+ */
2132
+ export interface DomainState {
2133
+ /** Number of tasks currently running for domain */
2134
+ pending: number;
2135
+ /** Number of tasks waiting for domain */
2136
+ size: number;
2137
+ /** Is domain paused */
2138
+ isPaused: boolean;
2139
+ /** Rate limit until timestamp (if rate limited) */
2140
+ rateLimitedUntil?: number;
2141
+ }
2142
+ /**
2143
+ * Queue event types
2144
+ */
2145
+ export interface QueueEvents {
2146
+ /** Task added to queue */
2147
+ add: {
2148
+ id: string;
2149
+ priority: number;
2150
+ };
2151
+ /** Task started executing */
2152
+ start: {
2153
+ id: string;
2154
+ };
2155
+ /** Task completed successfully */
2156
+ completed: {
2157
+ id: string;
2158
+ result: any;
2159
+ duration: number;
2160
+ };
2161
+ /** Task failed with error */
2162
+ error: {
2163
+ id: string;
2164
+ error: Error;
2165
+ };
2166
+ /** Task timed out */
2167
+ timeout: {
2168
+ id: string;
2169
+ };
2170
+ /** Task cancelled */
2171
+ cancelled: {
2172
+ id: string;
2173
+ };
2174
+ /** Queue became active (was idle, now processing) */
2175
+ active: undefined;
2176
+ /** Queue became idle (all tasks done) */
2177
+ idle: undefined;
2178
+ /** Queue was paused */
2179
+ paused: undefined;
2180
+ /** Queue was resumed */
2181
+ resumed: undefined;
2182
+ /** Next task about to run */
2183
+ next: undefined;
2184
+ /** Queue was emptied (no pending tasks) */
2185
+ empty: undefined;
2186
+ }
2187
+ /**
2188
+ * HTTP-specific events
2189
+ */
2190
+ export interface HttpQueueEvents extends QueueEvents {
2191
+ /** Rate limit hit for a domain */
2192
+ rateLimited: {
2193
+ domain: string;
2194
+ retryAfter: number;
2195
+ };
2196
+ /** Domain queue became available */
2197
+ domainAvailable: {
2198
+ domain: string;
2199
+ };
2200
+ /** Task being retried */
2201
+ retry: {
2202
+ id: string;
2203
+ attempt: number;
2204
+ error: Error;
2205
+ };
2206
+ }
2207
+ /**
2208
+ * Event handler type
2209
+ */
2210
+ export type EventHandler<T> = (data: T) => void;
2211
+ /**
2212
+ * Task function type
2213
+ */
2214
+ export type TaskFunction<T> = () => Promise<T>;
2215
+ /**
2216
+ * RezoQueue - A high-performance task queue with priority and concurrency control
2217
+ *
2218
+ * Features:
2219
+ * - Priority-based task ordering (higher priority runs first)
2220
+ * - Configurable concurrency limits
2221
+ * - Task timeout support
2222
+ * - Pause/resume functionality
2223
+ * - Interval-based rate limiting
2224
+ * - Task cancellation by ID
2225
+ * - Comprehensive event system
2226
+ * - Detailed statistics tracking
2227
+ *
2228
+ * @example
2229
+ * ```typescript
2230
+ * const queue = new RezoQueue({ concurrency: 5 });
2231
+ *
2232
+ * // Add tasks with priority
2233
+ * const result = await queue.add(() => fetchData(), { priority: 100 });
2234
+ *
2235
+ * // Wait for all tasks to complete
2236
+ * await queue.onIdle();
2237
+ * ```
2238
+ */
2239
+ export declare class RezoQueue<T = any> {
2240
+ private queue;
2241
+ private pendingCount;
2242
+ private isPausedFlag;
2243
+ private intervalId?;
2244
+ private intervalCount;
2245
+ private intervalStart;
2246
+ private eventHandlers;
2247
+ private statsData;
2248
+ private totalDuration;
2249
+ private throughputWindow;
2250
+ private readonly throughputWindowSize;
2251
+ private idlePromise?;
2252
+ private emptyPromise?;
2253
+ readonly config: Required<QueueConfig>;
2254
+ /**
2255
+ * Create a new RezoQueue
2256
+ * @param config - Queue configuration options
2257
+ */
2258
+ constructor(config?: QueueConfig);
2259
+ /**
2260
+ * Get current queue state
2261
+ */
2262
+ get state(): QueueState;
2263
+ /**
2264
+ * Get queue statistics
2265
+ */
2266
+ get stats(): QueueStats;
2267
+ /**
2268
+ * Get/set concurrency limit
2269
+ */
2270
+ get concurrency(): number;
2271
+ set concurrency(value: number);
2272
+ /**
2273
+ * Number of pending (running) tasks
2274
+ */
2275
+ get pending(): number;
2276
+ /**
2277
+ * Number of tasks waiting in queue
2278
+ */
2279
+ get size(): number;
2280
+ /**
2281
+ * Check if queue is paused
2282
+ */
2283
+ get isPaused(): boolean;
2284
+ /**
2285
+ * Add a task to the queue
2286
+ * @param fn - Async function to execute
2287
+ * @param options - Task options
2288
+ * @returns Promise resolving to task result
2289
+ */
2290
+ add<R = T>(fn: TaskFunction<R>, options?: TaskOptions): Promise<R>;
2291
+ /**
2292
+ * Add multiple tasks to the queue
2293
+ * @param fns - Array of async functions
2294
+ * @param options - Task options (applied to all)
2295
+ * @returns Promise resolving to array of results
2296
+ */
2297
+ addAll<R = T>(fns: TaskFunction<R>[], options?: TaskOptions): Promise<R[]>;
2298
+ /**
2299
+ * Pause queue processing (running tasks continue)
2300
+ */
2301
+ pause(): void;
2302
+ /**
2303
+ * Resume queue processing
2304
+ */
2305
+ start(): void;
2306
+ /**
2307
+ * Clear all pending tasks from queue
2308
+ */
2309
+ clear(): void;
2310
+ /**
2311
+ * Cancel a specific task by ID
2312
+ * @param id - Task ID to cancel
2313
+ * @returns true if task was found and cancelled
2314
+ */
2315
+ cancel(id: string): boolean;
2316
+ /**
2317
+ * Cancel all tasks matching a predicate
2318
+ * @param predicate - Function to test each task
2319
+ * @returns Number of tasks cancelled
2320
+ */
2321
+ cancelBy(predicate: (task: {
2322
+ id: string;
2323
+ priority: number;
2324
+ }) => boolean): number;
2325
+ /**
2326
+ * Wait for queue to become idle (no running or pending tasks)
2327
+ */
2328
+ onIdle(): Promise<void>;
2329
+ /**
2330
+ * Wait for queue to be empty (no pending tasks, but may have running)
2331
+ */
2332
+ onEmpty(): Promise<void>;
2333
+ /**
2334
+ * Wait for queue size to be less than limit
2335
+ * @param limit - Size threshold
2336
+ */
2337
+ onSizeLessThan(limit: number): Promise<void>;
2338
+ /**
2339
+ * Register an event handler
2340
+ * @param event - Event name
2341
+ * @param handler - Handler function
2342
+ */
2343
+ on<E extends keyof QueueEvents>(event: E, handler: EventHandler<QueueEvents[E]>): void;
2344
+ /**
2345
+ * Remove an event handler
2346
+ * @param event - Event name
2347
+ * @param handler - Handler function to remove
2348
+ */
2349
+ off<E extends keyof QueueEvents>(event: E, handler: EventHandler<QueueEvents[E]>): void;
2350
+ /**
2351
+ * Destroy the queue and cleanup resources
2352
+ */
2353
+ destroy(): void;
2354
+ /**
2355
+ * Insert task into queue maintaining priority order (highest first)
2356
+ */
2357
+ private insertByPriority;
2358
+ /**
2359
+ * Try to run next task if capacity available
2360
+ */
2361
+ private tryRunNext;
2362
+ /**
2363
+ * Execute a task
2364
+ */
2365
+ private runTask;
2366
+ /**
2367
+ * Record task duration for statistics
2368
+ */
2369
+ private recordDuration;
2370
+ /**
2371
+ * Start interval-based rate limiting
2372
+ */
2373
+ private startInterval;
2374
+ /**
2375
+ * Emit an event
2376
+ */
2377
+ protected emit<E extends keyof QueueEvents>(event: E, data: QueueEvents[E]): void;
2378
+ /**
2379
+ * Check if queue became empty
2380
+ */
2381
+ private checkEmpty;
2382
+ /**
2383
+ * Check if queue became idle
2384
+ */
2385
+ private checkIdle;
2386
+ }
1986
2387
  type ProxyProtocol$1 = "http" | "https" | "socks4" | "socks5";
1987
2388
  /**
1988
2389
  * Configuration options for proxy connections
@@ -2104,7 +2505,7 @@ export interface RezoRequestConfig<D = any> {
2104
2505
  /**
2105
2506
  * Queue to use for request execution
2106
2507
  */
2107
- queue?: PQueue | null;
2508
+ queue?: RezoQueue | null;
2108
2509
  /**
2109
2510
  * Controls how the response body is parsed and returned in `response.data`.
2110
2511
  *
@@ -2194,10 +2595,6 @@ export interface RezoRequestConfig<D = any> {
2194
2595
  autoSetOrigin?: boolean;
2195
2596
  treat302As303?: boolean;
2196
2597
  startNewRequest?: boolean;
2197
- /** Whether to use HTTP/2 protocol */
2198
- http2?: boolean;
2199
- /** Whether to use cURL adapter */
2200
- curl?: boolean;
2201
2598
  /**
2202
2599
  * DNS cache configuration for faster repeated requests.
2203
2600
  *
@@ -2301,6 +2698,12 @@ export interface RezoRequestConfig<D = any> {
2301
2698
  withCredentials?: boolean;
2302
2699
  /** Proxy configuration (URL string or detailed options) */
2303
2700
  proxy?: string | ProxyOptions;
2701
+ /**
2702
+ * Whether to use ProxyManager for this request
2703
+ * Set to false to bypass ProxyManager even when one is configured
2704
+ * @default true (uses ProxyManager if configured)
2705
+ */
2706
+ useProxyManager?: boolean;
2304
2707
  /** Whether to enable automatic cookie handling */
2305
2708
  useCookies?: boolean;
2306
2709
  /** Custom cookie jar for managing cookies */
@@ -2322,8 +2725,6 @@ export interface RezoRequestConfig<D = any> {
2322
2725
  transformRequest?: Array<(data: any, headers: RezoHeaders) => any>;
2323
2726
  /** Array of functions to transform response data */
2324
2727
  transformResponse?: Array<(data: any) => any>;
2325
- /** Adapter to use for the request (name or custom function) */
2326
- adapter?: string | ((config: RezoRequestConfig) => Promise<any>);
2327
2728
  /** AbortSignal to cancel the request */
2328
2729
  signal?: AbortSignal;
2329
2730
  /** File path to save the response to (for downloads) */
@@ -2707,7 +3108,7 @@ export declare class ProxyManager {
2707
3108
  private runAfterProxyDisableHooks;
2708
3109
  private runAfterProxyEnableHooks;
2709
3110
  }
2710
- export type queueOptions = Options$1<PriorityQueue, QueueAddOptions>;
3111
+ export type queueOptions = QueueConfig;
2711
3112
  export interface CacheConfig {
2712
3113
  /** Response cache configuration */
2713
3114
  response?: boolean | ResponseCacheConfig;
@@ -2766,10 +3167,6 @@ export interface RezoDefaultOptions {
2766
3167
  keepAlive?: boolean;
2767
3168
  /** Whether to detect and prevent redirect cycles */
2768
3169
  enableRedirectCycleDetection?: boolean;
2769
- /** Whether to use HTTP/2 protocol */
2770
- http2?: boolean;
2771
- /** Whether to use cURL adapter */
2772
- curl?: boolean;
2773
3170
  /** Whether to send cookies and authorization headers with cross-origin requests */
2774
3171
  withCredentials?: boolean;
2775
3172
  /** Proxy configuration (URL string or detailed options) */
@@ -2808,8 +3205,6 @@ export interface RezoDefaultOptions {
2808
3205
  transformRequest?: RezoHttpRequest["transformRequest"];
2809
3206
  /** Array of functions to transform response data */
2810
3207
  transformResponse?: RezoHttpRequest["transformResponse"];
2811
- /** Adapter to use for the request (name or custom function) */
2812
- adapter?: RezoHttpRequest["adapter"];
2813
3208
  /** Browser simulation configuration for user agent spoofing */
2814
3209
  browser?: RezoHttpRequest["browser"];
2815
3210
  /** Enable debug logging for the request */
@@ -3712,7 +4107,7 @@ export type AdapterFunction<T = any> = (options: RezoRequestConfig, defaultOptio
3712
4107
  * Main Rezo class - Enterprise-grade HTTP client with advanced features
3713
4108
  */
3714
4109
  export declare class Rezo {
3715
- protected queue: PQueue | null;
4110
+ protected queue: RezoQueue | null;
3716
4111
  protected isQueueEnabled: boolean;
3717
4112
  defaults: RezoDefaultOptions;
3718
4113
  hooks: RezoHooks;
@@ -3868,6 +4263,147 @@ export declare function createRezoInstance(adapter: AdapterFunction, config?: Re
3868
4263
  * Will throw if no global adapter has been set.
3869
4264
  */
3870
4265
  export declare function createDefaultInstance(config?: RezoDefaultOptions): RezoInstance;
4266
+ /**
4267
+ * HttpQueue - An HTTP-aware task queue with advanced features
4268
+ *
4269
+ * Features:
4270
+ * - Per-domain concurrency limiting
4271
+ * - Automatic rate limit header parsing (Retry-After, X-RateLimit-*)
4272
+ * - Automatic retry with exponential backoff
4273
+ * - HTTP method-based priority
4274
+ * - Domain pause/resume
4275
+ * - Rate limit event handling
4276
+ *
4277
+ * @example
4278
+ * ```typescript
4279
+ * const queue = new HttpQueue({
4280
+ * concurrency: 10,
4281
+ * domainConcurrency: 2,
4282
+ * respectRetryAfter: true,
4283
+ * autoRetry: true,
4284
+ * maxRetries: 3
4285
+ * });
4286
+ *
4287
+ * await queue.add(() => fetch('https://api.example.com/data'), {
4288
+ * domain: 'api.example.com'
4289
+ * });
4290
+ * ```
4291
+ */
4292
+ export declare class HttpQueue extends RezoQueue<any> {
4293
+ private domainQueues;
4294
+ private domainPending;
4295
+ private domainPaused;
4296
+ private domainRateLimited;
4297
+ private domainConcurrencyLimits;
4298
+ private httpStatsData;
4299
+ private httpEventHandlers;
4300
+ readonly httpConfig: Required<HttpQueueConfig>;
4301
+ /**
4302
+ * Create a new HttpQueue
4303
+ * @param config - HTTP queue configuration
4304
+ */
4305
+ constructor(config?: HttpQueueConfig);
4306
+ /**
4307
+ * Resume queue processing (overrides base to also process HTTP tasks)
4308
+ */
4309
+ start(): void;
4310
+ /**
4311
+ * Get HTTP-specific statistics
4312
+ */
4313
+ get httpStats(): HttpQueueStats;
4314
+ /**
4315
+ * Add an HTTP task to the queue
4316
+ * @param fn - Async function to execute
4317
+ * @param options - HTTP task options
4318
+ * @returns Promise resolving to task result
4319
+ */
4320
+ addHttp<R = any>(fn: TaskFunction<R>, options?: HttpTaskOptions): Promise<R>;
4321
+ /**
4322
+ * Pause requests to specific domain
4323
+ * @param domain - Domain to pause
4324
+ */
4325
+ pauseDomain(domain: string): void;
4326
+ /**
4327
+ * Resume requests to specific domain
4328
+ * @param domain - Domain to resume
4329
+ */
4330
+ resumeDomain(domain: string): void;
4331
+ /**
4332
+ * Set per-domain concurrency limit
4333
+ * @param domain - Domain to configure
4334
+ * @param limit - Concurrency limit
4335
+ */
4336
+ setDomainConcurrency(domain: string, limit: number): void;
4337
+ /**
4338
+ * Get domain-specific state
4339
+ * @param domain - Domain to query
4340
+ */
4341
+ getDomainState(domain: string): DomainState;
4342
+ /**
4343
+ * Handle rate limit response
4344
+ * @param domain - Domain that was rate limited
4345
+ * @param retryAfter - Seconds until retry is allowed
4346
+ */
4347
+ handleRateLimit(domain: string, retryAfter: number): void;
4348
+ /**
4349
+ * Cancel an HTTP task by ID
4350
+ * @param id - Task ID to cancel
4351
+ * @returns true if task was found and cancelled
4352
+ */
4353
+ cancelHttp(id: string): boolean;
4354
+ /**
4355
+ * Register an HTTP event handler
4356
+ * @param event - Event name
4357
+ * @param handler - Handler function
4358
+ */
4359
+ onHttp<E extends keyof HttpQueueEvents>(event: E, handler: EventHandler<HttpQueueEvents[E]>): void;
4360
+ /**
4361
+ * Remove an HTTP event handler
4362
+ * @param event - Event name
4363
+ * @param handler - Handler function to remove
4364
+ */
4365
+ offHttp<E extends keyof HttpQueueEvents>(event: E, handler: EventHandler<HttpQueueEvents[E]>): void;
4366
+ /**
4367
+ * Clear all HTTP tasks
4368
+ */
4369
+ clearHttp(): void;
4370
+ /**
4371
+ * Destroy the queue and cleanup resources
4372
+ */
4373
+ destroy(): void;
4374
+ /**
4375
+ * Insert HTTP task maintaining priority order
4376
+ */
4377
+ private insertHttpTask;
4378
+ /**
4379
+ * Get domain concurrency limit
4380
+ */
4381
+ private getDomainLimit;
4382
+ /**
4383
+ * Check if domain can accept more tasks
4384
+ */
4385
+ private canRunDomain;
4386
+ /**
4387
+ * Try to run next HTTP task
4388
+ */
4389
+ private tryRunHttpNext;
4390
+ /**
4391
+ * Execute an HTTP task
4392
+ */
4393
+ private runHttpTask;
4394
+ /**
4395
+ * Calculate retry delay for task
4396
+ */
4397
+ private getRetryDelay;
4398
+ /**
4399
+ * Ensure domain stats exist
4400
+ */
4401
+ private ensureDomainStats;
4402
+ /**
4403
+ * Emit an HTTP event
4404
+ */
4405
+ private emitHttp;
4406
+ }
3871
4407
  export declare const isRezoError: typeof RezoError.isRezoError;
3872
4408
  export declare const Cancel: typeof RezoError;
3873
4409
  export declare const CancelToken: {
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ export { RezoFormData } from './utils/form-data.js';
9
9
  export { RezoCookieJar } from './utils/cookies.js';
10
10
  export { createDefaultHooks, mergeHooks } from './core/hooks.js';
11
11
  export { ProxyManager } from './proxy/manager.js';
12
+ export { RezoQueue, HttpQueue, Priority, HttpMethodPriority } from './queue/index.js';
12
13
  import { RezoError } from './errors/rezo-error.js';
13
14
  export const isRezoError = RezoError.isRezoError;
14
15
  export const Cancel = RezoError;