bpmn-elements 6.0.1 → 8.0.1
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 +341 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +176 -172
- package/dist/src/Environment.js +110 -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/activity/Activity.js +1105 -916
- 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 +710 -408
- 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 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- 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 +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +439 -362
- package/dist/src/process/ProcessExecution.js +748 -646
- package/dist/src/shared.js +2 -2
- 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 +193 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +16 -16
- package/src/Api.js +65 -59
- package/src/Context.js +145 -140
- package/src/Environment.js +116 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +914 -776
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +437 -401
- package/src/definition/DefinitionExecution.js +598 -340
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +159 -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 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- 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 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +378 -333
- package/src/process/ProcessExecution.js +603 -553
- 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
|
@@ -2,136 +2,192 @@ import getPropertyValue from '../getPropertyValue';
|
|
|
2
2
|
import {brokerSafeId} from '../shared';
|
|
3
3
|
import {cloneContent, shiftParent} from '../messageHelper';
|
|
4
4
|
|
|
5
|
+
const kCompleted = Symbol.for('completed');
|
|
6
|
+
const kMessageQ = Symbol.for('messageQ');
|
|
7
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
8
|
+
const kReferenceElement = Symbol.for('referenceElement');
|
|
9
|
+
const kReferenceInfo = Symbol.for('referenceInfo');
|
|
10
|
+
|
|
5
11
|
export default function SignalEventDefinition(activity, eventDefinition) {
|
|
6
|
-
const {id, broker, environment, isStart, isThrowing
|
|
12
|
+
const {id, broker, environment, isStart, isThrowing} = activity;
|
|
7
13
|
const {type, behaviour = {}} = eventDefinition;
|
|
8
|
-
const {debug} = environment.Logger(type.toLowerCase());
|
|
9
|
-
const reference = behaviour.signalRef || {name: 'anonymous'};
|
|
10
|
-
const referenceElement = reference.id && getActivityById(reference.id);
|
|
11
|
-
const signalId = referenceElement ? referenceElement.id : 'anonymous';
|
|
12
|
-
const signalQueueName = `signal-${brokerSafeId(id)}-${brokerSafeId(signalId)}-q`;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.type = type;
|
|
15
17
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
execute: isThrowing ? executeThrow : executeCatch,
|
|
18
|
+
const reference = this.reference = {
|
|
19
|
+
name: 'anonymous',
|
|
20
|
+
...behaviour.signalRef,
|
|
21
|
+
referenceType: 'signal',
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
this.isThrowing = isThrowing;
|
|
25
|
+
this.activity = activity;
|
|
26
|
+
this.broker = broker;
|
|
27
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
28
|
+
|
|
29
|
+
const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
30
|
+
if (!isThrowing && isStart) {
|
|
31
|
+
this[kCompleted] = false;
|
|
32
|
+
const referenceId = referenceElement ? referenceElement.id : 'anonymous';
|
|
33
|
+
const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(referenceId)}-q`;
|
|
34
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
|
|
35
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
let completed;
|
|
39
|
+
const proto = SignalEventDefinition.prototype;
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
41
|
+
Object.defineProperty(proto, 'executionId', {
|
|
42
|
+
get() {
|
|
43
|
+
const message = this[kExecuteMessage];
|
|
44
|
+
return message && message.content.executionId;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
31
47
|
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
proto.execute = function execute(executeMessage) {
|
|
49
|
+
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
proto.executeCatch = function executeCatch(executeMessage) {
|
|
53
|
+
this[kExecuteMessage] = executeMessage;
|
|
54
|
+
this[kCompleted] = false;
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
const executeContent = executeMessage.content;
|
|
57
|
+
const {executionId, parent} = executeContent;
|
|
58
|
+
const parentExecutionId = parent && parent.executionId;
|
|
40
59
|
|
|
41
|
-
|
|
60
|
+
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
61
|
+
const broker = this.broker;
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
const onCatchMessage = this._onCatchMessage.bind(this);
|
|
64
|
+
if (this.activity.isStart) {
|
|
65
|
+
this[kMessageQ].consume(onCatchMessage, {
|
|
66
|
+
noAck: true,
|
|
67
|
+
consumerTag: `_api-signal-${executionId}`,
|
|
48
68
|
});
|
|
69
|
+
if (this[kCompleted]) return;
|
|
70
|
+
}
|
|
49
71
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
const onApiMessage = this._onApiMessage.bind(this);
|
|
73
|
+
broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
|
|
74
|
+
noAck: true,
|
|
75
|
+
consumerTag: `_api-parent-${executionId}`,
|
|
76
|
+
});
|
|
77
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
78
|
+
noAck: true,
|
|
79
|
+
consumerTag: `_api-${executionId}`,
|
|
80
|
+
});
|
|
81
|
+
broker.subscribeTmp('api', '#.signal.*', onCatchMessage, {
|
|
82
|
+
noAck: true,
|
|
83
|
+
consumerTag: `_api-delegated-${executionId}`,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
this._debug(`expect ${info.description}`);
|
|
87
|
+
|
|
88
|
+
const waitContent = cloneContent(executeContent, {
|
|
89
|
+
executionId: parent.executionId,
|
|
90
|
+
signal: {...info.message},
|
|
91
|
+
});
|
|
92
|
+
waitContent.parent = shiftParent(parent);
|
|
93
|
+
|
|
94
|
+
broker.publish('event', 'activity.wait', waitContent);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
proto.executeThrow = function executeThrow(executeMessage) {
|
|
98
|
+
const executeContent = executeMessage.content;
|
|
99
|
+
const {executionId, parent} = executeContent;
|
|
100
|
+
|
|
101
|
+
const info = this._getReferenceInfo(executeMessage);
|
|
102
|
+
|
|
103
|
+
this.logger.debug(`<${executionId} (${this.activity.id})> throw ${info.description}`);
|
|
104
|
+
|
|
105
|
+
const throwContent = cloneContent(executeContent, {
|
|
106
|
+
executionId: parent.executionId,
|
|
107
|
+
message: {...executeContent.input, ...info.message},
|
|
108
|
+
state: 'throw',
|
|
109
|
+
});
|
|
110
|
+
throwContent.parent = shiftParent(parent);
|
|
111
|
+
|
|
112
|
+
const broker = this.broker;
|
|
113
|
+
broker.publish('event', 'activity.signal', throwContent, {type: 'signal'});
|
|
114
|
+
|
|
115
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
proto._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
119
|
+
const info = this[kReferenceInfo];
|
|
120
|
+
if (getPropertyValue(message, 'content.message.id') !== info.message.id) return;
|
|
121
|
+
this[kCompleted] = true;
|
|
122
|
+
this._stop();
|
|
123
|
+
|
|
124
|
+
const {type, correlationId} = message.properties;
|
|
125
|
+
this.broker.publish('event', 'activity.consumed', cloneContent(this[kExecuteMessage].content, {
|
|
126
|
+
message: { ...message.content.message},
|
|
127
|
+
}), {
|
|
128
|
+
correlationId,
|
|
129
|
+
type,
|
|
130
|
+
});
|
|
54
131
|
|
|
55
|
-
|
|
56
|
-
|
|
132
|
+
return this._complete(message.content.message, message.properties);
|
|
133
|
+
};
|
|
57
134
|
|
|
58
|
-
|
|
59
|
-
|
|
135
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
136
|
+
const {type, correlationId} = message.properties;
|
|
60
137
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
switch (messageType) {
|
|
65
|
-
case 'signal': {
|
|
66
|
-
return complete(message.content.message, {correlationId});
|
|
67
|
-
}
|
|
68
|
-
case 'discard': {
|
|
69
|
-
completed = true;
|
|
70
|
-
stop();
|
|
71
|
-
return broker.publish('execution', 'execute.discard', {...messageContent}, {correlationId});
|
|
72
|
-
}
|
|
73
|
-
case 'stop': {
|
|
74
|
-
stop();
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
138
|
+
switch (type) {
|
|
139
|
+
case 'signal': {
|
|
140
|
+
return this._complete(message.content.message, {correlationId});
|
|
78
141
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
debug(`<${executionId} (${id})> signaled with`, description);
|
|
84
|
-
return broker.publish('execution', 'execute.completed', {...messageContent, output, state: 'signal'}, options);
|
|
142
|
+
case 'discard': {
|
|
143
|
+
this[kCompleted] = true;
|
|
144
|
+
this._stop();
|
|
145
|
+
return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
|
|
85
146
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
broker.cancel(`_api-parent-${parentExecutionId}`);
|
|
90
|
-
broker.cancel(`_api-${executionId}`);
|
|
91
|
-
broker.cancel(`_api-delegated-${executionId}`);
|
|
92
|
-
if (isStart) broker.purgeQueue(signalQueueName);
|
|
147
|
+
case 'stop': {
|
|
148
|
+
this._stop();
|
|
149
|
+
break;
|
|
93
150
|
}
|
|
94
151
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
proto._complete = function complete(output, options) {
|
|
155
|
+
this[kCompleted] = true;
|
|
156
|
+
this._stop();
|
|
157
|
+
this._debug(`signaled with ${this[kReferenceInfo].description}`);
|
|
158
|
+
return this.broker.publish('execution', 'execute.completed', cloneContent(this[kExecuteMessage].content, {
|
|
159
|
+
output,
|
|
160
|
+
state: 'signal',
|
|
161
|
+
}), options);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
proto._stop = function stop() {
|
|
165
|
+
const broker = this.broker, executionId = this.executionId;
|
|
166
|
+
broker.cancel(`_api-signal-${executionId}`);
|
|
167
|
+
broker.cancel(`_api-parent-${executionId}`);
|
|
168
|
+
broker.cancel(`_api-${executionId}`);
|
|
169
|
+
broker.cancel(`_api-delegated-${executionId}`);
|
|
170
|
+
if (this.activity.isStart) this[kMessageQ].purge();
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
proto._getReferenceInfo = function getReferenceInfo(message) {
|
|
174
|
+
const referenceElement = this[kReferenceElement];
|
|
175
|
+
if (!referenceElement) {
|
|
176
|
+
return {
|
|
177
|
+
message: {...this.reference},
|
|
178
|
+
description: 'anonymous signal',
|
|
179
|
+
};
|
|
114
180
|
}
|
|
115
181
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
message: {...reference},
|
|
120
|
-
description: 'anonymous signal',
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const result = {
|
|
125
|
-
message: referenceElement.resolve(message),
|
|
126
|
-
};
|
|
182
|
+
const result = {
|
|
183
|
+
message: referenceElement.resolve(message),
|
|
184
|
+
};
|
|
127
185
|
|
|
128
|
-
|
|
186
|
+
result.description = `${result.message.name} <${result.message.id}>`;
|
|
129
187
|
|
|
130
|
-
|
|
131
|
-
|
|
188
|
+
return result;
|
|
189
|
+
};
|
|
132
190
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
}
|
|
191
|
+
proto._debug = function debug(msg) {
|
|
192
|
+
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
193
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {cloneContent, shiftParent} from '../messageHelper';
|
|
2
2
|
|
|
3
|
-
export default function TerminateEventDefinition(activity, eventDefinition
|
|
3
|
+
export default function TerminateEventDefinition(activity, eventDefinition) {
|
|
4
4
|
const {id, broker, environment} = activity;
|
|
5
|
-
const {type = '
|
|
6
|
-
const {debug} = environment.Logger(type.toLowerCase());
|
|
5
|
+
const {type = 'TerminateEventDefinition'} = eventDefinition;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
this.id = id;
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.activity = activity;
|
|
10
|
+
this.broker = broker;
|
|
11
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
TerminateEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
15
|
+
const executeContent = executeMessage.content;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
terminateContent.state = 'terminate';
|
|
17
|
+
const throwContent = cloneContent(executeContent, {
|
|
18
|
+
state: 'terminate',
|
|
19
|
+
});
|
|
20
|
+
throwContent.parent = shiftParent(executeContent.parent);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
this.logger.debug(`<${executeContent.executionId} (${executeContent.id})> terminate`);
|
|
23
|
+
const broker = this.broker;
|
|
24
|
+
broker.publish('event', 'process.terminate', throwContent, {type: 'terminate'});
|
|
25
|
+
broker.publish('execution', 'execute.completed', cloneContent(executeContent));
|
|
26
|
+
};
|