@instantdb/solidjs 0.22.155 → 0.22.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/dist/standalone/index.js +110 -100
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +3 -3
package/dist/standalone/index.js
CHANGED
|
@@ -880,9 +880,9 @@ const Vr = (t) => function e(n, r, s) {
|
|
|
880
880
|
for (const I of l.mark) {
|
|
881
881
|
if (typeof I != "function")
|
|
882
882
|
throw new Error(`Invalid mark: ${I}, 'mark' should be a function.`);
|
|
883
|
-
const
|
|
884
|
-
if (
|
|
885
|
-
return
|
|
883
|
+
const E = I(T, v);
|
|
884
|
+
if (E)
|
|
885
|
+
return E;
|
|
886
886
|
}
|
|
887
887
|
} : l.mark, p = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, y = (o = l.strict) !== null && o !== void 0 ? o : !1, w = {
|
|
888
888
|
enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
|
|
@@ -909,9 +909,9 @@ const Vr = (t) => function e(n, r, s) {
|
|
|
909
909
|
if (!we(T)) {
|
|
910
910
|
if (T !== void 0 && !fe(T, _) && (v != null && v.operated))
|
|
911
911
|
throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
|
|
912
|
-
const
|
|
913
|
-
if (
|
|
914
|
-
const D =
|
|
912
|
+
const E = T == null ? void 0 : T[Dr];
|
|
913
|
+
if (E) {
|
|
914
|
+
const D = E[0];
|
|
915
915
|
return w.strict && typeof T == "object" && T !== null && It({
|
|
916
916
|
rootDraft: v,
|
|
917
917
|
value: T,
|
|
@@ -1301,7 +1301,7 @@ function us(t, e) {
|
|
|
1301
1301
|
return null;
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
|
-
function
|
|
1304
|
+
function Ct(t) {
|
|
1305
1305
|
for (const e of cs) {
|
|
1306
1306
|
const n = us(e, t);
|
|
1307
1307
|
if (n)
|
|
@@ -1312,7 +1312,7 @@ function Et(t) {
|
|
|
1312
1312
|
function ls(t) {
|
|
1313
1313
|
try {
|
|
1314
1314
|
const e = JSON.parse(t);
|
|
1315
|
-
return typeof e == "string" ?
|
|
1315
|
+
return typeof e == "string" ? Ct(e) : null;
|
|
1316
1316
|
} catch {
|
|
1317
1317
|
return null;
|
|
1318
1318
|
}
|
|
@@ -1324,7 +1324,7 @@ function ot(t) {
|
|
|
1324
1324
|
if (t instanceof Date)
|
|
1325
1325
|
return t;
|
|
1326
1326
|
if (typeof t == "string") {
|
|
1327
|
-
const e =
|
|
1327
|
+
const e = Ct(t) || ls(t) || Ct(t.trim());
|
|
1328
1328
|
if (!e)
|
|
1329
1329
|
throw new Error(`Unable to parse \`${t}\` as a date.`);
|
|
1330
1330
|
return e;
|
|
@@ -1417,7 +1417,7 @@ function Gt(t) {
|
|
|
1417
1417
|
function Ht(t) {
|
|
1418
1418
|
return t["value-type"] === "blob";
|
|
1419
1419
|
}
|
|
1420
|
-
function
|
|
1420
|
+
function Ce(t, e) {
|
|
1421
1421
|
return e.reduce((n, r) => n && n.get(r), t);
|
|
1422
1422
|
}
|
|
1423
1423
|
function ee(t, e) {
|
|
@@ -1471,7 +1471,7 @@ function Hn(t, e) {
|
|
|
1471
1471
|
return new ge(e.attrs, e.linkIndex);
|
|
1472
1472
|
}
|
|
1473
1473
|
function ds(t, e) {
|
|
1474
|
-
return
|
|
1474
|
+
return Ce(t.eav, [e]) !== void 0;
|
|
1475
1475
|
}
|
|
1476
1476
|
function je(t, e, n, r) {
|
|
1477
1477
|
const s = Qn(t, e, r);
|
|
@@ -1515,7 +1515,7 @@ let hs = 0;
|
|
|
1515
1515
|
function Yn(t, e, n) {
|
|
1516
1516
|
const [r, s, i] = n;
|
|
1517
1517
|
let o;
|
|
1518
|
-
const a =
|
|
1518
|
+
const a = Ce(t.eav, [r, s, i]);
|
|
1519
1519
|
return a && (o = a[3]), o || Date.now() * 10 + hs++;
|
|
1520
1520
|
}
|
|
1521
1521
|
function Zn(t, e, n) {
|
|
@@ -1527,7 +1527,7 @@ function Zn(t, e, n) {
|
|
|
1527
1527
|
if (!a)
|
|
1528
1528
|
return;
|
|
1529
1529
|
a["checked-data-type"] === "date" && t.useDateObjects && (o = ot(o));
|
|
1530
|
-
const c =
|
|
1530
|
+
const c = Ce(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Yn(t, a, r), l = [s, i, o, u];
|
|
1531
1531
|
fs(a) ? (W(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), W(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (W(t.eav, [s, i, o], l), W(t.aev, [i, s, o], l)), Gt(a) && W(t.vae, [o, i, s], l);
|
|
1532
1532
|
}
|
|
1533
1533
|
function ps(t, e, n) {
|
|
@@ -1540,7 +1540,7 @@ function ps(t, e, n) {
|
|
|
1540
1540
|
return;
|
|
1541
1541
|
if (!Ht(a))
|
|
1542
1542
|
throw new Error("merge operation is not supported for links");
|
|
1543
|
-
const c =
|
|
1543
|
+
const c = Ce(t.eav, [s, i]);
|
|
1544
1544
|
if (!c)
|
|
1545
1545
|
return;
|
|
1546
1546
|
const u = (p = c.values().next()) == null ? void 0 : p.value;
|
|
@@ -1554,7 +1554,7 @@ function ps(t, e, n) {
|
|
|
1554
1554
|
];
|
|
1555
1555
|
W(t.eav, [s, i], /* @__PURE__ */ new Map([[f, h]])), W(t.aev, [i, s], /* @__PURE__ */ new Map([[f, h]]));
|
|
1556
1556
|
}
|
|
1557
|
-
function
|
|
1557
|
+
function Et(t, e, n) {
|
|
1558
1558
|
var u, l;
|
|
1559
1559
|
const [r, s] = n, i = Ne(t, [r]);
|
|
1560
1560
|
if (!i)
|
|
@@ -1565,7 +1565,7 @@ function Ct(t, e, n) {
|
|
|
1565
1565
|
const h = e.getAttr(f);
|
|
1566
1566
|
h && h["on-delete-reverse"] === "cascade" && V(a.get(f), 1).forEach(([p, y, g]) => {
|
|
1567
1567
|
var w;
|
|
1568
|
-
return
|
|
1568
|
+
return Et(t, e, [g, (w = h["reverse-identity"]) == null ? void 0 : w[1]]);
|
|
1569
1569
|
}), // Fall back to deleting everything if we've rehydrated tx-steps from
|
|
1570
1570
|
// the store that didn't set `etype` in deleteEntity
|
|
1571
1571
|
(!s || // If we don't know about the attr, let's just get rid of it
|
|
@@ -1578,7 +1578,7 @@ function Ct(t, e, n) {
|
|
|
1578
1578
|
c && c.forEach((f) => {
|
|
1579
1579
|
var w, _, b;
|
|
1580
1580
|
const [h, p, y] = f, g = e.getAttr(p);
|
|
1581
|
-
(!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (ee(t.eav, [h, p, y]), ee(t.aev, [p, h, y]), ee(t.vae, [y, p, h])), g && g["on-delete"] === "cascade" && ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s &&
|
|
1581
|
+
(!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (ee(t.eav, [h, p, y]), ee(t.aev, [p, h, y]), ee(t.vae, [y, p, h])), g && g["on-delete"] === "cascade" && ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s && Et(t, e, [h, (b = g["forward-identity"]) == null ? void 0 : b[1]]);
|
|
1582
1582
|
}), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && ee(t.vae, [o]);
|
|
1583
1583
|
}
|
|
1584
1584
|
function Xn(t, e, n) {
|
|
@@ -1615,7 +1615,7 @@ function ws(t, e, n) {
|
|
|
1615
1615
|
Jn(t, e, s);
|
|
1616
1616
|
break;
|
|
1617
1617
|
case "delete-entity":
|
|
1618
|
-
|
|
1618
|
+
Et(t, e, s);
|
|
1619
1619
|
break;
|
|
1620
1620
|
case "add-attr":
|
|
1621
1621
|
ys(e, s);
|
|
@@ -1765,7 +1765,7 @@ function vs(t, e, n) {
|
|
|
1765
1765
|
return;
|
|
1766
1766
|
const [s, i, o] = r;
|
|
1767
1767
|
if (e.getAttr(i))
|
|
1768
|
-
return
|
|
1768
|
+
return Ce(t.eav, [s, i]);
|
|
1769
1769
|
}
|
|
1770
1770
|
function As(t, e, n) {
|
|
1771
1771
|
const r = n.filter(([s, i, o, a, c]) => {
|
|
@@ -1818,7 +1818,7 @@ function Is(t) {
|
|
|
1818
1818
|
return un;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
|
-
const
|
|
1821
|
+
const Cs = [
|
|
1822
1822
|
"in",
|
|
1823
1823
|
"$in",
|
|
1824
1824
|
"$not",
|
|
@@ -1826,14 +1826,14 @@ const Es = [
|
|
|
1826
1826
|
"$comparator"
|
|
1827
1827
|
// covers all of $gt, $lt, etc.
|
|
1828
1828
|
];
|
|
1829
|
-
function
|
|
1830
|
-
for (const e of
|
|
1829
|
+
function Es(t) {
|
|
1830
|
+
for (const e of Cs)
|
|
1831
1831
|
if (t.hasOwnProperty(e))
|
|
1832
1832
|
return !0;
|
|
1833
1833
|
return !1;
|
|
1834
1834
|
}
|
|
1835
1835
|
function nr(t, e, n) {
|
|
1836
|
-
return n ? typeof t == "object" ?
|
|
1836
|
+
return n ? typeof t == "object" ? Es(t) ? n : null : Is(t)(t, e, n) : null;
|
|
1837
1837
|
}
|
|
1838
1838
|
function Ps(t, e, n) {
|
|
1839
1839
|
return t.reduce((r, s, i) => {
|
|
@@ -2233,8 +2233,8 @@ function yi(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
|
|
|
2233
2233
|
if (f && ((g = f == null ? void 0 : f["forward-identity"]) == null ? void 0 : g[2]) !== "id") {
|
|
2234
2234
|
const w = f["checked-data-type"] === "date", _ = f.id;
|
|
2235
2235
|
u = u.map(([b]) => {
|
|
2236
|
-
var A, T, v, I,
|
|
2237
|
-
let m = (
|
|
2236
|
+
var A, T, v, I, E;
|
|
2237
|
+
let m = (E = (I = (v = (T = (A = t.eav.get(b)) == null ? void 0 : A.get(_)) == null ? void 0 : T.values()) == null ? void 0 : v.next()) == null ? void 0 : I.value) == null ? void 0 : E[2];
|
|
2238
2238
|
return w && (m = jt(m)), [b, m];
|
|
2239
2239
|
});
|
|
2240
2240
|
}
|
|
@@ -2423,7 +2423,7 @@ function $t(t) {
|
|
|
2423
2423
|
throw new Error(`${t} is not a valid lookup attribute.`);
|
|
2424
2424
|
return e;
|
|
2425
2425
|
}
|
|
2426
|
-
function
|
|
2426
|
+
function Ci(t, e, n) {
|
|
2427
2427
|
if (!Ii(t, e, n))
|
|
2428
2428
|
return j(t, e, n);
|
|
2429
2429
|
const r = $t(n), s = j(t, e, r) || me(t, e, r);
|
|
@@ -2438,7 +2438,7 @@ function Q(t, e, n) {
|
|
|
2438
2438
|
const r = Rt(n);
|
|
2439
2439
|
if (r === null)
|
|
2440
2440
|
return n;
|
|
2441
|
-
const [s, i] = r, o =
|
|
2441
|
+
const [s, i] = r, o = Ci(t, e, s);
|
|
2442
2442
|
if (!o || !o["unique?"])
|
|
2443
2443
|
throw new Error(`${s} is not a unique attribute.`);
|
|
2444
2444
|
return [o.id, i];
|
|
@@ -2453,7 +2453,7 @@ function cr(t, e, n, r) {
|
|
|
2453
2453
|
s
|
|
2454
2454
|
]].concat(r) : r;
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2456
|
+
function Ei({ attrsStore: t }, [e, n, r]) {
|
|
2457
2457
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2458
2458
|
const a = Array.isArray(o) ? o : [o], c = j(t, e, i), u = me(t, e, i);
|
|
2459
2459
|
return a.map((l) => c ? [
|
|
@@ -2583,7 +2583,7 @@ function Li(t, e) {
|
|
|
2583
2583
|
case "update":
|
|
2584
2584
|
return Di(t, r);
|
|
2585
2585
|
case "link":
|
|
2586
|
-
return
|
|
2586
|
+
return Ei(t, r);
|
|
2587
2587
|
case "unlink":
|
|
2588
2588
|
return Pi(t, r);
|
|
2589
2589
|
case "delete":
|
|
@@ -3242,12 +3242,13 @@ class fr {
|
|
|
3242
3242
|
}
|
|
3243
3243
|
}
|
|
3244
3244
|
class K extends Error {
|
|
3245
|
-
constructor(n, r) {
|
|
3245
|
+
constructor(n, r, s) {
|
|
3246
3246
|
super(n);
|
|
3247
3247
|
d(this, "hint");
|
|
3248
|
-
this
|
|
3249
|
-
|
|
3250
|
-
|
|
3248
|
+
d(this, "traceId");
|
|
3249
|
+
this.hint = r, s && (this.traceId = s);
|
|
3250
|
+
const i = new.target.prototype;
|
|
3251
|
+
Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, K), this.name = "InstantError";
|
|
3251
3252
|
}
|
|
3252
3253
|
get [Symbol.toStringTag]() {
|
|
3253
3254
|
return "InstantError";
|
|
@@ -3257,7 +3258,7 @@ class ct extends K {
|
|
|
3257
3258
|
constructor(n) {
|
|
3258
3259
|
var i;
|
|
3259
3260
|
const r = ((i = n.body) == null ? void 0 : i.message) || `API Error (${n.status})`;
|
|
3260
|
-
super(r, n.body.hint);
|
|
3261
|
+
super(r, n.body.hint, n.body["trace-id"]);
|
|
3261
3262
|
d(this, "body");
|
|
3262
3263
|
d(this, "status");
|
|
3263
3264
|
const s = new.target.prototype;
|
|
@@ -3480,7 +3481,7 @@ function An(t) {
|
|
|
3480
3481
|
}, e;
|
|
3481
3482
|
}, {});
|
|
3482
3483
|
}
|
|
3483
|
-
const Xt = "v0.22.
|
|
3484
|
+
const Xt = "v0.22.156";
|
|
3484
3485
|
function wo(t, e) {
|
|
3485
3486
|
return {
|
|
3486
3487
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
@@ -3564,7 +3565,7 @@ class lt {
|
|
|
3564
3565
|
return new lt(this.entities, this.links, {});
|
|
3565
3566
|
}
|
|
3566
3567
|
}
|
|
3567
|
-
class
|
|
3568
|
+
class C extends Error {
|
|
3568
3569
|
constructor(e, n) {
|
|
3569
3570
|
const r = n ? `At path '${n}': ${e}` : e;
|
|
3570
3571
|
super(r), this.name = "QueryValidationError";
|
|
@@ -3599,13 +3600,13 @@ const On = [
|
|
|
3599
3600
|
}, mo = (t, e, n, r, s, i, o) => {
|
|
3600
3601
|
const a = i.valueType === "json", c = (u, l, f) => {
|
|
3601
3602
|
if (!yr(f, l, a))
|
|
3602
|
-
throw new
|
|
3603
|
+
throw new C(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
|
|
3603
3604
|
};
|
|
3604
3605
|
switch (t) {
|
|
3605
3606
|
case "in":
|
|
3606
3607
|
case "$in":
|
|
3607
3608
|
if (!Array.isArray(e))
|
|
3608
|
-
throw new
|
|
3609
|
+
throw new C(`Operator '${t}' for attribute '${r}' in entity '${s}' must be an array, but received: ${typeof e}`, o);
|
|
3609
3610
|
for (const u of e)
|
|
3610
3611
|
c(t, n, u);
|
|
3611
3612
|
break;
|
|
@@ -3620,13 +3621,13 @@ const On = [
|
|
|
3620
3621
|
case "$like":
|
|
3621
3622
|
case "$ilike":
|
|
3622
3623
|
if (c(t, "string", e), t === "$ilike" && !i.isIndexed)
|
|
3623
|
-
throw new
|
|
3624
|
+
throw new C(`Operator '${t}' can only be used with indexed attributes, but '${r}' in entity '${s}' is not indexed`, o);
|
|
3624
3625
|
break;
|
|
3625
3626
|
case "$isNull":
|
|
3626
3627
|
c(t, "boolean", e);
|
|
3627
3628
|
break;
|
|
3628
3629
|
default:
|
|
3629
|
-
throw new
|
|
3630
|
+
throw new C(`Unknown operator '${t}' for attribute '${r}' in entity '${s}'`, o);
|
|
3630
3631
|
}
|
|
3631
3632
|
}, Oe = (t, e, n, r, s) => {
|
|
3632
3633
|
const i = _o(n), o = n.valueType === "json";
|
|
@@ -3637,42 +3638,42 @@ const On = [
|
|
|
3637
3638
|
for (const [u, l] of Object.entries(c))
|
|
3638
3639
|
mo(u, l, i, e, r, n, `${s}.${u}`);
|
|
3639
3640
|
} else if (!yr(t, i, o))
|
|
3640
|
-
throw new
|
|
3641
|
+
throw new C(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`, s);
|
|
3641
3642
|
}, To = (t, e, n, r, s) => {
|
|
3642
3643
|
const i = t.split(".");
|
|
3643
3644
|
if (i.length < 2)
|
|
3644
|
-
throw new
|
|
3645
|
+
throw new C(`Invalid dot notation path '${t}'. Must contain at least one dot.`, s);
|
|
3645
3646
|
let o = n;
|
|
3646
3647
|
for (let l = 0; l < i.length - 1; l++) {
|
|
3647
3648
|
const f = i[l], h = r.entities[o];
|
|
3648
3649
|
if (!h)
|
|
3649
|
-
throw new
|
|
3650
|
+
throw new C(`Entity '${o}' does not exist in schema while traversing dot notation path '${t}'.`, s);
|
|
3650
3651
|
const p = h.links[f];
|
|
3651
3652
|
if (!p) {
|
|
3652
3653
|
const y = Object.keys(h.links);
|
|
3653
|
-
throw new
|
|
3654
|
+
throw new C(`Link '${f}' does not exist on entity '${o}' in dot notation path '${t}'. Available links: ${y.length > 0 ? y.join(", ") : "none"}`, s);
|
|
3654
3655
|
}
|
|
3655
3656
|
o = p.entityName;
|
|
3656
3657
|
}
|
|
3657
3658
|
const a = i[i.length - 1], c = r.entities[o];
|
|
3658
3659
|
if (!c)
|
|
3659
|
-
throw new
|
|
3660
|
+
throw new C(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, s);
|
|
3660
3661
|
if (a === "id") {
|
|
3661
3662
|
if (typeof e == "string" && !ke(e))
|
|
3662
|
-
throw new
|
|
3663
|
+
throw new C(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3663
3664
|
Oe(e, t, new q("string", !1, !0), n, s);
|
|
3664
3665
|
return;
|
|
3665
3666
|
}
|
|
3666
3667
|
const u = c.attrs[a];
|
|
3667
3668
|
if (Object.keys(c.links).includes(a)) {
|
|
3668
3669
|
if (typeof e == "string" && !ke(e))
|
|
3669
|
-
throw new
|
|
3670
|
+
throw new C(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3670
3671
|
Oe(e, t, new q("string", !1, !0), n, s);
|
|
3671
3672
|
return;
|
|
3672
3673
|
}
|
|
3673
3674
|
if (!u) {
|
|
3674
3675
|
const l = Object.keys(c.attrs);
|
|
3675
|
-
throw new
|
|
3676
|
+
throw new C(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
|
|
3676
3677
|
}
|
|
3677
3678
|
Oe(e, t, u, n, s);
|
|
3678
3679
|
}, br = (t, e, n, r) => {
|
|
@@ -3697,13 +3698,13 @@ const On = [
|
|
|
3697
3698
|
const a = o.attrs[s], c = o.links[s];
|
|
3698
3699
|
if (!a && !c) {
|
|
3699
3700
|
const u = Object.keys(o.attrs), l = Object.keys(o.links);
|
|
3700
|
-
throw new
|
|
3701
|
+
throw new C(`Attribute or link '${s}' does not exist on entity '${e}'. Available attributes: ${u.length > 0 ? u.join(", ") : "none"}. Available links: ${l.length > 0 ? l.join(", ") : "none"}`, `${r}.${s}`);
|
|
3701
3702
|
}
|
|
3702
3703
|
if (a)
|
|
3703
3704
|
Oe(i, s, a, e, `${r}.${s}`);
|
|
3704
3705
|
else if (c) {
|
|
3705
3706
|
if (typeof i == "string" && !ke(i))
|
|
3706
|
-
throw new
|
|
3707
|
+
throw new C(`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`, `${r}.${s}`);
|
|
3707
3708
|
const u = new q("string", !1, !0);
|
|
3708
3709
|
Oe(i, s, u, e, `${r}.${s}`);
|
|
3709
3710
|
}
|
|
@@ -3711,7 +3712,7 @@ const On = [
|
|
|
3711
3712
|
}, So = (t, e, n, r, s = 0) => {
|
|
3712
3713
|
for (const o of Object.keys(t))
|
|
3713
3714
|
if (!On.includes(o))
|
|
3714
|
-
throw new
|
|
3715
|
+
throw new C(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${On.join(", ")}. Found: ${o}`, r);
|
|
3715
3716
|
const i = [
|
|
3716
3717
|
// 'limit', // only supported client side
|
|
3717
3718
|
"offset",
|
|
@@ -3722,21 +3723,21 @@ const On = [
|
|
|
3722
3723
|
];
|
|
3723
3724
|
for (const o of i)
|
|
3724
3725
|
if (t[o] !== void 0 && s > 0)
|
|
3725
|
-
throw new
|
|
3726
|
+
throw new C(`'${o}' can only be used on top-level namespaces. It cannot be used in nested queries.`, r);
|
|
3726
3727
|
if (t.where && n) {
|
|
3727
3728
|
if (typeof t.where != "object" || t.where === null)
|
|
3728
|
-
throw new
|
|
3729
|
+
throw new C(`'where' clause must be an object in entity '${e}', but received: ${typeof t.where}`, r ? `${r}.where` : void 0);
|
|
3729
3730
|
br(t.where, e, n, r ? `${r}.where` : "where");
|
|
3730
3731
|
}
|
|
3731
3732
|
}, gr = (t, e, n, r, s = 0) => {
|
|
3732
3733
|
var i;
|
|
3733
3734
|
if (!t || typeof t != "object")
|
|
3734
|
-
throw new
|
|
3735
|
+
throw new C(`Query part for entity '${e}' must be an object, but received: ${typeof t}`, r);
|
|
3735
3736
|
for (const o of Object.keys(t))
|
|
3736
3737
|
if (o !== "$") {
|
|
3737
3738
|
if (n && !(o in n.entities[e].links)) {
|
|
3738
3739
|
const c = Object.keys(n.entities[e].links);
|
|
3739
|
-
throw new
|
|
3740
|
+
throw new C(`Link '${o}' does not exist on entity '${e}'. Available links: ${c.length > 0 ? c.join(", ") : "none"}`, `${r}.${o}`);
|
|
3740
3741
|
}
|
|
3741
3742
|
const a = t[o];
|
|
3742
3743
|
if (typeof a == "object" && a !== null) {
|
|
@@ -3746,24 +3747,24 @@ const On = [
|
|
|
3746
3747
|
} else {
|
|
3747
3748
|
const a = t[o];
|
|
3748
3749
|
if (typeof a != "object" || a === null)
|
|
3749
|
-
throw new
|
|
3750
|
+
throw new C(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
|
|
3750
3751
|
So(a, e, n, `${r}.$`, s);
|
|
3751
3752
|
}
|
|
3752
3753
|
}, kn = (t, e) => {
|
|
3753
3754
|
if (typeof t != "object" || t === null)
|
|
3754
|
-
throw new
|
|
3755
|
+
throw new C(`Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`);
|
|
3755
3756
|
if (Array.isArray(t))
|
|
3756
|
-
throw new
|
|
3757
|
+
throw new C(`Query must be an object, but received: ${typeof t}`);
|
|
3757
3758
|
const n = t;
|
|
3758
3759
|
for (const r of Object.keys(n)) {
|
|
3759
3760
|
if (Array.isArray(t[r]))
|
|
3760
|
-
throw new
|
|
3761
|
+
throw new C(`Query keys must be strings, but found key of type: ${typeof r}`, r);
|
|
3761
3762
|
if (typeof r != "string")
|
|
3762
|
-
throw new
|
|
3763
|
+
throw new C(`Query keys must be strings, but found key of type: ${typeof r}`, r);
|
|
3763
3764
|
if (r !== "$$ruleParams") {
|
|
3764
3765
|
if (e && !e.entities[r]) {
|
|
3765
3766
|
const s = Object.keys(e.entities);
|
|
3766
|
-
throw new
|
|
3767
|
+
throw new C(`Entity '${r}' does not exist in schema. Available entities: ${s.length > 0 ? s.join(", ") : "none"}`, r);
|
|
3767
3768
|
}
|
|
3768
3769
|
gr(n[r], r, e, r, 0);
|
|
3769
3770
|
}
|
|
@@ -3799,7 +3800,7 @@ const wr = (t) => t.length > 0 ? t.join(", ") : "none", vo = (t, e) => new Y(`En
|
|
|
3799
3800
|
if (o && !Ao(i, o))
|
|
3800
3801
|
throw new Y(`Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`);
|
|
3801
3802
|
}
|
|
3802
|
-
},
|
|
3803
|
+
}, Cn = (t, e, n) => {
|
|
3803
3804
|
const r = _r(t, n);
|
|
3804
3805
|
if (typeof e != "object" || e === null)
|
|
3805
3806
|
throw new Y(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
|
|
@@ -3821,8 +3822,8 @@ const wr = (t) => t.length > 0 ? t.join(", ") : "none", vo = (t, e) => new Y(`En
|
|
|
3821
3822
|
create: wt,
|
|
3822
3823
|
update: wt,
|
|
3823
3824
|
merge: wt,
|
|
3824
|
-
link:
|
|
3825
|
-
unlink:
|
|
3825
|
+
link: Cn,
|
|
3826
|
+
unlink: Cn,
|
|
3826
3827
|
delete: () => {
|
|
3827
3828
|
}
|
|
3828
3829
|
}, ko = (t, e) => {
|
|
@@ -3850,7 +3851,7 @@ const wr = (t) => t.length > 0 ? t.join(", ") : "none", vo = (t, e) => new Y(`En
|
|
|
3850
3851
|
}
|
|
3851
3852
|
};
|
|
3852
3853
|
let mr = 0;
|
|
3853
|
-
class
|
|
3854
|
+
class En {
|
|
3854
3855
|
constructor(e) {
|
|
3855
3856
|
d(this, "type", "ws");
|
|
3856
3857
|
d(this, "conn");
|
|
@@ -3885,7 +3886,7 @@ class Cn {
|
|
|
3885
3886
|
return this.conn.send(JSON.stringify(e));
|
|
3886
3887
|
}
|
|
3887
3888
|
}
|
|
3888
|
-
class
|
|
3889
|
+
class Co {
|
|
3889
3890
|
constructor(e, n, r) {
|
|
3890
3891
|
d(this, "type", "sse");
|
|
3891
3892
|
d(this, "initParams", null);
|
|
@@ -3982,7 +3983,7 @@ class Eo {
|
|
|
3982
3983
|
this.handleClose();
|
|
3983
3984
|
}
|
|
3984
3985
|
}
|
|
3985
|
-
function
|
|
3986
|
+
function Eo(t, e) {
|
|
3986
3987
|
const n = t.values;
|
|
3987
3988
|
if (n) {
|
|
3988
3989
|
const r = Hn(n.attrsStore, null);
|
|
@@ -4022,7 +4023,7 @@ function Pn(t, e, n, r) {
|
|
|
4022
4023
|
const s = (o = j(n, t.table, "id")) == null ? void 0 : o.id;
|
|
4023
4024
|
if (!s)
|
|
4024
4025
|
return -1;
|
|
4025
|
-
const i =
|
|
4026
|
+
const i = Ce(e.eav, [r, s, r]);
|
|
4026
4027
|
return i ? i[3] : -1;
|
|
4027
4028
|
}
|
|
4028
4029
|
function Mn(t, e, n) {
|
|
@@ -4107,7 +4108,7 @@ class Ro {
|
|
|
4107
4108
|
persister: n,
|
|
4108
4109
|
merge: Mo,
|
|
4109
4110
|
serialize: Po,
|
|
4110
|
-
parse: (a, c) =>
|
|
4111
|
+
parse: (a, c) => Eo(c, this.config.useDateObjects),
|
|
4111
4112
|
objectSize: (a) => {
|
|
4112
4113
|
var c;
|
|
4113
4114
|
return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
|
|
@@ -4412,7 +4413,7 @@ function xo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4412
4413
|
} catch {
|
|
4413
4414
|
}
|
|
4414
4415
|
}
|
|
4415
|
-
function
|
|
4416
|
+
function E(S) {
|
|
4416
4417
|
return p.push(S), o && S(o), () => {
|
|
4417
4418
|
const k = p.indexOf(S);
|
|
4418
4419
|
k !== -1 && p.splice(k, 1);
|
|
@@ -4426,7 +4427,7 @@ function xo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4426
4427
|
function ae() {
|
|
4427
4428
|
g = !0;
|
|
4428
4429
|
}
|
|
4429
|
-
function
|
|
4430
|
+
function Ee(S) {
|
|
4430
4431
|
let k = w, F = 0, z = 0;
|
|
4431
4432
|
for (const { byteLen: X } of b) {
|
|
4432
4433
|
const ce = k + X;
|
|
@@ -4448,7 +4449,7 @@ function xo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4448
4449
|
switch (S.type) {
|
|
4449
4450
|
case "ok": {
|
|
4450
4451
|
const { streamId: k, offset: F } = S;
|
|
4451
|
-
o = k,
|
|
4452
|
+
o = k, Ee(F), b.length && r({
|
|
4452
4453
|
streamId: k,
|
|
4453
4454
|
chunks: b.map((z) => z.chunk),
|
|
4454
4455
|
offset: w
|
|
@@ -4469,7 +4470,7 @@ function xo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4469
4470
|
ae(), Z();
|
|
4470
4471
|
}
|
|
4471
4472
|
function re({ offset: S, done: k }) {
|
|
4472
|
-
|
|
4473
|
+
Ee(S), k && (l = !0, I());
|
|
4473
4474
|
}
|
|
4474
4475
|
function se(S) {
|
|
4475
4476
|
return l ? (B(S, new K("Stream has been closed.")), null) : o || (B(S, new K("Stream has not been initialized.")), null);
|
|
@@ -4528,7 +4529,7 @@ function xo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4528
4529
|
}, pt = (pe) => {
|
|
4529
4530
|
F(pe || new K("Stream is closed.")), X();
|
|
4530
4531
|
};
|
|
4531
|
-
z.push(
|
|
4532
|
+
z.push(E(ce)), z.push(T(pt));
|
|
4532
4533
|
});
|
|
4533
4534
|
}
|
|
4534
4535
|
}
|
|
@@ -4649,12 +4650,12 @@ function Lo({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
|
4649
4650
|
let v = s - T.offset;
|
|
4650
4651
|
if (T.files && T.files.length) {
|
|
4651
4652
|
const I = new AbortController();
|
|
4652
|
-
let
|
|
4653
|
+
let E = fetch(T.files[0].url, {
|
|
4653
4654
|
signal: I.signal
|
|
4654
4655
|
});
|
|
4655
4656
|
for (let D = 0; D < T.files.length; D++) {
|
|
4656
|
-
const ae = T.files[D + 1], B = await
|
|
4657
|
-
if (ae && (
|
|
4657
|
+
const ae = T.files[D + 1], B = await E;
|
|
4658
|
+
if (ae && (E = fetch(ae.url, { signal: I.signal })), !B.ok) {
|
|
4658
4659
|
if (y++, y > 10) {
|
|
4659
4660
|
p(m, new K("Unable to process stream."));
|
|
4660
4661
|
return;
|
|
@@ -4698,14 +4699,14 @@ function Lo({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
|
4698
4699
|
}
|
|
4699
4700
|
}
|
|
4700
4701
|
if (y = 0, T.content) {
|
|
4701
|
-
let I = T.content,
|
|
4702
|
+
let I = T.content, E = a.encode(T.content);
|
|
4702
4703
|
if (v > 0) {
|
|
4703
|
-
const D =
|
|
4704
|
-
if (v -=
|
|
4704
|
+
const D = E.subarray(v);
|
|
4705
|
+
if (v -= E.length - D.length, !D.length)
|
|
4705
4706
|
continue;
|
|
4706
|
-
|
|
4707
|
+
E = D, I = o.decode(D);
|
|
4707
4708
|
}
|
|
4708
|
-
s +=
|
|
4709
|
+
s += E.length, m.enqueue(I);
|
|
4709
4710
|
}
|
|
4710
4711
|
}
|
|
4711
4712
|
}
|
|
@@ -4910,12 +4911,12 @@ const ie = {
|
|
|
4910
4911
|
}, mt = "_instant_oauth_redirect", ve = "currentUser";
|
|
4911
4912
|
function Vo({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
|
|
4912
4913
|
if (!s)
|
|
4913
|
-
return new
|
|
4914
|
+
return new En(`${r}?app_id=${e}`);
|
|
4914
4915
|
switch (t) {
|
|
4915
4916
|
case "ws":
|
|
4916
|
-
return new
|
|
4917
|
+
return new En(`${r}?app_id=${e}`);
|
|
4917
4918
|
case "sse":
|
|
4918
|
-
return new
|
|
4919
|
+
return new Co(s, `${n}/runtime/sse?app_id=${e}`);
|
|
4919
4920
|
default:
|
|
4920
4921
|
throw new Error("Unknown transport type " + t);
|
|
4921
4922
|
}
|
|
@@ -5044,6 +5045,8 @@ class Zo {
|
|
|
5044
5045
|
d(this, "_pendingTxCleanupTimeout");
|
|
5045
5046
|
d(this, "_pendingMutationCleanupThreshold");
|
|
5046
5047
|
d(this, "_inFlightMutationEventIds", /* @__PURE__ */ new Set());
|
|
5048
|
+
/** @type FrameworkClient | null */
|
|
5049
|
+
d(this, "_frameworkClient", null);
|
|
5047
5050
|
d(this, "_onMergeKv", (e, n, r) => {
|
|
5048
5051
|
switch (e) {
|
|
5049
5052
|
case "pendingMutations": {
|
|
@@ -5223,6 +5226,13 @@ class Zo {
|
|
|
5223
5226
|
}), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
|
|
5224
5227
|
}
|
|
5225
5228
|
}
|
|
5229
|
+
getFrameworkClient() {
|
|
5230
|
+
return this._frameworkClient;
|
|
5231
|
+
}
|
|
5232
|
+
/** @param {FrameworkClient} client */
|
|
5233
|
+
setFrameworkClient(e) {
|
|
5234
|
+
this._frameworkClient = e;
|
|
5235
|
+
}
|
|
5226
5236
|
ensureAttrs() {
|
|
5227
5237
|
if (!this.attrs)
|
|
5228
5238
|
throw new Error("attrs have not loaded.");
|
|
@@ -5423,17 +5433,17 @@ class Zo {
|
|
|
5423
5433
|
});
|
|
5424
5434
|
const _ = Tt(w.entries()), b = p.map((m) => {
|
|
5425
5435
|
var J, re, se, Se;
|
|
5426
|
-
const A = m["instaql-query"], T = m["instaql-result"], v = x(A), I = vn(T),
|
|
5436
|
+
const A = m["instaql-query"], T = m["instaql-result"], v = x(A), I = vn(T), E = this.ensureAttrs(), D = je(E, I, r, this.config.useDateObjects), { store: ae, attrsStore: Ee } = this._applyOptimisticUpdates(D, E, _, g), B = (re = (J = T == null ? void 0 : T[0]) == null ? void 0 : J.data) == null ? void 0 : re["page-info"], Z = (Se = (se = T == null ? void 0 : T[0]) == null ? void 0 : se.data) == null ? void 0 : Se.aggregate;
|
|
5427
5437
|
return {
|
|
5428
5438
|
q: A,
|
|
5429
5439
|
hash: v,
|
|
5430
5440
|
store: ae,
|
|
5431
|
-
attrsStore:
|
|
5441
|
+
attrsStore: Ee,
|
|
5432
5442
|
pageInfo: B,
|
|
5433
5443
|
aggregate: Z
|
|
5434
5444
|
};
|
|
5435
5445
|
});
|
|
5436
|
-
b.forEach(({ hash: m, q: A, store: T, attrsStore: v, pageInfo: I, aggregate:
|
|
5446
|
+
b.forEach(({ hash: m, q: A, store: T, attrsStore: v, pageInfo: I, aggregate: E }) => {
|
|
5437
5447
|
this.querySubs.updateInPlace((D) => {
|
|
5438
5448
|
if (!D[m]) {
|
|
5439
5449
|
this._log.error("Missing value in querySubs", { hash: m, q: A });
|
|
@@ -5443,7 +5453,7 @@ class Zo {
|
|
|
5443
5453
|
store: T,
|
|
5444
5454
|
attrsStore: v,
|
|
5445
5455
|
pageInfo: I,
|
|
5446
|
-
aggregate:
|
|
5456
|
+
aggregate: E,
|
|
5447
5457
|
processedTxId: g
|
|
5448
5458
|
};
|
|
5449
5459
|
});
|
|
@@ -6066,7 +6076,7 @@ class Zo {
|
|
|
6066
6076
|
var r;
|
|
6067
6077
|
const { user: n } = await this.getCurrentUser();
|
|
6068
6078
|
if (!Ge(n, e)) {
|
|
6069
|
-
await this.setCurrentUser(e), await this.updateUser(e);
|
|
6079
|
+
this._frameworkClient = null, await this.setCurrentUser(e), await this.updateUser(e);
|
|
6070
6080
|
try {
|
|
6071
6081
|
await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
|
|
6072
6082
|
} catch (s) {
|
|
@@ -7078,11 +7088,11 @@ function ka(t, e) {
|
|
|
7078
7088
|
};
|
|
7079
7089
|
n.allowedHosts.includes(window.location.hostname) && ca(t, n);
|
|
7080
7090
|
}
|
|
7081
|
-
const Ia = !1,
|
|
7082
|
-
equals:
|
|
7091
|
+
const Ia = !1, Ca = (t, e) => t === e, tt = {
|
|
7092
|
+
equals: Ca
|
|
7083
7093
|
};
|
|
7084
7094
|
let Sr = kr;
|
|
7085
|
-
const Te = 1, nt = 2,
|
|
7095
|
+
const Te = 1, nt = 2, Ea = {};
|
|
7086
7096
|
var U = null;
|
|
7087
7097
|
let St = null, Pa = null, R = null, L = null, de = null, ft = 0;
|
|
7088
7098
|
function $e(t, e) {
|
|
@@ -7155,7 +7165,7 @@ function ja(t, e, n) {
|
|
|
7155
7165
|
try {
|
|
7156
7166
|
r = t.fn(e);
|
|
7157
7167
|
} catch (o) {
|
|
7158
|
-
return t.pure && (t.state = Te, t.owned && t.owned.forEach(it), t.owned = null), t.updatedAt = n + 1,
|
|
7168
|
+
return t.pure && (t.state = Te, t.owned && t.owned.forEach(it), t.owned = null), t.updatedAt = n + 1, Cr(o);
|
|
7159
7169
|
} finally {
|
|
7160
7170
|
R = i, U = s;
|
|
7161
7171
|
}
|
|
@@ -7175,7 +7185,7 @@ function Or(t, e, n, r = Te, s) {
|
|
|
7175
7185
|
context: U ? U.context : null,
|
|
7176
7186
|
pure: n
|
|
7177
7187
|
};
|
|
7178
|
-
return U === null || U !==
|
|
7188
|
+
return U === null || U !== Ea && (U.owned ? U.owned.push(i) : U.owned = [i]), i;
|
|
7179
7189
|
}
|
|
7180
7190
|
function rt(t) {
|
|
7181
7191
|
if (t.state === 0) return;
|
|
@@ -7200,7 +7210,7 @@ function ht(t, e) {
|
|
|
7200
7210
|
const r = t();
|
|
7201
7211
|
return Da(n), r;
|
|
7202
7212
|
} catch (r) {
|
|
7203
|
-
n || (de = null), L = null,
|
|
7213
|
+
n || (de = null), L = null, Cr(r);
|
|
7204
7214
|
}
|
|
7205
7215
|
}
|
|
7206
7216
|
function Da(t) {
|
|
@@ -7264,7 +7274,7 @@ function Ra(t) {
|
|
|
7264
7274
|
cause: t
|
|
7265
7275
|
});
|
|
7266
7276
|
}
|
|
7267
|
-
function
|
|
7277
|
+
function Cr(t, e = U) {
|
|
7268
7278
|
throw Ra(t);
|
|
7269
7279
|
}
|
|
7270
7280
|
const xa = 1e3;
|
|
@@ -7334,7 +7344,7 @@ function Na(t, e, n) {
|
|
|
7334
7344
|
}
|
|
7335
7345
|
function Ka(t, e, n = {}) {
|
|
7336
7346
|
let r = null;
|
|
7337
|
-
const s =
|
|
7347
|
+
const s = Er.usePresence(t, {
|
|
7338
7348
|
keys: [e]
|
|
7339
7349
|
}), i = en(() => {
|
|
7340
7350
|
if (n != null && n.writeOnly) return [];
|
|
@@ -7365,7 +7375,7 @@ function Ka(t, e, n = {}) {
|
|
|
7365
7375
|
} }
|
|
7366
7376
|
};
|
|
7367
7377
|
}
|
|
7368
|
-
const
|
|
7378
|
+
const Er = {
|
|
7369
7379
|
useTopicEffect: Ua,
|
|
7370
7380
|
usePublishTopic: La,
|
|
7371
7381
|
usePresence: Fa,
|
|
@@ -7573,7 +7583,7 @@ class Va {
|
|
|
7573
7583
|
* const presence = db.rooms.usePresence(room);
|
|
7574
7584
|
* const publish = db.rooms.usePublishTopic(room, 'emoji');
|
|
7575
7585
|
*/
|
|
7576
|
-
d(this, "rooms",
|
|
7586
|
+
d(this, "rooms", Er);
|
|
7577
7587
|
this.core = e, this.auth = this.core.auth, this.storage = this.core.storage;
|
|
7578
7588
|
}
|
|
7579
7589
|
/**
|