@instantdb/core 0.22.76 → 0.22.77
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/dates.test.ts +5 -0
- package/dist/commonjs/utils/dates.d.ts.map +1 -1
- package/dist/commonjs/utils/dates.js +16 -0
- package/dist/commonjs/utils/dates.js.map +1 -1
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +16 -0
- package/dist/esm/utils/dates.js.map +1 -1
- package/dist/standalone/index.js +345 -336
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +2 -2
- package/src/utils/dates.ts +19 -0
package/dist/standalone/index.js
CHANGED
|
@@ -1256,13 +1256,21 @@ function Tr(t) {
|
|
|
1256
1256
|
return null;
|
|
1257
1257
|
}
|
|
1258
1258
|
function mr(t) {
|
|
1259
|
+
const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
|
|
1260
|
+
if (n) {
|
|
1261
|
+
const [, r, s, i, o, a] = n, c = s.padStart(2, "0"), u = i.padStart(2, "0"), l = `${r}-${c}-${u}T${a}`;
|
|
1262
|
+
return new Date(l);
|
|
1263
|
+
}
|
|
1264
|
+
return null;
|
|
1265
|
+
}
|
|
1266
|
+
function Sr(t) {
|
|
1259
1267
|
const [e, n] = t.split(", "), [r, s, i] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
|
|
1260
1268
|
if (!o)
|
|
1261
1269
|
throw new Error(`Unable to parse time from: ${t}`);
|
|
1262
1270
|
let [, a, c, u, l] = o;
|
|
1263
1271
|
return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
|
|
1264
1272
|
}
|
|
1265
|
-
function
|
|
1273
|
+
function Or(t) {
|
|
1266
1274
|
switch (t) {
|
|
1267
1275
|
case "epoch":
|
|
1268
1276
|
return /* @__PURE__ */ new Date(0);
|
|
@@ -1274,27 +1282,28 @@ function Sr(t) {
|
|
|
1274
1282
|
return null;
|
|
1275
1283
|
}
|
|
1276
1284
|
}
|
|
1277
|
-
function
|
|
1285
|
+
function Ar(t) {
|
|
1278
1286
|
const e = t.match(Ct);
|
|
1279
1287
|
if (!e)
|
|
1280
1288
|
return null;
|
|
1281
1289
|
const [n] = e, r = fr[n], s = new Date(t.replace(Ct, "Z"));
|
|
1282
1290
|
return new Date(s.getTime() - r * 1e3);
|
|
1283
1291
|
}
|
|
1284
|
-
const
|
|
1292
|
+
const vr = [
|
|
1285
1293
|
yr,
|
|
1286
1294
|
_r,
|
|
1287
1295
|
wr,
|
|
1288
|
-
|
|
1296
|
+
Sr,
|
|
1289
1297
|
gr,
|
|
1290
1298
|
hr,
|
|
1291
1299
|
Tr,
|
|
1292
1300
|
br,
|
|
1293
1301
|
dr,
|
|
1294
|
-
|
|
1295
|
-
|
|
1302
|
+
Or,
|
|
1303
|
+
Ar,
|
|
1304
|
+
mr
|
|
1296
1305
|
];
|
|
1297
|
-
function
|
|
1306
|
+
function kr(t, e) {
|
|
1298
1307
|
try {
|
|
1299
1308
|
const n = t(e);
|
|
1300
1309
|
return n instanceof Date && !isNaN(n.getTime()) ? n : null;
|
|
@@ -1303,14 +1312,14 @@ function vr(t, e) {
|
|
|
1303
1312
|
}
|
|
1304
1313
|
}
|
|
1305
1314
|
function Qe(t) {
|
|
1306
|
-
for (const e of
|
|
1307
|
-
const n =
|
|
1315
|
+
for (const e of vr) {
|
|
1316
|
+
const n = kr(e, t);
|
|
1308
1317
|
if (n)
|
|
1309
1318
|
return n;
|
|
1310
1319
|
}
|
|
1311
1320
|
return null;
|
|
1312
1321
|
}
|
|
1313
|
-
function
|
|
1322
|
+
function Er(t) {
|
|
1314
1323
|
try {
|
|
1315
1324
|
const e = JSON.parse(t);
|
|
1316
1325
|
return typeof e == "string" ? Qe(e) : null;
|
|
@@ -1325,7 +1334,7 @@ function Me(t) {
|
|
|
1325
1334
|
if (t instanceof Date)
|
|
1326
1335
|
return t;
|
|
1327
1336
|
if (typeof t == "string") {
|
|
1328
|
-
const e = Qe(t) ||
|
|
1337
|
+
const e = Qe(t) || Er(t) || Qe(t.trim());
|
|
1329
1338
|
if (!e)
|
|
1330
1339
|
throw new Error(`Unable to parse \`${t}\` as a date.`);
|
|
1331
1340
|
return e;
|
|
@@ -1336,7 +1345,7 @@ function Me(t) {
|
|
|
1336
1345
|
);
|
|
1337
1346
|
}
|
|
1338
1347
|
}
|
|
1339
|
-
function
|
|
1348
|
+
function Cr(t) {
|
|
1340
1349
|
return t.cardinality === "one";
|
|
1341
1350
|
}
|
|
1342
1351
|
function ht(t) {
|
|
@@ -1413,7 +1422,7 @@ function bn(t) {
|
|
|
1413
1422
|
t.useDateObjects
|
|
1414
1423
|
);
|
|
1415
1424
|
}
|
|
1416
|
-
function
|
|
1425
|
+
function Mr(t, e) {
|
|
1417
1426
|
return se(t.eav, [e]) !== void 0;
|
|
1418
1427
|
}
|
|
1419
1428
|
function yt(t) {
|
|
@@ -1457,12 +1466,12 @@ function _n(t, e) {
|
|
|
1457
1466
|
const [r, s, i] = n, o = re(t.attrs, s);
|
|
1458
1467
|
o && (N(t.eav, [r, s, i]), N(t.aev, [s, r, i]), ht(o) && N(t.vae, [i, s, r]));
|
|
1459
1468
|
}
|
|
1460
|
-
let
|
|
1469
|
+
let Ir = 0;
|
|
1461
1470
|
function gn(t, e, n) {
|
|
1462
1471
|
const [r, s, i] = n;
|
|
1463
1472
|
let o;
|
|
1464
1473
|
const a = se(t.ea, [r, s, i]);
|
|
1465
|
-
return a && (o = a[3]), o || Date.now() * 10 +
|
|
1474
|
+
return a && (o = a[3]), o || Date.now() * 10 + Ir++;
|
|
1466
1475
|
}
|
|
1467
1476
|
function wn(t, e) {
|
|
1468
1477
|
const n = ye(t, e);
|
|
@@ -1474,9 +1483,9 @@ function wn(t, e) {
|
|
|
1474
1483
|
return;
|
|
1475
1484
|
o["checked-data-type"] === "date" && t.useDateObjects && (i = Me(i));
|
|
1476
1485
|
const a = se(t.eav, [r, s, i]), c = (a == null ? void 0 : a[3]) ?? gn(t, o, n), u = [r, s, i, c];
|
|
1477
|
-
|
|
1486
|
+
Cr(o) ? (D(t.eav, [r, s], /* @__PURE__ */ new Map([[i, u]])), D(t.aev, [s, r], /* @__PURE__ */ new Map([[i, u]]))) : (D(t.eav, [r, s, i], u), D(t.aev, [s, r, i], u)), ht(o) && D(t.vae, [i, s, r], u);
|
|
1478
1487
|
}
|
|
1479
|
-
function
|
|
1488
|
+
function Pr(t, e) {
|
|
1480
1489
|
var d;
|
|
1481
1490
|
const n = ye(t, e);
|
|
1482
1491
|
if (!n)
|
|
@@ -1536,29 +1545,29 @@ function Tn(t, e) {
|
|
|
1536
1545
|
t[r] = n[r];
|
|
1537
1546
|
});
|
|
1538
1547
|
}
|
|
1539
|
-
function
|
|
1548
|
+
function jr(t, [e]) {
|
|
1540
1549
|
t.attrs[e.id] = e, yt(t);
|
|
1541
1550
|
}
|
|
1542
1551
|
function mn(t) {
|
|
1543
1552
|
return R(t.eav, 3);
|
|
1544
1553
|
}
|
|
1545
|
-
function
|
|
1554
|
+
function $r(t, [e]) {
|
|
1546
1555
|
if (!t.attrs[e]) return;
|
|
1547
1556
|
const n = mn(t).filter(([r, s]) => s !== e);
|
|
1548
1557
|
delete t.attrs[e], yt(t), Tn(t, n);
|
|
1549
1558
|
}
|
|
1550
|
-
function
|
|
1559
|
+
function Dr(t, [e]) {
|
|
1551
1560
|
const n = t.attrs[e.id];
|
|
1552
1561
|
n && (t.attrs[e.id] = { ...n, ...e }, yt(t), Tn(t, mn(t)));
|
|
1553
1562
|
}
|
|
1554
|
-
function
|
|
1563
|
+
function Rr(t, e) {
|
|
1555
1564
|
const [n, ...r] = e;
|
|
1556
1565
|
switch (n) {
|
|
1557
1566
|
case "add-triple":
|
|
1558
1567
|
wn(t, r);
|
|
1559
1568
|
break;
|
|
1560
1569
|
case "deep-merge-triple":
|
|
1561
|
-
|
|
1570
|
+
Pr(t, r);
|
|
1562
1571
|
break;
|
|
1563
1572
|
case "retract-triple":
|
|
1564
1573
|
_n(t, r);
|
|
@@ -1567,13 +1576,13 @@ function Dr(t, e) {
|
|
|
1567
1576
|
Ge(t, r);
|
|
1568
1577
|
break;
|
|
1569
1578
|
case "add-attr":
|
|
1570
|
-
|
|
1579
|
+
jr(t, r);
|
|
1571
1580
|
break;
|
|
1572
1581
|
case "delete-attr":
|
|
1573
|
-
|
|
1582
|
+
$r(t, r);
|
|
1574
1583
|
break;
|
|
1575
1584
|
case "update-attr":
|
|
1576
|
-
|
|
1585
|
+
Dr(t, r);
|
|
1577
1586
|
break;
|
|
1578
1587
|
case "restore-attr":
|
|
1579
1588
|
break;
|
|
@@ -1628,13 +1637,13 @@ function be(t, e, n) {
|
|
|
1628
1637
|
}
|
|
1629
1638
|
return r;
|
|
1630
1639
|
}
|
|
1631
|
-
function
|
|
1640
|
+
function xr(t, e, n) {
|
|
1632
1641
|
let r = "";
|
|
1633
1642
|
return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
|
|
1634
1643
|
}
|
|
1635
|
-
function
|
|
1644
|
+
function Ur(t, [e, n, r]) {
|
|
1636
1645
|
var i, o;
|
|
1637
|
-
switch (
|
|
1646
|
+
switch (xr(e, n, r)) {
|
|
1638
1647
|
case "e": {
|
|
1639
1648
|
const a = t.eav.get(e);
|
|
1640
1649
|
return R(a, 2);
|
|
@@ -1680,7 +1689,7 @@ function xr(t, [e, n, r]) {
|
|
|
1680
1689
|
return R(t.eav, 3);
|
|
1681
1690
|
}
|
|
1682
1691
|
}
|
|
1683
|
-
function
|
|
1692
|
+
function Lr(t, e, n) {
|
|
1684
1693
|
var s;
|
|
1685
1694
|
const r = {};
|
|
1686
1695
|
for (const [i, o] of e.entries()) {
|
|
@@ -1698,7 +1707,7 @@ function Sn(t, e, n) {
|
|
|
1698
1707
|
var r;
|
|
1699
1708
|
return (r = t.attrIndexes.revIdents.get(e)) == null ? void 0 : r.get(n);
|
|
1700
1709
|
}
|
|
1701
|
-
function
|
|
1710
|
+
function Fr(t, e) {
|
|
1702
1711
|
return t.attrIndexes.blobAttrs.get(e);
|
|
1703
1712
|
}
|
|
1704
1713
|
function On(t, e) {
|
|
@@ -1706,7 +1715,7 @@ function On(t, e) {
|
|
|
1706
1715
|
const n = t.attrIndexes.primaryKeys.get(e);
|
|
1707
1716
|
return n || ((r = t.attrIndexes.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
|
|
1708
1717
|
}
|
|
1709
|
-
function
|
|
1718
|
+
function Nr(t, e) {
|
|
1710
1719
|
const n = ye(t, e);
|
|
1711
1720
|
if (!n)
|
|
1712
1721
|
return;
|
|
@@ -1714,7 +1723,7 @@ function Fr(t, e) {
|
|
|
1714
1723
|
if (re(t.attrs, s))
|
|
1715
1724
|
return se(t.eav, [r, s]);
|
|
1716
1725
|
}
|
|
1717
|
-
function
|
|
1726
|
+
function Kr(t, e) {
|
|
1718
1727
|
const n = e.filter(
|
|
1719
1728
|
([r, s, i, o, a]) => {
|
|
1720
1729
|
if (r !== "add-triple" && r !== "deep-merge-triple")
|
|
@@ -1726,21 +1735,21 @@ function Nr(t, e) {
|
|
|
1726
1735
|
const l = re(t.attrs, i);
|
|
1727
1736
|
if (l) {
|
|
1728
1737
|
const f = On(t, l["forward-identity"][1]);
|
|
1729
|
-
u = !!
|
|
1738
|
+
u = !!Nr(t, [s, f.id, s]);
|
|
1730
1739
|
}
|
|
1731
1740
|
return !(c === "create" && u || c === "update" && !u);
|
|
1732
1741
|
}
|
|
1733
1742
|
);
|
|
1734
1743
|
return ke(t, (r) => {
|
|
1735
1744
|
n.forEach((s) => {
|
|
1736
|
-
|
|
1745
|
+
Rr(r, s);
|
|
1737
1746
|
});
|
|
1738
1747
|
});
|
|
1739
1748
|
}
|
|
1740
|
-
function
|
|
1749
|
+
function qr(t) {
|
|
1741
1750
|
return typeof t == "string" && t.startsWith("?");
|
|
1742
1751
|
}
|
|
1743
|
-
function
|
|
1752
|
+
function zr(t, e, n) {
|
|
1744
1753
|
if (n.hasOwnProperty(t)) {
|
|
1745
1754
|
const r = n[t];
|
|
1746
1755
|
return An(r, e, n);
|
|
@@ -1750,15 +1759,15 @@ function qr(t, e, n) {
|
|
|
1750
1759
|
function Mt(t, e, n) {
|
|
1751
1760
|
return t === e ? n : null;
|
|
1752
1761
|
}
|
|
1753
|
-
function
|
|
1762
|
+
function Vr(t) {
|
|
1754
1763
|
switch (typeof t) {
|
|
1755
1764
|
case "string":
|
|
1756
|
-
return t.startsWith("?") ?
|
|
1765
|
+
return t.startsWith("?") ? zr : Mt;
|
|
1757
1766
|
default:
|
|
1758
1767
|
return Mt;
|
|
1759
1768
|
}
|
|
1760
1769
|
}
|
|
1761
|
-
const
|
|
1770
|
+
const Wr = [
|
|
1762
1771
|
"in",
|
|
1763
1772
|
"$in",
|
|
1764
1773
|
"$not",
|
|
@@ -1766,69 +1775,69 @@ const Vr = [
|
|
|
1766
1775
|
"$comparator"
|
|
1767
1776
|
// covers all of $gt, $lt, etc.
|
|
1768
1777
|
];
|
|
1769
|
-
function
|
|
1770
|
-
for (const e of
|
|
1778
|
+
function Qr(t) {
|
|
1779
|
+
for (const e of Wr)
|
|
1771
1780
|
if (t.hasOwnProperty(e))
|
|
1772
1781
|
return !0;
|
|
1773
1782
|
return !1;
|
|
1774
1783
|
}
|
|
1775
1784
|
function An(t, e, n) {
|
|
1776
|
-
return n ? typeof t == "object" ?
|
|
1785
|
+
return n ? typeof t == "object" ? Qr(t) ? n : null : Vr(t)(t, e, n) : null;
|
|
1777
1786
|
}
|
|
1778
|
-
function
|
|
1787
|
+
function Gr(t, e, n) {
|
|
1779
1788
|
return t.reduce((r, s, i) => {
|
|
1780
1789
|
const o = e[i];
|
|
1781
1790
|
return An(s, o, r);
|
|
1782
1791
|
}, n);
|
|
1783
1792
|
}
|
|
1784
|
-
function Gr(t, e, n) {
|
|
1785
|
-
return Jr(t, e, n).map((r) => Qr(e, r, n)).filter((r) => r);
|
|
1786
|
-
}
|
|
1787
1793
|
function Br(t, e, n) {
|
|
1788
|
-
return
|
|
1794
|
+
return Yr(t, e, n).map((r) => Gr(e, r, n)).filter((r) => r);
|
|
1795
|
+
}
|
|
1796
|
+
function Hr(t, e, n) {
|
|
1797
|
+
return e.or ? e.or.patterns.flatMap((r) => Be(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => Be(t, s, r), n) : n.flatMap((r) => Br(t, e, r));
|
|
1789
1798
|
}
|
|
1790
1799
|
function Be(t, e, n = [{}]) {
|
|
1791
|
-
return e.reduce((r, s) =>
|
|
1800
|
+
return e.reduce((r, s) => Hr(t, s, r), n);
|
|
1792
1801
|
}
|
|
1793
1802
|
function bt(t, e) {
|
|
1794
|
-
return Array.isArray(e) ? e.map((n) => bt(t, n)) :
|
|
1803
|
+
return Array.isArray(e) ? e.map((n) => bt(t, n)) : qr(e) ? t[e] : e;
|
|
1795
1804
|
}
|
|
1796
|
-
function
|
|
1805
|
+
function Jr(t, { find: e, where: n }) {
|
|
1797
1806
|
return Be(t, n).map((s) => bt(s, e));
|
|
1798
1807
|
}
|
|
1799
|
-
function
|
|
1800
|
-
return
|
|
1808
|
+
function Yr(t, e, n) {
|
|
1809
|
+
return Ur(t, bt(n, e));
|
|
1801
1810
|
}
|
|
1802
|
-
const
|
|
1811
|
+
const Zr = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
1803
1812
|
function te(t) {
|
|
1804
|
-
return typeof t == "string" &&
|
|
1813
|
+
return typeof t == "string" && Zr.test(t);
|
|
1805
1814
|
}
|
|
1806
1815
|
const E = [];
|
|
1807
1816
|
for (let t = 0; t < 256; ++t)
|
|
1808
1817
|
E.push((t + 256).toString(16).slice(1));
|
|
1809
|
-
function
|
|
1818
|
+
function Xr(t, e = 0) {
|
|
1810
1819
|
return (E[t[e + 0]] + E[t[e + 1]] + E[t[e + 2]] + E[t[e + 3]] + "-" + E[t[e + 4]] + E[t[e + 5]] + "-" + E[t[e + 6]] + E[t[e + 7]] + "-" + E[t[e + 8]] + E[t[e + 9]] + "-" + E[t[e + 10]] + E[t[e + 11]] + E[t[e + 12]] + E[t[e + 13]] + E[t[e + 14]] + E[t[e + 15]]).toLowerCase();
|
|
1811
1820
|
}
|
|
1812
1821
|
let xe;
|
|
1813
|
-
const
|
|
1814
|
-
function
|
|
1822
|
+
const es = new Uint8Array(16);
|
|
1823
|
+
function ts() {
|
|
1815
1824
|
if (!xe) {
|
|
1816
1825
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1817
1826
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1818
1827
|
xe = crypto.getRandomValues.bind(crypto);
|
|
1819
1828
|
}
|
|
1820
|
-
return xe(
|
|
1829
|
+
return xe(es);
|
|
1821
1830
|
}
|
|
1822
|
-
const
|
|
1823
|
-
function
|
|
1831
|
+
const ns = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), It = { randomUUID: ns };
|
|
1832
|
+
function rs(t, e, n) {
|
|
1824
1833
|
var s;
|
|
1825
1834
|
if (It.randomUUID && !t)
|
|
1826
1835
|
return It.randomUUID();
|
|
1827
1836
|
t = t || {};
|
|
1828
|
-
const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ??
|
|
1837
|
+
const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? ts();
|
|
1829
1838
|
if (r.length < 16)
|
|
1830
1839
|
throw new Error("Random bytes length must be >= 16");
|
|
1831
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
1840
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Xr(r);
|
|
1832
1841
|
}
|
|
1833
1842
|
function Pt(t) {
|
|
1834
1843
|
const e = t.replace(/-/g, ""), n = [];
|
|
@@ -1836,24 +1845,24 @@ function Pt(t) {
|
|
|
1836
1845
|
n.push(parseInt(e.substring(r, r + 2), 16));
|
|
1837
1846
|
return n;
|
|
1838
1847
|
}
|
|
1839
|
-
function
|
|
1848
|
+
function ss(t, e) {
|
|
1840
1849
|
for (let n = 0; n < t.length; n++) {
|
|
1841
1850
|
if (t[n] < e[n]) return -1;
|
|
1842
1851
|
if (t[n] > e[n]) return 1;
|
|
1843
1852
|
}
|
|
1844
1853
|
return 0;
|
|
1845
1854
|
}
|
|
1846
|
-
function
|
|
1847
|
-
return
|
|
1855
|
+
function is(t, e) {
|
|
1856
|
+
return ss(Pt(t), Pt(e));
|
|
1848
1857
|
}
|
|
1849
1858
|
function k() {
|
|
1850
|
-
return
|
|
1859
|
+
return rs();
|
|
1851
1860
|
}
|
|
1852
|
-
function
|
|
1861
|
+
function os(t, e) {
|
|
1853
1862
|
return t.localeCompare(e);
|
|
1854
1863
|
}
|
|
1855
|
-
function
|
|
1856
|
-
let t =
|
|
1864
|
+
function as() {
|
|
1865
|
+
let t = os;
|
|
1857
1866
|
if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
|
|
1858
1867
|
try {
|
|
1859
1868
|
t = Intl.Collator("en-US").compare;
|
|
@@ -1861,10 +1870,10 @@ function os() {
|
|
|
1861
1870
|
}
|
|
1862
1871
|
return t;
|
|
1863
1872
|
}
|
|
1864
|
-
const
|
|
1865
|
-
let
|
|
1873
|
+
const cs = as();
|
|
1874
|
+
let us = 0;
|
|
1866
1875
|
function le(t) {
|
|
1867
|
-
return Ie(`_${t}`,
|
|
1876
|
+
return Ie(`_${t}`, us++);
|
|
1868
1877
|
}
|
|
1869
1878
|
function Ie(t, e) {
|
|
1870
1879
|
return `?${t}-${e}`;
|
|
@@ -1874,24 +1883,24 @@ class ne extends Error {
|
|
|
1874
1883
|
super(e), this.name = "AttrNotFoundError";
|
|
1875
1884
|
}
|
|
1876
1885
|
}
|
|
1877
|
-
function
|
|
1886
|
+
function ls(t, e) {
|
|
1878
1887
|
const n = On(t, e);
|
|
1879
1888
|
if (!n)
|
|
1880
1889
|
throw new ne(`Could not find id attr for ${e}`);
|
|
1881
1890
|
return n;
|
|
1882
1891
|
}
|
|
1883
1892
|
function jt(t, e, n, r) {
|
|
1884
|
-
return [
|
|
1893
|
+
return [fs(t, e, n, r)];
|
|
1885
1894
|
}
|
|
1886
|
-
function
|
|
1895
|
+
function fs(t, e, n, r) {
|
|
1887
1896
|
return [
|
|
1888
1897
|
t(n, r),
|
|
1889
|
-
|
|
1898
|
+
ls(e, n).id,
|
|
1890
1899
|
t(n, r),
|
|
1891
1900
|
t("time", r)
|
|
1892
1901
|
];
|
|
1893
1902
|
}
|
|
1894
|
-
function
|
|
1903
|
+
function ds(t, e, n) {
|
|
1895
1904
|
return t.map((r) => r === e ? n : r);
|
|
1896
1905
|
}
|
|
1897
1906
|
function vn(t, e, n, r, s) {
|
|
@@ -1926,7 +1935,7 @@ function $t(t, e) {
|
|
|
1926
1935
|
return typeof o != "string" ? !1 : s.test(o);
|
|
1927
1936
|
};
|
|
1928
1937
|
}
|
|
1929
|
-
function
|
|
1938
|
+
function hs(t, e) {
|
|
1930
1939
|
if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
|
|
1931
1940
|
return e;
|
|
1932
1941
|
const n = t["checked-data-type"] === "date";
|
|
@@ -1986,7 +1995,7 @@ function ds(t, e) {
|
|
|
1986
1995
|
}
|
|
1987
1996
|
return e;
|
|
1988
1997
|
}
|
|
1989
|
-
function
|
|
1998
|
+
function ps(t, e, n, r, s, i) {
|
|
1990
1999
|
const o = G(e, n, s), a = Sn(e, n, s), c = o || a;
|
|
1991
2000
|
if (!c)
|
|
1992
2001
|
throw new ne(
|
|
@@ -2008,11 +2017,11 @@ function hs(t, e, n, r, s, i) {
|
|
|
2008
2017
|
return o ? [
|
|
2009
2018
|
t(n, r),
|
|
2010
2019
|
c.id,
|
|
2011
|
-
|
|
2020
|
+
hs(c, i),
|
|
2012
2021
|
le("time")
|
|
2013
2022
|
] : [i, c.id, t(n, r), le("time")];
|
|
2014
2023
|
}
|
|
2015
|
-
function
|
|
2024
|
+
function ys(t, e, n, r, s) {
|
|
2016
2025
|
const [i, o, a] = s.reduce(
|
|
2017
2026
|
(c, u) => {
|
|
2018
2027
|
const [l, f, d] = c, [h, p, b] = vn(
|
|
@@ -2029,13 +2038,13 @@ function ps(t, e, n, r, s) {
|
|
|
2029
2038
|
return [i, o, a];
|
|
2030
2039
|
}
|
|
2031
2040
|
function He(t, e, n, r, s, i) {
|
|
2032
|
-
const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] =
|
|
2041
|
+
const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = ys(
|
|
2033
2042
|
t,
|
|
2034
2043
|
e,
|
|
2035
2044
|
n,
|
|
2036
2045
|
r,
|
|
2037
2046
|
o
|
|
2038
|
-
), f =
|
|
2047
|
+
), f = ps(
|
|
2039
2048
|
t,
|
|
2040
2049
|
e,
|
|
2041
2050
|
c,
|
|
@@ -2045,16 +2054,16 @@ function He(t, e, n, r, s, i) {
|
|
|
2045
2054
|
);
|
|
2046
2055
|
return l.concat([f]);
|
|
2047
2056
|
}
|
|
2048
|
-
function
|
|
2057
|
+
function bs(t, e) {
|
|
2049
2058
|
return e ? [e].concat(t) : t;
|
|
2050
2059
|
}
|
|
2051
|
-
function
|
|
2060
|
+
function _s([t, e]) {
|
|
2052
2061
|
return t === "or" && Array.isArray(e);
|
|
2053
2062
|
}
|
|
2054
|
-
function
|
|
2063
|
+
function gs([t, e]) {
|
|
2055
2064
|
return t === "and" && Array.isArray(e);
|
|
2056
2065
|
}
|
|
2057
|
-
function
|
|
2066
|
+
function ws(t, e, n) {
|
|
2058
2067
|
return (r, s) => {
|
|
2059
2068
|
const i = t(r, s);
|
|
2060
2069
|
return e == i ? i : `${i}-${n}`;
|
|
@@ -2062,27 +2071,27 @@ function gs(t, e, n) {
|
|
|
2062
2071
|
}
|
|
2063
2072
|
function Dt(t, e, n, r, s, i) {
|
|
2064
2073
|
const o = t(r, s), a = i.map((c, u) => {
|
|
2065
|
-
const l =
|
|
2074
|
+
const l = ws(t, o, u);
|
|
2066
2075
|
return kn(l, n, r, s, c);
|
|
2067
2076
|
});
|
|
2068
2077
|
return { [e]: { patterns: a, joinSym: o } };
|
|
2069
2078
|
}
|
|
2070
|
-
function
|
|
2079
|
+
function Ts(t) {
|
|
2071
2080
|
const e = [];
|
|
2072
2081
|
for (let n = 1; n <= t.length; n++)
|
|
2073
2082
|
e.push(t.slice(0, n));
|
|
2074
2083
|
return e;
|
|
2075
2084
|
}
|
|
2076
2085
|
function Rt(t, e, n, r, s) {
|
|
2077
|
-
return
|
|
2086
|
+
return Ts(s).map(
|
|
2078
2087
|
(i) => He(t, e, n, r, i, { $isNull: !0 })
|
|
2079
2088
|
);
|
|
2080
2089
|
}
|
|
2081
2090
|
function kn(t, e, n, r, s) {
|
|
2082
2091
|
return Object.entries(s).flatMap(([i, o]) => {
|
|
2083
|
-
if (bs([i, o]))
|
|
2084
|
-
return Dt(t, "or", e, n, r, o);
|
|
2085
2092
|
if (_s([i, o]))
|
|
2093
|
+
return Dt(t, "or", e, n, r, o);
|
|
2094
|
+
if (gs([i, o]))
|
|
2086
2095
|
return Dt(t, "and", e, n, r, o);
|
|
2087
2096
|
if (i === "$entityIdStartsWith")
|
|
2088
2097
|
return [];
|
|
@@ -2120,31 +2129,31 @@ function kn(t, e, n, r, s) {
|
|
|
2120
2129
|
] : He(t, e, n, r, a, o);
|
|
2121
2130
|
});
|
|
2122
2131
|
}
|
|
2123
|
-
function
|
|
2132
|
+
function ms(t, e, n, r) {
|
|
2124
2133
|
const s = Ie;
|
|
2125
2134
|
return r ? kn(s, t, e, n, r).concat(jt(s, t, e, n)) : jt(s, t, e, n);
|
|
2126
2135
|
}
|
|
2127
|
-
function
|
|
2136
|
+
function Ss(t, e, n) {
|
|
2128
2137
|
return [t(e, n), t("time", n)];
|
|
2129
2138
|
}
|
|
2130
|
-
function
|
|
2139
|
+
function Os(t, e, n, r, s, i) {
|
|
2131
2140
|
const [o, a, c, u, l] = vn(
|
|
2132
2141
|
t,
|
|
2133
2142
|
e,
|
|
2134
2143
|
n,
|
|
2135
2144
|
r,
|
|
2136
2145
|
s
|
|
2137
|
-
), f =
|
|
2146
|
+
), f = ds(c, t(n, r), i);
|
|
2138
2147
|
return [o, a, f, u, l];
|
|
2139
2148
|
}
|
|
2140
|
-
function
|
|
2149
|
+
function As(t, e, { etype: n, level: r, form: s }, i) {
|
|
2141
2150
|
const o = Object.keys(s).filter((a) => a !== "$");
|
|
2142
2151
|
return o.length ? Object.entries(i).map(function([c, u]) {
|
|
2143
2152
|
return o.map(function(d) {
|
|
2144
2153
|
var p, b, _;
|
|
2145
2154
|
const h = !!(e.cardinalityInference && ((_ = (b = (p = e.linkIndex) == null ? void 0 : p[n]) == null ? void 0 : b[d]) != null && _.isSingular));
|
|
2146
2155
|
try {
|
|
2147
|
-
const [y, g, T] =
|
|
2156
|
+
const [y, g, T] = Os(
|
|
2148
2157
|
t,
|
|
2149
2158
|
e,
|
|
2150
2159
|
n,
|
|
@@ -2168,11 +2177,11 @@ function Os(t, e, { etype: n, level: r, form: s }, i) {
|
|
|
2168
2177
|
}, u);
|
|
2169
2178
|
}) : Object.values(i);
|
|
2170
2179
|
}
|
|
2171
|
-
function
|
|
2172
|
-
return n === "string" ?
|
|
2180
|
+
function vs(t, e, n) {
|
|
2181
|
+
return n === "string" ? cs(t, e) : t > e ? 1 : -1;
|
|
2173
2182
|
}
|
|
2174
2183
|
function ce(t, e, n, r, s) {
|
|
2175
|
-
return e === r || e == null && r == null ?
|
|
2184
|
+
return e === r || e == null && r == null ? is(t, n) : r == null ? 1 : e == null ? -1 : vs(e, r, s);
|
|
2176
2185
|
}
|
|
2177
2186
|
function Ee([t, e], [n, r], s) {
|
|
2178
2187
|
return ce(t, e, n, r, s);
|
|
@@ -2180,7 +2189,7 @@ function Ee([t, e], [n, r], s) {
|
|
|
2180
2189
|
function Je(t) {
|
|
2181
2190
|
return t == null ? t : new Date(t).getTime();
|
|
2182
2191
|
}
|
|
2183
|
-
function
|
|
2192
|
+
function ks(t, e, n, r) {
|
|
2184
2193
|
var p;
|
|
2185
2194
|
const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
|
|
2186
2195
|
if (((p = e["forward-identity"]) == null ? void 0 : p[2]) === "id")
|
|
@@ -2188,24 +2197,24 @@ function vs(t, e, n, r) {
|
|
|
2188
2197
|
const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? Je(l) : l, h = f === "date" ? Je(o) : o;
|
|
2189
2198
|
return Ee([u, d], [s, h], f) === c;
|
|
2190
2199
|
}
|
|
2191
|
-
function
|
|
2200
|
+
function Es(t, e) {
|
|
2192
2201
|
const n = e[1];
|
|
2193
2202
|
return t.attrs[n];
|
|
2194
2203
|
}
|
|
2195
|
-
function
|
|
2204
|
+
function Cs(t, e, n) {
|
|
2196
2205
|
const r = Object.keys(n)[0];
|
|
2197
2206
|
return G(t, e, r);
|
|
2198
2207
|
}
|
|
2199
|
-
function
|
|
2208
|
+
function Ms(t, e, n, r) {
|
|
2200
2209
|
if (n)
|
|
2201
|
-
return
|
|
2210
|
+
return Es(t, n);
|
|
2202
2211
|
if (r)
|
|
2203
|
-
return
|
|
2212
|
+
return Cs(t, e, r);
|
|
2204
2213
|
}
|
|
2205
|
-
function
|
|
2214
|
+
function Is(t, e, n) {
|
|
2206
2215
|
var s, i;
|
|
2207
2216
|
if (!Array.isArray(n.fields))
|
|
2208
|
-
return
|
|
2217
|
+
return Fr(t, e);
|
|
2209
2218
|
const r = /* @__PURE__ */ new Map();
|
|
2210
2219
|
for (const o of n.fields) {
|
|
2211
2220
|
const a = G(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
|
|
@@ -2217,11 +2226,11 @@ function Ms(t, e, n) {
|
|
|
2217
2226
|
}
|
|
2218
2227
|
return r;
|
|
2219
2228
|
}
|
|
2220
|
-
function
|
|
2229
|
+
function Ps(t, { etype: e, pageInfo: n, dq: r, form: s }) {
|
|
2221
2230
|
var h, p;
|
|
2222
|
-
const i = (h = s == null ? void 0 : s.$) == null ? void 0 : h.order, o = En(s), a =
|
|
2223
|
-
let c =
|
|
2224
|
-
const u = n == null ? void 0 : n["start-cursor"], l =
|
|
2231
|
+
const i = (h = s == null ? void 0 : s.$) == null ? void 0 : h.order, o = En(s), a = js(s);
|
|
2232
|
+
let c = Jr(t, r);
|
|
2233
|
+
const u = n == null ? void 0 : n["start-cursor"], l = Ms(t, e, u, i);
|
|
2225
2234
|
if (l && ((p = l == null ? void 0 : l["forward-identity"]) == null ? void 0 : p[2]) !== "id") {
|
|
2226
2235
|
const b = l["checked-data-type"] === "date", _ = l.id;
|
|
2227
2236
|
c = c.map(([y]) => {
|
|
@@ -2238,17 +2247,17 @@ function Is(t, { etype: e, pageInfo: n, dq: r, form: s }) {
|
|
|
2238
2247
|
}
|
|
2239
2248
|
);
|
|
2240
2249
|
let f = {};
|
|
2241
|
-
const d =
|
|
2250
|
+
const d = Is(t, e, r);
|
|
2242
2251
|
for (const b of c) {
|
|
2243
2252
|
const [_] = b;
|
|
2244
|
-
if (f[_] || !o && u && l &&
|
|
2253
|
+
if (f[_] || !o && u && l && ks(u, l, a, b))
|
|
2245
2254
|
continue;
|
|
2246
|
-
const y =
|
|
2255
|
+
const y = Lr(t, d, _);
|
|
2247
2256
|
y && (f[_] = y);
|
|
2248
2257
|
}
|
|
2249
2258
|
return f;
|
|
2250
2259
|
}
|
|
2251
|
-
function
|
|
2260
|
+
function js(t) {
|
|
2252
2261
|
var n;
|
|
2253
2262
|
const e = (n = t.$) == null ? void 0 : n.order;
|
|
2254
2263
|
return e && e[Object.keys(e)[0]] || "asc";
|
|
@@ -2258,11 +2267,11 @@ function En(t) {
|
|
|
2258
2267
|
const e = (s = t.$) == null ? void 0 : s.offset, n = (i = t.$) == null ? void 0 : i.before, r = (o = t.$) == null ? void 0 : o.after;
|
|
2259
2268
|
return !e && !n && !r;
|
|
2260
2269
|
}
|
|
2261
|
-
function
|
|
2270
|
+
function $s(t, { etype: e, level: n, form: r, join: s, pageInfo: i }) {
|
|
2262
2271
|
var f, d, h, p, b;
|
|
2263
2272
|
if (!En(r) && (!i || !i["start-cursor"]))
|
|
2264
2273
|
return [];
|
|
2265
|
-
const o =
|
|
2274
|
+
const o = bs(ms(t, e, n, (f = r.$) == null ? void 0 : f.where), s), a = Ss(Ie, e, n), c = (d = r.$) == null ? void 0 : d.fields, u = Ps(t, {
|
|
2266
2275
|
etype: e,
|
|
2267
2276
|
pageInfo: i,
|
|
2268
2277
|
form: r,
|
|
@@ -2277,9 +2286,9 @@ function js(t, { etype: e, level: n, form: r, join: s, pageInfo: i }) {
|
|
|
2277
2286
|
}
|
|
2278
2287
|
return u;
|
|
2279
2288
|
}
|
|
2280
|
-
function
|
|
2289
|
+
function Ds(t, e) {
|
|
2281
2290
|
try {
|
|
2282
|
-
return
|
|
2291
|
+
return $s(t, e);
|
|
2283
2292
|
} catch (n) {
|
|
2284
2293
|
if (n instanceof ne)
|
|
2285
2294
|
return {};
|
|
@@ -2287,10 +2296,10 @@ function $s(t, e) {
|
|
|
2287
2296
|
}
|
|
2288
2297
|
}
|
|
2289
2298
|
function Cn(t, e) {
|
|
2290
|
-
const n =
|
|
2291
|
-
return
|
|
2299
|
+
const n = Ds(t, e);
|
|
2300
|
+
return As(Ie, t, e, n);
|
|
2292
2301
|
}
|
|
2293
|
-
function
|
|
2302
|
+
function Rs(t) {
|
|
2294
2303
|
const e = {};
|
|
2295
2304
|
for (const [n, r] of Object.entries(t))
|
|
2296
2305
|
e[n] = {
|
|
@@ -2310,9 +2319,9 @@ function Mn({ store: t, pageInfo: e, aggregate: n }, r) {
|
|
|
2310
2319
|
pageInfo: e == null ? void 0 : e[c]
|
|
2311
2320
|
})), a;
|
|
2312
2321
|
}, {}) };
|
|
2313
|
-
return e && (i.pageInfo =
|
|
2322
|
+
return e && (i.pageInfo = Rs(e)), n && (i.aggregate = n), i;
|
|
2314
2323
|
}
|
|
2315
|
-
function
|
|
2324
|
+
function xs() {
|
|
2316
2325
|
const e = {
|
|
2317
2326
|
__etype: 1,
|
|
2318
2327
|
__ops: 1,
|
|
@@ -2326,7 +2335,7 @@ function Rs() {
|
|
|
2326
2335
|
};
|
|
2327
2336
|
return new Set(Object.keys(e));
|
|
2328
2337
|
}
|
|
2329
|
-
const
|
|
2338
|
+
const Us = xs();
|
|
2330
2339
|
function Ye(t, e, n) {
|
|
2331
2340
|
const r = {
|
|
2332
2341
|
__etype: t,
|
|
@@ -2336,7 +2345,7 @@ function Ye(t, e, n) {
|
|
|
2336
2345
|
get: (s, i) => {
|
|
2337
2346
|
if (i === "__ops") return n;
|
|
2338
2347
|
if (i === "__etype") return t;
|
|
2339
|
-
if (
|
|
2348
|
+
if (Us.has(i))
|
|
2340
2349
|
return (o, a) => Ye(t, e, [
|
|
2341
2350
|
...n,
|
|
2342
2351
|
a ? [i, t, e, o, a] : [i, t, e, o]
|
|
@@ -2344,7 +2353,7 @@ function Ye(t, e, n) {
|
|
|
2344
2353
|
}
|
|
2345
2354
|
});
|
|
2346
2355
|
}
|
|
2347
|
-
function
|
|
2356
|
+
function Ro(t, e) {
|
|
2348
2357
|
return `lookup__${t}__${JSON.stringify(e)}`;
|
|
2349
2358
|
}
|
|
2350
2359
|
function Ce(t) {
|
|
@@ -2354,7 +2363,7 @@ function In(t) {
|
|
|
2354
2363
|
const [e, n, ...r] = t.split("__");
|
|
2355
2364
|
return [n, JSON.parse(r.join("__"))];
|
|
2356
2365
|
}
|
|
2357
|
-
function
|
|
2366
|
+
function Ls(t) {
|
|
2358
2367
|
return new Proxy(
|
|
2359
2368
|
{
|
|
2360
2369
|
__etype: t
|
|
@@ -2373,16 +2382,16 @@ function Pn() {
|
|
|
2373
2382
|
{},
|
|
2374
2383
|
{
|
|
2375
2384
|
get(t, e) {
|
|
2376
|
-
return
|
|
2385
|
+
return Ls(e);
|
|
2377
2386
|
}
|
|
2378
2387
|
}
|
|
2379
2388
|
);
|
|
2380
2389
|
}
|
|
2381
|
-
const
|
|
2382
|
-
function
|
|
2390
|
+
const xo = Pn();
|
|
2391
|
+
function Fs(t) {
|
|
2383
2392
|
return t.__ops;
|
|
2384
2393
|
}
|
|
2385
|
-
function
|
|
2394
|
+
function Ns(t, e) {
|
|
2386
2395
|
const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
|
|
2387
2396
|
for (const o of e) {
|
|
2388
2397
|
const a = n[o];
|
|
@@ -2415,7 +2424,7 @@ function J(t, e, n) {
|
|
|
2415
2424
|
return o === e && a === n;
|
|
2416
2425
|
});
|
|
2417
2426
|
}
|
|
2418
|
-
function
|
|
2427
|
+
function Ks(t) {
|
|
2419
2428
|
if (Array.isArray(t))
|
|
2420
2429
|
return t;
|
|
2421
2430
|
const e = Object.entries(t);
|
|
@@ -2436,7 +2445,7 @@ function Xe(t) {
|
|
|
2436
2445
|
throw new Error(`${t} is not a valid lookup attribute.`);
|
|
2437
2446
|
return e;
|
|
2438
2447
|
}
|
|
2439
|
-
function
|
|
2448
|
+
function qs(t, e, n) {
|
|
2440
2449
|
if (!Ze(t, e, n))
|
|
2441
2450
|
return C(t, e, n);
|
|
2442
2451
|
const r = Xe(n), s = C(t, e, r) || J(t, e, r);
|
|
@@ -2445,13 +2454,13 @@ function Ks(t, e, n) {
|
|
|
2445
2454
|
return s;
|
|
2446
2455
|
}
|
|
2447
2456
|
function et(t) {
|
|
2448
|
-
return typeof t == "string" && !Ce(t) ? null : typeof t == "string" && Ce(t) ? In(t) :
|
|
2457
|
+
return typeof t == "string" && !Ce(t) ? null : typeof t == "string" && Ce(t) ? In(t) : Ks(t);
|
|
2449
2458
|
}
|
|
2450
2459
|
function x(t, e, n) {
|
|
2451
2460
|
const r = et(n);
|
|
2452
2461
|
if (r === null)
|
|
2453
2462
|
return n;
|
|
2454
|
-
const [s, i] = r, o =
|
|
2463
|
+
const [s, i] = r, o = qs(t, e, s);
|
|
2455
2464
|
if (!o || !o["unique?"])
|
|
2456
2465
|
throw new Error(`${s} is not a unique attribute.`);
|
|
2457
2466
|
return [o.id, i];
|
|
@@ -2465,7 +2474,7 @@ function jn(t, e, n, r) {
|
|
|
2465
2474
|
s
|
|
2466
2475
|
]].concat(r) : r;
|
|
2467
2476
|
}
|
|
2468
|
-
function
|
|
2477
|
+
function zs({ attrs: t }, [e, n, r]) {
|
|
2469
2478
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2470
2479
|
const a = Array.isArray(o) ? o : [o], c = C(t, e, i), u = J(t, e, i);
|
|
2471
2480
|
return a.map((l) => c ? [
|
|
@@ -2482,7 +2491,7 @@ function qs({ attrs: t }, [e, n, r]) {
|
|
|
2482
2491
|
});
|
|
2483
2492
|
return jn(t, e, n, s);
|
|
2484
2493
|
}
|
|
2485
|
-
function
|
|
2494
|
+
function Vs({ attrs: t }, [e, n, r]) {
|
|
2486
2495
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2487
2496
|
const a = Array.isArray(o) ? o : [o], c = C(t, e, i), u = J(t, e, i);
|
|
2488
2497
|
return a.map((l) => c ? [
|
|
@@ -2499,7 +2508,7 @@ function zs({ attrs: t }, [e, n, r]) {
|
|
|
2499
2508
|
});
|
|
2500
2509
|
return jn(t, e, n, s);
|
|
2501
2510
|
}
|
|
2502
|
-
function
|
|
2511
|
+
function Ws(t, e, n) {
|
|
2503
2512
|
if (Array.isArray(n)) {
|
|
2504
2513
|
const [r, s] = n;
|
|
2505
2514
|
for (const i of t || []) {
|
|
@@ -2522,16 +2531,16 @@ function Vs(t, e, n) {
|
|
|
2522
2531
|
return !1;
|
|
2523
2532
|
}
|
|
2524
2533
|
function $n({ stores: t, attrs: e }, [n, r, s, i]) {
|
|
2525
|
-
return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null :
|
|
2534
|
+
return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Ws(t, n, r) ? { mode: "update" } : null;
|
|
2526
2535
|
}
|
|
2527
|
-
function
|
|
2536
|
+
function Qs(t, e) {
|
|
2528
2537
|
const { attrs: n } = t, [r, s, i, o] = e, a = dt(i), c = x(n, r, s);
|
|
2529
2538
|
return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
|
|
2530
2539
|
const d = C(n, r, l);
|
|
2531
2540
|
return d["checked-data-type"] === "date" && t.useDateObjects && (f = Me(f)), ["add-triple", c, d.id, f, { mode: "create" }];
|
|
2532
2541
|
});
|
|
2533
2542
|
}
|
|
2534
|
-
function
|
|
2543
|
+
function Gs(t, e) {
|
|
2535
2544
|
const { attrs: n } = t, [r, s, i, o] = e, a = dt(i), c = x(n, r, s), u = $n(t, [r, c, i, o]);
|
|
2536
2545
|
return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
|
|
2537
2546
|
const h = C(n, r, f);
|
|
@@ -2544,10 +2553,10 @@ function Qs(t, e) {
|
|
|
2544
2553
|
];
|
|
2545
2554
|
});
|
|
2546
2555
|
}
|
|
2547
|
-
function
|
|
2556
|
+
function Bs({ attrs: t }, [e, n]) {
|
|
2548
2557
|
return [["delete-entity", x(t, e, n), e]];
|
|
2549
2558
|
}
|
|
2550
|
-
function
|
|
2559
|
+
function Hs(t, e) {
|
|
2551
2560
|
const { attrs: n } = t, [r, s, i, o] = e, a = dt(i), c = x(n, r, s), u = $n(t, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
|
|
2552
2561
|
const p = C(n, r, d);
|
|
2553
2562
|
return [
|
|
@@ -2566,38 +2575,38 @@ function Bs(t, e) {
|
|
|
2566
2575
|
...u ? [u] : []
|
|
2567
2576
|
]].concat(l);
|
|
2568
2577
|
}
|
|
2569
|
-
function
|
|
2578
|
+
function Js({ attrs: t }, [e, n, r]) {
|
|
2570
2579
|
return [["rule-params", x(t, e, n), e, r]];
|
|
2571
2580
|
}
|
|
2572
|
-
function
|
|
2581
|
+
function Ys(t) {
|
|
2573
2582
|
const [e, n, r, s, i] = t;
|
|
2574
2583
|
if (!s)
|
|
2575
2584
|
return t;
|
|
2576
2585
|
const o = { ...s };
|
|
2577
2586
|
return delete o.id, [e, n, r, o, ...i ? [i] : []];
|
|
2578
2587
|
}
|
|
2579
|
-
function
|
|
2580
|
-
const [n, ...r] =
|
|
2588
|
+
function Zs(t, e) {
|
|
2589
|
+
const [n, ...r] = Ys(e);
|
|
2581
2590
|
switch (n) {
|
|
2582
2591
|
case "merge":
|
|
2583
|
-
return
|
|
2592
|
+
return Hs(t, r);
|
|
2584
2593
|
case "create":
|
|
2585
|
-
return Ws(t, r);
|
|
2586
|
-
case "update":
|
|
2587
2594
|
return Qs(t, r);
|
|
2595
|
+
case "update":
|
|
2596
|
+
return Gs(t, r);
|
|
2588
2597
|
case "link":
|
|
2589
|
-
return qs(t, r);
|
|
2590
|
-
case "unlink":
|
|
2591
2598
|
return zs(t, r);
|
|
2599
|
+
case "unlink":
|
|
2600
|
+
return Vs(t, r);
|
|
2592
2601
|
case "delete":
|
|
2593
|
-
return
|
|
2602
|
+
return Bs(t, r);
|
|
2594
2603
|
case "ruleParams":
|
|
2595
|
-
return
|
|
2604
|
+
return Js(t, r);
|
|
2596
2605
|
default:
|
|
2597
2606
|
throw new Error(`unsupported action ${n}`);
|
|
2598
2607
|
}
|
|
2599
2608
|
}
|
|
2600
|
-
function
|
|
2609
|
+
function Xs(t) {
|
|
2601
2610
|
switch (t) {
|
|
2602
2611
|
case "string":
|
|
2603
2612
|
case "date":
|
|
@@ -2608,13 +2617,13 @@ function Zs(t) {
|
|
|
2608
2617
|
return;
|
|
2609
2618
|
}
|
|
2610
2619
|
}
|
|
2611
|
-
function
|
|
2620
|
+
function ei(t, e, n) {
|
|
2612
2621
|
var a, c;
|
|
2613
2622
|
const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
|
|
2614
2623
|
if (n === "id") return null;
|
|
2615
2624
|
if (!r)
|
|
2616
2625
|
throw new Error(`${e}.${n} does not exist in your schema`);
|
|
2617
|
-
const { unique: s, indexed: i } = r == null ? void 0 : r.config, o =
|
|
2626
|
+
const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Xs(r == null ? void 0 : r.valueType);
|
|
2618
2627
|
return {
|
|
2619
2628
|
"index?": i,
|
|
2620
2629
|
"unique?": s,
|
|
@@ -2622,7 +2631,7 @@ function Xs(t, e, n) {
|
|
|
2622
2631
|
};
|
|
2623
2632
|
}
|
|
2624
2633
|
function _e(t, e, n, r) {
|
|
2625
|
-
const s = t ?
|
|
2634
|
+
const s = t ? ei(t, e, n) : null, i = k(), a = [k(), e, n];
|
|
2626
2635
|
return {
|
|
2627
2636
|
id: i,
|
|
2628
2637
|
"forward-identity": a,
|
|
@@ -2635,11 +2644,11 @@ function _e(t, e, n, r) {
|
|
|
2635
2644
|
...r || {}
|
|
2636
2645
|
};
|
|
2637
2646
|
}
|
|
2638
|
-
function
|
|
2647
|
+
function ti(t, e, n) {
|
|
2639
2648
|
return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
|
|
2640
2649
|
}
|
|
2641
|
-
function
|
|
2642
|
-
const r =
|
|
2650
|
+
function ni(t, e, n) {
|
|
2651
|
+
const r = ti(t, e, n);
|
|
2643
2652
|
if (!r)
|
|
2644
2653
|
throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
|
|
2645
2654
|
const { forward: s, reverse: i } = r;
|
|
@@ -2653,7 +2662,7 @@ function ti(t, e, n) {
|
|
|
2653
2662
|
};
|
|
2654
2663
|
}
|
|
2655
2664
|
function xt(t, e, n, r) {
|
|
2656
|
-
const s = t ?
|
|
2665
|
+
const s = t ? ni(t, e, n) : null, i = k(), o = [k(), e, n], a = [k(), n, e];
|
|
2657
2666
|
return {
|
|
2658
2667
|
id: i,
|
|
2659
2668
|
"forward-identity": o,
|
|
@@ -2667,7 +2676,7 @@ function xt(t, e, n, r) {
|
|
|
2667
2676
|
...r || {}
|
|
2668
2677
|
};
|
|
2669
2678
|
}
|
|
2670
|
-
const
|
|
2679
|
+
const ri = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), si = /* @__PURE__ */ new Set(["link", "unlink"]), ii = /* @__PURE__ */ new Set(["create", "update", "merge"]), oi = /* @__PURE__ */ new Set([
|
|
2671
2680
|
"link",
|
|
2672
2681
|
"unlink",
|
|
2673
2682
|
"create",
|
|
@@ -2675,10 +2684,10 @@ const ni = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
|
|
|
2675
2684
|
"merge",
|
|
2676
2685
|
"delete",
|
|
2677
2686
|
"ruleParams"
|
|
2678
|
-
]), tt = { "unique?": !0, "index?": !0 },
|
|
2679
|
-
function
|
|
2687
|
+
]), tt = { "unique?": !0, "index?": !0 }, ai = { ...tt, cardinality: "one" };
|
|
2688
|
+
function ci(t) {
|
|
2680
2689
|
const e = [], [n, r, s, i] = t;
|
|
2681
|
-
if (!
|
|
2690
|
+
if (!oi.has(n))
|
|
2682
2691
|
return e;
|
|
2683
2692
|
const o = et(s);
|
|
2684
2693
|
if (o && e.push({ etype: r, lookupPair: o }), n === "link")
|
|
@@ -2695,7 +2704,7 @@ function ai(t) {
|
|
|
2695
2704
|
}
|
|
2696
2705
|
return e;
|
|
2697
2706
|
}
|
|
2698
|
-
function
|
|
2707
|
+
function ui({ attrs: t, schema: e }, n) {
|
|
2699
2708
|
var u, l;
|
|
2700
2709
|
const [r, s, i] = [/* @__PURE__ */ new Set(), { ...t }, []];
|
|
2701
2710
|
function o(f) {
|
|
@@ -2706,10 +2715,10 @@ function ci({ attrs: t, schema: e }, n) {
|
|
|
2706
2715
|
}
|
|
2707
2716
|
function c(f, d) {
|
|
2708
2717
|
const h = C(s, f, d), p = J(s, f, d);
|
|
2709
|
-
a(h), a(p), !h && !p && o(xt(e, f, d,
|
|
2718
|
+
a(h), a(p), !h && !p && o(xt(e, f, d, ai));
|
|
2710
2719
|
}
|
|
2711
2720
|
for (const f of n)
|
|
2712
|
-
for (const { etype: d, lookupPair: h, linkLabel: p } of
|
|
2721
|
+
for (const { etype: d, lookupPair: h, linkLabel: p } of ci(f)) {
|
|
2713
2722
|
const b = h[0];
|
|
2714
2723
|
if (p) {
|
|
2715
2724
|
c(d, p);
|
|
@@ -2733,19 +2742,19 @@ function ci({ attrs: t, schema: e }, n) {
|
|
|
2733
2742
|
}
|
|
2734
2743
|
for (const f of n) {
|
|
2735
2744
|
const [d, h, p, b] = f;
|
|
2736
|
-
if (
|
|
2745
|
+
if (ri.has(d)) {
|
|
2737
2746
|
const _ = C(s, h, "id");
|
|
2738
2747
|
a(_), _ || o(_e(e, h, "id", { "unique?": !0 }));
|
|
2739
2748
|
for (const y of Object.keys(b)) {
|
|
2740
2749
|
const g = C(s, h, y);
|
|
2741
|
-
if (a(g),
|
|
2750
|
+
if (a(g), ii.has(d) && (g || o(
|
|
2742
2751
|
_e(
|
|
2743
2752
|
e,
|
|
2744
2753
|
h,
|
|
2745
2754
|
y,
|
|
2746
2755
|
y === "id" ? { "unique?": !0 } : null
|
|
2747
2756
|
)
|
|
2748
|
-
)),
|
|
2757
|
+
)), si.has(d)) {
|
|
2749
2758
|
const T = J(s, h, y);
|
|
2750
2759
|
!g && !T && o(xt(e, h, y)), a(T);
|
|
2751
2760
|
}
|
|
@@ -2754,15 +2763,15 @@ function ci({ attrs: t, schema: e }, n) {
|
|
|
2754
2763
|
}
|
|
2755
2764
|
return [s, i];
|
|
2756
2765
|
}
|
|
2757
|
-
function
|
|
2758
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((c) =>
|
|
2766
|
+
function li(t, e) {
|
|
2767
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Fs(c)), [s, i] = ui(t, r), o = { ...t, attrs: s }, a = r.flatMap((c) => Zs(o, c));
|
|
2759
2768
|
return [...i, ...a];
|
|
2760
2769
|
}
|
|
2761
2770
|
function Ut(t, e) {
|
|
2762
2771
|
typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
|
|
2763
2772
|
}
|
|
2764
2773
|
const fe = "__meta";
|
|
2765
|
-
class
|
|
2774
|
+
class fi {
|
|
2766
2775
|
constructor(e, n) {
|
|
2767
2776
|
}
|
|
2768
2777
|
}
|
|
@@ -2998,13 +3007,13 @@ class nt {
|
|
|
2998
3007
|
};
|
|
2999
3008
|
}
|
|
3000
3009
|
}
|
|
3001
|
-
const
|
|
3002
|
-
function
|
|
3010
|
+
const di = 6, hi = ["kv", "querySubs", "syncSubs"];
|
|
3011
|
+
function pi(t) {
|
|
3003
3012
|
return function(n) {
|
|
3004
3013
|
console.error("Error in IndexedDB event", { source: t, event: n });
|
|
3005
3014
|
};
|
|
3006
3015
|
}
|
|
3007
|
-
async function
|
|
3016
|
+
async function yi(t) {
|
|
3008
3017
|
return new Promise((e) => {
|
|
3009
3018
|
const n = indexedDB.open(t);
|
|
3010
3019
|
n.onerror = (r) => {
|
|
@@ -3018,7 +3027,7 @@ async function pi(t) {
|
|
|
3018
3027
|
};
|
|
3019
3028
|
});
|
|
3020
3029
|
}
|
|
3021
|
-
async function
|
|
3030
|
+
async function bi(t, e, n) {
|
|
3022
3031
|
const r = (
|
|
3023
3032
|
// Backwards compatibility for older versions where we JSON.stringified before storing
|
|
3024
3033
|
typeof e == "string" ? JSON.parse(e) : e
|
|
@@ -3058,8 +3067,8 @@ async function Lt(t, e, n) {
|
|
|
3058
3067
|
r.onsuccess = () => s(), r.onerror = (o) => i(o);
|
|
3059
3068
|
});
|
|
3060
3069
|
}
|
|
3061
|
-
async function
|
|
3062
|
-
const n = await
|
|
3070
|
+
async function _i(t, e) {
|
|
3071
|
+
const n = await yi(`instant_${t}_5`);
|
|
3063
3072
|
if (!n)
|
|
3064
3073
|
return;
|
|
3065
3074
|
const r = await new Promise((l, f) => {
|
|
@@ -3082,7 +3091,7 @@ async function bi(t, e) {
|
|
|
3082
3091
|
for (const [l, f] of r)
|
|
3083
3092
|
switch (l) {
|
|
3084
3093
|
case "querySubs": {
|
|
3085
|
-
const d =
|
|
3094
|
+
const d = bi(l, f, o);
|
|
3086
3095
|
a.push(d);
|
|
3087
3096
|
break;
|
|
3088
3097
|
}
|
|
@@ -3104,9 +3113,9 @@ async function bi(t, e) {
|
|
|
3104
3113
|
});
|
|
3105
3114
|
}
|
|
3106
3115
|
const Ft = /* @__PURE__ */ new Map();
|
|
3107
|
-
class Dn extends
|
|
3116
|
+
class Dn extends fi {
|
|
3108
3117
|
constructor(e, n) {
|
|
3109
|
-
super(e, n), this.dbName = `instant_${e}_${
|
|
3118
|
+
super(e, n), this.dbName = `instant_${e}_${di}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
|
|
3110
3119
|
}
|
|
3111
3120
|
_init() {
|
|
3112
3121
|
return new Promise((e, n) => {
|
|
@@ -3117,8 +3126,8 @@ class Dn extends li {
|
|
|
3117
3126
|
}, s.onsuccess = (i) => {
|
|
3118
3127
|
const a = i.target.result;
|
|
3119
3128
|
if (r) {
|
|
3120
|
-
const c =
|
|
3121
|
-
|
|
3129
|
+
const c = _i(this._appId, a).catch((u) => {
|
|
3130
|
+
pi("Error upgrading store from version 5 to 6.")(u);
|
|
3122
3131
|
});
|
|
3123
3132
|
Ft.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
|
|
3124
3133
|
} else {
|
|
@@ -3132,7 +3141,7 @@ class Dn extends li {
|
|
|
3132
3141
|
}
|
|
3133
3142
|
_upgradeStore(e) {
|
|
3134
3143
|
const r = e.target.result;
|
|
3135
|
-
for (const s of
|
|
3144
|
+
for (const s of hi)
|
|
3136
3145
|
r.objectStoreNames.contains(s) || r.createObjectStore(s);
|
|
3137
3146
|
}
|
|
3138
3147
|
async getItem(e) {
|
|
@@ -3238,7 +3247,7 @@ async function q(t, e) {
|
|
|
3238
3247
|
const n = await fetch(t, e), r = await n.json();
|
|
3239
3248
|
return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Pe({ status: n.status, body: r }));
|
|
3240
3249
|
}
|
|
3241
|
-
function
|
|
3250
|
+
function gi({
|
|
3242
3251
|
apiURI: t,
|
|
3243
3252
|
appId: e,
|
|
3244
3253
|
email: n
|
|
@@ -3249,7 +3258,7 @@ function _i({
|
|
|
3249
3258
|
body: JSON.stringify({ "app-id": e, email: n })
|
|
3250
3259
|
});
|
|
3251
3260
|
}
|
|
3252
|
-
async function
|
|
3261
|
+
async function wi({
|
|
3253
3262
|
apiURI: t,
|
|
3254
3263
|
appId: e,
|
|
3255
3264
|
email: n,
|
|
@@ -3267,7 +3276,7 @@ async function gi({
|
|
|
3267
3276
|
})
|
|
3268
3277
|
});
|
|
3269
3278
|
}
|
|
3270
|
-
async function
|
|
3279
|
+
async function Ti({
|
|
3271
3280
|
apiURI: t,
|
|
3272
3281
|
appId: e,
|
|
3273
3282
|
refreshToken: n
|
|
@@ -3281,7 +3290,7 @@ async function wi({
|
|
|
3281
3290
|
})
|
|
3282
3291
|
});
|
|
3283
3292
|
}
|
|
3284
|
-
async function
|
|
3293
|
+
async function mi({
|
|
3285
3294
|
apiURI: t,
|
|
3286
3295
|
appId: e
|
|
3287
3296
|
}) {
|
|
@@ -3311,7 +3320,7 @@ async function Nt({
|
|
|
3311
3320
|
})
|
|
3312
3321
|
});
|
|
3313
3322
|
}
|
|
3314
|
-
async function
|
|
3323
|
+
async function Si({
|
|
3315
3324
|
apiURI: t,
|
|
3316
3325
|
appId: e,
|
|
3317
3326
|
nonce: n,
|
|
@@ -3331,7 +3340,7 @@ async function mi({
|
|
|
3331
3340
|
})
|
|
3332
3341
|
});
|
|
3333
3342
|
}
|
|
3334
|
-
async function
|
|
3343
|
+
async function Oi({
|
|
3335
3344
|
apiURI: t,
|
|
3336
3345
|
appId: e,
|
|
3337
3346
|
refreshToken: n
|
|
@@ -3347,7 +3356,7 @@ async function Si({
|
|
|
3347
3356
|
})
|
|
3348
3357
|
});
|
|
3349
3358
|
}
|
|
3350
|
-
async function
|
|
3359
|
+
async function Ai({
|
|
3351
3360
|
apiURI: t,
|
|
3352
3361
|
appId: e,
|
|
3353
3362
|
path: n,
|
|
@@ -3368,7 +3377,7 @@ async function Oi({
|
|
|
3368
3377
|
body: r
|
|
3369
3378
|
});
|
|
3370
3379
|
}
|
|
3371
|
-
async function
|
|
3380
|
+
async function vi({
|
|
3372
3381
|
apiURI: t,
|
|
3373
3382
|
appId: e,
|
|
3374
3383
|
path: n,
|
|
@@ -3386,7 +3395,7 @@ async function Ai({
|
|
|
3386
3395
|
);
|
|
3387
3396
|
return s;
|
|
3388
3397
|
}
|
|
3389
|
-
async function
|
|
3398
|
+
async function ki({
|
|
3390
3399
|
apiURI: t,
|
|
3391
3400
|
appId: e,
|
|
3392
3401
|
fileName: n,
|
|
@@ -3406,7 +3415,7 @@ async function vi({
|
|
|
3406
3415
|
});
|
|
3407
3416
|
return i;
|
|
3408
3417
|
}
|
|
3409
|
-
async function
|
|
3418
|
+
async function Ei(t, e) {
|
|
3410
3419
|
return (await fetch(t, {
|
|
3411
3420
|
method: "PUT",
|
|
3412
3421
|
body: e,
|
|
@@ -3415,7 +3424,7 @@ async function ki(t, e) {
|
|
|
3415
3424
|
}
|
|
3416
3425
|
})).ok;
|
|
3417
3426
|
}
|
|
3418
|
-
async function
|
|
3427
|
+
async function Ci({
|
|
3419
3428
|
apiURI: t,
|
|
3420
3429
|
appId: e,
|
|
3421
3430
|
path: n,
|
|
@@ -3444,7 +3453,7 @@ function Kt(t, e) {
|
|
|
3444
3453
|
n[r] = t[r];
|
|
3445
3454
|
}), n;
|
|
3446
3455
|
}
|
|
3447
|
-
function
|
|
3456
|
+
function Mi(t, e, n) {
|
|
3448
3457
|
const r = {
|
|
3449
3458
|
peers: {}
|
|
3450
3459
|
};
|
|
@@ -3461,7 +3470,7 @@ function Ci(t, e, n) {
|
|
|
3461
3470
|
}
|
|
3462
3471
|
return r;
|
|
3463
3472
|
}
|
|
3464
|
-
function
|
|
3473
|
+
function Ii(t, e) {
|
|
3465
3474
|
if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !kt(t.user, e.user)) || !ln(t.peers, e.peers)) return !0;
|
|
3466
3475
|
for (const r of Object.keys(t.peers))
|
|
3467
3476
|
if (!kt(t.peers[r], e.peers[r])) return !0;
|
|
@@ -3510,8 +3519,8 @@ function Vt(t) {
|
|
|
3510
3519
|
}, e;
|
|
3511
3520
|
}, {});
|
|
3512
3521
|
}
|
|
3513
|
-
const Fn = "v0.22.
|
|
3514
|
-
function
|
|
3522
|
+
const Fn = "v0.22.77";
|
|
3523
|
+
function Pi(t, e) {
|
|
3515
3524
|
return {
|
|
3516
3525
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
3517
3526
|
},
|
|
@@ -3631,7 +3640,7 @@ const Wt = [
|
|
|
3631
3640
|
"before",
|
|
3632
3641
|
"fields",
|
|
3633
3642
|
"aggregate"
|
|
3634
|
-
],
|
|
3643
|
+
], ji = (t) => t.valueType || "unknown", Nn = (t, e, n = !1) => {
|
|
3635
3644
|
if (n || t == null) return !0;
|
|
3636
3645
|
switch (e) {
|
|
3637
3646
|
case "string":
|
|
@@ -3645,7 +3654,7 @@ const Wt = [
|
|
|
3645
3654
|
default:
|
|
3646
3655
|
return !0;
|
|
3647
3656
|
}
|
|
3648
|
-
},
|
|
3657
|
+
}, $i = (t, e, n, r, s, i, o) => {
|
|
3649
3658
|
const a = i.valueType === "json", c = (u, l, f) => {
|
|
3650
3659
|
if (!Nn(f, l, a))
|
|
3651
3660
|
throw new O(
|
|
@@ -3690,13 +3699,13 @@ const Wt = [
|
|
|
3690
3699
|
);
|
|
3691
3700
|
}
|
|
3692
3701
|
}, ee = (t, e, n, r, s) => {
|
|
3693
|
-
const i =
|
|
3702
|
+
const i = ji(n), o = n.valueType === "json";
|
|
3694
3703
|
if (typeof t == "object" && t !== null && !Array.isArray(t)) {
|
|
3695
3704
|
if (o)
|
|
3696
3705
|
return;
|
|
3697
3706
|
const c = t;
|
|
3698
3707
|
for (const [u, l] of Object.entries(c))
|
|
3699
|
-
|
|
3708
|
+
$i(
|
|
3700
3709
|
u,
|
|
3701
3710
|
l,
|
|
3702
3711
|
i,
|
|
@@ -3710,7 +3719,7 @@ const Wt = [
|
|
|
3710
3719
|
`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`,
|
|
3711
3720
|
s
|
|
3712
3721
|
);
|
|
3713
|
-
},
|
|
3722
|
+
}, Di = (t, e, n, r, s) => {
|
|
3714
3723
|
const i = t.split(".");
|
|
3715
3724
|
if (i.length < 2)
|
|
3716
3725
|
throw new O(
|
|
@@ -3804,7 +3813,7 @@ const Wt = [
|
|
|
3804
3813
|
continue;
|
|
3805
3814
|
}
|
|
3806
3815
|
if (s.includes(".")) {
|
|
3807
|
-
|
|
3816
|
+
Di(
|
|
3808
3817
|
s,
|
|
3809
3818
|
i,
|
|
3810
3819
|
e,
|
|
@@ -3847,7 +3856,7 @@ const Wt = [
|
|
|
3847
3856
|
);
|
|
3848
3857
|
}
|
|
3849
3858
|
}
|
|
3850
|
-
},
|
|
3859
|
+
}, Ri = (t, e, n, r, s = 0) => {
|
|
3851
3860
|
for (const o of Object.keys(t))
|
|
3852
3861
|
if (!Wt.includes(o))
|
|
3853
3862
|
throw new O(
|
|
@@ -3915,7 +3924,7 @@ const Wt = [
|
|
|
3915
3924
|
`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`,
|
|
3916
3925
|
`${r}.$`
|
|
3917
3926
|
);
|
|
3918
|
-
|
|
3927
|
+
Ri(
|
|
3919
3928
|
a,
|
|
3920
3929
|
e,
|
|
3921
3930
|
n,
|
|
@@ -3968,7 +3977,7 @@ class F extends Error {
|
|
|
3968
3977
|
super(e), this.name = "TransactionValidationError";
|
|
3969
3978
|
}
|
|
3970
3979
|
}
|
|
3971
|
-
const zn = (t) => t.length > 0 ? t.join(", ") : "none",
|
|
3980
|
+
const zn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new F(
|
|
3972
3981
|
`Entity '${t}' does not exist in schema. Available entities: ${zn(e)}`
|
|
3973
3982
|
), Ue = {
|
|
3974
3983
|
string: (t) => typeof t == "string",
|
|
@@ -3976,13 +3985,13 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
|
|
|
3976
3985
|
boolean: (t) => typeof t == "boolean",
|
|
3977
3986
|
date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
|
|
3978
3987
|
json: () => !0
|
|
3979
|
-
},
|
|
3988
|
+
}, Ui = (t, e) => {
|
|
3980
3989
|
var n;
|
|
3981
3990
|
return t == null ? !0 : ((n = Ue[e.valueType]) == null ? void 0 : n.call(Ue, t)) ?? !1;
|
|
3982
3991
|
}, Vn = (t, e) => {
|
|
3983
3992
|
const n = e.entities[t];
|
|
3984
3993
|
if (!n)
|
|
3985
|
-
throw
|
|
3994
|
+
throw xi(t, Object.keys(e.entities));
|
|
3986
3995
|
return n;
|
|
3987
3996
|
}, Le = (t, e, n) => {
|
|
3988
3997
|
const r = Vn(t, n);
|
|
@@ -3993,7 +4002,7 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
|
|
|
3993
4002
|
for (const [s, i] of Object.entries(e)) {
|
|
3994
4003
|
if (s === "id") continue;
|
|
3995
4004
|
const o = r.attrs[s];
|
|
3996
|
-
if (o && !
|
|
4005
|
+
if (o && !Ui(i, o))
|
|
3997
4006
|
throw new F(
|
|
3998
4007
|
`Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`
|
|
3999
4008
|
);
|
|
@@ -4024,7 +4033,7 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
|
|
|
4024
4033
|
);
|
|
4025
4034
|
}
|
|
4026
4035
|
}
|
|
4027
|
-
},
|
|
4036
|
+
}, Li = {
|
|
4028
4037
|
create: Le,
|
|
4029
4038
|
update: Le,
|
|
4030
4039
|
merge: Le,
|
|
@@ -4032,7 +4041,7 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
|
|
|
4032
4041
|
unlink: Bt,
|
|
4033
4042
|
delete: () => {
|
|
4034
4043
|
}
|
|
4035
|
-
},
|
|
4044
|
+
}, Fi = (t, e) => {
|
|
4036
4045
|
if (!e) return;
|
|
4037
4046
|
const [n, r, s, i] = t;
|
|
4038
4047
|
if (!Array.isArray(s) && !te(s))
|
|
@@ -4043,9 +4052,9 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
|
|
|
4043
4052
|
throw new F(
|
|
4044
4053
|
`Entity name must be a string, but received: ${typeof r}`
|
|
4045
4054
|
);
|
|
4046
|
-
const o =
|
|
4055
|
+
const o = Li[n];
|
|
4047
4056
|
o && i !== void 0 && o(r, i, e);
|
|
4048
|
-
},
|
|
4057
|
+
}, Ni = (t, e) => {
|
|
4049
4058
|
const n = Array.isArray(t) ? t : [t];
|
|
4050
4059
|
for (const r of n) {
|
|
4051
4060
|
if (!r || typeof r != "object")
|
|
@@ -4061,7 +4070,7 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
|
|
|
4061
4070
|
throw new F(
|
|
4062
4071
|
`Transaction operation must be an array, but received: ${typeof s}`
|
|
4063
4072
|
);
|
|
4064
|
-
|
|
4073
|
+
Fi(s, e);
|
|
4065
4074
|
}
|
|
4066
4075
|
}
|
|
4067
4076
|
};
|
|
@@ -4094,7 +4103,7 @@ class Ht {
|
|
|
4094
4103
|
return this.conn.send(JSON.stringify(e));
|
|
4095
4104
|
}
|
|
4096
4105
|
}
|
|
4097
|
-
class
|
|
4106
|
+
class Ki {
|
|
4098
4107
|
constructor(e, n) {
|
|
4099
4108
|
this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Wn++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
|
|
4100
4109
|
this.initParams || this.handleError();
|
|
@@ -4177,14 +4186,14 @@ class Ni {
|
|
|
4177
4186
|
this.handleClose();
|
|
4178
4187
|
}
|
|
4179
4188
|
}
|
|
4180
|
-
function
|
|
4189
|
+
function qi(t, e) {
|
|
4181
4190
|
const n = t.values;
|
|
4182
4191
|
if (n)
|
|
4183
4192
|
for (const r of n.entities || [])
|
|
4184
4193
|
r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = bn(r.store);
|
|
4185
4194
|
return t;
|
|
4186
4195
|
}
|
|
4187
|
-
function
|
|
4196
|
+
function zi(t, e) {
|
|
4188
4197
|
var n, r;
|
|
4189
4198
|
if ((n = e.values) != null && n.entities) {
|
|
4190
4199
|
const s = [];
|
|
@@ -4196,7 +4205,7 @@ function qi(t, e) {
|
|
|
4196
4205
|
} else
|
|
4197
4206
|
return e;
|
|
4198
4207
|
}
|
|
4199
|
-
function
|
|
4208
|
+
function Vi(t, e, n) {
|
|
4200
4209
|
var i, o;
|
|
4201
4210
|
const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = n == null ? void 0 : n.state) == null ? void 0 : o.txId;
|
|
4202
4211
|
return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
|
|
@@ -4223,7 +4232,7 @@ function Yt(t, e) {
|
|
|
4223
4232
|
break;
|
|
4224
4233
|
}
|
|
4225
4234
|
}
|
|
4226
|
-
function
|
|
4235
|
+
function Wi(t, e) {
|
|
4227
4236
|
var r, s;
|
|
4228
4237
|
const n = {};
|
|
4229
4238
|
for (const { action: i, triple: o } of e) {
|
|
@@ -4250,14 +4259,14 @@ function Vi(t, e) {
|
|
|
4250
4259
|
function ge(t, e) {
|
|
4251
4260
|
return { [t.table]: e.map((n) => n.entity) };
|
|
4252
4261
|
}
|
|
4253
|
-
function
|
|
4262
|
+
function Qi(t, e) {
|
|
4254
4263
|
var r;
|
|
4255
4264
|
if (t.orderFieldType)
|
|
4256
4265
|
return t.orderFieldType;
|
|
4257
4266
|
const n = t.orderField === "serverCreatedAt" ? "number" : (r = G(e([]), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
|
|
4258
4267
|
return t.orderFieldType = n, n;
|
|
4259
4268
|
}
|
|
4260
|
-
function
|
|
4269
|
+
function Gi(t, e, n) {
|
|
4261
4270
|
const r = e;
|
|
4262
4271
|
if (t.orderField === "serverCreatedAt") {
|
|
4263
4272
|
n.sort(
|
|
@@ -4302,14 +4311,14 @@ function Qi(t, e, n) {
|
|
|
4302
4311
|
}
|
|
4303
4312
|
);
|
|
4304
4313
|
}
|
|
4305
|
-
var
|
|
4306
|
-
class
|
|
4314
|
+
var Bi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Bi || {});
|
|
4315
|
+
class Hi {
|
|
4307
4316
|
constructor(e, n, r, s, i) {
|
|
4308
4317
|
this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.subs = new nt({
|
|
4309
4318
|
persister: n,
|
|
4310
|
-
merge:
|
|
4311
|
-
serialize:
|
|
4312
|
-
parse: (o, a) =>
|
|
4319
|
+
merge: Vi,
|
|
4320
|
+
serialize: zi,
|
|
4321
|
+
parse: (o, a) => qi(a, this.config.useDateObjects),
|
|
4313
4322
|
objectSize: (o) => {
|
|
4314
4323
|
var a;
|
|
4315
4324
|
return ((a = o.values) == null ? void 0 : a.entities.length) || 0;
|
|
@@ -4516,9 +4525,9 @@ class Bi {
|
|
|
4516
4525
|
e: for (const [_, y] of Object.entries(u))
|
|
4517
4526
|
for (let g = 0; g < f.length; g++) {
|
|
4518
4527
|
const T = f[g];
|
|
4519
|
-
if (
|
|
4528
|
+
if (Mr(T.store, _)) {
|
|
4520
4529
|
Yt(T.store, y);
|
|
4521
|
-
const A = Fe(s, T.store), m =
|
|
4530
|
+
const A = Fe(s, T.store), m = Wi(T.store, y)[_];
|
|
4522
4531
|
A ? (d.push({
|
|
4523
4532
|
oldEntity: T.entity,
|
|
4524
4533
|
newEntity: A,
|
|
@@ -4549,8 +4558,8 @@ class Bi {
|
|
|
4549
4558
|
const p = [];
|
|
4550
4559
|
for (const _ of c.sort().reverse())
|
|
4551
4560
|
p.push(f[_].entity), f.splice(_, 1);
|
|
4552
|
-
const b =
|
|
4553
|
-
|
|
4561
|
+
const b = Qi(s, this.createStore);
|
|
4562
|
+
Gi(s, b, f), this.notifyCbs(r, {
|
|
4554
4563
|
type: "SyncTransaction",
|
|
4555
4564
|
data: ge(s, (o = s.values) == null ? void 0 : o.entities),
|
|
4556
4565
|
added: h,
|
|
@@ -4597,11 +4606,11 @@ const V = {
|
|
|
4597
4606
|
AUTHENTICATED: "authenticated",
|
|
4598
4607
|
CLOSED: "closed",
|
|
4599
4608
|
ERRORED: "errored"
|
|
4600
|
-
},
|
|
4609
|
+
}, Ji = 3e4, Yi = 3e4, Zi = 200, Xi = {
|
|
4601
4610
|
apiURI: "https://api.instantdb.com",
|
|
4602
4611
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
4603
4612
|
}, Ne = "_instant_oauth_redirect", ie = "currentUser";
|
|
4604
|
-
function
|
|
4613
|
+
function eo({
|
|
4605
4614
|
transportType: t,
|
|
4606
4615
|
appId: e,
|
|
4607
4616
|
apiURI: n,
|
|
@@ -4614,7 +4623,7 @@ function Xi({
|
|
|
4614
4623
|
case "ws":
|
|
4615
4624
|
return new Ht(`${r}?app_id=${e}`);
|
|
4616
4625
|
case "sse":
|
|
4617
|
-
return new
|
|
4626
|
+
return new Ki(
|
|
4618
4627
|
s,
|
|
4619
4628
|
`${n}/runtime/sse?app_id=${e}`
|
|
4620
4629
|
);
|
|
@@ -4622,7 +4631,7 @@ function Xi({
|
|
|
4622
4631
|
throw new Error("Unknown transport type " + t);
|
|
4623
4632
|
}
|
|
4624
4633
|
}
|
|
4625
|
-
function
|
|
4634
|
+
function to() {
|
|
4626
4635
|
return typeof window < "u" || typeof chrome < "u";
|
|
4627
4636
|
}
|
|
4628
4637
|
const Zt = {
|
|
@@ -4631,7 +4640,7 @@ const Zt = {
|
|
|
4631
4640
|
"refresh-presence": !0,
|
|
4632
4641
|
"patch-presence": !0
|
|
4633
4642
|
};
|
|
4634
|
-
function
|
|
4643
|
+
function no(t, e) {
|
|
4635
4644
|
var r;
|
|
4636
4645
|
const n = typeof t == "string" ? JSON.parse(t) : t;
|
|
4637
4646
|
if ((r = n == null ? void 0 : n.result) != null && r.store) {
|
|
@@ -4643,7 +4652,7 @@ function to(t, e) {
|
|
|
4643
4652
|
}
|
|
4644
4653
|
return n;
|
|
4645
4654
|
}
|
|
4646
|
-
function
|
|
4655
|
+
function ro(t, e) {
|
|
4647
4656
|
var r;
|
|
4648
4657
|
const n = { ...e };
|
|
4649
4658
|
return (r = e.result) != null && r.store && (n.result = {
|
|
@@ -4651,7 +4660,7 @@ function no(t, e) {
|
|
|
4651
4660
|
store: yn(e.result.store)
|
|
4652
4661
|
}), n;
|
|
4653
4662
|
}
|
|
4654
|
-
function
|
|
4663
|
+
function so(t, e) {
|
|
4655
4664
|
switch (t) {
|
|
4656
4665
|
case "pendingMutations":
|
|
4657
4666
|
return new Map(typeof e == "string" ? JSON.parse(e) : e);
|
|
@@ -4659,7 +4668,7 @@ function ro(t, e) {
|
|
|
4659
4668
|
return e;
|
|
4660
4669
|
}
|
|
4661
4670
|
}
|
|
4662
|
-
function
|
|
4671
|
+
function io(t, e) {
|
|
4663
4672
|
switch (t) {
|
|
4664
4673
|
case "pendingMutations":
|
|
4665
4674
|
return [...e.entries()];
|
|
@@ -4667,7 +4676,7 @@ function so(t, e) {
|
|
|
4667
4676
|
return e;
|
|
4668
4677
|
}
|
|
4669
4678
|
}
|
|
4670
|
-
function
|
|
4679
|
+
function oo(t, e, n) {
|
|
4671
4680
|
const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
|
|
4672
4681
|
return r && !s && n && (n.result = r), n || e;
|
|
4673
4682
|
}
|
|
@@ -4677,7 +4686,7 @@ function Xt(t) {
|
|
|
4677
4686
|
return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
|
|
4678
4687
|
});
|
|
4679
4688
|
}
|
|
4680
|
-
class
|
|
4689
|
+
class ao {
|
|
4681
4690
|
constructor(e, n = Dn, r = Rn, s, i) {
|
|
4682
4691
|
w(this, "attrs");
|
|
4683
4692
|
w(this, "_isOnline", !0);
|
|
@@ -4771,9 +4780,9 @@ class oo {
|
|
|
4771
4780
|
});
|
|
4772
4781
|
/** Applies transactions locally and sends transact message to server */
|
|
4773
4782
|
w(this, "pushTx", (e) => {
|
|
4774
|
-
this.config.disableValidation ||
|
|
4783
|
+
this.config.disableValidation || Ni(e, this.config.schema);
|
|
4775
4784
|
try {
|
|
4776
|
-
const n =
|
|
4785
|
+
const n = li(
|
|
4777
4786
|
{
|
|
4778
4787
|
attrs: this.optimisticAttrs(),
|
|
4779
4788
|
schema: this.config.schema,
|
|
@@ -4912,10 +4921,10 @@ class oo {
|
|
|
4912
4921
|
this._reconnectTimeoutMs
|
|
4913
4922
|
), this._scheduleReconnect();
|
|
4914
4923
|
});
|
|
4915
|
-
if (this._EventSource = i, this.config = { ...
|
|
4924
|
+
if (this._EventSource = i, this.config = { ...Xi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Yi, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Zi, this._log = Pi(
|
|
4916
4925
|
e.verbose || _t || xn,
|
|
4917
4926
|
() => this._reactorStats()
|
|
4918
|
-
), this.versions = { ...s || {}, "@instantdb/core": Fn }, this.config.schema && (this._linkIndex = Vt(this.config.schema)), !!
|
|
4927
|
+
), this.versions = { ...s || {}, "@instantdb/core": Fn }, this.config.schema && (this._linkIndex = Vt(this.config.schema)), !!to()) {
|
|
4919
4928
|
if (!e.appId)
|
|
4920
4929
|
throw new Error("Instant must be initialized with an appId.");
|
|
4921
4930
|
if (!te(e.appId))
|
|
@@ -4932,7 +4941,7 @@ class oo {
|
|
|
4932
4941
|
} catch (c) {
|
|
4933
4942
|
this._log.error("[error] handle broadcast channel", c);
|
|
4934
4943
|
}
|
|
4935
|
-
})), this._initStorage(n), this._syncTable = new
|
|
4944
|
+
})), this._initStorage(n), this._syncTable = new Hi(
|
|
4936
4945
|
this._trySendAuthed.bind(this),
|
|
4937
4946
|
new n(this.config.appId, "syncSubs"),
|
|
4938
4947
|
{
|
|
@@ -4978,9 +4987,9 @@ class oo {
|
|
|
4978
4987
|
_initStorage(e) {
|
|
4979
4988
|
this.querySubs = new nt({
|
|
4980
4989
|
persister: new e(this.config.appId, "querySubs"),
|
|
4981
|
-
merge:
|
|
4982
|
-
serialize:
|
|
4983
|
-
parse: (n, r) =>
|
|
4990
|
+
merge: oo,
|
|
4991
|
+
serialize: ro,
|
|
4992
|
+
parse: (n, r) => no(r, this.config.useDateObjects),
|
|
4984
4993
|
// objectSize
|
|
4985
4994
|
objectSize: (n) => {
|
|
4986
4995
|
var r, s, i;
|
|
@@ -4999,8 +5008,8 @@ class oo {
|
|
|
4999
5008
|
}), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new nt({
|
|
5000
5009
|
persister: new e(this.config.appId, "kv"),
|
|
5001
5010
|
merge: this._onMergeKv,
|
|
5002
|
-
serialize:
|
|
5003
|
-
parse:
|
|
5011
|
+
serialize: io,
|
|
5012
|
+
parse: so,
|
|
5004
5013
|
objectSize: () => 0,
|
|
5005
5014
|
logger: this._log,
|
|
5006
5015
|
saveThrottleMs: 100,
|
|
@@ -5331,7 +5340,7 @@ class oo {
|
|
|
5331
5340
|
const s = P(e), i = this._startQuerySub(e, s);
|
|
5332
5341
|
return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
|
|
5333
5342
|
() => r.reject(new Error("Query timed out")),
|
|
5334
|
-
|
|
5343
|
+
Ji
|
|
5335
5344
|
), r.promise;
|
|
5336
5345
|
}
|
|
5337
5346
|
_completeQueryOnce(e, n, r) {
|
|
@@ -5393,7 +5402,7 @@ class oo {
|
|
|
5393
5402
|
a = !0;
|
|
5394
5403
|
continue;
|
|
5395
5404
|
}
|
|
5396
|
-
const b = a ?
|
|
5405
|
+
const b = a ? Ns(o, h) : h;
|
|
5397
5406
|
d.push(b);
|
|
5398
5407
|
}
|
|
5399
5408
|
return a ? d : l;
|
|
@@ -5453,7 +5462,7 @@ class oo {
|
|
|
5453
5462
|
}
|
|
5454
5463
|
_applyOptimisticUpdates(e, n, r) {
|
|
5455
5464
|
for (const [s, i] of n)
|
|
5456
|
-
(!i["tx-id"] || r && i["tx-id"] > r) && (e =
|
|
5465
|
+
(!i["tx-id"] || r && i["tx-id"] > r) && (e = Kr(e, i["tx-steps"]));
|
|
5457
5466
|
return e;
|
|
5458
5467
|
}
|
|
5459
5468
|
/** Re-compute all subscriptions */
|
|
@@ -5576,7 +5585,7 @@ class oo {
|
|
|
5576
5585
|
return;
|
|
5577
5586
|
}
|
|
5578
5587
|
const e = this._transport;
|
|
5579
|
-
this._transport =
|
|
5588
|
+
this._transport = eo({
|
|
5580
5589
|
transportType: this._transportType,
|
|
5581
5590
|
appId: this.config.appId,
|
|
5582
5591
|
apiURI: this.config.apiURI,
|
|
@@ -5770,7 +5779,7 @@ class oo {
|
|
|
5770
5779
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
|
|
5771
5780
|
}
|
|
5772
5781
|
sendMagicCode({ email: e }) {
|
|
5773
|
-
return
|
|
5782
|
+
return gi({
|
|
5774
5783
|
apiURI: this.config.apiURI,
|
|
5775
5784
|
appId: this.config.appId,
|
|
5776
5785
|
email: e
|
|
@@ -5778,7 +5787,7 @@ class oo {
|
|
|
5778
5787
|
}
|
|
5779
5788
|
async signInWithMagicCode({ email: e, code: n }) {
|
|
5780
5789
|
var o;
|
|
5781
|
-
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await
|
|
5790
|
+
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await wi({
|
|
5782
5791
|
apiURI: this.config.apiURI,
|
|
5783
5792
|
appId: this.config.appId,
|
|
5784
5793
|
email: e,
|
|
@@ -5788,7 +5797,7 @@ class oo {
|
|
|
5788
5797
|
return await this.changeCurrentUser(i.user), i;
|
|
5789
5798
|
}
|
|
5790
5799
|
async signInWithCustomToken(e) {
|
|
5791
|
-
const n = await
|
|
5800
|
+
const n = await Ti({
|
|
5792
5801
|
apiURI: this.config.apiURI,
|
|
5793
5802
|
appId: this.config.appId,
|
|
5794
5803
|
refreshToken: e
|
|
@@ -5796,7 +5805,7 @@ class oo {
|
|
|
5796
5805
|
return await this.changeCurrentUser(n.user), n;
|
|
5797
5806
|
}
|
|
5798
5807
|
async signInAsGuest() {
|
|
5799
|
-
const e = await
|
|
5808
|
+
const e = await mi({
|
|
5800
5809
|
apiURI: this.config.apiURI,
|
|
5801
5810
|
appId: this.config.appId
|
|
5802
5811
|
});
|
|
@@ -5811,7 +5820,7 @@ class oo {
|
|
|
5811
5820
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
5812
5821
|
return;
|
|
5813
5822
|
}
|
|
5814
|
-
|
|
5823
|
+
Oi({
|
|
5815
5824
|
apiURI: this.config.apiURI,
|
|
5816
5825
|
appId: this.config.appId,
|
|
5817
5826
|
refreshToken: r
|
|
@@ -5864,7 +5873,7 @@ class oo {
|
|
|
5864
5873
|
*/
|
|
5865
5874
|
async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
|
|
5866
5875
|
var a;
|
|
5867
|
-
const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await
|
|
5876
|
+
const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await Si({
|
|
5868
5877
|
apiURI: this.config.apiURI,
|
|
5869
5878
|
appId: this.config.appId,
|
|
5870
5879
|
idToken: e,
|
|
@@ -5905,7 +5914,7 @@ class oo {
|
|
|
5905
5914
|
getPresence(e, n, r = {}) {
|
|
5906
5915
|
const s = this._rooms[n], i = this._presence[n];
|
|
5907
5916
|
return !s || !i || !i.result ? null : {
|
|
5908
|
-
...
|
|
5917
|
+
...Mi(i.result, r, this._sessionId),
|
|
5909
5918
|
isLoading: !s.isConnected,
|
|
5910
5919
|
error: s.error
|
|
5911
5920
|
};
|
|
@@ -5961,7 +5970,7 @@ class oo {
|
|
|
5961
5970
|
}
|
|
5962
5971
|
_notifyPresenceSub(e, n) {
|
|
5963
5972
|
const r = this.getPresence("", e, n);
|
|
5964
|
-
r && (n.prev && !
|
|
5973
|
+
r && (n.prev && !Ii(r, n.prev) || (n.prev = r, n.cb(r)));
|
|
5965
5974
|
}
|
|
5966
5975
|
_patchPresencePeers(e, n) {
|
|
5967
5976
|
var o, a, c;
|
|
@@ -6037,7 +6046,7 @@ class oo {
|
|
|
6037
6046
|
async uploadFile(e, n, r) {
|
|
6038
6047
|
var o;
|
|
6039
6048
|
const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
|
|
6040
|
-
return
|
|
6049
|
+
return Ai({
|
|
6041
6050
|
...r,
|
|
6042
6051
|
apiURI: this.config.apiURI,
|
|
6043
6052
|
appId: this.config.appId,
|
|
@@ -6049,7 +6058,7 @@ class oo {
|
|
|
6049
6058
|
async deleteFile(e) {
|
|
6050
6059
|
var i;
|
|
6051
6060
|
const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
|
|
6052
|
-
return await
|
|
6061
|
+
return await vi({
|
|
6053
6062
|
apiURI: this.config.apiURI,
|
|
6054
6063
|
appId: this.config.appId,
|
|
6055
6064
|
path: e,
|
|
@@ -6060,18 +6069,18 @@ class oo {
|
|
|
6060
6069
|
// ---------------------------------
|
|
6061
6070
|
async upload(e, n) {
|
|
6062
6071
|
var c;
|
|
6063
|
-
const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await
|
|
6072
|
+
const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await ki({
|
|
6064
6073
|
apiURI: this.config.apiURI,
|
|
6065
6074
|
appId: this.config.appId,
|
|
6066
6075
|
fileName: i,
|
|
6067
6076
|
refreshToken: s
|
|
6068
6077
|
});
|
|
6069
|
-
return await
|
|
6078
|
+
return await Ei(o, n);
|
|
6070
6079
|
}
|
|
6071
6080
|
async getDownloadUrl(e) {
|
|
6072
6081
|
var i;
|
|
6073
6082
|
const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
|
|
6074
|
-
return await
|
|
6083
|
+
return await Ci({
|
|
6075
6084
|
apiURI: this.config.apiURI,
|
|
6076
6085
|
appId: this.config.appId,
|
|
6077
6086
|
path: e,
|
|
@@ -6079,7 +6088,7 @@ class oo {
|
|
|
6079
6088
|
});
|
|
6080
6089
|
}
|
|
6081
6090
|
}
|
|
6082
|
-
function
|
|
6091
|
+
function co(t, e) {
|
|
6083
6092
|
return new $e(
|
|
6084
6093
|
Qn(t, e),
|
|
6085
6094
|
// (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
|
|
@@ -6091,25 +6100,25 @@ function ao(t, e) {
|
|
|
6091
6100
|
void 0
|
|
6092
6101
|
);
|
|
6093
6102
|
}
|
|
6094
|
-
function
|
|
6103
|
+
function uo(t) {
|
|
6095
6104
|
return new je(t, {});
|
|
6096
6105
|
}
|
|
6097
|
-
function
|
|
6106
|
+
function lo() {
|
|
6098
6107
|
return new $("string", !0, !1);
|
|
6099
6108
|
}
|
|
6100
|
-
function
|
|
6109
|
+
function fo() {
|
|
6101
6110
|
return new $("number", !0, !1);
|
|
6102
6111
|
}
|
|
6103
|
-
function
|
|
6112
|
+
function ho() {
|
|
6104
6113
|
return new $("boolean", !0, !1);
|
|
6105
6114
|
}
|
|
6106
|
-
function
|
|
6115
|
+
function po() {
|
|
6107
6116
|
return new $("date", !0, !1);
|
|
6108
6117
|
}
|
|
6109
|
-
function
|
|
6118
|
+
function yo() {
|
|
6110
6119
|
return new $("json", !0, !1);
|
|
6111
6120
|
}
|
|
6112
|
-
function
|
|
6121
|
+
function bo() {
|
|
6113
6122
|
return new $("json", !0, !1);
|
|
6114
6123
|
}
|
|
6115
6124
|
function Qn(t, e) {
|
|
@@ -6133,7 +6142,7 @@ function Qn(t, e) {
|
|
|
6133
6142
|
])
|
|
6134
6143
|
);
|
|
6135
6144
|
}
|
|
6136
|
-
function
|
|
6145
|
+
function _o({
|
|
6137
6146
|
entities: t,
|
|
6138
6147
|
links: e,
|
|
6139
6148
|
rooms: n
|
|
@@ -6150,23 +6159,23 @@ function bo({
|
|
|
6150
6159
|
s
|
|
6151
6160
|
);
|
|
6152
6161
|
}
|
|
6153
|
-
const
|
|
6162
|
+
const Uo = {
|
|
6154
6163
|
// constructs
|
|
6155
|
-
graph:
|
|
6156
|
-
schema:
|
|
6157
|
-
entity:
|
|
6164
|
+
graph: co,
|
|
6165
|
+
schema: _o,
|
|
6166
|
+
entity: uo,
|
|
6158
6167
|
// value types
|
|
6159
|
-
string:
|
|
6160
|
-
number:
|
|
6161
|
-
boolean:
|
|
6162
|
-
date:
|
|
6163
|
-
json:
|
|
6164
|
-
any:
|
|
6168
|
+
string: lo,
|
|
6169
|
+
number: fo,
|
|
6170
|
+
boolean: ho,
|
|
6171
|
+
date: po,
|
|
6172
|
+
json: yo,
|
|
6173
|
+
any: bo
|
|
6165
6174
|
};
|
|
6166
6175
|
let we;
|
|
6167
|
-
function
|
|
6176
|
+
function go(t, e) {
|
|
6168
6177
|
we == null || we.dispose();
|
|
6169
|
-
const n =
|
|
6178
|
+
const n = Ao(e), r = mo(e, a), s = To(wo(t));
|
|
6170
6179
|
function i(l) {
|
|
6171
6180
|
var f;
|
|
6172
6181
|
l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
|
|
@@ -6188,10 +6197,10 @@ function _o(t, e) {
|
|
|
6188
6197
|
}
|
|
6189
6198
|
return u();
|
|
6190
6199
|
}
|
|
6191
|
-
function
|
|
6200
|
+
function wo(t) {
|
|
6192
6201
|
return `${_t || Un ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
6193
6202
|
}
|
|
6194
|
-
function
|
|
6203
|
+
function To(t) {
|
|
6195
6204
|
const e = document.createElement("iframe");
|
|
6196
6205
|
return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
6197
6206
|
width: "100%",
|
|
@@ -6200,7 +6209,7 @@ function wo(t) {
|
|
|
6200
6209
|
border: "none"
|
|
6201
6210
|
}), { element: e };
|
|
6202
6211
|
}
|
|
6203
|
-
function
|
|
6212
|
+
function mo(t, e) {
|
|
6204
6213
|
const n = `
|
|
6205
6214
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6206
6215
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -6210,7 +6219,7 @@ function To(t, e) {
|
|
|
6210
6219
|
return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
|
|
6211
6220
|
// pos
|
|
6212
6221
|
position: "fixed",
|
|
6213
|
-
...
|
|
6222
|
+
...So(t.position),
|
|
6214
6223
|
height: "32px",
|
|
6215
6224
|
width: "32px",
|
|
6216
6225
|
// layout
|
|
@@ -6225,7 +6234,7 @@ function To(t, e) {
|
|
|
6225
6234
|
cursor: "pointer"
|
|
6226
6235
|
}), r.addEventListener("click", e), { element: r };
|
|
6227
6236
|
}
|
|
6228
|
-
function
|
|
6237
|
+
function So(t) {
|
|
6229
6238
|
switch (t) {
|
|
6230
6239
|
case "bottom-left":
|
|
6231
6240
|
return { bottom: "24px", left: "24px" };
|
|
@@ -6237,7 +6246,7 @@ function mo(t) {
|
|
|
6237
6246
|
return { top: "24px", left: "24px" };
|
|
6238
6247
|
}
|
|
6239
6248
|
}
|
|
6240
|
-
function
|
|
6249
|
+
function Oo(t) {
|
|
6241
6250
|
switch (t) {
|
|
6242
6251
|
case "bottom-left":
|
|
6243
6252
|
return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
|
|
@@ -6249,11 +6258,11 @@ function So(t) {
|
|
|
6249
6258
|
return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
|
|
6250
6259
|
}
|
|
6251
6260
|
}
|
|
6252
|
-
function
|
|
6261
|
+
function Ao(t) {
|
|
6253
6262
|
const e = document.createElement("div");
|
|
6254
6263
|
Object.assign(e.style, {
|
|
6255
6264
|
position: "fixed",
|
|
6256
|
-
...
|
|
6265
|
+
...Oo(t.position),
|
|
6257
6266
|
display: "block",
|
|
6258
6267
|
borderRadius: "4px",
|
|
6259
6268
|
border: "1px #ccc solid",
|
|
@@ -6266,37 +6275,37 @@ function Oo(t) {
|
|
|
6266
6275
|
}
|
|
6267
6276
|
return { element: e, isVisible: n };
|
|
6268
6277
|
}
|
|
6269
|
-
const
|
|
6278
|
+
const vo = {
|
|
6270
6279
|
apiURI: "https://api.instantdb.com",
|
|
6271
6280
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
6272
6281
|
};
|
|
6273
|
-
function
|
|
6282
|
+
function ko() {
|
|
6274
6283
|
return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
6275
6284
|
}
|
|
6276
|
-
function
|
|
6285
|
+
function Eo() {
|
|
6277
6286
|
return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
|
|
6278
6287
|
}
|
|
6279
6288
|
function rt(t) {
|
|
6280
6289
|
const e = t.__adminToken;
|
|
6281
6290
|
return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
|
|
6282
6291
|
}
|
|
6283
|
-
const st =
|
|
6284
|
-
class
|
|
6292
|
+
const st = Eo(), en = ko();
|
|
6293
|
+
class Co {
|
|
6285
6294
|
constructor(e) {
|
|
6286
6295
|
this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
|
|
6287
6296
|
}
|
|
6288
6297
|
}
|
|
6289
|
-
class
|
|
6298
|
+
class Mo {
|
|
6290
6299
|
constructor(e) {
|
|
6291
6300
|
this.db = e, this.uploadFile = (n, r, s = {}) => this.db.uploadFile(n, r, s), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
|
|
6292
6301
|
}
|
|
6293
6302
|
}
|
|
6294
|
-
function
|
|
6303
|
+
function Lo(t) {
|
|
6295
6304
|
return JSON.parse(JSON.stringify(t));
|
|
6296
6305
|
}
|
|
6297
|
-
class
|
|
6306
|
+
class Io {
|
|
6298
6307
|
constructor(e) {
|
|
6299
|
-
this.tx = Pn(), this._reactor = e, this.auth = new
|
|
6308
|
+
this.tx = Pn(), this._reactor = e, this.auth = new Co(this._reactor), this.storage = new Mo(this._reactor);
|
|
6300
6309
|
}
|
|
6301
6310
|
/**
|
|
6302
6311
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -6479,19 +6488,19 @@ function tn(t) {
|
|
|
6479
6488
|
const n = P(t);
|
|
6480
6489
|
return en.set(t, n), n;
|
|
6481
6490
|
}
|
|
6482
|
-
function
|
|
6491
|
+
function Po(t, e) {
|
|
6483
6492
|
return tn(t._reactor.config.schema) !== tn(e);
|
|
6484
6493
|
}
|
|
6485
|
-
function
|
|
6494
|
+
function jo(t, e, n, r, s) {
|
|
6486
6495
|
const i = {
|
|
6487
6496
|
...t,
|
|
6488
6497
|
useDateObjects: t.useDateObjects ?? !1
|
|
6489
6498
|
}, o = st[rt(i)];
|
|
6490
6499
|
if (o)
|
|
6491
|
-
return
|
|
6492
|
-
const a = new
|
|
6500
|
+
return Po(o, i.schema) && o._reactor.updateSchema(i.schema), o;
|
|
6501
|
+
const a = new ao(
|
|
6493
6502
|
{
|
|
6494
|
-
...
|
|
6503
|
+
...vo,
|
|
6495
6504
|
...i,
|
|
6496
6505
|
cardinalityInference: !!i.schema
|
|
6497
6506
|
},
|
|
@@ -6499,10 +6508,10 @@ function Po(t, e, n, r, s) {
|
|
|
6499
6508
|
n || Rn,
|
|
6500
6509
|
{ ...r || {}, "@instantdb/core": Fn },
|
|
6501
6510
|
s
|
|
6502
|
-
), c = new
|
|
6503
|
-
return st[rt(i)] = c,
|
|
6511
|
+
), c = new Io(a);
|
|
6512
|
+
return st[rt(i)] = c, $o(i.appId, i.devtool), c;
|
|
6504
6513
|
}
|
|
6505
|
-
function
|
|
6514
|
+
function $o(t, e) {
|
|
6506
6515
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
6507
6516
|
return;
|
|
6508
6517
|
const n = {
|
|
@@ -6510,33 +6519,33 @@ function jo(t, e) {
|
|
|
6510
6519
|
allowedHosts: ["localhost"],
|
|
6511
6520
|
...typeof e == "object" ? e : {}
|
|
6512
6521
|
};
|
|
6513
|
-
n.allowedHosts.includes(window.location.hostname) &&
|
|
6522
|
+
n.allowedHosts.includes(window.location.hostname) && go(t, n);
|
|
6514
6523
|
}
|
|
6515
|
-
const
|
|
6524
|
+
const Fo = jo;
|
|
6516
6525
|
export {
|
|
6517
|
-
|
|
6526
|
+
Co as Auth,
|
|
6518
6527
|
Dn as IndexedDBStorage,
|
|
6519
6528
|
Pe as InstantAPIError,
|
|
6520
|
-
|
|
6529
|
+
Io as InstantCoreDatabase,
|
|
6521
6530
|
he as InstantError,
|
|
6522
6531
|
O as QueryValidationError,
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6532
|
+
Mo as Storage,
|
|
6533
|
+
fi as StorageInterface,
|
|
6534
|
+
Bi as SyncTableCallbackEventType,
|
|
6526
6535
|
F as TransactionValidationError,
|
|
6527
6536
|
Rn as WindowNetworkListener,
|
|
6528
|
-
|
|
6537
|
+
Lo as coerceQuery,
|
|
6529
6538
|
Me as coerceToDate,
|
|
6530
|
-
|
|
6531
|
-
|
|
6539
|
+
Fs as getOps,
|
|
6540
|
+
Uo as i,
|
|
6532
6541
|
k as id,
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6542
|
+
jo as init,
|
|
6543
|
+
Fo as init_experimental,
|
|
6544
|
+
Ro as lookup,
|
|
6545
|
+
xo as tx,
|
|
6537
6546
|
Pn as txInit,
|
|
6538
6547
|
Qt as validateQuery,
|
|
6539
|
-
|
|
6548
|
+
Ni as validateTransactions,
|
|
6540
6549
|
Fn as version,
|
|
6541
6550
|
P as weakHash
|
|
6542
6551
|
};
|