interaqt 0.6.4 → 0.7.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/agent/agentspace/knowledge/generator/api-reference.md +14 -14
- package/agent/agentspace/knowledge/generator/computation-implementation.md +10 -10
- package/agent/agentspace/knowledge/usage/04-reactive-computations.md +3 -3
- package/agent/agentspace/knowledge/usage/05-interactions.md +5 -5
- package/agent/agentspace/knowledge/usage/13-testing.md +1 -1
- package/agent/agentspace/knowledge/usage/14-api-reference.md +2 -2
- package/agent/agentspace/knowledge/usage/15-entity-crud-patterns.md +11 -11
- package/agent/agentspace/knowledge/usage/19-common-anti-patterns.md +2 -2
- package/dist/index.js +553 -532
- package/dist/index.js.map +1 -1
- package/dist/runtime/Controller.d.ts +2 -2
- package/dist/runtime/Controller.d.ts.map +1 -1
- package/dist/runtime/computations/Any.d.ts +2 -2
- package/dist/runtime/computations/Average.d.ts +2 -2
- package/dist/runtime/computations/Computation.d.ts +2 -2
- package/dist/runtime/computations/Count.d.ts +2 -2
- package/dist/runtime/computations/Custom.d.ts +2 -2
- package/dist/runtime/computations/Every.d.ts +2 -2
- package/dist/runtime/computations/RealTime.d.ts +2 -2
- package/dist/runtime/computations/StateMachine.d.ts +4 -4
- package/dist/runtime/computations/StateMachine.d.ts.map +1 -1
- package/dist/runtime/computations/Summation.d.ts +2 -2
- package/dist/runtime/computations/Transform.d.ts +1 -1
- package/dist/runtime/computations/WeightedSummation.d.ts +2 -2
- package/dist/runtime/errors/SideEffectError.d.ts +19 -0
- package/dist/runtime/errors/SideEffectError.d.ts.map +1 -0
- package/dist/runtime/errors/index.d.ts +1 -0
- package/dist/runtime/errors/index.d.ts.map +1 -1
- package/dist/shared/Custom.d.ts +4 -4
- package/dist/shared/StateMachine.d.ts +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { parse as Ee } from "acorn";
|
|
2
|
-
import { AsyncLocalStorage as
|
|
3
|
-
function
|
|
2
|
+
import { AsyncLocalStorage as le } from "async_hooks";
|
|
3
|
+
function ue(u) {
|
|
4
4
|
return u !== null && typeof u == "object";
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
if (!
|
|
6
|
+
function de(u) {
|
|
7
|
+
if (!ue(u)) return !1;
|
|
8
8
|
const t = Object.getPrototypeOf(u);
|
|
9
9
|
return t === null ? !0 : t === Object.prototype || t === null;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function Ie(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);
|
|
15
15
|
return e;
|
|
16
16
|
}
|
|
17
17
|
function w(u) {
|
|
18
|
-
return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u :
|
|
18
|
+
return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : ue(u) && !de(u) ? `uuid::${u.uuid}` : u;
|
|
19
19
|
}
|
|
20
20
|
function ft(u, t) {
|
|
21
21
|
if (u == null || typeof u != "object") return u;
|
|
22
22
|
if (Array.isArray(u)) return u.map((i) => ft(i, t));
|
|
23
|
-
if (
|
|
23
|
+
if (de(u))
|
|
24
24
|
return Object.fromEntries(Object.entries(u).map(([i, r]) => [i, ft(r, t)]));
|
|
25
25
|
if (u instanceof Set)
|
|
26
26
|
return new Set(Array.from(u.values()).map((i) => ft(i, t)));
|
|
@@ -29,27 +29,27 @@ function ft(u, 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
|
|
32
|
+
function or(...u) {
|
|
33
33
|
for (const t of u)
|
|
34
34
|
t.instances.length = 0;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function nr() {
|
|
37
37
|
}
|
|
38
38
|
const Ft = /* @__PURE__ */ new Map();
|
|
39
|
-
function
|
|
39
|
+
function Ce(u, t) {
|
|
40
40
|
t && t.isKlass && t.displayName && Ft.set(u, t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function cr() {
|
|
43
43
|
const u = [];
|
|
44
44
|
return Array.from(Ft.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
|
|
48
|
+
function lr(u) {
|
|
49
49
|
const t = JSON.parse(u);
|
|
50
|
-
return
|
|
50
|
+
return xe(t);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function xe(u) {
|
|
53
53
|
const t = /* @__PURE__ */ new Map();
|
|
54
54
|
return u.forEach(({ type: e, options: i = {}, uuid: r, public: s }) => {
|
|
55
55
|
const a = Ft.get(e);
|
|
@@ -61,10 +61,10 @@ function Ie(u) {
|
|
|
61
61
|
t.set(r, o);
|
|
62
62
|
}), t;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ur(u) {
|
|
65
65
|
return console.warn("createClass is deprecated in refactored code"), null;
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class dr {
|
|
68
68
|
static {
|
|
69
69
|
this.isKlass = !0;
|
|
70
70
|
}
|
|
@@ -91,7 +91,7 @@ function k(u) {
|
|
|
91
91
|
return u?.uuid || `id_${++Me}`;
|
|
92
92
|
}
|
|
93
93
|
const Pe = /^[a-zA-Z0-9_]+$/;
|
|
94
|
-
class
|
|
94
|
+
class I {
|
|
95
95
|
// for Merged Entity
|
|
96
96
|
constructor(t, e) {
|
|
97
97
|
this._type = "Entity", this._options = e, this.uuid = k(e), this.name = t.name, this.properties = t.properties || [], this.computation = t.computation, this.baseEntity = t.baseEntity, this.matchExpression = t.matchExpression, this.inputEntities = t.inputEntities;
|
|
@@ -149,7 +149,7 @@ class C {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
static create(t, e) {
|
|
152
|
-
const i = new
|
|
152
|
+
const i = new I(t, e);
|
|
153
153
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
154
154
|
throw new Error(`duplicate uuid in options ${i.uuid}, Entity`);
|
|
155
155
|
return this.instances.push(i), i;
|
|
@@ -192,9 +192,9 @@ class C {
|
|
|
192
192
|
return this.create(e.public, e.options);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
var
|
|
195
|
+
var Dt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(Dt || {});
|
|
196
196
|
const $e = /^[a-zA-Z0-9_]+$/;
|
|
197
|
-
class
|
|
197
|
+
class Vt {
|
|
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
|
}
|
|
@@ -222,7 +222,7 @@ class Qt {
|
|
|
222
222
|
type: "string",
|
|
223
223
|
required: !0,
|
|
224
224
|
collection: !1,
|
|
225
|
-
options: Array.from(Object.values(
|
|
225
|
+
options: Array.from(Object.values(Dt))
|
|
226
226
|
},
|
|
227
227
|
collection: {
|
|
228
228
|
type: "boolean",
|
|
@@ -248,7 +248,7 @@ class Qt {
|
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
static create(t, e) {
|
|
251
|
-
const i = new
|
|
251
|
+
const i = new Vt(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 Qt {
|
|
|
287
287
|
return this.create(e.public, e.options);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
const
|
|
290
|
+
const Oe = /^[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 }) =>
|
|
310
|
+
format: ({ name: t }) => Oe.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(
|
|
317
|
+
options: () => Object.values(Dt)
|
|
318
318
|
},
|
|
319
319
|
collection: {
|
|
320
320
|
type: "boolean",
|
|
@@ -553,7 +553,7 @@ class P {
|
|
|
553
553
|
return this.create(e.public, e.options);
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
class
|
|
556
|
+
class Qt {
|
|
557
557
|
constructor(t, e) {
|
|
558
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;
|
|
559
559
|
}
|
|
@@ -614,7 +614,7 @@ class Lt {
|
|
|
614
614
|
};
|
|
615
615
|
}
|
|
616
616
|
static create(t, e) {
|
|
617
|
-
const i = new
|
|
617
|
+
const i = new Qt(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;
|
|
@@ -651,7 +651,7 @@ class Lt {
|
|
|
651
651
|
return this.create(e.public, e.options);
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
class
|
|
654
|
+
class Lt {
|
|
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 qt {
|
|
|
699
699
|
};
|
|
700
700
|
}
|
|
701
701
|
static create(t, e) {
|
|
702
|
-
const i = new
|
|
702
|
+
const i = new Lt(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;
|
|
@@ -800,7 +800,7 @@ class Z {
|
|
|
800
800
|
return this.create(e.public, e.options);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
-
class
|
|
803
|
+
class he {
|
|
804
804
|
constructor(t, e) {
|
|
805
805
|
this._type = "Transfer", this._options = e, this.uuid = k(e), this.name = t.name, this.source = t.source, this.target = t.target;
|
|
806
806
|
}
|
|
@@ -833,7 +833,7 @@ class pe {
|
|
|
833
833
|
};
|
|
834
834
|
}
|
|
835
835
|
static create(t, e) {
|
|
836
|
-
const i = new
|
|
836
|
+
const i = new he(t, e);
|
|
837
837
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
838
838
|
throw new Error(`duplicate uuid in options ${i.uuid}, Transfer`);
|
|
839
839
|
return this.instances.push(i), i;
|
|
@@ -869,16 +869,16 @@ class pe {
|
|
|
869
869
|
return this.create(e.public, e.options);
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
|
-
function
|
|
872
|
+
function pe(u, t, e) {
|
|
873
873
|
u.interactions.forEach((i) => t(i, e)), u.groups.forEach((i) => {
|
|
874
|
-
i.activities?.forEach((r) =>
|
|
874
|
+
i.activities?.forEach((r) => pe(r, t, i));
|
|
875
875
|
});
|
|
876
876
|
}
|
|
877
|
-
function
|
|
877
|
+
function hr(u) {
|
|
878
878
|
const t = [];
|
|
879
|
-
return
|
|
879
|
+
return pe(u, (e) => t.push(e)), t;
|
|
880
880
|
}
|
|
881
|
-
function
|
|
881
|
+
function pr(u) {
|
|
882
882
|
return null;
|
|
883
883
|
}
|
|
884
884
|
class it {
|
|
@@ -1171,19 +1171,19 @@ class R {
|
|
|
1171
1171
|
throw new Error(`invalid bool expression type: ${JSON.stringify(this.raw)}`);
|
|
1172
1172
|
}
|
|
1173
1173
|
}
|
|
1174
|
-
const
|
|
1174
|
+
const Fe = {
|
|
1175
1175
|
"&&": "and",
|
|
1176
1176
|
"||": "or",
|
|
1177
1177
|
"!": "not"
|
|
1178
1178
|
};
|
|
1179
|
-
function
|
|
1179
|
+
function De(u) {
|
|
1180
1180
|
return { key: u };
|
|
1181
1181
|
}
|
|
1182
1182
|
function mt(u, t, e) {
|
|
1183
1183
|
if (u.type === "LogicalExpression")
|
|
1184
1184
|
return {
|
|
1185
1185
|
type: "expression",
|
|
1186
|
-
operator:
|
|
1186
|
+
operator: Fe[u.operator],
|
|
1187
1187
|
left: mt(u.left, t, e),
|
|
1188
1188
|
right: mt(u.right, t, e)
|
|
1189
1189
|
};
|
|
@@ -1200,13 +1200,13 @@ function mt(u, t, e) {
|
|
|
1200
1200
|
};
|
|
1201
1201
|
throw new Error("unknown ast node type");
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1204
|
-
const i =
|
|
1203
|
+
function fr(u, t = [], e = De) {
|
|
1204
|
+
const i = Ie(t, "name"), r = Ee(u, { ecmaVersion: 2020 });
|
|
1205
1205
|
return new R(
|
|
1206
1206
|
mt(r.body[0].expression, i, e)
|
|
1207
1207
|
);
|
|
1208
1208
|
}
|
|
1209
|
-
class
|
|
1209
|
+
class U {
|
|
1210
1210
|
constructor(t, e) {
|
|
1211
1211
|
this._type = "Attributive", this._options = e, this.uuid = k(e), this.stringContent = t.stringContent, this.content = t.content, this.name = t.name, this.isRef = t.isRef;
|
|
1212
1212
|
}
|
|
@@ -1238,7 +1238,7 @@ class j {
|
|
|
1238
1238
|
};
|
|
1239
1239
|
}
|
|
1240
1240
|
static create(t, e) {
|
|
1241
|
-
const i = new
|
|
1241
|
+
const i = new U(t, e);
|
|
1242
1242
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1243
1243
|
throw new Error(`duplicate uuid in options ${i.uuid}, Attributive`);
|
|
1244
1244
|
return this.instances.push(i), i;
|
|
@@ -1274,7 +1274,7 @@ class j {
|
|
|
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
|
|
1277
|
+
class Nt {
|
|
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 vt {
|
|
|
1297
1297
|
};
|
|
1298
1298
|
}
|
|
1299
1299
|
static create(t, e) {
|
|
1300
|
-
const i = new
|
|
1300
|
+
const i = new Nt(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 vt {
|
|
|
1328
1328
|
return this.create(e.public, e.options);
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
1331
|
-
function
|
|
1331
|
+
function xt(u) {
|
|
1332
1332
|
if (!u) return;
|
|
1333
1333
|
if (u.raw.type === "atom")
|
|
1334
1334
|
return it.create({
|
|
@@ -1339,16 +1339,16 @@ function Mt(u) {
|
|
|
1339
1339
|
return rt.create({
|
|
1340
1340
|
type: "expression",
|
|
1341
1341
|
operator: t.operator,
|
|
1342
|
-
left:
|
|
1343
|
-
right:
|
|
1342
|
+
left: xt(u.left),
|
|
1343
|
+
right: xt(u.right)
|
|
1344
1344
|
});
|
|
1345
1345
|
}
|
|
1346
|
-
function
|
|
1347
|
-
return
|
|
1348
|
-
content:
|
|
1346
|
+
function mr(u) {
|
|
1347
|
+
return Nt.create({
|
|
1348
|
+
content: xt(u)
|
|
1349
1349
|
});
|
|
1350
1350
|
}
|
|
1351
|
-
class
|
|
1351
|
+
class qt {
|
|
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 _t {
|
|
|
1374
1374
|
};
|
|
1375
1375
|
}
|
|
1376
1376
|
static create(t, e) {
|
|
1377
|
-
const i = new
|
|
1377
|
+
const i = new qt(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;
|
|
@@ -1468,7 +1468,7 @@ class Bt {
|
|
|
1468
1468
|
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);
|
|
1469
1469
|
}
|
|
1470
1470
|
}
|
|
1471
|
-
class
|
|
1471
|
+
class fe {
|
|
1472
1472
|
constructor(t, e) {
|
|
1473
1473
|
this._type = "QueryItem", this._options = e, this.uuid = k(e), this.name = t.name, this.value = t.value;
|
|
1474
1474
|
}
|
|
@@ -1496,7 +1496,7 @@ class me {
|
|
|
1496
1496
|
};
|
|
1497
1497
|
}
|
|
1498
1498
|
static create(t, e) {
|
|
1499
|
-
const i = new
|
|
1499
|
+
const i = new fe(t, e);
|
|
1500
1500
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1501
1501
|
throw new Error(`duplicate uuid in options ${i.uuid}, QueryItem`);
|
|
1502
1502
|
return this.instances.push(i), i;
|
|
@@ -1530,7 +1530,7 @@ class me {
|
|
|
1530
1530
|
return this.create(e.public, e.options);
|
|
1531
1531
|
}
|
|
1532
1532
|
}
|
|
1533
|
-
class
|
|
1533
|
+
class me {
|
|
1534
1534
|
constructor(t, e) {
|
|
1535
1535
|
this._type = "Query", this._options = e, this.uuid = k(e), this.items = t.items;
|
|
1536
1536
|
}
|
|
@@ -1553,7 +1553,7 @@ class ye {
|
|
|
1553
1553
|
};
|
|
1554
1554
|
}
|
|
1555
1555
|
static create(t, e) {
|
|
1556
|
-
const i = new
|
|
1556
|
+
const i = new me(t, e);
|
|
1557
1557
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1558
1558
|
throw new Error(`duplicate uuid in options ${i.uuid}, Query`);
|
|
1559
1559
|
return this.instances.push(i), i;
|
|
@@ -1585,7 +1585,7 @@ class ye {
|
|
|
1585
1585
|
return this.create(e.public, e.options);
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
|
-
class
|
|
1588
|
+
class vt {
|
|
1589
1589
|
constructor(t, e) {
|
|
1590
1590
|
this._type = "Action", this._options = e, this.uuid = k(e), this.name = t.name;
|
|
1591
1591
|
}
|
|
@@ -1607,7 +1607,7 @@ class kt {
|
|
|
1607
1607
|
};
|
|
1608
1608
|
}
|
|
1609
1609
|
static create(t, e) {
|
|
1610
|
-
const i = new
|
|
1610
|
+
const i = new vt(t, e);
|
|
1611
1611
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1612
1612
|
throw new Error(`duplicate uuid in options ${i.uuid}, Action`);
|
|
1613
1613
|
return this.instances.push(i), i;
|
|
@@ -1639,7 +1639,7 @@ class kt {
|
|
|
1639
1639
|
return this.create(e.public, e.options);
|
|
1640
1640
|
}
|
|
1641
1641
|
}
|
|
1642
|
-
const Ve =
|
|
1642
|
+
const Ve = vt.create({ name: "get" });
|
|
1643
1643
|
class tt {
|
|
1644
1644
|
constructor(t, e) {
|
|
1645
1645
|
this._type = "Gateway", this._options = e, this.uuid = k(e), this.name = t.name;
|
|
@@ -1694,7 +1694,7 @@ class tt {
|
|
|
1694
1694
|
return this.create(e.public, e.options);
|
|
1695
1695
|
}
|
|
1696
1696
|
}
|
|
1697
|
-
class
|
|
1697
|
+
class _t {
|
|
1698
1698
|
constructor(t, e) {
|
|
1699
1699
|
this._type = "Event", this._options = e, this.uuid = k(e), this.name = t.name;
|
|
1700
1700
|
}
|
|
@@ -1716,7 +1716,7 @@ class Wt {
|
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
1718
|
static create(t, e) {
|
|
1719
|
-
const i = new
|
|
1719
|
+
const i = new _t(t, e);
|
|
1720
1720
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1721
1721
|
throw new Error(`duplicate uuid in options ${i.uuid}, Event`);
|
|
1722
1722
|
return this.instances.push(i), i;
|
|
@@ -1748,7 +1748,7 @@ class Wt {
|
|
|
1748
1748
|
return this.create(e.public, e.options);
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
|
-
class
|
|
1751
|
+
class K {
|
|
1752
1752
|
constructor(t, e) {
|
|
1753
1753
|
this._type = "StateNode", this._options = e, this.uuid = k(e), this.name = t.name, this.computeValue = t.computeValue;
|
|
1754
1754
|
}
|
|
@@ -1776,7 +1776,7 @@ class U {
|
|
|
1776
1776
|
};
|
|
1777
1777
|
}
|
|
1778
1778
|
static create(t, e) {
|
|
1779
|
-
const i = new
|
|
1779
|
+
const i = new K(t, e);
|
|
1780
1780
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1781
1781
|
throw new Error(`duplicate uuid in options ${i.uuid}, StateNode`);
|
|
1782
1782
|
return this.instances.push(i), i;
|
|
@@ -1811,7 +1811,7 @@ class U {
|
|
|
1811
1811
|
return this.create(e.public, e.options);
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
|
-
class
|
|
1814
|
+
class Wt {
|
|
1815
1815
|
constructor(t, e) {
|
|
1816
1816
|
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
1817
|
}
|
|
@@ -1849,7 +1849,7 @@ class Jt {
|
|
|
1849
1849
|
};
|
|
1850
1850
|
}
|
|
1851
1851
|
static create(t, e) {
|
|
1852
|
-
const i = new
|
|
1852
|
+
const i = new Wt(t, e);
|
|
1853
1853
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
1854
1854
|
throw new Error(`duplicate uuid in options ${i.uuid}, StateTransfer`);
|
|
1855
1855
|
return this.instances.push(i), i;
|
|
@@ -1890,7 +1890,7 @@ class Jt {
|
|
|
1890
1890
|
}
|
|
1891
1891
|
class st {
|
|
1892
1892
|
constructor(t, e) {
|
|
1893
|
-
this._type = "StateMachine", this._options = e, this.uuid = k(e), this.states = t.states, this.transfers = t.transfers, this.
|
|
1893
|
+
this._type = "StateMachine", this._options = e, this.uuid = k(e), this.states = t.states, this.transfers = t.transfers, this.initialState = t.initialState;
|
|
1894
1894
|
}
|
|
1895
1895
|
static {
|
|
1896
1896
|
this.isKlass = !0;
|
|
@@ -1913,7 +1913,7 @@ class st {
|
|
|
1913
1913
|
collection: !0,
|
|
1914
1914
|
required: !0
|
|
1915
1915
|
},
|
|
1916
|
-
|
|
1916
|
+
initialState: {
|
|
1917
1917
|
type: "StateNode",
|
|
1918
1918
|
collection: !1,
|
|
1919
1919
|
required: !0
|
|
@@ -1934,7 +1934,7 @@ class st {
|
|
|
1934
1934
|
public: {
|
|
1935
1935
|
states: t.states,
|
|
1936
1936
|
transfers: t.transfers,
|
|
1937
|
-
|
|
1937
|
+
initialState: t.initialState
|
|
1938
1938
|
}
|
|
1939
1939
|
};
|
|
1940
1940
|
return JSON.stringify(e);
|
|
@@ -1943,7 +1943,7 @@ class st {
|
|
|
1943
1943
|
return this.create({
|
|
1944
1944
|
states: t.states,
|
|
1945
1945
|
transfers: t.transfers,
|
|
1946
|
-
|
|
1946
|
+
initialState: t.initialState
|
|
1947
1947
|
});
|
|
1948
1948
|
}
|
|
1949
1949
|
static is(t) {
|
|
@@ -2112,7 +2112,7 @@ class ot {
|
|
|
2112
2112
|
}
|
|
2113
2113
|
static clone(t, e) {
|
|
2114
2114
|
let i = t.record;
|
|
2115
|
-
return e && (
|
|
2115
|
+
return e && (I.is(t.record) ? i = I.clone(t.record, e) : P.is(t.record) && (i = P.clone(t.record, e))), this.create({
|
|
2116
2116
|
record: i,
|
|
2117
2117
|
direction: t.direction,
|
|
2118
2118
|
callback: t.callback,
|
|
@@ -2442,7 +2442,7 @@ class ut {
|
|
|
2442
2442
|
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
2443
|
}
|
|
2444
2444
|
}
|
|
2445
|
-
class
|
|
2445
|
+
class kt {
|
|
2446
2446
|
constructor(t, e) {
|
|
2447
2447
|
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
2448
|
}
|
|
@@ -2475,7 +2475,7 @@ class Tt {
|
|
|
2475
2475
|
};
|
|
2476
2476
|
}
|
|
2477
2477
|
static create(t, e) {
|
|
2478
|
-
const i = new
|
|
2478
|
+
const i = new kt(t, e);
|
|
2479
2479
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
2480
2480
|
throw new Error(`duplicate uuid in options ${i.uuid}, Transform`);
|
|
2481
2481
|
return this.instances.push(i), i;
|
|
@@ -2585,7 +2585,7 @@ class dt {
|
|
|
2585
2585
|
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
2586
|
}
|
|
2587
2587
|
}
|
|
2588
|
-
class
|
|
2588
|
+
class Jt {
|
|
2589
2589
|
constructor(t, e) {
|
|
2590
2590
|
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
2591
|
}
|
|
@@ -2636,7 +2636,7 @@ class Ht {
|
|
|
2636
2636
|
};
|
|
2637
2637
|
}
|
|
2638
2638
|
static create(t, e) {
|
|
2639
|
-
const i = new
|
|
2639
|
+
const i = new Jt(t, e);
|
|
2640
2640
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
2641
2641
|
throw new Error(`duplicate uuid in options ${i.uuid}, PayloadItem`);
|
|
2642
2642
|
return this.instances.push(i), i;
|
|
@@ -2675,7 +2675,7 @@ class Ht {
|
|
|
2675
2675
|
return this.create(e.public, e.options);
|
|
2676
2676
|
}
|
|
2677
2677
|
}
|
|
2678
|
-
class
|
|
2678
|
+
class Ht {
|
|
2679
2679
|
constructor(t, e) {
|
|
2680
2680
|
this._type = "Payload", this._options = e, this.uuid = k(e), this.items = t.items || [];
|
|
2681
2681
|
}
|
|
@@ -2699,7 +2699,7 @@ class jt {
|
|
|
2699
2699
|
};
|
|
2700
2700
|
}
|
|
2701
2701
|
static create(t, e) {
|
|
2702
|
-
const i = new
|
|
2702
|
+
const i = new Ht(t, e);
|
|
2703
2703
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
2704
2704
|
throw new Error(`duplicate uuid in options ${i.uuid}, Payload`);
|
|
2705
2705
|
return this.instances.push(i), i;
|
|
@@ -2731,7 +2731,7 @@ class jt {
|
|
|
2731
2731
|
return this.create(e.public, e.options);
|
|
2732
2732
|
}
|
|
2733
2733
|
}
|
|
2734
|
-
class
|
|
2734
|
+
class jt {
|
|
2735
2735
|
constructor(t, e) {
|
|
2736
2736
|
this._type = "SideEffect", this._options = e, this.uuid = k(e), this.name = t.name, this.handle = t.handle;
|
|
2737
2737
|
}
|
|
@@ -2759,7 +2759,7 @@ class Ut {
|
|
|
2759
2759
|
};
|
|
2760
2760
|
}
|
|
2761
2761
|
static create(t, e) {
|
|
2762
|
-
const i = new
|
|
2762
|
+
const i = new jt(t, e);
|
|
2763
2763
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
2764
2764
|
throw new Error(`duplicate uuid in options ${i.uuid}, SideEffect`);
|
|
2765
2765
|
return this.instances.push(i), i;
|
|
@@ -2793,7 +2793,7 @@ class Ut {
|
|
|
2793
2793
|
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
2794
|
}
|
|
2795
2795
|
}
|
|
2796
|
-
function
|
|
2796
|
+
function Mt(u) {
|
|
2797
2797
|
if (!u) return;
|
|
2798
2798
|
if (u.raw.type === "atom")
|
|
2799
2799
|
return it.create({
|
|
@@ -2804,13 +2804,13 @@ function Pt(u) {
|
|
|
2804
2804
|
return rt.create({
|
|
2805
2805
|
type: "expression",
|
|
2806
2806
|
operator: t.operator,
|
|
2807
|
-
left:
|
|
2808
|
-
right:
|
|
2807
|
+
left: Mt(u.left),
|
|
2808
|
+
right: Mt(u.right)
|
|
2809
2809
|
});
|
|
2810
2810
|
}
|
|
2811
|
-
class
|
|
2811
|
+
class Tt {
|
|
2812
2812
|
constructor(t, e) {
|
|
2813
|
-
this._type = "Conditions", this._options = e, this.uuid = k(e), t.content && t.content instanceof R ? this.content =
|
|
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;
|
|
2814
2814
|
}
|
|
2815
2815
|
static {
|
|
2816
2816
|
this.isKlass = !0;
|
|
@@ -2831,7 +2831,7 @@ class At {
|
|
|
2831
2831
|
};
|
|
2832
2832
|
}
|
|
2833
2833
|
static create(t, e) {
|
|
2834
|
-
const i = new
|
|
2834
|
+
const i = new Tt(t, e);
|
|
2835
2835
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
2836
2836
|
throw new Error(`duplicate uuid in options ${i.uuid}, Conditions`);
|
|
2837
2837
|
return this.instances.push(i), i;
|
|
@@ -2862,7 +2862,7 @@ class At {
|
|
|
2862
2862
|
return this.create(e.public, e.options);
|
|
2863
2863
|
}
|
|
2864
2864
|
}
|
|
2865
|
-
class
|
|
2865
|
+
class Ut {
|
|
2866
2866
|
constructor(t, e) {
|
|
2867
2867
|
this._type = "DataAttributives", this._options = e, this.uuid = k(e), this.content = t.content;
|
|
2868
2868
|
}
|
|
@@ -2885,7 +2885,7 @@ class Kt {
|
|
|
2885
2885
|
};
|
|
2886
2886
|
}
|
|
2887
2887
|
static create(t, e) {
|
|
2888
|
-
const i = new
|
|
2888
|
+
const i = new Ut(t, e);
|
|
2889
2889
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
2890
2890
|
throw new Error(`duplicate uuid in options ${i.uuid}, DataAttributives`);
|
|
2891
2891
|
return this.instances.push(i), i;
|
|
@@ -2917,19 +2917,19 @@ class Kt {
|
|
|
2917
2917
|
}
|
|
2918
2918
|
}
|
|
2919
2919
|
const Qe = [
|
|
2920
|
-
|
|
2920
|
+
I,
|
|
2921
2921
|
P,
|
|
2922
2922
|
v,
|
|
2923
|
+
Qt,
|
|
2923
2924
|
Lt,
|
|
2925
|
+
U,
|
|
2924
2926
|
qt,
|
|
2925
|
-
j,
|
|
2926
|
-
_t,
|
|
2927
2927
|
Bt,
|
|
2928
|
-
|
|
2928
|
+
vt,
|
|
2929
2929
|
tt,
|
|
2930
|
+
_t,
|
|
2931
|
+
K,
|
|
2930
2932
|
Wt,
|
|
2931
|
-
U,
|
|
2932
|
-
Jt,
|
|
2933
2933
|
st,
|
|
2934
2934
|
at,
|
|
2935
2935
|
ot,
|
|
@@ -2937,23 +2937,23 @@ const Qe = [
|
|
|
2937
2937
|
ct,
|
|
2938
2938
|
lt,
|
|
2939
2939
|
ut,
|
|
2940
|
-
|
|
2940
|
+
kt,
|
|
2941
2941
|
dt,
|
|
2942
|
+
Jt,
|
|
2942
2943
|
Ht,
|
|
2943
2944
|
jt,
|
|
2944
|
-
|
|
2945
|
-
Qt,
|
|
2945
|
+
Vt,
|
|
2946
2946
|
it,
|
|
2947
2947
|
rt,
|
|
2948
|
-
|
|
2949
|
-
|
|
2948
|
+
Tt,
|
|
2949
|
+
Ut
|
|
2950
2950
|
];
|
|
2951
2951
|
Qe.forEach((u) => {
|
|
2952
|
-
u && u.displayName &&
|
|
2952
|
+
u && u.displayName && Ce(u.displayName, u);
|
|
2953
2953
|
});
|
|
2954
|
-
class
|
|
2954
|
+
class Kt {
|
|
2955
2955
|
constructor(t, e) {
|
|
2956
|
-
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.
|
|
2956
|
+
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
2957
|
}
|
|
2958
2958
|
static {
|
|
2959
2959
|
this.isKlass = !0;
|
|
@@ -2996,7 +2996,7 @@ class Gt {
|
|
|
2996
2996
|
collection: !1,
|
|
2997
2997
|
required: !1
|
|
2998
2998
|
},
|
|
2999
|
-
|
|
2999
|
+
getInitialValue: {
|
|
3000
3000
|
type: "function",
|
|
3001
3001
|
collection: !1,
|
|
3002
3002
|
required: !1
|
|
@@ -3014,7 +3014,7 @@ class Gt {
|
|
|
3014
3014
|
};
|
|
3015
3015
|
}
|
|
3016
3016
|
static create(t, e) {
|
|
3017
|
-
const i = new
|
|
3017
|
+
const i = new Kt(t, e);
|
|
3018
3018
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
3019
3019
|
throw new Error(`duplicate uuid in options ${i.uuid}, Custom`);
|
|
3020
3020
|
return this.instances.push(i), i;
|
|
@@ -3023,7 +3023,7 @@ class Gt {
|
|
|
3023
3023
|
const e = {
|
|
3024
3024
|
name: t.name
|
|
3025
3025
|
};
|
|
3026
|
-
t.dataDeps !== void 0 && (e.dataDeps = w(t.dataDeps)), t.compute !== void 0 && (e.compute = w(t.compute)), t.incrementalCompute !== void 0 && (e.incrementalCompute = w(t.incrementalCompute)), t.incrementalPatchCompute !== void 0 && (e.incrementalPatchCompute = w(t.incrementalPatchCompute)), t.createState !== void 0 && (e.createState = w(t.createState)), t.
|
|
3026
|
+
t.dataDeps !== void 0 && (e.dataDeps = w(t.dataDeps)), t.compute !== void 0 && (e.compute = w(t.compute)), t.incrementalCompute !== void 0 && (e.incrementalCompute = w(t.incrementalCompute)), t.incrementalPatchCompute !== void 0 && (e.incrementalPatchCompute = w(t.incrementalPatchCompute)), t.createState !== void 0 && (e.createState = w(t.createState)), t.getInitialValue !== void 0 && (e.getInitialValue = w(t.getInitialValue)), t.asyncReturn !== void 0 && (e.asyncReturn = w(t.asyncReturn)), t.useLastValue !== void 0 && (e.useLastValue = t.useLastValue);
|
|
3027
3027
|
const i = {
|
|
3028
3028
|
type: "Custom",
|
|
3029
3029
|
options: t._options,
|
|
@@ -3040,7 +3040,7 @@ class Gt {
|
|
|
3040
3040
|
incrementalCompute: t.incrementalCompute,
|
|
3041
3041
|
incrementalPatchCompute: t.incrementalPatchCompute,
|
|
3042
3042
|
createState: t.createState,
|
|
3043
|
-
|
|
3043
|
+
getInitialValue: t.getInitialValue,
|
|
3044
3044
|
asyncReturn: t.asyncReturn,
|
|
3045
3045
|
useLastValue: t.useLastValue
|
|
3046
3046
|
});
|
|
@@ -3053,12 +3053,12 @@ class Gt {
|
|
|
3053
3053
|
}
|
|
3054
3054
|
static parse(t) {
|
|
3055
3055
|
const e = JSON.parse(t), i = { ...e.public };
|
|
3056
|
-
return ["compute", "incrementalCompute", "incrementalPatchCompute", "createState", "
|
|
3056
|
+
return ["compute", "incrementalCompute", "incrementalPatchCompute", "createState", "getInitialValue", "asyncReturn"].forEach((s) => {
|
|
3057
3057
|
typeof i[s] == "string" && i[s].startsWith("func::") && (i[s] = new Function("return " + i[s].substring(6))());
|
|
3058
3058
|
}), this.create(i, e.options);
|
|
3059
3059
|
}
|
|
3060
3060
|
}
|
|
3061
|
-
class
|
|
3061
|
+
class ye {
|
|
3062
3062
|
constructor(t = [], e = []) {
|
|
3063
3063
|
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
3064
|
}
|
|
@@ -3067,7 +3067,7 @@ class ge {
|
|
|
3067
3067
|
*/
|
|
3068
3068
|
initializeClones() {
|
|
3069
3069
|
for (const t of this.originalEntities) {
|
|
3070
|
-
const e =
|
|
3070
|
+
const e = I.clone(t, !1);
|
|
3071
3071
|
this.clonedEntities.set(t, e), this.reverseEntityMap.set(e, t);
|
|
3072
3072
|
}
|
|
3073
3073
|
for (const t of this.originalRelations) {
|
|
@@ -3084,7 +3084,7 @@ class ge {
|
|
|
3084
3084
|
if (i === t || i.uuid === t.uuid)
|
|
3085
3085
|
throw new Error(`Entity already exists in container: ${t.name}`);
|
|
3086
3086
|
this.originalEntities.push(t);
|
|
3087
|
-
const e =
|
|
3087
|
+
const e = I.clone(t, !1);
|
|
3088
3088
|
return this.clonedEntities.set(t, e), this.reverseEntityMap.set(e, t), this.updateReferencesInObject(e), e;
|
|
3089
3089
|
}
|
|
3090
3090
|
/**
|
|
@@ -3269,8 +3269,8 @@ class ge {
|
|
|
3269
3269
|
return null;
|
|
3270
3270
|
}
|
|
3271
3271
|
}
|
|
3272
|
-
function
|
|
3273
|
-
return
|
|
3272
|
+
function yr({ name: u, isRef: t = !1 }, e) {
|
|
3273
|
+
return U.create({
|
|
3274
3274
|
name: u,
|
|
3275
3275
|
content: u ? new Function("user", `return user.roles.includes('${u}')`) : function() {
|
|
3276
3276
|
return !0;
|
|
@@ -3282,7 +3282,7 @@ function g(u, t) {
|
|
|
3282
3282
|
if (!u)
|
|
3283
3283
|
throw new Error(t);
|
|
3284
3284
|
}
|
|
3285
|
-
function
|
|
3285
|
+
function St(u, t, e) {
|
|
3286
3286
|
const i = [...t];
|
|
3287
3287
|
let r = u, s;
|
|
3288
3288
|
const a = i.pop();
|
|
@@ -3290,7 +3290,7 @@ function Et(u, t, e) {
|
|
|
3290
3290
|
r[s] || (r[s] = {}), r = r[s];
|
|
3291
3291
|
return r[a] = e, !0;
|
|
3292
3292
|
}
|
|
3293
|
-
class
|
|
3293
|
+
class _ {
|
|
3294
3294
|
constructor(t, e, i, r) {
|
|
3295
3295
|
this.parentEntityName = t, this.attributeName = e, this.map = i, this.symmetricDirection = r, this.data = this.map.getAttributeData(t, e), g(!!this.data, `${t} has no attribute: ${e}`);
|
|
3296
3296
|
}
|
|
@@ -3417,7 +3417,7 @@ class B {
|
|
|
3417
3417
|
return g(this.isLinkFiltered(), "only filtered relation can get match expression"), this.data.matchExpression;
|
|
3418
3418
|
}
|
|
3419
3419
|
getBaseAttributeInfo() {
|
|
3420
|
-
return g(this.isLinkFiltered(), "only filtered relation can get base attribute info"), new
|
|
3420
|
+
return g(this.isLinkFiltered(), "only filtered relation can get base attribute info"), new _(this.parentEntityName, this.data.baseRelationAttributeName, this.map, this.symmetricDirection);
|
|
3421
3421
|
}
|
|
3422
3422
|
}
|
|
3423
3423
|
class m {
|
|
@@ -3660,7 +3660,7 @@ class Le {
|
|
|
3660
3660
|
}));
|
|
3661
3661
|
}
|
|
3662
3662
|
}
|
|
3663
|
-
class
|
|
3663
|
+
class x {
|
|
3664
3664
|
constructor(t, e, i, r, s, a, o, n, c, l = !1, d, h, p, y) {
|
|
3665
3665
|
this.recordName = t, this.map = e, this.matchExpression = i, this.attributeQuery = r, this.modifier = s, this.contextRootEntity = a, this.parentRecord = o, this.attributeName = n, this.onlyRelationData = c, this.allowNull = l, this.label = d, this.goto = h, this.exit = p, this.alias = y;
|
|
3666
3666
|
}
|
|
@@ -3673,11 +3673,11 @@ class I {
|
|
|
3673
3673
|
key: "id",
|
|
3674
3674
|
value: ["not", null]
|
|
3675
3675
|
}), N = y;
|
|
3676
|
-
return d && (N = y.and(new m(h, e, l.data.resolvedMatchExpression))), new
|
|
3676
|
+
return d && (N = y.and(new m(h, e, l.data.resolvedMatchExpression))), new x(
|
|
3677
3677
|
h,
|
|
3678
3678
|
e,
|
|
3679
3679
|
N,
|
|
3680
|
-
new
|
|
3680
|
+
new C(h, e, i.attributeQuery || [], s, a),
|
|
3681
3681
|
new Le(h, e, i.modifier),
|
|
3682
3682
|
r,
|
|
3683
3683
|
s,
|
|
@@ -3700,7 +3700,7 @@ class I {
|
|
|
3700
3700
|
// CAUTION 特别注意这里的参数,不能让用取用原本的 matchExpression, attributeQuery, modifier 里面的 data 传进来。
|
|
3701
3701
|
// 因为 data 不能代表一切配置,例如 attributeQuery 里面 还有个 shouldQueryParentLinkData 就是保存在 this 上的。
|
|
3702
3702
|
derive({ matchExpression: t, attributeQuery: e, modifier: i }) {
|
|
3703
|
-
return new
|
|
3703
|
+
return new x(
|
|
3704
3704
|
this.recordName,
|
|
3705
3705
|
this.map,
|
|
3706
3706
|
t || this.matchExpression,
|
|
@@ -3773,7 +3773,7 @@ class L {
|
|
|
3773
3773
|
}
|
|
3774
3774
|
}
|
|
3775
3775
|
const f = "&", qe = "*";
|
|
3776
|
-
class
|
|
3776
|
+
class C {
|
|
3777
3777
|
constructor(t, e, i = [], r, s, a) {
|
|
3778
3778
|
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();
|
|
3779
3779
|
let o = /* @__PURE__ */ new Set();
|
|
@@ -3782,7 +3782,7 @@ class x {
|
|
|
3782
3782
|
if (l === f) {
|
|
3783
3783
|
g(!!(this.parentRecord && this.attributeName), `parent record and attribute name cannot be empty when query link data, you passed ${this.parentRecord} ${this.attributeName}`);
|
|
3784
3784
|
const y = this.map.getInfo(this.parentRecord, this.attributeName);
|
|
3785
|
-
this.parentLinkRecordQuery =
|
|
3785
|
+
this.parentLinkRecordQuery = x.create(y.linkName, this.map, d, void 0);
|
|
3786
3786
|
return;
|
|
3787
3787
|
}
|
|
3788
3788
|
if (l === qe) {
|
|
@@ -3794,13 +3794,13 @@ class x {
|
|
|
3794
3794
|
let y = l, N = d;
|
|
3795
3795
|
if (p.isLinkFiltered()) {
|
|
3796
3796
|
y = p.getBaseAttributeInfo().attributeName;
|
|
3797
|
-
const A = d.matchExpression,
|
|
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;
|
|
3798
3798
|
N = {
|
|
3799
3799
|
...d,
|
|
3800
3800
|
matchExpression: Se.data
|
|
3801
3801
|
};
|
|
3802
3802
|
}
|
|
3803
|
-
const b =
|
|
3803
|
+
const b = x.create(p.recordName, this.map, N, void 0, this.recordName, y, h, !1, l);
|
|
3804
3804
|
this.relatedRecords.push(b), p.isXToMany ? this.xToManyRecords.push(b) : p.isXToOne && this.xToOneRecords.push(b);
|
|
3805
3805
|
} else
|
|
3806
3806
|
o.add(l);
|
|
@@ -3809,7 +3809,7 @@ class x {
|
|
|
3809
3809
|
static mergeAttributeQueryData(t, e) {
|
|
3810
3810
|
const i = [...t, ...e], r = new Set(i.filter((o) => typeof o == "string")), a = i.filter((o) => typeof o != "string").reduce((o, n) => {
|
|
3811
3811
|
const [c, l] = n;
|
|
3812
|
-
return o[c] ? o[c] = { attributeQuery:
|
|
3812
|
+
return o[c] ? o[c] = { attributeQuery: C.mergeAttributeQueryData(o[c].attributeQuery, l.attributeQuery) } : o[c] = l, o;
|
|
3813
3813
|
}, {});
|
|
3814
3814
|
return [
|
|
3815
3815
|
...r,
|
|
@@ -3820,32 +3820,32 @@ class x {
|
|
|
3820
3820
|
const o = e.getRecordInfo(t), n = o.resolvedBaseRecordName ? e.getRecordInfo(o.resolvedBaseRecordName) : o;
|
|
3821
3821
|
let c = n.valueAttributes.map((l) => l.attributeName);
|
|
3822
3822
|
return i && n.sameTableReliance.forEach((l) => {
|
|
3823
|
-
const d =
|
|
3823
|
+
const d = C.getAttributeQueryDataForRecord(l.recordName, e, !0, r), h = [
|
|
3824
3824
|
l.attributeName,
|
|
3825
3825
|
{
|
|
3826
3826
|
attributeQuery: [...d]
|
|
3827
3827
|
}
|
|
3828
3828
|
];
|
|
3829
3829
|
if (!n.isRelation) {
|
|
3830
|
-
const p =
|
|
3830
|
+
const p = C.getAttributeQueryDataForRecord(l.linkName, e, !0, r);
|
|
3831
3831
|
h[1].attributeQuery.push([f, { attributeQuery: p }]);
|
|
3832
3832
|
}
|
|
3833
|
-
c =
|
|
3833
|
+
c = C.mergeAttributeQueryData(c, [h]);
|
|
3834
3834
|
}), a && n.notRelianceCombined.forEach((l) => {
|
|
3835
|
-
const d =
|
|
3835
|
+
const d = C.getAttributeQueryDataForRecord(l.recordName, e, !0, r), h = [
|
|
3836
3836
|
l.attributeName,
|
|
3837
3837
|
{
|
|
3838
3838
|
attributeQuery: [...d]
|
|
3839
3839
|
}
|
|
3840
3840
|
];
|
|
3841
3841
|
if (!n.isRelation) {
|
|
3842
|
-
const p =
|
|
3842
|
+
const p = C.getAttributeQueryDataForRecord(l.linkName, e, !0, r);
|
|
3843
3843
|
h[1].attributeQuery.push([f, { attributeQuery: p }]);
|
|
3844
3844
|
}
|
|
3845
|
-
c =
|
|
3845
|
+
c = C.mergeAttributeQueryData(c, [h]);
|
|
3846
3846
|
}), r && n.mergedRecordAttributes.forEach((l) => {
|
|
3847
|
-
const d =
|
|
3848
|
-
c =
|
|
3847
|
+
const d = C.getAttributeQueryDataForRecord(l.linkName, e, i, !0);
|
|
3848
|
+
c = C.mergeAttributeQueryData(c, [
|
|
3849
3849
|
[
|
|
3850
3850
|
l.attributeName,
|
|
3851
3851
|
{
|
|
@@ -3854,7 +3854,7 @@ class x {
|
|
|
3854
3854
|
]
|
|
3855
3855
|
]);
|
|
3856
3856
|
}), s && n.managedRecordAttributes.forEach((l) => {
|
|
3857
|
-
c =
|
|
3857
|
+
c = C.mergeAttributeQueryData(c, [
|
|
3858
3858
|
[
|
|
3859
3859
|
l.attributeName,
|
|
3860
3860
|
{
|
|
@@ -3912,10 +3912,10 @@ class x {
|
|
|
3912
3912
|
}), t;
|
|
3913
3913
|
}
|
|
3914
3914
|
withParentLinkData() {
|
|
3915
|
-
return this.parentLinkRecordQuery ? new
|
|
3915
|
+
return this.parentLinkRecordQuery ? new C(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
|
|
3916
3916
|
}
|
|
3917
3917
|
}
|
|
3918
|
-
function
|
|
3918
|
+
function Be(u) {
|
|
3919
3919
|
const t = [];
|
|
3920
3920
|
return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
|
|
3921
3921
|
}
|
|
@@ -3925,7 +3925,7 @@ class Q {
|
|
|
3925
3925
|
const s = this.map.getRecordInfo(e);
|
|
3926
3926
|
this.recordName = s.isFilteredEntity || s.isFilteredRelation ? s.resolvedBaseRecordName : e;
|
|
3927
3927
|
const [a, o, n] = this.map.groupAttributes(this.recordName, i ? Object.keys(i) : []);
|
|
3928
|
-
this.relatedEntitiesData =
|
|
3928
|
+
this.relatedEntitiesData = Be(o.map(
|
|
3929
3929
|
(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
3930
|
)), this.valueAttributes = a, this.entityIdAttributes = n;
|
|
3931
3931
|
const c = this.map.getRecordInfo(this.recordName);
|
|
@@ -4002,7 +4002,7 @@ class Q {
|
|
|
4002
4002
|
}), i;
|
|
4003
4003
|
}
|
|
4004
4004
|
}
|
|
4005
|
-
class
|
|
4005
|
+
class _e {
|
|
4006
4006
|
constructor(t, e) {
|
|
4007
4007
|
this.map = t, this.queryAgent = e, this.dependencies = /* @__PURE__ */ new Map();
|
|
4008
4008
|
}
|
|
@@ -4084,7 +4084,7 @@ class Be {
|
|
|
4084
4084
|
const o = s.path.concat("id").join("."), n = m.atom({
|
|
4085
4085
|
key: o,
|
|
4086
4086
|
value: ["=", i]
|
|
4087
|
-
}), c =
|
|
4087
|
+
}), c = x.create(t.baseEntityName, this.map, {
|
|
4088
4088
|
matchExpression: n,
|
|
4089
4089
|
attributeQuery: ["id"]
|
|
4090
4090
|
});
|
|
@@ -4096,7 +4096,7 @@ class Be {
|
|
|
4096
4096
|
async checkRecordMatchesFilter(t, e, i) {
|
|
4097
4097
|
if (!this.queryAgent)
|
|
4098
4098
|
throw new Error("QueryAgent not set in FilteredEntityManager");
|
|
4099
|
-
const r =
|
|
4099
|
+
const r = x.create(e, this.map, {
|
|
4100
4100
|
matchExpression: i.and({
|
|
4101
4101
|
key: "id",
|
|
4102
4102
|
value: ["=", t]
|
|
@@ -4191,7 +4191,7 @@ class Be {
|
|
|
4191
4191
|
*/
|
|
4192
4192
|
async updateSingleFilteredEntityFlag(t, e, i) {
|
|
4193
4193
|
const r = this.map.getRecordInfo(t.baseEntityName), s = await this.queryAgent.findRecords(
|
|
4194
|
-
|
|
4194
|
+
x.create(t.baseEntityName, this.map, {
|
|
4195
4195
|
matchExpression: m.atom({ key: "id", value: ["=", e] }),
|
|
4196
4196
|
attributeQuery: r.isRelation ? ["*", ["target", { attributeQuery: ["*"] }], ["source", { attributeQuery: ["*"] }]] : ["*"]
|
|
4197
4197
|
}),
|
|
@@ -4242,7 +4242,7 @@ class We {
|
|
|
4242
4242
|
return this.aliasToPath.get(t);
|
|
4243
4243
|
}
|
|
4244
4244
|
}
|
|
4245
|
-
const
|
|
4245
|
+
const ge = ":root";
|
|
4246
4246
|
class gt {
|
|
4247
4247
|
constructor(t, e, i = []) {
|
|
4248
4248
|
this.label = t, this.parent = e, this.stack = i;
|
|
@@ -4259,7 +4259,7 @@ class gt {
|
|
|
4259
4259
|
}
|
|
4260
4260
|
class Je {
|
|
4261
4261
|
constructor(t) {
|
|
4262
|
-
this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(
|
|
4262
|
+
this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(ge, t), this.recursiveSaveLabelledRecordQuery(t);
|
|
4263
4263
|
}
|
|
4264
4264
|
recursiveSaveLabelledRecordQuery(t) {
|
|
4265
4265
|
t.attributeQuery?.relatedRecords.forEach((e) => {
|
|
@@ -4275,7 +4275,7 @@ class Je {
|
|
|
4275
4275
|
}
|
|
4276
4276
|
class He {
|
|
4277
4277
|
constructor(t, e) {
|
|
4278
|
-
this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new
|
|
4278
|
+
this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new _e(t, this), this.initializeFilteredEntityDependencies();
|
|
4279
4279
|
}
|
|
4280
4280
|
/**
|
|
4281
4281
|
* 初始化所有 filtered entity 的依赖关系
|
|
@@ -4327,14 +4327,14 @@ ${b}
|
|
|
4327
4327
|
const s = {};
|
|
4328
4328
|
return Object.entries(r).forEach(([a, o]) => {
|
|
4329
4329
|
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 &&
|
|
4330
|
+
n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && St(s, n, o);
|
|
4331
4331
|
}), s;
|
|
4332
4332
|
});
|
|
4333
4333
|
}
|
|
4334
4334
|
// 查 entity 和 查 relation 都是一样的。具体在 entityQuery 里面区别。
|
|
4335
4335
|
// TODO 为了性能,也可以把信息丢到客户端,然客户端去结构化???
|
|
4336
4336
|
// CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
|
|
4337
|
-
async findRecords(t, e = "", i, r = new gt(
|
|
4337
|
+
async findRecords(t, e = "", i, r = new gt(ge)) {
|
|
4338
4338
|
if (i || (i = new Je(t)), t.goto) {
|
|
4339
4339
|
if (t.exit && await t.exit(r))
|
|
4340
4340
|
return [];
|
|
@@ -4373,15 +4373,15 @@ ${b}
|
|
|
4373
4373
|
key: `${y}.id`,
|
|
4374
4374
|
value: ["=", b]
|
|
4375
4375
|
})
|
|
4376
|
-
}),
|
|
4377
|
-
|
|
4376
|
+
}), D = t.label ? c.concat(N) : c;
|
|
4377
|
+
St(
|
|
4378
4378
|
N,
|
|
4379
4379
|
[l.alias || l.attributeName, f, h.attributeName],
|
|
4380
4380
|
await this.findRecords(
|
|
4381
4381
|
A,
|
|
4382
4382
|
`finding relation data: ${t.recordName}.${l.attributeName}.&.${h.attributeName}`,
|
|
4383
4383
|
i,
|
|
4384
|
-
|
|
4384
|
+
D
|
|
4385
4385
|
)
|
|
4386
4386
|
);
|
|
4387
4387
|
}
|
|
@@ -4461,17 +4461,17 @@ ${b}
|
|
|
4461
4461
|
if (N)
|
|
4462
4462
|
for (let b of N.attributeQuery.xToManyRecords)
|
|
4463
4463
|
for (let A of p) {
|
|
4464
|
-
const
|
|
4465
|
-
|
|
4464
|
+
const D = A[f].id, Zt = d.label ? y.concat(A) : y;
|
|
4465
|
+
St(
|
|
4466
4466
|
A,
|
|
4467
4467
|
[f, b.attributeName],
|
|
4468
4468
|
await this.findXToManyRelatedRecords(
|
|
4469
4469
|
b.parentRecord,
|
|
4470
4470
|
b.attributeName,
|
|
4471
|
-
|
|
4471
|
+
D,
|
|
4472
4472
|
b,
|
|
4473
4473
|
s,
|
|
4474
|
-
|
|
4474
|
+
Zt
|
|
4475
4475
|
)
|
|
4476
4476
|
);
|
|
4477
4477
|
}
|
|
@@ -4528,7 +4528,7 @@ ${b}
|
|
|
4528
4528
|
});
|
|
4529
4529
|
}
|
|
4530
4530
|
if (r.push(...this.getJoinTables(o, l, [N, d, h])), o.parentLinkQueryTree, o.parentLinkQueryTree && !o.parentLinkQueryTree.onlyIdField()) {
|
|
4531
|
-
const b = l.concat(f), [, A] = this.map.getTableAliasAndFieldName(b, "id", !0),
|
|
4531
|
+
const b = l.concat(f), [, A] = this.map.getTableAliasAndFieldName(b, "id", !0), D = [
|
|
4532
4532
|
A,
|
|
4533
4533
|
// link 的 idField
|
|
4534
4534
|
p,
|
|
@@ -4536,7 +4536,7 @@ ${b}
|
|
|
4536
4536
|
y
|
|
4537
4537
|
// link 的 tableAlias
|
|
4538
4538
|
];
|
|
4539
|
-
r.push(...this.getJoinTables(o.parentLinkQueryTree, b,
|
|
4539
|
+
r.push(...this.getJoinTables(o.parentLinkQueryTree, b, D));
|
|
4540
4540
|
}
|
|
4541
4541
|
}), r;
|
|
4542
4542
|
}
|
|
@@ -4588,7 +4588,7 @@ ${b}
|
|
|
4588
4588
|
return e ? e.map((s, a) => {
|
|
4589
4589
|
if (g(Array.isArray(s.data.value), `match value is not a array ${a.join(".")}`), !s.data.isFunctionMatch) return { ...s.data };
|
|
4590
4590
|
g(s.data.value[0].toLowerCase() === "exist", `we only support Exist function match on entity for now. yours: ${s.data.key} ${s.data.value[0]} ${s.data.value[1]}`);
|
|
4591
|
-
const o = this.map.getInfoByPath(s.data.namePath), { alias: n } = this.map.getTableAndAliasStack(s.data.namePath).at(-1), c = this.map.getReverseAttribute(o.parentEntityName, o.attributeName), l = s.data.namePath.slice(1, -1), d =
|
|
4591
|
+
const o = this.map.getInfoByPath(s.data.namePath), { alias: n } = this.map.getTableAndAliasStack(s.data.namePath).at(-1), c = this.map.getReverseAttribute(o.parentEntityName, o.attributeName), l = s.data.namePath.slice(1, -1), d = x.create(
|
|
4592
4592
|
o.recordName,
|
|
4593
4593
|
this.map,
|
|
4594
4594
|
{
|
|
@@ -4688,7 +4688,7 @@ ${h}
|
|
|
4688
4688
|
async flashOutCombinedRecordsAndMergedLinks(t, e, i = "") {
|
|
4689
4689
|
const r = {};
|
|
4690
4690
|
let s;
|
|
4691
|
-
const a =
|
|
4691
|
+
const a = C.getAttributeQueryDataForRecord(t.recordName, this.map, !0, !0, !1, !0);
|
|
4692
4692
|
for (let c of t.combinedRecordIdRefs) {
|
|
4693
4693
|
const l = {
|
|
4694
4694
|
key: `${c.info.attributeName}.id`,
|
|
@@ -4696,7 +4696,7 @@ ${h}
|
|
|
4696
4696
|
};
|
|
4697
4697
|
s ? s = s.or(l) : s = m.atom(l);
|
|
4698
4698
|
}
|
|
4699
|
-
const o =
|
|
4699
|
+
const o = x.create(t.recordName, this.map, {
|
|
4700
4700
|
matchExpression: s,
|
|
4701
4701
|
attributeQuery: a
|
|
4702
4702
|
}, void 0, void 0, void 0, !1, !0), n = await this.findRecords(o, i, void 0);
|
|
@@ -4718,7 +4718,7 @@ ${h}
|
|
|
4718
4718
|
return r;
|
|
4719
4719
|
}
|
|
4720
4720
|
async relocateCombinedRecordDataForLink(t, e, i = !1, r) {
|
|
4721
|
-
const s =
|
|
4721
|
+
const s = C.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0), a = i ? "source" : "target", o = await this.findRecords(x.create(t, this.map, {
|
|
4722
4722
|
matchExpression: e,
|
|
4723
4723
|
attributeQuery: s
|
|
4724
4724
|
}), `finding combined records for relocate ${t}.${a}`, void 0), n = this.map.getLinkInfoByName(t)[i ? "sourceRecordInfo" : "targetRecordInfo"];
|
|
@@ -4897,9 +4897,9 @@ WHERE "${s.idField}" = (${r()})
|
|
|
4897
4897
|
}
|
|
4898
4898
|
// 修改TODO注释以反映已实现的功能
|
|
4899
4899
|
async updateRecord(t, e, i, r) {
|
|
4900
|
-
const s =
|
|
4900
|
+
const s = x.create(t, this.map, {
|
|
4901
4901
|
matchExpression: e,
|
|
4902
|
-
attributeQuery:
|
|
4902
|
+
attributeQuery: C.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0)
|
|
4903
4903
|
}), a = await this.findRecords(s, `find record for updating ${t}`, void 0), o = [];
|
|
4904
4904
|
for (let n of a) {
|
|
4905
4905
|
const c = await this.createRecordDependency(i, r), l = await this.updateSameRowData(s.recordName, n, c, r), d = await this.handleUpdateReliance(s.recordName, n, i, r), h = Object.keys(i.getData());
|
|
@@ -4908,9 +4908,9 @@ WHERE "${s.idField}" = (${r()})
|
|
|
4908
4908
|
return o;
|
|
4909
4909
|
}
|
|
4910
4910
|
async deleteRecord(t, e, i, r = !1) {
|
|
4911
|
-
const s =
|
|
4911
|
+
const s = x.create(t, this.map, {
|
|
4912
4912
|
matchExpression: e,
|
|
4913
|
-
attributeQuery:
|
|
4913
|
+
attributeQuery: C.getAttributeQueryDataForRecord(
|
|
4914
4914
|
t,
|
|
4915
4915
|
this.map,
|
|
4916
4916
|
!0,
|
|
@@ -4936,7 +4936,7 @@ WHERE "${s.idField}" = (${r()})
|
|
|
4936
4936
|
const s = this.map.getRecordInfo(t);
|
|
4937
4937
|
for (let a of e) {
|
|
4938
4938
|
if (!r) {
|
|
4939
|
-
const o =
|
|
4939
|
+
const o = x.create(
|
|
4940
4940
|
t,
|
|
4941
4941
|
this.map,
|
|
4942
4942
|
{
|
|
@@ -4944,7 +4944,7 @@ WHERE "${s.idField}" = (${r()})
|
|
|
4944
4944
|
key: "id",
|
|
4945
4945
|
value: ["=", a.id]
|
|
4946
4946
|
}),
|
|
4947
|
-
attributeQuery:
|
|
4947
|
+
attributeQuery: C.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0),
|
|
4948
4948
|
modifier: { limit: 1 }
|
|
4949
4949
|
}
|
|
4950
4950
|
), n = await this.findRecords(o, `find record with same row data for delete ${t}`, void 0);
|
|
@@ -5061,7 +5061,7 @@ WHERE "${s.idField}" = ${l()}
|
|
|
5061
5061
|
return this.addLink(o.name, c, l, s, !o.isRelationSource(t, e), a);
|
|
5062
5062
|
}
|
|
5063
5063
|
async addLink(t, e, i, r = {}, s = !1, a) {
|
|
5064
|
-
const o = (await this.findRecords(
|
|
5064
|
+
const o = (await this.findRecords(x.create(t, this.map, {
|
|
5065
5065
|
matchExpression: m.atom({ key: "source.id", value: ["=", e] }).and({
|
|
5066
5066
|
key: "target.id",
|
|
5067
5067
|
value: ["=", i]
|
|
@@ -5095,7 +5095,7 @@ WHERE "${s.idField}" = ${l()}
|
|
|
5095
5095
|
const a = e.split("."), o = a.at(-1), n = a.slice(0, -1), c = m.atom({
|
|
5096
5096
|
key: "id",
|
|
5097
5097
|
value: ["=", i]
|
|
5098
|
-
}), l =
|
|
5098
|
+
}), l = C.getAttributeQueryDataForRecord(t, this.map, !0, !0, !1, !0), d = e;
|
|
5099
5099
|
let h = l;
|
|
5100
5100
|
for (let b of n)
|
|
5101
5101
|
h.push([b, { attributeQuery: ["*"] }]), h = h.at(-1)[1].attributeQuery;
|
|
@@ -5109,7 +5109,7 @@ WHERE "${s.idField}" = ${l()}
|
|
|
5109
5109
|
return p = [...b.stack], !0;
|
|
5110
5110
|
};
|
|
5111
5111
|
h.push([o, { goto: d, exit: y }]);
|
|
5112
|
-
const N = (await this.findRecords(
|
|
5112
|
+
const N = (await this.findRecords(x.create(t, this.map, {
|
|
5113
5113
|
matchExpression: c,
|
|
5114
5114
|
attributeQuery: l
|
|
5115
5115
|
}), `find records for path ${t}.${e}`))[0];
|
|
@@ -5129,7 +5129,7 @@ class je {
|
|
|
5129
5129
|
}
|
|
5130
5130
|
async find(t, e, i, r = []) {
|
|
5131
5131
|
g(this.map.getRecord(t), `cannot find entity ${t}`);
|
|
5132
|
-
const s =
|
|
5132
|
+
const s = x.create(
|
|
5133
5133
|
t,
|
|
5134
5134
|
this.map,
|
|
5135
5135
|
{
|
|
@@ -5222,19 +5222,19 @@ class et {
|
|
|
5222
5222
|
return Object.keys(this.data.attributes).filter((t) => {
|
|
5223
5223
|
const e = this.data.attributes[t];
|
|
5224
5224
|
return e.isRecord && e.field;
|
|
5225
|
-
}).map((t) => new
|
|
5225
|
+
}).map((t) => new _(this.name, t, this.map));
|
|
5226
5226
|
}
|
|
5227
5227
|
get strictRecordAttributes() {
|
|
5228
5228
|
return Object.keys(this.data.attributes).filter((t) => {
|
|
5229
5229
|
const e = this.data.attributes[t];
|
|
5230
5230
|
return e.isRecord && !e.field && !e.isFilteredRelation;
|
|
5231
|
-
}).map((t) => new
|
|
5231
|
+
}).map((t) => new _(this.name, t, this.map));
|
|
5232
5232
|
}
|
|
5233
5233
|
get differentTableRecordAttributes() {
|
|
5234
5234
|
return this.strictRecordAttributes.filter((t) => !(t.isMergedWithParent() || t.isLinkMergedWithParent()));
|
|
5235
5235
|
}
|
|
5236
5236
|
get reliance() {
|
|
5237
|
-
return Object.keys(this.data.attributes).filter((t) => this.data.attributes[t].isReliance).map((t) => new
|
|
5237
|
+
return Object.keys(this.data.attributes).filter((t) => this.data.attributes[t].isReliance).map((t) => new _(this.name, t, this.map));
|
|
5238
5238
|
}
|
|
5239
5239
|
get notRelianceCombined() {
|
|
5240
5240
|
return this.combinedRecords.filter((t) => !t.isReliance);
|
|
@@ -5246,10 +5246,10 @@ class et {
|
|
|
5246
5246
|
return this.reliance.filter((t) => t.table === this.table);
|
|
5247
5247
|
}
|
|
5248
5248
|
get valueAttributes() {
|
|
5249
|
-
return Object.entries(this.data.attributes).filter(([, t]) => !t.isRecord).map(([t]) => new
|
|
5249
|
+
return Object.entries(this.data.attributes).filter(([, t]) => !t.isRecord).map(([t]) => new _(this.name, t, this.map));
|
|
5250
5250
|
}
|
|
5251
5251
|
getAttributeInfo(t) {
|
|
5252
|
-
return new
|
|
5252
|
+
return new _(this.name, t, this.map);
|
|
5253
5253
|
}
|
|
5254
5254
|
get baseRecordName() {
|
|
5255
5255
|
return this.data.baseRecordName;
|
|
@@ -5426,7 +5426,7 @@ class Ue {
|
|
|
5426
5426
|
}
|
|
5427
5427
|
}
|
|
5428
5428
|
if (!(!s || !a))
|
|
5429
|
-
return new
|
|
5429
|
+
return new _(s, a, this, c);
|
|
5430
5430
|
}
|
|
5431
5431
|
getTableAndAliasStack(t) {
|
|
5432
5432
|
const [e, ...i] = t;
|
|
@@ -5449,14 +5449,14 @@ class Ue {
|
|
|
5449
5449
|
for (let h = 0; h < i.length; h++) {
|
|
5450
5450
|
const [p, y] = this.getAttributeAndSymmetricDirection(i[h]), N = [e, ...i.slice(0, h + 1)];
|
|
5451
5451
|
if (p === f) {
|
|
5452
|
-
const { linkTable: b, linkAlias: A, path:
|
|
5453
|
-
g(!c, `last attribute in path is a link, cannot read link of a link ${
|
|
5452
|
+
const { linkTable: b, linkAlias: A, path: D } = d.pop();
|
|
5453
|
+
g(!c, `last attribute in path is a link, cannot read link of a link ${D.join(".")}`), s = b, a = A, r = this.data.records[l.linkName], c = !0, o = "", n = "", l = void 0;
|
|
5454
5454
|
} else {
|
|
5455
5455
|
l = this.getInfoByPath(N);
|
|
5456
5456
|
const b = r.attributes[p];
|
|
5457
5457
|
g(l.isRecord, `${i.slice(0, h + 1).join(".")} is not a entity attribute`);
|
|
5458
|
-
const A = this.data.records[b.recordName],
|
|
5459
|
-
l.isMergedWithParent() || l.isLinkMergedWithParent() ? n = a : l.isLinkIsolated() ? n = `REL_${
|
|
5458
|
+
const A = this.data.records[b.recordName], D = `${a}_${p}${y ? `_${y.toUpperCase()}` : ""}`;
|
|
5459
|
+
l.isMergedWithParent() || l.isLinkMergedWithParent() ? n = a : l.isLinkIsolated() ? n = `REL_${D}` : n = D, l.isMergedWithParent() || (a = D), s = l.table, r = A, o = l.getLinkInfo()?.table, c = !1;
|
|
5460
5460
|
}
|
|
5461
5461
|
d.push({
|
|
5462
5462
|
table: s,
|
|
@@ -5600,20 +5600,20 @@ function Ge(u) {
|
|
|
5600
5600
|
return t;
|
|
5601
5601
|
}
|
|
5602
5602
|
function Xe(u, t) {
|
|
5603
|
-
const e = new
|
|
5604
|
-
return
|
|
5603
|
+
const e = new ye(u, t), i = Ke(u), r = Ge(t);
|
|
5604
|
+
return ee(
|
|
5605
5605
|
u,
|
|
5606
5606
|
e,
|
|
5607
5607
|
i,
|
|
5608
5608
|
"entity"
|
|
5609
|
-
),
|
|
5609
|
+
), ee(
|
|
5610
5610
|
t,
|
|
5611
5611
|
e,
|
|
5612
5612
|
r,
|
|
5613
5613
|
"relation"
|
|
5614
5614
|
), e.getAll();
|
|
5615
5615
|
}
|
|
5616
|
-
function
|
|
5616
|
+
function ee(u, t, e, i) {
|
|
5617
5617
|
const r = u.filter((s) => {
|
|
5618
5618
|
const a = pt(s);
|
|
5619
5619
|
return a && a.length > 0;
|
|
@@ -5628,7 +5628,7 @@ function ie(u, t, e, i) {
|
|
|
5628
5628
|
);
|
|
5629
5629
|
}
|
|
5630
5630
|
function ze(u, t, e, i) {
|
|
5631
|
-
const r = e === "entity", a = `__${
|
|
5631
|
+
const r = e === "entity", a = `__${G(u)}_input_${e}`, o = r ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = ii(
|
|
5632
5632
|
o,
|
|
5633
5633
|
a,
|
|
5634
5634
|
i,
|
|
@@ -5654,14 +5654,14 @@ function Ye(u, t, e, i, r) {
|
|
|
5654
5654
|
);
|
|
5655
5655
|
if (!r && s === u)
|
|
5656
5656
|
return;
|
|
5657
|
-
const o =
|
|
5657
|
+
const o = G(a), n = r ? i.getEntityByName(o) : i.getRelationByName(o);
|
|
5658
5658
|
n && i.replace(s, n);
|
|
5659
5659
|
}
|
|
5660
5660
|
function Ze(u, t) {
|
|
5661
5661
|
const e = /* @__PURE__ */ new Map(), i = pt(u);
|
|
5662
5662
|
if (i && i.length > 0)
|
|
5663
5663
|
for (const r of i) {
|
|
5664
|
-
const s =
|
|
5664
|
+
const s = G(r), a = [...t.get(s) || []], o = e.get(s) || [];
|
|
5665
5665
|
for (o.push(s), e.set(s, o); a.length; ) {
|
|
5666
5666
|
const n = a.shift(), c = e.get(n) || [];
|
|
5667
5667
|
c.push(...o), e.set(n, c);
|
|
@@ -5678,7 +5678,7 @@ function ti(u, t, e) {
|
|
|
5678
5678
|
type: "json",
|
|
5679
5679
|
defaultValue: (r, s) => {
|
|
5680
5680
|
const a = pt(t), n = (i.get(s) || []).filter(
|
|
5681
|
-
(c) => a.some((l) =>
|
|
5681
|
+
(c) => a.some((l) => G(l) === c)
|
|
5682
5682
|
);
|
|
5683
5683
|
return n.length > 0 ? n : [s];
|
|
5684
5684
|
}
|
|
@@ -5736,11 +5736,11 @@ function ii(u, t, e, i) {
|
|
|
5736
5736
|
...u.properties
|
|
5737
5737
|
];
|
|
5738
5738
|
if (ht(u)) {
|
|
5739
|
-
const a = i.getEntityByName(u.name), o =
|
|
5739
|
+
const a = i.getEntityByName(u.name), o = I.create({
|
|
5740
5740
|
name: a.name
|
|
5741
5741
|
});
|
|
5742
5742
|
let n;
|
|
5743
|
-
return a.inputEntities?.some((c) => c.baseEntity) ? (n =
|
|
5743
|
+
return a.inputEntities?.some((c) => c.baseEntity) ? (n = I.create({
|
|
5744
5744
|
name: `${a.name}_base`,
|
|
5745
5745
|
properties: s
|
|
5746
5746
|
}), o.baseEntity = n, o.matchExpression = m.fromArray(
|
|
@@ -5773,7 +5773,7 @@ function ii(u, t, e, i) {
|
|
|
5773
5773
|
properties: s
|
|
5774
5774
|
}), o.baseRelation = n, o.sourceProperty = a.sourceProperty, o.targetProperty = a.targetProperty, o.matchExpression = m.fromArray(
|
|
5775
5775
|
a.inputRelations.map((l) => {
|
|
5776
|
-
const d =
|
|
5776
|
+
const d = G(l);
|
|
5777
5777
|
return {
|
|
5778
5778
|
key: t,
|
|
5779
5779
|
value: ["contains", d]
|
|
@@ -5792,13 +5792,13 @@ function ri(u, t, e) {
|
|
|
5792
5792
|
if (i.baseEntity)
|
|
5793
5793
|
for (; s.baseEntity; )
|
|
5794
5794
|
s = s.baseEntity;
|
|
5795
|
-
const a =
|
|
5795
|
+
const a = I.clone(s, !0);
|
|
5796
5796
|
return a.baseEntity = r, a.matchExpression = m.atom({
|
|
5797
5797
|
key: e,
|
|
5798
5798
|
value: ["contains", i.name]
|
|
5799
5799
|
}), [a, s];
|
|
5800
5800
|
} else {
|
|
5801
|
-
const i = u, r = t, s =
|
|
5801
|
+
const i = u, r = t, s = G(i);
|
|
5802
5802
|
return i.baseRelation ? [i, si(i)] : [P.create({
|
|
5803
5803
|
name: s,
|
|
5804
5804
|
baseRelation: r,
|
|
@@ -5826,7 +5826,7 @@ function ai(u) {
|
|
|
5826
5826
|
function pt(u) {
|
|
5827
5827
|
return ht(u) ? u.inputEntities || [] : u.inputRelations || [];
|
|
5828
5828
|
}
|
|
5829
|
-
function
|
|
5829
|
+
function G(u) {
|
|
5830
5830
|
return ht(u), u.name;
|
|
5831
5831
|
}
|
|
5832
5832
|
class oi {
|
|
@@ -5924,8 +5924,8 @@ class oi {
|
|
|
5924
5924
|
}
|
|
5925
5925
|
];
|
|
5926
5926
|
}));
|
|
5927
|
-
e && g(!i.source && !i.target, "source and target is reserved name for relation attributes"), i[
|
|
5928
|
-
name:
|
|
5927
|
+
e && g(!i.source && !i.target, "source and target is reserved name for relation attributes"), i[ie] = {
|
|
5928
|
+
name: ie,
|
|
5929
5929
|
type: "id",
|
|
5930
5930
|
fieldType: this.database.mapToDBFieldType("pk")
|
|
5931
5931
|
};
|
|
@@ -6177,8 +6177,8 @@ class oi {
|
|
|
6177
6177
|
buildTables() {
|
|
6178
6178
|
Object.entries(this.map.records).forEach(([t, e]) => {
|
|
6179
6179
|
this.tables[e.table] || (this.tables[e.table] = { columns: {
|
|
6180
|
-
[
|
|
6181
|
-
name:
|
|
6180
|
+
[re]: {
|
|
6181
|
+
name: re,
|
|
6182
6182
|
type: "pk",
|
|
6183
6183
|
fieldType: this.database.mapToDBFieldType("pk")
|
|
6184
6184
|
}
|
|
@@ -6222,7 +6222,7 @@ ${Object.values(this.tables[t].columns).map((i) => ` "${i.name}" ${i.fieldTyp
|
|
|
6222
6222
|
return this.fieldCounter++, this.fieldNameMap.set(t, r), this.usedFieldNames.add(r), r;
|
|
6223
6223
|
}
|
|
6224
6224
|
}
|
|
6225
|
-
const X = "_System_", q = "_Dictionary_",
|
|
6225
|
+
const X = "_System_", q = "_Dictionary_", ie = "id", re = "_rowId", ni = I.create({
|
|
6226
6226
|
name: X,
|
|
6227
6227
|
properties: [
|
|
6228
6228
|
v.create({
|
|
@@ -6241,7 +6241,7 @@ const X = "_System_", q = "_Dictionary_", re = "id", se = "_rowId", ni = C.creat
|
|
|
6241
6241
|
collection: !1
|
|
6242
6242
|
})
|
|
6243
6243
|
]
|
|
6244
|
-
}), ci =
|
|
6244
|
+
}), ci = I.create({
|
|
6245
6245
|
name: q,
|
|
6246
6246
|
properties: [
|
|
6247
6247
|
v.create({
|
|
@@ -6255,7 +6255,7 @@ const X = "_System_", q = "_Dictionary_", re = "id", se = "_rowId", ni = C.creat
|
|
|
6255
6255
|
collection: !1
|
|
6256
6256
|
})
|
|
6257
6257
|
]
|
|
6258
|
-
}),
|
|
6258
|
+
}), gr = 0, Et = 1, br = 2;
|
|
6259
6259
|
class li {
|
|
6260
6260
|
constructor(t, e) {
|
|
6261
6261
|
this.controller = t, this.scheduler = e, this.sourceMaps = [], this.sourceMapTree = {};
|
|
@@ -6270,18 +6270,18 @@ class li {
|
|
|
6270
6270
|
if (this.scheduler.isDataBasedComputation(i)) {
|
|
6271
6271
|
if (Object.entries(i.dataDeps).forEach(([r, s]) => {
|
|
6272
6272
|
const a = this.convertDataDepToERMutationEventsSourceMap(r, s, i);
|
|
6273
|
-
e[s.phase ||
|
|
6273
|
+
e[s.phase || Et].push(...a);
|
|
6274
6274
|
}), i.dataContext.type === "property" && Object.values(i.dataDeps).some((r) => r.type === "global")) {
|
|
6275
6275
|
const r = {
|
|
6276
6276
|
type: "records",
|
|
6277
6277
|
source: i.dataContext.host
|
|
6278
6278
|
};
|
|
6279
|
-
e[
|
|
6279
|
+
e[Et].push(...this.convertDataDepToERMutationEventsSourceMap("_self", r, i, "create"));
|
|
6280
6280
|
}
|
|
6281
6281
|
} else {
|
|
6282
6282
|
const { eventDeps: r } = i;
|
|
6283
6283
|
for (const s of Object.values(r))
|
|
6284
|
-
e[s.phase ||
|
|
6284
|
+
e[s.phase || Et].push({
|
|
6285
6285
|
type: s.type,
|
|
6286
6286
|
recordName: s.recordName,
|
|
6287
6287
|
record: s.record,
|
|
@@ -6486,28 +6486,28 @@ class S {
|
|
|
6486
6486
|
this.skip = () => new Rt();
|
|
6487
6487
|
}
|
|
6488
6488
|
static {
|
|
6489
|
-
this.resolved = (t, e) => new
|
|
6489
|
+
this.resolved = (t, e) => new we(t, e);
|
|
6490
6490
|
}
|
|
6491
6491
|
static {
|
|
6492
|
-
this.async = (t) => new
|
|
6492
|
+
this.async = (t) => new Re(t);
|
|
6493
6493
|
}
|
|
6494
6494
|
static {
|
|
6495
|
-
this.fullRecompute = (t) => new
|
|
6495
|
+
this.fullRecompute = (t) => new be(t);
|
|
6496
6496
|
}
|
|
6497
6497
|
}
|
|
6498
6498
|
class Rt extends S {
|
|
6499
6499
|
}
|
|
6500
|
-
class
|
|
6500
|
+
class be extends S {
|
|
6501
6501
|
constructor(t) {
|
|
6502
6502
|
super(), this.reason = t;
|
|
6503
6503
|
}
|
|
6504
6504
|
}
|
|
6505
|
-
class
|
|
6505
|
+
class Re extends S {
|
|
6506
6506
|
constructor(t) {
|
|
6507
6507
|
super(), this.args = t;
|
|
6508
6508
|
}
|
|
6509
6509
|
}
|
|
6510
|
-
class
|
|
6510
|
+
class we extends S {
|
|
6511
6511
|
constructor(t, e) {
|
|
6512
6512
|
super(), this.result = t, this.args = e;
|
|
6513
6513
|
}
|
|
@@ -6527,7 +6527,7 @@ class E {
|
|
|
6527
6527
|
return t[this.key];
|
|
6528
6528
|
}
|
|
6529
6529
|
}
|
|
6530
|
-
class
|
|
6530
|
+
class B {
|
|
6531
6531
|
constructor(t) {
|
|
6532
6532
|
this.defaultValue = t;
|
|
6533
6533
|
}
|
|
@@ -6538,18 +6538,18 @@ class _ {
|
|
|
6538
6538
|
return await this.controller.system.storage.dict.get(this.key);
|
|
6539
6539
|
}
|
|
6540
6540
|
}
|
|
6541
|
-
function
|
|
6541
|
+
function Pt(u, t) {
|
|
6542
6542
|
if (t == null || u === t) return !0;
|
|
6543
6543
|
if (typeof t != "object" || t === null)
|
|
6544
6544
|
return u === t;
|
|
6545
6545
|
if (typeof u != "object" || u === null)
|
|
6546
6546
|
return !1;
|
|
6547
6547
|
for (const e in t)
|
|
6548
|
-
if (!(e in u) ||
|
|
6548
|
+
if (!(e in u) || !Pt(u[e], t[e]))
|
|
6549
6549
|
return !1;
|
|
6550
6550
|
return !0;
|
|
6551
6551
|
}
|
|
6552
|
-
class
|
|
6552
|
+
class Ne {
|
|
6553
6553
|
constructor(t) {
|
|
6554
6554
|
this.data = t, this.map = {};
|
|
6555
6555
|
for (const e of t.transfers)
|
|
@@ -6562,26 +6562,26 @@ class ve {
|
|
|
6562
6562
|
const i = this.map[t];
|
|
6563
6563
|
if (i) {
|
|
6564
6564
|
for (const r of i)
|
|
6565
|
-
if (
|
|
6565
|
+
if (Pt(e, r.trigger))
|
|
6566
6566
|
return r.next;
|
|
6567
6567
|
}
|
|
6568
6568
|
return null;
|
|
6569
6569
|
}
|
|
6570
6570
|
findTransfers(t) {
|
|
6571
|
-
return this.data.transfers.filter((e) =>
|
|
6571
|
+
return this.data.transfers.filter((e) => Pt(t, e.trigger));
|
|
6572
6572
|
}
|
|
6573
6573
|
}
|
|
6574
6574
|
function T(u, t) {
|
|
6575
6575
|
if (!u)
|
|
6576
6576
|
throw new Error(t);
|
|
6577
6577
|
}
|
|
6578
|
-
function
|
|
6578
|
+
function Rr(u, t) {
|
|
6579
6579
|
return new Map(Array.from(u.entries()).map(([e, i]) => [e, t(e, i)]));
|
|
6580
6580
|
}
|
|
6581
|
-
function
|
|
6581
|
+
function wr(u, t) {
|
|
6582
6582
|
return Object.fromEntries(Object.entries(u).map(([e, i]) => [e, t(e, i)]));
|
|
6583
6583
|
}
|
|
6584
|
-
async function
|
|
6584
|
+
async function Nr(u, t) {
|
|
6585
6585
|
for (let e of u)
|
|
6586
6586
|
if (!await t(e)) return !1;
|
|
6587
6587
|
return !0;
|
|
@@ -6600,7 +6600,7 @@ async function di(u, t) {
|
|
|
6600
6600
|
}
|
|
6601
6601
|
class hi {
|
|
6602
6602
|
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
|
|
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;
|
|
6604
6604
|
for (const r of this.args.transfers) {
|
|
6605
6605
|
const s = `${r.trigger.recordName}_${r.trigger.type}`;
|
|
6606
6606
|
this.eventDeps[s] = {
|
|
@@ -6617,12 +6617,11 @@ class hi {
|
|
|
6617
6617
|
}
|
|
6618
6618
|
createState() {
|
|
6619
6619
|
return {
|
|
6620
|
-
currentState: new
|
|
6620
|
+
currentState: new B(this.initialState.name)
|
|
6621
6621
|
};
|
|
6622
6622
|
}
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
return this.defaultState.computeValue ? this.defaultState.computeValue.call(this.controller, void 0, t) : this.defaultState.name;
|
|
6623
|
+
async getInitialValue(t) {
|
|
6624
|
+
return this.initialState.computeValue ? await this.initialState.computeValue.call(this.controller, void 0, t) : this.initialState.name;
|
|
6626
6625
|
}
|
|
6627
6626
|
async incrementalCompute(t, e, i) {
|
|
6628
6627
|
const r = await this.state.currentState.get(), s = this.transitionFinder?.findNextState(r, e);
|
|
@@ -6631,7 +6630,7 @@ class hi {
|
|
|
6631
6630
|
}
|
|
6632
6631
|
class pi {
|
|
6633
6632
|
constructor(t, e, i) {
|
|
6634
|
-
this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new
|
|
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;
|
|
6635
6634
|
for (const r of this.args.transfers) {
|
|
6636
6635
|
const s = `${r.trigger.recordName}_${r.trigger.type}`;
|
|
6637
6636
|
this.eventDeps[s] = {
|
|
@@ -6648,19 +6647,18 @@ class pi {
|
|
|
6648
6647
|
}
|
|
6649
6648
|
createState() {
|
|
6650
6649
|
return {
|
|
6651
|
-
currentState: new E(this.
|
|
6650
|
+
currentState: new E(this.initialState.name)
|
|
6652
6651
|
};
|
|
6653
6652
|
}
|
|
6654
|
-
|
|
6655
|
-
getDefaultValue(t) {
|
|
6653
|
+
async getInitialValue(t) {
|
|
6656
6654
|
const e = t[this.dataContext.id.name];
|
|
6657
6655
|
return T(
|
|
6658
|
-
!(e !== void 0 && !this.
|
|
6656
|
+
!(e !== void 0 && !this.initialState.computeValue),
|
|
6659
6657
|
`${this.dataContext.host.name}.${this.dataContext.id.name} have been set when ${this.dataContext.host.name} created,
|
|
6660
|
-
if you want to save the use the initial value, you need to define computeValue in
|
|
6658
|
+
if you want to save the use the initial value, you need to define computeValue in initialState to save it.
|
|
6661
6659
|
Or if you want to use state name as value, you should not set ${this.dataContext.host.name}.${this.dataContext.id.name} when ${this.dataContext.host.name} created.
|
|
6662
6660
|
`
|
|
6663
|
-
), e !== void 0 || this.
|
|
6661
|
+
), e !== void 0 || this.initialState.computeValue ? await this.initialState.computeValue.call(this.controller, e, void 0) : this.initialState.name;
|
|
6664
6662
|
}
|
|
6665
6663
|
async computeDirtyRecords(t) {
|
|
6666
6664
|
const e = this.transitionFinder.findTransfers(t);
|
|
@@ -6677,13 +6675,13 @@ Or if you want to use state name as value, you should not set ${this.dataContext
|
|
|
6677
6675
|
};
|
|
6678
6676
|
}
|
|
6679
6677
|
}
|
|
6680
|
-
const
|
|
6678
|
+
const vr = K.create({
|
|
6681
6679
|
name: "nonExistent",
|
|
6682
6680
|
computeValue: () => null
|
|
6683
|
-
}),
|
|
6681
|
+
}), kr = K.create({
|
|
6684
6682
|
name: "nonDeleted",
|
|
6685
6683
|
computeValue: () => !1
|
|
6686
|
-
}),
|
|
6684
|
+
}), Tr = K.create({
|
|
6687
6685
|
name: "deleted",
|
|
6688
6686
|
computeValue: () => !0
|
|
6689
6687
|
}), fi = [hi, pi];
|
|
@@ -6704,7 +6702,7 @@ class mi {
|
|
|
6704
6702
|
static {
|
|
6705
6703
|
this.contextType = "global";
|
|
6706
6704
|
}
|
|
6707
|
-
|
|
6705
|
+
getInitialValue() {
|
|
6708
6706
|
return 0;
|
|
6709
6707
|
}
|
|
6710
6708
|
createState() {
|
|
@@ -6768,7 +6766,7 @@ class yi {
|
|
|
6768
6766
|
itemResult: new E(0, this.relation.name)
|
|
6769
6767
|
};
|
|
6770
6768
|
}
|
|
6771
|
-
|
|
6769
|
+
getInitialValue() {
|
|
6772
6770
|
return 0;
|
|
6773
6771
|
}
|
|
6774
6772
|
async compute({ _current: t, ...e }) {
|
|
@@ -6836,12 +6834,12 @@ class bi {
|
|
|
6836
6834
|
}
|
|
6837
6835
|
createState() {
|
|
6838
6836
|
return {
|
|
6839
|
-
matchCount: new
|
|
6840
|
-
totalCount: new
|
|
6837
|
+
matchCount: new B(0),
|
|
6838
|
+
totalCount: new B(0),
|
|
6841
6839
|
isItemMatch: new E(!1, this.args.record.name)
|
|
6842
6840
|
};
|
|
6843
6841
|
}
|
|
6844
|
-
|
|
6842
|
+
getInitialValue() {
|
|
6845
6843
|
return this.defaultValue;
|
|
6846
6844
|
}
|
|
6847
6845
|
async compute({ main: t, ...e }) {
|
|
@@ -6901,7 +6899,7 @@ class Ri {
|
|
|
6901
6899
|
isItemMatch: new E(!1, this.relation.name)
|
|
6902
6900
|
};
|
|
6903
6901
|
}
|
|
6904
|
-
|
|
6902
|
+
getInitialValue() {
|
|
6905
6903
|
return !this.args.notEmpty;
|
|
6906
6904
|
}
|
|
6907
6905
|
async compute({ _current: t, ...e }) {
|
|
@@ -6964,11 +6962,11 @@ class Ni {
|
|
|
6964
6962
|
}
|
|
6965
6963
|
createState() {
|
|
6966
6964
|
return {
|
|
6967
|
-
matchCount: new
|
|
6965
|
+
matchCount: new B(0),
|
|
6968
6966
|
isItemMatch: new E(!1, this.args.record.name)
|
|
6969
6967
|
};
|
|
6970
6968
|
}
|
|
6971
|
-
|
|
6969
|
+
getInitialValue() {
|
|
6972
6970
|
return !1;
|
|
6973
6971
|
}
|
|
6974
6972
|
async compute({ main: t, ...e }) {
|
|
@@ -7032,7 +7030,7 @@ class vi {
|
|
|
7032
7030
|
isItemMatch: new E(!1, this.relation.name)
|
|
7033
7031
|
};
|
|
7034
7032
|
}
|
|
7035
|
-
|
|
7033
|
+
getInitialValue() {
|
|
7036
7034
|
return !1;
|
|
7037
7035
|
}
|
|
7038
7036
|
async compute({ _current: t, ...e }) {
|
|
@@ -7094,11 +7092,11 @@ class Ti {
|
|
|
7094
7092
|
}
|
|
7095
7093
|
createState() {
|
|
7096
7094
|
return {
|
|
7097
|
-
count: new
|
|
7095
|
+
count: new B(0),
|
|
7098
7096
|
isItemMatch: new E(!1, this.record.name)
|
|
7099
7097
|
};
|
|
7100
7098
|
}
|
|
7101
|
-
|
|
7099
|
+
getInitialValue() {
|
|
7102
7100
|
return 0;
|
|
7103
7101
|
}
|
|
7104
7102
|
async compute({ main: t, ...e }) {
|
|
@@ -7153,7 +7151,7 @@ class Ai {
|
|
|
7153
7151
|
isItemMatchCount: new E(!1, this.relation.name)
|
|
7154
7152
|
} : {};
|
|
7155
7153
|
}
|
|
7156
|
-
|
|
7154
|
+
getInitialValue() {
|
|
7157
7155
|
return 0;
|
|
7158
7156
|
}
|
|
7159
7157
|
async compute({ _current: t, ...e }) {
|
|
@@ -7220,7 +7218,7 @@ class Ei {
|
|
|
7220
7218
|
});
|
|
7221
7219
|
}
|
|
7222
7220
|
static {
|
|
7223
|
-
this.computationType =
|
|
7221
|
+
this.computationType = kt;
|
|
7224
7222
|
}
|
|
7225
7223
|
static {
|
|
7226
7224
|
this.contextType = ["entity", "relation"];
|
|
@@ -7231,7 +7229,7 @@ class Ei {
|
|
|
7231
7229
|
transformIndex: new E(0)
|
|
7232
7230
|
};
|
|
7233
7231
|
}
|
|
7234
|
-
|
|
7232
|
+
getInitialValue() {
|
|
7235
7233
|
return [];
|
|
7236
7234
|
}
|
|
7237
7235
|
async compute({ _source: t }) {
|
|
@@ -7316,7 +7314,7 @@ class Ei {
|
|
|
7316
7314
|
return r;
|
|
7317
7315
|
}
|
|
7318
7316
|
}
|
|
7319
|
-
const
|
|
7317
|
+
const Ii = [Ei];
|
|
7320
7318
|
class M {
|
|
7321
7319
|
constructor(t) {
|
|
7322
7320
|
this.node = t;
|
|
@@ -7421,7 +7419,7 @@ class M {
|
|
|
7421
7419
|
return new wt(this, "<", t);
|
|
7422
7420
|
}
|
|
7423
7421
|
eq(t) {
|
|
7424
|
-
return new
|
|
7422
|
+
return new Gt(this, t);
|
|
7425
7423
|
}
|
|
7426
7424
|
getVariables() {
|
|
7427
7425
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -7553,7 +7551,7 @@ class wt {
|
|
|
7553
7551
|
}
|
|
7554
7552
|
}
|
|
7555
7553
|
}
|
|
7556
|
-
class
|
|
7554
|
+
class Gt {
|
|
7557
7555
|
constructor(t, e) {
|
|
7558
7556
|
this.left = t, this.right = e;
|
|
7559
7557
|
}
|
|
@@ -7588,7 +7586,7 @@ class Xt {
|
|
|
7588
7586
|
}
|
|
7589
7587
|
}
|
|
7590
7588
|
}
|
|
7591
|
-
class
|
|
7589
|
+
class Ci {
|
|
7592
7590
|
constructor(t, e, i) {
|
|
7593
7591
|
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;
|
|
7594
7592
|
}
|
|
@@ -7600,11 +7598,11 @@ class xi {
|
|
|
7600
7598
|
}
|
|
7601
7599
|
createState() {
|
|
7602
7600
|
return {
|
|
7603
|
-
lastRecomputeTime: new
|
|
7604
|
-
nextRecomputeTime: new
|
|
7601
|
+
lastRecomputeTime: new B(null),
|
|
7602
|
+
nextRecomputeTime: new B(null)
|
|
7605
7603
|
};
|
|
7606
7604
|
}
|
|
7607
|
-
|
|
7605
|
+
getInitialValue() {
|
|
7608
7606
|
return null;
|
|
7609
7607
|
}
|
|
7610
7608
|
// TODO now 是不是应该用 dataDeps 动态注入???这样能手动测试。改成在哪里配置?
|
|
@@ -7613,14 +7611,14 @@ class xi {
|
|
|
7613
7611
|
let r, s;
|
|
7614
7612
|
if (e instanceof M)
|
|
7615
7613
|
r = e.evaluate({ now: i }), s = i + this.nextRecomputeTime(i, t);
|
|
7616
|
-
else if (e instanceof wt || e instanceof
|
|
7614
|
+
else if (e instanceof wt || e instanceof Gt)
|
|
7617
7615
|
r = e.evaluate({ now: i }), s = e.solve();
|
|
7618
7616
|
else
|
|
7619
7617
|
throw new Error("Invalid result type");
|
|
7620
7618
|
return await this.state.lastRecomputeTime.set(i), await this.state.nextRecomputeTime.set(s), r;
|
|
7621
7619
|
}
|
|
7622
7620
|
}
|
|
7623
|
-
class
|
|
7621
|
+
class xi {
|
|
7624
7622
|
constructor(t, e, i) {
|
|
7625
7623
|
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !1, this.dataDeps = {
|
|
7626
7624
|
_current: {
|
|
@@ -7642,7 +7640,7 @@ class Ii {
|
|
|
7642
7640
|
nextRecomputeTime: new E(null)
|
|
7643
7641
|
};
|
|
7644
7642
|
}
|
|
7645
|
-
|
|
7643
|
+
getInitialValue() {
|
|
7646
7644
|
return 0;
|
|
7647
7645
|
}
|
|
7648
7646
|
// TODO now 是不是应该用 dataDeps 动态注入???这样能手动测试。改成在哪里配置?
|
|
@@ -7651,14 +7649,14 @@ class Ii {
|
|
|
7651
7649
|
let s, a;
|
|
7652
7650
|
if (i instanceof M)
|
|
7653
7651
|
s = i.evaluate({ now: r }), a = r + this.nextRecomputeTime(r, t);
|
|
7654
|
-
else if (i instanceof wt || i instanceof
|
|
7652
|
+
else if (i instanceof wt || i instanceof Gt)
|
|
7655
7653
|
s = i.evaluate({ now: r }), a = i.solve();
|
|
7656
7654
|
else
|
|
7657
7655
|
throw new Error("Invalid result type");
|
|
7658
7656
|
return await this.state.lastRecomputeTime.set(e, r), await this.state.nextRecomputeTime.set(e, a), s;
|
|
7659
7657
|
}
|
|
7660
7658
|
}
|
|
7661
|
-
const Mi = [
|
|
7659
|
+
const Mi = [Ci, xi];
|
|
7662
7660
|
class Pi {
|
|
7663
7661
|
constructor(t, e, i) {
|
|
7664
7662
|
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)
|
|
@@ -7686,7 +7684,7 @@ class Pi {
|
|
|
7686
7684
|
itemValue: new E(0, this.record.name)
|
|
7687
7685
|
};
|
|
7688
7686
|
}
|
|
7689
|
-
|
|
7687
|
+
getInitialValue() {
|
|
7690
7688
|
return 0;
|
|
7691
7689
|
}
|
|
7692
7690
|
resolveSumField(t, e = this.sumFieldPath) {
|
|
@@ -7751,7 +7749,7 @@ class $i {
|
|
|
7751
7749
|
itemResult: new E(0, this.relation.name)
|
|
7752
7750
|
};
|
|
7753
7751
|
}
|
|
7754
|
-
|
|
7752
|
+
getInitialValue() {
|
|
7755
7753
|
return 0;
|
|
7756
7754
|
}
|
|
7757
7755
|
resolveSumField(t, e = this.sumFieldPath) {
|
|
@@ -7809,8 +7807,8 @@ class $i {
|
|
|
7809
7807
|
return a;
|
|
7810
7808
|
}
|
|
7811
7809
|
}
|
|
7812
|
-
const
|
|
7813
|
-
class
|
|
7810
|
+
const Oi = [Pi, $i];
|
|
7811
|
+
class Fi {
|
|
7814
7812
|
constructor(t, e, i) {
|
|
7815
7813
|
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)
|
|
7816
7814
|
throw new Error("Average computation requires attributeQuery with at least one field");
|
|
@@ -7834,12 +7832,12 @@ class Oi {
|
|
|
7834
7832
|
}
|
|
7835
7833
|
createState() {
|
|
7836
7834
|
return {
|
|
7837
|
-
sum: new
|
|
7838
|
-
count: new
|
|
7835
|
+
sum: new B(0),
|
|
7836
|
+
count: new B(0),
|
|
7839
7837
|
itemValue: new E(0, this.record.name)
|
|
7840
7838
|
};
|
|
7841
7839
|
}
|
|
7842
|
-
|
|
7840
|
+
getInitialValue() {
|
|
7843
7841
|
return 0;
|
|
7844
7842
|
}
|
|
7845
7843
|
resolveAvgField(t, e = this.avgFieldPath) {
|
|
@@ -7883,7 +7881,7 @@ class Oi {
|
|
|
7883
7881
|
return await this.state.sum.set(a), await this.state.count.set(s), s > 0 ? a / s : 0;
|
|
7884
7882
|
}
|
|
7885
7883
|
}
|
|
7886
|
-
class
|
|
7884
|
+
class Di {
|
|
7887
7885
|
constructor(t, e, i) {
|
|
7888
7886
|
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;
|
|
7889
7887
|
const r = this.args.attributeQuery || [];
|
|
@@ -7915,7 +7913,7 @@ class Fi {
|
|
|
7915
7913
|
itemResult: new E(0, this.relation.name)
|
|
7916
7914
|
};
|
|
7917
7915
|
}
|
|
7918
|
-
|
|
7916
|
+
getInitialValue() {
|
|
7919
7917
|
return 0;
|
|
7920
7918
|
}
|
|
7921
7919
|
resolveAvgField(t, e = this.avgFieldPath) {
|
|
@@ -7967,8 +7965,8 @@ class Fi {
|
|
|
7967
7965
|
return await this.state.count.set(e.record, a), a > 0 ? o / a : 0;
|
|
7968
7966
|
}
|
|
7969
7967
|
}
|
|
7970
|
-
const Vi = [
|
|
7971
|
-
class
|
|
7968
|
+
const Vi = [Fi, Di];
|
|
7969
|
+
class At {
|
|
7972
7970
|
constructor(t, e, i) {
|
|
7973
7971
|
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) => {
|
|
7974
7972
|
if (this.computeCallback) {
|
|
@@ -7998,7 +7996,7 @@ class St {
|
|
|
7998
7996
|
};
|
|
7999
7997
|
return await this.incrementalPatchComputeCallback.call(c, s, a, o, n);
|
|
8000
7998
|
}
|
|
8001
|
-
}), e.createState && (this.createStateCallback = e.createState), e.
|
|
7999
|
+
}), e.createState && (this.createStateCallback = e.createState), e.getInitialValue && (this.getInitialValueCallback = e.getInitialValue), e.asyncReturn && (this.asyncReturnCallback = e.asyncReturn, this.asyncReturn = async (...r) => {
|
|
8002
8000
|
if (this.asyncReturnCallback) {
|
|
8003
8001
|
const [s, a, o] = r, n = {
|
|
8004
8002
|
controller: this.controller,
|
|
@@ -8012,7 +8010,7 @@ class St {
|
|
|
8012
8010
|
}));
|
|
8013
8011
|
}
|
|
8014
8012
|
static {
|
|
8015
|
-
this.computationType =
|
|
8013
|
+
this.computationType = Kt;
|
|
8016
8014
|
}
|
|
8017
8015
|
createState() {
|
|
8018
8016
|
if (this.createStateCallback) {
|
|
@@ -8023,9 +8021,9 @@ class St {
|
|
|
8023
8021
|
}
|
|
8024
8022
|
return {};
|
|
8025
8023
|
}
|
|
8026
|
-
|
|
8027
|
-
if (this.
|
|
8028
|
-
return this.
|
|
8024
|
+
getInitialValue() {
|
|
8025
|
+
if (this.getInitialValueCallback)
|
|
8026
|
+
return this.getInitialValueCallback.call(this.controller);
|
|
8029
8027
|
}
|
|
8030
8028
|
async compute(...t) {
|
|
8031
8029
|
if (this.computeCallback) {
|
|
@@ -8039,22 +8037,22 @@ class St {
|
|
|
8039
8037
|
return S.skip();
|
|
8040
8038
|
}
|
|
8041
8039
|
}
|
|
8042
|
-
class Qi extends
|
|
8040
|
+
class Qi extends At {
|
|
8043
8041
|
static {
|
|
8044
8042
|
this.contextType = "global";
|
|
8045
8043
|
}
|
|
8046
8044
|
}
|
|
8047
|
-
class Li extends
|
|
8045
|
+
class Li extends At {
|
|
8048
8046
|
static {
|
|
8049
8047
|
this.contextType = "entity";
|
|
8050
8048
|
}
|
|
8051
8049
|
}
|
|
8052
|
-
class qi extends
|
|
8050
|
+
class qi extends At {
|
|
8053
8051
|
static {
|
|
8054
8052
|
this.contextType = "relation";
|
|
8055
8053
|
}
|
|
8056
8054
|
}
|
|
8057
|
-
class
|
|
8055
|
+
class Bi extends At {
|
|
8058
8056
|
static {
|
|
8059
8057
|
this.contextType = "property";
|
|
8060
8058
|
}
|
|
@@ -8069,13 +8067,13 @@ If you want to use aggregated data from all records in the entity/relation, you
|
|
|
8069
8067
|
super(t, e, i);
|
|
8070
8068
|
}
|
|
8071
8069
|
}
|
|
8072
|
-
const
|
|
8070
|
+
const _i = [
|
|
8073
8071
|
Qi,
|
|
8074
8072
|
Li,
|
|
8075
8073
|
qi,
|
|
8076
|
-
|
|
8074
|
+
Bi
|
|
8077
8075
|
];
|
|
8078
|
-
class
|
|
8076
|
+
class W extends Error {
|
|
8079
8077
|
constructor(t, e = {}) {
|
|
8080
8078
|
super(`${t}. Caused by: ${e.causedBy?.message}`), this.name = this.constructor.name, this.timestamp = /* @__PURE__ */ new Date(), this.errorId = this.generateErrorId(), this.errorType = e.errorType || this.constructor.name, this.context = e.context || {}, this.causedBy = e.causedBy, this.stackTrace = this.stack, Object.setPrototypeOf(this, new.target.prototype);
|
|
8081
8079
|
}
|
|
@@ -8088,7 +8086,7 @@ class J extends Error {
|
|
|
8088
8086
|
getErrorChain() {
|
|
8089
8087
|
const t = [this];
|
|
8090
8088
|
let e = this.causedBy;
|
|
8091
|
-
for (; e && (t.push(e), e instanceof
|
|
8089
|
+
for (; e && (t.push(e), e instanceof W); )
|
|
8092
8090
|
e = e.causedBy;
|
|
8093
8091
|
return t;
|
|
8094
8092
|
}
|
|
@@ -8192,13 +8190,13 @@ Stack trace:`, r.stack.split(`
|
|
|
8192
8190
|
return null;
|
|
8193
8191
|
}
|
|
8194
8192
|
}
|
|
8195
|
-
var
|
|
8196
|
-
class z extends
|
|
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 || {});
|
|
8194
|
+
class z extends W {
|
|
8197
8195
|
constructor(t, e = {}) {
|
|
8198
8196
|
super(t, {
|
|
8199
8197
|
errorType: e.context?.errorType || "InteractionExecutionError",
|
|
8200
8198
|
context: {
|
|
8201
|
-
category:
|
|
8199
|
+
category: H.INTERACTION,
|
|
8202
8200
|
interactionName: e.interactionName,
|
|
8203
8201
|
userId: e.userId,
|
|
8204
8202
|
payload: e.payload,
|
|
@@ -8206,15 +8204,15 @@ class z extends J {
|
|
|
8206
8204
|
...e.context
|
|
8207
8205
|
},
|
|
8208
8206
|
causedBy: e.causedBy
|
|
8209
|
-
}), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity ||
|
|
8207
|
+
}), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || F.HIGH;
|
|
8210
8208
|
}
|
|
8211
8209
|
}
|
|
8212
|
-
class
|
|
8210
|
+
class se extends W {
|
|
8213
8211
|
constructor(t, e = {}) {
|
|
8214
8212
|
super(t, {
|
|
8215
8213
|
errorType: e.context?.errorType || "ActivityError",
|
|
8216
8214
|
context: {
|
|
8217
|
-
category:
|
|
8215
|
+
category: H.ACTIVITY,
|
|
8218
8216
|
activityName: e.activityName,
|
|
8219
8217
|
activityId: e.activityId,
|
|
8220
8218
|
activityInstanceId: e.activityInstanceId,
|
|
@@ -8222,15 +8220,15 @@ class ae extends J {
|
|
|
8222
8220
|
...e.context
|
|
8223
8221
|
},
|
|
8224
8222
|
causedBy: e.causedBy
|
|
8225
|
-
}), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity ||
|
|
8223
|
+
}), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || F.MEDIUM;
|
|
8226
8224
|
}
|
|
8227
8225
|
}
|
|
8228
|
-
class
|
|
8226
|
+
class V extends W {
|
|
8229
8227
|
constructor(t, e = {}) {
|
|
8230
8228
|
super(t, {
|
|
8231
8229
|
errorType: e.context?.errorType || "ComputationError",
|
|
8232
8230
|
context: {
|
|
8233
|
-
category:
|
|
8231
|
+
category: H.COMPUTATION,
|
|
8234
8232
|
handleName: e.handleName,
|
|
8235
8233
|
computationName: e.computationName,
|
|
8236
8234
|
dataContext: e.dataContext,
|
|
@@ -8238,14 +8236,14 @@ class F extends J {
|
|
|
8238
8236
|
...e.context
|
|
8239
8237
|
},
|
|
8240
8238
|
causedBy: e.causedBy
|
|
8241
|
-
}), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity ||
|
|
8239
|
+
}), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || F.MEDIUM;
|
|
8242
8240
|
}
|
|
8243
8241
|
}
|
|
8244
|
-
class
|
|
8242
|
+
class ae extends V {
|
|
8245
8243
|
constructor(t, e = {}) {
|
|
8246
8244
|
super(t, {
|
|
8247
8245
|
...e,
|
|
8248
|
-
severity:
|
|
8246
|
+
severity: F.HIGH,
|
|
8249
8247
|
context: {
|
|
8250
8248
|
errorType: "ComputationStateError",
|
|
8251
8249
|
stateKey: e.stateKey,
|
|
@@ -8256,11 +8254,11 @@ class oe extends F {
|
|
|
8256
8254
|
}), this.stateKey = e.stateKey, this.stateValue = e.stateValue, this.expectedStateType = e.expectedStateType, this.actualStateType = e.actualStateType;
|
|
8257
8255
|
}
|
|
8258
8256
|
}
|
|
8259
|
-
class
|
|
8257
|
+
class J extends V {
|
|
8260
8258
|
constructor(t, e = {}) {
|
|
8261
8259
|
super(t, {
|
|
8262
8260
|
...e,
|
|
8263
|
-
severity:
|
|
8261
|
+
severity: F.MEDIUM,
|
|
8264
8262
|
context: {
|
|
8265
8263
|
errorType: "ComputationDataDepError",
|
|
8266
8264
|
depName: e.depName,
|
|
@@ -8271,26 +8269,42 @@ class W extends F {
|
|
|
8271
8269
|
}), this.depName = e.depName, this.depType = e.depType, this.missingData = e.missingData, this.invalidData = e.invalidData;
|
|
8272
8270
|
}
|
|
8273
8271
|
}
|
|
8274
|
-
class
|
|
8272
|
+
class It extends W {
|
|
8275
8273
|
constructor(t, e = {}) {
|
|
8276
8274
|
super(t, {
|
|
8277
8275
|
errorType: e.context?.errorType || "SchedulerError",
|
|
8278
8276
|
context: {
|
|
8279
|
-
category:
|
|
8277
|
+
category: H.SYSTEM,
|
|
8280
8278
|
schedulingPhase: e.schedulingPhase,
|
|
8281
8279
|
failedComputations: e.failedComputations,
|
|
8282
8280
|
...e.context
|
|
8283
8281
|
},
|
|
8284
8282
|
causedBy: e.causedBy
|
|
8285
|
-
}), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity =
|
|
8283
|
+
}), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = F.HIGH;
|
|
8284
|
+
}
|
|
8285
|
+
}
|
|
8286
|
+
class Wi extends W {
|
|
8287
|
+
constructor(t, e) {
|
|
8288
|
+
super(t, {
|
|
8289
|
+
errorType: "SideEffectError",
|
|
8290
|
+
context: {
|
|
8291
|
+
category: H.SYSTEM,
|
|
8292
|
+
sideEffectName: e.sideEffectName,
|
|
8293
|
+
recordName: e.recordName,
|
|
8294
|
+
mutationType: e.mutationType,
|
|
8295
|
+
recordId: e.recordId,
|
|
8296
|
+
...e.context
|
|
8297
|
+
},
|
|
8298
|
+
causedBy: e.causedBy
|
|
8299
|
+
}), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity = F.MEDIUM;
|
|
8286
8300
|
}
|
|
8287
8301
|
}
|
|
8288
|
-
class
|
|
8302
|
+
class O extends W {
|
|
8289
8303
|
constructor(t, e) {
|
|
8290
8304
|
super(t, {
|
|
8291
8305
|
errorType: e.context?.errorType || "ConditionError",
|
|
8292
8306
|
context: {
|
|
8293
|
-
category:
|
|
8307
|
+
category: H.PERMISSION,
|
|
8294
8308
|
checkType: e.checkType,
|
|
8295
8309
|
fieldName: e.fieldName,
|
|
8296
8310
|
payload: e.payload,
|
|
@@ -8298,16 +8312,16 @@ class D extends J {
|
|
|
8298
8312
|
...e.context
|
|
8299
8313
|
},
|
|
8300
8314
|
causedBy: e.causedBy
|
|
8301
|
-
}), 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 ||
|
|
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;
|
|
8302
8316
|
}
|
|
8303
8317
|
/**
|
|
8304
8318
|
* Helper factory methods for common condition error scenarios
|
|
8305
8319
|
*/
|
|
8306
8320
|
static userCheckFailed(t, e) {
|
|
8307
|
-
return new
|
|
8321
|
+
return new O("User check failed", {
|
|
8308
8322
|
checkType: "user",
|
|
8309
8323
|
evaluationError: t,
|
|
8310
|
-
severity:
|
|
8324
|
+
severity: F.HIGH,
|
|
8311
8325
|
context: e,
|
|
8312
8326
|
type: "check user failed"
|
|
8313
8327
|
// For backward compatibility
|
|
@@ -8315,21 +8329,21 @@ class D extends J {
|
|
|
8315
8329
|
}
|
|
8316
8330
|
static payloadValidationFailed(t, e, i, r) {
|
|
8317
8331
|
const s = `${t} ${e}`;
|
|
8318
|
-
return new
|
|
8332
|
+
return new O(`Payload validation failed for field '${t}': ${e}`, {
|
|
8319
8333
|
checkType: "payload",
|
|
8320
8334
|
fieldName: t,
|
|
8321
8335
|
payload: i,
|
|
8322
8336
|
evaluationError: r,
|
|
8323
|
-
severity:
|
|
8337
|
+
severity: F.MEDIUM,
|
|
8324
8338
|
type: s
|
|
8325
8339
|
// For backward compatibility
|
|
8326
8340
|
});
|
|
8327
8341
|
}
|
|
8328
8342
|
static conditionCheckFailed(t, e) {
|
|
8329
|
-
return new
|
|
8343
|
+
return new O(`Condition check failed: ${t.data.name}`, {
|
|
8330
8344
|
checkType: "condition",
|
|
8331
8345
|
evaluationError: t,
|
|
8332
|
-
severity:
|
|
8346
|
+
severity: F.HIGH,
|
|
8333
8347
|
context: e,
|
|
8334
8348
|
type: "condition check failed"
|
|
8335
8349
|
// For backward compatibility
|
|
@@ -8337,29 +8351,29 @@ class D extends J {
|
|
|
8337
8351
|
}
|
|
8338
8352
|
static attributiveCheckFailed(t, e, i, r) {
|
|
8339
8353
|
const s = `${t} ${e}`;
|
|
8340
|
-
return new
|
|
8354
|
+
return new O(`Attributive check failed for field '${t}': ${e}`, {
|
|
8341
8355
|
checkType: "attributive",
|
|
8342
8356
|
fieldName: t,
|
|
8343
8357
|
payload: i,
|
|
8344
8358
|
evaluationError: r,
|
|
8345
|
-
severity:
|
|
8359
|
+
severity: F.MEDIUM,
|
|
8346
8360
|
type: s
|
|
8347
8361
|
// For backward compatibility
|
|
8348
8362
|
});
|
|
8349
8363
|
}
|
|
8350
8364
|
static conceptCheckFailed(t, e) {
|
|
8351
|
-
return new
|
|
8365
|
+
return new O(`Concept check failed for field '${t}'`, {
|
|
8352
8366
|
checkType: "concept",
|
|
8353
8367
|
fieldName: t,
|
|
8354
8368
|
evaluationError: e,
|
|
8355
|
-
severity:
|
|
8369
|
+
severity: F.MEDIUM,
|
|
8356
8370
|
type: `${t} check concept failed`
|
|
8357
8371
|
// For backward compatibility
|
|
8358
8372
|
});
|
|
8359
8373
|
}
|
|
8360
8374
|
}
|
|
8361
|
-
const
|
|
8362
|
-
class
|
|
8375
|
+
const Ct = "_ASYNC_TASK_";
|
|
8376
|
+
class Ji {
|
|
8363
8377
|
constructor(t, e, i, r, s) {
|
|
8364
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);
|
|
8365
8379
|
const a = [];
|
|
@@ -8387,7 +8401,7 @@ class Wi {
|
|
|
8387
8401
|
const h = new d(this.controller, c, n);
|
|
8388
8402
|
if (this.computationsHandles.set(n.id, h), this.isAsyncComputation(h)) {
|
|
8389
8403
|
if (h.dataContext.type === "property") {
|
|
8390
|
-
const p =
|
|
8404
|
+
const p = I.create({
|
|
8391
8405
|
name: this.getAsyncTaskRecordKey(h),
|
|
8392
8406
|
properties: [
|
|
8393
8407
|
v.create({
|
|
@@ -8413,7 +8427,7 @@ class Wi {
|
|
|
8413
8427
|
});
|
|
8414
8428
|
e.push(p), i.push(y);
|
|
8415
8429
|
} else if (h.dataContext.type === "global") {
|
|
8416
|
-
const p =
|
|
8430
|
+
const p = I.create({
|
|
8417
8431
|
name: this.getAsyncTaskRecordKey(h),
|
|
8418
8432
|
properties: [
|
|
8419
8433
|
v.create({
|
|
@@ -8437,7 +8451,7 @@ class Wi {
|
|
|
8437
8451
|
e.push(p);
|
|
8438
8452
|
} else if (h.dataContext.type === "entity") {
|
|
8439
8453
|
h.dataContext;
|
|
8440
|
-
const p =
|
|
8454
|
+
const p = I.create({
|
|
8441
8455
|
name: this.getAsyncTaskRecordKey(h),
|
|
8442
8456
|
properties: [
|
|
8443
8457
|
v.create({
|
|
@@ -8461,7 +8475,7 @@ class Wi {
|
|
|
8461
8475
|
e.push(p);
|
|
8462
8476
|
} else if (h.dataContext.type === "relation") {
|
|
8463
8477
|
h.dataContext;
|
|
8464
|
-
const p =
|
|
8478
|
+
const p = I.create({
|
|
8465
8479
|
name: this.getAsyncTaskRecordKey(h),
|
|
8466
8480
|
properties: [
|
|
8467
8481
|
v.create({
|
|
@@ -8529,12 +8543,12 @@ class Wi {
|
|
|
8529
8543
|
}
|
|
8530
8544
|
addMutationPropertyComputationDefaultValueListeners() {
|
|
8531
8545
|
for (const t of this.computationsHandles.values())
|
|
8532
|
-
if (t.
|
|
8546
|
+
if (t.getInitialValue && t.dataContext.type === "property") {
|
|
8533
8547
|
const e = t.dataContext;
|
|
8534
8548
|
T(!e.id.defaultValue, `${e.host.name}.${e.id.name} property shuold not has a defaultValue, because it will be overridden by computation`), this.controller.system.storage.listen(async (i) => {
|
|
8535
8549
|
for (let r of i)
|
|
8536
8550
|
if (r.type === "create" && r.recordName === e.host.name) {
|
|
8537
|
-
const s = await t.
|
|
8551
|
+
const s = await t.getInitialValue?.(r.record);
|
|
8538
8552
|
s !== void 0 && await this.controller.applyResult(e, s, r.record);
|
|
8539
8553
|
}
|
|
8540
8554
|
});
|
|
@@ -8542,8 +8556,8 @@ class Wi {
|
|
|
8542
8556
|
}
|
|
8543
8557
|
async setupGlobalComputationDefaultValue() {
|
|
8544
8558
|
for (const t of this.computationsHandles.values())
|
|
8545
|
-
if (t.
|
|
8546
|
-
const e = await t.
|
|
8559
|
+
if (t.getInitialValue && t.dataContext.type === "global") {
|
|
8560
|
+
const e = await t.getInitialValue();
|
|
8547
8561
|
await this.controller.applyResult(t.dataContext, e);
|
|
8548
8562
|
}
|
|
8549
8563
|
}
|
|
@@ -8552,7 +8566,7 @@ class Wi {
|
|
|
8552
8566
|
const e = t;
|
|
8553
8567
|
if (e.state)
|
|
8554
8568
|
for (const i of Object.values(e.state))
|
|
8555
|
-
i instanceof
|
|
8569
|
+
i instanceof B && (i.controller = this.controller, await this.controller.system.storage.dict.set(i.key, i.defaultValue ?? null));
|
|
8556
8570
|
}
|
|
8557
8571
|
}
|
|
8558
8572
|
addMutationComputationListeners() {
|
|
@@ -8652,7 +8666,7 @@ class Wi {
|
|
|
8652
8666
|
try {
|
|
8653
8667
|
this.isDataBasedComputation(t.computation) ? i = await this.computeDataBasedDirtyRecordsAndEvents(t, e) : i = await this.computeEventBasedDirtyRecordsAndEvents(t, e);
|
|
8654
8668
|
} catch (r) {
|
|
8655
|
-
throw new
|
|
8669
|
+
throw new V("Failed to compute dirty records and events", {
|
|
8656
8670
|
handleName: t.computation.constructor.name,
|
|
8657
8671
|
computationName: t.computation.args.constructor.displayName,
|
|
8658
8672
|
dataContext: t.computation.dataContext,
|
|
@@ -8664,7 +8678,7 @@ class Wi {
|
|
|
8664
8678
|
try {
|
|
8665
8679
|
await this.runComputation(t.computation, s, r);
|
|
8666
8680
|
} catch (a) {
|
|
8667
|
-
throw new
|
|
8681
|
+
throw new V("Failed to run computation for dirty record", {
|
|
8668
8682
|
handleName: t.computation.constructor.name,
|
|
8669
8683
|
computationName: t.computation.args.constructor.displayName,
|
|
8670
8684
|
dataContext: t.computation.dataContext,
|
|
@@ -8675,7 +8689,7 @@ class Wi {
|
|
|
8675
8689
|
}
|
|
8676
8690
|
}
|
|
8677
8691
|
} catch (i) {
|
|
8678
|
-
throw i instanceof
|
|
8692
|
+
throw i instanceof V ? i : new It("Unexpected error in dirty records computation", {
|
|
8679
8693
|
schedulingPhase: "dirty-records-processing",
|
|
8680
8694
|
failedComputations: [t.computation.args.constructor.displayName],
|
|
8681
8695
|
causedBy: i instanceof Error ? i : new Error(String(i))
|
|
@@ -8685,8 +8699,8 @@ class Wi {
|
|
|
8685
8699
|
getAsyncTaskRecordKey(t) {
|
|
8686
8700
|
if (t.dataContext.type === "property") {
|
|
8687
8701
|
const e = t.dataContext;
|
|
8688
|
-
return `${
|
|
8689
|
-
} else return t.dataContext.type === "global" ? `${
|
|
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}`;
|
|
8690
8704
|
}
|
|
8691
8705
|
async createAsyncTask(t, e, i, r) {
|
|
8692
8706
|
if (t.dataContext.type === "property")
|
|
@@ -8738,7 +8752,7 @@ class Wi {
|
|
|
8738
8752
|
try {
|
|
8739
8753
|
a = t.dataDeps ? await this.resolveDataDeps(t, i) : {};
|
|
8740
8754
|
} catch (o) {
|
|
8741
|
-
throw new
|
|
8755
|
+
throw new J("Failed to resolve computation data dependencies", {
|
|
8742
8756
|
handleName: t.constructor.name,
|
|
8743
8757
|
computationName: t.args.constructor.displayName,
|
|
8744
8758
|
dataContext: t.dataContext,
|
|
@@ -8755,7 +8769,7 @@ class Wi {
|
|
|
8755
8769
|
try {
|
|
8756
8770
|
o = await this.controller.retrieveLastValue(t.dataContext, i);
|
|
8757
8771
|
} catch (n) {
|
|
8758
|
-
throw new
|
|
8772
|
+
throw new ae("Failed to retrieve last value for incremental computation", {
|
|
8759
8773
|
handleName: t.constructor.name,
|
|
8760
8774
|
computationName: t.args.constructor.displayName,
|
|
8761
8775
|
dataContext: t.dataContext,
|
|
@@ -8769,7 +8783,7 @@ class Wi {
|
|
|
8769
8783
|
try {
|
|
8770
8784
|
o = await this.controller.retrieveLastValue(t.dataContext, i);
|
|
8771
8785
|
} catch (n) {
|
|
8772
|
-
throw new
|
|
8786
|
+
throw new ae("Failed to retrieve last value for incremental patch computation", {
|
|
8773
8787
|
handleName: t.constructor.name,
|
|
8774
8788
|
computationName: t.args.constructor.displayName,
|
|
8775
8789
|
dataContext: t.dataContext,
|
|
@@ -8778,16 +8792,16 @@ class Wi {
|
|
|
8778
8792
|
}
|
|
8779
8793
|
s = await t.incrementalPatchCompute(o, e, i, a);
|
|
8780
8794
|
} else
|
|
8781
|
-
throw new
|
|
8795
|
+
throw new V(`Unknown computation type: ${t.constructor.name}`, {
|
|
8782
8796
|
handleName: t.constructor.name,
|
|
8783
8797
|
computationName: t.args.constructor.displayName,
|
|
8784
8798
|
dataContext: t.dataContext,
|
|
8785
8799
|
computationPhase: "type-validation"
|
|
8786
8800
|
});
|
|
8787
|
-
if (s instanceof
|
|
8801
|
+
if (s instanceof be) {
|
|
8788
8802
|
const o = t;
|
|
8789
8803
|
if (!o.compute)
|
|
8790
|
-
throw new
|
|
8804
|
+
throw new V("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
|
|
8791
8805
|
handleName: t.constructor.name,
|
|
8792
8806
|
computationName: t.args.constructor.displayName,
|
|
8793
8807
|
dataContext: t.dataContext,
|
|
@@ -8797,7 +8811,7 @@ class Wi {
|
|
|
8797
8811
|
}
|
|
8798
8812
|
}
|
|
8799
8813
|
} catch (o) {
|
|
8800
|
-
throw o instanceof
|
|
8814
|
+
throw o instanceof V ? o : new V("Computation execution failed", {
|
|
8801
8815
|
handleName: t.constructor.name,
|
|
8802
8816
|
computationName: t.args.constructor.displayName,
|
|
8803
8817
|
dataContext: t.dataContext,
|
|
@@ -8807,11 +8821,11 @@ class Wi {
|
|
|
8807
8821
|
}
|
|
8808
8822
|
if (s instanceof Rt)
|
|
8809
8823
|
return;
|
|
8810
|
-
if (s instanceof
|
|
8824
|
+
if (s instanceof Re)
|
|
8811
8825
|
try {
|
|
8812
8826
|
return await this.createAsyncTask(t, s.args, i);
|
|
8813
8827
|
} catch (o) {
|
|
8814
|
-
throw new
|
|
8828
|
+
throw new V("Failed to create async task", {
|
|
8815
8829
|
handleName: t.constructor.name,
|
|
8816
8830
|
computationName: t.args.constructor.displayName,
|
|
8817
8831
|
dataContext: t.dataContext,
|
|
@@ -8820,10 +8834,10 @@ class Wi {
|
|
|
8820
8834
|
});
|
|
8821
8835
|
}
|
|
8822
8836
|
try {
|
|
8823
|
-
const o = s instanceof
|
|
8837
|
+
const o = s instanceof we ? await t.asyncReturn(s.result, s.args) : s;
|
|
8824
8838
|
t.incrementalPatchCompute ? await this.controller.applyResultPatch(t.dataContext, o, i) : await this.controller.applyResult(t.dataContext, o, i);
|
|
8825
8839
|
} catch (o) {
|
|
8826
|
-
throw new
|
|
8840
|
+
throw new V("Failed to apply computation result", {
|
|
8827
8841
|
handleName: t.constructor.name,
|
|
8828
8842
|
computationName: t.args.constructor.displayName,
|
|
8829
8843
|
dataContext: t.dataContext,
|
|
@@ -8832,7 +8846,7 @@ class Wi {
|
|
|
8832
8846
|
});
|
|
8833
8847
|
}
|
|
8834
8848
|
} catch (s) {
|
|
8835
|
-
throw s instanceof
|
|
8849
|
+
throw s instanceof V ? s : new V("Unexpected error during computation execution", {
|
|
8836
8850
|
handleName: t.constructor.name,
|
|
8837
8851
|
computationName: t.args.constructor.displayName,
|
|
8838
8852
|
dataContext: t.dataContext,
|
|
@@ -8850,7 +8864,7 @@ class Wi {
|
|
|
8850
8864
|
return await this.controller.system.storage.find(s.source.name, void 0, {}, s.attributeQuery);
|
|
8851
8865
|
if (s.type === "property") {
|
|
8852
8866
|
if (!e?.id)
|
|
8853
|
-
throw new
|
|
8867
|
+
throw new J("Record ID is required for property data dependency", {
|
|
8854
8868
|
depName: r,
|
|
8855
8869
|
depType: s.type,
|
|
8856
8870
|
missingData: !0,
|
|
@@ -8862,7 +8876,7 @@ class Wi {
|
|
|
8862
8876
|
} else {
|
|
8863
8877
|
if (s.type === "global")
|
|
8864
8878
|
return await this.controller.system.storage.dict.get(s.source.name);
|
|
8865
|
-
throw new
|
|
8879
|
+
throw new J(`Unknown data dependency type: ${s.type}`, {
|
|
8866
8880
|
depName: r,
|
|
8867
8881
|
depType: s.type,
|
|
8868
8882
|
invalidData: !0,
|
|
@@ -8872,7 +8886,7 @@ class Wi {
|
|
|
8872
8886
|
});
|
|
8873
8887
|
}
|
|
8874
8888
|
} catch (a) {
|
|
8875
|
-
throw a instanceof
|
|
8889
|
+
throw a instanceof J ? a : new J(`Failed to resolve data dependency '${r}'`, {
|
|
8876
8890
|
depName: r,
|
|
8877
8891
|
depType: s.type,
|
|
8878
8892
|
handleName: t.constructor.name,
|
|
@@ -8884,7 +8898,7 @@ class Wi {
|
|
|
8884
8898
|
}));
|
|
8885
8899
|
return Object.fromEntries(Object.entries(t.dataDeps).map(([r], s) => [r, i[s]]));
|
|
8886
8900
|
} catch (i) {
|
|
8887
|
-
throw i instanceof
|
|
8901
|
+
throw i instanceof J ? i : new J("Failed to resolve computation data dependencies", {
|
|
8888
8902
|
handleName: t.constructor.name,
|
|
8889
8903
|
computationName: t.args.constructor.displayName,
|
|
8890
8904
|
dataContext: t.dataContext,
|
|
@@ -8903,14 +8917,14 @@ class Wi {
|
|
|
8903
8917
|
try {
|
|
8904
8918
|
this.addMutationPropertyComputationDefaultValueListeners(), this.addMutationComputationListeners(), t && (await this.setupGlobalBoundStateDefaultValues(), await this.setupGlobalComputationDefaultValue(), await this.setupDictDefaultValue());
|
|
8905
8919
|
} catch (e) {
|
|
8906
|
-
throw e instanceof
|
|
8920
|
+
throw e instanceof It ? e : new It("Unexpected error during scheduler setup", {
|
|
8907
8921
|
schedulingPhase: "top-level-setup",
|
|
8908
8922
|
causedBy: e instanceof Error ? e : new Error(String(e))
|
|
8909
8923
|
});
|
|
8910
8924
|
}
|
|
8911
8925
|
}
|
|
8912
8926
|
}
|
|
8913
|
-
class
|
|
8927
|
+
class ve {
|
|
8914
8928
|
constructor(t, e, i) {
|
|
8915
8929
|
this.interaction = t, this.controller = e, this.activitySeqCall = i, this.system = e.system;
|
|
8916
8930
|
}
|
|
@@ -8938,13 +8952,13 @@ class ke {
|
|
|
8938
8952
|
async checkUser(t, e, i) {
|
|
8939
8953
|
let r;
|
|
8940
8954
|
if (!this.interaction.userAttributives) return !0;
|
|
8941
|
-
const s =
|
|
8955
|
+
const s = Nt.is(this.interaction.userAttributives) ? R.fromValue(
|
|
8942
8956
|
this.interaction.userAttributives.content
|
|
8943
8957
|
) : R.atom(
|
|
8944
8958
|
this.interaction.userAttributives
|
|
8945
8959
|
), a = (o) => o.isRef ? i(o, t.user, e) : this.checkAttributive(o, t, t.user);
|
|
8946
8960
|
if (r = await this.checkAttributives(s, a, []), r === !0) return r;
|
|
8947
|
-
throw
|
|
8961
|
+
throw O.userCheckFailed(r);
|
|
8948
8962
|
}
|
|
8949
8963
|
// 用来check attributive 形容的后面的 target 到底是不是那个概念的实例。
|
|
8950
8964
|
async checkConcept(t, e, i, r = []) {
|
|
@@ -8969,10 +8983,10 @@ class ke {
|
|
|
8969
8983
|
return n === !0 ? !0 : (s.push(n), !1);
|
|
8970
8984
|
}) ? !0 : { name: e.name, type: "conceptAlias", stack: r, error: s };
|
|
8971
8985
|
} else {
|
|
8972
|
-
if (
|
|
8986
|
+
if (U.is(e))
|
|
8973
8987
|
return await this.checkAttributive(e, void 0, t) ? !0 : { name: e.name, type: "conceptCheck", stack: r, error: "role check error" };
|
|
8974
8988
|
const s = e.constructor?.check;
|
|
8975
|
-
return s ? s(t) ? !0 : { name: e.name, type: "conceptCheck", stack: r, error: "constructor check error" } : e.constructor && typeof e.constructor.check == "function" ? e.constructor.check(t) ? !0 : { name: e.name || "", type: "conceptCheck", stack: r, error: "constructor check error" } :
|
|
8989
|
+
return s ? s(t) ? !0 : { name: e.name, type: "conceptCheck", stack: r, error: "constructor check error" } : e.constructor && typeof e.constructor.check == "function" ? e.constructor.check(t) ? !0 : { name: e.name || "", type: "conceptCheck", stack: r, error: "constructor check error" } : I.is(e) ? t && typeof t == "object" && "id" in t || t && typeof t == "object" ? !0 : { name: e.name || "", type: "conceptCheck", stack: r, error: "invalid entity data" } : t && typeof t == "object" ? !0 : typeof e == "function" ? t instanceof e ? !0 : { name: e.name, type: "conceptCheck", stack: r, error: "instanceof check error" } : (console.warn(`unknown concept ${e}, cannot check ${t}. pass.`), !0);
|
|
8976
8990
|
}
|
|
8977
8991
|
}
|
|
8978
8992
|
isDerivedConcept(t) {
|
|
@@ -8992,25 +9006,25 @@ class ke {
|
|
|
8992
9006
|
throw new Error(`${r} in payload is not defined in interaction ${this.interaction.name}`);
|
|
8993
9007
|
for (let r of e) {
|
|
8994
9008
|
if (r.required && !(r.name in t.payload))
|
|
8995
|
-
throw
|
|
9009
|
+
throw O.payloadValidationFailed(r.name, "missing", t.payload);
|
|
8996
9010
|
const s = t.payload[r.name];
|
|
8997
9011
|
if (s === void 0) return;
|
|
8998
9012
|
if (r.isCollection && !Array.isArray(s))
|
|
8999
|
-
throw
|
|
9013
|
+
throw O.payloadValidationFailed(r.name, "data is not array", s);
|
|
9000
9014
|
if (r.isCollection) {
|
|
9001
9015
|
if (r.isRef && !s.every((a) => !!a.id))
|
|
9002
|
-
throw
|
|
9016
|
+
throw O.payloadValidationFailed(r.name, "data not every is ref", s);
|
|
9003
9017
|
} else if (r.isRef && !s.id)
|
|
9004
|
-
throw
|
|
9018
|
+
throw O.payloadValidationFailed(r.name, "data is not a ref", s);
|
|
9005
9019
|
if (r.base)
|
|
9006
9020
|
if (r.isCollection) {
|
|
9007
9021
|
const a = await di(s, (o) => this.checkConcept(o, r.base));
|
|
9008
9022
|
if (a !== !0)
|
|
9009
|
-
throw
|
|
9023
|
+
throw O.conceptCheckFailed(r.name, a);
|
|
9010
9024
|
} else {
|
|
9011
9025
|
const a = await this.checkConcept(s, r.base);
|
|
9012
9026
|
if (a !== !0)
|
|
9013
|
-
throw
|
|
9027
|
+
throw O.conceptCheckFailed(r.name, a);
|
|
9014
9028
|
}
|
|
9015
9029
|
if (r.isRef) {
|
|
9016
9030
|
const a = r.isCollection ? m.atom({
|
|
@@ -9026,7 +9040,7 @@ class ke {
|
|
|
9026
9040
|
}
|
|
9027
9041
|
async checkCondition(t) {
|
|
9028
9042
|
if (this.interaction.conditions) {
|
|
9029
|
-
const e =
|
|
9043
|
+
const e = Tt.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), i = async (s) => {
|
|
9030
9044
|
if (!s) return !0;
|
|
9031
9045
|
if (s.content) {
|
|
9032
9046
|
const a = s.content;
|
|
@@ -9042,7 +9056,7 @@ class ke {
|
|
|
9042
9056
|
return !0;
|
|
9043
9057
|
}, r = await e.evaluateAsync(i);
|
|
9044
9058
|
if (r !== !0)
|
|
9045
|
-
throw
|
|
9059
|
+
throw O.conditionCheckFailed(r);
|
|
9046
9060
|
}
|
|
9047
9061
|
}
|
|
9048
9062
|
// CAUTION sideEffect 是并行的。如果要串行,用户应该自己写在一个里面
|
|
@@ -9067,7 +9081,7 @@ class ke {
|
|
|
9067
9081
|
}
|
|
9068
9082
|
async retrieveData(t) {
|
|
9069
9083
|
let e;
|
|
9070
|
-
if (
|
|
9084
|
+
if (I.is(this.interaction.data) || P.is(this.interaction.data)) {
|
|
9071
9085
|
const i = this.interaction.data.name, r = Object.fromEntries(
|
|
9072
9086
|
this.interaction.query?.items?.map((p) => [p.name, p.value]) || []
|
|
9073
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);
|
|
@@ -9103,7 +9117,7 @@ class ke {
|
|
|
9103
9117
|
return s;
|
|
9104
9118
|
}
|
|
9105
9119
|
}
|
|
9106
|
-
class
|
|
9120
|
+
class j {
|
|
9107
9121
|
constructor(t, e) {
|
|
9108
9122
|
this.graph = t, this.parent = e;
|
|
9109
9123
|
}
|
|
@@ -9113,7 +9127,7 @@ class H {
|
|
|
9113
9127
|
};
|
|
9114
9128
|
}
|
|
9115
9129
|
static create(t, e, i) {
|
|
9116
|
-
const r = new
|
|
9130
|
+
const r = new j(e, i);
|
|
9117
9131
|
return t.current && (r.current = $.create(t.current, e, r)), r;
|
|
9118
9132
|
}
|
|
9119
9133
|
isInteractionAvailable(t) {
|
|
@@ -9147,13 +9161,13 @@ class $ {
|
|
|
9147
9161
|
}
|
|
9148
9162
|
static createInitialState(t) {
|
|
9149
9163
|
const e = { uuid: t.uuid };
|
|
9150
|
-
return Z.is(t.content) && (e.children = t.childSeqs.map((i) =>
|
|
9164
|
+
return Z.is(t.content) && (e.children = t.childSeqs.map((i) => j.createInitialState(i.head))), e;
|
|
9151
9165
|
}
|
|
9152
9166
|
static create(t, e, i) {
|
|
9153
9167
|
const r = e.getNodeByUUID(t.uuid);
|
|
9154
9168
|
if (Z.is(r.content)) {
|
|
9155
9169
|
const a = $.GroupStateNodeType.get(r.content.type), o = new a(r, e, i);
|
|
9156
|
-
return o.isGroup = !0, o.children = t?.children?.map((n) =>
|
|
9170
|
+
return o.isGroup = !0, o.children = t?.children?.map((n) => j.create(n, e, o)), o;
|
|
9157
9171
|
} else
|
|
9158
9172
|
return new $(r, e, i);
|
|
9159
9173
|
}
|
|
@@ -9173,12 +9187,12 @@ class $ {
|
|
|
9173
9187
|
this.parent.transferToNext(this.node.uuid);
|
|
9174
9188
|
}
|
|
9175
9189
|
}
|
|
9176
|
-
class
|
|
9190
|
+
class oe {
|
|
9177
9191
|
constructor(t, e) {
|
|
9178
|
-
this.graph = e, this.root =
|
|
9192
|
+
this.graph = e, this.root = j.create(t, this.graph);
|
|
9179
9193
|
}
|
|
9180
9194
|
static createInitialState(t) {
|
|
9181
|
-
return
|
|
9195
|
+
return j.createInitialState(t);
|
|
9182
9196
|
}
|
|
9183
9197
|
isInteractionAvailable(t) {
|
|
9184
9198
|
return this.root.isInteractionAvailable(t);
|
|
@@ -9208,7 +9222,7 @@ class Y {
|
|
|
9208
9222
|
for (let o of t.interactions) {
|
|
9209
9223
|
const n = { content: o, next: null, uuid: o.uuid, parentGroup: e, parentSeq: r };
|
|
9210
9224
|
this.uuidToNode.set(o.uuid, n), this.rawToNode.set(o, n);
|
|
9211
|
-
const c = new
|
|
9225
|
+
const c = new ve(o, this.controller, this);
|
|
9212
9226
|
this.uuidToInteractionCall.set(o.uuid, c), o.name && this.interactionCallByName.set(o.name, c);
|
|
9213
9227
|
}
|
|
9214
9228
|
for (let o of t.gateways) {
|
|
@@ -9237,7 +9251,7 @@ class Y {
|
|
|
9237
9251
|
}), r;
|
|
9238
9252
|
}
|
|
9239
9253
|
async create() {
|
|
9240
|
-
const t =
|
|
9254
|
+
const t = oe.createInitialState(this.graph.head);
|
|
9241
9255
|
return {
|
|
9242
9256
|
activityId: (await this.controller.activityManager.createActivity({
|
|
9243
9257
|
name: this.activity.name,
|
|
@@ -9296,7 +9310,7 @@ class Y {
|
|
|
9296
9310
|
s = (await this.create()).activityId;
|
|
9297
9311
|
}
|
|
9298
9312
|
} else if (!t) return { error: "activityId must be provided for non-head interaction of an activity" };
|
|
9299
|
-
const a = new
|
|
9313
|
+
const a = new oe(await this.getState(s), this);
|
|
9300
9314
|
if (!a.isInteractionAvailable(e)) return { error: `interaction ${e} not available` };
|
|
9301
9315
|
const o = await r.call(i, s, this.checkUserRef);
|
|
9302
9316
|
if (o.error)
|
|
@@ -9317,14 +9331,14 @@ class Y {
|
|
|
9317
9331
|
async saveUserRefs(t, e, i) {
|
|
9318
9332
|
const r = (await this.getActivity(t))?.refs || {};
|
|
9319
9333
|
e.interaction.userRef?.name && (r[e.interaction.userRef?.name] = i.user.id), e.interaction.payload?.items.forEach((s) => {
|
|
9320
|
-
if (
|
|
9334
|
+
if (U.is(s.itemRef) && s.itemRef?.name && i.payload[s.name]) {
|
|
9321
9335
|
const a = i.payload[s.name];
|
|
9322
9336
|
s.isCollection ? (r[s.itemRef.name] || (r[s.itemRef.name] = []), r[s.itemRef.name].push(a.id)) : r[s.itemRef.name] = a.id;
|
|
9323
9337
|
}
|
|
9324
9338
|
}), await this.setActivity(t, { refs: r });
|
|
9325
9339
|
}
|
|
9326
9340
|
}
|
|
9327
|
-
class
|
|
9341
|
+
class Hi extends $ {
|
|
9328
9342
|
onChange(t, e) {
|
|
9329
9343
|
if (this.graph.isStartNode(t)) {
|
|
9330
9344
|
if (e)
|
|
@@ -9335,25 +9349,25 @@ class Ji extends $ {
|
|
|
9335
9349
|
}
|
|
9336
9350
|
}
|
|
9337
9351
|
}
|
|
9338
|
-
$.GroupStateNodeType.set("any",
|
|
9339
|
-
class
|
|
9352
|
+
$.GroupStateNodeType.set("any", Hi);
|
|
9353
|
+
class ji extends $ {
|
|
9340
9354
|
onChange(t, e) {
|
|
9341
9355
|
this.isGroupCompleted() && this.complete();
|
|
9342
9356
|
}
|
|
9343
9357
|
}
|
|
9344
|
-
$.GroupStateNodeType.set("every",
|
|
9345
|
-
class
|
|
9358
|
+
$.GroupStateNodeType.set("every", ji);
|
|
9359
|
+
class Ui extends $ {
|
|
9346
9360
|
onChange(t, e) {
|
|
9347
9361
|
this.graph.isEndNode(t) && this.complete();
|
|
9348
9362
|
}
|
|
9349
9363
|
}
|
|
9350
|
-
$.GroupStateNodeType.set("race",
|
|
9351
|
-
class
|
|
9364
|
+
$.GroupStateNodeType.set("race", Ui);
|
|
9365
|
+
class Ki extends $ {
|
|
9352
9366
|
// 可以根据 group 上的具体配置逻辑,来动态决定。
|
|
9353
9367
|
}
|
|
9354
|
-
$.GroupStateNodeType.set("program",
|
|
9355
|
-
const
|
|
9356
|
-
name:
|
|
9368
|
+
$.GroupStateNodeType.set("program", Ki);
|
|
9369
|
+
const ne = new le(), $t = "_Interaction_", yt = "_Activity_", ke = I.create({
|
|
9370
|
+
name: $t,
|
|
9357
9371
|
properties: [
|
|
9358
9372
|
v.create({
|
|
9359
9373
|
name: "interactionId",
|
|
@@ -9381,7 +9395,7 @@ const ce = new ue(), Dt = "_Interaction_", yt = "_Activity_", Te = C.create({
|
|
|
9381
9395
|
collection: !1
|
|
9382
9396
|
})
|
|
9383
9397
|
]
|
|
9384
|
-
}),
|
|
9398
|
+
}), Te = I.create({
|
|
9385
9399
|
name: yt,
|
|
9386
9400
|
properties: [
|
|
9387
9401
|
v.create({
|
|
@@ -9405,26 +9419,26 @@ const ce = new ue(), Dt = "_Interaction_", yt = "_Activity_", Te = C.create({
|
|
|
9405
9419
|
collection: !1
|
|
9406
9420
|
})
|
|
9407
9421
|
]
|
|
9408
|
-
}),
|
|
9422
|
+
}), Gi = P.create({
|
|
9409
9423
|
name: "activityInteraction",
|
|
9410
|
-
source:
|
|
9424
|
+
source: Te,
|
|
9411
9425
|
sourceProperty: "interaction",
|
|
9412
|
-
target:
|
|
9426
|
+
target: ke,
|
|
9413
9427
|
targetProperty: "activity",
|
|
9414
9428
|
type: "1:n"
|
|
9415
9429
|
});
|
|
9416
|
-
class
|
|
9430
|
+
class Xi {
|
|
9417
9431
|
constructor(t, e, i) {
|
|
9418
|
-
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(
|
|
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) => {
|
|
9419
9433
|
const s = new Y(r, t);
|
|
9420
9434
|
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));
|
|
9421
9435
|
}), i.forEach((r) => {
|
|
9422
|
-
const s = new
|
|
9436
|
+
const s = new ve(r, t);
|
|
9423
9437
|
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));
|
|
9424
9438
|
});
|
|
9425
9439
|
}
|
|
9426
9440
|
async callInteraction(t, e) {
|
|
9427
|
-
const i =
|
|
9441
|
+
const i = ne.getStore(), r = this.controller.system.logger.child(i?.logContext || {});
|
|
9428
9442
|
try {
|
|
9429
9443
|
const s = this.interactionCallsByName.get(t);
|
|
9430
9444
|
if (!s)
|
|
@@ -9467,11 +9481,11 @@ class Gi {
|
|
|
9467
9481
|
}
|
|
9468
9482
|
}
|
|
9469
9483
|
async callActivityInteraction(t, e, i, r) {
|
|
9470
|
-
const s =
|
|
9484
|
+
const s = ne.getStore(), a = this.controller.system.logger.child(s?.logContext || {});
|
|
9471
9485
|
try {
|
|
9472
9486
|
const o = this.activityCallsByName.get(t);
|
|
9473
9487
|
if (!o)
|
|
9474
|
-
throw new
|
|
9488
|
+
throw new se(`Cannot find activity for ${t}`, {
|
|
9475
9489
|
activityName: t,
|
|
9476
9490
|
context: {
|
|
9477
9491
|
interactionName: e,
|
|
@@ -9494,7 +9508,7 @@ class Gi {
|
|
|
9494
9508
|
const c = await o.callInteraction(i, n.interaction.uuid, r);
|
|
9495
9509
|
return c.error ? (a.error({ label: "activity", message: o.activity.name }), await this.controller.system.storage.rollbackTransaction(o.activity.name)) : await this.controller.system.storage.commitTransaction(o.activity.name), c;
|
|
9496
9510
|
} catch (o) {
|
|
9497
|
-
throw new
|
|
9511
|
+
throw new se("Unexpected error during activity interaction call", {
|
|
9498
9512
|
activityName: t,
|
|
9499
9513
|
context: {
|
|
9500
9514
|
interactionName: e,
|
|
@@ -9526,10 +9540,10 @@ class Gi {
|
|
|
9526
9540
|
}));
|
|
9527
9541
|
}
|
|
9528
9542
|
async saveEvent(t) {
|
|
9529
|
-
return this.controller.system.storage.create(
|
|
9543
|
+
return this.controller.system.storage.create($t, t);
|
|
9530
9544
|
}
|
|
9531
9545
|
async getEvent(t) {
|
|
9532
|
-
return (await this.controller.system.storage.find(
|
|
9546
|
+
return (await this.controller.system.storage.find($t, t, void 0, ["*"])).map((e) => ({
|
|
9533
9547
|
...e
|
|
9534
9548
|
}));
|
|
9535
9549
|
}
|
|
@@ -9546,24 +9560,24 @@ class Gi {
|
|
|
9546
9560
|
return this.interactionCallsByName.get(t);
|
|
9547
9561
|
}
|
|
9548
9562
|
}
|
|
9549
|
-
const
|
|
9550
|
-
function
|
|
9551
|
-
return
|
|
9563
|
+
const Xt = new le();
|
|
9564
|
+
function zi() {
|
|
9565
|
+
return Xt.getStore()?.effects;
|
|
9552
9566
|
}
|
|
9553
|
-
function
|
|
9554
|
-
const t =
|
|
9567
|
+
function ce(u) {
|
|
9568
|
+
const t = Xt.getStore();
|
|
9555
9569
|
t?.effects && t.effects.push(...u);
|
|
9556
9570
|
}
|
|
9557
|
-
const
|
|
9558
|
-
class
|
|
9571
|
+
const Ar = "User";
|
|
9572
|
+
class Ae {
|
|
9559
9573
|
constructor(t) {
|
|
9560
9574
|
this.name = t.name, this.record = t.record, this.content = t.content;
|
|
9561
9575
|
}
|
|
9562
9576
|
static create(t) {
|
|
9563
|
-
return new
|
|
9577
|
+
return new Ae(t);
|
|
9564
9578
|
}
|
|
9565
9579
|
}
|
|
9566
|
-
const Ot = "_isDeleted_",
|
|
9580
|
+
const Ot = "_isDeleted_", Sr = {
|
|
9567
9581
|
create() {
|
|
9568
9582
|
return v.create({
|
|
9569
9583
|
name: Ot,
|
|
@@ -9571,7 +9585,7 @@ const Ot = "_isDeleted_", Ar = {
|
|
|
9571
9585
|
});
|
|
9572
9586
|
}
|
|
9573
9587
|
};
|
|
9574
|
-
class
|
|
9588
|
+
class Er {
|
|
9575
9589
|
constructor(t) {
|
|
9576
9590
|
this.recordNameToSideEffects = /* @__PURE__ */ new Map(), this.globals = {
|
|
9577
9591
|
BoolExp: R,
|
|
@@ -9590,21 +9604,21 @@ class Sr {
|
|
|
9590
9604
|
forceThrowInteractionError: d = !1
|
|
9591
9605
|
// 会 catch 住 error,并在 result 中返回。
|
|
9592
9606
|
} = t;
|
|
9593
|
-
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
|
|
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);
|
|
9594
9608
|
const h = [
|
|
9595
9609
|
...Si,
|
|
9596
|
-
...
|
|
9610
|
+
...Ii,
|
|
9597
9611
|
...ki,
|
|
9598
9612
|
...wi,
|
|
9599
9613
|
...gi,
|
|
9600
|
-
...
|
|
9614
|
+
...Oi,
|
|
9601
9615
|
...Vi,
|
|
9602
9616
|
...Mi,
|
|
9603
9617
|
...fi,
|
|
9604
|
-
...
|
|
9618
|
+
..._i,
|
|
9605
9619
|
...c
|
|
9606
9620
|
];
|
|
9607
|
-
this.scheduler = new
|
|
9621
|
+
this.scheduler = new Ji(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
|
|
9608
9622
|
let y = this.recordNameToSideEffects.get(p.record.name);
|
|
9609
9623
|
y || this.recordNameToSideEffects.set(p.record.name, y = /* @__PURE__ */ new Set()), y.add(p);
|
|
9610
9624
|
});
|
|
@@ -9672,7 +9686,7 @@ class Sr {
|
|
|
9672
9686
|
}
|
|
9673
9687
|
async callInteraction(t, e, i, r) {
|
|
9674
9688
|
try {
|
|
9675
|
-
const s = { effects: [] }, a = await
|
|
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));
|
|
9676
9690
|
if (a.effects = s.effects, a.error && this.forceThrowInteractionError)
|
|
9677
9691
|
throw a.error;
|
|
9678
9692
|
return await this.runRecordChangeSideEffects(a, this.system.logger), a;
|
|
@@ -9698,20 +9712,27 @@ class Sr {
|
|
|
9698
9712
|
if (s)
|
|
9699
9713
|
for (let a of s)
|
|
9700
9714
|
try {
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
};
|
|
9705
|
-
else {
|
|
9706
|
-
const o = a;
|
|
9707
|
-
o.name && typeof o.content == "function" && (t.sideEffects[o.name] = {
|
|
9708
|
-
result: await o.content(r)
|
|
9709
|
-
});
|
|
9710
|
-
}
|
|
9715
|
+
t.sideEffects[a.name] = {
|
|
9716
|
+
result: await a.content.call(this, r)
|
|
9717
|
+
};
|
|
9711
9718
|
} catch (o) {
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9719
|
+
const n = new Wi(
|
|
9720
|
+
`Side effect '${a.name}' failed for ${r.type} on ${r.recordName}`,
|
|
9721
|
+
{
|
|
9722
|
+
sideEffectName: a.name,
|
|
9723
|
+
recordName: r.recordName,
|
|
9724
|
+
mutationType: r.type,
|
|
9725
|
+
recordId: r.record?.id,
|
|
9726
|
+
context: {
|
|
9727
|
+
record: r.record,
|
|
9728
|
+
oldRecord: r.oldRecord,
|
|
9729
|
+
keys: r.keys
|
|
9730
|
+
},
|
|
9731
|
+
causedBy: o instanceof Error ? o : new Error(String(o))
|
|
9732
|
+
}
|
|
9733
|
+
);
|
|
9734
|
+
e.error({ label: "recordMutationSideEffect", message: a.name, error: n }), t.sideEffects[a.name] = {
|
|
9735
|
+
error: n
|
|
9715
9736
|
};
|
|
9716
9737
|
}
|
|
9717
9738
|
}
|
|
@@ -9721,13 +9742,13 @@ class Sr {
|
|
|
9721
9742
|
this.callbacks.has(t) || this.callbacks.set(t, /* @__PURE__ */ new Set()), this.callbacks.get(t).add(e);
|
|
9722
9743
|
}
|
|
9723
9744
|
}
|
|
9724
|
-
function
|
|
9745
|
+
function Yi(u) {
|
|
9725
9746
|
return encodeURI(JSON.stringify(u));
|
|
9726
9747
|
}
|
|
9727
|
-
function
|
|
9748
|
+
function Zi(u) {
|
|
9728
9749
|
return u === void 0 ? void 0 : JSON.parse(decodeURI(u));
|
|
9729
9750
|
}
|
|
9730
|
-
class
|
|
9751
|
+
class tr {
|
|
9731
9752
|
constructor(t) {
|
|
9732
9753
|
this.db = t, this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
|
|
9733
9754
|
get: async (e) => {
|
|
@@ -9752,11 +9773,11 @@ class Zi {
|
|
|
9752
9773
|
// CAUTION kv 结构数据的实现也用 er。这是系统约定,因为也需要 Record 事件!
|
|
9753
9774
|
async get(t, e, i) {
|
|
9754
9775
|
const r = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] }), s = (await this.queryHandle.findOne(X, r, void 0, ["value"]))?.value;
|
|
9755
|
-
return s === void 0 ? i :
|
|
9776
|
+
return s === void 0 ? i : Zi(s);
|
|
9756
9777
|
}
|
|
9757
9778
|
async set(t, e, i, r) {
|
|
9758
9779
|
const s = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] });
|
|
9759
|
-
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:
|
|
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);
|
|
9760
9781
|
}
|
|
9761
9782
|
async setup(t, e, i = !1) {
|
|
9762
9783
|
await this.db.open(i);
|
|
@@ -9785,8 +9806,8 @@ class Zi {
|
|
|
9785
9806
|
async callWithEvents(t, e, i = []) {
|
|
9786
9807
|
const r = [], s = await t(...e, r), a = await this.dispatch(r);
|
|
9787
9808
|
i.push(...r, ...a);
|
|
9788
|
-
const o =
|
|
9789
|
-
return o && r.length > 0 &&
|
|
9809
|
+
const o = zi();
|
|
9810
|
+
return o && r.length > 0 && ce(r), o && a.length > 0 && ce(a), s;
|
|
9790
9811
|
}
|
|
9791
9812
|
findRelationByName(...t) {
|
|
9792
9813
|
return this.queryHandle.findRelationByName(...t);
|
|
@@ -9824,8 +9845,8 @@ class Zi {
|
|
|
9824
9845
|
return this.db.close();
|
|
9825
9846
|
}
|
|
9826
9847
|
}
|
|
9827
|
-
var
|
|
9828
|
-
class
|
|
9848
|
+
var er = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(er || {});
|
|
9849
|
+
class zt {
|
|
9829
9850
|
constructor(t = 0) {
|
|
9830
9851
|
this.level = t;
|
|
9831
9852
|
}
|
|
@@ -9836,11 +9857,11 @@ class Yt {
|
|
|
9836
9857
|
this.level >= 0 && console.error({ type: t, name: e, sql: i, params: r, error: s });
|
|
9837
9858
|
}
|
|
9838
9859
|
child() {
|
|
9839
|
-
return new
|
|
9860
|
+
return new zt(this.level);
|
|
9840
9861
|
}
|
|
9841
9862
|
}
|
|
9842
|
-
var
|
|
9843
|
-
class
|
|
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 {
|
|
9844
9865
|
constructor(t = 0) {
|
|
9845
9866
|
this.level = t;
|
|
9846
9867
|
}
|
|
@@ -9854,16 +9875,16 @@ class Zt {
|
|
|
9854
9875
|
this.level >= 2 && console.debug(`[DEBUG] ${t}: ${e}`, i);
|
|
9855
9876
|
}
|
|
9856
9877
|
child(t) {
|
|
9857
|
-
return new
|
|
9878
|
+
return new Yt(this.level);
|
|
9858
9879
|
}
|
|
9859
9880
|
}
|
|
9860
|
-
const
|
|
9881
|
+
const Ir = new zt(), rr = new Yt();
|
|
9861
9882
|
class Cr {
|
|
9862
|
-
constructor(t, e =
|
|
9863
|
-
this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new
|
|
9883
|
+
constructor(t, e = rr) {
|
|
9884
|
+
this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new tr(t);
|
|
9864
9885
|
}
|
|
9865
9886
|
setup(t, e, i, r = !1) {
|
|
9866
|
-
const s = new
|
|
9887
|
+
const s = new ye(t, e), { entities: a, relations: o } = s.getAll();
|
|
9867
9888
|
return i.forEach(({ dataContext: n, state: c }) => {
|
|
9868
9889
|
Object.entries(c).forEach(([l, d]) => {
|
|
9869
9890
|
if (d instanceof E) {
|
|
@@ -9901,170 +9922,170 @@ class Cr {
|
|
|
9901
9922
|
export {
|
|
9902
9923
|
yt as ACTIVITY_RECORD,
|
|
9903
9924
|
qe as ALL_ATTR_SYMBOL,
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9925
|
+
Ct as ASYNC_TASK_RECORD,
|
|
9926
|
+
vt as Action,
|
|
9927
|
+
Lt as Activity,
|
|
9907
9928
|
Y as ActivityCall,
|
|
9908
9929
|
Z as ActivityGroup,
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9930
|
+
Gi as ActivityInteractionRelation,
|
|
9931
|
+
Xi as ActivityManager,
|
|
9932
|
+
Te as ActivityStateEntity,
|
|
9912
9933
|
ut as Any,
|
|
9913
9934
|
ki as AnyHandles,
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9935
|
+
_ as AttributeInfo,
|
|
9936
|
+
C as AttributeQuery,
|
|
9937
|
+
U as Attributive,
|
|
9938
|
+
Nt as Attributives,
|
|
9918
9939
|
ct as Average,
|
|
9919
9940
|
Vi as AverageHandles,
|
|
9920
|
-
|
|
9941
|
+
dr as BaseKlass,
|
|
9921
9942
|
it as BoolAtomData,
|
|
9922
9943
|
R as BoolExp,
|
|
9923
9944
|
rt as BoolExpressionData,
|
|
9924
|
-
|
|
9925
|
-
|
|
9945
|
+
J as ComputationDataDepError,
|
|
9946
|
+
V as ComputationError,
|
|
9926
9947
|
S as ComputationResult,
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9948
|
+
Re as ComputationResultAsync,
|
|
9949
|
+
be as ComputationResultFullRecompute,
|
|
9950
|
+
we as ComputationResultResolved,
|
|
9930
9951
|
Rt as ComputationResultSkip,
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9952
|
+
ae as ComputationStateError,
|
|
9953
|
+
qt as Condition,
|
|
9954
|
+
O as ConditionError,
|
|
9955
|
+
Tt as Conditions,
|
|
9956
|
+
Er as Controller,
|
|
9936
9957
|
ot as Count,
|
|
9937
9958
|
Si as CountHandles,
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9959
|
+
Kt as Custom,
|
|
9960
|
+
_i as CustomHandles,
|
|
9961
|
+
zt as DBConsoleLogger,
|
|
9962
|
+
er as DBLogLevel,
|
|
9942
9963
|
oi as DBSetup,
|
|
9943
|
-
|
|
9964
|
+
Tr as DELETED_STATE,
|
|
9944
9965
|
q as DICTIONARY_RECORD,
|
|
9945
9966
|
Bt as DataAttributive,
|
|
9946
|
-
|
|
9947
|
-
|
|
9967
|
+
Ut as DataAttributives,
|
|
9968
|
+
Vt as Dictionary,
|
|
9948
9969
|
ci as DictionaryEntity,
|
|
9949
|
-
|
|
9970
|
+
I as Entity,
|
|
9950
9971
|
Li as EntityCustomHandle,
|
|
9951
9972
|
je as EntityQueryHandle,
|
|
9952
9973
|
Ue as EntityToTableMap,
|
|
9953
|
-
|
|
9954
|
-
|
|
9974
|
+
Gt as Equation,
|
|
9975
|
+
_t as Event,
|
|
9955
9976
|
lt as Every,
|
|
9956
9977
|
wi as EveryHandles,
|
|
9957
9978
|
M as Expression,
|
|
9958
9979
|
tt as Gateway,
|
|
9959
9980
|
Ve as GetAction,
|
|
9960
9981
|
Ni as GlobalAnyHandle,
|
|
9961
|
-
|
|
9962
|
-
|
|
9982
|
+
Fi as GlobalAverageHandle,
|
|
9983
|
+
B as GlobalBoundState,
|
|
9963
9984
|
Ti as GlobalCountHandle,
|
|
9964
9985
|
Qi as GlobalCustomHandle,
|
|
9965
9986
|
bi as GlobalEveryHandle,
|
|
9966
|
-
|
|
9987
|
+
Ci as GlobalRealTimeComputation,
|
|
9967
9988
|
hi as GlobalStateMachineHandle,
|
|
9968
9989
|
Pi as GlobalSumHandle,
|
|
9969
9990
|
mi as GlobalWeightedSummationHandle,
|
|
9970
9991
|
Ot as HARD_DELETION_PROPERTY_NAME,
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9992
|
+
Sr as HardDeletionProperty,
|
|
9993
|
+
ie as ID_ATTR,
|
|
9994
|
+
$t as INTERACTION_RECORD,
|
|
9974
9995
|
wt as Inequality,
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9996
|
+
Qt as Interaction,
|
|
9997
|
+
ve as InteractionCall,
|
|
9998
|
+
ke as InteractionEventEntity,
|
|
9978
9999
|
Ft as KlassByName,
|
|
9979
10000
|
f as LINK_SYMBOL,
|
|
9980
10001
|
bt as LinkInfo,
|
|
9981
10002
|
m as MatchExp,
|
|
9982
10003
|
Le as Modifier,
|
|
9983
10004
|
Cr as MonoSystem,
|
|
9984
|
-
|
|
9985
|
-
|
|
10005
|
+
kr as NON_DELETED_STATE,
|
|
10006
|
+
vr as NON_EXIST_STATE,
|
|
9986
10007
|
Q as NewRecordData,
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
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,
|
|
9992
10013
|
v as Property,
|
|
9993
10014
|
vi as PropertyAnyHandle,
|
|
9994
|
-
|
|
10015
|
+
Di as PropertyAverageHandle,
|
|
9995
10016
|
Ai as PropertyCountHandle,
|
|
9996
|
-
|
|
10017
|
+
Bi as PropertyCustomHandle,
|
|
9997
10018
|
Ri as PropertyEveryHandle,
|
|
9998
|
-
|
|
10019
|
+
xi as PropertyRealTimeComputation,
|
|
9999
10020
|
pi as PropertyStateMachineHandle,
|
|
10000
10021
|
$i as PropertySumHandle,
|
|
10001
|
-
|
|
10022
|
+
Dt as PropertyTypes,
|
|
10002
10023
|
yi as PropertyWeightedSummationHandle,
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10024
|
+
me as Query,
|
|
10025
|
+
fe as QueryItem,
|
|
10026
|
+
ge as ROOT_LABEL,
|
|
10027
|
+
re as ROW_ID_ATTR,
|
|
10007
10028
|
dt as RealTime,
|
|
10008
10029
|
Mi as RealTimeHandles,
|
|
10009
10030
|
E as RecordBoundState,
|
|
10010
10031
|
et as RecordInfo,
|
|
10011
|
-
|
|
10012
|
-
|
|
10032
|
+
Ae as RecordMutationSideEffect,
|
|
10033
|
+
x as RecordQuery,
|
|
10013
10034
|
He as RecordQueryAgent,
|
|
10014
10035
|
L as RecordQueryTree,
|
|
10015
10036
|
Ei as RecordsTransformHandle,
|
|
10016
10037
|
gt as RecursiveContext,
|
|
10017
|
-
|
|
10038
|
+
ye as RefContainer,
|
|
10018
10039
|
P as Relation,
|
|
10019
10040
|
qi as RelationCustomHandle,
|
|
10020
10041
|
X as SYSTEM_RECORD,
|
|
10021
|
-
|
|
10022
|
-
|
|
10042
|
+
Ji as Scheduler,
|
|
10043
|
+
jt as SideEffect,
|
|
10023
10044
|
st as StateMachine,
|
|
10024
10045
|
fi as StateMachineHandles,
|
|
10025
|
-
|
|
10026
|
-
|
|
10046
|
+
K as StateNode,
|
|
10047
|
+
Wt as StateTransfer,
|
|
10027
10048
|
nt as Summation,
|
|
10028
|
-
|
|
10029
|
-
|
|
10049
|
+
Oi as SummationHandles,
|
|
10050
|
+
Yt as SystemConsoleLogger,
|
|
10030
10051
|
ni as SystemEntity,
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10052
|
+
ir as SystemLogLevel,
|
|
10053
|
+
he as Transfer,
|
|
10054
|
+
kt as Transform,
|
|
10055
|
+
Ii as TransformHandles,
|
|
10056
|
+
Ar as USER_ENTITY,
|
|
10036
10057
|
at as WeightedSummation,
|
|
10037
10058
|
gi as WeightedSummationHandles,
|
|
10038
|
-
|
|
10059
|
+
ce as addToCurrentEffects,
|
|
10039
10060
|
T as assert,
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10061
|
+
Xt as asyncEffectsContext,
|
|
10062
|
+
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,
|
|
10049
10070
|
ft as deepClone,
|
|
10050
|
-
|
|
10071
|
+
Nr as everyAsync,
|
|
10051
10072
|
di as everyWithErrorAsync,
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10073
|
+
Rr as filterMap,
|
|
10074
|
+
pr as findRootActivity,
|
|
10075
|
+
pe as forEachInteraction,
|
|
10055
10076
|
k as generateUUID,
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10077
|
+
zi as getCurrentEffects,
|
|
10078
|
+
hr as getInteractions,
|
|
10079
|
+
Ie as indexBy,
|
|
10080
|
+
ue as isObject,
|
|
10081
|
+
de as isPlainObject,
|
|
10082
|
+
wr as mapObject,
|
|
10083
|
+
fr as parse,
|
|
10084
|
+
Ce as registerKlass,
|
|
10085
|
+
nr as removeAllInstance,
|
|
10065
10086
|
ui as someAsync,
|
|
10066
|
-
|
|
10087
|
+
cr as stringifyAllInstances,
|
|
10067
10088
|
w as stringifyAttribute,
|
|
10068
|
-
|
|
10089
|
+
rr as systemConsoleLogger
|
|
10069
10090
|
};
|
|
10070
10091
|
//# sourceMappingURL=index.js.map
|