rezo 1.0.0

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 (135) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1507 -0
  3. package/assets/icon.svg +37 -0
  4. package/assets/logo-dark.svg +47 -0
  5. package/assets/logo.svg +58 -0
  6. package/dist/adapters/curl.cjs +1034 -0
  7. package/dist/adapters/curl.js +1031 -0
  8. package/dist/adapters/entries/curl.cjs +4 -0
  9. package/dist/adapters/entries/curl.d.ts +2136 -0
  10. package/dist/adapters/entries/curl.js +2 -0
  11. package/dist/adapters/entries/fetch.cjs +2 -0
  12. package/dist/adapters/entries/fetch.d.ts +2127 -0
  13. package/dist/adapters/entries/fetch.js +1 -0
  14. package/dist/adapters/entries/http.cjs +2 -0
  15. package/dist/adapters/entries/http.d.ts +2126 -0
  16. package/dist/adapters/entries/http.js +1 -0
  17. package/dist/adapters/entries/http2.cjs +4 -0
  18. package/dist/adapters/entries/http2.d.ts +2136 -0
  19. package/dist/adapters/entries/http2.js +2 -0
  20. package/dist/adapters/entries/react-native.cjs +2 -0
  21. package/dist/adapters/entries/react-native.d.ts +2126 -0
  22. package/dist/adapters/entries/react-native.js +1 -0
  23. package/dist/adapters/entries/xhr.cjs +2 -0
  24. package/dist/adapters/entries/xhr.d.ts +2127 -0
  25. package/dist/adapters/entries/xhr.js +1 -0
  26. package/dist/adapters/fetch.cjs +740 -0
  27. package/dist/adapters/fetch.js +739 -0
  28. package/dist/adapters/http.cjs +1153 -0
  29. package/dist/adapters/http.js +1151 -0
  30. package/dist/adapters/http2.cjs +957 -0
  31. package/dist/adapters/http2.js +956 -0
  32. package/dist/adapters/index.cjs +6 -0
  33. package/dist/adapters/index.js +7 -0
  34. package/dist/adapters/picker.cjs +342 -0
  35. package/dist/adapters/picker.js +331 -0
  36. package/dist/adapters/react-native.cjs +545 -0
  37. package/dist/adapters/react-native.js +544 -0
  38. package/dist/adapters/xhr.cjs +622 -0
  39. package/dist/adapters/xhr.js +621 -0
  40. package/dist/cache/dns-cache.cjs +118 -0
  41. package/dist/cache/dns-cache.js +113 -0
  42. package/dist/cache/file-cacher.cjs +264 -0
  43. package/dist/cache/file-cacher.js +261 -0
  44. package/dist/cache/index.cjs +13 -0
  45. package/dist/cache/index.js +5 -0
  46. package/dist/cache/lru-cache.cjs +96 -0
  47. package/dist/cache/lru-cache.js +93 -0
  48. package/dist/cache/response-cache.cjs +314 -0
  49. package/dist/cache/response-cache.js +310 -0
  50. package/dist/cache/url-store.cjs +288 -0
  51. package/dist/cache/url-store.js +285 -0
  52. package/dist/core/hooks.cjs +133 -0
  53. package/dist/core/hooks.js +120 -0
  54. package/dist/core/rezo.cjs +464 -0
  55. package/dist/core/rezo.js +458 -0
  56. package/dist/crawler.d.ts +6255 -0
  57. package/dist/dom/index.cjs +1 -0
  58. package/dist/dom/index.d.ts +23 -0
  59. package/dist/dom/index.js +1 -0
  60. package/dist/entries/crawler.cjs +5 -0
  61. package/dist/entries/crawler.js +2 -0
  62. package/dist/errors/rezo-error.cjs +722 -0
  63. package/dist/errors/rezo-error.js +716 -0
  64. package/dist/index.cjs +34 -0
  65. package/dist/index.d.ts +3335 -0
  66. package/dist/index.js +26 -0
  67. package/dist/platform/browser.cjs +9 -0
  68. package/dist/platform/browser.d.ts +3203 -0
  69. package/dist/platform/browser.js +7 -0
  70. package/dist/platform/bun.cjs +9 -0
  71. package/dist/platform/bun.d.ts +3203 -0
  72. package/dist/platform/bun.js +7 -0
  73. package/dist/platform/deno.cjs +9 -0
  74. package/dist/platform/deno.d.ts +3203 -0
  75. package/dist/platform/deno.js +7 -0
  76. package/dist/platform/node.cjs +9 -0
  77. package/dist/platform/node.d.ts +3203 -0
  78. package/dist/platform/node.js +7 -0
  79. package/dist/platform/react-native.cjs +9 -0
  80. package/dist/platform/react-native.d.ts +3203 -0
  81. package/dist/platform/react-native.js +7 -0
  82. package/dist/platform/worker.cjs +9 -0
  83. package/dist/platform/worker.d.ts +3203 -0
  84. package/dist/platform/worker.js +7 -0
  85. package/dist/plugin/addon/decodo/index.cjs +1 -0
  86. package/dist/plugin/addon/decodo/index.js +1 -0
  87. package/dist/plugin/addon/decodo/options.cjs +1 -0
  88. package/dist/plugin/addon/decodo/options.js +1 -0
  89. package/dist/plugin/addon/oxylabs/index.cjs +1 -0
  90. package/dist/plugin/addon/oxylabs/index.js +1 -0
  91. package/dist/plugin/addon/oxylabs/options.cjs +1 -0
  92. package/dist/plugin/addon/oxylabs/options.js +1 -0
  93. package/dist/plugin/crawler-options.cjs +1 -0
  94. package/dist/plugin/crawler-options.js +1 -0
  95. package/dist/plugin/crawler.cjs +519 -0
  96. package/dist/plugin/crawler.js +517 -0
  97. package/dist/plugin/index.cjs +36 -0
  98. package/dist/plugin/index.js +32 -0
  99. package/dist/proxy/index.cjs +142 -0
  100. package/dist/proxy/index.js +139 -0
  101. package/dist/responses/buildError.cjs +452 -0
  102. package/dist/responses/buildError.js +441 -0
  103. package/dist/responses/buildResponse.cjs +365 -0
  104. package/dist/responses/buildResponse.js +361 -0
  105. package/dist/responses/download.cjs +54 -0
  106. package/dist/responses/download.js +52 -0
  107. package/dist/responses/stream.cjs +60 -0
  108. package/dist/responses/stream.js +58 -0
  109. package/dist/responses/upload.cjs +54 -0
  110. package/dist/responses/upload.js +52 -0
  111. package/dist/types/cookies.cjs +394 -0
  112. package/dist/types/cookies.js +391 -0
  113. package/dist/types/download.cjs +10 -0
  114. package/dist/types/download.js +10 -0
  115. package/dist/types/rezo-request.cjs +131 -0
  116. package/dist/types/rezo-request.js +131 -0
  117. package/dist/utils/agent-merger.cjs +111 -0
  118. package/dist/utils/agent-merger.js +108 -0
  119. package/dist/utils/compression.cjs +84 -0
  120. package/dist/utils/compression.js +82 -0
  121. package/dist/utils/cookies.cjs +514 -0
  122. package/dist/utils/cookies.js +511 -0
  123. package/dist/utils/data-operations.cjs +75 -0
  124. package/dist/utils/data-operations.js +73 -0
  125. package/dist/utils/form-data.cjs +164 -0
  126. package/dist/utils/form-data.js +161 -0
  127. package/dist/utils/headers.cjs +162 -0
  128. package/dist/utils/headers.js +161 -0
  129. package/dist/utils/http-config.cjs +723 -0
  130. package/dist/utils/http-config.js +718 -0
  131. package/dist/utils/index.cjs +8 -0
  132. package/dist/utils/index.js +8 -0
  133. package/dist/utils/tools.cjs +18 -0
  134. package/dist/utils/tools.js +15 -0
  135. package/package.json +172 -0
@@ -0,0 +1,3335 @@
1
+ import NodeFormData from 'form-data';
2
+ import { Blob as Blob$1 } from 'node:buffer';
3
+ import { EventEmitter } from 'node:events';
4
+ import { Agent as HttpAgent, OutgoingHttpHeaders } from 'node:http';
5
+ import { Agent as HttpsAgent } from 'node:https';
6
+ import { Socket } from 'node:net';
7
+ import { Readable, Writable, WritableOptions } from 'node:stream';
8
+ import { SecureContext, TLSSocket } from 'node:tls';
9
+ import PQueue from 'p-queue';
10
+ import { Options as Options$1, QueueAddOptions } from 'p-queue';
11
+ import PriorityQueue from 'p-queue/dist/priority-queue';
12
+ import { Cookie as TouchCookie, CookieJar as TouchCookieJar, CreateCookieOptions } from 'tough-cookie';
13
+
14
+ export interface RezoHttpHeaders {
15
+ accept?: string | undefined;
16
+ "accept-encoding"?: string | undefined;
17
+ "accept-language"?: string | undefined;
18
+ "accept-patch"?: string | undefined;
19
+ "accept-ranges"?: string | undefined;
20
+ "access-control-allow-credentials"?: string | undefined;
21
+ "access-control-allow-headers"?: string | undefined;
22
+ "access-control-allow-methods"?: string | undefined;
23
+ "access-control-allow-origin"?: string | undefined;
24
+ "access-control-expose-headers"?: string | undefined;
25
+ "access-control-max-age"?: string | undefined;
26
+ "access-control-request-headers"?: string | undefined;
27
+ "access-control-request-method"?: string | undefined;
28
+ age?: string | undefined;
29
+ allow?: string | undefined;
30
+ "alt-svc"?: string | undefined;
31
+ authorization?: string | undefined;
32
+ "cache-control"?: string | undefined;
33
+ connection?: string | undefined;
34
+ "content-disposition"?: string | undefined;
35
+ "content-encoding"?: string | undefined;
36
+ "content-language"?: string | undefined;
37
+ "content-length"?: string | undefined;
38
+ "content-location"?: string | undefined;
39
+ "content-range"?: string | undefined;
40
+ "content-type"?: string | undefined;
41
+ cookie?: string | undefined;
42
+ date?: string | undefined;
43
+ etag?: string | undefined;
44
+ expect?: string | undefined;
45
+ expires?: string | undefined;
46
+ forwarded?: string | undefined;
47
+ from?: string | undefined;
48
+ host?: string | undefined;
49
+ "if-match"?: string | undefined;
50
+ "if-modified-since"?: string | undefined;
51
+ "if-none-match"?: string | undefined;
52
+ "if-unmodified-since"?: string | undefined;
53
+ "last-modified"?: string | undefined;
54
+ location?: string | undefined;
55
+ origin?: string | undefined;
56
+ pragma?: string | undefined;
57
+ "proxy-authenticate"?: string | undefined;
58
+ "proxy-authorization"?: string | undefined;
59
+ "public-key-pins"?: string | undefined;
60
+ range?: string | undefined;
61
+ referer?: string | undefined;
62
+ "retry-after"?: string | undefined;
63
+ "sec-fetch-site"?: string | undefined;
64
+ "sec-fetch-mode"?: string | undefined;
65
+ "sec-fetch-user"?: string | undefined;
66
+ "sec-fetch-dest"?: string | undefined;
67
+ "sec-websocket-accept"?: string | undefined;
68
+ "sec-websocket-extensions"?: string | undefined;
69
+ "sec-websocket-key"?: string | undefined;
70
+ "sec-websocket-protocol"?: string | undefined;
71
+ "sec-websocket-version"?: string | undefined;
72
+ "strict-transport-security"?: string | undefined;
73
+ tk?: string | undefined;
74
+ trailer?: string | undefined;
75
+ "transfer-encoding"?: string | undefined;
76
+ upgrade?: string | undefined;
77
+ "user-agent"?: string | undefined;
78
+ vary?: string | undefined;
79
+ via?: string | undefined;
80
+ warning?: string | undefined;
81
+ "www-authenticate"?: string | undefined;
82
+ "accept-charset"?: string | undefined;
83
+ "cdn-cache-control"?: string | undefined;
84
+ "content-security-policy"?: string | undefined;
85
+ "content-security-policy-report-only"?: string | undefined;
86
+ dav?: string | undefined;
87
+ dnt?: string | undefined;
88
+ "if-range"?: string | undefined;
89
+ link?: string | undefined;
90
+ "max-forwards"?: string | undefined;
91
+ "public-key-pins-report-only"?: string | undefined;
92
+ "referrer-policy"?: string | undefined;
93
+ refresh?: string | undefined;
94
+ server?: string | undefined;
95
+ te?: string | undefined;
96
+ "upgrade-insecure-requests"?: string | undefined;
97
+ "x-content-type-options"?: string | undefined;
98
+ "x-dns-prefetch-control"?: string | undefined;
99
+ "x-frame-options"?: string | undefined;
100
+ "x-xss-protection"?: string | undefined;
101
+ "set-cookie"?: string[];
102
+ }
103
+ export type RezoHeadersInit = [
104
+ string,
105
+ string
106
+ ][] | Record<string, string> | Headers | RezoHttpHeaders | RezoHeaders | OutgoingHttpHeaders;
107
+ export declare class RezoHeaders extends Headers {
108
+ constructor(init?: RezoHeadersInit);
109
+ getAll(name: "set-cookie" | "Set-Cookie"): string[];
110
+ getSetCookie(): string[];
111
+ get size(): number;
112
+ setContentType(value: string): this;
113
+ getContentType(): string | undefined;
114
+ setAuthorization(value: string): this;
115
+ setUserAgent(value: string): this;
116
+ getUserAgent(): string | undefined;
117
+ getKeys(): string[];
118
+ getValues(): string[];
119
+ toEntries(): [
120
+ string,
121
+ string | string
122
+ ][];
123
+ toNative(): Headers;
124
+ toRaw(): [
125
+ string,
126
+ string
127
+ ][];
128
+ toArray(): {
129
+ key: string;
130
+ value: string;
131
+ }[];
132
+ toObject(omit?: Array<keyof RezoHttpHeaders> | keyof RezoHttpHeaders): Record<string, string | string[]>;
133
+ toString(): string;
134
+ set(name: keyof RezoHttpHeaders, value: string): void;
135
+ set(name: string, value: string): void;
136
+ append(name: keyof RezoHttpHeaders, value: string): void;
137
+ append(name: string, value: string): void;
138
+ get(name: keyof RezoHttpHeaders): string | null;
139
+ get(name: string): string | null;
140
+ has(name: keyof RezoHttpHeaders): boolean;
141
+ has(name: string): boolean;
142
+ [Symbol.iterator](): ArrayIterator<[
143
+ string,
144
+ string | string[]
145
+ ]>;
146
+ [util.inspect.custom](_depth: number, options: util.InspectOptionsStylized): string;
147
+ get [Symbol.toStringTag](): string;
148
+ }
149
+ export interface SerializedCookie {
150
+ key: string;
151
+ value: string;
152
+ expires?: string;
153
+ maxAge?: number | "Infinity" | "-Infinity";
154
+ domain?: string;
155
+ path?: string;
156
+ secure?: boolean;
157
+ hostOnly?: boolean;
158
+ creation?: string;
159
+ lastAccessed?: string;
160
+ [key: string]: unknown;
161
+ }
162
+ declare class Cookie extends TouchCookie {
163
+ constructor(options?: CreateCookieOptions);
164
+ /**
165
+ * Fixes date fields that may have become strings during JSON deserialization.
166
+ * This is a workaround for tough-cookie's deserialization behavior in Bun/Node.js
167
+ * where Date objects become ISO strings.
168
+ */
169
+ private fixDateFields;
170
+ private getExpires;
171
+ toNetscapeFormat(): string;
172
+ toSetCookieString(): string;
173
+ /**
174
+ * Retrieves the complete URL from the cookie object
175
+ * @returns {string | undefined} The complete URL including protocol, domain and path. Returns undefined if domain is not set
176
+ * @example
177
+ * const cookie = new Cookie({
178
+ * domain: "example.com",
179
+ * path: "/path",
180
+ * secure: true
181
+ * });
182
+ * cookie.getURL(); // Returns: "https://example.com/path"
183
+ */
184
+ getURL(): string | undefined;
185
+ /**
186
+ * Type guard to check if an object is an instance of Cookie
187
+ * @param cookie - The object to check
188
+ * @returns {boolean} True if the object is a Cookie instance, false otherwise
189
+ * @example
190
+ * const obj = new Cookie();
191
+ * if (Cookie.isCookie(obj)) {
192
+ * // obj is confirmed to be a Cookie instance
193
+ * }
194
+ */
195
+ static isCookie(cookie: any): cookie is Cookie;
196
+ }
197
+ export declare class RezoCookieJar extends TouchCookieJar {
198
+ constructor();
199
+ constructor(cookies: Cookie[]);
200
+ constructor(cookies: Cookie[], url: string);
201
+ private generateCookies;
202
+ cookies(): Cookies;
203
+ parseResponseCookies(cookies: Cookie[]): Cookies;
204
+ static toNetscapeCookie(cookies: Cookie[] | SerializedCookie[]): string;
205
+ static toCookieString(cookies: Cookie[] | SerializedCookie[]): string;
206
+ toCookieString(): string;
207
+ toNetscapeCookie(): string;
208
+ toArray(): Cookie[];
209
+ toSetCookies(): string[];
210
+ toSerializedCookies(): SerializedCookie[];
211
+ setCookiesSync(setCookieArray: string[]): Cookies;
212
+ setCookiesSync(setCookieArray: string[], url: string): Cookies;
213
+ setCookiesSync(cookiesString: string): Cookies;
214
+ setCookiesSync(cookiesString: string, url: string): Cookies;
215
+ setCookiesSync(serializedCookies: SerializedCookie[]): Cookies;
216
+ setCookiesSync(serializedCookies: SerializedCookie[], url: string): Cookies;
217
+ setCookiesSync(cookieArray: Cookie[]): Cookies;
218
+ setCookiesSync(cookieArray: Cookie[], url: string): Cookies;
219
+ private splitSetCookiesString;
220
+ private getUrlFromCookie;
221
+ private parseNetscapeCookies;
222
+ /**
223
+ * Converts Netscape cookie format to an array of Set-Cookie header strings
224
+ *
225
+ * @param netscapeCookieText - Netscape format cookie string
226
+ * @returns Array of Set-Cookie header strings
227
+ */
228
+ static netscapeCookiesToSetCookieArray(netscapeCookieText: string): string[];
229
+ /** Path to cookie file for persistence */
230
+ private _cookieFile?;
231
+ /** Get the cookie file path */
232
+ get cookieFile(): string | undefined;
233
+ /**
234
+ * Load cookies from a file (sync version).
235
+ * - .json files are loaded as serialized JSON cookies
236
+ * - .txt files are loaded as Netscape format cookies
237
+ *
238
+ * This method bypasses public suffix validation for persisted cookies only,
239
+ * keeping normal network cookie validation intact.
240
+ *
241
+ * @param filePath - Path to the cookie file
242
+ * @param defaultUrl - Default URL for cookies without domain (optional)
243
+ */
244
+ loadFromFile(filePath: string, defaultUrl?: string): void;
245
+ /**
246
+ * Save cookies to a file.
247
+ * - .json files save cookies as serialized JSON
248
+ * - .txt files save cookies in Netscape format
249
+ *
250
+ * @param filePath - Path to save the cookies (defaults to the loaded file path)
251
+ */
252
+ saveToFile(filePath?: string): void;
253
+ /**
254
+ * Create a new RezoCookieJar from a cookie file.
255
+ * - .json files are loaded as serialized JSON cookies
256
+ * - .txt files are loaded as Netscape format cookies
257
+ *
258
+ * @param filePath - Path to the cookie file
259
+ * @param defaultUrl - Default URL for cookies without domain (optional)
260
+ * @returns A new RezoCookieJar with cookies loaded from the file
261
+ */
262
+ static fromFile(filePath: string, defaultUrl?: string): RezoCookieJar;
263
+ }
264
+ export interface Cookies {
265
+ array: Cookie[];
266
+ serialized: SerializedCookie[];
267
+ netscape: string;
268
+ string: string;
269
+ setCookiesString: string[];
270
+ }
271
+ export interface ReadableOptions {
272
+ highWaterMark?: number;
273
+ encoding?: string;
274
+ objectMode?: boolean;
275
+ read?(this: Readable, size: number): void;
276
+ destroy?(this: Readable, error: Error | null, callback: (error: Error | null) => void): void;
277
+ autoDestroy?: boolean;
278
+ }
279
+ export interface Options extends ReadableOptions {
280
+ writable?: boolean;
281
+ readable?: boolean;
282
+ dataSize?: number;
283
+ maxDataSize?: number;
284
+ pauseStreams?: boolean;
285
+ }
286
+ export declare class RezoFormData extends NodeFormData {
287
+ constructor(options?: Options);
288
+ /**
289
+ * Get field entries as array of [name, value] pairs
290
+ * @returns {Promise<Array<[string, any]>>} Array of field entries
291
+ */
292
+ getFieldEntries(): Promise<Array<[
293
+ string,
294
+ any
295
+ ]>>;
296
+ /**
297
+ * Convert to native FormData
298
+ * @returns {Promise<FormData | null>}
299
+ */
300
+ toNativeFormData(): Promise<FormData | null>;
301
+ /**
302
+ * Create RezoFormData from native FormData
303
+ * @param {FormData} formData - Native FormData object
304
+ * @param {Options} options - Optional RezoFormData options
305
+ * @returns {Promise<RezoFormData>}
306
+ */
307
+ static fromNativeFormData(formData: FormData, options?: Options): Promise<RezoFormData>;
308
+ /**
309
+ * Get the content type header for this form data
310
+ * @returns {string} Content type with boundary
311
+ */
312
+ getContentType(): string;
313
+ /**
314
+ * Convert form data to Buffer
315
+ * @returns {Buffer} Form data as buffer
316
+ */
317
+ toBuffer(): Buffer;
318
+ /**
319
+ * Create RezoFormData from object
320
+ * @param {Record<string, any>} obj - Object to convert
321
+ * @param {Options} options - Optional RezoFormData options
322
+ * @returns {RezoFormData}
323
+ */
324
+ static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
325
+ /**
326
+ * Convert to URL query string
327
+ * Warning: File, Blob, and binary data will be omitted
328
+ * @param {boolean} convertBinaryToBase64 - Convert binary data to base64 strings
329
+ * @returns {Promise<string>} URL query string
330
+ */
331
+ toUrlQueryString(convertBinaryToBase64?: boolean): Promise<string>;
332
+ /**
333
+ * Convert to URLSearchParams object
334
+ * Warning: File, Blob, and binary data will be omitted
335
+ * @param {boolean} convertBinaryToBase64 - Convert binary data to base64 strings
336
+ * @returns {Promise<URLSearchParams>} URLSearchParams object
337
+ */
338
+ toURLSearchParams(convertBinaryToBase64?: boolean): Promise<URLSearchParams>;
339
+ }
340
+ /**
341
+ * Emitted when request is initiated
342
+ * Contains basic request configuration without sensitive data
343
+ */
344
+ export interface RequestStartEvent {
345
+ /** Target URL */
346
+ url: string;
347
+ /** HTTP method */
348
+ method: string;
349
+ /** Request headers being sent */
350
+ headers: RezoHeaders;
351
+ /** Timestamp when request started (performance.now()) */
352
+ timestamp: number;
353
+ /** Request timeout in milliseconds */
354
+ timeout?: number;
355
+ /** Maximum redirects allowed */
356
+ maxRedirects?: number;
357
+ /** Retry configuration */
358
+ retry?: {
359
+ maxRetries?: number;
360
+ delay?: number;
361
+ backoff?: number;
362
+ };
363
+ }
364
+ /**
365
+ * Emitted when response headers are received (first byte)
366
+ * Provides response metadata before body is processed
367
+ */
368
+ export interface ResponseHeadersEvent {
369
+ /** HTTP status code */
370
+ status: number;
371
+ /** HTTP status text */
372
+ statusText: string;
373
+ /** Response headers */
374
+ headers: RezoHeaders;
375
+ /** Content-Type header value */
376
+ contentType?: string;
377
+ /** Content-Length header value (bytes) */
378
+ contentLength?: number;
379
+ /** Cookies from Set-Cookie headers */
380
+ cookies?: Cookie[];
381
+ /** Timing information */
382
+ timing: {
383
+ /** Time to first byte (TTFB) in milliseconds */
384
+ firstByte: number;
385
+ /** Total time elapsed so far in milliseconds */
386
+ total: number;
387
+ };
388
+ }
389
+ /**
390
+ * Emitted AFTER a redirect is followed
391
+ * Provides complete redirect information
392
+ */
393
+ export interface RedirectEvent {
394
+ /** Source URL (where we're redirecting FROM) */
395
+ sourceUrl: string;
396
+ /** Source HTTP status code */
397
+ sourceStatus: number;
398
+ /** Source HTTP status text */
399
+ sourceStatusText: string;
400
+ /** Destination URL (where we're redirecting TO) */
401
+ destinationUrl: string;
402
+ /** Number of redirects followed so far */
403
+ redirectCount: number;
404
+ /** Maximum redirects allowed */
405
+ maxRedirects: number;
406
+ /** Response headers from redirect response */
407
+ headers: RezoHeaders;
408
+ /** Cookies from redirect response */
409
+ cookies: Cookie[];
410
+ /** HTTP method used for the redirect */
411
+ method: string;
412
+ /** Timestamp when redirect occurred */
413
+ timestamp: number;
414
+ /** Duration of this redirect in milliseconds */
415
+ duration: number;
416
+ }
417
+ interface ProgressEvent$1 {
418
+ /** Bytes transferred so far */
419
+ loaded: number;
420
+ /** Total bytes (from Content-Length or file size) */
421
+ total: number;
422
+ /** Progress percentage (0-100) */
423
+ percentage: number;
424
+ /** Current transfer speed in bytes/second */
425
+ speed: number;
426
+ /** Average transfer speed in bytes/second */
427
+ averageSpeed: number;
428
+ /** Estimated time remaining in milliseconds */
429
+ estimatedTime: number;
430
+ /** Timestamp of this progress update */
431
+ timestamp: number;
432
+ }
433
+ /**
434
+ * Emitted when StreamResponse completes
435
+ * Body has already been emitted via 'data' events
436
+ */
437
+ export interface StreamFinishEvent {
438
+ /** HTTP status code */
439
+ status: number;
440
+ /** HTTP status text */
441
+ statusText: string;
442
+ /** Response headers */
443
+ headers: RezoHeaders;
444
+ /** Content-Type header value */
445
+ contentType?: string;
446
+ /** Content-Length (bytes received) */
447
+ contentLength: number;
448
+ /** Final URL after redirects */
449
+ finalUrl: string;
450
+ /** Cookies received */
451
+ cookies: Cookies;
452
+ /** All URLs traversed (includes redirects) */
453
+ urls: string[];
454
+ /** Timing breakdown */
455
+ timing: {
456
+ /** Total request time in milliseconds */
457
+ total: number;
458
+ /** DNS lookup time in milliseconds */
459
+ dns?: number;
460
+ /** TCP connection time in milliseconds */
461
+ tcp?: number;
462
+ /** TLS handshake time in milliseconds */
463
+ tls?: number;
464
+ /** Time to first byte in milliseconds */
465
+ firstByte?: number;
466
+ /** Content download time in milliseconds */
467
+ download?: number;
468
+ };
469
+ /** Response configuration (execution metadata) */
470
+ config: SanitizedRezoConfig;
471
+ }
472
+ /**
473
+ * Emitted when DownloadResponse completes
474
+ * Body has been saved to file
475
+ */
476
+ export interface DownloadFinishEvent {
477
+ /** HTTP status code */
478
+ status: number;
479
+ /** HTTP status text */
480
+ statusText: string;
481
+ /** Response headers */
482
+ headers: RezoHeaders;
483
+ /** Content-Type header value */
484
+ contentType?: string;
485
+ /** Content-Length (bytes downloaded) */
486
+ contentLength: number;
487
+ /** Final URL after redirects */
488
+ finalUrl: string;
489
+ /** Cookies received */
490
+ cookies: Cookies;
491
+ /** All URLs traversed (includes redirects) */
492
+ urls: string[];
493
+ /**
494
+ * File name (supports both basename and fullname)
495
+ * - For fileName: 'report.pdf' → returns 'report.pdf'
496
+ * - For saveTo: '/path/to/report.pdf' → returns '/path/to/report.pdf'
497
+ */
498
+ fileName: string;
499
+ /** File size in bytes */
500
+ fileSize: number;
501
+ /** Timing breakdown */
502
+ timing: {
503
+ /** Total request time in milliseconds */
504
+ total: number;
505
+ /** DNS lookup time in milliseconds */
506
+ dns?: number;
507
+ /** TCP connection time in milliseconds */
508
+ tcp?: number;
509
+ /** TLS handshake time in milliseconds */
510
+ tls?: number;
511
+ /** Time to first byte in milliseconds */
512
+ firstByte?: number;
513
+ /** Download duration in milliseconds */
514
+ download: number;
515
+ };
516
+ /** Average download speed in bytes/second */
517
+ averageSpeed: number;
518
+ /** Response configuration (execution metadata) */
519
+ config: SanitizedRezoConfig;
520
+ }
521
+ /**
522
+ * Emitted when UploadResponse completes
523
+ * Includes server's response body
524
+ */
525
+ export interface UploadFinishEvent {
526
+ /** Server's response to our upload */
527
+ response: {
528
+ /** HTTP status code */
529
+ status: number;
530
+ /** HTTP status text */
531
+ statusText: string;
532
+ /** Response headers */
533
+ headers: RezoHeaders;
534
+ /** Response body from server */
535
+ data: any;
536
+ /** Content-Type header value */
537
+ contentType?: string;
538
+ /** Response content length */
539
+ contentLength?: number;
540
+ };
541
+ /** Final URL after redirects */
542
+ finalUrl: string;
543
+ /** Cookies received */
544
+ cookies: Cookies;
545
+ /** All URLs traversed (includes redirects) */
546
+ urls: string[];
547
+ /** Upload size in bytes */
548
+ uploadSize: number;
549
+ /** File name if uploading a file */
550
+ fileName?: string;
551
+ /** Timing breakdown */
552
+ timing: {
553
+ /** Total request time in milliseconds */
554
+ total: number;
555
+ /** DNS lookup time in milliseconds */
556
+ dns?: number;
557
+ /** TCP connection time in milliseconds */
558
+ tcp?: number;
559
+ /** TLS handshake time in milliseconds */
560
+ tls?: number;
561
+ /** Upload duration in milliseconds */
562
+ upload: number;
563
+ /** Time waiting for server response in milliseconds */
564
+ waiting: number;
565
+ /** Response download time in milliseconds */
566
+ download?: number;
567
+ };
568
+ /** Average upload speed in bytes/second */
569
+ averageUploadSpeed: number;
570
+ /** Average download speed in bytes/second (for response) */
571
+ averageDownloadSpeed?: number;
572
+ /** Response configuration (execution metadata) */
573
+ config: SanitizedRezoConfig;
574
+ }
575
+ /**
576
+ * Sanitized RezoConfig for event emission
577
+ * Excludes only request body/data, includes all metadata
578
+ */
579
+ export type SanitizedRezoConfig = Omit<RezoConfig, "data"> & {
580
+ /** Data field explicitly removed */
581
+ data?: never;
582
+ };
583
+ /**
584
+ * Event map for StreamResponse - defines all available events and their signatures
585
+ */
586
+ export interface StreamResponseEvents {
587
+ close: [
588
+ ];
589
+ drain: [
590
+ ];
591
+ error: [
592
+ err: RezoError
593
+ ];
594
+ finish: [
595
+ info: StreamFinishEvent
596
+ ];
597
+ done: [
598
+ info: StreamFinishEvent
599
+ ];
600
+ start: [
601
+ info: RequestStartEvent
602
+ ];
603
+ initiated: [
604
+ ];
605
+ headers: [
606
+ info: ResponseHeadersEvent
607
+ ];
608
+ cookies: [
609
+ cookies: Cookie[]
610
+ ];
611
+ status: [
612
+ status: number,
613
+ statusText: string
614
+ ];
615
+ redirect: [
616
+ info: RedirectEvent
617
+ ];
618
+ progress: [
619
+ progress: ProgressEvent$1
620
+ ];
621
+ data: [
622
+ chunk: Buffer | string
623
+ ];
624
+ pipe: [
625
+ src: Readable
626
+ ];
627
+ unpipe: [
628
+ src: Readable
629
+ ];
630
+ }
631
+ /**
632
+ * Complete type-safe event method overrides for StreamResponse
633
+ * All event listener methods return 'this' for chaining
634
+ */
635
+ export interface StreamResponseEventOverrides {
636
+ on<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
637
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
638
+ once<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
639
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
640
+ addListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
641
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
642
+ prependListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
643
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
644
+ prependOnceListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
645
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
646
+ }
647
+ declare class StreamResponse extends Writable implements StreamResponseEventOverrides {
648
+ private _finished;
649
+ private _encoding?;
650
+ constructor(opts?: WritableOptions);
651
+ /**
652
+ * Set encoding for string chunks
653
+ * @param encoding - Buffer encoding (utf8, ascii, etc.)
654
+ * @returns this for chaining
655
+ */
656
+ setEncoding(encoding: BufferEncoding): this;
657
+ /**
658
+ * Get current encoding
659
+ */
660
+ getEncoding(): BufferEncoding | undefined;
661
+ /**
662
+ * Check if stream has finished
663
+ */
664
+ isFinished(): boolean;
665
+ /**
666
+ * Mark stream as finished (internal use)
667
+ * @internal
668
+ */
669
+ _markFinished(): void;
670
+ /**
671
+ * Internal write implementation required by Writable
672
+ * Emits 'data' event for each chunk received
673
+ * @internal
674
+ */
675
+ _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
676
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
677
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
678
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
679
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
680
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
681
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
682
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
683
+ removeAllListeners(event?: string | symbol): this;
684
+ }
685
+ /**
686
+ * Complete type-safe event method overrides for DownloadResponse
687
+ * All event listener methods return 'this' for chaining
688
+ */
689
+ export interface DownloadResponseEventOverrides {
690
+ on(event: "error", listener: (err: RezoError) => void): this;
691
+ on(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
692
+ on(event: "done", listener: (info: DownloadFinishEvent) => void): this;
693
+ on(event: "start", listener: (info: RequestStartEvent) => void): this;
694
+ on(event: "initiated", listener: () => void): this;
695
+ on(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
696
+ on(event: "cookies", listener: (cookies: Cookie[]) => void): this;
697
+ on(event: "status", listener: (status: number, statusText: string) => void): this;
698
+ on(event: "redirect", listener: (info: RedirectEvent) => void): this;
699
+ on(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
700
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
701
+ once(event: "error", listener: (err: RezoError) => void): this;
702
+ once(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
703
+ once(event: "done", listener: (info: DownloadFinishEvent) => void): this;
704
+ once(event: "start", listener: (info: RequestStartEvent) => void): this;
705
+ once(event: "initiated", listener: () => void): this;
706
+ once(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
707
+ once(event: "cookies", listener: (cookies: Cookie[]) => void): this;
708
+ once(event: "status", listener: (status: number, statusText: string) => void): this;
709
+ once(event: "redirect", listener: (info: RedirectEvent) => void): this;
710
+ once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
711
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
712
+ addListener(event: "error", listener: (err: RezoError) => void): this;
713
+ addListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
714
+ addListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
715
+ addListener(event: "start", listener: (info: RequestStartEvent) => void): this;
716
+ addListener(event: "initiated", listener: () => void): this;
717
+ addListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
718
+ addListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
719
+ addListener(event: "status", listener: (status: number, statusText: string) => void): this;
720
+ addListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
721
+ addListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
722
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
723
+ prependListener(event: "error", listener: (err: RezoError) => void): this;
724
+ prependListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
725
+ prependListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
726
+ prependListener(event: "start", listener: (info: RequestStartEvent) => void): this;
727
+ prependListener(event: "initiated", listener: () => void): this;
728
+ prependListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
729
+ prependListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
730
+ prependListener(event: "status", listener: (status: number, statusText: string) => void): this;
731
+ prependListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
732
+ prependListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
733
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
734
+ prependOnceListener(event: "error", listener: (err: RezoError) => void): this;
735
+ prependOnceListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
736
+ prependOnceListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
737
+ prependOnceListener(event: "start", listener: (info: RequestStartEvent) => void): this;
738
+ prependOnceListener(event: "initiated", listener: () => void): this;
739
+ prependOnceListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
740
+ prependOnceListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
741
+ prependOnceListener(event: "status", listener: (status: number, statusText: string) => void): this;
742
+ prependOnceListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
743
+ prependOnceListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
744
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
745
+ }
746
+ declare class DownloadResponse extends EventEmitter implements DownloadResponseEventOverrides {
747
+ /** File name (basename or fullname) */
748
+ fileName: string;
749
+ /** Target URL */
750
+ url: string;
751
+ /** HTTP status code (set when headers received) */
752
+ status?: number;
753
+ /** HTTP status text (set when headers received) */
754
+ statusText?: string;
755
+ private _finished;
756
+ constructor(fileName: string, url: string);
757
+ /**
758
+ * Check if download has finished
759
+ */
760
+ isFinished(): boolean;
761
+ /**
762
+ * Mark download as finished (internal use)
763
+ * @internal
764
+ */
765
+ _markFinished(): void;
766
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
767
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
768
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
769
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
770
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
771
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
772
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
773
+ removeAllListeners(event?: string | symbol): this;
774
+ }
775
+ /**
776
+ * Complete type-safe event method overrides for UploadResponse
777
+ * All event listener methods return 'this' for chaining
778
+ */
779
+ export interface UploadResponseEventOverrides {
780
+ on(event: "error", listener: (err: RezoError) => void): this;
781
+ on(event: "finish", listener: (info: UploadFinishEvent) => void): this;
782
+ on(event: "done", listener: (info: UploadFinishEvent) => void): this;
783
+ on(event: "start", listener: (info: RequestStartEvent) => void): this;
784
+ on(event: "initiated", listener: () => void): this;
785
+ on(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
786
+ on(event: "cookies", listener: (cookies: Cookie[]) => void): this;
787
+ on(event: "status", listener: (status: number, statusText: string) => void): this;
788
+ on(event: "redirect", listener: (info: RedirectEvent) => void): this;
789
+ on(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
790
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
791
+ once(event: "error", listener: (err: RezoError) => void): this;
792
+ once(event: "finish", listener: (info: UploadFinishEvent) => void): this;
793
+ once(event: "done", listener: (info: UploadFinishEvent) => void): this;
794
+ once(event: "start", listener: (info: RequestStartEvent) => void): this;
795
+ once(event: "initiated", listener: () => void): this;
796
+ once(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
797
+ once(event: "cookies", listener: (cookies: Cookie[]) => void): this;
798
+ once(event: "status", listener: (status: number, statusText: string) => void): this;
799
+ once(event: "redirect", listener: (info: RedirectEvent) => void): this;
800
+ once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
801
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
802
+ addListener(event: "error", listener: (err: RezoError) => void): this;
803
+ addListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
804
+ addListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
805
+ addListener(event: "start", listener: (info: RequestStartEvent) => void): this;
806
+ addListener(event: "initiated", listener: () => void): this;
807
+ addListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
808
+ addListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
809
+ addListener(event: "status", listener: (status: number, statusText: string) => void): this;
810
+ addListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
811
+ addListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
812
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
813
+ prependListener(event: "error", listener: (err: RezoError) => void): this;
814
+ prependListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
815
+ prependListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
816
+ prependListener(event: "start", listener: (info: RequestStartEvent) => void): this;
817
+ prependListener(event: "initiated", listener: () => void): this;
818
+ prependListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
819
+ prependListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
820
+ prependListener(event: "status", listener: (status: number, statusText: string) => void): this;
821
+ prependListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
822
+ prependListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
823
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
824
+ prependOnceListener(event: "error", listener: (err: RezoError) => void): this;
825
+ prependOnceListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
826
+ prependOnceListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
827
+ prependOnceListener(event: "start", listener: (info: RequestStartEvent) => void): this;
828
+ prependOnceListener(event: "initiated", listener: () => void): this;
829
+ prependOnceListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
830
+ prependOnceListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
831
+ prependOnceListener(event: "status", listener: (status: number, statusText: string) => void): this;
832
+ prependOnceListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
833
+ prependOnceListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
834
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
835
+ }
836
+ declare class UploadResponse extends EventEmitter implements UploadResponseEventOverrides {
837
+ /** Target URL */
838
+ url: string;
839
+ /** File name if uploading a file */
840
+ fileName?: string;
841
+ /** HTTP status code (set when headers received) */
842
+ status?: number;
843
+ /** HTTP status text (set when headers received) */
844
+ statusText?: string;
845
+ private _finished;
846
+ constructor(url: string, fileName?: string);
847
+ /**
848
+ * Check if upload has finished
849
+ */
850
+ isFinished(): boolean;
851
+ /**
852
+ * Mark upload as finished (internal use)
853
+ * @internal
854
+ */
855
+ _markFinished(): void;
856
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
857
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
858
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
859
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
860
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
861
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
862
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
863
+ removeAllListeners(event?: string | symbol): this;
864
+ }
865
+ /**
866
+ * Standard RezoResponse for non-streaming requests
867
+ * Contains response data, status, headers, cookies, and execution metadata
868
+ */
869
+ export interface RezoResponse<T = any> {
870
+ data: T;
871
+ status: number;
872
+ statusText: string;
873
+ finalUrl: string;
874
+ cookies: Cookies;
875
+ headers: RezoHeaders;
876
+ contentType: string | undefined;
877
+ contentLength: number;
878
+ urls: string[];
879
+ config: RezoConfig;
880
+ }
881
+ /**
882
+ * RezoStreamResponse - For responseType: 'stream'
883
+ * Extends StreamResponse class (EventEmitter)
884
+ * Emits 'data' events for response body chunks
885
+ */
886
+ export interface RezoStreamResponse extends StreamResponse {
887
+ }
888
+ /**
889
+ * RezoDownloadResponse - For fileName/saveTo options
890
+ * Extends DownloadResponse class (EventEmitter)
891
+ * Streams response body directly to file
892
+ */
893
+ export interface RezoDownloadResponse extends DownloadResponse {
894
+ }
895
+ /**
896
+ * RezoUploadResponse - For responseType: 'upload'
897
+ * Extends UploadResponse class (EventEmitter)
898
+ * Tracks upload progress and includes server response body
899
+ */
900
+ export interface RezoUploadResponse extends UploadResponse {
901
+ }
902
+ /**
903
+ * Context provided to beforeRequest hook
904
+ * Contains metadata about the current request state
905
+ */
906
+ export interface BeforeRequestContext {
907
+ /** Current retry count (0 for initial request, 1+ for retries) */
908
+ retryCount: number;
909
+ /** Whether this is a redirect follow-up request */
910
+ isRedirect: boolean;
911
+ /** Number of redirects followed so far */
912
+ redirectCount: number;
913
+ /** Timestamp when request processing started */
914
+ startTime: number;
915
+ }
916
+ /**
917
+ * Context provided to afterResponse hook
918
+ * Includes retry capability for token refresh scenarios
919
+ */
920
+ export interface AfterResponseContext {
921
+ /** Current retry count */
922
+ retryCount: number;
923
+ /** Function to retry request with merged options */
924
+ retryWithMergedOptions: (options: Partial<RezoRequestConfig>) => never;
925
+ }
926
+ /**
927
+ * DNS resolution event data
928
+ */
929
+ export interface DnsLookupEvent {
930
+ /** Hostname being resolved */
931
+ hostname: string;
932
+ /** Resolved IP address */
933
+ address: string;
934
+ /** Address family (4 for IPv4, 6 for IPv6) */
935
+ family: 4 | 6;
936
+ /** DNS lookup duration in milliseconds */
937
+ duration: number;
938
+ /** Timestamp when lookup completed */
939
+ timestamp: number;
940
+ }
941
+ /**
942
+ * TLS handshake event data
943
+ */
944
+ export interface TlsHandshakeEvent {
945
+ /** TLS protocol version (TLSv1.2, TLSv1.3, etc.) */
946
+ protocol: string;
947
+ /** Cipher suite used */
948
+ cipher: string;
949
+ /** Whether certificate is authorized */
950
+ authorized: boolean;
951
+ /** Authorization error if any */
952
+ authorizationError?: string;
953
+ /** Server certificate info */
954
+ certificate?: {
955
+ subject: string;
956
+ issuer: string;
957
+ validFrom: string;
958
+ validTo: string;
959
+ fingerprint: string;
960
+ };
961
+ /** Handshake duration in milliseconds */
962
+ duration: number;
963
+ /** Timestamp when handshake completed */
964
+ timestamp: number;
965
+ }
966
+ /**
967
+ * Socket event data
968
+ */
969
+ export interface SocketEvent {
970
+ /** Event type */
971
+ type: "connect" | "close" | "drain" | "error" | "timeout" | "end";
972
+ /** Local address */
973
+ localAddress?: string;
974
+ /** Local port */
975
+ localPort?: number;
976
+ /** Remote address */
977
+ remoteAddress?: string;
978
+ /** Remote port */
979
+ remotePort?: number;
980
+ /** Bytes written */
981
+ bytesWritten?: number;
982
+ /** Bytes read */
983
+ bytesRead?: number;
984
+ /** Error if applicable */
985
+ error?: Error;
986
+ /** Timestamp */
987
+ timestamp: number;
988
+ }
989
+ /**
990
+ * Timeout event data
991
+ */
992
+ export interface TimeoutEvent {
993
+ /** Type of timeout */
994
+ type: "connect" | "request" | "response" | "socket" | "lookup";
995
+ /** Configured timeout value in milliseconds */
996
+ timeout: number;
997
+ /** Elapsed time before timeout in milliseconds */
998
+ elapsed: number;
999
+ /** URL being requested */
1000
+ url: string;
1001
+ /** Timestamp when timeout occurred */
1002
+ timestamp: number;
1003
+ }
1004
+ /**
1005
+ * Abort event data
1006
+ */
1007
+ export interface AbortEvent {
1008
+ /** Reason for abort */
1009
+ reason: "user" | "timeout" | "signal" | "error";
1010
+ /** Abort message */
1011
+ message?: string;
1012
+ /** URL being requested */
1013
+ url: string;
1014
+ /** Elapsed time before abort in milliseconds */
1015
+ elapsed: number;
1016
+ /** Timestamp when abort occurred */
1017
+ timestamp: number;
1018
+ }
1019
+ /**
1020
+ * Headers received event data (before body)
1021
+ */
1022
+ export interface HeadersReceivedEvent {
1023
+ /** HTTP status code */
1024
+ status: number;
1025
+ /** HTTP status text */
1026
+ statusText: string;
1027
+ /** Response headers */
1028
+ headers: RezoHeaders;
1029
+ /** Content-Type header */
1030
+ contentType?: string;
1031
+ /** Content-Length header */
1032
+ contentLength?: number;
1033
+ /** Time to first byte in milliseconds */
1034
+ ttfb: number;
1035
+ /** Timestamp */
1036
+ timestamp: number;
1037
+ }
1038
+ /**
1039
+ * Parse complete event data
1040
+ */
1041
+ export interface ParseCompleteEvent<T = any> {
1042
+ /** Parsed data */
1043
+ data: T;
1044
+ /** Original raw data before parsing */
1045
+ rawData: string | Buffer;
1046
+ /** Content-Type that triggered parsing */
1047
+ contentType: string;
1048
+ /** Parse duration in milliseconds */
1049
+ parseDuration: number;
1050
+ /** Timestamp */
1051
+ timestamp: number;
1052
+ }
1053
+ /**
1054
+ * Cache event data
1055
+ */
1056
+ export interface CacheEvent {
1057
+ /** HTTP status code */
1058
+ status: number;
1059
+ /** Response headers */
1060
+ headers: RezoHeaders;
1061
+ /** URL being cached */
1062
+ url: string;
1063
+ /** Cache key if applicable */
1064
+ cacheKey?: string;
1065
+ /** Whether response is cacheable by default */
1066
+ isCacheable: boolean;
1067
+ /** Cache-Control header parsed */
1068
+ cacheControl?: {
1069
+ maxAge?: number;
1070
+ sMaxAge?: number;
1071
+ noCache?: boolean;
1072
+ noStore?: boolean;
1073
+ mustRevalidate?: boolean;
1074
+ private?: boolean;
1075
+ public?: boolean;
1076
+ };
1077
+ }
1078
+ /**
1079
+ * Cookie event data
1080
+ */
1081
+ export interface CookieEvent {
1082
+ /** Cookie being set/processed */
1083
+ cookie: Cookie;
1084
+ /** Source of cookie (response header, manual set, etc.) */
1085
+ source: "response" | "request" | "manual";
1086
+ /** URL context */
1087
+ url: string;
1088
+ /** Whether cookie is valid */
1089
+ isValid: boolean;
1090
+ /** Validation errors if any */
1091
+ validationErrors?: string[];
1092
+ }
1093
+ /**
1094
+ * Hook called during options initialization
1095
+ * Use to normalize or validate request options
1096
+ * Must be synchronous
1097
+ */
1098
+ export type InitHook = (plainOptions: Partial<RezoRequestConfig>, options: RezoRequestConfig) => void;
1099
+ /**
1100
+ * Hook called before request is sent
1101
+ * Use to modify config, add headers, sign requests
1102
+ * Can return early with a Response to bypass actual request
1103
+ */
1104
+ export type BeforeRequestHook = (config: RezoConfig, context: BeforeRequestContext) => void | Response | Promise<void | Response>;
1105
+ /**
1106
+ * Hook called before following a redirect
1107
+ * Use to inspect/modify redirect behavior
1108
+ */
1109
+ export type BeforeRedirectHook = (config: RezoConfig, response: RezoResponse) => void | Promise<void>;
1110
+ /**
1111
+ * Hook called before a retry attempt
1112
+ * Use for custom backoff logic, logging
1113
+ */
1114
+ export type BeforeRetryHook = (config: RezoConfig, error: RezoError, retryCount: number) => void | Promise<void>;
1115
+ /**
1116
+ * Hook called after response is received
1117
+ * Use to transform response, refresh tokens
1118
+ * Can trigger retry via context.retryWithMergedOptions
1119
+ * Return modified response or original
1120
+ */
1121
+ export type AfterResponseHook<T = any> = (response: RezoResponse<T>, config: RezoConfig, context: AfterResponseContext) => RezoResponse<T> | Promise<RezoResponse<T>>;
1122
+ /**
1123
+ * Hook called before error is thrown
1124
+ * Use to transform errors, add context
1125
+ * Can return custom Error subclasses
1126
+ */
1127
+ export type BeforeErrorHook = (error: RezoError | Error) => RezoError | Error | Promise<RezoError | Error>;
1128
+ /**
1129
+ * Hook called before caching a response
1130
+ * Return false to prevent caching
1131
+ * Can modify response headers to affect caching behavior
1132
+ */
1133
+ export type BeforeCacheHook = (event: CacheEvent) => boolean | void;
1134
+ /**
1135
+ * Hook called when response headers are received (before body)
1136
+ * Use to inspect headers, abort early, prepare for response
1137
+ */
1138
+ export type AfterHeadersHook = (event: HeadersReceivedEvent, config: RezoConfig) => void | Promise<void>;
1139
+ /**
1140
+ * Hook called after response body is parsed
1141
+ * Use to transform parsed data, validate response
1142
+ */
1143
+ export type AfterParseHook<T = any> = (event: ParseCompleteEvent<T>, config: RezoConfig) => T | Promise<T>;
1144
+ /**
1145
+ * Hook called before a cookie is set
1146
+ * Return false to reject the cookie
1147
+ * Can modify cookie properties
1148
+ */
1149
+ export type BeforeCookieHook = (event: CookieEvent, config: RezoConfig) => boolean | void | Promise<boolean | void>;
1150
+ /**
1151
+ * Hook called after cookies are processed
1152
+ * Use for cookie logging, analytics
1153
+ */
1154
+ export type AfterCookieHook = (cookies: Cookie[], config: RezoConfig) => void | Promise<void>;
1155
+ /**
1156
+ * Hook called on socket events
1157
+ * Use for connection monitoring, metrics
1158
+ */
1159
+ export type OnSocketHook = (event: SocketEvent, socket: Socket | TLSSocket) => void;
1160
+ /**
1161
+ * Hook called when DNS lookup completes
1162
+ * Use for DNS caching, logging, analytics
1163
+ */
1164
+ export type OnDnsHook = (event: DnsLookupEvent, config: RezoConfig) => void;
1165
+ /**
1166
+ * Hook called when TLS handshake completes
1167
+ * Use for certificate validation, security logging
1168
+ */
1169
+ export type OnTlsHook = (event: TlsHandshakeEvent, config: RezoConfig) => void;
1170
+ /**
1171
+ * Hook called when timeout occurs
1172
+ * Use for timeout logging, retry decisions
1173
+ */
1174
+ export type OnTimeoutHook = (event: TimeoutEvent, config: RezoConfig) => void;
1175
+ /**
1176
+ * Hook called when request is aborted
1177
+ * Use for cleanup, logging
1178
+ */
1179
+ export type OnAbortHook = (event: AbortEvent, config: RezoConfig) => void;
1180
+ /**
1181
+ * Collection of all hook types
1182
+ * All hooks are arrays to allow multiple handlers
1183
+ */
1184
+ export interface RezoHooks {
1185
+ init: InitHook[];
1186
+ beforeRequest: BeforeRequestHook[];
1187
+ beforeRedirect: BeforeRedirectHook[];
1188
+ beforeRetry: BeforeRetryHook[];
1189
+ afterResponse: AfterResponseHook[];
1190
+ beforeError: BeforeErrorHook[];
1191
+ beforeCache: BeforeCacheHook[];
1192
+ afterHeaders: AfterHeadersHook[];
1193
+ afterParse: AfterParseHook[];
1194
+ beforeCookie: BeforeCookieHook[];
1195
+ afterCookie: AfterCookieHook[];
1196
+ onSocket: OnSocketHook[];
1197
+ onDns: OnDnsHook[];
1198
+ onTls: OnTlsHook[];
1199
+ onTimeout: OnTimeoutHook[];
1200
+ onAbort: OnAbortHook[];
1201
+ }
1202
+ /**
1203
+ * Create empty hooks object with all arrays initialized
1204
+ */
1205
+ export declare function createDefaultHooks(): RezoHooks;
1206
+ /**
1207
+ * Merge base hooks with override hooks
1208
+ * Overrides are appended to base hooks (base runs first)
1209
+ */
1210
+ export declare function mergeHooks(base: RezoHooks, overrides?: Partial<RezoHooks>): RezoHooks;
1211
+ /**
1212
+ * Configuration object that encapsulates comprehensive request execution metadata and response processing information.
1213
+ * This interface serves as the central configuration hub for HTTP requests, containing both input parameters
1214
+ * and execution tracking data throughout the request lifecycle.
1215
+ *
1216
+ * @interface RezoConfig
1217
+ * @since 1.0.0
1218
+ * @example
1219
+ * ```typescript
1220
+ * const config: RezoConfig = {
1221
+ * originalRequest: requestConfig,
1222
+ * finalUrl: 'https://api.example.com/data',
1223
+ * adapterUsed: 'fetch',
1224
+ * timing: { startTime: Date.now(), endTime: Date.now() + 1000, total: 1000 },
1225
+ * network: { protocol: 'https' },
1226
+ * transfer: { requestSize: 256, responseSize: 1024, headerSize: 128, bodySize: 896 },
1227
+ * retryAttempts: 0,
1228
+ * errors: [],
1229
+ * security: {},
1230
+ * metadata: {}
1231
+ * };
1232
+ * ```
1233
+ */
1234
+ export interface RezoConfig {
1235
+ /** @description The target URL for the HTTP request */
1236
+ url: string;
1237
+ /** @description HTTP method (GET, POST, PUT, DELETE, etc.) */
1238
+ method: RezoRequestConfig["method"];
1239
+ /** @description HTTP headers to be sent with the request */
1240
+ headers: RezoHeaders;
1241
+ /** @description Request payload data (null when not set) */
1242
+ data?: RezoRequestConfig["body"] | null;
1243
+ /** @description URL query parameters */
1244
+ params?: RezoRequestConfig["params"];
1245
+ /** @description Request timeout in milliseconds (null when not set) */
1246
+ timeout?: number | null;
1247
+ /** @description Expected response data type */
1248
+ responseType?: "json" | "text" | "blob" | "arrayBuffer" | "stream" | "download" | "upload" | "buffer" | "binary";
1249
+ /** @description Basic authentication credentials (null when not set) */
1250
+ auth?: RezoRequestConfig["auth"] | null;
1251
+ /** @description Proxy configuration (null when not set) */
1252
+ proxy?: RezoRequestConfig["proxy"] | null;
1253
+ /** @description Maximum number of redirects to follow */
1254
+ maxRedirects: number;
1255
+ /** @description Base URL for relative requests */
1256
+ baseURL?: string;
1257
+ /** @description Enable HTTP/2 protocol */
1258
+ http2: boolean;
1259
+ /** @description Enable cURL command generation */
1260
+ curl: boolean;
1261
+ /** @description Enable detection of redirect cycles */
1262
+ enableRedirectCycleDetection?: boolean;
1263
+ /** @description Reject unauthorized SSL certificates */
1264
+ rejectUnauthorized?: boolean;
1265
+ /** @description Retry configuration */
1266
+ retry?: RezoRequestConfig["retry"];
1267
+ /** @description Compression settings */
1268
+ compression?: {
1269
+ /** @description Enable compression */
1270
+ enabled?: boolean;
1271
+ /** @description Compression threshold in bytes */
1272
+ threshold?: number;
1273
+ /** @description Supported compression algorithms */
1274
+ algorithms?: string[];
1275
+ };
1276
+ /** @description Enable cookie jar for session management */
1277
+ enableCookieJar?: boolean;
1278
+ /** @description Feature flags for adapter capabilities */
1279
+ features?: {
1280
+ /** @description HTTP/2 support */
1281
+ http2?: boolean;
1282
+ /** @description Compression support */
1283
+ compression?: boolean;
1284
+ /** @description Cookie support */
1285
+ cookies?: boolean;
1286
+ /** @description Redirect support */
1287
+ redirects?: boolean;
1288
+ /** @description Proxy support */
1289
+ proxy?: boolean;
1290
+ /** @description Timeout support */
1291
+ timeout?: boolean;
1292
+ /** @description Retry support */
1293
+ retry?: boolean;
1294
+ /** @description Cache support */
1295
+ cache?: boolean;
1296
+ /** @description Metrics support */
1297
+ metrics?: boolean;
1298
+ /** @description Event support */
1299
+ events?: boolean;
1300
+ /** @description Validation support */
1301
+ validation?: boolean;
1302
+ /** @description Browser support */
1303
+ browser?: boolean;
1304
+ /** @description SSL support */
1305
+ ssl?: boolean;
1306
+ };
1307
+ /** @description Use insecure HTTP parser */
1308
+ insecureHTTPParser: boolean;
1309
+ /** @description Custom adapter implementation */
1310
+ adapter?: any;
1311
+ isSecure?: boolean;
1312
+ /**
1313
+ * @description Rate limiting for network transfer speed (bandwidth throttling)
1314
+ *
1315
+ * Controls the maximum transfer speed in bytes per second.
1316
+ *
1317
+ * - `number`: Applies same limit to both download and upload (e.g., 1024000 = ~1MB/s)
1318
+ * - `[download, upload]`: Different limits for each direction (e.g., [5242880, 1048576] = 5MB/s down, 1MB/s up)
1319
+ * - `0` or `null`: No rate limiting (unlimited speed)
1320
+ *
1321
+ * Common values:
1322
+ * - 1048576 = 1 MB/s
1323
+ * - 5242880 = 5 MB/s
1324
+ * - 10485760 = 10 MB/s
1325
+ *
1326
+ * Note: Actual transfer speed may vary based on network conditions and adapter support.
1327
+ * This feature is adapter-dependent (HTTP adapter supports it, other adapters may vary).
1328
+ */
1329
+ maxRate: number | [
1330
+ number,
1331
+ number
1332
+ ];
1333
+ /** @description Cancellation token for request abortion (null when not set) */
1334
+ cancelToken?: any | null;
1335
+ /** @description AbortSignal for request cancellation (null when not set) */
1336
+ signal?: AbortSignal | null;
1337
+ /** @description Function to set the AbortSignal */
1338
+ setSignal: () => void;
1339
+ /** @description HTTP agent for connection pooling (null when not set) */
1340
+ httpAgent?: RezoRequestConfig["httpAgent"] | null;
1341
+ /** @description HTTPS agent for secure connection pooling (null when not set) */
1342
+ httpsAgent?: RezoRequestConfig["httpsAgent"] | null;
1343
+ /** @description Unix socket path (null when not set) */
1344
+ socketPath?: string | null;
1345
+ /** @description File path to save the response (null when not set) */
1346
+ fileName?: string | null;
1347
+ /**
1348
+ * Array of cookies to be sent with the request.
1349
+ * These cookies are configured before the request is made and will be included in the request headers.
1350
+ */
1351
+ requestCookies: Cookie[];
1352
+ /**
1353
+ * Cookies received from the server in the response.
1354
+ * These cookies are parsed from the 'Set-Cookie' response headers and can be used for subsequent requests
1355
+ * or session management. Contains multiple formats: array, serialized, netscape, string, setCookiesString.
1356
+ */
1357
+ responseCookies: Cookies;
1358
+ /**
1359
+ * Path to cookie file for persistence (null when not configured).
1360
+ * - .json files save cookies as serialized JSON
1361
+ * - .txt files save cookies in Netscape format
1362
+ */
1363
+ cookieFile?: string | null;
1364
+ /**
1365
+ * Request lifecycle hooks for intercepting and modifying request/response behavior.
1366
+ * null when no hooks are registered, otherwise contains only hooks with registered functions.
1367
+ * Empty arrays are not included - only hooks with actual handlers appear.
1368
+ *
1369
+ * Available hooks:
1370
+ * - init: During options initialization
1371
+ * - beforeRequest: Before request is sent
1372
+ * - beforeRedirect: Before following redirects
1373
+ * - beforeRetry: Before retry attempts
1374
+ * - afterResponse: After response is received
1375
+ * - beforeError: Before error is thrown
1376
+ * - beforeCache: Before caching response
1377
+ * - afterHeaders: When headers are received
1378
+ * - afterParse: After body is parsed
1379
+ * - beforeCookie/afterCookie: Cookie lifecycle
1380
+ * - onSocket/onDns/onTls/onTimeout/onAbort: Low-level events
1381
+ */
1382
+ hooks: Partial<RezoHooks> | null;
1383
+ /** @description Snapshot of the original request configuration */
1384
+ originalRequest: RezoRequestConfig;
1385
+ /** @description Final resolved URL after redirects and processing */
1386
+ finalUrl: string;
1387
+ /** @description HTTP adapter used for the request */
1388
+ adapterUsed: "http" | "https" | "http2" | "fetch" | "xhr" | "curl";
1389
+ /** @description Metadata about the adapter used */
1390
+ adapterMetadata?: {
1391
+ /** @description Adapter version */
1392
+ version?: string;
1393
+ /** @description Supported features */
1394
+ features?: string[];
1395
+ /** @description Adapter capabilities */
1396
+ capabilities?: Record<string, any>;
1397
+ };
1398
+ /** @description Complete redirect chain history */
1399
+ redirectHistory: {
1400
+ /** @description Cookies set in this redirect */
1401
+ cookies: Cookie[];
1402
+ /** @description Redirect URL */
1403
+ url: string;
1404
+ /** @description HTTP status code */
1405
+ statusCode: number;
1406
+ /** @description HTTP status text */
1407
+ statusText: string;
1408
+ /** @description Response headers */
1409
+ headers: RezoHeaders;
1410
+ /** @description Redirect timestamp */
1411
+ duration: number;
1412
+ /** @description Request configuration at this step */
1413
+ request: RezoRequestConfig;
1414
+ /** @description HTTP method used */
1415
+ method: string;
1416
+ }[];
1417
+ /** @description Number of redirects followed */
1418
+ redirectCount: number;
1419
+ /** @description Whether maximum redirects limit was reached */
1420
+ maxRedirectsReached: boolean;
1421
+ /**
1422
+ * @description Cookie jar instance for session management
1423
+ * Full RezoCookieJar class with all methods available:
1424
+ * - cookies(): Get all cookies in the jar
1425
+ * - setCookiesSync(cookies, url): Set cookies from Set-Cookie headers
1426
+ * - getCookiesSync(url): Get cookies for a URL
1427
+ * - removeAllCookiesSync(): Clear all cookies
1428
+ */
1429
+ cookieJar: RezoCookieJar;
1430
+ /** @description Comprehensive timing information */
1431
+ timing: {
1432
+ /** @description Request start timestamp (absolute performance.now() value) */
1433
+ startTimestamp: number;
1434
+ /** @description Request end timestamp (absolute performance.now() value) */
1435
+ endTimestamp: number;
1436
+ /** @description DNS lookup duration in milliseconds */
1437
+ dnsMs?: number;
1438
+ /** @description TCP connection duration in milliseconds */
1439
+ tcpMs?: number;
1440
+ /** @description TLS handshake duration in milliseconds */
1441
+ tlsMs?: number;
1442
+ /** @description Time to first byte in milliseconds (from start to first response byte) */
1443
+ ttfbMs?: number;
1444
+ /** @description Content transfer duration in milliseconds */
1445
+ transferMs?: number;
1446
+ /** @description Total request duration in milliseconds (endTimestamp - startTimestamp) */
1447
+ durationMs: number;
1448
+ };
1449
+ /** @description Network connection information */
1450
+ network: {
1451
+ /** @description Local IP address */
1452
+ localAddress?: string;
1453
+ /** @description Local port number */
1454
+ localPort?: number;
1455
+ /** @description Remote IP address */
1456
+ remoteAddress?: string;
1457
+ /** @description Remote port number */
1458
+ remotePort?: number;
1459
+ /** @description Protocol used (http/https) */
1460
+ protocol: string;
1461
+ /** @description HTTP version (1.1, 2.0, etc.) */
1462
+ httpVersion?: string;
1463
+ /** @description IP family preference (4 for IPv4, 6 for IPv6) */
1464
+ family?: 4 | 6;
1465
+ /** @description Custom DNS lookup function */
1466
+ lookup?: any;
1467
+ };
1468
+ /** @description Data transfer statistics */
1469
+ transfer: {
1470
+ /** @description Total request size in bytes (headers + body) */
1471
+ requestSize: number;
1472
+ /** @description Request headers size in bytes */
1473
+ requestHeaderSize?: number;
1474
+ /** @description Request body size in bytes */
1475
+ requestBodySize?: number;
1476
+ /** @description Total response size in bytes (headers + body) */
1477
+ responseSize: number;
1478
+ /** @description Response headers size in bytes */
1479
+ headerSize: number;
1480
+ /** @description Response body size in bytes */
1481
+ bodySize: number;
1482
+ /** @description Compression ratio if applicable */
1483
+ compressionRatio?: number;
1484
+ };
1485
+ /** @description Number of retry attempts made */
1486
+ retryAttempts: number;
1487
+ /** @description Error history during request execution */
1488
+ errors: Array<{
1489
+ /** @description Retry attempt number */
1490
+ attempt: number;
1491
+ /** @description Error message */
1492
+ error: RezoError;
1493
+ /** @description Request duration before error */
1494
+ duration: number;
1495
+ }>;
1496
+ /** @description Security and validation information */
1497
+ security: {
1498
+ /** @description TLS version used */
1499
+ tlsVersion?: string;
1500
+ /** @description Cipher suite used */
1501
+ cipher?: string;
1502
+ /** @description Certificate information */
1503
+ certificateInfo?: Record<string, any>;
1504
+ /** @description Validation results */
1505
+ validationResults?: Record<string, boolean>;
1506
+ };
1507
+ /** @description Debug mode flag */
1508
+ debug?: boolean;
1509
+ /** @description Request tracking identifier */
1510
+ requestId: string;
1511
+ /** @description Session identifier */
1512
+ sessionId?: string;
1513
+ /** @description Distributed tracing identifier */
1514
+ traceId?: string;
1515
+ /** @description Request timestamp */
1516
+ timestamp: number;
1517
+ /** @description Additional tracking data */
1518
+ trackingData?: Record<string, unknown>;
1519
+ /**
1520
+ * Callback invoked when a redirect response is received.
1521
+ * Controls redirect behavior including whether to follow, modify URL, or change HTTP method.
1522
+ *
1523
+ * @param options - Redirect response details
1524
+ * @param options.url - Redirect target URL
1525
+ * @param options.status - HTTP status code
1526
+ * @param options.headers - Response headers
1527
+ * @param options.sameDomain - Whether redirect is to same domain
1528
+ * @returns Boolean to follow/reject redirect, or object for granular control
1529
+ *
1530
+ * @example
1531
+ * ```typescript
1532
+ * beforeRedirect: ({ status, url }) => {
1533
+ * if (status === 301 || status === 302) {
1534
+ * return true; // Follow permanent/temporary redirects
1535
+ * } else if (status === 307 || status === 308) {
1536
+ * return { redirect: true, url: url.toString() }; // Preserve method for 307/308
1537
+ * } else if (status === 303) {
1538
+ * return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
1539
+ * }
1540
+ * return false; // Reject other redirects
1541
+ * }
1542
+ * ```
1543
+ */
1544
+ beforeRedirect?: RezoRequestConfig["beforeRedirect"];
1545
+ /** Character encoding for request body and response data */
1546
+ encoding?: BufferEncoding;
1547
+ /**
1548
+ * Whether to use cookies for the request
1549
+ */
1550
+ useCookies: boolean;
1551
+ }
1552
+ export declare enum RezoErrorCode {
1553
+ CONNECTION_REFUSED = "ECONNREFUSED",
1554
+ CONNECTION_RESET = "ECONNRESET",
1555
+ CONNECTION_TIMEOUT = "ETIMEDOUT",
1556
+ DNS_LOOKUP_FAILED = "ENOTFOUND",
1557
+ DNS_TEMPORARY_FAILURE = "EAI_AGAIN",
1558
+ HOST_UNREACHABLE = "EHOSTUNREACH",
1559
+ NETWORK_UNREACHABLE = "ENETUNREACH",
1560
+ BROKEN_PIPE = "EPIPE",
1561
+ HTTP_ERROR = "REZ_HTTP_ERROR",
1562
+ REDIRECT_DENIED = "REZ_REDIRECT_DENIED",
1563
+ MAX_REDIRECTS = "REZ_MAX_REDIRECTS_EXCEEDED",
1564
+ REDIRECT_CYCLE = "REZ_REDIRECT_CYCLE_DETECTED",
1565
+ MISSING_REDIRECT_LOCATION = "REZ_MISSING_REDIRECT_LOCATION",
1566
+ DECOMPRESSION_ERROR = "REZ_DECOMPRESSION_ERROR",
1567
+ REQUEST_TIMEOUT = "UND_ERR_REQUEST_TIMEOUT",
1568
+ HEADERS_TIMEOUT = "UND_ERR_HEADERS_TIMEOUT",
1569
+ CONNECT_TIMEOUT = "UND_ERR_CONNECT_TIMEOUT",
1570
+ ABORTED = "ABORT_ERR",
1571
+ DOWNLOAD_FAILED = "REZ_DOWNLOAD_FAILED",
1572
+ UPLOAD_FAILED = "REZ_UPLOAD_FAILED",
1573
+ STREAM_ERROR = "REZ_STREAM_ERROR",
1574
+ BODY_TOO_LARGE = "REZ_BODY_TOO_LARGE",
1575
+ RESPONSE_TOO_LARGE = "REZ_RESPONSE_TOO_LARGE",
1576
+ INVALID_JSON = "REZ_INVALID_JSON",
1577
+ INVALID_URL = "ERR_INVALID_URL",
1578
+ INVALID_PROTOCOL = "ERR_INVALID_PROTOCOL",
1579
+ INVALID_ARGUMENT = "ERR_INVALID_ARG_TYPE",
1580
+ FILE_PERMISSION = "REZ_FILE_PERMISSION_ERROR",
1581
+ PROXY_CONNECTION_FAILED = "REZ_PROXY_CONNECTION_FAILED",
1582
+ PROXY_AUTH_FAILED = "REZ_PROXY_AUTHENTICATION_FAILED",
1583
+ PROXY_TARGET_UNREACHABLE = "REZ_PROXY_TARGET_UNREACHABLE",
1584
+ PROXY_TIMEOUT = "REZ_PROXY_TIMEOUT",
1585
+ PROXY_ERROR = "REZ_PROXY_ERROR",
1586
+ PROXY_INVALID_PROTOCOL = "REZ_PROXY_INVALID_PROTOCOL",
1587
+ PROXY_INVALID_CONFIG = "REZ_PROXY_INVALID_HOSTPORT",
1588
+ SOCKS_CONNECTION_FAILED = "REZ_SOCKS_CONNECTION_FAILED",
1589
+ SOCKS_AUTH_FAILED = "REZ_SOCKS_AUTHENTICATION_FAILED",
1590
+ SOCKS_TARGET_UNREACHABLE = "REZ_SOCKS_TARGET_CONNECTION_FAILED",
1591
+ SOCKS_PROTOCOL_ERROR = "REZ_SOCKS_PROTOCOL_ERROR",
1592
+ SOCKS_UNSUPPORTED_VERSION = "REZ_SOCKS_UNSUPPORTED_VERSION",
1593
+ TLS_HANDSHAKE_TIMEOUT = "ERR_TLS_HANDSHAKE_TIMEOUT",
1594
+ TLS_PROTOCOL_ERROR = "EPROTO",
1595
+ TLS_PROTOCOL_VERSION = "ERR_TLS_INVALID_PROTOCOL_VERSION",
1596
+ CERTIFICATE_HOSTNAME_MISMATCH = "ERR_TLS_CERT_ALTNAME_INVALID",
1597
+ CERTIFICATE_EXPIRED = "CERT_HAS_EXPIRED",
1598
+ CERTIFICATE_SELF_SIGNED = "SELF_SIGNED_CERT_IN_CHAIN",
1599
+ CERTIFICATE_VERIFY_FAILED = "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
1600
+ RATE_LIMITED = "REZ_RATE_LIMITED",
1601
+ UNKNOWN_ERROR = "REZ_UNKNOWN_ERROR"
1602
+ }
1603
+ export declare class RezoError<T = any> extends Error {
1604
+ readonly code?: string;
1605
+ readonly errno?: number;
1606
+ readonly config: RezoConfig;
1607
+ readonly request?: RezoHttpRequest;
1608
+ readonly response?: RezoResponse<T>;
1609
+ readonly isRezoError: boolean;
1610
+ readonly cause?: Error;
1611
+ readonly syscall?: string;
1612
+ readonly hostname?: string;
1613
+ readonly port?: number;
1614
+ readonly address?: string;
1615
+ readonly status?: number;
1616
+ readonly statusText?: string;
1617
+ readonly isTimeout: boolean;
1618
+ readonly isAborted: boolean;
1619
+ readonly isNetworkError: boolean;
1620
+ readonly isHttpError: boolean;
1621
+ readonly isProxyError: boolean;
1622
+ readonly isSocksError: boolean;
1623
+ readonly isTlsError: boolean;
1624
+ readonly isRetryable: boolean;
1625
+ readonly details: string;
1626
+ readonly suggestion: string;
1627
+ constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
1628
+ static isRezoError(error: unknown): error is RezoError;
1629
+ static fromError<T = any>(error: Error, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1630
+ static createNetworkError<T = any>(message: string, code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1631
+ static createHttpError<T = any>(statusCode: number, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1632
+ static createTimeoutError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1633
+ static createAbortError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1634
+ static createParsingError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1635
+ static createEnvironmentError<T = any>(message: string, config: RezoConfig): RezoError<T>;
1636
+ static createDecompressionError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1637
+ static createDownloadError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1638
+ static createUploadError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1639
+ static createStreamError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1640
+ static createRedirectError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1641
+ static createProxyError<T = any>(code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1642
+ static createSocksError<T = any>(code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1643
+ static createTlsError<T = any>(code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
1644
+ static createRateLimitError<T = any>(config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
1645
+ /**
1646
+ * Convert error to JSON - only includes defined values
1647
+ */
1648
+ toJSON(): Record<string, unknown>;
1649
+ toString(): string;
1650
+ getFullDetails(): string;
1651
+ }
1652
+ /**
1653
+ * Supported proxy protocols for network requests
1654
+ */
1655
+ export type ProxyProtocol = "http" | "https" | "socks4" | "socks5";
1656
+ /**
1657
+ * Configuration options for proxy connections
1658
+ */
1659
+ export type ProxyOptions = {
1660
+ /** The proxy protocol to use */
1661
+ protocol: ProxyProtocol;
1662
+ /** Proxy server hostname or IP address */
1663
+ host: string;
1664
+ /** Proxy server port number */
1665
+ port: number;
1666
+ /** Optional authentication credentials for the proxy */
1667
+ auth?: {
1668
+ /** Username for proxy authentication */
1669
+ username: string;
1670
+ /** Password for proxy authentication */
1671
+ password: string;
1672
+ };
1673
+ /** Connection timeout in milliseconds */
1674
+ timeout?: number;
1675
+ /** Whether to keep the connection alive */
1676
+ keepAlive?: boolean;
1677
+ /** Keep-alive timeout in milliseconds */
1678
+ keepAliveMsecs?: number;
1679
+ /** Maximum number of sockets to allow per host */
1680
+ maxSockets?: number;
1681
+ /** Maximum number of free sockets to keep open per host */
1682
+ maxFreeSockets?: number;
1683
+ /** Whether to reject unauthorized SSL certificates */
1684
+ rejectUnauthorized?: boolean;
1685
+ };
1686
+ /**
1687
+ * Maximum upload rate in bytes per second
1688
+ */
1689
+ export type MaxUploadRate = number;
1690
+ /**
1691
+ * Maximum download rate in bytes per second
1692
+ */
1693
+ export type MaxDownloadRate = number;
1694
+ /**
1695
+ * Custom string type for Rezo-specific string values
1696
+ */
1697
+ export type RezoString = string;
1698
+ /**
1699
+ * Standard HTTP methods supported by Rezo
1700
+ */
1701
+ export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT";
1702
+ /**
1703
+ * Response data types that control how Rezo parses the response body.
1704
+ *
1705
+ * @description
1706
+ * Specifies how the response body should be parsed and returned in `response.data`.
1707
+ * Choose the type that matches your expected response format.
1708
+ *
1709
+ * **Available Types:**
1710
+ *
1711
+ * - `'json'` - Parse response as JSON. Returns parsed object/array.
1712
+ * Best for REST APIs that return JSON data.
1713
+ *
1714
+ * - `'text'` - Return response as a string. No parsing applied.
1715
+ * Best for HTML, XML, plain text, or when you need raw content.
1716
+ *
1717
+ * - `'blob'` - Return as Blob object (browser environments).
1718
+ * Best for binary data in browsers (images, files, etc).
1719
+ *
1720
+ * - `'arrayBuffer'` - Return as ArrayBuffer.
1721
+ * Best for binary data processing, cryptographic operations.
1722
+ *
1723
+ * - `'buffer'` - Return as Node.js Buffer.
1724
+ * Best for binary data in Node.js (files, images, binary protocols).
1725
+ *
1726
+ * - `'auto'` - Auto-detect based on Content-Type header (default).
1727
+ * JSON for `application/json`, text for `text/*`, buffer otherwise.
1728
+ *
1729
+ * **Streaming Operations:**
1730
+ * For streaming, use dedicated methods instead of responseType:
1731
+ * - `rezo.stream(url)` - Returns StreamResponse for real-time data
1732
+ * - `rezo.download(url, saveTo)` - Returns DownloadResponse with progress
1733
+ * - `rezo.upload(url, data)` - Returns UploadResponse with progress
1734
+ *
1735
+ * @example
1736
+ * // Get JSON data (default for JSON APIs)
1737
+ * const { data } = await rezo.get('/api/users', { responseType: 'json' });
1738
+ *
1739
+ * // Get HTML as text
1740
+ * const { data: html } = await rezo.get('/page', { responseType: 'text' });
1741
+ *
1742
+ * // Get image as buffer
1743
+ * const { data: imageBuffer } = await rezo.get('/image.png', { responseType: 'buffer' });
1744
+ *
1745
+ * @default 'auto'
1746
+ */
1747
+ type ResponseType$1 = "json" | "text" | "blob" | "arrayBuffer" | "buffer" | "auto";
1748
+ /**
1749
+ * MIME content types for request/response bodies
1750
+ */
1751
+ export type ContentType = "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | "text/html" | "application/xml" | "application/octet-stream" | RezoString;
1752
+ /**
1753
+ * RezoRequestConfig - Clean interface for internal request processing
1754
+ *
1755
+ * @template D - Type of the request body data
1756
+ */
1757
+ export interface RezoRequestConfig<D = any> {
1758
+ /** The target URL for the request */
1759
+ url: string | URL;
1760
+ /**
1761
+ * The absolute request url
1762
+ */
1763
+ fullUrl: string;
1764
+ /** Request method to use for the request */
1765
+ method: HttpMethod;
1766
+ /** Request headers as various supported formats */
1767
+ headers?: [
1768
+ string,
1769
+ string
1770
+ ][] | Record<string, string> | Headers | RezoHttpHeaders | RezoHeaders | OutgoingHttpHeaders;
1771
+ /** URL query parameters to append to the request */
1772
+ params?: Record<string | number, any>;
1773
+ /**
1774
+ * Queue to use for request execution
1775
+ */
1776
+ queue?: PQueue | null;
1777
+ /**
1778
+ * Controls how the response body is parsed and returned in `response.data`.
1779
+ *
1780
+ * **Available Types:**
1781
+ * - `'json'` - Parse as JSON object/array. Best for REST APIs.
1782
+ * - `'text'` - Return as string. Best for HTML, XML, plain text.
1783
+ * - `'blob'` - Return as Blob (browser). Best for binary in browsers.
1784
+ * - `'arrayBuffer'` - Return as ArrayBuffer. Best for binary processing.
1785
+ * - `'buffer'` - Return as Buffer (Node.js). Best for binary in Node.
1786
+ * - `'auto'` - Auto-detect from Content-Type header (default).
1787
+ *
1788
+ * **For streaming, use dedicated methods instead:**
1789
+ * - `rezo.stream(url)` - Real-time streaming data
1790
+ * - `rezo.download(url, saveTo)` - Download with progress
1791
+ * - `rezo.upload(url, data)` - Upload with progress
1792
+ *
1793
+ * @default 'auto'
1794
+ * @example
1795
+ * // Get JSON
1796
+ * const { data } = await rezo.get('/api/users', { responseType: 'json' });
1797
+ *
1798
+ * // Get HTML as text
1799
+ * const { data: html } = await rezo.get('/page', { responseType: 'text' });
1800
+ *
1801
+ * // Get image as buffer
1802
+ * const { data: img } = await rezo.get('/image.png', { responseType: 'buffer' });
1803
+ */
1804
+ responseType?: ResponseType$1;
1805
+ /** Character encoding for the response */
1806
+ responseEncoding?: string;
1807
+ /** Base URL for the request (used with relative URLs) */
1808
+ baseURL?: string;
1809
+ /** Raw request body data */
1810
+ body?: D;
1811
+ /** JSON object to be serialized as request body */
1812
+ json?: Record<string, any>;
1813
+ /** Form data to be URL-encoded */
1814
+ form?: Record<string, any>;
1815
+ /** Form data for multipart/form-data requests */
1816
+ formData?: Record<string, any> | RezoFormData;
1817
+ /** Multipart data (alias for formData) */
1818
+ multipart?: Record<string, any> | RezoFormData;
1819
+ /** Whether to detect and prevent redirect cycles */
1820
+ enableRedirectCycleDetection?: boolean;
1821
+ /** MIME type for the request content */
1822
+ contentType?: ContentType | string;
1823
+ /** Skip setting Content-Type header automatically */
1824
+ withoutContentType?: boolean;
1825
+ /** Basic authentication credentials */
1826
+ auth?: {
1827
+ /** Username for authentication */
1828
+ username: string;
1829
+ /** Password for authentication */
1830
+ password: string;
1831
+ };
1832
+ /** Request timeout in milliseconds */
1833
+ timeout?: number;
1834
+ /** Whether to reject requests with invalid SSL certificates */
1835
+ rejectUnauthorized?: boolean;
1836
+ /** Retry configuration for failed requests */
1837
+ retry?: {
1838
+ /** Maximum number of retry attempts */
1839
+ maxRetries?: number;
1840
+ /** Delay between retries in milliseconds */
1841
+ retryDelay?: number;
1842
+ /** Whether to increment delay on each retry */
1843
+ incrementDelay?: boolean;
1844
+ /** HTTP status codes that should trigger a retry attempt defaults are (408, 429, 500, 502, 503, 504, 425, 520) */
1845
+ statusCodes?: number[];
1846
+ /** Weather to stop or continue retry when certain condition is met*/
1847
+ condition?: (error: RezoError) => boolean | Promise<boolean>;
1848
+ };
1849
+ /** Whether to use a secure context for HTTPS requests */
1850
+ useSecureContext?: boolean;
1851
+ /** Custom secure context for TLS connections */
1852
+ secureContext?: SecureContext;
1853
+ /** Whether to automatically follow HTTP redirects */
1854
+ followRedirects?: boolean;
1855
+ /** Maximum number of redirects to follow */
1856
+ maxRedirects?: number;
1857
+ /** Whether to automatically decompress response data */
1858
+ decompress?: boolean;
1859
+ /** Whether to keep the connection alive for reuse */
1860
+ keepAlive?: boolean;
1861
+ withoutBodyOnRedirect?: boolean;
1862
+ autoSetReferer?: boolean;
1863
+ autoSetOrigin?: boolean;
1864
+ treat302As303?: boolean;
1865
+ startNewRequest?: boolean;
1866
+ /** Whether to use HTTP/2 protocol */
1867
+ http2?: boolean;
1868
+ /** Whether to use cURL adapter */
1869
+ curl?: boolean;
1870
+ /**
1871
+ * DNS cache configuration for faster repeated requests.
1872
+ *
1873
+ * When enabled, DNS lookups are cached to avoid repeated DNS queries
1874
+ * for the same hostname, significantly improving performance for
1875
+ * applications making many requests to the same servers.
1876
+ *
1877
+ * **Options:**
1878
+ * - `true` - Enable with default settings (1 min TTL, 1000 entries max)
1879
+ * - `false` - Disable DNS caching (default)
1880
+ * - `object` - Custom configuration with ttl and maxEntries
1881
+ *
1882
+ * @example
1883
+ * // Enable with defaults
1884
+ * { dnsCache: true }
1885
+ *
1886
+ * // Custom TTL (5 minutes) and max entries
1887
+ * { dnsCache: { ttl: 300000, maxEntries: 500 } }
1888
+ *
1889
+ * @default false
1890
+ */
1891
+ dnsCache?: boolean | {
1892
+ /** Time-to-live for cached entries in milliseconds */
1893
+ ttl?: number;
1894
+ /** Maximum number of entries to cache */
1895
+ maxEntries?: number;
1896
+ };
1897
+ /**
1898
+ * Response cache configuration for caching HTTP responses.
1899
+ *
1900
+ * When enabled, successful GET/HEAD responses are cached to avoid
1901
+ * repeated network requests. Supports memory-only or file persistence.
1902
+ * Honors Cache-Control headers by default.
1903
+ *
1904
+ * **Options:**
1905
+ * - `true` - Enable memory cache with defaults (5 min TTL, 500 entries)
1906
+ * - `false` - Disable response caching (default)
1907
+ * - `object` - Custom configuration
1908
+ *
1909
+ * **Cache-Control Support:**
1910
+ * - Respects `max-age`, `s-maxage`, `no-store`, `no-cache`
1911
+ * - Sends `If-None-Match` / `If-Modified-Since` for revalidation
1912
+ * - Returns cached response on 304 Not Modified
1913
+ *
1914
+ * @example
1915
+ * // Enable memory-only cache
1916
+ * { cache: true }
1917
+ *
1918
+ * // With file persistence
1919
+ * { cache: { cacheDir: './cache', ttl: 300000 } }
1920
+ *
1921
+ * // Custom settings
1922
+ * { cache: {
1923
+ * ttl: 600000, // 10 minutes
1924
+ * maxEntries: 1000,
1925
+ * methods: ['GET'], // Only cache GET
1926
+ * respectHeaders: true // Honor Cache-Control
1927
+ * }}
1928
+ *
1929
+ * @default false
1930
+ */
1931
+ cache?: boolean | {
1932
+ /** Directory for persistent cache storage (enables file persistence) */
1933
+ cacheDir?: string;
1934
+ /** Time-to-live for cached entries in milliseconds */
1935
+ ttl?: number;
1936
+ /** Maximum number of entries to cache */
1937
+ maxEntries?: number;
1938
+ /** HTTP methods to cache */
1939
+ methods?: string[];
1940
+ /** Whether to respect Cache-Control headers */
1941
+ respectHeaders?: boolean;
1942
+ };
1943
+ /**
1944
+ * Callback invoked when a redirect response is received.
1945
+ * Controls redirect behavior including whether to follow, modify URL, or change HTTP method.
1946
+ *
1947
+ * @param options - Redirect response details
1948
+ * @param options.url - Redirect target URL
1949
+ * @param options.status - HTTP status code
1950
+ * @param options.headers - Response headers
1951
+ * @param options.sameDomain - Whether redirect is to same domain
1952
+ * @returns Boolean to follow/reject redirect, or object for granular control
1953
+ *
1954
+ * @example
1955
+ * ```typescript
1956
+ * beforeRedirect: ({ status, url }) => {
1957
+ * if (status === 301 || status === 302) {
1958
+ * return true; // Follow permanent/temporary redirects
1959
+ * } else if (status === 307 || status === 308) {
1960
+ * return { redirect: true, url: url.toString() }; // Preserve method for 307/308
1961
+ * } else if (status === 303) {
1962
+ * return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
1963
+ * }
1964
+ * return false; // Reject other redirects
1965
+ * }
1966
+ * ```
1967
+ */
1968
+ beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
1969
+ /** Whether to send cookies and authorization headers with cross-origin requests */
1970
+ withCredentials?: boolean;
1971
+ /** Proxy configuration (URL string or detailed options) */
1972
+ proxy?: string | ProxyOptions;
1973
+ /** Whether to enable automatic cookie handling */
1974
+ useCookies?: boolean;
1975
+ /** Custom cookie jar for managing cookies */
1976
+ cookieJar?: RezoCookieJar;
1977
+ /** Cookies to send with the request in various formats */
1978
+ cookies?: Cookies["array"] | Cookies["netscape"] | Cookies["serialized"] | Cookies["setCookiesString"];
1979
+ /** Callback for upload progress events */
1980
+ onUploadProgress?: (progressEvent: any) => void;
1981
+ /** Callback for download progress events */
1982
+ onDownloadProgress?: (progressEvent: any) => void;
1983
+ /** Maximum allowed size of the request body in bytes */
1984
+ maxBodyLength?: number;
1985
+ /** Maximum transfer rate (single number or [upload, download] tuple) */
1986
+ maxRate?: number | [
1987
+ MaxUploadRate,
1988
+ MaxDownloadRate
1989
+ ];
1990
+ /** Array of functions to transform request data */
1991
+ transformRequest?: Array<(data: any, headers: RezoHeaders) => any>;
1992
+ /** Array of functions to transform response data */
1993
+ transformResponse?: Array<(data: any) => any>;
1994
+ /** Adapter to use for the request (name or custom function) */
1995
+ adapter?: string | ((config: RezoRequestConfig) => Promise<any>);
1996
+ /** AbortSignal to cancel the request */
1997
+ signal?: AbortSignal;
1998
+ /** File path to save the response to (for downloads) */
1999
+ saveTo?: string;
2000
+ /** Custom filename for downloaded files */
2001
+ fileName?: string;
2002
+ /** Browser simulation configuration for user agent spoofing */
2003
+ browser?: {
2004
+ /** Browser name to simulate */
2005
+ name: "chrome" | "firefox" | "safari" | "edge" | "opera" | "ie" | "chromium";
2006
+ /** Browser version string */
2007
+ version: string;
2008
+ /** Device platform type */
2009
+ platform: "desktop" | "mobile" | "tablet";
2010
+ /** Operating system details */
2011
+ os: {
2012
+ /** Operating system name */
2013
+ name: "windows" | "macos" | "linux" | "ios" | "android" | "chromeos";
2014
+ /** OS version string */
2015
+ version: string;
2016
+ /** CPU architecture */
2017
+ architecture: "x86" | "x64" | "arm" | "arm64";
2018
+ };
2019
+ /** Browser language preference */
2020
+ language?: string;
2021
+ };
2022
+ /** Enable debug logging for the request */
2023
+ debug?: boolean;
2024
+ /** Enable verbose logging with detailed information */
2025
+ verbose?: boolean;
2026
+ /** Name of the cookie containing XSRF token */
2027
+ xsrfCookieName?: string;
2028
+ /** Name of the header to send XSRF token in */
2029
+ xsrfHeaderName?: string;
2030
+ /** Custom HTTP agent for HTTP requests */
2031
+ httpAgent?: HttpAgent;
2032
+ /** Custom HTTPS agent for HTTPS requests */
2033
+ httpsAgent?: HttpsAgent;
2034
+ /** Transitional options for backward compatibility */
2035
+ transitional?: {
2036
+ /** Silently ignore JSON parsing errors */
2037
+ silentJSONParsing?: boolean;
2038
+ /** Force JSON parsing even for non-JSON responses */
2039
+ forcedJSONParsing?: boolean;
2040
+ /** Provide clearer timeout error messages */
2041
+ clarifyTimeoutError?: boolean;
2042
+ };
2043
+ /** Character encoding for request body and response data */
2044
+ encoding?: BufferEncoding;
2045
+ /**
2046
+ * Request lifecycle hooks for intercepting and modifying request/response behavior.
2047
+ * Optional hooks that will be merged with default hooks during request processing.
2048
+ */
2049
+ hooks?: Partial<RezoHooks>;
2050
+ }
2051
+ export interface OnRedirectOptions {
2052
+ url: URL;
2053
+ status: number;
2054
+ headers: RezoHeaders;
2055
+ sameDomain: boolean;
2056
+ method: string;
2057
+ }
2058
+ export type OnRedirectResponse = boolean | ToRedirectOptions | undefined;
2059
+ export type ToRedirectOptions = {
2060
+ redirect: false;
2061
+ message?: string;
2062
+ } | {
2063
+ redirect: true;
2064
+ url: string;
2065
+ method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
2066
+ body?: any;
2067
+ withoutBody?: boolean;
2068
+ setHeaders?: RezoHeaders | OutgoingHttpHeaders;
2069
+ setHeadersOnRedirects?: RezoHeaders | OutgoingHttpHeaders;
2070
+ };
2071
+ /**
2072
+ * RezoHttpRequest - Request configuration type for all methods
2073
+ *
2074
+ * This type excludes internal properties and is specifically designed for public API usage.
2075
+ * Use this type when creating reusable request configurations for the all method.
2076
+ *
2077
+ * @public - Use with all methods
2078
+ * @internal - Do not use internally within the library
2079
+ */
2080
+ export type RezoHttpRequest = Omit<RezoRequestConfig, "body" | "url" | "method" | "form" | "json" | "formData" | "multipart" | "fullUrl" | "responseType">;
2081
+ /**
2082
+ * Method-aware request types for better TypeScript inference
2083
+ * These types remove data/body fields from methods that don't typically use them
2084
+ */
2085
+ /**
2086
+ * RezoHttpGetRequest - Request options for GET requests (no request body)
2087
+ * @public - Use with GET method
2088
+ */
2089
+ export type RezoHttpGetRequest = Omit<RezoHttpRequest, "data" | "body">;
2090
+ /**
2091
+ * RezoHttpPostRequest - Request options for POST requests (includes request body)
2092
+ * @public - Use with POST method
2093
+ */
2094
+ export type RezoHttpPostRequest = RezoHttpRequest;
2095
+ /**
2096
+ * RezoHttpPutRequest - Request options for PUT requests (includes request body)
2097
+ * @public - Use with PUT method
2098
+ */
2099
+ export type RezoHttpPutRequest = RezoHttpRequest;
2100
+ /**
2101
+ * RezoHttpPatchRequest - Request options for PATCH requests (includes request body)
2102
+ * @public - Use with PATCH method
2103
+ */
2104
+ export type RezoHttpPatchRequest = RezoHttpRequest;
2105
+ /**
2106
+ * RezoHttpDeleteRequest - Request options for DELETE requests (no request body)
2107
+ * @public - Use with DELETE method
2108
+ */
2109
+ export type RezoHttpDeleteRequest = Omit<RezoHttpRequest, "data" | "body">;
2110
+ /**
2111
+ * RezoHttpHeadRequest - Request options for HEAD requests (no request body)
2112
+ * @public - Use with HEAD method
2113
+ */
2114
+ export type RezoHttpHeadRequest = Omit<RezoHttpRequest, "data" | "body">;
2115
+ /**
2116
+ * RezoHttpOptionsRequest - Request options for OPTIONS requests (no request body)
2117
+ * @public - Use with OPTIONS method
2118
+ */
2119
+ export type RezoHttpOptionsRequest = Omit<RezoHttpRequest, "data" | "body">;
2120
+ /**
2121
+ * RezoRequestOptions - Request configuration type for the .request() method
2122
+ *
2123
+ * This type excludes internal properties and is specifically designed for public API usage.
2124
+ * Use this type when creating reusable request configurations for the .request() method.
2125
+ *
2126
+ * @public - For external use with .request() method only
2127
+ * @internal - Do not use internally within the library
2128
+ */
2129
+ export type RezoRequestOptions = Omit<RezoRequestConfig, "fullUrl">;
2130
+ export interface DNSCacheOptions {
2131
+ enable?: boolean;
2132
+ ttl?: number;
2133
+ maxEntries?: number;
2134
+ }
2135
+ declare class DNSCache {
2136
+ private cache;
2137
+ private enabled;
2138
+ constructor(options?: DNSCacheOptions);
2139
+ private makeKey;
2140
+ lookup(hostname: string, family?: 4 | 6): Promise<{
2141
+ address: string;
2142
+ family: 4 | 6;
2143
+ } | undefined>;
2144
+ lookupAll(hostname: string, family?: 4 | 6): Promise<Array<{
2145
+ address: string;
2146
+ family: 4 | 6;
2147
+ }>>;
2148
+ private resolveDNS;
2149
+ private resolveAllDNS;
2150
+ invalidate(hostname: string): void;
2151
+ clear(): void;
2152
+ get size(): number;
2153
+ get isEnabled(): boolean;
2154
+ setEnabled(enabled: boolean): void;
2155
+ }
2156
+ export interface ResponseCacheConfig {
2157
+ enable?: boolean;
2158
+ cacheDir?: string;
2159
+ networkCheck?: boolean;
2160
+ ttl?: number;
2161
+ maxEntries?: number;
2162
+ methods?: string[];
2163
+ respectHeaders?: boolean;
2164
+ }
2165
+ export type ResponseCacheOption = boolean | ResponseCacheConfig;
2166
+ export interface CachedResponse {
2167
+ status: number;
2168
+ statusText: string;
2169
+ headers: Record<string, string>;
2170
+ data: unknown;
2171
+ url: string;
2172
+ timestamp: number;
2173
+ ttl: number;
2174
+ etag?: string;
2175
+ lastModified?: string;
2176
+ }
2177
+ declare class ResponseCache {
2178
+ private memoryCache;
2179
+ private config;
2180
+ private persistenceEnabled;
2181
+ private initialized;
2182
+ constructor(options?: ResponseCacheOption);
2183
+ private initializePersistence;
2184
+ private initializePersistenceAsync;
2185
+ private getCacheFilePath;
2186
+ private persistToDisk;
2187
+ private loadFromDiskAsync;
2188
+ private generateKey;
2189
+ private parseCacheControl;
2190
+ isCacheable(method: string, status: number, headers?: Record<string, string>): boolean;
2191
+ get(method: string, url: string, headers?: Record<string, string>): CachedResponse | undefined;
2192
+ private loadSingleFromDisk;
2193
+ set(method: string, url: string, response: RezoResponse, requestHeaders?: Record<string, string>): void;
2194
+ private normalizeHeaders;
2195
+ getConditionalHeaders(method: string, url: string, requestHeaders?: Record<string, string>): Record<string, string> | undefined;
2196
+ updateRevalidated(method: string, url: string, newHeaders: Record<string, string>, requestHeaders?: Record<string, string>): CachedResponse | undefined;
2197
+ invalidate(url: string, method?: string): void;
2198
+ clear(): void;
2199
+ get size(): number;
2200
+ get isEnabled(): boolean;
2201
+ get isPersistent(): boolean;
2202
+ getConfig(): ResponseCacheConfig;
2203
+ }
2204
+ export type queueOptions = Options$1<PriorityQueue, QueueAddOptions>;
2205
+ export interface CacheConfig {
2206
+ /** Response cache configuration */
2207
+ response?: boolean | ResponseCacheConfig;
2208
+ /** DNS cache configuration */
2209
+ dns?: boolean | DNSCacheOptions;
2210
+ }
2211
+ export type CacheOption = boolean | CacheConfig;
2212
+ export interface RezoDefaultOptions {
2213
+ baseURL?: string;
2214
+ /** Hooks for request/response lifecycle */
2215
+ hooks?: Partial<RezoHooks>;
2216
+ /** Whether to enable automatic cookie handling (default: true)*/
2217
+ enableCookieJar?: boolean;
2218
+ /** Custom cookie jar for managing cookies */
2219
+ cookieJar?: RezoHttpRequest["cookieJar"];
2220
+ /** Set default cookies to send with the requests in various formats */
2221
+ cookies?: RezoHttpRequest["cookies"];
2222
+ /**
2223
+ * Path to cookie file for persistence.
2224
+ * - .json files save cookies as serialized JSON
2225
+ * - .txt files save cookies in Netscape format
2226
+ * Cookies are loaded on construction and saved automatically after each request.
2227
+ */
2228
+ cookieFile?: string;
2229
+ queueOptions?: {
2230
+ enable: boolean;
2231
+ options?: queueOptions;
2232
+ };
2233
+ /** Request headers as various supported formats */
2234
+ headers?: RezoHttpRequest["headers"];
2235
+ /** Expected response data type */
2236
+ responseType?: ResponseType$1;
2237
+ /** Character encoding for the response */
2238
+ responseEncoding?: string;
2239
+ /** Basic authentication credentials */
2240
+ auth?: RezoHttpRequest["auth"];
2241
+ /** Request timeout in milliseconds */
2242
+ timeout?: number;
2243
+ /** @deprecated Use `timeout` instead */
2244
+ requestTimeout?: number;
2245
+ /** Whether to reject requests with invalid SSL certificates */
2246
+ rejectUnauthorized?: boolean;
2247
+ /** Retry configuration for failed requests */
2248
+ retry?: RezoHttpRequest["retry"];
2249
+ /** Whether to use a secure context for HTTPS requests */
2250
+ useSecureContext?: boolean;
2251
+ /** Custom secure context for TLS connections */
2252
+ secureContext?: RezoHttpRequest["secureContext"];
2253
+ /** Whether to automatically follow HTTP redirects */
2254
+ followRedirects?: boolean;
2255
+ /** Maximum number of redirects to follow */
2256
+ maxRedirects?: number;
2257
+ /** Whether to automatically decompress response data */
2258
+ decompress?: boolean;
2259
+ /** Whether to keep the connection alive for reuse */
2260
+ keepAlive?: boolean;
2261
+ /** Whether to detect and prevent redirect cycles */
2262
+ enableRedirectCycleDetection?: boolean;
2263
+ /** Whether to use HTTP/2 protocol */
2264
+ http2?: boolean;
2265
+ /** Whether to use cURL adapter */
2266
+ curl?: boolean;
2267
+ /** Whether to send cookies and authorization headers with cross-origin requests */
2268
+ withCredentials?: boolean;
2269
+ /** Proxy configuration (URL string or detailed options) */
2270
+ proxy?: RezoHttpRequest["proxy"];
2271
+ /** Maximum allowed size of the request body in bytes */
2272
+ maxBodyLength?: number;
2273
+ /** Maximum transfer rate (single number or [upload, download] tuple) */
2274
+ maxRate?: RezoHttpRequest["maxRate"];
2275
+ /**
2276
+ * Callback invoked when a redirect response is received.
2277
+ * Controls redirect behavior including whether to follow, modify URL, or change HTTP method.
2278
+ *
2279
+ * @param options - Redirect response details
2280
+ * @param options.url - Redirect target URL
2281
+ * @param options.status - HTTP status code
2282
+ * @param options.headers - Response headers
2283
+ * @param options.sameDomain - Whether redirect is to same domain
2284
+ * @returns Boolean to follow/reject redirect, or object for granular control
2285
+ *
2286
+ * @example
2287
+ * ```typescript
2288
+ * beforeRedirect: ({ status, url }) => {
2289
+ * if (status === 301 || status === 302) {
2290
+ * return true; // Follow permanent/temporary redirects
2291
+ * } else if (status === 307 || status === 308) {
2292
+ * return { redirect: true, url: url.toString() }; // Preserve method for 307/308
2293
+ * } else if (status === 303) {
2294
+ * return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
2295
+ * }
2296
+ * return false; // Reject other redirects
2297
+ * }
2298
+ * ```
2299
+ */
2300
+ beforeRedirect?: RezoHttpRequest["beforeRedirect"];
2301
+ /** Array of functions to transform request data */
2302
+ transformRequest?: RezoHttpRequest["transformRequest"];
2303
+ /** Array of functions to transform response data */
2304
+ transformResponse?: RezoHttpRequest["transformResponse"];
2305
+ /** Adapter to use for the request (name or custom function) */
2306
+ adapter?: RezoHttpRequest["adapter"];
2307
+ /** Browser simulation configuration for user agent spoofing */
2308
+ browser?: RezoHttpRequest["browser"];
2309
+ /** Enable debug logging for the request */
2310
+ debug?: RezoHttpRequest["debug"];
2311
+ /** Enable verbose logging with detailed information */
2312
+ verbose?: RezoHttpRequest["verbose"];
2313
+ /** HTTP agent for HTTP requests */
2314
+ httpAgent?: RezoHttpRequest["httpAgent"];
2315
+ /** HTTPS agent for HTTPS requests */
2316
+ httpsAgent?: RezoHttpRequest["httpsAgent"];
2317
+ /** Transitional options for backward compatibility */
2318
+ transitional?: RezoHttpRequest["transitional"];
2319
+ /** Character encoding for request body and response data */
2320
+ encoding?: BufferEncoding;
2321
+ /**
2322
+ * Cache configuration for response and DNS caching
2323
+ * - `true`: Enable default in-memory cache (fast, sensible defaults)
2324
+ * - `{ response: {...}, dns: {...} }`: Fine-grained control
2325
+ *
2326
+ * Response cache defaults: 30 min TTL, 500 entries, GET/HEAD only
2327
+ * DNS cache defaults: 1 min TTL, 1000 entries
2328
+ */
2329
+ cache?: CacheOption;
2330
+ }
2331
+ export interface httpAdapterOverloads {
2332
+ request<T = any>(options: RezoRequestOptions): Promise<RezoResponse<T>>;
2333
+ request<T = any>(options: RezoRequestOptions & {
2334
+ responseType: "auto";
2335
+ }): Promise<RezoResponse<T>>;
2336
+ request<T = any>(options: RezoRequestOptions & {
2337
+ responseType: "json";
2338
+ }): Promise<RezoResponse<T>>;
2339
+ request(options: {
2340
+ responseType: "stream";
2341
+ } & RezoRequestOptions): Promise<RezoStreamResponse>;
2342
+ request(options: RezoRequestOptions & {
2343
+ responseType: "arrayBuffer";
2344
+ }): Promise<RezoResponse<ArrayBuffer>>;
2345
+ request(options: RezoRequestOptions & {
2346
+ responseType: "buffer";
2347
+ }): Promise<RezoResponse<Buffer>>;
2348
+ request(options: RezoRequestOptions & {
2349
+ responseType: "blob";
2350
+ }): Promise<RezoResponse<Blob$1>>;
2351
+ request(options: RezoRequestOptions & {
2352
+ responseType: "text";
2353
+ }): Promise<RezoResponse<string>>;
2354
+ request(options: RezoRequestOptions & {
2355
+ responseType: "download";
2356
+ }): Promise<RezoDownloadResponse>;
2357
+ request(options: RezoRequestOptions & {
2358
+ fileName: string;
2359
+ }): Promise<RezoDownloadResponse>;
2360
+ request(options: RezoRequestOptions & {
2361
+ saveTo: string;
2362
+ }): Promise<RezoDownloadResponse>;
2363
+ request(options: RezoRequestOptions & {
2364
+ responseType: "upload";
2365
+ }): Promise<RezoUploadResponse>;
2366
+ get<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2367
+ get<T = any>(url: string | URL, options?: RezoHttpGetRequest): Promise<RezoResponse<T>>;
2368
+ get<T = any>(url: string | URL, options: RezoHttpGetRequest & {
2369
+ responseType: "auto" | "json";
2370
+ }): Promise<RezoResponse<T>>;
2371
+ get(url: string | URL, options: RezoHttpGetRequest & {
2372
+ responseType: "stream";
2373
+ }): Promise<RezoStreamResponse>;
2374
+ get(url: string | URL, options: RezoHttpGetRequest & {
2375
+ responseType: "arrayBuffer";
2376
+ }): Promise<RezoResponse<ArrayBuffer>>;
2377
+ get(url: string | URL, options: RezoHttpGetRequest & {
2378
+ responseType: "buffer";
2379
+ }): Promise<RezoResponse<Buffer>>;
2380
+ get(url: string | URL, options: RezoHttpGetRequest & {
2381
+ responseType: "blob";
2382
+ }): Promise<RezoResponse<Blob$1>>;
2383
+ get(url: string | URL, options: RezoHttpGetRequest & {
2384
+ responseType: "text";
2385
+ }): Promise<RezoResponse<string>>;
2386
+ get(url: string | URL, options: RezoHttpGetRequest & {
2387
+ responseType: "download";
2388
+ }): Promise<RezoDownloadResponse>;
2389
+ get(url: string | URL, options: RezoHttpGetRequest & {
2390
+ fileName: string;
2391
+ }): Promise<RezoDownloadResponse>;
2392
+ get(url: string | URL, options: RezoHttpGetRequest & {
2393
+ saveTo: string;
2394
+ }): Promise<RezoDownloadResponse>;
2395
+ head(url: string | URL): Promise<RezoResponse<null>>;
2396
+ head(url: string | URL, options: RezoHttpHeadRequest): Promise<RezoResponse<null>>;
2397
+ options<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2398
+ options<T = any>(url: string | URL, options: RezoHttpOptionsRequest): Promise<RezoResponse<T>>;
2399
+ trace<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2400
+ trace<T = any>(url: string | URL, options: RezoHttpRequest): Promise<RezoResponse<T>>;
2401
+ delete<T = any>(url: string | URL, options?: RezoHttpDeleteRequest): Promise<RezoResponse<T>>;
2402
+ delete<T = any>(url: string | URL, options: RezoHttpDeleteRequest & {
2403
+ responseType: "auto" | "json";
2404
+ }): Promise<RezoResponse<T>>;
2405
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2406
+ responseType: "stream";
2407
+ }): Promise<RezoStreamResponse>;
2408
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2409
+ responseType: "arrayBuffer";
2410
+ }): Promise<RezoResponse<ArrayBuffer>>;
2411
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2412
+ responseType: "buffer";
2413
+ }): Promise<RezoResponse<Buffer>>;
2414
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2415
+ responseType: "blob";
2416
+ }): Promise<RezoResponse<Blob$1>>;
2417
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2418
+ responseType: "text";
2419
+ }): Promise<RezoResponse<string>>;
2420
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2421
+ responseType: "download";
2422
+ }): Promise<RezoDownloadResponse>;
2423
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2424
+ fileName: string;
2425
+ }): Promise<RezoDownloadResponse>;
2426
+ delete(url: string | URL, options: RezoHttpDeleteRequest & {
2427
+ saveTo: string;
2428
+ }): Promise<RezoDownloadResponse>;
2429
+ }
2430
+ /**
2431
+ * Extended URLSearchParams that supports nested objects and arrays
2432
+ * for application/x-www-form-urlencoded encoding
2433
+ */
2434
+ export type Primitive = string | number | boolean | null | undefined | Date;
2435
+ export type NestedValue = Primitive | NestedObject | NestedArray;
2436
+ export type NestedObject = {
2437
+ [key: string]: NestedValue;
2438
+ };
2439
+ export type NestedArray = NestedValue[];
2440
+ declare class RezoURLSearchParams extends URLSearchParams {
2441
+ constructor(init?: string | URLSearchParams | NestedObject | string[][] | RezoURLSearchParams);
2442
+ /**
2443
+ * Append a nested object to the search params
2444
+ */
2445
+ appendObject(obj: NestedObject, prefix?: string): void;
2446
+ /**
2447
+ * Set a value (replacing existing values with the same key)
2448
+ */
2449
+ setObject(obj: NestedObject, prefix?: string): void;
2450
+ /**
2451
+ * Append a value with proper handling for different types
2452
+ */
2453
+ private appendValue;
2454
+ /**
2455
+ * Append an array with proper indexing
2456
+ */
2457
+ private appendArray;
2458
+ /**
2459
+ * Convert to a plain object (useful for debugging)
2460
+ */
2461
+ toObject(): Record<string, string>;
2462
+ /**
2463
+ * Create from a flat object with bracket notation keys
2464
+ */
2465
+ static fromFlat(flat: Record<string, string>): RezoURLSearchParams;
2466
+ }
2467
+ export interface httpAdapterPostOverloads {
2468
+ post<T = any>(url: string | URL, data?: any): Promise<RezoResponse<T>>;
2469
+ post<T = any>(url: string | URL, data: any, options?: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2470
+ post<T = any>(url: string | URL, data: any, options: RezoHttpPostRequest & {
2471
+ responseType: "auto" | "json";
2472
+ }): Promise<RezoResponse<T>>;
2473
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2474
+ responseType: "stream";
2475
+ }): Promise<RezoStreamResponse>;
2476
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2477
+ responseType: "arrayBuffer";
2478
+ }): Promise<RezoResponse<ArrayBuffer>>;
2479
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2480
+ responseType: "buffer";
2481
+ }): Promise<RezoResponse<Buffer>>;
2482
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2483
+ responseType: "blob";
2484
+ }): Promise<RezoResponse<Blob$1>>;
2485
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2486
+ responseType: "text";
2487
+ }): Promise<RezoResponse<string>>;
2488
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2489
+ responseType: "download";
2490
+ }): Promise<RezoDownloadResponse>;
2491
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2492
+ fileName: string;
2493
+ }): Promise<RezoDownloadResponse>;
2494
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2495
+ saveTo: string;
2496
+ }): Promise<RezoDownloadResponse>;
2497
+ post(url: string | URL, data: any, options: RezoHttpPostRequest & {
2498
+ responseType: "upload";
2499
+ }): Promise<RezoUploadResponse>;
2500
+ postJson<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2501
+ postJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>): Promise<RezoResponse<T>>;
2502
+ postJson<T = any>(url: string | URL, jsonString: string): Promise<RezoResponse<T>>;
2503
+ postJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2504
+ postJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2505
+ postJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2506
+ postJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
2507
+ responseType: "auto" | "json";
2508
+ }): Promise<RezoResponse<T>>;
2509
+ postJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
2510
+ responseType: "auto" | "json";
2511
+ }): Promise<RezoResponse<T>>;
2512
+ postJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2513
+ responseType: "auto" | "json";
2514
+ }): Promise<RezoResponse<T>>;
2515
+ postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
2516
+ responseType: "text";
2517
+ }): Promise<RezoResponse<string>>;
2518
+ postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
2519
+ responseType: "text";
2520
+ }): Promise<RezoResponse<string>>;
2521
+ postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2522
+ responseType: "text";
2523
+ }): Promise<RezoResponse<string>>;
2524
+ postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
2525
+ responseType: "arrayBuffer";
2526
+ }): Promise<RezoResponse<ArrayBuffer>>;
2527
+ postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
2528
+ responseType: "arrayBuffer";
2529
+ }): Promise<RezoResponse<ArrayBuffer>>;
2530
+ postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2531
+ responseType: "arrayBuffer";
2532
+ }): Promise<RezoResponse<ArrayBuffer>>;
2533
+ postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
2534
+ responseType: "buffer";
2535
+ }): Promise<RezoResponse<Buffer>>;
2536
+ postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
2537
+ responseType: "buffer";
2538
+ }): Promise<RezoResponse<Buffer>>;
2539
+ postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2540
+ responseType: "buffer";
2541
+ }): Promise<RezoResponse<Buffer>>;
2542
+ postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
2543
+ responseType: "blob";
2544
+ }): Promise<RezoResponse<Blob$1>>;
2545
+ postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
2546
+ responseType: "blob";
2547
+ }): Promise<RezoResponse<Blob$1>>;
2548
+ postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2549
+ responseType: "blob";
2550
+ }): Promise<RezoResponse<Blob$1>>;
2551
+ postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
2552
+ responseType: "stream";
2553
+ }): Promise<RezoStreamResponse>;
2554
+ postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
2555
+ responseType: "stream";
2556
+ }): Promise<RezoStreamResponse>;
2557
+ postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2558
+ responseType: "stream";
2559
+ }): Promise<RezoStreamResponse>;
2560
+ postForm<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2561
+ postForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>): Promise<RezoResponse<T>>;
2562
+ postForm<T = any>(url: string | URL, string: string): Promise<RezoResponse<T>>;
2563
+ postForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2564
+ postForm<T = any>(url: string | URL, string: string, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2565
+ postForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2566
+ postForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
2567
+ responseType: "auto" | "json";
2568
+ }): Promise<RezoResponse<T>>;
2569
+ postForm<T = any>(url: string | URL, string: string, options: RezoHttpPostRequest & {
2570
+ responseType: "auto" | "json";
2571
+ }): Promise<RezoResponse<T>>;
2572
+ postForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2573
+ responseType: "auto" | "json";
2574
+ }): Promise<RezoResponse<T>>;
2575
+ postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
2576
+ responseType: "text";
2577
+ }): Promise<RezoResponse<string>>;
2578
+ postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
2579
+ responseType: "text";
2580
+ }): Promise<RezoResponse<string>>;
2581
+ postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2582
+ responseType: "text";
2583
+ }): Promise<RezoResponse<string>>;
2584
+ postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
2585
+ responseType: "arrayBuffer";
2586
+ }): Promise<RezoResponse<ArrayBuffer>>;
2587
+ postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
2588
+ responseType: "arrayBuffer";
2589
+ }): Promise<RezoResponse<ArrayBuffer>>;
2590
+ postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2591
+ responseType: "arrayBuffer";
2592
+ }): Promise<RezoResponse<ArrayBuffer>>;
2593
+ postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
2594
+ responseType: "buffer";
2595
+ }): Promise<RezoResponse<Buffer>>;
2596
+ postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
2597
+ responseType: "buffer";
2598
+ }): Promise<RezoResponse<Buffer>>;
2599
+ postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2600
+ responseType: "buffer";
2601
+ }): Promise<RezoResponse<Buffer>>;
2602
+ postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
2603
+ responseType: "blob";
2604
+ }): Promise<RezoResponse<Blob$1>>;
2605
+ postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
2606
+ responseType: "blob";
2607
+ }): Promise<RezoResponse<Blob$1>>;
2608
+ postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2609
+ responseType: "blob";
2610
+ }): Promise<RezoResponse<Blob$1>>;
2611
+ postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
2612
+ responseType: "stream";
2613
+ }): Promise<RezoStreamResponse>;
2614
+ postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
2615
+ responseType: "stream";
2616
+ }): Promise<RezoStreamResponse>;
2617
+ postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
2618
+ responseType: "stream";
2619
+ }): Promise<RezoStreamResponse>;
2620
+ postMultipart<T = any>(url: string | URL, formData: RezoFormData): Promise<RezoResponse<T>>;
2621
+ postMultipart<T = any>(url: string | URL, formData: FormData): Promise<RezoResponse<T>>;
2622
+ postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>): Promise<RezoResponse<T>>;
2623
+ postMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2624
+ postMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2625
+ postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
2626
+ postMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2627
+ responseType: "auto";
2628
+ }): Promise<RezoResponse<T>>;
2629
+ postMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2630
+ responseType: "auto";
2631
+ }): Promise<RezoResponse<T>>;
2632
+ postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2633
+ responseType: "auto";
2634
+ }): Promise<RezoResponse<T>>;
2635
+ postMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2636
+ responseType: "json";
2637
+ }): Promise<RezoResponse<T>>;
2638
+ postMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2639
+ responseType: "json";
2640
+ }): Promise<RezoResponse<T>>;
2641
+ postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2642
+ responseType: "json";
2643
+ }): Promise<RezoResponse<T>>;
2644
+ postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2645
+ responseType: "text";
2646
+ }): Promise<RezoResponse<string>>;
2647
+ postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2648
+ responseType: "text";
2649
+ }): Promise<RezoResponse<string>>;
2650
+ postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2651
+ responseType: "text";
2652
+ }): Promise<RezoResponse<string>>;
2653
+ postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2654
+ responseType: "stream";
2655
+ }): Promise<RezoStreamResponse>;
2656
+ postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2657
+ responseType: "stream";
2658
+ }): Promise<RezoStreamResponse>;
2659
+ postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2660
+ responseType: "stream";
2661
+ }): Promise<RezoStreamResponse>;
2662
+ postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2663
+ responseType: "arrayBuffer";
2664
+ }): Promise<RezoResponse<ArrayBuffer>>;
2665
+ postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2666
+ responseType: "arrayBuffer";
2667
+ }): Promise<RezoResponse<ArrayBuffer>>;
2668
+ postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2669
+ responseType: "arrayBuffer";
2670
+ }): Promise<RezoResponse<ArrayBuffer>>;
2671
+ postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2672
+ responseType: "buffer";
2673
+ }): Promise<RezoResponse<Buffer>>;
2674
+ postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2675
+ responseType: "buffer";
2676
+ }): Promise<RezoResponse<Buffer>>;
2677
+ postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2678
+ responseType: "buffer";
2679
+ }): Promise<RezoResponse<Buffer>>;
2680
+ postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
2681
+ responseType: "blob";
2682
+ }): Promise<RezoResponse<Blob$1>>;
2683
+ postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
2684
+ responseType: "blob";
2685
+ }): Promise<RezoResponse<Blob$1>>;
2686
+ postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
2687
+ responseType: "blob";
2688
+ }): Promise<RezoResponse<Blob$1>>;
2689
+ }
2690
+ export interface httpAdapterPatchOverloads {
2691
+ patch<T = any>(url: string | URL, data?: any): Promise<RezoResponse<T>>;
2692
+ patch<T = any>(url: string | URL, data: any, options?: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2693
+ patch<T = any>(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2694
+ responseType: "auto" | "json";
2695
+ }): Promise<RezoResponse<T>>;
2696
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2697
+ responseType: "stream";
2698
+ }): RezoStreamResponse;
2699
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2700
+ responseType: "arrayBuffer";
2701
+ }): Promise<RezoResponse<ArrayBuffer>>;
2702
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2703
+ responseType: "buffer";
2704
+ }): Promise<RezoResponse<Buffer>>;
2705
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2706
+ responseType: "blob";
2707
+ }): Promise<RezoResponse<Blob$1>>;
2708
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2709
+ responseType: "text";
2710
+ }): Promise<RezoResponse<string>>;
2711
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2712
+ responseType: "download";
2713
+ }): RezoDownloadResponse;
2714
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2715
+ fileName: string;
2716
+ }): RezoDownloadResponse;
2717
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2718
+ saveTo: string;
2719
+ }): RezoDownloadResponse;
2720
+ patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
2721
+ responseType: "upload";
2722
+ }): Promise<RezoUploadResponse>;
2723
+ patchJson<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2724
+ patchJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>): Promise<RezoResponse<T>>;
2725
+ patchJson<T = any>(url: string | URL, jsonString: string): Promise<RezoResponse<T>>;
2726
+ patchJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2727
+ patchJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2728
+ patchJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2729
+ patchJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2730
+ responseType: "auto" | "json";
2731
+ }): Promise<RezoResponse<T>>;
2732
+ patchJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2733
+ responseType: "auto" | "json";
2734
+ }): Promise<RezoResponse<T>>;
2735
+ patchJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2736
+ responseType: "auto" | "json";
2737
+ }): Promise<RezoResponse<T>>;
2738
+ patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2739
+ responseType: "text";
2740
+ }): Promise<RezoResponse<string>>;
2741
+ patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2742
+ responseType: "text";
2743
+ }): Promise<RezoResponse<string>>;
2744
+ patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2745
+ responseType: "text";
2746
+ }): Promise<RezoResponse<string>>;
2747
+ patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2748
+ responseType: "arrayBuffer";
2749
+ }): Promise<RezoResponse<ArrayBuffer>>;
2750
+ patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2751
+ responseType: "arrayBuffer";
2752
+ }): Promise<RezoResponse<ArrayBuffer>>;
2753
+ patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2754
+ responseType: "arrayBuffer";
2755
+ }): Promise<RezoResponse<ArrayBuffer>>;
2756
+ patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2757
+ responseType: "buffer";
2758
+ }): Promise<RezoResponse<Buffer>>;
2759
+ patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2760
+ responseType: "buffer";
2761
+ }): Promise<RezoResponse<Buffer>>;
2762
+ patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2763
+ responseType: "buffer";
2764
+ }): Promise<RezoResponse<Buffer>>;
2765
+ patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2766
+ responseType: "blob";
2767
+ }): Promise<RezoResponse<Blob$1>>;
2768
+ patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2769
+ responseType: "blob";
2770
+ }): Promise<RezoResponse<Blob$1>>;
2771
+ patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2772
+ responseType: "blob";
2773
+ }): Promise<RezoResponse<Blob$1>>;
2774
+ patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2775
+ responseType: "stream";
2776
+ }): RezoStreamResponse;
2777
+ patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2778
+ responseType: "stream";
2779
+ }): RezoStreamResponse;
2780
+ patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2781
+ responseType: "stream";
2782
+ }): RezoStreamResponse;
2783
+ patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
2784
+ responseType: "upload";
2785
+ }): Promise<RezoUploadResponse>;
2786
+ patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
2787
+ responseType: "upload";
2788
+ }): Promise<RezoUploadResponse>;
2789
+ patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2790
+ responseType: "upload";
2791
+ }): Promise<RezoUploadResponse>;
2792
+ patchForm<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2793
+ patchForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>): Promise<RezoResponse<T>>;
2794
+ patchForm<T = any>(url: string | URL, string: string): Promise<RezoResponse<T>>;
2795
+ patchForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2796
+ patchForm<T = any>(url: string | URL, string: string, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2797
+ patchForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2798
+ patchForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2799
+ responseType: "auto" | "json";
2800
+ }): Promise<RezoResponse<T>>;
2801
+ patchForm<T = any>(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2802
+ responseType: "auto" | "json";
2803
+ }): Promise<RezoResponse<T>>;
2804
+ patchForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2805
+ responseType: "auto" | "json";
2806
+ }): Promise<RezoResponse<T>>;
2807
+ patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2808
+ responseType: "text";
2809
+ }): Promise<RezoResponse<string>>;
2810
+ patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2811
+ responseType: "text";
2812
+ }): Promise<RezoResponse<string>>;
2813
+ patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2814
+ responseType: "text";
2815
+ }): Promise<RezoResponse<string>>;
2816
+ patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2817
+ responseType: "arrayBuffer";
2818
+ }): Promise<RezoResponse<ArrayBuffer>>;
2819
+ patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2820
+ responseType: "arrayBuffer";
2821
+ }): Promise<RezoResponse<ArrayBuffer>>;
2822
+ patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2823
+ responseType: "arrayBuffer";
2824
+ }): Promise<RezoResponse<ArrayBuffer>>;
2825
+ patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2826
+ responseType: "buffer";
2827
+ }): Promise<RezoResponse<Buffer>>;
2828
+ patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2829
+ responseType: "buffer";
2830
+ }): Promise<RezoResponse<Buffer>>;
2831
+ patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2832
+ responseType: "buffer";
2833
+ }): Promise<RezoResponse<Buffer>>;
2834
+ patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2835
+ responseType: "blob";
2836
+ }): Promise<RezoResponse<Blob$1>>;
2837
+ patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2838
+ responseType: "blob";
2839
+ }): Promise<RezoResponse<Blob$1>>;
2840
+ patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2841
+ responseType: "blob";
2842
+ }): Promise<RezoResponse<Blob$1>>;
2843
+ patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2844
+ responseType: "stream";
2845
+ }): RezoStreamResponse;
2846
+ patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2847
+ responseType: "stream";
2848
+ }): RezoStreamResponse;
2849
+ patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2850
+ responseType: "stream";
2851
+ }): RezoStreamResponse;
2852
+ patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
2853
+ responseType: "upload";
2854
+ }): Promise<RezoUploadResponse>;
2855
+ patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
2856
+ responseType: "upload";
2857
+ }): Promise<RezoUploadResponse>;
2858
+ patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
2859
+ responseType: "upload";
2860
+ }): Promise<RezoUploadResponse>;
2861
+ patchMultipart<T = any>(url: string | URL, formData: RezoFormData): Promise<RezoResponse<T>>;
2862
+ patchMultipart<T = any>(url: string | URL, formData: FormData): Promise<RezoResponse<T>>;
2863
+ patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>): Promise<RezoResponse<T>>;
2864
+ patchMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2865
+ patchMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2866
+ patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
2867
+ patchMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2868
+ responseType: "auto" | "json";
2869
+ }): Promise<RezoResponse<T>>;
2870
+ patchMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2871
+ responseType: "auto" | "json";
2872
+ }): Promise<RezoResponse<T>>;
2873
+ patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2874
+ responseType: "auto" | "json";
2875
+ }): Promise<RezoResponse<T>>;
2876
+ patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2877
+ responseType: "text";
2878
+ }): Promise<RezoResponse<string>>;
2879
+ patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2880
+ responseType: "text";
2881
+ }): Promise<RezoResponse<string>>;
2882
+ patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2883
+ responseType: "text";
2884
+ }): Promise<RezoResponse<string>>;
2885
+ patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2886
+ responseType: "stream";
2887
+ }): RezoStreamResponse;
2888
+ patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2889
+ responseType: "stream";
2890
+ }): RezoStreamResponse;
2891
+ patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2892
+ responseType: "stream";
2893
+ }): RezoStreamResponse;
2894
+ patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2895
+ responseType: "arrayBuffer";
2896
+ }): Promise<RezoResponse<ArrayBuffer>>;
2897
+ patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2898
+ responseType: "arrayBuffer";
2899
+ }): Promise<RezoResponse<ArrayBuffer>>;
2900
+ patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2901
+ responseType: "arrayBuffer";
2902
+ }): Promise<RezoResponse<ArrayBuffer>>;
2903
+ patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2904
+ responseType: "buffer";
2905
+ }): Promise<RezoResponse<Buffer>>;
2906
+ patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2907
+ responseType: "buffer";
2908
+ }): Promise<RezoResponse<Buffer>>;
2909
+ patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2910
+ responseType: "buffer";
2911
+ }): Promise<RezoResponse<Buffer>>;
2912
+ patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2913
+ responseType: "blob";
2914
+ }): Promise<RezoResponse<Blob$1>>;
2915
+ patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2916
+ responseType: "blob";
2917
+ }): Promise<RezoResponse<Blob$1>>;
2918
+ patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2919
+ responseType: "blob";
2920
+ }): Promise<RezoResponse<Blob$1>>;
2921
+ patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
2922
+ responseType: "upload";
2923
+ }): Promise<RezoUploadResponse>;
2924
+ patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
2925
+ responseType: "upload";
2926
+ }): Promise<RezoUploadResponse>;
2927
+ patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
2928
+ responseType: "upload";
2929
+ }): Promise<RezoUploadResponse>;
2930
+ }
2931
+ export interface httpAdapterPutOverloads {
2932
+ put<T = any>(url: string | URL, data?: any): Promise<RezoResponse<T>>;
2933
+ put<T = any>(url: string | URL, data: any, options?: RezoHttpPutRequest): Promise<RezoResponse<T>>;
2934
+ put<T = any>(url: string | URL, data: any, options: RezoHttpPutRequest & {
2935
+ responseType: "auto" | "json";
2936
+ }): Promise<RezoResponse<T>>;
2937
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2938
+ responseType: "stream";
2939
+ }): RezoStreamResponse;
2940
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2941
+ responseType: "arrayBuffer";
2942
+ }): Promise<RezoResponse<ArrayBuffer>>;
2943
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2944
+ responseType: "buffer";
2945
+ }): Promise<RezoResponse<Buffer>>;
2946
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2947
+ responseType: "blob";
2948
+ }): Promise<RezoResponse<Blob$1>>;
2949
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2950
+ responseType: "text";
2951
+ }): Promise<RezoResponse<string>>;
2952
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2953
+ responseType: "download";
2954
+ }): RezoDownloadResponse;
2955
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2956
+ fileName: string;
2957
+ }): RezoDownloadResponse;
2958
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2959
+ saveTo: string;
2960
+ }): RezoDownloadResponse;
2961
+ put(url: string | URL, data: any, options: RezoHttpPutRequest & {
2962
+ responseType: "upload";
2963
+ }): Promise<RezoUploadResponse>;
2964
+ putJson<T = any>(url: string | URL): Promise<RezoResponse<T>>;
2965
+ putJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>): Promise<RezoResponse<T>>;
2966
+ putJson<T = any>(url: string | URL, jsonString: string): Promise<RezoResponse<T>>;
2967
+ putJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
2968
+ putJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
2969
+ putJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
2970
+ putJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
2971
+ responseType: "auto" | "json";
2972
+ }): Promise<RezoResponse<T>>;
2973
+ putJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
2974
+ responseType: "auto" | "json";
2975
+ }): Promise<RezoResponse<T>>;
2976
+ putJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
2977
+ responseType: "auto" | "json";
2978
+ }): Promise<RezoResponse<T>>;
2979
+ putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
2980
+ responseType: "text";
2981
+ }): Promise<RezoResponse<string>>;
2982
+ putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
2983
+ responseType: "text";
2984
+ }): Promise<RezoResponse<string>>;
2985
+ putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
2986
+ responseType: "text";
2987
+ }): Promise<RezoResponse<string>>;
2988
+ putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
2989
+ responseType: "arrayBuffer";
2990
+ }): Promise<RezoResponse<ArrayBuffer>>;
2991
+ putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
2992
+ responseType: "arrayBuffer";
2993
+ }): Promise<RezoResponse<ArrayBuffer>>;
2994
+ putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
2995
+ responseType: "arrayBuffer";
2996
+ }): Promise<RezoResponse<ArrayBuffer>>;
2997
+ putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
2998
+ responseType: "buffer";
2999
+ }): Promise<RezoResponse<Buffer>>;
3000
+ putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
3001
+ responseType: "buffer";
3002
+ }): Promise<RezoResponse<Buffer>>;
3003
+ putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3004
+ responseType: "buffer";
3005
+ }): Promise<RezoResponse<Buffer>>;
3006
+ putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
3007
+ responseType: "blob";
3008
+ }): Promise<RezoResponse<Blob$1>>;
3009
+ putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
3010
+ responseType: "blob";
3011
+ }): Promise<RezoResponse<Blob$1>>;
3012
+ putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3013
+ responseType: "blob";
3014
+ }): Promise<RezoResponse<Blob$1>>;
3015
+ putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
3016
+ responseType: "stream";
3017
+ }): RezoStreamResponse;
3018
+ putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
3019
+ responseType: "stream";
3020
+ }): RezoStreamResponse;
3021
+ putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3022
+ responseType: "stream";
3023
+ }): RezoStreamResponse;
3024
+ putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
3025
+ responseType: "upload";
3026
+ }): Promise<RezoUploadResponse>;
3027
+ putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
3028
+ responseType: "upload";
3029
+ }): Promise<RezoUploadResponse>;
3030
+ putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3031
+ responseType: "upload";
3032
+ }): Promise<RezoUploadResponse>;
3033
+ putForm<T = any>(url: string | URL): Promise<RezoResponse<T>>;
3034
+ putForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>): Promise<RezoResponse<T>>;
3035
+ putForm<T = any>(url: string | URL, string: string): Promise<RezoResponse<T>>;
3036
+ putForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
3037
+ putForm<T = any>(url: string | URL, string: string, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
3038
+ putForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
3039
+ putForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3040
+ responseType: "auto" | "json";
3041
+ }): Promise<RezoResponse<T>>;
3042
+ putForm<T = any>(url: string | URL, string: string, options: RezoHttpPutRequest & {
3043
+ responseType: "auto" | "json";
3044
+ }): Promise<RezoResponse<T>>;
3045
+ putForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3046
+ responseType: "auto" | "json";
3047
+ }): Promise<RezoResponse<T>>;
3048
+ putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3049
+ responseType: "text";
3050
+ }): Promise<RezoResponse<string>>;
3051
+ putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
3052
+ responseType: "text";
3053
+ }): Promise<RezoResponse<string>>;
3054
+ putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3055
+ responseType: "text";
3056
+ }): Promise<RezoResponse<string>>;
3057
+ putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3058
+ responseType: "arrayBuffer";
3059
+ }): Promise<RezoResponse<ArrayBuffer>>;
3060
+ putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
3061
+ responseType: "arrayBuffer";
3062
+ }): Promise<RezoResponse<ArrayBuffer>>;
3063
+ putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3064
+ responseType: "arrayBuffer";
3065
+ }): Promise<RezoResponse<ArrayBuffer>>;
3066
+ putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3067
+ responseType: "buffer";
3068
+ }): Promise<RezoResponse<Buffer>>;
3069
+ putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
3070
+ responseType: "buffer";
3071
+ }): Promise<RezoResponse<Buffer>>;
3072
+ putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3073
+ responseType: "buffer";
3074
+ }): Promise<RezoResponse<Buffer>>;
3075
+ putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3076
+ responseType: "blob";
3077
+ }): Promise<RezoResponse<Blob$1>>;
3078
+ putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
3079
+ responseType: "blob";
3080
+ }): Promise<RezoResponse<Blob$1>>;
3081
+ putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3082
+ responseType: "blob";
3083
+ }): Promise<RezoResponse<Blob$1>>;
3084
+ putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3085
+ responseType: "stream";
3086
+ }): RezoStreamResponse;
3087
+ putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
3088
+ responseType: "stream";
3089
+ }): RezoStreamResponse;
3090
+ putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3091
+ responseType: "stream";
3092
+ }): RezoStreamResponse;
3093
+ putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
3094
+ responseType: "upload";
3095
+ }): Promise<RezoUploadResponse>;
3096
+ putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
3097
+ responseType: "upload";
3098
+ }): Promise<RezoUploadResponse>;
3099
+ putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
3100
+ responseType: "upload";
3101
+ }): Promise<RezoUploadResponse>;
3102
+ putMultipart<T = any>(url: string | URL, formData: RezoFormData): Promise<RezoResponse<T>>;
3103
+ putMultipart<T = any>(url: string | URL, formData: FormData): Promise<RezoResponse<T>>;
3104
+ putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>): Promise<RezoResponse<T>>;
3105
+ putMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
3106
+ putMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
3107
+ putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
3108
+ putMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3109
+ responseType: "auto" | "json";
3110
+ }): Promise<RezoResponse<T>>;
3111
+ putMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3112
+ responseType: "auto" | "json";
3113
+ }): Promise<RezoResponse<T>>;
3114
+ putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3115
+ responseType: "auto" | "json";
3116
+ }): Promise<RezoResponse<T>>;
3117
+ putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3118
+ responseType: "text";
3119
+ }): Promise<RezoResponse<string>>;
3120
+ putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3121
+ responseType: "text";
3122
+ }): Promise<RezoResponse<string>>;
3123
+ putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3124
+ responseType: "text";
3125
+ }): Promise<RezoResponse<string>>;
3126
+ putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3127
+ responseType: "stream";
3128
+ }): RezoStreamResponse;
3129
+ putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3130
+ responseType: "stream";
3131
+ }): RezoStreamResponse;
3132
+ putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3133
+ responseType: "stream";
3134
+ }): RezoStreamResponse;
3135
+ putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3136
+ responseType: "arrayBuffer";
3137
+ }): Promise<RezoResponse<ArrayBuffer>>;
3138
+ putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3139
+ responseType: "arrayBuffer";
3140
+ }): Promise<RezoResponse<ArrayBuffer>>;
3141
+ putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3142
+ responseType: "arrayBuffer";
3143
+ }): Promise<RezoResponse<ArrayBuffer>>;
3144
+ putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3145
+ responseType: "buffer";
3146
+ }): Promise<RezoResponse<Buffer>>;
3147
+ putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3148
+ responseType: "buffer";
3149
+ }): Promise<RezoResponse<Buffer>>;
3150
+ putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3151
+ responseType: "buffer";
3152
+ }): Promise<RezoResponse<Buffer>>;
3153
+ putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3154
+ responseType: "blob";
3155
+ }): Promise<RezoResponse<Blob$1>>;
3156
+ putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3157
+ responseType: "blob";
3158
+ }): Promise<RezoResponse<Blob$1>>;
3159
+ putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3160
+ responseType: "blob";
3161
+ }): Promise<RezoResponse<Blob$1>>;
3162
+ putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
3163
+ responseType: "upload";
3164
+ }): Promise<RezoUploadResponse>;
3165
+ putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
3166
+ responseType: "upload";
3167
+ }): Promise<RezoUploadResponse>;
3168
+ putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
3169
+ responseType: "upload";
3170
+ }): Promise<RezoUploadResponse>;
3171
+ }
3172
+ /**
3173
+ * Adapter function type - all adapters must implement this signature
3174
+ */
3175
+ export type AdapterFunction<T = any> = (options: RezoRequestConfig, defaultOptions: RezoDefaultOptions, jar: RezoCookieJar) => Promise<RezoResponse<T> | RezoStreamResponse | RezoDownloadResponse | RezoUploadResponse>;
3176
+ /**
3177
+ * Main Rezo class - Enterprise-grade HTTP client with advanced features
3178
+ */
3179
+ export declare class Rezo {
3180
+ protected queue: PQueue | null;
3181
+ protected isQueueEnabled: boolean;
3182
+ defaults: RezoDefaultOptions;
3183
+ hooks: RezoHooks;
3184
+ private jar;
3185
+ /** Session ID persists across all requests from this instance */
3186
+ readonly sessionId: string;
3187
+ /** Response cache for caching HTTP responses */
3188
+ readonly responseCache?: ResponseCache;
3189
+ /** DNS cache for caching DNS lookups */
3190
+ readonly dnsCache?: DNSCache;
3191
+ /** The adapter function used for HTTP requests */
3192
+ private readonly adapter;
3193
+ constructor(config?: RezoDefaultOptions, adapter?: AdapterFunction);
3194
+ /**
3195
+ * Clear all caches (response and DNS)
3196
+ */
3197
+ clearCache(): void;
3198
+ /**
3199
+ * Invalidate cached response for a specific URL
3200
+ */
3201
+ invalidateCache(url: string, method?: string): void;
3202
+ /**
3203
+ * Get cache statistics
3204
+ */
3205
+ getCacheStats(): {
3206
+ response?: {
3207
+ size: number;
3208
+ enabled: boolean;
3209
+ persistent: boolean;
3210
+ };
3211
+ dns?: {
3212
+ size: number;
3213
+ enabled: boolean;
3214
+ };
3215
+ };
3216
+ get: httpAdapterOverloads["get"];
3217
+ head: httpAdapterOverloads["head"];
3218
+ options: httpAdapterOverloads["options"];
3219
+ trace: httpAdapterOverloads["trace"];
3220
+ delete: httpAdapterOverloads["delete"];
3221
+ request: httpAdapterOverloads["request"];
3222
+ post: httpAdapterPostOverloads["post"];
3223
+ postJson: httpAdapterPostOverloads["postJson"];
3224
+ postForm: httpAdapterPostOverloads["postForm"];
3225
+ postMultipart: httpAdapterPostOverloads["postMultipart"];
3226
+ put: httpAdapterPutOverloads["put"];
3227
+ putJson: httpAdapterPutOverloads["putJson"];
3228
+ putForm: httpAdapterPutOverloads["putForm"];
3229
+ putMultipart: httpAdapterPutOverloads["putMultipart"];
3230
+ patch: httpAdapterPatchOverloads["patch"];
3231
+ patchJson: httpAdapterPatchOverloads["patchJson"];
3232
+ patchForm: httpAdapterPatchOverloads["patchForm"];
3233
+ patchMultipart: httpAdapterPatchOverloads["patchMultipart"];
3234
+ private executeRequest;
3235
+ private buildFullUrl;
3236
+ private isvalidJson;
3237
+ private __create;
3238
+ /** Get the cookie jar for this instance */
3239
+ get cookieJar(): RezoCookieJar;
3240
+ /**
3241
+ * Save cookies to file (if cookieFile is configured).
3242
+ * Can also specify a different path to save to.
3243
+ */
3244
+ saveCookies(filePath?: string): void;
3245
+ /**
3246
+ * Stream a resource - returns immediately with StreamResponse
3247
+ * The response data is emitted via 'data' events.
3248
+ *
3249
+ * @param url - URL to stream from
3250
+ * @param options - Request options (optional)
3251
+ * @returns StreamResponse that emits 'data', 'end', 'error' events
3252
+ *
3253
+ * @example
3254
+ * ```typescript
3255
+ * const stream = rezo.stream('https://example.com/large-file');
3256
+ * stream.on('data', (chunk) => console.log('Received:', chunk.length, 'bytes'));
3257
+ * stream.on('end', () => console.log('Stream complete'));
3258
+ * stream.on('error', (err) => console.error('Error:', err));
3259
+ * ```
3260
+ */
3261
+ stream(url: string | URL, options?: RezoHttpRequest): RezoStreamResponse;
3262
+ /**
3263
+ * Download a resource to a file - returns immediately with DownloadResponse
3264
+ * The download progress and completion are emitted via events.
3265
+ *
3266
+ * @param url - URL to download from
3267
+ * @param saveTo - File path to save the download to
3268
+ * @param options - Request options (optional)
3269
+ * @returns DownloadResponse that emits 'progress', 'complete', 'error' events
3270
+ *
3271
+ * @example
3272
+ * ```typescript
3273
+ * const download = rezo.download('https://example.com/file.zip', './downloads/file.zip');
3274
+ * download.on('progress', (p) => console.log(`${p.percent}% complete`));
3275
+ * download.on('complete', () => console.log('Download finished'));
3276
+ * download.on('error', (err) => console.error('Error:', err));
3277
+ * ```
3278
+ */
3279
+ download(url: string | URL, saveTo: string, options?: RezoHttpRequest): RezoDownloadResponse;
3280
+ /**
3281
+ * Upload data with progress tracking - returns immediately with UploadResponse
3282
+ * The upload progress and completion are emitted via events.
3283
+ *
3284
+ * @param url - URL to upload to
3285
+ * @param data - Data to upload (Buffer, FormData, string, etc.)
3286
+ * @param options - Request options (optional)
3287
+ * @returns UploadResponse that emits 'progress', 'complete', 'error' events
3288
+ *
3289
+ * @example
3290
+ * ```typescript
3291
+ * const upload = rezo.upload('https://example.com/upload', fileBuffer);
3292
+ * upload.on('progress', (p) => console.log(`${p.percent}% uploaded`));
3293
+ * upload.on('complete', (response) => console.log('Upload finished:', response));
3294
+ * upload.on('error', (err) => console.error('Error:', err));
3295
+ * ```
3296
+ */
3297
+ upload(url: string | URL, data: Buffer | FormData | RezoFormData | string | Record<string, any>, options?: RezoHttpRequest): RezoUploadResponse;
3298
+ }
3299
+ export interface RezoInstance extends Rezo {
3300
+ create(config?: RezoDefaultOptions): Rezo;
3301
+ }
3302
+ /**
3303
+ * Create a Rezo instance with a specific adapter.
3304
+ * Used by platform-specific entry files.
3305
+ */
3306
+ export declare function createRezoInstance(adapter: AdapterFunction, config?: RezoDefaultOptions): RezoInstance;
3307
+ /**
3308
+ * Create default instance using the global adapter.
3309
+ * Will throw if no global adapter has been set.
3310
+ */
3311
+ export declare function createDefaultInstance(config?: RezoDefaultOptions): RezoInstance;
3312
+ export declare const isRezoError: typeof RezoError.isRezoError;
3313
+ export declare const Cancel: typeof RezoError;
3314
+ export declare const CancelToken: {
3315
+ new (): AbortController;
3316
+ prototype: AbortController;
3317
+ };
3318
+ export declare const isCancel: (error: unknown) => boolean;
3319
+ export declare const all: {
3320
+ <T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
3321
+ <T extends readonly unknown[] | [
3322
+ ]>(values: T): Promise<{
3323
+ -readonly [P in keyof T]: Awaited<T[P]>;
3324
+ }>;
3325
+ };
3326
+ export declare const spread: <T extends unknown[], R>(callback: (...args: T) => R) => (array: T) => R;
3327
+ export declare const VERSION: string;
3328
+ declare const rezo: RezoInstance;
3329
+
3330
+ export {
3331
+ ResponseType$1 as ResponseType,
3332
+ rezo as default,
3333
+ };
3334
+
3335
+ export {};