@ahoo-wang/fetcher 1.2.5 → 1.2.8
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 +1 -7
- package/README.zh-CN.md +1 -7
- package/dist/fetchExchange.d.ts +24 -1
- package/dist/fetchExchange.d.ts.map +1 -1
- package/dist/index.es.js +110 -82
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/requestBodyInterceptor.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -202,13 +202,7 @@ const success = fetcher.interceptors.request.use({
|
|
|
202
202
|
name: 'auth-interceptor',
|
|
203
203
|
order: 100,
|
|
204
204
|
intercept(exchange) {
|
|
205
|
-
exchange.request =
|
|
206
|
-
...exchange.request,
|
|
207
|
-
headers: {
|
|
208
|
-
...exchange.request.headers,
|
|
209
|
-
Authorization: 'Bearer ' + getAuthToken(),
|
|
210
|
-
},
|
|
211
|
-
};
|
|
205
|
+
exchange.request.headers.Authorization = 'Bearer ' + getAuthToken();
|
|
212
206
|
},
|
|
213
207
|
});
|
|
214
208
|
|
package/README.zh-CN.md
CHANGED
|
@@ -191,13 +191,7 @@ const success = fetcher.interceptors.request.use({
|
|
|
191
191
|
name: 'auth-interceptor',
|
|
192
192
|
order: 100,
|
|
193
193
|
intercept(exchange) {
|
|
194
|
-
exchange.request =
|
|
195
|
-
...exchange.request,
|
|
196
|
-
headers: {
|
|
197
|
-
...exchange.request.headers,
|
|
198
|
-
Authorization: 'Bearer ' + getAuthToken(),
|
|
199
|
-
},
|
|
200
|
-
};
|
|
194
|
+
exchange.request.headers.Authorization = 'Bearer ' + getAuthToken();
|
|
201
195
|
},
|
|
202
196
|
});
|
|
203
197
|
|
package/dist/fetchExchange.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fetcher } from './fetcher';
|
|
2
|
-
import { FetchRequest } from './fetchRequest';
|
|
2
|
+
import { FetchRequest, RequestHeaders } from './fetchRequest';
|
|
3
|
+
import { UrlParams } from './urlBuilder';
|
|
3
4
|
/**
|
|
4
5
|
* Container for HTTP request/response data that flows through the interceptor chain.
|
|
5
6
|
*
|
|
@@ -74,6 +75,28 @@ export declare class FetchExchange {
|
|
|
74
75
|
*/
|
|
75
76
|
attributes: Record<string, any>;
|
|
76
77
|
constructor(fetcher: Fetcher, request: FetchRequest, response?: Response, error?: Error | any);
|
|
78
|
+
/**
|
|
79
|
+
* Ensures that request headers object exists, creating it if necessary.
|
|
80
|
+
*
|
|
81
|
+
* This method checks if the request headers object is present and initializes
|
|
82
|
+
* it as an empty object if it's missing. This guarantees that headers can
|
|
83
|
+
* be safely accessed and modified after calling this method.
|
|
84
|
+
*
|
|
85
|
+
* @returns The request headers object, guaranteed to be non-null
|
|
86
|
+
*/
|
|
87
|
+
ensureRequestHeaders(): RequestHeaders;
|
|
88
|
+
/**
|
|
89
|
+
* Ensures that request URL parameters object exists with all required properties,
|
|
90
|
+
* creating them if necessary.
|
|
91
|
+
*
|
|
92
|
+
* This method checks if the request URL parameters object is present and initializes
|
|
93
|
+
* it with empty path and query objects if it's missing. It also ensures that both
|
|
94
|
+
* path and query sub-objects exist. This guarantees that URL parameters can be
|
|
95
|
+
* safely accessed and modified after calling this method.
|
|
96
|
+
*
|
|
97
|
+
* @returns The request URL parameters object with guaranteed non-null path and query properties
|
|
98
|
+
*/
|
|
99
|
+
ensureRequestUrlParams(): Required<UrlParams>;
|
|
77
100
|
/**
|
|
78
101
|
* Checks if the exchange has an error.
|
|
79
102
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchExchange.d.ts","sourceRoot":"","sources":["../src/fetchExchange.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchExchange.d.ts","sourceRoot":"","sources":["../src/fetchExchange.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAE/B;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,SAAS,CAAC;IAE/B;;;;;;;;;;;;;OAaG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAGnC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,YAAY,EACrB,QAAQ,CAAC,EAAE,QAAQ,EACnB,KAAK,CAAC,EAAE,KAAK,GAAG,GAAG;IAQrB;;;;;;;;OAQG;IACH,oBAAoB,IAAI,cAAc;IAOtC;;;;;;;;;;OAUG;IACH,sBAAsB,IAAI,QAAQ,CAAC,SAAS,CAAC;IAgB7C;;;;OAIG;IACH,QAAQ,IAAI,OAAO;IAInB;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;;;OASG;IACH,IAAI,gBAAgB,IAAI,QAAQ,CAQ/B;CACF"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(r) {
|
|
2
2
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(r);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function F(r, e) {
|
|
5
|
+
return S(e) ? e : e ? r.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : r;
|
|
6
6
|
}
|
|
7
7
|
var U = /* @__PURE__ */ ((r) => (r[r.UriTemplate = 0] = "UriTemplate", r[r.Express = 1] = "Express", r))(U || {});
|
|
8
8
|
function D(r) {
|
|
9
9
|
return r === 1 ? C : L;
|
|
10
10
|
}
|
|
11
11
|
function _(r, e, t) {
|
|
12
|
-
return t ? r.replace(e, (s,
|
|
13
|
-
const i = t[
|
|
12
|
+
return t ? r.replace(e, (s, n) => {
|
|
13
|
+
const i = t[n];
|
|
14
14
|
if (i === void 0)
|
|
15
|
-
throw new Error(`Missing required path parameter: ${
|
|
15
|
+
throw new Error(`Missing required path parameter: ${n}`);
|
|
16
16
|
return encodeURIComponent(i);
|
|
17
17
|
}) : r;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function g(r, e) {
|
|
20
20
|
const t = [];
|
|
21
21
|
let s;
|
|
22
22
|
for (; (s = e.exec(r)) !== null; )
|
|
@@ -48,7 +48,7 @@ const a = class a {
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
extractPathParams(e) {
|
|
51
|
-
return
|
|
51
|
+
return g(e, a.PATH_PARAM_REGEX);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Replaces placeholders in the URL with path parameters.
|
|
@@ -91,8 +91,8 @@ const a = class a {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
a.PATH_PARAM_REGEX = /{([^}]+)}/g;
|
|
94
|
-
let
|
|
95
|
-
const L = new
|
|
94
|
+
let T = a;
|
|
95
|
+
const L = new T(), h = class h {
|
|
96
96
|
/**
|
|
97
97
|
* Extracts path parameters from an Express-style URL string.
|
|
98
98
|
*
|
|
@@ -113,7 +113,7 @@ const L = new m(), h = class h {
|
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
115
|
extractPathParams(e) {
|
|
116
|
-
return
|
|
116
|
+
return g(e, h.PATH_PARAM_REGEX);
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Replaces Express-style placeholders in the URL with path parameters.
|
|
@@ -194,13 +194,13 @@ class v {
|
|
|
194
194
|
* ```
|
|
195
195
|
*/
|
|
196
196
|
build(e, t) {
|
|
197
|
-
const s = t?.path,
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
|
|
197
|
+
const s = t?.path, n = t?.query, i = F(this.baseURL, e);
|
|
198
|
+
let o = this.urlTemplateResolver.resolve(i, s);
|
|
199
|
+
if (n) {
|
|
200
|
+
const c = new URLSearchParams(n).toString();
|
|
201
|
+
c && (o += "?" + c);
|
|
202
202
|
}
|
|
203
|
-
return
|
|
203
|
+
return o;
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* Resolves a complete URL from a FetchRequest.
|
|
@@ -245,28 +245,28 @@ async function M(r) {
|
|
|
245
245
|
const e = r.url, t = r.timeout, s = r;
|
|
246
246
|
if (!t)
|
|
247
247
|
return fetch(e, s);
|
|
248
|
-
const
|
|
248
|
+
const n = new AbortController(), i = {
|
|
249
249
|
...s,
|
|
250
|
-
signal:
|
|
250
|
+
signal: n.signal
|
|
251
251
|
};
|
|
252
|
-
let
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
|
|
252
|
+
let o = null;
|
|
253
|
+
const c = new Promise((se, N) => {
|
|
254
|
+
o = setTimeout(() => {
|
|
255
|
+
o && clearTimeout(o);
|
|
256
|
+
const q = new y(r);
|
|
257
|
+
n.abort(q), N(q);
|
|
258
258
|
}, t);
|
|
259
259
|
});
|
|
260
260
|
try {
|
|
261
|
-
return await Promise.race([fetch(e, i),
|
|
261
|
+
return await Promise.race([fetch(e, i), c]);
|
|
262
262
|
} finally {
|
|
263
|
-
|
|
263
|
+
o && clearTimeout(o);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
const H = "UrlResolveInterceptor",
|
|
266
|
+
const H = "UrlResolveInterceptor", w = Number.MIN_SAFE_INTEGER + 1e3;
|
|
267
267
|
class B {
|
|
268
268
|
constructor() {
|
|
269
|
-
this.name = H, this.order =
|
|
269
|
+
this.name = H, this.order = w;
|
|
270
270
|
}
|
|
271
271
|
/**
|
|
272
272
|
* Resolves the final URL by combining the base URL, path parameters, and query parameters.
|
|
@@ -278,12 +278,12 @@ class B {
|
|
|
278
278
|
t.url = e.fetcher.urlBuilder.resolveRequestUrl(t);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
var
|
|
282
|
-
const
|
|
281
|
+
var u = /* @__PURE__ */ ((r) => (r.GET = "GET", r.POST = "POST", r.PUT = "PUT", r.DELETE = "DELETE", r.PATCH = "PATCH", r.HEAD = "HEAD", r.OPTIONS = "OPTIONS", r))(u || {});
|
|
282
|
+
const ne = "Content-Type", E = class E {
|
|
283
283
|
};
|
|
284
284
|
E.APPLICATION_JSON = "application/json", E.TEXT_EVENT_STREAM = "text/event-stream";
|
|
285
285
|
let d = E;
|
|
286
|
-
const $ = "RequestBodyInterceptor", j =
|
|
286
|
+
const $ = "RequestBodyInterceptor", j = w + 1e3;
|
|
287
287
|
class X {
|
|
288
288
|
constructor() {
|
|
289
289
|
this.name = $, this.order = j;
|
|
@@ -330,10 +330,9 @@ class X {
|
|
|
330
330
|
if (t.body === void 0 || t.body === null || typeof t.body != "object" || t.body instanceof ArrayBuffer || ArrayBuffer.isView(t.body) || // Includes TypedArray and DataView
|
|
331
331
|
t.body instanceof Blob || t.body instanceof File || t.body instanceof URLSearchParams || t.body instanceof FormData || t.body instanceof ReadableStream)
|
|
332
332
|
return;
|
|
333
|
-
|
|
334
|
-
s
|
|
335
|
-
|
|
336
|
-
o["Content-Type"] || (o["Content-Type"] = d.APPLICATION_JSON), e.request = s;
|
|
333
|
+
e.request.body = JSON.stringify(t.body);
|
|
334
|
+
const s = e.ensureRequestHeaders();
|
|
335
|
+
s["Content-Type"] || (s["Content-Type"] = d.APPLICATION_JSON);
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
338
|
const x = "FetchInterceptor", V = Number.MAX_SAFE_INTEGER - 1e3;
|
|
@@ -373,7 +372,7 @@ class k {
|
|
|
373
372
|
function p(r, e) {
|
|
374
373
|
return e ? r.filter(e).sort((t, s) => t.order - s.order) : [...r].sort((t, s) => t.order - s.order);
|
|
375
374
|
}
|
|
376
|
-
class
|
|
375
|
+
class R {
|
|
377
376
|
/**
|
|
378
377
|
* Initializes a new InterceptorRegistry instance.
|
|
379
378
|
*
|
|
@@ -520,7 +519,7 @@ class Q {
|
|
|
520
519
|
throw new I(e);
|
|
521
520
|
}
|
|
522
521
|
}
|
|
523
|
-
class
|
|
522
|
+
class m extends l {
|
|
524
523
|
/**
|
|
525
524
|
* Creates a new ExchangeError instance.
|
|
526
525
|
*
|
|
@@ -529,18 +528,18 @@ class R extends l {
|
|
|
529
528
|
*/
|
|
530
529
|
constructor(e, t) {
|
|
531
530
|
const s = t || e.error?.message || e.response?.statusText || `Request to ${e.request.url} failed during exchange`;
|
|
532
|
-
super(s, e.error), this.exchange = e, this.name = "ExchangeError", Object.setPrototypeOf(this,
|
|
531
|
+
super(s, e.error), this.exchange = e, this.name = "ExchangeError", Object.setPrototypeOf(this, m.prototype);
|
|
533
532
|
}
|
|
534
533
|
}
|
|
535
534
|
class K {
|
|
536
535
|
constructor() {
|
|
537
|
-
this.request = new
|
|
536
|
+
this.request = new R([
|
|
538
537
|
new B(),
|
|
539
538
|
new X(),
|
|
540
539
|
new k()
|
|
541
|
-
]), this.response = new
|
|
540
|
+
]), this.response = new R([
|
|
542
541
|
new Q()
|
|
543
|
-
]), this.error = new
|
|
542
|
+
]), this.error = new R();
|
|
544
543
|
}
|
|
545
544
|
/**
|
|
546
545
|
* Processes a FetchExchange through the interceptor pipeline.
|
|
@@ -634,13 +633,42 @@ class K {
|
|
|
634
633
|
} catch (t) {
|
|
635
634
|
if (e.error = t, await this.error.intercept(e), !e.hasError())
|
|
636
635
|
return e;
|
|
637
|
-
throw new
|
|
636
|
+
throw new m(e);
|
|
638
637
|
}
|
|
639
638
|
}
|
|
640
639
|
}
|
|
641
640
|
class W {
|
|
642
|
-
constructor(e, t, s,
|
|
643
|
-
this.attributes = {}, this.fetcher = e, this.request = t, this.response = s, this.error =
|
|
641
|
+
constructor(e, t, s, n) {
|
|
642
|
+
this.attributes = {}, this.fetcher = e, this.request = t, this.response = s, this.error = n;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Ensures that request headers object exists, creating it if necessary.
|
|
646
|
+
*
|
|
647
|
+
* This method checks if the request headers object is present and initializes
|
|
648
|
+
* it as an empty object if it's missing. This guarantees that headers can
|
|
649
|
+
* be safely accessed and modified after calling this method.
|
|
650
|
+
*
|
|
651
|
+
* @returns The request headers object, guaranteed to be non-null
|
|
652
|
+
*/
|
|
653
|
+
ensureRequestHeaders() {
|
|
654
|
+
return this.request.headers || (this.request.headers = {}), this.request.headers;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Ensures that request URL parameters object exists with all required properties,
|
|
658
|
+
* creating them if necessary.
|
|
659
|
+
*
|
|
660
|
+
* This method checks if the request URL parameters object is present and initializes
|
|
661
|
+
* it with empty path and query objects if it's missing. It also ensures that both
|
|
662
|
+
* path and query sub-objects exist. This guarantees that URL parameters can be
|
|
663
|
+
* safely accessed and modified after calling this method.
|
|
664
|
+
*
|
|
665
|
+
* @returns The request URL parameters object with guaranteed non-null path and query properties
|
|
666
|
+
*/
|
|
667
|
+
ensureRequestUrlParams() {
|
|
668
|
+
return this.request.urlParams || (this.request.urlParams = {
|
|
669
|
+
path: {},
|
|
670
|
+
query: {}
|
|
671
|
+
}), this.request.urlParams.path || (this.request.urlParams.path = {}), this.request.urlParams.query || (this.request.urlParams.query = {}), this.request.urlParams;
|
|
644
672
|
}
|
|
645
673
|
/**
|
|
646
674
|
* Checks if the exchange has an error.
|
|
@@ -670,18 +698,18 @@ class W {
|
|
|
670
698
|
*/
|
|
671
699
|
get requiredResponse() {
|
|
672
700
|
if (!this.response)
|
|
673
|
-
throw new
|
|
701
|
+
throw new m(
|
|
674
702
|
this,
|
|
675
703
|
`Request to ${this.request.url} failed with no response`
|
|
676
704
|
);
|
|
677
705
|
return this.response;
|
|
678
706
|
}
|
|
679
707
|
}
|
|
680
|
-
const
|
|
708
|
+
const P = {
|
|
681
709
|
"Content-Type": d.APPLICATION_JSON
|
|
682
|
-
},
|
|
710
|
+
}, b = {
|
|
683
711
|
baseURL: "",
|
|
684
|
-
headers:
|
|
712
|
+
headers: P
|
|
685
713
|
};
|
|
686
714
|
class Z {
|
|
687
715
|
/**
|
|
@@ -692,8 +720,8 @@ class Z {
|
|
|
692
720
|
*
|
|
693
721
|
* @param options - Configuration options for the Fetcher instance
|
|
694
722
|
*/
|
|
695
|
-
constructor(e =
|
|
696
|
-
this.headers =
|
|
723
|
+
constructor(e = b) {
|
|
724
|
+
this.headers = P, this.urlBuilder = new v(e.baseURL, e.urlTemplateStyle), this.headers = e.headers ?? P, this.timeout = e.timeout, this.interceptors = e.interceptors ?? new K();
|
|
697
725
|
}
|
|
698
726
|
/**
|
|
699
727
|
* Executes an HTTP request with the specified URL and options.
|
|
@@ -729,8 +757,8 @@ class Z {
|
|
|
729
757
|
...e,
|
|
730
758
|
headers: t,
|
|
731
759
|
timeout: G(e.timeout, this.timeout)
|
|
732
|
-
},
|
|
733
|
-
return this.interceptors.exchange(
|
|
760
|
+
}, n = new W(this, s);
|
|
761
|
+
return this.interceptors.exchange(n);
|
|
734
762
|
}
|
|
735
763
|
/**
|
|
736
764
|
* Internal helper method for making HTTP requests with a specific method.
|
|
@@ -760,7 +788,7 @@ class Z {
|
|
|
760
788
|
* @returns Promise that resolves to the HTTP response
|
|
761
789
|
*/
|
|
762
790
|
async get(e, t = {}) {
|
|
763
|
-
return this.methodFetch(
|
|
791
|
+
return this.methodFetch(u.GET, e, t);
|
|
764
792
|
}
|
|
765
793
|
/**
|
|
766
794
|
* Makes a POST HTTP request.
|
|
@@ -772,7 +800,7 @@ class Z {
|
|
|
772
800
|
* @returns Promise that resolves to the HTTP response
|
|
773
801
|
*/
|
|
774
802
|
async post(e, t = {}) {
|
|
775
|
-
return this.methodFetch(
|
|
803
|
+
return this.methodFetch(u.POST, e, t);
|
|
776
804
|
}
|
|
777
805
|
/**
|
|
778
806
|
* Makes a PUT HTTP request.
|
|
@@ -784,7 +812,7 @@ class Z {
|
|
|
784
812
|
* @returns Promise that resolves to the HTTP response
|
|
785
813
|
*/
|
|
786
814
|
async put(e, t = {}) {
|
|
787
|
-
return this.methodFetch(
|
|
815
|
+
return this.methodFetch(u.PUT, e, t);
|
|
788
816
|
}
|
|
789
817
|
/**
|
|
790
818
|
* Makes a DELETE HTTP request.
|
|
@@ -796,7 +824,7 @@ class Z {
|
|
|
796
824
|
* @returns Promise that resolves to the HTTP response
|
|
797
825
|
*/
|
|
798
826
|
async delete(e, t = {}) {
|
|
799
|
-
return this.methodFetch(
|
|
827
|
+
return this.methodFetch(u.DELETE, e, t);
|
|
800
828
|
}
|
|
801
829
|
/**
|
|
802
830
|
* Makes a PATCH HTTP request.
|
|
@@ -808,7 +836,7 @@ class Z {
|
|
|
808
836
|
* @returns Promise that resolves to the HTTP response
|
|
809
837
|
*/
|
|
810
838
|
async patch(e, t = {}) {
|
|
811
|
-
return this.methodFetch(
|
|
839
|
+
return this.methodFetch(u.PATCH, e, t);
|
|
812
840
|
}
|
|
813
841
|
/**
|
|
814
842
|
* Makes a HEAD HTTP request.
|
|
@@ -821,7 +849,7 @@ class Z {
|
|
|
821
849
|
* @returns Promise that resolves to the HTTP response
|
|
822
850
|
*/
|
|
823
851
|
async head(e, t = {}) {
|
|
824
|
-
return this.methodFetch(
|
|
852
|
+
return this.methodFetch(u.HEAD, e, t);
|
|
825
853
|
}
|
|
826
854
|
/**
|
|
827
855
|
* Makes an OPTIONS HTTP request.
|
|
@@ -834,10 +862,10 @@ class Z {
|
|
|
834
862
|
* @returns Promise that resolves to the HTTP response
|
|
835
863
|
*/
|
|
836
864
|
async options(e, t = {}) {
|
|
837
|
-
return this.methodFetch(
|
|
865
|
+
return this.methodFetch(u.OPTIONS, e, t);
|
|
838
866
|
}
|
|
839
867
|
}
|
|
840
|
-
const
|
|
868
|
+
const A = "default";
|
|
841
869
|
class ee {
|
|
842
870
|
constructor() {
|
|
843
871
|
this.registrar = /* @__PURE__ */ new Map();
|
|
@@ -911,7 +939,7 @@ class ee {
|
|
|
911
939
|
* const defaultFetcher = fetcherRegistrar.default;
|
|
912
940
|
*/
|
|
913
941
|
get default() {
|
|
914
|
-
return this.requiredGet(
|
|
942
|
+
return this.requiredGet(A);
|
|
915
943
|
}
|
|
916
944
|
/**
|
|
917
945
|
* Set the default Fetcher instance
|
|
@@ -922,7 +950,7 @@ class ee {
|
|
|
922
950
|
* fetcherRegistrar.default = fetcher;
|
|
923
951
|
*/
|
|
924
952
|
set default(e) {
|
|
925
|
-
this.register(
|
|
953
|
+
this.register(A, e);
|
|
926
954
|
}
|
|
927
955
|
/**
|
|
928
956
|
* Get a copy of all registered fetchers
|
|
@@ -943,7 +971,7 @@ function O(r, e) {
|
|
|
943
971
|
if (!(r === void 0 && e === void 0))
|
|
944
972
|
return e === void 0 ? r : r === void 0 ? e : { ...r, ...e };
|
|
945
973
|
}
|
|
946
|
-
function
|
|
974
|
+
function oe(r, e) {
|
|
947
975
|
if (Object.keys(r).length === 0)
|
|
948
976
|
return e;
|
|
949
977
|
if (Object.keys(e).length === 0)
|
|
@@ -954,16 +982,16 @@ function ne(r, e) {
|
|
|
954
982
|
}, s = {
|
|
955
983
|
...r.headers,
|
|
956
984
|
...e.headers
|
|
957
|
-
},
|
|
985
|
+
}, n = e.method ?? r.method, i = e.body ?? r.body, o = e.timeout ?? r.timeout, c = e.signal ?? r.signal;
|
|
958
986
|
return {
|
|
959
987
|
...r,
|
|
960
988
|
...e,
|
|
961
|
-
method:
|
|
989
|
+
method: n,
|
|
962
990
|
urlParams: t,
|
|
963
991
|
headers: s,
|
|
964
992
|
body: i,
|
|
965
|
-
timeout:
|
|
966
|
-
signal:
|
|
993
|
+
timeout: o,
|
|
994
|
+
signal: c
|
|
967
995
|
};
|
|
968
996
|
}
|
|
969
997
|
class re extends Z {
|
|
@@ -984,17 +1012,17 @@ class re extends Z {
|
|
|
984
1012
|
* headers: { 'Authorization': 'Bearer token' }
|
|
985
1013
|
* });
|
|
986
1014
|
*/
|
|
987
|
-
constructor(e, t =
|
|
1015
|
+
constructor(e, t = b) {
|
|
988
1016
|
super(t), this.name = e, te.register(e, this);
|
|
989
1017
|
}
|
|
990
1018
|
}
|
|
991
|
-
const ie = new re(
|
|
1019
|
+
const ie = new re(A);
|
|
992
1020
|
export {
|
|
993
|
-
|
|
1021
|
+
ne as CONTENT_TYPE_HEADER,
|
|
994
1022
|
d as ContentTypeValues,
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1023
|
+
A as DEFAULT_FETCHER_NAME,
|
|
1024
|
+
b as DEFAULT_OPTIONS,
|
|
1025
|
+
m as ExchangeError,
|
|
998
1026
|
f as ExpressUrlTemplateResolver,
|
|
999
1027
|
x as FETCH_INTERCEPTOR_NAME,
|
|
1000
1028
|
V as FETCH_INTERCEPTOR_ORDER,
|
|
@@ -1004,36 +1032,36 @@ export {
|
|
|
1004
1032
|
Z as Fetcher,
|
|
1005
1033
|
l as FetcherError,
|
|
1006
1034
|
ee as FetcherRegistrar,
|
|
1007
|
-
|
|
1035
|
+
u as HttpMethod,
|
|
1008
1036
|
I as HttpStatusValidationError,
|
|
1009
1037
|
K as InterceptorManager,
|
|
1010
|
-
|
|
1038
|
+
R as InterceptorRegistry,
|
|
1011
1039
|
re as NamedFetcher,
|
|
1012
1040
|
$ as REQUEST_BODY_INTERCEPTOR_NAME,
|
|
1013
1041
|
j as REQUEST_BODY_INTERCEPTOR_ORDER,
|
|
1014
1042
|
X as RequestBodyInterceptor,
|
|
1015
1043
|
H as URL_RESOLVE_INTERCEPTOR_NAME,
|
|
1016
|
-
|
|
1017
|
-
|
|
1044
|
+
w as URL_RESOLVE_INTERCEPTOR_ORDER,
|
|
1045
|
+
T as UriTemplateResolver,
|
|
1018
1046
|
v as UrlBuilder,
|
|
1019
1047
|
B as UrlResolveInterceptor,
|
|
1020
1048
|
U as UrlTemplateStyle,
|
|
1021
1049
|
Y as VALIDATE_STATUS_INTERCEPTOR_NAME,
|
|
1022
1050
|
z as VALIDATE_STATUS_INTERCEPTOR_ORDER,
|
|
1023
1051
|
Q as ValidateStatusInterceptor,
|
|
1024
|
-
|
|
1052
|
+
F as combineURLs,
|
|
1025
1053
|
C as expressUrlTemplateResolver,
|
|
1026
1054
|
ie as fetcher,
|
|
1027
1055
|
te as fetcherRegistrar,
|
|
1028
1056
|
D as getUrlTemplateResolver,
|
|
1029
|
-
|
|
1057
|
+
S as isAbsoluteURL,
|
|
1030
1058
|
O as mergeRecords,
|
|
1031
|
-
|
|
1059
|
+
oe as mergeRequest,
|
|
1032
1060
|
G as resolveTimeout,
|
|
1033
1061
|
M as timeoutFetch,
|
|
1034
1062
|
p as toSorted,
|
|
1035
1063
|
L as uriTemplateResolver,
|
|
1036
|
-
|
|
1064
|
+
g as urlTemplateRegexExtract,
|
|
1037
1065
|
_ as urlTemplateRegexResolve
|
|
1038
1066
|
};
|
|
1039
1067
|
//# sourceMappingURL=index.es.js.map
|