interaqt 0.8.11 → 0.8.13
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/.claude/settings.local.json +67 -3
- package/dist/index.js +91 -73
- package/dist/index.js.map +1 -1
- package/dist/runtime/computations/StateMachine.d.ts.map +1 -1
- package/dist/storage/erstorage/Modifier.d.ts +6 -0
- package/dist/storage/erstorage/Modifier.d.ts.map +1 -1
- package/dist/storage/erstorage/SQLBuilder.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -15,9 +15,19 @@
|
|
|
15
15
|
"Read(backend/**)",
|
|
16
16
|
"Write(backend/**)",
|
|
17
17
|
"Edit(backend/**)",
|
|
18
|
+
"Read(frontend/**)",
|
|
19
|
+
"Write(frontend/**)",
|
|
20
|
+
"Edit(frontend/**)",
|
|
21
|
+
"Edit(backend/**)",
|
|
22
|
+
"Read(integrations/**)",
|
|
23
|
+
"Write(integrations/**)",
|
|
24
|
+
"Edit(integrations/**)",
|
|
18
25
|
"Write(requirements/**)",
|
|
19
26
|
"Edit(requirements/**)",
|
|
20
27
|
"Read(requirements/**)",
|
|
28
|
+
"Write(aggregatedIntegration.ts)",
|
|
29
|
+
"Edit(aggregatedIntegration.ts)",
|
|
30
|
+
"Read(aggregatedIntegration.ts)",
|
|
21
31
|
"Bash(npm run plan)",
|
|
22
32
|
"Bash(npm run test tests/basic.test.ts)",
|
|
23
33
|
"Bash(grep:*)",
|
|
@@ -75,9 +85,63 @@
|
|
|
75
85
|
"Bash(if [ -z \"$VOLC_SECRET_ACCESS_KEY\" ])",
|
|
76
86
|
"Bash(then echo \"VOLC_SECRET_ACCESS_KEY is empty or not set\")",
|
|
77
87
|
"Bash(npm run)",
|
|
78
|
-
"Bash(chmod:*)"
|
|
88
|
+
"Bash(chmod:*)",
|
|
89
|
+
"Bash(npm install:*)",
|
|
90
|
+
"Bash(npx vitest typecheck --run)",
|
|
91
|
+
"Read(//Users/camus/Work/interqat/interaqt-old/agentspace/**)",
|
|
92
|
+
"Read(//Users/camus/Work/interqat/interaqt-old/agentspace/**)",
|
|
93
|
+
"Bash(MODULE=basic)",
|
|
94
|
+
"Bash(jq:*)",
|
|
95
|
+
"Bash(if [[ \"$MODULE\" != \"basic\" ]])",
|
|
96
|
+
"Bash(if [ -f \"docs/basic.phase-1-error-check-report.md\" ])",
|
|
97
|
+
"Bash(then rm \"docs/basic.phase-1-error-check-report.md\")",
|
|
98
|
+
"Bash(else echo \"No existing error report found\")",
|
|
99
|
+
"Bash(rm:*)",
|
|
100
|
+
"Read(//Users/camus/Work/interqat/interaqt-old/examples/**)",
|
|
101
|
+
"Bash(for file in docs/basic.data-design.json docs/basic.computation-analysis.json docs/basic.computation-implementation-plan.json docs/basic.business-rules-and-permission-control-implementation-plan.json)",
|
|
102
|
+
"Bash(do if [ -f \"$file\" ])",
|
|
103
|
+
"Bash(done)",
|
|
104
|
+
"Bash(pgrep:*)",
|
|
105
|
+
"Bash(npm run build:frontend:dev:*)",
|
|
106
|
+
"Read(//Users/camus/Work/interqat/interaqt-old/examples/**)",
|
|
107
|
+
"Bash([:*)",
|
|
108
|
+
"Read(//Users/camus/Work/interqat/interaqt-old/examples/cms/backend/**)",
|
|
109
|
+
"Bash(if [ -f \"/Users/camus/Work/interqat/interaqt-old/examples/lit/docs/basic.task-3-error-check-report.md\" ])",
|
|
110
|
+
"Bash(else echo \"No existing report found\")",
|
|
111
|
+
"Bash(tsc:*)",
|
|
112
|
+
"Bash(timeout 10 npm start)",
|
|
113
|
+
"Bash(ln:*)",
|
|
114
|
+
"Bash(JWT_SECRET=dummy npm run generate-frontend-api)",
|
|
115
|
+
"Bash(npm search:*)",
|
|
116
|
+
"Bash(npm run typecheck)",
|
|
117
|
+
"Bash(paste:*)",
|
|
118
|
+
"Bash(MODULE=chat)",
|
|
119
|
+
"Bash(npm run setup:rocketmq:*)",
|
|
120
|
+
"Bash(npx tsx:*)",
|
|
121
|
+
"Bash(npm start)",
|
|
122
|
+
"Bash(tsx:*)",
|
|
123
|
+
"Bash(xargs kill:*)",
|
|
124
|
+
"Bash(for rel in \"BlendedImageVolcJimengCallRelation\" \"UserBlendedImageRelation\" \"PostBlendedImageRelation\" \"UserImageConsumptionRecordRelation\" \"BlendedImageConsumptionRelation\")",
|
|
125
|
+
"Bash(do echo \"$rel:\")",
|
|
126
|
+
"Bash(npm info @volcengine/openapi)",
|
|
127
|
+
"Bash(else echo \"VOLC_ACCESS_KEY_ID is set to: $VOLC_ACCESS_KEY_ID:0:10...\")",
|
|
128
|
+
"Bash(else echo \"VOLC_SECRET_ACCESS_KEY is set (length: $#VOLC_SECRET_ACCESS_KEY)\")",
|
|
129
|
+
"Bash(if [ -f .env ])",
|
|
130
|
+
"Bash(then cat .env)",
|
|
131
|
+
"Bash(else echo \".env file not found\")",
|
|
132
|
+
"Bash(JIMENG_REQ_KEY=cv_high_aes npx vitest run:*)",
|
|
133
|
+
"Bash(then grep -E \"VOLC_ACCESS_KEY_ID|VOLC_SECRET_ACCESS_KEY\" .env)",
|
|
134
|
+
"Bash(NODE_OPTIONS=\"--max-old-space-size=4096\" npm run test:*)",
|
|
135
|
+
"Bash(git log:*)",
|
|
136
|
+
"Bash(timeout 10 npm run dev:*)",
|
|
137
|
+
"Bash(mv:*)",
|
|
138
|
+
"Bash(timeout 180 npm run test:*)",
|
|
139
|
+
"Bash(npm run plan:integration)"
|
|
79
140
|
],
|
|
80
141
|
"deny": [],
|
|
81
|
-
"ask": []
|
|
142
|
+
"ask": [],
|
|
143
|
+
"additionalDirectories": [
|
|
144
|
+
"/Users/camus/Work/interqat/interaqt-old/examples/boilerplate/backend"
|
|
145
|
+
]
|
|
82
146
|
}
|
|
83
|
-
}
|
|
147
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -3383,8 +3383,8 @@ class m {
|
|
|
3383
3383
|
const n = [...a.resolvedPath, o], c = this.map.getInfoByPath(n), l = a.resolvedPath.concat(c?.isLinkFiltered() ? c.getBaseAttributeInfo().attributeName : o);
|
|
3384
3384
|
let d = a.matchExpression;
|
|
3385
3385
|
if (c?.isLinkFiltered()) {
|
|
3386
|
-
const h = c.getLinkInfo(), p = new m(h.getResolvedBaseRecordName(), this.map, h.getResolvedMatchExpression()), y = this.map.getReversePath(l), g = [c.isRecordSource() ? "source" : "target", ...y.slice(2)],
|
|
3387
|
-
d = d ? d.and(
|
|
3386
|
+
const h = c.getLinkInfo(), p = new m(h.getResolvedBaseRecordName(), this.map, h.getResolvedMatchExpression()), y = this.map.getReversePath(l), g = [c.isRecordSource() ? "source" : "target", ...y.slice(2)], k = p.rebase(g.join("."));
|
|
3387
|
+
d = d ? d.and(k) : k;
|
|
3388
3388
|
}
|
|
3389
3389
|
return {
|
|
3390
3390
|
path: [...a.path, o],
|
|
@@ -3573,6 +3573,21 @@ class $e {
|
|
|
3573
3573
|
order: e
|
|
3574
3574
|
}));
|
|
3575
3575
|
}
|
|
3576
|
+
/**
|
|
3577
|
+
* 构建 xToOne 查询树
|
|
3578
|
+
* 用于确保 ORDER BY 中引用的关联字段会触发相应的 JOIN
|
|
3579
|
+
*/
|
|
3580
|
+
get xToOneQueryTree() {
|
|
3581
|
+
const t = new L(this.recordName, this.map);
|
|
3582
|
+
return Object.keys(this.data?.orderBy || {}).forEach((e) => {
|
|
3583
|
+
const i = e.split(".");
|
|
3584
|
+
if (i.length === 1) {
|
|
3585
|
+
t.addField([e]);
|
|
3586
|
+
return;
|
|
3587
|
+
}
|
|
3588
|
+
i.slice(0, -1), t.addField(i);
|
|
3589
|
+
}), t;
|
|
3590
|
+
}
|
|
3576
3591
|
}
|
|
3577
3592
|
class C {
|
|
3578
3593
|
constructor(t, e, i, r, s, a, o, n, c, l = !1, d, h, p, y) {
|
|
@@ -3705,7 +3720,7 @@ class x {
|
|
|
3705
3720
|
let y = l, v = d;
|
|
3706
3721
|
if (p.isLinkFiltered()) {
|
|
3707
3722
|
y = p.getBaseAttributeInfo().attributeName;
|
|
3708
|
-
const
|
|
3723
|
+
const k = d.matchExpression, D = p.getLinkInfo().getBaseLinkInfo(), z = new m(D.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), ke = k ? z.and(k.data) : z;
|
|
3709
3724
|
v = {
|
|
3710
3725
|
...d,
|
|
3711
3726
|
matchExpression: ke.data
|
|
@@ -4382,28 +4397,28 @@ class Le {
|
|
|
4382
4397
|
* @returns [SQL字符串, 参数数组, 字段别名映射]
|
|
4383
4398
|
*/
|
|
4384
4399
|
buildXToOneFindQuery(t, e = "", i) {
|
|
4385
|
-
const r = t.attributeQuery.xToOneQueryTree, s = t.matchExpression.xToOneQueryTree, a = r.merge(s),
|
|
4386
|
-
this.parseMatchExpressionValue(t.recordName,
|
|
4400
|
+
const r = t.attributeQuery.xToOneQueryTree, s = t.matchExpression.xToOneQueryTree, a = t.modifier.xToOneQueryTree, o = r.merge(s).merge(a), n = this.getJoinTables(o, [t.recordName]), c = i || this.getPlaceholder(), l = t.matchExpression.buildFieldMatchExpression(c, this.database), [d, h] = this.buildWhereClause(
|
|
4401
|
+
this.parseMatchExpressionValue(t.recordName, l, t.contextRootEntity, c),
|
|
4387
4402
|
e,
|
|
4388
|
-
|
|
4389
|
-
), [
|
|
4403
|
+
c
|
|
4404
|
+
), [p, y] = this.buildSelectClause(
|
|
4390
4405
|
t.attributeQuery.getValueAndXToOneRecordFields(),
|
|
4391
4406
|
e
|
|
4392
|
-
),
|
|
4407
|
+
), v = this.buildFromClause(t.recordName, e), g = this.buildJoinClause(n, e), k = this.buildModifierClause(t.modifier, e, y);
|
|
4393
4408
|
return [
|
|
4394
4409
|
`
|
|
4395
4410
|
SELECT
|
|
4396
|
-
${
|
|
4411
|
+
${p}
|
|
4397
4412
|
FROM
|
|
4398
|
-
${y}
|
|
4399
4413
|
${v}
|
|
4414
|
+
${g}
|
|
4400
4415
|
WHERE
|
|
4401
|
-
${
|
|
4416
|
+
${d}
|
|
4402
4417
|
|
|
4403
|
-
${
|
|
4418
|
+
${k}
|
|
4404
4419
|
`,
|
|
4405
|
-
|
|
4406
|
-
|
|
4420
|
+
h,
|
|
4421
|
+
y
|
|
4407
4422
|
];
|
|
4408
4423
|
}
|
|
4409
4424
|
/**
|
|
@@ -4464,11 +4479,14 @@ ${g}
|
|
|
4464
4479
|
buildModifierClause(t, e = "", i) {
|
|
4465
4480
|
const { limit: r, offset: s, orderBy: a } = t, o = [];
|
|
4466
4481
|
return a.length && o.push(`ORDER BY ${a.map(({ attribute: n, recordName: c, order: l }) => {
|
|
4467
|
-
const d =
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
]
|
|
4471
|
-
|
|
4482
|
+
const d = n.split(".");
|
|
4483
|
+
let h, p;
|
|
4484
|
+
d.length === 1 ? (h = [c], p = n) : (h = [c, ...d.slice(0, -1)], p = d[d.length - 1]);
|
|
4485
|
+
const [y, v] = this.map.getTableAliasAndFieldName(
|
|
4486
|
+
h,
|
|
4487
|
+
p
|
|
4488
|
+
);
|
|
4489
|
+
return `"${`${this.withPrefix(e)}${y}`}"."${v}" ${l}`;
|
|
4472
4490
|
}).join(",")}`), r && o.push(`LIMIT ${r}`), s && o.push(`OFFSET ${s}`), o.join(`
|
|
4473
4491
|
`);
|
|
4474
4492
|
}
|
|
@@ -4514,22 +4532,22 @@ ${g}
|
|
|
4514
4532
|
joinTarget: [d, h]
|
|
4515
4533
|
});
|
|
4516
4534
|
} else {
|
|
4517
|
-
const g = c.getLinkInfo(),
|
|
4535
|
+
const g = c.getLinkInfo(), k = c.isLinkManyToManySymmetric() ? c.symmetricDirection === "source" : g.isRelationSource(c.parentEntityName, c.attributeName);
|
|
4518
4536
|
r.push({
|
|
4519
4537
|
for: l,
|
|
4520
4538
|
joinSource: a,
|
|
4521
|
-
joinIdField: [s,
|
|
4539
|
+
joinIdField: [s, k ? g.record.attributes.source.field : g.record.attributes.target.field],
|
|
4522
4540
|
joinTarget: [p, y]
|
|
4523
4541
|
}), o.onlyIdField() || r.push({
|
|
4524
4542
|
for: l,
|
|
4525
4543
|
joinSource: [p, y],
|
|
4526
|
-
joinIdField: [
|
|
4544
|
+
joinIdField: [k ? g.record.attributes.target.field : g.record.attributes.source.field, v],
|
|
4527
4545
|
joinTarget: [d, h]
|
|
4528
4546
|
});
|
|
4529
4547
|
}
|
|
4530
4548
|
if (r.push(...this.getJoinTables(o, l, [v, d, h])), o.parentLinkQueryTree && !o.parentLinkQueryTree.onlyIdField()) {
|
|
4531
|
-
const g = l.concat(f), [,
|
|
4532
|
-
|
|
4549
|
+
const g = l.concat(f), [, k] = this.map.getTableAliasAndFieldName(g, "id", !0), D = [
|
|
4550
|
+
k,
|
|
4533
4551
|
// link 的 idField
|
|
4534
4552
|
p,
|
|
4535
4553
|
// link 的 tableName
|
|
@@ -4735,8 +4753,8 @@ class Be {
|
|
|
4735
4753
|
value: ["=", y.id]
|
|
4736
4754
|
}), g = d.derive({
|
|
4737
4755
|
matchExpression: v
|
|
4738
|
-
}),
|
|
4739
|
-
y[d.alias || d.attributeName] = await this.findRecords(g, e, i,
|
|
4756
|
+
}), k = t.label ? l.concat(y) : l;
|
|
4757
|
+
y[d.alias || d.attributeName] = await this.findRecords(g, e, i, k);
|
|
4740
4758
|
}
|
|
4741
4759
|
}
|
|
4742
4760
|
for (let d of t.attributeQuery.xToOneRecords) {
|
|
@@ -4745,10 +4763,10 @@ class Be {
|
|
|
4745
4763
|
for (let p of h.attributeQuery.xToManyRecords) {
|
|
4746
4764
|
const v = this.map.getInfo(p.parentRecord, p.attributeName).getReverseInfo()?.attributeName;
|
|
4747
4765
|
for (let g of c) {
|
|
4748
|
-
const
|
|
4766
|
+
const k = g[d.attributeName][f].id, D = p.derive({
|
|
4749
4767
|
matchExpression: p.matchExpression.and({
|
|
4750
4768
|
key: `${v}.id`,
|
|
4751
|
-
value: ["=",
|
|
4769
|
+
value: ["=", k]
|
|
4752
4770
|
})
|
|
4753
4771
|
}), J = t.label ? l.concat(g) : l;
|
|
4754
4772
|
Et(
|
|
@@ -4834,21 +4852,21 @@ class Be {
|
|
|
4834
4852
|
matchExpression: c,
|
|
4835
4853
|
attributeQuery: l
|
|
4836
4854
|
}), h = await this.findRecords(d, `finding related record: ${r.parentRecord}.${r.attributeName}`, s, a), p = r.attributeQuery.parentLinkRecordQuery ? h.map((g) => {
|
|
4837
|
-
let
|
|
4838
|
-
return o.isLinkManyToManySymmetric() ? (
|
|
4855
|
+
let k;
|
|
4856
|
+
return o.isLinkManyToManySymmetric() ? (k = {
|
|
4839
4857
|
...g,
|
|
4840
4858
|
[f]: g[`${n}:source`]?.[f]?.id ? g[`${n}:source`]?.[f] : g[`${n}:target`]?.[f]
|
|
4841
|
-
}, delete
|
|
4859
|
+
}, delete k[`${n}:source`], delete k[`${n}:target`]) : (k = {
|
|
4842
4860
|
...g,
|
|
4843
4861
|
[f]: g[n][f]
|
|
4844
|
-
}, delete
|
|
4862
|
+
}, delete k[n]), k;
|
|
4845
4863
|
}) : h, y = d.label && d.label !== a.label ? a.spawn(d.label) : a, v = r.attributeQuery.parentLinkRecordQuery;
|
|
4846
4864
|
if (v)
|
|
4847
4865
|
for (let g of v.attributeQuery.xToManyRecords)
|
|
4848
|
-
for (let
|
|
4849
|
-
const D =
|
|
4866
|
+
for (let k of p) {
|
|
4867
|
+
const D = k[f].id, J = d.label ? y.concat(k) : y;
|
|
4850
4868
|
Et(
|
|
4851
|
-
|
|
4869
|
+
k,
|
|
4852
4870
|
[f, g.attributeName],
|
|
4853
4871
|
await this.findXToManyRelatedRecords(
|
|
4854
4872
|
g.parentRecord,
|
|
@@ -5657,13 +5675,13 @@ class je {
|
|
|
5657
5675
|
for (let h = 0; h < i.length; h++) {
|
|
5658
5676
|
const [p, y] = this.getAttributeAndSymmetricDirection(i[h]), v = [e, ...i.slice(0, h + 1)];
|
|
5659
5677
|
if (p === f) {
|
|
5660
|
-
const { linkTable: g, linkAlias:
|
|
5661
|
-
b(!c, `last attribute in path is a link, cannot read link of a link ${D.join(".")}`), s = g, a =
|
|
5678
|
+
const { linkTable: g, linkAlias: k, path: D } = d.pop();
|
|
5679
|
+
b(!c, `last attribute in path is a link, cannot read link of a link ${D.join(".")}`), s = g, a = k, r = this.data.records[l.linkName], c = !0, o = "", n = "", l = void 0;
|
|
5662
5680
|
} else {
|
|
5663
5681
|
l = this.getInfoByPath(v);
|
|
5664
5682
|
const g = r.attributes[p];
|
|
5665
5683
|
b(l.isRecord, `${i.slice(0, h + 1).join(".")} is not a entity attribute`);
|
|
5666
|
-
const
|
|
5684
|
+
const k = this.data.records[g.recordName], D = `${a}_${p}${y ? `_${y.toUpperCase()}` : ""}`, J = this.aliasManager?.getTableAlias(D) || D;
|
|
5667
5685
|
if (l.isMergedWithParent() || l.isLinkMergedWithParent())
|
|
5668
5686
|
n = a;
|
|
5669
5687
|
else if (l.isLinkIsolated()) {
|
|
@@ -5671,7 +5689,7 @@ class je {
|
|
|
5671
5689
|
n = this.aliasManager?.getTableAlias(z) || z;
|
|
5672
5690
|
} else
|
|
5673
5691
|
n = J;
|
|
5674
|
-
l.isMergedWithParent() || (a = J), s = l.table, r =
|
|
5692
|
+
l.isMergedWithParent() || (a = J), s = l.table, r = k, o = l.getLinkInfo()?.table, c = !1;
|
|
5675
5693
|
}
|
|
5676
5694
|
d.push({
|
|
5677
5695
|
table: s,
|
|
@@ -6541,9 +6559,9 @@ class oi {
|
|
|
6541
6559
|
p[0] === "1" && p[1] === "1" && y !== v,
|
|
6542
6560
|
`only 1:1 can merge: ${s}.${a.slice(0, n + 1).join(".")}`
|
|
6543
6561
|
);
|
|
6544
|
-
const g = y === o ? v : y,
|
|
6545
|
-
if (
|
|
6546
|
-
throw new Error(`conflict found when join ${d}, ${
|
|
6562
|
+
const g = y === o ? v : y, k = this.combineRecordTable(o, g, d);
|
|
6563
|
+
if (k)
|
|
6564
|
+
throw new Error(`conflict found when join ${d}, ${k.join(",")} already merged with ${o}`);
|
|
6547
6565
|
h.mergedTo = "combined", i.push(h), o = l.recordName, delete t[d], delete e[d];
|
|
6548
6566
|
}
|
|
6549
6567
|
}), Object.values(t).forEach((r) => {
|
|
@@ -7025,7 +7043,7 @@ class Re {
|
|
|
7025
7043
|
return this.data.transfers.filter((e) => $t(t, e.trigger));
|
|
7026
7044
|
}
|
|
7027
7045
|
}
|
|
7028
|
-
function
|
|
7046
|
+
function A(u, t) {
|
|
7029
7047
|
if (!u)
|
|
7030
7048
|
throw new Error(t);
|
|
7031
7049
|
}
|
|
@@ -7106,7 +7124,7 @@ class pi {
|
|
|
7106
7124
|
}
|
|
7107
7125
|
async getInitialValue(t) {
|
|
7108
7126
|
const e = t[this.dataContext.id.name];
|
|
7109
|
-
return
|
|
7127
|
+
return A(
|
|
7110
7128
|
!(e !== void 0 && !this.initialState.computeValue),
|
|
7111
7129
|
`${this.dataContext.host.name}.${this.dataContext.id.name} have been set when ${this.dataContext.host.name} created,
|
|
7112
7130
|
if you want to save the use the initial value, you need to define computeValue in initialState to save it.
|
|
@@ -7115,8 +7133,8 @@ Or if you want to use state name as value, you should not set ${this.dataContext
|
|
|
7115
7133
|
), e !== void 0 || this.initialState.computeValue ? await this.initialState.computeValue.call(this.controller, e, void 0) : this.initialState.name;
|
|
7116
7134
|
}
|
|
7117
7135
|
async computeDirtyRecords(t) {
|
|
7118
|
-
const e = this.transitionFinder.findTransfers(t);
|
|
7119
|
-
return
|
|
7136
|
+
const e = this.transitionFinder.findTransfers(t), i = (await Promise.all(e.map((s) => s.computeTarget.call(this.controller, t)))).flat().filter(Boolean), r = /* @__PURE__ */ new Set();
|
|
7137
|
+
return i.filter((s) => r.has(s.id) ? !1 : (r.add(s.id), !0));
|
|
7120
7138
|
}
|
|
7121
7139
|
async incrementalCompute(t, e, i) {
|
|
7122
7140
|
const r = await this.state.currentState.get(i), s = this.transitionFinder?.findNextState(r, e);
|
|
@@ -7194,7 +7212,7 @@ class mi {
|
|
|
7194
7212
|
}
|
|
7195
7213
|
class yi {
|
|
7196
7214
|
constructor(t, e, i) {
|
|
7197
|
-
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property),
|
|
7215
|
+
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), A(this.relation, "weighted summation computation must specify property"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, A(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "weighted summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
|
|
7198
7216
|
const r = this.args.attributeQuery || [];
|
|
7199
7217
|
this.relatedAttributeQuery = this.args.attributeQuery?.filter((a) => a[0] !== f) || [];
|
|
7200
7218
|
const s = (r.find((a) => a[0] === f) || [])[1]?.attributeQuery;
|
|
@@ -7324,7 +7342,7 @@ class bi {
|
|
|
7324
7342
|
}
|
|
7325
7343
|
class Ri {
|
|
7326
7344
|
constructor(t, e, i) {
|
|
7327
|
-
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name,
|
|
7345
|
+
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, A(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "every computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
|
|
7328
7346
|
const r = this.args.attributeQuery || [];
|
|
7329
7347
|
this.relatedAttributeQuery = this.args.attributeQuery?.filter((a) => a[0] !== f) || [];
|
|
7330
7348
|
const s = (r.find((a) => a[0] === f) || [])[1]?.attributeQuery;
|
|
@@ -7452,12 +7470,12 @@ class Ni {
|
|
|
7452
7470
|
}
|
|
7453
7471
|
class vi {
|
|
7454
7472
|
constructor(t, e, i) {
|
|
7455
|
-
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((n) => n.source === i.host && n.sourceProperty === this.args.property || n.target === i.host && n.targetProperty === this.args.property),
|
|
7473
|
+
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((n) => n.source === i.host && n.sourceProperty === this.args.property || n.target === i.host && n.targetProperty === this.args.property), A(this.relation, `cannot find relation for property ${this.args.property} in "Any" computation`), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, A(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "any computation relation direction error");
|
|
7456
7474
|
let r = this.relation.baseRelation || this.relation;
|
|
7457
7475
|
for (; r.baseRelation; )
|
|
7458
7476
|
r = r.baseRelation;
|
|
7459
7477
|
const s = r.type.split(":");
|
|
7460
|
-
|
|
7478
|
+
A(s[this.isSource ? 1 : 0] === "n", `property-level Any computation argument must be an x:n relation. ${this.dataContext.host.name}.${this.args.property}" is a ${this.isSource ? s.join(":") : s.slice().reverse().join(":")} relation`), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
|
|
7461
7479
|
const a = this.args.attributeQuery || [];
|
|
7462
7480
|
this.relatedAttributeQuery = this.args.attributeQuery?.filter((n) => n[0] !== f) || [];
|
|
7463
7481
|
const o = (a.find((n) => n[0] === f) || [])[1]?.attributeQuery;
|
|
@@ -7579,7 +7597,7 @@ class ki {
|
|
|
7579
7597
|
}
|
|
7580
7598
|
class Ai {
|
|
7581
7599
|
constructor(t, e, i) {
|
|
7582
|
-
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback?.bind(this.controller), this.args.property ? this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property) : this.relation = this.args.record, this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name,
|
|
7600
|
+
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback?.bind(this.controller), this.args.property ? this.relation = this.controller.relations.find((a) => a.source === i.host && a.sourceProperty === this.args.property || a.target === i.host && a.targetProperty === this.args.property) : this.relation = this.args.record, this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, A(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "count computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
|
|
7583
7601
|
const r = this.args.attributeQuery || [];
|
|
7584
7602
|
this.relatedAttributeQuery = r.filter((a) => a && a[0] !== f) || [];
|
|
7585
7603
|
const s = (r.find((a) => a && a[0] === f) || [])[1]?.attributeQuery;
|
|
@@ -7662,7 +7680,7 @@ class Ai {
|
|
|
7662
7680
|
const Si = [ki, Ai];
|
|
7663
7681
|
class Ei {
|
|
7664
7682
|
constructor(t, e, i) {
|
|
7665
|
-
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {},
|
|
7683
|
+
this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, A(!(this.args.record && this.args.eventDeps), "Transform must have either record or eventDep"), A(!(this.args.dataDeps && this.args.eventDeps), "Transform must have either dataDeps or eventDeps"), this.transformCallback = this.args.callback.bind(this.controller), this.args.eventDeps ? this.eventDeps = this.args.eventDeps : (A(this.args.dataDeps?._source === void 0, "dataDep name `_source` is reserved for Transform"), this.dataDeps = {
|
|
7666
7684
|
...this.args.dataDeps || {},
|
|
7667
7685
|
_source: {
|
|
7668
7686
|
type: "records",
|
|
@@ -7687,7 +7705,7 @@ class Ei {
|
|
|
7687
7705
|
return [];
|
|
7688
7706
|
}
|
|
7689
7707
|
async compute({ _source: t }) {
|
|
7690
|
-
|
|
7708
|
+
A(!this.eventDeps, "Transform compute should not be called with eventDeps");
|
|
7691
7709
|
const e = [];
|
|
7692
7710
|
for (const i of t) {
|
|
7693
7711
|
const r = await this.transformCallback.call(this.controller, i);
|
|
@@ -7702,7 +7720,7 @@ class Ei {
|
|
|
7702
7720
|
return e;
|
|
7703
7721
|
}
|
|
7704
7722
|
async computeDirtyRecords(t) {
|
|
7705
|
-
return
|
|
7723
|
+
return A(this.eventDeps, "computeDirtyRecords should be called with eventDeps"), [{}];
|
|
7706
7724
|
}
|
|
7707
7725
|
async incrementalPatchCompute(t, e) {
|
|
7708
7726
|
return this.eventDeps ? this.eventBasedIncrementalPatchCompute(t, e) : this.dataBasedIncrementalPatchCompute(t, e);
|
|
@@ -8174,7 +8192,7 @@ class Pi {
|
|
|
8174
8192
|
}
|
|
8175
8193
|
class $i {
|
|
8176
8194
|
constructor(t, e, i) {
|
|
8177
|
-
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),
|
|
8195
|
+
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), A(this.relation, "summation computation must specify either property or record"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === i.host.name, A(this.isSource ? this.relation.source === i.host : this.relation.target === i.host, "summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
|
|
8178
8196
|
const r = this.args.attributeQuery || [];
|
|
8179
8197
|
this.relatedAttributeQuery = this.args.attributeQuery?.filter((o) => o[0] !== f) || [];
|
|
8180
8198
|
const s = (r.find((o) => o[0] === f) || [])[1]?.attributeQuery;
|
|
@@ -8337,7 +8355,7 @@ class Oi {
|
|
|
8337
8355
|
}
|
|
8338
8356
|
class Di {
|
|
8339
8357
|
constructor(t, e, i) {
|
|
8340
|
-
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,
|
|
8358
|
+
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, A(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;
|
|
8341
8359
|
const r = this.args.attributeQuery || [];
|
|
8342
8360
|
this.relatedAttributeQuery = r.filter((o) => o && o[0] !== f) || [];
|
|
8343
8361
|
const s = (r.find((o) => o && o[0] === f) || [])[1]?.attributeQuery;
|
|
@@ -8513,7 +8531,7 @@ class Bi extends St {
|
|
|
8513
8531
|
constructor(t, e, i) {
|
|
8514
8532
|
if (e.dataDeps) {
|
|
8515
8533
|
const r = Object.keys(e.dataDeps).filter((s) => e.dataDeps[s].type === "records");
|
|
8516
|
-
|
|
8534
|
+
A(r.length === 0, `property-level custom computation dataDeps should not contain "records” type dataDeps, but got ${r.join(", ")}
|
|
8517
8535
|
If you want to use related entity/relation as dataDeps, please use "property" type dataDeps with args: { type: "property", attributeQuery: [attributeQuery] }
|
|
8518
8536
|
If you want to use aggregated data from all records in the entity/relation, you should define a different dict value to store the aggregated data, and then use the dict value as dataDeps.
|
|
8519
8537
|
`);
|
|
@@ -8849,9 +8867,9 @@ class Ji {
|
|
|
8849
8867
|
});
|
|
8850
8868
|
for (const o of a) {
|
|
8851
8869
|
const n = o.dataContext, c = o.args, l = this.computationHandleMap.get(c.constructor);
|
|
8852
|
-
|
|
8870
|
+
A(!!l, `cannot find Computation handle map for ${c.constructor.displayName || c.constructor.name}`);
|
|
8853
8871
|
const d = l[n.type];
|
|
8854
|
-
|
|
8872
|
+
A(!!d, `cannot find Computation handle for ${c.constructor.displayName || c.constructor.name} with context type ${n.type}`);
|
|
8855
8873
|
const h = new d(this.controller, c, n);
|
|
8856
8874
|
if (this.computationsHandles.set(n.id, h), this.isAsyncComputation(h)) {
|
|
8857
8875
|
if (h.dataContext.type === "property") {
|
|
@@ -8963,7 +8981,7 @@ class Ji {
|
|
|
8963
8981
|
const r = this.computationHandleMap.get(i.computationType);
|
|
8964
8982
|
if (Array.isArray(i.contextType))
|
|
8965
8983
|
for (const s of i.contextType)
|
|
8966
|
-
|
|
8984
|
+
A(!r[s], `${s} for ${i.computationType.name} is already registered.`), r[s] = e;
|
|
8967
8985
|
else
|
|
8968
8986
|
r[i.contextType] = e;
|
|
8969
8987
|
}
|
|
@@ -8993,13 +9011,13 @@ class Ji {
|
|
|
8993
9011
|
}
|
|
8994
9012
|
async createStateData(t, ...e) {
|
|
8995
9013
|
const i = this.computationsHandles.get(t);
|
|
8996
|
-
return
|
|
9014
|
+
return A(!!i, "cannot find computation handle"), i.createStateData?.(...e) ?? {};
|
|
8997
9015
|
}
|
|
8998
9016
|
addMutationPropertyComputationDefaultValueListeners() {
|
|
8999
9017
|
for (const t of this.computationsHandles.values())
|
|
9000
9018
|
if (t.getInitialValue && t.dataContext.type === "property") {
|
|
9001
9019
|
const e = t.dataContext;
|
|
9002
|
-
|
|
9020
|
+
A(!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) => {
|
|
9003
9021
|
for (let r of i)
|
|
9004
9022
|
if (r.type === "create" && r.recordName === e.host.name) {
|
|
9005
9023
|
const s = await t.getInitialValue?.(r.record);
|
|
@@ -9038,11 +9056,11 @@ class Ji {
|
|
|
9038
9056
|
return [e.oldRecord ?? e.record];
|
|
9039
9057
|
let i = [];
|
|
9040
9058
|
if (!t.isRelation)
|
|
9041
|
-
|
|
9059
|
+
A(t.type === "update", "only support update event for entity"), i = await this.controller.system.storage.find(t.sourceRecordName, m.atom({
|
|
9042
9060
|
key: t.targetPath.concat("id").join("."),
|
|
9043
9061
|
value: ["=", e.oldRecord.id]
|
|
9044
9062
|
}), void 0);
|
|
9045
|
-
else if (
|
|
9063
|
+
else if (A(t.type === "create" || t.type === "delete", "only support create/delete event for relation"), t.dataDep, t.type === "create")
|
|
9046
9064
|
i = await this.controller.system.storage.find(t.sourceRecordName, m.atom({
|
|
9047
9065
|
key: t.targetPath.concat(["&", "id"]).join("."),
|
|
9048
9066
|
value: ["=", e.record.id]
|
|
@@ -9527,7 +9545,7 @@ class we {
|
|
|
9527
9545
|
return [o.name, { result: n, error: c }];
|
|
9528
9546
|
})()), a = await Promise.all(s);
|
|
9529
9547
|
for (let [o, { result: n, error: c }] of a)
|
|
9530
|
-
|
|
9548
|
+
A(!i.sideEffects[o], `sideEffect ${o} already exists`), i.sideEffects[o] = { result: n, error: c };
|
|
9531
9549
|
}
|
|
9532
9550
|
isGetInteraction() {
|
|
9533
9551
|
return this.interaction.action === Me;
|
|
@@ -9543,7 +9561,7 @@ class we {
|
|
|
9543
9561
|
const a = { ...t.query?.modifier || {}, ...s || {} }, o = t.query?.attributeQuery || [], n = typeof r == "function" ? await r.call(this.controller, t) : r, c = R.and(n, t.query?.match);
|
|
9544
9562
|
e = await this.system.storage.find(i, c, a, o);
|
|
9545
9563
|
} else
|
|
9546
|
-
|
|
9564
|
+
A(!1, `unknown data type ${this.interaction.data}`);
|
|
9547
9565
|
return e;
|
|
9548
9566
|
}
|
|
9549
9567
|
async check(t, e, i, r) {
|
|
@@ -9662,7 +9680,7 @@ class oe {
|
|
|
9662
9680
|
}
|
|
9663
9681
|
class tt {
|
|
9664
9682
|
constructor(t, e) {
|
|
9665
|
-
this.activity = t, this.controller = e, this.uuidToNode = /* @__PURE__ */ new Map(), this.uuidToInteractionCall = /* @__PURE__ */ new Map(), this.interactionCallByName = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.checkUserRef = async (i, r, s) => (
|
|
9683
|
+
this.activity = t, this.controller = e, this.uuidToNode = /* @__PURE__ */ new Map(), this.uuidToInteractionCall = /* @__PURE__ */ new Map(), this.interactionCallByName = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.checkUserRef = async (i, r, s) => (A(i.isRef, "attributive must be ref"), ((await this.getActivity(s))?.refs)[i.name] === r.id), this.system = e.system, this.graph = this.buildGraph(t);
|
|
9666
9684
|
}
|
|
9667
9685
|
static {
|
|
9668
9686
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -9698,7 +9716,7 @@ class tt {
|
|
|
9698
9716
|
const s = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]), a = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]);
|
|
9699
9717
|
if (t.transfers?.forEach((o) => {
|
|
9700
9718
|
const n = this.rawToNode.get(o.source) || i.get(o.source), c = this.rawToNode.get(o.target) || i.get(o.target);
|
|
9701
|
-
|
|
9719
|
+
A(!!n, `cannot find source ${o.source.name}`), A(!!c, `cannot find target ${o.source.name}`), it.is(n) ? n.next.push(c) : n.next = c, it.is(c) ? c.prev.push(n) : c.prev = n, a.delete(o.source), s.delete(o.target);
|
|
9702
9720
|
}), s.size !== 1) throw new Error(`start node must one, current: ${s.size}`);
|
|
9703
9721
|
if (a.size !== 1) throw new Error(`end node must be one, current: ${a.size}`);
|
|
9704
9722
|
return Object.assign(r, {
|
|
@@ -9773,7 +9791,7 @@ class tt {
|
|
|
9773
9791
|
return o;
|
|
9774
9792
|
await this.saveUserRefs(s, r, i);
|
|
9775
9793
|
const n = a.completeInteraction(e);
|
|
9776
|
-
|
|
9794
|
+
A(n, "change activity state failed");
|
|
9777
9795
|
const c = a.toJSON();
|
|
9778
9796
|
return await this.setActivity(s, { state: c }), {
|
|
9779
9797
|
...o,
|
|
@@ -9887,10 +9905,10 @@ class Xi {
|
|
|
9887
9905
|
constructor(t, e, i) {
|
|
9888
9906
|
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(ve, Ne), this.controller.relations.push(Gi), e.forEach((r) => {
|
|
9889
9907
|
const s = new tt(r, t);
|
|
9890
|
-
this.activityCalls.set(r.uuid, s), r.name && (
|
|
9908
|
+
this.activityCalls.set(r.uuid, s), r.name && (A(!this.activityCallsByName.has(r.name), `activity name ${r.name} is duplicated`), this.activityCallsByName.set(r.name, s));
|
|
9891
9909
|
}), i.forEach((r) => {
|
|
9892
9910
|
const s = new we(r, t);
|
|
9893
|
-
this.interactionCalls.set(r.uuid, s), r.name && (
|
|
9911
|
+
this.interactionCalls.set(r.uuid, s), r.name && (A(!this.interactionCallsByName.has(r.name), `interaction name ${r.name} is duplicated`), this.interactionCallsByName.set(r.name, s));
|
|
9894
9912
|
});
|
|
9895
9913
|
}
|
|
9896
9914
|
async callInteraction(t, e) {
|
|
@@ -10136,7 +10154,7 @@ class Sr {
|
|
|
10136
10154
|
}
|
|
10137
10155
|
} else {
|
|
10138
10156
|
const a = t;
|
|
10139
|
-
a.id.name === Ot && s.data ? (
|
|
10157
|
+
a.id.name === Ot && s.data ? (A(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 });
|
|
10140
10158
|
}
|
|
10141
10159
|
}
|
|
10142
10160
|
}
|
|
@@ -10517,7 +10535,7 @@ export {
|
|
|
10517
10535
|
ct as WeightedSummation,
|
|
10518
10536
|
gi as WeightedSummationHandles,
|
|
10519
10537
|
ce as addToCurrentEffects,
|
|
10520
|
-
|
|
10538
|
+
A as assert,
|
|
10521
10539
|
Yt as asyncEffectsContext,
|
|
10522
10540
|
ne as asyncInteractionContext,
|
|
10523
10541
|
fr as boolExpToAttributives,
|