interaqt 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18,15 +18,15 @@ function ls(c, t) {
18
18
  function k(c) {
19
19
  return typeof c == "function" ? `func::${c.toString()}` : Array.isArray(c) ? c : Ni(c) && !vi(c) ? `uuid::${c.uuid}` : c;
20
20
  }
21
- function Qt(c, t) {
21
+ function Bt(c, t) {
22
22
  if (c == null || typeof c != "object") return c;
23
- if (Array.isArray(c)) return c.map((i) => Qt(i, t));
23
+ if (Array.isArray(c)) return c.map((i) => Bt(i, t));
24
24
  if (vi(c))
25
- return Object.fromEntries(Object.entries(c).map(([i, r]) => [i, Qt(r, t)]));
25
+ return Object.fromEntries(Object.entries(c).map(([i, r]) => [i, Bt(r, t)]));
26
26
  if (c instanceof Set)
27
- return new Set(Array.from(c.values()).map((i) => Qt(i, t)));
27
+ return new Set(Array.from(c.values()).map((i) => Bt(i, t)));
28
28
  if (c instanceof Map)
29
- return new Map(Array.from(c.entries()).map(([i, r]) => [i, Qt(r, t)]));
29
+ return new Map(Array.from(c.entries()).map(([i, r]) => [i, Bt(r, t)]));
30
30
  const e = c;
31
31
  return t && e._type && e.constructor?.clone ? e.constructor.clone(c, t) : c;
32
32
  }
@@ -60,11 +60,11 @@ function Gi(c) {
60
60
  t.set(r, n);
61
61
  }), t;
62
62
  }
63
- let Ji = 0;
63
+ let Ki = 0;
64
64
  function A(c) {
65
- return c?.uuid || `id_${++Ji}`;
65
+ return c?.uuid || `id_${++Ki}`;
66
66
  }
67
- const Ki = /^[a-zA-Z0-9_]+$/;
67
+ const Ji = /^[a-zA-Z0-9_]+$/;
68
68
  class D {
69
69
  constructor(t, e) {
70
70
  this._type = "Entity", this._options = e, this.uuid = A(e), this.name = t.name, this.properties = t.properties || [], this.computation = t.computation, this.baseEntity = t.baseEntity, this.matchExpression = t.matchExpression, this.inputEntities = t.inputEntities, this.commonProperties = t.commonProperties, this.constraints = t.constraints;
@@ -84,7 +84,7 @@ class D {
84
84
  type: "string",
85
85
  required: !0,
86
86
  constraints: {
87
- nameFormat: ({ name: t }) => Ki.test(t)
87
+ nameFormat: ({ name: t }) => Ji.test(t)
88
88
  }
89
89
  },
90
90
  properties: {
@@ -842,7 +842,7 @@ class xe {
842
842
  return this.create(e.public, e.options);
843
843
  }
844
844
  }
845
- class At {
845
+ class Ct {
846
846
  constructor(t, e) {
847
847
  this._type = "StateMachine", this._options = e, this.uuid = A(e), this.states = t.states, this.transfers = t.transfers, this.initialState = t.initialState;
848
848
  }
@@ -875,7 +875,7 @@ class At {
875
875
  };
876
876
  }
877
877
  static create(t, e) {
878
- const i = new At(t, e);
878
+ const i = new Ct(t, e);
879
879
  if (this.instances.find((a) => a.uuid === i.uuid))
880
880
  throw new Error(`duplicate uuid in options ${i.uuid}, StateMachine`);
881
881
  return this.instances.push(i), i;
@@ -911,7 +911,7 @@ class At {
911
911
  return this.create(e.public, e.options);
912
912
  }
913
913
  }
914
- class Ct {
914
+ class $t {
915
915
  constructor(t, e) {
916
916
  this._type = "WeightedSummation", this._options = e, this.uuid = A(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps;
917
917
  }
@@ -959,7 +959,7 @@ class Ct {
959
959
  };
960
960
  }
961
961
  static create(t, e) {
962
- const i = new Ct(t, e);
962
+ const i = new $t(t, e);
963
963
  if (this.instances.find((a) => a.uuid === i.uuid))
964
964
  throw new Error(`duplicate uuid in options ${i.uuid}, WeightedSummation`);
965
965
  return this.instances.push(i), i;
@@ -1001,7 +1001,7 @@ class Ct {
1001
1001
  return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
1002
1002
  }
1003
1003
  }
1004
- class $t {
1004
+ class It {
1005
1005
  constructor(t, e) {
1006
1006
  this._type = "Count", this._options = e, this.uuid = A(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps;
1007
1007
  }
@@ -1044,7 +1044,7 @@ class $t {
1044
1044
  };
1045
1045
  }
1046
1046
  static create(t, e) {
1047
- const i = new $t(t, e);
1047
+ const i = new It(t, e);
1048
1048
  if (this.instances.find((a) => a.uuid === i.uuid))
1049
1049
  throw new Error(`duplicate uuid in options ${i.uuid}, Count`);
1050
1050
  return this.instances.push(i), i;
@@ -1085,7 +1085,7 @@ class $t {
1085
1085
  return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
1086
1086
  }
1087
1087
  }
1088
- class It {
1088
+ class xt {
1089
1089
  constructor(t, e) {
1090
1090
  this._type = "Summation", this._options = e, this.uuid = A(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.attributeQuery = t.attributeQuery;
1091
1091
  }
@@ -1118,7 +1118,7 @@ class It {
1118
1118
  };
1119
1119
  }
1120
1120
  static create(t, e) {
1121
- const i = new It(t, e);
1121
+ const i = new xt(t, e);
1122
1122
  if (this.instances.find((a) => a.uuid === i.uuid))
1123
1123
  throw new Error(`duplicate uuid in options ${i.uuid}, Summation`);
1124
1124
  return this.instances.push(i), i;
@@ -1153,7 +1153,7 @@ class It {
1153
1153
  return this.create(e.public, e.options);
1154
1154
  }
1155
1155
  }
1156
- class xt {
1156
+ class Mt {
1157
1157
  constructor(t, e) {
1158
1158
  this._type = "Average", this._options = e, this.uuid = A(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.attributeQuery = t.attributeQuery;
1159
1159
  }
@@ -1186,7 +1186,7 @@ class xt {
1186
1186
  };
1187
1187
  }
1188
1188
  static create(t, e) {
1189
- const i = new xt(t, e);
1189
+ const i = new Mt(t, e);
1190
1190
  if (this.instances.find((a) => a.uuid === i.uuid))
1191
1191
  throw new Error(`duplicate uuid in options ${i.uuid}, Average`);
1192
1192
  return this.instances.push(i), i;
@@ -1221,7 +1221,7 @@ class xt {
1221
1221
  return this.create(e.public, e.options);
1222
1222
  }
1223
1223
  }
1224
- class Mt {
1224
+ class Pt {
1225
1225
  constructor(t, e) {
1226
1226
  this._type = "Every", this._options = e, this.uuid = A(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps, this.notEmpty = t.notEmpty;
1227
1227
  }
@@ -1269,7 +1269,7 @@ class Mt {
1269
1269
  };
1270
1270
  }
1271
1271
  static create(t, e) {
1272
- const i = new Mt(t, e);
1272
+ const i = new Pt(t, e);
1273
1273
  if (this.instances.find((a) => a.uuid === i.uuid))
1274
1274
  throw new Error(`duplicate uuid in options ${i.uuid}, Every`);
1275
1275
  return this.instances.push(i), i;
@@ -1306,7 +1306,7 @@ class Mt {
1306
1306
  return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
1307
1307
  }
1308
1308
  }
1309
- class Pt {
1309
+ class Dt {
1310
1310
  constructor(t, e) {
1311
1311
  this._type = "Any", this._options = e, this.uuid = A(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps;
1312
1312
  }
@@ -1354,7 +1354,7 @@ class Pt {
1354
1354
  };
1355
1355
  }
1356
1356
  static create(t, e) {
1357
- const i = new Pt(t, e);
1357
+ const i = new Dt(t, e);
1358
1358
  if (this.instances.find((a) => a.uuid === i.uuid))
1359
1359
  throw new Error(`duplicate uuid in options ${i.uuid}, Any`);
1360
1360
  return this.instances.push(i), i;
@@ -1466,7 +1466,7 @@ class te {
1466
1466
  return typeof i.callback == "string" && i.callback.startsWith("func::") && (i.callback = new Function("return " + i.callback.substring(6))()), this.create(i, e.options);
1467
1467
  }
1468
1468
  }
1469
- class Dt {
1469
+ class Ot {
1470
1470
  constructor(t, e) {
1471
1471
  this._type = "RealTimeValue", this._options = e, this.uuid = A(e), this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps, this.nextRecomputeTime = t.nextRecomputeTime, this.callback = t.callback;
1472
1472
  }
@@ -1504,7 +1504,7 @@ class Dt {
1504
1504
  };
1505
1505
  }
1506
1506
  static create(t, e) {
1507
- const i = new Dt(t, e);
1507
+ const i = new Ot(t, e);
1508
1508
  if (this.instances.find((a) => a.uuid === i.uuid))
1509
1509
  throw new Error(`duplicate uuid in options ${i.uuid}, RealTimeValue`);
1510
1510
  return this.instances.push(i), i;
@@ -1601,7 +1601,7 @@ class Me {
1601
1601
  return typeof r.handle == "string" && r.handle.startsWith("func::") && (i.handle = new Function("return " + r.handle.substring(6))()), this.create(i, e.options);
1602
1602
  }
1603
1603
  }
1604
- class Ot {
1604
+ class Ft {
1605
1605
  constructor(t, e) {
1606
1606
  this._type = "BoolAtomData", this._options = e, this.uuid = A(e), this.type = t.type || "atom", this.data = t.data;
1607
1607
  }
@@ -1630,7 +1630,7 @@ class Ot {
1630
1630
  };
1631
1631
  }
1632
1632
  static create(t, e) {
1633
- const i = new Ot(t, e);
1633
+ const i = new Ft(t, e);
1634
1634
  if (this.instances.find((a) => a.uuid === i.uuid))
1635
1635
  throw new Error(`duplicate uuid in options ${i.uuid}, BoolAtomData`);
1636
1636
  return this.instances.push(i), i;
@@ -1648,7 +1648,7 @@ class Ot {
1648
1648
  return t !== null && typeof t == "object" && typeof t.uuid == "string";
1649
1649
  }
1650
1650
  }
1651
- class Ft {
1651
+ class Lt {
1652
1652
  constructor(t, e) {
1653
1653
  this._type = "BoolExpressionData", this._options = e, this.uuid = A(e), this.type = t.type || "expression", this.operator = t.operator || "and", this.left = t.left, this.right = t.right;
1654
1654
  }
@@ -1689,7 +1689,7 @@ class Ft {
1689
1689
  };
1690
1690
  }
1691
1691
  static create(t, e) {
1692
- const i = new Ft(t, e);
1692
+ const i = new Lt(t, e);
1693
1693
  if (this.instances.find((a) => a.uuid === i.uuid))
1694
1694
  throw new Error(`duplicate uuid in options ${i.uuid}, BoolExpressionData`);
1695
1695
  return this.instances.push(i), i;
@@ -1891,19 +1891,19 @@ const Yi = [
1891
1891
  Zt,
1892
1892
  mt,
1893
1893
  xe,
1894
- At,
1895
1894
  Ct,
1896
1895
  $t,
1897
1896
  It,
1898
1897
  xt,
1899
1898
  Mt,
1900
1899
  Pt,
1901
- te,
1902
1900
  Dt,
1901
+ te,
1902
+ Ot,
1903
1903
  Me,
1904
1904
  Ie,
1905
- Ot,
1906
- Ft
1905
+ Ft,
1906
+ Lt
1907
1907
  ];
1908
1908
  Yi.forEach((c) => {
1909
1909
  c && c.displayName && Ei(c.displayName, c);
@@ -2481,7 +2481,7 @@ class w {
2481
2481
  const o = [...s.resolvedPath, n], l = this.map.getInfoByPath(o), u = s.resolvedPath.concat(l?.isLinkFiltered() ? l.getBaseAttributeInfo().attributeName : n);
2482
2482
  let d = s.matchExpression;
2483
2483
  if (l?.isLinkFiltered()) {
2484
- const p = l.getLinkInfo(), f = new w(p.getResolvedBaseRecordName(), this.map, p.getResolvedMatchExpression()), m = this.map.getReversePath(u), y = [l.isRecordSource() ? "source" : "target", ...m.slice(2)], b = f.rebase(y.join("."));
2484
+ const h = l.getLinkInfo(), f = new w(h.getResolvedBaseRecordName(), this.map, h.getResolvedMatchExpression()), m = this.map.getReversePath(u), y = [l.isRecordSource() ? "source" : "target", ...m.slice(2)], b = f.rebase(y.join("."));
2485
2485
  d = d ? d.and(b) : b;
2486
2486
  }
2487
2487
  return {
@@ -2529,8 +2529,8 @@ class w {
2529
2529
  R(!t, "reference value cannot use IN to match"), o = `IN (${i[1].map((d) => s()).join(",")})`, l = i[1];
2530
2530
  else if (i[0].toLowerCase() === "between")
2531
2531
  if (t) {
2532
- const d = this.getReferenceFieldValue(i[1][0]), p = this.getReferenceFieldValue(i[1][1]);
2533
- o = `BETWEEN "${d.split(".")[0]}"."${d.split(".")[1]}" AND "${p.split(".")[0]}"."${p.split(".")[1]}"`, l = [];
2532
+ const d = this.getReferenceFieldValue(i[1][0]), h = this.getReferenceFieldValue(i[1][1]);
2533
+ o = `BETWEEN "${d.split(".")[0]}"."${d.split(".")[1]}" AND "${h.split(".")[0]}"."${h.split(".")[1]}"`, l = [];
2534
2534
  } else
2535
2535
  o = `BETWEEN ${s()} AND ${s()}`, l = [i[1][0], i[1][1]];
2536
2536
  else {
@@ -2544,20 +2544,20 @@ class w {
2544
2544
  const r = i.data.key.split("."), a = this.map.getInfoByPath([this.entityName].concat(r)), s = [this.entityName].concat(r), n = this.map.spawnManyToManySymmetricPath(s);
2545
2545
  let o, l;
2546
2546
  if (n && (o = n[0].slice(1, 1 / 0), l = n[1].slice(1, 1 / 0)), a.isValue) {
2547
- const u = this.getFinalFieldName(r), [d, p] = this.getFinalFieldValue(i.data.isReferenceValue, i.data.key, i.data.value, u.join("."), a.fieldType, t, e);
2547
+ const u = this.getFinalFieldName(r), [d, h] = this.getFinalFieldValue(i.data.isReferenceValue, i.data.key, i.data.value, u.join("."), a.fieldType, t, e);
2548
2548
  if (!n)
2549
2549
  return {
2550
2550
  ...i.data,
2551
2551
  fieldName: u,
2552
2552
  fieldValue: d,
2553
- fieldParams: p
2553
+ fieldParams: h
2554
2554
  };
2555
2555
  const [f, m] = this.getFinalFieldValue(i.data.isReferenceValue, i.data.key, i.data.value, u.join("."), a.fieldType, t, e);
2556
2556
  return E.atom({
2557
2557
  ...i.data,
2558
2558
  fieldName: this.getFinalFieldName(o),
2559
2559
  fieldValue: d,
2560
- fieldParams: p
2560
+ fieldParams: h
2561
2561
  }).or({
2562
2562
  ...i.data,
2563
2563
  fieldName: this.getFinalFieldName(l),
@@ -2688,12 +2688,12 @@ class Zi {
2688
2688
  }
2689
2689
  }
2690
2690
  class L {
2691
- constructor(t, e, i, r, a, s, n, o, l, u = !1, d, p, f, m) {
2692
- this.recordName = t, this.map = e, this.matchExpression = i, this.attributeQuery = r, this.modifier = a, this.contextRootEntity = s, this.parentRecord = n, this.attributeName = o, this.onlyRelationData = l, this.allowNull = u, this.label = d, this.goto = p, this.exit = f, this.alias = m;
2691
+ constructor(t, e, i, r, a, s, n, o, l, u = !1, d, h, f, m) {
2692
+ this.recordName = t, this.map = e, this.matchExpression = i, this.attributeQuery = r, this.modifier = a, this.contextRootEntity = s, this.parentRecord = n, this.attributeName = o, this.onlyRelationData = l, this.allowNull = u, this.label = d, this.goto = h, this.exit = f, this.alias = m;
2693
2693
  }
2694
2694
  static create(t, e, i, r, a, s, n, o = !1, l) {
2695
- const u = e.getRecordInfo(t), d = u.resolvedBaseRecordName, p = new w(d, e, i.matchExpression, r);
2696
- let f = o ? p : p.and({
2695
+ const u = e.getRecordInfo(t), d = u.resolvedBaseRecordName, h = new w(d, e, i.matchExpression, r);
2696
+ let f = o ? h : h.and({
2697
2697
  key: "id",
2698
2698
  value: ["not", null]
2699
2699
  }), m = f;
@@ -2802,7 +2802,7 @@ class O {
2802
2802
  this.recordName = t, this.map = e, this.data = i, this.parentRecord = r, this.attributeName = a, this.shouldQueryParentLinkData = s, this.relatedRecords = [], this.xToManyRecords = [], this.xToOneRecords = [], this.valueAttributes = [], this.id = Math.random();
2803
2803
  let n = /* @__PURE__ */ new Set();
2804
2804
  i.forEach((o) => {
2805
- const l = typeof o == "string" ? [o, {}, !1] : o, [u, d, p] = l;
2805
+ const l = typeof o == "string" ? [o, {}, !1] : o, [u, d, h] = l;
2806
2806
  if (u === g) {
2807
2807
  R(!!(this.parentRecord && this.attributeName), `parent record and attribute name cannot be empty when query link data, you passed ${this.parentRecord} ${this.attributeName}`);
2808
2808
  const m = this.map.getInfo(this.parentRecord, this.attributeName);
@@ -2815,16 +2815,16 @@ class O {
2815
2815
  }
2816
2816
  const f = this.map.getInfo(this.recordName, u);
2817
2817
  if (f.isRecord) {
2818
- let m = u, h = d;
2818
+ let m = u, p = d;
2819
2819
  if (f.isLinkFiltered()) {
2820
2820
  m = f.getBaseAttributeInfo().attributeName;
2821
2821
  const b = d.matchExpression, v = f.getLinkInfo().getBaseLinkInfo(), I = new w(v.name, this.map, f.getMatchExpression()).rebase(f.isRecordSource() ? "target" : "source"), S = b ? I.and(b.data) : I;
2822
- h = {
2822
+ p = {
2823
2823
  ...d,
2824
2824
  matchExpression: S.data
2825
2825
  };
2826
2826
  }
2827
- const y = L.create(f.recordName, this.map, h, void 0, this.recordName, m, p, !1, u);
2827
+ const y = L.create(f.recordName, this.map, p, void 0, this.recordName, m, h, !1, u);
2828
2828
  this.relatedRecords.push(y), f.isXToMany ? this.xToManyRecords.push(y) : f.isXToOne && this.xToOneRecords.push(y);
2829
2829
  } else
2830
2830
  n.add(u);
@@ -2844,7 +2844,7 @@ class O {
2844
2844
  const n = e.getRecordInfo(t), o = e.getRecordInfo(n.resolvedBaseRecordName);
2845
2845
  let l = o.valueAttributes.map((u) => u.attributeName);
2846
2846
  return i && o.sameTableReliance.forEach((u) => {
2847
- const d = O.getAttributeQueryDataForRecord(u.recordName, e, !0, r), p = [
2847
+ const d = O.getAttributeQueryDataForRecord(u.recordName, e, !0, r), h = [
2848
2848
  u.attributeName,
2849
2849
  {
2850
2850
  attributeQuery: [...d]
@@ -2852,11 +2852,11 @@ class O {
2852
2852
  ];
2853
2853
  if (!o.isRelation) {
2854
2854
  const f = O.getAttributeQueryDataForRecord(u.linkName, e, !0, r);
2855
- p[1].attributeQuery.push([g, { attributeQuery: f }]);
2855
+ h[1].attributeQuery.push([g, { attributeQuery: f }]);
2856
2856
  }
2857
- l = O.mergeAttributeQueryData(l, [p]);
2857
+ l = O.mergeAttributeQueryData(l, [h]);
2858
2858
  }), s && o.notRelianceCombined.forEach((u) => {
2859
- const d = O.getAttributeQueryDataForRecord(u.recordName, e, !0, r), p = [
2859
+ const d = O.getAttributeQueryDataForRecord(u.recordName, e, !0, r), h = [
2860
2860
  u.attributeName,
2861
2861
  {
2862
2862
  attributeQuery: [...d]
@@ -2864,9 +2864,9 @@ class O {
2864
2864
  ];
2865
2865
  if (!o.isRelation) {
2866
2866
  const f = O.getAttributeQueryDataForRecord(u.linkName, e, !0, r);
2867
- p[1].attributeQuery.push([g, { attributeQuery: f }]);
2867
+ h[1].attributeQuery.push([g, { attributeQuery: f }]);
2868
2868
  }
2869
- l = O.mergeAttributeQueryData(l, [p]);
2869
+ l = O.mergeAttributeQueryData(l, [h]);
2870
2870
  }), r && o.mergedRecordAttributes.forEach((u) => {
2871
2871
  const d = O.getAttributeQueryDataForRecord(u.linkName, e, i, !0);
2872
2872
  l = O.mergeAttributeQueryData(l, [
@@ -2954,8 +2954,8 @@ class j {
2954
2954
  )), this.valueAttributes = s, this.entityIdAttributes = o;
2955
2955
  const l = this.map.getRecordInfo(this.recordName);
2956
2956
  this.defaultValues = l.valueAttributes.reduce((u, d) => {
2957
- const p = d.data;
2958
- return !this.rawData?.hasOwnProperty(d.attributeName) && p.defaultValue && typeof p.defaultValue == "function" && (u[d.attributeName] = p.defaultValue(i, this.originalRecordName)), u;
2957
+ const h = d.data;
2958
+ return !this.rawData?.hasOwnProperty(d.attributeName) && h.defaultValue && typeof h.defaultValue == "function" && (u[d.attributeName] = h.defaultValue(i, this.originalRecordName)), u;
2959
2959
  }, {}), this.relatedEntitiesData.forEach((u) => {
2960
2960
  u.info.isMergedWithParent() ? u.isNull() ? this.combinedNullRecords.push(u) : u.isRef() ? this.combinedRecordIdRefs.push(u) : this.combinedNewRecords.push(u) : u.info.isLinkMergedWithParent() ? u.isNull() ? this.mergedLinkTargetNullRecords.push(u) : u.isRef() ? this.mergedLinkTargetRecordIdRefs.push(u) : this.mergedLinkTargetNewRecords.push(u) : u.info.isLinkMergedWithAttribute() ? u.isNull() ? this.differentTableMergedLinkNullRecords.push(u) : u.isRef() ? this.differentTableMergedLinkRecordIdRefs.push(u) : this.differentTableMergedLinkNewRecords.push(u) : u.isNull() ? this.isolatedNullRecords.push(u) : u.isRef() ? this.isolatedRecordIdRefs.push(u) : this.isolatedNewRecords.push(u);
2961
2961
  }), this.rawData?.[g] && (this.linkRecordData = new j(this.map, r?.linkName, this.rawData[g]));
@@ -3079,9 +3079,9 @@ class ir {
3079
3079
  }
3080
3080
  });
3081
3081
  else if (t.valueAttributes.length) {
3082
- const o = t.getSameRowFieldAndValue(r), l = this.map.getRecordInfo(t.recordName), u = new Set(l.valueAttributes.map((p) => p.attributeName)), d = { ...t.getData() };
3083
- o.forEach((p) => {
3084
- u.has(p.name) && (d[p.name] = p.value);
3082
+ const o = t.getSameRowFieldAndValue(r), l = this.map.getRecordInfo(t.recordName), u = new Set(l.valueAttributes.map((h) => h.attributeName)), d = { ...t.getData() };
3083
+ o.forEach((h) => {
3084
+ u.has(h.name) && (d[h.name] = h.value);
3085
3085
  }), i?.push({
3086
3086
  type: "update",
3087
3087
  recordName: t.recordName,
@@ -3221,11 +3221,11 @@ class ir {
3221
3221
  R(!n, `cannot create ${t} for ${e} ${i}, link already exist`);
3222
3222
  const o = this.map.getLinkInfoByName(t);
3223
3223
  if (!o.isCombined() && !o.isMerged() && (o.isManyToOne || o.isOneToMany)) {
3224
- const u = o.isManyToOne ? "source.id" : "target.id", d = o.isManyToOne ? e : i, p = w.atom({
3224
+ const u = o.isManyToOne ? "source.id" : "target.id", d = o.isManyToOne ? e : i, h = w.atom({
3225
3225
  key: u,
3226
3226
  value: ["=", d]
3227
3227
  });
3228
- await this.helper.unlink(t, p, !1, "unlink combined record for add new link", s);
3228
+ await this.helper.unlink(t, h, !1, "unlink combined record for add new link", s);
3229
3229
  }
3230
3230
  const l = new j(this.map, o.name, {
3231
3231
  source: { id: e },
@@ -3281,11 +3281,11 @@ class rr {
3281
3281
  for (let l = 1; l < o.length - 1; l++) {
3282
3282
  const u = o.slice(0, l + 1), d = this.map.getInfoByPath(u);
3283
3283
  if (d && d.isRecord) {
3284
- const p = d.recordName, f = n.slice(0, l), m = n[n.length - 1], h = i.find(
3285
- (y) => y.entityName === p && JSON.stringify(y.path) === JSON.stringify(f)
3284
+ const h = d.recordName, f = n.slice(0, l), m = n[n.length - 1], p = i.find(
3285
+ (y) => y.entityName === h && JSON.stringify(y.path) === JSON.stringify(f)
3286
3286
  );
3287
- h ? h.attributes.includes(m) || h.attributes.push(m) : i.push({
3288
- entityName: p,
3287
+ p ? p.attributes.includes(m) || p.attributes.push(m) : i.push({
3288
+ entityName: h,
3289
3289
  path: f,
3290
3290
  attributes: [m]
3291
3291
  });
@@ -3385,9 +3385,9 @@ class rr {
3385
3385
  record: { ...r, id: e }
3386
3386
  }));
3387
3387
  if (Object.keys(u).length > 0) {
3388
- const p = this.map.getRecordInfo(t).data.attributes.__filtered_entities;
3389
- if (p && p.field) {
3390
- const f = p.field;
3388
+ const h = this.map.getRecordInfo(t).data.attributes.__filtered_entities;
3389
+ if (h && h.field) {
3390
+ const f = h.field;
3391
3391
  await this.queryAgent.updateRecordDataById(
3392
3392
  t,
3393
3393
  { id: e },
@@ -3452,12 +3452,12 @@ class rr {
3452
3452
  }), n[t.filteredEntityName] = !1), l !== o) {
3453
3453
  const d = this.map.getRecordInfo(t.baseEntityName).data.attributes.__filtered_entities;
3454
3454
  if (d && d.field) {
3455
- const p = d.field;
3455
+ const h = d.field;
3456
3456
  await this.queryAgent.updateRecordDataById(
3457
3457
  t.baseEntityName,
3458
3458
  { id: e },
3459
3459
  [{
3460
- field: p,
3460
+ field: h,
3461
3461
  value: JSON.stringify(n)
3462
3462
  }]
3463
3463
  );
@@ -3502,27 +3502,27 @@ class sr {
3502
3502
  * @returns [SQL字符串, 参数数组, 字段别名映射]
3503
3503
  */
3504
3504
  buildXToOneFindQuery(t, e = "", i) {
3505
- const r = t.attributeQuery.xToOneQueryTree, a = t.matchExpression.xToOneQueryTree, s = t.modifier.xToOneQueryTree, n = r.merge(a).merge(s), o = this.getJoinTables(n, [t.recordName]), l = i || this.getPlaceholder(), u = t.matchExpression.buildFieldMatchExpression(l, this.database), [d, p] = this.buildWhereClause(
3505
+ const r = t.attributeQuery.xToOneQueryTree, a = t.matchExpression.xToOneQueryTree, s = t.modifier.xToOneQueryTree, n = r.merge(a).merge(s), o = this.getJoinTables(n, [t.recordName]), l = i || this.getPlaceholder(), u = t.matchExpression.buildFieldMatchExpression(l, this.database), [d, h] = this.buildWhereClause(
3506
3506
  this.parseMatchExpressionValue(t.recordName, u, t.contextRootEntity, l),
3507
3507
  e,
3508
3508
  l
3509
3509
  ), [f, m] = this.buildSelectClause(
3510
3510
  t.attributeQuery.getValueAndXToOneRecordFields(),
3511
3511
  e
3512
- ), h = this.buildFromClause(t.recordName, e), y = this.buildJoinClause(o, e), b = this.buildModifierClause(t.modifier, e, m);
3512
+ ), p = this.buildFromClause(t.recordName, e), y = this.buildJoinClause(o, e), b = this.buildModifierClause(t.modifier, e, m);
3513
3513
  return [
3514
3514
  `
3515
3515
  SELECT
3516
3516
  ${f}
3517
3517
  FROM
3518
- ${h}
3518
+ ${p}
3519
3519
  ${y}
3520
3520
  WHERE
3521
3521
  ${d}
3522
3522
 
3523
3523
  ${b}
3524
3524
  `,
3525
- p,
3525
+ h,
3526
3526
  m
3527
3527
  ];
3528
3528
  }
@@ -3585,13 +3585,13 @@ ${b}
3585
3585
  const { limit: r, offset: a, orderBy: s } = t, n = [];
3586
3586
  return s.length && n.push(`ORDER BY ${s.map(({ attribute: o, recordName: l, order: u }) => {
3587
3587
  const d = o.split(".");
3588
- let p, f;
3589
- d.length === 1 ? (p = [l], f = o) : (p = [l, ...d.slice(0, -1)], f = d[d.length - 1]);
3590
- const [m, h] = this.map.getTableAliasAndFieldName(
3591
- p,
3588
+ let h, f;
3589
+ d.length === 1 ? (h = [l], f = o) : (h = [l, ...d.slice(0, -1)], f = d[d.length - 1]);
3590
+ const [m, p] = this.map.getTableAliasAndFieldName(
3591
+ h,
3592
3592
  f
3593
3593
  );
3594
- return `"${`${this.withPrefix(e)}${m}`}"."${h}" ${u}`;
3594
+ return `"${`${this.withPrefix(e)}${m}`}"."${p}" ${u}`;
3595
3595
  }).join(",")}`), r && n.push(`LIMIT ${r}`), a && n.push(`OFFSET ${a}`), n.join(`
3596
3596
  `);
3597
3597
  }
@@ -3613,18 +3613,18 @@ ${b}
3613
3613
  throw new Error(`${e.concat(o).join(".")} is not a record`);
3614
3614
  const u = e.concat(o), {
3615
3615
  table: d,
3616
- alias: p,
3616
+ alias: h,
3617
3617
  linkTable: f,
3618
3618
  linkAlias: m
3619
- } = this.map.getTableAndAliasStack(u).at(-1), [, h] = this.map.getTableAliasAndFieldName(u, "id", !0);
3619
+ } = this.map.getTableAndAliasStack(u).at(-1), [, p] = this.map.getTableAliasAndFieldName(u, "id", !0);
3620
3620
  if (!l.isMergedWithParent())
3621
3621
  if (l.isLinkMergedWithParent()) {
3622
3622
  if (n.onlyIdField()) return;
3623
3623
  r.push({
3624
3624
  for: u,
3625
3625
  joinSource: s,
3626
- joinIdField: [l.linkField, h],
3627
- joinTarget: [d, p]
3626
+ joinIdField: [l.linkField, p],
3627
+ joinTarget: [d, h]
3628
3628
  });
3629
3629
  } else if (l.isLinkMergedWithAttribute()) {
3630
3630
  const y = l.getReverseInfo();
@@ -3634,7 +3634,7 @@ ${b}
3634
3634
  for: u,
3635
3635
  joinSource: s,
3636
3636
  joinIdField: [a, y.linkField],
3637
- joinTarget: [d, p]
3637
+ joinTarget: [d, h]
3638
3638
  });
3639
3639
  } else {
3640
3640
  const y = l.getLinkInfo(), b = l.isLinkManyToManySymmetric() ? l.symmetricDirection === "source" : y.isRelationSource(l.parentEntityName, l.attributeName);
@@ -3646,11 +3646,11 @@ ${b}
3646
3646
  }), n.onlyIdField() || r.push({
3647
3647
  for: u,
3648
3648
  joinSource: [f, m],
3649
- joinIdField: [b ? y.record.attributes.target.field : y.record.attributes.source.field, h],
3650
- joinTarget: [d, p]
3649
+ joinIdField: [b ? y.record.attributes.target.field : y.record.attributes.source.field, p],
3650
+ joinTarget: [d, h]
3651
3651
  });
3652
3652
  }
3653
- if (r.push(...this.getJoinTables(n, u, [h, d, p])), n.parentLinkQueryTree && !n.parentLinkQueryTree.onlyIdField()) {
3653
+ if (r.push(...this.getJoinTables(n, u, [p, d, h])), n.parentLinkQueryTree && !n.parentLinkQueryTree.onlyIdField()) {
3654
3654
  const y = u.concat(g), [, b] = this.map.getTableAliasAndFieldName(y, "id", !0), v = [
3655
3655
  b,
3656
3656
  // link 的 idField
@@ -3685,13 +3685,13 @@ ${b}
3685
3685
  },
3686
3686
  // 如果上层还有,就继承上层的,如果没有, context 就只这一层
3687
3687
  i || t
3688
- ), [p, f] = this.buildXToOneFindQuery(d, o, r);
3688
+ ), [h, f] = this.buildXToOneFindQuery(d, o, r);
3689
3689
  return {
3690
3690
  ...a.data,
3691
3691
  isInnerQuery: !0,
3692
3692
  fieldValue: `
3693
3693
  EXISTS (
3694
- ${p}
3694
+ ${h}
3695
3695
  )
3696
3696
  `,
3697
3697
  fieldParams: f
@@ -3770,7 +3770,7 @@ WHERE ${a}
3770
3770
  return e?.toLowerCase() === "json" ? JSON.stringify(t) : t;
3771
3771
  }
3772
3772
  }
3773
- const Jt = ":root";
3773
+ const Kt = ":root";
3774
3774
  class dt {
3775
3775
  constructor(t, e, i = []) {
3776
3776
  this.label = t, this.parent = e, this.stack = i;
@@ -3790,7 +3790,7 @@ class dt {
3790
3790
  }
3791
3791
  class nr {
3792
3792
  constructor(t) {
3793
- this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Jt, t), this.recursiveSaveLabelledRecordQuery(t);
3793
+ this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Kt, t), this.recursiveSaveLabelledRecordQuery(t);
3794
3794
  }
3795
3795
  recursiveSaveLabelledRecordQuery(t) {
3796
3796
  t.attributeQuery?.relatedRecords.forEach((e) => {
@@ -3828,16 +3828,16 @@ class or {
3828
3828
  * 查找记录(主查询方法)
3829
3829
  * CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
3830
3830
  */
3831
- async findRecords(t, e = "", i, r = new dt(Jt), a = !1) {
3831
+ async findRecords(t, e = "", i, r = new dt(Kt), a = !1) {
3832
3832
  if (i || (i = new nr(t)), t.goto) {
3833
3833
  if (t.exit && await t.exit(r))
3834
3834
  return [];
3835
3835
  const f = i.get(t.goto);
3836
3836
  R(f, `goto ${t.goto} not found`);
3837
- const m = t.matchExpression.and(f.matchExpression), h = f.derive({
3837
+ const m = t.matchExpression.and(f.matchExpression), p = f.derive({
3838
3838
  matchExpression: m
3839
3839
  });
3840
- return this.findRecords(h, e, i, r);
3840
+ return this.findRecords(p, e, i, r);
3841
3841
  }
3842
3842
  if (t.label && r.label === t.label && r.stack.length > 1 && r.stack[0].id === r.stack.at(-1).id)
3843
3843
  return [];
@@ -3846,39 +3846,39 @@ class or {
3846
3846
  FOR UPDATE` : s,
3847
3847
  n,
3848
3848
  e
3849
- ), d = this.structureRawReturns(u, this.map.getRecordInfo(t.recordName).JSONFields, o), p = t.label && t.label !== r.label ? r.spawn(t.label) : r;
3850
- await this.completeXToOneLeftoverRecords(t, d, i, p);
3849
+ ), d = this.structureRawReturns(u, this.map.getRecordInfo(t.recordName).JSONFields, o), h = t.label && t.label !== r.label ? r.spawn(t.label) : r;
3850
+ await this.completeXToOneLeftoverRecords(t, d, i, h);
3851
3851
  for (let f of t.attributeQuery.xToOneRecords)
3852
3852
  if (f.goto) {
3853
- const h = this.map.getInfo(f.parentRecord, f.attributeName).getReverseInfo()?.attributeName;
3853
+ const p = this.map.getInfo(f.parentRecord, f.attributeName).getReverseInfo()?.attributeName;
3854
3854
  for (let y of d) {
3855
3855
  const b = f.matchExpression.and({
3856
- key: `${h}.id`,
3856
+ key: `${p}.id`,
3857
3857
  value: ["=", y.id]
3858
3858
  }), v = f.derive({
3859
3859
  matchExpression: b
3860
- }), N = t.label ? p.concat(y) : p;
3860
+ }), N = t.label ? h.concat(y) : h;
3861
3861
  y[f.alias || f.attributeName] = await this.findRecords(v, e, i, N);
3862
3862
  }
3863
3863
  }
3864
3864
  for (let f of t.attributeQuery.xToOneRecords) {
3865
3865
  const m = f.attributeQuery.parentLinkRecordQuery;
3866
3866
  if (m)
3867
- for (let h of m.attributeQuery.xToManyRecords) {
3868
- const b = this.map.getInfo(h.parentRecord, h.attributeName).getReverseInfo()?.attributeName;
3867
+ for (let p of m.attributeQuery.xToManyRecords) {
3868
+ const b = this.map.getInfo(p.parentRecord, p.attributeName).getReverseInfo()?.attributeName;
3869
3869
  for (let v of d) {
3870
- const N = v[f.attributeName][g].id, I = h.derive({
3871
- matchExpression: h.matchExpression.and({
3870
+ const N = v[f.attributeName][g].id, I = p.derive({
3871
+ matchExpression: p.matchExpression.and({
3872
3872
  key: `${b}.id`,
3873
3873
  value: ["=", N]
3874
3874
  })
3875
- }), S = t.label ? p.concat(v) : p;
3875
+ }), S = t.label ? h.concat(v) : h;
3876
3876
  oe(
3877
3877
  v,
3878
- [f.alias || f.attributeName, g, h.attributeName],
3878
+ [f.alias || f.attributeName, g, p.attributeName],
3879
3879
  await this.findRecords(
3880
3880
  I,
3881
- `finding relation data: ${t.recordName}.${f.attributeName}.&.${h.attributeName}`,
3881
+ `finding relation data: ${t.recordName}.${f.attributeName}.&.${p.attributeName}`,
3882
3882
  i,
3883
3883
  S
3884
3884
  )
@@ -3889,14 +3889,14 @@ FOR UPDATE` : s,
3889
3889
  for (let f of t.attributeQuery.xToManyRecords)
3890
3890
  if (!f.onlyRelationData)
3891
3891
  for (let m of d) {
3892
- const h = t.label ? p.concat(m) : p;
3892
+ const p = t.label ? h.concat(m) : h;
3893
3893
  m[f.alias || f.attributeName] = await this.findXToManyRelatedRecords(
3894
3894
  t.recordName,
3895
3895
  f.attributeName,
3896
3896
  m.id,
3897
3897
  f,
3898
3898
  i,
3899
- h
3899
+ p
3900
3900
  );
3901
3901
  }
3902
3902
  return d;
@@ -3955,7 +3955,7 @@ FOR UPDATE` : s,
3955
3955
  }), u = r.attributeQuery.parentLinkRecordQuery ? r.attributeQuery.withParentLinkData() : r.attributeQuery, d = r.derive({
3956
3956
  matchExpression: l,
3957
3957
  attributeQuery: u
3958
- }), p = await this.findRecords(d, `finding related record: ${r.parentRecord}.${r.attributeName}`, a, s), f = r.attributeQuery.parentLinkRecordQuery ? p.map((y) => {
3958
+ }), h = await this.findRecords(d, `finding related record: ${r.parentRecord}.${r.attributeName}`, a, s), f = r.attributeQuery.parentLinkRecordQuery ? h.map((y) => {
3959
3959
  let b;
3960
3960
  return n.isLinkManyToManySymmetric() ? (b = {
3961
3961
  ...y,
@@ -3964,9 +3964,9 @@ FOR UPDATE` : s,
3964
3964
  ...y,
3965
3965
  [g]: y[o][g]
3966
3966
  }, delete b[o]), b;
3967
- }) : p, m = d.label && d.label !== s.label ? s.spawn(d.label) : s, h = r.attributeQuery.parentLinkRecordQuery;
3968
- if (h)
3969
- for (let y of h.attributeQuery.xToManyRecords)
3967
+ }) : h, m = d.label && d.label !== s.label ? s.spawn(d.label) : s, p = r.attributeQuery.parentLinkRecordQuery;
3968
+ if (p)
3969
+ for (let y of p.attributeQuery.xToManyRecords)
3970
3970
  for (let b of f) {
3971
3971
  const v = b[g].id, N = d.label ? m.concat(b) : m;
3972
3972
  oe(
@@ -3992,24 +3992,24 @@ FOR UPDATE` : s,
3992
3992
  key: "id",
3993
3993
  value: ["=", i]
3994
3994
  }), u = O.getAttributeQueryDataForRecord(t, this.map, !0, !0, !1, !0), d = e;
3995
- let p = u;
3995
+ let h = u;
3996
3996
  for (let y of o)
3997
- p.push([y, { attributeQuery: ["*"] }]), p = p.at(-1)[1].attributeQuery;
3998
- p.push([n, { label: d, attributeQuery: ["*"] }]), p = p.at(-1)[1].attributeQuery;
3997
+ h.push([y, { attributeQuery: ["*"] }]), h = h.at(-1)[1].attributeQuery;
3998
+ h.push([n, { label: d, attributeQuery: ["*"] }]), h = h.at(-1)[1].attributeQuery;
3999
3999
  for (let y of o)
4000
- p.push([y, { attributeQuery: ["*"] }]), p = p.at(-1)[1].attributeQuery;
4000
+ h.push([y, { attributeQuery: ["*"] }]), h = h.at(-1)[1].attributeQuery;
4001
4001
  let f;
4002
4002
  const m = async (y) => {
4003
4003
  if (f) return !0;
4004
4004
  if (y.stack.at(-1)?.id === r)
4005
4005
  return f = [...y.stack], !0;
4006
4006
  };
4007
- p.push([n, { goto: d, exit: m }]);
4008
- const h = (await this.findRecords(L.create(t, this.map, {
4007
+ h.push([n, { goto: d, exit: m }]);
4008
+ const p = (await this.findRecords(L.create(t, this.map, {
4009
4009
  matchExpression: l,
4010
4010
  attributeQuery: u
4011
4011
  }), `find records for path ${t}.${e}`))[0];
4012
- return f ? [h, ...f] : void 0;
4012
+ return f ? [p, ...f] : void 0;
4013
4013
  }
4014
4014
  }
4015
4015
  class cr {
@@ -4197,8 +4197,8 @@ class lr {
4197
4197
  attributeQuery: O.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0)
4198
4198
  }), s = await this.helper.findRecords(a, `find record for updating ${t}`), n = [];
4199
4199
  for (let o of s) {
4200
- const l = await this.helper.createRecordDependency(i, r), u = await this.updateSameRowData(a.recordName, o, l, r), d = await this.handleUpdateReliance(a.recordName, o, i, r), p = Object.keys(i.getData());
4201
- await this.filteredEntityManager.updateFilteredEntityFlags(a.recordName, o.id, r, o, !1, p), n.push({ ...i.getData(), ...u.getData(), ...d });
4200
+ const l = await this.helper.createRecordDependency(i, r), u = await this.updateSameRowData(a.recordName, o, l, r), d = await this.handleUpdateReliance(a.recordName, o, i, r), h = Object.keys(i.getData());
4201
+ await this.filteredEntityManager.updateFilteredEntityFlags(a.recordName, o.id, r, o, !1, h), n.push({ ...i.getData(), ...u.getData(), ...d });
4202
4202
  }
4203
4203
  return n;
4204
4204
  }
@@ -4310,11 +4310,11 @@ class ur {
4310
4310
  * 查找记录(主查询方法)- 委托给 QueryExecutor
4311
4311
  * CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
4312
4312
  */
4313
- async findRecords(t, e = "", i, r = new dt(Jt)) {
4313
+ async findRecords(t, e = "", i, r = new dt(Kt)) {
4314
4314
  return this.queryExecutor.findRecords(t, e, i, r);
4315
4315
  }
4316
4316
  async lockRecords(t, e = "") {
4317
- return this.queryExecutor.findRecords(t, e, void 0, new dt(Jt), !0);
4317
+ return this.queryExecutor.findRecords(t, e, void 0, new dt(Kt), !0);
4318
4318
  }
4319
4319
  // 委托给 CreationExecutor
4320
4320
  async createRecordDependency(t, e) {
@@ -4331,9 +4331,9 @@ class ur {
4331
4331
  return this.creationExecutor.preprocessSameRowData(t, e, i, r);
4332
4332
  const a = t.getData();
4333
4333
  if (e && !a.id && (a.id = r.id), t.valueAttributes.length) {
4334
- const o = t.getSameRowFieldAndValue(r), l = this.map.getRecordInfo(t.recordName), u = new Set(l.valueAttributes.map((p) => p.attributeName)), d = { ...t.getData() };
4335
- o.forEach((p) => {
4336
- u.has(p.name) && (d[p.name] = p.value);
4334
+ const o = t.getSameRowFieldAndValue(r), l = this.map.getRecordInfo(t.recordName), u = new Set(l.valueAttributes.map((h) => h.attributeName)), d = { ...t.getData() };
4335
+ o.forEach((h) => {
4336
+ u.has(h.name) && (d[h.name] = h.value);
4337
4337
  }), i?.push({
4338
4338
  type: "update",
4339
4339
  recordName: t.recordName,
@@ -4544,7 +4544,7 @@ class ti {
4544
4544
  return this.map.getInfo(t, e).recordName;
4545
4545
  }
4546
4546
  }
4547
- class vt {
4547
+ class Et {
4548
4548
  constructor(t, e) {
4549
4549
  this.name = t, this.map = e, this.data = this.map.data.records[t];
4550
4550
  }
@@ -4615,7 +4615,7 @@ class vt {
4615
4615
  return this.data.matchExpression;
4616
4616
  }
4617
4617
  get filteredBy() {
4618
- return this.data.filteredBy?.map((t) => new vt(t, this.map));
4618
+ return this.data.filteredBy?.map((t) => new Et(t, this.map));
4619
4619
  }
4620
4620
  get isFilteredEntity() {
4621
4621
  return this.data?.isFilteredEntity;
@@ -4633,7 +4633,7 @@ class vt {
4633
4633
  return this.data?.resolvedMatchExpression;
4634
4634
  }
4635
4635
  }
4636
- class Kt {
4636
+ class Jt {
4637
4637
  constructor(t, e, i, r = !0) {
4638
4638
  this.name = t, this.data = e, this.map = i, this.isFromSource = r;
4639
4639
  }
@@ -4662,10 +4662,10 @@ class Kt {
4662
4662
  return this.data.sourceRecord;
4663
4663
  }
4664
4664
  get sourceRecordInfo() {
4665
- return new vt(this.data.sourceRecord, this.map);
4665
+ return new Et(this.data.sourceRecord, this.map);
4666
4666
  }
4667
4667
  get targetRecordInfo() {
4668
- return new vt(this.data.targetRecord, this.map);
4668
+ return new Et(this.data.targetRecord, this.map);
4669
4669
  }
4670
4670
  get targetRecord() {
4671
4671
  return this.data.targetRecord;
@@ -4721,7 +4721,7 @@ class Kt {
4721
4721
  getBaseLinkInfo() {
4722
4722
  R(this.isFilteredRelation(), "only filtered relation can get base link info");
4723
4723
  const t = this.data.baseLinkName;
4724
- return new Kt(t, this.map.data.links[t], this.map);
4724
+ return new Jt(t, this.map.data.links[t], this.map);
4725
4725
  }
4726
4726
  getMatchExpression() {
4727
4727
  if (this.isFilteredRelation())
@@ -4749,7 +4749,7 @@ class ut {
4749
4749
  return this.data.records[t].attributes[this.getAttributeAndSymmetricDirection(e)[0]];
4750
4750
  }
4751
4751
  getRecordInfo(t) {
4752
- return new vt(t, this);
4752
+ return new Et(t, this);
4753
4753
  }
4754
4754
  getInfo(t, e) {
4755
4755
  const i = this.getInfoByPath([t, ...e.split(".")]);
@@ -4760,10 +4760,10 @@ class ut {
4760
4760
  }
4761
4761
  getLinkInfo(t, e) {
4762
4762
  const i = this.getAttributeAndSymmetricDirection(e)[0], { linkName: r, isSource: a } = this.data.records[t].attributes[i];
4763
- return R(!!r, `cannot find relation ${t} ${i}`), new Kt(r, this.data.links[r], this, !!a);
4763
+ return R(!!r, `cannot find relation ${t} ${i}`), new Jt(r, this.data.links[r], this, !!a);
4764
4764
  }
4765
4765
  getLinkInfoByName(t) {
4766
- return R(!!this.data.links[t], `cannot find link ${t}`), new Kt(t, this.data.links[t], this);
4766
+ return R(!!this.data.links[t], `cannot find link ${t}`), new Jt(t, this.data.links[t], this);
4767
4767
  }
4768
4768
  getInfoByPath(t) {
4769
4769
  const [e, ...i] = t;
@@ -4772,8 +4772,8 @@ class ut {
4772
4772
  const u = [];
4773
4773
  for (; o = i.shift(); ) {
4774
4774
  u.push(o);
4775
- const [d, p] = this.getAttributeAndSymmetricDirection(o);
4776
- l = p, d === g ? (R(!!a && !!s, `reading link in wrong path ${u.join(".")}`), a = this.data.records[a].attributes[s].linkName, s = void 0, r = n.linkName, n = void 0) : (n = this.data.records[r].attributes[d], R(!!n, `attribute ${d} not found in ${r}. namePath: ${t.join(".")}`), a = r, r = n.isRecord ? n.recordName : "", s = d);
4775
+ const [d, h] = this.getAttributeAndSymmetricDirection(o);
4776
+ l = h, d === g ? (R(!!a && !!s, `reading link in wrong path ${u.join(".")}`), a = this.data.records[a].attributes[s].linkName, s = void 0, r = n.linkName, n = void 0) : (n = this.data.records[r].attributes[d], R(!!n, `attribute ${d} not found in ${r}. namePath: ${t.join(".")}`), a = r, r = n.isRecord ? n.recordName : "", s = d);
4777
4777
  }
4778
4778
  if (!(!a || !s))
4779
4779
  return new it(a, s, this, l);
@@ -4796,15 +4796,15 @@ class ut {
4796
4796
  // link: currentLink,
4797
4797
  path: [e]
4798
4798
  }];
4799
- for (let p = 0; p < i.length; p++) {
4800
- const [f, m] = this.getAttributeAndSymmetricDirection(i[p]), h = [e, ...i.slice(0, p + 1)];
4799
+ for (let h = 0; h < i.length; h++) {
4800
+ const [f, m] = this.getAttributeAndSymmetricDirection(i[h]), p = [e, ...i.slice(0, h + 1)];
4801
4801
  if (f === g) {
4802
4802
  const { linkTable: y, linkAlias: b, path: v } = d.pop();
4803
4803
  R(!l, `last attribute in path is a link, cannot read link of a link ${v.join(".")}`), a = y, s = b, r = this.data.records[u.linkName], l = !0, n = "", o = "", u = void 0;
4804
4804
  } else {
4805
- u = this.getInfoByPath(h);
4805
+ u = this.getInfoByPath(p);
4806
4806
  const y = r.attributes[f];
4807
- R(u.isRecord, `${i.slice(0, p + 1).join(".")} is not a entity attribute`);
4807
+ R(u.isRecord, `${i.slice(0, h + 1).join(".")} is not a entity attribute`);
4808
4808
  const b = this.data.records[y.recordName], v = `${s}_${f}${m ? `_${m.toUpperCase()}` : ""}`, N = this.aliasManager?.getTableAlias(v) || v;
4809
4809
  if (u.isMergedWithParent() || u.isLinkMergedWithParent())
4810
4810
  o = s;
@@ -4822,20 +4822,20 @@ class ut {
4822
4822
  isLinkRecord: l,
4823
4823
  linkTable: n,
4824
4824
  linkAlias: o,
4825
- path: h
4825
+ path: p
4826
4826
  });
4827
4827
  }
4828
4828
  return d;
4829
4829
  }
4830
4830
  getTableAliasAndFieldName(t, e, i = !1) {
4831
- const r = this.getTableAndAliasStack(t), { table: a, alias: s, record: n, path: o, linkAlias: l, linkTable: u, isLinkRecord: d } = r.at(-1), p = !d && r.length > 1 ? this.getInfoByPath(o) : null;
4832
- if (!i && e === "id" && !d && t.length > 1 && (p?.isLinkMergedWithParent() || p?.isLinkIsolated()))
4833
- if (p?.isLinkMergedWithParent()) {
4834
- const { alias: m, table: h } = r.at(-2);
4835
- return [m, p.linkField, h];
4831
+ const r = this.getTableAndAliasStack(t), { table: a, alias: s, record: n, path: o, linkAlias: l, linkTable: u, isLinkRecord: d } = r.at(-1), h = !d && r.length > 1 ? this.getInfoByPath(o) : null;
4832
+ if (!i && e === "id" && !d && t.length > 1 && (h?.isLinkMergedWithParent() || h?.isLinkIsolated()))
4833
+ if (h?.isLinkMergedWithParent()) {
4834
+ const { alias: m, table: p } = r.at(-2);
4835
+ return [m, h.linkField, p];
4836
4836
  } else {
4837
- const m = p.getLinkInfo().record, h = p?.isLinkManyToManySymmetric() ? p?.symmetricDirection === "source" ? m?.attributes.target.field : m?.attributes.source.field : p.isRecordSource() ? m?.attributes.target.field : m?.attributes.source.field;
4838
- return [l, h, u];
4837
+ const m = h.getLinkInfo().record, p = h?.isLinkManyToManySymmetric() ? h?.symmetricDirection === "source" ? m?.attributes.target.field : m?.attributes.source.field : h.isRecordSource() ? m?.attributes.target.field : m?.attributes.source.field;
4838
+ return [l, p, u];
4839
4839
  }
4840
4840
  else {
4841
4841
  const m = n.attributes[this.getAttributeAndSymmetricDirection(e)[0]].field;
@@ -4904,11 +4904,11 @@ class ut {
4904
4904
  if (u === "source" || u === "target") {
4905
4905
  const d = this.getInfo(s, l);
4906
4906
  if (d.isRecord) {
4907
- const p = d.getLinkInfo().data;
4907
+ const h = d.getLinkInfo().data;
4908
4908
  let f;
4909
- d.isRecordSource() ? f = p.targetRecord : f = p.sourceRecord;
4909
+ d.isRecordSource() ? f = h.targetRecord : f = h.sourceRecord;
4910
4910
  let m;
4911
- if (u === "source" ? m = p.sourceRecord : m = p.targetRecord, f === m) {
4911
+ if (u === "source" ? m = h.sourceRecord : m = h.targetRecord, f === m) {
4912
4912
  n += 2;
4913
4913
  continue;
4914
4914
  } else {
@@ -4971,7 +4971,7 @@ function pr(c, t) {
4971
4971
  ), e.getAll();
4972
4972
  }
4973
4973
  function ei(c, t, e, i) {
4974
- const r = c.filter((a) => qt(a) !== void 0);
4974
+ const r = c.filter((a) => _t(a) !== void 0);
4975
4975
  for (const a of r)
4976
4976
  fr(
4977
4977
  a,
@@ -4988,11 +4988,11 @@ function fr(c, t, e, i) {
4988
4988
  t
4989
4989
  );
4990
4990
  t.replace(o, c), l !== o && t.add(l);
4991
- const u = qt(c) || [];
4991
+ const u = _t(c) || [];
4992
4992
  if (c.commonProperties) {
4993
- const d = u.filter((p) => c.commonProperties.some((f) => !p.properties.some((m) => m.name === f.name && m.type === f.type)));
4993
+ const d = u.filter((h) => c.commonProperties.some((f) => !h.properties.some((m) => m.name === f.name && m.type === f.type)));
4994
4994
  if (d.length > 0)
4995
- throw new Error(`Merged ${e} ${c.name} defined commonProperties, but these ${e}s do not have commonProperties: ${d.map((p) => p.name).join(", ")}`);
4995
+ throw new Error(`Merged ${e} ${c.name} defined commonProperties, but these ${e}s do not have commonProperties: ${d.map((h) => h.name).join(", ")}`);
4996
4996
  }
4997
4997
  if (u)
4998
4998
  for (const d of u)
@@ -5016,7 +5016,7 @@ function mr(c, t, e, i, r) {
5016
5016
  o && i.replace(a, o);
5017
5017
  }
5018
5018
  function yr(c, t) {
5019
- const e = /* @__PURE__ */ new Map(), i = qt(c);
5019
+ const e = /* @__PURE__ */ new Map(), i = _t(c);
5020
5020
  if (i && i.length > 0)
5021
5021
  for (const r of i) {
5022
5022
  const a = yt(r), s = [...t.get(a) || []], n = e.get(a) || [];
@@ -5035,7 +5035,7 @@ function gr(c, t, e) {
5035
5035
  name: c,
5036
5036
  type: "json",
5037
5037
  defaultValue: (r, a) => {
5038
- const s = qt(t) || [], o = (i.get(a) || []).filter(
5038
+ const s = _t(t) || [], o = (i.get(a) || []).filter(
5039
5039
  (l) => s.some((u) => yt(u) === l)
5040
5040
  );
5041
5041
  return o.length > 0 ? o : [a];
@@ -5043,30 +5043,30 @@ function gr(c, t, e) {
5043
5043
  });
5044
5044
  }
5045
5045
  function br(c, t, e) {
5046
- const i = qt(c) || [], r = [], a = /* @__PURE__ */ new Map(), s = Object.fromEntries(c.commonProperties?.map((n) => [n.name, n]) || []);
5046
+ const i = _t(c) || [], r = [], a = /* @__PURE__ */ new Map(), s = Object.fromEntries(c.commonProperties?.map((n) => [n.name, n]) || []);
5047
5047
  for (const n of i) {
5048
5048
  let o = n;
5049
- if (Lt(o))
5049
+ if (qt(o))
5050
5050
  for (; o.baseEntity && o.properties.length === 0; )
5051
5051
  o = o.baseEntity;
5052
5052
  else if (vr(o))
5053
5053
  for (; o.baseRelation && o.properties.length === 0; )
5054
5054
  o = o.baseRelation;
5055
- const l = Object.fromEntries(o.properties.map((p) => [p.name, p]));
5055
+ const l = Object.fromEntries(o.properties.map((h) => [h.name, h]));
5056
5056
  a.set(n.name, l), Object.assign(s, l);
5057
5057
  const u = n.inputEntities || n.inputRelations, d = [...t.get(n.name) || []];
5058
5058
  for (; d.length; ) {
5059
- const p = d.shift();
5059
+ const h = d.shift();
5060
5060
  if (!u)
5061
- a.set(p, l);
5061
+ a.set(h, l);
5062
5062
  else {
5063
- const f = e.getEntityByName(p) || e.getRelationByName(p);
5063
+ const f = e.getEntityByName(h) || e.getRelationByName(h);
5064
5064
  if (!(f.inputEntities || f.inputRelations)) {
5065
- const h = Object.fromEntries(f.properties.map((y) => [y.name, y]));
5066
- a.set(p, h), Object.assign(s, h);
5065
+ const p = Object.fromEntries(f.properties.map((y) => [y.name, y]));
5066
+ a.set(h, p), Object.assign(s, p);
5067
5067
  }
5068
5068
  }
5069
- d.push(...t.get(p) || []);
5069
+ d.push(...t.get(h) || []);
5070
5070
  }
5071
5071
  }
5072
5072
  for (const n of Object.keys(s)) {
@@ -5093,7 +5093,7 @@ function wr(c, t, e, i) {
5093
5093
  r,
5094
5094
  ...c.properties
5095
5095
  ];
5096
- if (Lt(c)) {
5096
+ if (qt(c)) {
5097
5097
  const s = i.getEntityByName(c.name), n = D.create({
5098
5098
  name: s.name
5099
5099
  });
@@ -5144,7 +5144,7 @@ function wr(c, t, e, i) {
5144
5144
  }
5145
5145
  }
5146
5146
  function Rr(c, t, e) {
5147
- if (Lt(c)) {
5147
+ if (qt(c)) {
5148
5148
  const i = c, r = t;
5149
5149
  let a = i;
5150
5150
  if (i.baseEntity)
@@ -5175,17 +5175,17 @@ function Nr(c) {
5175
5175
  t = t.baseRelation;
5176
5176
  return t;
5177
5177
  }
5178
- function Lt(c) {
5178
+ function qt(c) {
5179
5179
  return "inputEntities" in c || !("sourceProperty" in c);
5180
5180
  }
5181
5181
  function vr(c) {
5182
5182
  return "sourceProperty" in c;
5183
5183
  }
5184
- function qt(c) {
5185
- return Lt(c) ? c.inputEntities : c.inputRelations;
5184
+ function _t(c) {
5185
+ return qt(c) ? c.inputEntities : c.inputRelations;
5186
5186
  }
5187
5187
  function yt(c) {
5188
- return Lt(c), c.name;
5188
+ return qt(c), c.name;
5189
5189
  }
5190
5190
  class Er {
5191
5191
  constructor() {
@@ -5308,7 +5308,7 @@ function Q(c) {
5308
5308
  function ot(c, t) {
5309
5309
  return t.name === "mysql" ? `\`${c.replace(/`/g, "``")}\`` : `"${c.replace(/"/g, '""')}"`;
5310
5310
  }
5311
- function Bt(c, t) {
5311
+ function Ut(c, t) {
5312
5312
  return t.encodeLiteral(c);
5313
5313
  }
5314
5314
  function Tr(c, t, e) {
@@ -5319,16 +5319,16 @@ function Tr(c, t, e) {
5319
5319
  case "isNotNull":
5320
5320
  return `${i} IS NOT NULL`;
5321
5321
  case "equals":
5322
- return t.value === null ? `${i} IS NULL` : `${i} = ${Bt(t.value, e)}`;
5322
+ return t.value === null ? `${i} IS NULL` : `${i} = ${Ut(t.value, e)}`;
5323
5323
  case "notEquals":
5324
- return t.value === null ? `${i} IS NOT NULL` : `${i} != ${Bt(t.value, e)}`;
5324
+ return t.value === null ? `${i} IS NOT NULL` : `${i} != ${Ut(t.value, e)}`;
5325
5325
  case "in": {
5326
5326
  const r = t.value.filter((s) => s !== null), a = [];
5327
- return t.value.some((s) => s === null) && a.push(`${i} IS NULL`), r.length && a.push(`${i} IN (${r.map((s) => Bt(s, e)).join(", ")})`), `(${a.join(" OR ")})`;
5327
+ return t.value.some((s) => s === null) && a.push(`${i} IS NULL`), r.length && a.push(`${i} IN (${r.map((s) => Ut(s, e)).join(", ")})`), `(${a.join(" OR ")})`;
5328
5328
  }
5329
5329
  case "notIn": {
5330
5330
  const r = t.value.filter((s) => s !== null), a = [];
5331
- return t.value.some((s) => s === null) && a.push(`${i} IS NOT NULL`), r.length && a.push(`${i} NOT IN (${r.map((s) => Bt(s, e)).join(", ")})`), `(${a.join(" AND ")})`;
5331
+ return t.value.some((s) => s === null) && a.push(`${i} IS NOT NULL`), r.length && a.push(`${i} NOT IN (${r.map((s) => Ut(s, e)).join(", ")})`), `(${a.join(" AND ")})`;
5332
5332
  }
5333
5333
  }
5334
5334
  }
@@ -5778,15 +5778,15 @@ class ri {
5778
5778
  const [a, ...s] = r.split(".");
5779
5779
  let n = a;
5780
5780
  for (let o = 0; o < s.length; o++) {
5781
- const l = s[o], u = this.map.records[n].attributes[l], d = u.linkName, p = this.map.links[d], { relType: f, sourceRecord: m, targetRecord: h } = p;
5781
+ const l = s[o], u = this.map.records[n].attributes[l], d = u.linkName, h = this.map.links[d], { relType: f, sourceRecord: m, targetRecord: p } = h;
5782
5782
  R(
5783
- f[0] === "1" && f[1] === "1" && m !== h,
5783
+ f[0] === "1" && f[1] === "1" && m !== p,
5784
5784
  `only 1:1 can merge: ${a}.${s.slice(0, o + 1).join(".")}`
5785
5785
  );
5786
- const y = m === n ? h : m, b = this.combineRecordTable(n, y, d);
5786
+ const y = m === n ? p : m, b = this.combineRecordTable(n, y, d);
5787
5787
  if (b)
5788
5788
  throw new Error(`conflict found when join ${d}, ${b.join(",")} already merged with ${n}`);
5789
- p.mergedTo = "combined", i.push(p), n = u.recordName, delete t[d], delete e[d];
5789
+ h.mergedTo = "combined", i.push(h), n = u.recordName, delete t[d], delete e[d];
5790
5790
  }
5791
5791
  }), Object.values(t).forEach((r) => {
5792
5792
  if (r.isFilteredRelation) return;
@@ -6036,12 +6036,12 @@ ${Object.values(this.tables[t].columns).map((i) => ` "${i.name}" ${i.fieldTyp
6036
6036
  if (!l.isRecord) return;
6037
6037
  const u = l.recordName, d = `${e}_${n}`;
6038
6038
  if (this.aliasManager.registerTablePath(d), this.aliasManager.registerTablePath(`${d}_SOURCE`), this.aliasManager.registerTablePath(`${d}_TARGET`), this.aliasManager.registerTablePath(`REL_${d}`), this.aliasManager.registerTablePath(`REL_${d}_SOURCE`), this.aliasManager.registerTablePath(`REL_${d}_TARGET`), i.has(u)) return;
6039
- const p = new Set(i);
6040
- p.add(u), this.generateAliasesForRecord(u, d, p, r + 1, a);
6039
+ const h = new Set(i);
6040
+ h.add(u), this.generateAliasesForRecord(u, d, h, r + 1, a);
6041
6041
  });
6042
6042
  }
6043
6043
  }
6044
- const wt = "_System_", J = "_Dictionary_", ai = "id", si = "_rowId", ni = D.create({
6044
+ const wt = "_System_", K = "_Dictionary_", ai = "id", si = "_rowId", ni = D.create({
6045
6045
  name: wt,
6046
6046
  properties: [
6047
6047
  T.create({
@@ -6061,7 +6061,7 @@ const wt = "_System_", J = "_Dictionary_", ai = "id", si = "_rowId", ni = D.crea
6061
6061
  })
6062
6062
  ]
6063
6063
  }), oi = D.create({
6064
- name: J,
6064
+ name: K,
6065
6065
  properties: [
6066
6066
  T.create({
6067
6067
  name: "key",
@@ -6139,7 +6139,7 @@ class Ci {
6139
6139
  * @returns 是否需要触发计算
6140
6140
  */
6141
6141
  shouldTriggerUpdateComputation(t, e) {
6142
- return t.type !== "update" || !("dataDep" in t) ? !0 : t.dataDep.type === "global" && e.recordName === J ? e.record?.key === t.dataDep.source.name : t.attributes.includes("*") ? Object.keys(e.record || {}).some(
6142
+ return t.type !== "update" || !("dataDep" in t) ? !0 : t.dataDep.type === "global" && e.recordName === K ? e.record?.key === t.dataDep.source.name : t.attributes.includes("*") ? Object.keys(e.record || {}).some(
6143
6143
  (r) => r !== "id" && e.record[r] !== e.oldRecord?.[r]
6144
6144
  ) : !t.attributes.filter((r) => r !== "id").every(
6145
6145
  (r) => !e.record.hasOwnProperty(r) || e.record[r] === e.oldRecord[r]
@@ -6199,15 +6199,15 @@ class Ci {
6199
6199
  } else e.type === "global" && ((!r || r === "update") && s.push({
6200
6200
  dataDep: e,
6201
6201
  type: "update",
6202
- recordName: J,
6203
- sourceRecordName: J,
6202
+ recordName: K,
6203
+ sourceRecordName: K,
6204
6204
  attributes: ["value"],
6205
6205
  computation: i
6206
6206
  }), (!r || r === "create") && s.push({
6207
6207
  dataDep: e,
6208
6208
  type: "create",
6209
- recordName: J,
6210
- sourceRecordName: J,
6209
+ recordName: K,
6210
+ sourceRecordName: K,
6211
6211
  computation: i
6212
6212
  }));
6213
6213
  return s;
@@ -6312,7 +6312,7 @@ class x {
6312
6312
  this.resolved = (t, e) => new ee(t, e);
6313
6313
  }
6314
6314
  static {
6315
- this.async = (t) => new _t(t);
6315
+ this.async = (t) => new Vt(t);
6316
6316
  }
6317
6317
  static {
6318
6318
  this.fullRecompute = (t) => new Xt(t);
@@ -6325,7 +6325,7 @@ class Xt extends x {
6325
6325
  super(), this.reason = t;
6326
6326
  }
6327
6327
  }
6328
- class _t extends x {
6328
+ class Vt extends x {
6329
6329
  constructor(t) {
6330
6330
  super(), this.args = t;
6331
6331
  }
@@ -6514,7 +6514,7 @@ class Ar {
6514
6514
  }
6515
6515
  }
6516
6516
  static {
6517
- this.computationType = At;
6517
+ this.computationType = Ct;
6518
6518
  }
6519
6519
  static {
6520
6520
  this.contextType = "global";
@@ -6547,7 +6547,7 @@ class Cr {
6547
6547
  }
6548
6548
  }
6549
6549
  static {
6550
- this.computationType = At;
6550
+ this.computationType = Ct;
6551
6551
  }
6552
6552
  static {
6553
6553
  this.contextType = "property";
@@ -6609,7 +6609,7 @@ class Ir {
6609
6609
  };
6610
6610
  }
6611
6611
  static {
6612
- this.computationType = Ct;
6612
+ this.computationType = $t;
6613
6613
  }
6614
6614
  static {
6615
6615
  this.contextType = "global";
@@ -6668,7 +6668,7 @@ class xr {
6668
6668
  };
6669
6669
  }
6670
6670
  static {
6671
- this.computationType = Ct;
6671
+ this.computationType = $t;
6672
6672
  }
6673
6673
  static {
6674
6674
  this.contextType = "property";
@@ -6720,8 +6720,8 @@ class xr {
6720
6720
  this.relationAttributeQuery
6721
6721
  ), l = o[this.isSource ? "target" : "source"];
6722
6722
  l["&"] = o;
6723
- const u = this.matchRecordToWeight.call(this.controller, l, r), d = u.weight * u.value, { oldValue: p } = await this.state.itemResult.replace(o, d);
6724
- a = d - (p ?? 0);
6723
+ const u = this.matchRecordToWeight.call(this.controller, l, r), d = u.weight * u.value, { oldValue: h } = await this.state.itemResult.replace(o, d);
6724
+ a = d - (h ?? 0);
6725
6725
  }
6726
6726
  return this.state.total.increment(e.record, a);
6727
6727
  }
@@ -6739,7 +6739,7 @@ class Pr {
6739
6739
  }, this.defaultValue = !this.args.notEmpty;
6740
6740
  }
6741
6741
  static {
6742
- this.computationType = Mt;
6742
+ this.computationType = Pt;
6743
6743
  }
6744
6744
  static {
6745
6745
  this.contextType = "global";
@@ -6807,7 +6807,7 @@ class Dr {
6807
6807
  };
6808
6808
  }
6809
6809
  static {
6810
- this.computationType = Mt;
6810
+ this.computationType = Pt;
6811
6811
  }
6812
6812
  static {
6813
6813
  this.contextType = "property";
@@ -6837,19 +6837,19 @@ class Dr {
6837
6837
  const a = e.relatedMutationEvent;
6838
6838
  let s = 0, n = 0;
6839
6839
  if (a.type === "create" && a.recordName === this.relation.name) {
6840
- const u = a.record, p = (await this.controller.system.storage.findOne(this.relation.name, w.atom({
6840
+ const u = a.record, h = (await this.controller.system.storage.findOne(this.relation.name, w.atom({
6841
6841
  key: "id",
6842
6842
  value: ["=", u.id]
6843
6843
  }), void 0, this.relationAttributeQuery))[this.isSource ? "target" : "source"];
6844
- p["&"] = u;
6845
- const f = !!this.callback.call(this.controller, p, r);
6844
+ h["&"] = u;
6845
+ const f = !!this.callback.call(this.controller, h, r);
6846
6846
  let m;
6847
6847
  try {
6848
6848
  ({ oldValue: m } = await this.state.isItemMatch.replace(u, f));
6849
- } catch (h) {
6850
- if (h instanceof Error && h.message.includes("Atomic replace target not found"))
6849
+ } catch (p) {
6850
+ if (p instanceof Error && p.message.includes("Atomic replace target not found"))
6851
6851
  return x.fullRecompute("relation contribution state target not found");
6852
- throw h;
6852
+ throw p;
6853
6853
  }
6854
6854
  s = Number(f) - +!!m, n = 1;
6855
6855
  } else if (a.type === "delete" && a.recordName === this.relation.name) {
@@ -6866,18 +6866,18 @@ class Dr {
6866
6866
  ), d = w.atom({
6867
6867
  key: u,
6868
6868
  value: ["=", a.oldRecord.id]
6869
- }), p = await this.controller.system.storage.findOne(this.relation.name, d, void 0, this.relationAttributeQuery), f = p[this.isSource ? "target" : "source"];
6870
- f["&"] = p;
6869
+ }), h = await this.controller.system.storage.findOne(this.relation.name, d, void 0, this.relationAttributeQuery), f = h[this.isSource ? "target" : "source"];
6870
+ f["&"] = h;
6871
6871
  const m = !!this.callback.call(this.controller, f, r);
6872
- let h;
6872
+ let p;
6873
6873
  try {
6874
- ({ oldValue: h } = await this.state.isItemMatch.replace(p, m));
6874
+ ({ oldValue: p } = await this.state.isItemMatch.replace(h, m));
6875
6875
  } catch (y) {
6876
6876
  if (y instanceof Error && y.message.includes("Atomic replace target not found"))
6877
6877
  return x.fullRecompute("relation contribution state target not found");
6878
6878
  throw y;
6879
6879
  }
6880
- s = Number(m) - +!!h;
6880
+ s = Number(m) - +!!p;
6881
6881
  } else
6882
6882
  return x.fullRecompute("mutation is not caused by relation.");
6883
6883
  const o = await this.state.matchCount.increment(e.record, s), l = await this.state.totalCount.increment(e.record, n);
@@ -6897,7 +6897,7 @@ class Fr {
6897
6897
  };
6898
6898
  }
6899
6899
  static {
6900
- this.computationType = Pt;
6900
+ this.computationType = Dt;
6901
6901
  }
6902
6902
  static {
6903
6903
  this.contextType = "global";
@@ -6961,7 +6961,7 @@ class Lr {
6961
6961
  };
6962
6962
  }
6963
6963
  static {
6964
- this.computationType = Pt;
6964
+ this.computationType = Dt;
6965
6965
  }
6966
6966
  static {
6967
6967
  this.contextType = "property";
@@ -6994,8 +6994,8 @@ class Lr {
6994
6994
  value: ["=", o.id]
6995
6995
  }), void 0, this.relationAttributeQuery))[this.isSource ? "target" : "source"];
6996
6996
  u["&"] = o;
6997
- const d = !!this.callback.call(this.controller, u, r), { oldValue: p } = await this.state.isItemMatch.replace(o, d);
6998
- a = Number(d) - +!!p;
6997
+ const d = !!this.callback.call(this.controller, u, r), { oldValue: h } = await this.state.isItemMatch.replace(o, d);
6998
+ a = Number(d) - +!!h;
6999
6999
  } else if (s.type === "delete" && s.recordName === this.relation.name) {
7000
7000
  const o = s.record;
7001
7001
  a = !!await this.state.isItemMatch.get(o) ? -1 : 0;
@@ -7012,8 +7012,8 @@ class Lr {
7012
7012
  value: ["=", s.oldRecord.id]
7013
7013
  }), u = await this.controller.system.storage.findOne(this.relation.name, l, void 0, this.relationAttributeQuery), d = u[this.isSource ? "target" : "source"];
7014
7014
  d["&"] = u;
7015
- const p = !!this.callback.call(this.controller, d, r), { oldValue: f } = await this.state.isItemMatch.replace(u, p);
7016
- a = Number(p) - +!!f;
7015
+ const h = !!this.callback.call(this.controller, d, r), { oldValue: f } = await this.state.isItemMatch.replace(u, h);
7016
+ a = Number(h) - +!!f;
7017
7017
  } else
7018
7018
  return x.fullRecompute("mutation is not caused by relation.");
7019
7019
  return await this.state.matchCount.increment(e.record, a) > 0;
@@ -7032,7 +7032,7 @@ class _r {
7032
7032
  };
7033
7033
  }
7034
7034
  static {
7035
- this.computationType = $t;
7035
+ this.computationType = It;
7036
7036
  }
7037
7037
  static {
7038
7038
  this.contextType = "global";
@@ -7090,7 +7090,7 @@ class Vr {
7090
7090
  };
7091
7091
  }
7092
7092
  static {
7093
- this.computationType = $t;
7093
+ this.computationType = It;
7094
7094
  }
7095
7095
  static {
7096
7096
  this.contextType = "property";
@@ -7132,8 +7132,8 @@ class Vr {
7132
7132
  this.relationAttributeQuery
7133
7133
  ))[this.isSource ? "target" : "source"];
7134
7134
  u["&"] = o;
7135
- const d = !!this.callback.call(this.controller, u, r), { oldValue: p } = await this.state.isItemMatchCount.replace(o, d);
7136
- s = Number(d) - +!!p;
7135
+ const d = !!this.callback.call(this.controller, u, r), { oldValue: h } = await this.state.isItemMatchCount.replace(o, d);
7136
+ s = Number(d) - +!!h;
7137
7137
  } else
7138
7138
  s = 1;
7139
7139
  else if (a.type === "delete" && a.recordName === this.relation.name)
@@ -7153,8 +7153,8 @@ class Vr {
7153
7153
  this.relationAttributeQuery
7154
7154
  ), u = l[this.isSource ? "target" : "source"];
7155
7155
  u["&"] = l;
7156
- const d = !!this.callback.call(this.controller, u, r), { oldValue: p } = await this.state.isItemMatchCount.replace(l, d);
7157
- s = Number(d) - +!!p;
7156
+ const d = !!this.callback.call(this.controller, u, r), { oldValue: h } = await this.state.isItemMatchCount.replace(l, d);
7157
+ s = Number(d) - +!!h;
7158
7158
  }
7159
7159
  } else
7160
7160
  return x.fullRecompute(`unknown related mutation event for ${this.dataContext.host.name}.${this.dataContext.id.name}`);
@@ -7344,14 +7344,14 @@ const ci = [10, 25, 60, 150, 350];
7344
7344
  function Wr(c) {
7345
7345
  return new Promise((t) => setTimeout(t, c));
7346
7346
  }
7347
- function Ut(c, t, e, i) {
7347
+ function Ht(c, t, e, i) {
7348
7348
  return c && typeof c == "object" && Object.assign(c, {
7349
7349
  transactionAttempts: t,
7350
7350
  transactionIsolation: e,
7351
7351
  transactionName: i
7352
7352
  }), c;
7353
7353
  }
7354
- class jt extends Error {
7354
+ class Wt extends Error {
7355
7355
  constructor(t, e, i, r) {
7356
7356
  super(`Transaction retry exhausted for ${t} after ${e} attempts`, { cause: r }), this.name = "TransactionRetryExhaustedError", this.transactionAttempts = e, this.transactionIsolation = i, this.transactionName = t, Object.assign(this, {
7357
7357
  transactionAttempts: e,
@@ -7361,7 +7361,7 @@ class jt extends Error {
7361
7361
  }
7362
7362
  }
7363
7363
  function Ss(c) {
7364
- return Y(c).some((t) => t instanceof jt);
7364
+ return Y(c).some((t) => t instanceof Wt);
7365
7365
  }
7366
7366
  function ks(c) {
7367
7367
  return Y(c).some((t) => t instanceof Re);
@@ -7376,11 +7376,11 @@ async function De(c, t, e = {}) {
7376
7376
  } catch (n) {
7377
7377
  if (s = n, Ur(n)) {
7378
7378
  if (r = "SERIALIZABLE", a < i) continue;
7379
- throw new jt(
7379
+ throw new Wt(
7380
7380
  c,
7381
7381
  a,
7382
7382
  r,
7383
- Ut(n, a, r, c)
7383
+ Ht(n, a, r, c)
7384
7384
  );
7385
7385
  }
7386
7386
  if (Hr(n)) {
@@ -7389,17 +7389,17 @@ async function De(c, t, e = {}) {
7389
7389
  await Wr(o + l);
7390
7390
  continue;
7391
7391
  }
7392
- throw new jt(
7392
+ throw new Wt(
7393
7393
  c,
7394
7394
  a,
7395
7395
  r,
7396
- Ut(n, a, r, c)
7396
+ Ht(n, a, r, c)
7397
7397
  );
7398
7398
  }
7399
- throw Ut(n, a, r, c);
7399
+ throw Ht(n, a, r, c);
7400
7400
  }
7401
7401
  }
7402
- throw new jt(c, a, r, Ut(s, a, r, c));
7402
+ throw new Wt(c, a, r, Ht(s, a, r, c));
7403
7403
  }
7404
7404
  class Gr {
7405
7405
  constructor(t, e, i) {
@@ -7489,8 +7489,8 @@ class Gr {
7489
7489
  );
7490
7490
  if (!d)
7491
7491
  return [];
7492
- const p = await this.transformCallback.call(this.controller, d);
7493
- s = Array.isArray(p) ? p : [p];
7492
+ const h = await this.transformCallback.call(this.controller, d);
7493
+ s = Array.isArray(h) ? h : [h];
7494
7494
  }
7495
7495
  const n = w.atom({ key: this.state.sourceRecordId.key, value: ["=", a] }), l = (await this.controller.system.storage.atomic.lockRows(i.id.name, n, ["*"])).reduce((u, d) => (u[Number(d[this.state.transformIndex.key])] = d, u), {});
7496
7496
  s.forEach((u, d) => {
@@ -7520,7 +7520,7 @@ class Gr {
7520
7520
  return r;
7521
7521
  }
7522
7522
  }
7523
- const Jr = [Gr];
7523
+ const Kr = [Gr];
7524
7524
  class _ {
7525
7525
  constructor(t) {
7526
7526
  this.node = t;
@@ -7792,12 +7792,12 @@ class Oe {
7792
7792
  }
7793
7793
  }
7794
7794
  }
7795
- class Kr {
7795
+ class Jr {
7796
7796
  constructor(t, e, i) {
7797
7797
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !1, this.dataDeps = this.args.dataDeps ?? {}, this.callback = (r, a) => this.args.callback.call(this.controller, r, a), this.nextRecomputeTime = this.args.nextRecomputeTime ? (r, a) => this.args.nextRecomputeTime.call(this.controller, r, a) : void 0;
7798
7798
  }
7799
7799
  static {
7800
- this.computationType = Dt;
7800
+ this.computationType = Ot;
7801
7801
  }
7802
7802
  static {
7803
7803
  this.contextType = "global";
@@ -7835,7 +7835,7 @@ class Xr {
7835
7835
  }, this.isResultNumber = this.dataContext.id.type === "number", this.callback = (r, a) => this.args.callback.call(this.controller, r, a), this.nextRecomputeTime = this.args.nextRecomputeTime ? (r, a) => this.args.nextRecomputeTime.call(this.controller, r, a) : void 0;
7836
7836
  }
7837
7837
  static {
7838
- this.computationType = Dt;
7838
+ this.computationType = Ot;
7839
7839
  }
7840
7840
  static {
7841
7841
  this.contextType = "property";
@@ -7862,7 +7862,7 @@ class Xr {
7862
7862
  return await this.state.lastRecomputeTime.setInternal(e, r), await this.state.nextRecomputeTime.setInternal(e, s), a;
7863
7863
  }
7864
7864
  }
7865
- const zr = [Kr, Xr];
7865
+ const zr = [Jr, Xr];
7866
7866
  class Yr {
7867
7867
  constructor(t, e, i) {
7868
7868
  if (this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !1, this.dataDeps = {}, this.record = this.args.record, !this.args.attributeQuery || this.args.attributeQuery.length === 0)
@@ -7880,7 +7880,7 @@ class Yr {
7880
7880
  };
7881
7881
  }
7882
7882
  static {
7883
- this.computationType = It;
7883
+ this.computationType = xt;
7884
7884
  }
7885
7885
  static {
7886
7886
  this.contextType = "global";
@@ -7945,7 +7945,7 @@ class Zr {
7945
7945
  };
7946
7946
  }
7947
7947
  static {
7948
- this.computationType = It;
7948
+ this.computationType = xt;
7949
7949
  }
7950
7950
  static {
7951
7951
  this.contextType = "property";
@@ -8031,7 +8031,7 @@ class ea {
8031
8031
  };
8032
8032
  }
8033
8033
  static {
8034
- this.computationType = xt;
8034
+ this.computationType = Mt;
8035
8035
  }
8036
8036
  static {
8037
8037
  this.contextType = "global";
@@ -8069,8 +8069,8 @@ class ea {
8069
8069
  w.atom({ key: "id", value: ["=", e.record.id] }),
8070
8070
  void 0,
8071
8071
  this.args.attributeQuery
8072
- ), d = this.resolveAvgField(u) || 0, { oldValue: p } = await this.state.itemValue.replace(u, d);
8073
- a = d - (p ?? 0), s = 1;
8072
+ ), d = this.resolveAvgField(u) || 0, { oldValue: h } = await this.state.itemValue.replace(u, d);
8073
+ a = d - (h ?? 0), s = 1;
8074
8074
  } else if (e.type === "delete")
8075
8075
  a = -(await this.state.itemValue.get(e.record) || 0), s = -1;
8076
8076
  else if (e.type === "update") {
@@ -8079,8 +8079,8 @@ class ea {
8079
8079
  w.atom({ key: "id", value: ["=", e.record.id] }),
8080
8080
  void 0,
8081
8081
  this.args.attributeQuery
8082
- ), d = this.resolveAvgField(u) || 0, { oldValue: p } = await this.state.itemValue.replace(u, d);
8083
- a = d - (p ?? 0);
8082
+ ), d = this.resolveAvgField(u) || 0, { oldValue: h } = await this.state.itemValue.replace(u, d);
8083
+ a = d - (h ?? 0);
8084
8084
  }
8085
8085
  const n = await this.controller.system.storage.atomic.updateGlobalFields(
8086
8086
  {
@@ -8115,7 +8115,7 @@ class ia {
8115
8115
  };
8116
8116
  }
8117
8117
  static {
8118
- this.computationType = xt;
8118
+ this.computationType = Mt;
8119
8119
  }
8120
8120
  static {
8121
8121
  this.contextType = "property";
@@ -8158,9 +8158,9 @@ class ia {
8158
8158
  w.atom({ key: "id", value: ["=", u.id] }),
8159
8159
  void 0,
8160
8160
  this.relationAttributeQuery
8161
- ), p = d[this.isSource ? "target" : "source"];
8162
- p["&"] = d;
8163
- const f = this.resolveAvgField(p) || 0, { oldValue: m } = await this.state.itemResult.replace(d, f);
8161
+ ), h = d[this.isSource ? "target" : "source"];
8162
+ h["&"] = d;
8163
+ const f = this.resolveAvgField(h) || 0, { oldValue: m } = await this.state.itemResult.replace(d, f);
8164
8164
  s = f - (m ?? 0), n = 1;
8165
8165
  } else if (a.type === "delete" && a.recordName === this.relation.name)
8166
8166
  s = -(await this.state.itemResult.get(a.record) ?? 0), n = -1;
@@ -8172,8 +8172,8 @@ class ia {
8172
8172
  this.relationAttributeQuery
8173
8173
  ), d = u[this.isSource ? "target" : "source"];
8174
8174
  d["&"] = u;
8175
- const p = this.resolveAvgField(d) || 0, { oldValue: f } = await this.state.itemResult.replace(u, p);
8176
- s = p - (f ?? 0);
8175
+ const h = this.resolveAvgField(d) || 0, { oldValue: f } = await this.state.itemResult.replace(u, h);
8176
+ s = h - (f ?? 0);
8177
8177
  }
8178
8178
  const o = await this.state.sum.increment(e.record, s), l = await this.state.count.increment(e.record, n);
8179
8179
  return l > 0 ? o / l : 0;
@@ -8540,10 +8540,10 @@ class ha {
8540
8540
  C(!!u, `cannot find Computation handle map for ${l.constructor.displayName || l.constructor.name}`);
8541
8541
  const d = u[o.type];
8542
8542
  C(!!d, `cannot find Computation handle for ${l.constructor.displayName || l.constructor.name} with context type ${o.type}`);
8543
- const p = new d(this.controller, l, o);
8544
- if (this.computationsHandles.set(o.id, p), this.isAsyncComputation(p)) {
8545
- const f = this.getAsyncTaskRecordKey(p);
8546
- if (p.dataContext.type === "property") {
8543
+ const h = new d(this.controller, l, o);
8544
+ if (this.computationsHandles.set(o.id, h), this.isAsyncComputation(h)) {
8545
+ const f = this.getAsyncTaskRecordKey(h);
8546
+ if (h.dataContext.type === "property") {
8547
8547
  const m = new D({
8548
8548
  name: f,
8549
8549
  properties: [
@@ -8564,16 +8564,16 @@ class ha {
8564
8564
  type: "string"
8565
8565
  }, { uuid: `${f}_freshnessKey` })
8566
8566
  ]
8567
- }, { uuid: f }), h = new F({
8568
- name: `${m.name}_${p.dataContext.host.name}_${p.dataContext.id.name}`,
8567
+ }, { uuid: f }), p = new F({
8568
+ name: `${m.name}_${h.dataContext.host.name}_${h.dataContext.id.name}`,
8569
8569
  source: m,
8570
- target: p.dataContext.host,
8570
+ target: h.dataContext.host,
8571
8571
  sourceProperty: "record",
8572
- targetProperty: `_${p.dataContext.id.name}_task`,
8572
+ targetProperty: `_${h.dataContext.id.name}_task`,
8573
8573
  type: "1:1"
8574
8574
  }, { uuid: `${f}_record_relation` });
8575
- e.push(m), i.push(h);
8576
- } else if (p.dataContext.type === "global") {
8575
+ e.push(m), i.push(p);
8576
+ } else if (h.dataContext.type === "global") {
8577
8577
  const m = new D({
8578
8578
  name: f,
8579
8579
  properties: [
@@ -8600,8 +8600,8 @@ class ha {
8600
8600
  ]
8601
8601
  }, { uuid: f });
8602
8602
  e.push(m);
8603
- } else if (p.dataContext.type === "entity") {
8604
- p.dataContext;
8603
+ } else if (h.dataContext.type === "entity") {
8604
+ h.dataContext;
8605
8605
  const m = new D({
8606
8606
  name: f,
8607
8607
  properties: [
@@ -8628,8 +8628,8 @@ class ha {
8628
8628
  ]
8629
8629
  }, { uuid: f });
8630
8630
  e.push(m);
8631
- } else if (p.dataContext.type === "relation") {
8632
- p.dataContext;
8631
+ } else if (h.dataContext.type === "relation") {
8632
+ h.dataContext;
8633
8633
  const m = new D({
8634
8634
  name: f,
8635
8635
  properties: [
@@ -8776,7 +8776,7 @@ class ha {
8776
8776
  }
8777
8777
  async computeDataBasedDirtyRecordsAndEvents(t, e) {
8778
8778
  let i = [];
8779
- if (t.dataDep.type === "global" && e.recordName === J)
8779
+ if (t.dataDep.type === "global" && e.recordName === K)
8780
8780
  if (t.computation.dataContext.type === "property") {
8781
8781
  const r = t.computation.dataContext;
8782
8782
  i = (await this.controller.system.storage.find(r.host.name, w.atom({ key: "id", value: ["not", null] }), {}, ["*"])).map((s) => [s, {
@@ -9033,7 +9033,7 @@ class ha {
9033
9033
  }
9034
9034
  if (a instanceof ht)
9035
9035
  return;
9036
- if (a instanceof _t)
9036
+ if (a instanceof Vt)
9037
9037
  try {
9038
9038
  return await this.createAsyncTask(t, a.args, i);
9039
9039
  } catch (o) {
@@ -9159,11 +9159,11 @@ class he extends M {
9159
9159
  }
9160
9160
  class As extends M {
9161
9161
  }
9162
- class Et extends M {
9162
+ class Tt extends M {
9163
9163
  }
9164
9164
  class Ve extends M {
9165
9165
  }
9166
- class Tt extends M {
9166
+ class St extends M {
9167
9167
  }
9168
9168
  class fa extends M {
9169
9169
  }
@@ -9280,7 +9280,7 @@ ${i.text}`).join(`
9280
9280
  };
9281
9281
  }
9282
9282
  function Na(c, t = !1) {
9283
- const e = c.args, i = ga(c), r = ba(c), a = wa(c), s = a.map((b) => b.key), n = re(c), o = P(c.dataContext), l = c.dataContext.type === "entity" || c.dataContext.type === "relation" ? c.dataContext.id.name : void 0, u = c.constructor?.name || String(e._type || e.constructor?.name || "UnknownComputation"), d = st("computation", n, c.args.uuid), p = Ra(e, t), f = nt({
9283
+ const e = c.args, i = ga(c), r = ba(c), a = wa(c), s = a.map((b) => b.key), n = re(c), o = P(c.dataContext), l = c.dataContext.type === "entity" || c.dataContext.type === "relation" ? c.dataContext.id.name : void 0, u = c.constructor?.name || String(e._type || e.constructor?.name || "UnknownComputation"), d = st("computation", n, c.args.uuid), h = Ra(e, t), f = nt({
9284
9284
  type: u,
9285
9285
  dataContext: o,
9286
9286
  dataDeps: i,
@@ -9288,19 +9288,19 @@ function Na(c, t = !1) {
9288
9288
  hasCompute: typeof c.compute == "function",
9289
9289
  hasIncrementalCompute: typeof c.incrementalCompute == "function",
9290
9290
  hasIncrementalPatchCompute: typeof c.incrementalPatchCompute == "function"
9291
- }), m = nt({ stateKeys: s, boundStates: a }), h = nt({
9291
+ }), m = nt({ stateKeys: s, boundStates: a }), p = nt({
9292
9292
  type: u,
9293
9293
  dataContext: o,
9294
9294
  outputRecord: l,
9295
9295
  outputProperty: c.dataContext.type === "property" ? c.dataContext.id.name : void 0,
9296
9296
  deps: i,
9297
9297
  eventDeps: r,
9298
- callbackPaths: p?.callbackPaths || [],
9299
- hasFunction: p?.hasFunction === !0,
9298
+ callbackPaths: h?.callbackPaths || [],
9299
+ hasFunction: h?.hasFunction === !0,
9300
9300
  hasCompute: typeof c.compute == "function",
9301
9301
  hasIncrementalCompute: typeof c.incrementalCompute == "function",
9302
9302
  hasIncrementalPatchCompute: typeof c.incrementalPatchCompute == "function"
9303
- }), y = nt({ structuralSignature: h, stateSignature: m, functionHash: p?.hash });
9303
+ }), y = nt({ structuralSignature: p, stateSignature: m, functionHash: h?.hash });
9304
9304
  return {
9305
9305
  id: n,
9306
9306
  identity: d,
@@ -9323,12 +9323,12 @@ function Na(c, t = !1) {
9323
9323
  } : void 0,
9324
9324
  outputSignature: f,
9325
9325
  stateSignature: m,
9326
- structuralSignature: h,
9327
- functionSignature: p,
9326
+ structuralSignature: p,
9327
+ functionSignature: h,
9328
9328
  signature: y
9329
9329
  };
9330
9330
  }
9331
- function Ht(c, t = c.system.storage.schema, e = {}) {
9331
+ function jt(c, t = c.system.storage.schema, e = {}) {
9332
9332
  const i = [
9333
9333
  ...c.entities.map((l) => {
9334
9334
  const u = st("entity", `entity:${l.name}`, l.uuid);
@@ -9338,10 +9338,10 @@ function Ht(c, t = c.system.storage.schema, e = {}) {
9338
9338
  name: l.name,
9339
9339
  kind: "entity",
9340
9340
  properties: (l.properties || []).map((d) => {
9341
- const p = st("property", `property:${l.name}.${d.name}`, d.uuid);
9341
+ const h = st("property", `property:${l.name}.${d.name}`, d.uuid);
9342
9342
  return {
9343
- id: ct(p),
9344
- identity: p,
9343
+ id: ct(h),
9344
+ identity: h,
9345
9345
  name: d.name,
9346
9346
  type: d.type,
9347
9347
  collection: d.collection === !0,
@@ -9358,10 +9358,10 @@ function Ht(c, t = c.system.storage.schema, e = {}) {
9358
9358
  name: l.name,
9359
9359
  kind: "relation",
9360
9360
  properties: (l.properties || []).map((d) => {
9361
- const p = st("property", `property:${l.name}.${d.name}`, d.uuid);
9361
+ const h = st("property", `property:${l.name}.${d.name}`, d.uuid);
9362
9362
  return {
9363
- id: ct(p),
9364
- identity: p,
9363
+ id: ct(h),
9364
+ identity: h,
9365
9365
  name: d.name,
9366
9366
  type: d.type,
9367
9367
  collection: d.collection === !0,
@@ -9423,7 +9423,7 @@ function Cs(c, t) {
9423
9423
  return !r || r.signature !== i.signature;
9424
9424
  });
9425
9425
  }
9426
- function Wt(c) {
9426
+ function Rt(c) {
9427
9427
  if (c.kind === "computation") return `${c.kind}:${c.id}`;
9428
9428
  const t = c.kind === "destructive-scope" && c.recordName || "";
9429
9429
  return `${c.kind}:${c.dataContext}:${t}`;
@@ -9455,31 +9455,31 @@ function Pi(c, t) {
9455
9455
  return Mi(c?.handlers?.asyncCompletion, e?.handlerRef);
9456
9456
  }
9457
9457
  function Ta(c, t, e, i) {
9458
- const r = [], a = [], s = new Map(c.computations.map((h) => [h.id, h])), n = new Map(t.computations.map((h) => [h.id, h])), o = new Map(c.records.map((h) => [h.id, h])), l = new Map(t.records.map((h) => [h.id, h])), u = new Map(c.relations.map((h) => [h.id, h])), d = new Map(t.relations.map((h) => [h.id, h])), p = new Map((c.dictionaries || []).map((h) => [h.id, h])), f = new Map((t.dictionaries || []).map((h) => [h.id, h]));
9459
- for (const h of c.records)
9460
- l.has(h.id) || r.push({
9458
+ const r = [], a = [], s = new Map(c.computations.map((p) => [p.id, p])), n = new Map(t.computations.map((p) => [p.id, p])), o = new Map(c.records.map((p) => [p.id, p])), l = new Map(t.records.map((p) => [p.id, p])), u = new Map(c.relations.map((p) => [p.id, p])), d = new Map(t.relations.map((p) => [p.id, p])), h = new Map((c.dictionaries || []).map((p) => [p.id, p])), f = new Map((t.dictionaries || []).map((p) => [p.id, p]));
9459
+ for (const p of c.records)
9460
+ l.has(p.id) || r.push({
9461
9461
  kind: "record",
9462
- id: h.id,
9462
+ id: p.id,
9463
9463
  changeType: "removed",
9464
- dataContext: `${h.kind}:${h.name}`,
9465
- reason: `${h.kind} no longer exists in the new model`
9464
+ dataContext: `${p.kind}:${p.name}`,
9465
+ reason: `${p.kind} no longer exists in the new model`
9466
9466
  });
9467
- for (const h of t.records) {
9468
- const y = o.get(h.id);
9469
- y ? (y.kind !== h.kind || y.name !== h.name) && r.push({
9467
+ for (const p of t.records) {
9468
+ const y = o.get(p.id);
9469
+ y ? (y.kind !== p.kind || y.name !== p.name) && r.push({
9470
9470
  kind: "record",
9471
- id: h.id,
9471
+ id: p.id,
9472
9472
  changeType: "changed",
9473
- dataContext: `${h.kind}:${h.name}`,
9473
+ dataContext: `${p.kind}:${p.name}`,
9474
9474
  reason: "record kind or name changed"
9475
9475
  }) : r.push({
9476
9476
  kind: "record",
9477
- id: h.id,
9477
+ id: p.id,
9478
9478
  changeType: "added",
9479
- dataContext: `${h.kind}:${h.name}`,
9480
- reason: `${h.kind} was added`
9479
+ dataContext: `${p.kind}:${p.name}`,
9480
+ reason: `${p.kind} was added`
9481
9481
  });
9482
- const b = new Map((y?.properties || []).map((N) => [N.id, N])), v = new Map(h.properties.map((N) => [N.id, N]));
9482
+ const b = new Map((y?.properties || []).map((N) => [N.id, N])), v = new Map(p.properties.map((N) => [N.id, N]));
9483
9483
  for (const N of y?.properties || [])
9484
9484
  v.has(N.id) || r.push({
9485
9485
  kind: "property",
@@ -9488,142 +9488,142 @@ function Ta(c, t, e, i) {
9488
9488
  dataContext: `property:${y?.name}.${N.name}`,
9489
9489
  reason: "property no longer exists in the new model"
9490
9490
  });
9491
- for (const N of h.properties) {
9491
+ for (const N of p.properties) {
9492
9492
  const I = b.get(N.id);
9493
9493
  I ? (I.name !== N.name || I.type !== N.type || I.collection !== N.collection || I.computed !== N.computed) && r.push({
9494
9494
  kind: "property",
9495
9495
  id: N.id,
9496
9496
  changeType: "changed",
9497
- dataContext: `property:${h.name}.${N.name}`,
9497
+ dataContext: `property:${p.name}.${N.name}`,
9498
9498
  reason: "property name, type, collection, or computed flag changed"
9499
9499
  }) : r.push({
9500
9500
  kind: "property",
9501
9501
  id: N.id,
9502
9502
  changeType: "added",
9503
- dataContext: `property:${h.name}.${N.name}`,
9503
+ dataContext: `property:${p.name}.${N.name}`,
9504
9504
  reason: "property was added"
9505
9505
  });
9506
9506
  }
9507
9507
  }
9508
- for (const h of c.relations)
9509
- d.has(h.id) || r.push({
9508
+ for (const p of c.relations)
9509
+ d.has(p.id) || r.push({
9510
9510
  kind: "relation",
9511
- id: h.id,
9511
+ id: p.id,
9512
9512
  changeType: "removed",
9513
- dataContext: `relation:${h.name}`,
9513
+ dataContext: `relation:${p.name}`,
9514
9514
  reason: "relation no longer exists in the new model"
9515
9515
  });
9516
- for (const h of t.relations) {
9517
- const y = u.get(h.id);
9518
- y ? (y.name !== h.name || y.source !== h.source || y.target !== h.target || y.sourceProperty !== h.sourceProperty || y.targetProperty !== h.targetProperty || y.type !== h.type) && r.push({
9516
+ for (const p of t.relations) {
9517
+ const y = u.get(p.id);
9518
+ y ? (y.name !== p.name || y.source !== p.source || y.target !== p.target || y.sourceProperty !== p.sourceProperty || y.targetProperty !== p.targetProperty || y.type !== p.type) && r.push({
9519
9519
  kind: "relation",
9520
- id: h.id,
9520
+ id: p.id,
9521
9521
  changeType: "changed",
9522
- dataContext: `relation:${h.name}`,
9522
+ dataContext: `relation:${p.name}`,
9523
9523
  reason: "relation endpoints, properties, or type changed"
9524
9524
  }) : r.push({
9525
9525
  kind: "relation",
9526
- id: h.id,
9526
+ id: p.id,
9527
9527
  changeType: "added",
9528
- dataContext: `relation:${h.name}`,
9528
+ dataContext: `relation:${p.name}`,
9529
9529
  reason: "relation was added"
9530
9530
  });
9531
9531
  }
9532
- for (const h of c.dictionaries || [])
9533
- f.has(h.id) || r.push({
9532
+ for (const p of c.dictionaries || [])
9533
+ f.has(p.id) || r.push({
9534
9534
  kind: "dictionary",
9535
- id: h.id,
9535
+ id: p.id,
9536
9536
  changeType: "removed",
9537
- dataContext: `global:${h.name}`,
9537
+ dataContext: `global:${p.name}`,
9538
9538
  reason: "dictionary no longer exists in the new model"
9539
9539
  });
9540
- for (const h of t.dictionaries || []) {
9541
- const y = p.get(h.id);
9540
+ for (const p of t.dictionaries || []) {
9541
+ const y = h.get(p.id);
9542
9542
  let b = "unchanged", v = "dictionary is unchanged";
9543
- y ? (y.type !== h.type || y.collection !== h.collection || y.computed !== h.computed) && (b = "changed", v = "dictionary type, collection, or computed flag changed") : (b = "added", v = "dictionary was added"), b !== "unchanged" && r.push({
9543
+ y ? (y.type !== p.type || y.collection !== p.collection || y.computed !== p.computed) && (b = "changed", v = "dictionary type, collection, or computed flag changed") : (b = "added", v = "dictionary was added"), b !== "unchanged" && r.push({
9544
9544
  kind: "dictionary",
9545
- id: h.id,
9545
+ id: p.id,
9546
9546
  changeType: b,
9547
- dataContext: `global:${h.name}`,
9547
+ dataContext: `global:${p.name}`,
9548
9548
  reason: v
9549
9549
  });
9550
9550
  }
9551
- for (const h of c.computations)
9552
- n.has(h.id) || r.push({
9551
+ for (const p of c.computations)
9552
+ n.has(p.id) || r.push({
9553
9553
  kind: "computation",
9554
- id: h.id,
9555
- dataContext: h.dataContext,
9556
- computationType: h.type,
9554
+ id: p.id,
9555
+ dataContext: p.dataContext,
9556
+ computationType: p.type,
9557
9557
  changeType: "removed",
9558
9558
  detected: {},
9559
9559
  recommendation: "ignore",
9560
9560
  reason: "computation no longer exists in the new model"
9561
9561
  });
9562
- for (const h of t.computations) {
9563
- const y = s.get(h.id), b = {
9564
- dataDepsChanged: y ? !Yt(y.deps, h.deps) : !0,
9565
- eventDepsChanged: y ? !Yt(y.eventDeps, h.eventDeps) : !0,
9566
- outputSignatureChanged: y ? y.outputSignature !== h.outputSignature : !0,
9567
- stateSignatureChanged: y ? y.stateSignature !== h.stateSignature : !0,
9568
- functionTextChanged: y ? y.functionSignature?.hash !== h.functionSignature?.hash : h.functionSignature?.hasFunction === !0,
9569
- functionHash: h.functionSignature?.hash,
9562
+ for (const p of t.computations) {
9563
+ const y = s.get(p.id), b = {
9564
+ dataDepsChanged: y ? !Yt(y.deps, p.deps) : !0,
9565
+ eventDepsChanged: y ? !Yt(y.eventDeps, p.eventDeps) : !0,
9566
+ outputSignatureChanged: y ? y.outputSignature !== p.outputSignature : !0,
9567
+ stateSignatureChanged: y ? y.stateSignature !== p.stateSignature : !0,
9568
+ functionTextChanged: y ? y.functionSignature?.hash !== p.functionSignature?.hash : p.functionSignature?.hasFunction === !0,
9569
+ functionHash: p.functionSignature?.hash,
9570
9570
  previousFunctionHash: y?.functionSignature?.hash,
9571
- hasFunction: h.functionSignature?.hasFunction === !0,
9572
- hasClosureRisk: h.functionSignature?.hasFunction === !0,
9573
- needsEventRebuildHandler: h.eventDeps.length > 0,
9574
- needsAsyncCompletionHandler: h.asyncReturn
9571
+ hasFunction: p.functionSignature?.hasFunction === !0,
9572
+ hasClosureRisk: p.functionSignature?.hasFunction === !0,
9573
+ needsEventRebuildHandler: p.eventDeps.length > 0,
9574
+ needsAsyncCompletionHandler: p.asyncReturn
9575
9575
  };
9576
9576
  let v = "unchanged", N = "ignore", I = "unchanged", S = "computation is structurally unchanged";
9577
- y ? y.structuralSignature !== h.structuralSignature ? (v = "changed", N = "needs-review", I = "changed", S = "computation structure changed") : y.stateSignature !== h.stateSignature && y.outputSignature === h.outputSignature ? (v = "state-only", N = "needs-review", I = "state-only", S = "computation state changed without output structure changes") : y.functionSignature?.hash !== h.functionSignature?.hash ? (v = "possibly-changed", N = "needs-review", I = "changed", S = "function text changed and requires human semantic review") : h.functionSignature?.hasFunction && (N = "needs-review", S = "function callback has closure risk and requires human review") : (v = "added", N = "rebuild", I = "changed", S = "new computation requires approved rebuild"), r.push({
9577
+ y ? y.structuralSignature !== p.structuralSignature ? (v = "changed", N = "needs-review", I = "changed", S = "computation structure changed") : y.stateSignature !== p.stateSignature && y.outputSignature === p.outputSignature ? (v = "state-only", N = "needs-review", I = "state-only", S = "computation state changed without output structure changes") : y.functionSignature?.hash !== p.functionSignature?.hash ? (v = "possibly-changed", N = "needs-review", I = "changed", S = "function text changed and requires human semantic review") : p.functionSignature?.hasFunction && (N = "needs-review", S = "function callback has closure risk and requires human review") : (v = "added", N = "rebuild", I = "changed", S = "new computation requires approved rebuild"), r.push({
9578
9578
  kind: "computation",
9579
- id: h.id,
9580
- dataContext: h.dataContext,
9581
- computationType: h.type,
9579
+ id: p.id,
9580
+ dataContext: p.dataContext,
9581
+ computationType: p.type,
9582
9582
  changeType: v,
9583
9583
  detected: b,
9584
9584
  recommendation: N,
9585
9585
  reason: S
9586
9586
  }), N !== "ignore" && a.push({
9587
9587
  kind: "computation",
9588
- id: h.id,
9589
- dataContext: h.dataContext,
9588
+ id: p.id,
9589
+ dataContext: p.dataContext,
9590
9590
  recommendedDecision: I,
9591
9591
  reason: S
9592
9592
  }), b.needsEventRebuildHandler && a.push({
9593
9593
  kind: "event-rebuild-handler",
9594
- dataContext: h.dataContext,
9594
+ dataContext: p.dataContext,
9595
9595
  reason: "event-based computation needs an external migration rebuild handler"
9596
9596
  }), b.needsAsyncCompletionHandler && a.push({
9597
9597
  kind: "async-completion-handler",
9598
- dataContext: h.dataContext,
9598
+ dataContext: p.dataContext,
9599
9599
  reason: "async computation needs an external migration completion handler"
9600
9600
  });
9601
9601
  }
9602
- for (const h of e.preRecomputeDDL)
9602
+ for (const p of e.preRecomputeDDL)
9603
9603
  r.push({
9604
9604
  kind: "storage",
9605
- id: h.logicalPath || h.description,
9605
+ id: p.logicalPath || p.description,
9606
9606
  changeType: "added",
9607
- dataContext: h.logicalPath || h.tableName || h.description,
9608
- reason: h.description
9607
+ dataContext: p.logicalPath || p.tableName || p.description,
9608
+ reason: p.description
9609
9609
  });
9610
- for (const h of i.blockingChanges)
9610
+ for (const p of i.blockingChanges)
9611
9611
  r.push({
9612
9612
  kind: "storage",
9613
- id: h.logicalPath,
9613
+ id: p.logicalPath,
9614
9614
  changeType: "blocked",
9615
- dataContext: h.logicalPath,
9616
- reason: h.reason
9615
+ dataContext: p.logicalPath,
9616
+ reason: p.reason
9617
9617
  });
9618
- for (const h of i.destructiveScopes)
9618
+ for (const p of i.destructiveScopes)
9619
9619
  a.push({
9620
9620
  kind: "destructive-scope",
9621
- dataContext: h.dataContext,
9622
- recordName: h.recordName,
9623
- ids: h.ids || [],
9624
- reason: h.reason
9621
+ dataContext: p.dataContext,
9622
+ recordName: p.recordName,
9623
+ ids: p.ids || [],
9624
+ reason: p.reason
9625
9625
  });
9626
- const m = Array.from(new Map(a.map((h) => [Wt(h), h])).values());
9626
+ const m = Array.from(new Map(a.map((p) => [Rt(p), p])).values());
9627
9627
  return {
9628
9628
  kind: "interaqt-migration-diff",
9629
9629
  version: 2,
@@ -9652,35 +9652,38 @@ function Sa(c, t, e, i, r) {
9652
9652
  throw new M("Migration approvedDiff must have status 'approved'");
9653
9653
  if (c.fromModelHash !== t.modelHash || c.toModelHash !== e.modelHash)
9654
9654
  throw new M("Migration approvedDiff is stale: model hash does not match current database and code");
9655
- const a = r || c, s = new Set(a.requiredDecisions.map(Wt)), n = new Set(a.changes.map(Ea)), o = /* @__PURE__ */ new Set();
9656
- for (const u of c.decisions) {
9657
- const d = va(u);
9658
- if (o.has(d))
9659
- throw new M(`Duplicate migration decision: ${d}`);
9660
- if (o.add(d), u.kind === "computation" && !n.has(`computation:${u.id}`))
9661
- throw new M(`Migration decision references a computation that is not present in the approved diff: ${u.id}`);
9662
- if (u.kind === "event-rebuild-handler") {
9663
- if (!s.has(d))
9664
- throw new M(`Migration event rebuild decision does not match a required review item: ${u.dataContext}`);
9665
- if (!i?.eventRebuild?.[u.handlerRef])
9666
- throw new M(`Missing migration event rebuild handler '${u.handlerRef}' for ${u.dataContext}`);
9667
- }
9668
- if (u.kind === "async-completion-handler") {
9669
- if (!s.has(d))
9670
- throw new M(`Migration async completion decision does not match a required review item: ${u.dataContext}`);
9671
- if (!i?.asyncCompletion?.[u.handlerRef])
9672
- throw new M(`Missing migration async completion handler '${u.handlerRef}' for ${u.dataContext}`);
9673
- }
9674
- if (u.kind === "rename-candidate-reviewed")
9675
- throw new M(`Migration rename candidate decision does not match any Phase 1.5 executable review item: ${u.from} -> ${u.to}`);
9676
- }
9677
- for (const u of a.requiredDecisions)
9678
- if (!o.has(Wt(u)))
9679
- throw new M(`Missing migration decision for required review item: ${Wt(u)}`);
9680
- const l = new Set(e.computations.map((u) => u.id));
9681
- for (const u of c.decisions)
9682
- if (u.kind === "computation" && !l.has(u.id))
9683
- throw new M(`Migration decision references unknown computation: ${u.id}`);
9655
+ const a = r || c, s = new Set(c.requiredDecisions.map(Rt)), n = /* @__PURE__ */ new Set([
9656
+ ...a.requiredDecisions.map(Rt),
9657
+ ...s
9658
+ ]), o = new Set(a.changes.map(Ea)), l = /* @__PURE__ */ new Set();
9659
+ for (const d of c.decisions) {
9660
+ const h = va(d);
9661
+ if (l.has(h))
9662
+ throw new M(`Duplicate migration decision: ${h}`);
9663
+ if (l.add(h), d.kind === "computation" && !o.has(`computation:${d.id}`))
9664
+ throw new M(`Migration decision references a computation that is not present in the approved diff: ${d.id}`);
9665
+ if (d.kind === "event-rebuild-handler") {
9666
+ if (!n.has(h))
9667
+ throw new M(`Migration event rebuild decision does not match a required review item: ${d.dataContext}`);
9668
+ if (!i?.eventRebuild?.[d.handlerRef])
9669
+ throw new M(`Missing migration event rebuild handler '${d.handlerRef}' for ${d.dataContext}`);
9670
+ }
9671
+ if (d.kind === "async-completion-handler") {
9672
+ if (!n.has(h))
9673
+ throw new M(`Migration async completion decision does not match a required review item: ${d.dataContext}`);
9674
+ if (!i?.asyncCompletion?.[d.handlerRef])
9675
+ throw new M(`Missing migration async completion handler '${d.handlerRef}' for ${d.dataContext}`);
9676
+ }
9677
+ if (d.kind === "rename-candidate-reviewed")
9678
+ throw new M(`Migration rename candidate decision does not match any Phase 1.5 executable review item: ${d.from} -> ${d.to}`);
9679
+ }
9680
+ for (const d of a.requiredDecisions)
9681
+ if (!l.has(Rt(d)))
9682
+ throw new M(`Missing migration decision for required review item: ${Rt(d)}`);
9683
+ const u = new Set(e.computations.map((d) => d.id));
9684
+ for (const d of c.decisions)
9685
+ if (d.kind === "computation" && !u.has(d.id))
9686
+ throw new M(`Migration decision references unknown computation: ${d.id}`);
9684
9687
  }
9685
9688
  function ka(c, t, e) {
9686
9689
  const i = [], r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), s = new Map(t.computations.map((o) => [o.id, o]));
@@ -9735,34 +9738,34 @@ function pi(c, t) {
9735
9738
  return e;
9736
9739
  }
9737
9740
  function fi(c, t, e, i = [], r = {}) {
9738
- const a = new Map(t.computations.map((h) => [pe(h), h])), s = new Map(c.computations.map((h) => [h.id, h])), n = /* @__PURE__ */ new Map();
9739
- for (const h of t.computations) {
9740
- for (const y of h.deps)
9741
- for (const b of hi(y, h, t))
9742
- n.has(b) || n.set(b, /* @__PURE__ */ new Set()), n.get(b).add(h.id);
9743
- for (const y of h.eventDeps)
9741
+ const a = new Map(t.computations.map((p) => [pe(p), p])), s = new Map(c.computations.map((p) => [p.id, p])), n = /* @__PURE__ */ new Map();
9742
+ for (const p of t.computations) {
9743
+ for (const y of p.deps)
9744
+ for (const b of hi(y, p, t))
9745
+ n.has(b) || n.set(b, /* @__PURE__ */ new Set()), n.get(b).add(p.id);
9746
+ for (const y of p.eventDeps)
9744
9747
  for (const b of pi(y, t))
9745
- b !== h.dataContext && (n.has(b) || n.set(b, /* @__PURE__ */ new Set()), n.get(b).add(h.id));
9748
+ b !== p.dataContext && (n.has(b) || n.set(b, /* @__PURE__ */ new Set()), n.get(b).add(p.id));
9746
9749
  }
9747
- const o = new Set(e.map((h) => h.id)), u = [...e.filter((h) => {
9748
- const y = s.get(h.id);
9749
- return r.outputChangedIds?.has(h.id) || !y || y.outputSignature !== h.outputSignature;
9750
- }).map((h) => pe(h)), ...i];
9750
+ const o = new Set(e.map((p) => p.id)), u = [...e.filter((p) => {
9751
+ const y = s.get(p.id);
9752
+ return r.outputChangedIds?.has(p.id) || !y || y.outputSignature !== p.outputSignature;
9753
+ }).map((p) => pe(p)), ...i];
9751
9754
  for (; u.length; ) {
9752
- const h = u.shift();
9753
- for (const y of n.get(h) || []) {
9755
+ const p = u.shift();
9756
+ for (const y of n.get(p) || []) {
9754
9757
  if (o.has(y)) continue;
9755
9758
  o.add(y);
9756
9759
  const b = t.computations.find((v) => v.id === y);
9757
9760
  b && u.push(pe(b));
9758
9761
  }
9759
9762
  }
9760
- const d = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), f = [], m = (h) => {
9761
- if (p.has(h)) return;
9762
- if (d.has(h))
9763
- throw new Et(`Migration detected a derived computation cycle at ${h}`);
9764
- d.add(h);
9765
- const y = t.computations.find((b) => b.id === h);
9763
+ const d = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), f = [], m = (p) => {
9764
+ if (h.has(p)) return;
9765
+ if (d.has(p))
9766
+ throw new Tt(`Migration detected a derived computation cycle at ${p}`);
9767
+ d.add(p);
9768
+ const y = t.computations.find((b) => b.id === p);
9766
9769
  if (y) {
9767
9770
  for (const b of y.deps)
9768
9771
  for (const v of hi(b, y, t)) {
@@ -9776,12 +9779,12 @@ function fi(c, t, e, i = [], r = {}) {
9776
9779
  N && o.has(N.id) && m(N.id);
9777
9780
  }
9778
9781
  }
9779
- d.delete(h), p.add(h), f.push(h);
9782
+ d.delete(p), h.add(p), f.push(p);
9780
9783
  };
9781
- return o.forEach(m), f.map((h) => {
9782
- const y = t.computations.find((W) => W.id === h), b = s.get(h), v = r.stateOnlyIds?.has(h) === !0, N = r.outputChangedIds?.has(h) || !b || b.outputSignature !== y.outputSignature, I = !b || b.stateSignature !== y.stateSignature, S = e.some((W) => W.id === h);
9784
+ return o.forEach(m), f.map((p) => {
9785
+ const y = t.computations.find((W) => W.id === p), b = s.get(p), v = r.stateOnlyIds?.has(p) === !0, N = r.outputChangedIds?.has(p) || !b || b.outputSignature !== y.outputSignature, I = !b || b.stateSignature !== y.stateSignature, S = e.some((W) => W.id === p);
9783
9786
  return {
9784
- computationId: h,
9787
+ computationId: p,
9785
9788
  dataContext: y.dataContext,
9786
9789
  rebuildState: (v || I) && y.boundStates.length > 0,
9787
9790
  rebuildOutput: v ? !1 : N || !S,
@@ -9815,11 +9818,11 @@ function mi(c, t) {
9815
9818
  newPhysicalPath: l.tableName,
9816
9819
  reason: "fact record table changed"
9817
9820
  });
9818
- const d = new Map((u.attributeDetails || []).map((m) => [m.name, m])), p = new Map((l.attributeDetails || []).map((m) => [m.name, m]));
9821
+ const d = new Map((u.attributeDetails || []).map((m) => [m.name, m])), h = new Map((l.attributeDetails || []).map((m) => [m.name, m]));
9819
9822
  a.get(u.recordName), s.get(l.recordName);
9820
- const f = (m, h, y) => y.records.find((v) => v.name === m)?.properties.find((v) => v.name === h)?.computed === !0;
9823
+ const f = (m, p, y) => y.records.find((v) => v.name === m)?.properties.find((v) => v.name === p)?.computed === !0;
9821
9824
  for (const m of u.attributeDetails || [])
9822
- if (!p.get(m.name) && !m.name.startsWith("_")) {
9825
+ if (!h.get(m.name) && !m.name.startsWith("_")) {
9823
9826
  const y = f(u.recordName, m.name, c);
9824
9827
  e.push({
9825
9828
  kind: "unsupported-destructive-schema-change",
@@ -9829,17 +9832,17 @@ function mi(c, t) {
9829
9832
  });
9830
9833
  }
9831
9834
  for (const m of l.attributeDetails || []) {
9832
- const h = d.get(m.name);
9833
- !h || f(u.recordName, m.name, c) || f(l.recordName, m.name, t) || ((h.kind !== m.kind || h.tableName !== m.tableName || h.fieldName !== m.fieldName || h.sourceField !== m.sourceField || h.targetField !== m.targetField) && e.push({
9835
+ const p = d.get(m.name);
9836
+ !p || f(u.recordName, m.name, c) || f(l.recordName, m.name, t) || ((p.kind !== m.kind || p.tableName !== m.tableName || p.fieldName !== m.fieldName || p.sourceField !== m.sourceField || p.targetField !== m.targetField) && e.push({
9834
9837
  kind: "physical-path-move",
9835
9838
  logicalPath: `${l.recordName}.${m.name}`,
9836
- oldPhysicalPath: fe(h.tableName, h.fieldName || h.sourceField || h.targetField),
9839
+ oldPhysicalPath: fe(p.tableName, p.fieldName || p.sourceField || p.targetField),
9837
9840
  newPhysicalPath: fe(m.tableName, m.fieldName || m.sourceField || m.targetField),
9838
9841
  reason: "fact attribute physical path changed"
9839
- }), (h.type !== m.type || h.fieldType !== m.fieldType || h.collection !== m.collection) && e.push({
9842
+ }), (p.type !== m.type || p.fieldType !== m.fieldType || p.collection !== m.collection) && e.push({
9840
9843
  kind: "unsupported-destructive-schema-change",
9841
9844
  logicalPath: `${l.recordName}.${m.name}`,
9842
- oldPhysicalPath: `${h.type || "?"}/${h.fieldType || "?"}/${h.collection === !0}`,
9845
+ oldPhysicalPath: `${p.type || "?"}/${p.fieldType || "?"}/${p.collection === !0}`,
9843
9846
  newPhysicalPath: `${m.type || "?"}/${m.fieldType || "?"}/${m.collection === !0}`,
9844
9847
  reason: "fact attribute type, field type, or collection flag changed"
9845
9848
  }));
@@ -9882,8 +9885,8 @@ async function Te(c, t, e) {
9882
9885
  if (!o || !l || u.length === 0) return;
9883
9886
  const d = c.system.storage.db || c.system.db;
9884
9887
  if (typeof d?.query != "function") return;
9885
- const p = (m) => `"${m.replace(/"/g, '""')}"`, f = u.map((m) => `${p(m.fieldName)} AS ${p(m.name)}`).join(", ");
9886
- return d.query(`SELECT ${f} FROM ${p(l)}`, []);
9888
+ const h = (m) => `"${m.replace(/"/g, '""')}"`, f = u.map((m) => `${h(m.fieldName)} AS ${h(m.name)}`).join(", ");
9889
+ return d.query(`SELECT ${f} FROM ${h(l)}`, []);
9887
9890
  };
9888
9891
  for (const s of t) {
9889
9892
  const n = i.get(s.computationId);
@@ -9909,7 +9912,7 @@ async function Te(c, t, e) {
9909
9912
  if (!l || !u) continue;
9910
9913
  const d = await n.compute(await c.scheduler.resolveDataDeps(n));
9911
9914
  if (!Array.isArray(d)) continue;
9912
- const p = new Set(d.map((h) => `${h[l]}:${h[u]}`)), m = (await a(o) || []).filter((h) => !p.has(`${h[l]}:${h[u]}`)).map((h) => String(h.id));
9915
+ const h = new Set(d.map((p) => `${p[l]}:${p[u]}`)), m = (await a(o) || []).filter((p) => !h.has(`${p[l]}:${p[u]}`)).map((p) => String(p.id));
9913
9916
  m.length && r.push({
9914
9917
  dataContext: P(n.dataContext),
9915
9918
  recordName: o,
@@ -9925,11 +9928,11 @@ function Fi(c, t) {
9925
9928
  const e = (c.approvedDiff?.decisions || []).filter((s) => s.kind === "destructive-scope"), i = (s) => `${s.dataContext}:${s.recordName || ""}`, r = new Map(e.map((s) => [i(s), [...s.ids || []].sort().join(",")])), a = new Set(t.map(i));
9926
9929
  for (const s of e)
9927
9930
  if (!a.has(i(s)))
9928
- throw new Tt(`Destructive migration scope mismatch for ${s.dataContext}`);
9931
+ throw new St(`Destructive migration scope mismatch for ${s.dataContext}`);
9929
9932
  for (const s of t) {
9930
9933
  const n = [...s.ids || []].sort().join(",");
9931
9934
  if (r.get(i(s)) !== n)
9932
- throw new Tt(`Destructive migration scope mismatch for ${s.dataContext}`);
9935
+ throw new St(`Destructive migration scope mismatch for ${s.dataContext}`);
9933
9936
  }
9934
9937
  }
9935
9938
  function yi(c, t) {
@@ -9971,7 +9974,7 @@ async function Be(c, t, e, i, r = {}) {
9971
9974
  }
9972
9975
  async function et(c, t, e, i, r = {}) {
9973
9976
  if (e instanceof ht) return;
9974
- if (e instanceof _t && (e = await Be(c, t, e, i, r)), e instanceof ee)
9977
+ if (e instanceof Vt && (e = await Be(c, t, e, i, r)), e instanceof ee)
9975
9978
  throw new Ve(`Migration requires direct final output, not asyncReturn resolution, for ${P(t.dataContext)}`);
9976
9979
  const a = await c.retrieveLastValue(t.dataContext, i);
9977
9980
  if (!Yt(a, e))
@@ -9979,7 +9982,7 @@ async function et(c, t, e, i, r = {}) {
9979
9982
  }
9980
9983
  async function xa(c, t, e, i, r = {}) {
9981
9984
  if (e instanceof ht || e === void 0) return [];
9982
- if (e instanceof _t && (e = await Be(c, t, e, i, r)), e instanceof ee)
9985
+ if (e instanceof Vt && (e = await Be(c, t, e, i, r)), e instanceof ee)
9983
9986
  throw new Ve(`Migration requires direct final output for ${P(t.dataContext)}`);
9984
9987
  const a = Array.isArray(e) ? e : [e], s = [];
9985
9988
  for (const n of a) {
@@ -9990,7 +9993,7 @@ async function xa(c, t, e, i, r = {}) {
9990
9993
  }
9991
9994
  const o = n;
9992
9995
  if (o.type === "delete" && (t.dataContext.type === "entity" || t.dataContext.type === "relation"))
9993
- throw new Tt(`Migration refuses delete patch for ${P(t.dataContext)} without explicit audited scope`);
9996
+ throw new St(`Migration refuses delete patch for ${P(t.dataContext)} without explicit audited scope`);
9994
9997
  if (await c.applyResultPatch(t.dataContext, o, i), t.dataContext.type === "entity" || t.dataContext.type === "relation")
9995
9998
  s.push({
9996
9999
  recordName: t.dataContext.id.name,
@@ -10009,7 +10012,7 @@ async function xa(c, t, e, i, r = {}) {
10009
10012
  function Li(c, t, e, i) {
10010
10013
  if (c.type === "global")
10011
10014
  return {
10012
- recordName: J,
10015
+ recordName: K,
10013
10016
  type: e === void 0 ? "create" : "update",
10014
10017
  record: { key: c.id.name, value: t, id: c.id.name },
10015
10018
  oldRecord: e === void 0 ? void 0 : { key: c.id.name, value: e, id: c.id.name },
@@ -10027,16 +10030,16 @@ function Li(c, t, e, i) {
10027
10030
  async function Ma(c, t, e = {}) {
10028
10031
  if (t.dataContext.type !== "entity" && t.dataContext.type !== "relation") return [];
10029
10032
  let i = await t.compute(await c.scheduler.resolveDataDeps(t));
10030
- if (i instanceof _t && (i = await Be(c, t, i, void 0, e)), !Array.isArray(i))
10031
- throw new Et(`Entity/relation migration compute must return an array for ${P(t.dataContext)}`);
10033
+ if (i instanceof Vt && (i = await Be(c, t, i, void 0, e)), !Array.isArray(i))
10034
+ throw new Tt(`Entity/relation migration compute must return an array for ${P(t.dataContext)}`);
10032
10035
  const r = t.dataContext.id.name, a = t.state?.sourceRecordId?.key, s = t.state?.transformIndex?.key;
10033
10036
  if (!a || !s)
10034
- throw new Et(`Transform migration requires sourceRecordId and transformIndex state for ${P(t.dataContext)}`);
10037
+ throw new Tt(`Transform migration requires sourceRecordId and transformIndex state for ${P(t.dataContext)}`);
10035
10038
  const n = await c.system.storage.find(r, void 0, void 0, ["*"]), o = new Map(n.map((u) => [`${u[a]}:${u[s]}`, u])), l = [];
10036
10039
  for (const u of i) {
10037
- const d = `${u[a]}:${u[s]}`, p = o.get(d);
10038
- if (o.delete(d), p)
10039
- Yt({ ...p, id: void 0 }, { ...u, id: void 0 }) || (await c.system.storage.update(r, w.atom({ key: "id", value: ["=", p.id] }), u), l.push({ recordName: r, type: "update", record: { ...p, ...u }, oldRecord: p, keys: Object.keys(u) }));
10040
+ const d = `${u[a]}:${u[s]}`, h = o.get(d);
10041
+ if (o.delete(d), h)
10042
+ Yt({ ...h, id: void 0 }, { ...u, id: void 0 }) || (await c.system.storage.update(r, w.atom({ key: "id", value: ["=", h.id] }), u), l.push({ recordName: r, type: "update", record: { ...h, ...u }, oldRecord: h, keys: Object.keys(u) }));
10040
10043
  else {
10041
10044
  const f = await c.system.storage.create(r, u);
10042
10045
  l.push({ recordName: r, type: "create", record: f });
@@ -10045,9 +10048,9 @@ async function Ma(c, t, e = {}) {
10045
10048
  for (const u of o.values()) {
10046
10049
  if (!Qe(
10047
10050
  e.approvedDiff,
10048
- (p) => p.kind === "destructive-scope" && p.dataContext === P(t.dataContext) && p.recordName === r
10051
+ (h) => h.kind === "destructive-scope" && h.dataContext === P(t.dataContext) && h.recordName === r
10049
10052
  )?.ids.map(String).includes(String(u.id)))
10050
- throw new Tt(`Migration would delete stale derived ${r} record ${u.id}; approve destructive scope before executing`);
10053
+ throw new St(`Migration would delete stale derived ${r} record ${u.id}; approve destructive scope before executing`);
10051
10054
  await c.system.storage.delete(r, w.atom({ key: "id", value: ["=", u.id] })), l.push({ recordName: r, type: "delete", record: u });
10052
10055
  }
10053
10056
  return l;
@@ -10068,9 +10071,9 @@ class Da {
10068
10071
  const i = this.handles.get(e.computationId);
10069
10072
  if (!i) continue;
10070
10073
  if (i.dataContext.type === "property" && i.dataContext.id.name === _e && !xi(this.options.approvedDiff, (s) => s.kind === "destructive-scope" && s.dataContext === P(i.dataContext)))
10071
- throw new Tt(`Migration refuses to recompute destructive property ${P(i.dataContext)} without approved destructive scope`);
10074
+ throw new St(`Migration refuses to recompute destructive property ${P(i.dataContext)} without approved destructive scope`);
10072
10075
  if (typeof i.compute != "function" && !Gt(this.options, P(i.dataContext)))
10073
- throw new Et(`Migration requires full compute support for ${P(i.dataContext)}`);
10076
+ throw new Tt(`Migration requires full compute support for ${P(i.dataContext)}`);
10074
10077
  if (e.rebuildState && !e.rebuildOutput) {
10075
10078
  await this.rebuildStateDefaults(i);
10076
10079
  continue;
@@ -10095,7 +10098,7 @@ class Da {
10095
10098
  if (t.dataContext.type === "property") {
10096
10099
  const o = t.dataContext.host.name, l = await this.controller.system.storage.find(o, void 0, void 0, ["*"]), u = [];
10097
10100
  for (const d of l) {
10098
- const p = await e({ controller: this.controller, dataContext: t.dataContext, record: d }), f = await et(this.controller, t, p, d, this.options);
10101
+ const h = await e({ controller: this.controller, dataContext: t.dataContext, record: d }), f = await et(this.controller, t, h, d, this.options);
10099
10102
  f && u.push(f);
10100
10103
  }
10101
10104
  return u;
@@ -10140,7 +10143,7 @@ class Da {
10140
10143
  if (!("dataDep" in s)) {
10141
10144
  const o = Gt(this.options, P(t.dataContext));
10142
10145
  if (!o)
10143
- throw new Et(`Event-based migration requires an approved event rebuild handler for ${P(t.dataContext)}`);
10146
+ throw new Tt(`Event-based migration requires an approved event rebuild handler for ${P(t.dataContext)}`);
10144
10147
  const l = await o({ controller: this.controller, dataContext: t.dataContext, mutationEvent: r }), u = await et(this.controller, t, l, void 0, this.options);
10145
10148
  u && i.push(u);
10146
10149
  continue;
@@ -10179,18 +10182,18 @@ async function Oa(c, t, e) {
10179
10182
  if (!n || !s.resolvedMatchExpression) continue;
10180
10183
  const o = await c.system.storage.find(n, void 0, void 0, ["id", "__filtered_entities"]), l = await c.system.storage.find(n, s.resolvedMatchExpression, void 0, ["id"]), u = new Set(l.map((d) => String(d.id)));
10181
10184
  for (const d of o) {
10182
- const p = {
10185
+ const h = {
10183
10186
  ...d.__filtered_entities && typeof d.__filtered_entities == "object" ? d.__filtered_entities : {},
10184
10187
  [s.recordName]: u.has(String(d.id))
10185
10188
  };
10186
10189
  await c.system.storage.update(
10187
10190
  n,
10188
10191
  w.atom({ key: "id", value: ["=", d.id] }),
10189
- { __filtered_entities: p }
10192
+ { __filtered_entities: h }
10190
10193
  ), a.push({
10191
10194
  recordName: s.recordName,
10192
10195
  type: u.has(String(d.id)) ? "create" : "delete",
10193
- record: { ...d, __filtered_entities: p },
10196
+ record: { ...d, __filtered_entities: h },
10194
10197
  oldRecord: d,
10195
10198
  keys: ["__filtered_entities"]
10196
10199
  });
@@ -10238,9 +10241,9 @@ class xs {
10238
10241
  const d = new Set(this.entities.map((f) => f.name));
10239
10242
  for (const f of this.eventSources)
10240
10243
  f.entity && f.entity.name && !d.has(f.entity.name) && (this.entities.push(f.entity), d.add(f.entity.name));
10241
- const p = [
10244
+ const h = [
10242
10245
  ...Qr,
10243
- ...Jr,
10246
+ ...Kr,
10244
10247
  ...qr,
10245
10248
  ...Or,
10246
10249
  ...Mr,
@@ -10251,7 +10254,7 @@ class xs {
10251
10254
  ...ca,
10252
10255
  ...o
10253
10256
  ];
10254
- this.scheduler = new ha(this, this.entities, this.relations, this.dict, p), n.forEach((f) => {
10257
+ this.scheduler = new ha(this, this.entities, this.relations, this.dict, h), n.forEach((f) => {
10255
10258
  let m = this.recordNameToSideEffects.get(f.record.name);
10256
10259
  m || this.recordNameToSideEffects.set(f.record.name, m = /* @__PURE__ */ new Set()), m.add(f);
10257
10260
  });
@@ -10269,7 +10272,7 @@ class xs {
10269
10272
  const s = this.system, n = s.prepareMigrationSchema;
10270
10273
  if (typeof n != "function")
10271
10274
  throw new Error("Current system does not support migration manifest validation");
10272
- const o = await n.call(s, this.entities, this.relations, r), l = Ht(this, o.schema), u = await gi(this);
10275
+ const o = await n.call(s, this.entities, this.relations, r), l = jt(this, o.schema), u = await gi(this);
10273
10276
  if (u && u.modelHash !== l.modelHash)
10274
10277
  throw new Error(`Model manifest mismatch. Call controller.generateMigrationDiff(), review it, then call controller.migrate({ approvedDiff }). Manifest key: ${Le}/${qe}`);
10275
10278
  if (!u && await this.system.hasExistingData?.())
@@ -10278,7 +10281,7 @@ class xs {
10278
10281
  return;
10279
10282
  }
10280
10283
  await this.system.setup(this.entities, this.relations, r, e);
10281
- const a = Ht(this);
10284
+ const a = jt(this);
10282
10285
  await this.scheduler.setup(e), e && await me(this, a);
10283
10286
  }
10284
10287
  async createMigrationBaseline() {
@@ -10290,7 +10293,7 @@ class xs {
10290
10293
  missingDDL: i.preRecomputeDDL,
10291
10294
  blockingChanges: i.blockingChanges
10292
10295
  });
10293
- const r = Ht(this, i.schema);
10296
+ const r = jt(this, i.schema);
10294
10297
  return await me(this, r), r;
10295
10298
  }
10296
10299
  async prepareMigrationContext(t = {}) {
@@ -10299,18 +10302,18 @@ class xs {
10299
10302
  const r = await i.prepareMigrationSchema(this.entities, this.relations, e), a = await gi(this);
10300
10303
  if (!a)
10301
10304
  throw new he("Migration baseline manifest not found. Run setup(true) with the current framework first or createMigrationBaseline().");
10302
- const s = Ht(this, r.schema, { includeFunctionText: t.includeFunctionText === !0 });
10305
+ const s = jt(this, r.schema, { includeFunctionText: t.includeFunctionText === !0 });
10303
10306
  return { states: e, migrationSystem: i, schemaPlan: r, previousManifest: a, nextManifest: s };
10304
10307
  }
10305
10308
  async buildCurrentMigrationDiff(t, e, i, r = {}) {
10306
10309
  const a = i.computations.filter(
10307
- (p) => !e.computations.some((f) => f.id === p.id && f.signature === p.signature)
10310
+ (h) => !e.computations.some((f) => f.id === h.id && f.signature === h.signature)
10308
10311
  ), s = yi(e, i), n = fi(
10309
10312
  e,
10310
10313
  i,
10311
10314
  a,
10312
10315
  s,
10313
- { outputChangedIds: new Set(a.map((p) => p.id)) }
10316
+ { outputChangedIds: new Set(a.map((h) => h.id)) }
10314
10317
  ), o = mi(e, i), l = r.includeDestructiveScope === !0 ? await Te(this, n, e) : [], u = {
10315
10318
  blockingChanges: [
10316
10319
  ...t.blockingChanges,
@@ -10331,17 +10334,17 @@ class xs {
10331
10334
  C(typeof r.applyMigrationSchema == "function", "Current system does not support schema migration application");
10332
10335
  const { schemaPlan: a, previousManifest: s, nextManifest: n } = i, o = await this.buildCurrentMigrationDiff(a, s, n, { includeDestructiveScope: !1 });
10333
10336
  Sa(e.approvedDiff, s, n, e.handlers, o);
10334
- const l = e.approvedDiff, u = ma(l), d = ka(s, n, l), p = d.changedComputations, f = yi(s, n), m = fi(s, n, p, f, {
10337
+ const l = e.approvedDiff, u = ma(l), d = ka(s, n, l), h = d.changedComputations, f = yi(s, n), m = fi(s, n, h, f, {
10335
10338
  outputChangedIds: d.outputChangedIds,
10336
10339
  stateOnlyIds: d.stateOnlyIds
10337
- }), h = mi(s, n), y = $a(
10340
+ }), p = mi(s, n), y = $a(
10338
10341
  this,
10339
10342
  m,
10340
10343
  e,
10341
10344
  s
10342
10345
  ), b = [
10343
10346
  ...a.blockingChanges,
10344
- ...h,
10347
+ ...p,
10345
10348
  ...d.blocking,
10346
10349
  ...y
10347
10350
  ], v = Ia(b), N = await Te(this, m, s);
@@ -10349,7 +10352,7 @@ class xs {
10349
10352
  const I = {
10350
10353
  mode: "compute",
10351
10354
  dryRun: e.dryRun === !0,
10352
- changedComputations: p,
10355
+ changedComputations: h,
10353
10356
  rebuildPlan: m,
10354
10357
  schemaPlan: {
10355
10358
  schema: a.schema,
@@ -10591,7 +10594,7 @@ class qa {
10591
10594
  }, this.transactionContext = new wi(), this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
10592
10595
  get: async (e) => {
10593
10596
  const i = w.atom({ key: "key", value: ["=", e] });
10594
- return (await this.queryHandle.findOne(J, i, void 0, ["value"]))?.value?.raw;
10597
+ return (await this.queryHandle.findOne(K, i, void 0, ["value"]))?.value?.raw;
10595
10598
  },
10596
10599
  set: async (e, i) => {
10597
10600
  await this.setDictionaryValue(e, i, !0);
@@ -10677,12 +10680,12 @@ class qa {
10677
10680
  return this.isInTransaction() ? e() : De(t, (i) => this.runInTransaction({ name: t, isolation: i }, e));
10678
10681
  }
10679
10682
  async setDictionaryValue(t, e, i) {
10680
- const r = w.atom({ key: "key", value: ["=", t] }), a = await this.queryHandle.findOne(J, r, void 0, ["value"]);
10683
+ const r = w.atom({ key: "key", value: ["=", t] }), a = await this.queryHandle.findOne(K, r, void 0, ["value"]);
10681
10684
  if (a) {
10682
- const s = [J, w.atom({ key: "id", value: ["=", a.id] }), { key: t, value: { raw: e } }];
10685
+ const s = [K, w.atom({ key: "id", value: ["=", a.id] }), { key: t, value: { raw: e } }];
10683
10686
  i ? await this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), s, []) : await this.queryHandle.update(...s, []);
10684
10687
  } else {
10685
- const s = [J, { key: t, value: { raw: e } }];
10688
+ const s = [K, { key: t, value: { raw: e } }];
10686
10689
  i ? await this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), s, []) : await this.queryHandle.create(...s, []);
10687
10690
  }
10688
10691
  }
@@ -11104,8 +11107,8 @@ class qa {
11104
11107
  increment: async (e, i) => {
11105
11108
  const r = this.getPlaceholder();
11106
11109
  if (this.isRecordTarget(e)) {
11107
- const { tableName: l, idField: u, fieldName: d } = this.resolveRecordTarget(e), p = r(), f = r(), m = await this.db.query(
11108
- `UPDATE "${l}" SET "${d}" = COALESCE("${d}", 0) + ${p} WHERE "${u}" = ${f} RETURNING "${d}" AS value`,
11110
+ const { tableName: l, idField: u, fieldName: d } = this.resolveRecordTarget(e), h = r(), f = r(), m = await this.db.query(
11111
+ `UPDATE "${l}" SET "${d}" = COALESCE("${d}", 0) + ${h} WHERE "${u}" = ${f} RETURNING "${d}" AS value`,
11109
11112
  [i, e.id],
11110
11113
  `atomic increment ${e.recordName}.${e.field}`
11111
11114
  );
@@ -11145,12 +11148,12 @@ RETURNING "numberValue" AS value`,
11145
11148
  `SELECT "${a}" AS value FROM "_ComputationState_" WHERE "key" = ${n}${this.supportsForUpdate() ? " FOR UPDATE" : ""}`,
11146
11149
  [e.key],
11147
11150
  `atomic replace lock ${e.key}`
11148
- ), l = t.filter((y) => y !== a).map((y) => `"${y}" = NULL`).join(", "), u = this.parseGlobalValue(o[0]?.value, a) ?? e.defaultValue ?? null, d = this.getPlaceholder(), p = d(), f = d(), m = [`"${a}" = ${p}`, l].filter(Boolean).join(", "), h = await this.db.query(
11151
+ ), l = t.filter((y) => y !== a).map((y) => `"${y}" = NULL`).join(", "), u = this.parseGlobalValue(o[0]?.value, a) ?? e.defaultValue ?? null, d = this.getPlaceholder(), h = d(), f = d(), m = [`"${a}" = ${h}`, l].filter(Boolean).join(", "), p = await this.db.query(
11149
11152
  `UPDATE "_ComputationState_" SET ${m} WHERE "key" = ${f} RETURNING "${a}" AS value`,
11150
11153
  [s, e.key],
11151
11154
  `atomic replace ${e.key}`
11152
11155
  );
11153
- return { oldValue: u, newValue: this.parseGlobalValue(h[0]?.value, a) ?? i };
11156
+ return { oldValue: u, newValue: this.parseGlobalValue(p[0]?.value, a) ?? i };
11154
11157
  }
11155
11158
  ),
11156
11159
  compareAndSet: async (e, i, r, a) => {
@@ -11163,9 +11166,9 @@ RETURNING "numberValue" AS value`,
11163
11166
  `atomic compareAndSet ${e.recordName}.${e.field}`
11164
11167
  )).length > 0;
11165
11168
  }
11166
- const o = this.resolveGlobalColumn(e, r), l = this.normalizeGlobalValue(r, o), u = this.normalizeGlobalValue(n, o), d = this.normalizeGlobalValue(i, o), p = s(), f = s(), m = s(), h = s();
11169
+ const o = this.resolveGlobalColumn(e, r), l = this.normalizeGlobalValue(r, o), u = this.normalizeGlobalValue(n, o), d = this.normalizeGlobalValue(i, o), h = s(), f = s(), m = s(), p = s();
11167
11170
  if ((await this.db.query(
11168
- `UPDATE "_ComputationState_" SET "${o}" = ${p} WHERE "key" = ${f} AND COALESCE("${o}", ${m}) = ${h} RETURNING "${o}" AS value`,
11171
+ `UPDATE "_ComputationState_" SET "${o}" = ${h} WHERE "key" = ${f} AND COALESCE("${o}", ${m}) = ${p} RETURNING "${o}" AS value`,
11169
11172
  [l, e.key, u, d],
11170
11173
  `atomic compareAndSet ${e.key}`
11171
11174
  )).length) return !0;
@@ -11200,9 +11203,9 @@ RETURNING "numberValue" AS value`,
11200
11203
  Object.entries(i).forEach(([f, m]) => {
11201
11204
  l[f] = Number(l[f] ?? r[f] ?? 0) + m;
11202
11205
  });
11203
- const u = this.getPlaceholder(), d = u(), p = u();
11206
+ const u = this.getPlaceholder(), d = u(), h = u();
11204
11207
  return await this.db.update(
11205
- `UPDATE "_ComputationState_" SET "jsonValue" = ${d} WHERE "key" = ${p}`,
11208
+ `UPDATE "_ComputationState_" SET "jsonValue" = ${d} WHERE "key" = ${h}`,
11206
11209
  [JSON.stringify(l), e.key],
11207
11210
  void 0,
11208
11211
  `atomic updateGlobalFields ${e.key}`
@@ -11509,16 +11512,16 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
11509
11512
  if (d instanceof $) {
11510
11513
  if (!d.record)
11511
11514
  return;
11512
- let p = a.getEntityByName(d.record);
11513
- if (p || (p = a.getRelationByName(d.record)), !p)
11515
+ let h = a.getEntityByName(d.record);
11516
+ if (h || (h = a.getRelationByName(d.record)), !h)
11514
11517
  throw new Error(`Entity or Relation not found: ${d.record}`);
11515
- for (; p.baseEntity || p.baseRelation; )
11516
- p = p.baseEntity || p.baseRelation;
11518
+ for (; h.baseEntity || h.baseRelation; )
11519
+ h = h.baseEntity || h.baseRelation;
11517
11520
  if (d.defaultValue instanceof T)
11518
- d.defaultValue.name = d.key, p.properties.push(d.defaultValue);
11521
+ d.defaultValue.name = d.key, h.properties.push(d.defaultValue);
11519
11522
  else {
11520
11523
  const f = typeof d.defaultValue;
11521
- p.properties.push(T.create({
11524
+ h.properties.push(T.create({
11522
11525
  name: d.key,
11523
11526
  type: f,
11524
11527
  // 应该系统定义
@@ -11599,9 +11602,9 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
11599
11602
  const r = i.sourceRecordId, a = i.transformIndex;
11600
11603
  if (!(r instanceof $) || !(a instanceof $) || r.unique === !1 || e.type !== "entity" && e.type !== "relation")
11601
11604
  continue;
11602
- const s = e.id.name, n = this.storage, o = n.queryHandle.map, l = o.getRecordInfo(s), [, u] = o.getTableAliasAndFieldName([s], r.key, !0), [, d] = o.getTableAliasAndFieldName([s], a.key, !0), p = `idx_transform_${this.hashIdentifier(`${l.table}_${u}_${d}`)}`, f = Q(n.db);
11605
+ const s = e.id.name, n = this.storage, o = n.queryHandle.map, l = o.getRecordInfo(s), [, u] = o.getTableAliasAndFieldName([s], r.key, !0), [, d] = o.getTableAliasAndFieldName([s], a.key, !0), h = `idx_transform_${this.hashIdentifier(`${l.table}_${u}_${d}`)}`, f = Q(n.db);
11603
11606
  await n.db.scheme(
11604
- be(p, l.table, [u, d], f),
11607
+ be(h, l.table, [u, d], f),
11605
11608
  `setup transform unique index ${s}`
11606
11609
  );
11607
11610
  }
@@ -11614,10 +11617,10 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
11614
11617
  const o = n.sourceRecordId, l = n.transformIndex;
11615
11618
  if (!(o instanceof $) || !(l instanceof $) || o.unique === !1 || s.type !== "entity" && s.type !== "relation")
11616
11619
  return [];
11617
- const u = s.id.name, d = r.getRecordInfo(u), [, p] = r.getTableAliasAndFieldName([u], o.key, !0), [, f] = r.getTableAliasAndFieldName([u], l.key, !0), m = `idx_transform_${this.hashIdentifier(`${d.table}_${p}_${f}`)}`;
11620
+ const u = s.id.name, d = r.getRecordInfo(u), [, h] = r.getTableAliasAndFieldName([u], o.key, !0), [, f] = r.getTableAliasAndFieldName([u], l.key, !0), m = `idx_transform_${this.hashIdentifier(`${d.table}_${h}_${f}`)}`;
11618
11621
  return [{
11619
11622
  kind: "create-constraint",
11620
- sql: be(m, d.table, [p, f], a),
11623
+ sql: be(m, d.table, [h, f], a),
11621
11624
  tableName: d.table,
11622
11625
  logicalPath: `${u}.${o.key}.${l.key}`,
11623
11626
  description: `migration setup transform unique index ${u}`
@@ -11687,12 +11690,12 @@ const Ba = ae.create({ name: "get" });
11687
11690
  function ke(c) {
11688
11691
  if (!c) return;
11689
11692
  if (c.raw.type === "atom")
11690
- return Ot.create({
11693
+ return Ft.create({
11691
11694
  type: "atom",
11692
11695
  data: c.raw.data
11693
11696
  });
11694
11697
  const t = c.raw;
11695
- return Ft.create({
11698
+ return Lt.create({
11696
11699
  type: "expression",
11697
11700
  operator: t.operator,
11698
11701
  left: ke(c.left),
@@ -11821,7 +11824,7 @@ class gt {
11821
11824
  return typeof r.content == "string" && r.content.startsWith("func::") && (i.content = new Function("return " + r.content.substring(6))()), this.create(i, e.options);
11822
11825
  }
11823
11826
  }
11824
- class Vt {
11827
+ class Qt {
11825
11828
  constructor(t, e) {
11826
11829
  this._type = "Attributives", this._options = e, this.uuid = A(e), this.content = t.content;
11827
11830
  }
@@ -11844,7 +11847,7 @@ class Vt {
11844
11847
  };
11845
11848
  }
11846
11849
  static create(t, e) {
11847
- const i = new Vt(t, e);
11850
+ const i = new Qt(t, e);
11848
11851
  if (this.instances.find((a) => a.uuid === i.uuid))
11849
11852
  throw new Error(`duplicate uuid in options ${i.uuid}, Attributives`);
11850
11853
  return this.instances.push(i), i;
@@ -11878,12 +11881,12 @@ class Vt {
11878
11881
  function Ae(c) {
11879
11882
  if (!c) return;
11880
11883
  if (c.raw.type === "atom")
11881
- return Ot.create({
11884
+ return Ft.create({
11882
11885
  type: "atom",
11883
11886
  data: c.raw.data
11884
11887
  });
11885
11888
  const t = c.raw;
11886
- return Ft.create({
11889
+ return Lt.create({
11887
11890
  type: "expression",
11888
11891
  operator: t.operator,
11889
11892
  left: Ae(c.left),
@@ -11891,7 +11894,7 @@ function Ae(c) {
11891
11894
  });
11892
11895
  }
11893
11896
  function Os(c) {
11894
- return Vt.create({
11897
+ return Qt.create({
11895
11898
  content: Ae(c)
11896
11899
  });
11897
11900
  }
@@ -11999,14 +12002,14 @@ class We {
11999
12002
  return this.create(e.public, e.options);
12000
12003
  }
12001
12004
  }
12002
- class K extends Error {
12005
+ class J extends Error {
12003
12006
  constructor(t, e) {
12004
12007
  super(t), this.name = "InteractionGuardError", this.type = e.type, this.checkType = e.checkType, this.error = e.error;
12005
12008
  }
12006
12009
  }
12007
12010
  function Ha(c) {
12008
12011
  return async function(t) {
12009
- await _i(this, c, t), await Ja(this, c, t), await Vi(this, c, t);
12012
+ await _i(this, c, t), await Ka(this, c, t), await Vi(this, c, t);
12010
12013
  };
12011
12014
  }
12012
12015
  function ja(c) {
@@ -12021,7 +12024,7 @@ function ja(c) {
12021
12024
  }
12022
12025
  function Wa(c) {
12023
12026
  return async function(t) {
12024
- return Ka(this, c, t);
12027
+ return Ja(this, c, t);
12025
12028
  };
12026
12029
  }
12027
12030
  async function _i(c, t, e) {
@@ -12041,7 +12044,7 @@ async function _i(c, t, e) {
12041
12044
  return !0;
12042
12045
  }, a = await i.evaluateAsync(r);
12043
12046
  if (a !== !0)
12044
- throw new K(`Condition check failed: ${a?.data?.name}`, {
12047
+ throw new J(`Condition check failed: ${a?.data?.name}`, {
12045
12048
  type: "condition check failed",
12046
12049
  checkType: "condition",
12047
12050
  error: a
@@ -12059,11 +12062,11 @@ async function Ga(c, t, e, i) {
12059
12062
  }
12060
12063
  return !0;
12061
12064
  }
12062
- async function Ja(c, t, e) {
12065
+ async function Ka(c, t, e) {
12063
12066
  if (!t.userAttributives) return;
12064
- const i = Vt.is(t.userAttributives) ? E.fromValue(t.userAttributives.content) : E.atom(t.userAttributives), r = (s) => Ga(c, s, e, e.user), a = await i.evaluateAsync(r);
12067
+ const i = Qt.is(t.userAttributives) ? E.fromValue(t.userAttributives.content) : E.atom(t.userAttributives), r = (s) => Ga(c, s, e, e.user), a = await i.evaluateAsync(r);
12065
12068
  if (a !== !0)
12066
- throw new K("User check failed", {
12069
+ throw new J("User check failed", {
12067
12070
  type: "check user failed",
12068
12071
  checkType: "user",
12069
12072
  error: a
@@ -12073,67 +12076,67 @@ async function Vi(c, t, e) {
12073
12076
  const i = e.payload || {}, r = t.payload?.items || [], a = Object.keys(i);
12074
12077
  for (const s of a)
12075
12078
  if (!r.some((n) => n.name === s))
12076
- throw new K(
12079
+ throw new J(
12077
12080
  `${s} in payload is not defined in interaction ${t.name}`,
12078
12081
  { type: `${s} not defined`, checkType: "payload" }
12079
12082
  );
12080
12083
  for (const s of r) {
12081
12084
  if (s.required && !(s.name in i))
12082
- throw new K(
12085
+ throw new J(
12083
12086
  `Payload validation failed for field '${s.name}': missing`,
12084
12087
  { type: `${s.name} missing`, checkType: "payload" }
12085
12088
  );
12086
12089
  const n = i[s.name];
12087
12090
  if (n === void 0) return;
12088
12091
  if (s.isCollection && !Array.isArray(n))
12089
- throw new K(
12092
+ throw new J(
12090
12093
  `Payload validation failed for field '${s.name}': data is not array`,
12091
12094
  { type: `${s.name} data is not array`, checkType: "payload" }
12092
12095
  );
12093
12096
  if (s.isCollection) {
12094
12097
  if (s.isRef && !n.every((o) => !!o.id))
12095
- throw new K(
12098
+ throw new J(
12096
12099
  `Payload validation failed for field '${s.name}': data not every is ref`,
12097
12100
  { type: `${s.name} data not every is ref`, checkType: "payload" }
12098
12101
  );
12099
12102
  } else if (s.isRef && !n.id)
12100
- throw new K(
12103
+ throw new J(
12101
12104
  `Payload validation failed for field '${s.name}': data is not a ref`,
12102
12105
  { type: `${s.name} data is not a ref`, checkType: "payload" }
12103
12106
  );
12104
12107
  if (s.base)
12105
12108
  if (s.isCollection)
12106
12109
  for (const o of n) {
12107
- const l = await Rt(o, s.base);
12110
+ const l = await Nt(o, s.base);
12108
12111
  if (l !== !0)
12109
- throw new K(
12112
+ throw new J(
12110
12113
  `Concept check failed for field '${s.name}'`,
12111
12114
  { type: `${s.name} check concept failed`, checkType: "concept", error: l }
12112
12115
  );
12113
12116
  }
12114
12117
  else {
12115
- const o = await Rt(n, s.base);
12118
+ const o = await Nt(n, s.base);
12116
12119
  if (o !== !0)
12117
- throw new K(
12120
+ throw new J(
12118
12121
  `Concept check failed for field '${s.name}'`,
12119
12122
  { type: `${s.name} check concept failed`, checkType: "concept", error: o }
12120
12123
  );
12121
12124
  }
12122
12125
  }
12123
12126
  }
12124
- async function Rt(c, t) {
12127
+ async function Nt(c, t) {
12125
12128
  if (t.base) {
12126
12129
  const e = t;
12127
- return e.attributive, Rt(c, e.base);
12130
+ return e.attributive, Nt(c, e.base);
12128
12131
  }
12129
12132
  if (t.for) {
12130
12133
  for (const e of t.for)
12131
- if (await Rt(c, e) === !0) return !0;
12134
+ if (await Nt(c, e) === !0) return !0;
12132
12135
  return { name: t.name || "", type: "conceptAlias", error: "no match" };
12133
12136
  }
12134
12137
  return gt.is(t) ? !0 : D.is(t) ? c && typeof c == "object" ? !0 : { name: t.name || "", type: "conceptCheck", error: "invalid entity data" } : !0;
12135
12138
  }
12136
- async function Ka(c, t, e) {
12139
+ async function Ja(c, t, e) {
12137
12140
  if (D.is(t.data) || F.is(t.data)) {
12138
12141
  const i = t.data.name, r = t.dataPolicy?.match, a = t.dataPolicy?.modifier, s = { ...e.query?.modifier || {}, ...a || {} }, n = e.query?.attributeQuery || [], o = typeof r == "function" ? await r.call(c, e) : r, l = E.and(o, e.query?.match);
12139
12142
  return c.system.storage.find(i, l, s, n);
@@ -12225,7 +12228,7 @@ class Ge {
12225
12228
  return this.create(e.public, e.options);
12226
12229
  }
12227
12230
  }
12228
- class St {
12231
+ class kt {
12229
12232
  constructor(t, e) {
12230
12233
  this._type = "ActivityGroup", this._options = e, this.uuid = A(e), this.type = t.type, this.activities = t.activities || [];
12231
12234
  }
@@ -12254,7 +12257,7 @@ class St {
12254
12257
  };
12255
12258
  }
12256
12259
  static create(t, e) {
12257
- const i = new St(t, e);
12260
+ const i = new kt(t, e);
12258
12261
  if (this.instances.find((a) => a.uuid === i.uuid))
12259
12262
  throw new Error(`duplicate uuid in options ${i.uuid}, ActivityGroup`);
12260
12263
  return this.instances.push(i), i;
@@ -12369,7 +12372,7 @@ function Fs(c) {
12369
12372
  function Ls(c) {
12370
12373
  return null;
12371
12374
  }
12372
- class Je {
12375
+ class Ke {
12373
12376
  constructor(t, e) {
12374
12377
  this._type = "Condition", this._options = e, this.uuid = A(e), this.content = t.content, this.name = t.name;
12375
12378
  }
@@ -12395,7 +12398,7 @@ class Je {
12395
12398
  };
12396
12399
  }
12397
12400
  static create(t, e) {
12398
- const i = new Je(t, e);
12401
+ const i = new Ke(t, e);
12399
12402
  if (this.instances.find((a) => a.uuid === i.uuid))
12400
12403
  throw new Error(`duplicate uuid in options ${i.uuid}, Condition`);
12401
12404
  return this.instances.push(i), i;
@@ -12429,7 +12432,7 @@ class Je {
12429
12432
  return typeof r.content == "string" && r.content.startsWith("func::") && (i.content = new Function("return " + r.content.substring(6))()), this.create(i, e.options);
12430
12433
  }
12431
12434
  }
12432
- class Ke {
12435
+ class Je {
12433
12436
  constructor(t, e) {
12434
12437
  this._type = "DataAttributive", this._options = e, this.uuid = A(e), this.content = t.content, this.name = t.name;
12435
12438
  }
@@ -12455,7 +12458,7 @@ class Ke {
12455
12458
  };
12456
12459
  }
12457
12460
  static create(t, e) {
12458
- const i = new Ke(t, e);
12461
+ const i = new Je(t, e);
12459
12462
  if (this.instances.find((a) => a.uuid === i.uuid))
12460
12463
  throw new Error(`duplicate uuid in options ${i.uuid}, DataAttributive`);
12461
12464
  return this.instances.push(i), i;
@@ -12553,7 +12556,7 @@ class Ui {
12553
12556
  return this.create(e.public, e.options);
12554
12557
  }
12555
12558
  }
12556
- class kt {
12559
+ class At {
12557
12560
  constructor(t, e) {
12558
12561
  this._type = "Gateway", this._options = e, this.uuid = A(e), this.name = t.name;
12559
12562
  }
@@ -12575,7 +12578,7 @@ class kt {
12575
12578
  };
12576
12579
  }
12577
12580
  static create(t, e) {
12578
- const i = new kt(t, e);
12581
+ const i = new At(t, e);
12579
12582
  if (this.instances.find((a) => a.uuid === i.uuid))
12580
12583
  throw new Error(`duplicate uuid in options ${i.uuid}, Gateway`);
12581
12584
  return this.instances.push(i), i;
@@ -12865,10 +12868,10 @@ const Xa = [
12865
12868
  We,
12866
12869
  Ge,
12867
12870
  gt,
12868
- Je,
12869
12871
  Ke,
12872
+ Je,
12870
12873
  ae,
12871
- kt,
12874
+ At,
12872
12875
  Xe,
12873
12876
  ze,
12874
12877
  Ye,
@@ -12930,11 +12933,11 @@ class B {
12930
12933
  }
12931
12934
  static createInitialState(t) {
12932
12935
  const e = { uuid: t.uuid };
12933
- return St.is(t.content) && (e.children = t.childSeqs.map((i) => ft.createInitialState(i.head))), e;
12936
+ return kt.is(t.content) && (e.children = t.childSeqs.map((i) => ft.createInitialState(i.head))), e;
12934
12937
  }
12935
12938
  static create(t, e, i) {
12936
12939
  const r = e.getNodeByUUID(t.uuid);
12937
- if (St.is(r.content)) {
12940
+ if (kt.is(r.content)) {
12938
12941
  const s = B.GroupStateNodeType.get(r.content.type), n = new s(r, e, i);
12939
12942
  return n.isGroup = !0, n.children = t?.children?.map((o) => ft.create(o, e, n)), n;
12940
12943
  } else
@@ -12972,7 +12975,7 @@ class ye {
12972
12975
  return this.root.toJSON();
12973
12976
  }
12974
12977
  }
12975
- class Nt {
12978
+ class vt {
12976
12979
  constructor(t) {
12977
12980
  this.activity = t, this.uuidToNode = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.checkUserRef = async (e, i, r, a) => (C(i.isRef, "attributive must be ref"), ((await this.getActivity(e, a))?.refs)[i.name] === r.id), this.graph = this.buildGraph(t);
12978
12981
  }
@@ -12999,7 +13002,7 @@ class Nt {
12999
13002
  const a = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]), s = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]);
13000
13003
  if (t.transfers?.forEach((n) => {
13001
13004
  const o = this.rawToNode.get(n.source) || i.get(n.source), l = this.rawToNode.get(n.target) || i.get(n.target);
13002
- C(!!o, `cannot find source ${n.source.name}`), C(!!l, `cannot find target ${n.source.name}`), kt.is(o) ? o.next.push(l) : o.next = l, kt.is(l) ? l.prev.push(o) : l.prev = o, s.delete(n.source), a.delete(n.target);
13005
+ C(!!o, `cannot find source ${n.source.name}`), C(!!l, `cannot find target ${n.source.name}`), At.is(o) ? o.next.push(l) : o.next = l, At.is(l) ? l.prev.push(o) : l.prev = o, s.delete(n.source), a.delete(n.target);
13003
13006
  }), a.size !== 1) throw new Error(`start node must one, current: ${a.size}`);
13004
13007
  if (s.size !== 1) throw new Error(`end node must be one, current: ${s.size}`);
13005
13008
  return Object.assign(r, {
@@ -13013,7 +13016,7 @@ class Nt {
13013
13016
  async create(t) {
13014
13017
  const e = ye.createInitialState(this.graph.head);
13015
13018
  return {
13016
- activityId: (await t.system.storage.create(Nt.ACTIVITY_RECORD, {
13019
+ activityId: (await t.system.storage.create(vt.ACTIVITY_RECORD, {
13017
13020
  name: this.activity.name,
13018
13021
  uuid: this.activity.uuid,
13019
13022
  state: e,
@@ -13033,14 +13036,14 @@ class Nt {
13033
13036
  key: "id",
13034
13037
  value: ["=", e]
13035
13038
  });
13036
- return (await t.system.storage.find(Nt.ACTIVITY_RECORD, i, void 0, ["*"])).map((a) => ({ ...a, state: a.state, refs: a.refs }))[0];
13039
+ return (await t.system.storage.find(vt.ACTIVITY_RECORD, i, void 0, ["*"])).map((a) => ({ ...a, state: a.state, refs: a.refs }))[0];
13037
13040
  }
13038
13041
  async setActivity(t, e, i) {
13039
13042
  const r = w.atom({
13040
13043
  key: "id",
13041
13044
  value: ["=", e]
13042
13045
  }), a = { ...i };
13043
- return delete a.state, delete a.refs, i.state && (a.state = i.state), i.refs && (a.refs = i.refs), await t.system.storage.update(Nt.ACTIVITY_RECORD, r, a);
13046
+ return delete a.state, delete a.refs, i.state && (a.state = i.state), i.refs && (a.refs = i.refs), await t.system.storage.update(vt.ACTIVITY_RECORD, r, a);
13044
13047
  }
13045
13048
  async setState(t, e, i) {
13046
13049
  return this.setActivity(t, e, { state: i });
@@ -13054,7 +13057,7 @@ class Nt {
13054
13057
  return e.parentSeq.tail === e;
13055
13058
  }
13056
13059
  isActivityHead(t, e = this.graph.head) {
13057
- return St.is(this.graph.head.content) ? !!this.graph.head.childSeqs?.some((i) => this.isActivityHead(t, i.head)) : t === this.graph.head.content;
13060
+ return kt.is(this.graph.head.content) ? !!this.graph.head.childSeqs?.some((i) => this.isActivityHead(t, i.head)) : t === this.graph.head.content;
13058
13061
  }
13059
13062
  async checkActivityState(t, e, i) {
13060
13063
  if (!new ye(await this.getState(t, e), this).isInteractionAvailable(i))
@@ -13062,13 +13065,13 @@ class Nt {
13062
13065
  }
13063
13066
  async fullGuardWithUserRef(t, e, i) {
13064
13067
  if (!t.ignoreGuard && e.conditions && await _i(t, e, i), e.userAttributives) {
13065
- const r = Vt.is(e.userAttributives) ? E.fromValue(
13068
+ const r = Qt.is(e.userAttributives) ? E.fromValue(
13066
13069
  e.userAttributives.content
13067
13070
  ) : E.atom(
13068
13071
  e.userAttributives
13069
13072
  ), a = (n) => n.isRef ? this.checkUserRef(t, n, i.user, i.activityId) : za(t, n, i, i.user), s = await r.evaluateAsync(a);
13070
13073
  if (s !== !0)
13071
- throw new K("User check failed", {
13074
+ throw new J("User check failed", {
13072
13075
  type: "check user failed",
13073
13076
  checkType: "user",
13074
13077
  error: s
@@ -13166,7 +13169,7 @@ const is = "_Activity_", Hi = D.create({
13166
13169
  class _s {
13167
13170
  constructor(t) {
13168
13171
  this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.activityEventSources = [], this.requiredEntities = [], this.requiredRelations = [], t.length > 0 && (this.requiredEntities.push(Hi, je), this.requiredRelations.push(rs)), t.forEach((e) => {
13169
- const i = new Nt(e);
13172
+ const i = new vt(e);
13170
13173
  this.activityCalls.set(e.uuid, i), e.name && (C(!this.activityCallsByName.has(e.name), `activity name ${e.name} is duplicated`), this.activityCallsByName.set(e.name, i));
13171
13174
  });
13172
13175
  for (const e of t) {
@@ -13293,42 +13296,42 @@ export {
13293
13296
  de as ASYNC_TASK_RECORD,
13294
13297
  ae as Action,
13295
13298
  Ge as Activity,
13296
- Nt as ActivityCall,
13299
+ vt as ActivityCall,
13297
13300
  as as ActivityError,
13298
- St as ActivityGroup,
13301
+ kt as ActivityGroup,
13299
13302
  rs as ActivityInteractionRelation,
13300
13303
  _s as ActivityManager,
13301
13304
  Hi as ActivityStateEntity,
13302
13305
  Qs as ActivityStateError,
13303
13306
  Er as AliasManager,
13304
13307
  fa as AmbiguousComputationSignatureError,
13305
- Pt as Any,
13308
+ Dt as Any,
13306
13309
  qr as AnyHandles,
13307
13310
  Ve as AsyncMigrationComputationError,
13308
13311
  it as AttributeInfo,
13309
13312
  O as AttributeQuery,
13310
13313
  gt as Attributive,
13311
- Vt as Attributives,
13312
- xt as Average,
13314
+ Qt as Attributives,
13315
+ Mt as Average,
13313
13316
  ra as AverageHandles,
13314
- Ot as BoolAtomData,
13317
+ Ft as BoolAtomData,
13315
13318
  E as BoolExp,
13316
- Ft as BoolExpressionData,
13319
+ Lt as BoolExpressionData,
13317
13320
  rt as ComputationDataDepError,
13318
13321
  H as ComputationError,
13319
13322
  x as ComputationResult,
13320
- _t as ComputationResultAsync,
13323
+ Vt as ComputationResultAsync,
13321
13324
  Xt as ComputationResultFullRecompute,
13322
13325
  ee as ComputationResultResolved,
13323
13326
  ht as ComputationResultSkip,
13324
13327
  li as ComputationStateError,
13325
- Je as Condition,
13328
+ Ke as Condition,
13326
13329
  lt as ConditionError,
13327
13330
  se as Conditions,
13328
13331
  at as ConstraintSetupError,
13329
13332
  Ii as ConstraintViolationError,
13330
13333
  xs as Controller,
13331
- $t as Count,
13334
+ It as Count,
13332
13335
  Qr as CountHandles,
13333
13336
  ir as CreationExecutor,
13334
13337
  Pe as Custom,
@@ -13338,11 +13341,11 @@ export {
13338
13341
  ri as DBSetup,
13339
13342
  ii as DEFAULT_SCHEMA_DIALECT,
13340
13343
  Es as DELETED_STATE,
13341
- J as DICTIONARY_RECORD,
13342
- Ke as DataAttributive,
13344
+ K as DICTIONARY_RECORD,
13345
+ Je as DataAttributive,
13343
13346
  Ze as DataAttributives,
13344
13347
  Ui as DataPolicy,
13345
- Tt as DestructiveComputedOutputError,
13348
+ St as DestructiveComputedOutputError,
13346
13349
  Ie as Dictionary,
13347
13350
  oi as DictionaryEntity,
13348
13351
  D as Entity,
@@ -13354,11 +13357,11 @@ export {
13354
13357
  q as ErrorSeverity,
13355
13358
  Xe as Event,
13356
13359
  ki as EventSource,
13357
- Mt as Every,
13360
+ Pt as Every,
13358
13361
  Or as EveryHandles,
13359
13362
  _ as Expression,
13360
13363
  U as FrameworkError,
13361
- kt as Gateway,
13364
+ At as Gateway,
13362
13365
  Ba as GetAction,
13363
13366
  Fr as GlobalAnyHandle,
13364
13367
  ea as GlobalAverageHandle,
@@ -13366,7 +13369,7 @@ export {
13366
13369
  _r as GlobalCountHandle,
13367
13370
  aa as GlobalCustomHandle,
13368
13371
  Pr as GlobalEveryHandle,
13369
- Kr as GlobalRealTimeComputation,
13372
+ Jr as GlobalRealTimeComputation,
13370
13373
  Ar as GlobalStateMachineHandle,
13371
13374
  Yr as GlobalSumHandle,
13372
13375
  Ir as GlobalWeightedSummationHandle,
@@ -13378,10 +13381,10 @@ export {
13378
13381
  We as Interaction,
13379
13382
  je as InteractionEventEntity,
13380
13383
  Vs as InteractionExecutionError,
13381
- K as InteractionGuardError,
13384
+ J as InteractionGuardError,
13382
13385
  Ce as KlassByName,
13383
13386
  g as LINK_SYMBOL,
13384
- Kt as LinkInfo,
13387
+ Jt as LinkInfo,
13385
13388
  Le as MIGRATION_MANIFEST_CONCEPT,
13386
13389
  qe as MIGRATION_MANIFEST_CURRENT_KEY,
13387
13390
  w as MatchExp,
@@ -13412,12 +13415,12 @@ export {
13412
13415
  $e as PropertyTypes,
13413
13416
  xr as PropertyWeightedSummationHandle,
13414
13417
  or as QueryExecutor,
13415
- Jt as ROOT_LABEL,
13418
+ Kt as ROOT_LABEL,
13416
13419
  si as ROW_ID_ATTR,
13417
- Dt as RealTime,
13420
+ Ot as RealTime,
13418
13421
  zr as RealTimeHandles,
13419
13422
  $ as RecordBoundState,
13420
- vt as RecordInfo,
13423
+ Et as RecordInfo,
13421
13424
  qi as RecordMutationSideEffect,
13422
13425
  L as RecordQuery,
13423
13426
  ur as RecordQueryAgent,
@@ -13433,24 +13436,24 @@ export {
13433
13436
  wt as SYSTEM_RECORD,
13434
13437
  ha as Scheduler,
13435
13438
  Me as SideEffect,
13436
- At as StateMachine,
13439
+ Ct as StateMachine,
13437
13440
  $r as StateMachineHandles,
13438
13441
  mt as StateNode,
13439
13442
  xe as StateTransfer,
13440
- It as Summation,
13443
+ xt as Summation,
13441
13444
  ta as SummationHandles,
13442
13445
  He as SystemConsoleLogger,
13443
13446
  ni as SystemEntity,
13444
13447
  Va as SystemLogLevel,
13445
13448
  Re as TransactionCapabilityError,
13446
- jt as TransactionRetryExhaustedError,
13449
+ Wt as TransactionRetryExhaustedError,
13447
13450
  Qi as Transfer,
13448
13451
  te as Transform,
13449
- Jr as TransformHandles,
13452
+ Kr as TransformHandles,
13450
13453
  $s as USER_ENTITY,
13451
13454
  Zt as UniqueConstraint,
13452
- Et as UnrebuildableComputationError,
13453
- Ct as WeightedSummation,
13455
+ Tt as UnrebuildableComputationError,
13456
+ $t as WeightedSummation,
13454
13457
  Mr as WeightedSummationHandles,
13455
13458
  di as addToCurrentEffects,
13456
13459
  C as assert,
@@ -13467,7 +13470,7 @@ export {
13467
13470
  re as computationManifestId,
13468
13471
  Gi as createInstances,
13469
13472
  hs as createInstancesFromString,
13470
- Ht as createMigrationManifest,
13473
+ jt as createMigrationManifest,
13471
13474
  kr as createNonNullConstraintStatement,
13472
13475
  Ia as createPlanBlockingMessages,
13473
13476
  Sr as createUniqueConstraintStatement,
@@ -13475,7 +13478,7 @@ export {
13475
13478
  qs as createUserRoleAttributive,
13476
13479
  P as dataContextPath,
13477
13480
  Ms as dbConsoleLogger,
13478
- Qt as deepClone,
13481
+ Bt as deepClone,
13479
13482
  Ai as defaultEncodeLiteral,
13480
13483
  bs as everyAsync,
13481
13484
  Rs as everyWithErrorAsync,
@@ -13507,7 +13510,7 @@ export {
13507
13510
  le as normalizeDatabaseError,
13508
13511
  Tr as predicateSQLForOperator,
13509
13512
  ot as quoteIdentifier,
13510
- Bt as quoteLiteral,
13513
+ Ut as quoteLiteral,
13511
13514
  gi as readMigrationManifest,
13512
13515
  Pa as recomputeChangedComputations,
13513
13516
  Oa as recomputeFilteredMemberships,