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.
- package/README.md +352 -9
- package/dist/adapters/curl.cjs +796 -0
- package/dist/adapters/curl.js +796 -0
- package/dist/adapters/entries/curl.d.ts +2407 -20
- package/dist/adapters/entries/fetch.d.ts +364 -20
- package/dist/adapters/entries/http.d.ts +364 -20
- package/dist/adapters/entries/http2.d.ts +364 -20
- package/dist/adapters/entries/react-native.d.ts +364 -20
- package/dist/adapters/entries/xhr.d.ts +364 -20
- package/dist/adapters/index.cjs +6 -6
- package/dist/adapters/picker.cjs +2 -2
- package/dist/adapters/picker.js +2 -2
- package/dist/cache/index.cjs +13 -13
- package/dist/core/hooks.cjs +2 -0
- package/dist/core/hooks.js +2 -0
- package/dist/core/rezo.cjs +2 -2
- package/dist/core/rezo.js +2 -2
- package/dist/crawler.d.ts +366 -22
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +23 -18
- package/dist/index.d.ts +631 -20
- package/dist/index.js +1 -0
- package/dist/platform/browser.d.ts +364 -20
- package/dist/platform/bun.d.ts +364 -20
- package/dist/platform/deno.d.ts +364 -20
- package/dist/platform/node.d.ts +364 -20
- package/dist/platform/react-native.d.ts +364 -20
- package/dist/platform/worker.d.ts +364 -20
- package/dist/plugin/crawler-options.cjs +1 -1
- package/dist/plugin/crawler-options.js +1 -1
- package/dist/plugin/crawler.cjs +2 -2
- package/dist/plugin/crawler.js +2 -2
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/proxy/manager.cjs +57 -2
- package/dist/proxy/manager.js +57 -2
- package/dist/queue/http-queue.cjs +313 -0
- package/dist/queue/http-queue.js +312 -0
- package/dist/queue/index.cjs +8 -0
- package/dist/queue/index.js +6 -0
- package/dist/queue/queue.cjs +346 -0
- package/dist/queue/queue.js +344 -0
- package/dist/queue/types.cjs +17 -0
- package/dist/queue/types.js +17 -0
- package/dist/types/curl-options.cjs +25 -0
- package/dist/types/curl-options.js +25 -0
- package/dist/utils/http-config.cjs +0 -15
- package/dist/utils/http-config.js +0 -15
- package/package.json +1 -2
package/dist/crawler.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
|
/**
|
|
@@ -1195,8 +1192,17 @@ export interface ProxyCooldownConfig {
|
|
|
1195
1192
|
* Complete configuration for proxy rotation, filtering, and failure handling
|
|
1196
1193
|
*/
|
|
1197
1194
|
export interface ProxyManagerBaseConfig {
|
|
1198
|
-
/**
|
|
1199
|
-
|
|
1195
|
+
/**
|
|
1196
|
+
* Array of proxies to manage
|
|
1197
|
+
* Accepts ProxyInfo objects or proxy URL strings (parsed via parseProxyString)
|
|
1198
|
+
* @example
|
|
1199
|
+
* proxies: [
|
|
1200
|
+
* { protocol: 'http', host: '127.0.0.1', port: 8080 },
|
|
1201
|
+
* 'socks5://user:pass@proxy.example.com:1080',
|
|
1202
|
+
* 'http://proxy.example.com:3128'
|
|
1203
|
+
* ]
|
|
1204
|
+
*/
|
|
1205
|
+
proxies: (ProxyInfo | string)[];
|
|
1200
1206
|
/**
|
|
1201
1207
|
* Whitelist patterns for URLs that should use proxy
|
|
1202
1208
|
* - String: exact domain match (e.g., 'api.example.com') or subdomain match (e.g., 'example.com' matches '*.example.com')
|
|
@@ -1408,6 +1414,35 @@ export interface AfterProxyEnableContext {
|
|
|
1408
1414
|
/** Reason for enabling */
|
|
1409
1415
|
reason: "cooldown-expired" | "manual";
|
|
1410
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Context for onNoProxiesAvailable hook
|
|
1419
|
+
* Triggered when no proxies are available and an error would be thrown
|
|
1420
|
+
*/
|
|
1421
|
+
export interface OnNoProxiesAvailableContext {
|
|
1422
|
+
/** Request URL that needed a proxy */
|
|
1423
|
+
url: string;
|
|
1424
|
+
/** The error that will be thrown */
|
|
1425
|
+
error: Error;
|
|
1426
|
+
/** All proxies (including disabled ones) */
|
|
1427
|
+
allProxies: ProxyState[];
|
|
1428
|
+
/** Number of active proxies (should be 0) */
|
|
1429
|
+
activeCount: number;
|
|
1430
|
+
/** Number of disabled proxies */
|
|
1431
|
+
disabledCount: number;
|
|
1432
|
+
/** Number of proxies in cooldown */
|
|
1433
|
+
cooldownCount: number;
|
|
1434
|
+
/** Reasons why proxies are unavailable */
|
|
1435
|
+
disabledReasons: {
|
|
1436
|
+
/** Proxies disabled due to failures */
|
|
1437
|
+
dead: number;
|
|
1438
|
+
/** Proxies disabled due to request limit */
|
|
1439
|
+
limitReached: number;
|
|
1440
|
+
/** Proxies manually disabled */
|
|
1441
|
+
manual: number;
|
|
1442
|
+
};
|
|
1443
|
+
/** Timestamp when this event occurred */
|
|
1444
|
+
timestamp: number;
|
|
1445
|
+
}
|
|
1411
1446
|
/**
|
|
1412
1447
|
* Context provided to beforeRequest hook
|
|
1413
1448
|
* Contains metadata about the current request state
|
|
@@ -1726,6 +1761,16 @@ export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void |
|
|
|
1726
1761
|
* Use for notifications, logging
|
|
1727
1762
|
*/
|
|
1728
1763
|
export type AfterProxyEnableHook = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
1764
|
+
/**
|
|
1765
|
+
* Hook called when no proxies are available and an error is about to be thrown
|
|
1766
|
+
* Use for alerting, logging exhausted proxy pools, or triggering proxy refresh
|
|
1767
|
+
* This hook is called just before the error is thrown, allowing you to:
|
|
1768
|
+
* - Log the exhaustion event for monitoring
|
|
1769
|
+
* - Trigger external proxy pool refresh
|
|
1770
|
+
* - Send alerts to monitoring systems
|
|
1771
|
+
* - Record statistics about proxy pool health
|
|
1772
|
+
*/
|
|
1773
|
+
export type OnNoProxiesAvailableHook = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
|
|
1729
1774
|
/**
|
|
1730
1775
|
* Collection of all hook types
|
|
1731
1776
|
* All hooks are arrays to allow multiple handlers
|
|
@@ -1750,6 +1795,7 @@ export interface RezoHooks {
|
|
|
1750
1795
|
afterProxyDisable: AfterProxyDisableHook[];
|
|
1751
1796
|
afterProxyRotate: AfterProxyRotateHook[];
|
|
1752
1797
|
afterProxyEnable: AfterProxyEnableHook[];
|
|
1798
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook[];
|
|
1753
1799
|
onSocket: OnSocketHook[];
|
|
1754
1800
|
onDns: OnDnsHook[];
|
|
1755
1801
|
onTls: OnTlsHook[];
|
|
@@ -2146,6 +2192,275 @@ declare class RezoError<T = any> extends Error {
|
|
|
2146
2192
|
toString(): string;
|
|
2147
2193
|
getFullDetails(): string;
|
|
2148
2194
|
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Queue configuration options
|
|
2197
|
+
*/
|
|
2198
|
+
export interface QueueConfig {
|
|
2199
|
+
/** Maximum concurrent tasks (default: Infinity) */
|
|
2200
|
+
concurrency?: number;
|
|
2201
|
+
/** Auto-start processing when tasks are added (default: true) */
|
|
2202
|
+
autoStart?: boolean;
|
|
2203
|
+
/** Timeout per task in milliseconds (default: none) */
|
|
2204
|
+
timeout?: number;
|
|
2205
|
+
/** Throw on timeout vs silently fail (default: true) */
|
|
2206
|
+
throwOnTimeout?: boolean;
|
|
2207
|
+
/** Interval between task starts in ms for rate limiting */
|
|
2208
|
+
interval?: number;
|
|
2209
|
+
/** Max tasks to start per interval (default: Infinity) */
|
|
2210
|
+
intervalCap?: number;
|
|
2211
|
+
/** Carry over unused interval capacity to next interval */
|
|
2212
|
+
carryoverConcurrencyCount?: boolean;
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Task options when adding to queue
|
|
2216
|
+
*/
|
|
2217
|
+
export interface TaskOptions {
|
|
2218
|
+
/** Task priority (higher runs first, default: 0) */
|
|
2219
|
+
priority?: number;
|
|
2220
|
+
/** Task-specific timeout (overrides queue default) */
|
|
2221
|
+
timeout?: number;
|
|
2222
|
+
/** Unique ID for tracking/cancellation */
|
|
2223
|
+
id?: string;
|
|
2224
|
+
/** Signal for external cancellation */
|
|
2225
|
+
signal?: AbortSignal;
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Current queue state
|
|
2229
|
+
*/
|
|
2230
|
+
export interface QueueState {
|
|
2231
|
+
/** Number of tasks currently running */
|
|
2232
|
+
pending: number;
|
|
2233
|
+
/** Number of tasks waiting in queue */
|
|
2234
|
+
size: number;
|
|
2235
|
+
/** Total tasks (pending + size) */
|
|
2236
|
+
total: number;
|
|
2237
|
+
/** Is queue paused */
|
|
2238
|
+
isPaused: boolean;
|
|
2239
|
+
/** Is queue idle (no tasks) */
|
|
2240
|
+
isIdle: boolean;
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* Queue statistics
|
|
2244
|
+
*/
|
|
2245
|
+
export interface QueueStats {
|
|
2246
|
+
/** Total tasks added since creation */
|
|
2247
|
+
added: number;
|
|
2248
|
+
/** Total tasks processed (started) */
|
|
2249
|
+
processed: number;
|
|
2250
|
+
/** Total successful completions */
|
|
2251
|
+
completed: number;
|
|
2252
|
+
/** Total failures */
|
|
2253
|
+
failed: number;
|
|
2254
|
+
/** Total timeouts */
|
|
2255
|
+
timedOut: number;
|
|
2256
|
+
/** Total cancellations */
|
|
2257
|
+
cancelled: number;
|
|
2258
|
+
/** Average task duration (ms) */
|
|
2259
|
+
averageDuration: number;
|
|
2260
|
+
/** Tasks per second (rolling average) */
|
|
2261
|
+
throughput: number;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Queue event types
|
|
2265
|
+
*/
|
|
2266
|
+
export interface QueueEvents {
|
|
2267
|
+
/** Task added to queue */
|
|
2268
|
+
add: {
|
|
2269
|
+
id: string;
|
|
2270
|
+
priority: number;
|
|
2271
|
+
};
|
|
2272
|
+
/** Task started executing */
|
|
2273
|
+
start: {
|
|
2274
|
+
id: string;
|
|
2275
|
+
};
|
|
2276
|
+
/** Task completed successfully */
|
|
2277
|
+
completed: {
|
|
2278
|
+
id: string;
|
|
2279
|
+
result: any;
|
|
2280
|
+
duration: number;
|
|
2281
|
+
};
|
|
2282
|
+
/** Task failed with error */
|
|
2283
|
+
error: {
|
|
2284
|
+
id: string;
|
|
2285
|
+
error: Error;
|
|
2286
|
+
};
|
|
2287
|
+
/** Task timed out */
|
|
2288
|
+
timeout: {
|
|
2289
|
+
id: string;
|
|
2290
|
+
};
|
|
2291
|
+
/** Task cancelled */
|
|
2292
|
+
cancelled: {
|
|
2293
|
+
id: string;
|
|
2294
|
+
};
|
|
2295
|
+
/** Queue became active (was idle, now processing) */
|
|
2296
|
+
active: undefined;
|
|
2297
|
+
/** Queue became idle (all tasks done) */
|
|
2298
|
+
idle: undefined;
|
|
2299
|
+
/** Queue was paused */
|
|
2300
|
+
paused: undefined;
|
|
2301
|
+
/** Queue was resumed */
|
|
2302
|
+
resumed: undefined;
|
|
2303
|
+
/** Next task about to run */
|
|
2304
|
+
next: undefined;
|
|
2305
|
+
/** Queue was emptied (no pending tasks) */
|
|
2306
|
+
empty: undefined;
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Event handler type
|
|
2310
|
+
*/
|
|
2311
|
+
export type EventHandler<T> = (data: T) => void;
|
|
2312
|
+
/**
|
|
2313
|
+
* Task function type
|
|
2314
|
+
*/
|
|
2315
|
+
export type TaskFunction<T> = () => Promise<T>;
|
|
2316
|
+
declare class RezoQueue<T = any> {
|
|
2317
|
+
private queue;
|
|
2318
|
+
private pendingCount;
|
|
2319
|
+
private isPausedFlag;
|
|
2320
|
+
private intervalId?;
|
|
2321
|
+
private intervalCount;
|
|
2322
|
+
private intervalStart;
|
|
2323
|
+
private eventHandlers;
|
|
2324
|
+
private statsData;
|
|
2325
|
+
private totalDuration;
|
|
2326
|
+
private throughputWindow;
|
|
2327
|
+
private readonly throughputWindowSize;
|
|
2328
|
+
private idlePromise?;
|
|
2329
|
+
private emptyPromise?;
|
|
2330
|
+
readonly config: Required<QueueConfig>;
|
|
2331
|
+
/**
|
|
2332
|
+
* Create a new RezoQueue
|
|
2333
|
+
* @param config - Queue configuration options
|
|
2334
|
+
*/
|
|
2335
|
+
constructor(config?: QueueConfig);
|
|
2336
|
+
/**
|
|
2337
|
+
* Get current queue state
|
|
2338
|
+
*/
|
|
2339
|
+
get state(): QueueState;
|
|
2340
|
+
/**
|
|
2341
|
+
* Get queue statistics
|
|
2342
|
+
*/
|
|
2343
|
+
get stats(): QueueStats;
|
|
2344
|
+
/**
|
|
2345
|
+
* Get/set concurrency limit
|
|
2346
|
+
*/
|
|
2347
|
+
get concurrency(): number;
|
|
2348
|
+
set concurrency(value: number);
|
|
2349
|
+
/**
|
|
2350
|
+
* Number of pending (running) tasks
|
|
2351
|
+
*/
|
|
2352
|
+
get pending(): number;
|
|
2353
|
+
/**
|
|
2354
|
+
* Number of tasks waiting in queue
|
|
2355
|
+
*/
|
|
2356
|
+
get size(): number;
|
|
2357
|
+
/**
|
|
2358
|
+
* Check if queue is paused
|
|
2359
|
+
*/
|
|
2360
|
+
get isPaused(): boolean;
|
|
2361
|
+
/**
|
|
2362
|
+
* Add a task to the queue
|
|
2363
|
+
* @param fn - Async function to execute
|
|
2364
|
+
* @param options - Task options
|
|
2365
|
+
* @returns Promise resolving to task result
|
|
2366
|
+
*/
|
|
2367
|
+
add<R = T>(fn: TaskFunction<R>, options?: TaskOptions): Promise<R>;
|
|
2368
|
+
/**
|
|
2369
|
+
* Add multiple tasks to the queue
|
|
2370
|
+
* @param fns - Array of async functions
|
|
2371
|
+
* @param options - Task options (applied to all)
|
|
2372
|
+
* @returns Promise resolving to array of results
|
|
2373
|
+
*/
|
|
2374
|
+
addAll<R = T>(fns: TaskFunction<R>[], options?: TaskOptions): Promise<R[]>;
|
|
2375
|
+
/**
|
|
2376
|
+
* Pause queue processing (running tasks continue)
|
|
2377
|
+
*/
|
|
2378
|
+
pause(): void;
|
|
2379
|
+
/**
|
|
2380
|
+
* Resume queue processing
|
|
2381
|
+
*/
|
|
2382
|
+
start(): void;
|
|
2383
|
+
/**
|
|
2384
|
+
* Clear all pending tasks from queue
|
|
2385
|
+
*/
|
|
2386
|
+
clear(): void;
|
|
2387
|
+
/**
|
|
2388
|
+
* Cancel a specific task by ID
|
|
2389
|
+
* @param id - Task ID to cancel
|
|
2390
|
+
* @returns true if task was found and cancelled
|
|
2391
|
+
*/
|
|
2392
|
+
cancel(id: string): boolean;
|
|
2393
|
+
/**
|
|
2394
|
+
* Cancel all tasks matching a predicate
|
|
2395
|
+
* @param predicate - Function to test each task
|
|
2396
|
+
* @returns Number of tasks cancelled
|
|
2397
|
+
*/
|
|
2398
|
+
cancelBy(predicate: (task: {
|
|
2399
|
+
id: string;
|
|
2400
|
+
priority: number;
|
|
2401
|
+
}) => boolean): number;
|
|
2402
|
+
/**
|
|
2403
|
+
* Wait for queue to become idle (no running or pending tasks)
|
|
2404
|
+
*/
|
|
2405
|
+
onIdle(): Promise<void>;
|
|
2406
|
+
/**
|
|
2407
|
+
* Wait for queue to be empty (no pending tasks, but may have running)
|
|
2408
|
+
*/
|
|
2409
|
+
onEmpty(): Promise<void>;
|
|
2410
|
+
/**
|
|
2411
|
+
* Wait for queue size to be less than limit
|
|
2412
|
+
* @param limit - Size threshold
|
|
2413
|
+
*/
|
|
2414
|
+
onSizeLessThan(limit: number): Promise<void>;
|
|
2415
|
+
/**
|
|
2416
|
+
* Register an event handler
|
|
2417
|
+
* @param event - Event name
|
|
2418
|
+
* @param handler - Handler function
|
|
2419
|
+
*/
|
|
2420
|
+
on<E extends keyof QueueEvents>(event: E, handler: EventHandler<QueueEvents[E]>): void;
|
|
2421
|
+
/**
|
|
2422
|
+
* Remove an event handler
|
|
2423
|
+
* @param event - Event name
|
|
2424
|
+
* @param handler - Handler function to remove
|
|
2425
|
+
*/
|
|
2426
|
+
off<E extends keyof QueueEvents>(event: E, handler: EventHandler<QueueEvents[E]>): void;
|
|
2427
|
+
/**
|
|
2428
|
+
* Destroy the queue and cleanup resources
|
|
2429
|
+
*/
|
|
2430
|
+
destroy(): void;
|
|
2431
|
+
/**
|
|
2432
|
+
* Insert task into queue maintaining priority order (highest first)
|
|
2433
|
+
*/
|
|
2434
|
+
private insertByPriority;
|
|
2435
|
+
/**
|
|
2436
|
+
* Try to run next task if capacity available
|
|
2437
|
+
*/
|
|
2438
|
+
private tryRunNext;
|
|
2439
|
+
/**
|
|
2440
|
+
* Execute a task
|
|
2441
|
+
*/
|
|
2442
|
+
private runTask;
|
|
2443
|
+
/**
|
|
2444
|
+
* Record task duration for statistics
|
|
2445
|
+
*/
|
|
2446
|
+
private recordDuration;
|
|
2447
|
+
/**
|
|
2448
|
+
* Start interval-based rate limiting
|
|
2449
|
+
*/
|
|
2450
|
+
private startInterval;
|
|
2451
|
+
/**
|
|
2452
|
+
* Emit an event
|
|
2453
|
+
*/
|
|
2454
|
+
protected emit<E extends keyof QueueEvents>(event: E, data: QueueEvents[E]): void;
|
|
2455
|
+
/**
|
|
2456
|
+
* Check if queue became empty
|
|
2457
|
+
*/
|
|
2458
|
+
private checkEmpty;
|
|
2459
|
+
/**
|
|
2460
|
+
* Check if queue became idle
|
|
2461
|
+
*/
|
|
2462
|
+
private checkIdle;
|
|
2463
|
+
}
|
|
2149
2464
|
type ProxyProtocol$1 = "http" | "https" | "socks4" | "socks5";
|
|
2150
2465
|
/**
|
|
2151
2466
|
* Configuration options for proxy connections
|
|
@@ -2222,7 +2537,7 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2222
2537
|
/**
|
|
2223
2538
|
* Queue to use for request execution
|
|
2224
2539
|
*/
|
|
2225
|
-
queue?:
|
|
2540
|
+
queue?: RezoQueue | null;
|
|
2226
2541
|
/**
|
|
2227
2542
|
* Controls how the response body is parsed and returned in `response.data`.
|
|
2228
2543
|
*
|
|
@@ -2312,10 +2627,6 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2312
2627
|
autoSetOrigin?: boolean;
|
|
2313
2628
|
treat302As303?: boolean;
|
|
2314
2629
|
startNewRequest?: boolean;
|
|
2315
|
-
/** Whether to use HTTP/2 protocol */
|
|
2316
|
-
http2?: boolean;
|
|
2317
|
-
/** Whether to use cURL adapter */
|
|
2318
|
-
curl?: boolean;
|
|
2319
2630
|
/**
|
|
2320
2631
|
* DNS cache configuration for faster repeated requests.
|
|
2321
2632
|
*
|
|
@@ -2419,6 +2730,12 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2419
2730
|
withCredentials?: boolean;
|
|
2420
2731
|
/** Proxy configuration (URL string or detailed options) */
|
|
2421
2732
|
proxy?: string | ProxyOptions;
|
|
2733
|
+
/**
|
|
2734
|
+
* Whether to use ProxyManager for this request
|
|
2735
|
+
* Set to false to bypass ProxyManager even when one is configured
|
|
2736
|
+
* @default true (uses ProxyManager if configured)
|
|
2737
|
+
*/
|
|
2738
|
+
useProxyManager?: boolean;
|
|
2422
2739
|
/** Whether to enable automatic cookie handling */
|
|
2423
2740
|
useCookies?: boolean;
|
|
2424
2741
|
/** Custom cookie jar for managing cookies */
|
|
@@ -2440,8 +2757,6 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2440
2757
|
transformRequest?: Array<(data: any, headers: RezoHeaders) => any>;
|
|
2441
2758
|
/** Array of functions to transform response data */
|
|
2442
2759
|
transformResponse?: Array<(data: any) => any>;
|
|
2443
|
-
/** Adapter to use for the request (name or custom function) */
|
|
2444
|
-
adapter?: string | ((config: RezoRequestConfig) => Promise<any>);
|
|
2445
2760
|
/** AbortSignal to cancel the request */
|
|
2446
2761
|
signal?: AbortSignal;
|
|
2447
2762
|
/** File path to save the response to (for downloads) */
|
|
@@ -2658,6 +2973,7 @@ type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean
|
|
|
2658
2973
|
type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
2659
2974
|
type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
2660
2975
|
type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
2976
|
+
type OnNoProxiesAvailableHook$1 = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
|
|
2661
2977
|
/**
|
|
2662
2978
|
* Proxy hooks collection for ProxyManager events
|
|
2663
2979
|
*/
|
|
@@ -2670,6 +2986,8 @@ export interface ProxyHooks {
|
|
|
2670
2986
|
afterProxyDisable: AfterProxyDisableHook$1[];
|
|
2671
2987
|
afterProxyRotate: AfterProxyRotateHook$1[];
|
|
2672
2988
|
afterProxyEnable: AfterProxyEnableHook$1[];
|
|
2989
|
+
/** Hook triggered when no proxies are available */
|
|
2990
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook$1[];
|
|
2673
2991
|
}
|
|
2674
2992
|
declare class ProxyManager {
|
|
2675
2993
|
/** Configuration for the proxy manager */
|
|
@@ -2805,8 +3123,40 @@ declare class ProxyManager {
|
|
|
2805
3123
|
private runAfterProxyRotateHooks;
|
|
2806
3124
|
private runAfterProxyDisableHooks;
|
|
2807
3125
|
private runAfterProxyEnableHooks;
|
|
3126
|
+
/**
|
|
3127
|
+
* Run onNoProxiesAvailable hooks synchronously
|
|
3128
|
+
* Called when no proxies are available and an error is about to be thrown
|
|
3129
|
+
*/
|
|
3130
|
+
private runOnNoProxiesAvailableHooksSync;
|
|
3131
|
+
/**
|
|
3132
|
+
* Run onNoProxiesAvailable hooks asynchronously
|
|
3133
|
+
* Called when no proxies are available and an error is about to be thrown
|
|
3134
|
+
*/
|
|
3135
|
+
runOnNoProxiesAvailableHooks(context: OnNoProxiesAvailableContext): Promise<void>;
|
|
3136
|
+
/**
|
|
3137
|
+
* Notify that no proxies are available and trigger hooks
|
|
3138
|
+
* This method is called when proxy selection fails due to pool exhaustion
|
|
3139
|
+
*
|
|
3140
|
+
* @param url - The request URL that needed a proxy
|
|
3141
|
+
* @param error - The error that will be thrown
|
|
3142
|
+
* @returns The context object with detailed information about the proxy pool state
|
|
3143
|
+
*
|
|
3144
|
+
* @example
|
|
3145
|
+
* ```typescript
|
|
3146
|
+
* manager.hooks.onNoProxiesAvailable.push((context) => {
|
|
3147
|
+
* console.error(`No proxies available for ${context.url}`);
|
|
3148
|
+
* console.log(`Dead: ${context.disabledReasons.dead}, Limit: ${context.disabledReasons.limitReached}`);
|
|
3149
|
+
* // Trigger external alert or proxy refresh
|
|
3150
|
+
* alertSystem.notify('Proxy pool exhausted', context);
|
|
3151
|
+
* });
|
|
3152
|
+
*
|
|
3153
|
+
* // Called internally or by adapters when no proxies are available
|
|
3154
|
+
* const context = manager.notifyNoProxiesAvailable('https://api.example.com', new Error('No proxies'));
|
|
3155
|
+
* ```
|
|
3156
|
+
*/
|
|
3157
|
+
notifyNoProxiesAvailable(url: string, error: Error): OnNoProxiesAvailableContext;
|
|
2808
3158
|
}
|
|
2809
|
-
export type queueOptions =
|
|
3159
|
+
export type queueOptions = QueueConfig;
|
|
2810
3160
|
export interface CacheConfig {
|
|
2811
3161
|
/** Response cache configuration */
|
|
2812
3162
|
response?: boolean | ResponseCacheConfig;
|
|
@@ -2865,10 +3215,6 @@ export interface RezoDefaultOptions {
|
|
|
2865
3215
|
keepAlive?: boolean;
|
|
2866
3216
|
/** Whether to detect and prevent redirect cycles */
|
|
2867
3217
|
enableRedirectCycleDetection?: boolean;
|
|
2868
|
-
/** Whether to use HTTP/2 protocol */
|
|
2869
|
-
http2?: boolean;
|
|
2870
|
-
/** Whether to use cURL adapter */
|
|
2871
|
-
curl?: boolean;
|
|
2872
3218
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2873
3219
|
withCredentials?: boolean;
|
|
2874
3220
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -2907,8 +3253,6 @@ export interface RezoDefaultOptions {
|
|
|
2907
3253
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
2908
3254
|
/** Array of functions to transform response data */
|
|
2909
3255
|
transformResponse?: RezoHttpRequest["transformResponse"];
|
|
2910
|
-
/** Adapter to use for the request (name or custom function) */
|
|
2911
|
-
adapter?: RezoHttpRequest["adapter"];
|
|
2912
3256
|
/** Browser simulation configuration for user agent spoofing */
|
|
2913
3257
|
browser?: RezoHttpRequest["browser"];
|
|
2914
3258
|
/** Enable debug logging for the request */
|
|
@@ -3808,7 +4152,7 @@ export interface httpAdapterPutOverloads {
|
|
|
3808
4152
|
*/
|
|
3809
4153
|
export type AdapterFunction<T = any> = (options: RezoRequestConfig, defaultOptions: RezoDefaultOptions, jar: RezoCookieJar) => Promise<RezoResponse<T> | RezoStreamResponse | RezoDownloadResponse | RezoUploadResponse>;
|
|
3810
4154
|
declare class Rezo {
|
|
3811
|
-
protected queue:
|
|
4155
|
+
protected queue: RezoQueue | null;
|
|
3812
4156
|
protected isQueueEnabled: boolean;
|
|
3813
4157
|
defaults: RezoDefaultOptions;
|
|
3814
4158
|
hooks: RezoHooks;
|
|
@@ -6041,7 +6385,7 @@ export declare class CrawlerOptions {
|
|
|
6041
6385
|
/**
|
|
6042
6386
|
* Internal method to process and add rate limiter configurations
|
|
6043
6387
|
* @param options - Limiter configuration object with enable flag and queue options
|
|
6044
|
-
* @description Validates and stores rate limiter configurations, creating
|
|
6388
|
+
* @description Validates and stores rate limiter configurations, creating RezoQueue instances
|
|
6045
6389
|
* for each valid configuration. Supports domain-specific or global rate limiting.
|
|
6046
6390
|
* @private
|
|
6047
6391
|
*/
|
|
@@ -6205,7 +6549,7 @@ export declare class CrawlerOptions {
|
|
|
6205
6549
|
* ```
|
|
6206
6550
|
*/
|
|
6207
6551
|
getAdapter(url: string, type: "proxies", useGlobal?: boolean, random?: boolean): IProxy | null;
|
|
6208
|
-
getAdapter(url: string, type: "limiters", useGlobal?: boolean, random?: boolean):
|
|
6552
|
+
getAdapter(url: string, type: "limiters", useGlobal?: boolean, random?: boolean): RezoQueue | null;
|
|
6209
6553
|
getAdapter(url: string, type: "oxylabs", useGlobal?: boolean, random?: boolean): Oxylabs | null;
|
|
6210
6554
|
getAdapter(url: string, type: "decodo", useGlobal?: boolean, random?: boolean): Decodo | null;
|
|
6211
6555
|
getAdapter(url: string, type: "headers", useGlobal?: boolean, random?: boolean): OutgoingHttpHeaders | null;
|
package/dist/entries/crawler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Crawler =
|
|
3
|
-
const
|
|
4
|
-
exports.CrawlerOptions =
|
|
5
|
-
exports.Domain =
|
|
1
|
+
const _mod_juod8q = require('../plugin/crawler.cjs');
|
|
2
|
+
exports.Crawler = _mod_juod8q.Crawler;;
|
|
3
|
+
const _mod_lugvyb = require('../plugin/crawler-options.cjs');
|
|
4
|
+
exports.CrawlerOptions = _mod_lugvyb.CrawlerOptions;
|
|
5
|
+
exports.Domain = _mod_lugvyb.Domain;;
|
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Rezo =
|
|
3
|
-
exports.createRezoInstance =
|
|
4
|
-
exports.createDefaultInstance =
|
|
5
|
-
const
|
|
6
|
-
exports.RezoError =
|
|
7
|
-
exports.RezoErrorCode =
|
|
8
|
-
const
|
|
9
|
-
exports.RezoHeaders =
|
|
10
|
-
const
|
|
11
|
-
exports.RezoFormData =
|
|
12
|
-
const
|
|
13
|
-
exports.RezoCookieJar =
|
|
14
|
-
const
|
|
15
|
-
exports.createDefaultHooks =
|
|
16
|
-
exports.mergeHooks =
|
|
17
|
-
const
|
|
18
|
-
exports.ProxyManager =
|
|
1
|
+
const _mod_8g1zwb = require('./core/rezo.cjs');
|
|
2
|
+
exports.Rezo = _mod_8g1zwb.Rezo;
|
|
3
|
+
exports.createRezoInstance = _mod_8g1zwb.createRezoInstance;
|
|
4
|
+
exports.createDefaultInstance = _mod_8g1zwb.createDefaultInstance;;
|
|
5
|
+
const _mod_brpqyx = require('./errors/rezo-error.cjs');
|
|
6
|
+
exports.RezoError = _mod_brpqyx.RezoError;
|
|
7
|
+
exports.RezoErrorCode = _mod_brpqyx.RezoErrorCode;;
|
|
8
|
+
const _mod_nxs9mv = require('./utils/headers.cjs');
|
|
9
|
+
exports.RezoHeaders = _mod_nxs9mv.RezoHeaders;;
|
|
10
|
+
const _mod_sp17k6 = require('./utils/form-data.cjs');
|
|
11
|
+
exports.RezoFormData = _mod_sp17k6.RezoFormData;;
|
|
12
|
+
const _mod_rt2h0v = require('./utils/cookies.cjs');
|
|
13
|
+
exports.RezoCookieJar = _mod_rt2h0v.RezoCookieJar;;
|
|
14
|
+
const _mod_pg0wwn = require('./core/hooks.cjs');
|
|
15
|
+
exports.createDefaultHooks = _mod_pg0wwn.createDefaultHooks;
|
|
16
|
+
exports.mergeHooks = _mod_pg0wwn.mergeHooks;;
|
|
17
|
+
const _mod_qipnt4 = require('./proxy/manager.cjs');
|
|
18
|
+
exports.ProxyManager = _mod_qipnt4.ProxyManager;;
|
|
19
|
+
const _mod_z8k198 = require('./queue/index.cjs');
|
|
20
|
+
exports.RezoQueue = _mod_z8k198.RezoQueue;
|
|
21
|
+
exports.HttpQueue = _mod_z8k198.HttpQueue;
|
|
22
|
+
exports.Priority = _mod_z8k198.Priority;
|
|
23
|
+
exports.HttpMethodPriority = _mod_z8k198.HttpMethodPriority;;
|
|
19
24
|
const { RezoError } = require('./errors/rezo-error.cjs');
|
|
20
25
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
21
26
|
const Cancel = exports.Cancel = RezoError;
|