fetchium 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/development/QueryClient-CbG-qdpt.js +2 -0
- package/dist/cjs/development/QueryClient-CbG-qdpt.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-CjSajlTU.js → development/mutation-CFkoRirO.js} +2 -2
- package/dist/cjs/{production/mutation-CjSajlTU.js.map → development/mutation-CFkoRirO.js.map} +1 -1
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/rest/index.js.map +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/production/QueryClient-DGCBmyPp.js +2 -0
- package/dist/cjs/production/QueryClient-DGCBmyPp.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-OJNwoJcf.js → production/mutation-B0wMYfHP.js} +2 -2
- package/dist/cjs/{development/mutation-OJNwoJcf.js.map → production/mutation-B0wMYfHP.js.map} +1 -1
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/rest/index.js.map +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/esm/QueryResult.d.ts +5 -5
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/{QueryClient-DfxP7pt2.js → QueryClient-BZY2FTv3.js} +340 -335
- package/dist/esm/development/QueryClient-BZY2FTv3.js.map +1 -0
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-DZAq7Pbu.js → mutation-Dot2Ejg6.js} +2 -2
- package/dist/esm/development/{mutation-DZAq7Pbu.js.map → mutation-Dot2Ejg6.js.map} +1 -1
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +8 -8
- package/dist/esm/development/rest/index.js.map +1 -1
- package/dist/esm/development/topic/index.js +1 -1
- package/dist/esm/fieldRef.d.ts.map +1 -1
- package/dist/esm/production/{QueryClient-DrWSXg0y.js → QueryClient-WtzRneAd.js} +279 -274
- package/dist/esm/production/QueryClient-WtzRneAd.js.map +1 -0
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-B8dmX5lz.js → mutation-AXg513Dg.js} +2 -2
- package/dist/esm/production/{mutation-B8dmX5lz.js.map → mutation-AXg513Dg.js.map} +1 -1
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +8 -8
- package/dist/esm/production/rest/index.js.map +1 -1
- package/dist/esm/production/topic/index.js +1 -1
- package/dist/esm/rest/RESTQuery.d.ts +2 -0
- package/dist/esm/rest/RESTQuery.d.ts.map +1 -1
- package/dist/esm/rest/RESTQueryAdapter.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/docs/api/fetchium.md +16 -15
- package/plugin/docs/core/queries.md +10 -3
- package/plugin/docs/reference/rest-queries.md +1 -1
- package/dist/cjs/development/QueryClient-BefSCMoE.js +0 -2
- package/dist/cjs/development/QueryClient-BefSCMoE.js.map +0 -1
- package/dist/cjs/production/QueryClient-rbPYznie.js +0 -2
- package/dist/cjs/production/QueryClient-rbPYznie.js.map +0 -1
- package/dist/esm/development/QueryClient-DfxP7pt2.js.map +0 -1
- package/dist/esm/production/QueryClient-DrWSXg0y.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { notifier as
|
|
1
|
+
import { notifier as Z, relay as Lt, setScopeOwner as Ce, reactiveMethod as Se, signal as Ut, context as qt, getContext as Oe, reactiveSignal as st, task as Re, isSignal as xe, watcher as Ae } from "signalium";
|
|
2
2
|
import { registerCustomHash as Ne, hashValue as N, registerCustomSnapshot as De } from "signalium/utils";
|
|
3
|
-
import { d as
|
|
4
|
-
import { SyncQueryStore as Ie, MemoryPersistentStore as
|
|
3
|
+
import { d as Vt } from "./shared-DcuVH8Pf.js";
|
|
4
|
+
import { SyncQueryStore as Ie, MemoryPersistentStore as Fe } from "./stores/sync.js";
|
|
5
5
|
var K = /* @__PURE__ */ ((e) => (e.Always = "always", e.Online = "online", e.OfflineFirst = "offlineFirst", e))(K || {}), d = /* @__PURE__ */ ((e) => (e[e.UNDEFINED = 1] = "UNDEFINED", e[e.NULL = 2] = "NULL", e[e.NUMBER = 4] = "NUMBER", e[e.STRING = 8] = "STRING", e[e.BOOLEAN = 16] = "BOOLEAN", e[e.OBJECT = 32] = "OBJECT", e[e.ARRAY = 64] = "ARRAY", e[e.ID = 128] = "ID", e[e.RECORD = 256] = "RECORD", e[e.UNION = 512] = "UNION", e[e.ENTITY = 1024] = "ENTITY", e[e.HAS_FORMAT = 4096] = "HAS_FORMAT", e[e.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", e[e.PARSE_RESULT = 16384] = "PARSE_RESULT", e[e.LIVE = 32768] = "LIVE", e))(d || {});
|
|
6
|
-
const
|
|
7
|
-
var
|
|
6
|
+
const F = /* @__PURE__ */ Symbol("array"), k = /* @__PURE__ */ Symbol("record"), Kt = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
|
+
var ht = /* @__PURE__ */ ((e) => (e[e.Array = 0] = "Array", e[e.Value = 1] = "Value", e))(ht || {});
|
|
8
8
|
class Q {
|
|
9
9
|
type;
|
|
10
10
|
entityDefs;
|
|
@@ -42,12 +42,12 @@ class Q {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const S = /* @__PURE__ */ new WeakMap();
|
|
46
46
|
function P(e) {
|
|
47
|
-
return
|
|
47
|
+
return S.get(e);
|
|
48
48
|
}
|
|
49
|
-
var
|
|
50
|
-
class
|
|
49
|
+
var tt = /* @__PURE__ */ ((e) => (e[e.Query = 0] = "Query", e[e.Entity = 1] = "Entity", e))(tt || {});
|
|
50
|
+
class ke {
|
|
51
51
|
constructor(t, n, i) {
|
|
52
52
|
this._onEvict = n, this._intervalId = setInterval(this._tick, t * 6e4 * i);
|
|
53
53
|
}
|
|
@@ -88,7 +88,7 @@ class Me {
|
|
|
88
88
|
}
|
|
89
89
|
const { _buckets: r } = this;
|
|
90
90
|
let s = r.get(n);
|
|
91
|
-
s || (s = new
|
|
91
|
+
s || (s = new ke(n, this._onEvict, this._multiplier), r.set(n, s)), s.schedule(t, i);
|
|
92
92
|
}
|
|
93
93
|
cancel(t, n) {
|
|
94
94
|
if (n !== 1 / 0) {
|
|
@@ -121,8 +121,8 @@ class Te {
|
|
|
121
121
|
destroy() {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const z = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"),
|
|
125
|
-
function
|
|
124
|
+
const z = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"), yt = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), J = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Pe = /\[([^\]]+)\]/g;
|
|
125
|
+
function Bt(e) {
|
|
126
126
|
const t = {
|
|
127
127
|
[z]: !0,
|
|
128
128
|
[I]: e
|
|
@@ -139,19 +139,19 @@ const je = {
|
|
|
139
139
|
}
|
|
140
140
|
if (typeof t == "symbol") return;
|
|
141
141
|
const n = e[I];
|
|
142
|
-
return
|
|
142
|
+
return Bt([...n, t]);
|
|
143
143
|
},
|
|
144
144
|
has(e, t) {
|
|
145
145
|
return t === z || t === I;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
function
|
|
148
|
+
function Qt(e) {
|
|
149
149
|
return typeof e == "object" && e !== null && e[z] === !0;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Yt(e) {
|
|
152
152
|
return e[I];
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Gt(e) {
|
|
155
155
|
let t = !1;
|
|
156
156
|
return new Proxy(e, {
|
|
157
157
|
set(n, i, r) {
|
|
@@ -160,14 +160,14 @@ function Yt(e) {
|
|
|
160
160
|
get(n, i) {
|
|
161
161
|
if (t)
|
|
162
162
|
throw new Error("Definition proxy accessed after extraction. Avoid arrow functions that capture `this`.");
|
|
163
|
-
return i ===
|
|
163
|
+
return i === yt ? n : i === J ? () => {
|
|
164
164
|
t = !0;
|
|
165
|
-
} : typeof i == "symbol" ? n[i] :
|
|
165
|
+
} : typeof i == "symbol" ? n[i] : Bt([i]);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
function $e(e) {
|
|
170
|
-
const t = e[
|
|
170
|
+
const t = e[yt];
|
|
171
171
|
e[J]();
|
|
172
172
|
const n = {};
|
|
173
173
|
for (const s of Object.getOwnPropertyNames(t))
|
|
@@ -184,7 +184,7 @@ function $e(e) {
|
|
|
184
184
|
}
|
|
185
185
|
return { fields: n, methods: i };
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function pt(e, t) {
|
|
188
188
|
let n = t;
|
|
189
189
|
for (const i of e) {
|
|
190
190
|
if (n == null) return;
|
|
@@ -194,13 +194,13 @@ function yt(e, t) {
|
|
|
194
194
|
}
|
|
195
195
|
function Le(e, t) {
|
|
196
196
|
return e.replace(Pe, (n, i) => {
|
|
197
|
-
const r = i.split("."), s =
|
|
197
|
+
const r = i.split("."), s = pt(r, t);
|
|
198
198
|
return s != null ? encodeURIComponent(String(s)) : "";
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
function X(e, t) {
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
202
|
+
if (Qt(e))
|
|
203
|
+
return pt(Yt(e), t);
|
|
204
204
|
if (typeof e == "string")
|
|
205
205
|
return Le(e, t);
|
|
206
206
|
if (Array.isArray(e))
|
|
@@ -213,23 +213,23 @@ function X(e, t) {
|
|
|
213
213
|
}
|
|
214
214
|
return e;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function ot(e, t, n) {
|
|
217
217
|
const i = e.fields, r = e.methods, s = { params: t }, o = {};
|
|
218
218
|
for (const [a, c] of Object.entries(i))
|
|
219
219
|
o[a] = X(c, s);
|
|
220
|
-
o.params = t, o.context = n;
|
|
220
|
+
o.params = t, o.context = n, o.responseNotifier = Z();
|
|
221
221
|
for (const [a, c] of Object.entries(r))
|
|
222
222
|
o[a] = c.bind(o);
|
|
223
223
|
return o;
|
|
224
224
|
}
|
|
225
|
-
class
|
|
225
|
+
class gt {
|
|
226
226
|
static cache;
|
|
227
227
|
constructor() {
|
|
228
|
-
return
|
|
228
|
+
return Gt(this);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
let
|
|
231
|
+
const Ht = Object.entries, at = Object.keys;
|
|
232
|
+
let Wt = () => {
|
|
233
233
|
};
|
|
234
234
|
{
|
|
235
235
|
const t = (i, r) => {
|
|
@@ -249,7 +249,7 @@ let Ht = () => {
|
|
|
249
249
|
if (typeof i == "string") return i === r;
|
|
250
250
|
if (i instanceof Set && r instanceof Set)
|
|
251
251
|
return t(i, r);
|
|
252
|
-
if (i instanceof
|
|
252
|
+
if (i instanceof v && r instanceof v) {
|
|
253
253
|
const s = i.mask, o = r.mask;
|
|
254
254
|
if ((s & 65535) !== (o & 65535)) return !1;
|
|
255
255
|
const a = s >> 16, c = o >> 16;
|
|
@@ -266,20 +266,20 @@ let Ht = () => {
|
|
|
266
266
|
}
|
|
267
267
|
return !1;
|
|
268
268
|
};
|
|
269
|
-
|
|
269
|
+
Wt = (i, r, s, o) => {
|
|
270
270
|
if (!n(s, o))
|
|
271
271
|
throw new Error(
|
|
272
272
|
`[fetchium] Entity typename '${i}' has incompatible type for field '${r}' across different entity definitions`
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
return typeof e == "number" ? e | d.UNDEFINED : e instanceof
|
|
276
|
+
function xt(e) {
|
|
277
|
+
return typeof e == "number" ? e | d.UNDEFINED : e instanceof v ? (e.mask & d.UNDEFINED) !== 0 ? e : v.cloneWith(e, d.UNDEFINED) : e;
|
|
278
278
|
}
|
|
279
279
|
function At(e) {
|
|
280
|
-
return e instanceof
|
|
280
|
+
return e instanceof v && (e.mask & d.OBJECT) !== 0 && (e.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function zt(e, t, n) {
|
|
283
283
|
const i = /* @__PURE__ */ new Set();
|
|
284
284
|
for (const s of e)
|
|
285
285
|
if (s !== void 0)
|
|
@@ -292,17 +292,17 @@ function Wt(e, t, n) {
|
|
|
292
292
|
let f = !0;
|
|
293
293
|
for (const l of e) {
|
|
294
294
|
const u = l?.[s];
|
|
295
|
-
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !At(u) &&
|
|
295
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !At(u) && Wt(n, s, a, u), At(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
296
296
|
}
|
|
297
297
|
if (f && o > 0) {
|
|
298
|
-
const l =
|
|
299
|
-
r[s] = o < t ?
|
|
298
|
+
const l = zt(c, t, n), u = new v(d.OBJECT, l);
|
|
299
|
+
r[s] = o < t ? xt(u) : u;
|
|
300
300
|
} else
|
|
301
|
-
r[s] = o < t ?
|
|
301
|
+
r[s] = o < t ? xt(a) : a;
|
|
302
302
|
}
|
|
303
303
|
return r;
|
|
304
304
|
}
|
|
305
|
-
class
|
|
305
|
+
class v {
|
|
306
306
|
mask;
|
|
307
307
|
shape;
|
|
308
308
|
typenameField = void 0;
|
|
@@ -336,7 +336,7 @@ class m {
|
|
|
336
336
|
}
|
|
337
337
|
static merge(t) {
|
|
338
338
|
if (t.length === 1) return t[0];
|
|
339
|
-
const n = t.length, i = t.map((f) => f.shape), r = t[0].typenameValue ?? "(unknown)", s =
|
|
339
|
+
const n = t.length, i = t.map((f) => f.shape), r = t[0].typenameValue ?? "(unknown)", s = zt(i, n, r);
|
|
340
340
|
let o, a, c;
|
|
341
341
|
for (const f of t) {
|
|
342
342
|
if (o === void 0 && f.idField !== void 0)
|
|
@@ -347,7 +347,7 @@ class m {
|
|
|
347
347
|
);
|
|
348
348
|
a === void 0 && (a = f.typenameField), c === void 0 && (c = f.typenameValue);
|
|
349
349
|
}
|
|
350
|
-
return new
|
|
350
|
+
return new v(
|
|
351
351
|
d.ENTITY | d.OBJECT,
|
|
352
352
|
s,
|
|
353
353
|
void 0,
|
|
@@ -357,7 +357,7 @@ class m {
|
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
359
|
static cloneWith(t, n) {
|
|
360
|
-
const i = new
|
|
360
|
+
const i = new v(
|
|
361
361
|
n | t.mask,
|
|
362
362
|
t.shape,
|
|
363
363
|
t.values,
|
|
@@ -410,21 +410,21 @@ Ne(L, (e) => {
|
|
|
410
410
|
t += N(n);
|
|
411
411
|
return t >>> 0;
|
|
412
412
|
});
|
|
413
|
-
function
|
|
414
|
-
return new
|
|
413
|
+
function vt(e, t) {
|
|
414
|
+
return new v(e, t);
|
|
415
415
|
}
|
|
416
416
|
function qe(e) {
|
|
417
|
-
return
|
|
417
|
+
return vt(d.ARRAY, e);
|
|
418
418
|
}
|
|
419
419
|
function Ve(e) {
|
|
420
|
-
return
|
|
420
|
+
return vt(d.RECORD | d.OBJECT, e);
|
|
421
421
|
}
|
|
422
422
|
function Ke(e) {
|
|
423
|
-
return
|
|
423
|
+
return vt(d.PARSE_RESULT, e);
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function Jt(e, t) {
|
|
426
426
|
let n = e, i, r, s;
|
|
427
|
-
for (const [o, a] of
|
|
427
|
+
for (const [o, a] of Ht(t))
|
|
428
428
|
switch (typeof a) {
|
|
429
429
|
case "number":
|
|
430
430
|
if ((a & d.ID) !== 0) {
|
|
@@ -444,12 +444,12 @@ function zt(e, t) {
|
|
|
444
444
|
a.mask & d.LIVE && (n |= d.LIVE);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
|
-
return new
|
|
447
|
+
return new v(n, t, void 0, r, s, i);
|
|
448
448
|
}
|
|
449
449
|
function Be(e) {
|
|
450
|
-
return
|
|
450
|
+
return Jt(d.OBJECT, e);
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function Nt(e, t, n) {
|
|
453
453
|
const i = e.mask;
|
|
454
454
|
if ((i & d.UNION) !== 0) {
|
|
455
455
|
const r = e;
|
|
@@ -462,7 +462,7 @@ function xt(e, t, n) {
|
|
|
462
462
|
}
|
|
463
463
|
const s = r.shape;
|
|
464
464
|
if (s !== void 0)
|
|
465
|
-
for (const o of [...
|
|
465
|
+
for (const o of [...at(s), F, k]) {
|
|
466
466
|
const a = s[o];
|
|
467
467
|
if (t[o] !== void 0 && t[o] !== a)
|
|
468
468
|
throw new Error(
|
|
@@ -471,13 +471,13 @@ function xt(e, t, n) {
|
|
|
471
471
|
t[o] = a;
|
|
472
472
|
}
|
|
473
473
|
} else if ((i & d.ARRAY) !== 0) {
|
|
474
|
-
if (t[
|
|
474
|
+
if (t[F] !== void 0)
|
|
475
475
|
throw new Error("Array shape already defined");
|
|
476
|
-
t[
|
|
476
|
+
t[F] = e.shape;
|
|
477
477
|
} else if ((i & d.RECORD) !== 0) {
|
|
478
|
-
if (t[
|
|
478
|
+
if (t[k] !== void 0)
|
|
479
479
|
throw new Error("Record shape already defined");
|
|
480
|
-
t[
|
|
480
|
+
t[k] = e.shape;
|
|
481
481
|
} else {
|
|
482
482
|
const r = e.typenameField, s = e.typenameValue;
|
|
483
483
|
if (s === void 0)
|
|
@@ -510,33 +510,33 @@ function mt(...e) {
|
|
|
510
510
|
r = l;
|
|
511
511
|
continue;
|
|
512
512
|
}
|
|
513
|
-
i === 2 && (o = /* @__PURE__ */ Object.create(null), a =
|
|
513
|
+
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Nt(r, o, a)), a = Nt(l, o, a);
|
|
514
514
|
}
|
|
515
515
|
if (i === 0)
|
|
516
|
-
return s === void 0 ? n : n === 0 ? s : new
|
|
516
|
+
return s === void 0 ? n : n === 0 ? s : new v(n | d.UNION, void 0, s);
|
|
517
517
|
if (i === 1)
|
|
518
|
-
return
|
|
518
|
+
return v.cloneWith(r, n);
|
|
519
519
|
const f = n | c | d.UNION;
|
|
520
|
-
return new
|
|
520
|
+
return new v(f, o, s, a);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function _t(e, t, n) {
|
|
523
523
|
const i = e;
|
|
524
524
|
if (typeof i == "number")
|
|
525
525
|
return i | t;
|
|
526
526
|
if (i instanceof Set)
|
|
527
527
|
return mt(e, t);
|
|
528
528
|
let r = n.get(i);
|
|
529
|
-
return r === void 0 && (r =
|
|
529
|
+
return r === void 0 && (r = v.cloneWith(i, t), n.set(i, r)), r;
|
|
530
530
|
}
|
|
531
531
|
const Qe = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), Ge = /* @__PURE__ */ new WeakMap();
|
|
532
532
|
function He(e) {
|
|
533
|
-
return
|
|
533
|
+
return _t(e, d.UNDEFINED | d.NULL, Ge);
|
|
534
534
|
}
|
|
535
535
|
function We(e) {
|
|
536
|
-
return
|
|
536
|
+
return _t(e, d.UNDEFINED, Qe);
|
|
537
537
|
}
|
|
538
538
|
function ze(e) {
|
|
539
|
-
return
|
|
539
|
+
return _t(e, d.NULL, Ye);
|
|
540
540
|
}
|
|
541
541
|
function Je(e) {
|
|
542
542
|
return e;
|
|
@@ -544,43 +544,43 @@ function Je(e) {
|
|
|
544
544
|
function Xe(e) {
|
|
545
545
|
return /* @__PURE__ */ new Set([e]);
|
|
546
546
|
}
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
const
|
|
547
|
+
const Xt = ((...e) => new Set(e));
|
|
548
|
+
Xt.caseInsensitive = (...e) => new L(e);
|
|
549
|
+
const wt = 16;
|
|
550
550
|
let Ze = 0;
|
|
551
|
-
const
|
|
551
|
+
const ct = [], Zt = [], te = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), et = /* @__PURE__ */ new WeakSet();
|
|
552
552
|
class Y {
|
|
553
553
|
_raw;
|
|
554
554
|
_formatted;
|
|
555
555
|
_parsed;
|
|
556
556
|
_formatId;
|
|
557
557
|
constructor(t, n, i) {
|
|
558
|
-
this._raw = t, this._formatId = n, i ? (this._formatted =
|
|
558
|
+
this._raw = t, this._formatId = n, i ? (this._formatted = ct[n](t), this._parsed = !0) : this._parsed = !1, et.add(this);
|
|
559
559
|
}
|
|
560
560
|
getValue() {
|
|
561
|
-
return this._parsed || (this._formatted =
|
|
561
|
+
return this._parsed || (this._formatted = ct[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
562
562
|
}
|
|
563
563
|
toJSON() {
|
|
564
|
-
return this._parsed ?
|
|
564
|
+
return this._parsed ? Zt[this._formatId](this._formatted) : this._raw;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
function tn(e) {
|
|
568
|
-
const t =
|
|
568
|
+
const t = te.get(e);
|
|
569
569
|
if (t === void 0)
|
|
570
570
|
throw new Error(`Format ${e} not registered`);
|
|
571
571
|
return t;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
const t = e >>
|
|
575
|
-
return
|
|
573
|
+
function Dt(e) {
|
|
574
|
+
const t = e >> wt;
|
|
575
|
+
return ee.get(t);
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function ne(e, t, n, i, r) {
|
|
578
578
|
const s = Ze++;
|
|
579
|
-
|
|
580
|
-
const o = r?.eager ?? !0, c = s <<
|
|
581
|
-
|
|
579
|
+
ct[s] = n, Zt[s] = i, ee.set(s, e);
|
|
580
|
+
const o = r?.eager ?? !0, c = s << wt | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
581
|
+
te.set(e, c);
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
ne(
|
|
584
584
|
"date",
|
|
585
585
|
d.STRING,
|
|
586
586
|
(e) => {
|
|
@@ -597,7 +597,7 @@ ee(
|
|
|
597
597
|
return `${t}-${n}-${i}`;
|
|
598
598
|
}
|
|
599
599
|
);
|
|
600
|
-
|
|
600
|
+
ne(
|
|
601
601
|
"date-time",
|
|
602
602
|
d.STRING,
|
|
603
603
|
(e) => {
|
|
@@ -608,15 +608,15 @@ ee(
|
|
|
608
608
|
},
|
|
609
609
|
(e) => e.toISOString()
|
|
610
610
|
);
|
|
611
|
-
const
|
|
611
|
+
const It = /* @__PURE__ */ new WeakMap();
|
|
612
612
|
function $(e) {
|
|
613
|
-
let t =
|
|
613
|
+
let t = It.get(e);
|
|
614
614
|
if (t === void 0) {
|
|
615
|
-
const n = new e(), i = n[
|
|
615
|
+
const n = new e(), i = n[yt] ?? n;
|
|
616
616
|
n[J] && n[J]();
|
|
617
617
|
const r = {};
|
|
618
|
-
for (const [f, l] of
|
|
619
|
-
if (!(typeof l == "number" || typeof l == "string" || l instanceof Set || l instanceof
|
|
618
|
+
for (const [f, l] of Ht(i)) {
|
|
619
|
+
if (!(typeof l == "number" || typeof l == "string" || l instanceof Set || l instanceof v || l instanceof L))
|
|
620
620
|
throw new Error(
|
|
621
621
|
`[fetchium] Entity '${e.name}' field '${f}' has an invalid type definition. All entity fields must be type definitions (e.g. t.string, t.number, t.entity(...), etc). Got: ${typeof l == "object" ? l?.constructor?.name ?? typeof l : typeof l}`
|
|
622
622
|
);
|
|
@@ -625,9 +625,9 @@ function $(e) {
|
|
|
625
625
|
const s = Object.getPrototypeOf(e.prototype);
|
|
626
626
|
if (s != null) {
|
|
627
627
|
const f = s.constructor;
|
|
628
|
-
if (f !==
|
|
628
|
+
if (f !== gt && typeof f == "function") {
|
|
629
629
|
const u = $(f).shape;
|
|
630
|
-
for (const h of
|
|
630
|
+
for (const h of at(u))
|
|
631
631
|
if (h in r && r[h] !== u[h])
|
|
632
632
|
throw new Error(`Cannot extend: field '${h}' already exists in type definition`);
|
|
633
633
|
}
|
|
@@ -635,16 +635,16 @@ function $(e) {
|
|
|
635
635
|
const o = {}, a = e.prototype;
|
|
636
636
|
for (const f of Object.getOwnPropertyNames(a))
|
|
637
637
|
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
638
|
-
t =
|
|
638
|
+
t = Jt(d.ENTITY | d.OBJECT, r), t._entityClass = e, at(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
639
639
|
const c = e;
|
|
640
|
-
c.cache && (t._entityCache = c.cache),
|
|
640
|
+
c.cache && (t._entityCache = c.cache), It.set(e, t);
|
|
641
641
|
}
|
|
642
642
|
return t;
|
|
643
643
|
}
|
|
644
644
|
function en(e) {
|
|
645
645
|
return $(e);
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function ie(e, t) {
|
|
648
648
|
if (t == null) return;
|
|
649
649
|
const n = /* @__PURE__ */ new Map();
|
|
650
650
|
if (Array.isArray(t))
|
|
@@ -667,22 +667,22 @@ function ne(e, t) {
|
|
|
667
667
|
}
|
|
668
668
|
return n.size > 0 ? n : void 0;
|
|
669
669
|
}
|
|
670
|
-
function
|
|
670
|
+
function re(e) {
|
|
671
671
|
return Array.isArray(e) ? e.map((t) => $(t)) : [$(e)];
|
|
672
672
|
}
|
|
673
673
|
function nn(e, t) {
|
|
674
|
-
const n =
|
|
674
|
+
const n = re(e), i = n.length === 1 ? n[0] : mt(...n.map((o) => o)), r = d.ARRAY | d.LIVE, s = new v(r, i);
|
|
675
675
|
return s._liveConfig = Q.array(
|
|
676
676
|
n,
|
|
677
|
-
|
|
677
|
+
ie(n, t?.constraints),
|
|
678
678
|
t?.sort
|
|
679
679
|
), s;
|
|
680
680
|
}
|
|
681
681
|
function rn(e, t, n) {
|
|
682
|
-
const i =
|
|
682
|
+
const i = re(t), r = e, s = d.LIVE, o = new v(s, void 0);
|
|
683
683
|
return o._liveConfig = Q.value(
|
|
684
684
|
i,
|
|
685
|
-
|
|
685
|
+
ie(i, n?.constraints),
|
|
686
686
|
r,
|
|
687
687
|
n.onCreate,
|
|
688
688
|
n.onUpdate,
|
|
@@ -693,7 +693,7 @@ const sn = {
|
|
|
693
693
|
format: tn,
|
|
694
694
|
typename: Je,
|
|
695
695
|
const: Xe,
|
|
696
|
-
enum:
|
|
696
|
+
enum: Xt,
|
|
697
697
|
id: d.ID | d.STRING | d.NUMBER,
|
|
698
698
|
string: d.STRING,
|
|
699
699
|
number: d.NUMBER,
|
|
@@ -723,7 +723,7 @@ function B(e) {
|
|
|
723
723
|
return String(e);
|
|
724
724
|
if (typeof e == "number") {
|
|
725
725
|
if ((e & d.HAS_FORMAT) !== 0) {
|
|
726
|
-
const r =
|
|
726
|
+
const r = Dt(e);
|
|
727
727
|
if (r)
|
|
728
728
|
return `"${r}"`;
|
|
729
729
|
}
|
|
@@ -739,12 +739,12 @@ function B(e) {
|
|
|
739
739
|
i.push(o);
|
|
740
740
|
}
|
|
741
741
|
if (n.shape !== void 0) {
|
|
742
|
-
n.shape[
|
|
742
|
+
n.shape[F] !== void 0 && i.push(`Array<${B(n.shape[F])}>`), n.shape[k] !== void 0 && i.push(`Record<string, ${B(n.shape[k])}>`);
|
|
743
743
|
for (const [s, o] of Object.entries(n.shape))
|
|
744
|
-
s !==
|
|
744
|
+
s !== F && s !== k && i.push(s);
|
|
745
745
|
}
|
|
746
746
|
if (t = n.mask, (t & d.HAS_FORMAT) !== 0) {
|
|
747
|
-
const s =
|
|
747
|
+
const s = Dt(t);
|
|
748
748
|
s && i.push(`"${s}"`);
|
|
749
749
|
}
|
|
750
750
|
return t & d.UNDEFINED && i.push("undefined"), t & d.NULL && i.push("null"), t & d.NUMBER && i.push("number"), t & d.STRING && i.push("string"), t & d.BOOLEAN && i.push("boolean"), i.length === 0 ? "union" : i.join(" | ");
|
|
@@ -770,8 +770,8 @@ function V(e, t, n) {
|
|
|
770
770
|
`Validation error at ${e}: expected ${B(t)}, got ${typeof n == "object" ? n === null ? "null" : Array.isArray(n) ? "array" : "object" : typeof n}`
|
|
771
771
|
);
|
|
772
772
|
}
|
|
773
|
-
const
|
|
774
|
-
function
|
|
773
|
+
const se = Array.isArray;
|
|
774
|
+
function Ft(e) {
|
|
775
775
|
if (e === null) return d.NULL;
|
|
776
776
|
switch (typeof e) {
|
|
777
777
|
case "number":
|
|
@@ -783,7 +783,7 @@ function It(e) {
|
|
|
783
783
|
case "undefined":
|
|
784
784
|
return d.UNDEFINED;
|
|
785
785
|
case "object":
|
|
786
|
-
return
|
|
786
|
+
return se(e) ? d.ARRAY : d.OBJECT;
|
|
787
787
|
default:
|
|
788
788
|
throw new Error(`Invalid type: ${typeof e}`);
|
|
789
789
|
}
|
|
@@ -794,7 +794,7 @@ function $n(e) {
|
|
|
794
794
|
function j(e) {
|
|
795
795
|
if (e === null || typeof e != "object")
|
|
796
796
|
return e;
|
|
797
|
-
if (
|
|
797
|
+
if (se(e))
|
|
798
798
|
return e.map((n) => j(n));
|
|
799
799
|
if (e instanceof Date)
|
|
800
800
|
return new Date(e.getTime());
|
|
@@ -815,9 +815,9 @@ function j(e) {
|
|
|
815
815
|
t[n] = j(e[n]);
|
|
816
816
|
return t;
|
|
817
817
|
}
|
|
818
|
-
const
|
|
818
|
+
const Et = Object.entries, on = () => {
|
|
819
819
|
};
|
|
820
|
-
class
|
|
820
|
+
class ft {
|
|
821
821
|
queryClient = void 0;
|
|
822
822
|
preloadedEntities = void 0;
|
|
823
823
|
warn = on;
|
|
@@ -830,14 +830,14 @@ class at {
|
|
|
830
830
|
this.queryClient = t, this.preloadedEntities = n, this.warn = i, this.isPartialEvent = r, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
function
|
|
833
|
+
function oe(e, t, n) {
|
|
834
834
|
return M(e, t, n, "");
|
|
835
835
|
}
|
|
836
836
|
function an(e, t, n) {
|
|
837
|
-
return
|
|
837
|
+
return bt(e, t, n);
|
|
838
838
|
}
|
|
839
839
|
function kt(e, t, n, i) {
|
|
840
|
-
const r = e >>
|
|
840
|
+
const r = e >> wt;
|
|
841
841
|
if ((e & d.IS_EAGER_FORMAT) !== 0)
|
|
842
842
|
try {
|
|
843
843
|
return new Y(t, r, !0);
|
|
@@ -871,7 +871,7 @@ function M(e, t, n, i) {
|
|
|
871
871
|
return e;
|
|
872
872
|
}
|
|
873
873
|
if (typeof r == "number") {
|
|
874
|
-
const c =
|
|
874
|
+
const c = Ft(e);
|
|
875
875
|
if ((r & c) === 0) {
|
|
876
876
|
if ((r & d.UNDEFINED) !== 0) {
|
|
877
877
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
@@ -882,7 +882,7 @@ function M(e, t, n, i) {
|
|
|
882
882
|
return (r & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? kt(r, e, n, i) : e;
|
|
883
883
|
}
|
|
884
884
|
const s = r.mask, o = r._liveConfig;
|
|
885
|
-
if (o !== void 0 && o.type ===
|
|
885
|
+
if (o !== void 0 && o.type === ht.Value)
|
|
886
886
|
return o.valueType !== void 0 ? M(e, o.valueType, n, i) : e;
|
|
887
887
|
if ((s & d.PARSE_RESULT) !== 0)
|
|
888
888
|
try {
|
|
@@ -890,7 +890,7 @@ function M(e, t, n, i) {
|
|
|
890
890
|
} catch (c) {
|
|
891
891
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
892
892
|
}
|
|
893
|
-
const a =
|
|
893
|
+
const a = Ft(e);
|
|
894
894
|
if ((s & a) === 0 && !r.values?.has(e)) {
|
|
895
895
|
if ((s & d.UNDEFINED) !== 0) {
|
|
896
896
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
@@ -898,29 +898,29 @@ function M(e, t, n, i) {
|
|
|
898
898
|
}
|
|
899
899
|
throw V(i, s, e);
|
|
900
900
|
}
|
|
901
|
-
return a < d.OBJECT ? (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? kt(s, e, n, i) : e : (s & d.UNION) !== 0 ? cn(a, e, r, n, i) : a === d.ARRAY ?
|
|
901
|
+
return a < d.OBJECT ? (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? kt(s, e, n, i) : e : (s & d.UNION) !== 0 ? cn(a, e, r, n, i) : a === d.ARRAY ? ae(e, r.shape, n, i) : (s & d.RECORD) !== 0 ? ce(e, r.shape, n, i) : (s & d.ENTITY) !== 0 && n.queryClient !== void 0 ? bt(e, r, n) : fe(e, r, n, i);
|
|
902
902
|
}
|
|
903
903
|
function cn(e, t, n, i, r) {
|
|
904
904
|
if (e === d.ARRAY) {
|
|
905
|
-
const s = n.shape[
|
|
906
|
-
return s === void 0 || typeof s == "number" ? t :
|
|
905
|
+
const s = n.shape[F];
|
|
906
|
+
return s === void 0 || typeof s == "number" ? t : ae(t, s, i, r);
|
|
907
907
|
} else {
|
|
908
908
|
const s = n.typenameField, o = s ? t[s] : void 0;
|
|
909
909
|
if (o === void 0 || typeof o != "string") {
|
|
910
|
-
const c = n.shape[
|
|
910
|
+
const c = n.shape[k];
|
|
911
911
|
if (c === void 0)
|
|
912
912
|
throw new Error(
|
|
913
913
|
`Typename field '${s}' is required for union discrimination but was not found in the data`
|
|
914
914
|
);
|
|
915
|
-
return
|
|
915
|
+
return ce(t, c, i, r);
|
|
916
916
|
}
|
|
917
917
|
const a = n.shape[o];
|
|
918
918
|
if (a === void 0 || typeof a == "number")
|
|
919
919
|
throw new Error(`Unknown typename '${o}' in union`);
|
|
920
|
-
return a.mask & d.ENTITY && i.queryClient !== void 0 ?
|
|
920
|
+
return a.mask & d.ENTITY && i.queryClient !== void 0 ? bt(t, a, i) : fe(t, a, i, r);
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function ae(e, t, n, i) {
|
|
924
924
|
const r = [];
|
|
925
925
|
for (let s = 0; s < e.length; s++)
|
|
926
926
|
try {
|
|
@@ -934,20 +934,20 @@ function oe(e, t, n, i) {
|
|
|
934
934
|
}
|
|
935
935
|
return r;
|
|
936
936
|
}
|
|
937
|
-
function
|
|
938
|
-
for (const [r, s] of
|
|
937
|
+
function ce(e, t, n, i) {
|
|
938
|
+
for (const [r, s] of Et(e))
|
|
939
939
|
e[r] = M(s, t, n, `${i}["${r}"]`);
|
|
940
940
|
return e;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
if (
|
|
942
|
+
function fe(e, t, n, i) {
|
|
943
|
+
if (S.has(e))
|
|
944
944
|
return e;
|
|
945
945
|
const r = t.shape;
|
|
946
|
-
for (const [s, o] of
|
|
946
|
+
for (const [s, o] of Et(r))
|
|
947
947
|
e[s] = M(e[s], o, n, `${i}.${s}`);
|
|
948
948
|
return e;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function bt(e, t, n) {
|
|
951
951
|
const i = n.queryClient, r = n.preloadedEntities;
|
|
952
952
|
let s, o;
|
|
953
953
|
if (r !== void 0)
|
|
@@ -977,7 +977,7 @@ function Et(e, t, n) {
|
|
|
977
977
|
};
|
|
978
978
|
n.seen.set(c, u), n.seenByKey.set(s, u);
|
|
979
979
|
const h = `[[${t.typenameValue}:${o}]]`, g = t.shape;
|
|
980
|
-
for (const [p, _] of
|
|
980
|
+
for (const [p, _] of Et(g))
|
|
981
981
|
l && !(p in e) || (c[p] = M(e[p], _, n, `${h}.${p}`));
|
|
982
982
|
return c;
|
|
983
983
|
}
|
|
@@ -989,7 +989,7 @@ function un(e, t, n) {
|
|
|
989
989
|
for (const i of Object.keys(t)) {
|
|
990
990
|
if (i === n) continue;
|
|
991
991
|
const r = t[i];
|
|
992
|
-
if (r instanceof
|
|
992
|
+
if (r instanceof v) {
|
|
993
993
|
if ((r.mask & d.UNDEFINED) !== 0) continue;
|
|
994
994
|
if (!(i in e) || e[i] === void 0) return !1;
|
|
995
995
|
} else if (typeof r == "number") {
|
|
@@ -1000,10 +1000,10 @@ function un(e, t, n) {
|
|
|
1000
1000
|
return !0;
|
|
1001
1001
|
}
|
|
1002
1002
|
const dn = Object.prototype, W = /* @__PURE__ */ new WeakMap();
|
|
1003
|
-
function
|
|
1003
|
+
function A(e) {
|
|
1004
1004
|
if (typeof e != "object" || e === null) return e;
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1005
|
+
if (et.has(e)) return A(e.getValue());
|
|
1006
|
+
if (S.has(e)) return e;
|
|
1007
1007
|
if (Array.isArray(e)) {
|
|
1008
1008
|
let t = W.get(e);
|
|
1009
1009
|
return t === void 0 && (t = new Proxy(e, ln), W.set(e, t)), t;
|
|
@@ -1019,7 +1019,7 @@ const ln = {
|
|
|
1019
1019
|
if (typeof t == "string") {
|
|
1020
1020
|
const i = Number(t);
|
|
1021
1021
|
if (Number.isInteger(i) && i >= 0 && i < e.length)
|
|
1022
|
-
return
|
|
1022
|
+
return A(e[i]);
|
|
1023
1023
|
}
|
|
1024
1024
|
return Reflect.get(e, t, n);
|
|
1025
1025
|
},
|
|
@@ -1031,7 +1031,7 @@ const ln = {
|
|
|
1031
1031
|
}
|
|
1032
1032
|
}, hn = {
|
|
1033
1033
|
get(e, t, n) {
|
|
1034
|
-
return typeof t == "string" ?
|
|
1034
|
+
return typeof t == "string" ? A(e[t]) : Reflect.get(e, t, n);
|
|
1035
1035
|
},
|
|
1036
1036
|
set() {
|
|
1037
1037
|
throw new Error("Cannot mutate a read-only object");
|
|
@@ -1060,7 +1060,7 @@ const ln = {
|
|
|
1060
1060
|
return o ? a : s;
|
|
1061
1061
|
};
|
|
1062
1062
|
De(
|
|
1063
|
-
|
|
1063
|
+
gt,
|
|
1064
1064
|
yn
|
|
1065
1065
|
);
|
|
1066
1066
|
class pn {
|
|
@@ -1081,7 +1081,7 @@ class pn {
|
|
|
1081
1081
|
_extraMethods;
|
|
1082
1082
|
_extraGetters;
|
|
1083
1083
|
constructor(t, n, i, r, s, o) {
|
|
1084
|
-
this._notifier =
|
|
1084
|
+
this._notifier = Z(), this._queryClient = o, this.key = t, this.typename = n, this.id = i, this.idField = r, this.data = s, this.entityRefs = void 0;
|
|
1085
1085
|
}
|
|
1086
1086
|
retain() {
|
|
1087
1087
|
this.refCount++;
|
|
@@ -1093,7 +1093,7 @@ class pn {
|
|
|
1093
1093
|
if (this.refCount < 0)
|
|
1094
1094
|
throw new Error(`Entity ${this.typename}:${this.id} released more times than retained`);
|
|
1095
1095
|
const t = this._entityCache?.gcTime;
|
|
1096
|
-
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t,
|
|
1096
|
+
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, tt.Entity) : this.evict();
|
|
1097
1097
|
}
|
|
1098
1098
|
evict() {
|
|
1099
1099
|
const t = this.liveCollections.slice();
|
|
@@ -1127,7 +1127,7 @@ class pn {
|
|
|
1127
1127
|
getProxy(t) {
|
|
1128
1128
|
const n = t;
|
|
1129
1129
|
let i = this._proxies.get(n);
|
|
1130
|
-
return i === void 0 && (i =
|
|
1130
|
+
return i === void 0 && (i = vn(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(n, i)), i;
|
|
1131
1131
|
}
|
|
1132
1132
|
get proxy() {
|
|
1133
1133
|
return this._proxies.values().next().value;
|
|
@@ -1149,34 +1149,34 @@ function gn(e, t, n) {
|
|
|
1149
1149
|
const i = [];
|
|
1150
1150
|
for (const r of e) {
|
|
1151
1151
|
if (typeof r != "object" || r === null) continue;
|
|
1152
|
-
const s =
|
|
1152
|
+
const s = S.get(r);
|
|
1153
1153
|
if (s === void 0) continue;
|
|
1154
1154
|
const o = n.entityMap.getEntity(s);
|
|
1155
1155
|
o !== void 0 && o.satisfiesDef(t) && i.push(r);
|
|
1156
1156
|
}
|
|
1157
1157
|
return i;
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1160
|
-
const s = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype :
|
|
1159
|
+
function vn(e, t, n, i, r) {
|
|
1160
|
+
const s = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype : gt.prototype, u = n.typenameField, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = () => ({ __entityRef: t });
|
|
1161
1161
|
let _;
|
|
1162
|
-
f?.hasSubscribe && a && "__subscribe" in a && (_ =
|
|
1162
|
+
f?.hasSubscribe && a && "__subscribe" in a && (_ = Lt((E) => {
|
|
1163
1163
|
const y = (w) => {
|
|
1164
1164
|
w.__eventSource = t, r.applyMutationEvent(w);
|
|
1165
|
-
}, b = a.__subscribe.call(
|
|
1166
|
-
return E.value =
|
|
1165
|
+
}, b = a.__subscribe.call(m, y);
|
|
1166
|
+
return E.value = m, b;
|
|
1167
1167
|
}));
|
|
1168
|
-
let
|
|
1168
|
+
let m;
|
|
1169
1169
|
if (u && !(u in s))
|
|
1170
1170
|
throw new Error(`typenameField "${u}" must be declared in the entity shape`);
|
|
1171
|
-
const
|
|
1172
|
-
if (
|
|
1171
|
+
const O = Object.keys(s);
|
|
1172
|
+
if (O.includes("__typename") || O.push("__typename"), a)
|
|
1173
1173
|
for (const E of Object.keys(a))
|
|
1174
|
-
|
|
1175
|
-
let T, R =
|
|
1174
|
+
O.includes(E) || O.push(E);
|
|
1175
|
+
let T, R = O;
|
|
1176
1176
|
function U() {
|
|
1177
1177
|
const E = e._extraMethods;
|
|
1178
1178
|
if (E !== T) {
|
|
1179
|
-
if (T = E, R =
|
|
1179
|
+
if (T = E, R = O.slice(), E !== void 0)
|
|
1180
1180
|
for (const b of Object.keys(E))
|
|
1181
1181
|
R.includes(b) || R.push(b);
|
|
1182
1182
|
const y = e._extraGetters;
|
|
@@ -1199,40 +1199,40 @@ function mn(e, t, n, i, r) {
|
|
|
1199
1199
|
const D = e._extraGetters;
|
|
1200
1200
|
if (D !== void 0 && y in D)
|
|
1201
1201
|
return D[y]();
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1202
|
+
const x = e._extraMethods;
|
|
1203
|
+
if (x !== void 0 && y in x) {
|
|
1204
1204
|
let C = h.get(y);
|
|
1205
|
-
return C || (C =
|
|
1205
|
+
return C || (C = x[y].bind(m), h.set(y, C)), C;
|
|
1206
1206
|
}
|
|
1207
1207
|
if (a && y in a) {
|
|
1208
1208
|
let C = h.get(y);
|
|
1209
|
-
return C || (C =
|
|
1209
|
+
return C || (C = Se(m, a[y].bind(m)), h.set(y, C)), C;
|
|
1210
1210
|
}
|
|
1211
1211
|
}
|
|
1212
1212
|
const w = e.data[y];
|
|
1213
|
-
if (typeof w == "object" && w !== null &&
|
|
1214
|
-
return
|
|
1213
|
+
if (typeof w == "object" && w !== null && et.has(w))
|
|
1214
|
+
return A(w.getValue());
|
|
1215
1215
|
if (Array.isArray(w) && typeof y == "string") {
|
|
1216
1216
|
const D = s[y];
|
|
1217
|
-
if (D instanceof
|
|
1218
|
-
const
|
|
1219
|
-
if (
|
|
1220
|
-
const C =
|
|
1217
|
+
if (D instanceof v && (D.mask & d.ARRAY) !== 0) {
|
|
1218
|
+
const x = D.shape;
|
|
1219
|
+
if (x instanceof v && (x.mask & d.ENTITY) !== 0) {
|
|
1220
|
+
const C = x.typenameValue;
|
|
1221
1221
|
if (C !== void 0) {
|
|
1222
1222
|
const Ot = r.getEntityDefsForTypename(C);
|
|
1223
1223
|
if (Ot !== void 0 && Ot.length > 1) {
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
return
|
|
1227
|
-
const
|
|
1228
|
-
return g.set(y, { source: w, filtered:
|
|
1224
|
+
const nt = g.get(y);
|
|
1225
|
+
if (nt !== void 0 && nt.source === w)
|
|
1226
|
+
return A(nt.filtered);
|
|
1227
|
+
const Rt = gn(w, x, r);
|
|
1228
|
+
return g.set(y, { source: w, filtered: Rt }), A(Rt);
|
|
1229
1229
|
}
|
|
1230
1230
|
}
|
|
1231
1231
|
}
|
|
1232
1232
|
}
|
|
1233
|
-
return
|
|
1233
|
+
return A(w);
|
|
1234
1234
|
}
|
|
1235
|
-
return
|
|
1235
|
+
return A(w);
|
|
1236
1236
|
},
|
|
1237
1237
|
set() {
|
|
1238
1238
|
throw new Error("Entity properties are read-only");
|
|
@@ -1254,22 +1254,22 @@ function mn(e, t, n, i, r) {
|
|
|
1254
1254
|
if (y === "__typename")
|
|
1255
1255
|
return { enumerable: !0, configurable: !0, value: e.typename, writable: !1 };
|
|
1256
1256
|
if (y in s)
|
|
1257
|
-
return { enumerable: !0, configurable: !0, value: q.get(E, y,
|
|
1257
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1258
1258
|
if (typeof y == "string") {
|
|
1259
1259
|
const b = e._extraGetters;
|
|
1260
1260
|
if (b && y in b)
|
|
1261
|
-
return { enumerable: !0, configurable: !0, value: q.get(E, y,
|
|
1261
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1262
1262
|
const w = e._extraMethods;
|
|
1263
1263
|
if (w && y in w)
|
|
1264
|
-
return { enumerable: !0, configurable: !0, value: q.get(E, y,
|
|
1264
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1265
1265
|
if (a && y in a)
|
|
1266
|
-
return { enumerable: !1, configurable: !0, value: q.get(E, y,
|
|
1266
|
+
return { enumerable: !1, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
|
-
return
|
|
1270
|
+
return m = new Proxy({}, q), S.set(m, t), Ce(m, r), m;
|
|
1271
1271
|
}
|
|
1272
|
-
class
|
|
1272
|
+
class mn {
|
|
1273
1273
|
instances = /* @__PURE__ */ new Map();
|
|
1274
1274
|
persistEntity;
|
|
1275
1275
|
constructor(t) {
|
|
@@ -1307,13 +1307,13 @@ class vn {
|
|
|
1307
1307
|
this.persistEntity(t.key, t.data, n);
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
class
|
|
1310
|
+
class ue {
|
|
1311
1311
|
onlineSignal;
|
|
1312
1312
|
manualOverride = void 0;
|
|
1313
1313
|
eventListenersAttached = !1;
|
|
1314
1314
|
constructor(t) {
|
|
1315
1315
|
const n = t ?? this.detectOnlineStatus();
|
|
1316
|
-
this.onlineSignal =
|
|
1316
|
+
this.onlineSignal = Ut(n), this.canAttachListeners() && this.attachEventListeners();
|
|
1317
1317
|
}
|
|
1318
1318
|
/**
|
|
1319
1319
|
* Returns true if the network is currently online
|
|
@@ -1371,8 +1371,8 @@ class fe {
|
|
|
1371
1371
|
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
class
|
|
1375
|
-
static onlineSignal =
|
|
1374
|
+
class de {
|
|
1375
|
+
static onlineSignal = Ut(!0);
|
|
1376
1376
|
get isOnline() {
|
|
1377
1377
|
return !0;
|
|
1378
1378
|
}
|
|
@@ -1381,13 +1381,13 @@ class ue {
|
|
|
1381
1381
|
clearManualOverride() {
|
|
1382
1382
|
}
|
|
1383
1383
|
getOnlineSignal() {
|
|
1384
|
-
return
|
|
1384
|
+
return de.onlineSignal;
|
|
1385
1385
|
}
|
|
1386
1386
|
destroy() {
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
|
-
const _n = new
|
|
1390
|
-
function
|
|
1389
|
+
const _n = new ue(), Ln = qt(_n);
|
|
1390
|
+
function Ct(e, t = typeof window > "u") {
|
|
1391
1391
|
let n;
|
|
1392
1392
|
e === !1 ? n = 0 : e === void 0 || e === !0 ? n = t ? 0 : 3 : typeof e == "number" ? n = e : n = e.retries;
|
|
1393
1393
|
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (r) => 1e3 * Math.pow(2, r);
|
|
@@ -1403,94 +1403,94 @@ class Un {
|
|
|
1403
1403
|
params;
|
|
1404
1404
|
config;
|
|
1405
1405
|
constructor() {
|
|
1406
|
-
return
|
|
1406
|
+
return Gt(this);
|
|
1407
1407
|
}
|
|
1408
1408
|
}
|
|
1409
|
-
const
|
|
1409
|
+
const Mt = /* @__PURE__ */ new WeakMap();
|
|
1410
1410
|
class H {
|
|
1411
1411
|
constructor(t, n) {
|
|
1412
1412
|
this.captured = n, this.statics = t;
|
|
1413
1413
|
}
|
|
1414
1414
|
statics;
|
|
1415
1415
|
createExecutionContext(t, n) {
|
|
1416
|
-
return
|
|
1416
|
+
return ot(this.captured, t, n);
|
|
1417
1417
|
}
|
|
1418
1418
|
resolveOptions(t) {
|
|
1419
|
-
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config, r =
|
|
1419
|
+
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config, r = Ct(i?.retry);
|
|
1420
1420
|
return { config: i, retryConfig: r };
|
|
1421
1421
|
}
|
|
1422
1422
|
static for(t) {
|
|
1423
|
-
let n =
|
|
1423
|
+
let n = Mt.get(t);
|
|
1424
1424
|
if (n !== void 0)
|
|
1425
1425
|
return n;
|
|
1426
|
-
const i = new t(), r = $e(i), s = String(r.methods.getIdentityKey.call(r.fields)), o = r.fields.result, a = o instanceof
|
|
1426
|
+
const i = new t(), r = $e(i), s = String(r.methods.getIdentityKey.call(r.fields)), o = r.fields.result, a = o instanceof v ? o : sn.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = r.fields.fetchNext, u = t.adapter;
|
|
1427
1427
|
if (!u)
|
|
1428
1428
|
throw new Error(
|
|
1429
1429
|
`Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
|
|
1430
1430
|
);
|
|
1431
|
-
const h = typeof u.prototype.sendNext == "function", g = c ? a : new
|
|
1431
|
+
const h = typeof u.prototype.sendNext == "function", g = c ? a : new v(
|
|
1432
1432
|
d.ENTITY | d.OBJECT,
|
|
1433
1433
|
a.shape,
|
|
1434
1434
|
void 0,
|
|
1435
1435
|
void 0,
|
|
1436
1436
|
s,
|
|
1437
1437
|
// typenameValue — unique per query class
|
|
1438
|
-
|
|
1438
|
+
Kt
|
|
1439
1439
|
// idField — symbol, injected onto payload before parse
|
|
1440
1440
|
);
|
|
1441
1441
|
return n = new H(
|
|
1442
1442
|
{ id: s, shape: g, cache: f, rawFetchNext: l, hasSendNext: h, isEntityResult: c, adapterClass: u },
|
|
1443
1443
|
r
|
|
1444
|
-
),
|
|
1444
|
+
), Mt.set(t, n), n;
|
|
1445
1445
|
}
|
|
1446
1446
|
}
|
|
1447
1447
|
const qn = (e, t) => {
|
|
1448
1448
|
const n = H.for(e);
|
|
1449
|
-
return
|
|
1449
|
+
return St(n, t);
|
|
1450
1450
|
};
|
|
1451
1451
|
function Vn(e, ...t) {
|
|
1452
|
-
const n = H.for(e), i = Oe(
|
|
1452
|
+
const n = H.for(e), i = Oe(Fn);
|
|
1453
1453
|
if (i === void 0)
|
|
1454
1454
|
throw new Error("QueryClient not found");
|
|
1455
1455
|
const r = t[0];
|
|
1456
1456
|
return i.getQuery(n, r);
|
|
1457
1457
|
}
|
|
1458
|
-
function
|
|
1458
|
+
function ut(e) {
|
|
1459
1459
|
if (e.reason !== void 0) return e.reason;
|
|
1460
1460
|
if (typeof DOMException < "u")
|
|
1461
1461
|
return new DOMException("The operation was aborted", "AbortError");
|
|
1462
1462
|
const t = new Error("The operation was aborted");
|
|
1463
1463
|
return t.name = "AbortError", t;
|
|
1464
1464
|
}
|
|
1465
|
-
function
|
|
1465
|
+
function le(e, t) {
|
|
1466
1466
|
return new Promise((n, i) => {
|
|
1467
1467
|
if (t?.aborted) {
|
|
1468
|
-
i(
|
|
1468
|
+
i(ut(t));
|
|
1469
1469
|
return;
|
|
1470
1470
|
}
|
|
1471
1471
|
const r = setTimeout(n, e);
|
|
1472
1472
|
t?.addEventListener(
|
|
1473
1473
|
"abort",
|
|
1474
1474
|
() => {
|
|
1475
|
-
clearTimeout(r), i(
|
|
1475
|
+
clearTimeout(r), i(ut(t));
|
|
1476
1476
|
},
|
|
1477
1477
|
{ once: !0 }
|
|
1478
1478
|
);
|
|
1479
1479
|
});
|
|
1480
1480
|
}
|
|
1481
|
-
async function
|
|
1481
|
+
async function dt(e, t, n) {
|
|
1482
1482
|
if (t.retries < 0)
|
|
1483
1483
|
throw new Error("retries must be non-negative");
|
|
1484
1484
|
const i = Math.max(0, t.retries);
|
|
1485
1485
|
let r;
|
|
1486
1486
|
for (let s = 0; s <= i; s++) {
|
|
1487
1487
|
if (n?.aborted)
|
|
1488
|
-
throw
|
|
1488
|
+
throw ut(n);
|
|
1489
1489
|
try {
|
|
1490
1490
|
return await e();
|
|
1491
1491
|
} catch (o) {
|
|
1492
1492
|
if (r = o, s >= i) throw o;
|
|
1493
|
-
await
|
|
1493
|
+
await le(t.retryDelay(s), n);
|
|
1494
1494
|
}
|
|
1495
1495
|
}
|
|
1496
1496
|
throw r;
|
|
@@ -1506,14 +1506,24 @@ class wn {
|
|
|
1506
1506
|
updatedAt = void 0;
|
|
1507
1507
|
params = void 0;
|
|
1508
1508
|
unsubscribe = void 0;
|
|
1509
|
+
lastSubscribeFn = void 0;
|
|
1509
1510
|
_relayState = void 0;
|
|
1510
1511
|
_isActive = !1;
|
|
1511
1512
|
wasPaused = !1;
|
|
1512
1513
|
currentParams = void 0;
|
|
1513
1514
|
debounceTimer = void 0;
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1515
|
+
// Invalidates on any signal consumed by getConfig() (such as
|
|
1516
|
+
// responseNotifier, fired by the adapter after each fetch). Param
|
|
1517
|
+
// changes are handled separately: getOrCreateExecutionContext
|
|
1518
|
+
// replaces this wholesale to force recomputation against the new ctx.
|
|
1519
|
+
_resolvedOptions = st(() => this.def.resolveOptions(this._executionCtx));
|
|
1520
|
+
get config() {
|
|
1521
|
+
if (this._executionCtx !== void 0)
|
|
1522
|
+
return this._resolvedOptions.value.config;
|
|
1523
|
+
}
|
|
1524
|
+
get retryConfig() {
|
|
1525
|
+
return this._executionCtx === void 0 ? Ct(void 0) : this._resolvedOptions.value.retryConfig;
|
|
1526
|
+
}
|
|
1517
1527
|
/** Cancels in-flight fetches and retry waits. */
|
|
1518
1528
|
_abortController = void 0;
|
|
1519
1529
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
@@ -1536,14 +1546,14 @@ class wn {
|
|
|
1536
1546
|
}
|
|
1537
1547
|
constructor(t, n, i, r) {
|
|
1538
1548
|
this.def = t, this.queryClient = n, this.queryKey = i, this.params = r, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1539
|
-
const s =
|
|
1540
|
-
this._queryId = s !== void 0 ? N(s) : 0, this.relay =
|
|
1549
|
+
const s = $t(r);
|
|
1550
|
+
this._queryId = s !== void 0 ? N(s) : 0, this.relay = Lt(
|
|
1541
1551
|
(o) => {
|
|
1542
1552
|
this._relayState = o;
|
|
1543
1553
|
const a = () => {
|
|
1544
|
-
this._isActive = !1, clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1545
|
-
const f = this.config?.gcTime ??
|
|
1546
|
-
this.queryClient.gcManager.schedule(this.queryKey, f,
|
|
1554
|
+
this._isActive = !1, clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0, this.lastSubscribeFn = void 0;
|
|
1555
|
+
const f = this.config?.gcTime ?? Vt;
|
|
1556
|
+
this.queryClient.gcManager.schedule(this.queryKey, f, tt.Query);
|
|
1547
1557
|
}, c = (f = !1) => {
|
|
1548
1558
|
const { wasPaused: l, isPaused: u, initialized: h } = this;
|
|
1549
1559
|
if (this.wasPaused = u, u && !l && h) {
|
|
@@ -1551,8 +1561,8 @@ class wn {
|
|
|
1551
1561
|
return;
|
|
1552
1562
|
}
|
|
1553
1563
|
this._isActive = !0;
|
|
1554
|
-
const g =
|
|
1555
|
-
_ && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.
|
|
1564
|
+
const g = $t(this.params), p = St(this.def, g), _ = p !== this.storageKey;
|
|
1565
|
+
_ && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.reconcileSubscription(), this.relayState.isPending && this._abortController === void 0 ? this.runQueryImmediately() : (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : _ && (this.lastSubscribeFn = void 0, this.reconcileSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1556
1566
|
};
|
|
1557
1567
|
return c(!0), {
|
|
1558
1568
|
update: c,
|
|
@@ -1600,18 +1610,17 @@ class wn {
|
|
|
1600
1610
|
}
|
|
1601
1611
|
if (!this.isPaused)
|
|
1602
1612
|
try {
|
|
1603
|
-
if (i !== void 0 && this.
|
|
1604
|
-
if (await
|
|
1613
|
+
if (i !== void 0 && this.reconcileSubscription(), i === void 0 || this.isStale) {
|
|
1614
|
+
if (await le(0), this.isPaused) return;
|
|
1605
1615
|
this.runQueryImmediately();
|
|
1606
1616
|
}
|
|
1607
1617
|
} catch (r) {
|
|
1608
1618
|
n.setError(r);
|
|
1609
1619
|
}
|
|
1610
1620
|
}
|
|
1611
|
-
|
|
1612
|
-
this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1621
|
+
reconcileSubscription() {
|
|
1613
1622
|
const t = this.config?.subscribe;
|
|
1614
|
-
if (!t) return;
|
|
1623
|
+
if (t === this.lastSubscribeFn || (this.unsubscribe?.(), this.unsubscribe = void 0, this.lastSubscribeFn = t, !t)) return;
|
|
1615
1624
|
const n = this._executionCtx;
|
|
1616
1625
|
this.unsubscribe = t.call(n, (i) => {
|
|
1617
1626
|
i.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(i);
|
|
@@ -1621,23 +1630,19 @@ class wn {
|
|
|
1621
1630
|
return (this._executionCtx === void 0 || this._executionCtxKey !== this.storageKey) && (this._executionCtxKey = this.storageKey, this._executionCtx = this.def.createExecutionContext(
|
|
1622
1631
|
this.currentParams ?? {},
|
|
1623
1632
|
this.queryClient.getContext()
|
|
1624
|
-
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext
|
|
1625
|
-
}
|
|
1626
|
-
resolveAndApplyOptions() {
|
|
1627
|
-
const t = this.def.resolveOptions(this._executionCtx);
|
|
1628
|
-
this.config = t.config, this.retryConfig = t.retryConfig;
|
|
1633
|
+
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext, this._resolvedOptions = st(() => this.def.resolveOptions(this._executionCtx))), this._executionCtx;
|
|
1629
1634
|
}
|
|
1630
1635
|
async runQuery() {
|
|
1631
1636
|
const t = this.def;
|
|
1632
1637
|
if (this.isPaused)
|
|
1633
1638
|
throw new Error("Query is paused due to network status");
|
|
1634
1639
|
const n = this.getOrCreateExecutionContext(), i = this.queryClient.getAdapter(t.statics.adapterClass), r = this._abortController?.signal ?? new AbortController().signal;
|
|
1635
|
-
return
|
|
1640
|
+
return dt(
|
|
1636
1641
|
async () => {
|
|
1637
1642
|
const s = await i.send(n, r);
|
|
1638
1643
|
this.updatedAt = Date.now();
|
|
1639
1644
|
const o = this.applyData(s, !0);
|
|
1640
|
-
return this.saveQueryMetadata(), this.
|
|
1645
|
+
return this.saveQueryMetadata(), this.reconcileSubscription(), o;
|
|
1641
1646
|
},
|
|
1642
1647
|
this.retryConfig,
|
|
1643
1648
|
r
|
|
@@ -1688,7 +1693,7 @@ class wn {
|
|
|
1688
1693
|
const n = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
|
|
1689
1694
|
i.resultData = this.rootEntity.data;
|
|
1690
1695
|
const r = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1691
|
-
return
|
|
1696
|
+
return dt(
|
|
1692
1697
|
async () => {
|
|
1693
1698
|
const s = await r.sendNext(i, n);
|
|
1694
1699
|
this.updatedAt = Date.now();
|
|
@@ -1732,7 +1737,7 @@ class En {
|
|
|
1732
1737
|
this.def = t, this.queryClient = n, this.task = this.createTask();
|
|
1733
1738
|
}
|
|
1734
1739
|
createTask() {
|
|
1735
|
-
return
|
|
1740
|
+
return Re(
|
|
1736
1741
|
async (t) => {
|
|
1737
1742
|
if (this._inFlight)
|
|
1738
1743
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
@@ -1749,11 +1754,11 @@ class En {
|
|
|
1749
1754
|
}
|
|
1750
1755
|
validateResponse(t) {
|
|
1751
1756
|
const n = this.def.responseShape;
|
|
1752
|
-
if (!(n instanceof
|
|
1757
|
+
if (!(n instanceof v))
|
|
1753
1758
|
return t;
|
|
1754
1759
|
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1755
|
-
}), r = new
|
|
1756
|
-
return r.reset(void 0, void 0, i),
|
|
1760
|
+
}), r = new ft();
|
|
1761
|
+
return r.reset(void 0, void 0, i), oe(t, n, r);
|
|
1757
1762
|
}
|
|
1758
1763
|
// ======================================================
|
|
1759
1764
|
// Effects processing
|
|
@@ -1761,7 +1766,7 @@ class En {
|
|
|
1761
1766
|
processEffects(t, n) {
|
|
1762
1767
|
let i;
|
|
1763
1768
|
if (this.def.hasGetEffects) {
|
|
1764
|
-
const s =
|
|
1769
|
+
const s = ot(
|
|
1765
1770
|
this.def.captured,
|
|
1766
1771
|
t ?? {},
|
|
1767
1772
|
this.queryClient.getContext()
|
|
@@ -1773,19 +1778,19 @@ class En {
|
|
|
1773
1778
|
}
|
|
1774
1779
|
if (i === void 0) return;
|
|
1775
1780
|
const r = this.queryClient;
|
|
1776
|
-
|
|
1781
|
+
it(i.creates, "create", r), it(i.updates, "update", r), it(i.deletes, "delete", r), i.invalidates && r.invalidateQueries(i.invalidates);
|
|
1777
1782
|
}
|
|
1778
1783
|
// ======================================================
|
|
1779
1784
|
// Retry logic
|
|
1780
1785
|
// ======================================================
|
|
1781
1786
|
executeWithRetry(t) {
|
|
1782
|
-
const n =
|
|
1787
|
+
const n = Ct(this.def.config?.retry, !0), i = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1783
1788
|
if (!i.sendMutation)
|
|
1784
1789
|
throw new Error(
|
|
1785
1790
|
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1786
1791
|
);
|
|
1787
|
-
return
|
|
1788
|
-
const r = new AbortController(), s =
|
|
1792
|
+
return dt(async () => {
|
|
1793
|
+
const r = new AbortController(), s = ot(
|
|
1789
1794
|
this.def.captured,
|
|
1790
1795
|
t ?? {},
|
|
1791
1796
|
this.queryClient.getContext()
|
|
@@ -1797,21 +1802,21 @@ class En {
|
|
|
1797
1802
|
function bn(e) {
|
|
1798
1803
|
return typeof e == "string" ? e : $(e).typenameValue;
|
|
1799
1804
|
}
|
|
1800
|
-
function
|
|
1805
|
+
function it(e, t, n) {
|
|
1801
1806
|
if (e)
|
|
1802
1807
|
for (const [i, r] of e) {
|
|
1803
1808
|
const s = bn(i);
|
|
1804
1809
|
s !== void 0 && n.applyMutationEvent({ type: t, typename: s, data: r });
|
|
1805
1810
|
}
|
|
1806
1811
|
}
|
|
1807
|
-
const
|
|
1808
|
-
function
|
|
1812
|
+
const he = "__eventSource";
|
|
1813
|
+
function ye(e) {
|
|
1809
1814
|
return { field: e, segments: e.indexOf(".") !== -1 ? e.split(".") : void 0 };
|
|
1810
1815
|
}
|
|
1811
1816
|
function Cn(e) {
|
|
1812
|
-
return e.map(
|
|
1817
|
+
return e.map(ye);
|
|
1813
1818
|
}
|
|
1814
|
-
function
|
|
1819
|
+
function Sn(e, t) {
|
|
1815
1820
|
if (t.segments === void 0) return e[t.field];
|
|
1816
1821
|
let n = e;
|
|
1817
1822
|
for (const i of t.segments) {
|
|
@@ -1820,16 +1825,16 @@ function On(e, t) {
|
|
|
1820
1825
|
}
|
|
1821
1826
|
return n;
|
|
1822
1827
|
}
|
|
1823
|
-
function
|
|
1828
|
+
function pe(e, t) {
|
|
1824
1829
|
const n = [];
|
|
1825
1830
|
for (let i = 0; i < t.length; i++) {
|
|
1826
|
-
const r = t[i], s =
|
|
1831
|
+
const r = t[i], s = Sn(e, r);
|
|
1827
1832
|
if (s === void 0) return;
|
|
1828
1833
|
n.push(r.field, s);
|
|
1829
1834
|
}
|
|
1830
1835
|
return N(n);
|
|
1831
1836
|
}
|
|
1832
|
-
function
|
|
1837
|
+
function On(e, t) {
|
|
1833
1838
|
if (e === void 0) return;
|
|
1834
1839
|
const n = /* @__PURE__ */ new Map();
|
|
1835
1840
|
for (const [i, r] of e) {
|
|
@@ -1837,9 +1842,9 @@ function Sn(e, t) {
|
|
|
1837
1842
|
let a = !0;
|
|
1838
1843
|
for (const [c, f] of s) {
|
|
1839
1844
|
let l;
|
|
1840
|
-
if (
|
|
1841
|
-
const u =
|
|
1842
|
-
l =
|
|
1845
|
+
if (Qt(f)) {
|
|
1846
|
+
const u = Yt(f);
|
|
1847
|
+
l = pt(u, t);
|
|
1843
1848
|
} else
|
|
1844
1849
|
l = f;
|
|
1845
1850
|
if (l === void 0) {
|
|
@@ -1852,7 +1857,7 @@ function Sn(e, t) {
|
|
|
1852
1857
|
}
|
|
1853
1858
|
return n.size > 0 ? n : void 0;
|
|
1854
1859
|
}
|
|
1855
|
-
function
|
|
1860
|
+
function Tt(e, t) {
|
|
1856
1861
|
const n = e.get(t);
|
|
1857
1862
|
if (n !== void 0)
|
|
1858
1863
|
return n.map(([i]) => i).sort();
|
|
@@ -1862,7 +1867,7 @@ class Rn {
|
|
|
1862
1867
|
fieldPaths;
|
|
1863
1868
|
_bindings = /* @__PURE__ */ new Map();
|
|
1864
1869
|
constructor(t) {
|
|
1865
|
-
this.fields = t, this.fieldPaths = t.map(
|
|
1870
|
+
this.fields = t, this.fieldPaths = t.map(ye);
|
|
1866
1871
|
}
|
|
1867
1872
|
register(t, n) {
|
|
1868
1873
|
let i = this._bindings.get(t);
|
|
@@ -1879,13 +1884,13 @@ class Rn {
|
|
|
1879
1884
|
return this._bindings.size === 0;
|
|
1880
1885
|
}
|
|
1881
1886
|
}
|
|
1882
|
-
function
|
|
1887
|
+
function Pt(e) {
|
|
1883
1888
|
return N(e);
|
|
1884
1889
|
}
|
|
1885
|
-
class
|
|
1890
|
+
class xn {
|
|
1886
1891
|
_groups = /* @__PURE__ */ new Map();
|
|
1887
1892
|
getOrCreateGroup(t) {
|
|
1888
|
-
const n =
|
|
1893
|
+
const n = Pt(t);
|
|
1889
1894
|
let i = this._groups.get(n);
|
|
1890
1895
|
return i === void 0 && (i = new Rn(t), this._groups.set(n, i)), i;
|
|
1891
1896
|
}
|
|
@@ -1893,24 +1898,24 @@ class An {
|
|
|
1893
1898
|
this.getOrCreateGroup(n).register(t, i);
|
|
1894
1899
|
}
|
|
1895
1900
|
unregister(t, n, i) {
|
|
1896
|
-
const r =
|
|
1901
|
+
const r = Pt(n), s = this._groups.get(r);
|
|
1897
1902
|
s !== void 0 && (s.unregister(t, i), s.isEmpty && this._groups.delete(r));
|
|
1898
1903
|
}
|
|
1899
1904
|
registerBinding(t, n) {
|
|
1900
1905
|
const i = t._constraintHashes.get(n);
|
|
1901
1906
|
if (i === void 0) return;
|
|
1902
|
-
const r =
|
|
1907
|
+
const r = Tt(t._constraintFieldRefs, n);
|
|
1903
1908
|
r !== void 0 && this.register(i, r, t);
|
|
1904
1909
|
}
|
|
1905
1910
|
unregisterBinding(t, n) {
|
|
1906
1911
|
const i = t._constraintHashes.get(n);
|
|
1907
1912
|
if (i === void 0) return;
|
|
1908
|
-
const r =
|
|
1913
|
+
const r = Tt(t._constraintFieldRefs, n);
|
|
1909
1914
|
r !== void 0 && this.unregister(i, r, t);
|
|
1910
1915
|
}
|
|
1911
1916
|
routeEvent(t, n, i, r, s, o) {
|
|
1912
1917
|
for (const a of this._groups.values()) {
|
|
1913
|
-
const c =
|
|
1918
|
+
const c = pe(n, a.fieldPaths);
|
|
1914
1919
|
if (c === void 0) continue;
|
|
1915
1920
|
const f = a.getMatching(c);
|
|
1916
1921
|
if (f !== void 0)
|
|
@@ -1919,7 +1924,7 @@ class An {
|
|
|
1919
1924
|
}
|
|
1920
1925
|
}
|
|
1921
1926
|
}
|
|
1922
|
-
function
|
|
1927
|
+
function jt(e) {
|
|
1923
1928
|
const t = /* @__PURE__ */ new Set();
|
|
1924
1929
|
for (const n of e)
|
|
1925
1930
|
if (typeof n == "object" && n !== null) {
|
|
@@ -1928,7 +1933,7 @@ function Pt(e) {
|
|
|
1928
1933
|
}
|
|
1929
1934
|
return t;
|
|
1930
1935
|
}
|
|
1931
|
-
class
|
|
1936
|
+
class ge {
|
|
1932
1937
|
_queryClient;
|
|
1933
1938
|
_parent;
|
|
1934
1939
|
_constraintHashes;
|
|
@@ -1939,7 +1944,7 @@ class pe {
|
|
|
1939
1944
|
this._queryClient = i, this._parent = r, this._constraintHashes = s, this._constraintFieldRefs = n, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1940
1945
|
for (const a of t)
|
|
1941
1946
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1942
|
-
|
|
1947
|
+
et.add(this);
|
|
1943
1948
|
}
|
|
1944
1949
|
getValue() {
|
|
1945
1950
|
return this.instance.getValue();
|
|
@@ -1978,7 +1983,7 @@ class pe {
|
|
|
1978
1983
|
n !== -1 && t.splice(n, 1);
|
|
1979
1984
|
}
|
|
1980
1985
|
}
|
|
1981
|
-
class
|
|
1986
|
+
class An {
|
|
1982
1987
|
_notifier;
|
|
1983
1988
|
_items;
|
|
1984
1989
|
_keys;
|
|
@@ -1986,9 +1991,9 @@ class xn {
|
|
|
1986
1991
|
_queryClient;
|
|
1987
1992
|
_parent;
|
|
1988
1993
|
constructor(t, n, i, r, s, o) {
|
|
1989
|
-
this._notifier =
|
|
1994
|
+
this._notifier = Z(), this._items = i, this._keys = jt(i), this._queryClient = t, this._parent = n;
|
|
1990
1995
|
const a = r !== void 0 && s !== void 0, c = o !== void 0;
|
|
1991
|
-
(a || c) && (this._outputSignal =
|
|
1996
|
+
(a || c) && (this._outputSignal = st(() => {
|
|
1992
1997
|
this._notifier.consume();
|
|
1993
1998
|
let f = this._items;
|
|
1994
1999
|
if (a) {
|
|
@@ -2008,7 +2013,7 @@ class xn {
|
|
|
2008
2013
|
l.push(u);
|
|
2009
2014
|
continue;
|
|
2010
2015
|
}
|
|
2011
|
-
g.consume(),
|
|
2016
|
+
g.consume(), pe(g.data, r) === s && l.push(u);
|
|
2012
2017
|
}
|
|
2013
2018
|
f = l;
|
|
2014
2019
|
}
|
|
@@ -2053,7 +2058,7 @@ class xn {
|
|
|
2053
2058
|
}
|
|
2054
2059
|
reset(t) {
|
|
2055
2060
|
const n = this._items, i = Array.isArray(t) ? t : [];
|
|
2056
|
-
this._items = i, this._keys =
|
|
2061
|
+
this._items = i, this._keys = jt(i);
|
|
2057
2062
|
for (const r of i)
|
|
2058
2063
|
if (typeof r == "object" && r !== null) {
|
|
2059
2064
|
const s = P(r);
|
|
@@ -2100,7 +2105,7 @@ class Nn {
|
|
|
2100
2105
|
_onUpdate;
|
|
2101
2106
|
_onDelete;
|
|
2102
2107
|
constructor(t, n, i, r, s, o) {
|
|
2103
|
-
this._notifier =
|
|
2108
|
+
this._notifier = Z(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = n, this._onCreate = r, this._onUpdate = s, this._onDelete = o;
|
|
2104
2109
|
}
|
|
2105
2110
|
onEvent(t, n, i, r) {
|
|
2106
2111
|
switch (r) {
|
|
@@ -2130,18 +2135,18 @@ class Nn {
|
|
|
2130
2135
|
append(t) {
|
|
2131
2136
|
}
|
|
2132
2137
|
}
|
|
2133
|
-
function
|
|
2138
|
+
function ve(e, t, n, i, r) {
|
|
2134
2139
|
let s = e.constraintFieldRefs;
|
|
2135
2140
|
if (s === void 0) {
|
|
2136
2141
|
s = /* @__PURE__ */ new Map();
|
|
2137
2142
|
for (const f of e.entityDefs) {
|
|
2138
2143
|
const l = f.typenameValue;
|
|
2139
|
-
l !== void 0 && s.set(l, [[
|
|
2144
|
+
l !== void 0 && s.set(l, [[he, n.key]]);
|
|
2140
2145
|
}
|
|
2141
2146
|
}
|
|
2142
|
-
const o =
|
|
2147
|
+
const o = On(s, i) ?? /* @__PURE__ */ new Map();
|
|
2143
2148
|
let a;
|
|
2144
|
-
if (e.type ===
|
|
2149
|
+
if (e.type === ht.Array) {
|
|
2145
2150
|
let f, l;
|
|
2146
2151
|
if (e.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2147
2152
|
for (const [u] of e.constraintFieldRefs) {
|
|
@@ -2153,7 +2158,7 @@ function ge(e, t, n, i, r) {
|
|
|
2153
2158
|
break;
|
|
2154
2159
|
}
|
|
2155
2160
|
}
|
|
2156
|
-
a = new
|
|
2161
|
+
a = new An(
|
|
2157
2162
|
r,
|
|
2158
2163
|
n,
|
|
2159
2164
|
Array.isArray(t) ? t : [],
|
|
@@ -2170,7 +2175,7 @@ function ge(e, t, n, i, r) {
|
|
|
2170
2175
|
e.onUpdate,
|
|
2171
2176
|
e.onDelete
|
|
2172
2177
|
);
|
|
2173
|
-
const c = new
|
|
2178
|
+
const c = new ge(
|
|
2174
2179
|
e.entityDefs,
|
|
2175
2180
|
s,
|
|
2176
2181
|
r,
|
|
@@ -2180,8 +2185,8 @@ function ge(e, t, n, i, r) {
|
|
|
2180
2185
|
);
|
|
2181
2186
|
return n.liveCollections.push(c), r.registerLiveCollection(c), c;
|
|
2182
2187
|
}
|
|
2183
|
-
const me = Object.entries,
|
|
2184
|
-
function
|
|
2188
|
+
const me = Object.entries, _e = Object.prototype;
|
|
2189
|
+
function rt(e, t, n, i = !1) {
|
|
2185
2190
|
const r = e.queryClient;
|
|
2186
2191
|
r.currentParseId++;
|
|
2187
2192
|
const s = e.seen, o = /* @__PURE__ */ new Map();
|
|
@@ -2195,25 +2200,25 @@ function G(e, t, n, i, r, s) {
|
|
|
2195
2200
|
if (Array.isArray(e)) {
|
|
2196
2201
|
for (let a = 0; a < e.length; a++) {
|
|
2197
2202
|
const c = e[a];
|
|
2198
|
-
typeof c == "object" && c !== null && !(c instanceof Y) && !
|
|
2203
|
+
typeof c == "object" && c !== null && !(c instanceof Y) && !S.has(c) && (e[a] = G(c, t, n, i, r, s));
|
|
2199
2204
|
}
|
|
2200
2205
|
return e;
|
|
2201
2206
|
}
|
|
2202
|
-
if (Object.getPrototypeOf(e) ===
|
|
2207
|
+
if (Object.getPrototypeOf(e) === _e && !S.has(e)) {
|
|
2203
2208
|
const a = e;
|
|
2204
2209
|
for (const c of Object.keys(a)) {
|
|
2205
2210
|
const f = a[c];
|
|
2206
|
-
typeof f == "object" && f !== null && !(f instanceof Y) && !
|
|
2211
|
+
typeof f == "object" && f !== null && !(f instanceof Y) && !S.has(f) && (a[c] = G(f, t, n, i, r, s));
|
|
2207
2212
|
}
|
|
2208
2213
|
}
|
|
2209
2214
|
return e;
|
|
2210
2215
|
}
|
|
2211
|
-
function
|
|
2212
|
-
return typeof e == "object" && e !== null && !(e instanceof Y) && !
|
|
2216
|
+
function we(e) {
|
|
2217
|
+
return typeof e == "object" && e !== null && !(e instanceof Y) && !S.has(e);
|
|
2213
2218
|
}
|
|
2214
2219
|
function Dn(e, t, n, i, r, s) {
|
|
2215
2220
|
const { key: o, data: a, shape: c, rawKeys: f } = e, l = c.shape, u = n.prepareEntity(o, a, c), h = u.data, g = h !== a, p = g && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2216
|
-
if (g ? (
|
|
2221
|
+
if (g ? (Ee(
|
|
2217
2222
|
l,
|
|
2218
2223
|
a,
|
|
2219
2224
|
h,
|
|
@@ -2225,13 +2230,13 @@ function Dn(e, t, n, i, r, s) {
|
|
|
2225
2230
|
i,
|
|
2226
2231
|
p,
|
|
2227
2232
|
s
|
|
2228
|
-
), u.notify()) :
|
|
2229
|
-
for (const
|
|
2230
|
-
const
|
|
2231
|
-
if (Array.isArray(
|
|
2232
|
-
for (const T of
|
|
2233
|
+
), u.notify()) : be(l, a, u, a, t, n, i, p, s), s && u.liveCollections.length > 0)
|
|
2234
|
+
for (const m of u.liveCollections) {
|
|
2235
|
+
const O = m.instance.getRawValue();
|
|
2236
|
+
if (Array.isArray(O))
|
|
2237
|
+
for (const T of O) {
|
|
2233
2238
|
if (typeof T != "object" || T === null) continue;
|
|
2234
|
-
const R =
|
|
2239
|
+
const R = S.get(T);
|
|
2235
2240
|
if (R === void 0) continue;
|
|
2236
2241
|
const U = n.entityMap.getEntity(R);
|
|
2237
2242
|
U !== void 0 && p.set(U, (p.get(U) ?? 0) + 1);
|
|
@@ -2241,12 +2246,12 @@ function Dn(e, t, n, i, r, s) {
|
|
|
2241
2246
|
const _ = u.getProxy(c);
|
|
2242
2247
|
return r.set(u, (r.get(u) ?? 0) + 1), _;
|
|
2243
2248
|
}
|
|
2244
|
-
function
|
|
2249
|
+
function Ee(e, t, n, i, r, s, o, a, c, f, l) {
|
|
2245
2250
|
for (const [u, h] of me(e))
|
|
2246
2251
|
if (!(i !== void 0 && !i.has(u)))
|
|
2247
|
-
if (
|
|
2252
|
+
if (we(t[u]) && (t[u] = G(t[u], o, a, c, f, l)), h instanceof v && h._liveConfig !== void 0) {
|
|
2248
2253
|
const g = n[u];
|
|
2249
|
-
g instanceof
|
|
2254
|
+
g instanceof ge ? l ? g.append(t[u]) : g.reset(t[u]) : n[u] = ve(
|
|
2250
2255
|
h._liveConfig,
|
|
2251
2256
|
t[u],
|
|
2252
2257
|
r,
|
|
@@ -2255,10 +2260,10 @@ function we(e, t, n, i, r, s, o, a, c, f, l) {
|
|
|
2255
2260
|
);
|
|
2256
2261
|
} else {
|
|
2257
2262
|
const g = t[u], p = n[u];
|
|
2258
|
-
if (
|
|
2259
|
-
const _ = h instanceof
|
|
2263
|
+
if (lt(g) && lt(p)) {
|
|
2264
|
+
const _ = h instanceof v && h.shape !== void 0 ? h.shape : void 0;
|
|
2260
2265
|
if (_ !== void 0)
|
|
2261
|
-
|
|
2266
|
+
Ee(
|
|
2262
2267
|
_,
|
|
2263
2268
|
g,
|
|
2264
2269
|
p,
|
|
@@ -2272,18 +2277,18 @@ function we(e, t, n, i, r, s, o, a, c, f, l) {
|
|
|
2272
2277
|
l
|
|
2273
2278
|
);
|
|
2274
2279
|
else
|
|
2275
|
-
for (const
|
|
2276
|
-
p[
|
|
2280
|
+
for (const m of Object.keys(g))
|
|
2281
|
+
p[m] = g[m];
|
|
2277
2282
|
n[u] = p;
|
|
2278
2283
|
} else
|
|
2279
2284
|
n[u] = g;
|
|
2280
2285
|
}
|
|
2281
2286
|
}
|
|
2282
|
-
function
|
|
2287
|
+
function be(e, t, n, i, r, s, o, a, c) {
|
|
2283
2288
|
for (const [f, l] of me(e))
|
|
2284
2289
|
if (f in t)
|
|
2285
|
-
if (
|
|
2286
|
-
t[f] =
|
|
2290
|
+
if (we(t[f]) && (t[f] = G(t[f], r, s, o, a, c)), l instanceof v && l._liveConfig !== void 0)
|
|
2291
|
+
t[f] = ve(
|
|
2287
2292
|
l._liveConfig,
|
|
2288
2293
|
t[f],
|
|
2289
2294
|
n,
|
|
@@ -2292,23 +2297,23 @@ function Ee(e, t, n, i, r, s, o, a, c) {
|
|
|
2292
2297
|
);
|
|
2293
2298
|
else {
|
|
2294
2299
|
const u = t[f];
|
|
2295
|
-
if (
|
|
2296
|
-
const h = l instanceof
|
|
2297
|
-
h !== void 0 &&
|
|
2300
|
+
if (lt(u)) {
|
|
2301
|
+
const h = l instanceof v && l.shape !== void 0 ? l.shape : void 0;
|
|
2302
|
+
h !== void 0 && be(h, u, n, i, r, s, o, a, c);
|
|
2298
2303
|
}
|
|
2299
2304
|
}
|
|
2300
2305
|
}
|
|
2301
|
-
function
|
|
2302
|
-
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) ===
|
|
2306
|
+
function lt(e) {
|
|
2307
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) === _e && !S.has(e);
|
|
2303
2308
|
}
|
|
2304
2309
|
function Kn(e) {
|
|
2305
2310
|
if (e !== void 0)
|
|
2306
2311
|
return typeof e == "string" ? e : typeof e == "function" ? e() : e.value;
|
|
2307
2312
|
}
|
|
2308
2313
|
function In(e) {
|
|
2309
|
-
return
|
|
2314
|
+
return xe(e);
|
|
2310
2315
|
}
|
|
2311
|
-
function
|
|
2316
|
+
function $t(e) {
|
|
2312
2317
|
if (e === void 0)
|
|
2313
2318
|
return;
|
|
2314
2319
|
const t = {};
|
|
@@ -2316,7 +2321,7 @@ function jt(e) {
|
|
|
2316
2321
|
In(i) ? t[n] = i.value : t[n] = i;
|
|
2317
2322
|
return t;
|
|
2318
2323
|
}
|
|
2319
|
-
const
|
|
2324
|
+
const St = (e, t) => N([e.statics.id, t]);
|
|
2320
2325
|
class Bn {
|
|
2321
2326
|
entityMap;
|
|
2322
2327
|
queryInstances = /* @__PURE__ */ new Map();
|
|
@@ -2334,7 +2339,7 @@ class Bn {
|
|
|
2334
2339
|
networkUnsubscribe;
|
|
2335
2340
|
constructor(t = {}) {
|
|
2336
2341
|
const {
|
|
2337
|
-
store: n = new Ie(new
|
|
2342
|
+
store: n = new Ie(new Fe()),
|
|
2338
2343
|
log: i,
|
|
2339
2344
|
evictionMultiplier: r,
|
|
2340
2345
|
adapters: s,
|
|
@@ -2342,10 +2347,10 @@ class Bn {
|
|
|
2342
2347
|
gcManager: a,
|
|
2343
2348
|
...c
|
|
2344
2349
|
} = t;
|
|
2345
|
-
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: r }, this.gcManager = t.gcManager ?? (this.isServer ? new Te() : new Me(this.handleEviction, r)), this.networkManager = t.networkManager ?? new
|
|
2350
|
+
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: r }, this.gcManager = t.gcManager ?? (this.isServer ? new Te() : new Me(this.handleEviction, r)), this.networkManager = t.networkManager ?? new ue(), this.entityMap = new mn((u, h, g) => this.store.saveEntity(u, h, g));
|
|
2346
2351
|
for (const u of t.adapters ?? [])
|
|
2347
2352
|
this.adapters.set(u.constructor, u), u.register(this);
|
|
2348
|
-
const f = this.networkManager.getOnlineSignal(), l =
|
|
2353
|
+
const f = this.networkManager.getOnlineSignal(), l = Ae(() => f.value);
|
|
2349
2354
|
this.networkUnsubscribe = l.addListener(
|
|
2350
2355
|
() => {
|
|
2351
2356
|
const u = f.value;
|
|
@@ -2421,7 +2426,7 @@ class Bn {
|
|
|
2421
2426
|
if (n !== void 0) return n;
|
|
2422
2427
|
const i = this.typenameRegistry.get(t);
|
|
2423
2428
|
if (i !== void 0)
|
|
2424
|
-
return n =
|
|
2429
|
+
return n = v.merge(i), this.mergedDefCache.set(t, n), n;
|
|
2425
2430
|
}
|
|
2426
2431
|
saveQueryData(t, n, i, r, s) {
|
|
2427
2432
|
const o = s !== void 0 && s.size > 0 ? new Set([...s.keys()].map((a) => a.key)) : void 0;
|
|
@@ -2430,7 +2435,7 @@ class Bn {
|
|
|
2430
2435
|
activateQuery(t) {
|
|
2431
2436
|
const { def: n, queryKey: i, storageKey: r, config: s } = t;
|
|
2432
2437
|
this.store.activateQuery(n, r);
|
|
2433
|
-
const o = s?.gcTime ??
|
|
2438
|
+
const o = s?.gcTime ?? Vt;
|
|
2434
2439
|
this.gcManager.cancel(i, o);
|
|
2435
2440
|
}
|
|
2436
2441
|
loadCachedQuery(t, n) {
|
|
@@ -2441,7 +2446,7 @@ class Bn {
|
|
|
2441
2446
|
* that triggers fetches and prepopulates with cached data
|
|
2442
2447
|
*/
|
|
2443
2448
|
getQuery(t, n) {
|
|
2444
|
-
const i =
|
|
2449
|
+
const i = St(t, n);
|
|
2445
2450
|
let r = this.queryInstances.get(i);
|
|
2446
2451
|
return r === void 0 && (r = new wn(t, this, i, n), this.queryInstances.set(i, r)), r.relay;
|
|
2447
2452
|
}
|
|
@@ -2460,8 +2465,8 @@ class Bn {
|
|
|
2460
2465
|
*/
|
|
2461
2466
|
parseData(t, n, i) {
|
|
2462
2467
|
const r = this.context.log?.warn ?? (() => {
|
|
2463
|
-
}), s = new
|
|
2464
|
-
return s.reset(this, i, r), { data:
|
|
2468
|
+
}), s = new ft();
|
|
2469
|
+
return s.reset(this, i, r), { data: oe(t, n, s), ctx: s };
|
|
2465
2470
|
}
|
|
2466
2471
|
/**
|
|
2467
2472
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
@@ -2469,7 +2474,7 @@ class Bn {
|
|
|
2469
2474
|
* refs. Returns the reified data and root-level entity refs.
|
|
2470
2475
|
*/
|
|
2471
2476
|
applyRefs(t, n = !0, i = !1) {
|
|
2472
|
-
return
|
|
2477
|
+
return rt(t.ctx, t.data, n, i);
|
|
2473
2478
|
}
|
|
2474
2479
|
/**
|
|
2475
2480
|
* Parse and apply data as a root entity. For non-entity results, injects
|
|
@@ -2477,8 +2482,8 @@ class Bn {
|
|
|
2477
2482
|
* found in the store by the standard entity pipeline).
|
|
2478
2483
|
*/
|
|
2479
2484
|
parseAndApplyRootEntity(t, n, i, r, s = !1, o) {
|
|
2480
|
-
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[
|
|
2481
|
-
const a = this.parseData(t, i, o), c =
|
|
2485
|
+
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Kt] = n);
|
|
2486
|
+
const a = this.parseData(t, i, o), c = rt(a.ctx, a.data, r, s), f = S.get(c.data);
|
|
2482
2487
|
return this.entityMap.getEntity(f);
|
|
2483
2488
|
}
|
|
2484
2489
|
prepareEntity(t, n, i) {
|
|
@@ -2502,20 +2507,20 @@ class Bn {
|
|
|
2502
2507
|
}
|
|
2503
2508
|
try {
|
|
2504
2509
|
const _ = this.context.log?.warn ?? (() => {
|
|
2505
|
-
}),
|
|
2506
|
-
|
|
2510
|
+
}), m = new ft();
|
|
2511
|
+
m.reset(
|
|
2507
2512
|
this,
|
|
2508
2513
|
void 0,
|
|
2509
2514
|
_,
|
|
2510
2515
|
/* isPartialEvent */
|
|
2511
2516
|
!0
|
|
2512
2517
|
);
|
|
2513
|
-
const
|
|
2514
|
-
|
|
2518
|
+
const O = an(l, r, m);
|
|
2519
|
+
rt(m, O, !0);
|
|
2515
2520
|
} catch (_) {
|
|
2516
2521
|
if (this.context.log?.warn?.("Failed to apply mutation event", _), u === void 0) {
|
|
2517
|
-
const
|
|
2518
|
-
|
|
2522
|
+
const m = this.entityMap.getEntity(c);
|
|
2523
|
+
m !== void 0 && m.evict();
|
|
2519
2524
|
}
|
|
2520
2525
|
return;
|
|
2521
2526
|
}
|
|
@@ -2535,14 +2540,14 @@ class Bn {
|
|
|
2535
2540
|
for (const n of t) {
|
|
2536
2541
|
const i = Array.isArray(n), r = i ? n[0] : n, s = i ? n[1] : void 0, a = H.for(r).statics.id;
|
|
2537
2542
|
for (const [, c] of this.queryInstances)
|
|
2538
|
-
c.def.statics.id === a && (s === void 0 ||
|
|
2543
|
+
c.def.statics.id === a && (s === void 0 || kn(c.resolvedParams, s)) && c.markStale();
|
|
2539
2544
|
}
|
|
2540
2545
|
}
|
|
2541
2546
|
// ======================================================
|
|
2542
2547
|
// In-Memory GC
|
|
2543
2548
|
// ======================================================
|
|
2544
2549
|
handleEviction = (t, n) => {
|
|
2545
|
-
if (n ===
|
|
2550
|
+
if (n === tt.Query) {
|
|
2546
2551
|
const r = this.queryInstances.get(t);
|
|
2547
2552
|
if (r === void 0) return;
|
|
2548
2553
|
r.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
@@ -2556,7 +2561,7 @@ class Bn {
|
|
|
2556
2561
|
// ======================================================
|
|
2557
2562
|
getOrCreateMatcher(t) {
|
|
2558
2563
|
let n = this.constraintRegistry.get(t);
|
|
2559
|
-
return n === void 0 && (n = new
|
|
2564
|
+
return n === void 0 && (n = new xn(), this.constraintRegistry.set(t, n)), n;
|
|
2560
2565
|
}
|
|
2561
2566
|
registerLiveCollection(t) {
|
|
2562
2567
|
for (const [n, i] of t._entityDefsByTypename)
|
|
@@ -2571,7 +2576,7 @@ class Bn {
|
|
|
2571
2576
|
routeEvent(t, n, i, r, s, o, a) {
|
|
2572
2577
|
const c = this.constraintRegistry.get(t);
|
|
2573
2578
|
if (c === void 0) return;
|
|
2574
|
-
const f = s !== void 0 ? { ...n, [
|
|
2579
|
+
const f = s !== void 0 ? { ...n, [he]: s } : n;
|
|
2575
2580
|
c.routeEvent(t, f, i, r, o, a);
|
|
2576
2581
|
}
|
|
2577
2582
|
destroy() {
|
|
@@ -2581,40 +2586,40 @@ class Bn {
|
|
|
2581
2586
|
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2582
2587
|
}
|
|
2583
2588
|
}
|
|
2584
|
-
const
|
|
2585
|
-
function
|
|
2589
|
+
const Fn = qt(void 0);
|
|
2590
|
+
function kn(e, t) {
|
|
2586
2591
|
if (e === void 0) return !1;
|
|
2587
2592
|
for (const n in t)
|
|
2588
2593
|
if (e[n] !== t[n]) return !1;
|
|
2589
2594
|
return !0;
|
|
2590
2595
|
}
|
|
2591
2596
|
export {
|
|
2592
|
-
|
|
2593
|
-
|
|
2597
|
+
F as A,
|
|
2598
|
+
gt as E,
|
|
2594
2599
|
Me as G,
|
|
2595
2600
|
Q as L,
|
|
2596
2601
|
d as M,
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
+
ue as N,
|
|
2603
|
+
Kt as Q,
|
|
2604
|
+
k as R,
|
|
2605
|
+
v as V,
|
|
2606
|
+
ht as a,
|
|
2602
2607
|
Ln as b,
|
|
2603
2608
|
K as c,
|
|
2604
2609
|
Te as d,
|
|
2605
|
-
|
|
2610
|
+
de as e,
|
|
2606
2611
|
Un as f,
|
|
2607
2612
|
Bn as g,
|
|
2608
|
-
|
|
2613
|
+
Fn as h,
|
|
2609
2614
|
_n as i,
|
|
2610
2615
|
$n as j,
|
|
2611
2616
|
Vn as k,
|
|
2612
|
-
|
|
2617
|
+
Gt as l,
|
|
2613
2618
|
$e as m,
|
|
2614
2619
|
X as n,
|
|
2615
2620
|
Kn as o,
|
|
2616
2621
|
qn as q,
|
|
2617
|
-
|
|
2622
|
+
ne as r,
|
|
2618
2623
|
sn as t
|
|
2619
2624
|
};
|
|
2620
|
-
//# sourceMappingURL=QueryClient-
|
|
2625
|
+
//# sourceMappingURL=QueryClient-BZY2FTv3.js.map
|