rezo 1.0.6 → 1.0.8
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.cjs +2 -1
- package/dist/adapters/entries/curl.d.ts +76 -1
- package/dist/adapters/entries/curl.js +2 -2
- package/dist/adapters/entries/fetch.cjs +2 -1
- package/dist/adapters/entries/fetch.d.ts +76 -1
- package/dist/adapters/entries/fetch.js +2 -2
- package/dist/adapters/entries/http.cjs +2 -1
- package/dist/adapters/entries/http.d.ts +76 -1
- package/dist/adapters/entries/http.js +2 -1
- package/dist/adapters/entries/http2.cjs +2 -1
- package/dist/adapters/entries/http2.d.ts +76 -1
- package/dist/adapters/entries/http2.js +2 -2
- package/dist/adapters/entries/react-native.cjs +2 -1
- package/dist/adapters/entries/react-native.d.ts +76 -1
- package/dist/adapters/entries/react-native.js +2 -2
- package/dist/adapters/entries/xhr.cjs +2 -1
- package/dist/adapters/entries/xhr.d.ts +76 -1
- package/dist/adapters/entries/xhr.js +2 -2
- 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 +24 -23
- package/dist/index.d.ts +76 -1
- package/dist/index.js +1 -1
- package/dist/platform/browser.cjs +2 -1
- package/dist/platform/browser.d.ts +76 -1
- package/dist/platform/browser.js +2 -2
- package/dist/platform/bun.cjs +2 -1
- package/dist/platform/bun.d.ts +76 -1
- package/dist/platform/bun.js +2 -2
- package/dist/platform/deno.cjs +2 -1
- package/dist/platform/deno.d.ts +76 -1
- package/dist/platform/deno.js +2 -2
- package/dist/platform/node.cjs +2 -1
- package/dist/platform/node.d.ts +76 -1
- package/dist/platform/node.js +2 -2
- package/dist/platform/react-native.cjs +2 -1
- package/dist/platform/react-native.d.ts +76 -1
- package/dist/platform/react-native.js +2 -2
- package/dist/platform/worker.cjs +2 -1
- package/dist/platform/worker.d.ts +76 -1
- package/dist/platform/worker.js +2 -2
- 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/dist/utils/cookies.cjs +0 -2
- package/dist/utils/cookies.js +0 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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 {
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ export { RezoError };
|
|
|
12
12
|
export { RezoErrorCode };
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
|
-
export { RezoCookieJar };
|
|
15
|
+
export { RezoCookieJar, Cookie };
|
|
16
16
|
export { createDefaultHooks };
|
|
17
17
|
export { mergeHooks };
|
|
18
18
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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 {
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ export { RezoError };
|
|
|
12
12
|
export { RezoErrorCode };
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
|
-
export { RezoCookieJar };
|
|
15
|
+
export { RezoCookieJar, Cookie };
|
|
16
16
|
export { createDefaultHooks };
|
|
17
17
|
export { mergeHooks };
|
|
18
18
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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 {
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ export { RezoErrorCode };
|
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
15
|
export { RezoCookieJar };
|
|
16
|
+
export { Cookie };
|
|
16
17
|
export { createDefaultHooks };
|
|
17
18
|
export { mergeHooks };
|
|
18
19
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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 {
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ export { RezoError };
|
|
|
12
12
|
export { RezoErrorCode };
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
|
-
export { RezoCookieJar };
|
|
15
|
+
export { RezoCookieJar, Cookie };
|
|
16
16
|
export { createDefaultHooks };
|
|
17
17
|
export { mergeHooks };
|
|
18
18
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|