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
|
@@ -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;
|
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_eif00c = require('./picker.cjs');
|
|
2
|
+
exports.detectRuntime = _mod_eif00c.detectRuntime;
|
|
3
|
+
exports.getAdapterCapabilities = _mod_eif00c.getAdapterCapabilities;
|
|
4
|
+
exports.buildAdapterContext = _mod_eif00c.buildAdapterContext;
|
|
5
|
+
exports.getAvailableAdapters = _mod_eif00c.getAvailableAdapters;
|
|
6
|
+
exports.selectAdapter = _mod_eif00c.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_9e4qn8 = require('./lru-cache.cjs');
|
|
2
|
+
exports.LRUCache = _mod_9e4qn8.LRUCache;;
|
|
3
|
+
const _mod_gs3doh = require('./dns-cache.cjs');
|
|
4
|
+
exports.DNSCache = _mod_gs3doh.DNSCache;
|
|
5
|
+
exports.getGlobalDNSCache = _mod_gs3doh.getGlobalDNSCache;
|
|
6
|
+
exports.resetGlobalDNSCache = _mod_gs3doh.resetGlobalDNSCache;;
|
|
7
|
+
const _mod_9ffg9j = require('./response-cache.cjs');
|
|
8
|
+
exports.ResponseCache = _mod_9ffg9j.ResponseCache;
|
|
9
|
+
exports.normalizeResponseCacheConfig = _mod_9ffg9j.normalizeResponseCacheConfig;;
|
|
10
|
+
const _mod_4dvgnu = require('./file-cacher.cjs');
|
|
11
|
+
exports.FileCacher = _mod_4dvgnu.FileCacher;;
|
|
12
|
+
const _mod_avqpi9 = require('./url-store.cjs');
|
|
13
|
+
exports.UrlStore = _mod_avqpi9.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_wpalft = require('../plugin/crawler.cjs');
|
|
2
|
+
exports.Crawler = _mod_wpalft.Crawler;;
|
|
3
|
+
const _mod_0yhulz = require('../plugin/crawler-options.cjs');
|
|
4
|
+
exports.CrawlerOptions = _mod_0yhulz.CrawlerOptions;
|
|
5
|
+
exports.Domain = _mod_0yhulz.Domain;;
|
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
exports.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
1
|
+
const _mod_8dr47b = require('./core/rezo.cjs');
|
|
2
|
+
exports.Rezo = _mod_8dr47b.Rezo;
|
|
3
|
+
exports.createRezoInstance = _mod_8dr47b.createRezoInstance;
|
|
4
|
+
exports.createDefaultInstance = _mod_8dr47b.createDefaultInstance;;
|
|
5
|
+
const _mod_z7hw1b = require('./errors/rezo-error.cjs');
|
|
6
|
+
exports.RezoError = _mod_z7hw1b.RezoError;
|
|
7
|
+
exports.RezoErrorCode = _mod_z7hw1b.RezoErrorCode;;
|
|
8
|
+
const _mod_3vh4fg = require('./utils/headers.cjs');
|
|
9
|
+
exports.RezoHeaders = _mod_3vh4fg.RezoHeaders;;
|
|
10
|
+
const _mod_ad6idl = require('./utils/form-data.cjs');
|
|
11
|
+
exports.RezoFormData = _mod_ad6idl.RezoFormData;;
|
|
12
|
+
const _mod_8x9fab = require('./utils/cookies.cjs');
|
|
13
|
+
exports.RezoCookieJar = _mod_8x9fab.RezoCookieJar;
|
|
14
|
+
exports.Cookie = _mod_8x9fab.Cookie;;
|
|
15
|
+
const _mod_ii7ay0 = require('./core/hooks.cjs');
|
|
16
|
+
exports.createDefaultHooks = _mod_ii7ay0.createDefaultHooks;
|
|
17
|
+
exports.mergeHooks = _mod_ii7ay0.mergeHooks;;
|
|
18
|
+
const _mod_tcxc6y = require('./proxy/manager.cjs');
|
|
19
|
+
exports.ProxyManager = _mod_tcxc6y.ProxyManager;;
|
|
20
|
+
const _mod_zco8m1 = require('./queue/index.cjs');
|
|
21
|
+
exports.RezoQueue = _mod_zco8m1.RezoQueue;
|
|
22
|
+
exports.HttpQueue = _mod_zco8m1.HttpQueue;
|
|
23
|
+
exports.Priority = _mod_zco8m1.Priority;
|
|
24
|
+
exports.HttpMethodPriority = _mod_zco8m1.HttpMethodPriority;;
|
|
24
25
|
const { RezoError } = require('./errors/rezo-error.cjs');
|
|
25
26
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
26
27
|
const Cancel = exports.Cancel = RezoError;
|