@instantdb/core 0.22.144 → 0.22.145

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.
@@ -234,7 +234,7 @@ function te(n) {
234
234
  function Lt() {
235
235
  throw new Error("Cannot modify frozen object");
236
236
  }
237
- function pe(n, e, t, r, s) {
237
+ function ye(n, e, t, r, s) {
238
238
  {
239
239
  t = t ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], s = s ?? [];
240
240
  const o = t.has(n) ? t.get(n) : n;
@@ -258,24 +258,24 @@ function pe(n, e, t, r, s) {
258
258
  switch (de(n)) {
259
259
  case 2:
260
260
  for (const [a, c] of n)
261
- pe(a, a, t, r, s), pe(c, a, t, r, s);
261
+ ye(a, a, t, r, s), ye(c, a, t, r, s);
262
262
  n.set = n.clear = n.delete = Lt;
263
263
  break;
264
264
  case 3:
265
265
  for (const a of n)
266
- pe(a, a, t, r, s);
266
+ ye(a, a, t, r, s);
267
267
  n.add = n.clear = n.delete = Lt;
268
268
  break;
269
269
  case 1:
270
270
  Object.freeze(n);
271
271
  let o = 0;
272
272
  for (const a of n)
273
- pe(a, o, t, r, s), o += 1;
273
+ ye(a, o, t, r, s), o += 1;
274
274
  break;
275
275
  default:
276
276
  Object.freeze(n), Object.keys(n).forEach((a) => {
277
277
  const c = n[a];
278
- pe(c, a, t, r, s);
278
+ ye(c, a, t, r, s);
279
279
  });
280
280
  }
281
281
  r.pop(), s.pop();
@@ -781,7 +781,7 @@ function mr(n, e, t, r, s) {
781
781
  for (; o.finalities.draft.length > 0; )
782
782
  o.finalities.draft.pop()(t, r);
783
783
  const u = c ? e[0] : o ? o.operated ? o.copy : o.original : n;
784
- return o && ot(o), s && pe(u, u, o == null ? void 0 : o.options.updatedValues), [
784
+ return o && ot(o), s && ye(u, u, o == null ? void 0 : o.options.updatedValues), [
785
785
  u,
786
786
  t && c ? [{ op: j.Replace, path: [], value: e[0] }] : t,
787
787
  r && c ? [{ op: j.Replace, path: [], value: a }] : r
@@ -1429,7 +1429,7 @@ function jt(n) {
1429
1429
  function Dt(n) {
1430
1430
  return n["value-type"] === "blob";
1431
1431
  }
1432
- function _e(n, e) {
1432
+ function we(n, e) {
1433
1433
  return e.reduce((t, r) => t && t.get(r), n);
1434
1434
  }
1435
1435
  function Y(n, e) {
@@ -1473,7 +1473,7 @@ function In(n) {
1473
1473
  };
1474
1474
  }
1475
1475
  function Cn(n, e) {
1476
- return ye(
1476
+ return be(
1477
1477
  n,
1478
1478
  e.triples,
1479
1479
  e.cardinalityInference,
@@ -1487,9 +1487,9 @@ function En(n, e) {
1487
1487
  return new ce(e.attrs, e.linkIndex);
1488
1488
  }
1489
1489
  function Nr(n, e) {
1490
- return _e(n.eav, [e]) !== void 0;
1490
+ return we(n.eav, [e]) !== void 0;
1491
1491
  }
1492
- function ye(n, e, t, r) {
1492
+ function be(n, e, t, r) {
1493
1493
  const s = On(
1494
1494
  n,
1495
1495
  e,
@@ -1535,7 +1535,7 @@ let qr = 0;
1535
1535
  function Pn(n, e, t) {
1536
1536
  const [r, s, i] = t;
1537
1537
  let o;
1538
- const a = _e(n.eav, [r, s, i]);
1538
+ const a = we(n.eav, [r, s, i]);
1539
1539
  return a && (o = a[3]), o || Date.now() * 10 + qr++;
1540
1540
  }
1541
1541
  function jn(n, e, t) {
@@ -1547,7 +1547,7 @@ function jn(n, e, t) {
1547
1547
  if (!a)
1548
1548
  return;
1549
1549
  a["checked-data-type"] === "date" && n.useDateObjects && (o = Be(o));
1550
- const c = _e(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Pn(n, a, r), l = [s, i, o, u];
1550
+ const c = we(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Pn(n, a, r), l = [s, i, o, u];
1551
1551
  Fr(a) ? (K(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), K(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (K(n.eav, [s, i, o], l), K(n.aev, [i, s, o], l)), jt(a) && K(n.vae, [o, i, s], l);
1552
1552
  }
1553
1553
  function Kr(n, e, t) {
@@ -1559,7 +1559,7 @@ function Kr(n, e, t) {
1559
1559
  if (!a) return;
1560
1560
  if (!Dt(a))
1561
1561
  throw new Error("merge operation is not supported for links");
1562
- const c = _e(n.eav, [s, i]);
1562
+ const c = we(n.eav, [s, i]);
1563
1563
  if (!c) return;
1564
1564
  const u = (p = c.values().next()) == null ? void 0 : p.value;
1565
1565
  if (!u) return;
@@ -1787,7 +1787,7 @@ function Yr(n, e, t) {
1787
1787
  return;
1788
1788
  const [s, i, o] = r;
1789
1789
  if (e.getAttr(i))
1790
- return _e(n.eav, [s, i]);
1790
+ return we(n.eav, [s, i]);
1791
1791
  }
1792
1792
  function Zr(n, e, t) {
1793
1793
  const r = t.filter(
@@ -1891,7 +1891,7 @@ function cs(n, e, t) {
1891
1891
  return Gr(n, $t(t, e));
1892
1892
  }
1893
1893
  const us = /^(?:[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;
1894
- function me(n) {
1894
+ function ge(n) {
1895
1895
  return typeof n == "string" && us.test(n);
1896
1896
  }
1897
1897
  const x = [];
@@ -1964,7 +1964,7 @@ function Oe(n) {
1964
1964
  function Ge(n, e) {
1965
1965
  return `?${n}-${e}`;
1966
1966
  }
1967
- class ge extends Error {
1967
+ class _e extends Error {
1968
1968
  constructor(e) {
1969
1969
  super(e), this.name = "AttrNotFoundError";
1970
1970
  }
@@ -1972,7 +1972,7 @@ class ge extends Error {
1972
1972
  function Ts(n, e) {
1973
1973
  const t = Rn(n, e);
1974
1974
  if (!t)
1975
- throw new ge(`Could not find id attr for ${e}`);
1975
+ throw new _e(`Could not find id attr for ${e}`);
1976
1976
  return t;
1977
1977
  }
1978
1978
  function Bt(n, e, t, r) {
@@ -1992,7 +1992,7 @@ function As(n, e, t) {
1992
1992
  function Ln(n, e, t, r, s) {
1993
1993
  const i = $(e, t, s), o = he(e, t, s), a = i || o;
1994
1994
  if (!a)
1995
- throw new ge(`Could not find attr for ${[t, s]}`);
1995
+ throw new _e(`Could not find attr for ${[t, s]}`);
1996
1996
  if (a["value-type"] !== "ref")
1997
1997
  throw new Error(`Attr ${a.id} is not a ref`);
1998
1998
  const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], d = r + 1, p = i ? [
@@ -2088,13 +2088,13 @@ function ks(n, e, t, r, s, i) {
2088
2088
  s
2089
2089
  ), c = o || a;
2090
2090
  if (!c)
2091
- throw new ge(
2091
+ throw new _e(
2092
2092
  `No attr for etype = ${t} label = ${s}`
2093
2093
  );
2094
2094
  if (i != null && i.hasOwnProperty("$isNull")) {
2095
2095
  const u = $(e, t, "id");
2096
2096
  if (!u)
2097
- throw new ge(
2097
+ throw new _e(
2098
2098
  `No attr for etype = ${t} label = id`
2099
2099
  );
2100
2100
  return [
@@ -2267,7 +2267,7 @@ function Rs(n, e, t, { etype: r, level: s, form: i }, o) {
2267
2267
  }), S = y ? T[0] : T;
2268
2268
  return { [p]: S };
2269
2269
  } catch (b) {
2270
- if (b instanceof ge)
2270
+ if (b instanceof _e)
2271
2271
  return { [p]: y ? void 0 : [] };
2272
2272
  throw b;
2273
2273
  }
@@ -2392,7 +2392,7 @@ function Vs(n, e, t) {
2392
2392
  try {
2393
2393
  return Ws(n, e, t);
2394
2394
  } catch (r) {
2395
- if (r instanceof ge)
2395
+ if (r instanceof _e)
2396
2396
  return {};
2397
2397
  throw r;
2398
2398
  }
@@ -3680,7 +3680,7 @@ function Tt(n) {
3680
3680
  }, e;
3681
3681
  }, {});
3682
3682
  }
3683
- const Yn = "v0.22.144";
3683
+ const Yn = "v0.22.145";
3684
3684
  function zi(n, e) {
3685
3685
  return {
3686
3686
  info: n ? (...t) => console.info(...t, e()) : () => {
@@ -3860,7 +3860,7 @@ const on = [
3860
3860
  o
3861
3861
  );
3862
3862
  }
3863
- }, be = (n, e, t, r, s) => {
3863
+ }, me = (n, e, t, r, s) => {
3864
3864
  const i = Wi(t), o = t.valueType === "json";
3865
3865
  if (typeof n == "object" && n !== null && !Array.isArray(n)) {
3866
3866
  if (o)
@@ -3913,12 +3913,12 @@ const on = [
3913
3913
  s
3914
3914
  );
3915
3915
  if (a === "id") {
3916
- if (typeof e == "string" && !me(e))
3916
+ if (typeof e == "string" && !ge(e))
3917
3917
  throw new C(
3918
3918
  `Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`,
3919
3919
  s
3920
3920
  );
3921
- be(
3921
+ me(
3922
3922
  e,
3923
3923
  n,
3924
3924
  new N("string", !1, !0),
@@ -3929,12 +3929,12 @@ const on = [
3929
3929
  }
3930
3930
  const u = c.attrs[a];
3931
3931
  if (Object.keys(c.links).includes(a)) {
3932
- if (typeof e == "string" && !me(e))
3932
+ if (typeof e == "string" && !ge(e))
3933
3933
  throw new C(
3934
3934
  `Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`,
3935
3935
  s
3936
3936
  );
3937
- be(
3937
+ me(
3938
3938
  e,
3939
3939
  n,
3940
3940
  new N("string", !1, !0),
@@ -3950,7 +3950,7 @@ const on = [
3950
3950
  s
3951
3951
  );
3952
3952
  }
3953
- be(e, n, u, t, s);
3953
+ me(e, n, u, t, s);
3954
3954
  }, Xn = (n, e, t, r) => {
3955
3955
  for (const [s, i] of Object.entries(n)) {
3956
3956
  if (s === "or" || s === "and") {
@@ -3965,7 +3965,7 @@ const on = [
3965
3965
  continue;
3966
3966
  }
3967
3967
  if (s === "id") {
3968
- be(
3968
+ me(
3969
3969
  i,
3970
3970
  "id",
3971
3971
  new N("string", !1, !0),
@@ -3995,7 +3995,7 @@ const on = [
3995
3995
  );
3996
3996
  }
3997
3997
  if (a)
3998
- be(
3998
+ me(
3999
3999
  i,
4000
4000
  s,
4001
4001
  a,
@@ -4003,13 +4003,13 @@ const on = [
4003
4003
  `${r}.${s}`
4004
4004
  );
4005
4005
  else if (c) {
4006
- if (typeof i == "string" && !me(i))
4006
+ if (typeof i == "string" && !ge(i))
4007
4007
  throw new C(
4008
4008
  `Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`,
4009
4009
  `${r}.${s}`
4010
4010
  );
4011
4011
  const u = new N("string", !1, !0);
4012
- be(
4012
+ me(
4013
4013
  i,
4014
4014
  s,
4015
4015
  u,
@@ -4133,7 +4133,7 @@ const on = [
4133
4133
  );
4134
4134
  }
4135
4135
  }
4136
- }, cn = (n) => typeof n != "string" ? !1 : Qe(n) ? !0 : me(n);
4136
+ }, cn = (n) => typeof n != "string" ? !1 : Qe(n) ? !0 : ge(n);
4137
4137
  class G extends Error {
4138
4138
  constructor(e) {
4139
4139
  super(e), this.name = "TransactionValidationError";
@@ -4206,7 +4206,7 @@ const tr = (n) => n.length > 0 ? n.join(", ") : "none", Gi = (n, e) => new G(
4206
4206
  }, Yi = (n, e) => {
4207
4207
  if (!e) return;
4208
4208
  const [t, r, s, i] = n;
4209
- if (!Array.isArray(s) && !me(s))
4209
+ if (!Array.isArray(s) && !ge(s))
4210
4210
  throw new G(
4211
4211
  `Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`
4212
4212
  );
@@ -4413,7 +4413,7 @@ function fn(n, e, t, r) {
4413
4413
  const s = (o = $(t, n.table, "id")) == null ? void 0 : o.id;
4414
4414
  if (!s)
4415
4415
  return -1;
4416
- const i = _e(e.eav, [r, s, r]);
4416
+ const i = we(e.eav, [r, s, r]);
4417
4417
  return i ? i[3] : -1;
4418
4418
  }
4419
4419
  function dn(n, e, t) {
@@ -4936,8 +4936,8 @@ function co({
4936
4936
  case "ok": {
4937
4937
  const { streamId: se, offset: Ze } = J;
4938
4938
  if (Ze !== 0) {
4939
- const we = new V("Write stream is corrupted");
4940
- ne(A, we);
4939
+ const Te = new V("Write stream is corrupted");
4940
+ ne(A, Te);
4941
4941
  return;
4942
4942
  }
4943
4943
  E(se), s(se, {
@@ -4968,10 +4968,10 @@ function co({
4968
4968
  async streamId() {
4969
4969
  return o || new Promise((I, L) => {
4970
4970
  const q = [], J = () => {
4971
- for (const we of q)
4972
- we();
4973
- }, se = (we) => {
4974
- I(we), J();
4971
+ for (const Te of q)
4972
+ Te();
4973
+ }, se = (Te) => {
4974
+ I(Te), J();
4975
4975
  }, Ze = () => {
4976
4976
  L(new V("Stream is closed.")), J();
4977
4977
  };
@@ -5374,7 +5374,7 @@ const ee = {
5374
5374
  }, ho = 3e4, po = 3e4, yo = 200, bo = 1e3 * 60, mo = {
5375
5375
  apiURI: "https://api.instantdb.com",
5376
5376
  websocketURI: "wss://api.instantdb.com/runtime/session"
5377
- }, st = "_instant_oauth_redirect", Te = "currentUser";
5377
+ }, st = "_instant_oauth_redirect", pe = "currentUser";
5378
5378
  function go({
5379
5379
  transportType: n,
5380
5380
  appId: e,
@@ -5708,7 +5708,7 @@ class ko {
5708
5708
  ), this.versions = { ...s || {}, "@instantdb/core": Yn }, this.config.schema && (this._linkIndex = Tt(this.config.schema)), !!_o()) {
5709
5709
  if (!e.appId)
5710
5710
  throw new Error("Instant must be initialized with an appId.");
5711
- if (!me(e.appId))
5711
+ if (!ge(e.appId))
5712
5712
  throw new Error(
5713
5713
  `Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`
5714
5714
  );
@@ -5716,7 +5716,9 @@ class ko {
5716
5716
  var a;
5717
5717
  try {
5718
5718
  if (((a = o.data) == null ? void 0 : a.type) === "auth") {
5719
- const c = await this.getCurrentUser();
5719
+ const c = await this.getCurrentUser({
5720
+ forceReadFromStorage: !0
5721
+ });
5720
5722
  await this.updateUser(c.user).catch((u) => {
5721
5723
  this._log.error("[error] update user", u);
5722
5724
  });
@@ -5731,7 +5733,7 @@ class ko {
5731
5733
  useDateObjects: this.config.useDateObjects
5732
5734
  },
5733
5735
  this._log,
5734
- (o) => ye(
5736
+ (o) => be(
5735
5737
  this.ensureAttrs(),
5736
5738
  o,
5737
5739
  this.config.enableCardinalityInference,
@@ -5816,7 +5818,7 @@ class ko {
5816
5818
  gc: null
5817
5819
  }), this.kv.onKeyLoaded = (t) => {
5818
5820
  t === "pendingMutations" && this.notifyAll();
5819
- }, this.kv.waitForKeyToLoad("pendingMutations"), this.kv.waitForKeyToLoad(Te), this._beforeUnloadCbs.push(() => {
5821
+ }, this.kv.waitForKeyToLoad("pendingMutations"), this.kv.waitForKeyToLoad(pe), this._beforeUnloadCbs.push(() => {
5820
5822
  this.kv.flush(), this.querySubs.flush();
5821
5823
  });
5822
5824
  }
@@ -5876,7 +5878,7 @@ class ko {
5876
5878
  _addQueryData(e, t, r) {
5877
5879
  if (!this.attrs)
5878
5880
  throw new Error("Attrs in reactor have not been set");
5879
- const s = R(e), i = this.ensureAttrs(), o = ye(
5881
+ const s = R(e), i = this.ensureAttrs(), o = be(
5880
5882
  this.attrs,
5881
5883
  t.triples,
5882
5884
  r,
@@ -5915,7 +5917,7 @@ class ko {
5915
5917
  const { q: p, result: y } = t, m = R(p);
5916
5918
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[m])
5917
5919
  break;
5918
- const _ = (c = (a = y == null ? void 0 : y[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], w = (l = (u = y == null ? void 0 : y[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, b = sn(y), g = this.ensureAttrs(), k = ye(
5920
+ const _ = (c = (a = y == null ? void 0 : y[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], w = (l = (u = y == null ? void 0 : y[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, b = sn(y), g = this.ensureAttrs(), k = be(
5919
5921
  g,
5920
5922
  b,
5921
5923
  r,
@@ -5981,7 +5983,7 @@ class ko {
5981
5983
  });
5982
5984
  const w = it(_.entries()), b = p.map((g) => {
5983
5985
  var U, ae, Pe, je;
5984
- const k = g["instaql-query"], T = g["instaql-result"], S = R(k), v = sn(T), E = this.ensureAttrs(), D = ye(
5986
+ const k = g["instaql-query"], T = g["instaql-result"], S = R(k), v = sn(T), E = this.ensureAttrs(), D = be(
5985
5987
  E,
5986
5988
  v,
5987
5989
  r,
@@ -6608,7 +6610,7 @@ class ko {
6608
6610
  const { user: e, error: t } = await this.getCurrentUser();
6609
6611
  if (t)
6610
6612
  throw new V("Could not get current user: " + t.message);
6611
- return e;
6613
+ return e ?? null;
6612
6614
  }
6613
6615
  subscribeConnectionStatus(e) {
6614
6616
  return this.connectionStatusCbs.push(e), () => {
@@ -6638,38 +6640,47 @@ class ko {
6638
6640
  }
6639
6641
  async setCurrentUser(e) {
6640
6642
  this.kv.updateInPlace((t) => {
6641
- t[Te] = e;
6642
- }), await this.kv.waitForKeyToLoad(Te);
6643
+ t[pe] = e;
6644
+ }), await this.kv.waitForKeyToLoad(pe);
6643
6645
  }
6644
6646
  getCurrentUserCached() {
6645
6647
  return this._currentUserCached;
6646
6648
  }
6647
- async _getCurrentUser() {
6648
- const e = await this.kv.waitForKeyToLoad(Te);
6649
- return typeof e == "string" ? JSON.parse(e) : e;
6649
+ /**
6650
+ * @param {{ forceReadFromStorage?: boolean }} [opts]
6651
+ * @returns {Promise<User | undefined>}
6652
+ */
6653
+ async _getCurrentUser(e) {
6654
+ e != null && e.forceReadFromStorage && await this.kv.unloadKey(pe);
6655
+ const t = await this.kv.waitForKeyToLoad(pe);
6656
+ return typeof t == "string" ? JSON.parse(t) : t;
6650
6657
  }
6651
- async getCurrentUser() {
6652
- const e = await this._waitForOAuthCallbackResponse();
6653
- if (e != null && e.error) {
6654
- const t = { error: e.error, user: void 0 };
6655
- return this._currentUserCached = { isLoading: !1, ...t }, t;
6658
+ /**
6659
+ * @param {{ forceReadFromStorage?: boolean }} [opts]
6660
+ * @returns {Promise<AuthState>}
6661
+ */
6662
+ async getCurrentUser(e) {
6663
+ const t = await this._waitForOAuthCallbackResponse();
6664
+ if (t != null && t.error) {
6665
+ const r = { error: t.error, user: void 0 };
6666
+ return this._currentUserCached = { isLoading: !1, ...r }, this._currentUserCached;
6656
6667
  }
6657
6668
  try {
6658
- const r = { user: await this._getCurrentUser(), error: void 0 };
6669
+ const s = { user: await this._getCurrentUser(e), error: void 0 };
6659
6670
  return this._currentUserCached = {
6660
6671
  isLoading: !1,
6661
- ...r
6662
- }, r;
6663
- } catch (t) {
6672
+ ...s
6673
+ }, this._currentUserCached;
6674
+ } catch (r) {
6664
6675
  return {
6665
6676
  user: void 0,
6666
6677
  isLoading: !1,
6667
- error: { message: (t == null ? void 0 : t.message) || "Error loading user" }
6678
+ error: { message: (r == null ? void 0 : r.message) || "Error loading user" }
6668
6679
  };
6669
6680
  }
6670
6681
  }
6671
6682
  async _hasCurrentUser() {
6672
- const e = await this.kv.waitForKeyToLoad(Te);
6683
+ const e = await this.kv.waitForKeyToLoad(pe);
6673
6684
  return typeof e == "string" ? JSON.parse(e) != null : e != null;
6674
6685
  }
6675
6686
  async changeCurrentUser(e) {
@@ -6678,7 +6689,7 @@ class ko {
6678
6689
  if (!Ne(t, e)) {
6679
6690
  await this.setCurrentUser(e), await this.updateUser(e);
6680
6691
  try {
6681
- (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
6692
+ await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
6682
6693
  } catch (s) {
6683
6694
  console.error("Error posting message to broadcast channel", s);
6684
6695
  }
@@ -6723,13 +6734,13 @@ class ko {
6723
6734
  });
6724
6735
  }
6725
6736
  async signInWithMagicCode({ email: e, code: t }) {
6726
- var o;
6737
+ var o, a;
6727
6738
  const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Pi({
6728
6739
  apiURI: this.config.apiURI,
6729
6740
  appId: this.config.appId,
6730
6741
  email: e,
6731
6742
  code: t,
6732
- refreshToken: s ? r.user.refresh_token : void 0
6743
+ refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
6733
6744
  });
6734
6745
  return await this.changeCurrentUser(i.user), i;
6735
6746
  }
@@ -6788,13 +6799,13 @@ class ko {
6788
6799
  * @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
6789
6800
  */
6790
6801
  async exchangeCodeForToken({ code: e, codeVerifier: t }) {
6791
- var o;
6802
+ var o, a;
6792
6803
  const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await tn({
6793
6804
  apiURI: this.config.apiURI,
6794
6805
  appId: this.config.appId,
6795
6806
  code: e,
6796
6807
  codeVerifier: t,
6797
- refreshToken: s ? r.user.refresh_token : void 0
6808
+ refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
6798
6809
  });
6799
6810
  return await this.changeCurrentUser(i.user), i;
6800
6811
  }
@@ -7445,7 +7456,7 @@ class aa {
7445
7456
  const o = !!((d = (f = (l = this.db) == null ? void 0 : l._reactor) == null ? void 0 : f.config) != null && d.schema) && ("cardinalityInference" in ((y = (p = this.db) == null ? void 0 : p._reactor) == null ? void 0 : y.config) ? !!((_ = (m = this.db) == null ? void 0 : m._reactor.config) != null && _.cardinalityInference) : !0), a = new ce(
7446
7457
  r.reduce((b, g) => (b[g.id] = g, b), {}),
7447
7458
  Tt((w = this.db) == null ? void 0 : w._reactor.config.schema)
7448
- ), c = ye(
7459
+ ), c = be(
7449
7460
  a,
7450
7461
  t,
7451
7462
  o,