fetchium 0.2.0 → 0.2.2
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 +14 -0
- package/dist/cjs/development/QueryAdapter-DUo338ga.js.map +1 -1
- package/dist/cjs/development/QueryClient-BZpqASy3.js +2 -0
- package/dist/cjs/development/QueryClient-BZpqASy3.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-Dk0gznwX.js → development/mutation-COeBCn7p.js} +2 -2
- package/dist/cjs/development/mutation-COeBCn7p.js.map +1 -0
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/development/topic/index.js.map +1 -1
- package/dist/cjs/production/QueryAdapter-DUo338ga.js.map +1 -1
- package/dist/cjs/production/QueryClient-BmoHLlvu.js +2 -0
- package/dist/cjs/production/QueryClient-BmoHLlvu.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-wUhcGxKl.js → production/mutation-CfFdNkYV.js} +2 -2
- package/dist/cjs/production/mutation-CfFdNkYV.js.map +1 -0
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/cjs/production/topic/index.js.map +1 -1
- package/dist/esm/QueryAdapter.d.ts +11 -0
- package/dist/esm/QueryAdapter.d.ts.map +1 -1
- package/dist/esm/QueryClient.d.ts +5 -5
- package/dist/esm/QueryClient.d.ts.map +1 -1
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -1
- package/dist/esm/development/{QueryClient-BajBmpnA.js → QueryClient-4co72n4i.js} +636 -628
- package/dist/esm/development/QueryClient-4co72n4i.js.map +1 -0
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-DAOZE4Ok.js → mutation-BMAWDUP4.js} +2 -2
- package/dist/esm/development/mutation-BMAWDUP4.js.map +1 -0
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +2 -2
- package/dist/esm/development/topic/index.js +1 -1
- package/dist/esm/development/topic/index.js.map +1 -1
- package/dist/esm/mutation.d.ts +3 -3
- package/dist/esm/mutation.d.ts.map +1 -1
- package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -1
- package/dist/esm/production/{QueryClient-KH0Ex_8m.js → QueryClient-CS4iUKWj.js} +782 -774
- package/dist/esm/production/QueryClient-CS4iUKWj.js.map +1 -0
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-C7BOChR2.js → mutation-B1EiA34B.js} +2 -2
- package/dist/esm/production/mutation-B1EiA34B.js.map +1 -0
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +2 -2
- package/dist/esm/production/topic/index.js +1 -1
- package/dist/esm/production/topic/index.js.map +1 -1
- package/dist/esm/query.d.ts +3 -3
- package/dist/esm/query.d.ts.map +1 -1
- package/dist/esm/retry.d.ts.map +1 -1
- package/dist/esm/topic/TopicQuery.d.ts +2 -1
- package/dist/esm/topic/TopicQuery.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/docs/api/fetchium.md +2 -2
- package/plugin/docs/api/stores-async.md +9 -3
- package/plugin/docs/api/stores-sync.md +9 -3
- package/plugin/docs/core/entities.md +2 -2
- package/plugin/docs/core/queries.md +12 -19
- package/plugin/docs/data/mutations.md +1 -1
- package/plugin/docs/guides/auth.md +65 -42
- package/plugin/docs/guides/error-handling.md +9 -5
- package/plugin/docs/guides/offline.md +11 -8
- package/plugin/docs/guides/testing.md +1 -1
- package/plugin/docs/quickstart.md +1 -1
- package/plugin/docs/reference/rest-queries.md +9 -9
- package/plugin/docs/setup/project-setup.md +5 -5
- package/dist/cjs/development/QueryClient-m7BzCIe9.js +0 -2
- package/dist/cjs/development/QueryClient-m7BzCIe9.js.map +0 -1
- package/dist/cjs/development/mutation-wUhcGxKl.js.map +0 -1
- package/dist/cjs/production/QueryClient-4T90peFN.js +0 -2
- package/dist/cjs/production/QueryClient-4T90peFN.js.map +0 -1
- package/dist/cjs/production/mutation-Dk0gznwX.js.map +0 -1
- package/dist/esm/development/QueryClient-BajBmpnA.js.map +0 -1
- package/dist/esm/development/mutation-DAOZE4Ok.js.map +0 -1
- package/dist/esm/production/QueryClient-KH0Ex_8m.js.map +0 -1
- package/dist/esm/production/mutation-C7BOChR2.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { notifier as
|
|
2
|
-
import { registerCustomHash as
|
|
3
|
-
import { d as
|
|
4
|
-
import { SyncQueryStore as
|
|
1
|
+
import { notifier as ut, relay as Pt, setScopeOwner as Ee, reactiveMethod as be, signal as jt, context as $t, getContext as Ce, task as Se, reactiveSignal as Oe, isSignal as Re, watcher as xe } from "signalium";
|
|
2
|
+
import { registerCustomHash as Ae, hashValue as N } from "signalium/utils";
|
|
3
|
+
import { d as Lt } from "./shared-DcuVH8Pf.js";
|
|
4
|
+
import { SyncQueryStore as Ne, MemoryPersistentStore as De } from "./stores/sync.js";
|
|
5
5
|
var V = /* @__PURE__ */ ((e) => (e.Always = "always", e.Online = "online", e.OfflineFirst = "offlineFirst", e))(V || {}), d = /* @__PURE__ */ ((e) => (e[e.UNDEFINED = 1] = "UNDEFINED", e[e.NULL = 2] = "NULL", e[e.NUMBER = 4] = "NUMBER", e[e.STRING = 8] = "STRING", e[e.BOOLEAN = 16] = "BOOLEAN", e[e.OBJECT = 32] = "OBJECT", e[e.ARRAY = 64] = "ARRAY", e[e.ID = 128] = "ID", e[e.RECORD = 256] = "RECORD", e[e.UNION = 512] = "UNION", e[e.ENTITY = 1024] = "ENTITY", e[e.HAS_FORMAT = 4096] = "HAS_FORMAT", e[e.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", e[e.PARSE_RESULT = 16384] = "PARSE_RESULT", e[e.LIVE = 32768] = "LIVE", e))(d || {});
|
|
6
|
-
const
|
|
7
|
-
var
|
|
6
|
+
const I = /* @__PURE__ */ Symbol("array"), F = /* @__PURE__ */ Symbol("record"), Ut = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
|
+
var dt = /* @__PURE__ */ ((e) => (e[e.Array = 0] = "Array", e[e.Value = 1] = "Value", e))(dt || {});
|
|
8
8
|
class B {
|
|
9
9
|
type;
|
|
10
10
|
entityDefs;
|
|
@@ -14,8 +14,8 @@ class B {
|
|
|
14
14
|
onCreate;
|
|
15
15
|
onUpdate;
|
|
16
16
|
onDelete;
|
|
17
|
-
constructor(t, n, i,
|
|
18
|
-
this.type = t, this.entityDefs = n, this.constraintFieldRefs = i, this.sort =
|
|
17
|
+
constructor(t, n, i, r, s, o, a, c) {
|
|
18
|
+
this.type = t, this.entityDefs = n, this.constraintFieldRefs = i, this.sort = r, this.valueType = s, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
|
|
19
19
|
}
|
|
20
20
|
static array(t, n, i) {
|
|
21
21
|
return new B(
|
|
@@ -29,15 +29,15 @@ class B {
|
|
|
29
29
|
void 0
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
-
static value(t, n, i,
|
|
32
|
+
static value(t, n, i, r, s, o) {
|
|
33
33
|
return new B(
|
|
34
34
|
1,
|
|
35
35
|
t,
|
|
36
36
|
n,
|
|
37
37
|
void 0,
|
|
38
38
|
i,
|
|
39
|
-
s,
|
|
40
39
|
r,
|
|
40
|
+
s,
|
|
41
41
|
o
|
|
42
42
|
);
|
|
43
43
|
}
|
|
@@ -62,15 +62,15 @@ class Ie {
|
|
|
62
62
|
}
|
|
63
63
|
_tick = () => {
|
|
64
64
|
const { _currentFlush: t, _nextFlush: n, _onEvict: i } = this;
|
|
65
|
-
for (const [
|
|
66
|
-
i(
|
|
65
|
+
for (const [r, s] of t)
|
|
66
|
+
i(r, s);
|
|
67
67
|
this._currentFlush = n, this._nextFlush = /* @__PURE__ */ new Map();
|
|
68
68
|
};
|
|
69
69
|
destroy() {
|
|
70
70
|
clearInterval(this._intervalId);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
class
|
|
73
|
+
class Fe {
|
|
74
74
|
_buckets = /* @__PURE__ */ new Map();
|
|
75
75
|
_nextTickEntries = /* @__PURE__ */ new Map();
|
|
76
76
|
_nextTickScheduled = !1;
|
|
@@ -86,9 +86,9 @@ class De {
|
|
|
86
86
|
o.set(t, i), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const { _buckets:
|
|
90
|
-
let
|
|
91
|
-
|
|
89
|
+
const { _buckets: r } = this;
|
|
90
|
+
let s = r.get(n);
|
|
91
|
+
s || (s = new Ie(n, this._onEvict, this._multiplier), r.set(n, s)), s.schedule(t, i);
|
|
92
92
|
}
|
|
93
93
|
cancel(t, n) {
|
|
94
94
|
if (n !== 1 / 0) {
|
|
@@ -102,8 +102,8 @@ class De {
|
|
|
102
102
|
_flushNextTick = () => {
|
|
103
103
|
const { _nextTickEntries: t, _onEvict: n } = this;
|
|
104
104
|
this._nextTickScheduled = !1;
|
|
105
|
-
for (const [i,
|
|
106
|
-
n(i,
|
|
105
|
+
for (const [i, r] of t)
|
|
106
|
+
n(i, r);
|
|
107
107
|
t.clear();
|
|
108
108
|
};
|
|
109
109
|
destroy() {
|
|
@@ -113,7 +113,7 @@ class De {
|
|
|
113
113
|
t.clear(), n.clear();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
class
|
|
116
|
+
class Me {
|
|
117
117
|
schedule(t, n, i) {
|
|
118
118
|
}
|
|
119
119
|
cancel(t, n) {
|
|
@@ -121,70 +121,70 @@ class Fe {
|
|
|
121
121
|
destroy() {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const W = /* @__PURE__ */ Symbol("fieldRef"),
|
|
125
|
-
function
|
|
124
|
+
const W = /* @__PURE__ */ Symbol("fieldRef"), D = /* @__PURE__ */ Symbol("fieldRefPath"), ht = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), z = /* @__PURE__ */ Symbol("CANCEL_PROXY"), ke = /\[([^\]]+)\]/g;
|
|
125
|
+
function qt(e) {
|
|
126
126
|
const t = {
|
|
127
127
|
[W]: !0,
|
|
128
|
-
[
|
|
128
|
+
[D]: e
|
|
129
129
|
};
|
|
130
|
-
return new Proxy(t,
|
|
130
|
+
return new Proxy(t, Te);
|
|
131
131
|
}
|
|
132
|
-
const
|
|
132
|
+
const Te = {
|
|
133
133
|
get(e, t) {
|
|
134
134
|
if (t === W) return !0;
|
|
135
|
-
if (t ===
|
|
135
|
+
if (t === D) return e[D];
|
|
136
136
|
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
|
|
137
|
-
const i = e[
|
|
137
|
+
const i = e[D];
|
|
138
138
|
return () => `[${i.join(".")}]`;
|
|
139
139
|
}
|
|
140
140
|
if (typeof t == "symbol") return;
|
|
141
|
-
const n = e[
|
|
142
|
-
return
|
|
141
|
+
const n = e[D];
|
|
142
|
+
return qt([...n, t]);
|
|
143
143
|
},
|
|
144
144
|
has(e, t) {
|
|
145
|
-
return t === W || t ===
|
|
145
|
+
return t === W || t === D;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
function qt(e) {
|
|
149
|
-
return typeof e == "object" && e !== null && e[W] === !0;
|
|
150
|
-
}
|
|
151
148
|
function Vt(e) {
|
|
152
|
-
return e[
|
|
149
|
+
return typeof e == "object" && e !== null && e[W] === !0;
|
|
153
150
|
}
|
|
154
151
|
function Kt(e) {
|
|
152
|
+
return e[D];
|
|
153
|
+
}
|
|
154
|
+
function Bt(e) {
|
|
155
155
|
let t = !1;
|
|
156
156
|
return new Proxy(e, {
|
|
157
|
-
set(n, i,
|
|
158
|
-
return n[i] =
|
|
157
|
+
set(n, i, r) {
|
|
158
|
+
return n[i] = r, !0;
|
|
159
159
|
},
|
|
160
160
|
get(n, i) {
|
|
161
161
|
if (t)
|
|
162
162
|
throw new Error("Definition proxy accessed after extraction. Avoid arrow functions that capture `this`.");
|
|
163
|
-
return i ===
|
|
163
|
+
return i === ht ? n : i === z ? () => {
|
|
164
164
|
t = !0;
|
|
165
|
-
} : typeof i == "symbol" ? n[i] :
|
|
165
|
+
} : typeof i == "symbol" ? n[i] : qt([i]);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
const t = e[
|
|
169
|
+
function Pe(e) {
|
|
170
|
+
const t = e[ht];
|
|
171
171
|
e[z]();
|
|
172
172
|
const n = {};
|
|
173
|
-
for (const
|
|
174
|
-
n[
|
|
173
|
+
for (const s of Object.getOwnPropertyNames(t))
|
|
174
|
+
n[s] = t[s];
|
|
175
175
|
const i = {};
|
|
176
|
-
let
|
|
177
|
-
for (;
|
|
178
|
-
for (const
|
|
179
|
-
if (
|
|
180
|
-
const o = Object.getOwnPropertyDescriptor(
|
|
181
|
-
typeof o.value == "function" && !(
|
|
176
|
+
let r = Object.getPrototypeOf(t);
|
|
177
|
+
for (; r && r !== Object.prototype; ) {
|
|
178
|
+
for (const s of Object.getOwnPropertyNames(r)) {
|
|
179
|
+
if (s === "constructor") continue;
|
|
180
|
+
const o = Object.getOwnPropertyDescriptor(r, s);
|
|
181
|
+
typeof o.value == "function" && !(s in i) && (i[s] = o.value);
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
r = Object.getPrototypeOf(r);
|
|
184
184
|
}
|
|
185
185
|
return { fields: n, methods: i };
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function lt(e, t) {
|
|
188
188
|
let n = t;
|
|
189
189
|
for (const i of e) {
|
|
190
190
|
if (n == null) return;
|
|
@@ -192,17 +192,17 @@ function ht(e, t) {
|
|
|
192
192
|
}
|
|
193
193
|
return n;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
return e.replace(
|
|
197
|
-
const
|
|
198
|
-
return
|
|
195
|
+
function je(e, t) {
|
|
196
|
+
return e.replace(ke, (n, i) => {
|
|
197
|
+
const r = i.split("."), s = lt(r, t);
|
|
198
|
+
return s != null ? encodeURIComponent(String(s)) : "";
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
function J(e, t) {
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
202
|
+
if (Vt(e))
|
|
203
|
+
return lt(Kt(e), t);
|
|
204
204
|
if (typeof e == "string")
|
|
205
|
-
return
|
|
205
|
+
return je(e, t);
|
|
206
206
|
if (Array.isArray(e))
|
|
207
207
|
return e.map((n) => J(n, t));
|
|
208
208
|
if (typeof e == "object" && e !== null && Object.getPrototypeOf(e) === Object.prototype) {
|
|
@@ -214,49 +214,49 @@ function J(e, t) {
|
|
|
214
214
|
return e;
|
|
215
215
|
}
|
|
216
216
|
function it(e, t, n) {
|
|
217
|
-
const i = e.fields,
|
|
217
|
+
const i = e.fields, r = e.methods, s = { params: t }, o = {};
|
|
218
218
|
for (const [a, c] of Object.entries(i))
|
|
219
|
-
o[a] = J(c,
|
|
219
|
+
o[a] = J(c, s);
|
|
220
220
|
o.params = t, o.context = n;
|
|
221
|
-
for (const [a, c] of Object.entries(
|
|
221
|
+
for (const [a, c] of Object.entries(r))
|
|
222
222
|
o[a] = c.bind(o);
|
|
223
223
|
return o;
|
|
224
224
|
}
|
|
225
|
-
class
|
|
225
|
+
class Qt {
|
|
226
226
|
static cache;
|
|
227
227
|
constructor() {
|
|
228
|
-
return
|
|
228
|
+
return Bt(this);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
let
|
|
231
|
+
const Yt = Object.entries, rt = Object.keys;
|
|
232
|
+
let Gt = () => {
|
|
233
233
|
};
|
|
234
234
|
{
|
|
235
|
-
const t = (i,
|
|
236
|
-
if (i.size !==
|
|
237
|
-
for (const
|
|
238
|
-
if (!
|
|
235
|
+
const t = (i, r) => {
|
|
236
|
+
if (i.size !== r.size) return !1;
|
|
237
|
+
for (const s of i)
|
|
238
|
+
if (!r.has(s)) return !1;
|
|
239
239
|
return !0;
|
|
240
|
-
}, n = (i,
|
|
241
|
-
if (i ===
|
|
242
|
-
if (typeof i != typeof
|
|
240
|
+
}, n = (i, r) => {
|
|
241
|
+
if (i === r) return !0;
|
|
242
|
+
if (typeof i != typeof r) return !1;
|
|
243
243
|
if (typeof i == "number") {
|
|
244
|
-
const
|
|
245
|
-
if ((i & 65535) !== (
|
|
246
|
-
const o = i >> 16, a =
|
|
244
|
+
const s = r;
|
|
245
|
+
if ((i & 65535) !== (s & 65535)) return !1;
|
|
246
|
+
const o = i >> 16, a = s >> 16;
|
|
247
247
|
return !(o !== 0 && a !== 0 && o !== a);
|
|
248
248
|
}
|
|
249
|
-
if (typeof i == "string") return i ===
|
|
250
|
-
if (i instanceof Set &&
|
|
251
|
-
return t(i,
|
|
252
|
-
if (i instanceof m &&
|
|
253
|
-
const
|
|
254
|
-
if ((
|
|
255
|
-
const a =
|
|
249
|
+
if (typeof i == "string") return i === r;
|
|
250
|
+
if (i instanceof Set && r instanceof Set)
|
|
251
|
+
return t(i, r);
|
|
252
|
+
if (i instanceof m && r instanceof m) {
|
|
253
|
+
const s = i.mask, o = r.mask;
|
|
254
|
+
if ((s & 65535) !== (o & 65535)) return !1;
|
|
255
|
+
const a = s >> 16, c = o >> 16;
|
|
256
256
|
if (a !== 0 && c !== 0 && a !== c) return !1;
|
|
257
|
-
if (i.shape ===
|
|
258
|
-
if (i.shape !== void 0 &&
|
|
259
|
-
const f = i.shape, h =
|
|
257
|
+
if (i.shape === r.shape) return !0;
|
|
258
|
+
if (i.shape !== void 0 && r.shape !== void 0 && typeof i.shape == "object" && typeof r.shape == "object") {
|
|
259
|
+
const f = i.shape, h = r.shape;
|
|
260
260
|
for (const u of Object.keys(f))
|
|
261
261
|
if (u in h && !n(f[u], h[u])) return !1;
|
|
262
262
|
for (const u of Object.keys(h))
|
|
@@ -266,41 +266,41 @@ let Yt = () => {
|
|
|
266
266
|
}
|
|
267
267
|
return !1;
|
|
268
268
|
};
|
|
269
|
-
|
|
270
|
-
if (!n(
|
|
269
|
+
Gt = (i, r, s, o) => {
|
|
270
|
+
if (!n(s, o))
|
|
271
271
|
throw new Error(
|
|
272
|
-
`[fetchium] Entity typename '${i}' has incompatible type for field '${
|
|
272
|
+
`[fetchium] Entity typename '${i}' has incompatible type for field '${r}' across different entity definitions`
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function St(e) {
|
|
277
277
|
return typeof e == "number" ? e | d.UNDEFINED : e instanceof m ? (e.mask & d.UNDEFINED) !== 0 ? e : m.cloneWith(e, d.UNDEFINED) : e;
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function Ot(e) {
|
|
280
280
|
return e instanceof m && (e.mask & d.OBJECT) !== 0 && (e.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function Ht(e, t, n) {
|
|
283
283
|
const i = /* @__PURE__ */ new Set();
|
|
284
|
-
for (const
|
|
285
|
-
if (
|
|
286
|
-
for (const o of Object.keys(
|
|
284
|
+
for (const s of e)
|
|
285
|
+
if (s !== void 0)
|
|
286
|
+
for (const o of Object.keys(s))
|
|
287
287
|
i.add(o);
|
|
288
|
-
const
|
|
289
|
-
for (const
|
|
288
|
+
const r = {};
|
|
289
|
+
for (const s of i) {
|
|
290
290
|
let o = 0, a;
|
|
291
291
|
const c = [];
|
|
292
292
|
let f = !0;
|
|
293
293
|
for (const h of e) {
|
|
294
|
-
const u = h?.[
|
|
295
|
-
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !
|
|
294
|
+
const u = h?.[s];
|
|
295
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !Ot(u) && Gt(n, s, a, u), Ot(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
296
296
|
}
|
|
297
297
|
if (f && o > 0) {
|
|
298
|
-
const h =
|
|
299
|
-
s
|
|
298
|
+
const h = Ht(c, t, n), u = new m(d.OBJECT, h);
|
|
299
|
+
r[s] = o < t ? St(u) : u;
|
|
300
300
|
} else
|
|
301
|
-
s
|
|
301
|
+
r[s] = o < t ? St(a) : a;
|
|
302
302
|
}
|
|
303
|
-
return
|
|
303
|
+
return r;
|
|
304
304
|
}
|
|
305
305
|
class m {
|
|
306
306
|
mask;
|
|
@@ -331,12 +331,12 @@ class m {
|
|
|
331
331
|
* Live data configuration (shared by LiveArray and LiveValue).
|
|
332
332
|
*/
|
|
333
333
|
_liveConfig = void 0;
|
|
334
|
-
constructor(t, n, i,
|
|
335
|
-
this.mask = t, this.shape = n, this.values = i, this.typenameField =
|
|
334
|
+
constructor(t, n, i, r, s, o) {
|
|
335
|
+
this.mask = t, this.shape = n, this.values = i, this.typenameField = r, this.typenameValue = s, this.idField = o;
|
|
336
336
|
}
|
|
337
337
|
static merge(t) {
|
|
338
338
|
if (t.length === 1) return t[0];
|
|
339
|
-
const n = t.length, i = t.map((f) => f.shape),
|
|
339
|
+
const n = t.length, i = t.map((f) => f.shape), r = t[0].typenameValue ?? "(unknown)", s = Ht(i, n, r);
|
|
340
340
|
let o, a, c;
|
|
341
341
|
for (const f of t) {
|
|
342
342
|
if (o === void 0 && f.idField !== void 0)
|
|
@@ -349,7 +349,7 @@ class m {
|
|
|
349
349
|
}
|
|
350
350
|
return new m(
|
|
351
351
|
d.ENTITY | d.OBJECT,
|
|
352
|
-
|
|
352
|
+
s,
|
|
353
353
|
void 0,
|
|
354
354
|
a,
|
|
355
355
|
c,
|
|
@@ -375,10 +375,10 @@ class $ extends Set {
|
|
|
375
375
|
super(t), this.lowercaseMap = /* @__PURE__ */ new Map();
|
|
376
376
|
for (const n of t)
|
|
377
377
|
if (typeof n == "string") {
|
|
378
|
-
const i = n.toLowerCase(),
|
|
379
|
-
if (
|
|
378
|
+
const i = n.toLowerCase(), r = this.lowercaseMap.get(i);
|
|
379
|
+
if (r !== void 0)
|
|
380
380
|
throw new Error(
|
|
381
|
-
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${
|
|
381
|
+
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${r}' and '${n}' both become '${i}'`
|
|
382
382
|
);
|
|
383
383
|
this.lowercaseMap.set(i, n);
|
|
384
384
|
}
|
|
@@ -403,28 +403,28 @@ class $ extends Set {
|
|
|
403
403
|
return t;
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
let t =
|
|
406
|
+
const $e = 1128875347;
|
|
407
|
+
Ae($, (e) => {
|
|
408
|
+
let t = $e;
|
|
409
409
|
for (const n of e)
|
|
410
410
|
t += N(n);
|
|
411
411
|
return t >>> 0;
|
|
412
412
|
});
|
|
413
|
-
function
|
|
413
|
+
function yt(e, t) {
|
|
414
414
|
return new m(e, t);
|
|
415
415
|
}
|
|
416
|
-
function $e(e) {
|
|
417
|
-
return lt(d.ARRAY, e);
|
|
418
|
-
}
|
|
419
416
|
function Le(e) {
|
|
420
|
-
return
|
|
417
|
+
return yt(d.ARRAY, e);
|
|
421
418
|
}
|
|
422
419
|
function Ue(e) {
|
|
423
|
-
return
|
|
420
|
+
return yt(d.RECORD | d.OBJECT, e);
|
|
424
421
|
}
|
|
425
|
-
function
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
function qe(e) {
|
|
423
|
+
return yt(d.PARSE_RESULT, e);
|
|
424
|
+
}
|
|
425
|
+
function Wt(e, t) {
|
|
426
|
+
let n = e, i, r, s;
|
|
427
|
+
for (const [o, a] of Yt(t))
|
|
428
428
|
switch (typeof a) {
|
|
429
429
|
case "number":
|
|
430
430
|
if ((a & d.ID) !== 0) {
|
|
@@ -434,9 +434,9 @@ function Ht(e, t) {
|
|
|
434
434
|
}
|
|
435
435
|
break;
|
|
436
436
|
case "string":
|
|
437
|
-
if (
|
|
437
|
+
if (r !== void 0 && r !== o)
|
|
438
438
|
throw new Error(`Duplicate typename field: ${o}`);
|
|
439
|
-
|
|
439
|
+
r = o, s = a;
|
|
440
440
|
break;
|
|
441
441
|
case "object":
|
|
442
442
|
if (a instanceof $ || a instanceof Set)
|
|
@@ -444,26 +444,26 @@ function Ht(e, t) {
|
|
|
444
444
|
a.mask & d.LIVE && (n |= d.LIVE);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
|
-
return new m(n, t, void 0,
|
|
447
|
+
return new m(n, t, void 0, r, s, i);
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return
|
|
449
|
+
function Ve(e) {
|
|
450
|
+
return Wt(d.OBJECT, e);
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function Rt(e, t, n) {
|
|
453
453
|
const i = e.mask;
|
|
454
454
|
if ((i & d.UNION) !== 0) {
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
if (n !== void 0 && n !==
|
|
455
|
+
const r = e;
|
|
456
|
+
if (r.typenameField !== void 0) {
|
|
457
|
+
if (n !== void 0 && n !== r.typenameField)
|
|
458
458
|
throw new Error(
|
|
459
|
-
`Union typename field conflict: Cannot merge unions with different typename fields ('${n}' vs '${
|
|
459
|
+
`Union typename field conflict: Cannot merge unions with different typename fields ('${n}' vs '${r.typenameField}')`
|
|
460
460
|
);
|
|
461
|
-
n =
|
|
461
|
+
n = r.typenameField;
|
|
462
462
|
}
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
465
|
-
for (const o of [...
|
|
466
|
-
const a =
|
|
463
|
+
const s = r.shape;
|
|
464
|
+
if (s !== void 0)
|
|
465
|
+
for (const o of [...rt(s), I, F]) {
|
|
466
|
+
const a = s[o];
|
|
467
467
|
if (t[o] !== void 0 && t[o] !== a)
|
|
468
468
|
throw new Error(
|
|
469
469
|
`Union merge conflict: Duplicate typename value '${String(o)}' found when merging nested unions (${String(t[o])} vs ${String(a)})`
|
|
@@ -471,133 +471,133 @@ function Ot(e, t, n) {
|
|
|
471
471
|
t[o] = a;
|
|
472
472
|
}
|
|
473
473
|
} else if ((i & d.ARRAY) !== 0) {
|
|
474
|
-
if (t[
|
|
474
|
+
if (t[I] !== void 0)
|
|
475
475
|
throw new Error("Array shape already defined");
|
|
476
|
-
t[
|
|
476
|
+
t[I] = e.shape;
|
|
477
477
|
} else if ((i & d.RECORD) !== 0) {
|
|
478
478
|
if (t[F] !== void 0)
|
|
479
479
|
throw new Error("Record shape already defined");
|
|
480
480
|
t[F] = e.shape;
|
|
481
481
|
} else {
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
482
|
+
const r = e.typenameField, s = e.typenameValue;
|
|
483
|
+
if (s === void 0)
|
|
484
484
|
throw new Error(
|
|
485
485
|
"Object definitions must have a typename to be in a union with other objects, records, or arrays"
|
|
486
486
|
);
|
|
487
|
-
if (n !== void 0 &&
|
|
487
|
+
if (n !== void 0 && r !== n)
|
|
488
488
|
throw new Error("Object definitions must have the same typename field to be in the same union");
|
|
489
|
-
n =
|
|
489
|
+
n = r, t[s] = e;
|
|
490
490
|
}
|
|
491
491
|
return n;
|
|
492
492
|
}
|
|
493
|
-
function
|
|
493
|
+
function pt(...e) {
|
|
494
494
|
const t = e;
|
|
495
|
-
let n = 0, i = 0,
|
|
495
|
+
let n = 0, i = 0, r, s, o, a, c = 0;
|
|
496
496
|
for (const h of t) {
|
|
497
497
|
if (typeof h == "number") {
|
|
498
498
|
n |= h;
|
|
499
499
|
continue;
|
|
500
500
|
}
|
|
501
501
|
if (h instanceof Set) {
|
|
502
|
-
if (
|
|
503
|
-
|
|
502
|
+
if (s === void 0)
|
|
503
|
+
s = new Set(h);
|
|
504
504
|
else
|
|
505
505
|
for (const u of h)
|
|
506
|
-
|
|
506
|
+
s.add(u);
|
|
507
507
|
continue;
|
|
508
508
|
}
|
|
509
509
|
if (i++, c |= h.mask, i === 1) {
|
|
510
|
-
|
|
510
|
+
r = h;
|
|
511
511
|
continue;
|
|
512
512
|
}
|
|
513
|
-
i === 2 && (o = /* @__PURE__ */ Object.create(null), a =
|
|
513
|
+
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Rt(r, o, a)), a = Rt(h, o, a);
|
|
514
514
|
}
|
|
515
515
|
if (i === 0)
|
|
516
|
-
return
|
|
516
|
+
return s === void 0 ? n : n === 0 ? s : new m(n | d.UNION, void 0, s);
|
|
517
517
|
if (i === 1)
|
|
518
|
-
return m.cloneWith(
|
|
518
|
+
return m.cloneWith(r, n);
|
|
519
519
|
const f = n | c | d.UNION;
|
|
520
|
-
return new m(f, o,
|
|
520
|
+
return new m(f, o, s, a);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function gt(e, t, n) {
|
|
523
523
|
const i = e;
|
|
524
524
|
if (typeof i == "number")
|
|
525
525
|
return i | t;
|
|
526
526
|
if (i instanceof Set)
|
|
527
|
-
return
|
|
528
|
-
let
|
|
529
|
-
return
|
|
530
|
-
}
|
|
531
|
-
const Ve = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new WeakMap();
|
|
532
|
-
function Qe(e) {
|
|
533
|
-
return pt(e, d.UNDEFINED | d.NULL, Be);
|
|
527
|
+
return pt(e, t);
|
|
528
|
+
let r = n.get(i);
|
|
529
|
+
return r === void 0 && (r = m.cloneWith(i, t), n.set(i, r)), r;
|
|
534
530
|
}
|
|
531
|
+
const Ke = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new WeakMap(), Qe = /* @__PURE__ */ new WeakMap();
|
|
535
532
|
function Ye(e) {
|
|
536
|
-
return
|
|
533
|
+
return gt(e, d.UNDEFINED | d.NULL, Qe);
|
|
537
534
|
}
|
|
538
535
|
function Ge(e) {
|
|
539
|
-
return
|
|
536
|
+
return gt(e, d.UNDEFINED, Ke);
|
|
540
537
|
}
|
|
541
538
|
function He(e) {
|
|
542
|
-
return e;
|
|
539
|
+
return gt(e, d.NULL, Be);
|
|
543
540
|
}
|
|
544
541
|
function We(e) {
|
|
542
|
+
return e;
|
|
543
|
+
}
|
|
544
|
+
function ze(e) {
|
|
545
545
|
return /* @__PURE__ */ new Set([e]);
|
|
546
546
|
}
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
const
|
|
550
|
-
let
|
|
551
|
-
const
|
|
547
|
+
const zt = ((...e) => new Set(e));
|
|
548
|
+
zt.caseInsensitive = (...e) => new $(e);
|
|
549
|
+
const mt = 16;
|
|
550
|
+
let Je = 0;
|
|
551
|
+
const st = [], Jt = [], Xt = /* @__PURE__ */ new Map(), Zt = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new WeakSet();
|
|
552
552
|
class Q {
|
|
553
553
|
_raw;
|
|
554
554
|
_formatted;
|
|
555
555
|
_parsed;
|
|
556
556
|
_formatId;
|
|
557
557
|
constructor(t, n, i) {
|
|
558
|
-
this._raw = t, this._formatId = n, i ? (this._formatted =
|
|
558
|
+
this._raw = t, this._formatId = n, i ? (this._formatted = st[n](t), this._parsed = !0) : this._parsed = !1, Z.add(this);
|
|
559
559
|
}
|
|
560
560
|
getValue() {
|
|
561
|
-
return this._parsed || (this._formatted =
|
|
561
|
+
return this._parsed || (this._formatted = st[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
562
562
|
}
|
|
563
563
|
toJSON() {
|
|
564
|
-
return this._parsed ?
|
|
564
|
+
return this._parsed ? Jt[this._formatId](this._formatted) : this._raw;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
const t =
|
|
567
|
+
function Xe(e) {
|
|
568
|
+
const t = Xt.get(e);
|
|
569
569
|
if (t === void 0)
|
|
570
570
|
throw new Error(`Format ${e} not registered`);
|
|
571
571
|
return t;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
const t = e >>
|
|
575
|
-
return
|
|
573
|
+
function xt(e) {
|
|
574
|
+
const t = e >> mt;
|
|
575
|
+
return Zt.get(t);
|
|
576
576
|
}
|
|
577
|
-
function
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
const o =
|
|
581
|
-
|
|
577
|
+
function te(e, t, n, i, r) {
|
|
578
|
+
const s = Je++;
|
|
579
|
+
st[s] = n, Jt[s] = i, Zt.set(s, e);
|
|
580
|
+
const o = r?.eager ?? !0, c = s << mt | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
581
|
+
Xt.set(e, c);
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
te(
|
|
584
584
|
"date",
|
|
585
585
|
d.STRING,
|
|
586
586
|
(e) => {
|
|
587
587
|
const t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
588
588
|
if (!t)
|
|
589
589
|
throw new Error(`Invalid date string: ${e}. Expected YYYY-MM-DD format.`);
|
|
590
|
-
const [, n, i,
|
|
591
|
-
if (isNaN(
|
|
590
|
+
const [, n, i, r] = t, s = new Date(Date.UTC(parseInt(n, 10), parseInt(i, 10) - 1, parseInt(r, 10)));
|
|
591
|
+
if (isNaN(s.getTime()))
|
|
592
592
|
throw new Error(`Invalid date string: ${e}`);
|
|
593
|
-
return
|
|
593
|
+
return s;
|
|
594
594
|
},
|
|
595
595
|
(e) => {
|
|
596
596
|
const t = e.getUTCFullYear(), n = String(e.getUTCMonth() + 1).padStart(2, "0"), i = String(e.getUTCDate()).padStart(2, "0");
|
|
597
597
|
return `${t}-${n}-${i}`;
|
|
598
598
|
}
|
|
599
599
|
);
|
|
600
|
-
|
|
600
|
+
te(
|
|
601
601
|
"date-time",
|
|
602
602
|
d.STRING,
|
|
603
603
|
(e) => {
|
|
@@ -608,109 +608,109 @@ Zt(
|
|
|
608
608
|
},
|
|
609
609
|
(e) => e.toISOString()
|
|
610
610
|
);
|
|
611
|
-
const
|
|
611
|
+
const At = /* @__PURE__ */ new WeakMap();
|
|
612
612
|
function j(e) {
|
|
613
|
-
let t =
|
|
613
|
+
let t = At.get(e);
|
|
614
614
|
if (t === void 0) {
|
|
615
|
-
const n = new e(), i = n[
|
|
615
|
+
const n = new e(), i = n[ht] ?? n;
|
|
616
616
|
n[z] && n[z]();
|
|
617
|
-
const
|
|
618
|
-
for (const [f, h] of
|
|
617
|
+
const r = {};
|
|
618
|
+
for (const [f, h] of Yt(i)) {
|
|
619
619
|
if (!(typeof h == "number" || typeof h == "string" || h instanceof Set || h instanceof m || h instanceof $))
|
|
620
620
|
throw new Error(
|
|
621
621
|
`[fetchium] Entity '${e.name}' field '${f}' has an invalid type definition. All entity fields must be type definitions (e.g. t.string, t.number, t.entity(...), etc). Got: ${typeof h == "object" ? h?.constructor?.name ?? typeof h : typeof h}`
|
|
622
622
|
);
|
|
623
|
-
|
|
623
|
+
r[f] = h;
|
|
624
624
|
}
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
const f =
|
|
628
|
-
if (f !==
|
|
625
|
+
const s = Object.getPrototypeOf(e.prototype);
|
|
626
|
+
if (s != null) {
|
|
627
|
+
const f = s.constructor;
|
|
628
|
+
if (f !== Qt && typeof f == "function") {
|
|
629
629
|
const u = j(f).shape;
|
|
630
|
-
for (const l of
|
|
631
|
-
if (l in
|
|
630
|
+
for (const l of rt(u))
|
|
631
|
+
if (l in r && r[l] !== u[l])
|
|
632
632
|
throw new Error(`Cannot extend: field '${l}' already exists in type definition`);
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
635
|
const o = {}, a = e.prototype;
|
|
636
636
|
for (const f of Object.getOwnPropertyNames(a))
|
|
637
637
|
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
638
|
-
t =
|
|
638
|
+
t = Wt(d.ENTITY | d.OBJECT, r), t._entityClass = e, rt(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
639
639
|
const c = e;
|
|
640
|
-
c.cache && (t._entityCache = c.cache),
|
|
640
|
+
c.cache && (t._entityCache = c.cache), At.set(e, t);
|
|
641
641
|
}
|
|
642
642
|
return t;
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function Ze(e) {
|
|
645
645
|
return j(e);
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function ee(e, t) {
|
|
648
648
|
if (t == null) return;
|
|
649
649
|
const n = /* @__PURE__ */ new Map();
|
|
650
650
|
if (Array.isArray(t))
|
|
651
651
|
for (const i of t) {
|
|
652
|
-
const [
|
|
652
|
+
const [r, s] = i, a = j(r).typenameValue;
|
|
653
653
|
if (a === void 0) continue;
|
|
654
654
|
const c = [];
|
|
655
|
-
for (const [f, h] of Object.entries(
|
|
655
|
+
for (const [f, h] of Object.entries(s))
|
|
656
656
|
c.push([f, h]);
|
|
657
657
|
c.length > 0 && n.set(a, c);
|
|
658
658
|
}
|
|
659
659
|
else {
|
|
660
|
-
const
|
|
661
|
-
if (
|
|
662
|
-
const
|
|
660
|
+
const r = Object.entries(t);
|
|
661
|
+
if (r.length === 0) return;
|
|
662
|
+
const s = r.map(([o, a]) => [o, a]);
|
|
663
663
|
for (const o of e) {
|
|
664
664
|
const a = o.typenameValue;
|
|
665
|
-
a !== void 0 && n.set(a,
|
|
665
|
+
a !== void 0 && n.set(a, s);
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
return n.size > 0 ? n : void 0;
|
|
669
669
|
}
|
|
670
|
-
function
|
|
670
|
+
function ne(e) {
|
|
671
671
|
return Array.isArray(e) ? e.map((t) => j(t)) : [j(e)];
|
|
672
672
|
}
|
|
673
|
-
function
|
|
674
|
-
const n =
|
|
675
|
-
return
|
|
673
|
+
function tn(e, t) {
|
|
674
|
+
const n = ne(e), i = n.length === 1 ? n[0] : pt(...n.map((o) => o)), r = d.ARRAY | d.LIVE, s = new m(r, i);
|
|
675
|
+
return s._liveConfig = B.array(
|
|
676
676
|
n,
|
|
677
|
-
|
|
677
|
+
ee(n, t?.constraints),
|
|
678
678
|
t?.sort
|
|
679
|
-
),
|
|
679
|
+
), s;
|
|
680
680
|
}
|
|
681
|
-
function
|
|
682
|
-
const i =
|
|
681
|
+
function en(e, t, n) {
|
|
682
|
+
const i = ne(t), r = e, s = d.LIVE, o = new m(s, void 0);
|
|
683
683
|
return o._liveConfig = B.value(
|
|
684
684
|
i,
|
|
685
|
-
|
|
686
|
-
|
|
685
|
+
ee(i, n?.constraints),
|
|
686
|
+
r,
|
|
687
687
|
n.onCreate,
|
|
688
688
|
n.onUpdate,
|
|
689
689
|
n.onDelete
|
|
690
690
|
), o;
|
|
691
691
|
}
|
|
692
|
-
const
|
|
693
|
-
format:
|
|
694
|
-
typename:
|
|
695
|
-
const:
|
|
696
|
-
enum:
|
|
692
|
+
const nn = {
|
|
693
|
+
format: Xe,
|
|
694
|
+
typename: We,
|
|
695
|
+
const: ze,
|
|
696
|
+
enum: zt,
|
|
697
697
|
id: d.ID | d.STRING | d.NUMBER,
|
|
698
698
|
string: d.STRING,
|
|
699
699
|
number: d.NUMBER,
|
|
700
700
|
boolean: d.BOOLEAN,
|
|
701
701
|
null: d.NULL,
|
|
702
702
|
undefined: d.UNDEFINED,
|
|
703
|
-
array:
|
|
704
|
-
object:
|
|
705
|
-
record:
|
|
706
|
-
union:
|
|
707
|
-
nullish:
|
|
708
|
-
optional:
|
|
709
|
-
nullable:
|
|
710
|
-
result:
|
|
711
|
-
entity:
|
|
712
|
-
liveArray:
|
|
713
|
-
liveValue:
|
|
703
|
+
array: Le,
|
|
704
|
+
object: Ve,
|
|
705
|
+
record: Ue,
|
|
706
|
+
union: pt,
|
|
707
|
+
nullish: Ye,
|
|
708
|
+
optional: Ge,
|
|
709
|
+
nullable: He,
|
|
710
|
+
result: qe,
|
|
711
|
+
entity: Ze,
|
|
712
|
+
liveArray: tn,
|
|
713
|
+
liveValue: en
|
|
714
714
|
};
|
|
715
715
|
function K(e) {
|
|
716
716
|
if (e instanceof $)
|
|
@@ -723,9 +723,9 @@ function K(e) {
|
|
|
723
723
|
return String(e);
|
|
724
724
|
if (typeof e == "number") {
|
|
725
725
|
if ((e & d.HAS_FORMAT) !== 0) {
|
|
726
|
-
const
|
|
727
|
-
if (
|
|
728
|
-
return `"${
|
|
726
|
+
const r = xt(e);
|
|
727
|
+
if (r)
|
|
728
|
+
return `"${r}"`;
|
|
729
729
|
}
|
|
730
730
|
const i = [];
|
|
731
731
|
return e & d.UNDEFINED && i.push("undefined"), e & d.NULL && i.push("null"), e & d.NUMBER && i.push("number"), e & d.STRING && i.push("string"), e & d.BOOLEAN && i.push("boolean"), e & d.OBJECT && i.push("object"), e & d.ARRAY && i.push("array"), i.length === 0 ? "unknown" : i.length === 1 ? i[0] : i.join(" | ");
|
|
@@ -734,18 +734,18 @@ function K(e) {
|
|
|
734
734
|
if (t & d.UNION) {
|
|
735
735
|
const n = e, i = [];
|
|
736
736
|
if (n.values !== void 0 && n.values.size > 0)
|
|
737
|
-
for (const
|
|
738
|
-
const o = typeof
|
|
737
|
+
for (const s of n.values) {
|
|
738
|
+
const o = typeof s == "string" ? `"${s}"` : String(s);
|
|
739
739
|
i.push(o);
|
|
740
740
|
}
|
|
741
741
|
if (n.shape !== void 0) {
|
|
742
|
-
n.shape[
|
|
743
|
-
for (const [
|
|
744
|
-
|
|
742
|
+
n.shape[I] !== void 0 && i.push(`Array<${K(n.shape[I])}>`), n.shape[F] !== void 0 && i.push(`Record<string, ${K(n.shape[F])}>`);
|
|
743
|
+
for (const [s, o] of Object.entries(n.shape))
|
|
744
|
+
s !== I && s !== F && i.push(s);
|
|
745
745
|
}
|
|
746
746
|
if (t = n.mask, (t & d.HAS_FORMAT) !== 0) {
|
|
747
|
-
const
|
|
748
|
-
|
|
747
|
+
const s = xt(t);
|
|
748
|
+
s && i.push(`"${s}"`);
|
|
749
749
|
}
|
|
750
750
|
return t & d.UNDEFINED && i.push("undefined"), t & d.NULL && i.push("null"), t & d.NUMBER && i.push("number"), t & d.STRING && i.push("string"), t & d.BOOLEAN && i.push("boolean"), i.length === 0 ? "union" : i.join(" | ");
|
|
751
751
|
}
|
|
@@ -770,8 +770,8 @@ function q(e, t, n) {
|
|
|
770
770
|
`Validation error at ${e}: expected ${K(t)}, got ${typeof n == "object" ? n === null ? "null" : Array.isArray(n) ? "array" : "object" : typeof n}`
|
|
771
771
|
);
|
|
772
772
|
}
|
|
773
|
-
const
|
|
774
|
-
function
|
|
773
|
+
const ie = Array.isArray;
|
|
774
|
+
function Nt(e) {
|
|
775
775
|
if (e === null) return d.NULL;
|
|
776
776
|
switch (typeof e) {
|
|
777
777
|
case "number":
|
|
@@ -783,25 +783,25 @@ function At(e) {
|
|
|
783
783
|
case "undefined":
|
|
784
784
|
return d.UNDEFINED;
|
|
785
785
|
case "object":
|
|
786
|
-
return
|
|
786
|
+
return ie(e) ? d.ARRAY : d.OBJECT;
|
|
787
787
|
default:
|
|
788
788
|
throw new Error(`Invalid type: ${typeof e}`);
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
|
-
function
|
|
791
|
+
function Tn(e) {
|
|
792
792
|
return P(e);
|
|
793
793
|
}
|
|
794
794
|
function P(e) {
|
|
795
795
|
if (e === null || typeof e != "object")
|
|
796
796
|
return e;
|
|
797
|
-
if (
|
|
797
|
+
if (ie(e))
|
|
798
798
|
return e.map((n) => P(n));
|
|
799
799
|
if (e instanceof Date)
|
|
800
800
|
return new Date(e.getTime());
|
|
801
801
|
if (e instanceof Map) {
|
|
802
802
|
const n = /* @__PURE__ */ new Map();
|
|
803
|
-
for (const [i,
|
|
804
|
-
n.set(P(i), P(
|
|
803
|
+
for (const [i, r] of e)
|
|
804
|
+
n.set(P(i), P(r));
|
|
805
805
|
return n;
|
|
806
806
|
}
|
|
807
807
|
if (e instanceof Set) {
|
|
@@ -815,32 +815,32 @@ function P(e) {
|
|
|
815
815
|
t[n] = P(e[n]);
|
|
816
816
|
return t;
|
|
817
817
|
}
|
|
818
|
-
const
|
|
818
|
+
const vt = Object.entries, rn = () => {
|
|
819
819
|
};
|
|
820
820
|
class ot {
|
|
821
821
|
queryClient = void 0;
|
|
822
822
|
preloadedEntities = void 0;
|
|
823
|
-
warn =
|
|
823
|
+
warn = rn;
|
|
824
824
|
/** When true, missing optional fields on existing entities are set to
|
|
825
825
|
* undefined. False for mutation events (truly partial payloads). */
|
|
826
826
|
isPartialEvent = !1;
|
|
827
827
|
seen = void 0;
|
|
828
828
|
seenByKey = void 0;
|
|
829
|
-
reset(t, n, i,
|
|
830
|
-
this.queryClient = t, this.preloadedEntities = n, this.warn = i, this.isPartialEvent =
|
|
829
|
+
reset(t, n, i, r = !1) {
|
|
830
|
+
this.queryClient = t, this.preloadedEntities = n, this.warn = i, this.isPartialEvent = r, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
function
|
|
833
|
+
function re(e, t, n) {
|
|
834
834
|
return M(e, t, n, "");
|
|
835
835
|
}
|
|
836
836
|
function sn(e, t, n) {
|
|
837
|
-
return
|
|
837
|
+
return _t(e, t, n);
|
|
838
838
|
}
|
|
839
|
-
function
|
|
840
|
-
const
|
|
839
|
+
function Dt(e, t, n, i) {
|
|
840
|
+
const r = e >> mt;
|
|
841
841
|
if ((e & d.IS_EAGER_FORMAT) !== 0)
|
|
842
842
|
try {
|
|
843
|
-
return new Q(t,
|
|
843
|
+
return new Q(t, r, !0);
|
|
844
844
|
} catch (o) {
|
|
845
845
|
if ((e & d.UNDEFINED) !== 0) {
|
|
846
846
|
n.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
@@ -852,169 +852,169 @@ function Nt(e, t, n, i) {
|
|
|
852
852
|
}
|
|
853
853
|
throw o;
|
|
854
854
|
}
|
|
855
|
-
return new Q(t,
|
|
855
|
+
return new Q(t, r, !1);
|
|
856
856
|
}
|
|
857
857
|
function M(e, t, n, i) {
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
860
|
-
const c =
|
|
861
|
-
if (c === void 0) throw q(i,
|
|
858
|
+
const r = t;
|
|
859
|
+
if (r instanceof $) {
|
|
860
|
+
const c = r.get(e);
|
|
861
|
+
if (c === void 0) throw q(i, r, e);
|
|
862
862
|
return c;
|
|
863
863
|
}
|
|
864
|
-
if (
|
|
865
|
-
if (!
|
|
864
|
+
if (r instanceof Set) {
|
|
865
|
+
if (!r.has(e)) throw q(i, r, e);
|
|
866
866
|
return e;
|
|
867
867
|
}
|
|
868
|
-
if (typeof
|
|
869
|
-
if (e == null) return
|
|
870
|
-
if (e !==
|
|
868
|
+
if (typeof r == "string") {
|
|
869
|
+
if (e == null) return r;
|
|
870
|
+
if (e !== r) throw q(i, r, e);
|
|
871
871
|
return e;
|
|
872
872
|
}
|
|
873
|
-
if (typeof
|
|
874
|
-
const c =
|
|
875
|
-
if ((
|
|
876
|
-
if ((
|
|
873
|
+
if (typeof r == "number") {
|
|
874
|
+
const c = Nt(e);
|
|
875
|
+
if ((r & c) === 0) {
|
|
876
|
+
if ((r & d.UNDEFINED) !== 0) {
|
|
877
877
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
878
878
|
return;
|
|
879
879
|
}
|
|
880
|
-
throw q(i,
|
|
880
|
+
throw q(i, r, e);
|
|
881
881
|
}
|
|
882
|
-
return (
|
|
882
|
+
return (r & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? Dt(r, e, n, i) : e;
|
|
883
883
|
}
|
|
884
|
-
const
|
|
885
|
-
if (o !== void 0 && o.type ===
|
|
884
|
+
const s = r.mask, o = r._liveConfig;
|
|
885
|
+
if (o !== void 0 && o.type === dt.Value)
|
|
886
886
|
return o.valueType !== void 0 ? M(e, o.valueType, n, i) : e;
|
|
887
|
-
if ((
|
|
887
|
+
if ((s & d.PARSE_RESULT) !== 0)
|
|
888
888
|
try {
|
|
889
|
-
return { success: !0, value: M(e,
|
|
889
|
+
return { success: !0, value: M(e, r.shape, n, i) };
|
|
890
890
|
} catch (c) {
|
|
891
891
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
892
892
|
}
|
|
893
|
-
const a =
|
|
894
|
-
if ((
|
|
895
|
-
if ((
|
|
893
|
+
const a = Nt(e);
|
|
894
|
+
if ((s & a) === 0 && !r.values?.has(e)) {
|
|
895
|
+
if ((s & d.UNDEFINED) !== 0) {
|
|
896
896
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
897
897
|
return;
|
|
898
898
|
}
|
|
899
|
-
throw q(i,
|
|
899
|
+
throw q(i, s, e);
|
|
900
900
|
}
|
|
901
|
-
return a < d.OBJECT ? (
|
|
901
|
+
return a < d.OBJECT ? (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? Dt(s, e, n, i) : e : (s & d.UNION) !== 0 ? on(a, e, r, n, i) : a === d.ARRAY ? se(e, r.shape, n, i) : (s & d.RECORD) !== 0 ? oe(e, r.shape, n, i) : (s & d.ENTITY) !== 0 && n.queryClient !== void 0 ? _t(e, r, n) : ae(e, r, n, i);
|
|
902
902
|
}
|
|
903
|
-
function
|
|
903
|
+
function on(e, t, n, i, r) {
|
|
904
904
|
if (e === d.ARRAY) {
|
|
905
|
-
const
|
|
906
|
-
return
|
|
905
|
+
const s = n.shape[I];
|
|
906
|
+
return s === void 0 || typeof s == "number" ? t : se(t, s, i, r);
|
|
907
907
|
} else {
|
|
908
|
-
const
|
|
908
|
+
const s = n.typenameField, o = s ? t[s] : void 0;
|
|
909
909
|
if (o === void 0 || typeof o != "string") {
|
|
910
910
|
const c = n.shape[F];
|
|
911
911
|
if (c === void 0)
|
|
912
912
|
throw new Error(
|
|
913
|
-
`Typename field '${
|
|
913
|
+
`Typename field '${s}' is required for union discrimination but was not found in the data`
|
|
914
914
|
);
|
|
915
|
-
return
|
|
915
|
+
return oe(t, c, i, r);
|
|
916
916
|
}
|
|
917
917
|
const a = n.shape[o];
|
|
918
918
|
if (a === void 0 || typeof a == "number")
|
|
919
919
|
throw new Error(`Unknown typename '${o}' in union`);
|
|
920
|
-
return a.mask & d.ENTITY && i.queryClient !== void 0 ?
|
|
920
|
+
return a.mask & d.ENTITY && i.queryClient !== void 0 ? _t(t, a, i) : ae(t, a, i, r);
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
function se(e, t, n, i) {
|
|
924
|
-
const
|
|
925
|
-
for (let
|
|
924
|
+
const r = [];
|
|
925
|
+
for (let s = 0; s < e.length; s++)
|
|
926
926
|
try {
|
|
927
|
-
|
|
927
|
+
r.push(M(e[s], t, n, `${i}[${s}]`));
|
|
928
928
|
} catch (o) {
|
|
929
929
|
n.warn("Failed to parse array item, filtering out", {
|
|
930
|
-
index:
|
|
931
|
-
value: e[
|
|
930
|
+
index: s,
|
|
931
|
+
value: e[s],
|
|
932
932
|
error: o instanceof Error ? o.message : String(o)
|
|
933
933
|
});
|
|
934
934
|
}
|
|
935
|
-
return
|
|
935
|
+
return r;
|
|
936
936
|
}
|
|
937
|
-
function
|
|
938
|
-
for (const [
|
|
939
|
-
e[
|
|
937
|
+
function oe(e, t, n, i) {
|
|
938
|
+
for (const [r, s] of vt(e))
|
|
939
|
+
e[r] = M(s, t, n, `${i}["${r}"]`);
|
|
940
940
|
return e;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
942
|
+
function ae(e, t, n, i) {
|
|
943
943
|
if (S.has(e))
|
|
944
944
|
return e;
|
|
945
|
-
const
|
|
946
|
-
for (const [
|
|
947
|
-
e[
|
|
945
|
+
const r = t.shape;
|
|
946
|
+
for (const [s, o] of vt(r))
|
|
947
|
+
e[s] = M(e[s], o, n, `${i}.${s}`);
|
|
948
948
|
return e;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
const i = n.queryClient,
|
|
952
|
-
let
|
|
953
|
-
if (
|
|
954
|
-
|
|
950
|
+
function _t(e, t, n) {
|
|
951
|
+
const i = n.queryClient, r = n.preloadedEntities;
|
|
952
|
+
let s, o;
|
|
953
|
+
if (r !== void 0)
|
|
954
|
+
s = e.__entityRef, o = s;
|
|
955
955
|
else {
|
|
956
956
|
const p = e[t.idField];
|
|
957
957
|
if (p == null || typeof p != "string" && typeof p != "number")
|
|
958
958
|
throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
|
|
959
|
-
o = p,
|
|
959
|
+
o = p, s = N([t.typenameValue, o]);
|
|
960
960
|
}
|
|
961
|
-
const a = n.seenByKey.get(
|
|
961
|
+
const a = n.seenByKey.get(s);
|
|
962
962
|
if (a !== void 0)
|
|
963
963
|
return a.data;
|
|
964
|
-
if (
|
|
965
|
-
const w = i.entityMap.getEntity(
|
|
964
|
+
if (r !== void 0) {
|
|
965
|
+
const w = i.entityMap.getEntity(s)?.data ?? r.get(s);
|
|
966
966
|
if (w === void 0)
|
|
967
|
-
throw new Error(`Cached entity ${
|
|
967
|
+
throw new Error(`Cached entity ${s} not found in preloaded map`);
|
|
968
968
|
e = w;
|
|
969
969
|
}
|
|
970
970
|
const c = {};
|
|
971
971
|
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
972
|
-
const f = i.entityMap.getEntity(
|
|
973
|
-
key:
|
|
972
|
+
const f = i.entityMap.getEntity(s), h = n.isPartialEvent && f !== void 0, u = {
|
|
973
|
+
key: s,
|
|
974
974
|
shape: t,
|
|
975
975
|
data: c,
|
|
976
976
|
rawKeys: h ? new Set(Object.keys(e)) : void 0
|
|
977
977
|
};
|
|
978
|
-
n.seen.set(c, u), n.seenByKey.set(
|
|
978
|
+
n.seen.set(c, u), n.seenByKey.set(s, u);
|
|
979
979
|
const l = `[[${t.typenameValue}:${o}]]`, g = t.shape;
|
|
980
|
-
for (const [p, w] of
|
|
980
|
+
for (const [p, w] of vt(g))
|
|
981
981
|
h && !(p in e) || (c[p] = M(e[p], w, n, `${l}.${p}`));
|
|
982
982
|
return c;
|
|
983
983
|
}
|
|
984
|
-
function
|
|
985
|
-
return
|
|
984
|
+
function an(e, t) {
|
|
985
|
+
return cn(e, t.shape, t.typenameField);
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function cn(e, t, n) {
|
|
988
988
|
if (t === void 0) return !0;
|
|
989
989
|
for (const i of Object.keys(t)) {
|
|
990
990
|
if (i === n) continue;
|
|
991
|
-
const
|
|
992
|
-
if (
|
|
993
|
-
if ((
|
|
991
|
+
const r = t[i];
|
|
992
|
+
if (r instanceof m) {
|
|
993
|
+
if ((r.mask & d.UNDEFINED) !== 0) continue;
|
|
994
994
|
if (!(i in e) || e[i] === void 0) return !1;
|
|
995
|
-
} else if (typeof
|
|
996
|
-
if ((
|
|
995
|
+
} else if (typeof r == "number") {
|
|
996
|
+
if ((r & d.UNDEFINED) !== 0) continue;
|
|
997
997
|
if (!(i in e) || e[i] === void 0) return !1;
|
|
998
998
|
} else if (!(i in e) || e[i] === void 0) return !1;
|
|
999
999
|
}
|
|
1000
1000
|
return !0;
|
|
1001
1001
|
}
|
|
1002
|
-
const
|
|
1002
|
+
const fn = Object.prototype, H = /* @__PURE__ */ new WeakMap();
|
|
1003
1003
|
function A(e) {
|
|
1004
1004
|
if (typeof e != "object" || e === null) return e;
|
|
1005
1005
|
if (Z.has(e)) return A(e.getValue());
|
|
1006
1006
|
if (S.has(e)) return e;
|
|
1007
1007
|
if (Array.isArray(e)) {
|
|
1008
1008
|
let t = H.get(e);
|
|
1009
|
-
return t === void 0 && (t = new Proxy(e,
|
|
1009
|
+
return t === void 0 && (t = new Proxy(e, un), H.set(e, t)), t;
|
|
1010
1010
|
}
|
|
1011
|
-
if (Object.getPrototypeOf(e) ===
|
|
1011
|
+
if (Object.getPrototypeOf(e) === fn) {
|
|
1012
1012
|
let t = H.get(e);
|
|
1013
|
-
return t === void 0 && (t = new Proxy(e,
|
|
1013
|
+
return t === void 0 && (t = new Proxy(e, dn), H.set(e, t)), t;
|
|
1014
1014
|
}
|
|
1015
1015
|
return e;
|
|
1016
1016
|
}
|
|
1017
|
-
const
|
|
1017
|
+
const un = {
|
|
1018
1018
|
get(e, t, n) {
|
|
1019
1019
|
if (typeof t == "string") {
|
|
1020
1020
|
const i = Number(t);
|
|
@@ -1029,7 +1029,7 @@ const fn = {
|
|
|
1029
1029
|
deleteProperty() {
|
|
1030
1030
|
throw new Error("Cannot mutate a read-only array");
|
|
1031
1031
|
}
|
|
1032
|
-
},
|
|
1032
|
+
}, dn = {
|
|
1033
1033
|
get(e, t, n) {
|
|
1034
1034
|
return typeof t == "string" ? A(e[t]) : Reflect.get(e, t, n);
|
|
1035
1035
|
},
|
|
@@ -1049,7 +1049,7 @@ const fn = {
|
|
|
1049
1049
|
return Object.getOwnPropertyDescriptor(e, t);
|
|
1050
1050
|
}
|
|
1051
1051
|
};
|
|
1052
|
-
class
|
|
1052
|
+
class hn {
|
|
1053
1053
|
_notifier;
|
|
1054
1054
|
_queryClient;
|
|
1055
1055
|
_proxies = /* @__PURE__ */ new Map();
|
|
@@ -1066,8 +1066,8 @@ class dn {
|
|
|
1066
1066
|
_entityCache;
|
|
1067
1067
|
_extraMethods;
|
|
1068
1068
|
_extraGetters;
|
|
1069
|
-
constructor(t, n, i,
|
|
1070
|
-
this._notifier =
|
|
1069
|
+
constructor(t, n, i, r, s, o) {
|
|
1070
|
+
this._notifier = ut(), this._queryClient = o, this.key = t, this.typename = n, this.id = i, this.idField = r, this.data = s, this.entityRefs = void 0;
|
|
1071
1071
|
}
|
|
1072
1072
|
retain() {
|
|
1073
1073
|
this.refCount++;
|
|
@@ -1093,11 +1093,11 @@ class dn {
|
|
|
1093
1093
|
setChildRefs(t, n) {
|
|
1094
1094
|
const i = this.entityRefs;
|
|
1095
1095
|
if (t !== void 0 && t.size > 0)
|
|
1096
|
-
for (const
|
|
1097
|
-
(i === void 0 || !i.has(
|
|
1096
|
+
for (const r of t.keys())
|
|
1097
|
+
(i === void 0 || !i.has(r)) && r.retain();
|
|
1098
1098
|
if (i !== void 0 && i.size > 0)
|
|
1099
|
-
for (const
|
|
1100
|
-
(t === void 0 || !t.has(
|
|
1099
|
+
for (const r of i.keys())
|
|
1100
|
+
(t === void 0 || !t.has(r)) && r.release();
|
|
1101
1101
|
this.entityRefs = t, n && this.save();
|
|
1102
1102
|
}
|
|
1103
1103
|
addChildRef(t) {
|
|
@@ -1113,13 +1113,13 @@ class dn {
|
|
|
1113
1113
|
getProxy(t) {
|
|
1114
1114
|
const n = t;
|
|
1115
1115
|
let i = this._proxies.get(n);
|
|
1116
|
-
return i === void 0 && (i =
|
|
1116
|
+
return i === void 0 && (i = yn(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(n, i)), i;
|
|
1117
1117
|
}
|
|
1118
1118
|
get proxy() {
|
|
1119
1119
|
return this._proxies.values().next().value;
|
|
1120
1120
|
}
|
|
1121
1121
|
satisfiesDef(t) {
|
|
1122
|
-
return this.satisfiedDefs.has(t) ? !0 :
|
|
1122
|
+
return this.satisfiedDefs.has(t) ? !0 : an(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
|
|
1123
1123
|
}
|
|
1124
1124
|
save() {
|
|
1125
1125
|
this._queryClient.entityMap.save(this);
|
|
@@ -1131,30 +1131,30 @@ class dn {
|
|
|
1131
1131
|
this._notifier.consume();
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
function
|
|
1134
|
+
function ln(e, t, n) {
|
|
1135
1135
|
const i = [];
|
|
1136
|
-
for (const
|
|
1137
|
-
if (typeof
|
|
1138
|
-
const
|
|
1139
|
-
if (
|
|
1140
|
-
const o = n.entityMap.getEntity(
|
|
1141
|
-
o !== void 0 && o.satisfiesDef(t) && i.push(
|
|
1136
|
+
for (const r of e) {
|
|
1137
|
+
if (typeof r != "object" || r === null) continue;
|
|
1138
|
+
const s = S.get(r);
|
|
1139
|
+
if (s === void 0) continue;
|
|
1140
|
+
const o = n.entityMap.getEntity(s);
|
|
1141
|
+
o !== void 0 && o.satisfiesDef(t) && i.push(r);
|
|
1142
1142
|
}
|
|
1143
1143
|
return i;
|
|
1144
1144
|
}
|
|
1145
|
-
function
|
|
1146
|
-
const
|
|
1145
|
+
function yn(e, t, n, i, r) {
|
|
1146
|
+
const s = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig, h = c ? c.prototype : Qt.prototype, u = n.typenameField, l = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = () => ({ __entityRef: t });
|
|
1147
1147
|
let w;
|
|
1148
|
-
f?.hasSubscribe && a && "__subscribe" in a && (w =
|
|
1148
|
+
f?.hasSubscribe && a && "__subscribe" in a && (w = Pt((E) => {
|
|
1149
1149
|
const y = (b) => {
|
|
1150
|
-
b.__eventSource = t,
|
|
1150
|
+
b.__eventSource = t, r.applyMutationEvent(b);
|
|
1151
1151
|
}, _ = a.__subscribe.call(v, y);
|
|
1152
1152
|
return E.value = v, _;
|
|
1153
1153
|
}));
|
|
1154
1154
|
let v;
|
|
1155
|
-
if (u && !(u in
|
|
1155
|
+
if (u && !(u in s))
|
|
1156
1156
|
throw new Error(`typenameField "${u}" must be declared in the entity shape`);
|
|
1157
|
-
const O = Object.keys(
|
|
1157
|
+
const O = Object.keys(s);
|
|
1158
1158
|
if (O.includes("__typename") || O.push("__typename"), a)
|
|
1159
1159
|
for (const E of Object.keys(a))
|
|
1160
1160
|
O.includes(E) || O.push(E);
|
|
@@ -1179,7 +1179,7 @@ function ln(e, t, n, i, s) {
|
|
|
1179
1179
|
get(E, y) {
|
|
1180
1180
|
if (typeof y == "symbol") return;
|
|
1181
1181
|
if (y === "toJSON") return p;
|
|
1182
|
-
if (y === "__context") return
|
|
1182
|
+
if (y === "__context") return r.getContext();
|
|
1183
1183
|
if (y === "__typename") return e.typename;
|
|
1184
1184
|
if (w?.value, i.consume(), typeof y == "string") {
|
|
1185
1185
|
const b = e._extraGetters;
|
|
@@ -1192,26 +1192,26 @@ function ln(e, t, n, i, s) {
|
|
|
1192
1192
|
}
|
|
1193
1193
|
if (a && y in a) {
|
|
1194
1194
|
let C = l.get(y);
|
|
1195
|
-
return C || (C =
|
|
1195
|
+
return C || (C = be(v, a[y].bind(v)), l.set(y, C)), C;
|
|
1196
1196
|
}
|
|
1197
1197
|
}
|
|
1198
1198
|
const _ = e.data[y];
|
|
1199
1199
|
if (typeof _ == "object" && _ !== null && Z.has(_))
|
|
1200
1200
|
return A(_.getValue());
|
|
1201
1201
|
if (Array.isArray(_) && typeof y == "string") {
|
|
1202
|
-
const b =
|
|
1202
|
+
const b = s[y];
|
|
1203
1203
|
if (b instanceof m && (b.mask & d.ARRAY) !== 0) {
|
|
1204
1204
|
const x = b.shape;
|
|
1205
1205
|
if (x instanceof m && (x.mask & d.ENTITY) !== 0) {
|
|
1206
1206
|
const C = x.typenameValue;
|
|
1207
1207
|
if (C !== void 0) {
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1208
|
+
const bt = r.getEntityDefsForTypename(C);
|
|
1209
|
+
if (bt !== void 0 && bt.length > 1) {
|
|
1210
1210
|
const tt = g.get(y);
|
|
1211
1211
|
if (tt !== void 0 && tt.source === _)
|
|
1212
1212
|
return A(tt.filtered);
|
|
1213
|
-
const
|
|
1214
|
-
return g.set(y, { source: _, filtered:
|
|
1213
|
+
const Ct = ln(_, x, r);
|
|
1214
|
+
return g.set(y, { source: _, filtered: Ct }), A(Ct);
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
@@ -1231,7 +1231,7 @@ function ln(e, t, n, i, s) {
|
|
|
1231
1231
|
const b = e._extraMethods;
|
|
1232
1232
|
if (b && y in b || a && y in a) return !0;
|
|
1233
1233
|
}
|
|
1234
|
-
return y in
|
|
1234
|
+
return y in s;
|
|
1235
1235
|
},
|
|
1236
1236
|
ownKeys() {
|
|
1237
1237
|
return L();
|
|
@@ -1239,7 +1239,7 @@ function ln(e, t, n, i, s) {
|
|
|
1239
1239
|
getOwnPropertyDescriptor(E, y) {
|
|
1240
1240
|
if (y === "__typename")
|
|
1241
1241
|
return { enumerable: !0, configurable: !0, value: e.typename, writable: !1 };
|
|
1242
|
-
if (y in
|
|
1242
|
+
if (y in s)
|
|
1243
1243
|
return { enumerable: !0, configurable: !0, value: U.get(E, y, v), writable: !1 };
|
|
1244
1244
|
if (typeof y == "string") {
|
|
1245
1245
|
const _ = e._extraGetters;
|
|
@@ -1253,9 +1253,9 @@ function ln(e, t, n, i, s) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
1255
|
};
|
|
1256
|
-
return v = new Proxy({}, U), S.set(v, t),
|
|
1256
|
+
return v = new Proxy({}, U), S.set(v, t), Ee(v, r), v;
|
|
1257
1257
|
}
|
|
1258
|
-
class
|
|
1258
|
+
class pn {
|
|
1259
1259
|
instances = /* @__PURE__ */ new Map();
|
|
1260
1260
|
persistEntity;
|
|
1261
1261
|
constructor(t) {
|
|
@@ -1267,9 +1267,9 @@ class yn {
|
|
|
1267
1267
|
getEntity(t) {
|
|
1268
1268
|
return this.instances.get(t);
|
|
1269
1269
|
}
|
|
1270
|
-
getOrCreateEntity(t, n, i,
|
|
1271
|
-
let
|
|
1272
|
-
if (
|
|
1270
|
+
getOrCreateEntity(t, n, i, r) {
|
|
1271
|
+
let s = this.instances.get(t);
|
|
1272
|
+
if (s === void 0) {
|
|
1273
1273
|
const o = i.idField;
|
|
1274
1274
|
if (o === void 0)
|
|
1275
1275
|
throw new Error(`Entity id field is required ${i.typenameValue}`);
|
|
@@ -1277,9 +1277,9 @@ class yn {
|
|
|
1277
1277
|
if (typeof a != "string" && typeof a != "number")
|
|
1278
1278
|
throw new Error(`Entity id must be string or number: ${i.typenameValue}`);
|
|
1279
1279
|
const c = i;
|
|
1280
|
-
|
|
1280
|
+
s = new hn(t, i.typenameValue, a, o, n, r), s._entityCache = c._entityCache, this.instances.set(t, s);
|
|
1281
1281
|
}
|
|
1282
|
-
return
|
|
1282
|
+
return s.parseId = r.currentParseId, s;
|
|
1283
1283
|
}
|
|
1284
1284
|
remove(t) {
|
|
1285
1285
|
this.instances.delete(t);
|
|
@@ -1293,13 +1293,13 @@ class yn {
|
|
|
1293
1293
|
this.persistEntity(t.key, t.data, n);
|
|
1294
1294
|
}
|
|
1295
1295
|
}
|
|
1296
|
-
class
|
|
1296
|
+
class ce {
|
|
1297
1297
|
onlineSignal;
|
|
1298
1298
|
manualOverride = void 0;
|
|
1299
1299
|
eventListenersAttached = !1;
|
|
1300
1300
|
constructor(t) {
|
|
1301
1301
|
const n = t ?? this.detectOnlineStatus();
|
|
1302
|
-
this.onlineSignal =
|
|
1302
|
+
this.onlineSignal = jt(n), this.canAttachListeners() && this.attachEventListeners();
|
|
1303
1303
|
}
|
|
1304
1304
|
/**
|
|
1305
1305
|
* Returns true if the network is currently online
|
|
@@ -1357,8 +1357,8 @@ class ae {
|
|
|
1357
1357
|
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
|
-
class
|
|
1361
|
-
static onlineSignal =
|
|
1360
|
+
class fe {
|
|
1361
|
+
static onlineSignal = jt(!0);
|
|
1362
1362
|
get isOnline() {
|
|
1363
1363
|
return !0;
|
|
1364
1364
|
}
|
|
@@ -1367,19 +1367,19 @@ class ce {
|
|
|
1367
1367
|
clearManualOverride() {
|
|
1368
1368
|
}
|
|
1369
1369
|
getOnlineSignal() {
|
|
1370
|
-
return
|
|
1370
|
+
return fe.onlineSignal;
|
|
1371
1371
|
}
|
|
1372
1372
|
destroy() {
|
|
1373
1373
|
}
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1376
|
-
function
|
|
1375
|
+
const gn = new ce(), Pn = $t(gn);
|
|
1376
|
+
function wt(e, t = typeof window > "u") {
|
|
1377
1377
|
let n;
|
|
1378
1378
|
e === !1 ? n = 0 : e === void 0 || e === !0 ? n = t ? 0 : 3 : typeof e == "number" ? n = e : n = e.retries;
|
|
1379
|
-
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (
|
|
1379
|
+
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (r) => 1e3 * Math.pow(2, r);
|
|
1380
1380
|
return { retries: n, retryDelay: i };
|
|
1381
1381
|
}
|
|
1382
|
-
class
|
|
1382
|
+
class jn {
|
|
1383
1383
|
static cache;
|
|
1384
1384
|
/**
|
|
1385
1385
|
* The adapter class responsible for sending requests for this query type.
|
|
@@ -1389,7 +1389,7 @@ class Pn {
|
|
|
1389
1389
|
params;
|
|
1390
1390
|
config;
|
|
1391
1391
|
constructor() {
|
|
1392
|
-
return
|
|
1392
|
+
return Bt(this);
|
|
1393
1393
|
}
|
|
1394
1394
|
}
|
|
1395
1395
|
const It = /* @__PURE__ */ new WeakMap();
|
|
@@ -1402,14 +1402,14 @@ class G {
|
|
|
1402
1402
|
return it(this.captured, t, n);
|
|
1403
1403
|
}
|
|
1404
1404
|
resolveOptions(t) {
|
|
1405
|
-
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config,
|
|
1406
|
-
return { config: i, retryConfig:
|
|
1405
|
+
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config, r = wt(i?.retry);
|
|
1406
|
+
return { config: i, retryConfig: r };
|
|
1407
1407
|
}
|
|
1408
1408
|
static for(t) {
|
|
1409
1409
|
let n = It.get(t);
|
|
1410
1410
|
if (n !== void 0)
|
|
1411
1411
|
return n;
|
|
1412
|
-
const i = new t(),
|
|
1412
|
+
const i = new t(), r = Pe(i), s = String(r.methods.getIdentityKey.call(r.fields)), o = r.fields.result, a = o instanceof m ? o : nn.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, h = r.fields.fetchNext, u = t.adapter;
|
|
1413
1413
|
if (!u)
|
|
1414
1414
|
throw new Error(
|
|
1415
1415
|
`Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
|
|
@@ -1419,61 +1419,69 @@ class G {
|
|
|
1419
1419
|
a.shape,
|
|
1420
1420
|
void 0,
|
|
1421
1421
|
void 0,
|
|
1422
|
-
|
|
1422
|
+
s,
|
|
1423
1423
|
// typenameValue — unique per query class
|
|
1424
|
-
|
|
1424
|
+
Ut
|
|
1425
1425
|
// idField — symbol, injected onto payload before parse
|
|
1426
1426
|
);
|
|
1427
1427
|
return n = new G(
|
|
1428
|
-
{ id:
|
|
1429
|
-
|
|
1428
|
+
{ id: s, shape: g, cache: f, rawFetchNext: h, hasSendNext: l, isEntityResult: c, adapterClass: u },
|
|
1429
|
+
r
|
|
1430
1430
|
), It.set(t, n), n;
|
|
1431
1431
|
}
|
|
1432
1432
|
}
|
|
1433
|
-
const
|
|
1433
|
+
const $n = (e, t) => {
|
|
1434
1434
|
const n = G.for(e);
|
|
1435
|
-
return
|
|
1435
|
+
return Et(n, t);
|
|
1436
1436
|
};
|
|
1437
|
-
function
|
|
1438
|
-
const n = G.for(e), i =
|
|
1437
|
+
function Ln(e, ...t) {
|
|
1438
|
+
const n = G.for(e), i = Ce(Nn);
|
|
1439
1439
|
if (i === void 0)
|
|
1440
1440
|
throw new Error("QueryClient not found");
|
|
1441
|
-
const
|
|
1442
|
-
return i.getQuery(n,
|
|
1441
|
+
const r = t[0];
|
|
1442
|
+
return i.getQuery(n, r);
|
|
1443
|
+
}
|
|
1444
|
+
function at(e) {
|
|
1445
|
+
if (e.reason !== void 0) return e.reason;
|
|
1446
|
+
if (typeof DOMException < "u")
|
|
1447
|
+
return new DOMException("The operation was aborted", "AbortError");
|
|
1448
|
+
const t = new Error("The operation was aborted");
|
|
1449
|
+
return t.name = "AbortError", t;
|
|
1443
1450
|
}
|
|
1444
|
-
function
|
|
1451
|
+
function ue(e, t) {
|
|
1445
1452
|
return new Promise((n, i) => {
|
|
1446
1453
|
if (t?.aborted) {
|
|
1447
|
-
i(t
|
|
1454
|
+
i(at(t));
|
|
1448
1455
|
return;
|
|
1449
1456
|
}
|
|
1450
|
-
const
|
|
1457
|
+
const r = setTimeout(n, e);
|
|
1451
1458
|
t?.addEventListener(
|
|
1452
1459
|
"abort",
|
|
1453
1460
|
() => {
|
|
1454
|
-
clearTimeout(
|
|
1461
|
+
clearTimeout(r), i(at(t));
|
|
1455
1462
|
},
|
|
1456
1463
|
{ once: !0 }
|
|
1457
1464
|
);
|
|
1458
1465
|
});
|
|
1459
1466
|
}
|
|
1460
|
-
async function
|
|
1467
|
+
async function ct(e, t, n) {
|
|
1461
1468
|
if (t.retries < 0)
|
|
1462
1469
|
throw new Error("retries must be non-negative");
|
|
1463
1470
|
const i = Math.max(0, t.retries);
|
|
1464
|
-
let
|
|
1465
|
-
for (let
|
|
1466
|
-
n?.
|
|
1471
|
+
let r;
|
|
1472
|
+
for (let s = 0; s <= i; s++) {
|
|
1473
|
+
if (n?.aborted)
|
|
1474
|
+
throw at(n);
|
|
1467
1475
|
try {
|
|
1468
1476
|
return await e();
|
|
1469
1477
|
} catch (o) {
|
|
1470
|
-
if (
|
|
1471
|
-
await
|
|
1478
|
+
if (r = o, s >= i) throw o;
|
|
1479
|
+
await ue(t.retryDelay(s), n);
|
|
1472
1480
|
}
|
|
1473
1481
|
}
|
|
1474
|
-
throw
|
|
1482
|
+
throw r;
|
|
1475
1483
|
}
|
|
1476
|
-
class
|
|
1484
|
+
class mn {
|
|
1477
1485
|
def;
|
|
1478
1486
|
queryKey;
|
|
1479
1487
|
storageKey = -1;
|
|
@@ -1490,7 +1498,7 @@ class gn {
|
|
|
1490
1498
|
debounceTimer = void 0;
|
|
1491
1499
|
/** Resolved per-instance options (depend on actual params). */
|
|
1492
1500
|
config = void 0;
|
|
1493
|
-
retryConfig =
|
|
1501
|
+
retryConfig = wt(void 0);
|
|
1494
1502
|
/** Cancels in-flight fetches and retry waits. */
|
|
1495
1503
|
_abortController = void 0;
|
|
1496
1504
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
@@ -1511,15 +1519,15 @@ class gn {
|
|
|
1511
1519
|
throw new Error("Relay state not initialized");
|
|
1512
1520
|
return this._relayState;
|
|
1513
1521
|
}
|
|
1514
|
-
constructor(t, n, i,
|
|
1515
|
-
this.def = t, this.queryClient = n, this.queryKey = i, this.params =
|
|
1516
|
-
const
|
|
1517
|
-
this._queryId =
|
|
1522
|
+
constructor(t, n, i, r) {
|
|
1523
|
+
this.def = t, this.queryClient = n, this.queryKey = i, this.params = r, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1524
|
+
const s = Tt(r);
|
|
1525
|
+
this._queryId = s !== void 0 ? N(s) : 0, this.relay = Pt(
|
|
1518
1526
|
(o) => {
|
|
1519
1527
|
this._relayState = o;
|
|
1520
1528
|
const a = () => {
|
|
1521
1529
|
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;
|
|
1522
|
-
const f = this.config?.gcTime ??
|
|
1530
|
+
const f = this.config?.gcTime ?? Lt;
|
|
1523
1531
|
this.queryClient.gcManager.schedule(this.queryKey, f, X.Query);
|
|
1524
1532
|
}, c = (f = !1) => {
|
|
1525
1533
|
const { wasPaused: h, isPaused: u, initialized: l } = this;
|
|
@@ -1527,8 +1535,8 @@ class gn {
|
|
|
1527
1535
|
a();
|
|
1528
1536
|
return;
|
|
1529
1537
|
}
|
|
1530
|
-
const g =
|
|
1531
|
-
w && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? h || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : w && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1538
|
+
const g = Tt(this.params), p = Et(this.def, g), w = p !== this.storageKey;
|
|
1539
|
+
w && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? h || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), this.relayState.isPending && this._abortController === void 0 ? this.runQueryImmediately() : (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : w && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1532
1540
|
};
|
|
1533
1541
|
return c(!0), {
|
|
1534
1542
|
update: c,
|
|
@@ -1539,19 +1547,19 @@ class gn {
|
|
|
1539
1547
|
);
|
|
1540
1548
|
}
|
|
1541
1549
|
/** Apply raw data (fresh or cached) to the root entity and return the proxy. */
|
|
1542
|
-
applyData(t, n, i = !1,
|
|
1543
|
-
const
|
|
1550
|
+
applyData(t, n, i = !1, r) {
|
|
1551
|
+
const s = this.def;
|
|
1544
1552
|
return this.rootEntity = this.queryClient.parseAndApplyRootEntity(
|
|
1545
1553
|
t,
|
|
1546
1554
|
this._queryId,
|
|
1547
|
-
|
|
1555
|
+
s.statics.shape,
|
|
1548
1556
|
n,
|
|
1549
1557
|
i,
|
|
1550
|
-
|
|
1558
|
+
r
|
|
1551
1559
|
), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
|
|
1552
1560
|
__hasNext: () => this.hasNext,
|
|
1553
1561
|
__isFetchingNext: () => this._fetchNextPromise !== void 0
|
|
1554
|
-
}), this.rootEntity.getProxy(
|
|
1562
|
+
}), this.rootEntity.getProxy(s.statics.shape);
|
|
1555
1563
|
}
|
|
1556
1564
|
/** Save query metadata (the __entityRef pointer, updatedAt, ref set). */
|
|
1557
1565
|
saveQueryMetadata() {
|
|
@@ -1571,17 +1579,17 @@ class gn {
|
|
|
1571
1579
|
let i;
|
|
1572
1580
|
try {
|
|
1573
1581
|
i = await t.loadCachedQuery(this.def, this.storageKey), i !== void 0 && (this.updatedAt = i.updatedAt, n.value = this.applyData(i.value, !1, !1, i.preloadedEntities));
|
|
1574
|
-
} catch (
|
|
1575
|
-
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid",
|
|
1582
|
+
} catch (r) {
|
|
1583
|
+
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid", r);
|
|
1576
1584
|
}
|
|
1577
1585
|
if (!this.isPaused)
|
|
1578
1586
|
try {
|
|
1579
1587
|
if (i !== void 0 && this.setupSubscription(), i === void 0 || this.isStale) {
|
|
1580
|
-
if (await
|
|
1588
|
+
if (await ue(0), this.isPaused) return;
|
|
1581
1589
|
this.runQueryImmediately();
|
|
1582
1590
|
}
|
|
1583
|
-
} catch (
|
|
1584
|
-
n.setError(
|
|
1591
|
+
} catch (r) {
|
|
1592
|
+
n.setError(r);
|
|
1585
1593
|
}
|
|
1586
1594
|
}
|
|
1587
1595
|
setupSubscription() {
|
|
@@ -1607,16 +1615,16 @@ class gn {
|
|
|
1607
1615
|
const t = this.def;
|
|
1608
1616
|
if (this.isPaused)
|
|
1609
1617
|
throw new Error("Query is paused due to network status");
|
|
1610
|
-
const n = this.getOrCreateExecutionContext(), i = this.queryClient.getAdapter(t.statics.adapterClass),
|
|
1611
|
-
return
|
|
1618
|
+
const n = this.getOrCreateExecutionContext(), i = this.queryClient.getAdapter(t.statics.adapterClass), r = this._abortController?.signal ?? new AbortController().signal;
|
|
1619
|
+
return ct(
|
|
1612
1620
|
async () => {
|
|
1613
|
-
const
|
|
1621
|
+
const s = await i.send(n, r);
|
|
1614
1622
|
this.updatedAt = Date.now();
|
|
1615
|
-
const o = this.applyData(
|
|
1623
|
+
const o = this.applyData(s, !0);
|
|
1616
1624
|
return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
|
|
1617
1625
|
},
|
|
1618
1626
|
this.retryConfig,
|
|
1619
|
-
|
|
1627
|
+
r
|
|
1620
1628
|
);
|
|
1621
1629
|
}
|
|
1622
1630
|
runQueryImmediately() {
|
|
@@ -1663,12 +1671,12 @@ class gn {
|
|
|
1663
1671
|
this._fetchNextAbort = new AbortController();
|
|
1664
1672
|
const n = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
|
|
1665
1673
|
i.resultData = this.rootEntity.data;
|
|
1666
|
-
const
|
|
1667
|
-
return
|
|
1674
|
+
const r = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1675
|
+
return ct(
|
|
1668
1676
|
async () => {
|
|
1669
|
-
const
|
|
1677
|
+
const s = await r.sendNext(i, n);
|
|
1670
1678
|
this.updatedAt = Date.now();
|
|
1671
|
-
const o = this.applyData(
|
|
1679
|
+
const o = this.applyData(s, !0, !0);
|
|
1672
1680
|
return this.saveQueryMetadata(), o;
|
|
1673
1681
|
},
|
|
1674
1682
|
this.retryConfig,
|
|
@@ -1699,7 +1707,7 @@ class gn {
|
|
|
1699
1707
|
}
|
|
1700
1708
|
}
|
|
1701
1709
|
}
|
|
1702
|
-
class
|
|
1710
|
+
class vn {
|
|
1703
1711
|
def;
|
|
1704
1712
|
queryClient;
|
|
1705
1713
|
_inFlight = !1;
|
|
@@ -1708,7 +1716,7 @@ class mn {
|
|
|
1708
1716
|
this.def = t, this.queryClient = n, this.task = this.createTask();
|
|
1709
1717
|
}
|
|
1710
1718
|
createTask() {
|
|
1711
|
-
return
|
|
1719
|
+
return Se(
|
|
1712
1720
|
async (t) => {
|
|
1713
1721
|
if (this._inFlight)
|
|
1714
1722
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
@@ -1728,8 +1736,8 @@ class mn {
|
|
|
1728
1736
|
if (!(n instanceof m))
|
|
1729
1737
|
return t;
|
|
1730
1738
|
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1731
|
-
}),
|
|
1732
|
-
return
|
|
1739
|
+
}), r = new ot();
|
|
1740
|
+
return r.reset(void 0, void 0, i), re(t, n, r);
|
|
1733
1741
|
}
|
|
1734
1742
|
// ======================================================
|
|
1735
1743
|
// Effects processing
|
|
@@ -1737,57 +1745,57 @@ class mn {
|
|
|
1737
1745
|
processEffects(t, n) {
|
|
1738
1746
|
let i;
|
|
1739
1747
|
if (this.def.hasGetEffects) {
|
|
1740
|
-
const
|
|
1748
|
+
const s = it(
|
|
1741
1749
|
this.def.captured,
|
|
1742
1750
|
t ?? {},
|
|
1743
1751
|
this.queryClient.getContext()
|
|
1744
1752
|
);
|
|
1745
|
-
|
|
1753
|
+
s.result = n, i = s.getEffects();
|
|
1746
1754
|
} else if (this.def.effects !== void 0) {
|
|
1747
|
-
const
|
|
1748
|
-
i = J(this.def.effects,
|
|
1755
|
+
const s = { params: t, result: n };
|
|
1756
|
+
i = J(this.def.effects, s);
|
|
1749
1757
|
}
|
|
1750
1758
|
if (i === void 0) return;
|
|
1751
|
-
const
|
|
1752
|
-
et(i.creates, "create",
|
|
1759
|
+
const r = this.queryClient;
|
|
1760
|
+
et(i.creates, "create", r), et(i.updates, "update", r), et(i.deletes, "delete", r), i.invalidates && r.invalidateQueries(i.invalidates);
|
|
1753
1761
|
}
|
|
1754
1762
|
// ======================================================
|
|
1755
1763
|
// Retry logic
|
|
1756
1764
|
// ======================================================
|
|
1757
1765
|
executeWithRetry(t) {
|
|
1758
|
-
const n =
|
|
1766
|
+
const n = wt(this.def.config?.retry, !0), i = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1759
1767
|
if (!i.sendMutation)
|
|
1760
1768
|
throw new Error(
|
|
1761
1769
|
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1762
1770
|
);
|
|
1763
|
-
return
|
|
1764
|
-
const
|
|
1771
|
+
return ct(async () => {
|
|
1772
|
+
const r = new AbortController(), s = it(
|
|
1765
1773
|
this.def.captured,
|
|
1766
1774
|
t ?? {},
|
|
1767
1775
|
this.queryClient.getContext()
|
|
1768
1776
|
);
|
|
1769
|
-
return await i.sendMutation(
|
|
1777
|
+
return await i.sendMutation(s, r.signal);
|
|
1770
1778
|
}, n);
|
|
1771
1779
|
}
|
|
1772
1780
|
}
|
|
1773
|
-
function
|
|
1781
|
+
function _n(e) {
|
|
1774
1782
|
return typeof e == "string" ? e : j(e).typenameValue;
|
|
1775
1783
|
}
|
|
1776
1784
|
function et(e, t, n) {
|
|
1777
1785
|
if (e)
|
|
1778
|
-
for (const [i,
|
|
1779
|
-
const
|
|
1780
|
-
|
|
1786
|
+
for (const [i, r] of e) {
|
|
1787
|
+
const s = _n(i);
|
|
1788
|
+
s !== void 0 && n.applyMutationEvent({ type: t, typename: s, data: r });
|
|
1781
1789
|
}
|
|
1782
1790
|
}
|
|
1783
|
-
const
|
|
1784
|
-
function
|
|
1791
|
+
const de = "__eventSource";
|
|
1792
|
+
function he(e) {
|
|
1785
1793
|
return { field: e, segments: e.indexOf(".") !== -1 ? e.split(".") : void 0 };
|
|
1786
1794
|
}
|
|
1787
|
-
function
|
|
1788
|
-
return e.map(
|
|
1795
|
+
function wn(e) {
|
|
1796
|
+
return e.map(he);
|
|
1789
1797
|
}
|
|
1790
|
-
function
|
|
1798
|
+
function En(e, t) {
|
|
1791
1799
|
if (t.segments === void 0) return e[t.field];
|
|
1792
1800
|
let n = e;
|
|
1793
1801
|
for (const i of t.segments) {
|
|
@@ -1796,26 +1804,26 @@ function wn(e, t) {
|
|
|
1796
1804
|
}
|
|
1797
1805
|
return n;
|
|
1798
1806
|
}
|
|
1799
|
-
function
|
|
1807
|
+
function le(e, t) {
|
|
1800
1808
|
const n = [];
|
|
1801
1809
|
for (let i = 0; i < t.length; i++) {
|
|
1802
|
-
const
|
|
1803
|
-
if (
|
|
1804
|
-
n.push(
|
|
1810
|
+
const r = t[i], s = En(e, r);
|
|
1811
|
+
if (s === void 0) return;
|
|
1812
|
+
n.push(r.field, s);
|
|
1805
1813
|
}
|
|
1806
1814
|
return N(n);
|
|
1807
1815
|
}
|
|
1808
|
-
function
|
|
1816
|
+
function bn(e, t) {
|
|
1809
1817
|
if (e === void 0) return;
|
|
1810
1818
|
const n = /* @__PURE__ */ new Map();
|
|
1811
|
-
for (const [i,
|
|
1812
|
-
const
|
|
1819
|
+
for (const [i, r] of e) {
|
|
1820
|
+
const s = r.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
|
|
1813
1821
|
let a = !0;
|
|
1814
|
-
for (const [c, f] of
|
|
1822
|
+
for (const [c, f] of s) {
|
|
1815
1823
|
let h;
|
|
1816
|
-
if (
|
|
1817
|
-
const u =
|
|
1818
|
-
h =
|
|
1824
|
+
if (Vt(f)) {
|
|
1825
|
+
const u = Kt(f);
|
|
1826
|
+
h = lt(u, t);
|
|
1819
1827
|
} else
|
|
1820
1828
|
h = f;
|
|
1821
1829
|
if (h === void 0) {
|
|
@@ -1828,17 +1836,17 @@ function En(e, t) {
|
|
|
1828
1836
|
}
|
|
1829
1837
|
return n.size > 0 ? n : void 0;
|
|
1830
1838
|
}
|
|
1831
|
-
function
|
|
1839
|
+
function Ft(e, t) {
|
|
1832
1840
|
const n = e.get(t);
|
|
1833
1841
|
if (n !== void 0)
|
|
1834
1842
|
return n.map(([i]) => i).sort();
|
|
1835
1843
|
}
|
|
1836
|
-
class
|
|
1844
|
+
class Cn {
|
|
1837
1845
|
fields;
|
|
1838
1846
|
fieldPaths;
|
|
1839
1847
|
_bindings = /* @__PURE__ */ new Map();
|
|
1840
1848
|
constructor(t) {
|
|
1841
|
-
this.fields = t, this.fieldPaths = t.map(
|
|
1849
|
+
this.fields = t, this.fieldPaths = t.map(he);
|
|
1842
1850
|
}
|
|
1843
1851
|
register(t, n) {
|
|
1844
1852
|
let i = this._bindings.get(t);
|
|
@@ -1855,47 +1863,47 @@ class bn {
|
|
|
1855
1863
|
return this._bindings.size === 0;
|
|
1856
1864
|
}
|
|
1857
1865
|
}
|
|
1858
|
-
function
|
|
1866
|
+
function Mt(e) {
|
|
1859
1867
|
return N(e);
|
|
1860
1868
|
}
|
|
1861
|
-
class
|
|
1869
|
+
class Sn {
|
|
1862
1870
|
_groups = /* @__PURE__ */ new Map();
|
|
1863
1871
|
getOrCreateGroup(t) {
|
|
1864
|
-
const n =
|
|
1872
|
+
const n = Mt(t);
|
|
1865
1873
|
let i = this._groups.get(n);
|
|
1866
|
-
return i === void 0 && (i = new
|
|
1874
|
+
return i === void 0 && (i = new Cn(t), this._groups.set(n, i)), i;
|
|
1867
1875
|
}
|
|
1868
1876
|
register(t, n, i) {
|
|
1869
1877
|
this.getOrCreateGroup(n).register(t, i);
|
|
1870
1878
|
}
|
|
1871
1879
|
unregister(t, n, i) {
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1880
|
+
const r = Mt(n), s = this._groups.get(r);
|
|
1881
|
+
s !== void 0 && (s.unregister(t, i), s.isEmpty && this._groups.delete(r));
|
|
1874
1882
|
}
|
|
1875
1883
|
registerBinding(t, n) {
|
|
1876
1884
|
const i = t._constraintHashes.get(n);
|
|
1877
1885
|
if (i === void 0) return;
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1886
|
+
const r = Ft(t._constraintFieldRefs, n);
|
|
1887
|
+
r !== void 0 && this.register(i, r, t);
|
|
1880
1888
|
}
|
|
1881
1889
|
unregisterBinding(t, n) {
|
|
1882
1890
|
const i = t._constraintHashes.get(n);
|
|
1883
1891
|
if (i === void 0) return;
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1892
|
+
const r = Ft(t._constraintFieldRefs, n);
|
|
1893
|
+
r !== void 0 && this.unregister(i, r, t);
|
|
1886
1894
|
}
|
|
1887
|
-
routeEvent(t, n, i,
|
|
1895
|
+
routeEvent(t, n, i, r, s, o) {
|
|
1888
1896
|
for (const a of this._groups.values()) {
|
|
1889
|
-
const c =
|
|
1897
|
+
const c = le(n, a.fieldPaths);
|
|
1890
1898
|
if (c === void 0) continue;
|
|
1891
1899
|
const f = a.getMatching(c);
|
|
1892
1900
|
if (f !== void 0)
|
|
1893
1901
|
for (const h of f)
|
|
1894
|
-
h.onEvent(t, i,
|
|
1902
|
+
h.onEvent(t, i, r, s, o);
|
|
1895
1903
|
}
|
|
1896
1904
|
}
|
|
1897
1905
|
}
|
|
1898
|
-
function
|
|
1906
|
+
function kt(e) {
|
|
1899
1907
|
const t = /* @__PURE__ */ new Set();
|
|
1900
1908
|
for (const n of e)
|
|
1901
1909
|
if (typeof n == "object" && n !== null) {
|
|
@@ -1904,15 +1912,15 @@ function Mt(e) {
|
|
|
1904
1912
|
}
|
|
1905
1913
|
return t;
|
|
1906
1914
|
}
|
|
1907
|
-
class
|
|
1915
|
+
class ye {
|
|
1908
1916
|
_queryClient;
|
|
1909
1917
|
_parent;
|
|
1910
1918
|
_constraintHashes;
|
|
1911
1919
|
_entityDefsByTypename;
|
|
1912
1920
|
_constraintFieldRefs;
|
|
1913
1921
|
instance;
|
|
1914
|
-
constructor(t, n, i,
|
|
1915
|
-
this._queryClient = i, this._parent =
|
|
1922
|
+
constructor(t, n, i, r, s, o) {
|
|
1923
|
+
this._queryClient = i, this._parent = r, this._constraintHashes = s, this._constraintFieldRefs = n, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1916
1924
|
for (const a of t)
|
|
1917
1925
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1918
1926
|
Z.add(this);
|
|
@@ -1934,17 +1942,17 @@ class le {
|
|
|
1934
1942
|
* root level by applyMutationEvent. The binding just checks if the entity's
|
|
1935
1943
|
* current data satisfies this binding's shape and forwards to the instance.
|
|
1936
1944
|
*/
|
|
1937
|
-
onEvent(t, n, i,
|
|
1945
|
+
onEvent(t, n, i, r, s) {
|
|
1938
1946
|
const o = this._entityDefsByTypename.get(t);
|
|
1939
1947
|
if (o === void 0) return;
|
|
1940
1948
|
const a = this._queryClient.entityMap.getEntity(n);
|
|
1941
1949
|
if (i === "delete") {
|
|
1942
|
-
const f = a !== void 0 ? a.getProxy(o) :
|
|
1943
|
-
f !== void 0 && (this.instance.onEvent(n, f,
|
|
1950
|
+
const f = a !== void 0 ? a.getProxy(o) : s;
|
|
1951
|
+
f !== void 0 && (this.instance.onEvent(n, f, s ?? a?.data ?? {}, "delete"), r?.());
|
|
1944
1952
|
return;
|
|
1945
1953
|
}
|
|
1946
1954
|
if (a === void 0 || !a.satisfiesDef(o)) return;
|
|
1947
|
-
|
|
1955
|
+
r?.();
|
|
1948
1956
|
const c = a.getProxy(o);
|
|
1949
1957
|
this.instance.onEvent(n, c, a.data, i);
|
|
1950
1958
|
}
|
|
@@ -1954,17 +1962,17 @@ class le {
|
|
|
1954
1962
|
n !== -1 && t.splice(n, 1);
|
|
1955
1963
|
}
|
|
1956
1964
|
}
|
|
1957
|
-
class
|
|
1965
|
+
class On {
|
|
1958
1966
|
_notifier;
|
|
1959
1967
|
_items;
|
|
1960
1968
|
_keys;
|
|
1961
1969
|
_outputSignal;
|
|
1962
1970
|
_queryClient;
|
|
1963
1971
|
_parent;
|
|
1964
|
-
constructor(t, n, i,
|
|
1965
|
-
this._notifier =
|
|
1966
|
-
const a =
|
|
1967
|
-
(a || c) && (this._outputSignal =
|
|
1972
|
+
constructor(t, n, i, r, s, o) {
|
|
1973
|
+
this._notifier = ut(), this._items = i, this._keys = kt(i), this._queryClient = t, this._parent = n;
|
|
1974
|
+
const a = r !== void 0 && s !== void 0, c = o !== void 0;
|
|
1975
|
+
(a || c) && (this._outputSignal = Oe(() => {
|
|
1968
1976
|
this._notifier.consume();
|
|
1969
1977
|
let f = this._items;
|
|
1970
1978
|
if (a) {
|
|
@@ -1984,15 +1992,15 @@ class Sn {
|
|
|
1984
1992
|
h.push(u);
|
|
1985
1993
|
continue;
|
|
1986
1994
|
}
|
|
1987
|
-
g.consume(),
|
|
1995
|
+
g.consume(), le(g.data, r) === s && h.push(u);
|
|
1988
1996
|
}
|
|
1989
1997
|
f = h;
|
|
1990
1998
|
}
|
|
1991
1999
|
return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
|
|
1992
2000
|
}));
|
|
1993
2001
|
}
|
|
1994
|
-
onEvent(t, n, i,
|
|
1995
|
-
switch (
|
|
2002
|
+
onEvent(t, n, i, r) {
|
|
2003
|
+
switch (r) {
|
|
1996
2004
|
case "create":
|
|
1997
2005
|
this.add(t, n);
|
|
1998
2006
|
break;
|
|
@@ -2029,20 +2037,20 @@ class Sn {
|
|
|
2029
2037
|
}
|
|
2030
2038
|
reset(t) {
|
|
2031
2039
|
const n = this._items, i = Array.isArray(t) ? t : [];
|
|
2032
|
-
this._items = i, this._keys =
|
|
2033
|
-
for (const
|
|
2034
|
-
if (typeof
|
|
2035
|
-
const
|
|
2036
|
-
if (
|
|
2037
|
-
const o = this._queryClient.entityMap.getEntity(
|
|
2040
|
+
this._items = i, this._keys = kt(i);
|
|
2041
|
+
for (const r of i)
|
|
2042
|
+
if (typeof r == "object" && r !== null) {
|
|
2043
|
+
const s = T(r);
|
|
2044
|
+
if (s !== void 0) {
|
|
2045
|
+
const o = this._queryClient.entityMap.getEntity(s);
|
|
2038
2046
|
o !== void 0 && this._parent.addChildRef(o);
|
|
2039
2047
|
}
|
|
2040
2048
|
}
|
|
2041
|
-
for (const
|
|
2042
|
-
if (typeof
|
|
2043
|
-
const
|
|
2044
|
-
if (
|
|
2045
|
-
const o = this._queryClient.entityMap.getEntity(
|
|
2049
|
+
for (const r of n)
|
|
2050
|
+
if (typeof r == "object" && r !== null) {
|
|
2051
|
+
const s = T(r);
|
|
2052
|
+
if (s !== void 0) {
|
|
2053
|
+
const o = this._queryClient.entityMap.getEntity(s);
|
|
2046
2054
|
o !== void 0 && this._parent.removeChildRef(o);
|
|
2047
2055
|
}
|
|
2048
2056
|
}
|
|
@@ -2065,7 +2073,7 @@ class Sn {
|
|
|
2065
2073
|
return -1;
|
|
2066
2074
|
}
|
|
2067
2075
|
}
|
|
2068
|
-
class
|
|
2076
|
+
class Rn {
|
|
2069
2077
|
_notifier;
|
|
2070
2078
|
_value;
|
|
2071
2079
|
_createdKeys;
|
|
@@ -2075,11 +2083,11 @@ class On {
|
|
|
2075
2083
|
_onCreate;
|
|
2076
2084
|
_onUpdate;
|
|
2077
2085
|
_onDelete;
|
|
2078
|
-
constructor(t, n, i,
|
|
2079
|
-
this._notifier =
|
|
2086
|
+
constructor(t, n, i, r, s, o) {
|
|
2087
|
+
this._notifier = ut(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = n, this._onCreate = r, this._onUpdate = s, this._onDelete = o;
|
|
2080
2088
|
}
|
|
2081
|
-
onEvent(t, n, i,
|
|
2082
|
-
switch (
|
|
2089
|
+
onEvent(t, n, i, r) {
|
|
2090
|
+
switch (r) {
|
|
2083
2091
|
case "create":
|
|
2084
2092
|
if (this._createdKeys.has(t)) return;
|
|
2085
2093
|
this._createdKeys.add(t), this._value = this._onCreate(this._value, n);
|
|
@@ -2106,18 +2114,18 @@ class On {
|
|
|
2106
2114
|
append(t) {
|
|
2107
2115
|
}
|
|
2108
2116
|
}
|
|
2109
|
-
function
|
|
2110
|
-
let
|
|
2111
|
-
if (
|
|
2112
|
-
|
|
2117
|
+
function pe(e, t, n, i, r) {
|
|
2118
|
+
let s = e.constraintFieldRefs;
|
|
2119
|
+
if (s === void 0) {
|
|
2120
|
+
s = /* @__PURE__ */ new Map();
|
|
2113
2121
|
for (const f of e.entityDefs) {
|
|
2114
2122
|
const h = f.typenameValue;
|
|
2115
|
-
h !== void 0 &&
|
|
2123
|
+
h !== void 0 && s.set(h, [[de, n.key]]);
|
|
2116
2124
|
}
|
|
2117
2125
|
}
|
|
2118
|
-
const o =
|
|
2126
|
+
const o = bn(s, i) ?? /* @__PURE__ */ new Map();
|
|
2119
2127
|
let a;
|
|
2120
|
-
if (e.type ===
|
|
2128
|
+
if (e.type === dt.Array) {
|
|
2121
2129
|
let f, h;
|
|
2122
2130
|
if (e.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2123
2131
|
for (const [u] of e.constraintFieldRefs) {
|
|
@@ -2125,12 +2133,12 @@ function ye(e, t, n, i, s) {
|
|
|
2125
2133
|
if (l !== void 0) {
|
|
2126
2134
|
h = l;
|
|
2127
2135
|
const g = e.constraintFieldRefs.get(u);
|
|
2128
|
-
g !== void 0 && (f =
|
|
2136
|
+
g !== void 0 && (f = wn(g.map(([p]) => p)));
|
|
2129
2137
|
break;
|
|
2130
2138
|
}
|
|
2131
2139
|
}
|
|
2132
|
-
a = new
|
|
2133
|
-
|
|
2140
|
+
a = new On(
|
|
2141
|
+
r,
|
|
2134
2142
|
n,
|
|
2135
2143
|
Array.isArray(t) ? t : [],
|
|
2136
2144
|
f,
|
|
@@ -2138,58 +2146,58 @@ function ye(e, t, n, i, s) {
|
|
|
2138
2146
|
e.sort
|
|
2139
2147
|
);
|
|
2140
2148
|
} else
|
|
2141
|
-
a = new
|
|
2142
|
-
|
|
2149
|
+
a = new Rn(
|
|
2150
|
+
r,
|
|
2143
2151
|
n,
|
|
2144
2152
|
t,
|
|
2145
2153
|
e.onCreate,
|
|
2146
2154
|
e.onUpdate,
|
|
2147
2155
|
e.onDelete
|
|
2148
2156
|
);
|
|
2149
|
-
const c = new
|
|
2157
|
+
const c = new ye(
|
|
2150
2158
|
e.entityDefs,
|
|
2151
|
-
r,
|
|
2152
2159
|
s,
|
|
2160
|
+
r,
|
|
2153
2161
|
n,
|
|
2154
2162
|
o,
|
|
2155
2163
|
a
|
|
2156
2164
|
);
|
|
2157
|
-
return n.liveCollections.push(c),
|
|
2165
|
+
return n.liveCollections.push(c), r.registerLiveCollection(c), c;
|
|
2158
2166
|
}
|
|
2159
|
-
const
|
|
2167
|
+
const ge = Object.entries, me = Object.prototype;
|
|
2160
2168
|
function nt(e, t, n, i = !1) {
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
const
|
|
2164
|
-
return { data: Y(t,
|
|
2169
|
+
const r = e.queryClient;
|
|
2170
|
+
r.currentParseId++;
|
|
2171
|
+
const s = e.seen, o = /* @__PURE__ */ new Map();
|
|
2172
|
+
return { data: Y(t, s, r, n, o, i), entityRefs: o };
|
|
2165
2173
|
}
|
|
2166
|
-
function Y(e, t, n, i,
|
|
2174
|
+
function Y(e, t, n, i, r, s) {
|
|
2167
2175
|
if (typeof e != "object" || e === null) return e;
|
|
2168
2176
|
const o = t.get(e);
|
|
2169
2177
|
if (o !== void 0)
|
|
2170
|
-
return
|
|
2178
|
+
return xn(o, t, n, i, r, s);
|
|
2171
2179
|
if (Array.isArray(e)) {
|
|
2172
2180
|
for (let a = 0; a < e.length; a++) {
|
|
2173
2181
|
const c = e[a];
|
|
2174
|
-
typeof c == "object" && c !== null && !(c instanceof Q) && !S.has(c) && (e[a] = Y(c, t, n, i,
|
|
2182
|
+
typeof c == "object" && c !== null && !(c instanceof Q) && !S.has(c) && (e[a] = Y(c, t, n, i, r, s));
|
|
2175
2183
|
}
|
|
2176
2184
|
return e;
|
|
2177
2185
|
}
|
|
2178
|
-
if (Object.getPrototypeOf(e) ===
|
|
2186
|
+
if (Object.getPrototypeOf(e) === me && !S.has(e)) {
|
|
2179
2187
|
const a = e;
|
|
2180
2188
|
for (const c of Object.keys(a)) {
|
|
2181
2189
|
const f = a[c];
|
|
2182
|
-
typeof f == "object" && f !== null && !(f instanceof Q) && !S.has(f) && (a[c] = Y(f, t, n, i,
|
|
2190
|
+
typeof f == "object" && f !== null && !(f instanceof Q) && !S.has(f) && (a[c] = Y(f, t, n, i, r, s));
|
|
2183
2191
|
}
|
|
2184
2192
|
}
|
|
2185
2193
|
return e;
|
|
2186
2194
|
}
|
|
2187
|
-
function
|
|
2195
|
+
function ve(e) {
|
|
2188
2196
|
return typeof e == "object" && e !== null && !(e instanceof Q) && !S.has(e);
|
|
2189
2197
|
}
|
|
2190
|
-
function
|
|
2198
|
+
function xn(e, t, n, i, r, s) {
|
|
2191
2199
|
const { key: o, data: a, shape: c, rawKeys: f } = e, h = c.shape, u = n.prepareEntity(o, a, c), l = u.data, g = l !== a, p = g && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2192
|
-
if (g ? (
|
|
2200
|
+
if (g ? (_e(
|
|
2193
2201
|
h,
|
|
2194
2202
|
a,
|
|
2195
2203
|
l,
|
|
@@ -2200,8 +2208,8 @@ function Rn(e, t, n, i, s, r) {
|
|
|
2200
2208
|
n,
|
|
2201
2209
|
i,
|
|
2202
2210
|
p,
|
|
2203
|
-
|
|
2204
|
-
), u.notify()) :
|
|
2211
|
+
s
|
|
2212
|
+
), u.notify()) : we(h, a, u, a, t, n, i, p, s), s && u.liveCollections.length > 0)
|
|
2205
2213
|
for (const v of u.liveCollections) {
|
|
2206
2214
|
const O = v.instance.getRawValue();
|
|
2207
2215
|
if (Array.isArray(O))
|
|
@@ -2215,32 +2223,32 @@ function Rn(e, t, n, i, s, r) {
|
|
|
2215
2223
|
}
|
|
2216
2224
|
u.setChildRefs(p.size > 0 ? p : void 0, i);
|
|
2217
2225
|
const w = u.getProxy(c);
|
|
2218
|
-
return
|
|
2226
|
+
return r.set(u, (r.get(u) ?? 0) + 1), w;
|
|
2219
2227
|
}
|
|
2220
|
-
function
|
|
2221
|
-
for (const [u, l] of
|
|
2228
|
+
function _e(e, t, n, i, r, s, o, a, c, f, h) {
|
|
2229
|
+
for (const [u, l] of ge(e))
|
|
2222
2230
|
if (!(i !== void 0 && !i.has(u)))
|
|
2223
|
-
if (
|
|
2231
|
+
if (ve(t[u]) && (t[u] = Y(t[u], o, a, c, f, h)), l instanceof m && l._liveConfig !== void 0) {
|
|
2224
2232
|
const g = n[u];
|
|
2225
|
-
g instanceof
|
|
2233
|
+
g instanceof ye ? h ? g.append(t[u]) : g.reset(t[u]) : n[u] = pe(
|
|
2226
2234
|
l._liveConfig,
|
|
2227
2235
|
t[u],
|
|
2228
|
-
s,
|
|
2229
2236
|
r,
|
|
2237
|
+
s,
|
|
2230
2238
|
a
|
|
2231
2239
|
);
|
|
2232
2240
|
} else {
|
|
2233
2241
|
const g = t[u], p = n[u];
|
|
2234
|
-
if (
|
|
2242
|
+
if (ft(g) && ft(p)) {
|
|
2235
2243
|
const w = l instanceof m && l.shape !== void 0 ? l.shape : void 0;
|
|
2236
2244
|
if (w !== void 0)
|
|
2237
|
-
|
|
2245
|
+
_e(
|
|
2238
2246
|
w,
|
|
2239
2247
|
g,
|
|
2240
2248
|
p,
|
|
2241
2249
|
void 0,
|
|
2242
|
-
s,
|
|
2243
2250
|
r,
|
|
2251
|
+
s,
|
|
2244
2252
|
o,
|
|
2245
2253
|
a,
|
|
2246
2254
|
c,
|
|
@@ -2255,45 +2263,45 @@ function ve(e, t, n, i, s, r, o, a, c, f, h) {
|
|
|
2255
2263
|
n[u] = g;
|
|
2256
2264
|
}
|
|
2257
2265
|
}
|
|
2258
|
-
function
|
|
2259
|
-
for (const [f, h] of
|
|
2266
|
+
function we(e, t, n, i, r, s, o, a, c) {
|
|
2267
|
+
for (const [f, h] of ge(e))
|
|
2260
2268
|
if (f in t)
|
|
2261
|
-
if (
|
|
2262
|
-
t[f] =
|
|
2269
|
+
if (ve(t[f]) && (t[f] = Y(t[f], r, s, o, a, c)), h instanceof m && h._liveConfig !== void 0)
|
|
2270
|
+
t[f] = pe(
|
|
2263
2271
|
h._liveConfig,
|
|
2264
2272
|
t[f],
|
|
2265
2273
|
n,
|
|
2266
2274
|
i,
|
|
2267
|
-
|
|
2275
|
+
s
|
|
2268
2276
|
);
|
|
2269
2277
|
else {
|
|
2270
2278
|
const u = t[f];
|
|
2271
|
-
if (
|
|
2279
|
+
if (ft(u)) {
|
|
2272
2280
|
const l = h instanceof m && h.shape !== void 0 ? h.shape : void 0;
|
|
2273
|
-
l !== void 0 &&
|
|
2281
|
+
l !== void 0 && we(l, u, n, i, r, s, o, a, c);
|
|
2274
2282
|
}
|
|
2275
2283
|
}
|
|
2276
2284
|
}
|
|
2277
|
-
function
|
|
2278
|
-
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) ===
|
|
2285
|
+
function ft(e) {
|
|
2286
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) === me && !S.has(e);
|
|
2279
2287
|
}
|
|
2280
|
-
function
|
|
2288
|
+
function Un(e) {
|
|
2281
2289
|
if (e !== void 0)
|
|
2282
2290
|
return typeof e == "string" ? e : typeof e == "function" ? e() : e.value;
|
|
2283
2291
|
}
|
|
2284
|
-
function
|
|
2285
|
-
return
|
|
2292
|
+
function An(e) {
|
|
2293
|
+
return Re(e);
|
|
2286
2294
|
}
|
|
2287
|
-
function
|
|
2295
|
+
function Tt(e) {
|
|
2288
2296
|
if (e === void 0)
|
|
2289
2297
|
return;
|
|
2290
2298
|
const t = {};
|
|
2291
2299
|
for (const [n, i] of Object.entries(e))
|
|
2292
|
-
|
|
2300
|
+
An(i) ? t[n] = i.value : t[n] = i;
|
|
2293
2301
|
return t;
|
|
2294
2302
|
}
|
|
2295
|
-
const
|
|
2296
|
-
class
|
|
2303
|
+
const Et = (e, t) => N([e.statics.id, t]);
|
|
2304
|
+
class qn {
|
|
2297
2305
|
entityMap;
|
|
2298
2306
|
queryInstances = /* @__PURE__ */ new Map();
|
|
2299
2307
|
mutationInstances = /* @__PURE__ */ new Map();
|
|
@@ -2310,18 +2318,18 @@ class Un {
|
|
|
2310
2318
|
networkUnsubscribe;
|
|
2311
2319
|
constructor(t = {}) {
|
|
2312
2320
|
const {
|
|
2313
|
-
store: n = new
|
|
2321
|
+
store: n = new Ne(new De()),
|
|
2314
2322
|
log: i,
|
|
2315
|
-
evictionMultiplier:
|
|
2316
|
-
adapters:
|
|
2323
|
+
evictionMultiplier: r,
|
|
2324
|
+
adapters: s,
|
|
2317
2325
|
networkManager: o,
|
|
2318
2326
|
gcManager: a,
|
|
2319
2327
|
...c
|
|
2320
2328
|
} = t;
|
|
2321
|
-
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier:
|
|
2329
|
+
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: r }, this.gcManager = t.gcManager ?? (this.isServer ? new Me() : new Fe(this.handleEviction, r)), this.networkManager = t.networkManager ?? new ce(), this.entityMap = new pn((u, l, g) => this.store.saveEntity(u, l, g));
|
|
2322
2330
|
for (const u of t.adapters ?? [])
|
|
2323
2331
|
this.adapters.set(u.constructor, u), u.register(this);
|
|
2324
|
-
const f = this.networkManager.getOnlineSignal(), h =
|
|
2332
|
+
const f = this.networkManager.getOnlineSignal(), h = xe(() => f.value);
|
|
2325
2333
|
this.networkUnsubscribe = h.addListener(
|
|
2326
2334
|
() => {
|
|
2327
2335
|
const u = f.value;
|
|
@@ -2375,14 +2383,14 @@ class Un {
|
|
|
2375
2383
|
if (i !== void 0)
|
|
2376
2384
|
return n = m.merge(i), this.mergedDefCache.set(t, n), n;
|
|
2377
2385
|
}
|
|
2378
|
-
saveQueryData(t, n, i,
|
|
2379
|
-
const o =
|
|
2380
|
-
this.store.saveQuery(t, n, i,
|
|
2386
|
+
saveQueryData(t, n, i, r, s) {
|
|
2387
|
+
const o = s !== void 0 && s.size > 0 ? new Set([...s.keys()].map((a) => a.key)) : void 0;
|
|
2388
|
+
this.store.saveQuery(t, n, i, r, o);
|
|
2381
2389
|
}
|
|
2382
2390
|
activateQuery(t) {
|
|
2383
|
-
const { def: n, queryKey: i, storageKey:
|
|
2384
|
-
this.store.activateQuery(n,
|
|
2385
|
-
const o =
|
|
2391
|
+
const { def: n, queryKey: i, storageKey: r, config: s } = t;
|
|
2392
|
+
this.store.activateQuery(n, r);
|
|
2393
|
+
const o = s?.gcTime ?? Lt;
|
|
2386
2394
|
this.gcManager.cancel(i, o);
|
|
2387
2395
|
}
|
|
2388
2396
|
loadCachedQuery(t, n) {
|
|
@@ -2393,9 +2401,9 @@ class Un {
|
|
|
2393
2401
|
* that triggers fetches and prepopulates with cached data
|
|
2394
2402
|
*/
|
|
2395
2403
|
getQuery(t, n) {
|
|
2396
|
-
const i =
|
|
2397
|
-
let
|
|
2398
|
-
return
|
|
2404
|
+
const i = Et(t, n);
|
|
2405
|
+
let r = this.queryInstances.get(i);
|
|
2406
|
+
return r === void 0 && (r = new mn(t, this, i, n), this.queryInstances.set(i, r)), r.relay;
|
|
2399
2407
|
}
|
|
2400
2408
|
/**
|
|
2401
2409
|
* Gets or creates a MutationResult for the given mutation definition.
|
|
@@ -2404,16 +2412,16 @@ class Un {
|
|
|
2404
2412
|
getMutation(t) {
|
|
2405
2413
|
const n = t.id;
|
|
2406
2414
|
let i = this.mutationInstances.get(n);
|
|
2407
|
-
return i === void 0 && (i = new
|
|
2415
|
+
return i === void 0 && (i = new vn(t, this), this.mutationInstances.set(n, i)), i.task;
|
|
2408
2416
|
}
|
|
2409
2417
|
/**
|
|
2410
2418
|
* Parse data: validates, formats, produces parsed entity data objects.
|
|
2411
2419
|
* Does NOT touch the entity store. Call applyRefs() after to commit entities.
|
|
2412
2420
|
*/
|
|
2413
2421
|
parseData(t, n, i) {
|
|
2414
|
-
const
|
|
2415
|
-
}),
|
|
2416
|
-
return
|
|
2422
|
+
const r = this.context.log?.warn ?? (() => {
|
|
2423
|
+
}), s = new ot();
|
|
2424
|
+
return s.reset(this, i, r), { data: re(t, n, s), ctx: s };
|
|
2417
2425
|
}
|
|
2418
2426
|
/**
|
|
2419
2427
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
@@ -2428,9 +2436,9 @@ class Un {
|
|
|
2428
2436
|
* QUERY_ID onto the payload. Returns the root EntityInstance (created or
|
|
2429
2437
|
* found in the store by the standard entity pipeline).
|
|
2430
2438
|
*/
|
|
2431
|
-
parseAndApplyRootEntity(t, n, i,
|
|
2432
|
-
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[
|
|
2433
|
-
const a = this.parseData(t, i, o), c = nt(a.ctx, a.data,
|
|
2439
|
+
parseAndApplyRootEntity(t, n, i, r, s = !1, o) {
|
|
2440
|
+
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Ut] = n);
|
|
2441
|
+
const a = this.parseData(t, i, o), c = nt(a.ctx, a.data, r, s), f = S.get(c.data);
|
|
2434
2442
|
return this.entityMap.getEntity(f);
|
|
2435
2443
|
}
|
|
2436
2444
|
prepareEntity(t, n, i) {
|
|
@@ -2440,11 +2448,11 @@ class Un {
|
|
|
2440
2448
|
// Mutation Events
|
|
2441
2449
|
// ======================================================
|
|
2442
2450
|
applyMutationEvent(t) {
|
|
2443
|
-
const { type: n, typename: i } = t,
|
|
2444
|
-
if (
|
|
2445
|
-
const
|
|
2446
|
-
if (
|
|
2447
|
-
const o = t.data, a = t.id !== void 0 ? t.id : n === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[
|
|
2451
|
+
const { type: n, typename: i } = t, r = this.getMergedDef(i);
|
|
2452
|
+
if (r === void 0) return;
|
|
2453
|
+
const s = r.idField;
|
|
2454
|
+
if (s === void 0 || typeof s == "symbol") return;
|
|
2455
|
+
const o = t.data, a = t.id !== void 0 ? t.id : n === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[s];
|
|
2448
2456
|
if (a === void 0) return;
|
|
2449
2457
|
const c = N([i, a]), f = t.__eventSource, h = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2450
2458
|
if (n === "delete") {
|
|
@@ -2462,7 +2470,7 @@ class Un {
|
|
|
2462
2470
|
/* isPartialEvent */
|
|
2463
2471
|
!0
|
|
2464
2472
|
);
|
|
2465
|
-
const O = sn(h,
|
|
2473
|
+
const O = sn(h, r, v);
|
|
2466
2474
|
nt(v, O, !0);
|
|
2467
2475
|
} catch (w) {
|
|
2468
2476
|
if (this.context.log?.warn?.("Failed to apply mutation event", w), u === void 0) {
|
|
@@ -2485,9 +2493,9 @@ class Un {
|
|
|
2485
2493
|
// ======================================================
|
|
2486
2494
|
invalidateQueries(t) {
|
|
2487
2495
|
for (const n of t) {
|
|
2488
|
-
const i = Array.isArray(n),
|
|
2496
|
+
const i = Array.isArray(n), r = i ? n[0] : n, s = i ? n[1] : void 0, a = G.for(r).statics.id;
|
|
2489
2497
|
for (const [, c] of this.queryInstances)
|
|
2490
|
-
c.def.statics.id === a && (
|
|
2498
|
+
c.def.statics.id === a && (s === void 0 || Dn(c.resolvedParams, s)) && c.markStale();
|
|
2491
2499
|
}
|
|
2492
2500
|
}
|
|
2493
2501
|
// ======================================================
|
|
@@ -2495,9 +2503,9 @@ class Un {
|
|
|
2495
2503
|
// ======================================================
|
|
2496
2504
|
handleEviction = (t, n) => {
|
|
2497
2505
|
if (n === X.Query) {
|
|
2498
|
-
const
|
|
2499
|
-
if (
|
|
2500
|
-
|
|
2506
|
+
const r = this.queryInstances.get(t);
|
|
2507
|
+
if (r === void 0) return;
|
|
2508
|
+
r.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
2501
2509
|
return;
|
|
2502
2510
|
}
|
|
2503
2511
|
const i = this.entityMap.getEntity(t);
|
|
@@ -2508,7 +2516,7 @@ class Un {
|
|
|
2508
2516
|
// ======================================================
|
|
2509
2517
|
getOrCreateMatcher(t) {
|
|
2510
2518
|
let n = this.constraintRegistry.get(t);
|
|
2511
|
-
return n === void 0 && (n = new
|
|
2519
|
+
return n === void 0 && (n = new Sn(), this.constraintRegistry.set(t, n)), n;
|
|
2512
2520
|
}
|
|
2513
2521
|
registerLiveCollection(t) {
|
|
2514
2522
|
for (const [n, i] of t._entityDefsByTypename)
|
|
@@ -2520,11 +2528,11 @@ class Un {
|
|
|
2520
2528
|
i !== void 0 && i.unregisterBinding(t, n);
|
|
2521
2529
|
}
|
|
2522
2530
|
}
|
|
2523
|
-
routeEvent(t, n, i,
|
|
2531
|
+
routeEvent(t, n, i, r, s, o, a) {
|
|
2524
2532
|
const c = this.constraintRegistry.get(t);
|
|
2525
2533
|
if (c === void 0) return;
|
|
2526
|
-
const f =
|
|
2527
|
-
c.routeEvent(t, f, i,
|
|
2534
|
+
const f = s !== void 0 ? { ...n, [de]: s } : n;
|
|
2535
|
+
c.routeEvent(t, f, i, r, o, a);
|
|
2528
2536
|
}
|
|
2529
2537
|
destroy() {
|
|
2530
2538
|
this.networkUnsubscribe?.(), this.gcManager.destroy(), this.networkManager.destroy();
|
|
@@ -2533,40 +2541,40 @@ class Un {
|
|
|
2533
2541
|
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2534
2542
|
}
|
|
2535
2543
|
}
|
|
2536
|
-
const
|
|
2537
|
-
function
|
|
2544
|
+
const Nn = $t(void 0);
|
|
2545
|
+
function Dn(e, t) {
|
|
2538
2546
|
if (e === void 0) return !1;
|
|
2539
2547
|
for (const n in t)
|
|
2540
2548
|
if (e[n] !== t[n]) return !1;
|
|
2541
2549
|
return !0;
|
|
2542
2550
|
}
|
|
2543
2551
|
export {
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2552
|
+
I as A,
|
|
2553
|
+
Qt as E,
|
|
2554
|
+
Fe as G,
|
|
2547
2555
|
B as L,
|
|
2548
2556
|
d as M,
|
|
2549
|
-
|
|
2550
|
-
|
|
2557
|
+
ce as N,
|
|
2558
|
+
Ut as Q,
|
|
2551
2559
|
F as R,
|
|
2552
2560
|
m as V,
|
|
2553
|
-
|
|
2554
|
-
|
|
2561
|
+
dt as a,
|
|
2562
|
+
Pn as b,
|
|
2555
2563
|
V as c,
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2564
|
+
Me as d,
|
|
2565
|
+
fe as e,
|
|
2566
|
+
jn as f,
|
|
2567
|
+
qn as g,
|
|
2568
|
+
Nn as h,
|
|
2569
|
+
gn as i,
|
|
2570
|
+
Tn as j,
|
|
2571
|
+
Ln as k,
|
|
2572
|
+
Bt as l,
|
|
2573
|
+
Pe as m,
|
|
2566
2574
|
J as n,
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2575
|
+
Un as o,
|
|
2576
|
+
$n as q,
|
|
2577
|
+
te as r,
|
|
2578
|
+
nn as t
|
|
2571
2579
|
};
|
|
2572
|
-
//# sourceMappingURL=QueryClient-
|
|
2580
|
+
//# sourceMappingURL=QueryClient-4co72n4i.js.map
|