rezo 1.0.136 → 1.0.138

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.
Files changed (50) hide show
  1. package/README.md +3 -3
  2. package/dist/adapters/entries/curl.d.ts +119 -82
  3. package/dist/adapters/entries/fetch.d.ts +119 -82
  4. package/dist/adapters/entries/http.d.ts +119 -82
  5. package/dist/adapters/entries/http2.d.ts +119 -82
  6. package/dist/adapters/entries/react-native.cjs +6 -6
  7. package/dist/adapters/entries/react-native.d.ts +119 -82
  8. package/dist/adapters/entries/xhr.d.ts +119 -82
  9. package/dist/adapters/http.cjs +26 -0
  10. package/dist/adapters/http.js +26 -0
  11. package/dist/adapters/index.cjs +10 -10
  12. package/dist/adapters/index.d.ts +52 -15
  13. package/dist/cache/index.cjs +9 -9
  14. package/dist/cookies/cookie-jar.cjs +154 -9
  15. package/dist/cookies/cookie-jar.js +150 -5
  16. package/dist/cookies/index.cjs +10 -10
  17. package/dist/crawler/index.cjs +42 -42
  18. package/dist/crawler/plugin/index.cjs +1 -1
  19. package/dist/crawler.d.ts +118 -81
  20. package/dist/entries/crawler.cjs +24 -24
  21. package/dist/errors/rezo-error.cjs +3 -2
  22. package/dist/errors/rezo-error.js +3 -2
  23. package/dist/index.cjs +58 -58
  24. package/dist/index.d.ts +119 -82
  25. package/dist/internal/agents/index.cjs +14 -14
  26. package/dist/platform/browser.d.ts +119 -82
  27. package/dist/platform/bun.d.ts +119 -82
  28. package/dist/platform/deno.d.ts +119 -82
  29. package/dist/platform/node.d.ts +119 -82
  30. package/dist/platform/react-native.cjs +6 -6
  31. package/dist/platform/react-native.d.ts +119 -82
  32. package/dist/platform/worker.d.ts +119 -82
  33. package/dist/proxy/index.cjs +4 -4
  34. package/dist/queue/index.cjs +8 -8
  35. package/dist/responses/universal/index.cjs +11 -11
  36. package/dist/stealth/index.cjs +17 -17
  37. package/dist/stealth/profiles/index.cjs +10 -10
  38. package/dist/utils/agent-pool.cjs +1 -1
  39. package/dist/utils/agent-pool.js +1 -1
  40. package/dist/utils/headers.cjs +3 -0
  41. package/dist/utils/headers.js +3 -0
  42. package/dist/utils/http-config.cjs +15 -2
  43. package/dist/utils/http-config.js +15 -2
  44. package/dist/utils/staged-timeout.cjs +1 -2
  45. package/dist/utils/staged-timeout.js +1 -2
  46. package/dist/version.cjs +1 -1
  47. package/dist/version.js +1 -1
  48. package/dist/wget/index.cjs +51 -51
  49. package/dist/wget/index.d.ts +118 -81
  50. package/package.json +1 -1
package/dist/crawler.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Agent as HttpAgent, OutgoingHttpHeaders } from 'node:http';
2
2
  import { Agent as HttpsAgent } from 'node:https';
3
3
  import { Socket } from 'node:net';
4
4
  import { SecureContext, TLSSocket } from 'node:tls';
5
- import { Cookie as TouchCookie, CookieJar as TouchCookieJar, CreateCookieJarOptions, CreateCookieOptions, Nullable, Store } from 'tough-cookie';
5
+ import { Callback, Cookie as TouchCookie, CookieJar as TouchCookieJar, CreateCookieJarOptions, CreateCookieOptions, GetCookiesOptions, Nullable, SerializedCookieJar, SetCookieOptions, Store } from 'tough-cookie';
6
6
 
7
7
  /**
8
8
  * CrawlerCache - High-performance SQLite-based response caching for web crawlers
@@ -367,6 +367,9 @@ declare class RezoHeaders extends Headers {
367
367
  * Used by stealth adapters to match browser header ordering.
368
368
  */
369
369
  toOrderedObject(order: string[]): Record<string, string | string[]>;
370
+ toJSON(): Record<string, string> & {
371
+ "set-cookie"?: string[];
372
+ };
370
373
  toObject(omit?: Array<keyof RezoHttpHeaders> | keyof RezoHttpHeaders): Record<string, string | string[]>;
371
374
  toString(): string;
372
375
  set(name: keyof RezoHttpHeaders, value: string): void;
@@ -444,6 +447,38 @@ declare class RezoCookieJar extends TouchCookieJar {
444
447
  constructor(cookies: Cookie[], url: string);
445
448
  constructor(store: Nullable<Store>, options?: CreateCookieJarOptions | boolean);
446
449
  private generateCookies;
450
+ setCookieSync(cookie: string | Cookie, url: string, options?: SetCookieOptions): Cookie | undefined;
451
+ setCookie(cookie: string | TouchCookie, url: string | URL, callback: Callback<TouchCookie | undefined>): void;
452
+ setCookie(cookie: string | TouchCookie, url: string | URL, options: SetCookieOptions, callback: Callback<TouchCookie | undefined>): void;
453
+ setCookie(cookie: string | TouchCookie, url: string | URL, options?: SetCookieOptions): Promise<TouchCookie | undefined>;
454
+ setCookie(cookie: string | TouchCookie, url: string | URL, options: SetCookieOptions | Callback<TouchCookie | undefined>, callback?: Callback<TouchCookie | undefined>): unknown;
455
+ getCookies(url: string, callback: Callback<TouchCookie[]>): void;
456
+ getCookies(url: string | URL, options: GetCookiesOptions | undefined, callback: Callback<TouchCookie[]>): void;
457
+ getCookies(url: string | URL, options?: GetCookiesOptions): Promise<TouchCookie[]>;
458
+ getCookies(url: string | URL, options: GetCookiesOptions | undefined | Callback<TouchCookie[]>, callback?: Callback<TouchCookie[]>): unknown;
459
+ getCookiesSync(url: string, options?: GetCookiesOptions): Cookie[];
460
+ getCookieString(url: string, callback: Callback<string | undefined>): void;
461
+ getCookieString(url: string, options: GetCookiesOptions, callback: Callback<string | undefined>): void;
462
+ getCookieString(url: string, options?: GetCookiesOptions): Promise<string>;
463
+ getCookieString(url: string, options: GetCookiesOptions | Callback<string | undefined>, callback?: Callback<string | undefined>): unknown;
464
+ getCookieStringSync(url: string, options?: GetCookiesOptions): string;
465
+ getSetCookieStrings(url: string, callback: Callback<string[] | undefined>): void;
466
+ getSetCookieStrings(url: string, options: GetCookiesOptions, callback: Callback<string[] | undefined>): void;
467
+ getSetCookieStrings(url: string, options?: GetCookiesOptions): Promise<string[] | undefined>;
468
+ getSetCookieStrings(url: string, options: GetCookiesOptions, callback?: Callback<string[] | undefined>): unknown;
469
+ getSetCookieStringsSync(url: string, options?: GetCookiesOptions): string[];
470
+ serialize(callback: Callback<SerializedCookieJar>): void;
471
+ serialize(): Promise<SerializedCookieJar>;
472
+ serializeSync(): SerializedCookieJar | undefined;
473
+ toJSON(): ReturnType<TouchCookieJar["toJSON"]>;
474
+ private toPublicSerializedJar;
475
+ private toStoredCookie;
476
+ private toPublicCookies;
477
+ private toPublicCookie;
478
+ private toStoredCookieKey;
479
+ private toPublicCookieKey;
480
+ private cookiesToCookieString;
481
+ private cookiesToSetCookieStrings;
447
482
  /**
448
483
  * Get all cookies from the cookie jar.
449
484
  *
@@ -4283,34 +4318,36 @@ export interface RezoRequestConfig<D = any> {
4283
4318
  * TLS negotiation for HTTPS).
4284
4319
  *
4285
4320
  * **Behavior:**
4286
- * - `false` (default) - Connection closes after each request. Process exits immediately.
4287
- * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
4321
+ * - `true` (default) - Connections are pooled and reused across requests to the
4322
+ * same host. Idle pooled sockets are closed after ~5 seconds.
4323
+ * - `false` - A fresh connection is opened for every request and closed after
4324
+ * the response. No pooling, no reuse.
4288
4325
  *
4289
- * **When to use `keepAlive: true`:**
4326
+ * **When to keep the default (`keepAlive: true`):**
4290
4327
  * - Making multiple requests to the same host in sequence
4291
4328
  * - Long-running applications (servers, bots, scrapers)
4292
4329
  * - Performance-critical applications where connection overhead matters
4293
4330
  *
4294
- * **When to use `keepAlive: false` (default):**
4295
- * - Single requests or scripts that should exit immediately
4296
- * - CLI tools that make one-off requests
4297
- * - When you need predictable process termination
4331
+ * **When to use `keepAlive: false`:**
4332
+ * - Hosts that reset reused connections aggressively
4333
+ * - Debugging connection-level issues (isolates every request)
4334
+ * - One-off requests where connection reuse buys nothing
4298
4335
  *
4299
4336
  * @example
4300
4337
  * ```typescript
4301
- * // Default: process exits immediately after request
4338
+ * // Default: pooled keep-alive connections
4302
4339
  * const { data } = await rezo.get('https://api.example.com/data');
4303
4340
  *
4304
- * // Keep connection alive for 1 minute (default) for subsequent requests
4305
- * const client = new Rezo({ keepAlive: true });
4341
+ * // Fresh connection per request for this instance
4342
+ * const client = rezo.create({ keepAlive: false });
4306
4343
  * await client.get('https://api.example.com/users');
4307
- * await client.get('https://api.example.com/posts'); // Reuses connection
4344
+ * await client.get('https://api.example.com/posts'); // New connection again
4308
4345
  *
4309
- * // Custom keep-alive timeout (30 seconds)
4310
- * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
4346
+ * // Or per request
4347
+ * await rezo.get('https://api.example.com/data', { keepAlive: false });
4311
4348
  * ```
4312
4349
  *
4313
- * @default false
4350
+ * @default true
4314
4351
  */
4315
4352
  keepAlive?: boolean;
4316
4353
  /**
@@ -4732,9 +4769,9 @@ export interface httpAdapterOverloads {
4732
4769
  request(options: RezoRequestOptions & {
4733
4770
  responseType: "blob";
4734
4771
  }): Promise<RezoResponse<Blob>>;
4735
- request(options: RezoRequestOptions & {
4772
+ request<T extends string = string>(options: RezoRequestOptions & {
4736
4773
  responseType: "text";
4737
- }): Promise<RezoResponse<string>>;
4774
+ }): Promise<RezoResponse<T>>;
4738
4775
  request(options: RezoRequestOptions & {
4739
4776
  responseType: "download";
4740
4777
  }): Promise<RezoDownloadResponse>;
@@ -4764,9 +4801,9 @@ export interface httpAdapterOverloads {
4764
4801
  get(url: string | URL, options: RezoHttpGetRequest & {
4765
4802
  responseType: "blob";
4766
4803
  }): Promise<RezoResponse<Blob>>;
4767
- get(url: string | URL, options: RezoHttpGetRequest & {
4804
+ get<T extends string = string>(url: string | URL, options: RezoHttpGetRequest & {
4768
4805
  responseType: "text";
4769
- }): Promise<RezoResponse<string>>;
4806
+ }): Promise<RezoResponse<T>>;
4770
4807
  get(url: string | URL, options: RezoHttpGetRequest & {
4771
4808
  responseType: "download";
4772
4809
  }): Promise<RezoDownloadResponse>;
@@ -4798,9 +4835,9 @@ export interface httpAdapterOverloads {
4798
4835
  delete(url: string | URL, options: RezoHttpDeleteRequest & {
4799
4836
  responseType: "blob";
4800
4837
  }): Promise<RezoResponse<Blob>>;
4801
- delete(url: string | URL, options: RezoHttpDeleteRequest & {
4838
+ delete<T extends string = string>(url: string | URL, options: RezoHttpDeleteRequest & {
4802
4839
  responseType: "text";
4803
- }): Promise<RezoResponse<string>>;
4840
+ }): Promise<RezoResponse<T>>;
4804
4841
  delete(url: string | URL, options: RezoHttpDeleteRequest & {
4805
4842
  responseType: "download";
4806
4843
  }): Promise<RezoDownloadResponse>;
@@ -4887,9 +4924,9 @@ export interface httpAdapterPostOverloads {
4887
4924
  post(url: string | URL, data: any, options: RezoHttpPostRequest & {
4888
4925
  responseType: "blob";
4889
4926
  }): Promise<RezoResponse<Blob>>;
4890
- post(url: string | URL, data: any, options: RezoHttpPostRequest & {
4927
+ post<T extends string = string>(url: string | URL, data: any, options: RezoHttpPostRequest & {
4891
4928
  responseType: "text";
4892
- }): Promise<RezoResponse<string>>;
4929
+ }): Promise<RezoResponse<T>>;
4893
4930
  post(url: string | URL, data: any, options: RezoHttpPostRequest & {
4894
4931
  responseType: "download";
4895
4932
  }): Promise<RezoDownloadResponse>;
@@ -4917,15 +4954,15 @@ export interface httpAdapterPostOverloads {
4917
4954
  postJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
4918
4955
  responseType: "auto" | "json";
4919
4956
  }): Promise<RezoResponse<T>>;
4920
- postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
4957
+ postJson<T extends string = string>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
4921
4958
  responseType: "text";
4922
- }): Promise<RezoResponse<string>>;
4923
- postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
4959
+ }): Promise<RezoResponse<T>>;
4960
+ postJson<T extends string = string>(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
4924
4961
  responseType: "text";
4925
- }): Promise<RezoResponse<string>>;
4926
- postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
4962
+ }): Promise<RezoResponse<T>>;
4963
+ postJson<T extends string = string>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
4927
4964
  responseType: "text";
4928
- }): Promise<RezoResponse<string>>;
4965
+ }): Promise<RezoResponse<T>>;
4929
4966
  postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
4930
4967
  responseType: "arrayBuffer";
4931
4968
  }): Promise<RezoResponse<ArrayBuffer>>;
@@ -4977,15 +5014,15 @@ export interface httpAdapterPostOverloads {
4977
5014
  postForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
4978
5015
  responseType: "auto" | "json";
4979
5016
  }): Promise<RezoResponse<T>>;
4980
- postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
5017
+ postForm<T extends string = string>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
4981
5018
  responseType: "text";
4982
- }): Promise<RezoResponse<string>>;
4983
- postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
5019
+ }): Promise<RezoResponse<T>>;
5020
+ postForm<T extends string = string>(url: string | URL, string: string, options: RezoHttpPostRequest & {
4984
5021
  responseType: "text";
4985
- }): Promise<RezoResponse<string>>;
4986
- postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
5022
+ }): Promise<RezoResponse<T>>;
5023
+ postForm<T extends string = string>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
4987
5024
  responseType: "text";
4988
- }): Promise<RezoResponse<string>>;
5025
+ }): Promise<RezoResponse<T>>;
4989
5026
  postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
4990
5027
  responseType: "arrayBuffer";
4991
5028
  }): Promise<RezoResponse<ArrayBuffer>>;
@@ -5046,15 +5083,15 @@ export interface httpAdapterPostOverloads {
5046
5083
  postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
5047
5084
  responseType: "json";
5048
5085
  }): Promise<RezoResponse<T>>;
5049
- postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
5086
+ postMultipart<T extends string = string>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
5050
5087
  responseType: "text";
5051
- }): Promise<RezoResponse<string>>;
5052
- postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
5088
+ }): Promise<RezoResponse<T>>;
5089
+ postMultipart<T extends string = string>(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
5053
5090
  responseType: "text";
5054
- }): Promise<RezoResponse<string>>;
5055
- postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
5091
+ }): Promise<RezoResponse<T>>;
5092
+ postMultipart<T extends string = string>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
5056
5093
  responseType: "text";
5057
- }): Promise<RezoResponse<string>>;
5094
+ }): Promise<RezoResponse<T>>;
5058
5095
  postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
5059
5096
  responseType: "stream";
5060
5097
  }): Promise<RezoStreamResponse>;
@@ -5110,9 +5147,9 @@ export interface httpAdapterPatchOverloads {
5110
5147
  patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
5111
5148
  responseType: "blob";
5112
5149
  }): Promise<RezoResponse<Blob>>;
5113
- patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
5150
+ patch<T extends string = string>(url: string | URL, data: any, options: RezoHttpPatchRequest & {
5114
5151
  responseType: "text";
5115
- }): Promise<RezoResponse<string>>;
5152
+ }): Promise<RezoResponse<T>>;
5116
5153
  patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
5117
5154
  responseType: "download";
5118
5155
  }): RezoDownloadResponse;
@@ -5140,15 +5177,15 @@ export interface httpAdapterPatchOverloads {
5140
5177
  patchJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
5141
5178
  responseType: "auto" | "json";
5142
5179
  }): Promise<RezoResponse<T>>;
5143
- patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
5180
+ patchJson<T extends string = string>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
5144
5181
  responseType: "text";
5145
- }): Promise<RezoResponse<string>>;
5146
- patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
5182
+ }): Promise<RezoResponse<T>>;
5183
+ patchJson<T extends string = string>(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
5147
5184
  responseType: "text";
5148
- }): Promise<RezoResponse<string>>;
5149
- patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
5185
+ }): Promise<RezoResponse<T>>;
5186
+ patchJson<T extends string = string>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
5150
5187
  responseType: "text";
5151
- }): Promise<RezoResponse<string>>;
5188
+ }): Promise<RezoResponse<T>>;
5152
5189
  patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
5153
5190
  responseType: "arrayBuffer";
5154
5191
  }): Promise<RezoResponse<ArrayBuffer>>;
@@ -5209,15 +5246,15 @@ export interface httpAdapterPatchOverloads {
5209
5246
  patchForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
5210
5247
  responseType: "auto" | "json";
5211
5248
  }): Promise<RezoResponse<T>>;
5212
- patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
5249
+ patchForm<T extends string = string>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
5213
5250
  responseType: "text";
5214
- }): Promise<RezoResponse<string>>;
5215
- patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
5251
+ }): Promise<RezoResponse<T>>;
5252
+ patchForm<T extends string = string>(url: string | URL, string: string, options: RezoHttpPatchRequest & {
5216
5253
  responseType: "text";
5217
- }): Promise<RezoResponse<string>>;
5218
- patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
5254
+ }): Promise<RezoResponse<T>>;
5255
+ patchForm<T extends string = string>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
5219
5256
  responseType: "text";
5220
- }): Promise<RezoResponse<string>>;
5257
+ }): Promise<RezoResponse<T>>;
5221
5258
  patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
5222
5259
  responseType: "arrayBuffer";
5223
5260
  }): Promise<RezoResponse<ArrayBuffer>>;
@@ -5278,15 +5315,15 @@ export interface httpAdapterPatchOverloads {
5278
5315
  patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
5279
5316
  responseType: "auto" | "json";
5280
5317
  }): Promise<RezoResponse<T>>;
5281
- patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
5318
+ patchMultipart<T extends string = string>(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
5282
5319
  responseType: "text";
5283
- }): Promise<RezoResponse<string>>;
5284
- patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
5320
+ }): Promise<RezoResponse<T>>;
5321
+ patchMultipart<T extends string = string>(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
5285
5322
  responseType: "text";
5286
- }): Promise<RezoResponse<string>>;
5287
- patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
5323
+ }): Promise<RezoResponse<T>>;
5324
+ patchMultipart<T extends string = string>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
5288
5325
  responseType: "text";
5289
- }): Promise<RezoResponse<string>>;
5326
+ }): Promise<RezoResponse<T>>;
5290
5327
  patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
5291
5328
  responseType: "stream";
5292
5329
  }): RezoStreamResponse;
@@ -5351,9 +5388,9 @@ export interface httpAdapterPutOverloads {
5351
5388
  put(url: string | URL, data: any, options: RezoHttpPutRequest & {
5352
5389
  responseType: "blob";
5353
5390
  }): Promise<RezoResponse<Blob>>;
5354
- put(url: string | URL, data: any, options: RezoHttpPutRequest & {
5391
+ put<T extends string = string>(url: string | URL, data: any, options: RezoHttpPutRequest & {
5355
5392
  responseType: "text";
5356
- }): Promise<RezoResponse<string>>;
5393
+ }): Promise<RezoResponse<T>>;
5357
5394
  put(url: string | URL, data: any, options: RezoHttpPutRequest & {
5358
5395
  responseType: "download";
5359
5396
  }): RezoDownloadResponse;
@@ -5381,15 +5418,15 @@ export interface httpAdapterPutOverloads {
5381
5418
  putJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
5382
5419
  responseType: "auto" | "json";
5383
5420
  }): Promise<RezoResponse<T>>;
5384
- putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
5421
+ putJson<T extends string = string>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
5385
5422
  responseType: "text";
5386
- }): Promise<RezoResponse<string>>;
5387
- putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
5423
+ }): Promise<RezoResponse<T>>;
5424
+ putJson<T extends string = string>(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
5388
5425
  responseType: "text";
5389
- }): Promise<RezoResponse<string>>;
5390
- putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
5426
+ }): Promise<RezoResponse<T>>;
5427
+ putJson<T extends string = string>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
5391
5428
  responseType: "text";
5392
- }): Promise<RezoResponse<string>>;
5429
+ }): Promise<RezoResponse<T>>;
5393
5430
  putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
5394
5431
  responseType: "arrayBuffer";
5395
5432
  }): Promise<RezoResponse<ArrayBuffer>>;
@@ -5450,15 +5487,15 @@ export interface httpAdapterPutOverloads {
5450
5487
  putForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
5451
5488
  responseType: "auto" | "json";
5452
5489
  }): Promise<RezoResponse<T>>;
5453
- putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
5490
+ putForm<T extends string = string>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
5454
5491
  responseType: "text";
5455
- }): Promise<RezoResponse<string>>;
5456
- putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
5492
+ }): Promise<RezoResponse<T>>;
5493
+ putForm<T extends string = string>(url: string | URL, string: string, options: RezoHttpPutRequest & {
5457
5494
  responseType: "text";
5458
- }): Promise<RezoResponse<string>>;
5459
- putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
5495
+ }): Promise<RezoResponse<T>>;
5496
+ putForm<T extends string = string>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
5460
5497
  responseType: "text";
5461
- }): Promise<RezoResponse<string>>;
5498
+ }): Promise<RezoResponse<T>>;
5462
5499
  putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
5463
5500
  responseType: "arrayBuffer";
5464
5501
  }): Promise<RezoResponse<ArrayBuffer>>;
@@ -5519,15 +5556,15 @@ export interface httpAdapterPutOverloads {
5519
5556
  putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
5520
5557
  responseType: "auto" | "json";
5521
5558
  }): Promise<RezoResponse<T>>;
5522
- putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
5559
+ putMultipart<T extends string = string>(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
5523
5560
  responseType: "text";
5524
- }): Promise<RezoResponse<string>>;
5525
- putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
5561
+ }): Promise<RezoResponse<T>>;
5562
+ putMultipart<T extends string = string>(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
5526
5563
  responseType: "text";
5527
- }): Promise<RezoResponse<string>>;
5528
- putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
5564
+ }): Promise<RezoResponse<T>>;
5565
+ putMultipart<T extends string = string>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
5529
5566
  responseType: "text";
5530
- }): Promise<RezoResponse<string>>;
5567
+ }): Promise<RezoResponse<T>>;
5531
5568
  putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
5532
5569
  responseType: "stream";
5533
5570
  }): RezoStreamResponse;
@@ -1,24 +1,24 @@
1
- const _mod_kjuoa9 = require('../crawler/crawler.cjs');
2
- exports.Crawler = _mod_kjuoa9.Crawler;;
3
- const _mod_otbgyt = require('../crawler/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_otbgyt.CrawlerOptions;;
5
- const _mod_rg1qnw = require('../crawler/scraper.cjs');
6
- exports.isRestrictedDomain = _mod_rg1qnw.isRestrictedDomain;;
7
- const _mod_691zmm = require('../crawler/plugin/file-cacher.cjs');
8
- exports.FileCacher = _mod_691zmm.FileCacher;;
9
- const _mod_drmlt9 = require('../crawler/plugin/health-metrics.cjs');
10
- exports.HealthMetrics = _mod_drmlt9.HealthMetrics;;
11
- const _mod_rg7m8j = require('../crawler/plugin/memory-monitor.cjs');
12
- exports.MemoryMonitor = _mod_rg7m8j.MemoryMonitor;;
13
- const _mod_ksdzz0 = require('../crawler/plugin/result-stream.cjs');
14
- exports.ResultStream = _mod_ksdzz0.ResultStream;;
15
- const _mod_iidf98 = require('../crawler/plugin/capped-array.cjs');
16
- exports.CappedArray = _mod_iidf98.CappedArray;;
17
- const _mod_l4i21m = require('../crawler/plugin/navigation-history.cjs');
18
- exports.NavigationHistory = _mod_l4i21m.NavigationHistory;;
19
- const _mod_2d3zxn = require('../crawler/plugin/robots-txt.cjs');
20
- exports.RobotsTxt = _mod_2d3zxn.RobotsTxt;;
21
- const _mod_gdble9 = require('../crawler/plugin/url-store.cjs');
22
- exports.UrlStore = _mod_gdble9.UrlStore;;
23
- const _mod_rhmp5z = require('../crawler/plugin/capped-map.cjs');
24
- exports.CappedMap = _mod_rhmp5z.CappedMap;;
1
+ const _mod_auayo3 = require('../crawler/crawler.cjs');
2
+ exports.Crawler = _mod_auayo3.Crawler;;
3
+ const _mod_40s3mc = require('../crawler/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_40s3mc.CrawlerOptions;;
5
+ const _mod_kxkjxj = require('../crawler/scraper.cjs');
6
+ exports.isRestrictedDomain = _mod_kxkjxj.isRestrictedDomain;;
7
+ const _mod_foijq2 = require('../crawler/plugin/file-cacher.cjs');
8
+ exports.FileCacher = _mod_foijq2.FileCacher;;
9
+ const _mod_om72kp = require('../crawler/plugin/health-metrics.cjs');
10
+ exports.HealthMetrics = _mod_om72kp.HealthMetrics;;
11
+ const _mod_s7lvj9 = require('../crawler/plugin/memory-monitor.cjs');
12
+ exports.MemoryMonitor = _mod_s7lvj9.MemoryMonitor;;
13
+ const _mod_4m3iwr = require('../crawler/plugin/result-stream.cjs');
14
+ exports.ResultStream = _mod_4m3iwr.ResultStream;;
15
+ const _mod_4wr7fb = require('../crawler/plugin/capped-array.cjs');
16
+ exports.CappedArray = _mod_4wr7fb.CappedArray;;
17
+ const _mod_eu1d0z = require('../crawler/plugin/navigation-history.cjs');
18
+ exports.NavigationHistory = _mod_eu1d0z.NavigationHistory;;
19
+ const _mod_27cm0o = require('../crawler/plugin/robots-txt.cjs');
20
+ exports.RobotsTxt = _mod_27cm0o.RobotsTxt;;
21
+ const _mod_m450hs = require('../crawler/plugin/url-store.cjs');
22
+ exports.UrlStore = _mod_m450hs.UrlStore;;
23
+ const _mod_nip9qc = require('../crawler/plugin/capped-map.cjs');
24
+ exports.CappedMap = _mod_nip9qc.CappedMap;;
@@ -597,7 +597,7 @@ class RezoError extends Error {
597
597
  if (code) {
598
598
  Object.defineProperty(this, "code", { value: code, enumerable: true });
599
599
  }
600
- const timeoutCodes = ["ETIMEDOUT", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_REQUEST_TIMEOUT", "ERR_TLS_HANDSHAKE_TIMEOUT", "REZ_PROXY_TIMEOUT"];
600
+ const timeoutCodes = ["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNABORTED", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_REQUEST_TIMEOUT", "ERR_TLS_HANDSHAKE_TIMEOUT", "REZ_PROXY_TIMEOUT"];
601
601
  const abortCodes = ["ABORT_ERR", "UND_ERR_ABORTED"];
602
602
  const networkCodes = ["ECONNREFUSED", "ECONNRESET", "ENOTFOUND", "EAI_AGAIN", "EPIPE", "EHOSTUNREACH", "ENETUNREACH", "UND_ERR_SOCKET"];
603
603
  const proxyCodes = ["REZ_PROXY_CONNECTION_FAILED", "REZ_PROXY_AUTHENTICATION_FAILED", "REZ_PROXY_TARGET_UNREACHABLE", "REZ_PROXY_ERROR", "REZ_PROXY_TIMEOUT", "REZ_PROXY_INVALID_PROTOCOL", "REZ_PROXY_INVALID_HOSTPORT"];
@@ -616,7 +616,8 @@ class RezoError extends Error {
616
616
  const errorInfo = getCode(code);
617
617
  Object.defineProperty(this, "errno", { value: errorInfo.errno, enumerable: false });
618
618
  Object.defineProperty(this, "suggestion", { value: errorInfo.suggestion, enumerable: false });
619
- this.message = errorInfo.message;
619
+ this.message = message || errorInfo.message;
620
+ Object.defineProperty(this, "details", { value: errorInfo.details, enumerable: false, configurable: true });
620
621
  } else {
621
622
  this.message = message;
622
623
  Object.defineProperty(this, "suggestion", { value: "Check the error for more information.", enumerable: false });
@@ -597,7 +597,7 @@ export class RezoError extends Error {
597
597
  if (code) {
598
598
  Object.defineProperty(this, "code", { value: code, enumerable: true });
599
599
  }
600
- const timeoutCodes = ["ETIMEDOUT", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_REQUEST_TIMEOUT", "ERR_TLS_HANDSHAKE_TIMEOUT", "REZ_PROXY_TIMEOUT"];
600
+ const timeoutCodes = ["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNABORTED", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_REQUEST_TIMEOUT", "ERR_TLS_HANDSHAKE_TIMEOUT", "REZ_PROXY_TIMEOUT"];
601
601
  const abortCodes = ["ABORT_ERR", "UND_ERR_ABORTED"];
602
602
  const networkCodes = ["ECONNREFUSED", "ECONNRESET", "ENOTFOUND", "EAI_AGAIN", "EPIPE", "EHOSTUNREACH", "ENETUNREACH", "UND_ERR_SOCKET"];
603
603
  const proxyCodes = ["REZ_PROXY_CONNECTION_FAILED", "REZ_PROXY_AUTHENTICATION_FAILED", "REZ_PROXY_TARGET_UNREACHABLE", "REZ_PROXY_ERROR", "REZ_PROXY_TIMEOUT", "REZ_PROXY_INVALID_PROTOCOL", "REZ_PROXY_INVALID_HOSTPORT"];
@@ -616,7 +616,8 @@ export class RezoError extends Error {
616
616
  const errorInfo = getCode(code);
617
617
  Object.defineProperty(this, "errno", { value: errorInfo.errno, enumerable: false });
618
618
  Object.defineProperty(this, "suggestion", { value: errorInfo.suggestion, enumerable: false });
619
- this.message = errorInfo.message;
619
+ this.message = message || errorInfo.message;
620
+ Object.defineProperty(this, "details", { value: errorInfo.details, enumerable: false, configurable: true });
620
621
  } else {
621
622
  this.message = message;
622
623
  Object.defineProperty(this, "suggestion", { value: "Check the error for more information.", enumerable: false });
package/dist/index.cjs CHANGED
@@ -1,58 +1,58 @@
1
- const _mod_x9kv85 = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_x9kv85.Rezo;
3
- exports.createRezoInstance = _mod_x9kv85.createRezoInstance;
4
- exports.createDefaultInstance = _mod_x9kv85.createDefaultInstance;;
5
- const _mod_q7dn9f = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_q7dn9f.RezoError;
7
- exports.RezoErrorCode = _mod_q7dn9f.RezoErrorCode;;
8
- const _mod_ajxw2g = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_ajxw2g.RezoHeaders;;
10
- const _mod_385i8a = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_385i8a.RezoFormData;;
12
- const _mod_adrlma = require('./utils/data-operations.cjs');
13
- exports.RezoURLSearchParams = _mod_adrlma.RezoURLSearchParams;;
14
- const _mod_h1j1cg = require('./cookies/cookie-jar.cjs');
15
- exports.RezoCookieJar = _mod_h1j1cg.RezoCookieJar;
16
- exports.CookieJar = _mod_h1j1cg.CookieJar;
17
- exports.Cookie = _mod_h1j1cg.Cookie;
18
- exports.Store = _mod_h1j1cg.Store;;
19
- const _mod_2cfis6 = require('./cookies/cookie-store.cjs');
20
- exports.RezoCookieStore = _mod_2cfis6.RezoCookieStore;;
21
- const _mod_1rt4ql = require('./utils/curl.cjs');
22
- exports.toCurl = _mod_1rt4ql.toCurl;
23
- exports.fromCurl = _mod_1rt4ql.fromCurl;;
24
- const _mod_b3hror = require('./utils/link-header.cjs');
25
- exports.parseLinkHeader = _mod_b3hror.parseLinkHeader;;
26
- const _mod_jvl2j0 = require('./utils/uri.cjs');
27
- exports.RezoUri = _mod_jvl2j0.RezoUri;;
28
- const _mod_on6y32 = require('./cache/index.cjs');
29
- exports.DNSCache = _mod_on6y32.DNSCache;
30
- exports.ResponseCache = _mod_on6y32.ResponseCache;
31
- exports.getGlobalDNSCache = _mod_on6y32.getGlobalDNSCache;
32
- exports.resetGlobalDNSCache = _mod_on6y32.resetGlobalDNSCache;;
33
- const _mod_tchicl = require('./core/hooks.cjs');
34
- exports.createDefaultHooks = _mod_tchicl.createDefaultHooks;
35
- exports.mergeHooks = _mod_tchicl.mergeHooks;;
36
- const _mod_doxtn9 = require('./core/interceptor-manager.cjs');
37
- exports.RequestInterceptorManager = _mod_doxtn9.RequestInterceptorManager;
38
- exports.ResponseInterceptorManager = _mod_doxtn9.ResponseInterceptorManager;;
39
- const _mod_sohv1e = require('./proxy/manager.cjs');
40
- exports.ProxyManager = _mod_sohv1e.ProxyManager;;
41
- const _mod_xx3m1b = require('./stealth/stealth.cjs');
42
- exports.RezoStealth = _mod_xx3m1b.RezoStealth;;
43
- const _mod_yt79xg = require('./stealth/profiles/index.cjs');
44
- exports.listProfiles = _mod_yt79xg.listProfiles;
45
- exports.getProfile = _mod_yt79xg.getProfile;
46
- exports.getProfilesByFamily = _mod_yt79xg.getProfilesByFamily;
47
- exports.getProfilesByDevice = _mod_yt79xg.getProfilesByDevice;
48
- exports.getRandomProfile = _mod_yt79xg.getRandomProfile;
49
- exports.getRandomProfileByFamily = _mod_yt79xg.getRandomProfileByFamily;;
50
- const _mod_dxu8iu = require('./queue/index.cjs');
51
- exports.RezoQueue = _mod_dxu8iu.RezoQueue;
52
- exports.HttpQueue = _mod_dxu8iu.HttpQueue;
53
- exports.RezoHttpQueue = _mod_dxu8iu.HttpQueue;
54
- exports.Priority = _mod_dxu8iu.Priority;
55
- exports.HttpMethodPriority = _mod_dxu8iu.HttpMethodPriority;;
1
+ const _mod_hdnt0m = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_hdnt0m.Rezo;
3
+ exports.createRezoInstance = _mod_hdnt0m.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_hdnt0m.createDefaultInstance;;
5
+ const _mod_8rz5hh = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_8rz5hh.RezoError;
7
+ exports.RezoErrorCode = _mod_8rz5hh.RezoErrorCode;;
8
+ const _mod_x2uipe = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_x2uipe.RezoHeaders;;
10
+ const _mod_r3jelq = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_r3jelq.RezoFormData;;
12
+ const _mod_rf9p54 = require('./utils/data-operations.cjs');
13
+ exports.RezoURLSearchParams = _mod_rf9p54.RezoURLSearchParams;;
14
+ const _mod_uzq2ov = require('./cookies/cookie-jar.cjs');
15
+ exports.RezoCookieJar = _mod_uzq2ov.RezoCookieJar;
16
+ exports.CookieJar = _mod_uzq2ov.CookieJar;
17
+ exports.Cookie = _mod_uzq2ov.Cookie;
18
+ exports.Store = _mod_uzq2ov.Store;;
19
+ const _mod_358j9w = require('./cookies/cookie-store.cjs');
20
+ exports.RezoCookieStore = _mod_358j9w.RezoCookieStore;;
21
+ const _mod_6p3lfa = require('./utils/curl.cjs');
22
+ exports.toCurl = _mod_6p3lfa.toCurl;
23
+ exports.fromCurl = _mod_6p3lfa.fromCurl;;
24
+ const _mod_trpxhb = require('./utils/link-header.cjs');
25
+ exports.parseLinkHeader = _mod_trpxhb.parseLinkHeader;;
26
+ const _mod_nrv5am = require('./utils/uri.cjs');
27
+ exports.RezoUri = _mod_nrv5am.RezoUri;;
28
+ const _mod_du719p = require('./cache/index.cjs');
29
+ exports.DNSCache = _mod_du719p.DNSCache;
30
+ exports.ResponseCache = _mod_du719p.ResponseCache;
31
+ exports.getGlobalDNSCache = _mod_du719p.getGlobalDNSCache;
32
+ exports.resetGlobalDNSCache = _mod_du719p.resetGlobalDNSCache;;
33
+ const _mod_ygzq5g = require('./core/hooks.cjs');
34
+ exports.createDefaultHooks = _mod_ygzq5g.createDefaultHooks;
35
+ exports.mergeHooks = _mod_ygzq5g.mergeHooks;;
36
+ const _mod_ab0bqd = require('./core/interceptor-manager.cjs');
37
+ exports.RequestInterceptorManager = _mod_ab0bqd.RequestInterceptorManager;
38
+ exports.ResponseInterceptorManager = _mod_ab0bqd.ResponseInterceptorManager;;
39
+ const _mod_od9jzv = require('./proxy/manager.cjs');
40
+ exports.ProxyManager = _mod_od9jzv.ProxyManager;;
41
+ const _mod_6gr7e7 = require('./stealth/stealth.cjs');
42
+ exports.RezoStealth = _mod_6gr7e7.RezoStealth;;
43
+ const _mod_i76cc6 = require('./stealth/profiles/index.cjs');
44
+ exports.listProfiles = _mod_i76cc6.listProfiles;
45
+ exports.getProfile = _mod_i76cc6.getProfile;
46
+ exports.getProfilesByFamily = _mod_i76cc6.getProfilesByFamily;
47
+ exports.getProfilesByDevice = _mod_i76cc6.getProfilesByDevice;
48
+ exports.getRandomProfile = _mod_i76cc6.getRandomProfile;
49
+ exports.getRandomProfileByFamily = _mod_i76cc6.getRandomProfileByFamily;;
50
+ const _mod_5tvlta = require('./queue/index.cjs');
51
+ exports.RezoQueue = _mod_5tvlta.RezoQueue;
52
+ exports.HttpQueue = _mod_5tvlta.HttpQueue;
53
+ exports.RezoHttpQueue = _mod_5tvlta.HttpQueue;
54
+ exports.Priority = _mod_5tvlta.Priority;
55
+ exports.HttpMethodPriority = _mod_5tvlta.HttpMethodPriority;;
56
56
  const { RezoError } = require('./errors/rezo-error.cjs');
57
57
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
58
58
  const Cancel = exports.Cancel = RezoError;
@@ -62,9 +62,9 @@ const isCancel = exports.isCancel = (error) => {
62
62
  };
63
63
  const all = exports.all = Promise.all.bind(Promise);
64
64
  const spread = exports.spread = (callback) => (array) => callback(...array);
65
- const _mod_q4wb08 = require('./version.cjs');
66
- exports.VERSION = _mod_q4wb08.VERSION;
67
- exports.PACKAGE_NAME = _mod_q4wb08.PACKAGE_NAME;;
65
+ const _mod_vqh7gc = require('./version.cjs');
66
+ exports.VERSION = _mod_vqh7gc.VERSION;
67
+ exports.PACKAGE_NAME = _mod_vqh7gc.PACKAGE_NAME;;
68
68
  const { executeRequest } = require('./adapters/http.cjs');
69
69
  const { setGlobalAdapter, createRezoInstance } = require('./core/rezo.cjs');
70
70
  setGlobalAdapter(executeRequest);