@instantdb/core 0.22.167 → 0.22.168
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/__tests__/src/auth-extra-fields.e2e.test.ts +134 -0
- package/__tests__/src/utils/e2e.ts +23 -11
- package/dist/commonjs/Reactor.d.ts +12 -9
- package/dist/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +48 -11
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/authAPI.d.ts +19 -2
- package/dist/commonjs/authAPI.d.ts.map +1 -1
- package/dist/commonjs/authAPI.js +23 -2
- package/dist/commonjs/authAPI.js.map +1 -1
- package/dist/commonjs/index.d.ts +6 -5
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/Reactor.d.ts +12 -9
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +48 -11
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/authAPI.d.ts +19 -2
- package/dist/esm/authAPI.d.ts.map +1 -1
- package/dist/esm/authAPI.js +22 -2
- package/dist/esm/authAPI.js.map +1 -1
- package/dist/esm/index.d.ts +6 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/standalone/index.js +891 -864
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +3 -2
- package/src/Reactor.js +49 -11
- package/src/authAPI.ts +45 -2
- package/src/index.ts +11 -4
- package/vitest.config.ts +6 -0
package/dist/standalone/index.js
CHANGED
|
@@ -40,14 +40,14 @@ const R = {
|
|
|
40
40
|
Remove: "remove",
|
|
41
41
|
Replace: "replace",
|
|
42
42
|
Add: "add"
|
|
43
|
-
},
|
|
43
|
+
}, Tn = /* @__PURE__ */ Symbol.for("__MUTATIVE_PROXY_DRAFT__"), yr = /* @__PURE__ */ Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Ke = Symbol.iterator, Z = {
|
|
44
44
|
mutable: "mutable",
|
|
45
45
|
immutable: "immutable"
|
|
46
|
-
},
|
|
46
|
+
}, Ot = {};
|
|
47
47
|
function Me(n, e) {
|
|
48
48
|
return n instanceof Map ? n.has(e) : Object.prototype.hasOwnProperty.call(n, e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Nt(n, e) {
|
|
51
51
|
if (e in n) {
|
|
52
52
|
let t = Reflect.getPrototypeOf(n);
|
|
53
53
|
for (; t; ) {
|
|
@@ -58,10 +58,10 @@ function Ut(n, e) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function It(n) {
|
|
62
62
|
return Object.getPrototypeOf(n) === Set.prototype;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Ct(n) {
|
|
65
65
|
return Object.getPrototypeOf(n) === Map.prototype;
|
|
66
66
|
}
|
|
67
67
|
function Y(n) {
|
|
@@ -72,9 +72,9 @@ function he(n) {
|
|
|
72
72
|
return !!A(n);
|
|
73
73
|
}
|
|
74
74
|
function A(n) {
|
|
75
|
-
return typeof n != "object" ? null : n?.[
|
|
75
|
+
return typeof n != "object" ? null : n?.[Tn];
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function Et(n) {
|
|
78
78
|
var e;
|
|
79
79
|
const t = A(n);
|
|
80
80
|
return t ? (e = t.copy) !== null && e !== void 0 ? e : t.original : n;
|
|
@@ -85,7 +85,7 @@ function re(n, e) {
|
|
|
85
85
|
let t;
|
|
86
86
|
return Object.getPrototypeOf(n) === Object.prototype || Array.isArray(n) || n instanceof Map || n instanceof Set || !!e?.mark && ((t = e.mark(n, Z)) === Z.immutable || typeof t == "function");
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function vn(n, e = []) {
|
|
89
89
|
if (Object.hasOwnProperty.call(n, "key")) {
|
|
90
90
|
const t = n.parent.copy, r = A(ue(t, n.key));
|
|
91
91
|
if (r !== null && r?.original !== n.original)
|
|
@@ -96,10 +96,10 @@ function Sn(n, e = []) {
|
|
|
96
96
|
e.push(i);
|
|
97
97
|
}
|
|
98
98
|
if (n.parent)
|
|
99
|
-
return
|
|
99
|
+
return vn(n.parent, e);
|
|
100
100
|
e.reverse();
|
|
101
101
|
try {
|
|
102
|
-
|
|
102
|
+
br(n.copy, e);
|
|
103
103
|
} catch {
|
|
104
104
|
return null;
|
|
105
105
|
}
|
|
@@ -114,14 +114,14 @@ function ue(n, e) {
|
|
|
114
114
|
function $e(n, e, t) {
|
|
115
115
|
pe(n) === 2 ? n.set(e, t) : n[e] = t;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function tt(n, e) {
|
|
118
118
|
const t = A(n);
|
|
119
119
|
return (t ? Y(t) : n)[e];
|
|
120
120
|
}
|
|
121
121
|
function ce(n, e) {
|
|
122
122
|
return n === e ? n !== 0 || 1 / n === 1 / e : n !== n && e !== e;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function ct(n) {
|
|
125
125
|
if (n)
|
|
126
126
|
for (; n.finalities.revoke.length > 0; )
|
|
127
127
|
n.finalities.revoke.pop()();
|
|
@@ -132,7 +132,7 @@ function fe(n, e) {
|
|
|
132
132
|
return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
133
133
|
}).join("/");
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function br(n, e) {
|
|
136
136
|
for (let t = 0; t < e.length - 1; t += 1) {
|
|
137
137
|
const r = e[t];
|
|
138
138
|
if (n = ue(pe(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
|
|
@@ -140,7 +140,7 @@ function pr(n, e) {
|
|
|
140
140
|
}
|
|
141
141
|
return n;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function gr(n) {
|
|
144
144
|
const e = Object.create(Object.getPrototypeOf(n));
|
|
145
145
|
return Reflect.ownKeys(n).forEach((t) => {
|
|
146
146
|
let r = Reflect.getOwnPropertyDescriptor(n, t);
|
|
@@ -156,26 +156,26 @@ function yr(n) {
|
|
|
156
156
|
}), Reflect.defineProperty(e, t, r);
|
|
157
157
|
}), e;
|
|
158
158
|
}
|
|
159
|
-
const
|
|
160
|
-
function
|
|
159
|
+
const mr = Object.prototype.propertyIsEnumerable;
|
|
160
|
+
function An(n, e) {
|
|
161
161
|
let t;
|
|
162
162
|
if (Array.isArray(n))
|
|
163
163
|
return Array.prototype.concat.call(n);
|
|
164
164
|
if (n instanceof Set) {
|
|
165
|
-
if (!
|
|
165
|
+
if (!It(n)) {
|
|
166
166
|
const r = Object.getPrototypeOf(n).constructor;
|
|
167
167
|
return new r(n.values());
|
|
168
168
|
}
|
|
169
169
|
return Set.prototype.difference ? Set.prototype.difference.call(n, /* @__PURE__ */ new Set()) : new Set(n.values());
|
|
170
170
|
} else if (n instanceof Map) {
|
|
171
|
-
if (!
|
|
171
|
+
if (!Ct(n)) {
|
|
172
172
|
const r = Object.getPrototypeOf(n).constructor;
|
|
173
173
|
return new r(n);
|
|
174
174
|
}
|
|
175
175
|
return new Map(n);
|
|
176
176
|
} else if (e?.mark && (t = e.mark(n, Z), t !== void 0) && t !== Z.mutable) {
|
|
177
177
|
if (t === Z.immutable)
|
|
178
|
-
return
|
|
178
|
+
return gr(n);
|
|
179
179
|
if (typeof t == "function") {
|
|
180
180
|
if (e.enablePatches || e.enableAutoFreeze)
|
|
181
181
|
throw new Error("You can't use mark and patches or auto freeze together.");
|
|
@@ -187,17 +187,17 @@ function Tn(n, e) {
|
|
|
187
187
|
return Object.keys(n).forEach((s) => {
|
|
188
188
|
r[s] = n[s];
|
|
189
189
|
}), Object.getOwnPropertySymbols(n).forEach((s) => {
|
|
190
|
-
|
|
190
|
+
mr.call(n, s) && (r[s] = n[s]);
|
|
191
191
|
}), r;
|
|
192
192
|
} else
|
|
193
193
|
throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
|
|
194
194
|
}
|
|
195
195
|
function z(n) {
|
|
196
|
-
n.copy || (n.copy =
|
|
196
|
+
n.copy || (n.copy = An(n.original, n.options));
|
|
197
197
|
}
|
|
198
198
|
function Ie(n) {
|
|
199
199
|
if (!re(n))
|
|
200
|
-
return
|
|
200
|
+
return Et(n);
|
|
201
201
|
if (Array.isArray(n))
|
|
202
202
|
return n.map(Ie);
|
|
203
203
|
if (n instanceof Map) {
|
|
@@ -205,7 +205,7 @@ function Ie(n) {
|
|
|
205
205
|
r,
|
|
206
206
|
Ie(s)
|
|
207
207
|
]);
|
|
208
|
-
if (!
|
|
208
|
+
if (!Ct(n)) {
|
|
209
209
|
const r = Object.getPrototypeOf(n).constructor;
|
|
210
210
|
return new r(t);
|
|
211
211
|
}
|
|
@@ -213,7 +213,7 @@ function Ie(n) {
|
|
|
213
213
|
}
|
|
214
214
|
if (n instanceof Set) {
|
|
215
215
|
const t = Array.from(n).map(Ie);
|
|
216
|
-
if (!
|
|
216
|
+
if (!It(n)) {
|
|
217
217
|
const r = Object.getPrototypeOf(n).constructor;
|
|
218
218
|
return new r(t);
|
|
219
219
|
}
|
|
@@ -231,7 +231,7 @@ function oe(n) {
|
|
|
231
231
|
var e;
|
|
232
232
|
n.assignedMap = (e = n.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), n.operated || (n.operated = !0, n.parent && oe(n.parent));
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function Ft() {
|
|
235
235
|
throw new Error("Cannot modify frozen object");
|
|
236
236
|
}
|
|
237
237
|
function me(n, e, t, r, s) {
|
|
@@ -259,12 +259,12 @@ function me(n, e, t, r, s) {
|
|
|
259
259
|
case 2:
|
|
260
260
|
for (const [a, c] of n)
|
|
261
261
|
me(a, a, t, r, s), me(c, a, t, r, s);
|
|
262
|
-
n.set = n.clear = n.delete =
|
|
262
|
+
n.set = n.clear = n.delete = Ft;
|
|
263
263
|
break;
|
|
264
264
|
case 3:
|
|
265
265
|
for (const a of n)
|
|
266
266
|
me(a, a, t, r, s);
|
|
267
|
-
n.add = n.clear = n.delete =
|
|
267
|
+
n.add = n.clear = n.delete = Ft;
|
|
268
268
|
break;
|
|
269
269
|
case 1:
|
|
270
270
|
Object.freeze(n);
|
|
@@ -280,7 +280,7 @@ function me(n, e, t, r, s) {
|
|
|
280
280
|
}
|
|
281
281
|
r.pop(), s.pop();
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function Mt(n, e) {
|
|
284
284
|
const t = pe(n);
|
|
285
285
|
if (t === 0)
|
|
286
286
|
Reflect.ownKeys(n).forEach((r) => {
|
|
@@ -293,11 +293,11 @@ function Ct(n, e) {
|
|
|
293
293
|
} else
|
|
294
294
|
n.forEach((r, s) => e(s, r, n));
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function kn(n, e, t) {
|
|
297
297
|
if (he(n) || !re(n, t) || e.has(n) || Object.isFrozen(n))
|
|
298
298
|
return;
|
|
299
299
|
const r = n instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
|
|
300
|
-
if (e.add(n),
|
|
300
|
+
if (e.add(n), Mt(n, (i, o) => {
|
|
301
301
|
var a;
|
|
302
302
|
if (he(o)) {
|
|
303
303
|
const c = A(o);
|
|
@@ -305,7 +305,7 @@ function vn(n, e, t) {
|
|
|
305
305
|
const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
|
|
306
306
|
$e(r ? s : n, i, u);
|
|
307
307
|
} else
|
|
308
|
-
|
|
308
|
+
kn(o, e, t);
|
|
309
309
|
}), s) {
|
|
310
310
|
const i = n, o = Array.from(i);
|
|
311
311
|
i.clear(), o.forEach((a) => {
|
|
@@ -313,39 +313,39 @@ function vn(n, e, t) {
|
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function wr(n, e) {
|
|
317
317
|
const t = n.type === 3 ? n.setMap : n.copy;
|
|
318
|
-
n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t &&
|
|
318
|
+
n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && kn(ue(t, e), n.finalities.handledSet, n.options);
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function ut(n) {
|
|
321
321
|
n.type === 3 && n.copy && (n.copy.clear(), n.setMap.forEach((e) => {
|
|
322
|
-
n.copy.add(
|
|
322
|
+
n.copy.add(Et(e));
|
|
323
323
|
}));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function lt(n, e, t, r) {
|
|
326
326
|
if (n.operated && n.assignedMap && n.assignedMap.size > 0 && !n.finalized) {
|
|
327
327
|
if (t && r) {
|
|
328
|
-
const i =
|
|
328
|
+
const i = vn(n);
|
|
329
329
|
i && e(n, i, t, r);
|
|
330
330
|
}
|
|
331
331
|
n.finalized = !0;
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function Pt(n, e, t, r) {
|
|
335
335
|
const s = A(t);
|
|
336
336
|
s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
|
|
337
337
|
var a;
|
|
338
338
|
const c = n.type === 3 ? n.setMap : n.copy;
|
|
339
339
|
if (ce(ue(c, e), t)) {
|
|
340
340
|
let u = s.original;
|
|
341
|
-
s.copy && (u = s.copy),
|
|
341
|
+
s.copy && (u = s.copy), ut(n), lt(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), $e(c, e, u);
|
|
342
342
|
}
|
|
343
343
|
}), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), re(t, n.options) && n.finalities.draft.push(() => {
|
|
344
344
|
const i = n.type === 3 ? n.setMap : n.copy;
|
|
345
|
-
ce(ue(i, e), t) &&
|
|
345
|
+
ce(ue(i, e), t) && wr(n, e);
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function _r(n, e, t, r, s) {
|
|
349
349
|
let { original: i, assignedMap: o, options: a } = n, c = n.copy;
|
|
350
350
|
c.length < i.length && ([i, c] = [c, i], [t, r] = [r, t]);
|
|
351
351
|
for (let u = 0; u < i.length; u += 1)
|
|
@@ -391,7 +391,7 @@ function mr(n, e, t, r, s) {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function Sr({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
|
|
395
395
|
t.forEach((a, c) => {
|
|
396
396
|
const u = ue(n, c), l = qe(ue(e, c)), f = a ? Me(n, c) ? R.Replace : R.Add : R.Remove;
|
|
397
397
|
if (ce(u, l) && f === R.Replace)
|
|
@@ -400,7 +400,7 @@ function wr({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
|
|
|
400
400
|
s.push(f === R.Remove ? { op: f, path: h } : { op: f, path: h, value: l }), i.push(f === R.Add ? { op: R.Remove, path: h } : f === R.Remove ? { op: R.Add, path: h, value: u } : { op: R.Replace, path: h, value: u });
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function Tr({ original: n, copy: e }, t, r, s, i) {
|
|
404
404
|
let o = 0;
|
|
405
405
|
n.forEach((a) => {
|
|
406
406
|
if (!e.has(a)) {
|
|
@@ -437,17 +437,17 @@ function je(n, e, t, r) {
|
|
|
437
437
|
switch (n.type) {
|
|
438
438
|
case 0:
|
|
439
439
|
case 2:
|
|
440
|
-
return
|
|
440
|
+
return Sr(n, e, t, r, s);
|
|
441
441
|
case 1:
|
|
442
|
-
return mr(n, e, t, r, s);
|
|
443
|
-
case 3:
|
|
444
442
|
return _r(n, e, t, r, s);
|
|
443
|
+
case 3:
|
|
444
|
+
return Tr(n, e, t, r, s);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
const
|
|
447
|
+
const Ve = (n, e, t = !1) => {
|
|
448
448
|
if (typeof n == "object" && n !== null && (!re(n, e) || t))
|
|
449
449
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
450
|
-
},
|
|
450
|
+
}, dt = {
|
|
451
451
|
get size() {
|
|
452
452
|
return Y(A(this)).size;
|
|
453
453
|
},
|
|
@@ -456,7 +456,7 @@ const We = (n, e, t = !1) => {
|
|
|
456
456
|
},
|
|
457
457
|
set(n, e) {
|
|
458
458
|
const t = A(this), r = Y(t);
|
|
459
|
-
return (!r.has(n) || !ce(r.get(n), e)) && (z(t), oe(t), t.assignedMap.set(n, !0), t.copy.set(n, e),
|
|
459
|
+
return (!r.has(n) || !ce(r.get(n), e)) && (z(t), oe(t), t.assignedMap.set(n, !0), t.copy.set(n, e), Pt(t, n, e, je)), this;
|
|
460
460
|
},
|
|
461
461
|
delete(n) {
|
|
462
462
|
if (!this.has(n))
|
|
@@ -482,9 +482,9 @@ const We = (n, e, t = !1) => {
|
|
|
482
482
|
get(n) {
|
|
483
483
|
var e, t;
|
|
484
484
|
const r = A(this), s = Y(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, Z)) === Z.mutable;
|
|
485
|
-
if (r.options.strict &&
|
|
485
|
+
if (r.options.strict && Ve(s, r.options, i), i || r.finalized || !re(s, r.options) || s !== r.original.get(n))
|
|
486
486
|
return s;
|
|
487
|
-
const o =
|
|
487
|
+
const o = Ot.createDraft({
|
|
488
488
|
original: s,
|
|
489
489
|
parentDraft: r,
|
|
490
490
|
key: n,
|
|
@@ -499,7 +499,7 @@ const We = (n, e, t = !1) => {
|
|
|
499
499
|
values() {
|
|
500
500
|
const n = this.keys();
|
|
501
501
|
return {
|
|
502
|
-
[
|
|
502
|
+
[Ke]: () => this.values(),
|
|
503
503
|
next: () => {
|
|
504
504
|
const e = n.next();
|
|
505
505
|
return e.done ? e : {
|
|
@@ -512,7 +512,7 @@ const We = (n, e, t = !1) => {
|
|
|
512
512
|
entries() {
|
|
513
513
|
const n = this.keys();
|
|
514
514
|
return {
|
|
515
|
-
[
|
|
515
|
+
[Ke]: () => this.entries(),
|
|
516
516
|
next: () => {
|
|
517
517
|
const e = n.next();
|
|
518
518
|
if (e.done)
|
|
@@ -525,10 +525,10 @@ const We = (n, e, t = !1) => {
|
|
|
525
525
|
}
|
|
526
526
|
};
|
|
527
527
|
},
|
|
528
|
-
[
|
|
528
|
+
[Ke]() {
|
|
529
529
|
return this.entries();
|
|
530
530
|
}
|
|
531
|
-
},
|
|
531
|
+
}, vr = Reflect.ownKeys(dt), Kt = (n, e, { isValuesIterator: t }) => () => {
|
|
532
532
|
var r, s;
|
|
533
533
|
const i = e.next();
|
|
534
534
|
if (i.done)
|
|
@@ -536,8 +536,8 @@ const We = (n, e, t = !1) => {
|
|
|
536
536
|
const o = i.value;
|
|
537
537
|
let a = n.setMap.get(o);
|
|
538
538
|
const c = A(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, Z)) === Z.mutable;
|
|
539
|
-
if (n.options.strict &&
|
|
540
|
-
const l =
|
|
539
|
+
if (n.options.strict && Ve(o, n.options, u), !u && !c && re(o, n.options) && !n.finalized && n.original.has(o)) {
|
|
540
|
+
const l = Ot.createDraft({
|
|
541
541
|
original: o,
|
|
542
542
|
parentDraft: n,
|
|
543
543
|
key: o,
|
|
@@ -550,7 +550,7 @@ const We = (n, e, t = !1) => {
|
|
|
550
550
|
done: !1,
|
|
551
551
|
value: t ? a : [a, a]
|
|
552
552
|
};
|
|
553
|
-
},
|
|
553
|
+
}, Qe = {
|
|
554
554
|
get size() {
|
|
555
555
|
return A(this).setMap.size;
|
|
556
556
|
},
|
|
@@ -564,7 +564,7 @@ const We = (n, e, t = !1) => {
|
|
|
564
564
|
},
|
|
565
565
|
add(n) {
|
|
566
566
|
const e = A(this);
|
|
567
|
-
return this.has(n) || (z(e), oe(e), e.assignedMap.set(n, !0), e.setMap.set(n, n),
|
|
567
|
+
return this.has(n) || (z(e), oe(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), Pt(e, n, n, je)), this;
|
|
568
568
|
},
|
|
569
569
|
delete(n) {
|
|
570
570
|
if (!this.has(n))
|
|
@@ -589,7 +589,7 @@ const We = (n, e, t = !1) => {
|
|
|
589
589
|
const e = n.setMap.keys();
|
|
590
590
|
return {
|
|
591
591
|
[Symbol.iterator]: () => this.values(),
|
|
592
|
-
next:
|
|
592
|
+
next: Kt(n, e, { isValuesIterator: !0 })
|
|
593
593
|
};
|
|
594
594
|
},
|
|
595
595
|
entries() {
|
|
@@ -598,7 +598,7 @@ const We = (n, e, t = !1) => {
|
|
|
598
598
|
const e = n.setMap.keys();
|
|
599
599
|
return {
|
|
600
600
|
[Symbol.iterator]: () => this.entries(),
|
|
601
|
-
next:
|
|
601
|
+
next: Kt(n, e, {
|
|
602
602
|
isValuesIterator: !1
|
|
603
603
|
})
|
|
604
604
|
};
|
|
@@ -606,7 +606,7 @@ const We = (n, e, t = !1) => {
|
|
|
606
606
|
keys() {
|
|
607
607
|
return this.values();
|
|
608
608
|
},
|
|
609
|
-
[
|
|
609
|
+
[Ke]() {
|
|
610
610
|
return this.values();
|
|
611
611
|
},
|
|
612
612
|
forEach(n, e) {
|
|
@@ -616,7 +616,7 @@ const We = (n, e, t = !1) => {
|
|
|
616
616
|
n.call(e, r.value, r.value, this), r = t.next();
|
|
617
617
|
}
|
|
618
618
|
};
|
|
619
|
-
Set.prototype.difference && Object.assign(
|
|
619
|
+
Set.prototype.difference && Object.assign(Qe, {
|
|
620
620
|
intersection(n) {
|
|
621
621
|
return Set.prototype.intersection.call(new Set(this.values()), n);
|
|
622
622
|
},
|
|
@@ -639,47 +639,47 @@ Set.prototype.difference && Object.assign(Ve, {
|
|
|
639
639
|
return Set.prototype.isDisjointFrom.call(new Set(this.values()), n);
|
|
640
640
|
}
|
|
641
641
|
});
|
|
642
|
-
const
|
|
642
|
+
const Ar = Reflect.ownKeys(Qe), On = /* @__PURE__ */ new WeakSet(), In = {
|
|
643
643
|
get(n, e, t) {
|
|
644
644
|
var r, s;
|
|
645
645
|
const i = (r = n.copy) === null || r === void 0 ? void 0 : r[e];
|
|
646
|
-
if (i &&
|
|
646
|
+
if (i && On.has(i))
|
|
647
647
|
return i;
|
|
648
|
-
if (e ===
|
|
648
|
+
if (e === Tn)
|
|
649
649
|
return n;
|
|
650
650
|
let o;
|
|
651
651
|
if (n.options.mark) {
|
|
652
652
|
const u = e === "size" && (n.original instanceof Map || n.original instanceof Set) ? Reflect.get(n.original, e) : Reflect.get(n.original, e, t);
|
|
653
653
|
if (o = n.options.mark(u, Z), o === Z.mutable)
|
|
654
|
-
return n.options.strict &&
|
|
654
|
+
return n.options.strict && Ve(u, n.options, !0), u;
|
|
655
655
|
}
|
|
656
656
|
const a = Y(n);
|
|
657
|
-
if (a instanceof Map &&
|
|
657
|
+
if (a instanceof Map && vr.includes(e)) {
|
|
658
658
|
if (e === "size")
|
|
659
|
-
return Object.getOwnPropertyDescriptor(
|
|
660
|
-
const u =
|
|
659
|
+
return Object.getOwnPropertyDescriptor(dt, "size").get.call(n.proxy);
|
|
660
|
+
const u = dt[e];
|
|
661
661
|
if (u)
|
|
662
662
|
return u.bind(n.proxy);
|
|
663
663
|
}
|
|
664
|
-
if (a instanceof Set &&
|
|
664
|
+
if (a instanceof Set && Ar.includes(e)) {
|
|
665
665
|
if (e === "size")
|
|
666
|
-
return Object.getOwnPropertyDescriptor(
|
|
667
|
-
const u =
|
|
666
|
+
return Object.getOwnPropertyDescriptor(Qe, "size").get.call(n.proxy);
|
|
667
|
+
const u = Qe[e];
|
|
668
668
|
if (u)
|
|
669
669
|
return u.bind(n.proxy);
|
|
670
670
|
}
|
|
671
671
|
if (!Me(a, e)) {
|
|
672
|
-
const u =
|
|
672
|
+
const u = Nt(a, e);
|
|
673
673
|
return u ? "value" in u ? u.value : (
|
|
674
674
|
// !case: support for getter
|
|
675
675
|
(s = u.get) === null || s === void 0 ? void 0 : s.call(n.proxy)
|
|
676
676
|
) : void 0;
|
|
677
677
|
}
|
|
678
678
|
const c = a[e];
|
|
679
|
-
if (n.options.strict &&
|
|
679
|
+
if (n.options.strict && Ve(c, n.options), n.finalized || !re(c, n.options))
|
|
680
680
|
return c;
|
|
681
|
-
if (c ===
|
|
682
|
-
if (z(n), n.copy[e] =
|
|
681
|
+
if (c === tt(n.original, e)) {
|
|
682
|
+
if (z(n), n.copy[e] = jt({
|
|
683
683
|
original: n.original[e],
|
|
684
684
|
parentDraft: n,
|
|
685
685
|
key: n.type === 1 ? Number(e) : e,
|
|
@@ -700,11 +700,11 @@ const Tr = Reflect.ownKeys(Ve), An = /* @__PURE__ */ new WeakSet(), kn = {
|
|
|
700
700
|
let s;
|
|
701
701
|
if (n.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
|
|
702
702
|
throw new Error("Only supports setting array indices and the 'length' property.");
|
|
703
|
-
const i =
|
|
703
|
+
const i = Nt(Y(n), e);
|
|
704
704
|
if (i?.set)
|
|
705
705
|
return i.set.call(n.proxy, t), !0;
|
|
706
|
-
const o =
|
|
707
|
-
return a && ce(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (ce(t, o) && (t !== void 0 || Me(n.original, e)) || (z(n), oe(n), Me(n.original, e) && ce(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t,
|
|
706
|
+
const o = tt(Y(n), e), a = A(o);
|
|
707
|
+
return a && ce(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (ce(t, o) && (t !== void 0 || Me(n.original, e)) || (z(n), oe(n), Me(n.original, e) && ce(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Pt(n, e, t, je)), !0);
|
|
708
708
|
},
|
|
709
709
|
has(n, e) {
|
|
710
710
|
return e in Y(n);
|
|
@@ -732,10 +732,10 @@ const Tr = Reflect.ownKeys(Ve), An = /* @__PURE__ */ new WeakSet(), kn = {
|
|
|
732
732
|
},
|
|
733
733
|
deleteProperty(n, e) {
|
|
734
734
|
var t;
|
|
735
|
-
return n.type === 1 ?
|
|
735
|
+
return n.type === 1 ? In.set.call(this, n, e, void 0, n.proxy) : (tt(n.original, e) !== void 0 || e in n.original ? (z(n), oe(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
|
|
736
736
|
}
|
|
737
737
|
};
|
|
738
|
-
function
|
|
738
|
+
function jt(n) {
|
|
739
739
|
const { original: e, parentDraft: t, key: r, finalities: s, options: i } = n, o = pe(e), a = {
|
|
740
740
|
type: o,
|
|
741
741
|
finalized: !1,
|
|
@@ -749,8 +749,8 @@ function Mt(n) {
|
|
|
749
749
|
setMap: o === 3 ? new Map(e.entries()) : void 0
|
|
750
750
|
};
|
|
751
751
|
(r || "key" in n) && (a.key = r);
|
|
752
|
-
const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a,
|
|
753
|
-
if (s.revoke.push(u),
|
|
752
|
+
const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, In);
|
|
753
|
+
if (s.revoke.push(u), On.add(c), a.proxy = c, t) {
|
|
754
754
|
const l = t;
|
|
755
755
|
l.finalities.draft.push((f, d) => {
|
|
756
756
|
var h, p;
|
|
@@ -759,7 +759,7 @@ function Mt(n) {
|
|
|
759
759
|
const y = ue(g, r), b = A(y);
|
|
760
760
|
if (b) {
|
|
761
761
|
let _ = b.original;
|
|
762
|
-
b.operated && (_ =
|
|
762
|
+
b.operated && (_ = Et(y)), ut(b), lt(b, je, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (h = l.options.updatedValues) !== null && h !== void 0 ? h : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(_, b.original)), $e(g, r, _);
|
|
763
763
|
}
|
|
764
764
|
(p = m.callbacks) === null || p === void 0 || p.forEach((_) => {
|
|
765
765
|
_(f, d);
|
|
@@ -768,26 +768,26 @@ function Mt(n) {
|
|
|
768
768
|
} else {
|
|
769
769
|
const l = A(c);
|
|
770
770
|
l.finalities.draft.push((f, d) => {
|
|
771
|
-
|
|
771
|
+
ut(l), lt(l, je, f, d);
|
|
772
772
|
});
|
|
773
773
|
}
|
|
774
774
|
return c;
|
|
775
775
|
}
|
|
776
|
-
|
|
777
|
-
function
|
|
776
|
+
Ot.createDraft = jt;
|
|
777
|
+
function kr(n, e, t, r, s) {
|
|
778
778
|
var i;
|
|
779
779
|
const o = A(n), a = (i = o?.original) !== null && i !== void 0 ? i : n, c = !!e.length;
|
|
780
780
|
if (o?.operated)
|
|
781
781
|
for (; o.finalities.draft.length > 0; )
|
|
782
782
|
o.finalities.draft.pop()(t, r);
|
|
783
783
|
const u = c ? e[0] : o ? o.operated ? o.copy : o.original : n;
|
|
784
|
-
return o &&
|
|
784
|
+
return o && ct(o), s && me(u, u, o?.options.updatedValues), [
|
|
785
785
|
u,
|
|
786
786
|
t && c ? [{ op: R.Replace, path: [], value: e[0] }] : t,
|
|
787
787
|
r && c ? [{ op: R.Replace, path: [], value: a }] : r
|
|
788
788
|
];
|
|
789
789
|
}
|
|
790
|
-
function
|
|
790
|
+
function Or(n, e) {
|
|
791
791
|
var t;
|
|
792
792
|
const r = {
|
|
793
793
|
draft: [],
|
|
@@ -796,7 +796,7 @@ function Ar(n, e) {
|
|
|
796
796
|
};
|
|
797
797
|
let s, i;
|
|
798
798
|
e.enablePatches && (s = [], i = []);
|
|
799
|
-
const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, Z)) === Z.mutable || !re(n, e) ? n :
|
|
799
|
+
const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, Z)) === Z.mutable || !re(n, e) ? n : jt({
|
|
800
800
|
original: n,
|
|
801
801
|
parentDraft: null,
|
|
802
802
|
finalities: r,
|
|
@@ -805,14 +805,14 @@ function Ar(n, e) {
|
|
|
805
805
|
return [
|
|
806
806
|
a,
|
|
807
807
|
(c = []) => {
|
|
808
|
-
const [u, l, f] =
|
|
808
|
+
const [u, l, f] = kr(a, c, s, i, e.enableAutoFreeze);
|
|
809
809
|
return e.enablePatches ? [u, l, f] : u;
|
|
810
810
|
}
|
|
811
811
|
];
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function ft(n) {
|
|
814
814
|
const { rootDraft: e, value: t, useRawReturn: r = !1, isRoot: s = !0 } = n;
|
|
815
|
-
|
|
815
|
+
Mt(t, (i, o, a) => {
|
|
816
816
|
const c = A(o);
|
|
817
817
|
if (c && e && c.finalities === e.finalities) {
|
|
818
818
|
n.isContainDraft = !0;
|
|
@@ -822,10 +822,10 @@ function lt(n) {
|
|
|
822
822
|
a.clear(), l.forEach((f) => a.add(i === f ? u : f));
|
|
823
823
|
} else
|
|
824
824
|
$e(a, i, u);
|
|
825
|
-
} else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1,
|
|
825
|
+
} else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, ft(n));
|
|
826
826
|
}), s && (n.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
|
|
827
827
|
}
|
|
828
|
-
function
|
|
828
|
+
function Cn(n) {
|
|
829
829
|
var e;
|
|
830
830
|
const t = A(n);
|
|
831
831
|
if (!re(n, t?.options))
|
|
@@ -835,7 +835,7 @@ function On(n) {
|
|
|
835
835
|
return t.original;
|
|
836
836
|
let s;
|
|
837
837
|
function i() {
|
|
838
|
-
s = r === 2 ?
|
|
838
|
+
s = r === 2 ? Ct(n) ? new Map(n) : new (Object.getPrototypeOf(n)).constructor(n) : r === 3 ? Array.from(t.setMap.values()) : An(n, t?.options);
|
|
839
839
|
}
|
|
840
840
|
if (t) {
|
|
841
841
|
t.finalized = !0;
|
|
@@ -846,23 +846,23 @@ function On(n) {
|
|
|
846
846
|
}
|
|
847
847
|
} else
|
|
848
848
|
s = n;
|
|
849
|
-
if (
|
|
849
|
+
if (Mt(s, (o, a) => {
|
|
850
850
|
if (t && ce(ue(t.original, o), a))
|
|
851
851
|
return;
|
|
852
|
-
const c =
|
|
852
|
+
const c = Cn(a);
|
|
853
853
|
c !== a && (s === n && i(), $e(s, o, c));
|
|
854
854
|
}), r === 3) {
|
|
855
855
|
const o = (e = t?.original) !== null && e !== void 0 ? e : s;
|
|
856
|
-
return
|
|
856
|
+
return It(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
|
|
857
857
|
}
|
|
858
858
|
return s;
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function qt(n) {
|
|
861
861
|
if (!he(n))
|
|
862
862
|
throw new Error(`current() is only used for Draft, parameter: ${n}`);
|
|
863
|
-
return
|
|
863
|
+
return Cn(n);
|
|
864
864
|
}
|
|
865
|
-
const
|
|
865
|
+
const Ir = (n) => function e(t, r, s) {
|
|
866
866
|
var i, o, a;
|
|
867
867
|
if (typeof t == "function" && typeof r != "function")
|
|
868
868
|
return function(w, ...E) {
|
|
@@ -873,7 +873,7 @@ const kr = (n) => function e(t, r, s) {
|
|
|
873
873
|
if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
|
|
874
874
|
throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
|
|
875
875
|
l = Object.assign(Object.assign({}, n), l);
|
|
876
|
-
const f = he(c) ?
|
|
876
|
+
const f = he(c) ? qt(c) : c, d = Array.isArray(l.mark) ? ((w, E) => {
|
|
877
877
|
for (const P of l.mark) {
|
|
878
878
|
if (typeof P != "function")
|
|
879
879
|
throw new Error(`Invalid mark: ${P}, 'mark' should be a function.`);
|
|
@@ -889,7 +889,7 @@ const kr = (n) => function e(t, r, s) {
|
|
|
889
889
|
};
|
|
890
890
|
if (!re(f, g) && typeof f == "object" && f !== null)
|
|
891
891
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
892
|
-
const [y, b] =
|
|
892
|
+
const [y, b] = Or(f, g);
|
|
893
893
|
if (typeof r != "function") {
|
|
894
894
|
if (!re(f, g))
|
|
895
895
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
@@ -899,24 +899,24 @@ const kr = (n) => function e(t, r, s) {
|
|
|
899
899
|
try {
|
|
900
900
|
_ = u(y);
|
|
901
901
|
} catch (w) {
|
|
902
|
-
throw
|
|
902
|
+
throw ct(A(y)), w;
|
|
903
903
|
}
|
|
904
904
|
const M = (w) => {
|
|
905
905
|
const E = A(y);
|
|
906
906
|
if (!he(w)) {
|
|
907
907
|
if (w !== void 0 && !ce(w, y) && E?.operated)
|
|
908
908
|
throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
|
|
909
|
-
const N = w?.[
|
|
909
|
+
const N = w?.[yr];
|
|
910
910
|
if (N) {
|
|
911
911
|
const H = N[0];
|
|
912
|
-
return g.strict && typeof w == "object" && w !== null &&
|
|
912
|
+
return g.strict && typeof w == "object" && w !== null && ft({
|
|
913
913
|
rootDraft: E,
|
|
914
914
|
value: w,
|
|
915
915
|
useRawReturn: !0
|
|
916
916
|
}), b([H]);
|
|
917
917
|
}
|
|
918
918
|
if (w !== void 0)
|
|
919
|
-
return typeof w == "object" && w !== null &&
|
|
919
|
+
return typeof w == "object" && w !== null && ft({ rootDraft: E, value: w }), b([w]);
|
|
920
920
|
}
|
|
921
921
|
if (w === y || w === void 0)
|
|
922
922
|
return b([]);
|
|
@@ -924,30 +924,30 @@ const kr = (n) => function e(t, r, s) {
|
|
|
924
924
|
if (g === P.options) {
|
|
925
925
|
if (P.operated)
|
|
926
926
|
throw new Error("Cannot return a modified child draft.");
|
|
927
|
-
return b([
|
|
927
|
+
return b([qt(w)]);
|
|
928
928
|
}
|
|
929
929
|
return b([w]);
|
|
930
930
|
};
|
|
931
931
|
return _ instanceof Promise ? _.then(M, (w) => {
|
|
932
|
-
throw
|
|
932
|
+
throw ct(A(y)), w;
|
|
933
933
|
}) : M(_);
|
|
934
|
-
},
|
|
934
|
+
}, Be = Ir();
|
|
935
935
|
Object.prototype.constructor.toString();
|
|
936
|
-
function
|
|
936
|
+
function En(n, e) {
|
|
937
937
|
const t = Object.keys(n), r = Object.keys(e);
|
|
938
938
|
return t.length === r.length && Object.keys(n).every((s) => e.hasOwnProperty(s));
|
|
939
939
|
}
|
|
940
|
-
function
|
|
940
|
+
function zt(n, e) {
|
|
941
941
|
return Object.keys(n).length === Object.keys(e).length && Object.keys(n).every(
|
|
942
942
|
(t) => e.hasOwnProperty(t) && n[t] === e[t]
|
|
943
943
|
);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
946
|
-
return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e :
|
|
947
|
-
(t) =>
|
|
945
|
+
function ze(n, e) {
|
|
946
|
+
return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : En(n, e) ? Object.keys(n).every(
|
|
947
|
+
(t) => ze(n[t], e[t])
|
|
948
948
|
) : !1;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function $t(n) {
|
|
951
951
|
if (!Ce(n))
|
|
952
952
|
return n;
|
|
953
953
|
const e = {};
|
|
@@ -955,7 +955,7 @@ function Pt(n) {
|
|
|
955
955
|
r !== void 0 && (e[t] = r);
|
|
956
956
|
return e;
|
|
957
957
|
}
|
|
958
|
-
function
|
|
958
|
+
function Mn(n, e) {
|
|
959
959
|
if (!Ce(n) || !Ce(e))
|
|
960
960
|
return e;
|
|
961
961
|
const t = { ...n };
|
|
@@ -966,14 +966,14 @@ function Cn(n, e) {
|
|
|
966
966
|
continue;
|
|
967
967
|
}
|
|
968
968
|
const s = Ce(n[r]) && Ce(e[r]);
|
|
969
|
-
t[r] = s ?
|
|
969
|
+
t[r] = s ? Mn(n[r], e[r]) : e[r];
|
|
970
970
|
}
|
|
971
971
|
return t;
|
|
972
972
|
}
|
|
973
973
|
function Ce(n) {
|
|
974
974
|
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
975
975
|
}
|
|
976
|
-
function
|
|
976
|
+
function Cr(n, e, t) {
|
|
977
977
|
if (!n || e.length === 0)
|
|
978
978
|
return;
|
|
979
979
|
let r = n || {};
|
|
@@ -984,7 +984,7 @@ function Or(n, e, t) {
|
|
|
984
984
|
const s = e[e.length - 1];
|
|
985
985
|
Array.isArray(r) && typeof s == "number" ? r.splice(s, 0, t) : r[s] = t;
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function Wt(n, e, t) {
|
|
988
988
|
if (!n || e.length === 0)
|
|
989
989
|
return;
|
|
990
990
|
let r = n || {};
|
|
@@ -994,7 +994,7 @@ function Kt(n, e, t) {
|
|
|
994
994
|
}
|
|
995
995
|
r[e[e.length - 1]] = t;
|
|
996
996
|
}
|
|
997
|
-
function
|
|
997
|
+
function Pn(n, e) {
|
|
998
998
|
if (!n || e.length === 0)
|
|
999
999
|
return;
|
|
1000
1000
|
const [t, ...r] = e;
|
|
@@ -1003,13 +1003,13 @@ function En(n, e) {
|
|
|
1003
1003
|
Array.isArray(n) ? n.splice(t, 1) : delete n[t];
|
|
1004
1004
|
return;
|
|
1005
1005
|
}
|
|
1006
|
-
|
|
1006
|
+
Pn(n[t], r), Er(n[t]) && delete n[t];
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
function
|
|
1009
|
+
function Er(n) {
|
|
1010
1010
|
return n && Object.keys(n).length === 0;
|
|
1011
1011
|
}
|
|
1012
|
-
const
|
|
1012
|
+
const Vt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, Mr = {
|
|
1013
1013
|
ZULU: 0,
|
|
1014
1014
|
YEKT: 18e3,
|
|
1015
1015
|
YEKST: 21600,
|
|
@@ -1205,32 +1205,32 @@ const zt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
|
|
|
1205
1205
|
ACSST: 37800,
|
|
1206
1206
|
ACDT: 37800
|
|
1207
1207
|
};
|
|
1208
|
-
function
|
|
1208
|
+
function Pr(n) {
|
|
1209
1209
|
return new Date(n);
|
|
1210
1210
|
}
|
|
1211
|
-
function
|
|
1211
|
+
function jr(n) {
|
|
1212
1212
|
return /* @__PURE__ */ new Date(n + "Z");
|
|
1213
1213
|
}
|
|
1214
|
-
const
|
|
1215
|
-
function
|
|
1216
|
-
const e = n.match(
|
|
1214
|
+
const $r = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
|
|
1215
|
+
function xr(n) {
|
|
1216
|
+
const e = n.match($r);
|
|
1217
1217
|
if (!e)
|
|
1218
1218
|
return null;
|
|
1219
1219
|
const [t, r, s, i] = e;
|
|
1220
1220
|
return r <= 0 || s <= 0 || i <= 0 ? null : r > 999 ? new Date(Date.UTC(r, s - 1, i, 0, 0, 0, 0)) : new Date(Date.UTC(i, r - 1, s, 0, 0, 0, 0));
|
|
1221
1221
|
}
|
|
1222
|
-
function
|
|
1222
|
+
function Rr(n) {
|
|
1223
1223
|
const [e, t] = n.split(" ");
|
|
1224
1224
|
return /* @__PURE__ */ new Date(e + "T" + t + "Z");
|
|
1225
1225
|
}
|
|
1226
|
-
function
|
|
1226
|
+
function Dr(n) {
|
|
1227
1227
|
const [e, t] = n.split(" ");
|
|
1228
1228
|
return /* @__PURE__ */ new Date(e + "T" + t + "Z");
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1230
|
+
function Ur(n) {
|
|
1231
1231
|
return new Date(n);
|
|
1232
1232
|
}
|
|
1233
|
-
function
|
|
1233
|
+
function Lr(n) {
|
|
1234
1234
|
const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
|
|
1235
1235
|
if (!n.match(e))
|
|
1236
1236
|
throw new Error(`Unable to parse \`${n}\` as a date.`);
|
|
@@ -1247,7 +1247,7 @@ function Dr(n) {
|
|
|
1247
1247
|
)
|
|
1248
1248
|
);
|
|
1249
1249
|
}
|
|
1250
|
-
function
|
|
1250
|
+
function Nr(n) {
|
|
1251
1251
|
const e = /^(.+T.+)([+-])(\d{2})$/, t = n.match(e);
|
|
1252
1252
|
if (t) {
|
|
1253
1253
|
const [, r, s, i] = t, o = `${r}${s}${i}:00`;
|
|
@@ -1255,7 +1255,7 @@ function Ur(n) {
|
|
|
1255
1255
|
}
|
|
1256
1256
|
return null;
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1258
|
+
function Fr(n) {
|
|
1259
1259
|
const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, t = n.match(e);
|
|
1260
1260
|
if (t) {
|
|
1261
1261
|
const [, r, s, i, o, a] = t, c = s.padStart(2, "0"), u = i.padStart(2, "0"), l = `${r}-${c}-${u}T${a}`;
|
|
@@ -1263,14 +1263,14 @@ function Lr(n) {
|
|
|
1263
1263
|
}
|
|
1264
1264
|
return null;
|
|
1265
1265
|
}
|
|
1266
|
-
function
|
|
1266
|
+
function Kr(n) {
|
|
1267
1267
|
const [e, t] = n.split(", "), [r, s, i] = e.split("/").map(Number), o = t.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
|
|
1268
1268
|
if (!o)
|
|
1269
1269
|
throw new Error(`Unable to parse time from: ${n}`);
|
|
1270
1270
|
let [, a, c, u, l] = o;
|
|
1271
1271
|
return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
|
|
1272
1272
|
}
|
|
1273
|
-
function
|
|
1273
|
+
function qr(n) {
|
|
1274
1274
|
switch (n) {
|
|
1275
1275
|
case "epoch":
|
|
1276
1276
|
return /* @__PURE__ */ new Date(0);
|
|
@@ -1284,28 +1284,28 @@ function Fr(n) {
|
|
|
1284
1284
|
return null;
|
|
1285
1285
|
}
|
|
1286
1286
|
}
|
|
1287
|
-
function
|
|
1288
|
-
const e = n.match(
|
|
1287
|
+
function zr(n) {
|
|
1288
|
+
const e = n.match(Vt);
|
|
1289
1289
|
if (!e)
|
|
1290
1290
|
return null;
|
|
1291
|
-
const [t] = e, r =
|
|
1291
|
+
const [t] = e, r = Mr[t], s = new Date(n.replace(Vt, "Z"));
|
|
1292
1292
|
return new Date(s.getTime() - r * 1e3);
|
|
1293
1293
|
}
|
|
1294
|
-
const
|
|
1295
|
-
jr,
|
|
1294
|
+
const Wr = [
|
|
1296
1295
|
xr,
|
|
1297
1296
|
Dr,
|
|
1297
|
+
Lr,
|
|
1298
|
+
Kr,
|
|
1299
|
+
Ur,
|
|
1300
|
+
jr,
|
|
1298
1301
|
Nr,
|
|
1299
1302
|
Rr,
|
|
1300
|
-
|
|
1301
|
-
Ur,
|
|
1302
|
-
$r,
|
|
1303
|
-
Er,
|
|
1304
|
-
Fr,
|
|
1303
|
+
Pr,
|
|
1305
1304
|
qr,
|
|
1306
|
-
|
|
1305
|
+
zr,
|
|
1306
|
+
Fr
|
|
1307
1307
|
];
|
|
1308
|
-
function
|
|
1308
|
+
function Vr(n, e) {
|
|
1309
1309
|
try {
|
|
1310
1310
|
const t = n(e);
|
|
1311
1311
|
return t instanceof Date && !isNaN(t.getTime()) ? t : null;
|
|
@@ -1313,30 +1313,30 @@ function zr(n, e) {
|
|
|
1313
1313
|
return null;
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
|
-
function
|
|
1317
|
-
for (const e of
|
|
1318
|
-
const t =
|
|
1316
|
+
function ht(n) {
|
|
1317
|
+
for (const e of Wr) {
|
|
1318
|
+
const t = Vr(e, n);
|
|
1319
1319
|
if (t)
|
|
1320
1320
|
return t;
|
|
1321
1321
|
}
|
|
1322
1322
|
return null;
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1324
|
+
function Qr(n) {
|
|
1325
1325
|
try {
|
|
1326
1326
|
const e = JSON.parse(n);
|
|
1327
|
-
return typeof e == "string" ?
|
|
1327
|
+
return typeof e == "string" ? ht(e) : null;
|
|
1328
1328
|
} catch {
|
|
1329
1329
|
return null;
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
1332
|
-
function
|
|
1332
|
+
function Je(n) {
|
|
1333
1333
|
if (n !== void 0) {
|
|
1334
1334
|
if (n === null)
|
|
1335
1335
|
return null;
|
|
1336
1336
|
if (n instanceof Date)
|
|
1337
1337
|
return n;
|
|
1338
1338
|
if (typeof n == "string") {
|
|
1339
|
-
const e =
|
|
1339
|
+
const e = ht(n) || Qr(n) || ht(n.trim());
|
|
1340
1340
|
if (!e)
|
|
1341
1341
|
throw new Error(`Unable to parse \`${n}\` as a date.`);
|
|
1342
1342
|
return e;
|
|
@@ -1378,7 +1378,7 @@ class le {
|
|
|
1378
1378
|
return this._blobAttrs;
|
|
1379
1379
|
this._blobAttrs = /* @__PURE__ */ new Map();
|
|
1380
1380
|
for (const e of Object.values(this.attrs))
|
|
1381
|
-
if (
|
|
1381
|
+
if (Rt(e)) {
|
|
1382
1382
|
const [t, r, s] = e["forward-identity"];
|
|
1383
1383
|
Q(this.blobAttrs, [r, s], e);
|
|
1384
1384
|
}
|
|
@@ -1422,13 +1422,13 @@ class le {
|
|
|
1422
1422
|
return { attrs: this.attrs, linkIndex: this.linkIndex };
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
|
-
function
|
|
1425
|
+
function Br(n) {
|
|
1426
1426
|
return n.cardinality === "one";
|
|
1427
1427
|
}
|
|
1428
|
-
function
|
|
1428
|
+
function xt(n) {
|
|
1429
1429
|
return n["value-type"] === "ref";
|
|
1430
1430
|
}
|
|
1431
|
-
function
|
|
1431
|
+
function Rt(n) {
|
|
1432
1432
|
return n["value-type"] === "blob";
|
|
1433
1433
|
}
|
|
1434
1434
|
function Ae(n, e) {
|
|
@@ -1453,7 +1453,7 @@ function Q(n, e, t) {
|
|
|
1453
1453
|
}
|
|
1454
1454
|
s > -1 && r.set(e[s], t);
|
|
1455
1455
|
}
|
|
1456
|
-
function
|
|
1456
|
+
function jn(n, e, t) {
|
|
1457
1457
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
1458
1458
|
for (const o of e) {
|
|
1459
1459
|
let [a, c, u] = o;
|
|
@@ -1462,11 +1462,11 @@ function Mn(n, e, t) {
|
|
|
1462
1462
|
console.warn("no such attr", c, a);
|
|
1463
1463
|
continue;
|
|
1464
1464
|
}
|
|
1465
|
-
l["checked-data-type"] === "date" && t && (u =
|
|
1465
|
+
l["checked-data-type"] === "date" && t && (u = Je(u), o[2] = u), xt(l) && Q(i, [u, c, a], o), Q(r, [a, c, u], o), Q(s, [c, a, u], o);
|
|
1466
1466
|
}
|
|
1467
1467
|
return { eav: r, aev: s, vae: i };
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function $n(n) {
|
|
1470
1470
|
return {
|
|
1471
1471
|
triples: B(n.eav, 3),
|
|
1472
1472
|
cardinalityInference: n.cardinalityInference,
|
|
@@ -1474,7 +1474,7 @@ function Pn(n) {
|
|
|
1474
1474
|
version: 1
|
|
1475
1475
|
};
|
|
1476
1476
|
}
|
|
1477
|
-
function
|
|
1477
|
+
function xn(n, e) {
|
|
1478
1478
|
return we(
|
|
1479
1479
|
n,
|
|
1480
1480
|
e.triples,
|
|
@@ -1482,17 +1482,17 @@ function jn(n, e) {
|
|
|
1482
1482
|
e.useDateObjects
|
|
1483
1483
|
);
|
|
1484
1484
|
}
|
|
1485
|
-
function
|
|
1485
|
+
function Rn(n, e) {
|
|
1486
1486
|
if (n)
|
|
1487
1487
|
return new le(n.attrs, n.linkIndex);
|
|
1488
1488
|
if (e && "__type" in e)
|
|
1489
1489
|
return new le(e.attrs, e.linkIndex);
|
|
1490
1490
|
}
|
|
1491
|
-
function
|
|
1491
|
+
function Gr(n, e) {
|
|
1492
1492
|
return Ae(n.eav, [e]) !== void 0;
|
|
1493
1493
|
}
|
|
1494
1494
|
function we(n, e, t, r) {
|
|
1495
|
-
const s =
|
|
1495
|
+
const s = jn(
|
|
1496
1496
|
n,
|
|
1497
1497
|
e,
|
|
1498
1498
|
r
|
|
@@ -1525,21 +1525,21 @@ function xe(n, e) {
|
|
|
1525
1525
|
return [t, ...i];
|
|
1526
1526
|
}
|
|
1527
1527
|
}
|
|
1528
|
-
function
|
|
1528
|
+
function Dn(n, e, t) {
|
|
1529
1529
|
const r = xe(n, t);
|
|
1530
1530
|
if (!r)
|
|
1531
1531
|
return;
|
|
1532
1532
|
const [s, i, o] = r, a = e.getAttr(i);
|
|
1533
|
-
a && (ne(n.eav, [s, i, o]), ne(n.aev, [i, s, o]),
|
|
1533
|
+
a && (ne(n.eav, [s, i, o]), ne(n.aev, [i, s, o]), xt(a) && ne(n.vae, [o, i, s]));
|
|
1534
1534
|
}
|
|
1535
|
-
let
|
|
1536
|
-
function
|
|
1535
|
+
let Hr = 0;
|
|
1536
|
+
function Un(n, e, t) {
|
|
1537
1537
|
const [r, s, i] = t;
|
|
1538
1538
|
let o;
|
|
1539
1539
|
const a = Ae(n.eav, [r, s, i]);
|
|
1540
|
-
return a && (o = a[3]), o || Date.now() * 10 +
|
|
1540
|
+
return a && (o = a[3]), o || Date.now() * 10 + Hr++;
|
|
1541
1541
|
}
|
|
1542
|
-
function
|
|
1542
|
+
function Ln(n, e, t) {
|
|
1543
1543
|
const r = xe(n, t);
|
|
1544
1544
|
if (!r)
|
|
1545
1545
|
return;
|
|
@@ -1547,31 +1547,31 @@ function Dn(n, e, t) {
|
|
|
1547
1547
|
const a = e.getAttr(i);
|
|
1548
1548
|
if (!a)
|
|
1549
1549
|
return;
|
|
1550
|
-
a["checked-data-type"] === "date" && n.useDateObjects && (o =
|
|
1551
|
-
const u = Ae(n.eav, [s, i, o])?.[3] ??
|
|
1552
|
-
|
|
1550
|
+
a["checked-data-type"] === "date" && n.useDateObjects && (o = Je(o));
|
|
1551
|
+
const u = Ae(n.eav, [s, i, o])?.[3] ?? Un(n, a, r), l = [s, i, o, u];
|
|
1552
|
+
Br(a) ? (Q(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), Q(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (Q(n.eav, [s, i, o], l), Q(n.aev, [i, s, o], l)), xt(a) && Q(n.vae, [o, i, s], l);
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function Jr(n, e, t) {
|
|
1555
1555
|
const r = xe(n, t);
|
|
1556
1556
|
if (!r)
|
|
1557
1557
|
return;
|
|
1558
1558
|
const [s, i, o] = r, a = e.getAttr(i);
|
|
1559
1559
|
if (!a) return;
|
|
1560
|
-
if (
|
|
1560
|
+
if (!Rt(a))
|
|
1561
1561
|
throw new Error("merge operation is not supported for links");
|
|
1562
1562
|
const c = Ae(n.eav, [s, i]);
|
|
1563
1563
|
if (!c) return;
|
|
1564
1564
|
const u = c.values().next()?.value;
|
|
1565
1565
|
if (!u) return;
|
|
1566
|
-
const l = u[2], f =
|
|
1566
|
+
const l = u[2], f = Mn(l, o), d = [
|
|
1567
1567
|
s,
|
|
1568
1568
|
i,
|
|
1569
1569
|
f,
|
|
1570
|
-
|
|
1570
|
+
Un(n, a, u)
|
|
1571
1571
|
];
|
|
1572
1572
|
Q(n.eav, [s, i], /* @__PURE__ */ new Map([[f, d]])), Q(n.aev, [i, s], /* @__PURE__ */ new Map([[f, d]]));
|
|
1573
1573
|
}
|
|
1574
|
-
function
|
|
1574
|
+
function pt(n, e, t) {
|
|
1575
1575
|
const [r, s] = t, i = xe(n, [r]);
|
|
1576
1576
|
if (!i)
|
|
1577
1577
|
return;
|
|
@@ -1580,7 +1580,7 @@ function ft(n, e, t) {
|
|
|
1580
1580
|
for (const u of a.keys()) {
|
|
1581
1581
|
const l = e.getAttr(u);
|
|
1582
1582
|
l && l["on-delete-reverse"] === "cascade" && B(a.get(u), 1).forEach(
|
|
1583
|
-
([f, d, h]) =>
|
|
1583
|
+
([f, d, h]) => pt(n, e, [h, l["reverse-identity"]?.[1]])
|
|
1584
1584
|
), // Fall back to deleting everything if we've rehydrated tx-steps from
|
|
1585
1585
|
// the store that didn't set `etype` in deleteEntity
|
|
1586
1586
|
(!s || // If we don't know about the attr, let's just get rid of it
|
|
@@ -1592,11 +1592,11 @@ function ft(n, e, t) {
|
|
|
1592
1592
|
const c = n.vae.get(o) && B(n.vae.get(o), 2);
|
|
1593
1593
|
c && c.forEach((u) => {
|
|
1594
1594
|
const [l, f, d] = u, h = e.getAttr(f);
|
|
1595
|
-
(!s || !h || h["reverse-identity"]?.[1] === s) && (ne(n.eav, [l, f, d]), ne(n.aev, [f, l, d]), ne(n.vae, [d, f, l])), h && h["on-delete"] === "cascade" && h["reverse-identity"]?.[1] === s &&
|
|
1595
|
+
(!s || !h || h["reverse-identity"]?.[1] === s) && (ne(n.eav, [l, f, d]), ne(n.aev, [f, l, d]), ne(n.vae, [d, f, l])), h && h["on-delete"] === "cascade" && h["reverse-identity"]?.[1] === s && pt(n, e, [l, h["forward-identity"]?.[1]]);
|
|
1596
1596
|
}), n.vae.get(o)?.size === 0 && ne(n.vae, [o]);
|
|
1597
1597
|
}
|
|
1598
|
-
function
|
|
1599
|
-
const r =
|
|
1598
|
+
function Nn(n, e, t) {
|
|
1599
|
+
const r = jn(
|
|
1600
1600
|
e,
|
|
1601
1601
|
t,
|
|
1602
1602
|
n.useDateObjects
|
|
@@ -1605,43 +1605,43 @@ function Un(n, e, t) {
|
|
|
1605
1605
|
n[s] = r[s];
|
|
1606
1606
|
});
|
|
1607
1607
|
}
|
|
1608
|
-
function
|
|
1608
|
+
function Yr(n, [e]) {
|
|
1609
1609
|
n.addAttr(e);
|
|
1610
1610
|
}
|
|
1611
|
-
function
|
|
1611
|
+
function Fn(n) {
|
|
1612
1612
|
return B(n.eav, 3);
|
|
1613
1613
|
}
|
|
1614
|
-
function
|
|
1614
|
+
function Zr(n, e, [t]) {
|
|
1615
1615
|
if (!e.getAttr(t)) return;
|
|
1616
|
-
const r =
|
|
1617
|
-
e.deleteAttr(t),
|
|
1616
|
+
const r = Fn(n).filter(([s, i]) => i !== t);
|
|
1617
|
+
e.deleteAttr(t), Nn(n, e, r);
|
|
1618
1618
|
}
|
|
1619
|
-
function
|
|
1620
|
-
e.getAttr(t.id) && (e.updateAttr(t),
|
|
1619
|
+
function Xr(n, e, [t]) {
|
|
1620
|
+
e.getAttr(t.id) && (e.updateAttr(t), Nn(n, e, Fn(n)));
|
|
1621
1621
|
}
|
|
1622
|
-
function
|
|
1622
|
+
function es(n, e, t) {
|
|
1623
1623
|
const [r, ...s] = t;
|
|
1624
1624
|
switch (r) {
|
|
1625
1625
|
case "add-triple":
|
|
1626
|
-
|
|
1626
|
+
Ln(n, e, s);
|
|
1627
1627
|
break;
|
|
1628
1628
|
case "deep-merge-triple":
|
|
1629
|
-
|
|
1629
|
+
Jr(n, e, s);
|
|
1630
1630
|
break;
|
|
1631
1631
|
case "retract-triple":
|
|
1632
|
-
|
|
1632
|
+
Dn(n, e, s);
|
|
1633
1633
|
break;
|
|
1634
1634
|
case "delete-entity":
|
|
1635
|
-
|
|
1635
|
+
pt(n, e, s);
|
|
1636
1636
|
break;
|
|
1637
1637
|
case "add-attr":
|
|
1638
|
-
|
|
1638
|
+
Yr(e, s);
|
|
1639
1639
|
break;
|
|
1640
1640
|
case "delete-attr":
|
|
1641
|
-
|
|
1641
|
+
Zr(n, e, s);
|
|
1642
1642
|
break;
|
|
1643
1643
|
case "update-attr":
|
|
1644
|
-
|
|
1644
|
+
Xr(n, e, s);
|
|
1645
1645
|
break;
|
|
1646
1646
|
case "restore-attr":
|
|
1647
1647
|
break;
|
|
@@ -1695,12 +1695,12 @@ function De(n, e, t) {
|
|
|
1695
1695
|
}
|
|
1696
1696
|
return r;
|
|
1697
1697
|
}
|
|
1698
|
-
function
|
|
1698
|
+
function ts(n, e, t) {
|
|
1699
1699
|
let r = "";
|
|
1700
1700
|
return n !== void 0 && (r += "e"), e !== void 0 && (r += "a"), t !== void 0 && (r += "v"), r;
|
|
1701
1701
|
}
|
|
1702
|
-
function
|
|
1703
|
-
switch (
|
|
1702
|
+
function ns(n, [e, t, r]) {
|
|
1703
|
+
switch (ts(e, t, r)) {
|
|
1704
1704
|
case "e": {
|
|
1705
1705
|
const i = n.eav.get(e);
|
|
1706
1706
|
return B(i, 2);
|
|
@@ -1746,7 +1746,7 @@ function es(n, [e, t, r]) {
|
|
|
1746
1746
|
return B(n.eav, 3);
|
|
1747
1747
|
}
|
|
1748
1748
|
}
|
|
1749
|
-
function
|
|
1749
|
+
function rs(n, e, t) {
|
|
1750
1750
|
const r = {};
|
|
1751
1751
|
if (!e)
|
|
1752
1752
|
return r;
|
|
@@ -1763,14 +1763,14 @@ function U(n, e, t) {
|
|
|
1763
1763
|
function ye(n, e, t) {
|
|
1764
1764
|
return n.revIdents.get(e)?.get(t);
|
|
1765
1765
|
}
|
|
1766
|
-
function
|
|
1766
|
+
function ss(n, e) {
|
|
1767
1767
|
return n.blobAttrs.get(e);
|
|
1768
1768
|
}
|
|
1769
|
-
function
|
|
1769
|
+
function Kn(n, e) {
|
|
1770
1770
|
const t = n.primaryKeys.get(e);
|
|
1771
1771
|
return t || n.forwardIdents.get(e)?.get("id");
|
|
1772
1772
|
}
|
|
1773
|
-
function
|
|
1773
|
+
function is(n, e, t) {
|
|
1774
1774
|
const r = xe(n, t);
|
|
1775
1775
|
if (!r)
|
|
1776
1776
|
return;
|
|
@@ -1778,7 +1778,7 @@ function rs(n, e, t) {
|
|
|
1778
1778
|
if (e.getAttr(i))
|
|
1779
1779
|
return Ae(n.eav, [s, i]);
|
|
1780
1780
|
}
|
|
1781
|
-
function
|
|
1781
|
+
function os(n, e, t) {
|
|
1782
1782
|
const r = t.filter(
|
|
1783
1783
|
([s, i, o, a, c]) => {
|
|
1784
1784
|
if (s !== "add-triple" && s !== "deep-merge-triple")
|
|
@@ -1789,11 +1789,11 @@ function ss(n, e, t) {
|
|
|
1789
1789
|
let l = !1;
|
|
1790
1790
|
const f = e.getAttr(o);
|
|
1791
1791
|
if (f) {
|
|
1792
|
-
const d =
|
|
1792
|
+
const d = Kn(
|
|
1793
1793
|
e,
|
|
1794
1794
|
f["forward-identity"][1]
|
|
1795
1795
|
);
|
|
1796
|
-
l = !!
|
|
1796
|
+
l = !!is(n, e, [
|
|
1797
1797
|
i,
|
|
1798
1798
|
d?.id,
|
|
1799
1799
|
i
|
|
@@ -1802,11 +1802,11 @@ function ss(n, e, t) {
|
|
|
1802
1802
|
return !(u === "create" && l || u === "update" && !l);
|
|
1803
1803
|
}
|
|
1804
1804
|
);
|
|
1805
|
-
return
|
|
1805
|
+
return Be(
|
|
1806
1806
|
{ store: n, attrsStore: e },
|
|
1807
1807
|
(s) => {
|
|
1808
1808
|
r.forEach((i) => {
|
|
1809
|
-
|
|
1809
|
+
es(s.store, s.attrsStore, i);
|
|
1810
1810
|
});
|
|
1811
1811
|
},
|
|
1812
1812
|
{
|
|
@@ -1817,23 +1817,23 @@ function ss(n, e, t) {
|
|
|
1817
1817
|
}
|
|
1818
1818
|
);
|
|
1819
1819
|
}
|
|
1820
|
-
function
|
|
1820
|
+
function as(n) {
|
|
1821
1821
|
return typeof n == "string" && n.startsWith("?");
|
|
1822
1822
|
}
|
|
1823
|
-
function
|
|
1823
|
+
function cs(n, e, t) {
|
|
1824
1824
|
if (t.hasOwnProperty(n)) {
|
|
1825
1825
|
const r = t[n];
|
|
1826
|
-
return
|
|
1826
|
+
return qn(r, e, t);
|
|
1827
1827
|
}
|
|
1828
1828
|
return { ...t, [n]: e };
|
|
1829
1829
|
}
|
|
1830
|
-
function
|
|
1830
|
+
function Qt(n, e, t) {
|
|
1831
1831
|
return n === e ? t : null;
|
|
1832
1832
|
}
|
|
1833
|
-
function
|
|
1834
|
-
return typeof n === "string" && n.startsWith("?") ?
|
|
1833
|
+
function us(n) {
|
|
1834
|
+
return typeof n === "string" && n.startsWith("?") ? cs : Qt;
|
|
1835
1835
|
}
|
|
1836
|
-
const
|
|
1836
|
+
const ls = [
|
|
1837
1837
|
"in",
|
|
1838
1838
|
"$in",
|
|
1839
1839
|
"$not",
|
|
@@ -1841,93 +1841,93 @@ const cs = [
|
|
|
1841
1841
|
"$comparator"
|
|
1842
1842
|
// covers all of $gt, $lt, etc.
|
|
1843
1843
|
];
|
|
1844
|
-
function
|
|
1845
|
-
for (const e of
|
|
1844
|
+
function ds(n) {
|
|
1845
|
+
for (const e of ls)
|
|
1846
1846
|
if (n.hasOwnProperty(e))
|
|
1847
1847
|
return !0;
|
|
1848
1848
|
return !1;
|
|
1849
1849
|
}
|
|
1850
|
-
function
|
|
1851
|
-
return t ? typeof n == "object" ?
|
|
1850
|
+
function qn(n, e, t) {
|
|
1851
|
+
return t ? typeof n == "object" ? ds(n) ? t : null : us(n)(n, e, t) : null;
|
|
1852
1852
|
}
|
|
1853
|
-
function
|
|
1853
|
+
function fs(n, e, t) {
|
|
1854
1854
|
return n.reduce((r, s, i) => {
|
|
1855
1855
|
const o = e[i];
|
|
1856
|
-
return
|
|
1856
|
+
return qn(s, o, r);
|
|
1857
1857
|
}, t);
|
|
1858
1858
|
}
|
|
1859
|
-
function
|
|
1860
|
-
return
|
|
1859
|
+
function hs(n, e, t) {
|
|
1860
|
+
return bs(n, e, t).map((r) => fs(e, r, t)).filter((r) => r);
|
|
1861
1861
|
}
|
|
1862
|
-
function
|
|
1863
|
-
return e.or ? e.or.patterns.flatMap((r) =>
|
|
1862
|
+
function ps(n, e, t) {
|
|
1863
|
+
return e.or ? e.or.patterns.flatMap((r) => yt(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => yt(n, s, r), t) : t.flatMap((r) => hs(n, e, r));
|
|
1864
1864
|
}
|
|
1865
|
-
function
|
|
1866
|
-
return e.reduce((r, s) =>
|
|
1865
|
+
function yt(n, e, t = [{}]) {
|
|
1866
|
+
return e.reduce((r, s) => ps(n, s, r), t);
|
|
1867
1867
|
}
|
|
1868
|
-
function
|
|
1869
|
-
return Array.isArray(e) ? e.map((t) =>
|
|
1868
|
+
function Dt(n, e) {
|
|
1869
|
+
return Array.isArray(e) ? e.map((t) => Dt(n, t)) : as(e) ? n[e] : e;
|
|
1870
1870
|
}
|
|
1871
|
-
function
|
|
1872
|
-
return
|
|
1871
|
+
function ys(n, { find: e, where: t }) {
|
|
1872
|
+
return yt(n, t).map((s) => Dt(s, e));
|
|
1873
1873
|
}
|
|
1874
|
-
function
|
|
1875
|
-
return
|
|
1874
|
+
function bs(n, e, t) {
|
|
1875
|
+
return ns(n, Dt(t, e));
|
|
1876
1876
|
}
|
|
1877
|
-
const
|
|
1877
|
+
const gs = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
1878
1878
|
function Te(n) {
|
|
1879
|
-
return typeof n == "string" &&
|
|
1879
|
+
return typeof n == "string" && gs.test(n);
|
|
1880
1880
|
}
|
|
1881
1881
|
const F = [];
|
|
1882
1882
|
for (let n = 0; n < 256; ++n)
|
|
1883
1883
|
F.push((n + 256).toString(16).slice(1));
|
|
1884
|
-
function
|
|
1884
|
+
function ms(n, e = 0) {
|
|
1885
1885
|
return (F[n[e + 0]] + F[n[e + 1]] + F[n[e + 2]] + F[n[e + 3]] + "-" + F[n[e + 4]] + F[n[e + 5]] + "-" + F[n[e + 6]] + F[n[e + 7]] + "-" + F[n[e + 8]] + F[n[e + 9]] + "-" + F[n[e + 10]] + F[n[e + 11]] + F[n[e + 12]] + F[n[e + 13]] + F[n[e + 14]] + F[n[e + 15]]).toLowerCase();
|
|
1886
1886
|
}
|
|
1887
|
-
let
|
|
1888
|
-
const
|
|
1889
|
-
function
|
|
1890
|
-
if (!
|
|
1887
|
+
let nt;
|
|
1888
|
+
const ws = new Uint8Array(16);
|
|
1889
|
+
function _s() {
|
|
1890
|
+
if (!nt) {
|
|
1891
1891
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1892
1892
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1893
|
-
|
|
1893
|
+
nt = crypto.getRandomValues.bind(crypto);
|
|
1894
1894
|
}
|
|
1895
|
-
return
|
|
1895
|
+
return nt(ws);
|
|
1896
1896
|
}
|
|
1897
|
-
const
|
|
1898
|
-
function
|
|
1899
|
-
if (
|
|
1900
|
-
return
|
|
1897
|
+
const Ss = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Bt = { randomUUID: Ss };
|
|
1898
|
+
function Ts(n, e, t) {
|
|
1899
|
+
if (Bt.randomUUID && !n)
|
|
1900
|
+
return Bt.randomUUID();
|
|
1901
1901
|
n = n || {};
|
|
1902
|
-
const r = n.random ?? n.rng?.() ??
|
|
1902
|
+
const r = n.random ?? n.rng?.() ?? _s();
|
|
1903
1903
|
if (r.length < 16)
|
|
1904
1904
|
throw new Error("Random bytes length must be >= 16");
|
|
1905
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
1905
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, ms(r);
|
|
1906
1906
|
}
|
|
1907
|
-
function
|
|
1907
|
+
function Gt(n) {
|
|
1908
1908
|
const e = n.replace(/-/g, ""), t = [];
|
|
1909
1909
|
for (let r = 0; r < e.length; r += 2)
|
|
1910
1910
|
t.push(parseInt(e.substring(r, r + 2), 16));
|
|
1911
1911
|
return t;
|
|
1912
1912
|
}
|
|
1913
|
-
function
|
|
1913
|
+
function vs(n, e) {
|
|
1914
1914
|
for (let t = 0; t < n.length; t++) {
|
|
1915
1915
|
if (n[t] < e[t]) return -1;
|
|
1916
1916
|
if (n[t] > e[t]) return 1;
|
|
1917
1917
|
}
|
|
1918
1918
|
return 0;
|
|
1919
1919
|
}
|
|
1920
|
-
function
|
|
1921
|
-
return
|
|
1920
|
+
function As(n, e) {
|
|
1921
|
+
return vs(Gt(n), Gt(e));
|
|
1922
1922
|
}
|
|
1923
1923
|
function j() {
|
|
1924
|
-
return
|
|
1924
|
+
return Ts();
|
|
1925
1925
|
}
|
|
1926
|
-
function
|
|
1926
|
+
function ks(n, e) {
|
|
1927
1927
|
return n.localeCompare(e);
|
|
1928
1928
|
}
|
|
1929
|
-
function
|
|
1930
|
-
let n =
|
|
1929
|
+
function Os() {
|
|
1930
|
+
let n = ks;
|
|
1931
1931
|
if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
|
|
1932
1932
|
try {
|
|
1933
1933
|
n = Intl.Collator("en-US").compare;
|
|
@@ -1935,16 +1935,16 @@ function As() {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
return n;
|
|
1937
1937
|
}
|
|
1938
|
-
const
|
|
1939
|
-
let
|
|
1940
|
-
const
|
|
1941
|
-
|
|
1938
|
+
const Is = Os();
|
|
1939
|
+
let zn = !0;
|
|
1940
|
+
const ya = (n) => {
|
|
1941
|
+
zn = n;
|
|
1942
1942
|
};
|
|
1943
|
-
let
|
|
1943
|
+
let Cs = 0;
|
|
1944
1944
|
function Pe(n) {
|
|
1945
|
-
return
|
|
1945
|
+
return Ye(`_${n}`, Cs++);
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1947
|
+
function Ye(n, e) {
|
|
1948
1948
|
return `?${n}-${e}`;
|
|
1949
1949
|
}
|
|
1950
1950
|
class ve extends Error {
|
|
@@ -1952,27 +1952,27 @@ class ve extends Error {
|
|
|
1952
1952
|
super(e), this.name = "AttrNotFoundError";
|
|
1953
1953
|
}
|
|
1954
1954
|
}
|
|
1955
|
-
function
|
|
1956
|
-
const t =
|
|
1955
|
+
function Es(n, e) {
|
|
1956
|
+
const t = Kn(n, e);
|
|
1957
1957
|
if (!t)
|
|
1958
1958
|
throw new ve(`Could not find id attr for ${e}`);
|
|
1959
1959
|
return t;
|
|
1960
1960
|
}
|
|
1961
|
-
function
|
|
1962
|
-
return [
|
|
1961
|
+
function Ht(n, e, t, r) {
|
|
1962
|
+
return [Ms(n, e, t, r)];
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1964
|
+
function Ms(n, e, t, r) {
|
|
1965
1965
|
return [
|
|
1966
1966
|
n(t, r),
|
|
1967
|
-
|
|
1967
|
+
Es(e, t).id,
|
|
1968
1968
|
n(t, r),
|
|
1969
1969
|
n("time", r)
|
|
1970
1970
|
];
|
|
1971
1971
|
}
|
|
1972
|
-
function
|
|
1972
|
+
function Ps(n, e, t) {
|
|
1973
1973
|
return n.map((r) => r === e ? t : r);
|
|
1974
1974
|
}
|
|
1975
|
-
function
|
|
1975
|
+
function Wn(n, e, t, r, s) {
|
|
1976
1976
|
const i = U(e, t, s), o = ye(e, t, s), a = i || o;
|
|
1977
1977
|
if (!a)
|
|
1978
1978
|
throw new ve(`Could not find attr for ${[t, s]}`);
|
|
@@ -1991,7 +1991,7 @@ function Kn(n, e, t, r, s) {
|
|
|
1991
1991
|
];
|
|
1992
1992
|
return [i ? f : u, d, h, a, !!i];
|
|
1993
1993
|
}
|
|
1994
|
-
function
|
|
1994
|
+
function Jt(n, e) {
|
|
1995
1995
|
if (typeof e != "string")
|
|
1996
1996
|
return function(o) {
|
|
1997
1997
|
return !1;
|
|
@@ -2004,7 +2004,7 @@ function Gt(n, e) {
|
|
|
2004
2004
|
return typeof o != "string" ? !1 : s.test(o);
|
|
2005
2005
|
};
|
|
2006
2006
|
}
|
|
2007
|
-
function
|
|
2007
|
+
function js(n, e) {
|
|
2008
2008
|
if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
|
|
2009
2009
|
return e;
|
|
2010
2010
|
const t = n["checked-data-type"] === "date";
|
|
@@ -2045,7 +2045,7 @@ function Ms(n, e) {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
};
|
|
2047
2047
|
if (e.hasOwnProperty("$like")) {
|
|
2048
|
-
const r =
|
|
2048
|
+
const r = Jt(!0, e.$like);
|
|
2049
2049
|
return {
|
|
2050
2050
|
$comparator: !0,
|
|
2051
2051
|
$op: function(i) {
|
|
@@ -2054,7 +2054,7 @@ function Ms(n, e) {
|
|
|
2054
2054
|
};
|
|
2055
2055
|
}
|
|
2056
2056
|
if (e.hasOwnProperty("$ilike")) {
|
|
2057
|
-
const r =
|
|
2057
|
+
const r = Jt(!1, e.$ilike);
|
|
2058
2058
|
return {
|
|
2059
2059
|
$comparator: !0,
|
|
2060
2060
|
$op: function(i) {
|
|
@@ -2064,7 +2064,7 @@ function Ms(n, e) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
return e;
|
|
2066
2066
|
}
|
|
2067
|
-
function
|
|
2067
|
+
function $s(n, e, t, r, s, i) {
|
|
2068
2068
|
const o = U(e, t, s), a = ye(
|
|
2069
2069
|
e,
|
|
2070
2070
|
t,
|
|
@@ -2090,14 +2090,14 @@ function Ps(n, e, t, r, s, i) {
|
|
|
2090
2090
|
return o ? [
|
|
2091
2091
|
n(t, r),
|
|
2092
2092
|
c.id,
|
|
2093
|
-
|
|
2093
|
+
js(c, i),
|
|
2094
2094
|
Pe("time")
|
|
2095
2095
|
] : [i, c.id, n(t, r), Pe("time")];
|
|
2096
2096
|
}
|
|
2097
|
-
function
|
|
2097
|
+
function xs(n, e, t, r, s) {
|
|
2098
2098
|
const [i, o, a] = s.reduce(
|
|
2099
2099
|
(c, u) => {
|
|
2100
|
-
const [l, f, d] = c, [h, p, m] =
|
|
2100
|
+
const [l, f, d] = c, [h, p, m] = Wn(
|
|
2101
2101
|
n,
|
|
2102
2102
|
e,
|
|
2103
2103
|
l,
|
|
@@ -2110,14 +2110,14 @@ function js(n, e, t, r, s) {
|
|
|
2110
2110
|
);
|
|
2111
2111
|
return [i, o, a];
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2114
|
-
const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] =
|
|
2113
|
+
function bt(n, e, t, r, s, i) {
|
|
2114
|
+
const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = xs(
|
|
2115
2115
|
n,
|
|
2116
2116
|
e,
|
|
2117
2117
|
t,
|
|
2118
2118
|
r,
|
|
2119
2119
|
o
|
|
2120
|
-
), f =
|
|
2120
|
+
), f = $s(
|
|
2121
2121
|
n,
|
|
2122
2122
|
e,
|
|
2123
2123
|
c,
|
|
@@ -2127,59 +2127,59 @@ function pt(n, e, t, r, s, i) {
|
|
|
2127
2127
|
);
|
|
2128
2128
|
return l.concat([f]);
|
|
2129
2129
|
}
|
|
2130
|
-
function
|
|
2130
|
+
function Rs(n, e) {
|
|
2131
2131
|
return e ? [e].concat(n) : n;
|
|
2132
2132
|
}
|
|
2133
|
-
function
|
|
2133
|
+
function Ds([n, e]) {
|
|
2134
2134
|
return n === "or" && Array.isArray(e);
|
|
2135
2135
|
}
|
|
2136
|
-
function
|
|
2136
|
+
function Us([n, e]) {
|
|
2137
2137
|
return n === "and" && Array.isArray(e);
|
|
2138
2138
|
}
|
|
2139
|
-
function
|
|
2139
|
+
function Ls(n, e, t) {
|
|
2140
2140
|
return (r, s) => {
|
|
2141
2141
|
const i = n(r, s);
|
|
2142
2142
|
return e == i ? i : `${i}-${t}`;
|
|
2143
2143
|
};
|
|
2144
2144
|
}
|
|
2145
|
-
function
|
|
2145
|
+
function Yt(n, e, t, r, s, i) {
|
|
2146
2146
|
const o = n(r, s), a = i.map((c, u) => {
|
|
2147
|
-
const l =
|
|
2148
|
-
return
|
|
2147
|
+
const l = Ls(n, o, u);
|
|
2148
|
+
return Vn(l, t, r, s, c);
|
|
2149
2149
|
});
|
|
2150
2150
|
return { [e]: { patterns: a, joinSym: o } };
|
|
2151
2151
|
}
|
|
2152
|
-
function
|
|
2152
|
+
function Ns(n) {
|
|
2153
2153
|
const e = [];
|
|
2154
2154
|
for (let t = 1; t <= n.length; t++)
|
|
2155
2155
|
e.push(n.slice(0, t));
|
|
2156
2156
|
return e;
|
|
2157
2157
|
}
|
|
2158
|
-
function
|
|
2159
|
-
return
|
|
2160
|
-
(i) =>
|
|
2158
|
+
function Zt(n, e, t, r, s) {
|
|
2159
|
+
return Ns(s).map(
|
|
2160
|
+
(i) => bt(n, e, t, r, i, {
|
|
2161
2161
|
$isNull: !0
|
|
2162
2162
|
})
|
|
2163
2163
|
);
|
|
2164
2164
|
}
|
|
2165
|
-
function
|
|
2165
|
+
function Vn(n, e, t, r, s) {
|
|
2166
2166
|
return Object.entries(s).flatMap(([i, o]) => {
|
|
2167
|
-
if (
|
|
2168
|
-
return
|
|
2169
|
-
if (
|
|
2170
|
-
return
|
|
2167
|
+
if (Ds([i, o]))
|
|
2168
|
+
return Yt(n, "or", e, t, r, o);
|
|
2169
|
+
if (Us([i, o]))
|
|
2170
|
+
return Yt(n, "and", e, t, r, o);
|
|
2171
2171
|
if (i === "$entityIdStartsWith")
|
|
2172
2172
|
return [];
|
|
2173
2173
|
const a = i.split(".");
|
|
2174
2174
|
if (o?.hasOwnProperty("$ne") && (o = { ...o, $not: o.$ne }, delete o.$ne), o?.hasOwnProperty("$not")) {
|
|
2175
|
-
const c =
|
|
2175
|
+
const c = bt(
|
|
2176
2176
|
n,
|
|
2177
2177
|
e,
|
|
2178
2178
|
t,
|
|
2179
2179
|
r,
|
|
2180
2180
|
a,
|
|
2181
2181
|
o
|
|
2182
|
-
), u =
|
|
2182
|
+
), u = Zt(
|
|
2183
2183
|
n,
|
|
2184
2184
|
e,
|
|
2185
2185
|
t,
|
|
@@ -2198,7 +2198,7 @@ function zn(n, e, t, r, s) {
|
|
|
2198
2198
|
return o?.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
|
|
2199
2199
|
{
|
|
2200
2200
|
or: {
|
|
2201
|
-
patterns:
|
|
2201
|
+
patterns: Zt(
|
|
2202
2202
|
n,
|
|
2203
2203
|
e,
|
|
2204
2204
|
t,
|
|
@@ -2208,40 +2208,40 @@ function zn(n, e, t, r, s) {
|
|
|
2208
2208
|
joinSym: n(t, r)
|
|
2209
2209
|
}
|
|
2210
2210
|
}
|
|
2211
|
-
] :
|
|
2211
|
+
] : bt(n, e, t, r, a, o);
|
|
2212
2212
|
});
|
|
2213
2213
|
}
|
|
2214
|
-
function
|
|
2215
|
-
const s =
|
|
2216
|
-
return r ?
|
|
2214
|
+
function Fs(n, e, t, r) {
|
|
2215
|
+
const s = Ye;
|
|
2216
|
+
return r ? Vn(s, n, e, t, r).concat(Ht(s, n, e, t)) : Ht(s, n, e, t);
|
|
2217
2217
|
}
|
|
2218
|
-
function
|
|
2218
|
+
function Ks(n, e, t) {
|
|
2219
2219
|
return [n(e, t), n("time", t)];
|
|
2220
2220
|
}
|
|
2221
|
-
function
|
|
2222
|
-
const [o, a, c, u, l] =
|
|
2221
|
+
function qs(n, e, t, r, s, i) {
|
|
2222
|
+
const [o, a, c, u, l] = Wn(
|
|
2223
2223
|
n,
|
|
2224
2224
|
e,
|
|
2225
2225
|
t,
|
|
2226
2226
|
r,
|
|
2227
2227
|
s
|
|
2228
|
-
), f =
|
|
2228
|
+
), f = Ps(c, n(t, r), i);
|
|
2229
2229
|
return [o, a, f, u, l];
|
|
2230
2230
|
}
|
|
2231
|
-
function
|
|
2231
|
+
function zs(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
2232
2232
|
const a = Object.keys(i).filter((c) => c !== "$");
|
|
2233
2233
|
return a.length ? Object.entries(o).map(function([u, l]) {
|
|
2234
2234
|
return a.map(function(h) {
|
|
2235
2235
|
const p = !!(e.cardinalityInference && t.linkIndex?.[r]?.[h]?.isSingular);
|
|
2236
2236
|
try {
|
|
2237
|
-
const [m, g, y] =
|
|
2237
|
+
const [m, g, y] = qs(
|
|
2238
2238
|
n,
|
|
2239
2239
|
t,
|
|
2240
2240
|
r,
|
|
2241
2241
|
s,
|
|
2242
2242
|
h,
|
|
2243
2243
|
u
|
|
2244
|
-
), b =
|
|
2244
|
+
), b = Gn(e, t, {
|
|
2245
2245
|
etype: m,
|
|
2246
2246
|
level: g,
|
|
2247
2247
|
form: i[h],
|
|
@@ -2258,54 +2258,54 @@ function qs(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
|
2258
2258
|
}, l);
|
|
2259
2259
|
}) : Object.values(o);
|
|
2260
2260
|
}
|
|
2261
|
-
function
|
|
2262
|
-
return t === "string" ?
|
|
2261
|
+
function Ws(n, e, t) {
|
|
2262
|
+
return t === "string" ? Is(n, e) : n > e ? 1 : -1;
|
|
2263
2263
|
}
|
|
2264
2264
|
function Ee(n, e, t, r, s) {
|
|
2265
|
-
return e === r || e == null && r == null ?
|
|
2265
|
+
return e === r || e == null && r == null ? As(n, t) : r == null ? 1 : e == null ? -1 : Ws(e, r, s);
|
|
2266
2266
|
}
|
|
2267
|
-
function
|
|
2267
|
+
function Ge([n, e], [t, r], s) {
|
|
2268
2268
|
return Ee(n, e, t, r, s);
|
|
2269
2269
|
}
|
|
2270
|
-
function
|
|
2270
|
+
function gt(n) {
|
|
2271
2271
|
return n == null ? n : new Date(n).getTime();
|
|
2272
2272
|
}
|
|
2273
|
-
function
|
|
2273
|
+
function Qn(n, e, t) {
|
|
2274
2274
|
const [r, s, i, o] = n;
|
|
2275
2275
|
if (e["forward-identity"]?.[2] === "id")
|
|
2276
|
-
return
|
|
2277
|
-
const [a, c] = t, u = e["checked-data-type"], l = u === "date" ?
|
|
2278
|
-
return
|
|
2276
|
+
return Ge(t, [r, o], null);
|
|
2277
|
+
const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? gt(c) : c, f = u === "date" ? gt(i) : i;
|
|
2278
|
+
return Ge([a, l], [r, f], u);
|
|
2279
2279
|
}
|
|
2280
|
-
function
|
|
2281
|
-
const s =
|
|
2280
|
+
function Vs(n, e, t, r) {
|
|
2281
|
+
const s = Qn(n, e, r);
|
|
2282
2282
|
return t === "desc" ? s > 0 : s < 0;
|
|
2283
2283
|
}
|
|
2284
|
-
function
|
|
2285
|
-
const s =
|
|
2284
|
+
function Qs(n, e, t, r) {
|
|
2285
|
+
const s = Qn(n, e, r);
|
|
2286
2286
|
return t === "desc" ? s < 0 : s > 0;
|
|
2287
2287
|
}
|
|
2288
|
-
function
|
|
2288
|
+
function Bs(n, e) {
|
|
2289
2289
|
const t = e[1];
|
|
2290
2290
|
return n.getAttr(t);
|
|
2291
2291
|
}
|
|
2292
|
-
function
|
|
2292
|
+
function Gs(n, e, t) {
|
|
2293
2293
|
const r = Object.keys(t)[0];
|
|
2294
2294
|
return U(n, e, r);
|
|
2295
2295
|
}
|
|
2296
|
-
function
|
|
2296
|
+
function Hs(n, e, t, r) {
|
|
2297
2297
|
if (t)
|
|
2298
|
-
return
|
|
2298
|
+
return Bs(n, t);
|
|
2299
2299
|
if (r)
|
|
2300
|
-
return
|
|
2300
|
+
return Gs(n, e, r);
|
|
2301
2301
|
}
|
|
2302
|
-
function
|
|
2302
|
+
function Js(n, e, t) {
|
|
2303
2303
|
if (!Array.isArray(t.fields))
|
|
2304
|
-
return
|
|
2304
|
+
return ss(n, e);
|
|
2305
2305
|
const r = /* @__PURE__ */ new Map();
|
|
2306
2306
|
for (const s of t.fields) {
|
|
2307
2307
|
const i = U(n, e, s), o = i?.["forward-identity"]?.[2];
|
|
2308
|
-
o &&
|
|
2308
|
+
o && Rt(i) && r.set(o, i);
|
|
2309
2309
|
}
|
|
2310
2310
|
if (!r.has("id")) {
|
|
2311
2311
|
const s = U(n, e, "id"), i = s?.["forward-identity"]?.[2];
|
|
@@ -2313,57 +2313,57 @@ function Gs(n, e, t) {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
return r;
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2317
|
-
const o = i?.$?.order, a =
|
|
2318
|
-
let u =
|
|
2319
|
-
const l = r?.["start-cursor"], f = r?.["end-cursor"], d =
|
|
2316
|
+
function Ys(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
|
|
2317
|
+
const o = i?.$?.order, a = Bn(i), c = Zs(i);
|
|
2318
|
+
let u = ys(n, s);
|
|
2319
|
+
const l = r?.["start-cursor"], f = r?.["end-cursor"], d = Hs(e, t, l, o);
|
|
2320
2320
|
if (d && d?.["forward-identity"]?.[2] !== "id") {
|
|
2321
2321
|
const m = d["checked-data-type"] === "date", g = d.id;
|
|
2322
2322
|
u = u.map(([y]) => {
|
|
2323
2323
|
let b = n.eav.get(y)?.get(g)?.values()?.next()?.value?.[2];
|
|
2324
|
-
return m && (b =
|
|
2324
|
+
return m && (b = gt(b)), [y, b];
|
|
2325
2325
|
});
|
|
2326
2326
|
}
|
|
2327
2327
|
u.sort(
|
|
2328
2328
|
c === "asc" ? function(g, y) {
|
|
2329
|
-
return
|
|
2329
|
+
return Ge(g, y, d?.["checked-data-type"]);
|
|
2330
2330
|
} : function(g, y) {
|
|
2331
|
-
return
|
|
2331
|
+
return Ge(y, g, d?.["checked-data-type"]);
|
|
2332
2332
|
}
|
|
2333
2333
|
);
|
|
2334
2334
|
let h = {};
|
|
2335
|
-
const p =
|
|
2335
|
+
const p = Js(e, t, s);
|
|
2336
2336
|
for (const m of u) {
|
|
2337
2337
|
const [g] = m;
|
|
2338
|
-
if (h[g] || !a && l && d &&
|
|
2338
|
+
if (h[g] || !a && l && d && Vs(l, d, c, m) || f && d && Qs(f, d, c, m))
|
|
2339
2339
|
continue;
|
|
2340
|
-
const y =
|
|
2340
|
+
const y = rs(n, p, g);
|
|
2341
2341
|
y && (h[g] = y);
|
|
2342
2342
|
}
|
|
2343
2343
|
return h;
|
|
2344
2344
|
}
|
|
2345
|
-
function
|
|
2345
|
+
function Zs(n) {
|
|
2346
2346
|
const e = n.$?.order;
|
|
2347
2347
|
return e && e[Object.keys(e)[0]] || "asc";
|
|
2348
2348
|
}
|
|
2349
|
-
function
|
|
2349
|
+
function Bn(n) {
|
|
2350
2350
|
const e = n.$?.offset, t = n.$?.before, r = n.$?.after;
|
|
2351
2351
|
return !e && !t && !r;
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2354
|
-
if (!
|
|
2353
|
+
function Xs(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
|
|
2354
|
+
if (!Bn(s) && (!o || !o["start-cursor"]))
|
|
2355
2355
|
return [];
|
|
2356
|
-
const a =
|
|
2357
|
-
|
|
2356
|
+
const a = Rs(
|
|
2357
|
+
Fs(e, t, r, s.$?.where),
|
|
2358
2358
|
i
|
|
2359
|
-
), c =
|
|
2359
|
+
), c = Ks(Ye, t, r), u = s.$?.fields, l = Ys(n, e, {
|
|
2360
2360
|
etype: t,
|
|
2361
2361
|
pageInfo: o,
|
|
2362
2362
|
form: s,
|
|
2363
2363
|
dq: { where: a, find: c, fields: u }
|
|
2364
2364
|
}), f = s.$?.limit || s.$?.first || s.$?.last;
|
|
2365
2365
|
if (f != null) {
|
|
2366
|
-
r > 0 &&
|
|
2366
|
+
r > 0 && zn && console.warn(
|
|
2367
2367
|
"WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit."
|
|
2368
2368
|
);
|
|
2369
2369
|
const d = Object.entries(l);
|
|
@@ -2371,20 +2371,20 @@ function Ys(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
|
|
|
2371
2371
|
}
|
|
2372
2372
|
return l;
|
|
2373
2373
|
}
|
|
2374
|
-
function
|
|
2374
|
+
function ei(n, e, t) {
|
|
2375
2375
|
try {
|
|
2376
|
-
return
|
|
2376
|
+
return Xs(n, e, t);
|
|
2377
2377
|
} catch (r) {
|
|
2378
2378
|
if (r instanceof ve)
|
|
2379
2379
|
return {};
|
|
2380
2380
|
throw r;
|
|
2381
2381
|
}
|
|
2382
2382
|
}
|
|
2383
|
-
function
|
|
2384
|
-
const r =
|
|
2385
|
-
return
|
|
2383
|
+
function Gn(n, e, t) {
|
|
2384
|
+
const r = ei(n, e, t);
|
|
2385
|
+
return zs(Ye, n, e, t, r);
|
|
2386
2386
|
}
|
|
2387
|
-
function
|
|
2387
|
+
function ti(n) {
|
|
2388
2388
|
const e = {};
|
|
2389
2389
|
for (const [t, r] of Object.entries(n))
|
|
2390
2390
|
e[t] = {
|
|
@@ -2395,23 +2395,23 @@ function Xs(n) {
|
|
|
2395
2395
|
};
|
|
2396
2396
|
return e;
|
|
2397
2397
|
}
|
|
2398
|
-
function
|
|
2398
|
+
function Ut({
|
|
2399
2399
|
store: n,
|
|
2400
2400
|
attrsStore: e,
|
|
2401
2401
|
pageInfo: t,
|
|
2402
2402
|
aggregate: r
|
|
2403
2403
|
}, s) {
|
|
2404
2404
|
const o = { data: Object.keys(s).reduce(function(c, u) {
|
|
2405
|
-
return r?.[u] || u === "$$ruleParams" || (c[u] =
|
|
2405
|
+
return r?.[u] || u === "$$ruleParams" || (c[u] = Gn(n, e, {
|
|
2406
2406
|
etype: u,
|
|
2407
2407
|
form: s[u],
|
|
2408
2408
|
level: 0,
|
|
2409
2409
|
pageInfo: t?.[u]
|
|
2410
2410
|
})), c;
|
|
2411
2411
|
}, {}) };
|
|
2412
|
-
return t && (o.pageInfo =
|
|
2412
|
+
return t && (o.pageInfo = ti(t)), r && (o.aggregate = r), o;
|
|
2413
2413
|
}
|
|
2414
|
-
function
|
|
2414
|
+
function ni() {
|
|
2415
2415
|
const e = {
|
|
2416
2416
|
__etype: 1,
|
|
2417
2417
|
__ops: 1,
|
|
@@ -2425,8 +2425,8 @@ function ei() {
|
|
|
2425
2425
|
};
|
|
2426
2426
|
return new Set(Object.keys(e));
|
|
2427
2427
|
}
|
|
2428
|
-
const
|
|
2429
|
-
function
|
|
2428
|
+
const ri = ni();
|
|
2429
|
+
function We(n, e, t) {
|
|
2430
2430
|
const r = {
|
|
2431
2431
|
__etype: n,
|
|
2432
2432
|
__ops: t
|
|
@@ -2435,25 +2435,25 @@ function ze(n, e, t) {
|
|
|
2435
2435
|
get: (s, i) => {
|
|
2436
2436
|
if (i === "__ops") return t;
|
|
2437
2437
|
if (i === "__etype") return n;
|
|
2438
|
-
if (
|
|
2439
|
-
return (o, a) =>
|
|
2438
|
+
if (ri.has(i))
|
|
2439
|
+
return (o, a) => We(n, e, [
|
|
2440
2440
|
...t,
|
|
2441
2441
|
a ? [i, n, e, o, a] : [i, n, e, o]
|
|
2442
2442
|
]);
|
|
2443
2443
|
}
|
|
2444
2444
|
});
|
|
2445
2445
|
}
|
|
2446
|
-
function
|
|
2446
|
+
function si(n, e) {
|
|
2447
2447
|
return `lookup__${n}__${JSON.stringify(e)}`;
|
|
2448
2448
|
}
|
|
2449
|
-
function
|
|
2449
|
+
function He(n) {
|
|
2450
2450
|
return n.startsWith("lookup__");
|
|
2451
2451
|
}
|
|
2452
|
-
function
|
|
2452
|
+
function mt(n) {
|
|
2453
2453
|
const [e, t, ...r] = n.split("__");
|
|
2454
2454
|
return [t, JSON.parse(r.join("__"))];
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2456
|
+
function ii(n) {
|
|
2457
2457
|
return new Proxy(
|
|
2458
2458
|
{
|
|
2459
2459
|
__etype: n
|
|
@@ -2461,29 +2461,29 @@ function ri(n) {
|
|
|
2461
2461
|
{
|
|
2462
2462
|
get(e, t) {
|
|
2463
2463
|
if (t === "lookup")
|
|
2464
|
-
return (s, i) =>
|
|
2464
|
+
return (s, i) => We(n, mt(si(s, i)), []);
|
|
2465
2465
|
if (t === "__etype") return n;
|
|
2466
2466
|
const r = t;
|
|
2467
|
-
return
|
|
2467
|
+
return He(r) ? We(n, mt(r), []) : We(n, r, []);
|
|
2468
2468
|
}
|
|
2469
2469
|
}
|
|
2470
2470
|
);
|
|
2471
2471
|
}
|
|
2472
|
-
function
|
|
2472
|
+
function Hn() {
|
|
2473
2473
|
return new Proxy(
|
|
2474
2474
|
{},
|
|
2475
2475
|
{
|
|
2476
2476
|
get(n, e) {
|
|
2477
|
-
return
|
|
2477
|
+
return ii(e);
|
|
2478
2478
|
}
|
|
2479
2479
|
}
|
|
2480
2480
|
);
|
|
2481
2481
|
}
|
|
2482
|
-
const
|
|
2483
|
-
function
|
|
2482
|
+
const ba = Hn();
|
|
2483
|
+
function oi(n) {
|
|
2484
2484
|
return n.__ops;
|
|
2485
2485
|
}
|
|
2486
|
-
function
|
|
2486
|
+
function ai(n, e) {
|
|
2487
2487
|
const { attrIdMap: t, refSwapAttrIds: r } = n, s = [];
|
|
2488
2488
|
for (const o of e) {
|
|
2489
2489
|
const a = t[o];
|
|
@@ -2502,7 +2502,7 @@ function ii(n, e) {
|
|
|
2502
2502
|
}
|
|
2503
2503
|
return s;
|
|
2504
2504
|
}
|
|
2505
|
-
function
|
|
2505
|
+
function ci(n) {
|
|
2506
2506
|
if (Array.isArray(n))
|
|
2507
2507
|
return n;
|
|
2508
2508
|
const e = Object.entries(n);
|
|
@@ -2512,38 +2512,38 @@ function oi(n) {
|
|
|
2512
2512
|
);
|
|
2513
2513
|
return e[0];
|
|
2514
2514
|
}
|
|
2515
|
-
function
|
|
2515
|
+
function ui(n, e, t) {
|
|
2516
2516
|
return t.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2517
2517
|
// before assuming it's a ref lookup.
|
|
2518
2518
|
!U(n, e, t);
|
|
2519
2519
|
}
|
|
2520
|
-
function
|
|
2520
|
+
function wt(n) {
|
|
2521
2521
|
const [e, t, ...r] = n.split(".");
|
|
2522
2522
|
if (r.length > 0 || t !== "id")
|
|
2523
2523
|
throw new Error(`${n} is not a valid lookup attribute.`);
|
|
2524
2524
|
return e;
|
|
2525
2525
|
}
|
|
2526
|
-
function
|
|
2527
|
-
if (!
|
|
2526
|
+
function li(n, e, t) {
|
|
2527
|
+
if (!ui(n, e, t))
|
|
2528
2528
|
return U(n, e, t);
|
|
2529
|
-
const r =
|
|
2529
|
+
const r = wt(t), s = U(n, e, r) || ye(n, e, r);
|
|
2530
2530
|
if (s && s["value-type"] !== "ref")
|
|
2531
2531
|
throw new Error(`${t} does not reference a valid link attribute.`);
|
|
2532
2532
|
return s;
|
|
2533
2533
|
}
|
|
2534
|
-
function
|
|
2535
|
-
return typeof n == "string" && !
|
|
2534
|
+
function _t(n) {
|
|
2535
|
+
return typeof n == "string" && !He(n) ? null : typeof n == "string" && He(n) ? mt(n) : ci(n);
|
|
2536
2536
|
}
|
|
2537
2537
|
function G(n, e, t) {
|
|
2538
|
-
const r =
|
|
2538
|
+
const r = _t(t);
|
|
2539
2539
|
if (r === null)
|
|
2540
2540
|
return t;
|
|
2541
|
-
const [s, i] = r, o =
|
|
2541
|
+
const [s, i] = r, o = li(n, e, s);
|
|
2542
2542
|
if (!o || !o["unique?"])
|
|
2543
2543
|
throw new Error(`${s} is not a unique attribute.`);
|
|
2544
2544
|
return [o.id, i];
|
|
2545
2545
|
}
|
|
2546
|
-
function
|
|
2546
|
+
function Jn(n, e, t, r) {
|
|
2547
2547
|
const s = G(n, e, t);
|
|
2548
2548
|
return Array.isArray(s) ? [[
|
|
2549
2549
|
"add-triple",
|
|
@@ -2552,7 +2552,7 @@ function Gn(n, e, t, r) {
|
|
|
2552
2552
|
s
|
|
2553
2553
|
]].concat(r) : r;
|
|
2554
2554
|
}
|
|
2555
|
-
function
|
|
2555
|
+
function di({ attrsStore: n }, [e, t, r]) {
|
|
2556
2556
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2557
2557
|
const a = Array.isArray(o) ? o : [o], c = U(n, e, i), u = ye(n, e, i);
|
|
2558
2558
|
return a.map((l) => c ? [
|
|
@@ -2571,9 +2571,9 @@ function ui({ attrsStore: n }, [e, t, r]) {
|
|
|
2571
2571
|
G(n, e, t)
|
|
2572
2572
|
]);
|
|
2573
2573
|
});
|
|
2574
|
-
return
|
|
2574
|
+
return Jn(n, e, t, s);
|
|
2575
2575
|
}
|
|
2576
|
-
function
|
|
2576
|
+
function fi({ attrsStore: n }, [e, t, r]) {
|
|
2577
2577
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2578
2578
|
const a = Array.isArray(o) ? o : [o], c = U(n, e, i), u = ye(n, e, i);
|
|
2579
2579
|
return a.map((l) => c ? [
|
|
@@ -2592,9 +2592,9 @@ function li({ attrsStore: n }, [e, t, r]) {
|
|
|
2592
2592
|
G(n, e, t)
|
|
2593
2593
|
]);
|
|
2594
2594
|
});
|
|
2595
|
-
return
|
|
2595
|
+
return Jn(n, e, t, s);
|
|
2596
2596
|
}
|
|
2597
|
-
function
|
|
2597
|
+
function hi(n, e, t, r) {
|
|
2598
2598
|
if (Array.isArray(r)) {
|
|
2599
2599
|
const [s, i] = r;
|
|
2600
2600
|
for (const o of n || []) {
|
|
@@ -2616,21 +2616,21 @@ function di(n, e, t, r) {
|
|
|
2616
2616
|
}
|
|
2617
2617
|
return !1;
|
|
2618
2618
|
}
|
|
2619
|
-
function
|
|
2620
|
-
return i?.upsert === !1 ? { mode: "update" } : i?.upsert === !0 ? null :
|
|
2619
|
+
function Yn({ stores: n, attrsStore: e }, [t, r, s, i]) {
|
|
2620
|
+
return i?.upsert === !1 ? { mode: "update" } : i?.upsert === !0 ? null : hi(n, e, t, r) ? { mode: "update" } : null;
|
|
2621
2621
|
}
|
|
2622
|
-
function
|
|
2623
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a =
|
|
2622
|
+
function pi(n, e) {
|
|
2623
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = $t(i), c = G(t, r, s);
|
|
2624
2624
|
return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
|
|
2625
2625
|
const d = U(t, r, l);
|
|
2626
|
-
return d["checked-data-type"] === "date" && n.useDateObjects && (f =
|
|
2626
|
+
return d["checked-data-type"] === "date" && n.useDateObjects && (f = Je(f)), ["add-triple", c, d.id, f, { mode: "create" }];
|
|
2627
2627
|
});
|
|
2628
2628
|
}
|
|
2629
|
-
function
|
|
2630
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a =
|
|
2629
|
+
function yi(n, e) {
|
|
2630
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = $t(i), c = G(t, r, s), u = Yn(n, [r, c, i, o]);
|
|
2631
2631
|
return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
|
|
2632
2632
|
const h = U(t, r, f);
|
|
2633
|
-
return h["checked-data-type"] === "date" && n.useDateObjects && (d =
|
|
2633
|
+
return h["checked-data-type"] === "date" && n.useDateObjects && (d = Je(d)), [
|
|
2634
2634
|
"add-triple",
|
|
2635
2635
|
c,
|
|
2636
2636
|
h.id,
|
|
@@ -2639,11 +2639,11 @@ function hi(n, e) {
|
|
|
2639
2639
|
];
|
|
2640
2640
|
});
|
|
2641
2641
|
}
|
|
2642
|
-
function
|
|
2642
|
+
function bi({ attrsStore: n }, [e, t]) {
|
|
2643
2643
|
return [["delete-entity", G(n, e, t), e]];
|
|
2644
2644
|
}
|
|
2645
|
-
function
|
|
2646
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a =
|
|
2645
|
+
function gi(n, e) {
|
|
2646
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = $t(i), c = G(t, r, s), u = Yn(n, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
|
|
2647
2647
|
const p = U(t, r, d);
|
|
2648
2648
|
return [
|
|
2649
2649
|
"deep-merge-triple",
|
|
@@ -2661,38 +2661,38 @@ function yi(n, e) {
|
|
|
2661
2661
|
...u ? [u] : []
|
|
2662
2662
|
]].concat(l);
|
|
2663
2663
|
}
|
|
2664
|
-
function
|
|
2664
|
+
function mi({ attrsStore: n }, [e, t, r]) {
|
|
2665
2665
|
return [["rule-params", G(n, e, t), e, r]];
|
|
2666
2666
|
}
|
|
2667
|
-
function
|
|
2667
|
+
function wi(n) {
|
|
2668
2668
|
const [e, t, r, s, i] = n;
|
|
2669
2669
|
if (!s)
|
|
2670
2670
|
return n;
|
|
2671
2671
|
const o = { ...s };
|
|
2672
2672
|
return delete o.id, [e, t, r, o, ...i ? [i] : []];
|
|
2673
2673
|
}
|
|
2674
|
-
function
|
|
2675
|
-
const [t, ...r] =
|
|
2674
|
+
function _i(n, e) {
|
|
2675
|
+
const [t, ...r] = wi(e);
|
|
2676
2676
|
switch (t) {
|
|
2677
2677
|
case "merge":
|
|
2678
|
-
return
|
|
2678
|
+
return gi(n, r);
|
|
2679
2679
|
case "create":
|
|
2680
|
-
return
|
|
2680
|
+
return pi(n, r);
|
|
2681
2681
|
case "update":
|
|
2682
|
-
return
|
|
2682
|
+
return yi(n, r);
|
|
2683
2683
|
case "link":
|
|
2684
|
-
return
|
|
2684
|
+
return di(n, r);
|
|
2685
2685
|
case "unlink":
|
|
2686
|
-
return
|
|
2686
|
+
return fi(n, r);
|
|
2687
2687
|
case "delete":
|
|
2688
|
-
return pi(n, r);
|
|
2689
|
-
case "ruleParams":
|
|
2690
2688
|
return bi(n, r);
|
|
2689
|
+
case "ruleParams":
|
|
2690
|
+
return mi(n, r);
|
|
2691
2691
|
default:
|
|
2692
2692
|
throw new Error(`unsupported action ${t}`);
|
|
2693
2693
|
}
|
|
2694
2694
|
}
|
|
2695
|
-
function
|
|
2695
|
+
function Si(n) {
|
|
2696
2696
|
switch (n) {
|
|
2697
2697
|
case "string":
|
|
2698
2698
|
case "date":
|
|
@@ -2703,12 +2703,12 @@ function wi(n) {
|
|
|
2703
2703
|
return;
|
|
2704
2704
|
}
|
|
2705
2705
|
}
|
|
2706
|
-
function
|
|
2706
|
+
function Ti(n, e, t) {
|
|
2707
2707
|
const r = n.entities[e]?.attrs?.[t];
|
|
2708
2708
|
if (t === "id") return null;
|
|
2709
2709
|
if (!r)
|
|
2710
2710
|
throw new Error(`${e}.${t} does not exist in your schema`);
|
|
2711
|
-
const { unique: s, indexed: i } = r?.config, o =
|
|
2711
|
+
const { unique: s, indexed: i } = r?.config, o = Si(r?.valueType);
|
|
2712
2712
|
return {
|
|
2713
2713
|
"index?": i,
|
|
2714
2714
|
"unique?": s,
|
|
@@ -2716,7 +2716,7 @@ function _i(n, e, t) {
|
|
|
2716
2716
|
};
|
|
2717
2717
|
}
|
|
2718
2718
|
function Ue(n, e, t, r) {
|
|
2719
|
-
const s = n ?
|
|
2719
|
+
const s = n ? Ti(n, e, t) : null, i = j(), a = [j(), e, t];
|
|
2720
2720
|
return {
|
|
2721
2721
|
id: i,
|
|
2722
2722
|
"forward-identity": a,
|
|
@@ -2729,11 +2729,11 @@ function Ue(n, e, t, r) {
|
|
|
2729
2729
|
...r || {}
|
|
2730
2730
|
};
|
|
2731
2731
|
}
|
|
2732
|
-
function
|
|
2732
|
+
function vi(n, e, t) {
|
|
2733
2733
|
return Object.values(n.links).find((i) => i.forward.on === e && i.forward.label === t || i.reverse.on === e && i.reverse.label === t);
|
|
2734
2734
|
}
|
|
2735
|
-
function
|
|
2736
|
-
const r =
|
|
2735
|
+
function Ai(n, e, t) {
|
|
2736
|
+
const r = vi(n, e, t);
|
|
2737
2737
|
if (!r)
|
|
2738
2738
|
throw new Error(`Couldn't find the link ${e}.${t} in your schema`);
|
|
2739
2739
|
const { forward: s, reverse: i } = r;
|
|
@@ -2746,8 +2746,8 @@ function Ti(n, e, t) {
|
|
|
2746
2746
|
"on-delete-reverse": i.onDelete
|
|
2747
2747
|
};
|
|
2748
2748
|
}
|
|
2749
|
-
function
|
|
2750
|
-
const s = n ?
|
|
2749
|
+
function Xt(n, e, t, r) {
|
|
2750
|
+
const s = n ? Ai(n, e, t) : null, i = j(), o = [j(), e, t], a = [j(), t, e];
|
|
2751
2751
|
return {
|
|
2752
2752
|
id: i,
|
|
2753
2753
|
// @ts-ignore: ts thinks it's any[]
|
|
@@ -2764,7 +2764,7 @@ function Yt(n, e, t, r) {
|
|
|
2764
2764
|
...r || {}
|
|
2765
2765
|
};
|
|
2766
2766
|
}
|
|
2767
|
-
const
|
|
2767
|
+
const ki = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Oi = /* @__PURE__ */ new Set(["link", "unlink"]), Ii = /* @__PURE__ */ new Set(["create", "update", "merge"]), Ci = /* @__PURE__ */ new Set([
|
|
2768
2768
|
"link",
|
|
2769
2769
|
"unlink",
|
|
2770
2770
|
"create",
|
|
@@ -2772,20 +2772,20 @@ const vi = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
|
|
|
2772
2772
|
"merge",
|
|
2773
2773
|
"delete",
|
|
2774
2774
|
"ruleParams"
|
|
2775
|
-
]),
|
|
2776
|
-
...
|
|
2775
|
+
]), St = { "unique?": !0, "index?": !0 }, Ei = {
|
|
2776
|
+
...St,
|
|
2777
2777
|
cardinality: "one"
|
|
2778
2778
|
};
|
|
2779
|
-
function
|
|
2779
|
+
function Mi(n) {
|
|
2780
2780
|
const e = [], [t, r, s, i] = n;
|
|
2781
|
-
if (!
|
|
2781
|
+
if (!Ci.has(t))
|
|
2782
2782
|
return e;
|
|
2783
|
-
const o =
|
|
2783
|
+
const o = _t(s);
|
|
2784
2784
|
if (o && e.push({ etype: r, lookupPair: o }), t === "link")
|
|
2785
2785
|
for (const [a, c] of Object.entries(i)) {
|
|
2786
2786
|
const u = Array.isArray(c) ? c : [c];
|
|
2787
2787
|
for (const l of u) {
|
|
2788
|
-
const f =
|
|
2788
|
+
const f = _t(l);
|
|
2789
2789
|
f && e.push({
|
|
2790
2790
|
etype: r,
|
|
2791
2791
|
lookupPair: f,
|
|
@@ -2795,7 +2795,7 @@ function Ci(n) {
|
|
|
2795
2795
|
}
|
|
2796
2796
|
return e;
|
|
2797
2797
|
}
|
|
2798
|
-
function
|
|
2798
|
+
function Pi({ attrsStore: n, schema: e }, t) {
|
|
2799
2799
|
const r = /* @__PURE__ */ new Set(), s = [], i = [];
|
|
2800
2800
|
function o(d, h) {
|
|
2801
2801
|
return U(n, d, h) || s.find(
|
|
@@ -2820,10 +2820,10 @@ function Ei({ attrsStore: n, schema: e }, t) {
|
|
|
2820
2820
|
}
|
|
2821
2821
|
function f(d, h) {
|
|
2822
2822
|
const p = o(d, h), m = a(d, h);
|
|
2823
|
-
u(p), u(m), !p && !m && c(
|
|
2823
|
+
u(p), u(m), !p && !m && c(Xt(e, d, h, Ei));
|
|
2824
2824
|
}
|
|
2825
2825
|
for (const d of t)
|
|
2826
|
-
for (const { etype: h, lookupPair: p, linkLabel: m } of
|
|
2826
|
+
for (const { etype: h, lookupPair: p, linkLabel: m } of Mi(d)) {
|
|
2827
2827
|
const g = p[0];
|
|
2828
2828
|
if (m) {
|
|
2829
2829
|
f(h, m);
|
|
@@ -2831,37 +2831,37 @@ function Ei({ attrsStore: n, schema: e }, t) {
|
|
|
2831
2831
|
u(y), u(b);
|
|
2832
2832
|
const _ = y?.["reverse-identity"]?.[1] || b?.["forward-identity"]?.[1] || m;
|
|
2833
2833
|
if (l(_, g))
|
|
2834
|
-
f(_,
|
|
2834
|
+
f(_, wt(g));
|
|
2835
2835
|
else {
|
|
2836
2836
|
const M = o(_, g);
|
|
2837
2837
|
M || c(
|
|
2838
|
-
Ue(e, _, g,
|
|
2838
|
+
Ue(e, _, g, St)
|
|
2839
2839
|
), u(M);
|
|
2840
2840
|
}
|
|
2841
2841
|
} else if (l(h, g))
|
|
2842
|
-
f(h,
|
|
2842
|
+
f(h, wt(g));
|
|
2843
2843
|
else {
|
|
2844
2844
|
const y = o(h, g);
|
|
2845
|
-
y || c(Ue(e, h, g,
|
|
2845
|
+
y || c(Ue(e, h, g, St)), u(y);
|
|
2846
2846
|
}
|
|
2847
2847
|
}
|
|
2848
2848
|
for (const d of t) {
|
|
2849
2849
|
const [h, p, m, g] = d;
|
|
2850
|
-
if (
|
|
2850
|
+
if (ki.has(h)) {
|
|
2851
2851
|
const y = o(p, "id");
|
|
2852
2852
|
u(y), y || c(Ue(e, p, "id", { "unique?": !0 }));
|
|
2853
2853
|
for (const b of Object.keys(g)) {
|
|
2854
2854
|
const _ = o(p, b);
|
|
2855
|
-
if (u(_),
|
|
2855
|
+
if (u(_), Ii.has(h) && (_ || c(
|
|
2856
2856
|
Ue(
|
|
2857
2857
|
e,
|
|
2858
2858
|
p,
|
|
2859
2859
|
b,
|
|
2860
2860
|
b === "id" ? { "unique?": !0 } : null
|
|
2861
2861
|
)
|
|
2862
|
-
)),
|
|
2862
|
+
)), Oi.has(h)) {
|
|
2863
2863
|
const M = a(p, b);
|
|
2864
|
-
!_ && !M && c(
|
|
2864
|
+
!_ && !M && c(Xt(e, p, b)), u(M);
|
|
2865
2865
|
}
|
|
2866
2866
|
}
|
|
2867
2867
|
}
|
|
@@ -2874,19 +2874,19 @@ function Ei({ attrsStore: n, schema: e }, t) {
|
|
|
2874
2874
|
}
|
|
2875
2875
|
return [n, i];
|
|
2876
2876
|
}
|
|
2877
|
-
function
|
|
2878
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((c) =>
|
|
2877
|
+
function ji(n, e) {
|
|
2878
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((c) => oi(c)), [s, i] = Pi(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => _i(o, c));
|
|
2879
2879
|
return [...i, ...a];
|
|
2880
2880
|
}
|
|
2881
|
-
function
|
|
2881
|
+
function en(n, e) {
|
|
2882
2882
|
typeof requestIdleCallback > "u" ? n() : requestIdleCallback(n, { timeout: e });
|
|
2883
2883
|
}
|
|
2884
2884
|
const _e = "__meta";
|
|
2885
|
-
class
|
|
2885
|
+
class Zn {
|
|
2886
2886
|
constructor(e, t) {
|
|
2887
2887
|
}
|
|
2888
2888
|
}
|
|
2889
|
-
class
|
|
2889
|
+
class Tt {
|
|
2890
2890
|
currentValue;
|
|
2891
2891
|
_subs = [];
|
|
2892
2892
|
_persister;
|
|
@@ -3086,7 +3086,7 @@ class _t {
|
|
|
3086
3086
|
gc() {
|
|
3087
3087
|
this._nextGc || (this._nextGc = setTimeout(
|
|
3088
3088
|
() => {
|
|
3089
|
-
|
|
3089
|
+
en(() => {
|
|
3090
3090
|
this._nextGc = null, this._gc();
|
|
3091
3091
|
}, 30 * 1e3);
|
|
3092
3092
|
},
|
|
@@ -3101,7 +3101,7 @@ class _t {
|
|
|
3101
3101
|
return;
|
|
3102
3102
|
}
|
|
3103
3103
|
this._nextSave = setTimeout(() => {
|
|
3104
|
-
|
|
3104
|
+
en(() => {
|
|
3105
3105
|
this._nextSave = null, this._writeToStorage(e).then(t).catch(r);
|
|
3106
3106
|
}, this._idleCallbackMaxWaitMs);
|
|
3107
3107
|
}, this._saveThrottleMs);
|
|
@@ -3115,7 +3115,7 @@ class _t {
|
|
|
3115
3115
|
// so that we know which entries we need to persist to the store.
|
|
3116
3116
|
updateInPlace(e) {
|
|
3117
3117
|
this._version++;
|
|
3118
|
-
const [t, r] =
|
|
3118
|
+
const [t, r] = Be(this.currentValue, e, {
|
|
3119
3119
|
enablePatches: !0
|
|
3120
3120
|
});
|
|
3121
3121
|
for (const s of r) {
|
|
@@ -3141,13 +3141,13 @@ class _t {
|
|
|
3141
3141
|
e && await this._enqueuePersist();
|
|
3142
3142
|
}
|
|
3143
3143
|
}
|
|
3144
|
-
const
|
|
3145
|
-
function
|
|
3144
|
+
const $i = 6, xi = ["kv", "querySubs", "syncSubs"];
|
|
3145
|
+
function Ri(n) {
|
|
3146
3146
|
return function(t) {
|
|
3147
3147
|
console.error("Error in IndexedDB event", { source: n, event: t });
|
|
3148
3148
|
};
|
|
3149
3149
|
}
|
|
3150
|
-
async function
|
|
3150
|
+
async function Di(n) {
|
|
3151
3151
|
return new Promise((e) => {
|
|
3152
3152
|
const t = indexedDB.open(n);
|
|
3153
3153
|
t.onerror = (r) => {
|
|
@@ -3160,7 +3160,7 @@ async function xi(n) {
|
|
|
3160
3160
|
};
|
|
3161
3161
|
});
|
|
3162
3162
|
}
|
|
3163
|
-
async function
|
|
3163
|
+
async function Ui(n, e, t) {
|
|
3164
3164
|
const r = (
|
|
3165
3165
|
// Backwards compatibility for older versions where we JSON.stringified before storing
|
|
3166
3166
|
typeof e == "string" ? JSON.parse(e) : e
|
|
@@ -3193,14 +3193,14 @@ async function Ri(n, e, t) {
|
|
|
3193
3193
|
};
|
|
3194
3194
|
});
|
|
3195
3195
|
}
|
|
3196
|
-
async function
|
|
3196
|
+
async function tn(n, e, t) {
|
|
3197
3197
|
const r = t.put(e, n);
|
|
3198
3198
|
return new Promise((s, i) => {
|
|
3199
3199
|
r.onsuccess = () => s(), r.onerror = (o) => i(o);
|
|
3200
3200
|
});
|
|
3201
3201
|
}
|
|
3202
|
-
async function
|
|
3203
|
-
const t = await
|
|
3202
|
+
async function Li(n, e) {
|
|
3203
|
+
const t = await Di(`instant_${n}_5`);
|
|
3204
3204
|
if (!t)
|
|
3205
3205
|
return;
|
|
3206
3206
|
const r = await new Promise((l, f) => {
|
|
@@ -3222,10 +3222,10 @@ async function Di(n, e) {
|
|
|
3222
3222
|
}), s = e.transaction(["kv", "querySubs"], "readwrite"), i = s.objectStore("kv"), o = s.objectStore("querySubs"), a = [], c = { objects: {} };
|
|
3223
3223
|
for (const [l, f] of r)
|
|
3224
3224
|
if (l === "querySubs") {
|
|
3225
|
-
const d =
|
|
3225
|
+
const d = Ui(l, f, o);
|
|
3226
3226
|
a.push(d);
|
|
3227
3227
|
} else {
|
|
3228
|
-
const d =
|
|
3228
|
+
const d = tn(l, f, i);
|
|
3229
3229
|
a.push(d);
|
|
3230
3230
|
const h = {
|
|
3231
3231
|
createdAt: Date.now(),
|
|
@@ -3234,20 +3234,20 @@ async function Di(n, e) {
|
|
|
3234
3234
|
};
|
|
3235
3235
|
c.objects[l] = h;
|
|
3236
3236
|
}
|
|
3237
|
-
const u =
|
|
3237
|
+
const u = tn(_e, c, i);
|
|
3238
3238
|
a.push(u), await Promise.all(a), await new Promise((l, f) => {
|
|
3239
3239
|
s.oncomplete = (d) => l(d), s.onerror = (d) => f(d), s.onabort = (d) => f(d);
|
|
3240
3240
|
});
|
|
3241
3241
|
}
|
|
3242
|
-
const
|
|
3243
|
-
class
|
|
3242
|
+
const nn = /* @__PURE__ */ new Map();
|
|
3243
|
+
class Xn extends Zn {
|
|
3244
3244
|
dbName;
|
|
3245
3245
|
_storeName;
|
|
3246
3246
|
_appId;
|
|
3247
3247
|
_prefix;
|
|
3248
3248
|
_dbPromise;
|
|
3249
3249
|
constructor(e, t) {
|
|
3250
|
-
super(e, t), this.dbName = `instant_${e}_${
|
|
3250
|
+
super(e, t), this.dbName = `instant_${e}_${$i}`, this._storeName = t, this._appId = e, this._dbPromise = this._init();
|
|
3251
3251
|
}
|
|
3252
3252
|
_init() {
|
|
3253
3253
|
return new Promise((e, t) => {
|
|
@@ -3258,12 +3258,12 @@ class Yn extends Jn {
|
|
|
3258
3258
|
}, s.onsuccess = (i) => {
|
|
3259
3259
|
const a = i.target.result;
|
|
3260
3260
|
if (r) {
|
|
3261
|
-
const c =
|
|
3262
|
-
|
|
3261
|
+
const c = Li(this._appId, a).catch((u) => {
|
|
3262
|
+
Ri("Error upgrading store from version 5 to 6.")(u);
|
|
3263
3263
|
});
|
|
3264
|
-
|
|
3264
|
+
nn.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
|
|
3265
3265
|
} else {
|
|
3266
|
-
const c =
|
|
3266
|
+
const c = nn.get(this.dbName);
|
|
3267
3267
|
c ? c.then(() => e(a)).catch(() => e(a)) : e(a);
|
|
3268
3268
|
}
|
|
3269
3269
|
}, s.onupgradeneeded = (i) => {
|
|
@@ -3273,7 +3273,7 @@ class Yn extends Jn {
|
|
|
3273
3273
|
}
|
|
3274
3274
|
_upgradeStore(e) {
|
|
3275
3275
|
const r = e.target.result;
|
|
3276
|
-
for (const s of
|
|
3276
|
+
for (const s of xi)
|
|
3277
3277
|
r.objectStoreNames.contains(s) || r.createObjectStore(s);
|
|
3278
3278
|
}
|
|
3279
3279
|
async getItem(e) {
|
|
@@ -3338,7 +3338,7 @@ class Yn extends Jn {
|
|
|
3338
3338
|
});
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
|
-
class
|
|
3341
|
+
class er {
|
|
3342
3342
|
static async getIsOnline() {
|
|
3343
3343
|
return navigator.onLine;
|
|
3344
3344
|
}
|
|
@@ -3353,19 +3353,19 @@ class Zn {
|
|
|
3353
3353
|
};
|
|
3354
3354
|
}
|
|
3355
3355
|
}
|
|
3356
|
-
class
|
|
3356
|
+
class K extends Error {
|
|
3357
3357
|
hint;
|
|
3358
3358
|
traceId;
|
|
3359
3359
|
constructor(e, t, r) {
|
|
3360
3360
|
super(e), this.hint = t, r && (this.traceId = r);
|
|
3361
3361
|
const s = new.target.prototype;
|
|
3362
|
-
Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
3362
|
+
Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, K), this.name = "InstantError";
|
|
3363
3363
|
}
|
|
3364
3364
|
get [Symbol.toStringTag]() {
|
|
3365
3365
|
return "InstantError";
|
|
3366
3366
|
}
|
|
3367
3367
|
}
|
|
3368
|
-
class Re extends
|
|
3368
|
+
class Re extends K {
|
|
3369
3369
|
body;
|
|
3370
3370
|
status;
|
|
3371
3371
|
constructor(e) {
|
|
@@ -3382,7 +3382,7 @@ async function se(n, e) {
|
|
|
3382
3382
|
const t = await fetch(n, e), r = await t.json();
|
|
3383
3383
|
return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Re({ status: t.status, body: r }));
|
|
3384
3384
|
}
|
|
3385
|
-
function
|
|
3385
|
+
function Ni({
|
|
3386
3386
|
apiURI: n,
|
|
3387
3387
|
appId: e,
|
|
3388
3388
|
email: t
|
|
@@ -3393,12 +3393,13 @@ function Ui({
|
|
|
3393
3393
|
body: JSON.stringify({ "app-id": e, email: t })
|
|
3394
3394
|
});
|
|
3395
3395
|
}
|
|
3396
|
-
async function
|
|
3396
|
+
async function Fi({
|
|
3397
3397
|
apiURI: n,
|
|
3398
3398
|
appId: e,
|
|
3399
3399
|
email: t,
|
|
3400
3400
|
code: r,
|
|
3401
|
-
refreshToken: s
|
|
3401
|
+
refreshToken: s,
|
|
3402
|
+
extraFields: i
|
|
3402
3403
|
}) {
|
|
3403
3404
|
return await se(`${n}/runtime/auth/verify_magic_code`, {
|
|
3404
3405
|
method: "POST",
|
|
@@ -3407,11 +3408,12 @@ async function Li({
|
|
|
3407
3408
|
"app-id": e,
|
|
3408
3409
|
email: t,
|
|
3409
3410
|
code: r,
|
|
3410
|
-
...s ? { "refresh-token": s } : {}
|
|
3411
|
+
...s ? { "refresh-token": s } : {},
|
|
3412
|
+
...i ? { "extra-fields": i } : {}
|
|
3411
3413
|
})
|
|
3412
3414
|
});
|
|
3413
3415
|
}
|
|
3414
|
-
async function
|
|
3416
|
+
async function Ki({
|
|
3415
3417
|
apiURI: n,
|
|
3416
3418
|
appId: e,
|
|
3417
3419
|
refreshToken: t
|
|
@@ -3425,7 +3427,7 @@ async function Ni({
|
|
|
3425
3427
|
})
|
|
3426
3428
|
});
|
|
3427
3429
|
}
|
|
3428
|
-
async function
|
|
3430
|
+
async function qi({
|
|
3429
3431
|
apiURI: n,
|
|
3430
3432
|
appId: e
|
|
3431
3433
|
}) {
|
|
@@ -3437,12 +3439,13 @@ async function Fi({
|
|
|
3437
3439
|
})
|
|
3438
3440
|
});
|
|
3439
3441
|
}
|
|
3440
|
-
async function
|
|
3442
|
+
async function rn({
|
|
3441
3443
|
apiURI: n,
|
|
3442
3444
|
appId: e,
|
|
3443
3445
|
code: t,
|
|
3444
3446
|
codeVerifier: r,
|
|
3445
|
-
refreshToken: s
|
|
3447
|
+
refreshToken: s,
|
|
3448
|
+
extraFields: i
|
|
3446
3449
|
}) {
|
|
3447
3450
|
return await se(`${n}/runtime/oauth/token`, {
|
|
3448
3451
|
method: "POST",
|
|
@@ -3451,17 +3454,19 @@ async function tn({
|
|
|
3451
3454
|
app_id: e,
|
|
3452
3455
|
code: t,
|
|
3453
3456
|
code_verifier: r,
|
|
3454
|
-
refresh_token: s
|
|
3457
|
+
refresh_token: s,
|
|
3458
|
+
...i ? { extra_fields: i } : {}
|
|
3455
3459
|
})
|
|
3456
3460
|
});
|
|
3457
3461
|
}
|
|
3458
|
-
async function
|
|
3462
|
+
async function zi({
|
|
3459
3463
|
apiURI: n,
|
|
3460
3464
|
appId: e,
|
|
3461
3465
|
nonce: t,
|
|
3462
3466
|
idToken: r,
|
|
3463
3467
|
clientName: s,
|
|
3464
|
-
refreshToken: i
|
|
3468
|
+
refreshToken: i,
|
|
3469
|
+
extraFields: o
|
|
3465
3470
|
}) {
|
|
3466
3471
|
return await se(`${n}/runtime/oauth/id_token`, {
|
|
3467
3472
|
method: "POST",
|
|
@@ -3471,11 +3476,12 @@ async function qi({
|
|
|
3471
3476
|
nonce: t,
|
|
3472
3477
|
id_token: r,
|
|
3473
3478
|
client_name: s,
|
|
3474
|
-
refresh_token: i
|
|
3479
|
+
refresh_token: i,
|
|
3480
|
+
...o ? { extra_fields: o } : {}
|
|
3475
3481
|
})
|
|
3476
3482
|
});
|
|
3477
3483
|
}
|
|
3478
|
-
async function
|
|
3484
|
+
async function Wi({
|
|
3479
3485
|
apiURI: n,
|
|
3480
3486
|
appId: e,
|
|
3481
3487
|
refreshToken: t
|
|
@@ -3491,7 +3497,7 @@ async function Ki({
|
|
|
3491
3497
|
})
|
|
3492
3498
|
});
|
|
3493
3499
|
}
|
|
3494
|
-
async function
|
|
3500
|
+
async function Vi({
|
|
3495
3501
|
apiURI: n,
|
|
3496
3502
|
appId: e,
|
|
3497
3503
|
path: t,
|
|
@@ -3512,7 +3518,7 @@ async function zi({
|
|
|
3512
3518
|
body: r
|
|
3513
3519
|
});
|
|
3514
3520
|
}
|
|
3515
|
-
async function
|
|
3521
|
+
async function Qi({
|
|
3516
3522
|
apiURI: n,
|
|
3517
3523
|
appId: e,
|
|
3518
3524
|
path: t,
|
|
@@ -3530,7 +3536,7 @@ async function Wi({
|
|
|
3530
3536
|
);
|
|
3531
3537
|
return s;
|
|
3532
3538
|
}
|
|
3533
|
-
async function
|
|
3539
|
+
async function Bi({
|
|
3534
3540
|
apiURI: n,
|
|
3535
3541
|
appId: e,
|
|
3536
3542
|
fileName: t,
|
|
@@ -3550,7 +3556,7 @@ async function Vi({
|
|
|
3550
3556
|
});
|
|
3551
3557
|
return i;
|
|
3552
3558
|
}
|
|
3553
|
-
async function
|
|
3559
|
+
async function Gi(n, e) {
|
|
3554
3560
|
return (await fetch(n, {
|
|
3555
3561
|
method: "PUT",
|
|
3556
3562
|
body: e,
|
|
@@ -3559,7 +3565,7 @@ async function Qi(n, e) {
|
|
|
3559
3565
|
}
|
|
3560
3566
|
})).ok;
|
|
3561
3567
|
}
|
|
3562
|
-
async function
|
|
3568
|
+
async function Hi({
|
|
3563
3569
|
apiURI: n,
|
|
3564
3570
|
appId: e,
|
|
3565
3571
|
path: t,
|
|
@@ -3579,39 +3585,39 @@ async function Bi({
|
|
|
3579
3585
|
);
|
|
3580
3586
|
return s;
|
|
3581
3587
|
}
|
|
3582
|
-
let
|
|
3583
|
-
typeof window < "u" && typeof window.localStorage < "u" && (
|
|
3584
|
-
function
|
|
3588
|
+
let Lt = !1, tr = !1, nr = !1;
|
|
3589
|
+
typeof window < "u" && typeof window.localStorage < "u" && (Lt = !!window.localStorage.getItem("devBackend"), tr = !!window.localStorage.getItem("__instantLogging"), nr = !!window.localStorage.getItem("__devtoolLocalDash"));
|
|
3590
|
+
function sn(n, e) {
|
|
3585
3591
|
if (!e) return n;
|
|
3586
3592
|
const t = {};
|
|
3587
3593
|
return e.forEach((r) => {
|
|
3588
3594
|
t[r] = n[r];
|
|
3589
3595
|
}), t;
|
|
3590
3596
|
}
|
|
3591
|
-
function
|
|
3597
|
+
function Ji(n, e, t) {
|
|
3592
3598
|
const r = {
|
|
3593
3599
|
peers: {}
|
|
3594
3600
|
};
|
|
3595
3601
|
if (e && "user" in e ? e.user : !0) {
|
|
3596
|
-
const i =
|
|
3602
|
+
const i = sn(n.user ?? {}, e?.keys);
|
|
3597
3603
|
r.user = { ...i, peerId: t };
|
|
3598
3604
|
}
|
|
3599
3605
|
for (const i of Object.keys(n.peers ?? {})) {
|
|
3600
3606
|
const o = e?.peers === void 0, a = Array.isArray(e?.peers) && e?.peers.includes(i);
|
|
3601
3607
|
if (o || a) {
|
|
3602
|
-
const c =
|
|
3608
|
+
const c = sn(n.peers[i], e?.keys);
|
|
3603
3609
|
r.peers[i] = { ...c, peerId: i };
|
|
3604
3610
|
}
|
|
3605
3611
|
}
|
|
3606
3612
|
return r;
|
|
3607
3613
|
}
|
|
3608
|
-
function
|
|
3609
|
-
if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !
|
|
3614
|
+
function Yi(n, e) {
|
|
3615
|
+
if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !zt(n.user, e.user)) || !En(n.peers, e.peers)) return !0;
|
|
3610
3616
|
for (const r of Object.keys(n.peers))
|
|
3611
|
-
if (!
|
|
3617
|
+
if (!zt(n.peers[r], e.peers[r])) return !0;
|
|
3612
3618
|
return !1;
|
|
3613
3619
|
}
|
|
3614
|
-
class
|
|
3620
|
+
class on {
|
|
3615
3621
|
promise;
|
|
3616
3622
|
_resolve;
|
|
3617
3623
|
_reject;
|
|
@@ -3627,20 +3633,20 @@ class rn {
|
|
|
3627
3633
|
this._reject(e);
|
|
3628
3634
|
}
|
|
3629
3635
|
}
|
|
3630
|
-
function
|
|
3636
|
+
function rr(n, e = []) {
|
|
3631
3637
|
n.forEach((t) => {
|
|
3632
3638
|
const { data: r } = t, { "datalog-result": s } = r, { "join-rows": i } = s;
|
|
3633
3639
|
for (const o of i)
|
|
3634
3640
|
for (const a of o)
|
|
3635
3641
|
e.push(a);
|
|
3636
|
-
|
|
3642
|
+
rr(t["child-nodes"], e);
|
|
3637
3643
|
});
|
|
3638
3644
|
}
|
|
3639
|
-
function
|
|
3645
|
+
function an(n) {
|
|
3640
3646
|
const e = [];
|
|
3641
|
-
return
|
|
3647
|
+
return rr(n, e), e;
|
|
3642
3648
|
}
|
|
3643
|
-
function
|
|
3649
|
+
function vt(n) {
|
|
3644
3650
|
return Object.values(n.links).reduce((e, t) => (e[t.forward.on] ??= {}, e[t.forward.on][t.forward.label] = {
|
|
3645
3651
|
isForward: !0,
|
|
3646
3652
|
isSingular: t.forward.has === "one",
|
|
@@ -3651,8 +3657,8 @@ function St(n) {
|
|
|
3651
3657
|
link: t
|
|
3652
3658
|
}, e), {});
|
|
3653
3659
|
}
|
|
3654
|
-
const
|
|
3655
|
-
function
|
|
3660
|
+
const sr = "v0.22.168";
|
|
3661
|
+
function Zi(n, e) {
|
|
3656
3662
|
return {
|
|
3657
3663
|
info: n ? (...t) => console.info(...t, e()) : () => {
|
|
3658
3664
|
},
|
|
@@ -3717,15 +3723,15 @@ class W {
|
|
|
3717
3723
|
// });
|
|
3718
3724
|
// }
|
|
3719
3725
|
}
|
|
3720
|
-
class
|
|
3726
|
+
class Ze {
|
|
3721
3727
|
constructor(e, t) {
|
|
3722
3728
|
this.attrs = e, this.links = t;
|
|
3723
3729
|
}
|
|
3724
3730
|
asType() {
|
|
3725
|
-
return new
|
|
3731
|
+
return new Ze(this.attrs, this.links);
|
|
3726
3732
|
}
|
|
3727
3733
|
}
|
|
3728
|
-
class
|
|
3734
|
+
class Xe {
|
|
3729
3735
|
constructor(e, t, r) {
|
|
3730
3736
|
this.entities = e, this.links = t, this.rooms = r;
|
|
3731
3737
|
}
|
|
@@ -3749,7 +3755,7 @@ class Ze {
|
|
|
3749
3755
|
* @see https://instantdb.com/docs/presence-and-topics#typesafety
|
|
3750
3756
|
*/
|
|
3751
3757
|
withRoomSchema() {
|
|
3752
|
-
return new
|
|
3758
|
+
return new Xe(
|
|
3753
3759
|
this.entities,
|
|
3754
3760
|
this.links,
|
|
3755
3761
|
{}
|
|
@@ -3762,7 +3768,7 @@ class C extends Error {
|
|
|
3762
3768
|
super(r), this.name = "QueryValidationError";
|
|
3763
3769
|
}
|
|
3764
3770
|
}
|
|
3765
|
-
const
|
|
3771
|
+
const cn = [
|
|
3766
3772
|
"where",
|
|
3767
3773
|
"order",
|
|
3768
3774
|
"limit",
|
|
@@ -3775,7 +3781,7 @@ const on = [
|
|
|
3775
3781
|
"beforeInclusive",
|
|
3776
3782
|
"fields",
|
|
3777
3783
|
"aggregate"
|
|
3778
|
-
],
|
|
3784
|
+
], Xi = (n) => n.valueType || "unknown", ir = (n, e, t = !1) => {
|
|
3779
3785
|
if (t || n == null) return !0;
|
|
3780
3786
|
switch (e) {
|
|
3781
3787
|
case "string":
|
|
@@ -3789,9 +3795,9 @@ const on = [
|
|
|
3789
3795
|
default:
|
|
3790
3796
|
return !0;
|
|
3791
3797
|
}
|
|
3792
|
-
},
|
|
3798
|
+
}, eo = (n, e, t, r, s, i, o) => {
|
|
3793
3799
|
const a = i.valueType === "json", c = (u, l, f) => {
|
|
3794
|
-
if (!
|
|
3800
|
+
if (!ir(f, l, a))
|
|
3795
3801
|
throw new C(
|
|
3796
3802
|
`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`,
|
|
3797
3803
|
o
|
|
@@ -3834,13 +3840,13 @@ const on = [
|
|
|
3834
3840
|
);
|
|
3835
3841
|
}
|
|
3836
3842
|
}, Se = (n, e, t, r, s) => {
|
|
3837
|
-
const i =
|
|
3843
|
+
const i = Xi(t), o = t.valueType === "json";
|
|
3838
3844
|
if (typeof n == "object" && n !== null && !Array.isArray(n)) {
|
|
3839
3845
|
if (o)
|
|
3840
3846
|
return;
|
|
3841
3847
|
const c = n;
|
|
3842
3848
|
for (const [u, l] of Object.entries(c))
|
|
3843
|
-
|
|
3849
|
+
eo(
|
|
3844
3850
|
u,
|
|
3845
3851
|
l,
|
|
3846
3852
|
i,
|
|
@@ -3849,12 +3855,12 @@ const on = [
|
|
|
3849
3855
|
t,
|
|
3850
3856
|
`${s}.${u}`
|
|
3851
3857
|
);
|
|
3852
|
-
} else if (!
|
|
3858
|
+
} else if (!ir(n, i, o))
|
|
3853
3859
|
throw new C(
|
|
3854
3860
|
`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof n}`,
|
|
3855
3861
|
s
|
|
3856
3862
|
);
|
|
3857
|
-
},
|
|
3863
|
+
}, to = (n, e, t, r, s) => {
|
|
3858
3864
|
const i = n.split(".");
|
|
3859
3865
|
if (i.length < 2)
|
|
3860
3866
|
throw new C(
|
|
@@ -3924,12 +3930,12 @@ const on = [
|
|
|
3924
3930
|
);
|
|
3925
3931
|
}
|
|
3926
3932
|
Se(e, n, u, t, s);
|
|
3927
|
-
},
|
|
3933
|
+
}, or = (n, e, t, r) => {
|
|
3928
3934
|
for (const [s, i] of Object.entries(n)) {
|
|
3929
3935
|
if (s === "or" || s === "and") {
|
|
3930
3936
|
if (Array.isArray(i))
|
|
3931
3937
|
for (const u of i)
|
|
3932
|
-
typeof u == "object" && u !== null &&
|
|
3938
|
+
typeof u == "object" && u !== null && or(
|
|
3933
3939
|
u,
|
|
3934
3940
|
e,
|
|
3935
3941
|
t,
|
|
@@ -3948,7 +3954,7 @@ const on = [
|
|
|
3948
3954
|
continue;
|
|
3949
3955
|
}
|
|
3950
3956
|
if (s.includes(".")) {
|
|
3951
|
-
|
|
3957
|
+
to(
|
|
3952
3958
|
s,
|
|
3953
3959
|
i,
|
|
3954
3960
|
e,
|
|
@@ -3991,11 +3997,11 @@ const on = [
|
|
|
3991
3997
|
);
|
|
3992
3998
|
}
|
|
3993
3999
|
}
|
|
3994
|
-
},
|
|
4000
|
+
}, no = (n, e, t, r, s = 0) => {
|
|
3995
4001
|
for (const o of Object.keys(n))
|
|
3996
|
-
if (!
|
|
4002
|
+
if (!cn.includes(o))
|
|
3997
4003
|
throw new C(
|
|
3998
|
-
`Invalid query parameter '${o}' in $ object. Valid parameters are: ${
|
|
4004
|
+
`Invalid query parameter '${o}' in $ object. Valid parameters are: ${cn.join(", ")}. Found: ${o}`,
|
|
3999
4005
|
r
|
|
4000
4006
|
);
|
|
4001
4007
|
const i = [
|
|
@@ -4020,14 +4026,14 @@ const on = [
|
|
|
4020
4026
|
`'where' clause must be an object in entity '${e}', but received: ${typeof n.where}`,
|
|
4021
4027
|
r ? `${r}.where` : void 0
|
|
4022
4028
|
);
|
|
4023
|
-
|
|
4029
|
+
or(
|
|
4024
4030
|
n.where,
|
|
4025
4031
|
e,
|
|
4026
4032
|
t,
|
|
4027
4033
|
r ? `${r}.where` : "where"
|
|
4028
4034
|
);
|
|
4029
4035
|
}
|
|
4030
|
-
},
|
|
4036
|
+
}, ar = (n, e, t, r, s = 0) => {
|
|
4031
4037
|
if (!n || typeof n != "object")
|
|
4032
4038
|
throw new C(
|
|
4033
4039
|
`Query part for entity '${e}' must be an object, but received: ${typeof n}`,
|
|
@@ -4045,7 +4051,7 @@ const on = [
|
|
|
4045
4051
|
const o = n[i];
|
|
4046
4052
|
if (typeof o == "object" && o !== null) {
|
|
4047
4053
|
const a = t?.entities[e].links[i]?.entityName;
|
|
4048
|
-
a &&
|
|
4054
|
+
a && ar(
|
|
4049
4055
|
o,
|
|
4050
4056
|
a,
|
|
4051
4057
|
t,
|
|
@@ -4060,7 +4066,7 @@ const on = [
|
|
|
4060
4066
|
`Query parameter '$' must be an object in entity '${e}', but received: ${typeof o}`,
|
|
4061
4067
|
`${r}.$`
|
|
4062
4068
|
);
|
|
4063
|
-
|
|
4069
|
+
no(
|
|
4064
4070
|
o,
|
|
4065
4071
|
e,
|
|
4066
4072
|
t,
|
|
@@ -4068,7 +4074,7 @@ const on = [
|
|
|
4068
4074
|
s
|
|
4069
4075
|
);
|
|
4070
4076
|
}
|
|
4071
|
-
},
|
|
4077
|
+
}, un = (n, e) => {
|
|
4072
4078
|
if (typeof n != "object" || n === null)
|
|
4073
4079
|
throw new C(
|
|
4074
4080
|
`Query must be an object, but received: ${typeof n}${n === null ? " (null)" : ""}`
|
|
@@ -4097,7 +4103,7 @@ const on = [
|
|
|
4097
4103
|
r
|
|
4098
4104
|
);
|
|
4099
4105
|
}
|
|
4100
|
-
|
|
4106
|
+
ar(
|
|
4101
4107
|
t[r],
|
|
4102
4108
|
r,
|
|
4103
4109
|
e,
|
|
@@ -4107,27 +4113,27 @@ const on = [
|
|
|
4107
4113
|
);
|
|
4108
4114
|
}
|
|
4109
4115
|
}
|
|
4110
|
-
},
|
|
4116
|
+
}, ln = (n) => typeof n != "string" ? !1 : He(n) ? !0 : Te(n);
|
|
4111
4117
|
class X extends Error {
|
|
4112
4118
|
constructor(e) {
|
|
4113
4119
|
super(e), this.name = "TransactionValidationError";
|
|
4114
4120
|
}
|
|
4115
4121
|
}
|
|
4116
|
-
const
|
|
4117
|
-
`Entity '${n}' does not exist in schema. Available entities: ${
|
|
4118
|
-
),
|
|
4122
|
+
const cr = (n) => n.length > 0 ? n.join(", ") : "none", ro = (n, e) => new X(
|
|
4123
|
+
`Entity '${n}' does not exist in schema. Available entities: ${cr(e)}`
|
|
4124
|
+
), so = {
|
|
4119
4125
|
string: (n) => typeof n == "string",
|
|
4120
4126
|
number: (n) => typeof n == "number" && !isNaN(n),
|
|
4121
4127
|
boolean: (n) => typeof n == "boolean",
|
|
4122
4128
|
date: (n) => n instanceof Date || typeof n == "string" || typeof n == "number",
|
|
4123
4129
|
json: () => !0
|
|
4124
|
-
},
|
|
4130
|
+
}, io = (n, e) => n == null ? !0 : so[e.valueType]?.(n) ?? !1, ur = (n, e) => {
|
|
4125
4131
|
const t = e.entities[n];
|
|
4126
4132
|
if (!t)
|
|
4127
|
-
throw
|
|
4133
|
+
throw ro(n, Object.keys(e.entities));
|
|
4128
4134
|
return t;
|
|
4129
|
-
},
|
|
4130
|
-
const r =
|
|
4135
|
+
}, rt = (n, e, t) => {
|
|
4136
|
+
const r = ur(n, t);
|
|
4131
4137
|
if (typeof e != "object" || e === null)
|
|
4132
4138
|
throw new X(
|
|
4133
4139
|
`Arguments for data operation on entity '${n}' must be an object, but received: ${typeof e}`
|
|
@@ -4135,13 +4141,13 @@ const or = (n) => n.length > 0 ? n.join(", ") : "none", to = (n, e) => new X(
|
|
|
4135
4141
|
for (const [s, i] of Object.entries(e)) {
|
|
4136
4142
|
if (s === "id") continue;
|
|
4137
4143
|
const o = r.attrs[s];
|
|
4138
|
-
if (o && !
|
|
4144
|
+
if (o && !io(i, o))
|
|
4139
4145
|
throw new X(
|
|
4140
4146
|
`Invalid value for attribute '${s}' in entity '${n}'. Expected ${o.valueType}, but received: ${typeof i}`
|
|
4141
4147
|
);
|
|
4142
4148
|
}
|
|
4143
|
-
},
|
|
4144
|
-
const r =
|
|
4149
|
+
}, dn = (n, e, t) => {
|
|
4150
|
+
const r = ur(n, t);
|
|
4145
4151
|
if (typeof e != "object" || e === null)
|
|
4146
4152
|
throw new X(
|
|
4147
4153
|
`Arguments for link operation on entity '${n}' must be an object, but received: ${typeof e}`
|
|
@@ -4150,31 +4156,31 @@ const or = (n) => n.length > 0 ? n.join(", ") : "none", to = (n, e) => new X(
|
|
|
4150
4156
|
if (!r.links[s]) {
|
|
4151
4157
|
const a = Object.keys(r.links);
|
|
4152
4158
|
throw new X(
|
|
4153
|
-
`Link '${s}' does not exist on entity '${n}'. Available links: ${
|
|
4159
|
+
`Link '${s}' does not exist on entity '${n}'. Available links: ${cr(a)}`
|
|
4154
4160
|
);
|
|
4155
4161
|
}
|
|
4156
4162
|
if (i != null) {
|
|
4157
4163
|
if (Array.isArray(i)) {
|
|
4158
4164
|
for (const a of i)
|
|
4159
|
-
if (!
|
|
4165
|
+
if (!ln(a))
|
|
4160
4166
|
throw new X(
|
|
4161
4167
|
`Invalid entity ID in link '${s}' for entity '${n}'. Expected a UUID or a lookup, but received: ${a}`
|
|
4162
4168
|
);
|
|
4163
|
-
} else if (!
|
|
4169
|
+
} else if (!ln(i))
|
|
4164
4170
|
throw new X(
|
|
4165
4171
|
`Invalid UUID in link '${s}' for entity '${n}'. Expected a UUID, but received: ${i}`
|
|
4166
4172
|
);
|
|
4167
4173
|
}
|
|
4168
4174
|
}
|
|
4169
|
-
},
|
|
4170
|
-
create:
|
|
4171
|
-
update:
|
|
4172
|
-
merge:
|
|
4173
|
-
link:
|
|
4174
|
-
unlink:
|
|
4175
|
+
}, oo = {
|
|
4176
|
+
create: rt,
|
|
4177
|
+
update: rt,
|
|
4178
|
+
merge: rt,
|
|
4179
|
+
link: dn,
|
|
4180
|
+
unlink: dn,
|
|
4175
4181
|
delete: () => {
|
|
4176
4182
|
}
|
|
4177
|
-
},
|
|
4183
|
+
}, ao = (n, e) => {
|
|
4178
4184
|
if (!e) return;
|
|
4179
4185
|
const [t, r, s, i] = n;
|
|
4180
4186
|
if (!Array.isArray(s) && !Te(s))
|
|
@@ -4185,9 +4191,9 @@ const or = (n) => n.length > 0 ? n.join(", ") : "none", to = (n, e) => new X(
|
|
|
4185
4191
|
throw new X(
|
|
4186
4192
|
`Entity name must be a string, but received: ${typeof r}`
|
|
4187
4193
|
);
|
|
4188
|
-
const o =
|
|
4194
|
+
const o = oo[t];
|
|
4189
4195
|
o && i !== void 0 && o(r, i, e);
|
|
4190
|
-
},
|
|
4196
|
+
}, co = (n, e) => {
|
|
4191
4197
|
const t = Array.isArray(n) ? n : [n];
|
|
4192
4198
|
for (const r of t) {
|
|
4193
4199
|
if (!r || typeof r != "object")
|
|
@@ -4203,12 +4209,12 @@ const or = (n) => n.length > 0 ? n.join(", ") : "none", to = (n, e) => new X(
|
|
|
4203
4209
|
throw new X(
|
|
4204
4210
|
`Transaction operation must be an array, but received: ${typeof s}`
|
|
4205
4211
|
);
|
|
4206
|
-
|
|
4212
|
+
ao(s, e);
|
|
4207
4213
|
}
|
|
4208
4214
|
}
|
|
4209
4215
|
};
|
|
4210
|
-
let
|
|
4211
|
-
class
|
|
4216
|
+
let lr = 0;
|
|
4217
|
+
class fn {
|
|
4212
4218
|
type = "ws";
|
|
4213
4219
|
conn;
|
|
4214
4220
|
id;
|
|
@@ -4217,7 +4223,7 @@ class ln {
|
|
|
4217
4223
|
onclose;
|
|
4218
4224
|
onerror;
|
|
4219
4225
|
constructor(e) {
|
|
4220
|
-
this.id = `${this.type}_${
|
|
4226
|
+
this.id = `${this.type}_${lr++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
|
|
4221
4227
|
this.onopen && this.onopen({ target: this });
|
|
4222
4228
|
}, this.conn.onmessage = (t) => {
|
|
4223
4229
|
this.onmessage && this.onmessage({
|
|
@@ -4243,7 +4249,7 @@ class ln {
|
|
|
4243
4249
|
return this.conn.send(JSON.stringify(e));
|
|
4244
4250
|
}
|
|
4245
4251
|
}
|
|
4246
|
-
class
|
|
4252
|
+
class uo {
|
|
4247
4253
|
type = "sse";
|
|
4248
4254
|
initParams = null;
|
|
4249
4255
|
sendQueue = [];
|
|
@@ -4260,7 +4266,7 @@ class ao {
|
|
|
4260
4266
|
onclose;
|
|
4261
4267
|
onerror;
|
|
4262
4268
|
constructor(e, t, r) {
|
|
4263
|
-
this.id = `${this.type}_${
|
|
4269
|
+
this.id = `${this.type}_${lr++}`, this.url = t, this.messageUrl = r || this.url, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
|
|
4264
4270
|
this.initParams || this.handleError();
|
|
4265
4271
|
}, 1e4), this.conn.onmessage = (s) => {
|
|
4266
4272
|
const i = JSON.parse(s.data);
|
|
@@ -4340,23 +4346,23 @@ class ao {
|
|
|
4340
4346
|
this.handleClose();
|
|
4341
4347
|
}
|
|
4342
4348
|
}
|
|
4343
|
-
function
|
|
4349
|
+
function lo(n, e) {
|
|
4344
4350
|
const t = n.values;
|
|
4345
4351
|
if (t) {
|
|
4346
|
-
const r =
|
|
4352
|
+
const r = Rn(t.attrsStore, null);
|
|
4347
4353
|
if (r) {
|
|
4348
4354
|
for (const s of t.entities || [])
|
|
4349
|
-
s.store.useDateObjects = e, s.store =
|
|
4355
|
+
s.store.useDateObjects = e, s.store = xn(r, s.store);
|
|
4350
4356
|
t.attrsStore = r;
|
|
4351
4357
|
}
|
|
4352
4358
|
}
|
|
4353
4359
|
return n;
|
|
4354
4360
|
}
|
|
4355
|
-
function
|
|
4361
|
+
function fo(n, e) {
|
|
4356
4362
|
if (e.values) {
|
|
4357
4363
|
const t = [];
|
|
4358
4364
|
for (const r of e.values?.entities) {
|
|
4359
|
-
const s =
|
|
4365
|
+
const s = $n(r.store);
|
|
4360
4366
|
t.push({ ...r, store: s });
|
|
4361
4367
|
}
|
|
4362
4368
|
return {
|
|
@@ -4366,35 +4372,35 @@ function uo(n, e) {
|
|
|
4366
4372
|
} else
|
|
4367
4373
|
return e;
|
|
4368
4374
|
}
|
|
4369
|
-
function
|
|
4375
|
+
function ho(n, e, t) {
|
|
4370
4376
|
const r = e?.state?.txId, s = t?.state?.txId;
|
|
4371
4377
|
return r && (!s || r > s) ? e : s && (!r || s > r) ? t : e || t;
|
|
4372
4378
|
}
|
|
4373
|
-
function
|
|
4374
|
-
return
|
|
4379
|
+
function st(n, e, t) {
|
|
4380
|
+
return Ut(
|
|
4375
4381
|
{ store: e, attrsStore: t, pageInfo: null, aggregate: null },
|
|
4376
4382
|
n.query
|
|
4377
4383
|
).data[n.table][0];
|
|
4378
4384
|
}
|
|
4379
|
-
function
|
|
4385
|
+
function hn(n, e, t, r) {
|
|
4380
4386
|
const s = U(t, n.table, "id")?.id;
|
|
4381
4387
|
if (!s)
|
|
4382
4388
|
return -1;
|
|
4383
4389
|
const i = Ae(e.eav, [r, s, r]);
|
|
4384
4390
|
return i ? i[3] : -1;
|
|
4385
4391
|
}
|
|
4386
|
-
function
|
|
4392
|
+
function pn(n, e, t) {
|
|
4387
4393
|
for (const { action: r, triple: s } of t)
|
|
4388
4394
|
switch (r) {
|
|
4389
4395
|
case "added":
|
|
4390
|
-
|
|
4396
|
+
Ln(n, e, s);
|
|
4391
4397
|
break;
|
|
4392
4398
|
case "removed":
|
|
4393
|
-
|
|
4399
|
+
Dn(n, e, s);
|
|
4394
4400
|
break;
|
|
4395
4401
|
}
|
|
4396
4402
|
}
|
|
4397
|
-
function
|
|
4403
|
+
function po(n, e, t) {
|
|
4398
4404
|
const r = {};
|
|
4399
4405
|
for (const { action: s, triple: i } of t) {
|
|
4400
4406
|
const [o, a, c] = i, u = e.getAttr(a)?.["forward-identity"]?.[2];
|
|
@@ -4420,13 +4426,13 @@ function fo(n, e, t) {
|
|
|
4420
4426
|
function Le(n, e) {
|
|
4421
4427
|
return { [n.table]: e.map((t) => t.entity) };
|
|
4422
4428
|
}
|
|
4423
|
-
function
|
|
4429
|
+
function yo(n, e) {
|
|
4424
4430
|
if (n.orderFieldType)
|
|
4425
4431
|
return n.orderFieldType;
|
|
4426
4432
|
const t = n.orderField === "serverCreatedAt" ? "number" : U(e(), n.table, n.orderField)?.["checked-data-type"];
|
|
4427
4433
|
return n.orderFieldType = t, t;
|
|
4428
4434
|
}
|
|
4429
|
-
function
|
|
4435
|
+
function bo(n, e, t) {
|
|
4430
4436
|
const r = e;
|
|
4431
4437
|
if (n.orderField === "serverCreatedAt") {
|
|
4432
4438
|
t.sort(
|
|
@@ -4471,8 +4477,8 @@ function po(n, e, t) {
|
|
|
4471
4477
|
}
|
|
4472
4478
|
);
|
|
4473
4479
|
}
|
|
4474
|
-
var
|
|
4475
|
-
class
|
|
4480
|
+
var go = /* @__PURE__ */ ((n) => (n.InitialSyncBatch = "InitialSyncBatch", n.InitialSyncComplete = "InitialSyncComplete", n.LoadFromStorage = "LoadFromStorage", n.SyncTransaction = "SyncTransaction", n.Error = "Error", n))(go || {});
|
|
4481
|
+
class mo {
|
|
4476
4482
|
trySend;
|
|
4477
4483
|
subs;
|
|
4478
4484
|
// Using any for the SyncCallback because we'd need Reactor to be typed
|
|
@@ -4483,11 +4489,11 @@ class bo {
|
|
|
4483
4489
|
createStore;
|
|
4484
4490
|
getAttrs;
|
|
4485
4491
|
constructor(e, t, r, s, i, o) {
|
|
4486
|
-
this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new
|
|
4492
|
+
this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new Tt({
|
|
4487
4493
|
persister: t,
|
|
4488
|
-
merge:
|
|
4489
|
-
serialize:
|
|
4490
|
-
parse: (a, c) =>
|
|
4494
|
+
merge: ho,
|
|
4495
|
+
serialize: fo,
|
|
4496
|
+
parse: (a, c) => lo(c, this.config.useDateObjects),
|
|
4491
4497
|
objectSize: (a) => a.values?.entities.length || 0,
|
|
4492
4498
|
logger: s,
|
|
4493
4499
|
gc: {
|
|
@@ -4614,11 +4620,11 @@ class bo {
|
|
|
4614
4620
|
o.values = a;
|
|
4615
4621
|
const c = a.entities;
|
|
4616
4622
|
for (const u of r) {
|
|
4617
|
-
const l = this.createStore(u), f =
|
|
4623
|
+
const l = this.createStore(u), f = st(o, l, a.attrsStore);
|
|
4618
4624
|
c.push({
|
|
4619
4625
|
store: l,
|
|
4620
4626
|
entity: f,
|
|
4621
|
-
serverCreatedAt:
|
|
4627
|
+
serverCreatedAt: hn(
|
|
4622
4628
|
o,
|
|
4623
4629
|
l,
|
|
4624
4630
|
a.attrsStore,
|
|
@@ -4691,9 +4697,9 @@ class bo {
|
|
|
4691
4697
|
e: for (const [m, g] of Object.entries(c))
|
|
4692
4698
|
for (let y = 0; y < l.length; y++) {
|
|
4693
4699
|
const b = l[y];
|
|
4694
|
-
if (
|
|
4695
|
-
|
|
4696
|
-
const _ =
|
|
4700
|
+
if (Gr(b.store, m)) {
|
|
4701
|
+
pn(b.store, u.attrsStore, g);
|
|
4702
|
+
const _ = st(s, b.store, u.attrsStore), M = po(
|
|
4697
4703
|
b.store,
|
|
4698
4704
|
u.attrsStore,
|
|
4699
4705
|
g
|
|
@@ -4709,8 +4715,8 @@ class bo {
|
|
|
4709
4715
|
const d = [];
|
|
4710
4716
|
for (const [m, g] of Object.entries(c)) {
|
|
4711
4717
|
const y = this.createStore([]);
|
|
4712
|
-
|
|
4713
|
-
const b =
|
|
4718
|
+
pn(y, u.attrsStore, g);
|
|
4719
|
+
const b = st(s, y, u.attrsStore);
|
|
4714
4720
|
if (!b) {
|
|
4715
4721
|
this.log.error("No entity found after applying change", {
|
|
4716
4722
|
sub: s,
|
|
@@ -4722,7 +4728,7 @@ class bo {
|
|
|
4722
4728
|
l.push({
|
|
4723
4729
|
store: y,
|
|
4724
4730
|
entity: b,
|
|
4725
|
-
serverCreatedAt:
|
|
4731
|
+
serverCreatedAt: hn(
|
|
4726
4732
|
s,
|
|
4727
4733
|
y,
|
|
4728
4734
|
u.attrsStore,
|
|
@@ -4733,8 +4739,8 @@ class bo {
|
|
|
4733
4739
|
const h = [];
|
|
4734
4740
|
for (const m of a.sort().reverse())
|
|
4735
4741
|
h.push(l[m].entity), l.splice(m, 1);
|
|
4736
|
-
const p =
|
|
4737
|
-
|
|
4742
|
+
const p = yo(s, this.getAttrs);
|
|
4743
|
+
bo(s, p, l), this.notifyCbs(r, {
|
|
4738
4744
|
type: "SyncTransaction",
|
|
4739
4745
|
data: Le(s, s.values?.entities),
|
|
4740
4746
|
added: d,
|
|
@@ -4775,7 +4781,7 @@ class bo {
|
|
|
4775
4781
|
r && this.initSubscription(r.query, r.hash);
|
|
4776
4782
|
}
|
|
4777
4783
|
}
|
|
4778
|
-
function
|
|
4784
|
+
function wo({
|
|
4779
4785
|
WStream: n,
|
|
4780
4786
|
opts: e,
|
|
4781
4787
|
startStream: t,
|
|
@@ -4833,14 +4839,14 @@ function go({
|
|
|
4833
4839
|
m = !0;
|
|
4834
4840
|
}
|
|
4835
4841
|
function I(S) {
|
|
4836
|
-
let k = g,
|
|
4842
|
+
let k = g, q = 0, V = 0;
|
|
4837
4843
|
for (const { byteLen: te } of b) {
|
|
4838
4844
|
const ae = k + te;
|
|
4839
4845
|
if (ae > S)
|
|
4840
4846
|
break;
|
|
4841
|
-
k = ae,
|
|
4847
|
+
k = ae, q++, V += te;
|
|
4842
4848
|
}
|
|
4843
|
-
|
|
4849
|
+
q > 0 && (g += V, y -= V, b.splice(0, q));
|
|
4844
4850
|
}
|
|
4845
4851
|
function v(S, k) {
|
|
4846
4852
|
a = k, M(), S.error(k), P();
|
|
@@ -4853,8 +4859,8 @@ function go({
|
|
|
4853
4859
|
});
|
|
4854
4860
|
switch (S.type) {
|
|
4855
4861
|
case "ok": {
|
|
4856
|
-
const { streamId: k, offset:
|
|
4857
|
-
o = k, I(
|
|
4862
|
+
const { streamId: k, offset: q } = S;
|
|
4863
|
+
o = k, I(q), b.length && r({
|
|
4858
4864
|
streamId: k,
|
|
4859
4865
|
chunks: b.map((V) => V.chunk),
|
|
4860
4866
|
offset: g
|
|
@@ -4878,13 +4884,13 @@ function go({
|
|
|
4878
4884
|
I(S), k && (l = !0, P());
|
|
4879
4885
|
}
|
|
4880
4886
|
function J(S) {
|
|
4881
|
-
return l ? (v(S, new
|
|
4887
|
+
return l ? (v(S, new K("Stream has been closed.")), null) : o || (v(S, new K("Stream has not been initialized.")), null);
|
|
4882
4888
|
}
|
|
4883
4889
|
async function ee(S) {
|
|
4884
4890
|
c = S;
|
|
4885
|
-
let k = !0,
|
|
4891
|
+
let k = !0, q = 0;
|
|
4886
4892
|
for (; k; ) {
|
|
4887
|
-
let V = Date.now() + Math.min(15e3, 500 * (
|
|
4893
|
+
let V = Date.now() + Math.min(15e3, 500 * (q - 1));
|
|
4888
4894
|
k = !1;
|
|
4889
4895
|
const te = await t({
|
|
4890
4896
|
clientId: e.clientId,
|
|
@@ -4893,9 +4899,9 @@ function go({
|
|
|
4893
4899
|
});
|
|
4894
4900
|
switch (te.type) {
|
|
4895
4901
|
case "ok": {
|
|
4896
|
-
const { streamId: ae, offset:
|
|
4897
|
-
if (
|
|
4898
|
-
const de = new
|
|
4902
|
+
const { streamId: ae, offset: et } = te;
|
|
4903
|
+
if (et !== 0) {
|
|
4904
|
+
const de = new K("Write stream is corrupted");
|
|
4899
4905
|
v(S, de);
|
|
4900
4906
|
return;
|
|
4901
4907
|
}
|
|
@@ -4908,7 +4914,7 @@ function go({
|
|
|
4908
4914
|
return;
|
|
4909
4915
|
}
|
|
4910
4916
|
case "disconnect": {
|
|
4911
|
-
k = !0, T(),
|
|
4917
|
+
k = !0, T(), q++, await new Promise((ae) => {
|
|
4912
4918
|
setTimeout(ae, Math.max(0, V - Date.now()));
|
|
4913
4919
|
});
|
|
4914
4920
|
break;
|
|
@@ -4920,26 +4926,26 @@ function go({
|
|
|
4920
4926
|
}
|
|
4921
4927
|
}
|
|
4922
4928
|
}
|
|
4923
|
-
class
|
|
4924
|
-
constructor(k,
|
|
4925
|
-
super(k,
|
|
4929
|
+
class pr extends n {
|
|
4930
|
+
constructor(k, q) {
|
|
4931
|
+
super(k, q);
|
|
4926
4932
|
}
|
|
4927
4933
|
async streamId() {
|
|
4928
|
-
return o || new Promise((k,
|
|
4934
|
+
return o || new Promise((k, q) => {
|
|
4929
4935
|
const V = [], te = () => {
|
|
4930
4936
|
for (const de of V)
|
|
4931
4937
|
de();
|
|
4932
4938
|
}, ae = (de) => {
|
|
4933
4939
|
k(de), te();
|
|
4934
|
-
},
|
|
4935
|
-
|
|
4940
|
+
}, et = (de) => {
|
|
4941
|
+
q(de || new K("Stream is closed.")), te();
|
|
4936
4942
|
};
|
|
4937
|
-
V.push(N(ae)), V.push(w(
|
|
4943
|
+
V.push(N(ae)), V.push(w(et));
|
|
4938
4944
|
});
|
|
4939
4945
|
}
|
|
4940
4946
|
}
|
|
4941
4947
|
return {
|
|
4942
|
-
stream: new
|
|
4948
|
+
stream: new pr({
|
|
4943
4949
|
// TODO(dww): accept a storage so that write streams can survive across
|
|
4944
4950
|
// browser restarts
|
|
4945
4951
|
async start(S) {
|
|
@@ -4950,12 +4956,12 @@ function go({
|
|
|
4950
4956
|
}
|
|
4951
4957
|
},
|
|
4952
4958
|
write(S, k) {
|
|
4953
|
-
const
|
|
4954
|
-
if (
|
|
4959
|
+
const q = J(k);
|
|
4960
|
+
if (q) {
|
|
4955
4961
|
const V = _.encode(S).length;
|
|
4956
4962
|
b.push({ chunk: S, byteLen: V });
|
|
4957
4963
|
const te = g + y;
|
|
4958
|
-
y += V, m || r({ streamId:
|
|
4964
|
+
y += V, m || r({ streamId: q, chunks: [S], offset: te });
|
|
4959
4965
|
}
|
|
4960
4966
|
},
|
|
4961
4967
|
close() {
|
|
@@ -4982,7 +4988,7 @@ function go({
|
|
|
4982
4988
|
}
|
|
4983
4989
|
};
|
|
4984
4990
|
}
|
|
4985
|
-
class
|
|
4991
|
+
class _o {
|
|
4986
4992
|
items = [];
|
|
4987
4993
|
resolvers = [];
|
|
4988
4994
|
isClosed = !1;
|
|
@@ -5015,7 +5021,7 @@ class mo {
|
|
|
5015
5021
|
}
|
|
5016
5022
|
}
|
|
5017
5023
|
}
|
|
5018
|
-
function
|
|
5024
|
+
function So({
|
|
5019
5025
|
RStream: n,
|
|
5020
5026
|
opts: e,
|
|
5021
5027
|
startStream: t,
|
|
@@ -5053,7 +5059,7 @@ function wo({
|
|
|
5053
5059
|
return;
|
|
5054
5060
|
}
|
|
5055
5061
|
if (w.offset > s) {
|
|
5056
|
-
h(_, new
|
|
5062
|
+
h(_, new K("Stream is corrupted.")), i = !0;
|
|
5057
5063
|
return;
|
|
5058
5064
|
}
|
|
5059
5065
|
let E = s - w.offset;
|
|
@@ -5066,7 +5072,7 @@ function wo({
|
|
|
5066
5072
|
const T = w.files[H + 1], v = await N;
|
|
5067
5073
|
if (T && (N = fetch(T.url, { signal: P.signal })), !v.ok) {
|
|
5068
5074
|
if (p++, p > 10) {
|
|
5069
|
-
h(_, new
|
|
5075
|
+
h(_, new K("Unable to process stream."));
|
|
5070
5076
|
return;
|
|
5071
5077
|
}
|
|
5072
5078
|
return { retry: !0 };
|
|
@@ -5148,7 +5154,7 @@ function wo({
|
|
|
5148
5154
|
}
|
|
5149
5155
|
};
|
|
5150
5156
|
}
|
|
5151
|
-
class
|
|
5157
|
+
class To {
|
|
5152
5158
|
trySend;
|
|
5153
5159
|
WStream;
|
|
5154
5160
|
RStream;
|
|
@@ -5166,7 +5172,7 @@ class _o {
|
|
|
5166
5172
|
this.WStream = e, this.RStream = t, this.trySend = r, this.log = s;
|
|
5167
5173
|
}
|
|
5168
5174
|
createWriteStream(e) {
|
|
5169
|
-
const { stream: t, addCompleteCb: r } =
|
|
5175
|
+
const { stream: t, addCompleteCb: r } = wo({
|
|
5170
5176
|
WStream: this.WStream,
|
|
5171
5177
|
startStream: this.startWriteStream.bind(this),
|
|
5172
5178
|
appendStream: this.appendStream.bind(this),
|
|
@@ -5178,7 +5184,7 @@ class _o {
|
|
|
5178
5184
|
}), t;
|
|
5179
5185
|
}
|
|
5180
5186
|
createReadStream(e) {
|
|
5181
|
-
const { stream: t, addCloseCb: r } =
|
|
5187
|
+
const { stream: t, addCloseCb: r } = So({
|
|
5182
5188
|
RStream: this.RStream,
|
|
5183
5189
|
opts: e,
|
|
5184
5190
|
startStream: this.startReadStream.bind(this),
|
|
@@ -5254,7 +5260,7 @@ class _o {
|
|
|
5254
5260
|
"Must provide one of streamId or clientId to subscribe to the stream."
|
|
5255
5261
|
);
|
|
5256
5262
|
r && (o["stream-id"] = r), t && (o["client-id"] = t), s && (o.offset = s), i && (o["rule-params"] = i);
|
|
5257
|
-
const a = new
|
|
5263
|
+
const a = new _o();
|
|
5258
5264
|
return this.readStreamIterators[e] = a, this.trySend(e, o), a;
|
|
5259
5265
|
}
|
|
5260
5266
|
cancelReadStream({ eventId: e }) {
|
|
@@ -5273,7 +5279,7 @@ class _o {
|
|
|
5273
5279
|
if (e.error) {
|
|
5274
5280
|
e.retry ? r.push({ type: "reconnect" }) : r.push({
|
|
5275
5281
|
type: "error",
|
|
5276
|
-
error: new
|
|
5282
|
+
error: new K(e.error)
|
|
5277
5283
|
}), r.close(), delete this.readStreamIterators[t];
|
|
5278
5284
|
return;
|
|
5279
5285
|
}
|
|
@@ -5312,7 +5318,7 @@ class _o {
|
|
|
5312
5318
|
const r = e["client-event-id"], s = this.startWriteStreamCbs[r];
|
|
5313
5319
|
s && (s({
|
|
5314
5320
|
type: "error",
|
|
5315
|
-
error: new
|
|
5321
|
+
error: new K(e.message || "Unknown error", e.hint)
|
|
5316
5322
|
}), delete this.startWriteStreamCbs[r]);
|
|
5317
5323
|
break;
|
|
5318
5324
|
}
|
|
@@ -5320,7 +5326,7 @@ class _o {
|
|
|
5320
5326
|
const r = e["client-event-id"], s = this.readStreamIterators[r];
|
|
5321
5327
|
s && (s.push({
|
|
5322
5328
|
type: "error",
|
|
5323
|
-
error: new
|
|
5329
|
+
error: new K(e.message || "Unknown error", e.hint)
|
|
5324
5330
|
}), s.close(), delete this.readStreamIterators[r]);
|
|
5325
5331
|
break;
|
|
5326
5332
|
}
|
|
@@ -5336,11 +5342,11 @@ const ie = {
|
|
|
5336
5342
|
AUTHENTICATED: "authenticated",
|
|
5337
5343
|
CLOSED: "closed",
|
|
5338
5344
|
ERRORED: "errored"
|
|
5339
|
-
},
|
|
5345
|
+
}, vo = 3e4, Ao = 3e4, ko = 200, Oo = 1e3 * 60, Io = {
|
|
5340
5346
|
apiURI: "https://api.instantdb.com",
|
|
5341
5347
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
5342
|
-
},
|
|
5343
|
-
function
|
|
5348
|
+
}, it = "_instant_oauth_redirect", ot = "_instant_extra_fields_id", Ne = "oauthExtraFields", be = "currentUser";
|
|
5349
|
+
function Co({
|
|
5344
5350
|
transportType: n,
|
|
5345
5351
|
appId: e,
|
|
5346
5352
|
apiURI: t,
|
|
@@ -5348,12 +5354,12 @@ function Oo({
|
|
|
5348
5354
|
EventSourceImpl: s
|
|
5349
5355
|
}) {
|
|
5350
5356
|
if (!s)
|
|
5351
|
-
return new
|
|
5357
|
+
return new fn(`${r}?app_id=${e}`);
|
|
5352
5358
|
switch (n) {
|
|
5353
5359
|
case "ws":
|
|
5354
|
-
return new
|
|
5360
|
+
return new fn(`${r}?app_id=${e}`);
|
|
5355
5361
|
case "sse":
|
|
5356
|
-
return new
|
|
5362
|
+
return new uo(
|
|
5357
5363
|
s,
|
|
5358
5364
|
`${t}/runtime/sse?app_id=${e}`
|
|
5359
5365
|
);
|
|
@@ -5361,25 +5367,25 @@ function Oo({
|
|
|
5361
5367
|
throw new Error("Unknown transport type " + n);
|
|
5362
5368
|
}
|
|
5363
5369
|
}
|
|
5364
|
-
function
|
|
5370
|
+
function Eo() {
|
|
5365
5371
|
return typeof window < "u" || typeof chrome < "u";
|
|
5366
5372
|
}
|
|
5367
|
-
const
|
|
5373
|
+
const yn = {
|
|
5368
5374
|
"set-presence": !0,
|
|
5369
5375
|
"set-presence-ok": !0,
|
|
5370
5376
|
"refresh-presence": !0,
|
|
5371
5377
|
"patch-presence": !0
|
|
5372
5378
|
};
|
|
5373
|
-
function
|
|
5379
|
+
function Mo(n, e) {
|
|
5374
5380
|
const t = typeof n == "string" ? JSON.parse(n) : n;
|
|
5375
5381
|
if (t?.result?.store) {
|
|
5376
|
-
const r =
|
|
5382
|
+
const r = Rn(
|
|
5377
5383
|
t.result.attrsStore,
|
|
5378
5384
|
t.result.store
|
|
5379
5385
|
);
|
|
5380
5386
|
if (r) {
|
|
5381
5387
|
const s = t.result.store;
|
|
5382
|
-
t.result.store =
|
|
5388
|
+
t.result.store = xn(r, {
|
|
5383
5389
|
...s,
|
|
5384
5390
|
useDateObjects: e
|
|
5385
5391
|
}), t.result.attrsStore = r;
|
|
@@ -5387,7 +5393,7 @@ function Co(n, e) {
|
|
|
5387
5393
|
}
|
|
5388
5394
|
return t;
|
|
5389
5395
|
}
|
|
5390
|
-
function
|
|
5396
|
+
function Po(n, e) {
|
|
5391
5397
|
const { result: t, ...r } = e, s = (
|
|
5392
5398
|
/** @type {import('./reactorTypes.ts').QuerySubInStorage} */
|
|
5393
5399
|
r
|
|
@@ -5395,30 +5401,30 @@ function Eo(n, e) {
|
|
|
5395
5401
|
if (t) {
|
|
5396
5402
|
const i = {
|
|
5397
5403
|
...t,
|
|
5398
|
-
store:
|
|
5404
|
+
store: $n(t.store),
|
|
5399
5405
|
attrsStore: t.attrsStore.toJSON()
|
|
5400
5406
|
};
|
|
5401
5407
|
s.result = i;
|
|
5402
5408
|
}
|
|
5403
5409
|
return s;
|
|
5404
5410
|
}
|
|
5405
|
-
function
|
|
5411
|
+
function jo(n, e) {
|
|
5406
5412
|
return n === "pendingMutations" ? new Map(typeof e == "string" ? JSON.parse(e) : e) : e;
|
|
5407
5413
|
}
|
|
5408
|
-
function
|
|
5414
|
+
function $o(n, e) {
|
|
5409
5415
|
return n === "pendingMutations" ? [...e.entries()] : e;
|
|
5410
5416
|
}
|
|
5411
|
-
function
|
|
5417
|
+
function xo(n, e, t) {
|
|
5412
5418
|
const r = e?.result, s = t?.result;
|
|
5413
5419
|
return r && !s && t && (t.result = r), t || e;
|
|
5414
5420
|
}
|
|
5415
|
-
function
|
|
5421
|
+
function at(n) {
|
|
5416
5422
|
return [...n].sort((e, t) => {
|
|
5417
5423
|
const [r, s] = e, [i, o] = t, a = s.order || 0, c = o.order || 0;
|
|
5418
5424
|
return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
|
|
5419
5425
|
});
|
|
5420
5426
|
}
|
|
5421
|
-
class
|
|
5427
|
+
class Ro {
|
|
5422
5428
|
/** @type {s.AttrsStore | undefined} */
|
|
5423
5429
|
attrs;
|
|
5424
5430
|
_isOnline = !0;
|
|
@@ -5478,11 +5484,11 @@ class $o {
|
|
|
5478
5484
|
_inFlightMutationEventIds = /* @__PURE__ */ new Set();
|
|
5479
5485
|
/** @type FrameworkClient | null */
|
|
5480
5486
|
_frameworkClient = null;
|
|
5481
|
-
constructor(e, t =
|
|
5482
|
-
if (this._EventSource = i, this.config = { ...
|
|
5483
|
-
e.verbose ||
|
|
5487
|
+
constructor(e, t = Xn, r = er, s, i) {
|
|
5488
|
+
if (this._EventSource = i, this.config = { ...Io, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ao, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? ko, this._log = Zi(
|
|
5489
|
+
e.verbose || Lt || tr,
|
|
5484
5490
|
() => this._reactorStats()
|
|
5485
|
-
), this.versions = { ...s || {}, "@instantdb/core":
|
|
5491
|
+
), this.versions = { ...s || {}, "@instantdb/core": sr }, this.config.schema && (this._linkIndex = vt(this.config.schema)), !!Eo()) {
|
|
5486
5492
|
if (!e.appId)
|
|
5487
5493
|
throw new Error("Instant must be initialized with an appId.");
|
|
5488
5494
|
if (!Te(e.appId))
|
|
@@ -5502,7 +5508,7 @@ class $o {
|
|
|
5502
5508
|
} catch (a) {
|
|
5503
5509
|
this._log.error("[error] handle broadcast channel", a);
|
|
5504
5510
|
}
|
|
5505
|
-
})), this._initStorage(t), this._syncTable = new
|
|
5511
|
+
})), this._initStorage(t), this._syncTable = new mo(
|
|
5506
5512
|
this._trySendAuthed.bind(this),
|
|
5507
5513
|
new t(this.config.appId, "syncSubs"),
|
|
5508
5514
|
{
|
|
@@ -5516,7 +5522,7 @@ class $o {
|
|
|
5516
5522
|
this.config.useDateObjects
|
|
5517
5523
|
),
|
|
5518
5524
|
() => this.ensureAttrs()
|
|
5519
|
-
), this._instantStream = new
|
|
5525
|
+
), this._instantStream = new To({
|
|
5520
5526
|
WStream: this.config.WritableStream || WritableStream,
|
|
5521
5527
|
RStream: this.config.ReadableStream || ReadableStream,
|
|
5522
5528
|
trySend: this._trySendAuthed.bind(this),
|
|
@@ -5526,7 +5532,7 @@ class $o {
|
|
|
5526
5532
|
}), setInterval(async () => {
|
|
5527
5533
|
const o = await this.getCurrentUser();
|
|
5528
5534
|
this.syncUserToEndpoint(o.user);
|
|
5529
|
-
},
|
|
5535
|
+
}, Oo), r.getIsOnline().then((o) => {
|
|
5530
5536
|
this._isOnline = o, this._startSocket(), r.listen((a) => {
|
|
5531
5537
|
a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info(
|
|
5532
5538
|
"Changing status from",
|
|
@@ -5555,7 +5561,7 @@ class $o {
|
|
|
5555
5561
|
...this.config,
|
|
5556
5562
|
schema: e,
|
|
5557
5563
|
cardinalityInference: !!e
|
|
5558
|
-
}, this._linkIndex = e ?
|
|
5564
|
+
}, this._linkIndex = e ? vt(this.config.schema) : null;
|
|
5559
5565
|
}
|
|
5560
5566
|
_reactorStats() {
|
|
5561
5567
|
return {
|
|
@@ -5568,11 +5574,11 @@ class $o {
|
|
|
5568
5574
|
this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
|
|
5569
5575
|
}
|
|
5570
5576
|
_initStorage(e) {
|
|
5571
|
-
this.querySubs = new
|
|
5577
|
+
this.querySubs = new Tt({
|
|
5572
5578
|
persister: new e(this.config.appId, "querySubs"),
|
|
5573
|
-
merge:
|
|
5574
|
-
serialize:
|
|
5575
|
-
parse: (t, r) =>
|
|
5579
|
+
merge: xo,
|
|
5580
|
+
serialize: Po,
|
|
5581
|
+
parse: (t, r) => Mo(r, this.config.useDateObjects),
|
|
5576
5582
|
// objectSize
|
|
5577
5583
|
objectSize: (t) => t?.result?.store?.triples?.length ?? 0,
|
|
5578
5584
|
logger: this._log,
|
|
@@ -5585,11 +5591,11 @@ class $o {
|
|
|
5585
5591
|
maxSize: 1e6
|
|
5586
5592
|
// 1 million triples
|
|
5587
5593
|
}
|
|
5588
|
-
}), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new
|
|
5594
|
+
}), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new Tt({
|
|
5589
5595
|
persister: new e(this.config.appId, "kv"),
|
|
5590
5596
|
merge: this._onMergeKv,
|
|
5591
|
-
serialize:
|
|
5592
|
-
parse:
|
|
5597
|
+
serialize: $o,
|
|
5598
|
+
parse: jo,
|
|
5593
5599
|
objectSize: () => 0,
|
|
5594
5600
|
logger: this._log,
|
|
5595
5601
|
saveThrottleMs: 100,
|
|
@@ -5630,7 +5636,7 @@ class $o {
|
|
|
5630
5636
|
);
|
|
5631
5637
|
} else
|
|
5632
5638
|
s.reject(
|
|
5633
|
-
new
|
|
5639
|
+
new K(
|
|
5634
5640
|
r?.message || "Unknown error",
|
|
5635
5641
|
r?.hint
|
|
5636
5642
|
)
|
|
@@ -5687,7 +5693,7 @@ class $o {
|
|
|
5687
5693
|
}
|
|
5688
5694
|
_handleReceive(e, t) {
|
|
5689
5695
|
const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
|
|
5690
|
-
switch (
|
|
5696
|
+
switch (yn[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
|
|
5691
5697
|
case "init-ok": {
|
|
5692
5698
|
this._setStatus(ie.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
|
|
5693
5699
|
for (const o of Object.keys(this._rooms)) {
|
|
@@ -5704,7 +5710,7 @@ class $o {
|
|
|
5704
5710
|
const { q: o, result: a } = t, c = L(o);
|
|
5705
5711
|
if (!this._hasQueryListeners() && !this.querySubs.currentValue[c])
|
|
5706
5712
|
break;
|
|
5707
|
-
const u = a?.[0]?.data?.["page-info"], l = a?.[0]?.data?.aggregate, f =
|
|
5713
|
+
const u = a?.[0]?.data?.["page-info"], l = a?.[0]?.data?.aggregate, f = an(a), d = this.ensureAttrs(), h = we(
|
|
5708
5714
|
d,
|
|
5709
5715
|
f,
|
|
5710
5716
|
r,
|
|
@@ -5768,8 +5774,8 @@ class $o {
|
|
|
5768
5774
|
u !== this._pendingMutations() && this.kv.updateInPlace((d) => {
|
|
5769
5775
|
d.pendingMutations = u;
|
|
5770
5776
|
});
|
|
5771
|
-
const l =
|
|
5772
|
-
const h = d["instaql-query"], p = d["instaql-result"], m = L(h), g =
|
|
5777
|
+
const l = at(u.entries()), f = o.map((d) => {
|
|
5778
|
+
const h = d["instaql-query"], p = d["instaql-result"], m = L(h), g = an(p), y = this.ensureAttrs(), b = we(
|
|
5773
5779
|
y,
|
|
5774
5780
|
g,
|
|
5775
5781
|
r,
|
|
@@ -5995,15 +6001,15 @@ class $o {
|
|
|
5995
6001
|
* Returns an unsubscribe function
|
|
5996
6002
|
*/
|
|
5997
6003
|
subscribeQuery(e, t, r) {
|
|
5998
|
-
this.config.disableValidation ||
|
|
6004
|
+
this.config.disableValidation || un(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
|
|
5999
6005
|
const s = L(e), i = this.getPreviousResult(e);
|
|
6000
6006
|
return i && t(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: t }), this._startQuerySub(e, s), () => {
|
|
6001
6007
|
this._unsubQuery(e, s, t);
|
|
6002
6008
|
};
|
|
6003
6009
|
}
|
|
6004
6010
|
queryOnce(e, t) {
|
|
6005
|
-
this.config.disableValidation ||
|
|
6006
|
-
const r = new
|
|
6011
|
+
this.config.disableValidation || un(e, this.config.schema), t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
|
|
6012
|
+
const r = new on();
|
|
6007
6013
|
if (!this._isOnline)
|
|
6008
6014
|
return r.reject(
|
|
6009
6015
|
new Error("We can't run `queryOnce`, because the device is offline.")
|
|
@@ -6017,7 +6023,7 @@ class $o {
|
|
|
6017
6023
|
const s = L(e), i = this._startQuerySub(e, s);
|
|
6018
6024
|
return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
|
|
6019
6025
|
() => r.reject(new Error("Query timed out")),
|
|
6020
|
-
|
|
6026
|
+
vo
|
|
6021
6027
|
), r.promise;
|
|
6022
6028
|
}
|
|
6023
6029
|
_completeQueryOnce(e, t, r) {
|
|
@@ -6084,7 +6090,7 @@ class $o {
|
|
|
6084
6090
|
a = !0;
|
|
6085
6091
|
continue;
|
|
6086
6092
|
}
|
|
6087
|
-
const m = a ?
|
|
6093
|
+
const m = a ? ai(o, h) : h;
|
|
6088
6094
|
d.push(m);
|
|
6089
6095
|
}
|
|
6090
6096
|
return a ? d : l;
|
|
@@ -6097,7 +6103,7 @@ class $o {
|
|
|
6097
6103
|
return a ? u : t;
|
|
6098
6104
|
}
|
|
6099
6105
|
_rewriteMutationsSorted(e, t) {
|
|
6100
|
-
return
|
|
6106
|
+
return at(this._rewriteMutations(e, t).entries());
|
|
6101
6107
|
}
|
|
6102
6108
|
// ---------------------------
|
|
6103
6109
|
// Transact
|
|
@@ -6149,7 +6155,7 @@ class $o {
|
|
|
6149
6155
|
);
|
|
6150
6156
|
f = b.store, d = b.attrsStore;
|
|
6151
6157
|
}
|
|
6152
|
-
return { data:
|
|
6158
|
+
return { data: Ut(
|
|
6153
6159
|
{ store: f, attrsStore: d, pageInfo: h, aggregate: p },
|
|
6154
6160
|
c
|
|
6155
6161
|
), querySubVersion: s, pendingMutationsVersion: o };
|
|
@@ -6157,7 +6163,7 @@ class $o {
|
|
|
6157
6163
|
_applyOptimisticUpdates(e, t, r, s) {
|
|
6158
6164
|
for (const [i, o] of r)
|
|
6159
6165
|
if (!o["tx-id"] || s && o["tx-id"] > s) {
|
|
6160
|
-
const a =
|
|
6166
|
+
const a = os(e, t, o["tx-steps"]);
|
|
6161
6167
|
e = a.store, t = a.attrsStore;
|
|
6162
6168
|
}
|
|
6163
6169
|
return { store: e, attrsStore: t };
|
|
@@ -6165,7 +6171,7 @@ class $o {
|
|
|
6165
6171
|
/** Re-run instaql and call all callbacks with new data */
|
|
6166
6172
|
notifyOne = (e) => {
|
|
6167
6173
|
const t = this.queryCbs[e] ?? [], r = this._dataForQueryCache[e]?.data, s = this.dataForQuery(e);
|
|
6168
|
-
s?.data && (this._dataForQueryCache[e] = s, !
|
|
6174
|
+
s?.data && (this._dataForQueryCache[e] = s, !ze(s.data, r) && t.forEach((i) => i.cb(s.data)));
|
|
6169
6175
|
};
|
|
6170
6176
|
notifyOneQueryOnce = (e) => {
|
|
6171
6177
|
const t = this.queryOnceDfds[e] ?? [], r = this.dataForQuery(e)?.data;
|
|
@@ -6187,9 +6193,9 @@ class $o {
|
|
|
6187
6193
|
}
|
|
6188
6194
|
/** Applies transactions locally and sends transact message to server */
|
|
6189
6195
|
pushTx = (e) => {
|
|
6190
|
-
this.config.disableValidation ||
|
|
6196
|
+
this.config.disableValidation || co(e, this.config.schema);
|
|
6191
6197
|
try {
|
|
6192
|
-
const t =
|
|
6198
|
+
const t = ji(
|
|
6193
6199
|
{
|
|
6194
6200
|
attrsStore: this.optimisticAttrs(),
|
|
6195
6201
|
schema: this.config.schema,
|
|
@@ -6221,7 +6227,7 @@ class $o {
|
|
|
6221
6227
|
this._updatePendingMutations((c) => {
|
|
6222
6228
|
c.set(r, o);
|
|
6223
6229
|
});
|
|
6224
|
-
const a = new
|
|
6230
|
+
const a = new on();
|
|
6225
6231
|
return this.mutationDeferredStore.set(r, a), this._sendMutation(r, o), this.notifyAll(), a.promise;
|
|
6226
6232
|
};
|
|
6227
6233
|
shutdown() {
|
|
@@ -6274,7 +6280,7 @@ class $o {
|
|
|
6274
6280
|
);
|
|
6275
6281
|
r !== this._pendingMutations() && this.kv.updateInPlace((i) => {
|
|
6276
6282
|
i.pendingMutations = r;
|
|
6277
|
-
}),
|
|
6283
|
+
}), at(r.entries()).forEach(([i, o]) => {
|
|
6278
6284
|
o["tx-id"] || this._sendMutation(i, o);
|
|
6279
6285
|
}), this._syncTable.flushPending();
|
|
6280
6286
|
}
|
|
@@ -6309,7 +6315,7 @@ class $o {
|
|
|
6309
6315
|
}
|
|
6310
6316
|
_trySend(e, t, r) {
|
|
6311
6317
|
if (this._transport.isOpen()) {
|
|
6312
|
-
switch (
|
|
6318
|
+
switch (yn[t.op] || this._log.info("[send]", this._transport.id, t.op, {
|
|
6313
6319
|
"client-event-id": e,
|
|
6314
6320
|
...t
|
|
6315
6321
|
}), t.op) {
|
|
@@ -6441,7 +6447,7 @@ class $o {
|
|
|
6441
6447
|
return;
|
|
6442
6448
|
}
|
|
6443
6449
|
const e = this._transport;
|
|
6444
|
-
this._transport =
|
|
6450
|
+
this._transport = Co({
|
|
6445
6451
|
transportType: this._transportType,
|
|
6446
6452
|
appId: this.config.appId,
|
|
6447
6453
|
apiURI: this.config.apiURI,
|
|
@@ -6480,9 +6486,9 @@ class $o {
|
|
|
6480
6486
|
if (typeof URL > "u")
|
|
6481
6487
|
return;
|
|
6482
6488
|
const e = new URL(window.location.href);
|
|
6483
|
-
if (e.searchParams.get(
|
|
6489
|
+
if (e.searchParams.get(it)) {
|
|
6484
6490
|
const t = e.toString();
|
|
6485
|
-
e.searchParams.delete(
|
|
6491
|
+
e.searchParams.delete(it), e.searchParams.delete(ot), e.searchParams.delete("code"), e.searchParams.delete("error");
|
|
6486
6492
|
const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
|
|
6487
6493
|
if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
|
|
6488
6494
|
typeof navigation == "object" && // @ts-ignore (waiting for ts support)
|
|
@@ -6504,7 +6510,7 @@ class $o {
|
|
|
6504
6510
|
if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
|
|
6505
6511
|
return null;
|
|
6506
6512
|
const e = new URLSearchParams(window.location.search);
|
|
6507
|
-
if (!e.get(
|
|
6513
|
+
if (!e.get(it))
|
|
6508
6514
|
return null;
|
|
6509
6515
|
const t = e.get("error");
|
|
6510
6516
|
if (t)
|
|
@@ -6512,17 +6518,24 @@ class $o {
|
|
|
6512
6518
|
const r = e.get("code");
|
|
6513
6519
|
if (!r)
|
|
6514
6520
|
return null;
|
|
6521
|
+
const s = e.get(ot);
|
|
6515
6522
|
this._replaceUrlAfterOAuth();
|
|
6516
6523
|
try {
|
|
6517
|
-
|
|
6524
|
+
let i;
|
|
6525
|
+
const o = await this.kv.waitForKeyToLoad(Ne);
|
|
6526
|
+
s && o && (i = o[s]), o && this.kv.updateInPlace((l) => {
|
|
6527
|
+
delete l[Ne];
|
|
6528
|
+
});
|
|
6529
|
+
const a = await this._getCurrentUser(), c = a?.type === "guest", { user: u } = await rn({
|
|
6518
6530
|
apiURI: this.config.apiURI,
|
|
6519
6531
|
appId: this.config.appId,
|
|
6520
6532
|
code: r,
|
|
6521
|
-
refreshToken:
|
|
6533
|
+
refreshToken: c ? a.refresh_token : void 0,
|
|
6534
|
+
extraFields: i
|
|
6522
6535
|
});
|
|
6523
|
-
return this.setCurrentUser(
|
|
6524
|
-
} catch (
|
|
6525
|
-
return
|
|
6536
|
+
return this.setCurrentUser(u), null;
|
|
6537
|
+
} catch (i) {
|
|
6538
|
+
return i?.body?.type === "record-not-found" && i?.body?.hint?.["record-type"] === "app-oauth-code" && await this._hasCurrentUser() ? null : { error: { message: i?.body?.message || "Error logging in." } };
|
|
6526
6539
|
}
|
|
6527
6540
|
}
|
|
6528
6541
|
async _waitForOAuthCallbackResponse() {
|
|
@@ -6539,7 +6552,7 @@ class $o {
|
|
|
6539
6552
|
t.isLoading || e(this._currentUserCached);
|
|
6540
6553
|
let r = !1;
|
|
6541
6554
|
return this.getCurrentUser().then((s) => {
|
|
6542
|
-
r ||
|
|
6555
|
+
r || ze(s, t) || e(s);
|
|
6543
6556
|
}), () => {
|
|
6544
6557
|
r = !0, this.authCbs = this.authCbs.filter((s) => s !== e);
|
|
6545
6558
|
};
|
|
@@ -6547,7 +6560,7 @@ class $o {
|
|
|
6547
6560
|
async getAuth() {
|
|
6548
6561
|
const { user: e, error: t } = await this.getCurrentUser();
|
|
6549
6562
|
if (t)
|
|
6550
|
-
throw new
|
|
6563
|
+
throw new K("Could not get current user: " + t.message);
|
|
6551
6564
|
return e ?? null;
|
|
6552
6565
|
}
|
|
6553
6566
|
subscribeConnectionStatus(e) {
|
|
@@ -6623,7 +6636,7 @@ class $o {
|
|
|
6623
6636
|
}
|
|
6624
6637
|
async changeCurrentUser(e) {
|
|
6625
6638
|
const { user: t } = await this.getCurrentUser();
|
|
6626
|
-
if (!
|
|
6639
|
+
if (!ze(t, e)) {
|
|
6627
6640
|
this._frameworkClient = null, await this.setCurrentUser(e), await this.updateUser(e);
|
|
6628
6641
|
try {
|
|
6629
6642
|
await this.kv.flush(), this._broadcastChannel?.postMessage({ type: "auth" });
|
|
@@ -6671,24 +6684,25 @@ class $o {
|
|
|
6671
6684
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(t);
|
|
6672
6685
|
}
|
|
6673
6686
|
sendMagicCode({ email: e }) {
|
|
6674
|
-
return
|
|
6687
|
+
return Ni({
|
|
6675
6688
|
apiURI: this.config.apiURI,
|
|
6676
6689
|
appId: this.config.appId,
|
|
6677
6690
|
email: e
|
|
6678
6691
|
});
|
|
6679
6692
|
}
|
|
6680
|
-
async signInWithMagicCode(
|
|
6681
|
-
const
|
|
6693
|
+
async signInWithMagicCode(e) {
|
|
6694
|
+
const t = await this.getCurrentUser(), r = t?.user?.type === "guest", s = await Fi({
|
|
6682
6695
|
apiURI: this.config.apiURI,
|
|
6683
6696
|
appId: this.config.appId,
|
|
6684
|
-
email: e,
|
|
6685
|
-
code:
|
|
6686
|
-
refreshToken:
|
|
6697
|
+
email: e.email,
|
|
6698
|
+
code: e.code,
|
|
6699
|
+
refreshToken: r ? t?.user?.refresh_token : void 0,
|
|
6700
|
+
extraFields: e.extraFields
|
|
6687
6701
|
});
|
|
6688
|
-
return await this.changeCurrentUser(
|
|
6702
|
+
return await this.changeCurrentUser(s.user), s;
|
|
6689
6703
|
}
|
|
6690
6704
|
async signInWithCustomToken(e) {
|
|
6691
|
-
const t = await
|
|
6705
|
+
const t = await Ki({
|
|
6692
6706
|
apiURI: this.config.apiURI,
|
|
6693
6707
|
appId: this.config.appId,
|
|
6694
6708
|
refreshToken: e
|
|
@@ -6696,7 +6710,7 @@ class $o {
|
|
|
6696
6710
|
return await this.changeCurrentUser(t.user), t;
|
|
6697
6711
|
}
|
|
6698
6712
|
async signInAsGuest() {
|
|
6699
|
-
const e = await
|
|
6713
|
+
const e = await qi({
|
|
6700
6714
|
apiURI: this.config.apiURI,
|
|
6701
6715
|
appId: this.config.appId
|
|
6702
6716
|
});
|
|
@@ -6710,7 +6724,7 @@ class $o {
|
|
|
6710
6724
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
6711
6725
|
return;
|
|
6712
6726
|
}
|
|
6713
|
-
|
|
6727
|
+
Wi({
|
|
6714
6728
|
apiURI: this.config.apiURI,
|
|
6715
6729
|
appId: this.config.appId,
|
|
6716
6730
|
refreshToken: r
|
|
@@ -6729,26 +6743,37 @@ class $o {
|
|
|
6729
6743
|
* @param {Object} params - The parameters to create the authorization URL.
|
|
6730
6744
|
* @param {string} params.clientName - The name of the client requesting authorization.
|
|
6731
6745
|
* @param {string} params.redirectURL - The URL to redirect users to after authorization.
|
|
6746
|
+
* @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
|
|
6732
6747
|
* @returns {string} The created authorization URL.
|
|
6733
6748
|
*/
|
|
6734
|
-
createAuthorizationURL({ clientName: e, redirectURL: t }) {
|
|
6735
|
-
const { apiURI:
|
|
6736
|
-
|
|
6749
|
+
createAuthorizationURL({ clientName: e, redirectURL: t, extraFields: r }) {
|
|
6750
|
+
const { apiURI: s, appId: i } = this.config;
|
|
6751
|
+
let o = t;
|
|
6752
|
+
if (r) {
|
|
6753
|
+
const a = `${Math.random().toString(36).slice(2)}`;
|
|
6754
|
+
this.kv.updateInPlace((c) => {
|
|
6755
|
+
const u = c[Ne] || {};
|
|
6756
|
+
u[a] = r, c[Ne] = u;
|
|
6757
|
+
}), o = `${t}${t.includes("?") ? "&" : "?"}${ot}=${a}`;
|
|
6758
|
+
}
|
|
6759
|
+
return `${s}/runtime/oauth/start?app_id=${i}&client_name=${e}&redirect_uri=${encodeURIComponent(o)}`;
|
|
6737
6760
|
}
|
|
6738
6761
|
/**
|
|
6739
6762
|
* @param {Object} params
|
|
6740
6763
|
* @param {string} params.code - The code received from the OAuth service.
|
|
6741
6764
|
* @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
|
|
6765
|
+
* @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
|
|
6742
6766
|
*/
|
|
6743
|
-
async exchangeCodeForToken({ code: e, codeVerifier: t }) {
|
|
6744
|
-
const
|
|
6767
|
+
async exchangeCodeForToken({ code: e, codeVerifier: t, extraFields: r }) {
|
|
6768
|
+
const s = await this.getCurrentUser(), i = s?.user?.type === "guest", o = await rn({
|
|
6745
6769
|
apiURI: this.config.apiURI,
|
|
6746
6770
|
appId: this.config.appId,
|
|
6747
6771
|
code: e,
|
|
6748
6772
|
codeVerifier: t,
|
|
6749
|
-
refreshToken:
|
|
6773
|
+
refreshToken: i ? s?.user?.refresh_token : void 0,
|
|
6774
|
+
extraFields: r
|
|
6750
6775
|
});
|
|
6751
|
-
return await this.changeCurrentUser(
|
|
6776
|
+
return await this.changeCurrentUser(o.user), o;
|
|
6752
6777
|
}
|
|
6753
6778
|
issuerURI() {
|
|
6754
6779
|
const { apiURI: e, appId: t } = this.config;
|
|
@@ -6759,17 +6784,19 @@ class $o {
|
|
|
6759
6784
|
* @param {string} params.clientName - The name of the client requesting authorization.
|
|
6760
6785
|
* @param {string} params.idToken - The id_token from the external service
|
|
6761
6786
|
* @param {string | null | undefined} [params.nonce] - The nonce used when requesting the id_token from the external service
|
|
6787
|
+
* @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
|
|
6762
6788
|
*/
|
|
6763
|
-
async signInWithIdToken(
|
|
6764
|
-
const
|
|
6789
|
+
async signInWithIdToken(e) {
|
|
6790
|
+
const r = (await this.getCurrentUser())?.user?.refresh_token, s = await zi({
|
|
6765
6791
|
apiURI: this.config.apiURI,
|
|
6766
6792
|
appId: this.config.appId,
|
|
6767
|
-
idToken: e,
|
|
6768
|
-
clientName:
|
|
6769
|
-
nonce:
|
|
6770
|
-
refreshToken:
|
|
6793
|
+
idToken: e.idToken,
|
|
6794
|
+
clientName: e.clientName,
|
|
6795
|
+
nonce: e.nonce,
|
|
6796
|
+
refreshToken: r,
|
|
6797
|
+
extraFields: e.extraFields
|
|
6771
6798
|
});
|
|
6772
|
-
return await this.changeCurrentUser(
|
|
6799
|
+
return await this.changeCurrentUser(s.user), s;
|
|
6773
6800
|
}
|
|
6774
6801
|
// --------
|
|
6775
6802
|
// Rooms
|
|
@@ -6803,7 +6830,7 @@ class $o {
|
|
|
6803
6830
|
getPresence(e, t, r = {}) {
|
|
6804
6831
|
const s = this._rooms[t], i = this._presence[t];
|
|
6805
6832
|
return !s || !i || !i.result ? null : {
|
|
6806
|
-
...
|
|
6833
|
+
...Ji(i.result, r, this._sessionId),
|
|
6807
6834
|
isLoading: !s.isConnected,
|
|
6808
6835
|
error: s.error
|
|
6809
6836
|
};
|
|
@@ -6863,7 +6890,7 @@ class $o {
|
|
|
6863
6890
|
}
|
|
6864
6891
|
_notifyPresenceSub(e, t) {
|
|
6865
6892
|
const r = this.getPresence("", e, t);
|
|
6866
|
-
r && (t.prev && !
|
|
6893
|
+
r && (t.prev && !Yi(r, t.prev) || (t.prev = r, t.cb(r)));
|
|
6867
6894
|
}
|
|
6868
6895
|
_patchPresencePeers(e, t) {
|
|
6869
6896
|
const r = this._presence[e]?.result?.peers || {};
|
|
@@ -6871,17 +6898,17 @@ class $o {
|
|
|
6871
6898
|
Object.entries(r).map(([o, a]) => [o, { data: a }])
|
|
6872
6899
|
);
|
|
6873
6900
|
this._presence[e]?.result;
|
|
6874
|
-
const i =
|
|
6901
|
+
const i = Be(s, (o) => {
|
|
6875
6902
|
for (let [a, c, u] of t)
|
|
6876
6903
|
switch (c) {
|
|
6877
6904
|
case "+":
|
|
6878
|
-
|
|
6905
|
+
Cr(o, a, u);
|
|
6879
6906
|
break;
|
|
6880
6907
|
case "r":
|
|
6881
|
-
|
|
6908
|
+
Wt(o, a, u);
|
|
6882
6909
|
break;
|
|
6883
6910
|
case "-":
|
|
6884
|
-
|
|
6911
|
+
Pn(o, a);
|
|
6885
6912
|
break;
|
|
6886
6913
|
}
|
|
6887
6914
|
delete o[this._sessionId];
|
|
@@ -6894,8 +6921,8 @@ class $o {
|
|
|
6894
6921
|
const s = Object.fromEntries(
|
|
6895
6922
|
Object.entries(r).map(([i, o]) => [i, o.data])
|
|
6896
6923
|
);
|
|
6897
|
-
this._presence =
|
|
6898
|
-
|
|
6924
|
+
this._presence = Be(this._presence, (i) => {
|
|
6925
|
+
Wt(i, [e, "result", "peers"], s);
|
|
6899
6926
|
});
|
|
6900
6927
|
}
|
|
6901
6928
|
// --------
|
|
@@ -6935,7 +6962,7 @@ class $o {
|
|
|
6935
6962
|
// Storage
|
|
6936
6963
|
async uploadFile(e, t, r) {
|
|
6937
6964
|
const i = (await this.getCurrentUser())?.user?.refresh_token;
|
|
6938
|
-
return
|
|
6965
|
+
return Vi({
|
|
6939
6966
|
...r,
|
|
6940
6967
|
apiURI: this.config.apiURI,
|
|
6941
6968
|
appId: this.config.appId,
|
|
@@ -6946,7 +6973,7 @@ class $o {
|
|
|
6946
6973
|
}
|
|
6947
6974
|
async deleteFile(e) {
|
|
6948
6975
|
const r = (await this.getCurrentUser())?.user?.refresh_token;
|
|
6949
|
-
return await
|
|
6976
|
+
return await Qi({
|
|
6950
6977
|
apiURI: this.config.apiURI,
|
|
6951
6978
|
appId: this.config.appId,
|
|
6952
6979
|
path: e,
|
|
@@ -6956,17 +6983,17 @@ class $o {
|
|
|
6956
6983
|
// Deprecated Storage API (Jan 2025)
|
|
6957
6984
|
// ---------------------------------
|
|
6958
6985
|
async upload(e, t) {
|
|
6959
|
-
const s = (await this.getCurrentUser())?.user?.refresh_token, i = e || t.name, o = await
|
|
6986
|
+
const s = (await this.getCurrentUser())?.user?.refresh_token, i = e || t.name, o = await Bi({
|
|
6960
6987
|
apiURI: this.config.apiURI,
|
|
6961
6988
|
appId: this.config.appId,
|
|
6962
6989
|
fileName: i,
|
|
6963
6990
|
refreshToken: s
|
|
6964
6991
|
});
|
|
6965
|
-
return await
|
|
6992
|
+
return await Gi(o, t);
|
|
6966
6993
|
}
|
|
6967
6994
|
async getDownloadUrl(e) {
|
|
6968
6995
|
const r = (await this.getCurrentUser())?.user?.refresh_token;
|
|
6969
|
-
return await
|
|
6996
|
+
return await Hi({
|
|
6970
6997
|
apiURI: this.config.apiURI,
|
|
6971
6998
|
appId: this.config.appId,
|
|
6972
6999
|
path: e,
|
|
@@ -6974,9 +7001,9 @@ class $o {
|
|
|
6974
7001
|
});
|
|
6975
7002
|
}
|
|
6976
7003
|
}
|
|
6977
|
-
function
|
|
6978
|
-
return new
|
|
6979
|
-
|
|
7004
|
+
function Do(n, e) {
|
|
7005
|
+
return new Xe(
|
|
7006
|
+
dr(n, e),
|
|
6980
7007
|
// (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
|
|
6981
7008
|
// type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
|
|
6982
7009
|
// EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
|
|
@@ -6986,28 +7013,28 @@ function xo(n, e) {
|
|
|
6986
7013
|
void 0
|
|
6987
7014
|
);
|
|
6988
7015
|
}
|
|
6989
|
-
function
|
|
6990
|
-
return new
|
|
7016
|
+
function Uo(n) {
|
|
7017
|
+
return new Ze(n, {});
|
|
6991
7018
|
}
|
|
6992
|
-
function
|
|
7019
|
+
function Lo() {
|
|
6993
7020
|
return new W("string", !0, !1);
|
|
6994
7021
|
}
|
|
6995
|
-
function
|
|
7022
|
+
function No() {
|
|
6996
7023
|
return new W("number", !0, !1);
|
|
6997
7024
|
}
|
|
6998
|
-
function
|
|
7025
|
+
function Fo() {
|
|
6999
7026
|
return new W("boolean", !0, !1);
|
|
7000
7027
|
}
|
|
7001
|
-
function
|
|
7028
|
+
function Ko() {
|
|
7002
7029
|
return new W("date", !0, !1);
|
|
7003
7030
|
}
|
|
7004
|
-
function
|
|
7031
|
+
function qo() {
|
|
7005
7032
|
return new W("json", !0, !1);
|
|
7006
7033
|
}
|
|
7007
|
-
function
|
|
7034
|
+
function zo() {
|
|
7008
7035
|
return new W("json", !0, !1);
|
|
7009
7036
|
}
|
|
7010
|
-
function
|
|
7037
|
+
function dr(n, e) {
|
|
7011
7038
|
const t = { fwd: {}, rev: {} };
|
|
7012
7039
|
for (const s of Object.values(e))
|
|
7013
7040
|
t.fwd[s.forward.on] ||= {}, t.rev[s.reverse.on] ||= {}, t.fwd[s.forward.on][s.forward.label] = {
|
|
@@ -7020,21 +7047,21 @@ function ur(n, e) {
|
|
|
7020
7047
|
return Object.fromEntries(
|
|
7021
7048
|
Object.entries(n).map(([s, i]) => [
|
|
7022
7049
|
s,
|
|
7023
|
-
new
|
|
7050
|
+
new Ze(i.attrs, {
|
|
7024
7051
|
...t.fwd[s],
|
|
7025
7052
|
...t.rev[s]
|
|
7026
7053
|
})
|
|
7027
7054
|
])
|
|
7028
7055
|
);
|
|
7029
7056
|
}
|
|
7030
|
-
function
|
|
7057
|
+
function Wo({
|
|
7031
7058
|
entities: n,
|
|
7032
7059
|
links: e,
|
|
7033
7060
|
rooms: t
|
|
7034
7061
|
}) {
|
|
7035
7062
|
const r = e ?? {}, s = t ?? {};
|
|
7036
|
-
return new
|
|
7037
|
-
|
|
7063
|
+
return new Xe(
|
|
7064
|
+
dr(n, r),
|
|
7038
7065
|
// (XXX): LinksDef<any> stems from TypeScript's inability to reconcile the
|
|
7039
7066
|
// type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
|
|
7040
7067
|
// EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
|
|
@@ -7046,21 +7073,21 @@ function Ko({
|
|
|
7046
7073
|
}
|
|
7047
7074
|
const $ = {
|
|
7048
7075
|
// constructs
|
|
7049
|
-
graph:
|
|
7050
|
-
schema:
|
|
7051
|
-
entity:
|
|
7076
|
+
graph: Do,
|
|
7077
|
+
schema: Wo,
|
|
7078
|
+
entity: Uo,
|
|
7052
7079
|
// value types
|
|
7053
|
-
string:
|
|
7054
|
-
number:
|
|
7055
|
-
boolean:
|
|
7056
|
-
date:
|
|
7057
|
-
json:
|
|
7058
|
-
any:
|
|
7080
|
+
string: Lo,
|
|
7081
|
+
number: No,
|
|
7082
|
+
boolean: Fo,
|
|
7083
|
+
date: Ko,
|
|
7084
|
+
json: qo,
|
|
7085
|
+
any: zo
|
|
7059
7086
|
};
|
|
7060
|
-
let
|
|
7061
|
-
function
|
|
7062
|
-
|
|
7063
|
-
const t =
|
|
7087
|
+
let bn;
|
|
7088
|
+
function Vo(n, e) {
|
|
7089
|
+
bn?.dispose();
|
|
7090
|
+
const t = Yo(e), r = Go(e, a), s = Bo(Qo(n));
|
|
7064
7091
|
function i(l) {
|
|
7065
7092
|
l.source === s.element.contentWindow && l.data?.type === "close" && t.isVisible() && a();
|
|
7066
7093
|
}
|
|
@@ -7075,16 +7102,16 @@ function zo(n, e) {
|
|
|
7075
7102
|
t.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", i);
|
|
7076
7103
|
}
|
|
7077
7104
|
function u() {
|
|
7078
|
-
document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i),
|
|
7105
|
+
document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), bn = {
|
|
7079
7106
|
dispose: c
|
|
7080
7107
|
};
|
|
7081
7108
|
}
|
|
7082
7109
|
return u();
|
|
7083
7110
|
}
|
|
7084
|
-
function
|
|
7085
|
-
return `${
|
|
7111
|
+
function Qo(n) {
|
|
7112
|
+
return `${Lt || nr ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
|
|
7086
7113
|
}
|
|
7087
|
-
function
|
|
7114
|
+
function Bo(n) {
|
|
7088
7115
|
const e = document.createElement("iframe");
|
|
7089
7116
|
return e.src = n, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
7090
7117
|
width: "100%",
|
|
@@ -7093,7 +7120,7 @@ function Vo(n) {
|
|
|
7093
7120
|
border: "none"
|
|
7094
7121
|
}), { element: e };
|
|
7095
7122
|
}
|
|
7096
|
-
function
|
|
7123
|
+
function Go(n, e) {
|
|
7097
7124
|
const t = `
|
|
7098
7125
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7099
7126
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -7103,7 +7130,7 @@ function Qo(n, e) {
|
|
|
7103
7130
|
return r.innerHTML = t, r.className = "instant-devtool-toggler", Object.assign(r.style, {
|
|
7104
7131
|
// pos
|
|
7105
7132
|
position: "fixed",
|
|
7106
|
-
...
|
|
7133
|
+
...Ho(n.position),
|
|
7107
7134
|
height: "32px",
|
|
7108
7135
|
width: "32px",
|
|
7109
7136
|
// layout
|
|
@@ -7118,7 +7145,7 @@ function Qo(n, e) {
|
|
|
7118
7145
|
cursor: "pointer"
|
|
7119
7146
|
}), r.addEventListener("click", e), { element: r };
|
|
7120
7147
|
}
|
|
7121
|
-
function
|
|
7148
|
+
function Ho(n) {
|
|
7122
7149
|
switch (n) {
|
|
7123
7150
|
case "bottom-left":
|
|
7124
7151
|
return { bottom: "24px", left: "24px" };
|
|
@@ -7130,7 +7157,7 @@ function Bo(n) {
|
|
|
7130
7157
|
return { top: "24px", left: "24px" };
|
|
7131
7158
|
}
|
|
7132
7159
|
}
|
|
7133
|
-
function
|
|
7160
|
+
function Jo(n) {
|
|
7134
7161
|
switch (n) {
|
|
7135
7162
|
case "bottom-left":
|
|
7136
7163
|
return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
|
|
@@ -7142,11 +7169,11 @@ function Go(n) {
|
|
|
7142
7169
|
return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
|
|
7143
7170
|
}
|
|
7144
7171
|
}
|
|
7145
|
-
function
|
|
7172
|
+
function Yo(n) {
|
|
7146
7173
|
const e = document.createElement("div");
|
|
7147
7174
|
Object.assign(e.style, {
|
|
7148
7175
|
position: "fixed",
|
|
7149
|
-
...
|
|
7176
|
+
...Jo(n.position),
|
|
7150
7177
|
display: "block",
|
|
7151
7178
|
borderRadius: "4px",
|
|
7152
7179
|
border: "1px #ccc solid",
|
|
@@ -7159,7 +7186,7 @@ function Ho(n) {
|
|
|
7159
7186
|
}
|
|
7160
7187
|
return { element: e, isVisible: t };
|
|
7161
7188
|
}
|
|
7162
|
-
function
|
|
7189
|
+
function Zo(n, e) {
|
|
7163
7190
|
return e && e.refresh_token ? new Response(JSON.stringify({ ok: !0 }), {
|
|
7164
7191
|
headers: {
|
|
7165
7192
|
"Content-Type": "application/json",
|
|
@@ -7174,23 +7201,23 @@ function Jo(n, e) {
|
|
|
7174
7201
|
}
|
|
7175
7202
|
});
|
|
7176
7203
|
}
|
|
7177
|
-
function
|
|
7204
|
+
function Fe(n, e) {
|
|
7178
7205
|
return new Response(JSON.stringify({ ok: !1, error: e }), {
|
|
7179
7206
|
status: n,
|
|
7180
7207
|
headers: { "Content-Type": "application/json" }
|
|
7181
7208
|
});
|
|
7182
7209
|
}
|
|
7183
|
-
const
|
|
7210
|
+
const ga = (n) => ({
|
|
7184
7211
|
POST: async (e) => {
|
|
7185
7212
|
let t;
|
|
7186
7213
|
try {
|
|
7187
7214
|
t = await e.json();
|
|
7188
7215
|
} catch {
|
|
7189
|
-
return
|
|
7216
|
+
return Fe(400, "Invalid JSON body");
|
|
7190
7217
|
}
|
|
7191
|
-
return t.type ? t.appId !== n.appId ?
|
|
7218
|
+
return t.type ? t.appId !== n.appId ? Fe(403, "App ID mismatch") : t.type === "sync-user" ? Zo(n, t.user ?? null) : Fe(400, `Unknown type: ${t.type}`) : Fe(400, 'Missing "type" field');
|
|
7192
7219
|
}
|
|
7193
|
-
}),
|
|
7220
|
+
}), ma = (n) => {
|
|
7194
7221
|
const e = {};
|
|
7195
7222
|
for (const [i, o] of Object.entries(n.entities)) {
|
|
7196
7223
|
const a = o, c = {};
|
|
@@ -7290,8 +7317,8 @@ const ya = (n) => ({
|
|
|
7290
7317
|
links: t,
|
|
7291
7318
|
rooms: r
|
|
7292
7319
|
});
|
|
7293
|
-
},
|
|
7294
|
-
class
|
|
7320
|
+
}, Xo = typeof window > "u" || "Deno" in globalThis;
|
|
7321
|
+
class wa {
|
|
7295
7322
|
params;
|
|
7296
7323
|
db;
|
|
7297
7324
|
// stores all of the query promises so that ssr can read them
|
|
@@ -7312,7 +7339,7 @@ class ga {
|
|
|
7312
7339
|
data: t,
|
|
7313
7340
|
promise: null,
|
|
7314
7341
|
error: null
|
|
7315
|
-
}),
|
|
7342
|
+
}), Xo || (this.db._reactor.attrs || this.db._reactor._setAttrs(t.attrs), this.db._reactor._addQueryData(
|
|
7316
7343
|
t.query,
|
|
7317
7344
|
t,
|
|
7318
7345
|
!!this.db._reactor.config.schema
|
|
@@ -7397,14 +7424,14 @@ class ga {
|
|
|
7397
7424
|
});
|
|
7398
7425
|
const o = !!this.db?._reactor?.config?.schema && ("cardinalityInference" in this.db?._reactor?.config ? !!this.db?._reactor.config?.cardinalityInference : !0), a = new le(
|
|
7399
7426
|
r.reduce((l, f) => (l[f.id] = f, l), {}),
|
|
7400
|
-
|
|
7427
|
+
vt(this.db?._reactor.config.schema)
|
|
7401
7428
|
), c = we(
|
|
7402
7429
|
a,
|
|
7403
7430
|
t,
|
|
7404
7431
|
o,
|
|
7405
7432
|
this.params.db._reactor.config.useDateObjects || !1
|
|
7406
7433
|
);
|
|
7407
|
-
return
|
|
7434
|
+
return Ut(
|
|
7408
7435
|
{
|
|
7409
7436
|
store: c,
|
|
7410
7437
|
attrsStore: a,
|
|
@@ -7416,7 +7443,7 @@ class ga {
|
|
|
7416
7443
|
};
|
|
7417
7444
|
hashQuery = (e, t) => {
|
|
7418
7445
|
e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
|
|
7419
|
-
const r = e ?
|
|
7446
|
+
const r = e ? hr(e) : null;
|
|
7420
7447
|
return { hash: L(r), query: r };
|
|
7421
7448
|
};
|
|
7422
7449
|
// Run by the server to get triples and attrs
|
|
@@ -7441,7 +7468,7 @@ class ga {
|
|
|
7441
7468
|
const a = await t.json();
|
|
7442
7469
|
throw "message" in a ? new Re({ body: a, status: t.status }) : new Error("Error getting triples from server");
|
|
7443
7470
|
} catch (a) {
|
|
7444
|
-
throw a instanceof
|
|
7471
|
+
throw a instanceof K ? a : new Error("Error getting triples from server");
|
|
7445
7472
|
}
|
|
7446
7473
|
const r = await t.json(), s = r?.attrs;
|
|
7447
7474
|
if (!s)
|
|
@@ -7456,7 +7483,7 @@ class ga {
|
|
|
7456
7483
|
pageInfo: o
|
|
7457
7484
|
};
|
|
7458
7485
|
} catch (t) {
|
|
7459
|
-
if (t instanceof
|
|
7486
|
+
if (t instanceof K)
|
|
7460
7487
|
throw t;
|
|
7461
7488
|
const r = new Error(
|
|
7462
7489
|
"Error getting triples from framework client"
|
|
@@ -7469,10 +7496,10 @@ function ke(n, e) {
|
|
|
7469
7496
|
if (!n)
|
|
7470
7497
|
throw new Error("[assertion error] " + e);
|
|
7471
7498
|
}
|
|
7472
|
-
const Oe = (n) => JSON.stringify(n),
|
|
7499
|
+
const Oe = (n) => JSON.stringify(n), gn = (n) => JSON.parse(n), ea = (n) => !!n.endCursor, ta = (n) => {
|
|
7473
7500
|
const e = Array.from(n.values());
|
|
7474
7501
|
return e.length === 0 ? !1 : e[e.length - 1]?.hasMore || !1;
|
|
7475
|
-
}, ge = (n, e) => `${n}:${JSON.stringify(e)}`,
|
|
7502
|
+
}, ge = (n, e) => `${n}:${JSON.stringify(e)}`, mn = (n) => {
|
|
7476
7503
|
if (!n)
|
|
7477
7504
|
return {
|
|
7478
7505
|
serverCreatedAt: "asc"
|
|
@@ -7483,7 +7510,7 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7483
7510
|
} : {
|
|
7484
7511
|
serverCreatedAt: "asc"
|
|
7485
7512
|
};
|
|
7486
|
-
},
|
|
7513
|
+
}, na = (n, e) => {
|
|
7487
7514
|
const t = [
|
|
7488
7515
|
...Array.from(e.values()).slice().reverse(),
|
|
7489
7516
|
...Array.from(n.values())
|
|
@@ -7492,26 +7519,26 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7492
7519
|
...Array.from(n.values()).flatMap((s) => s.data)
|
|
7493
7520
|
];
|
|
7494
7521
|
return { chunks: t, data: r };
|
|
7495
|
-
},
|
|
7496
|
-
const { entityName: s, entityQuery: i } =
|
|
7522
|
+
}, wn = ["bootstrap", "bootstrap", "bootstrap", 1], ra = (n, e, t, r) => {
|
|
7523
|
+
const { entityName: s, entityQuery: i } = fr(e), o = i.$?.limit || 10, a = s, c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
7497
7524
|
let f = !1, d = !0, h = null, p = null;
|
|
7498
7525
|
const m = (T) => {
|
|
7499
7526
|
t({ error: T, data: void 0, canLoadNextPage: !1 });
|
|
7500
7527
|
}, g = () => {
|
|
7501
7528
|
if (!d) return;
|
|
7502
|
-
const { chunks: T, data: I } =
|
|
7529
|
+
const { chunks: T, data: I } = na(c, u);
|
|
7503
7530
|
t({
|
|
7504
7531
|
data: { [a]: I },
|
|
7505
7532
|
// @ts-expect-error hidden debug variable
|
|
7506
7533
|
chunks: T,
|
|
7507
|
-
canLoadNextPage:
|
|
7534
|
+
canLoadNextPage: ta(c)
|
|
7508
7535
|
});
|
|
7509
7536
|
}, y = (T, I) => {
|
|
7510
7537
|
c.set(Oe(T), I), g();
|
|
7511
7538
|
}, b = (T, I) => {
|
|
7512
7539
|
u.set(Oe(T), I), P(), g();
|
|
7513
7540
|
}, _ = (T, I) => {
|
|
7514
|
-
const v =
|
|
7541
|
+
const v = gn(T);
|
|
7515
7542
|
l.get(ge("reverse", v))?.();
|
|
7516
7543
|
const D = n.subscribeQuery(
|
|
7517
7544
|
{
|
|
@@ -7523,7 +7550,7 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7523
7550
|
beforeInclusive: !0,
|
|
7524
7551
|
where: i.$?.where,
|
|
7525
7552
|
fields: i.$?.fields,
|
|
7526
|
-
order:
|
|
7553
|
+
order: mn(i.$?.order)
|
|
7527
7554
|
}
|
|
7528
7555
|
}
|
|
7529
7556
|
},
|
|
@@ -7554,7 +7581,7 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7554
7581
|
after: T,
|
|
7555
7582
|
where: i.$?.where,
|
|
7556
7583
|
fields: i.$?.fields,
|
|
7557
|
-
order:
|
|
7584
|
+
order: mn(i.$?.order)
|
|
7558
7585
|
}
|
|
7559
7586
|
}
|
|
7560
7587
|
},
|
|
@@ -7641,14 +7668,14 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7641
7668
|
const T = Array.from(u.entries()).at(-1);
|
|
7642
7669
|
if (!T) return;
|
|
7643
7670
|
const [I, v] = T;
|
|
7644
|
-
if (!v?.hasMore || !
|
|
7671
|
+
if (!v?.hasMore || !ea(v)) return;
|
|
7645
7672
|
const O = `${I}:${Oe(v.endCursor)}`;
|
|
7646
7673
|
O != h && (h = O, _(I, v), M(v.endCursor));
|
|
7647
7674
|
}, N = () => {
|
|
7648
7675
|
const T = Array.from(c.entries()).at(-1);
|
|
7649
7676
|
if (!T) return;
|
|
7650
7677
|
const [I, v] = T;
|
|
7651
|
-
v.endCursor && (E(
|
|
7678
|
+
v.endCursor && (E(gn(I)), w(v.endCursor));
|
|
7652
7679
|
};
|
|
7653
7680
|
return p = n.subscribeQuery(
|
|
7654
7681
|
{
|
|
@@ -7668,14 +7695,14 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7668
7695
|
return m(T.error);
|
|
7669
7696
|
const I = T.pageInfo[a], v = T?.data?.[a];
|
|
7670
7697
|
if (ke(v && I, "Expected rows and pageInfo"), v.length < o) {
|
|
7671
|
-
y(
|
|
7698
|
+
y(wn, {
|
|
7672
7699
|
data: v,
|
|
7673
7700
|
status: "pre-bootstrap"
|
|
7674
7701
|
});
|
|
7675
7702
|
return;
|
|
7676
7703
|
}
|
|
7677
7704
|
const O = I.startCursor;
|
|
7678
|
-
O && (c.delete(Oe(
|
|
7705
|
+
O && (c.delete(Oe(wn)), w(O, !0), M(I.startCursor), f = !0, await n._reactor.querySubs.flush(), p?.(), p = null);
|
|
7679
7706
|
},
|
|
7680
7707
|
r
|
|
7681
7708
|
), {
|
|
@@ -7689,15 +7716,15 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7689
7716
|
},
|
|
7690
7717
|
loadNextPage: N
|
|
7691
7718
|
};
|
|
7692
|
-
},
|
|
7719
|
+
}, _a = (n, e, t) => {
|
|
7693
7720
|
if (!e)
|
|
7694
7721
|
return {
|
|
7695
7722
|
canLoadNextPage: !1,
|
|
7696
7723
|
data: void 0,
|
|
7697
7724
|
error: void 0
|
|
7698
7725
|
};
|
|
7699
|
-
const { entityName: r, entityQuery: s } =
|
|
7700
|
-
let o = e ?
|
|
7726
|
+
const { entityName: r, entityQuery: s } = fr(e), i = s.$?.limit || 10;
|
|
7727
|
+
let o = e ? hr({
|
|
7701
7728
|
[r]: {
|
|
7702
7729
|
...s,
|
|
7703
7730
|
$: {
|
|
@@ -7716,7 +7743,7 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7716
7743
|
data: n._reactor.getPreviousResult(o)?.data || void 0,
|
|
7717
7744
|
error: void 0
|
|
7718
7745
|
};
|
|
7719
|
-
},
|
|
7746
|
+
}, fr = (n) => {
|
|
7720
7747
|
if (Object.keys(n).length !== 1)
|
|
7721
7748
|
throw new C(
|
|
7722
7749
|
"subscribeInfiniteQuery expects exactly one entity"
|
|
@@ -7725,22 +7752,22 @@ const Oe = (n) => JSON.stringify(n), yn = (n) => JSON.parse(n), Zo = (n) => !!n.
|
|
|
7725
7752
|
if (!t || !r)
|
|
7726
7753
|
throw new C("No query provided for infinite query");
|
|
7727
7754
|
return { entityName: t, entityQuery: r };
|
|
7728
|
-
},
|
|
7755
|
+
}, sa = {
|
|
7729
7756
|
apiURI: "https://api.instantdb.com",
|
|
7730
7757
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
7731
7758
|
};
|
|
7732
|
-
function
|
|
7759
|
+
function ia() {
|
|
7733
7760
|
return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
7734
7761
|
}
|
|
7735
|
-
function
|
|
7762
|
+
function oa() {
|
|
7736
7763
|
return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
|
|
7737
7764
|
}
|
|
7738
|
-
function
|
|
7765
|
+
function At(n) {
|
|
7739
7766
|
const e = n.__adminToken;
|
|
7740
7767
|
return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects;
|
|
7741
7768
|
}
|
|
7742
|
-
const
|
|
7743
|
-
class
|
|
7769
|
+
const kt = oa(), _n = ia();
|
|
7770
|
+
class aa {
|
|
7744
7771
|
constructor(e) {
|
|
7745
7772
|
this.db = e;
|
|
7746
7773
|
}
|
|
@@ -7856,7 +7883,7 @@ class ia {
|
|
|
7856
7883
|
*/
|
|
7857
7884
|
signOut = (e = { invalidateToken: !0 }) => this.db.signOut(e);
|
|
7858
7885
|
}
|
|
7859
|
-
class
|
|
7886
|
+
class ca {
|
|
7860
7887
|
constructor(e) {
|
|
7861
7888
|
this.db = e;
|
|
7862
7889
|
}
|
|
@@ -7913,7 +7940,7 @@ class oa {
|
|
|
7913
7940
|
*/
|
|
7914
7941
|
getDownloadUrl = (e) => this.db.getDownloadUrl(e);
|
|
7915
7942
|
}
|
|
7916
|
-
class
|
|
7943
|
+
class ua {
|
|
7917
7944
|
constructor(e) {
|
|
7918
7945
|
this.db = e;
|
|
7919
7946
|
}
|
|
@@ -7938,17 +7965,17 @@ class aa {
|
|
|
7938
7965
|
*/
|
|
7939
7966
|
createWriteStream = (e) => this.db.createWriteStream(e);
|
|
7940
7967
|
}
|
|
7941
|
-
function
|
|
7968
|
+
function hr(n) {
|
|
7942
7969
|
return JSON.parse(JSON.stringify(n));
|
|
7943
7970
|
}
|
|
7944
|
-
class
|
|
7971
|
+
class la {
|
|
7945
7972
|
_reactor;
|
|
7946
7973
|
auth;
|
|
7947
7974
|
storage;
|
|
7948
7975
|
streams;
|
|
7949
|
-
tx =
|
|
7976
|
+
tx = Hn();
|
|
7950
7977
|
constructor(e) {
|
|
7951
|
-
this._reactor = e, this.auth = new
|
|
7978
|
+
this._reactor = e, this.auth = new aa(this._reactor), this.storage = new ca(this._reactor), this.streams = new ua(this._reactor);
|
|
7952
7979
|
}
|
|
7953
7980
|
/**
|
|
7954
7981
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -8026,7 +8053,7 @@ class ca {
|
|
|
8026
8053
|
* });
|
|
8027
8054
|
*/
|
|
8028
8055
|
subscribeInfiniteQuery(e, t, r) {
|
|
8029
|
-
return
|
|
8056
|
+
return ra(
|
|
8030
8057
|
this,
|
|
8031
8058
|
e,
|
|
8032
8059
|
t,
|
|
@@ -8120,7 +8147,7 @@ class ca {
|
|
|
8120
8147
|
};
|
|
8121
8148
|
}
|
|
8122
8149
|
shutdown() {
|
|
8123
|
-
delete
|
|
8150
|
+
delete kt[At(this._reactor.config)], this._reactor.shutdown();
|
|
8124
8151
|
}
|
|
8125
8152
|
/**
|
|
8126
8153
|
* Use this for one-off queries.
|
|
@@ -8153,40 +8180,40 @@ class ca {
|
|
|
8153
8180
|
return this._reactor.subscribeTable(e, t);
|
|
8154
8181
|
}
|
|
8155
8182
|
}
|
|
8156
|
-
function
|
|
8183
|
+
function Sn(n) {
|
|
8157
8184
|
if (!n)
|
|
8158
8185
|
return "0";
|
|
8159
|
-
const e =
|
|
8186
|
+
const e = _n.get(n);
|
|
8160
8187
|
if (e)
|
|
8161
8188
|
return e;
|
|
8162
8189
|
const t = L(n);
|
|
8163
|
-
return
|
|
8190
|
+
return _n.set(n, t), t;
|
|
8164
8191
|
}
|
|
8165
|
-
function
|
|
8166
|
-
return
|
|
8192
|
+
function da(n, e) {
|
|
8193
|
+
return Sn(n._reactor.config.schema) !== Sn(e);
|
|
8167
8194
|
}
|
|
8168
|
-
function
|
|
8195
|
+
function fa(n, e, t, r, s) {
|
|
8169
8196
|
const i = {
|
|
8170
8197
|
...n,
|
|
8171
8198
|
appId: n.appId?.trim(),
|
|
8172
8199
|
useDateObjects: n.useDateObjects ?? !1
|
|
8173
|
-
}, o =
|
|
8200
|
+
}, o = kt[At(i)];
|
|
8174
8201
|
if (o)
|
|
8175
|
-
return
|
|
8176
|
-
const a = new
|
|
8202
|
+
return da(o, i.schema) && o._reactor.updateSchema(i.schema), o;
|
|
8203
|
+
const a = new Ro(
|
|
8177
8204
|
{
|
|
8178
|
-
...
|
|
8205
|
+
...sa,
|
|
8179
8206
|
...i,
|
|
8180
8207
|
cardinalityInference: !!i.schema
|
|
8181
8208
|
},
|
|
8182
|
-
e ||
|
|
8183
|
-
t ||
|
|
8184
|
-
{ ...r || {}, "@instantdb/core":
|
|
8209
|
+
e || Xn,
|
|
8210
|
+
t || er,
|
|
8211
|
+
{ ...r || {}, "@instantdb/core": sr },
|
|
8185
8212
|
s
|
|
8186
|
-
), c = new
|
|
8187
|
-
return
|
|
8213
|
+
), c = new la(a);
|
|
8214
|
+
return kt[At(i)] = c, ha(i.appId, i.devtool), c;
|
|
8188
8215
|
}
|
|
8189
|
-
function
|
|
8216
|
+
function ha(n, e) {
|
|
8190
8217
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
8191
8218
|
return;
|
|
8192
8219
|
const t = {
|
|
@@ -8194,43 +8221,43 @@ function da(n, e) {
|
|
|
8194
8221
|
allowedHosts: ["localhost"],
|
|
8195
8222
|
...typeof e == "object" ? e : {}
|
|
8196
8223
|
};
|
|
8197
|
-
t.allowedHosts.includes(window.location.hostname) &&
|
|
8224
|
+
t.allowedHosts.includes(window.location.hostname) && Vo(n, t);
|
|
8198
8225
|
}
|
|
8199
|
-
const
|
|
8226
|
+
const Sa = fa, Ta = Zn;
|
|
8200
8227
|
export {
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8228
|
+
aa as Auth,
|
|
8229
|
+
wa as FrameworkClient,
|
|
8230
|
+
Xn as IndexedDBStorage,
|
|
8204
8231
|
Re as InstantAPIError,
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8232
|
+
la as InstantCoreDatabase,
|
|
8233
|
+
K as InstantError,
|
|
8234
|
+
To as InstantStream,
|
|
8208
8235
|
C as QueryValidationError,
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8236
|
+
Ro as Reactor,
|
|
8237
|
+
uo as SSEConnection,
|
|
8238
|
+
ca as Storage,
|
|
8239
|
+
Ta as StorageInterface,
|
|
8240
|
+
Zn as StoreInterface,
|
|
8241
|
+
ua as Streams,
|
|
8242
|
+
go as SyncTableCallbackEventType,
|
|
8216
8243
|
X as TransactionValidationError,
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8244
|
+
er as WindowNetworkListener,
|
|
8245
|
+
hr as coerceQuery,
|
|
8246
|
+
Je as coerceToDate,
|
|
8247
|
+
ga as createInstantRouteHandler,
|
|
8248
|
+
_a as getInfiniteQueryInitialSnapshot,
|
|
8249
|
+
oi as getOps,
|
|
8223
8250
|
$ as i,
|
|
8224
8251
|
j as id,
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8252
|
+
fa as init,
|
|
8253
|
+
Sa as init_experimental,
|
|
8254
|
+
si as lookup,
|
|
8255
|
+
ma as parseSchemaFromJSON,
|
|
8256
|
+
ya as setInstantWarningsEnabled,
|
|
8257
|
+
ba as tx,
|
|
8258
|
+
Hn as txInit,
|
|
8259
|
+
un as validateQuery,
|
|
8260
|
+
co as validateTransactions,
|
|
8261
|
+
sr as version,
|
|
8235
8262
|
L as weakHash
|
|
8236
8263
|
};
|