@scirexs/fetchy 0.4.0 → 0.4.2
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/esm/main.js +1 -434
- package/package.json +1 -1
- package/types/main.d.ts +28 -176
- package/types/main.d.ts.map +1 -1
package/esm/main.js
CHANGED
|
@@ -1,434 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
/*=============== Constant Values ===============*/
|
|
3
|
-
/**
|
|
4
|
-
* Default configuration values for fetchy.
|
|
5
|
-
* These values are used when corresponding options are not specified.
|
|
6
|
-
*/
|
|
7
|
-
const _DEFAULT = {
|
|
8
|
-
timeout: 15,
|
|
9
|
-
delay: 0,
|
|
10
|
-
interval: 3,
|
|
11
|
-
maxInterval: 30,
|
|
12
|
-
maxAttempts: 3,
|
|
13
|
-
retryAfter: true,
|
|
14
|
-
onNative: true,
|
|
15
|
-
onStatus: false,
|
|
16
|
-
redirect: "follow",
|
|
17
|
-
};
|
|
18
|
-
/*=============== Main Code =====================*/
|
|
19
|
-
/**
|
|
20
|
-
* Error thrown when HTTP response has a non-OK status code (4xx, 5xx, ...).
|
|
21
|
-
* Only thrown when throwError.onErrorStatus is set to true.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* try {
|
|
26
|
-
* await fetchy("https://api.example.com/data", {
|
|
27
|
-
* throwError: { onErrorStatus: true }
|
|
28
|
-
* });
|
|
29
|
-
* } catch (error) {
|
|
30
|
-
* if (error instanceof HTTPStatusError) {
|
|
31
|
-
* console.error("HTTP error:", error.message); // e.g., "403 Forbidden: {success:false}"
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
class HTTPStatusError extends Error {
|
|
37
|
-
static #MAX_BODY_LEN = 80;
|
|
38
|
-
status;
|
|
39
|
-
body;
|
|
40
|
-
constructor(msg, status, body) {
|
|
41
|
-
super(msg);
|
|
42
|
-
this.name = "HTTPStatusError";
|
|
43
|
-
this.status = status;
|
|
44
|
-
this.body = body;
|
|
45
|
-
}
|
|
46
|
-
static async fromResponse(resp) {
|
|
47
|
-
const body = await resp.text();
|
|
48
|
-
const bodyMsg = body.length > this.#MAX_BODY_LEN
|
|
49
|
-
? `${body.slice(0, this.#MAX_BODY_LEN)}... (more ${body.length - this.#MAX_BODY_LEN} chars)`
|
|
50
|
-
: body || "(no response body)";
|
|
51
|
-
const msg = `${resp.status} ${resp.statusText}: ${bodyMsg}`;
|
|
52
|
-
return new this(msg, resp.status, body);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Error thrown when a redirect response is received and redirect option is set to "error".
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* try {
|
|
61
|
-
* await fetchy("https://example.com/redirect", {
|
|
62
|
-
* redirect: "error"
|
|
63
|
-
* });
|
|
64
|
-
* } catch (error) {
|
|
65
|
-
* if (error instanceof RedirectError) {
|
|
66
|
-
* console.error("Unexpected redirect:", error.message);
|
|
67
|
-
* }
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
class RedirectError extends Error {
|
|
72
|
-
status;
|
|
73
|
-
constructor(msg, status) {
|
|
74
|
-
super(msg);
|
|
75
|
-
this.name = "RedirectError";
|
|
76
|
-
this.status = status;
|
|
77
|
-
}
|
|
78
|
-
static fromResponse(resp) {
|
|
79
|
-
const msg = `${resp.status} ${resp.statusText}`.trim();
|
|
80
|
-
return new this(msg, resp.status);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async function fetchyb(url, type = "auto", options) {
|
|
84
|
-
const resp = await fetchy(url, options);
|
|
85
|
-
if (!resp || !resp.ok)
|
|
86
|
-
return null;
|
|
87
|
-
const btype = resp.headers.get("Content-Type") ?? "";
|
|
88
|
-
try {
|
|
89
|
-
if (type === "text" || (type === "auto" && btype.startsWith("text/")))
|
|
90
|
-
return await resp.text();
|
|
91
|
-
if (type === "json" || (type === "auto" && btype === "application/json"))
|
|
92
|
-
return await resp.json();
|
|
93
|
-
return await resp.bytes();
|
|
94
|
-
}
|
|
95
|
-
catch (e) {
|
|
96
|
-
if (_throwError("onNative", options?.onError))
|
|
97
|
-
throw e;
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function fetchy(url, options) {
|
|
102
|
-
try {
|
|
103
|
-
if (!url)
|
|
104
|
-
url = options?.url ?? new URL("");
|
|
105
|
-
const opts = _getOptions(options);
|
|
106
|
-
const init = _getRequestInit(url, opts, options);
|
|
107
|
-
const resp = await _fetchWithRetry(url, init, opts);
|
|
108
|
-
if (!resp.ok && opts.onStatus)
|
|
109
|
-
throw await HTTPStatusError.fromResponse(resp);
|
|
110
|
-
return resp;
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
if (_throwError("onNative", options?.onError))
|
|
114
|
-
throw e;
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/*=============== Helper Code ===================*/
|
|
119
|
-
/**
|
|
120
|
-
* Checks if a value is a string.
|
|
121
|
-
* @internal
|
|
122
|
-
* @param v - Value to check.
|
|
123
|
-
* @returns True if the value is a string.
|
|
124
|
-
*/
|
|
125
|
-
function _isString(v) {
|
|
126
|
-
return typeof v === "string";
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Checks if a value is a number.
|
|
130
|
-
* @internal
|
|
131
|
-
* @param v - Value to check.
|
|
132
|
-
* @returns True if the value is a number.
|
|
133
|
-
*/
|
|
134
|
-
function _isNumber(v) {
|
|
135
|
-
return typeof v === "number";
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Checks if a value is a boolean.
|
|
139
|
-
* @internal
|
|
140
|
-
* @param v - Value to check.
|
|
141
|
-
* @returns True if the value is a boolean.
|
|
142
|
-
*/
|
|
143
|
-
function _isBool(v) {
|
|
144
|
-
return typeof v === "boolean";
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Checks if a value is a plain object (not array, null, or other object types).
|
|
148
|
-
* @internal
|
|
149
|
-
* @param v - Value to check.
|
|
150
|
-
* @returns True if the value is a plain object.
|
|
151
|
-
*/
|
|
152
|
-
function _isPlainObject(v) {
|
|
153
|
-
return Boolean(v &&
|
|
154
|
-
typeof v === "object" &&
|
|
155
|
-
Object.prototype.toString.call(v).slice(8, -1) === "Object" &&
|
|
156
|
-
v.constructor === Object);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Determines whether to throw an error based on configuration.
|
|
160
|
-
* @internal
|
|
161
|
-
* @param prop - The error option property to check.
|
|
162
|
-
* @param options - Error configuration or boolean flag.
|
|
163
|
-
* @returns True if error should be thrown.
|
|
164
|
-
*/
|
|
165
|
-
function _throwError(prop, options) {
|
|
166
|
-
return Boolean((options === void 0 && _DEFAULT[prop]) ||
|
|
167
|
-
(typeof options === "boolean" && options) ||
|
|
168
|
-
(typeof options === "object" && (options[prop] ?? _DEFAULT[prop])));
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Corrects a number to be non-negative, using default if invalid.
|
|
172
|
-
* @internal
|
|
173
|
-
* @param dflt - Default value to use if number is invalid.
|
|
174
|
-
* @param num - Number to validate.
|
|
175
|
-
* @param integer - Whether to truncate to integer.
|
|
176
|
-
* @returns Corrected number.
|
|
177
|
-
*/
|
|
178
|
-
function _correctNumber(dflt, num, integer = false) {
|
|
179
|
-
if (num === void 0 || num < 0)
|
|
180
|
-
return dflt;
|
|
181
|
-
return integer ? Math.trunc(num) : num;
|
|
182
|
-
}
|
|
183
|
-
function _getRetryOption(prop, off, options) {
|
|
184
|
-
if (_isBool(options))
|
|
185
|
-
return off;
|
|
186
|
-
if (options === void 0 || options[prop] === void 0)
|
|
187
|
-
return _DEFAULT[prop];
|
|
188
|
-
if (_isNumber(options[prop]))
|
|
189
|
-
return _correctNumber(_DEFAULT[prop], options[prop], prop === "maxAttempts");
|
|
190
|
-
return options[prop];
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Converts FetchyOptions to internal Options format with validated values.
|
|
194
|
-
* @internal
|
|
195
|
-
* @param options - User-provided options.
|
|
196
|
-
* @returns Normalized internal options.
|
|
197
|
-
*/
|
|
198
|
-
function _getOptions(options) {
|
|
199
|
-
return {
|
|
200
|
-
timeout: _correctNumber(_DEFAULT.timeout, options?.timeout),
|
|
201
|
-
delay: _correctNumber(_DEFAULT.delay, options?.delay),
|
|
202
|
-
interval: _getRetryOption("interval", 0, options?.retry),
|
|
203
|
-
maxInterval: _getRetryOption("maxInterval", 0, options?.retry),
|
|
204
|
-
maxAttempts: _getRetryOption("maxAttempts", 0, options?.retry),
|
|
205
|
-
retryAfter: _getRetryOption("retryAfter", false, options?.retry),
|
|
206
|
-
onStatus: _throwError("onStatus", options?.onError),
|
|
207
|
-
redirect: options?.redirect ?? _DEFAULT.redirect,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Converts FetchyOptions to standard RequestInit format.
|
|
212
|
-
* @internal
|
|
213
|
-
* @param url - Original request URL.
|
|
214
|
-
* @param opts - Internal options.
|
|
215
|
-
* @param options - User-provided options.
|
|
216
|
-
* @returns Standard RequestInit object.
|
|
217
|
-
*/
|
|
218
|
-
function _getRequestInit(url, opts, options) {
|
|
219
|
-
const { method, body, timeout, retry, bearer, onError, delay, redirect, signal, ...rest } = options ?? {};
|
|
220
|
-
return {
|
|
221
|
-
headers: _getHeaders(options),
|
|
222
|
-
method: method ? method : url instanceof Request ? url.method : body === void 0 ? "GET" : "POST",
|
|
223
|
-
signal: _combineSignal(url, opts.timeout, options?.signal),
|
|
224
|
-
...(redirect && { redirect: redirect === "error" ? "manual" : redirect }),
|
|
225
|
-
...(body && { body: _getBody(body) }),
|
|
226
|
-
...rest,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Converts FetchyBody to standard BodyInit format.
|
|
231
|
-
* @internal
|
|
232
|
-
* @param body - Body content to convert.
|
|
233
|
-
* @returns Standard BodyInit or undefined.
|
|
234
|
-
*/
|
|
235
|
-
function _getBody(body) {
|
|
236
|
-
return _isJSONObject(body) ? JSON.stringify(body) : body;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Checks if a value should be treated as JSON object for serialization.
|
|
240
|
-
* @internal
|
|
241
|
-
* @param arg - Value to check.
|
|
242
|
-
* @returns True if value should be JSON stringified.
|
|
243
|
-
*/
|
|
244
|
-
function _isJSONObject(arg) {
|
|
245
|
-
return Boolean(arg === null || _isNumber(arg) || _isBool(arg) || Array.isArray(arg) || _isPlainObject(arg));
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Constructs request headers with automatic Content-Type and Authorization.
|
|
249
|
-
* @internal
|
|
250
|
-
* @param options - User-provided options.
|
|
251
|
-
* @returns Headers object.
|
|
252
|
-
*/
|
|
253
|
-
function _getHeaders(options) {
|
|
254
|
-
const type = _getContentType(options?.body);
|
|
255
|
-
return {
|
|
256
|
-
"Accept": "application/json, text/plain",
|
|
257
|
-
...(type && { "Content-Type": type }),
|
|
258
|
-
...(options?.bearer && { "Authorization": `Bearer ${options.bearer}` }),
|
|
259
|
-
...options?.headers,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Determines Content-Type header based on body type.
|
|
264
|
-
* @internal
|
|
265
|
-
* @param body - Request body content.
|
|
266
|
-
* @returns Content-Type string or undefined.
|
|
267
|
-
*/
|
|
268
|
-
function _getContentType(body) {
|
|
269
|
-
if (body === void 0 || _isString(body) || body instanceof FormData || body instanceof URLSearchParams)
|
|
270
|
-
return;
|
|
271
|
-
if (body instanceof Blob && body.type)
|
|
272
|
-
return;
|
|
273
|
-
if (_isJSONObject(body))
|
|
274
|
-
return "application/json";
|
|
275
|
-
return "application/octet-stream";
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Combine abort signals.
|
|
279
|
-
* @internal
|
|
280
|
-
* @param url - Original request URL.
|
|
281
|
-
* @param timeout - Request timeout in seconds.
|
|
282
|
-
* @param signal - AbortSignal in User-provided options.
|
|
283
|
-
* @returns Combined AbortSignal or undefined.
|
|
284
|
-
*/
|
|
285
|
-
function _combineSignal(url, timeout, signal) {
|
|
286
|
-
const signals = [];
|
|
287
|
-
if (url instanceof Request && url.signal)
|
|
288
|
-
signals.push(url.signal);
|
|
289
|
-
if (signal)
|
|
290
|
-
signals.push(signal);
|
|
291
|
-
if (timeout > 0)
|
|
292
|
-
signals.push(AbortSignal.timeout(timeout * 1000 + 1));
|
|
293
|
-
return signals.length ? AbortSignal.any(signals) : undefined;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Waits for specified seconds with optional randomization.
|
|
297
|
-
* @internal
|
|
298
|
-
* @param sec - Seconds to wait.
|
|
299
|
-
* @param random - Whether to randomize the delay.
|
|
300
|
-
*/
|
|
301
|
-
async function _wait(sec, random = true) {
|
|
302
|
-
if (sec <= 0)
|
|
303
|
-
return;
|
|
304
|
-
const delay = Math.trunc((random ? Math.random() : 1) * sec * 1000);
|
|
305
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Checks if response is a redirect (3xx status).
|
|
309
|
-
* @internal
|
|
310
|
-
* @param resp - Response to check.
|
|
311
|
-
* @returns True if response is a redirect.
|
|
312
|
-
*/
|
|
313
|
-
function _shouldRedirect(resp) {
|
|
314
|
-
return resp.status < 400 && resp.status >= 300;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Determines if retry should stop based on conditions and waits if continuing.
|
|
318
|
-
* @internal
|
|
319
|
-
* @param count - Current retry attempt number.
|
|
320
|
-
* @param init - Request initialization object.
|
|
321
|
-
* @param opts - Internal options.
|
|
322
|
-
* @param resp - Response from previous attempt.
|
|
323
|
-
* @returns True if retry should stop.
|
|
324
|
-
*/
|
|
325
|
-
async function _shouldNotRetry(count, init, opts, resp) {
|
|
326
|
-
if (count >= opts.maxAttempts - 1 || init.signal?.aborted || resp?.ok)
|
|
327
|
-
return true;
|
|
328
|
-
if (resp && _shouldRedirect(resp)) {
|
|
329
|
-
if (opts.redirect === "manual")
|
|
330
|
-
return true;
|
|
331
|
-
if (opts.redirect === "error") {
|
|
332
|
-
opts.maxAttempts = 0;
|
|
333
|
-
throw RedirectError.fromResponse(resp);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const interval = _getNextInterval(count, opts, resp);
|
|
337
|
-
if (interval > opts.maxInterval)
|
|
338
|
-
return true;
|
|
339
|
-
await _wait(interval, false);
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Calculates next retry interval using exponential backoff or Retry-After header.
|
|
344
|
-
* @internal
|
|
345
|
-
* @param count - Current retry attempt number.
|
|
346
|
-
* @param opts - Internal options.
|
|
347
|
-
* @param resp - Response from previous attempt.
|
|
348
|
-
* @returns Next retry interval in seconds.
|
|
349
|
-
*/
|
|
350
|
-
function _getNextInterval(count, opts, resp) {
|
|
351
|
-
return opts.retryAfter && resp
|
|
352
|
-
? Math.max(_parseRetryAfter(resp.headers.get("Retry-After")?.trim() ?? ""), opts.interval)
|
|
353
|
-
: Math.min(Math.pow(Math.max(1, opts.interval), count), opts.maxInterval);
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Parses Retry-After header value to seconds.
|
|
357
|
-
* @internal
|
|
358
|
-
* @param value - Retry-After header value (seconds or HTTP date).
|
|
359
|
-
* @returns Retry delay in seconds, or Infinity if invalid.
|
|
360
|
-
*/
|
|
361
|
-
function _parseRetryAfter(value) {
|
|
362
|
-
if (!value)
|
|
363
|
-
return Infinity;
|
|
364
|
-
const sec1 = Number.parseInt(value, 10);
|
|
365
|
-
if (!Number.isNaN(sec1))
|
|
366
|
-
return sec1;
|
|
367
|
-
const sec2 = Math.ceil((new Date(value).getTime() - Date.now()) / 1000);
|
|
368
|
-
if (!Number.isNaN(sec2))
|
|
369
|
-
return sec2;
|
|
370
|
-
return Infinity;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Updates URL and method for redirect responses.
|
|
374
|
-
* @internal
|
|
375
|
-
* @param url - Original request URL.
|
|
376
|
-
* @param init - Request initialization object.
|
|
377
|
-
* @param resp - Redirect response.
|
|
378
|
-
* @returns Updated URL for next request.
|
|
379
|
-
*/
|
|
380
|
-
function _handleRedirectResponse(url, init, resp) {
|
|
381
|
-
if (!resp.redirected)
|
|
382
|
-
return url;
|
|
383
|
-
if (resp.status === 303)
|
|
384
|
-
init.method = "GET";
|
|
385
|
-
return url instanceof Request ? new Request(resp.url, url) : resp.url;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Clone input if required.
|
|
389
|
-
* @internal
|
|
390
|
-
* @param url - Original request URL.
|
|
391
|
-
* @param required - Switch to clone or not.
|
|
392
|
-
* @returns Cloned input for fetch.
|
|
393
|
-
*/
|
|
394
|
-
function _cloneInput(url, required) {
|
|
395
|
-
return url instanceof Request && required ? url.clone() : url;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Executes fetch with retry logic and exponential backoff.
|
|
399
|
-
* @internal
|
|
400
|
-
* @param url - Request URL.
|
|
401
|
-
* @param init - Request initialization object.
|
|
402
|
-
* @param opts - Internal options.
|
|
403
|
-
* @returns Response from successful request.
|
|
404
|
-
*/
|
|
405
|
-
async function _fetchWithRetry(url, init, opts) {
|
|
406
|
-
for (let i = 0; i < opts.maxAttempts; i++) {
|
|
407
|
-
try {
|
|
408
|
-
const input = _cloneInput(url, i < opts.maxAttempts - 1); // no clone if end of retry
|
|
409
|
-
const resp = await _fetchWithJitter(input, init, opts);
|
|
410
|
-
if (await _shouldNotRetry(i, init, opts, resp))
|
|
411
|
-
return resp;
|
|
412
|
-
url = _handleRedirectResponse(url, init, resp);
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
catch (e) {
|
|
416
|
-
if (await _shouldNotRetry(i, init, opts))
|
|
417
|
-
throw e;
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return await _fetchWithJitter(url, init, opts);
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Executes fetch with initial jitter delay.
|
|
425
|
-
* @internal
|
|
426
|
-
* @param url - Request URL.
|
|
427
|
-
* @param init - Request initialization object.
|
|
428
|
-
* @param opts - Internal options.
|
|
429
|
-
* @returns Response from request.
|
|
430
|
-
*/
|
|
431
|
-
async function _fetchWithJitter(url, init, opts) {
|
|
432
|
-
await _wait(opts.delay);
|
|
433
|
-
return await fetch(url, init);
|
|
434
|
-
}
|
|
1
|
+
export{m as fetchy,A as fetchyb,l as HTTPStatusError,h as RedirectError};const i={timeout:15,delay:0,interval:3,maxInterval:30,maxAttempts:3,retryAfter:!0,onNative:!0,onStatus:!1,redirect:"follow"};class l extends Error{static#t=80;status;body;constructor(e,r,n){super(e),this.name="HTTPStatusError",this.status=r,this.body=n}static async fromResponse(e){const r=await e.text(),n=r.length>this.#t?`${r.slice(0,this.#t)}... (more ${r.length-this.#t} chars)`:r||"(no response body)",a=`${e.status} ${e.statusText}: ${n}`;return new this(a,e.status,r)}}class h extends Error{status;constructor(e,r){super(e),this.name="RedirectError",this.status=r}static fromResponse(e){const r=`${e.status} ${e.statusText}`.trim();return new this(r,e.status)}}async function A(t,e="auto",r){const n=await m(t,r);if(!n||!n.ok)return null;const a=n.headers.get("Content-Type")??"";try{return e==="text"||e==="auto"&&a.startsWith("text/")?await n.text():e==="json"||e==="auto"&&a==="application/json"?await n.json():await n.bytes()}catch(s){if(o("onNative",r?.onError))throw s;return null}}async function m(t,e){try{t||(t=e?.url??new URL(""));const r=v(e),n=T(t,r,e),a=await P(t,n,r);if(!a.ok&&r.onStatus)throw await l.fromResponse(a);return a}catch(r){if(o("onNative",e?.onError))throw r;return null}}function R(t){return typeof t=="string"}function y(t){return typeof t=="number"}function d(t){return typeof t=="boolean"}function N(t){return!!(t&&typeof t=="object"&&Object.prototype.toString.call(t).slice(8,-1)==="Object"&&t.constructor===Object)}function o(t,e){return!!(e===void 0&&i[t]||typeof e=="boolean"&&e||typeof e=="object"&&(e[t]??i[t]))}function f(t,e,r=!1){return e===void 0||e<0?t:r?Math.trunc(e):e}function u(t,e,r){return d(r)?e:r===void 0||r[t]===void 0?i[t]:y(r[t])?f(i[t],r[t],t==="maxAttempts"):r[t]}function v(t){return{timeout:f(i.timeout,t?.timeout),delay:f(i.delay,t?.delay),interval:u("interval",0,t?.retry),maxInterval:u("maxInterval",0,t?.retry),maxAttempts:u("maxAttempts",0,t?.retry),retryAfter:u("retryAfter",!1,t?.retry),onStatus:o("onStatus",t?.onError),redirect:t?.redirect??i.redirect}}function T(t,e,r){const{method:n,body:a,timeout:s,retry:D,bearer:C,onError:H,delay:L,redirect:c,signal:k,...g}=r??{};return{headers:S(r),method:n||(t instanceof Request?t.method:a===void 0?"GET":"POST"),signal:I(t,e.timeout,r?.signal),...c&&{redirect:c==="error"?"manual":c},...a&&{body:E(a)},...g}}function E(t){return w(t)?JSON.stringify(t):t}function w(t){return!!(t===null||y(t)||d(t)||Array.isArray(t)||N(t))}function S(t){const e=new Headers(t?.headers);if(e.has("Accept")||e.append("Accept","application/json, text/plain"),!e.has("Content-Type")){const r=j(t?.body);r&&e.append("Content-Type",r)}return t?.bearer&&e.set("Authorization",`Bearer ${t.bearer}`),e}function j(t){if(!(t===void 0||R(t)||t instanceof FormData||t instanceof URLSearchParams)&&!(t instanceof Blob&&t.type))return w(t)?"application/json":"application/octet-stream"}function I(t,e,r){const n=[];return t instanceof Request&&t.signal&&n.push(t.signal),r&&n.push(r),e>0&&n.push(AbortSignal.timeout(e*1e3+1)),n.length?AbortSignal.any(n):void 0}async function b(t,e=!0){if(t<=0)return;const r=Math.trunc((e?Math.random():1)*t*1e3);await new Promise(n=>setTimeout(n,r))}function O(t){return t.status<400&&t.status>=300}async function x(t,e,r,n){if(t>=r.maxAttempts-1||e.signal?.aborted||n?.ok)return!0;if(n&&O(n)){if(r.redirect==="manual")return!0;if(r.redirect==="error")throw r.maxAttempts=0,h.fromResponse(n)}const a=M(t,r,n);return a>r.maxInterval?!0:(await b(a,!1),!1)}function M(t,e,r){return e.retryAfter&&r?Math.max(B(r.headers.get("Retry-After")?.trim()??""),e.interval):Math.min(Math.pow(Math.max(1,e.interval),t),e.maxInterval)}function B(t){if(!t)return 1/0;const e=Number.parseInt(t,10);if(!Number.isNaN(e))return e;const r=Math.ceil((new Date(t).getTime()-Date.now())/1e3);return Number.isNaN(r)?1/0:r}function $(t,e,r){return r.redirected?(r.status===303&&(e.method="GET"),t instanceof Request?new Request(r.url,t):r.url):t}function q(t,e){return t instanceof Request&&e?t.clone():t}async function P(t,e,r){for(let n=0;n<r.maxAttempts;n++)try{const a=q(t,n<r.maxAttempts-1),s=await _(a,e,r);if(await x(n,e,r,s))return s;t=$(t,e,s);continue}catch(a){if(await x(n,e,r))throw a;continue}return await _(t,e,r)}async function _(t,e,r){return await b(r.delay),await fetch(t,e)}
|
package/package.json
CHANGED
package/types/main.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
export { _cloneInput, _combineSignal, _correctNumber, _DEFAULT, _fetchWithJitter, _fetchWithRetry, _getBody, _getContentType, _getHeaders, _getNextInterval, _getOptions, _getRequestInit, _getRetryOption, _handleRedirectResponse, _isBool, _isJSONObject, _isNumber, _isPlainObject, _isString, _parseRetryAfter, _shouldNotRetry, _shouldRedirect, _throwError, _wait, fetchy, fetchyb, HTTPStatusError, RedirectError, };
|
|
2
2
|
import type { ErrorOptions, FetchyBody, FetchyOptions, RetryOptions } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Default configuration values for fetchy.
|
|
5
|
-
* These values are used when corresponding options are not specified.
|
|
6
|
-
*/
|
|
3
|
+
/** Default configuration values for fetchy. */
|
|
7
4
|
declare const _DEFAULT: Options;
|
|
8
|
-
/**
|
|
9
|
-
* Valid input types for fetch requests.
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
5
|
+
/** Valid input types for fetch requests. */
|
|
12
6
|
type Input = string | URL | Request;
|
|
13
|
-
/**
|
|
14
|
-
* Internal normalized options used throughout the fetch process.
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
7
|
+
/** Internal normalized options used throughout the fetch process. */
|
|
17
8
|
interface Options {
|
|
18
9
|
timeout: number;
|
|
19
10
|
delay: number;
|
|
@@ -25,10 +16,7 @@ interface Options {
|
|
|
25
16
|
onStatus: boolean;
|
|
26
17
|
redirect: "follow" | "error" | "manual";
|
|
27
18
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Infer helper type for response type overload.
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
19
|
+
/** Infer helper type for response type overload. */
|
|
32
20
|
type ThrowError = FetchyOptions & Partial<{
|
|
33
21
|
throwError: true;
|
|
34
22
|
}> | FetchyOptions & Partial<{
|
|
@@ -155,187 +143,51 @@ declare function fetchyb<T>(url: Input | null, type?: "auto", options?: FetchyOp
|
|
|
155
143
|
declare function fetchy(url: Input | null, options?: undefined): Promise<Response>;
|
|
156
144
|
declare function fetchy(url: Input | null, options: FetchyOptions & ThrowError): Promise<Response>;
|
|
157
145
|
declare function fetchy(url: Input | null, options?: FetchyOptions): Promise<Response | null>;
|
|
158
|
-
/**
|
|
159
|
-
* Checks if a value is a string.
|
|
160
|
-
* @internal
|
|
161
|
-
* @param v - Value to check.
|
|
162
|
-
* @returns True if the value is a string.
|
|
163
|
-
*/
|
|
146
|
+
/** Checks if a value is a string. */
|
|
164
147
|
declare function _isString(v: unknown): v is string;
|
|
165
|
-
/**
|
|
166
|
-
* Checks if a value is a number.
|
|
167
|
-
* @internal
|
|
168
|
-
* @param v - Value to check.
|
|
169
|
-
* @returns True if the value is a number.
|
|
170
|
-
*/
|
|
148
|
+
/** Checks if a value is a number. */
|
|
171
149
|
declare function _isNumber(v: unknown): v is number;
|
|
172
|
-
/**
|
|
173
|
-
* Checks if a value is a boolean.
|
|
174
|
-
* @internal
|
|
175
|
-
* @param v - Value to check.
|
|
176
|
-
* @returns True if the value is a boolean.
|
|
177
|
-
*/
|
|
150
|
+
/** Checks if a value is a boolean. */
|
|
178
151
|
declare function _isBool(v: unknown): v is boolean;
|
|
179
|
-
/**
|
|
180
|
-
* Checks if a value is a plain object (not array, null, or other object types).
|
|
181
|
-
* @internal
|
|
182
|
-
* @param v - Value to check.
|
|
183
|
-
* @returns True if the value is a plain object.
|
|
184
|
-
*/
|
|
152
|
+
/** Checks if a value is a plain object (not array, null, or other object types). */
|
|
185
153
|
declare function _isPlainObject(v: unknown): v is object;
|
|
186
|
-
/**
|
|
187
|
-
* Determines whether to throw an error based on configuration.
|
|
188
|
-
* @internal
|
|
189
|
-
* @param prop - The error option property to check.
|
|
190
|
-
* @param options - Error configuration or boolean flag.
|
|
191
|
-
* @returns True if error should be thrown.
|
|
192
|
-
*/
|
|
154
|
+
/** Determines whether to throw an error based on configuration. */
|
|
193
155
|
declare function _throwError(prop: keyof ErrorOptions, options?: ErrorOptions | boolean): boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Corrects a number to be non-negative, using default if invalid.
|
|
196
|
-
* @internal
|
|
197
|
-
* @param dflt - Default value to use if number is invalid.
|
|
198
|
-
* @param num - Number to validate.
|
|
199
|
-
* @param integer - Whether to truncate to integer.
|
|
200
|
-
* @returns Corrected number.
|
|
201
|
-
*/
|
|
156
|
+
/** Corrects a number to be non-negative, using default if invalid. */
|
|
202
157
|
declare function _correctNumber(dflt: number, num?: number, integer?: boolean): number;
|
|
203
|
-
/**
|
|
204
|
-
* Gets retry option value from configuration with fallback to default.
|
|
205
|
-
* @internal
|
|
206
|
-
* @param prop - The retry option property to get.
|
|
207
|
-
* @param off - Fallback value when retry is disabled.
|
|
208
|
-
* @param options - Retry configuration.
|
|
209
|
-
* @returns The retry option value.
|
|
210
|
-
*/
|
|
158
|
+
/** Gets retry option value from configuration with fallback to default. */
|
|
211
159
|
declare function _getRetryOption(prop: keyof RetryOptions, off: number, options?: RetryOptions | false): number;
|
|
212
160
|
declare function _getRetryOption(prop: keyof RetryOptions, off: boolean, options?: RetryOptions | false): boolean;
|
|
213
|
-
/**
|
|
214
|
-
* Converts FetchyOptions to internal Options format with validated values.
|
|
215
|
-
* @internal
|
|
216
|
-
* @param options - User-provided options.
|
|
217
|
-
* @returns Normalized internal options.
|
|
218
|
-
*/
|
|
161
|
+
/** Converts FetchyOptions to internal Options format with validated values. */
|
|
219
162
|
declare function _getOptions(options?: FetchyOptions): Options;
|
|
220
|
-
/**
|
|
221
|
-
* Converts FetchyOptions to standard RequestInit format.
|
|
222
|
-
* @internal
|
|
223
|
-
* @param url - Original request URL.
|
|
224
|
-
* @param opts - Internal options.
|
|
225
|
-
* @param options - User-provided options.
|
|
226
|
-
* @returns Standard RequestInit object.
|
|
227
|
-
*/
|
|
163
|
+
/** Converts FetchyOptions to standard RequestInit format. */
|
|
228
164
|
declare function _getRequestInit(url: Input, opts: Options, options?: FetchyOptions): RequestInit;
|
|
229
|
-
/**
|
|
230
|
-
* Converts FetchyBody to standard BodyInit format.
|
|
231
|
-
* @internal
|
|
232
|
-
* @param body - Body content to convert.
|
|
233
|
-
* @returns Standard BodyInit or undefined.
|
|
234
|
-
*/
|
|
165
|
+
/** Converts FetchyBody to standard BodyInit format. */
|
|
235
166
|
declare function _getBody(body: FetchyBody): BodyInit | undefined;
|
|
236
|
-
/**
|
|
237
|
-
* Checks if a value should be treated as JSON object for serialization.
|
|
238
|
-
* @internal
|
|
239
|
-
* @param arg - Value to check.
|
|
240
|
-
* @returns True if value should be JSON stringified.
|
|
241
|
-
*/
|
|
167
|
+
/** Checks if a value should be treated as JSON object for serialization. */
|
|
242
168
|
declare function _isJSONObject(arg?: FetchyBody): boolean;
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* @param options - User-provided options.
|
|
247
|
-
* @returns Headers object.
|
|
248
|
-
*/
|
|
249
|
-
declare function _getHeaders(options?: FetchyOptions): HeadersInit;
|
|
250
|
-
/**
|
|
251
|
-
* Determines Content-Type header based on body type.
|
|
252
|
-
* @internal
|
|
253
|
-
* @param body - Request body content.
|
|
254
|
-
* @returns Content-Type string or undefined.
|
|
255
|
-
*/
|
|
169
|
+
/** Constructs request headers with automatic Content-Type and Authorization. */
|
|
170
|
+
declare function _getHeaders(options?: FetchyOptions): Headers;
|
|
171
|
+
/** Determines Content-Type header based on body type. */
|
|
256
172
|
declare function _getContentType(body?: FetchyBody): string | undefined;
|
|
257
|
-
/**
|
|
258
|
-
* Combine abort signals.
|
|
259
|
-
* @internal
|
|
260
|
-
* @param url - Original request URL.
|
|
261
|
-
* @param timeout - Request timeout in seconds.
|
|
262
|
-
* @param signal - AbortSignal in User-provided options.
|
|
263
|
-
* @returns Combined AbortSignal or undefined.
|
|
264
|
-
*/
|
|
173
|
+
/** Combine abort signals. */
|
|
265
174
|
declare function _combineSignal(url: Input, timeout: number, signal?: AbortSignal | null): AbortSignal | undefined;
|
|
266
|
-
/**
|
|
267
|
-
* Waits for specified seconds with optional randomization.
|
|
268
|
-
* @internal
|
|
269
|
-
* @param sec - Seconds to wait.
|
|
270
|
-
* @param random - Whether to randomize the delay.
|
|
271
|
-
*/
|
|
175
|
+
/** Waits for specified seconds with optional randomization. */
|
|
272
176
|
declare function _wait(sec: number, random?: boolean): Promise<void>;
|
|
273
|
-
/**
|
|
274
|
-
* Checks if response is a redirect (3xx status).
|
|
275
|
-
* @internal
|
|
276
|
-
* @param resp - Response to check.
|
|
277
|
-
* @returns True if response is a redirect.
|
|
278
|
-
*/
|
|
177
|
+
/** Checks if response is a redirect (3xx status). */
|
|
279
178
|
declare function _shouldRedirect(resp: Response): boolean;
|
|
280
|
-
/**
|
|
281
|
-
* Determines if retry should stop based on conditions and waits if continuing.
|
|
282
|
-
* @internal
|
|
283
|
-
* @param count - Current retry attempt number.
|
|
284
|
-
* @param init - Request initialization object.
|
|
285
|
-
* @param opts - Internal options.
|
|
286
|
-
* @param resp - Response from previous attempt.
|
|
287
|
-
* @returns True if retry should stop.
|
|
288
|
-
*/
|
|
179
|
+
/** Determines if retry should stop based on conditions and waits if continuing. */
|
|
289
180
|
declare function _shouldNotRetry(count: number, init: RequestInit, opts: Options, resp?: Response): Promise<boolean>;
|
|
290
|
-
/**
|
|
291
|
-
* Calculates next retry interval using exponential backoff or Retry-After header.
|
|
292
|
-
* @internal
|
|
293
|
-
* @param count - Current retry attempt number.
|
|
294
|
-
* @param opts - Internal options.
|
|
295
|
-
* @param resp - Response from previous attempt.
|
|
296
|
-
* @returns Next retry interval in seconds.
|
|
297
|
-
*/
|
|
181
|
+
/** Calculates next retry interval using exponential backoff or Retry-After header. */
|
|
298
182
|
declare function _getNextInterval(count: number, opts: Options, resp?: Response): number;
|
|
299
|
-
/**
|
|
300
|
-
* Parses Retry-After header value to seconds.
|
|
301
|
-
* @internal
|
|
302
|
-
* @param value - Retry-After header value (seconds or HTTP date).
|
|
303
|
-
* @returns Retry delay in seconds, or Infinity if invalid.
|
|
304
|
-
*/
|
|
183
|
+
/** Parses Retry-After header value to seconds. */
|
|
305
184
|
declare function _parseRetryAfter(value: string): number;
|
|
306
|
-
/**
|
|
307
|
-
* Updates URL and method for redirect responses.
|
|
308
|
-
* @internal
|
|
309
|
-
* @param url - Original request URL.
|
|
310
|
-
* @param init - Request initialization object.
|
|
311
|
-
* @param resp - Redirect response.
|
|
312
|
-
* @returns Updated URL for next request.
|
|
313
|
-
*/
|
|
185
|
+
/** Updates URL and method for redirect responses. */
|
|
314
186
|
declare function _handleRedirectResponse(url: Input, init: RequestInit, resp: Response): Input;
|
|
315
|
-
/**
|
|
316
|
-
* Clone input if required.
|
|
317
|
-
* @internal
|
|
318
|
-
* @param url - Original request URL.
|
|
319
|
-
* @param required - Switch to clone or not.
|
|
320
|
-
* @returns Cloned input for fetch.
|
|
321
|
-
*/
|
|
187
|
+
/** Clone input if required. */
|
|
322
188
|
declare function _cloneInput(url: Input, required: boolean): Input;
|
|
323
|
-
/**
|
|
324
|
-
* Executes fetch with retry logic and exponential backoff.
|
|
325
|
-
* @internal
|
|
326
|
-
* @param url - Request URL.
|
|
327
|
-
* @param init - Request initialization object.
|
|
328
|
-
* @param opts - Internal options.
|
|
329
|
-
* @returns Response from successful request.
|
|
330
|
-
*/
|
|
189
|
+
/** Executes fetch with retry logic and exponential backoff. */
|
|
331
190
|
declare function _fetchWithRetry(url: Input, init: RequestInit, opts: Options): Promise<Response>;
|
|
332
|
-
/**
|
|
333
|
-
* Executes fetch with initial jitter delay.
|
|
334
|
-
* @internal
|
|
335
|
-
* @param url - Request URL.
|
|
336
|
-
* @param init - Request initialization object.
|
|
337
|
-
* @param opts - Internal options.
|
|
338
|
-
* @returns Response from request.
|
|
339
|
-
*/
|
|
191
|
+
/** Executes fetch with initial jitter delay. */
|
|
340
192
|
declare function _fetchWithJitter(url: Input, init: RequestInit, opts: Options): Promise<Response>;
|
|
341
193
|
//# sourceMappingURL=main.d.ts.map
|
package/types/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,OAAO,EACP,aAAa,EACb,SAAS,EACT,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,WAAW,EACX,KAAK,EACL,MAAM,EACN,OAAO,EACP,eAAe,EACf,aAAa,GACd,CAAC;AAEF,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGxF
|
|
1
|
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