interaqt 0.4.1 → 0.4.2

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
@@ -1,31 +1,31 @@
1
- import { uuidv7 as de } from "uuidv7";
2
- import { parse as Ie } from "acorn";
3
- import Ce from "better-sqlite3";
4
- import { AsyncLocalStorage as xe } from "async_hooks";
5
- import Me from "pg";
6
- import { PGlite as $e } from "@electric-sql/pglite";
7
- import se from "mysql2/promise";
8
- function he(u) {
1
+ import { uuidv7 as pe } from "uuidv7";
2
+ import { parse as Me } from "acorn";
3
+ import { AsyncLocalStorage as fe } from "async_hooks";
4
+ import $e from "better-sqlite3";
5
+ import Pe from "pg";
6
+ import { PGlite as De } from "@electric-sql/pglite";
7
+ import ae from "mysql2/promise";
8
+ function me(u) {
9
9
  return u !== null && typeof u == "object";
10
10
  }
11
- function pe(u) {
12
- if (!he(u)) return !1;
11
+ function ye(u) {
12
+ if (!me(u)) return !1;
13
13
  const t = Object.getPrototypeOf(u);
14
14
  return t === null ? !0 : t === Object.prototype || t === null;
15
15
  }
16
- function Pe(u, t) {
16
+ function Oe(u, t) {
17
17
  const e = {};
18
18
  for (const i of u)
19
19
  i && i[t] !== void 0 && (e[String(i[t])] = i);
20
20
  return e;
21
21
  }
22
22
  function w(u) {
23
- return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : he(u) && !pe(u) ? `uuid::${u.uuid}` : u;
23
+ return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : me(u) && !ye(u) ? `uuid::${u.uuid}` : u;
24
24
  }
25
25
  function Nt(u, t) {
26
26
  if (u == null || typeof u != "object") return u;
27
27
  if (Array.isArray(u)) return u.map((i) => Nt(i, t));
28
- if (pe(u))
28
+ if (ye(u))
29
29
  return Object.fromEntries(Object.entries(u).map(([i, r]) => [i, Nt(r, t)]));
30
30
  if (u instanceof Set)
31
31
  return new Set(Array.from(u.values()).map((i) => Nt(i, t)));
@@ -34,30 +34,30 @@ function Nt(u, t) {
34
34
  const e = u;
35
35
  return t && e._type && e.constructor?.clone ? e.constructor.clone(u, t) : u;
36
36
  }
37
- function gr(...u) {
37
+ function wr(...u) {
38
38
  for (const t of u)
39
39
  t.instances.length = 0;
40
40
  }
41
- function br() {
41
+ function Nr() {
42
42
  }
43
- const Lt = /* @__PURE__ */ new Map();
44
- function De(u, t) {
45
- t && t.isKlass && t.displayName && Lt.set(u, t);
43
+ const _t = /* @__PURE__ */ new Map();
44
+ function Fe(u, t) {
45
+ t && t.isKlass && t.displayName && _t.set(u, t);
46
46
  }
47
- function Rr() {
47
+ function Tr() {
48
48
  const u = [];
49
- return Array.from(Lt.entries()).forEach(([, t]) => {
49
+ return Array.from(_t.entries()).forEach(([, t]) => {
50
50
  t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
51
51
  }), `[${u.join(",")}]`;
52
52
  }
53
- function wr(u) {
53
+ function vr(u) {
54
54
  const t = JSON.parse(u);
55
- return Oe(t);
55
+ return Qe(t);
56
56
  }
57
- function Oe(u) {
57
+ function Qe(u) {
58
58
  const t = /* @__PURE__ */ new Map();
59
59
  return u.forEach(({ type: e, options: i = {}, uuid: r, public: s }) => {
60
- const a = Lt.get(e);
60
+ const a = _t.get(e);
61
61
  if (!a) {
62
62
  console.warn(`Class ${e} not found in KlassByName`);
63
63
  return;
@@ -66,10 +66,10 @@ function Oe(u) {
66
66
  t.set(r, o);
67
67
  }), t;
68
68
  }
69
- function Nr(u) {
69
+ function Sr(u) {
70
70
  return console.warn("createClass is deprecated in refactored code"), null;
71
71
  }
72
- class Tr {
72
+ class kr {
73
73
  static {
74
74
  this.isKlass = !0;
75
75
  }
@@ -92,9 +92,9 @@ class Tr {
92
92
  }
93
93
  }
94
94
  function v(u) {
95
- return u?.uuid || de();
95
+ return u?.uuid || pe();
96
96
  }
97
- const Fe = /^[a-zA-Z0-9_]+$/;
97
+ const Ve = /^[a-zA-Z0-9_]+$/;
98
98
  class C {
99
99
  // for Merged Entity
100
100
  constructor(t, e) {
@@ -115,7 +115,7 @@ class C {
115
115
  type: "string",
116
116
  required: !0,
117
117
  constraints: {
118
- nameFormat: ({ name: t }) => Fe.test(t)
118
+ nameFormat: ({ name: t }) => Ve.test(t)
119
119
  }
120
120
  },
121
121
  properties: {
@@ -197,8 +197,8 @@ class C {
197
197
  }
198
198
  }
199
199
  var qt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(qt || {});
200
- const Qe = /^[a-zA-Z0-9_]+$/;
201
- class _t {
200
+ const Le = /^[a-zA-Z0-9_]+$/;
201
+ class Bt {
202
202
  constructor(t, e) {
203
203
  this._type = "Dictionary", this._options = e, this.uuid = v(e), this.name = t.name, this.type = t.type, this.collection = t.collection ?? !1, this.args = t.args, this.defaultValue = t.defaultValue, this.computation = t.computation;
204
204
  }
@@ -218,7 +218,7 @@ class _t {
218
218
  required: !0,
219
219
  collection: !1,
220
220
  constraints: {
221
- format: ({ name: t }) => Qe.test(t),
221
+ format: ({ name: t }) => Le.test(t),
222
222
  length: ({ name: t }) => t.length > 1 && t.length < 5
223
223
  }
224
224
  },
@@ -252,7 +252,7 @@ class _t {
252
252
  };
253
253
  }
254
254
  static create(t, e) {
255
- const i = new _t(t, e);
255
+ const i = new Bt(t, e);
256
256
  if (this.instances.find((s) => s.uuid === i.uuid))
257
257
  throw new Error(`duplicate uuid in options ${i.uuid}, Dictionary`);
258
258
  return this.instances.push(i), i;
@@ -291,7 +291,7 @@ class _t {
291
291
  return this.create(e.public, e.options);
292
292
  }
293
293
  }
294
- const Ve = /^[a-zA-Z0-9_]+$/;
294
+ const _e = /^[a-zA-Z0-9_]+$/;
295
295
  class T {
296
296
  constructor(t, e) {
297
297
  this._type = "Property", this._options = e, this.uuid = v(e), this.name = t.name, this.type = t.type, this.collection = t.collection, this.defaultValue = t.defaultValue, this.computed = t.computed, this.computation = t.computation;
@@ -311,7 +311,7 @@ class T {
311
311
  type: "string",
312
312
  required: !0,
313
313
  constraints: {
314
- format: ({ name: t }) => Ve.test(t),
314
+ format: ({ name: t }) => _e.test(t),
315
315
  length: ({ name: t }) => t.length > 1 && t.length < 5
316
316
  }
317
317
  },
@@ -557,7 +557,7 @@ class D {
557
557
  return this.create(e.public, e.options);
558
558
  }
559
559
  }
560
- class Bt {
560
+ class Wt {
561
561
  constructor(t, e) {
562
562
  this._type = "Interaction", this._options = e, this.uuid = v(e), this.name = t.name, this.conditions = t.conditions, this.userAttributives = t.userAttributives, this.userRef = t.userRef, this.action = t.action, this.payload = t.payload, this.sideEffects = t.sideEffects || [], this.data = t.data, this.query = t.query;
563
563
  }
@@ -618,7 +618,7 @@ class Bt {
618
618
  };
619
619
  }
620
620
  static create(t, e) {
621
- const i = new Bt(t, e);
621
+ const i = new Wt(t, e);
622
622
  if (this.instances.find((s) => s.uuid === i.uuid))
623
623
  throw new Error(`duplicate uuid in options ${i.uuid}, Interaction`);
624
624
  return this.instances.push(i), i;
@@ -655,7 +655,7 @@ class Bt {
655
655
  return this.create(e.public, e.options);
656
656
  }
657
657
  }
658
- class Wt {
658
+ class Jt {
659
659
  constructor(t, e) {
660
660
  this._type = "Activity", this._options = e, this.uuid = v(e), this.name = t.name, this.interactions = t.interactions || [], this.gateways = t.gateways || [], this.transfers = t.transfers || [], this.groups = t.groups || [], this.events = t.events || [];
661
661
  }
@@ -703,7 +703,7 @@ class Wt {
703
703
  };
704
704
  }
705
705
  static create(t, e) {
706
- const i = new Wt(t, e);
706
+ const i = new Jt(t, e);
707
707
  if (this.instances.find((s) => s.uuid === i.uuid))
708
708
  throw new Error(`duplicate uuid in options ${i.uuid}, Activity`);
709
709
  return this.instances.push(i), i;
@@ -804,7 +804,7 @@ class rt {
804
804
  return this.create(e.public, e.options);
805
805
  }
806
806
  }
807
- class fe {
807
+ class ge {
808
808
  constructor(t, e) {
809
809
  this._type = "Transfer", this._options = e, this.uuid = v(e), this.name = t.name, this.source = t.source, this.target = t.target;
810
810
  }
@@ -837,7 +837,7 @@ class fe {
837
837
  };
838
838
  }
839
839
  static create(t, e) {
840
- const i = new fe(t, e);
840
+ const i = new ge(t, e);
841
841
  if (this.instances.find((s) => s.uuid === i.uuid))
842
842
  throw new Error(`duplicate uuid in options ${i.uuid}, Transfer`);
843
843
  return this.instances.push(i), i;
@@ -873,16 +873,16 @@ class fe {
873
873
  return this.create(e.public, e.options);
874
874
  }
875
875
  }
876
- function me(u, t, e) {
876
+ function be(u, t, e) {
877
877
  u.interactions.forEach((i) => t(i, e)), u.groups.forEach((i) => {
878
- i.activities?.forEach((r) => me(r, t, i));
878
+ i.activities?.forEach((r) => be(r, t, i));
879
879
  });
880
880
  }
881
- function vr(u) {
881
+ function Ar(u) {
882
882
  const t = [];
883
- return me(u, (e) => t.push(e)), t;
883
+ return be(u, (e) => t.push(e)), t;
884
884
  }
885
- function Sr(u) {
885
+ function Er(u) {
886
886
  return null;
887
887
  }
888
888
  class ct {
@@ -1161,19 +1161,19 @@ class R {
1161
1161
  throw new Error(`invalid bool expression type: ${JSON.stringify(this.raw)}`);
1162
1162
  }
1163
1163
  }
1164
- const Le = {
1164
+ const qe = {
1165
1165
  "&&": "and",
1166
1166
  "||": "or",
1167
1167
  "!": "not"
1168
1168
  };
1169
- function qe(u) {
1169
+ function Be(u) {
1170
1170
  return { key: u };
1171
1171
  }
1172
1172
  function Tt(u, t, e) {
1173
1173
  if (u.type === "LogicalExpression")
1174
1174
  return {
1175
1175
  type: "expression",
1176
- operator: Le[u.operator],
1176
+ operator: qe[u.operator],
1177
1177
  left: Tt(u.left, t, e),
1178
1178
  right: Tt(u.right, t, e)
1179
1179
  };
@@ -1190,8 +1190,8 @@ function Tt(u, t, e) {
1190
1190
  };
1191
1191
  throw new Error("unknown ast node type");
1192
1192
  }
1193
- function kr(u, t = [], e = qe) {
1194
- const i = Pe(t, "name"), r = Ie(u, { ecmaVersion: 2020 });
1193
+ function Ir(u, t = [], e = Be) {
1194
+ const i = Oe(t, "name"), r = Me(u, { ecmaVersion: 2020 });
1195
1195
  return new R(
1196
1196
  Tt(r.body[0].expression, i, e)
1197
1197
  );
@@ -1318,7 +1318,7 @@ class st {
1318
1318
  return this.create(e.public, e.options);
1319
1319
  }
1320
1320
  }
1321
- function Dt(u) {
1321
+ function Ot(u) {
1322
1322
  if (!u) return;
1323
1323
  if (u.raw.type === "atom")
1324
1324
  return ct.create({
@@ -1329,16 +1329,16 @@ function Dt(u) {
1329
1329
  return lt.create({
1330
1330
  type: "expression",
1331
1331
  operator: t.operator,
1332
- left: Dt(u.left),
1333
- right: Dt(u.right)
1332
+ left: Ot(u.left),
1333
+ right: Ot(u.right)
1334
1334
  });
1335
1335
  }
1336
- function Ar(u) {
1336
+ function Cr(u) {
1337
1337
  return st.create({
1338
- content: Dt(u)
1338
+ content: Ot(u)
1339
1339
  });
1340
1340
  }
1341
- class Jt {
1341
+ class jt {
1342
1342
  constructor(t, e) {
1343
1343
  this._type = "Condition", this._options = e, this.uuid = v(e), this.content = t.content, this.name = t.name;
1344
1344
  }
@@ -1364,7 +1364,7 @@ class Jt {
1364
1364
  };
1365
1365
  }
1366
1366
  static create(t, e) {
1367
- const i = new Jt(t, e);
1367
+ const i = new jt(t, e);
1368
1368
  if (this.instances.find((s) => s.uuid === i.uuid))
1369
1369
  throw new Error(`duplicate uuid in options ${i.uuid}, Condition`);
1370
1370
  return this.instances.push(i), i;
@@ -1398,7 +1398,7 @@ class Jt {
1398
1398
  return i.content && typeof i.content == "string" && i.content.startsWith("func::") && (i.content = new Function("return " + i.content.substring(6))()), this.create(i, e.options);
1399
1399
  }
1400
1400
  }
1401
- class jt {
1401
+ class Ht {
1402
1402
  constructor(t, e) {
1403
1403
  this._type = "DataAttributive", this._options = e, this.uuid = v(e), this.content = t.content, this.name = t.name;
1404
1404
  }
@@ -1424,7 +1424,7 @@ class jt {
1424
1424
  };
1425
1425
  }
1426
1426
  static create(t, e) {
1427
- const i = new jt(t, e);
1427
+ const i = new Ht(t, e);
1428
1428
  if (this.instances.find((s) => s.uuid === i.uuid))
1429
1429
  throw new Error(`duplicate uuid in options ${i.uuid}, DataAttributive`);
1430
1430
  return this.instances.push(i), i;
@@ -1458,7 +1458,7 @@ class jt {
1458
1458
  return i.content && typeof i.content == "string" && i.content.startsWith("func::") && (i.content = new Function("return " + i.content.substring(6))()), this.create(i, e.options);
1459
1459
  }
1460
1460
  }
1461
- class ye {
1461
+ class Re {
1462
1462
  constructor(t, e) {
1463
1463
  this._type = "QueryItem", this._options = e, this.uuid = v(e), this.name = t.name, this.value = t.value;
1464
1464
  }
@@ -1486,7 +1486,7 @@ class ye {
1486
1486
  };
1487
1487
  }
1488
1488
  static create(t, e) {
1489
- const i = new ye(t, e);
1489
+ const i = new Re(t, e);
1490
1490
  if (this.instances.find((s) => s.uuid === i.uuid))
1491
1491
  throw new Error(`duplicate uuid in options ${i.uuid}, QueryItem`);
1492
1492
  return this.instances.push(i), i;
@@ -1520,7 +1520,7 @@ class ye {
1520
1520
  return this.create(e.public, e.options);
1521
1521
  }
1522
1522
  }
1523
- class ge {
1523
+ class we {
1524
1524
  constructor(t, e) {
1525
1525
  this._type = "Query", this._options = e, this.uuid = v(e), this.items = t.items;
1526
1526
  }
@@ -1543,7 +1543,7 @@ class ge {
1543
1543
  };
1544
1544
  }
1545
1545
  static create(t, e) {
1546
- const i = new ge(t, e);
1546
+ const i = new we(t, e);
1547
1547
  if (this.instances.find((s) => s.uuid === i.uuid))
1548
1548
  throw new Error(`duplicate uuid in options ${i.uuid}, Query`);
1549
1549
  return this.instances.push(i), i;
@@ -1575,7 +1575,7 @@ class ge {
1575
1575
  return this.create(e.public, e.options);
1576
1576
  }
1577
1577
  }
1578
- class It {
1578
+ class Ct {
1579
1579
  constructor(t, e) {
1580
1580
  this._type = "Action", this._options = e, this.uuid = v(e), this.name = t.name;
1581
1581
  }
@@ -1597,7 +1597,7 @@ class It {
1597
1597
  };
1598
1598
  }
1599
1599
  static create(t, e) {
1600
- const i = new It(t, e);
1600
+ const i = new Ct(t, e);
1601
1601
  if (this.instances.find((s) => s.uuid === i.uuid))
1602
1602
  throw new Error(`duplicate uuid in options ${i.uuid}, Action`);
1603
1603
  return this.instances.push(i), i;
@@ -1629,7 +1629,7 @@ class It {
1629
1629
  return this.create(e.public, e.options);
1630
1630
  }
1631
1631
  }
1632
- const _e = It.create({ name: "get" });
1632
+ const We = Ct.create({ name: "get" });
1633
1633
  class at {
1634
1634
  constructor(t, e) {
1635
1635
  this._type = "Gateway", this._options = e, this.uuid = v(e), this.name = t.name;
@@ -1684,7 +1684,7 @@ class at {
1684
1684
  return this.create(e.public, e.options);
1685
1685
  }
1686
1686
  }
1687
- class Ht {
1687
+ class Ut {
1688
1688
  constructor(t, e) {
1689
1689
  this._type = "Event", this._options = e, this.uuid = v(e), this.name = t.name;
1690
1690
  }
@@ -1706,7 +1706,7 @@ class Ht {
1706
1706
  };
1707
1707
  }
1708
1708
  static create(t, e) {
1709
- const i = new Ht(t, e);
1709
+ const i = new Ut(t, e);
1710
1710
  if (this.instances.find((s) => s.uuid === i.uuid))
1711
1711
  throw new Error(`duplicate uuid in options ${i.uuid}, Event`);
1712
1712
  return this.instances.push(i), i;
@@ -1801,7 +1801,7 @@ class Y {
1801
1801
  return this.create(e.public, e.options);
1802
1802
  }
1803
1803
  }
1804
- class Ut {
1804
+ class Gt {
1805
1805
  constructor(t, e) {
1806
1806
  this._type = "StateTransfer", this._options = e, this.uuid = v(e), this.trigger = t.trigger, this.current = t.current, this.next = t.next, this.computeTarget = t.computeTarget;
1807
1807
  }
@@ -1839,7 +1839,7 @@ class Ut {
1839
1839
  };
1840
1840
  }
1841
1841
  static create(t, e) {
1842
- const i = new Ut(t, e);
1842
+ const i = new Gt(t, e);
1843
1843
  if (this.instances.find((s) => s.uuid === i.uuid))
1844
1844
  throw new Error(`duplicate uuid in options ${i.uuid}, StateTransfer`);
1845
1845
  return this.instances.push(i), i;
@@ -2432,7 +2432,7 @@ class yt {
2432
2432
  return i.callback && typeof i.callback == "string" && i.callback.startsWith("func::") && (i.callback = new Function("return " + i.callback.substring(6))()), this.create(i, e.options);
2433
2433
  }
2434
2434
  }
2435
- class Ct {
2435
+ class xt {
2436
2436
  constructor(t, e) {
2437
2437
  this._type = "Transform", this._options = e, this.uuid = v(e), this.record = t.record, this.eventDeps = t.eventDeps, this.attributeQuery = t.attributeQuery, this.callback = t.callback;
2438
2438
  }
@@ -2465,7 +2465,7 @@ class Ct {
2465
2465
  };
2466
2466
  }
2467
2467
  static create(t, e) {
2468
- const i = new Ct(t, e);
2468
+ const i = new xt(t, e);
2469
2469
  if (this.instances.find((s) => s.uuid === i.uuid))
2470
2470
  throw new Error(`duplicate uuid in options ${i.uuid}, Transform`);
2471
2471
  return this.instances.push(i), i;
@@ -2575,7 +2575,7 @@ class gt {
2575
2575
  return typeof i.callback == "string" && i.callback.startsWith("func::") && (i.callback = new Function("return " + i.callback.substring(6))()), typeof i.nextRecomputeTime == "string" && i.nextRecomputeTime.startsWith("func::") && (i.nextRecomputeTime = new Function("return " + i.nextRecomputeTime.substring(6))()), this.create(i, e.options);
2576
2576
  }
2577
2577
  }
2578
- class Gt {
2578
+ class Kt {
2579
2579
  constructor(t, e) {
2580
2580
  this._type = "PayloadItem", this._options = e, this.uuid = v(e), this.name = t.name, this.attributives = t.attributives, this.base = t.base, this.isRef = t.isRef ?? !1, this.required = t.required ?? !1, this.isCollection = t.isCollection ?? !1, this.itemRef = t.itemRef;
2581
2581
  }
@@ -2626,7 +2626,7 @@ class Gt {
2626
2626
  };
2627
2627
  }
2628
2628
  static create(t, e) {
2629
- const i = new Gt(t, e);
2629
+ const i = new Kt(t, e);
2630
2630
  if (this.instances.find((s) => s.uuid === i.uuid))
2631
2631
  throw new Error(`duplicate uuid in options ${i.uuid}, PayloadItem`);
2632
2632
  return this.instances.push(i), i;
@@ -2664,7 +2664,7 @@ class Gt {
2664
2664
  return this.create(e.public, e.options);
2665
2665
  }
2666
2666
  }
2667
- class Kt {
2667
+ class Xt {
2668
2668
  constructor(t, e) {
2669
2669
  this._type = "Payload", this._options = e, this.uuid = v(e), this.items = t.items || [];
2670
2670
  }
@@ -2688,7 +2688,7 @@ class Kt {
2688
2688
  };
2689
2689
  }
2690
2690
  static create(t, e) {
2691
- const i = new Kt(t, e);
2691
+ const i = new Xt(t, e);
2692
2692
  if (this.instances.find((s) => s.uuid === i.uuid))
2693
2693
  throw new Error(`duplicate uuid in options ${i.uuid}, Payload`);
2694
2694
  return this.instances.push(i), i;
@@ -2720,7 +2720,7 @@ class Kt {
2720
2720
  return this.create(e.public, e.options);
2721
2721
  }
2722
2722
  }
2723
- class Xt {
2723
+ class Yt {
2724
2724
  constructor(t, e) {
2725
2725
  this._type = "SideEffect", this._options = e, this.uuid = v(e), this.name = t.name, this.handle = t.handle;
2726
2726
  }
@@ -2748,7 +2748,7 @@ class Xt {
2748
2748
  };
2749
2749
  }
2750
2750
  static create(t, e) {
2751
- const i = new Xt(t, e);
2751
+ const i = new Yt(t, e);
2752
2752
  if (this.instances.find((s) => s.uuid === i.uuid))
2753
2753
  throw new Error(`duplicate uuid in options ${i.uuid}, SideEffect`);
2754
2754
  return this.instances.push(i), i;
@@ -2782,7 +2782,7 @@ class Xt {
2782
2782
  return i.handle && typeof i.handle == "string" && i.handle.startsWith("func::") && (i.handle = new Function("return " + i.handle.substring(6))()), this.create(i, e.options);
2783
2783
  }
2784
2784
  }
2785
- function Ot(u) {
2785
+ function Ft(u) {
2786
2786
  if (!u) return;
2787
2787
  if (u.raw.type === "atom")
2788
2788
  return ct.create({
@@ -2793,13 +2793,13 @@ function Ot(u) {
2793
2793
  return lt.create({
2794
2794
  type: "expression",
2795
2795
  operator: t.operator,
2796
- left: Ot(u.left),
2797
- right: Ot(u.right)
2796
+ left: Ft(u.left),
2797
+ right: Ft(u.right)
2798
2798
  });
2799
2799
  }
2800
- class xt {
2800
+ class Mt {
2801
2801
  constructor(t, e) {
2802
- this._type = "Conditions", this._options = e, this.uuid = v(e), t.content && t.content instanceof R ? this.content = Ot(t.content) : this.content = t.content;
2802
+ this._type = "Conditions", this._options = e, this.uuid = v(e), t.content && t.content instanceof R ? this.content = Ft(t.content) : this.content = t.content;
2803
2803
  }
2804
2804
  static {
2805
2805
  this.isKlass = !0;
@@ -2820,7 +2820,7 @@ class xt {
2820
2820
  };
2821
2821
  }
2822
2822
  static create(t, e) {
2823
- const i = new xt(t, e);
2823
+ const i = new Mt(t, e);
2824
2824
  if (this.instances.find((s) => s.uuid === i.uuid))
2825
2825
  throw new Error(`duplicate uuid in options ${i.uuid}, Conditions`);
2826
2826
  return this.instances.push(i), i;
@@ -2851,7 +2851,7 @@ class xt {
2851
2851
  return this.create(e.public, e.options);
2852
2852
  }
2853
2853
  }
2854
- class Yt {
2854
+ class zt {
2855
2855
  constructor(t, e) {
2856
2856
  this._type = "DataAttributives", this._options = e, this.uuid = v(e), this.content = t.content;
2857
2857
  }
@@ -2874,7 +2874,7 @@ class Yt {
2874
2874
  };
2875
2875
  }
2876
2876
  static create(t, e) {
2877
- const i = new Yt(t, e);
2877
+ const i = new zt(t, e);
2878
2878
  if (this.instances.find((s) => s.uuid === i.uuid))
2879
2879
  throw new Error(`duplicate uuid in options ${i.uuid}, DataAttributives`);
2880
2880
  return this.instances.push(i), i;
@@ -2905,20 +2905,20 @@ class Yt {
2905
2905
  return this.create(e.public, e.options);
2906
2906
  }
2907
2907
  }
2908
- const Be = [
2908
+ const Je = [
2909
2909
  C,
2910
2910
  D,
2911
2911
  T,
2912
- Bt,
2913
2912
  Wt,
2914
- J,
2915
2913
  Jt,
2914
+ J,
2916
2915
  jt,
2917
- It,
2918
- at,
2919
2916
  Ht,
2920
- Y,
2917
+ Ct,
2918
+ at,
2921
2919
  Ut,
2920
+ Y,
2921
+ Gt,
2922
2922
  ut,
2923
2923
  dt,
2924
2924
  ht,
@@ -2926,21 +2926,21 @@ const Be = [
2926
2926
  ft,
2927
2927
  mt,
2928
2928
  yt,
2929
- Ct,
2929
+ xt,
2930
2930
  gt,
2931
- Gt,
2932
2931
  Kt,
2933
2932
  Xt,
2934
- _t,
2933
+ Yt,
2934
+ Bt,
2935
2935
  ct,
2936
2936
  lt,
2937
- xt,
2938
- Yt
2937
+ Mt,
2938
+ zt
2939
2939
  ];
2940
- Be.forEach((u) => {
2941
- u && u.displayName && De(u.displayName, u);
2940
+ Je.forEach((u) => {
2941
+ u && u.displayName && Fe(u.displayName, u);
2942
2942
  });
2943
- class zt {
2943
+ class Zt {
2944
2944
  constructor(t, e) {
2945
2945
  this._type = "Custom", this._options = e, this.uuid = v(e), this.name = t.name, this.dataDeps = t.dataDeps, this.compute = t.compute, this.incrementalCompute = t.incrementalCompute, this.incrementalPatchCompute = t.incrementalPatchCompute, this.createState = t.createState, this.getDefaultValue = t.getDefaultValue, this.asyncReturn = t.asyncReturn, this.useLastValue = t.useLastValue;
2946
2946
  }
@@ -3003,7 +3003,7 @@ class zt {
3003
3003
  };
3004
3004
  }
3005
3005
  static create(t, e) {
3006
- const i = new zt(t, e);
3006
+ const i = new Zt(t, e);
3007
3007
  if (this.instances.find((s) => s.uuid === i.uuid))
3008
3008
  throw new Error(`duplicate uuid in options ${i.uuid}, Custom`);
3009
3009
  return this.instances.push(i), i;
@@ -3047,7 +3047,7 @@ class zt {
3047
3047
  }), this.create(i, e.options);
3048
3048
  }
3049
3049
  }
3050
- class be {
3050
+ class Ne {
3051
3051
  constructor(t = [], e = []) {
3052
3052
  this.clonedEntities = /* @__PURE__ */ new Map(), this.clonedRelations = /* @__PURE__ */ new Map(), this.reverseEntityMap = /* @__PURE__ */ new Map(), this.reverseRelationMap = /* @__PURE__ */ new Map(), this.originalEntities = [...t], this.originalRelations = [...e], (t.length > 0 || e.length > 0) && this.initializeClones();
3053
3053
  }
@@ -3258,7 +3258,7 @@ class be {
3258
3258
  return null;
3259
3259
  }
3260
3260
  }
3261
- function Er({ name: u, isRef: t = !1 }, e) {
3261
+ function xr({ name: u, isRef: t = !1 }, e) {
3262
3262
  return J.create({
3263
3263
  name: u,
3264
3264
  content: u ? new Function("user", `return user.roles.includes('${u}')`) : function() {
@@ -3271,7 +3271,7 @@ function g(u, t) {
3271
3271
  if (!u)
3272
3272
  throw new Error(t);
3273
3273
  }
3274
- function $t(u, t, e) {
3274
+ function Pt(u, t, e) {
3275
3275
  const i = [...t];
3276
3276
  let r = u, s;
3277
3277
  const a = i.pop();
@@ -3415,7 +3415,7 @@ class m {
3415
3415
  const a = this.map.getRecordInfo(t);
3416
3416
  this.entityName = a.isFilteredEntity || a.isFilteredRelation ? a.baseRecordName : t;
3417
3417
  const o = a.isFilteredEntity || a.isFilteredRelation;
3418
- this.xToOneQueryTree = new q(this.entityName, this.map);
3418
+ this.xToOneQueryTree = new _(this.entityName, this.map);
3419
3419
  let n = i;
3420
3420
  o && (n = i ? a.matchExpression.and(i) : a.matchExpression), n && (this.data = this.convertFilteredRelation(n), this.buildQueryTree(this.data, this.xToOneQueryTree));
3421
3421
  }
@@ -3463,8 +3463,8 @@ class m {
3463
3463
  const n = [...a.resolvedPath, o], c = this.map.getInfoByPath(n), l = a.resolvedPath.concat(c?.isLinkFiltered() ? c.getBaseAttributeInfo().attributeName : o);
3464
3464
  let d = a.matchExpression;
3465
3465
  if (c?.isLinkFiltered()) {
3466
- const h = c.getLinkInfo(), p = new m(h.getResolvedBaseRecordName(), this.map, h.getResolvedMatchExpression()), y = this.map.getReversePath(l), b = [c.isRecordSource() ? "source" : "target", ...y.slice(2)], S = p.rebase(b.join("."));
3467
- d = d ? d.and(S) : S;
3466
+ const h = c.getLinkInfo(), p = new m(h.getResolvedBaseRecordName(), this.map, h.getResolvedMatchExpression()), y = this.map.getReversePath(l), b = [c.isRecordSource() ? "source" : "target", ...y.slice(2)], k = p.rebase(b.join("."));
3467
+ d = d ? d.and(k) : k;
3468
3468
  }
3469
3469
  return {
3470
3470
  path: [...a.path, o],
@@ -3603,7 +3603,7 @@ class m {
3603
3603
  return new m(i, this.map, a, this.contextRootEntity, this.fromRelation);
3604
3604
  }
3605
3605
  }
3606
- class We {
3606
+ class je {
3607
3607
  constructor(t, e, i, r) {
3608
3608
  this.recordName = t, this.map = e, this.data = i, this.fromRelation = r;
3609
3609
  }
@@ -3639,7 +3639,7 @@ class M {
3639
3639
  e,
3640
3640
  N,
3641
3641
  new x(h, e, i.attributeQuery || [], s, a),
3642
- new We(h, e, i.modifier),
3642
+ new je(h, e, i.modifier),
3643
3643
  r,
3644
3644
  s,
3645
3645
  a,
@@ -3678,7 +3678,7 @@ class M {
3678
3678
  );
3679
3679
  }
3680
3680
  }
3681
- class q {
3681
+ class _ {
3682
3682
  // 父节点和自己这个几点 link 上的 query
3683
3683
  constructor(t, e, i, r, s, a, o) {
3684
3684
  this.recordName = t, this.map = e, this.parentRecord = i, this.attributeName = r, this.data = s, this.parent = a, this.parentLinkQueryTree = o, this.fields = [], g(!!t, "recordName cannot be empty"), this.fields = s?.fields || [], this.records = s?.records || {}, i && (this.info = this.map.getInfo(this.parentRecord, this.attributeName));
@@ -3688,26 +3688,26 @@ class q {
3688
3688
  if (t.length === 1)
3689
3689
  this.fields.push(e);
3690
3690
  else if (e === f)
3691
- this.parentLinkQueryTree || (this.parentLinkQueryTree = new q(this.info.linkName, this.map)), this.parentLinkQueryTree.addField(i);
3691
+ this.parentLinkQueryTree || (this.parentLinkQueryTree = new _(this.info.linkName, this.map)), this.parentLinkQueryTree.addField(i);
3692
3692
  else {
3693
3693
  const r = this.map.getInfo(this.recordName, e);
3694
- this.records[e] || (this.records[e] = new q(r.recordName, this.map, this.recordName, e, void 0, this)), this.records[e].addField(i);
3694
+ this.records[e] || (this.records[e] = new _(r.recordName, this.map, this.recordName, e, void 0, this)), this.records[e].addField(i);
3695
3695
  }
3696
3696
  }
3697
3697
  addRecord(t, e) {
3698
3698
  const [i, ...r] = t;
3699
3699
  if (t.length === 1)
3700
3700
  if (i === f)
3701
- this.parentLinkQueryTree || (this.parentLinkQueryTree = new q(this.info.linkName, this.map)), e && (this.parentLinkQueryTree = this.parentLinkQueryTree.merge(e));
3701
+ this.parentLinkQueryTree || (this.parentLinkQueryTree = new _(this.info.linkName, this.map)), e && (this.parentLinkQueryTree = this.parentLinkQueryTree.merge(e));
3702
3702
  else {
3703
- const s = this.map.getInfo(this.recordName, i), a = e || new q(s.recordName, this.map, this.recordName, i, void 0, this);
3703
+ const s = this.map.getInfo(this.recordName, i), a = e || new _(s.recordName, this.map, this.recordName, i, void 0, this);
3704
3704
  this.records[i] = this.records[i] ? this.records[i].merge(a) : a;
3705
3705
  }
3706
3706
  else if (i === f)
3707
- this.parentLinkQueryTree || (this.parentLinkQueryTree = new q(this.info.linkName, this.map)), this.parentLinkQueryTree.addRecord(r, e);
3707
+ this.parentLinkQueryTree || (this.parentLinkQueryTree = new _(this.info.linkName, this.map)), this.parentLinkQueryTree.addRecord(r, e);
3708
3708
  else {
3709
3709
  const s = this.map.getInfo(this.recordName, i);
3710
- this.records[i] = new q(s.recordName, this.map, this.recordName, i, void 0, this), this.records[i].addRecord(r, e);
3710
+ this.records[i] = new _(s.recordName, this.map, this.recordName, i, void 0, this), this.records[i].addRecord(r, e);
3711
3711
  }
3712
3712
  }
3713
3713
  forEachRecords(t) {
@@ -3722,7 +3722,7 @@ class q {
3722
3722
  this.records[a] && t.records[a] ? r[a] = this.records[a].merge(t.records[a]) : this.records[a] ? r[a] = this.records[a] : r[a] = t.records[a];
3723
3723
  });
3724
3724
  let s;
3725
- return this.parentLinkQueryTree && t.parentLinkQueryTree ? s = this.parentLinkQueryTree.merge(t.parentLinkQueryTree) : s = this.parentLinkQueryTree || t.parentLinkQueryTree, new q(this.recordName, this.map, this.parentRecord, this.attributeName, { fields: e, records: r }, this.parent, s);
3725
+ return this.parentLinkQueryTree && t.parentLinkQueryTree ? s = this.parentLinkQueryTree.merge(t.parentLinkQueryTree) : s = this.parentLinkQueryTree || t.parentLinkQueryTree, new _(this.recordName, this.map, this.parentRecord, this.attributeName, { fields: e, records: r }, this.parent, s);
3726
3726
  }
3727
3727
  getData() {
3728
3728
  const t = {
@@ -3733,7 +3733,7 @@ class q {
3733
3733
  }), this.parentLinkQueryTree && (t[f] = this.parentLinkQueryTree.getData()), t;
3734
3734
  }
3735
3735
  }
3736
- const f = "&", Je = "*";
3736
+ const f = "&", He = "*";
3737
3737
  class x {
3738
3738
  constructor(t, e, i = [], r, s, a) {
3739
3739
  this.recordName = t, this.map = e, this.data = i, this.parentRecord = r, this.attributeName = s, this.shouldQueryParentLinkData = a, this.relatedRecords = [], this.xToManyRecords = [], this.xToOneRecords = [], this.valueAttributes = [], this.id = Math.random();
@@ -3746,7 +3746,7 @@ class x {
3746
3746
  this.parentLinkRecordQuery = M.create(y.linkName, this.map, d, void 0);
3747
3747
  return;
3748
3748
  }
3749
- if (l === Je) {
3749
+ if (l === He) {
3750
3750
  o = new Set(this.map.getRecordInfo(this.recordName).valueAttributes.map((y) => y.attributeName));
3751
3751
  return;
3752
3752
  }
@@ -3755,10 +3755,10 @@ class x {
3755
3755
  let y = l, N = d;
3756
3756
  if (p.isLinkFiltered()) {
3757
3757
  y = p.getBaseAttributeInfo().attributeName;
3758
- const S = d.matchExpression, F = p.getLinkInfo().getBaseLinkInfo(), re = new m(F.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), Ee = S ? re.and(S.data) : re;
3758
+ const k = d.matchExpression, F = p.getLinkInfo().getBaseLinkInfo(), se = new m(F.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), xe = k ? se.and(k.data) : se;
3759
3759
  N = {
3760
3760
  ...d,
3761
- matchExpression: Ee.data
3761
+ matchExpression: xe.data
3762
3762
  };
3763
3763
  }
3764
3764
  const b = M.create(p.recordName, this.map, N, void 0, this.recordName, y, h, !1, l);
@@ -3855,7 +3855,7 @@ class x {
3855
3855
  return this.buildXToOneQueryTree();
3856
3856
  }
3857
3857
  buildXToOneQueryTree() {
3858
- const t = new q(this.recordName, this.map, this.parentRecord, this.attributeName);
3858
+ const t = new _(this.recordName, this.map, this.parentRecord, this.attributeName);
3859
3859
  if (this.data.forEach((e) => {
3860
3860
  Array.isArray(e) || t.addField([e]);
3861
3861
  }), this.xToOneRecords.forEach((e) => {
@@ -3867,7 +3867,7 @@ class x {
3867
3867
  return t;
3868
3868
  }
3869
3869
  buildFullQueryTree() {
3870
- const t = new q(this.recordName, this.map, this.parentRecord, this.attributeName);
3870
+ const t = new _(this.recordName, this.map, this.parentRecord, this.attributeName);
3871
3871
  return this.relatedRecords.forEach((e) => {
3872
3872
  t.addRecord([e.attributeName], e.attributeQuery.fullQueryTree);
3873
3873
  }), t;
@@ -3876,7 +3876,7 @@ class x {
3876
3876
  return this.parentLinkRecordQuery ? new x(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
3877
3877
  }
3878
3878
  }
3879
- function je(u) {
3879
+ function Ue(u) {
3880
3880
  const t = [];
3881
3881
  return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
3882
3882
  }
@@ -3886,7 +3886,7 @@ class L {
3886
3886
  const s = this.map.getRecordInfo(e);
3887
3887
  this.recordName = s.isFilteredEntity || s.isFilteredRelation ? s.resolvedBaseRecordName : e;
3888
3888
  const [a, o, n] = this.map.groupAttributes(this.recordName, i ? Object.keys(i) : []);
3889
- this.relatedEntitiesData = je(o.map(
3889
+ this.relatedEntitiesData = Ue(o.map(
3890
3890
  (l) => Array.isArray(i[l.attributeName]) ? i[l.attributeName].map((d) => new L(this.map, l.recordName, d, l)) : new L(this.map, l.recordName, i[l.attributeName], l)
3891
3891
  )), this.valueAttributes = a, this.entityIdAttributes = n;
3892
3892
  const c = this.map.getRecordInfo(this.recordName);
@@ -3963,7 +3963,7 @@ class L {
3963
3963
  }), i;
3964
3964
  }
3965
3965
  }
3966
- class He {
3966
+ class Ge {
3967
3967
  constructor(t, e) {
3968
3968
  this.map = t, this.queryAgent = e, this.dependencies = /* @__PURE__ */ new Map();
3969
3969
  }
@@ -4189,7 +4189,7 @@ class He {
4189
4189
  }
4190
4190
  }
4191
4191
  }
4192
- class Ue {
4192
+ class Ke {
4193
4193
  constructor() {
4194
4194
  this.aliasToPath = /* @__PURE__ */ new Map(), this.pathStrToAlias = /* @__PURE__ */ new Map(), this.aliasPlaceholder = 0;
4195
4195
  }
@@ -4203,7 +4203,7 @@ class Ue {
4203
4203
  return this.aliasToPath.get(t);
4204
4204
  }
4205
4205
  }
4206
- const Re = ":root";
4206
+ const Te = ":root";
4207
4207
  class St {
4208
4208
  constructor(t, e, i = []) {
4209
4209
  this.label = t, this.parent = e, this.stack = i;
@@ -4218,9 +4218,9 @@ class St {
4218
4218
  return new St(t, this);
4219
4219
  }
4220
4220
  }
4221
- class Ge {
4221
+ class Xe {
4222
4222
  constructor(t) {
4223
- this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Re, t), this.recursiveSaveLabelledRecordQuery(t);
4223
+ this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Te, t), this.recursiveSaveLabelledRecordQuery(t);
4224
4224
  }
4225
4225
  recursiveSaveLabelledRecordQuery(t) {
4226
4226
  t.attributeQuery?.relatedRecords.forEach((e) => {
@@ -4234,9 +4234,9 @@ class Ge {
4234
4234
  return this.recordQueryByName.get(t);
4235
4235
  }
4236
4236
  }
4237
- class Ke {
4237
+ class Ye {
4238
4238
  constructor(t, e) {
4239
- this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new He(t, this), this.initializeFilteredEntityDependencies();
4239
+ this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new Ge(t, this), this.initializeFilteredEntityDependencies();
4240
4240
  }
4241
4241
  /**
4242
4242
  * 初始化所有 filtered entity 的依赖关系
@@ -4288,15 +4288,15 @@ ${b}
4288
4288
  const s = {};
4289
4289
  return Object.entries(r).forEach(([a, o]) => {
4290
4290
  const n = i.getPath(a).slice(1, 1 / 0);
4291
- n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && $t(s, n, o);
4291
+ n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && Pt(s, n, o);
4292
4292
  }), s;
4293
4293
  });
4294
4294
  }
4295
4295
  // 查 entity 和 查 relation 都是一样的。具体在 entityQuery 里面区别。
4296
4296
  // TODO 为了性能,也可以把信息丢到客户端,然客户端去结构化???
4297
4297
  // CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
4298
- async findRecords(t, e = "", i, r = new St(Re)) {
4299
- if (i || (i = new Ge(t)), t.goto) {
4298
+ async findRecords(t, e = "", i, r = new St(Te)) {
4299
+ if (i || (i = new Xe(t)), t.goto) {
4300
4300
  if (t.exit && await t.exit(r))
4301
4301
  return [];
4302
4302
  const l = i.get(t.goto);
@@ -4329,17 +4329,17 @@ ${b}
4329
4329
  for (let h of d.attributeQuery.xToManyRecords) {
4330
4330
  const y = this.map.getInfo(h.parentRecord, h.attributeName).getReverseInfo()?.attributeName;
4331
4331
  for (let N of n) {
4332
- const b = N[l.attributeName][f].id, S = h.derive({
4332
+ const b = N[l.attributeName][f].id, k = h.derive({
4333
4333
  matchExpression: h.matchExpression.and({
4334
4334
  key: `${y}.id`,
4335
4335
  value: ["=", b]
4336
4336
  })
4337
4337
  }), F = t.label ? c.concat(N) : c;
4338
- $t(
4338
+ Pt(
4339
4339
  N,
4340
4340
  [l.alias || l.attributeName, f, h.attributeName],
4341
4341
  await this.findRecords(
4342
- S,
4342
+ k,
4343
4343
  `finding relation data: ${t.recordName}.${l.attributeName}.&.${h.attributeName}`,
4344
4344
  i,
4345
4345
  F
@@ -4410,21 +4410,21 @@ ${b}
4410
4410
  matchExpression: c,
4411
4411
  attributeQuery: l
4412
4412
  }), h = await this.findRecords(d, `finding related record: ${r.parentRecord}.${r.attributeName}`, s, a), p = r.attributeQuery.parentLinkRecordQuery ? h.map((b) => {
4413
- let S;
4414
- return o.isLinkManyToManySymmetric() ? (S = {
4413
+ let k;
4414
+ return o.isLinkManyToManySymmetric() ? (k = {
4415
4415
  ...b,
4416
4416
  [f]: b[`${n}:source`]?.[f]?.id ? b[`${n}:source`]?.[f] : b[`${n}:target`]?.[f]
4417
- }, delete S[`${n}:source`], delete S[`${n}:target`]) : (S = {
4417
+ }, delete k[`${n}:source`], delete k[`${n}:target`]) : (k = {
4418
4418
  ...b,
4419
4419
  [f]: b[n][f]
4420
- }, delete S[n]), S;
4420
+ }, delete k[n]), k;
4421
4421
  }) : h, y = d.label && d.label !== a.label ? a.spawn(d.label) : a, N = r.attributeQuery.parentLinkRecordQuery;
4422
4422
  if (N)
4423
4423
  for (let b of N.attributeQuery.xToManyRecords)
4424
- for (let S of p) {
4425
- const F = S[f].id, ie = d.label ? y.concat(S) : y;
4426
- $t(
4427
- S,
4424
+ for (let k of p) {
4425
+ const F = k[f].id, re = d.label ? y.concat(k) : y;
4426
+ Pt(
4427
+ k,
4428
4428
  [f, b.attributeName],
4429
4429
  await this.findXToManyRelatedRecords(
4430
4430
  b.parentRecord,
@@ -4432,7 +4432,7 @@ ${b}
4432
4432
  F,
4433
4433
  b,
4434
4434
  s,
4435
- ie
4435
+ re
4436
4436
  )
4437
4437
  );
4438
4438
  }
@@ -4474,23 +4474,23 @@ ${b}
4474
4474
  joinTarget: [d, h]
4475
4475
  });
4476
4476
  } else {
4477
- const b = c.getLinkInfo(), S = c.isLinkManyToManySymmetric() ? c.symmetricDirection === "source" : b.isRelationSource(c.parentEntityName, c.attributeName);
4477
+ const b = c.getLinkInfo(), k = c.isLinkManyToManySymmetric() ? c.symmetricDirection === "source" : b.isRelationSource(c.parentEntityName, c.attributeName);
4478
4478
  r.push({
4479
4479
  for: l,
4480
4480
  joinSource: a,
4481
4481
  // CAUTION sourceField 是用在合并了情况里面的,指的是 target 在 source 里面的名字!所以这里不能用
4482
- joinIdField: [s, S ? b.record.attributes.source.field : b.record.attributes.target.field],
4482
+ joinIdField: [s, k ? b.record.attributes.source.field : b.record.attributes.target.field],
4483
4483
  joinTarget: [p, y]
4484
4484
  }), o.onlyIdField() || r.push({
4485
4485
  for: l,
4486
4486
  joinSource: [p, y],
4487
- joinIdField: [S ? b.record.attributes.target.field : b.record.attributes.source.field, N],
4487
+ joinIdField: [k ? b.record.attributes.target.field : b.record.attributes.source.field, N],
4488
4488
  joinTarget: [d, h]
4489
4489
  });
4490
4490
  }
4491
4491
  if (r.push(...this.getJoinTables(o, l, [N, d, h])), o.parentLinkQueryTree, o.parentLinkQueryTree && !o.parentLinkQueryTree.onlyIdField()) {
4492
- const b = l.concat(f), [, S] = this.map.getTableAliasAndFieldName(b, "id", !0), F = [
4493
- S,
4492
+ const b = l.concat(f), [, k] = this.map.getTableAliasAndFieldName(b, "id", !0), F = [
4493
+ k,
4494
4494
  // link 的 idField
4495
4495
  p,
4496
4496
  // link 的 tableName
@@ -4505,7 +4505,7 @@ ${b}
4505
4505
  return t ? `${t}___` : "";
4506
4506
  }
4507
4507
  buildSelectClause(t, e = "") {
4508
- const i = new Ue();
4508
+ const i = new Ke();
4509
4509
  return t.length ? [t.map(({ tableAliasAndField: s, attribute: a, nameContext: o }) => {
4510
4510
  const n = [
4511
4511
  `${this.withPrefix(e)}${o[0]}`,
@@ -5077,9 +5077,9 @@ WHERE "${s.idField}" = ${l()}
5077
5077
  return p ? [N, ...p] : void 0;
5078
5078
  }
5079
5079
  }
5080
- class Xe {
5080
+ class ze {
5081
5081
  constructor(t, e) {
5082
- this.map = t, this.database = e, this.agent = new Ke(t, e);
5082
+ this.map = t, this.database = e, this.agent = new Ye(t, e);
5083
5083
  }
5084
5084
  async findOne(t, e, i = {}, r) {
5085
5085
  const s = {
@@ -5340,7 +5340,7 @@ class kt {
5340
5340
  return g(this.isFilteredRelation(), "only filtered relation can get resolved record name"), this.data.resolvedBaseRecordName;
5341
5341
  }
5342
5342
  }
5343
- class Ye {
5343
+ class Ze {
5344
5344
  constructor(t) {
5345
5345
  this.data = t;
5346
5346
  }
@@ -5411,14 +5411,14 @@ class Ye {
5411
5411
  for (let h = 0; h < i.length; h++) {
5412
5412
  const [p, y] = this.getAttributeAndSymmetricDirection(i[h]), N = [e, ...i.slice(0, h + 1)];
5413
5413
  if (p === f) {
5414
- const { linkTable: b, linkAlias: S, path: F } = d.pop();
5415
- g(!c, `last attribute in path is a link, cannot read link of a link ${F.join(".")}`), s = b, a = S, r = this.data.records[l.linkName], c = !0, o = "", n = "", l = void 0;
5414
+ const { linkTable: b, linkAlias: k, path: F } = d.pop();
5415
+ g(!c, `last attribute in path is a link, cannot read link of a link ${F.join(".")}`), s = b, a = k, r = this.data.records[l.linkName], c = !0, o = "", n = "", l = void 0;
5416
5416
  } else {
5417
5417
  l = this.getInfoByPath(N);
5418
5418
  const b = r.attributes[p];
5419
5419
  g(l.isRecord, `${i.slice(0, h + 1).join(".")} is not a entity attribute`);
5420
- const S = this.data.records[b.recordName], F = `${a}_${p}${y ? `_${y.toUpperCase()}` : ""}`;
5421
- l.isMergedWithParent() || l.isLinkMergedWithParent() ? n = a : l.isLinkIsolated() ? n = `REL_${F}` : n = F, l.isMergedWithParent() || (a = F), s = l.table, r = S, o = l.getLinkInfo()?.table, c = !1;
5420
+ const k = this.data.records[b.recordName], F = `${a}_${p}${y ? `_${y.toUpperCase()}` : ""}`;
5421
+ l.isMergedWithParent() || l.isLinkMergedWithParent() ? n = a : l.isLinkIsolated() ? n = `REL_${F}` : n = F, l.isMergedWithParent() || (a = F), s = l.table, r = k, o = l.getLinkInfo()?.table, c = !1;
5422
5422
  }
5423
5423
  d.push({
5424
5424
  table: s,
@@ -5536,7 +5536,7 @@ class Ye {
5536
5536
  return r.join(".");
5537
5537
  }
5538
5538
  }
5539
- function ze(u) {
5539
+ function ti(u) {
5540
5540
  const t = /* @__PURE__ */ new Map();
5541
5541
  for (const e of u)
5542
5542
  if (e.inputEntities)
@@ -5547,7 +5547,7 @@ function ze(u) {
5547
5547
  }
5548
5548
  return t;
5549
5549
  }
5550
- function Ze(u) {
5550
+ function ei(u) {
5551
5551
  const t = /* @__PURE__ */ new Map();
5552
5552
  for (const e of u) {
5553
5553
  const i = e.name || `${e.source.name}_${e.sourceProperty}_${e.targetProperty}_${e.target.name}`;
@@ -5561,36 +5561,36 @@ function Ze(u) {
5561
5561
  }
5562
5562
  return t;
5563
5563
  }
5564
- function ti(u, t) {
5565
- const e = new be(u, t), i = ze(u), r = Ze(t);
5566
- return ae(
5564
+ function ii(u, t) {
5565
+ const e = new Ne(u, t), i = ti(u), r = ei(t);
5566
+ return oe(
5567
5567
  u,
5568
5568
  e,
5569
5569
  i,
5570
5570
  "entity"
5571
- ), ae(
5571
+ ), oe(
5572
5572
  t,
5573
5573
  e,
5574
5574
  r,
5575
5575
  "relation"
5576
5576
  ), e.getAll();
5577
5577
  }
5578
- function ae(u, t, e, i) {
5578
+ function oe(u, t, e, i) {
5579
5579
  const r = u.filter((s) => {
5580
5580
  const a = Rt(s);
5581
5581
  return a && a.length > 0;
5582
5582
  });
5583
5583
  if (r.length !== 0)
5584
5584
  for (const s of r)
5585
- ei(
5585
+ ri(
5586
5586
  s,
5587
5587
  t,
5588
5588
  i,
5589
5589
  e
5590
5590
  );
5591
5591
  }
5592
- function ei(u, t, e, i) {
5593
- const r = e === "entity", a = `__${z(u)}_input_${e}`, o = r ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = oi(
5592
+ function ri(u, t, e, i) {
5593
+ const r = e === "entity", a = `__${z(u)}_input_${e}`, o = r ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = ci(
5594
5594
  o,
5595
5595
  a,
5596
5596
  i,
@@ -5600,7 +5600,7 @@ function ei(u, t, e, i) {
5600
5600
  const l = Rt(u);
5601
5601
  if (l)
5602
5602
  for (const d of l)
5603
- ii(
5603
+ si(
5604
5604
  d,
5605
5605
  c,
5606
5606
  a,
@@ -5608,8 +5608,8 @@ function ei(u, t, e, i) {
5608
5608
  r
5609
5609
  );
5610
5610
  }
5611
- function ii(u, t, e, i, r) {
5612
- const [s, a] = ni(
5611
+ function si(u, t, e, i, r) {
5612
+ const [s, a] = li(
5613
5613
  u,
5614
5614
  t,
5615
5615
  e
@@ -5619,7 +5619,7 @@ function ii(u, t, e, i, r) {
5619
5619
  const o = z(a), n = r ? i.getEntityByName(o) : i.getRelationByName(o);
5620
5620
  n && i.replace(s, n);
5621
5621
  }
5622
- function ri(u, t) {
5622
+ function ai(u, t) {
5623
5623
  const e = /* @__PURE__ */ new Map(), i = Rt(u);
5624
5624
  if (i && i.length > 0)
5625
5625
  for (const r of i) {
@@ -5633,8 +5633,8 @@ function ri(u, t) {
5633
5633
  }
5634
5634
  return e;
5635
5635
  }
5636
- function si(u, t, e) {
5637
- const i = ri(t, e);
5636
+ function oi(u, t, e) {
5637
+ const i = ai(t, e);
5638
5638
  return T.create({
5639
5639
  name: u,
5640
5640
  type: "json",
@@ -5646,14 +5646,14 @@ function si(u, t, e) {
5646
5646
  }
5647
5647
  });
5648
5648
  }
5649
- function ai(u, t, e) {
5649
+ function ni(u, t, e) {
5650
5650
  const i = Rt(u), r = [], s = /* @__PURE__ */ new Map(), a = {};
5651
5651
  for (const o of i) {
5652
5652
  let n = o;
5653
5653
  if (bt(n))
5654
5654
  for (; n.baseEntity && n.properties.length === 0; )
5655
5655
  n = n.baseEntity;
5656
- else if (li(n))
5656
+ else if (di(n))
5657
5657
  for (; n.baseRelation && n.properties.length === 0; )
5658
5658
  n = n.baseRelation;
5659
5659
  const c = Object.fromEntries(n.properties.map((h) => [h.name, h]));
@@ -5683,13 +5683,13 @@ function ai(u, t, e) {
5683
5683
  }
5684
5684
  return r;
5685
5685
  }
5686
- function oi(u, t, e, i) {
5687
- const r = si(
5686
+ function ci(u, t, e, i) {
5687
+ const r = oi(
5688
5688
  t,
5689
5689
  u,
5690
5690
  e
5691
5691
  ), s = [
5692
- ...ai(
5692
+ ...ni(
5693
5693
  u,
5694
5694
  e,
5695
5695
  i
@@ -5747,7 +5747,7 @@ function oi(u, t, e, i) {
5747
5747
  return [o, n || o];
5748
5748
  }
5749
5749
  }
5750
- function ni(u, t, e) {
5750
+ function li(u, t, e) {
5751
5751
  if (bt(u)) {
5752
5752
  const i = u, r = t;
5753
5753
  let s = i;
@@ -5761,7 +5761,7 @@ function ni(u, t, e) {
5761
5761
  }), [a, s];
5762
5762
  } else {
5763
5763
  const i = u, r = t, s = z(i);
5764
- return i.baseRelation ? [i, ci(i)] : [D.create({
5764
+ return i.baseRelation ? [i, ui(i)] : [D.create({
5765
5765
  name: s,
5766
5766
  baseRelation: r,
5767
5767
  sourceProperty: i.sourceProperty,
@@ -5773,7 +5773,7 @@ function ni(u, t, e) {
5773
5773
  }), i];
5774
5774
  }
5775
5775
  }
5776
- function ci(u) {
5776
+ function ui(u) {
5777
5777
  let t = u;
5778
5778
  for (; t.baseRelation; )
5779
5779
  t = t.baseRelation;
@@ -5782,7 +5782,7 @@ function ci(u) {
5782
5782
  function bt(u) {
5783
5783
  return "inputEntities" in u || !("sourceProperty" in u);
5784
5784
  }
5785
- function li(u) {
5785
+ function di(u) {
5786
5786
  return "sourceProperty" in u;
5787
5787
  }
5788
5788
  function Rt(u) {
@@ -5791,7 +5791,7 @@ function Rt(u) {
5791
5791
  function z(u) {
5792
5792
  return bt(u), u.name;
5793
5793
  }
5794
- class ui {
5794
+ class hi {
5795
5795
  constructor(t, e, i, r = []) {
5796
5796
  this.entities = t, this.relations = e, this.database = i, this.mergeLinks = r, this.fieldNameMap = /* @__PURE__ */ new Map(), this.usedFieldNames = /* @__PURE__ */ new Set(), this.fieldCounter = 1, this.recordToTableMap = /* @__PURE__ */ new Map(), this.tableToRecordsMap = /* @__PURE__ */ new Map(), this.mergeLog = [], this.tables = {}, this.map = { links: {}, records: {} }, this.buildMap(), this.buildTables();
5797
5797
  }
@@ -6070,7 +6070,7 @@ class ui {
6070
6070
  * 统一处理 merged entities 和 merged relations
6071
6071
  */
6072
6072
  processMergedItems() {
6073
- const t = ti(
6073
+ const t = ii(
6074
6074
  this.entities,
6075
6075
  this.relations
6076
6076
  );
@@ -6087,9 +6087,9 @@ class ui {
6087
6087
  p[0] === "1" && p[1] === "1" && y !== N,
6088
6088
  `only 1:1 can merge: ${s}.${a.slice(0, n + 1).join(".")}`
6089
6089
  );
6090
- const b = y === o ? N : y, S = this.combineRecordTable(o, b, d);
6091
- if (S)
6092
- throw new Error(`conflict found when join ${d}, ${S.join(",")} already merged with ${o}`);
6090
+ const b = y === o ? N : y, k = this.combineRecordTable(o, b, d);
6091
+ if (k)
6092
+ throw new Error(`conflict found when join ${d}, ${k.join(",")} already merged with ${o}`);
6093
6093
  h.mergedTo = "combined", i.push(h), o = l.recordName, delete t[d], delete e[d];
6094
6094
  }
6095
6095
  }), Object.values(t).forEach((r) => {
@@ -6189,28 +6189,28 @@ class A {
6189
6189
  this.skip = () => new At();
6190
6190
  }
6191
6191
  static {
6192
- this.resolved = (t, e) => new Te(t, e);
6192
+ this.resolved = (t, e) => new ke(t, e);
6193
6193
  }
6194
6194
  static {
6195
- this.async = (t) => new Ne(t);
6195
+ this.async = (t) => new Se(t);
6196
6196
  }
6197
6197
  static {
6198
- this.fullRecompute = (t) => new we(t);
6198
+ this.fullRecompute = (t) => new ve(t);
6199
6199
  }
6200
6200
  }
6201
6201
  class At extends A {
6202
6202
  }
6203
- class we extends A {
6203
+ class ve extends A {
6204
6204
  constructor(t) {
6205
6205
  super(), this.reason = t;
6206
6206
  }
6207
6207
  }
6208
- class Ne extends A {
6208
+ class Se extends A {
6209
6209
  constructor(t) {
6210
6210
  super(), this.args = t;
6211
6211
  }
6212
6212
  }
6213
- class Te extends A {
6213
+ class ke extends A {
6214
6214
  constructor(t, e) {
6215
6215
  super(), this.result = t, this.args = e;
6216
6216
  }
@@ -6241,18 +6241,18 @@ class B {
6241
6241
  return await this.controller.system.storage.dict.get(this.key);
6242
6242
  }
6243
6243
  }
6244
- function Ft(u, t) {
6244
+ function Qt(u, t) {
6245
6245
  if (t == null || u === t) return !0;
6246
6246
  if (typeof t != "object" || t === null)
6247
6247
  return u === t;
6248
6248
  if (typeof u != "object" || u === null)
6249
6249
  return !1;
6250
6250
  for (const e in t)
6251
- if (!(e in u) || !Ft(u[e], t[e]))
6251
+ if (!(e in u) || !Qt(u[e], t[e]))
6252
6252
  return !1;
6253
6253
  return !0;
6254
6254
  }
6255
- class ve {
6255
+ class Ae {
6256
6256
  constructor(t) {
6257
6257
  this.data = t, this.map = {};
6258
6258
  for (const e of t.transfers)
@@ -6265,45 +6265,45 @@ class ve {
6265
6265
  const i = this.map[t];
6266
6266
  if (i) {
6267
6267
  for (const r of i)
6268
- if (Ft(e, r.trigger))
6268
+ if (Qt(e, r.trigger))
6269
6269
  return r.next;
6270
6270
  }
6271
6271
  return null;
6272
6272
  }
6273
6273
  findTransfers(t) {
6274
- return this.data.transfers.filter((e) => Ft(t, e.trigger));
6274
+ return this.data.transfers.filter((e) => Qt(t, e.trigger));
6275
6275
  }
6276
6276
  }
6277
- function k(u, t) {
6277
+ function S(u, t) {
6278
6278
  if (!u)
6279
6279
  throw new Error(t);
6280
6280
  }
6281
- function Ir(u, t) {
6281
+ function Mr(u, t) {
6282
6282
  return new Map(Array.from(u.entries()).map(([e, i]) => [e, t(e, i)]));
6283
6283
  }
6284
- function Cr(u, t) {
6284
+ function $r(u, t) {
6285
6285
  return Object.fromEntries(Object.entries(u).map(([e, i]) => [e, t(e, i)]));
6286
6286
  }
6287
- async function xr(u, t) {
6287
+ async function Pr(u, t) {
6288
6288
  for (let e of u)
6289
6289
  if (!await t(e)) return !1;
6290
6290
  return !0;
6291
6291
  }
6292
- async function di(u, t) {
6292
+ async function pi(u, t) {
6293
6293
  for (let e of u)
6294
6294
  if (await t(e)) return !0;
6295
6295
  return !1;
6296
6296
  }
6297
- async function oe(u, t) {
6297
+ async function ne(u, t) {
6298
6298
  for (let e of u) {
6299
6299
  const i = await t(e);
6300
6300
  if (i !== !0) return i;
6301
6301
  }
6302
6302
  return !0;
6303
6303
  }
6304
- class hi {
6304
+ class fi {
6305
6305
  constructor(t, e, i) {
6306
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new ve(this.args), this.defaultState = this.args.defaultState;
6306
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ae(this.args), this.defaultState = this.args.defaultState;
6307
6307
  for (const r of this.args.transfers) {
6308
6308
  const s = `${r.trigger.recordName}_${r.trigger.type}`;
6309
6309
  this.eventDeps[s] = {
@@ -6332,9 +6332,9 @@ class hi {
6332
6332
  return s ? (await this.state.currentState.set(s.name), s.computeValue ? await s.computeValue.call(this.controller, t, e) : s.name) : A.skip();
6333
6333
  }
6334
6334
  }
6335
- class pi {
6335
+ class mi {
6336
6336
  constructor(t, e, i) {
6337
- this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new ve(this.args), this.defaultState = this.args.defaultState, this.dataContext = i;
6337
+ this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ae(this.args), this.defaultState = this.args.defaultState, this.dataContext = i;
6338
6338
  for (const r of this.args.transfers) {
6339
6339
  const s = `${r.trigger.recordName}_${r.trigger.type}`;
6340
6340
  this.eventDeps[s] = {
@@ -6357,7 +6357,7 @@ class pi {
6357
6357
  // 这里的 defaultValue 不能是 async 的模式。因为是直接创建时填入的。
6358
6358
  getDefaultValue(t) {
6359
6359
  const e = t[this.dataContext.id.name];
6360
- return k(
6360
+ return S(
6361
6361
  !(e !== void 0 && !this.defaultState.computeValue),
6362
6362
  `${this.dataContext.host.name}.${this.dataContext.id.name} have been set when ${this.dataContext.host.name} created,
6363
6363
  if you want to save the use the initial value, you need to define computeValue in defaultState to save it.
@@ -6374,17 +6374,17 @@ Or if you want to use state name as value, you should not set ${this.dataContext
6374
6374
  return s ? (await this.state.currentState.set(i, s.name), s.computeValue ? await s.computeValue.call(this.controller, t, e) : s.name) : A.skip();
6375
6375
  }
6376
6376
  }
6377
- const Mr = Y.create({
6377
+ const Dr = Y.create({
6378
6378
  name: "nonExistent",
6379
6379
  computeValue: () => null
6380
- }), $r = Y.create({
6380
+ }), Or = Y.create({
6381
6381
  name: "nonDeleted",
6382
6382
  computeValue: () => !1
6383
- }), Pr = Y.create({
6383
+ }), Fr = Y.create({
6384
6384
  name: "deleted",
6385
6385
  computeValue: () => !0
6386
- }), fi = [hi, pi];
6387
- class mi {
6386
+ }), yi = [fi, mi];
6387
+ class gi {
6388
6388
  constructor(t, e, i) {
6389
6389
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.record = this.args.record, this.dataDeps = {
6390
6390
  main: {
@@ -6437,9 +6437,9 @@ class mi {
6437
6437
  return i;
6438
6438
  }
6439
6439
  }
6440
- class yi {
6440
+ class bi {
6441
6441
  constructor(t, e, i) {
6442
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), k(this.relation, "weighted summation computation must specify property"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, k(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "weighted summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6442
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), S(this.relation, "weighted summation computation must specify property"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, S(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "weighted summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6443
6443
  const r = this.args.attributeQuery || [];
6444
6444
  this.relatedAttributeQuery = this.args.attributeQuery?.filter((a) => a[0] !== f) || [];
6445
6445
  const s = (r.find((a) => a[0] === f) || [])[1]?.attributeQuery;
@@ -6513,8 +6513,8 @@ class yi {
6513
6513
  return s;
6514
6514
  }
6515
6515
  }
6516
- const gi = [mi, yi];
6517
- class bi {
6516
+ const Ri = [gi, bi];
6517
+ class wi {
6518
6518
  constructor(t, e, i) {
6519
6519
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.dataDeps = {
6520
6520
  main: {
@@ -6567,9 +6567,9 @@ class bi {
6567
6567
  return a === s;
6568
6568
  }
6569
6569
  }
6570
- class Ri {
6570
+ class Ni {
6571
6571
  constructor(t, e, i) {
6572
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, k(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "every computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6572
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, S(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "every computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6573
6573
  const r = this.args.attributeQuery || [];
6574
6574
  this.relatedAttributeQuery = this.args.attributeQuery?.filter((a) => a[0] !== f) || [];
6575
6575
  const s = (r.find((a) => a[0] === f) || [])[1]?.attributeQuery;
@@ -6641,8 +6641,8 @@ class Ri {
6641
6641
  return a === o;
6642
6642
  }
6643
6643
  }
6644
- const wi = [bi, Ri];
6645
- class Ni {
6644
+ const Ti = [wi, Ni];
6645
+ class vi {
6646
6646
  constructor(t, e, i) {
6647
6647
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.dataDeps = {
6648
6648
  main: {
@@ -6695,14 +6695,14 @@ class Ni {
6695
6695
  return s > 0;
6696
6696
  }
6697
6697
  }
6698
- class Ti {
6698
+ class Si {
6699
6699
  constructor(t, e, i) {
6700
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((n) => n.source === i.host && n.sourceProperty === this.args.property || n.target === i.host && n.targetProperty === this.args.property), k(this.relation, `cannot find relation for property ${this.args.property} in "Any" computation`), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, k(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "any computation relation direction error");
6700
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((n) => n.source === i.host && n.sourceProperty === this.args.property || n.target === i.host && n.targetProperty === this.args.property), S(this.relation, `cannot find relation for property ${this.args.property} in "Any" computation`), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, S(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "any computation relation direction error");
6701
6701
  let r = this.relation.baseRelation || this.relation;
6702
6702
  for (; r.baseRelation; )
6703
6703
  r = r.baseRelation;
6704
6704
  const s = r.type.split(":");
6705
- k(s[this.isSource ? 1 : 0] === "n", `property-level Any computation argument must be an x:n relation. ${this.dataContext.host.name}.${this.args.property}" is a ${this.isSource ? s.join(":") : s.slice().reverse().join(":")} relation`), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6705
+ S(s[this.isSource ? 1 : 0] === "n", `property-level Any computation argument must be an x:n relation. ${this.dataContext.host.name}.${this.args.property}" is a ${this.isSource ? s.join(":") : s.slice().reverse().join(":")} relation`), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6706
6706
  const a = this.args.attributeQuery || [];
6707
6707
  this.relatedAttributeQuery = this.args.attributeQuery?.filter((n) => n[0] !== f) || [];
6708
6708
  const o = (a.find((n) => n[0] === f) || [])[1]?.attributeQuery;
@@ -6771,8 +6771,8 @@ class Ti {
6771
6771
  return s > 0;
6772
6772
  }
6773
6773
  }
6774
- const vi = [Ni, Ti];
6775
- class Si {
6774
+ const ki = [vi, Si];
6775
+ class Ai {
6776
6776
  constructor(t, e, i) {
6777
6777
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, this.callback = this.args.callback?.bind(this) || (() => !0), this.dataDeps = {
6778
6778
  main: {
@@ -6822,9 +6822,9 @@ class Si {
6822
6822
  return s = Math.max(0, s), await this.state.count.set(s), s;
6823
6823
  }
6824
6824
  }
6825
- class ki {
6825
+ class Ei {
6826
6826
  constructor(t, e, i) {
6827
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback?.bind(this.controller), this.args.property ? this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property) : this.relation = this.args.record, this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, k(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "count computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6827
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback?.bind(this.controller), this.args.property ? this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property) : this.relation = this.args.record, this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, S(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "count computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6828
6828
  const r = this.args.attributeQuery || [];
6829
6829
  this.relatedAttributeQuery = r.filter((a) => a && a[0] !== f) || [];
6830
6830
  const s = (r.find((a) => a && a[0] === f) || [])[1]?.attributeQuery;
@@ -6904,19 +6904,20 @@ class ki {
6904
6904
  return a;
6905
6905
  }
6906
6906
  }
6907
- const Ai = [Si, ki];
6908
- class Ei {
6907
+ const Ii = [Ai, Ei];
6908
+ class Ci {
6909
6909
  constructor(t, e, i) {
6910
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, k(!(this.args.record && this.args.eventDeps), "Transform must have either record or eventDep"), this.transformCallback = this.args.callback.bind(this.controller), this.args.eventDeps ? this.eventDeps = this.args.eventDeps : this.dataDeps = {
6911
- main: {
6910
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, S(!(this.args.record && this.args.eventDeps), "Transform must have either record or eventDep"), S(!(this.args.dataDeps && this.args.eventDeps), "Transform must have either dataDeps or eventDeps"), this.transformCallback = this.args.callback.bind(this.controller), this.args.eventDeps ? this.eventDeps = this.args.eventDeps : (S(this.args.dataDeps?._source === void 0, "dataDep name `_source` is reserved for Transform"), this.dataDeps = {
6911
+ ...this.args.dataDeps || {},
6912
+ _source: {
6912
6913
  type: "records",
6913
6914
  source: this.args.record,
6914
6915
  attributeQuery: this.args.attributeQuery || ["*"]
6915
6916
  }
6916
- };
6917
+ });
6917
6918
  }
6918
6919
  static {
6919
- this.computationType = Ct;
6920
+ this.computationType = xt;
6920
6921
  }
6921
6922
  static {
6922
6923
  this.contextType = ["entity", "relation"];
@@ -6930,8 +6931,8 @@ class Ei {
6930
6931
  getDefaultValue() {
6931
6932
  return [];
6932
6933
  }
6933
- async compute({ main: t }) {
6934
- k(!this.eventDeps, "Transform compute should not be called with eventDeps");
6934
+ async compute({ _source: t }) {
6935
+ S(!this.eventDeps, "Transform compute should not be called with eventDeps");
6935
6936
  const e = [];
6936
6937
  for (const i of t) {
6937
6938
  const r = await this.transformCallback.call(this.controller, i);
@@ -6946,7 +6947,7 @@ class Ei {
6946
6947
  return e;
6947
6948
  }
6948
6949
  async computeDirtyRecords(t) {
6949
- return k(this.eventDeps, "computeDirtyRecords should be called with eventDeps"), [{}];
6950
+ return S(this.eventDeps, "computeDirtyRecords should be called with eventDeps"), [{}];
6950
6951
  }
6951
6952
  async incrementalPatchCompute(t, e) {
6952
6953
  return this.eventDeps ? this.eventBasedIncrementalPatchCompute(t, e) : this.dataBasedIncrementalPatchCompute(t, e);
@@ -6967,7 +6968,7 @@ class Ei {
6967
6968
  async dataBasedIncrementalPatchCompute(t, e) {
6968
6969
  const i = this.dataContext, r = [];
6969
6970
  if (e.type === "create") {
6970
- const s = m.atom({ key: "id", value: ["=", e.record.id] }), a = this.dataDeps.main, o = await this.controller.system.storage.findOne(a.source.name, s, void 0, a.attributeQuery), n = await this.transformCallback.call(this.controller, o);
6971
+ const s = m.atom({ key: "id", value: ["=", e.record.id] }), a = this.dataDeps._source, o = await this.controller.system.storage.findOne(a.source.name, s, void 0, a.attributeQuery), n = await this.transformCallback.call(this.controller, o);
6971
6972
  (Array.isArray(n) ? n : [n]).forEach((l, d) => {
6972
6973
  l && r.push({
6973
6974
  type: "insert",
@@ -6982,7 +6983,7 @@ class Ei {
6982
6983
  const s = e.oldRecord?.id ?? e.record.id, a = m.atom({ key: this.state.sourceRecordId.key, value: ["=", s] }), n = (await this.controller.system.storage.find(i.id.name, a, void 0, ["*"])).reduce((l, d) => (l[d[this.state.transformIndex.key]] = d, l), {});
6983
6984
  let c = [];
6984
6985
  if (e.type === "update") {
6985
- const l = m.atom({ key: "id", value: ["=", s] }), d = await this.controller.system.storage.findOne(this.dataDeps.main.source.name, l, void 0, this.dataDeps.main.attributeQuery), h = await this.transformCallback.call(this.controller, d);
6986
+ const l = m.atom({ key: "id", value: ["=", s] }), d = await this.controller.system.storage.findOne(this.dataDeps._source.source.name, l, void 0, this.dataDeps._source.attributeQuery), h = await this.transformCallback.call(this.controller, d);
6986
6987
  c = Array.isArray(h) ? h : [h];
6987
6988
  }
6988
6989
  c.forEach((l, d) => {
@@ -7012,7 +7013,7 @@ class Ei {
7012
7013
  return r;
7013
7014
  }
7014
7015
  }
7015
- const Ii = [Ei];
7016
+ const xi = [Ci];
7016
7017
  class P {
7017
7018
  constructor(t) {
7018
7019
  this.node = t;
@@ -7117,7 +7118,7 @@ class P {
7117
7118
  return new Et(this, "<", t);
7118
7119
  }
7119
7120
  eq(t) {
7120
- return new Zt(this, t);
7121
+ return new te(this, t);
7121
7122
  }
7122
7123
  getVariables() {
7123
7124
  const t = /* @__PURE__ */ new Set();
@@ -7249,7 +7250,7 @@ class Et {
7249
7250
  }
7250
7251
  }
7251
7252
  }
7252
- class Zt {
7253
+ class te {
7253
7254
  constructor(t, e) {
7254
7255
  this.left = t, this.right = e;
7255
7256
  }
@@ -7284,7 +7285,7 @@ class Zt {
7284
7285
  }
7285
7286
  }
7286
7287
  }
7287
- class Ci {
7288
+ class Mi {
7288
7289
  constructor(t, e, i) {
7289
7290
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !1, this.dataDeps = this.args.dataDeps ?? {}, this.callback = (r, s) => this.args.callback.call(this.controller, r, s), this.nextRecomputeTime = this.args.nextRecomputeTime ? (r, s) => this.args.nextRecomputeTime.call(this.controller, r, s) : void 0;
7290
7291
  }
@@ -7309,14 +7310,14 @@ class Ci {
7309
7310
  let r, s;
7310
7311
  if (e instanceof P)
7311
7312
  r = e.evaluate({ now: i }), s = i + this.nextRecomputeTime(i, t);
7312
- else if (e instanceof Et || e instanceof Zt)
7313
+ else if (e instanceof Et || e instanceof te)
7313
7314
  r = e.evaluate({ now: i }), s = e.solve();
7314
7315
  else
7315
7316
  throw new Error("Invalid result type");
7316
7317
  return await this.state.lastRecomputeTime.set(i), await this.state.nextRecomputeTime.set(s), r;
7317
7318
  }
7318
7319
  }
7319
- class xi {
7320
+ class $i {
7320
7321
  constructor(t, e, i) {
7321
7322
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !1, this.dataDeps = {
7322
7323
  _current: {
@@ -7347,15 +7348,15 @@ class xi {
7347
7348
  let s, a;
7348
7349
  if (i instanceof P)
7349
7350
  s = i.evaluate({ now: r }), a = r + this.nextRecomputeTime(r, t);
7350
- else if (i instanceof Et || i instanceof Zt)
7351
+ else if (i instanceof Et || i instanceof te)
7351
7352
  s = i.evaluate({ now: r }), a = i.solve();
7352
7353
  else
7353
7354
  throw new Error("Invalid result type");
7354
7355
  return await this.state.lastRecomputeTime.set(e, r), await this.state.nextRecomputeTime.set(e, a), s;
7355
7356
  }
7356
7357
  }
7357
- const Mi = [Ci, xi];
7358
- class $i {
7358
+ const Pi = [Mi, $i];
7359
+ class Di {
7359
7360
  constructor(t, e, i) {
7360
7361
  if (this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, !this.args.attributeQuery || this.args.attributeQuery.length === 0)
7361
7362
  throw new Error("Sum computation requires attributeQuery with at least one field");
@@ -7416,9 +7417,9 @@ class $i {
7416
7417
  return s;
7417
7418
  }
7418
7419
  }
7419
- class Pi {
7420
+ class Oi {
7420
7421
  constructor(t, e, i) {
7421
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.relation = this.controller.relations.find((o) => o.source === i.host && o.sourceProperty === this.args.property || o.target === i.host && o.targetProperty === this.args.property), k(this.relation, "summation computation must specify either property or record"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, k(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7422
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.relation = this.controller.relations.find((o) => o.source === i.host && o.sourceProperty === this.args.property || o.target === i.host && o.targetProperty === this.args.property), S(this.relation, "summation computation must specify either property or record"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, S(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7422
7423
  const r = this.args.attributeQuery || [];
7423
7424
  this.relatedAttributeQuery = this.args.attributeQuery?.filter((o) => o[0] !== f) || [];
7424
7425
  const s = (r.find((o) => o[0] === f) || [])[1]?.attributeQuery;
@@ -7505,8 +7506,8 @@ class Pi {
7505
7506
  return a;
7506
7507
  }
7507
7508
  }
7508
- const Di = [$i, Pi];
7509
- class Oi {
7509
+ const Fi = [Di, Oi];
7510
+ class Qi {
7510
7511
  constructor(t, e, i) {
7511
7512
  if (this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, !this.args.attributeQuery || this.args.attributeQuery.length === 0)
7512
7513
  throw new Error("Average computation requires attributeQuery with at least one field");
@@ -7579,9 +7580,9 @@ class Oi {
7579
7580
  return await this.state.sum.set(a), await this.state.count.set(s), s > 0 ? a / s : 0;
7580
7581
  }
7581
7582
  }
7582
- class Fi {
7583
+ class Vi {
7583
7584
  constructor(t, e, i) {
7584
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.relation = this.controller.relations.find((o) => o.source === i.host && o.sourceProperty === this.args.property || o.target === i.host && o.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, k(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "average computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7585
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.relation = this.controller.relations.find((o) => o.source === i.host && o.sourceProperty === this.args.property || o.target === i.host && o.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, S(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "average computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7585
7586
  const r = this.args.attributeQuery || [];
7586
7587
  this.relatedAttributeQuery = r.filter((o) => o && o[0] !== f) || [];
7587
7588
  const s = (r.find((o) => o && o[0] === f) || [])[1]?.attributeQuery;
@@ -7663,8 +7664,8 @@ class Fi {
7663
7664
  return await this.state.count.set(e.record, a), a > 0 ? o / a : 0;
7664
7665
  }
7665
7666
  }
7666
- const Qi = [Oi, Fi];
7667
- class Mt {
7667
+ const Li = [Qi, Vi];
7668
+ class $t {
7668
7669
  constructor(t, e, i) {
7669
7670
  this.controller = t, this.args = e, this.dataContext = i, this.state = {}, this.dataDeps = {}, this.useLastValue = e.useLastValue !== void 0 ? e.useLastValue : !0, e.dataDeps && (this.dataDeps = e.dataDeps), e.compute && (this.computeCallback = e.compute, this.compute = async (...r) => {
7670
7671
  if (this.computeCallback) {
@@ -7708,7 +7709,7 @@ class Mt {
7708
7709
  }));
7709
7710
  }
7710
7711
  static {
7711
- this.computationType = zt;
7712
+ this.computationType = Zt;
7712
7713
  }
7713
7714
  createState() {
7714
7715
  if (this.createStateCallback) {
@@ -7735,29 +7736,29 @@ class Mt {
7735
7736
  return A.skip();
7736
7737
  }
7737
7738
  }
7738
- class Vi extends Mt {
7739
+ class _i extends $t {
7739
7740
  static {
7740
7741
  this.contextType = "global";
7741
7742
  }
7742
7743
  }
7743
- class Li extends Mt {
7744
+ class qi extends $t {
7744
7745
  static {
7745
7746
  this.contextType = "entity";
7746
7747
  }
7747
7748
  }
7748
- class qi extends Mt {
7749
+ class Bi extends $t {
7749
7750
  static {
7750
7751
  this.contextType = "relation";
7751
7752
  }
7752
7753
  }
7753
- class _i extends Mt {
7754
+ class Wi extends $t {
7754
7755
  static {
7755
7756
  this.contextType = "property";
7756
7757
  }
7757
7758
  constructor(t, e, i) {
7758
7759
  if (e.dataDeps) {
7759
7760
  const r = Object.keys(e.dataDeps).filter((s) => e.dataDeps[s].type === "records");
7760
- k(r.length === 0, `property-level custom computation dataDeps should not contain "records” type dataDeps, but got ${r.join(", ")}
7761
+ S(r.length === 0, `property-level custom computation dataDeps should not contain "records” type dataDeps, but got ${r.join(", ")}
7761
7762
  If you want to use related entity/relation as dataDeps, please use "property" type dataDeps with args: { type: "property", attributeQuery: [attributeQuery] }
7762
7763
  If you want to use aggregated data from all records in the entity/relation, you should define a different dict value to store the aggregated data, and then use the dict value as dataDeps.
7763
7764
  `);
@@ -7765,11 +7766,11 @@ If you want to use aggregated data from all records in the entity/relation, you
7765
7766
  super(t, e, i);
7766
7767
  }
7767
7768
  }
7768
- const Bi = [
7769
- Vi,
7770
- Li,
7769
+ const Ji = [
7770
+ _i,
7771
7771
  qi,
7772
- _i
7772
+ Bi,
7773
+ Wi
7773
7774
  ];
7774
7775
  class U extends Error {
7775
7776
  constructor(t, e = {}) {
@@ -7905,7 +7906,7 @@ class G extends U {
7905
7906
  }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || V.HIGH;
7906
7907
  }
7907
7908
  }
7908
- class ne extends U {
7909
+ class ce extends U {
7909
7910
  constructor(t, e = {}) {
7910
7911
  super(t, {
7911
7912
  errorType: e.context?.errorType || "ActivityError",
@@ -7937,7 +7938,7 @@ class Q extends U {
7937
7938
  }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || V.MEDIUM;
7938
7939
  }
7939
7940
  }
7940
- class ce extends Q {
7941
+ class le extends Q {
7941
7942
  constructor(t, e = {}) {
7942
7943
  super(t, {
7943
7944
  ...e,
@@ -8054,7 +8055,7 @@ class $ extends U {
8054
8055
  });
8055
8056
  }
8056
8057
  }
8057
- const tt = "_System_", _ = "_Dictionary_", et = "id", nt = "_rowId", Wi = C.create({
8058
+ const tt = "_System_", q = "_Dictionary_", et = "id", nt = "_rowId", ji = C.create({
8058
8059
  name: tt,
8059
8060
  properties: [
8060
8061
  T.create({
@@ -8073,8 +8074,8 @@ const tt = "_System_", _ = "_Dictionary_", et = "id", nt = "_rowId", Wi = C.crea
8073
8074
  collection: !1
8074
8075
  })
8075
8076
  ]
8076
- }), Ji = C.create({
8077
- name: _,
8077
+ }), Hi = C.create({
8078
+ name: q,
8078
8079
  properties: [
8079
8080
  T.create({
8080
8081
  name: "key",
@@ -8088,7 +8089,7 @@ const tt = "_System_", _ = "_Dictionary_", et = "id", nt = "_rowId", Wi = C.crea
8088
8089
  })
8089
8090
  ]
8090
8091
  });
8091
- class ji {
8092
+ class Ui {
8092
8093
  constructor(t, e) {
8093
8094
  this.controller = t, this.scheduler = e, this.sourceMaps = [], this.sourceMapTree = {};
8094
8095
  }
@@ -8149,7 +8150,7 @@ class ji {
8149
8150
  * @returns 是否需要触发计算
8150
8151
  */
8151
8152
  shouldTriggerUpdateComputation(t, e) {
8152
- return t.type !== "update" || !("dataDep" in t) ? !0 : t.dataDep.type === "global" && e.recordName === _ ? e.record?.key === t.dataDep.source.name : !t.attributes.filter((r) => r !== "id").every(
8153
+ return t.type !== "update" || !("dataDep" in t) ? !0 : t.dataDep.type === "global" && e.recordName === q ? e.record?.key === t.dataDep.source.name : !t.attributes.filter((r) => r !== "id").every(
8153
8154
  (r) => !e.record.hasOwnProperty(r) || e.record[r] === e.oldRecord[r]
8154
8155
  );
8155
8156
  }
@@ -8176,15 +8177,15 @@ class ji {
8176
8177
  } else e.type === "global" && ((!r || r === "update") && a.push({
8177
8178
  dataDep: e,
8178
8179
  type: "update",
8179
- recordName: _,
8180
- sourceRecordName: _,
8180
+ recordName: q,
8181
+ sourceRecordName: q,
8181
8182
  attributes: ["value"],
8182
8183
  computation: i
8183
8184
  }), (!r || r === "create") && a.push({
8184
8185
  dataDep: e,
8185
8186
  type: "create",
8186
- recordName: _,
8187
- sourceRecordName: _,
8187
+ recordName: q,
8188
+ sourceRecordName: q,
8188
8189
  computation: i
8189
8190
  }));
8190
8191
  return a;
@@ -8279,10 +8280,10 @@ class ji {
8279
8280
  i[t.recordName] || (i[t.recordName] = {}), i[t.recordName][t.type] || (i[t.recordName][t.type] = []), i[t.recordName][t.type].push(t);
8280
8281
  }
8281
8282
  }
8282
- const Pt = "_ASYNC_TASK_";
8283
- class Hi {
8283
+ const Dt = "_ASYNC_TASK_";
8284
+ class Gi {
8284
8285
  constructor(t, e, i, r, s) {
8285
- this.controller = t, this.computations = /* @__PURE__ */ new Set(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new ji(this.controller, this), this.buildComputationHandleMap(s);
8286
+ this.controller = t, this.computations = /* @__PURE__ */ new Set(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new Ui(this.controller, this), this.buildComputationHandleMap(s);
8286
8287
  const a = [];
8287
8288
  e.forEach((o) => {
8288
8289
  o.computation && a.push({ dataContext: { type: "entity", id: o }, args: o.computation }), o.properties?.forEach((n) => {
@@ -8298,9 +8299,9 @@ class Hi {
8298
8299
  });
8299
8300
  for (const o of a) {
8300
8301
  const n = o.dataContext, c = o.args, l = this.computationHandleMap.get(c.constructor);
8301
- k(!!l, `cannot find Computation handle map for ${c.constructor.displayName || c.constructor.name}`);
8302
+ S(!!l, `cannot find Computation handle map for ${c.constructor.displayName || c.constructor.name}`);
8302
8303
  const d = l[n.type];
8303
- k(!!d, `cannot find Computation handle for ${c.constructor.displayName || c.constructor.name} with context type ${n.type}`);
8304
+ S(!!d, `cannot find Computation handle for ${c.constructor.displayName || c.constructor.name} with context type ${n.type}`);
8304
8305
  const h = new d(this.controller, c, n);
8305
8306
  if (this.computations.add(h), this.isAsyncComputation(h)) {
8306
8307
  if (h.dataContext.type === "property") {
@@ -8412,7 +8413,7 @@ class Hi {
8412
8413
  const r = this.computationHandleMap.get(i.computationType);
8413
8414
  if (Array.isArray(i.contextType))
8414
8415
  for (const s of i.contextType)
8415
- k(!r[s], `${s} for ${i.computationType.name} is already registered.`), r[s] = e;
8416
+ S(!r[s], `${s} for ${i.computationType.name} is already registered.`), r[s] = e;
8416
8417
  else
8417
8418
  r[i.contextType] = e;
8418
8419
  }
@@ -8448,7 +8449,7 @@ class Hi {
8448
8449
  await this.controller.applyResult(t.dataContext, e);
8449
8450
  } else {
8450
8451
  const e = t.dataContext;
8451
- k(!e.id.defaultValue, `${e.host.name}.${e.id.name} property shuold not has a defaultValue, because it will be overridden by computation`), this.controller.system.storage.listen(async (i) => {
8452
+ S(!e.id.defaultValue, `${e.host.name}.${e.id.name} property shuold not has a defaultValue, because it will be overridden by computation`), this.controller.system.storage.listen(async (i) => {
8452
8453
  for (let r of i)
8453
8454
  if (r.type === "create" && r.recordName === e.host.name) {
8454
8455
  const s = await t.getDefaultValue?.(r.record);
@@ -8480,11 +8481,11 @@ class Hi {
8480
8481
  return [e.oldRecord ?? e.record];
8481
8482
  let i = [];
8482
8483
  if (!t.isRelation)
8483
- k(t.type === "update", "only support update event for entity"), i = await this.controller.system.storage.find(t.sourceRecordName, m.atom({
8484
+ S(t.type === "update", "only support update event for entity"), i = await this.controller.system.storage.find(t.sourceRecordName, m.atom({
8484
8485
  key: t.targetPath.concat("id").join("."),
8485
8486
  value: ["=", e.oldRecord.id]
8486
8487
  }), void 0);
8487
- else if (k(t.type === "create" || t.type === "delete", "only support create/delete event for relation"), t.dataDep, t.type === "create")
8488
+ else if (S(t.type === "create" || t.type === "delete", "only support create/delete event for relation"), t.dataDep, t.type === "create")
8488
8489
  i = await this.controller.system.storage.find(t.sourceRecordName, m.atom({
8489
8490
  key: t.targetPath.concat(["&", "id"]).join("."),
8490
8491
  value: ["=", e.record.id]
@@ -8513,7 +8514,7 @@ class Hi {
8513
8514
  }
8514
8515
  async computeDataBasedDirtyRecordsAndEvents(t, e) {
8515
8516
  let i = [];
8516
- if (t.dataDep.type === "global" && e.recordName === _)
8517
+ if (t.dataDep.type === "global" && e.recordName === q)
8517
8518
  if (t.computation.dataContext.type === "property") {
8518
8519
  const r = t.computation.dataContext;
8519
8520
  i = (await this.controller.system.storage.find(r.host.name, m.atom({ key: "id", value: ["not", null] }), {}, ["*"])).map((a) => [a, {
@@ -8595,8 +8596,8 @@ class Hi {
8595
8596
  getAsyncTaskRecordKey(t) {
8596
8597
  if (t.dataContext.type === "property") {
8597
8598
  const e = t.dataContext;
8598
- return `${Pt}_${e.host.name}_${e.id.name}`;
8599
- } else return t.dataContext.type === "global" ? `${Pt}_${t.dataContext.id}` : `${Pt}_${t.dataContext.type}_${t.dataContext.id?.name || t.dataContext.id}`;
8599
+ return `${Dt}_${e.host.name}_${e.id.name}`;
8600
+ } else return t.dataContext.type === "global" ? `${Dt}_${t.dataContext.id}` : `${Dt}_${t.dataContext.type}_${t.dataContext.id?.name || t.dataContext.id}`;
8600
8601
  }
8601
8602
  async createAsyncTask(t, e, i, r) {
8602
8603
  if (t.dataContext.type === "property")
@@ -8665,7 +8666,7 @@ class Hi {
8665
8666
  try {
8666
8667
  o = await this.controller.retrieveLastValue(t.dataContext, i);
8667
8668
  } catch (n) {
8668
- throw new ce("Failed to retrieve last value for incremental computation", {
8669
+ throw new le("Failed to retrieve last value for incremental computation", {
8669
8670
  handleName: t.constructor.name,
8670
8671
  computationName: t.args.constructor.displayName,
8671
8672
  dataContext: t.dataContext,
@@ -8679,7 +8680,7 @@ class Hi {
8679
8680
  try {
8680
8681
  o = await this.controller.retrieveLastValue(t.dataContext, i);
8681
8682
  } catch (n) {
8682
- throw new ce("Failed to retrieve last value for incremental patch computation", {
8683
+ throw new le("Failed to retrieve last value for incremental patch computation", {
8683
8684
  handleName: t.constructor.name,
8684
8685
  computationName: t.args.constructor.displayName,
8685
8686
  dataContext: t.dataContext,
@@ -8694,7 +8695,7 @@ class Hi {
8694
8695
  dataContext: t.dataContext,
8695
8696
  computationPhase: "type-validation"
8696
8697
  });
8697
- if (s instanceof we) {
8698
+ if (s instanceof ve) {
8698
8699
  const o = t;
8699
8700
  if (!o.compute)
8700
8701
  throw new Q("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
@@ -8717,7 +8718,7 @@ class Hi {
8717
8718
  }
8718
8719
  if (s instanceof At)
8719
8720
  return;
8720
- if (s instanceof Ne)
8721
+ if (s instanceof Se)
8721
8722
  try {
8722
8723
  return await this.createAsyncTask(t, s.args, i);
8723
8724
  } catch (o) {
@@ -8730,7 +8731,7 @@ class Hi {
8730
8731
  });
8731
8732
  }
8732
8733
  try {
8733
- const o = s instanceof Te ? await t.asyncReturn(s.result, s.args) : s;
8734
+ const o = s instanceof ke ? await t.asyncReturn(s.result, s.args) : s;
8734
8735
  t.incrementalPatchCompute ? await this.controller.applyResultPatch(t.dataContext, o, i) : await this.controller.applyResult(t.dataContext, o, i);
8735
8736
  } catch (o) {
8736
8737
  throw new Q("Failed to apply computation result", {
@@ -8851,7 +8852,7 @@ class Hi {
8851
8852
  }
8852
8853
  }
8853
8854
  }
8854
- class Se {
8855
+ class Ee {
8855
8856
  constructor(t, e, i) {
8856
8857
  this.interaction = t, this.controller = e, this.activitySeqCall = i, this.system = e.system;
8857
8858
  }
@@ -8905,7 +8906,7 @@ class Se {
8905
8906
  }
8906
8907
  if (this.isConceptAlias(e)) {
8907
8908
  const s = [];
8908
- return await di(e.for, async (o) => {
8909
+ return await pi(e.for, async (o) => {
8909
8910
  const n = await this.isConcept(t, o);
8910
8911
  return n === !0 ? !0 : (s.push(n), !1);
8911
8912
  }) ? !0 : { name: e.name, type: "conceptAlias", stack: r, error: s };
@@ -8945,7 +8946,7 @@ class Se {
8945
8946
  throw $.payloadValidationFailed(r.name, "data is not a ref", s);
8946
8947
  if (r.base)
8947
8948
  if (r.isCollection) {
8948
- const o = await oe(s, (n) => this.checkConcept(n, r.base));
8949
+ const o = await ne(s, (n) => this.checkConcept(n, r.base));
8949
8950
  if (o !== !0)
8950
8951
  throw $.conceptCheckFailed(r.name, o);
8951
8952
  } else {
@@ -8967,7 +8968,7 @@ class Se {
8967
8968
  if (r.attributives) {
8968
8969
  const o = st.is(r.attributives) ? new R(r.attributives.content) : R.atom(r.attributives);
8969
8970
  if (r.isCollection) {
8970
- const n = await oe(a, (c) => {
8971
+ const n = await ne(a, (c) => {
8971
8972
  const l = this.createHandleAttributive(
8972
8973
  J,
8973
8974
  t,
@@ -8991,7 +8992,7 @@ class Se {
8991
8992
  }
8992
8993
  async checkCondition(t) {
8993
8994
  if (this.interaction.conditions) {
8994
- const e = xt.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), i = async (s) => {
8995
+ const e = Mt.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), i = async (s) => {
8995
8996
  if (!s) return !0;
8996
8997
  if (s.content) {
8997
8998
  const a = s.content;
@@ -9022,13 +9023,13 @@ class Se {
9022
9023
  return [o.name, { result: n, error: c }];
9023
9024
  })()), a = await Promise.all(s);
9024
9025
  for (let [o, { result: n, error: c }] of a)
9025
- k(!i.sideEffects[o], `sideEffect ${o} already exists`), i.sideEffects[o] = { result: n, error: c };
9026
+ S(!i.sideEffects[o], `sideEffect ${o} already exists`), i.sideEffects[o] = { result: n, error: c };
9026
9027
  }
9027
9028
  isGetInteraction() {
9028
- return this.interaction.action === _e;
9029
+ return this.interaction.action === We;
9029
9030
  }
9030
- async saveEvent(t, e) {
9031
- return await this.controller.activityManager.saveEvent(t, e);
9031
+ async saveEvent(t) {
9032
+ return await this.controller.activityManager.saveEvent(t);
9032
9033
  }
9033
9034
  async retrieveData(t) {
9034
9035
  let e;
@@ -9038,7 +9039,7 @@ class Se {
9038
9039
  ), a = { ...t.query?.modifier || {}, ...r || {} }, o = t.query?.attributeQuery || [];
9039
9040
  e = await this.system.storage.find(i, t.query?.match, a, o);
9040
9041
  } else
9041
- k(!1, `unknown data type ${this.interaction.data}`);
9042
+ S(!1, `unknown data type ${this.interaction.data}`);
9042
9043
  return e;
9043
9044
  }
9044
9045
  async check(t, e, i, r) {
@@ -9052,8 +9053,7 @@ class Se {
9052
9053
  }
9053
9054
  async call(t, e, i, r) {
9054
9055
  const s = {
9055
- sideEffects: {},
9056
- effects: []
9056
+ sideEffects: {}
9057
9057
  };
9058
9058
  if (s.error = await this.check(t, e, i, r), !s.error) {
9059
9059
  const a = {
@@ -9067,7 +9067,7 @@ class Se {
9067
9067
  id: e
9068
9068
  }
9069
9069
  };
9070
- await this.saveEvent(a, s.effects), s.event = a, await this.runEffects(t, e, s), this.isGetInteraction() && (s.data = await this.retrieveData(t));
9070
+ await this.saveEvent(a), s.event = a, await this.runEffects(t, e, s), this.isGetInteraction() && (s.data = await this.retrieveData(t));
9071
9071
  }
9072
9072
  return s;
9073
9073
  }
@@ -9142,7 +9142,7 @@ class O {
9142
9142
  this.parent.transferToNext(this.node.uuid);
9143
9143
  }
9144
9144
  }
9145
- class le {
9145
+ class ue {
9146
9146
  constructor(t, e) {
9147
9147
  this.graph = e, this.root = K.create(t, this.graph);
9148
9148
  }
@@ -9161,7 +9161,7 @@ class le {
9161
9161
  }
9162
9162
  class it {
9163
9163
  constructor(t, e) {
9164
- this.activity = t, this.controller = e, this.uuidToNode = /* @__PURE__ */ new Map(), this.uuidToInteractionCall = /* @__PURE__ */ new Map(), this.interactionCallByName = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.checkUserRef = async (i, r, s) => (k(i.isRef, "attributive must be ref"), ((await this.getActivity(s))?.refs)[i.name] === r.id), this.system = e.system, this.graph = this.buildGraph(t);
9164
+ this.activity = t, this.controller = e, this.uuidToNode = /* @__PURE__ */ new Map(), this.uuidToInteractionCall = /* @__PURE__ */ new Map(), this.interactionCallByName = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.checkUserRef = async (i, r, s) => (S(i.isRef, "attributive must be ref"), ((await this.getActivity(s))?.refs)[i.name] === r.id), this.system = e.system, this.graph = this.buildGraph(t);
9165
9165
  }
9166
9166
  static {
9167
9167
  this.cache = /* @__PURE__ */ new Map();
@@ -9177,7 +9177,7 @@ class it {
9177
9177
  for (let o of t.interactions) {
9178
9178
  const n = { content: o, next: null, uuid: o.uuid, parentGroup: e, parentSeq: r };
9179
9179
  this.uuidToNode.set(o.uuid, n), this.rawToNode.set(o, n);
9180
- const c = new Se(o, this.controller, this);
9180
+ const c = new Ee(o, this.controller, this);
9181
9181
  this.uuidToInteractionCall.set(o.uuid, c), o.name && this.interactionCallByName.set(o.name, c);
9182
9182
  }
9183
9183
  for (let o of t.gateways) {
@@ -9197,7 +9197,7 @@ class it {
9197
9197
  const s = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]), a = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]);
9198
9198
  if (t.transfers?.forEach((o) => {
9199
9199
  const n = this.rawToNode.get(o.source) || i.get(o.source), c = this.rawToNode.get(o.target) || i.get(o.target);
9200
- k(!!n, `cannot find source ${o.source.name}`), k(!!c, `cannot find target ${o.source.name}`), at.is(n) ? n.next.push(c) : n.next = c, at.is(c) ? c.prev.push(n) : c.prev = n, a.delete(o.source), s.delete(o.target);
9200
+ S(!!n, `cannot find source ${o.source.name}`), S(!!c, `cannot find target ${o.source.name}`), at.is(n) ? n.next.push(c) : n.next = c, at.is(c) ? c.prev.push(n) : c.prev = n, a.delete(o.source), s.delete(o.target);
9201
9201
  }), s.size !== 1) throw new Error(`start node must one, current: ${s.size}`);
9202
9202
  if (a.size !== 1) throw new Error(`end node must be one, current: ${a.size}`);
9203
9203
  return Object.assign(r, {
@@ -9206,7 +9206,7 @@ class it {
9206
9206
  }), r;
9207
9207
  }
9208
9208
  async create() {
9209
- const t = le.createInitialState(this.graph.head);
9209
+ const t = ue.createInitialState(this.graph.head);
9210
9210
  return {
9211
9211
  activityId: (await this.controller.activityManager.createActivity({
9212
9212
  name: this.activity.name,
@@ -9265,14 +9265,14 @@ class it {
9265
9265
  s = (await this.create()).activityId;
9266
9266
  }
9267
9267
  } else if (!t) return { error: "activityId must be provided for non-head interaction of an activity" };
9268
- const a = new le(await this.getState(s), this);
9268
+ const a = new ue(await this.getState(s), this);
9269
9269
  if (!a.isInteractionAvailable(e)) return { error: `interaction ${e} not available` };
9270
9270
  const o = await r.call(i, s, this.checkUserRef);
9271
9271
  if (o.error)
9272
9272
  return o;
9273
9273
  await this.saveUserRefs(s, r, i);
9274
9274
  const n = a.completeInteraction(e);
9275
- k(n, "change activity state failed");
9275
+ S(n, "change activity state failed");
9276
9276
  const c = a.toJSON();
9277
9277
  return await this.setActivity(s, { state: c }), {
9278
9278
  ...o,
@@ -9293,7 +9293,7 @@ class it {
9293
9293
  }), await this.setActivity(t, { refs: r });
9294
9294
  }
9295
9295
  }
9296
- class Ui extends O {
9296
+ class Ki extends O {
9297
9297
  onChange(t, e) {
9298
9298
  if (this.graph.isStartNode(t)) {
9299
9299
  if (e)
@@ -9304,25 +9304,25 @@ class Ui extends O {
9304
9304
  }
9305
9305
  }
9306
9306
  }
9307
- O.GroupStateNodeType.set("any", Ui);
9308
- class Gi extends O {
9307
+ O.GroupStateNodeType.set("any", Ki);
9308
+ class Xi extends O {
9309
9309
  onChange(t, e) {
9310
9310
  this.isGroupCompleted() && this.complete();
9311
9311
  }
9312
9312
  }
9313
- O.GroupStateNodeType.set("every", Gi);
9314
- class Ki extends O {
9313
+ O.GroupStateNodeType.set("every", Xi);
9314
+ class Yi extends O {
9315
9315
  onChange(t, e) {
9316
9316
  this.graph.isEndNode(t) && this.complete();
9317
9317
  }
9318
9318
  }
9319
- O.GroupStateNodeType.set("race", Ki);
9320
- class Xi extends O {
9319
+ O.GroupStateNodeType.set("race", Yi);
9320
+ class zi extends O {
9321
9321
  // 可以根据 group 上的具体配置逻辑,来动态决定。
9322
9322
  }
9323
- O.GroupStateNodeType.set("program", Xi);
9324
- const I = new xe(), Qt = "_Interaction_", vt = "_Activity_", ke = C.create({
9325
- name: Qt,
9323
+ O.GroupStateNodeType.set("program", zi);
9324
+ const I = new fe(), Vt = "_Interaction_", vt = "_Activity_", Ie = C.create({
9325
+ name: Vt,
9326
9326
  properties: [
9327
9327
  T.create({
9328
9328
  name: "interactionId",
@@ -9350,7 +9350,7 @@ const I = new xe(), Qt = "_Interaction_", vt = "_Activity_", ke = C.create({
9350
9350
  collection: !1
9351
9351
  })
9352
9352
  ]
9353
- }), Ae = C.create({
9353
+ }), Ce = C.create({
9354
9354
  name: vt,
9355
9355
  properties: [
9356
9356
  T.create({
@@ -9374,22 +9374,22 @@ const I = new xe(), Qt = "_Interaction_", vt = "_Activity_", ke = C.create({
9374
9374
  collection: !1
9375
9375
  })
9376
9376
  ]
9377
- }), Yi = D.create({
9377
+ }), Zi = D.create({
9378
9378
  name: "activityInteraction",
9379
- source: Ae,
9379
+ source: Ce,
9380
9380
  sourceProperty: "interaction",
9381
- target: ke,
9381
+ target: Ie,
9382
9382
  targetProperty: "activity",
9383
9383
  type: "1:n"
9384
9384
  });
9385
- class zi {
9385
+ class tr {
9386
9386
  constructor(t, e, i) {
9387
- this.controller = t, this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.interactionCallsByName = /* @__PURE__ */ new Map(), this.interactionCalls = /* @__PURE__ */ new Map(), this.controller.entities.push(Ae, ke), this.controller.relations.push(Yi), e.forEach((r) => {
9387
+ this.controller = t, this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.interactionCallsByName = /* @__PURE__ */ new Map(), this.interactionCalls = /* @__PURE__ */ new Map(), this.controller.entities.push(Ce, Ie), this.controller.relations.push(Zi), e.forEach((r) => {
9388
9388
  const s = new it(r, t);
9389
- this.activityCalls.set(r.uuid, s), r.name && (k(!this.activityCallsByName.has(r.name), `activity name ${r.name} is duplicated`), this.activityCallsByName.set(r.name, s));
9389
+ this.activityCalls.set(r.uuid, s), r.name && (S(!this.activityCallsByName.has(r.name), `activity name ${r.name} is duplicated`), this.activityCallsByName.set(r.name, s));
9390
9390
  }), i.forEach((r) => {
9391
- const s = new Se(r, t);
9392
- this.interactionCalls.set(r.uuid, s), r.name && (k(!this.interactionCallsByName.has(r.name), `interaction name ${r.name} is duplicated`), this.interactionCallsByName.set(r.name, s));
9391
+ const s = new Ee(r, t);
9392
+ this.interactionCalls.set(r.uuid, s), r.name && (S(!this.interactionCallsByName.has(r.name), `interaction name ${r.name} is duplicated`), this.interactionCallsByName.set(r.name, s));
9393
9393
  });
9394
9394
  }
9395
9395
  async callInteraction(t, e) {
@@ -9440,7 +9440,7 @@ class zi {
9440
9440
  try {
9441
9441
  const o = this.activityCallsByName.get(t);
9442
9442
  if (!o)
9443
- throw new ne(`Cannot find activity for ${t}`, {
9443
+ throw new ce(`Cannot find activity for ${t}`, {
9444
9444
  activityName: t,
9445
9445
  context: {
9446
9446
  interactionName: e,
@@ -9463,7 +9463,7 @@ class zi {
9463
9463
  const c = await o.callInteraction(i, n.interaction.uuid, r);
9464
9464
  return c.error ? (a.error({ label: "activity", message: o.activity.name }), await this.controller.system.storage.rollbackTransaction(o.activity.name)) : (await this.controller.system.storage.commitTransaction(o.activity.name), await this.runRecordChangeSideEffects(c, a)), c;
9465
9465
  } catch (o) {
9466
- throw new ne("Unexpected error during activity interaction call", {
9466
+ throw new ce("Unexpected error during activity interaction call", {
9467
9467
  activityName: t,
9468
9468
  context: {
9469
9469
  interactionName: e,
@@ -9521,11 +9521,11 @@ class zi {
9521
9521
  refs: e.refs
9522
9522
  }));
9523
9523
  }
9524
- async saveEvent(t, e = []) {
9525
- return this.controller.system.storage.create(Qt, t, e);
9524
+ async saveEvent(t) {
9525
+ return this.controller.system.storage.create(Vt, t);
9526
9526
  }
9527
9527
  async getEvent(t) {
9528
- return (await this.controller.system.storage.find(Qt, t, void 0, ["*"])).map((e) => ({
9528
+ return (await this.controller.system.storage.find(Vt, t, void 0, ["*"])).map((e) => ({
9529
9529
  ...e
9530
9530
  }));
9531
9531
  }
@@ -9542,7 +9542,15 @@ class zi {
9542
9542
  return this.interactionCallsByName.get(t);
9543
9543
  }
9544
9544
  }
9545
- const Dr = "User";
9545
+ const It = new fe();
9546
+ function er() {
9547
+ return It.getStore()?.effects;
9548
+ }
9549
+ function de(u) {
9550
+ const t = It.getStore();
9551
+ t?.effects && t.effects.push(...u);
9552
+ }
9553
+ const Qr = "User";
9546
9554
  class X {
9547
9555
  constructor(t) {
9548
9556
  this.name = t.name, this.record = t.record, this.content = t.content;
@@ -9551,15 +9559,15 @@ class X {
9551
9559
  return new X(t);
9552
9560
  }
9553
9561
  }
9554
- const Vt = "_isDeleted_", Or = {
9562
+ const Lt = "_isDeleted_", Vr = {
9555
9563
  create() {
9556
9564
  return T.create({
9557
- name: Vt,
9565
+ name: Lt,
9558
9566
  type: "boolean"
9559
9567
  });
9560
9568
  }
9561
9569
  };
9562
- class Fr {
9570
+ class Lr {
9563
9571
  constructor(t) {
9564
9572
  this.recordNameToSideEffects = /* @__PURE__ */ new Map(), this.globals = {
9565
9573
  BoolExp: R,
@@ -9578,21 +9586,21 @@ class Fr {
9578
9586
  forceThtrowInteractionError: d = !1
9579
9587
  // 会 catch 住 error,并在 result 中返回。
9580
9588
  } = t;
9581
- this.system = e, this.ignorePermission = l, this.forceThtrowInteractionError = d, this.entities = [...i], this.relations = [...r], this.activities = [...s], this.interactions = [...a], this.dict = [...o], this.recordMutationSideEffects = [...n], this.activityManager = new zi(this, s, a);
9589
+ this.system = e, this.ignorePermission = l, this.forceThtrowInteractionError = d, this.entities = [...i], this.relations = [...r], this.activities = [...s], this.interactions = [...a], this.dict = [...o], this.recordMutationSideEffects = [...n], this.activityManager = new tr(this, s, a);
9582
9590
  const h = [
9583
- ...Ai,
9584
9591
  ...Ii,
9585
- ...vi,
9586
- ...wi,
9587
- ...gi,
9588
- ...Di,
9589
- ...Qi,
9590
- ...Mi,
9591
- ...fi,
9592
- ...Bi,
9592
+ ...xi,
9593
+ ...ki,
9594
+ ...Ti,
9595
+ ...Ri,
9596
+ ...Fi,
9597
+ ...Li,
9598
+ ...Pi,
9599
+ ...yi,
9600
+ ...Ji,
9593
9601
  ...c
9594
9602
  ];
9595
- this.scheduler = new Hi(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9603
+ this.scheduler = new Gi(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9596
9604
  let y = this.recordNameToSideEffects.get(p.record.name);
9597
9605
  y || this.recordNameToSideEffects.set(p.record.name, y = /* @__PURE__ */ new Set()), y.add(p);
9598
9606
  });
@@ -9631,7 +9639,7 @@ class Fr {
9631
9639
  await this.system.storage.create(r.id.name, a);
9632
9640
  } else {
9633
9641
  const r = t;
9634
- r.id.name === Vt && e ? await this.system.storage.delete(r.host.name, R.atom({ key: "id", value: ["=", i.id] })) : await this.system.storage.update(r.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [r.id.name]: e });
9642
+ r.id.name === Lt && e ? await this.system.storage.delete(r.host.name, R.atom({ key: "id", value: ["=", i.id] })) : await this.system.storage.update(r.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [r.id.name]: e });
9635
9643
  }
9636
9644
  }
9637
9645
  }
@@ -9654,16 +9662,16 @@ class Fr {
9654
9662
  }
9655
9663
  } else {
9656
9664
  const a = t;
9657
- a.id.name === Vt && s.data ? (k(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", i.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: null });
9665
+ a.id.name === Lt && s.data ? (S(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", i.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: null });
9658
9666
  }
9659
9667
  }
9660
9668
  }
9661
9669
  async callInteraction(t, e) {
9662
9670
  try {
9663
- const i = await this.activityManager.callInteraction(t, e);
9664
- if (i.error && this.forceThtrowInteractionError)
9665
- throw i.error;
9666
- return i;
9671
+ const i = { effects: [] }, r = await It.run(i, async () => await this.activityManager.callInteraction(t, e));
9672
+ if (r.effects = i.effects, r.error && this.forceThtrowInteractionError)
9673
+ throw r.error;
9674
+ return r;
9667
9675
  } catch (i) {
9668
9676
  throw new G("Failed to call interaction", {
9669
9677
  interactionName: t,
@@ -9676,10 +9684,18 @@ class Fr {
9676
9684
  }
9677
9685
  async callActivityInteraction(t, e, i, r) {
9678
9686
  try {
9679
- const s = await this.activityManager.callActivityInteraction(t, e, i, r);
9680
- if (s.error && this.forceThtrowInteractionError)
9681
- throw s.error;
9682
- return s;
9687
+ const s = { effects: [] }, a = await It.run(s, async () => await this.activityManager.callActivityInteraction(t, e, i, r));
9688
+ if (a.effects && s.effects.length > 0) {
9689
+ const o = s.effects.filter(
9690
+ (n) => !a.effects.some(
9691
+ (c) => c.type === n.type && c.recordName === n.recordName && c.record?.id === n.record?.id
9692
+ )
9693
+ );
9694
+ a.effects.push(...o);
9695
+ }
9696
+ if (a.error && this.forceThtrowInteractionError)
9697
+ throw a.error;
9698
+ return a;
9683
9699
  } catch (s) {
9684
9700
  throw new G("Failed to call activity interaction", {
9685
9701
  interactionName: e,
@@ -9721,7 +9737,7 @@ class Fr {
9721
9737
  this.callbacks.has(t) || this.callbacks.set(t, /* @__PURE__ */ new Set()), this.callbacks.get(t).add(e);
9722
9738
  }
9723
9739
  }
9724
- let Zi = class {
9740
+ let ir = class {
9725
9741
  constructor(t) {
9726
9742
  this.db = t;
9727
9743
  }
@@ -9733,12 +9749,12 @@ let Zi = class {
9733
9749
  return e === void 0 ? await this.db.scheme(`INSERT INTO _IDS_ (name, last) VALUES ('${t}', ${i})`, r) : await this.db.update("UPDATE _IDS_ SET last = ? WHERE name = ?", [i, t], void 0, r), i;
9734
9750
  }
9735
9751
  };
9736
- class tr {
9752
+ class rr {
9737
9753
  constructor(t = ":memory:", e) {
9738
- this.file = t, this.options = e, this.idSystem = new Zi(this), this.logger = this.options?.logger || wt;
9754
+ this.file = t, this.options = e, this.idSystem = new ir(this), this.logger = this.options?.logger || wt;
9739
9755
  }
9740
9756
  async open() {
9741
- this.db = new Ce(this.file, this.options), await this.idSystem.setup();
9757
+ this.db = new $e(this.file, this.options), await this.idSystem.setup();
9742
9758
  }
9743
9759
  async query(t, e = [], i = "") {
9744
9760
  const r = I.getStore(), s = this.logger.child(r?.logContext || {}), a = e.map((o) => o === !1 ? 0 : o === !0 ? 1 : o);
@@ -9805,22 +9821,22 @@ class tr {
9805
9821
  return t === "pk" ? "INTEGER PRIMARY KEY" : t === "id" ? "INT" : e || t === "object" || t === "json" ? "JSON" : t === "string" ? "TEXT" : t === "boolean" ? "INT(2)" : t === "number" || t === "timestamp" ? "INT" : t;
9806
9822
  }
9807
9823
  }
9808
- function er(u) {
9824
+ function sr(u) {
9809
9825
  return encodeURI(JSON.stringify(u));
9810
9826
  }
9811
- function ir(u) {
9827
+ function ar(u) {
9812
9828
  return u === void 0 ? void 0 : JSON.parse(decodeURI(u));
9813
9829
  }
9814
- class rr {
9830
+ class or {
9815
9831
  constructor(t) {
9816
9832
  this.db = t, this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
9817
9833
  get: async (e) => {
9818
9834
  const i = m.atom({ key: "key", value: ["=", e] });
9819
- return (await this.queryHandle.findOne(_, i, void 0, ["value"]))?.value?.raw;
9835
+ return (await this.queryHandle.findOne(q, i, void 0, ["value"]))?.value?.raw;
9820
9836
  },
9821
9837
  set: async (e, i) => {
9822
- const r = m.atom({ key: "key", value: ["=", e] }), s = await this.queryHandle.findOne(_, r, void 0, ["value"]);
9823
- return s ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [_, m.atom({ key: "id", value: ["=", s.id] }), { key: e, value: { raw: i } }], []) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [_, { key: e, value: { raw: i } }], []);
9838
+ const r = m.atom({ key: "key", value: ["=", e] }), s = await this.queryHandle.findOne(q, r, void 0, ["value"]);
9839
+ return s ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [q, m.atom({ key: "id", value: ["=", s.id] }), { key: e, value: { raw: i } }], []) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [q, { key: e, value: { raw: i } }], []);
9824
9840
  }
9825
9841
  };
9826
9842
  }
@@ -9836,20 +9852,20 @@ class rr {
9836
9852
  // CAUTION kv 结构数据的实现也用 er。这是系统约定,因为也需要 Record 事件!
9837
9853
  async get(t, e, i) {
9838
9854
  const r = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] }), s = (await this.queryHandle.findOne(tt, r, void 0, ["value"]))?.value;
9839
- return s === void 0 ? i : ir(s);
9855
+ return s === void 0 ? i : ar(s);
9840
9856
  }
9841
9857
  async set(t, e, i, r) {
9842
9858
  const s = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] });
9843
- return await this.queryHandle.findOne(tt, s, void 0, ["value"]) ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [tt, s, { concept: t, key: e.toString(), value: er(i) }], r) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [tt, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(i)) }], r);
9859
+ return await this.queryHandle.findOne(tt, s, void 0, ["value"]) ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [tt, s, { concept: t, key: e.toString(), value: sr(i) }], r) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [tt, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(i)) }], r);
9844
9860
  }
9845
9861
  async setup(t, e, i = !1) {
9846
9862
  await this.db.open(i);
9847
- const r = new ui(
9863
+ const r = new hi(
9848
9864
  t,
9849
9865
  e,
9850
9866
  this.db
9851
9867
  );
9852
- i && await r.createTables(), this.queryHandle = new Xe(new Ye(r.map), this.db), this.map = r.map;
9868
+ i && await r.createTables(), this.queryHandle = new ze(new Ze(r.map), this.db), this.map = r.map;
9853
9869
  }
9854
9870
  findOne(...t) {
9855
9871
  return this.queryHandle.findOne(...t);
@@ -9867,8 +9883,10 @@ class rr {
9867
9883
  return this.callWithEvents(this.queryHandle.delete.bind(this.queryHandle), [t, e], i);
9868
9884
  }
9869
9885
  async callWithEvents(t, e, i = []) {
9870
- const r = await t(...e, i), s = await this.dispatch(i);
9871
- return i.push(...s), r;
9886
+ const r = [], s = await t(...e, r), a = await this.dispatch(r);
9887
+ i.push(...r, ...a);
9888
+ const o = er();
9889
+ return o && r.length > 0 && de(r), o && a.length > 0 && de(a), s;
9872
9890
  }
9873
9891
  findRelationByName(...t) {
9874
9892
  return this.queryHandle.findRelationByName(...t);
@@ -9906,8 +9924,8 @@ class rr {
9906
9924
  return this.db.close();
9907
9925
  }
9908
9926
  }
9909
- var sr = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(sr || {});
9910
- class te {
9927
+ var nr = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(nr || {});
9928
+ class ee {
9911
9929
  constructor(t = 0) {
9912
9930
  this.level = t;
9913
9931
  }
@@ -9918,11 +9936,11 @@ class te {
9918
9936
  this.level >= 0 && console.error({ type: t, name: e, sql: i, params: r, error: s });
9919
9937
  }
9920
9938
  child() {
9921
- return new te(this.level);
9939
+ return new ee(this.level);
9922
9940
  }
9923
9941
  }
9924
- var ar = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(ar || {});
9925
- class ee {
9942
+ var cr = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(cr || {});
9943
+ class ie {
9926
9944
  constructor(t = 0) {
9927
9945
  this.level = t;
9928
9946
  }
@@ -9936,16 +9954,16 @@ class ee {
9936
9954
  this.level >= 2 && console.debug(`[DEBUG] ${t}: ${e}`, i);
9937
9955
  }
9938
9956
  child(t) {
9939
- return new ee(this.level);
9957
+ return new ie(this.level);
9940
9958
  }
9941
9959
  }
9942
- const wt = new te(), or = new ee();
9943
- class Vr {
9944
- constructor(t = new tr(void 0, { logger: wt }), e = or) {
9945
- this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new rr(t);
9960
+ const wt = new ee(), lr = new ie();
9961
+ class qr {
9962
+ constructor(t = new rr(void 0, { logger: wt }), e = lr) {
9963
+ this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new or(t);
9946
9964
  }
9947
9965
  setup(t, e, i, r = !1) {
9948
- const s = new be(t, e), { entities: a, relations: o } = s.getAll();
9966
+ const s = new Ne(t, e), { entities: a, relations: o } = s.getAll();
9949
9967
  return i.forEach(({ dataContext: n, state: c }) => {
9950
9968
  Object.entries(c).forEach(([l, d]) => {
9951
9969
  if (d instanceof E) {
@@ -9971,7 +9989,7 @@ class Vr {
9971
9989
  }
9972
9990
  });
9973
9991
  }), this.storage.setup(
9974
- [...a, Ji, Wi],
9992
+ [...a, Hi, ji],
9975
9993
  o,
9976
9994
  r
9977
9995
  );
@@ -9980,8 +9998,8 @@ class Vr {
9980
9998
  this.storage.destroy();
9981
9999
  }
9982
10000
  }
9983
- const { Client: ue } = Me;
9984
- let nr = class {
10001
+ const { Client: he } = Pe;
10002
+ let ur = class {
9985
10003
  constructor(t) {
9986
10004
  this.db = t;
9987
10005
  }
@@ -9993,14 +10011,14 @@ let nr = class {
9993
10011
  return e === void 0 ? await this.db.scheme(`INSERT INTO "_IDS_" (name, last) VALUES ('${t}', ${i})`, r) : await this.db.update('UPDATE "_IDS_" SET last = $1 WHERE name = $2', [i, t], void 0, r), i;
9994
10012
  }
9995
10013
  };
9996
- class qr {
10014
+ class Wr {
9997
10015
  constructor(t, e = {}) {
9998
- this.database = t, this.options = e, this.idSystem = new nr(this), this.logger = this.options?.logger || wt, this.db = new ue({
10016
+ this.database = t, this.options = e, this.idSystem = new ur(this), this.logger = this.options?.logger || wt, this.db = new he({
9999
10017
  ...e
10000
10018
  });
10001
10019
  }
10002
10020
  async open(t = !1) {
10003
- await this.db.connect(), (await this.db.query(`SELECT FROM pg_database WHERE datname = '${this.database}'`)).rows.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = new ue({
10021
+ await this.db.connect(), (await this.db.query(`SELECT FROM pg_database WHERE datname = '${this.database}'`)).rows.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = new he({
10004
10022
  ...this.options,
10005
10023
  database: this.database
10006
10024
  }), await this.db.connect()), await this.idSystem.setup();
@@ -10074,7 +10092,7 @@ class qr {
10074
10092
  return t === "pk" ? "INT GENERATED ALWAYS AS IDENTITY" : t === "id" ? "INT" : e || t === "object" ? "JSON" : t === "string" ? "TEXT" : t === "boolean" ? "BOOLEAN" : t === "number" ? "INT" : t === "timestamp" ? "TIMESTAMP" : t;
10075
10093
  }
10076
10094
  }
10077
- let cr = class {
10095
+ let dr = class {
10078
10096
  constructor(t) {
10079
10097
  this.db = t;
10080
10098
  }
@@ -10082,12 +10100,12 @@ let cr = class {
10082
10100
  return this.db.scheme('CREATE Table IF NOT EXISTS "_IDS_" (last INTEGER, name TEXT)');
10083
10101
  }
10084
10102
  async getAutoId(t) {
10085
- return de();
10103
+ return pe();
10086
10104
  }
10087
10105
  };
10088
- class Br {
10106
+ class jr {
10089
10107
  constructor(t, e = {}) {
10090
- this.database = t, this.options = e, this.idSystem = new cr(this), this.logger = this.options?.logger || wt, this.db = new $e(this.database);
10108
+ this.database = t, this.options = e, this.idSystem = new dr(this), this.logger = this.options?.logger || wt, this.db = new De(this.database);
10091
10109
  }
10092
10110
  async open(t = !1) {
10093
10111
  if (t) {
@@ -10202,7 +10220,7 @@ class Br {
10202
10220
  return t === "pk" ? "SERIAL PRIMARY KEY" : t === "id" ? "UUID" : e || t === "object" ? "JSON" : t === "string" ? "TEXT" : t === "boolean" ? "BOOL" : t === "number" ? "INT" : t === "timestamp" ? "TIMESTAMP" : t;
10203
10221
  }
10204
10222
  }
10205
- class lr {
10223
+ class hr {
10206
10224
  constructor(t) {
10207
10225
  this.db = t;
10208
10226
  }
@@ -10214,16 +10232,16 @@ class lr {
10214
10232
  return e === void 0 ? await this.db.scheme(`INSERT INTO "_IDS_" (name, last) VALUES ('${t}', ${i})`, r) : await this.db.update('UPDATE "_IDS_" SET last = ? WHERE name = ?', [i, t], void 0, r), i;
10215
10233
  }
10216
10234
  }
10217
- class Wr {
10235
+ class Hr {
10218
10236
  constructor(t, e = {}) {
10219
- this.database = t, this.options = e, this.idSystem = new lr(this), this.logger = this.options?.logger || wt;
10237
+ this.database = t, this.options = e, this.idSystem = new hr(this), this.logger = this.options?.logger || wt;
10220
10238
  }
10221
10239
  async open(t = !1) {
10222
- ({ ...this.options }, this.db = await se.createConnection({
10240
+ ({ ...this.options }, this.db = await ae.createConnection({
10223
10241
  ...this.options
10224
10242
  })), await this.db.connect();
10225
10243
  const [e] = await this.db.query(`SHOW DATABASES LIKE '${this.database}'`);
10226
- e.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = await se.createConnection({
10244
+ e.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = await ae.createConnection({
10227
10245
  ...this.options,
10228
10246
  database: this.database
10229
10247
  }), await this.db.connect()), await this.db.query("SET sql_mode='ANSI_QUOTES'"), await this.idSystem.setup();
@@ -10296,169 +10314,172 @@ class Wr {
10296
10314
  }
10297
10315
  export {
10298
10316
  vt as ACTIVITY_RECORD,
10299
- Je as ALL_ATTR_SYMBOL,
10300
- Pt as ASYNC_TASK_RECORD,
10301
- It as Action,
10302
- Wt as Activity,
10317
+ He as ALL_ATTR_SYMBOL,
10318
+ Dt as ASYNC_TASK_RECORD,
10319
+ Ct as Action,
10320
+ Jt as Activity,
10303
10321
  it as ActivityCall,
10304
10322
  rt as ActivityGroup,
10305
- Yi as ActivityInteractionRelation,
10306
- zi as ActivityManager,
10307
- Ae as ActivityStateEntity,
10323
+ Zi as ActivityInteractionRelation,
10324
+ tr as ActivityManager,
10325
+ Ce as ActivityStateEntity,
10308
10326
  yt as Any,
10309
- vi as AnyHandles,
10327
+ ki as AnyHandles,
10310
10328
  W as AttributeInfo,
10311
10329
  x as AttributeQuery,
10312
10330
  J as Attributive,
10313
10331
  st as Attributives,
10314
10332
  ft as Average,
10315
- Qi as AverageHandles,
10316
- Tr as BaseKlass,
10333
+ Li as AverageHandles,
10334
+ kr as BaseKlass,
10317
10335
  ct as BoolAtomData,
10318
10336
  R as BoolExp,
10319
10337
  lt as BoolExpressionData,
10320
10338
  j as ComputationDataDepError,
10321
10339
  Q as ComputationError,
10322
10340
  A as ComputationResult,
10323
- Ne as ComputationResultAsync,
10324
- we as ComputationResultFullRecompute,
10325
- Te as ComputationResultResolved,
10341
+ Se as ComputationResultAsync,
10342
+ ve as ComputationResultFullRecompute,
10343
+ ke as ComputationResultResolved,
10326
10344
  At as ComputationResultSkip,
10327
- ce as ComputationStateError,
10328
- Jt as Condition,
10345
+ le as ComputationStateError,
10346
+ jt as Condition,
10329
10347
  $ as ConditionError,
10330
- xt as Conditions,
10331
- Fr as Controller,
10348
+ Mt as Conditions,
10349
+ Lr as Controller,
10332
10350
  ht as Count,
10333
- Ai as CountHandles,
10334
- zt as Custom,
10335
- Bi as CustomHandles,
10336
- te as DBConsoleLogger,
10337
- sr as DBLogLevel,
10338
- ui as DBSetup,
10339
- Pr as DELETED_STATE,
10340
- _ as DICTIONARY_RECORD,
10341
- jt as DataAttributive,
10342
- Yt as DataAttributives,
10343
- _t as Dictionary,
10344
- Ji as DictionaryEntity,
10351
+ Ii as CountHandles,
10352
+ Zt as Custom,
10353
+ Ji as CustomHandles,
10354
+ ee as DBConsoleLogger,
10355
+ nr as DBLogLevel,
10356
+ hi as DBSetup,
10357
+ Fr as DELETED_STATE,
10358
+ q as DICTIONARY_RECORD,
10359
+ Ht as DataAttributive,
10360
+ zt as DataAttributives,
10361
+ Bt as Dictionary,
10362
+ Hi as DictionaryEntity,
10345
10363
  C as Entity,
10346
- Li as EntityCustomHandle,
10347
- Xe as EntityQueryHandle,
10348
- Ye as EntityToTableMap,
10349
- Zt as Equation,
10350
- Ht as Event,
10364
+ qi as EntityCustomHandle,
10365
+ ze as EntityQueryHandle,
10366
+ Ze as EntityToTableMap,
10367
+ te as Equation,
10368
+ Ut as Event,
10351
10369
  mt as Every,
10352
- wi as EveryHandles,
10370
+ Ti as EveryHandles,
10353
10371
  P as Expression,
10354
10372
  at as Gateway,
10355
- _e as GetAction,
10356
- Ni as GlobalAnyHandle,
10357
- Oi as GlobalAverageHandle,
10373
+ We as GetAction,
10374
+ vi as GlobalAnyHandle,
10375
+ Qi as GlobalAverageHandle,
10358
10376
  B as GlobalBoundState,
10359
- Si as GlobalCountHandle,
10360
- Vi as GlobalCustomHandle,
10361
- bi as GlobalEveryHandle,
10362
- Ci as GlobalRealTimeComputation,
10363
- hi as GlobalStateMachineHandle,
10364
- $i as GlobalSumHandle,
10365
- mi as GlobalWeightedSummationHandle,
10366
- Vt as HARD_DELETION_PROPERTY_NAME,
10367
- Or as HardDeletionProperty,
10377
+ Ai as GlobalCountHandle,
10378
+ _i as GlobalCustomHandle,
10379
+ wi as GlobalEveryHandle,
10380
+ Mi as GlobalRealTimeComputation,
10381
+ fi as GlobalStateMachineHandle,
10382
+ Di as GlobalSumHandle,
10383
+ gi as GlobalWeightedSummationHandle,
10384
+ Lt as HARD_DELETION_PROPERTY_NAME,
10385
+ Vr as HardDeletionProperty,
10368
10386
  et as ID_ATTR,
10369
- Qt as INTERACTION_RECORD,
10387
+ Vt as INTERACTION_RECORD,
10370
10388
  Et as Inequality,
10371
- Bt as Interaction,
10372
- Se as InteractionCall,
10373
- ke as InteractionEventEntity,
10374
- Lt as KlassByName,
10389
+ Wt as Interaction,
10390
+ Ee as InteractionCall,
10391
+ Ie as InteractionEventEntity,
10392
+ _t as KlassByName,
10375
10393
  f as LINK_SYMBOL,
10376
10394
  kt as LinkInfo,
10377
10395
  m as MatchExp,
10378
- We as Modifier,
10379
- Vr as MonoSystem,
10380
- Wr as MysqlDB,
10381
- $r as NON_DELETED_STATE,
10382
- Mr as NON_EXIST_STATE,
10396
+ je as Modifier,
10397
+ qr as MonoSystem,
10398
+ Hr as MysqlDB,
10399
+ Or as NON_DELETED_STATE,
10400
+ Dr as NON_EXIST_STATE,
10383
10401
  L as NewRecordData,
10384
- Br as PGLiteDB,
10385
- Kt as Payload,
10386
- Gt as PayloadItem,
10387
- qr as PostgreSQLDB,
10402
+ jr as PGLiteDB,
10403
+ Xt as Payload,
10404
+ Kt as PayloadItem,
10405
+ Wr as PostgreSQLDB,
10388
10406
  T as Property,
10389
- Ti as PropertyAnyHandle,
10390
- Fi as PropertyAverageHandle,
10391
- ki as PropertyCountHandle,
10392
- _i as PropertyCustomHandle,
10393
- Ri as PropertyEveryHandle,
10394
- xi as PropertyRealTimeComputation,
10395
- pi as PropertyStateMachineHandle,
10396
- Pi as PropertySumHandle,
10407
+ Si as PropertyAnyHandle,
10408
+ Vi as PropertyAverageHandle,
10409
+ Ei as PropertyCountHandle,
10410
+ Wi as PropertyCustomHandle,
10411
+ Ni as PropertyEveryHandle,
10412
+ $i as PropertyRealTimeComputation,
10413
+ mi as PropertyStateMachineHandle,
10414
+ Oi as PropertySumHandle,
10397
10415
  qt as PropertyTypes,
10398
- yi as PropertyWeightedSummationHandle,
10399
- ge as Query,
10400
- ye as QueryItem,
10401
- Re as ROOT_LABEL,
10416
+ bi as PropertyWeightedSummationHandle,
10417
+ we as Query,
10418
+ Re as QueryItem,
10419
+ Te as ROOT_LABEL,
10402
10420
  nt as ROW_ID_ATTR,
10403
10421
  gt as RealTime,
10404
- Mi as RealTimeHandles,
10422
+ Pi as RealTimeHandles,
10405
10423
  E as RecordBoundState,
10406
10424
  ot as RecordInfo,
10407
10425
  X as RecordMutationSideEffect,
10408
10426
  M as RecordQuery,
10409
- Ke as RecordQueryAgent,
10410
- q as RecordQueryTree,
10411
- Ei as RecordsTransformHandle,
10427
+ Ye as RecordQueryAgent,
10428
+ _ as RecordQueryTree,
10429
+ Ci as RecordsTransformHandle,
10412
10430
  St as RecursiveContext,
10413
- be as RefContainer,
10431
+ Ne as RefContainer,
10414
10432
  D as Relation,
10415
- qi as RelationCustomHandle,
10416
- tr as SQLiteDB,
10433
+ Bi as RelationCustomHandle,
10434
+ rr as SQLiteDB,
10417
10435
  tt as SYSTEM_RECORD,
10418
- Hi as Scheduler,
10419
- Xt as SideEffect,
10436
+ Gi as Scheduler,
10437
+ Yt as SideEffect,
10420
10438
  ut as StateMachine,
10421
- fi as StateMachineHandles,
10439
+ yi as StateMachineHandles,
10422
10440
  Y as StateNode,
10423
- Ut as StateTransfer,
10441
+ Gt as StateTransfer,
10424
10442
  pt as Summation,
10425
- Di as SummationHandles,
10426
- ee as SystemConsoleLogger,
10427
- Wi as SystemEntity,
10428
- ar as SystemLogLevel,
10429
- fe as Transfer,
10430
- Ct as Transform,
10431
- Ii as TransformHandles,
10432
- Dr as USER_ENTITY,
10443
+ Fi as SummationHandles,
10444
+ ie as SystemConsoleLogger,
10445
+ ji as SystemEntity,
10446
+ cr as SystemLogLevel,
10447
+ ge as Transfer,
10448
+ xt as Transform,
10449
+ xi as TransformHandles,
10450
+ Qr as USER_ENTITY,
10433
10451
  dt as WeightedSummation,
10434
- gi as WeightedSummationHandles,
10435
- k as assert,
10452
+ Ri as WeightedSummationHandles,
10453
+ de as addToCurrentEffects,
10454
+ S as assert,
10455
+ It as asyncEffectsContext,
10436
10456
  I as asyncInteractionContext,
10437
- Ar as boolExpToAttributives,
10438
- gr as clearAllInstances,
10439
- Nr as createClass,
10440
- Oe as createInstances,
10441
- wr as createInstancesFromString,
10442
- Er as createUserRoleAttributive,
10457
+ Cr as boolExpToAttributives,
10458
+ wr as clearAllInstances,
10459
+ Sr as createClass,
10460
+ Qe as createInstances,
10461
+ vr as createInstancesFromString,
10462
+ xr as createUserRoleAttributive,
10443
10463
  wt as dbConsoleLogger,
10444
10464
  Nt as deepClone,
10445
- xr as everyAsync,
10446
- oe as everyWithErrorAsync,
10447
- Ir as filterMap,
10448
- Sr as findRootActivity,
10449
- me as forEachInteraction,
10465
+ Pr as everyAsync,
10466
+ ne as everyWithErrorAsync,
10467
+ Mr as filterMap,
10468
+ Er as findRootActivity,
10469
+ be as forEachInteraction,
10450
10470
  v as generateUUID,
10451
- vr as getInteractions,
10452
- Pe as indexBy,
10453
- he as isObject,
10454
- pe as isPlainObject,
10455
- Cr as mapObject,
10456
- kr as parse,
10457
- De as registerKlass,
10458
- br as removeAllInstance,
10459
- di as someAsync,
10460
- Rr as stringifyAllInstances,
10471
+ er as getCurrentEffects,
10472
+ Ar as getInteractions,
10473
+ Oe as indexBy,
10474
+ me as isObject,
10475
+ ye as isPlainObject,
10476
+ $r as mapObject,
10477
+ Ir as parse,
10478
+ Fe as registerKlass,
10479
+ Nr as removeAllInstance,
10480
+ pi as someAsync,
10481
+ Tr as stringifyAllInstances,
10461
10482
  w as stringifyAttribute,
10462
- or as systemConsoleLogger
10483
+ lr as systemConsoleLogger
10463
10484
  };
10464
10485
  //# sourceMappingURL=index.js.map