interaqt 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +78 -44
- package/dist/index.js.map +1 -1
- package/dist/runtime/activity/InteractionCall.d.ts.map +1 -1
- package/dist/shared/BoolExp.d.ts +2 -0
- package/dist/shared/BoolExp.d.ts.map +1 -1
- package/dist/storage/erstorage/MatchExp.d.ts +12 -0
- package/dist/storage/erstorage/MatchExp.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,13 +40,13 @@ function wi(...u) {
|
|
|
40
40
|
}
|
|
41
41
|
function Ni() {
|
|
42
42
|
}
|
|
43
|
-
const
|
|
43
|
+
const qt = /* @__PURE__ */ new Map();
|
|
44
44
|
function Oe(u, t) {
|
|
45
|
-
t && t.isKlass && t.displayName &&
|
|
45
|
+
t && t.isKlass && t.displayName && qt.set(u, t);
|
|
46
46
|
}
|
|
47
47
|
function Ti() {
|
|
48
48
|
const u = [];
|
|
49
|
-
return Array.from(
|
|
49
|
+
return Array.from(qt.entries()).forEach(([, t]) => {
|
|
50
50
|
t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
|
|
51
51
|
}), `[${u.join(",")}]`;
|
|
52
52
|
}
|
|
@@ -57,7 +57,7 @@ function Si(u) {
|
|
|
57
57
|
function Fe(u) {
|
|
58
58
|
const t = /* @__PURE__ */ new Map();
|
|
59
59
|
return u.forEach(({ type: e, options: r = {}, uuid: i, public: s }) => {
|
|
60
|
-
const a =
|
|
60
|
+
const a = qt.get(e);
|
|
61
61
|
if (!a) {
|
|
62
62
|
console.warn(`Class ${e} not found in KlassByName`);
|
|
63
63
|
return;
|
|
@@ -196,7 +196,7 @@ class C {
|
|
|
196
196
|
return this.create(e.public, e.options);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
var
|
|
199
|
+
var _t = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(_t || {});
|
|
200
200
|
const Ve = /^[a-zA-Z0-9_]+$/;
|
|
201
201
|
class Bt {
|
|
202
202
|
constructor(t, e) {
|
|
@@ -226,7 +226,7 @@ class Bt {
|
|
|
226
226
|
type: "string",
|
|
227
227
|
required: !0,
|
|
228
228
|
collection: !1,
|
|
229
|
-
options: Array.from(Object.values(
|
|
229
|
+
options: Array.from(Object.values(_t))
|
|
230
230
|
},
|
|
231
231
|
collection: {
|
|
232
232
|
type: "boolean",
|
|
@@ -318,7 +318,7 @@ class T {
|
|
|
318
318
|
type: {
|
|
319
319
|
type: "string",
|
|
320
320
|
required: !0,
|
|
321
|
-
options: () => Object.values(
|
|
321
|
+
options: () => Object.values(_t)
|
|
322
322
|
},
|
|
323
323
|
collection: {
|
|
324
324
|
type: "boolean",
|
|
@@ -1063,6 +1063,12 @@ class R {
|
|
|
1063
1063
|
static fromValue(t) {
|
|
1064
1064
|
return new R(t);
|
|
1065
1065
|
}
|
|
1066
|
+
toJSON() {
|
|
1067
|
+
return this.raw;
|
|
1068
|
+
}
|
|
1069
|
+
static fromJSON(t) {
|
|
1070
|
+
return new R(t);
|
|
1071
|
+
}
|
|
1066
1072
|
isExpression() {
|
|
1067
1073
|
return this.raw.type === "expression";
|
|
1068
1074
|
}
|
|
@@ -1161,19 +1167,19 @@ class R {
|
|
|
1161
1167
|
throw new Error(`invalid bool expression type: ${JSON.stringify(this.raw)}`);
|
|
1162
1168
|
}
|
|
1163
1169
|
}
|
|
1164
|
-
const
|
|
1170
|
+
const qe = {
|
|
1165
1171
|
"&&": "and",
|
|
1166
1172
|
"||": "or",
|
|
1167
1173
|
"!": "not"
|
|
1168
1174
|
};
|
|
1169
|
-
function
|
|
1175
|
+
function _e(u) {
|
|
1170
1176
|
return { key: u };
|
|
1171
1177
|
}
|
|
1172
1178
|
function Nt(u, t, e) {
|
|
1173
1179
|
if (u.type === "LogicalExpression")
|
|
1174
1180
|
return {
|
|
1175
1181
|
type: "expression",
|
|
1176
|
-
operator:
|
|
1182
|
+
operator: qe[u.operator],
|
|
1177
1183
|
left: Nt(u.left, t, e),
|
|
1178
1184
|
right: Nt(u.right, t, e)
|
|
1179
1185
|
};
|
|
@@ -1190,7 +1196,7 @@ function Nt(u, t, e) {
|
|
|
1190
1196
|
};
|
|
1191
1197
|
throw new Error("unknown ast node type");
|
|
1192
1198
|
}
|
|
1193
|
-
function Ii(u, t = [], e =
|
|
1199
|
+
function Ii(u, t = [], e = _e) {
|
|
1194
1200
|
const r = De(t, "name"), i = xe(u, { ecmaVersion: 2020 });
|
|
1195
1201
|
return new R(
|
|
1196
1202
|
Nt(i.body[0].expression, r, e)
|
|
@@ -3416,7 +3422,7 @@ class m {
|
|
|
3416
3422
|
const a = this.map.getRecordInfo(t);
|
|
3417
3423
|
this.entityName = a.isFilteredEntity || a.isFilteredRelation ? a.baseRecordName : t;
|
|
3418
3424
|
const o = a.isFilteredEntity || a.isFilteredRelation;
|
|
3419
|
-
this.xToOneQueryTree = new
|
|
3425
|
+
this.xToOneQueryTree = new q(this.entityName, this.map);
|
|
3420
3426
|
let n = r;
|
|
3421
3427
|
o && (n = r ? a.matchExpression.and(r) : a.matchExpression), n && (this.data = this.convertFilteredRelation(n), this.buildQueryTree(this.data, this.xToOneQueryTree));
|
|
3422
3428
|
}
|
|
@@ -3603,6 +3609,34 @@ class m {
|
|
|
3603
3609
|
}, a = this.data ? s(this.data) : void 0;
|
|
3604
3610
|
return new m(r, this.map, a, this.contextRootEntity, this.fromRelation);
|
|
3605
3611
|
}
|
|
3612
|
+
/**
|
|
3613
|
+
* 将 MatchExp 实例序列化为 JSON 格式
|
|
3614
|
+
* @returns JSON 可序列化的对象
|
|
3615
|
+
*/
|
|
3616
|
+
toJSON() {
|
|
3617
|
+
return {
|
|
3618
|
+
entityName: this.entityName,
|
|
3619
|
+
data: this.data ? this.data.raw : void 0,
|
|
3620
|
+
contextRootEntity: this.contextRootEntity,
|
|
3621
|
+
fromRelation: this.fromRelation
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
/**
|
|
3625
|
+
* 从 JSON 对象创建 MatchExp 实例
|
|
3626
|
+
* @param json JSON 对象
|
|
3627
|
+
* @param map EntityToTableMap 实例
|
|
3628
|
+
* @returns MatchExp 实例
|
|
3629
|
+
*/
|
|
3630
|
+
static fromJSON(t, e) {
|
|
3631
|
+
const r = t.data ? R.fromValue(t.data) : void 0;
|
|
3632
|
+
return new m(
|
|
3633
|
+
t.entityName,
|
|
3634
|
+
e,
|
|
3635
|
+
r,
|
|
3636
|
+
t.contextRootEntity,
|
|
3637
|
+
t.fromRelation
|
|
3638
|
+
);
|
|
3639
|
+
}
|
|
3606
3640
|
}
|
|
3607
3641
|
class Je {
|
|
3608
3642
|
constructor(t, e, r, i) {
|
|
@@ -3679,7 +3713,7 @@ class M {
|
|
|
3679
3713
|
);
|
|
3680
3714
|
}
|
|
3681
3715
|
}
|
|
3682
|
-
class
|
|
3716
|
+
class q {
|
|
3683
3717
|
// 父节点和自己这个几点 link 上的 query
|
|
3684
3718
|
constructor(t, e, r, i, s, a, o) {
|
|
3685
3719
|
this.recordName = t, this.map = e, this.parentRecord = r, this.attributeName = i, this.data = s, this.parent = a, this.parentLinkQueryTree = o, this.fields = [], g(!!t, "recordName cannot be empty"), this.fields = s?.fields || [], this.records = s?.records || {}, r && (this.info = this.map.getInfo(this.parentRecord, this.attributeName));
|
|
@@ -3689,26 +3723,26 @@ class _ {
|
|
|
3689
3723
|
if (t.length === 1)
|
|
3690
3724
|
this.fields.push(e);
|
|
3691
3725
|
else if (e === f)
|
|
3692
|
-
this.parentLinkQueryTree || (this.parentLinkQueryTree = new
|
|
3726
|
+
this.parentLinkQueryTree || (this.parentLinkQueryTree = new q(this.info.linkName, this.map)), this.parentLinkQueryTree.addField(r);
|
|
3693
3727
|
else {
|
|
3694
3728
|
const i = this.map.getInfo(this.recordName, e);
|
|
3695
|
-
this.records[e] || (this.records[e] = new
|
|
3729
|
+
this.records[e] || (this.records[e] = new q(i.recordName, this.map, this.recordName, e, void 0, this)), this.records[e].addField(r);
|
|
3696
3730
|
}
|
|
3697
3731
|
}
|
|
3698
3732
|
addRecord(t, e) {
|
|
3699
3733
|
const [r, ...i] = t;
|
|
3700
3734
|
if (t.length === 1)
|
|
3701
3735
|
if (r === f)
|
|
3702
|
-
this.parentLinkQueryTree || (this.parentLinkQueryTree = new
|
|
3736
|
+
this.parentLinkQueryTree || (this.parentLinkQueryTree = new q(this.info.linkName, this.map)), e && (this.parentLinkQueryTree = this.parentLinkQueryTree.merge(e));
|
|
3703
3737
|
else {
|
|
3704
|
-
const s = this.map.getInfo(this.recordName, r), a = e || new
|
|
3738
|
+
const s = this.map.getInfo(this.recordName, r), a = e || new q(s.recordName, this.map, this.recordName, r, void 0, this);
|
|
3705
3739
|
this.records[r] = this.records[r] ? this.records[r].merge(a) : a;
|
|
3706
3740
|
}
|
|
3707
3741
|
else if (r === f)
|
|
3708
|
-
this.parentLinkQueryTree || (this.parentLinkQueryTree = new
|
|
3742
|
+
this.parentLinkQueryTree || (this.parentLinkQueryTree = new q(this.info.linkName, this.map)), this.parentLinkQueryTree.addRecord(i, e);
|
|
3709
3743
|
else {
|
|
3710
3744
|
const s = this.map.getInfo(this.recordName, r);
|
|
3711
|
-
this.records[r] = new
|
|
3745
|
+
this.records[r] = new q(s.recordName, this.map, this.recordName, r, void 0, this), this.records[r].addRecord(i, e);
|
|
3712
3746
|
}
|
|
3713
3747
|
}
|
|
3714
3748
|
forEachRecords(t) {
|
|
@@ -3723,7 +3757,7 @@ class _ {
|
|
|
3723
3757
|
this.records[a] && t.records[a] ? i[a] = this.records[a].merge(t.records[a]) : this.records[a] ? i[a] = this.records[a] : i[a] = t.records[a];
|
|
3724
3758
|
});
|
|
3725
3759
|
let s;
|
|
3726
|
-
return this.parentLinkQueryTree && t.parentLinkQueryTree ? s = this.parentLinkQueryTree.merge(t.parentLinkQueryTree) : s = this.parentLinkQueryTree || t.parentLinkQueryTree, new
|
|
3760
|
+
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: i }, this.parent, s);
|
|
3727
3761
|
}
|
|
3728
3762
|
getData() {
|
|
3729
3763
|
const t = {
|
|
@@ -3856,7 +3890,7 @@ class x {
|
|
|
3856
3890
|
return this.buildXToOneQueryTree();
|
|
3857
3891
|
}
|
|
3858
3892
|
buildXToOneQueryTree() {
|
|
3859
|
-
const t = new
|
|
3893
|
+
const t = new q(this.recordName, this.map, this.parentRecord, this.attributeName);
|
|
3860
3894
|
if (this.data.forEach((e) => {
|
|
3861
3895
|
Array.isArray(e) || t.addField([e]);
|
|
3862
3896
|
}), this.xToOneRecords.forEach((e) => {
|
|
@@ -3868,7 +3902,7 @@ class x {
|
|
|
3868
3902
|
return t;
|
|
3869
3903
|
}
|
|
3870
3904
|
buildFullQueryTree() {
|
|
3871
|
-
const t = new
|
|
3905
|
+
const t = new q(this.recordName, this.map, this.parentRecord, this.attributeName);
|
|
3872
3906
|
return this.relatedRecords.forEach((e) => {
|
|
3873
3907
|
t.addRecord([e.attributeName], e.attributeQuery.fullQueryTree);
|
|
3874
3908
|
}), t;
|
|
@@ -7737,12 +7771,12 @@ class $t {
|
|
|
7737
7771
|
return A.skip();
|
|
7738
7772
|
}
|
|
7739
7773
|
}
|
|
7740
|
-
class
|
|
7774
|
+
class qr extends $t {
|
|
7741
7775
|
static {
|
|
7742
7776
|
this.contextType = "global";
|
|
7743
7777
|
}
|
|
7744
7778
|
}
|
|
7745
|
-
class
|
|
7779
|
+
class _r extends $t {
|
|
7746
7780
|
static {
|
|
7747
7781
|
this.contextType = "entity";
|
|
7748
7782
|
}
|
|
@@ -7768,8 +7802,8 @@ If you want to use aggregated data from all records in the entity/relation, you
|
|
|
7768
7802
|
}
|
|
7769
7803
|
}
|
|
7770
7804
|
const Jr = [
|
|
7771
|
-
_r,
|
|
7772
7805
|
qr,
|
|
7806
|
+
_r,
|
|
7773
7807
|
Br,
|
|
7774
7808
|
Wr
|
|
7775
7809
|
];
|
|
@@ -8056,7 +8090,7 @@ class O extends H {
|
|
|
8056
8090
|
});
|
|
8057
8091
|
}
|
|
8058
8092
|
}
|
|
8059
|
-
const tt = "_System_",
|
|
8093
|
+
const tt = "_System_", _ = "_Dictionary_", et = "id", ot = "_rowId", jr = C.create({
|
|
8060
8094
|
name: tt,
|
|
8061
8095
|
properties: [
|
|
8062
8096
|
T.create({
|
|
@@ -8076,7 +8110,7 @@ const tt = "_System_", q = "_Dictionary_", et = "id", ot = "_rowId", jr = C.crea
|
|
|
8076
8110
|
})
|
|
8077
8111
|
]
|
|
8078
8112
|
}), Hr = C.create({
|
|
8079
|
-
name:
|
|
8113
|
+
name: _,
|
|
8080
8114
|
properties: [
|
|
8081
8115
|
T.create({
|
|
8082
8116
|
name: "key",
|
|
@@ -8151,7 +8185,7 @@ class Ur {
|
|
|
8151
8185
|
* @returns 是否需要触发计算
|
|
8152
8186
|
*/
|
|
8153
8187
|
shouldTriggerUpdateComputation(t, e) {
|
|
8154
|
-
return t.type !== "update" || !("dataDep" in t) ? !0 : t.dataDep.type === "global" && e.recordName ===
|
|
8188
|
+
return t.type !== "update" || !("dataDep" in t) ? !0 : t.dataDep.type === "global" && e.recordName === _ ? e.record?.key === t.dataDep.source.name : !t.attributes.filter((i) => i !== "id").every(
|
|
8155
8189
|
(i) => !e.record.hasOwnProperty(i) || e.record[i] === e.oldRecord[i]
|
|
8156
8190
|
);
|
|
8157
8191
|
}
|
|
@@ -8178,15 +8212,15 @@ class Ur {
|
|
|
8178
8212
|
} else e.type === "global" && ((!i || i === "update") && a.push({
|
|
8179
8213
|
dataDep: e,
|
|
8180
8214
|
type: "update",
|
|
8181
|
-
recordName:
|
|
8182
|
-
sourceRecordName:
|
|
8215
|
+
recordName: _,
|
|
8216
|
+
sourceRecordName: _,
|
|
8183
8217
|
attributes: ["value"],
|
|
8184
8218
|
computation: r
|
|
8185
8219
|
}), (!i || i === "create") && a.push({
|
|
8186
8220
|
dataDep: e,
|
|
8187
8221
|
type: "create",
|
|
8188
|
-
recordName:
|
|
8189
|
-
sourceRecordName:
|
|
8222
|
+
recordName: _,
|
|
8223
|
+
sourceRecordName: _,
|
|
8190
8224
|
computation: r
|
|
8191
8225
|
}));
|
|
8192
8226
|
return a;
|
|
@@ -8515,7 +8549,7 @@ class Gr {
|
|
|
8515
8549
|
}
|
|
8516
8550
|
async computeDataBasedDirtyRecordsAndEvents(t, e) {
|
|
8517
8551
|
let r = [];
|
|
8518
|
-
if (t.dataDep.type === "global" && e.recordName ===
|
|
8552
|
+
if (t.dataDep.type === "global" && e.recordName === _)
|
|
8519
8553
|
if (t.computation.dataContext.type === "property") {
|
|
8520
8554
|
const i = t.computation.dataContext;
|
|
8521
8555
|
r = (await this.controller.system.storage.find(i.host.name, m.atom({ key: "id", value: ["not", null] }), {}, ["*"])).map((a) => [a, {
|
|
@@ -9809,11 +9843,11 @@ class oi {
|
|
|
9809
9843
|
this.db = t, this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
|
|
9810
9844
|
get: async (e) => {
|
|
9811
9845
|
const r = m.atom({ key: "key", value: ["=", e] });
|
|
9812
|
-
return (await this.queryHandle.findOne(
|
|
9846
|
+
return (await this.queryHandle.findOne(_, r, void 0, ["value"]))?.value?.raw;
|
|
9813
9847
|
},
|
|
9814
9848
|
set: async (e, r) => {
|
|
9815
|
-
const i = m.atom({ key: "key", value: ["=", e] }), s = await this.queryHandle.findOne(
|
|
9816
|
-
return s ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [
|
|
9849
|
+
const i = m.atom({ key: "key", value: ["=", e] }), s = await this.queryHandle.findOne(_, i, void 0, ["value"]);
|
|
9850
|
+
return s ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [_, m.atom({ key: "id", value: ["=", s.id] }), { key: e, value: { raw: r } }], []) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [_, { key: e, value: { raw: r } }], []);
|
|
9817
9851
|
}
|
|
9818
9852
|
};
|
|
9819
9853
|
}
|
|
@@ -9935,7 +9969,7 @@ class re {
|
|
|
9935
9969
|
}
|
|
9936
9970
|
}
|
|
9937
9971
|
const Rt = new ee(), li = new re();
|
|
9938
|
-
class
|
|
9972
|
+
class _i {
|
|
9939
9973
|
constructor(t = new ii(void 0, { logger: Rt }), e = li) {
|
|
9940
9974
|
this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new oi(t);
|
|
9941
9975
|
}
|
|
@@ -10332,13 +10366,13 @@ export {
|
|
|
10332
10366
|
ni as DBLogLevel,
|
|
10333
10367
|
dr as DBSetup,
|
|
10334
10368
|
Fi as DELETED_STATE,
|
|
10335
|
-
|
|
10369
|
+
_ as DICTIONARY_RECORD,
|
|
10336
10370
|
Ht as DataAttributive,
|
|
10337
10371
|
zt as DataAttributives,
|
|
10338
10372
|
Bt as Dictionary,
|
|
10339
10373
|
Hr as DictionaryEntity,
|
|
10340
10374
|
C as Entity,
|
|
10341
|
-
|
|
10375
|
+
_r as EntityCustomHandle,
|
|
10342
10376
|
Ye as EntityQueryHandle,
|
|
10343
10377
|
ze as EntityToTableMap,
|
|
10344
10378
|
te as Equation,
|
|
@@ -10352,7 +10386,7 @@ export {
|
|
|
10352
10386
|
Qr as GlobalAverageHandle,
|
|
10353
10387
|
B as GlobalBoundState,
|
|
10354
10388
|
Ar as GlobalCountHandle,
|
|
10355
|
-
|
|
10389
|
+
qr as GlobalCustomHandle,
|
|
10356
10390
|
wr as GlobalEveryHandle,
|
|
10357
10391
|
Mr as GlobalRealTimeComputation,
|
|
10358
10392
|
fr as GlobalStateMachineHandle,
|
|
@@ -10366,12 +10400,12 @@ export {
|
|
|
10366
10400
|
Wt as Interaction,
|
|
10367
10401
|
Ae as InteractionCall,
|
|
10368
10402
|
Ee as InteractionEventEntity,
|
|
10369
|
-
|
|
10403
|
+
qt as KlassByName,
|
|
10370
10404
|
f as LINK_SYMBOL,
|
|
10371
10405
|
vt as LinkInfo,
|
|
10372
10406
|
m as MatchExp,
|
|
10373
10407
|
Je as Modifier,
|
|
10374
|
-
|
|
10408
|
+
_i as MonoSystem,
|
|
10375
10409
|
Hi as MysqlDB,
|
|
10376
10410
|
Oi as NON_DELETED_STATE,
|
|
10377
10411
|
Di as NON_EXIST_STATE,
|
|
@@ -10389,7 +10423,7 @@ export {
|
|
|
10389
10423
|
$r as PropertyRealTimeComputation,
|
|
10390
10424
|
mr as PropertyStateMachineHandle,
|
|
10391
10425
|
Or as PropertySumHandle,
|
|
10392
|
-
|
|
10426
|
+
_t as PropertyTypes,
|
|
10393
10427
|
br as PropertyWeightedSummationHandle,
|
|
10394
10428
|
Re as Query,
|
|
10395
10429
|
be as QueryItem,
|
|
@@ -10402,7 +10436,7 @@ export {
|
|
|
10402
10436
|
K as RecordMutationSideEffect,
|
|
10403
10437
|
M as RecordQuery,
|
|
10404
10438
|
Xe as RecordQueryAgent,
|
|
10405
|
-
|
|
10439
|
+
q as RecordQueryTree,
|
|
10406
10440
|
Cr as RecordsTransformHandle,
|
|
10407
10441
|
St as RecursiveContext,
|
|
10408
10442
|
we as RefContainer,
|