interaqt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/ActivityCall.d.ts +68 -0
- package/dist/runtime/ActivityCall.d.ts.map +1 -0
- package/dist/runtime/ActivityCall.js +379 -0
- package/dist/runtime/ActivityCall.js.map +1 -0
- package/dist/runtime/Controller.d.ts +60 -0
- package/dist/runtime/Controller.d.ts.map +1 -0
- package/dist/runtime/Controller.js +225 -0
- package/dist/runtime/Controller.js.map +1 -0
- package/dist/runtime/InteractionCall.d.ts +102 -0
- package/dist/runtime/InteractionCall.d.ts.map +1 -0
- package/dist/runtime/InteractionCall.js +385 -0
- package/dist/runtime/InteractionCall.js.map +1 -0
- package/dist/runtime/MonoSystem.d.ts +26 -0
- package/dist/runtime/MonoSystem.d.ts.map +1 -0
- package/dist/runtime/MonoSystem.js +331 -0
- package/dist/runtime/MonoSystem.js.map +1 -0
- package/dist/runtime/Mysql.d.ts +35 -0
- package/dist/runtime/Mysql.d.ts.map +1 -0
- package/dist/runtime/Mysql.js +171 -0
- package/dist/runtime/Mysql.js.map +1 -0
- package/dist/runtime/PostgreSQL.d.ts +36 -0
- package/dist/runtime/PostgreSQL.d.ts.map +1 -0
- package/dist/runtime/PostgreSQL.js +172 -0
- package/dist/runtime/PostgreSQL.js.map +1 -0
- package/dist/runtime/SQLite.d.ts +34 -0
- package/dist/runtime/SQLite.d.ts.map +1 -0
- package/dist/runtime/SQLite.js +146 -0
- package/dist/runtime/SQLite.js.map +1 -0
- package/dist/runtime/Scheduler.d.ts +81 -0
- package/dist/runtime/Scheduler.d.ts.map +1 -0
- package/dist/runtime/Scheduler.js +457 -0
- package/dist/runtime/Scheduler.js.map +1 -0
- package/dist/runtime/System.d.ts +312 -0
- package/dist/runtime/System.d.ts.map +1 -0
- package/dist/runtime/System.js +90 -0
- package/dist/runtime/System.js.map +1 -0
- package/dist/runtime/asyncInteractionContext.d.ts +3 -0
- package/dist/runtime/asyncInteractionContext.d.ts.map +1 -0
- package/dist/runtime/asyncInteractionContext.js +3 -0
- package/dist/runtime/asyncInteractionContext.js.map +1 -0
- package/dist/runtime/boolExpression.d.ts +23 -0
- package/dist/runtime/boolExpression.d.ts.map +1 -0
- package/dist/runtime/boolExpression.js +43 -0
- package/dist/runtime/boolExpression.js.map +1 -0
- package/dist/runtime/computedDataHandles/Any.d.ts +52 -0
- package/dist/runtime/computedDataHandles/Any.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/Any.js +152 -0
- package/dist/runtime/computedDataHandles/Any.js.map +1 -0
- package/dist/runtime/computedDataHandles/Computation.d.ts +108 -0
- package/dist/runtime/computedDataHandles/Computation.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/Computation.js +49 -0
- package/dist/runtime/computedDataHandles/Computation.js.map +1 -0
- package/dist/runtime/computedDataHandles/ComputedDataHandle.d.ts +42 -0
- package/dist/runtime/computedDataHandles/ComputedDataHandle.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/ComputedDataHandle.js +4 -0
- package/dist/runtime/computedDataHandles/ComputedDataHandle.js.map +1 -0
- package/dist/runtime/computedDataHandles/Count.d.ts +45 -0
- package/dist/runtime/computedDataHandles/Count.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/Count.js +85 -0
- package/dist/runtime/computedDataHandles/Count.js.map +1 -0
- package/dist/runtime/computedDataHandles/Every.d.ts +56 -0
- package/dist/runtime/computedDataHandles/Every.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/Every.js +178 -0
- package/dist/runtime/computedDataHandles/Every.js.map +1 -0
- package/dist/runtime/computedDataHandles/StateMachine.d.ts +74 -0
- package/dist/runtime/computedDataHandles/StateMachine.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/StateMachine.js +180 -0
- package/dist/runtime/computedDataHandles/StateMachine.js.map +1 -0
- package/dist/runtime/computedDataHandles/Transform.d.ts +26 -0
- package/dist/runtime/computedDataHandles/Transform.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/Transform.js +106 -0
- package/dist/runtime/computedDataHandles/Transform.js.map +1 -0
- package/dist/runtime/computedDataHandles/TransitionFinder.d.ts +57 -0
- package/dist/runtime/computedDataHandles/TransitionFinder.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/TransitionFinder.js +40 -0
- package/dist/runtime/computedDataHandles/TransitionFinder.js.map +1 -0
- package/dist/runtime/computedDataHandles/WeightedSummation.d.ts +57 -0
- package/dist/runtime/computedDataHandles/WeightedSummation.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/WeightedSummation.js +146 -0
- package/dist/runtime/computedDataHandles/WeightedSummation.js.map +1 -0
- package/dist/runtime/computedDataHandles/index.d.ts +7 -0
- package/dist/runtime/computedDataHandles/index.d.ts.map +1 -0
- package/dist/runtime/computedDataHandles/index.js +7 -0
- package/dist/runtime/computedDataHandles/index.js.map +1 -0
- package/dist/runtime/index.d.ts +15 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/server.d.ts +35 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +171 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/runtime/types/boolExpression.d.ts +22 -0
- package/dist/runtime/types/boolExpression.d.ts.map +1 -0
- package/dist/runtime/types/boolExpression.js +6 -0
- package/dist/runtime/types/boolExpression.js.map +1 -0
- package/dist/runtime/util.d.ts +10 -0
- package/dist/runtime/util.d.ts.map +1 -0
- package/dist/runtime/util.js +39 -0
- package/dist/runtime/util.js.map +1 -0
- package/dist/shared/BoolExp.d.ts +97 -0
- package/dist/shared/BoolExp.d.ts.map +1 -0
- package/dist/shared/BoolExp.js +252 -0
- package/dist/shared/BoolExp.js.map +1 -0
- package/dist/shared/activity/Activity.d.ts +465 -0
- package/dist/shared/activity/Activity.d.ts.map +1 -0
- package/dist/shared/activity/Activity.js +264 -0
- package/dist/shared/activity/Activity.js.map +1 -0
- package/dist/shared/activity/Condition.d.ts +75 -0
- package/dist/shared/activity/Condition.d.ts.map +1 -0
- package/dist/shared/activity/Condition.js +51 -0
- package/dist/shared/activity/Condition.js.map +1 -0
- package/dist/shared/activity/Data.d.ts +115 -0
- package/dist/shared/activity/Data.d.ts.map +1 -0
- package/dist/shared/activity/Data.js +89 -0
- package/dist/shared/activity/Data.js.map +1 -0
- package/dist/shared/attributive.d.ts +93 -0
- package/dist/shared/attributive.d.ts.map +1 -0
- package/dist/shared/attributive.js +59 -0
- package/dist/shared/attributive.js.map +1 -0
- package/dist/shared/computed.d.ts +607 -0
- package/dist/shared/computed.d.ts.map +1 -0
- package/dist/shared/computed.js +202 -0
- package/dist/shared/computed.js.map +1 -0
- package/dist/shared/createClass.d.ts +102 -0
- package/dist/shared/createClass.d.ts.map +1 -0
- package/dist/shared/createClass.js +276 -0
- package/dist/shared/createClass.js.map +1 -0
- package/dist/shared/dictionary/Dictionary.d.ts +40 -0
- package/dist/shared/dictionary/Dictionary.d.ts.map +1 -0
- package/dist/shared/dictionary/Dictionary.js +51 -0
- package/dist/shared/dictionary/Dictionary.js.map +1 -0
- package/dist/shared/entity/Entity.d.ts +149 -0
- package/dist/shared/entity/Entity.d.ts.map +1 -0
- package/dist/shared/entity/Entity.js +226 -0
- package/dist/shared/entity/Entity.js.map +1 -0
- package/dist/shared/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +11 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/user/User.d.ts +21 -0
- package/dist/shared/user/User.d.ts.map +1 -0
- package/dist/shared/user/User.js +11 -0
- package/dist/shared/user/User.js.map +1 -0
- package/dist/shared/utils.d.ts +11 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +19 -0
- package/dist/shared/utils.js.map +1 -0
- package/dist/storage/erstorage/AttributeInfo.d.ts +40 -0
- package/dist/storage/erstorage/AttributeInfo.d.ts.map +1 -0
- package/dist/storage/erstorage/AttributeInfo.js +147 -0
- package/dist/storage/erstorage/AttributeInfo.js.map +1 -0
- package/dist/storage/erstorage/AttributeQuery.d.ts +33 -0
- package/dist/storage/erstorage/AttributeQuery.d.ts.map +1 -0
- package/dist/storage/erstorage/AttributeQuery.js +190 -0
- package/dist/storage/erstorage/AttributeQuery.js.map +1 -0
- package/dist/storage/erstorage/EntityQueryHandle.d.ts +29 -0
- package/dist/storage/erstorage/EntityQueryHandle.d.ts.map +1 -0
- package/dist/storage/erstorage/EntityQueryHandle.js +78 -0
- package/dist/storage/erstorage/EntityQueryHandle.js.map +1 -0
- package/dist/storage/erstorage/EntityToTableMap.d.ts +85 -0
- package/dist/storage/erstorage/EntityToTableMap.d.ts.map +1 -0
- package/dist/storage/erstorage/EntityToTableMap.js +262 -0
- package/dist/storage/erstorage/EntityToTableMap.js.map +1 -0
- package/dist/storage/erstorage/LinkInfo.d.ts +35 -0
- package/dist/storage/erstorage/LinkInfo.d.ts.map +1 -0
- package/dist/storage/erstorage/LinkInfo.js +89 -0
- package/dist/storage/erstorage/LinkInfo.js.map +1 -0
- package/dist/storage/erstorage/MatchExp.d.ts +37 -0
- package/dist/storage/erstorage/MatchExp.d.ts.map +1 -0
- package/dist/storage/erstorage/MatchExp.js +211 -0
- package/dist/storage/erstorage/MatchExp.js.map +1 -0
- package/dist/storage/erstorage/Modifier.d.ts +23 -0
- package/dist/storage/erstorage/Modifier.d.ts.map +1 -0
- package/dist/storage/erstorage/Modifier.js +24 -0
- package/dist/storage/erstorage/Modifier.js.map +1 -0
- package/dist/storage/erstorage/NewRecordData.d.ts +42 -0
- package/dist/storage/erstorage/NewRecordData.d.ts.map +1 -0
- package/dist/storage/erstorage/NewRecordData.js +178 -0
- package/dist/storage/erstorage/NewRecordData.js.map +1 -0
- package/dist/storage/erstorage/RecordInfo.d.ts +26 -0
- package/dist/storage/erstorage/RecordInfo.d.ts.map +1 -0
- package/dist/storage/erstorage/RecordInfo.js +111 -0
- package/dist/storage/erstorage/RecordInfo.js.map +1 -0
- package/dist/storage/erstorage/RecordQuery.d.ts +73 -0
- package/dist/storage/erstorage/RecordQuery.d.ts.map +1 -0
- package/dist/storage/erstorage/RecordQuery.js +158 -0
- package/dist/storage/erstorage/RecordQuery.js.map +1 -0
- package/dist/storage/erstorage/RecordQueryAgent.d.ts +84 -0
- package/dist/storage/erstorage/RecordQueryAgent.d.ts.map +1 -0
- package/dist/storage/erstorage/RecordQueryAgent.js +1130 -0
- package/dist/storage/erstorage/RecordQueryAgent.js.map +1 -0
- package/dist/storage/erstorage/Setup.d.ts +49 -0
- package/dist/storage/erstorage/Setup.d.ts.map +1 -0
- package/dist/storage/erstorage/Setup.js +400 -0
- package/dist/storage/erstorage/Setup.js.map +1 -0
- package/dist/storage/erstorage/util.d.ts +6 -0
- package/dist/storage/erstorage/util.d.ts.map +1 -0
- package/dist/storage/erstorage/util.js +25 -0
- package/dist/storage/erstorage/util.js.map +1 -0
- package/dist/storage/index.d.ts +13 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +13 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/utils.d.ts +10 -0
- package/dist/storage/utils.d.ts.map +1 -0
- package/dist/storage/utils.js +48 -0
- package/dist/storage/utils.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ComputedDataHandle } from "./ComputedDataHandle.js";
|
|
2
|
+
import { Any } from "@shared";
|
|
3
|
+
import { GlobalBoundState, RecordBoundState, RelationBoundState } from "./Computation.js";
|
|
4
|
+
import { MatchExp } from "@storage";
|
|
5
|
+
export class GlobalAnyHandle {
|
|
6
|
+
constructor(controller, args, dataContext) {
|
|
7
|
+
this.controller = controller;
|
|
8
|
+
this.dataContext = dataContext;
|
|
9
|
+
this.useLastValue = true;
|
|
10
|
+
this.dataDeps = {};
|
|
11
|
+
this.callback = args.callback.bind(this);
|
|
12
|
+
this.dataDeps = {
|
|
13
|
+
main: {
|
|
14
|
+
type: 'records',
|
|
15
|
+
source: args.record,
|
|
16
|
+
attributeQuery: args.attributeQuery
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
createState() {
|
|
21
|
+
return {
|
|
22
|
+
matchCount: new GlobalBoundState(0),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getDefaultValue() {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
async compute({ main: records }) {
|
|
29
|
+
// TODO deps
|
|
30
|
+
const matchCount = await this.state.matchCount.set(records.filter(this.callback).length);
|
|
31
|
+
return matchCount > 0;
|
|
32
|
+
}
|
|
33
|
+
async incrementalCompute(lastValue, mutationEvent) {
|
|
34
|
+
let matchCount = await this.state.matchCount.get();
|
|
35
|
+
if (mutationEvent.type === 'create') {
|
|
36
|
+
const newItemMatch = !!this.callback.call(this.controller, mutationEvent.record);
|
|
37
|
+
if (newItemMatch === true) {
|
|
38
|
+
matchCount = await this.state.matchCount.set(matchCount + 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (mutationEvent.type === 'delete') {
|
|
42
|
+
const oldItemMatch = !!this.callback.call(this.controller, mutationEvent.record);
|
|
43
|
+
if (oldItemMatch === true) {
|
|
44
|
+
matchCount = await this.state.matchCount.set(matchCount - 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (mutationEvent.type === 'update') {
|
|
48
|
+
const oldItemMatch = !!this.callback.call(this.controller, mutationEvent.oldRecord);
|
|
49
|
+
const newItemMatch = !!this.callback.call(this.controller, mutationEvent.record);
|
|
50
|
+
if (oldItemMatch === true && newItemMatch === false) {
|
|
51
|
+
matchCount = await this.state.matchCount.set(matchCount - 1);
|
|
52
|
+
}
|
|
53
|
+
else if (oldItemMatch === false && newItemMatch === true) {
|
|
54
|
+
matchCount = await this.state.matchCount.set(matchCount + 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return matchCount > 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class PropertyAnyHandle {
|
|
61
|
+
constructor(controller, args, dataContext) {
|
|
62
|
+
this.controller = controller;
|
|
63
|
+
this.dataContext = dataContext;
|
|
64
|
+
this.useLastValue = true;
|
|
65
|
+
this.dataDeps = {};
|
|
66
|
+
this.callback = args.callback.bind(this);
|
|
67
|
+
const relation = args.record;
|
|
68
|
+
this.relation = relation;
|
|
69
|
+
this.isSource = args.direction ? args.direction === 'source' : relation.source.name === dataContext.host.name;
|
|
70
|
+
this.relationAttr = this.isSource ? relation.sourceProperty : relation.targetProperty;
|
|
71
|
+
this.relatedRecordName = this.isSource ? relation.target.name : relation.source.name;
|
|
72
|
+
this.relationAttributeQuery = args.attributeQuery || [];
|
|
73
|
+
this.dataDeps = {
|
|
74
|
+
_current: {
|
|
75
|
+
type: 'property',
|
|
76
|
+
attributeQuery: [[this.relationAttr, { attributeQuery: [['&', { attributeQuery: this.relationAttributeQuery }]] }]]
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
createState() {
|
|
81
|
+
return {
|
|
82
|
+
matchCount: new RecordBoundState(0),
|
|
83
|
+
isItemMatch: new RelationBoundState(false, this.relation.name)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
getDefaultValue() {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
async compute({ _current }) {
|
|
90
|
+
const matchCount = await this.state.matchCount.set(_current, _current[this.relationAttr].filter(this.callback).length);
|
|
91
|
+
return matchCount > 0;
|
|
92
|
+
}
|
|
93
|
+
async incrementalCompute(lastValue, mutationEvent) {
|
|
94
|
+
// TODO 如果未来支持用户可以自定义 dataDeps,那么这里也要支持如果发现是其他 dataDeps 变化,这里要直接返回重算的信号。
|
|
95
|
+
let matchCount = await this.state.matchCount.get(mutationEvent.record);
|
|
96
|
+
const relatedMutationEvent = mutationEvent.relatedMutationEvent;
|
|
97
|
+
if (relatedMutationEvent.type === 'create') {
|
|
98
|
+
// 关联关系的新建
|
|
99
|
+
const relationRecord = relatedMutationEvent.record;
|
|
100
|
+
const newRelationWithEntity = await this.controller.system.storage.findOne(this.relation.name, MatchExp.atom({
|
|
101
|
+
key: 'id',
|
|
102
|
+
value: ['=', relationRecord.id]
|
|
103
|
+
}), undefined, this.relationAttributeQuery);
|
|
104
|
+
const newItemMatch = !!this.callback.call(this.controller, newRelationWithEntity);
|
|
105
|
+
if (newItemMatch === true) {
|
|
106
|
+
matchCount = await this.state.matchCount.set(mutationEvent.record, matchCount + 1);
|
|
107
|
+
await this.state.isItemMatch.set(relationRecord, true);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (relatedMutationEvent.type === 'delete') {
|
|
111
|
+
// 关联关系的删除
|
|
112
|
+
const relationRecord = relatedMutationEvent.record;
|
|
113
|
+
const oldItemMatch = !!await this.state.isItemMatch.get(relationRecord);
|
|
114
|
+
if (oldItemMatch === true) {
|
|
115
|
+
matchCount = await this.state.matchCount.set(mutationEvent.record, matchCount - 1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (relatedMutationEvent.type === 'update') {
|
|
119
|
+
// 关联实体或者关联关系上的字段的更新
|
|
120
|
+
const currentRecord = mutationEvent.oldRecord;
|
|
121
|
+
const isRelationUpdate = mutationEvent.relatedMutationEvent?.recordName === this.relation.name;
|
|
122
|
+
const relationMatch = isRelationUpdate ?
|
|
123
|
+
MatchExp.atom({
|
|
124
|
+
key: 'id',
|
|
125
|
+
value: ['=', mutationEvent.relatedMutationEvent.oldRecord.id]
|
|
126
|
+
}) :
|
|
127
|
+
MatchExp.atom({
|
|
128
|
+
key: 'source.id',
|
|
129
|
+
value: ['=', this.isSource ? currentRecord.id : mutationEvent.relatedMutationEvent.oldRecord.id]
|
|
130
|
+
}).and({
|
|
131
|
+
key: 'target.id',
|
|
132
|
+
value: ['=', this.isSource ? mutationEvent.relatedMutationEvent.oldRecord.id : currentRecord.id]
|
|
133
|
+
});
|
|
134
|
+
const relationRecord = await this.controller.system.storage.findOne(this.relation.name, relationMatch, undefined, this.relationAttributeQuery);
|
|
135
|
+
const oldItemMatch = !!await this.state.isItemMatch.get(relationRecord);
|
|
136
|
+
const newItemMatch = !!this.callback.call(this.controller, relationRecord);
|
|
137
|
+
if (oldItemMatch === true && newItemMatch === false) {
|
|
138
|
+
matchCount = await this.state.matchCount.set(currentRecord, matchCount - 1);
|
|
139
|
+
}
|
|
140
|
+
else if (oldItemMatch === false && newItemMatch === true) {
|
|
141
|
+
matchCount = await this.state.matchCount.set(currentRecord, matchCount + 1);
|
|
142
|
+
}
|
|
143
|
+
await this.state.isItemMatch.set(relationRecord, newItemMatch);
|
|
144
|
+
}
|
|
145
|
+
return matchCount > 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
ComputedDataHandle.Handles.set(Any, {
|
|
149
|
+
global: GlobalAnyHandle,
|
|
150
|
+
property: PropertyAnyHandle
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=Any.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Any.js","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/Any.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAoC,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,GAAG,EAA2B,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAW,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGnG,OAAO,EAAE,QAAQ,EAAsB,MAAM,UAAU,CAAC;AAGxD,MAAM,OAAO,eAAe;IAKxB,YAAmB,UAAsB,EAAG,IAA+B,EAAU,WAAwB;QAA1F,eAAU,GAAV,UAAU,CAAY;QAA4C,gBAAW,GAAX,WAAW,CAAa;QAF7G,iBAAY,GAAY,IAAI,CAAA;Q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,EAAE;IAChC,MAAM,EAAE,eAAe;IACvB,QAAQ,EAAE,iBAAiB;CAC9B,CAAC,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Activity, Interaction, Relation } from "@shared";
|
|
2
|
+
import { KlassInstance } from "@shared";
|
|
3
|
+
import { Entity } from "@shared";
|
|
4
|
+
import { Controller } from "../Controller";
|
|
5
|
+
import { DataContext } from "./ComputedDataHandle";
|
|
6
|
+
import { AttributeQueryData, MatchExpressionData, ModifierData } from "@storage";
|
|
7
|
+
import { Dictionary } from "@shared";
|
|
8
|
+
import { SKIP_RESULT } from "../Scheduler";
|
|
9
|
+
export type ComputeResult = any;
|
|
10
|
+
export type ComputeResultPatch = {
|
|
11
|
+
type: 'insert' | 'update' | 'delete';
|
|
12
|
+
data?: any;
|
|
13
|
+
affectedId?: any;
|
|
14
|
+
};
|
|
15
|
+
export declare class RecordBoundState<T> {
|
|
16
|
+
defaultValue: any;
|
|
17
|
+
record: string;
|
|
18
|
+
key: string;
|
|
19
|
+
controller: Controller;
|
|
20
|
+
constructor(defaultValue: any);
|
|
21
|
+
set(record: any, value: any): Promise<T>;
|
|
22
|
+
get(record: any): Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
export declare class RelationBoundState<T> {
|
|
25
|
+
defaultValue: any;
|
|
26
|
+
record: string;
|
|
27
|
+
key: string;
|
|
28
|
+
controller: Controller;
|
|
29
|
+
constructor(defaultValue: any, record: string);
|
|
30
|
+
set(record: any, value: any): Promise<T>;
|
|
31
|
+
get(record: any): Promise<T>;
|
|
32
|
+
}
|
|
33
|
+
export declare class GlobalBoundState<T> {
|
|
34
|
+
defaultValue?: any | undefined;
|
|
35
|
+
key: string;
|
|
36
|
+
controller: Controller;
|
|
37
|
+
constructor(defaultValue?: any | undefined);
|
|
38
|
+
set(value: any): Promise<T>;
|
|
39
|
+
get(): Promise<T>;
|
|
40
|
+
}
|
|
41
|
+
export type RecordsDataDep = {
|
|
42
|
+
type: 'records';
|
|
43
|
+
source: KlassInstance<typeof Entity> | KlassInstance<typeof Relation> | KlassInstance<typeof Activity> | KlassInstance<typeof Interaction>;
|
|
44
|
+
match?: MatchExpressionData;
|
|
45
|
+
modifier?: ModifierData;
|
|
46
|
+
attributeQuery?: AttributeQueryData;
|
|
47
|
+
};
|
|
48
|
+
export type GlobalDataDep = {
|
|
49
|
+
type: 'global';
|
|
50
|
+
source: KlassInstance<typeof Dictionary>;
|
|
51
|
+
};
|
|
52
|
+
export type PropertyDataDep = {
|
|
53
|
+
type: 'property';
|
|
54
|
+
attributeQuery?: AttributeQueryData;
|
|
55
|
+
};
|
|
56
|
+
export type DictionaryDataDep = {
|
|
57
|
+
type: 'dict';
|
|
58
|
+
source: KlassInstance<typeof Dictionary>;
|
|
59
|
+
keys: string[];
|
|
60
|
+
};
|
|
61
|
+
export type DataDep = RecordsDataDep | PropertyDataDep | GlobalDataDep | DictionaryDataDep;
|
|
62
|
+
export interface DataBasedComputation {
|
|
63
|
+
dataContext: DataContext;
|
|
64
|
+
state: {
|
|
65
|
+
[key: string]: RecordBoundState<any> | GlobalBoundState<any> | RelationBoundState<any>;
|
|
66
|
+
};
|
|
67
|
+
compute: (...args: any[]) => ComputeResult;
|
|
68
|
+
incrementalCompute?: (...args: any[]) => Promise<ComputeResult | typeof SKIP_RESULT>;
|
|
69
|
+
incrementalPatchCompute?: (...args: any[]) => Promise<ComputeResultPatch | ComputeResultPatch[] | undefined | typeof SKIP_RESULT>;
|
|
70
|
+
createState?: (...args: any[]) => {
|
|
71
|
+
[key: string]: RecordBoundState<any> | GlobalBoundState<any>;
|
|
72
|
+
};
|
|
73
|
+
dataDeps?: {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
};
|
|
76
|
+
getDefaultValue?: (...args: any[]) => any;
|
|
77
|
+
useLastValue?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export type InteractionEventDep = {
|
|
80
|
+
type: 'interaction';
|
|
81
|
+
interaction: KlassInstance<typeof Interaction>;
|
|
82
|
+
};
|
|
83
|
+
export type DataEventDep = {
|
|
84
|
+
type: 'data';
|
|
85
|
+
eventType?: 'create' | 'delete' | 'update';
|
|
86
|
+
dataDep: DataDep;
|
|
87
|
+
};
|
|
88
|
+
export type EventDep = InteractionEventDep | DataEventDep;
|
|
89
|
+
export interface EventBasedComputation {
|
|
90
|
+
dataContext: DataContext;
|
|
91
|
+
state: {
|
|
92
|
+
[key: string]: RecordBoundState<any> | GlobalBoundState<any> | RelationBoundState<any>;
|
|
93
|
+
};
|
|
94
|
+
incrementalCompute?: (...args: any[]) => Promise<ComputeResult | typeof SKIP_RESULT>;
|
|
95
|
+
incrementalPatchCompute?: (...args: any[]) => Promise<ComputeResultPatch | ComputeResultPatch[] | undefined | typeof SKIP_RESULT>;
|
|
96
|
+
createState?: (...args: any[]) => {
|
|
97
|
+
[key: string]: RecordBoundState<any> | GlobalBoundState<any>;
|
|
98
|
+
};
|
|
99
|
+
eventDeps?: {
|
|
100
|
+
[key: string]: EventDep;
|
|
101
|
+
};
|
|
102
|
+
useLastValue?: boolean;
|
|
103
|
+
getDefaultValue?: (...args: any[]) => any;
|
|
104
|
+
computeDirtyRecords?: (...args: any[]) => Promise<any[] | undefined>;
|
|
105
|
+
}
|
|
106
|
+
export type Computation = DataBasedComputation | EventBasedComputation;
|
|
107
|
+
export type ComputationClass = new (...args: any[]) => Computation;
|
|
108
|
+
//# sourceMappingURL=Computation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Computation.d.ts","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/Computation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAA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AAC,GAAG,CAAC,GAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;KAAC,CAAA;IAC3F,kBAAkB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,aAAa,GAAC,OAAO,WAAW,CAAC,CAAA;IAClF,uBAAuB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,kBAAkB,GAAC,kBAAkB,EAAE,GAAC,SAAS,GAAC,OAAO,WAAW,CAAC,CAAA;IAC3H,WAAW,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;KAAC,CAAA;IAC9F,SAAS,CAAC,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAC,CAAA;IACrC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,eAAe,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACzC,mBAAmB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,EAAE,GAAC,SAAS,CAAC,CAAA;CACrE;AAED,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAC,qBAAqB,CAAA;AAEpE,MAAM,MAAM,gBAAgB,GAAG,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,WAAW,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BoolExp } from "@shared";
|
|
2
|
+
export class RecordBoundState {
|
|
3
|
+
constructor(defaultValue) {
|
|
4
|
+
this.defaultValue = defaultValue;
|
|
5
|
+
}
|
|
6
|
+
async set(record, value) {
|
|
7
|
+
await this.controller.system.storage.update(this.record, BoolExp.atom({ key: 'id', value: ['=', record.id] }), { [this.key]: value });
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
async get(record) {
|
|
11
|
+
// TODO 如果 record 上不存在就重新查询
|
|
12
|
+
if (record[this.key] === undefined) {
|
|
13
|
+
const fullRecord = await this.controller.system.storage.findOne(this.record, BoolExp.atom({ key: 'id', value: ['=', record.id] }), undefined, [this.key]);
|
|
14
|
+
return fullRecord[this.key];
|
|
15
|
+
}
|
|
16
|
+
return record[this.key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class RelationBoundState {
|
|
20
|
+
constructor(defaultValue, record) {
|
|
21
|
+
this.defaultValue = defaultValue;
|
|
22
|
+
this.record = record;
|
|
23
|
+
}
|
|
24
|
+
async set(record, value) {
|
|
25
|
+
await this.controller.system.storage.update(this.record, BoolExp.atom({ key: 'id', value: ['=', record.id] }), { [this.key]: value });
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
async get(record) {
|
|
29
|
+
// TODO 如果 record 上不存在就重新查询
|
|
30
|
+
if (record[this.key] === undefined) {
|
|
31
|
+
const fullRecord = await this.controller.system.storage.findOne(this.record, BoolExp.atom({ key: 'id', value: ['=', record.id] }), undefined, [this.key]);
|
|
32
|
+
return fullRecord[this.key];
|
|
33
|
+
}
|
|
34
|
+
return record[this.key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class GlobalBoundState {
|
|
38
|
+
constructor(defaultValue) {
|
|
39
|
+
this.defaultValue = defaultValue;
|
|
40
|
+
}
|
|
41
|
+
async set(value) {
|
|
42
|
+
await this.controller.system.storage.set('state', this.key, value);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
async get() {
|
|
46
|
+
return await this.controller.system.storage.get('state', this.key);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=Computation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Computation.js","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/Computation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AAG;QACL,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACtE,CAAC;CACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { KlassInstance, Klass } from "@shared";
|
|
2
|
+
import { Entity, Relation } from "@shared";
|
|
3
|
+
import { Computation } from "./Computation.js";
|
|
4
|
+
export type GlobalDataContext = {
|
|
5
|
+
type: 'global';
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
export type EntityDataContext = {
|
|
9
|
+
type: 'entity';
|
|
10
|
+
id: KlassInstance<typeof Entity>;
|
|
11
|
+
};
|
|
12
|
+
export type RelationDataContext = {
|
|
13
|
+
type: 'relation';
|
|
14
|
+
id: KlassInstance<typeof Relation>;
|
|
15
|
+
};
|
|
16
|
+
export type PropertyDataContext = {
|
|
17
|
+
type: 'property';
|
|
18
|
+
host: KlassInstance<typeof Entity> | KlassInstance<typeof Relation>;
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
export type DataContext = GlobalDataContext | EntityDataContext | RelationDataContext | PropertyDataContext;
|
|
22
|
+
export type ComputedEffect = any;
|
|
23
|
+
export type ComputeEffectResult = ComputedEffect | ComputedEffect[] | undefined;
|
|
24
|
+
type HandlesForType = {
|
|
25
|
+
global?: {
|
|
26
|
+
new (...args: any[]): Computation;
|
|
27
|
+
};
|
|
28
|
+
entity?: {
|
|
29
|
+
new (...args: any[]): Computation;
|
|
30
|
+
};
|
|
31
|
+
relation?: {
|
|
32
|
+
new (...args: any[]): Computation;
|
|
33
|
+
};
|
|
34
|
+
property?: {
|
|
35
|
+
new (...args: any[]): Computation;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare class ComputedDataHandle {
|
|
39
|
+
static Handles: Map<Klass<any>, HandlesForType>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=ComputedDataHandle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComputedDataHandle.d.ts","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/ComputedDataHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,aAAa,CAAC,OAAO,MAAM,CAAC,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,aAAa,CAAC,OAAO,QAAQ,CAAC,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC,OAAO,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,QAAQ,CAAC,CAAC;IACpE,EAAE,EAAE,MAAM,CAAA;CACb,CAAA;AAID,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAC,iBAAiB,GAAC,mBAAmB,GAAC,mBAAmB,CAAA;AAErG,MAAM,MAAM,cAAc,GAAG,GAAG,CAAA;AAEhC,MAAM,MAAM,mBAAmB,GAAE,cAAc,GAAC,cAAc,EAAE,GAAC,SAAS,CAAA;AAG1E,KAAK,cAAc,GAAG;IAClB,MAAM,CAAC,EAAE;QAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAA;KAAE,CAAC;IAC9C,MAAM,CAAC,EAAE;QAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAA;KAAE,CAAC;IAC9C,QAAQ,CAAC,EAAE;QAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAA;KAAE,CAAC;IAChD,QAAQ,CAAC,EAAE;QAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAA;KAAE,CAAC;CACnD,CAAA;AAED,qBAAa,kBAAkB;IAC3B,OAAe,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAG,cAAc,CAAC,CAAY;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComputedDataHandle.js","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/ComputedDataHandle.ts"],"names":[],"mappings":"AAyCA,MAAM,OAAO,kBAAkB;aACZ,YAAO,GAAqC,IAAI,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DataContext, PropertyDataContext } from "./ComputedDataHandle.js";
|
|
2
|
+
import { Count, KlassInstance, Relation, Entity } from "@shared";
|
|
3
|
+
import { Controller } from "../Controller.js";
|
|
4
|
+
import { DataDep } from "./Computation.js";
|
|
5
|
+
import { DataBasedComputation } from "./Computation.js";
|
|
6
|
+
import { EtityMutationEvent } from "../Scheduler.js";
|
|
7
|
+
export declare class GlobalCountHandle implements DataBasedComputation {
|
|
8
|
+
controller: Controller;
|
|
9
|
+
dataContext: DataContext;
|
|
10
|
+
state: ReturnType<typeof this.createState>;
|
|
11
|
+
useLastValue: boolean;
|
|
12
|
+
dataDeps: {
|
|
13
|
+
[key: string]: DataDep;
|
|
14
|
+
};
|
|
15
|
+
record: KlassInstance<typeof Entity | typeof Relation>;
|
|
16
|
+
constructor(controller: Controller, args: KlassInstance<typeof Count>, dataContext: DataContext);
|
|
17
|
+
createState(): {};
|
|
18
|
+
getDefaultValue(): number;
|
|
19
|
+
compute({ main: records }: {
|
|
20
|
+
main: any[];
|
|
21
|
+
}): Promise<number>;
|
|
22
|
+
incrementalCompute(lastValue: number, mutationEvent: EtityMutationEvent): Promise<number>;
|
|
23
|
+
}
|
|
24
|
+
export declare class PropertyCountHandle implements DataBasedComputation {
|
|
25
|
+
controller: Controller;
|
|
26
|
+
args: KlassInstance<typeof Count>;
|
|
27
|
+
dataContext: PropertyDataContext;
|
|
28
|
+
state: ReturnType<typeof this.createState>;
|
|
29
|
+
useLastValue: boolean;
|
|
30
|
+
dataDeps: {
|
|
31
|
+
[key: string]: DataDep;
|
|
32
|
+
};
|
|
33
|
+
relationAttr: string;
|
|
34
|
+
relatedRecordName: string;
|
|
35
|
+
isSource: boolean;
|
|
36
|
+
relation: KlassInstance<typeof Relation>;
|
|
37
|
+
constructor(controller: Controller, args: KlassInstance<typeof Count>, dataContext: PropertyDataContext);
|
|
38
|
+
createState(): {};
|
|
39
|
+
getDefaultValue(): number;
|
|
40
|
+
compute({ _current }: {
|
|
41
|
+
_current: any;
|
|
42
|
+
}): Promise<number>;
|
|
43
|
+
incrementalCompute(lastValue: number, mutationEvent: EtityMutationEvent): Promise<number>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=Count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Count.d.ts","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/Count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAsC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,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,CAAC,OAAO,KAAK,CAAC,EAAS,WAAW,EAAE,mBAAmB;IAe5H,WAAW;IAKX,eAAe;IAIT,OAAO,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,GAAG,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAKrD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;CAclG"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ComputedDataHandle } from "./ComputedDataHandle.js";
|
|
2
|
+
import { Count } from "@shared";
|
|
3
|
+
export class GlobalCountHandle {
|
|
4
|
+
constructor(controller, args, dataContext) {
|
|
5
|
+
this.controller = controller;
|
|
6
|
+
this.dataContext = dataContext;
|
|
7
|
+
this.useLastValue = true;
|
|
8
|
+
this.dataDeps = {};
|
|
9
|
+
this.record = args.record;
|
|
10
|
+
this.dataDeps = {
|
|
11
|
+
main: {
|
|
12
|
+
type: 'records',
|
|
13
|
+
source: this.record
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
createState() {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
getDefaultValue() {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
async compute({ main: records }) {
|
|
24
|
+
return records.length;
|
|
25
|
+
}
|
|
26
|
+
async incrementalCompute(lastValue, mutationEvent) {
|
|
27
|
+
debugger;
|
|
28
|
+
let count = lastValue || 0;
|
|
29
|
+
if (mutationEvent.type === 'create') {
|
|
30
|
+
count = lastValue + 1;
|
|
31
|
+
}
|
|
32
|
+
else if (mutationEvent.type === 'delete') {
|
|
33
|
+
count = lastValue - 1;
|
|
34
|
+
}
|
|
35
|
+
return count;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class PropertyCountHandle {
|
|
39
|
+
constructor(controller, args, dataContext) {
|
|
40
|
+
this.controller = controller;
|
|
41
|
+
this.args = args;
|
|
42
|
+
this.dataContext = dataContext;
|
|
43
|
+
this.useLastValue = true;
|
|
44
|
+
this.dataDeps = {};
|
|
45
|
+
// We assume in PropertyCountHandle, the records array's first element is a Relation
|
|
46
|
+
this.relation = args.record;
|
|
47
|
+
this.relationAttr = this.relation.source.name === dataContext.host.name ? this.relation.sourceProperty : this.relation.targetProperty;
|
|
48
|
+
this.isSource = this.relation.source.name === dataContext.host.name;
|
|
49
|
+
this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name;
|
|
50
|
+
this.dataDeps = {
|
|
51
|
+
_current: {
|
|
52
|
+
type: 'property',
|
|
53
|
+
attributeQuery: [[this.relationAttr, { attributeQuery: ['id'] }]]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
createState() {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
getDefaultValue() {
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
async compute({ _current }) {
|
|
64
|
+
const count = _current[this.relationAttr]?.length || 0;
|
|
65
|
+
return count;
|
|
66
|
+
}
|
|
67
|
+
async incrementalCompute(lastValue, mutationEvent) {
|
|
68
|
+
let count = lastValue || 0;
|
|
69
|
+
const relatedMutationEvent = mutationEvent.relatedMutationEvent;
|
|
70
|
+
if (relatedMutationEvent.type === 'create') {
|
|
71
|
+
// Relation creation
|
|
72
|
+
count = lastValue + 1;
|
|
73
|
+
}
|
|
74
|
+
else if (relatedMutationEvent.type === 'delete') {
|
|
75
|
+
// Relation deletion
|
|
76
|
+
count = lastValue - 1;
|
|
77
|
+
}
|
|
78
|
+
return count;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
ComputedDataHandle.Handles.set(Count, {
|
|
82
|
+
global: GlobalCountHandle,
|
|
83
|
+
property: PropertyCountHandle
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=Count.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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,kBAAkB,CAAC,SAAiB,EAAE,aAAiC;QACzE,IAAI,KAAK,GAAG,SAAS,IAAI,CAAC,CAAC;QAC3B,MAAM,oBAAoB,GAAG,aAAa,CAAC,oBAAqB,CAAC;QAEjE,IAAI,oBAAoB,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzC,oBAAoB;YACpB,KAAK,GAAG,SAAS,GAAG,CAAC,CAAC;QAC1B,CAAC;aAAM,IAAI,oBAAoB,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChD,oBAAoB;YACpB,KAAK,GAAG,SAAS,GAAG,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAED,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;IAClC,MAAM,EAAE,iBAAiB;IACzB,QAAQ,EAAE,mBAAmB;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PropertyDataContext } from "./ComputedDataHandle.js";
|
|
2
|
+
import { Every, KlassInstance, Relation } from "@shared";
|
|
3
|
+
import { DataBasedComputation, DataDep, GlobalBoundState, RecordBoundState, RelationBoundState } from "./Computation.js";
|
|
4
|
+
import { Controller } from "../Controller.js";
|
|
5
|
+
import { DataContext } from "./ComputedDataHandle.js";
|
|
6
|
+
import { EtityMutationEvent } from "../Scheduler.js";
|
|
7
|
+
import { AttributeQueryData } from "@storage";
|
|
8
|
+
export declare class GlobalEveryHandle implements DataBasedComputation {
|
|
9
|
+
controller: Controller;
|
|
10
|
+
dataContext: DataContext;
|
|
11
|
+
callback: (this: Controller, item: any) => boolean;
|
|
12
|
+
state: ReturnType<typeof this.createState>;
|
|
13
|
+
useLastValue: boolean;
|
|
14
|
+
dataDeps: {
|
|
15
|
+
[key: string]: DataDep;
|
|
16
|
+
};
|
|
17
|
+
defaultValue: boolean;
|
|
18
|
+
constructor(controller: Controller, args: KlassInstance<typeof Every>, dataContext: DataContext);
|
|
19
|
+
createState(): {
|
|
20
|
+
matchCount: GlobalBoundState<number>;
|
|
21
|
+
totalCount: GlobalBoundState<number>;
|
|
22
|
+
};
|
|
23
|
+
getDefaultValue(): boolean;
|
|
24
|
+
compute({ main: records }: {
|
|
25
|
+
main: any[];
|
|
26
|
+
}): Promise<boolean>;
|
|
27
|
+
incrementalCompute(lastValue: boolean, mutationEvent: EtityMutationEvent): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
export declare class PropertyEveryHandle implements DataBasedComputation {
|
|
30
|
+
controller: Controller;
|
|
31
|
+
args: KlassInstance<typeof Every>;
|
|
32
|
+
dataContext: PropertyDataContext;
|
|
33
|
+
callback: (this: Controller, item: any) => boolean;
|
|
34
|
+
state: ReturnType<typeof this.createState>;
|
|
35
|
+
useLastValue: boolean;
|
|
36
|
+
dataDeps: {
|
|
37
|
+
[key: string]: DataDep;
|
|
38
|
+
};
|
|
39
|
+
relationAttr: string;
|
|
40
|
+
relation: KlassInstance<typeof Relation>;
|
|
41
|
+
relatedRecordName: string;
|
|
42
|
+
isSource: boolean;
|
|
43
|
+
relationAttributeQuery: AttributeQueryData;
|
|
44
|
+
constructor(controller: Controller, args: KlassInstance<typeof Every>, dataContext: PropertyDataContext);
|
|
45
|
+
createState(): {
|
|
46
|
+
matchCount: RecordBoundState<number>;
|
|
47
|
+
totalCount: RecordBoundState<number>;
|
|
48
|
+
isItemMatch: RelationBoundState<boolean>;
|
|
49
|
+
};
|
|
50
|
+
getDefaultValue(): boolean;
|
|
51
|
+
compute({ _current }: {
|
|
52
|
+
_current: any;
|
|
53
|
+
}): Promise<boolean>;
|
|
54
|
+
incrementalCompute(lastValue: boolean, mutationEvent: EtityMutationEvent): Promise<boolean>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=Every.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Every.d.ts","sourceRoot":"","sources":["../../../src/runtime/computedDataHandles/Every.ts"],"names":[],"mappings":"A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