bpmn-elements 5.1.3 → 7.0.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/CHANGELOG.md +322 -0
- package/README.md +9 -3
- package/dist/index.js +71 -39
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +169 -164
- package/dist/src/Environment.js +90 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/Timers.js +4 -6
- package/dist/src/activity/Activity.js +1108 -901
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +722 -409
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -101
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +172 -184
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +31 -0
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +52 -0
- package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +252 -0
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +433 -359
- package/dist/src/process/ProcessExecution.js +744 -645
- package/dist/src/shared.js +3 -6
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +195 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +8 -0
- package/package.json +16 -15
- package/src/Api.js +65 -59
- package/src/Context.js +142 -132
- package/src/Environment.js +88 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/Timers.js +4 -4
- package/src/activity/Activity.js +916 -757
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +436 -401
- package/src/definition/DefinitionExecution.js +603 -343
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -113
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +145 -163
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -0
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +33 -0
- package/src/io/EnvironmentDataStoreReference.js +33 -0
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +199 -0
- package/src/process/Process.js +374 -333
- package/src/process/ProcessExecution.js +606 -554
- package/src/shared.js +1 -5
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import getPropertyValue from '../getPropertyValue';
|
|
2
|
+
|
|
3
|
+
const propertiesSymbol = Symbol.for('properties');
|
|
4
|
+
const consumingSymbol = Symbol.for('consuming');
|
|
5
|
+
|
|
6
|
+
export default function Properties(activity, propertiesDef, context) {
|
|
7
|
+
this.activity = activity;
|
|
8
|
+
this.broker = activity.broker;
|
|
9
|
+
|
|
10
|
+
const props = this[propertiesSymbol] = {
|
|
11
|
+
properties: [],
|
|
12
|
+
dataInputObjects: [],
|
|
13
|
+
dataOutputObjects: [],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
for (const {id, ...def} of propertiesDef.values) {
|
|
18
|
+
const source = {
|
|
19
|
+
id,
|
|
20
|
+
type: def.type,
|
|
21
|
+
name: def.behaviour && def.behaviour.name,
|
|
22
|
+
};
|
|
23
|
+
props.properties.push(source);
|
|
24
|
+
|
|
25
|
+
const inputDataObjectId = getPropertyValue(def, 'behaviour.dataInput.association.source.dataObject.id');
|
|
26
|
+
const outputDataObjectId = getPropertyValue(def, 'behaviour.dataOutput.association.target.dataObject.id');
|
|
27
|
+
const inputDataStoreId = getPropertyValue(def, 'behaviour.dataInput.association.source.dataStore.id');
|
|
28
|
+
const outputDataStoreId = getPropertyValue(def, 'behaviour.dataOutput.association.target.dataStore.id');
|
|
29
|
+
|
|
30
|
+
if (inputDataObjectId) {
|
|
31
|
+
const reference = context.getDataObjectById(inputDataObjectId);
|
|
32
|
+
props.dataInputObjects.push({id, reference});
|
|
33
|
+
source.input = {
|
|
34
|
+
reference,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (outputDataObjectId) {
|
|
38
|
+
const reference = context.getDataObjectById(outputDataObjectId);
|
|
39
|
+
props.dataOutputObjects.push({id, reference: reference});
|
|
40
|
+
source.output = {
|
|
41
|
+
reference,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (inputDataStoreId) {
|
|
45
|
+
const reference = context.getDataStoreById(inputDataStoreId);
|
|
46
|
+
props.dataInputObjects.push({id, reference});
|
|
47
|
+
source.input = {
|
|
48
|
+
reference,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (outputDataStoreId) {
|
|
52
|
+
const reference = context.getDataStoreById(outputDataStoreId);
|
|
53
|
+
props.dataOutputObjects.push({id, reference});
|
|
54
|
+
source.output = {
|
|
55
|
+
reference,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const proto = Properties.prototype;
|
|
62
|
+
|
|
63
|
+
proto.activate = function activate(message) {
|
|
64
|
+
if (this[consumingSymbol]) return;
|
|
65
|
+
|
|
66
|
+
if (message.fields.redelivered && message.content.properties) {
|
|
67
|
+
this._onActivityEvent('activity.extension.resume', message);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this[consumingSymbol] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {noAck: true});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
proto.deactivate = function deactivate() {
|
|
74
|
+
if (this[consumingSymbol]) this[consumingSymbol] = this[consumingSymbol].cancel();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
78
|
+
if (routingKey === 'activity.enter') {
|
|
79
|
+
return this._formatOnEnter(message);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (routingKey === 'activity.extension.resume') {
|
|
83
|
+
return this._formatOnEnter(message);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (routingKey === 'activity.execution.completed') {
|
|
87
|
+
return this._formatOnComplete(message);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
proto._formatOnEnter = function formatOnEnter(message) {
|
|
92
|
+
const startRoutingKey = 'run.enter.bpmn-properties';
|
|
93
|
+
|
|
94
|
+
const dataInputObjects = this[propertiesSymbol].dataInputObjects;
|
|
95
|
+
const broker = this.broker;
|
|
96
|
+
if (!dataInputObjects.length) {
|
|
97
|
+
return broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
|
|
98
|
+
properties: this._getProperties(message),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const endRoutingKey = 'run.enter.bpmn-properties.end';
|
|
103
|
+
broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
|
|
104
|
+
endRoutingKey,
|
|
105
|
+
properties: this._getProperties(message),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return read(broker, dataInputObjects, (_, responses) => {
|
|
109
|
+
broker.publish('format', endRoutingKey, {
|
|
110
|
+
properties: this._getProperties(message, responses),
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
proto._formatOnComplete = function formatOnComplete(message) {
|
|
116
|
+
const startRoutingKey = 'run.end.bpmn-properties';
|
|
117
|
+
|
|
118
|
+
const messageOutput = getPropertyValue(message, 'content.output.properties') || {};
|
|
119
|
+
const outputProperties = this._getProperties(message, messageOutput);
|
|
120
|
+
|
|
121
|
+
const dataOutputObjects = this[propertiesSymbol].dataOutputObjects;
|
|
122
|
+
const broker = this.broker;
|
|
123
|
+
if (!dataOutputObjects.length) {
|
|
124
|
+
return broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
|
|
125
|
+
properties: outputProperties,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const endRoutingKey = 'run.end.bpmn-properties.end';
|
|
130
|
+
broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
|
|
131
|
+
endRoutingKey,
|
|
132
|
+
properties: outputProperties,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
|
|
136
|
+
broker.publish('format', endRoutingKey, {
|
|
137
|
+
properties: this._getProperties(message, responses),
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
proto._getProperties = function getProperties(message, values) {
|
|
143
|
+
let response = {};
|
|
144
|
+
|
|
145
|
+
if (message.content.properties) {
|
|
146
|
+
response = {...message.content.properties};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (const {id, type, name} of this[propertiesSymbol].properties) {
|
|
150
|
+
if (!(id in response)) {
|
|
151
|
+
response[id] = {id, type, name};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!values || !(id in values)) continue;
|
|
155
|
+
response[id].value = values[id].value;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return response;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
function read(broker, dataReferences, callback) {
|
|
162
|
+
const responses = {};
|
|
163
|
+
let count = 0;
|
|
164
|
+
|
|
165
|
+
const dataReadConsumer = broker.subscribeTmp('data', 'data.read.#', onDataReadResponse, {noAck: true});
|
|
166
|
+
|
|
167
|
+
for (const {id: propertyId, reference} of dataReferences) {
|
|
168
|
+
reference.read(broker, 'data', 'data.read.', {correlationId: propertyId});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function onDataReadResponse(routingKey, message) {
|
|
172
|
+
responses[message.properties.correlationId] = {...message.content};
|
|
173
|
+
|
|
174
|
+
if (++count < dataReferences.length) return;
|
|
175
|
+
|
|
176
|
+
dataReadConsumer.cancel();
|
|
177
|
+
return callback(null, responses);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function write(broker, dataReferences, properties, callback) {
|
|
182
|
+
const responses = [];
|
|
183
|
+
let count = 0;
|
|
184
|
+
const dataWriteConsumer = broker.subscribeTmp('data', 'data.write.#', onDataWriteResponse, {noAck: true});
|
|
185
|
+
|
|
186
|
+
for (const {id: propertyId, reference} of dataReferences) {
|
|
187
|
+
const value = propertyId in properties ? properties[propertyId].value : undefined;
|
|
188
|
+
reference.write(broker, 'data', 'data.write.', value, {correlationId: propertyId});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function onDataWriteResponse(routingKey, message) {
|
|
192
|
+
responses[message.properties.correlationId] = {...message.content};
|
|
193
|
+
|
|
194
|
+
if (++count < dataReferences.length) return;
|
|
195
|
+
|
|
196
|
+
dataWriteConsumer.cancel();
|
|
197
|
+
return callback(null, responses);
|
|
198
|
+
}
|
|
199
|
+
}
|