rezo 1.0.6 → 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/dist/adapters/entries/curl.d.ts +75 -0
- package/dist/adapters/entries/fetch.d.ts +75 -0
- package/dist/adapters/entries/http.d.ts +75 -0
- package/dist/adapters/entries/http2.d.ts +75 -0
- package/dist/adapters/entries/react-native.d.ts +75 -0
- package/dist/adapters/entries/xhr.d.ts +75 -0
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/core/hooks.cjs +2 -0
- package/dist/core/hooks.js +2 -0
- package/dist/crawler.d.ts +75 -0
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +23 -23
- package/dist/index.d.ts +75 -0
- package/dist/platform/browser.d.ts +75 -0
- package/dist/platform/bun.d.ts +75 -0
- package/dist/platform/deno.d.ts +75 -0
- package/dist/platform/node.d.ts +75 -0
- package/dist/platform/react-native.d.ts +75 -0
- package/dist/platform/worker.d.ts +75 -0
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/proxy/manager.cjs +43 -1
- package/dist/proxy/manager.js +43 -1
- package/dist/queue/index.cjs +8 -8
- package/package.json +1 -1
|
@@ -1191,6 +1191,35 @@ export interface AfterProxyEnableContext {
|
|
|
1191
1191
|
/** Reason for enabling */
|
|
1192
1192
|
reason: "cooldown-expired" | "manual";
|
|
1193
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
|
+
}
|
|
1194
1223
|
/**
|
|
1195
1224
|
* Context provided to beforeRequest hook
|
|
1196
1225
|
* Contains metadata about the current request state
|
|
@@ -1509,6 +1538,16 @@ export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void |
|
|
|
1509
1538
|
* Use for notifications, logging
|
|
1510
1539
|
*/
|
|
1511
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>;
|
|
1512
1551
|
/**
|
|
1513
1552
|
* Collection of all hook types
|
|
1514
1553
|
* All hooks are arrays to allow multiple handlers
|
|
@@ -1533,6 +1572,7 @@ export interface RezoHooks {
|
|
|
1533
1572
|
afterProxyDisable: AfterProxyDisableHook[];
|
|
1534
1573
|
afterProxyRotate: AfterProxyRotateHook[];
|
|
1535
1574
|
afterProxyEnable: AfterProxyEnableHook[];
|
|
1575
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook[];
|
|
1536
1576
|
onSocket: OnSocketHook[];
|
|
1537
1577
|
onDns: OnDnsHook[];
|
|
1538
1578
|
onTls: OnTlsHook[];
|
|
@@ -2815,6 +2855,7 @@ type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean
|
|
|
2815
2855
|
type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
2816
2856
|
type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
2817
2857
|
type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
2858
|
+
type OnNoProxiesAvailableHook$1 = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
|
|
2818
2859
|
/**
|
|
2819
2860
|
* Proxy hooks collection for ProxyManager events
|
|
2820
2861
|
*/
|
|
@@ -2827,6 +2868,8 @@ export interface ProxyHooks {
|
|
|
2827
2868
|
afterProxyDisable: AfterProxyDisableHook$1[];
|
|
2828
2869
|
afterProxyRotate: AfterProxyRotateHook$1[];
|
|
2829
2870
|
afterProxyEnable: AfterProxyEnableHook$1[];
|
|
2871
|
+
/** Hook triggered when no proxies are available */
|
|
2872
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook$1[];
|
|
2830
2873
|
}
|
|
2831
2874
|
declare class ProxyManager {
|
|
2832
2875
|
/** Configuration for the proxy manager */
|
|
@@ -2962,6 +3005,38 @@ declare class ProxyManager {
|
|
|
2962
3005
|
private runAfterProxyRotateHooks;
|
|
2963
3006
|
private runAfterProxyDisableHooks;
|
|
2964
3007
|
private runAfterProxyEnableHooks;
|
|
3008
|
+
/**
|
|
3009
|
+
* Run onNoProxiesAvailable hooks synchronously
|
|
3010
|
+
* Called when no proxies are available and an error is about to be thrown
|
|
3011
|
+
*/
|
|
3012
|
+
private runOnNoProxiesAvailableHooksSync;
|
|
3013
|
+
/**
|
|
3014
|
+
* Run onNoProxiesAvailable hooks asynchronously
|
|
3015
|
+
* Called when no proxies are available and an error is about to be thrown
|
|
3016
|
+
*/
|
|
3017
|
+
runOnNoProxiesAvailableHooks(context: OnNoProxiesAvailableContext): Promise<void>;
|
|
3018
|
+
/**
|
|
3019
|
+
* Notify that no proxies are available and trigger hooks
|
|
3020
|
+
* This method is called when proxy selection fails due to pool exhaustion
|
|
3021
|
+
*
|
|
3022
|
+
* @param url - The request URL that needed a proxy
|
|
3023
|
+
* @param error - The error that will be thrown
|
|
3024
|
+
* @returns The context object with detailed information about the proxy pool state
|
|
3025
|
+
*
|
|
3026
|
+
* @example
|
|
3027
|
+
* ```typescript
|
|
3028
|
+
* manager.hooks.onNoProxiesAvailable.push((context) => {
|
|
3029
|
+
* console.error(`No proxies available for ${context.url}`);
|
|
3030
|
+
* console.log(`Dead: ${context.disabledReasons.dead}, Limit: ${context.disabledReasons.limitReached}`);
|
|
3031
|
+
* // Trigger external alert or proxy refresh
|
|
3032
|
+
* alertSystem.notify('Proxy pool exhausted', context);
|
|
3033
|
+
* });
|
|
3034
|
+
*
|
|
3035
|
+
* // Called internally or by adapters when no proxies are available
|
|
3036
|
+
* const context = manager.notifyNoProxiesAvailable('https://api.example.com', new Error('No proxies'));
|
|
3037
|
+
* ```
|
|
3038
|
+
*/
|
|
3039
|
+
notifyNoProxiesAvailable(url: string, error: Error): OnNoProxiesAvailableContext;
|
|
2965
3040
|
}
|
|
2966
3041
|
export type queueOptions = QueueConfig;
|
|
2967
3042
|
export interface CacheConfig {
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.detectRuntime =
|
|
3
|
-
exports.getAdapterCapabilities =
|
|
4
|
-
exports.buildAdapterContext =
|
|
5
|
-
exports.getAvailableAdapters =
|
|
6
|
-
exports.selectAdapter =
|
|
1
|
+
const _mod_1j8os6 = require('./picker.cjs');
|
|
2
|
+
exports.detectRuntime = _mod_1j8os6.detectRuntime;
|
|
3
|
+
exports.getAdapterCapabilities = _mod_1j8os6.getAdapterCapabilities;
|
|
4
|
+
exports.buildAdapterContext = _mod_1j8os6.buildAdapterContext;
|
|
5
|
+
exports.getAvailableAdapters = _mod_1j8os6.getAvailableAdapters;
|
|
6
|
+
exports.selectAdapter = _mod_1j8os6.selectAdapter;;
|
package/dist/cache/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.LRUCache =
|
|
3
|
-
const
|
|
4
|
-
exports.DNSCache =
|
|
5
|
-
exports.getGlobalDNSCache =
|
|
6
|
-
exports.resetGlobalDNSCache =
|
|
7
|
-
const
|
|
8
|
-
exports.ResponseCache =
|
|
9
|
-
exports.normalizeResponseCacheConfig =
|
|
10
|
-
const
|
|
11
|
-
exports.FileCacher =
|
|
12
|
-
const
|
|
13
|
-
exports.UrlStore =
|
|
1
|
+
const _mod_5re24b = require('./lru-cache.cjs');
|
|
2
|
+
exports.LRUCache = _mod_5re24b.LRUCache;;
|
|
3
|
+
const _mod_nmlyd4 = require('./dns-cache.cjs');
|
|
4
|
+
exports.DNSCache = _mod_nmlyd4.DNSCache;
|
|
5
|
+
exports.getGlobalDNSCache = _mod_nmlyd4.getGlobalDNSCache;
|
|
6
|
+
exports.resetGlobalDNSCache = _mod_nmlyd4.resetGlobalDNSCache;;
|
|
7
|
+
const _mod_n1g00g = require('./response-cache.cjs');
|
|
8
|
+
exports.ResponseCache = _mod_n1g00g.ResponseCache;
|
|
9
|
+
exports.normalizeResponseCacheConfig = _mod_n1g00g.normalizeResponseCacheConfig;;
|
|
10
|
+
const _mod_xmultr = require('./file-cacher.cjs');
|
|
11
|
+
exports.FileCacher = _mod_xmultr.FileCacher;;
|
|
12
|
+
const _mod_81d50n = require('./url-store.cjs');
|
|
13
|
+
exports.UrlStore = _mod_81d50n.UrlStore;;
|
package/dist/core/hooks.cjs
CHANGED
|
@@ -19,6 +19,7 @@ function createDefaultHooks() {
|
|
|
19
19
|
afterProxyDisable: [],
|
|
20
20
|
afterProxyRotate: [],
|
|
21
21
|
afterProxyEnable: [],
|
|
22
|
+
onNoProxiesAvailable: [],
|
|
22
23
|
onSocket: [],
|
|
23
24
|
onDns: [],
|
|
24
25
|
onTls: [],
|
|
@@ -49,6 +50,7 @@ function mergeHooks(base, overrides) {
|
|
|
49
50
|
afterProxyDisable: [...base.afterProxyDisable, ...overrides.afterProxyDisable || []],
|
|
50
51
|
afterProxyRotate: [...base.afterProxyRotate, ...overrides.afterProxyRotate || []],
|
|
51
52
|
afterProxyEnable: [...base.afterProxyEnable, ...overrides.afterProxyEnable || []],
|
|
53
|
+
onNoProxiesAvailable: [...base.onNoProxiesAvailable, ...overrides.onNoProxiesAvailable || []],
|
|
52
54
|
onSocket: [...base.onSocket, ...overrides.onSocket || []],
|
|
53
55
|
onDns: [...base.onDns, ...overrides.onDns || []],
|
|
54
56
|
onTls: [...base.onTls, ...overrides.onTls || []],
|
package/dist/core/hooks.js
CHANGED
|
@@ -19,6 +19,7 @@ export function createDefaultHooks() {
|
|
|
19
19
|
afterProxyDisable: [],
|
|
20
20
|
afterProxyRotate: [],
|
|
21
21
|
afterProxyEnable: [],
|
|
22
|
+
onNoProxiesAvailable: [],
|
|
22
23
|
onSocket: [],
|
|
23
24
|
onDns: [],
|
|
24
25
|
onTls: [],
|
|
@@ -49,6 +50,7 @@ export function mergeHooks(base, overrides) {
|
|
|
49
50
|
afterProxyDisable: [...base.afterProxyDisable, ...overrides.afterProxyDisable || []],
|
|
50
51
|
afterProxyRotate: [...base.afterProxyRotate, ...overrides.afterProxyRotate || []],
|
|
51
52
|
afterProxyEnable: [...base.afterProxyEnable, ...overrides.afterProxyEnable || []],
|
|
53
|
+
onNoProxiesAvailable: [...base.onNoProxiesAvailable, ...overrides.onNoProxiesAvailable || []],
|
|
52
54
|
onSocket: [...base.onSocket, ...overrides.onSocket || []],
|
|
53
55
|
onDns: [...base.onDns, ...overrides.onDns || []],
|
|
54
56
|
onTls: [...base.onTls, ...overrides.onTls || []],
|
package/dist/crawler.d.ts
CHANGED
|
@@ -1414,6 +1414,35 @@ export interface AfterProxyEnableContext {
|
|
|
1414
1414
|
/** Reason for enabling */
|
|
1415
1415
|
reason: "cooldown-expired" | "manual";
|
|
1416
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
|
+
}
|
|
1417
1446
|
/**
|
|
1418
1447
|
* Context provided to beforeRequest hook
|
|
1419
1448
|
* Contains metadata about the current request state
|
|
@@ -1732,6 +1761,16 @@ export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void |
|
|
|
1732
1761
|
* Use for notifications, logging
|
|
1733
1762
|
*/
|
|
1734
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>;
|
|
1735
1774
|
/**
|
|
1736
1775
|
* Collection of all hook types
|
|
1737
1776
|
* All hooks are arrays to allow multiple handlers
|
|
@@ -1756,6 +1795,7 @@ export interface RezoHooks {
|
|
|
1756
1795
|
afterProxyDisable: AfterProxyDisableHook[];
|
|
1757
1796
|
afterProxyRotate: AfterProxyRotateHook[];
|
|
1758
1797
|
afterProxyEnable: AfterProxyEnableHook[];
|
|
1798
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook[];
|
|
1759
1799
|
onSocket: OnSocketHook[];
|
|
1760
1800
|
onDns: OnDnsHook[];
|
|
1761
1801
|
onTls: OnTlsHook[];
|
|
@@ -2933,6 +2973,7 @@ type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean
|
|
|
2933
2973
|
type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
2934
2974
|
type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
2935
2975
|
type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
2976
|
+
type OnNoProxiesAvailableHook$1 = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
|
|
2936
2977
|
/**
|
|
2937
2978
|
* Proxy hooks collection for ProxyManager events
|
|
2938
2979
|
*/
|
|
@@ -2945,6 +2986,8 @@ export interface ProxyHooks {
|
|
|
2945
2986
|
afterProxyDisable: AfterProxyDisableHook$1[];
|
|
2946
2987
|
afterProxyRotate: AfterProxyRotateHook$1[];
|
|
2947
2988
|
afterProxyEnable: AfterProxyEnableHook$1[];
|
|
2989
|
+
/** Hook triggered when no proxies are available */
|
|
2990
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook$1[];
|
|
2948
2991
|
}
|
|
2949
2992
|
declare class ProxyManager {
|
|
2950
2993
|
/** Configuration for the proxy manager */
|
|
@@ -3080,6 +3123,38 @@ declare class ProxyManager {
|
|
|
3080
3123
|
private runAfterProxyRotateHooks;
|
|
3081
3124
|
private runAfterProxyDisableHooks;
|
|
3082
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;
|
|
3083
3158
|
}
|
|
3084
3159
|
export type queueOptions = QueueConfig;
|
|
3085
3160
|
export interface CacheConfig {
|
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,26 +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 =
|
|
19
|
-
const
|
|
20
|
-
exports.RezoQueue =
|
|
21
|
-
exports.HttpQueue =
|
|
22
|
-
exports.Priority =
|
|
23
|
-
exports.HttpMethodPriority =
|
|
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;;
|
|
24
24
|
const { RezoError } = require('./errors/rezo-error.cjs');
|
|
25
25
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
26
26
|
const Cancel = exports.Cancel = RezoError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1191,6 +1191,35 @@ export interface AfterProxyEnableContext {
|
|
|
1191
1191
|
/** Reason for enabling */
|
|
1192
1192
|
reason: "cooldown-expired" | "manual";
|
|
1193
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
|
+
}
|
|
1194
1223
|
/**
|
|
1195
1224
|
* Context provided to beforeRequest hook
|
|
1196
1225
|
* Contains metadata about the current request state
|
|
@@ -1509,6 +1538,16 @@ export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void |
|
|
|
1509
1538
|
* Use for notifications, logging
|
|
1510
1539
|
*/
|
|
1511
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>;
|
|
1512
1551
|
/**
|
|
1513
1552
|
* Collection of all hook types
|
|
1514
1553
|
* All hooks are arrays to allow multiple handlers
|
|
@@ -1533,6 +1572,7 @@ export interface RezoHooks {
|
|
|
1533
1572
|
afterProxyDisable: AfterProxyDisableHook[];
|
|
1534
1573
|
afterProxyRotate: AfterProxyRotateHook[];
|
|
1535
1574
|
afterProxyEnable: AfterProxyEnableHook[];
|
|
1575
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook[];
|
|
1536
1576
|
onSocket: OnSocketHook[];
|
|
1537
1577
|
onDns: OnDnsHook[];
|
|
1538
1578
|
onTls: OnTlsHook[];
|
|
@@ -2941,6 +2981,7 @@ type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean
|
|
|
2941
2981
|
type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
2942
2982
|
type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
2943
2983
|
type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
2984
|
+
type OnNoProxiesAvailableHook$1 = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
|
|
2944
2985
|
/**
|
|
2945
2986
|
* Proxy hooks collection for ProxyManager events
|
|
2946
2987
|
*/
|
|
@@ -2953,6 +2994,8 @@ export interface ProxyHooks {
|
|
|
2953
2994
|
afterProxyDisable: AfterProxyDisableHook$1[];
|
|
2954
2995
|
afterProxyRotate: AfterProxyRotateHook$1[];
|
|
2955
2996
|
afterProxyEnable: AfterProxyEnableHook$1[];
|
|
2997
|
+
/** Hook triggered when no proxies are available */
|
|
2998
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook$1[];
|
|
2956
2999
|
}
|
|
2957
3000
|
/**
|
|
2958
3001
|
* ProxyManager - Advanced proxy rotation and pool management
|
|
@@ -3107,6 +3150,38 @@ export declare class ProxyManager {
|
|
|
3107
3150
|
private runAfterProxyRotateHooks;
|
|
3108
3151
|
private runAfterProxyDisableHooks;
|
|
3109
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;
|
|
3110
3185
|
}
|
|
3111
3186
|
export type queueOptions = QueueConfig;
|
|
3112
3187
|
export interface CacheConfig {
|
|
@@ -1191,6 +1191,35 @@ export interface AfterProxyEnableContext {
|
|
|
1191
1191
|
/** Reason for enabling */
|
|
1192
1192
|
reason: "cooldown-expired" | "manual";
|
|
1193
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
|
+
}
|
|
1194
1223
|
/**
|
|
1195
1224
|
* Context provided to beforeRequest hook
|
|
1196
1225
|
* Contains metadata about the current request state
|
|
@@ -1509,6 +1538,16 @@ export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void |
|
|
|
1509
1538
|
* Use for notifications, logging
|
|
1510
1539
|
*/
|
|
1511
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>;
|
|
1512
1551
|
/**
|
|
1513
1552
|
* Collection of all hook types
|
|
1514
1553
|
* All hooks are arrays to allow multiple handlers
|
|
@@ -1533,6 +1572,7 @@ export interface RezoHooks {
|
|
|
1533
1572
|
afterProxyDisable: AfterProxyDisableHook[];
|
|
1534
1573
|
afterProxyRotate: AfterProxyRotateHook[];
|
|
1535
1574
|
afterProxyEnable: AfterProxyEnableHook[];
|
|
1575
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook[];
|
|
1536
1576
|
onSocket: OnSocketHook[];
|
|
1537
1577
|
onDns: OnDnsHook[];
|
|
1538
1578
|
onTls: OnTlsHook[];
|
|
@@ -2815,6 +2855,7 @@ type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean
|
|
|
2815
2855
|
type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
2816
2856
|
type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
2817
2857
|
type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
2858
|
+
type OnNoProxiesAvailableHook$1 = (context: OnNoProxiesAvailableContext) => void | Promise<void>;
|
|
2818
2859
|
/**
|
|
2819
2860
|
* Proxy hooks collection for ProxyManager events
|
|
2820
2861
|
*/
|
|
@@ -2827,6 +2868,8 @@ export interface ProxyHooks {
|
|
|
2827
2868
|
afterProxyDisable: AfterProxyDisableHook$1[];
|
|
2828
2869
|
afterProxyRotate: AfterProxyRotateHook$1[];
|
|
2829
2870
|
afterProxyEnable: AfterProxyEnableHook$1[];
|
|
2871
|
+
/** Hook triggered when no proxies are available */
|
|
2872
|
+
onNoProxiesAvailable: OnNoProxiesAvailableHook$1[];
|
|
2830
2873
|
}
|
|
2831
2874
|
declare class ProxyManager {
|
|
2832
2875
|
/** Configuration for the proxy manager */
|
|
@@ -2962,6 +3005,38 @@ declare class ProxyManager {
|
|
|
2962
3005
|
private runAfterProxyRotateHooks;
|
|
2963
3006
|
private runAfterProxyDisableHooks;
|
|
2964
3007
|
private runAfterProxyEnableHooks;
|
|
3008
|
+
/**
|
|
3009
|
+
* Run onNoProxiesAvailable hooks synchronously
|
|
3010
|
+
* Called when no proxies are available and an error is about to be thrown
|
|
3011
|
+
*/
|
|
3012
|
+
private runOnNoProxiesAvailableHooksSync;
|
|
3013
|
+
/**
|
|
3014
|
+
* Run onNoProxiesAvailable hooks asynchronously
|
|
3015
|
+
* Called when no proxies are available and an error is about to be thrown
|
|
3016
|
+
*/
|
|
3017
|
+
runOnNoProxiesAvailableHooks(context: OnNoProxiesAvailableContext): Promise<void>;
|
|
3018
|
+
/**
|
|
3019
|
+
* Notify that no proxies are available and trigger hooks
|
|
3020
|
+
* This method is called when proxy selection fails due to pool exhaustion
|
|
3021
|
+
*
|
|
3022
|
+
* @param url - The request URL that needed a proxy
|
|
3023
|
+
* @param error - The error that will be thrown
|
|
3024
|
+
* @returns The context object with detailed information about the proxy pool state
|
|
3025
|
+
*
|
|
3026
|
+
* @example
|
|
3027
|
+
* ```typescript
|
|
3028
|
+
* manager.hooks.onNoProxiesAvailable.push((context) => {
|
|
3029
|
+
* console.error(`No proxies available for ${context.url}`);
|
|
3030
|
+
* console.log(`Dead: ${context.disabledReasons.dead}, Limit: ${context.disabledReasons.limitReached}`);
|
|
3031
|
+
* // Trigger external alert or proxy refresh
|
|
3032
|
+
* alertSystem.notify('Proxy pool exhausted', context);
|
|
3033
|
+
* });
|
|
3034
|
+
*
|
|
3035
|
+
* // Called internally or by adapters when no proxies are available
|
|
3036
|
+
* const context = manager.notifyNoProxiesAvailable('https://api.example.com', new Error('No proxies'));
|
|
3037
|
+
* ```
|
|
3038
|
+
*/
|
|
3039
|
+
notifyNoProxiesAvailable(url: string, error: Error): OnNoProxiesAvailableContext;
|
|
2965
3040
|
}
|
|
2966
3041
|
export type queueOptions = QueueConfig;
|
|
2967
3042
|
export interface CacheConfig {
|