fetchium 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/cjs/development/QueryAdapter-DUo338ga.js +2 -0
- package/dist/cjs/development/QueryAdapter-DUo338ga.js.map +1 -0
- package/dist/cjs/development/QueryClient-m7BzCIe9.js +2 -0
- package/dist/cjs/development/QueryClient-m7BzCIe9.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/development/mutation-wUhcGxKl.js +2 -0
- package/dist/cjs/development/mutation-wUhcGxKl.js.map +1 -0
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/rest/index.js.map +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/development/topic/index.js.map +1 -1
- package/dist/cjs/production/QueryAdapter-DUo338ga.js +2 -0
- package/dist/cjs/production/QueryAdapter-DUo338ga.js.map +1 -0
- package/dist/cjs/production/QueryClient-4T90peFN.js +2 -0
- package/dist/cjs/production/QueryClient-4T90peFN.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/production/mutation-Dk0gznwX.js +2 -0
- package/dist/cjs/production/mutation-Dk0gznwX.js.map +1 -0
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/rest/index.js.map +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/cjs/production/topic/index.js.map +1 -1
- package/dist/esm/{QueryController.d.ts → QueryAdapter.d.ts} +7 -7
- package/dist/esm/QueryAdapter.d.ts.map +1 -0
- package/dist/esm/QueryClient.d.ts +6 -6
- package/dist/esm/QueryClient.d.ts.map +1 -1
- package/dist/esm/QueryResult.d.ts +2 -2
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/{QueryController-Ch_ncxiI.js → QueryAdapter-Bu5UJjE4.js} +2 -2
- package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -0
- package/dist/esm/development/{QueryClient-Dtde3pss.js → QueryClient-BajBmpnA.js} +532 -532
- package/dist/esm/development/QueryClient-BajBmpnA.js.map +1 -0
- package/dist/esm/development/index.js +14 -14
- package/dist/esm/development/{mutation-UZshUQAf.js → mutation-DAOZE4Ok.js} +13 -13
- package/dist/esm/development/mutation-DAOZE4Ok.js.map +1 -0
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +26 -26
- package/dist/esm/development/rest/index.js.map +1 -1
- package/dist/esm/development/topic/index.js +11 -11
- package/dist/esm/development/topic/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/mutation.d.ts +3 -3
- package/dist/esm/mutation.d.ts.map +1 -1
- package/dist/esm/production/{QueryController-Ch_ncxiI.js → QueryAdapter-Bu5UJjE4.js} +2 -2
- package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -0
- package/dist/esm/production/{QueryClient-YqnBxFy1.js → QueryClient-KH0Ex_8m.js} +708 -708
- package/dist/esm/production/QueryClient-KH0Ex_8m.js.map +1 -0
- package/dist/esm/production/index.js +14 -14
- package/dist/esm/production/{mutation-pgFl1uIY.js → mutation-C7BOChR2.js} +13 -13
- package/dist/esm/production/mutation-C7BOChR2.js.map +1 -0
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +26 -26
- package/dist/esm/production/rest/index.js.map +1 -1
- package/dist/esm/production/topic/index.js +11 -11
- package/dist/esm/production/topic/index.js.map +1 -1
- package/dist/esm/query.d.ts +6 -6
- package/dist/esm/query.d.ts.map +1 -1
- package/dist/esm/rest/RESTMutation.d.ts +2 -2
- package/dist/esm/rest/RESTMutation.d.ts.map +1 -1
- package/dist/esm/rest/RESTQuery.d.ts +2 -2
- package/dist/esm/rest/RESTQuery.d.ts.map +1 -1
- package/dist/esm/rest/{RESTQueryController.d.ts → RESTQueryAdapter.d.ts} +6 -6
- package/dist/esm/rest/RESTQueryAdapter.d.ts.map +1 -0
- package/dist/esm/rest/index.d.ts +2 -2
- package/dist/esm/rest/index.d.ts.map +1 -1
- package/dist/esm/topic/TopicQuery.d.ts +2 -2
- package/dist/esm/topic/TopicQuery.d.ts.map +1 -1
- package/dist/esm/topic/{TopicQueryController.d.ts → TopicQueryAdapter.d.ts} +3 -3
- package/dist/esm/topic/TopicQueryAdapter.d.ts.map +1 -0
- package/dist/esm/topic/index.d.ts +1 -1
- package/dist/esm/topic/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/docs/api/fetchium.md +40 -40
- package/plugin/docs/core/queries.md +15 -15
- package/plugin/docs/core/streaming.md +18 -18
- package/plugin/docs/data/mutations.md +5 -5
- package/plugin/docs/quickstart.md +1 -1
- package/plugin/docs/setup/project-setup.md +19 -19
- package/dist/cjs/development/QueryClient-CLi3ONNM.js +0 -2
- package/dist/cjs/development/QueryClient-CLi3ONNM.js.map +0 -1
- package/dist/cjs/development/QueryController-BQA49OYU.js +0 -2
- package/dist/cjs/development/QueryController-BQA49OYU.js.map +0 -1
- package/dist/cjs/development/mutation-CikIl_6k.js +0 -2
- package/dist/cjs/development/mutation-CikIl_6k.js.map +0 -1
- package/dist/cjs/production/QueryClient-N0MJmuHW.js +0 -2
- package/dist/cjs/production/QueryClient-N0MJmuHW.js.map +0 -1
- package/dist/cjs/production/QueryController-BQA49OYU.js +0 -2
- package/dist/cjs/production/QueryController-BQA49OYU.js.map +0 -1
- package/dist/cjs/production/mutation-P_Yb4LI9.js +0 -2
- package/dist/cjs/production/mutation-P_Yb4LI9.js.map +0 -1
- package/dist/esm/QueryController.d.ts.map +0 -1
- package/dist/esm/development/QueryClient-Dtde3pss.js.map +0 -1
- package/dist/esm/development/QueryController-Ch_ncxiI.js.map +0 -1
- package/dist/esm/development/mutation-UZshUQAf.js.map +0 -1
- package/dist/esm/production/QueryClient-YqnBxFy1.js.map +0 -1
- package/dist/esm/production/QueryController-Ch_ncxiI.js.map +0 -1
- package/dist/esm/production/mutation-pgFl1uIY.js.map +0 -1
- package/dist/esm/rest/RESTQueryController.d.ts.map +0 -1
- package/dist/esm/topic/TopicQueryController.d.ts.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { notifier as at, relay as It, setScopeOwner as ye, reactiveMethod as pe, signal as Nt, context as Mt, getContext as ge, task as ve, reactiveSignal as _e, isSignal as me, watcher as we } from "signalium";
|
|
2
2
|
import { registerCustomHash as Ee, hashValue as D } from "signalium/utils";
|
|
3
3
|
import { d as kt } from "./shared-DcuVH8Pf.js";
|
|
4
|
-
import { SyncQueryStore as
|
|
5
|
-
var L = /* @__PURE__ */ ((
|
|
4
|
+
import { SyncQueryStore as be, MemoryPersistentStore as Ce } from "./stores/sync.js";
|
|
5
|
+
var L = /* @__PURE__ */ ((i) => (i.Always = "always", i.Online = "online", i.OfflineFirst = "offlineFirst", i))(L || {}), d = /* @__PURE__ */ ((i) => (i[i.UNDEFINED = 1] = "UNDEFINED", i[i.NULL = 2] = "NULL", i[i.NUMBER = 4] = "NUMBER", i[i.STRING = 8] = "STRING", i[i.BOOLEAN = 16] = "BOOLEAN", i[i.OBJECT = 32] = "OBJECT", i[i.ARRAY = 64] = "ARRAY", i[i.ID = 128] = "ID", i[i.RECORD = 256] = "RECORD", i[i.UNION = 512] = "UNION", i[i.ENTITY = 1024] = "ENTITY", i[i.HAS_FORMAT = 4096] = "HAS_FORMAT", i[i.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", i[i.PARSE_RESULT = 16384] = "PARSE_RESULT", i[i.LIVE = 32768] = "LIVE", i))(d || {});
|
|
6
6
|
const Q = /* @__PURE__ */ Symbol("array"), B = /* @__PURE__ */ Symbol("record"), Ft = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
|
-
var ct = /* @__PURE__ */ ((
|
|
7
|
+
var ct = /* @__PURE__ */ ((i) => (i[i.Array = 0] = "Array", i[i.Value = 1] = "Value", i))(ct || {});
|
|
8
8
|
class j {
|
|
9
9
|
type;
|
|
10
10
|
entityDefs;
|
|
@@ -14,28 +14,28 @@ class j {
|
|
|
14
14
|
onCreate;
|
|
15
15
|
onUpdate;
|
|
16
16
|
onDelete;
|
|
17
|
-
constructor(t, e,
|
|
18
|
-
this.type = t, this.entityDefs = e, this.constraintFieldRefs =
|
|
17
|
+
constructor(t, e, n, s, r, o, a, c) {
|
|
18
|
+
this.type = t, this.entityDefs = e, this.constraintFieldRefs = n, this.sort = s, this.valueType = r, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
|
|
19
19
|
}
|
|
20
|
-
static array(t, e,
|
|
20
|
+
static array(t, e, n) {
|
|
21
21
|
return new j(
|
|
22
22
|
0,
|
|
23
23
|
t,
|
|
24
24
|
e,
|
|
25
|
-
|
|
25
|
+
n,
|
|
26
26
|
void 0,
|
|
27
27
|
void 0,
|
|
28
28
|
void 0,
|
|
29
29
|
void 0
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
-
static value(t, e,
|
|
32
|
+
static value(t, e, n, s, r, o) {
|
|
33
33
|
return new j(
|
|
34
34
|
1,
|
|
35
35
|
t,
|
|
36
36
|
e,
|
|
37
37
|
void 0,
|
|
38
|
-
|
|
38
|
+
n,
|
|
39
39
|
s,
|
|
40
40
|
r,
|
|
41
41
|
o
|
|
@@ -43,13 +43,13 @@ class j {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
const x = /* @__PURE__ */ new WeakMap();
|
|
46
|
-
function k(
|
|
47
|
-
return x.get(
|
|
46
|
+
function k(i) {
|
|
47
|
+
return x.get(i);
|
|
48
48
|
}
|
|
49
|
-
var z = /* @__PURE__ */ ((
|
|
49
|
+
var z = /* @__PURE__ */ ((i) => (i[i.Query = 0] = "Query", i[i.Entity = 1] = "Entity", i))(z || {});
|
|
50
50
|
class xe {
|
|
51
|
-
constructor(t, e,
|
|
52
|
-
this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 *
|
|
51
|
+
constructor(t, e, n) {
|
|
52
|
+
this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 * n);
|
|
53
53
|
}
|
|
54
54
|
_currentFlush = /* @__PURE__ */ new Map();
|
|
55
55
|
_nextFlush = /* @__PURE__ */ new Map();
|
|
@@ -61,9 +61,9 @@ class xe {
|
|
|
61
61
|
this._currentFlush.delete(t), this._nextFlush.delete(t);
|
|
62
62
|
}
|
|
63
63
|
_tick = () => {
|
|
64
|
-
const { _currentFlush: t, _nextFlush: e, _onEvict:
|
|
64
|
+
const { _currentFlush: t, _nextFlush: e, _onEvict: n } = this;
|
|
65
65
|
for (const [s, r] of t)
|
|
66
|
-
|
|
66
|
+
n(s, r);
|
|
67
67
|
this._currentFlush = e, this._nextFlush = /* @__PURE__ */ new Map();
|
|
68
68
|
};
|
|
69
69
|
destroy() {
|
|
@@ -79,16 +79,16 @@ class Oe {
|
|
|
79
79
|
constructor(t, e = 1) {
|
|
80
80
|
this._onEvict = t, this._multiplier = e;
|
|
81
81
|
}
|
|
82
|
-
schedule(t, e,
|
|
82
|
+
schedule(t, e, n) {
|
|
83
83
|
if (e === 1 / 0) return;
|
|
84
84
|
if (e === 0) {
|
|
85
85
|
const { _nextTickEntries: o } = this;
|
|
86
|
-
o.set(t,
|
|
86
|
+
o.set(t, n), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
const { _buckets: s } = this;
|
|
90
90
|
let r = s.get(e);
|
|
91
|
-
r || (r = new xe(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t,
|
|
91
|
+
r || (r = new xe(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t, n);
|
|
92
92
|
}
|
|
93
93
|
cancel(t, e) {
|
|
94
94
|
if (e !== 1 / 0) {
|
|
@@ -102,19 +102,19 @@ class Oe {
|
|
|
102
102
|
_flushNextTick = () => {
|
|
103
103
|
const { _nextTickEntries: t, _onEvict: e } = this;
|
|
104
104
|
this._nextTickScheduled = !1;
|
|
105
|
-
for (const [
|
|
106
|
-
e(
|
|
105
|
+
for (const [n, s] of t)
|
|
106
|
+
e(n, s);
|
|
107
107
|
t.clear();
|
|
108
108
|
};
|
|
109
109
|
destroy() {
|
|
110
110
|
const { _buckets: t, _nextTickEntries: e } = this;
|
|
111
|
-
for (const
|
|
112
|
-
|
|
111
|
+
for (const n of t.values())
|
|
112
|
+
n.destroy();
|
|
113
113
|
t.clear(), e.clear();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
class Re {
|
|
117
|
-
schedule(t, e,
|
|
117
|
+
schedule(t, e, n) {
|
|
118
118
|
}
|
|
119
119
|
cancel(t, e) {
|
|
120
120
|
}
|
|
@@ -122,39 +122,39 @@ class Re {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
const Y = /* @__PURE__ */ Symbol("fieldRef"), N = /* @__PURE__ */ Symbol("fieldRefPath"), ft = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Se = /\[([^\]]+)\]/g;
|
|
125
|
-
function Tt(
|
|
125
|
+
function Tt(i) {
|
|
126
126
|
const t = {
|
|
127
127
|
[Y]: !0,
|
|
128
|
-
[N]:
|
|
128
|
+
[N]: i
|
|
129
129
|
};
|
|
130
130
|
return new Proxy(t, Ae);
|
|
131
131
|
}
|
|
132
132
|
const Ae = {
|
|
133
|
-
get(
|
|
133
|
+
get(i, t) {
|
|
134
134
|
if (t === Y) return !0;
|
|
135
|
-
if (t === N) return
|
|
135
|
+
if (t === N) return i[N];
|
|
136
136
|
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
|
|
137
|
-
const
|
|
138
|
-
return () => `[${
|
|
137
|
+
const n = i[N];
|
|
138
|
+
return () => `[${n.join(".")}]`;
|
|
139
139
|
}
|
|
140
140
|
if (typeof t == "symbol") return;
|
|
141
|
-
const e =
|
|
141
|
+
const e = i[N];
|
|
142
142
|
return Tt([...e, t]);
|
|
143
143
|
},
|
|
144
|
-
has(
|
|
144
|
+
has(i, t) {
|
|
145
145
|
return t === Y || t === N;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
function Pt(
|
|
149
|
-
return typeof
|
|
148
|
+
function Pt(i) {
|
|
149
|
+
return typeof i == "object" && i !== null && i[Y] === !0;
|
|
150
150
|
}
|
|
151
|
-
function Lt(
|
|
152
|
-
return
|
|
151
|
+
function Lt(i) {
|
|
152
|
+
return i[N];
|
|
153
153
|
}
|
|
154
|
-
function jt(
|
|
155
|
-
return new Proxy(
|
|
156
|
-
set(t, e,
|
|
157
|
-
return t[e] =
|
|
154
|
+
function jt(i) {
|
|
155
|
+
return new Proxy(i, {
|
|
156
|
+
set(t, e, n) {
|
|
157
|
+
return t[e] = n, !0;
|
|
158
158
|
},
|
|
159
159
|
get(t, e) {
|
|
160
160
|
return e === ft ? t : e === G ? () => {
|
|
@@ -162,56 +162,56 @@ function jt(n) {
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
-
function De(
|
|
166
|
-
const t =
|
|
167
|
-
|
|
165
|
+
function De(i) {
|
|
166
|
+
const t = i[ft];
|
|
167
|
+
i[G]();
|
|
168
168
|
const e = {};
|
|
169
169
|
for (const r of Object.getOwnPropertyNames(t))
|
|
170
170
|
e[r] = t[r];
|
|
171
|
-
const
|
|
171
|
+
const n = {};
|
|
172
172
|
let s = Object.getPrototypeOf(t);
|
|
173
173
|
for (; s && s !== Object.prototype; ) {
|
|
174
174
|
for (const r of Object.getOwnPropertyNames(s)) {
|
|
175
175
|
if (r === "constructor") continue;
|
|
176
176
|
const o = Object.getOwnPropertyDescriptor(s, r);
|
|
177
|
-
typeof o.value == "function" && !(r in
|
|
177
|
+
typeof o.value == "function" && !(r in n) && (n[r] = o.value);
|
|
178
178
|
}
|
|
179
179
|
s = Object.getPrototypeOf(s);
|
|
180
180
|
}
|
|
181
|
-
return { fields: e, methods:
|
|
181
|
+
return { fields: e, methods: n };
|
|
182
182
|
}
|
|
183
|
-
function ut(
|
|
183
|
+
function ut(i, t) {
|
|
184
184
|
let e = t;
|
|
185
|
-
for (const
|
|
185
|
+
for (const n of i) {
|
|
186
186
|
if (e == null) return;
|
|
187
|
-
e = e[
|
|
187
|
+
e = e[n];
|
|
188
188
|
}
|
|
189
189
|
return e;
|
|
190
190
|
}
|
|
191
|
-
function Ie(
|
|
192
|
-
return
|
|
193
|
-
const s =
|
|
191
|
+
function Ie(i, t) {
|
|
192
|
+
return i.replace(Se, (e, n) => {
|
|
193
|
+
const s = n.split("."), r = ut(s, t);
|
|
194
194
|
return r != null ? encodeURIComponent(String(r)) : "";
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
|
-
function W(
|
|
198
|
-
if (Pt(
|
|
199
|
-
return ut(Lt(
|
|
200
|
-
if (typeof
|
|
201
|
-
return Ie(
|
|
202
|
-
if (Array.isArray(
|
|
203
|
-
return
|
|
204
|
-
if (typeof
|
|
197
|
+
function W(i, t) {
|
|
198
|
+
if (Pt(i))
|
|
199
|
+
return ut(Lt(i), t);
|
|
200
|
+
if (typeof i == "string")
|
|
201
|
+
return Ie(i, t);
|
|
202
|
+
if (Array.isArray(i))
|
|
203
|
+
return i.map((e) => W(e, t));
|
|
204
|
+
if (typeof i == "object" && i !== null && Object.getPrototypeOf(i) === Object.prototype) {
|
|
205
205
|
const e = {};
|
|
206
|
-
for (const
|
|
207
|
-
e[
|
|
206
|
+
for (const n of Object.keys(i))
|
|
207
|
+
e[n] = W(i[n], t);
|
|
208
208
|
return e;
|
|
209
209
|
}
|
|
210
|
-
return
|
|
210
|
+
return i;
|
|
211
211
|
}
|
|
212
|
-
function et(
|
|
213
|
-
const
|
|
214
|
-
for (const [a, c] of Object.entries(
|
|
212
|
+
function et(i, t, e) {
|
|
213
|
+
const n = i.fields, s = i.methods, r = { params: t }, o = {};
|
|
214
|
+
for (const [a, c] of Object.entries(n))
|
|
215
215
|
o[a] = W(c, r);
|
|
216
216
|
o.params = t, o.context = e;
|
|
217
217
|
for (const [a, c] of Object.entries(s))
|
|
@@ -224,30 +224,30 @@ class qt {
|
|
|
224
224
|
return jt(this);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
const Ut = Object.entries,
|
|
228
|
-
function wt(
|
|
229
|
-
return typeof
|
|
227
|
+
const Ut = Object.entries, it = Object.keys;
|
|
228
|
+
function wt(i) {
|
|
229
|
+
return typeof i == "number" ? i | d.UNDEFINED : i instanceof _ ? (i.mask & d.UNDEFINED) !== 0 ? i : _.cloneWith(i, d.UNDEFINED) : i;
|
|
230
230
|
}
|
|
231
|
-
function Ne(
|
|
232
|
-
return
|
|
231
|
+
function Ne(i) {
|
|
232
|
+
return i instanceof _ && (i.mask & d.OBJECT) !== 0 && (i.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
233
233
|
}
|
|
234
|
-
function Vt(
|
|
235
|
-
const
|
|
236
|
-
for (const r of
|
|
234
|
+
function Vt(i, t, e) {
|
|
235
|
+
const n = /* @__PURE__ */ new Set();
|
|
236
|
+
for (const r of i)
|
|
237
237
|
if (r !== void 0)
|
|
238
238
|
for (const o of Object.keys(r))
|
|
239
|
-
|
|
239
|
+
n.add(o);
|
|
240
240
|
const s = {};
|
|
241
|
-
for (const r of
|
|
241
|
+
for (const r of n) {
|
|
242
242
|
let o = 0, a;
|
|
243
243
|
const c = [];
|
|
244
244
|
let f = !0;
|
|
245
|
-
for (const
|
|
246
|
-
const u =
|
|
245
|
+
for (const l of i) {
|
|
246
|
+
const u = l?.[r];
|
|
247
247
|
u !== void 0 ? (o++, a === void 0 && (a = u), Ne(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
248
248
|
}
|
|
249
249
|
if (f && o > 0) {
|
|
250
|
-
const
|
|
250
|
+
const l = Vt(c, t), u = new _(d.OBJECT, l);
|
|
251
251
|
s[r] = o < t ? wt(u) : u;
|
|
252
252
|
} else
|
|
253
253
|
s[r] = o < t ? wt(a) : a;
|
|
@@ -283,14 +283,14 @@ class _ {
|
|
|
283
283
|
* Live data configuration (shared by LiveArray and LiveValue).
|
|
284
284
|
*/
|
|
285
285
|
_liveConfig = void 0;
|
|
286
|
-
constructor(t, e,
|
|
287
|
-
this.mask = t, this.shape = e, this.values =
|
|
286
|
+
constructor(t, e, n, s, r, o) {
|
|
287
|
+
this.mask = t, this.shape = e, this.values = n, this.typenameField = s, this.typenameValue = r, this.idField = o;
|
|
288
288
|
}
|
|
289
289
|
static merge(t) {
|
|
290
290
|
if (t.length === 1) return t[0];
|
|
291
|
-
const e = t.length,
|
|
291
|
+
const e = t.length, n = t.map((c) => c.shape);
|
|
292
292
|
t[0].typenameValue;
|
|
293
|
-
const s = Vt(
|
|
293
|
+
const s = Vt(n, e);
|
|
294
294
|
let r, o, a;
|
|
295
295
|
for (const c of t) {
|
|
296
296
|
if (r === void 0 && c.idField !== void 0)
|
|
@@ -302,7 +302,7 @@ class _ {
|
|
|
302
302
|
o === void 0 && (o = c.typenameField), a === void 0 && (a = c.typenameValue);
|
|
303
303
|
}
|
|
304
304
|
return new _(
|
|
305
|
-
|
|
305
|
+
d.ENTITY | d.OBJECT,
|
|
306
306
|
s,
|
|
307
307
|
void 0,
|
|
308
308
|
o,
|
|
@@ -311,7 +311,7 @@ class _ {
|
|
|
311
311
|
);
|
|
312
312
|
}
|
|
313
313
|
static cloneWith(t, e) {
|
|
314
|
-
const
|
|
314
|
+
const n = new _(
|
|
315
315
|
e | t.mask,
|
|
316
316
|
t.shape,
|
|
317
317
|
t.values,
|
|
@@ -319,7 +319,7 @@ class _ {
|
|
|
319
319
|
t.typenameValue,
|
|
320
320
|
t.idField
|
|
321
321
|
);
|
|
322
|
-
return
|
|
322
|
+
return n._methods = t._methods, n._entityConfig = t._entityConfig, n._entityClass = t._entityClass, n._entityCache = t._entityCache, n._liveConfig = t._liveConfig, n;
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
class H extends Set {
|
|
@@ -329,12 +329,12 @@ class H extends Set {
|
|
|
329
329
|
super(t), this.lowercaseMap = /* @__PURE__ */ new Map();
|
|
330
330
|
for (const e of t)
|
|
331
331
|
if (typeof e == "string") {
|
|
332
|
-
const
|
|
332
|
+
const n = e.toLowerCase(), s = this.lowercaseMap.get(n);
|
|
333
333
|
if (s !== void 0)
|
|
334
334
|
throw new Error(
|
|
335
|
-
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${
|
|
335
|
+
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${n}'`
|
|
336
336
|
);
|
|
337
|
-
this.lowercaseMap.set(
|
|
337
|
+
this.lowercaseMap.set(n, e);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
@@ -358,33 +358,33 @@ class H extends Set {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
const Me = 1128875347;
|
|
361
|
-
Ee(H, (
|
|
361
|
+
Ee(H, (i) => {
|
|
362
362
|
let t = Me;
|
|
363
|
-
for (const e of
|
|
363
|
+
for (const e of i)
|
|
364
364
|
t += D(e);
|
|
365
365
|
return t >>> 0;
|
|
366
366
|
});
|
|
367
|
-
function
|
|
368
|
-
return new _(
|
|
367
|
+
function dt(i, t) {
|
|
368
|
+
return new _(i, t);
|
|
369
369
|
}
|
|
370
|
-
function ke(
|
|
371
|
-
return
|
|
370
|
+
function ke(i) {
|
|
371
|
+
return dt(d.ARRAY, i);
|
|
372
372
|
}
|
|
373
|
-
function Fe(
|
|
374
|
-
return
|
|
373
|
+
function Fe(i) {
|
|
374
|
+
return dt(d.RECORD | d.OBJECT, i);
|
|
375
375
|
}
|
|
376
|
-
function Te(
|
|
377
|
-
return
|
|
376
|
+
function Te(i) {
|
|
377
|
+
return dt(d.PARSE_RESULT, i);
|
|
378
378
|
}
|
|
379
|
-
function Kt(
|
|
380
|
-
let e =
|
|
379
|
+
function Kt(i, t) {
|
|
380
|
+
let e = i, n, s, r;
|
|
381
381
|
for (const [o, a] of Ut(t))
|
|
382
382
|
switch (typeof a) {
|
|
383
383
|
case "number":
|
|
384
|
-
if ((a &
|
|
385
|
-
if (
|
|
384
|
+
if ((a & d.ID) !== 0) {
|
|
385
|
+
if (n !== void 0)
|
|
386
386
|
throw new Error(`Duplicate id field: ${o}`);
|
|
387
|
-
|
|
387
|
+
n = o;
|
|
388
388
|
}
|
|
389
389
|
break;
|
|
390
390
|
case "string":
|
|
@@ -395,18 +395,18 @@ function Kt(n, t) {
|
|
|
395
395
|
case "object":
|
|
396
396
|
if (a instanceof H || a instanceof Set)
|
|
397
397
|
break;
|
|
398
|
-
a.mask &
|
|
398
|
+
a.mask & d.LIVE && (e |= d.LIVE);
|
|
399
399
|
break;
|
|
400
400
|
}
|
|
401
|
-
return new _(e, t, void 0, s, r,
|
|
401
|
+
return new _(e, t, void 0, s, r, n);
|
|
402
402
|
}
|
|
403
|
-
function Pe(
|
|
404
|
-
return Kt(
|
|
403
|
+
function Pe(i) {
|
|
404
|
+
return Kt(d.OBJECT, i);
|
|
405
405
|
}
|
|
406
|
-
function Et(
|
|
407
|
-
const
|
|
408
|
-
if ((
|
|
409
|
-
const s =
|
|
406
|
+
function Et(i, t, e) {
|
|
407
|
+
const n = i.mask;
|
|
408
|
+
if ((n & d.UNION) !== 0) {
|
|
409
|
+
const s = i;
|
|
410
410
|
if (s.typenameField !== void 0) {
|
|
411
411
|
if (e !== void 0 && e !== s.typenameField)
|
|
412
412
|
throw new Error(
|
|
@@ -416,7 +416,7 @@ function Et(n, t, e) {
|
|
|
416
416
|
}
|
|
417
417
|
const r = s.shape;
|
|
418
418
|
if (r !== void 0)
|
|
419
|
-
for (const o of [...
|
|
419
|
+
for (const o of [...it(r), Q, B]) {
|
|
420
420
|
const a = r[o];
|
|
421
421
|
if (t[o] !== void 0 && t[o] !== a)
|
|
422
422
|
throw new Error(
|
|
@@ -424,210 +424,210 @@ function Et(n, t, e) {
|
|
|
424
424
|
);
|
|
425
425
|
t[o] = a;
|
|
426
426
|
}
|
|
427
|
-
} else if ((
|
|
427
|
+
} else if ((n & d.ARRAY) !== 0) {
|
|
428
428
|
if (t[Q] !== void 0)
|
|
429
429
|
throw new Error("Array shape already defined");
|
|
430
|
-
t[Q] =
|
|
431
|
-
} else if ((
|
|
430
|
+
t[Q] = i.shape;
|
|
431
|
+
} else if ((n & d.RECORD) !== 0) {
|
|
432
432
|
if (t[B] !== void 0)
|
|
433
433
|
throw new Error("Record shape already defined");
|
|
434
|
-
t[B] =
|
|
434
|
+
t[B] = i.shape;
|
|
435
435
|
} else {
|
|
436
|
-
const s =
|
|
436
|
+
const s = i.typenameField, r = i.typenameValue;
|
|
437
437
|
if (r === void 0)
|
|
438
438
|
throw new Error(
|
|
439
439
|
"Object definitions must have a typename to be in a union with other objects, records, or arrays"
|
|
440
440
|
);
|
|
441
441
|
if (e !== void 0 && s !== e)
|
|
442
442
|
throw new Error("Object definitions must have the same typename field to be in the same union");
|
|
443
|
-
e = s, t[r] =
|
|
443
|
+
e = s, t[r] = i;
|
|
444
444
|
}
|
|
445
445
|
return e;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
448
|
-
const t =
|
|
449
|
-
let e = 0,
|
|
450
|
-
for (const
|
|
451
|
-
if (typeof
|
|
452
|
-
e |=
|
|
447
|
+
function lt(...i) {
|
|
448
|
+
const t = i;
|
|
449
|
+
let e = 0, n = 0, s, r, o, a, c = 0;
|
|
450
|
+
for (const l of t) {
|
|
451
|
+
if (typeof l == "number") {
|
|
452
|
+
e |= l;
|
|
453
453
|
continue;
|
|
454
454
|
}
|
|
455
|
-
if (
|
|
455
|
+
if (l instanceof Set) {
|
|
456
456
|
if (r === void 0)
|
|
457
|
-
r = new Set(
|
|
457
|
+
r = new Set(l);
|
|
458
458
|
else
|
|
459
|
-
for (const u of
|
|
459
|
+
for (const u of l)
|
|
460
460
|
r.add(u);
|
|
461
461
|
continue;
|
|
462
462
|
}
|
|
463
|
-
if (
|
|
464
|
-
s =
|
|
463
|
+
if (n++, c |= l.mask, n === 1) {
|
|
464
|
+
s = l;
|
|
465
465
|
continue;
|
|
466
466
|
}
|
|
467
|
-
|
|
467
|
+
n === 2 && (o = /* @__PURE__ */ Object.create(null), a = Et(s, o, a)), a = Et(l, o, a);
|
|
468
468
|
}
|
|
469
|
-
if (
|
|
470
|
-
return r === void 0 ? e : e === 0 ? r : new _(e |
|
|
471
|
-
if (
|
|
469
|
+
if (n === 0)
|
|
470
|
+
return r === void 0 ? e : e === 0 ? r : new _(e | d.UNION, void 0, r);
|
|
471
|
+
if (n === 1)
|
|
472
472
|
return _.cloneWith(s, e);
|
|
473
|
-
const f = e | c |
|
|
473
|
+
const f = e | c | d.UNION;
|
|
474
474
|
return new _(f, o, r, a);
|
|
475
475
|
}
|
|
476
|
-
function ht(
|
|
477
|
-
const
|
|
478
|
-
if (typeof
|
|
479
|
-
return
|
|
480
|
-
if (
|
|
481
|
-
return
|
|
482
|
-
let s = e.get(
|
|
483
|
-
return s === void 0 && (s = _.cloneWith(
|
|
476
|
+
function ht(i, t, e) {
|
|
477
|
+
const n = i;
|
|
478
|
+
if (typeof n == "number")
|
|
479
|
+
return n | t;
|
|
480
|
+
if (n instanceof Set)
|
|
481
|
+
return lt(i, t);
|
|
482
|
+
let s = e.get(n);
|
|
483
|
+
return s === void 0 && (s = _.cloneWith(n, t), e.set(n, s)), s;
|
|
484
484
|
}
|
|
485
485
|
const Le = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap();
|
|
486
|
-
function Ue(
|
|
487
|
-
return ht(
|
|
486
|
+
function Ue(i) {
|
|
487
|
+
return ht(i, d.UNDEFINED | d.NULL, qe);
|
|
488
488
|
}
|
|
489
|
-
function Ve(
|
|
490
|
-
return ht(
|
|
489
|
+
function Ve(i) {
|
|
490
|
+
return ht(i, d.UNDEFINED, Le);
|
|
491
491
|
}
|
|
492
|
-
function Ke(
|
|
493
|
-
return ht(
|
|
492
|
+
function Ke(i) {
|
|
493
|
+
return ht(i, d.NULL, je);
|
|
494
494
|
}
|
|
495
|
-
function $e(
|
|
496
|
-
return
|
|
495
|
+
function $e(i) {
|
|
496
|
+
return i;
|
|
497
497
|
}
|
|
498
|
-
function Qe(
|
|
499
|
-
return /* @__PURE__ */ new Set([
|
|
498
|
+
function Qe(i) {
|
|
499
|
+
return /* @__PURE__ */ new Set([i]);
|
|
500
500
|
}
|
|
501
|
-
const $t = ((...
|
|
502
|
-
$t.caseInsensitive = (...
|
|
501
|
+
const $t = ((...i) => new Set(i));
|
|
502
|
+
$t.caseInsensitive = (...i) => new H(i);
|
|
503
503
|
const Qt = 16;
|
|
504
504
|
let Be = 0;
|
|
505
|
-
const
|
|
505
|
+
const nt = [], Bt = [], Yt = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new WeakSet();
|
|
506
506
|
class q {
|
|
507
507
|
_raw;
|
|
508
508
|
_formatted;
|
|
509
509
|
_parsed;
|
|
510
510
|
_formatId;
|
|
511
|
-
constructor(t, e,
|
|
512
|
-
this._raw = t, this._formatId = e,
|
|
511
|
+
constructor(t, e, n) {
|
|
512
|
+
this._raw = t, this._formatId = e, n ? (this._formatted = nt[e](t), this._parsed = !0) : this._parsed = !1, J.add(this);
|
|
513
513
|
}
|
|
514
514
|
getValue() {
|
|
515
|
-
return this._parsed || (this._formatted =
|
|
515
|
+
return this._parsed || (this._formatted = nt[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
516
516
|
}
|
|
517
517
|
toJSON() {
|
|
518
518
|
return this._parsed ? Bt[this._formatId](this._formatted) : this._raw;
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
function Ye(
|
|
522
|
-
const t = Yt.get(
|
|
521
|
+
function Ye(i) {
|
|
522
|
+
const t = Yt.get(i);
|
|
523
523
|
if (t === void 0)
|
|
524
|
-
throw new Error(`Format ${
|
|
524
|
+
throw new Error(`Format ${i} not registered`);
|
|
525
525
|
return t;
|
|
526
526
|
}
|
|
527
|
-
function Gt(
|
|
527
|
+
function Gt(i, t, e, n, s) {
|
|
528
528
|
const r = Be++;
|
|
529
|
-
|
|
530
|
-
const o = s?.eager ?? !0, c = r << Qt | t |
|
|
531
|
-
Yt.set(
|
|
529
|
+
nt[r] = e, Bt[r] = n;
|
|
530
|
+
const o = s?.eager ?? !0, c = r << Qt | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
531
|
+
Yt.set(i, c);
|
|
532
532
|
}
|
|
533
533
|
Gt(
|
|
534
534
|
"date",
|
|
535
|
-
|
|
536
|
-
(
|
|
537
|
-
const t =
|
|
535
|
+
d.STRING,
|
|
536
|
+
(i) => {
|
|
537
|
+
const t = i.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
538
538
|
if (!t)
|
|
539
|
-
throw new Error(`Invalid date string: ${
|
|
540
|
-
const [, e,
|
|
539
|
+
throw new Error(`Invalid date string: ${i}. Expected YYYY-MM-DD format.`);
|
|
540
|
+
const [, e, n, s] = t, r = new Date(Date.UTC(parseInt(e, 10), parseInt(n, 10) - 1, parseInt(s, 10)));
|
|
541
541
|
if (isNaN(r.getTime()))
|
|
542
|
-
throw new Error(`Invalid date string: ${
|
|
542
|
+
throw new Error(`Invalid date string: ${i}`);
|
|
543
543
|
return r;
|
|
544
544
|
},
|
|
545
|
-
(
|
|
546
|
-
const t =
|
|
547
|
-
return `${t}-${e}-${
|
|
545
|
+
(i) => {
|
|
546
|
+
const t = i.getUTCFullYear(), e = String(i.getUTCMonth() + 1).padStart(2, "0"), n = String(i.getUTCDate()).padStart(2, "0");
|
|
547
|
+
return `${t}-${e}-${n}`;
|
|
548
548
|
}
|
|
549
549
|
);
|
|
550
550
|
Gt(
|
|
551
551
|
"date-time",
|
|
552
|
-
|
|
553
|
-
(
|
|
554
|
-
const t = new Date(
|
|
552
|
+
d.STRING,
|
|
553
|
+
(i) => {
|
|
554
|
+
const t = new Date(i);
|
|
555
555
|
if (isNaN(t.getTime()))
|
|
556
|
-
throw new Error(`Invalid date-time string: ${
|
|
556
|
+
throw new Error(`Invalid date-time string: ${i}`);
|
|
557
557
|
return t;
|
|
558
558
|
},
|
|
559
|
-
(
|
|
559
|
+
(i) => i.toISOString()
|
|
560
560
|
);
|
|
561
|
-
const
|
|
562
|
-
function T(
|
|
563
|
-
let t =
|
|
561
|
+
const bt = /* @__PURE__ */ new WeakMap();
|
|
562
|
+
function T(i) {
|
|
563
|
+
let t = bt.get(i);
|
|
564
564
|
if (t === void 0) {
|
|
565
|
-
const e = new
|
|
565
|
+
const e = new i(), n = e[ft] ?? e;
|
|
566
566
|
e[G] && e[G]();
|
|
567
567
|
const s = {};
|
|
568
|
-
for (const [f,
|
|
569
|
-
s[f] =
|
|
570
|
-
const r = Object.getPrototypeOf(
|
|
568
|
+
for (const [f, l] of Ut(n))
|
|
569
|
+
s[f] = l;
|
|
570
|
+
const r = Object.getPrototypeOf(i.prototype);
|
|
571
571
|
if (r != null) {
|
|
572
572
|
const f = r.constructor;
|
|
573
573
|
if (f !== qt && typeof f == "function") {
|
|
574
574
|
const u = T(f).shape;
|
|
575
|
-
for (const y of
|
|
575
|
+
for (const y of it(u))
|
|
576
576
|
if (y in s && s[y] !== u[y])
|
|
577
577
|
throw new Error(`Cannot extend: field '${y}' already exists in type definition`);
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
|
-
const o = {}, a =
|
|
580
|
+
const o = {}, a = i.prototype;
|
|
581
581
|
for (const f of Object.getOwnPropertyNames(a))
|
|
582
582
|
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
583
|
-
t = Kt(
|
|
584
|
-
const c =
|
|
585
|
-
c.cache && (t._entityCache = c.cache),
|
|
583
|
+
t = Kt(d.ENTITY | d.OBJECT, s), t._entityClass = i, it(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
584
|
+
const c = i;
|
|
585
|
+
c.cache && (t._entityCache = c.cache), bt.set(i, t);
|
|
586
586
|
}
|
|
587
587
|
return t;
|
|
588
588
|
}
|
|
589
|
-
function Ge(
|
|
590
|
-
return T(
|
|
589
|
+
function Ge(i) {
|
|
590
|
+
return T(i);
|
|
591
591
|
}
|
|
592
|
-
function Wt(
|
|
592
|
+
function Wt(i, t) {
|
|
593
593
|
if (t == null) return;
|
|
594
594
|
const e = /* @__PURE__ */ new Map();
|
|
595
595
|
if (Array.isArray(t))
|
|
596
|
-
for (const
|
|
597
|
-
const [s, r] =
|
|
596
|
+
for (const n of t) {
|
|
597
|
+
const [s, r] = n, a = T(s).typenameValue;
|
|
598
598
|
if (a === void 0) continue;
|
|
599
599
|
const c = [];
|
|
600
|
-
for (const [f,
|
|
601
|
-
c.push([f,
|
|
600
|
+
for (const [f, l] of Object.entries(r))
|
|
601
|
+
c.push([f, l]);
|
|
602
602
|
c.length > 0 && e.set(a, c);
|
|
603
603
|
}
|
|
604
604
|
else {
|
|
605
605
|
const s = Object.entries(t);
|
|
606
606
|
if (s.length === 0) return;
|
|
607
607
|
const r = s.map(([o, a]) => [o, a]);
|
|
608
|
-
for (const o of
|
|
608
|
+
for (const o of i) {
|
|
609
609
|
const a = o.typenameValue;
|
|
610
610
|
a !== void 0 && e.set(a, r);
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
return e.size > 0 ? e : void 0;
|
|
614
614
|
}
|
|
615
|
-
function zt(
|
|
616
|
-
return Array.isArray(
|
|
615
|
+
function zt(i) {
|
|
616
|
+
return Array.isArray(i) ? i.map((t) => T(t)) : [T(i)];
|
|
617
617
|
}
|
|
618
|
-
function We(
|
|
619
|
-
const e = zt(
|
|
618
|
+
function We(i, t) {
|
|
619
|
+
const e = zt(i), n = e.length === 1 ? e[0] : lt(...e.map((o) => o)), s = d.ARRAY | d.LIVE, r = new _(s, n);
|
|
620
620
|
return r._liveConfig = j.array(
|
|
621
621
|
e,
|
|
622
622
|
Wt(e, t?.constraints),
|
|
623
623
|
t?.sort
|
|
624
624
|
), r;
|
|
625
625
|
}
|
|
626
|
-
function ze(
|
|
627
|
-
const
|
|
626
|
+
function ze(i, t, e) {
|
|
627
|
+
const n = zt(t), s = i, r = d.LIVE, o = new _(r, void 0);
|
|
628
628
|
return o._liveConfig = j.value(
|
|
629
|
-
|
|
630
|
-
Wt(
|
|
629
|
+
n,
|
|
630
|
+
Wt(n, e?.constraints),
|
|
631
631
|
s,
|
|
632
632
|
e.onCreate,
|
|
633
633
|
e.onUpdate,
|
|
@@ -639,16 +639,16 @@ const He = {
|
|
|
639
639
|
typename: $e,
|
|
640
640
|
const: Qe,
|
|
641
641
|
enum: $t,
|
|
642
|
-
id:
|
|
643
|
-
string:
|
|
644
|
-
number:
|
|
645
|
-
boolean:
|
|
646
|
-
null:
|
|
647
|
-
undefined:
|
|
642
|
+
id: d.ID | d.STRING | d.NUMBER,
|
|
643
|
+
string: d.STRING,
|
|
644
|
+
number: d.NUMBER,
|
|
645
|
+
boolean: d.BOOLEAN,
|
|
646
|
+
null: d.NULL,
|
|
647
|
+
undefined: d.UNDEFINED,
|
|
648
648
|
array: ke,
|
|
649
649
|
object: Pe,
|
|
650
650
|
record: Fe,
|
|
651
|
-
union:
|
|
651
|
+
union: lt,
|
|
652
652
|
nullish: Ue,
|
|
653
653
|
optional: Ve,
|
|
654
654
|
nullable: Ke,
|
|
@@ -657,52 +657,52 @@ const He = {
|
|
|
657
657
|
liveArray: We,
|
|
658
658
|
liveValue: ze
|
|
659
659
|
};
|
|
660
|
-
function P(
|
|
661
|
-
return new TypeError(`Validation error at ${
|
|
660
|
+
function P(i, t, e) {
|
|
661
|
+
return new TypeError(`Validation error at ${i}`);
|
|
662
662
|
}
|
|
663
663
|
const Ht = Array.isArray;
|
|
664
|
-
function
|
|
665
|
-
if (
|
|
666
|
-
switch (typeof
|
|
664
|
+
function Ct(i) {
|
|
665
|
+
if (i === null) return d.NULL;
|
|
666
|
+
switch (typeof i) {
|
|
667
667
|
case "number":
|
|
668
|
-
return
|
|
668
|
+
return d.NUMBER;
|
|
669
669
|
case "string":
|
|
670
|
-
return
|
|
670
|
+
return d.STRING;
|
|
671
671
|
case "boolean":
|
|
672
|
-
return
|
|
672
|
+
return d.BOOLEAN;
|
|
673
673
|
case "undefined":
|
|
674
|
-
return
|
|
674
|
+
return d.UNDEFINED;
|
|
675
675
|
case "object":
|
|
676
|
-
return Ht(
|
|
676
|
+
return Ht(i) ? d.ARRAY : d.OBJECT;
|
|
677
677
|
default:
|
|
678
|
-
throw new Error(`Invalid type: ${typeof
|
|
678
|
+
throw new Error(`Invalid type: ${typeof i}`);
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
|
-
function
|
|
682
|
-
return F(
|
|
681
|
+
function Ai(i) {
|
|
682
|
+
return F(i);
|
|
683
683
|
}
|
|
684
|
-
function F(
|
|
685
|
-
if (
|
|
686
|
-
return
|
|
687
|
-
if (Ht(
|
|
688
|
-
return
|
|
689
|
-
if (
|
|
690
|
-
return new Date(
|
|
691
|
-
if (
|
|
684
|
+
function F(i) {
|
|
685
|
+
if (i === null || typeof i != "object")
|
|
686
|
+
return i;
|
|
687
|
+
if (Ht(i))
|
|
688
|
+
return i.map((e) => F(e));
|
|
689
|
+
if (i instanceof Date)
|
|
690
|
+
return new Date(i.getTime());
|
|
691
|
+
if (i instanceof Map) {
|
|
692
692
|
const e = /* @__PURE__ */ new Map();
|
|
693
|
-
for (const [
|
|
694
|
-
e.set(F(
|
|
693
|
+
for (const [n, s] of i)
|
|
694
|
+
e.set(F(n), F(s));
|
|
695
695
|
return e;
|
|
696
696
|
}
|
|
697
|
-
if (
|
|
697
|
+
if (i instanceof Set) {
|
|
698
698
|
const e = /* @__PURE__ */ new Set();
|
|
699
|
-
for (const
|
|
700
|
-
e.add(F(
|
|
699
|
+
for (const n of i)
|
|
700
|
+
e.add(F(n));
|
|
701
701
|
return e;
|
|
702
702
|
}
|
|
703
703
|
const t = {};
|
|
704
|
-
for (const e of Object.keys(
|
|
705
|
-
t[e] = F(
|
|
704
|
+
for (const e of Object.keys(i))
|
|
705
|
+
t[e] = F(i[e]);
|
|
706
706
|
return t;
|
|
707
707
|
}
|
|
708
708
|
const yt = Object.entries, Je = () => {
|
|
@@ -716,26 +716,26 @@ class st {
|
|
|
716
716
|
isPartialEvent = !1;
|
|
717
717
|
seen = void 0;
|
|
718
718
|
seenByKey = void 0;
|
|
719
|
-
reset(t, e,
|
|
720
|
-
this.queryClient = t, this.preloadedEntities = e, this.warn =
|
|
719
|
+
reset(t, e, n, s = !1) {
|
|
720
|
+
this.queryClient = t, this.preloadedEntities = e, this.warn = n, this.isPartialEvent = s, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
function Jt(
|
|
724
|
-
return M(
|
|
723
|
+
function Jt(i, t, e) {
|
|
724
|
+
return M(i, t, e, "");
|
|
725
725
|
}
|
|
726
|
-
function Xe(
|
|
727
|
-
return pt(
|
|
726
|
+
function Xe(i, t, e) {
|
|
727
|
+
return pt(i, t, e);
|
|
728
728
|
}
|
|
729
|
-
function xt(
|
|
730
|
-
const s =
|
|
731
|
-
if ((
|
|
729
|
+
function xt(i, t, e, n) {
|
|
730
|
+
const s = i >> Qt;
|
|
731
|
+
if ((i & d.IS_EAGER_FORMAT) !== 0)
|
|
732
732
|
try {
|
|
733
733
|
return new q(t, s, !0);
|
|
734
734
|
} catch (o) {
|
|
735
|
-
if ((
|
|
735
|
+
if ((i & d.UNDEFINED) !== 0) {
|
|
736
736
|
e.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
737
737
|
value: t,
|
|
738
|
-
path:
|
|
738
|
+
path: n,
|
|
739
739
|
error: o instanceof Error ? o.message : String(o)
|
|
740
740
|
});
|
|
741
741
|
return;
|
|
@@ -744,56 +744,56 @@ function xt(n, t, e, i) {
|
|
|
744
744
|
}
|
|
745
745
|
return new q(t, s, !1);
|
|
746
746
|
}
|
|
747
|
-
function M(
|
|
747
|
+
function M(i, t, e, n) {
|
|
748
748
|
const s = t;
|
|
749
749
|
if (s instanceof H) {
|
|
750
|
-
const c = s.get(
|
|
751
|
-
if (c === void 0) throw P(
|
|
750
|
+
const c = s.get(i);
|
|
751
|
+
if (c === void 0) throw P(n);
|
|
752
752
|
return c;
|
|
753
753
|
}
|
|
754
754
|
if (s instanceof Set) {
|
|
755
|
-
if (!s.has(
|
|
756
|
-
return
|
|
755
|
+
if (!s.has(i)) throw P(n);
|
|
756
|
+
return i;
|
|
757
757
|
}
|
|
758
758
|
if (typeof s == "string") {
|
|
759
|
-
if (
|
|
760
|
-
if (
|
|
761
|
-
return
|
|
759
|
+
if (i == null) return s;
|
|
760
|
+
if (i !== s) throw P(n);
|
|
761
|
+
return i;
|
|
762
762
|
}
|
|
763
763
|
if (typeof s == "number") {
|
|
764
|
-
const c =
|
|
764
|
+
const c = Ct(i);
|
|
765
765
|
if ((s & c) === 0) {
|
|
766
|
-
if ((s &
|
|
767
|
-
e.warn("Invalid value for optional type, defaulting to undefined", { value:
|
|
766
|
+
if ((s & d.UNDEFINED) !== 0) {
|
|
767
|
+
e.warn("Invalid value for optional type, defaulting to undefined", { value: i, path: n });
|
|
768
768
|
return;
|
|
769
769
|
}
|
|
770
|
-
throw P(
|
|
770
|
+
throw P(n);
|
|
771
771
|
}
|
|
772
|
-
return (s &
|
|
772
|
+
return (s & d.HAS_FORMAT) !== 0 && i !== null && i !== void 0 ? xt(s, i, e, n) : i;
|
|
773
773
|
}
|
|
774
774
|
const r = s.mask, o = s._liveConfig;
|
|
775
775
|
if (o !== void 0 && o.type === ct.Value)
|
|
776
|
-
return o.valueType !== void 0 ? M(
|
|
777
|
-
if ((r &
|
|
776
|
+
return o.valueType !== void 0 ? M(i, o.valueType, e, n) : i;
|
|
777
|
+
if ((r & d.PARSE_RESULT) !== 0)
|
|
778
778
|
try {
|
|
779
|
-
return { success: !0, value: M(
|
|
779
|
+
return { success: !0, value: M(i, s.shape, e, n) };
|
|
780
780
|
} catch (c) {
|
|
781
781
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
782
782
|
}
|
|
783
|
-
const a =
|
|
784
|
-
if ((r & a) === 0 && !s.values?.has(
|
|
785
|
-
if ((r &
|
|
786
|
-
e.warn("Invalid value for optional type, defaulting to undefined", { value:
|
|
783
|
+
const a = Ct(i);
|
|
784
|
+
if ((r & a) === 0 && !s.values?.has(i)) {
|
|
785
|
+
if ((r & d.UNDEFINED) !== 0) {
|
|
786
|
+
e.warn("Invalid value for optional type, defaulting to undefined", { value: i, path: n });
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
|
-
throw P(
|
|
789
|
+
throw P(n);
|
|
790
790
|
}
|
|
791
|
-
return a <
|
|
791
|
+
return a < d.OBJECT ? (r & d.HAS_FORMAT) !== 0 && i !== null && i !== void 0 ? xt(r, i, e, n) : i : (r & d.UNION) !== 0 ? Ze(a, i, s, e, n) : a === d.ARRAY ? Xt(i, s.shape, e, n) : (r & d.RECORD) !== 0 ? Zt(i, s.shape, e, n) : (r & d.ENTITY) !== 0 && e.queryClient !== void 0 ? pt(i, s, e) : te(i, s, e, n);
|
|
792
792
|
}
|
|
793
|
-
function Ze(
|
|
794
|
-
if (
|
|
793
|
+
function Ze(i, t, e, n, s) {
|
|
794
|
+
if (i === d.ARRAY) {
|
|
795
795
|
const r = e.shape[Q];
|
|
796
|
-
return r === void 0 || typeof r == "number" ? t : Xt(t, r,
|
|
796
|
+
return r === void 0 || typeof r == "number" ? t : Xt(t, r, n, s);
|
|
797
797
|
} else {
|
|
798
798
|
const r = e.typenameField, o = r ? t[r] : void 0;
|
|
799
799
|
if (o === void 0 || typeof o != "string") {
|
|
@@ -802,48 +802,48 @@ function Ze(n, t, e, i, s) {
|
|
|
802
802
|
throw new Error(
|
|
803
803
|
`Typename field '${r}' is required for union discrimination but was not found in the data`
|
|
804
804
|
);
|
|
805
|
-
return Zt(t, c,
|
|
805
|
+
return Zt(t, c, n, s);
|
|
806
806
|
}
|
|
807
807
|
const a = e.shape[o];
|
|
808
808
|
if (a === void 0 || typeof a == "number")
|
|
809
809
|
throw new Error(`Unknown typename '${o}' in union`);
|
|
810
|
-
return a.mask &
|
|
810
|
+
return a.mask & d.ENTITY && n.queryClient !== void 0 ? pt(t, a, n) : te(t, a, n, s);
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
function Xt(
|
|
813
|
+
function Xt(i, t, e, n) {
|
|
814
814
|
const s = [];
|
|
815
|
-
for (let r = 0; r <
|
|
815
|
+
for (let r = 0; r < i.length; r++)
|
|
816
816
|
try {
|
|
817
|
-
s.push(M(
|
|
817
|
+
s.push(M(i[r], t, e, `${n}[${r}]`));
|
|
818
818
|
} catch (o) {
|
|
819
819
|
e.warn("Failed to parse array item, filtering out", {
|
|
820
820
|
index: r,
|
|
821
|
-
value:
|
|
821
|
+
value: i[r],
|
|
822
822
|
error: o instanceof Error ? o.message : String(o)
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
825
|
return s;
|
|
826
826
|
}
|
|
827
|
-
function Zt(
|
|
828
|
-
for (const [s, r] of yt(
|
|
829
|
-
|
|
830
|
-
return
|
|
827
|
+
function Zt(i, t, e, n) {
|
|
828
|
+
for (const [s, r] of yt(i))
|
|
829
|
+
i[s] = M(r, t, e, `${n}["${s}"]`);
|
|
830
|
+
return i;
|
|
831
831
|
}
|
|
832
|
-
function te(
|
|
833
|
-
if (x.has(
|
|
834
|
-
return
|
|
832
|
+
function te(i, t, e, n) {
|
|
833
|
+
if (x.has(i))
|
|
834
|
+
return i;
|
|
835
835
|
const s = t.shape;
|
|
836
836
|
for (const [r, o] of yt(s))
|
|
837
|
-
|
|
838
|
-
return
|
|
837
|
+
i[r] = M(i[r], o, e, `${n}.${r}`);
|
|
838
|
+
return i;
|
|
839
839
|
}
|
|
840
|
-
function pt(
|
|
841
|
-
const
|
|
840
|
+
function pt(i, t, e) {
|
|
841
|
+
const n = e.queryClient, s = e.preloadedEntities;
|
|
842
842
|
let r, o;
|
|
843
843
|
if (s !== void 0)
|
|
844
|
-
r =
|
|
844
|
+
r = i.__entityRef, o = r;
|
|
845
845
|
else {
|
|
846
|
-
const p =
|
|
846
|
+
const p = i[t.idField];
|
|
847
847
|
if (p == null || typeof p != "string" && typeof p != "number")
|
|
848
848
|
throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
|
|
849
849
|
o = p, r = D([t.typenameValue, o]);
|
|
@@ -852,66 +852,66 @@ function pt(n, t, e) {
|
|
|
852
852
|
if (a !== void 0)
|
|
853
853
|
return a.data;
|
|
854
854
|
if (s !== void 0) {
|
|
855
|
-
const g =
|
|
855
|
+
const g = n.entityMap.getEntity(r)?.data ?? s.get(r);
|
|
856
856
|
if (g === void 0)
|
|
857
857
|
throw new Error(`Cached entity ${r} not found in preloaded map`);
|
|
858
|
-
|
|
858
|
+
i = g;
|
|
859
859
|
}
|
|
860
860
|
const c = {};
|
|
861
861
|
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
862
|
-
const f =
|
|
862
|
+
const f = n.entityMap.getEntity(r), l = e.isPartialEvent && f !== void 0, u = {
|
|
863
863
|
key: r,
|
|
864
864
|
shape: t,
|
|
865
865
|
data: c,
|
|
866
|
-
rawKeys:
|
|
866
|
+
rawKeys: l ? new Set(Object.keys(i)) : void 0
|
|
867
867
|
};
|
|
868
868
|
e.seen.set(c, u), e.seenByKey.set(r, u);
|
|
869
869
|
const y = `[[${t.typenameValue}:${o}]]`, v = t.shape;
|
|
870
870
|
for (const [p, g] of yt(v))
|
|
871
|
-
|
|
871
|
+
l && !(p in i) || (c[p] = M(i[p], g, e, `${y}.${p}`));
|
|
872
872
|
return c;
|
|
873
873
|
}
|
|
874
|
-
function
|
|
875
|
-
return
|
|
874
|
+
function ti(i, t) {
|
|
875
|
+
return ei(i, t.shape, t.typenameField);
|
|
876
876
|
}
|
|
877
|
-
function
|
|
877
|
+
function ei(i, t, e) {
|
|
878
878
|
if (t === void 0) return !0;
|
|
879
|
-
for (const
|
|
880
|
-
if (
|
|
881
|
-
const s = t[
|
|
879
|
+
for (const n of Object.keys(t)) {
|
|
880
|
+
if (n === e) continue;
|
|
881
|
+
const s = t[n];
|
|
882
882
|
if (s instanceof _) {
|
|
883
|
-
if ((s.mask &
|
|
884
|
-
if (!(
|
|
883
|
+
if ((s.mask & d.UNDEFINED) !== 0) continue;
|
|
884
|
+
if (!(n in i) || i[n] === void 0) return !1;
|
|
885
885
|
} else if (typeof s == "number") {
|
|
886
|
-
if ((s &
|
|
887
|
-
if (!(
|
|
888
|
-
} else if (!(
|
|
886
|
+
if ((s & d.UNDEFINED) !== 0) continue;
|
|
887
|
+
if (!(n in i) || i[n] === void 0) return !1;
|
|
888
|
+
} else if (!(n in i) || i[n] === void 0) return !1;
|
|
889
889
|
}
|
|
890
890
|
return !0;
|
|
891
891
|
}
|
|
892
|
-
const
|
|
893
|
-
function A(
|
|
894
|
-
if (typeof
|
|
895
|
-
if (J.has(
|
|
896
|
-
if (x.has(
|
|
897
|
-
if (Array.isArray(
|
|
898
|
-
let t = $.get(
|
|
899
|
-
return t === void 0 && (t = new Proxy(
|
|
892
|
+
const ii = Object.prototype, $ = /* @__PURE__ */ new WeakMap();
|
|
893
|
+
function A(i) {
|
|
894
|
+
if (typeof i != "object" || i === null) return i;
|
|
895
|
+
if (J.has(i)) return A(i.getValue());
|
|
896
|
+
if (x.has(i)) return i;
|
|
897
|
+
if (Array.isArray(i)) {
|
|
898
|
+
let t = $.get(i);
|
|
899
|
+
return t === void 0 && (t = new Proxy(i, ni), $.set(i, t)), t;
|
|
900
900
|
}
|
|
901
|
-
if (Object.getPrototypeOf(
|
|
902
|
-
let t = $.get(
|
|
903
|
-
return t === void 0 && (t = new Proxy(
|
|
901
|
+
if (Object.getPrototypeOf(i) === ii) {
|
|
902
|
+
let t = $.get(i);
|
|
903
|
+
return t === void 0 && (t = new Proxy(i, si), $.set(i, t)), t;
|
|
904
904
|
}
|
|
905
|
-
return
|
|
905
|
+
return i;
|
|
906
906
|
}
|
|
907
|
-
const
|
|
908
|
-
get(
|
|
907
|
+
const ni = {
|
|
908
|
+
get(i, t, e) {
|
|
909
909
|
if (typeof t == "string") {
|
|
910
|
-
const
|
|
911
|
-
if (Number.isInteger(
|
|
912
|
-
return A(n
|
|
910
|
+
const n = Number(t);
|
|
911
|
+
if (Number.isInteger(n) && n >= 0 && n < i.length)
|
|
912
|
+
return A(i[n]);
|
|
913
913
|
}
|
|
914
|
-
return Reflect.get(
|
|
914
|
+
return Reflect.get(i, t, e);
|
|
915
915
|
},
|
|
916
916
|
set() {
|
|
917
917
|
return !1;
|
|
@@ -919,9 +919,9 @@ const sn = {
|
|
|
919
919
|
deleteProperty() {
|
|
920
920
|
return !1;
|
|
921
921
|
}
|
|
922
|
-
},
|
|
923
|
-
get(
|
|
924
|
-
return typeof t == "string" ? A(
|
|
922
|
+
}, si = {
|
|
923
|
+
get(i, t, e) {
|
|
924
|
+
return typeof t == "string" ? A(i[t]) : Reflect.get(i, t, e);
|
|
925
925
|
},
|
|
926
926
|
set() {
|
|
927
927
|
return !1;
|
|
@@ -929,17 +929,17 @@ const sn = {
|
|
|
929
929
|
deleteProperty() {
|
|
930
930
|
return !1;
|
|
931
931
|
},
|
|
932
|
-
has(
|
|
933
|
-
return t in
|
|
932
|
+
has(i, t) {
|
|
933
|
+
return t in i;
|
|
934
934
|
},
|
|
935
|
-
ownKeys(
|
|
936
|
-
return Reflect.ownKeys(
|
|
935
|
+
ownKeys(i) {
|
|
936
|
+
return Reflect.ownKeys(i);
|
|
937
937
|
},
|
|
938
|
-
getOwnPropertyDescriptor(
|
|
939
|
-
return Object.getOwnPropertyDescriptor(
|
|
938
|
+
getOwnPropertyDescriptor(i, t) {
|
|
939
|
+
return Object.getOwnPropertyDescriptor(i, t);
|
|
940
940
|
}
|
|
941
941
|
};
|
|
942
|
-
class
|
|
942
|
+
class ri {
|
|
943
943
|
_notifier;
|
|
944
944
|
_queryClient;
|
|
945
945
|
_proxies = /* @__PURE__ */ new Map();
|
|
@@ -956,8 +956,8 @@ class on {
|
|
|
956
956
|
_entityCache;
|
|
957
957
|
_extraMethods;
|
|
958
958
|
_extraGetters;
|
|
959
|
-
constructor(t, e,
|
|
960
|
-
this._notifier = at(), this._queryClient = o, this.key = t, this.typename = e, this.id =
|
|
959
|
+
constructor(t, e, n, s, r, o) {
|
|
960
|
+
this._notifier = at(), this._queryClient = o, this.key = t, this.typename = e, this.id = n, this.idField = s, this.data = r, this.entityRefs = void 0;
|
|
961
961
|
}
|
|
962
962
|
retain() {
|
|
963
963
|
this.refCount++;
|
|
@@ -973,19 +973,19 @@ class on {
|
|
|
973
973
|
evict() {
|
|
974
974
|
const t = this.liveCollections.slice();
|
|
975
975
|
this.liveCollections.length = 0;
|
|
976
|
-
for (const
|
|
976
|
+
for (const n of t) n.destroy();
|
|
977
977
|
this._queryClient.entityMap.remove(this.key);
|
|
978
978
|
const e = this.entityRefs;
|
|
979
979
|
if (this.entityRefs = void 0, e)
|
|
980
|
-
for (const
|
|
980
|
+
for (const n of e.keys()) n.release();
|
|
981
981
|
}
|
|
982
982
|
setChildRefs(t, e) {
|
|
983
|
-
const
|
|
983
|
+
const n = this.entityRefs;
|
|
984
984
|
if (t !== void 0 && t.size > 0)
|
|
985
985
|
for (const s of t.keys())
|
|
986
|
-
(
|
|
987
|
-
if (
|
|
988
|
-
for (const s of
|
|
986
|
+
(n === void 0 || !n.has(s)) && s.retain();
|
|
987
|
+
if (n !== void 0 && n.size > 0)
|
|
988
|
+
for (const s of n.keys())
|
|
989
989
|
(t === void 0 || !t.has(s)) && s.release();
|
|
990
990
|
this.entityRefs = t, e && this.save();
|
|
991
991
|
}
|
|
@@ -1001,14 +1001,14 @@ class on {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
getProxy(t) {
|
|
1003
1003
|
const e = t;
|
|
1004
|
-
let
|
|
1005
|
-
return
|
|
1004
|
+
let n = this._proxies.get(e);
|
|
1005
|
+
return n === void 0 && (n = ai(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(e, n)), n;
|
|
1006
1006
|
}
|
|
1007
1007
|
get proxy() {
|
|
1008
1008
|
return this._proxies.values().next().value;
|
|
1009
1009
|
}
|
|
1010
1010
|
satisfiesDef(t) {
|
|
1011
|
-
return this.satisfiedDefs.has(t) ? !0 :
|
|
1011
|
+
return this.satisfiedDefs.has(t) ? !0 : ti(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
|
|
1012
1012
|
}
|
|
1013
1013
|
save() {
|
|
1014
1014
|
this._queryClient.entityMap.save(this);
|
|
@@ -1020,25 +1020,25 @@ class on {
|
|
|
1020
1020
|
this._notifier.consume();
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
|
-
function
|
|
1024
|
-
const
|
|
1025
|
-
for (const s of
|
|
1023
|
+
function oi(i, t, e) {
|
|
1024
|
+
const n = [];
|
|
1025
|
+
for (const s of i) {
|
|
1026
1026
|
if (typeof s != "object" || s === null) continue;
|
|
1027
1027
|
const r = x.get(s);
|
|
1028
1028
|
if (r === void 0) continue;
|
|
1029
1029
|
const o = e.entityMap.getEntity(r);
|
|
1030
|
-
o !== void 0 && o.satisfiesDef(t) &&
|
|
1030
|
+
o !== void 0 && o.satisfiesDef(t) && n.push(s);
|
|
1031
1031
|
}
|
|
1032
|
-
return
|
|
1032
|
+
return n;
|
|
1033
1033
|
}
|
|
1034
|
-
function
|
|
1035
|
-
const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig,
|
|
1034
|
+
function ai(i, t, e, n, s) {
|
|
1035
|
+
const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype : qt.prototype;
|
|
1036
1036
|
e.typenameField;
|
|
1037
1037
|
const u = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
|
|
1038
1038
|
let p;
|
|
1039
1039
|
f?.hasSubscribe && a && "__subscribe" in a && (p = It((E) => {
|
|
1040
|
-
const h = (
|
|
1041
|
-
|
|
1040
|
+
const h = (b) => {
|
|
1041
|
+
b.__eventSource = t, s.applyMutationEvent(b);
|
|
1042
1042
|
}, m = a.__subscribe.call(g, h);
|
|
1043
1043
|
return E.value = g, m;
|
|
1044
1044
|
}));
|
|
@@ -1049,12 +1049,12 @@ function cn(n, t, e, i, s) {
|
|
|
1049
1049
|
w.includes(E) || w.push(E);
|
|
1050
1050
|
let I, O = w;
|
|
1051
1051
|
function K() {
|
|
1052
|
-
const E =
|
|
1052
|
+
const E = i._extraMethods;
|
|
1053
1053
|
if (E !== I) {
|
|
1054
1054
|
if (I = E, O = w.slice(), E !== void 0)
|
|
1055
1055
|
for (const m of Object.keys(E))
|
|
1056
1056
|
O.includes(m) || O.push(m);
|
|
1057
|
-
const h =
|
|
1057
|
+
const h = i._extraGetters;
|
|
1058
1058
|
if (h !== void 0)
|
|
1059
1059
|
for (const m of Object.keys(h))
|
|
1060
1060
|
O.includes(m) || O.push(m);
|
|
@@ -1063,43 +1063,43 @@ function cn(n, t, e, i, s) {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
const R = {
|
|
1065
1065
|
getPrototypeOf() {
|
|
1066
|
-
return
|
|
1066
|
+
return l;
|
|
1067
1067
|
},
|
|
1068
1068
|
get(E, h) {
|
|
1069
1069
|
if (typeof h == "symbol") return;
|
|
1070
1070
|
if (h === "toJSON") return v;
|
|
1071
1071
|
if (h === "__context") return s.getContext();
|
|
1072
|
-
if (h === "__typename") return
|
|
1073
|
-
if (p?.value,
|
|
1074
|
-
const
|
|
1075
|
-
if (
|
|
1076
|
-
return
|
|
1077
|
-
const S =
|
|
1072
|
+
if (h === "__typename") return i.typename;
|
|
1073
|
+
if (p?.value, n.consume(), typeof h == "string") {
|
|
1074
|
+
const b = i._extraGetters;
|
|
1075
|
+
if (b !== void 0 && h in b)
|
|
1076
|
+
return b[h]();
|
|
1077
|
+
const S = i._extraMethods;
|
|
1078
1078
|
if (S !== void 0 && h in S) {
|
|
1079
|
-
let
|
|
1080
|
-
return
|
|
1079
|
+
let C = u.get(h);
|
|
1080
|
+
return C || (C = S[h].bind(g), u.set(h, C)), C;
|
|
1081
1081
|
}
|
|
1082
1082
|
if (a && h in a) {
|
|
1083
|
-
let
|
|
1084
|
-
return
|
|
1083
|
+
let C = u.get(h);
|
|
1084
|
+
return C || (C = pe(g, a[h].bind(g)), u.set(h, C)), C;
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
1087
|
-
const m =
|
|
1087
|
+
const m = i.data[h];
|
|
1088
1088
|
if (typeof m == "object" && m !== null && J.has(m))
|
|
1089
1089
|
return A(m.getValue());
|
|
1090
1090
|
if (Array.isArray(m) && typeof h == "string") {
|
|
1091
|
-
const
|
|
1092
|
-
if (
|
|
1093
|
-
const S =
|
|
1094
|
-
if (S instanceof _ && (S.mask &
|
|
1095
|
-
const
|
|
1096
|
-
if (
|
|
1097
|
-
const _t = s.getEntityDefsForTypename(
|
|
1091
|
+
const b = r[h];
|
|
1092
|
+
if (b instanceof _ && (b.mask & d.ARRAY) !== 0) {
|
|
1093
|
+
const S = b.shape;
|
|
1094
|
+
if (S instanceof _ && (S.mask & d.ENTITY) !== 0) {
|
|
1095
|
+
const C = S.typenameValue;
|
|
1096
|
+
if (C !== void 0) {
|
|
1097
|
+
const _t = s.getEntityDefsForTypename(C);
|
|
1098
1098
|
if (_t !== void 0 && _t.length > 1) {
|
|
1099
1099
|
const X = y.get(h);
|
|
1100
1100
|
if (X !== void 0 && X.source === m)
|
|
1101
1101
|
return A(X.filtered);
|
|
1102
|
-
const mt =
|
|
1102
|
+
const mt = oi(m, S, s);
|
|
1103
1103
|
return y.set(h, { source: m, filtered: mt }), A(mt);
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
@@ -1115,10 +1115,10 @@ function cn(n, t, e, i, s) {
|
|
|
1115
1115
|
has(E, h) {
|
|
1116
1116
|
if (h === "__typename") return !0;
|
|
1117
1117
|
if (typeof h == "string") {
|
|
1118
|
-
const m =
|
|
1118
|
+
const m = i._extraGetters;
|
|
1119
1119
|
if (m && h in m) return !0;
|
|
1120
|
-
const
|
|
1121
|
-
if (
|
|
1120
|
+
const b = i._extraMethods;
|
|
1121
|
+
if (b && h in b || a && h in a) return !0;
|
|
1122
1122
|
}
|
|
1123
1123
|
return h in r;
|
|
1124
1124
|
},
|
|
@@ -1127,15 +1127,15 @@ function cn(n, t, e, i, s) {
|
|
|
1127
1127
|
},
|
|
1128
1128
|
getOwnPropertyDescriptor(E, h) {
|
|
1129
1129
|
if (h === "__typename")
|
|
1130
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1130
|
+
return { enumerable: !0, configurable: !0, value: i.typename, writable: !1 };
|
|
1131
1131
|
if (h in r)
|
|
1132
1132
|
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1133
1133
|
if (typeof h == "string") {
|
|
1134
|
-
const m =
|
|
1134
|
+
const m = i._extraGetters;
|
|
1135
1135
|
if (m && h in m)
|
|
1136
1136
|
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1137
|
-
const
|
|
1138
|
-
if (
|
|
1137
|
+
const b = i._extraMethods;
|
|
1138
|
+
if (b && h in b)
|
|
1139
1139
|
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1140
1140
|
if (a && h in a)
|
|
1141
1141
|
return { enumerable: !1, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
@@ -1144,7 +1144,7 @@ function cn(n, t, e, i, s) {
|
|
|
1144
1144
|
};
|
|
1145
1145
|
return g = new Proxy({}, R), x.set(g, t), ye(g, s), g;
|
|
1146
1146
|
}
|
|
1147
|
-
class
|
|
1147
|
+
class ci {
|
|
1148
1148
|
instances = /* @__PURE__ */ new Map();
|
|
1149
1149
|
persistEntity;
|
|
1150
1150
|
constructor(t) {
|
|
@@ -1156,17 +1156,17 @@ class fn {
|
|
|
1156
1156
|
getEntity(t) {
|
|
1157
1157
|
return this.instances.get(t);
|
|
1158
1158
|
}
|
|
1159
|
-
getOrCreateEntity(t, e,
|
|
1159
|
+
getOrCreateEntity(t, e, n, s) {
|
|
1160
1160
|
let r = this.instances.get(t);
|
|
1161
1161
|
if (r === void 0) {
|
|
1162
|
-
const o =
|
|
1162
|
+
const o = n.idField;
|
|
1163
1163
|
if (o === void 0)
|
|
1164
|
-
throw new Error(`Entity id field is required ${
|
|
1164
|
+
throw new Error(`Entity id field is required ${n.typenameValue}`);
|
|
1165
1165
|
const a = e[o];
|
|
1166
1166
|
if (typeof a != "string" && typeof a != "number")
|
|
1167
|
-
throw new Error(`Entity id must be string or number: ${
|
|
1168
|
-
const c =
|
|
1169
|
-
r = new
|
|
1167
|
+
throw new Error(`Entity id must be string or number: ${n.typenameValue}`);
|
|
1168
|
+
const c = n;
|
|
1169
|
+
r = new ri(t, n.typenameValue, a, o, e, s), r._entityCache = c._entityCache, this.instances.set(t, r);
|
|
1170
1170
|
}
|
|
1171
1171
|
return r.parseId = s.currentParseId, r;
|
|
1172
1172
|
}
|
|
@@ -1177,7 +1177,7 @@ class fn {
|
|
|
1177
1177
|
let e;
|
|
1178
1178
|
if (t.entityRefs) {
|
|
1179
1179
|
e = /* @__PURE__ */ new Set();
|
|
1180
|
-
for (const
|
|
1180
|
+
for (const n of t.entityRefs.keys()) e.add(n.key);
|
|
1181
1181
|
}
|
|
1182
1182
|
this.persistEntity(t.key, t.data, e);
|
|
1183
1183
|
}
|
|
@@ -1246,7 +1246,7 @@ class ee {
|
|
|
1246
1246
|
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
|
-
class
|
|
1249
|
+
class ie {
|
|
1250
1250
|
static onlineSignal = Nt(!0);
|
|
1251
1251
|
get isOnline() {
|
|
1252
1252
|
return !0;
|
|
@@ -1256,25 +1256,25 @@ class ne {
|
|
|
1256
1256
|
clearManualOverride() {
|
|
1257
1257
|
}
|
|
1258
1258
|
getOnlineSignal() {
|
|
1259
|
-
return
|
|
1259
|
+
return ie.onlineSignal;
|
|
1260
1260
|
}
|
|
1261
1261
|
destroy() {
|
|
1262
1262
|
}
|
|
1263
1263
|
}
|
|
1264
|
-
const
|
|
1265
|
-
function gt(
|
|
1264
|
+
const fi = new ee(), Di = Mt(fi);
|
|
1265
|
+
function gt(i, t = typeof window > "u") {
|
|
1266
1266
|
let e;
|
|
1267
|
-
|
|
1268
|
-
const
|
|
1269
|
-
return { retries: e, retryDelay:
|
|
1267
|
+
i === !1 ? e = 0 : i === void 0 || i === !0 ? e = t ? 0 : 3 : typeof i == "number" ? e = i : e = i.retries;
|
|
1268
|
+
const n = typeof i == "object" && i.retryDelay ? i.retryDelay : (s) => 1e3 * Math.pow(2, s);
|
|
1269
|
+
return { retries: e, retryDelay: n };
|
|
1270
1270
|
}
|
|
1271
|
-
class
|
|
1271
|
+
class Ii {
|
|
1272
1272
|
static cache;
|
|
1273
1273
|
/**
|
|
1274
|
-
* The
|
|
1274
|
+
* The adapter class responsible for sending requests for this query type.
|
|
1275
1275
|
* Must be set on each concrete Query subclass (or inherited from a base like RESTQuery).
|
|
1276
1276
|
*/
|
|
1277
|
-
static
|
|
1277
|
+
static adapter;
|
|
1278
1278
|
params;
|
|
1279
1279
|
config;
|
|
1280
1280
|
constructor() {
|
|
@@ -1291,20 +1291,20 @@ class V {
|
|
|
1291
1291
|
return et(this.captured, t, e);
|
|
1292
1292
|
}
|
|
1293
1293
|
resolveOptions(t) {
|
|
1294
|
-
const { methods: e } = this.captured,
|
|
1295
|
-
return { config:
|
|
1294
|
+
const { methods: e } = this.captured, n = e.getConfig ? e.getConfig.call(t) : t.config, s = gt(n?.retry);
|
|
1295
|
+
return { config: n, retryConfig: s };
|
|
1296
1296
|
}
|
|
1297
1297
|
static for(t) {
|
|
1298
1298
|
let e = Ot.get(t);
|
|
1299
1299
|
if (e !== void 0)
|
|
1300
1300
|
return e;
|
|
1301
|
-
const
|
|
1301
|
+
const n = new t(), s = De(n), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : He.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = s.fields.fetchNext, u = t.adapter;
|
|
1302
1302
|
if (!u)
|
|
1303
1303
|
throw new Error(
|
|
1304
|
-
`Query class "${t.name}" must define a static \`
|
|
1304
|
+
`Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
|
|
1305
1305
|
);
|
|
1306
1306
|
const y = typeof u.prototype.sendNext == "function", v = c ? a : new _(
|
|
1307
|
-
|
|
1307
|
+
d.ENTITY | d.OBJECT,
|
|
1308
1308
|
a.shape,
|
|
1309
1309
|
void 0,
|
|
1310
1310
|
void 0,
|
|
@@ -1314,53 +1314,53 @@ class V {
|
|
|
1314
1314
|
// idField — symbol, injected onto payload before parse
|
|
1315
1315
|
);
|
|
1316
1316
|
return e = new V(
|
|
1317
|
-
{ id: r, shape: v, cache: f, rawFetchNext:
|
|
1317
|
+
{ id: r, shape: v, cache: f, rawFetchNext: l, hasSendNext: y, isEntityResult: c, adapterClass: u },
|
|
1318
1318
|
s
|
|
1319
1319
|
), Ot.set(t, e), e;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
const
|
|
1323
|
-
const e = V.for(
|
|
1322
|
+
const Ni = (i, t) => {
|
|
1323
|
+
const e = V.for(i);
|
|
1324
1324
|
return vt(e, t);
|
|
1325
1325
|
};
|
|
1326
|
-
function
|
|
1327
|
-
const e = V.for(
|
|
1328
|
-
if (
|
|
1326
|
+
function Mi(i, ...t) {
|
|
1327
|
+
const e = V.for(i), n = ge(bi);
|
|
1328
|
+
if (n === void 0)
|
|
1329
1329
|
throw new Error("QueryClient not found");
|
|
1330
1330
|
const s = t[0];
|
|
1331
|
-
return
|
|
1331
|
+
return n.getQuery(e, s);
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1334
|
-
return new Promise((e,
|
|
1333
|
+
function ne(i, t) {
|
|
1334
|
+
return new Promise((e, n) => {
|
|
1335
1335
|
if (t?.aborted) {
|
|
1336
|
-
|
|
1336
|
+
n(t.reason);
|
|
1337
1337
|
return;
|
|
1338
1338
|
}
|
|
1339
|
-
const s = setTimeout(e,
|
|
1339
|
+
const s = setTimeout(e, i);
|
|
1340
1340
|
t?.addEventListener(
|
|
1341
1341
|
"abort",
|
|
1342
1342
|
() => {
|
|
1343
|
-
clearTimeout(s),
|
|
1343
|
+
clearTimeout(s), n(t.reason);
|
|
1344
1344
|
},
|
|
1345
1345
|
{ once: !0 }
|
|
1346
1346
|
);
|
|
1347
1347
|
});
|
|
1348
1348
|
}
|
|
1349
|
-
async function rt(
|
|
1350
|
-
const
|
|
1349
|
+
async function rt(i, t, e) {
|
|
1350
|
+
const n = Math.max(0, t.retries);
|
|
1351
1351
|
let s;
|
|
1352
|
-
for (let r = 0; r <=
|
|
1352
|
+
for (let r = 0; r <= n; r++) {
|
|
1353
1353
|
e?.throwIfAborted();
|
|
1354
1354
|
try {
|
|
1355
|
-
return await
|
|
1355
|
+
return await i();
|
|
1356
1356
|
} catch (o) {
|
|
1357
|
-
if (s = o, r >=
|
|
1358
|
-
await
|
|
1357
|
+
if (s = o, r >= n) throw o;
|
|
1358
|
+
await ne(t.retryDelay(r), e);
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
1361
|
throw s;
|
|
1362
1362
|
}
|
|
1363
|
-
class
|
|
1363
|
+
class ui {
|
|
1364
1364
|
def;
|
|
1365
1365
|
queryKey;
|
|
1366
1366
|
storageKey = -1;
|
|
@@ -1378,7 +1378,7 @@ class ln {
|
|
|
1378
1378
|
/** Resolved per-instance options (depend on actual params). */
|
|
1379
1379
|
config = void 0;
|
|
1380
1380
|
retryConfig = gt(void 0);
|
|
1381
|
-
/**
|
|
1381
|
+
/** Cancels in-flight fetches and retry waits. */
|
|
1382
1382
|
_abortController = void 0;
|
|
1383
1383
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
1384
1384
|
_executionCtx = void 0;
|
|
@@ -1396,8 +1396,8 @@ class ln {
|
|
|
1396
1396
|
get relayState() {
|
|
1397
1397
|
return this._relayState;
|
|
1398
1398
|
}
|
|
1399
|
-
constructor(t, e,
|
|
1400
|
-
this.def = t, this.queryClient = e, this.queryKey =
|
|
1399
|
+
constructor(t, e, n, s) {
|
|
1400
|
+
this.def = t, this.queryClient = e, this.queryKey = n, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1401
1401
|
const r = Dt(s);
|
|
1402
1402
|
this._queryId = r !== void 0 ? D(r) : 0, this.relay = It(
|
|
1403
1403
|
(o) => {
|
|
@@ -1407,13 +1407,13 @@ class ln {
|
|
|
1407
1407
|
const f = this.config?.gcTime ?? kt;
|
|
1408
1408
|
this.queryClient.gcManager.schedule(this.queryKey, f, z.Query);
|
|
1409
1409
|
}, c = (f = !1) => {
|
|
1410
|
-
const { wasPaused:
|
|
1411
|
-
if (this.wasPaused = u, u && !
|
|
1410
|
+
const { wasPaused: l, isPaused: u, initialized: y } = this;
|
|
1411
|
+
if (this.wasPaused = u, u && !l && y) {
|
|
1412
1412
|
a();
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
1415
|
const v = Dt(this.params), p = vt(this.def, v), g = p !== this.storageKey;
|
|
1416
|
-
g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ?
|
|
1416
|
+
g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1417
1417
|
};
|
|
1418
1418
|
return c(!0), {
|
|
1419
1419
|
update: c,
|
|
@@ -1424,14 +1424,14 @@ class ln {
|
|
|
1424
1424
|
);
|
|
1425
1425
|
}
|
|
1426
1426
|
/** Apply raw data (fresh or cached) to the root entity and return the proxy. */
|
|
1427
|
-
applyData(t, e,
|
|
1427
|
+
applyData(t, e, n = !1, s) {
|
|
1428
1428
|
const r = this.def;
|
|
1429
1429
|
return this.rootEntity = this.queryClient.parseAndApplyRootEntity(
|
|
1430
1430
|
t,
|
|
1431
1431
|
this._queryId,
|
|
1432
1432
|
r.statics.shape,
|
|
1433
1433
|
e,
|
|
1434
|
-
|
|
1434
|
+
n,
|
|
1435
1435
|
s
|
|
1436
1436
|
), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
|
|
1437
1437
|
__hasNext: () => this.hasNext,
|
|
@@ -1453,16 +1453,16 @@ class ln {
|
|
|
1453
1453
|
async initialize() {
|
|
1454
1454
|
const t = this.queryClient, e = this.relayState;
|
|
1455
1455
|
this.initialized = !0;
|
|
1456
|
-
let
|
|
1456
|
+
let n;
|
|
1457
1457
|
try {
|
|
1458
|
-
|
|
1458
|
+
n = await t.loadCachedQuery(this.def, this.storageKey), n !== void 0 && (this.updatedAt = n.updatedAt, e.value = this.applyData(n.value, !1, !1, n.preloadedEntities));
|
|
1459
1459
|
} catch (s) {
|
|
1460
1460
|
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid", s);
|
|
1461
1461
|
}
|
|
1462
1462
|
if (!this.isPaused)
|
|
1463
1463
|
try {
|
|
1464
|
-
if (
|
|
1465
|
-
if (await
|
|
1464
|
+
if (n !== void 0 && this.setupSubscription(), n === void 0 || this.isStale) {
|
|
1465
|
+
if (await ne(0), this.isPaused) return;
|
|
1466
1466
|
this.runQueryImmediately();
|
|
1467
1467
|
}
|
|
1468
1468
|
} catch (s) {
|
|
@@ -1474,8 +1474,8 @@ class ln {
|
|
|
1474
1474
|
const t = this.config?.subscribe;
|
|
1475
1475
|
if (!t) return;
|
|
1476
1476
|
const e = this._executionCtx;
|
|
1477
|
-
this.unsubscribe = t.call(e, (
|
|
1478
|
-
|
|
1477
|
+
this.unsubscribe = t.call(e, (n) => {
|
|
1478
|
+
n.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(n);
|
|
1479
1479
|
});
|
|
1480
1480
|
}
|
|
1481
1481
|
getOrCreateExecutionContext() {
|
|
@@ -1492,10 +1492,10 @@ class ln {
|
|
|
1492
1492
|
const t = this.def;
|
|
1493
1493
|
if (this.isPaused)
|
|
1494
1494
|
throw new Error("Query is paused due to network status");
|
|
1495
|
-
const e = this.getOrCreateExecutionContext(),
|
|
1495
|
+
const e = this.getOrCreateExecutionContext(), n = this.queryClient.getAdapter(t.statics.adapterClass), s = this._abortController?.signal ?? new AbortController().signal;
|
|
1496
1496
|
return rt(
|
|
1497
1497
|
async () => {
|
|
1498
|
-
const r = await
|
|
1498
|
+
const r = await n.send(e, s);
|
|
1499
1499
|
this.updatedAt = Date.now();
|
|
1500
1500
|
const o = this.applyData(r, !0);
|
|
1501
1501
|
return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
|
|
@@ -1526,7 +1526,7 @@ class ln {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
/** In-flight fetchNext promise for deduplication. */
|
|
1528
1528
|
_fetchNextPromise = void 0;
|
|
1529
|
-
/**
|
|
1529
|
+
/** Cancels in-flight fetchNext requests. */
|
|
1530
1530
|
_fetchNextAbort = void 0;
|
|
1531
1531
|
fetchNext = () => {
|
|
1532
1532
|
if (this.updatedAt === void 0)
|
|
@@ -1540,18 +1540,18 @@ class ln {
|
|
|
1540
1540
|
};
|
|
1541
1541
|
get hasNext() {
|
|
1542
1542
|
if (this.rootEntity === void 0 || !this._executionCtx) return !1;
|
|
1543
|
-
const t = this.queryClient.
|
|
1543
|
+
const t = this.queryClient.getAdapter(this.def.statics.adapterClass);
|
|
1544
1544
|
return t.hasNext ? (this._executionCtx.resultData = this.rootEntity.data, t.hasNext(this._executionCtx)) : !1;
|
|
1545
1545
|
}
|
|
1546
1546
|
async runFetchNext() {
|
|
1547
1547
|
const t = this.def;
|
|
1548
1548
|
this._fetchNextAbort = new AbortController();
|
|
1549
|
-
const e = this._fetchNextAbort.signal,
|
|
1550
|
-
|
|
1551
|
-
const s = this.queryClient.
|
|
1549
|
+
const e = this._fetchNextAbort.signal, n = this.getOrCreateExecutionContext();
|
|
1550
|
+
n.resultData = this.rootEntity.data;
|
|
1551
|
+
const s = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1552
1552
|
return rt(
|
|
1553
1553
|
async () => {
|
|
1554
|
-
const r = await s.sendNext(
|
|
1554
|
+
const r = await s.sendNext(n, e);
|
|
1555
1555
|
this.updatedAt = Date.now();
|
|
1556
1556
|
const o = this.applyData(r, !0, !0);
|
|
1557
1557
|
return this.saveQueryMetadata(), o;
|
|
@@ -1584,7 +1584,7 @@ class ln {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
|
-
class
|
|
1587
|
+
class di {
|
|
1588
1588
|
def;
|
|
1589
1589
|
queryClient;
|
|
1590
1590
|
_inFlight = !1;
|
|
@@ -1599,8 +1599,8 @@ class dn {
|
|
|
1599
1599
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
1600
1600
|
this._inFlight = !0;
|
|
1601
1601
|
try {
|
|
1602
|
-
const e = await this.executeWithRetry(t),
|
|
1603
|
-
return this.processEffects(t,
|
|
1602
|
+
const e = await this.executeWithRetry(t), n = this.validateResponse(e);
|
|
1603
|
+
return this.processEffects(t, n), n;
|
|
1604
1604
|
} finally {
|
|
1605
1605
|
this._inFlight = !1;
|
|
1606
1606
|
}
|
|
@@ -1612,38 +1612,38 @@ class dn {
|
|
|
1612
1612
|
const e = this.def.responseShape;
|
|
1613
1613
|
if (!(e instanceof _))
|
|
1614
1614
|
return t;
|
|
1615
|
-
const
|
|
1615
|
+
const n = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1616
1616
|
}), s = new st();
|
|
1617
|
-
return s.reset(void 0, void 0,
|
|
1617
|
+
return s.reset(void 0, void 0, n), Jt(t, e, s);
|
|
1618
1618
|
}
|
|
1619
1619
|
// ======================================================
|
|
1620
1620
|
// Effects processing
|
|
1621
1621
|
// ======================================================
|
|
1622
1622
|
processEffects(t, e) {
|
|
1623
|
-
let
|
|
1623
|
+
let n;
|
|
1624
1624
|
if (this.def.hasGetEffects) {
|
|
1625
1625
|
const r = et(
|
|
1626
1626
|
this.def.captured,
|
|
1627
1627
|
t ?? {},
|
|
1628
1628
|
this.queryClient.getContext()
|
|
1629
1629
|
);
|
|
1630
|
-
r.result = e,
|
|
1630
|
+
r.result = e, n = r.getEffects();
|
|
1631
1631
|
} else if (this.def.effects !== void 0) {
|
|
1632
1632
|
const r = { params: t, result: e };
|
|
1633
|
-
|
|
1633
|
+
n = W(this.def.effects, r);
|
|
1634
1634
|
}
|
|
1635
|
-
if (
|
|
1635
|
+
if (n === void 0) return;
|
|
1636
1636
|
const s = this.queryClient;
|
|
1637
|
-
Z(
|
|
1637
|
+
Z(n.creates, "create", s), Z(n.updates, "update", s), Z(n.deletes, "delete", s), n.invalidates && s.invalidateQueries(n.invalidates);
|
|
1638
1638
|
}
|
|
1639
1639
|
// ======================================================
|
|
1640
1640
|
// Retry logic
|
|
1641
1641
|
// ======================================================
|
|
1642
1642
|
executeWithRetry(t) {
|
|
1643
|
-
const e = gt(this.def.config?.retry, !0),
|
|
1644
|
-
if (!
|
|
1643
|
+
const e = gt(this.def.config?.retry, !0), n = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1644
|
+
if (!n.sendMutation)
|
|
1645
1645
|
throw new Error(
|
|
1646
|
-
`
|
|
1646
|
+
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1647
1647
|
);
|
|
1648
1648
|
return rt(async () => {
|
|
1649
1649
|
const s = new AbortController(), r = et(
|
|
@@ -1651,74 +1651,74 @@ class dn {
|
|
|
1651
1651
|
t ?? {},
|
|
1652
1652
|
this.queryClient.getContext()
|
|
1653
1653
|
);
|
|
1654
|
-
return await
|
|
1654
|
+
return await n.sendMutation(r, s.signal);
|
|
1655
1655
|
}, e);
|
|
1656
1656
|
}
|
|
1657
1657
|
}
|
|
1658
|
-
function
|
|
1659
|
-
return typeof
|
|
1658
|
+
function li(i) {
|
|
1659
|
+
return typeof i == "string" ? i : T(i).typenameValue;
|
|
1660
1660
|
}
|
|
1661
|
-
function Z(
|
|
1662
|
-
if (
|
|
1663
|
-
for (const [
|
|
1664
|
-
const r =
|
|
1661
|
+
function Z(i, t, e) {
|
|
1662
|
+
if (i)
|
|
1663
|
+
for (const [n, s] of i) {
|
|
1664
|
+
const r = li(n);
|
|
1665
1665
|
r !== void 0 && e.applyMutationEvent({ type: t, typename: r, data: s });
|
|
1666
1666
|
}
|
|
1667
1667
|
}
|
|
1668
1668
|
const se = "__eventSource";
|
|
1669
|
-
function re(
|
|
1670
|
-
return { field:
|
|
1669
|
+
function re(i) {
|
|
1670
|
+
return { field: i, segments: i.indexOf(".") !== -1 ? i.split(".") : void 0 };
|
|
1671
1671
|
}
|
|
1672
|
-
function
|
|
1673
|
-
return
|
|
1672
|
+
function hi(i) {
|
|
1673
|
+
return i.map(re);
|
|
1674
1674
|
}
|
|
1675
|
-
function
|
|
1676
|
-
if (t.segments === void 0) return
|
|
1677
|
-
let e =
|
|
1678
|
-
for (const
|
|
1675
|
+
function yi(i, t) {
|
|
1676
|
+
if (t.segments === void 0) return i[t.field];
|
|
1677
|
+
let e = i;
|
|
1678
|
+
for (const n of t.segments) {
|
|
1679
1679
|
if (e == null) return;
|
|
1680
|
-
e = e[
|
|
1680
|
+
e = e[n];
|
|
1681
1681
|
}
|
|
1682
1682
|
return e;
|
|
1683
1683
|
}
|
|
1684
|
-
function oe(
|
|
1684
|
+
function oe(i, t) {
|
|
1685
1685
|
const e = [];
|
|
1686
|
-
for (let
|
|
1687
|
-
const s = t[
|
|
1686
|
+
for (let n = 0; n < t.length; n++) {
|
|
1687
|
+
const s = t[n], r = yi(i, s);
|
|
1688
1688
|
if (r === void 0) return;
|
|
1689
1689
|
e.push(s.field, r);
|
|
1690
1690
|
}
|
|
1691
1691
|
return D(e);
|
|
1692
1692
|
}
|
|
1693
|
-
function
|
|
1694
|
-
if (
|
|
1693
|
+
function pi(i, t) {
|
|
1694
|
+
if (i === void 0) return;
|
|
1695
1695
|
const e = /* @__PURE__ */ new Map();
|
|
1696
|
-
for (const [
|
|
1696
|
+
for (const [n, s] of i) {
|
|
1697
1697
|
const r = s.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
|
|
1698
1698
|
let a = !0;
|
|
1699
1699
|
for (const [c, f] of r) {
|
|
1700
|
-
let
|
|
1700
|
+
let l;
|
|
1701
1701
|
if (Pt(f)) {
|
|
1702
1702
|
const u = Lt(f);
|
|
1703
|
-
|
|
1703
|
+
l = ut(u, t);
|
|
1704
1704
|
} else
|
|
1705
|
-
|
|
1706
|
-
if (
|
|
1705
|
+
l = f;
|
|
1706
|
+
if (l === void 0) {
|
|
1707
1707
|
a = !1;
|
|
1708
1708
|
break;
|
|
1709
1709
|
}
|
|
1710
|
-
o.push(c,
|
|
1710
|
+
o.push(c, l);
|
|
1711
1711
|
}
|
|
1712
|
-
a && e.set(
|
|
1712
|
+
a && e.set(n, D(o));
|
|
1713
1713
|
}
|
|
1714
1714
|
return e.size > 0 ? e : void 0;
|
|
1715
1715
|
}
|
|
1716
|
-
function Rt(
|
|
1717
|
-
const e =
|
|
1716
|
+
function Rt(i, t) {
|
|
1717
|
+
const e = i.get(t);
|
|
1718
1718
|
if (e !== void 0)
|
|
1719
|
-
return e.map(([
|
|
1719
|
+
return e.map(([n]) => n).sort();
|
|
1720
1720
|
}
|
|
1721
|
-
class
|
|
1721
|
+
class gi {
|
|
1722
1722
|
fields;
|
|
1723
1723
|
fieldPaths;
|
|
1724
1724
|
_bindings = /* @__PURE__ */ new Map();
|
|
@@ -1726,12 +1726,12 @@ class vn {
|
|
|
1726
1726
|
this.fields = t, this.fieldPaths = t.map(re);
|
|
1727
1727
|
}
|
|
1728
1728
|
register(t, e) {
|
|
1729
|
-
let
|
|
1730
|
-
|
|
1729
|
+
let n = this._bindings.get(t);
|
|
1730
|
+
n === void 0 && (n = /* @__PURE__ */ new Set(), this._bindings.set(t, n)), n.add(e);
|
|
1731
1731
|
}
|
|
1732
1732
|
unregister(t, e) {
|
|
1733
|
-
const
|
|
1734
|
-
|
|
1733
|
+
const n = this._bindings.get(t);
|
|
1734
|
+
n !== void 0 && (n.delete(e), n.size === 0 && this._bindings.delete(t));
|
|
1735
1735
|
}
|
|
1736
1736
|
getMatching(t) {
|
|
1737
1737
|
return this._bindings.get(t);
|
|
@@ -1740,52 +1740,52 @@ class vn {
|
|
|
1740
1740
|
return this._bindings.size === 0;
|
|
1741
1741
|
}
|
|
1742
1742
|
}
|
|
1743
|
-
function St(
|
|
1744
|
-
return D(
|
|
1743
|
+
function St(i) {
|
|
1744
|
+
return D(i);
|
|
1745
1745
|
}
|
|
1746
|
-
class
|
|
1746
|
+
class vi {
|
|
1747
1747
|
_groups = /* @__PURE__ */ new Map();
|
|
1748
1748
|
getOrCreateGroup(t) {
|
|
1749
1749
|
const e = St(t);
|
|
1750
|
-
let
|
|
1751
|
-
return
|
|
1750
|
+
let n = this._groups.get(e);
|
|
1751
|
+
return n === void 0 && (n = new gi(t), this._groups.set(e, n)), n;
|
|
1752
1752
|
}
|
|
1753
|
-
register(t, e,
|
|
1754
|
-
this.getOrCreateGroup(e).register(t,
|
|
1753
|
+
register(t, e, n) {
|
|
1754
|
+
this.getOrCreateGroup(e).register(t, n);
|
|
1755
1755
|
}
|
|
1756
|
-
unregister(t, e,
|
|
1756
|
+
unregister(t, e, n) {
|
|
1757
1757
|
const s = St(e), r = this._groups.get(s);
|
|
1758
|
-
r !== void 0 && (r.unregister(t,
|
|
1758
|
+
r !== void 0 && (r.unregister(t, n), r.isEmpty && this._groups.delete(s));
|
|
1759
1759
|
}
|
|
1760
1760
|
registerBinding(t, e) {
|
|
1761
|
-
const
|
|
1762
|
-
if (
|
|
1761
|
+
const n = t._constraintHashes.get(e);
|
|
1762
|
+
if (n === void 0) return;
|
|
1763
1763
|
const s = Rt(t._constraintFieldRefs, e);
|
|
1764
|
-
s !== void 0 && this.register(
|
|
1764
|
+
s !== void 0 && this.register(n, s, t);
|
|
1765
1765
|
}
|
|
1766
1766
|
unregisterBinding(t, e) {
|
|
1767
|
-
const
|
|
1768
|
-
if (
|
|
1767
|
+
const n = t._constraintHashes.get(e);
|
|
1768
|
+
if (n === void 0) return;
|
|
1769
1769
|
const s = Rt(t._constraintFieldRefs, e);
|
|
1770
|
-
s !== void 0 && this.unregister(
|
|
1770
|
+
s !== void 0 && this.unregister(n, s, t);
|
|
1771
1771
|
}
|
|
1772
|
-
routeEvent(t, e,
|
|
1772
|
+
routeEvent(t, e, n, s, r, o) {
|
|
1773
1773
|
for (const a of this._groups.values()) {
|
|
1774
1774
|
const c = oe(e, a.fieldPaths);
|
|
1775
1775
|
if (c === void 0) continue;
|
|
1776
1776
|
const f = a.getMatching(c);
|
|
1777
1777
|
if (f !== void 0)
|
|
1778
|
-
for (const
|
|
1779
|
-
|
|
1778
|
+
for (const l of f)
|
|
1779
|
+
l.onEvent(t, n, s, r, o);
|
|
1780
1780
|
}
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
|
-
function At(
|
|
1783
|
+
function At(i) {
|
|
1784
1784
|
const t = /* @__PURE__ */ new Set();
|
|
1785
|
-
for (const e of
|
|
1785
|
+
for (const e of i)
|
|
1786
1786
|
if (typeof e == "object" && e !== null) {
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1787
|
+
const n = k(e);
|
|
1788
|
+
n !== void 0 && t.add(n);
|
|
1789
1789
|
}
|
|
1790
1790
|
return t;
|
|
1791
1791
|
}
|
|
@@ -1796,8 +1796,8 @@ class ae {
|
|
|
1796
1796
|
_entityDefsByTypename;
|
|
1797
1797
|
_constraintFieldRefs;
|
|
1798
1798
|
instance;
|
|
1799
|
-
constructor(t, e,
|
|
1800
|
-
this._queryClient =
|
|
1799
|
+
constructor(t, e, n, s, r, o) {
|
|
1800
|
+
this._queryClient = n, this._parent = s, this._constraintHashes = r, this._constraintFieldRefs = e, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1801
1801
|
for (const a of t)
|
|
1802
1802
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1803
1803
|
J.add(this);
|
|
@@ -1819,11 +1819,11 @@ class ae {
|
|
|
1819
1819
|
* root level by applyMutationEvent. The binding just checks if the entity's
|
|
1820
1820
|
* current data satisfies this binding's shape and forwards to the instance.
|
|
1821
1821
|
*/
|
|
1822
|
-
onEvent(t, e,
|
|
1822
|
+
onEvent(t, e, n, s, r) {
|
|
1823
1823
|
const o = this._entityDefsByTypename.get(t);
|
|
1824
1824
|
if (o === void 0) return;
|
|
1825
1825
|
const a = this._queryClient.entityMap.getEntity(e);
|
|
1826
|
-
if (
|
|
1826
|
+
if (n === "delete") {
|
|
1827
1827
|
const f = a !== void 0 ? a.getProxy(o) : r;
|
|
1828
1828
|
f !== void 0 && (this.instance.onEvent(e, f, r ?? a?.data ?? {}, "delete"), s?.());
|
|
1829
1829
|
return;
|
|
@@ -1831,7 +1831,7 @@ class ae {
|
|
|
1831
1831
|
if (a === void 0 || !a.satisfiesDef(o)) return;
|
|
1832
1832
|
s?.();
|
|
1833
1833
|
const c = a.getProxy(o);
|
|
1834
|
-
this.instance.onEvent(e, c, a.data,
|
|
1834
|
+
this.instance.onEvent(e, c, a.data, n);
|
|
1835
1835
|
}
|
|
1836
1836
|
destroy() {
|
|
1837
1837
|
this._queryClient.unregisterLiveCollection(this);
|
|
@@ -1839,44 +1839,44 @@ class ae {
|
|
|
1839
1839
|
e !== -1 && t.splice(e, 1);
|
|
1840
1840
|
}
|
|
1841
1841
|
}
|
|
1842
|
-
class
|
|
1842
|
+
class _i {
|
|
1843
1843
|
_notifier;
|
|
1844
1844
|
_items;
|
|
1845
1845
|
_keys;
|
|
1846
1846
|
_outputSignal;
|
|
1847
1847
|
_queryClient;
|
|
1848
1848
|
_parent;
|
|
1849
|
-
constructor(t, e,
|
|
1850
|
-
this._notifier = at(), this._items =
|
|
1849
|
+
constructor(t, e, n, s, r, o) {
|
|
1850
|
+
this._notifier = at(), this._items = n, this._keys = At(n), this._queryClient = t, this._parent = e;
|
|
1851
1851
|
const a = s !== void 0 && r !== void 0, c = o !== void 0;
|
|
1852
1852
|
(a || c) && (this._outputSignal = _e(() => {
|
|
1853
1853
|
this._notifier.consume();
|
|
1854
1854
|
let f = this._items;
|
|
1855
1855
|
if (a) {
|
|
1856
|
-
const
|
|
1856
|
+
const l = [];
|
|
1857
1857
|
for (const u of f) {
|
|
1858
1858
|
if (typeof u != "object" || u === null) {
|
|
1859
|
-
|
|
1859
|
+
l.push(u);
|
|
1860
1860
|
continue;
|
|
1861
1861
|
}
|
|
1862
1862
|
const y = k(u);
|
|
1863
1863
|
if (y === void 0) {
|
|
1864
|
-
|
|
1864
|
+
l.push(u);
|
|
1865
1865
|
continue;
|
|
1866
1866
|
}
|
|
1867
1867
|
const v = t.entityMap.getEntity(y);
|
|
1868
1868
|
if (v === void 0) {
|
|
1869
|
-
|
|
1869
|
+
l.push(u);
|
|
1870
1870
|
continue;
|
|
1871
1871
|
}
|
|
1872
|
-
v.consume(), oe(v.data, s) === r &&
|
|
1872
|
+
v.consume(), oe(v.data, s) === r && l.push(u);
|
|
1873
1873
|
}
|
|
1874
|
-
f =
|
|
1874
|
+
f = l;
|
|
1875
1875
|
}
|
|
1876
1876
|
return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
|
|
1877
1877
|
}));
|
|
1878
1878
|
}
|
|
1879
|
-
onEvent(t, e,
|
|
1879
|
+
onEvent(t, e, n, s) {
|
|
1880
1880
|
switch (s) {
|
|
1881
1881
|
case "create":
|
|
1882
1882
|
this.add(t, e);
|
|
@@ -1898,24 +1898,24 @@ class mn {
|
|
|
1898
1898
|
add(t, e) {
|
|
1899
1899
|
if (this._keys.has(t)) return !1;
|
|
1900
1900
|
this._keys.add(t), this._items.push(e);
|
|
1901
|
-
const
|
|
1902
|
-
return
|
|
1901
|
+
const n = this._queryClient.entityMap.getEntity(t);
|
|
1902
|
+
return n !== void 0 && (this._parent.addChildRef(n), n.save()), this._notifier.notify(), !0;
|
|
1903
1903
|
}
|
|
1904
1904
|
remove(t) {
|
|
1905
1905
|
if (!this._keys.has(t)) return !1;
|
|
1906
1906
|
this._keys.delete(t);
|
|
1907
1907
|
const e = this._findIndex(t);
|
|
1908
1908
|
e !== -1 && this._items.splice(e, 1);
|
|
1909
|
-
const
|
|
1910
|
-
return
|
|
1909
|
+
const n = this._queryClient.entityMap.getEntity(t);
|
|
1910
|
+
return n !== void 0 && this._parent.removeChildRef(n), this._notifier.notify(), !0;
|
|
1911
1911
|
}
|
|
1912
1912
|
has(t) {
|
|
1913
1913
|
return this._keys.has(t);
|
|
1914
1914
|
}
|
|
1915
1915
|
reset(t) {
|
|
1916
|
-
const e = this._items,
|
|
1917
|
-
this._items =
|
|
1918
|
-
for (const s of
|
|
1916
|
+
const e = this._items, n = Array.isArray(t) ? t : [];
|
|
1917
|
+
this._items = n, this._keys = At(n);
|
|
1918
|
+
for (const s of n)
|
|
1919
1919
|
if (typeof s == "object" && s !== null) {
|
|
1920
1920
|
const r = k(s);
|
|
1921
1921
|
if (r !== void 0) {
|
|
@@ -1937,20 +1937,20 @@ class mn {
|
|
|
1937
1937
|
if (Array.isArray(t))
|
|
1938
1938
|
for (const e of t) {
|
|
1939
1939
|
if (typeof e != "object" || e === null) continue;
|
|
1940
|
-
const
|
|
1941
|
-
|
|
1940
|
+
const n = k(e);
|
|
1941
|
+
n !== void 0 && this.add(n, e);
|
|
1942
1942
|
}
|
|
1943
1943
|
}
|
|
1944
1944
|
_findIndex(t) {
|
|
1945
1945
|
for (let e = 0; e < this._items.length; e++) {
|
|
1946
|
-
const
|
|
1947
|
-
if (typeof
|
|
1946
|
+
const n = this._items[e];
|
|
1947
|
+
if (typeof n == "object" && n !== null && k(n) === t)
|
|
1948
1948
|
return e;
|
|
1949
1949
|
}
|
|
1950
1950
|
return -1;
|
|
1951
1951
|
}
|
|
1952
1952
|
}
|
|
1953
|
-
class
|
|
1953
|
+
class mi {
|
|
1954
1954
|
_notifier;
|
|
1955
1955
|
_value;
|
|
1956
1956
|
_createdKeys;
|
|
@@ -1960,21 +1960,21 @@ class wn {
|
|
|
1960
1960
|
_onCreate;
|
|
1961
1961
|
_onUpdate;
|
|
1962
1962
|
_onDelete;
|
|
1963
|
-
constructor(t, e,
|
|
1964
|
-
this._notifier = at(), this._value =
|
|
1963
|
+
constructor(t, e, n, s, r, o) {
|
|
1964
|
+
this._notifier = at(), this._value = n, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = e, this._onCreate = s, this._onUpdate = r, this._onDelete = o;
|
|
1965
1965
|
}
|
|
1966
|
-
onEvent(t, e,
|
|
1966
|
+
onEvent(t, e, n, s) {
|
|
1967
1967
|
switch (s) {
|
|
1968
1968
|
case "create":
|
|
1969
1969
|
if (this._createdKeys.has(t)) return;
|
|
1970
1970
|
this._createdKeys.add(t), this._value = this._onCreate(this._value, e);
|
|
1971
1971
|
break;
|
|
1972
1972
|
case "update":
|
|
1973
|
-
this._value = this._onUpdate(this._value, e ??
|
|
1973
|
+
this._value = this._onUpdate(this._value, e ?? n);
|
|
1974
1974
|
break;
|
|
1975
1975
|
case "delete":
|
|
1976
1976
|
if (this._deletedKeys.has(t)) return;
|
|
1977
|
-
this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ??
|
|
1977
|
+
this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ?? n);
|
|
1978
1978
|
break;
|
|
1979
1979
|
}
|
|
1980
1980
|
this._notifier.notify();
|
|
@@ -1991,48 +1991,48 @@ class wn {
|
|
|
1991
1991
|
append(t) {
|
|
1992
1992
|
}
|
|
1993
1993
|
}
|
|
1994
|
-
function ce(
|
|
1995
|
-
let r =
|
|
1994
|
+
function ce(i, t, e, n, s) {
|
|
1995
|
+
let r = i.constraintFieldRefs;
|
|
1996
1996
|
if (r === void 0) {
|
|
1997
1997
|
r = /* @__PURE__ */ new Map();
|
|
1998
|
-
for (const f of
|
|
1999
|
-
const
|
|
2000
|
-
|
|
1998
|
+
for (const f of i.entityDefs) {
|
|
1999
|
+
const l = f.typenameValue;
|
|
2000
|
+
l !== void 0 && r.set(l, [[se, e.key]]);
|
|
2001
2001
|
}
|
|
2002
2002
|
}
|
|
2003
|
-
const o =
|
|
2003
|
+
const o = pi(r, n) ?? /* @__PURE__ */ new Map();
|
|
2004
2004
|
let a;
|
|
2005
|
-
if (
|
|
2006
|
-
let f,
|
|
2007
|
-
if (
|
|
2008
|
-
for (const [u] of
|
|
2005
|
+
if (i.type === ct.Array) {
|
|
2006
|
+
let f, l;
|
|
2007
|
+
if (i.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2008
|
+
for (const [u] of i.constraintFieldRefs) {
|
|
2009
2009
|
const y = o.get(u);
|
|
2010
2010
|
if (y !== void 0) {
|
|
2011
|
-
|
|
2012
|
-
const v =
|
|
2013
|
-
v !== void 0 && (f =
|
|
2011
|
+
l = y;
|
|
2012
|
+
const v = i.constraintFieldRefs.get(u);
|
|
2013
|
+
v !== void 0 && (f = hi(v.map(([p]) => p)));
|
|
2014
2014
|
break;
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
|
-
a = new
|
|
2017
|
+
a = new _i(
|
|
2018
2018
|
s,
|
|
2019
2019
|
e,
|
|
2020
2020
|
Array.isArray(t) ? t : [],
|
|
2021
2021
|
f,
|
|
2022
|
-
|
|
2023
|
-
|
|
2022
|
+
l,
|
|
2023
|
+
i.sort
|
|
2024
2024
|
);
|
|
2025
2025
|
} else
|
|
2026
|
-
a = new
|
|
2026
|
+
a = new mi(
|
|
2027
2027
|
s,
|
|
2028
2028
|
e,
|
|
2029
2029
|
t,
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2030
|
+
i.onCreate,
|
|
2031
|
+
i.onUpdate,
|
|
2032
|
+
i.onDelete
|
|
2033
2033
|
);
|
|
2034
2034
|
const c = new ae(
|
|
2035
|
-
|
|
2035
|
+
i.entityDefs,
|
|
2036
2036
|
r,
|
|
2037
2037
|
s,
|
|
2038
2038
|
e,
|
|
@@ -2042,40 +2042,40 @@ function ce(n, t, e, i, s) {
|
|
|
2042
2042
|
return e.liveCollections.push(c), s.registerLiveCollection(c), c;
|
|
2043
2043
|
}
|
|
2044
2044
|
const fe = Object.entries, ue = Object.prototype;
|
|
2045
|
-
function tt(
|
|
2046
|
-
const s =
|
|
2045
|
+
function tt(i, t, e, n = !1) {
|
|
2046
|
+
const s = i.queryClient;
|
|
2047
2047
|
s.currentParseId++;
|
|
2048
|
-
const r =
|
|
2049
|
-
return { data: U(t, r, s, e, o,
|
|
2048
|
+
const r = i.seen, o = /* @__PURE__ */ new Map();
|
|
2049
|
+
return { data: U(t, r, s, e, o, n), entityRefs: o };
|
|
2050
2050
|
}
|
|
2051
|
-
function U(
|
|
2052
|
-
if (typeof
|
|
2053
|
-
const o = t.get(
|
|
2051
|
+
function U(i, t, e, n, s, r) {
|
|
2052
|
+
if (typeof i != "object" || i === null) return i;
|
|
2053
|
+
const o = t.get(i);
|
|
2054
2054
|
if (o !== void 0)
|
|
2055
|
-
return
|
|
2056
|
-
if (Array.isArray(
|
|
2057
|
-
for (let a = 0; a <
|
|
2058
|
-
const c =
|
|
2059
|
-
typeof c == "object" && c !== null && !(c instanceof q) && !x.has(c) && (
|
|
2055
|
+
return wi(o, t, e, n, s, r);
|
|
2056
|
+
if (Array.isArray(i)) {
|
|
2057
|
+
for (let a = 0; a < i.length; a++) {
|
|
2058
|
+
const c = i[a];
|
|
2059
|
+
typeof c == "object" && c !== null && !(c instanceof q) && !x.has(c) && (i[a] = U(c, t, e, n, s, r));
|
|
2060
2060
|
}
|
|
2061
|
-
return
|
|
2061
|
+
return i;
|
|
2062
2062
|
}
|
|
2063
|
-
if (Object.getPrototypeOf(
|
|
2064
|
-
const a =
|
|
2063
|
+
if (Object.getPrototypeOf(i) === ue && !x.has(i)) {
|
|
2064
|
+
const a = i;
|
|
2065
2065
|
for (const c of Object.keys(a)) {
|
|
2066
2066
|
const f = a[c];
|
|
2067
|
-
typeof f == "object" && f !== null && !(f instanceof q) && !x.has(f) && (a[c] = U(f, t, e,
|
|
2067
|
+
typeof f == "object" && f !== null && !(f instanceof q) && !x.has(f) && (a[c] = U(f, t, e, n, s, r));
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
|
-
return
|
|
2070
|
+
return i;
|
|
2071
2071
|
}
|
|
2072
|
-
function
|
|
2073
|
-
return typeof
|
|
2072
|
+
function de(i) {
|
|
2073
|
+
return typeof i == "object" && i !== null && !(i instanceof q) && !x.has(i);
|
|
2074
2074
|
}
|
|
2075
|
-
function
|
|
2076
|
-
const { key: o, data: a, shape: c, rawKeys: f } =
|
|
2077
|
-
if (v ? (
|
|
2078
|
-
|
|
2075
|
+
function wi(i, t, e, n, s, r) {
|
|
2076
|
+
const { key: o, data: a, shape: c, rawKeys: f } = i, l = c.shape, u = e.prepareEntity(o, a, c), y = u.data, v = y !== a, p = v && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2077
|
+
if (v ? (le(
|
|
2078
|
+
l,
|
|
2079
2079
|
a,
|
|
2080
2080
|
y,
|
|
2081
2081
|
f,
|
|
@@ -2083,10 +2083,10 @@ function En(n, t, e, i, s, r) {
|
|
|
2083
2083
|
y,
|
|
2084
2084
|
t,
|
|
2085
2085
|
e,
|
|
2086
|
-
|
|
2086
|
+
n,
|
|
2087
2087
|
p,
|
|
2088
2088
|
r
|
|
2089
|
-
), u.notify()) : he(
|
|
2089
|
+
), u.notify()) : he(l, a, u, a, t, e, n, p, r), r && u.liveCollections.length > 0)
|
|
2090
2090
|
for (const w of u.liveCollections) {
|
|
2091
2091
|
const I = w.instance.getRawValue();
|
|
2092
2092
|
if (Array.isArray(I))
|
|
@@ -2098,16 +2098,16 @@ function En(n, t, e, i, s, r) {
|
|
|
2098
2098
|
R !== void 0 && p.set(R, (p.get(R) ?? 0) + 1);
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
|
-
u.setChildRefs(p.size > 0 ? p : void 0,
|
|
2101
|
+
u.setChildRefs(p.size > 0 ? p : void 0, n);
|
|
2102
2102
|
const g = u.getProxy(c);
|
|
2103
2103
|
return s.set(u, (s.get(u) ?? 0) + 1), g;
|
|
2104
2104
|
}
|
|
2105
|
-
function
|
|
2106
|
-
for (const [u, y] of fe(
|
|
2107
|
-
if (!(
|
|
2108
|
-
if (
|
|
2105
|
+
function le(i, t, e, n, s, r, o, a, c, f, l) {
|
|
2106
|
+
for (const [u, y] of fe(i))
|
|
2107
|
+
if (!(n !== void 0 && !n.has(u)))
|
|
2108
|
+
if (de(t[u]) && (t[u] = U(t[u], o, a, c, f, l)), y instanceof _ && y._liveConfig !== void 0) {
|
|
2109
2109
|
const v = e[u];
|
|
2110
|
-
v instanceof ae ?
|
|
2110
|
+
v instanceof ae ? l ? v.append(t[u]) : v.reset(t[u]) : e[u] = ce(
|
|
2111
2111
|
y._liveConfig,
|
|
2112
2112
|
t[u],
|
|
2113
2113
|
s,
|
|
@@ -2119,7 +2119,7 @@ function de(n, t, e, i, s, r, o, a, c, f, d) {
|
|
|
2119
2119
|
if (ot(v) && ot(p)) {
|
|
2120
2120
|
const g = y instanceof _ && y.shape !== void 0 ? y.shape : void 0;
|
|
2121
2121
|
if (g !== void 0)
|
|
2122
|
-
|
|
2122
|
+
le(
|
|
2123
2123
|
g,
|
|
2124
2124
|
v,
|
|
2125
2125
|
p,
|
|
@@ -2130,7 +2130,7 @@ function de(n, t, e, i, s, r, o, a, c, f, d) {
|
|
|
2130
2130
|
a,
|
|
2131
2131
|
c,
|
|
2132
2132
|
f,
|
|
2133
|
-
|
|
2133
|
+
l
|
|
2134
2134
|
);
|
|
2135
2135
|
else
|
|
2136
2136
|
for (const w of Object.keys(v))
|
|
@@ -2140,45 +2140,45 @@ function de(n, t, e, i, s, r, o, a, c, f, d) {
|
|
|
2140
2140
|
e[u] = v;
|
|
2141
2141
|
}
|
|
2142
2142
|
}
|
|
2143
|
-
function he(
|
|
2144
|
-
for (const [f,
|
|
2143
|
+
function he(i, t, e, n, s, r, o, a, c) {
|
|
2144
|
+
for (const [f, l] of fe(i))
|
|
2145
2145
|
if (f in t)
|
|
2146
|
-
if (
|
|
2146
|
+
if (de(t[f]) && (t[f] = U(t[f], s, r, o, a, c)), l instanceof _ && l._liveConfig !== void 0)
|
|
2147
2147
|
t[f] = ce(
|
|
2148
|
-
|
|
2148
|
+
l._liveConfig,
|
|
2149
2149
|
t[f],
|
|
2150
2150
|
e,
|
|
2151
|
-
|
|
2151
|
+
n,
|
|
2152
2152
|
r
|
|
2153
2153
|
);
|
|
2154
2154
|
else {
|
|
2155
2155
|
const u = t[f];
|
|
2156
2156
|
if (ot(u)) {
|
|
2157
|
-
const y =
|
|
2158
|
-
y !== void 0 && he(y, u, e,
|
|
2157
|
+
const y = l instanceof _ && l.shape !== void 0 ? l.shape : void 0;
|
|
2158
|
+
y !== void 0 && he(y, u, e, n, s, r, o, a, c);
|
|
2159
2159
|
}
|
|
2160
2160
|
}
|
|
2161
2161
|
}
|
|
2162
|
-
function ot(
|
|
2163
|
-
return typeof
|
|
2162
|
+
function ot(i) {
|
|
2163
|
+
return typeof i == "object" && i !== null && !Array.isArray(i) && Object.getPrototypeOf(i) === ue && !x.has(i);
|
|
2164
2164
|
}
|
|
2165
|
-
function
|
|
2166
|
-
if (
|
|
2167
|
-
return typeof
|
|
2165
|
+
function ki(i) {
|
|
2166
|
+
if (i !== void 0)
|
|
2167
|
+
return typeof i == "string" ? i : typeof i == "function" ? i() : i.value;
|
|
2168
2168
|
}
|
|
2169
|
-
function
|
|
2170
|
-
return me(
|
|
2169
|
+
function Ei(i) {
|
|
2170
|
+
return me(i);
|
|
2171
2171
|
}
|
|
2172
|
-
function Dt(
|
|
2173
|
-
if (
|
|
2172
|
+
function Dt(i) {
|
|
2173
|
+
if (i === void 0)
|
|
2174
2174
|
return;
|
|
2175
2175
|
const t = {};
|
|
2176
|
-
for (const [e,
|
|
2177
|
-
|
|
2176
|
+
for (const [e, n] of Object.entries(i))
|
|
2177
|
+
Ei(n) ? t[e] = n.value : t[e] = n;
|
|
2178
2178
|
return t;
|
|
2179
2179
|
}
|
|
2180
|
-
const vt = (
|
|
2181
|
-
class
|
|
2180
|
+
const vt = (i, t) => D([i.statics.id, t]);
|
|
2181
|
+
class Fi {
|
|
2182
2182
|
entityMap;
|
|
2183
2183
|
queryInstances = /* @__PURE__ */ new Map();
|
|
2184
2184
|
mutationInstances = /* @__PURE__ */ new Map();
|
|
@@ -2191,46 +2191,46 @@ class Tn {
|
|
|
2191
2191
|
typenameRegistry = /* @__PURE__ */ new Map();
|
|
2192
2192
|
constraintRegistry = /* @__PURE__ */ new Map();
|
|
2193
2193
|
mergedDefCache = /* @__PURE__ */ new Map();
|
|
2194
|
-
|
|
2194
|
+
adapters = /* @__PURE__ */ new Map();
|
|
2195
2195
|
networkUnsubscribe;
|
|
2196
2196
|
constructor(t = {}) {
|
|
2197
2197
|
const {
|
|
2198
|
-
store: e = new
|
|
2199
|
-
log:
|
|
2198
|
+
store: e = new be(new Ce()),
|
|
2199
|
+
log: n,
|
|
2200
2200
|
evictionMultiplier: s,
|
|
2201
|
-
|
|
2201
|
+
adapters: r,
|
|
2202
2202
|
networkManager: o,
|
|
2203
2203
|
gcManager: a,
|
|
2204
2204
|
...c
|
|
2205
2205
|
} = t;
|
|
2206
|
-
this.isServer = typeof window > "u", this.store = e, this.context = { ...c, log:
|
|
2207
|
-
for (const u of t.
|
|
2208
|
-
this.
|
|
2209
|
-
const f = this.networkManager.getOnlineSignal(),
|
|
2210
|
-
this.networkUnsubscribe =
|
|
2206
|
+
this.isServer = typeof window > "u", this.store = e, this.context = { ...c, log: n ?? console, evictionMultiplier: s }, this.gcManager = t.gcManager ?? (this.isServer ? new Re() : new Oe(this.handleEviction, s)), this.networkManager = t.networkManager ?? new ee(), this.entityMap = new ci((u, y, v) => this.store.saveEntity(u, y, v));
|
|
2207
|
+
for (const u of t.adapters ?? [])
|
|
2208
|
+
this.adapters.set(u.constructor, u), u.register(this);
|
|
2209
|
+
const f = this.networkManager.getOnlineSignal(), l = we(() => f.value);
|
|
2210
|
+
this.networkUnsubscribe = l.addListener(
|
|
2211
2211
|
() => {
|
|
2212
2212
|
const u = f.value;
|
|
2213
|
-
for (const y of this.
|
|
2213
|
+
for (const y of this.adapters.values())
|
|
2214
2214
|
y.onNetworkStatusChange?.(u);
|
|
2215
2215
|
},
|
|
2216
2216
|
{ skipInitial: !0 }
|
|
2217
2217
|
), this.store.purgeStaleQueries?.();
|
|
2218
2218
|
}
|
|
2219
2219
|
/**
|
|
2220
|
-
* Returns the registered
|
|
2221
|
-
* Throws if no
|
|
2220
|
+
* Returns the registered adapter instance for the given adapter class.
|
|
2221
|
+
* Throws if no adapter of that class has been registered.
|
|
2222
2222
|
*/
|
|
2223
|
-
|
|
2224
|
-
let e = this.
|
|
2223
|
+
getAdapter(t) {
|
|
2224
|
+
let e = this.adapters.get(t);
|
|
2225
2225
|
if (!e) {
|
|
2226
2226
|
try {
|
|
2227
2227
|
e = new t();
|
|
2228
2228
|
} catch {
|
|
2229
2229
|
throw new Error(
|
|
2230
|
-
`No
|
|
2230
|
+
`No adapter registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, adapters: [new ${t.name}(...)] })`
|
|
2231
2231
|
);
|
|
2232
2232
|
}
|
|
2233
|
-
this.
|
|
2233
|
+
this.adapters.set(t, e), e.register(this);
|
|
2234
2234
|
}
|
|
2235
2235
|
return e;
|
|
2236
2236
|
}
|
|
@@ -2243,10 +2243,10 @@ class Tn {
|
|
|
2243
2243
|
registerEntityDef(t) {
|
|
2244
2244
|
const e = t.typenameValue;
|
|
2245
2245
|
if (e === void 0 || t._entityClass === void 0) return;
|
|
2246
|
-
const
|
|
2247
|
-
if (
|
|
2248
|
-
if (
|
|
2249
|
-
|
|
2246
|
+
const n = this.typenameRegistry.get(e);
|
|
2247
|
+
if (n !== void 0) {
|
|
2248
|
+
if (n.indexOf(t) !== -1) return;
|
|
2249
|
+
n.push(t), this.mergedDefCache.delete(e), this.getMergedDef(e);
|
|
2250
2250
|
} else
|
|
2251
2251
|
this.typenameRegistry.set(e, [t]);
|
|
2252
2252
|
}
|
|
@@ -2256,19 +2256,19 @@ class Tn {
|
|
|
2256
2256
|
getMergedDef(t) {
|
|
2257
2257
|
let e = this.mergedDefCache.get(t);
|
|
2258
2258
|
if (e !== void 0) return e;
|
|
2259
|
-
const
|
|
2260
|
-
if (
|
|
2261
|
-
return e = _.merge(
|
|
2259
|
+
const n = this.typenameRegistry.get(t);
|
|
2260
|
+
if (n !== void 0)
|
|
2261
|
+
return e = _.merge(n), this.mergedDefCache.set(t, e), e;
|
|
2262
2262
|
}
|
|
2263
|
-
saveQueryData(t, e,
|
|
2263
|
+
saveQueryData(t, e, n, s, r) {
|
|
2264
2264
|
const o = r !== void 0 && r.size > 0 ? new Set([...r.keys()].map((a) => a.key)) : void 0;
|
|
2265
|
-
this.store.saveQuery(t, e,
|
|
2265
|
+
this.store.saveQuery(t, e, n, s, o);
|
|
2266
2266
|
}
|
|
2267
2267
|
activateQuery(t) {
|
|
2268
|
-
const { def: e, queryKey:
|
|
2268
|
+
const { def: e, queryKey: n, storageKey: s, config: r } = t;
|
|
2269
2269
|
this.store.activateQuery(e, s);
|
|
2270
2270
|
const o = r?.gcTime ?? kt;
|
|
2271
|
-
this.gcManager.cancel(
|
|
2271
|
+
this.gcManager.cancel(n, o);
|
|
2272
2272
|
}
|
|
2273
2273
|
loadCachedQuery(t, e) {
|
|
2274
2274
|
return this.store.loadQuery(t, e);
|
|
@@ -2278,9 +2278,9 @@ class Tn {
|
|
|
2278
2278
|
* that triggers fetches and prepopulates with cached data
|
|
2279
2279
|
*/
|
|
2280
2280
|
getQuery(t, e) {
|
|
2281
|
-
const
|
|
2282
|
-
let s = this.queryInstances.get(
|
|
2283
|
-
return s === void 0 && (s = new
|
|
2281
|
+
const n = vt(t, e);
|
|
2282
|
+
let s = this.queryInstances.get(n);
|
|
2283
|
+
return s === void 0 && (s = new ui(t, this, n, e), this.queryInstances.set(n, s)), s.relay;
|
|
2284
2284
|
}
|
|
2285
2285
|
/**
|
|
2286
2286
|
* Gets or creates a MutationResult for the given mutation definition.
|
|
@@ -2288,53 +2288,53 @@ class Tn {
|
|
|
2288
2288
|
*/
|
|
2289
2289
|
getMutation(t) {
|
|
2290
2290
|
const e = t.id;
|
|
2291
|
-
let
|
|
2292
|
-
return
|
|
2291
|
+
let n = this.mutationInstances.get(e);
|
|
2292
|
+
return n === void 0 && (n = new di(t, this), this.mutationInstances.set(e, n)), n.task;
|
|
2293
2293
|
}
|
|
2294
2294
|
/**
|
|
2295
2295
|
* Parse data: validates, formats, produces parsed entity data objects.
|
|
2296
2296
|
* Does NOT touch the entity store. Call applyRefs() after to commit entities.
|
|
2297
2297
|
*/
|
|
2298
|
-
parseData(t, e,
|
|
2298
|
+
parseData(t, e, n) {
|
|
2299
2299
|
const s = this.context.log?.warn ?? (() => {
|
|
2300
2300
|
}), r = new st();
|
|
2301
|
-
return r.reset(this,
|
|
2301
|
+
return r.reset(this, n, s), { data: Jt(t, e, r), ctx: r };
|
|
2302
2302
|
}
|
|
2303
2303
|
/**
|
|
2304
2304
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
2305
2305
|
* updates EntityInstances, replaces parsed data with proxies, counts child
|
|
2306
2306
|
* refs. Returns the reified data and root-level entity refs.
|
|
2307
2307
|
*/
|
|
2308
|
-
applyRefs(t, e = !0,
|
|
2309
|
-
return tt(t.ctx, t.data, e,
|
|
2308
|
+
applyRefs(t, e = !0, n = !1) {
|
|
2309
|
+
return tt(t.ctx, t.data, e, n);
|
|
2310
2310
|
}
|
|
2311
2311
|
/**
|
|
2312
2312
|
* Parse and apply data as a root entity. For non-entity results, injects
|
|
2313
2313
|
* QUERY_ID onto the payload. Returns the root EntityInstance (created or
|
|
2314
2314
|
* found in the store by the standard entity pipeline).
|
|
2315
2315
|
*/
|
|
2316
|
-
parseAndApplyRootEntity(t, e,
|
|
2317
|
-
typeof
|
|
2318
|
-
const a = this.parseData(t,
|
|
2316
|
+
parseAndApplyRootEntity(t, e, n, s, r = !1, o) {
|
|
2317
|
+
typeof n.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Ft] = e);
|
|
2318
|
+
const a = this.parseData(t, n, o), c = tt(a.ctx, a.data, s, r), f = x.get(c.data);
|
|
2319
2319
|
return this.entityMap.getEntity(f);
|
|
2320
2320
|
}
|
|
2321
|
-
prepareEntity(t, e,
|
|
2322
|
-
return this.registerEntityDef(
|
|
2321
|
+
prepareEntity(t, e, n) {
|
|
2322
|
+
return this.registerEntityDef(n), this.entityMap.getOrCreateEntity(t, e, n, this);
|
|
2323
2323
|
}
|
|
2324
2324
|
// ======================================================
|
|
2325
2325
|
// Mutation Events
|
|
2326
2326
|
// ======================================================
|
|
2327
2327
|
applyMutationEvent(t) {
|
|
2328
|
-
const { type: e, typename:
|
|
2328
|
+
const { type: e, typename: n } = t, s = this.getMergedDef(n);
|
|
2329
2329
|
if (s === void 0) return;
|
|
2330
2330
|
const r = s.idField;
|
|
2331
2331
|
if (r === void 0 || typeof r == "symbol") return;
|
|
2332
2332
|
const o = t.data, a = t.id !== void 0 ? t.id : e === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[r];
|
|
2333
2333
|
if (a === void 0) return;
|
|
2334
|
-
const c = D([
|
|
2334
|
+
const c = D([n, a]), f = t.__eventSource, l = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2335
2335
|
if (e === "delete") {
|
|
2336
|
-
const g = u !== void 0 ? u.data :
|
|
2337
|
-
this.routeEvent(
|
|
2336
|
+
const g = u !== void 0 ? u.data : l;
|
|
2337
|
+
this.routeEvent(n, g, c, e, f, void 0, g);
|
|
2338
2338
|
return;
|
|
2339
2339
|
}
|
|
2340
2340
|
try {
|
|
@@ -2347,7 +2347,7 @@ class Tn {
|
|
|
2347
2347
|
/* isPartialEvent */
|
|
2348
2348
|
!0
|
|
2349
2349
|
);
|
|
2350
|
-
const I = Xe(
|
|
2350
|
+
const I = Xe(l, s, w);
|
|
2351
2351
|
tt(w, I, !0);
|
|
2352
2352
|
} catch (g) {
|
|
2353
2353
|
if (this.context.log?.warn?.("Failed to apply mutation event", g), u === void 0) {
|
|
@@ -2361,7 +2361,7 @@ class Tn {
|
|
|
2361
2361
|
this.entityMap.save(y);
|
|
2362
2362
|
const v = u === void 0;
|
|
2363
2363
|
let p = !1;
|
|
2364
|
-
this.routeEvent(
|
|
2364
|
+
this.routeEvent(n, y.data, c, e, f, () => {
|
|
2365
2365
|
p = !0;
|
|
2366
2366
|
}), v && !p && y.evict();
|
|
2367
2367
|
}
|
|
@@ -2370,9 +2370,9 @@ class Tn {
|
|
|
2370
2370
|
// ======================================================
|
|
2371
2371
|
invalidateQueries(t) {
|
|
2372
2372
|
for (const e of t) {
|
|
2373
|
-
const
|
|
2373
|
+
const n = Array.isArray(e), s = n ? e[0] : e, r = n ? e[1] : void 0, a = V.for(s).statics.id;
|
|
2374
2374
|
for (const [, c] of this.queryInstances)
|
|
2375
|
-
c.def.statics.id === a && (r === void 0 ||
|
|
2375
|
+
c.def.statics.id === a && (r === void 0 || Ci(c.resolvedParams, r)) && c.markStale();
|
|
2376
2376
|
}
|
|
2377
2377
|
}
|
|
2378
2378
|
// ======================================================
|
|
@@ -2385,44 +2385,44 @@ class Tn {
|
|
|
2385
2385
|
s.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
2386
2386
|
return;
|
|
2387
2387
|
}
|
|
2388
|
-
const
|
|
2389
|
-
|
|
2388
|
+
const n = this.entityMap.getEntity(t);
|
|
2389
|
+
n !== void 0 && n.evict();
|
|
2390
2390
|
};
|
|
2391
2391
|
// ======================================================
|
|
2392
2392
|
// Constraint Registry (Live Data)
|
|
2393
2393
|
// ======================================================
|
|
2394
2394
|
getOrCreateMatcher(t) {
|
|
2395
2395
|
let e = this.constraintRegistry.get(t);
|
|
2396
|
-
return e === void 0 && (e = new
|
|
2396
|
+
return e === void 0 && (e = new vi(), this.constraintRegistry.set(t, e)), e;
|
|
2397
2397
|
}
|
|
2398
2398
|
registerLiveCollection(t) {
|
|
2399
|
-
for (const [e,
|
|
2400
|
-
this.registerEntityDef(
|
|
2399
|
+
for (const [e, n] of t._entityDefsByTypename)
|
|
2400
|
+
this.registerEntityDef(n), this.getOrCreateMatcher(e).registerBinding(t, e);
|
|
2401
2401
|
}
|
|
2402
2402
|
unregisterLiveCollection(t) {
|
|
2403
2403
|
for (const e of t._entityDefsByTypename.keys()) {
|
|
2404
|
-
const
|
|
2405
|
-
|
|
2404
|
+
const n = this.constraintRegistry.get(e);
|
|
2405
|
+
n !== void 0 && n.unregisterBinding(t, e);
|
|
2406
2406
|
}
|
|
2407
2407
|
}
|
|
2408
|
-
routeEvent(t, e,
|
|
2408
|
+
routeEvent(t, e, n, s, r, o, a) {
|
|
2409
2409
|
const c = this.constraintRegistry.get(t);
|
|
2410
2410
|
if (c === void 0) return;
|
|
2411
2411
|
const f = r !== void 0 ? { ...e, [se]: r } : e;
|
|
2412
|
-
c.routeEvent(t, f,
|
|
2412
|
+
c.routeEvent(t, f, n, s, o, a);
|
|
2413
2413
|
}
|
|
2414
2414
|
destroy() {
|
|
2415
2415
|
this.networkUnsubscribe?.(), this.gcManager.destroy(), this.networkManager.destroy();
|
|
2416
|
-
for (const t of this.
|
|
2416
|
+
for (const t of this.adapters.values())
|
|
2417
2417
|
t.destroy?.();
|
|
2418
|
-
this.
|
|
2418
|
+
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2419
2419
|
}
|
|
2420
2420
|
}
|
|
2421
|
-
const
|
|
2422
|
-
function
|
|
2423
|
-
if (
|
|
2421
|
+
const bi = Mt(void 0);
|
|
2422
|
+
function Ci(i, t) {
|
|
2423
|
+
if (i === void 0) return !1;
|
|
2424
2424
|
for (const e in t)
|
|
2425
|
-
if (
|
|
2425
|
+
if (i[e] !== t[e]) return !1;
|
|
2426
2426
|
return !0;
|
|
2427
2427
|
}
|
|
2428
2428
|
export {
|
|
@@ -2430,28 +2430,28 @@ export {
|
|
|
2430
2430
|
qt as E,
|
|
2431
2431
|
Oe as G,
|
|
2432
2432
|
j as L,
|
|
2433
|
-
|
|
2433
|
+
d as M,
|
|
2434
2434
|
ee as N,
|
|
2435
2435
|
Ft as Q,
|
|
2436
2436
|
B as R,
|
|
2437
2437
|
_ as V,
|
|
2438
2438
|
ct as a,
|
|
2439
|
-
|
|
2439
|
+
Di as b,
|
|
2440
2440
|
L as c,
|
|
2441
2441
|
Re as d,
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2442
|
+
ie as e,
|
|
2443
|
+
Ii as f,
|
|
2444
|
+
Fi as g,
|
|
2445
|
+
bi as h,
|
|
2446
|
+
fi as i,
|
|
2447
|
+
Ai as j,
|
|
2448
|
+
Mi as k,
|
|
2449
2449
|
jt as l,
|
|
2450
2450
|
De as m,
|
|
2451
2451
|
W as n,
|
|
2452
|
-
|
|
2453
|
-
|
|
2452
|
+
ki as o,
|
|
2453
|
+
Ni as q,
|
|
2454
2454
|
Gt as r,
|
|
2455
2455
|
He as t
|
|
2456
2456
|
};
|
|
2457
|
-
//# sourceMappingURL=QueryClient-
|
|
2457
|
+
//# sourceMappingURL=QueryClient-KH0Ex_8m.js.map
|