@instantdb/core 0.22.90-experimental.drewh-ssr.20320632959.1 → 0.22.90-experimental.drewh-ssr.20347747146.1
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/dist/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +4 -2
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/createRouteHandler.d.ts +0 -2
- package/dist/commonjs/createRouteHandler.d.ts.map +1 -1
- package/dist/commonjs/createRouteHandler.js +43 -34
- package/dist/commonjs/createRouteHandler.js.map +1 -1
- package/dist/commonjs/index.d.ts +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +4 -2
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/createRouteHandler.d.ts +0 -2
- package/dist/esm/createRouteHandler.d.ts.map +1 -1
- package/dist/esm/createRouteHandler.js +43 -34
- package/dist/esm/createRouteHandler.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/standalone/index.js +172 -159
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +2 -2
- package/src/Reactor.js +4 -2
- package/src/createRouteHandler.ts +38 -26
- package/src/index.ts +1 -1
package/dist/standalone/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Gn = Object.defineProperty;
|
|
2
2
|
var Bn = (n, e, t) => e in n ? Gn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
3
|
var T = (n, e, t) => Bn(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
function
|
|
4
|
+
function M(n) {
|
|
5
5
|
if (typeof n == "number")
|
|
6
6
|
return (Math.abs(n * 2654435761) >>> 0).toString(16);
|
|
7
7
|
if (typeof n == "boolean") return n ? "1" : "0";
|
|
@@ -17,7 +17,7 @@ function C(n) {
|
|
|
17
17
|
let e = 2166136261;
|
|
18
18
|
for (let t = 0; t < n.length; t++) {
|
|
19
19
|
e ^= (t + 1) * 2654435761;
|
|
20
|
-
const r =
|
|
20
|
+
const r = M(n[t]);
|
|
21
21
|
for (let s = 0; s < r.length; s++)
|
|
22
22
|
e ^= r.charCodeAt(s), e *= 16777619, e = e >>> 0;
|
|
23
23
|
}
|
|
@@ -27,20 +27,20 @@ function C(n) {
|
|
|
27
27
|
let e = 2166136261;
|
|
28
28
|
const t = Object.keys(n).sort();
|
|
29
29
|
for (let r = 0; r < t.length; r++) {
|
|
30
|
-
const s = t[r], i =
|
|
30
|
+
const s = t[r], i = M(s);
|
|
31
31
|
e ^= parseInt(i, 16), e *= 16777619, e = e >>> 0;
|
|
32
|
-
const o =
|
|
32
|
+
const o = M(n[s]);
|
|
33
33
|
e ^= parseInt(o, 16), e *= 16777619, e = e >>> 0;
|
|
34
34
|
}
|
|
35
35
|
return e.toString(16);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return M(String(n));
|
|
38
38
|
}
|
|
39
39
|
const I = {
|
|
40
40
|
Remove: "remove",
|
|
41
41
|
Replace: "replace",
|
|
42
42
|
Add: "add"
|
|
43
|
-
}, tn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Hn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), me = Symbol.iterator,
|
|
43
|
+
}, tn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Hn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), me = Symbol.iterator, F = {
|
|
44
44
|
mutable: "mutable",
|
|
45
45
|
immutable: "immutable"
|
|
46
46
|
}, it = {};
|
|
@@ -64,7 +64,7 @@ function ot(n) {
|
|
|
64
64
|
function at(n) {
|
|
65
65
|
return Object.getPrototypeOf(n) === Map.prototype;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function N(n) {
|
|
68
68
|
var e;
|
|
69
69
|
return (e = n.copy) !== null && e !== void 0 ? e : n.original;
|
|
70
70
|
}
|
|
@@ -83,7 +83,7 @@ function z(n, e) {
|
|
|
83
83
|
if (!n || typeof n != "object")
|
|
84
84
|
return !1;
|
|
85
85
|
let t;
|
|
86
|
-
return Object.getPrototypeOf(n) === Object.prototype || Array.isArray(n) || n instanceof Map || n instanceof Set || !!(e != null && e.mark) && ((t = e.mark(n,
|
|
86
|
+
return Object.getPrototypeOf(n) === Object.prototype || Array.isArray(n) || n instanceof Map || n instanceof Set || !!(e != null && e.mark) && ((t = e.mark(n, F)) === F.immutable || typeof t == "function");
|
|
87
87
|
}
|
|
88
88
|
function nn(n, e = []) {
|
|
89
89
|
if (Object.hasOwnProperty.call(n, "key")) {
|
|
@@ -116,7 +116,7 @@ function ye(n, e, t) {
|
|
|
116
116
|
}
|
|
117
117
|
function Re(n, e) {
|
|
118
118
|
const t = A(n);
|
|
119
|
-
return (t ?
|
|
119
|
+
return (t ? N(t) : n)[e];
|
|
120
120
|
}
|
|
121
121
|
function G(n, e) {
|
|
122
122
|
return n === e ? n !== 0 || 1 / n === 1 / e : n !== n && e !== e;
|
|
@@ -173,8 +173,8 @@ function rn(n, e) {
|
|
|
173
173
|
return new r(n);
|
|
174
174
|
}
|
|
175
175
|
return new Map(n);
|
|
176
|
-
} else if (e != null && e.mark && (t = e.mark(n,
|
|
177
|
-
if (t ===
|
|
176
|
+
} else if (e != null && e.mark && (t = e.mark(n, F), t !== void 0) && t !== F.mutable) {
|
|
177
|
+
if (t === F.immutable)
|
|
178
178
|
return Yn(n);
|
|
179
179
|
if (typeof t == "function") {
|
|
180
180
|
if (e.enablePatches || e.enableAutoFreeze)
|
|
@@ -449,13 +449,13 @@ const Oe = (n, e, t = !1) => {
|
|
|
449
449
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
450
450
|
}, Ve = {
|
|
451
451
|
get size() {
|
|
452
|
-
return
|
|
452
|
+
return N(A(this)).size;
|
|
453
453
|
},
|
|
454
454
|
has(n) {
|
|
455
|
-
return
|
|
455
|
+
return N(A(this)).has(n);
|
|
456
456
|
},
|
|
457
457
|
set(n, e) {
|
|
458
|
-
const t = A(this), r =
|
|
458
|
+
const t = A(this), r = N(t);
|
|
459
459
|
return (!r.has(n) || !G(r.get(n), e)) && ($(t), Q(t), t.assignedMap.set(n, !0), t.copy.set(n, e), lt(t, n, e, he)), this;
|
|
460
460
|
},
|
|
461
461
|
delete(n) {
|
|
@@ -475,13 +475,13 @@ const Oe = (n, e, t = !1) => {
|
|
|
475
475
|
},
|
|
476
476
|
forEach(n, e) {
|
|
477
477
|
const t = A(this);
|
|
478
|
-
|
|
478
|
+
N(t).forEach((r, s) => {
|
|
479
479
|
n.call(e, this.get(s), s, this);
|
|
480
480
|
});
|
|
481
481
|
},
|
|
482
482
|
get(n) {
|
|
483
483
|
var e, t;
|
|
484
|
-
const r = A(this), s =
|
|
484
|
+
const r = A(this), s = N(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, F)) === F.mutable;
|
|
485
485
|
if (r.options.strict && Oe(s, r.options, i), i || r.finalized || !z(s, r.options) || s !== r.original.get(n))
|
|
486
486
|
return s;
|
|
487
487
|
const o = it.createDraft({
|
|
@@ -494,7 +494,7 @@ const Oe = (n, e, t = !1) => {
|
|
|
494
494
|
return $(r), r.copy.set(n, o), o;
|
|
495
495
|
},
|
|
496
496
|
keys() {
|
|
497
|
-
return
|
|
497
|
+
return N(A(this)).keys();
|
|
498
498
|
},
|
|
499
499
|
values() {
|
|
500
500
|
const n = this.keys();
|
|
@@ -535,7 +535,7 @@ const Oe = (n, e, t = !1) => {
|
|
|
535
535
|
return i;
|
|
536
536
|
const o = i.value;
|
|
537
537
|
let a = n.setMap.get(o);
|
|
538
|
-
const c = A(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a,
|
|
538
|
+
const c = A(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, F)) === F.mutable;
|
|
539
539
|
if (n.options.strict && Oe(o, n.options, u), !u && !c && z(o, n.options) && !n.finalized && n.original.has(o)) {
|
|
540
540
|
const l = it.createDraft({
|
|
541
541
|
original: o,
|
|
@@ -650,10 +650,10 @@ const sr = Reflect.ownKeys(ve), on = /* @__PURE__ */ new WeakSet(), an = {
|
|
|
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
|
-
if (o = n.options.mark(u,
|
|
653
|
+
if (o = n.options.mark(u, F), o === F.mutable)
|
|
654
654
|
return n.options.strict && Oe(u, n.options, !0), u;
|
|
655
655
|
}
|
|
656
|
-
const a =
|
|
656
|
+
const a = N(n);
|
|
657
657
|
if (a instanceof Map && rr.includes(e)) {
|
|
658
658
|
if (e === "size")
|
|
659
659
|
return Object.getOwnPropertyDescriptor(Ve, "size").get.call(n.proxy);
|
|
@@ -700,20 +700,20 @@ const sr = Reflect.ownKeys(ve), on = /* @__PURE__ */ new WeakSet(), an = {
|
|
|
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 = St(
|
|
703
|
+
const i = St(N(n), e);
|
|
704
704
|
if (i != null && i.set)
|
|
705
705
|
return i.set.call(n.proxy, t), !0;
|
|
706
|
-
const o = Re(
|
|
706
|
+
const o = Re(N(n), e), a = A(o);
|
|
707
707
|
return a && G(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) : (G(t, o) && (t !== void 0 || le(n.original, e)) || ($(n), Q(n), le(n.original, e) && G(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, lt(n, e, t, he)), !0);
|
|
708
708
|
},
|
|
709
709
|
has(n, e) {
|
|
710
|
-
return e in
|
|
710
|
+
return e in N(n);
|
|
711
711
|
},
|
|
712
712
|
ownKeys(n) {
|
|
713
|
-
return Reflect.ownKeys(
|
|
713
|
+
return Reflect.ownKeys(N(n));
|
|
714
714
|
},
|
|
715
715
|
getOwnPropertyDescriptor(n, e) {
|
|
716
|
-
const t =
|
|
716
|
+
const t = N(n), r = Reflect.getOwnPropertyDescriptor(t, e);
|
|
717
717
|
return r && {
|
|
718
718
|
writable: !0,
|
|
719
719
|
configurable: n.type !== 1 || e !== "length",
|
|
@@ -796,7 +796,7 @@ function or(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,
|
|
799
|
+
const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, F)) === F.mutable || !z(n, e) ? n : ft({
|
|
800
800
|
original: n,
|
|
801
801
|
parentDraft: null,
|
|
802
802
|
finalities: r,
|
|
@@ -1327,7 +1327,7 @@ function kr(n) {
|
|
|
1327
1327
|
return null;
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
|
-
function
|
|
1330
|
+
function Ce(n) {
|
|
1331
1331
|
if (n !== void 0) {
|
|
1332
1332
|
if (n === null)
|
|
1333
1333
|
return null;
|
|
@@ -1454,7 +1454,7 @@ function dn(n, e, t) {
|
|
|
1454
1454
|
console.warn("no such attr", c, a);
|
|
1455
1455
|
continue;
|
|
1456
1456
|
}
|
|
1457
|
-
l["checked-data-type"] === "date" && t && (u =
|
|
1457
|
+
l["checked-data-type"] === "date" && t && (u = Ce(u), o[2] = u), ht(l) && R(i, [u, c, a], o), R(r, [a, c, u], o), R(s, [c, a, u], o);
|
|
1458
1458
|
}
|
|
1459
1459
|
return { eav: r, aev: s, vae: i };
|
|
1460
1460
|
}
|
|
@@ -1525,12 +1525,12 @@ function bn(n, e, t) {
|
|
|
1525
1525
|
const [s, i, o] = r, a = e.getAttr(i);
|
|
1526
1526
|
a && (K(n.eav, [s, i, o]), K(n.aev, [i, s, o]), ht(a) && K(n.vae, [o, i, s]));
|
|
1527
1527
|
}
|
|
1528
|
-
let
|
|
1528
|
+
let Cr = 0;
|
|
1529
1529
|
function gn(n, e, t) {
|
|
1530
1530
|
const [r, s, i] = t;
|
|
1531
1531
|
let o;
|
|
1532
1532
|
const a = ie(n.eav, [r, s, i]);
|
|
1533
|
-
return a && (o = a[3]), o || Date.now() * 10 +
|
|
1533
|
+
return a && (o = a[3]), o || Date.now() * 10 + Cr++;
|
|
1534
1534
|
}
|
|
1535
1535
|
function _n(n, e, t) {
|
|
1536
1536
|
const r = be(n, t);
|
|
@@ -1540,11 +1540,11 @@ function _n(n, e, t) {
|
|
|
1540
1540
|
const a = e.getAttr(i);
|
|
1541
1541
|
if (!a)
|
|
1542
1542
|
return;
|
|
1543
|
-
a["checked-data-type"] === "date" && n.useDateObjects && (o =
|
|
1543
|
+
a["checked-data-type"] === "date" && n.useDateObjects && (o = Ce(o));
|
|
1544
1544
|
const c = ie(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? gn(n, a, r), l = [s, i, o, u];
|
|
1545
1545
|
Er(a) ? (R(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), R(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (R(n.eav, [s, i, o], l), R(n.aev, [i, s, o], l)), ht(a) && R(n.vae, [o, i, s], l);
|
|
1546
1546
|
}
|
|
1547
|
-
function
|
|
1547
|
+
function Mr(n, e, t) {
|
|
1548
1548
|
var h;
|
|
1549
1549
|
const r = be(n, t);
|
|
1550
1550
|
if (!r)
|
|
@@ -1625,7 +1625,7 @@ function Dr(n, e, t) {
|
|
|
1625
1625
|
_n(n, e, s);
|
|
1626
1626
|
break;
|
|
1627
1627
|
case "deep-merge-triple":
|
|
1628
|
-
|
|
1628
|
+
Mr(n, e, s);
|
|
1629
1629
|
break;
|
|
1630
1630
|
case "retract-triple":
|
|
1631
1631
|
bn(n, e, s);
|
|
@@ -1759,7 +1759,7 @@ function Ur(n, e, t) {
|
|
|
1759
1759
|
}
|
|
1760
1760
|
return r;
|
|
1761
1761
|
}
|
|
1762
|
-
function
|
|
1762
|
+
function C(n, e, t) {
|
|
1763
1763
|
var r;
|
|
1764
1764
|
return (r = n.forwardIdents.get(e)) == null ? void 0 : r.get(t);
|
|
1765
1765
|
}
|
|
@@ -1775,7 +1775,7 @@ function mn(n, e) {
|
|
|
1775
1775
|
const t = n.primaryKeys.get(e);
|
|
1776
1776
|
return t || ((r = n.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
|
|
1777
1777
|
}
|
|
1778
|
-
function
|
|
1778
|
+
function Nr(n, e, t) {
|
|
1779
1779
|
const r = be(n, t);
|
|
1780
1780
|
if (!r)
|
|
1781
1781
|
return;
|
|
@@ -1783,7 +1783,7 @@ function Fr(n, e, t) {
|
|
|
1783
1783
|
if (e.getAttr(i))
|
|
1784
1784
|
return ie(n.eav, [s, i]);
|
|
1785
1785
|
}
|
|
1786
|
-
function
|
|
1786
|
+
function Fr(n, e, t) {
|
|
1787
1787
|
const r = t.filter(
|
|
1788
1788
|
([s, i, o, a, c]) => {
|
|
1789
1789
|
if (s !== "add-triple" && s !== "deep-merge-triple")
|
|
@@ -1798,7 +1798,7 @@ function Nr(n, e, t) {
|
|
|
1798
1798
|
e,
|
|
1799
1799
|
f["forward-identity"][1]
|
|
1800
1800
|
);
|
|
1801
|
-
l = !!
|
|
1801
|
+
l = !!Nr(n, e, [
|
|
1802
1802
|
i,
|
|
1803
1803
|
d == null ? void 0 : d.id,
|
|
1804
1804
|
i
|
|
@@ -1832,15 +1832,15 @@ function Kr(n, e, t) {
|
|
|
1832
1832
|
}
|
|
1833
1833
|
return { ...t, [n]: e };
|
|
1834
1834
|
}
|
|
1835
|
-
function
|
|
1835
|
+
function Ct(n, e, t) {
|
|
1836
1836
|
return n === e ? t : null;
|
|
1837
1837
|
}
|
|
1838
1838
|
function zr(n) {
|
|
1839
1839
|
switch (typeof n) {
|
|
1840
1840
|
case "string":
|
|
1841
|
-
return n.startsWith("?") ? Kr :
|
|
1841
|
+
return n.startsWith("?") ? Kr : Ct;
|
|
1842
1842
|
default:
|
|
1843
|
-
return
|
|
1843
|
+
return Ct;
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
1846
1846
|
const Vr = [
|
|
@@ -1904,11 +1904,11 @@ function es() {
|
|
|
1904
1904
|
}
|
|
1905
1905
|
return xe(Xr);
|
|
1906
1906
|
}
|
|
1907
|
-
const ts = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
1907
|
+
const ts = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Mt = { randomUUID: ts };
|
|
1908
1908
|
function ns(n, e, t) {
|
|
1909
1909
|
var s;
|
|
1910
|
-
if (
|
|
1911
|
-
return
|
|
1910
|
+
if (Mt.randomUUID && !n)
|
|
1911
|
+
return Mt.randomUUID();
|
|
1912
1912
|
n = n || {};
|
|
1913
1913
|
const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? es();
|
|
1914
1914
|
if (r.length < 16)
|
|
@@ -1949,9 +1949,9 @@ function os() {
|
|
|
1949
1949
|
const as = os();
|
|
1950
1950
|
let cs = 0;
|
|
1951
1951
|
function fe(n) {
|
|
1952
|
-
return
|
|
1952
|
+
return Me(`_${n}`, cs++);
|
|
1953
1953
|
}
|
|
1954
|
-
function
|
|
1954
|
+
function Me(n, e) {
|
|
1955
1955
|
return `?${n}-${e}`;
|
|
1956
1956
|
}
|
|
1957
1957
|
class se extends Error {
|
|
@@ -1980,7 +1980,7 @@ function fs(n, e, t) {
|
|
|
1980
1980
|
return n.map((r) => r === e ? t : r);
|
|
1981
1981
|
}
|
|
1982
1982
|
function An(n, e, t, r, s) {
|
|
1983
|
-
const i =
|
|
1983
|
+
const i = C(e, t, s), o = X(e, t, s), a = i || o;
|
|
1984
1984
|
if (!a)
|
|
1985
1985
|
throw new se(`Could not find attr for ${[t, s]}`);
|
|
1986
1986
|
if (a["value-type"] !== "ref")
|
|
@@ -2072,7 +2072,7 @@ function ds(n, e) {
|
|
|
2072
2072
|
return e;
|
|
2073
2073
|
}
|
|
2074
2074
|
function hs(n, e, t, r, s, i) {
|
|
2075
|
-
const o =
|
|
2075
|
+
const o = C(e, t, s), a = X(
|
|
2076
2076
|
e,
|
|
2077
2077
|
t,
|
|
2078
2078
|
s
|
|
@@ -2082,7 +2082,7 @@ function hs(n, e, t, r, s, i) {
|
|
|
2082
2082
|
`No attr for etype = ${t} label = ${s}`
|
|
2083
2083
|
);
|
|
2084
2084
|
if (i != null && i.hasOwnProperty("$isNull")) {
|
|
2085
|
-
const u =
|
|
2085
|
+
const u = C(e, t, "id");
|
|
2086
2086
|
if (!u)
|
|
2087
2087
|
throw new se(
|
|
2088
2088
|
`No attr for etype = ${t} label = id`
|
|
@@ -2219,7 +2219,7 @@ function On(n, e, t, r, s) {
|
|
|
2219
2219
|
});
|
|
2220
2220
|
}
|
|
2221
2221
|
function Ts(n, e, t, r) {
|
|
2222
|
-
const s =
|
|
2222
|
+
const s = Me;
|
|
2223
2223
|
return r ? On(s, n, e, t, r).concat(jt(s, n, e, t)) : jt(s, n, e, t);
|
|
2224
2224
|
}
|
|
2225
2225
|
function ms(n, e, t) {
|
|
@@ -2292,7 +2292,7 @@ function ks(n, e) {
|
|
|
2292
2292
|
}
|
|
2293
2293
|
function Es(n, e, t) {
|
|
2294
2294
|
const r = Object.keys(t)[0];
|
|
2295
|
-
return
|
|
2295
|
+
return C(n, e, r);
|
|
2296
2296
|
}
|
|
2297
2297
|
function Is(n, e, t, r) {
|
|
2298
2298
|
if (t)
|
|
@@ -2300,22 +2300,22 @@ function Is(n, e, t, r) {
|
|
|
2300
2300
|
if (r)
|
|
2301
2301
|
return Es(n, e, r);
|
|
2302
2302
|
}
|
|
2303
|
-
function
|
|
2303
|
+
function Cs(n, e, t) {
|
|
2304
2304
|
var s, i;
|
|
2305
2305
|
if (!Array.isArray(t.fields))
|
|
2306
2306
|
return Lr(n, e);
|
|
2307
2307
|
const r = /* @__PURE__ */ new Map();
|
|
2308
2308
|
for (const o of t.fields) {
|
|
2309
|
-
const a =
|
|
2309
|
+
const a = C(n, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
|
|
2310
2310
|
c && pt(a) && r.set(c, a);
|
|
2311
2311
|
}
|
|
2312
2312
|
if (!r.has("id")) {
|
|
2313
|
-
const o =
|
|
2313
|
+
const o = C(n, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
|
|
2314
2314
|
a && r.set(a, o);
|
|
2315
2315
|
}
|
|
2316
2316
|
return r;
|
|
2317
2317
|
}
|
|
2318
|
-
function
|
|
2318
|
+
function Ms(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
|
|
2319
2319
|
var p, b;
|
|
2320
2320
|
const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = vn(i), c = Ps(i);
|
|
2321
2321
|
let u = Hr(n, s);
|
|
@@ -2336,7 +2336,7 @@ function Cs(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
|
|
|
2336
2336
|
}
|
|
2337
2337
|
);
|
|
2338
2338
|
let d = {};
|
|
2339
|
-
const h =
|
|
2339
|
+
const h = Cs(e, t, s);
|
|
2340
2340
|
for (const _ of u) {
|
|
2341
2341
|
const [g] = _;
|
|
2342
2342
|
if (d[g] || !a && l && f && vs(l, f, c, _))
|
|
@@ -2363,7 +2363,7 @@ function js(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
|
|
|
2363
2363
|
const a = ys(
|
|
2364
2364
|
Ts(e, t, r, (d = s.$) == null ? void 0 : d.where),
|
|
2365
2365
|
i
|
|
2366
|
-
), c = ms(
|
|
2366
|
+
), c = ms(Me, t, r), u = (h = s.$) == null ? void 0 : h.fields, l = Ms(n, e, {
|
|
2367
2367
|
etype: t,
|
|
2368
2368
|
pageInfo: o,
|
|
2369
2369
|
form: s,
|
|
@@ -2389,7 +2389,7 @@ function $s(n, e, t) {
|
|
|
2389
2389
|
}
|
|
2390
2390
|
function kn(n, e, t) {
|
|
2391
2391
|
const r = $s(n, e, t);
|
|
2392
|
-
return As(
|
|
2392
|
+
return As(Me, n, e, t, r);
|
|
2393
2393
|
}
|
|
2394
2394
|
function Ds(n) {
|
|
2395
2395
|
const e = {};
|
|
@@ -2488,7 +2488,7 @@ const Lo = In();
|
|
|
2488
2488
|
function Ls(n) {
|
|
2489
2489
|
return n.__ops;
|
|
2490
2490
|
}
|
|
2491
|
-
function
|
|
2491
|
+
function Ns(n, e) {
|
|
2492
2492
|
const { attrIdMap: t, refSwapAttrIds: r } = n, s = [];
|
|
2493
2493
|
for (const o of e) {
|
|
2494
2494
|
const a = t[o];
|
|
@@ -2507,7 +2507,7 @@ function Fs(n, e) {
|
|
|
2507
2507
|
}
|
|
2508
2508
|
return s;
|
|
2509
2509
|
}
|
|
2510
|
-
function
|
|
2510
|
+
function Fs(n) {
|
|
2511
2511
|
if (Array.isArray(n))
|
|
2512
2512
|
return n;
|
|
2513
2513
|
const e = Object.entries(n);
|
|
@@ -2520,7 +2520,7 @@ function Ns(n) {
|
|
|
2520
2520
|
function qs(n, e, t) {
|
|
2521
2521
|
return t.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2522
2522
|
// before assuming it's a ref lookup.
|
|
2523
|
-
!
|
|
2523
|
+
!C(n, e, t);
|
|
2524
2524
|
}
|
|
2525
2525
|
function Ze(n) {
|
|
2526
2526
|
const [e, t, ...r] = n.split(".");
|
|
@@ -2530,14 +2530,14 @@ function Ze(n) {
|
|
|
2530
2530
|
}
|
|
2531
2531
|
function Ks(n, e, t) {
|
|
2532
2532
|
if (!qs(n, e, t))
|
|
2533
|
-
return
|
|
2534
|
-
const r = Ze(t), s =
|
|
2533
|
+
return C(n, e, t);
|
|
2534
|
+
const r = Ze(t), s = C(n, e, r) || X(n, e, r);
|
|
2535
2535
|
if (s && s["value-type"] !== "ref")
|
|
2536
2536
|
throw new Error(`${t} does not reference a valid link attribute.`);
|
|
2537
2537
|
return s;
|
|
2538
2538
|
}
|
|
2539
2539
|
function Xe(n) {
|
|
2540
|
-
return typeof n == "string" && !Ie(n) ? null : typeof n == "string" && Ie(n) ? En(n) :
|
|
2540
|
+
return typeof n == "string" && !Ie(n) ? null : typeof n == "string" && Ie(n) ? En(n) : Fs(n);
|
|
2541
2541
|
}
|
|
2542
2542
|
function U(n, e, t) {
|
|
2543
2543
|
const r = Xe(t);
|
|
@@ -2548,19 +2548,19 @@ function U(n, e, t) {
|
|
|
2548
2548
|
throw new Error(`${s} is not a unique attribute.`);
|
|
2549
2549
|
return [o.id, i];
|
|
2550
2550
|
}
|
|
2551
|
-
function
|
|
2551
|
+
function Cn(n, e, t, r) {
|
|
2552
2552
|
var o;
|
|
2553
2553
|
const s = U(n, e, t);
|
|
2554
2554
|
return Array.isArray(s) ? [[
|
|
2555
2555
|
"add-triple",
|
|
2556
2556
|
s,
|
|
2557
|
-
(o =
|
|
2557
|
+
(o = C(n, e, "id")) == null ? void 0 : o.id,
|
|
2558
2558
|
s
|
|
2559
2559
|
]].concat(r) : r;
|
|
2560
2560
|
}
|
|
2561
2561
|
function zs({ attrsStore: n }, [e, t, r]) {
|
|
2562
2562
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2563
|
-
const a = Array.isArray(o) ? o : [o], c =
|
|
2563
|
+
const a = Array.isArray(o) ? o : [o], c = C(n, e, i), u = X(n, e, i);
|
|
2564
2564
|
return a.map((l) => c ? [
|
|
2565
2565
|
"add-triple",
|
|
2566
2566
|
U(n, e, t),
|
|
@@ -2577,11 +2577,11 @@ function zs({ attrsStore: n }, [e, t, r]) {
|
|
|
2577
2577
|
U(n, e, t)
|
|
2578
2578
|
]);
|
|
2579
2579
|
});
|
|
2580
|
-
return
|
|
2580
|
+
return Cn(n, e, t, s);
|
|
2581
2581
|
}
|
|
2582
2582
|
function Vs({ attrsStore: n }, [e, t, r]) {
|
|
2583
2583
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2584
|
-
const a = Array.isArray(o) ? o : [o], c =
|
|
2584
|
+
const a = Array.isArray(o) ? o : [o], c = C(n, e, i), u = X(n, e, i);
|
|
2585
2585
|
return a.map((l) => c ? [
|
|
2586
2586
|
"retract-triple",
|
|
2587
2587
|
U(n, e, t),
|
|
@@ -2598,7 +2598,7 @@ function Vs({ attrsStore: n }, [e, t, r]) {
|
|
|
2598
2598
|
U(n, e, t)
|
|
2599
2599
|
]);
|
|
2600
2600
|
});
|
|
2601
|
-
return
|
|
2601
|
+
return Cn(n, e, t, s);
|
|
2602
2602
|
}
|
|
2603
2603
|
function Qs(n, e, t, r) {
|
|
2604
2604
|
var s;
|
|
@@ -2623,21 +2623,21 @@ function Qs(n, e, t, r) {
|
|
|
2623
2623
|
}
|
|
2624
2624
|
return !1;
|
|
2625
2625
|
}
|
|
2626
|
-
function
|
|
2626
|
+
function Mn({ stores: n, attrsStore: e }, [t, r, s, i]) {
|
|
2627
2627
|
return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Qs(n, e, t, r) ? { mode: "update" } : null;
|
|
2628
2628
|
}
|
|
2629
2629
|
function Ws(n, e) {
|
|
2630
2630
|
const { attrsStore: t } = n, [r, s, i, o] = e, a = dt(i), c = U(t, r, s);
|
|
2631
2631
|
return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
|
|
2632
|
-
const d =
|
|
2633
|
-
return d["checked-data-type"] === "date" && n.useDateObjects && (f =
|
|
2632
|
+
const d = C(t, r, l);
|
|
2633
|
+
return d["checked-data-type"] === "date" && n.useDateObjects && (f = Ce(f)), ["add-triple", c, d.id, f, { mode: "create" }];
|
|
2634
2634
|
});
|
|
2635
2635
|
}
|
|
2636
2636
|
function Gs(n, e) {
|
|
2637
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a = dt(i), c = U(t, r, s), u =
|
|
2637
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = dt(i), c = U(t, r, s), u = Mn(n, [r, c, i, o]);
|
|
2638
2638
|
return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
|
|
2639
|
-
const h =
|
|
2640
|
-
return h["checked-data-type"] === "date" && n.useDateObjects && (d =
|
|
2639
|
+
const h = C(t, r, f);
|
|
2640
|
+
return h["checked-data-type"] === "date" && n.useDateObjects && (d = Ce(d)), [
|
|
2641
2641
|
"add-triple",
|
|
2642
2642
|
c,
|
|
2643
2643
|
h.id,
|
|
@@ -2650,8 +2650,8 @@ function Bs({ attrsStore: n }, [e, t]) {
|
|
|
2650
2650
|
return [["delete-entity", U(n, e, t), e]];
|
|
2651
2651
|
}
|
|
2652
2652
|
function Hs(n, e) {
|
|
2653
|
-
const { attrsStore: t } = n, [r, s, i, o] = e, a = dt(i), c = U(t, r, s), u =
|
|
2654
|
-
const p =
|
|
2653
|
+
const { attrsStore: t } = n, [r, s, i, o] = e, a = dt(i), c = U(t, r, s), u = Mn(n, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
|
|
2654
|
+
const p = C(t, r, d);
|
|
2655
2655
|
return [
|
|
2656
2656
|
"deep-merge-triple",
|
|
2657
2657
|
c,
|
|
@@ -2663,7 +2663,7 @@ function Hs(n, e) {
|
|
|
2663
2663
|
return [[
|
|
2664
2664
|
"add-triple",
|
|
2665
2665
|
c,
|
|
2666
|
-
|
|
2666
|
+
C(t, r, "id").id,
|
|
2667
2667
|
c,
|
|
2668
2668
|
...u ? [u] : []
|
|
2669
2669
|
]].concat(l);
|
|
@@ -2807,7 +2807,7 @@ function ui({ attrsStore: n, schema: e }, t) {
|
|
|
2807
2807
|
var d, h;
|
|
2808
2808
|
const r = /* @__PURE__ */ new Set(), s = [], i = [];
|
|
2809
2809
|
function o(p, b) {
|
|
2810
|
-
return
|
|
2810
|
+
return C(n, p, b) || s.find(
|
|
2811
2811
|
(_) => _["forward-identity"][1] === p && _["forward-identity"][2] === b
|
|
2812
2812
|
);
|
|
2813
2813
|
}
|
|
@@ -3232,7 +3232,7 @@ async function gi(n, e) {
|
|
|
3232
3232
|
s.oncomplete = (d) => l(d), s.onerror = (d) => f(d), s.onabort = (d) => f(d);
|
|
3233
3233
|
});
|
|
3234
3234
|
}
|
|
3235
|
-
const
|
|
3235
|
+
const Nt = /* @__PURE__ */ new Map();
|
|
3236
3236
|
class Pn extends fi {
|
|
3237
3237
|
constructor(e, t) {
|
|
3238
3238
|
super(e, t), this.dbName = `instant_${e}_${di}`, this._storeName = t, this._appId = e, this._dbPromise = this._init();
|
|
@@ -3249,9 +3249,9 @@ class Pn extends fi {
|
|
|
3249
3249
|
const c = gi(this._appId, a).catch((u) => {
|
|
3250
3250
|
pi("Error upgrading store from version 5 to 6.")(u);
|
|
3251
3251
|
});
|
|
3252
|
-
|
|
3252
|
+
Nt.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
|
|
3253
3253
|
} else {
|
|
3254
|
-
const c =
|
|
3254
|
+
const c = Nt.get(this.dbName);
|
|
3255
3255
|
c ? c.then(() => e(a)).catch(() => e(a)) : e(a);
|
|
3256
3256
|
}
|
|
3257
3257
|
}, s.onupgradeneeded = (i) => {
|
|
@@ -3422,7 +3422,7 @@ async function mi({
|
|
|
3422
3422
|
})
|
|
3423
3423
|
});
|
|
3424
3424
|
}
|
|
3425
|
-
async function
|
|
3425
|
+
async function Ft({
|
|
3426
3426
|
apiURI: n,
|
|
3427
3427
|
appId: e,
|
|
3428
3428
|
code: t,
|
|
@@ -3573,7 +3573,7 @@ function qt(n, e) {
|
|
|
3573
3573
|
t[r] = n[r];
|
|
3574
3574
|
}), t;
|
|
3575
3575
|
}
|
|
3576
|
-
function
|
|
3576
|
+
function Ci(n, e, t) {
|
|
3577
3577
|
const r = {
|
|
3578
3578
|
peers: {}
|
|
3579
3579
|
};
|
|
@@ -3590,7 +3590,7 @@ function Mi(n, e, t) {
|
|
|
3590
3590
|
}
|
|
3591
3591
|
return r;
|
|
3592
3592
|
}
|
|
3593
|
-
function
|
|
3593
|
+
function Mi(n, e) {
|
|
3594
3594
|
if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !kt(n.user, e.user)) || !un(n.peers, e.peers)) return !0;
|
|
3595
3595
|
for (const r of Object.keys(n.peers))
|
|
3596
3596
|
if (!kt(n.peers[r], e.peers[r])) return !0;
|
|
@@ -3639,7 +3639,7 @@ function nt(n) {
|
|
|
3639
3639
|
}, e;
|
|
3640
3640
|
}, {});
|
|
3641
3641
|
}
|
|
3642
|
-
const xn = "v0.22.90-experimental.drewh-ssr.
|
|
3642
|
+
const xn = "v0.22.90-experimental.drewh-ssr.20347747146.1";
|
|
3643
3643
|
function Pi(n, e) {
|
|
3644
3644
|
return {
|
|
3645
3645
|
info: n ? (...t) => console.info(...t, e()) : () => {
|
|
@@ -4010,7 +4010,7 @@ const Vt = [
|
|
|
4010
4010
|
r ? `${r}.where` : "where"
|
|
4011
4011
|
);
|
|
4012
4012
|
}
|
|
4013
|
-
},
|
|
4013
|
+
}, Nn = (n, e, t, r, s = 0) => {
|
|
4014
4014
|
var i;
|
|
4015
4015
|
if (!n || typeof n != "object")
|
|
4016
4016
|
throw new k(
|
|
@@ -4029,7 +4029,7 @@ const Vt = [
|
|
|
4029
4029
|
const a = n[o];
|
|
4030
4030
|
if (typeof a == "object" && a !== null) {
|
|
4031
4031
|
const c = (i = t == null ? void 0 : t.entities[e].links[o]) == null ? void 0 : i.entityName;
|
|
4032
|
-
c &&
|
|
4032
|
+
c && Nn(
|
|
4033
4033
|
a,
|
|
4034
4034
|
c,
|
|
4035
4035
|
t,
|
|
@@ -4081,7 +4081,7 @@ const Vt = [
|
|
|
4081
4081
|
r
|
|
4082
4082
|
);
|
|
4083
4083
|
}
|
|
4084
|
-
|
|
4084
|
+
Nn(
|
|
4085
4085
|
t[r],
|
|
4086
4086
|
r,
|
|
4087
4087
|
e,
|
|
@@ -4097,8 +4097,8 @@ class q extends Error {
|
|
|
4097
4097
|
super(e), this.name = "TransactionValidationError";
|
|
4098
4098
|
}
|
|
4099
4099
|
}
|
|
4100
|
-
const
|
|
4101
|
-
`Entity '${n}' does not exist in schema. Available entities: ${
|
|
4100
|
+
const Fn = (n) => n.length > 0 ? n.join(", ") : "none", xi = (n, e) => new q(
|
|
4101
|
+
`Entity '${n}' does not exist in schema. Available entities: ${Fn(e)}`
|
|
4102
4102
|
), Ue = {
|
|
4103
4103
|
string: (n) => typeof n == "string",
|
|
4104
4104
|
number: (n) => typeof n == "number" && !isNaN(n),
|
|
@@ -4137,7 +4137,7 @@ const Nn = (n) => n.length > 0 ? n.join(", ") : "none", xi = (n, e) => new q(
|
|
|
4137
4137
|
if (!r.links[s]) {
|
|
4138
4138
|
const a = Object.keys(r.links);
|
|
4139
4139
|
throw new q(
|
|
4140
|
-
`Link '${s}' does not exist on entity '${n}'. Available links: ${
|
|
4140
|
+
`Link '${s}' does not exist on entity '${n}'. Available links: ${Fn(a)}`
|
|
4141
4141
|
);
|
|
4142
4142
|
}
|
|
4143
4143
|
if (i != null) {
|
|
@@ -4161,7 +4161,7 @@ const Nn = (n) => n.length > 0 ? n.join(", ") : "none", xi = (n, e) => new q(
|
|
|
4161
4161
|
unlink: Gt,
|
|
4162
4162
|
delete: () => {
|
|
4163
4163
|
}
|
|
4164
|
-
},
|
|
4164
|
+
}, Ni = (n, e) => {
|
|
4165
4165
|
if (!e) return;
|
|
4166
4166
|
const [t, r, s, i] = n;
|
|
4167
4167
|
if (!Array.isArray(s) && !re(s))
|
|
@@ -4174,7 +4174,7 @@ const Nn = (n) => n.length > 0 ? n.join(", ") : "none", xi = (n, e) => new q(
|
|
|
4174
4174
|
);
|
|
4175
4175
|
const o = Li[t];
|
|
4176
4176
|
o && i !== void 0 && o(r, i, e);
|
|
4177
|
-
},
|
|
4177
|
+
}, Fi = (n, e) => {
|
|
4178
4178
|
const t = Array.isArray(n) ? n : [n];
|
|
4179
4179
|
for (const r of t) {
|
|
4180
4180
|
if (!r || typeof r != "object")
|
|
@@ -4190,7 +4190,7 @@ const Nn = (n) => n.length > 0 ? n.join(", ") : "none", xi = (n, e) => new q(
|
|
|
4190
4190
|
throw new q(
|
|
4191
4191
|
`Transaction operation must be an array, but received: ${typeof s}`
|
|
4192
4192
|
);
|
|
4193
|
-
|
|
4193
|
+
Ni(s, e);
|
|
4194
4194
|
}
|
|
4195
4195
|
}
|
|
4196
4196
|
};
|
|
@@ -4338,7 +4338,7 @@ function Vi(n, e, t) {
|
|
|
4338
4338
|
const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = t == null ? void 0 : t.state) == null ? void 0 : o.txId;
|
|
4339
4339
|
return r && (!s || r > s) ? e : s && (!r || s > r) ? t : e || t;
|
|
4340
4340
|
}
|
|
4341
|
-
function
|
|
4341
|
+
function Ne(n, e, t) {
|
|
4342
4342
|
return bt(
|
|
4343
4343
|
{ store: e, attrsStore: t, pageInfo: null, aggregate: null },
|
|
4344
4344
|
n.query
|
|
@@ -4346,7 +4346,7 @@ function Fe(n, e, t) {
|
|
|
4346
4346
|
}
|
|
4347
4347
|
function Ht(n, e, t, r) {
|
|
4348
4348
|
var o;
|
|
4349
|
-
const s = (o =
|
|
4349
|
+
const s = (o = C(t, n.table, "id")) == null ? void 0 : o.id;
|
|
4350
4350
|
if (!s)
|
|
4351
4351
|
return -1;
|
|
4352
4352
|
const i = ie(e.eav, [r, s, r]);
|
|
@@ -4394,7 +4394,7 @@ function Wi(n, e) {
|
|
|
4394
4394
|
var r;
|
|
4395
4395
|
if (n.orderFieldType)
|
|
4396
4396
|
return n.orderFieldType;
|
|
4397
|
-
const t = n.orderField === "serverCreatedAt" ? "number" : (r =
|
|
4397
|
+
const t = n.orderField === "serverCreatedAt" ? "number" : (r = C(e(), n.table, n.orderField)) == null ? void 0 : r["checked-data-type"];
|
|
4398
4398
|
return n.orderFieldType = t, t;
|
|
4399
4399
|
}
|
|
4400
4400
|
function Gi(n, e, t) {
|
|
@@ -4469,7 +4469,7 @@ class Hi {
|
|
|
4469
4469
|
this.subs.flush();
|
|
4470
4470
|
}
|
|
4471
4471
|
subscribe(e, t) {
|
|
4472
|
-
const r =
|
|
4472
|
+
const r = M(e);
|
|
4473
4473
|
return this.callbacks[r] = this.callbacks[r] || [], this.callbacks[r].push(t), this.initSubscription(e, r, t), (s) => {
|
|
4474
4474
|
this.unsubscribe(r, t, s == null ? void 0 : s.keepSubscription);
|
|
4475
4475
|
};
|
|
@@ -4540,7 +4540,7 @@ class Hi {
|
|
|
4540
4540
|
}
|
|
4541
4541
|
}
|
|
4542
4542
|
onStartSyncOk(e) {
|
|
4543
|
-
const t = e["subscription-id"], r = e.q, s =
|
|
4543
|
+
const t = e["subscription-id"], r = e.q, s = M(r);
|
|
4544
4544
|
this.idToHash[t] = s, this.subs.updateInPlace((i) => {
|
|
4545
4545
|
const o = i[s];
|
|
4546
4546
|
if (!o)
|
|
@@ -4580,7 +4580,7 @@ class Hi {
|
|
|
4580
4580
|
o.values = a;
|
|
4581
4581
|
const c = a.entities;
|
|
4582
4582
|
for (const u of r) {
|
|
4583
|
-
const l = this.createStore(u), f =
|
|
4583
|
+
const l = this.createStore(u), f = Ne(o, l, a.attrsStore);
|
|
4584
4584
|
c.push({
|
|
4585
4585
|
store: l,
|
|
4586
4586
|
entity: f,
|
|
@@ -4661,7 +4661,7 @@ class Hi {
|
|
|
4661
4661
|
const w = f[y];
|
|
4662
4662
|
if (Ir(w.store, _)) {
|
|
4663
4663
|
Jt(w.store, l.attrsStore, g);
|
|
4664
|
-
const S =
|
|
4664
|
+
const S = Ne(s, w.store, l.attrsStore), m = Qi(
|
|
4665
4665
|
w.store,
|
|
4666
4666
|
l.attrsStore,
|
|
4667
4667
|
g
|
|
@@ -4678,7 +4678,7 @@ class Hi {
|
|
|
4678
4678
|
for (const [_, g] of Object.entries(u)) {
|
|
4679
4679
|
const y = this.createStore([]);
|
|
4680
4680
|
Jt(y, l.attrsStore, g);
|
|
4681
|
-
const w =
|
|
4681
|
+
const w = Ne(s, y, l.attrsStore);
|
|
4682
4682
|
if (!w) {
|
|
4683
4683
|
this.log.error("No entity found after applying change", {
|
|
4684
4684
|
sub: s,
|
|
@@ -4726,7 +4726,7 @@ class Hi {
|
|
|
4726
4726
|
}
|
|
4727
4727
|
}
|
|
4728
4728
|
onStartSyncError(e) {
|
|
4729
|
-
const t =
|
|
4729
|
+
const t = M(e["original-event"].q), r = {
|
|
4730
4730
|
message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa.",
|
|
4731
4731
|
status: e.status,
|
|
4732
4732
|
type: e.type,
|
|
@@ -4752,7 +4752,7 @@ const W = {
|
|
|
4752
4752
|
}, Ji = 3e4, Yi = 3e4, Zi = 200, Xi = {
|
|
4753
4753
|
apiURI: "https://api.instantdb.com",
|
|
4754
4754
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
4755
|
-
},
|
|
4755
|
+
}, Fe = "_instant_oauth_redirect", oe = "currentUser";
|
|
4756
4756
|
function eo({
|
|
4757
4757
|
transportType: n,
|
|
4758
4758
|
appId: e,
|
|
@@ -4916,7 +4916,7 @@ class ao {
|
|
|
4916
4916
|
// Queries
|
|
4917
4917
|
T(this, "getPreviousResult", (e) => {
|
|
4918
4918
|
var r;
|
|
4919
|
-
const t =
|
|
4919
|
+
const t = M(e);
|
|
4920
4920
|
return (r = this.dataForQuery(t)) == null ? void 0 : r.data;
|
|
4921
4921
|
});
|
|
4922
4922
|
/** Re-run instaql and call all callbacks with new data */
|
|
@@ -4937,7 +4937,7 @@ class ao {
|
|
|
4937
4937
|
});
|
|
4938
4938
|
/** Applies transactions locally and sends transact message to server */
|
|
4939
4939
|
T(this, "pushTx", (e) => {
|
|
4940
|
-
this.config.disableValidation ||
|
|
4940
|
+
this.config.disableValidation || Fi(e, this.config.schema);
|
|
4941
4941
|
try {
|
|
4942
4942
|
const t = li(
|
|
4943
4943
|
{
|
|
@@ -5248,7 +5248,7 @@ class ao {
|
|
|
5248
5248
|
_addQueryData(e, t, r) {
|
|
5249
5249
|
if (!this.attrs)
|
|
5250
5250
|
throw new Error("Attrs in reactor have not been set");
|
|
5251
|
-
const s =
|
|
5251
|
+
const s = M(e), i = this.ensureAttrs(), o = te(
|
|
5252
5252
|
this.attrs,
|
|
5253
5253
|
t.triples,
|
|
5254
5254
|
r,
|
|
@@ -5280,11 +5280,11 @@ class ao {
|
|
|
5280
5280
|
break;
|
|
5281
5281
|
}
|
|
5282
5282
|
case "add-query-exists": {
|
|
5283
|
-
this.notifyOneQueryOnce(
|
|
5283
|
+
this.notifyOneQueryOnce(M(t.q));
|
|
5284
5284
|
break;
|
|
5285
5285
|
}
|
|
5286
5286
|
case "add-query-ok": {
|
|
5287
|
-
const { q: d, result: h } = t, p =
|
|
5287
|
+
const { q: d, result: h } = t, p = M(d);
|
|
5288
5288
|
if (!this._hasQueryListeners() && !this.querySubs.currentValue[p])
|
|
5289
5289
|
break;
|
|
5290
5290
|
const b = (a = (o = h == null ? void 0 : h[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], _ = (u = (c = h == null ? void 0 : h[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, g = zt(h), y = this.ensureAttrs(), w = te(
|
|
@@ -5337,7 +5337,7 @@ class ao {
|
|
|
5337
5337
|
});
|
|
5338
5338
|
const _ = Zt(b.entries()), g = d.map((y) => {
|
|
5339
5339
|
var _t, wt, Tt, mt;
|
|
5340
|
-
const w = y["instaql-query"], S = y["instaql-result"], m =
|
|
5340
|
+
const w = y["instaql-query"], S = y["instaql-result"], m = M(w), v = zt(S), O = this.ensureAttrs(), L = te(
|
|
5341
5341
|
O,
|
|
5342
5342
|
v,
|
|
5343
5343
|
r,
|
|
@@ -5486,8 +5486,8 @@ class ao {
|
|
|
5486
5486
|
return;
|
|
5487
5487
|
}
|
|
5488
5488
|
if ((a = e["original-event"]) != null && a.hasOwnProperty("q") && ((c = e["original-event"]) == null ? void 0 : c.op) === "add-query") {
|
|
5489
|
-
const p = (u = e["original-event"]) == null ? void 0 : u.q, b =
|
|
5490
|
-
this.notifyQueryError(
|
|
5489
|
+
const p = (u = e["original-event"]) == null ? void 0 : u.q, b = M(p);
|
|
5490
|
+
this.notifyQueryError(M(p), s), this.notifyQueryOnceError(p, b, t, s);
|
|
5491
5491
|
return;
|
|
5492
5492
|
}
|
|
5493
5493
|
if (((l = e["original-event"]) == null ? void 0 : l.op) === "init") {
|
|
@@ -5545,7 +5545,7 @@ class ao {
|
|
|
5545
5545
|
*/
|
|
5546
5546
|
subscribeQuery(e, t, r) {
|
|
5547
5547
|
this.config.disableValidation || Qt(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
|
|
5548
|
-
const s =
|
|
5548
|
+
const s = M(e), i = this.getPreviousResult(e);
|
|
5549
5549
|
return i && t(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: t }), this._startQuerySub(e, s), () => {
|
|
5550
5550
|
this._unsubQuery(e, s, t);
|
|
5551
5551
|
};
|
|
@@ -5563,7 +5563,7 @@ class ao {
|
|
|
5563
5563
|
"We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query"
|
|
5564
5564
|
)
|
|
5565
5565
|
), r.promise;
|
|
5566
|
-
const s =
|
|
5566
|
+
const s = M(e), i = this._startQuerySub(e, s);
|
|
5567
5567
|
return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
|
|
5568
5568
|
() => r.reject(new Error("Query timed out")),
|
|
5569
5569
|
Ji
|
|
@@ -5606,7 +5606,7 @@ class ao {
|
|
|
5606
5606
|
if (!t) return /* @__PURE__ */ new Map();
|
|
5607
5607
|
const s = (l) => {
|
|
5608
5608
|
const [f, d, h] = l["forward-identity"];
|
|
5609
|
-
return
|
|
5609
|
+
return C(e, d, h);
|
|
5610
5610
|
}, i = (l) => {
|
|
5611
5611
|
const [f, d, h] = l["forward-identity"];
|
|
5612
5612
|
return X(e, d, h);
|
|
@@ -5634,7 +5634,7 @@ class ao {
|
|
|
5634
5634
|
a = !0;
|
|
5635
5635
|
continue;
|
|
5636
5636
|
}
|
|
5637
|
-
const b = a ?
|
|
5637
|
+
const b = a ? Ns(o, h) : h;
|
|
5638
5638
|
d.push(b);
|
|
5639
5639
|
}
|
|
5640
5640
|
return a ? d : l;
|
|
@@ -5708,7 +5708,7 @@ class ao {
|
|
|
5708
5708
|
_applyOptimisticUpdates(e, t, r, s) {
|
|
5709
5709
|
for (const [i, o] of r)
|
|
5710
5710
|
if (!o["tx-id"] || s && o["tx-id"] > s) {
|
|
5711
|
-
const a =
|
|
5711
|
+
const a = Fr(e, t, o["tx-steps"]);
|
|
5712
5712
|
e = a.store, t = a.attrsStore;
|
|
5713
5713
|
}
|
|
5714
5714
|
return { store: e, attrsStore: t };
|
|
@@ -5872,9 +5872,9 @@ class ao {
|
|
|
5872
5872
|
if (typeof URL > "u")
|
|
5873
5873
|
return;
|
|
5874
5874
|
const e = new URL(window.location.href);
|
|
5875
|
-
if (e.searchParams.get(
|
|
5875
|
+
if (e.searchParams.get(Fe)) {
|
|
5876
5876
|
const t = e.toString();
|
|
5877
|
-
e.searchParams.delete(
|
|
5877
|
+
e.searchParams.delete(Fe), e.searchParams.delete("code"), e.searchParams.delete("error");
|
|
5878
5878
|
const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
|
|
5879
5879
|
if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
|
|
5880
5880
|
typeof navigation == "object" && // @ts-ignore (waiting for ts support)
|
|
@@ -5898,7 +5898,7 @@ class ao {
|
|
|
5898
5898
|
if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
|
|
5899
5899
|
return null;
|
|
5900
5900
|
const e = new URLSearchParams(window.location.search);
|
|
5901
|
-
if (!e.get(
|
|
5901
|
+
if (!e.get(Fe))
|
|
5902
5902
|
return null;
|
|
5903
5903
|
const t = e.get("error");
|
|
5904
5904
|
if (t)
|
|
@@ -5908,7 +5908,7 @@ class ao {
|
|
|
5908
5908
|
return null;
|
|
5909
5909
|
this._replaceUrlAfterOAuth();
|
|
5910
5910
|
try {
|
|
5911
|
-
const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await
|
|
5911
|
+
const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await Ft({
|
|
5912
5912
|
apiURI: this.config.apiURI,
|
|
5913
5913
|
appId: this.config.appId,
|
|
5914
5914
|
code: r,
|
|
@@ -6019,11 +6019,13 @@ class ao {
|
|
|
6019
6019
|
}
|
|
6020
6020
|
}
|
|
6021
6021
|
async syncUserToEndpoint(e) {
|
|
6022
|
-
if (this.config.
|
|
6022
|
+
if (this.config.firstPartyPath)
|
|
6023
6023
|
try {
|
|
6024
|
-
fetch(this.config.
|
|
6024
|
+
fetch(this.config.firstPartyPath + "/", {
|
|
6025
6025
|
method: "POST",
|
|
6026
6026
|
body: JSON.stringify({
|
|
6027
|
+
type: "sync-user",
|
|
6028
|
+
appId: this.config.appId,
|
|
6027
6029
|
user: e
|
|
6028
6030
|
}),
|
|
6029
6031
|
headers: {
|
|
@@ -6117,7 +6119,7 @@ class ao {
|
|
|
6117
6119
|
*/
|
|
6118
6120
|
async exchangeCodeForToken({ code: e, codeVerifier: t }) {
|
|
6119
6121
|
var o;
|
|
6120
|
-
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await
|
|
6122
|
+
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Ft({
|
|
6121
6123
|
apiURI: this.config.apiURI,
|
|
6122
6124
|
appId: this.config.appId,
|
|
6123
6125
|
code: e,
|
|
@@ -6179,7 +6181,7 @@ class ao {
|
|
|
6179
6181
|
getPresence(e, t, r = {}) {
|
|
6180
6182
|
const s = this._rooms[t], i = this._presence[t];
|
|
6181
6183
|
return !s || !i || !i.result ? null : {
|
|
6182
|
-
...
|
|
6184
|
+
...Ci(i.result, r, this._sessionId),
|
|
6183
6185
|
isLoading: !s.isConnected,
|
|
6184
6186
|
error: s.error
|
|
6185
6187
|
};
|
|
@@ -6235,7 +6237,7 @@ class ao {
|
|
|
6235
6237
|
}
|
|
6236
6238
|
_notifyPresenceSub(e, t) {
|
|
6237
6239
|
const r = this.getPresence("", e, t);
|
|
6238
|
-
r && (t.prev && !
|
|
6240
|
+
r && (t.prev && !Mi(r, t.prev) || (t.prev = r, t.cb(r)));
|
|
6239
6241
|
}
|
|
6240
6242
|
_patchPresencePeers(e, t) {
|
|
6241
6243
|
var o, a, c;
|
|
@@ -6540,38 +6542,49 @@ function Oo(n) {
|
|
|
6540
6542
|
}
|
|
6541
6543
|
return { element: e, isVisible: t };
|
|
6542
6544
|
}
|
|
6543
|
-
const
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
return r.user && r.user.refresh_token ? new Response("sync", {
|
|
6545
|
+
const No = (n) => {
|
|
6546
|
+
function e(r) {
|
|
6547
|
+
return r && r.refresh_token ? new Response(JSON.stringify({ ok: !0 }), {
|
|
6547
6548
|
headers: {
|
|
6549
|
+
"Content-Type": "application/json",
|
|
6548
6550
|
// 7 day expiry
|
|
6549
|
-
"Set-Cookie": `
|
|
6551
|
+
"Set-Cookie": `instant_user_${n.appId}=${JSON.stringify(r)}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=604800`
|
|
6550
6552
|
}
|
|
6551
|
-
}) : new Response(
|
|
6553
|
+
}) : new Response(JSON.stringify({ ok: !0 }), {
|
|
6552
6554
|
headers: {
|
|
6555
|
+
"Content-Type": "application/json",
|
|
6553
6556
|
// remove the cookie (some browsers)
|
|
6554
|
-
"Set-Cookie":
|
|
6557
|
+
"Set-Cookie": `instant_user_${n.appId}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=-1`
|
|
6555
6558
|
}
|
|
6556
6559
|
});
|
|
6557
6560
|
}
|
|
6561
|
+
function t(r, s) {
|
|
6562
|
+
return new Response(JSON.stringify({ ok: !1, error: s }), {
|
|
6563
|
+
status: r,
|
|
6564
|
+
headers: { "Content-Type": "application/json" }
|
|
6565
|
+
});
|
|
6566
|
+
}
|
|
6558
6567
|
return {
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
+
POST: async (r) => {
|
|
6569
|
+
let s;
|
|
6570
|
+
try {
|
|
6571
|
+
s = await r.json();
|
|
6572
|
+
} catch {
|
|
6573
|
+
return t(400, "Invalid JSON body");
|
|
6574
|
+
}
|
|
6575
|
+
if (!s.type)
|
|
6576
|
+
return t(400, 'Missing "type" field');
|
|
6577
|
+
if (s.appId !== n.appId)
|
|
6578
|
+
return t(403, "App ID mismatch");
|
|
6579
|
+
switch (s.type) {
|
|
6580
|
+
case "sync-user":
|
|
6581
|
+
return e(s.user ?? null);
|
|
6582
|
+
default:
|
|
6583
|
+
return t(400, `Unknown type: ${s.type}`);
|
|
6568
6584
|
}
|
|
6569
|
-
return new Response("Route not found", {
|
|
6570
|
-
status: 404
|
|
6571
|
-
});
|
|
6572
6585
|
}
|
|
6573
6586
|
};
|
|
6574
|
-
},
|
|
6587
|
+
}, Fo = (n) => {
|
|
6575
6588
|
var i, o, a, c, u, l;
|
|
6576
6589
|
const e = {};
|
|
6577
6590
|
for (const [f, d] of Object.entries(n.entities)) {
|
|
@@ -6759,7 +6772,7 @@ class qo {
|
|
|
6759
6772
|
}, this.hashQuery = (t, r) => {
|
|
6760
6773
|
t && r && "ruleParams" in r && (t = { $$ruleParams: r.ruleParams, ...t });
|
|
6761
6774
|
const s = t ? Po(t) : null;
|
|
6762
|
-
return { hash:
|
|
6775
|
+
return { hash: M(s), query: s };
|
|
6763
6776
|
}, this.getTriplesAndAttrsForQuery = async (t) => {
|
|
6764
6777
|
var c, u, l, f, d, h;
|
|
6765
6778
|
const r = await fetch(
|
|
@@ -6808,12 +6821,12 @@ function rt(n) {
|
|
|
6808
6821
|
return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects;
|
|
6809
6822
|
}
|
|
6810
6823
|
const st = Io(), Xt = Eo();
|
|
6811
|
-
class
|
|
6824
|
+
class Co {
|
|
6812
6825
|
constructor(e) {
|
|
6813
6826
|
this.db = e, this.sendMagicCode = (t) => this.db.sendMagicCode(t), this.signInWithMagicCode = (t) => this.db.signInWithMagicCode(t), this.signInWithToken = (t) => this.db.signInWithCustomToken(t), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (t) => this.db.createAuthorizationURL(t), this.signInWithIdToken = (t) => this.db.signInWithIdToken(t), this.exchangeOAuthCode = (t) => this.db.exchangeCodeForToken(t), this.issuerURI = () => this.db.issuerURI(), this.signOut = (t = { invalidateToken: !0 }) => this.db.signOut(t);
|
|
6814
6827
|
}
|
|
6815
6828
|
}
|
|
6816
|
-
class
|
|
6829
|
+
class Mo {
|
|
6817
6830
|
constructor(e) {
|
|
6818
6831
|
this.db = e, this.uploadFile = (t, r, s = {}) => this.db.uploadFile(t, r, s), this.delete = (t) => this.db.deleteFile(t), this.upload = (t, r) => this.db.upload(t, r), this.put = this.upload, this.getDownloadUrl = (t) => this.db.getDownloadUrl(t);
|
|
6819
6832
|
}
|
|
@@ -6823,7 +6836,7 @@ function Po(n) {
|
|
|
6823
6836
|
}
|
|
6824
6837
|
class jo {
|
|
6825
6838
|
constructor(e) {
|
|
6826
|
-
this.tx = In(), this._reactor = e, this.auth = new
|
|
6839
|
+
this.tx = In(), this._reactor = e, this.auth = new Co(this._reactor), this.storage = new Mo(this._reactor);
|
|
6827
6840
|
}
|
|
6828
6841
|
/**
|
|
6829
6842
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -7003,7 +7016,7 @@ function en(n) {
|
|
|
7003
7016
|
const e = Xt.get(n);
|
|
7004
7017
|
if (e)
|
|
7005
7018
|
return e;
|
|
7006
|
-
const t =
|
|
7019
|
+
const t = M(n);
|
|
7007
7020
|
return Xt.set(n, t), t;
|
|
7008
7021
|
}
|
|
7009
7022
|
function $o(n, e) {
|
|
@@ -7041,32 +7054,32 @@ function Ro(n, e) {
|
|
|
7041
7054
|
}
|
|
7042
7055
|
const Ko = Do;
|
|
7043
7056
|
export {
|
|
7044
|
-
|
|
7057
|
+
Co as Auth,
|
|
7045
7058
|
qo as FrameworkClient,
|
|
7046
7059
|
Pn as IndexedDBStorage,
|
|
7047
7060
|
Pe as InstantAPIError,
|
|
7048
7061
|
jo as InstantCoreDatabase,
|
|
7049
7062
|
pe as InstantError,
|
|
7050
7063
|
k as QueryValidationError,
|
|
7051
|
-
|
|
7064
|
+
Mo as Storage,
|
|
7052
7065
|
fi as StorageInterface,
|
|
7053
7066
|
Bi as SyncTableCallbackEventType,
|
|
7054
7067
|
q as TransactionValidationError,
|
|
7055
7068
|
jn as WindowNetworkListener,
|
|
7056
7069
|
Po as coerceQuery,
|
|
7057
|
-
|
|
7058
|
-
|
|
7070
|
+
Ce as coerceToDate,
|
|
7071
|
+
No as createInstantRouteHandler,
|
|
7059
7072
|
Ls as getOps,
|
|
7060
7073
|
E as i,
|
|
7061
7074
|
P as id,
|
|
7062
7075
|
Do as init,
|
|
7063
7076
|
Ko as init_experimental,
|
|
7064
7077
|
Uo as lookup,
|
|
7065
|
-
|
|
7078
|
+
Fo as parseSchemaFromJSON,
|
|
7066
7079
|
Lo as tx,
|
|
7067
7080
|
In as txInit,
|
|
7068
7081
|
Qt as validateQuery,
|
|
7069
|
-
|
|
7082
|
+
Fi as validateTransactions,
|
|
7070
7083
|
xn as version,
|
|
7071
|
-
|
|
7084
|
+
M as weakHash
|
|
7072
7085
|
};
|