interaqt 0.7.3 → 0.8.0

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,4 +1,4 @@
1
- import { parse as Ee } from "acorn";
1
+ import { parse as Se } from "acorn";
2
2
  import { AsyncLocalStorage as le } from "async_hooks";
3
3
  function ue(u) {
4
4
  return u !== null && typeof u == "object";
@@ -8,7 +8,7 @@ function de(u) {
8
8
  const t = Object.getPrototypeOf(u);
9
9
  return t === null ? !0 : t === Object.prototype || t === null;
10
10
  }
11
- function Ie(u, t) {
11
+ function Ee(u, t) {
12
12
  const e = {};
13
13
  for (const i of u)
14
14
  i && i[t] !== void 0 && (e[String(i[t])] = i);
@@ -17,42 +17,42 @@ function Ie(u, t) {
17
17
  function w(u) {
18
18
  return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : ue(u) && !de(u) ? `uuid::${u.uuid}` : u;
19
19
  }
20
- function ft(u, t) {
20
+ function mt(u, t) {
21
21
  if (u == null || typeof u != "object") return u;
22
- if (Array.isArray(u)) return u.map((i) => ft(i, t));
22
+ if (Array.isArray(u)) return u.map((i) => mt(i, t));
23
23
  if (de(u))
24
- return Object.fromEntries(Object.entries(u).map(([i, r]) => [i, ft(r, t)]));
24
+ return Object.fromEntries(Object.entries(u).map(([i, r]) => [i, mt(r, t)]));
25
25
  if (u instanceof Set)
26
- return new Set(Array.from(u.values()).map((i) => ft(i, t)));
26
+ return new Set(Array.from(u.values()).map((i) => mt(i, t)));
27
27
  if (u instanceof Map)
28
- return new Map(Array.from(u.entries()).map(([i, r]) => [i, ft(r, t)]));
28
+ return new Map(Array.from(u.entries()).map(([i, r]) => [i, mt(r, t)]));
29
29
  const e = u;
30
30
  return t && e._type && e.constructor?.clone ? e.constructor.clone(u, t) : u;
31
31
  }
32
- function or(...u) {
32
+ function ar(...u) {
33
33
  for (const t of u)
34
34
  t.instances.length = 0;
35
35
  }
36
- function nr() {
36
+ function or() {
37
37
  }
38
- const Ft = /* @__PURE__ */ new Map();
39
- function Ce(u, t) {
40
- t && t.isKlass && t.displayName && Ft.set(u, t);
38
+ const Dt = /* @__PURE__ */ new Map();
39
+ function Ie(u, t) {
40
+ t && t.isKlass && t.displayName && Dt.set(u, t);
41
41
  }
42
- function cr() {
42
+ function nr() {
43
43
  const u = [];
44
- return Array.from(Ft.entries()).forEach(([, t]) => {
44
+ return Array.from(Dt.entries()).forEach(([, t]) => {
45
45
  t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
46
46
  }), `[${u.join(",")}]`;
47
47
  }
48
- function lr(u) {
48
+ function cr(u) {
49
49
  const t = JSON.parse(u);
50
- return xe(t);
50
+ return Ce(t);
51
51
  }
52
- function xe(u) {
52
+ function Ce(u) {
53
53
  const t = /* @__PURE__ */ new Map();
54
54
  return u.forEach(({ type: e, options: i = {}, uuid: r, public: s }) => {
55
- const a = Ft.get(e);
55
+ const a = Dt.get(e);
56
56
  if (!a) {
57
57
  console.warn(`Class ${e} not found in KlassByName`);
58
58
  return;
@@ -61,10 +61,10 @@ function xe(u) {
61
61
  t.set(r, o);
62
62
  }), t;
63
63
  }
64
- function ur(u) {
64
+ function lr(u) {
65
65
  return console.warn("createClass is deprecated in refactored code"), null;
66
66
  }
67
- class dr {
67
+ class ur {
68
68
  static {
69
69
  this.isKlass = !0;
70
70
  }
@@ -86,11 +86,11 @@ class dr {
86
86
  return t !== null && typeof t == "object" && typeof t.uuid == "string";
87
87
  }
88
88
  }
89
- let Me = 0;
89
+ let xe = 0;
90
90
  function k(u) {
91
- return u?.uuid || `id_${++Me}`;
91
+ return u?.uuid || `id_${++xe}`;
92
92
  }
93
- const Pe = /^[a-zA-Z0-9_]+$/;
93
+ const Me = /^[a-zA-Z0-9_]+$/;
94
94
  class I {
95
95
  // for Merged Entity
96
96
  constructor(t, e) {
@@ -111,7 +111,7 @@ class I {
111
111
  type: "string",
112
112
  required: !0,
113
113
  constraints: {
114
- nameFormat: ({ name: t }) => Pe.test(t)
114
+ nameFormat: ({ name: t }) => Me.test(t)
115
115
  }
116
116
  },
117
117
  properties: {
@@ -192,9 +192,9 @@ class I {
192
192
  return this.create(e.public, e.options);
193
193
  }
194
194
  }
195
- var Dt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(Dt || {});
196
- const $e = /^[a-zA-Z0-9_]+$/;
197
- class Vt {
195
+ var Vt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(Vt || {});
196
+ const Pe = /^[a-zA-Z0-9_]+$/;
197
+ class Qt {
198
198
  constructor(t, e) {
199
199
  this._type = "Dictionary", this._options = e, this.uuid = k(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;
200
200
  }
@@ -214,7 +214,7 @@ class Vt {
214
214
  required: !0,
215
215
  collection: !1,
216
216
  constraints: {
217
- format: ({ name: t }) => $e.test(t),
217
+ format: ({ name: t }) => Pe.test(t),
218
218
  length: ({ name: t }) => t.length > 1 && t.length < 5
219
219
  }
220
220
  },
@@ -222,7 +222,7 @@ class Vt {
222
222
  type: "string",
223
223
  required: !0,
224
224
  collection: !1,
225
- options: Array.from(Object.values(Dt))
225
+ options: Array.from(Object.values(Vt))
226
226
  },
227
227
  collection: {
228
228
  type: "boolean",
@@ -248,7 +248,7 @@ class Vt {
248
248
  };
249
249
  }
250
250
  static create(t, e) {
251
- const i = new Vt(t, e);
251
+ const i = new Qt(t, e);
252
252
  if (this.instances.find((s) => s.uuid === i.uuid))
253
253
  throw new Error(`duplicate uuid in options ${i.uuid}, Dictionary`);
254
254
  return this.instances.push(i), i;
@@ -287,7 +287,7 @@ class Vt {
287
287
  return this.create(e.public, e.options);
288
288
  }
289
289
  }
290
- const Oe = /^[a-zA-Z0-9_]+$/;
290
+ const $e = /^[a-zA-Z0-9_]+$/;
291
291
  class v {
292
292
  constructor(t, e) {
293
293
  this._type = "Property", this._options = e, this.uuid = k(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;
@@ -307,14 +307,14 @@ class v {
307
307
  type: "string",
308
308
  required: !0,
309
309
  constraints: {
310
- format: ({ name: t }) => Oe.test(t),
310
+ format: ({ name: t }) => $e.test(t),
311
311
  length: ({ name: t }) => t.length > 1 && t.length < 5
312
312
  }
313
313
  },
314
314
  type: {
315
315
  type: "string",
316
316
  required: !0,
317
- options: () => Object.values(Dt)
317
+ options: () => Object.values(Vt)
318
318
  },
319
319
  collection: {
320
320
  type: "boolean",
@@ -553,9 +553,9 @@ class P {
553
553
  return this.create(e.public, e.options);
554
554
  }
555
555
  }
556
- class Qt {
556
+ class Lt {
557
557
  constructor(t, e) {
558
- this._type = "Interaction", this._options = e, this.uuid = k(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;
558
+ this._type = "Interaction", this._options = e, this.uuid = k(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.dataPolicy = t.dataPolicy;
559
559
  }
560
560
  static {
561
561
  this.isKlass = !0;
@@ -606,15 +606,15 @@ class Qt {
606
606
  required: !1,
607
607
  collection: !1
608
608
  },
609
- query: {
610
- type: "Query",
609
+ dataPolicy: {
610
+ type: "DataPolicy",
611
611
  required: !1,
612
612
  collection: !1
613
613
  }
614
614
  };
615
615
  }
616
616
  static create(t, e) {
617
- const i = new Qt(t, e);
617
+ const i = new Lt(t, e);
618
618
  if (this.instances.find((s) => s.uuid === i.uuid))
619
619
  throw new Error(`duplicate uuid in options ${i.uuid}, Interaction`);
620
620
  return this.instances.push(i), i;
@@ -624,7 +624,7 @@ class Qt {
624
624
  name: t.name,
625
625
  action: t.action
626
626
  };
627
- t.conditions !== void 0 && (e.conditions = t.conditions), t.userAttributives !== void 0 && (e.userAttributives = t.userAttributives), t.userRef !== void 0 && (e.userRef = t.userRef), t.payload !== void 0 && (e.payload = t.payload), t.sideEffects && t.sideEffects.length > 0 && (e.sideEffects = t.sideEffects), t.data !== void 0 && (e.data = t.data), t.query !== void 0 && (e.query = t.query);
627
+ t.conditions !== void 0 && (e.conditions = t.conditions), t.userAttributives !== void 0 && (e.userAttributives = t.userAttributives), t.userRef !== void 0 && (e.userRef = t.userRef), t.payload !== void 0 && (e.payload = t.payload), t.sideEffects && t.sideEffects.length > 0 && (e.sideEffects = t.sideEffects), t.data !== void 0 && (e.data = t.data), t.dataPolicy !== void 0 && (e.dataPolicy = t.dataPolicy);
628
628
  const i = {
629
629
  type: "Interaction",
630
630
  options: t._options,
@@ -638,7 +638,7 @@ class Qt {
638
638
  name: t.name,
639
639
  action: t.action
640
640
  };
641
- return t.conditions !== void 0 && (i.conditions = t.conditions), t.userAttributives !== void 0 && (i.userAttributives = t.userAttributives), t.userRef !== void 0 && (i.userRef = t.userRef), t.payload !== void 0 && (i.payload = t.payload), t.sideEffects && t.sideEffects.length > 0 && (i.sideEffects = t.sideEffects), t.data !== void 0 && (i.data = t.data), t.query !== void 0 && (i.query = t.query), this.create(i);
641
+ return t.conditions !== void 0 && (i.conditions = t.conditions), t.userAttributives !== void 0 && (i.userAttributives = t.userAttributives), t.userRef !== void 0 && (i.userRef = t.userRef), t.payload !== void 0 && (i.payload = t.payload), t.sideEffects && t.sideEffects.length > 0 && (i.sideEffects = t.sideEffects), t.data !== void 0 && (i.data = t.data), t.dataPolicy !== void 0 && (i.dataPolicy = t.dataPolicy), this.create(i);
642
642
  }
643
643
  static is(t) {
644
644
  return t !== null && typeof t == "object" && "_type" in t && t._type === "Interaction";
@@ -651,7 +651,7 @@ class Qt {
651
651
  return this.create(e.public, e.options);
652
652
  }
653
653
  }
654
- class Lt {
654
+ class qt {
655
655
  constructor(t, e) {
656
656
  this._type = "Activity", this._options = e, this.uuid = k(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 || [];
657
657
  }
@@ -699,7 +699,7 @@ class Lt {
699
699
  };
700
700
  }
701
701
  static create(t, e) {
702
- const i = new Lt(t, e);
702
+ const i = new qt(t, e);
703
703
  if (this.instances.find((s) => s.uuid === i.uuid))
704
704
  throw new Error(`duplicate uuid in options ${i.uuid}, Activity`);
705
705
  return this.instances.push(i), i;
@@ -874,11 +874,11 @@ function pe(u, t, e) {
874
874
  i.activities?.forEach((r) => pe(r, t, i));
875
875
  });
876
876
  }
877
- function hr(u) {
877
+ function dr(u) {
878
878
  const t = [];
879
879
  return pe(u, (e) => t.push(e)), t;
880
880
  }
881
- function pr(u) {
881
+ function hr(u) {
882
882
  return null;
883
883
  }
884
884
  class it {
@@ -1176,16 +1176,16 @@ const Fe = {
1176
1176
  "||": "or",
1177
1177
  "!": "not"
1178
1178
  };
1179
- function De(u) {
1179
+ function Oe(u) {
1180
1180
  return { key: u };
1181
1181
  }
1182
- function mt(u, t, e) {
1182
+ function yt(u, t, e) {
1183
1183
  if (u.type === "LogicalExpression")
1184
1184
  return {
1185
1185
  type: "expression",
1186
1186
  operator: Fe[u.operator],
1187
- left: mt(u.left, t, e),
1188
- right: mt(u.right, t, e)
1187
+ left: yt(u.left, t, e),
1188
+ right: yt(u.right, t, e)
1189
1189
  };
1190
1190
  if (u.type === "Identifier")
1191
1191
  return {
@@ -1196,14 +1196,14 @@ function mt(u, t, e) {
1196
1196
  return {
1197
1197
  type: "expression",
1198
1198
  operator: "not",
1199
- left: mt(u.argument, t, e)
1199
+ left: yt(u.argument, t, e)
1200
1200
  };
1201
1201
  throw new Error("unknown ast node type");
1202
1202
  }
1203
- function fr(u, t = [], e = De) {
1204
- const i = Ie(t, "name"), r = Ee(u, { ecmaVersion: 2020 });
1203
+ function pr(u, t = [], e = Oe) {
1204
+ const i = Ee(t, "name"), r = Se(u, { ecmaVersion: 2020 });
1205
1205
  return new R(
1206
- mt(r.body[0].expression, i, e)
1206
+ yt(r.body[0].expression, i, e)
1207
1207
  );
1208
1208
  }
1209
1209
  class U {
@@ -1274,7 +1274,7 @@ class U {
1274
1274
  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);
1275
1275
  }
1276
1276
  }
1277
- class Nt {
1277
+ class vt {
1278
1278
  constructor(t, e) {
1279
1279
  this._type = "Attributives", this._options = e, this.uuid = k(e), this.content = t.content;
1280
1280
  }
@@ -1297,7 +1297,7 @@ class Nt {
1297
1297
  };
1298
1298
  }
1299
1299
  static create(t, e) {
1300
- const i = new Nt(t, e);
1300
+ const i = new vt(t, e);
1301
1301
  if (this.instances.find((s) => s.uuid === i.uuid))
1302
1302
  throw new Error(`duplicate uuid in options ${i.uuid}, Attributives`);
1303
1303
  return this.instances.push(i), i;
@@ -1328,7 +1328,7 @@ class Nt {
1328
1328
  return this.create(e.public, e.options);
1329
1329
  }
1330
1330
  }
1331
- function xt(u) {
1331
+ function Mt(u) {
1332
1332
  if (!u) return;
1333
1333
  if (u.raw.type === "atom")
1334
1334
  return it.create({
@@ -1339,16 +1339,16 @@ function xt(u) {
1339
1339
  return rt.create({
1340
1340
  type: "expression",
1341
1341
  operator: t.operator,
1342
- left: xt(u.left),
1343
- right: xt(u.right)
1342
+ left: Mt(u.left),
1343
+ right: Mt(u.right)
1344
1344
  });
1345
1345
  }
1346
- function mr(u) {
1347
- return Nt.create({
1348
- content: xt(u)
1346
+ function fr(u) {
1347
+ return vt.create({
1348
+ content: Mt(u)
1349
1349
  });
1350
1350
  }
1351
- class qt {
1351
+ class Bt {
1352
1352
  constructor(t, e) {
1353
1353
  this._type = "Condition", this._options = e, this.uuid = k(e), this.content = t.content, this.name = t.name;
1354
1354
  }
@@ -1374,7 +1374,7 @@ class qt {
1374
1374
  };
1375
1375
  }
1376
1376
  static create(t, e) {
1377
- const i = new qt(t, e);
1377
+ const i = new Bt(t, e);
1378
1378
  if (this.instances.find((s) => s.uuid === i.uuid))
1379
1379
  throw new Error(`duplicate uuid in options ${i.uuid}, Condition`);
1380
1380
  return this.instances.push(i), i;
@@ -1408,7 +1408,7 @@ class qt {
1408
1408
  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);
1409
1409
  }
1410
1410
  }
1411
- class Bt {
1411
+ class _t {
1412
1412
  constructor(t, e) {
1413
1413
  this._type = "DataAttributive", this._options = e, this.uuid = k(e), this.content = t.content, this.name = t.name;
1414
1414
  }
@@ -1434,7 +1434,7 @@ class Bt {
1434
1434
  };
1435
1435
  }
1436
1436
  static create(t, e) {
1437
- const i = new Bt(t, e);
1437
+ const i = new _t(t, e);
1438
1438
  if (this.instances.find((s) => s.uuid === i.uuid))
1439
1439
  throw new Error(`duplicate uuid in options ${i.uuid}, DataAttributive`);
1440
1440
  return this.instances.push(i), i;
@@ -1470,27 +1470,32 @@ class Bt {
1470
1470
  }
1471
1471
  class fe {
1472
1472
  constructor(t, e) {
1473
- this._type = "QueryItem", this._options = e, this.uuid = k(e), this.name = t.name, this.value = t.value;
1473
+ this._type = "DataPolicy", this._options = e, this.uuid = k(e), this.match = t.match, this.modifier = t.modifier, this.attributeQuery = t.attributeQuery;
1474
1474
  }
1475
1475
  static {
1476
1476
  this.isKlass = !0;
1477
1477
  }
1478
1478
  static {
1479
- this.displayName = "QueryItem";
1479
+ this.displayName = "DataPolicy";
1480
1480
  }
1481
1481
  static {
1482
1482
  this.instances = [];
1483
1483
  }
1484
1484
  static {
1485
1485
  this.public = {
1486
- name: {
1487
- type: "string",
1488
- required: !0,
1486
+ match: {
1487
+ type: "any",
1488
+ required: !1,
1489
1489
  collection: !1
1490
1490
  },
1491
- value: {
1492
- type: "string",
1493
- required: !0,
1491
+ modifier: {
1492
+ type: "any",
1493
+ required: !1,
1494
+ collection: !1
1495
+ },
1496
+ attributeQuery: {
1497
+ type: "any",
1498
+ required: !1,
1494
1499
  collection: !1
1495
1500
  }
1496
1501
  };
@@ -1498,84 +1503,26 @@ class fe {
1498
1503
  static create(t, e) {
1499
1504
  const i = new fe(t, e);
1500
1505
  if (this.instances.find((s) => s.uuid === i.uuid))
1501
- throw new Error(`duplicate uuid in options ${i.uuid}, QueryItem`);
1502
- return this.instances.push(i), i;
1503
- }
1504
- static stringify(t) {
1505
- const e = {
1506
- type: "QueryItem",
1507
- options: t._options,
1508
- uuid: t.uuid,
1509
- public: {
1510
- name: t.name,
1511
- value: t.value
1512
- }
1513
- };
1514
- return JSON.stringify(e);
1515
- }
1516
- static clone(t, e) {
1517
- return this.create({
1518
- name: t.name,
1519
- value: t.value
1520
- });
1521
- }
1522
- static is(t) {
1523
- return t !== null && typeof t == "object" && "_type" in t && t._type === "QueryItem";
1524
- }
1525
- static check(t) {
1526
- return t !== null && typeof t == "object" && typeof t.uuid == "string";
1527
- }
1528
- static parse(t) {
1529
- const e = JSON.parse(t);
1530
- return this.create(e.public, e.options);
1531
- }
1532
- }
1533
- class me {
1534
- constructor(t, e) {
1535
- this._type = "Query", this._options = e, this.uuid = k(e), this.items = t.items;
1536
- }
1537
- static {
1538
- this.isKlass = !0;
1539
- }
1540
- static {
1541
- this.displayName = "Query";
1542
- }
1543
- static {
1544
- this.instances = [];
1545
- }
1546
- static {
1547
- this.public = {
1548
- items: {
1549
- type: "QueryItem",
1550
- required: !0,
1551
- collection: !0
1552
- }
1553
- };
1554
- }
1555
- static create(t, e) {
1556
- const i = new me(t, e);
1557
- if (this.instances.find((s) => s.uuid === i.uuid))
1558
- throw new Error(`duplicate uuid in options ${i.uuid}, Query`);
1506
+ throw new Error(`duplicate uuid in options ${i.uuid}, DataPolicy`);
1559
1507
  return this.instances.push(i), i;
1560
1508
  }
1561
1509
  static stringify(t) {
1562
- const e = {
1563
- type: "Query",
1510
+ const e = {};
1511
+ t.match !== void 0 && (e.match = t.match), t.modifier !== void 0 && (e.modifier = t.modifier), t.attributeQuery !== void 0 && (e.attributeQuery = t.attributeQuery);
1512
+ const i = {
1513
+ type: "DataPolicy",
1564
1514
  options: t._options,
1565
1515
  uuid: t.uuid,
1566
- public: {
1567
- items: t.items
1568
- }
1516
+ public: e
1569
1517
  };
1570
- return JSON.stringify(e);
1518
+ return JSON.stringify(i);
1571
1519
  }
1572
1520
  static clone(t, e) {
1573
- return this.create({
1574
- items: t.items
1575
- });
1521
+ const i = {};
1522
+ return t.match !== void 0 && (i.match = t.match), t.modifier !== void 0 && (i.modifier = t.modifier), t.attributeQuery !== void 0 && (i.attributeQuery = t.attributeQuery), this.create(i);
1576
1523
  }
1577
1524
  static is(t) {
1578
- return t !== null && typeof t == "object" && "_type" in t && t._type === "Query";
1525
+ return t !== null && typeof t == "object" && "_type" in t && t._type === "DataPolicy";
1579
1526
  }
1580
1527
  static check(t) {
1581
1528
  return t !== null && typeof t == "object" && typeof t.uuid == "string";
@@ -1585,7 +1532,7 @@ class me {
1585
1532
  return this.create(e.public, e.options);
1586
1533
  }
1587
1534
  }
1588
- class vt {
1535
+ class kt {
1589
1536
  constructor(t, e) {
1590
1537
  this._type = "Action", this._options = e, this.uuid = k(e), this.name = t.name;
1591
1538
  }
@@ -1607,7 +1554,7 @@ class vt {
1607
1554
  };
1608
1555
  }
1609
1556
  static create(t, e) {
1610
- const i = new vt(t, e);
1557
+ const i = new kt(t, e);
1611
1558
  if (this.instances.find((s) => s.uuid === i.uuid))
1612
1559
  throw new Error(`duplicate uuid in options ${i.uuid}, Action`);
1613
1560
  return this.instances.push(i), i;
@@ -1639,7 +1586,7 @@ class vt {
1639
1586
  return this.create(e.public, e.options);
1640
1587
  }
1641
1588
  }
1642
- const Ve = vt.create({ name: "get" });
1589
+ const De = kt.create({ name: "get" });
1643
1590
  class tt {
1644
1591
  constructor(t, e) {
1645
1592
  this._type = "Gateway", this._options = e, this.uuid = k(e), this.name = t.name;
@@ -1694,7 +1641,7 @@ class tt {
1694
1641
  return this.create(e.public, e.options);
1695
1642
  }
1696
1643
  }
1697
- class _t {
1644
+ class Wt {
1698
1645
  constructor(t, e) {
1699
1646
  this._type = "Event", this._options = e, this.uuid = k(e), this.name = t.name;
1700
1647
  }
@@ -1716,7 +1663,7 @@ class _t {
1716
1663
  };
1717
1664
  }
1718
1665
  static create(t, e) {
1719
- const i = new _t(t, e);
1666
+ const i = new Wt(t, e);
1720
1667
  if (this.instances.find((s) => s.uuid === i.uuid))
1721
1668
  throw new Error(`duplicate uuid in options ${i.uuid}, Event`);
1722
1669
  return this.instances.push(i), i;
@@ -1811,7 +1758,7 @@ class K {
1811
1758
  return this.create(e.public, e.options);
1812
1759
  }
1813
1760
  }
1814
- class Wt {
1761
+ class Jt {
1815
1762
  constructor(t, e) {
1816
1763
  this._type = "StateTransfer", this._options = e, this.uuid = k(e), this.trigger = t.trigger, this.current = t.current, this.next = t.next, this.computeTarget = t.computeTarget;
1817
1764
  }
@@ -1849,7 +1796,7 @@ class Wt {
1849
1796
  };
1850
1797
  }
1851
1798
  static create(t, e) {
1852
- const i = new Wt(t, e);
1799
+ const i = new Jt(t, e);
1853
1800
  if (this.instances.find((s) => s.uuid === i.uuid))
1854
1801
  throw new Error(`duplicate uuid in options ${i.uuid}, StateTransfer`);
1855
1802
  return this.instances.push(i), i;
@@ -2442,7 +2389,7 @@ class ut {
2442
2389
  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);
2443
2390
  }
2444
2391
  }
2445
- class kt {
2392
+ class Tt {
2446
2393
  constructor(t, e) {
2447
2394
  this._type = "Transform", this._options = e, this.uuid = k(e), this.record = t.record, this.eventDeps = t.eventDeps, this.attributeQuery = t.attributeQuery, this.callback = t.callback;
2448
2395
  }
@@ -2475,7 +2422,7 @@ class kt {
2475
2422
  };
2476
2423
  }
2477
2424
  static create(t, e) {
2478
- const i = new kt(t, e);
2425
+ const i = new Tt(t, e);
2479
2426
  if (this.instances.find((s) => s.uuid === i.uuid))
2480
2427
  throw new Error(`duplicate uuid in options ${i.uuid}, Transform`);
2481
2428
  return this.instances.push(i), i;
@@ -2585,7 +2532,7 @@ class dt {
2585
2532
  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);
2586
2533
  }
2587
2534
  }
2588
- class Jt {
2535
+ class Ht {
2589
2536
  constructor(t, e) {
2590
2537
  this._type = "PayloadItem", this._options = e, this.uuid = k(e), this.name = t.name, this.base = t.base, this.type = t.type, this.isRef = t.isRef ?? !1, this.required = t.required ?? !1, this.isCollection = t.isCollection ?? !1, this.itemRef = t.itemRef;
2591
2538
  }
@@ -2636,7 +2583,7 @@ class Jt {
2636
2583
  };
2637
2584
  }
2638
2585
  static create(t, e) {
2639
- const i = new Jt(t, e);
2586
+ const i = new Ht(t, e);
2640
2587
  if (this.instances.find((s) => s.uuid === i.uuid))
2641
2588
  throw new Error(`duplicate uuid in options ${i.uuid}, PayloadItem`);
2642
2589
  return this.instances.push(i), i;
@@ -2675,7 +2622,7 @@ class Jt {
2675
2622
  return this.create(e.public, e.options);
2676
2623
  }
2677
2624
  }
2678
- class Ht {
2625
+ class jt {
2679
2626
  constructor(t, e) {
2680
2627
  this._type = "Payload", this._options = e, this.uuid = k(e), this.items = t.items || [];
2681
2628
  }
@@ -2699,7 +2646,7 @@ class Ht {
2699
2646
  };
2700
2647
  }
2701
2648
  static create(t, e) {
2702
- const i = new Ht(t, e);
2649
+ const i = new jt(t, e);
2703
2650
  if (this.instances.find((s) => s.uuid === i.uuid))
2704
2651
  throw new Error(`duplicate uuid in options ${i.uuid}, Payload`);
2705
2652
  return this.instances.push(i), i;
@@ -2731,7 +2678,7 @@ class Ht {
2731
2678
  return this.create(e.public, e.options);
2732
2679
  }
2733
2680
  }
2734
- class jt {
2681
+ class Ut {
2735
2682
  constructor(t, e) {
2736
2683
  this._type = "SideEffect", this._options = e, this.uuid = k(e), this.name = t.name, this.handle = t.handle;
2737
2684
  }
@@ -2759,7 +2706,7 @@ class jt {
2759
2706
  };
2760
2707
  }
2761
2708
  static create(t, e) {
2762
- const i = new jt(t, e);
2709
+ const i = new Ut(t, e);
2763
2710
  if (this.instances.find((s) => s.uuid === i.uuid))
2764
2711
  throw new Error(`duplicate uuid in options ${i.uuid}, SideEffect`);
2765
2712
  return this.instances.push(i), i;
@@ -2793,7 +2740,7 @@ class jt {
2793
2740
  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);
2794
2741
  }
2795
2742
  }
2796
- function Mt(u) {
2743
+ function Pt(u) {
2797
2744
  if (!u) return;
2798
2745
  if (u.raw.type === "atom")
2799
2746
  return it.create({
@@ -2804,13 +2751,13 @@ function Mt(u) {
2804
2751
  return rt.create({
2805
2752
  type: "expression",
2806
2753
  operator: t.operator,
2807
- left: Mt(u.left),
2808
- right: Mt(u.right)
2754
+ left: Pt(u.left),
2755
+ right: Pt(u.right)
2809
2756
  });
2810
2757
  }
2811
- class Tt {
2758
+ class At {
2812
2759
  constructor(t, e) {
2813
- this._type = "Conditions", this._options = e, this.uuid = k(e), t.content && t.content instanceof R ? this.content = Mt(t.content) : this.content = t.content;
2760
+ this._type = "Conditions", this._options = e, this.uuid = k(e), t.content && t.content instanceof R ? this.content = Pt(t.content) : this.content = t.content;
2814
2761
  }
2815
2762
  static {
2816
2763
  this.isKlass = !0;
@@ -2831,7 +2778,7 @@ class Tt {
2831
2778
  };
2832
2779
  }
2833
2780
  static create(t, e) {
2834
- const i = new Tt(t, e);
2781
+ const i = new At(t, e);
2835
2782
  if (this.instances.find((s) => s.uuid === i.uuid))
2836
2783
  throw new Error(`duplicate uuid in options ${i.uuid}, Conditions`);
2837
2784
  return this.instances.push(i), i;
@@ -2862,7 +2809,7 @@ class Tt {
2862
2809
  return this.create(e.public, e.options);
2863
2810
  }
2864
2811
  }
2865
- class Ut {
2812
+ class Kt {
2866
2813
  constructor(t, e) {
2867
2814
  this._type = "DataAttributives", this._options = e, this.uuid = k(e), this.content = t.content;
2868
2815
  }
@@ -2885,7 +2832,7 @@ class Ut {
2885
2832
  };
2886
2833
  }
2887
2834
  static create(t, e) {
2888
- const i = new Ut(t, e);
2835
+ const i = new Kt(t, e);
2889
2836
  if (this.instances.find((s) => s.uuid === i.uuid))
2890
2837
  throw new Error(`duplicate uuid in options ${i.uuid}, DataAttributives`);
2891
2838
  return this.instances.push(i), i;
@@ -2916,20 +2863,20 @@ class Ut {
2916
2863
  return this.create(e.public, e.options);
2917
2864
  }
2918
2865
  }
2919
- const Qe = [
2866
+ const Ve = [
2920
2867
  I,
2921
2868
  P,
2922
2869
  v,
2923
- Qt,
2924
2870
  Lt,
2925
- U,
2926
2871
  qt,
2872
+ U,
2927
2873
  Bt,
2928
- vt,
2929
- tt,
2930
2874
  _t,
2931
- K,
2875
+ kt,
2876
+ tt,
2932
2877
  Wt,
2878
+ K,
2879
+ Jt,
2933
2880
  st,
2934
2881
  at,
2935
2882
  ot,
@@ -2937,21 +2884,21 @@ const Qe = [
2937
2884
  ct,
2938
2885
  lt,
2939
2886
  ut,
2940
- kt,
2887
+ Tt,
2941
2888
  dt,
2942
- Jt,
2943
2889
  Ht,
2944
2890
  jt,
2945
- Vt,
2891
+ Ut,
2892
+ Qt,
2946
2893
  it,
2947
2894
  rt,
2948
- Tt,
2949
- Ut
2895
+ At,
2896
+ Kt
2950
2897
  ];
2951
- Qe.forEach((u) => {
2952
- u && u.displayName && Ce(u.displayName, u);
2898
+ Ve.forEach((u) => {
2899
+ u && u.displayName && Ie(u.displayName, u);
2953
2900
  });
2954
- class Kt {
2901
+ class Gt {
2955
2902
  constructor(t, e) {
2956
2903
  this._type = "Custom", this._options = e, this.uuid = k(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.getInitialValue = t.getInitialValue, this.asyncReturn = t.asyncReturn, this.useLastValue = t.useLastValue;
2957
2904
  }
@@ -3014,7 +2961,7 @@ class Kt {
3014
2961
  };
3015
2962
  }
3016
2963
  static create(t, e) {
3017
- const i = new Kt(t, e);
2964
+ const i = new Gt(t, e);
3018
2965
  if (this.instances.find((s) => s.uuid === i.uuid))
3019
2966
  throw new Error(`duplicate uuid in options ${i.uuid}, Custom`);
3020
2967
  return this.instances.push(i), i;
@@ -3058,7 +3005,7 @@ class Kt {
3058
3005
  }), this.create(i, e.options);
3059
3006
  }
3060
3007
  }
3061
- class ye {
3008
+ class me {
3062
3009
  constructor(t = [], e = []) {
3063
3010
  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();
3064
3011
  }
@@ -3269,7 +3216,7 @@ class ye {
3269
3216
  return null;
3270
3217
  }
3271
3218
  }
3272
- function yr({ name: u, isRef: t = !1 }, e) {
3219
+ function mr({ name: u, isRef: t = !1 }, e) {
3273
3220
  return U.create({
3274
3221
  name: u,
3275
3222
  content: u ? new Function("user", `return user.roles.includes('${u}')`) : function() {
@@ -3282,7 +3229,7 @@ function g(u, t) {
3282
3229
  if (!u)
3283
3230
  throw new Error(t);
3284
3231
  }
3285
- function St(u, t, e) {
3232
+ function Et(u, t, e) {
3286
3233
  const i = [...t];
3287
3234
  let r = u, s;
3288
3235
  const a = i.pop();
@@ -3642,7 +3589,7 @@ class m {
3642
3589
  );
3643
3590
  }
3644
3591
  }
3645
- class Le {
3592
+ class Qe {
3646
3593
  constructor(t, e, i, r) {
3647
3594
  this.recordName = t, this.map = e, this.data = i, this.fromRelation = r;
3648
3595
  }
@@ -3678,7 +3625,7 @@ class x {
3678
3625
  e,
3679
3626
  N,
3680
3627
  new C(h, e, i.attributeQuery || [], s, a),
3681
- new Le(h, e, i.modifier),
3628
+ new Qe(h, e, i.modifier),
3682
3629
  r,
3683
3630
  s,
3684
3631
  a,
@@ -3772,7 +3719,7 @@ class L {
3772
3719
  }), this.parentLinkQueryTree && (t[f] = this.parentLinkQueryTree.getData()), t;
3773
3720
  }
3774
3721
  }
3775
- const f = "&", qe = "*";
3722
+ const f = "&", Le = "*";
3776
3723
  class C {
3777
3724
  constructor(t, e, i = [], r, s, a) {
3778
3725
  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();
@@ -3785,7 +3732,7 @@ class C {
3785
3732
  this.parentLinkRecordQuery = x.create(y.linkName, this.map, d, void 0);
3786
3733
  return;
3787
3734
  }
3788
- if (l === qe) {
3735
+ if (l === Le) {
3789
3736
  o = new Set(this.map.getRecordInfo(this.recordName).valueAttributes.map((y) => y.attributeName));
3790
3737
  return;
3791
3738
  }
@@ -3794,10 +3741,10 @@ class C {
3794
3741
  let y = l, N = d;
3795
3742
  if (p.isLinkFiltered()) {
3796
3743
  y = p.getBaseAttributeInfo().attributeName;
3797
- const A = d.matchExpression, D = p.getLinkInfo().getBaseLinkInfo(), te = new m(D.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), Se = A ? te.and(A.data) : te;
3744
+ const A = d.matchExpression, D = p.getLinkInfo().getBaseLinkInfo(), te = new m(D.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), Ae = A ? te.and(A.data) : te;
3798
3745
  N = {
3799
3746
  ...d,
3800
- matchExpression: Se.data
3747
+ matchExpression: Ae.data
3801
3748
  };
3802
3749
  }
3803
3750
  const b = x.create(p.recordName, this.map, N, void 0, this.recordName, y, h, !1, l);
@@ -3915,7 +3862,7 @@ class C {
3915
3862
  return this.parentLinkRecordQuery ? new C(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
3916
3863
  }
3917
3864
  }
3918
- function Be(u) {
3865
+ function qe(u) {
3919
3866
  const t = [];
3920
3867
  return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
3921
3868
  }
@@ -3925,7 +3872,7 @@ class Q {
3925
3872
  const s = this.map.getRecordInfo(e);
3926
3873
  this.recordName = s.isFilteredEntity || s.isFilteredRelation ? s.resolvedBaseRecordName : e;
3927
3874
  const [a, o, n] = this.map.groupAttributes(this.recordName, i ? Object.keys(i) : []);
3928
- this.relatedEntitiesData = Be(o.map(
3875
+ this.relatedEntitiesData = qe(o.map(
3929
3876
  (l) => Array.isArray(i[l.attributeName]) ? i[l.attributeName].map((d) => new Q(this.map, l.recordName, d, l)) : new Q(this.map, l.recordName, i[l.attributeName], l)
3930
3877
  )), this.valueAttributes = a, this.entityIdAttributes = n;
3931
3878
  const c = this.map.getRecordInfo(this.recordName);
@@ -4002,7 +3949,7 @@ class Q {
4002
3949
  }), i;
4003
3950
  }
4004
3951
  }
4005
- class _e {
3952
+ class Be {
4006
3953
  constructor(t, e) {
4007
3954
  this.map = t, this.queryAgent = e, this.dependencies = /* @__PURE__ */ new Map();
4008
3955
  }
@@ -4228,7 +4175,7 @@ class _e {
4228
4175
  }
4229
4176
  }
4230
4177
  }
4231
- class We {
4178
+ class _e {
4232
4179
  constructor() {
4233
4180
  this.aliasToPath = /* @__PURE__ */ new Map(), this.pathStrToAlias = /* @__PURE__ */ new Map(), this.aliasPlaceholder = 0;
4234
4181
  }
@@ -4242,24 +4189,24 @@ class We {
4242
4189
  return this.aliasToPath.get(t);
4243
4190
  }
4244
4191
  }
4245
- const ge = ":root";
4246
- class gt {
4192
+ const ye = ":root";
4193
+ class bt {
4247
4194
  constructor(t, e, i = []) {
4248
4195
  this.label = t, this.parent = e, this.stack = i;
4249
4196
  }
4250
4197
  concat(t) {
4251
- return new gt(this.label, this.parent, [...this.stack, t]);
4198
+ return new bt(this.label, this.parent, [...this.stack, t]);
4252
4199
  }
4253
4200
  getStack(t) {
4254
4201
  return [...this.stack];
4255
4202
  }
4256
4203
  spawn(t) {
4257
- return new gt(t, this);
4204
+ return new bt(t, this);
4258
4205
  }
4259
4206
  }
4260
- class Je {
4207
+ class We {
4261
4208
  constructor(t) {
4262
- this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(ge, t), this.recursiveSaveLabelledRecordQuery(t);
4209
+ this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(ye, t), this.recursiveSaveLabelledRecordQuery(t);
4263
4210
  }
4264
4211
  recursiveSaveLabelledRecordQuery(t) {
4265
4212
  t.attributeQuery?.relatedRecords.forEach((e) => {
@@ -4273,9 +4220,9 @@ class Je {
4273
4220
  return this.recordQueryByName.get(t);
4274
4221
  }
4275
4222
  }
4276
- class He {
4223
+ class Je {
4277
4224
  constructor(t, e) {
4278
- this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new _e(t, this), this.initializeFilteredEntityDependencies();
4225
+ this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new Be(t, this), this.initializeFilteredEntityDependencies();
4279
4226
  }
4280
4227
  /**
4281
4228
  * 初始化所有 filtered entity 的依赖关系
@@ -4327,80 +4274,80 @@ ${b}
4327
4274
  const s = {};
4328
4275
  return Object.entries(r).forEach(([a, o]) => {
4329
4276
  const n = i.getPath(a).slice(1, 1 / 0);
4330
- n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && St(s, n, o);
4277
+ n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && Et(s, n, o);
4331
4278
  }), s;
4332
4279
  });
4333
4280
  }
4334
4281
  // 查 entity 和 查 relation 都是一样的。具体在 entityQuery 里面区别。
4335
4282
  // TODO 为了性能,也可以把信息丢到客户端,然客户端去结构化???
4336
4283
  // CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
4337
- async findRecords(t, e = "", i, r = new gt(ge)) {
4338
- if (i || (i = new Je(t)), t.goto) {
4284
+ async findRecords(t, e = "", i, r = new bt(ye)) {
4285
+ if (i || (i = new We(t)), t.goto) {
4339
4286
  if (t.exit && await t.exit(r))
4340
4287
  return [];
4341
- const l = i.get(t.goto);
4342
- g(l, `goto ${t.goto} not found`);
4343
- const d = t.matchExpression.and(l.matchExpression), h = l.derive({
4344
- matchExpression: d
4288
+ const d = i.get(t.goto);
4289
+ g(d, `goto ${t.goto} not found`);
4290
+ const h = t.matchExpression.and(d.matchExpression), p = d.derive({
4291
+ matchExpression: h
4345
4292
  });
4346
- return this.findRecords(h, e, i, r);
4293
+ return this.findRecords(p, e, i, r);
4347
4294
  }
4348
4295
  if (t.label && r.label === t.label && r.stack.length > 1 && r.stack[0].id === r.stack.at(-1).id)
4349
4296
  return [];
4350
- const [s, a, o] = this.buildXToOneFindQuery(t, ""), n = this.structureRawReturns(await this.database.query(s, a, e), this.map.getRecordInfo(t.recordName).JSONFields, o), c = t.label && t.label !== r.label ? r.spawn(t.label) : r;
4351
- this.completeXToOneLeftoverRecords(t, n, i, c);
4352
- for (let l of t.attributeQuery.xToOneRecords)
4353
- if (l.goto) {
4354
- const h = this.map.getInfo(l.parentRecord, l.attributeName).getReverseInfo()?.attributeName;
4355
- for (let p of n) {
4356
- const y = l.matchExpression.and({
4357
- key: `${h}.id`,
4358
- value: ["=", p.id]
4359
- }), N = l.derive({
4360
- matchExpression: y
4361
- }), b = t.label ? c.concat(p) : c;
4362
- p[l.alias || l.attributeName] = await this.findRecords(N, e, i, b);
4297
+ const [s, a, o] = this.buildXToOneFindQuery(t, ""), n = await this.database.query(s, a, e), c = this.structureRawReturns(n, this.map.getRecordInfo(t.recordName).JSONFields, o), l = t.label && t.label !== r.label ? r.spawn(t.label) : r;
4298
+ await this.completeXToOneLeftoverRecords(t, c, i, l);
4299
+ for (let d of t.attributeQuery.xToOneRecords)
4300
+ if (d.goto) {
4301
+ const p = this.map.getInfo(d.parentRecord, d.attributeName).getReverseInfo()?.attributeName;
4302
+ for (let y of c) {
4303
+ const N = d.matchExpression.and({
4304
+ key: `${p}.id`,
4305
+ value: ["=", y.id]
4306
+ }), b = d.derive({
4307
+ matchExpression: N
4308
+ }), A = t.label ? l.concat(y) : l;
4309
+ y[d.alias || d.attributeName] = await this.findRecords(b, e, i, A);
4363
4310
  }
4364
4311
  }
4365
- for (let l of t.attributeQuery.xToOneRecords) {
4366
- const d = l.attributeQuery.parentLinkRecordQuery;
4367
- if (d)
4368
- for (let h of d.attributeQuery.xToManyRecords) {
4369
- const y = this.map.getInfo(h.parentRecord, h.attributeName).getReverseInfo()?.attributeName;
4370
- for (let N of n) {
4371
- const b = N[l.attributeName][f].id, A = h.derive({
4372
- matchExpression: h.matchExpression.and({
4373
- key: `${y}.id`,
4374
- value: ["=", b]
4312
+ for (let d of t.attributeQuery.xToOneRecords) {
4313
+ const h = d.attributeQuery.parentLinkRecordQuery;
4314
+ if (h)
4315
+ for (let p of h.attributeQuery.xToManyRecords) {
4316
+ const N = this.map.getInfo(p.parentRecord, p.attributeName).getReverseInfo()?.attributeName;
4317
+ for (let b of c) {
4318
+ const A = b[d.attributeName][f].id, D = p.derive({
4319
+ matchExpression: p.matchExpression.and({
4320
+ key: `${N}.id`,
4321
+ value: ["=", A]
4375
4322
  })
4376
- }), D = t.label ? c.concat(N) : c;
4377
- St(
4378
- N,
4379
- [l.alias || l.attributeName, f, h.attributeName],
4323
+ }), ft = t.label ? l.concat(b) : l;
4324
+ Et(
4325
+ b,
4326
+ [d.alias || d.attributeName, f, p.attributeName],
4380
4327
  await this.findRecords(
4381
- A,
4382
- `finding relation data: ${t.recordName}.${l.attributeName}.&.${h.attributeName}`,
4328
+ D,
4329
+ `finding relation data: ${t.recordName}.${d.attributeName}.&.${p.attributeName}`,
4383
4330
  i,
4384
- D
4331
+ ft
4385
4332
  )
4386
4333
  );
4387
4334
  }
4388
4335
  }
4389
4336
  }
4390
- for (let l of t.attributeQuery.xToManyRecords)
4391
- if (!l.onlyRelationData)
4392
- for (let d of n) {
4393
- const h = t.label ? c.concat(d) : c;
4394
- d[l.alias || l.attributeName] = await this.findXToManyRelatedRecords(
4337
+ for (let d of t.attributeQuery.xToManyRecords)
4338
+ if (!d.onlyRelationData)
4339
+ for (let h of c) {
4340
+ const p = t.label ? l.concat(h) : l;
4341
+ h[d.alias || d.attributeName] = await this.findXToManyRelatedRecords(
4395
4342
  t.recordName,
4396
- l.attributeName,
4397
- d.id,
4398
- l,
4343
+ d.attributeName,
4344
+ h.id,
4345
+ d,
4399
4346
  i,
4400
- h
4347
+ p
4401
4348
  );
4402
4349
  }
4403
- return n;
4350
+ return c;
4404
4351
  }
4405
4352
  async completeXToOneLeftoverRecords(t, e, i, r) {
4406
4353
  if (t.attributeQuery.parentLinkRecordQuery) {
@@ -4422,6 +4369,8 @@ ${b}
4422
4369
  for (let s of t.attributeQuery.xToOneRecords) {
4423
4370
  for (let a of s.attributeQuery.xToManyRecords)
4424
4371
  for (let o of e) {
4372
+ if (!o[s.attributeName])
4373
+ continue;
4425
4374
  const n = t.label ? r.concat(o) : r;
4426
4375
  o[s.attributeName][a.attributeName] = await this.findXToManyRelatedRecords(
4427
4376
  a.parentRecord,
@@ -4461,8 +4410,8 @@ ${b}
4461
4410
  if (N)
4462
4411
  for (let b of N.attributeQuery.xToManyRecords)
4463
4412
  for (let A of p) {
4464
- const D = A[f].id, Zt = d.label ? y.concat(A) : y;
4465
- St(
4413
+ const D = A[f].id, ft = d.label ? y.concat(A) : y;
4414
+ Et(
4466
4415
  A,
4467
4416
  [f, b.attributeName],
4468
4417
  await this.findXToManyRelatedRecords(
@@ -4471,7 +4420,7 @@ ${b}
4471
4420
  D,
4472
4421
  b,
4473
4422
  s,
4474
- Zt
4423
+ ft
4475
4424
  )
4476
4425
  );
4477
4426
  }
@@ -4544,7 +4493,7 @@ ${b}
4544
4493
  return t ? `${t}___` : "";
4545
4494
  }
4546
4495
  buildSelectClause(t, e = "") {
4547
- const i = new We();
4496
+ const i = new _e();
4548
4497
  return t.length ? [t.map(({ tableAliasAndField: s, attribute: a, nameContext: o }) => {
4549
4498
  const n = [
4550
4499
  `${this.withPrefix(e)}${o[0]}`,
@@ -5116,9 +5065,9 @@ WHERE "${s.idField}" = ${l()}
5116
5065
  return p ? [N, ...p] : void 0;
5117
5066
  }
5118
5067
  }
5119
- class je {
5068
+ class He {
5120
5069
  constructor(t, e) {
5121
- this.map = t, this.database = e, this.agent = new He(t, e);
5070
+ this.map = t, this.database = e, this.agent = new Je(t, e);
5122
5071
  }
5123
5072
  async findOne(t, e, i = {}, r) {
5124
5073
  const s = {
@@ -5276,7 +5225,7 @@ class et {
5276
5225
  return this.data?.resolvedMatchExpression;
5277
5226
  }
5278
5227
  }
5279
- class bt {
5228
+ class Rt {
5280
5229
  constructor(t, e, i, r = !0) {
5281
5230
  this.name = t, this.data = e, this.map = i, this.isFromSource = r;
5282
5231
  }
@@ -5364,7 +5313,7 @@ class bt {
5364
5313
  getBaseLinkInfo() {
5365
5314
  g(this.isFilteredRelation(), "only filtered relation can get base link info");
5366
5315
  const t = this.data.baseLinkName;
5367
- return new bt(t, this.map.data.links[t], this.map);
5316
+ return new Rt(t, this.map.data.links[t], this.map);
5368
5317
  }
5369
5318
  getMatchExpression() {
5370
5319
  if (this.isFilteredRelation())
@@ -5378,7 +5327,7 @@ class bt {
5378
5327
  return g(this.isFilteredRelation(), "only filtered relation can get resolved record name"), this.data.resolvedBaseRecordName;
5379
5328
  }
5380
5329
  }
5381
- class Ue {
5330
+ class je {
5382
5331
  constructor(t) {
5383
5332
  this.data = t;
5384
5333
  }
@@ -5403,10 +5352,10 @@ class Ue {
5403
5352
  }
5404
5353
  getLinkInfo(t, e) {
5405
5354
  const i = this.getAttributeAndSymmetricDirection(e)[0], { linkName: r, isSource: s } = this.data.records[t].attributes[i];
5406
- return g(!!r, `cannot find relation ${t} ${i}`), new bt(r, this.data.links[r], this, !!s);
5355
+ return g(!!r, `cannot find relation ${t} ${i}`), new Rt(r, this.data.links[r], this, !!s);
5407
5356
  }
5408
5357
  getLinkInfoByName(t) {
5409
- return g(!!this.data.links[t], `cannot find link ${t}`), new bt(t, this.data.links[t], this);
5358
+ return g(!!this.data.links[t], `cannot find link ${t}`), new Rt(t, this.data.links[t], this);
5410
5359
  }
5411
5360
  getInfoByPath(t) {
5412
5361
  const [e, ...i] = t;
@@ -5574,7 +5523,7 @@ class Ue {
5574
5523
  return r.join(".");
5575
5524
  }
5576
5525
  }
5577
- function Ke(u) {
5526
+ function Ue(u) {
5578
5527
  const t = /* @__PURE__ */ new Map();
5579
5528
  for (const e of u)
5580
5529
  if (e.inputEntities)
@@ -5585,7 +5534,7 @@ function Ke(u) {
5585
5534
  }
5586
5535
  return t;
5587
5536
  }
5588
- function Ge(u) {
5537
+ function Ke(u) {
5589
5538
  const t = /* @__PURE__ */ new Map();
5590
5539
  for (const e of u) {
5591
5540
  const i = e.name || `${e.source.name}_${e.sourceProperty}_${e.targetProperty}_${e.target.name}`;
@@ -5599,8 +5548,8 @@ function Ge(u) {
5599
5548
  }
5600
5549
  return t;
5601
5550
  }
5602
- function Xe(u, t) {
5603
- const e = new ye(u, t), i = Ke(u), r = Ge(t);
5551
+ function Ge(u, t) {
5552
+ const e = new me(u, t), i = Ue(u), r = Ke(t);
5604
5553
  return ee(
5605
5554
  u,
5606
5555
  e,
@@ -5620,15 +5569,15 @@ function ee(u, t, e, i) {
5620
5569
  });
5621
5570
  if (r.length !== 0)
5622
5571
  for (const s of r)
5623
- ze(
5572
+ Xe(
5624
5573
  s,
5625
5574
  t,
5626
5575
  i,
5627
5576
  e
5628
5577
  );
5629
5578
  }
5630
- function ze(u, t, e, i) {
5631
- const r = e === "entity", a = `__${G(u)}_input_${e}`, o = r ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = ii(
5579
+ function Xe(u, t, e, i) {
5580
+ const r = e === "entity", a = `__${G(u)}_input_${e}`, o = r ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = ei(
5632
5581
  o,
5633
5582
  a,
5634
5583
  i,
@@ -5638,7 +5587,7 @@ function ze(u, t, e, i) {
5638
5587
  const l = pt(u);
5639
5588
  if (l)
5640
5589
  for (const d of l)
5641
- Ye(
5590
+ ze(
5642
5591
  d,
5643
5592
  c,
5644
5593
  a,
@@ -5646,8 +5595,8 @@ function ze(u, t, e, i) {
5646
5595
  r
5647
5596
  );
5648
5597
  }
5649
- function Ye(u, t, e, i, r) {
5650
- const [s, a] = ri(
5598
+ function ze(u, t, e, i, r) {
5599
+ const [s, a] = ii(
5651
5600
  u,
5652
5601
  t,
5653
5602
  e
@@ -5657,7 +5606,7 @@ function Ye(u, t, e, i, r) {
5657
5606
  const o = G(a), n = r ? i.getEntityByName(o) : i.getRelationByName(o);
5658
5607
  n && i.replace(s, n);
5659
5608
  }
5660
- function Ze(u, t) {
5609
+ function Ye(u, t) {
5661
5610
  const e = /* @__PURE__ */ new Map(), i = pt(u);
5662
5611
  if (i && i.length > 0)
5663
5612
  for (const r of i) {
@@ -5671,8 +5620,8 @@ function Ze(u, t) {
5671
5620
  }
5672
5621
  return e;
5673
5622
  }
5674
- function ti(u, t, e) {
5675
- const i = Ze(t, e);
5623
+ function Ze(u, t, e) {
5624
+ const i = Ye(t, e);
5676
5625
  return v.create({
5677
5626
  name: u,
5678
5627
  type: "json",
@@ -5684,14 +5633,14 @@ function ti(u, t, e) {
5684
5633
  }
5685
5634
  });
5686
5635
  }
5687
- function ei(u, t, e) {
5636
+ function ti(u, t, e) {
5688
5637
  const i = pt(u), r = [], s = /* @__PURE__ */ new Map(), a = {};
5689
5638
  for (const o of i) {
5690
5639
  let n = o;
5691
5640
  if (ht(n))
5692
5641
  for (; n.baseEntity && n.properties.length === 0; )
5693
5642
  n = n.baseEntity;
5694
- else if (ai(n))
5643
+ else if (si(n))
5695
5644
  for (; n.baseRelation && n.properties.length === 0; )
5696
5645
  n = n.baseRelation;
5697
5646
  const c = Object.fromEntries(n.properties.map((h) => [h.name, h]));
@@ -5721,13 +5670,13 @@ function ei(u, t, e) {
5721
5670
  }
5722
5671
  return r;
5723
5672
  }
5724
- function ii(u, t, e, i) {
5725
- const r = ti(
5673
+ function ei(u, t, e, i) {
5674
+ const r = Ze(
5726
5675
  t,
5727
5676
  u,
5728
5677
  e
5729
5678
  ), s = [
5730
- ...ei(
5679
+ ...ti(
5731
5680
  u,
5732
5681
  e,
5733
5682
  i
@@ -5785,7 +5734,7 @@ function ii(u, t, e, i) {
5785
5734
  return [o, n || o];
5786
5735
  }
5787
5736
  }
5788
- function ri(u, t, e) {
5737
+ function ii(u, t, e) {
5789
5738
  if (ht(u)) {
5790
5739
  const i = u, r = t;
5791
5740
  let s = i;
@@ -5799,7 +5748,7 @@ function ri(u, t, e) {
5799
5748
  }), [a, s];
5800
5749
  } else {
5801
5750
  const i = u, r = t, s = G(i);
5802
- return i.baseRelation ? [i, si(i)] : [P.create({
5751
+ return i.baseRelation ? [i, ri(i)] : [P.create({
5803
5752
  name: s,
5804
5753
  baseRelation: r,
5805
5754
  sourceProperty: i.sourceProperty,
@@ -5811,7 +5760,7 @@ function ri(u, t, e) {
5811
5760
  }), i];
5812
5761
  }
5813
5762
  }
5814
- function si(u) {
5763
+ function ri(u) {
5815
5764
  let t = u;
5816
5765
  for (; t.baseRelation; )
5817
5766
  t = t.baseRelation;
@@ -5820,7 +5769,7 @@ function si(u) {
5820
5769
  function ht(u) {
5821
5770
  return "inputEntities" in u || !("sourceProperty" in u);
5822
5771
  }
5823
- function ai(u) {
5772
+ function si(u) {
5824
5773
  return "sourceProperty" in u;
5825
5774
  }
5826
5775
  function pt(u) {
@@ -5829,7 +5778,7 @@ function pt(u) {
5829
5778
  function G(u) {
5830
5779
  return ht(u), u.name;
5831
5780
  }
5832
- class oi {
5781
+ class ai {
5833
5782
  constructor(t, e, i, r = []) {
5834
5783
  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();
5835
5784
  }
@@ -6108,7 +6057,7 @@ class oi {
6108
6057
  * 统一处理 merged entities 和 merged relations
6109
6058
  */
6110
6059
  processMergedItems() {
6111
- const t = Xe(
6060
+ const t = Ge(
6112
6061
  this.entities,
6113
6062
  this.relations
6114
6063
  );
@@ -6222,7 +6171,7 @@ ${Object.values(this.tables[t].columns).map((i) => ` "${i.name}" ${i.fieldTyp
6222
6171
  return this.fieldCounter++, this.fieldNameMap.set(t, r), this.usedFieldNames.add(r), r;
6223
6172
  }
6224
6173
  }
6225
- const X = "_System_", q = "_Dictionary_", ie = "id", re = "_rowId", ni = I.create({
6174
+ const X = "_System_", q = "_Dictionary_", ie = "id", re = "_rowId", oi = I.create({
6226
6175
  name: X,
6227
6176
  properties: [
6228
6177
  v.create({
@@ -6241,7 +6190,7 @@ const X = "_System_", q = "_Dictionary_", ie = "id", re = "_rowId", ni = I.creat
6241
6190
  collection: !1
6242
6191
  })
6243
6192
  ]
6244
- }), ci = I.create({
6193
+ }), ni = I.create({
6245
6194
  name: q,
6246
6195
  properties: [
6247
6196
  v.create({
@@ -6255,8 +6204,8 @@ const X = "_System_", q = "_Dictionary_", ie = "id", re = "_rowId", ni = I.creat
6255
6204
  collection: !1
6256
6205
  })
6257
6206
  ]
6258
- }), gr = 0, Et = 1, br = 2;
6259
- class li {
6207
+ }), yr = 0, It = 1, gr = 2;
6208
+ class ci {
6260
6209
  constructor(t, e) {
6261
6210
  this.controller = t, this.scheduler = e, this.sourceMaps = [], this.sourceMapTree = {};
6262
6211
  }
@@ -6270,18 +6219,18 @@ class li {
6270
6219
  if (this.scheduler.isDataBasedComputation(i)) {
6271
6220
  if (Object.entries(i.dataDeps).forEach(([r, s]) => {
6272
6221
  const a = this.convertDataDepToERMutationEventsSourceMap(r, s, i);
6273
- e[s.phase || Et].push(...a);
6222
+ e[s.phase || It].push(...a);
6274
6223
  }), i.dataContext.type === "property" && Object.values(i.dataDeps).some((r) => r.type === "global")) {
6275
6224
  const r = {
6276
6225
  type: "records",
6277
6226
  source: i.dataContext.host
6278
6227
  };
6279
- e[Et].push(...this.convertDataDepToERMutationEventsSourceMap("_self", r, i, "create"));
6228
+ e[It].push(...this.convertDataDepToERMutationEventsSourceMap("_self", r, i, "create"));
6280
6229
  }
6281
6230
  } else {
6282
6231
  const { eventDeps: r } = i;
6283
6232
  for (const s of Object.values(r))
6284
- e[s.phase || Et].push({
6233
+ e[s.phase || It].push({
6285
6234
  type: s.type,
6286
6235
  recordName: s.recordName,
6287
6236
  record: s.record,
@@ -6483,31 +6432,31 @@ class li {
6483
6432
  }
6484
6433
  class S {
6485
6434
  static {
6486
- this.skip = () => new Rt();
6435
+ this.skip = () => new wt();
6487
6436
  }
6488
6437
  static {
6489
- this.resolved = (t, e) => new we(t, e);
6438
+ this.resolved = (t, e) => new Re(t, e);
6490
6439
  }
6491
6440
  static {
6492
- this.async = (t) => new Re(t);
6441
+ this.async = (t) => new be(t);
6493
6442
  }
6494
6443
  static {
6495
- this.fullRecompute = (t) => new be(t);
6444
+ this.fullRecompute = (t) => new ge(t);
6496
6445
  }
6497
6446
  }
6498
- class Rt extends S {
6447
+ class wt extends S {
6499
6448
  }
6500
- class be extends S {
6449
+ class ge extends S {
6501
6450
  constructor(t) {
6502
6451
  super(), this.reason = t;
6503
6452
  }
6504
6453
  }
6505
- class Re extends S {
6454
+ class be extends S {
6506
6455
  constructor(t) {
6507
6456
  super(), this.args = t;
6508
6457
  }
6509
6458
  }
6510
- class we extends S {
6459
+ class Re extends S {
6511
6460
  constructor(t, e) {
6512
6461
  super(), this.result = t, this.args = e;
6513
6462
  }
@@ -6538,18 +6487,18 @@ class B {
6538
6487
  return await this.controller.system.storage.dict.get(this.key);
6539
6488
  }
6540
6489
  }
6541
- function Pt(u, t) {
6490
+ function $t(u, t) {
6542
6491
  if (t == null || u === t) return !0;
6543
6492
  if (typeof t != "object" || t === null)
6544
6493
  return u === t;
6545
6494
  if (typeof u != "object" || u === null)
6546
6495
  return !1;
6547
6496
  for (const e in t)
6548
- if (!(e in u) || !Pt(u[e], t[e]))
6497
+ if (!(e in u) || !$t(u[e], t[e]))
6549
6498
  return !1;
6550
6499
  return !0;
6551
6500
  }
6552
- class Ne {
6501
+ class we {
6553
6502
  constructor(t) {
6554
6503
  this.data = t, this.map = {};
6555
6504
  for (const e of t.transfers)
@@ -6562,45 +6511,45 @@ class Ne {
6562
6511
  const i = this.map[t];
6563
6512
  if (i) {
6564
6513
  for (const r of i)
6565
- if (Pt(e, r.trigger))
6514
+ if ($t(e, r.trigger))
6566
6515
  return r.next;
6567
6516
  }
6568
6517
  return null;
6569
6518
  }
6570
6519
  findTransfers(t) {
6571
- return this.data.transfers.filter((e) => Pt(t, e.trigger));
6520
+ return this.data.transfers.filter((e) => $t(t, e.trigger));
6572
6521
  }
6573
6522
  }
6574
6523
  function T(u, t) {
6575
6524
  if (!u)
6576
6525
  throw new Error(t);
6577
6526
  }
6578
- function Rr(u, t) {
6527
+ function br(u, t) {
6579
6528
  return new Map(Array.from(u.entries()).map(([e, i]) => [e, t(e, i)]));
6580
6529
  }
6581
- function wr(u, t) {
6530
+ function Rr(u, t) {
6582
6531
  return Object.fromEntries(Object.entries(u).map(([e, i]) => [e, t(e, i)]));
6583
6532
  }
6584
- async function Nr(u, t) {
6533
+ async function wr(u, t) {
6585
6534
  for (let e of u)
6586
6535
  if (!await t(e)) return !1;
6587
6536
  return !0;
6588
6537
  }
6589
- async function ui(u, t) {
6538
+ async function li(u, t) {
6590
6539
  for (let e of u)
6591
6540
  if (await t(e)) return !0;
6592
6541
  return !1;
6593
6542
  }
6594
- async function di(u, t) {
6543
+ async function ui(u, t) {
6595
6544
  for (let e of u) {
6596
6545
  const i = await t(e);
6597
6546
  if (i !== !0) return i;
6598
6547
  }
6599
6548
  return !0;
6600
6549
  }
6601
- class hi {
6550
+ class di {
6602
6551
  constructor(t, e, i) {
6603
- this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ne(this.args), this.initialState = this.args.initialState;
6552
+ this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new we(this.args), this.initialState = this.args.initialState;
6604
6553
  for (const r of this.args.transfers) {
6605
6554
  const s = `${r.trigger.recordName}_${r.trigger.type}`;
6606
6555
  this.eventDeps[s] = {
@@ -6628,9 +6577,9 @@ class hi {
6628
6577
  return s ? (await this.state.currentState.set(s.name), s.computeValue ? await s.computeValue.call(this.controller, t, e) : s.name) : S.skip();
6629
6578
  }
6630
6579
  }
6631
- class pi {
6580
+ class hi {
6632
6581
  constructor(t, e, i) {
6633
- this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ne(this.args), this.initialState = this.args.initialState, this.dataContext = i;
6582
+ this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new we(this.args), this.initialState = this.args.initialState, this.dataContext = i;
6634
6583
  for (const r of this.args.transfers) {
6635
6584
  const s = `${r.trigger.recordName}_${r.trigger.type}`;
6636
6585
  this.eventDeps[s] = {
@@ -6675,17 +6624,17 @@ Or if you want to use state name as value, you should not set ${this.dataContext
6675
6624
  };
6676
6625
  }
6677
6626
  }
6678
- const vr = K.create({
6627
+ const Nr = K.create({
6679
6628
  name: "nonExistent",
6680
6629
  computeValue: () => null
6681
- }), kr = K.create({
6630
+ }), vr = K.create({
6682
6631
  name: "nonDeleted",
6683
6632
  computeValue: () => !1
6684
- }), Tr = K.create({
6633
+ }), kr = K.create({
6685
6634
  name: "deleted",
6686
6635
  computeValue: () => !0
6687
- }), fi = [hi, pi];
6688
- class mi {
6636
+ }), pi = [di, hi];
6637
+ class fi {
6689
6638
  constructor(t, e, i) {
6690
6639
  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 = {
6691
6640
  main: {
@@ -6738,7 +6687,7 @@ class mi {
6738
6687
  return i;
6739
6688
  }
6740
6689
  }
6741
- class yi {
6690
+ class mi {
6742
6691
  constructor(t, e, i) {
6743
6692
  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), T(this.relation, "weighted summation computation must specify property"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, T(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;
6744
6693
  const r = this.args.attributeQuery || [];
@@ -6814,8 +6763,8 @@ class yi {
6814
6763
  return s;
6815
6764
  }
6816
6765
  }
6817
- const gi = [mi, yi];
6818
- class bi {
6766
+ const yi = [fi, mi];
6767
+ class gi {
6819
6768
  constructor(t, e, i) {
6820
6769
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.dataDeps = {
6821
6770
  main: {
@@ -6868,7 +6817,7 @@ class bi {
6868
6817
  return a === s;
6869
6818
  }
6870
6819
  }
6871
- class Ri {
6820
+ class bi {
6872
6821
  constructor(t, e, i) {
6873
6822
  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, T(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;
6874
6823
  const r = this.args.attributeQuery || [];
@@ -6942,8 +6891,8 @@ class Ri {
6942
6891
  return a === o;
6943
6892
  }
6944
6893
  }
6945
- const wi = [bi, Ri];
6946
- class Ni {
6894
+ const Ri = [gi, bi];
6895
+ class wi {
6947
6896
  constructor(t, e, i) {
6948
6897
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.dataDeps = {
6949
6898
  main: {
@@ -6996,7 +6945,7 @@ class Ni {
6996
6945
  return s > 0;
6997
6946
  }
6998
6947
  }
6999
- class vi {
6948
+ class Ni {
7000
6949
  constructor(t, e, i) {
7001
6950
  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), T(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, T(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "any computation relation direction error");
7002
6951
  let r = this.relation.baseRelation || this.relation;
@@ -7072,8 +7021,8 @@ class vi {
7072
7021
  return s > 0;
7073
7022
  }
7074
7023
  }
7075
- const ki = [Ni, vi];
7076
- class Ti {
7024
+ const vi = [wi, Ni];
7025
+ class ki {
7077
7026
  constructor(t, e, i) {
7078
7027
  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 = {
7079
7028
  main: {
@@ -7123,7 +7072,7 @@ class Ti {
7123
7072
  return s = Math.max(0, s), await this.state.count.set(s), s;
7124
7073
  }
7125
7074
  }
7126
- class Ai {
7075
+ class Ti {
7127
7076
  constructor(t, e, i) {
7128
7077
  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, T(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;
7129
7078
  const r = this.args.attributeQuery || [];
@@ -7205,8 +7154,8 @@ class Ai {
7205
7154
  return a;
7206
7155
  }
7207
7156
  }
7208
- const Si = [Ti, Ai];
7209
- class Ei {
7157
+ const Ai = [ki, Ti];
7158
+ class Si {
7210
7159
  constructor(t, e, i) {
7211
7160
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, T(!(this.args.record && this.args.eventDeps), "Transform must have either record or eventDep"), T(!(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 : (T(this.args.dataDeps?._source === void 0, "dataDep name `_source` is reserved for Transform"), this.dataDeps = {
7212
7161
  ...this.args.dataDeps || {},
@@ -7218,7 +7167,7 @@ class Ei {
7218
7167
  });
7219
7168
  }
7220
7169
  static {
7221
- this.computationType = kt;
7170
+ this.computationType = Tt;
7222
7171
  }
7223
7172
  static {
7224
7173
  this.contextType = ["entity", "relation"];
@@ -7314,7 +7263,7 @@ class Ei {
7314
7263
  return r;
7315
7264
  }
7316
7265
  }
7317
- const Ii = [Ei];
7266
+ const Ei = [Si];
7318
7267
  class M {
7319
7268
  constructor(t) {
7320
7269
  this.node = t;
@@ -7413,13 +7362,13 @@ class M {
7413
7362
  }
7414
7363
  }
7415
7364
  gt(t) {
7416
- return new wt(this, ">", t);
7365
+ return new Nt(this, ">", t);
7417
7366
  }
7418
7367
  lt(t) {
7419
- return new wt(this, "<", t);
7368
+ return new Nt(this, "<", t);
7420
7369
  }
7421
7370
  eq(t) {
7422
- return new Gt(this, t);
7371
+ return new Xt(this, t);
7423
7372
  }
7424
7373
  getVariables() {
7425
7374
  const t = /* @__PURE__ */ new Set();
@@ -7516,7 +7465,7 @@ class M {
7516
7465
  }
7517
7466
  }
7518
7467
  }
7519
- class wt {
7468
+ class Nt {
7520
7469
  constructor(t, e, i) {
7521
7470
  this.left = t, this.operator = e, this.right = i;
7522
7471
  }
@@ -7551,7 +7500,7 @@ class wt {
7551
7500
  }
7552
7501
  }
7553
7502
  }
7554
- class Gt {
7503
+ class Xt {
7555
7504
  constructor(t, e) {
7556
7505
  this.left = t, this.right = e;
7557
7506
  }
@@ -7586,7 +7535,7 @@ class Gt {
7586
7535
  }
7587
7536
  }
7588
7537
  }
7589
- class Ci {
7538
+ class Ii {
7590
7539
  constructor(t, e, i) {
7591
7540
  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;
7592
7541
  }
@@ -7611,14 +7560,14 @@ class Ci {
7611
7560
  let r, s;
7612
7561
  if (e instanceof M)
7613
7562
  r = e.evaluate({ now: i }), s = i + this.nextRecomputeTime(i, t);
7614
- else if (e instanceof wt || e instanceof Gt)
7563
+ else if (e instanceof Nt || e instanceof Xt)
7615
7564
  r = e.evaluate({ now: i }), s = e.solve();
7616
7565
  else
7617
7566
  throw new Error("Invalid result type");
7618
7567
  return await this.state.lastRecomputeTime.set(i), await this.state.nextRecomputeTime.set(s), r;
7619
7568
  }
7620
7569
  }
7621
- class xi {
7570
+ class Ci {
7622
7571
  constructor(t, e, i) {
7623
7572
  this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !1, this.dataDeps = {
7624
7573
  _current: {
@@ -7649,15 +7598,15 @@ class xi {
7649
7598
  let s, a;
7650
7599
  if (i instanceof M)
7651
7600
  s = i.evaluate({ now: r }), a = r + this.nextRecomputeTime(r, t);
7652
- else if (i instanceof wt || i instanceof Gt)
7601
+ else if (i instanceof Nt || i instanceof Xt)
7653
7602
  s = i.evaluate({ now: r }), a = i.solve();
7654
7603
  else
7655
7604
  throw new Error("Invalid result type");
7656
7605
  return await this.state.lastRecomputeTime.set(e, r), await this.state.nextRecomputeTime.set(e, a), s;
7657
7606
  }
7658
7607
  }
7659
- const Mi = [Ci, xi];
7660
- class Pi {
7608
+ const xi = [Ii, Ci];
7609
+ class Mi {
7661
7610
  constructor(t, e, i) {
7662
7611
  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)
7663
7612
  throw new Error("Sum computation requires attributeQuery with at least one field");
@@ -7718,7 +7667,7 @@ class Pi {
7718
7667
  return s;
7719
7668
  }
7720
7669
  }
7721
- class $i {
7670
+ class Pi {
7722
7671
  constructor(t, e, i) {
7723
7672
  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), T(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, T(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;
7724
7673
  const r = this.args.attributeQuery || [];
@@ -7807,7 +7756,7 @@ class $i {
7807
7756
  return a;
7808
7757
  }
7809
7758
  }
7810
- const Oi = [Pi, $i];
7759
+ const $i = [Mi, Pi];
7811
7760
  class Fi {
7812
7761
  constructor(t, e, i) {
7813
7762
  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)
@@ -7881,7 +7830,7 @@ class Fi {
7881
7830
  return await this.state.sum.set(a), await this.state.count.set(s), s > 0 ? a / s : 0;
7882
7831
  }
7883
7832
  }
7884
- class Di {
7833
+ class Oi {
7885
7834
  constructor(t, e, i) {
7886
7835
  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, T(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;
7887
7836
  const r = this.args.attributeQuery || [];
@@ -7965,8 +7914,8 @@ class Di {
7965
7914
  return await this.state.count.set(e.record, a), a > 0 ? o / a : 0;
7966
7915
  }
7967
7916
  }
7968
- const Vi = [Fi, Di];
7969
- class At {
7917
+ const Di = [Fi, Oi];
7918
+ class St {
7970
7919
  constructor(t, e, i) {
7971
7920
  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) => {
7972
7921
  if (this.computeCallback) {
@@ -8010,7 +7959,7 @@ class At {
8010
7959
  }));
8011
7960
  }
8012
7961
  static {
8013
- this.computationType = Kt;
7962
+ this.computationType = Gt;
8014
7963
  }
8015
7964
  createState() {
8016
7965
  if (this.createStateCallback) {
@@ -8037,22 +7986,22 @@ class At {
8037
7986
  return S.skip();
8038
7987
  }
8039
7988
  }
8040
- class Qi extends At {
7989
+ class Vi extends St {
8041
7990
  static {
8042
7991
  this.contextType = "global";
8043
7992
  }
8044
7993
  }
8045
- class Li extends At {
7994
+ class Qi extends St {
8046
7995
  static {
8047
7996
  this.contextType = "entity";
8048
7997
  }
8049
7998
  }
8050
- class qi extends At {
7999
+ class Li extends St {
8051
8000
  static {
8052
8001
  this.contextType = "relation";
8053
8002
  }
8054
8003
  }
8055
- class Bi extends At {
8004
+ class qi extends St {
8056
8005
  static {
8057
8006
  this.contextType = "property";
8058
8007
  }
@@ -8067,11 +8016,11 @@ If you want to use aggregated data from all records in the entity/relation, you
8067
8016
  super(t, e, i);
8068
8017
  }
8069
8018
  }
8070
- const _i = [
8019
+ const Bi = [
8020
+ Vi,
8071
8021
  Qi,
8072
8022
  Li,
8073
- qi,
8074
- Bi
8023
+ qi
8075
8024
  ];
8076
8025
  class W extends Error {
8077
8026
  constructor(t, e = {}) {
@@ -8190,7 +8139,7 @@ Stack trace:`, r.stack.split(`
8190
8139
  return null;
8191
8140
  }
8192
8141
  }
8193
- var F = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(F || {}), H = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(H || {});
8142
+ var O = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(O || {}), H = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(H || {});
8194
8143
  class z extends W {
8195
8144
  constructor(t, e = {}) {
8196
8145
  super(t, {
@@ -8204,7 +8153,7 @@ class z extends W {
8204
8153
  ...e.context
8205
8154
  },
8206
8155
  causedBy: e.causedBy
8207
- }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || F.HIGH;
8156
+ }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || O.HIGH;
8208
8157
  }
8209
8158
  }
8210
8159
  class se extends W {
@@ -8220,7 +8169,7 @@ class se extends W {
8220
8169
  ...e.context
8221
8170
  },
8222
8171
  causedBy: e.causedBy
8223
- }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || F.MEDIUM;
8172
+ }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || O.MEDIUM;
8224
8173
  }
8225
8174
  }
8226
8175
  class V extends W {
@@ -8236,14 +8185,14 @@ class V extends W {
8236
8185
  ...e.context
8237
8186
  },
8238
8187
  causedBy: e.causedBy
8239
- }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || F.MEDIUM;
8188
+ }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || O.MEDIUM;
8240
8189
  }
8241
8190
  }
8242
8191
  class ae extends V {
8243
8192
  constructor(t, e = {}) {
8244
8193
  super(t, {
8245
8194
  ...e,
8246
- severity: F.HIGH,
8195
+ severity: O.HIGH,
8247
8196
  context: {
8248
8197
  errorType: "ComputationStateError",
8249
8198
  stateKey: e.stateKey,
@@ -8258,7 +8207,7 @@ class J extends V {
8258
8207
  constructor(t, e = {}) {
8259
8208
  super(t, {
8260
8209
  ...e,
8261
- severity: F.MEDIUM,
8210
+ severity: O.MEDIUM,
8262
8211
  context: {
8263
8212
  errorType: "ComputationDataDepError",
8264
8213
  depName: e.depName,
@@ -8269,7 +8218,7 @@ class J extends V {
8269
8218
  }), this.depName = e.depName, this.depType = e.depType, this.missingData = e.missingData, this.invalidData = e.invalidData;
8270
8219
  }
8271
8220
  }
8272
- class It extends W {
8221
+ class Ct extends W {
8273
8222
  constructor(t, e = {}) {
8274
8223
  super(t, {
8275
8224
  errorType: e.context?.errorType || "SchedulerError",
@@ -8280,10 +8229,10 @@ class It extends W {
8280
8229
  ...e.context
8281
8230
  },
8282
8231
  causedBy: e.causedBy
8283
- }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = F.HIGH;
8232
+ }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = O.HIGH;
8284
8233
  }
8285
8234
  }
8286
- class Wi extends W {
8235
+ class _i extends W {
8287
8236
  constructor(t, e) {
8288
8237
  super(t, {
8289
8238
  errorType: "SideEffectError",
@@ -8296,10 +8245,10 @@ class Wi extends W {
8296
8245
  ...e.context
8297
8246
  },
8298
8247
  causedBy: e.causedBy
8299
- }), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity = F.MEDIUM;
8248
+ }), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity = O.MEDIUM;
8300
8249
  }
8301
8250
  }
8302
- class O extends W {
8251
+ class F extends W {
8303
8252
  constructor(t, e) {
8304
8253
  super(t, {
8305
8254
  errorType: e.context?.errorType || "ConditionError",
@@ -8312,16 +8261,16 @@ class O extends W {
8312
8261
  ...e.context
8313
8262
  },
8314
8263
  causedBy: e.causedBy
8315
- }), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || F.HIGH;
8264
+ }), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || O.HIGH;
8316
8265
  }
8317
8266
  /**
8318
8267
  * Helper factory methods for common condition error scenarios
8319
8268
  */
8320
8269
  static userCheckFailed(t, e) {
8321
- return new O("User check failed", {
8270
+ return new F("User check failed", {
8322
8271
  checkType: "user",
8323
8272
  evaluationError: t,
8324
- severity: F.HIGH,
8273
+ severity: O.HIGH,
8325
8274
  context: e,
8326
8275
  type: "check user failed"
8327
8276
  // For backward compatibility
@@ -8329,21 +8278,21 @@ class O extends W {
8329
8278
  }
8330
8279
  static payloadValidationFailed(t, e, i, r) {
8331
8280
  const s = `${t} ${e}`;
8332
- return new O(`Payload validation failed for field '${t}': ${e}`, {
8281
+ return new F(`Payload validation failed for field '${t}': ${e}`, {
8333
8282
  checkType: "payload",
8334
8283
  fieldName: t,
8335
8284
  payload: i,
8336
8285
  evaluationError: r,
8337
- severity: F.MEDIUM,
8286
+ severity: O.MEDIUM,
8338
8287
  type: s
8339
8288
  // For backward compatibility
8340
8289
  });
8341
8290
  }
8342
8291
  static conditionCheckFailed(t, e) {
8343
- return new O(`Condition check failed: ${t.data.name}`, {
8292
+ return new F(`Condition check failed: ${t.data.name}`, {
8344
8293
  checkType: "condition",
8345
8294
  evaluationError: t,
8346
- severity: F.HIGH,
8295
+ severity: O.HIGH,
8347
8296
  context: e,
8348
8297
  type: "condition check failed"
8349
8298
  // For backward compatibility
@@ -8351,31 +8300,31 @@ class O extends W {
8351
8300
  }
8352
8301
  static attributiveCheckFailed(t, e, i, r) {
8353
8302
  const s = `${t} ${e}`;
8354
- return new O(`Attributive check failed for field '${t}': ${e}`, {
8303
+ return new F(`Attributive check failed for field '${t}': ${e}`, {
8355
8304
  checkType: "attributive",
8356
8305
  fieldName: t,
8357
8306
  payload: i,
8358
8307
  evaluationError: r,
8359
- severity: F.MEDIUM,
8308
+ severity: O.MEDIUM,
8360
8309
  type: s
8361
8310
  // For backward compatibility
8362
8311
  });
8363
8312
  }
8364
8313
  static conceptCheckFailed(t, e) {
8365
- return new O(`Concept check failed for field '${t}'`, {
8314
+ return new F(`Concept check failed for field '${t}'`, {
8366
8315
  checkType: "concept",
8367
8316
  fieldName: t,
8368
8317
  evaluationError: e,
8369
- severity: F.MEDIUM,
8318
+ severity: O.MEDIUM,
8370
8319
  type: `${t} check concept failed`
8371
8320
  // For backward compatibility
8372
8321
  });
8373
8322
  }
8374
8323
  }
8375
- const Ct = "_ASYNC_TASK_";
8376
- class Ji {
8324
+ const xt = "_ASYNC_TASK_";
8325
+ class Wi {
8377
8326
  constructor(t, e, i, r, s) {
8378
- this.controller = t, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new li(this.controller, this), this.buildComputationHandleMap(s);
8327
+ this.controller = t, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new ci(this.controller, this), this.buildComputationHandleMap(s);
8379
8328
  const a = [];
8380
8329
  r.forEach((o) => {
8381
8330
  o.computation && a.push({ dataContext: { type: "global", id: o }, args: o.computation });
@@ -8689,7 +8638,7 @@ class Ji {
8689
8638
  }
8690
8639
  }
8691
8640
  } catch (i) {
8692
- throw i instanceof V ? i : new It("Unexpected error in dirty records computation", {
8641
+ throw i instanceof V ? i : new Ct("Unexpected error in dirty records computation", {
8693
8642
  schedulingPhase: "dirty-records-processing",
8694
8643
  failedComputations: [t.computation.args.constructor.displayName],
8695
8644
  causedBy: i instanceof Error ? i : new Error(String(i))
@@ -8699,8 +8648,8 @@ class Ji {
8699
8648
  getAsyncTaskRecordKey(t) {
8700
8649
  if (t.dataContext.type === "property") {
8701
8650
  const e = t.dataContext;
8702
- return `${Ct}_${e.host.name}_${e.id.name}`;
8703
- } else return t.dataContext.type === "global" ? `${Ct}_${t.dataContext.id.name}` : `${Ct}_${t.dataContext.type}_${t.dataContext.id?.name}`;
8651
+ return `${xt}_${e.host.name}_${e.id.name}`;
8652
+ } else return t.dataContext.type === "global" ? `${xt}_${t.dataContext.id.name}` : `${xt}_${t.dataContext.type}_${t.dataContext.id?.name}`;
8704
8653
  }
8705
8654
  async createAsyncTask(t, e, i, r) {
8706
8655
  if (t.dataContext.type === "property")
@@ -8798,7 +8747,7 @@ class Ji {
8798
8747
  dataContext: t.dataContext,
8799
8748
  computationPhase: "type-validation"
8800
8749
  });
8801
- if (s instanceof be) {
8750
+ if (s instanceof ge) {
8802
8751
  const o = t;
8803
8752
  if (!o.compute)
8804
8753
  throw new V("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
@@ -8819,9 +8768,9 @@ class Ji {
8819
8768
  causedBy: o instanceof Error ? o : new Error(String(o))
8820
8769
  });
8821
8770
  }
8822
- if (s instanceof Rt)
8771
+ if (s instanceof wt)
8823
8772
  return;
8824
- if (s instanceof Re)
8773
+ if (s instanceof be)
8825
8774
  try {
8826
8775
  return await this.createAsyncTask(t, s.args, i);
8827
8776
  } catch (o) {
@@ -8834,7 +8783,7 @@ class Ji {
8834
8783
  });
8835
8784
  }
8836
8785
  try {
8837
- const o = s instanceof we ? await t.asyncReturn(s.result, s.args) : s;
8786
+ const o = s instanceof Re ? await t.asyncReturn(s.result, s.args) : s;
8838
8787
  t.incrementalPatchCompute ? await this.controller.applyResultPatch(t.dataContext, o, i) : await this.controller.applyResult(t.dataContext, o, i);
8839
8788
  } catch (o) {
8840
8789
  throw new V("Failed to apply computation result", {
@@ -8917,14 +8866,14 @@ class Ji {
8917
8866
  try {
8918
8867
  this.addMutationPropertyComputationDefaultValueListeners(), this.addMutationComputationListeners(), t && (await this.setupGlobalBoundStateDefaultValues(), await this.setupGlobalComputationDefaultValue(), await this.setupDictDefaultValue());
8919
8868
  } catch (e) {
8920
- throw e instanceof It ? e : new It("Unexpected error during scheduler setup", {
8869
+ throw e instanceof Ct ? e : new Ct("Unexpected error during scheduler setup", {
8921
8870
  schedulingPhase: "top-level-setup",
8922
8871
  causedBy: e instanceof Error ? e : new Error(String(e))
8923
8872
  });
8924
8873
  }
8925
8874
  }
8926
8875
  }
8927
- class ve {
8876
+ class Ne {
8928
8877
  constructor(t, e, i) {
8929
8878
  this.interaction = t, this.controller = e, this.activitySeqCall = i, this.system = e.system;
8930
8879
  }
@@ -8952,13 +8901,13 @@ class ve {
8952
8901
  async checkUser(t, e, i) {
8953
8902
  let r;
8954
8903
  if (!this.interaction.userAttributives) return !0;
8955
- const s = Nt.is(this.interaction.userAttributives) ? R.fromValue(
8904
+ const s = vt.is(this.interaction.userAttributives) ? R.fromValue(
8956
8905
  this.interaction.userAttributives.content
8957
8906
  ) : R.atom(
8958
8907
  this.interaction.userAttributives
8959
8908
  ), a = (o) => o.isRef ? i(o, t.user, e) : this.checkAttributive(o, t, t.user);
8960
8909
  if (r = await this.checkAttributives(s, a, []), r === !0) return r;
8961
- throw O.userCheckFailed(r);
8910
+ throw F.userCheckFailed(r);
8962
8911
  }
8963
8912
  // 用来check attributive 形容的后面的 target 到底是不是那个概念的实例。
8964
8913
  async checkConcept(t, e, i, r = []) {
@@ -8978,7 +8927,7 @@ class ve {
8978
8927
  }
8979
8928
  if (this.isConceptAlias(e)) {
8980
8929
  const s = [];
8981
- return await ui(e.for, async (o) => {
8930
+ return await li(e.for, async (o) => {
8982
8931
  const n = await this.isConcept(t, o);
8983
8932
  return n === !0 ? !0 : (s.push(n), !1);
8984
8933
  }) ? !0 : { name: e.name, type: "conceptAlias", stack: r, error: s };
@@ -9006,25 +8955,25 @@ class ve {
9006
8955
  throw new Error(`${s} in payload is not defined in interaction ${this.interaction.name}`);
9007
8956
  for (let s of i) {
9008
8957
  if (s.required && !(s.name in e))
9009
- throw O.payloadValidationFailed(s.name, "missing", e);
8958
+ throw F.payloadValidationFailed(s.name, "missing", e);
9010
8959
  const a = e[s.name];
9011
8960
  if (a === void 0) return;
9012
8961
  if (s.isCollection && !Array.isArray(a))
9013
- throw O.payloadValidationFailed(s.name, "data is not array", a);
8962
+ throw F.payloadValidationFailed(s.name, "data is not array", a);
9014
8963
  if (s.isCollection) {
9015
8964
  if (s.isRef && !a.every((o) => !!o.id))
9016
- throw O.payloadValidationFailed(s.name, "data not every is ref", a);
8965
+ throw F.payloadValidationFailed(s.name, "data not every is ref", a);
9017
8966
  } else if (s.isRef && !a.id)
9018
- throw O.payloadValidationFailed(s.name, "data is not a ref", a);
8967
+ throw F.payloadValidationFailed(s.name, "data is not a ref", a);
9019
8968
  if (s.base)
9020
8969
  if (s.isCollection) {
9021
- const o = await di(a, (n) => this.checkConcept(n, s.base));
8970
+ const o = await ui(a, (n) => this.checkConcept(n, s.base));
9022
8971
  if (o !== !0)
9023
- throw O.conceptCheckFailed(s.name, o);
8972
+ throw F.conceptCheckFailed(s.name, o);
9024
8973
  } else {
9025
8974
  const o = await this.checkConcept(a, s.base);
9026
8975
  if (o !== !0)
9027
- throw O.conceptCheckFailed(s.name, o);
8976
+ throw F.conceptCheckFailed(s.name, o);
9028
8977
  }
9029
8978
  if (s.isRef) {
9030
8979
  const o = s.isCollection ? m.atom({
@@ -9040,7 +8989,7 @@ class ve {
9040
8989
  }
9041
8990
  async checkCondition(t) {
9042
8991
  if (this.interaction.conditions) {
9043
- const e = Tt.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), i = async (s) => {
8992
+ const e = At.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), i = async (s) => {
9044
8993
  if (!s) return !0;
9045
8994
  if (s.content) {
9046
8995
  const a = s.content;
@@ -9056,7 +9005,7 @@ class ve {
9056
9005
  return !0;
9057
9006
  }, r = await e.evaluateAsync(i);
9058
9007
  if (r !== !0)
9059
- throw O.conditionCheckFailed(r);
9008
+ throw F.conditionCheckFailed(r);
9060
9009
  }
9061
9010
  }
9062
9011
  // CAUTION sideEffect 是并行的。如果要串行,用户应该自己写在一个里面
@@ -9074,7 +9023,7 @@ class ve {
9074
9023
  T(!i.sideEffects[o], `sideEffect ${o} already exists`), i.sideEffects[o] = { result: n, error: c };
9075
9024
  }
9076
9025
  isGetInteraction() {
9077
- return this.interaction.action === Ve;
9026
+ return this.interaction.action === De;
9078
9027
  }
9079
9028
  async saveEvent(t) {
9080
9029
  return await this.controller.activityManager.saveEvent(t);
@@ -9082,10 +9031,10 @@ class ve {
9082
9031
  async retrieveData(t) {
9083
9032
  let e;
9084
9033
  if (I.is(this.interaction.data) || P.is(this.interaction.data)) {
9085
- const i = this.interaction.data.name, r = Object.fromEntries(
9086
- this.interaction.query?.items?.map((p) => [p.name, p.value]) || []
9087
- ), { match: s, modifier: a, attributeQuery: o } = r, n = { ...t.query?.modifier || {}, ...a || {} }, c = t.query?.attributeQuery || [], l = typeof s == "function" ? await s.call(this.controller, t) : s, d = l instanceof R ? l : l ? R.atom(l) : void 0, h = R.and(d, t.query?.match);
9088
- e = await this.system.storage.find(i, h, n, c);
9034
+ const i = this.interaction.data.name, r = this.interaction.dataPolicy?.match, s = this.interaction.dataPolicy?.modifier;
9035
+ this.interaction.dataPolicy?.attributeQuery;
9036
+ const a = { ...t.query?.modifier || {}, ...s || {} }, o = t.query?.attributeQuery || [], n = typeof r == "function" ? await r.call(this.controller, t) : r, c = n instanceof R ? n : n ? R.atom(n) : void 0, l = R.and(c, t.query?.match);
9037
+ e = await this.system.storage.find(i, l, a, o);
9089
9038
  } else
9090
9039
  T(!1, `unknown data type ${this.interaction.data}`);
9091
9040
  return e;
@@ -9222,7 +9171,7 @@ class Y {
9222
9171
  for (let o of t.interactions) {
9223
9172
  const n = { content: o, next: null, uuid: o.uuid, parentGroup: e, parentSeq: r };
9224
9173
  this.uuidToNode.set(o.uuid, n), this.rawToNode.set(o, n);
9225
- const c = new ve(o, this.controller, this);
9174
+ const c = new Ne(o, this.controller, this);
9226
9175
  this.uuidToInteractionCall.set(o.uuid, c), o.name && this.interactionCallByName.set(o.name, c);
9227
9176
  }
9228
9177
  for (let o of t.gateways) {
@@ -9338,7 +9287,7 @@ class Y {
9338
9287
  }), await this.setActivity(t, { refs: r });
9339
9288
  }
9340
9289
  }
9341
- class Hi extends $ {
9290
+ class Ji extends $ {
9342
9291
  onChange(t, e) {
9343
9292
  if (this.graph.isStartNode(t)) {
9344
9293
  if (e)
@@ -9349,25 +9298,25 @@ class Hi extends $ {
9349
9298
  }
9350
9299
  }
9351
9300
  }
9352
- $.GroupStateNodeType.set("any", Hi);
9353
- class ji extends $ {
9301
+ $.GroupStateNodeType.set("any", Ji);
9302
+ class Hi extends $ {
9354
9303
  onChange(t, e) {
9355
9304
  this.isGroupCompleted() && this.complete();
9356
9305
  }
9357
9306
  }
9358
- $.GroupStateNodeType.set("every", ji);
9359
- class Ui extends $ {
9307
+ $.GroupStateNodeType.set("every", Hi);
9308
+ class ji extends $ {
9360
9309
  onChange(t, e) {
9361
9310
  this.graph.isEndNode(t) && this.complete();
9362
9311
  }
9363
9312
  }
9364
- $.GroupStateNodeType.set("race", Ui);
9365
- class Ki extends $ {
9313
+ $.GroupStateNodeType.set("race", ji);
9314
+ class Ui extends $ {
9366
9315
  // 可以根据 group 上的具体配置逻辑,来动态决定。
9367
9316
  }
9368
- $.GroupStateNodeType.set("program", Ki);
9369
- const ne = new le(), $t = "_Interaction_", yt = "_Activity_", ke = I.create({
9370
- name: $t,
9317
+ $.GroupStateNodeType.set("program", Ui);
9318
+ const ne = new le(), Ft = "_Interaction_", gt = "_Activity_", ve = I.create({
9319
+ name: Ft,
9371
9320
  properties: [
9372
9321
  v.create({
9373
9322
  name: "interactionId",
@@ -9395,8 +9344,8 @@ const ne = new le(), $t = "_Interaction_", yt = "_Activity_", ke = I.create({
9395
9344
  collection: !1
9396
9345
  })
9397
9346
  ]
9398
- }), Te = I.create({
9399
- name: yt,
9347
+ }), ke = I.create({
9348
+ name: gt,
9400
9349
  properties: [
9401
9350
  v.create({
9402
9351
  name: "name",
@@ -9419,21 +9368,21 @@ const ne = new le(), $t = "_Interaction_", yt = "_Activity_", ke = I.create({
9419
9368
  collection: !1
9420
9369
  })
9421
9370
  ]
9422
- }), Gi = P.create({
9371
+ }), Ki = P.create({
9423
9372
  name: "activityInteraction",
9424
- source: Te,
9373
+ source: ke,
9425
9374
  sourceProperty: "interaction",
9426
- target: ke,
9375
+ target: ve,
9427
9376
  targetProperty: "activity",
9428
9377
  type: "1:n"
9429
9378
  });
9430
- class Xi {
9379
+ class Gi {
9431
9380
  constructor(t, e, i) {
9432
- 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(Te, ke), this.controller.relations.push(Gi), e.forEach((r) => {
9381
+ 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(ke, ve), this.controller.relations.push(Ki), e.forEach((r) => {
9433
9382
  const s = new Y(r, t);
9434
9383
  this.activityCalls.set(r.uuid, s), r.name && (T(!this.activityCallsByName.has(r.name), `activity name ${r.name} is duplicated`), this.activityCallsByName.set(r.name, s));
9435
9384
  }), i.forEach((r) => {
9436
- const s = new ve(r, t);
9385
+ const s = new Ne(r, t);
9437
9386
  this.interactionCalls.set(r.uuid, s), r.name && (T(!this.interactionCallsByName.has(r.name), `interaction name ${r.name} is duplicated`), this.interactionCallsByName.set(r.name, s));
9438
9387
  });
9439
9388
  }
@@ -9520,7 +9469,7 @@ class Xi {
9520
9469
  }
9521
9470
  }
9522
9471
  async createActivity(t) {
9523
- return this.controller.system.storage.create(yt, {
9472
+ return this.controller.system.storage.create(gt, {
9524
9473
  ...t,
9525
9474
  state: t.state,
9526
9475
  refs: t.refs
@@ -9530,20 +9479,20 @@ class Xi {
9530
9479
  const i = {
9531
9480
  ...e
9532
9481
  };
9533
- return delete i.state, delete i.refs, e.state && (i.state = e.state), e.refs && (i.refs = e.refs), this.controller.system.storage.update(yt, t, i);
9482
+ return delete i.state, delete i.refs, e.state && (i.state = e.state), e.refs && (i.refs = e.refs), this.controller.system.storage.update(gt, t, i);
9534
9483
  }
9535
9484
  async getActivity(t) {
9536
- return (await this.controller.system.storage.find(yt, t, void 0, ["*"])).map((e) => ({
9485
+ return (await this.controller.system.storage.find(gt, t, void 0, ["*"])).map((e) => ({
9537
9486
  ...e,
9538
9487
  state: e.state,
9539
9488
  refs: e.refs
9540
9489
  }));
9541
9490
  }
9542
9491
  async saveEvent(t) {
9543
- return this.controller.system.storage.create($t, t);
9492
+ return this.controller.system.storage.create(Ft, t);
9544
9493
  }
9545
9494
  async getEvent(t) {
9546
- return (await this.controller.system.storage.find($t, t, void 0, ["*"])).map((e) => ({
9495
+ return (await this.controller.system.storage.find(Ft, t, void 0, ["*"])).map((e) => ({
9547
9496
  ...e
9548
9497
  }));
9549
9498
  }
@@ -9560,24 +9509,24 @@ class Xi {
9560
9509
  return this.interactionCallsByName.get(t);
9561
9510
  }
9562
9511
  }
9563
- const Xt = new le();
9564
- function zi() {
9565
- return Xt.getStore()?.effects;
9512
+ const zt = new le();
9513
+ function Xi() {
9514
+ return zt.getStore()?.effects;
9566
9515
  }
9567
9516
  function ce(u) {
9568
- const t = Xt.getStore();
9517
+ const t = zt.getStore();
9569
9518
  t?.effects && t.effects.push(...u);
9570
9519
  }
9571
- const Ar = "User";
9572
- class Ae {
9520
+ const Tr = "User";
9521
+ class Te {
9573
9522
  constructor(t) {
9574
9523
  this.name = t.name, this.record = t.record, this.content = t.content;
9575
9524
  }
9576
9525
  static create(t) {
9577
- return new Ae(t);
9526
+ return new Te(t);
9578
9527
  }
9579
9528
  }
9580
- const Ot = "_isDeleted_", Sr = {
9529
+ const Ot = "_isDeleted_", Ar = {
9581
9530
  create() {
9582
9531
  return v.create({
9583
9532
  name: Ot,
@@ -9585,7 +9534,7 @@ const Ot = "_isDeleted_", Sr = {
9585
9534
  });
9586
9535
  }
9587
9536
  };
9588
- class Er {
9537
+ class Sr {
9589
9538
  constructor(t) {
9590
9539
  this.recordNameToSideEffects = /* @__PURE__ */ new Map(), this.globals = {
9591
9540
  BoolExp: R,
@@ -9604,21 +9553,21 @@ class Er {
9604
9553
  forceThrowInteractionError: d = !1
9605
9554
  // 会 catch 住 error,并在 result 中返回。
9606
9555
  } = t;
9607
- this.system = e, this.ignorePermission = l, this.forceThrowInteractionError = d, this.entities = [...i], this.relations = [...r], this.activities = [...s], this.interactions = [...a], this.dict = [...o], this.recordMutationSideEffects = [...n], this.activityManager = new Xi(this, s, a);
9556
+ this.system = e, this.ignorePermission = l, this.forceThrowInteractionError = d, this.entities = [...i], this.relations = [...r], this.activities = [...s], this.interactions = [...a], this.dict = [...o], this.recordMutationSideEffects = [...n], this.activityManager = new Gi(this, s, a);
9608
9557
  const h = [
9609
- ...Si,
9610
- ...Ii,
9611
- ...ki,
9612
- ...wi,
9613
- ...gi,
9614
- ...Oi,
9615
- ...Vi,
9616
- ...Mi,
9617
- ...fi,
9618
- ..._i,
9558
+ ...Ai,
9559
+ ...Ei,
9560
+ ...vi,
9561
+ ...Ri,
9562
+ ...yi,
9563
+ ...$i,
9564
+ ...Di,
9565
+ ...xi,
9566
+ ...pi,
9567
+ ...Bi,
9619
9568
  ...c
9620
9569
  ];
9621
- this.scheduler = new Ji(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9570
+ this.scheduler = new Wi(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9622
9571
  let y = this.recordNameToSideEffects.get(p.record.name);
9623
9572
  y || this.recordNameToSideEffects.set(p.record.name, y = /* @__PURE__ */ new Set()), y.add(p);
9624
9573
  });
@@ -9638,7 +9587,7 @@ class Er {
9638
9587
  }
9639
9588
  }
9640
9589
  async applyResult(t, e, i) {
9641
- if (!(e instanceof Rt)) {
9590
+ if (!(e instanceof wt)) {
9642
9591
  if (t.type === "global")
9643
9592
  return this.system.storage.dict.set(t.id.name, e);
9644
9593
  if (t.type === "entity") {
@@ -9662,7 +9611,7 @@ class Er {
9662
9611
  }
9663
9612
  }
9664
9613
  async applyResultPatch(t, e, i) {
9665
- if (e instanceof Rt || e === void 0) return;
9614
+ if (e instanceof wt || e === void 0) return;
9666
9615
  const r = Array.isArray(e) ? e : [e];
9667
9616
  for (const s of r) {
9668
9617
  if (t.type === "global")
@@ -9686,7 +9635,7 @@ class Er {
9686
9635
  }
9687
9636
  async callInteraction(t, e, i, r) {
9688
9637
  try {
9689
- const s = { effects: [] }, a = await Xt.run(s, async () => i ? await this.activityManager.callActivityInteraction(i, t, r, e) : await this.activityManager.callInteraction(t, e));
9638
+ const s = { effects: [] }, a = await zt.run(s, async () => i ? await this.activityManager.callActivityInteraction(i, t, r, e) : await this.activityManager.callInteraction(t, e));
9690
9639
  if (a.effects = s.effects, a.error && this.forceThrowInteractionError)
9691
9640
  throw a.error;
9692
9641
  return await this.runRecordChangeSideEffects(a, this.system.logger), a;
@@ -9716,7 +9665,7 @@ class Er {
9716
9665
  result: await a.content.call(this, r)
9717
9666
  };
9718
9667
  } catch (o) {
9719
- const n = new Wi(
9668
+ const n = new _i(
9720
9669
  `Side effect '${a.name}' failed for ${r.type} on ${r.recordName}`,
9721
9670
  {
9722
9671
  sideEffectName: a.name,
@@ -9742,13 +9691,13 @@ class Er {
9742
9691
  this.callbacks.has(t) || this.callbacks.set(t, /* @__PURE__ */ new Set()), this.callbacks.get(t).add(e);
9743
9692
  }
9744
9693
  }
9745
- function Yi(u) {
9694
+ function zi(u) {
9746
9695
  return encodeURI(JSON.stringify(u));
9747
9696
  }
9748
- function Zi(u) {
9697
+ function Yi(u) {
9749
9698
  return u === void 0 ? void 0 : JSON.parse(decodeURI(u));
9750
9699
  }
9751
- class tr {
9700
+ class Zi {
9752
9701
  constructor(t) {
9753
9702
  this.db = t, this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
9754
9703
  get: async (e) => {
@@ -9773,20 +9722,20 @@ class tr {
9773
9722
  // CAUTION kv 结构数据的实现也用 er。这是系统约定,因为也需要 Record 事件!
9774
9723
  async get(t, e, i) {
9775
9724
  const r = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] }), s = (await this.queryHandle.findOne(X, r, void 0, ["value"]))?.value;
9776
- return s === void 0 ? i : Zi(s);
9725
+ return s === void 0 ? i : Yi(s);
9777
9726
  }
9778
9727
  async set(t, e, i, r) {
9779
9728
  const s = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] });
9780
- return await this.queryHandle.findOne(X, s, void 0, ["value"]) ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [X, s, { concept: t, key: e.toString(), value: Yi(i) }], r) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [X, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(i)) }], r);
9729
+ return await this.queryHandle.findOne(X, s, void 0, ["value"]) ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [X, s, { concept: t, key: e.toString(), value: zi(i) }], r) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [X, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(i)) }], r);
9781
9730
  }
9782
9731
  async setup(t, e, i = !1) {
9783
9732
  await this.db.open(i);
9784
- const r = new oi(
9733
+ const r = new ai(
9785
9734
  t,
9786
9735
  e,
9787
9736
  this.db
9788
9737
  );
9789
- i && await r.createTables(), this.queryHandle = new je(new Ue(r.map), this.db), this.map = r.map;
9738
+ i && await r.createTables(), this.queryHandle = new He(new je(r.map), this.db), this.map = r.map;
9790
9739
  }
9791
9740
  findOne(...t) {
9792
9741
  return this.queryHandle.findOne(...t);
@@ -9806,7 +9755,7 @@ class tr {
9806
9755
  async callWithEvents(t, e, i = []) {
9807
9756
  const r = [], s = await t(...e, r), a = await this.dispatch(r);
9808
9757
  i.push(...r, ...a);
9809
- const o = zi();
9758
+ const o = Xi();
9810
9759
  return o && r.length > 0 && ce(r), o && a.length > 0 && ce(a), s;
9811
9760
  }
9812
9761
  findRelationByName(...t) {
@@ -9845,8 +9794,8 @@ class tr {
9845
9794
  return this.db.close();
9846
9795
  }
9847
9796
  }
9848
- var er = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(er || {});
9849
- class zt {
9797
+ var tr = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(tr || {});
9798
+ class Yt {
9850
9799
  constructor(t = 0) {
9851
9800
  this.level = t;
9852
9801
  }
@@ -9857,11 +9806,11 @@ class zt {
9857
9806
  this.level >= 0 && console.error({ type: t, name: e, sql: i, params: r, error: s });
9858
9807
  }
9859
9808
  child() {
9860
- return new zt(this.level);
9809
+ return new Yt(this.level);
9861
9810
  }
9862
9811
  }
9863
- var ir = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(ir || {});
9864
- class Yt {
9812
+ var er = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(er || {});
9813
+ class Zt {
9865
9814
  constructor(t = 0) {
9866
9815
  this.level = t;
9867
9816
  }
@@ -9875,16 +9824,16 @@ class Yt {
9875
9824
  this.level >= 2 && console.debug(`[DEBUG] ${t}: ${e}`, i);
9876
9825
  }
9877
9826
  child(t) {
9878
- return new Yt(this.level);
9827
+ return new Zt(this.level);
9879
9828
  }
9880
9829
  }
9881
- const Ir = new zt(), rr = new Yt();
9882
- class Cr {
9883
- constructor(t, e = rr) {
9884
- this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new tr(t);
9830
+ const Er = new Yt(), ir = new Zt();
9831
+ class Ir {
9832
+ constructor(t, e = ir) {
9833
+ this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new Zi(t);
9885
9834
  }
9886
9835
  setup(t, e, i, r = !1) {
9887
- const s = new ye(t, e), { entities: a, relations: o } = s.getAll();
9836
+ const s = new me(t, e), { entities: a, relations: o } = s.getAll();
9888
9837
  return i.forEach(({ dataContext: n, state: c }) => {
9889
9838
  Object.entries(c).forEach(([l, d]) => {
9890
9839
  if (d instanceof E) {
@@ -9910,7 +9859,7 @@ class Cr {
9910
9859
  }
9911
9860
  });
9912
9861
  }), this.storage.setup(
9913
- [...a, ci, ni],
9862
+ [...a, ni, oi],
9914
9863
  o,
9915
9864
  r
9916
9865
  );
@@ -9920,172 +9869,171 @@ class Cr {
9920
9869
  }
9921
9870
  }
9922
9871
  export {
9923
- yt as ACTIVITY_RECORD,
9924
- qe as ALL_ATTR_SYMBOL,
9925
- Ct as ASYNC_TASK_RECORD,
9926
- vt as Action,
9927
- Lt as Activity,
9872
+ gt as ACTIVITY_RECORD,
9873
+ Le as ALL_ATTR_SYMBOL,
9874
+ xt as ASYNC_TASK_RECORD,
9875
+ kt as Action,
9876
+ qt as Activity,
9928
9877
  Y as ActivityCall,
9929
9878
  Z as ActivityGroup,
9930
- Gi as ActivityInteractionRelation,
9931
- Xi as ActivityManager,
9932
- Te as ActivityStateEntity,
9879
+ Ki as ActivityInteractionRelation,
9880
+ Gi as ActivityManager,
9881
+ ke as ActivityStateEntity,
9933
9882
  ut as Any,
9934
- ki as AnyHandles,
9883
+ vi as AnyHandles,
9935
9884
  _ as AttributeInfo,
9936
9885
  C as AttributeQuery,
9937
9886
  U as Attributive,
9938
- Nt as Attributives,
9887
+ vt as Attributives,
9939
9888
  ct as Average,
9940
- Vi as AverageHandles,
9941
- dr as BaseKlass,
9889
+ Di as AverageHandles,
9890
+ ur as BaseKlass,
9942
9891
  it as BoolAtomData,
9943
9892
  R as BoolExp,
9944
9893
  rt as BoolExpressionData,
9945
9894
  J as ComputationDataDepError,
9946
9895
  V as ComputationError,
9947
9896
  S as ComputationResult,
9948
- Re as ComputationResultAsync,
9949
- be as ComputationResultFullRecompute,
9950
- we as ComputationResultResolved,
9951
- Rt as ComputationResultSkip,
9897
+ be as ComputationResultAsync,
9898
+ ge as ComputationResultFullRecompute,
9899
+ Re as ComputationResultResolved,
9900
+ wt as ComputationResultSkip,
9952
9901
  ae as ComputationStateError,
9953
- qt as Condition,
9954
- O as ConditionError,
9955
- Tt as Conditions,
9956
- Er as Controller,
9902
+ Bt as Condition,
9903
+ F as ConditionError,
9904
+ At as Conditions,
9905
+ Sr as Controller,
9957
9906
  ot as Count,
9958
- Si as CountHandles,
9959
- Kt as Custom,
9960
- _i as CustomHandles,
9961
- zt as DBConsoleLogger,
9962
- er as DBLogLevel,
9963
- oi as DBSetup,
9964
- Tr as DELETED_STATE,
9907
+ Ai as CountHandles,
9908
+ Gt as Custom,
9909
+ Bi as CustomHandles,
9910
+ Yt as DBConsoleLogger,
9911
+ tr as DBLogLevel,
9912
+ ai as DBSetup,
9913
+ kr as DELETED_STATE,
9965
9914
  q as DICTIONARY_RECORD,
9966
- Bt as DataAttributive,
9967
- Ut as DataAttributives,
9968
- Vt as Dictionary,
9969
- ci as DictionaryEntity,
9915
+ _t as DataAttributive,
9916
+ Kt as DataAttributives,
9917
+ fe as DataPolicy,
9918
+ Qt as Dictionary,
9919
+ ni as DictionaryEntity,
9970
9920
  I as Entity,
9971
- Li as EntityCustomHandle,
9972
- je as EntityQueryHandle,
9973
- Ue as EntityToTableMap,
9974
- Gt as Equation,
9975
- _t as Event,
9921
+ Qi as EntityCustomHandle,
9922
+ He as EntityQueryHandle,
9923
+ je as EntityToTableMap,
9924
+ Xt as Equation,
9925
+ Wt as Event,
9976
9926
  lt as Every,
9977
- wi as EveryHandles,
9927
+ Ri as EveryHandles,
9978
9928
  M as Expression,
9979
9929
  tt as Gateway,
9980
- Ve as GetAction,
9981
- Ni as GlobalAnyHandle,
9930
+ De as GetAction,
9931
+ wi as GlobalAnyHandle,
9982
9932
  Fi as GlobalAverageHandle,
9983
9933
  B as GlobalBoundState,
9984
- Ti as GlobalCountHandle,
9985
- Qi as GlobalCustomHandle,
9986
- bi as GlobalEveryHandle,
9987
- Ci as GlobalRealTimeComputation,
9988
- hi as GlobalStateMachineHandle,
9989
- Pi as GlobalSumHandle,
9990
- mi as GlobalWeightedSummationHandle,
9934
+ ki as GlobalCountHandle,
9935
+ Vi as GlobalCustomHandle,
9936
+ gi as GlobalEveryHandle,
9937
+ Ii as GlobalRealTimeComputation,
9938
+ di as GlobalStateMachineHandle,
9939
+ Mi as GlobalSumHandle,
9940
+ fi as GlobalWeightedSummationHandle,
9991
9941
  Ot as HARD_DELETION_PROPERTY_NAME,
9992
- Sr as HardDeletionProperty,
9942
+ Ar as HardDeletionProperty,
9993
9943
  ie as ID_ATTR,
9994
- $t as INTERACTION_RECORD,
9995
- wt as Inequality,
9996
- Qt as Interaction,
9997
- ve as InteractionCall,
9998
- ke as InteractionEventEntity,
9999
- Ft as KlassByName,
9944
+ Ft as INTERACTION_RECORD,
9945
+ Nt as Inequality,
9946
+ Lt as Interaction,
9947
+ Ne as InteractionCall,
9948
+ ve as InteractionEventEntity,
9949
+ Dt as KlassByName,
10000
9950
  f as LINK_SYMBOL,
10001
- bt as LinkInfo,
9951
+ Rt as LinkInfo,
10002
9952
  m as MatchExp,
10003
- Le as Modifier,
10004
- Cr as MonoSystem,
10005
- kr as NON_DELETED_STATE,
10006
- vr as NON_EXIST_STATE,
9953
+ Qe as Modifier,
9954
+ Ir as MonoSystem,
9955
+ vr as NON_DELETED_STATE,
9956
+ Nr as NON_EXIST_STATE,
10007
9957
  Q as NewRecordData,
10008
- br as PHASE_AFTER_ALL,
10009
- gr as PHASE_BEFORE_ALL,
10010
- Et as PHASE_NORMAL,
10011
- Ht as Payload,
10012
- Jt as PayloadItem,
9958
+ gr as PHASE_AFTER_ALL,
9959
+ yr as PHASE_BEFORE_ALL,
9960
+ It as PHASE_NORMAL,
9961
+ jt as Payload,
9962
+ Ht as PayloadItem,
10013
9963
  v as Property,
10014
- vi as PropertyAnyHandle,
10015
- Di as PropertyAverageHandle,
10016
- Ai as PropertyCountHandle,
10017
- Bi as PropertyCustomHandle,
10018
- Ri as PropertyEveryHandle,
10019
- xi as PropertyRealTimeComputation,
10020
- pi as PropertyStateMachineHandle,
10021
- $i as PropertySumHandle,
10022
- Dt as PropertyTypes,
10023
- yi as PropertyWeightedSummationHandle,
10024
- me as Query,
10025
- fe as QueryItem,
10026
- ge as ROOT_LABEL,
9964
+ Ni as PropertyAnyHandle,
9965
+ Oi as PropertyAverageHandle,
9966
+ Ti as PropertyCountHandle,
9967
+ qi as PropertyCustomHandle,
9968
+ bi as PropertyEveryHandle,
9969
+ Ci as PropertyRealTimeComputation,
9970
+ hi as PropertyStateMachineHandle,
9971
+ Pi as PropertySumHandle,
9972
+ Vt as PropertyTypes,
9973
+ mi as PropertyWeightedSummationHandle,
9974
+ ye as ROOT_LABEL,
10027
9975
  re as ROW_ID_ATTR,
10028
9976
  dt as RealTime,
10029
- Mi as RealTimeHandles,
9977
+ xi as RealTimeHandles,
10030
9978
  E as RecordBoundState,
10031
9979
  et as RecordInfo,
10032
- Ae as RecordMutationSideEffect,
9980
+ Te as RecordMutationSideEffect,
10033
9981
  x as RecordQuery,
10034
- He as RecordQueryAgent,
9982
+ Je as RecordQueryAgent,
10035
9983
  L as RecordQueryTree,
10036
- Ei as RecordsTransformHandle,
10037
- gt as RecursiveContext,
10038
- ye as RefContainer,
9984
+ Si as RecordsTransformHandle,
9985
+ bt as RecursiveContext,
9986
+ me as RefContainer,
10039
9987
  P as Relation,
10040
- qi as RelationCustomHandle,
9988
+ Li as RelationCustomHandle,
10041
9989
  X as SYSTEM_RECORD,
10042
- Ji as Scheduler,
10043
- jt as SideEffect,
9990
+ Wi as Scheduler,
9991
+ Ut as SideEffect,
10044
9992
  st as StateMachine,
10045
- fi as StateMachineHandles,
9993
+ pi as StateMachineHandles,
10046
9994
  K as StateNode,
10047
- Wt as StateTransfer,
9995
+ Jt as StateTransfer,
10048
9996
  nt as Summation,
10049
- Oi as SummationHandles,
10050
- Yt as SystemConsoleLogger,
10051
- ni as SystemEntity,
10052
- ir as SystemLogLevel,
9997
+ $i as SummationHandles,
9998
+ Zt as SystemConsoleLogger,
9999
+ oi as SystemEntity,
10000
+ er as SystemLogLevel,
10053
10001
  he as Transfer,
10054
- kt as Transform,
10055
- Ii as TransformHandles,
10056
- Ar as USER_ENTITY,
10002
+ Tt as Transform,
10003
+ Ei as TransformHandles,
10004
+ Tr as USER_ENTITY,
10057
10005
  at as WeightedSummation,
10058
- gi as WeightedSummationHandles,
10006
+ yi as WeightedSummationHandles,
10059
10007
  ce as addToCurrentEffects,
10060
10008
  T as assert,
10061
- Xt as asyncEffectsContext,
10009
+ zt as asyncEffectsContext,
10062
10010
  ne as asyncInteractionContext,
10063
- mr as boolExpToAttributives,
10064
- or as clearAllInstances,
10065
- ur as createClass,
10066
- xe as createInstances,
10067
- lr as createInstancesFromString,
10068
- yr as createUserRoleAttributive,
10069
- Ir as dbConsoleLogger,
10070
- ft as deepClone,
10071
- Nr as everyAsync,
10072
- di as everyWithErrorAsync,
10073
- Rr as filterMap,
10074
- pr as findRootActivity,
10011
+ fr as boolExpToAttributives,
10012
+ ar as clearAllInstances,
10013
+ lr as createClass,
10014
+ Ce as createInstances,
10015
+ cr as createInstancesFromString,
10016
+ mr as createUserRoleAttributive,
10017
+ Er as dbConsoleLogger,
10018
+ mt as deepClone,
10019
+ wr as everyAsync,
10020
+ ui as everyWithErrorAsync,
10021
+ br as filterMap,
10022
+ hr as findRootActivity,
10075
10023
  pe as forEachInteraction,
10076
10024
  k as generateUUID,
10077
- zi as getCurrentEffects,
10078
- hr as getInteractions,
10079
- Ie as indexBy,
10025
+ Xi as getCurrentEffects,
10026
+ dr as getInteractions,
10027
+ Ee as indexBy,
10080
10028
  ue as isObject,
10081
10029
  de as isPlainObject,
10082
- wr as mapObject,
10083
- fr as parse,
10084
- Ce as registerKlass,
10085
- nr as removeAllInstance,
10086
- ui as someAsync,
10087
- cr as stringifyAllInstances,
10030
+ Rr as mapObject,
10031
+ pr as parse,
10032
+ Ie as registerKlass,
10033
+ or as removeAllInstance,
10034
+ li as someAsync,
10035
+ nr as stringifyAllInstances,
10088
10036
  w as stringifyAttribute,
10089
- rr as systemConsoleLogger
10037
+ ir as systemConsoleLogger
10090
10038
  };
10091
10039
  //# sourceMappingURL=index.js.map