@ahoo-wang/fetcher 1.5.6 → 1.5.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/dist/index.es.js CHANGED
@@ -1,29 +1,29 @@
1
1
  function F(r) {
2
2
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(r);
3
3
  }
4
- function C(r, e) {
5
- return F(e) ? e : e ? r.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : r;
4
+ function C(r, t) {
5
+ return F(t) ? t : t ? r.replace(/\/?\/$/, "") + "/" + t.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 ? v : L;
10
10
  }
11
- function q(r, e, t) {
12
- return t ? r.replace(e, (s, o) => {
13
- const n = t[o];
11
+ function q(r, t, e) {
12
+ return e ? r.replace(t, (s, o) => {
13
+ const n = e[o];
14
14
  if (n === void 0)
15
15
  throw new Error(`Missing required path parameter: ${o}`);
16
16
  return encodeURIComponent(n);
17
17
  }) : r;
18
18
  }
19
- function w(r, e) {
20
- const t = [];
19
+ function w(r, t) {
20
+ const e = [];
21
21
  let s;
22
- for (; (s = e.exec(r)) !== null; )
23
- t.push(s[1]);
24
- return t;
22
+ for (; (s = t.exec(r)) !== null; )
23
+ e.push(s[1]);
24
+ return e;
25
25
  }
26
- const c = class c {
26
+ const a = class a {
27
27
  /**
28
28
  * Extracts path parameters from a URL string.
29
29
  *
@@ -47,10 +47,10 @@ const c = class c {
47
47
  * // noParams = []
48
48
  * ```
49
49
  */
50
- extractPathParams(e) {
50
+ extractPathParams(t) {
51
51
  return w(
52
- e,
53
- c.PATH_PARAM_REGEX
52
+ t,
53
+ a.PATH_PARAM_REGEX
54
54
  );
55
55
  }
56
56
  /**
@@ -89,16 +89,16 @@ const c = class c {
89
89
  * }
90
90
  * ```
91
91
  */
92
- resolve(e, t) {
92
+ resolve(t, e) {
93
93
  return q(
94
- e,
95
- c.PATH_PARAM_REGEX,
96
- t
94
+ t,
95
+ a.PATH_PARAM_REGEX,
96
+ e
97
97
  );
98
98
  }
99
99
  };
100
- c.PATH_PARAM_REGEX = /{([^}]+)}/g;
101
- let f = c;
100
+ a.PATH_PARAM_REGEX = /{([^}]+)}/g;
101
+ let f = a;
102
102
  const L = new f(), h = class h {
103
103
  /**
104
104
  * Extracts path parameters from an Express-style URL string.
@@ -119,9 +119,9 @@ const L = new f(), h = class h {
119
119
  * // noParams = []
120
120
  * ```
121
121
  */
122
- extractPathParams(e) {
122
+ extractPathParams(t) {
123
123
  return w(
124
- e,
124
+ t,
125
125
  h.PATH_PARAM_REGEX
126
126
  );
127
127
  }
@@ -157,18 +157,18 @@ const L = new f(), h = class h {
157
157
  * }
158
158
  * ```
159
159
  */
160
- resolve(e, t) {
160
+ resolve(t, e) {
161
161
  return q(
162
- e,
162
+ t,
163
163
  h.PATH_PARAM_REGEX,
164
- t
164
+ e
165
165
  );
166
166
  }
167
167
  };
168
168
  h.PATH_PARAM_REGEX = /:([^/]+)/g;
169
169
  let P = h;
170
170
  const v = new P();
171
- class G {
171
+ class x {
172
172
  /**
173
173
  * Initializes a new UrlBuilder instance.
174
174
  *
@@ -186,8 +186,8 @@ class G {
186
186
  * const expressUrlBuilder = new UrlBuilder('https://api.example.com', UrlTemplateStyle.Express);
187
187
  * ```
188
188
  */
189
- constructor(e, t) {
190
- this.baseURL = e, this.urlTemplateResolver = D(t);
189
+ constructor(t, e) {
190
+ this.baseURL = t, this.urlTemplateResolver = D(e);
191
191
  }
192
192
  /**
193
193
  * Builds a complete URL, including path parameter replacement and query parameter addition.
@@ -207,12 +207,12 @@ class G {
207
207
  * // Result: https://api.example.com/users/123/posts/456?filter=active&limit=10
208
208
  * ```
209
209
  */
210
- build(e, t) {
211
- const s = t?.path, o = t?.query, n = C(this.baseURL, e);
210
+ build(t, e) {
211
+ const s = e?.path, o = e?.query, n = C(this.baseURL, t);
212
212
  let i = this.urlTemplateResolver.resolve(n, s);
213
213
  if (o) {
214
- const a = new URLSearchParams(o).toString();
215
- a && (i += "?" + a);
214
+ const c = new URLSearchParams(o).toString();
215
+ c && (i += "?" + c);
216
216
  }
217
217
  return i;
218
218
  }
@@ -225,8 +225,8 @@ class G {
225
225
  * @param request - The FetchRequest containing URL and URL parameters
226
226
  * @returns Complete resolved URL string
227
227
  */
228
- resolveRequestUrl(e) {
229
- return this.build(e.url, e.urlParams);
228
+ resolveRequestUrl(t) {
229
+ return this.build(t.url, t.urlParams);
230
230
  }
231
231
  }
232
232
  class l extends Error {
@@ -236,9 +236,9 @@ class l extends Error {
236
236
  * @param errorMsg - Optional error message. If not provided, will use the cause's message or a default message.
237
237
  * @param cause - Optional underlying error that caused this error.
238
238
  */
239
- constructor(e, t) {
240
- const s = e || t?.message || "An error occurred in the fetcher";
241
- super(s), this.cause = t, this.name = "FetcherError", t?.stack && (this.stack = t.stack), Object.setPrototypeOf(this, l.prototype);
239
+ constructor(t, e) {
240
+ const s = t || e?.message || "An error occurred in the fetcher";
241
+ super(s), this.cause = e, this.name = "FetcherError", e?.stack && (this.stack = e.stack), Object.setPrototypeOf(this, l.prototype);
242
242
  }
243
243
  }
244
244
  class I extends l {
@@ -247,53 +247,53 @@ class I extends l {
247
247
  *
248
248
  * @param request - The request options that timed out
249
249
  */
250
- constructor(e) {
251
- const t = e.method || "GET", s = `Request timeout of ${e.timeout}ms exceeded for ${t} ${e.url}`;
252
- super(s), this.name = "FetchTimeoutError", this.request = e, Object.setPrototypeOf(this, I.prototype);
250
+ constructor(t) {
251
+ const e = t.method || "GET", s = `Request timeout of ${t.timeout}ms exceeded for ${e} ${t.url}`;
252
+ super(s), this.name = "FetchTimeoutError", this.request = t, Object.setPrototypeOf(this, I.prototype);
253
253
  }
254
254
  }
255
- function M(r, e) {
256
- return typeof r < "u" ? r : e;
255
+ function G(r, t) {
256
+ return typeof r < "u" ? r : t;
257
257
  }
258
- async function H(r) {
259
- const e = r.url, t = r.timeout, s = r;
258
+ async function M(r) {
259
+ const t = r.url, e = r.timeout, s = r;
260
260
  if (r.signal)
261
- return fetch(e, s);
262
- if (!t)
263
- return r.abortController && (s.signal = r.abortController.signal), fetch(e, s);
261
+ return fetch(t, s);
262
+ if (!e)
263
+ return r.abortController && (s.signal = r.abortController.signal), fetch(t, s);
264
264
  const o = r.abortController ?? new AbortController();
265
265
  s.signal = o.signal;
266
266
  let n = null;
267
- const i = new Promise((a, p) => {
267
+ const i = new Promise((c, p) => {
268
268
  n = setTimeout(() => {
269
269
  n && clearTimeout(n);
270
- const O = new I(r);
271
- o.abort(O), p(O);
272
- }, t);
270
+ const _ = new I(r);
271
+ o.abort(_), p(_);
272
+ }, e);
273
273
  });
274
274
  try {
275
- return await Promise.race([fetch(e, s), i]);
275
+ return await Promise.race([fetch(t, s), i]);
276
276
  } finally {
277
277
  n && clearTimeout(n);
278
278
  }
279
279
  }
280
- const x = "UrlResolveInterceptor", N = Number.MIN_SAFE_INTEGER + 1e3;
280
+ const H = "UrlResolveInterceptor", N = Number.MIN_SAFE_INTEGER + 1e3;
281
281
  class j {
282
282
  constructor() {
283
- this.name = x, this.order = N;
283
+ this.name = H, this.order = N;
284
284
  }
285
285
  /**
286
286
  * Resolves the final URL by combining the base URL, path parameters, and query parameters.
287
287
  *
288
288
  * @param exchange - The fetch exchange containing the request information
289
289
  */
290
- intercept(e) {
291
- const t = e.request;
292
- t.url = e.fetcher.urlBuilder.resolveRequestUrl(t);
290
+ intercept(t) {
291
+ const e = t.request;
292
+ e.url = t.fetcher.urlBuilder.resolveRequestUrl(e);
293
293
  }
294
294
  }
295
295
  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 || {});
296
- const ae = "Content-Type", d = class d {
296
+ const ct = "Content-Type", d = class d {
297
297
  };
298
298
  d.APPLICATION_JSON = "application/json", d.TEXT_EVENT_STREAM = "text/event-stream";
299
299
  let E = d;
@@ -339,13 +339,13 @@ class X {
339
339
  * // exchange.request.body will be '{"name":"John","age":30}'
340
340
  * // exchange.request.headers will include 'Content-Type: application/json'
341
341
  */
342
- intercept(e) {
343
- const t = e.request;
344
- if (t.body === void 0 || t.body === null || typeof t.body != "object" || t.body instanceof ArrayBuffer || ArrayBuffer.isView(t.body) || // Includes TypedArray and DataView
345
- t.body instanceof Blob || t.body instanceof File || t.body instanceof URLSearchParams || t.body instanceof FormData || t.body instanceof ReadableStream)
342
+ intercept(t) {
343
+ const e = t.request;
344
+ if (e.body === void 0 || e.body === null || typeof e.body != "object" || e.body instanceof ArrayBuffer || ArrayBuffer.isView(e.body) || // Includes TypedArray and DataView
345
+ e.body instanceof Blob || e.body instanceof File || e.body instanceof URLSearchParams || e.body instanceof FormData || e.body instanceof ReadableStream)
346
346
  return;
347
- e.request.body = JSON.stringify(t.body);
348
- const s = e.ensureRequestHeaders();
347
+ t.request.body = JSON.stringify(e.body);
348
+ const s = t.ensureRequestHeaders();
349
349
  s["Content-Type"] || (s["Content-Type"] = E.APPLICATION_JSON);
350
350
  }
351
351
  }
@@ -379,12 +379,12 @@ class k {
379
379
  * await fetchInterceptor.intercept(exchange);
380
380
  * console.log(exchange.response); // HTTP response object
381
381
  */
382
- async intercept(e) {
383
- e.response = await H(e.request);
382
+ async intercept(t) {
383
+ t.response = await M(t.request);
384
384
  }
385
385
  }
386
- function m(r, e) {
387
- return e ? r.filter(e).sort((t, s) => t.order - s.order) : [...r].sort((t, s) => t.order - s.order);
386
+ function m(r, t) {
387
+ return t ? r.filter(t).sort((e, s) => e.order - s.order) : [...r].sort((e, s) => e.order - s.order);
388
388
  }
389
389
  class T {
390
390
  /**
@@ -396,8 +396,8 @@ class T {
396
396
  * The provided interceptors will be sorted by their order property immediately
397
397
  * upon construction.
398
398
  */
399
- constructor(e = []) {
400
- this.sortedInterceptors = [], this.sortedInterceptors = m(e);
399
+ constructor(t = []) {
400
+ this.sortedInterceptors = [], this.sortedInterceptors = m(t);
401
401
  }
402
402
  /**
403
403
  * Gets the name of this interceptor registry.
@@ -434,10 +434,10 @@ class T {
434
434
  *
435
435
  * After adding, interceptors are automatically sorted by their order property.
436
436
  */
437
- use(e) {
438
- return this.sortedInterceptors.some((t) => t.name === e.name) ? !1 : (this.sortedInterceptors = m([
437
+ use(t) {
438
+ return this.sortedInterceptors.some((e) => e.name === t.name) ? !1 : (this.sortedInterceptors = m([
439
439
  ...this.sortedInterceptors,
440
- e
440
+ t
441
441
  ]), !0);
442
442
  }
443
443
  /**
@@ -447,12 +447,12 @@ class T {
447
447
  * @returns True if an interceptor was removed, false if no interceptor with the
448
448
  * given name was found
449
449
  */
450
- eject(e) {
451
- const t = this.sortedInterceptors;
450
+ eject(t) {
451
+ const e = this.sortedInterceptors;
452
452
  return this.sortedInterceptors = m(
453
- t,
454
- (s) => s.name !== e
455
- ), t.length !== this.sortedInterceptors.length;
453
+ e,
454
+ (s) => s.name !== t
455
+ ), e.length !== this.sortedInterceptors.length;
456
456
  }
457
457
  /**
458
458
  * Removes all interceptors from this registry.
@@ -474,16 +474,16 @@ class T {
474
474
  * If any interceptor throws an error, the execution chain is broken and the error
475
475
  * is propagated to the caller.
476
476
  */
477
- async intercept(e) {
478
- for (const t of this.sortedInterceptors)
479
- await t.intercept(e);
477
+ async intercept(t) {
478
+ for (const e of this.sortedInterceptors)
479
+ await e.intercept(t);
480
480
  }
481
481
  }
482
- class b extends l {
483
- constructor(e) {
482
+ class O extends l {
483
+ constructor(t) {
484
484
  super(
485
- `Request failed with status code ${e.response?.status} for ${e.request.url}`
486
- ), this.exchange = e, this.name = "HttpStatusValidationError", Object.setPrototypeOf(this, b.prototype);
485
+ `Request failed with status code ${t.response?.status} for ${t.request.url}`
486
+ ), this.exchange = t, this.name = "HttpStatusValidationError", Object.setPrototypeOf(this, O.prototype);
487
487
  }
488
488
  }
489
489
  const Y = (r) => r >= 200 && r < 300, z = "ValidateStatusInterceptor", Q = Number.MAX_SAFE_INTEGER - 1e3;
@@ -493,8 +493,8 @@ class K {
493
493
  *
494
494
  * @param validateStatus - Function that determines if a status code is valid
495
495
  */
496
- constructor(e = Y) {
497
- this.validateStatus = e;
496
+ constructor(t = Y) {
497
+ this.validateStatus = t;
498
498
  }
499
499
  /**
500
500
  * Gets the name of this interceptor.
@@ -525,12 +525,12 @@ class K {
525
525
  * preventing other response handlers from attempting to process them. Valid responses
526
526
  * proceed through the rest of the response interceptor chain normally.
527
527
  */
528
- intercept(e) {
529
- if (!e.response)
528
+ intercept(t) {
529
+ if (!t.response)
530
530
  return;
531
- const t = e.response.status;
532
- if (!this.validateStatus(t))
533
- throw new b(e);
531
+ const e = t.response.status;
532
+ if (!this.validateStatus(e))
533
+ throw new O(t);
534
534
  }
535
535
  }
536
536
  class R extends l {
@@ -540,9 +540,9 @@ class R extends l {
540
540
  * @param exchange - The FetchExchange object containing request/response/error information.
541
541
  * @param errorMsg - An optional error message.
542
542
  */
543
- constructor(e, t) {
544
- const s = t || e.error?.message || e.response?.statusText || `Request to ${e.request.url} failed during exchange`;
545
- super(s, e.error), this.exchange = e, this.name = "ExchangeError", Object.setPrototypeOf(this, R.prototype);
543
+ constructor(t, e) {
544
+ const s = e || t.error?.message || t.response?.statusText || `Request to ${t.request.url} failed during exchange`;
545
+ super(s, t.error), this.exchange = t, this.name = "ExchangeError", Object.setPrototypeOf(this, R.prototype);
546
546
  }
547
547
  }
548
548
  class W {
@@ -641,19 +641,25 @@ class W {
641
641
  * const result = await fetcher.exchange(exchange);
642
642
  * ```
643
643
  */
644
- async exchange(e) {
644
+ async exchange(t) {
645
645
  try {
646
- return await this.request.intercept(e), await this.response.intercept(e), e;
647
- } catch (t) {
648
- if (e.error = t, await this.error.intercept(e), !e.hasError())
649
- return e;
650
- throw new R(e);
646
+ return await this.request.intercept(t), await this.response.intercept(t), t;
647
+ } catch (e) {
648
+ if (t.error = e, await this.error.intercept(t), !t.hasError())
649
+ return t;
650
+ throw new R(t);
651
651
  }
652
652
  }
653
653
  }
654
- class Z {
655
- constructor(e) {
656
- this.fetcher = e.fetcher, this.request = e.request, this.attributes = e.attributes ?? {}, this.response = e.response, this.error = e.error;
654
+ const Z = (r) => r, tt = (r) => r.requiredResponse, et = (r) => r.requiredResponse.json(), rt = (r) => r.requiredResponse.text(), A = {
655
+ Exchange: Z,
656
+ Response: tt,
657
+ Json: et,
658
+ Text: rt
659
+ };
660
+ class st {
661
+ constructor(t) {
662
+ this.fetcher = t.fetcher, this.request = t.request, this.resultExtractor = t.resultExtractor ?? A.Exchange, this.attributes = t.attributes ?? {}, this.response = t.response, this.error = t.error;
657
663
  }
658
664
  /**
659
665
  * Ensures that request headers object exists, creating it if necessary.
@@ -718,19 +724,23 @@ class Z {
718
724
  );
719
725
  return this.response;
720
726
  }
727
+ /**
728
+ * Gets the extracted result by applying the result extractor to the exchange.
729
+ * The result is cached after the first computation.
730
+ *
731
+ * @returns The extracted result or null if extraction failed
732
+ */
733
+ typedExtractedResult() {
734
+ return this.cachedExtractedResult !== void 0 ? this.cachedExtractedResult : (this.cachedExtractedResult = this.resultExtractor(this), this.cachedExtractedResult);
735
+ }
721
736
  }
722
- const ee = (r) => r, te = (r) => r.requiredResponse, re = (r) => r.requiredResponse.json(), se = (r) => r.requiredResponse.text(), _ = {
723
- Exchange: ee,
724
- Response: te,
725
- Json: re,
726
- Text: se
727
- }, A = {
737
+ const y = {
728
738
  "Content-Type": E.APPLICATION_JSON
729
739
  }, S = {
730
740
  baseURL: "",
731
- headers: A
741
+ headers: y
732
742
  };
733
- class oe {
743
+ class ot {
734
744
  /**
735
745
  * Initializes a new Fetcher instance with optional configuration.
736
746
  *
@@ -739,8 +749,8 @@ class oe {
739
749
  *
740
750
  * @param options - Configuration options for the Fetcher instance
741
751
  */
742
- constructor(e = S) {
743
- this.headers = A, this.urlBuilder = new G(e.baseURL, e.urlTemplateStyle), this.headers = e.headers ?? A, this.timeout = e.timeout, this.interceptors = e.interceptors ?? new W();
752
+ constructor(t = S) {
753
+ this.headers = y, this.urlBuilder = new x(t.baseURL, t.urlTemplateStyle), this.headers = t.headers ?? y, this.timeout = t.timeout, this.interceptors = t.interceptors ?? new W();
744
754
  }
745
755
  /**
746
756
  * Executes an HTTP request with the specified URL and options.
@@ -756,9 +766,9 @@ class oe {
756
766
  * @returns Promise that resolves to the HTTP response
757
767
  * @throws FetchError if the request fails and no response is generated
758
768
  */
759
- async fetch(e, t = {}, s) {
760
- const o = t;
761
- return o.url = e, this.request(o, _.Response, s);
769
+ async fetch(t, e = {}, s) {
770
+ const o = e;
771
+ return o.url = t, this.request(o, A.Response, s);
762
772
  }
763
773
  /**
764
774
  * Processes an HTTP request through the Fetcher's internal workflow.
@@ -776,20 +786,21 @@ class oe {
776
786
  * @returns Promise that resolves to the extracted result based on resultExtractor
777
787
  * @throws Error if an unhandled error occurs during request processing
778
788
  */
779
- async request(e, t = _.Exchange, s) {
789
+ async request(t, e = A.Exchange, s) {
780
790
  const o = {
781
791
  ...this.headers,
782
- ...e.headers
792
+ ...t.headers
783
793
  }, n = {
784
- ...e,
794
+ ...t,
785
795
  headers: o,
786
- timeout: M(e.timeout, this.timeout)
787
- }, i = new Z({
796
+ timeout: G(t.timeout, this.timeout)
797
+ }, i = new st({
788
798
  fetcher: this,
789
799
  request: n,
800
+ resultExtractor: e,
790
801
  attributes: s
791
802
  });
792
- return await this.interceptors.exchange(i), t(i);
803
+ return await this.interceptors.exchange(i), i.typedExtractedResult();
793
804
  }
794
805
  /**
795
806
  * Internal helper method for making HTTP requests with a specific method.
@@ -805,12 +816,12 @@ class oe {
805
816
  * custom data between different interceptors.
806
817
  * @returns Promise that resolves to the HTTP response
807
818
  */
808
- async methodFetch(e, t, s = {}, o) {
819
+ async methodFetch(t, e, s = {}, o) {
809
820
  return this.fetch(
810
- t,
821
+ e,
811
822
  {
812
823
  ...s,
813
- method: e
824
+ method: t
814
825
  },
815
826
  o
816
827
  );
@@ -828,8 +839,8 @@ class oe {
828
839
  * custom data between different interceptors.
829
840
  * @returns Promise that resolves to the HTTP response
830
841
  */
831
- async get(e, t = {}, s) {
832
- return this.methodFetch(u.GET, e, t, s);
842
+ async get(t, e = {}, s) {
843
+ return this.methodFetch(u.GET, t, e, s);
833
844
  }
834
845
  /**
835
846
  * Makes a POST HTTP request.
@@ -843,8 +854,8 @@ class oe {
843
854
  * custom data between different interceptors.
844
855
  * @returns Promise that resolves to the HTTP response
845
856
  */
846
- async post(e, t = {}, s) {
847
- return this.methodFetch(u.POST, e, t, s);
857
+ async post(t, e = {}, s) {
858
+ return this.methodFetch(u.POST, t, e, s);
848
859
  }
849
860
  /**
850
861
  * Makes a PUT HTTP request.
@@ -858,8 +869,8 @@ class oe {
858
869
  * custom data between different interceptors.
859
870
  * @returns Promise that resolves to the HTTP response
860
871
  */
861
- async put(e, t = {}, s) {
862
- return this.methodFetch(u.PUT, e, t, s);
872
+ async put(t, e = {}, s) {
873
+ return this.methodFetch(u.PUT, t, e, s);
863
874
  }
864
875
  /**
865
876
  * Makes a DELETE HTTP request.
@@ -873,8 +884,8 @@ class oe {
873
884
  * custom data between different interceptors.
874
885
  * @returns Promise that resolves to the HTTP response
875
886
  */
876
- async delete(e, t = {}, s) {
877
- return this.methodFetch(u.DELETE, e, t, s);
887
+ async delete(t, e = {}, s) {
888
+ return this.methodFetch(u.DELETE, t, e, s);
878
889
  }
879
890
  /**
880
891
  * Makes a PATCH HTTP request.
@@ -888,8 +899,8 @@ class oe {
888
899
  * custom data between different interceptors.
889
900
  * @returns Promise that resolves to the HTTP response
890
901
  */
891
- async patch(e, t = {}, s) {
892
- return this.methodFetch(u.PATCH, e, t, s);
902
+ async patch(t, e = {}, s) {
903
+ return this.methodFetch(u.PATCH, t, e, s);
893
904
  }
894
905
  /**
895
906
  * Makes a HEAD HTTP request.
@@ -904,8 +915,8 @@ class oe {
904
915
  * custom data between different interceptors.
905
916
  * @returns Promise that resolves to the HTTP response
906
917
  */
907
- async head(e, t = {}, s) {
908
- return this.methodFetch(u.HEAD, e, t, s);
918
+ async head(t, e = {}, s) {
919
+ return this.methodFetch(u.HEAD, t, e, s);
909
920
  }
910
921
  /**
911
922
  * Makes an OPTIONS HTTP request.
@@ -920,12 +931,12 @@ class oe {
920
931
  * custom data between different interceptors.
921
932
  * @returns Promise that resolves to the HTTP response
922
933
  */
923
- async options(e, t = {}, s) {
924
- return this.methodFetch(u.OPTIONS, e, t, s);
934
+ async options(t, e = {}, s) {
935
+ return this.methodFetch(u.OPTIONS, t, e, s);
925
936
  }
926
937
  }
927
- const y = "default";
928
- class ne {
938
+ const b = "default";
939
+ class nt {
929
940
  constructor() {
930
941
  this.registrar = /* @__PURE__ */ new Map();
931
942
  }
@@ -938,8 +949,8 @@ class ne {
938
949
  * const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
939
950
  * fetcherRegistrar.register('api', fetcher);
940
951
  */
941
- register(e, t) {
942
- this.registrar.set(e, t);
952
+ register(t, e) {
953
+ this.registrar.set(t, e);
943
954
  }
944
955
  /**
945
956
  * Unregister a Fetcher instance by name
@@ -952,8 +963,8 @@ class ne {
952
963
  * console.log('Fetcher unregistered successfully');
953
964
  * }
954
965
  */
955
- unregister(e) {
956
- return this.registrar.delete(e);
966
+ unregister(t) {
967
+ return this.registrar.delete(t);
957
968
  }
958
969
  /**
959
970
  * Get a Fetcher instance by name
@@ -966,8 +977,8 @@ class ne {
966
977
  * // Use the fetcher
967
978
  * }
968
979
  */
969
- get(e) {
970
- return this.registrar.get(e);
980
+ get(t) {
981
+ return this.registrar.get(t);
971
982
  }
972
983
  /**
973
984
  * Get a Fetcher instance by name, throwing an error if not found
@@ -983,11 +994,11 @@ class ne {
983
994
  * console.error('Fetcher not found:', error.message);
984
995
  * }
985
996
  */
986
- requiredGet(e) {
987
- const t = this.get(e);
988
- if (!t)
989
- throw new Error(`Fetcher ${e} not found`);
990
- return t;
997
+ requiredGet(t) {
998
+ const e = this.get(t);
999
+ if (!e)
1000
+ throw new Error(`Fetcher ${t} not found`);
1001
+ return e;
991
1002
  }
992
1003
  /**
993
1004
  * Get the default Fetcher instance
@@ -998,7 +1009,7 @@ class ne {
998
1009
  * const defaultFetcher = fetcherRegistrar.default;
999
1010
  */
1000
1011
  get default() {
1001
- return this.requiredGet(y);
1012
+ return this.requiredGet(b);
1002
1013
  }
1003
1014
  /**
1004
1015
  * Set the default Fetcher instance
@@ -1008,8 +1019,8 @@ class ne {
1008
1019
  * const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
1009
1020
  * fetcherRegistrar.default = fetcher;
1010
1021
  */
1011
- set default(e) {
1012
- this.register(y, e);
1022
+ set default(t) {
1023
+ this.register(b, t);
1013
1024
  }
1014
1025
  /**
1015
1026
  * Get a copy of all registered fetchers
@@ -1025,36 +1036,36 @@ class ne {
1025
1036
  return new Map(this.registrar);
1026
1037
  }
1027
1038
  }
1028
- const ie = new ne();
1029
- function g(r, e) {
1030
- if (!(r === void 0 && e === void 0))
1031
- return e === void 0 ? r : r === void 0 ? e : { ...r, ...e };
1039
+ const it = new nt();
1040
+ function g(r, t) {
1041
+ if (!(r === void 0 && t === void 0))
1042
+ return t === void 0 ? r : r === void 0 ? t : { ...r, ...t };
1032
1043
  }
1033
- function ce(r, e) {
1044
+ function at(r, t) {
1034
1045
  if (Object.keys(r).length === 0)
1035
- return e;
1036
- if (Object.keys(e).length === 0)
1046
+ return t;
1047
+ if (Object.keys(t).length === 0)
1037
1048
  return r;
1038
- const t = {
1039
- path: g(r.urlParams?.path, e.urlParams?.path),
1040
- query: g(r.urlParams?.query, e.urlParams?.query)
1049
+ const e = {
1050
+ path: g(r.urlParams?.path, t.urlParams?.path),
1051
+ query: g(r.urlParams?.query, t.urlParams?.query)
1041
1052
  }, s = {
1042
1053
  ...r.headers,
1043
- ...e.headers
1044
- }, o = e.method ?? r.method, n = e.body ?? r.body, i = e.timeout ?? r.timeout, a = e.signal ?? r.signal, p = e.abortController ?? r.abortController;
1054
+ ...t.headers
1055
+ }, o = t.method ?? r.method, n = t.body ?? r.body, i = t.timeout ?? r.timeout, c = t.signal ?? r.signal, p = t.abortController ?? r.abortController;
1045
1056
  return {
1046
1057
  ...r,
1047
- ...e,
1058
+ ...t,
1048
1059
  method: o,
1049
- urlParams: t,
1060
+ urlParams: e,
1050
1061
  headers: s,
1051
1062
  body: n,
1052
1063
  timeout: i,
1053
- signal: a,
1064
+ signal: c,
1054
1065
  abortController: p
1055
1066
  };
1056
1067
  }
1057
- class ue extends oe {
1068
+ class ut extends ot {
1058
1069
  /**
1059
1070
  * Create a NamedFetcher instance and automatically register it with the global fetcherRegistrar
1060
1071
  *
@@ -1072,43 +1083,43 @@ class ue extends oe {
1072
1083
  * headers: { 'Authorization': 'Bearer token' }
1073
1084
  * });
1074
1085
  */
1075
- constructor(e, t = S) {
1076
- super(t), this.name = e, ie.register(e, this);
1086
+ constructor(t, e = S) {
1087
+ super(e), this.name = t, it.register(t, this);
1077
1088
  }
1078
1089
  }
1079
- const he = new ue(y);
1090
+ const ht = new ut(b);
1080
1091
  export {
1081
- ae as CONTENT_TYPE_HEADER,
1092
+ ct as CONTENT_TYPE_HEADER,
1082
1093
  E as ContentTypeValues,
1083
- y as DEFAULT_FETCHER_NAME,
1094
+ b as DEFAULT_FETCHER_NAME,
1084
1095
  S as DEFAULT_OPTIONS,
1085
1096
  R as ExchangeError,
1086
- ee as ExchangeResultExtractor,
1097
+ Z as ExchangeResultExtractor,
1087
1098
  P as ExpressUrlTemplateResolver,
1088
1099
  V as FETCH_INTERCEPTOR_NAME,
1089
1100
  J as FETCH_INTERCEPTOR_ORDER,
1090
- Z as FetchExchange,
1101
+ st as FetchExchange,
1091
1102
  k as FetchInterceptor,
1092
1103
  I as FetchTimeoutError,
1093
- oe as Fetcher,
1104
+ ot as Fetcher,
1094
1105
  l as FetcherError,
1095
- ne as FetcherRegistrar,
1106
+ nt as FetcherRegistrar,
1096
1107
  u as HttpMethod,
1097
- b as HttpStatusValidationError,
1108
+ O as HttpStatusValidationError,
1098
1109
  W as InterceptorManager,
1099
1110
  T as InterceptorRegistry,
1100
- re as JsonResultExtractor,
1101
- ue as NamedFetcher,
1111
+ et as JsonResultExtractor,
1112
+ ut as NamedFetcher,
1102
1113
  B as REQUEST_BODY_INTERCEPTOR_NAME,
1103
1114
  $ as REQUEST_BODY_INTERCEPTOR_ORDER,
1104
1115
  X as RequestBodyInterceptor,
1105
- te as ResponseResultExtractor,
1106
- _ as ResultExtractors,
1107
- se as TextResultExtractor,
1108
- x as URL_RESOLVE_INTERCEPTOR_NAME,
1116
+ tt as ResponseResultExtractor,
1117
+ A as ResultExtractors,
1118
+ rt as TextResultExtractor,
1119
+ H as URL_RESOLVE_INTERCEPTOR_NAME,
1109
1120
  N as URL_RESOLVE_INTERCEPTOR_ORDER,
1110
1121
  f as UriTemplateResolver,
1111
- G as UrlBuilder,
1122
+ x as UrlBuilder,
1112
1123
  j as UrlResolveInterceptor,
1113
1124
  U as UrlTemplateStyle,
1114
1125
  z as VALIDATE_STATUS_INTERCEPTOR_NAME,
@@ -1116,14 +1127,14 @@ export {
1116
1127
  K as ValidateStatusInterceptor,
1117
1128
  C as combineURLs,
1118
1129
  v as expressUrlTemplateResolver,
1119
- he as fetcher,
1120
- ie as fetcherRegistrar,
1130
+ ht as fetcher,
1131
+ it as fetcherRegistrar,
1121
1132
  D as getUrlTemplateResolver,
1122
1133
  F as isAbsoluteURL,
1123
1134
  g as mergeRecords,
1124
- ce as mergeRequest,
1125
- M as resolveTimeout,
1126
- H as timeoutFetch,
1135
+ at as mergeRequest,
1136
+ G as resolveTimeout,
1137
+ M as timeoutFetch,
1127
1138
  m as toSorted,
1128
1139
  L as uriTemplateResolver,
1129
1140
  w as urlTemplateRegexExtract,