fetchium 0.1.1 → 0.2.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/README.md +1 -1
- package/dist/cjs/development/QueryAdapter-DUo338ga.js +2 -0
- package/dist/cjs/development/QueryAdapter-DUo338ga.js.map +1 -0
- package/dist/cjs/development/QueryClient-m7BzCIe9.js +2 -0
- package/dist/cjs/development/QueryClient-m7BzCIe9.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/development/mutation-wUhcGxKl.js +2 -0
- package/dist/cjs/development/mutation-wUhcGxKl.js.map +1 -0
- 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/development/topic/index.js.map +1 -1
- package/dist/cjs/production/QueryAdapter-DUo338ga.js +2 -0
- package/dist/cjs/production/QueryAdapter-DUo338ga.js.map +1 -0
- package/dist/cjs/production/QueryClient-4T90peFN.js +2 -0
- package/dist/cjs/production/QueryClient-4T90peFN.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/production/mutation-Dk0gznwX.js +2 -0
- package/dist/cjs/production/mutation-Dk0gznwX.js.map +1 -0
- 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/cjs/production/topic/index.js.map +1 -1
- package/dist/esm/{QueryController.d.ts → QueryAdapter.d.ts} +7 -7
- package/dist/esm/QueryAdapter.d.ts.map +1 -0
- package/dist/esm/QueryClient.d.ts +6 -6
- package/dist/esm/QueryClient.d.ts.map +1 -1
- package/dist/esm/QueryResult.d.ts +2 -2
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/{QueryController-Ch_ncxiI.js → QueryAdapter-Bu5UJjE4.js} +2 -2
- package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -0
- package/dist/esm/development/{QueryClient-Dtde3pss.js → QueryClient-BajBmpnA.js} +532 -532
- package/dist/esm/development/QueryClient-BajBmpnA.js.map +1 -0
- package/dist/esm/development/index.js +14 -14
- package/dist/esm/development/{mutation-UZshUQAf.js → mutation-DAOZE4Ok.js} +13 -13
- package/dist/esm/development/mutation-DAOZE4Ok.js.map +1 -0
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +26 -26
- package/dist/esm/development/rest/index.js.map +1 -1
- package/dist/esm/development/topic/index.js +11 -11
- package/dist/esm/development/topic/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/mutation.d.ts +3 -3
- package/dist/esm/mutation.d.ts.map +1 -1
- package/dist/esm/production/{QueryController-Ch_ncxiI.js → QueryAdapter-Bu5UJjE4.js} +2 -2
- package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -0
- package/dist/esm/production/{QueryClient-YqnBxFy1.js → QueryClient-KH0Ex_8m.js} +708 -708
- package/dist/esm/production/QueryClient-KH0Ex_8m.js.map +1 -0
- package/dist/esm/production/index.js +14 -14
- package/dist/esm/production/{mutation-pgFl1uIY.js → mutation-C7BOChR2.js} +13 -13
- package/dist/esm/production/mutation-C7BOChR2.js.map +1 -0
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +26 -26
- package/dist/esm/production/rest/index.js.map +1 -1
- package/dist/esm/production/topic/index.js +11 -11
- package/dist/esm/production/topic/index.js.map +1 -1
- package/dist/esm/query.d.ts +6 -6
- package/dist/esm/query.d.ts.map +1 -1
- package/dist/esm/rest/RESTMutation.d.ts +2 -2
- package/dist/esm/rest/RESTMutation.d.ts.map +1 -1
- package/dist/esm/rest/RESTQuery.d.ts +2 -2
- package/dist/esm/rest/RESTQuery.d.ts.map +1 -1
- package/dist/esm/rest/{RESTQueryController.d.ts → RESTQueryAdapter.d.ts} +6 -6
- package/dist/esm/rest/RESTQueryAdapter.d.ts.map +1 -0
- package/dist/esm/rest/index.d.ts +2 -2
- package/dist/esm/rest/index.d.ts.map +1 -1
- package/dist/esm/topic/TopicQuery.d.ts +2 -2
- package/dist/esm/topic/TopicQuery.d.ts.map +1 -1
- package/dist/esm/topic/{TopicQueryController.d.ts → TopicQueryAdapter.d.ts} +3 -3
- package/dist/esm/topic/TopicQueryAdapter.d.ts.map +1 -0
- package/dist/esm/topic/index.d.ts +1 -1
- package/dist/esm/topic/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/docs/api/fetchium.md +40 -40
- package/plugin/docs/core/queries.md +15 -15
- package/plugin/docs/core/streaming.md +18 -18
- package/plugin/docs/data/mutations.md +5 -5
- package/plugin/docs/quickstart.md +1 -1
- package/plugin/docs/setup/project-setup.md +19 -19
- package/dist/cjs/development/QueryClient-CLi3ONNM.js +0 -2
- package/dist/cjs/development/QueryClient-CLi3ONNM.js.map +0 -1
- package/dist/cjs/development/QueryController-BQA49OYU.js +0 -2
- package/dist/cjs/development/QueryController-BQA49OYU.js.map +0 -1
- package/dist/cjs/development/mutation-CikIl_6k.js +0 -2
- package/dist/cjs/development/mutation-CikIl_6k.js.map +0 -1
- package/dist/cjs/production/QueryClient-N0MJmuHW.js +0 -2
- package/dist/cjs/production/QueryClient-N0MJmuHW.js.map +0 -1
- package/dist/cjs/production/QueryController-BQA49OYU.js +0 -2
- package/dist/cjs/production/QueryController-BQA49OYU.js.map +0 -1
- package/dist/cjs/production/mutation-P_Yb4LI9.js +0 -2
- package/dist/cjs/production/mutation-P_Yb4LI9.js.map +0 -1
- package/dist/esm/QueryController.d.ts.map +0 -1
- package/dist/esm/development/QueryClient-Dtde3pss.js.map +0 -1
- package/dist/esm/development/QueryController-Ch_ncxiI.js.map +0 -1
- package/dist/esm/development/mutation-UZshUQAf.js.map +0 -1
- package/dist/esm/production/QueryClient-YqnBxFy1.js.map +0 -1
- package/dist/esm/production/QueryController-Ch_ncxiI.js.map +0 -1
- package/dist/esm/production/mutation-pgFl1uIY.js.map +0 -1
- package/dist/esm/rest/RESTQueryController.d.ts.map +0 -1
- package/dist/esm/topic/TopicQueryController.d.ts.map +0 -1
|
@@ -2,7 +2,7 @@ import { notifier as ft, relay as Tt, setScopeOwner as we, reactiveMethod as Ee,
|
|
|
2
2
|
import { registerCustomHash as xe, hashValue as N } from "signalium/utils";
|
|
3
3
|
import { d as $t } from "./shared-DcuVH8Pf.js";
|
|
4
4
|
import { SyncQueryStore as Ae, MemoryPersistentStore as Ne } from "./stores/sync.js";
|
|
5
|
-
var V = /* @__PURE__ */ ((e) => (e.Always = "always", e.Online = "online", e.OfflineFirst = "offlineFirst", e))(V || {}),
|
|
5
|
+
var V = /* @__PURE__ */ ((e) => (e.Always = "always", e.Online = "online", e.OfflineFirst = "offlineFirst", e))(V || {}), 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
6
|
const D = /* @__PURE__ */ Symbol("array"), F = /* @__PURE__ */ Symbol("record"), Lt = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
7
|
var ut = /* @__PURE__ */ ((e) => (e[e.Array = 0] = "Array", e[e.Value = 1] = "Value", e))(ut || {});
|
|
8
8
|
class B {
|
|
@@ -14,8 +14,8 @@ class B {
|
|
|
14
14
|
onCreate;
|
|
15
15
|
onUpdate;
|
|
16
16
|
onDelete;
|
|
17
|
-
constructor(t, n, i,
|
|
18
|
-
this.type = t, this.entityDefs = n, this.constraintFieldRefs = i, this.sort =
|
|
17
|
+
constructor(t, n, i, s, r, o, a, c) {
|
|
18
|
+
this.type = t, this.entityDefs = n, this.constraintFieldRefs = i, this.sort = s, this.valueType = r, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
|
|
19
19
|
}
|
|
20
20
|
static array(t, n, i) {
|
|
21
21
|
return new B(
|
|
@@ -29,15 +29,15 @@ class B {
|
|
|
29
29
|
void 0
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
-
static value(t, n, i,
|
|
32
|
+
static value(t, n, i, s, r, o) {
|
|
33
33
|
return new B(
|
|
34
34
|
1,
|
|
35
35
|
t,
|
|
36
36
|
n,
|
|
37
37
|
void 0,
|
|
38
38
|
i,
|
|
39
|
-
r,
|
|
40
39
|
s,
|
|
40
|
+
r,
|
|
41
41
|
o
|
|
42
42
|
);
|
|
43
43
|
}
|
|
@@ -62,8 +62,8 @@ class Ie {
|
|
|
62
62
|
}
|
|
63
63
|
_tick = () => {
|
|
64
64
|
const { _currentFlush: t, _nextFlush: n, _onEvict: i } = this;
|
|
65
|
-
for (const [
|
|
66
|
-
i(
|
|
65
|
+
for (const [s, r] of t)
|
|
66
|
+
i(s, r);
|
|
67
67
|
this._currentFlush = n, this._nextFlush = /* @__PURE__ */ new Map();
|
|
68
68
|
};
|
|
69
69
|
destroy() {
|
|
@@ -86,9 +86,9 @@ class De {
|
|
|
86
86
|
o.set(t, i), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const { _buckets:
|
|
90
|
-
let
|
|
91
|
-
|
|
89
|
+
const { _buckets: s } = this;
|
|
90
|
+
let r = s.get(n);
|
|
91
|
+
r || (r = new Ie(n, this._onEvict, this._multiplier), s.set(n, r)), r.schedule(t, i);
|
|
92
92
|
}
|
|
93
93
|
cancel(t, n) {
|
|
94
94
|
if (n !== 1 / 0) {
|
|
@@ -102,8 +102,8 @@ class De {
|
|
|
102
102
|
_flushNextTick = () => {
|
|
103
103
|
const { _nextTickEntries: t, _onEvict: n } = this;
|
|
104
104
|
this._nextTickScheduled = !1;
|
|
105
|
-
for (const [i,
|
|
106
|
-
n(i,
|
|
105
|
+
for (const [i, s] of t)
|
|
106
|
+
n(i, s);
|
|
107
107
|
t.clear();
|
|
108
108
|
};
|
|
109
109
|
destroy() {
|
|
@@ -121,7 +121,7 @@ class Fe {
|
|
|
121
121
|
destroy() {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const W = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"),
|
|
124
|
+
const W = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"), dt = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), z = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Me = /\[([^\]]+)\]/g;
|
|
125
125
|
function Ut(e) {
|
|
126
126
|
const t = {
|
|
127
127
|
[W]: !0,
|
|
@@ -154,37 +154,37 @@ function Vt(e) {
|
|
|
154
154
|
function Kt(e) {
|
|
155
155
|
let t = !1;
|
|
156
156
|
return new Proxy(e, {
|
|
157
|
-
set(n, i,
|
|
158
|
-
return n[i] =
|
|
157
|
+
set(n, i, s) {
|
|
158
|
+
return n[i] = s, !0;
|
|
159
159
|
},
|
|
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 === dt ? n : i === z ? () => {
|
|
164
164
|
t = !0;
|
|
165
165
|
} : typeof i == "symbol" ? n[i] : Ut([i]);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
function Te(e) {
|
|
170
|
-
const t = e[
|
|
170
|
+
const t = e[dt];
|
|
171
171
|
e[z]();
|
|
172
172
|
const n = {};
|
|
173
|
-
for (const
|
|
174
|
-
n[
|
|
173
|
+
for (const r of Object.getOwnPropertyNames(t))
|
|
174
|
+
n[r] = t[r];
|
|
175
175
|
const i = {};
|
|
176
|
-
let
|
|
177
|
-
for (;
|
|
178
|
-
for (const
|
|
179
|
-
if (
|
|
180
|
-
const o = Object.getOwnPropertyDescriptor(
|
|
181
|
-
typeof o.value == "function" && !(
|
|
176
|
+
let s = Object.getPrototypeOf(t);
|
|
177
|
+
for (; s && s !== Object.prototype; ) {
|
|
178
|
+
for (const r of Object.getOwnPropertyNames(s)) {
|
|
179
|
+
if (r === "constructor") continue;
|
|
180
|
+
const o = Object.getOwnPropertyDescriptor(s, r);
|
|
181
|
+
typeof o.value == "function" && !(r in i) && (i[r] = o.value);
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
s = Object.getPrototypeOf(s);
|
|
184
184
|
}
|
|
185
185
|
return { fields: n, methods: i };
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function ht(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 dt(e, t) {
|
|
|
194
194
|
}
|
|
195
195
|
function Pe(e, t) {
|
|
196
196
|
return e.replace(Me, (n, i) => {
|
|
197
|
-
const
|
|
198
|
-
return
|
|
197
|
+
const s = i.split("."), r = ht(s, t);
|
|
198
|
+
return r != null ? encodeURIComponent(String(r)) : "";
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
function J(e, t) {
|
|
202
202
|
if (qt(e))
|
|
203
|
-
return
|
|
203
|
+
return ht(Vt(e), t);
|
|
204
204
|
if (typeof e == "string")
|
|
205
205
|
return Pe(e, t);
|
|
206
206
|
if (Array.isArray(e))
|
|
@@ -214,11 +214,11 @@ function J(e, t) {
|
|
|
214
214
|
return e;
|
|
215
215
|
}
|
|
216
216
|
function it(e, t, n) {
|
|
217
|
-
const i = e.fields,
|
|
217
|
+
const i = e.fields, s = e.methods, r = { params: t }, o = {};
|
|
218
218
|
for (const [a, c] of Object.entries(i))
|
|
219
|
-
o[a] = J(c,
|
|
219
|
+
o[a] = J(c, r);
|
|
220
220
|
o.params = t, o.context = n;
|
|
221
|
-
for (const [a, c] of Object.entries(
|
|
221
|
+
for (const [a, c] of Object.entries(s))
|
|
222
222
|
o[a] = c.bind(o);
|
|
223
223
|
return o;
|
|
224
224
|
}
|
|
@@ -228,79 +228,79 @@ class Bt {
|
|
|
228
228
|
return Kt(this);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
const Qt = Object.entries,
|
|
231
|
+
const Qt = Object.entries, st = Object.keys;
|
|
232
232
|
let Yt = () => {
|
|
233
233
|
};
|
|
234
234
|
{
|
|
235
|
-
const t = (i,
|
|
236
|
-
if (i.size !==
|
|
237
|
-
for (const
|
|
238
|
-
if (!
|
|
235
|
+
const t = (i, s) => {
|
|
236
|
+
if (i.size !== s.size) return !1;
|
|
237
|
+
for (const r of i)
|
|
238
|
+
if (!s.has(r)) return !1;
|
|
239
239
|
return !0;
|
|
240
|
-
}, n = (i,
|
|
241
|
-
if (i ===
|
|
242
|
-
if (typeof i != typeof
|
|
240
|
+
}, n = (i, s) => {
|
|
241
|
+
if (i === s) return !0;
|
|
242
|
+
if (typeof i != typeof s) return !1;
|
|
243
243
|
if (typeof i == "number") {
|
|
244
|
-
const
|
|
245
|
-
if ((i & 65535) !== (
|
|
246
|
-
const o = i >> 16, a =
|
|
244
|
+
const r = s;
|
|
245
|
+
if ((i & 65535) !== (r & 65535)) return !1;
|
|
246
|
+
const o = i >> 16, a = r >> 16;
|
|
247
247
|
return !(o !== 0 && a !== 0 && o !== a);
|
|
248
248
|
}
|
|
249
|
-
if (typeof i == "string") return i ===
|
|
250
|
-
if (i instanceof Set &&
|
|
251
|
-
return t(i,
|
|
252
|
-
if (i instanceof m &&
|
|
253
|
-
const
|
|
254
|
-
if ((
|
|
255
|
-
const a =
|
|
249
|
+
if (typeof i == "string") return i === s;
|
|
250
|
+
if (i instanceof Set && s instanceof Set)
|
|
251
|
+
return t(i, s);
|
|
252
|
+
if (i instanceof m && s instanceof m) {
|
|
253
|
+
const r = i.mask, o = s.mask;
|
|
254
|
+
if ((r & 65535) !== (o & 65535)) return !1;
|
|
255
|
+
const a = r >> 16, c = o >> 16;
|
|
256
256
|
if (a !== 0 && c !== 0 && a !== c) return !1;
|
|
257
|
-
if (i.shape ===
|
|
258
|
-
if (i.shape !== void 0 &&
|
|
259
|
-
const f = i.shape,
|
|
257
|
+
if (i.shape === s.shape) return !0;
|
|
258
|
+
if (i.shape !== void 0 && s.shape !== void 0 && typeof i.shape == "object" && typeof s.shape == "object") {
|
|
259
|
+
const f = i.shape, h = s.shape;
|
|
260
260
|
for (const u of Object.keys(f))
|
|
261
|
-
if (u in
|
|
262
|
-
for (const u of Object.keys(
|
|
263
|
-
if (u in f && !n(f[u],
|
|
261
|
+
if (u in h && !n(f[u], h[u])) return !1;
|
|
262
|
+
for (const u of Object.keys(h))
|
|
263
|
+
if (u in f && !n(f[u], h[u])) return !1;
|
|
264
264
|
}
|
|
265
265
|
return !0;
|
|
266
266
|
}
|
|
267
267
|
return !1;
|
|
268
268
|
};
|
|
269
|
-
Yt = (i,
|
|
270
|
-
if (!n(
|
|
269
|
+
Yt = (i, s, r, o) => {
|
|
270
|
+
if (!n(r, o))
|
|
271
271
|
throw new Error(
|
|
272
|
-
`[fetchium] Entity typename '${i}' has incompatible type for field '${
|
|
272
|
+
`[fetchium] Entity typename '${i}' has incompatible type for field '${s}' across different entity definitions`
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
function Ct(e) {
|
|
277
|
-
return typeof e == "number" ? e |
|
|
277
|
+
return typeof e == "number" ? e | d.UNDEFINED : e instanceof m ? (e.mask & d.UNDEFINED) !== 0 ? e : m.cloneWith(e, d.UNDEFINED) : e;
|
|
278
278
|
}
|
|
279
279
|
function St(e) {
|
|
280
|
-
return e instanceof m && (e.mask &
|
|
280
|
+
return e instanceof m && (e.mask & d.OBJECT) !== 0 && (e.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
281
281
|
}
|
|
282
282
|
function Gt(e, t, n) {
|
|
283
283
|
const i = /* @__PURE__ */ new Set();
|
|
284
|
-
for (const
|
|
285
|
-
if (
|
|
286
|
-
for (const o of Object.keys(
|
|
284
|
+
for (const r of e)
|
|
285
|
+
if (r !== void 0)
|
|
286
|
+
for (const o of Object.keys(r))
|
|
287
287
|
i.add(o);
|
|
288
|
-
const
|
|
289
|
-
for (const
|
|
288
|
+
const s = {};
|
|
289
|
+
for (const r of i) {
|
|
290
290
|
let o = 0, a;
|
|
291
291
|
const c = [];
|
|
292
292
|
let f = !0;
|
|
293
|
-
for (const
|
|
294
|
-
const u =
|
|
295
|
-
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !St(u) && Yt(n,
|
|
293
|
+
for (const h of e) {
|
|
294
|
+
const u = h?.[r];
|
|
295
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !St(u) && Yt(n, r, a, u), St(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
|
|
299
|
-
r
|
|
298
|
+
const h = Gt(c, t, n), u = new m(d.OBJECT, h);
|
|
299
|
+
s[r] = o < t ? Ct(u) : u;
|
|
300
300
|
} else
|
|
301
|
-
r
|
|
301
|
+
s[r] = o < t ? Ct(a) : a;
|
|
302
302
|
}
|
|
303
|
-
return
|
|
303
|
+
return s;
|
|
304
304
|
}
|
|
305
305
|
class m {
|
|
306
306
|
mask;
|
|
@@ -331,12 +331,12 @@ class m {
|
|
|
331
331
|
* Live data configuration (shared by LiveArray and LiveValue).
|
|
332
332
|
*/
|
|
333
333
|
_liveConfig = void 0;
|
|
334
|
-
constructor(t, n, i,
|
|
335
|
-
this.mask = t, this.shape = n, this.values = i, this.typenameField =
|
|
334
|
+
constructor(t, n, i, s, r, o) {
|
|
335
|
+
this.mask = t, this.shape = n, this.values = i, this.typenameField = s, this.typenameValue = r, this.idField = o;
|
|
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),
|
|
339
|
+
const n = t.length, i = t.map((f) => f.shape), s = t[0].typenameValue ?? "(unknown)", r = Gt(i, n, s);
|
|
340
340
|
let o, a, c;
|
|
341
341
|
for (const f of t) {
|
|
342
342
|
if (o === void 0 && f.idField !== void 0)
|
|
@@ -348,8 +348,8 @@ class m {
|
|
|
348
348
|
a === void 0 && (a = f.typenameField), c === void 0 && (c = f.typenameValue);
|
|
349
349
|
}
|
|
350
350
|
return new m(
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
d.ENTITY | d.OBJECT,
|
|
352
|
+
r,
|
|
353
353
|
void 0,
|
|
354
354
|
a,
|
|
355
355
|
c,
|
|
@@ -375,10 +375,10 @@ class $ extends Set {
|
|
|
375
375
|
super(t), this.lowercaseMap = /* @__PURE__ */ new Map();
|
|
376
376
|
for (const n of t)
|
|
377
377
|
if (typeof n == "string") {
|
|
378
|
-
const i = n.toLowerCase(),
|
|
379
|
-
if (
|
|
378
|
+
const i = n.toLowerCase(), s = this.lowercaseMap.get(i);
|
|
379
|
+
if (s !== void 0)
|
|
380
380
|
throw new Error(
|
|
381
|
-
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${
|
|
381
|
+
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${n}' both become '${i}'`
|
|
382
382
|
);
|
|
383
383
|
this.lowercaseMap.set(i, n);
|
|
384
384
|
}
|
|
@@ -410,114 +410,114 @@ xe($, (e) => {
|
|
|
410
410
|
t += N(n);
|
|
411
411
|
return t >>> 0;
|
|
412
412
|
});
|
|
413
|
-
function
|
|
413
|
+
function lt(e, t) {
|
|
414
414
|
return new m(e, t);
|
|
415
415
|
}
|
|
416
416
|
function $e(e) {
|
|
417
|
-
return
|
|
417
|
+
return lt(d.ARRAY, e);
|
|
418
418
|
}
|
|
419
419
|
function Le(e) {
|
|
420
|
-
return
|
|
420
|
+
return lt(d.RECORD | d.OBJECT, e);
|
|
421
421
|
}
|
|
422
422
|
function Ue(e) {
|
|
423
|
-
return
|
|
423
|
+
return lt(d.PARSE_RESULT, e);
|
|
424
424
|
}
|
|
425
425
|
function Ht(e, t) {
|
|
426
|
-
let n = e, i,
|
|
426
|
+
let n = e, i, s, r;
|
|
427
427
|
for (const [o, a] of Qt(t))
|
|
428
428
|
switch (typeof a) {
|
|
429
429
|
case "number":
|
|
430
|
-
if ((a &
|
|
430
|
+
if ((a & d.ID) !== 0) {
|
|
431
431
|
if (i !== void 0)
|
|
432
432
|
throw new Error(`Duplicate id field: ${o}`);
|
|
433
433
|
i = o;
|
|
434
434
|
}
|
|
435
435
|
break;
|
|
436
436
|
case "string":
|
|
437
|
-
if (
|
|
437
|
+
if (s !== void 0 && s !== o)
|
|
438
438
|
throw new Error(`Duplicate typename field: ${o}`);
|
|
439
|
-
|
|
439
|
+
s = o, r = a;
|
|
440
440
|
break;
|
|
441
441
|
case "object":
|
|
442
442
|
if (a instanceof $ || a instanceof Set)
|
|
443
443
|
break;
|
|
444
|
-
a.mask &
|
|
444
|
+
a.mask & d.LIVE && (n |= d.LIVE);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
|
-
return new m(n, t, void 0,
|
|
447
|
+
return new m(n, t, void 0, s, r, i);
|
|
448
448
|
}
|
|
449
449
|
function qe(e) {
|
|
450
|
-
return Ht(
|
|
450
|
+
return Ht(d.OBJECT, e);
|
|
451
451
|
}
|
|
452
452
|
function Ot(e, t, n) {
|
|
453
453
|
const i = e.mask;
|
|
454
|
-
if ((i &
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
if (n !== void 0 && n !==
|
|
454
|
+
if ((i & d.UNION) !== 0) {
|
|
455
|
+
const s = e;
|
|
456
|
+
if (s.typenameField !== void 0) {
|
|
457
|
+
if (n !== void 0 && n !== s.typenameField)
|
|
458
458
|
throw new Error(
|
|
459
|
-
`Union typename field conflict: Cannot merge unions with different typename fields ('${n}' vs '${
|
|
459
|
+
`Union typename field conflict: Cannot merge unions with different typename fields ('${n}' vs '${s.typenameField}')`
|
|
460
460
|
);
|
|
461
|
-
n =
|
|
461
|
+
n = s.typenameField;
|
|
462
462
|
}
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
465
|
-
for (const o of [...
|
|
466
|
-
const a =
|
|
463
|
+
const r = s.shape;
|
|
464
|
+
if (r !== void 0)
|
|
465
|
+
for (const o of [...st(r), D, F]) {
|
|
466
|
+
const a = r[o];
|
|
467
467
|
if (t[o] !== void 0 && t[o] !== a)
|
|
468
468
|
throw new Error(
|
|
469
469
|
`Union merge conflict: Duplicate typename value '${String(o)}' found when merging nested unions (${String(t[o])} vs ${String(a)})`
|
|
470
470
|
);
|
|
471
471
|
t[o] = a;
|
|
472
472
|
}
|
|
473
|
-
} else if ((i &
|
|
473
|
+
} else if ((i & d.ARRAY) !== 0) {
|
|
474
474
|
if (t[D] !== void 0)
|
|
475
475
|
throw new Error("Array shape already defined");
|
|
476
476
|
t[D] = e.shape;
|
|
477
|
-
} else if ((i &
|
|
477
|
+
} else if ((i & d.RECORD) !== 0) {
|
|
478
478
|
if (t[F] !== void 0)
|
|
479
479
|
throw new Error("Record shape already defined");
|
|
480
480
|
t[F] = e.shape;
|
|
481
481
|
} else {
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
482
|
+
const s = e.typenameField, r = e.typenameValue;
|
|
483
|
+
if (r === void 0)
|
|
484
484
|
throw new Error(
|
|
485
485
|
"Object definitions must have a typename to be in a union with other objects, records, or arrays"
|
|
486
486
|
);
|
|
487
|
-
if (n !== void 0 &&
|
|
487
|
+
if (n !== void 0 && s !== n)
|
|
488
488
|
throw new Error("Object definitions must have the same typename field to be in the same union");
|
|
489
|
-
n =
|
|
489
|
+
n = s, t[r] = e;
|
|
490
490
|
}
|
|
491
491
|
return n;
|
|
492
492
|
}
|
|
493
493
|
function yt(...e) {
|
|
494
494
|
const t = e;
|
|
495
|
-
let n = 0, i = 0,
|
|
496
|
-
for (const
|
|
497
|
-
if (typeof
|
|
498
|
-
n |=
|
|
495
|
+
let n = 0, i = 0, s, r, o, a, c = 0;
|
|
496
|
+
for (const h of t) {
|
|
497
|
+
if (typeof h == "number") {
|
|
498
|
+
n |= h;
|
|
499
499
|
continue;
|
|
500
500
|
}
|
|
501
|
-
if (
|
|
502
|
-
if (
|
|
503
|
-
|
|
501
|
+
if (h instanceof Set) {
|
|
502
|
+
if (r === void 0)
|
|
503
|
+
r = new Set(h);
|
|
504
504
|
else
|
|
505
|
-
for (const u of
|
|
506
|
-
|
|
505
|
+
for (const u of h)
|
|
506
|
+
r.add(u);
|
|
507
507
|
continue;
|
|
508
508
|
}
|
|
509
|
-
if (i++, c |=
|
|
510
|
-
|
|
509
|
+
if (i++, c |= h.mask, i === 1) {
|
|
510
|
+
s = h;
|
|
511
511
|
continue;
|
|
512
512
|
}
|
|
513
|
-
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Ot(
|
|
513
|
+
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Ot(s, o, a)), a = Ot(h, o, a);
|
|
514
514
|
}
|
|
515
515
|
if (i === 0)
|
|
516
|
-
return
|
|
516
|
+
return r === void 0 ? n : n === 0 ? r : new m(n | d.UNION, void 0, r);
|
|
517
517
|
if (i === 1)
|
|
518
|
-
return m.cloneWith(
|
|
519
|
-
const f = n | c |
|
|
520
|
-
return new m(f, o,
|
|
518
|
+
return m.cloneWith(s, n);
|
|
519
|
+
const f = n | c | d.UNION;
|
|
520
|
+
return new m(f, o, r, a);
|
|
521
521
|
}
|
|
522
522
|
function pt(e, t, n) {
|
|
523
523
|
const i = e;
|
|
@@ -525,18 +525,18 @@ function pt(e, t, n) {
|
|
|
525
525
|
return i | t;
|
|
526
526
|
if (i instanceof Set)
|
|
527
527
|
return yt(e, t);
|
|
528
|
-
let
|
|
529
|
-
return
|
|
528
|
+
let s = n.get(i);
|
|
529
|
+
return s === void 0 && (s = m.cloneWith(i, t), n.set(i, s)), s;
|
|
530
530
|
}
|
|
531
531
|
const Ve = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new WeakMap();
|
|
532
532
|
function Qe(e) {
|
|
533
|
-
return pt(e,
|
|
533
|
+
return pt(e, d.UNDEFINED | d.NULL, Be);
|
|
534
534
|
}
|
|
535
535
|
function Ye(e) {
|
|
536
|
-
return pt(e,
|
|
536
|
+
return pt(e, d.UNDEFINED, Ve);
|
|
537
537
|
}
|
|
538
538
|
function Ge(e) {
|
|
539
|
-
return pt(e,
|
|
539
|
+
return pt(e, d.NULL, Ke);
|
|
540
540
|
}
|
|
541
541
|
function He(e) {
|
|
542
542
|
return e;
|
|
@@ -548,17 +548,17 @@ const Wt = ((...e) => new Set(e));
|
|
|
548
548
|
Wt.caseInsensitive = (...e) => new $(e);
|
|
549
549
|
const gt = 16;
|
|
550
550
|
let ze = 0;
|
|
551
|
-
const
|
|
551
|
+
const rt = [], zt = [], Jt = /* @__PURE__ */ new Map(), Xt = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new WeakSet();
|
|
552
552
|
class Q {
|
|
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 = rt[n](t), this._parsed = !0) : this._parsed = !1, Z.add(this);
|
|
559
559
|
}
|
|
560
560
|
getValue() {
|
|
561
|
-
return this._parsed || (this._formatted =
|
|
561
|
+
return this._parsed || (this._formatted = rt[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
562
562
|
}
|
|
563
563
|
toJSON() {
|
|
564
564
|
return this._parsed ? zt[this._formatId](this._formatted) : this._raw;
|
|
@@ -574,23 +574,23 @@ function Rt(e) {
|
|
|
574
574
|
const t = e >> gt;
|
|
575
575
|
return Xt.get(t);
|
|
576
576
|
}
|
|
577
|
-
function Zt(e, t, n, i,
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
const o =
|
|
577
|
+
function Zt(e, t, n, i, s) {
|
|
578
|
+
const r = ze++;
|
|
579
|
+
rt[r] = n, zt[r] = i, Xt.set(r, e);
|
|
580
|
+
const o = s?.eager ?? !0, c = r << gt | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
581
581
|
Jt.set(e, c);
|
|
582
582
|
}
|
|
583
583
|
Zt(
|
|
584
584
|
"date",
|
|
585
|
-
|
|
585
|
+
d.STRING,
|
|
586
586
|
(e) => {
|
|
587
587
|
const t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
588
588
|
if (!t)
|
|
589
589
|
throw new Error(`Invalid date string: ${e}. Expected YYYY-MM-DD format.`);
|
|
590
|
-
const [, n, i,
|
|
591
|
-
if (isNaN(
|
|
590
|
+
const [, n, i, s] = t, r = new Date(Date.UTC(parseInt(n, 10), parseInt(i, 10) - 1, parseInt(s, 10)));
|
|
591
|
+
if (isNaN(r.getTime()))
|
|
592
592
|
throw new Error(`Invalid date string: ${e}`);
|
|
593
|
-
return
|
|
593
|
+
return r;
|
|
594
594
|
},
|
|
595
595
|
(e) => {
|
|
596
596
|
const t = e.getUTCFullYear(), n = String(e.getUTCMonth() + 1).padStart(2, "0"), i = String(e.getUTCDate()).padStart(2, "0");
|
|
@@ -599,7 +599,7 @@ Zt(
|
|
|
599
599
|
);
|
|
600
600
|
Zt(
|
|
601
601
|
"date-time",
|
|
602
|
-
|
|
602
|
+
d.STRING,
|
|
603
603
|
(e) => {
|
|
604
604
|
const t = new Date(e);
|
|
605
605
|
if (isNaN(t.getTime()))
|
|
@@ -612,30 +612,30 @@ const xt = /* @__PURE__ */ new WeakMap();
|
|
|
612
612
|
function j(e) {
|
|
613
613
|
let t = xt.get(e);
|
|
614
614
|
if (t === void 0) {
|
|
615
|
-
const n = new e(), i = n[
|
|
615
|
+
const n = new e(), i = n[dt] ?? n;
|
|
616
616
|
n[z] && n[z]();
|
|
617
|
-
const
|
|
618
|
-
for (const [f,
|
|
619
|
-
if (!(typeof
|
|
617
|
+
const s = {};
|
|
618
|
+
for (const [f, h] of Qt(i)) {
|
|
619
|
+
if (!(typeof h == "number" || typeof h == "string" || h instanceof Set || h instanceof m || h instanceof $))
|
|
620
620
|
throw new Error(
|
|
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
|
|
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 h == "object" ? h?.constructor?.name ?? typeof h : typeof h}`
|
|
622
622
|
);
|
|
623
|
-
|
|
623
|
+
s[f] = h;
|
|
624
624
|
}
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
const f =
|
|
625
|
+
const r = Object.getPrototypeOf(e.prototype);
|
|
626
|
+
if (r != null) {
|
|
627
|
+
const f = r.constructor;
|
|
628
628
|
if (f !== Bt && typeof f == "function") {
|
|
629
629
|
const u = j(f).shape;
|
|
630
|
-
for (const
|
|
631
|
-
if (
|
|
632
|
-
throw new Error(`Cannot extend: field '${
|
|
630
|
+
for (const l of st(u))
|
|
631
|
+
if (l in s && s[l] !== u[l])
|
|
632
|
+
throw new Error(`Cannot extend: field '${l}' already exists in type definition`);
|
|
633
633
|
}
|
|
634
634
|
}
|
|
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 = Ht(
|
|
638
|
+
t = Ht(d.ENTITY | d.OBJECT, s), t._entityClass = e, st(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
639
639
|
const c = e;
|
|
640
640
|
c.cache && (t._entityCache = c.cache), xt.set(e, t);
|
|
641
641
|
}
|
|
@@ -649,20 +649,20 @@ function te(e, t) {
|
|
|
649
649
|
const n = /* @__PURE__ */ new Map();
|
|
650
650
|
if (Array.isArray(t))
|
|
651
651
|
for (const i of t) {
|
|
652
|
-
const [
|
|
652
|
+
const [s, r] = i, a = j(s).typenameValue;
|
|
653
653
|
if (a === void 0) continue;
|
|
654
654
|
const c = [];
|
|
655
|
-
for (const [f,
|
|
656
|
-
c.push([f,
|
|
655
|
+
for (const [f, h] of Object.entries(r))
|
|
656
|
+
c.push([f, h]);
|
|
657
657
|
c.length > 0 && n.set(a, c);
|
|
658
658
|
}
|
|
659
659
|
else {
|
|
660
|
-
const
|
|
661
|
-
if (
|
|
662
|
-
const
|
|
660
|
+
const s = Object.entries(t);
|
|
661
|
+
if (s.length === 0) return;
|
|
662
|
+
const r = s.map(([o, a]) => [o, a]);
|
|
663
663
|
for (const o of e) {
|
|
664
664
|
const a = o.typenameValue;
|
|
665
|
-
a !== void 0 && n.set(a,
|
|
665
|
+
a !== void 0 && n.set(a, r);
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
return n.size > 0 ? n : void 0;
|
|
@@ -671,19 +671,19 @@ function ee(e) {
|
|
|
671
671
|
return Array.isArray(e) ? e.map((t) => j(t)) : [j(e)];
|
|
672
672
|
}
|
|
673
673
|
function Ze(e, t) {
|
|
674
|
-
const n = ee(e), i = n.length === 1 ? n[0] : yt(...n.map((o) => o)),
|
|
675
|
-
return
|
|
674
|
+
const n = ee(e), i = n.length === 1 ? n[0] : yt(...n.map((o) => o)), s = d.ARRAY | d.LIVE, r = new m(s, i);
|
|
675
|
+
return r._liveConfig = B.array(
|
|
676
676
|
n,
|
|
677
677
|
te(n, t?.constraints),
|
|
678
678
|
t?.sort
|
|
679
|
-
),
|
|
679
|
+
), r;
|
|
680
680
|
}
|
|
681
681
|
function tn(e, t, n) {
|
|
682
|
-
const i = ee(t),
|
|
682
|
+
const i = ee(t), s = e, r = d.LIVE, o = new m(r, void 0);
|
|
683
683
|
return o._liveConfig = B.value(
|
|
684
684
|
i,
|
|
685
685
|
te(i, n?.constraints),
|
|
686
|
-
|
|
686
|
+
s,
|
|
687
687
|
n.onCreate,
|
|
688
688
|
n.onUpdate,
|
|
689
689
|
n.onDelete
|
|
@@ -694,12 +694,12 @@ const en = {
|
|
|
694
694
|
typename: He,
|
|
695
695
|
const: We,
|
|
696
696
|
enum: Wt,
|
|
697
|
-
id:
|
|
698
|
-
string:
|
|
699
|
-
number:
|
|
700
|
-
boolean:
|
|
701
|
-
null:
|
|
702
|
-
undefined:
|
|
697
|
+
id: d.ID | d.STRING | d.NUMBER,
|
|
698
|
+
string: d.STRING,
|
|
699
|
+
number: d.NUMBER,
|
|
700
|
+
boolean: d.BOOLEAN,
|
|
701
|
+
null: d.NULL,
|
|
702
|
+
undefined: d.UNDEFINED,
|
|
703
703
|
array: $e,
|
|
704
704
|
object: qe,
|
|
705
705
|
record: Le,
|
|
@@ -722,44 +722,44 @@ function K(e) {
|
|
|
722
722
|
if (typeof e == "boolean")
|
|
723
723
|
return String(e);
|
|
724
724
|
if (typeof e == "number") {
|
|
725
|
-
if ((e &
|
|
726
|
-
const
|
|
727
|
-
if (
|
|
728
|
-
return `"${
|
|
725
|
+
if ((e & d.HAS_FORMAT) !== 0) {
|
|
726
|
+
const s = Rt(e);
|
|
727
|
+
if (s)
|
|
728
|
+
return `"${s}"`;
|
|
729
729
|
}
|
|
730
730
|
const i = [];
|
|
731
|
-
return e &
|
|
731
|
+
return e & d.UNDEFINED && i.push("undefined"), e & d.NULL && i.push("null"), e & d.NUMBER && i.push("number"), e & d.STRING && i.push("string"), e & d.BOOLEAN && i.push("boolean"), e & d.OBJECT && i.push("object"), e & d.ARRAY && i.push("array"), i.length === 0 ? "unknown" : i.length === 1 ? i[0] : i.join(" | ");
|
|
732
732
|
}
|
|
733
733
|
let t = e.mask;
|
|
734
|
-
if (t &
|
|
734
|
+
if (t & d.UNION) {
|
|
735
735
|
const n = e, i = [];
|
|
736
736
|
if (n.values !== void 0 && n.values.size > 0)
|
|
737
|
-
for (const
|
|
738
|
-
const o = typeof
|
|
737
|
+
for (const r of n.values) {
|
|
738
|
+
const o = typeof r == "string" ? `"${r}"` : String(r);
|
|
739
739
|
i.push(o);
|
|
740
740
|
}
|
|
741
741
|
if (n.shape !== void 0) {
|
|
742
742
|
n.shape[D] !== void 0 && i.push(`Array<${K(n.shape[D])}>`), n.shape[F] !== void 0 && i.push(`Record<string, ${K(n.shape[F])}>`);
|
|
743
|
-
for (const [
|
|
744
|
-
|
|
743
|
+
for (const [r, o] of Object.entries(n.shape))
|
|
744
|
+
r !== D && r !== F && i.push(r);
|
|
745
745
|
}
|
|
746
|
-
if (t = n.mask, (t &
|
|
747
|
-
const
|
|
748
|
-
|
|
746
|
+
if (t = n.mask, (t & d.HAS_FORMAT) !== 0) {
|
|
747
|
+
const r = Rt(t);
|
|
748
|
+
r && i.push(`"${r}"`);
|
|
749
749
|
}
|
|
750
|
-
return t &
|
|
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(" | ");
|
|
751
751
|
}
|
|
752
|
-
if (t &
|
|
752
|
+
if (t & d.ENTITY)
|
|
753
753
|
return `Entity<${e.typenameValue}>`;
|
|
754
|
-
if (t &
|
|
754
|
+
if (t & d.ARRAY) {
|
|
755
755
|
const n = e.shape;
|
|
756
756
|
return `Array<${K(n)}>`;
|
|
757
757
|
}
|
|
758
|
-
if (t &
|
|
758
|
+
if (t & d.RECORD) {
|
|
759
759
|
const n = e.shape;
|
|
760
760
|
return `Record<string, ${K(n)}>`;
|
|
761
761
|
}
|
|
762
|
-
if (t &
|
|
762
|
+
if (t & d.OBJECT) {
|
|
763
763
|
const n = e.typenameValue;
|
|
764
764
|
return n ? `Object<${n}>` : "object";
|
|
765
765
|
}
|
|
@@ -772,18 +772,18 @@ function q(e, t, n) {
|
|
|
772
772
|
}
|
|
773
773
|
const ne = Array.isArray;
|
|
774
774
|
function At(e) {
|
|
775
|
-
if (e === null) return
|
|
775
|
+
if (e === null) return d.NULL;
|
|
776
776
|
switch (typeof e) {
|
|
777
777
|
case "number":
|
|
778
|
-
return
|
|
778
|
+
return d.NUMBER;
|
|
779
779
|
case "string":
|
|
780
|
-
return
|
|
780
|
+
return d.STRING;
|
|
781
781
|
case "boolean":
|
|
782
|
-
return
|
|
782
|
+
return d.BOOLEAN;
|
|
783
783
|
case "undefined":
|
|
784
|
-
return
|
|
784
|
+
return d.UNDEFINED;
|
|
785
785
|
case "object":
|
|
786
|
-
return ne(e) ?
|
|
786
|
+
return ne(e) ? d.ARRAY : d.OBJECT;
|
|
787
787
|
default:
|
|
788
788
|
throw new Error(`Invalid type: ${typeof e}`);
|
|
789
789
|
}
|
|
@@ -800,8 +800,8 @@ function P(e) {
|
|
|
800
800
|
return new Date(e.getTime());
|
|
801
801
|
if (e instanceof Map) {
|
|
802
802
|
const n = /* @__PURE__ */ new Map();
|
|
803
|
-
for (const [i,
|
|
804
|
-
n.set(P(i), P(
|
|
803
|
+
for (const [i, s] of e)
|
|
804
|
+
n.set(P(i), P(s));
|
|
805
805
|
return n;
|
|
806
806
|
}
|
|
807
807
|
if (e instanceof Set) {
|
|
@@ -826,23 +826,23 @@ class ot {
|
|
|
826
826
|
isPartialEvent = !1;
|
|
827
827
|
seen = void 0;
|
|
828
828
|
seenByKey = void 0;
|
|
829
|
-
reset(t, n, i,
|
|
830
|
-
this.queryClient = t, this.preloadedEntities = n, this.warn = i, this.isPartialEvent =
|
|
829
|
+
reset(t, n, i, s = !1) {
|
|
830
|
+
this.queryClient = t, this.preloadedEntities = n, this.warn = i, this.isPartialEvent = s, 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
833
|
function ie(e, t, n) {
|
|
834
834
|
return M(e, t, n, "");
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function sn(e, t, n) {
|
|
837
837
|
return vt(e, t, n);
|
|
838
838
|
}
|
|
839
839
|
function Nt(e, t, n, i) {
|
|
840
|
-
const
|
|
841
|
-
if ((e &
|
|
840
|
+
const s = e >> gt;
|
|
841
|
+
if ((e & d.IS_EAGER_FORMAT) !== 0)
|
|
842
842
|
try {
|
|
843
|
-
return new Q(t,
|
|
843
|
+
return new Q(t, s, !0);
|
|
844
844
|
} catch (o) {
|
|
845
|
-
if ((e &
|
|
845
|
+
if ((e & d.UNDEFINED) !== 0) {
|
|
846
846
|
n.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
847
847
|
value: t,
|
|
848
848
|
path: i,
|
|
@@ -852,133 +852,133 @@ function Nt(e, t, n, i) {
|
|
|
852
852
|
}
|
|
853
853
|
throw o;
|
|
854
854
|
}
|
|
855
|
-
return new Q(t,
|
|
855
|
+
return new Q(t, s, !1);
|
|
856
856
|
}
|
|
857
857
|
function M(e, t, n, i) {
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
860
|
-
const c =
|
|
861
|
-
if (c === void 0) throw q(i,
|
|
858
|
+
const s = t;
|
|
859
|
+
if (s instanceof $) {
|
|
860
|
+
const c = s.get(e);
|
|
861
|
+
if (c === void 0) throw q(i, s, e);
|
|
862
862
|
return c;
|
|
863
863
|
}
|
|
864
|
-
if (
|
|
865
|
-
if (!
|
|
864
|
+
if (s instanceof Set) {
|
|
865
|
+
if (!s.has(e)) throw q(i, s, e);
|
|
866
866
|
return e;
|
|
867
867
|
}
|
|
868
|
-
if (typeof
|
|
869
|
-
if (e == null) return
|
|
870
|
-
if (e !==
|
|
868
|
+
if (typeof s == "string") {
|
|
869
|
+
if (e == null) return s;
|
|
870
|
+
if (e !== s) throw q(i, s, e);
|
|
871
871
|
return e;
|
|
872
872
|
}
|
|
873
|
-
if (typeof
|
|
873
|
+
if (typeof s == "number") {
|
|
874
874
|
const c = At(e);
|
|
875
|
-
if ((
|
|
876
|
-
if ((
|
|
875
|
+
if ((s & c) === 0) {
|
|
876
|
+
if ((s & d.UNDEFINED) !== 0) {
|
|
877
877
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
878
878
|
return;
|
|
879
879
|
}
|
|
880
|
-
throw q(i,
|
|
880
|
+
throw q(i, s, e);
|
|
881
881
|
}
|
|
882
|
-
return (
|
|
882
|
+
return (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? Nt(s, e, n, i) : e;
|
|
883
883
|
}
|
|
884
|
-
const
|
|
884
|
+
const r = s.mask, o = s._liveConfig;
|
|
885
885
|
if (o !== void 0 && o.type === ut.Value)
|
|
886
886
|
return o.valueType !== void 0 ? M(e, o.valueType, n, i) : e;
|
|
887
|
-
if ((
|
|
887
|
+
if ((r & d.PARSE_RESULT) !== 0)
|
|
888
888
|
try {
|
|
889
|
-
return { success: !0, value: M(e,
|
|
889
|
+
return { success: !0, value: M(e, s.shape, n, i) };
|
|
890
890
|
} catch (c) {
|
|
891
891
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
892
892
|
}
|
|
893
893
|
const a = At(e);
|
|
894
|
-
if ((
|
|
895
|
-
if ((
|
|
894
|
+
if ((r & a) === 0 && !s.values?.has(e)) {
|
|
895
|
+
if ((r & d.UNDEFINED) !== 0) {
|
|
896
896
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
897
897
|
return;
|
|
898
898
|
}
|
|
899
|
-
throw q(i,
|
|
899
|
+
throw q(i, r, e);
|
|
900
900
|
}
|
|
901
|
-
return a <
|
|
901
|
+
return a < d.OBJECT ? (r & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? Nt(r, e, n, i) : e : (r & d.UNION) !== 0 ? rn(a, e, s, n, i) : a === d.ARRAY ? se(e, s.shape, n, i) : (r & d.RECORD) !== 0 ? re(e, s.shape, n, i) : (r & d.ENTITY) !== 0 && n.queryClient !== void 0 ? vt(e, s, n) : oe(e, s, n, i);
|
|
902
902
|
}
|
|
903
|
-
function
|
|
904
|
-
if (e ===
|
|
905
|
-
const
|
|
906
|
-
return
|
|
903
|
+
function rn(e, t, n, i, s) {
|
|
904
|
+
if (e === d.ARRAY) {
|
|
905
|
+
const r = n.shape[D];
|
|
906
|
+
return r === void 0 || typeof r == "number" ? t : se(t, r, i, s);
|
|
907
907
|
} else {
|
|
908
|
-
const
|
|
908
|
+
const r = n.typenameField, o = r ? t[r] : void 0;
|
|
909
909
|
if (o === void 0 || typeof o != "string") {
|
|
910
910
|
const c = n.shape[F];
|
|
911
911
|
if (c === void 0)
|
|
912
912
|
throw new Error(
|
|
913
|
-
`Typename field '${
|
|
913
|
+
`Typename field '${r}' is required for union discrimination but was not found in the data`
|
|
914
914
|
);
|
|
915
|
-
return
|
|
915
|
+
return re(t, c, i, s);
|
|
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 &
|
|
920
|
+
return a.mask & d.ENTITY && i.queryClient !== void 0 ? vt(t, a, i) : oe(t, a, i, s);
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
function
|
|
924
|
-
const
|
|
925
|
-
for (let
|
|
923
|
+
function se(e, t, n, i) {
|
|
924
|
+
const s = [];
|
|
925
|
+
for (let r = 0; r < e.length; r++)
|
|
926
926
|
try {
|
|
927
|
-
|
|
927
|
+
s.push(M(e[r], t, n, `${i}[${r}]`));
|
|
928
928
|
} catch (o) {
|
|
929
929
|
n.warn("Failed to parse array item, filtering out", {
|
|
930
|
-
index:
|
|
931
|
-
value: e[
|
|
930
|
+
index: r,
|
|
931
|
+
value: e[r],
|
|
932
932
|
error: o instanceof Error ? o.message : String(o)
|
|
933
933
|
});
|
|
934
934
|
}
|
|
935
|
-
return
|
|
935
|
+
return s;
|
|
936
936
|
}
|
|
937
|
-
function
|
|
938
|
-
for (const [
|
|
939
|
-
e[
|
|
937
|
+
function re(e, t, n, i) {
|
|
938
|
+
for (const [s, r] of mt(e))
|
|
939
|
+
e[s] = M(r, t, n, `${i}["${s}"]`);
|
|
940
940
|
return e;
|
|
941
941
|
}
|
|
942
942
|
function oe(e, t, n, i) {
|
|
943
943
|
if (S.has(e))
|
|
944
944
|
return e;
|
|
945
|
-
const
|
|
946
|
-
for (const [
|
|
947
|
-
e[
|
|
945
|
+
const s = t.shape;
|
|
946
|
+
for (const [r, o] of mt(s))
|
|
947
|
+
e[r] = M(e[r], o, n, `${i}.${r}`);
|
|
948
948
|
return e;
|
|
949
949
|
}
|
|
950
950
|
function vt(e, t, n) {
|
|
951
|
-
const i = n.queryClient,
|
|
952
|
-
let
|
|
953
|
-
if (
|
|
954
|
-
|
|
951
|
+
const i = n.queryClient, s = n.preloadedEntities;
|
|
952
|
+
let r, o;
|
|
953
|
+
if (s !== void 0)
|
|
954
|
+
r = e.__entityRef, o = r;
|
|
955
955
|
else {
|
|
956
956
|
const p = e[t.idField];
|
|
957
957
|
if (p == null || typeof p != "string" && typeof p != "number")
|
|
958
958
|
throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
|
|
959
|
-
o = p,
|
|
959
|
+
o = p, r = N([t.typenameValue, o]);
|
|
960
960
|
}
|
|
961
|
-
const a = n.seenByKey.get(
|
|
961
|
+
const a = n.seenByKey.get(r);
|
|
962
962
|
if (a !== void 0)
|
|
963
963
|
return a.data;
|
|
964
|
-
if (
|
|
965
|
-
const w = i.entityMap.getEntity(
|
|
964
|
+
if (s !== void 0) {
|
|
965
|
+
const w = i.entityMap.getEntity(r)?.data ?? s.get(r);
|
|
966
966
|
if (w === void 0)
|
|
967
|
-
throw new Error(`Cached entity ${
|
|
967
|
+
throw new Error(`Cached entity ${r} not found in preloaded map`);
|
|
968
968
|
e = w;
|
|
969
969
|
}
|
|
970
970
|
const c = {};
|
|
971
971
|
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
972
|
-
const f = i.entityMap.getEntity(
|
|
973
|
-
key:
|
|
972
|
+
const f = i.entityMap.getEntity(r), h = n.isPartialEvent && f !== void 0, u = {
|
|
973
|
+
key: r,
|
|
974
974
|
shape: t,
|
|
975
975
|
data: c,
|
|
976
|
-
rawKeys:
|
|
976
|
+
rawKeys: h ? new Set(Object.keys(e)) : void 0
|
|
977
977
|
};
|
|
978
|
-
n.seen.set(c, u), n.seenByKey.set(
|
|
979
|
-
const
|
|
978
|
+
n.seen.set(c, u), n.seenByKey.set(r, u);
|
|
979
|
+
const l = `[[${t.typenameValue}:${o}]]`, g = t.shape;
|
|
980
980
|
for (const [p, w] of mt(g))
|
|
981
|
-
|
|
981
|
+
h && !(p in e) || (c[p] = M(e[p], w, n, `${l}.${p}`));
|
|
982
982
|
return c;
|
|
983
983
|
}
|
|
984
984
|
function on(e, t) {
|
|
@@ -988,12 +988,12 @@ function an(e, t, n) {
|
|
|
988
988
|
if (t === void 0) return !0;
|
|
989
989
|
for (const i of Object.keys(t)) {
|
|
990
990
|
if (i === n) continue;
|
|
991
|
-
const
|
|
992
|
-
if (
|
|
993
|
-
if ((
|
|
991
|
+
const s = t[i];
|
|
992
|
+
if (s instanceof m) {
|
|
993
|
+
if ((s.mask & d.UNDEFINED) !== 0) continue;
|
|
994
994
|
if (!(i in e) || e[i] === void 0) return !1;
|
|
995
|
-
} else if (typeof
|
|
996
|
-
if ((
|
|
995
|
+
} else if (typeof s == "number") {
|
|
996
|
+
if ((s & d.UNDEFINED) !== 0) continue;
|
|
997
997
|
if (!(i in e) || e[i] === void 0) return !1;
|
|
998
998
|
} else if (!(i in e) || e[i] === void 0) return !1;
|
|
999
999
|
}
|
|
@@ -1049,7 +1049,7 @@ const fn = {
|
|
|
1049
1049
|
return Object.getOwnPropertyDescriptor(e, t);
|
|
1050
1050
|
}
|
|
1051
1051
|
};
|
|
1052
|
-
class
|
|
1052
|
+
class dn {
|
|
1053
1053
|
_notifier;
|
|
1054
1054
|
_queryClient;
|
|
1055
1055
|
_proxies = /* @__PURE__ */ new Map();
|
|
@@ -1066,8 +1066,8 @@ class ln {
|
|
|
1066
1066
|
_entityCache;
|
|
1067
1067
|
_extraMethods;
|
|
1068
1068
|
_extraGetters;
|
|
1069
|
-
constructor(t, n, i,
|
|
1070
|
-
this._notifier = ft(), this._queryClient = o, this.key = t, this.typename = n, this.id = i, this.idField =
|
|
1069
|
+
constructor(t, n, i, s, r, o) {
|
|
1070
|
+
this._notifier = ft(), this._queryClient = o, this.key = t, this.typename = n, this.id = i, this.idField = s, this.data = r, this.entityRefs = void 0;
|
|
1071
1071
|
}
|
|
1072
1072
|
retain() {
|
|
1073
1073
|
this.refCount++;
|
|
@@ -1093,11 +1093,11 @@ class ln {
|
|
|
1093
1093
|
setChildRefs(t, n) {
|
|
1094
1094
|
const i = this.entityRefs;
|
|
1095
1095
|
if (t !== void 0 && t.size > 0)
|
|
1096
|
-
for (const
|
|
1097
|
-
(i === void 0 || !i.has(
|
|
1096
|
+
for (const s of t.keys())
|
|
1097
|
+
(i === void 0 || !i.has(s)) && s.retain();
|
|
1098
1098
|
if (i !== void 0 && i.size > 0)
|
|
1099
|
-
for (const
|
|
1100
|
-
(t === void 0 || !t.has(
|
|
1099
|
+
for (const s of i.keys())
|
|
1100
|
+
(t === void 0 || !t.has(s)) && s.release();
|
|
1101
1101
|
this.entityRefs = t, n && this.save();
|
|
1102
1102
|
}
|
|
1103
1103
|
addChildRef(t) {
|
|
@@ -1113,7 +1113,7 @@ class ln {
|
|
|
1113
1113
|
getProxy(t) {
|
|
1114
1114
|
const n = t;
|
|
1115
1115
|
let i = this._proxies.get(n);
|
|
1116
|
-
return i === void 0 && (i =
|
|
1116
|
+
return i === void 0 && (i = ln(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(n, i)), i;
|
|
1117
1117
|
}
|
|
1118
1118
|
get proxy() {
|
|
1119
1119
|
return this._proxies.values().next().value;
|
|
@@ -1131,30 +1131,30 @@ class ln {
|
|
|
1131
1131
|
this._notifier.consume();
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
function
|
|
1134
|
+
function hn(e, t, n) {
|
|
1135
1135
|
const i = [];
|
|
1136
|
-
for (const
|
|
1137
|
-
if (typeof
|
|
1138
|
-
const
|
|
1139
|
-
if (
|
|
1140
|
-
const o = n.entityMap.getEntity(
|
|
1141
|
-
o !== void 0 && o.satisfiesDef(t) && i.push(
|
|
1136
|
+
for (const s of e) {
|
|
1137
|
+
if (typeof s != "object" || s === null) continue;
|
|
1138
|
+
const r = S.get(s);
|
|
1139
|
+
if (r === void 0) continue;
|
|
1140
|
+
const o = n.entityMap.getEntity(r);
|
|
1141
|
+
o !== void 0 && o.satisfiesDef(t) && i.push(s);
|
|
1142
1142
|
}
|
|
1143
1143
|
return i;
|
|
1144
1144
|
}
|
|
1145
|
-
function
|
|
1146
|
-
const
|
|
1145
|
+
function ln(e, t, n, i, s) {
|
|
1146
|
+
const r = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig, h = c ? c.prototype : Bt.prototype, u = n.typenameField, l = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = () => ({ __entityRef: t });
|
|
1147
1147
|
let w;
|
|
1148
1148
|
f?.hasSubscribe && a && "__subscribe" in a && (w = Tt((E) => {
|
|
1149
1149
|
const y = (b) => {
|
|
1150
|
-
b.__eventSource = t,
|
|
1150
|
+
b.__eventSource = t, s.applyMutationEvent(b);
|
|
1151
1151
|
}, _ = a.__subscribe.call(v, y);
|
|
1152
1152
|
return E.value = v, _;
|
|
1153
1153
|
}));
|
|
1154
1154
|
let v;
|
|
1155
|
-
if (u && !(u in
|
|
1155
|
+
if (u && !(u in r))
|
|
1156
1156
|
throw new Error(`typenameField "${u}" must be declared in the entity shape`);
|
|
1157
|
-
const O = Object.keys(
|
|
1157
|
+
const O = Object.keys(r);
|
|
1158
1158
|
if (O.includes("__typename") || O.push("__typename"), a)
|
|
1159
1159
|
for (const E of Object.keys(a))
|
|
1160
1160
|
O.includes(E) || O.push(E);
|
|
@@ -1174,12 +1174,12 @@ function hn(e, t, n, i, r) {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
const U = {
|
|
1176
1176
|
getPrototypeOf() {
|
|
1177
|
-
return
|
|
1177
|
+
return h;
|
|
1178
1178
|
},
|
|
1179
1179
|
get(E, y) {
|
|
1180
1180
|
if (typeof y == "symbol") return;
|
|
1181
1181
|
if (y === "toJSON") return p;
|
|
1182
|
-
if (y === "__context") return
|
|
1182
|
+
if (y === "__context") return s.getContext();
|
|
1183
1183
|
if (y === "__typename") return e.typename;
|
|
1184
1184
|
if (w?.value, i.consume(), typeof y == "string") {
|
|
1185
1185
|
const b = e._extraGetters;
|
|
@@ -1187,30 +1187,30 @@ function hn(e, t, n, i, r) {
|
|
|
1187
1187
|
return b[y]();
|
|
1188
1188
|
const x = e._extraMethods;
|
|
1189
1189
|
if (x !== void 0 && y in x) {
|
|
1190
|
-
let C =
|
|
1191
|
-
return C || (C = x[y].bind(v),
|
|
1190
|
+
let C = l.get(y);
|
|
1191
|
+
return C || (C = x[y].bind(v), l.set(y, C)), C;
|
|
1192
1192
|
}
|
|
1193
1193
|
if (a && y in a) {
|
|
1194
|
-
let C =
|
|
1195
|
-
return C || (C = Ee(v, a[y].bind(v)),
|
|
1194
|
+
let C = l.get(y);
|
|
1195
|
+
return C || (C = Ee(v, a[y].bind(v)), l.set(y, C)), C;
|
|
1196
1196
|
}
|
|
1197
1197
|
}
|
|
1198
1198
|
const _ = e.data[y];
|
|
1199
1199
|
if (typeof _ == "object" && _ !== null && Z.has(_))
|
|
1200
1200
|
return A(_.getValue());
|
|
1201
1201
|
if (Array.isArray(_) && typeof y == "string") {
|
|
1202
|
-
const b =
|
|
1203
|
-
if (b instanceof m && (b.mask &
|
|
1202
|
+
const b = r[y];
|
|
1203
|
+
if (b instanceof m && (b.mask & d.ARRAY) !== 0) {
|
|
1204
1204
|
const x = b.shape;
|
|
1205
|
-
if (x instanceof m && (x.mask &
|
|
1205
|
+
if (x instanceof m && (x.mask & d.ENTITY) !== 0) {
|
|
1206
1206
|
const C = x.typenameValue;
|
|
1207
1207
|
if (C !== void 0) {
|
|
1208
|
-
const Et =
|
|
1208
|
+
const Et = s.getEntityDefsForTypename(C);
|
|
1209
1209
|
if (Et !== void 0 && Et.length > 1) {
|
|
1210
1210
|
const tt = g.get(y);
|
|
1211
1211
|
if (tt !== void 0 && tt.source === _)
|
|
1212
1212
|
return A(tt.filtered);
|
|
1213
|
-
const bt =
|
|
1213
|
+
const bt = hn(_, x, s);
|
|
1214
1214
|
return g.set(y, { source: _, filtered: bt }), A(bt);
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
@@ -1231,7 +1231,7 @@ function hn(e, t, n, i, r) {
|
|
|
1231
1231
|
const b = e._extraMethods;
|
|
1232
1232
|
if (b && y in b || a && y in a) return !0;
|
|
1233
1233
|
}
|
|
1234
|
-
return y in
|
|
1234
|
+
return y in r;
|
|
1235
1235
|
},
|
|
1236
1236
|
ownKeys() {
|
|
1237
1237
|
return L();
|
|
@@ -1239,7 +1239,7 @@ function hn(e, t, n, i, r) {
|
|
|
1239
1239
|
getOwnPropertyDescriptor(E, y) {
|
|
1240
1240
|
if (y === "__typename")
|
|
1241
1241
|
return { enumerable: !0, configurable: !0, value: e.typename, writable: !1 };
|
|
1242
|
-
if (y in
|
|
1242
|
+
if (y in r)
|
|
1243
1243
|
return { enumerable: !0, configurable: !0, value: U.get(E, y, v), writable: !1 };
|
|
1244
1244
|
if (typeof y == "string") {
|
|
1245
1245
|
const _ = e._extraGetters;
|
|
@@ -1253,7 +1253,7 @@ function hn(e, t, n, i, r) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
1255
|
};
|
|
1256
|
-
return v = new Proxy({}, U), S.set(v, t), we(v,
|
|
1256
|
+
return v = new Proxy({}, U), S.set(v, t), we(v, s), v;
|
|
1257
1257
|
}
|
|
1258
1258
|
class yn {
|
|
1259
1259
|
instances = /* @__PURE__ */ new Map();
|
|
@@ -1267,9 +1267,9 @@ class yn {
|
|
|
1267
1267
|
getEntity(t) {
|
|
1268
1268
|
return this.instances.get(t);
|
|
1269
1269
|
}
|
|
1270
|
-
getOrCreateEntity(t, n, i,
|
|
1271
|
-
let
|
|
1272
|
-
if (
|
|
1270
|
+
getOrCreateEntity(t, n, i, s) {
|
|
1271
|
+
let r = this.instances.get(t);
|
|
1272
|
+
if (r === void 0) {
|
|
1273
1273
|
const o = i.idField;
|
|
1274
1274
|
if (o === void 0)
|
|
1275
1275
|
throw new Error(`Entity id field is required ${i.typenameValue}`);
|
|
@@ -1277,9 +1277,9 @@ class yn {
|
|
|
1277
1277
|
if (typeof a != "string" && typeof a != "number")
|
|
1278
1278
|
throw new Error(`Entity id must be string or number: ${i.typenameValue}`);
|
|
1279
1279
|
const c = i;
|
|
1280
|
-
|
|
1280
|
+
r = new dn(t, i.typenameValue, a, o, n, s), r._entityCache = c._entityCache, this.instances.set(t, r);
|
|
1281
1281
|
}
|
|
1282
|
-
return
|
|
1282
|
+
return r.parseId = s.currentParseId, r;
|
|
1283
1283
|
}
|
|
1284
1284
|
remove(t) {
|
|
1285
1285
|
this.instances.delete(t);
|
|
@@ -1376,16 +1376,16 @@ const pn = new ae(), Tn = jt(pn);
|
|
|
1376
1376
|
function _t(e, t = typeof window > "u") {
|
|
1377
1377
|
let n;
|
|
1378
1378
|
e === !1 ? n = 0 : e === void 0 || e === !0 ? n = t ? 0 : 3 : typeof e == "number" ? n = e : n = e.retries;
|
|
1379
|
-
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (
|
|
1379
|
+
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (s) => 1e3 * Math.pow(2, s);
|
|
1380
1380
|
return { retries: n, retryDelay: i };
|
|
1381
1381
|
}
|
|
1382
1382
|
class Pn {
|
|
1383
1383
|
static cache;
|
|
1384
1384
|
/**
|
|
1385
|
-
* The
|
|
1385
|
+
* The adapter class responsible for sending requests for this query type.
|
|
1386
1386
|
* Must be set on each concrete Query subclass (or inherited from a base like RESTQuery).
|
|
1387
1387
|
*/
|
|
1388
|
-
static
|
|
1388
|
+
static adapter;
|
|
1389
1389
|
params;
|
|
1390
1390
|
config;
|
|
1391
1391
|
constructor() {
|
|
@@ -1402,31 +1402,31 @@ class G {
|
|
|
1402
1402
|
return it(this.captured, t, n);
|
|
1403
1403
|
}
|
|
1404
1404
|
resolveOptions(t) {
|
|
1405
|
-
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config,
|
|
1406
|
-
return { config: i, retryConfig:
|
|
1405
|
+
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config, s = _t(i?.retry);
|
|
1406
|
+
return { config: i, retryConfig: s };
|
|
1407
1407
|
}
|
|
1408
1408
|
static for(t) {
|
|
1409
1409
|
let n = It.get(t);
|
|
1410
1410
|
if (n !== void 0)
|
|
1411
1411
|
return n;
|
|
1412
|
-
const i = new t(),
|
|
1412
|
+
const i = new t(), s = Te(i), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof m ? o : en.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, h = s.fields.fetchNext, u = t.adapter;
|
|
1413
1413
|
if (!u)
|
|
1414
1414
|
throw new Error(
|
|
1415
|
-
`Query class "${t.name}" must define a static \`
|
|
1415
|
+
`Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
|
|
1416
1416
|
);
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1417
|
+
const l = typeof u.prototype.sendNext == "function", g = c ? a : new m(
|
|
1418
|
+
d.ENTITY | d.OBJECT,
|
|
1419
1419
|
a.shape,
|
|
1420
1420
|
void 0,
|
|
1421
1421
|
void 0,
|
|
1422
|
-
|
|
1422
|
+
r,
|
|
1423
1423
|
// typenameValue — unique per query class
|
|
1424
1424
|
Lt
|
|
1425
1425
|
// idField — symbol, injected onto payload before parse
|
|
1426
1426
|
);
|
|
1427
1427
|
return n = new G(
|
|
1428
|
-
{ id:
|
|
1429
|
-
|
|
1428
|
+
{ id: r, shape: g, cache: f, rawFetchNext: h, hasSendNext: l, isEntityResult: c, adapterClass: u },
|
|
1429
|
+
s
|
|
1430
1430
|
), It.set(t, n), n;
|
|
1431
1431
|
}
|
|
1432
1432
|
}
|
|
@@ -1438,8 +1438,8 @@ function $n(e, ...t) {
|
|
|
1438
1438
|
const n = G.for(e), i = be(An);
|
|
1439
1439
|
if (i === void 0)
|
|
1440
1440
|
throw new Error("QueryClient not found");
|
|
1441
|
-
const
|
|
1442
|
-
return i.getQuery(n,
|
|
1441
|
+
const s = t[0];
|
|
1442
|
+
return i.getQuery(n, s);
|
|
1443
1443
|
}
|
|
1444
1444
|
function fe(e, t) {
|
|
1445
1445
|
return new Promise((n, i) => {
|
|
@@ -1447,11 +1447,11 @@ function fe(e, t) {
|
|
|
1447
1447
|
i(t.reason);
|
|
1448
1448
|
return;
|
|
1449
1449
|
}
|
|
1450
|
-
const
|
|
1450
|
+
const s = setTimeout(n, e);
|
|
1451
1451
|
t?.addEventListener(
|
|
1452
1452
|
"abort",
|
|
1453
1453
|
() => {
|
|
1454
|
-
clearTimeout(
|
|
1454
|
+
clearTimeout(s), i(t.reason);
|
|
1455
1455
|
},
|
|
1456
1456
|
{ once: !0 }
|
|
1457
1457
|
);
|
|
@@ -1461,17 +1461,17 @@ async function at(e, t, n) {
|
|
|
1461
1461
|
if (t.retries < 0)
|
|
1462
1462
|
throw new Error("retries must be non-negative");
|
|
1463
1463
|
const i = Math.max(0, t.retries);
|
|
1464
|
-
let
|
|
1465
|
-
for (let
|
|
1464
|
+
let s;
|
|
1465
|
+
for (let r = 0; r <= i; r++) {
|
|
1466
1466
|
n?.throwIfAborted();
|
|
1467
1467
|
try {
|
|
1468
1468
|
return await e();
|
|
1469
1469
|
} catch (o) {
|
|
1470
|
-
if (
|
|
1471
|
-
await fe(t.retryDelay(
|
|
1470
|
+
if (s = o, r >= i) throw o;
|
|
1471
|
+
await fe(t.retryDelay(r), n);
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
throw
|
|
1474
|
+
throw s;
|
|
1475
1475
|
}
|
|
1476
1476
|
class gn {
|
|
1477
1477
|
def;
|
|
@@ -1491,7 +1491,7 @@ class gn {
|
|
|
1491
1491
|
/** Resolved per-instance options (depend on actual params). */
|
|
1492
1492
|
config = void 0;
|
|
1493
1493
|
retryConfig = _t(void 0);
|
|
1494
|
-
/**
|
|
1494
|
+
/** Cancels in-flight fetches and retry waits. */
|
|
1495
1495
|
_abortController = void 0;
|
|
1496
1496
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
1497
1497
|
_executionCtx = void 0;
|
|
@@ -1511,10 +1511,10 @@ class gn {
|
|
|
1511
1511
|
throw new Error("Relay state not initialized");
|
|
1512
1512
|
return this._relayState;
|
|
1513
1513
|
}
|
|
1514
|
-
constructor(t, n, i,
|
|
1515
|
-
this.def = t, this.queryClient = n, this.queryKey = i, this.params =
|
|
1516
|
-
const
|
|
1517
|
-
this._queryId =
|
|
1514
|
+
constructor(t, n, i, s) {
|
|
1515
|
+
this.def = t, this.queryClient = n, this.queryKey = i, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1516
|
+
const r = kt(s);
|
|
1517
|
+
this._queryId = r !== void 0 ? N(r) : 0, this.relay = Tt(
|
|
1518
1518
|
(o) => {
|
|
1519
1519
|
this._relayState = o;
|
|
1520
1520
|
const a = () => {
|
|
@@ -1522,13 +1522,13 @@ class gn {
|
|
|
1522
1522
|
const f = this.config?.gcTime ?? $t;
|
|
1523
1523
|
this.queryClient.gcManager.schedule(this.queryKey, f, X.Query);
|
|
1524
1524
|
}, c = (f = !1) => {
|
|
1525
|
-
const { wasPaused:
|
|
1526
|
-
if (this.wasPaused = u, u && !
|
|
1525
|
+
const { wasPaused: h, isPaused: u, initialized: l } = this;
|
|
1526
|
+
if (this.wasPaused = u, u && !h && l) {
|
|
1527
1527
|
a();
|
|
1528
1528
|
return;
|
|
1529
1529
|
}
|
|
1530
1530
|
const g = kt(this.params), p = wt(this.def, g), w = p !== this.storageKey;
|
|
1531
|
-
w && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ?
|
|
1531
|
+
w && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? h || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : w && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1532
1532
|
};
|
|
1533
1533
|
return c(!0), {
|
|
1534
1534
|
update: c,
|
|
@@ -1539,19 +1539,19 @@ class gn {
|
|
|
1539
1539
|
);
|
|
1540
1540
|
}
|
|
1541
1541
|
/** Apply raw data (fresh or cached) to the root entity and return the proxy. */
|
|
1542
|
-
applyData(t, n, i = !1,
|
|
1543
|
-
const
|
|
1542
|
+
applyData(t, n, i = !1, s) {
|
|
1543
|
+
const r = this.def;
|
|
1544
1544
|
return this.rootEntity = this.queryClient.parseAndApplyRootEntity(
|
|
1545
1545
|
t,
|
|
1546
1546
|
this._queryId,
|
|
1547
|
-
|
|
1547
|
+
r.statics.shape,
|
|
1548
1548
|
n,
|
|
1549
1549
|
i,
|
|
1550
|
-
|
|
1550
|
+
s
|
|
1551
1551
|
), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
|
|
1552
1552
|
__hasNext: () => this.hasNext,
|
|
1553
1553
|
__isFetchingNext: () => this._fetchNextPromise !== void 0
|
|
1554
|
-
}), this.rootEntity.getProxy(
|
|
1554
|
+
}), this.rootEntity.getProxy(r.statics.shape);
|
|
1555
1555
|
}
|
|
1556
1556
|
/** Save query metadata (the __entityRef pointer, updatedAt, ref set). */
|
|
1557
1557
|
saveQueryMetadata() {
|
|
@@ -1571,8 +1571,8 @@ class gn {
|
|
|
1571
1571
|
let i;
|
|
1572
1572
|
try {
|
|
1573
1573
|
i = await t.loadCachedQuery(this.def, this.storageKey), i !== void 0 && (this.updatedAt = i.updatedAt, n.value = this.applyData(i.value, !1, !1, i.preloadedEntities));
|
|
1574
|
-
} catch (
|
|
1575
|
-
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid",
|
|
1574
|
+
} catch (s) {
|
|
1575
|
+
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid", s);
|
|
1576
1576
|
}
|
|
1577
1577
|
if (!this.isPaused)
|
|
1578
1578
|
try {
|
|
@@ -1580,8 +1580,8 @@ class gn {
|
|
|
1580
1580
|
if (await fe(0), this.isPaused) return;
|
|
1581
1581
|
this.runQueryImmediately();
|
|
1582
1582
|
}
|
|
1583
|
-
} catch (
|
|
1584
|
-
n.setError(
|
|
1583
|
+
} catch (s) {
|
|
1584
|
+
n.setError(s);
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
1587
|
setupSubscription() {
|
|
@@ -1607,16 +1607,16 @@ class gn {
|
|
|
1607
1607
|
const t = this.def;
|
|
1608
1608
|
if (this.isPaused)
|
|
1609
1609
|
throw new Error("Query is paused due to network status");
|
|
1610
|
-
const n = this.getOrCreateExecutionContext(), i = this.queryClient.
|
|
1610
|
+
const n = this.getOrCreateExecutionContext(), i = this.queryClient.getAdapter(t.statics.adapterClass), s = this._abortController?.signal ?? new AbortController().signal;
|
|
1611
1611
|
return at(
|
|
1612
1612
|
async () => {
|
|
1613
|
-
const
|
|
1613
|
+
const r = await i.send(n, s);
|
|
1614
1614
|
this.updatedAt = Date.now();
|
|
1615
|
-
const o = this.applyData(
|
|
1615
|
+
const o = this.applyData(r, !0);
|
|
1616
1616
|
return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
|
|
1617
1617
|
},
|
|
1618
1618
|
this.retryConfig,
|
|
1619
|
-
|
|
1619
|
+
s
|
|
1620
1620
|
);
|
|
1621
1621
|
}
|
|
1622
1622
|
runQueryImmediately() {
|
|
@@ -1641,7 +1641,7 @@ class gn {
|
|
|
1641
1641
|
}
|
|
1642
1642
|
/** In-flight fetchNext promise for deduplication. */
|
|
1643
1643
|
_fetchNextPromise = void 0;
|
|
1644
|
-
/**
|
|
1644
|
+
/** Cancels in-flight fetchNext requests. */
|
|
1645
1645
|
_fetchNextAbort = void 0;
|
|
1646
1646
|
fetchNext = () => {
|
|
1647
1647
|
if (this.updatedAt === void 0)
|
|
@@ -1655,7 +1655,7 @@ class gn {
|
|
|
1655
1655
|
};
|
|
1656
1656
|
get hasNext() {
|
|
1657
1657
|
if (this.rootEntity === void 0 || !this._executionCtx) return !1;
|
|
1658
|
-
const t = this.queryClient.
|
|
1658
|
+
const t = this.queryClient.getAdapter(this.def.statics.adapterClass);
|
|
1659
1659
|
return t.hasNext ? (this._executionCtx.resultData = this.rootEntity.data, t.hasNext(this._executionCtx)) : !1;
|
|
1660
1660
|
}
|
|
1661
1661
|
async runFetchNext() {
|
|
@@ -1663,12 +1663,12 @@ class gn {
|
|
|
1663
1663
|
this._fetchNextAbort = new AbortController();
|
|
1664
1664
|
const n = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
|
|
1665
1665
|
i.resultData = this.rootEntity.data;
|
|
1666
|
-
const
|
|
1666
|
+
const s = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1667
1667
|
return at(
|
|
1668
1668
|
async () => {
|
|
1669
|
-
const
|
|
1669
|
+
const r = await s.sendNext(i, n);
|
|
1670
1670
|
this.updatedAt = Date.now();
|
|
1671
|
-
const o = this.applyData(
|
|
1671
|
+
const o = this.applyData(r, !0, !0);
|
|
1672
1672
|
return this.saveQueryMetadata(), o;
|
|
1673
1673
|
},
|
|
1674
1674
|
this.retryConfig,
|
|
@@ -1728,8 +1728,8 @@ class mn {
|
|
|
1728
1728
|
if (!(n instanceof m))
|
|
1729
1729
|
return t;
|
|
1730
1730
|
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1731
|
-
}),
|
|
1732
|
-
return
|
|
1731
|
+
}), s = new ot();
|
|
1732
|
+
return s.reset(void 0, void 0, i), ie(t, n, s);
|
|
1733
1733
|
}
|
|
1734
1734
|
// ======================================================
|
|
1735
1735
|
// Effects processing
|
|
@@ -1737,36 +1737,36 @@ class mn {
|
|
|
1737
1737
|
processEffects(t, n) {
|
|
1738
1738
|
let i;
|
|
1739
1739
|
if (this.def.hasGetEffects) {
|
|
1740
|
-
const
|
|
1740
|
+
const r = it(
|
|
1741
1741
|
this.def.captured,
|
|
1742
1742
|
t ?? {},
|
|
1743
1743
|
this.queryClient.getContext()
|
|
1744
1744
|
);
|
|
1745
|
-
|
|
1745
|
+
r.result = n, i = r.getEffects();
|
|
1746
1746
|
} else if (this.def.effects !== void 0) {
|
|
1747
|
-
const
|
|
1748
|
-
i = J(this.def.effects,
|
|
1747
|
+
const r = { params: t, result: n };
|
|
1748
|
+
i = J(this.def.effects, r);
|
|
1749
1749
|
}
|
|
1750
1750
|
if (i === void 0) return;
|
|
1751
|
-
const
|
|
1752
|
-
et(i.creates, "create",
|
|
1751
|
+
const s = this.queryClient;
|
|
1752
|
+
et(i.creates, "create", s), et(i.updates, "update", s), et(i.deletes, "delete", s), i.invalidates && s.invalidateQueries(i.invalidates);
|
|
1753
1753
|
}
|
|
1754
1754
|
// ======================================================
|
|
1755
1755
|
// Retry logic
|
|
1756
1756
|
// ======================================================
|
|
1757
1757
|
executeWithRetry(t) {
|
|
1758
|
-
const n = _t(this.def.config?.retry, !0), i = this.queryClient.
|
|
1758
|
+
const n = _t(this.def.config?.retry, !0), i = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1759
1759
|
if (!i.sendMutation)
|
|
1760
1760
|
throw new Error(
|
|
1761
|
-
`
|
|
1761
|
+
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1762
1762
|
);
|
|
1763
1763
|
return at(async () => {
|
|
1764
|
-
const
|
|
1764
|
+
const s = new AbortController(), r = it(
|
|
1765
1765
|
this.def.captured,
|
|
1766
1766
|
t ?? {},
|
|
1767
1767
|
this.queryClient.getContext()
|
|
1768
1768
|
);
|
|
1769
|
-
return await i.sendMutation(
|
|
1769
|
+
return await i.sendMutation(r, s.signal);
|
|
1770
1770
|
}, n);
|
|
1771
1771
|
}
|
|
1772
1772
|
}
|
|
@@ -1775,17 +1775,17 @@ function vn(e) {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
function et(e, t, n) {
|
|
1777
1777
|
if (e)
|
|
1778
|
-
for (const [i,
|
|
1779
|
-
const
|
|
1780
|
-
|
|
1778
|
+
for (const [i, s] of e) {
|
|
1779
|
+
const r = vn(i);
|
|
1780
|
+
r !== void 0 && n.applyMutationEvent({ type: t, typename: r, data: s });
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
1783
|
const ue = "__eventSource";
|
|
1784
|
-
function
|
|
1784
|
+
function de(e) {
|
|
1785
1785
|
return { field: e, segments: e.indexOf(".") !== -1 ? e.split(".") : void 0 };
|
|
1786
1786
|
}
|
|
1787
1787
|
function _n(e) {
|
|
1788
|
-
return e.map(
|
|
1788
|
+
return e.map(de);
|
|
1789
1789
|
}
|
|
1790
1790
|
function wn(e, t) {
|
|
1791
1791
|
if (t.segments === void 0) return e[t.field];
|
|
@@ -1796,33 +1796,33 @@ function wn(e, t) {
|
|
|
1796
1796
|
}
|
|
1797
1797
|
return n;
|
|
1798
1798
|
}
|
|
1799
|
-
function
|
|
1799
|
+
function he(e, t) {
|
|
1800
1800
|
const n = [];
|
|
1801
1801
|
for (let i = 0; i < t.length; i++) {
|
|
1802
|
-
const
|
|
1803
|
-
if (
|
|
1804
|
-
n.push(
|
|
1802
|
+
const s = t[i], r = wn(e, s);
|
|
1803
|
+
if (r === void 0) return;
|
|
1804
|
+
n.push(s.field, r);
|
|
1805
1805
|
}
|
|
1806
1806
|
return N(n);
|
|
1807
1807
|
}
|
|
1808
1808
|
function En(e, t) {
|
|
1809
1809
|
if (e === void 0) return;
|
|
1810
1810
|
const n = /* @__PURE__ */ new Map();
|
|
1811
|
-
for (const [i,
|
|
1812
|
-
const
|
|
1811
|
+
for (const [i, s] of e) {
|
|
1812
|
+
const r = s.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
|
|
1813
1813
|
let a = !0;
|
|
1814
|
-
for (const [c, f] of
|
|
1815
|
-
let
|
|
1814
|
+
for (const [c, f] of r) {
|
|
1815
|
+
let h;
|
|
1816
1816
|
if (qt(f)) {
|
|
1817
1817
|
const u = Vt(f);
|
|
1818
|
-
|
|
1818
|
+
h = ht(u, t);
|
|
1819
1819
|
} else
|
|
1820
|
-
|
|
1821
|
-
if (
|
|
1820
|
+
h = f;
|
|
1821
|
+
if (h === void 0) {
|
|
1822
1822
|
a = !1;
|
|
1823
1823
|
break;
|
|
1824
1824
|
}
|
|
1825
|
-
o.push(c,
|
|
1825
|
+
o.push(c, h);
|
|
1826
1826
|
}
|
|
1827
1827
|
a && n.set(i, N(o));
|
|
1828
1828
|
}
|
|
@@ -1838,7 +1838,7 @@ class bn {
|
|
|
1838
1838
|
fieldPaths;
|
|
1839
1839
|
_bindings = /* @__PURE__ */ new Map();
|
|
1840
1840
|
constructor(t) {
|
|
1841
|
-
this.fields = t, this.fieldPaths = t.map(
|
|
1841
|
+
this.fields = t, this.fieldPaths = t.map(de);
|
|
1842
1842
|
}
|
|
1843
1843
|
register(t, n) {
|
|
1844
1844
|
let i = this._bindings.get(t);
|
|
@@ -1869,29 +1869,29 @@ class Cn {
|
|
|
1869
1869
|
this.getOrCreateGroup(n).register(t, i);
|
|
1870
1870
|
}
|
|
1871
1871
|
unregister(t, n, i) {
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1872
|
+
const s = Ft(n), r = this._groups.get(s);
|
|
1873
|
+
r !== void 0 && (r.unregister(t, i), r.isEmpty && this._groups.delete(s));
|
|
1874
1874
|
}
|
|
1875
1875
|
registerBinding(t, n) {
|
|
1876
1876
|
const i = t._constraintHashes.get(n);
|
|
1877
1877
|
if (i === void 0) return;
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1878
|
+
const s = Dt(t._constraintFieldRefs, n);
|
|
1879
|
+
s !== void 0 && this.register(i, s, t);
|
|
1880
1880
|
}
|
|
1881
1881
|
unregisterBinding(t, n) {
|
|
1882
1882
|
const i = t._constraintHashes.get(n);
|
|
1883
1883
|
if (i === void 0) return;
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1884
|
+
const s = Dt(t._constraintFieldRefs, n);
|
|
1885
|
+
s !== void 0 && this.unregister(i, s, t);
|
|
1886
1886
|
}
|
|
1887
|
-
routeEvent(t, n, i,
|
|
1887
|
+
routeEvent(t, n, i, s, r, o) {
|
|
1888
1888
|
for (const a of this._groups.values()) {
|
|
1889
|
-
const c =
|
|
1889
|
+
const c = he(n, a.fieldPaths);
|
|
1890
1890
|
if (c === void 0) continue;
|
|
1891
1891
|
const f = a.getMatching(c);
|
|
1892
1892
|
if (f !== void 0)
|
|
1893
|
-
for (const
|
|
1894
|
-
|
|
1893
|
+
for (const h of f)
|
|
1894
|
+
h.onEvent(t, i, s, r, o);
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
}
|
|
@@ -1904,15 +1904,15 @@ function Mt(e) {
|
|
|
1904
1904
|
}
|
|
1905
1905
|
return t;
|
|
1906
1906
|
}
|
|
1907
|
-
class
|
|
1907
|
+
class le {
|
|
1908
1908
|
_queryClient;
|
|
1909
1909
|
_parent;
|
|
1910
1910
|
_constraintHashes;
|
|
1911
1911
|
_entityDefsByTypename;
|
|
1912
1912
|
_constraintFieldRefs;
|
|
1913
1913
|
instance;
|
|
1914
|
-
constructor(t, n, i,
|
|
1915
|
-
this._queryClient = i, this._parent =
|
|
1914
|
+
constructor(t, n, i, s, r, o) {
|
|
1915
|
+
this._queryClient = i, this._parent = s, this._constraintHashes = r, this._constraintFieldRefs = n, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1916
1916
|
for (const a of t)
|
|
1917
1917
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1918
1918
|
Z.add(this);
|
|
@@ -1934,17 +1934,17 @@ class he {
|
|
|
1934
1934
|
* root level by applyMutationEvent. The binding just checks if the entity's
|
|
1935
1935
|
* current data satisfies this binding's shape and forwards to the instance.
|
|
1936
1936
|
*/
|
|
1937
|
-
onEvent(t, n, i,
|
|
1937
|
+
onEvent(t, n, i, s, r) {
|
|
1938
1938
|
const o = this._entityDefsByTypename.get(t);
|
|
1939
1939
|
if (o === void 0) return;
|
|
1940
1940
|
const a = this._queryClient.entityMap.getEntity(n);
|
|
1941
1941
|
if (i === "delete") {
|
|
1942
|
-
const f = a !== void 0 ? a.getProxy(o) :
|
|
1943
|
-
f !== void 0 && (this.instance.onEvent(n, f,
|
|
1942
|
+
const f = a !== void 0 ? a.getProxy(o) : r;
|
|
1943
|
+
f !== void 0 && (this.instance.onEvent(n, f, r ?? a?.data ?? {}, "delete"), s?.());
|
|
1944
1944
|
return;
|
|
1945
1945
|
}
|
|
1946
1946
|
if (a === void 0 || !a.satisfiesDef(o)) return;
|
|
1947
|
-
|
|
1947
|
+
s?.();
|
|
1948
1948
|
const c = a.getProxy(o);
|
|
1949
1949
|
this.instance.onEvent(n, c, a.data, i);
|
|
1950
1950
|
}
|
|
@@ -1961,38 +1961,38 @@ class Sn {
|
|
|
1961
1961
|
_outputSignal;
|
|
1962
1962
|
_queryClient;
|
|
1963
1963
|
_parent;
|
|
1964
|
-
constructor(t, n, i,
|
|
1964
|
+
constructor(t, n, i, s, r, o) {
|
|
1965
1965
|
this._notifier = ft(), this._items = i, this._keys = Mt(i), this._queryClient = t, this._parent = n;
|
|
1966
|
-
const a =
|
|
1966
|
+
const a = s !== void 0 && r !== void 0, c = o !== void 0;
|
|
1967
1967
|
(a || c) && (this._outputSignal = Se(() => {
|
|
1968
1968
|
this._notifier.consume();
|
|
1969
1969
|
let f = this._items;
|
|
1970
1970
|
if (a) {
|
|
1971
|
-
const
|
|
1971
|
+
const h = [];
|
|
1972
1972
|
for (const u of f) {
|
|
1973
1973
|
if (typeof u != "object" || u === null) {
|
|
1974
|
-
|
|
1974
|
+
h.push(u);
|
|
1975
1975
|
continue;
|
|
1976
1976
|
}
|
|
1977
|
-
const
|
|
1978
|
-
if (
|
|
1979
|
-
|
|
1977
|
+
const l = T(u);
|
|
1978
|
+
if (l === void 0) {
|
|
1979
|
+
h.push(u);
|
|
1980
1980
|
continue;
|
|
1981
1981
|
}
|
|
1982
|
-
const g = t.entityMap.getEntity(
|
|
1982
|
+
const g = t.entityMap.getEntity(l);
|
|
1983
1983
|
if (g === void 0) {
|
|
1984
|
-
|
|
1984
|
+
h.push(u);
|
|
1985
1985
|
continue;
|
|
1986
1986
|
}
|
|
1987
|
-
g.consume(),
|
|
1987
|
+
g.consume(), he(g.data, s) === r && h.push(u);
|
|
1988
1988
|
}
|
|
1989
|
-
f =
|
|
1989
|
+
f = h;
|
|
1990
1990
|
}
|
|
1991
1991
|
return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
|
|
1992
1992
|
}));
|
|
1993
1993
|
}
|
|
1994
|
-
onEvent(t, n, i,
|
|
1995
|
-
switch (
|
|
1994
|
+
onEvent(t, n, i, s) {
|
|
1995
|
+
switch (s) {
|
|
1996
1996
|
case "create":
|
|
1997
1997
|
this.add(t, n);
|
|
1998
1998
|
break;
|
|
@@ -2030,19 +2030,19 @@ class Sn {
|
|
|
2030
2030
|
reset(t) {
|
|
2031
2031
|
const n = this._items, i = Array.isArray(t) ? t : [];
|
|
2032
2032
|
this._items = i, this._keys = Mt(i);
|
|
2033
|
-
for (const
|
|
2034
|
-
if (typeof
|
|
2035
|
-
const
|
|
2036
|
-
if (
|
|
2037
|
-
const o = this._queryClient.entityMap.getEntity(
|
|
2033
|
+
for (const s of i)
|
|
2034
|
+
if (typeof s == "object" && s !== null) {
|
|
2035
|
+
const r = T(s);
|
|
2036
|
+
if (r !== void 0) {
|
|
2037
|
+
const o = this._queryClient.entityMap.getEntity(r);
|
|
2038
2038
|
o !== void 0 && this._parent.addChildRef(o);
|
|
2039
2039
|
}
|
|
2040
2040
|
}
|
|
2041
|
-
for (const
|
|
2042
|
-
if (typeof
|
|
2043
|
-
const
|
|
2044
|
-
if (
|
|
2045
|
-
const o = this._queryClient.entityMap.getEntity(
|
|
2041
|
+
for (const s of n)
|
|
2042
|
+
if (typeof s == "object" && s !== null) {
|
|
2043
|
+
const r = T(s);
|
|
2044
|
+
if (r !== void 0) {
|
|
2045
|
+
const o = this._queryClient.entityMap.getEntity(r);
|
|
2046
2046
|
o !== void 0 && this._parent.removeChildRef(o);
|
|
2047
2047
|
}
|
|
2048
2048
|
}
|
|
@@ -2075,11 +2075,11 @@ class On {
|
|
|
2075
2075
|
_onCreate;
|
|
2076
2076
|
_onUpdate;
|
|
2077
2077
|
_onDelete;
|
|
2078
|
-
constructor(t, n, i,
|
|
2079
|
-
this._notifier = ft(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = n, this._onCreate =
|
|
2078
|
+
constructor(t, n, i, s, r, o) {
|
|
2079
|
+
this._notifier = ft(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = n, this._onCreate = s, this._onUpdate = r, this._onDelete = o;
|
|
2080
2080
|
}
|
|
2081
|
-
onEvent(t, n, i,
|
|
2082
|
-
switch (
|
|
2081
|
+
onEvent(t, n, i, s) {
|
|
2082
|
+
switch (s) {
|
|
2083
2083
|
case "create":
|
|
2084
2084
|
if (this._createdKeys.has(t)) return;
|
|
2085
2085
|
this._createdKeys.add(t), this._value = this._onCreate(this._value, n);
|
|
@@ -2106,72 +2106,72 @@ class On {
|
|
|
2106
2106
|
append(t) {
|
|
2107
2107
|
}
|
|
2108
2108
|
}
|
|
2109
|
-
function ye(e, t, n, i,
|
|
2110
|
-
let
|
|
2111
|
-
if (
|
|
2112
|
-
|
|
2109
|
+
function ye(e, t, n, i, s) {
|
|
2110
|
+
let r = e.constraintFieldRefs;
|
|
2111
|
+
if (r === void 0) {
|
|
2112
|
+
r = /* @__PURE__ */ new Map();
|
|
2113
2113
|
for (const f of e.entityDefs) {
|
|
2114
|
-
const
|
|
2115
|
-
|
|
2114
|
+
const h = f.typenameValue;
|
|
2115
|
+
h !== void 0 && r.set(h, [[ue, n.key]]);
|
|
2116
2116
|
}
|
|
2117
2117
|
}
|
|
2118
|
-
const o = En(
|
|
2118
|
+
const o = En(r, i) ?? /* @__PURE__ */ new Map();
|
|
2119
2119
|
let a;
|
|
2120
2120
|
if (e.type === ut.Array) {
|
|
2121
|
-
let f,
|
|
2121
|
+
let f, h;
|
|
2122
2122
|
if (e.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2123
2123
|
for (const [u] of e.constraintFieldRefs) {
|
|
2124
|
-
const
|
|
2125
|
-
if (
|
|
2126
|
-
|
|
2124
|
+
const l = o.get(u);
|
|
2125
|
+
if (l !== void 0) {
|
|
2126
|
+
h = l;
|
|
2127
2127
|
const g = e.constraintFieldRefs.get(u);
|
|
2128
2128
|
g !== void 0 && (f = _n(g.map(([p]) => p)));
|
|
2129
2129
|
break;
|
|
2130
2130
|
}
|
|
2131
2131
|
}
|
|
2132
2132
|
a = new Sn(
|
|
2133
|
-
|
|
2133
|
+
s,
|
|
2134
2134
|
n,
|
|
2135
2135
|
Array.isArray(t) ? t : [],
|
|
2136
2136
|
f,
|
|
2137
|
-
|
|
2137
|
+
h,
|
|
2138
2138
|
e.sort
|
|
2139
2139
|
);
|
|
2140
2140
|
} else
|
|
2141
2141
|
a = new On(
|
|
2142
|
-
|
|
2142
|
+
s,
|
|
2143
2143
|
n,
|
|
2144
2144
|
t,
|
|
2145
2145
|
e.onCreate,
|
|
2146
2146
|
e.onUpdate,
|
|
2147
2147
|
e.onDelete
|
|
2148
2148
|
);
|
|
2149
|
-
const c = new
|
|
2149
|
+
const c = new le(
|
|
2150
2150
|
e.entityDefs,
|
|
2151
|
-
s,
|
|
2152
2151
|
r,
|
|
2152
|
+
s,
|
|
2153
2153
|
n,
|
|
2154
2154
|
o,
|
|
2155
2155
|
a
|
|
2156
2156
|
);
|
|
2157
|
-
return n.liveCollections.push(c),
|
|
2157
|
+
return n.liveCollections.push(c), s.registerLiveCollection(c), c;
|
|
2158
2158
|
}
|
|
2159
2159
|
const pe = Object.entries, ge = Object.prototype;
|
|
2160
2160
|
function nt(e, t, n, i = !1) {
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
const
|
|
2164
|
-
return { data: Y(t,
|
|
2161
|
+
const s = e.queryClient;
|
|
2162
|
+
s.currentParseId++;
|
|
2163
|
+
const r = e.seen, o = /* @__PURE__ */ new Map();
|
|
2164
|
+
return { data: Y(t, r, s, n, o, i), entityRefs: o };
|
|
2165
2165
|
}
|
|
2166
|
-
function Y(e, t, n, i,
|
|
2166
|
+
function Y(e, t, n, i, s, r) {
|
|
2167
2167
|
if (typeof e != "object" || e === null) return e;
|
|
2168
2168
|
const o = t.get(e);
|
|
2169
2169
|
if (o !== void 0)
|
|
2170
|
-
return Rn(o, t, n, i,
|
|
2170
|
+
return Rn(o, t, n, i, s, r);
|
|
2171
2171
|
if (Array.isArray(e)) {
|
|
2172
2172
|
for (let a = 0; a < e.length; a++) {
|
|
2173
2173
|
const c = e[a];
|
|
2174
|
-
typeof c == "object" && c !== null && !(c instanceof Q) && !S.has(c) && (e[a] = Y(c, t, n, i,
|
|
2174
|
+
typeof c == "object" && c !== null && !(c instanceof Q) && !S.has(c) && (e[a] = Y(c, t, n, i, s, r));
|
|
2175
2175
|
}
|
|
2176
2176
|
return e;
|
|
2177
2177
|
}
|
|
@@ -2179,7 +2179,7 @@ function Y(e, t, n, i, r, s) {
|
|
|
2179
2179
|
const a = e;
|
|
2180
2180
|
for (const c of Object.keys(a)) {
|
|
2181
2181
|
const f = a[c];
|
|
2182
|
-
typeof f == "object" && f !== null && !(f instanceof Q) && !S.has(f) && (a[c] = Y(f, t, n, i,
|
|
2182
|
+
typeof f == "object" && f !== null && !(f instanceof Q) && !S.has(f) && (a[c] = Y(f, t, n, i, s, r));
|
|
2183
2183
|
}
|
|
2184
2184
|
}
|
|
2185
2185
|
return e;
|
|
@@ -2187,21 +2187,21 @@ function Y(e, t, n, i, r, s) {
|
|
|
2187
2187
|
function me(e) {
|
|
2188
2188
|
return typeof e == "object" && e !== null && !(e instanceof Q) && !S.has(e);
|
|
2189
2189
|
}
|
|
2190
|
-
function Rn(e, t, n, i,
|
|
2191
|
-
const { key: o, data: a, shape: c, rawKeys: f } = e,
|
|
2190
|
+
function Rn(e, t, n, i, s, r) {
|
|
2191
|
+
const { key: o, data: a, shape: c, rawKeys: f } = e, h = c.shape, u = n.prepareEntity(o, a, c), l = u.data, g = l !== a, p = g && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2192
2192
|
if (g ? (ve(
|
|
2193
|
-
d,
|
|
2194
|
-
a,
|
|
2195
2193
|
h,
|
|
2194
|
+
a,
|
|
2195
|
+
l,
|
|
2196
2196
|
f,
|
|
2197
2197
|
u,
|
|
2198
|
-
|
|
2198
|
+
l,
|
|
2199
2199
|
t,
|
|
2200
2200
|
n,
|
|
2201
2201
|
i,
|
|
2202
2202
|
p,
|
|
2203
|
-
|
|
2204
|
-
), u.notify()) : _e(
|
|
2203
|
+
r
|
|
2204
|
+
), u.notify()) : _e(h, a, u, a, t, n, i, p, r), r && u.liveCollections.length > 0)
|
|
2205
2205
|
for (const v of u.liveCollections) {
|
|
2206
2206
|
const O = v.instance.getRawValue();
|
|
2207
2207
|
if (Array.isArray(O))
|
|
@@ -2215,37 +2215,37 @@ function Rn(e, t, n, i, r, s) {
|
|
|
2215
2215
|
}
|
|
2216
2216
|
u.setChildRefs(p.size > 0 ? p : void 0, i);
|
|
2217
2217
|
const w = u.getProxy(c);
|
|
2218
|
-
return
|
|
2218
|
+
return s.set(u, (s.get(u) ?? 0) + 1), w;
|
|
2219
2219
|
}
|
|
2220
|
-
function ve(e, t, n, i,
|
|
2221
|
-
for (const [u,
|
|
2220
|
+
function ve(e, t, n, i, s, r, o, a, c, f, h) {
|
|
2221
|
+
for (const [u, l] of pe(e))
|
|
2222
2222
|
if (!(i !== void 0 && !i.has(u)))
|
|
2223
|
-
if (me(t[u]) && (t[u] = Y(t[u], o, a, c, f,
|
|
2223
|
+
if (me(t[u]) && (t[u] = Y(t[u], o, a, c, f, h)), l instanceof m && l._liveConfig !== void 0) {
|
|
2224
2224
|
const g = n[u];
|
|
2225
|
-
g instanceof
|
|
2226
|
-
|
|
2225
|
+
g instanceof le ? h ? g.append(t[u]) : g.reset(t[u]) : n[u] = ye(
|
|
2226
|
+
l._liveConfig,
|
|
2227
2227
|
t[u],
|
|
2228
|
-
r,
|
|
2229
2228
|
s,
|
|
2229
|
+
r,
|
|
2230
2230
|
a
|
|
2231
2231
|
);
|
|
2232
2232
|
} else {
|
|
2233
2233
|
const g = t[u], p = n[u];
|
|
2234
2234
|
if (ct(g) && ct(p)) {
|
|
2235
|
-
const w =
|
|
2235
|
+
const w = l instanceof m && l.shape !== void 0 ? l.shape : void 0;
|
|
2236
2236
|
if (w !== void 0)
|
|
2237
2237
|
ve(
|
|
2238
2238
|
w,
|
|
2239
2239
|
g,
|
|
2240
2240
|
p,
|
|
2241
2241
|
void 0,
|
|
2242
|
-
r,
|
|
2243
2242
|
s,
|
|
2243
|
+
r,
|
|
2244
2244
|
o,
|
|
2245
2245
|
a,
|
|
2246
2246
|
c,
|
|
2247
2247
|
f,
|
|
2248
|
-
|
|
2248
|
+
h
|
|
2249
2249
|
);
|
|
2250
2250
|
else
|
|
2251
2251
|
for (const v of Object.keys(g))
|
|
@@ -2255,22 +2255,22 @@ function ve(e, t, n, i, r, s, o, a, c, f, d) {
|
|
|
2255
2255
|
n[u] = g;
|
|
2256
2256
|
}
|
|
2257
2257
|
}
|
|
2258
|
-
function _e(e, t, n, i,
|
|
2259
|
-
for (const [f,
|
|
2258
|
+
function _e(e, t, n, i, s, r, o, a, c) {
|
|
2259
|
+
for (const [f, h] of pe(e))
|
|
2260
2260
|
if (f in t)
|
|
2261
|
-
if (me(t[f]) && (t[f] = Y(t[f],
|
|
2261
|
+
if (me(t[f]) && (t[f] = Y(t[f], s, r, o, a, c)), h instanceof m && h._liveConfig !== void 0)
|
|
2262
2262
|
t[f] = ye(
|
|
2263
|
-
|
|
2263
|
+
h._liveConfig,
|
|
2264
2264
|
t[f],
|
|
2265
2265
|
n,
|
|
2266
2266
|
i,
|
|
2267
|
-
|
|
2267
|
+
r
|
|
2268
2268
|
);
|
|
2269
2269
|
else {
|
|
2270
2270
|
const u = t[f];
|
|
2271
2271
|
if (ct(u)) {
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2272
|
+
const l = h instanceof m && h.shape !== void 0 ? h.shape : void 0;
|
|
2273
|
+
l !== void 0 && _e(l, u, n, i, s, r, o, a, c);
|
|
2274
2274
|
}
|
|
2275
2275
|
}
|
|
2276
2276
|
}
|
|
@@ -2306,46 +2306,46 @@ class Un {
|
|
|
2306
2306
|
typenameRegistry = /* @__PURE__ */ new Map();
|
|
2307
2307
|
constraintRegistry = /* @__PURE__ */ new Map();
|
|
2308
2308
|
mergedDefCache = /* @__PURE__ */ new Map();
|
|
2309
|
-
|
|
2309
|
+
adapters = /* @__PURE__ */ new Map();
|
|
2310
2310
|
networkUnsubscribe;
|
|
2311
2311
|
constructor(t = {}) {
|
|
2312
2312
|
const {
|
|
2313
2313
|
store: n = new Ae(new Ne()),
|
|
2314
2314
|
log: i,
|
|
2315
|
-
evictionMultiplier:
|
|
2316
|
-
|
|
2315
|
+
evictionMultiplier: s,
|
|
2316
|
+
adapters: r,
|
|
2317
2317
|
networkManager: o,
|
|
2318
2318
|
gcManager: a,
|
|
2319
2319
|
...c
|
|
2320
2320
|
} = t;
|
|
2321
|
-
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier:
|
|
2322
|
-
for (const u of t.
|
|
2323
|
-
this.
|
|
2324
|
-
const f = this.networkManager.getOnlineSignal(),
|
|
2325
|
-
this.networkUnsubscribe =
|
|
2321
|
+
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: s }, this.gcManager = t.gcManager ?? (this.isServer ? new Fe() : new De(this.handleEviction, s)), this.networkManager = t.networkManager ?? new ae(), this.entityMap = new yn((u, l, g) => this.store.saveEntity(u, l, g));
|
|
2322
|
+
for (const u of t.adapters ?? [])
|
|
2323
|
+
this.adapters.set(u.constructor, u), u.register(this);
|
|
2324
|
+
const f = this.networkManager.getOnlineSignal(), h = Re(() => f.value);
|
|
2325
|
+
this.networkUnsubscribe = h.addListener(
|
|
2326
2326
|
() => {
|
|
2327
2327
|
const u = f.value;
|
|
2328
|
-
for (const
|
|
2329
|
-
|
|
2328
|
+
for (const l of this.adapters.values())
|
|
2329
|
+
l.onNetworkStatusChange?.(u);
|
|
2330
2330
|
},
|
|
2331
2331
|
{ skipInitial: !0 }
|
|
2332
2332
|
), this.store.purgeStaleQueries?.();
|
|
2333
2333
|
}
|
|
2334
2334
|
/**
|
|
2335
|
-
* Returns the registered
|
|
2336
|
-
* Throws if no
|
|
2335
|
+
* Returns the registered adapter instance for the given adapter class.
|
|
2336
|
+
* Throws if no adapter of that class has been registered.
|
|
2337
2337
|
*/
|
|
2338
|
-
|
|
2339
|
-
let n = this.
|
|
2338
|
+
getAdapter(t) {
|
|
2339
|
+
let n = this.adapters.get(t);
|
|
2340
2340
|
if (!n) {
|
|
2341
2341
|
try {
|
|
2342
2342
|
n = new t();
|
|
2343
2343
|
} catch {
|
|
2344
2344
|
throw new Error(
|
|
2345
|
-
`No
|
|
2345
|
+
`No adapter registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, adapters: [new ${t.name}(...)] })`
|
|
2346
2346
|
);
|
|
2347
2347
|
}
|
|
2348
|
-
this.
|
|
2348
|
+
this.adapters.set(t, n), n.register(this);
|
|
2349
2349
|
}
|
|
2350
2350
|
return n;
|
|
2351
2351
|
}
|
|
@@ -2375,14 +2375,14 @@ class Un {
|
|
|
2375
2375
|
if (i !== void 0)
|
|
2376
2376
|
return n = m.merge(i), this.mergedDefCache.set(t, n), n;
|
|
2377
2377
|
}
|
|
2378
|
-
saveQueryData(t, n, i,
|
|
2379
|
-
const o =
|
|
2380
|
-
this.store.saveQuery(t, n, i,
|
|
2378
|
+
saveQueryData(t, n, i, s, r) {
|
|
2379
|
+
const o = r !== void 0 && r.size > 0 ? new Set([...r.keys()].map((a) => a.key)) : void 0;
|
|
2380
|
+
this.store.saveQuery(t, n, i, s, o);
|
|
2381
2381
|
}
|
|
2382
2382
|
activateQuery(t) {
|
|
2383
|
-
const { def: n, queryKey: i, storageKey:
|
|
2384
|
-
this.store.activateQuery(n,
|
|
2385
|
-
const o =
|
|
2383
|
+
const { def: n, queryKey: i, storageKey: s, config: r } = t;
|
|
2384
|
+
this.store.activateQuery(n, s);
|
|
2385
|
+
const o = r?.gcTime ?? $t;
|
|
2386
2386
|
this.gcManager.cancel(i, o);
|
|
2387
2387
|
}
|
|
2388
2388
|
loadCachedQuery(t, n) {
|
|
@@ -2394,8 +2394,8 @@ class Un {
|
|
|
2394
2394
|
*/
|
|
2395
2395
|
getQuery(t, n) {
|
|
2396
2396
|
const i = wt(t, n);
|
|
2397
|
-
let
|
|
2398
|
-
return
|
|
2397
|
+
let s = this.queryInstances.get(i);
|
|
2398
|
+
return s === void 0 && (s = new gn(t, this, i, n), this.queryInstances.set(i, s)), s.relay;
|
|
2399
2399
|
}
|
|
2400
2400
|
/**
|
|
2401
2401
|
* Gets or creates a MutationResult for the given mutation definition.
|
|
@@ -2411,9 +2411,9 @@ class Un {
|
|
|
2411
2411
|
* Does NOT touch the entity store. Call applyRefs() after to commit entities.
|
|
2412
2412
|
*/
|
|
2413
2413
|
parseData(t, n, i) {
|
|
2414
|
-
const
|
|
2415
|
-
}),
|
|
2416
|
-
return
|
|
2414
|
+
const s = this.context.log?.warn ?? (() => {
|
|
2415
|
+
}), r = new ot();
|
|
2416
|
+
return r.reset(this, i, s), { data: ie(t, n, r), ctx: r };
|
|
2417
2417
|
}
|
|
2418
2418
|
/**
|
|
2419
2419
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
@@ -2428,9 +2428,9 @@ class Un {
|
|
|
2428
2428
|
* QUERY_ID onto the payload. Returns the root EntityInstance (created or
|
|
2429
2429
|
* found in the store by the standard entity pipeline).
|
|
2430
2430
|
*/
|
|
2431
|
-
parseAndApplyRootEntity(t, n, i,
|
|
2431
|
+
parseAndApplyRootEntity(t, n, i, s, r = !1, o) {
|
|
2432
2432
|
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Lt] = n);
|
|
2433
|
-
const a = this.parseData(t, i, o), c = nt(a.ctx, a.data,
|
|
2433
|
+
const a = this.parseData(t, i, o), c = nt(a.ctx, a.data, s, r), f = S.get(c.data);
|
|
2434
2434
|
return this.entityMap.getEntity(f);
|
|
2435
2435
|
}
|
|
2436
2436
|
prepareEntity(t, n, i) {
|
|
@@ -2440,15 +2440,15 @@ class Un {
|
|
|
2440
2440
|
// Mutation Events
|
|
2441
2441
|
// ======================================================
|
|
2442
2442
|
applyMutationEvent(t) {
|
|
2443
|
-
const { type: n, typename: i } = t,
|
|
2444
|
-
if (
|
|
2445
|
-
const
|
|
2446
|
-
if (
|
|
2447
|
-
const o = t.data, a = t.id !== void 0 ? t.id : n === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[
|
|
2443
|
+
const { type: n, typename: i } = t, s = this.getMergedDef(i);
|
|
2444
|
+
if (s === void 0) return;
|
|
2445
|
+
const r = s.idField;
|
|
2446
|
+
if (r === void 0 || typeof r == "symbol") return;
|
|
2447
|
+
const o = t.data, a = t.id !== void 0 ? t.id : n === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[r];
|
|
2448
2448
|
if (a === void 0) return;
|
|
2449
|
-
const c = N([i, a]), f = t.__eventSource,
|
|
2449
|
+
const c = N([i, a]), f = t.__eventSource, h = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2450
2450
|
if (n === "delete") {
|
|
2451
|
-
const w = u !== void 0 ? u.data :
|
|
2451
|
+
const w = u !== void 0 ? u.data : h;
|
|
2452
2452
|
this.routeEvent(i, w, c, n, f, void 0, w);
|
|
2453
2453
|
return;
|
|
2454
2454
|
}
|
|
@@ -2462,7 +2462,7 @@ class Un {
|
|
|
2462
2462
|
/* isPartialEvent */
|
|
2463
2463
|
!0
|
|
2464
2464
|
);
|
|
2465
|
-
const O =
|
|
2465
|
+
const O = sn(h, s, v);
|
|
2466
2466
|
nt(v, O, !0);
|
|
2467
2467
|
} catch (w) {
|
|
2468
2468
|
if (this.context.log?.warn?.("Failed to apply mutation event", w), u === void 0) {
|
|
@@ -2471,23 +2471,23 @@ class Un {
|
|
|
2471
2471
|
}
|
|
2472
2472
|
return;
|
|
2473
2473
|
}
|
|
2474
|
-
const
|
|
2475
|
-
if (
|
|
2476
|
-
this.entityMap.save(
|
|
2474
|
+
const l = this.entityMap.getEntity(c);
|
|
2475
|
+
if (l === void 0) return;
|
|
2476
|
+
this.entityMap.save(l);
|
|
2477
2477
|
const g = u === void 0;
|
|
2478
2478
|
let p = !1;
|
|
2479
|
-
this.routeEvent(i,
|
|
2479
|
+
this.routeEvent(i, l.data, c, n, f, () => {
|
|
2480
2480
|
p = !0;
|
|
2481
|
-
}), g && !p &&
|
|
2481
|
+
}), g && !p && l.evict();
|
|
2482
2482
|
}
|
|
2483
2483
|
// ======================================================
|
|
2484
2484
|
// Query Invalidation
|
|
2485
2485
|
// ======================================================
|
|
2486
2486
|
invalidateQueries(t) {
|
|
2487
2487
|
for (const n of t) {
|
|
2488
|
-
const i = Array.isArray(n),
|
|
2488
|
+
const i = Array.isArray(n), s = i ? n[0] : n, r = i ? n[1] : void 0, a = G.for(s).statics.id;
|
|
2489
2489
|
for (const [, c] of this.queryInstances)
|
|
2490
|
-
c.def.statics.id === a && (
|
|
2490
|
+
c.def.statics.id === a && (r === void 0 || Nn(c.resolvedParams, r)) && c.markStale();
|
|
2491
2491
|
}
|
|
2492
2492
|
}
|
|
2493
2493
|
// ======================================================
|
|
@@ -2495,9 +2495,9 @@ class Un {
|
|
|
2495
2495
|
// ======================================================
|
|
2496
2496
|
handleEviction = (t, n) => {
|
|
2497
2497
|
if (n === X.Query) {
|
|
2498
|
-
const
|
|
2499
|
-
if (
|
|
2500
|
-
|
|
2498
|
+
const s = this.queryInstances.get(t);
|
|
2499
|
+
if (s === void 0) return;
|
|
2500
|
+
s.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
2501
2501
|
return;
|
|
2502
2502
|
}
|
|
2503
2503
|
const i = this.entityMap.getEntity(t);
|
|
@@ -2520,17 +2520,17 @@ class Un {
|
|
|
2520
2520
|
i !== void 0 && i.unregisterBinding(t, n);
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
|
-
routeEvent(t, n, i,
|
|
2523
|
+
routeEvent(t, n, i, s, r, o, a) {
|
|
2524
2524
|
const c = this.constraintRegistry.get(t);
|
|
2525
2525
|
if (c === void 0) return;
|
|
2526
|
-
const f =
|
|
2527
|
-
c.routeEvent(t, f, i,
|
|
2526
|
+
const f = r !== void 0 ? { ...n, [ue]: r } : n;
|
|
2527
|
+
c.routeEvent(t, f, i, s, o, a);
|
|
2528
2528
|
}
|
|
2529
2529
|
destroy() {
|
|
2530
2530
|
this.networkUnsubscribe?.(), this.gcManager.destroy(), this.networkManager.destroy();
|
|
2531
|
-
for (const t of this.
|
|
2531
|
+
for (const t of this.adapters.values())
|
|
2532
2532
|
t.destroy?.();
|
|
2533
|
-
this.
|
|
2533
|
+
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2534
2534
|
}
|
|
2535
2535
|
}
|
|
2536
2536
|
const An = jt(void 0);
|
|
@@ -2545,7 +2545,7 @@ export {
|
|
|
2545
2545
|
Bt as E,
|
|
2546
2546
|
De as G,
|
|
2547
2547
|
B as L,
|
|
2548
|
-
|
|
2548
|
+
d as M,
|
|
2549
2549
|
ae as N,
|
|
2550
2550
|
Lt as Q,
|
|
2551
2551
|
F as R,
|
|
@@ -2569,4 +2569,4 @@ export {
|
|
|
2569
2569
|
Zt as r,
|
|
2570
2570
|
en as t
|
|
2571
2571
|
};
|
|
2572
|
-
//# sourceMappingURL=QueryClient-
|
|
2572
|
+
//# sourceMappingURL=QueryClient-BajBmpnA.js.map
|