rezo 1.0.20 → 1.0.21

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.
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -1,6 +1,6 @@
1
- const _mod_dy07ge = require('./picker.cjs');
2
- exports.detectRuntime = _mod_dy07ge.detectRuntime;
3
- exports.getAdapterCapabilities = _mod_dy07ge.getAdapterCapabilities;
4
- exports.buildAdapterContext = _mod_dy07ge.buildAdapterContext;
5
- exports.getAvailableAdapters = _mod_dy07ge.getAvailableAdapters;
6
- exports.selectAdapter = _mod_dy07ge.selectAdapter;;
1
+ const _mod_cotolp = require('./picker.cjs');
2
+ exports.detectRuntime = _mod_cotolp.detectRuntime;
3
+ exports.getAdapterCapabilities = _mod_cotolp.getAdapterCapabilities;
4
+ exports.buildAdapterContext = _mod_cotolp.buildAdapterContext;
5
+ exports.getAvailableAdapters = _mod_cotolp.getAvailableAdapters;
6
+ exports.selectAdapter = _mod_cotolp.selectAdapter;;
@@ -1,13 +1,13 @@
1
- const _mod_pcungp = require('./lru-cache.cjs');
2
- exports.LRUCache = _mod_pcungp.LRUCache;;
3
- const _mod_6vuqjm = require('./dns-cache.cjs');
4
- exports.DNSCache = _mod_6vuqjm.DNSCache;
5
- exports.getGlobalDNSCache = _mod_6vuqjm.getGlobalDNSCache;
6
- exports.resetGlobalDNSCache = _mod_6vuqjm.resetGlobalDNSCache;;
7
- const _mod_cklgi1 = require('./response-cache.cjs');
8
- exports.ResponseCache = _mod_cklgi1.ResponseCache;
9
- exports.normalizeResponseCacheConfig = _mod_cklgi1.normalizeResponseCacheConfig;;
10
- const _mod_wlgf05 = require('./file-cacher.cjs');
11
- exports.FileCacher = _mod_wlgf05.FileCacher;;
12
- const _mod_ih62yw = require('./url-store.cjs');
13
- exports.UrlStore = _mod_ih62yw.UrlStore;;
1
+ const _mod_npvfdd = require('./lru-cache.cjs');
2
+ exports.LRUCache = _mod_npvfdd.LRUCache;;
3
+ const _mod_4em23l = require('./dns-cache.cjs');
4
+ exports.DNSCache = _mod_4em23l.DNSCache;
5
+ exports.getGlobalDNSCache = _mod_4em23l.getGlobalDNSCache;
6
+ exports.resetGlobalDNSCache = _mod_4em23l.resetGlobalDNSCache;;
7
+ const _mod_ij8xvl = require('./response-cache.cjs');
8
+ exports.ResponseCache = _mod_ij8xvl.ResponseCache;
9
+ exports.normalizeResponseCacheConfig = _mod_ij8xvl.normalizeResponseCacheConfig;;
10
+ const _mod_ox3maj = require('./file-cacher.cjs');
11
+ exports.FileCacher = _mod_ox3maj.FileCacher;;
12
+ const _mod_ihxikf = require('./url-store.cjs');
13
+ exports.UrlStore = _mod_ihxikf.UrlStore;;
package/dist/crawler.d.ts CHANGED
@@ -2177,7 +2177,6 @@ declare class RezoError<T = any> extends Error {
2177
2177
  readonly isSocksError: boolean;
2178
2178
  readonly isTlsError: boolean;
2179
2179
  readonly isRetryable: boolean;
2180
- readonly details: string;
2181
2180
  readonly suggestion: string;
2182
2181
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2183
2182
  static isRezoError(error: unknown): error is RezoError;
@@ -1,5 +1,5 @@
1
- const _mod_3tqnb0 = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_3tqnb0.Crawler;;
3
- const _mod_a15878 = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_a15878.CrawlerOptions;
5
- exports.Domain = _mod_a15878.Domain;;
1
+ const _mod_k28o05 = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_k28o05.Crawler;;
3
+ const _mod_qjgrqf = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_qjgrqf.CrawlerOptions;
5
+ exports.Domain = _mod_qjgrqf.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,13 +578,11 @@ 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, "details", { value: message, enumerable: false });
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
588
  Object.defineProperty(this, "status", { value: response.status, enumerable: false });
@@ -568,17 +600,71 @@ class RezoError extends Error {
568
600
  }
569
601
  }
570
602
  }
571
- [Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
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.details && this.details !== this.message) {
578
- parts.push(` details: ${this.details}`);
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 error = new RezoError(getHttpErrorMessage(statusCode), config, "REZ_HTTP_ERROR", request, response);
616
- Object.defineProperty(error, "status", { value: statusCode, enumerable: false });
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.details !== undefined)
674
- result.details = this.details;
675
- if (this.suggestion !== undefined)
676
- result.suggestion = this.suggestion;
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.errno)
702
- result += `Error Number: ${this.errno}
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;
@@ -424,6 +424,40 @@ export 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
+ export 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
  export function getCode(code) {
428
462
  const error = ERROR_INFO[code];
429
463
  if (error) {
@@ -544,13 +578,11 @@ export 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, "details", { value: message, enumerable: false });
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
588
  Object.defineProperty(this, "status", { value: response.status, enumerable: false });
@@ -568,17 +600,71 @@ export class RezoError extends Error {
568
600
  }
569
601
  }
570
602
  }
571
- [Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
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.details && this.details !== this.message) {
578
- parts.push(` details: ${this.details}`);
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 @@ export 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 error = new RezoError(getHttpErrorMessage(statusCode), config, "REZ_HTTP_ERROR", request, response);
616
- Object.defineProperty(error, "status", { value: statusCode, enumerable: false });
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 @@ export class RezoError extends Error {
670
768
  };
671
769
  if (this.code !== undefined)
672
770
  result.code = this.code;
673
- if (this.details !== undefined)
674
- result.details = this.details;
675
- if (this.suggestion !== undefined)
676
- result.suggestion = this.suggestion;
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,26 +793,39 @@ export 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.errno)
702
- result += `Error Number: ${this.errno}
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
  }
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- const _mod_duhs83 = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_duhs83.Rezo;
3
- exports.createRezoInstance = _mod_duhs83.createRezoInstance;
4
- exports.createDefaultInstance = _mod_duhs83.createDefaultInstance;;
5
- const _mod_8z3sz9 = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_8z3sz9.RezoError;
7
- exports.RezoErrorCode = _mod_8z3sz9.RezoErrorCode;;
8
- const _mod_o75xf9 = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_o75xf9.RezoHeaders;;
10
- const _mod_igc0kq = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_igc0kq.RezoFormData;;
12
- const _mod_kuocqq = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_kuocqq.RezoCookieJar;
14
- exports.Cookie = _mod_kuocqq.Cookie;;
15
- const _mod_k7ozxh = require('./core/hooks.cjs');
16
- exports.createDefaultHooks = _mod_k7ozxh.createDefaultHooks;
17
- exports.mergeHooks = _mod_k7ozxh.mergeHooks;;
18
- const _mod_5af6mv = require('./proxy/manager.cjs');
19
- exports.ProxyManager = _mod_5af6mv.ProxyManager;;
20
- const _mod_ahusy5 = require('./queue/index.cjs');
21
- exports.RezoQueue = _mod_ahusy5.RezoQueue;
22
- exports.HttpQueue = _mod_ahusy5.HttpQueue;
23
- exports.Priority = _mod_ahusy5.Priority;
24
- exports.HttpMethodPriority = _mod_ahusy5.HttpMethodPriority;;
1
+ const _mod_l63c18 = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_l63c18.Rezo;
3
+ exports.createRezoInstance = _mod_l63c18.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_l63c18.createDefaultInstance;;
5
+ const _mod_wb9vn2 = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_wb9vn2.RezoError;
7
+ exports.RezoErrorCode = _mod_wb9vn2.RezoErrorCode;;
8
+ const _mod_4bxq6e = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_4bxq6e.RezoHeaders;;
10
+ const _mod_gxwkvw = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_gxwkvw.RezoFormData;;
12
+ const _mod_iqdevw = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_iqdevw.RezoCookieJar;
14
+ exports.Cookie = _mod_iqdevw.Cookie;;
15
+ const _mod_aj2qcb = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_aj2qcb.createDefaultHooks;
17
+ exports.mergeHooks = _mod_aj2qcb.mergeHooks;;
18
+ const _mod_5nufcq = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_5nufcq.ProxyManager;;
20
+ const _mod_0sh353 = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_0sh353.RezoQueue;
22
+ exports.HttpQueue = _mod_0sh353.HttpQueue;
23
+ exports.Priority = _mod_0sh353.Priority;
24
+ exports.HttpMethodPriority = _mod_0sh353.HttpMethodPriority;;
25
25
  const { RezoError } = require('./errors/rezo-error.cjs');
26
26
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
27
27
  const Cancel = exports.Cancel = RezoError;
package/dist/index.d.ts CHANGED
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -2014,7 +2014,6 @@ export declare class RezoError<T = any> extends Error {
2014
2014
  readonly isSocksError: boolean;
2015
2015
  readonly isTlsError: boolean;
2016
2016
  readonly isRetryable: boolean;
2017
- readonly details: string;
2018
2017
  readonly suggestion: string;
2019
2018
  constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
2020
2019
  static isRezoError(error: unknown): error is RezoError;
@@ -1,36 +1,36 @@
1
- const _mod_2ijd3k = require('./crawler.cjs');
2
- exports.Crawler = _mod_2ijd3k.Crawler;;
3
- const _mod_gc69uh = require('./crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_gc69uh.CrawlerOptions;;
5
- const _mod_4wjcb5 = require('../cache/file-cacher.cjs');
6
- exports.FileCacher = _mod_4wjcb5.FileCacher;;
7
- const _mod_hoe0p4 = require('../cache/url-store.cjs');
8
- exports.UrlStore = _mod_hoe0p4.UrlStore;;
9
- const _mod_87dbqg = require('./addon/oxylabs/index.cjs');
10
- exports.Oxylabs = _mod_87dbqg.Oxylabs;;
11
- const _mod_0u3ysd = require('./addon/oxylabs/options.cjs');
12
- exports.OXYLABS_BROWSER_TYPES = _mod_0u3ysd.OXYLABS_BROWSER_TYPES;
13
- exports.OXYLABS_COMMON_LOCALES = _mod_0u3ysd.OXYLABS_COMMON_LOCALES;
14
- exports.OXYLABS_COMMON_GEO_LOCATIONS = _mod_0u3ysd.OXYLABS_COMMON_GEO_LOCATIONS;
15
- exports.OXYLABS_US_STATES = _mod_0u3ysd.OXYLABS_US_STATES;
16
- exports.OXYLABS_EUROPEAN_COUNTRIES = _mod_0u3ysd.OXYLABS_EUROPEAN_COUNTRIES;
17
- exports.OXYLABS_ASIAN_COUNTRIES = _mod_0u3ysd.OXYLABS_ASIAN_COUNTRIES;
18
- exports.getRandomOxylabsBrowserType = _mod_0u3ysd.getRandomBrowserType;
19
- exports.getRandomOxylabsLocale = _mod_0u3ysd.getRandomLocale;
20
- exports.getRandomOxylabsGeoLocation = _mod_0u3ysd.getRandomGeoLocation;;
21
- const _mod_qvvezh = require('./addon/decodo/index.cjs');
22
- exports.Decodo = _mod_qvvezh.Decodo;;
23
- const _mod_c8oa9x = require('./addon/decodo/options.cjs');
24
- exports.DECODO_DEVICE_TYPES = _mod_c8oa9x.DECODO_DEVICE_TYPES;
25
- exports.DECODO_HEADLESS_MODES = _mod_c8oa9x.DECODO_HEADLESS_MODES;
26
- exports.DECODO_COMMON_LOCALES = _mod_c8oa9x.DECODO_COMMON_LOCALES;
27
- exports.DECODO_COMMON_COUNTRIES = _mod_c8oa9x.DECODO_COMMON_COUNTRIES;
28
- exports.DECODO_EUROPEAN_COUNTRIES = _mod_c8oa9x.DECODO_EUROPEAN_COUNTRIES;
29
- exports.DECODO_ASIAN_COUNTRIES = _mod_c8oa9x.DECODO_ASIAN_COUNTRIES;
30
- exports.DECODO_US_STATES = _mod_c8oa9x.DECODO_US_STATES;
31
- exports.DECODO_COMMON_CITIES = _mod_c8oa9x.DECODO_COMMON_CITIES;
32
- exports.getRandomDecodoDeviceType = _mod_c8oa9x.getRandomDeviceType;
33
- exports.getRandomDecodoLocale = _mod_c8oa9x.getRandomLocale;
34
- exports.getRandomDecodoCountry = _mod_c8oa9x.getRandomCountry;
35
- exports.getRandomDecodoCity = _mod_c8oa9x.getRandomCity;
36
- exports.generateDecodoSessionId = _mod_c8oa9x.generateSessionId;;
1
+ const _mod_biedh3 = require('./crawler.cjs');
2
+ exports.Crawler = _mod_biedh3.Crawler;;
3
+ const _mod_t5bcfi = require('./crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_t5bcfi.CrawlerOptions;;
5
+ const _mod_fhs26e = require('../cache/file-cacher.cjs');
6
+ exports.FileCacher = _mod_fhs26e.FileCacher;;
7
+ const _mod_nqlyec = require('../cache/url-store.cjs');
8
+ exports.UrlStore = _mod_nqlyec.UrlStore;;
9
+ const _mod_4hdlkj = require('./addon/oxylabs/index.cjs');
10
+ exports.Oxylabs = _mod_4hdlkj.Oxylabs;;
11
+ const _mod_jpwlfi = require('./addon/oxylabs/options.cjs');
12
+ exports.OXYLABS_BROWSER_TYPES = _mod_jpwlfi.OXYLABS_BROWSER_TYPES;
13
+ exports.OXYLABS_COMMON_LOCALES = _mod_jpwlfi.OXYLABS_COMMON_LOCALES;
14
+ exports.OXYLABS_COMMON_GEO_LOCATIONS = _mod_jpwlfi.OXYLABS_COMMON_GEO_LOCATIONS;
15
+ exports.OXYLABS_US_STATES = _mod_jpwlfi.OXYLABS_US_STATES;
16
+ exports.OXYLABS_EUROPEAN_COUNTRIES = _mod_jpwlfi.OXYLABS_EUROPEAN_COUNTRIES;
17
+ exports.OXYLABS_ASIAN_COUNTRIES = _mod_jpwlfi.OXYLABS_ASIAN_COUNTRIES;
18
+ exports.getRandomOxylabsBrowserType = _mod_jpwlfi.getRandomBrowserType;
19
+ exports.getRandomOxylabsLocale = _mod_jpwlfi.getRandomLocale;
20
+ exports.getRandomOxylabsGeoLocation = _mod_jpwlfi.getRandomGeoLocation;;
21
+ const _mod_0sldke = require('./addon/decodo/index.cjs');
22
+ exports.Decodo = _mod_0sldke.Decodo;;
23
+ const _mod_sb934b = require('./addon/decodo/options.cjs');
24
+ exports.DECODO_DEVICE_TYPES = _mod_sb934b.DECODO_DEVICE_TYPES;
25
+ exports.DECODO_HEADLESS_MODES = _mod_sb934b.DECODO_HEADLESS_MODES;
26
+ exports.DECODO_COMMON_LOCALES = _mod_sb934b.DECODO_COMMON_LOCALES;
27
+ exports.DECODO_COMMON_COUNTRIES = _mod_sb934b.DECODO_COMMON_COUNTRIES;
28
+ exports.DECODO_EUROPEAN_COUNTRIES = _mod_sb934b.DECODO_EUROPEAN_COUNTRIES;
29
+ exports.DECODO_ASIAN_COUNTRIES = _mod_sb934b.DECODO_ASIAN_COUNTRIES;
30
+ exports.DECODO_US_STATES = _mod_sb934b.DECODO_US_STATES;
31
+ exports.DECODO_COMMON_CITIES = _mod_sb934b.DECODO_COMMON_CITIES;
32
+ exports.getRandomDecodoDeviceType = _mod_sb934b.getRandomDeviceType;
33
+ exports.getRandomDecodoLocale = _mod_sb934b.getRandomLocale;
34
+ exports.getRandomDecodoCountry = _mod_sb934b.getRandomCountry;
35
+ exports.getRandomDecodoCity = _mod_sb934b.getRandomCity;
36
+ exports.generateDecodoSessionId = _mod_sb934b.generateSessionId;;
@@ -1,8 +1,8 @@
1
1
  const { SocksProxyAgent: RezoSocksProxy } = require("socks-proxy-agent");
2
2
  const { HttpsProxyAgent: RezoHttpsSocks } = require("https-proxy-agent");
3
3
  const { HttpProxyAgent: RezoHttpSocks } = require("http-proxy-agent");
4
- const _mod_iw6rg6 = require('./manager.cjs');
5
- exports.ProxyManager = _mod_iw6rg6.ProxyManager;;
4
+ const _mod_vkj5br = require('./manager.cjs');
5
+ exports.ProxyManager = _mod_vkj5br.ProxyManager;;
6
6
  function createOptions(uri, opts) {
7
7
  if (uri instanceof URL || typeof uri === "string") {
8
8
  return {
@@ -1,8 +1,8 @@
1
- const _mod_sdr4pe = require('./queue.cjs');
2
- exports.RezoQueue = _mod_sdr4pe.RezoQueue;;
3
- const _mod_p0tjg8 = require('./http-queue.cjs');
4
- exports.HttpQueue = _mod_p0tjg8.HttpQueue;
5
- exports.extractDomain = _mod_p0tjg8.extractDomain;;
6
- const _mod_tfd6vx = require('./types.cjs');
7
- exports.Priority = _mod_tfd6vx.Priority;
8
- exports.HttpMethodPriority = _mod_tfd6vx.HttpMethodPriority;;
1
+ const _mod_bn1v0t = require('./queue.cjs');
2
+ exports.RezoQueue = _mod_bn1v0t.RezoQueue;;
3
+ const _mod_pkpo24 = require('./http-queue.cjs');
4
+ exports.HttpQueue = _mod_pkpo24.HttpQueue;
5
+ exports.extractDomain = _mod_pkpo24.extractDomain;;
6
+ const _mod_w6ii81 = require('./types.cjs');
7
+ exports.Priority = _mod_w6ii81.Priority;
8
+ exports.HttpMethodPriority = _mod_w6ii81.HttpMethodPriority;;
@@ -186,6 +186,7 @@ async function getDefaultConfig(config = {}, proxyManager) {
186
186
  httpAgent: config.httpAgent,
187
187
  httpsAgent: config.httpsAgent,
188
188
  debug: config.debug === true,
189
+ trackUrl: config.trackUrl === true,
189
190
  maxRedirects: config.maxRedirects,
190
191
  retry: config.retry,
191
192
  proxy: config.proxy,
@@ -186,6 +186,7 @@ export async function getDefaultConfig(config = {}, proxyManager) {
186
186
  httpAgent: config.httpAgent,
187
187
  httpsAgent: config.httpsAgent,
188
188
  debug: config.debug === true,
189
+ trackUrl: config.trackUrl === true,
189
190
  maxRedirects: config.maxRedirects,
190
191
  retry: config.retry,
191
192
  proxy: config.proxy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rezo",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Lightning-fast, enterprise-grade HTTP client for modern JavaScript. Full HTTP/2 support, intelligent cookie management, multiple adapters (HTTP, Fetch, cURL, XHR), streaming, proxy support (HTTP/HTTPS/SOCKS), and cross-environment compatibility.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",