interaqt 0.8.6 → 0.8.7
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.
|
@@ -19,6 +19,8 @@ Entity.create(config: EntityConfig): EntityInstance
|
|
|
19
19
|
- `config.computation` (Computation[], optional): Entity-level computed data
|
|
20
20
|
- `config.baseEntity` (Entity|Relation, optional): Base entity for filtered entity (used to create filtered entities)
|
|
21
21
|
- `config.matchExpression` (MatchExp, optional): Match expression (used to create filtered entities)
|
|
22
|
+
- `config.inputEntities` (Entity[], optional): Input entities for merged entity (used to create merged entities)
|
|
23
|
+
- `config.commonProperties` (Property[], optional): Common properties that all input entities must have (used with merged entities to define shared attributes)
|
|
22
24
|
|
|
23
25
|
**Examples**
|
|
24
26
|
```typescript
|
|
@@ -96,6 +98,42 @@ const TechYoungUser = Entity.create({
|
|
|
96
98
|
|
|
97
99
|
3. **Automatic Updates**: When source entity records are created, updated, or deleted, filtered entities automatically reflect these changes based on their match expressions.
|
|
98
100
|
|
|
101
|
+
**Merged Entities**
|
|
102
|
+
|
|
103
|
+
Merged entities represent a unified view of multiple entities, treating them as a single type. Use `commonProperties` to define shared attributes:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const Teacher = Entity.create({
|
|
107
|
+
name: 'Teacher',
|
|
108
|
+
properties: [
|
|
109
|
+
Property.create({ name: 'name', type: 'string' }),
|
|
110
|
+
Property.create({ name: 'age', type: 'number' }),
|
|
111
|
+
Property.create({ name: 'subject', type: 'string' })
|
|
112
|
+
]
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const Student = Entity.create({
|
|
116
|
+
name: 'Student',
|
|
117
|
+
properties: [
|
|
118
|
+
Property.create({ name: 'name', type: 'string' }),
|
|
119
|
+
Property.create({ name: 'age', type: 'number' }),
|
|
120
|
+
Property.create({ name: 'grade', type: 'number' })
|
|
121
|
+
]
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// Merged entity with common properties
|
|
125
|
+
const TeacherStudent = Entity.create({
|
|
126
|
+
name: 'TeacherStudent',
|
|
127
|
+
inputEntities: [Teacher, Student],
|
|
128
|
+
commonProperties: [
|
|
129
|
+
Property.create({ name: 'name', type: 'string' }),
|
|
130
|
+
Property.create({ name: 'age', type: 'number' })
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Note**: Merged entities cannot define their own `properties` - only `commonProperties` that specify the shared attribute contract.
|
|
136
|
+
|
|
99
137
|
### Property.create()
|
|
100
138
|
|
|
101
139
|
Create entity property definition.
|
|
@@ -293,9 +331,10 @@ Create relationship definition between entities or create filtered views of exis
|
|
|
293
331
|
Relation.create(config: RelationConfig): RelationInstance
|
|
294
332
|
```
|
|
295
333
|
|
|
296
|
-
**
|
|
334
|
+
**Three Types of Relations**
|
|
297
335
|
1. **Base Relations**: Define direct relationships between entities (requires `source`, `target`, `type`)
|
|
298
336
|
2. **Filtered Relations**: Create filtered views of existing relations (requires `baseRelation`, `matchExpression`)
|
|
337
|
+
3. **Merged Relations**: Combine multiple relations with same source/target into unified view (requires `inputRelations`, `sourceProperty`, `targetProperty`)
|
|
299
338
|
|
|
300
339
|
**Important: Auto-Generated Relation Names**
|
|
301
340
|
|
|
@@ -314,6 +353,8 @@ If you did not specify a `name` property when creating relations, The framework
|
|
|
314
353
|
- `config.computation` (Computation, optional): Relationship-level computed data
|
|
315
354
|
- `config.baseRelation` (Relation, required for filtered relations): Base relation to filter from
|
|
316
355
|
- `config.matchExpression` (MatchExp, required for filtered relations): Filter condition for the relation records
|
|
356
|
+
- `config.inputRelations` (Relation[], required for merged relations): Input relations with same source/target to merge
|
|
357
|
+
- `config.commonProperties` (Property[], optional): Common properties that all input relations must have (used with merged relations)
|
|
317
358
|
|
|
318
359
|
|
|
319
360
|
**Note on Symmetric Relations**: The system automatically detects symmetric relations when `source === target` AND `sourceProperty === targetProperty`. There is no need to specify a `symmetric` parameter.
|
|
@@ -440,6 +481,49 @@ const ImportantActiveRelation = Relation.create({
|
|
|
440
481
|
|
|
441
482
|
4. **Automatic Updates**: When source relation records are created, updated, or deleted, filtered relations automatically reflect these changes based on their match expressions. For example, if a relation's `isActive` property is updated from `false` to `true`, it will automatically appear in the corresponding filtered relation.
|
|
442
483
|
|
|
484
|
+
**Merged Relations**
|
|
485
|
+
|
|
486
|
+
Merged relations combine multiple relations with the same source/target into a unified view. Use `commonProperties` to define shared relation attributes:
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
// Base relations between User and Project
|
|
490
|
+
const UserProjectOwnerRelation = Relation.create({
|
|
491
|
+
source: User,
|
|
492
|
+
sourceProperty: 'ownedProjects',
|
|
493
|
+
target: Project,
|
|
494
|
+
targetProperty: 'owners',
|
|
495
|
+
type: 'n:n',
|
|
496
|
+
properties: [
|
|
497
|
+
Property.create({ name: 'since', type: 'number' }),
|
|
498
|
+
Property.create({ name: 'equity', type: 'number' })
|
|
499
|
+
]
|
|
500
|
+
})
|
|
501
|
+
|
|
502
|
+
const UserProjectMemberRelation = Relation.create({
|
|
503
|
+
source: User,
|
|
504
|
+
sourceProperty: 'memberProjects',
|
|
505
|
+
target: Project,
|
|
506
|
+
targetProperty: 'members',
|
|
507
|
+
type: 'n:n',
|
|
508
|
+
properties: [
|
|
509
|
+
Property.create({ name: 'since', type: 'number' }),
|
|
510
|
+
Property.create({ name: 'role', type: 'string' })
|
|
511
|
+
]
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
// Merged relation with common properties
|
|
515
|
+
const UserProjectRelation = Relation.create({
|
|
516
|
+
inputRelations: [UserProjectOwnerRelation, UserProjectMemberRelation],
|
|
517
|
+
sourceProperty: 'allProjects',
|
|
518
|
+
targetProperty: 'allUsers',
|
|
519
|
+
commonProperties: [
|
|
520
|
+
Property.create({ name: 'since', type: 'number' })
|
|
521
|
+
]
|
|
522
|
+
})
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
**Note**: Merged relations cannot define their own `properties` - only `commonProperties` that specify the shared attribute contract. The `source`, `target`, and `type` are inherited from input relations (which must all have the same source/target).
|
|
526
|
+
|
|
443
527
|
## 13.2 Computation-Related APIs
|
|
444
528
|
|
|
445
529
|
### Count.create()
|
package/dist/index.js
CHANGED
|
@@ -34,13 +34,13 @@ function tr(...u) {
|
|
|
34
34
|
}
|
|
35
35
|
function er() {
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const Ft = /* @__PURE__ */ new Map();
|
|
38
38
|
function Ae(u, t) {
|
|
39
|
-
t && t.isKlass && t.displayName &&
|
|
39
|
+
t && t.isKlass && t.displayName && Ft.set(u, t);
|
|
40
40
|
}
|
|
41
41
|
function ir() {
|
|
42
42
|
const u = [];
|
|
43
|
-
return Array.from(
|
|
43
|
+
return Array.from(Ft.entries()).forEach(([, t]) => {
|
|
44
44
|
t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
|
|
45
45
|
}), `[${u.join(",")}]`;
|
|
46
46
|
}
|
|
@@ -51,7 +51,7 @@ function rr(u) {
|
|
|
51
51
|
function Se(u) {
|
|
52
52
|
const t = /* @__PURE__ */ new Map();
|
|
53
53
|
return u.forEach(({ type: e, options: i = {}, uuid: r, public: s }) => {
|
|
54
|
-
const a =
|
|
54
|
+
const a = Ft.get(e);
|
|
55
55
|
if (!a) {
|
|
56
56
|
console.warn(`Class ${e} not found in KlassByName`);
|
|
57
57
|
return;
|
|
@@ -185,7 +185,8 @@ class I {
|
|
|
185
185
|
computation: t.computation,
|
|
186
186
|
baseEntity: t.baseEntity,
|
|
187
187
|
matchExpression: t.matchExpression,
|
|
188
|
-
inputEntities: t.inputEntities
|
|
188
|
+
inputEntities: t.inputEntities,
|
|
189
|
+
commonProperties: t.commonProperties
|
|
189
190
|
};
|
|
190
191
|
return this.create(i);
|
|
191
192
|
}
|
|
@@ -3679,7 +3680,7 @@ class L {
|
|
|
3679
3680
|
}), this.parentLinkQueryTree && (t[f] = this.parentLinkQueryTree.getData()), t;
|
|
3680
3681
|
}
|
|
3681
3682
|
}
|
|
3682
|
-
const f = "&",
|
|
3683
|
+
const f = "&", Oe = "*";
|
|
3683
3684
|
class C {
|
|
3684
3685
|
constructor(t, e, i = [], r, s, a) {
|
|
3685
3686
|
this.recordName = t, this.map = e, this.data = i, this.parentRecord = r, this.attributeName = s, this.shouldQueryParentLinkData = a, this.relatedRecords = [], this.xToManyRecords = [], this.xToOneRecords = [], this.valueAttributes = [], this.id = Math.random();
|
|
@@ -3692,7 +3693,7 @@ class C {
|
|
|
3692
3693
|
this.parentLinkRecordQuery = x.create(y.linkName, this.map, d, void 0);
|
|
3693
3694
|
return;
|
|
3694
3695
|
}
|
|
3695
|
-
if (l ===
|
|
3696
|
+
if (l === Oe) {
|
|
3696
3697
|
o = new Set(this.map.getRecordInfo(this.recordName).valueAttributes.map((y) => y.attributeName));
|
|
3697
3698
|
return;
|
|
3698
3699
|
}
|
|
@@ -3822,7 +3823,7 @@ class C {
|
|
|
3822
3823
|
return this.parentLinkRecordQuery ? new C(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
|
|
3823
3824
|
}
|
|
3824
3825
|
}
|
|
3825
|
-
function
|
|
3826
|
+
function Fe(u) {
|
|
3826
3827
|
const t = [];
|
|
3827
3828
|
return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
|
|
3828
3829
|
}
|
|
@@ -3832,7 +3833,7 @@ class Q {
|
|
|
3832
3833
|
const s = this.map.getRecordInfo(e);
|
|
3833
3834
|
this.recordName = s.isFilteredEntity || s.isFilteredRelation ? s.resolvedBaseRecordName : e;
|
|
3834
3835
|
const [a, o, n] = this.map.groupAttributes(this.recordName, i ? Object.keys(i) : []);
|
|
3835
|
-
this.relatedEntitiesData =
|
|
3836
|
+
this.relatedEntitiesData = Fe(o.map(
|
|
3836
3837
|
(l) => Array.isArray(i[l.attributeName]) ? i[l.attributeName].map((d) => new Q(this.map, l.recordName, d, l)) : new Q(this.map, l.recordName, i[l.attributeName], l)
|
|
3837
3838
|
)), this.valueAttributes = a, this.entityIdAttributes = n;
|
|
3838
3839
|
const c = this.map.getRecordInfo(this.recordName);
|
|
@@ -5523,18 +5524,14 @@ function Je(u, t) {
|
|
|
5523
5524
|
), e.getAll();
|
|
5524
5525
|
}
|
|
5525
5526
|
function te(u, t, e, i) {
|
|
5526
|
-
const r = u.filter((s) =>
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
t,
|
|
5535
|
-
i,
|
|
5536
|
-
e
|
|
5537
|
-
);
|
|
5527
|
+
const r = u.filter((s) => pt(s) !== void 0);
|
|
5528
|
+
for (const s of r)
|
|
5529
|
+
He(
|
|
5530
|
+
s,
|
|
5531
|
+
t,
|
|
5532
|
+
i,
|
|
5533
|
+
e
|
|
5534
|
+
);
|
|
5538
5535
|
}
|
|
5539
5536
|
function He(u, t, e, i) {
|
|
5540
5537
|
const r = e === "entity", a = `__${G(u)}_input_${e}`, o = r ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = Xe(
|
|
@@ -5544,7 +5541,7 @@ function He(u, t, e, i) {
|
|
|
5544
5541
|
t
|
|
5545
5542
|
);
|
|
5546
5543
|
t.replace(n, u), c !== n && t.add(c);
|
|
5547
|
-
const l = pt(u);
|
|
5544
|
+
const l = pt(u) || [];
|
|
5548
5545
|
if (u.commonProperties) {
|
|
5549
5546
|
const d = l.filter((h) => u.commonProperties.some((p) => !h.properties.some((y) => y.name === p.name && y.type === p.type)));
|
|
5550
5547
|
if (d.length > 0)
|
|
@@ -5591,7 +5588,7 @@ function Ke(u, t, e) {
|
|
|
5591
5588
|
name: u,
|
|
5592
5589
|
type: "json",
|
|
5593
5590
|
defaultValue: (r, s) => {
|
|
5594
|
-
const a = pt(t), n = (i.get(s) || []).filter(
|
|
5591
|
+
const a = pt(t) || [], n = (i.get(s) || []).filter(
|
|
5595
5592
|
(c) => a.some((l) => G(l) === c)
|
|
5596
5593
|
);
|
|
5597
5594
|
return n.length > 0 ? n : [s];
|
|
@@ -5599,7 +5596,7 @@ function Ke(u, t, e) {
|
|
|
5599
5596
|
});
|
|
5600
5597
|
}
|
|
5601
5598
|
function Ge(u, t, e) {
|
|
5602
|
-
const i = pt(u), r = [], s = /* @__PURE__ */ new Map(), a =
|
|
5599
|
+
const i = pt(u) || [], r = [], s = /* @__PURE__ */ new Map(), a = Object.fromEntries(u.commonProperties?.map((o) => [o.name, o]) || []);
|
|
5603
5600
|
for (const o of i) {
|
|
5604
5601
|
let n = o;
|
|
5605
5602
|
if (ht(n))
|
|
@@ -5738,7 +5735,7 @@ function Ze(u) {
|
|
|
5738
5735
|
return "sourceProperty" in u;
|
|
5739
5736
|
}
|
|
5740
5737
|
function pt(u) {
|
|
5741
|
-
return ht(u) ? u.inputEntities
|
|
5738
|
+
return ht(u) ? u.inputEntities : u.inputRelations;
|
|
5742
5739
|
}
|
|
5743
5740
|
function G(u) {
|
|
5744
5741
|
return ht(u), u.name;
|
|
@@ -7961,12 +7958,12 @@ class $i extends At {
|
|
|
7961
7958
|
this.contextType = "entity";
|
|
7962
7959
|
}
|
|
7963
7960
|
}
|
|
7964
|
-
class
|
|
7961
|
+
class Oi extends At {
|
|
7965
7962
|
static {
|
|
7966
7963
|
this.contextType = "relation";
|
|
7967
7964
|
}
|
|
7968
7965
|
}
|
|
7969
|
-
class
|
|
7966
|
+
class Fi extends At {
|
|
7970
7967
|
static {
|
|
7971
7968
|
this.contextType = "property";
|
|
7972
7969
|
}
|
|
@@ -7984,8 +7981,8 @@ If you want to use aggregated data from all records in the entity/relation, you
|
|
|
7984
7981
|
const Di = [
|
|
7985
7982
|
Pi,
|
|
7986
7983
|
$i,
|
|
7987
|
-
|
|
7988
|
-
|
|
7984
|
+
Oi,
|
|
7985
|
+
Fi
|
|
7989
7986
|
];
|
|
7990
7987
|
class W extends Error {
|
|
7991
7988
|
constructor(t, e = {}) {
|
|
@@ -8104,7 +8101,7 @@ Stack trace:`, r.stack.split(`
|
|
|
8104
8101
|
return null;
|
|
8105
8102
|
}
|
|
8106
8103
|
}
|
|
8107
|
-
var
|
|
8104
|
+
var F = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(F || {}), H = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(H || {});
|
|
8108
8105
|
class z extends W {
|
|
8109
8106
|
constructor(t, e = {}) {
|
|
8110
8107
|
super(t, {
|
|
@@ -8118,7 +8115,7 @@ class z extends W {
|
|
|
8118
8115
|
...e.context
|
|
8119
8116
|
},
|
|
8120
8117
|
causedBy: e.causedBy
|
|
8121
|
-
}), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity ||
|
|
8118
|
+
}), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || F.HIGH;
|
|
8122
8119
|
}
|
|
8123
8120
|
}
|
|
8124
8121
|
class re extends W {
|
|
@@ -8134,7 +8131,7 @@ class re extends W {
|
|
|
8134
8131
|
...e.context
|
|
8135
8132
|
},
|
|
8136
8133
|
causedBy: e.causedBy
|
|
8137
|
-
}), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity ||
|
|
8134
|
+
}), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || F.MEDIUM;
|
|
8138
8135
|
}
|
|
8139
8136
|
}
|
|
8140
8137
|
class V extends W {
|
|
@@ -8150,14 +8147,14 @@ class V extends W {
|
|
|
8150
8147
|
...e.context
|
|
8151
8148
|
},
|
|
8152
8149
|
causedBy: e.causedBy
|
|
8153
|
-
}), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity ||
|
|
8150
|
+
}), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || F.MEDIUM;
|
|
8154
8151
|
}
|
|
8155
8152
|
}
|
|
8156
8153
|
class se extends V {
|
|
8157
8154
|
constructor(t, e = {}) {
|
|
8158
8155
|
super(t, {
|
|
8159
8156
|
...e,
|
|
8160
|
-
severity:
|
|
8157
|
+
severity: F.HIGH,
|
|
8161
8158
|
context: {
|
|
8162
8159
|
errorType: "ComputationStateError",
|
|
8163
8160
|
stateKey: e.stateKey,
|
|
@@ -8172,7 +8169,7 @@ class J extends V {
|
|
|
8172
8169
|
constructor(t, e = {}) {
|
|
8173
8170
|
super(t, {
|
|
8174
8171
|
...e,
|
|
8175
|
-
severity:
|
|
8172
|
+
severity: F.MEDIUM,
|
|
8176
8173
|
context: {
|
|
8177
8174
|
errorType: "ComputationDataDepError",
|
|
8178
8175
|
depName: e.depName,
|
|
@@ -8194,7 +8191,7 @@ class It extends W {
|
|
|
8194
8191
|
...e.context
|
|
8195
8192
|
},
|
|
8196
8193
|
causedBy: e.causedBy
|
|
8197
|
-
}), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity =
|
|
8194
|
+
}), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = F.HIGH;
|
|
8198
8195
|
}
|
|
8199
8196
|
}
|
|
8200
8197
|
class Vi extends W {
|
|
@@ -8210,10 +8207,10 @@ class Vi extends W {
|
|
|
8210
8207
|
...e.context
|
|
8211
8208
|
},
|
|
8212
8209
|
causedBy: e.causedBy
|
|
8213
|
-
}), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity =
|
|
8210
|
+
}), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity = F.MEDIUM;
|
|
8214
8211
|
}
|
|
8215
8212
|
}
|
|
8216
|
-
class
|
|
8213
|
+
class O extends W {
|
|
8217
8214
|
constructor(t, e) {
|
|
8218
8215
|
super(t, {
|
|
8219
8216
|
errorType: e.context?.errorType || "ConditionError",
|
|
@@ -8226,16 +8223,16 @@ class F extends W {
|
|
|
8226
8223
|
...e.context
|
|
8227
8224
|
},
|
|
8228
8225
|
causedBy: e.causedBy
|
|
8229
|
-
}), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity ||
|
|
8226
|
+
}), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || F.HIGH;
|
|
8230
8227
|
}
|
|
8231
8228
|
/**
|
|
8232
8229
|
* Helper factory methods for common condition error scenarios
|
|
8233
8230
|
*/
|
|
8234
8231
|
static userCheckFailed(t, e) {
|
|
8235
|
-
return new
|
|
8232
|
+
return new O("User check failed", {
|
|
8236
8233
|
checkType: "user",
|
|
8237
8234
|
evaluationError: t,
|
|
8238
|
-
severity:
|
|
8235
|
+
severity: F.HIGH,
|
|
8239
8236
|
context: e,
|
|
8240
8237
|
type: "check user failed"
|
|
8241
8238
|
// For backward compatibility
|
|
@@ -8243,21 +8240,21 @@ class F extends W {
|
|
|
8243
8240
|
}
|
|
8244
8241
|
static payloadValidationFailed(t, e, i, r) {
|
|
8245
8242
|
const s = `${t} ${e}`;
|
|
8246
|
-
return new
|
|
8243
|
+
return new O(`Payload validation failed for field '${t}': ${e}`, {
|
|
8247
8244
|
checkType: "payload",
|
|
8248
8245
|
fieldName: t,
|
|
8249
8246
|
payload: i,
|
|
8250
8247
|
evaluationError: r,
|
|
8251
|
-
severity:
|
|
8248
|
+
severity: F.MEDIUM,
|
|
8252
8249
|
type: s
|
|
8253
8250
|
// For backward compatibility
|
|
8254
8251
|
});
|
|
8255
8252
|
}
|
|
8256
8253
|
static conditionCheckFailed(t, e) {
|
|
8257
|
-
return new
|
|
8254
|
+
return new O(`Condition check failed: ${t.data.name}`, {
|
|
8258
8255
|
checkType: "condition",
|
|
8259
8256
|
evaluationError: t,
|
|
8260
|
-
severity:
|
|
8257
|
+
severity: F.HIGH,
|
|
8261
8258
|
context: e,
|
|
8262
8259
|
type: "condition check failed"
|
|
8263
8260
|
// For backward compatibility
|
|
@@ -8265,22 +8262,22 @@ class F extends W {
|
|
|
8265
8262
|
}
|
|
8266
8263
|
static attributiveCheckFailed(t, e, i, r) {
|
|
8267
8264
|
const s = `${t} ${e}`;
|
|
8268
|
-
return new
|
|
8265
|
+
return new O(`Attributive check failed for field '${t}': ${e}`, {
|
|
8269
8266
|
checkType: "attributive",
|
|
8270
8267
|
fieldName: t,
|
|
8271
8268
|
payload: i,
|
|
8272
8269
|
evaluationError: r,
|
|
8273
|
-
severity:
|
|
8270
|
+
severity: F.MEDIUM,
|
|
8274
8271
|
type: s
|
|
8275
8272
|
// For backward compatibility
|
|
8276
8273
|
});
|
|
8277
8274
|
}
|
|
8278
8275
|
static conceptCheckFailed(t, e) {
|
|
8279
|
-
return new
|
|
8276
|
+
return new O(`Concept check failed for field '${t}'`, {
|
|
8280
8277
|
checkType: "concept",
|
|
8281
8278
|
fieldName: t,
|
|
8282
8279
|
evaluationError: e,
|
|
8283
|
-
severity:
|
|
8280
|
+
severity: F.MEDIUM,
|
|
8284
8281
|
type: `${t} check concept failed`
|
|
8285
8282
|
// For backward compatibility
|
|
8286
8283
|
});
|
|
@@ -8872,7 +8869,7 @@ class we {
|
|
|
8872
8869
|
this.interaction.userAttributives
|
|
8873
8870
|
), a = (o) => o.isRef ? i(o, t.user, e) : this.checkAttributive(o, t, t.user);
|
|
8874
8871
|
if (r = await this.checkAttributives(s, a, []), r === !0) return r;
|
|
8875
|
-
throw
|
|
8872
|
+
throw O.userCheckFailed(r);
|
|
8876
8873
|
}
|
|
8877
8874
|
// 用来check attributive 形容的后面的 target 到底是不是那个概念的实例。
|
|
8878
8875
|
async checkConcept(t, e, i, r = []) {
|
|
@@ -8920,25 +8917,25 @@ class we {
|
|
|
8920
8917
|
throw new Error(`${s} in payload is not defined in interaction ${this.interaction.name}`);
|
|
8921
8918
|
for (let s of i) {
|
|
8922
8919
|
if (s.required && !(s.name in e))
|
|
8923
|
-
throw
|
|
8920
|
+
throw O.payloadValidationFailed(s.name, "missing", e);
|
|
8924
8921
|
const a = e[s.name];
|
|
8925
8922
|
if (a === void 0) return;
|
|
8926
8923
|
if (s.isCollection && !Array.isArray(a))
|
|
8927
|
-
throw
|
|
8924
|
+
throw O.payloadValidationFailed(s.name, "data is not array", a);
|
|
8928
8925
|
if (s.isCollection) {
|
|
8929
8926
|
if (s.isRef && !a.every((o) => !!o.id))
|
|
8930
|
-
throw
|
|
8927
|
+
throw O.payloadValidationFailed(s.name, "data not every is ref", a);
|
|
8931
8928
|
} else if (s.isRef && !a.id)
|
|
8932
|
-
throw
|
|
8929
|
+
throw O.payloadValidationFailed(s.name, "data is not a ref", a);
|
|
8933
8930
|
if (s.base)
|
|
8934
8931
|
if (s.isCollection) {
|
|
8935
8932
|
const o = await ai(a, (n) => this.checkConcept(n, s.base));
|
|
8936
8933
|
if (o !== !0)
|
|
8937
|
-
throw
|
|
8934
|
+
throw O.conceptCheckFailed(s.name, o);
|
|
8938
8935
|
} else {
|
|
8939
8936
|
const o = await this.checkConcept(a, s.base);
|
|
8940
8937
|
if (o !== !0)
|
|
8941
|
-
throw
|
|
8938
|
+
throw O.conceptCheckFailed(s.name, o);
|
|
8942
8939
|
}
|
|
8943
8940
|
if (s.isRef) {
|
|
8944
8941
|
const o = s.isCollection ? m.atom({
|
|
@@ -8970,7 +8967,7 @@ class we {
|
|
|
8970
8967
|
return !0;
|
|
8971
8968
|
}, r = await e.evaluateAsync(i);
|
|
8972
8969
|
if (r !== !0)
|
|
8973
|
-
throw
|
|
8970
|
+
throw O.conditionCheckFailed(r);
|
|
8974
8971
|
}
|
|
8975
8972
|
}
|
|
8976
8973
|
// CAUTION sideEffect 是并行的。如果要串行,用户应该自己写在一个里面
|
|
@@ -9491,10 +9488,10 @@ class ke {
|
|
|
9491
9488
|
return new ke(t);
|
|
9492
9489
|
}
|
|
9493
9490
|
}
|
|
9494
|
-
const
|
|
9491
|
+
const Ot = "_isDeleted_", Rr = {
|
|
9495
9492
|
create() {
|
|
9496
9493
|
return v.create({
|
|
9497
|
-
name:
|
|
9494
|
+
name: Ot,
|
|
9498
9495
|
type: "boolean"
|
|
9499
9496
|
});
|
|
9500
9497
|
}
|
|
@@ -9571,7 +9568,7 @@ class wr {
|
|
|
9571
9568
|
await this.system.storage.create(r.id.name, a);
|
|
9572
9569
|
} else {
|
|
9573
9570
|
const r = t;
|
|
9574
|
-
r.id.name ===
|
|
9571
|
+
r.id.name === Ot && e ? await this.system.storage.delete(r.host.name, R.atom({ key: "id", value: ["=", i.id] })) : await this.system.storage.update(r.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [r.id.name]: e });
|
|
9575
9572
|
}
|
|
9576
9573
|
}
|
|
9577
9574
|
}
|
|
@@ -9594,7 +9591,7 @@ class wr {
|
|
|
9594
9591
|
}
|
|
9595
9592
|
} else {
|
|
9596
9593
|
const a = t;
|
|
9597
|
-
a.id.name ===
|
|
9594
|
+
a.id.name === Ot && s.data ? (T(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 });
|
|
9598
9595
|
}
|
|
9599
9596
|
}
|
|
9600
9597
|
}
|
|
@@ -9835,7 +9832,7 @@ class vr {
|
|
|
9835
9832
|
}
|
|
9836
9833
|
export {
|
|
9837
9834
|
yt as ACTIVITY_RECORD,
|
|
9838
|
-
|
|
9835
|
+
Oe as ALL_ATTR_SYMBOL,
|
|
9839
9836
|
Ct as ASYNC_TASK_RECORD,
|
|
9840
9837
|
vt as Action,
|
|
9841
9838
|
Lt as Activity,
|
|
@@ -9865,7 +9862,7 @@ export {
|
|
|
9865
9862
|
Rt as ComputationResultSkip,
|
|
9866
9863
|
se as ComputationStateError,
|
|
9867
9864
|
qt as Condition,
|
|
9868
|
-
|
|
9865
|
+
O as ConditionError,
|
|
9869
9866
|
Tt as Conditions,
|
|
9870
9867
|
wr as Controller,
|
|
9871
9868
|
ot as Count,
|
|
@@ -9903,7 +9900,7 @@ export {
|
|
|
9903
9900
|
oi as GlobalStateMachineHandle,
|
|
9904
9901
|
Si as GlobalSumHandle,
|
|
9905
9902
|
li as GlobalWeightedSummationHandle,
|
|
9906
|
-
|
|
9903
|
+
Ot as HARD_DELETION_PROPERTY_NAME,
|
|
9907
9904
|
Rr as HardDeletionProperty,
|
|
9908
9905
|
ee as ID_ATTR,
|
|
9909
9906
|
$t as INTERACTION_RECORD,
|
|
@@ -9911,7 +9908,7 @@ export {
|
|
|
9911
9908
|
Qt as Interaction,
|
|
9912
9909
|
we as InteractionCall,
|
|
9913
9910
|
Ne as InteractionEventEntity,
|
|
9914
|
-
|
|
9911
|
+
Ft as KlassByName,
|
|
9915
9912
|
f as LINK_SYMBOL,
|
|
9916
9913
|
bt as LinkInfo,
|
|
9917
9914
|
m as MatchExp,
|
|
@@ -9929,7 +9926,7 @@ export {
|
|
|
9929
9926
|
yi as PropertyAnyHandle,
|
|
9930
9927
|
xi as PropertyAverageHandle,
|
|
9931
9928
|
Ri as PropertyCountHandle,
|
|
9932
|
-
|
|
9929
|
+
Fi as PropertyCustomHandle,
|
|
9933
9930
|
pi as PropertyEveryHandle,
|
|
9934
9931
|
Ti as PropertyRealTimeComputation,
|
|
9935
9932
|
ni as PropertyStateMachineHandle,
|
|
@@ -9950,7 +9947,7 @@ export {
|
|
|
9950
9947
|
gt as RecursiveContext,
|
|
9951
9948
|
fe as RefContainer,
|
|
9952
9949
|
P as Relation,
|
|
9953
|
-
|
|
9950
|
+
Oi as RelationCustomHandle,
|
|
9954
9951
|
X as SYSTEM_RECORD,
|
|
9955
9952
|
Qi as Scheduler,
|
|
9956
9953
|
jt as SideEffect,
|