fetchium 0.1.0 → 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 +12 -5
- 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/index.js.map +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 +2 -0
- package/dist/cjs/development/rest/index.js.map +1 -0
- package/dist/cjs/development/topic/index.js +2 -0
- package/dist/cjs/development/topic/index.js.map +1 -0
- 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/index.js.map +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 +2 -0
- package/dist/cjs/production/rest/index.js.map +1 -0
- package/dist/cjs/production/topic/index.js +2 -0
- package/dist/cjs/production/topic/index.js.map +1 -0
- package/dist/esm/MutationResult.d.ts +0 -1
- package/dist/esm/MutationResult.d.ts.map +1 -1
- package/dist/esm/QueryAdapter.d.ts +49 -0
- package/dist/esm/QueryAdapter.d.ts.map +1 -0
- package/dist/esm/QueryClient.d.ts +26 -4
- package/dist/esm/QueryClient.d.ts.map +1 -1
- package/dist/esm/QueryResult.d.ts +11 -11
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/QueryAdapter-Bu5UJjE4.js +14 -0
- package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -0
- package/dist/esm/development/QueryClient-BajBmpnA.js +2572 -0
- package/dist/esm/development/QueryClient-BajBmpnA.js.map +1 -0
- package/dist/esm/development/index.js +29 -100
- package/dist/esm/development/index.js.map +1 -1
- package/dist/esm/development/mutation-DAOZE4Ok.js +58 -0
- 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 +142 -0
- package/dist/esm/development/rest/index.js.map +1 -0
- package/dist/esm/development/{shared-Dq2yW78d.js → shared-DcuVH8Pf.js} +5 -5
- package/dist/esm/development/{shared-Dq2yW78d.js.map → shared-DcuVH8Pf.js.map} +1 -1
- package/dist/esm/development/stores/async.js +6 -6
- package/dist/esm/development/stores/sync.js +5 -5
- package/dist/esm/development/topic/index.js +86 -0
- package/dist/esm/development/topic/index.js.map +1 -0
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/mutation.d.ts +6 -19
- package/dist/esm/mutation.d.ts.map +1 -1
- package/dist/esm/production/QueryAdapter-Bu5UJjE4.js +14 -0
- package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -0
- package/dist/esm/production/{QueryClient-BP0Z1rQV.js → QueryClient-KH0Ex_8m.js} +595 -591
- package/dist/esm/production/QueryClient-KH0Ex_8m.js.map +1 -0
- package/dist/esm/production/index.js +29 -100
- package/dist/esm/production/index.js.map +1 -1
- package/dist/esm/production/mutation-C7BOChR2.js +58 -0
- 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 +142 -0
- package/dist/esm/production/rest/index.js.map +1 -0
- package/dist/esm/production/{shared-Dq2yW78d.js → shared-DcuVH8Pf.js} +5 -5
- package/dist/esm/production/{shared-Dq2yW78d.js.map → shared-DcuVH8Pf.js.map} +1 -1
- package/dist/esm/production/stores/async.js +6 -6
- package/dist/esm/production/stores/sync.js +5 -5
- package/dist/esm/production/topic/index.js +86 -0
- package/dist/esm/production/topic/index.js.map +1 -0
- package/dist/esm/query-types.d.ts +2 -4
- package/dist/esm/query-types.d.ts.map +1 -1
- package/dist/esm/query.d.ts +17 -39
- package/dist/esm/query.d.ts.map +1 -1
- package/dist/esm/rest/RESTMutation.d.ts +18 -0
- package/dist/esm/rest/RESTMutation.d.ts.map +1 -0
- package/dist/esm/rest/RESTQuery.d.ts +24 -0
- package/dist/esm/rest/RESTQuery.d.ts.map +1 -0
- package/dist/esm/rest/RESTQueryAdapter.d.ts +34 -0
- package/dist/esm/rest/RESTQueryAdapter.d.ts.map +1 -0
- package/dist/esm/rest/index.d.ts +5 -0
- package/dist/esm/rest/index.d.ts.map +1 -0
- package/dist/esm/stores/shared.d.ts.map +1 -1
- package/dist/esm/testing/MockClient.d.ts +64 -0
- package/dist/esm/testing/MockClient.d.ts.map +1 -0
- package/dist/esm/testing/auto-generate.d.ts +20 -0
- package/dist/esm/testing/auto-generate.d.ts.map +1 -0
- package/dist/esm/testing/entity-factory.d.ts +13 -0
- package/dist/esm/testing/entity-factory.d.ts.map +1 -0
- package/dist/esm/testing/index.d.ts +6 -0
- package/dist/esm/testing/index.d.ts.map +1 -0
- package/dist/esm/testing/types.d.ts +37 -0
- package/dist/esm/testing/types.d.ts.map +1 -0
- package/dist/esm/topic/TopicQuery.d.ts +10 -0
- package/dist/esm/topic/TopicQuery.d.ts.map +1 -0
- package/dist/esm/topic/TopicQueryAdapter.d.ts +43 -0
- package/dist/esm/topic/TopicQueryAdapter.d.ts.map +1 -0
- package/dist/esm/topic/index.d.ts +3 -0
- package/dist/esm/topic/index.d.ts.map +1 -0
- package/dist/esm/typeDefs.d.ts +1 -1
- package/dist/esm/types.d.ts +9 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +51 -4
- package/plugin/.claude-plugin/plugin.json +10 -0
- package/plugin/agents/fetchium.md +168 -0
- package/plugin/docs/api/fetchium-react.md +135 -0
- package/plugin/docs/api/fetchium.md +674 -0
- package/plugin/docs/api/stores-async.md +219 -0
- package/plugin/docs/api/stores-sync.md +133 -0
- package/plugin/docs/core/entities.md +351 -0
- package/plugin/docs/core/queries.md +600 -0
- package/plugin/docs/core/streaming.md +550 -0
- package/plugin/docs/core/types.md +374 -0
- package/plugin/docs/data/caching.md +298 -0
- package/plugin/docs/data/live-data.md +435 -0
- package/plugin/docs/data/mutations.md +465 -0
- package/plugin/docs/guides/auth.md +318 -0
- package/plugin/docs/guides/error-handling.md +351 -0
- package/plugin/docs/guides/offline.md +270 -0
- package/plugin/docs/guides/testing.md +301 -0
- package/plugin/docs/quickstart.md +170 -0
- package/plugin/docs/reference/pagination.md +519 -0
- package/plugin/docs/reference/rest-queries.md +107 -0
- package/plugin/docs/reference/why-signalium.md +364 -0
- package/plugin/docs/setup/project-setup.md +319 -0
- package/plugin/install.mjs +88 -0
- package/plugin/skills/design/SKILL.md +140 -0
- package/plugin/skills/teach/SKILL.md +105 -0
- package/dist/cjs/development/QueryClient-CpmwggOn.js +0 -2
- package/dist/cjs/development/QueryClient-CpmwggOn.js.map +0 -1
- package/dist/cjs/production/QueryClient-qi3bR0eD.js +0 -2
- package/dist/cjs/production/QueryClient-qi3bR0eD.js.map +0 -1
- package/dist/esm/development/QueryClient-DRZtPKFD.js +0 -2568
- package/dist/esm/development/QueryClient-DRZtPKFD.js.map +0 -1
- package/dist/esm/production/QueryClient-BP0Z1rQV.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { notifier as at, relay as It, setScopeOwner as
|
|
2
|
-
import { registerCustomHash as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { notifier as at, relay as It, setScopeOwner as ye, reactiveMethod as pe, signal as Nt, context as Mt, getContext as ge, task as ve, reactiveSignal as _e, isSignal as me, watcher as we } from "signalium";
|
|
2
|
+
import { registerCustomHash as Ee, hashValue as D } from "signalium/utils";
|
|
3
|
+
import { d as kt } from "./shared-DcuVH8Pf.js";
|
|
4
|
+
import { SyncQueryStore as be, MemoryPersistentStore as Ce } from "./stores/sync.js";
|
|
5
|
+
var L = /* @__PURE__ */ ((i) => (i.Always = "always", i.Online = "online", i.OfflineFirst = "offlineFirst", i))(L || {}), d = /* @__PURE__ */ ((i) => (i[i.UNDEFINED = 1] = "UNDEFINED", i[i.NULL = 2] = "NULL", i[i.NUMBER = 4] = "NUMBER", i[i.STRING = 8] = "STRING", i[i.BOOLEAN = 16] = "BOOLEAN", i[i.OBJECT = 32] = "OBJECT", i[i.ARRAY = 64] = "ARRAY", i[i.ID = 128] = "ID", i[i.RECORD = 256] = "RECORD", i[i.UNION = 512] = "UNION", i[i.ENTITY = 1024] = "ENTITY", i[i.HAS_FORMAT = 4096] = "HAS_FORMAT", i[i.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", i[i.PARSE_RESULT = 16384] = "PARSE_RESULT", i[i.LIVE = 32768] = "LIVE", i))(d || {});
|
|
6
|
+
const Q = /* @__PURE__ */ Symbol("array"), B = /* @__PURE__ */ Symbol("record"), Ft = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
6
7
|
var ct = /* @__PURE__ */ ((i) => (i[i.Array = 0] = "Array", i[i.Value = 1] = "Value", i))(ct || {});
|
|
7
|
-
class
|
|
8
|
+
class j {
|
|
8
9
|
type;
|
|
9
10
|
entityDefs;
|
|
10
11
|
constraintFieldRefs;
|
|
@@ -17,7 +18,7 @@ class U {
|
|
|
17
18
|
this.type = t, this.entityDefs = e, this.constraintFieldRefs = n, this.sort = s, this.valueType = r, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
|
|
18
19
|
}
|
|
19
20
|
static array(t, e, n) {
|
|
20
|
-
return new
|
|
21
|
+
return new j(
|
|
21
22
|
0,
|
|
22
23
|
t,
|
|
23
24
|
e,
|
|
@@ -29,7 +30,7 @@ class U {
|
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
static value(t, e, n, s, r, o) {
|
|
32
|
-
return new
|
|
33
|
+
return new j(
|
|
33
34
|
1,
|
|
34
35
|
t,
|
|
35
36
|
e,
|
|
@@ -41,12 +42,12 @@ class U {
|
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
const
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function k(i) {
|
|
47
|
+
return x.get(i);
|
|
47
48
|
}
|
|
48
|
-
var
|
|
49
|
-
class
|
|
49
|
+
var z = /* @__PURE__ */ ((i) => (i[i.Query = 0] = "Query", i[i.Entity = 1] = "Entity", i))(z || {});
|
|
50
|
+
class xe {
|
|
50
51
|
constructor(t, e, n) {
|
|
51
52
|
this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 * n);
|
|
52
53
|
}
|
|
@@ -69,7 +70,7 @@ class be {
|
|
|
69
70
|
clearInterval(this._intervalId);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
class
|
|
73
|
+
class Oe {
|
|
73
74
|
_buckets = /* @__PURE__ */ new Map();
|
|
74
75
|
_nextTickEntries = /* @__PURE__ */ new Map();
|
|
75
76
|
_nextTickScheduled = !1;
|
|
@@ -87,7 +88,7 @@ class Ce {
|
|
|
87
88
|
}
|
|
88
89
|
const { _buckets: s } = this;
|
|
89
90
|
let r = s.get(e);
|
|
90
|
-
r || (r = new
|
|
91
|
+
r || (r = new xe(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t, n);
|
|
91
92
|
}
|
|
92
93
|
cancel(t, e) {
|
|
93
94
|
if (e !== 1 / 0) {
|
|
@@ -112,7 +113,7 @@ class Ce {
|
|
|
112
113
|
t.clear(), e.clear();
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
class
|
|
116
|
+
class Re {
|
|
116
117
|
schedule(t, e, n) {
|
|
117
118
|
}
|
|
118
119
|
cancel(t, e) {
|
|
@@ -120,48 +121,48 @@ class xe {
|
|
|
120
121
|
destroy() {
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
const Y = /* @__PURE__ */ Symbol("fieldRef"),
|
|
124
|
-
function
|
|
124
|
+
const Y = /* @__PURE__ */ Symbol("fieldRef"), N = /* @__PURE__ */ Symbol("fieldRefPath"), ft = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Se = /\[([^\]]+)\]/g;
|
|
125
|
+
function Tt(i) {
|
|
125
126
|
const t = {
|
|
126
127
|
[Y]: !0,
|
|
127
|
-
[
|
|
128
|
+
[N]: i
|
|
128
129
|
};
|
|
129
|
-
return new Proxy(t,
|
|
130
|
+
return new Proxy(t, Ae);
|
|
130
131
|
}
|
|
131
|
-
const
|
|
132
|
+
const Ae = {
|
|
132
133
|
get(i, t) {
|
|
133
134
|
if (t === Y) return !0;
|
|
134
|
-
if (t ===
|
|
135
|
+
if (t === N) return i[N];
|
|
135
136
|
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
|
|
136
|
-
const n = i[
|
|
137
|
+
const n = i[N];
|
|
137
138
|
return () => `[${n.join(".")}]`;
|
|
138
139
|
}
|
|
139
140
|
if (typeof t == "symbol") return;
|
|
140
|
-
const e = i[
|
|
141
|
-
return
|
|
141
|
+
const e = i[N];
|
|
142
|
+
return Tt([...e, t]);
|
|
142
143
|
},
|
|
143
144
|
has(i, t) {
|
|
144
|
-
return t === Y || t ===
|
|
145
|
+
return t === Y || t === N;
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
|
-
function
|
|
148
|
+
function Pt(i) {
|
|
148
149
|
return typeof i == "object" && i !== null && i[Y] === !0;
|
|
149
150
|
}
|
|
150
|
-
function
|
|
151
|
-
return i[
|
|
151
|
+
function Lt(i) {
|
|
152
|
+
return i[N];
|
|
152
153
|
}
|
|
153
|
-
function
|
|
154
|
+
function jt(i) {
|
|
154
155
|
return new Proxy(i, {
|
|
155
156
|
set(t, e, n) {
|
|
156
157
|
return t[e] = n, !0;
|
|
157
158
|
},
|
|
158
159
|
get(t, e) {
|
|
159
160
|
return e === ft ? t : e === G ? () => {
|
|
160
|
-
} : typeof e == "symbol" ? t[e] :
|
|
161
|
+
} : typeof e == "symbol" ? t[e] : Tt([e]);
|
|
161
162
|
}
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
+
function De(i) {
|
|
165
166
|
const t = i[ft];
|
|
166
167
|
i[G]();
|
|
167
168
|
const e = {};
|
|
@@ -187,23 +188,23 @@ function ut(i, t) {
|
|
|
187
188
|
}
|
|
188
189
|
return e;
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
-
return i.replace(
|
|
191
|
+
function Ie(i, t) {
|
|
192
|
+
return i.replace(Se, (e, n) => {
|
|
192
193
|
const s = n.split("."), r = ut(s, t);
|
|
193
194
|
return r != null ? encodeURIComponent(String(r)) : "";
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
-
if (
|
|
198
|
-
return ut(
|
|
197
|
+
function W(i, t) {
|
|
198
|
+
if (Pt(i))
|
|
199
|
+
return ut(Lt(i), t);
|
|
199
200
|
if (typeof i == "string")
|
|
200
|
-
return
|
|
201
|
+
return Ie(i, t);
|
|
201
202
|
if (Array.isArray(i))
|
|
202
|
-
return i.map((e) =>
|
|
203
|
+
return i.map((e) => W(e, t));
|
|
203
204
|
if (typeof i == "object" && i !== null && Object.getPrototypeOf(i) === Object.prototype) {
|
|
204
205
|
const e = {};
|
|
205
206
|
for (const n of Object.keys(i))
|
|
206
|
-
e[n] =
|
|
207
|
+
e[n] = W(i[n], t);
|
|
207
208
|
return e;
|
|
208
209
|
}
|
|
209
210
|
return i;
|
|
@@ -211,26 +212,26 @@ function P(i, t) {
|
|
|
211
212
|
function et(i, t, e) {
|
|
212
213
|
const n = i.fields, s = i.methods, r = { params: t }, o = {};
|
|
213
214
|
for (const [a, c] of Object.entries(n))
|
|
214
|
-
o[a] =
|
|
215
|
+
o[a] = W(c, r);
|
|
215
216
|
o.params = t, o.context = e;
|
|
216
217
|
for (const [a, c] of Object.entries(s))
|
|
217
218
|
o[a] = c.bind(o);
|
|
218
219
|
return o;
|
|
219
220
|
}
|
|
220
|
-
class
|
|
221
|
+
class qt {
|
|
221
222
|
static cache;
|
|
222
223
|
constructor() {
|
|
223
|
-
return
|
|
224
|
+
return jt(this);
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
return typeof i == "number" ? i |
|
|
227
|
+
const Ut = Object.entries, it = Object.keys;
|
|
228
|
+
function wt(i) {
|
|
229
|
+
return typeof i == "number" ? i | d.UNDEFINED : i instanceof _ ? (i.mask & d.UNDEFINED) !== 0 ? i : _.cloneWith(i, d.UNDEFINED) : i;
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
-
return i instanceof _ && (i.mask &
|
|
231
|
+
function Ne(i) {
|
|
232
|
+
return i instanceof _ && (i.mask & d.OBJECT) !== 0 && (i.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
+
function Vt(i, t, e) {
|
|
234
235
|
const n = /* @__PURE__ */ new Set();
|
|
235
236
|
for (const r of i)
|
|
236
237
|
if (r !== void 0)
|
|
@@ -242,14 +243,14 @@ function Kt(i, t, e) {
|
|
|
242
243
|
const c = [];
|
|
243
244
|
let f = !0;
|
|
244
245
|
for (const l of i) {
|
|
245
|
-
const
|
|
246
|
-
|
|
246
|
+
const u = l?.[r];
|
|
247
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), Ne(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
247
248
|
}
|
|
248
249
|
if (f && o > 0) {
|
|
249
|
-
const l =
|
|
250
|
-
s[r] = o < t ?
|
|
250
|
+
const l = Vt(c, t), u = new _(d.OBJECT, l);
|
|
251
|
+
s[r] = o < t ? wt(u) : u;
|
|
251
252
|
} else
|
|
252
|
-
s[r] = o < t ?
|
|
253
|
+
s[r] = o < t ? wt(a) : a;
|
|
253
254
|
}
|
|
254
255
|
return s;
|
|
255
256
|
}
|
|
@@ -279,7 +280,7 @@ class _ {
|
|
|
279
280
|
*/
|
|
280
281
|
_entityCache = void 0;
|
|
281
282
|
/**
|
|
282
|
-
* Live
|
|
283
|
+
* Live data configuration (shared by LiveArray and LiveValue).
|
|
283
284
|
*/
|
|
284
285
|
_liveConfig = void 0;
|
|
285
286
|
constructor(t, e, n, s, r, o) {
|
|
@@ -289,7 +290,7 @@ class _ {
|
|
|
289
290
|
if (t.length === 1) return t[0];
|
|
290
291
|
const e = t.length, n = t.map((c) => c.shape);
|
|
291
292
|
t[0].typenameValue;
|
|
292
|
-
const s =
|
|
293
|
+
const s = Vt(n, e);
|
|
293
294
|
let r, o, a;
|
|
294
295
|
for (const c of t) {
|
|
295
296
|
if (r === void 0 && c.idField !== void 0)
|
|
@@ -301,7 +302,7 @@ class _ {
|
|
|
301
302
|
o === void 0 && (o = c.typenameField), a === void 0 && (a = c.typenameValue);
|
|
302
303
|
}
|
|
303
304
|
return new _(
|
|
304
|
-
|
|
305
|
+
d.ENTITY | d.OBJECT,
|
|
305
306
|
s,
|
|
306
307
|
void 0,
|
|
307
308
|
o,
|
|
@@ -356,31 +357,31 @@ class H extends Set {
|
|
|
356
357
|
return t;
|
|
357
358
|
}
|
|
358
359
|
}
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
let t =
|
|
360
|
+
const Me = 1128875347;
|
|
361
|
+
Ee(H, (i) => {
|
|
362
|
+
let t = Me;
|
|
362
363
|
for (const e of i)
|
|
363
|
-
t +=
|
|
364
|
+
t += D(e);
|
|
364
365
|
return t >>> 0;
|
|
365
366
|
});
|
|
366
367
|
function dt(i, t) {
|
|
367
368
|
return new _(i, t);
|
|
368
369
|
}
|
|
369
|
-
function
|
|
370
|
-
return dt(
|
|
370
|
+
function ke(i) {
|
|
371
|
+
return dt(d.ARRAY, i);
|
|
371
372
|
}
|
|
372
|
-
function
|
|
373
|
-
return dt(
|
|
373
|
+
function Fe(i) {
|
|
374
|
+
return dt(d.RECORD | d.OBJECT, i);
|
|
374
375
|
}
|
|
375
376
|
function Te(i) {
|
|
376
|
-
return dt(
|
|
377
|
+
return dt(d.PARSE_RESULT, i);
|
|
377
378
|
}
|
|
378
|
-
function
|
|
379
|
+
function Kt(i, t) {
|
|
379
380
|
let e = i, n, s, r;
|
|
380
|
-
for (const [o, a] of
|
|
381
|
+
for (const [o, a] of Ut(t))
|
|
381
382
|
switch (typeof a) {
|
|
382
383
|
case "number":
|
|
383
|
-
if ((a &
|
|
384
|
+
if ((a & d.ID) !== 0) {
|
|
384
385
|
if (n !== void 0)
|
|
385
386
|
throw new Error(`Duplicate id field: ${o}`);
|
|
386
387
|
n = o;
|
|
@@ -394,17 +395,17 @@ function $t(i, t) {
|
|
|
394
395
|
case "object":
|
|
395
396
|
if (a instanceof H || a instanceof Set)
|
|
396
397
|
break;
|
|
397
|
-
a.mask &
|
|
398
|
+
a.mask & d.LIVE && (e |= d.LIVE);
|
|
398
399
|
break;
|
|
399
400
|
}
|
|
400
401
|
return new _(e, t, void 0, s, r, n);
|
|
401
402
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
403
|
+
function Pe(i) {
|
|
404
|
+
return Kt(d.OBJECT, i);
|
|
404
405
|
}
|
|
405
|
-
function
|
|
406
|
+
function Et(i, t, e) {
|
|
406
407
|
const n = i.mask;
|
|
407
|
-
if ((n &
|
|
408
|
+
if ((n & d.UNION) !== 0) {
|
|
408
409
|
const s = i;
|
|
409
410
|
if (s.typenameField !== void 0) {
|
|
410
411
|
if (e !== void 0 && e !== s.typenameField)
|
|
@@ -415,7 +416,7 @@ function wt(i, t, e) {
|
|
|
415
416
|
}
|
|
416
417
|
const r = s.shape;
|
|
417
418
|
if (r !== void 0)
|
|
418
|
-
for (const o of [...it(r),
|
|
419
|
+
for (const o of [...it(r), Q, B]) {
|
|
419
420
|
const a = r[o];
|
|
420
421
|
if (t[o] !== void 0 && t[o] !== a)
|
|
421
422
|
throw new Error(
|
|
@@ -423,14 +424,14 @@ function wt(i, t, e) {
|
|
|
423
424
|
);
|
|
424
425
|
t[o] = a;
|
|
425
426
|
}
|
|
426
|
-
} else if ((n &
|
|
427
|
-
if (t[B] !== void 0)
|
|
428
|
-
throw new Error("Array shape already defined");
|
|
429
|
-
t[B] = i.shape;
|
|
430
|
-
} else if ((n & u.RECORD) !== 0) {
|
|
427
|
+
} else if ((n & d.ARRAY) !== 0) {
|
|
431
428
|
if (t[Q] !== void 0)
|
|
432
|
-
throw new Error("
|
|
429
|
+
throw new Error("Array shape already defined");
|
|
433
430
|
t[Q] = i.shape;
|
|
431
|
+
} else if ((n & d.RECORD) !== 0) {
|
|
432
|
+
if (t[B] !== void 0)
|
|
433
|
+
throw new Error("Record shape already defined");
|
|
434
|
+
t[B] = i.shape;
|
|
434
435
|
} else {
|
|
435
436
|
const s = i.typenameField, r = i.typenameValue;
|
|
436
437
|
if (r === void 0)
|
|
@@ -455,21 +456,21 @@ function lt(...i) {
|
|
|
455
456
|
if (r === void 0)
|
|
456
457
|
r = new Set(l);
|
|
457
458
|
else
|
|
458
|
-
for (const
|
|
459
|
-
r.add(
|
|
459
|
+
for (const u of l)
|
|
460
|
+
r.add(u);
|
|
460
461
|
continue;
|
|
461
462
|
}
|
|
462
463
|
if (n++, c |= l.mask, n === 1) {
|
|
463
464
|
s = l;
|
|
464
465
|
continue;
|
|
465
466
|
}
|
|
466
|
-
n === 2 && (o = /* @__PURE__ */ Object.create(null), a =
|
|
467
|
+
n === 2 && (o = /* @__PURE__ */ Object.create(null), a = Et(s, o, a)), a = Et(l, o, a);
|
|
467
468
|
}
|
|
468
469
|
if (n === 0)
|
|
469
|
-
return r === void 0 ? e : e === 0 ? r : new _(e |
|
|
470
|
+
return r === void 0 ? e : e === 0 ? r : new _(e | d.UNION, void 0, r);
|
|
470
471
|
if (n === 1)
|
|
471
472
|
return _.cloneWith(s, e);
|
|
472
|
-
const f = e | c |
|
|
473
|
+
const f = e | c | d.UNION;
|
|
473
474
|
return new _(f, o, r, a);
|
|
474
475
|
}
|
|
475
476
|
function ht(i, t, e) {
|
|
@@ -481,57 +482,57 @@ function ht(i, t, e) {
|
|
|
481
482
|
let s = e.get(n);
|
|
482
483
|
return s === void 0 && (s = _.cloneWith(n, t), e.set(n, s)), s;
|
|
483
484
|
}
|
|
484
|
-
const
|
|
485
|
-
function je(i) {
|
|
486
|
-
return ht(i, u.UNDEFINED | u.NULL, Le);
|
|
487
|
-
}
|
|
488
|
-
function qe(i) {
|
|
489
|
-
return ht(i, u.UNDEFINED, ke);
|
|
490
|
-
}
|
|
485
|
+
const Le = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap();
|
|
491
486
|
function Ue(i) {
|
|
492
|
-
return ht(i,
|
|
487
|
+
return ht(i, d.UNDEFINED | d.NULL, qe);
|
|
493
488
|
}
|
|
494
489
|
function Ve(i) {
|
|
495
|
-
return i;
|
|
490
|
+
return ht(i, d.UNDEFINED, Le);
|
|
496
491
|
}
|
|
497
492
|
function Ke(i) {
|
|
493
|
+
return ht(i, d.NULL, je);
|
|
494
|
+
}
|
|
495
|
+
function $e(i) {
|
|
496
|
+
return i;
|
|
497
|
+
}
|
|
498
|
+
function Qe(i) {
|
|
498
499
|
return /* @__PURE__ */ new Set([i]);
|
|
499
500
|
}
|
|
500
|
-
const
|
|
501
|
-
|
|
501
|
+
const $t = ((...i) => new Set(i));
|
|
502
|
+
$t.caseInsensitive = (...i) => new H(i);
|
|
502
503
|
const Qt = 16;
|
|
503
|
-
let
|
|
504
|
-
const nt = [],
|
|
505
|
-
class
|
|
504
|
+
let Be = 0;
|
|
505
|
+
const nt = [], Bt = [], Yt = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new WeakSet();
|
|
506
|
+
class q {
|
|
506
507
|
_raw;
|
|
507
508
|
_formatted;
|
|
508
509
|
_parsed;
|
|
509
510
|
_formatId;
|
|
510
511
|
constructor(t, e, n) {
|
|
511
|
-
this._raw = t, this._formatId = e, n ? (this._formatted = nt[e](t), this._parsed = !0) : this._parsed = !1,
|
|
512
|
+
this._raw = t, this._formatId = e, n ? (this._formatted = nt[e](t), this._parsed = !0) : this._parsed = !1, J.add(this);
|
|
512
513
|
}
|
|
513
514
|
getValue() {
|
|
514
515
|
return this._parsed || (this._formatted = nt[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
515
516
|
}
|
|
516
517
|
toJSON() {
|
|
517
|
-
return this._parsed ?
|
|
518
|
+
return this._parsed ? Bt[this._formatId](this._formatted) : this._raw;
|
|
518
519
|
}
|
|
519
520
|
}
|
|
520
|
-
function
|
|
521
|
-
const t =
|
|
521
|
+
function Ye(i) {
|
|
522
|
+
const t = Yt.get(i);
|
|
522
523
|
if (t === void 0)
|
|
523
524
|
throw new Error(`Format ${i} not registered`);
|
|
524
525
|
return t;
|
|
525
526
|
}
|
|
526
|
-
function
|
|
527
|
-
const r =
|
|
528
|
-
nt[r] = e,
|
|
529
|
-
const o = s?.eager ?? !0, c = r << Qt | t |
|
|
530
|
-
|
|
527
|
+
function Gt(i, t, e, n, s) {
|
|
528
|
+
const r = Be++;
|
|
529
|
+
nt[r] = e, Bt[r] = n;
|
|
530
|
+
const o = s?.eager ?? !0, c = r << Qt | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
531
|
+
Yt.set(i, c);
|
|
531
532
|
}
|
|
532
|
-
|
|
533
|
+
Gt(
|
|
533
534
|
"date",
|
|
534
|
-
|
|
535
|
+
d.STRING,
|
|
535
536
|
(i) => {
|
|
536
537
|
const t = i.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
537
538
|
if (!t)
|
|
@@ -546,9 +547,9 @@ Wt(
|
|
|
546
547
|
return `${t}-${e}-${n}`;
|
|
547
548
|
}
|
|
548
549
|
);
|
|
549
|
-
|
|
550
|
+
Gt(
|
|
550
551
|
"date-time",
|
|
551
|
-
|
|
552
|
+
d.STRING,
|
|
552
553
|
(i) => {
|
|
553
554
|
const t = new Date(i);
|
|
554
555
|
if (isNaN(t.getTime()))
|
|
@@ -558,42 +559,42 @@ Wt(
|
|
|
558
559
|
(i) => i.toISOString()
|
|
559
560
|
);
|
|
560
561
|
const bt = /* @__PURE__ */ new WeakMap();
|
|
561
|
-
function
|
|
562
|
+
function T(i) {
|
|
562
563
|
let t = bt.get(i);
|
|
563
564
|
if (t === void 0) {
|
|
564
565
|
const e = new i(), n = e[ft] ?? e;
|
|
565
566
|
e[G] && e[G]();
|
|
566
567
|
const s = {};
|
|
567
|
-
for (const [f, l] of
|
|
568
|
+
for (const [f, l] of Ut(n))
|
|
568
569
|
s[f] = l;
|
|
569
570
|
const r = Object.getPrototypeOf(i.prototype);
|
|
570
571
|
if (r != null) {
|
|
571
572
|
const f = r.constructor;
|
|
572
|
-
if (f !==
|
|
573
|
-
const
|
|
574
|
-
for (const y of it(
|
|
575
|
-
if (y in s && s[y] !==
|
|
573
|
+
if (f !== qt && typeof f == "function") {
|
|
574
|
+
const u = T(f).shape;
|
|
575
|
+
for (const y of it(u))
|
|
576
|
+
if (y in s && s[y] !== u[y])
|
|
576
577
|
throw new Error(`Cannot extend: field '${y}' already exists in type definition`);
|
|
577
578
|
}
|
|
578
579
|
}
|
|
579
580
|
const o = {}, a = i.prototype;
|
|
580
581
|
for (const f of Object.getOwnPropertyNames(a))
|
|
581
582
|
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
582
|
-
t =
|
|
583
|
+
t = Kt(d.ENTITY | d.OBJECT, s), t._entityClass = i, it(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
583
584
|
const c = i;
|
|
584
585
|
c.cache && (t._entityCache = c.cache), bt.set(i, t);
|
|
585
586
|
}
|
|
586
587
|
return t;
|
|
587
588
|
}
|
|
588
|
-
function
|
|
589
|
-
return
|
|
589
|
+
function Ge(i) {
|
|
590
|
+
return T(i);
|
|
590
591
|
}
|
|
591
|
-
function
|
|
592
|
+
function Wt(i, t) {
|
|
592
593
|
if (t == null) return;
|
|
593
594
|
const e = /* @__PURE__ */ new Map();
|
|
594
595
|
if (Array.isArray(t))
|
|
595
596
|
for (const n of t) {
|
|
596
|
-
const [s, r] = n, a =
|
|
597
|
+
const [s, r] = n, a = T(s).typenameValue;
|
|
597
598
|
if (a === void 0) continue;
|
|
598
599
|
const c = [];
|
|
599
600
|
for (const [f, l] of Object.entries(r))
|
|
@@ -612,104 +613,104 @@ function Ht(i, t) {
|
|
|
612
613
|
return e.size > 0 ? e : void 0;
|
|
613
614
|
}
|
|
614
615
|
function zt(i) {
|
|
615
|
-
return Array.isArray(i) ? i.map((t) =>
|
|
616
|
+
return Array.isArray(i) ? i.map((t) => T(t)) : [T(i)];
|
|
616
617
|
}
|
|
617
|
-
function
|
|
618
|
-
const e = zt(i), n = e.length === 1 ? e[0] : lt(...e.map((o) => o)), s =
|
|
619
|
-
return r._liveConfig =
|
|
618
|
+
function We(i, t) {
|
|
619
|
+
const e = zt(i), n = e.length === 1 ? e[0] : lt(...e.map((o) => o)), s = d.ARRAY | d.LIVE, r = new _(s, n);
|
|
620
|
+
return r._liveConfig = j.array(
|
|
620
621
|
e,
|
|
621
|
-
|
|
622
|
+
Wt(e, t?.constraints),
|
|
622
623
|
t?.sort
|
|
623
624
|
), r;
|
|
624
625
|
}
|
|
625
|
-
function
|
|
626
|
-
const n = zt(t), s = i, r =
|
|
627
|
-
return o._liveConfig =
|
|
626
|
+
function ze(i, t, e) {
|
|
627
|
+
const n = zt(t), s = i, r = d.LIVE, o = new _(r, void 0);
|
|
628
|
+
return o._liveConfig = j.value(
|
|
628
629
|
n,
|
|
629
|
-
|
|
630
|
+
Wt(n, e?.constraints),
|
|
630
631
|
s,
|
|
631
632
|
e.onCreate,
|
|
632
633
|
e.onUpdate,
|
|
633
634
|
e.onDelete
|
|
634
635
|
), o;
|
|
635
636
|
}
|
|
636
|
-
const
|
|
637
|
-
format:
|
|
638
|
-
typename:
|
|
639
|
-
const:
|
|
640
|
-
enum:
|
|
641
|
-
id:
|
|
642
|
-
string:
|
|
643
|
-
number:
|
|
644
|
-
boolean:
|
|
645
|
-
null:
|
|
646
|
-
undefined:
|
|
647
|
-
array:
|
|
648
|
-
object:
|
|
649
|
-
record:
|
|
637
|
+
const He = {
|
|
638
|
+
format: Ye,
|
|
639
|
+
typename: $e,
|
|
640
|
+
const: Qe,
|
|
641
|
+
enum: $t,
|
|
642
|
+
id: d.ID | d.STRING | d.NUMBER,
|
|
643
|
+
string: d.STRING,
|
|
644
|
+
number: d.NUMBER,
|
|
645
|
+
boolean: d.BOOLEAN,
|
|
646
|
+
null: d.NULL,
|
|
647
|
+
undefined: d.UNDEFINED,
|
|
648
|
+
array: ke,
|
|
649
|
+
object: Pe,
|
|
650
|
+
record: Fe,
|
|
650
651
|
union: lt,
|
|
651
|
-
nullish:
|
|
652
|
-
optional:
|
|
653
|
-
nullable:
|
|
652
|
+
nullish: Ue,
|
|
653
|
+
optional: Ve,
|
|
654
|
+
nullable: Ke,
|
|
654
655
|
result: Te,
|
|
655
|
-
entity:
|
|
656
|
-
liveArray:
|
|
657
|
-
liveValue:
|
|
656
|
+
entity: Ge,
|
|
657
|
+
liveArray: We,
|
|
658
|
+
liveValue: ze
|
|
658
659
|
};
|
|
659
|
-
function
|
|
660
|
+
function P(i, t, e) {
|
|
660
661
|
return new TypeError(`Validation error at ${i}`);
|
|
661
662
|
}
|
|
662
|
-
const
|
|
663
|
+
const Ht = Array.isArray;
|
|
663
664
|
function Ct(i) {
|
|
664
|
-
if (i === null) return
|
|
665
|
+
if (i === null) return d.NULL;
|
|
665
666
|
switch (typeof i) {
|
|
666
667
|
case "number":
|
|
667
|
-
return
|
|
668
|
+
return d.NUMBER;
|
|
668
669
|
case "string":
|
|
669
|
-
return
|
|
670
|
+
return d.STRING;
|
|
670
671
|
case "boolean":
|
|
671
|
-
return
|
|
672
|
+
return d.BOOLEAN;
|
|
672
673
|
case "undefined":
|
|
673
|
-
return
|
|
674
|
+
return d.UNDEFINED;
|
|
674
675
|
case "object":
|
|
675
|
-
return
|
|
676
|
+
return Ht(i) ? d.ARRAY : d.OBJECT;
|
|
676
677
|
default:
|
|
677
678
|
throw new Error(`Invalid type: ${typeof i}`);
|
|
678
679
|
}
|
|
679
680
|
}
|
|
680
|
-
function
|
|
681
|
-
return
|
|
681
|
+
function Ai(i) {
|
|
682
|
+
return F(i);
|
|
682
683
|
}
|
|
683
|
-
function
|
|
684
|
+
function F(i) {
|
|
684
685
|
if (i === null || typeof i != "object")
|
|
685
686
|
return i;
|
|
686
|
-
if (
|
|
687
|
-
return i.map((e) =>
|
|
687
|
+
if (Ht(i))
|
|
688
|
+
return i.map((e) => F(e));
|
|
688
689
|
if (i instanceof Date)
|
|
689
690
|
return new Date(i.getTime());
|
|
690
691
|
if (i instanceof Map) {
|
|
691
692
|
const e = /* @__PURE__ */ new Map();
|
|
692
693
|
for (const [n, s] of i)
|
|
693
|
-
e.set(
|
|
694
|
+
e.set(F(n), F(s));
|
|
694
695
|
return e;
|
|
695
696
|
}
|
|
696
697
|
if (i instanceof Set) {
|
|
697
698
|
const e = /* @__PURE__ */ new Set();
|
|
698
699
|
for (const n of i)
|
|
699
|
-
e.add(
|
|
700
|
+
e.add(F(n));
|
|
700
701
|
return e;
|
|
701
702
|
}
|
|
702
703
|
const t = {};
|
|
703
704
|
for (const e of Object.keys(i))
|
|
704
|
-
t[e] =
|
|
705
|
+
t[e] = F(i[e]);
|
|
705
706
|
return t;
|
|
706
707
|
}
|
|
707
|
-
const yt = Object.entries,
|
|
708
|
+
const yt = Object.entries, Je = () => {
|
|
708
709
|
};
|
|
709
710
|
class st {
|
|
710
711
|
queryClient = void 0;
|
|
711
712
|
preloadedEntities = void 0;
|
|
712
|
-
warn =
|
|
713
|
+
warn = Je;
|
|
713
714
|
/** When true, missing optional fields on existing entities are set to
|
|
714
715
|
* undefined. False for mutation events (truly partial payloads). */
|
|
715
716
|
isPartialEvent = !1;
|
|
@@ -719,19 +720,19 @@ class st {
|
|
|
719
720
|
this.queryClient = t, this.preloadedEntities = e, this.warn = n, 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()));
|
|
720
721
|
}
|
|
721
722
|
}
|
|
722
|
-
function
|
|
723
|
-
return
|
|
723
|
+
function Jt(i, t, e) {
|
|
724
|
+
return M(i, t, e, "");
|
|
724
725
|
}
|
|
725
|
-
function
|
|
726
|
+
function Xe(i, t, e) {
|
|
726
727
|
return pt(i, t, e);
|
|
727
728
|
}
|
|
728
729
|
function xt(i, t, e, n) {
|
|
729
730
|
const s = i >> Qt;
|
|
730
|
-
if ((i &
|
|
731
|
+
if ((i & d.IS_EAGER_FORMAT) !== 0)
|
|
731
732
|
try {
|
|
732
|
-
return new
|
|
733
|
+
return new q(t, s, !0);
|
|
733
734
|
} catch (o) {
|
|
734
|
-
if ((i &
|
|
735
|
+
if ((i & d.UNDEFINED) !== 0) {
|
|
735
736
|
e.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
736
737
|
value: t,
|
|
737
738
|
path: n,
|
|
@@ -741,79 +742,79 @@ function xt(i, t, e, n) {
|
|
|
741
742
|
}
|
|
742
743
|
throw o;
|
|
743
744
|
}
|
|
744
|
-
return new
|
|
745
|
+
return new q(t, s, !1);
|
|
745
746
|
}
|
|
746
|
-
function
|
|
747
|
+
function M(i, t, e, n) {
|
|
747
748
|
const s = t;
|
|
748
749
|
if (s instanceof H) {
|
|
749
750
|
const c = s.get(i);
|
|
750
|
-
if (c === void 0) throw
|
|
751
|
+
if (c === void 0) throw P(n);
|
|
751
752
|
return c;
|
|
752
753
|
}
|
|
753
754
|
if (s instanceof Set) {
|
|
754
|
-
if (!s.has(i)) throw
|
|
755
|
+
if (!s.has(i)) throw P(n);
|
|
755
756
|
return i;
|
|
756
757
|
}
|
|
757
758
|
if (typeof s == "string") {
|
|
758
759
|
if (i == null) return s;
|
|
759
|
-
if (i !== s) throw
|
|
760
|
+
if (i !== s) throw P(n);
|
|
760
761
|
return i;
|
|
761
762
|
}
|
|
762
763
|
if (typeof s == "number") {
|
|
763
764
|
const c = Ct(i);
|
|
764
765
|
if ((s & c) === 0) {
|
|
765
|
-
if ((s &
|
|
766
|
+
if ((s & d.UNDEFINED) !== 0) {
|
|
766
767
|
e.warn("Invalid value for optional type, defaulting to undefined", { value: i, path: n });
|
|
767
768
|
return;
|
|
768
769
|
}
|
|
769
|
-
throw
|
|
770
|
+
throw P(n);
|
|
770
771
|
}
|
|
771
|
-
return (s &
|
|
772
|
+
return (s & d.HAS_FORMAT) !== 0 && i !== null && i !== void 0 ? xt(s, i, e, n) : i;
|
|
772
773
|
}
|
|
773
774
|
const r = s.mask, o = s._liveConfig;
|
|
774
775
|
if (o !== void 0 && o.type === ct.Value)
|
|
775
|
-
return o.valueType !== void 0 ?
|
|
776
|
-
if ((r &
|
|
776
|
+
return o.valueType !== void 0 ? M(i, o.valueType, e, n) : i;
|
|
777
|
+
if ((r & d.PARSE_RESULT) !== 0)
|
|
777
778
|
try {
|
|
778
|
-
return { success: !0, value:
|
|
779
|
+
return { success: !0, value: M(i, s.shape, e, n) };
|
|
779
780
|
} catch (c) {
|
|
780
781
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
781
782
|
}
|
|
782
783
|
const a = Ct(i);
|
|
783
784
|
if ((r & a) === 0 && !s.values?.has(i)) {
|
|
784
|
-
if ((r &
|
|
785
|
+
if ((r & d.UNDEFINED) !== 0) {
|
|
785
786
|
e.warn("Invalid value for optional type, defaulting to undefined", { value: i, path: n });
|
|
786
787
|
return;
|
|
787
788
|
}
|
|
788
|
-
throw
|
|
789
|
+
throw P(n);
|
|
789
790
|
}
|
|
790
|
-
return a <
|
|
791
|
+
return a < d.OBJECT ? (r & d.HAS_FORMAT) !== 0 && i !== null && i !== void 0 ? xt(r, i, e, n) : i : (r & d.UNION) !== 0 ? Ze(a, i, s, e, n) : a === d.ARRAY ? Xt(i, s.shape, e, n) : (r & d.RECORD) !== 0 ? Zt(i, s.shape, e, n) : (r & d.ENTITY) !== 0 && e.queryClient !== void 0 ? pt(i, s, e) : te(i, s, e, n);
|
|
791
792
|
}
|
|
792
|
-
function
|
|
793
|
-
if (i ===
|
|
794
|
-
const r = e.shape[
|
|
795
|
-
return r === void 0 || typeof r == "number" ? t :
|
|
793
|
+
function Ze(i, t, e, n, s) {
|
|
794
|
+
if (i === d.ARRAY) {
|
|
795
|
+
const r = e.shape[Q];
|
|
796
|
+
return r === void 0 || typeof r == "number" ? t : Xt(t, r, n, s);
|
|
796
797
|
} else {
|
|
797
798
|
const r = e.typenameField, o = r ? t[r] : void 0;
|
|
798
799
|
if (o === void 0 || typeof o != "string") {
|
|
799
|
-
const c = e.shape[
|
|
800
|
+
const c = e.shape[B];
|
|
800
801
|
if (c === void 0)
|
|
801
802
|
throw new Error(
|
|
802
803
|
`Typename field '${r}' is required for union discrimination but was not found in the data`
|
|
803
804
|
);
|
|
804
|
-
return
|
|
805
|
+
return Zt(t, c, n, s);
|
|
805
806
|
}
|
|
806
807
|
const a = e.shape[o];
|
|
807
808
|
if (a === void 0 || typeof a == "number")
|
|
808
809
|
throw new Error(`Unknown typename '${o}' in union`);
|
|
809
|
-
return a.mask &
|
|
810
|
+
return a.mask & d.ENTITY && n.queryClient !== void 0 ? pt(t, a, n) : te(t, a, n, s);
|
|
810
811
|
}
|
|
811
812
|
}
|
|
812
|
-
function
|
|
813
|
+
function Xt(i, t, e, n) {
|
|
813
814
|
const s = [];
|
|
814
815
|
for (let r = 0; r < i.length; r++)
|
|
815
816
|
try {
|
|
816
|
-
s.push(
|
|
817
|
+
s.push(M(i[r], t, e, `${n}[${r}]`));
|
|
817
818
|
} catch (o) {
|
|
818
819
|
e.warn("Failed to parse array item, filtering out", {
|
|
819
820
|
index: r,
|
|
@@ -823,17 +824,17 @@ function Zt(i, t, e, n) {
|
|
|
823
824
|
}
|
|
824
825
|
return s;
|
|
825
826
|
}
|
|
826
|
-
function
|
|
827
|
+
function Zt(i, t, e, n) {
|
|
827
828
|
for (const [s, r] of yt(i))
|
|
828
|
-
i[s] =
|
|
829
|
+
i[s] = M(r, t, e, `${n}["${s}"]`);
|
|
829
830
|
return i;
|
|
830
831
|
}
|
|
831
|
-
function
|
|
832
|
-
if (
|
|
832
|
+
function te(i, t, e, n) {
|
|
833
|
+
if (x.has(i))
|
|
833
834
|
return i;
|
|
834
835
|
const s = t.shape;
|
|
835
836
|
for (const [r, o] of yt(s))
|
|
836
|
-
i[r] =
|
|
837
|
+
i[r] = M(i[r], o, e, `${n}.${r}`);
|
|
837
838
|
return i;
|
|
838
839
|
}
|
|
839
840
|
function pt(i, t, e) {
|
|
@@ -845,7 +846,7 @@ function pt(i, t, e) {
|
|
|
845
846
|
const p = i[t.idField];
|
|
846
847
|
if (p == null || typeof p != "string" && typeof p != "number")
|
|
847
848
|
throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
|
|
848
|
-
o = p, r =
|
|
849
|
+
o = p, r = D([t.typenameValue, o]);
|
|
849
850
|
}
|
|
850
851
|
const a = e.seenByKey.get(r);
|
|
851
852
|
if (a !== void 0)
|
|
@@ -858,57 +859,57 @@ function pt(i, t, e) {
|
|
|
858
859
|
}
|
|
859
860
|
const c = {};
|
|
860
861
|
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
861
|
-
const f = n.entityMap.getEntity(r), l = e.isPartialEvent && f !== void 0,
|
|
862
|
+
const f = n.entityMap.getEntity(r), l = e.isPartialEvent && f !== void 0, u = {
|
|
862
863
|
key: r,
|
|
863
864
|
shape: t,
|
|
864
865
|
data: c,
|
|
865
866
|
rawKeys: l ? new Set(Object.keys(i)) : void 0
|
|
866
867
|
};
|
|
867
|
-
e.seen.set(c,
|
|
868
|
+
e.seen.set(c, u), e.seenByKey.set(r, u);
|
|
868
869
|
const y = `[[${t.typenameValue}:${o}]]`, v = t.shape;
|
|
869
870
|
for (const [p, g] of yt(v))
|
|
870
|
-
l && !(p in i) || (c[p] =
|
|
871
|
+
l && !(p in i) || (c[p] = M(i[p], g, e, `${y}.${p}`));
|
|
871
872
|
return c;
|
|
872
873
|
}
|
|
873
|
-
function
|
|
874
|
-
return
|
|
874
|
+
function ti(i, t) {
|
|
875
|
+
return ei(i, t.shape, t.typenameField);
|
|
875
876
|
}
|
|
876
|
-
function
|
|
877
|
+
function ei(i, t, e) {
|
|
877
878
|
if (t === void 0) return !0;
|
|
878
879
|
for (const n of Object.keys(t)) {
|
|
879
880
|
if (n === e) continue;
|
|
880
881
|
const s = t[n];
|
|
881
882
|
if (s instanceof _) {
|
|
882
|
-
if ((s.mask &
|
|
883
|
+
if ((s.mask & d.UNDEFINED) !== 0) continue;
|
|
883
884
|
if (!(n in i) || i[n] === void 0) return !1;
|
|
884
885
|
} else if (typeof s == "number") {
|
|
885
|
-
if ((s &
|
|
886
|
+
if ((s & d.UNDEFINED) !== 0) continue;
|
|
886
887
|
if (!(n in i) || i[n] === void 0) return !1;
|
|
887
888
|
} else if (!(n in i) || i[n] === void 0) return !1;
|
|
888
889
|
}
|
|
889
890
|
return !0;
|
|
890
891
|
}
|
|
891
|
-
const
|
|
892
|
-
function
|
|
892
|
+
const ii = Object.prototype, $ = /* @__PURE__ */ new WeakMap();
|
|
893
|
+
function A(i) {
|
|
893
894
|
if (typeof i != "object" || i === null) return i;
|
|
894
|
-
if (
|
|
895
|
-
if (
|
|
895
|
+
if (J.has(i)) return A(i.getValue());
|
|
896
|
+
if (x.has(i)) return i;
|
|
896
897
|
if (Array.isArray(i)) {
|
|
897
898
|
let t = $.get(i);
|
|
898
|
-
return t === void 0 && (t = new Proxy(i,
|
|
899
|
+
return t === void 0 && (t = new Proxy(i, ni), $.set(i, t)), t;
|
|
899
900
|
}
|
|
900
|
-
if (Object.getPrototypeOf(i) ===
|
|
901
|
+
if (Object.getPrototypeOf(i) === ii) {
|
|
901
902
|
let t = $.get(i);
|
|
902
|
-
return t === void 0 && (t = new Proxy(i,
|
|
903
|
+
return t === void 0 && (t = new Proxy(i, si), $.set(i, t)), t;
|
|
903
904
|
}
|
|
904
905
|
return i;
|
|
905
906
|
}
|
|
906
|
-
const
|
|
907
|
+
const ni = {
|
|
907
908
|
get(i, t, e) {
|
|
908
909
|
if (typeof t == "string") {
|
|
909
910
|
const n = Number(t);
|
|
910
911
|
if (Number.isInteger(n) && n >= 0 && n < i.length)
|
|
911
|
-
return
|
|
912
|
+
return A(i[n]);
|
|
912
913
|
}
|
|
913
914
|
return Reflect.get(i, t, e);
|
|
914
915
|
},
|
|
@@ -918,9 +919,9 @@ const ei = {
|
|
|
918
919
|
deleteProperty() {
|
|
919
920
|
return !1;
|
|
920
921
|
}
|
|
921
|
-
},
|
|
922
|
+
}, si = {
|
|
922
923
|
get(i, t, e) {
|
|
923
|
-
return typeof t == "string" ?
|
|
924
|
+
return typeof t == "string" ? A(i[t]) : Reflect.get(i, t, e);
|
|
924
925
|
},
|
|
925
926
|
set() {
|
|
926
927
|
return !1;
|
|
@@ -938,7 +939,7 @@ const ei = {
|
|
|
938
939
|
return Object.getOwnPropertyDescriptor(i, t);
|
|
939
940
|
}
|
|
940
941
|
};
|
|
941
|
-
class
|
|
942
|
+
class ri {
|
|
942
943
|
_notifier;
|
|
943
944
|
_queryClient;
|
|
944
945
|
_proxies = /* @__PURE__ */ new Map();
|
|
@@ -967,7 +968,7 @@ class ni {
|
|
|
967
968
|
if (--this.refCount > 0 || this.refCount < 0)
|
|
968
969
|
return;
|
|
969
970
|
const t = this._entityCache?.gcTime;
|
|
970
|
-
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t,
|
|
971
|
+
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, z.Entity) : this.evict();
|
|
971
972
|
}
|
|
972
973
|
evict() {
|
|
973
974
|
const t = this.liveCollections.slice();
|
|
@@ -1001,13 +1002,13 @@ class ni {
|
|
|
1001
1002
|
getProxy(t) {
|
|
1002
1003
|
const e = t;
|
|
1003
1004
|
let n = this._proxies.get(e);
|
|
1004
|
-
return n === void 0 && (n =
|
|
1005
|
+
return n === void 0 && (n = ai(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(e, n)), n;
|
|
1005
1006
|
}
|
|
1006
1007
|
get proxy() {
|
|
1007
1008
|
return this._proxies.values().next().value;
|
|
1008
1009
|
}
|
|
1009
1010
|
satisfiesDef(t) {
|
|
1010
|
-
return this.satisfiedDefs.has(t) ? !0 :
|
|
1011
|
+
return this.satisfiedDefs.has(t) ? !0 : ti(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
|
|
1011
1012
|
}
|
|
1012
1013
|
save() {
|
|
1013
1014
|
this._queryClient.entityMap.save(this);
|
|
@@ -1019,52 +1020,52 @@ class ni {
|
|
|
1019
1020
|
this._notifier.consume();
|
|
1020
1021
|
}
|
|
1021
1022
|
}
|
|
1022
|
-
function
|
|
1023
|
+
function oi(i, t, e) {
|
|
1023
1024
|
const n = [];
|
|
1024
1025
|
for (const s of i) {
|
|
1025
1026
|
if (typeof s != "object" || s === null) continue;
|
|
1026
|
-
const r =
|
|
1027
|
+
const r = x.get(s);
|
|
1027
1028
|
if (r === void 0) continue;
|
|
1028
1029
|
const o = e.entityMap.getEntity(r);
|
|
1029
1030
|
o !== void 0 && o.satisfiesDef(t) && n.push(s);
|
|
1030
1031
|
}
|
|
1031
1032
|
return n;
|
|
1032
1033
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype :
|
|
1034
|
+
function ai(i, t, e, n, s) {
|
|
1035
|
+
const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype : qt.prototype;
|
|
1035
1036
|
e.typenameField;
|
|
1036
|
-
const
|
|
1037
|
+
const u = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
|
|
1037
1038
|
let p;
|
|
1038
|
-
f?.hasSubscribe && a && "__subscribe" in a && (p = It((
|
|
1039
|
+
f?.hasSubscribe && a && "__subscribe" in a && (p = It((E) => {
|
|
1039
1040
|
const h = (b) => {
|
|
1040
1041
|
b.__eventSource = t, s.applyMutationEvent(b);
|
|
1041
1042
|
}, m = a.__subscribe.call(g, h);
|
|
1042
|
-
return
|
|
1043
|
+
return E.value = g, m;
|
|
1043
1044
|
}));
|
|
1044
1045
|
let g;
|
|
1045
|
-
const
|
|
1046
|
-
if (
|
|
1047
|
-
for (const
|
|
1048
|
-
|
|
1049
|
-
let
|
|
1050
|
-
function
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
if (
|
|
1054
|
-
for (const m of Object.keys(
|
|
1055
|
-
|
|
1046
|
+
const w = Object.keys(r);
|
|
1047
|
+
if (w.includes("__typename") || w.push("__typename"), a)
|
|
1048
|
+
for (const E of Object.keys(a))
|
|
1049
|
+
w.includes(E) || w.push(E);
|
|
1050
|
+
let I, O = w;
|
|
1051
|
+
function K() {
|
|
1052
|
+
const E = i._extraMethods;
|
|
1053
|
+
if (E !== I) {
|
|
1054
|
+
if (I = E, O = w.slice(), E !== void 0)
|
|
1055
|
+
for (const m of Object.keys(E))
|
|
1056
|
+
O.includes(m) || O.push(m);
|
|
1056
1057
|
const h = i._extraGetters;
|
|
1057
1058
|
if (h !== void 0)
|
|
1058
1059
|
for (const m of Object.keys(h))
|
|
1059
|
-
|
|
1060
|
+
O.includes(m) || O.push(m);
|
|
1060
1061
|
}
|
|
1061
|
-
return
|
|
1062
|
+
return O;
|
|
1062
1063
|
}
|
|
1063
|
-
const
|
|
1064
|
+
const R = {
|
|
1064
1065
|
getPrototypeOf() {
|
|
1065
1066
|
return l;
|
|
1066
1067
|
},
|
|
1067
|
-
get(
|
|
1068
|
+
get(E, h) {
|
|
1068
1069
|
if (typeof h == "symbol") return;
|
|
1069
1070
|
if (h === "toJSON") return v;
|
|
1070
1071
|
if (h === "__context") return s.getContext();
|
|
@@ -1073,45 +1074,45 @@ function ri(i, t, e, n, s) {
|
|
|
1073
1074
|
const b = i._extraGetters;
|
|
1074
1075
|
if (b !== void 0 && h in b)
|
|
1075
1076
|
return b[h]();
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
let
|
|
1079
|
-
return
|
|
1077
|
+
const S = i._extraMethods;
|
|
1078
|
+
if (S !== void 0 && h in S) {
|
|
1079
|
+
let C = u.get(h);
|
|
1080
|
+
return C || (C = S[h].bind(g), u.set(h, C)), C;
|
|
1080
1081
|
}
|
|
1081
1082
|
if (a && h in a) {
|
|
1082
|
-
let
|
|
1083
|
-
return
|
|
1083
|
+
let C = u.get(h);
|
|
1084
|
+
return C || (C = pe(g, a[h].bind(g)), u.set(h, C)), C;
|
|
1084
1085
|
}
|
|
1085
1086
|
}
|
|
1086
1087
|
const m = i.data[h];
|
|
1087
|
-
if (typeof m == "object" && m !== null &&
|
|
1088
|
-
return
|
|
1088
|
+
if (typeof m == "object" && m !== null && J.has(m))
|
|
1089
|
+
return A(m.getValue());
|
|
1089
1090
|
if (Array.isArray(m) && typeof h == "string") {
|
|
1090
1091
|
const b = r[h];
|
|
1091
|
-
if (b instanceof _ && (b.mask &
|
|
1092
|
-
const
|
|
1093
|
-
if (
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
const _t = s.getEntityDefsForTypename(
|
|
1092
|
+
if (b instanceof _ && (b.mask & d.ARRAY) !== 0) {
|
|
1093
|
+
const S = b.shape;
|
|
1094
|
+
if (S instanceof _ && (S.mask & d.ENTITY) !== 0) {
|
|
1095
|
+
const C = S.typenameValue;
|
|
1096
|
+
if (C !== void 0) {
|
|
1097
|
+
const _t = s.getEntityDefsForTypename(C);
|
|
1097
1098
|
if (_t !== void 0 && _t.length > 1) {
|
|
1098
1099
|
const X = y.get(h);
|
|
1099
1100
|
if (X !== void 0 && X.source === m)
|
|
1100
|
-
return
|
|
1101
|
-
const mt =
|
|
1102
|
-
return y.set(h, { source: m, filtered: mt }),
|
|
1101
|
+
return A(X.filtered);
|
|
1102
|
+
const mt = oi(m, S, s);
|
|
1103
|
+
return y.set(h, { source: m, filtered: mt }), A(mt);
|
|
1103
1104
|
}
|
|
1104
1105
|
}
|
|
1105
1106
|
}
|
|
1106
1107
|
}
|
|
1107
|
-
return
|
|
1108
|
+
return A(m);
|
|
1108
1109
|
}
|
|
1109
|
-
return
|
|
1110
|
+
return A(m);
|
|
1110
1111
|
},
|
|
1111
1112
|
set() {
|
|
1112
1113
|
return !1;
|
|
1113
1114
|
},
|
|
1114
|
-
has(
|
|
1115
|
+
has(E, h) {
|
|
1115
1116
|
if (h === "__typename") return !0;
|
|
1116
1117
|
if (typeof h == "string") {
|
|
1117
1118
|
const m = i._extraGetters;
|
|
@@ -1122,28 +1123,28 @@ function ri(i, t, e, n, s) {
|
|
|
1122
1123
|
return h in r;
|
|
1123
1124
|
},
|
|
1124
1125
|
ownKeys() {
|
|
1125
|
-
return
|
|
1126
|
+
return K();
|
|
1126
1127
|
},
|
|
1127
|
-
getOwnPropertyDescriptor(
|
|
1128
|
+
getOwnPropertyDescriptor(E, h) {
|
|
1128
1129
|
if (h === "__typename")
|
|
1129
1130
|
return { enumerable: !0, configurable: !0, value: i.typename, writable: !1 };
|
|
1130
1131
|
if (h in r)
|
|
1131
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1132
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1132
1133
|
if (typeof h == "string") {
|
|
1133
1134
|
const m = i._extraGetters;
|
|
1134
1135
|
if (m && h in m)
|
|
1135
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1136
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1136
1137
|
const b = i._extraMethods;
|
|
1137
1138
|
if (b && h in b)
|
|
1138
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1139
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1139
1140
|
if (a && h in a)
|
|
1140
|
-
return { enumerable: !1, configurable: !0, value:
|
|
1141
|
+
return { enumerable: !1, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1141
1142
|
}
|
|
1142
1143
|
}
|
|
1143
1144
|
};
|
|
1144
|
-
return g = new Proxy({},
|
|
1145
|
+
return g = new Proxy({}, R), x.set(g, t), ye(g, s), g;
|
|
1145
1146
|
}
|
|
1146
|
-
class
|
|
1147
|
+
class ci {
|
|
1147
1148
|
instances = /* @__PURE__ */ new Map();
|
|
1148
1149
|
persistEntity;
|
|
1149
1150
|
constructor(t) {
|
|
@@ -1165,7 +1166,7 @@ class oi {
|
|
|
1165
1166
|
if (typeof a != "string" && typeof a != "number")
|
|
1166
1167
|
throw new Error(`Entity id must be string or number: ${n.typenameValue}`);
|
|
1167
1168
|
const c = n;
|
|
1168
|
-
r = new
|
|
1169
|
+
r = new ri(t, n.typenameValue, a, o, e, s), r._entityCache = c._entityCache, this.instances.set(t, r);
|
|
1169
1170
|
}
|
|
1170
1171
|
return r.parseId = s.currentParseId, r;
|
|
1171
1172
|
}
|
|
@@ -1181,13 +1182,13 @@ class oi {
|
|
|
1181
1182
|
this.persistEntity(t.key, t.data, e);
|
|
1182
1183
|
}
|
|
1183
1184
|
}
|
|
1184
|
-
class
|
|
1185
|
+
class ee {
|
|
1185
1186
|
onlineSignal;
|
|
1186
1187
|
manualOverride = void 0;
|
|
1187
1188
|
eventListenersAttached = !1;
|
|
1188
1189
|
constructor(t) {
|
|
1189
1190
|
const e = t ?? this.detectOnlineStatus();
|
|
1190
|
-
this.onlineSignal =
|
|
1191
|
+
this.onlineSignal = Nt(e), this.canAttachListeners() && this.attachEventListeners();
|
|
1191
1192
|
}
|
|
1192
1193
|
/**
|
|
1193
1194
|
* Returns true if the network is currently online
|
|
@@ -1245,8 +1246,8 @@ class ie {
|
|
|
1245
1246
|
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1246
1247
|
}
|
|
1247
1248
|
}
|
|
1248
|
-
class
|
|
1249
|
-
static onlineSignal =
|
|
1249
|
+
class ie {
|
|
1250
|
+
static onlineSignal = Nt(!0);
|
|
1250
1251
|
get isOnline() {
|
|
1251
1252
|
return !0;
|
|
1252
1253
|
}
|
|
@@ -1255,102 +1256,33 @@ class ne {
|
|
|
1255
1256
|
clearManualOverride() {
|
|
1256
1257
|
}
|
|
1257
1258
|
getOnlineSignal() {
|
|
1258
|
-
return
|
|
1259
|
+
return ie.onlineSignal;
|
|
1259
1260
|
}
|
|
1260
1261
|
destroy() {
|
|
1261
1262
|
}
|
|
1262
1263
|
}
|
|
1263
|
-
const
|
|
1264
|
+
const fi = new ee(), Di = Mt(fi);
|
|
1264
1265
|
function gt(i, t = typeof window > "u") {
|
|
1265
1266
|
let e;
|
|
1266
1267
|
i === !1 ? e = 0 : i === void 0 || i === !0 ? e = t ? 0 : 3 : typeof i == "number" ? e = i : e = i.retries;
|
|
1267
1268
|
const n = typeof i == "object" && i.retryDelay ? i.retryDelay : (s) => 1e3 * Math.pow(2, s);
|
|
1268
1269
|
return { retries: e, retryDelay: n };
|
|
1269
1270
|
}
|
|
1270
|
-
class
|
|
1271
|
+
class Ii {
|
|
1271
1272
|
static cache;
|
|
1273
|
+
/**
|
|
1274
|
+
* The adapter class responsible for sending requests for this query type.
|
|
1275
|
+
* Must be set on each concrete Query subclass (or inherited from a base like RESTQuery).
|
|
1276
|
+
*/
|
|
1277
|
+
static adapter;
|
|
1272
1278
|
params;
|
|
1273
1279
|
config;
|
|
1274
1280
|
constructor() {
|
|
1275
|
-
return
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
class Si extends ci {
|
|
1279
|
-
method = "GET";
|
|
1280
|
-
path;
|
|
1281
|
-
searchParams;
|
|
1282
|
-
body;
|
|
1283
|
-
headers;
|
|
1284
|
-
requestOptions;
|
|
1285
|
-
loadNext;
|
|
1286
|
-
getStorageKey() {
|
|
1287
|
-
return `${this.method ?? "GET"}:${this.path ?? ""}`;
|
|
1288
|
-
}
|
|
1289
|
-
async send() {
|
|
1290
|
-
return this.executeRequest();
|
|
1291
|
-
}
|
|
1292
|
-
resolveLoadNext() {
|
|
1293
|
-
const e = (this.getLoadNext ? this.getLoadNext() : void 0) ?? this.rawLoadNext;
|
|
1294
|
-
if (e === void 0) return;
|
|
1295
|
-
const n = {
|
|
1296
|
-
params: this.params ?? {},
|
|
1297
|
-
result: this.resultData
|
|
1298
|
-
};
|
|
1299
|
-
return {
|
|
1300
|
-
url: e.url !== void 0 ? P(e.url, n) : void 0,
|
|
1301
|
-
searchParams: e.searchParams !== void 0 ? P(e.searchParams, n) : void 0
|
|
1302
|
-
};
|
|
1303
|
-
}
|
|
1304
|
-
hasNext() {
|
|
1305
|
-
const t = this.resolveLoadNext();
|
|
1306
|
-
if (t === void 0) return !1;
|
|
1307
|
-
if (t.url !== void 0 && t.url !== null)
|
|
1308
|
-
return !0;
|
|
1309
|
-
if (t.searchParams !== void 0) {
|
|
1310
|
-
const e = Object.keys(t.searchParams);
|
|
1311
|
-
if (e.length === 0) return !1;
|
|
1312
|
-
for (const n of e)
|
|
1313
|
-
if (t.searchParams[n] === void 0 || t.searchParams[n] === null)
|
|
1314
|
-
return !1;
|
|
1315
|
-
return !0;
|
|
1316
|
-
}
|
|
1317
|
-
return !1;
|
|
1318
|
-
}
|
|
1319
|
-
async sendNext() {
|
|
1320
|
-
const t = this.resolveLoadNext();
|
|
1321
|
-
if (t === void 0)
|
|
1322
|
-
throw new Error("loadNext is not configured for this query");
|
|
1323
|
-
return this.executeRequest(t);
|
|
1324
|
-
}
|
|
1325
|
-
async executeRequest(t) {
|
|
1326
|
-
const e = t?.url ?? (this.getPath ? this.getPath() : this.path), n = this.getMethod ? this.getMethod() : this.method, s = this.getSearchParams ? this.getSearchParams() : this.searchParams, r = t?.searchParams ? { ...s, ...t.searchParams } : s, o = this.getBody ? this.getBody() : this.body, a = this.getRequestOptions ? this.getRequestOptions() : this.requestOptions;
|
|
1327
|
-
if (!e)
|
|
1328
|
-
throw new Error("RESTQuery requires a path. Define `path` as a field or override `getPath()`.");
|
|
1329
|
-
let c = e;
|
|
1330
|
-
if (r) {
|
|
1331
|
-
const S = new URLSearchParams();
|
|
1332
|
-
for (const I in r) {
|
|
1333
|
-
const x = r[I];
|
|
1334
|
-
x != null && S.append(I, String(x));
|
|
1335
|
-
}
|
|
1336
|
-
const C = S.toString();
|
|
1337
|
-
C && (c += "?" + C);
|
|
1338
|
-
}
|
|
1339
|
-
const f = Dt(a?.baseUrl) ?? Dt(this.context.baseUrl), l = f ? `${f}${c}` : c, { baseUrl: d, signal: y, ...v } = a ?? {}, g = o || this.headers ? {
|
|
1340
|
-
...o ? { "Content-Type": "application/json" } : void 0,
|
|
1341
|
-
...this.headers
|
|
1342
|
-
} : void 0, E = await this.context.fetch(l, {
|
|
1343
|
-
method: n,
|
|
1344
|
-
headers: g,
|
|
1345
|
-
body: o ? JSON.stringify(o) : void 0,
|
|
1346
|
-
signal: this.signal,
|
|
1347
|
-
...v
|
|
1348
|
-
});
|
|
1349
|
-
return this.response = E, E.json();
|
|
1281
|
+
return jt(this);
|
|
1350
1282
|
}
|
|
1351
1283
|
}
|
|
1352
|
-
const
|
|
1353
|
-
class
|
|
1284
|
+
const Ot = /* @__PURE__ */ new WeakMap();
|
|
1285
|
+
class V {
|
|
1354
1286
|
constructor(t, e) {
|
|
1355
1287
|
this.captured = e, this.statics = t;
|
|
1356
1288
|
}
|
|
@@ -1363,37 +1295,42 @@ class J {
|
|
|
1363
1295
|
return { config: n, retryConfig: s };
|
|
1364
1296
|
}
|
|
1365
1297
|
static for(t) {
|
|
1366
|
-
let e =
|
|
1298
|
+
let e = Ot.get(t);
|
|
1367
1299
|
if (e !== void 0)
|
|
1368
1300
|
return e;
|
|
1369
|
-
const n = new t(), s =
|
|
1370
|
-
|
|
1301
|
+
const n = new t(), s = De(n), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : He.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = s.fields.fetchNext, u = t.adapter;
|
|
1302
|
+
if (!u)
|
|
1303
|
+
throw new Error(
|
|
1304
|
+
`Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
|
|
1305
|
+
);
|
|
1306
|
+
const y = typeof u.prototype.sendNext == "function", v = c ? a : new _(
|
|
1307
|
+
d.ENTITY | d.OBJECT,
|
|
1371
1308
|
a.shape,
|
|
1372
1309
|
void 0,
|
|
1373
1310
|
void 0,
|
|
1374
1311
|
r,
|
|
1375
1312
|
// typenameValue — unique per query class
|
|
1376
|
-
|
|
1313
|
+
Ft
|
|
1377
1314
|
// idField — symbol, injected onto payload before parse
|
|
1378
1315
|
);
|
|
1379
|
-
return e = new
|
|
1380
|
-
{ id: r, shape:
|
|
1316
|
+
return e = new V(
|
|
1317
|
+
{ id: r, shape: v, cache: f, rawFetchNext: l, hasSendNext: y, isEntityResult: c, adapterClass: u },
|
|
1381
1318
|
s
|
|
1382
|
-
),
|
|
1319
|
+
), Ot.set(t, e), e;
|
|
1383
1320
|
}
|
|
1384
1321
|
}
|
|
1385
1322
|
const Ni = (i, t) => {
|
|
1386
|
-
const e =
|
|
1323
|
+
const e = V.for(i);
|
|
1387
1324
|
return vt(e, t);
|
|
1388
1325
|
};
|
|
1389
|
-
function
|
|
1390
|
-
const e =
|
|
1326
|
+
function Mi(i, ...t) {
|
|
1327
|
+
const e = V.for(i), n = ge(bi);
|
|
1391
1328
|
if (n === void 0)
|
|
1392
1329
|
throw new Error("QueryClient not found");
|
|
1393
1330
|
const s = t[0];
|
|
1394
1331
|
return n.getQuery(e, s);
|
|
1395
1332
|
}
|
|
1396
|
-
function
|
|
1333
|
+
function ne(i, t) {
|
|
1397
1334
|
return new Promise((e, n) => {
|
|
1398
1335
|
if (t?.aborted) {
|
|
1399
1336
|
n(t.reason);
|
|
@@ -1418,12 +1355,12 @@ async function rt(i, t, e) {
|
|
|
1418
1355
|
return await i();
|
|
1419
1356
|
} catch (o) {
|
|
1420
1357
|
if (s = o, r >= n) throw o;
|
|
1421
|
-
await
|
|
1358
|
+
await ne(t.retryDelay(r), e);
|
|
1422
1359
|
}
|
|
1423
1360
|
}
|
|
1424
1361
|
throw s;
|
|
1425
1362
|
}
|
|
1426
|
-
class
|
|
1363
|
+
class ui {
|
|
1427
1364
|
def;
|
|
1428
1365
|
queryKey;
|
|
1429
1366
|
storageKey = -1;
|
|
@@ -1441,9 +1378,7 @@ class fi {
|
|
|
1441
1378
|
/** Resolved per-instance options (depend on actual params). */
|
|
1442
1379
|
config = void 0;
|
|
1443
1380
|
retryConfig = gt(void 0);
|
|
1444
|
-
/**
|
|
1445
|
-
_lastResponse = void 0;
|
|
1446
|
-
/** Controller for aborting in-flight fetches and retry waits. */
|
|
1381
|
+
/** Cancels in-flight fetches and retry waits. */
|
|
1447
1382
|
_abortController = void 0;
|
|
1448
1383
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
1449
1384
|
_executionCtx = void 0;
|
|
@@ -1451,7 +1386,7 @@ class fi {
|
|
|
1451
1386
|
/** Root entity that holds parsed data, proxy, child refs, and bindings.
|
|
1452
1387
|
* For entity results, this is undefined until the first apply discovers it. */
|
|
1453
1388
|
rootEntity;
|
|
1454
|
-
/** Extra methods (__refetch,
|
|
1389
|
+
/** Extra methods (__refetch, __fetchNext) attached to the root entity proxy. */
|
|
1455
1390
|
_extraMethods = {};
|
|
1456
1391
|
/** Query id injected as QUERY_ID on non-entity payloads. */
|
|
1457
1392
|
_queryId = 0;
|
|
@@ -1462,22 +1397,22 @@ class fi {
|
|
|
1462
1397
|
return this._relayState;
|
|
1463
1398
|
}
|
|
1464
1399
|
constructor(t, e, n, s) {
|
|
1465
|
-
this.def = t, this.queryClient = e, this.queryKey = n, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.
|
|
1466
|
-
const r =
|
|
1467
|
-
this._queryId = r !== void 0 ?
|
|
1400
|
+
this.def = t, this.queryClient = e, this.queryKey = n, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1401
|
+
const r = Dt(s);
|
|
1402
|
+
this._queryId = r !== void 0 ? D(r) : 0, this.relay = It(
|
|
1468
1403
|
(o) => {
|
|
1469
1404
|
this._relayState = o;
|
|
1470
1405
|
const a = () => {
|
|
1471
|
-
clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this.
|
|
1472
|
-
const f = this.config?.gcTime ??
|
|
1473
|
-
this.queryClient.gcManager.schedule(this.queryKey, f,
|
|
1406
|
+
clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1407
|
+
const f = this.config?.gcTime ?? kt;
|
|
1408
|
+
this.queryClient.gcManager.schedule(this.queryKey, f, z.Query);
|
|
1474
1409
|
}, c = (f = !1) => {
|
|
1475
|
-
const { wasPaused: l, isPaused:
|
|
1476
|
-
if (this.wasPaused =
|
|
1410
|
+
const { wasPaused: l, isPaused: u, initialized: y } = this;
|
|
1411
|
+
if (this.wasPaused = u, u && !l && y) {
|
|
1477
1412
|
a();
|
|
1478
1413
|
return;
|
|
1479
1414
|
}
|
|
1480
|
-
const v =
|
|
1415
|
+
const v = Dt(this.params), p = vt(this.def, v), g = p !== this.storageKey;
|
|
1481
1416
|
g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1482
1417
|
};
|
|
1483
1418
|
return c(!0), {
|
|
@@ -1500,7 +1435,7 @@ class fi {
|
|
|
1500
1435
|
s
|
|
1501
1436
|
), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
|
|
1502
1437
|
__hasNext: () => this.hasNext,
|
|
1503
|
-
|
|
1438
|
+
__isFetchingNext: () => this._fetchNextPromise !== void 0
|
|
1504
1439
|
}), this.rootEntity.getProxy(r.statics.shape);
|
|
1505
1440
|
}
|
|
1506
1441
|
/** Save query metadata (the __entityRef pointer, updatedAt, ref set). */
|
|
@@ -1527,7 +1462,7 @@ class fi {
|
|
|
1527
1462
|
if (!this.isPaused)
|
|
1528
1463
|
try {
|
|
1529
1464
|
if (n !== void 0 && this.setupSubscription(), n === void 0 || this.isStale) {
|
|
1530
|
-
if (await
|
|
1465
|
+
if (await ne(0), this.isPaused) return;
|
|
1531
1466
|
this.runQueryImmediately();
|
|
1532
1467
|
}
|
|
1533
1468
|
} catch (s) {
|
|
@@ -1547,7 +1482,7 @@ class fi {
|
|
|
1547
1482
|
return (this._executionCtx === void 0 || this._executionCtxKey !== this.storageKey) && (this._executionCtxKey = this.storageKey, this._executionCtx = this.def.createExecutionContext(
|
|
1548
1483
|
this.currentParams ?? {},
|
|
1549
1484
|
this.queryClient.getContext()
|
|
1550
|
-
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.
|
|
1485
|
+
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext), this.resolveAndApplyOptions(), this._executionCtx;
|
|
1551
1486
|
}
|
|
1552
1487
|
resolveAndApplyOptions() {
|
|
1553
1488
|
const t = this.def.resolveOptions(this._executionCtx);
|
|
@@ -1557,11 +1492,11 @@ class fi {
|
|
|
1557
1492
|
const t = this.def;
|
|
1558
1493
|
if (this.isPaused)
|
|
1559
1494
|
throw new Error("Query is paused due to network status");
|
|
1560
|
-
const e = this.getOrCreateExecutionContext(),
|
|
1561
|
-
return
|
|
1495
|
+
const e = this.getOrCreateExecutionContext(), n = this.queryClient.getAdapter(t.statics.adapterClass), s = this._abortController?.signal ?? new AbortController().signal;
|
|
1496
|
+
return rt(
|
|
1562
1497
|
async () => {
|
|
1563
|
-
const r = await n.
|
|
1564
|
-
this.
|
|
1498
|
+
const r = await n.send(e, s);
|
|
1499
|
+
this.updatedAt = Date.now();
|
|
1565
1500
|
const o = this.applyData(r, !0);
|
|
1566
1501
|
return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
|
|
1567
1502
|
},
|
|
@@ -1570,7 +1505,7 @@ class fi {
|
|
|
1570
1505
|
);
|
|
1571
1506
|
}
|
|
1572
1507
|
runQueryImmediately() {
|
|
1573
|
-
this._abortController?.abort(), this._abortController = new AbortController(), this.
|
|
1508
|
+
this._abortController?.abort(), this._abortController = new AbortController(), this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.relayState.setPromise(this.runQuery());
|
|
1574
1509
|
}
|
|
1575
1510
|
runDebounced() {
|
|
1576
1511
|
if (this.relayState.isPending) return;
|
|
@@ -1583,35 +1518,41 @@ class fi {
|
|
|
1583
1518
|
// Public methods
|
|
1584
1519
|
// ======================================================
|
|
1585
1520
|
refetch = () => this.relayState.isPending ? this.relay : (this.runQueryImmediately(), this.relay);
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1521
|
+
markStale() {
|
|
1522
|
+
this.updatedAt = 0;
|
|
1523
|
+
}
|
|
1524
|
+
get resolvedParams() {
|
|
1525
|
+
return this.currentParams;
|
|
1526
|
+
}
|
|
1527
|
+
/** In-flight fetchNext promise for deduplication. */
|
|
1528
|
+
_fetchNextPromise = void 0;
|
|
1529
|
+
/** Cancels in-flight fetchNext requests. */
|
|
1530
|
+
_fetchNextAbort = void 0;
|
|
1531
|
+
fetchNext = () => {
|
|
1591
1532
|
if (this.updatedAt === void 0)
|
|
1592
|
-
throw new Error("Cannot call
|
|
1593
|
-
return this.
|
|
1594
|
-
(t) => (this.
|
|
1533
|
+
throw new Error("Cannot call __fetchNext before initial data has loaded");
|
|
1534
|
+
return this._fetchNextPromise !== void 0 ? this._fetchNextPromise : (queueMicrotask(() => this.rootEntity?.notify()), this._fetchNextPromise = this.runFetchNext().then(
|
|
1535
|
+
(t) => (this._fetchNextPromise = void 0, this.rootEntity?.notify(), t),
|
|
1595
1536
|
(t) => {
|
|
1596
|
-
throw this.
|
|
1537
|
+
throw this._fetchNextPromise = void 0, this.rootEntity?.notify(), t;
|
|
1597
1538
|
}
|
|
1598
|
-
), this.
|
|
1539
|
+
), this._fetchNextPromise);
|
|
1599
1540
|
};
|
|
1600
1541
|
get hasNext() {
|
|
1601
1542
|
if (this.rootEntity === void 0 || !this._executionCtx) return !1;
|
|
1602
|
-
const t = this.def.
|
|
1603
|
-
return t ? (this._executionCtx.resultData = this.rootEntity.data, t.
|
|
1543
|
+
const t = this.queryClient.getAdapter(this.def.statics.adapterClass);
|
|
1544
|
+
return t.hasNext ? (this._executionCtx.resultData = this.rootEntity.data, t.hasNext(this._executionCtx)) : !1;
|
|
1604
1545
|
}
|
|
1605
|
-
async
|
|
1546
|
+
async runFetchNext() {
|
|
1606
1547
|
const t = this.def;
|
|
1607
|
-
this.
|
|
1608
|
-
const e = this.
|
|
1609
|
-
n.
|
|
1610
|
-
const s = t.
|
|
1548
|
+
this._fetchNextAbort = new AbortController();
|
|
1549
|
+
const e = this._fetchNextAbort.signal, n = this.getOrCreateExecutionContext();
|
|
1550
|
+
n.resultData = this.rootEntity.data;
|
|
1551
|
+
const s = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1611
1552
|
return rt(
|
|
1612
1553
|
async () => {
|
|
1613
|
-
const r = await s.
|
|
1614
|
-
this.
|
|
1554
|
+
const r = await s.sendNext(n, e);
|
|
1555
|
+
this.updatedAt = Date.now();
|
|
1615
1556
|
const o = this.applyData(r, !0, !0);
|
|
1616
1557
|
return this.saveQueryMetadata(), o;
|
|
1617
1558
|
},
|
|
@@ -1629,31 +1570,30 @@ class fi {
|
|
|
1629
1570
|
return Date.now() - this.updatedAt >= t;
|
|
1630
1571
|
}
|
|
1631
1572
|
get isPaused() {
|
|
1632
|
-
const t = this.config?.networkMode ??
|
|
1633
|
-
if (t ===
|
|
1573
|
+
const t = this.config?.networkMode ?? L.Online;
|
|
1574
|
+
if (t === L.Always)
|
|
1634
1575
|
return !1;
|
|
1635
1576
|
const e = this.queryClient.networkManager.getOnlineSignal().value;
|
|
1636
1577
|
switch (t) {
|
|
1637
|
-
case
|
|
1578
|
+
case L.Online:
|
|
1638
1579
|
return !e;
|
|
1639
|
-
case
|
|
1580
|
+
case L.OfflineFirst:
|
|
1640
1581
|
return !e && this.updatedAt === void 0;
|
|
1641
1582
|
default:
|
|
1642
1583
|
return !1;
|
|
1643
1584
|
}
|
|
1644
1585
|
}
|
|
1645
1586
|
}
|
|
1646
|
-
class
|
|
1587
|
+
class di {
|
|
1647
1588
|
def;
|
|
1648
1589
|
queryClient;
|
|
1649
|
-
_lastResponse;
|
|
1650
1590
|
_inFlight = !1;
|
|
1651
1591
|
task;
|
|
1652
1592
|
constructor(t, e) {
|
|
1653
1593
|
this.def = t, this.queryClient = e, this.task = this.createTask();
|
|
1654
1594
|
}
|
|
1655
1595
|
createTask() {
|
|
1656
|
-
return
|
|
1596
|
+
return ve(
|
|
1657
1597
|
async (t) => {
|
|
1658
1598
|
if (this._inFlight)
|
|
1659
1599
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
@@ -1674,7 +1614,7 @@ class ui {
|
|
|
1674
1614
|
return t;
|
|
1675
1615
|
const n = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1676
1616
|
}), s = new st();
|
|
1677
|
-
return s.reset(void 0, void 0, n),
|
|
1617
|
+
return s.reset(void 0, void 0, n), Jt(t, e, s);
|
|
1678
1618
|
}
|
|
1679
1619
|
// ======================================================
|
|
1680
1620
|
// Effects processing
|
|
@@ -1687,48 +1627,52 @@ class ui {
|
|
|
1687
1627
|
t ?? {},
|
|
1688
1628
|
this.queryClient.getContext()
|
|
1689
1629
|
);
|
|
1690
|
-
r.result = e,
|
|
1630
|
+
r.result = e, n = r.getEffects();
|
|
1691
1631
|
} else if (this.def.effects !== void 0) {
|
|
1692
1632
|
const r = { params: t, result: e };
|
|
1693
|
-
n =
|
|
1633
|
+
n = W(this.def.effects, r);
|
|
1694
1634
|
}
|
|
1695
1635
|
if (n === void 0) return;
|
|
1696
1636
|
const s = this.queryClient;
|
|
1697
|
-
Z(n.creates, "create", s), Z(n.updates, "update", s), Z(n.deletes, "delete", s);
|
|
1637
|
+
Z(n.creates, "create", s), Z(n.updates, "update", s), Z(n.deletes, "delete", s), n.invalidates && s.invalidateQueries(n.invalidates);
|
|
1698
1638
|
}
|
|
1699
1639
|
// ======================================================
|
|
1700
1640
|
// Retry logic
|
|
1701
1641
|
// ======================================================
|
|
1702
1642
|
executeWithRetry(t) {
|
|
1703
|
-
const e = gt(this.def.config?.retry, !0);
|
|
1643
|
+
const e = gt(this.def.config?.retry, !0), n = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1644
|
+
if (!n.sendMutation)
|
|
1645
|
+
throw new Error(
|
|
1646
|
+
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1647
|
+
);
|
|
1704
1648
|
return rt(async () => {
|
|
1705
|
-
const
|
|
1649
|
+
const s = new AbortController(), r = et(
|
|
1706
1650
|
this.def.captured,
|
|
1707
1651
|
t ?? {},
|
|
1708
1652
|
this.queryClient.getContext()
|
|
1709
|
-
)
|
|
1710
|
-
return
|
|
1653
|
+
);
|
|
1654
|
+
return await n.sendMutation(r, s.signal);
|
|
1711
1655
|
}, e);
|
|
1712
1656
|
}
|
|
1713
1657
|
}
|
|
1714
|
-
function
|
|
1715
|
-
return typeof i == "string" ? i :
|
|
1658
|
+
function li(i) {
|
|
1659
|
+
return typeof i == "string" ? i : T(i).typenameValue;
|
|
1716
1660
|
}
|
|
1717
1661
|
function Z(i, t, e) {
|
|
1718
1662
|
if (i)
|
|
1719
1663
|
for (const [n, s] of i) {
|
|
1720
|
-
const r =
|
|
1664
|
+
const r = li(n);
|
|
1721
1665
|
r !== void 0 && e.applyMutationEvent({ type: t, typename: r, data: s });
|
|
1722
1666
|
}
|
|
1723
1667
|
}
|
|
1724
|
-
const
|
|
1725
|
-
function
|
|
1668
|
+
const se = "__eventSource";
|
|
1669
|
+
function re(i) {
|
|
1726
1670
|
return { field: i, segments: i.indexOf(".") !== -1 ? i.split(".") : void 0 };
|
|
1727
1671
|
}
|
|
1728
|
-
function
|
|
1729
|
-
return i.map(
|
|
1672
|
+
function hi(i) {
|
|
1673
|
+
return i.map(re);
|
|
1730
1674
|
}
|
|
1731
|
-
function
|
|
1675
|
+
function yi(i, t) {
|
|
1732
1676
|
if (t.segments === void 0) return i[t.field];
|
|
1733
1677
|
let e = i;
|
|
1734
1678
|
for (const n of t.segments) {
|
|
@@ -1737,16 +1681,16 @@ function hi(i, t) {
|
|
|
1737
1681
|
}
|
|
1738
1682
|
return e;
|
|
1739
1683
|
}
|
|
1740
|
-
function
|
|
1684
|
+
function oe(i, t) {
|
|
1741
1685
|
const e = [];
|
|
1742
1686
|
for (let n = 0; n < t.length; n++) {
|
|
1743
|
-
const s = t[n], r =
|
|
1687
|
+
const s = t[n], r = yi(i, s);
|
|
1744
1688
|
if (r === void 0) return;
|
|
1745
1689
|
e.push(s.field, r);
|
|
1746
1690
|
}
|
|
1747
|
-
return
|
|
1691
|
+
return D(e);
|
|
1748
1692
|
}
|
|
1749
|
-
function
|
|
1693
|
+
function pi(i, t) {
|
|
1750
1694
|
if (i === void 0) return;
|
|
1751
1695
|
const e = /* @__PURE__ */ new Map();
|
|
1752
1696
|
for (const [n, s] of i) {
|
|
@@ -1754,9 +1698,9 @@ function yi(i, t) {
|
|
|
1754
1698
|
let a = !0;
|
|
1755
1699
|
for (const [c, f] of r) {
|
|
1756
1700
|
let l;
|
|
1757
|
-
if (
|
|
1758
|
-
const
|
|
1759
|
-
l = ut(
|
|
1701
|
+
if (Pt(f)) {
|
|
1702
|
+
const u = Lt(f);
|
|
1703
|
+
l = ut(u, t);
|
|
1760
1704
|
} else
|
|
1761
1705
|
l = f;
|
|
1762
1706
|
if (l === void 0) {
|
|
@@ -1765,21 +1709,21 @@ function yi(i, t) {
|
|
|
1765
1709
|
}
|
|
1766
1710
|
o.push(c, l);
|
|
1767
1711
|
}
|
|
1768
|
-
a && e.set(n,
|
|
1712
|
+
a && e.set(n, D(o));
|
|
1769
1713
|
}
|
|
1770
1714
|
return e.size > 0 ? e : void 0;
|
|
1771
1715
|
}
|
|
1772
|
-
function
|
|
1716
|
+
function Rt(i, t) {
|
|
1773
1717
|
const e = i.get(t);
|
|
1774
1718
|
if (e !== void 0)
|
|
1775
1719
|
return e.map(([n]) => n).sort();
|
|
1776
1720
|
}
|
|
1777
|
-
class
|
|
1721
|
+
class gi {
|
|
1778
1722
|
fields;
|
|
1779
1723
|
fieldPaths;
|
|
1780
1724
|
_bindings = /* @__PURE__ */ new Map();
|
|
1781
1725
|
constructor(t) {
|
|
1782
|
-
this.fields = t, this.fieldPaths = t.map(
|
|
1726
|
+
this.fields = t, this.fieldPaths = t.map(re);
|
|
1783
1727
|
}
|
|
1784
1728
|
register(t, e) {
|
|
1785
1729
|
let n = this._bindings.get(t);
|
|
@@ -1797,14 +1741,14 @@ class pi {
|
|
|
1797
1741
|
}
|
|
1798
1742
|
}
|
|
1799
1743
|
function St(i) {
|
|
1800
|
-
return
|
|
1744
|
+
return D(i);
|
|
1801
1745
|
}
|
|
1802
|
-
class
|
|
1746
|
+
class vi {
|
|
1803
1747
|
_groups = /* @__PURE__ */ new Map();
|
|
1804
1748
|
getOrCreateGroup(t) {
|
|
1805
1749
|
const e = St(t);
|
|
1806
1750
|
let n = this._groups.get(e);
|
|
1807
|
-
return n === void 0 && (n = new
|
|
1751
|
+
return n === void 0 && (n = new gi(t), this._groups.set(e, n)), n;
|
|
1808
1752
|
}
|
|
1809
1753
|
register(t, e, n) {
|
|
1810
1754
|
this.getOrCreateGroup(e).register(t, n);
|
|
@@ -1816,18 +1760,18 @@ class gi {
|
|
|
1816
1760
|
registerBinding(t, e) {
|
|
1817
1761
|
const n = t._constraintHashes.get(e);
|
|
1818
1762
|
if (n === void 0) return;
|
|
1819
|
-
const s =
|
|
1763
|
+
const s = Rt(t._constraintFieldRefs, e);
|
|
1820
1764
|
s !== void 0 && this.register(n, s, t);
|
|
1821
1765
|
}
|
|
1822
1766
|
unregisterBinding(t, e) {
|
|
1823
1767
|
const n = t._constraintHashes.get(e);
|
|
1824
1768
|
if (n === void 0) return;
|
|
1825
|
-
const s =
|
|
1769
|
+
const s = Rt(t._constraintFieldRefs, e);
|
|
1826
1770
|
s !== void 0 && this.unregister(n, s, t);
|
|
1827
1771
|
}
|
|
1828
1772
|
routeEvent(t, e, n, s, r, o) {
|
|
1829
1773
|
for (const a of this._groups.values()) {
|
|
1830
|
-
const c =
|
|
1774
|
+
const c = oe(e, a.fieldPaths);
|
|
1831
1775
|
if (c === void 0) continue;
|
|
1832
1776
|
const f = a.getMatching(c);
|
|
1833
1777
|
if (f !== void 0)
|
|
@@ -1836,16 +1780,16 @@ class gi {
|
|
|
1836
1780
|
}
|
|
1837
1781
|
}
|
|
1838
1782
|
}
|
|
1839
|
-
function
|
|
1783
|
+
function At(i) {
|
|
1840
1784
|
const t = /* @__PURE__ */ new Set();
|
|
1841
1785
|
for (const e of i)
|
|
1842
1786
|
if (typeof e == "object" && e !== null) {
|
|
1843
|
-
const n =
|
|
1787
|
+
const n = k(e);
|
|
1844
1788
|
n !== void 0 && t.add(n);
|
|
1845
1789
|
}
|
|
1846
1790
|
return t;
|
|
1847
1791
|
}
|
|
1848
|
-
class
|
|
1792
|
+
class ae {
|
|
1849
1793
|
_queryClient;
|
|
1850
1794
|
_parent;
|
|
1851
1795
|
_constraintHashes;
|
|
@@ -1856,7 +1800,7 @@ class ce {
|
|
|
1856
1800
|
this._queryClient = n, this._parent = s, this._constraintHashes = r, this._constraintFieldRefs = e, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1857
1801
|
for (const a of t)
|
|
1858
1802
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1859
|
-
|
|
1803
|
+
J.add(this);
|
|
1860
1804
|
}
|
|
1861
1805
|
getValue() {
|
|
1862
1806
|
return this.instance.getValue();
|
|
@@ -1895,7 +1839,7 @@ class ce {
|
|
|
1895
1839
|
e !== -1 && t.splice(e, 1);
|
|
1896
1840
|
}
|
|
1897
1841
|
}
|
|
1898
|
-
class
|
|
1842
|
+
class _i {
|
|
1899
1843
|
_notifier;
|
|
1900
1844
|
_items;
|
|
1901
1845
|
_keys;
|
|
@@ -1903,29 +1847,29 @@ class vi {
|
|
|
1903
1847
|
_queryClient;
|
|
1904
1848
|
_parent;
|
|
1905
1849
|
constructor(t, e, n, s, r, o) {
|
|
1906
|
-
this._notifier = at(), this._items = n, this._keys =
|
|
1850
|
+
this._notifier = at(), this._items = n, this._keys = At(n), this._queryClient = t, this._parent = e;
|
|
1907
1851
|
const a = s !== void 0 && r !== void 0, c = o !== void 0;
|
|
1908
|
-
(a || c) && (this._outputSignal =
|
|
1852
|
+
(a || c) && (this._outputSignal = _e(() => {
|
|
1909
1853
|
this._notifier.consume();
|
|
1910
1854
|
let f = this._items;
|
|
1911
1855
|
if (a) {
|
|
1912
1856
|
const l = [];
|
|
1913
|
-
for (const
|
|
1914
|
-
if (typeof
|
|
1915
|
-
l.push(
|
|
1857
|
+
for (const u of f) {
|
|
1858
|
+
if (typeof u != "object" || u === null) {
|
|
1859
|
+
l.push(u);
|
|
1916
1860
|
continue;
|
|
1917
1861
|
}
|
|
1918
|
-
const y =
|
|
1862
|
+
const y = k(u);
|
|
1919
1863
|
if (y === void 0) {
|
|
1920
|
-
l.push(
|
|
1864
|
+
l.push(u);
|
|
1921
1865
|
continue;
|
|
1922
1866
|
}
|
|
1923
1867
|
const v = t.entityMap.getEntity(y);
|
|
1924
1868
|
if (v === void 0) {
|
|
1925
|
-
l.push(
|
|
1869
|
+
l.push(u);
|
|
1926
1870
|
continue;
|
|
1927
1871
|
}
|
|
1928
|
-
v.consume(),
|
|
1872
|
+
v.consume(), oe(v.data, s) === r && l.push(u);
|
|
1929
1873
|
}
|
|
1930
1874
|
f = l;
|
|
1931
1875
|
}
|
|
@@ -1970,10 +1914,10 @@ class vi {
|
|
|
1970
1914
|
}
|
|
1971
1915
|
reset(t) {
|
|
1972
1916
|
const e = this._items, n = Array.isArray(t) ? t : [];
|
|
1973
|
-
this._items = n, this._keys =
|
|
1917
|
+
this._items = n, this._keys = At(n);
|
|
1974
1918
|
for (const s of n)
|
|
1975
1919
|
if (typeof s == "object" && s !== null) {
|
|
1976
|
-
const r =
|
|
1920
|
+
const r = k(s);
|
|
1977
1921
|
if (r !== void 0) {
|
|
1978
1922
|
const o = this._queryClient.entityMap.getEntity(r);
|
|
1979
1923
|
o !== void 0 && this._parent.addChildRef(o);
|
|
@@ -1981,7 +1925,7 @@ class vi {
|
|
|
1981
1925
|
}
|
|
1982
1926
|
for (const s of e)
|
|
1983
1927
|
if (typeof s == "object" && s !== null) {
|
|
1984
|
-
const r =
|
|
1928
|
+
const r = k(s);
|
|
1985
1929
|
if (r !== void 0) {
|
|
1986
1930
|
const o = this._queryClient.entityMap.getEntity(r);
|
|
1987
1931
|
o !== void 0 && this._parent.removeChildRef(o);
|
|
@@ -1993,20 +1937,20 @@ class vi {
|
|
|
1993
1937
|
if (Array.isArray(t))
|
|
1994
1938
|
for (const e of t) {
|
|
1995
1939
|
if (typeof e != "object" || e === null) continue;
|
|
1996
|
-
const n =
|
|
1940
|
+
const n = k(e);
|
|
1997
1941
|
n !== void 0 && this.add(n, e);
|
|
1998
1942
|
}
|
|
1999
1943
|
}
|
|
2000
1944
|
_findIndex(t) {
|
|
2001
1945
|
for (let e = 0; e < this._items.length; e++) {
|
|
2002
1946
|
const n = this._items[e];
|
|
2003
|
-
if (typeof n == "object" && n !== null &&
|
|
1947
|
+
if (typeof n == "object" && n !== null && k(n) === t)
|
|
2004
1948
|
return e;
|
|
2005
1949
|
}
|
|
2006
1950
|
return -1;
|
|
2007
1951
|
}
|
|
2008
1952
|
}
|
|
2009
|
-
class
|
|
1953
|
+
class mi {
|
|
2010
1954
|
_notifier;
|
|
2011
1955
|
_value;
|
|
2012
1956
|
_createdKeys;
|
|
@@ -2047,30 +1991,30 @@ class _i {
|
|
|
2047
1991
|
append(t) {
|
|
2048
1992
|
}
|
|
2049
1993
|
}
|
|
2050
|
-
function
|
|
1994
|
+
function ce(i, t, e, n, s) {
|
|
2051
1995
|
let r = i.constraintFieldRefs;
|
|
2052
1996
|
if (r === void 0) {
|
|
2053
1997
|
r = /* @__PURE__ */ new Map();
|
|
2054
1998
|
for (const f of i.entityDefs) {
|
|
2055
1999
|
const l = f.typenameValue;
|
|
2056
|
-
l !== void 0 && r.set(l, [[
|
|
2000
|
+
l !== void 0 && r.set(l, [[se, e.key]]);
|
|
2057
2001
|
}
|
|
2058
2002
|
}
|
|
2059
|
-
const o =
|
|
2003
|
+
const o = pi(r, n) ?? /* @__PURE__ */ new Map();
|
|
2060
2004
|
let a;
|
|
2061
2005
|
if (i.type === ct.Array) {
|
|
2062
2006
|
let f, l;
|
|
2063
2007
|
if (i.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2064
|
-
for (const [
|
|
2065
|
-
const y = o.get(
|
|
2008
|
+
for (const [u] of i.constraintFieldRefs) {
|
|
2009
|
+
const y = o.get(u);
|
|
2066
2010
|
if (y !== void 0) {
|
|
2067
2011
|
l = y;
|
|
2068
|
-
const v = i.constraintFieldRefs.get(
|
|
2069
|
-
v !== void 0 && (f =
|
|
2012
|
+
const v = i.constraintFieldRefs.get(u);
|
|
2013
|
+
v !== void 0 && (f = hi(v.map(([p]) => p)));
|
|
2070
2014
|
break;
|
|
2071
2015
|
}
|
|
2072
2016
|
}
|
|
2073
|
-
a = new
|
|
2017
|
+
a = new _i(
|
|
2074
2018
|
s,
|
|
2075
2019
|
e,
|
|
2076
2020
|
Array.isArray(t) ? t : [],
|
|
@@ -2079,7 +2023,7 @@ function fe(i, t, e, n, s) {
|
|
|
2079
2023
|
i.sort
|
|
2080
2024
|
);
|
|
2081
2025
|
} else
|
|
2082
|
-
a = new
|
|
2026
|
+
a = new mi(
|
|
2083
2027
|
s,
|
|
2084
2028
|
e,
|
|
2085
2029
|
t,
|
|
@@ -2087,7 +2031,7 @@ function fe(i, t, e, n, s) {
|
|
|
2087
2031
|
i.onUpdate,
|
|
2088
2032
|
i.onDelete
|
|
2089
2033
|
);
|
|
2090
|
-
const c = new
|
|
2034
|
+
const c = new ae(
|
|
2091
2035
|
i.entityDefs,
|
|
2092
2036
|
r,
|
|
2093
2037
|
s,
|
|
@@ -2097,85 +2041,85 @@ function fe(i, t, e, n, s) {
|
|
|
2097
2041
|
);
|
|
2098
2042
|
return e.liveCollections.push(c), s.registerLiveCollection(c), c;
|
|
2099
2043
|
}
|
|
2100
|
-
const
|
|
2044
|
+
const fe = Object.entries, ue = Object.prototype;
|
|
2101
2045
|
function tt(i, t, e, n = !1) {
|
|
2102
2046
|
const s = i.queryClient;
|
|
2103
2047
|
s.currentParseId++;
|
|
2104
2048
|
const r = i.seen, o = /* @__PURE__ */ new Map();
|
|
2105
|
-
return { data:
|
|
2049
|
+
return { data: U(t, r, s, e, o, n), entityRefs: o };
|
|
2106
2050
|
}
|
|
2107
|
-
function
|
|
2051
|
+
function U(i, t, e, n, s, r) {
|
|
2108
2052
|
if (typeof i != "object" || i === null) return i;
|
|
2109
2053
|
const o = t.get(i);
|
|
2110
2054
|
if (o !== void 0)
|
|
2111
|
-
return
|
|
2055
|
+
return wi(o, t, e, n, s, r);
|
|
2112
2056
|
if (Array.isArray(i)) {
|
|
2113
2057
|
for (let a = 0; a < i.length; a++) {
|
|
2114
2058
|
const c = i[a];
|
|
2115
|
-
typeof c == "object" && c !== null && !(c instanceof
|
|
2059
|
+
typeof c == "object" && c !== null && !(c instanceof q) && !x.has(c) && (i[a] = U(c, t, e, n, s, r));
|
|
2116
2060
|
}
|
|
2117
2061
|
return i;
|
|
2118
2062
|
}
|
|
2119
|
-
if (Object.getPrototypeOf(i) ===
|
|
2063
|
+
if (Object.getPrototypeOf(i) === ue && !x.has(i)) {
|
|
2120
2064
|
const a = i;
|
|
2121
2065
|
for (const c of Object.keys(a)) {
|
|
2122
2066
|
const f = a[c];
|
|
2123
|
-
typeof f == "object" && f !== null && !(f instanceof
|
|
2067
|
+
typeof f == "object" && f !== null && !(f instanceof q) && !x.has(f) && (a[c] = U(f, t, e, n, s, r));
|
|
2124
2068
|
}
|
|
2125
2069
|
}
|
|
2126
2070
|
return i;
|
|
2127
2071
|
}
|
|
2128
|
-
function
|
|
2129
|
-
return typeof i == "object" && i !== null && !(i instanceof
|
|
2072
|
+
function de(i) {
|
|
2073
|
+
return typeof i == "object" && i !== null && !(i instanceof q) && !x.has(i);
|
|
2130
2074
|
}
|
|
2131
|
-
function
|
|
2132
|
-
const { key: o, data: a, shape: c, rawKeys: f } = i, l = c.shape,
|
|
2133
|
-
if (v ? (
|
|
2075
|
+
function wi(i, t, e, n, s, r) {
|
|
2076
|
+
const { key: o, data: a, shape: c, rawKeys: f } = i, l = c.shape, u = e.prepareEntity(o, a, c), y = u.data, v = y !== a, p = v && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2077
|
+
if (v ? (le(
|
|
2134
2078
|
l,
|
|
2135
2079
|
a,
|
|
2136
2080
|
y,
|
|
2137
2081
|
f,
|
|
2138
|
-
|
|
2082
|
+
u,
|
|
2139
2083
|
y,
|
|
2140
2084
|
t,
|
|
2141
2085
|
e,
|
|
2142
2086
|
n,
|
|
2143
2087
|
p,
|
|
2144
2088
|
r
|
|
2145
|
-
),
|
|
2146
|
-
for (const
|
|
2147
|
-
const
|
|
2148
|
-
if (Array.isArray(
|
|
2149
|
-
for (const
|
|
2150
|
-
if (typeof
|
|
2151
|
-
const
|
|
2152
|
-
if (
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2089
|
+
), u.notify()) : he(l, a, u, a, t, e, n, p, r), r && u.liveCollections.length > 0)
|
|
2090
|
+
for (const w of u.liveCollections) {
|
|
2091
|
+
const I = w.instance.getRawValue();
|
|
2092
|
+
if (Array.isArray(I))
|
|
2093
|
+
for (const O of I) {
|
|
2094
|
+
if (typeof O != "object" || O === null) continue;
|
|
2095
|
+
const K = x.get(O);
|
|
2096
|
+
if (K === void 0) continue;
|
|
2097
|
+
const R = e.entityMap.getEntity(K);
|
|
2098
|
+
R !== void 0 && p.set(R, (p.get(R) ?? 0) + 1);
|
|
2155
2099
|
}
|
|
2156
2100
|
}
|
|
2157
|
-
|
|
2158
|
-
const g =
|
|
2159
|
-
return s.set(
|
|
2160
|
-
}
|
|
2161
|
-
function
|
|
2162
|
-
for (const [
|
|
2163
|
-
if (!(n !== void 0 && !n.has(
|
|
2164
|
-
if (
|
|
2165
|
-
const v = e[
|
|
2166
|
-
v instanceof
|
|
2101
|
+
u.setChildRefs(p.size > 0 ? p : void 0, n);
|
|
2102
|
+
const g = u.getProxy(c);
|
|
2103
|
+
return s.set(u, (s.get(u) ?? 0) + 1), g;
|
|
2104
|
+
}
|
|
2105
|
+
function le(i, t, e, n, s, r, o, a, c, f, l) {
|
|
2106
|
+
for (const [u, y] of fe(i))
|
|
2107
|
+
if (!(n !== void 0 && !n.has(u)))
|
|
2108
|
+
if (de(t[u]) && (t[u] = U(t[u], o, a, c, f, l)), y instanceof _ && y._liveConfig !== void 0) {
|
|
2109
|
+
const v = e[u];
|
|
2110
|
+
v instanceof ae ? l ? v.append(t[u]) : v.reset(t[u]) : e[u] = ce(
|
|
2167
2111
|
y._liveConfig,
|
|
2168
|
-
t[
|
|
2112
|
+
t[u],
|
|
2169
2113
|
s,
|
|
2170
2114
|
r,
|
|
2171
2115
|
a
|
|
2172
2116
|
);
|
|
2173
2117
|
} else {
|
|
2174
|
-
const v = t[
|
|
2118
|
+
const v = t[u], p = e[u];
|
|
2175
2119
|
if (ot(v) && ot(p)) {
|
|
2176
2120
|
const g = y instanceof _ && y.shape !== void 0 ? y.shape : void 0;
|
|
2177
2121
|
if (g !== void 0)
|
|
2178
|
-
|
|
2122
|
+
le(
|
|
2179
2123
|
g,
|
|
2180
2124
|
v,
|
|
2181
2125
|
p,
|
|
@@ -2189,18 +2133,18 @@ function he(i, t, e, n, s, r, o, a, c, f, l) {
|
|
|
2189
2133
|
l
|
|
2190
2134
|
);
|
|
2191
2135
|
else
|
|
2192
|
-
for (const
|
|
2193
|
-
p[
|
|
2194
|
-
e[
|
|
2136
|
+
for (const w of Object.keys(v))
|
|
2137
|
+
p[w] = v[w];
|
|
2138
|
+
e[u] = p;
|
|
2195
2139
|
} else
|
|
2196
|
-
e[
|
|
2140
|
+
e[u] = v;
|
|
2197
2141
|
}
|
|
2198
2142
|
}
|
|
2199
|
-
function
|
|
2200
|
-
for (const [f, l] of
|
|
2143
|
+
function he(i, t, e, n, s, r, o, a, c) {
|
|
2144
|
+
for (const [f, l] of fe(i))
|
|
2201
2145
|
if (f in t)
|
|
2202
|
-
if (
|
|
2203
|
-
t[f] =
|
|
2146
|
+
if (de(t[f]) && (t[f] = U(t[f], s, r, o, a, c)), l instanceof _ && l._liveConfig !== void 0)
|
|
2147
|
+
t[f] = ce(
|
|
2204
2148
|
l._liveConfig,
|
|
2205
2149
|
t[f],
|
|
2206
2150
|
e,
|
|
@@ -2208,24 +2152,24 @@ function ye(i, t, e, n, s, r, o, a, c) {
|
|
|
2208
2152
|
r
|
|
2209
2153
|
);
|
|
2210
2154
|
else {
|
|
2211
|
-
const
|
|
2212
|
-
if (ot(
|
|
2155
|
+
const u = t[f];
|
|
2156
|
+
if (ot(u)) {
|
|
2213
2157
|
const y = l instanceof _ && l.shape !== void 0 ? l.shape : void 0;
|
|
2214
|
-
y !== void 0 &&
|
|
2158
|
+
y !== void 0 && he(y, u, e, n, s, r, o, a, c);
|
|
2215
2159
|
}
|
|
2216
2160
|
}
|
|
2217
2161
|
}
|
|
2218
2162
|
function ot(i) {
|
|
2219
|
-
return typeof i == "object" && i !== null && !Array.isArray(i) && Object.getPrototypeOf(i) ===
|
|
2163
|
+
return typeof i == "object" && i !== null && !Array.isArray(i) && Object.getPrototypeOf(i) === ue && !x.has(i);
|
|
2220
2164
|
}
|
|
2221
|
-
function
|
|
2165
|
+
function ki(i) {
|
|
2222
2166
|
if (i !== void 0)
|
|
2223
2167
|
return typeof i == "string" ? i : typeof i == "function" ? i() : i.value;
|
|
2224
2168
|
}
|
|
2225
2169
|
function Ei(i) {
|
|
2226
|
-
return
|
|
2170
|
+
return me(i);
|
|
2227
2171
|
}
|
|
2228
|
-
function
|
|
2172
|
+
function Dt(i) {
|
|
2229
2173
|
if (i === void 0)
|
|
2230
2174
|
return;
|
|
2231
2175
|
const t = {};
|
|
@@ -2233,11 +2177,8 @@ function At(i) {
|
|
|
2233
2177
|
Ei(n) ? t[e] = n.value : t[e] = n;
|
|
2234
2178
|
return t;
|
|
2235
2179
|
}
|
|
2236
|
-
const vt = (i, t) =>
|
|
2237
|
-
class
|
|
2238
|
-
constructor(t, e = { fetch, log: console }, n, s) {
|
|
2239
|
-
this.context = e, this.isServer = typeof window > "u", this.store = t, this.gcManager = s ?? (this.isServer ? new xe() : new Ce(this.handleEviction, this.context.evictionMultiplier)), this.networkManager = n ?? new ie(), this.entityMap = new oi((r, o, a) => this.store.saveEntity(r, o, a)), this.store.purgeStaleQueries?.();
|
|
2240
|
-
}
|
|
2180
|
+
const vt = (i, t) => D([i.statics.id, t]);
|
|
2181
|
+
class Fi {
|
|
2241
2182
|
entityMap;
|
|
2242
2183
|
queryInstances = /* @__PURE__ */ new Map();
|
|
2243
2184
|
mutationInstances = /* @__PURE__ */ new Map();
|
|
@@ -2246,9 +2187,53 @@ class Ai {
|
|
|
2246
2187
|
isServer;
|
|
2247
2188
|
store;
|
|
2248
2189
|
currentParseId = 0;
|
|
2190
|
+
context;
|
|
2249
2191
|
typenameRegistry = /* @__PURE__ */ new Map();
|
|
2250
2192
|
constraintRegistry = /* @__PURE__ */ new Map();
|
|
2251
2193
|
mergedDefCache = /* @__PURE__ */ new Map();
|
|
2194
|
+
adapters = /* @__PURE__ */ new Map();
|
|
2195
|
+
networkUnsubscribe;
|
|
2196
|
+
constructor(t = {}) {
|
|
2197
|
+
const {
|
|
2198
|
+
store: e = new be(new Ce()),
|
|
2199
|
+
log: n,
|
|
2200
|
+
evictionMultiplier: s,
|
|
2201
|
+
adapters: r,
|
|
2202
|
+
networkManager: o,
|
|
2203
|
+
gcManager: a,
|
|
2204
|
+
...c
|
|
2205
|
+
} = t;
|
|
2206
|
+
this.isServer = typeof window > "u", this.store = e, this.context = { ...c, log: n ?? console, evictionMultiplier: s }, this.gcManager = t.gcManager ?? (this.isServer ? new Re() : new Oe(this.handleEviction, s)), this.networkManager = t.networkManager ?? new ee(), this.entityMap = new ci((u, y, v) => this.store.saveEntity(u, y, v));
|
|
2207
|
+
for (const u of t.adapters ?? [])
|
|
2208
|
+
this.adapters.set(u.constructor, u), u.register(this);
|
|
2209
|
+
const f = this.networkManager.getOnlineSignal(), l = we(() => f.value);
|
|
2210
|
+
this.networkUnsubscribe = l.addListener(
|
|
2211
|
+
() => {
|
|
2212
|
+
const u = f.value;
|
|
2213
|
+
for (const y of this.adapters.values())
|
|
2214
|
+
y.onNetworkStatusChange?.(u);
|
|
2215
|
+
},
|
|
2216
|
+
{ skipInitial: !0 }
|
|
2217
|
+
), this.store.purgeStaleQueries?.();
|
|
2218
|
+
}
|
|
2219
|
+
/**
|
|
2220
|
+
* Returns the registered adapter instance for the given adapter class.
|
|
2221
|
+
* Throws if no adapter of that class has been registered.
|
|
2222
|
+
*/
|
|
2223
|
+
getAdapter(t) {
|
|
2224
|
+
let e = this.adapters.get(t);
|
|
2225
|
+
if (!e) {
|
|
2226
|
+
try {
|
|
2227
|
+
e = new t();
|
|
2228
|
+
} catch {
|
|
2229
|
+
throw new Error(
|
|
2230
|
+
`No adapter registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, adapters: [new ${t.name}(...)] })`
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
this.adapters.set(t, e), e.register(this);
|
|
2234
|
+
}
|
|
2235
|
+
return e;
|
|
2236
|
+
}
|
|
2252
2237
|
getContext() {
|
|
2253
2238
|
return this.context;
|
|
2254
2239
|
}
|
|
@@ -2282,7 +2267,7 @@ class Ai {
|
|
|
2282
2267
|
activateQuery(t) {
|
|
2283
2268
|
const { def: e, queryKey: n, storageKey: s, config: r } = t;
|
|
2284
2269
|
this.store.activateQuery(e, s);
|
|
2285
|
-
const o = r?.gcTime ??
|
|
2270
|
+
const o = r?.gcTime ?? kt;
|
|
2286
2271
|
this.gcManager.cancel(n, o);
|
|
2287
2272
|
}
|
|
2288
2273
|
loadCachedQuery(t, e) {
|
|
@@ -2295,7 +2280,7 @@ class Ai {
|
|
|
2295
2280
|
getQuery(t, e) {
|
|
2296
2281
|
const n = vt(t, e);
|
|
2297
2282
|
let s = this.queryInstances.get(n);
|
|
2298
|
-
return s === void 0 && (s = new
|
|
2283
|
+
return s === void 0 && (s = new ui(t, this, n, e), this.queryInstances.set(n, s)), s.relay;
|
|
2299
2284
|
}
|
|
2300
2285
|
/**
|
|
2301
2286
|
* Gets or creates a MutationResult for the given mutation definition.
|
|
@@ -2304,7 +2289,7 @@ class Ai {
|
|
|
2304
2289
|
getMutation(t) {
|
|
2305
2290
|
const e = t.id;
|
|
2306
2291
|
let n = this.mutationInstances.get(e);
|
|
2307
|
-
return n === void 0 && (n = new
|
|
2292
|
+
return n === void 0 && (n = new di(t, this), this.mutationInstances.set(e, n)), n.task;
|
|
2308
2293
|
}
|
|
2309
2294
|
/**
|
|
2310
2295
|
* Parse data: validates, formats, produces parsed entity data objects.
|
|
@@ -2313,7 +2298,7 @@ class Ai {
|
|
|
2313
2298
|
parseData(t, e, n) {
|
|
2314
2299
|
const s = this.context.log?.warn ?? (() => {
|
|
2315
2300
|
}), r = new st();
|
|
2316
|
-
return r.reset(this, n, s), { data:
|
|
2301
|
+
return r.reset(this, n, s), { data: Jt(t, e, r), ctx: r };
|
|
2317
2302
|
}
|
|
2318
2303
|
/**
|
|
2319
2304
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
@@ -2329,8 +2314,8 @@ class Ai {
|
|
|
2329
2314
|
* found in the store by the standard entity pipeline).
|
|
2330
2315
|
*/
|
|
2331
2316
|
parseAndApplyRootEntity(t, e, n, s, r = !1, o) {
|
|
2332
|
-
typeof n.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[
|
|
2333
|
-
const a = this.parseData(t, n, o), c = tt(a.ctx, a.data, s, r), f =
|
|
2317
|
+
typeof n.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Ft] = e);
|
|
2318
|
+
const a = this.parseData(t, n, o), c = tt(a.ctx, a.data, s, r), f = x.get(c.data);
|
|
2334
2319
|
return this.entityMap.getEntity(f);
|
|
2335
2320
|
}
|
|
2336
2321
|
prepareEntity(t, e, n) {
|
|
@@ -2346,45 +2331,55 @@ class Ai {
|
|
|
2346
2331
|
if (r === void 0 || typeof r == "symbol") return;
|
|
2347
2332
|
const o = t.data, a = t.id !== void 0 ? t.id : e === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[r];
|
|
2348
2333
|
if (a === void 0) return;
|
|
2349
|
-
const c =
|
|
2334
|
+
const c = D([n, a]), f = t.__eventSource, l = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2350
2335
|
if (e === "delete") {
|
|
2351
|
-
const g =
|
|
2336
|
+
const g = u !== void 0 ? u.data : l;
|
|
2352
2337
|
this.routeEvent(n, g, c, e, f, void 0, g);
|
|
2353
2338
|
return;
|
|
2354
2339
|
}
|
|
2355
2340
|
try {
|
|
2356
2341
|
const g = this.context.log?.warn ?? (() => {
|
|
2357
|
-
}),
|
|
2358
|
-
|
|
2342
|
+
}), w = new st();
|
|
2343
|
+
w.reset(
|
|
2359
2344
|
this,
|
|
2360
2345
|
void 0,
|
|
2361
2346
|
g,
|
|
2362
2347
|
/* isPartialEvent */
|
|
2363
2348
|
!0
|
|
2364
2349
|
);
|
|
2365
|
-
const
|
|
2366
|
-
tt(
|
|
2350
|
+
const I = Xe(l, s, w);
|
|
2351
|
+
tt(w, I, !0);
|
|
2367
2352
|
} catch (g) {
|
|
2368
|
-
if (this.context.log?.warn?.("Failed to apply mutation event", g),
|
|
2369
|
-
const
|
|
2370
|
-
|
|
2353
|
+
if (this.context.log?.warn?.("Failed to apply mutation event", g), u === void 0) {
|
|
2354
|
+
const w = this.entityMap.getEntity(c);
|
|
2355
|
+
w !== void 0 && w.evict();
|
|
2371
2356
|
}
|
|
2372
2357
|
return;
|
|
2373
2358
|
}
|
|
2374
2359
|
const y = this.entityMap.getEntity(c);
|
|
2375
2360
|
if (y === void 0) return;
|
|
2376
2361
|
this.entityMap.save(y);
|
|
2377
|
-
const v =
|
|
2362
|
+
const v = u === void 0;
|
|
2378
2363
|
let p = !1;
|
|
2379
2364
|
this.routeEvent(n, y.data, c, e, f, () => {
|
|
2380
2365
|
p = !0;
|
|
2381
2366
|
}), v && !p && y.evict();
|
|
2382
2367
|
}
|
|
2383
2368
|
// ======================================================
|
|
2369
|
+
// Query Invalidation
|
|
2370
|
+
// ======================================================
|
|
2371
|
+
invalidateQueries(t) {
|
|
2372
|
+
for (const e of t) {
|
|
2373
|
+
const n = Array.isArray(e), s = n ? e[0] : e, r = n ? e[1] : void 0, a = V.for(s).statics.id;
|
|
2374
|
+
for (const [, c] of this.queryInstances)
|
|
2375
|
+
c.def.statics.id === a && (r === void 0 || Ci(c.resolvedParams, r)) && c.markStale();
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
// ======================================================
|
|
2384
2379
|
// In-Memory GC
|
|
2385
2380
|
// ======================================================
|
|
2386
2381
|
handleEviction = (t, e) => {
|
|
2387
|
-
if (e ===
|
|
2382
|
+
if (e === z.Query) {
|
|
2388
2383
|
const s = this.queryInstances.get(t);
|
|
2389
2384
|
if (s === void 0) return;
|
|
2390
2385
|
s.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
@@ -2394,11 +2389,11 @@ class Ai {
|
|
|
2394
2389
|
n !== void 0 && n.evict();
|
|
2395
2390
|
};
|
|
2396
2391
|
// ======================================================
|
|
2397
|
-
// Constraint Registry (Live
|
|
2392
|
+
// Constraint Registry (Live Data)
|
|
2398
2393
|
// ======================================================
|
|
2399
2394
|
getOrCreateMatcher(t) {
|
|
2400
2395
|
let e = this.constraintRegistry.get(t);
|
|
2401
|
-
return e === void 0 && (e = new
|
|
2396
|
+
return e === void 0 && (e = new vi(), this.constraintRegistry.set(t, e)), e;
|
|
2402
2397
|
}
|
|
2403
2398
|
registerLiveCollection(t) {
|
|
2404
2399
|
for (const [e, n] of t._entityDefsByTypename)
|
|
@@ -2413,41 +2408,50 @@ class Ai {
|
|
|
2413
2408
|
routeEvent(t, e, n, s, r, o, a) {
|
|
2414
2409
|
const c = this.constraintRegistry.get(t);
|
|
2415
2410
|
if (c === void 0) return;
|
|
2416
|
-
const f = r !== void 0 ? { ...e, [
|
|
2411
|
+
const f = r !== void 0 ? { ...e, [se]: r } : e;
|
|
2417
2412
|
c.routeEvent(t, f, n, s, o, a);
|
|
2418
2413
|
}
|
|
2419
2414
|
destroy() {
|
|
2420
|
-
this.
|
|
2415
|
+
this.networkUnsubscribe?.(), this.gcManager.destroy(), this.networkManager.destroy();
|
|
2416
|
+
for (const t of this.adapters.values())
|
|
2417
|
+
t.destroy?.();
|
|
2418
|
+
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2421
2419
|
}
|
|
2422
2420
|
}
|
|
2423
|
-
const
|
|
2421
|
+
const bi = Mt(void 0);
|
|
2422
|
+
function Ci(i, t) {
|
|
2423
|
+
if (i === void 0) return !1;
|
|
2424
|
+
for (const e in t)
|
|
2425
|
+
if (i[e] !== t[e]) return !1;
|
|
2426
|
+
return !0;
|
|
2427
|
+
}
|
|
2424
2428
|
export {
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2429
|
+
Q as A,
|
|
2430
|
+
qt as E,
|
|
2431
|
+
Oe as G,
|
|
2432
|
+
j as L,
|
|
2433
|
+
d as M,
|
|
2434
|
+
ee as N,
|
|
2435
|
+
Ft as Q,
|
|
2436
|
+
B as R,
|
|
2433
2437
|
_ as V,
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2438
|
+
ct as a,
|
|
2439
|
+
Di as b,
|
|
2440
|
+
L as c,
|
|
2441
|
+
Re as d,
|
|
2442
|
+
ie as e,
|
|
2443
|
+
Ii as f,
|
|
2444
|
+
Fi as g,
|
|
2445
|
+
bi as h,
|
|
2446
|
+
fi as i,
|
|
2447
|
+
Ai as j,
|
|
2448
|
+
Mi as k,
|
|
2449
|
+
jt as l,
|
|
2450
|
+
De as m,
|
|
2451
|
+
W as n,
|
|
2452
|
+
ki as o,
|
|
2449
2453
|
Ni as q,
|
|
2450
|
-
|
|
2451
|
-
|
|
2454
|
+
Gt as r,
|
|
2455
|
+
He as t
|
|
2452
2456
|
};
|
|
2453
|
-
//# sourceMappingURL=QueryClient-
|
|
2457
|
+
//# sourceMappingURL=QueryClient-KH0Ex_8m.js.map
|