interaqt 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +329 -0
- package/agent/skill/interaqt-patterns.md +536 -0
- package/agent/skill/interaqt-recipes.md +501 -0
- package/agent/skill/interaqt-reference.md +409 -0
- package/dist/builtins/interaction/Interaction.d.ts +16 -10
- package/dist/builtins/interaction/Interaction.d.ts.map +1 -1
- package/dist/builtins/interaction/activity/ActivityManager.d.ts.map +1 -1
- package/dist/builtins/interaction/errors/ActivityErrors.d.ts +2 -2
- package/dist/builtins/interaction/errors/ActivityErrors.d.ts.map +1 -1
- package/dist/builtins/interaction/errors/InteractionErrors.d.ts +1 -1
- package/dist/builtins/interaction/errors/InteractionErrors.d.ts.map +1 -1
- package/dist/core/BoolExp.d.ts +2 -1
- package/dist/core/BoolExp.d.ts.map +1 -1
- package/dist/core/Computation.d.ts +3 -8
- package/dist/core/Computation.d.ts.map +1 -1
- package/dist/core/Custom.d.ts +2 -2
- package/dist/core/Custom.d.ts.map +1 -1
- package/dist/core/EventSource.d.ts +18 -16
- package/dist/core/EventSource.d.ts.map +1 -1
- package/dist/core/Property.d.ts +0 -3
- package/dist/core/Property.d.ts.map +1 -1
- package/dist/core/RealDictionary.d.ts +0 -3
- package/dist/core/RealDictionary.d.ts.map +1 -1
- package/dist/core/Relation.d.ts.map +1 -1
- package/dist/core/StateNode.d.ts +3 -3
- package/dist/core/StateNode.d.ts.map +1 -1
- package/dist/core/StateTransfer.d.ts +2 -6
- package/dist/core/StateTransfer.d.ts.map +1 -1
- package/dist/core/Transform.d.ts +2 -2
- package/dist/core/Transform.d.ts.map +1 -1
- package/dist/core/interfaces.d.ts +0 -9
- package/dist/core/interfaces.d.ts.map +1 -1
- package/dist/core/types.d.ts +0 -29
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utils.d.ts +22 -6
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/drivers/Mysql.d.ts +5 -5
- package/dist/drivers/Mysql.d.ts.map +1 -1
- package/dist/drivers/PGLite.d.ts +5 -5
- package/dist/drivers/PGLite.d.ts.map +1 -1
- package/dist/drivers/PostgreSQL.d.ts +5 -5
- package/dist/drivers/PostgreSQL.d.ts.map +1 -1
- package/dist/drivers/SQLite.d.ts +5 -5
- package/dist/drivers/SQLite.d.ts.map +1 -1
- package/dist/index.js +194 -228
- package/dist/index.js.map +1 -1
- package/dist/runtime/Controller.d.ts +14 -14
- package/dist/runtime/Controller.d.ts.map +1 -1
- package/dist/runtime/MonoSystem.d.ts +4 -4
- package/dist/runtime/MonoSystem.d.ts.map +1 -1
- package/dist/runtime/Scheduler.d.ts +3 -3
- package/dist/runtime/Scheduler.d.ts.map +1 -1
- package/dist/runtime/System.d.ts +50 -51
- package/dist/runtime/System.d.ts.map +1 -1
- package/dist/runtime/computations/Any.d.ts +4 -4
- package/dist/runtime/computations/Any.d.ts.map +1 -1
- package/dist/runtime/computations/Average.d.ts +2 -2
- package/dist/runtime/computations/Average.d.ts.map +1 -1
- package/dist/runtime/computations/Computation.d.ts +41 -47
- package/dist/runtime/computations/Computation.d.ts.map +1 -1
- package/dist/runtime/computations/Count.d.ts +4 -4
- package/dist/runtime/computations/Count.d.ts.map +1 -1
- package/dist/runtime/computations/Every.d.ts +4 -4
- package/dist/runtime/computations/Every.d.ts.map +1 -1
- package/dist/runtime/computations/RealTime.d.ts +9 -17
- package/dist/runtime/computations/RealTime.d.ts.map +1 -1
- package/dist/runtime/computations/StateMachine.d.ts +2 -2
- package/dist/runtime/computations/Summation.d.ts +2 -2
- package/dist/runtime/computations/Summation.d.ts.map +1 -1
- package/dist/runtime/computations/TransitionFinder.d.ts +9 -4
- package/dist/runtime/computations/TransitionFinder.d.ts.map +1 -1
- package/dist/runtime/computations/WeightedSummation.d.ts +2 -2
- package/dist/runtime/computations/WeightedSummation.d.ts.map +1 -1
- package/dist/runtime/errors/ComputationErrors.d.ts +3 -3
- package/dist/runtime/errors/ComputationErrors.d.ts.map +1 -1
- package/dist/runtime/errors/ConditionErrors.d.ts +6 -6
- package/dist/runtime/errors/ConditionErrors.d.ts.map +1 -1
- package/dist/runtime/errors/FrameworkError.d.ts +4 -4
- package/dist/runtime/errors/FrameworkError.d.ts.map +1 -1
- package/dist/runtime/errors/SideEffectError.d.ts +1 -1
- package/dist/runtime/errors/SideEffectError.d.ts.map +1 -1
- package/dist/runtime/errors/SystemErrors.d.ts +1 -1
- package/dist/runtime/errors/SystemErrors.d.ts.map +1 -1
- package/dist/runtime/errors/index.d.ts +5 -5
- package/dist/runtime/errors/index.d.ts.map +1 -1
- package/dist/runtime/types/computation.d.ts +11 -0
- package/dist/runtime/types/computation.d.ts.map +1 -0
- package/dist/runtime/util.d.ts +6 -6
- package/dist/runtime/util.d.ts.map +1 -1
- package/dist/storage/erstorage/MatchExp.d.ts +4 -4
- package/dist/storage/erstorage/MatchExp.d.ts.map +1 -1
- package/dist/storage/erstorage/QueryExecutor.d.ts +1 -1
- package/dist/storage/erstorage/QueryExecutor.d.ts.map +1 -1
- package/dist/storage/erstorage/RecordQuery.d.ts +5 -5
- package/dist/storage/erstorage/RecordQuery.d.ts.map +1 -1
- package/dist/storage/erstorage/SQLBuilder.d.ts +11 -11
- package/dist/storage/erstorage/SQLBuilder.d.ts.map +1 -1
- package/dist/storage/erstorage/Setup.d.ts +1 -1
- package/dist/storage/erstorage/util/RecursiveContext.d.ts +4 -10
- package/dist/storage/erstorage/util/RecursiveContext.d.ts.map +1 -1
- package/dist/storage/erstorage/util.d.ts +3 -3
- package/dist/storage/erstorage/util.d.ts.map +1 -1
- package/dist/storage/utils.d.ts +2 -2
- package/dist/storage/utils.d.ts.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -32,19 +32,17 @@ function pr(...u) {
|
|
|
32
32
|
for (const t of u)
|
|
33
33
|
t.instances.length = 0;
|
|
34
34
|
}
|
|
35
|
-
function fr() {
|
|
36
|
-
}
|
|
37
35
|
const Ft = /* @__PURE__ */ new Map();
|
|
38
36
|
function ue(u, t) {
|
|
39
37
|
t && t.isKlass && t.displayName && Ft.set(u, t);
|
|
40
38
|
}
|
|
41
|
-
function
|
|
39
|
+
function fr() {
|
|
42
40
|
const u = [];
|
|
43
41
|
return Array.from(Ft.entries()).forEach(([, t]) => {
|
|
44
42
|
t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
|
|
45
43
|
}), `[${u.join(",")}]`;
|
|
46
44
|
}
|
|
47
|
-
function
|
|
45
|
+
function mr(u) {
|
|
48
46
|
const t = JSON.parse(u);
|
|
49
47
|
return ke(t);
|
|
50
48
|
}
|
|
@@ -60,31 +58,6 @@ function ke(u) {
|
|
|
60
58
|
t.set(r, o);
|
|
61
59
|
}), t;
|
|
62
60
|
}
|
|
63
|
-
function gr(u) {
|
|
64
|
-
return console.warn("createClass is deprecated in refactored code"), null;
|
|
65
|
-
}
|
|
66
|
-
class br {
|
|
67
|
-
static {
|
|
68
|
-
this.isKlass = !0;
|
|
69
|
-
}
|
|
70
|
-
static {
|
|
71
|
-
this.instances = [];
|
|
72
|
-
}
|
|
73
|
-
// 通用的 create 方法实现
|
|
74
|
-
static createBase(t, e) {
|
|
75
|
-
if (e.find((r) => r.uuid === t.uuid))
|
|
76
|
-
throw new Error(`duplicate uuid in options ${t.uuid}, ${t._type}`);
|
|
77
|
-
return e.push(t), t;
|
|
78
|
-
}
|
|
79
|
-
// 通用的 is 方法实现
|
|
80
|
-
static isBase(t, e) {
|
|
81
|
-
return t !== null && typeof t == "object" && "_type" in t && t._type === e;
|
|
82
|
-
}
|
|
83
|
-
// 通用的 check 方法实现
|
|
84
|
-
static checkBase(t) {
|
|
85
|
-
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
61
|
let Se = 0;
|
|
89
62
|
function T(u) {
|
|
90
63
|
return u?.uuid || `id_${++Se}`;
|
|
@@ -201,9 +174,9 @@ class I {
|
|
|
201
174
|
return this.create(e.public, e.options);
|
|
202
175
|
}
|
|
203
176
|
}
|
|
204
|
-
var
|
|
177
|
+
var Vt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(Vt || {});
|
|
205
178
|
const Ie = /^[a-zA-Z0-9_]+$/;
|
|
206
|
-
class
|
|
179
|
+
class Qt {
|
|
207
180
|
constructor(t, e) {
|
|
208
181
|
this._type = "Dictionary", this._options = e, this.uuid = T(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;
|
|
209
182
|
}
|
|
@@ -223,15 +196,14 @@ class Vt {
|
|
|
223
196
|
required: !0,
|
|
224
197
|
collection: !1,
|
|
225
198
|
constraints: {
|
|
226
|
-
format: ({ name: t }) => Ie.test(t)
|
|
227
|
-
length: ({ name: t }) => t.length > 1 && t.length < 5
|
|
199
|
+
format: ({ name: t }) => Ie.test(t)
|
|
228
200
|
}
|
|
229
201
|
},
|
|
230
202
|
type: {
|
|
231
203
|
type: "string",
|
|
232
204
|
required: !0,
|
|
233
205
|
collection: !1,
|
|
234
|
-
options: Array.from(Object.values(
|
|
206
|
+
options: Array.from(Object.values(Vt))
|
|
235
207
|
},
|
|
236
208
|
collection: {
|
|
237
209
|
type: "boolean",
|
|
@@ -257,7 +229,7 @@ class Vt {
|
|
|
257
229
|
};
|
|
258
230
|
}
|
|
259
231
|
static create(t, e) {
|
|
260
|
-
const i = new
|
|
232
|
+
const i = new Qt(t, e);
|
|
261
233
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
262
234
|
throw new Error(`duplicate uuid in options ${i.uuid}, Dictionary`);
|
|
263
235
|
return this.instances.push(i), i;
|
|
@@ -316,14 +288,13 @@ class N {
|
|
|
316
288
|
type: "string",
|
|
317
289
|
required: !0,
|
|
318
290
|
constraints: {
|
|
319
|
-
format: ({ name: t }) => xe.test(t)
|
|
320
|
-
length: ({ name: t }) => t.length > 1 && t.length < 5
|
|
291
|
+
format: ({ name: t }) => xe.test(t)
|
|
321
292
|
}
|
|
322
293
|
},
|
|
323
294
|
type: {
|
|
324
295
|
type: "string",
|
|
325
296
|
required: !0,
|
|
326
|
-
options: () => Object.values(
|
|
297
|
+
options: () => Object.values(Vt)
|
|
327
298
|
},
|
|
328
299
|
collection: {
|
|
329
300
|
type: "boolean",
|
|
@@ -379,11 +350,11 @@ class N {
|
|
|
379
350
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
380
351
|
}
|
|
381
352
|
static parse(t) {
|
|
382
|
-
const e = JSON.parse(t), i = e.public;
|
|
383
|
-
return
|
|
353
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
354
|
+
return typeof r.defaultValue == "string" && r.defaultValue.startsWith("func::") && (i.defaultValue = new Function("return " + r.defaultValue.substring(6))()), typeof r.computed == "string" && r.computed.startsWith("func::") && (i.computed = new Function("return " + r.computed.substring(6))()), this.create(i, e.options);
|
|
384
355
|
}
|
|
385
356
|
}
|
|
386
|
-
class
|
|
357
|
+
class M {
|
|
387
358
|
constructor(t, e) {
|
|
388
359
|
if (this._type = "Relation", this._options = e, this.uuid = T(e), t.inputRelations) {
|
|
389
360
|
if (!t.inputRelations || t.inputRelations.length === 0)
|
|
@@ -415,7 +386,7 @@ class C {
|
|
|
415
386
|
// for Merged Relation
|
|
416
387
|
// Getter for name that returns computed name if _name is undefined
|
|
417
388
|
get name() {
|
|
418
|
-
return this._name !== void 0 ? this._name :
|
|
389
|
+
return this._name !== void 0 ? this._name : M.public.name.computed ? M.public.name.computed(this) : void 0;
|
|
419
390
|
}
|
|
420
391
|
// Setter for name
|
|
421
392
|
set name(t) {
|
|
@@ -515,7 +486,7 @@ class C {
|
|
|
515
486
|
};
|
|
516
487
|
}
|
|
517
488
|
static create(t, e) {
|
|
518
|
-
const i = new
|
|
489
|
+
const i = new M(t, e);
|
|
519
490
|
if (this.instances.find((s) => s.uuid === i.uuid))
|
|
520
491
|
throw new Error(`duplicate uuid in options ${i.uuid}, Relation`);
|
|
521
492
|
return this.instances.push(i), i;
|
|
@@ -529,7 +500,7 @@ class C {
|
|
|
529
500
|
properties: t.properties
|
|
530
501
|
};
|
|
531
502
|
t.inputRelations || (e.source = t.source, e.target = t.target);
|
|
532
|
-
const i = t
|
|
503
|
+
const i = (t instanceof M, t.name);
|
|
533
504
|
i !== void 0 && (e.name = i), t.computation !== void 0 && (e.computation = t.computation), t.baseRelation !== void 0 && (e.baseRelation = t.baseRelation), t.matchExpression !== void 0 && (e.matchExpression = t.matchExpression), t.inputRelations !== void 0 && (e.inputRelations = t.inputRelations);
|
|
534
505
|
const r = {
|
|
535
506
|
type: "Relation",
|
|
@@ -548,8 +519,8 @@ class C {
|
|
|
548
519
|
properties: t.properties?.map((s) => N.clone(s, e))
|
|
549
520
|
};
|
|
550
521
|
t.inputRelations || (i.source = t.source, i.target = t.target);
|
|
551
|
-
const r = t
|
|
552
|
-
return r !== void 0 && (i.name = r), t.computation !== void 0 && (i.computation = t.computation), t.baseRelation !== void 0 && (i.baseRelation = t.baseRelation), t.matchExpression !== void 0 && (i.matchExpression = t.matchExpression), t.inputRelations !== void 0 && (i.inputRelations = t.inputRelations), new
|
|
522
|
+
const r = (t instanceof M, t.name);
|
|
523
|
+
return r !== void 0 && (i.name = r), t.computation !== void 0 && (i.computation = t.computation), t.baseRelation !== void 0 && (i.baseRelation = t.baseRelation), t.matchExpression !== void 0 && (i.matchExpression = t.matchExpression), t.inputRelations !== void 0 && (i.inputRelations = t.inputRelations), new M(i, t._options);
|
|
553
524
|
}
|
|
554
525
|
static is(t) {
|
|
555
526
|
return t !== null && typeof t == "object" && "_type" in t && t._type === "Relation";
|
|
@@ -857,8 +828,8 @@ class nt {
|
|
|
857
828
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
858
829
|
}
|
|
859
830
|
static parse(t) {
|
|
860
|
-
const e = JSON.parse(t), i = e.public;
|
|
861
|
-
return
|
|
831
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
832
|
+
return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
|
|
862
833
|
}
|
|
863
834
|
}
|
|
864
835
|
class ct {
|
|
@@ -926,7 +897,7 @@ class ct {
|
|
|
926
897
|
}
|
|
927
898
|
static clone(t, e) {
|
|
928
899
|
let i = t.record;
|
|
929
|
-
return e && (I.is(t.record) ? i = I.clone(t.record, e) :
|
|
900
|
+
return e && (I.is(t.record) ? i = I.clone(t.record, e) : M.is(t.record) && (i = M.clone(t.record, e))), this.create({
|
|
930
901
|
record: i,
|
|
931
902
|
direction: t.direction,
|
|
932
903
|
callback: t.callback,
|
|
@@ -941,8 +912,8 @@ class ct {
|
|
|
941
912
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
942
913
|
}
|
|
943
914
|
static parse(t) {
|
|
944
|
-
const e = JSON.parse(t), i = e.public;
|
|
945
|
-
return
|
|
915
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
916
|
+
return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
|
|
946
917
|
}
|
|
947
918
|
}
|
|
948
919
|
class lt {
|
|
@@ -1162,8 +1133,8 @@ class dt {
|
|
|
1162
1133
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
1163
1134
|
}
|
|
1164
1135
|
static parse(t) {
|
|
1165
|
-
const e = JSON.parse(t), i = e.public;
|
|
1166
|
-
return
|
|
1136
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
1137
|
+
return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
|
|
1167
1138
|
}
|
|
1168
1139
|
}
|
|
1169
1140
|
class ht {
|
|
@@ -1252,8 +1223,8 @@ class ht {
|
|
|
1252
1223
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
1253
1224
|
}
|
|
1254
1225
|
static parse(t) {
|
|
1255
|
-
const e = JSON.parse(t), i = e.public;
|
|
1256
|
-
return
|
|
1226
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
1227
|
+
return typeof r.callback == "string" && r.callback.startsWith("func::") && (i.callback = new Function("return " + r.callback.substring(6))()), this.create(i, e.options);
|
|
1257
1228
|
}
|
|
1258
1229
|
}
|
|
1259
1230
|
class Tt {
|
|
@@ -1389,7 +1360,7 @@ class pt {
|
|
|
1389
1360
|
return t.attributeQuery !== void 0 && (i.attributeQuery = t.attributeQuery), t.dataDeps !== void 0 && (i.dataDeps = t.dataDeps), t.nextRecomputeTime !== void 0 && (i.nextRecomputeTime = t.nextRecomputeTime), this.create(i);
|
|
1390
1361
|
}
|
|
1391
1362
|
static is(t) {
|
|
1392
|
-
return t !== null && typeof t == "object" && "_type" in t && t._type === "
|
|
1363
|
+
return t !== null && typeof t == "object" && "_type" in t && t._type === "RealTimeValue";
|
|
1393
1364
|
}
|
|
1394
1365
|
static check(t) {
|
|
1395
1366
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
@@ -1457,8 +1428,8 @@ class qt {
|
|
|
1457
1428
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
1458
1429
|
}
|
|
1459
1430
|
static parse(t) {
|
|
1460
|
-
const e = JSON.parse(t), i = e.public;
|
|
1461
|
-
return
|
|
1431
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
1432
|
+
return typeof r.handle == "string" && r.handle.startsWith("func::") && (i.handle = new Function("return " + r.handle.substring(6))()), this.create(i, e.options);
|
|
1462
1433
|
}
|
|
1463
1434
|
}
|
|
1464
1435
|
class ft {
|
|
@@ -1640,8 +1611,11 @@ class R {
|
|
|
1640
1611
|
isExpression() {
|
|
1641
1612
|
return this.raw.type === "expression";
|
|
1642
1613
|
}
|
|
1614
|
+
static isExpressionData(t) {
|
|
1615
|
+
return t !== null && typeof t == "object" && "type" in t && (t.type === "atom" || t.type === "expression");
|
|
1616
|
+
}
|
|
1643
1617
|
static standardizeData(t) {
|
|
1644
|
-
return t instanceof R ? t.raw :
|
|
1618
|
+
return t instanceof R ? t.raw : R.isExpressionData(t) ? t : { type: "atom", data: t };
|
|
1645
1619
|
}
|
|
1646
1620
|
and(t) {
|
|
1647
1621
|
return new R({
|
|
@@ -1743,7 +1717,7 @@ class R {
|
|
|
1743
1717
|
}
|
|
1744
1718
|
const Me = [
|
|
1745
1719
|
I,
|
|
1746
|
-
|
|
1720
|
+
M,
|
|
1747
1721
|
N,
|
|
1748
1722
|
K,
|
|
1749
1723
|
Lt,
|
|
@@ -1757,7 +1731,7 @@ const Me = [
|
|
|
1757
1731
|
Tt,
|
|
1758
1732
|
pt,
|
|
1759
1733
|
qt,
|
|
1760
|
-
|
|
1734
|
+
Qt,
|
|
1761
1735
|
ft,
|
|
1762
1736
|
mt
|
|
1763
1737
|
];
|
|
@@ -1777,7 +1751,7 @@ class de {
|
|
|
1777
1751
|
this.clonedEntities.set(t, e), this.reverseEntityMap.set(e, t);
|
|
1778
1752
|
}
|
|
1779
1753
|
for (const t of this.originalRelations) {
|
|
1780
|
-
const e =
|
|
1754
|
+
const e = M.clone(t, !1);
|
|
1781
1755
|
this.clonedRelations.set(t, e), this.reverseRelationMap.set(e, t);
|
|
1782
1756
|
}
|
|
1783
1757
|
this.updateAllReferences();
|
|
@@ -1801,7 +1775,7 @@ class de {
|
|
|
1801
1775
|
if (i === t || i.uuid === t.uuid)
|
|
1802
1776
|
throw new Error(`Relation already exists in container: ${t.name}`);
|
|
1803
1777
|
this.originalRelations.push(t);
|
|
1804
|
-
const e =
|
|
1778
|
+
const e = M.clone(t, !1);
|
|
1805
1779
|
return this.clonedRelations.set(t, e), this.reverseRelationMap.set(e, t), this.updateReferencesInObject(e), e;
|
|
1806
1780
|
}
|
|
1807
1781
|
/**
|
|
@@ -2280,7 +2254,7 @@ class m {
|
|
|
2280
2254
|
constructor(t, e, i, r, s) {
|
|
2281
2255
|
this.map = e, this.contextRootEntity = r, this.fromRelation = s, b(!i || i instanceof R, `match data is not a BoolExpression instance, you passed: ${this.data}`);
|
|
2282
2256
|
const a = this.map.getRecordInfo(t);
|
|
2283
|
-
this.entityName = a.resolvedBaseRecordName, this.xToOneQueryTree = new
|
|
2257
|
+
this.entityName = a.resolvedBaseRecordName, this.xToOneQueryTree = new Q(this.entityName, this.map);
|
|
2284
2258
|
let o = i;
|
|
2285
2259
|
a.resolvedMatchExpression && (o = i ? a.resolvedMatchExpression.and(i) : a.resolvedMatchExpression), o && (this.data = this.convertFilteredRelation(o), this.buildQueryTree(this.data, this.xToOneQueryTree));
|
|
2286
2260
|
}
|
|
@@ -2523,7 +2497,7 @@ class Pe {
|
|
|
2523
2497
|
* 用于确保 ORDER BY 中引用的关联字段会触发相应的 JOIN
|
|
2524
2498
|
*/
|
|
2525
2499
|
get xToOneQueryTree() {
|
|
2526
|
-
const t = new
|
|
2500
|
+
const t = new Q(this.recordName, this.map);
|
|
2527
2501
|
return Object.keys(this.data?.orderBy || {}).forEach((e) => {
|
|
2528
2502
|
const i = e.split(".");
|
|
2529
2503
|
if (i.length === 1) {
|
|
@@ -2534,7 +2508,7 @@ class Pe {
|
|
|
2534
2508
|
}), t;
|
|
2535
2509
|
}
|
|
2536
2510
|
}
|
|
2537
|
-
class
|
|
2511
|
+
class P {
|
|
2538
2512
|
constructor(t, e, i, r, s, a, o, n, c, l = !1, d, h, p, y) {
|
|
2539
2513
|
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;
|
|
2540
2514
|
}
|
|
@@ -2544,7 +2518,7 @@ class M {
|
|
|
2544
2518
|
key: "id",
|
|
2545
2519
|
value: ["not", null]
|
|
2546
2520
|
}), y = p;
|
|
2547
|
-
return l.resolvedMatchExpression && (y = p.and(new m(d, e, l.resolvedMatchExpression))), new
|
|
2521
|
+
return l.resolvedMatchExpression && (y = p.and(new m(d, e, l.resolvedMatchExpression))), new P(
|
|
2548
2522
|
d,
|
|
2549
2523
|
e,
|
|
2550
2524
|
y,
|
|
@@ -2571,7 +2545,7 @@ class M {
|
|
|
2571
2545
|
// CAUTION 特别注意这里的参数,不能让用取用原本的 matchExpression, attributeQuery, modifier 里面的 data 传进来。
|
|
2572
2546
|
// 因为 data 不能代表一切配置,例如 attributeQuery 里面 还有个 shouldQueryParentLinkData 就是保存在 this 上的。
|
|
2573
2547
|
derive({ matchExpression: t, attributeQuery: e, modifier: i }) {
|
|
2574
|
-
return new
|
|
2548
|
+
return new P(
|
|
2575
2549
|
this.recordName,
|
|
2576
2550
|
this.map,
|
|
2577
2551
|
t || this.matchExpression,
|
|
@@ -2588,7 +2562,7 @@ class M {
|
|
|
2588
2562
|
);
|
|
2589
2563
|
}
|
|
2590
2564
|
}
|
|
2591
|
-
class
|
|
2565
|
+
class Q {
|
|
2592
2566
|
// 父节点和自己这个几点 link 上的 query
|
|
2593
2567
|
constructor(t, e, i, r, s, a, o) {
|
|
2594
2568
|
this.recordName = t, this.map = e, this.parentRecord = i, this.attributeName = r, this.data = s, this.parent = a, this.parentLinkQueryTree = o, this.fields = [], b(!!t, "recordName cannot be empty"), this.fields = s?.fields || [], this.records = s?.records || {}, i && (this.info = this.map.getInfo(this.parentRecord, this.attributeName));
|
|
@@ -2598,26 +2572,26 @@ class V {
|
|
|
2598
2572
|
if (t.length === 1)
|
|
2599
2573
|
this.fields.push(e);
|
|
2600
2574
|
else if (e === f)
|
|
2601
|
-
this.parentLinkQueryTree || (this.parentLinkQueryTree = new
|
|
2575
|
+
this.parentLinkQueryTree || (this.parentLinkQueryTree = new Q(this.info.linkName, this.map)), this.parentLinkQueryTree.addField(i);
|
|
2602
2576
|
else {
|
|
2603
2577
|
const r = this.map.getInfo(this.recordName, e);
|
|
2604
|
-
this.records[e] || (this.records[e] = new
|
|
2578
|
+
this.records[e] || (this.records[e] = new Q(r.recordName, this.map, this.recordName, e, void 0, this)), this.records[e].addField(i);
|
|
2605
2579
|
}
|
|
2606
2580
|
}
|
|
2607
2581
|
addRecord(t, e) {
|
|
2608
2582
|
const [i, ...r] = t;
|
|
2609
2583
|
if (t.length === 1)
|
|
2610
2584
|
if (i === f)
|
|
2611
|
-
this.parentLinkQueryTree || (this.parentLinkQueryTree = new
|
|
2585
|
+
this.parentLinkQueryTree || (this.parentLinkQueryTree = new Q(this.info.linkName, this.map)), e && (this.parentLinkQueryTree = this.parentLinkQueryTree.merge(e));
|
|
2612
2586
|
else {
|
|
2613
|
-
const s = this.map.getInfo(this.recordName, i), a = e || new
|
|
2587
|
+
const s = this.map.getInfo(this.recordName, i), a = e || new Q(s.recordName, this.map, this.recordName, i, void 0, this);
|
|
2614
2588
|
this.records[i] = this.records[i] ? this.records[i].merge(a) : a;
|
|
2615
2589
|
}
|
|
2616
2590
|
else if (i === f)
|
|
2617
|
-
this.parentLinkQueryTree || (this.parentLinkQueryTree = new
|
|
2591
|
+
this.parentLinkQueryTree || (this.parentLinkQueryTree = new Q(this.info.linkName, this.map)), this.parentLinkQueryTree.addRecord(r, e);
|
|
2618
2592
|
else {
|
|
2619
2593
|
const s = this.map.getInfo(this.recordName, i);
|
|
2620
|
-
this.records[i] = new
|
|
2594
|
+
this.records[i] = new Q(s.recordName, this.map, this.recordName, i, void 0, this), this.records[i].addRecord(r, e);
|
|
2621
2595
|
}
|
|
2622
2596
|
}
|
|
2623
2597
|
forEachRecords(t) {
|
|
@@ -2632,7 +2606,7 @@ class V {
|
|
|
2632
2606
|
this.records[a] && t.records[a] ? r[a] = this.records[a].merge(t.records[a]) : this.records[a] ? r[a] = this.records[a] : r[a] = t.records[a];
|
|
2633
2607
|
});
|
|
2634
2608
|
let s;
|
|
2635
|
-
return this.parentLinkQueryTree && t.parentLinkQueryTree ? s = this.parentLinkQueryTree.merge(t.parentLinkQueryTree) : s = this.parentLinkQueryTree || t.parentLinkQueryTree, new
|
|
2609
|
+
return this.parentLinkQueryTree && t.parentLinkQueryTree ? s = this.parentLinkQueryTree.merge(t.parentLinkQueryTree) : s = this.parentLinkQueryTree || t.parentLinkQueryTree, new Q(this.recordName, this.map, this.parentRecord, this.attributeName, { fields: e, records: r }, this.parent, s);
|
|
2636
2610
|
}
|
|
2637
2611
|
getData() {
|
|
2638
2612
|
const t = {
|
|
@@ -2653,7 +2627,7 @@ class x {
|
|
|
2653
2627
|
if (l === f) {
|
|
2654
2628
|
b(!!(this.parentRecord && this.attributeName), `parent record and attribute name cannot be empty when query link data, you passed ${this.parentRecord} ${this.attributeName}`);
|
|
2655
2629
|
const y = this.map.getInfo(this.parentRecord, this.attributeName);
|
|
2656
|
-
this.parentLinkRecordQuery =
|
|
2630
|
+
this.parentLinkRecordQuery = P.create(y.linkName, this.map, d, void 0);
|
|
2657
2631
|
return;
|
|
2658
2632
|
}
|
|
2659
2633
|
if (l === Ce) {
|
|
@@ -2671,7 +2645,7 @@ class x {
|
|
|
2671
2645
|
matchExpression: Ae.data
|
|
2672
2646
|
};
|
|
2673
2647
|
}
|
|
2674
|
-
const g =
|
|
2648
|
+
const g = P.create(p.recordName, this.map, v, void 0, this.recordName, y, h, !1, l);
|
|
2675
2649
|
this.relatedRecords.push(g), p.isXToMany ? this.xToManyRecords.push(g) : p.isXToOne && this.xToOneRecords.push(g);
|
|
2676
2650
|
} else
|
|
2677
2651
|
o.add(l);
|
|
@@ -2765,7 +2739,7 @@ class x {
|
|
|
2765
2739
|
return this.buildXToOneQueryTree();
|
|
2766
2740
|
}
|
|
2767
2741
|
buildXToOneQueryTree() {
|
|
2768
|
-
const t = new
|
|
2742
|
+
const t = new Q(this.recordName, this.map, this.parentRecord, this.attributeName);
|
|
2769
2743
|
if (this.data.forEach((e) => {
|
|
2770
2744
|
Array.isArray(e) || t.addField([e]);
|
|
2771
2745
|
}), this.xToOneRecords.forEach((e) => {
|
|
@@ -2777,7 +2751,7 @@ class x {
|
|
|
2777
2751
|
return t;
|
|
2778
2752
|
}
|
|
2779
2753
|
buildFullQueryTree() {
|
|
2780
|
-
const t = new
|
|
2754
|
+
const t = new Q(this.recordName, this.map, this.parentRecord, this.attributeName);
|
|
2781
2755
|
return this.relatedRecords.forEach((e) => {
|
|
2782
2756
|
t.addRecord([e.attributeName], e.attributeQuery.fullQueryTree);
|
|
2783
2757
|
}), t;
|
|
@@ -2790,14 +2764,14 @@ function $e(u) {
|
|
|
2790
2764
|
const t = [];
|
|
2791
2765
|
return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
|
|
2792
2766
|
}
|
|
2793
|
-
class
|
|
2767
|
+
class V {
|
|
2794
2768
|
constructor(t, e, i, r) {
|
|
2795
2769
|
this.map = t, this.originalRecordName = e, this.rawData = i, this.info = r, this.mergedLinkTargetNewRecords = [], this.mergedLinkTargetRecordIdRefs = [], this.mergedLinkTargetNullRecords = [], this.combinedNewRecords = [], this.combinedRecordIdRefs = [], this.combinedNullRecords = [], this.differentTableMergedLinkNewRecords = [], this.differentTableMergedLinkRecordIdRefs = [], this.differentTableMergedLinkNullRecords = [], this.isolatedNewRecords = [], this.isolatedRecordIdRefs = [], this.isolatedNullRecords = [], this.entityIdAttributes = [], this.relatedEntitiesData = [], this.valueAttributes = [], this.sameRowEntityIdRefs = [], this.defaultValues = {};
|
|
2796
2770
|
const s = this.map.getRecordInfo(e);
|
|
2797
2771
|
this.recordName = s.resolvedBaseRecordName;
|
|
2798
2772
|
const [a, o, n] = this.map.groupAttributes(this.recordName, i ? Object.keys(i) : []);
|
|
2799
2773
|
this.relatedEntitiesData = $e(o.map(
|
|
2800
|
-
(l) => Array.isArray(i[l.attributeName]) ? i[l.attributeName].map((d) => new
|
|
2774
|
+
(l) => Array.isArray(i[l.attributeName]) ? i[l.attributeName].map((d) => new V(this.map, l.recordName, d, l)) : new V(this.map, l.recordName, i[l.attributeName], l)
|
|
2801
2775
|
)), this.valueAttributes = a, this.entityIdAttributes = n;
|
|
2802
2776
|
const c = this.map.getRecordInfo(this.recordName);
|
|
2803
2777
|
this.defaultValues = c.valueAttributes.reduce((l, d) => {
|
|
@@ -2805,10 +2779,10 @@ class Q {
|
|
|
2805
2779
|
return !this.rawData?.hasOwnProperty(d.attributeName) && h.defaultValue && typeof h.defaultValue == "function" && (l[d.attributeName] = h.defaultValue(i, this.originalRecordName)), l;
|
|
2806
2780
|
}, {}), this.relatedEntitiesData.forEach((l) => {
|
|
2807
2781
|
l.info.isMergedWithParent() ? l.isNull() ? this.combinedNullRecords.push(l) : l.isRef() ? this.combinedRecordIdRefs.push(l) : this.combinedNewRecords.push(l) : l.info.isLinkMergedWithParent() ? l.isNull() ? this.mergedLinkTargetNullRecords.push(l) : l.isRef() ? this.mergedLinkTargetRecordIdRefs.push(l) : this.mergedLinkTargetNewRecords.push(l) : l.info.isLinkMergedWithAttribute() ? l.isNull() ? this.differentTableMergedLinkNullRecords.push(l) : l.isRef() ? this.differentTableMergedLinkRecordIdRefs.push(l) : this.differentTableMergedLinkNewRecords.push(l) : l.isNull() ? this.isolatedNullRecords.push(l) : l.isRef() ? this.isolatedRecordIdRefs.push(l) : this.isolatedNewRecords.push(l);
|
|
2808
|
-
}), this.rawData?.[f] && (this.linkRecordData = new
|
|
2782
|
+
}), this.rawData?.[f] && (this.linkRecordData = new V(this.map, r?.linkName, this.rawData[f]));
|
|
2809
2783
|
}
|
|
2810
2784
|
merge(t) {
|
|
2811
|
-
const e = new
|
|
2785
|
+
const e = new V(this.map, this.originalRecordName, { ...this.rawData, ...t }, this.info);
|
|
2812
2786
|
return this.recordName !== this.originalRecordName && (e.recordName = this.recordName), e;
|
|
2813
2787
|
}
|
|
2814
2788
|
getRef() {
|
|
@@ -2996,7 +2970,7 @@ class Oe {
|
|
|
2996
2970
|
}), n = {
|
|
2997
2971
|
[a.attributeName]: i,
|
|
2998
2972
|
[f]: s.getData()[f]
|
|
2999
|
-
}, [c] = await this.helper.updateRecord(a.parentEntityName, o, new
|
|
2973
|
+
}, [c] = await this.helper.updateRecord(a.parentEntityName, o, new V(this.map, a.parentEntityName, n), e);
|
|
3000
2974
|
s.info.isXToMany ? (r[s.info.attributeName] || (r[s.info.attributeName] = []), r[s.info.attributeName].push({
|
|
3001
2975
|
...c,
|
|
3002
2976
|
[f]: c[a.attributeName][f]
|
|
@@ -3011,7 +2985,7 @@ class Oe {
|
|
|
3011
2985
|
source: s.info.isRecordSource() ? i : a,
|
|
3012
2986
|
target: s.info.isRecordSource() ? a : i
|
|
3013
2987
|
});
|
|
3014
|
-
const n = new
|
|
2988
|
+
const n = new V(this.map, s.info.linkName, o), c = await this.createRecord(n, `create isolated related link record ${t.recordName}.${s.info?.attributeName}`, e);
|
|
3015
2989
|
s.info.isXToMany ? (r[s.info.attributeName] || (r[s.info.attributeName] = []), r[s.info.attributeName].push({
|
|
3016
2990
|
...a,
|
|
3017
2991
|
[f]: c
|
|
@@ -3034,7 +3008,7 @@ class Oe {
|
|
|
3034
3008
|
source: a.info.isRecordSource() ? i : a.getRef(),
|
|
3035
3009
|
target: a.info.isRecordSource() ? a.getRef() : i
|
|
3036
3010
|
});
|
|
3037
|
-
const n = new
|
|
3011
|
+
const n = new V(this.map, a.info.linkName, o), c = await this.createRecord(n, `create isolated related link record of old related ${t.recordName}.${a.info?.attributeName}`, e);
|
|
3038
3012
|
a.info.isXToMany ? (r[a.info.attributeName] || (r[a.info.attributeName] = []), r[a.info.attributeName][s] = {
|
|
3039
3013
|
...a.getData(),
|
|
3040
3014
|
[f]: c
|
|
@@ -3056,7 +3030,7 @@ class Oe {
|
|
|
3056
3030
|
* 添加链接
|
|
3057
3031
|
*/
|
|
3058
3032
|
async addLink(t, e, i, r = {}, s = !1, a) {
|
|
3059
|
-
const o = (await this.queryExecutor.findRecords(
|
|
3033
|
+
const o = (await this.queryExecutor.findRecords(P.create(t, this.map, {
|
|
3060
3034
|
matchExpression: m.atom({ key: "source.id", value: ["=", e] }).and({
|
|
3061
3035
|
key: "target.id",
|
|
3062
3036
|
value: ["=", i]
|
|
@@ -3074,7 +3048,7 @@ class Oe {
|
|
|
3074
3048
|
});
|
|
3075
3049
|
await this.helper.unlink(t, h, !1, "unlink combined record for add new link", a);
|
|
3076
3050
|
}
|
|
3077
|
-
const c = new
|
|
3051
|
+
const c = new V(this.map, n.name, {
|
|
3078
3052
|
source: { id: e },
|
|
3079
3053
|
target: { id: i },
|
|
3080
3054
|
...r
|
|
@@ -3168,7 +3142,7 @@ class De {
|
|
|
3168
3142
|
const o = s.path.concat("id").join("."), n = m.atom({
|
|
3169
3143
|
key: o,
|
|
3170
3144
|
value: ["=", i]
|
|
3171
|
-
}), c =
|
|
3145
|
+
}), c = P.create(t.baseEntityName, this.map, {
|
|
3172
3146
|
matchExpression: n,
|
|
3173
3147
|
attributeQuery: ["id"]
|
|
3174
3148
|
});
|
|
@@ -3180,7 +3154,7 @@ class De {
|
|
|
3180
3154
|
async checkRecordMatchesFilter(t, e, i) {
|
|
3181
3155
|
if (!this.queryAgent)
|
|
3182
3156
|
throw new Error("QueryAgent not set in FilteredEntityManager");
|
|
3183
|
-
const r =
|
|
3157
|
+
const r = P.create(e, this.map, {
|
|
3184
3158
|
matchExpression: i.and({
|
|
3185
3159
|
key: "id",
|
|
3186
3160
|
value: ["=", t]
|
|
@@ -3275,7 +3249,7 @@ class De {
|
|
|
3275
3249
|
*/
|
|
3276
3250
|
async updateSingleFilteredEntityFlag(t, e, i) {
|
|
3277
3251
|
const r = this.map.getRecordInfo(t.baseEntityName), s = await this.queryAgent.findRecords(
|
|
3278
|
-
|
|
3252
|
+
P.create(t.baseEntityName, this.map, {
|
|
3279
3253
|
matchExpression: m.atom({ key: "id", value: ["=", e] }),
|
|
3280
3254
|
attributeQuery: r.isRelation ? ["*", ["target", { attributeQuery: ["*"] }], ["source", { attributeQuery: ["*"] }]] : ["*"]
|
|
3281
3255
|
}),
|
|
@@ -3335,7 +3309,7 @@ class Fe {
|
|
|
3335
3309
|
return this.aliasToPath.get(t);
|
|
3336
3310
|
}
|
|
3337
3311
|
}
|
|
3338
|
-
class
|
|
3312
|
+
class Ve {
|
|
3339
3313
|
constructor(t, e) {
|
|
3340
3314
|
this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?");
|
|
3341
3315
|
}
|
|
@@ -3520,7 +3494,7 @@ ${A}
|
|
|
3520
3494
|
if (!s.data.isFunctionMatch) return { ...s.data };
|
|
3521
3495
|
if (s.data.value[0].toLowerCase() !== "exist")
|
|
3522
3496
|
throw new Error(`we only support Exist function match on entity for now. yours: ${s.data.key} ${s.data.value[0]} ${s.data.value[1]}`);
|
|
3523
|
-
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 =
|
|
3497
|
+
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 = P.create(
|
|
3524
3498
|
o.recordName,
|
|
3525
3499
|
this.map,
|
|
3526
3500
|
{
|
|
@@ -3622,15 +3596,9 @@ class it {
|
|
|
3622
3596
|
constructor(t, e, i = []) {
|
|
3623
3597
|
this.label = t, this.parent = e, this.stack = i;
|
|
3624
3598
|
}
|
|
3625
|
-
/**
|
|
3626
|
-
* 添加一个值到栈中,返回新的上下文
|
|
3627
|
-
*/
|
|
3628
3599
|
concat(t) {
|
|
3629
3600
|
return new it(this.label, this.parent, [...this.stack, t]);
|
|
3630
3601
|
}
|
|
3631
|
-
/**
|
|
3632
|
-
* 获取栈数据
|
|
3633
|
-
*/
|
|
3634
3602
|
getStack(t) {
|
|
3635
3603
|
return [...this.stack];
|
|
3636
3604
|
}
|
|
@@ -3641,7 +3609,7 @@ class it {
|
|
|
3641
3609
|
return new it(t, this);
|
|
3642
3610
|
}
|
|
3643
3611
|
}
|
|
3644
|
-
class
|
|
3612
|
+
class Qe {
|
|
3645
3613
|
constructor(t) {
|
|
3646
3614
|
this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(_t, t), this.recursiveSaveLabelledRecordQuery(t);
|
|
3647
3615
|
}
|
|
@@ -3682,7 +3650,7 @@ class Le {
|
|
|
3682
3650
|
* CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
|
|
3683
3651
|
*/
|
|
3684
3652
|
async findRecords(t, e = "", i, r = new it(_t)) {
|
|
3685
|
-
if (i || (i = new
|
|
3653
|
+
if (i || (i = new Qe(t)), t.goto) {
|
|
3686
3654
|
if (t.exit && await t.exit(r))
|
|
3687
3655
|
return [];
|
|
3688
3656
|
const d = i.get(t.goto);
|
|
@@ -3853,7 +3821,7 @@ class Le {
|
|
|
3853
3821
|
return p = [...g.stack], !0;
|
|
3854
3822
|
};
|
|
3855
3823
|
h.push([o, { goto: d, exit: y }]);
|
|
3856
|
-
const v = (await this.findRecords(
|
|
3824
|
+
const v = (await this.findRecords(P.create(t, this.map, {
|
|
3857
3825
|
matchExpression: c,
|
|
3858
3826
|
attributeQuery: l
|
|
3859
3827
|
}), `find records for path ${t}.${e}`))[0];
|
|
@@ -3868,7 +3836,7 @@ class qe {
|
|
|
3868
3836
|
* 删除记录(主入口)
|
|
3869
3837
|
*/
|
|
3870
3838
|
async deleteRecord(t, e, i, r = !1) {
|
|
3871
|
-
const s =
|
|
3839
|
+
const s = P.create(t, this.map, {
|
|
3872
3840
|
matchExpression: e,
|
|
3873
3841
|
attributeQuery: x.getAttributeQueryDataForRecord(
|
|
3874
3842
|
t,
|
|
@@ -3898,7 +3866,7 @@ class qe {
|
|
|
3898
3866
|
const s = this.map.getRecordInfo(t);
|
|
3899
3867
|
for (let a of e) {
|
|
3900
3868
|
if (!r) {
|
|
3901
|
-
const o =
|
|
3869
|
+
const o = P.create(
|
|
3902
3870
|
t,
|
|
3903
3871
|
this.map,
|
|
3904
3872
|
{
|
|
@@ -4040,7 +4008,7 @@ class Be {
|
|
|
4040
4008
|
* 更新记录(主入口)
|
|
4041
4009
|
*/
|
|
4042
4010
|
async updateRecord(t, e, i, r) {
|
|
4043
|
-
const s =
|
|
4011
|
+
const s = P.create(t, this.map, {
|
|
4044
4012
|
matchExpression: e,
|
|
4045
4013
|
attributeQuery: x.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0)
|
|
4046
4014
|
}), a = await this.helper.findRecords(s, `find record for updating ${t}`), o = [];
|
|
@@ -4138,7 +4106,7 @@ class Be {
|
|
|
4138
4106
|
}
|
|
4139
4107
|
class _e {
|
|
4140
4108
|
constructor(t, e) {
|
|
4141
|
-
this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new De(t, this), this.sqlBuilder = new
|
|
4109
|
+
this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (i) => "?"), this.filteredEntityManager = new De(t, this), this.sqlBuilder = new Ve(t, e), this.queryExecutor = new Le(t, e, this.sqlBuilder), this.creationExecutor = new Oe(t, e, this.queryExecutor, this.filteredEntityManager, this.sqlBuilder, this), this.deletionExecutor = new qe(t, e, this.queryExecutor, this.filteredEntityManager, this.sqlBuilder, this), this.updateExecutor = new Be(t, e, this.filteredEntityManager, this.sqlBuilder, this), this.initializeFilteredEntityDependencies();
|
|
4142
4110
|
}
|
|
4143
4111
|
/**
|
|
4144
4112
|
* 初始化所有 filtered entity 的依赖关系
|
|
@@ -4230,7 +4198,7 @@ class _e {
|
|
|
4230
4198
|
};
|
|
4231
4199
|
s ? s = s.or(l) : s = m.atom(l);
|
|
4232
4200
|
}
|
|
4233
|
-
const o =
|
|
4201
|
+
const o = P.create(t.recordName, this.map, {
|
|
4234
4202
|
matchExpression: s,
|
|
4235
4203
|
attributeQuery: a
|
|
4236
4204
|
}, void 0, void 0, void 0, !1, !0), n = await this.queryExecutor.findRecords(o, i, void 0);
|
|
@@ -4256,13 +4224,13 @@ class _e {
|
|
|
4256
4224
|
* 用于 unlink 场景中处理合并记录的数据迁移
|
|
4257
4225
|
*/
|
|
4258
4226
|
async relocateCombinedRecordDataForLink(t, e, i = !1, r) {
|
|
4259
|
-
const s = x.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0), a = i ? "source" : "target", o = await this.queryExecutor.findRecords(
|
|
4227
|
+
const s = x.getAttributeQueryDataForRecord(t, this.map, !0, !0, !0, !0), a = i ? "source" : "target", o = await this.queryExecutor.findRecords(P.create(t, this.map, {
|
|
4260
4228
|
matchExpression: e,
|
|
4261
4229
|
attributeQuery: s
|
|
4262
4230
|
}), `finding combined records for relocate ${t}.${a}`, void 0), n = this.map.getLinkInfoByName(t)[i ? "sourceRecordInfo" : "targetRecordInfo"];
|
|
4263
4231
|
await this.deleteRecordSameRowData(n.name, o.map((c) => c[a]));
|
|
4264
4232
|
for (let c of o) {
|
|
4265
|
-
const l = new
|
|
4233
|
+
const l = new V(this.map, n.name, c[a]);
|
|
4266
4234
|
await this.creationExecutor.insertSameRowData(l, void 0), r?.push({
|
|
4267
4235
|
type: "delete",
|
|
4268
4236
|
recordName: t,
|
|
@@ -4319,7 +4287,7 @@ class We {
|
|
|
4319
4287
|
}
|
|
4320
4288
|
async find(t, e, i, r = []) {
|
|
4321
4289
|
b(this.map.getRecord(t), `cannot find entity ${t}`);
|
|
4322
|
-
const s =
|
|
4290
|
+
const s = P.create(
|
|
4323
4291
|
t,
|
|
4324
4292
|
this.map,
|
|
4325
4293
|
{
|
|
@@ -4331,12 +4299,12 @@ class We {
|
|
|
4331
4299
|
return this.agent.findRecords(s, `finding ${t} from handle`);
|
|
4332
4300
|
}
|
|
4333
4301
|
async create(t, e, i) {
|
|
4334
|
-
const r = new
|
|
4302
|
+
const r = new V(this.map, t, e);
|
|
4335
4303
|
return this.agent.createRecord(r, `create record ${t} from handle`, i);
|
|
4336
4304
|
}
|
|
4337
4305
|
// CAUTION 不能递归更新 relate entity 的 value,如果传入了 related entity 的值,说明是建立新的联系。
|
|
4338
4306
|
async update(t, e, i, r) {
|
|
4339
|
-
const s = new
|
|
4307
|
+
const s = new V(this.map, t, i);
|
|
4340
4308
|
return this.agent.updateRecord(t, e, s, r);
|
|
4341
4309
|
}
|
|
4342
4310
|
async delete(t, e, i) {
|
|
@@ -4349,7 +4317,7 @@ class We {
|
|
|
4349
4317
|
return this.agent.addLinkFromRecord(t, e, i, r, s, a);
|
|
4350
4318
|
}
|
|
4351
4319
|
async updateRelationByName(t, e, i, r) {
|
|
4352
|
-
return b(!i.source && !i.target, "Relation can only update attributes. Use addRelation/removeRelation to update source/target."), this.agent.updateRecord(t, e, new
|
|
4320
|
+
return b(!i.source && !i.target, "Relation can only update attributes. Use addRelation/removeRelation to update source/target."), this.agent.updateRecord(t, e, new V(this.map, t, i), r);
|
|
4353
4321
|
}
|
|
4354
4322
|
async removeRelationByName(t, e, i) {
|
|
4355
4323
|
return this.agent.unlink(t, e, !1, `remove relation ${t}`, i);
|
|
@@ -4941,7 +4909,7 @@ function Ze(u, t, e, i) {
|
|
|
4941
4909
|
}))
|
|
4942
4910
|
)) : o.properties = s, [o, n || o];
|
|
4943
4911
|
} else {
|
|
4944
|
-
const a = i.getRelationByName(u.name), o =
|
|
4912
|
+
const a = i.getRelationByName(u.name), o = M.create({
|
|
4945
4913
|
name: a.name,
|
|
4946
4914
|
source: a.source,
|
|
4947
4915
|
sourceProperty: a.sourceProperty,
|
|
@@ -4953,7 +4921,7 @@ function Ze(u, t, e, i) {
|
|
|
4953
4921
|
let n;
|
|
4954
4922
|
if (a.inputRelations?.some((c) => c.baseRelation)) {
|
|
4955
4923
|
const c = a.name || `${a.source.name}_${a.sourceProperty}_${a.targetProperty}_${a.target.name}`;
|
|
4956
|
-
n =
|
|
4924
|
+
n = M.create({
|
|
4957
4925
|
name: `__${c}_base`,
|
|
4958
4926
|
source: a.source,
|
|
4959
4927
|
sourceProperty: `__${a.sourceProperty}_base`,
|
|
@@ -4990,7 +4958,7 @@ function ti(u, t, e) {
|
|
|
4990
4958
|
}), [a, s];
|
|
4991
4959
|
} else {
|
|
4992
4960
|
const i = u, r = t, s = X(i);
|
|
4993
|
-
return i.baseRelation ? [i, ei(i)] : [
|
|
4961
|
+
return i.baseRelation ? [i, ei(i)] : [M.create({
|
|
4994
4962
|
name: s,
|
|
4995
4963
|
baseRelation: r,
|
|
4996
4964
|
sourceProperty: i.sourceProperty,
|
|
@@ -5684,7 +5652,7 @@ const Z = "_System_", L = "_Dictionary_", re = "id", se = "_rowId", ai = I.creat
|
|
|
5684
5652
|
collection: !1
|
|
5685
5653
|
})
|
|
5686
5654
|
]
|
|
5687
|
-
}),
|
|
5655
|
+
}), yr = 0, It = 1, gr = 2;
|
|
5688
5656
|
class ni {
|
|
5689
5657
|
constructor(t, e) {
|
|
5690
5658
|
this.controller = t, this.scheduler = e, this.sourceMaps = [], this.sourceMapTree = {};
|
|
@@ -5949,8 +5917,8 @@ class E {
|
|
|
5949
5917
|
return await this.controller.system.storage.update(this.record, m.atom({ key: "id", value: ["=", t.id] }), { [this.key]: e }), e;
|
|
5950
5918
|
}
|
|
5951
5919
|
async get(t) {
|
|
5952
|
-
if (t[this.key] === void 0) {
|
|
5953
|
-
const i = (await this.controller.system.storage.findOne(this.record, m.atom({ key: "id", value: ["=", t.id] }), void 0, [this.key]))?.[this.key];
|
|
5920
|
+
if (!t || t[this.key] === void 0) {
|
|
5921
|
+
const i = (t ? await this.controller.system.storage.findOne(this.record, m.atom({ key: "id", value: ["=", t.id] }), void 0, [this.key]) : void 0)?.[this.key];
|
|
5954
5922
|
return i !== void 0 ? i : this.defaultValue;
|
|
5955
5923
|
}
|
|
5956
5924
|
return t[this.key];
|
|
@@ -5973,8 +5941,9 @@ function Ct(u, t) {
|
|
|
5973
5941
|
return u === t;
|
|
5974
5942
|
if (typeof u != "object" || u === null)
|
|
5975
5943
|
return !1;
|
|
5976
|
-
|
|
5977
|
-
|
|
5944
|
+
const e = u, i = t;
|
|
5945
|
+
for (const r in i)
|
|
5946
|
+
if (!(r in e) || !Ct(e[r], i[r]))
|
|
5978
5947
|
return !1;
|
|
5979
5948
|
return !0;
|
|
5980
5949
|
}
|
|
@@ -6004,23 +5973,23 @@ function k(u, t) {
|
|
|
6004
5973
|
if (!u)
|
|
6005
5974
|
throw new Error(t);
|
|
6006
5975
|
}
|
|
6007
|
-
function
|
|
5976
|
+
function br(u, t) {
|
|
6008
5977
|
return new Map(Array.from(u.entries()).map(([e, i]) => [e, t(e, i)]));
|
|
6009
5978
|
}
|
|
6010
|
-
function
|
|
5979
|
+
function Rr(u, t) {
|
|
6011
5980
|
return Object.fromEntries(Object.entries(u).map(([e, i]) => [e, t(e, i)]));
|
|
6012
5981
|
}
|
|
6013
|
-
async function
|
|
5982
|
+
async function wr(u, t) {
|
|
6014
5983
|
for (let e of u)
|
|
6015
5984
|
if (!await t(e)) return !1;
|
|
6016
5985
|
return !0;
|
|
6017
5986
|
}
|
|
6018
|
-
async function
|
|
5987
|
+
async function Nr(u, t) {
|
|
6019
5988
|
for (let e of u)
|
|
6020
5989
|
if (await t(e)) return !0;
|
|
6021
5990
|
return !1;
|
|
6022
5991
|
}
|
|
6023
|
-
async function
|
|
5992
|
+
async function vr(u, t) {
|
|
6024
5993
|
for (let e of u) {
|
|
6025
5994
|
const i = await t(e);
|
|
6026
5995
|
if (i !== !0) return i;
|
|
@@ -6104,13 +6073,13 @@ Or if you want to use state name as value, you should not set ${this.dataContext
|
|
|
6104
6073
|
};
|
|
6105
6074
|
}
|
|
6106
6075
|
}
|
|
6107
|
-
const
|
|
6076
|
+
const Tr = K.create({
|
|
6108
6077
|
name: "nonExistent",
|
|
6109
6078
|
computeValue: () => null
|
|
6110
|
-
}),
|
|
6079
|
+
}), Ar = K.create({
|
|
6111
6080
|
name: "nonDeleted",
|
|
6112
6081
|
computeValue: () => !1
|
|
6113
|
-
}),
|
|
6082
|
+
}), kr = K.create({
|
|
6114
6083
|
name: "deleted",
|
|
6115
6084
|
computeValue: () => !0
|
|
6116
6085
|
}), ui = [ci, li];
|
|
@@ -6746,19 +6715,19 @@ class Ti {
|
|
|
6746
6715
|
}
|
|
6747
6716
|
}
|
|
6748
6717
|
const Ai = [Ti];
|
|
6749
|
-
class
|
|
6718
|
+
class C {
|
|
6750
6719
|
constructor(t) {
|
|
6751
6720
|
this.node = t;
|
|
6752
6721
|
}
|
|
6753
6722
|
static number(t) {
|
|
6754
|
-
return new
|
|
6723
|
+
return new C({ type: "number", value: t });
|
|
6755
6724
|
}
|
|
6756
6725
|
static variable(t) {
|
|
6757
|
-
return new
|
|
6726
|
+
return new C({ type: "variable", variable: { id: t } });
|
|
6758
6727
|
}
|
|
6759
6728
|
add(t) {
|
|
6760
6729
|
const e = typeof t == "number" ? { type: "number", value: t } : t.node;
|
|
6761
|
-
return new
|
|
6730
|
+
return new C({
|
|
6762
6731
|
type: "operation",
|
|
6763
6732
|
operation: "+",
|
|
6764
6733
|
left: this.node,
|
|
@@ -6767,7 +6736,7 @@ class P {
|
|
|
6767
6736
|
}
|
|
6768
6737
|
subtract(t) {
|
|
6769
6738
|
const e = typeof t == "number" ? { type: "number", value: t } : t.node;
|
|
6770
|
-
return new
|
|
6739
|
+
return new C({
|
|
6771
6740
|
type: "operation",
|
|
6772
6741
|
operation: "-",
|
|
6773
6742
|
left: this.node,
|
|
@@ -6776,7 +6745,7 @@ class P {
|
|
|
6776
6745
|
}
|
|
6777
6746
|
multiply(t) {
|
|
6778
6747
|
const e = typeof t == "number" ? { type: "number", value: t } : t.node;
|
|
6779
|
-
return new
|
|
6748
|
+
return new C({
|
|
6780
6749
|
type: "operation",
|
|
6781
6750
|
operation: "*",
|
|
6782
6751
|
left: this.node,
|
|
@@ -6785,7 +6754,7 @@ class P {
|
|
|
6785
6754
|
}
|
|
6786
6755
|
divide(t) {
|
|
6787
6756
|
const e = typeof t == "number" ? { type: "number", value: t } : t.node;
|
|
6788
|
-
return new
|
|
6757
|
+
return new C({
|
|
6789
6758
|
type: "operation",
|
|
6790
6759
|
operation: "/",
|
|
6791
6760
|
left: this.node,
|
|
@@ -6794,7 +6763,7 @@ class P {
|
|
|
6794
6763
|
}
|
|
6795
6764
|
power(t) {
|
|
6796
6765
|
const e = typeof t == "number" ? { type: "number", value: t } : t.node;
|
|
6797
|
-
return new
|
|
6766
|
+
return new C({
|
|
6798
6767
|
type: "operation",
|
|
6799
6768
|
operation: "^",
|
|
6800
6769
|
left: this.node,
|
|
@@ -6802,7 +6771,7 @@ class P {
|
|
|
6802
6771
|
});
|
|
6803
6772
|
}
|
|
6804
6773
|
sqrt() {
|
|
6805
|
-
return new
|
|
6774
|
+
return new C({
|
|
6806
6775
|
type: "operation",
|
|
6807
6776
|
operation: "sqrt",
|
|
6808
6777
|
left: this.node
|
|
@@ -6860,7 +6829,7 @@ class P {
|
|
|
6860
6829
|
t.type === "variable" ? e.add(t.variable.id) : t.type === "operation" && (t.left && this.collectVariables(t.left, e), t.right && this.collectVariables(t.right, e));
|
|
6861
6830
|
}
|
|
6862
6831
|
clone() {
|
|
6863
|
-
return new
|
|
6832
|
+
return new C(this.cloneNode(this.node));
|
|
6864
6833
|
}
|
|
6865
6834
|
cloneNode(t) {
|
|
6866
6835
|
const e = { type: t.type };
|
|
@@ -6956,7 +6925,7 @@ class vt {
|
|
|
6956
6925
|
return this.operator === ">" ? e > i : e < i;
|
|
6957
6926
|
}
|
|
6958
6927
|
solve() {
|
|
6959
|
-
const t = typeof this.right == "number" ?
|
|
6928
|
+
const t = typeof this.right == "number" ? C.number(this.right) : this.right, e = this.left.getVariables(), i = t.getVariables(), r = [.../* @__PURE__ */ new Set([...e, ...i])];
|
|
6960
6929
|
if (r.length !== 1)
|
|
6961
6930
|
throw new Error("Can only solve inequalities with exactly one variable");
|
|
6962
6931
|
const s = r[0];
|
|
@@ -6991,7 +6960,7 @@ class Wt {
|
|
|
6991
6960
|
return Math.abs(e - i) < 1e-10;
|
|
6992
6961
|
}
|
|
6993
6962
|
solve() {
|
|
6994
|
-
const t = typeof this.right == "number" ?
|
|
6963
|
+
const t = typeof this.right == "number" ? C.number(this.right) : this.right, e = this.left.getVariables(), i = t.getVariables(), r = [.../* @__PURE__ */ new Set([...e, ...i])];
|
|
6995
6964
|
if (r.length !== 1)
|
|
6996
6965
|
throw new Error("Can only solve equations with exactly one variable");
|
|
6997
6966
|
const s = r[0];
|
|
@@ -7038,9 +7007,9 @@ class ki {
|
|
|
7038
7007
|
}
|
|
7039
7008
|
// TODO now 是不是应该用 dataDeps 动态注入???这样能手动测试。改成在哪里配置?
|
|
7040
7009
|
async compute(t) {
|
|
7041
|
-
const e = await this.args.callback(
|
|
7010
|
+
const e = await this.args.callback(C.variable("now"), t), i = Date.now();
|
|
7042
7011
|
let r, s;
|
|
7043
|
-
if (e instanceof
|
|
7012
|
+
if (e instanceof C)
|
|
7044
7013
|
r = e.evaluate({ now: i }), s = i + this.nextRecomputeTime(i, t);
|
|
7045
7014
|
else if (e instanceof vt || e instanceof Wt)
|
|
7046
7015
|
r = e.evaluate({ now: i }), s = e.solve();
|
|
@@ -7076,9 +7045,9 @@ class Si {
|
|
|
7076
7045
|
}
|
|
7077
7046
|
// TODO now 是不是应该用 dataDeps 动态注入???这样能手动测试。改成在哪里配置?
|
|
7078
7047
|
async compute(t, e) {
|
|
7079
|
-
const i = await this.args.callback(
|
|
7048
|
+
const i = await this.args.callback(C.variable("now"), t), r = Date.now();
|
|
7080
7049
|
let s, a;
|
|
7081
|
-
if (i instanceof
|
|
7050
|
+
if (i instanceof C)
|
|
7082
7051
|
s = i.evaluate({ now: r }), a = r + this.nextRecomputeTime(r, t);
|
|
7083
7052
|
else if (i instanceof vt || i instanceof Wt)
|
|
7084
7053
|
s = i.evaluate({ now: r }), a = i.solve();
|
|
@@ -7484,7 +7453,7 @@ class Fi extends At {
|
|
|
7484
7453
|
this.contextType = "relation";
|
|
7485
7454
|
}
|
|
7486
7455
|
}
|
|
7487
|
-
class
|
|
7456
|
+
class Vi extends At {
|
|
7488
7457
|
static {
|
|
7489
7458
|
this.contextType = "property";
|
|
7490
7459
|
}
|
|
@@ -7499,11 +7468,11 @@ If you want to use aggregated data from all records in the entity/relation, you
|
|
|
7499
7468
|
super(t, e, i);
|
|
7500
7469
|
}
|
|
7501
7470
|
}
|
|
7502
|
-
const
|
|
7471
|
+
const Qi = [
|
|
7503
7472
|
Oi,
|
|
7504
7473
|
Di,
|
|
7505
7474
|
Fi,
|
|
7506
|
-
|
|
7475
|
+
Vi
|
|
7507
7476
|
];
|
|
7508
7477
|
class W extends Error {
|
|
7509
7478
|
constructor(t, e = {}) {
|
|
@@ -7817,7 +7786,7 @@ class qi {
|
|
|
7817
7786
|
type: "json"
|
|
7818
7787
|
})
|
|
7819
7788
|
]
|
|
7820
|
-
}), y =
|
|
7789
|
+
}), y = M.create({
|
|
7821
7790
|
name: `${p.name}_${h.dataContext.host.name}_${h.dataContext.id.name}`,
|
|
7822
7791
|
source: p,
|
|
7823
7792
|
target: h.dataContext.host,
|
|
@@ -8332,7 +8301,7 @@ function oe(u) {
|
|
|
8332
8301
|
const t = Jt.getStore();
|
|
8333
8302
|
t?.effects && t.effects.push(...u);
|
|
8334
8303
|
}
|
|
8335
|
-
const
|
|
8304
|
+
const Sr = "User";
|
|
8336
8305
|
class ge {
|
|
8337
8306
|
constructor(t) {
|
|
8338
8307
|
this.name = t.name, this.record = t.record, this.content = t.content;
|
|
@@ -8341,7 +8310,7 @@ class ge {
|
|
|
8341
8310
|
return new ge(t);
|
|
8342
8311
|
}
|
|
8343
8312
|
}
|
|
8344
|
-
const $t = "_isDeleted_",
|
|
8313
|
+
const $t = "_isDeleted_", Er = {
|
|
8345
8314
|
create() {
|
|
8346
8315
|
return N.create({
|
|
8347
8316
|
name: $t,
|
|
@@ -8349,7 +8318,7 @@ const $t = "_isDeleted_", Mr = {
|
|
|
8349
8318
|
});
|
|
8350
8319
|
}
|
|
8351
8320
|
};
|
|
8352
|
-
class
|
|
8321
|
+
class Ir {
|
|
8353
8322
|
constructor(t) {
|
|
8354
8323
|
this.recordNameToSideEffects = /* @__PURE__ */ new Map(), this.globals = {
|
|
8355
8324
|
BoolExp: R,
|
|
@@ -8382,7 +8351,7 @@ class Pr {
|
|
|
8382
8351
|
...$i,
|
|
8383
8352
|
...Ei,
|
|
8384
8353
|
...ui,
|
|
8385
|
-
...
|
|
8354
|
+
...Qi,
|
|
8386
8355
|
...n
|
|
8387
8356
|
];
|
|
8388
8357
|
this.scheduler = new qi(this, this.entities, this.relations, this.dict, h), o.forEach((p) => {
|
|
@@ -8431,10 +8400,10 @@ class Pr {
|
|
|
8431
8400
|
async applyResultPatch(t, e, i) {
|
|
8432
8401
|
if (e instanceof Nt || e === void 0) return;
|
|
8433
8402
|
const r = Array.isArray(e) ? e : [e];
|
|
8434
|
-
for (const s of r)
|
|
8403
|
+
for (const s of r)
|
|
8435
8404
|
if (t.type === "global")
|
|
8436
|
-
|
|
8437
|
-
if (t.type === "entity" || t.type === "relation") {
|
|
8405
|
+
await this.system.storage.dict.set(t.id.name, s);
|
|
8406
|
+
else if (t.type === "entity" || t.type === "relation") {
|
|
8438
8407
|
const a = t;
|
|
8439
8408
|
if (s.type === "insert")
|
|
8440
8409
|
await this.system.storage.create(a.id.name, s.data);
|
|
@@ -8449,7 +8418,6 @@ class Pr {
|
|
|
8449
8418
|
const a = t;
|
|
8450
8419
|
a.id.name === $t && s.data ? (k(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", i.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: null });
|
|
8451
8420
|
}
|
|
8452
|
-
}
|
|
8453
8421
|
}
|
|
8454
8422
|
/**
|
|
8455
8423
|
* Unified dispatch API for all event source types.
|
|
@@ -8518,6 +8486,7 @@ class Pr {
|
|
|
8518
8486
|
addEventListener(t, e) {
|
|
8519
8487
|
this.callbacks.has(t) || this.callbacks.set(t, /* @__PURE__ */ new Set()), this.callbacks.get(t).add(e);
|
|
8520
8488
|
}
|
|
8489
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8521
8490
|
findEventSourceByName(t) {
|
|
8522
8491
|
return this.eventSourcesByName.get(t);
|
|
8523
8492
|
}
|
|
@@ -8537,18 +8506,18 @@ class Ji {
|
|
|
8537
8506
|
},
|
|
8538
8507
|
set: async (e, i) => {
|
|
8539
8508
|
const r = m.atom({ key: "key", value: ["=", e] }), s = await this.queryHandle.findOne(L, r, void 0, ["value"]);
|
|
8540
|
-
|
|
8509
|
+
s ? await this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [L, m.atom({ key: "id", value: ["=", s.id] }), { key: e, value: { raw: i } }], []) : await this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [L, { key: e, value: { raw: i } }], []);
|
|
8541
8510
|
}
|
|
8542
8511
|
};
|
|
8543
8512
|
}
|
|
8544
|
-
beginTransaction(t = "") {
|
|
8545
|
-
|
|
8513
|
+
async beginTransaction(t = "") {
|
|
8514
|
+
await (this.db.beginTransaction ? this.db.beginTransaction(t) : this.db.scheme("BEGIN", t));
|
|
8546
8515
|
}
|
|
8547
|
-
commitTransaction(t = "") {
|
|
8548
|
-
|
|
8516
|
+
async commitTransaction(t = "") {
|
|
8517
|
+
await (this.db.commitTransaction ? this.db.commitTransaction(t) : this.db.scheme("COMMIT", t));
|
|
8549
8518
|
}
|
|
8550
|
-
rollbackTransaction(t = "") {
|
|
8551
|
-
|
|
8519
|
+
async rollbackTransaction(t = "") {
|
|
8520
|
+
await (this.db.rollbackTransaction ? this.db.rollbackTransaction(t) : this.db.scheme("ROLLBACK", t));
|
|
8552
8521
|
}
|
|
8553
8522
|
// CAUTION kv 结构数据的实现也用 er。这是系统约定,因为也需要 Record 事件!
|
|
8554
8523
|
async get(t, e, i) {
|
|
@@ -8658,14 +8627,14 @@ class jt {
|
|
|
8658
8627
|
return new jt(this.level);
|
|
8659
8628
|
}
|
|
8660
8629
|
}
|
|
8661
|
-
const
|
|
8662
|
-
class
|
|
8630
|
+
const xr = new Ht(), Ui = new jt();
|
|
8631
|
+
class Mr {
|
|
8663
8632
|
constructor(t, e = Ui) {
|
|
8664
8633
|
this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new Ji(t);
|
|
8665
8634
|
}
|
|
8666
|
-
setup(t, e, i, r = !1) {
|
|
8635
|
+
async setup(t, e, i, r = !1) {
|
|
8667
8636
|
const s = new de(t, e), { entities: a, relations: o } = s.getAll();
|
|
8668
|
-
|
|
8637
|
+
i.forEach(({ dataContext: n, state: c }) => {
|
|
8669
8638
|
Object.entries(c).forEach(([l, d]) => {
|
|
8670
8639
|
if (d instanceof E) {
|
|
8671
8640
|
if (!d.record)
|
|
@@ -8689,17 +8658,17 @@ class $r {
|
|
|
8689
8658
|
}
|
|
8690
8659
|
}
|
|
8691
8660
|
});
|
|
8692
|
-
}), this.storage.setup(
|
|
8661
|
+
}), await this.storage.setup(
|
|
8693
8662
|
[...a, oi, ai],
|
|
8694
8663
|
o,
|
|
8695
8664
|
r
|
|
8696
8665
|
);
|
|
8697
8666
|
}
|
|
8698
|
-
destroy() {
|
|
8699
|
-
this.storage.destroy();
|
|
8667
|
+
async destroy() {
|
|
8668
|
+
await this.storage.destroy();
|
|
8700
8669
|
}
|
|
8701
8670
|
}
|
|
8702
|
-
const
|
|
8671
|
+
const Pr = new ne();
|
|
8703
8672
|
class kt {
|
|
8704
8673
|
constructor(t, e) {
|
|
8705
8674
|
this._type = "Action", this._options = e, this.uuid = T(e), this.name = t.name;
|
|
@@ -8888,8 +8857,8 @@ class z {
|
|
|
8888
8857
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
8889
8858
|
}
|
|
8890
8859
|
static parse(t) {
|
|
8891
|
-
const e = JSON.parse(t), i = e.public;
|
|
8892
|
-
return
|
|
8860
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
8861
|
+
return typeof r.content == "string" && r.content.startsWith("func::") && (i.content = new Function("return " + r.content.substring(6))()), this.create(i, e.options);
|
|
8893
8862
|
}
|
|
8894
8863
|
}
|
|
8895
8864
|
class bt {
|
|
@@ -8961,7 +8930,7 @@ function Dt(u) {
|
|
|
8961
8930
|
right: Dt(u.right)
|
|
8962
8931
|
});
|
|
8963
8932
|
}
|
|
8964
|
-
function
|
|
8933
|
+
function Cr(u) {
|
|
8965
8934
|
return bt.create({
|
|
8966
8935
|
content: Dt(u)
|
|
8967
8936
|
});
|
|
@@ -9200,12 +9169,12 @@ async function tt(u, t) {
|
|
|
9200
9169
|
if (t.for) {
|
|
9201
9170
|
for (const e of t.for)
|
|
9202
9171
|
if (await tt(u, e) === !0) return !0;
|
|
9203
|
-
return { name: t.name, type: "conceptAlias", error: "no match" };
|
|
9172
|
+
return { name: t.name || "", type: "conceptAlias", error: "no match" };
|
|
9204
9173
|
}
|
|
9205
9174
|
return z.is(t) ? !0 : I.is(t) ? u && typeof u == "object" ? !0 : { name: t.name || "", type: "conceptCheck", error: "invalid entity data" } : !0;
|
|
9206
9175
|
}
|
|
9207
9176
|
async function er(u, t, e) {
|
|
9208
|
-
if (I.is(t.data) ||
|
|
9177
|
+
if (I.is(t.data) || M.is(t.data)) {
|
|
9209
9178
|
const i = t.data.name, r = t.dataPolicy?.match, s = t.dataPolicy?.modifier, a = { ...e.query?.modifier || {}, ...s || {} }, o = e.query?.attributeQuery || [], n = typeof r == "function" ? await r.call(u, e) : r, c = R.and(n, e.query?.match);
|
|
9210
9179
|
return u.system.storage.find(i, c, a, o);
|
|
9211
9180
|
}
|
|
@@ -9433,11 +9402,11 @@ function Ne(u, t, e) {
|
|
|
9433
9402
|
i.activities?.forEach((r) => Ne(r, t, i));
|
|
9434
9403
|
});
|
|
9435
9404
|
}
|
|
9436
|
-
function
|
|
9405
|
+
function $r(u) {
|
|
9437
9406
|
const t = [];
|
|
9438
9407
|
return Ne(u, (e) => t.push(e)), t;
|
|
9439
9408
|
}
|
|
9440
|
-
function
|
|
9409
|
+
function Or(u) {
|
|
9441
9410
|
return null;
|
|
9442
9411
|
}
|
|
9443
9412
|
class Xt {
|
|
@@ -9496,8 +9465,8 @@ class Xt {
|
|
|
9496
9465
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
9497
9466
|
}
|
|
9498
9467
|
static parse(t) {
|
|
9499
|
-
const e = JSON.parse(t), i = e.public;
|
|
9500
|
-
return
|
|
9468
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
9469
|
+
return typeof r.content == "string" && r.content.startsWith("func::") && (i.content = new Function("return " + r.content.substring(6))()), this.create(i, e.options);
|
|
9501
9470
|
}
|
|
9502
9471
|
}
|
|
9503
9472
|
class zt {
|
|
@@ -9556,8 +9525,8 @@ class zt {
|
|
|
9556
9525
|
return t !== null && typeof t == "object" && typeof t.uuid == "string";
|
|
9557
9526
|
}
|
|
9558
9527
|
static parse(t) {
|
|
9559
|
-
const e = JSON.parse(t), i = e.public;
|
|
9560
|
-
return
|
|
9528
|
+
const e = JSON.parse(t), i = e.public, r = i;
|
|
9529
|
+
return typeof r.content == "string" && r.content.startsWith("func::") && (i.content = new Function("return " + r.content.substring(6))()), this.create(i, e.options);
|
|
9561
9530
|
}
|
|
9562
9531
|
}
|
|
9563
9532
|
class ve {
|
|
@@ -9949,7 +9918,7 @@ const ir = [
|
|
|
9949
9918
|
ir.forEach((u) => {
|
|
9950
9919
|
u && u.displayName && ue(u.displayName, u);
|
|
9951
9920
|
});
|
|
9952
|
-
function
|
|
9921
|
+
function Dr({ name: u, isRef: t = !1 }, e) {
|
|
9953
9922
|
return z.create({
|
|
9954
9923
|
name: u,
|
|
9955
9924
|
content: u ? new Function("user", `return user.roles.includes('${u}')`) : function() {
|
|
@@ -10226,7 +10195,7 @@ const cr = "_Activity_", Te = I.create({
|
|
|
10226
10195
|
collection: !1
|
|
10227
10196
|
})
|
|
10228
10197
|
]
|
|
10229
|
-
}), lr =
|
|
10198
|
+
}), lr = M.create({
|
|
10230
10199
|
name: "activityInteraction",
|
|
10231
10200
|
source: Te,
|
|
10232
10201
|
sourceProperty: "interaction",
|
|
@@ -10234,7 +10203,7 @@ const cr = "_Activity_", Te = I.create({
|
|
|
10234
10203
|
targetProperty: "activity",
|
|
10235
10204
|
type: "1:n"
|
|
10236
10205
|
});
|
|
10237
|
-
class
|
|
10206
|
+
class Fr {
|
|
10238
10207
|
constructor(t) {
|
|
10239
10208
|
this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.activityEventSources = [], this.requiredEntities = [], this.requiredRelations = [], t.length > 0 && (this.requiredEntities.push(Te, Ut), this.requiredRelations.push(lr)), t.forEach((e) => {
|
|
10240
10209
|
const i = new et(e);
|
|
@@ -10311,7 +10280,7 @@ class Lr {
|
|
|
10311
10280
|
return this.activityCallsByName.get(t);
|
|
10312
10281
|
}
|
|
10313
10282
|
}
|
|
10314
|
-
class
|
|
10283
|
+
class Vr extends W {
|
|
10315
10284
|
constructor(t, e = {}) {
|
|
10316
10285
|
super(t, {
|
|
10317
10286
|
errorType: e.context?.errorType || "InteractionExecutionError",
|
|
@@ -10343,7 +10312,7 @@ class ur extends W {
|
|
|
10343
10312
|
}), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || $.MEDIUM;
|
|
10344
10313
|
}
|
|
10345
10314
|
}
|
|
10346
|
-
class
|
|
10315
|
+
class Qr extends ur {
|
|
10347
10316
|
constructor(t, e = {}) {
|
|
10348
10317
|
super(t, {
|
|
10349
10318
|
...e,
|
|
@@ -10367,9 +10336,9 @@ export {
|
|
|
10367
10336
|
ur as ActivityError,
|
|
10368
10337
|
st as ActivityGroup,
|
|
10369
10338
|
lr as ActivityInteractionRelation,
|
|
10370
|
-
|
|
10339
|
+
Fr as ActivityManager,
|
|
10371
10340
|
Te as ActivityStateEntity,
|
|
10372
|
-
|
|
10341
|
+
Qr as ActivityStateError,
|
|
10373
10342
|
ri as AliasManager,
|
|
10374
10343
|
ht as Any,
|
|
10375
10344
|
Ri as AnyHandles,
|
|
@@ -10379,7 +10348,6 @@ export {
|
|
|
10379
10348
|
bt as Attributives,
|
|
10380
10349
|
ut as Average,
|
|
10381
10350
|
$i as AverageHandles,
|
|
10382
|
-
br as BaseKlass,
|
|
10383
10351
|
ft as BoolAtomData,
|
|
10384
10352
|
R as BoolExp,
|
|
10385
10353
|
mt as BoolExpressionData,
|
|
@@ -10394,21 +10362,21 @@ export {
|
|
|
10394
10362
|
Xt as Condition,
|
|
10395
10363
|
U as ConditionError,
|
|
10396
10364
|
St as Conditions,
|
|
10397
|
-
|
|
10365
|
+
Ir as Controller,
|
|
10398
10366
|
ct as Count,
|
|
10399
10367
|
vi as CountHandles,
|
|
10400
10368
|
Oe as CreationExecutor,
|
|
10401
10369
|
Bt as Custom,
|
|
10402
|
-
|
|
10370
|
+
Qi as CustomHandles,
|
|
10403
10371
|
Ht as DBConsoleLogger,
|
|
10404
10372
|
Hi as DBLogLevel,
|
|
10405
10373
|
si as DBSetup,
|
|
10406
|
-
|
|
10374
|
+
kr as DELETED_STATE,
|
|
10407
10375
|
L as DICTIONARY_RECORD,
|
|
10408
10376
|
zt as DataAttributive,
|
|
10409
10377
|
ee as DataAttributives,
|
|
10410
10378
|
ve as DataPolicy,
|
|
10411
|
-
|
|
10379
|
+
Qt as Dictionary,
|
|
10412
10380
|
oi as DictionaryEntity,
|
|
10413
10381
|
I as Entity,
|
|
10414
10382
|
Di as EntityCustomHandle,
|
|
@@ -10421,7 +10389,7 @@ export {
|
|
|
10421
10389
|
he as EventSource,
|
|
10422
10390
|
dt as Every,
|
|
10423
10391
|
yi as EveryHandles,
|
|
10424
|
-
|
|
10392
|
+
C as Expression,
|
|
10425
10393
|
W as FrameworkError,
|
|
10426
10394
|
at as Gateway,
|
|
10427
10395
|
Gi as GetAction,
|
|
@@ -10436,25 +10404,25 @@ export {
|
|
|
10436
10404
|
Ii as GlobalSumHandle,
|
|
10437
10405
|
di as GlobalWeightedSummationHandle,
|
|
10438
10406
|
$t as HARD_DELETION_PROPERTY_NAME,
|
|
10439
|
-
|
|
10407
|
+
Er as HardDeletionProperty,
|
|
10440
10408
|
re as ID_ATTR,
|
|
10441
10409
|
Ki as INTERACTION_RECORD,
|
|
10442
10410
|
vt as Inequality,
|
|
10443
10411
|
Gt as Interaction,
|
|
10444
10412
|
Ut as InteractionEventEntity,
|
|
10445
|
-
|
|
10413
|
+
Vr as InteractionExecutionError,
|
|
10446
10414
|
q as InteractionGuardError,
|
|
10447
10415
|
Ft as KlassByName,
|
|
10448
10416
|
f as LINK_SYMBOL,
|
|
10449
10417
|
wt as LinkInfo,
|
|
10450
10418
|
m as MatchExp,
|
|
10451
10419
|
Pe as Modifier,
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10420
|
+
Mr as MonoSystem,
|
|
10421
|
+
Ar as NON_DELETED_STATE,
|
|
10422
|
+
Tr as NON_EXIST_STATE,
|
|
10423
|
+
V as NewRecordData,
|
|
10424
|
+
gr as PHASE_AFTER_ALL,
|
|
10425
|
+
yr as PHASE_BEFORE_ALL,
|
|
10458
10426
|
It as PHASE_NORMAL,
|
|
10459
10427
|
te as Payload,
|
|
10460
10428
|
Zt as PayloadItem,
|
|
@@ -10462,12 +10430,12 @@ export {
|
|
|
10462
10430
|
bi as PropertyAnyHandle,
|
|
10463
10431
|
Ci as PropertyAverageHandle,
|
|
10464
10432
|
Ni as PropertyCountHandle,
|
|
10465
|
-
|
|
10433
|
+
Vi as PropertyCustomHandle,
|
|
10466
10434
|
mi as PropertyEveryHandle,
|
|
10467
10435
|
Si as PropertyRealTimeComputation,
|
|
10468
10436
|
li as PropertyStateMachineHandle,
|
|
10469
10437
|
xi as PropertySumHandle,
|
|
10470
|
-
|
|
10438
|
+
Vt as PropertyTypes,
|
|
10471
10439
|
hi as PropertyWeightedSummationHandle,
|
|
10472
10440
|
Le as QueryExecutor,
|
|
10473
10441
|
_t as ROOT_LABEL,
|
|
@@ -10477,16 +10445,16 @@ export {
|
|
|
10477
10445
|
E as RecordBoundState,
|
|
10478
10446
|
rt as RecordInfo,
|
|
10479
10447
|
ge as RecordMutationSideEffect,
|
|
10480
|
-
|
|
10448
|
+
P as RecordQuery,
|
|
10481
10449
|
_e as RecordQueryAgent,
|
|
10482
|
-
|
|
10483
|
-
|
|
10450
|
+
Qe as RecordQueryRef,
|
|
10451
|
+
Q as RecordQueryTree,
|
|
10484
10452
|
Ti as RecordsTransformHandle,
|
|
10485
10453
|
it as RecursiveContext,
|
|
10486
10454
|
de as RefContainer,
|
|
10487
|
-
|
|
10455
|
+
M as Relation,
|
|
10488
10456
|
Fi as RelationCustomHandle,
|
|
10489
|
-
|
|
10457
|
+
Ve as SQLBuilder,
|
|
10490
10458
|
Z as SYSTEM_RECORD,
|
|
10491
10459
|
qi as Scheduler,
|
|
10492
10460
|
qt as SideEffect,
|
|
@@ -10502,39 +10470,37 @@ export {
|
|
|
10502
10470
|
we as Transfer,
|
|
10503
10471
|
Tt as Transform,
|
|
10504
10472
|
Ai as TransformHandles,
|
|
10505
|
-
|
|
10473
|
+
Sr as USER_ENTITY,
|
|
10506
10474
|
nt as WeightedSummation,
|
|
10507
10475
|
pi as WeightedSummationHandles,
|
|
10508
10476
|
oe as addToCurrentEffects,
|
|
10509
10477
|
k as assert,
|
|
10510
10478
|
Jt as asyncEffectsContext,
|
|
10511
|
-
|
|
10512
|
-
|
|
10479
|
+
Pr as asyncInteractionContext,
|
|
10480
|
+
Cr as boolExpToAttributives,
|
|
10513
10481
|
be as checkCondition,
|
|
10514
10482
|
Re as checkPayload,
|
|
10515
10483
|
pr as clearAllInstances,
|
|
10516
|
-
gr as createClass,
|
|
10517
10484
|
ke as createInstances,
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10485
|
+
mr as createInstancesFromString,
|
|
10486
|
+
Dr as createUserRoleAttributive,
|
|
10487
|
+
xr as dbConsoleLogger,
|
|
10521
10488
|
Rt as deepClone,
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10489
|
+
wr as everyAsync,
|
|
10490
|
+
vr as everyWithErrorAsync,
|
|
10491
|
+
br as filterMap,
|
|
10492
|
+
Or as findRootActivity,
|
|
10526
10493
|
Ne as forEachInteraction,
|
|
10527
10494
|
T as generateUUID,
|
|
10528
10495
|
Bi as getCurrentEffects,
|
|
10529
|
-
|
|
10496
|
+
$r as getInteractions,
|
|
10530
10497
|
hr as indexBy,
|
|
10531
10498
|
ce as isObject,
|
|
10532
10499
|
le as isPlainObject,
|
|
10533
|
-
|
|
10500
|
+
Rr as mapObject,
|
|
10534
10501
|
ue as registerKlass,
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
mr as stringifyAllInstances,
|
|
10502
|
+
Nr as someAsync,
|
|
10503
|
+
fr as stringifyAllInstances,
|
|
10538
10504
|
w as stringifyAttribute,
|
|
10539
10505
|
Ui as systemConsoleLogger
|
|
10540
10506
|
};
|