@ahoo-wang/fetcher 1.0.6 → 1.1.0

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,10 +1,10 @@
1
1
  function g(r) {
2
2
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(r);
3
3
  }
4
- function P(r, e) {
5
- return g(e) ? e : e ? r.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : r;
4
+ function b(r, t) {
5
+ return g(t) ? t : t ? r.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : r;
6
6
  }
7
- class b {
7
+ class S {
8
8
  /**
9
9
  * Initializes a new UrlBuilder instance.
10
10
  *
@@ -15,8 +15,8 @@ class b {
15
15
  * const urlBuilder = new UrlBuilder('https://api.example.com');
16
16
  * ```
17
17
  */
18
- constructor(e) {
19
- this.baseURL = e;
18
+ constructor(t) {
19
+ this.baseURL = t;
20
20
  }
21
21
  /**
22
22
  * Builds a complete URL, including path parameter replacement and query parameter addition.
@@ -36,8 +36,8 @@ class b {
36
36
  * // Result: https://api.example.com/users/123/posts/456?filter=active&limit=10
37
37
  * ```
38
38
  */
39
- build(e, t) {
40
- const s = t?.path, o = t?.query, i = P(this.baseURL, e);
39
+ build(t, e) {
40
+ const s = e?.path, o = e?.query, i = b(this.baseURL, t);
41
41
  let n = this.interpolateUrl(i, s);
42
42
  if (o) {
43
43
  const u = new URLSearchParams(o).toString();
@@ -54,8 +54,8 @@ class b {
54
54
  * @param request - The FetchRequest containing URL and URL parameters
55
55
  * @returns Complete resolved URL string
56
56
  */
57
- resolveRequestUrl(e) {
58
- return this.build(e.url, e.urlParams);
57
+ resolveRequestUrl(t) {
58
+ return this.build(t.url, t.urlParams);
59
59
  }
60
60
  /**
61
61
  * Replaces placeholders in the URL with path parameters.
@@ -84,13 +84,13 @@ class b {
84
84
  * }
85
85
  * ```
86
86
  */
87
- interpolateUrl(e, t) {
88
- return t ? e.replace(/{([^}]+)}/g, (s, o) => {
89
- const i = t[o];
87
+ interpolateUrl(t, e) {
88
+ return e ? t.replace(/{([^}]+)}/g, (s, o) => {
89
+ const i = e[o];
90
90
  if (i === void 0)
91
91
  throw new Error(`Missing required path parameter: ${o}`);
92
92
  return String(i);
93
- }) : e;
93
+ }) : t;
94
94
  }
95
95
  }
96
96
  class a extends Error {
@@ -100,69 +100,71 @@ class a extends Error {
100
100
  * @param errorMsg - Optional error message. If not provided, will use the cause's message or a default message.
101
101
  * @param cause - Optional underlying error that caused this error.
102
102
  */
103
- constructor(e, t) {
104
- const s = e || t?.message || "An error occurred in the fetcher";
105
- super(s), this.cause = t, this.name = "FetcherError", t?.stack && (this.stack = t.stack), Object.setPrototypeOf(this, a.prototype);
103
+ constructor(t, e) {
104
+ const s = t || e?.message || "An error occurred in the fetcher";
105
+ super(s), this.cause = e, this.name = "FetcherError", e?.stack && (this.stack = e.stack), Object.setPrototypeOf(this, a.prototype);
106
106
  }
107
107
  }
108
- class m extends a {
108
+ class R extends a {
109
109
  /**
110
110
  * Creates a new FetchTimeoutError instance.
111
111
  *
112
112
  * @param request - The request options that timed out
113
113
  */
114
- constructor(e) {
115
- const t = e.method || "GET", s = `Request timeout of ${e.timeout}ms exceeded for ${t} ${e.url}`;
116
- super(s), this.name = "FetchTimeoutError", this.request = e, Object.setPrototypeOf(this, m.prototype);
114
+ constructor(t) {
115
+ const e = t.method || "GET", s = `Request timeout of ${t.timeout}ms exceeded for ${e} ${t.url}`;
116
+ super(s), this.name = "FetchTimeoutError", this.request = t, Object.setPrototypeOf(this, R.prototype);
117
117
  }
118
118
  }
119
- function S(r, e) {
120
- return typeof r < "u" ? r : e;
119
+ function _(r, t) {
120
+ return typeof r < "u" ? r : t;
121
121
  }
122
- async function _(r) {
123
- const e = r.url, t = r.timeout, s = r;
124
- if (!t)
125
- return fetch(e, s);
122
+ async function w(r) {
123
+ const t = r.url, e = r.timeout, s = r;
124
+ if (!e)
125
+ return fetch(t, s);
126
126
  const o = new AbortController(), i = {
127
127
  ...s,
128
128
  signal: o.signal
129
129
  };
130
130
  let n = null;
131
- const u = new Promise((X, A) => {
131
+ const u = new Promise((Y, P) => {
132
132
  n = setTimeout(() => {
133
133
  n && clearTimeout(n);
134
- const f = new m(r);
135
- o.abort(f), A(f);
136
- }, t);
134
+ const y = new R(r);
135
+ o.abort(y), P(y);
136
+ }, e);
137
137
  });
138
138
  try {
139
- return await Promise.race([fetch(e, i), u]);
139
+ return await Promise.race([fetch(t, i), u]);
140
140
  } finally {
141
141
  n && clearTimeout(n);
142
142
  }
143
143
  }
144
- const w = "UrlResolveInterceptor", I = Number.MIN_SAFE_INTEGER + 1e3;
145
- class N {
144
+ const N = "UrlResolveInterceptor", O = Number.MIN_SAFE_INTEGER + 1e3;
145
+ class F {
146
146
  constructor() {
147
- this.name = w, this.order = I;
147
+ this.name = N, this.order = O;
148
148
  }
149
149
  /**
150
150
  * Resolves the final URL by combining the base URL, path parameters, and query parameters.
151
151
  *
152
152
  * @param exchange - The fetch exchange containing the request information
153
153
  */
154
- intercept(e) {
155
- const t = e.request;
156
- t.url = e.fetcher.urlBuilder.resolveRequestUrl(t);
154
+ intercept(t) {
155
+ const e = t.request;
156
+ e.url = t.fetcher.urlBuilder.resolveRequestUrl(e);
157
157
  }
158
158
  }
159
159
  var c = /* @__PURE__ */ ((r) => (r.GET = "GET", r.POST = "POST", r.PUT = "PUT", r.DELETE = "DELETE", r.PATCH = "PATCH", r.HEAD = "HEAD", r.OPTIONS = "OPTIONS", r))(c || {});
160
- const z = "Content-Type";
161
- var T = /* @__PURE__ */ ((r) => (r.APPLICATION_JSON = "application/json", r.TEXT_EVENT_STREAM = "text/event-stream", r))(T || {});
162
- const F = "RequestBodyInterceptor", q = I + 1e3;
163
- class U {
160
+ const z = "Content-Type", d = class d {
161
+ };
162
+ d.APPLICATION_JSON = "application/json", d.TEXT_EVENT_STREAM = "text/event-stream";
163
+ let h = d;
164
+ const q = "RequestBodyInterceptor", U = O + 1e3;
165
+ class D {
164
166
  constructor() {
165
- this.name = F, this.order = q;
167
+ this.name = q, this.order = U;
166
168
  }
167
169
  /**
168
170
  * Attempts to convert request body to a valid fetch API body type.
@@ -201,21 +203,21 @@ class U {
201
203
  * // exchange.request.body will be '{"name":"John","age":30}'
202
204
  * // exchange.request.headers will include 'Content-Type: application/json'
203
205
  */
204
- intercept(e) {
205
- const t = e.request;
206
- if (t.body === void 0 || t.body === null || typeof t.body != "object" || t.body instanceof ArrayBuffer || ArrayBuffer.isView(t.body) || // Includes TypedArray and DataView
207
- t.body instanceof Blob || t.body instanceof File || t.body instanceof URLSearchParams || t.body instanceof FormData || t.body instanceof ReadableStream)
206
+ intercept(t) {
207
+ const e = t.request;
208
+ if (e.body === void 0 || e.body === null || typeof e.body != "object" || e.body instanceof ArrayBuffer || ArrayBuffer.isView(e.body) || // Includes TypedArray and DataView
209
+ e.body instanceof Blob || e.body instanceof File || e.body instanceof URLSearchParams || e.body instanceof FormData || e.body instanceof ReadableStream)
208
210
  return;
209
- const s = { ...t };
210
- s.body = JSON.stringify(t.body), s.headers || (s.headers = {});
211
+ const s = { ...e };
212
+ s.body = JSON.stringify(e.body), s.headers || (s.headers = {});
211
213
  const o = s.headers;
212
- o["Content-Type"] || (o["Content-Type"] = T.APPLICATION_JSON), e.request = s;
214
+ o["Content-Type"] || (o["Content-Type"] = h.APPLICATION_JSON), t.request = s;
213
215
  }
214
216
  }
215
- const C = "FetchInterceptor", L = Number.MAX_SAFE_INTEGER - 1e3;
216
- class D {
217
+ const L = "FetchInterceptor", C = Number.MAX_SAFE_INTEGER - 1e3;
218
+ class v {
217
219
  constructor() {
218
- this.name = C, this.order = L;
220
+ this.name = L, this.order = C;
219
221
  }
220
222
  /**
221
223
  * Intercept and process HTTP requests.
@@ -242,14 +244,14 @@ class D {
242
244
  * await fetchInterceptor.intercept(exchange);
243
245
  * console.log(exchange.response); // HTTP response object
244
246
  */
245
- async intercept(e) {
246
- e.response = await _(e.request);
247
+ async intercept(t) {
248
+ t.response = await w(t.request);
247
249
  }
248
250
  }
249
- function d(r, e) {
250
- return e ? r.filter(e).sort((t, s) => t.order - s.order) : [...r].sort((t, s) => t.order - s.order);
251
+ function E(r, t) {
252
+ return t ? r.filter(t).sort((e, s) => e.order - s.order) : [...r].sort((e, s) => e.order - s.order);
251
253
  }
252
- class l {
254
+ class p {
253
255
  /**
254
256
  * Initializes a new InterceptorRegistry instance.
255
257
  *
@@ -259,8 +261,8 @@ class l {
259
261
  * The provided interceptors will be sorted by their order property immediately
260
262
  * upon construction.
261
263
  */
262
- constructor(e = []) {
263
- this.sortedInterceptors = [], this.sortedInterceptors = d(e);
264
+ constructor(t = []) {
265
+ this.sortedInterceptors = [], this.sortedInterceptors = E(t);
264
266
  }
265
267
  /**
266
268
  * Gets the name of this interceptor registry.
@@ -297,10 +299,10 @@ class l {
297
299
  *
298
300
  * After adding, interceptors are automatically sorted by their order property.
299
301
  */
300
- use(e) {
301
- return this.sortedInterceptors.some((t) => t.name === e.name) ? !1 : (this.sortedInterceptors = d([
302
+ use(t) {
303
+ return this.sortedInterceptors.some((e) => e.name === t.name) ? !1 : (this.sortedInterceptors = E([
302
304
  ...this.sortedInterceptors,
303
- e
305
+ t
304
306
  ]), !0);
305
307
  }
306
308
  /**
@@ -310,12 +312,12 @@ class l {
310
312
  * @returns True if an interceptor was removed, false if no interceptor with the
311
313
  * given name was found
312
314
  */
313
- eject(e) {
314
- const t = this.sortedInterceptors;
315
- return this.sortedInterceptors = d(
316
- t,
317
- (s) => s.name !== e
318
- ), t.length !== this.sortedInterceptors.length;
315
+ eject(t) {
316
+ const e = this.sortedInterceptors;
317
+ return this.sortedInterceptors = E(
318
+ e,
319
+ (s) => s.name !== t
320
+ ), e.length !== this.sortedInterceptors.length;
319
321
  }
320
322
  /**
321
323
  * Removes all interceptors from this registry.
@@ -337,27 +339,27 @@ class l {
337
339
  * If any interceptor throws an error, the execution chain is broken and the error
338
340
  * is propagated to the caller.
339
341
  */
340
- async intercept(e) {
341
- for (const t of this.sortedInterceptors)
342
- await t.intercept(e);
342
+ async intercept(t) {
343
+ for (const e of this.sortedInterceptors)
344
+ await e.intercept(t);
343
345
  }
344
346
  }
345
- class R extends a {
346
- constructor(e) {
347
+ class f extends a {
348
+ constructor(t) {
347
349
  super(
348
- `Request failed with status code ${e.response?.status} for ${e.request.url}`
349
- ), this.exchange = e, this.name = "HttpStatusValidationError", Object.setPrototypeOf(this, R.prototype);
350
+ `Request failed with status code ${t.response?.status} for ${t.request.url}`
351
+ ), this.exchange = t, this.name = "HttpStatusValidationError", Object.setPrototypeOf(this, f.prototype);
350
352
  }
351
353
  }
352
- const v = (r) => r >= 200 && r < 300, B = "ValidateStatusInterceptor", G = Number.MAX_SAFE_INTEGER - 1e3;
353
- class M {
354
+ const B = (r) => r >= 200 && r < 300, G = "ValidateStatusInterceptor", M = Number.MAX_SAFE_INTEGER - 1e3;
355
+ class $ {
354
356
  /**
355
357
  * Creates a new ValidateStatusInterceptor instance.
356
358
  *
357
359
  * @param validateStatus - Function that determines if a status code is valid
358
360
  */
359
- constructor(e = v) {
360
- this.validateStatus = e;
361
+ constructor(t = B) {
362
+ this.validateStatus = t;
361
363
  }
362
364
  /**
363
365
  * Gets the name of this interceptor.
@@ -365,7 +367,7 @@ class M {
365
367
  * @returns The name of this interceptor
366
368
  */
367
369
  get name() {
368
- return B;
370
+ return G;
369
371
  }
370
372
  /**
371
373
  * Gets the order of this interceptor.
@@ -373,7 +375,7 @@ class M {
373
375
  * @returns VALIDATE_STATUS_INTERCEPTOR_ORDER, indicating this interceptor should execute early
374
376
  */
375
377
  get order() {
376
- return G;
378
+ return M;
377
379
  }
378
380
  /**
379
381
  * Validates the response status code.
@@ -388,35 +390,35 @@ class M {
388
390
  * preventing other response handlers from attempting to process them. Valid responses
389
391
  * proceed through the rest of the response interceptor chain normally.
390
392
  */
391
- intercept(e) {
392
- if (!e.response)
393
+ intercept(t) {
394
+ if (!t.response)
393
395
  return;
394
- const t = e.response.status;
395
- if (!this.validateStatus(t))
396
- throw new R(e);
396
+ const e = t.response.status;
397
+ if (!this.validateStatus(e))
398
+ throw new f(t);
397
399
  }
398
400
  }
399
- class h extends a {
401
+ class l extends a {
400
402
  /**
401
403
  * Creates a new ExchangeError instance.
402
404
  *
403
405
  * @param exchange - The FetchExchange object containing request/response/error information.
404
406
  * @param errorMsg - An optional error message.
405
407
  */
406
- constructor(e, t) {
407
- const s = t || e.error?.message || e.response?.statusText || `Request to ${e.request.url} failed during exchange`;
408
- super(s, e.error), this.exchange = e, this.name = "ExchangeError", Object.setPrototypeOf(this, h.prototype);
408
+ constructor(t, e) {
409
+ const s = e || t.error?.message || t.response?.statusText || `Request to ${t.request.url} failed during exchange`;
410
+ super(s, t.error), this.exchange = t, this.name = "ExchangeError", Object.setPrototypeOf(this, l.prototype);
409
411
  }
410
412
  }
411
- class $ {
413
+ class j {
412
414
  constructor() {
413
- this.request = new l([
414
- new N(),
415
- new U(),
416
- new D()
417
- ]), this.response = new l([
418
- new M()
419
- ]), this.error = new l();
415
+ this.request = new p([
416
+ new F(),
417
+ new D(),
418
+ new v()
419
+ ]), this.response = new p([
420
+ new $()
421
+ ]), this.error = new p();
420
422
  }
421
423
  /**
422
424
  * Processes a FetchExchange through the interceptor pipeline.
@@ -504,19 +506,19 @@ class $ {
504
506
  * const result = await fetcher.exchange(exchange);
505
507
  * ```
506
508
  */
507
- async exchange(e) {
509
+ async exchange(t) {
508
510
  try {
509
- return await this.request.intercept(e), await this.response.intercept(e), e;
510
- } catch (t) {
511
- if (e.error = t, await this.error.intercept(e), !e.hasError())
512
- return e;
513
- throw new h(e);
511
+ return await this.request.intercept(t), await this.response.intercept(t), t;
512
+ } catch (e) {
513
+ if (t.error = e, await this.error.intercept(t), !t.hasError())
514
+ return t;
515
+ throw new l(t);
514
516
  }
515
517
  }
516
518
  }
517
- class j {
518
- constructor(e, t, s, o) {
519
- this.attributes = {}, this.fetcher = e, this.request = t, this.response = s, this.error = o;
519
+ class H {
520
+ constructor(t, e, s, o) {
521
+ this.attributes = {}, this.fetcher = t, this.request = e, this.response = s, this.error = o;
520
522
  }
521
523
  /**
522
524
  * Checks if the exchange has an error.
@@ -546,18 +548,18 @@ class j {
546
548
  */
547
549
  get requiredResponse() {
548
550
  if (!this.response)
549
- throw new h(
551
+ throw new l(
550
552
  this,
551
553
  `Request to ${this.request.url} failed with no response`
552
554
  );
553
555
  return this.response;
554
556
  }
555
557
  }
556
- const p = {
557
- "Content-Type": T.APPLICATION_JSON
558
- }, O = {
558
+ const m = {
559
+ "Content-Type": h.APPLICATION_JSON
560
+ }, A = {
559
561
  baseURL: "",
560
- headers: p
562
+ headers: m
561
563
  };
562
564
  class V {
563
565
  /**
@@ -568,8 +570,8 @@ class V {
568
570
  *
569
571
  * @param options - Configuration options for the Fetcher instance
570
572
  */
571
- constructor(e = O) {
572
- this.headers = p, this.urlBuilder = new b(e.baseURL), this.headers = e.headers ?? p, this.timeout = e.timeout, this.interceptors = e.interceptors ?? new $();
573
+ constructor(t = A) {
574
+ this.headers = m, this.urlBuilder = new S(t.baseURL), this.headers = t.headers ?? m, this.timeout = t.timeout, this.interceptors = t.interceptors ?? new j();
573
575
  }
574
576
  /**
575
577
  * Executes an HTTP request with the specified URL and options.
@@ -582,9 +584,9 @@ class V {
582
584
  * @returns Promise that resolves to the HTTP response
583
585
  * @throws FetchError if the request fails and no response is generated
584
586
  */
585
- async fetch(e, t = {}) {
586
- const s = t;
587
- return s.url = e, (await this.request(s)).requiredResponse;
587
+ async fetch(t, e = {}) {
588
+ const s = e;
589
+ return s.url = t, (await this.request(s)).requiredResponse;
588
590
  }
589
591
  /**
590
592
  * Processes an HTTP request through the Fetcher's internal workflow.
@@ -597,15 +599,15 @@ class V {
597
599
  * @returns Promise that resolves to a FetchExchange containing request/response data
598
600
  * @throws Error if an unhandled error occurs during request processing
599
601
  */
600
- async request(e) {
601
- const t = {
602
+ async request(t) {
603
+ const e = {
602
604
  ...this.headers,
603
- ...e.headers
605
+ ...t.headers
604
606
  }, s = {
605
- ...e,
606
- headers: t,
607
- timeout: S(e.timeout, this.timeout)
608
- }, o = new j(this, s);
607
+ ...t,
608
+ headers: e,
609
+ timeout: _(t.timeout, this.timeout)
610
+ }, o = new H(this, s);
609
611
  return this.interceptors.exchange(o);
610
612
  }
611
613
  /**
@@ -619,10 +621,10 @@ class V {
619
621
  * @param request - Additional request options
620
622
  * @returns Promise that resolves to the HTTP response
621
623
  */
622
- async methodFetch(e, t, s = {}) {
623
- return this.fetch(t, {
624
+ async methodFetch(t, e, s = {}) {
625
+ return this.fetch(e, {
624
626
  ...s,
625
- method: e
627
+ method: t
626
628
  });
627
629
  }
628
630
  /**
@@ -635,8 +637,8 @@ class V {
635
637
  * @param request - Request options excluding method and body
636
638
  * @returns Promise that resolves to the HTTP response
637
639
  */
638
- async get(e, t = {}) {
639
- return this.methodFetch(c.GET, e, t);
640
+ async get(t, e = {}) {
641
+ return this.methodFetch(c.GET, t, e);
640
642
  }
641
643
  /**
642
644
  * Makes a POST HTTP request.
@@ -647,8 +649,8 @@ class V {
647
649
  * @param request - Request options including body and other parameters
648
650
  * @returns Promise that resolves to the HTTP response
649
651
  */
650
- async post(e, t = {}) {
651
- return this.methodFetch(c.POST, e, t);
652
+ async post(t, e = {}) {
653
+ return this.methodFetch(c.POST, t, e);
652
654
  }
653
655
  /**
654
656
  * Makes a PUT HTTP request.
@@ -659,8 +661,8 @@ class V {
659
661
  * @param request - Request options including body and other parameters
660
662
  * @returns Promise that resolves to the HTTP response
661
663
  */
662
- async put(e, t = {}) {
663
- return this.methodFetch(c.PUT, e, t);
664
+ async put(t, e = {}) {
665
+ return this.methodFetch(c.PUT, t, e);
664
666
  }
665
667
  /**
666
668
  * Makes a DELETE HTTP request.
@@ -671,8 +673,8 @@ class V {
671
673
  * @param request - Request options excluding method and body
672
674
  * @returns Promise that resolves to the HTTP response
673
675
  */
674
- async delete(e, t = {}) {
675
- return this.methodFetch(c.DELETE, e, t);
676
+ async delete(t, e = {}) {
677
+ return this.methodFetch(c.DELETE, t, e);
676
678
  }
677
679
  /**
678
680
  * Makes a PATCH HTTP request.
@@ -683,8 +685,8 @@ class V {
683
685
  * @param request - Request options including body and other parameters
684
686
  * @returns Promise that resolves to the HTTP response
685
687
  */
686
- async patch(e, t = {}) {
687
- return this.methodFetch(c.PATCH, e, t);
688
+ async patch(t, e = {}) {
689
+ return this.methodFetch(c.PATCH, t, e);
688
690
  }
689
691
  /**
690
692
  * Makes a HEAD HTTP request.
@@ -696,8 +698,8 @@ class V {
696
698
  * @param request - Request options excluding method and body
697
699
  * @returns Promise that resolves to the HTTP response
698
700
  */
699
- async head(e, t = {}) {
700
- return this.methodFetch(c.HEAD, e, t);
701
+ async head(t, e = {}) {
702
+ return this.methodFetch(c.HEAD, t, e);
701
703
  }
702
704
  /**
703
705
  * Makes an OPTIONS HTTP request.
@@ -709,12 +711,12 @@ class V {
709
711
  * @param request - Request options excluding method and body
710
712
  * @returns Promise that resolves to the HTTP response
711
713
  */
712
- async options(e, t = {}) {
713
- return this.methodFetch(c.OPTIONS, e, t);
714
+ async options(t, e = {}) {
715
+ return this.methodFetch(c.OPTIONS, t, e);
714
716
  }
715
717
  }
716
- const E = "default";
717
- class H {
718
+ const T = "default";
719
+ class k {
718
720
  constructor() {
719
721
  this.registrar = /* @__PURE__ */ new Map();
720
722
  }
@@ -727,8 +729,8 @@ class H {
727
729
  * const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
728
730
  * fetcherRegistrar.register('api', fetcher);
729
731
  */
730
- register(e, t) {
731
- this.registrar.set(e, t);
732
+ register(t, e) {
733
+ this.registrar.set(t, e);
732
734
  }
733
735
  /**
734
736
  * Unregister a Fetcher instance by name
@@ -741,8 +743,8 @@ class H {
741
743
  * console.log('Fetcher unregistered successfully');
742
744
  * }
743
745
  */
744
- unregister(e) {
745
- return this.registrar.delete(e);
746
+ unregister(t) {
747
+ return this.registrar.delete(t);
746
748
  }
747
749
  /**
748
750
  * Get a Fetcher instance by name
@@ -755,8 +757,8 @@ class H {
755
757
  * // Use the fetcher
756
758
  * }
757
759
  */
758
- get(e) {
759
- return this.registrar.get(e);
760
+ get(t) {
761
+ return this.registrar.get(t);
760
762
  }
761
763
  /**
762
764
  * Get a Fetcher instance by name, throwing an error if not found
@@ -772,11 +774,11 @@ class H {
772
774
  * console.error('Fetcher not found:', error.message);
773
775
  * }
774
776
  */
775
- requiredGet(e) {
776
- const t = this.get(e);
777
- if (!t)
778
- throw new Error(`Fetcher ${e} not found`);
779
- return t;
777
+ requiredGet(t) {
778
+ const e = this.get(t);
779
+ if (!e)
780
+ throw new Error(`Fetcher ${t} not found`);
781
+ return e;
780
782
  }
781
783
  /**
782
784
  * Get the default Fetcher instance
@@ -787,7 +789,7 @@ class H {
787
789
  * const defaultFetcher = fetcherRegistrar.default;
788
790
  */
789
791
  get default() {
790
- return this.requiredGet(E);
792
+ return this.requiredGet(T);
791
793
  }
792
794
  /**
793
795
  * Set the default Fetcher instance
@@ -797,8 +799,8 @@ class H {
797
799
  * const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
798
800
  * fetcherRegistrar.default = fetcher;
799
801
  */
800
- set default(e) {
801
- this.register(E, e);
802
+ set default(t) {
803
+ this.register(T, t);
802
804
  }
803
805
  /**
804
806
  * Get a copy of all registered fetchers
@@ -814,35 +816,35 @@ class H {
814
816
  return new Map(this.registrar);
815
817
  }
816
818
  }
817
- const k = new H();
818
- function y(r, e) {
819
- if (!(r === void 0 && e === void 0))
820
- return e === void 0 ? r : r === void 0 ? e : { ...r, ...e };
819
+ const J = new k();
820
+ function I(r, t) {
821
+ if (!(r === void 0 && t === void 0))
822
+ return t === void 0 ? r : r === void 0 ? t : { ...r, ...t };
821
823
  }
822
- function Q(r, e) {
824
+ function Q(r, t) {
823
825
  if (Object.keys(r).length === 0)
824
- return e;
825
- if (Object.keys(e).length === 0)
826
+ return t;
827
+ if (Object.keys(t).length === 0)
826
828
  return r;
827
- const t = {
828
- path: y(r.urlParams?.path, e.urlParams?.path),
829
- query: y(r.urlParams?.query, e.urlParams?.query)
829
+ const e = {
830
+ path: I(r.urlParams?.path, t.urlParams?.path),
831
+ query: I(r.urlParams?.query, t.urlParams?.query)
830
832
  }, s = {
831
833
  ...r.headers,
832
- ...e.headers
833
- }, o = e.method ?? r.method, i = e.body ?? r.body, n = e.timeout ?? r.timeout, u = e.signal ?? r.signal;
834
+ ...t.headers
835
+ }, o = t.method ?? r.method, i = t.body ?? r.body, n = t.timeout ?? r.timeout, u = t.signal ?? r.signal;
834
836
  return {
835
837
  ...r,
836
- ...e,
838
+ ...t,
837
839
  method: o,
838
- urlParams: t,
840
+ urlParams: e,
839
841
  headers: s,
840
842
  body: i,
841
843
  timeout: n,
842
844
  signal: u
843
845
  };
844
846
  }
845
- class J extends V {
847
+ class X extends V {
846
848
  /**
847
849
  * Create a NamedFetcher instance and automatically register it with the global fetcherRegistrar
848
850
  *
@@ -860,48 +862,48 @@ class J extends V {
860
862
  * headers: { 'Authorization': 'Bearer token' }
861
863
  * });
862
864
  */
863
- constructor(e, t = O) {
864
- super(t), this.name = e, k.register(e, this);
865
+ constructor(t, e = A) {
866
+ super(e), this.name = t, J.register(t, this);
865
867
  }
866
868
  }
867
- const Y = new J(E);
869
+ const x = new X(T);
868
870
  export {
869
- z as ContentTypeHeader,
870
- T as ContentTypeValues,
871
- E as DEFAULT_FETCHER_NAME,
872
- O as DEFAULT_OPTIONS,
873
- h as ExchangeError,
874
- C as FETCH_INTERCEPTOR_NAME,
875
- L as FETCH_INTERCEPTOR_ORDER,
876
- j as FetchExchange,
877
- D as FetchInterceptor,
878
- m as FetchTimeoutError,
871
+ z as CONTENT_TYPE_HEADER,
872
+ h as ContentTypeValues,
873
+ T as DEFAULT_FETCHER_NAME,
874
+ A as DEFAULT_OPTIONS,
875
+ l as ExchangeError,
876
+ L as FETCH_INTERCEPTOR_NAME,
877
+ C as FETCH_INTERCEPTOR_ORDER,
878
+ H as FetchExchange,
879
+ v as FetchInterceptor,
880
+ R as FetchTimeoutError,
879
881
  V as Fetcher,
880
882
  a as FetcherError,
881
- H as FetcherRegistrar,
883
+ k as FetcherRegistrar,
882
884
  c as HttpMethod,
883
- R as HttpStatusValidationError,
884
- $ as InterceptorManager,
885
- l as InterceptorRegistry,
886
- J as NamedFetcher,
887
- F as REQUEST_BODY_INTERCEPTOR_NAME,
888
- q as REQUEST_BODY_INTERCEPTOR_ORDER,
889
- U as RequestBodyInterceptor,
890
- w as URL_RESOLVE_INTERCEPTOR_NAME,
891
- I as URL_RESOLVE_INTERCEPTOR_ORDER,
892
- b as UrlBuilder,
893
- N as UrlResolveInterceptor,
894
- B as VALIDATE_STATUS_INTERCEPTOR_NAME,
895
- G as VALIDATE_STATUS_INTERCEPTOR_ORDER,
896
- M as ValidateStatusInterceptor,
897
- P as combineURLs,
898
- Y as fetcher,
899
- k as fetcherRegistrar,
885
+ f as HttpStatusValidationError,
886
+ j as InterceptorManager,
887
+ p as InterceptorRegistry,
888
+ X as NamedFetcher,
889
+ q as REQUEST_BODY_INTERCEPTOR_NAME,
890
+ U as REQUEST_BODY_INTERCEPTOR_ORDER,
891
+ D as RequestBodyInterceptor,
892
+ N as URL_RESOLVE_INTERCEPTOR_NAME,
893
+ O as URL_RESOLVE_INTERCEPTOR_ORDER,
894
+ S as UrlBuilder,
895
+ F as UrlResolveInterceptor,
896
+ G as VALIDATE_STATUS_INTERCEPTOR_NAME,
897
+ M as VALIDATE_STATUS_INTERCEPTOR_ORDER,
898
+ $ as ValidateStatusInterceptor,
899
+ b as combineURLs,
900
+ x as fetcher,
901
+ J as fetcherRegistrar,
900
902
  g as isAbsoluteURL,
901
- y as mergeRecords,
903
+ I as mergeRecords,
902
904
  Q as mergeRequest,
903
- S as resolveTimeout,
904
- _ as timeoutFetch,
905
- d as toSorted
905
+ _ as resolveTimeout,
906
+ w as timeoutFetch,
907
+ E as toSorted
906
908
  };
907
909
  //# sourceMappingURL=index.es.js.map