rezo 1.0.20 → 1.0.22
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 +9 -1
- package/dist/adapters/entries/fetch.d.ts +9 -1
- package/dist/adapters/entries/http.d.ts +9 -1
- package/dist/adapters/entries/http2.d.ts +9 -1
- package/dist/adapters/entries/react-native.d.ts +9 -1
- package/dist/adapters/entries/xhr.d.ts +9 -1
- package/dist/adapters/fetch.cjs +2 -1
- package/dist/adapters/fetch.js +2 -1
- package/dist/adapters/http.cjs +2 -1
- package/dist/adapters/http.js +2 -1
- package/dist/adapters/http2.cjs +2 -1
- package/dist/adapters/http2.js +2 -1
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/crawler.d.ts +9 -1
- package/dist/entries/crawler.cjs +5 -5
- package/dist/errors/rezo-error.cjs +141 -23
- package/dist/errors/rezo-error.js +140 -23
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +9 -1
- package/dist/platform/browser.d.ts +9 -1
- package/dist/platform/bun.d.ts +9 -1
- package/dist/platform/deno.d.ts +9 -1
- package/dist/platform/node.d.ts +9 -1
- package/dist/platform/react-native.d.ts +9 -1
- package/dist/platform/worker.d.ts +9 -1
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/queue/index.cjs +8 -8
- package/dist/utils/http-config.cjs +4 -0
- package/dist/utils/http-config.js +4 -0
- package/package.json +1 -1
|
@@ -1934,6 +1934,8 @@ export interface RezoConfig {
|
|
|
1934
1934
|
* ```
|
|
1935
1935
|
*/
|
|
1936
1936
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
|
+
/** Alias for beforeRedirect */
|
|
1938
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
1939
|
/** Character encoding for request body and response data */
|
|
1938
1940
|
encoding?: BufferEncoding;
|
|
1939
1941
|
/**
|
|
@@ -2014,7 +2016,6 @@ export declare class RezoError<T = any> extends Error {
|
|
|
2014
2016
|
readonly isSocksError: boolean;
|
|
2015
2017
|
readonly isTlsError: boolean;
|
|
2016
2018
|
readonly isRetryable: boolean;
|
|
2017
|
-
readonly details: string;
|
|
2018
2019
|
readonly suggestion: string;
|
|
2019
2020
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2020
2021
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2685,6 +2686,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2685
2686
|
* ```
|
|
2686
2687
|
*/
|
|
2687
2688
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2689
|
+
/**
|
|
2690
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2691
|
+
* @see beforeRedirect
|
|
2692
|
+
*/
|
|
2693
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2688
2694
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2689
2695
|
withCredentials?: boolean;
|
|
2690
2696
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3234,6 +3240,8 @@ export interface RezoDefaultOptions {
|
|
|
3234
3240
|
* ```
|
|
3235
3241
|
*/
|
|
3236
3242
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3243
|
+
/** Alias for beforeRedirect */
|
|
3244
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3237
3245
|
/** Array of functions to transform request data */
|
|
3238
3246
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3239
3247
|
/** Array of functions to transform response data */
|
|
@@ -1934,6 +1934,8 @@ export interface RezoConfig {
|
|
|
1934
1934
|
* ```
|
|
1935
1935
|
*/
|
|
1936
1936
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
|
+
/** Alias for beforeRedirect */
|
|
1938
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
1939
|
/** Character encoding for request body and response data */
|
|
1938
1940
|
encoding?: BufferEncoding;
|
|
1939
1941
|
/**
|
|
@@ -2014,7 +2016,6 @@ export declare class RezoError<T = any> extends Error {
|
|
|
2014
2016
|
readonly isSocksError: boolean;
|
|
2015
2017
|
readonly isTlsError: boolean;
|
|
2016
2018
|
readonly isRetryable: boolean;
|
|
2017
|
-
readonly details: string;
|
|
2018
2019
|
readonly suggestion: string;
|
|
2019
2020
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2020
2021
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2685,6 +2686,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2685
2686
|
* ```
|
|
2686
2687
|
*/
|
|
2687
2688
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2689
|
+
/**
|
|
2690
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2691
|
+
* @see beforeRedirect
|
|
2692
|
+
*/
|
|
2693
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2688
2694
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2689
2695
|
withCredentials?: boolean;
|
|
2690
2696
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3234,6 +3240,8 @@ export interface RezoDefaultOptions {
|
|
|
3234
3240
|
* ```
|
|
3235
3241
|
*/
|
|
3236
3242
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3243
|
+
/** Alias for beforeRedirect */
|
|
3244
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3237
3245
|
/** Array of functions to transform request data */
|
|
3238
3246
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3239
3247
|
/** Array of functions to transform response data */
|
|
@@ -1934,6 +1934,8 @@ export interface RezoConfig {
|
|
|
1934
1934
|
* ```
|
|
1935
1935
|
*/
|
|
1936
1936
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
|
+
/** Alias for beforeRedirect */
|
|
1938
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
1939
|
/** Character encoding for request body and response data */
|
|
1938
1940
|
encoding?: BufferEncoding;
|
|
1939
1941
|
/**
|
|
@@ -2014,7 +2016,6 @@ export declare class RezoError<T = any> extends Error {
|
|
|
2014
2016
|
readonly isSocksError: boolean;
|
|
2015
2017
|
readonly isTlsError: boolean;
|
|
2016
2018
|
readonly isRetryable: boolean;
|
|
2017
|
-
readonly details: string;
|
|
2018
2019
|
readonly suggestion: string;
|
|
2019
2020
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2020
2021
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2685,6 +2686,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2685
2686
|
* ```
|
|
2686
2687
|
*/
|
|
2687
2688
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2689
|
+
/**
|
|
2690
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2691
|
+
* @see beforeRedirect
|
|
2692
|
+
*/
|
|
2693
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2688
2694
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2689
2695
|
withCredentials?: boolean;
|
|
2690
2696
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3234,6 +3240,8 @@ export interface RezoDefaultOptions {
|
|
|
3234
3240
|
* ```
|
|
3235
3241
|
*/
|
|
3236
3242
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3243
|
+
/** Alias for beforeRedirect */
|
|
3244
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3237
3245
|
/** Array of functions to transform request data */
|
|
3238
3246
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3239
3247
|
/** Array of functions to transform response data */
|
|
@@ -1934,6 +1934,8 @@ export interface RezoConfig {
|
|
|
1934
1934
|
* ```
|
|
1935
1935
|
*/
|
|
1936
1936
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
|
+
/** Alias for beforeRedirect */
|
|
1938
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
1939
|
/** Character encoding for request body and response data */
|
|
1938
1940
|
encoding?: BufferEncoding;
|
|
1939
1941
|
/**
|
|
@@ -2014,7 +2016,6 @@ export declare class RezoError<T = any> extends Error {
|
|
|
2014
2016
|
readonly isSocksError: boolean;
|
|
2015
2017
|
readonly isTlsError: boolean;
|
|
2016
2018
|
readonly isRetryable: boolean;
|
|
2017
|
-
readonly details: string;
|
|
2018
2019
|
readonly suggestion: string;
|
|
2019
2020
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2020
2021
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2685,6 +2686,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2685
2686
|
* ```
|
|
2686
2687
|
*/
|
|
2687
2688
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2689
|
+
/**
|
|
2690
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2691
|
+
* @see beforeRedirect
|
|
2692
|
+
*/
|
|
2693
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2688
2694
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2689
2695
|
withCredentials?: boolean;
|
|
2690
2696
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3234,6 +3240,8 @@ export interface RezoDefaultOptions {
|
|
|
3234
3240
|
* ```
|
|
3235
3241
|
*/
|
|
3236
3242
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3243
|
+
/** Alias for beforeRedirect */
|
|
3244
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3237
3245
|
/** Array of functions to transform request data */
|
|
3238
3246
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3239
3247
|
/** Array of functions to transform response data */
|
|
@@ -1934,6 +1934,8 @@ export interface RezoConfig {
|
|
|
1934
1934
|
* ```
|
|
1935
1935
|
*/
|
|
1936
1936
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
|
+
/** Alias for beforeRedirect */
|
|
1938
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
1939
|
/** Character encoding for request body and response data */
|
|
1938
1940
|
encoding?: BufferEncoding;
|
|
1939
1941
|
/**
|
|
@@ -2014,7 +2016,6 @@ export declare class RezoError<T = any> extends Error {
|
|
|
2014
2016
|
readonly isSocksError: boolean;
|
|
2015
2017
|
readonly isTlsError: boolean;
|
|
2016
2018
|
readonly isRetryable: boolean;
|
|
2017
|
-
readonly details: string;
|
|
2018
2019
|
readonly suggestion: string;
|
|
2019
2020
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2020
2021
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2685,6 +2686,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2685
2686
|
* ```
|
|
2686
2687
|
*/
|
|
2687
2688
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2689
|
+
/**
|
|
2690
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2691
|
+
* @see beforeRedirect
|
|
2692
|
+
*/
|
|
2693
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2688
2694
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2689
2695
|
withCredentials?: boolean;
|
|
2690
2696
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3234,6 +3240,8 @@ export interface RezoDefaultOptions {
|
|
|
3234
3240
|
* ```
|
|
3235
3241
|
*/
|
|
3236
3242
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3243
|
+
/** Alias for beforeRedirect */
|
|
3244
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3237
3245
|
/** Array of functions to transform request data */
|
|
3238
3246
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3239
3247
|
/** Array of functions to transform response data */
|
|
@@ -1934,6 +1934,8 @@ export interface RezoConfig {
|
|
|
1934
1934
|
* ```
|
|
1935
1935
|
*/
|
|
1936
1936
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
|
+
/** Alias for beforeRedirect */
|
|
1938
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1937
1939
|
/** Character encoding for request body and response data */
|
|
1938
1940
|
encoding?: BufferEncoding;
|
|
1939
1941
|
/**
|
|
@@ -2014,7 +2016,6 @@ export declare class RezoError<T = any> extends Error {
|
|
|
2014
2016
|
readonly isSocksError: boolean;
|
|
2015
2017
|
readonly isTlsError: boolean;
|
|
2016
2018
|
readonly isRetryable: boolean;
|
|
2017
|
-
readonly details: string;
|
|
2018
2019
|
readonly suggestion: string;
|
|
2019
2020
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2020
2021
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2685,6 +2686,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2685
2686
|
* ```
|
|
2686
2687
|
*/
|
|
2687
2688
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2689
|
+
/**
|
|
2690
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2691
|
+
* @see beforeRedirect
|
|
2692
|
+
*/
|
|
2693
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2688
2694
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2689
2695
|
withCredentials?: boolean;
|
|
2690
2696
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3234,6 +3240,8 @@ export interface RezoDefaultOptions {
|
|
|
3234
3240
|
* ```
|
|
3235
3241
|
*/
|
|
3236
3242
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3243
|
+
/** Alias for beforeRedirect */
|
|
3244
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3237
3245
|
/** Array of functions to transform request data */
|
|
3238
3246
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3239
3247
|
/** Array of functions to transform response data */
|
package/dist/adapters/fetch.cjs
CHANGED
|
@@ -435,7 +435,8 @@ async function executeFetchRequest(fetchOptions, config, options, perform, strea
|
|
|
435
435
|
visitedUrls.add(normalizedRedirectUrl);
|
|
436
436
|
}
|
|
437
437
|
const redirectCode = response.status;
|
|
438
|
-
const
|
|
438
|
+
const redirectCallback = config.beforeRedirect || config.onRedirect;
|
|
439
|
+
const onRedirect = redirectCallback ? redirectCallback({
|
|
439
440
|
url: new URL(location),
|
|
440
441
|
status: response.status,
|
|
441
442
|
headers: response.headers,
|
package/dist/adapters/fetch.js
CHANGED
|
@@ -435,7 +435,8 @@ async function executeFetchRequest(fetchOptions, config, options, perform, strea
|
|
|
435
435
|
visitedUrls.add(normalizedRedirectUrl);
|
|
436
436
|
}
|
|
437
437
|
const redirectCode = response.status;
|
|
438
|
-
const
|
|
438
|
+
const redirectCallback = config.beforeRedirect || config.onRedirect;
|
|
439
|
+
const onRedirect = redirectCallback ? redirectCallback({
|
|
439
440
|
url: new URL(location),
|
|
440
441
|
status: response.status,
|
|
441
442
|
headers: response.headers,
|
package/dist/adapters/http.cjs
CHANGED
|
@@ -427,7 +427,8 @@ async function executeHttp1Request(fetchOptions, config, options, perform, fs, s
|
|
|
427
427
|
}
|
|
428
428
|
const redirectCode = response.status;
|
|
429
429
|
const customHeaders = undefined;
|
|
430
|
-
const
|
|
430
|
+
const redirectCallback = config.beforeRedirect || config.onRedirect;
|
|
431
|
+
const onRedirect = redirectCallback ? redirectCallback({
|
|
431
432
|
url: new URL(_stats.redirectUrl),
|
|
432
433
|
status: response.status,
|
|
433
434
|
headers: response.headers,
|
package/dist/adapters/http.js
CHANGED
|
@@ -427,7 +427,8 @@ async function executeHttp1Request(fetchOptions, config, options, perform, fs, s
|
|
|
427
427
|
}
|
|
428
428
|
const redirectCode = response.status;
|
|
429
429
|
const customHeaders = undefined;
|
|
430
|
-
const
|
|
430
|
+
const redirectCallback = config.beforeRedirect || config.onRedirect;
|
|
431
|
+
const onRedirect = redirectCallback ? redirectCallback({
|
|
431
432
|
url: new URL(_stats.redirectUrl),
|
|
432
433
|
status: response.status,
|
|
433
434
|
headers: response.headers,
|
package/dist/adapters/http2.cjs
CHANGED
|
@@ -626,7 +626,8 @@ async function executeHttp2Request(fetchOptions, config, options, perform, fs, s
|
|
|
626
626
|
visitedUrls.add(normalizedRedirectUrl);
|
|
627
627
|
}
|
|
628
628
|
const redirectCode = response.status;
|
|
629
|
-
const
|
|
629
|
+
const redirectCallback = config.beforeRedirect || config.onRedirect;
|
|
630
|
+
const onRedirect = redirectCallback ? redirectCallback({
|
|
630
631
|
url: new URL(location),
|
|
631
632
|
status: response.status,
|
|
632
633
|
headers: response.headers,
|
package/dist/adapters/http2.js
CHANGED
|
@@ -626,7 +626,8 @@ async function executeHttp2Request(fetchOptions, config, options, perform, fs, s
|
|
|
626
626
|
visitedUrls.add(normalizedRedirectUrl);
|
|
627
627
|
}
|
|
628
628
|
const redirectCode = response.status;
|
|
629
|
-
const
|
|
629
|
+
const redirectCallback = config.beforeRedirect || config.onRedirect;
|
|
630
|
+
const onRedirect = redirectCallback ? redirectCallback({
|
|
630
631
|
url: new URL(location),
|
|
631
632
|
status: response.status,
|
|
632
633
|
headers: response.headers,
|
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_bvuup4 = require('./picker.cjs');
|
|
2
|
+
exports.detectRuntime = _mod_bvuup4.detectRuntime;
|
|
3
|
+
exports.getAdapterCapabilities = _mod_bvuup4.getAdapterCapabilities;
|
|
4
|
+
exports.buildAdapterContext = _mod_bvuup4.buildAdapterContext;
|
|
5
|
+
exports.getAvailableAdapters = _mod_bvuup4.getAvailableAdapters;
|
|
6
|
+
exports.selectAdapter = _mod_bvuup4.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_sqwaw0 = require('./lru-cache.cjs');
|
|
2
|
+
exports.LRUCache = _mod_sqwaw0.LRUCache;;
|
|
3
|
+
const _mod_wv7mbf = require('./dns-cache.cjs');
|
|
4
|
+
exports.DNSCache = _mod_wv7mbf.DNSCache;
|
|
5
|
+
exports.getGlobalDNSCache = _mod_wv7mbf.getGlobalDNSCache;
|
|
6
|
+
exports.resetGlobalDNSCache = _mod_wv7mbf.resetGlobalDNSCache;;
|
|
7
|
+
const _mod_v9gfkh = require('./response-cache.cjs');
|
|
8
|
+
exports.ResponseCache = _mod_v9gfkh.ResponseCache;
|
|
9
|
+
exports.normalizeResponseCacheConfig = _mod_v9gfkh.normalizeResponseCacheConfig;;
|
|
10
|
+
const _mod_17mnwt = require('./file-cacher.cjs');
|
|
11
|
+
exports.FileCacher = _mod_17mnwt.FileCacher;;
|
|
12
|
+
const _mod_qtim1g = require('./url-store.cjs');
|
|
13
|
+
exports.UrlStore = _mod_qtim1g.UrlStore;;
|
package/dist/crawler.d.ts
CHANGED
|
@@ -2148,6 +2148,8 @@ export interface RezoConfig {
|
|
|
2148
2148
|
* ```
|
|
2149
2149
|
*/
|
|
2150
2150
|
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
2151
|
+
/** Alias for beforeRedirect */
|
|
2152
|
+
onRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
2151
2153
|
/** Character encoding for request body and response data */
|
|
2152
2154
|
encoding?: BufferEncoding;
|
|
2153
2155
|
/**
|
|
@@ -2177,7 +2179,6 @@ declare class RezoError<T = any> extends Error {
|
|
|
2177
2179
|
readonly isSocksError: boolean;
|
|
2178
2180
|
readonly isTlsError: boolean;
|
|
2179
2181
|
readonly isRetryable: boolean;
|
|
2180
|
-
readonly details: string;
|
|
2181
2182
|
readonly suggestion: string;
|
|
2182
2183
|
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
2183
2184
|
static isRezoError(error: unknown): error is RezoError;
|
|
@@ -2803,6 +2804,11 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2803
2804
|
* ```
|
|
2804
2805
|
*/
|
|
2805
2806
|
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2807
|
+
/**
|
|
2808
|
+
* Alias for beforeRedirect - callback invoked when a redirect response is received.
|
|
2809
|
+
* @see beforeRedirect
|
|
2810
|
+
*/
|
|
2811
|
+
onRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2806
2812
|
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2807
2813
|
withCredentials?: boolean;
|
|
2808
2814
|
/** Proxy configuration (URL string or detailed options) */
|
|
@@ -3352,6 +3358,8 @@ export interface RezoDefaultOptions {
|
|
|
3352
3358
|
* ```
|
|
3353
3359
|
*/
|
|
3354
3360
|
beforeRedirect?: RezoHttpRequest["beforeRedirect"];
|
|
3361
|
+
/** Alias for beforeRedirect */
|
|
3362
|
+
onRedirect?: RezoHttpRequest["onRedirect"];
|
|
3355
3363
|
/** Array of functions to transform request data */
|
|
3356
3364
|
transformRequest?: RezoHttpRequest["transformRequest"];
|
|
3357
3365
|
/** Array of functions to transform response data */
|
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_svsktw = require('../plugin/crawler.cjs');
|
|
2
|
+
exports.Crawler = _mod_svsktw.Crawler;;
|
|
3
|
+
const _mod_hcjbxq = require('../plugin/crawler-options.cjs');
|
|
4
|
+
exports.CrawlerOptions = _mod_hcjbxq.CrawlerOptions;
|
|
5
|
+
exports.Domain = _mod_hcjbxq.Domain;;
|
|
@@ -424,6 +424,40 @@ function getHttpErrorMessage(statusCode) {
|
|
|
424
424
|
};
|
|
425
425
|
return statusMessages[statusCode] || `HTTP Error ${statusCode}: The server responded with a non-successful status code.`;
|
|
426
426
|
}
|
|
427
|
+
function getHttpStatusText(statusCode) {
|
|
428
|
+
const statusTexts = {
|
|
429
|
+
200: "OK",
|
|
430
|
+
201: "Created",
|
|
431
|
+
202: "Accepted",
|
|
432
|
+
204: "No Content",
|
|
433
|
+
301: "Moved Permanently",
|
|
434
|
+
302: "Found",
|
|
435
|
+
303: "See Other",
|
|
436
|
+
304: "Not Modified",
|
|
437
|
+
307: "Temporary Redirect",
|
|
438
|
+
308: "Permanent Redirect",
|
|
439
|
+
400: "Bad Request",
|
|
440
|
+
401: "Unauthorized",
|
|
441
|
+
403: "Forbidden",
|
|
442
|
+
404: "Not Found",
|
|
443
|
+
405: "Method Not Allowed",
|
|
444
|
+
408: "Request Timeout",
|
|
445
|
+
409: "Conflict",
|
|
446
|
+
410: "Gone",
|
|
447
|
+
413: "Payload Too Large",
|
|
448
|
+
414: "URI Too Long",
|
|
449
|
+
415: "Unsupported Media Type",
|
|
450
|
+
422: "Unprocessable Entity",
|
|
451
|
+
429: "Too Many Requests",
|
|
452
|
+
500: "Internal Server Error",
|
|
453
|
+
501: "Not Implemented",
|
|
454
|
+
502: "Bad Gateway",
|
|
455
|
+
503: "Service Unavailable",
|
|
456
|
+
504: "Gateway Timeout",
|
|
457
|
+
505: "HTTP Version Not Supported"
|
|
458
|
+
};
|
|
459
|
+
return statusTexts[statusCode] || "Unknown Status";
|
|
460
|
+
}
|
|
427
461
|
function getCode(code) {
|
|
428
462
|
const error = ERROR_INFO[code];
|
|
429
463
|
if (error) {
|
|
@@ -544,17 +578,15 @@ class RezoError extends Error {
|
|
|
544
578
|
if (code) {
|
|
545
579
|
const errorInfo = getCode(code);
|
|
546
580
|
Object.defineProperty(this, "errno", { value: errorInfo.errno, enumerable: false });
|
|
547
|
-
Object.defineProperty(this, "details", { value: errorInfo.details, enumerable: false });
|
|
548
581
|
Object.defineProperty(this, "suggestion", { value: errorInfo.suggestion, enumerable: false });
|
|
549
582
|
this.message = errorInfo.message;
|
|
550
583
|
} else {
|
|
551
584
|
this.message = message;
|
|
552
|
-
Object.defineProperty(this, "
|
|
553
|
-
Object.defineProperty(this, "suggestion", { value: "Check the error details for more information.", enumerable: false });
|
|
585
|
+
Object.defineProperty(this, "suggestion", { value: "Check the error for more information.", enumerable: false });
|
|
554
586
|
}
|
|
555
587
|
if (response) {
|
|
556
|
-
Object.defineProperty(this, "status", { value: response.status, enumerable: false });
|
|
557
|
-
Object.defineProperty(this, "statusText", { value: response.statusText, enumerable: false });
|
|
588
|
+
Object.defineProperty(this, "status", { value: response.status, enumerable: false, configurable: true });
|
|
589
|
+
Object.defineProperty(this, "statusText", { value: response.statusText, enumerable: false, configurable: true });
|
|
558
590
|
}
|
|
559
591
|
this.name = this.constructor.name;
|
|
560
592
|
Object.setPrototypeOf(this, RezoError.prototype);
|
|
@@ -568,17 +600,71 @@ class RezoError extends Error {
|
|
|
568
600
|
}
|
|
569
601
|
}
|
|
570
602
|
}
|
|
571
|
-
[Symbol.for("nodejs.util.inspect.custom")](_depth,
|
|
603
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, options) {
|
|
572
604
|
const parts = [];
|
|
605
|
+
const isDebug = this.config?.debug === true;
|
|
606
|
+
const inspect = options?.stylize ? (v) => require("util").inspect(v, { depth: 3, colors: true }) : JSON.stringify;
|
|
573
607
|
parts.push(`${this.name}: ${this.message}`);
|
|
574
|
-
if (this.code)
|
|
608
|
+
if (this.code)
|
|
575
609
|
parts.push(` code: '${this.code}'`);
|
|
610
|
+
if (this.method)
|
|
611
|
+
parts.push(` method: '${this.method}'`);
|
|
612
|
+
if (this.url)
|
|
613
|
+
parts.push(` url: '${this.url}'`);
|
|
614
|
+
if (this.finalUrl && this.finalUrl !== this.url) {
|
|
615
|
+
parts.push(` finalUrl: '${this.finalUrl}'`);
|
|
576
616
|
}
|
|
577
|
-
if (this.
|
|
578
|
-
parts.push(`
|
|
617
|
+
if (this.status)
|
|
618
|
+
parts.push(` status: ${this.status}`);
|
|
619
|
+
if (this.statusText)
|
|
620
|
+
parts.push(` statusText: '${this.statusText}'`);
|
|
621
|
+
if (this.urls && this.urls.length > 1) {
|
|
622
|
+
parts.push(` urls: [${this.urls.map((u) => `'${u}'`).join(", ")}]`);
|
|
579
623
|
}
|
|
580
|
-
if (this.suggestion)
|
|
624
|
+
if (this.suggestion)
|
|
581
625
|
parts.push(` suggestion: ${this.suggestion}`);
|
|
626
|
+
if (isDebug) {
|
|
627
|
+
parts.push("");
|
|
628
|
+
parts.push(" --- Debug Info ---");
|
|
629
|
+
if (this.cause) {
|
|
630
|
+
const causeMsg = typeof this.cause === "string" ? this.cause : this.cause?.message || String(this.cause);
|
|
631
|
+
parts.push(` cause: ${causeMsg}`);
|
|
632
|
+
}
|
|
633
|
+
if (this.errno)
|
|
634
|
+
parts.push(` errno: ${this.errno}`);
|
|
635
|
+
if (this.hostname)
|
|
636
|
+
parts.push(` hostname: '${this.hostname}'`);
|
|
637
|
+
if (this.port)
|
|
638
|
+
parts.push(` port: ${this.port}`);
|
|
639
|
+
if (this.address)
|
|
640
|
+
parts.push(` address: '${this.address}'`);
|
|
641
|
+
if (this.syscall)
|
|
642
|
+
parts.push(` syscall: '${this.syscall}'`);
|
|
643
|
+
if (this.response) {
|
|
644
|
+
parts.push("");
|
|
645
|
+
parts.push(" --- Response ---");
|
|
646
|
+
parts.push(` response.status: ${this.response.status}`);
|
|
647
|
+
parts.push(` response.statusText: '${this.response.statusText || ""}'`);
|
|
648
|
+
parts.push(` response.finalUrl: '${this.response.finalUrl || ""}'`);
|
|
649
|
+
if (this.response.headers) {
|
|
650
|
+
parts.push(` response.headers: ${inspect(this.response.headers)}`);
|
|
651
|
+
}
|
|
652
|
+
if (this.response.data !== undefined) {
|
|
653
|
+
const dataStr = typeof this.response.data === "string" ? this.response.data.substring(0, 500) + (this.response.data.length > 500 ? "..." : "") : inspect(this.response.data);
|
|
654
|
+
parts.push(` response.data: ${dataStr}`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (this.response?.config) {
|
|
658
|
+
parts.push("");
|
|
659
|
+
parts.push(" --- Request Config ---");
|
|
660
|
+
const { cookieJar, ...configWithoutJar } = this.response.config;
|
|
661
|
+
parts.push(` config: ${inspect(configWithoutJar)}`);
|
|
662
|
+
}
|
|
663
|
+
if (this.stack) {
|
|
664
|
+
parts.push("");
|
|
665
|
+
parts.push(" --- Stack Trace ---");
|
|
666
|
+
parts.push(this.stack);
|
|
667
|
+
}
|
|
582
668
|
}
|
|
583
669
|
return parts.join(`
|
|
584
670
|
`);
|
|
@@ -612,8 +698,20 @@ class RezoError extends Error {
|
|
|
612
698
|
return new RezoError(message, config, code, request);
|
|
613
699
|
}
|
|
614
700
|
static createHttpError(statusCode, config, request, response) {
|
|
615
|
-
const
|
|
616
|
-
|
|
701
|
+
const method = (config.method || request?.method || "GET").toUpperCase();
|
|
702
|
+
const url = config.fullUrl || config.url || request?.url || "unknown";
|
|
703
|
+
const statusText = response?.statusText || getHttpStatusText(statusCode);
|
|
704
|
+
const finalUrl = response?.finalUrl || url;
|
|
705
|
+
const urls = response?.urls || [url];
|
|
706
|
+
const message = `Request failed with status code ${statusCode}`;
|
|
707
|
+
const error = new RezoError(message, config, "REZ_HTTP_ERROR", request, response);
|
|
708
|
+
error.message = message;
|
|
709
|
+
Object.defineProperty(error, "status", { value: statusCode, enumerable: true });
|
|
710
|
+
Object.defineProperty(error, "statusText", { value: statusText, enumerable: true });
|
|
711
|
+
Object.defineProperty(error, "method", { value: method, enumerable: true });
|
|
712
|
+
Object.defineProperty(error, "url", { value: url, enumerable: true });
|
|
713
|
+
Object.defineProperty(error, "finalUrl", { value: finalUrl, enumerable: true });
|
|
714
|
+
Object.defineProperty(error, "urls", { value: urls, enumerable: true });
|
|
617
715
|
return error;
|
|
618
716
|
}
|
|
619
717
|
static createTimeoutError(message, config, request) {
|
|
@@ -670,14 +768,20 @@ class RezoError extends Error {
|
|
|
670
768
|
};
|
|
671
769
|
if (this.code !== undefined)
|
|
672
770
|
result.code = this.code;
|
|
673
|
-
if (this.
|
|
674
|
-
result.
|
|
675
|
-
if (this.
|
|
676
|
-
result.
|
|
771
|
+
if (this.method !== undefined)
|
|
772
|
+
result.method = this.method;
|
|
773
|
+
if (this.url !== undefined)
|
|
774
|
+
result.url = this.url;
|
|
775
|
+
if (this.finalUrl !== undefined)
|
|
776
|
+
result.finalUrl = this.finalUrl;
|
|
677
777
|
if (this.status !== undefined)
|
|
678
778
|
result.status = this.status;
|
|
679
779
|
if (this.statusText !== undefined)
|
|
680
780
|
result.statusText = this.statusText;
|
|
781
|
+
if (this.urls !== undefined)
|
|
782
|
+
result.urls = this.urls;
|
|
783
|
+
if (this.cause)
|
|
784
|
+
result.cause = typeof this.cause === "string" ? this.cause : this.cause?.message || null;
|
|
681
785
|
return result;
|
|
682
786
|
}
|
|
683
787
|
toString() {
|
|
@@ -689,32 +793,46 @@ class RezoError extends Error {
|
|
|
689
793
|
}
|
|
690
794
|
getFullDetails() {
|
|
691
795
|
let result = `${this.name}: ${this.message}
|
|
692
|
-
`;
|
|
693
|
-
result += `
|
|
694
|
-
Details: ${this.details}
|
|
695
|
-
`;
|
|
696
|
-
result += `Suggestion: ${this.suggestion}
|
|
697
796
|
`;
|
|
698
797
|
if (this.code)
|
|
699
798
|
result += `Code: ${this.code}
|
|
700
799
|
`;
|
|
701
|
-
if (this.
|
|
702
|
-
result += `
|
|
800
|
+
if (this.method)
|
|
801
|
+
result += `Method: ${this.method}
|
|
802
|
+
`;
|
|
803
|
+
if (this.url)
|
|
804
|
+
result += `URL: ${this.url}
|
|
703
805
|
`;
|
|
806
|
+
if (this.finalUrl && this.finalUrl !== this.url) {
|
|
807
|
+
result += `Final URL: ${this.finalUrl}
|
|
808
|
+
`;
|
|
809
|
+
}
|
|
704
810
|
if (this.status)
|
|
705
811
|
result += `HTTP Status: ${this.status} ${this.statusText || ""}
|
|
812
|
+
`;
|
|
813
|
+
if (this.urls && this.urls.length > 1) {
|
|
814
|
+
result += `Redirect Chain: ${this.urls.join(" -> ")}
|
|
815
|
+
`;
|
|
816
|
+
}
|
|
817
|
+
if (this.errno)
|
|
818
|
+
result += `Error Number: ${this.errno}
|
|
706
819
|
`;
|
|
707
820
|
if (this.hostname)
|
|
708
821
|
result += `Host: ${this.hostname}
|
|
709
822
|
`;
|
|
710
823
|
if (this.port)
|
|
711
824
|
result += `Port: ${this.port}
|
|
825
|
+
`;
|
|
826
|
+
if (this.suggestion)
|
|
827
|
+
result += `
|
|
828
|
+
Suggestion: ${this.suggestion}
|
|
712
829
|
`;
|
|
713
830
|
return result;
|
|
714
831
|
}
|
|
715
832
|
}
|
|
716
833
|
|
|
717
834
|
exports.getHttpErrorMessage = getHttpErrorMessage;
|
|
835
|
+
exports.getHttpStatusText = getHttpStatusText;
|
|
718
836
|
exports.getCode = getCode;
|
|
719
837
|
exports.getErrorInfo = getErrorInfo;
|
|
720
838
|
exports.RezoError = RezoError;
|