@ahoo-wang/fetcher-react 2.6.15 → 2.6.16

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,2178 +1,222 @@
1
- import { useRef as pt, useCallback as g, useEffect as z, useState as C, useMemo as F, useSyncExternalStore as ke } from "react";
2
- import { fetcherRegistrar as Ce, getFetcher as Kt, CONTENT_TYPE_HEADER as je, ContentTypeValues as ot, FetcherError as De, HttpMethod as Ge, combineURLs as qe, JsonResultExtractor as He, mergeRecordToMap as St, mergeRequest as Ue } from "@ahoo-wang/fetcher";
3
- function bt() {
4
- const t = pt(!1), e = g(() => t.current, []);
5
- return z(() => (t.current = !0, () => {
1
+ import { useRef as S, useCallback as o, useEffect as m, useState as L, useMemo as b, useSyncExternalStore as p } from "react";
2
+ import { fetcherRegistrar as F, getFetcher as M } from "@ahoo-wang/fetcher";
3
+ function R() {
4
+ const t = S(!1), s = o(() => t.current, []);
5
+ return m(() => (t.current = !0, () => {
6
6
  t.current = !1;
7
- }), []), e;
7
+ }), []), s;
8
8
  }
9
- function Z(t) {
10
- const e = pt(t);
11
- return e.current = t, e;
9
+ function w(t) {
10
+ const s = S(t);
11
+ return s.current = t, s;
12
12
  }
13
- var $e = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.LOADING = "loading", t.SUCCESS = "success", t.ERROR = "error", t))($e || {});
14
- function te(t) {
15
- const [e, r] = C(
13
+ var O = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.LOADING = "loading", t.SUCCESS = "success", t.ERROR = "error", t))(O || {});
14
+ function C(t) {
15
+ const [s, e] = L(
16
16
  t?.initialStatus ?? "idle"
17
17
  /* IDLE */
18
- ), [a, s] = C(void 0), [u, f] = C(void 0), y = bt(), m = Z(t), S = g(() => {
19
- y() && (r(
18
+ ), [u, a] = L(void 0), [r, n] = L(void 0), c = R(), i = w(t), l = o(() => {
19
+ c() && (e(
20
20
  "loading"
21
21
  /* LOADING */
22
- ), f(void 0));
23
- }, [y]), M = g(
24
- async (b) => {
25
- if (y()) {
26
- s(b), r(
22
+ ), n(void 0));
23
+ }, [c]), d = o(
24
+ async (f) => {
25
+ if (c()) {
26
+ a(f), e(
27
27
  "success"
28
28
  /* SUCCESS */
29
- ), f(void 0);
29
+ ), n(void 0);
30
30
  try {
31
- await m.current?.onSuccess?.(b);
32
- } catch (R) {
33
- console.warn("PromiseState onSuccess callback error:", R);
31
+ await i.current?.onSuccess?.(f);
32
+ } catch (y) {
33
+ console.warn("PromiseState onSuccess callback error:", y);
34
34
  }
35
35
  }
36
36
  },
37
- [y, m]
38
- ), _ = g(
39
- async (b) => {
40
- if (y()) {
41
- f(b), r(
37
+ [c, i]
38
+ ), E = o(
39
+ async (f) => {
40
+ if (c()) {
41
+ n(f), e(
42
42
  "error"
43
43
  /* ERROR */
44
- ), s(void 0);
44
+ ), a(void 0);
45
45
  try {
46
- await m.current?.onError?.(b);
47
- } catch (R) {
48
- console.warn("PromiseState onError callback error:", R);
46
+ await i.current?.onError?.(f);
47
+ } catch (y) {
48
+ console.warn("PromiseState onError callback error:", y);
49
49
  }
50
50
  }
51
51
  },
52
- [y, m]
53
- ), A = g(() => {
54
- y() && (r(
52
+ [c, i]
53
+ ), g = o(() => {
54
+ c() && (e(
55
55
  "idle"
56
56
  /* IDLE */
57
- ), f(void 0), s(void 0));
58
- }, [y]);
59
- return F(
57
+ ), n(void 0), a(void 0));
58
+ }, [c]);
59
+ return b(
60
60
  () => ({
61
- status: e,
62
- loading: e === "loading",
63
- result: a,
64
- error: u,
65
- setLoading: S,
66
- setSuccess: M,
67
- setError: _,
68
- setIdle: A
61
+ status: s,
62
+ loading: s === "loading",
63
+ result: u,
64
+ error: r,
65
+ setLoading: l,
66
+ setSuccess: d,
67
+ setError: E,
68
+ setIdle: g
69
69
  }),
70
- [e, a, u, S, M, _, A]
70
+ [s, u, r, l, d, E, g]
71
71
  );
72
72
  }
73
- function ee() {
74
- const t = pt(0), e = g(() => ++t.current, []), r = g(() => t.current, []), a = g((f) => f === t.current, []), s = g(() => {
73
+ function Q() {
74
+ const t = S(0), s = o(() => ++t.current, []), e = o(() => t.current, []), u = o((n) => n === t.current, []), a = o(() => {
75
75
  t.current++;
76
- }, []), u = g(() => {
76
+ }, []), r = o(() => {
77
77
  t.current = 0;
78
78
  }, []);
79
- return F(() => ({
80
- generate: e,
81
- current: r,
82
- isLatest: a,
83
- invalidate: s,
84
- reset: u
85
- }), [e, r, a, s, u]);
86
- }
87
- function it(t) {
88
- const e = te(t), r = bt(), a = ee(), s = g(
89
- async (f) => {
90
- if (!r())
79
+ return b(() => ({
80
+ generate: s,
81
+ current: e,
82
+ isLatest: u,
83
+ invalidate: a,
84
+ reset: r
85
+ }), [s, e, u, a, r]);
86
+ }
87
+ function q(t) {
88
+ const { loading: s, result: e, error: u, status: a, setLoading: r, setSuccess: n, setError: c, setIdle: i } = C(t), l = R(), d = Q(), E = t?.propagateError, g = o(
89
+ async (y) => {
90
+ if (!l())
91
91
  throw new Error("Component is unmounted");
92
- const y = a.generate();
93
- e.setLoading();
92
+ const v = d.generate();
93
+ r();
94
94
  try {
95
- const S = await (typeof f == "function" ? f() : f);
96
- return r() && a.isLatest(y) && await e.setSuccess(S), S;
97
- } catch (m) {
98
- if (r() && a.isLatest(y) && await e.setError(m), t?.propagateError)
99
- throw m;
100
- return m;
95
+ const I = await (typeof y == "function" ? y() : y);
96
+ return l() && d.isLatest(v) && await n(I), I;
97
+ } catch (x) {
98
+ if (l() && d.isLatest(v) && await c(x), E)
99
+ throw x;
100
+ return x;
101
101
  }
102
102
  },
103
- [e, r, a, t]
104
- ), u = g(() => {
105
- r() && e.setIdle();
106
- }, [e, r]);
107
- return F(
103
+ [r, n, c, l, d, E]
104
+ ), f = o(() => {
105
+ l() && i();
106
+ }, [i, l]);
107
+ return b(
108
108
  () => ({
109
- loading: e.loading,
110
- result: e.result,
111
- error: e.error,
112
- execute: s,
113
- reset: u,
114
- status: e.status
109
+ loading: s,
110
+ result: e,
111
+ error: u,
112
+ execute: g,
113
+ reset: f,
114
+ status: a
115
115
  }),
116
- [e.loading, e.result, e.error, s, u, e.status]
116
+ [s, e, u, g, f, a]
117
117
  );
118
118
  }
119
- function Pr(t) {
120
- const e = g(
121
- (u) => t.addListener(u),
119
+ function P(t) {
120
+ const s = o(
121
+ (r) => t.addListener(r),
122
122
  [t]
123
- ), r = g(() => t.get(), [t]), a = ke(e, r, r), s = g(
124
- (u) => t.set(u),
123
+ ), e = o(() => t.get(), [t]), u = p(s, e, e), a = o(
124
+ (r) => t.set(r),
125
125
  [t]
126
126
  );
127
- return [a, s];
127
+ return [u, a];
128
128
  }
129
- function Ir(t) {
130
- const { fetcher: e = Ce.default } = t || {}, r = te(t), [a, s] = C(
129
+ function G(t) {
130
+ const { fetcher: s = F.default } = t || {}, e = C(t), [u, a] = L(
131
131
  void 0
132
- ), u = bt(), f = pt(), y = ee(), m = Z(t), S = Kt(e), M = g(
133
- async (_) => {
134
- f.current && f.current.abort(), f.current = _.abortController ?? new AbortController(), _.abortController = f.current;
135
- const A = y.generate();
136
- r.setLoading();
132
+ ), r = R(), n = S(), c = Q(), i = w(t), l = M(s), d = o(
133
+ async (E) => {
134
+ n.current && n.current.abort(), n.current = E.abortController ?? new AbortController(), E.abortController = n.current;
135
+ const g = c.generate();
136
+ e.setLoading();
137
137
  try {
138
- const b = await S.exchange(
139
- _,
140
- m.current
138
+ const f = await l.exchange(
139
+ E,
140
+ i.current
141
141
  );
142
- u() && y.isLatest(A) && s(b);
143
- const R = await b.extractResult();
144
- u() && y.isLatest(A) && await r.setSuccess(R);
145
- } catch (b) {
146
- if (b instanceof Error && b.name === "AbortError") {
147
- u() && r.setIdle();
142
+ r() && c.isLatest(g) && a(f);
143
+ const y = await f.extractResult();
144
+ r() && c.isLatest(g) && await e.setSuccess(y);
145
+ } catch (f) {
146
+ if (f instanceof Error && f.name === "AbortError") {
147
+ r() && e.setIdle();
148
148
  return;
149
149
  }
150
- u() && y.isLatest(A) && await r.setError(b);
150
+ r() && c.isLatest(g) && await e.setError(f);
151
151
  } finally {
152
- f.current === _.abortController && (f.current = void 0);
152
+ n.current === E.abortController && (n.current = void 0);
153
153
  }
154
154
  },
155
- [S, u, m, r, y]
155
+ [l, r, i, e, c]
156
156
  );
157
- return z(() => () => {
158
- f.current?.abort(), f.current = void 0;
159
- }, []), F(
157
+ return m(() => () => {
158
+ n.current?.abort(), n.current = void 0;
159
+ }, []), b(
160
160
  () => ({
161
- ...r,
162
- exchange: a,
163
- execute: M
161
+ ...e,
162
+ exchange: u,
163
+ execute: d
164
164
  }),
165
- [r, a, M]
165
+ [e, u, d]
166
166
  );
167
167
  }
168
- let We = class {
169
- constructor() {
170
- this.buffer = "";
171
- }
172
- /**
173
- * Transform input string chunk by splitting it into lines.
174
- *
175
- * @param chunk Input string chunk
176
- * @param controller Controller for controlling the transform stream
177
- */
178
- transform(e, r) {
179
- try {
180
- this.buffer += e;
181
- const a = this.buffer.split(`
182
- `);
183
- this.buffer = a.pop() || "";
184
- for (const s of a)
185
- r.enqueue(s);
186
- } catch (a) {
187
- r.error(a);
188
- }
189
- }
190
- /**
191
- * Flush remaining buffer when the stream ends.
192
- *
193
- * @param controller Controller for controlling the transform stream
194
- */
195
- flush(e) {
196
- try {
197
- this.buffer && e.enqueue(this.buffer);
198
- } catch (r) {
199
- e.error(r);
200
- }
201
- }
202
- };
203
- class Fe extends TransformStream {
204
- constructor() {
205
- super(new We());
206
- }
207
- }
208
- const at = class {
209
- };
210
- at.ID = "id", at.RETRY = "retry", at.EVENT = "event", at.DATA = "data";
211
- let dt = at;
212
- function Qe(t, e, r) {
213
- switch (t) {
214
- case dt.EVENT:
215
- r.event = e;
216
- break;
217
- case dt.DATA:
218
- r.data.push(e);
219
- break;
220
- case dt.ID:
221
- r.id = e;
222
- break;
223
- case dt.RETRY: {
224
- const a = parseInt(e, 10);
225
- isNaN(a) || (r.retry = a);
226
- break;
227
- }
228
- }
229
- }
230
- const tt = "message";
231
- let Ve = class {
232
- constructor() {
233
- this.currentEvent = {
234
- event: tt,
235
- id: void 0,
236
- retry: void 0,
237
- data: []
238
- };
239
- }
240
- /**
241
- * Transform input string chunk into ServerSentEvent object.
242
- *
243
- * @param chunk Input string chunk
244
- * @param controller Controller for controlling the transform stream
245
- */
246
- transform(e, r) {
247
- const a = this.currentEvent;
248
- try {
249
- if (e.trim() === "") {
250
- a.data.length > 0 && (r.enqueue({
251
- event: a.event || tt,
252
- data: a.data.join(`
253
- `),
254
- id: a.id || "",
255
- retry: a.retry
256
- }), a.event = tt, a.data = []);
257
- return;
258
- }
259
- if (e.startsWith(":"))
260
- return;
261
- const s = e.indexOf(":");
262
- let u, f;
263
- s === -1 ? (u = e.toLowerCase(), f = "") : (u = e.substring(0, s).toLowerCase(), f = e.substring(s + 1), f.startsWith(" ") && (f = f.substring(1))), u = u.trim(), f = f.trim(), Qe(u, f, a);
264
- } catch (s) {
265
- r.error(
266
- s instanceof Error ? s : new Error(String(s))
267
- ), a.event = tt, a.id = void 0, a.retry = void 0, a.data = [];
268
- }
269
- }
270
- /**
271
- * Called when the stream ends, used to process remaining data.
272
- *
273
- * @param controller Controller for controlling the transform stream
274
- */
275
- flush(e) {
276
- const r = this.currentEvent;
277
- try {
278
- r.data.length > 0 && e.enqueue({
279
- event: r.event || tt,
280
- data: r.data.join(`
281
- `),
282
- id: r.id || "",
283
- retry: r.retry
284
- });
285
- } catch (a) {
286
- e.error(
287
- a instanceof Error ? a : new Error(String(a))
288
- );
289
- } finally {
290
- r.event = tt, r.id = void 0, r.retry = void 0, r.data = [];
291
- }
292
- }
293
- }, Ye = class extends TransformStream {
294
- constructor() {
295
- super(new Ve());
296
- }
297
- };
298
- class st extends De {
299
- /**
300
- * Creates a new EventStreamConvertError instance.
301
- * @param response - The Response object associated with the error
302
- * @param errorMsg - Optional error message describing what went wrong during conversion
303
- * @param cause - Optional underlying error that caused this error
304
- */
305
- constructor(e, r, a) {
306
- super(r, a), this.response = e, this.name = "EventStreamConvertError", Object.setPrototypeOf(this, st.prototype);
307
- }
308
- }
309
- function Be(t) {
310
- if (!t.body)
311
- throw new st(t, "Response body is null");
312
- return t.body.pipeThrough(new TextDecoderStream("utf-8")).pipeThrough(new Fe()).pipeThrough(new Ye());
313
- }
314
- class Xe {
315
- transform(e, r) {
316
- const a = JSON.parse(e.data);
317
- r.enqueue({
318
- data: a,
319
- event: e.event,
320
- id: e.id,
321
- retry: e.retry
322
- });
323
- }
324
- }
325
- class Je extends TransformStream {
326
- constructor() {
327
- super(new Xe());
328
- }
329
- }
330
- function ze(t) {
331
- return t.pipeThrough(
332
- new Je()
333
- );
334
- }
335
- const yt = (t) => t.requiredResponse.requiredJsonEventStream(), Yt = "contentType";
336
- Object.prototype.hasOwnProperty.call(
337
- Response.prototype,
338
- Yt
339
- ) || Object.defineProperty(Response.prototype, Yt, {
340
- get() {
341
- return this.headers.get(je);
342
- },
343
- configurable: !0
344
- });
345
- const Bt = "isEventStream";
346
- Object.prototype.hasOwnProperty.call(
347
- Response.prototype,
348
- Bt
349
- ) || Object.defineProperty(Response.prototype, Bt, {
350
- get() {
351
- const t = this.contentType;
352
- return t ? t.includes(ot.TEXT_EVENT_STREAM) : !1;
353
- },
354
- configurable: !0
355
- });
356
- Object.prototype.hasOwnProperty.call(Response.prototype, "eventStream") || (Response.prototype.eventStream = function() {
357
- return this.isEventStream ? Be(this) : null;
358
- });
359
- Object.prototype.hasOwnProperty.call(
360
- Response.prototype,
361
- "requiredEventStream"
362
- ) || (Response.prototype.requiredEventStream = function() {
363
- const t = this.eventStream();
364
- if (!t)
365
- throw new st(
366
- this,
367
- `Event stream is not available. Response content-type: [${this.contentType}]`
368
- );
369
- return t;
370
- });
371
- Object.prototype.hasOwnProperty.call(Response.prototype, "jsonEventStream") || (Response.prototype.jsonEventStream = function() {
372
- const t = this.eventStream();
373
- return t ? ze(t) : null;
374
- });
375
- Object.prototype.hasOwnProperty.call(
376
- Response.prototype,
377
- "requiredJsonEventStream"
378
- ) || (Response.prototype.requiredJsonEventStream = function() {
379
- const t = this.jsonEventStream();
380
- if (!t)
381
- throw new st(
382
- this,
383
- `Event stream is not available. Response content-type: [${this.contentType}]`
384
- );
385
- return t;
386
- });
387
- class Ze {
388
- /**
389
- * Creates a new ReadableStreamAsyncIterable instance.
390
- * @param stream - The ReadableStream to wrap.
391
- */
392
- constructor(e) {
393
- this.stream = e, this._locked = !0, this.reader = e.getReader();
394
- }
395
- /**
396
- * Gets the lock status of the reader.
397
- * @returns True if the reader is currently locked, false otherwise.
398
- */
399
- get locked() {
400
- return this._locked;
401
- }
402
- /**
403
- * Releases the reader lock if currently locked.
404
- * This method safely releases the reader lock by catching any potential errors.
405
- */
406
- releaseLock() {
407
- if (!this._locked) return !1;
408
- this._locked = !1;
409
- try {
410
- return this.reader.releaseLock(), !0;
411
- } catch (e) {
412
- return console.debug("Failed to release reader lock:", e), !1;
413
- }
414
- }
415
- /**
416
- * Implements the AsyncIterable interface by returning this iterator.
417
- * @returns The async iterator for this instance.
418
- */
419
- [Symbol.asyncIterator]() {
420
- return this;
421
- }
422
- /**
423
- * Gets the next value from the stream.
424
- * Reads the next chunk from the stream and returns it as an IteratorResult.
425
- * If the stream is done, releases the lock and returns a done result.
426
- * @returns A promise that resolves to an IteratorResult containing the next value or done status.
427
- * @throws If an error occurs while reading from the stream.
428
- */
429
- async next() {
430
- try {
431
- const { done: e, value: r } = await this.reader.read();
432
- return e ? (this.releaseLock(), { done: !0, value: void 0 }) : { done: !1, value: r };
433
- } catch (e) {
434
- throw this.releaseLock(), e;
435
- }
436
- }
437
- /**
438
- * Implements the return method of the async iterator.
439
- * Cancels the stream reader and releases the lock.
440
- * @returns A promise that resolves to a done IteratorResult.
441
- */
442
- async return() {
443
- try {
444
- await this.reader.cancel();
445
- } catch (e) {
446
- console.debug("Failed to cancel stream reader:", e);
447
- } finally {
448
- this.releaseLock();
449
- }
450
- return { done: !0, value: void 0 };
451
- }
452
- /**
453
- * Implements the throw method of the async iterator.
454
- * Releases the lock and returns a done result.
455
- * @param error - The error to be thrown.
456
- * @returns A promise that resolves to a done IteratorResult.
457
- */
458
- async throw(e) {
459
- return console.debug("Throwing error:", e), this.releaseLock(), { done: !0, value: void 0 };
460
- }
461
- }
462
- const Ke = typeof ReadableStream.prototype[Symbol.asyncIterator] == "function";
463
- Ke || (ReadableStream.prototype[Symbol.asyncIterator] = function() {
464
- return new Ze(this);
465
- });
466
- var Xt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Jt = {};
467
- /*! *****************************************************************************
468
- Copyright (C) Microsoft. All rights reserved.
469
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
470
- this file except in compliance with the License. You may obtain a copy of the
471
- License at http://www.apache.org/licenses/LICENSE-2.0
472
-
473
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
474
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
475
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
476
- MERCHANTABLITY OR NON-INFRINGEMENT.
477
-
478
- See the Apache Version 2.0 License for specific language governing permissions
479
- and limitations under the License.
480
- ***************************************************************************** */
481
- var zt;
482
- function tr() {
483
- if (zt) return Jt;
484
- zt = 1;
485
- var t;
486
- return (function(e) {
487
- (function(r) {
488
- var a = typeof globalThis == "object" ? globalThis : typeof Xt == "object" ? Xt : typeof self == "object" ? self : typeof this == "object" ? this : m(), s = u(e);
489
- typeof a.Reflect < "u" && (s = u(a.Reflect, s)), r(s, a), typeof a.Reflect > "u" && (a.Reflect = e);
490
- function u(S, M) {
491
- return function(_, A) {
492
- Object.defineProperty(S, _, { configurable: !0, writable: !0, value: A }), M && M(_, A);
493
- };
494
- }
495
- function f() {
496
- try {
497
- return Function("return this;")();
498
- } catch {
499
- }
500
- }
501
- function y() {
502
- try {
503
- return (0, eval)("(function() { return this; })()");
504
- } catch {
505
- }
506
- }
507
- function m() {
508
- return f() || y();
509
- }
510
- })(function(r, a) {
511
- var s = Object.prototype.hasOwnProperty, u = typeof Symbol == "function", f = u && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", y = u && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", m = typeof Object.create == "function", S = { __proto__: [] } instanceof Array, M = !m && !S, _ = {
512
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
513
- create: m ? function() {
514
- return mt(/* @__PURE__ */ Object.create(null));
515
- } : S ? function() {
516
- return mt({ __proto__: null });
517
- } : function() {
518
- return mt({});
519
- },
520
- has: M ? function(n, o) {
521
- return s.call(n, o);
522
- } : function(n, o) {
523
- return o in n;
524
- },
525
- get: M ? function(n, o) {
526
- return s.call(n, o) ? n[o] : void 0;
527
- } : function(n, o) {
528
- return n[o];
529
- }
530
- }, A = Object.getPrototypeOf(Function), b = typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : Pe(), R = typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Ie(), X = typeof WeakMap == "function" ? WeakMap : Ne(), G = u ? Symbol.for("@reflect-metadata:registry") : void 0, ct = Re(), It = Me(ct);
531
- function ue(n, o, i, c) {
532
- if (v(i)) {
533
- if (!qt(n))
534
- throw new TypeError();
535
- if (!Ht(o))
536
- throw new TypeError();
537
- return we(n, o);
538
- } else {
539
- if (!qt(n))
540
- throw new TypeError();
541
- if (!N(o))
542
- throw new TypeError();
543
- if (!N(c) && !v(c) && !K(c))
544
- throw new TypeError();
545
- return K(c) && (c = void 0), i = W(i), Te(n, o, i, c);
546
- }
547
- }
548
- r("decorate", ue);
549
- function ce(n, o) {
550
- function i(c, E) {
551
- if (!N(c))
552
- throw new TypeError();
553
- if (!v(E) && !ge(E))
554
- throw new TypeError();
555
- kt(n, o, c, E);
556
- }
557
- return i;
558
- }
559
- r("metadata", ce);
560
- function fe(n, o, i, c) {
561
- if (!N(i))
562
- throw new TypeError();
563
- return v(c) || (c = W(c)), kt(n, o, i, c);
564
- }
565
- r("defineMetadata", fe);
566
- function de(n, o, i) {
567
- if (!N(o))
568
- throw new TypeError();
569
- return v(i) || (i = W(i)), Nt(n, o, i);
570
- }
571
- r("hasMetadata", de);
572
- function le(n, o, i) {
573
- if (!N(o))
574
- throw new TypeError();
575
- return v(i) || (i = W(i)), vt(n, o, i);
576
- }
577
- r("hasOwnMetadata", le);
578
- function he(n, o, i) {
579
- if (!N(o))
580
- throw new TypeError();
581
- return v(i) || (i = W(i)), Lt(n, o, i);
582
- }
583
- r("getMetadata", he);
584
- function pe(n, o, i) {
585
- if (!N(o))
586
- throw new TypeError();
587
- return v(i) || (i = W(i)), xt(n, o, i);
588
- }
589
- r("getOwnMetadata", pe);
590
- function ye(n, o) {
591
- if (!N(n))
592
- throw new TypeError();
593
- return v(o) || (o = W(o)), Ct(n, o);
594
- }
595
- r("getMetadataKeys", ye);
596
- function Ee(n, o) {
597
- if (!N(n))
598
- throw new TypeError();
599
- return v(o) || (o = W(o)), jt(n, o);
600
- }
601
- r("getOwnMetadataKeys", Ee);
602
- function ve(n, o, i) {
603
- if (!N(o))
604
- throw new TypeError();
605
- if (v(i) || (i = W(i)), !N(o))
606
- throw new TypeError();
607
- v(i) || (i = W(i));
608
- var c = rt(
609
- o,
610
- i,
611
- /*Create*/
612
- !1
613
- );
614
- return v(c) ? !1 : c.OrdinaryDeleteMetadata(n, o, i);
615
- }
616
- r("deleteMetadata", ve);
617
- function we(n, o) {
618
- for (var i = n.length - 1; i >= 0; --i) {
619
- var c = n[i], E = c(o);
620
- if (!v(E) && !K(E)) {
621
- if (!Ht(E))
622
- throw new TypeError();
623
- o = E;
624
- }
625
- }
626
- return o;
627
- }
628
- function Te(n, o, i, c) {
629
- for (var E = n.length - 1; E >= 0; --E) {
630
- var P = n[E], L = P(o, i, c);
631
- if (!v(L) && !K(L)) {
632
- if (!N(L))
633
- throw new TypeError();
634
- c = L;
635
- }
636
- }
637
- return c;
638
- }
639
- function Nt(n, o, i) {
640
- var c = vt(n, o, i);
641
- if (c)
642
- return !0;
643
- var E = Tt(o);
644
- return K(E) ? !1 : Nt(n, E, i);
645
- }
646
- function vt(n, o, i) {
647
- var c = rt(
648
- o,
649
- i,
650
- /*Create*/
651
- !1
652
- );
653
- return v(c) ? !1 : Gt(c.OrdinaryHasOwnMetadata(n, o, i));
654
- }
655
- function Lt(n, o, i) {
656
- var c = vt(n, o, i);
657
- if (c)
658
- return xt(n, o, i);
659
- var E = Tt(o);
660
- if (!K(E))
661
- return Lt(n, E, i);
662
- }
663
- function xt(n, o, i) {
664
- var c = rt(
665
- o,
666
- i,
667
- /*Create*/
668
- !1
669
- );
670
- if (!v(c))
671
- return c.OrdinaryGetOwnMetadata(n, o, i);
672
- }
673
- function kt(n, o, i, c) {
674
- var E = rt(
675
- i,
676
- c,
677
- /*Create*/
678
- !0
679
- );
680
- E.OrdinaryDefineOwnMetadata(n, o, i, c);
681
- }
682
- function Ct(n, o) {
683
- var i = jt(n, o), c = Tt(n);
684
- if (c === null)
685
- return i;
686
- var E = Ct(c, o);
687
- if (E.length <= 0)
688
- return i;
689
- if (i.length <= 0)
690
- return E;
691
- for (var P = new R(), L = [], w = 0, d = i; w < d.length; w++) {
692
- var l = d[w], h = P.has(l);
693
- h || (P.add(l), L.push(l));
694
- }
695
- for (var p = 0, T = E; p < T.length; p++) {
696
- var l = T[p], h = P.has(l);
697
- h || (P.add(l), L.push(l));
698
- }
699
- return L;
700
- }
701
- function jt(n, o) {
702
- var i = rt(
703
- n,
704
- o,
705
- /*create*/
706
- !1
707
- );
708
- return i ? i.OrdinaryOwnMetadataKeys(n, o) : [];
709
- }
710
- function Dt(n) {
711
- if (n === null)
712
- return 1;
713
- switch (typeof n) {
714
- case "undefined":
715
- return 0;
716
- case "boolean":
717
- return 2;
718
- case "string":
719
- return 3;
720
- case "symbol":
721
- return 4;
722
- case "number":
723
- return 5;
724
- case "object":
725
- return n === null ? 1 : 6;
726
- default:
727
- return 6;
728
- }
729
- }
730
- function v(n) {
731
- return n === void 0;
732
- }
733
- function K(n) {
734
- return n === null;
735
- }
736
- function me(n) {
737
- return typeof n == "symbol";
738
- }
739
- function N(n) {
740
- return typeof n == "object" ? n !== null : typeof n == "function";
741
- }
742
- function Se(n, o) {
743
- switch (Dt(n)) {
744
- case 0:
745
- return n;
746
- case 1:
747
- return n;
748
- case 2:
749
- return n;
750
- case 3:
751
- return n;
752
- case 4:
753
- return n;
754
- case 5:
755
- return n;
756
- }
757
- var i = "string", c = Ut(n, f);
758
- if (c !== void 0) {
759
- var E = c.call(n, i);
760
- if (N(E))
761
- throw new TypeError();
762
- return E;
763
- }
764
- return _e(n);
765
- }
766
- function _e(n, o) {
767
- var i, c, E;
768
- {
769
- var P = n.toString;
770
- if (ft(P)) {
771
- var c = P.call(n);
772
- if (!N(c))
773
- return c;
774
- }
775
- var i = n.valueOf;
776
- if (ft(i)) {
777
- var c = i.call(n);
778
- if (!N(c))
779
- return c;
780
- }
781
- }
782
- throw new TypeError();
783
- }
784
- function Gt(n) {
785
- return !!n;
786
- }
787
- function be(n) {
788
- return "" + n;
789
- }
790
- function W(n) {
791
- var o = Se(n);
792
- return me(o) ? o : be(o);
793
- }
794
- function qt(n) {
795
- return Array.isArray ? Array.isArray(n) : n instanceof Object ? n instanceof Array : Object.prototype.toString.call(n) === "[object Array]";
796
- }
797
- function ft(n) {
798
- return typeof n == "function";
799
- }
800
- function Ht(n) {
801
- return typeof n == "function";
802
- }
803
- function ge(n) {
804
- switch (Dt(n)) {
805
- case 3:
806
- return !0;
807
- case 4:
808
- return !0;
809
- default:
810
- return !1;
811
- }
812
- }
813
- function wt(n, o) {
814
- return n === o || n !== n && o !== o;
815
- }
816
- function Ut(n, o) {
817
- var i = n[o];
818
- if (i != null) {
819
- if (!ft(i))
820
- throw new TypeError();
821
- return i;
822
- }
823
- }
824
- function $t(n) {
825
- var o = Ut(n, y);
826
- if (!ft(o))
827
- throw new TypeError();
828
- var i = o.call(n);
829
- if (!N(i))
830
- throw new TypeError();
831
- return i;
832
- }
833
- function Wt(n) {
834
- return n.value;
835
- }
836
- function Ft(n) {
837
- var o = n.next();
838
- return o.done ? !1 : o;
839
- }
840
- function Qt(n) {
841
- var o = n.return;
842
- o && o.call(n);
843
- }
844
- function Tt(n) {
845
- var o = Object.getPrototypeOf(n);
846
- if (typeof n != "function" || n === A || o !== A)
847
- return o;
848
- var i = n.prototype, c = i && Object.getPrototypeOf(i);
849
- if (c == null || c === Object.prototype)
850
- return o;
851
- var E = c.constructor;
852
- return typeof E != "function" || E === n ? o : E;
853
- }
854
- function Oe() {
855
- var n;
856
- !v(G) && typeof a.Reflect < "u" && !(G in a.Reflect) && typeof a.Reflect.defineMetadata == "function" && (n = Ae(a.Reflect));
857
- var o, i, c, E = new X(), P = {
858
- registerProvider: L,
859
- getProvider: d,
860
- setProvider: h
861
- };
862
- return P;
863
- function L(p) {
864
- if (!Object.isExtensible(P))
865
- throw new Error("Cannot add provider to a frozen registry.");
866
- switch (!0) {
867
- case n === p:
868
- break;
869
- case v(o):
870
- o = p;
871
- break;
872
- case o === p:
873
- break;
874
- case v(i):
875
- i = p;
876
- break;
877
- case i === p:
878
- break;
879
- default:
880
- c === void 0 && (c = new R()), c.add(p);
881
- break;
882
- }
883
- }
884
- function w(p, T) {
885
- if (!v(o)) {
886
- if (o.isProviderFor(p, T))
887
- return o;
888
- if (!v(i)) {
889
- if (i.isProviderFor(p, T))
890
- return o;
891
- if (!v(c))
892
- for (var O = $t(c); ; ) {
893
- var I = Ft(O);
894
- if (!I)
895
- return;
896
- var U = Wt(I);
897
- if (U.isProviderFor(p, T))
898
- return Qt(O), U;
899
- }
900
- }
901
- }
902
- if (!v(n) && n.isProviderFor(p, T))
903
- return n;
904
- }
905
- function d(p, T) {
906
- var O = E.get(p), I;
907
- return v(O) || (I = O.get(T)), v(I) && (I = w(p, T), v(I) || (v(O) && (O = new b(), E.set(p, O)), O.set(T, I))), I;
908
- }
909
- function l(p) {
910
- if (v(p))
911
- throw new TypeError();
912
- return o === p || i === p || !v(c) && c.has(p);
913
- }
914
- function h(p, T, O) {
915
- if (!l(O))
916
- throw new Error("Metadata provider not registered.");
917
- var I = d(p, T);
918
- if (I !== O) {
919
- if (!v(I))
920
- return !1;
921
- var U = E.get(p);
922
- v(U) && (U = new b(), E.set(p, U)), U.set(T, O);
923
- }
924
- return !0;
925
- }
926
- }
927
- function Re() {
928
- var n;
929
- return !v(G) && N(a.Reflect) && Object.isExtensible(a.Reflect) && (n = a.Reflect[G]), v(n) && (n = Oe()), !v(G) && N(a.Reflect) && Object.isExtensible(a.Reflect) && Object.defineProperty(a.Reflect, G, {
930
- enumerable: !1,
931
- configurable: !1,
932
- writable: !1,
933
- value: n
934
- }), n;
935
- }
936
- function Me(n) {
937
- var o = new X(), i = {
938
- isProviderFor: function(l, h) {
939
- var p = o.get(l);
940
- return v(p) ? !1 : p.has(h);
941
- },
942
- OrdinaryDefineOwnMetadata: L,
943
- OrdinaryHasOwnMetadata: E,
944
- OrdinaryGetOwnMetadata: P,
945
- OrdinaryOwnMetadataKeys: w,
946
- OrdinaryDeleteMetadata: d
947
- };
948
- return ct.registerProvider(i), i;
949
- function c(l, h, p) {
950
- var T = o.get(l), O = !1;
951
- if (v(T)) {
952
- if (!p)
953
- return;
954
- T = new b(), o.set(l, T), O = !0;
955
- }
956
- var I = T.get(h);
957
- if (v(I)) {
958
- if (!p)
959
- return;
960
- if (I = new b(), T.set(h, I), !n.setProvider(l, h, i))
961
- throw T.delete(h), O && o.delete(l), new Error("Wrong provider for target.");
962
- }
963
- return I;
964
- }
965
- function E(l, h, p) {
966
- var T = c(
967
- h,
968
- p,
969
- /*Create*/
970
- !1
971
- );
972
- return v(T) ? !1 : Gt(T.has(l));
973
- }
974
- function P(l, h, p) {
975
- var T = c(
976
- h,
977
- p,
978
- /*Create*/
979
- !1
980
- );
981
- if (!v(T))
982
- return T.get(l);
983
- }
984
- function L(l, h, p, T) {
985
- var O = c(
986
- p,
987
- T,
988
- /*Create*/
989
- !0
990
- );
991
- O.set(l, h);
992
- }
993
- function w(l, h) {
994
- var p = [], T = c(
995
- l,
996
- h,
997
- /*Create*/
998
- !1
999
- );
1000
- if (v(T))
1001
- return p;
1002
- for (var O = T.keys(), I = $t(O), U = 0; ; ) {
1003
- var Vt = Ft(I);
1004
- if (!Vt)
1005
- return p.length = U, p;
1006
- var Le = Wt(Vt);
1007
- try {
1008
- p[U] = Le;
1009
- } catch (xe) {
1010
- try {
1011
- Qt(I);
1012
- } finally {
1013
- throw xe;
1014
- }
1015
- }
1016
- U++;
1017
- }
1018
- }
1019
- function d(l, h, p) {
1020
- var T = c(
1021
- h,
1022
- p,
1023
- /*Create*/
1024
- !1
1025
- );
1026
- if (v(T) || !T.delete(l))
1027
- return !1;
1028
- if (T.size === 0) {
1029
- var O = o.get(h);
1030
- v(O) || (O.delete(p), O.size === 0 && o.delete(O));
1031
- }
1032
- return !0;
1033
- }
1034
- }
1035
- function Ae(n) {
1036
- var o = n.defineMetadata, i = n.hasOwnMetadata, c = n.getOwnMetadata, E = n.getOwnMetadataKeys, P = n.deleteMetadata, L = new X(), w = {
1037
- isProviderFor: function(d, l) {
1038
- var h = L.get(d);
1039
- return !v(h) && h.has(l) ? !0 : E(d, l).length ? (v(h) && (h = new R(), L.set(d, h)), h.add(l), !0) : !1;
1040
- },
1041
- OrdinaryDefineOwnMetadata: o,
1042
- OrdinaryHasOwnMetadata: i,
1043
- OrdinaryGetOwnMetadata: c,
1044
- OrdinaryOwnMetadataKeys: E,
1045
- OrdinaryDeleteMetadata: P
1046
- };
1047
- return w;
1048
- }
1049
- function rt(n, o, i) {
1050
- var c = ct.getProvider(n, o);
1051
- if (!v(c))
1052
- return c;
1053
- if (i) {
1054
- if (ct.setProvider(n, o, It))
1055
- return It;
1056
- throw new Error("Illegal state.");
1057
- }
1058
- }
1059
- function Pe() {
1060
- var n = {}, o = [], i = (
1061
- /** @class */
1062
- (function() {
1063
- function w(d, l, h) {
1064
- this._index = 0, this._keys = d, this._values = l, this._selector = h;
1065
- }
1066
- return w.prototype["@@iterator"] = function() {
1067
- return this;
1068
- }, w.prototype[y] = function() {
1069
- return this;
1070
- }, w.prototype.next = function() {
1071
- var d = this._index;
1072
- if (d >= 0 && d < this._keys.length) {
1073
- var l = this._selector(this._keys[d], this._values[d]);
1074
- return d + 1 >= this._keys.length ? (this._index = -1, this._keys = o, this._values = o) : this._index++, { value: l, done: !1 };
1075
- }
1076
- return { value: void 0, done: !0 };
1077
- }, w.prototype.throw = function(d) {
1078
- throw this._index >= 0 && (this._index = -1, this._keys = o, this._values = o), d;
1079
- }, w.prototype.return = function(d) {
1080
- return this._index >= 0 && (this._index = -1, this._keys = o, this._values = o), { value: d, done: !0 };
1081
- }, w;
1082
- })()
1083
- ), c = (
1084
- /** @class */
1085
- (function() {
1086
- function w() {
1087
- this._keys = [], this._values = [], this._cacheKey = n, this._cacheIndex = -2;
1088
- }
1089
- return Object.defineProperty(w.prototype, "size", {
1090
- get: function() {
1091
- return this._keys.length;
1092
- },
1093
- enumerable: !0,
1094
- configurable: !0
1095
- }), w.prototype.has = function(d) {
1096
- return this._find(
1097
- d,
1098
- /*insert*/
1099
- !1
1100
- ) >= 0;
1101
- }, w.prototype.get = function(d) {
1102
- var l = this._find(
1103
- d,
1104
- /*insert*/
1105
- !1
1106
- );
1107
- return l >= 0 ? this._values[l] : void 0;
1108
- }, w.prototype.set = function(d, l) {
1109
- var h = this._find(
1110
- d,
1111
- /*insert*/
1112
- !0
1113
- );
1114
- return this._values[h] = l, this;
1115
- }, w.prototype.delete = function(d) {
1116
- var l = this._find(
1117
- d,
1118
- /*insert*/
1119
- !1
1120
- );
1121
- if (l >= 0) {
1122
- for (var h = this._keys.length, p = l + 1; p < h; p++)
1123
- this._keys[p - 1] = this._keys[p], this._values[p - 1] = this._values[p];
1124
- return this._keys.length--, this._values.length--, wt(d, this._cacheKey) && (this._cacheKey = n, this._cacheIndex = -2), !0;
1125
- }
1126
- return !1;
1127
- }, w.prototype.clear = function() {
1128
- this._keys.length = 0, this._values.length = 0, this._cacheKey = n, this._cacheIndex = -2;
1129
- }, w.prototype.keys = function() {
1130
- return new i(this._keys, this._values, E);
1131
- }, w.prototype.values = function() {
1132
- return new i(this._keys, this._values, P);
1133
- }, w.prototype.entries = function() {
1134
- return new i(this._keys, this._values, L);
1135
- }, w.prototype["@@iterator"] = function() {
1136
- return this.entries();
1137
- }, w.prototype[y] = function() {
1138
- return this.entries();
1139
- }, w.prototype._find = function(d, l) {
1140
- if (!wt(this._cacheKey, d)) {
1141
- this._cacheIndex = -1;
1142
- for (var h = 0; h < this._keys.length; h++)
1143
- if (wt(this._keys[h], d)) {
1144
- this._cacheIndex = h;
1145
- break;
1146
- }
1147
- }
1148
- return this._cacheIndex < 0 && l && (this._cacheIndex = this._keys.length, this._keys.push(d), this._values.push(void 0)), this._cacheIndex;
1149
- }, w;
1150
- })()
1151
- );
1152
- return c;
1153
- function E(w, d) {
1154
- return w;
1155
- }
1156
- function P(w, d) {
1157
- return d;
1158
- }
1159
- function L(w, d) {
1160
- return [w, d];
1161
- }
1162
- }
1163
- function Ie() {
1164
- var n = (
1165
- /** @class */
1166
- (function() {
1167
- function o() {
1168
- this._map = new b();
1169
- }
1170
- return Object.defineProperty(o.prototype, "size", {
1171
- get: function() {
1172
- return this._map.size;
1173
- },
1174
- enumerable: !0,
1175
- configurable: !0
1176
- }), o.prototype.has = function(i) {
1177
- return this._map.has(i);
1178
- }, o.prototype.add = function(i) {
1179
- return this._map.set(i, i), this;
1180
- }, o.prototype.delete = function(i) {
1181
- return this._map.delete(i);
1182
- }, o.prototype.clear = function() {
1183
- this._map.clear();
1184
- }, o.prototype.keys = function() {
1185
- return this._map.keys();
1186
- }, o.prototype.values = function() {
1187
- return this._map.keys();
1188
- }, o.prototype.entries = function() {
1189
- return this._map.entries();
1190
- }, o.prototype["@@iterator"] = function() {
1191
- return this.keys();
1192
- }, o.prototype[y] = function() {
1193
- return this.keys();
1194
- }, o;
1195
- })()
1196
- );
1197
- return n;
1198
- }
1199
- function Ne() {
1200
- var n = 16, o = _.create(), i = c();
1201
- return (
1202
- /** @class */
1203
- (function() {
1204
- function d() {
1205
- this._key = c();
1206
- }
1207
- return d.prototype.has = function(l) {
1208
- var h = E(
1209
- l,
1210
- /*create*/
1211
- !1
1212
- );
1213
- return h !== void 0 ? _.has(h, this._key) : !1;
1214
- }, d.prototype.get = function(l) {
1215
- var h = E(
1216
- l,
1217
- /*create*/
1218
- !1
1219
- );
1220
- return h !== void 0 ? _.get(h, this._key) : void 0;
1221
- }, d.prototype.set = function(l, h) {
1222
- var p = E(
1223
- l,
1224
- /*create*/
1225
- !0
1226
- );
1227
- return p[this._key] = h, this;
1228
- }, d.prototype.delete = function(l) {
1229
- var h = E(
1230
- l,
1231
- /*create*/
1232
- !1
1233
- );
1234
- return h !== void 0 ? delete h[this._key] : !1;
1235
- }, d.prototype.clear = function() {
1236
- this._key = c();
1237
- }, d;
1238
- })()
1239
- );
1240
- function c() {
1241
- var d;
1242
- do
1243
- d = "@@WeakMap@@" + w();
1244
- while (_.has(o, d));
1245
- return o[d] = !0, d;
1246
- }
1247
- function E(d, l) {
1248
- if (!s.call(d, i)) {
1249
- if (!l)
1250
- return;
1251
- Object.defineProperty(d, i, { value: _.create() });
1252
- }
1253
- return d[i];
1254
- }
1255
- function P(d, l) {
1256
- for (var h = 0; h < l; ++h)
1257
- d[h] = Math.random() * 255 | 0;
1258
- return d;
1259
- }
1260
- function L(d) {
1261
- if (typeof Uint8Array == "function") {
1262
- var l = new Uint8Array(d);
1263
- return typeof crypto < "u" ? crypto.getRandomValues(l) : typeof msCrypto < "u" ? msCrypto.getRandomValues(l) : P(l, d), l;
1264
- }
1265
- return P(new Array(d), d);
1266
- }
1267
- function w() {
1268
- var d = L(n);
1269
- d[6] = d[6] & 79 | 64, d[8] = d[8] & 191 | 128;
1270
- for (var l = "", h = 0; h < n; ++h) {
1271
- var p = d[h];
1272
- (h === 4 || h === 6 || h === 8) && (l += "-"), p < 16 && (l += "0"), l += p.toString(16).toLowerCase();
1273
- }
1274
- return l;
1275
- }
1276
- }
1277
- function mt(n) {
1278
- return n.__ = void 0, delete n.__, n;
1279
- }
1280
- });
1281
- })(t || (t = {})), Jt;
1282
- }
1283
- tr();
1284
- const re = Symbol("endpoint:metadata");
1285
- function gt(t, e, r = {}) {
1286
- return function(a, s) {
1287
- const u = {
1288
- method: t,
1289
- path: e,
1290
- ...r
1291
- };
1292
- Reflect.defineMetadata(
1293
- re,
1294
- u,
1295
- a,
1296
- s
1297
- );
1298
- };
1299
- }
1300
- function q(t = "", e = {}) {
1301
- return gt(Ge.POST, t, e);
1302
- }
1303
- var Ot = /* @__PURE__ */ ((t) => (t.EXCHANGE = "Exchange", t.RESULT = "Result", t))(Ot || {});
1304
- const er = "__decorator_target__", rr = "__decorator_metadata__";
1305
- let nr = class {
1306
- /**
1307
- * Creates a new RequestExecutor instance.
1308
- * @param target - The target object that the method is called on.
1309
- * This can contain a custom fetcher instance in its 'fetcher' property.
1310
- * @param metadata - The function metadata containing all request information
1311
- */
1312
- constructor(e, r) {
1313
- this.target = e, this.metadata = r;
1314
- }
1315
- /**
1316
- * Executes the HTTP request.
1317
- *
1318
- * This method resolves the path and request configuration from the metadata
1319
- * and arguments, then executes the request using the configured fetcher.
1320
- * It handles the complete request lifecycle from parameter processing to
1321
- * response extraction.
1322
- *
1323
-
1324
- * @param args - The runtime arguments passed to the decorated method.
1325
- * These are mapped to request components based on parameter decorators.
1326
- * @returns A Promise that resolves to the extracted result based on the configured result extractor.
1327
- * By default, this is the Response object, but can be customized to return
1328
- * parsed JSON, the raw exchange object, or any other transformed result.
1329
- *
1330
- * @example
1331
- * ```typescript
1332
- * // Given a decorated service method:
1333
- * class UserService {
1334
- * @get('/users/{id}')
1335
- * getUser(@path('id') id: number): Promise<Response> {
1336
- * // This method body is replaced by the executor at runtime
1337
- * }
1338
- * }
1339
- *
1340
- * // When calling:
1341
- * const userService = new UserService();
1342
- * const response = await userService.getUser(123);
1343
- *
1344
- * // The execute method will:
1345
- * // 1. Resolve the path to '/users/123'
1346
- * // 2. Create a request with method 'GET'
1347
- * // 3. Execute the request using the configured fetcher
1348
- * // 4. Return the Response object
1349
- * ```
1350
- */
1351
- async execute(e) {
1352
- const r = this.metadata.fetcher, a = this.metadata.resolveExchangeInit(e);
1353
- a.attributes?.set(er, this.target), a.attributes?.set(
1354
- rr,
1355
- this.metadata
1356
- );
1357
- const s = this.metadata.resolveResultExtractor(), u = this.metadata.resolveEndpointReturnType(), f = await r.exchange(a.request, {
1358
- resultExtractor: s,
1359
- attributes: a.attributes
1360
- });
1361
- return u === Ot.EXCHANGE ? f : await f.extractResult();
1362
- }
1363
- };
1364
- const nt = /* @__PURE__ */ new WeakMap();
1365
- function ar(t) {
1366
- if (typeof t != "function")
1367
- throw new TypeError("Expected a function");
1368
- if (nt.has(t))
1369
- return nt.get(t);
1370
- try {
1371
- const e = t.toString().trim(), r = sr(e);
1372
- if (!ir(r)) {
1373
- const s = [];
1374
- return nt.set(t, s), s;
1375
- }
1376
- const a = ur(r);
1377
- return nt.set(t, a), a;
1378
- } catch {
1379
- const e = [];
1380
- return nt.set(t, e), e;
1381
- }
1382
- }
1383
- function or(t, e, r, a) {
1384
- if (a)
1385
- return a;
1386
- try {
1387
- const s = t[e];
1388
- if (s && typeof s == "function") {
1389
- const u = ar(s);
1390
- if (r < u.length)
1391
- return u[r];
1392
- }
1393
- } catch {
1394
- }
1395
- }
1396
- function ir(t) {
1397
- return t != null && t.trim() !== "";
1398
- }
1399
- function sr(t) {
1400
- if (t.startsWith("(")) {
1401
- const a = Zt(t, 0);
1402
- return a === -1 ? "" : t.substring(1, a);
1403
- }
1404
- const e = t.indexOf("(");
1405
- if (e === -1) return "";
1406
- const r = Zt(t, e);
1407
- return r === -1 ? "" : t.substring(e + 1, r);
1408
- }
1409
- function Zt(t, e) {
1410
- let r = 1;
1411
- for (let a = e + 1; a < t.length; a++) {
1412
- const s = t[a];
1413
- if (s === "(")
1414
- r++;
1415
- else if (s === ")" && (r--, r === 0))
1416
- return a;
1417
- }
1418
- return -1;
1419
- }
1420
- function ur(t) {
1421
- return t.split(",").map(cr).filter(fr).map(dr);
1422
- }
1423
- function cr(t) {
1424
- return t.trim();
1425
- }
1426
- function fr(t) {
1427
- return t.length > 0;
1428
- }
1429
- function dr(t) {
1430
- let e = lr(t);
1431
- return e = hr(e), e.trim();
1432
- }
1433
- function lr(t) {
1434
- const e = t.indexOf("=");
1435
- return e !== -1 ? t.substring(0, e) : t;
1436
- }
1437
- function hr(t) {
1438
- const e = t.indexOf(":");
1439
- return e !== -1 ? t.substring(0, e) : t;
1440
- }
1441
- var J = /* @__PURE__ */ ((t) => (t.PATH = "path", t.QUERY = "query", t.HEADER = "header", t.BODY = "body", t.REQUEST = "request", t.ATTRIBUTE = "attribute", t))(J || {});
1442
- const _t = Symbol("parameter:metadata");
1443
- function Rt(t, e = "") {
1444
- return function(r, a, s) {
1445
- const u = or(
1446
- r,
1447
- a,
1448
- s,
1449
- e
1450
- ), f = Reflect.getMetadata(_t, r, a) || /* @__PURE__ */ new Map(), y = {
1451
- type: t,
1452
- name: u,
1453
- index: s
1454
- };
1455
- f.set(s, y), Reflect.defineMetadata(
1456
- _t,
1457
- f,
1458
- r,
1459
- a
1460
- );
1461
- };
1462
- }
1463
- function H() {
1464
- return Rt(
1465
- "body"
1466
- /* BODY */
1467
- );
1468
- }
1469
- function ne() {
1470
- return Rt(
1471
- "request"
1472
- /* REQUEST */
1473
- );
1474
- }
1475
- function D(t = "") {
1476
- return Rt("attribute", t);
1477
- }
1478
- let ae = class {
1479
- /**
1480
- * Creates a new FunctionMetadata instance.
1481
- *
1482
- * @param name - The name of the function
1483
- * @param api - API-level metadata
1484
- * @param endpoint - Endpoint-level metadata
1485
- * @param parameters - Parameter metadata array
1486
- */
1487
- constructor(e, r, a, s) {
1488
- this.name = e, this.api = r, this.endpoint = a, this.parameters = s;
1489
- }
1490
- /**
1491
- * Gets the fetcher instance to use for this function.
1492
- *
1493
- * Returns the fetcher specified in the endpoint metadata, or the API metadata,
1494
- * or falls back to the default fetcher if none is specified.
1495
- *
1496
- * @returns The fetcher instance
1497
- */
1498
- get fetcher() {
1499
- return Kt(this.endpoint.fetcher ?? this.api.fetcher);
1500
- }
1501
- /**
1502
- * Resolves the complete path by combining base path and endpoint path
1503
- *
1504
- * @param parameterPath - Optional path parameter to use instead of endpoint path
1505
- * @returns The combined URL path
1506
- */
1507
- resolvePath(e) {
1508
- const r = this.endpoint.basePath || this.api.basePath || "", a = e || this.endpoint.path || "";
1509
- return qe(r, a);
1510
- }
1511
- /**
1512
- * Resolves the timeout for the request.
1513
- *
1514
- * Returns the timeout specified in the endpoint metadata, or the API metadata,
1515
- * or undefined if no timeout is specified.
1516
- *
1517
- * @returns The timeout value in milliseconds, or undefined
1518
- */
1519
- resolveTimeout() {
1520
- return this.endpoint.timeout || this.api.timeout;
1521
- }
1522
- resolveResultExtractor() {
1523
- return this.endpoint.resultExtractor || this.api.resultExtractor || He;
1524
- }
1525
- resolveAttributes() {
1526
- const e = St(this.api.attributes);
1527
- return St(this.endpoint.attributes, e);
1528
- }
1529
- resolveEndpointReturnType() {
1530
- return this.endpoint.returnType || this.api.returnType || Ot.RESULT;
1531
- }
1532
- /**
1533
- * Resolves the request configuration from the method arguments.
1534
- *
1535
- * This method processes the runtime arguments according to the parameter metadata
1536
- * and constructs a FetcherRequest object with path parameters, query parameters,
1537
- * headers, body, and timeout. It handles various parameter types including:
1538
- * - Path parameters (@path decorator)
1539
- * - Query parameters (@query decorator)
1540
- * - Header parameters (@header decorator)
1541
- * - Body parameter (@body decorator)
1542
- * - Complete request object (@request decorator)
1543
- * - AbortSignal for request cancellation
1544
- *
1545
- * The method uses mergeRequest to combine the endpoint-specific configuration
1546
- * with the parameter-provided request object, where the parameter request
1547
- * takes precedence over endpoint configuration.
1548
- *
1549
- * @param args - The runtime arguments passed to the method
1550
- * @returns A FetcherRequest object with all request configuration
1551
- *
1552
- * @example
1553
- * ```typescript
1554
- * // For a method decorated like:
1555
- * @get('/users/{id}')
1556
- * getUser(
1557
- * @path('id') id: number,
1558
- * @query('include') include: string,
1559
- * @header('Authorization') auth: string
1560
- * ): Promise<Response>
1561
- *
1562
- * // Calling with: getUser(123, 'profile', 'Bearer token')
1563
- * // Would produce a request with:
1564
- * // {
1565
- * // method: 'GET',
1566
- * // urlParams: {
1567
- * // path: { id: 123 },
1568
- * // query: { include: 'profile' }
1569
- * // },
1570
- * // headers: {
1571
- * // 'Authorization': 'Bearer token',
1572
- * // ...apiHeaders,
1573
- * // ...endpointHeaders
1574
- * // }
1575
- * // }
1576
- * ```
1577
- */
1578
- resolveExchangeInit(e) {
1579
- const r = {}, a = {}, s = {
1580
- ...this.api.headers,
1581
- ...this.endpoint.headers
1582
- };
1583
- let u, f, y, m = {};
1584
- const S = this.resolveAttributes();
1585
- e.forEach((R, X) => {
1586
- if (R instanceof AbortSignal) {
1587
- f = R;
1588
- return;
1589
- }
1590
- if (R instanceof AbortController) {
1591
- y = R;
1592
- return;
1593
- }
1594
- const G = this.parameters.get(X);
1595
- if (G)
1596
- switch (G.type) {
1597
- case J.PATH:
1598
- this.processPathParam(G, R, r);
1599
- break;
1600
- case J.QUERY:
1601
- this.processQueryParam(G, R, a);
1602
- break;
1603
- case J.HEADER:
1604
- this.processHeaderParam(G, R, s);
1605
- break;
1606
- case J.BODY:
1607
- u = R;
1608
- break;
1609
- case J.REQUEST:
1610
- m = this.processRequestParam(R);
1611
- break;
1612
- case J.ATTRIBUTE:
1613
- this.processAttributeParam(G, R, S);
1614
- break;
1615
- }
1616
- });
1617
- const M = {
1618
- path: r,
1619
- query: a
1620
- }, _ = {
1621
- method: this.endpoint.method,
1622
- urlParams: M,
1623
- headers: s,
1624
- body: u,
1625
- timeout: this.resolveTimeout(),
1626
- signal: f,
1627
- abortController: y
1628
- }, A = Ue(
1629
- _,
1630
- m
1631
- ), b = m.path;
1632
- return A.url = this.resolvePath(b), {
1633
- request: A,
1634
- attributes: S
1635
- };
1636
- }
1637
- processHttpParam(e, r, a) {
1638
- if (r == null)
1639
- return;
1640
- if (typeof r == "object") {
1641
- Object.entries(r).forEach(([u, f]) => {
1642
- a[u] = f;
1643
- });
1644
- return;
1645
- }
1646
- const s = e.name || `param${e.index}`;
1647
- a[s] = r;
1648
- }
1649
- processPathParam(e, r, a) {
1650
- this.processHttpParam(e, r, a);
1651
- }
1652
- processQueryParam(e, r, a) {
1653
- this.processHttpParam(e, r, a);
1654
- }
1655
- processHeaderParam(e, r, a) {
1656
- this.processHttpParam(e, r, a);
1657
- }
1658
- /**
1659
- * Processes a request parameter value.
1660
- *
1661
- * This method handles the @request() decorator parameter by casting
1662
- * the provided value to a FetcherRequest. The @request() decorator
1663
- * allows users to pass a complete FetcherRequest object to customize
1664
- * the request configuration.
1665
- *
1666
- * @param value - The value provided for the @request() parameter
1667
- * @returns The value cast to FetcherRequest type
1668
- *
1669
- * @example
1670
- * ```typescript
1671
- * @post('/users')
1672
- * createUsers(@request() request: FetcherRequest): Promise<Response>
1673
- *
1674
- * // Usage:
1675
- * const customRequest: FetcherRequest = {
1676
- * headers: { 'X-Custom': 'value' },
1677
- * timeout: 5000
1678
- * };
1679
- * await service.createUsers(customRequest);
1680
- * ```
1681
- */
1682
- processRequestParam(e) {
1683
- if (!e)
1684
- return {};
1685
- const r = e;
1686
- return {
1687
- ...r,
1688
- headers: r.headers || {},
1689
- urlParams: r.urlParams || { path: {}, query: {} }
1690
- };
1691
- }
1692
- processAttributeParam(e, r, a) {
1693
- if (typeof r == "object" || r instanceof Map) {
1694
- St(r, a);
1695
- return;
1696
- }
1697
- e.name && r !== void 0 && a.set(e.name, r);
1698
- }
1699
- };
1700
- const pr = Symbol("api:metadata");
1701
- function yr(t, e, r) {
1702
- const a = t.prototype[e];
1703
- if (e === "constructor" || typeof a != "function")
1704
- return;
1705
- const s = Reflect.getMetadata(
1706
- re,
1707
- t.prototype,
1708
- e
1709
- );
1710
- if (!s)
1711
- return;
1712
- const u = Reflect.getMetadata(
1713
- _t,
1714
- t.prototype,
1715
- e
1716
- ) || /* @__PURE__ */ new Map(), f = new ae(
1717
- e,
1718
- r,
1719
- s,
1720
- u
1721
- );
1722
- t.prototype[e] = async function(...y) {
1723
- return await Er(
1724
- this,
1725
- f
1726
- ).execute(y);
1727
- };
1728
- }
1729
- function Er(t, e) {
1730
- let r = t.requestExecutors;
1731
- r || (r = /* @__PURE__ */ new Map(), t.requestExecutors = r);
1732
- let a = r.get(e.name);
1733
- if (a)
1734
- return a;
1735
- const s = t.apiMetadata, u = {
1736
- ...e.api,
1737
- ...s
1738
- };
1739
- return a = new nr(
1740
- t,
1741
- new ae(
1742
- e.name,
1743
- u,
1744
- e.endpoint,
1745
- e.parameters
1746
- )
1747
- ), r.set(e.name, a), a;
1748
- }
1749
- function Mt(t = "", e = {}) {
1750
- return function(r) {
1751
- const a = {
1752
- basePath: t,
1753
- ...e
1754
- };
1755
- return Reflect.defineMetadata(pr, a, r), Object.getOwnPropertyNames(r.prototype).forEach((s) => {
1756
- yr(r, s, a);
1757
- }), r;
1758
- };
1759
- }
1760
- let vr = class extends Error {
1761
- constructor() {
1762
- super("Implementation will be generated automatically."), this.name = "AutoGenerated";
1763
- }
1764
- };
1765
- const j = (...t) => new vr();
1766
- var wr = Object.defineProperty, Tr = Object.getOwnPropertyDescriptor, At = (t, e, r, a) => {
1767
- for (var s = a > 1 ? void 0 : a ? Tr(e, r) : e, u = t.length - 1, f; u >= 0; u--)
1768
- (f = t[u]) && (s = (a ? f(e, r, s) : f(s)) || s);
1769
- return a && s && wr(e, r, s), s;
1770
- }, lt = (t, e) => (r, a) => e(r, a, t);
1771
- let ht = class {
1772
- constructor(t) {
1773
- this.apiMetadata = t;
1774
- }
1775
- send(t, e) {
1776
- throw j(t, e);
1777
- }
1778
- sendAndWaitStream(t, e) {
1779
- throw j(t, e);
1780
- }
1781
- };
1782
- At([
1783
- gt(),
1784
- lt(0, ne()),
1785
- lt(1, D())
1786
- ], ht.prototype, "send", 1);
1787
- At([
1788
- gt(void 0, void 0, {
1789
- headers: { Accept: ot.TEXT_EVENT_STREAM },
1790
- resultExtractor: yt
1791
- }),
1792
- lt(0, ne()),
1793
- lt(1, D())
1794
- ], ht.prototype, "sendAndWaitStream", 1);
1795
- ht = At([
1796
- Mt()
1797
- ], ht);
1798
- var oe = /* @__PURE__ */ ((t) => (t.AND = "AND", t.OR = "OR", t.NOR = "NOR", t.ID = "ID", t.IDS = "IDS", t.AGGREGATE_ID = "AGGREGATE_ID", t.AGGREGATE_IDS = "AGGREGATE_IDS", t.TENANT_ID = "TENANT_ID", t.OWNER_ID = "OWNER_ID", t.DELETED = "DELETED", t.ALL = "ALL", t.EQ = "EQ", t.NE = "NE", t.GT = "GT", t.LT = "LT", t.GTE = "GTE", t.LTE = "LTE", t.CONTAINS = "CONTAINS", t.IN = "IN", t.NOT_IN = "NOT_IN", t.BETWEEN = "BETWEEN", t.ALL_IN = "ALL_IN", t.STARTS_WITH = "STARTS_WITH", t.ENDS_WITH = "ENDS_WITH", t.ELEM_MATCH = "ELEM_MATCH", t.NULL = "NULL", t.NOT_NULL = "NOT_NULL", t.TRUE = "TRUE", t.FALSE = "FALSE", t.EXISTS = "EXISTS", t.TODAY = "TODAY", t.BEFORE_TODAY = "BEFORE_TODAY", t.TOMORROW = "TOMORROW", t.THIS_WEEK = "THIS_WEEK", t.NEXT_WEEK = "NEXT_WEEK", t.LAST_WEEK = "LAST_WEEK", t.THIS_MONTH = "THIS_MONTH", t.LAST_MONTH = "LAST_MONTH", t.RECENT_DAYS = "RECENT_DAYS", t.EARLIER_DAYS = "EARLIER_DAYS", t.RAW = "RAW", t))(oe || {});
1799
- function Pt() {
1800
- return {
1801
- operator: oe.ALL
1802
- };
1803
- }
1804
- const ie = {
1805
- index: 1,
1806
- size: 10
1807
- };
1808
- function mr({
1809
- condition: t = Pt(),
1810
- projection: e,
1811
- sort: r
1812
- } = {}) {
1813
- return {
1814
- condition: t,
1815
- projection: e,
1816
- sort: r
1817
- };
1818
- }
1819
- function Sr({
1820
- condition: t = Pt(),
1821
- projection: e,
1822
- sort: r,
1823
- limit: a = ie.size
1824
- } = {}) {
1825
- return {
1826
- condition: t,
1827
- projection: e,
1828
- sort: r,
1829
- limit: a
1830
- };
1831
- }
1832
- function _r({
1833
- condition: t = Pt(),
1834
- projection: e,
1835
- sort: r,
1836
- pagination: a = ie
1837
- } = {}) {
1838
- return {
1839
- condition: t,
1840
- projection: e,
1841
- sort: r,
1842
- pagination: a
1843
- };
1844
- }
1845
- const Y = class {
1846
- };
1847
- Y.EVENT_STREAM_RESOURCE_NAME = "event", Y.COUNT = `${Y.EVENT_STREAM_RESOURCE_NAME}/count`, Y.LIST = `${Y.EVENT_STREAM_RESOURCE_NAME}/list`, Y.PAGED = `${Y.EVENT_STREAM_RESOURCE_NAME}/paged`;
1848
- let Et = Y;
1849
- var br = Object.defineProperty, gr = Object.getOwnPropertyDescriptor, ut = (t, e, r, a) => {
1850
- for (var s = a > 1 ? void 0 : a ? gr(e, r) : e, u = t.length - 1, f; u >= 0; u--)
1851
- (f = t[u]) && (s = (a ? f(e, r, s) : f(s)) || s);
1852
- return a && s && br(e, r, s), s;
1853
- }, B = (t, e) => (r, a) => e(r, a, t);
1854
- let et = class {
1855
- /**
1856
- * Creates a new EventStreamQueryClient instance.
1857
- */
1858
- constructor(t) {
1859
- this.apiMetadata = t;
1860
- }
1861
- count(t, e) {
1862
- throw j(t, e);
1863
- }
1864
- list(t, e) {
1865
- throw j(t, e);
1866
- }
1867
- listStream(t, e) {
1868
- throw j(t, e);
1869
- }
1870
- paged(t, e) {
1871
- throw j(t, e);
1872
- }
1873
- };
1874
- ut([
1875
- q(Et.COUNT),
1876
- B(0, H()),
1877
- B(1, D())
1878
- ], et.prototype, "count", 1);
1879
- ut([
1880
- q(Et.LIST),
1881
- B(0, H()),
1882
- B(1, D())
1883
- ], et.prototype, "list", 1);
1884
- ut([
1885
- q(Et.LIST, {
1886
- headers: { Accept: ot.TEXT_EVENT_STREAM },
1887
- resultExtractor: yt
1888
- }),
1889
- B(0, H()),
1890
- B(1, D())
1891
- ], et.prototype, "listStream", 1);
1892
- ut([
1893
- q(Et.PAGED),
1894
- B(0, H()),
1895
- B(1, D())
1896
- ], et.prototype, "paged", 1);
1897
- et = ut([
1898
- Mt()
1899
- ], et);
1900
- const k = class {
1901
- };
1902
- k.SNAPSHOT_RESOURCE_NAME = "snapshot", k.COUNT = `${k.SNAPSHOT_RESOURCE_NAME}/count`, k.LIST = `${k.SNAPSHOT_RESOURCE_NAME}/list`, k.LIST_STATE = `${k.LIST}/state`, k.PAGED = `${k.SNAPSHOT_RESOURCE_NAME}/paged`, k.PAGED_STATE = `${k.PAGED}/state`, k.SINGLE = `${k.SNAPSHOT_RESOURCE_NAME}/single`, k.SINGLE_STATE = `${k.SINGLE}/state`;
1903
- let V = k;
1904
- var Or = Object.defineProperty, Rr = Object.getOwnPropertyDescriptor, Q = (t, e, r, a) => {
1905
- for (var s = a > 1 ? void 0 : a ? Rr(e, r) : e, u = t.length - 1, f; u >= 0; u--)
1906
- (f = t[u]) && (s = (a ? f(e, r, s) : f(s)) || s);
1907
- return a && s && Or(e, r, s), s;
1908
- }, x = (t, e) => (r, a) => e(r, a, t);
1909
- let $ = class {
1910
- /**
1911
- * Creates a new SnapshotQueryClient instance.
1912
- */
1913
- constructor(t) {
1914
- this.apiMetadata = t;
1915
- }
1916
- count(t, e) {
1917
- throw j(t, e);
1918
- }
1919
- list(t, e) {
1920
- throw j(t, e);
1921
- }
1922
- listStream(t, e) {
1923
- throw j(t, e);
1924
- }
1925
- listState(t, e) {
1926
- throw j(t, e);
1927
- }
1928
- listStateStream(t, e) {
1929
- throw j(t, e);
1930
- }
1931
- paged(t, e) {
1932
- throw j(t, e);
1933
- }
1934
- pagedState(t, e) {
1935
- throw j(t, e);
1936
- }
1937
- single(t, e) {
1938
- throw j(t, e);
1939
- }
1940
- singleState(t, e) {
1941
- throw j(t, e);
1942
- }
1943
- };
1944
- Q([
1945
- q(V.COUNT),
1946
- x(0, H()),
1947
- x(1, D())
1948
- ], $.prototype, "count", 1);
1949
- Q([
1950
- q(V.LIST),
1951
- x(0, H()),
1952
- x(1, D())
1953
- ], $.prototype, "list", 1);
1954
- Q([
1955
- q(V.LIST, {
1956
- headers: { Accept: ot.TEXT_EVENT_STREAM },
1957
- resultExtractor: yt
1958
- }),
1959
- x(0, H()),
1960
- x(1, D())
1961
- ], $.prototype, "listStream", 1);
1962
- Q([
1963
- q(V.LIST_STATE),
1964
- x(0, H()),
1965
- x(1, D())
1966
- ], $.prototype, "listState", 1);
1967
- Q([
1968
- q(V.LIST_STATE, {
1969
- headers: { Accept: ot.TEXT_EVENT_STREAM },
1970
- resultExtractor: yt
1971
- }),
1972
- x(0, H()),
1973
- x(1, D())
1974
- ], $.prototype, "listStateStream", 1);
1975
- Q([
1976
- q(V.PAGED),
1977
- x(0, H()),
1978
- x(1, D())
1979
- ], $.prototype, "paged", 1);
1980
- Q([
1981
- q(V.PAGED_STATE),
1982
- x(0, H()),
1983
- x(1, D())
1984
- ], $.prototype, "pagedState", 1);
1985
- Q([
1986
- q(V.SINGLE),
1987
- x(0, H()),
1988
- x(1, D())
1989
- ], $.prototype, "single", 1);
1990
- Q([
1991
- q(V.SINGLE_STATE),
1992
- x(0, H()),
1993
- x(1, D())
1994
- ], $.prototype, "singleState", 1);
1995
- $ = Q([
1996
- Mt()
1997
- ], $);
1998
- function Hr(t) {
1999
- const { initialQuery: e } = t, r = it(t), [a, s] = C(e.condition), [u, f] = C(e.pagination), [y, m] = C(e.projection), [S, M] = C(e.sort), _ = Z(t), A = g(async () => {
2000
- const X = _r({
2001
- condition: a,
2002
- pagination: u,
2003
- projection: y,
2004
- sort: S
2005
- });
2006
- return _.current.query(
2007
- X,
2008
- _.current.attributes
2009
- );
2010
- }, [a, y, u, S, _]), b = g(() => r.execute(A), [r, A]), { autoExecute: R } = t;
2011
- return z(() => {
2012
- R && b();
2013
- }, [R, b]), F(
168
+ function h(t) {
169
+ const { initialQuery: s } = t, e = q(t), u = w(s), a = w(t), r = o(async () => a.current.execute(
170
+ u.current,
171
+ a.current.attributes
172
+ ), [u, a]), n = o(
173
+ (d) => {
174
+ u.current = d;
175
+ },
176
+ [u]
177
+ ), { execute: c } = e, i = o(() => c(r), [c, r]), { autoExecute: l } = t;
178
+ return m(() => {
179
+ l && i();
180
+ }, [l, i]), b(
2014
181
  () => ({
2015
- ...r,
2016
- execute: b,
2017
- setCondition: s,
2018
- setProjection: m,
2019
- setPagination: f,
2020
- setSort: M
182
+ ...e,
183
+ execute: i,
184
+ setQuery: n
2021
185
  }),
2022
- [
2023
- r,
2024
- b,
2025
- s,
2026
- m,
2027
- f,
2028
- M
2029
- ]
186
+ [e, i, n]
2030
187
  );
2031
188
  }
2032
- function Ur(t) {
2033
- const { initialQuery: e } = t, r = it(t), [a, s] = C(e.condition), [u, f] = C(e.projection), [y, m] = C(e.sort), S = Z(t), M = g(async () => {
2034
- const b = mr({
2035
- condition: a,
2036
- projection: u,
2037
- sort: y
2038
- });
2039
- return S.current.query(
2040
- b,
2041
- S.current.attributes
2042
- );
2043
- }, [a, u, y, S]), _ = g(() => r.execute(M), [r, M]), { autoExecute: A } = t;
2044
- return z(() => {
2045
- A && _();
2046
- }, [A, _]), F(
2047
- () => ({
2048
- ...r,
2049
- execute: _,
2050
- setCondition: s,
2051
- setProjection: f,
2052
- setSort: m
2053
- }),
2054
- [r, _, s, f, m]
2055
- );
189
+ function K(t) {
190
+ return h(t);
2056
191
  }
2057
- function $r(t) {
2058
- const { initialCondition: e } = t, r = it(t), [a, s] = C(e), u = Z(t), f = g(async () => u.current.count(
2059
- a,
2060
- u.current.attributes
2061
- ), [a, u]), y = g(() => r.execute(f), [r, f]), { autoExecute: m } = t;
2062
- return z(() => {
2063
- m && y();
2064
- }, [m, y]), F(
2065
- () => ({
2066
- ...r,
2067
- execute: y,
2068
- setCondition: s
2069
- }),
2070
- [r, y, s]
2071
- );
192
+ function N(t) {
193
+ return h(t);
2072
194
  }
2073
- function se(t) {
2074
- const { initialQuery: e } = t, [r, a] = C(e.condition), [s, u] = C(e.projection), [f, y] = C(e.sort), [m, S] = C(e.limit), M = g(() => Sr({
2075
- condition: r,
2076
- projection: s,
2077
- sort: f,
2078
- limit: m
2079
- }), [r, s, f, m]);
2080
- return F(
2081
- () => ({
2082
- condition: r,
2083
- projection: s,
2084
- sort: f,
2085
- limit: m,
2086
- setCondition: a,
2087
- setProjection: u,
2088
- setSort: y,
2089
- setLimit: S,
2090
- buildQuery: M
2091
- }),
2092
- [
2093
- r,
2094
- s,
2095
- f,
2096
- m,
2097
- a,
2098
- u,
2099
- y,
2100
- S,
2101
- M
2102
- ]
2103
- );
195
+ function U(t) {
196
+ return h(t);
2104
197
  }
2105
- function Wr(t) {
2106
- const e = it(t), r = se({ initialQuery: t.initialQuery }), a = Z(t), s = g(async () => {
2107
- const y = r.buildQuery();
2108
- return a.current.list(
2109
- y,
2110
- a.current.attributes
2111
- );
2112
- }, [r, a]), u = g(() => e.execute(s), [e, s]), { autoExecute: f } = t;
2113
- return z(() => {
2114
- f && u();
2115
- }, [f, u]), F(
2116
- () => ({
2117
- ...e,
2118
- execute: u,
2119
- setCondition: r.setCondition,
2120
- setProjection: r.setProjection,
2121
- setSort: r.setSort,
2122
- setLimit: r.setLimit
2123
- }),
2124
- [
2125
- e,
2126
- u,
2127
- r.setCondition,
2128
- r.setProjection,
2129
- r.setSort,
2130
- r.setLimit
2131
- ]
2132
- );
198
+ function V(t) {
199
+ return h(t);
2133
200
  }
2134
- function Fr(t) {
2135
- const e = it(t), r = se({ initialQuery: t.initialQuery }), a = Z(t), s = g(async () => {
2136
- const y = r.buildQuery();
2137
- return a.current.listStream(
2138
- y,
2139
- a.current.attributes
2140
- );
2141
- }, [r, a]), u = g(() => e.execute(s), [e, s]), { autoExecute: f } = t;
2142
- return z(() => {
2143
- f && u();
2144
- }, [f, u]), F(
2145
- () => ({
2146
- ...e,
2147
- execute: u,
2148
- setCondition: r.setCondition,
2149
- setProjection: r.setProjection,
2150
- setSort: r.setSort,
2151
- setLimit: r.setLimit
2152
- }),
2153
- [
2154
- e,
2155
- u,
2156
- r.setCondition,
2157
- r.setProjection,
2158
- r.setSort,
2159
- r.setLimit
2160
- ]
201
+ function j(t) {
202
+ return h(
203
+ t
2161
204
  );
2162
205
  }
2163
206
  export {
2164
- $e as PromiseStatus,
2165
- $r as useCountQuery,
2166
- it as useExecutePromise,
2167
- Ir as useFetcher,
2168
- Pr as useKeyStorage,
2169
- Z as useLatest,
2170
- Wr as useListQuery,
2171
- Fr as useListStreamQuery,
2172
- bt as useMounted,
2173
- Hr as usePagedQuery,
2174
- te as usePromiseState,
2175
- ee as useRequestId,
2176
- Ur as useSingleQuery
207
+ O as PromiseStatus,
208
+ U as useCountQuery,
209
+ q as useExecutePromise,
210
+ G as useFetcher,
211
+ P as useKeyStorage,
212
+ w as useLatest,
213
+ V as useListQuery,
214
+ j as useListStreamQuery,
215
+ R as useMounted,
216
+ K as usePagedQuery,
217
+ C as usePromiseState,
218
+ h as useQuery,
219
+ Q as useRequestId,
220
+ N as useSingleQuery
2177
221
  };
2178
222
  //# sourceMappingURL=index.es.js.map