@scirexs/fetchy 0.6.1 → 0.8.1
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 +269 -220
- package/esm/main.js +1 -1
- package/esm/mod.js +1 -1
- package/package.json +1 -1
- package/types/main.d.ts +149 -222
- package/types/main.d.ts.map +1 -1
- package/types/mod.d.ts +2 -2
- package/types/mod.d.ts.map +1 -1
- package/types/types.d.ts +282 -18
- package/types/types.d.ts.map +1 -1
package/esm/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{N as fetchy,U as fy,w as HTTPStatusError,k as setFetchy,M as sfetchy};const l="GET",m="HEAD",o="POST",F="PUT",_="PATCH",v="DELETE",d="fetch",y="Accept",T="Content-Type",b="application/json",u={a:15,b:0,c:3,d:30,e:3,f:!0,g:!1,h:[500,502,503,504,408,429],i:["retry-after","ratelimit-reset","x-ratelimit-reset"],j:!1},I=[o,_,"CONNECT"],E=["text","json","bytes","blob","arrayBuffer","formData"],L=[d,l,m,o,F,_,v];let g={};class w extends Error{status;response;constructor(e){super(`${e.status} ${e.url}`),this.name="HTTPStatusError",this.status=e.status,this.response=e}}function U(t){const e=S({},t);return D(e),D(e,!0),e}function M(t,e){return O(t,e,!0)}function N(t,e){return O(t,e)}function k(t){g=t}function O(t,e,n=!1){e=h(g,e);const r=G(t,e),i=V(r,t,e);return ct(at(t,r,i,n),n)}function h(t,e,n){return{...t,...e,...n&&{method:n}}}function J(t){return typeof t=="string"}function $(t){return typeof t=="number"}function H(t){return typeof t=="boolean"}function R(t){return t instanceof ReadableStream}function f(t){return t instanceof Request}function q(t){return!!(t&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype)}function S(t,e){return Object.assign(t,e)}function s(t,e){return(e??-1)>=0?e:t}function G(t,e){const{method:n,body:r,timeout:i,retry:c,bearer:a,native:ft,jitter:st,headers:ot,signal:lt,...B}=e??{};return{headers:Y(e,f(t)?t.headers:null),method:n?n.toUpperCase():f(t)?t.method:r==null?l:o,...W(r),...B}}function W(t){return R(t)?null:{body:j(t)?JSON.stringify(t):t}}function j(t){return!!($(t)||H(t)||Array.isArray(t)||q(t))}function Y(t,e){const n=new Headers(t?.headers);if(C(y,n,e)&&n.set(y,`${b}, text/plain`),C(T,n,e)){const r=z(t?.body);r&&n.set(T,r)}return t?.bearer&&n.set("Authorization",`Bearer ${t.bearer}`),n}function C(t,e,n){return!e.has(t)&&!n?.has(t)}function z(t){return j(t)?b:K(t)?"":"application/octet-stream"}function K(t){return t==null||J(t)||t instanceof FormData||t instanceof URLSearchParams||!!(t instanceof Blob&&t.type)}function Q(t,e){return H(e)?{...u,e:1}:{e:Math.max(s(u.e,e?.maxAttempts),1),c:Math.max(s(u.c,e?.interval),.01),d:Math.max(s(u.d,e?.maxInterval),1),f:e?.retryOnTimeout??u.f,g:e?.idempotentOnly?I.includes(t.method??""):!1,h:e?.statusCodes??u.h,i:e?.respectHeaders??u.i}}function V(t,e,n){return{...Q(t,n?.retry),a:s(u.a,n?.timeout),b:s(u.b,n?.jitter),j:n?.native??u.j,k:P(f(e)?e.signal:null,n?.signal),l:n?.url,m:n?.base,n:n?.body}}function P(t,e){if(!(!t&&!e))return t&&e?AbortSignal.any([t,e]):t||(e??void 0)}function X(t){return t.a<=0?t.k:P(AbortSignal.timeout(t.a*1e3),t.k)}async function x(t,e=!1){if(t<=0)return;const n=Math.trunc((e?Math.random():1)*t*1e3);await new Promise(r=>setTimeout(r,n))}function Z(t){return t>=400||t<100}async function A(t,e,n,r){if(e.g||t>=e.e-1||!r)return!1;if(n instanceof Response){if(e.j||!e.h.includes(n.status))return!1;const i=p(t,e,n.headers);return i>e.d?!1:(await x(i),!0)}else return n instanceof Error&&n.name=="TimeoutError"&&e.f}function p(t,e,n){return e.i.some(r=>n.has(r))?tt(e,n)??e.c:Math.min(e.c*2**t,e.d)}function tt(t,e){for(const n of t.i){const r=et(e.get(n)?.trim());if(!Number.isNaN(r))return Math.max(r,t.c)}}function et(t){if(!t)return NaN;const e=Number.parseInt(t,10);return Number.isNaN(e)?Math.ceil((new Date(t).getTime()-Date.now())/1e3):e}function nt(t,e){if(!R(e.n))return t;const n=[l,m].includes(t.method)?o:t.method;return new Request(t,{method:n,body:e.n})}function rt(t,e){return f(e)||(e||(e=t?.l??""),f(e))?e:new Request(URL.parse(e,t?.m)??"")}function it(t){let e;return async n=>{n&&await e?.body?.cancel();const r=e??t;return n||(e=e?e.clone():t.clone()),r}}async function at(t,e,n,r){let i;for(let c=0;c<n.e;c++)try{c===0&&(i=it(nt(rt(n,t),n)));const a=await ut(await i(),e,n);if(await A(c,n,a,i))continue;if(Z(a.status)&&!n.j)throw new w(a);return a}catch(a){if(await A(c,n,a,i))continue;if(r)return null;throw a}finally{await i?.(!0)}throw new Error}async function ut(t,e,n){return await x(n.b,!0),await fetch(t,{...e,signal:X(n)})}function ct(t,e){return S(t,Object.fromEntries([...e?E.map(n=>[n,()=>t.then(r=>r[n]()).catch(()=>null)]):E.map(n=>[n,()=>t.then(r=>r[n]())])]))}function D(t,e){for(const n of L){const r=(e?"s":"")+n.toLowerCase();t[r]=function(i,c){const a=n===d?h(this,c):h(this,c,n);return e?M(i,a):N(i,a)}}}
|
package/esm/mod.js
CHANGED
package/package.json
CHANGED
package/types/main.d.ts
CHANGED
|
@@ -1,171 +1,79 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import type { FetchyBody, FetchyOptions, RetryOptions } from "./types.js";
|
|
3
|
-
/** Error message to simulate immediate failures without retry for writing tests. */
|
|
4
|
-
declare const NO_RETRY_ERROR = "$$_NO_RETRY_$$";
|
|
1
|
+
export { _assign, _buildOption, _cloneRequestF, _correctNumber, _createRequest, _DEFAULT, _fetchWithJitter, _fetchWithRetry, _findRetryHeader, _genMethods, _getBody, _getContentType, _getHeaders, _getNextInterval, _getOptions, _getRequestInit, _getRetryOption, _handleByNative, _includeStream, _isBool, _isHttpError, _isJSONObject, _isNoHeader, _isNumber, _isPlain, _isRequest, _isStream, _isString, _main, _makeFetchyResponse, _mergeSignals, _parseRetryHeader, _shouldRetry, _wait, _withTimeout, fetchy, fy, HTTPStatusError, setFetchy, sfetchy, };
|
|
2
|
+
import type { Fetchy, FetchyBody, FetchyOptions, FetchyResponse, FetchySafeResponse, RetryOptions } from "./types.js";
|
|
5
3
|
/** Default configuration values for fetchy. */
|
|
6
4
|
declare const _DEFAULT: Options;
|
|
7
|
-
/** Valid input types for fetch requests. */
|
|
8
|
-
type Input = string | URL | Request;
|
|
9
|
-
type FetchyReturn<T> = Response | string | Uint8Array<ArrayBuffer> | Blob | ArrayBuffer | T;
|
|
10
|
-
/** Response body parsing method specification. */
|
|
11
|
-
type ParseMethod = "text" | "json" | "bytes" | "blob" | "buffer";
|
|
12
5
|
/** Internal normalized options used throughout the fetch process. */
|
|
13
6
|
interface Options {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
ztimeout: number;
|
|
8
|
+
zjitter: number;
|
|
9
|
+
zinterval: number;
|
|
10
|
+
zmaxInterval: number;
|
|
11
|
+
zmaxAttempts: number;
|
|
12
|
+
zonTimeout: boolean;
|
|
13
|
+
znoIdempotent: boolean;
|
|
14
|
+
zstatusCodes: number[];
|
|
15
|
+
zrespects: string[];
|
|
16
|
+
znative: boolean;
|
|
17
|
+
zsignal?: AbortSignal;
|
|
18
|
+
zurl?: string | URL | Request;
|
|
19
|
+
zbase?: string | URL;
|
|
20
|
+
zbody?: FetchyBody;
|
|
22
21
|
}
|
|
22
|
+
/** URL argument type for fetchy functions. */
|
|
23
|
+
type InputArg = string | URL | Request | null;
|
|
24
|
+
/** Internal retry-related options extracted from RetryOptions. */
|
|
25
|
+
type InternalRetry = Pick<Options, "zinterval" | "zmaxInterval" | "zmaxAttempts" | "zonTimeout" | "znoIdempotent" | "zstatusCodes" | "zrespects">;
|
|
23
26
|
/**
|
|
24
|
-
* Error thrown when HTTP response has a non-OK status code (4xx, 5xx
|
|
25
|
-
* Only thrown when
|
|
27
|
+
* Error thrown when HTTP response has a non-OK status code (4xx, 5xx).
|
|
28
|
+
* Only thrown when `native` option is set to false (default behavior).
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
28
31
|
* ```ts
|
|
29
32
|
* try {
|
|
30
|
-
* await fetchy("https://api.example.com/data"
|
|
31
|
-
* throwError: { onErrorStatus: true }
|
|
32
|
-
* });
|
|
33
|
+
* await fetchy("https://api.example.com/data");
|
|
33
34
|
* } catch (error) {
|
|
34
35
|
* if (error instanceof HTTPStatusError) {
|
|
35
|
-
* console.error(
|
|
36
|
+
* console.error(`HTTP ${error.status}:`, error.message);
|
|
37
|
+
* console.error("Response:", error.response);
|
|
36
38
|
* }
|
|
37
39
|
* }
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
42
|
declare class HTTPStatusError extends Error {
|
|
41
|
-
#private;
|
|
42
43
|
status: number;
|
|
43
|
-
|
|
44
|
-
constructor(
|
|
45
|
-
static fromResponse(resp: Response): Promise<HTTPStatusError>;
|
|
44
|
+
response: Response;
|
|
45
|
+
constructor(resp: Response);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* try {
|
|
53
|
-
* await fetchy("https://example.com/redirect", {
|
|
54
|
-
* redirect: "error"
|
|
55
|
-
* });
|
|
56
|
-
* } catch (error) {
|
|
57
|
-
* if (error instanceof RedirectError) {
|
|
58
|
-
* console.error("Unexpected redirect:", error.message);
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
declare class RedirectError extends Error {
|
|
64
|
-
status: number;
|
|
65
|
-
constructor(msg: string, status: number);
|
|
66
|
-
static fromResponse(resp: Response): RedirectError;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* A fluent HTTP client class that provides both instance and static methods for making HTTP requests.
|
|
48
|
+
* A fluent HTTP client that provides methods for making HTTP requests.
|
|
70
49
|
* Supports features like timeout, retry with exponential backoff, automatic header management, and response parsing.
|
|
71
50
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* - Static methods: Call methods directly with URL and options
|
|
51
|
+
* @param options - Configuration options to apply to all requests made with this instance.
|
|
52
|
+
* @returns An object that has Fetchy interface.
|
|
75
53
|
*
|
|
76
54
|
* @example
|
|
77
55
|
* ```ts
|
|
78
|
-
*
|
|
79
|
-
*
|
|
56
|
+
* import { fy } from "@scirexs/fetchy";
|
|
57
|
+
*
|
|
58
|
+
* const client = fy({
|
|
80
59
|
* bearer: "token123",
|
|
81
60
|
* timeout: 10,
|
|
82
|
-
*
|
|
61
|
+
* base: "https://api.example.com"
|
|
83
62
|
* });
|
|
84
|
-
* const user = await client.json<User>("https://api.example.com/user");
|
|
85
|
-
* const posts = await client.json<Post[]>("https://api.example.com/posts");
|
|
86
63
|
*
|
|
87
|
-
*
|
|
88
|
-
* const
|
|
89
|
-
* const response = await Fetchy.fetch("https://api.example.com/endpoint", {
|
|
90
|
-
* body: { key: "value" },
|
|
91
|
-
* timeout: 5
|
|
92
|
-
* });
|
|
64
|
+
* const user = await client.get("/user").json<User>();
|
|
65
|
+
* const posts = await client.get("/posts").json<Post[]>();
|
|
93
66
|
*
|
|
94
67
|
* // Safe mode - returns null on error instead of throwing
|
|
95
|
-
* const result = await
|
|
68
|
+
* const result = await client.sfetch("https://api.example.com/data").json<Data>();
|
|
96
69
|
* if (result !== null) {
|
|
97
70
|
* // Handle successful response
|
|
98
71
|
* }
|
|
99
72
|
* ```
|
|
100
73
|
*/
|
|
101
|
-
declare
|
|
102
|
-
/** Request URL. Used if call fetchy with null. */
|
|
103
|
-
url?: string | URL;
|
|
104
|
-
/** Request body content. Automatically serializes JSON objects. */
|
|
105
|
-
body?: FetchyBody;
|
|
106
|
-
/** Request timeout in seconds. Default is 15 seconds. */
|
|
107
|
-
timeout?: number;
|
|
108
|
-
/** Retry configuration. Set to false to disable retry functionality. */
|
|
109
|
-
retry?: false | RetryOptions;
|
|
110
|
-
/** Bearer token for Authorization header. Automatically adds "Bearer " prefix. */
|
|
111
|
-
bearer?: string;
|
|
112
|
-
/** Initial jitter delay in seconds before sending the request. Adds randomness to prevent thundering herd. */
|
|
113
|
-
delay?: number;
|
|
114
|
-
/** If receive response, does not throw error same with native fetch. */
|
|
115
|
-
native?: true;
|
|
116
|
-
constructor(options?: FetchyOptions);
|
|
117
|
-
/** Call fetchy with instance options. */
|
|
118
|
-
fetch(url?: Input | null): Promise<Response>;
|
|
119
|
-
/** Call fetchy with instance options and parsing as text. */
|
|
120
|
-
text(url?: Input | null): Promise<string>;
|
|
121
|
-
/** Call fetchy with instance options and parsing as json. */
|
|
122
|
-
json<T>(url?: Input | null): Promise<T>;
|
|
123
|
-
/** Call fetchy with instance options and parsing as Uint8Array. */
|
|
124
|
-
bytes(url?: Input | null): Promise<Uint8Array<ArrayBuffer>>;
|
|
125
|
-
/** Call fetchy with instance options and parsing as Blob. */
|
|
126
|
-
blob(url?: Input | null): Promise<Blob>;
|
|
127
|
-
/** Call fetchy with instance options and parsing as ArrayBuffer. */
|
|
128
|
-
buffer(url?: Input | null): Promise<ArrayBuffer>;
|
|
129
|
-
/** Call sfetchy with instance options. */
|
|
130
|
-
safe(url?: Input | null): Promise<Response | null>;
|
|
131
|
-
/** Call sfetchy with instance options and parsing as text. */
|
|
132
|
-
stext(url?: Input | null): Promise<string | null>;
|
|
133
|
-
/** Call sfetchy with instance options and parsing as json. */
|
|
134
|
-
sjson<T>(url?: Input | null): Promise<T | null>;
|
|
135
|
-
/** Call sfetchy with instance options and parsing as Uint8Array. */
|
|
136
|
-
sbytes(url?: Input | null): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
137
|
-
/** Call sfetchy with instance options and parsing as Blob. */
|
|
138
|
-
sblob(url?: Input | null): Promise<Blob | null>;
|
|
139
|
-
/** Call sfetchy with instance options and parsing as ArrayBuffer. */
|
|
140
|
-
sbuffer(url?: Input | null): Promise<ArrayBuffer | null>;
|
|
141
|
-
/** Call fetchy. */
|
|
142
|
-
static fetch(url: Input | null, options?: FetchyOptions): Promise<Response>;
|
|
143
|
-
/** Call fetchy with parsing as text. */
|
|
144
|
-
static text(url: Input | null, options?: FetchyOptions): Promise<string>;
|
|
145
|
-
/** Call fetchy with parsing as json. */
|
|
146
|
-
static json<T>(url: Input | null, options?: FetchyOptions): Promise<T>;
|
|
147
|
-
/** Call fetchy with parsing as Uint8Array. */
|
|
148
|
-
static bytes(url: Input | null, options?: FetchyOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
149
|
-
/** Call fetchy with parsing as Blob. */
|
|
150
|
-
static blob(url: Input | null, options?: FetchyOptions): Promise<Blob>;
|
|
151
|
-
/** Call fetchy with parsing as ArrayBuffer. */
|
|
152
|
-
static buffer(url: Input | null, options?: FetchyOptions): Promise<ArrayBuffer>;
|
|
153
|
-
/** Call sfetchy. */
|
|
154
|
-
static safe(url: Input | null, options?: FetchyOptions): Promise<Response | null>;
|
|
155
|
-
/** Call sfetchy with parsing as text. */
|
|
156
|
-
static stext(url: Input | null, options?: FetchyOptions): Promise<string | null>;
|
|
157
|
-
/** Call sfetchy with parsing as json. */
|
|
158
|
-
static sjson<T>(url: Input | null, options?: FetchyOptions): Promise<T | null>;
|
|
159
|
-
/** Call sfetchy with parsing as Uint8Array. */
|
|
160
|
-
static sbytes(url: Input | null, options?: FetchyOptions): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
161
|
-
/** Call sfetchy with parsing as Blob. */
|
|
162
|
-
static sblob(url: Input | null, options?: FetchyOptions): Promise<Blob | null>;
|
|
163
|
-
/** Call sfetchy with parsing as ArrayBuffer. */
|
|
164
|
-
static sbuffer(url: Input | null, options?: FetchyOptions): Promise<ArrayBuffer | null>;
|
|
165
|
-
}
|
|
74
|
+
declare function fy(options?: FetchyOptions): Fetchy;
|
|
166
75
|
/**
|
|
167
76
|
* Performs an HTTP request with safe error handling that returns null on failure.
|
|
168
|
-
* Automatically parses the response body based on the specified parse method.
|
|
169
77
|
* Unlike `fetchy`, this function never throws errors - it returns null for any failure.
|
|
170
78
|
*
|
|
171
79
|
* This is useful when you want to handle errors gracefully without try-catch blocks,
|
|
@@ -173,59 +81,46 @@ declare class Fetchy implements FetchyOptions {
|
|
|
173
81
|
*
|
|
174
82
|
* @param url - The URL to fetch. Can be a string, URL object, Request object, or null (uses options.url).
|
|
175
83
|
* @param options - Configuration options for the request (timeout, retry, headers, etc.).
|
|
176
|
-
* @
|
|
177
|
-
* Supported values: "json", "text", "bytes", "blob", "buffer".
|
|
178
|
-
* @returns Parsed response body, Response object, or null if request fails or response is not OK.
|
|
84
|
+
* @returns Promise that resolves to Response object or null if request fails.
|
|
179
85
|
*
|
|
180
86
|
* @example
|
|
181
87
|
* ```ts
|
|
182
88
|
* import { sfetchy } from "@scirexs/fetchy";
|
|
183
89
|
*
|
|
184
90
|
* // Returns null instead of throwing on error
|
|
185
|
-
* const
|
|
186
|
-
* if (
|
|
91
|
+
* const response = await sfetchy("https://api.example.com/user");
|
|
92
|
+
* if (response === null) {
|
|
187
93
|
* console.log("Request failed, using default data");
|
|
188
94
|
* // Handle failure case
|
|
95
|
+
* } else {
|
|
96
|
+
* const data = await response.json();
|
|
189
97
|
* }
|
|
190
98
|
*
|
|
191
|
-
* //
|
|
192
|
-
*
|
|
193
|
-
*
|
|
99
|
+
* // Using convenience methods
|
|
100
|
+
* const user = await sfetchy("https://api.example.com/user").json<User>();
|
|
101
|
+
* if (user !== null) {
|
|
102
|
+
* // Handle successful response
|
|
103
|
+
* }
|
|
194
104
|
*
|
|
195
105
|
* // Text response - returns null on any error
|
|
196
|
-
* const text = await sfetchy("https://example.com/page"
|
|
106
|
+
* const text = await sfetchy("https://example.com/page").text();
|
|
197
107
|
*
|
|
198
108
|
* // Binary data with safe error handling
|
|
199
|
-
* const bytes = await sfetchy("https://example.com/image.png"
|
|
109
|
+
* const bytes = await sfetchy("https://example.com/image.png").bytes();
|
|
200
110
|
* if (bytes !== null) {
|
|
201
111
|
* // Process binary data
|
|
202
112
|
* }
|
|
203
|
-
*
|
|
204
|
-
* // Raw Response object (no parsing)
|
|
205
|
-
* const response = await sfetchy("https://api.example.com/data");
|
|
206
|
-
* if (response !== null && response.ok) {
|
|
207
|
-
* // Handle response
|
|
208
|
-
* }
|
|
209
113
|
* ```
|
|
210
114
|
*/
|
|
211
|
-
declare function sfetchy(url
|
|
212
|
-
declare function sfetchy<T>(url: Input | null, options: FetchyOptions | undefined, parse: "json"): Promise<T | null>;
|
|
213
|
-
declare function sfetchy(url: Input | null, options: FetchyOptions | undefined, parse: "text"): Promise<string | null>;
|
|
214
|
-
declare function sfetchy(url: Input | null, options: FetchyOptions | undefined, parse: "bytes"): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
215
|
-
declare function sfetchy(url: Input | null, options: FetchyOptions | undefined, parse: "blob"): Promise<Blob | null>;
|
|
216
|
-
declare function sfetchy(url: Input | null, options: FetchyOptions | undefined, parse: "buffer"): Promise<ArrayBuffer | null>;
|
|
115
|
+
declare function sfetchy(url?: string | URL | Request | null, options?: FetchyOptions): FetchySafeResponse;
|
|
217
116
|
/**
|
|
218
117
|
* Performs an HTTP request with enhanced features like timeout, retry, and automatic header management.
|
|
219
118
|
* Throws errors on failure unless configured otherwise via the `native` option.
|
|
220
|
-
* Automatically parses the response body based on the specified parse method.
|
|
221
119
|
*
|
|
222
120
|
* @param url - The URL to fetch. Can be a string, URL object, Request object, or null (uses options.url).
|
|
223
121
|
* @param options - Configuration options for the request (timeout, retry, headers, body, etc.).
|
|
224
|
-
* @
|
|
225
|
-
*
|
|
226
|
-
* @returns Parsed response body or Response object.
|
|
227
|
-
* @throws {HTTPStatusError} When response status is not OK (4xx, 5xx) - default behavior.
|
|
228
|
-
* @throws {RedirectError} When redirect is encountered and redirect option is set to "error".
|
|
122
|
+
* @returns Promise that resolves to Response object.
|
|
123
|
+
* @throws {HTTPStatusError} When response status is not OK (4xx, 5xx) and native mode is disabled.
|
|
229
124
|
* @throws {TypeError} When network error occurs (e.g., DNS resolution failure, connection refused).
|
|
230
125
|
* @throws {DOMException} When request is aborted via timeout or AbortSignal.
|
|
231
126
|
*
|
|
@@ -233,95 +128,127 @@ declare function sfetchy(url: Input | null, options: FetchyOptions | undefined,
|
|
|
233
128
|
* ```ts
|
|
234
129
|
* import { fetchy } from "@scirexs/fetchy";
|
|
235
130
|
*
|
|
236
|
-
* // Simple GET request
|
|
131
|
+
* // Simple GET request
|
|
237
132
|
* const response = await fetchy("https://api.example.com/data");
|
|
238
|
-
*
|
|
239
|
-
* const data = await response.json();
|
|
240
|
-
* }
|
|
133
|
+
* const data = await response.json();
|
|
241
134
|
*
|
|
242
|
-
* //
|
|
243
|
-
*
|
|
244
|
-
* const user = await fetchy<User>("https://api.example.com/user", {}, "json");
|
|
135
|
+
* // Using convenience methods
|
|
136
|
+
* const user = await fetchy("https://api.example.com/user").json<User>();
|
|
245
137
|
*
|
|
246
138
|
* // POST request with JSON body and authentication
|
|
247
139
|
* const result = await fetchy("https://api.example.com/create", {
|
|
140
|
+
* method: MPOST,
|
|
248
141
|
* body: { name: "John", age: 30 },
|
|
249
142
|
* bearer: "your-token-here"
|
|
250
|
-
* }
|
|
143
|
+
* }).json();
|
|
251
144
|
*
|
|
252
145
|
* // With retry, timeout, and error handling
|
|
253
146
|
* try {
|
|
254
147
|
* const data = await fetchy("https://api.example.com/data", {
|
|
255
148
|
* timeout: 10,
|
|
256
|
-
* retry: {
|
|
257
|
-
* }
|
|
149
|
+
* retry: { maxAttempts: 5, interval: 2, maxInterval: 30 }
|
|
150
|
+
* }).json();
|
|
258
151
|
* } catch (error) {
|
|
259
152
|
* if (error instanceof HTTPStatusError) {
|
|
260
|
-
* console.error(`HTTP ${error.status}
|
|
153
|
+
* console.error(`HTTP ${error.status}:`, error.message);
|
|
261
154
|
* }
|
|
262
155
|
* }
|
|
263
156
|
*
|
|
264
|
-
* // Native error mode -
|
|
157
|
+
* // Native error mode - does not throw HTTPStatusError
|
|
265
158
|
* const response = await fetchy("https://api.example.com/data", {
|
|
266
159
|
* native: true
|
|
267
160
|
* });
|
|
268
161
|
* ```
|
|
269
162
|
*/
|
|
270
|
-
declare function fetchy(url
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
163
|
+
declare function fetchy(url?: string | URL | Request | null, options?: FetchyOptions): FetchyResponse;
|
|
164
|
+
/**
|
|
165
|
+
* Sets global default options for all fetchy instances.
|
|
166
|
+
* These options will be merged with instance-specific options, with instance options taking precedence.
|
|
167
|
+
*
|
|
168
|
+
* @param options - Default configuration options to apply globally.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* import { setFetchy, fetchy } from "@scirexs/fetchy";
|
|
173
|
+
*
|
|
174
|
+
* // Set global defaults
|
|
175
|
+
* setFetchy({
|
|
176
|
+
* timeout: 30,
|
|
177
|
+
* retry: { maxAttempts: 5 },
|
|
178
|
+
* bearer: "global-token"
|
|
179
|
+
* });
|
|
180
|
+
*
|
|
181
|
+
* // All subsequent requests use these defaults
|
|
182
|
+
* await fetchy("https://api.example.com/data");
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
declare function setFetchy(options: FetchyOptions): void;
|
|
186
|
+
/** Main procedure for fetchy and sfetchy. @internal */
|
|
187
|
+
declare function _main(url: InputArg | undefined, options: FetchyOptions | undefined, safe?: undefined): FetchyResponse;
|
|
188
|
+
declare function _main(url: InputArg | undefined, options: FetchyOptions | undefined, safe: true): FetchySafeResponse;
|
|
189
|
+
/** Creates new options object with specified HTTP method and temporal options. @internal */
|
|
190
|
+
declare function _buildOption(options?: FetchyOptions, temp?: FetchyOptions, method?: string): FetchyOptions;
|
|
191
|
+
/** Type guard: checks if value is a string. @internal */
|
|
279
192
|
declare function _isString(v: unknown): v is string;
|
|
280
|
-
/**
|
|
193
|
+
/** Type guard: checks if value is a number. @internal */
|
|
281
194
|
declare function _isNumber(v: unknown): v is number;
|
|
282
|
-
/**
|
|
195
|
+
/** Type guard: checks if value is a boolean. @internal */
|
|
283
196
|
declare function _isBool(v: unknown): v is boolean;
|
|
284
|
-
/**
|
|
285
|
-
declare function
|
|
286
|
-
/**
|
|
287
|
-
declare function
|
|
288
|
-
/**
|
|
289
|
-
declare function
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
197
|
+
/** Type guard: checks if value is a ReadableStream. @internal */
|
|
198
|
+
declare function _isStream(v: unknown): v is ReadableStream;
|
|
199
|
+
/** Type guard: checks if value is a Request. @internal */
|
|
200
|
+
declare function _isRequest(v: unknown): v is Request;
|
|
201
|
+
/** Type guard: checks if value is a plain object (not array, null, or other object types). @internal */
|
|
202
|
+
declare function _isPlain(v: unknown): v is object;
|
|
203
|
+
/** Corrects a number to be non-negative, using default if invalid. @internal */
|
|
204
|
+
declare function _assign<T extends {}>(target: T, source: unknown): T;
|
|
205
|
+
/** Corrects a number to be non-negative, using default if invalid. @internal */
|
|
206
|
+
declare function _correctNumber(dflt: number, num?: number): number;
|
|
207
|
+
/** Converts FetchyOptions to standard RequestInit format. @internal */
|
|
208
|
+
declare function _getRequestInit(url?: InputArg, options?: FetchyOptions): RequestInit;
|
|
209
|
+
/** Converts FetchyBody to standard BodyInit format. @internal */
|
|
210
|
+
declare function _getBody(body?: FetchyBody): Record<string, BodyInit> | null;
|
|
211
|
+
/** Checks if value should be treated as JSON for serialization. @internal */
|
|
298
212
|
declare function _isJSONObject(arg?: FetchyBody): boolean;
|
|
299
|
-
/** Constructs request headers with automatic Content-Type and Authorization. */
|
|
300
|
-
declare function _getHeaders(options?: FetchyOptions): Headers;
|
|
301
|
-
/**
|
|
302
|
-
declare function
|
|
303
|
-
/**
|
|
304
|
-
declare function
|
|
305
|
-
/**
|
|
306
|
-
declare function
|
|
307
|
-
/**
|
|
213
|
+
/** Constructs request headers with automatic Content-Type and Authorization. @internal */
|
|
214
|
+
declare function _getHeaders(options?: FetchyOptions, reqHeaders?: Headers | null): Headers;
|
|
215
|
+
/** Checks if header is absent in both option headers and request headers. @internal */
|
|
216
|
+
declare function _isNoHeader(name: string, optionHeader: Headers, reqHeaders?: Headers | null): boolean;
|
|
217
|
+
/** Determines Content-Type header based on body type. @internal */
|
|
218
|
+
declare function _getContentType(body?: FetchyBody): string;
|
|
219
|
+
/** Checks if Content-Type should be handled by native fetch. @internal */
|
|
220
|
+
declare function _handleByNative(body?: FetchyBody): boolean;
|
|
221
|
+
/** Extracts retry-related options with defaults. @internal */
|
|
222
|
+
declare function _getRetryOption(init: RequestInit, options?: RetryOptions | false): InternalRetry;
|
|
223
|
+
/** Converts FetchyOptions to internal Options format with validated values. @internal */
|
|
224
|
+
declare function _getOptions(init: RequestInit, url?: InputArg, options?: FetchyOptions): Options;
|
|
225
|
+
/** Merges multiple AbortSignals into one. @internal */
|
|
226
|
+
declare function _mergeSignals(s1?: AbortSignal | null, s2?: AbortSignal | null): AbortSignal | undefined;
|
|
227
|
+
/** Creates timeout signal and merges with existing signal. @internal */
|
|
228
|
+
declare function _withTimeout(opts: Options): AbortSignal | undefined;
|
|
229
|
+
/** Waits for specified seconds with optional randomization. @internal */
|
|
308
230
|
declare function _wait(sec: number, random?: boolean): Promise<void>;
|
|
309
|
-
/** Checks if
|
|
310
|
-
declare function
|
|
311
|
-
/**
|
|
312
|
-
declare function
|
|
313
|
-
/**
|
|
314
|
-
declare function
|
|
315
|
-
/**
|
|
316
|
-
declare function
|
|
317
|
-
/** Parses
|
|
318
|
-
declare function
|
|
319
|
-
/**
|
|
320
|
-
declare function
|
|
321
|
-
/**
|
|
322
|
-
declare function
|
|
323
|
-
/**
|
|
324
|
-
declare function
|
|
325
|
-
/** Executes fetch with
|
|
326
|
-
declare function
|
|
231
|
+
/** Checks if HTTP status code indicates an error. @internal */
|
|
232
|
+
declare function _isHttpError(stat: number): boolean;
|
|
233
|
+
/** Determines whether to retry based on conditions and waits before next attempt. @internal */
|
|
234
|
+
declare function _shouldRetry(count: number, opts: Options, r: Response | unknown, fn?: unknown): Promise<boolean>;
|
|
235
|
+
/** Calculates next retry interval using exponential backoff or response headers. @internal */
|
|
236
|
+
declare function _getNextInterval(count: number, opts: Options, headers: Headers): number;
|
|
237
|
+
/** Finds and parses retry timing from response headers. @internal */
|
|
238
|
+
declare function _findRetryHeader(opts: Options, headers: Headers): number | undefined;
|
|
239
|
+
/** Parses retry header value to seconds. @internal */
|
|
240
|
+
declare function _parseRetryHeader(value?: string | null): number;
|
|
241
|
+
/** Creates new Request with ReadableStream body if present in options. @internal */
|
|
242
|
+
declare function _includeStream(req: Request, opts: Options): Request;
|
|
243
|
+
/** Creates Request object from various input types. @internal */
|
|
244
|
+
declare function _createRequest(opts: Options, url?: InputArg): Request;
|
|
245
|
+
/** Creates request cloning function with abort handling. @internal */
|
|
246
|
+
declare function _cloneRequestF(req: Request): (cancel?: boolean) => Promise<Request>;
|
|
247
|
+
/** Executes fetch with retry logic and exponential backoff. @internal */
|
|
248
|
+
declare function _fetchWithRetry(url: InputArg | undefined, init: RequestInit, opts: Options, safe: boolean): Promise<Response | null>;
|
|
249
|
+
/** Executes fetch with initial jitter delay. @internal */
|
|
250
|
+
declare function _fetchWithJitter(req: Request, init: RequestInit, opts: Options): Promise<Response>;
|
|
251
|
+
/** Creates promise-like object with convenience parsing methods. @internal */
|
|
252
|
+
declare function _makeFetchyResponse(resp: Promise<Response | null>, safe: boolean): FetchyResponse | FetchySafeResponse;
|
|
253
|
+
declare function _genMethods(obj: object, safe?: boolean): void;
|
|
327
254
|
//# 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,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,OAAO,EACP,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,QAAQ,EACR,UAAU,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,MAAM,EACN,EAAE,EACF,eAAe,EACf,SAAS,EACT,OAAO,GACR,CAAC;AAEF,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAatH,+CAA+C;AAC/C,QAAA,MAAM,QAAQ,EAAE,OAWN,CAAC;AASX,qEAAqE;AACrE,UAAU,OAAO;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM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AAC,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,kBAAkB,CAa/G;AACD,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,QAS/C"}
|
package/types/mod.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Exports main functions and types for external.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
6
|
-
export type { FetchyBody, FetchyOptions, JSONValue, RetryOptions } from "./types.js";
|
|
5
|
+
export { fetchy, fy, HTTPStatusError, setFetchy, sfetchy } from "./main.js";
|
|
6
|
+
export type { FetchyBody, FetchyOptions, FetchyResponse, FetchySafeResponse, JSONValue, RetryOptions } from "./types.js";
|
|
7
7
|
//# sourceMappingURL=mod.d.ts.map
|