rezo 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +261 -0
- package/dist/adapters/curl.cjs +47 -1
- package/dist/adapters/curl.js +47 -1
- package/dist/adapters/entries/curl.cjs +31 -4
- package/dist/adapters/entries/curl.d.ts +2576 -847
- package/dist/adapters/entries/curl.js +29 -2
- package/dist/adapters/entries/fetch.cjs +31 -2
- package/dist/adapters/entries/fetch.d.ts +1753 -15
- package/dist/adapters/entries/fetch.js +29 -1
- package/dist/adapters/entries/http.cjs +31 -2
- package/dist/adapters/entries/http.d.ts +1774 -14
- package/dist/adapters/entries/http.js +29 -1
- package/dist/adapters/entries/http2.cjs +31 -4
- package/dist/adapters/entries/http2.d.ts +1748 -19
- package/dist/adapters/entries/http2.js +29 -2
- package/dist/adapters/entries/react-native.cjs +31 -2
- package/dist/adapters/entries/react-native.d.ts +1753 -14
- package/dist/adapters/entries/react-native.js +29 -1
- package/dist/adapters/entries/xhr.cjs +31 -2
- package/dist/adapters/entries/xhr.d.ts +1753 -15
- package/dist/adapters/entries/xhr.js +29 -1
- package/dist/adapters/fetch.cjs +24 -20
- package/dist/adapters/fetch.js +24 -20
- package/dist/adapters/http.cjs +69 -19
- package/dist/adapters/http.js +69 -19
- package/dist/adapters/http2.cjs +69 -19
- package/dist/adapters/http2.js +69 -19
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/core/hooks.cjs +16 -0
- package/dist/core/hooks.js +16 -0
- package/dist/core/rezo.cjs +23 -1
- package/dist/core/rezo.js +23 -1
- package/dist/crawler.d.ts +528 -5
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +18 -16
- package/dist/index.d.ts +564 -5
- package/dist/index.js +1 -0
- package/dist/platform/browser.cjs +24 -2
- package/dist/platform/browser.d.ts +672 -10
- package/dist/platform/browser.js +24 -2
- package/dist/platform/bun.cjs +24 -2
- package/dist/platform/bun.d.ts +672 -10
- package/dist/platform/bun.js +24 -2
- package/dist/platform/deno.cjs +24 -2
- package/dist/platform/deno.d.ts +672 -10
- package/dist/platform/deno.js +24 -2
- package/dist/platform/node.cjs +24 -2
- package/dist/platform/node.d.ts +672 -10
- package/dist/platform/node.js +24 -2
- package/dist/platform/react-native.cjs +24 -2
- package/dist/platform/react-native.d.ts +672 -10
- package/dist/platform/react-native.js +24 -2
- package/dist/platform/worker.cjs +24 -2
- package/dist/platform/worker.d.ts +672 -10
- package/dist/platform/worker.js +24 -2
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -0
- package/dist/proxy/index.js +1 -0
- package/dist/proxy/manager.cjs +446 -0
- package/dist/proxy/manager.js +444 -0
- package/dist/utils/http-config.cjs +14 -3
- package/dist/utils/http-config.js +14 -3
- package/package.json +19 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import NodeFormData from 'form-data';
|
|
2
|
+
import { Blob as Blob$1 } from 'node:buffer';
|
|
2
3
|
import { EventEmitter } from 'node:events';
|
|
3
4
|
import { Agent as HttpAgent, OutgoingHttpHeaders } from 'node:http';
|
|
4
5
|
import { Agent as HttpsAgent } from 'node:https';
|
|
@@ -10,128 +11,6 @@ import { Options as Options$1, QueueAddOptions } from 'p-queue';
|
|
|
10
11
|
import PriorityQueue from 'p-queue/dist/priority-queue';
|
|
11
12
|
import { Cookie as TouchCookie, CookieJar as TouchCookieJar, CreateCookieOptions } from 'tough-cookie';
|
|
12
13
|
|
|
13
|
-
export interface SerializedCookie {
|
|
14
|
-
key: string;
|
|
15
|
-
value: string;
|
|
16
|
-
expires?: string;
|
|
17
|
-
maxAge?: number | "Infinity" | "-Infinity";
|
|
18
|
-
domain?: string;
|
|
19
|
-
path?: string;
|
|
20
|
-
secure?: boolean;
|
|
21
|
-
hostOnly?: boolean;
|
|
22
|
-
creation?: string;
|
|
23
|
-
lastAccessed?: string;
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}
|
|
26
|
-
declare class Cookie extends TouchCookie {
|
|
27
|
-
constructor(options?: CreateCookieOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Fixes date fields that may have become strings during JSON deserialization.
|
|
30
|
-
* This is a workaround for tough-cookie's deserialization behavior in Bun/Node.js
|
|
31
|
-
* where Date objects become ISO strings.
|
|
32
|
-
*/
|
|
33
|
-
private fixDateFields;
|
|
34
|
-
private getExpires;
|
|
35
|
-
toNetscapeFormat(): string;
|
|
36
|
-
toSetCookieString(): string;
|
|
37
|
-
/**
|
|
38
|
-
* Retrieves the complete URL from the cookie object
|
|
39
|
-
* @returns {string | undefined} The complete URL including protocol, domain and path. Returns undefined if domain is not set
|
|
40
|
-
* @example
|
|
41
|
-
* const cookie = new Cookie({
|
|
42
|
-
* domain: "example.com",
|
|
43
|
-
* path: "/path",
|
|
44
|
-
* secure: true
|
|
45
|
-
* });
|
|
46
|
-
* cookie.getURL(); // Returns: "https://example.com/path"
|
|
47
|
-
*/
|
|
48
|
-
getURL(): string | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Type guard to check if an object is an instance of Cookie
|
|
51
|
-
* @param cookie - The object to check
|
|
52
|
-
* @returns {boolean} True if the object is a Cookie instance, false otherwise
|
|
53
|
-
* @example
|
|
54
|
-
* const obj = new Cookie();
|
|
55
|
-
* if (Cookie.isCookie(obj)) {
|
|
56
|
-
* // obj is confirmed to be a Cookie instance
|
|
57
|
-
* }
|
|
58
|
-
*/
|
|
59
|
-
static isCookie(cookie: any): cookie is Cookie;
|
|
60
|
-
}
|
|
61
|
-
declare class RezoCookieJar extends TouchCookieJar {
|
|
62
|
-
constructor();
|
|
63
|
-
constructor(cookies: Cookie[]);
|
|
64
|
-
constructor(cookies: Cookie[], url: string);
|
|
65
|
-
private generateCookies;
|
|
66
|
-
cookies(): Cookies;
|
|
67
|
-
parseResponseCookies(cookies: Cookie[]): Cookies;
|
|
68
|
-
static toNetscapeCookie(cookies: Cookie[] | SerializedCookie[]): string;
|
|
69
|
-
static toCookieString(cookies: Cookie[] | SerializedCookie[]): string;
|
|
70
|
-
toCookieString(): string;
|
|
71
|
-
toNetscapeCookie(): string;
|
|
72
|
-
toArray(): Cookie[];
|
|
73
|
-
toSetCookies(): string[];
|
|
74
|
-
toSerializedCookies(): SerializedCookie[];
|
|
75
|
-
setCookiesSync(setCookieArray: string[]): Cookies;
|
|
76
|
-
setCookiesSync(setCookieArray: string[], url: string): Cookies;
|
|
77
|
-
setCookiesSync(cookiesString: string): Cookies;
|
|
78
|
-
setCookiesSync(cookiesString: string, url: string): Cookies;
|
|
79
|
-
setCookiesSync(serializedCookies: SerializedCookie[]): Cookies;
|
|
80
|
-
setCookiesSync(serializedCookies: SerializedCookie[], url: string): Cookies;
|
|
81
|
-
setCookiesSync(cookieArray: Cookie[]): Cookies;
|
|
82
|
-
setCookiesSync(cookieArray: Cookie[], url: string): Cookies;
|
|
83
|
-
private splitSetCookiesString;
|
|
84
|
-
private getUrlFromCookie;
|
|
85
|
-
private parseNetscapeCookies;
|
|
86
|
-
/**
|
|
87
|
-
* Converts Netscape cookie format to an array of Set-Cookie header strings
|
|
88
|
-
*
|
|
89
|
-
* @param netscapeCookieText - Netscape format cookie string
|
|
90
|
-
* @returns Array of Set-Cookie header strings
|
|
91
|
-
*/
|
|
92
|
-
static netscapeCookiesToSetCookieArray(netscapeCookieText: string): string[];
|
|
93
|
-
/** Path to cookie file for persistence */
|
|
94
|
-
private _cookieFile?;
|
|
95
|
-
/** Get the cookie file path */
|
|
96
|
-
get cookieFile(): string | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Load cookies from a file (sync version).
|
|
99
|
-
* - .json files are loaded as serialized JSON cookies
|
|
100
|
-
* - .txt files are loaded as Netscape format cookies
|
|
101
|
-
*
|
|
102
|
-
* This method bypasses public suffix validation for persisted cookies only,
|
|
103
|
-
* keeping normal network cookie validation intact.
|
|
104
|
-
*
|
|
105
|
-
* @param filePath - Path to the cookie file
|
|
106
|
-
* @param defaultUrl - Default URL for cookies without domain (optional)
|
|
107
|
-
*/
|
|
108
|
-
loadFromFile(filePath: string, defaultUrl?: string): void;
|
|
109
|
-
/**
|
|
110
|
-
* Save cookies to a file.
|
|
111
|
-
* - .json files save cookies as serialized JSON
|
|
112
|
-
* - .txt files save cookies in Netscape format
|
|
113
|
-
*
|
|
114
|
-
* @param filePath - Path to save the cookies (defaults to the loaded file path)
|
|
115
|
-
*/
|
|
116
|
-
saveToFile(filePath?: string): void;
|
|
117
|
-
/**
|
|
118
|
-
* Create a new RezoCookieJar from a cookie file.
|
|
119
|
-
* - .json files are loaded as serialized JSON cookies
|
|
120
|
-
* - .txt files are loaded as Netscape format cookies
|
|
121
|
-
*
|
|
122
|
-
* @param filePath - Path to the cookie file
|
|
123
|
-
* @param defaultUrl - Default URL for cookies without domain (optional)
|
|
124
|
-
* @returns A new RezoCookieJar with cookies loaded from the file
|
|
125
|
-
*/
|
|
126
|
-
static fromFile(filePath: string, defaultUrl?: string): RezoCookieJar;
|
|
127
|
-
}
|
|
128
|
-
export interface Cookies {
|
|
129
|
-
array: Cookie[];
|
|
130
|
-
serialized: SerializedCookie[];
|
|
131
|
-
netscape: string;
|
|
132
|
-
string: string;
|
|
133
|
-
setCookiesString: string[];
|
|
134
|
-
}
|
|
135
14
|
export interface RezoHttpHeaders {
|
|
136
15
|
accept?: string | undefined;
|
|
137
16
|
"accept-encoding"?: string | undefined;
|
|
@@ -225,7 +104,7 @@ export type RezoHeadersInit = [
|
|
|
225
104
|
string,
|
|
226
105
|
string
|
|
227
106
|
][] | Record<string, string> | Headers | RezoHttpHeaders | RezoHeaders | OutgoingHttpHeaders;
|
|
228
|
-
declare class RezoHeaders extends Headers {
|
|
107
|
+
export declare class RezoHeaders extends Headers {
|
|
229
108
|
constructor(init?: RezoHeadersInit);
|
|
230
109
|
getAll(name: "set-cookie" | "Set-Cookie"): string[];
|
|
231
110
|
getSetCookie(): string[];
|
|
@@ -267,6 +146,128 @@ declare class RezoHeaders extends Headers {
|
|
|
267
146
|
[util.inspect.custom](_depth: number, options: util.InspectOptionsStylized): string;
|
|
268
147
|
get [Symbol.toStringTag](): string;
|
|
269
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
|
+
}
|
|
270
271
|
export interface ReadableOptions {
|
|
271
272
|
highWaterMark?: number;
|
|
272
273
|
encoding?: string;
|
|
@@ -282,7 +283,7 @@ export interface Options extends ReadableOptions {
|
|
|
282
283
|
maxDataSize?: number;
|
|
283
284
|
pauseStreams?: boolean;
|
|
284
285
|
}
|
|
285
|
-
declare class RezoFormData extends NodeFormData {
|
|
286
|
+
export declare class RezoFormData extends NodeFormData {
|
|
286
287
|
constructor(options?: Options);
|
|
287
288
|
/**
|
|
288
289
|
* Get field entries as array of [name, value] pairs
|
|
@@ -898,54 +899,291 @@ export interface RezoDownloadResponse extends DownloadResponse {
|
|
|
898
899
|
*/
|
|
899
900
|
export interface RezoUploadResponse extends UploadResponse {
|
|
900
901
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
902
|
+
/**
|
|
903
|
+
* Rezo ProxyManager Types
|
|
904
|
+
* Type definitions for advanced proxy rotation and management
|
|
905
|
+
*
|
|
906
|
+
* @module proxy/types
|
|
907
|
+
* @author Yuniq Solutions Team
|
|
908
|
+
* @version 1.0.0
|
|
909
|
+
*/
|
|
910
|
+
/** Supported proxy protocols */
|
|
911
|
+
export type ProxyProtocol = "socks4" | "socks5" | "http" | "https";
|
|
912
|
+
/**
|
|
913
|
+
* Proxy information structure
|
|
914
|
+
* Represents a single proxy server with its connection details
|
|
915
|
+
*/
|
|
916
|
+
export interface ProxyInfo {
|
|
917
|
+
/** Unique identifier for the proxy (auto-generated if not provided) */
|
|
918
|
+
id?: string;
|
|
919
|
+
/** The proxy protocol to use */
|
|
920
|
+
protocol: ProxyProtocol;
|
|
921
|
+
/** Proxy server hostname or IP address */
|
|
922
|
+
host: string;
|
|
923
|
+
/** Proxy server port number */
|
|
924
|
+
port: number;
|
|
925
|
+
/** Optional authentication credentials for the proxy */
|
|
926
|
+
auth?: {
|
|
927
|
+
/** Username for proxy authentication */
|
|
928
|
+
username: string;
|
|
929
|
+
/** Password for proxy authentication */
|
|
930
|
+
password: string;
|
|
931
|
+
};
|
|
932
|
+
/** Optional label for identification/logging */
|
|
933
|
+
label?: string;
|
|
934
|
+
/** Optional metadata for custom tracking */
|
|
935
|
+
metadata?: Record<string, unknown>;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Proxy rotation strategies
|
|
939
|
+
* - `random`: Select a random proxy from the pool for each request
|
|
940
|
+
* - `sequential`: Use proxies in order, optionally rotating after N requests
|
|
941
|
+
* - `per-proxy-limit`: Use each proxy for a maximum number of requests, then permanently remove
|
|
942
|
+
*/
|
|
943
|
+
export type RotationStrategy = "random" | "sequential" | "per-proxy-limit";
|
|
944
|
+
/**
|
|
945
|
+
* Rotation configuration for different strategies
|
|
946
|
+
*/
|
|
947
|
+
export type RotationConfig = {
|
|
948
|
+
/** Random selection from available proxies */
|
|
949
|
+
rotation: "random";
|
|
950
|
+
} | {
|
|
951
|
+
/** Sequential rotation through proxy list */
|
|
952
|
+
rotation: "sequential";
|
|
953
|
+
/** Number of requests before rotating to next proxy (default: 1) */
|
|
954
|
+
requestsPerProxy?: number;
|
|
955
|
+
} | {
|
|
956
|
+
/** Use each proxy for a limited number of total requests, then remove */
|
|
957
|
+
rotation: "per-proxy-limit";
|
|
958
|
+
/** Maximum requests per proxy before permanent removal */
|
|
959
|
+
limit: number;
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* Cooldown configuration for disabled proxies
|
|
963
|
+
*/
|
|
964
|
+
export interface ProxyCooldownConfig {
|
|
965
|
+
/** Whether to enable automatic re-enabling after cooldown */
|
|
966
|
+
enabled: boolean;
|
|
967
|
+
/** Duration in milliseconds before re-enabling a disabled proxy */
|
|
968
|
+
durationMs: number;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Base proxy manager configuration (without rotation)
|
|
972
|
+
* Complete configuration for proxy rotation, filtering, and failure handling
|
|
973
|
+
*/
|
|
974
|
+
export interface ProxyManagerBaseConfig {
|
|
975
|
+
/** Array of proxies to manage */
|
|
976
|
+
proxies: ProxyInfo[];
|
|
943
977
|
/**
|
|
944
|
-
*
|
|
978
|
+
* Whitelist patterns for URLs that should use proxy
|
|
979
|
+
* - String: exact domain match (e.g., 'api.example.com') or subdomain match (e.g., 'example.com' matches '*.example.com')
|
|
980
|
+
* - RegExp: regex pattern to test against full URL
|
|
981
|
+
* If not set, all URLs use proxy
|
|
945
982
|
*/
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
983
|
+
whitelist?: (string | RegExp)[];
|
|
984
|
+
/**
|
|
985
|
+
* Blacklist patterns for URLs that should NOT use proxy (go direct)
|
|
986
|
+
* - String: exact domain match or subdomain match
|
|
987
|
+
* - RegExp: regex pattern to test against full URL
|
|
988
|
+
* Blacklist is checked after whitelist
|
|
989
|
+
*/
|
|
990
|
+
blacklist?: (string | RegExp)[];
|
|
991
|
+
/**
|
|
992
|
+
* Automatically disable proxies after consecutive failures
|
|
993
|
+
* @default false
|
|
994
|
+
*/
|
|
995
|
+
autoDisableDeadProxies?: boolean;
|
|
996
|
+
/**
|
|
997
|
+
* Number of consecutive failures before disabling a proxy
|
|
998
|
+
* Only applies when autoDisableDeadProxies is true
|
|
999
|
+
* @default 3
|
|
1000
|
+
*/
|
|
1001
|
+
maxFailures?: number;
|
|
1002
|
+
/**
|
|
1003
|
+
* Cooldown configuration for disabled proxies
|
|
1004
|
+
* If not set or enabled: false, proxies are permanently removed when disabled
|
|
1005
|
+
*/
|
|
1006
|
+
cooldown?: ProxyCooldownConfig;
|
|
1007
|
+
/**
|
|
1008
|
+
* Whether to throw error when no proxy is available
|
|
1009
|
+
* - true (default): Throw RezoError when no proxies available
|
|
1010
|
+
* - false: Proceed with direct connection (no proxy)
|
|
1011
|
+
* @default true
|
|
1012
|
+
*/
|
|
1013
|
+
failWithoutProxy?: boolean;
|
|
1014
|
+
/**
|
|
1015
|
+
* Whether to retry the request with next proxy on failure
|
|
1016
|
+
* @default false
|
|
1017
|
+
*/
|
|
1018
|
+
retryWithNextProxy?: boolean;
|
|
1019
|
+
/**
|
|
1020
|
+
* Maximum retry attempts when retryWithNextProxy is enabled
|
|
1021
|
+
* @default 3
|
|
1022
|
+
*/
|
|
1023
|
+
maxProxyRetries?: number;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Full proxy manager configuration
|
|
1027
|
+
* Combines base config with rotation strategy
|
|
1028
|
+
*/
|
|
1029
|
+
export type ProxyManagerConfig = ProxyManagerBaseConfig & RotationConfig;
|
|
1030
|
+
/**
|
|
1031
|
+
* Internal proxy state tracking
|
|
1032
|
+
* Used internally by ProxyManager to track usage and failures
|
|
1033
|
+
*/
|
|
1034
|
+
export interface ProxyState {
|
|
1035
|
+
/** The proxy info */
|
|
1036
|
+
proxy: ProxyInfo;
|
|
1037
|
+
/** Number of requests made through this proxy */
|
|
1038
|
+
requestCount: number;
|
|
1039
|
+
/** Number of consecutive failures */
|
|
1040
|
+
failureCount: number;
|
|
1041
|
+
/** Total number of successful requests */
|
|
1042
|
+
successCount: number;
|
|
1043
|
+
/** Total number of failed requests */
|
|
1044
|
+
totalFailures: number;
|
|
1045
|
+
/** Whether the proxy is currently active */
|
|
1046
|
+
isActive: boolean;
|
|
1047
|
+
/** Reason for being disabled (if applicable) */
|
|
1048
|
+
disabledReason?: "dead" | "limit-reached" | "manual";
|
|
1049
|
+
/** Timestamp when proxy was disabled */
|
|
1050
|
+
disabledAt?: number;
|
|
1051
|
+
/** Timestamp when proxy will be re-enabled (if cooldown enabled) */
|
|
1052
|
+
reenableAt?: number;
|
|
1053
|
+
/** Last successful request timestamp */
|
|
1054
|
+
lastSuccessAt?: number;
|
|
1055
|
+
/** Last failure timestamp */
|
|
1056
|
+
lastFailureAt?: number;
|
|
1057
|
+
/** Last error message */
|
|
1058
|
+
lastError?: string;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Proxy manager status snapshot
|
|
1062
|
+
* Provides overview of all proxies in the manager
|
|
1063
|
+
*/
|
|
1064
|
+
export interface ProxyManagerStatus {
|
|
1065
|
+
/** Active proxies available for use */
|
|
1066
|
+
active: ProxyInfo[];
|
|
1067
|
+
/** Disabled proxies (dead or limit reached) */
|
|
1068
|
+
disabled: ProxyInfo[];
|
|
1069
|
+
/** Proxies in cooldown waiting to be re-enabled */
|
|
1070
|
+
cooldown: ProxyInfo[];
|
|
1071
|
+
/** Total number of proxies */
|
|
1072
|
+
total: number;
|
|
1073
|
+
/** Current rotation strategy */
|
|
1074
|
+
rotation: RotationStrategy;
|
|
1075
|
+
/** Total requests made through the manager */
|
|
1076
|
+
totalRequests: number;
|
|
1077
|
+
/** Total successful requests */
|
|
1078
|
+
totalSuccesses: number;
|
|
1079
|
+
/** Total failed requests */
|
|
1080
|
+
totalFailures: number;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Result from proxy selection
|
|
1084
|
+
*/
|
|
1085
|
+
export interface ProxySelectionResult {
|
|
1086
|
+
/** Selected proxy (null if should go direct) */
|
|
1087
|
+
proxy: ProxyInfo | null;
|
|
1088
|
+
/** Reason for selection result */
|
|
1089
|
+
reason: "selected" | "whitelist-no-match" | "blacklist-match" | "no-proxies-available" | "disabled";
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Context for beforeProxySelect hook
|
|
1093
|
+
*/
|
|
1094
|
+
export interface BeforeProxySelectContext {
|
|
1095
|
+
/** Request URL */
|
|
1096
|
+
url: string;
|
|
1097
|
+
/** Available active proxies */
|
|
1098
|
+
proxies: ProxyInfo[];
|
|
1099
|
+
/** Whether this is a retry attempt */
|
|
1100
|
+
isRetry: boolean;
|
|
1101
|
+
/** Retry count (0 for initial request) */
|
|
1102
|
+
retryCount: number;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Context for afterProxySelect hook
|
|
1106
|
+
*/
|
|
1107
|
+
export interface AfterProxySelectContext {
|
|
1108
|
+
/** Request URL */
|
|
1109
|
+
url: string;
|
|
1110
|
+
/** Selected proxy (null if going direct) */
|
|
1111
|
+
proxy: ProxyInfo | null;
|
|
1112
|
+
/** Selection reason */
|
|
1113
|
+
reason: ProxySelectionResult["reason"];
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Context for beforeProxyError hook
|
|
1117
|
+
*/
|
|
1118
|
+
export interface BeforeProxyErrorContext {
|
|
1119
|
+
/** The proxy that failed */
|
|
1120
|
+
proxy: ProxyInfo;
|
|
1121
|
+
/** The error that occurred */
|
|
1122
|
+
error: Error;
|
|
1123
|
+
/** Request URL */
|
|
1124
|
+
url: string;
|
|
1125
|
+
/** Current failure count for this proxy */
|
|
1126
|
+
failureCount: number;
|
|
1127
|
+
/** Whether proxy will be disabled after this error */
|
|
1128
|
+
willBeDisabled: boolean;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Context for afterProxyError hook
|
|
1132
|
+
*/
|
|
1133
|
+
export interface AfterProxyErrorContext {
|
|
1134
|
+
/** The proxy that failed */
|
|
1135
|
+
proxy: ProxyInfo;
|
|
1136
|
+
/** The error that occurred */
|
|
1137
|
+
error: Error;
|
|
1138
|
+
/** Action taken after error */
|
|
1139
|
+
action: "retry-next-proxy" | "disabled" | "continue";
|
|
1140
|
+
/** Next proxy for retry (if action is 'retry-next-proxy') */
|
|
1141
|
+
nextProxy?: ProxyInfo;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Context for beforeProxyDisable hook
|
|
1145
|
+
* Return false to prevent disabling
|
|
1146
|
+
*/
|
|
1147
|
+
export interface BeforeProxyDisableContext {
|
|
1148
|
+
/** The proxy about to be disabled */
|
|
1149
|
+
proxy: ProxyInfo;
|
|
1150
|
+
/** Reason for disabling */
|
|
1151
|
+
reason: "dead" | "limit-reached" | "manual";
|
|
1152
|
+
/** Current proxy state */
|
|
1153
|
+
state: ProxyState;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Context for afterProxyDisable hook
|
|
1157
|
+
*/
|
|
1158
|
+
export interface AfterProxyDisableContext {
|
|
1159
|
+
/** The proxy that was disabled */
|
|
1160
|
+
proxy: ProxyInfo;
|
|
1161
|
+
/** Reason for disabling */
|
|
1162
|
+
reason: "dead" | "limit-reached" | "manual";
|
|
1163
|
+
/** Whether cooldown is enabled for re-enabling */
|
|
1164
|
+
hasCooldown: boolean;
|
|
1165
|
+
/** Timestamp when proxy will be re-enabled (if cooldown enabled) */
|
|
1166
|
+
reenableAt?: number;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Context for afterProxyRotate hook
|
|
1170
|
+
*/
|
|
1171
|
+
export interface AfterProxyRotateContext {
|
|
1172
|
+
/** Previous proxy (null if first selection) */
|
|
1173
|
+
from: ProxyInfo | null;
|
|
1174
|
+
/** New proxy */
|
|
1175
|
+
to: ProxyInfo;
|
|
1176
|
+
/** Reason for rotation */
|
|
1177
|
+
reason: "scheduled" | "failure" | "limit-reached";
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Context for afterProxyEnable hook
|
|
1181
|
+
*/
|
|
1182
|
+
export interface AfterProxyEnableContext {
|
|
1183
|
+
/** The proxy that was enabled */
|
|
1184
|
+
proxy: ProxyInfo;
|
|
1185
|
+
/** Reason for enabling */
|
|
1186
|
+
reason: "cooldown-expired" | "manual";
|
|
949
1187
|
}
|
|
950
1188
|
/**
|
|
951
1189
|
* Context provided to beforeRequest hook
|
|
@@ -1225,6 +1463,46 @@ export type OnTimeoutHook = (event: TimeoutEvent, config: RezoConfig) => void;
|
|
|
1225
1463
|
* Use for cleanup, logging
|
|
1226
1464
|
*/
|
|
1227
1465
|
export type OnAbortHook = (event: AbortEvent, config: RezoConfig) => void;
|
|
1466
|
+
/**
|
|
1467
|
+
* Hook called before a proxy is selected
|
|
1468
|
+
* Can return a specific proxy to override selection
|
|
1469
|
+
*/
|
|
1470
|
+
export type BeforeProxySelectHook = (context: BeforeProxySelectContext) => ProxyInfo | void | Promise<ProxyInfo | void>;
|
|
1471
|
+
/**
|
|
1472
|
+
* Hook called after a proxy is selected
|
|
1473
|
+
* Use for logging, analytics
|
|
1474
|
+
*/
|
|
1475
|
+
export type AfterProxySelectHook = (context: AfterProxySelectContext) => void | Promise<void>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Hook called before a proxy error is processed
|
|
1478
|
+
* Use for error inspection, custom handling
|
|
1479
|
+
*/
|
|
1480
|
+
export type BeforeProxyErrorHook = (context: BeforeProxyErrorContext) => void | Promise<void>;
|
|
1481
|
+
/**
|
|
1482
|
+
* Hook called after a proxy error is processed
|
|
1483
|
+
* Use for error logging, fallback logic
|
|
1484
|
+
*/
|
|
1485
|
+
export type AfterProxyErrorHook = (context: AfterProxyErrorContext) => void | Promise<void>;
|
|
1486
|
+
/**
|
|
1487
|
+
* Hook called before a proxy is disabled
|
|
1488
|
+
* Return false to prevent disabling
|
|
1489
|
+
*/
|
|
1490
|
+
export type BeforeProxyDisableHook = (context: BeforeProxyDisableContext) => boolean | void | Promise<boolean | void>;
|
|
1491
|
+
/**
|
|
1492
|
+
* Hook called after a proxy is disabled
|
|
1493
|
+
* Use for notifications, logging
|
|
1494
|
+
*/
|
|
1495
|
+
export type AfterProxyDisableHook = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Hook called when proxy rotation occurs
|
|
1498
|
+
* Use for monitoring rotation patterns
|
|
1499
|
+
*/
|
|
1500
|
+
export type AfterProxyRotateHook = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
1501
|
+
/**
|
|
1502
|
+
* Hook called when a proxy is re-enabled
|
|
1503
|
+
* Use for notifications, logging
|
|
1504
|
+
*/
|
|
1505
|
+
export type AfterProxyEnableHook = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
1228
1506
|
/**
|
|
1229
1507
|
* Collection of all hook types
|
|
1230
1508
|
* All hooks are arrays to allow multiple handlers
|
|
@@ -1241,6 +1519,14 @@ export interface RezoHooks {
|
|
|
1241
1519
|
afterParse: AfterParseHook[];
|
|
1242
1520
|
beforeCookie: BeforeCookieHook[];
|
|
1243
1521
|
afterCookie: AfterCookieHook[];
|
|
1522
|
+
beforeProxySelect: BeforeProxySelectHook[];
|
|
1523
|
+
afterProxySelect: AfterProxySelectHook[];
|
|
1524
|
+
beforeProxyError: BeforeProxyErrorHook[];
|
|
1525
|
+
afterProxyError: AfterProxyErrorHook[];
|
|
1526
|
+
beforeProxyDisable: BeforeProxyDisableHook[];
|
|
1527
|
+
afterProxyDisable: AfterProxyDisableHook[];
|
|
1528
|
+
afterProxyRotate: AfterProxyRotateHook[];
|
|
1529
|
+
afterProxyEnable: AfterProxyEnableHook[];
|
|
1244
1530
|
onSocket: OnSocketHook[];
|
|
1245
1531
|
onDns: OnDnsHook[];
|
|
1246
1532
|
onTls: OnTlsHook[];
|
|
@@ -1248,735 +1534,956 @@ export interface RezoHooks {
|
|
|
1248
1534
|
onAbort: OnAbortHook[];
|
|
1249
1535
|
}
|
|
1250
1536
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*/
|
|
1253
|
-
export type ProxyProtocol = "http" | "https" | "socks4" | "socks5";
|
|
1254
|
-
/**
|
|
1255
|
-
* Configuration options for proxy connections
|
|
1256
|
-
*/
|
|
1257
|
-
export type ProxyOptions = {
|
|
1258
|
-
/** The proxy protocol to use */
|
|
1259
|
-
protocol: ProxyProtocol;
|
|
1260
|
-
/** Proxy server hostname or IP address */
|
|
1261
|
-
host: string;
|
|
1262
|
-
/** Proxy server port number */
|
|
1263
|
-
port: number;
|
|
1264
|
-
/** Optional authentication credentials for the proxy */
|
|
1265
|
-
auth?: {
|
|
1266
|
-
/** Username for proxy authentication */
|
|
1267
|
-
username: string;
|
|
1268
|
-
/** Password for proxy authentication */
|
|
1269
|
-
password: string;
|
|
1270
|
-
};
|
|
1271
|
-
/** Connection timeout in milliseconds */
|
|
1272
|
-
timeout?: number;
|
|
1273
|
-
/** Whether to keep the connection alive */
|
|
1274
|
-
keepAlive?: boolean;
|
|
1275
|
-
/** Keep-alive timeout in milliseconds */
|
|
1276
|
-
keepAliveMsecs?: number;
|
|
1277
|
-
/** Maximum number of sockets to allow per host */
|
|
1278
|
-
maxSockets?: number;
|
|
1279
|
-
/** Maximum number of free sockets to keep open per host */
|
|
1280
|
-
maxFreeSockets?: number;
|
|
1281
|
-
/** Whether to reject unauthorized SSL certificates */
|
|
1282
|
-
rejectUnauthorized?: boolean;
|
|
1283
|
-
};
|
|
1284
|
-
/**
|
|
1285
|
-
* Maximum upload rate in bytes per second
|
|
1286
|
-
*/
|
|
1287
|
-
export type MaxUploadRate = number;
|
|
1288
|
-
/**
|
|
1289
|
-
* Maximum download rate in bytes per second
|
|
1290
|
-
*/
|
|
1291
|
-
export type MaxDownloadRate = number;
|
|
1292
|
-
/**
|
|
1293
|
-
* Custom string type for Rezo-specific string values
|
|
1294
|
-
*/
|
|
1295
|
-
export type RezoString = string;
|
|
1296
|
-
/**
|
|
1297
|
-
* Standard HTTP methods supported by Rezo
|
|
1537
|
+
* Create empty hooks object with all arrays initialized
|
|
1298
1538
|
*/
|
|
1299
|
-
export
|
|
1300
|
-
type ResponseType$1 = "json" | "text" | "blob" | "arrayBuffer" | "buffer" | "auto";
|
|
1539
|
+
export declare function createDefaultHooks(): RezoHooks;
|
|
1301
1540
|
/**
|
|
1302
|
-
*
|
|
1541
|
+
* Merge base hooks with override hooks
|
|
1542
|
+
* Overrides are appended to base hooks (base runs first)
|
|
1303
1543
|
*/
|
|
1304
|
-
export
|
|
1544
|
+
export declare function mergeHooks(base: RezoHooks, overrides?: Partial<RezoHooks>): RezoHooks;
|
|
1305
1545
|
/**
|
|
1306
|
-
*
|
|
1546
|
+
* Configuration object that encapsulates comprehensive request execution metadata and response processing information.
|
|
1547
|
+
* This interface serves as the central configuration hub for HTTP requests, containing both input parameters
|
|
1548
|
+
* and execution tracking data throughout the request lifecycle.
|
|
1307
1549
|
*
|
|
1308
|
-
* @
|
|
1550
|
+
* @interface RezoConfig
|
|
1551
|
+
* @since 1.0.0
|
|
1552
|
+
* @example
|
|
1553
|
+
* ```typescript
|
|
1554
|
+
* const config: RezoConfig = {
|
|
1555
|
+
* originalRequest: requestConfig,
|
|
1556
|
+
* finalUrl: 'https://api.example.com/data',
|
|
1557
|
+
* adapterUsed: 'fetch',
|
|
1558
|
+
* timing: { startTime: Date.now(), endTime: Date.now() + 1000, total: 1000 },
|
|
1559
|
+
* network: { protocol: 'https' },
|
|
1560
|
+
* transfer: { requestSize: 256, responseSize: 1024, headerSize: 128, bodySize: 896 },
|
|
1561
|
+
* retryAttempts: 0,
|
|
1562
|
+
* errors: [],
|
|
1563
|
+
* security: {},
|
|
1564
|
+
* metadata: {}
|
|
1565
|
+
* };
|
|
1566
|
+
* ```
|
|
1309
1567
|
*/
|
|
1310
|
-
export interface
|
|
1311
|
-
/** The target URL for the request */
|
|
1312
|
-
url: string
|
|
1313
|
-
/**
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
/** Request
|
|
1318
|
-
|
|
1319
|
-
/**
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
*
|
|
1333
|
-
* **Available Types:**
|
|
1334
|
-
* - `'json'` - Parse as JSON object/array. Best for REST APIs.
|
|
1335
|
-
* - `'text'` - Return as string. Best for HTML, XML, plain text.
|
|
1336
|
-
* - `'blob'` - Return as Blob (browser). Best for binary in browsers.
|
|
1337
|
-
* - `'arrayBuffer'` - Return as ArrayBuffer. Best for binary processing.
|
|
1338
|
-
* - `'buffer'` - Return as Buffer (Node.js). Best for binary in Node.
|
|
1339
|
-
* - `'auto'` - Auto-detect from Content-Type header (default).
|
|
1340
|
-
*
|
|
1341
|
-
* **For streaming, use dedicated methods instead:**
|
|
1342
|
-
* - `rezo.stream(url)` - Real-time streaming data
|
|
1343
|
-
* - `rezo.download(url, saveTo)` - Download with progress
|
|
1344
|
-
* - `rezo.upload(url, data)` - Upload with progress
|
|
1345
|
-
*
|
|
1346
|
-
* @default 'auto'
|
|
1347
|
-
* @example
|
|
1348
|
-
* // Get JSON
|
|
1349
|
-
* const { data } = await rezo.get('/api/users', { responseType: 'json' });
|
|
1350
|
-
*
|
|
1351
|
-
* // Get HTML as text
|
|
1352
|
-
* const { data: html } = await rezo.get('/page', { responseType: 'text' });
|
|
1353
|
-
*
|
|
1354
|
-
* // Get image as buffer
|
|
1355
|
-
* const { data: img } = await rezo.get('/image.png', { responseType: 'buffer' });
|
|
1356
|
-
*/
|
|
1357
|
-
responseType?: ResponseType$1;
|
|
1358
|
-
/** Character encoding for the response */
|
|
1359
|
-
responseEncoding?: string;
|
|
1360
|
-
/** Base URL for the request (used with relative URLs) */
|
|
1568
|
+
export interface RezoConfig {
|
|
1569
|
+
/** @description The target URL for the HTTP request */
|
|
1570
|
+
url: string;
|
|
1571
|
+
/** @description HTTP method (GET, POST, PUT, DELETE, etc.) */
|
|
1572
|
+
method: RezoRequestConfig["method"];
|
|
1573
|
+
/** @description HTTP headers to be sent with the request */
|
|
1574
|
+
headers: RezoHeaders;
|
|
1575
|
+
/** @description Request payload data (null when not set) */
|
|
1576
|
+
data?: RezoRequestConfig["body"] | null;
|
|
1577
|
+
/** @description URL query parameters */
|
|
1578
|
+
params?: RezoRequestConfig["params"];
|
|
1579
|
+
/** @description Request timeout in milliseconds (null when not set) */
|
|
1580
|
+
timeout?: number | null;
|
|
1581
|
+
/** @description Expected response data type */
|
|
1582
|
+
responseType?: "json" | "text" | "blob" | "arrayBuffer" | "stream" | "download" | "upload" | "buffer" | "binary";
|
|
1583
|
+
/** @description Basic authentication credentials (null when not set) */
|
|
1584
|
+
auth?: RezoRequestConfig["auth"] | null;
|
|
1585
|
+
/** @description Proxy configuration (null when not set) */
|
|
1586
|
+
proxy?: RezoRequestConfig["proxy"] | null;
|
|
1587
|
+
/** @description Maximum number of redirects to follow */
|
|
1588
|
+
maxRedirects: number;
|
|
1589
|
+
/** @description Base URL for relative requests */
|
|
1361
1590
|
baseURL?: string;
|
|
1362
|
-
/**
|
|
1363
|
-
|
|
1364
|
-
/**
|
|
1365
|
-
|
|
1366
|
-
/**
|
|
1367
|
-
form?: Record<string, any>;
|
|
1368
|
-
/** Form data for multipart/form-data requests */
|
|
1369
|
-
formData?: Record<string, any> | RezoFormData;
|
|
1370
|
-
/** Multipart data (alias for formData) */
|
|
1371
|
-
multipart?: Record<string, any> | RezoFormData;
|
|
1372
|
-
/** Whether to detect and prevent redirect cycles */
|
|
1591
|
+
/** @description Enable HTTP/2 protocol */
|
|
1592
|
+
http2: boolean;
|
|
1593
|
+
/** @description Enable cURL command generation */
|
|
1594
|
+
curl: boolean;
|
|
1595
|
+
/** @description Enable detection of redirect cycles */
|
|
1373
1596
|
enableRedirectCycleDetection?: boolean;
|
|
1374
|
-
/**
|
|
1375
|
-
contentType?: ContentType | string;
|
|
1376
|
-
/** Skip setting Content-Type header automatically */
|
|
1377
|
-
withoutContentType?: boolean;
|
|
1378
|
-
/** Basic authentication credentials */
|
|
1379
|
-
auth?: {
|
|
1380
|
-
/** Username for authentication */
|
|
1381
|
-
username: string;
|
|
1382
|
-
/** Password for authentication */
|
|
1383
|
-
password: string;
|
|
1384
|
-
};
|
|
1385
|
-
/** Request timeout in milliseconds */
|
|
1386
|
-
timeout?: number;
|
|
1387
|
-
/** Whether to reject requests with invalid SSL certificates */
|
|
1597
|
+
/** @description Reject unauthorized SSL certificates */
|
|
1388
1598
|
rejectUnauthorized?: boolean;
|
|
1389
|
-
/** Retry configuration
|
|
1390
|
-
retry?:
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
/**
|
|
1394
|
-
|
|
1395
|
-
/**
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
|
|
1399
|
-
/** Weather to stop or continue retry when certain condition is met*/
|
|
1400
|
-
condition?: (error: RezoError) => boolean | Promise<boolean>;
|
|
1599
|
+
/** @description Retry configuration */
|
|
1600
|
+
retry?: RezoRequestConfig["retry"];
|
|
1601
|
+
/** @description Compression settings */
|
|
1602
|
+
compression?: {
|
|
1603
|
+
/** @description Enable compression */
|
|
1604
|
+
enabled?: boolean;
|
|
1605
|
+
/** @description Compression threshold in bytes */
|
|
1606
|
+
threshold?: number;
|
|
1607
|
+
/** @description Supported compression algorithms */
|
|
1608
|
+
algorithms?: string[];
|
|
1401
1609
|
};
|
|
1402
|
-
/**
|
|
1403
|
-
|
|
1404
|
-
/**
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1610
|
+
/** @description Enable cookie jar for session management */
|
|
1611
|
+
enableCookieJar?: boolean;
|
|
1612
|
+
/** @description Feature flags for adapter capabilities */
|
|
1613
|
+
features?: {
|
|
1614
|
+
/** @description HTTP/2 support */
|
|
1615
|
+
http2?: boolean;
|
|
1616
|
+
/** @description Compression support */
|
|
1617
|
+
compression?: boolean;
|
|
1618
|
+
/** @description Cookie support */
|
|
1619
|
+
cookies?: boolean;
|
|
1620
|
+
/** @description Redirect support */
|
|
1621
|
+
redirects?: boolean;
|
|
1622
|
+
/** @description Proxy support */
|
|
1623
|
+
proxy?: boolean;
|
|
1624
|
+
/** @description Timeout support */
|
|
1625
|
+
timeout?: boolean;
|
|
1626
|
+
/** @description Retry support */
|
|
1627
|
+
retry?: boolean;
|
|
1628
|
+
/** @description Cache support */
|
|
1629
|
+
cache?: boolean;
|
|
1630
|
+
/** @description Metrics support */
|
|
1631
|
+
metrics?: boolean;
|
|
1632
|
+
/** @description Event support */
|
|
1633
|
+
events?: boolean;
|
|
1634
|
+
/** @description Validation support */
|
|
1635
|
+
validation?: boolean;
|
|
1636
|
+
/** @description Browser support */
|
|
1637
|
+
browser?: boolean;
|
|
1638
|
+
/** @description SSL support */
|
|
1639
|
+
ssl?: boolean;
|
|
1640
|
+
};
|
|
1641
|
+
/** @description Use insecure HTTP parser */
|
|
1642
|
+
insecureHTTPParser: boolean;
|
|
1643
|
+
/** @description Custom adapter implementation */
|
|
1644
|
+
adapter?: any;
|
|
1645
|
+
isSecure?: boolean;
|
|
1423
1646
|
/**
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
* When enabled, DNS lookups are cached to avoid repeated DNS queries
|
|
1427
|
-
* for the same hostname, significantly improving performance for
|
|
1428
|
-
* applications making many requests to the same servers.
|
|
1647
|
+
* @description Rate limiting for network transfer speed (bandwidth throttling)
|
|
1429
1648
|
*
|
|
1430
|
-
*
|
|
1431
|
-
* - `true` - Enable with default settings (1 min TTL, 1000 entries max)
|
|
1432
|
-
* - `false` - Disable DNS caching (default)
|
|
1433
|
-
* - `object` - Custom configuration with ttl and maxEntries
|
|
1649
|
+
* Controls the maximum transfer speed in bytes per second.
|
|
1434
1650
|
*
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1651
|
+
* - `number`: Applies same limit to both download and upload (e.g., 1024000 = ~1MB/s)
|
|
1652
|
+
* - `[download, upload]`: Different limits for each direction (e.g., [5242880, 1048576] = 5MB/s down, 1MB/s up)
|
|
1653
|
+
* - `0` or `null`: No rate limiting (unlimited speed)
|
|
1438
1654
|
*
|
|
1439
|
-
*
|
|
1440
|
-
*
|
|
1655
|
+
* Common values:
|
|
1656
|
+
* - 1048576 = 1 MB/s
|
|
1657
|
+
* - 5242880 = 5 MB/s
|
|
1658
|
+
* - 10485760 = 10 MB/s
|
|
1441
1659
|
*
|
|
1442
|
-
*
|
|
1660
|
+
* Note: Actual transfer speed may vary based on network conditions and adapter support.
|
|
1661
|
+
* This feature is adapter-dependent (HTTP adapter supports it, other adapters may vary).
|
|
1443
1662
|
*/
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1663
|
+
maxRate: number | [
|
|
1664
|
+
number,
|
|
1665
|
+
number
|
|
1666
|
+
];
|
|
1667
|
+
/** @description Cancellation token for request abortion (null when not set) */
|
|
1668
|
+
cancelToken?: any | null;
|
|
1669
|
+
/** @description AbortSignal for request cancellation (null when not set) */
|
|
1670
|
+
signal?: AbortSignal | null;
|
|
1671
|
+
/** @description Function to set the AbortSignal */
|
|
1672
|
+
setSignal: () => void;
|
|
1673
|
+
/** @description HTTP agent for connection pooling (null when not set) */
|
|
1674
|
+
httpAgent?: RezoRequestConfig["httpAgent"] | null;
|
|
1675
|
+
/** @description HTTPS agent for secure connection pooling (null when not set) */
|
|
1676
|
+
httpsAgent?: RezoRequestConfig["httpsAgent"] | null;
|
|
1677
|
+
/** @description Unix socket path (null when not set) */
|
|
1678
|
+
socketPath?: string | null;
|
|
1679
|
+
/** @description File path to save the response (null when not set) */
|
|
1680
|
+
fileName?: string | null;
|
|
1450
1681
|
/**
|
|
1451
|
-
*
|
|
1452
|
-
*
|
|
1453
|
-
* When enabled, successful GET/HEAD responses are cached to avoid
|
|
1454
|
-
* repeated network requests. Supports memory-only or file persistence.
|
|
1455
|
-
* Honors Cache-Control headers by default.
|
|
1456
|
-
*
|
|
1457
|
-
* **Options:**
|
|
1458
|
-
* - `true` - Enable memory cache with defaults (5 min TTL, 500 entries)
|
|
1459
|
-
* - `false` - Disable response caching (default)
|
|
1460
|
-
* - `object` - Custom configuration
|
|
1461
|
-
*
|
|
1462
|
-
* **Cache-Control Support:**
|
|
1463
|
-
* - Respects `max-age`, `s-maxage`, `no-store`, `no-cache`
|
|
1464
|
-
* - Sends `If-None-Match` / `If-Modified-Since` for revalidation
|
|
1465
|
-
* - Returns cached response on 304 Not Modified
|
|
1466
|
-
*
|
|
1467
|
-
* @example
|
|
1468
|
-
* // Enable memory-only cache
|
|
1469
|
-
* { cache: true }
|
|
1470
|
-
*
|
|
1471
|
-
* // With file persistence
|
|
1472
|
-
* { cache: { cacheDir: './cache', ttl: 300000 } }
|
|
1473
|
-
*
|
|
1474
|
-
* // Custom settings
|
|
1475
|
-
* { cache: {
|
|
1476
|
-
* ttl: 600000, // 10 minutes
|
|
1477
|
-
* maxEntries: 1000,
|
|
1478
|
-
* methods: ['GET'], // Only cache GET
|
|
1479
|
-
* respectHeaders: true // Honor Cache-Control
|
|
1480
|
-
* }}
|
|
1481
|
-
*
|
|
1482
|
-
* @default false
|
|
1682
|
+
* Array of cookies to be sent with the request.
|
|
1683
|
+
* These cookies are configured before the request is made and will be included in the request headers.
|
|
1483
1684
|
*/
|
|
1484
|
-
|
|
1485
|
-
/** Directory for persistent cache storage (enables file persistence) */
|
|
1486
|
-
cacheDir?: string;
|
|
1487
|
-
/** Time-to-live for cached entries in milliseconds */
|
|
1488
|
-
ttl?: number;
|
|
1489
|
-
/** Maximum number of entries to cache */
|
|
1490
|
-
maxEntries?: number;
|
|
1491
|
-
/** HTTP methods to cache */
|
|
1492
|
-
methods?: string[];
|
|
1493
|
-
/** Whether to respect Cache-Control headers */
|
|
1494
|
-
respectHeaders?: boolean;
|
|
1495
|
-
};
|
|
1685
|
+
requestCookies: Cookie[];
|
|
1496
1686
|
/**
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
* @param options - Redirect response details
|
|
1501
|
-
* @param options.url - Redirect target URL
|
|
1502
|
-
* @param options.status - HTTP status code
|
|
1503
|
-
* @param options.headers - Response headers
|
|
1504
|
-
* @param options.sameDomain - Whether redirect is to same domain
|
|
1505
|
-
* @returns Boolean to follow/reject redirect, or object for granular control
|
|
1506
|
-
*
|
|
1507
|
-
* @example
|
|
1508
|
-
* ```typescript
|
|
1509
|
-
* beforeRedirect: ({ status, url }) => {
|
|
1510
|
-
* if (status === 301 || status === 302) {
|
|
1511
|
-
* return true; // Follow permanent/temporary redirects
|
|
1512
|
-
* } else if (status === 307 || status === 308) {
|
|
1513
|
-
* return { redirect: true, url: url.toString() }; // Preserve method for 307/308
|
|
1514
|
-
* } else if (status === 303) {
|
|
1515
|
-
* return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
|
|
1516
|
-
* }
|
|
1517
|
-
* return false; // Reject other redirects
|
|
1518
|
-
* }
|
|
1519
|
-
* ```
|
|
1687
|
+
* Cookies received from the server in the response.
|
|
1688
|
+
* These cookies are parsed from the 'Set-Cookie' response headers and can be used for subsequent requests
|
|
1689
|
+
* or session management. Contains multiple formats: array, serialized, netscape, string, setCookiesString.
|
|
1520
1690
|
*/
|
|
1521
|
-
|
|
1522
|
-
/**
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
/**
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
/**
|
|
1548
|
-
|
|
1549
|
-
/**
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
|
|
1553
|
-
/**
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
|
|
1559
|
-
/**
|
|
1560
|
-
|
|
1561
|
-
/** Device platform type */
|
|
1562
|
-
platform: "desktop" | "mobile" | "tablet";
|
|
1563
|
-
/** Operating system details */
|
|
1564
|
-
os: {
|
|
1565
|
-
/** Operating system name */
|
|
1566
|
-
name: "windows" | "macos" | "linux" | "ios" | "android" | "chromeos";
|
|
1567
|
-
/** OS version string */
|
|
1568
|
-
version: string;
|
|
1569
|
-
/** CPU architecture */
|
|
1570
|
-
architecture: "x86" | "x64" | "arm" | "arm64";
|
|
1571
|
-
};
|
|
1572
|
-
/** Browser language preference */
|
|
1573
|
-
language?: string;
|
|
1691
|
+
responseCookies: Cookies;
|
|
1692
|
+
/**
|
|
1693
|
+
* Path to cookie file for persistence (null when not configured).
|
|
1694
|
+
* - .json files save cookies as serialized JSON
|
|
1695
|
+
* - .txt files save cookies in Netscape format
|
|
1696
|
+
*/
|
|
1697
|
+
cookieFile?: string | null;
|
|
1698
|
+
/**
|
|
1699
|
+
* Request lifecycle hooks for intercepting and modifying request/response behavior.
|
|
1700
|
+
* null when no hooks are registered, otherwise contains only hooks with registered functions.
|
|
1701
|
+
* Empty arrays are not included - only hooks with actual handlers appear.
|
|
1702
|
+
*
|
|
1703
|
+
* Available hooks:
|
|
1704
|
+
* - init: During options initialization
|
|
1705
|
+
* - beforeRequest: Before request is sent
|
|
1706
|
+
* - beforeRedirect: Before following redirects
|
|
1707
|
+
* - beforeRetry: Before retry attempts
|
|
1708
|
+
* - afterResponse: After response is received
|
|
1709
|
+
* - beforeError: Before error is thrown
|
|
1710
|
+
* - beforeCache: Before caching response
|
|
1711
|
+
* - afterHeaders: When headers are received
|
|
1712
|
+
* - afterParse: After body is parsed
|
|
1713
|
+
* - beforeCookie/afterCookie: Cookie lifecycle
|
|
1714
|
+
* - onSocket/onDns/onTls/onTimeout/onAbort: Low-level events
|
|
1715
|
+
*/
|
|
1716
|
+
hooks: Partial<RezoHooks> | null;
|
|
1717
|
+
/** @description Snapshot of the original request configuration */
|
|
1718
|
+
originalRequest: RezoRequestConfig;
|
|
1719
|
+
/** @description Final resolved URL after redirects and processing */
|
|
1720
|
+
finalUrl: string;
|
|
1721
|
+
/** @description HTTP adapter used for the request */
|
|
1722
|
+
adapterUsed: "http" | "https" | "http2" | "fetch" | "xhr" | "curl";
|
|
1723
|
+
/** @description Metadata about the adapter used */
|
|
1724
|
+
adapterMetadata?: {
|
|
1725
|
+
/** @description Adapter version */
|
|
1726
|
+
version?: string;
|
|
1727
|
+
/** @description Supported features */
|
|
1728
|
+
features?: string[];
|
|
1729
|
+
/** @description Adapter capabilities */
|
|
1730
|
+
capabilities?: Record<string, any>;
|
|
1574
1731
|
};
|
|
1575
|
-
/**
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
/**
|
|
1590
|
-
|
|
1591
|
-
/**
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1732
|
+
/** @description Complete redirect chain history */
|
|
1733
|
+
redirectHistory: {
|
|
1734
|
+
/** @description Cookies set in this redirect */
|
|
1735
|
+
cookies: Cookie[];
|
|
1736
|
+
/** @description Redirect URL */
|
|
1737
|
+
url: string;
|
|
1738
|
+
/** @description HTTP status code */
|
|
1739
|
+
statusCode: number;
|
|
1740
|
+
/** @description HTTP status text */
|
|
1741
|
+
statusText: string;
|
|
1742
|
+
/** @description Response headers */
|
|
1743
|
+
headers: RezoHeaders;
|
|
1744
|
+
/** @description Redirect timestamp */
|
|
1745
|
+
duration: number;
|
|
1746
|
+
/** @description Request configuration at this step */
|
|
1747
|
+
request: RezoRequestConfig;
|
|
1748
|
+
/** @description HTTP method used */
|
|
1749
|
+
method: string;
|
|
1750
|
+
}[];
|
|
1751
|
+
/** @description Number of redirects followed */
|
|
1752
|
+
redirectCount: number;
|
|
1753
|
+
/** @description Whether maximum redirects limit was reached */
|
|
1754
|
+
maxRedirectsReached: boolean;
|
|
1755
|
+
/**
|
|
1756
|
+
* @description Cookie jar instance for session management
|
|
1757
|
+
* Full RezoCookieJar class with all methods available:
|
|
1758
|
+
* - cookies(): Get all cookies in the jar
|
|
1759
|
+
* - setCookiesSync(cookies, url): Set cookies from Set-Cookie headers
|
|
1760
|
+
* - getCookiesSync(url): Get cookies for a URL
|
|
1761
|
+
* - removeAllCookiesSync(): Clear all cookies
|
|
1762
|
+
*/
|
|
1763
|
+
cookieJar: RezoCookieJar;
|
|
1764
|
+
/** @description Comprehensive timing information */
|
|
1765
|
+
timing: {
|
|
1766
|
+
/** @description Request start timestamp (absolute performance.now() value) */
|
|
1767
|
+
startTimestamp: number;
|
|
1768
|
+
/** @description Request end timestamp (absolute performance.now() value) */
|
|
1769
|
+
endTimestamp: number;
|
|
1770
|
+
/** @description DNS lookup duration in milliseconds */
|
|
1771
|
+
dnsMs?: number;
|
|
1772
|
+
/** @description TCP connection duration in milliseconds */
|
|
1773
|
+
tcpMs?: number;
|
|
1774
|
+
/** @description TLS handshake duration in milliseconds */
|
|
1775
|
+
tlsMs?: number;
|
|
1776
|
+
/** @description Time to first byte in milliseconds (from start to first response byte) */
|
|
1777
|
+
ttfbMs?: number;
|
|
1778
|
+
/** @description Content transfer duration in milliseconds */
|
|
1779
|
+
transferMs?: number;
|
|
1780
|
+
/** @description Total request duration in milliseconds (endTimestamp - startTimestamp) */
|
|
1781
|
+
durationMs: number;
|
|
1595
1782
|
};
|
|
1783
|
+
/** @description Network connection information */
|
|
1784
|
+
network: {
|
|
1785
|
+
/** @description Local IP address */
|
|
1786
|
+
localAddress?: string;
|
|
1787
|
+
/** @description Local port number */
|
|
1788
|
+
localPort?: number;
|
|
1789
|
+
/** @description Remote IP address */
|
|
1790
|
+
remoteAddress?: string;
|
|
1791
|
+
/** @description Remote port number */
|
|
1792
|
+
remotePort?: number;
|
|
1793
|
+
/** @description Protocol used (http/https) */
|
|
1794
|
+
protocol: string;
|
|
1795
|
+
/** @description HTTP version (1.1, 2.0, etc.) */
|
|
1796
|
+
httpVersion?: string;
|
|
1797
|
+
/** @description IP family preference (4 for IPv4, 6 for IPv6) */
|
|
1798
|
+
family?: 4 | 6;
|
|
1799
|
+
/** @description Custom DNS lookup function */
|
|
1800
|
+
lookup?: any;
|
|
1801
|
+
};
|
|
1802
|
+
/** @description Data transfer statistics */
|
|
1803
|
+
transfer: {
|
|
1804
|
+
/** @description Total request size in bytes (headers + body) */
|
|
1805
|
+
requestSize: number;
|
|
1806
|
+
/** @description Request headers size in bytes */
|
|
1807
|
+
requestHeaderSize?: number;
|
|
1808
|
+
/** @description Request body size in bytes */
|
|
1809
|
+
requestBodySize?: number;
|
|
1810
|
+
/** @description Total response size in bytes (headers + body) */
|
|
1811
|
+
responseSize: number;
|
|
1812
|
+
/** @description Response headers size in bytes */
|
|
1813
|
+
headerSize: number;
|
|
1814
|
+
/** @description Response body size in bytes */
|
|
1815
|
+
bodySize: number;
|
|
1816
|
+
/** @description Compression ratio if applicable */
|
|
1817
|
+
compressionRatio?: number;
|
|
1818
|
+
};
|
|
1819
|
+
/** @description Number of retry attempts made */
|
|
1820
|
+
retryAttempts: number;
|
|
1821
|
+
/** @description Error history during request execution */
|
|
1822
|
+
errors: Array<{
|
|
1823
|
+
/** @description Retry attempt number */
|
|
1824
|
+
attempt: number;
|
|
1825
|
+
/** @description Error message */
|
|
1826
|
+
error: RezoError;
|
|
1827
|
+
/** @description Request duration before error */
|
|
1828
|
+
duration: number;
|
|
1829
|
+
}>;
|
|
1830
|
+
/** @description Security and validation information */
|
|
1831
|
+
security: {
|
|
1832
|
+
/** @description TLS version used */
|
|
1833
|
+
tlsVersion?: string;
|
|
1834
|
+
/** @description Cipher suite used */
|
|
1835
|
+
cipher?: string;
|
|
1836
|
+
/** @description Certificate information */
|
|
1837
|
+
certificateInfo?: Record<string, any>;
|
|
1838
|
+
/** @description Validation results */
|
|
1839
|
+
validationResults?: Record<string, boolean>;
|
|
1840
|
+
};
|
|
1841
|
+
/** @description Debug mode flag */
|
|
1842
|
+
debug?: boolean;
|
|
1843
|
+
/** @description Request tracking identifier */
|
|
1844
|
+
requestId: string;
|
|
1845
|
+
/** @description Session identifier */
|
|
1846
|
+
sessionId?: string;
|
|
1847
|
+
/** @description Distributed tracing identifier */
|
|
1848
|
+
traceId?: string;
|
|
1849
|
+
/** @description Request timestamp */
|
|
1850
|
+
timestamp: number;
|
|
1851
|
+
/** @description Additional tracking data */
|
|
1852
|
+
trackingData?: Record<string, unknown>;
|
|
1853
|
+
/**
|
|
1854
|
+
* Callback invoked when a redirect response is received.
|
|
1855
|
+
* Controls redirect behavior including whether to follow, modify URL, or change HTTP method.
|
|
1856
|
+
*
|
|
1857
|
+
* @param options - Redirect response details
|
|
1858
|
+
* @param options.url - Redirect target URL
|
|
1859
|
+
* @param options.status - HTTP status code
|
|
1860
|
+
* @param options.headers - Response headers
|
|
1861
|
+
* @param options.sameDomain - Whether redirect is to same domain
|
|
1862
|
+
* @returns Boolean to follow/reject redirect, or object for granular control
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ```typescript
|
|
1866
|
+
* beforeRedirect: ({ status, url }) => {
|
|
1867
|
+
* if (status === 301 || status === 302) {
|
|
1868
|
+
* return true; // Follow permanent/temporary redirects
|
|
1869
|
+
* } else if (status === 307 || status === 308) {
|
|
1870
|
+
* return { redirect: true, url: url.toString() }; // Preserve method for 307/308
|
|
1871
|
+
* } else if (status === 303) {
|
|
1872
|
+
* return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
|
|
1873
|
+
* }
|
|
1874
|
+
* return false; // Reject other redirects
|
|
1875
|
+
* }
|
|
1876
|
+
* ```
|
|
1877
|
+
*/
|
|
1878
|
+
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
1596
1879
|
/** Character encoding for request body and response data */
|
|
1597
1880
|
encoding?: BufferEncoding;
|
|
1598
1881
|
/**
|
|
1599
|
-
*
|
|
1600
|
-
* Optional hooks that will be merged with default hooks during request processing.
|
|
1882
|
+
* Whether to use cookies for the request
|
|
1601
1883
|
*/
|
|
1602
|
-
|
|
1884
|
+
useCookies: boolean;
|
|
1603
1885
|
}
|
|
1604
|
-
export
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1886
|
+
export declare enum RezoErrorCode {
|
|
1887
|
+
CONNECTION_REFUSED = "ECONNREFUSED",
|
|
1888
|
+
CONNECTION_RESET = "ECONNRESET",
|
|
1889
|
+
CONNECTION_TIMEOUT = "ETIMEDOUT",
|
|
1890
|
+
DNS_LOOKUP_FAILED = "ENOTFOUND",
|
|
1891
|
+
DNS_TEMPORARY_FAILURE = "EAI_AGAIN",
|
|
1892
|
+
HOST_UNREACHABLE = "EHOSTUNREACH",
|
|
1893
|
+
NETWORK_UNREACHABLE = "ENETUNREACH",
|
|
1894
|
+
BROKEN_PIPE = "EPIPE",
|
|
1895
|
+
HTTP_ERROR = "REZ_HTTP_ERROR",
|
|
1896
|
+
REDIRECT_DENIED = "REZ_REDIRECT_DENIED",
|
|
1897
|
+
MAX_REDIRECTS = "REZ_MAX_REDIRECTS_EXCEEDED",
|
|
1898
|
+
REDIRECT_CYCLE = "REZ_REDIRECT_CYCLE_DETECTED",
|
|
1899
|
+
MISSING_REDIRECT_LOCATION = "REZ_MISSING_REDIRECT_LOCATION",
|
|
1900
|
+
DECOMPRESSION_ERROR = "REZ_DECOMPRESSION_ERROR",
|
|
1901
|
+
REQUEST_TIMEOUT = "UND_ERR_REQUEST_TIMEOUT",
|
|
1902
|
+
HEADERS_TIMEOUT = "UND_ERR_HEADERS_TIMEOUT",
|
|
1903
|
+
CONNECT_TIMEOUT = "UND_ERR_CONNECT_TIMEOUT",
|
|
1904
|
+
ABORTED = "ABORT_ERR",
|
|
1905
|
+
DOWNLOAD_FAILED = "REZ_DOWNLOAD_FAILED",
|
|
1906
|
+
UPLOAD_FAILED = "REZ_UPLOAD_FAILED",
|
|
1907
|
+
STREAM_ERROR = "REZ_STREAM_ERROR",
|
|
1908
|
+
BODY_TOO_LARGE = "REZ_BODY_TOO_LARGE",
|
|
1909
|
+
RESPONSE_TOO_LARGE = "REZ_RESPONSE_TOO_LARGE",
|
|
1910
|
+
INVALID_JSON = "REZ_INVALID_JSON",
|
|
1911
|
+
INVALID_URL = "ERR_INVALID_URL",
|
|
1912
|
+
INVALID_PROTOCOL = "ERR_INVALID_PROTOCOL",
|
|
1913
|
+
INVALID_ARGUMENT = "ERR_INVALID_ARG_TYPE",
|
|
1914
|
+
FILE_PERMISSION = "REZ_FILE_PERMISSION_ERROR",
|
|
1915
|
+
PROXY_CONNECTION_FAILED = "REZ_PROXY_CONNECTION_FAILED",
|
|
1916
|
+
PROXY_AUTH_FAILED = "REZ_PROXY_AUTHENTICATION_FAILED",
|
|
1917
|
+
PROXY_TARGET_UNREACHABLE = "REZ_PROXY_TARGET_UNREACHABLE",
|
|
1918
|
+
PROXY_TIMEOUT = "REZ_PROXY_TIMEOUT",
|
|
1919
|
+
PROXY_ERROR = "REZ_PROXY_ERROR",
|
|
1920
|
+
PROXY_INVALID_PROTOCOL = "REZ_PROXY_INVALID_PROTOCOL",
|
|
1921
|
+
PROXY_INVALID_CONFIG = "REZ_PROXY_INVALID_HOSTPORT",
|
|
1922
|
+
SOCKS_CONNECTION_FAILED = "REZ_SOCKS_CONNECTION_FAILED",
|
|
1923
|
+
SOCKS_AUTH_FAILED = "REZ_SOCKS_AUTHENTICATION_FAILED",
|
|
1924
|
+
SOCKS_TARGET_UNREACHABLE = "REZ_SOCKS_TARGET_CONNECTION_FAILED",
|
|
1925
|
+
SOCKS_PROTOCOL_ERROR = "REZ_SOCKS_PROTOCOL_ERROR",
|
|
1926
|
+
SOCKS_UNSUPPORTED_VERSION = "REZ_SOCKS_UNSUPPORTED_VERSION",
|
|
1927
|
+
TLS_HANDSHAKE_TIMEOUT = "ERR_TLS_HANDSHAKE_TIMEOUT",
|
|
1928
|
+
TLS_PROTOCOL_ERROR = "EPROTO",
|
|
1929
|
+
TLS_PROTOCOL_VERSION = "ERR_TLS_INVALID_PROTOCOL_VERSION",
|
|
1930
|
+
CERTIFICATE_HOSTNAME_MISMATCH = "ERR_TLS_CERT_ALTNAME_INVALID",
|
|
1931
|
+
CERTIFICATE_EXPIRED = "CERT_HAS_EXPIRED",
|
|
1932
|
+
CERTIFICATE_SELF_SIGNED = "SELF_SIGNED_CERT_IN_CHAIN",
|
|
1933
|
+
CERTIFICATE_VERIFY_FAILED = "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
1934
|
+
RATE_LIMITED = "REZ_RATE_LIMITED",
|
|
1935
|
+
UNKNOWN_ERROR = "REZ_UNKNOWN_ERROR"
|
|
1610
1936
|
}
|
|
1611
|
-
export
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1937
|
+
export declare class RezoError<T = any> extends Error {
|
|
1938
|
+
readonly code?: string;
|
|
1939
|
+
readonly errno?: number;
|
|
1940
|
+
readonly config: RezoConfig;
|
|
1941
|
+
readonly request?: RezoHttpRequest;
|
|
1942
|
+
readonly response?: RezoResponse<T>;
|
|
1943
|
+
readonly isRezoError: boolean;
|
|
1944
|
+
readonly cause?: Error;
|
|
1945
|
+
readonly syscall?: string;
|
|
1946
|
+
readonly hostname?: string;
|
|
1947
|
+
readonly port?: number;
|
|
1948
|
+
readonly address?: string;
|
|
1949
|
+
readonly status?: number;
|
|
1950
|
+
readonly statusText?: string;
|
|
1951
|
+
readonly isTimeout: boolean;
|
|
1952
|
+
readonly isAborted: boolean;
|
|
1953
|
+
readonly isNetworkError: boolean;
|
|
1954
|
+
readonly isHttpError: boolean;
|
|
1955
|
+
readonly isProxyError: boolean;
|
|
1956
|
+
readonly isSocksError: boolean;
|
|
1957
|
+
readonly isTlsError: boolean;
|
|
1958
|
+
readonly isRetryable: boolean;
|
|
1959
|
+
readonly details: string;
|
|
1960
|
+
readonly suggestion: string;
|
|
1961
|
+
constructor(message: string, config: RezoConfig, code?: string, request?: RezoHttpRequest, response?: RezoResponse<T>);
|
|
1962
|
+
static isRezoError(error: unknown): error is RezoError;
|
|
1963
|
+
static fromError<T = any>(error: Error, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1964
|
+
static createNetworkError<T = any>(message: string, code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1965
|
+
static createHttpError<T = any>(statusCode: number, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1966
|
+
static createTimeoutError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1967
|
+
static createAbortError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1968
|
+
static createParsingError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1969
|
+
static createEnvironmentError<T = any>(message: string, config: RezoConfig): RezoError<T>;
|
|
1970
|
+
static createDecompressionError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1971
|
+
static createDownloadError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1972
|
+
static createUploadError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1973
|
+
static createStreamError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1974
|
+
static createRedirectError<T = any>(message: string, config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1975
|
+
static createProxyError<T = any>(code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1976
|
+
static createSocksError<T = any>(code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1977
|
+
static createTlsError<T = any>(code: string, config: RezoConfig, request?: RezoHttpRequest): RezoError<T>;
|
|
1978
|
+
static createRateLimitError<T = any>(config: RezoConfig, request?: RezoHttpRequest, response?: RezoResponse<T>): RezoError<T>;
|
|
1979
|
+
/**
|
|
1980
|
+
* Convert error to JSON - only includes defined values
|
|
1981
|
+
*/
|
|
1982
|
+
toJSON(): Record<string, unknown>;
|
|
1983
|
+
toString(): string;
|
|
1984
|
+
getFullDetails(): string;
|
|
1985
|
+
}
|
|
1986
|
+
type ProxyProtocol$1 = "http" | "https" | "socks4" | "socks5";
|
|
1987
|
+
/**
|
|
1988
|
+
* Configuration options for proxy connections
|
|
1989
|
+
*/
|
|
1990
|
+
export type ProxyOptions = {
|
|
1991
|
+
/** The proxy protocol to use */
|
|
1992
|
+
protocol: ProxyProtocol$1;
|
|
1993
|
+
/** Proxy server hostname or IP address */
|
|
1994
|
+
host: string;
|
|
1995
|
+
/** Proxy server port number */
|
|
1996
|
+
port: number;
|
|
1997
|
+
/** Optional authentication credentials for the proxy */
|
|
1998
|
+
auth?: {
|
|
1999
|
+
/** Username for proxy authentication */
|
|
2000
|
+
username: string;
|
|
2001
|
+
/** Password for proxy authentication */
|
|
2002
|
+
password: string;
|
|
2003
|
+
};
|
|
2004
|
+
/** Connection timeout in milliseconds */
|
|
2005
|
+
timeout?: number;
|
|
2006
|
+
/** Whether to keep the connection alive */
|
|
2007
|
+
keepAlive?: boolean;
|
|
2008
|
+
/** Keep-alive timeout in milliseconds */
|
|
2009
|
+
keepAliveMsecs?: number;
|
|
2010
|
+
/** Maximum number of sockets to allow per host */
|
|
2011
|
+
maxSockets?: number;
|
|
2012
|
+
/** Maximum number of free sockets to keep open per host */
|
|
2013
|
+
maxFreeSockets?: number;
|
|
2014
|
+
/** Whether to reject unauthorized SSL certificates */
|
|
2015
|
+
rejectUnauthorized?: boolean;
|
|
1623
2016
|
};
|
|
1624
2017
|
/**
|
|
1625
|
-
*
|
|
2018
|
+
* Maximum upload rate in bytes per second
|
|
2019
|
+
*/
|
|
2020
|
+
export type MaxUploadRate = number;
|
|
2021
|
+
/**
|
|
2022
|
+
* Maximum download rate in bytes per second
|
|
2023
|
+
*/
|
|
2024
|
+
export type MaxDownloadRate = number;
|
|
2025
|
+
/**
|
|
2026
|
+
* Custom string type for Rezo-specific string values
|
|
2027
|
+
*/
|
|
2028
|
+
export type RezoString = string;
|
|
2029
|
+
/**
|
|
2030
|
+
* Standard HTTP methods supported by Rezo
|
|
2031
|
+
*/
|
|
2032
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT";
|
|
2033
|
+
/**
|
|
2034
|
+
* Response data types that control how Rezo parses the response body.
|
|
1626
2035
|
*
|
|
1627
|
-
*
|
|
1628
|
-
*
|
|
2036
|
+
* @description
|
|
2037
|
+
* Specifies how the response body should be parsed and returned in `response.data`.
|
|
2038
|
+
* Choose the type that matches your expected response format.
|
|
1629
2039
|
*
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
2040
|
+
* **Available Types:**
|
|
2041
|
+
*
|
|
2042
|
+
* - `'json'` - Parse response as JSON. Returns parsed object/array.
|
|
2043
|
+
* Best for REST APIs that return JSON data.
|
|
2044
|
+
*
|
|
2045
|
+
* - `'text'` - Return response as a string. No parsing applied.
|
|
2046
|
+
* Best for HTML, XML, plain text, or when you need raw content.
|
|
2047
|
+
*
|
|
2048
|
+
* - `'blob'` - Return as Blob object (browser environments).
|
|
2049
|
+
* Best for binary data in browsers (images, files, etc).
|
|
2050
|
+
*
|
|
2051
|
+
* - `'arrayBuffer'` - Return as ArrayBuffer.
|
|
2052
|
+
* Best for binary data processing, cryptographic operations.
|
|
2053
|
+
*
|
|
2054
|
+
* - `'buffer'` - Return as Node.js Buffer.
|
|
2055
|
+
* Best for binary data in Node.js (files, images, binary protocols).
|
|
2056
|
+
*
|
|
2057
|
+
* - `'auto'` - Auto-detect based on Content-Type header (default).
|
|
2058
|
+
* JSON for `application/json`, text for `text/*`, buffer otherwise.
|
|
2059
|
+
*
|
|
2060
|
+
* **Streaming Operations:**
|
|
2061
|
+
* For streaming, use dedicated methods instead of responseType:
|
|
2062
|
+
* - `rezo.stream(url)` - Returns StreamResponse for real-time data
|
|
2063
|
+
* - `rezo.download(url, saveTo)` - Returns DownloadResponse with progress
|
|
2064
|
+
* - `rezo.upload(url, data)` - Returns UploadResponse with progress
|
|
2065
|
+
*
|
|
2066
|
+
* @example
|
|
2067
|
+
* // Get JSON data (default for JSON APIs)
|
|
2068
|
+
* const { data } = await rezo.get('/api/users', { responseType: 'json' });
|
|
2069
|
+
*
|
|
2070
|
+
* // Get HTML as text
|
|
2071
|
+
* const { data: html } = await rezo.get('/page', { responseType: 'text' });
|
|
2072
|
+
*
|
|
2073
|
+
* // Get image as buffer
|
|
2074
|
+
* const { data: imageBuffer } = await rezo.get('/image.png', { responseType: 'buffer' });
|
|
2075
|
+
*
|
|
2076
|
+
* @default 'auto'
|
|
1632
2077
|
*/
|
|
1633
|
-
|
|
2078
|
+
type ResponseType$1 = "json" | "text" | "blob" | "arrayBuffer" | "buffer" | "auto";
|
|
1634
2079
|
/**
|
|
1635
|
-
*
|
|
1636
|
-
|
|
1637
|
-
|
|
2080
|
+
* MIME content types for request/response bodies
|
|
2081
|
+
*/
|
|
2082
|
+
export type ContentType = "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | "text/html" | "application/xml" | "application/octet-stream" | RezoString;
|
|
2083
|
+
/**
|
|
2084
|
+
* RezoRequestConfig - Clean interface for internal request processing
|
|
1638
2085
|
*
|
|
1639
|
-
* @
|
|
1640
|
-
* @since 1.0.0
|
|
1641
|
-
* @example
|
|
1642
|
-
* ```typescript
|
|
1643
|
-
* const config: RezoConfig = {
|
|
1644
|
-
* originalRequest: requestConfig,
|
|
1645
|
-
* finalUrl: 'https://api.example.com/data',
|
|
1646
|
-
* adapterUsed: 'fetch',
|
|
1647
|
-
* timing: { startTime: Date.now(), endTime: Date.now() + 1000, total: 1000 },
|
|
1648
|
-
* network: { protocol: 'https' },
|
|
1649
|
-
* transfer: { requestSize: 256, responseSize: 1024, headerSize: 128, bodySize: 896 },
|
|
1650
|
-
* retryAttempts: 0,
|
|
1651
|
-
* errors: [],
|
|
1652
|
-
* security: {},
|
|
1653
|
-
* metadata: {}
|
|
1654
|
-
* };
|
|
1655
|
-
* ```
|
|
2086
|
+
* @template D - Type of the request body data
|
|
1656
2087
|
*/
|
|
1657
|
-
export interface
|
|
1658
|
-
/**
|
|
1659
|
-
url: string;
|
|
1660
|
-
/** @description HTTP method (GET, POST, PUT, DELETE, etc.) */
|
|
1661
|
-
method: RezoRequestConfig["method"];
|
|
1662
|
-
/** @description HTTP headers to be sent with the request */
|
|
1663
|
-
headers: RezoHeaders;
|
|
1664
|
-
/** @description Request payload data (null when not set) */
|
|
1665
|
-
data?: RezoRequestConfig["body"] | null;
|
|
1666
|
-
/** @description URL query parameters */
|
|
1667
|
-
params?: RezoRequestConfig["params"];
|
|
1668
|
-
/** @description Request timeout in milliseconds (null when not set) */
|
|
1669
|
-
timeout?: number | null;
|
|
1670
|
-
/** @description Expected response data type */
|
|
1671
|
-
responseType?: "json" | "text" | "blob" | "arrayBuffer" | "stream" | "download" | "upload" | "buffer" | "binary";
|
|
1672
|
-
/** @description Basic authentication credentials (null when not set) */
|
|
1673
|
-
auth?: RezoRequestConfig["auth"] | null;
|
|
1674
|
-
/** @description Proxy configuration (null when not set) */
|
|
1675
|
-
proxy?: RezoRequestConfig["proxy"] | null;
|
|
1676
|
-
/** @description Maximum number of redirects to follow */
|
|
1677
|
-
maxRedirects: number;
|
|
1678
|
-
/** @description Base URL for relative requests */
|
|
1679
|
-
baseURL?: string;
|
|
1680
|
-
/** @description Enable HTTP/2 protocol */
|
|
1681
|
-
http2: boolean;
|
|
1682
|
-
/** @description Enable cURL command generation */
|
|
1683
|
-
curl: boolean;
|
|
1684
|
-
/** @description Enable detection of redirect cycles */
|
|
1685
|
-
enableRedirectCycleDetection?: boolean;
|
|
1686
|
-
/** @description Reject unauthorized SSL certificates */
|
|
1687
|
-
rejectUnauthorized?: boolean;
|
|
1688
|
-
/** @description Retry configuration */
|
|
1689
|
-
retry?: RezoRequestConfig["retry"];
|
|
1690
|
-
/** @description Compression settings */
|
|
1691
|
-
compression?: {
|
|
1692
|
-
/** @description Enable compression */
|
|
1693
|
-
enabled?: boolean;
|
|
1694
|
-
/** @description Compression threshold in bytes */
|
|
1695
|
-
threshold?: number;
|
|
1696
|
-
/** @description Supported compression algorithms */
|
|
1697
|
-
algorithms?: string[];
|
|
1698
|
-
};
|
|
1699
|
-
/** @description Enable cookie jar for session management */
|
|
1700
|
-
enableCookieJar?: boolean;
|
|
1701
|
-
/** @description Feature flags for adapter capabilities */
|
|
1702
|
-
features?: {
|
|
1703
|
-
/** @description HTTP/2 support */
|
|
1704
|
-
http2?: boolean;
|
|
1705
|
-
/** @description Compression support */
|
|
1706
|
-
compression?: boolean;
|
|
1707
|
-
/** @description Cookie support */
|
|
1708
|
-
cookies?: boolean;
|
|
1709
|
-
/** @description Redirect support */
|
|
1710
|
-
redirects?: boolean;
|
|
1711
|
-
/** @description Proxy support */
|
|
1712
|
-
proxy?: boolean;
|
|
1713
|
-
/** @description Timeout support */
|
|
1714
|
-
timeout?: boolean;
|
|
1715
|
-
/** @description Retry support */
|
|
1716
|
-
retry?: boolean;
|
|
1717
|
-
/** @description Cache support */
|
|
1718
|
-
cache?: boolean;
|
|
1719
|
-
/** @description Metrics support */
|
|
1720
|
-
metrics?: boolean;
|
|
1721
|
-
/** @description Event support */
|
|
1722
|
-
events?: boolean;
|
|
1723
|
-
/** @description Validation support */
|
|
1724
|
-
validation?: boolean;
|
|
1725
|
-
/** @description Browser support */
|
|
1726
|
-
browser?: boolean;
|
|
1727
|
-
/** @description SSL support */
|
|
1728
|
-
ssl?: boolean;
|
|
1729
|
-
};
|
|
1730
|
-
/** @description Use insecure HTTP parser */
|
|
1731
|
-
insecureHTTPParser: boolean;
|
|
1732
|
-
/** @description Custom adapter implementation */
|
|
1733
|
-
adapter?: any;
|
|
1734
|
-
isSecure?: boolean;
|
|
2088
|
+
export interface RezoRequestConfig<D = any> {
|
|
2089
|
+
/** The target URL for the request */
|
|
2090
|
+
url: string | URL;
|
|
1735
2091
|
/**
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
* Controls the maximum transfer speed in bytes per second.
|
|
1739
|
-
*
|
|
1740
|
-
* - `number`: Applies same limit to both download and upload (e.g., 1024000 = ~1MB/s)
|
|
1741
|
-
* - `[download, upload]`: Different limits for each direction (e.g., [5242880, 1048576] = 5MB/s down, 1MB/s up)
|
|
1742
|
-
* - `0` or `null`: No rate limiting (unlimited speed)
|
|
1743
|
-
*
|
|
1744
|
-
* Common values:
|
|
1745
|
-
* - 1048576 = 1 MB/s
|
|
1746
|
-
* - 5242880 = 5 MB/s
|
|
1747
|
-
* - 10485760 = 10 MB/s
|
|
1748
|
-
*
|
|
1749
|
-
* Note: Actual transfer speed may vary based on network conditions and adapter support.
|
|
1750
|
-
* This feature is adapter-dependent (HTTP adapter supports it, other adapters may vary).
|
|
2092
|
+
* The absolute request url
|
|
1751
2093
|
*/
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
/**
|
|
1761
|
-
|
|
1762
|
-
/** @description HTTP agent for connection pooling (null when not set) */
|
|
1763
|
-
httpAgent?: RezoRequestConfig["httpAgent"] | null;
|
|
1764
|
-
/** @description HTTPS agent for secure connection pooling (null when not set) */
|
|
1765
|
-
httpsAgent?: RezoRequestConfig["httpsAgent"] | null;
|
|
1766
|
-
/** @description Unix socket path (null when not set) */
|
|
1767
|
-
socketPath?: string | null;
|
|
1768
|
-
/** @description File path to save the response (null when not set) */
|
|
1769
|
-
fileName?: string | null;
|
|
2094
|
+
fullUrl: string;
|
|
2095
|
+
/** Request method to use for the request */
|
|
2096
|
+
method: HttpMethod;
|
|
2097
|
+
/** Request headers as various supported formats */
|
|
2098
|
+
headers?: [
|
|
2099
|
+
string,
|
|
2100
|
+
string
|
|
2101
|
+
][] | Record<string, string> | Headers | RezoHttpHeaders | RezoHeaders | OutgoingHttpHeaders;
|
|
2102
|
+
/** URL query parameters to append to the request */
|
|
2103
|
+
params?: Record<string | number, any>;
|
|
1770
2104
|
/**
|
|
1771
|
-
*
|
|
1772
|
-
* These cookies are configured before the request is made and will be included in the request headers.
|
|
2105
|
+
* Queue to use for request execution
|
|
1773
2106
|
*/
|
|
1774
|
-
|
|
2107
|
+
queue?: PQueue | null;
|
|
1775
2108
|
/**
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
2109
|
+
* Controls how the response body is parsed and returned in `response.data`.
|
|
2110
|
+
*
|
|
2111
|
+
* **Available Types:**
|
|
2112
|
+
* - `'json'` - Parse as JSON object/array. Best for REST APIs.
|
|
2113
|
+
* - `'text'` - Return as string. Best for HTML, XML, plain text.
|
|
2114
|
+
* - `'blob'` - Return as Blob (browser). Best for binary in browsers.
|
|
2115
|
+
* - `'arrayBuffer'` - Return as ArrayBuffer. Best for binary processing.
|
|
2116
|
+
* - `'buffer'` - Return as Buffer (Node.js). Best for binary in Node.
|
|
2117
|
+
* - `'auto'` - Auto-detect from Content-Type header (default).
|
|
2118
|
+
*
|
|
2119
|
+
* **For streaming, use dedicated methods instead:**
|
|
2120
|
+
* - `rezo.stream(url)` - Real-time streaming data
|
|
2121
|
+
* - `rezo.download(url, saveTo)` - Download with progress
|
|
2122
|
+
* - `rezo.upload(url, data)` - Upload with progress
|
|
2123
|
+
*
|
|
2124
|
+
* @default 'auto'
|
|
2125
|
+
* @example
|
|
2126
|
+
* // Get JSON
|
|
2127
|
+
* const { data } = await rezo.get('/api/users', { responseType: 'json' });
|
|
2128
|
+
*
|
|
2129
|
+
* // Get HTML as text
|
|
2130
|
+
* const { data: html } = await rezo.get('/page', { responseType: 'text' });
|
|
2131
|
+
*
|
|
2132
|
+
* // Get image as buffer
|
|
2133
|
+
* const { data: img } = await rezo.get('/image.png', { responseType: 'buffer' });
|
|
1779
2134
|
*/
|
|
1780
|
-
|
|
2135
|
+
responseType?: ResponseType$1;
|
|
2136
|
+
/** Character encoding for the response */
|
|
2137
|
+
responseEncoding?: string;
|
|
2138
|
+
/** Base URL for the request (used with relative URLs) */
|
|
2139
|
+
baseURL?: string;
|
|
2140
|
+
/** Raw request body data */
|
|
2141
|
+
body?: D;
|
|
2142
|
+
/** JSON object to be serialized as request body */
|
|
2143
|
+
json?: Record<string, any>;
|
|
2144
|
+
/** Form data to be URL-encoded */
|
|
2145
|
+
form?: Record<string, any>;
|
|
2146
|
+
/** Form data for multipart/form-data requests */
|
|
2147
|
+
formData?: Record<string, any> | RezoFormData;
|
|
2148
|
+
/** Multipart data (alias for formData) */
|
|
2149
|
+
multipart?: Record<string, any> | RezoFormData;
|
|
2150
|
+
/** Whether to detect and prevent redirect cycles */
|
|
2151
|
+
enableRedirectCycleDetection?: boolean;
|
|
2152
|
+
/** MIME type for the request content */
|
|
2153
|
+
contentType?: ContentType | string;
|
|
2154
|
+
/** Skip setting Content-Type header automatically */
|
|
2155
|
+
withoutContentType?: boolean;
|
|
2156
|
+
/** Basic authentication credentials */
|
|
2157
|
+
auth?: {
|
|
2158
|
+
/** Username for authentication */
|
|
2159
|
+
username: string;
|
|
2160
|
+
/** Password for authentication */
|
|
2161
|
+
password: string;
|
|
2162
|
+
};
|
|
2163
|
+
/** Request timeout in milliseconds */
|
|
2164
|
+
timeout?: number;
|
|
2165
|
+
/** Whether to reject requests with invalid SSL certificates */
|
|
2166
|
+
rejectUnauthorized?: boolean;
|
|
2167
|
+
/** Retry configuration for failed requests */
|
|
2168
|
+
retry?: {
|
|
2169
|
+
/** Maximum number of retry attempts */
|
|
2170
|
+
maxRetries?: number;
|
|
2171
|
+
/** Delay between retries in milliseconds */
|
|
2172
|
+
retryDelay?: number;
|
|
2173
|
+
/** Whether to increment delay on each retry */
|
|
2174
|
+
incrementDelay?: boolean;
|
|
2175
|
+
/** HTTP status codes that should trigger a retry attempt defaults are (408, 429, 500, 502, 503, 504, 425, 520) */
|
|
2176
|
+
statusCodes?: number[];
|
|
2177
|
+
/** Weather to stop or continue retry when certain condition is met*/
|
|
2178
|
+
condition?: (error: RezoError) => boolean | Promise<boolean>;
|
|
2179
|
+
};
|
|
2180
|
+
/** Whether to use a secure context for HTTPS requests */
|
|
2181
|
+
useSecureContext?: boolean;
|
|
2182
|
+
/** Custom secure context for TLS connections */
|
|
2183
|
+
secureContext?: SecureContext;
|
|
2184
|
+
/** Whether to automatically follow HTTP redirects */
|
|
2185
|
+
followRedirects?: boolean;
|
|
2186
|
+
/** Maximum number of redirects to follow */
|
|
2187
|
+
maxRedirects?: number;
|
|
2188
|
+
/** Whether to automatically decompress response data */
|
|
2189
|
+
decompress?: boolean;
|
|
2190
|
+
/** Whether to keep the connection alive for reuse */
|
|
2191
|
+
keepAlive?: boolean;
|
|
2192
|
+
withoutBodyOnRedirect?: boolean;
|
|
2193
|
+
autoSetReferer?: boolean;
|
|
2194
|
+
autoSetOrigin?: boolean;
|
|
2195
|
+
treat302As303?: boolean;
|
|
2196
|
+
startNewRequest?: boolean;
|
|
2197
|
+
/** Whether to use HTTP/2 protocol */
|
|
2198
|
+
http2?: boolean;
|
|
2199
|
+
/** Whether to use cURL adapter */
|
|
2200
|
+
curl?: boolean;
|
|
1781
2201
|
/**
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1784
|
-
*
|
|
2202
|
+
* DNS cache configuration for faster repeated requests.
|
|
2203
|
+
*
|
|
2204
|
+
* When enabled, DNS lookups are cached to avoid repeated DNS queries
|
|
2205
|
+
* for the same hostname, significantly improving performance for
|
|
2206
|
+
* applications making many requests to the same servers.
|
|
2207
|
+
*
|
|
2208
|
+
* **Options:**
|
|
2209
|
+
* - `true` - Enable with default settings (1 min TTL, 1000 entries max)
|
|
2210
|
+
* - `false` - Disable DNS caching (default)
|
|
2211
|
+
* - `object` - Custom configuration with ttl and maxEntries
|
|
2212
|
+
*
|
|
2213
|
+
* @example
|
|
2214
|
+
* // Enable with defaults
|
|
2215
|
+
* { dnsCache: true }
|
|
2216
|
+
*
|
|
2217
|
+
* // Custom TTL (5 minutes) and max entries
|
|
2218
|
+
* { dnsCache: { ttl: 300000, maxEntries: 500 } }
|
|
2219
|
+
*
|
|
2220
|
+
* @default false
|
|
1785
2221
|
*/
|
|
1786
|
-
|
|
2222
|
+
dnsCache?: boolean | {
|
|
2223
|
+
/** Time-to-live for cached entries in milliseconds */
|
|
2224
|
+
ttl?: number;
|
|
2225
|
+
/** Maximum number of entries to cache */
|
|
2226
|
+
maxEntries?: number;
|
|
2227
|
+
};
|
|
1787
2228
|
/**
|
|
1788
|
-
*
|
|
1789
|
-
* null when no hooks are registered, otherwise contains only hooks with registered functions.
|
|
1790
|
-
* Empty arrays are not included - only hooks with actual handlers appear.
|
|
2229
|
+
* Response cache configuration for caching HTTP responses.
|
|
1791
2230
|
*
|
|
1792
|
-
*
|
|
1793
|
-
* -
|
|
1794
|
-
* -
|
|
1795
|
-
*
|
|
1796
|
-
*
|
|
1797
|
-
* -
|
|
1798
|
-
* -
|
|
1799
|
-
* -
|
|
1800
|
-
*
|
|
1801
|
-
* -
|
|
1802
|
-
* -
|
|
1803
|
-
* -
|
|
2231
|
+
* When enabled, successful GET/HEAD responses are cached to avoid
|
|
2232
|
+
* repeated network requests. Supports memory-only or file persistence.
|
|
2233
|
+
* Honors Cache-Control headers by default.
|
|
2234
|
+
*
|
|
2235
|
+
* **Options:**
|
|
2236
|
+
* - `true` - Enable memory cache with defaults (5 min TTL, 500 entries)
|
|
2237
|
+
* - `false` - Disable response caching (default)
|
|
2238
|
+
* - `object` - Custom configuration
|
|
2239
|
+
*
|
|
2240
|
+
* **Cache-Control Support:**
|
|
2241
|
+
* - Respects `max-age`, `s-maxage`, `no-store`, `no-cache`
|
|
2242
|
+
* - Sends `If-None-Match` / `If-Modified-Since` for revalidation
|
|
2243
|
+
* - Returns cached response on 304 Not Modified
|
|
2244
|
+
*
|
|
2245
|
+
* @example
|
|
2246
|
+
* // Enable memory-only cache
|
|
2247
|
+
* { cache: true }
|
|
2248
|
+
*
|
|
2249
|
+
* // With file persistence
|
|
2250
|
+
* { cache: { cacheDir: './cache', ttl: 300000 } }
|
|
2251
|
+
*
|
|
2252
|
+
* // Custom settings
|
|
2253
|
+
* { cache: {
|
|
2254
|
+
* ttl: 600000, // 10 minutes
|
|
2255
|
+
* maxEntries: 1000,
|
|
2256
|
+
* methods: ['GET'], // Only cache GET
|
|
2257
|
+
* respectHeaders: true // Honor Cache-Control
|
|
2258
|
+
* }}
|
|
2259
|
+
*
|
|
2260
|
+
* @default false
|
|
1804
2261
|
*/
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
/**
|
|
1815
|
-
|
|
1816
|
-
/** @description Supported features */
|
|
1817
|
-
features?: string[];
|
|
1818
|
-
/** @description Adapter capabilities */
|
|
1819
|
-
capabilities?: Record<string, any>;
|
|
2262
|
+
cache?: boolean | {
|
|
2263
|
+
/** Directory for persistent cache storage (enables file persistence) */
|
|
2264
|
+
cacheDir?: string;
|
|
2265
|
+
/** Time-to-live for cached entries in milliseconds */
|
|
2266
|
+
ttl?: number;
|
|
2267
|
+
/** Maximum number of entries to cache */
|
|
2268
|
+
maxEntries?: number;
|
|
2269
|
+
/** HTTP methods to cache */
|
|
2270
|
+
methods?: string[];
|
|
2271
|
+
/** Whether to respect Cache-Control headers */
|
|
2272
|
+
respectHeaders?: boolean;
|
|
1820
2273
|
};
|
|
1821
|
-
/** @description Complete redirect chain history */
|
|
1822
|
-
redirectHistory: {
|
|
1823
|
-
/** @description Cookies set in this redirect */
|
|
1824
|
-
cookies: Cookie[];
|
|
1825
|
-
/** @description Redirect URL */
|
|
1826
|
-
url: string;
|
|
1827
|
-
/** @description HTTP status code */
|
|
1828
|
-
statusCode: number;
|
|
1829
|
-
/** @description HTTP status text */
|
|
1830
|
-
statusText: string;
|
|
1831
|
-
/** @description Response headers */
|
|
1832
|
-
headers: RezoHeaders;
|
|
1833
|
-
/** @description Redirect timestamp */
|
|
1834
|
-
duration: number;
|
|
1835
|
-
/** @description Request configuration at this step */
|
|
1836
|
-
request: RezoRequestConfig;
|
|
1837
|
-
/** @description HTTP method used */
|
|
1838
|
-
method: string;
|
|
1839
|
-
}[];
|
|
1840
|
-
/** @description Number of redirects followed */
|
|
1841
|
-
redirectCount: number;
|
|
1842
|
-
/** @description Whether maximum redirects limit was reached */
|
|
1843
|
-
maxRedirectsReached: boolean;
|
|
1844
2274
|
/**
|
|
1845
|
-
*
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1850
|
-
* -
|
|
2275
|
+
* Callback invoked when a redirect response is received.
|
|
2276
|
+
* Controls redirect behavior including whether to follow, modify URL, or change HTTP method.
|
|
2277
|
+
*
|
|
2278
|
+
* @param options - Redirect response details
|
|
2279
|
+
* @param options.url - Redirect target URL
|
|
2280
|
+
* @param options.status - HTTP status code
|
|
2281
|
+
* @param options.headers - Response headers
|
|
2282
|
+
* @param options.sameDomain - Whether redirect is to same domain
|
|
2283
|
+
* @returns Boolean to follow/reject redirect, or object for granular control
|
|
2284
|
+
*
|
|
2285
|
+
* @example
|
|
2286
|
+
* ```typescript
|
|
2287
|
+
* beforeRedirect: ({ status, url }) => {
|
|
2288
|
+
* if (status === 301 || status === 302) {
|
|
2289
|
+
* return true; // Follow permanent/temporary redirects
|
|
2290
|
+
* } else if (status === 307 || status === 308) {
|
|
2291
|
+
* return { redirect: true, url: url.toString() }; // Preserve method for 307/308
|
|
2292
|
+
* } else if (status === 303) {
|
|
2293
|
+
* return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
|
|
2294
|
+
* }
|
|
2295
|
+
* return false; // Reject other redirects
|
|
2296
|
+
* }
|
|
2297
|
+
* ```
|
|
1851
2298
|
*/
|
|
1852
|
-
|
|
1853
|
-
/**
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
/**
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
/**
|
|
1904
|
-
|
|
1905
|
-
/** @description Compression ratio if applicable */
|
|
1906
|
-
compressionRatio?: number;
|
|
1907
|
-
};
|
|
1908
|
-
/** @description Number of retry attempts made */
|
|
1909
|
-
retryAttempts: number;
|
|
1910
|
-
/** @description Error history during request execution */
|
|
1911
|
-
errors: Array<{
|
|
1912
|
-
/** @description Retry attempt number */
|
|
1913
|
-
attempt: number;
|
|
1914
|
-
/** @description Error message */
|
|
1915
|
-
error: RezoError;
|
|
1916
|
-
/** @description Request duration before error */
|
|
1917
|
-
duration: number;
|
|
1918
|
-
}>;
|
|
1919
|
-
/** @description Security and validation information */
|
|
1920
|
-
security: {
|
|
1921
|
-
/** @description TLS version used */
|
|
1922
|
-
tlsVersion?: string;
|
|
1923
|
-
/** @description Cipher suite used */
|
|
1924
|
-
cipher?: string;
|
|
1925
|
-
/** @description Certificate information */
|
|
1926
|
-
certificateInfo?: Record<string, any>;
|
|
1927
|
-
/** @description Validation results */
|
|
1928
|
-
validationResults?: Record<string, boolean>;
|
|
2299
|
+
beforeRedirect?: (options: OnRedirectOptions) => OnRedirectResponse;
|
|
2300
|
+
/** Whether to send cookies and authorization headers with cross-origin requests */
|
|
2301
|
+
withCredentials?: boolean;
|
|
2302
|
+
/** Proxy configuration (URL string or detailed options) */
|
|
2303
|
+
proxy?: string | ProxyOptions;
|
|
2304
|
+
/** Whether to enable automatic cookie handling */
|
|
2305
|
+
useCookies?: boolean;
|
|
2306
|
+
/** Custom cookie jar for managing cookies */
|
|
2307
|
+
cookieJar?: RezoCookieJar;
|
|
2308
|
+
/** Cookies to send with the request in various formats */
|
|
2309
|
+
cookies?: Cookies["array"] | Cookies["netscape"] | Cookies["serialized"] | Cookies["setCookiesString"];
|
|
2310
|
+
/** Callback for upload progress events */
|
|
2311
|
+
onUploadProgress?: (progressEvent: any) => void;
|
|
2312
|
+
/** Callback for download progress events */
|
|
2313
|
+
onDownloadProgress?: (progressEvent: any) => void;
|
|
2314
|
+
/** Maximum allowed size of the request body in bytes */
|
|
2315
|
+
maxBodyLength?: number;
|
|
2316
|
+
/** Maximum transfer rate (single number or [upload, download] tuple) */
|
|
2317
|
+
maxRate?: number | [
|
|
2318
|
+
MaxUploadRate,
|
|
2319
|
+
MaxDownloadRate
|
|
2320
|
+
];
|
|
2321
|
+
/** Array of functions to transform request data */
|
|
2322
|
+
transformRequest?: Array<(data: any, headers: RezoHeaders) => any>;
|
|
2323
|
+
/** Array of functions to transform response data */
|
|
2324
|
+
transformResponse?: Array<(data: any) => any>;
|
|
2325
|
+
/** Adapter to use for the request (name or custom function) */
|
|
2326
|
+
adapter?: string | ((config: RezoRequestConfig) => Promise<any>);
|
|
2327
|
+
/** AbortSignal to cancel the request */
|
|
2328
|
+
signal?: AbortSignal;
|
|
2329
|
+
/** File path to save the response to (for downloads) */
|
|
2330
|
+
saveTo?: string;
|
|
2331
|
+
/** Custom filename for downloaded files */
|
|
2332
|
+
fileName?: string;
|
|
2333
|
+
/** Browser simulation configuration for user agent spoofing */
|
|
2334
|
+
browser?: {
|
|
2335
|
+
/** Browser name to simulate */
|
|
2336
|
+
name: "chrome" | "firefox" | "safari" | "edge" | "opera" | "ie" | "chromium";
|
|
2337
|
+
/** Browser version string */
|
|
2338
|
+
version: string;
|
|
2339
|
+
/** Device platform type */
|
|
2340
|
+
platform: "desktop" | "mobile" | "tablet";
|
|
2341
|
+
/** Operating system details */
|
|
2342
|
+
os: {
|
|
2343
|
+
/** Operating system name */
|
|
2344
|
+
name: "windows" | "macos" | "linux" | "ios" | "android" | "chromeos";
|
|
2345
|
+
/** OS version string */
|
|
2346
|
+
version: string;
|
|
2347
|
+
/** CPU architecture */
|
|
2348
|
+
architecture: "x86" | "x64" | "arm" | "arm64";
|
|
2349
|
+
};
|
|
2350
|
+
/** Browser language preference */
|
|
2351
|
+
language?: string;
|
|
1929
2352
|
};
|
|
1930
|
-
/**
|
|
2353
|
+
/** Enable debug logging for the request */
|
|
1931
2354
|
debug?: boolean;
|
|
1932
|
-
/**
|
|
1933
|
-
|
|
1934
|
-
/**
|
|
1935
|
-
|
|
1936
|
-
/**
|
|
1937
|
-
|
|
1938
|
-
/**
|
|
1939
|
-
|
|
1940
|
-
/**
|
|
1941
|
-
|
|
1942
|
-
/**
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
* @returns Boolean to follow/reject redirect, or object for granular control
|
|
1952
|
-
*
|
|
1953
|
-
* @example
|
|
1954
|
-
* ```typescript
|
|
1955
|
-
* beforeRedirect: ({ status, url }) => {
|
|
1956
|
-
* if (status === 301 || status === 302) {
|
|
1957
|
-
* return true; // Follow permanent/temporary redirects
|
|
1958
|
-
* } else if (status === 307 || status === 308) {
|
|
1959
|
-
* return { redirect: true, url: url.toString() }; // Preserve method for 307/308
|
|
1960
|
-
* } else if (status === 303) {
|
|
1961
|
-
* return { redirect: true, url: url.toString(), method: 'GET' }; // Force GET for 303
|
|
1962
|
-
* }
|
|
1963
|
-
* return false; // Reject other redirects
|
|
1964
|
-
* }
|
|
1965
|
-
* ```
|
|
1966
|
-
*/
|
|
1967
|
-
beforeRedirect?: RezoRequestConfig["beforeRedirect"];
|
|
2355
|
+
/** Enable verbose logging with detailed information */
|
|
2356
|
+
verbose?: boolean;
|
|
2357
|
+
/** Name of the cookie containing XSRF token */
|
|
2358
|
+
xsrfCookieName?: string;
|
|
2359
|
+
/** Name of the header to send XSRF token in */
|
|
2360
|
+
xsrfHeaderName?: string;
|
|
2361
|
+
/** Custom HTTP agent for HTTP requests */
|
|
2362
|
+
httpAgent?: HttpAgent;
|
|
2363
|
+
/** Custom HTTPS agent for HTTPS requests */
|
|
2364
|
+
httpsAgent?: HttpsAgent;
|
|
2365
|
+
/** Transitional options for backward compatibility */
|
|
2366
|
+
transitional?: {
|
|
2367
|
+
/** Silently ignore JSON parsing errors */
|
|
2368
|
+
silentJSONParsing?: boolean;
|
|
2369
|
+
/** Force JSON parsing even for non-JSON responses */
|
|
2370
|
+
forcedJSONParsing?: boolean;
|
|
2371
|
+
/** Provide clearer timeout error messages */
|
|
2372
|
+
clarifyTimeoutError?: boolean;
|
|
2373
|
+
};
|
|
1968
2374
|
/** Character encoding for request body and response data */
|
|
1969
2375
|
encoding?: BufferEncoding;
|
|
1970
2376
|
/**
|
|
1971
|
-
*
|
|
2377
|
+
* Request lifecycle hooks for intercepting and modifying request/response behavior.
|
|
2378
|
+
* Optional hooks that will be merged with default hooks during request processing.
|
|
1972
2379
|
*/
|
|
1973
|
-
|
|
2380
|
+
hooks?: Partial<RezoHooks>;
|
|
2381
|
+
}
|
|
2382
|
+
export interface OnRedirectOptions {
|
|
2383
|
+
url: URL;
|
|
2384
|
+
status: number;
|
|
2385
|
+
headers: RezoHeaders;
|
|
2386
|
+
sameDomain: boolean;
|
|
2387
|
+
method: string;
|
|
1974
2388
|
}
|
|
2389
|
+
export type OnRedirectResponse = boolean | ToRedirectOptions | undefined;
|
|
2390
|
+
export type ToRedirectOptions = {
|
|
2391
|
+
redirect: false;
|
|
2392
|
+
message?: string;
|
|
2393
|
+
} | {
|
|
2394
|
+
redirect: true;
|
|
2395
|
+
url: string;
|
|
2396
|
+
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
|
2397
|
+
body?: any;
|
|
2398
|
+
withoutBody?: boolean;
|
|
2399
|
+
setHeaders?: RezoHeaders | OutgoingHttpHeaders;
|
|
2400
|
+
setHeadersOnRedirects?: RezoHeaders | OutgoingHttpHeaders;
|
|
2401
|
+
};
|
|
2402
|
+
/**
|
|
2403
|
+
* RezoHttpRequest - Request configuration type for all methods
|
|
2404
|
+
*
|
|
2405
|
+
* This type excludes internal properties and is specifically designed for public API usage.
|
|
2406
|
+
* Use this type when creating reusable request configurations for the all method.
|
|
2407
|
+
*
|
|
2408
|
+
* @public - Use with all methods
|
|
2409
|
+
* @internal - Do not use internally within the library
|
|
2410
|
+
*/
|
|
2411
|
+
export type RezoHttpRequest = Omit<RezoRequestConfig, "body" | "url" | "method" | "form" | "json" | "formData" | "multipart" | "fullUrl" | "responseType">;
|
|
2412
|
+
/**
|
|
2413
|
+
* Method-aware request types for better TypeScript inference
|
|
2414
|
+
* These types remove data/body fields from methods that don't typically use them
|
|
2415
|
+
*/
|
|
2416
|
+
/**
|
|
2417
|
+
* RezoHttpGetRequest - Request options for GET requests (no request body)
|
|
2418
|
+
* @public - Use with GET method
|
|
2419
|
+
*/
|
|
2420
|
+
export type RezoHttpGetRequest = Omit<RezoHttpRequest, "data" | "body">;
|
|
2421
|
+
/**
|
|
2422
|
+
* RezoHttpPostRequest - Request options for POST requests (includes request body)
|
|
2423
|
+
* @public - Use with POST method
|
|
2424
|
+
*/
|
|
2425
|
+
export type RezoHttpPostRequest = RezoHttpRequest;
|
|
2426
|
+
/**
|
|
2427
|
+
* RezoHttpPutRequest - Request options for PUT requests (includes request body)
|
|
2428
|
+
* @public - Use with PUT method
|
|
2429
|
+
*/
|
|
2430
|
+
export type RezoHttpPutRequest = RezoHttpRequest;
|
|
2431
|
+
/**
|
|
2432
|
+
* RezoHttpPatchRequest - Request options for PATCH requests (includes request body)
|
|
2433
|
+
* @public - Use with PATCH method
|
|
2434
|
+
*/
|
|
2435
|
+
export type RezoHttpPatchRequest = RezoHttpRequest;
|
|
2436
|
+
/**
|
|
2437
|
+
* RezoHttpDeleteRequest - Request options for DELETE requests (no request body)
|
|
2438
|
+
* @public - Use with DELETE method
|
|
2439
|
+
*/
|
|
2440
|
+
export type RezoHttpDeleteRequest = Omit<RezoHttpRequest, "data" | "body">;
|
|
2441
|
+
/**
|
|
2442
|
+
* RezoHttpHeadRequest - Request options for HEAD requests (no request body)
|
|
2443
|
+
* @public - Use with HEAD method
|
|
2444
|
+
*/
|
|
2445
|
+
export type RezoHttpHeadRequest = Omit<RezoHttpRequest, "data" | "body">;
|
|
2446
|
+
/**
|
|
2447
|
+
* RezoHttpOptionsRequest - Request options for OPTIONS requests (no request body)
|
|
2448
|
+
* @public - Use with OPTIONS method
|
|
2449
|
+
*/
|
|
2450
|
+
export type RezoHttpOptionsRequest = Omit<RezoHttpRequest, "data" | "body">;
|
|
2451
|
+
/**
|
|
2452
|
+
* RezoRequestOptions - Request configuration type for the .request() method
|
|
2453
|
+
*
|
|
2454
|
+
* This type excludes internal properties and is specifically designed for public API usage.
|
|
2455
|
+
* Use this type when creating reusable request configurations for the .request() method.
|
|
2456
|
+
*
|
|
2457
|
+
* @public - For external use with .request() method only
|
|
2458
|
+
* @internal - Do not use internally within the library
|
|
2459
|
+
*/
|
|
2460
|
+
export type RezoRequestOptions = Omit<RezoRequestConfig, "fullUrl">;
|
|
1975
2461
|
export interface DNSCacheOptions {
|
|
1976
2462
|
enable?: boolean;
|
|
1977
2463
|
ttl?: number;
|
|
1978
2464
|
maxEntries?: number;
|
|
1979
2465
|
}
|
|
2466
|
+
declare class DNSCache {
|
|
2467
|
+
private cache;
|
|
2468
|
+
private enabled;
|
|
2469
|
+
constructor(options?: DNSCacheOptions);
|
|
2470
|
+
private makeKey;
|
|
2471
|
+
lookup(hostname: string, family?: 4 | 6): Promise<{
|
|
2472
|
+
address: string;
|
|
2473
|
+
family: 4 | 6;
|
|
2474
|
+
} | undefined>;
|
|
2475
|
+
lookupAll(hostname: string, family?: 4 | 6): Promise<Array<{
|
|
2476
|
+
address: string;
|
|
2477
|
+
family: 4 | 6;
|
|
2478
|
+
}>>;
|
|
2479
|
+
private resolveDNS;
|
|
2480
|
+
private resolveAllDNS;
|
|
2481
|
+
invalidate(hostname: string): void;
|
|
2482
|
+
clear(): void;
|
|
2483
|
+
get size(): number;
|
|
2484
|
+
get isEnabled(): boolean;
|
|
2485
|
+
setEnabled(enabled: boolean): void;
|
|
2486
|
+
}
|
|
1980
2487
|
export interface ResponseCacheConfig {
|
|
1981
2488
|
enable?: boolean;
|
|
1982
2489
|
cacheDir?: string;
|
|
@@ -1986,6 +2493,201 @@ export interface ResponseCacheConfig {
|
|
|
1986
2493
|
methods?: string[];
|
|
1987
2494
|
respectHeaders?: boolean;
|
|
1988
2495
|
}
|
|
2496
|
+
export type ResponseCacheOption = boolean | ResponseCacheConfig;
|
|
2497
|
+
export interface CachedResponse {
|
|
2498
|
+
status: number;
|
|
2499
|
+
statusText: string;
|
|
2500
|
+
headers: Record<string, string>;
|
|
2501
|
+
data: unknown;
|
|
2502
|
+
url: string;
|
|
2503
|
+
timestamp: number;
|
|
2504
|
+
ttl: number;
|
|
2505
|
+
etag?: string;
|
|
2506
|
+
lastModified?: string;
|
|
2507
|
+
}
|
|
2508
|
+
declare class ResponseCache {
|
|
2509
|
+
private memoryCache;
|
|
2510
|
+
private config;
|
|
2511
|
+
private persistenceEnabled;
|
|
2512
|
+
private initialized;
|
|
2513
|
+
constructor(options?: ResponseCacheOption);
|
|
2514
|
+
private initializePersistence;
|
|
2515
|
+
private initializePersistenceAsync;
|
|
2516
|
+
private getCacheFilePath;
|
|
2517
|
+
private persistToDisk;
|
|
2518
|
+
private loadFromDiskAsync;
|
|
2519
|
+
private generateKey;
|
|
2520
|
+
private parseCacheControl;
|
|
2521
|
+
isCacheable(method: string, status: number, headers?: Record<string, string>): boolean;
|
|
2522
|
+
get(method: string, url: string, headers?: Record<string, string>): CachedResponse | undefined;
|
|
2523
|
+
private loadSingleFromDisk;
|
|
2524
|
+
set(method: string, url: string, response: RezoResponse, requestHeaders?: Record<string, string>): void;
|
|
2525
|
+
private normalizeHeaders;
|
|
2526
|
+
getConditionalHeaders(method: string, url: string, requestHeaders?: Record<string, string>): Record<string, string> | undefined;
|
|
2527
|
+
updateRevalidated(method: string, url: string, newHeaders: Record<string, string>, requestHeaders?: Record<string, string>): CachedResponse | undefined;
|
|
2528
|
+
invalidate(url: string, method?: string): void;
|
|
2529
|
+
clear(): void;
|
|
2530
|
+
get size(): number;
|
|
2531
|
+
get isEnabled(): boolean;
|
|
2532
|
+
get isPersistent(): boolean;
|
|
2533
|
+
getConfig(): ResponseCacheConfig;
|
|
2534
|
+
}
|
|
2535
|
+
type BeforeProxySelectHook$1 = (context: BeforeProxySelectContext) => ProxyInfo | void | Promise<ProxyInfo | void>;
|
|
2536
|
+
type AfterProxySelectHook$1 = (context: AfterProxySelectContext) => void | Promise<void>;
|
|
2537
|
+
type BeforeProxyErrorHook$1 = (context: BeforeProxyErrorContext) => void | Promise<void>;
|
|
2538
|
+
type AfterProxyErrorHook$1 = (context: AfterProxyErrorContext) => void | Promise<void>;
|
|
2539
|
+
type BeforeProxyDisableHook$1 = (context: BeforeProxyDisableContext) => boolean | void | Promise<boolean | void>;
|
|
2540
|
+
type AfterProxyDisableHook$1 = (context: AfterProxyDisableContext) => void | Promise<void>;
|
|
2541
|
+
type AfterProxyRotateHook$1 = (context: AfterProxyRotateContext) => void | Promise<void>;
|
|
2542
|
+
type AfterProxyEnableHook$1 = (context: AfterProxyEnableContext) => void | Promise<void>;
|
|
2543
|
+
/**
|
|
2544
|
+
* Proxy hooks collection for ProxyManager events
|
|
2545
|
+
*/
|
|
2546
|
+
export interface ProxyHooks {
|
|
2547
|
+
beforeProxySelect: BeforeProxySelectHook$1[];
|
|
2548
|
+
afterProxySelect: AfterProxySelectHook$1[];
|
|
2549
|
+
beforeProxyError: BeforeProxyErrorHook$1[];
|
|
2550
|
+
afterProxyError: AfterProxyErrorHook$1[];
|
|
2551
|
+
beforeProxyDisable: BeforeProxyDisableHook$1[];
|
|
2552
|
+
afterProxyDisable: AfterProxyDisableHook$1[];
|
|
2553
|
+
afterProxyRotate: AfterProxyRotateHook$1[];
|
|
2554
|
+
afterProxyEnable: AfterProxyEnableHook$1[];
|
|
2555
|
+
}
|
|
2556
|
+
declare class ProxyManager {
|
|
2557
|
+
/** Configuration for the proxy manager */
|
|
2558
|
+
readonly config: ProxyManagerConfig;
|
|
2559
|
+
/** Internal proxy states map (proxyId -> state) */
|
|
2560
|
+
private states;
|
|
2561
|
+
/** Current index for sequential rotation */
|
|
2562
|
+
private currentIndex;
|
|
2563
|
+
/** Request counter for current proxy (sequential rotation) */
|
|
2564
|
+
private currentProxyRequests;
|
|
2565
|
+
/** Last selected proxy (for rotation tracking) */
|
|
2566
|
+
private lastSelectedProxy;
|
|
2567
|
+
/** Cooldown timers map (proxyId -> timerId) */
|
|
2568
|
+
private cooldownTimers;
|
|
2569
|
+
/** Total requests through manager */
|
|
2570
|
+
private _totalRequests;
|
|
2571
|
+
/** Total successful requests */
|
|
2572
|
+
private _totalSuccesses;
|
|
2573
|
+
/** Total failed requests */
|
|
2574
|
+
private _totalFailures;
|
|
2575
|
+
/** Proxy hooks */
|
|
2576
|
+
hooks: ProxyHooks;
|
|
2577
|
+
/**
|
|
2578
|
+
* Create a new ProxyManager instance
|
|
2579
|
+
* @param config - Proxy manager configuration
|
|
2580
|
+
*/
|
|
2581
|
+
constructor(config: ProxyManagerConfig);
|
|
2582
|
+
/**
|
|
2583
|
+
* Create initial state for a proxy
|
|
2584
|
+
*/
|
|
2585
|
+
private createInitialState;
|
|
2586
|
+
/**
|
|
2587
|
+
* Check if a URL should use proxy based on whitelist/blacklist
|
|
2588
|
+
* @param url - The request URL to check
|
|
2589
|
+
* @returns true if URL should use proxy, false if should go direct
|
|
2590
|
+
*/
|
|
2591
|
+
shouldProxy(url: string): boolean;
|
|
2592
|
+
/**
|
|
2593
|
+
* Match a URL against a pattern
|
|
2594
|
+
*/
|
|
2595
|
+
private matchPattern;
|
|
2596
|
+
/**
|
|
2597
|
+
* Get active proxies (not disabled)
|
|
2598
|
+
*/
|
|
2599
|
+
getActive(): ProxyInfo[];
|
|
2600
|
+
/**
|
|
2601
|
+
* Get disabled proxies
|
|
2602
|
+
*/
|
|
2603
|
+
getDisabled(): ProxyInfo[];
|
|
2604
|
+
/**
|
|
2605
|
+
* Get proxies in cooldown
|
|
2606
|
+
*/
|
|
2607
|
+
getCooldown(): ProxyInfo[];
|
|
2608
|
+
/**
|
|
2609
|
+
* Process expired cooldowns and re-enable proxies
|
|
2610
|
+
*/
|
|
2611
|
+
private processExpiredCooldowns;
|
|
2612
|
+
/**
|
|
2613
|
+
* Get next proxy based on rotation strategy
|
|
2614
|
+
* @param url - The request URL (for whitelist/blacklist checking)
|
|
2615
|
+
* @returns Selected proxy or null if should go direct
|
|
2616
|
+
*/
|
|
2617
|
+
next(url: string): ProxyInfo | null;
|
|
2618
|
+
/**
|
|
2619
|
+
* Get detailed selection result with reason
|
|
2620
|
+
* @param url - The request URL
|
|
2621
|
+
* @returns Selection result with proxy and reason
|
|
2622
|
+
*/
|
|
2623
|
+
select(url: string): ProxySelectionResult;
|
|
2624
|
+
/**
|
|
2625
|
+
* Select proxy based on rotation strategy
|
|
2626
|
+
*/
|
|
2627
|
+
private selectProxy;
|
|
2628
|
+
/**
|
|
2629
|
+
* Report a successful request through a proxy
|
|
2630
|
+
* @param proxy - The proxy that succeeded
|
|
2631
|
+
*/
|
|
2632
|
+
reportSuccess(proxy: ProxyInfo): void;
|
|
2633
|
+
/**
|
|
2634
|
+
* Report a failed request through a proxy
|
|
2635
|
+
* @param proxy - The proxy that failed
|
|
2636
|
+
* @param error - The error that occurred
|
|
2637
|
+
* @param url - Optional URL for hook context
|
|
2638
|
+
*/
|
|
2639
|
+
reportFailure(proxy: ProxyInfo, error: Error, url?: string): void;
|
|
2640
|
+
/**
|
|
2641
|
+
* Disable a proxy from the pool
|
|
2642
|
+
* @param proxy - The proxy to disable
|
|
2643
|
+
* @param reason - Reason for disabling
|
|
2644
|
+
*/
|
|
2645
|
+
disableProxy(proxy: ProxyInfo, reason?: "dead" | "limit-reached" | "manual"): void;
|
|
2646
|
+
/**
|
|
2647
|
+
* Enable a previously disabled proxy
|
|
2648
|
+
* @param proxy - The proxy to enable
|
|
2649
|
+
* @param reason - Reason for enabling
|
|
2650
|
+
*/
|
|
2651
|
+
enableProxy(proxy: ProxyInfo, reason?: "cooldown-expired" | "manual"): void;
|
|
2652
|
+
/**
|
|
2653
|
+
* Add proxies to the pool
|
|
2654
|
+
* @param proxies - Proxies to add
|
|
2655
|
+
*/
|
|
2656
|
+
add(proxies: ProxyInfo | ProxyInfo[]): void;
|
|
2657
|
+
/**
|
|
2658
|
+
* Remove proxies from the pool
|
|
2659
|
+
* @param proxies - Proxies to remove
|
|
2660
|
+
*/
|
|
2661
|
+
remove(proxies: ProxyInfo | ProxyInfo[]): void;
|
|
2662
|
+
/**
|
|
2663
|
+
* Reset all proxies - re-enable all and reset counters
|
|
2664
|
+
*/
|
|
2665
|
+
reset(): void;
|
|
2666
|
+
/**
|
|
2667
|
+
* Get current status of all proxies
|
|
2668
|
+
*/
|
|
2669
|
+
getStatus(): ProxyManagerStatus;
|
|
2670
|
+
/**
|
|
2671
|
+
* Get state for a specific proxy
|
|
2672
|
+
* @param proxy - The proxy to get state for
|
|
2673
|
+
*/
|
|
2674
|
+
getProxyState(proxy: ProxyInfo): ProxyState | undefined;
|
|
2675
|
+
/**
|
|
2676
|
+
* Check if any proxies are available
|
|
2677
|
+
*/
|
|
2678
|
+
hasAvailableProxies(): boolean;
|
|
2679
|
+
/**
|
|
2680
|
+
* Destroy the manager and cleanup timers
|
|
2681
|
+
*/
|
|
2682
|
+
destroy(): void;
|
|
2683
|
+
private runBeforeProxySelectHooksSync;
|
|
2684
|
+
private runAfterProxySelectHooksSync;
|
|
2685
|
+
private runBeforeProxyErrorHooksSync;
|
|
2686
|
+
private runAfterProxyErrorHooksSync;
|
|
2687
|
+
private runAfterProxyRotateHooks;
|
|
2688
|
+
private runAfterProxyDisableHooks;
|
|
2689
|
+
private runAfterProxyEnableHooks;
|
|
2690
|
+
}
|
|
1989
2691
|
export type queueOptions = Options$1<PriorityQueue, QueueAddOptions>;
|
|
1990
2692
|
export interface CacheConfig {
|
|
1991
2693
|
/** Response cache configuration */
|
|
@@ -2112,25 +2814,1052 @@ export interface RezoDefaultOptions {
|
|
|
2112
2814
|
* DNS cache defaults: 1 min TTL, 1000 entries
|
|
2113
2815
|
*/
|
|
2114
2816
|
cache?: CacheOption;
|
|
2817
|
+
/**
|
|
2818
|
+
* Proxy manager for advanced proxy rotation and pool management
|
|
2819
|
+
* - Provide a `ProxyManager` instance for full control
|
|
2820
|
+
* - Or provide `ProxyManagerConfig` to auto-create internally
|
|
2821
|
+
*
|
|
2822
|
+
* Note: ProxyManager overrides `proxy` option when set.
|
|
2823
|
+
* Use `useProxyManager: false` per-request to bypass.
|
|
2824
|
+
*
|
|
2825
|
+
* @example
|
|
2826
|
+
* ```typescript
|
|
2827
|
+
* // With config (auto-creates ProxyManager)
|
|
2828
|
+
* const client = new Rezo({
|
|
2829
|
+
* proxyManager: {
|
|
2830
|
+
* rotation: 'random',
|
|
2831
|
+
* proxies: [
|
|
2832
|
+
* { protocol: 'socks5', host: '127.0.0.1', port: 1080 },
|
|
2833
|
+
* { protocol: 'http', host: 'proxy.example.com', port: 8080 }
|
|
2834
|
+
* ],
|
|
2835
|
+
* whitelist: ['api.example.com'],
|
|
2836
|
+
* autoDisableDeadProxies: true
|
|
2837
|
+
* }
|
|
2838
|
+
* });
|
|
2839
|
+
*
|
|
2840
|
+
* // With ProxyManager instance
|
|
2841
|
+
* const pm = new ProxyManager({ rotation: 'sequential', proxies: [...] });
|
|
2842
|
+
* const client = new Rezo({ proxyManager: pm });
|
|
2843
|
+
* ```
|
|
2844
|
+
*/
|
|
2845
|
+
proxyManager?: ProxyManager | ProxyManagerConfig;
|
|
2846
|
+
}
|
|
2847
|
+
export interface httpAdapterOverloads {
|
|
2848
|
+
request<T = any>(options: RezoRequestOptions): Promise<RezoResponse<T>>;
|
|
2849
|
+
request<T = any>(options: RezoRequestOptions & {
|
|
2850
|
+
responseType: "auto";
|
|
2851
|
+
}): Promise<RezoResponse<T>>;
|
|
2852
|
+
request<T = any>(options: RezoRequestOptions & {
|
|
2853
|
+
responseType: "json";
|
|
2854
|
+
}): Promise<RezoResponse<T>>;
|
|
2855
|
+
request(options: {
|
|
2856
|
+
responseType: "stream";
|
|
2857
|
+
} & RezoRequestOptions): Promise<RezoStreamResponse>;
|
|
2858
|
+
request(options: RezoRequestOptions & {
|
|
2859
|
+
responseType: "arrayBuffer";
|
|
2860
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
2861
|
+
request(options: RezoRequestOptions & {
|
|
2862
|
+
responseType: "buffer";
|
|
2863
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
2864
|
+
request(options: RezoRequestOptions & {
|
|
2865
|
+
responseType: "blob";
|
|
2866
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
2867
|
+
request(options: RezoRequestOptions & {
|
|
2868
|
+
responseType: "text";
|
|
2869
|
+
}): Promise<RezoResponse<string>>;
|
|
2870
|
+
request(options: RezoRequestOptions & {
|
|
2871
|
+
responseType: "download";
|
|
2872
|
+
}): Promise<RezoDownloadResponse>;
|
|
2873
|
+
request(options: RezoRequestOptions & {
|
|
2874
|
+
fileName: string;
|
|
2875
|
+
}): Promise<RezoDownloadResponse>;
|
|
2876
|
+
request(options: RezoRequestOptions & {
|
|
2877
|
+
saveTo: string;
|
|
2878
|
+
}): Promise<RezoDownloadResponse>;
|
|
2879
|
+
request(options: RezoRequestOptions & {
|
|
2880
|
+
responseType: "upload";
|
|
2881
|
+
}): Promise<RezoUploadResponse>;
|
|
2882
|
+
get<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
2883
|
+
get<T = any>(url: string | URL, options?: RezoHttpGetRequest): Promise<RezoResponse<T>>;
|
|
2884
|
+
get<T = any>(url: string | URL, options: RezoHttpGetRequest & {
|
|
2885
|
+
responseType: "auto" | "json";
|
|
2886
|
+
}): Promise<RezoResponse<T>>;
|
|
2887
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2888
|
+
responseType: "stream";
|
|
2889
|
+
}): Promise<RezoStreamResponse>;
|
|
2890
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2891
|
+
responseType: "arrayBuffer";
|
|
2892
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
2893
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2894
|
+
responseType: "buffer";
|
|
2895
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
2896
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2897
|
+
responseType: "blob";
|
|
2898
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
2899
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2900
|
+
responseType: "text";
|
|
2901
|
+
}): Promise<RezoResponse<string>>;
|
|
2902
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2903
|
+
responseType: "download";
|
|
2904
|
+
}): Promise<RezoDownloadResponse>;
|
|
2905
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2906
|
+
fileName: string;
|
|
2907
|
+
}): Promise<RezoDownloadResponse>;
|
|
2908
|
+
get(url: string | URL, options: RezoHttpGetRequest & {
|
|
2909
|
+
saveTo: string;
|
|
2910
|
+
}): Promise<RezoDownloadResponse>;
|
|
2911
|
+
head(url: string | URL): Promise<RezoResponse<null>>;
|
|
2912
|
+
head(url: string | URL, options: RezoHttpHeadRequest): Promise<RezoResponse<null>>;
|
|
2913
|
+
options<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
2914
|
+
options<T = any>(url: string | URL, options: RezoHttpOptionsRequest): Promise<RezoResponse<T>>;
|
|
2915
|
+
trace<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
2916
|
+
trace<T = any>(url: string | URL, options: RezoHttpRequest): Promise<RezoResponse<T>>;
|
|
2917
|
+
delete<T = any>(url: string | URL, options?: RezoHttpDeleteRequest): Promise<RezoResponse<T>>;
|
|
2918
|
+
delete<T = any>(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2919
|
+
responseType: "auto" | "json";
|
|
2920
|
+
}): Promise<RezoResponse<T>>;
|
|
2921
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2922
|
+
responseType: "stream";
|
|
2923
|
+
}): Promise<RezoStreamResponse>;
|
|
2924
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2925
|
+
responseType: "arrayBuffer";
|
|
2926
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
2927
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2928
|
+
responseType: "buffer";
|
|
2929
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
2930
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2931
|
+
responseType: "blob";
|
|
2932
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
2933
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2934
|
+
responseType: "text";
|
|
2935
|
+
}): Promise<RezoResponse<string>>;
|
|
2936
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2937
|
+
responseType: "download";
|
|
2938
|
+
}): Promise<RezoDownloadResponse>;
|
|
2939
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2940
|
+
fileName: string;
|
|
2941
|
+
}): Promise<RezoDownloadResponse>;
|
|
2942
|
+
delete(url: string | URL, options: RezoHttpDeleteRequest & {
|
|
2943
|
+
saveTo: string;
|
|
2944
|
+
}): Promise<RezoDownloadResponse>;
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
* Extended URLSearchParams that supports nested objects and arrays
|
|
2948
|
+
* for application/x-www-form-urlencoded encoding
|
|
2949
|
+
*/
|
|
2950
|
+
export type Primitive = string | number | boolean | null | undefined | Date;
|
|
2951
|
+
export type NestedValue = Primitive | NestedObject | NestedArray;
|
|
2952
|
+
export type NestedObject = {
|
|
2953
|
+
[key: string]: NestedValue;
|
|
2954
|
+
};
|
|
2955
|
+
export type NestedArray = NestedValue[];
|
|
2956
|
+
declare class RezoURLSearchParams extends URLSearchParams {
|
|
2957
|
+
constructor(init?: string | URLSearchParams | NestedObject | string[][] | RezoURLSearchParams);
|
|
2958
|
+
/**
|
|
2959
|
+
* Append a nested object to the search params
|
|
2960
|
+
*/
|
|
2961
|
+
appendObject(obj: NestedObject, prefix?: string): void;
|
|
2962
|
+
/**
|
|
2963
|
+
* Set a value (replacing existing values with the same key)
|
|
2964
|
+
*/
|
|
2965
|
+
setObject(obj: NestedObject, prefix?: string): void;
|
|
2966
|
+
/**
|
|
2967
|
+
* Append a value with proper handling for different types
|
|
2968
|
+
*/
|
|
2969
|
+
private appendValue;
|
|
2970
|
+
/**
|
|
2971
|
+
* Append an array with proper indexing
|
|
2972
|
+
*/
|
|
2973
|
+
private appendArray;
|
|
2974
|
+
/**
|
|
2975
|
+
* Convert to a plain object (useful for debugging)
|
|
2976
|
+
*/
|
|
2977
|
+
toObject(): Record<string, string>;
|
|
2978
|
+
/**
|
|
2979
|
+
* Create from a flat object with bracket notation keys
|
|
2980
|
+
*/
|
|
2981
|
+
static fromFlat(flat: Record<string, string>): RezoURLSearchParams;
|
|
2982
|
+
}
|
|
2983
|
+
export interface httpAdapterPostOverloads {
|
|
2984
|
+
post<T = any>(url: string | URL, data?: any): Promise<RezoResponse<T>>;
|
|
2985
|
+
post<T = any>(url: string | URL, data: any, options?: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
2986
|
+
post<T = any>(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
2987
|
+
responseType: "auto" | "json";
|
|
2988
|
+
}): Promise<RezoResponse<T>>;
|
|
2989
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
2990
|
+
responseType: "stream";
|
|
2991
|
+
}): Promise<RezoStreamResponse>;
|
|
2992
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
2993
|
+
responseType: "arrayBuffer";
|
|
2994
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
2995
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
2996
|
+
responseType: "buffer";
|
|
2997
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
2998
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
2999
|
+
responseType: "blob";
|
|
3000
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3001
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
3002
|
+
responseType: "text";
|
|
3003
|
+
}): Promise<RezoResponse<string>>;
|
|
3004
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
3005
|
+
responseType: "download";
|
|
3006
|
+
}): Promise<RezoDownloadResponse>;
|
|
3007
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
3008
|
+
fileName: string;
|
|
3009
|
+
}): Promise<RezoDownloadResponse>;
|
|
3010
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
3011
|
+
saveTo: string;
|
|
3012
|
+
}): Promise<RezoDownloadResponse>;
|
|
3013
|
+
post(url: string | URL, data: any, options: RezoHttpPostRequest & {
|
|
3014
|
+
responseType: "upload";
|
|
3015
|
+
}): Promise<RezoUploadResponse>;
|
|
3016
|
+
postJson<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
3017
|
+
postJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>): Promise<RezoResponse<T>>;
|
|
3018
|
+
postJson<T = any>(url: string | URL, jsonString: string): Promise<RezoResponse<T>>;
|
|
3019
|
+
postJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3020
|
+
postJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3021
|
+
postJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3022
|
+
postJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
|
|
3023
|
+
responseType: "auto" | "json";
|
|
3024
|
+
}): Promise<RezoResponse<T>>;
|
|
3025
|
+
postJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
|
|
3026
|
+
responseType: "auto" | "json";
|
|
3027
|
+
}): Promise<RezoResponse<T>>;
|
|
3028
|
+
postJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3029
|
+
responseType: "auto" | "json";
|
|
3030
|
+
}): Promise<RezoResponse<T>>;
|
|
3031
|
+
postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
|
|
3032
|
+
responseType: "text";
|
|
3033
|
+
}): Promise<RezoResponse<string>>;
|
|
3034
|
+
postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
|
|
3035
|
+
responseType: "text";
|
|
3036
|
+
}): Promise<RezoResponse<string>>;
|
|
3037
|
+
postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3038
|
+
responseType: "text";
|
|
3039
|
+
}): Promise<RezoResponse<string>>;
|
|
3040
|
+
postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
|
|
3041
|
+
responseType: "arrayBuffer";
|
|
3042
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3043
|
+
postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
|
|
3044
|
+
responseType: "arrayBuffer";
|
|
3045
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3046
|
+
postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3047
|
+
responseType: "arrayBuffer";
|
|
3048
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3049
|
+
postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
|
|
3050
|
+
responseType: "buffer";
|
|
3051
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3052
|
+
postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
|
|
3053
|
+
responseType: "buffer";
|
|
3054
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3055
|
+
postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3056
|
+
responseType: "buffer";
|
|
3057
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3058
|
+
postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
|
|
3059
|
+
responseType: "blob";
|
|
3060
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3061
|
+
postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
|
|
3062
|
+
responseType: "blob";
|
|
3063
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3064
|
+
postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3065
|
+
responseType: "blob";
|
|
3066
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3067
|
+
postJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPostRequest & {
|
|
3068
|
+
responseType: "stream";
|
|
3069
|
+
}): Promise<RezoStreamResponse>;
|
|
3070
|
+
postJson(url: string | URL, jsonString: string, options: RezoHttpPostRequest & {
|
|
3071
|
+
responseType: "stream";
|
|
3072
|
+
}): Promise<RezoStreamResponse>;
|
|
3073
|
+
postJson(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3074
|
+
responseType: "stream";
|
|
3075
|
+
}): Promise<RezoStreamResponse>;
|
|
3076
|
+
postForm<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
3077
|
+
postForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>): Promise<RezoResponse<T>>;
|
|
3078
|
+
postForm<T = any>(url: string | URL, string: string): Promise<RezoResponse<T>>;
|
|
3079
|
+
postForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3080
|
+
postForm<T = any>(url: string | URL, string: string, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3081
|
+
postForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3082
|
+
postForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
|
|
3083
|
+
responseType: "auto" | "json";
|
|
3084
|
+
}): Promise<RezoResponse<T>>;
|
|
3085
|
+
postForm<T = any>(url: string | URL, string: string, options: RezoHttpPostRequest & {
|
|
3086
|
+
responseType: "auto" | "json";
|
|
3087
|
+
}): Promise<RezoResponse<T>>;
|
|
3088
|
+
postForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3089
|
+
responseType: "auto" | "json";
|
|
3090
|
+
}): Promise<RezoResponse<T>>;
|
|
3091
|
+
postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
|
|
3092
|
+
responseType: "text";
|
|
3093
|
+
}): Promise<RezoResponse<string>>;
|
|
3094
|
+
postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
|
|
3095
|
+
responseType: "text";
|
|
3096
|
+
}): Promise<RezoResponse<string>>;
|
|
3097
|
+
postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3098
|
+
responseType: "text";
|
|
3099
|
+
}): Promise<RezoResponse<string>>;
|
|
3100
|
+
postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
|
|
3101
|
+
responseType: "arrayBuffer";
|
|
3102
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3103
|
+
postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
|
|
3104
|
+
responseType: "arrayBuffer";
|
|
3105
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3106
|
+
postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3107
|
+
responseType: "arrayBuffer";
|
|
3108
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3109
|
+
postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
|
|
3110
|
+
responseType: "buffer";
|
|
3111
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3112
|
+
postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
|
|
3113
|
+
responseType: "buffer";
|
|
3114
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3115
|
+
postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3116
|
+
responseType: "buffer";
|
|
3117
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3118
|
+
postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
|
|
3119
|
+
responseType: "blob";
|
|
3120
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3121
|
+
postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
|
|
3122
|
+
responseType: "blob";
|
|
3123
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3124
|
+
postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3125
|
+
responseType: "blob";
|
|
3126
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3127
|
+
postForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPostRequest & {
|
|
3128
|
+
responseType: "stream";
|
|
3129
|
+
}): Promise<RezoStreamResponse>;
|
|
3130
|
+
postForm(url: string | URL, string: string, options: RezoHttpPostRequest & {
|
|
3131
|
+
responseType: "stream";
|
|
3132
|
+
}): Promise<RezoStreamResponse>;
|
|
3133
|
+
postForm(url: string | URL, nullData: null | undefined, options: RezoHttpPostRequest & {
|
|
3134
|
+
responseType: "stream";
|
|
3135
|
+
}): Promise<RezoStreamResponse>;
|
|
3136
|
+
postMultipart<T = any>(url: string | URL, formData: RezoFormData): Promise<RezoResponse<T>>;
|
|
3137
|
+
postMultipart<T = any>(url: string | URL, formData: FormData): Promise<RezoResponse<T>>;
|
|
3138
|
+
postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>): Promise<RezoResponse<T>>;
|
|
3139
|
+
postMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3140
|
+
postMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3141
|
+
postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest): Promise<RezoResponse<T>>;
|
|
3142
|
+
postMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3143
|
+
responseType: "auto";
|
|
3144
|
+
}): Promise<RezoResponse<T>>;
|
|
3145
|
+
postMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3146
|
+
responseType: "auto";
|
|
3147
|
+
}): Promise<RezoResponse<T>>;
|
|
3148
|
+
postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3149
|
+
responseType: "auto";
|
|
3150
|
+
}): Promise<RezoResponse<T>>;
|
|
3151
|
+
postMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3152
|
+
responseType: "json";
|
|
3153
|
+
}): Promise<RezoResponse<T>>;
|
|
3154
|
+
postMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3155
|
+
responseType: "json";
|
|
3156
|
+
}): Promise<RezoResponse<T>>;
|
|
3157
|
+
postMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3158
|
+
responseType: "json";
|
|
3159
|
+
}): Promise<RezoResponse<T>>;
|
|
3160
|
+
postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3161
|
+
responseType: "text";
|
|
3162
|
+
}): Promise<RezoResponse<string>>;
|
|
3163
|
+
postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3164
|
+
responseType: "text";
|
|
3165
|
+
}): Promise<RezoResponse<string>>;
|
|
3166
|
+
postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3167
|
+
responseType: "text";
|
|
3168
|
+
}): Promise<RezoResponse<string>>;
|
|
3169
|
+
postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3170
|
+
responseType: "stream";
|
|
3171
|
+
}): Promise<RezoStreamResponse>;
|
|
3172
|
+
postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3173
|
+
responseType: "stream";
|
|
3174
|
+
}): Promise<RezoStreamResponse>;
|
|
3175
|
+
postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3176
|
+
responseType: "stream";
|
|
3177
|
+
}): Promise<RezoStreamResponse>;
|
|
3178
|
+
postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3179
|
+
responseType: "arrayBuffer";
|
|
3180
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3181
|
+
postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3182
|
+
responseType: "arrayBuffer";
|
|
3183
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3184
|
+
postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3185
|
+
responseType: "arrayBuffer";
|
|
3186
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3187
|
+
postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3188
|
+
responseType: "buffer";
|
|
3189
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3190
|
+
postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3191
|
+
responseType: "buffer";
|
|
3192
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3193
|
+
postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3194
|
+
responseType: "buffer";
|
|
3195
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3196
|
+
postMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPostRequest & {
|
|
3197
|
+
responseType: "blob";
|
|
3198
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3199
|
+
postMultipart(url: string | URL, formData: FormData, options: RezoHttpPostRequest & {
|
|
3200
|
+
responseType: "blob";
|
|
3201
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3202
|
+
postMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPostRequest & {
|
|
3203
|
+
responseType: "blob";
|
|
3204
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3205
|
+
}
|
|
3206
|
+
export interface httpAdapterPatchOverloads {
|
|
3207
|
+
patch<T = any>(url: string | URL, data?: any): Promise<RezoResponse<T>>;
|
|
3208
|
+
patch<T = any>(url: string | URL, data: any, options?: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3209
|
+
patch<T = any>(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3210
|
+
responseType: "auto" | "json";
|
|
3211
|
+
}): Promise<RezoResponse<T>>;
|
|
3212
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3213
|
+
responseType: "stream";
|
|
3214
|
+
}): RezoStreamResponse;
|
|
3215
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3216
|
+
responseType: "arrayBuffer";
|
|
3217
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3218
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3219
|
+
responseType: "buffer";
|
|
3220
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3221
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3222
|
+
responseType: "blob";
|
|
3223
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3224
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3225
|
+
responseType: "text";
|
|
3226
|
+
}): Promise<RezoResponse<string>>;
|
|
3227
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3228
|
+
responseType: "download";
|
|
3229
|
+
}): RezoDownloadResponse;
|
|
3230
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3231
|
+
fileName: string;
|
|
3232
|
+
}): RezoDownloadResponse;
|
|
3233
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3234
|
+
saveTo: string;
|
|
3235
|
+
}): RezoDownloadResponse;
|
|
3236
|
+
patch(url: string | URL, data: any, options: RezoHttpPatchRequest & {
|
|
3237
|
+
responseType: "upload";
|
|
3238
|
+
}): Promise<RezoUploadResponse>;
|
|
3239
|
+
patchJson<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
3240
|
+
patchJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>): Promise<RezoResponse<T>>;
|
|
3241
|
+
patchJson<T = any>(url: string | URL, jsonString: string): Promise<RezoResponse<T>>;
|
|
3242
|
+
patchJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3243
|
+
patchJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3244
|
+
patchJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3245
|
+
patchJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3246
|
+
responseType: "auto" | "json";
|
|
3247
|
+
}): Promise<RezoResponse<T>>;
|
|
3248
|
+
patchJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3249
|
+
responseType: "auto" | "json";
|
|
3250
|
+
}): Promise<RezoResponse<T>>;
|
|
3251
|
+
patchJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3252
|
+
responseType: "auto" | "json";
|
|
3253
|
+
}): Promise<RezoResponse<T>>;
|
|
3254
|
+
patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3255
|
+
responseType: "text";
|
|
3256
|
+
}): Promise<RezoResponse<string>>;
|
|
3257
|
+
patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3258
|
+
responseType: "text";
|
|
3259
|
+
}): Promise<RezoResponse<string>>;
|
|
3260
|
+
patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3261
|
+
responseType: "text";
|
|
3262
|
+
}): Promise<RezoResponse<string>>;
|
|
3263
|
+
patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3264
|
+
responseType: "arrayBuffer";
|
|
3265
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3266
|
+
patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3267
|
+
responseType: "arrayBuffer";
|
|
3268
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3269
|
+
patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3270
|
+
responseType: "arrayBuffer";
|
|
3271
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3272
|
+
patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3273
|
+
responseType: "buffer";
|
|
3274
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3275
|
+
patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3276
|
+
responseType: "buffer";
|
|
3277
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3278
|
+
patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3279
|
+
responseType: "buffer";
|
|
3280
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3281
|
+
patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3282
|
+
responseType: "blob";
|
|
3283
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3284
|
+
patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3285
|
+
responseType: "blob";
|
|
3286
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3287
|
+
patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3288
|
+
responseType: "blob";
|
|
3289
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3290
|
+
patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3291
|
+
responseType: "stream";
|
|
3292
|
+
}): RezoStreamResponse;
|
|
3293
|
+
patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3294
|
+
responseType: "stream";
|
|
3295
|
+
}): RezoStreamResponse;
|
|
3296
|
+
patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3297
|
+
responseType: "stream";
|
|
3298
|
+
}): RezoStreamResponse;
|
|
3299
|
+
patchJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPatchRequest & {
|
|
3300
|
+
responseType: "upload";
|
|
3301
|
+
}): Promise<RezoUploadResponse>;
|
|
3302
|
+
patchJson(url: string | URL, jsonString: string, options: RezoHttpPatchRequest & {
|
|
3303
|
+
responseType: "upload";
|
|
3304
|
+
}): Promise<RezoUploadResponse>;
|
|
3305
|
+
patchJson(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3306
|
+
responseType: "upload";
|
|
3307
|
+
}): Promise<RezoUploadResponse>;
|
|
3308
|
+
patchForm<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
3309
|
+
patchForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>): Promise<RezoResponse<T>>;
|
|
3310
|
+
patchForm<T = any>(url: string | URL, string: string): Promise<RezoResponse<T>>;
|
|
3311
|
+
patchForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3312
|
+
patchForm<T = any>(url: string | URL, string: string, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3313
|
+
patchForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3314
|
+
patchForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3315
|
+
responseType: "auto" | "json";
|
|
3316
|
+
}): Promise<RezoResponse<T>>;
|
|
3317
|
+
patchForm<T = any>(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3318
|
+
responseType: "auto" | "json";
|
|
3319
|
+
}): Promise<RezoResponse<T>>;
|
|
3320
|
+
patchForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3321
|
+
responseType: "auto" | "json";
|
|
3322
|
+
}): Promise<RezoResponse<T>>;
|
|
3323
|
+
patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3324
|
+
responseType: "text";
|
|
3325
|
+
}): Promise<RezoResponse<string>>;
|
|
3326
|
+
patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3327
|
+
responseType: "text";
|
|
3328
|
+
}): Promise<RezoResponse<string>>;
|
|
3329
|
+
patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3330
|
+
responseType: "text";
|
|
3331
|
+
}): Promise<RezoResponse<string>>;
|
|
3332
|
+
patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3333
|
+
responseType: "arrayBuffer";
|
|
3334
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3335
|
+
patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3336
|
+
responseType: "arrayBuffer";
|
|
3337
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3338
|
+
patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3339
|
+
responseType: "arrayBuffer";
|
|
3340
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3341
|
+
patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3342
|
+
responseType: "buffer";
|
|
3343
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3344
|
+
patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3345
|
+
responseType: "buffer";
|
|
3346
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3347
|
+
patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3348
|
+
responseType: "buffer";
|
|
3349
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3350
|
+
patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3351
|
+
responseType: "blob";
|
|
3352
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3353
|
+
patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3354
|
+
responseType: "blob";
|
|
3355
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3356
|
+
patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3357
|
+
responseType: "blob";
|
|
3358
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3359
|
+
patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3360
|
+
responseType: "stream";
|
|
3361
|
+
}): RezoStreamResponse;
|
|
3362
|
+
patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3363
|
+
responseType: "stream";
|
|
3364
|
+
}): RezoStreamResponse;
|
|
3365
|
+
patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3366
|
+
responseType: "stream";
|
|
3367
|
+
}): RezoStreamResponse;
|
|
3368
|
+
patchForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3369
|
+
responseType: "upload";
|
|
3370
|
+
}): Promise<RezoUploadResponse>;
|
|
3371
|
+
patchForm(url: string | URL, string: string, options: RezoHttpPatchRequest & {
|
|
3372
|
+
responseType: "upload";
|
|
3373
|
+
}): Promise<RezoUploadResponse>;
|
|
3374
|
+
patchForm(url: string | URL, nullData: null | undefined, options: RezoHttpPatchRequest & {
|
|
3375
|
+
responseType: "upload";
|
|
3376
|
+
}): Promise<RezoUploadResponse>;
|
|
3377
|
+
patchMultipart<T = any>(url: string | URL, formData: RezoFormData): Promise<RezoResponse<T>>;
|
|
3378
|
+
patchMultipart<T = any>(url: string | URL, formData: FormData): Promise<RezoResponse<T>>;
|
|
3379
|
+
patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>): Promise<RezoResponse<T>>;
|
|
3380
|
+
patchMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3381
|
+
patchMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3382
|
+
patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest): Promise<RezoResponse<T>>;
|
|
3383
|
+
patchMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3384
|
+
responseType: "auto" | "json";
|
|
3385
|
+
}): Promise<RezoResponse<T>>;
|
|
3386
|
+
patchMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3387
|
+
responseType: "auto" | "json";
|
|
3388
|
+
}): Promise<RezoResponse<T>>;
|
|
3389
|
+
patchMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3390
|
+
responseType: "auto" | "json";
|
|
3391
|
+
}): Promise<RezoResponse<T>>;
|
|
3392
|
+
patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3393
|
+
responseType: "text";
|
|
3394
|
+
}): Promise<RezoResponse<string>>;
|
|
3395
|
+
patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3396
|
+
responseType: "text";
|
|
3397
|
+
}): Promise<RezoResponse<string>>;
|
|
3398
|
+
patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3399
|
+
responseType: "text";
|
|
3400
|
+
}): Promise<RezoResponse<string>>;
|
|
3401
|
+
patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3402
|
+
responseType: "stream";
|
|
3403
|
+
}): RezoStreamResponse;
|
|
3404
|
+
patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3405
|
+
responseType: "stream";
|
|
3406
|
+
}): RezoStreamResponse;
|
|
3407
|
+
patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3408
|
+
responseType: "stream";
|
|
3409
|
+
}): RezoStreamResponse;
|
|
3410
|
+
patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3411
|
+
responseType: "arrayBuffer";
|
|
3412
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3413
|
+
patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3414
|
+
responseType: "arrayBuffer";
|
|
3415
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3416
|
+
patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3417
|
+
responseType: "arrayBuffer";
|
|
3418
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3419
|
+
patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3420
|
+
responseType: "buffer";
|
|
3421
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3422
|
+
patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3423
|
+
responseType: "buffer";
|
|
3424
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3425
|
+
patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3426
|
+
responseType: "buffer";
|
|
3427
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3428
|
+
patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3429
|
+
responseType: "blob";
|
|
3430
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3431
|
+
patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3432
|
+
responseType: "blob";
|
|
3433
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3434
|
+
patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3435
|
+
responseType: "blob";
|
|
3436
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3437
|
+
patchMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPatchRequest & {
|
|
3438
|
+
responseType: "upload";
|
|
3439
|
+
}): Promise<RezoUploadResponse>;
|
|
3440
|
+
patchMultipart(url: string | URL, formData: FormData, options: RezoHttpPatchRequest & {
|
|
3441
|
+
responseType: "upload";
|
|
3442
|
+
}): Promise<RezoUploadResponse>;
|
|
3443
|
+
patchMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPatchRequest & {
|
|
3444
|
+
responseType: "upload";
|
|
3445
|
+
}): Promise<RezoUploadResponse>;
|
|
3446
|
+
}
|
|
3447
|
+
export interface httpAdapterPutOverloads {
|
|
3448
|
+
put<T = any>(url: string | URL, data?: any): Promise<RezoResponse<T>>;
|
|
3449
|
+
put<T = any>(url: string | URL, data: any, options?: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3450
|
+
put<T = any>(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3451
|
+
responseType: "auto" | "json";
|
|
3452
|
+
}): Promise<RezoResponse<T>>;
|
|
3453
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3454
|
+
responseType: "stream";
|
|
3455
|
+
}): RezoStreamResponse;
|
|
3456
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3457
|
+
responseType: "arrayBuffer";
|
|
3458
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3459
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3460
|
+
responseType: "buffer";
|
|
3461
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3462
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3463
|
+
responseType: "blob";
|
|
3464
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3465
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3466
|
+
responseType: "text";
|
|
3467
|
+
}): Promise<RezoResponse<string>>;
|
|
3468
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3469
|
+
responseType: "download";
|
|
3470
|
+
}): RezoDownloadResponse;
|
|
3471
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3472
|
+
fileName: string;
|
|
3473
|
+
}): RezoDownloadResponse;
|
|
3474
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3475
|
+
saveTo: string;
|
|
3476
|
+
}): RezoDownloadResponse;
|
|
3477
|
+
put(url: string | URL, data: any, options: RezoHttpPutRequest & {
|
|
3478
|
+
responseType: "upload";
|
|
3479
|
+
}): Promise<RezoUploadResponse>;
|
|
3480
|
+
putJson<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
3481
|
+
putJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>): Promise<RezoResponse<T>>;
|
|
3482
|
+
putJson<T = any>(url: string | URL, jsonString: string): Promise<RezoResponse<T>>;
|
|
3483
|
+
putJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3484
|
+
putJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3485
|
+
putJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3486
|
+
putJson<T = any>(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3487
|
+
responseType: "auto" | "json";
|
|
3488
|
+
}): Promise<RezoResponse<T>>;
|
|
3489
|
+
putJson<T = any>(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3490
|
+
responseType: "auto" | "json";
|
|
3491
|
+
}): Promise<RezoResponse<T>>;
|
|
3492
|
+
putJson<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3493
|
+
responseType: "auto" | "json";
|
|
3494
|
+
}): Promise<RezoResponse<T>>;
|
|
3495
|
+
putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3496
|
+
responseType: "text";
|
|
3497
|
+
}): Promise<RezoResponse<string>>;
|
|
3498
|
+
putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3499
|
+
responseType: "text";
|
|
3500
|
+
}): Promise<RezoResponse<string>>;
|
|
3501
|
+
putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3502
|
+
responseType: "text";
|
|
3503
|
+
}): Promise<RezoResponse<string>>;
|
|
3504
|
+
putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3505
|
+
responseType: "arrayBuffer";
|
|
3506
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3507
|
+
putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3508
|
+
responseType: "arrayBuffer";
|
|
3509
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3510
|
+
putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3511
|
+
responseType: "arrayBuffer";
|
|
3512
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3513
|
+
putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3514
|
+
responseType: "buffer";
|
|
3515
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3516
|
+
putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3517
|
+
responseType: "buffer";
|
|
3518
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3519
|
+
putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3520
|
+
responseType: "buffer";
|
|
3521
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3522
|
+
putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3523
|
+
responseType: "blob";
|
|
3524
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3525
|
+
putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3526
|
+
responseType: "blob";
|
|
3527
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3528
|
+
putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3529
|
+
responseType: "blob";
|
|
3530
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3531
|
+
putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3532
|
+
responseType: "stream";
|
|
3533
|
+
}): RezoStreamResponse;
|
|
3534
|
+
putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3535
|
+
responseType: "stream";
|
|
3536
|
+
}): RezoStreamResponse;
|
|
3537
|
+
putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3538
|
+
responseType: "stream";
|
|
3539
|
+
}): RezoStreamResponse;
|
|
3540
|
+
putJson(url: string | URL, data: Record<any, any> | Array<any>, options: RezoHttpPutRequest & {
|
|
3541
|
+
responseType: "upload";
|
|
3542
|
+
}): Promise<RezoUploadResponse>;
|
|
3543
|
+
putJson(url: string | URL, jsonString: string, options: RezoHttpPutRequest & {
|
|
3544
|
+
responseType: "upload";
|
|
3545
|
+
}): Promise<RezoUploadResponse>;
|
|
3546
|
+
putJson(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3547
|
+
responseType: "upload";
|
|
3548
|
+
}): Promise<RezoUploadResponse>;
|
|
3549
|
+
putForm<T = any>(url: string | URL): Promise<RezoResponse<T>>;
|
|
3550
|
+
putForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>): Promise<RezoResponse<T>>;
|
|
3551
|
+
putForm<T = any>(url: string | URL, string: string): Promise<RezoResponse<T>>;
|
|
3552
|
+
putForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3553
|
+
putForm<T = any>(url: string | URL, string: string, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3554
|
+
putForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3555
|
+
putForm<T = any>(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3556
|
+
responseType: "auto" | "json";
|
|
3557
|
+
}): Promise<RezoResponse<T>>;
|
|
3558
|
+
putForm<T = any>(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3559
|
+
responseType: "auto" | "json";
|
|
3560
|
+
}): Promise<RezoResponse<T>>;
|
|
3561
|
+
putForm<T = any>(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3562
|
+
responseType: "auto" | "json";
|
|
3563
|
+
}): Promise<RezoResponse<T>>;
|
|
3564
|
+
putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3565
|
+
responseType: "text";
|
|
3566
|
+
}): Promise<RezoResponse<string>>;
|
|
3567
|
+
putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3568
|
+
responseType: "text";
|
|
3569
|
+
}): Promise<RezoResponse<string>>;
|
|
3570
|
+
putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3571
|
+
responseType: "text";
|
|
3572
|
+
}): Promise<RezoResponse<string>>;
|
|
3573
|
+
putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3574
|
+
responseType: "arrayBuffer";
|
|
3575
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3576
|
+
putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3577
|
+
responseType: "arrayBuffer";
|
|
3578
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3579
|
+
putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3580
|
+
responseType: "arrayBuffer";
|
|
3581
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3582
|
+
putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3583
|
+
responseType: "buffer";
|
|
3584
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3585
|
+
putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3586
|
+
responseType: "buffer";
|
|
3587
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3588
|
+
putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3589
|
+
responseType: "buffer";
|
|
3590
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3591
|
+
putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3592
|
+
responseType: "blob";
|
|
3593
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3594
|
+
putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3595
|
+
responseType: "blob";
|
|
3596
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3597
|
+
putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3598
|
+
responseType: "blob";
|
|
3599
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3600
|
+
putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3601
|
+
responseType: "stream";
|
|
3602
|
+
}): RezoStreamResponse;
|
|
3603
|
+
putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3604
|
+
responseType: "stream";
|
|
3605
|
+
}): RezoStreamResponse;
|
|
3606
|
+
putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3607
|
+
responseType: "stream";
|
|
3608
|
+
}): RezoStreamResponse;
|
|
3609
|
+
putForm(url: string | URL, data: URLSearchParams | RezoURLSearchParams | Record<string, any>, options: RezoHttpPutRequest & {
|
|
3610
|
+
responseType: "upload";
|
|
3611
|
+
}): Promise<RezoUploadResponse>;
|
|
3612
|
+
putForm(url: string | URL, string: string, options: RezoHttpPutRequest & {
|
|
3613
|
+
responseType: "upload";
|
|
3614
|
+
}): Promise<RezoUploadResponse>;
|
|
3615
|
+
putForm(url: string | URL, nullData: null | undefined, options: RezoHttpPutRequest & {
|
|
3616
|
+
responseType: "upload";
|
|
3617
|
+
}): Promise<RezoUploadResponse>;
|
|
3618
|
+
putMultipart<T = any>(url: string | URL, formData: RezoFormData): Promise<RezoResponse<T>>;
|
|
3619
|
+
putMultipart<T = any>(url: string | URL, formData: FormData): Promise<RezoResponse<T>>;
|
|
3620
|
+
putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>): Promise<RezoResponse<T>>;
|
|
3621
|
+
putMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3622
|
+
putMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3623
|
+
putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest): Promise<RezoResponse<T>>;
|
|
3624
|
+
putMultipart<T = any>(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3625
|
+
responseType: "auto" | "json";
|
|
3626
|
+
}): Promise<RezoResponse<T>>;
|
|
3627
|
+
putMultipart<T = any>(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3628
|
+
responseType: "auto" | "json";
|
|
3629
|
+
}): Promise<RezoResponse<T>>;
|
|
3630
|
+
putMultipart<T = any>(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3631
|
+
responseType: "auto" | "json";
|
|
3632
|
+
}): Promise<RezoResponse<T>>;
|
|
3633
|
+
putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3634
|
+
responseType: "text";
|
|
3635
|
+
}): Promise<RezoResponse<string>>;
|
|
3636
|
+
putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3637
|
+
responseType: "text";
|
|
3638
|
+
}): Promise<RezoResponse<string>>;
|
|
3639
|
+
putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3640
|
+
responseType: "text";
|
|
3641
|
+
}): Promise<RezoResponse<string>>;
|
|
3642
|
+
putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3643
|
+
responseType: "stream";
|
|
3644
|
+
}): RezoStreamResponse;
|
|
3645
|
+
putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3646
|
+
responseType: "stream";
|
|
3647
|
+
}): RezoStreamResponse;
|
|
3648
|
+
putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3649
|
+
responseType: "stream";
|
|
3650
|
+
}): RezoStreamResponse;
|
|
3651
|
+
putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3652
|
+
responseType: "arrayBuffer";
|
|
3653
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3654
|
+
putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3655
|
+
responseType: "arrayBuffer";
|
|
3656
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3657
|
+
putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3658
|
+
responseType: "arrayBuffer";
|
|
3659
|
+
}): Promise<RezoResponse<ArrayBuffer>>;
|
|
3660
|
+
putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3661
|
+
responseType: "buffer";
|
|
3662
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3663
|
+
putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3664
|
+
responseType: "buffer";
|
|
3665
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3666
|
+
putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3667
|
+
responseType: "buffer";
|
|
3668
|
+
}): Promise<RezoResponse<Buffer>>;
|
|
3669
|
+
putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3670
|
+
responseType: "blob";
|
|
3671
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3672
|
+
putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3673
|
+
responseType: "blob";
|
|
3674
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3675
|
+
putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3676
|
+
responseType: "blob";
|
|
3677
|
+
}): Promise<RezoResponse<Blob$1>>;
|
|
3678
|
+
putMultipart(url: string | URL, formData: RezoFormData, options: RezoHttpPutRequest & {
|
|
3679
|
+
responseType: "upload";
|
|
3680
|
+
}): Promise<RezoUploadResponse>;
|
|
3681
|
+
putMultipart(url: string | URL, formData: FormData, options: RezoHttpPutRequest & {
|
|
3682
|
+
responseType: "upload";
|
|
3683
|
+
}): Promise<RezoUploadResponse>;
|
|
3684
|
+
putMultipart(url: string | URL, dataObject: Record<string, any>, options: RezoHttpPutRequest & {
|
|
3685
|
+
responseType: "upload";
|
|
3686
|
+
}): Promise<RezoUploadResponse>;
|
|
2115
3687
|
}
|
|
2116
3688
|
/**
|
|
2117
|
-
*
|
|
2118
|
-
* Follows the same pattern as http.ts executeRequest
|
|
3689
|
+
* Adapter function type - all adapters must implement this signature
|
|
2119
3690
|
*/
|
|
2120
|
-
|
|
3691
|
+
export type AdapterFunction<T = any> = (options: RezoRequestConfig, defaultOptions: RezoDefaultOptions, jar: RezoCookieJar) => Promise<RezoResponse<T> | RezoStreamResponse | RezoDownloadResponse | RezoUploadResponse>;
|
|
2121
3692
|
/**
|
|
2122
|
-
*
|
|
3693
|
+
* Main Rezo class - Enterprise-grade HTTP client with advanced features
|
|
2123
3694
|
*/
|
|
2124
|
-
declare
|
|
3695
|
+
export declare class Rezo {
|
|
3696
|
+
protected queue: PQueue | null;
|
|
3697
|
+
protected isQueueEnabled: boolean;
|
|
3698
|
+
defaults: RezoDefaultOptions;
|
|
3699
|
+
hooks: RezoHooks;
|
|
3700
|
+
private jar;
|
|
3701
|
+
/** Session ID persists across all requests from this instance */
|
|
3702
|
+
readonly sessionId: string;
|
|
3703
|
+
/** Response cache for caching HTTP responses */
|
|
3704
|
+
readonly responseCache?: ResponseCache;
|
|
3705
|
+
/** DNS cache for caching DNS lookups */
|
|
3706
|
+
readonly dnsCache?: DNSCache;
|
|
3707
|
+
/** The adapter function used for HTTP requests */
|
|
3708
|
+
private readonly adapter;
|
|
3709
|
+
/** Proxy manager for advanced proxy rotation and pool management */
|
|
3710
|
+
private readonly _proxyManager;
|
|
3711
|
+
constructor(config?: RezoDefaultOptions, adapter?: AdapterFunction);
|
|
3712
|
+
/**
|
|
3713
|
+
* Get the ProxyManager instance (if configured)
|
|
3714
|
+
* @returns ProxyManager instance or null
|
|
3715
|
+
*/
|
|
3716
|
+
get proxyManager(): ProxyManager | null;
|
|
3717
|
+
/**
|
|
3718
|
+
* Clear all caches (response and DNS)
|
|
3719
|
+
*/
|
|
3720
|
+
clearCache(): void;
|
|
3721
|
+
/**
|
|
3722
|
+
* Invalidate cached response for a specific URL
|
|
3723
|
+
*/
|
|
3724
|
+
invalidateCache(url: string, method?: string): void;
|
|
3725
|
+
/**
|
|
3726
|
+
* Get cache statistics
|
|
3727
|
+
*/
|
|
3728
|
+
getCacheStats(): {
|
|
3729
|
+
response?: {
|
|
3730
|
+
size: number;
|
|
3731
|
+
enabled: boolean;
|
|
3732
|
+
persistent: boolean;
|
|
3733
|
+
};
|
|
3734
|
+
dns?: {
|
|
3735
|
+
size: number;
|
|
3736
|
+
enabled: boolean;
|
|
3737
|
+
};
|
|
3738
|
+
};
|
|
3739
|
+
get: httpAdapterOverloads["get"];
|
|
3740
|
+
head: httpAdapterOverloads["head"];
|
|
3741
|
+
options: httpAdapterOverloads["options"];
|
|
3742
|
+
trace: httpAdapterOverloads["trace"];
|
|
3743
|
+
delete: httpAdapterOverloads["delete"];
|
|
3744
|
+
request: httpAdapterOverloads["request"];
|
|
3745
|
+
post: httpAdapterPostOverloads["post"];
|
|
3746
|
+
postJson: httpAdapterPostOverloads["postJson"];
|
|
3747
|
+
postForm: httpAdapterPostOverloads["postForm"];
|
|
3748
|
+
postMultipart: httpAdapterPostOverloads["postMultipart"];
|
|
3749
|
+
put: httpAdapterPutOverloads["put"];
|
|
3750
|
+
putJson: httpAdapterPutOverloads["putJson"];
|
|
3751
|
+
putForm: httpAdapterPutOverloads["putForm"];
|
|
3752
|
+
putMultipart: httpAdapterPutOverloads["putMultipart"];
|
|
3753
|
+
patch: httpAdapterPatchOverloads["patch"];
|
|
3754
|
+
patchJson: httpAdapterPatchOverloads["patchJson"];
|
|
3755
|
+
patchForm: httpAdapterPatchOverloads["patchForm"];
|
|
3756
|
+
patchMultipart: httpAdapterPatchOverloads["patchMultipart"];
|
|
3757
|
+
private executeRequest;
|
|
3758
|
+
private buildFullUrl;
|
|
3759
|
+
private isvalidJson;
|
|
3760
|
+
private __create;
|
|
3761
|
+
/** Get the cookie jar for this instance */
|
|
3762
|
+
get cookieJar(): RezoCookieJar;
|
|
3763
|
+
/**
|
|
3764
|
+
* Save cookies to file (if cookieFile is configured).
|
|
3765
|
+
* Can also specify a different path to save to.
|
|
3766
|
+
*/
|
|
3767
|
+
saveCookies(filePath?: string): void;
|
|
3768
|
+
/**
|
|
3769
|
+
* Stream a resource - returns immediately with StreamResponse
|
|
3770
|
+
* The response data is emitted via 'data' events.
|
|
3771
|
+
*
|
|
3772
|
+
* @param url - URL to stream from
|
|
3773
|
+
* @param options - Request options (optional)
|
|
3774
|
+
* @returns StreamResponse that emits 'data', 'end', 'error' events
|
|
3775
|
+
*
|
|
3776
|
+
* @example
|
|
3777
|
+
* ```typescript
|
|
3778
|
+
* const stream = rezo.stream('https://example.com/large-file');
|
|
3779
|
+
* stream.on('data', (chunk) => console.log('Received:', chunk.length, 'bytes'));
|
|
3780
|
+
* stream.on('end', () => console.log('Stream complete'));
|
|
3781
|
+
* stream.on('error', (err) => console.error('Error:', err));
|
|
3782
|
+
* ```
|
|
3783
|
+
*/
|
|
3784
|
+
stream(url: string | URL, options?: RezoHttpRequest): RezoStreamResponse;
|
|
3785
|
+
/**
|
|
3786
|
+
* Download a resource to a file - returns immediately with DownloadResponse
|
|
3787
|
+
* The download progress and completion are emitted via events.
|
|
3788
|
+
*
|
|
3789
|
+
* @param url - URL to download from
|
|
3790
|
+
* @param saveTo - File path to save the download to
|
|
3791
|
+
* @param options - Request options (optional)
|
|
3792
|
+
* @returns DownloadResponse that emits 'progress', 'complete', 'error' events
|
|
3793
|
+
*
|
|
3794
|
+
* @example
|
|
3795
|
+
* ```typescript
|
|
3796
|
+
* const download = rezo.download('https://example.com/file.zip', './downloads/file.zip');
|
|
3797
|
+
* download.on('progress', (p) => console.log(`${p.percent}% complete`));
|
|
3798
|
+
* download.on('complete', () => console.log('Download finished'));
|
|
3799
|
+
* download.on('error', (err) => console.error('Error:', err));
|
|
3800
|
+
* ```
|
|
3801
|
+
*/
|
|
3802
|
+
download(url: string | URL, saveTo: string, options?: RezoHttpRequest): RezoDownloadResponse;
|
|
3803
|
+
/**
|
|
3804
|
+
* Upload data with progress tracking - returns immediately with UploadResponse
|
|
3805
|
+
* The upload progress and completion are emitted via events.
|
|
3806
|
+
*
|
|
3807
|
+
* @param url - URL to upload to
|
|
3808
|
+
* @param data - Data to upload (Buffer, FormData, string, etc.)
|
|
3809
|
+
* @param options - Request options (optional)
|
|
3810
|
+
* @returns UploadResponse that emits 'progress', 'complete', 'error' events
|
|
3811
|
+
*
|
|
3812
|
+
* @example
|
|
3813
|
+
* ```typescript
|
|
3814
|
+
* const upload = rezo.upload('https://example.com/upload', fileBuffer);
|
|
3815
|
+
* upload.on('progress', (p) => console.log(`${p.percent}% uploaded`));
|
|
3816
|
+
* upload.on('complete', (response) => console.log('Upload finished:', response));
|
|
3817
|
+
* upload.on('error', (err) => console.error('Error:', err));
|
|
3818
|
+
* ```
|
|
3819
|
+
*/
|
|
3820
|
+
upload(url: string | URL, data: Buffer | FormData | RezoFormData | string | Record<string, any>, options?: RezoHttpRequest): RezoUploadResponse;
|
|
3821
|
+
}
|
|
2125
3822
|
/**
|
|
2126
|
-
*
|
|
2127
|
-
*
|
|
3823
|
+
* Extended Rezo instance with Axios-compatible static helpers.
|
|
3824
|
+
* Provides drop-in replacement API surface for Axios users.
|
|
2128
3825
|
*/
|
|
2129
|
-
export
|
|
3826
|
+
export interface RezoInstance extends Rezo {
|
|
3827
|
+
/** Create a new Rezo instance with custom configuration */
|
|
3828
|
+
create(config?: RezoDefaultOptions): Rezo;
|
|
3829
|
+
/** Type guard to check if an error is a RezoError instance */
|
|
3830
|
+
isRezoError: typeof RezoError.isRezoError;
|
|
3831
|
+
/** Check if an error is a cancellation error */
|
|
3832
|
+
isCancel: (error: unknown) => boolean;
|
|
3833
|
+
/** Alias for RezoError (Axios compatibility) */
|
|
3834
|
+
Cancel: typeof RezoError;
|
|
3835
|
+
/** AbortController for request cancellation (Axios compatibility) */
|
|
3836
|
+
CancelToken: typeof AbortController;
|
|
3837
|
+
/** Promise.all wrapper (Axios compatibility) */
|
|
3838
|
+
all: typeof Promise.all;
|
|
3839
|
+
/** Spread array arguments to callback function (Axios compatibility) */
|
|
3840
|
+
spread: <T extends unknown[], R>(callback: (...args: T) => R) => (array: T) => R;
|
|
3841
|
+
}
|
|
3842
|
+
export declare const isRezoError: typeof RezoError.isRezoError;
|
|
3843
|
+
export declare const Cancel: typeof RezoError;
|
|
3844
|
+
export declare const CancelToken: {
|
|
3845
|
+
new (): AbortController;
|
|
3846
|
+
prototype: AbortController;
|
|
3847
|
+
};
|
|
3848
|
+
export declare const isCancel: (error: unknown) => boolean;
|
|
3849
|
+
export declare const all: {
|
|
3850
|
+
<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
|
3851
|
+
<T extends readonly unknown[] | [
|
|
3852
|
+
]>(values: T): Promise<{
|
|
3853
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
3854
|
+
}>;
|
|
3855
|
+
};
|
|
3856
|
+
export declare const spread: <T extends unknown[], R>(callback: (...args: T) => R) => (array: T) => R;
|
|
3857
|
+
export declare const VERSION: string;
|
|
3858
|
+
declare const rezo: RezoInstance;
|
|
2130
3859
|
|
|
2131
3860
|
export {
|
|
2132
|
-
|
|
2133
|
-
|
|
3861
|
+
ResponseType$1 as ResponseType,
|
|
3862
|
+
rezo as default,
|
|
2134
3863
|
};
|
|
2135
3864
|
|
|
2136
3865
|
export {};
|