@instantdb/core 0.22.155 → 0.22.156
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/utils/e2e.ts +42 -18
- package/dist/commonjs/InstantError.d.ts +2 -1
- package/dist/commonjs/InstantError.d.ts.map +1 -1
- package/dist/commonjs/InstantError.js +5 -1
- package/dist/commonjs/InstantError.js.map +1 -1
- package/dist/commonjs/Reactor.d.ts +6 -0
- package/dist/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +12 -0
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/framework.d.ts +4 -0
- package/dist/commonjs/framework.d.ts.map +1 -1
- package/dist/commonjs/framework.js +67 -1
- package/dist/commonjs/framework.js.map +1 -1
- package/dist/commonjs/utils/fetch.js +1 -1
- package/dist/commonjs/utils/fetch.js.map +1 -1
- package/dist/esm/InstantError.d.ts +2 -1
- package/dist/esm/InstantError.d.ts.map +1 -1
- package/dist/esm/InstantError.js +5 -1
- package/dist/esm/InstantError.js.map +1 -1
- package/dist/esm/Reactor.d.ts +6 -0
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +12 -0
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/framework.d.ts +4 -0
- package/dist/esm/framework.d.ts.map +1 -1
- package/dist/esm/framework.js +68 -2
- package/dist/esm/framework.js.map +1 -1
- package/dist/esm/utils/fetch.js +1 -1
- package/dist/esm/utils/fetch.js.map +1 -1
- package/dist/standalone/index.js +348 -308
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +2 -2
- package/src/InstantError.ts +5 -1
- package/src/Reactor.js +15 -0
- package/src/framework.ts +79 -1
- package/src/utils/fetch.ts +1 -1
package/dist/standalone/index.js
CHANGED
|
@@ -37,7 +37,7 @@ const M = {
|
|
|
37
37
|
Remove: "remove",
|
|
38
38
|
Replace: "replace",
|
|
39
39
|
Add: "add"
|
|
40
|
-
}, pn = /* @__PURE__ */ Symbol.for("__MUTATIVE_PROXY_DRAFT__"), sr = /* @__PURE__ */ Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),
|
|
40
|
+
}, pn = /* @__PURE__ */ Symbol.for("__MUTATIVE_PROXY_DRAFT__"), sr = /* @__PURE__ */ Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Re = Symbol.iterator, W = {
|
|
41
41
|
mutable: "mutable",
|
|
42
42
|
immutable: "immutable"
|
|
43
43
|
}, Tt = {};
|
|
@@ -189,7 +189,7 @@ function bn(n, e) {
|
|
|
189
189
|
} else
|
|
190
190
|
throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function U(n) {
|
|
193
193
|
n.copy || (n.copy = bn(n.original, n.options));
|
|
194
194
|
}
|
|
195
195
|
function Te(n) {
|
|
@@ -221,7 +221,7 @@ function Te(n) {
|
|
|
221
221
|
e[t] = Te(n[t]);
|
|
222
222
|
return e;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function xe(n) {
|
|
225
225
|
return de(n) ? Te(n) : n;
|
|
226
226
|
}
|
|
227
227
|
function X(n) {
|
|
@@ -298,7 +298,7 @@ function gn(n, e, t) {
|
|
|
298
298
|
var a;
|
|
299
299
|
if (de(o)) {
|
|
300
300
|
const c = S(o);
|
|
301
|
-
|
|
301
|
+
U(c);
|
|
302
302
|
const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
|
|
303
303
|
Ce(r ? s : n, i, u);
|
|
304
304
|
} else
|
|
@@ -352,12 +352,12 @@ function ur(n, e, t, r, s) {
|
|
|
352
352
|
op: M.Replace,
|
|
353
353
|
path: f,
|
|
354
354
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
355
|
-
value:
|
|
355
|
+
value: xe(c[u])
|
|
356
356
|
}), r.push({
|
|
357
357
|
op: M.Replace,
|
|
358
358
|
path: f,
|
|
359
359
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
360
|
-
value:
|
|
360
|
+
value: xe(i[u])
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
363
|
for (let u = i.length; u < c.length; u += 1) {
|
|
@@ -366,7 +366,7 @@ function ur(n, e, t, r, s) {
|
|
|
366
366
|
op: M.Add,
|
|
367
367
|
path: f,
|
|
368
368
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
369
|
-
value:
|
|
369
|
+
value: xe(c[u])
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
if (i.length < c.length) {
|
|
@@ -390,7 +390,7 @@ function ur(n, e, t, r, s) {
|
|
|
390
390
|
}
|
|
391
391
|
function lr({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
|
|
392
392
|
t.forEach((a, c) => {
|
|
393
|
-
const u = se(n, c), l =
|
|
393
|
+
const u = se(n, c), l = xe(se(e, c)), f = a ? Ae(n, c) ? M.Replace : M.Add : M.Remove;
|
|
394
394
|
if (re(u, l) && f === M.Replace)
|
|
395
395
|
return;
|
|
396
396
|
const d = r.concat(c), h = le(d, o);
|
|
@@ -441,7 +441,7 @@ function Ie(n, e, t, r) {
|
|
|
441
441
|
return dr(n, e, t, r, s);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
|
-
const
|
|
444
|
+
const Fe = (n, e, t = !1) => {
|
|
445
445
|
if (typeof n == "object" && n !== null && (!J(n, e) || t))
|
|
446
446
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
447
447
|
}, ot = {
|
|
@@ -453,18 +453,18 @@ const Le = (n, e, t = !1) => {
|
|
|
453
453
|
},
|
|
454
454
|
set(n, e) {
|
|
455
455
|
const t = S(this), r = z(t);
|
|
456
|
-
return (!r.has(n) || !re(r.get(n), e)) && (
|
|
456
|
+
return (!r.has(n) || !re(r.get(n), e)) && (U(t), X(t), t.assignedMap.set(n, !0), t.copy.set(n, e), Ot(t, n, e, Ie)), this;
|
|
457
457
|
},
|
|
458
458
|
delete(n) {
|
|
459
459
|
if (!this.has(n))
|
|
460
460
|
return !1;
|
|
461
461
|
const e = S(this);
|
|
462
|
-
return
|
|
462
|
+
return U(e), X(e), e.original.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.copy.delete(n), !0;
|
|
463
463
|
},
|
|
464
464
|
clear() {
|
|
465
465
|
const n = S(this);
|
|
466
466
|
if (this.size) {
|
|
467
|
-
|
|
467
|
+
U(n), X(n), n.assignedMap = /* @__PURE__ */ new Map();
|
|
468
468
|
for (const [e] of n.original)
|
|
469
469
|
n.assignedMap.set(e, !1);
|
|
470
470
|
n.copy.clear();
|
|
@@ -479,7 +479,7 @@ const Le = (n, e, t = !1) => {
|
|
|
479
479
|
get(n) {
|
|
480
480
|
var e, t;
|
|
481
481
|
const r = S(this), s = z(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, W)) === W.mutable;
|
|
482
|
-
if (r.options.strict &&
|
|
482
|
+
if (r.options.strict && Fe(s, r.options, i), i || r.finalized || !J(s, r.options) || s !== r.original.get(n))
|
|
483
483
|
return s;
|
|
484
484
|
const o = Tt.createDraft({
|
|
485
485
|
original: s,
|
|
@@ -488,7 +488,7 @@ const Le = (n, e, t = !1) => {
|
|
|
488
488
|
finalities: r.finalities,
|
|
489
489
|
options: r.options
|
|
490
490
|
});
|
|
491
|
-
return
|
|
491
|
+
return U(r), r.copy.set(n, o), o;
|
|
492
492
|
},
|
|
493
493
|
keys() {
|
|
494
494
|
return z(S(this)).keys();
|
|
@@ -496,7 +496,7 @@ const Le = (n, e, t = !1) => {
|
|
|
496
496
|
values() {
|
|
497
497
|
const n = this.keys();
|
|
498
498
|
return {
|
|
499
|
-
[
|
|
499
|
+
[Re]: () => this.values(),
|
|
500
500
|
next: () => {
|
|
501
501
|
const e = n.next();
|
|
502
502
|
return e.done ? e : {
|
|
@@ -509,7 +509,7 @@ const Le = (n, e, t = !1) => {
|
|
|
509
509
|
entries() {
|
|
510
510
|
const n = this.keys();
|
|
511
511
|
return {
|
|
512
|
-
[
|
|
512
|
+
[Re]: () => this.entries(),
|
|
513
513
|
next: () => {
|
|
514
514
|
const e = n.next();
|
|
515
515
|
if (e.done)
|
|
@@ -522,7 +522,7 @@ const Le = (n, e, t = !1) => {
|
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
524
|
},
|
|
525
|
-
[
|
|
525
|
+
[Re]() {
|
|
526
526
|
return this.entries();
|
|
527
527
|
}
|
|
528
528
|
}, fr = Reflect.ownKeys(ot), xt = (n, e, { isValuesIterator: t }) => () => {
|
|
@@ -533,7 +533,7 @@ const Le = (n, e, t = !1) => {
|
|
|
533
533
|
const o = i.value;
|
|
534
534
|
let a = n.setMap.get(o);
|
|
535
535
|
const c = S(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, W)) === W.mutable;
|
|
536
|
-
if (n.options.strict &&
|
|
536
|
+
if (n.options.strict && Fe(o, n.options, u), !u && !c && J(o, n.options) && !n.finalized && n.original.has(o)) {
|
|
537
537
|
const l = Tt.createDraft({
|
|
538
538
|
original: o,
|
|
539
539
|
parentDraft: n,
|
|
@@ -547,7 +547,7 @@ const Le = (n, e, t = !1) => {
|
|
|
547
547
|
done: !1,
|
|
548
548
|
value: t ? a : [a, a]
|
|
549
549
|
};
|
|
550
|
-
},
|
|
550
|
+
}, Ne = {
|
|
551
551
|
get size() {
|
|
552
552
|
return S(this).setMap.size;
|
|
553
553
|
},
|
|
@@ -555,19 +555,19 @@ const Le = (n, e, t = !1) => {
|
|
|
555
555
|
const e = S(this);
|
|
556
556
|
if (e.setMap.has(n))
|
|
557
557
|
return !0;
|
|
558
|
-
|
|
558
|
+
U(e);
|
|
559
559
|
const t = S(n);
|
|
560
560
|
return !!(t && e.setMap.has(t.original));
|
|
561
561
|
},
|
|
562
562
|
add(n) {
|
|
563
563
|
const e = S(this);
|
|
564
|
-
return this.has(n) || (
|
|
564
|
+
return this.has(n) || (U(e), X(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), Ot(e, n, n, Ie)), this;
|
|
565
565
|
},
|
|
566
566
|
delete(n) {
|
|
567
567
|
if (!this.has(n))
|
|
568
568
|
return !1;
|
|
569
569
|
const e = S(this);
|
|
570
|
-
|
|
570
|
+
U(e), X(e);
|
|
571
571
|
const t = S(n);
|
|
572
572
|
return t && e.setMap.has(t.original) ? (e.assignedMap.set(t.original, !1), e.setMap.delete(t.original)) : (!t && e.setMap.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.setMap.delete(n));
|
|
573
573
|
},
|
|
@@ -575,14 +575,14 @@ const Le = (n, e, t = !1) => {
|
|
|
575
575
|
if (!this.size)
|
|
576
576
|
return;
|
|
577
577
|
const n = S(this);
|
|
578
|
-
|
|
578
|
+
U(n), X(n);
|
|
579
579
|
for (const e of n.original)
|
|
580
580
|
n.assignedMap.set(e, !1);
|
|
581
581
|
n.setMap.clear();
|
|
582
582
|
},
|
|
583
583
|
values() {
|
|
584
584
|
const n = S(this);
|
|
585
|
-
|
|
585
|
+
U(n);
|
|
586
586
|
const e = n.setMap.keys();
|
|
587
587
|
return {
|
|
588
588
|
[Symbol.iterator]: () => this.values(),
|
|
@@ -591,7 +591,7 @@ const Le = (n, e, t = !1) => {
|
|
|
591
591
|
},
|
|
592
592
|
entries() {
|
|
593
593
|
const n = S(this);
|
|
594
|
-
|
|
594
|
+
U(n);
|
|
595
595
|
const e = n.setMap.keys();
|
|
596
596
|
return {
|
|
597
597
|
[Symbol.iterator]: () => this.entries(),
|
|
@@ -603,7 +603,7 @@ const Le = (n, e, t = !1) => {
|
|
|
603
603
|
keys() {
|
|
604
604
|
return this.values();
|
|
605
605
|
},
|
|
606
|
-
[
|
|
606
|
+
[Re]() {
|
|
607
607
|
return this.values();
|
|
608
608
|
},
|
|
609
609
|
forEach(n, e) {
|
|
@@ -613,7 +613,7 @@ const Le = (n, e, t = !1) => {
|
|
|
613
613
|
n.call(e, r.value, r.value, this), r = t.next();
|
|
614
614
|
}
|
|
615
615
|
};
|
|
616
|
-
Set.prototype.difference && Object.assign(
|
|
616
|
+
Set.prototype.difference && Object.assign(Ne, {
|
|
617
617
|
intersection(n) {
|
|
618
618
|
return Set.prototype.intersection.call(new Set(this.values()), n);
|
|
619
619
|
},
|
|
@@ -636,7 +636,7 @@ Set.prototype.difference && Object.assign(Fe, {
|
|
|
636
636
|
return Set.prototype.isDisjointFrom.call(new Set(this.values()), n);
|
|
637
637
|
}
|
|
638
638
|
});
|
|
639
|
-
const hr = Reflect.ownKeys(
|
|
639
|
+
const hr = Reflect.ownKeys(Ne), mn = /* @__PURE__ */ new WeakSet(), wn = {
|
|
640
640
|
get(n, e, t) {
|
|
641
641
|
var r, s;
|
|
642
642
|
const i = (r = n.copy) === null || r === void 0 ? void 0 : r[e];
|
|
@@ -648,7 +648,7 @@ const hr = Reflect.ownKeys(Fe), mn = /* @__PURE__ */ new WeakSet(), _n = {
|
|
|
648
648
|
if (n.options.mark) {
|
|
649
649
|
const u = e === "size" && (n.original instanceof Map || n.original instanceof Set) ? Reflect.get(n.original, e) : Reflect.get(n.original, e, t);
|
|
650
650
|
if (o = n.options.mark(u, W), o === W.mutable)
|
|
651
|
-
return n.options.strict &&
|
|
651
|
+
return n.options.strict && Fe(u, n.options, !0), u;
|
|
652
652
|
}
|
|
653
653
|
const a = z(n);
|
|
654
654
|
if (a instanceof Map && fr.includes(e)) {
|
|
@@ -660,8 +660,8 @@ const hr = Reflect.ownKeys(Fe), mn = /* @__PURE__ */ new WeakSet(), _n = {
|
|
|
660
660
|
}
|
|
661
661
|
if (a instanceof Set && hr.includes(e)) {
|
|
662
662
|
if (e === "size")
|
|
663
|
-
return Object.getOwnPropertyDescriptor(
|
|
664
|
-
const u =
|
|
663
|
+
return Object.getOwnPropertyDescriptor(Ne, "size").get.call(n.proxy);
|
|
664
|
+
const u = Ne[e];
|
|
665
665
|
if (u)
|
|
666
666
|
return u.bind(n.proxy);
|
|
667
667
|
}
|
|
@@ -673,10 +673,10 @@ const hr = Reflect.ownKeys(Fe), mn = /* @__PURE__ */ new WeakSet(), _n = {
|
|
|
673
673
|
) : void 0;
|
|
674
674
|
}
|
|
675
675
|
const c = a[e];
|
|
676
|
-
if (n.options.strict &&
|
|
676
|
+
if (n.options.strict && Fe(c, n.options), n.finalized || !J(c, n.options))
|
|
677
677
|
return c;
|
|
678
678
|
if (c === Ye(n.original, e)) {
|
|
679
|
-
if (
|
|
679
|
+
if (U(n), n.copy[e] = It({
|
|
680
680
|
original: n.original[e],
|
|
681
681
|
parentDraft: n,
|
|
682
682
|
key: n.type === 1 ? Number(e) : e,
|
|
@@ -684,7 +684,7 @@ const hr = Reflect.ownKeys(Fe), mn = /* @__PURE__ */ new WeakSet(), _n = {
|
|
|
684
684
|
options: n.options
|
|
685
685
|
}), typeof o == "function") {
|
|
686
686
|
const u = S(n.copy[e]);
|
|
687
|
-
return
|
|
687
|
+
return U(u), X(u), u.copy;
|
|
688
688
|
}
|
|
689
689
|
return n.copy[e];
|
|
690
690
|
}
|
|
@@ -701,7 +701,7 @@ const hr = Reflect.ownKeys(Fe), mn = /* @__PURE__ */ new WeakSet(), _n = {
|
|
|
701
701
|
if (i?.set)
|
|
702
702
|
return i.set.call(n.proxy, t), !0;
|
|
703
703
|
const o = Ye(z(n), e), a = S(o);
|
|
704
|
-
return a && re(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) : (re(t, o) && (t !== void 0 || Ae(n.original, e)) || (
|
|
704
|
+
return a && re(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) : (re(t, o) && (t !== void 0 || Ae(n.original, e)) || (U(n), X(n), Ae(n.original, e) && re(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Ot(n, e, t, Ie)), !0);
|
|
705
705
|
},
|
|
706
706
|
has(n, e) {
|
|
707
707
|
return e in z(n);
|
|
@@ -729,7 +729,7 @@ const hr = Reflect.ownKeys(Fe), mn = /* @__PURE__ */ new WeakSet(), _n = {
|
|
|
729
729
|
},
|
|
730
730
|
deleteProperty(n, e) {
|
|
731
731
|
var t;
|
|
732
|
-
return n.type === 1 ?
|
|
732
|
+
return n.type === 1 ? wn.set.call(this, n, e, void 0, n.proxy) : (Ye(n.original, e) !== void 0 || e in n.original ? (U(n), X(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);
|
|
733
733
|
}
|
|
734
734
|
};
|
|
735
735
|
function It(n) {
|
|
@@ -746,7 +746,7 @@ function It(n) {
|
|
|
746
746
|
setMap: o === 3 ? new Map(e.entries()) : void 0
|
|
747
747
|
};
|
|
748
748
|
(r || "key" in n) && (a.key = r);
|
|
749
|
-
const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a,
|
|
749
|
+
const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, wn);
|
|
750
750
|
if (s.revoke.push(u), mn.add(c), a.proxy = c, t) {
|
|
751
751
|
const l = t;
|
|
752
752
|
l.finalities.draft.push((f, d) => {
|
|
@@ -755,11 +755,11 @@ function It(n) {
|
|
|
755
755
|
let g = l.type === 3 ? l.setMap : l.copy;
|
|
756
756
|
const y = se(g, r), b = S(y);
|
|
757
757
|
if (b) {
|
|
758
|
-
let
|
|
759
|
-
b.operated && (
|
|
758
|
+
let w = b.original;
|
|
759
|
+
b.operated && (w = At(y)), st(b), it(b, Ie, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (h = l.options.updatedValues) !== null && h !== void 0 ? h : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(w, b.original)), Ce(g, r, w);
|
|
760
760
|
}
|
|
761
|
-
(p = m.callbacks) === null || p === void 0 || p.forEach((
|
|
762
|
-
|
|
761
|
+
(p = m.callbacks) === null || p === void 0 || p.forEach((w) => {
|
|
762
|
+
w(f, d);
|
|
763
763
|
});
|
|
764
764
|
});
|
|
765
765
|
} else {
|
|
@@ -822,7 +822,7 @@ function at(n) {
|
|
|
822
822
|
} else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, at(n));
|
|
823
823
|
}), 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."));
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function _n(n) {
|
|
826
826
|
var e;
|
|
827
827
|
const t = S(n);
|
|
828
828
|
if (!J(n, t?.options))
|
|
@@ -846,7 +846,7 @@ function wn(n) {
|
|
|
846
846
|
if (kt(s, (o, a) => {
|
|
847
847
|
if (t && re(se(t.original, o), a))
|
|
848
848
|
return;
|
|
849
|
-
const c =
|
|
849
|
+
const c = _n(a);
|
|
850
850
|
c !== a && (s === n && i(), Ce(s, o, c));
|
|
851
851
|
}), r === 3) {
|
|
852
852
|
const o = (e = t?.original) !== null && e !== void 0 ? e : s;
|
|
@@ -857,26 +857,26 @@ function wn(n) {
|
|
|
857
857
|
function Ut(n) {
|
|
858
858
|
if (!de(n))
|
|
859
859
|
throw new Error(`current() is only used for Draft, parameter: ${n}`);
|
|
860
|
-
return
|
|
860
|
+
return _n(n);
|
|
861
861
|
}
|
|
862
862
|
const br = (n) => function e(t, r, s) {
|
|
863
863
|
var i, o, a;
|
|
864
864
|
if (typeof t == "function" && typeof r != "function")
|
|
865
|
-
return function(
|
|
866
|
-
return e(
|
|
865
|
+
return function(_, ...k) {
|
|
866
|
+
return e(_, (O) => t.call(this, O, ...k), r);
|
|
867
867
|
};
|
|
868
868
|
const c = t, u = r;
|
|
869
869
|
let l = s;
|
|
870
870
|
if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
|
|
871
871
|
throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
|
|
872
872
|
l = Object.assign(Object.assign({}, n), l);
|
|
873
|
-
const f = de(c) ? Ut(c) : c, d = Array.isArray(l.mark) ? ((
|
|
873
|
+
const f = de(c) ? Ut(c) : c, d = Array.isArray(l.mark) ? ((_, k) => {
|
|
874
874
|
for (const O of l.mark) {
|
|
875
875
|
if (typeof O != "function")
|
|
876
876
|
throw new Error(`Invalid mark: ${O}, 'mark' should be a function.`);
|
|
877
|
-
const
|
|
878
|
-
if (
|
|
879
|
-
return
|
|
877
|
+
const R = O(_, k);
|
|
878
|
+
if (R)
|
|
879
|
+
return R;
|
|
880
880
|
}
|
|
881
881
|
}) : l.mark, h = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, p = (o = l.strict) !== null && o !== void 0 ? o : !1, g = {
|
|
882
882
|
enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
|
|
@@ -892,43 +892,43 @@ const br = (n) => function e(t, r, s) {
|
|
|
892
892
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
893
893
|
return [y, b];
|
|
894
894
|
}
|
|
895
|
-
let
|
|
895
|
+
let w;
|
|
896
896
|
try {
|
|
897
|
-
|
|
898
|
-
} catch (
|
|
899
|
-
throw rt(S(y)),
|
|
897
|
+
w = u(y);
|
|
898
|
+
} catch (_) {
|
|
899
|
+
throw rt(S(y)), _;
|
|
900
900
|
}
|
|
901
|
-
const C = (
|
|
901
|
+
const C = (_) => {
|
|
902
902
|
const k = S(y);
|
|
903
|
-
if (!de(
|
|
904
|
-
if (
|
|
903
|
+
if (!de(_)) {
|
|
904
|
+
if (_ !== void 0 && !re(_, y) && k?.operated)
|
|
905
905
|
throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
const V =
|
|
909
|
-
return g.strict && typeof
|
|
906
|
+
const R = _?.[sr];
|
|
907
|
+
if (R) {
|
|
908
|
+
const V = R[0];
|
|
909
|
+
return g.strict && typeof _ == "object" && _ !== null && at({
|
|
910
910
|
rootDraft: k,
|
|
911
|
-
value:
|
|
911
|
+
value: _,
|
|
912
912
|
useRawReturn: !0
|
|
913
913
|
}), b([V]);
|
|
914
914
|
}
|
|
915
|
-
if (
|
|
916
|
-
return typeof
|
|
915
|
+
if (_ !== void 0)
|
|
916
|
+
return typeof _ == "object" && _ !== null && at({ rootDraft: k, value: _ }), b([_]);
|
|
917
917
|
}
|
|
918
|
-
if (
|
|
918
|
+
if (_ === y || _ === void 0)
|
|
919
919
|
return b([]);
|
|
920
|
-
const O = S(
|
|
920
|
+
const O = S(_);
|
|
921
921
|
if (g === O.options) {
|
|
922
922
|
if (O.operated)
|
|
923
923
|
throw new Error("Cannot return a modified child draft.");
|
|
924
|
-
return b([Ut(
|
|
924
|
+
return b([Ut(_)]);
|
|
925
925
|
}
|
|
926
|
-
return b([
|
|
926
|
+
return b([_]);
|
|
927
927
|
};
|
|
928
|
-
return
|
|
929
|
-
throw rt(S(y)),
|
|
930
|
-
}) : C(
|
|
931
|
-
},
|
|
928
|
+
return w instanceof Promise ? w.then(C, (_) => {
|
|
929
|
+
throw rt(S(y)), _;
|
|
930
|
+
}) : C(w);
|
|
931
|
+
}, qe = br();
|
|
932
932
|
Object.prototype.constructor.toString();
|
|
933
933
|
function Tn(n, e) {
|
|
934
934
|
const t = Object.keys(n), r = Object.keys(e);
|
|
@@ -939,9 +939,9 @@ function Lt(n, e) {
|
|
|
939
939
|
(t) => e.hasOwnProperty(t) && n[t] === e[t]
|
|
940
940
|
);
|
|
941
941
|
}
|
|
942
|
-
function
|
|
942
|
+
function Ue(n, e) {
|
|
943
943
|
return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Tn(n, e) ? Object.keys(n).every(
|
|
944
|
-
(t) =>
|
|
944
|
+
(t) => Ue(n[t], e[t])
|
|
945
945
|
) : !1;
|
|
946
946
|
}
|
|
947
947
|
function Ct(n) {
|
|
@@ -1006,7 +1006,7 @@ function vn(n, e) {
|
|
|
1006
1006
|
function mr(n) {
|
|
1007
1007
|
return n && Object.keys(n).length === 0;
|
|
1008
1008
|
}
|
|
1009
|
-
const Nt = /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$/,
|
|
1009
|
+
const Nt = /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$/, wr = {
|
|
1010
1010
|
ZULU: 0,
|
|
1011
1011
|
YEKT: 18e3,
|
|
1012
1012
|
YEKST: 21600,
|
|
@@ -1202,7 +1202,7 @@ const Nt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
|
|
|
1202
1202
|
ACSST: 37800,
|
|
1203
1203
|
ACDT: 37800
|
|
1204
1204
|
};
|
|
1205
|
-
function
|
|
1205
|
+
function _r(n) {
|
|
1206
1206
|
return new Date(n);
|
|
1207
1207
|
}
|
|
1208
1208
|
function Tr(n) {
|
|
@@ -1285,7 +1285,7 @@ function jr(n) {
|
|
|
1285
1285
|
const e = n.match(Nt);
|
|
1286
1286
|
if (!e)
|
|
1287
1287
|
return null;
|
|
1288
|
-
const [t] = e, r =
|
|
1288
|
+
const [t] = e, r = wr[t], s = new Date(n.replace(Nt, "Z"));
|
|
1289
1289
|
return new Date(s.getTime() - r * 1e3);
|
|
1290
1290
|
}
|
|
1291
1291
|
const Dr = [
|
|
@@ -1297,7 +1297,7 @@ const Dr = [
|
|
|
1297
1297
|
Tr,
|
|
1298
1298
|
Cr,
|
|
1299
1299
|
Ar,
|
|
1300
|
-
|
|
1300
|
+
_r,
|
|
1301
1301
|
Pr,
|
|
1302
1302
|
jr,
|
|
1303
1303
|
Er
|
|
@@ -1326,7 +1326,7 @@ function Rr(n) {
|
|
|
1326
1326
|
return null;
|
|
1327
1327
|
}
|
|
1328
1328
|
}
|
|
1329
|
-
function
|
|
1329
|
+
function We(n) {
|
|
1330
1330
|
if (n !== void 0) {
|
|
1331
1331
|
if (n === null)
|
|
1332
1332
|
return null;
|
|
@@ -1377,7 +1377,7 @@ class ie {
|
|
|
1377
1377
|
for (const e of Object.values(this.attrs))
|
|
1378
1378
|
if (Mt(e)) {
|
|
1379
1379
|
const [t, r, s] = e["forward-identity"];
|
|
1380
|
-
|
|
1380
|
+
N(this.blobAttrs, [r, s], e);
|
|
1381
1381
|
}
|
|
1382
1382
|
return this._blobAttrs;
|
|
1383
1383
|
}
|
|
@@ -1388,7 +1388,7 @@ class ie {
|
|
|
1388
1388
|
for (const e of Object.values(this.attrs))
|
|
1389
1389
|
if (e["primary?"]) {
|
|
1390
1390
|
const [t, r] = e["forward-identity"];
|
|
1391
|
-
|
|
1391
|
+
N(this._primaryKeys, [r], e);
|
|
1392
1392
|
}
|
|
1393
1393
|
return this._primaryKeys;
|
|
1394
1394
|
}
|
|
@@ -1398,7 +1398,7 @@ class ie {
|
|
|
1398
1398
|
this._forwardIdents = /* @__PURE__ */ new Map();
|
|
1399
1399
|
for (const e of Object.values(this.attrs)) {
|
|
1400
1400
|
const t = e["forward-identity"], [r, s, i] = t;
|
|
1401
|
-
|
|
1401
|
+
N(this._forwardIdents, [s, i], e);
|
|
1402
1402
|
}
|
|
1403
1403
|
return this._forwardIdents;
|
|
1404
1404
|
}
|
|
@@ -1410,7 +1410,7 @@ class ie {
|
|
|
1410
1410
|
const t = e["reverse-identity"];
|
|
1411
1411
|
if (t) {
|
|
1412
1412
|
const [r, s, i] = t;
|
|
1413
|
-
|
|
1413
|
+
N(this._revIdents, [s, i], e);
|
|
1414
1414
|
}
|
|
1415
1415
|
}
|
|
1416
1416
|
return this._revIdents;
|
|
@@ -1428,7 +1428,7 @@ function Et(n) {
|
|
|
1428
1428
|
function Mt(n) {
|
|
1429
1429
|
return n["value-type"] === "blob";
|
|
1430
1430
|
}
|
|
1431
|
-
function
|
|
1431
|
+
function _e(n, e) {
|
|
1432
1432
|
return e.reduce((t, r) => t && t.get(r), n);
|
|
1433
1433
|
}
|
|
1434
1434
|
function H(n, e) {
|
|
@@ -1440,7 +1440,7 @@ function H(n, e) {
|
|
|
1440
1440
|
const [t, ...r] = e;
|
|
1441
1441
|
n.has(t) && H(n.get(t), r);
|
|
1442
1442
|
}
|
|
1443
|
-
function
|
|
1443
|
+
function N(n, e, t) {
|
|
1444
1444
|
let r = n;
|
|
1445
1445
|
const s = e.length - 1;
|
|
1446
1446
|
for (let i = 0; i < s; i++) {
|
|
@@ -1459,13 +1459,13 @@ function An(n, e, t) {
|
|
|
1459
1459
|
console.warn("no such attr", c, a);
|
|
1460
1460
|
continue;
|
|
1461
1461
|
}
|
|
1462
|
-
l["checked-data-type"] === "date" && t && (u =
|
|
1462
|
+
l["checked-data-type"] === "date" && t && (u = We(u), o[2] = u), Et(l) && N(i, [u, c, a], o), N(r, [a, c, u], o), N(s, [c, a, u], o);
|
|
1463
1463
|
}
|
|
1464
1464
|
return { eav: r, aev: s, vae: i };
|
|
1465
1465
|
}
|
|
1466
1466
|
function kn(n) {
|
|
1467
1467
|
return {
|
|
1468
|
-
triples:
|
|
1468
|
+
triples: q(n.eav, 3),
|
|
1469
1469
|
cardinalityInference: n.cardinalityInference,
|
|
1470
1470
|
useDateObjects: n.useDateObjects,
|
|
1471
1471
|
version: 1
|
|
@@ -1486,7 +1486,7 @@ function In(n, e) {
|
|
|
1486
1486
|
return new ie(e.attrs, e.linkIndex);
|
|
1487
1487
|
}
|
|
1488
1488
|
function Ur(n, e) {
|
|
1489
|
-
return
|
|
1489
|
+
return _e(n.eav, [e]) !== void 0;
|
|
1490
1490
|
}
|
|
1491
1491
|
function be(n, e, t, r) {
|
|
1492
1492
|
const s = An(
|
|
@@ -1502,7 +1502,7 @@ function Ee(n, e) {
|
|
|
1502
1502
|
const [s, i] = e[0], o = n.aev.get(s);
|
|
1503
1503
|
if (!o)
|
|
1504
1504
|
return null;
|
|
1505
|
-
t =
|
|
1505
|
+
t = q(o, 2).find((c) => c[2] === i)?.[0];
|
|
1506
1506
|
} else
|
|
1507
1507
|
t = e[0];
|
|
1508
1508
|
if (!t)
|
|
@@ -1512,7 +1512,7 @@ function Ee(n, e) {
|
|
|
1512
1512
|
const [s, i] = r, o = n.aev.get(s);
|
|
1513
1513
|
if (!o)
|
|
1514
1514
|
return null;
|
|
1515
|
-
const c =
|
|
1515
|
+
const c = q(o, 2).find((h) => h[2] === i)?.[0];
|
|
1516
1516
|
if (!c)
|
|
1517
1517
|
return null;
|
|
1518
1518
|
const [u, l, f, ...d] = e;
|
|
@@ -1533,7 +1533,7 @@ let Lr = 0;
|
|
|
1533
1533
|
function En(n, e, t) {
|
|
1534
1534
|
const [r, s, i] = t;
|
|
1535
1535
|
let o;
|
|
1536
|
-
const a =
|
|
1536
|
+
const a = _e(n.eav, [r, s, i]);
|
|
1537
1537
|
return a && (o = a[3]), o || Date.now() * 10 + Lr++;
|
|
1538
1538
|
}
|
|
1539
1539
|
function Mn(n, e, t) {
|
|
@@ -1544,9 +1544,9 @@ function Mn(n, e, t) {
|
|
|
1544
1544
|
const a = e.getAttr(i);
|
|
1545
1545
|
if (!a)
|
|
1546
1546
|
return;
|
|
1547
|
-
a["checked-data-type"] === "date" && n.useDateObjects && (o =
|
|
1548
|
-
const u =
|
|
1549
|
-
xr(a) ? (
|
|
1547
|
+
a["checked-data-type"] === "date" && n.useDateObjects && (o = We(o));
|
|
1548
|
+
const u = _e(n.eav, [s, i, o])?.[3] ?? En(n, a, r), l = [s, i, o, u];
|
|
1549
|
+
xr(a) ? (N(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), N(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (N(n.eav, [s, i, o], l), N(n.aev, [i, s, o], l)), Et(a) && N(n.vae, [o, i, s], l);
|
|
1550
1550
|
}
|
|
1551
1551
|
function Fr(n, e, t) {
|
|
1552
1552
|
const r = Ee(n, t);
|
|
@@ -1556,7 +1556,7 @@ function Fr(n, e, t) {
|
|
|
1556
1556
|
if (!a) return;
|
|
1557
1557
|
if (!Mt(a))
|
|
1558
1558
|
throw new Error("merge operation is not supported for links");
|
|
1559
|
-
const c =
|
|
1559
|
+
const c = _e(n.eav, [s, i]);
|
|
1560
1560
|
if (!c) return;
|
|
1561
1561
|
const u = c.values().next()?.value;
|
|
1562
1562
|
if (!u) return;
|
|
@@ -1566,7 +1566,7 @@ function Fr(n, e, t) {
|
|
|
1566
1566
|
f,
|
|
1567
1567
|
En(n, a, u)
|
|
1568
1568
|
];
|
|
1569
|
-
|
|
1569
|
+
N(n.eav, [s, i], /* @__PURE__ */ new Map([[f, d]])), N(n.aev, [i, s], /* @__PURE__ */ new Map([[f, d]]));
|
|
1570
1570
|
}
|
|
1571
1571
|
function ut(n, e, t) {
|
|
1572
1572
|
const [r, s] = t, i = Ee(n, [r]);
|
|
@@ -1576,7 +1576,7 @@ function ut(n, e, t) {
|
|
|
1576
1576
|
if (a) {
|
|
1577
1577
|
for (const u of a.keys()) {
|
|
1578
1578
|
const l = e.getAttr(u);
|
|
1579
|
-
l && l["on-delete-reverse"] === "cascade" &&
|
|
1579
|
+
l && l["on-delete-reverse"] === "cascade" && q(a.get(u), 1).forEach(
|
|
1580
1580
|
([f, d, h]) => ut(n, e, [h, l["reverse-identity"]?.[1]])
|
|
1581
1581
|
), // Fall back to deleting everything if we've rehydrated tx-steps from
|
|
1582
1582
|
// the store that didn't set `etype` in deleteEntity
|
|
@@ -1586,7 +1586,7 @@ function ut(n, e, t) {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
a.size === 0 && H(n.eav, [o]);
|
|
1588
1588
|
}
|
|
1589
|
-
const c = n.vae.get(o) &&
|
|
1589
|
+
const c = n.vae.get(o) && q(n.vae.get(o), 2);
|
|
1590
1590
|
c && c.forEach((u) => {
|
|
1591
1591
|
const [l, f, d] = u, h = e.getAttr(f);
|
|
1592
1592
|
(!s || !h || h["reverse-identity"]?.[1] === s) && (H(n.eav, [l, f, d]), H(n.aev, [f, l, d]), H(n.vae, [d, f, l])), h && h["on-delete"] === "cascade" && h["reverse-identity"]?.[1] === s && ut(n, e, [l, h["forward-identity"]?.[1]]);
|
|
@@ -1606,7 +1606,7 @@ function Nr(n, [e]) {
|
|
|
1606
1606
|
n.addAttr(e);
|
|
1607
1607
|
}
|
|
1608
1608
|
function jn(n) {
|
|
1609
|
-
return
|
|
1609
|
+
return q(n.eav, 3);
|
|
1610
1610
|
}
|
|
1611
1611
|
function qr(n, e, [t]) {
|
|
1612
1612
|
if (!e.getAttr(t)) return;
|
|
@@ -1648,7 +1648,7 @@ function zr(n, e, t) {
|
|
|
1648
1648
|
throw new Error(`unhandled transaction action: ${r}`);
|
|
1649
1649
|
}
|
|
1650
1650
|
}
|
|
1651
|
-
function
|
|
1651
|
+
function q(n, e, t = []) {
|
|
1652
1652
|
if (!n || e === 0)
|
|
1653
1653
|
return t;
|
|
1654
1654
|
if (e === 1) {
|
|
@@ -1657,10 +1657,10 @@ function N(n, e, t = []) {
|
|
|
1657
1657
|
return t;
|
|
1658
1658
|
}
|
|
1659
1659
|
for (const r of n.values())
|
|
1660
|
-
|
|
1660
|
+
q(r, e - 1, t);
|
|
1661
1661
|
return t;
|
|
1662
1662
|
}
|
|
1663
|
-
function
|
|
1663
|
+
function Pe(n, e, t) {
|
|
1664
1664
|
const r = [];
|
|
1665
1665
|
if (t?.hasOwnProperty("$not")) {
|
|
1666
1666
|
for (const i of e.keys())
|
|
@@ -1684,7 +1684,7 @@ function Me(n, e, t) {
|
|
|
1684
1684
|
return r;
|
|
1685
1685
|
}
|
|
1686
1686
|
if (t?.$comparator)
|
|
1687
|
-
return
|
|
1687
|
+
return q(e, 1).filter(t.$op);
|
|
1688
1688
|
const s = t.in || t.$in || [t];
|
|
1689
1689
|
for (const i of s) {
|
|
1690
1690
|
const o = e.get(i);
|
|
@@ -1700,15 +1700,15 @@ function Vr(n, [e, t, r]) {
|
|
|
1700
1700
|
switch (Wr(e, t, r)) {
|
|
1701
1701
|
case "e": {
|
|
1702
1702
|
const i = n.eav.get(e);
|
|
1703
|
-
return
|
|
1703
|
+
return q(i, 2);
|
|
1704
1704
|
}
|
|
1705
1705
|
case "ea": {
|
|
1706
1706
|
const i = n.eav.get(e)?.get(t);
|
|
1707
|
-
return
|
|
1707
|
+
return q(i, 1);
|
|
1708
1708
|
}
|
|
1709
1709
|
case "eav": {
|
|
1710
1710
|
const i = n.eav.get(e)?.get(t);
|
|
1711
|
-
return i ?
|
|
1711
|
+
return i ? Pe(n, i, r) : [];
|
|
1712
1712
|
}
|
|
1713
1713
|
case "ev": {
|
|
1714
1714
|
const i = n.eav.get(e);
|
|
@@ -1716,12 +1716,12 @@ function Vr(n, [e, t, r]) {
|
|
|
1716
1716
|
return [];
|
|
1717
1717
|
const o = [];
|
|
1718
1718
|
for (const a of i.values())
|
|
1719
|
-
o.push(...
|
|
1719
|
+
o.push(...Pe(n, a, r));
|
|
1720
1720
|
return o;
|
|
1721
1721
|
}
|
|
1722
1722
|
case "a": {
|
|
1723
1723
|
const i = n.aev.get(t);
|
|
1724
|
-
return
|
|
1724
|
+
return q(i, 2);
|
|
1725
1725
|
}
|
|
1726
1726
|
case "av": {
|
|
1727
1727
|
const i = n.aev.get(t);
|
|
@@ -1729,18 +1729,18 @@ function Vr(n, [e, t, r]) {
|
|
|
1729
1729
|
return [];
|
|
1730
1730
|
const o = [];
|
|
1731
1731
|
for (const a of i.values())
|
|
1732
|
-
o.push(...
|
|
1732
|
+
o.push(...Pe(n, a, r));
|
|
1733
1733
|
return o;
|
|
1734
1734
|
}
|
|
1735
1735
|
case "v": {
|
|
1736
1736
|
const i = [];
|
|
1737
1737
|
for (const o of n.eav.values())
|
|
1738
1738
|
for (const a of o.values())
|
|
1739
|
-
i.push(...
|
|
1739
|
+
i.push(...Pe(n, a, r));
|
|
1740
1740
|
return i;
|
|
1741
1741
|
}
|
|
1742
1742
|
default:
|
|
1743
|
-
return
|
|
1743
|
+
return q(n.eav, 3);
|
|
1744
1744
|
}
|
|
1745
1745
|
}
|
|
1746
1746
|
function Qr(n, e, t) {
|
|
@@ -1748,7 +1748,7 @@ function Qr(n, e, t) {
|
|
|
1748
1748
|
if (!e)
|
|
1749
1749
|
return r;
|
|
1750
1750
|
for (const [s, i] of e.entries()) {
|
|
1751
|
-
const o = n.eav.get(t)?.get(i.id), a =
|
|
1751
|
+
const o = n.eav.get(t)?.get(i.id), a = q(o, 1);
|
|
1752
1752
|
for (const c of a)
|
|
1753
1753
|
r[s] = c[2];
|
|
1754
1754
|
}
|
|
@@ -1773,7 +1773,7 @@ function Gr(n, e, t) {
|
|
|
1773
1773
|
return;
|
|
1774
1774
|
const [s, i, o] = r;
|
|
1775
1775
|
if (e.getAttr(i))
|
|
1776
|
-
return
|
|
1776
|
+
return _e(n.eav, [s, i]);
|
|
1777
1777
|
}
|
|
1778
1778
|
function Hr(n, e, t) {
|
|
1779
1779
|
const r = t.filter(
|
|
@@ -1799,7 +1799,7 @@ function Hr(n, e, t) {
|
|
|
1799
1799
|
return !(u === "create" && l || u === "update" && !l);
|
|
1800
1800
|
}
|
|
1801
1801
|
);
|
|
1802
|
-
return
|
|
1802
|
+
return qe(
|
|
1803
1803
|
{ store: n, attrsStore: e },
|
|
1804
1804
|
(s) => {
|
|
1805
1805
|
r.forEach((i) => {
|
|
@@ -1939,12 +1939,12 @@ const ea = (n) => {
|
|
|
1939
1939
|
};
|
|
1940
1940
|
let gs = 0;
|
|
1941
1941
|
function ke(n) {
|
|
1942
|
-
return
|
|
1942
|
+
return Ve(`_${n}`, gs++);
|
|
1943
1943
|
}
|
|
1944
|
-
function
|
|
1944
|
+
function Ve(n, e) {
|
|
1945
1945
|
return `?${n}-${e}`;
|
|
1946
1946
|
}
|
|
1947
|
-
class
|
|
1947
|
+
class we extends Error {
|
|
1948
1948
|
constructor(e) {
|
|
1949
1949
|
super(e), this.name = "AttrNotFoundError";
|
|
1950
1950
|
}
|
|
@@ -1952,13 +1952,13 @@ class _e extends Error {
|
|
|
1952
1952
|
function ms(n, e) {
|
|
1953
1953
|
const t = Dn(n, e);
|
|
1954
1954
|
if (!t)
|
|
1955
|
-
throw new
|
|
1955
|
+
throw new we(`Could not find id attr for ${e}`);
|
|
1956
1956
|
return t;
|
|
1957
1957
|
}
|
|
1958
1958
|
function Wt(n, e, t, r) {
|
|
1959
|
-
return [
|
|
1959
|
+
return [ws(n, e, t, r)];
|
|
1960
1960
|
}
|
|
1961
|
-
function
|
|
1961
|
+
function ws(n, e, t, r) {
|
|
1962
1962
|
return [
|
|
1963
1963
|
n(t, r),
|
|
1964
1964
|
ms(e, t).id,
|
|
@@ -1966,13 +1966,13 @@ function _s(n, e, t, r) {
|
|
|
1966
1966
|
n("time", r)
|
|
1967
1967
|
];
|
|
1968
1968
|
}
|
|
1969
|
-
function
|
|
1969
|
+
function _s(n, e, t) {
|
|
1970
1970
|
return n.map((r) => r === e ? t : r);
|
|
1971
1971
|
}
|
|
1972
1972
|
function xn(n, e, t, r, s) {
|
|
1973
1973
|
const i = P(e, t, s), o = he(e, t, s), a = i || o;
|
|
1974
1974
|
if (!a)
|
|
1975
|
-
throw new
|
|
1975
|
+
throw new we(`Could not find attr for ${[t, s]}`);
|
|
1976
1976
|
if (a["value-type"] !== "ref")
|
|
1977
1977
|
throw new Error(`Attr ${a.id} is not a ref`);
|
|
1978
1978
|
const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], d = r + 1, h = i ? [
|
|
@@ -2068,13 +2068,13 @@ function Ss(n, e, t, r, s, i) {
|
|
|
2068
2068
|
s
|
|
2069
2069
|
), c = o || a;
|
|
2070
2070
|
if (!c)
|
|
2071
|
-
throw new
|
|
2071
|
+
throw new we(
|
|
2072
2072
|
`No attr for etype = ${t} label = ${s}`
|
|
2073
2073
|
);
|
|
2074
2074
|
if (i?.hasOwnProperty("$isNull")) {
|
|
2075
2075
|
const u = P(e, t, "id");
|
|
2076
2076
|
if (!u)
|
|
2077
|
-
throw new
|
|
2077
|
+
throw new we(
|
|
2078
2078
|
`No attr for etype = ${t} label = id`
|
|
2079
2079
|
);
|
|
2080
2080
|
return [
|
|
@@ -2209,7 +2209,7 @@ function Un(n, e, t, r, s) {
|
|
|
2209
2209
|
});
|
|
2210
2210
|
}
|
|
2211
2211
|
function Es(n, e, t, r) {
|
|
2212
|
-
const s =
|
|
2212
|
+
const s = Ve;
|
|
2213
2213
|
return r ? Un(s, n, e, t, r).concat(Wt(s, n, e, t)) : Wt(s, n, e, t);
|
|
2214
2214
|
}
|
|
2215
2215
|
function Ms(n, e, t) {
|
|
@@ -2222,7 +2222,7 @@ function Ps(n, e, t, r, s, i) {
|
|
|
2222
2222
|
t,
|
|
2223
2223
|
r,
|
|
2224
2224
|
s
|
|
2225
|
-
), f =
|
|
2225
|
+
), f = _s(c, n(t, r), i);
|
|
2226
2226
|
return [o, a, f, u, l];
|
|
2227
2227
|
}
|
|
2228
2228
|
function js(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
@@ -2243,10 +2243,10 @@ function js(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
|
2243
2243
|
level: g,
|
|
2244
2244
|
form: i[h],
|
|
2245
2245
|
join: y
|
|
2246
|
-
}),
|
|
2247
|
-
return { [h]:
|
|
2246
|
+
}), w = p ? b[0] : b;
|
|
2247
|
+
return { [h]: w };
|
|
2248
2248
|
} catch (m) {
|
|
2249
|
-
if (m instanceof
|
|
2249
|
+
if (m instanceof we)
|
|
2250
2250
|
return { [h]: p ? void 0 : [] };
|
|
2251
2251
|
throw m;
|
|
2252
2252
|
}
|
|
@@ -2261,7 +2261,7 @@ function Ds(n, e, t) {
|
|
|
2261
2261
|
function ve(n, e, t, r, s) {
|
|
2262
2262
|
return e === r || e == null && r == null ? hs(n, t) : r == null ? 1 : e == null ? -1 : Ds(e, r, s);
|
|
2263
2263
|
}
|
|
2264
|
-
function
|
|
2264
|
+
function Ke([n, e], [t, r], s) {
|
|
2265
2265
|
return ve(n, e, t, r, s);
|
|
2266
2266
|
}
|
|
2267
2267
|
function ft(n) {
|
|
@@ -2270,9 +2270,9 @@ function ft(n) {
|
|
|
2270
2270
|
function $s(n, e, t, r) {
|
|
2271
2271
|
const [s, i, o, a] = n, c = t === "desc" ? 1 : -1;
|
|
2272
2272
|
if (e["forward-identity"]?.[2] === "id")
|
|
2273
|
-
return
|
|
2273
|
+
return Ke(r, [s, a], null) === c;
|
|
2274
2274
|
const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? ft(l) : l, h = f === "date" ? ft(o) : o;
|
|
2275
|
-
return
|
|
2275
|
+
return Ke([u, d], [s, h], f) === c;
|
|
2276
2276
|
}
|
|
2277
2277
|
function Rs(n, e) {
|
|
2278
2278
|
const t = e[1];
|
|
@@ -2315,9 +2315,9 @@ function Fs(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
|
|
|
2315
2315
|
}
|
|
2316
2316
|
u.sort(
|
|
2317
2317
|
c === "asc" ? function(m, g) {
|
|
2318
|
-
return
|
|
2318
|
+
return Ke(m, g, f?.["checked-data-type"]);
|
|
2319
2319
|
} : function(m, g) {
|
|
2320
|
-
return
|
|
2320
|
+
return Ke(g, m, f?.["checked-data-type"]);
|
|
2321
2321
|
}
|
|
2322
2322
|
);
|
|
2323
2323
|
let d = {};
|
|
@@ -2345,7 +2345,7 @@ function qs(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
|
|
|
2345
2345
|
const a = As(
|
|
2346
2346
|
Es(e, t, r, s.$?.where),
|
|
2347
2347
|
i
|
|
2348
|
-
), c = Ms(
|
|
2348
|
+
), c = Ms(Ve, t, r), u = s.$?.fields, l = Fs(n, e, {
|
|
2349
2349
|
etype: t,
|
|
2350
2350
|
pageInfo: o,
|
|
2351
2351
|
form: s,
|
|
@@ -2364,14 +2364,14 @@ function Ks(n, e, t) {
|
|
|
2364
2364
|
try {
|
|
2365
2365
|
return qs(n, e, t);
|
|
2366
2366
|
} catch (r) {
|
|
2367
|
-
if (r instanceof
|
|
2367
|
+
if (r instanceof we)
|
|
2368
2368
|
return {};
|
|
2369
2369
|
throw r;
|
|
2370
2370
|
}
|
|
2371
2371
|
}
|
|
2372
2372
|
function Fn(n, e, t) {
|
|
2373
2373
|
const r = Ks(n, e, t);
|
|
2374
|
-
return js(
|
|
2374
|
+
return js(Ve, n, e, t, r);
|
|
2375
2375
|
}
|
|
2376
2376
|
function zs(n) {
|
|
2377
2377
|
const e = {};
|
|
@@ -2415,7 +2415,7 @@ function Ws() {
|
|
|
2415
2415
|
return new Set(Object.keys(e));
|
|
2416
2416
|
}
|
|
2417
2417
|
const Vs = Ws();
|
|
2418
|
-
function
|
|
2418
|
+
function Le(n, e, t) {
|
|
2419
2419
|
const r = {
|
|
2420
2420
|
__etype: n,
|
|
2421
2421
|
__ops: t
|
|
@@ -2425,7 +2425,7 @@ function Ue(n, e, t) {
|
|
|
2425
2425
|
if (i === "__ops") return t;
|
|
2426
2426
|
if (i === "__etype") return n;
|
|
2427
2427
|
if (Vs.has(i))
|
|
2428
|
-
return (o, a) =>
|
|
2428
|
+
return (o, a) => Le(n, e, [
|
|
2429
2429
|
...t,
|
|
2430
2430
|
a ? [i, n, e, o, a] : [i, n, e, o]
|
|
2431
2431
|
]);
|
|
@@ -2435,7 +2435,7 @@ function Ue(n, e, t) {
|
|
|
2435
2435
|
function Qs(n, e) {
|
|
2436
2436
|
return `lookup__${n}__${JSON.stringify(e)}`;
|
|
2437
2437
|
}
|
|
2438
|
-
function
|
|
2438
|
+
function ze(n) {
|
|
2439
2439
|
return n.startsWith("lookup__");
|
|
2440
2440
|
}
|
|
2441
2441
|
function ht(n) {
|
|
@@ -2450,10 +2450,10 @@ function Bs(n) {
|
|
|
2450
2450
|
{
|
|
2451
2451
|
get(e, t) {
|
|
2452
2452
|
if (t === "lookup")
|
|
2453
|
-
return (s, i) =>
|
|
2453
|
+
return (s, i) => Le(n, ht(Qs(s, i)), []);
|
|
2454
2454
|
if (t === "__etype") return n;
|
|
2455
2455
|
const r = t;
|
|
2456
|
-
return
|
|
2456
|
+
return ze(r) ? Le(n, ht(r), []) : Le(n, r, []);
|
|
2457
2457
|
}
|
|
2458
2458
|
}
|
|
2459
2459
|
);
|
|
@@ -2521,9 +2521,9 @@ function Zs(n, e, t) {
|
|
|
2521
2521
|
return s;
|
|
2522
2522
|
}
|
|
2523
2523
|
function yt(n) {
|
|
2524
|
-
return typeof n == "string" && !
|
|
2524
|
+
return typeof n == "string" && !ze(n) ? null : typeof n == "string" && ze(n) ? ht(n) : Js(n);
|
|
2525
2525
|
}
|
|
2526
|
-
function
|
|
2526
|
+
function K(n, e, t) {
|
|
2527
2527
|
const r = yt(t);
|
|
2528
2528
|
if (r === null)
|
|
2529
2529
|
return t;
|
|
@@ -2533,7 +2533,7 @@ function q(n, e, t) {
|
|
|
2533
2533
|
return [o.id, i];
|
|
2534
2534
|
}
|
|
2535
2535
|
function qn(n, e, t, r) {
|
|
2536
|
-
const s =
|
|
2536
|
+
const s = K(n, e, t);
|
|
2537
2537
|
return Array.isArray(s) ? [[
|
|
2538
2538
|
"add-triple",
|
|
2539
2539
|
s,
|
|
@@ -2546,18 +2546,18 @@ function Xs({ attrsStore: n }, [e, t, r]) {
|
|
|
2546
2546
|
const a = Array.isArray(o) ? o : [o], c = P(n, e, i), u = he(n, e, i);
|
|
2547
2547
|
return a.map((l) => c ? [
|
|
2548
2548
|
"add-triple",
|
|
2549
|
-
|
|
2549
|
+
K(n, e, t),
|
|
2550
2550
|
c.id,
|
|
2551
2551
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2552
2552
|
// already exist
|
|
2553
|
-
|
|
2553
|
+
K(n, c["reverse-identity"][1], l)
|
|
2554
2554
|
] : [
|
|
2555
2555
|
"add-triple",
|
|
2556
2556
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2557
2557
|
// already exist
|
|
2558
|
-
|
|
2558
|
+
K(n, u["forward-identity"][1], l),
|
|
2559
2559
|
u?.id,
|
|
2560
|
-
|
|
2560
|
+
K(n, e, t)
|
|
2561
2561
|
]);
|
|
2562
2562
|
});
|
|
2563
2563
|
return qn(n, e, t, s);
|
|
@@ -2567,18 +2567,18 @@ function ei({ attrsStore: n }, [e, t, r]) {
|
|
|
2567
2567
|
const a = Array.isArray(o) ? o : [o], c = P(n, e, i), u = he(n, e, i);
|
|
2568
2568
|
return a.map((l) => c ? [
|
|
2569
2569
|
"retract-triple",
|
|
2570
|
-
|
|
2570
|
+
K(n, e, t),
|
|
2571
2571
|
c.id,
|
|
2572
2572
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2573
2573
|
// already exist
|
|
2574
|
-
|
|
2574
|
+
K(n, c["reverse-identity"][1], l)
|
|
2575
2575
|
] : [
|
|
2576
2576
|
"retract-triple",
|
|
2577
2577
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2578
2578
|
// already exist
|
|
2579
|
-
|
|
2579
|
+
K(n, u["forward-identity"][1], l),
|
|
2580
2580
|
u.id,
|
|
2581
|
-
|
|
2581
|
+
K(n, e, t)
|
|
2582
2582
|
]);
|
|
2583
2583
|
});
|
|
2584
2584
|
return qn(n, e, t, s);
|
|
@@ -2589,7 +2589,7 @@ function ti(n, e, t, r) {
|
|
|
2589
2589
|
for (const o of n || []) {
|
|
2590
2590
|
const a = o?.aev.get(s);
|
|
2591
2591
|
if (a) {
|
|
2592
|
-
for (const [c, u, l] of
|
|
2592
|
+
for (const [c, u, l] of q(a, 2))
|
|
2593
2593
|
if (l === i)
|
|
2594
2594
|
return !0;
|
|
2595
2595
|
}
|
|
@@ -2609,17 +2609,17 @@ function Kn({ stores: n, attrsStore: e }, [t, r, s, i]) {
|
|
|
2609
2609
|
return i?.upsert === !1 ? { mode: "update" } : i?.upsert === !0 ? null : ti(n, e, t, r) ? { mode: "update" } : null;
|
|
2610
2610
|
}
|
|
2611
2611
|
function ni(n, e) {
|
|
2612
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a = Ct(i), c =
|
|
2612
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = Ct(i), c = K(t, r, s);
|
|
2613
2613
|
return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
|
|
2614
2614
|
const d = P(t, r, l);
|
|
2615
|
-
return d["checked-data-type"] === "date" && n.useDateObjects && (f =
|
|
2615
|
+
return d["checked-data-type"] === "date" && n.useDateObjects && (f = We(f)), ["add-triple", c, d.id, f, { mode: "create" }];
|
|
2616
2616
|
});
|
|
2617
2617
|
}
|
|
2618
2618
|
function ri(n, e) {
|
|
2619
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a = Ct(i), c =
|
|
2619
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = Ct(i), c = K(t, r, s), u = Kn(n, [r, c, i, o]);
|
|
2620
2620
|
return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
|
|
2621
2621
|
const h = P(t, r, f);
|
|
2622
|
-
return h["checked-data-type"] === "date" && n.useDateObjects && (d =
|
|
2622
|
+
return h["checked-data-type"] === "date" && n.useDateObjects && (d = We(d)), [
|
|
2623
2623
|
"add-triple",
|
|
2624
2624
|
c,
|
|
2625
2625
|
h.id,
|
|
@@ -2629,10 +2629,10 @@ function ri(n, e) {
|
|
|
2629
2629
|
});
|
|
2630
2630
|
}
|
|
2631
2631
|
function si({ attrsStore: n }, [e, t]) {
|
|
2632
|
-
return [["delete-entity",
|
|
2632
|
+
return [["delete-entity", K(n, e, t), e]];
|
|
2633
2633
|
}
|
|
2634
2634
|
function ii(n, e) {
|
|
2635
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a = Ct(i), c =
|
|
2635
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = Ct(i), c = K(t, r, s), u = Kn(n, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
|
|
2636
2636
|
const p = P(t, r, d);
|
|
2637
2637
|
return [
|
|
2638
2638
|
"deep-merge-triple",
|
|
@@ -2651,7 +2651,7 @@ function ii(n, e) {
|
|
|
2651
2651
|
]].concat(l);
|
|
2652
2652
|
}
|
|
2653
2653
|
function oi({ attrsStore: n }, [e, t, r]) {
|
|
2654
|
-
return [["rule-params",
|
|
2654
|
+
return [["rule-params", K(n, e, t), e, r]];
|
|
2655
2655
|
}
|
|
2656
2656
|
function ai(n) {
|
|
2657
2657
|
const [e, t, r, s, i] = n;
|
|
@@ -2704,7 +2704,7 @@ function li(n, e, t) {
|
|
|
2704
2704
|
"checked-data-type": o
|
|
2705
2705
|
};
|
|
2706
2706
|
}
|
|
2707
|
-
function
|
|
2707
|
+
function je(n, e, t, r) {
|
|
2708
2708
|
const s = n ? li(n, e, t) : null, i = I(), a = [I(), e, t];
|
|
2709
2709
|
return {
|
|
2710
2710
|
id: i,
|
|
@@ -2784,7 +2784,7 @@ function mi(n) {
|
|
|
2784
2784
|
}
|
|
2785
2785
|
return e;
|
|
2786
2786
|
}
|
|
2787
|
-
function
|
|
2787
|
+
function wi({ attrsStore: n, schema: e }, t) {
|
|
2788
2788
|
const r = /* @__PURE__ */ new Set(), s = [], i = [];
|
|
2789
2789
|
function o(d, h) {
|
|
2790
2790
|
return P(n, d, h) || s.find(
|
|
@@ -2818,31 +2818,31 @@ function _i({ attrsStore: n, schema: e }, t) {
|
|
|
2818
2818
|
f(h, m);
|
|
2819
2819
|
const y = o(h, m), b = a(h, m);
|
|
2820
2820
|
u(y), u(b);
|
|
2821
|
-
const
|
|
2822
|
-
if (l(
|
|
2823
|
-
f(
|
|
2821
|
+
const w = y?.["reverse-identity"]?.[1] || b?.["forward-identity"]?.[1] || m;
|
|
2822
|
+
if (l(w, g))
|
|
2823
|
+
f(w, pt(g));
|
|
2824
2824
|
else {
|
|
2825
|
-
const C = o(
|
|
2825
|
+
const C = o(w, g);
|
|
2826
2826
|
C || c(
|
|
2827
|
-
|
|
2827
|
+
je(e, w, g, bt)
|
|
2828
2828
|
), u(C);
|
|
2829
2829
|
}
|
|
2830
2830
|
} else if (l(h, g))
|
|
2831
2831
|
f(h, pt(g));
|
|
2832
2832
|
else {
|
|
2833
2833
|
const y = o(h, g);
|
|
2834
|
-
y || c(
|
|
2834
|
+
y || c(je(e, h, g, bt)), u(y);
|
|
2835
2835
|
}
|
|
2836
2836
|
}
|
|
2837
2837
|
for (const d of t) {
|
|
2838
2838
|
const [h, p, m, g] = d;
|
|
2839
2839
|
if (hi.has(h)) {
|
|
2840
2840
|
const y = o(p, "id");
|
|
2841
|
-
u(y), y || c(
|
|
2841
|
+
u(y), y || c(je(e, p, "id", { "unique?": !0 }));
|
|
2842
2842
|
for (const b of Object.keys(g)) {
|
|
2843
|
-
const
|
|
2844
|
-
if (u(
|
|
2845
|
-
|
|
2843
|
+
const w = o(p, b);
|
|
2844
|
+
if (u(w), yi.has(h) && (w || c(
|
|
2845
|
+
je(
|
|
2846
2846
|
e,
|
|
2847
2847
|
p,
|
|
2848
2848
|
b,
|
|
@@ -2850,7 +2850,7 @@ function _i({ attrsStore: n, schema: e }, t) {
|
|
|
2850
2850
|
)
|
|
2851
2851
|
)), pi.has(h)) {
|
|
2852
2852
|
const C = a(p, b);
|
|
2853
|
-
!
|
|
2853
|
+
!w && !C && c(Gt(e, p, b)), u(C);
|
|
2854
2854
|
}
|
|
2855
2855
|
}
|
|
2856
2856
|
}
|
|
@@ -2863,8 +2863,8 @@ function _i({ attrsStore: n, schema: e }, t) {
|
|
|
2863
2863
|
}
|
|
2864
2864
|
return [n, i];
|
|
2865
2865
|
}
|
|
2866
|
-
function
|
|
2867
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Gs(c)), [s, i] =
|
|
2866
|
+
function _i(n, e) {
|
|
2867
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Gs(c)), [s, i] = wi(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => ci(o, c));
|
|
2868
2868
|
return [...i, ...a];
|
|
2869
2869
|
}
|
|
2870
2870
|
function Ht(n, e) {
|
|
@@ -3104,7 +3104,7 @@ class gt {
|
|
|
3104
3104
|
// so that we know which entries we need to persist to the store.
|
|
3105
3105
|
updateInPlace(e) {
|
|
3106
3106
|
this._version++;
|
|
3107
|
-
const [t, r] =
|
|
3107
|
+
const [t, r] = qe(this.currentValue, e, {
|
|
3108
3108
|
enablePatches: !0
|
|
3109
3109
|
});
|
|
3110
3110
|
for (const s of r) {
|
|
@@ -3334,25 +3334,26 @@ class Vn {
|
|
|
3334
3334
|
};
|
|
3335
3335
|
}
|
|
3336
3336
|
}
|
|
3337
|
-
class
|
|
3337
|
+
class $ extends Error {
|
|
3338
3338
|
hint;
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3339
|
+
traceId;
|
|
3340
|
+
constructor(e, t, r) {
|
|
3341
|
+
super(e), this.hint = t, r && (this.traceId = r);
|
|
3342
|
+
const s = new.target.prototype;
|
|
3343
|
+
Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, $), this.name = "InstantError";
|
|
3343
3344
|
}
|
|
3344
3345
|
get [Symbol.toStringTag]() {
|
|
3345
3346
|
return "InstantError";
|
|
3346
3347
|
}
|
|
3347
3348
|
}
|
|
3348
|
-
class
|
|
3349
|
+
class Me extends $ {
|
|
3349
3350
|
body;
|
|
3350
3351
|
status;
|
|
3351
3352
|
constructor(e) {
|
|
3352
3353
|
const t = e.body?.message || `API Error (${e.status})`;
|
|
3353
|
-
super(t, e.body.hint);
|
|
3354
|
+
super(t, e.body.hint, e.body["trace-id"]);
|
|
3354
3355
|
const r = new.target.prototype;
|
|
3355
|
-
Object.setPrototypeOf && Object.setPrototypeOf(this, r), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
3356
|
+
Object.setPrototypeOf && Object.setPrototypeOf(this, r), Error.captureStackTrace && Error.captureStackTrace(this, Me), this.name = "InstantAPIError", this.status = e.status, this.body = e.body;
|
|
3356
3357
|
}
|
|
3357
3358
|
get [Symbol.toStringTag]() {
|
|
3358
3359
|
return "InstantAPIError";
|
|
@@ -3360,7 +3361,7 @@ class Ve extends K {
|
|
|
3360
3361
|
}
|
|
3361
3362
|
async function Y(n, e) {
|
|
3362
3363
|
const t = await fetch(n, e), r = await t.json();
|
|
3363
|
-
return t.status === 200 ? Promise.resolve(r) : Promise.reject(new
|
|
3364
|
+
return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Me({ status: t.status, body: r }));
|
|
3364
3365
|
}
|
|
3365
3366
|
function Ii({
|
|
3366
3367
|
apiURI: n,
|
|
@@ -3631,7 +3632,7 @@ function mt(n) {
|
|
|
3631
3632
|
link: t
|
|
3632
3633
|
}, e), {});
|
|
3633
3634
|
}
|
|
3634
|
-
const Hn = "v0.22.
|
|
3635
|
+
const Hn = "v0.22.156";
|
|
3635
3636
|
function Ni(n, e) {
|
|
3636
3637
|
return {
|
|
3637
3638
|
info: n ? (...t) => console.info(...t, e()) : () => {
|
|
@@ -3642,7 +3643,7 @@ function Ni(n, e) {
|
|
|
3642
3643
|
}
|
|
3643
3644
|
};
|
|
3644
3645
|
}
|
|
3645
|
-
class
|
|
3646
|
+
class L {
|
|
3646
3647
|
constructor(e, t, r, s = { indexed: !1, unique: !1 }) {
|
|
3647
3648
|
this.valueType = e, this.required = t, this.isIndexed = r, this.config = s;
|
|
3648
3649
|
}
|
|
@@ -3653,7 +3654,7 @@ class U {
|
|
|
3653
3654
|
* and enforced for backend
|
|
3654
3655
|
*/
|
|
3655
3656
|
clientRequired() {
|
|
3656
|
-
return new
|
|
3657
|
+
return new L(
|
|
3657
3658
|
this.valueType,
|
|
3658
3659
|
!1,
|
|
3659
3660
|
this.isIndexed,
|
|
@@ -3661,7 +3662,7 @@ class U {
|
|
|
3661
3662
|
);
|
|
3662
3663
|
}
|
|
3663
3664
|
optional() {
|
|
3664
|
-
return new
|
|
3665
|
+
return new L(
|
|
3665
3666
|
this.valueType,
|
|
3666
3667
|
!1,
|
|
3667
3668
|
this.isIndexed,
|
|
@@ -3669,7 +3670,7 @@ class U {
|
|
|
3669
3670
|
);
|
|
3670
3671
|
}
|
|
3671
3672
|
unique() {
|
|
3672
|
-
return new
|
|
3673
|
+
return new L(
|
|
3673
3674
|
this.valueType,
|
|
3674
3675
|
this.required,
|
|
3675
3676
|
this.isIndexed,
|
|
@@ -3680,7 +3681,7 @@ class U {
|
|
|
3680
3681
|
);
|
|
3681
3682
|
}
|
|
3682
3683
|
indexed() {
|
|
3683
|
-
return new
|
|
3684
|
+
return new L(
|
|
3684
3685
|
this.valueType,
|
|
3685
3686
|
this.required,
|
|
3686
3687
|
!0,
|
|
@@ -3872,7 +3873,7 @@ const nn = [
|
|
|
3872
3873
|
ge(
|
|
3873
3874
|
e,
|
|
3874
3875
|
n,
|
|
3875
|
-
new
|
|
3876
|
+
new L("string", !1, !0),
|
|
3876
3877
|
t,
|
|
3877
3878
|
s
|
|
3878
3879
|
);
|
|
@@ -3888,7 +3889,7 @@ const nn = [
|
|
|
3888
3889
|
ge(
|
|
3889
3890
|
e,
|
|
3890
3891
|
n,
|
|
3891
|
-
new
|
|
3892
|
+
new L("string", !1, !0),
|
|
3892
3893
|
t,
|
|
3893
3894
|
s
|
|
3894
3895
|
);
|
|
@@ -3919,7 +3920,7 @@ const nn = [
|
|
|
3919
3920
|
ge(
|
|
3920
3921
|
i,
|
|
3921
3922
|
"id",
|
|
3922
|
-
new
|
|
3923
|
+
new L("string", !1, !0),
|
|
3923
3924
|
e,
|
|
3924
3925
|
`${r}.id`
|
|
3925
3926
|
);
|
|
@@ -3959,7 +3960,7 @@ const nn = [
|
|
|
3959
3960
|
`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`,
|
|
3960
3961
|
`${r}.${s}`
|
|
3961
3962
|
);
|
|
3962
|
-
const u = new
|
|
3963
|
+
const u = new L("string", !1, !0);
|
|
3963
3964
|
ge(
|
|
3964
3965
|
i,
|
|
3965
3966
|
s,
|
|
@@ -4083,7 +4084,7 @@ const nn = [
|
|
|
4083
4084
|
);
|
|
4084
4085
|
}
|
|
4085
4086
|
}
|
|
4086
|
-
}, sn = (n) => typeof n != "string" ? !1 :
|
|
4087
|
+
}, sn = (n) => typeof n != "string" ? !1 : ze(n) ? !0 : me(n);
|
|
4087
4088
|
class Q extends Error {
|
|
4088
4089
|
constructor(e) {
|
|
4089
4090
|
super(e), this.name = "TransactionValidationError";
|
|
@@ -4356,7 +4357,7 @@ function cn(n, e, t, r) {
|
|
|
4356
4357
|
const s = P(t, n.table, "id")?.id;
|
|
4357
4358
|
if (!s)
|
|
4358
4359
|
return -1;
|
|
4359
|
-
const i =
|
|
4360
|
+
const i = _e(e.eav, [r, s, r]);
|
|
4360
4361
|
return i ? i[3] : -1;
|
|
4361
4362
|
}
|
|
4362
4363
|
function un(n, e, t) {
|
|
@@ -4393,7 +4394,7 @@ function to(n, e, t) {
|
|
|
4393
4394
|
a === c && delete i[o];
|
|
4394
4395
|
return r;
|
|
4395
4396
|
}
|
|
4396
|
-
function
|
|
4397
|
+
function De(n, e) {
|
|
4397
4398
|
return { [n.table]: e.map((t) => t.entity) };
|
|
4398
4399
|
}
|
|
4399
4400
|
function no(n, e) {
|
|
@@ -4525,7 +4526,7 @@ class io {
|
|
|
4525
4526
|
if (s && s.state && s.state.txId) {
|
|
4526
4527
|
this.sendResync(s, s.state, s.state.txId), s.values?.entities && r && r({
|
|
4527
4528
|
type: "LoadFromStorage",
|
|
4528
|
-
data:
|
|
4529
|
+
data: De(s, s.values?.entities)
|
|
4529
4530
|
});
|
|
4530
4531
|
return;
|
|
4531
4532
|
}
|
|
@@ -4606,7 +4607,7 @@ class io {
|
|
|
4606
4607
|
u[s] = o, u[s].updatedAt = Date.now();
|
|
4607
4608
|
}), o.values && this.notifyCbs(s, {
|
|
4608
4609
|
type: "InitialSyncBatch",
|
|
4609
|
-
data:
|
|
4610
|
+
data: De(o, o.values.entities),
|
|
4610
4611
|
batch: i
|
|
4611
4612
|
});
|
|
4612
4613
|
}
|
|
@@ -4630,7 +4631,7 @@ class io {
|
|
|
4630
4631
|
const s = this.subs.currentValue[r];
|
|
4631
4632
|
s && this.notifyCbs(r, {
|
|
4632
4633
|
type: "InitialSyncComplete",
|
|
4633
|
-
data:
|
|
4634
|
+
data: De(s, s.values?.entities || [])
|
|
4634
4635
|
});
|
|
4635
4636
|
}
|
|
4636
4637
|
onSyncUpdateTriples(e) {
|
|
@@ -4669,16 +4670,16 @@ class io {
|
|
|
4669
4670
|
const b = l[y];
|
|
4670
4671
|
if (Ur(b.store, m)) {
|
|
4671
4672
|
un(b.store, u.attrsStore, g);
|
|
4672
|
-
const
|
|
4673
|
+
const w = et(s, b.store, u.attrsStore), C = to(
|
|
4673
4674
|
b.store,
|
|
4674
4675
|
u.attrsStore,
|
|
4675
4676
|
g
|
|
4676
4677
|
)[m];
|
|
4677
|
-
|
|
4678
|
+
w ? (f.push({
|
|
4678
4679
|
oldEntity: b.entity,
|
|
4679
|
-
newEntity:
|
|
4680
|
+
newEntity: w,
|
|
4680
4681
|
changedFields: C || {}
|
|
4681
|
-
}), b.entity =
|
|
4682
|
+
}), b.entity = w) : a.push(y), delete c[m];
|
|
4682
4683
|
continue e;
|
|
4683
4684
|
}
|
|
4684
4685
|
}
|
|
@@ -4712,7 +4713,7 @@ class io {
|
|
|
4712
4713
|
const p = no(s, this.getAttrs);
|
|
4713
4714
|
ro(s, p, l), this.notifyCbs(r, {
|
|
4714
4715
|
type: "SyncTransaction",
|
|
4715
|
-
data:
|
|
4716
|
+
data: De(s, s.values?.entities),
|
|
4716
4717
|
added: d,
|
|
4717
4718
|
removed: h,
|
|
4718
4719
|
updated: f
|
|
@@ -4764,13 +4765,13 @@ function oo({
|
|
|
4764
4765
|
let l = !1, f = !1;
|
|
4765
4766
|
const d = [], h = [], p = [];
|
|
4766
4767
|
let m = !1, g = 0, y = 0;
|
|
4767
|
-
const b = [],
|
|
4768
|
+
const b = [], w = new TextEncoder();
|
|
4768
4769
|
function C() {
|
|
4769
4770
|
f = !0;
|
|
4770
4771
|
for (const T of d)
|
|
4771
4772
|
T(a ?? void 0);
|
|
4772
4773
|
}
|
|
4773
|
-
function
|
|
4774
|
+
function _(T) {
|
|
4774
4775
|
return d.push(T), f && T(a ?? void 0), () => {
|
|
4775
4776
|
const v = d.indexOf(T);
|
|
4776
4777
|
v !== -1 && d.splice(v, 1);
|
|
@@ -4794,7 +4795,7 @@ function oo({
|
|
|
4794
4795
|
} catch {
|
|
4795
4796
|
}
|
|
4796
4797
|
}
|
|
4797
|
-
function
|
|
4798
|
+
function R(T) {
|
|
4798
4799
|
return h.push(T), o && T(o), () => {
|
|
4799
4800
|
const v = h.indexOf(T);
|
|
4800
4801
|
v !== -1 && h.splice(v, 1);
|
|
@@ -4809,14 +4810,14 @@ function oo({
|
|
|
4809
4810
|
m = !0;
|
|
4810
4811
|
}
|
|
4811
4812
|
function Ge(T) {
|
|
4812
|
-
let v = g,
|
|
4813
|
+
let v = g, x = 0, F = 0;
|
|
4813
4814
|
for (const { byteLen: G } of b) {
|
|
4814
4815
|
const ne = v + G;
|
|
4815
4816
|
if (ne > T)
|
|
4816
4817
|
break;
|
|
4817
|
-
v = ne,
|
|
4818
|
+
v = ne, x++, F += G;
|
|
4818
4819
|
}
|
|
4819
|
-
|
|
4820
|
+
x > 0 && (g += F, y -= F, b.splice(0, x));
|
|
4820
4821
|
}
|
|
4821
4822
|
function B(T, v) {
|
|
4822
4823
|
a = v, C(), T.error(v), O();
|
|
@@ -4829,10 +4830,10 @@ function oo({
|
|
|
4829
4830
|
});
|
|
4830
4831
|
switch (T.type) {
|
|
4831
4832
|
case "ok": {
|
|
4832
|
-
const { streamId: v, offset:
|
|
4833
|
-
o = v, Ge(
|
|
4833
|
+
const { streamId: v, offset: x } = T;
|
|
4834
|
+
o = v, Ge(x), b.length && r({
|
|
4834
4835
|
streamId: v,
|
|
4835
|
-
chunks: b.map((
|
|
4836
|
+
chunks: b.map((F) => F.chunk),
|
|
4836
4837
|
offset: g
|
|
4837
4838
|
}), m = !1;
|
|
4838
4839
|
break;
|
|
@@ -4854,13 +4855,13 @@ function oo({
|
|
|
4854
4855
|
Ge(T), v && (l = !0, O());
|
|
4855
4856
|
}
|
|
4856
4857
|
function ce(T) {
|
|
4857
|
-
return l ? (B(T, new
|
|
4858
|
+
return l ? (B(T, new $("Stream has been closed.")), null) : o || (B(T, new $("Stream has not been initialized.")), null);
|
|
4858
4859
|
}
|
|
4859
4860
|
async function He(T) {
|
|
4860
4861
|
c = T;
|
|
4861
|
-
let v = !0,
|
|
4862
|
+
let v = !0, x = 0;
|
|
4862
4863
|
for (; v; ) {
|
|
4863
|
-
let
|
|
4864
|
+
let F = Date.now() + Math.min(15e3, 500 * (x - 1));
|
|
4864
4865
|
v = !1;
|
|
4865
4866
|
const G = await t({
|
|
4866
4867
|
clientId: e.clientId,
|
|
@@ -4871,7 +4872,7 @@ function oo({
|
|
|
4871
4872
|
case "ok": {
|
|
4872
4873
|
const { streamId: ne, offset: Je } = G;
|
|
4873
4874
|
if (Je !== 0) {
|
|
4874
|
-
const ue = new
|
|
4875
|
+
const ue = new $("Write stream is corrupted");
|
|
4875
4876
|
B(T, ue);
|
|
4876
4877
|
return;
|
|
4877
4878
|
}
|
|
@@ -4884,8 +4885,8 @@ function oo({
|
|
|
4884
4885
|
return;
|
|
4885
4886
|
}
|
|
4886
4887
|
case "disconnect": {
|
|
4887
|
-
v = !0, oe(),
|
|
4888
|
-
setTimeout(ne, Math.max(0,
|
|
4888
|
+
v = !0, oe(), x++, await new Promise((ne) => {
|
|
4889
|
+
setTimeout(ne, Math.max(0, F - Date.now()));
|
|
4889
4890
|
});
|
|
4890
4891
|
break;
|
|
4891
4892
|
}
|
|
@@ -4897,20 +4898,20 @@ function oo({
|
|
|
4897
4898
|
}
|
|
4898
4899
|
}
|
|
4899
4900
|
class rr extends n {
|
|
4900
|
-
constructor(v,
|
|
4901
|
-
super(v,
|
|
4901
|
+
constructor(v, x) {
|
|
4902
|
+
super(v, x);
|
|
4902
4903
|
}
|
|
4903
4904
|
async streamId() {
|
|
4904
|
-
return o || new Promise((v,
|
|
4905
|
-
const
|
|
4906
|
-
for (const ue of
|
|
4905
|
+
return o || new Promise((v, x) => {
|
|
4906
|
+
const F = [], G = () => {
|
|
4907
|
+
for (const ue of F)
|
|
4907
4908
|
ue();
|
|
4908
4909
|
}, ne = (ue) => {
|
|
4909
4910
|
v(ue), G();
|
|
4910
4911
|
}, Je = (ue) => {
|
|
4911
|
-
|
|
4912
|
+
x(ue || new $("Stream is closed.")), G();
|
|
4912
4913
|
};
|
|
4913
|
-
|
|
4914
|
+
F.push(R(ne)), F.push(_(Je));
|
|
4914
4915
|
});
|
|
4915
4916
|
}
|
|
4916
4917
|
}
|
|
@@ -4926,12 +4927,12 @@ function oo({
|
|
|
4926
4927
|
}
|
|
4927
4928
|
},
|
|
4928
4929
|
write(T, v) {
|
|
4929
|
-
const
|
|
4930
|
-
if (
|
|
4931
|
-
const
|
|
4932
|
-
b.push({ chunk: T, byteLen:
|
|
4930
|
+
const x = ce(v);
|
|
4931
|
+
if (x) {
|
|
4932
|
+
const F = w.encode(T).length;
|
|
4933
|
+
b.push({ chunk: T, byteLen: F });
|
|
4933
4934
|
const G = g + y;
|
|
4934
|
-
y +=
|
|
4935
|
+
y += F, m || r({ streamId: x, chunks: [T], offset: G });
|
|
4935
4936
|
}
|
|
4936
4937
|
},
|
|
4937
4938
|
close() {
|
|
@@ -5008,41 +5009,41 @@ function co({
|
|
|
5008
5009
|
}
|
|
5009
5010
|
function d(b) {
|
|
5010
5011
|
return l.push(b), () => {
|
|
5011
|
-
const
|
|
5012
|
-
|
|
5012
|
+
const w = l.indexOf(b);
|
|
5013
|
+
w !== -1 && l.splice(w, 1);
|
|
5013
5014
|
};
|
|
5014
5015
|
}
|
|
5015
|
-
function h(b,
|
|
5016
|
-
b.error(
|
|
5016
|
+
function h(b, w) {
|
|
5017
|
+
b.error(w), f();
|
|
5017
5018
|
}
|
|
5018
5019
|
let p = 0;
|
|
5019
|
-
async function m(b,
|
|
5020
|
+
async function m(b, w) {
|
|
5020
5021
|
c = I();
|
|
5021
5022
|
const C = { ...b || {}, eventId: c };
|
|
5022
|
-
for await (const
|
|
5023
|
+
for await (const _ of t(C)) {
|
|
5023
5024
|
if (i)
|
|
5024
5025
|
return;
|
|
5025
|
-
if (
|
|
5026
|
+
if (_.type === "reconnect")
|
|
5026
5027
|
return { retry: !0 };
|
|
5027
|
-
if (
|
|
5028
|
-
h(
|
|
5028
|
+
if (_.type === "error") {
|
|
5029
|
+
h(w, _.error);
|
|
5029
5030
|
return;
|
|
5030
5031
|
}
|
|
5031
|
-
if (
|
|
5032
|
-
h(
|
|
5032
|
+
if (_.offset > s) {
|
|
5033
|
+
h(w, new $("Stream is corrupted.")), i = !0;
|
|
5033
5034
|
return;
|
|
5034
5035
|
}
|
|
5035
|
-
let k = s -
|
|
5036
|
-
if (
|
|
5036
|
+
let k = s - _.offset;
|
|
5037
|
+
if (_.files && _.files.length) {
|
|
5037
5038
|
const O = new AbortController();
|
|
5038
|
-
let
|
|
5039
|
+
let R = fetch(_.files[0].url, {
|
|
5039
5040
|
signal: O.signal
|
|
5040
5041
|
});
|
|
5041
|
-
for (let V = 0; V <
|
|
5042
|
-
const oe =
|
|
5043
|
-
if (oe && (
|
|
5042
|
+
for (let V = 0; V < _.files.length; V++) {
|
|
5043
|
+
const oe = _.files[V + 1], B = await R;
|
|
5044
|
+
if (oe && (R = fetch(oe.url, { signal: O.signal })), !B.ok) {
|
|
5044
5045
|
if (p++, p > 10) {
|
|
5045
|
-
h(
|
|
5046
|
+
h(w, new $("Unable to process stream."));
|
|
5046
5047
|
return;
|
|
5047
5048
|
}
|
|
5048
5049
|
return { retry: !0 };
|
|
@@ -5063,7 +5064,7 @@ function co({
|
|
|
5063
5064
|
continue;
|
|
5064
5065
|
s += ce.length;
|
|
5065
5066
|
const He = o.decode(ce);
|
|
5066
|
-
|
|
5067
|
+
w.enqueue(He);
|
|
5067
5068
|
}
|
|
5068
5069
|
} finally {
|
|
5069
5070
|
ee.releaseLock();
|
|
@@ -5079,32 +5080,32 @@ function co({
|
|
|
5079
5080
|
continue;
|
|
5080
5081
|
s += te.byteLength;
|
|
5081
5082
|
const ae = o.decode(te);
|
|
5082
|
-
|
|
5083
|
+
w.enqueue(ae);
|
|
5083
5084
|
}
|
|
5084
5085
|
}
|
|
5085
5086
|
}
|
|
5086
|
-
if (p = 0,
|
|
5087
|
-
let O =
|
|
5087
|
+
if (p = 0, _.content) {
|
|
5088
|
+
let O = _.content, R = a.encode(_.content);
|
|
5088
5089
|
if (k > 0) {
|
|
5089
|
-
const V =
|
|
5090
|
-
if (k -=
|
|
5090
|
+
const V = R.subarray(k);
|
|
5091
|
+
if (k -= R.length - V.length, !V.length)
|
|
5091
5092
|
continue;
|
|
5092
|
-
|
|
5093
|
+
R = V, O = o.decode(V);
|
|
5093
5094
|
}
|
|
5094
|
-
s +=
|
|
5095
|
+
s += R.length, w.enqueue(O);
|
|
5095
5096
|
}
|
|
5096
5097
|
}
|
|
5097
5098
|
}
|
|
5098
5099
|
async function g(b) {
|
|
5099
|
-
let
|
|
5100
|
-
for (;
|
|
5101
|
-
|
|
5102
|
-
let
|
|
5100
|
+
let w = !0, C = 0;
|
|
5101
|
+
for (; w; ) {
|
|
5102
|
+
w = !1;
|
|
5103
|
+
let _ = Date.now() + Math.min(15e3, 500 * (C - 1));
|
|
5103
5104
|
(await m(
|
|
5104
5105
|
{ ...e, offset: s },
|
|
5105
5106
|
b
|
|
5106
|
-
))?.retry && (
|
|
5107
|
-
setTimeout(O, Math.max(0,
|
|
5107
|
+
))?.retry && (w = !0, C++, _ < Date.now() - 3e5 && (C = 0), await new Promise((O) => {
|
|
5108
|
+
setTimeout(O, Math.max(0, _ - Date.now()));
|
|
5108
5109
|
}));
|
|
5109
5110
|
}
|
|
5110
5111
|
!i && !u && (b.close(), f());
|
|
@@ -5249,7 +5250,7 @@ class uo {
|
|
|
5249
5250
|
if (e.error) {
|
|
5250
5251
|
e.retry ? r.push({ type: "reconnect" }) : r.push({
|
|
5251
5252
|
type: "error",
|
|
5252
|
-
error: new
|
|
5253
|
+
error: new $(e.error)
|
|
5253
5254
|
}), r.close(), delete this.readStreamIterators[t];
|
|
5254
5255
|
return;
|
|
5255
5256
|
}
|
|
@@ -5288,7 +5289,7 @@ class uo {
|
|
|
5288
5289
|
const r = e["client-event-id"], s = this.startWriteStreamCbs[r];
|
|
5289
5290
|
s && (s({
|
|
5290
5291
|
type: "error",
|
|
5291
|
-
error: new
|
|
5292
|
+
error: new $(e.message || "Unknown error", e.hint)
|
|
5292
5293
|
}), delete this.startWriteStreamCbs[r]);
|
|
5293
5294
|
break;
|
|
5294
5295
|
}
|
|
@@ -5296,7 +5297,7 @@ class uo {
|
|
|
5296
5297
|
const r = e["client-event-id"], s = this.readStreamIterators[r];
|
|
5297
5298
|
s && (s.push({
|
|
5298
5299
|
type: "error",
|
|
5299
|
-
error: new
|
|
5300
|
+
error: new $(e.message || "Unknown error", e.hint)
|
|
5300
5301
|
}), s.close(), delete this.readStreamIterators[r]);
|
|
5301
5302
|
break;
|
|
5302
5303
|
}
|
|
@@ -5363,7 +5364,7 @@ function mo(n, e) {
|
|
|
5363
5364
|
}
|
|
5364
5365
|
return t;
|
|
5365
5366
|
}
|
|
5366
|
-
function
|
|
5367
|
+
function wo(n, e) {
|
|
5367
5368
|
const { result: t, ...r } = e, s = (
|
|
5368
5369
|
/** @type {import('./reactorTypes.ts').QuerySubInStorage} */
|
|
5369
5370
|
r
|
|
@@ -5378,7 +5379,7 @@ function _o(n, e) {
|
|
|
5378
5379
|
}
|
|
5379
5380
|
return s;
|
|
5380
5381
|
}
|
|
5381
|
-
function
|
|
5382
|
+
function _o(n, e) {
|
|
5382
5383
|
return n === "pendingMutations" ? new Map(typeof e == "string" ? JSON.parse(e) : e) : e;
|
|
5383
5384
|
}
|
|
5384
5385
|
function To(n, e) {
|
|
@@ -5452,6 +5453,8 @@ class vo {
|
|
|
5452
5453
|
_pendingTxCleanupTimeout;
|
|
5453
5454
|
_pendingMutationCleanupThreshold;
|
|
5454
5455
|
_inFlightMutationEventIds = /* @__PURE__ */ new Set();
|
|
5456
|
+
/** @type FrameworkClient | null */
|
|
5457
|
+
_frameworkClient = null;
|
|
5455
5458
|
constructor(e, t = Wn, r = Vn, s, i) {
|
|
5456
5459
|
if (this._EventSource = i, this.config = { ...yo, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? fo, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? ho, this._log = Ni(
|
|
5457
5460
|
e.verbose || Dt || Qn,
|
|
@@ -5512,6 +5515,13 @@ class vo {
|
|
|
5512
5515
|
}), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
|
|
5513
5516
|
}
|
|
5514
5517
|
}
|
|
5518
|
+
getFrameworkClient() {
|
|
5519
|
+
return this._frameworkClient;
|
|
5520
|
+
}
|
|
5521
|
+
/** @param {FrameworkClient} client */
|
|
5522
|
+
setFrameworkClient(e) {
|
|
5523
|
+
this._frameworkClient = e;
|
|
5524
|
+
}
|
|
5515
5525
|
ensureAttrs() {
|
|
5516
5526
|
if (!this.attrs)
|
|
5517
5527
|
throw new Error("attrs have not loaded.");
|
|
@@ -5538,7 +5548,7 @@ class vo {
|
|
|
5538
5548
|
this.querySubs = new gt({
|
|
5539
5549
|
persister: new e(this.config.appId, "querySubs"),
|
|
5540
5550
|
merge: So,
|
|
5541
|
-
serialize:
|
|
5551
|
+
serialize: wo,
|
|
5542
5552
|
parse: (t, r) => mo(r, this.config.useDateObjects),
|
|
5543
5553
|
// objectSize
|
|
5544
5554
|
objectSize: (t) => t?.result?.store?.triples?.length ?? 0,
|
|
@@ -5556,7 +5566,7 @@ class vo {
|
|
|
5556
5566
|
persister: new e(this.config.appId, "kv"),
|
|
5557
5567
|
merge: this._onMergeKv,
|
|
5558
5568
|
serialize: To,
|
|
5559
|
-
parse:
|
|
5569
|
+
parse: _o,
|
|
5560
5570
|
objectSize: () => 0,
|
|
5561
5571
|
logger: this._log,
|
|
5562
5572
|
saveThrottleMs: 100,
|
|
@@ -5589,7 +5599,7 @@ class vo {
|
|
|
5589
5599
|
else if (r?.type) {
|
|
5590
5600
|
const { status: o, ...a } = r;
|
|
5591
5601
|
s.reject(
|
|
5592
|
-
new
|
|
5602
|
+
new Me({
|
|
5593
5603
|
// @ts-expect-error body.type is not constant typed
|
|
5594
5604
|
body: a,
|
|
5595
5605
|
status: o ?? 0
|
|
@@ -5597,7 +5607,7 @@ class vo {
|
|
|
5597
5607
|
);
|
|
5598
5608
|
} else
|
|
5599
5609
|
s.reject(
|
|
5600
|
-
new
|
|
5610
|
+
new $(
|
|
5601
5611
|
r?.message || "Unknown error",
|
|
5602
5612
|
r?.hint
|
|
5603
5613
|
)
|
|
@@ -5741,18 +5751,18 @@ class vo {
|
|
|
5741
5751
|
g,
|
|
5742
5752
|
r,
|
|
5743
5753
|
this.config.useDateObjects
|
|
5744
|
-
), { store:
|
|
5754
|
+
), { store: w, attrsStore: C } = this._applyOptimisticUpdates(
|
|
5745
5755
|
b,
|
|
5746
5756
|
y,
|
|
5747
5757
|
l,
|
|
5748
5758
|
c
|
|
5749
|
-
),
|
|
5759
|
+
), _ = p?.[0]?.data?.["page-info"], k = p?.[0]?.data?.aggregate;
|
|
5750
5760
|
return {
|
|
5751
5761
|
q: h,
|
|
5752
5762
|
hash: m,
|
|
5753
|
-
store:
|
|
5763
|
+
store: w,
|
|
5754
5764
|
attrsStore: C,
|
|
5755
|
-
pageInfo:
|
|
5765
|
+
pageInfo: _,
|
|
5756
5766
|
aggregate: k
|
|
5757
5767
|
};
|
|
5758
5768
|
});
|
|
@@ -6040,9 +6050,9 @@ class vo {
|
|
|
6040
6050
|
continue;
|
|
6041
6051
|
}
|
|
6042
6052
|
if (y["value-type"] === "ref") {
|
|
6043
|
-
const
|
|
6044
|
-
if (
|
|
6045
|
-
o.attrIdMap[y.id] =
|
|
6053
|
+
const w = i(y);
|
|
6054
|
+
if (w) {
|
|
6055
|
+
o.attrIdMap[y.id] = w.id, o.refSwapAttrIds.add(y.id), a = !0;
|
|
6046
6056
|
continue;
|
|
6047
6057
|
}
|
|
6048
6058
|
}
|
|
@@ -6132,7 +6142,7 @@ class vo {
|
|
|
6132
6142
|
/** Re-run instaql and call all callbacks with new data */
|
|
6133
6143
|
notifyOne = (e) => {
|
|
6134
6144
|
const t = this.queryCbs[e] ?? [], r = this._dataForQueryCache[e]?.data, s = this.dataForQuery(e);
|
|
6135
|
-
s?.data && (this._dataForQueryCache[e] = s, !
|
|
6145
|
+
s?.data && (this._dataForQueryCache[e] = s, !Ue(s.data, r) && t.forEach((i) => i.cb(s.data)));
|
|
6136
6146
|
};
|
|
6137
6147
|
notifyOneQueryOnce = (e) => {
|
|
6138
6148
|
const t = this.queryOnceDfds[e] ?? [], r = this.dataForQuery(e)?.data;
|
|
@@ -6156,7 +6166,7 @@ class vo {
|
|
|
6156
6166
|
pushTx = (e) => {
|
|
6157
6167
|
this.config.disableValidation || Ji(e, this.config.schema);
|
|
6158
6168
|
try {
|
|
6159
|
-
const t =
|
|
6169
|
+
const t = _i(
|
|
6160
6170
|
{
|
|
6161
6171
|
attrsStore: this.optimisticAttrs(),
|
|
6162
6172
|
schema: this.config.schema,
|
|
@@ -6506,7 +6516,7 @@ class vo {
|
|
|
6506
6516
|
t.isLoading || e(this._currentUserCached);
|
|
6507
6517
|
let r = !1;
|
|
6508
6518
|
return this.getCurrentUser().then((s) => {
|
|
6509
|
-
r ||
|
|
6519
|
+
r || Ue(s, t) || e(s);
|
|
6510
6520
|
}), () => {
|
|
6511
6521
|
r = !0, this.authCbs = this.authCbs.filter((s) => s !== e);
|
|
6512
6522
|
};
|
|
@@ -6514,7 +6524,7 @@ class vo {
|
|
|
6514
6524
|
async getAuth() {
|
|
6515
6525
|
const { user: e, error: t } = await this.getCurrentUser();
|
|
6516
6526
|
if (t)
|
|
6517
|
-
throw new
|
|
6527
|
+
throw new $("Could not get current user: " + t.message);
|
|
6518
6528
|
return e ?? null;
|
|
6519
6529
|
}
|
|
6520
6530
|
subscribeConnectionStatus(e) {
|
|
@@ -6590,8 +6600,8 @@ class vo {
|
|
|
6590
6600
|
}
|
|
6591
6601
|
async changeCurrentUser(e) {
|
|
6592
6602
|
const { user: t } = await this.getCurrentUser();
|
|
6593
|
-
if (!
|
|
6594
|
-
await this.setCurrentUser(e), await this.updateUser(e);
|
|
6603
|
+
if (!Ue(t, e)) {
|
|
6604
|
+
this._frameworkClient = null, await this.setCurrentUser(e), await this.updateUser(e);
|
|
6595
6605
|
try {
|
|
6596
6606
|
await this.kv.flush(), this._broadcastChannel?.postMessage({ type: "auth" });
|
|
6597
6607
|
} catch (r) {
|
|
@@ -6831,7 +6841,7 @@ class vo {
|
|
|
6831
6841
|
Object.entries(r).map(([o, a]) => [o, { data: a }])
|
|
6832
6842
|
);
|
|
6833
6843
|
this._presence[e]?.result;
|
|
6834
|
-
const i =
|
|
6844
|
+
const i = qe(s, (o) => {
|
|
6835
6845
|
for (let [a, c, u] of t)
|
|
6836
6846
|
switch (c) {
|
|
6837
6847
|
case "+":
|
|
@@ -6854,7 +6864,7 @@ class vo {
|
|
|
6854
6864
|
const s = Object.fromEntries(
|
|
6855
6865
|
Object.entries(r).map(([i, o]) => [i, o.data])
|
|
6856
6866
|
);
|
|
6857
|
-
this._presence =
|
|
6867
|
+
this._presence = qe(this._presence, (i) => {
|
|
6858
6868
|
Ft(i, [e, "result", "peers"], s);
|
|
6859
6869
|
});
|
|
6860
6870
|
}
|
|
@@ -6950,22 +6960,22 @@ function ko(n) {
|
|
|
6950
6960
|
return new Qe(n, {});
|
|
6951
6961
|
}
|
|
6952
6962
|
function Oo() {
|
|
6953
|
-
return new
|
|
6963
|
+
return new L("string", !0, !1);
|
|
6954
6964
|
}
|
|
6955
6965
|
function Io() {
|
|
6956
|
-
return new
|
|
6966
|
+
return new L("number", !0, !1);
|
|
6957
6967
|
}
|
|
6958
6968
|
function Co() {
|
|
6959
|
-
return new
|
|
6969
|
+
return new L("boolean", !0, !1);
|
|
6960
6970
|
}
|
|
6961
6971
|
function Eo() {
|
|
6962
|
-
return new
|
|
6972
|
+
return new L("date", !0, !1);
|
|
6963
6973
|
}
|
|
6964
6974
|
function Mo() {
|
|
6965
|
-
return new
|
|
6975
|
+
return new L("json", !0, !1);
|
|
6966
6976
|
}
|
|
6967
6977
|
function Po() {
|
|
6968
|
-
return new
|
|
6978
|
+
return new L("json", !0, !1);
|
|
6969
6979
|
}
|
|
6970
6980
|
function nr(n, e) {
|
|
6971
6981
|
const t = { fwd: {}, rev: {} };
|
|
@@ -7134,7 +7144,7 @@ function No(n, e) {
|
|
|
7134
7144
|
}
|
|
7135
7145
|
});
|
|
7136
7146
|
}
|
|
7137
|
-
function
|
|
7147
|
+
function $e(n, e) {
|
|
7138
7148
|
return new Response(JSON.stringify({ ok: !1, error: e }), {
|
|
7139
7149
|
status: n,
|
|
7140
7150
|
headers: { "Content-Type": "application/json" }
|
|
@@ -7146,9 +7156,9 @@ const na = (n) => ({
|
|
|
7146
7156
|
try {
|
|
7147
7157
|
t = await e.json();
|
|
7148
7158
|
} catch {
|
|
7149
|
-
return
|
|
7159
|
+
return $e(400, "Invalid JSON body");
|
|
7150
7160
|
}
|
|
7151
|
-
return t.type ? t.appId !== n.appId ?
|
|
7161
|
+
return t.type ? t.appId !== n.appId ? $e(403, "App ID mismatch") : t.type === "sync-user" ? No(n, t.user ?? null) : $e(400, `Unknown type: ${t.type}`) : $e(400, 'Missing "type" field');
|
|
7152
7162
|
}
|
|
7153
7163
|
}), ra = (n) => {
|
|
7154
7164
|
const e = {};
|
|
@@ -7278,6 +7288,29 @@ class sa {
|
|
|
7278
7288
|
!!this.db._reactor.config.schema
|
|
7279
7289
|
));
|
|
7280
7290
|
};
|
|
7291
|
+
removeCachedQueryResult = (e) => {
|
|
7292
|
+
this.resultMap.delete(e);
|
|
7293
|
+
};
|
|
7294
|
+
// Run a query on the client and return a promise with the result
|
|
7295
|
+
queryClient = (e, t) => {
|
|
7296
|
+
const { hash: r, query: s } = this.hashQuery(e, t);
|
|
7297
|
+
let i, o;
|
|
7298
|
+
const a = new Promise(
|
|
7299
|
+
(l, f) => {
|
|
7300
|
+
i = l, o = f;
|
|
7301
|
+
}
|
|
7302
|
+
);
|
|
7303
|
+
let c = {
|
|
7304
|
+
status: "pending",
|
|
7305
|
+
type: "session",
|
|
7306
|
+
data: void 0,
|
|
7307
|
+
error: void 0,
|
|
7308
|
+
promise: a
|
|
7309
|
+
}, u = null;
|
|
7310
|
+
return u = this.db.subscribeQuery(s, (l) => {
|
|
7311
|
+
l.error ? (c.status = "error", c.error = l.error, c.promise = null, o(l.error)) : (c.status = "success", c.data = l, c.promise = null, i(l)), u !== null && u();
|
|
7312
|
+
}), this.resultMap.set(r, c), a;
|
|
7313
|
+
};
|
|
7281
7314
|
// creates an entry in the results map
|
|
7282
7315
|
// and returns the same thing added to the map
|
|
7283
7316
|
query = (e, t) => {
|
|
@@ -7374,7 +7407,12 @@ class sa {
|
|
|
7374
7407
|
}
|
|
7375
7408
|
);
|
|
7376
7409
|
if (!t.ok)
|
|
7377
|
-
|
|
7410
|
+
try {
|
|
7411
|
+
const a = await t.json();
|
|
7412
|
+
throw "message" in a ? new Me({ body: a, status: t.status }) : new Error("Error getting triples from server");
|
|
7413
|
+
} catch (a) {
|
|
7414
|
+
throw a instanceof $ ? a : new Error("Error getting triples from server");
|
|
7415
|
+
}
|
|
7378
7416
|
const r = await t.json(), s = r?.attrs;
|
|
7379
7417
|
if (!s)
|
|
7380
7418
|
throw new Error("No attrs");
|
|
@@ -7388,6 +7426,8 @@ class sa {
|
|
|
7388
7426
|
pageInfo: o
|
|
7389
7427
|
};
|
|
7390
7428
|
} catch (t) {
|
|
7429
|
+
if (t instanceof $)
|
|
7430
|
+
throw t;
|
|
7391
7431
|
const r = new Error(
|
|
7392
7432
|
"Error getting triples from framework client"
|
|
7393
7433
|
);
|
|
@@ -7405,11 +7445,11 @@ function zo() {
|
|
|
7405
7445
|
function Wo() {
|
|
7406
7446
|
return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
|
|
7407
7447
|
}
|
|
7408
|
-
function
|
|
7448
|
+
function wt(n) {
|
|
7409
7449
|
const e = n.__adminToken;
|
|
7410
7450
|
return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects;
|
|
7411
7451
|
}
|
|
7412
|
-
const
|
|
7452
|
+
const _t = Wo(), fn = zo();
|
|
7413
7453
|
class Vo {
|
|
7414
7454
|
constructor(e) {
|
|
7415
7455
|
this.db = e;
|
|
@@ -7763,7 +7803,7 @@ class Ho {
|
|
|
7763
7803
|
};
|
|
7764
7804
|
}
|
|
7765
7805
|
shutdown() {
|
|
7766
|
-
delete wt
|
|
7806
|
+
delete _t[wt(this._reactor.config)], this._reactor.shutdown();
|
|
7767
7807
|
}
|
|
7768
7808
|
/**
|
|
7769
7809
|
* Use this for one-off queries.
|
|
@@ -7813,7 +7853,7 @@ function Yo(n, e, t, r, s) {
|
|
|
7813
7853
|
...n,
|
|
7814
7854
|
appId: n.appId?.trim(),
|
|
7815
7855
|
useDateObjects: n.useDateObjects ?? !1
|
|
7816
|
-
}, o = wt
|
|
7856
|
+
}, o = _t[wt(i)];
|
|
7817
7857
|
if (o)
|
|
7818
7858
|
return Jo(o, i.schema) && o._reactor.updateSchema(i.schema), o;
|
|
7819
7859
|
const a = new vo(
|
|
@@ -7827,7 +7867,7 @@ function Yo(n, e, t, r, s) {
|
|
|
7827
7867
|
{ ...r || {}, "@instantdb/core": Hn },
|
|
7828
7868
|
s
|
|
7829
7869
|
), c = new Ho(a);
|
|
7830
|
-
return wt
|
|
7870
|
+
return _t[wt(i)] = c, Zo(i.appId, i.devtool), c;
|
|
7831
7871
|
}
|
|
7832
7872
|
function Zo(n, e) {
|
|
7833
7873
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
@@ -7844,9 +7884,9 @@ export {
|
|
|
7844
7884
|
Vo as Auth,
|
|
7845
7885
|
sa as FrameworkClient,
|
|
7846
7886
|
Wn as IndexedDBStorage,
|
|
7847
|
-
|
|
7887
|
+
Me as InstantAPIError,
|
|
7848
7888
|
Ho as InstantCoreDatabase,
|
|
7849
|
-
|
|
7889
|
+
$ as InstantError,
|
|
7850
7890
|
uo as InstantStream,
|
|
7851
7891
|
A as QueryValidationError,
|
|
7852
7892
|
vo as Reactor,
|
|
@@ -7859,7 +7899,7 @@ export {
|
|
|
7859
7899
|
Q as TransactionValidationError,
|
|
7860
7900
|
Vn as WindowNetworkListener,
|
|
7861
7901
|
Go as coerceQuery,
|
|
7862
|
-
|
|
7902
|
+
We as coerceToDate,
|
|
7863
7903
|
na as createInstantRouteHandler,
|
|
7864
7904
|
Gs as getOps,
|
|
7865
7905
|
E as i,
|