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