bpmn-elements 13.1.1 → 13.2.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 +1 -2
- package/dist/Context.js +36 -2
- package/dist/definition/DefinitionExecution.js +2 -1
- package/dist/getPropertyValue.js +1 -2
- package/dist/index.js +1 -1
- package/package.json +14 -13
- package/src/Api.js +18 -20
- package/src/Context.js +49 -7
- package/src/Environment.js +10 -20
- package/src/EventBroker.js +21 -27
- package/src/MessageFormatter.js +23 -19
- package/src/Tracker.js +4 -4
- package/src/activity/Activity.js +141 -109
- package/src/activity/ActivityExecution.js +38 -29
- package/src/activity/Dummy.js +3 -3
- package/src/activity/Escalation.js +4 -4
- package/src/activity/ExecutionScope.js +4 -4
- package/src/activity/Message.js +5 -5
- package/src/activity/Signal.js +5 -5
- package/src/definition/Definition.js +44 -36
- package/src/definition/DefinitionExecution.js +98 -66
- package/src/error/BpmnError.js +3 -3
- package/src/error/Errors.js +19 -14
- package/src/eventDefinitions/CancelEventDefinition.js +16 -11
- package/src/eventDefinitions/CompensateEventDefinition.js +28 -23
- package/src/eventDefinitions/ConditionalEventDefinition.js +42 -23
- package/src/eventDefinitions/ErrorEventDefinition.js +47 -34
- package/src/eventDefinitions/EscalationEventDefinition.js +21 -20
- package/src/eventDefinitions/EventDefinitionExecution.js +6 -6
- package/src/eventDefinitions/LinkEventDefinition.js +28 -22
- package/src/eventDefinitions/MessageEventDefinition.js +47 -36
- package/src/eventDefinitions/SignalEventDefinition.js +42 -31
- package/src/eventDefinitions/TerminateEventDefinition.js +4 -4
- package/src/eventDefinitions/TimerEventDefinition.js +41 -29
- package/src/events/BoundaryEvent.js +81 -46
- package/src/events/EndEvent.js +2 -2
- package/src/events/IntermediateCatchEvent.js +8 -4
- package/src/events/IntermediateThrowEvent.js +2 -2
- package/src/events/StartEvent.js +29 -18
- package/src/flows/Association.js +11 -11
- package/src/flows/MessageFlow.js +16 -14
- package/src/flows/SequenceFlow.js +22 -20
- package/src/gateways/EventBasedGateway.js +7 -6
- package/src/gateways/ExclusiveGateway.js +4 -4
- package/src/gateways/InclusiveGateway.js +3 -3
- package/src/gateways/ParallelGateway.js +4 -4
- package/src/getPropertyValue.js +3 -6
- package/src/index.js +1 -1
- package/src/io/BpmnIO.js +5 -6
- package/src/io/EnvironmentDataObject.js +2 -3
- package/src/io/EnvironmentDataStore.js +2 -2
- package/src/io/EnvironmentDataStoreReference.js +2 -2
- package/src/io/InputOutputSpecification.js +60 -54
- package/src/io/Properties.js +45 -33
- package/src/iso-duration.js +9 -13
- package/src/messageHelper.js +16 -23
- package/src/process/Lane.js +3 -3
- package/src/process/Process.js +40 -34
- package/src/process/ProcessExecution.js +122 -78
- package/src/tasks/CallActivity.js +109 -57
- package/src/tasks/LoopCharacteristics.js +30 -18
- package/src/tasks/ReceiveTask.js +59 -38
- package/src/tasks/ScriptTask.js +17 -8
- package/src/tasks/ServiceTask.js +16 -9
- package/src/tasks/SignalTask.js +47 -28
- package/src/tasks/StandardLoopCharacteristics.js +3 -3
- package/src/tasks/SubProcess.js +9 -8
- package/src/tasks/Task.js +4 -3
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +6 -6
- package/types/types.d.ts +39 -35
- package/CHANGELOG.md +0 -455
- package/src/ExtensionsMapper.js +0 -42
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Activity from '../activity/Activity.js';
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution.js';
|
|
3
|
-
import {cloneContent, cloneMessage} from '../messageHelper.js';
|
|
4
|
-
import {brokerSafeId} from '../shared.js';
|
|
3
|
+
import { cloneContent, cloneMessage } from '../messageHelper.js';
|
|
4
|
+
import { brokerSafeId } from '../shared.js';
|
|
5
5
|
|
|
6
6
|
const kAttachedTags = Symbol.for('attachedConsumers');
|
|
7
7
|
const kCompleteContent = Symbol.for('completeContent');
|
|
@@ -20,7 +20,8 @@ export function BoundaryEventBehaviour(activity) {
|
|
|
20
20
|
this.activity = activity;
|
|
21
21
|
this.environment = activity.environment;
|
|
22
22
|
this.broker = activity.broker;
|
|
23
|
-
this[kExecution] =
|
|
23
|
+
this[kExecution] =
|
|
24
|
+
activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions, 'execute.bound.completed');
|
|
24
25
|
this[kShovels] = [];
|
|
25
26
|
this[kAttachedTags] = [];
|
|
26
27
|
}
|
|
@@ -41,7 +42,7 @@ Object.defineProperties(BoundaryEventBehaviour.prototype, {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
BoundaryEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
44
|
-
const {isRootScope, executionId} = executeMessage.content;
|
|
45
|
+
const { isRootScope, executionId } = executeMessage.content;
|
|
45
46
|
|
|
46
47
|
const eventDefinitionExecution = this[kExecution];
|
|
47
48
|
if (isRootScope && executeMessage.content.id === this.id) {
|
|
@@ -65,7 +66,7 @@ BoundaryEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
|
65
66
|
consumerTag: `_api-${executionId}`,
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
const execQ = broker.assertQueue(`_bound-execution-${executionId}`, {durable: false, autoDelete: true});
|
|
69
|
+
const execQ = broker.assertQueue(`_bound-execution-${executionId}`, { durable: false, autoDelete: true });
|
|
69
70
|
broker.bindQueue(execQ.name, 'execution', 'execute.detach');
|
|
70
71
|
broker.bindQueue(execQ.name, 'execution', 'execute.bound.completed');
|
|
71
72
|
broker.bindQueue(execQ.name, 'execution', 'execute.repeat');
|
|
@@ -73,7 +74,7 @@ BoundaryEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
|
73
74
|
broker.bindQueue(execQ.name, 'execution', 'execute.expect');
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
execQ.consume(this._onExecutionMessage.bind(this), {consumerTag: '_execution-tag'});
|
|
77
|
+
execQ.consume(this._onExecutionMessage.bind(this), { consumerTag: '_execution-tag' });
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
if (eventDefinitionExecution) {
|
|
@@ -95,32 +96,43 @@ BoundaryEventBehaviour.prototype._onExecutionMessage = function onExecutionMessa
|
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
98
|
|
|
98
|
-
BoundaryEventBehaviour.prototype._onCompleted = function onCompleted(_, {content}) {
|
|
99
|
-
if (content.cancelActivity === false || !this.cancelActivity && !content.cancelActivity) {
|
|
99
|
+
BoundaryEventBehaviour.prototype._onCompleted = function onCompleted(_, { content }) {
|
|
100
|
+
if (content.cancelActivity === false || (!this.cancelActivity && !content.cancelActivity)) {
|
|
100
101
|
this._stop();
|
|
101
|
-
return this.broker.publish(
|
|
102
|
+
return this.broker.publish(
|
|
103
|
+
'execution',
|
|
104
|
+
'execute.completed',
|
|
105
|
+
cloneContent(content, { isDefinitionScope: false, cancelActivity: false }),
|
|
106
|
+
);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
this[kCompleteContent] = content;
|
|
105
110
|
|
|
106
|
-
const {inbound, executionId} = this[kExecuteMessage].content;
|
|
111
|
+
const { inbound, executionId } = this[kExecuteMessage].content;
|
|
107
112
|
const attachedToContent = inbound && inbound[0];
|
|
108
113
|
const attachedTo = this.attachedTo;
|
|
109
114
|
|
|
110
|
-
this.activity.logger.debug(
|
|
115
|
+
this.activity.logger.debug(
|
|
116
|
+
`<${executionId} (${this.id})> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`,
|
|
117
|
+
);
|
|
111
118
|
|
|
112
119
|
if (content.isRecovered && !attachedTo.isRunning) {
|
|
113
120
|
const attachedExecuteTag = `_on-attached-execute-${executionId}`;
|
|
114
121
|
this[kAttachedTags].push(attachedExecuteTag);
|
|
115
|
-
attachedTo.broker.subscribeOnce(
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
attachedTo.broker.subscribeOnce(
|
|
123
|
+
'execution',
|
|
124
|
+
'#',
|
|
125
|
+
() => {
|
|
126
|
+
attachedTo.getApi({ content: attachedToContent }).discard();
|
|
127
|
+
},
|
|
128
|
+
{ consumerTag: attachedExecuteTag },
|
|
129
|
+
);
|
|
118
130
|
} else {
|
|
119
|
-
attachedTo.getApi({content: attachedToContent}).discard();
|
|
131
|
+
attachedTo.getApi({ content: attachedToContent }).discard();
|
|
120
132
|
}
|
|
121
133
|
};
|
|
122
134
|
|
|
123
|
-
BoundaryEventBehaviour.prototype._onAttachedLeave = function onAttachedLeave(_, {content}) {
|
|
135
|
+
BoundaryEventBehaviour.prototype._onAttachedLeave = function onAttachedLeave(_, { content }) {
|
|
124
136
|
if (content.id !== this.attachedTo.id) return;
|
|
125
137
|
|
|
126
138
|
this._stop();
|
|
@@ -129,45 +141,59 @@ BoundaryEventBehaviour.prototype._onAttachedLeave = function onAttachedLeave(_,
|
|
|
129
141
|
return this.broker.publish('execution', 'execute.completed', cloneContent(completeContent));
|
|
130
142
|
};
|
|
131
143
|
|
|
132
|
-
BoundaryEventBehaviour.prototype._onExpectMessage = function onExpectMessage(_, {content}) {
|
|
133
|
-
const {executionId, expectRoutingKey, pattern, exchange} = content;
|
|
144
|
+
BoundaryEventBehaviour.prototype._onExpectMessage = function onExpectMessage(_, { content }) {
|
|
145
|
+
const { executionId, expectRoutingKey, pattern, exchange } = content;
|
|
134
146
|
const attachedTo = this.attachedTo;
|
|
135
147
|
|
|
136
148
|
const errorConsumerTag = `_bound-error-listener-${executionId}`;
|
|
137
149
|
this[kAttachedTags].push(errorConsumerTag);
|
|
138
150
|
|
|
139
|
-
attachedTo.broker.subscribeTmp(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
151
|
+
attachedTo.broker.subscribeTmp(
|
|
152
|
+
'event',
|
|
153
|
+
pattern,
|
|
154
|
+
(__, message) => {
|
|
155
|
+
if (message.content.id !== attachedTo.id) return;
|
|
156
|
+
this.broker.publish(exchange, expectRoutingKey, cloneContent(message.content, { attachedTo: attachedTo.id }), {
|
|
157
|
+
...message.properties,
|
|
158
|
+
mandatory: false,
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
noAck: true,
|
|
163
|
+
consumerTag: errorConsumerTag,
|
|
164
|
+
priority: 400,
|
|
165
|
+
},
|
|
166
|
+
);
|
|
147
167
|
};
|
|
148
168
|
|
|
149
169
|
BoundaryEventBehaviour.prototype._onDetachMessage = function onDetachMessage(_, message) {
|
|
150
170
|
const content = message.content;
|
|
151
|
-
const {executionId, parent} = this[kExecuteMessage].content;
|
|
152
|
-
const id = this.id,
|
|
171
|
+
const { executionId, parent } = this[kExecuteMessage].content;
|
|
172
|
+
const id = this.id,
|
|
173
|
+
attachedTo = this.attachedTo;
|
|
153
174
|
this.activity.logger.debug(`<${executionId} (${id})> detach from activity <${attachedTo.id}>`);
|
|
154
175
|
this._stop(true);
|
|
155
176
|
|
|
156
|
-
const {executionId: detachId, bindExchange, sourceExchange, sourcePattern} = content;
|
|
177
|
+
const { executionId: detachId, bindExchange, sourceExchange, sourcePattern } = content;
|
|
157
178
|
|
|
158
179
|
const shovelName = `_detached-${brokerSafeId(id)}_${detachId}`;
|
|
159
180
|
this[kShovels].push(shovelName);
|
|
160
181
|
|
|
161
182
|
const broker = this.broker;
|
|
162
|
-
attachedTo.broker.createShovel(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
183
|
+
attachedTo.broker.createShovel(
|
|
184
|
+
shovelName,
|
|
185
|
+
{
|
|
186
|
+
exchange: sourceExchange,
|
|
187
|
+
pattern: sourcePattern,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
broker,
|
|
191
|
+
exchange: bindExchange,
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
cloneMessage,
|
|
195
|
+
},
|
|
196
|
+
);
|
|
171
197
|
|
|
172
198
|
const detachContent = cloneContent(content, {
|
|
173
199
|
executionId,
|
|
@@ -177,12 +203,17 @@ BoundaryEventBehaviour.prototype._onDetachMessage = function onDetachMessage(_,
|
|
|
177
203
|
this.activity.removeInboundListeners();
|
|
178
204
|
broker.publish('event', 'activity.detach', detachContent);
|
|
179
205
|
|
|
180
|
-
broker.subscribeOnce(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
206
|
+
broker.subscribeOnce(
|
|
207
|
+
'execution',
|
|
208
|
+
'execute.bound.completed',
|
|
209
|
+
(__, { content: completeContent }) => {
|
|
210
|
+
this._stop();
|
|
211
|
+
this.broker.publish('execution', 'execute.completed', cloneContent(completeContent));
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
consumerTag: `_execution-completed-${executionId}`,
|
|
215
|
+
},
|
|
216
|
+
);
|
|
186
217
|
};
|
|
187
218
|
|
|
188
219
|
BoundaryEventBehaviour.prototype._onApiMessage = function onApiMessage(_, message) {
|
|
@@ -198,11 +229,15 @@ BoundaryEventBehaviour.prototype._onRepeatMessage = function onRepeatMessage(_,
|
|
|
198
229
|
if (this.cancelActivity) return;
|
|
199
230
|
const executeMessage = this[kExecuteMessage];
|
|
200
231
|
const repeat = message.content.repeat;
|
|
201
|
-
this.broker
|
|
232
|
+
this.broker
|
|
233
|
+
.getQueue('inbound-q')
|
|
234
|
+
.queueMessage({ routingKey: 'activity.restart' }, cloneContent(executeMessage.content.inbound[0], { repeat }));
|
|
202
235
|
};
|
|
203
236
|
|
|
204
237
|
BoundaryEventBehaviour.prototype._stop = function stop(detach) {
|
|
205
|
-
const attachedTo = this.attachedTo,
|
|
238
|
+
const attachedTo = this.attachedTo,
|
|
239
|
+
broker = this.broker,
|
|
240
|
+
executionId = this.executionId;
|
|
206
241
|
for (const tag of this[kAttachedTags].splice(0)) attachedTo.broker.cancel(tag);
|
|
207
242
|
for (const shovelName of this[kShovels].splice(0)) attachedTo.broker.closeShovel(shovelName);
|
|
208
243
|
|
package/src/events/EndEvent.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Activity from '../activity/Activity.js';
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution.js';
|
|
3
|
-
import {cloneContent} from '../messageHelper.js';
|
|
3
|
+
import { cloneContent } from '../messageHelper.js';
|
|
4
4
|
|
|
5
5
|
const kExecution = Symbol.for('execution');
|
|
6
6
|
|
|
7
7
|
export default function EndEvent(activityDef, context) {
|
|
8
|
-
return new Activity(EndEventBehaviour, {...activityDef, isThrowing: true}, context);
|
|
8
|
+
return new Activity(EndEventBehaviour, { ...activityDef, isThrowing: true }, context);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function EndEventBehaviour(activity) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Activity from '../activity/Activity.js';
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution.js';
|
|
3
|
-
import {cloneContent} from '../messageHelper.js';
|
|
3
|
+
import { cloneContent } from '../messageHelper.js';
|
|
4
4
|
|
|
5
5
|
const kExecution = Symbol.for('execution');
|
|
6
6
|
|
|
@@ -38,9 +38,13 @@ IntermediateCatchEventBehaviour.prototype._onApiMessage = function onApiMessage(
|
|
|
38
38
|
case 'signal': {
|
|
39
39
|
const broker = this.broker;
|
|
40
40
|
broker.cancel('_api-behaviour-execution');
|
|
41
|
-
return broker.publish(
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
return broker.publish(
|
|
42
|
+
'execution',
|
|
43
|
+
'execute.completed',
|
|
44
|
+
cloneContent(executeMessage.content, {
|
|
45
|
+
output: message.content.message,
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
44
48
|
}
|
|
45
49
|
case 'discard': {
|
|
46
50
|
const broker = this.broker;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Activity from '../activity/Activity.js';
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution.js';
|
|
3
|
-
import {cloneContent} from '../messageHelper.js';
|
|
3
|
+
import { cloneContent } from '../messageHelper.js';
|
|
4
4
|
|
|
5
5
|
const kExecution = Symbol.for('execution');
|
|
6
6
|
|
|
7
7
|
export default function IntermediateThrowEvent(activityDef, context) {
|
|
8
|
-
return new Activity(IntermediateThrowEventBehaviour, {...activityDef, isThrowing: true}, context);
|
|
8
|
+
return new Activity(IntermediateThrowEventBehaviour, { ...activityDef, isThrowing: true }, context);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function IntermediateThrowEventBehaviour(activity) {
|
package/src/events/StartEvent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Activity from '../activity/Activity.js';
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution.js';
|
|
3
|
-
import {cloneContent} from '../messageHelper.js';
|
|
3
|
+
import { cloneContent } from '../messageHelper.js';
|
|
4
4
|
|
|
5
5
|
const kExecuteMessage = Symbol.for('executeMessage');
|
|
6
6
|
const kExecution = Symbol.for('execution');
|
|
@@ -47,26 +47,31 @@ StartEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
|
47
47
|
noAck: true,
|
|
48
48
|
consumerTag: `_api-delegated-${executionId}`,
|
|
49
49
|
});
|
|
50
|
-
broker.publish('event', 'activity.wait', {...content, executionId, state: 'wait'});
|
|
50
|
+
broker.publish('event', 'activity.wait', { ...content, executionId, state: 'wait' });
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
StartEventBehaviour.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
54
|
-
const {type: messageType, correlationId} = message.properties;
|
|
54
|
+
const { type: messageType, correlationId } = message.properties;
|
|
55
55
|
switch (messageType) {
|
|
56
56
|
case 'stop':
|
|
57
57
|
return this._stop();
|
|
58
58
|
case 'signal': {
|
|
59
59
|
this._stop();
|
|
60
60
|
const content = this[kExecuteMessage].content;
|
|
61
|
-
return this.broker.publish(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
return this.broker.publish(
|
|
62
|
+
'execution',
|
|
63
|
+
'execute.completed',
|
|
64
|
+
cloneContent(content, {
|
|
65
|
+
output: message.content.message,
|
|
66
|
+
state: 'signal',
|
|
67
|
+
}),
|
|
68
|
+
{ correlationId },
|
|
69
|
+
);
|
|
65
70
|
}
|
|
66
71
|
case 'discard': {
|
|
67
72
|
this._stop();
|
|
68
73
|
const content = this[kExecuteMessage].content;
|
|
69
|
-
return this.broker.publish('execution', 'execute.discard', cloneContent(content), {correlationId});
|
|
74
|
+
return this.broker.publish('execution', 'execute.discard', cloneContent(content), { correlationId });
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
};
|
|
@@ -77,25 +82,31 @@ StartEventBehaviour.prototype._onDelegatedApiMessage = function onDelegatedApiMe
|
|
|
77
82
|
const content = message.content;
|
|
78
83
|
if (!content.message) return;
|
|
79
84
|
|
|
80
|
-
const {id: signalId, executionId: signalExecutionId} = content.message;
|
|
85
|
+
const { id: signalId, executionId: signalExecutionId } = content.message;
|
|
81
86
|
if (signalId !== this.id && signalExecutionId !== this.executionId) return;
|
|
82
87
|
|
|
83
|
-
const {type, correlationId} = message.properties;
|
|
88
|
+
const { type, correlationId } = message.properties;
|
|
84
89
|
const executeContent = this[kExecuteMessage].content;
|
|
85
|
-
this.broker.publish(
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
this.broker.publish(
|
|
91
|
+
'event',
|
|
92
|
+
'activity.consumed',
|
|
93
|
+
cloneContent(executeContent, {
|
|
94
|
+
message: {
|
|
95
|
+
...content.message,
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
{
|
|
99
|
+
correlationId,
|
|
100
|
+
type,
|
|
88
101
|
},
|
|
89
|
-
|
|
90
|
-
correlationId,
|
|
91
|
-
type,
|
|
92
|
-
});
|
|
102
|
+
);
|
|
93
103
|
|
|
94
104
|
return this._onApiMessage(routingKey, message);
|
|
95
105
|
};
|
|
96
106
|
|
|
97
107
|
StartEventBehaviour.prototype._stop = function stop() {
|
|
98
|
-
const broker = this.broker,
|
|
108
|
+
const broker = this.broker,
|
|
109
|
+
executionId = this.executionId;
|
|
99
110
|
broker.cancel(`_api-${executionId}`);
|
|
100
111
|
broker.cancel(`_api-delegated-${executionId}`);
|
|
101
112
|
};
|
package/src/flows/Association.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {cloneParent} from '../messageHelper.js';
|
|
2
|
-
import {EventBroker} from '../EventBroker.js';
|
|
3
|
-
import {Api} from '../Api.js';
|
|
4
|
-
import {getUniqueId} from '../shared.js';
|
|
1
|
+
import { cloneParent } from '../messageHelper.js';
|
|
2
|
+
import { EventBroker } from '../EventBroker.js';
|
|
3
|
+
import { Api } from '../Api.js';
|
|
4
|
+
import { getUniqueId } from '../shared.js';
|
|
5
5
|
|
|
6
6
|
const kCounters = Symbol.for('counters');
|
|
7
7
|
|
|
8
|
-
export default function Association(associationDef, {environment}) {
|
|
9
|
-
const {id, type = 'association', name, parent, targetId, sourceId, behaviour = {}} = associationDef;
|
|
8
|
+
export default function Association(associationDef, { environment }) {
|
|
9
|
+
const { id, type = 'association', name, parent, targetId, sourceId, behaviour = {} } = associationDef;
|
|
10
10
|
|
|
11
11
|
this.id = id;
|
|
12
12
|
this.type = type;
|
|
@@ -17,14 +17,14 @@ export default function Association(associationDef, {environment}) {
|
|
|
17
17
|
this.targetId = targetId;
|
|
18
18
|
this.isAssociation = true;
|
|
19
19
|
this.environment = environment;
|
|
20
|
-
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
20
|
+
const logger = (this.logger = environment.Logger(type.toLowerCase()));
|
|
21
21
|
|
|
22
22
|
this[kCounters] = {
|
|
23
23
|
take: 0,
|
|
24
24
|
discard: 0,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const {broker, on, once, waitFor} = new EventBroker(this, {prefix: 'association', durable: true, autoDelete: false});
|
|
27
|
+
const { broker, on, once, waitFor } = new EventBroker(this, { prefix: 'association', durable: true, autoDelete: false });
|
|
28
28
|
this.broker = broker;
|
|
29
29
|
this.on = on;
|
|
30
30
|
this.once = once;
|
|
@@ -35,7 +35,7 @@ export default function Association(associationDef, {environment}) {
|
|
|
35
35
|
|
|
36
36
|
Object.defineProperty(Association.prototype, 'counters', {
|
|
37
37
|
get() {
|
|
38
|
-
return {...this[kCounters]};
|
|
38
|
+
return { ...this[kCounters] };
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -75,7 +75,7 @@ Association.prototype.recover = function recover(state) {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
Association.prototype.getApi = function getApi(message) {
|
|
78
|
-
return new Api('association', this.broker, message || {content: this._createMessageContent()});
|
|
78
|
+
return new Api('association', this.broker, message || { content: this._createMessageContent() });
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
Association.prototype.stop = function stop() {
|
|
@@ -89,7 +89,7 @@ Association.prototype._publishEvent = function publishEvent(action, content) {
|
|
|
89
89
|
sequenceId: getUniqueId(this.id),
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
this.broker.publish('event', `association.${action}`, eventContent, {type: action});
|
|
92
|
+
this.broker.publish('event', `association.${action}`, eventContent, { type: action });
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
Association.prototype._createMessageContent = function createMessageContent(override) {
|
package/src/flows/MessageFlow.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {brokerSafeId} from '../shared.js';
|
|
2
|
-
import {cloneParent} from '../messageHelper.js';
|
|
3
|
-
import {MessageFlowBroker} from '../EventBroker.js';
|
|
4
|
-
import {Api} from '../Api.js';
|
|
1
|
+
import { brokerSafeId } from '../shared.js';
|
|
2
|
+
import { cloneParent } from '../messageHelper.js';
|
|
3
|
+
import { MessageFlowBroker } from '../EventBroker.js';
|
|
4
|
+
import { Api } from '../Api.js';
|
|
5
5
|
|
|
6
6
|
const kCounters = Symbol.for('counters');
|
|
7
7
|
const kSourceElement = Symbol.for('sourceElement');
|
|
8
8
|
|
|
9
9
|
export default function MessageFlow(flowDef, context) {
|
|
10
|
-
const {id, type = 'messageflow', name, target, source, behaviour, parent} = flowDef;
|
|
10
|
+
const { id, type = 'messageflow', name, target, source, behaviour, parent } = flowDef;
|
|
11
11
|
|
|
12
12
|
this.id = id;
|
|
13
13
|
this.type = type;
|
|
@@ -23,7 +23,7 @@ export default function MessageFlow(flowDef, context) {
|
|
|
23
23
|
messages: 0,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const {broker, on, once, emit, waitFor} = MessageFlowBroker(this);
|
|
26
|
+
const { broker, on, once, emit, waitFor } = MessageFlowBroker(this);
|
|
27
27
|
this.broker = broker;
|
|
28
28
|
this.on = on;
|
|
29
29
|
this.once = once;
|
|
@@ -36,7 +36,7 @@ export default function MessageFlow(flowDef, context) {
|
|
|
36
36
|
|
|
37
37
|
Object.defineProperty(MessageFlow.prototype, 'counters', {
|
|
38
38
|
get() {
|
|
39
|
-
return {...this[kCounters]};
|
|
39
|
+
return { ...this[kCounters] };
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -58,14 +58,14 @@ MessageFlow.prototype.recover = function recover(state) {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
MessageFlow.prototype.getApi = function getApi(message) {
|
|
61
|
-
return new Api('message', this.broker, message || {content: this._createMessageContent()});
|
|
61
|
+
return new Api('message', this.broker, message || { content: this._createMessageContent() });
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
MessageFlow.prototype.activate = function activate() {
|
|
65
65
|
const sourceElement = this[kSourceElement];
|
|
66
66
|
const safeId = brokerSafeId(this.id);
|
|
67
|
-
sourceElement.on('message', this.deactivate.bind(this), {consumerTag: `_message-on-message-${safeId}`});
|
|
68
|
-
sourceElement.on('end', this._onSourceEnd.bind(this), {consumerTag: `_message-on-end-${safeId}`});
|
|
67
|
+
sourceElement.on('message', this.deactivate.bind(this), { consumerTag: `_message-on-message-${safeId}` });
|
|
68
|
+
sourceElement.on('end', this._onSourceEnd.bind(this), { consumerTag: `_message-on-end-${safeId}` });
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
MessageFlow.prototype.deactivate = function deactivate() {
|
|
@@ -75,11 +75,13 @@ MessageFlow.prototype.deactivate = function deactivate() {
|
|
|
75
75
|
sourceElement.broker.cancel(`_message-on-message-${safeId}`);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
MessageFlow.prototype._onSourceEnd = function onSourceEnd({content}) {
|
|
78
|
+
MessageFlow.prototype._onSourceEnd = function onSourceEnd({ content }) {
|
|
79
79
|
++this[kCounters].messages;
|
|
80
80
|
const source = this.source;
|
|
81
81
|
const target = this.target;
|
|
82
|
-
this.logger.debug(
|
|
82
|
+
this.logger.debug(
|
|
83
|
+
`<${this.id}> sending message from <${source.processId}.${source.id}> to <${target.id ? `${target.processId}.${target.id}` : target.processId}>`,
|
|
84
|
+
);
|
|
83
85
|
this.broker.publish('event', 'message.outbound', this._createMessageContent(content.message));
|
|
84
86
|
};
|
|
85
87
|
|
|
@@ -88,8 +90,8 @@ MessageFlow.prototype._createMessageContent = function createMessage(message) {
|
|
|
88
90
|
id: this.id,
|
|
89
91
|
type: this.type,
|
|
90
92
|
name: this.name,
|
|
91
|
-
source: {...this.source},
|
|
92
|
-
target: {...this.target},
|
|
93
|
+
source: { ...this.source },
|
|
94
|
+
target: { ...this.target },
|
|
93
95
|
parent: cloneParent(this.parent),
|
|
94
96
|
message,
|
|
95
97
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import ExecutionScope from '../activity/ExecutionScope.js';
|
|
2
|
-
import {cloneParent, cloneContent} from '../messageHelper.js';
|
|
3
|
-
import {getUniqueId} from '../shared.js';
|
|
4
|
-
import {EventBroker} from '../EventBroker.js';
|
|
5
|
-
import {FlowApi} from '../Api.js';
|
|
2
|
+
import { cloneParent, cloneContent } from '../messageHelper.js';
|
|
3
|
+
import { getUniqueId } from '../shared.js';
|
|
4
|
+
import { EventBroker } from '../EventBroker.js';
|
|
5
|
+
import { FlowApi } from '../Api.js';
|
|
6
6
|
|
|
7
7
|
const kCounters = Symbol.for('counters');
|
|
8
8
|
|
|
9
9
|
export default SequenceFlow;
|
|
10
10
|
|
|
11
|
-
function SequenceFlow(flowDef, {environment}) {
|
|
12
|
-
const {id, type = 'sequenceflow', name, parent, targetId, sourceId, isDefault, behaviour = {}} = flowDef;
|
|
11
|
+
function SequenceFlow(flowDef, { environment }) {
|
|
12
|
+
const { id, type = 'sequenceflow', name, parent, targetId, sourceId, isDefault, behaviour = {} } = flowDef;
|
|
13
13
|
|
|
14
14
|
this.id = id;
|
|
15
15
|
this.type = type;
|
|
@@ -21,7 +21,7 @@ function SequenceFlow(flowDef, {environment}) {
|
|
|
21
21
|
this.isDefault = isDefault;
|
|
22
22
|
this.isSequenceFlow = true;
|
|
23
23
|
this.environment = environment;
|
|
24
|
-
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
24
|
+
const logger = (this.logger = environment.Logger(type.toLowerCase()));
|
|
25
25
|
|
|
26
26
|
this[kCounters] = {
|
|
27
27
|
looped: 0,
|
|
@@ -30,7 +30,7 @@ function SequenceFlow(flowDef, {environment}) {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
environment.registerScript(this);
|
|
33
|
-
const {broker, on, once, waitFor, emitFatal} = new EventBroker(this, {prefix: 'flow', durable: true, autoDelete: false});
|
|
33
|
+
const { broker, on, once, waitFor, emitFatal } = new EventBroker(this, { prefix: 'flow', durable: true, autoDelete: false });
|
|
34
34
|
this.broker = broker;
|
|
35
35
|
this.on = on;
|
|
36
36
|
this.once = once;
|
|
@@ -42,12 +42,12 @@ function SequenceFlow(flowDef, {environment}) {
|
|
|
42
42
|
|
|
43
43
|
Object.defineProperty(SequenceFlow.prototype, 'counters', {
|
|
44
44
|
get() {
|
|
45
|
-
return {...this[kCounters]};
|
|
45
|
+
return { ...this[kCounters] };
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
SequenceFlow.prototype.take = function take(content = {}) {
|
|
50
|
-
const {sequenceId} = content;
|
|
50
|
+
const { sequenceId } = content;
|
|
51
51
|
|
|
52
52
|
this.logger.debug(`<${sequenceId} (${this.id})> take, target <${this.targetId}>`);
|
|
53
53
|
++this[kCounters].take;
|
|
@@ -58,8 +58,8 @@ SequenceFlow.prototype.take = function take(content = {}) {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
SequenceFlow.prototype.discard = function discard(content = {}) {
|
|
61
|
-
const {sequenceId = getUniqueId(this.id)} = content;
|
|
62
|
-
const discardSequence = content.discardSequence = (content.discardSequence || []).slice();
|
|
61
|
+
const { sequenceId = getUniqueId(this.id) } = content;
|
|
62
|
+
const discardSequence = (content.discardSequence = (content.discardSequence || []).slice());
|
|
63
63
|
if (discardSequence.indexOf(this.targetId) > -1) {
|
|
64
64
|
++this[kCounters].looped;
|
|
65
65
|
this.logger.debug(`<${this.id}> discard loop detected <${this.sourceId}> -> <${this.targetId}>. Stop.`);
|
|
@@ -91,7 +91,7 @@ SequenceFlow.prototype.recover = function recover(state) {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
SequenceFlow.prototype.getApi = function getApi(message) {
|
|
94
|
-
return FlowApi(this.broker, message || {content: this.createMessage()});
|
|
94
|
+
return FlowApi(this.broker, message || { content: this.createMessage() });
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
SequenceFlow.prototype.stop = function stop() {
|
|
@@ -101,29 +101,31 @@ SequenceFlow.prototype.stop = function stop() {
|
|
|
101
101
|
SequenceFlow.prototype.shake = function shake(message) {
|
|
102
102
|
const content = cloneContent(message.content);
|
|
103
103
|
content.sequence = content.sequence || [];
|
|
104
|
-
content.sequence.push({id: this.id, type: this.type, isSequenceFlow: true, targetId: this.targetId});
|
|
104
|
+
content.sequence.push({ id: this.id, type: this.type, isSequenceFlow: true, targetId: this.targetId });
|
|
105
105
|
|
|
106
|
-
if (content.id === this.targetId) return this.broker.publish('event', 'flow.shake.loop', content, {persistent: false, type: 'shake'});
|
|
106
|
+
if (content.id === this.targetId) return this.broker.publish('event', 'flow.shake.loop', content, { persistent: false, type: 'shake' });
|
|
107
107
|
|
|
108
108
|
for (const s of message.content.sequence || []) {
|
|
109
|
-
if (s.id === this.id) return this.broker.publish('event', 'flow.shake.loop', content, {persistent: false, type: 'shake'});
|
|
109
|
+
if (s.id === this.id) return this.broker.publish('event', 'flow.shake.loop', content, { persistent: false, type: 'shake' });
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
this.broker.publish('event', 'flow.shake', content, {persistent: false, type: 'shake'});
|
|
112
|
+
this.broker.publish('event', 'flow.shake', content, { persistent: false, type: 'shake' });
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
SequenceFlow.prototype.getCondition = function getCondition() {
|
|
116
116
|
const conditionExpression = this.behaviour.conditionExpression;
|
|
117
117
|
if (!conditionExpression) return null;
|
|
118
118
|
|
|
119
|
-
const {language} = conditionExpression;
|
|
119
|
+
const { language } = conditionExpression;
|
|
120
120
|
const script = this.environment.getScript(language, this);
|
|
121
121
|
if (script) {
|
|
122
122
|
return new ScriptCondition(this, script, language);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
if (!conditionExpression.body) {
|
|
126
|
-
const msg = language
|
|
126
|
+
const msg = language
|
|
127
|
+
? `Condition expression script ${language} is unsupported or was not registered`
|
|
128
|
+
: 'Condition expression without body is unsupported';
|
|
127
129
|
return this.emitFatal(new Error(msg), this.createMessage());
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -163,7 +165,7 @@ SequenceFlow.prototype._publishEvent = function publishEvent(action, content) {
|
|
|
163
165
|
...content,
|
|
164
166
|
});
|
|
165
167
|
|
|
166
|
-
this.broker.publish('event', `flow.${action}`, eventContent, {type: action});
|
|
168
|
+
this.broker.publish('event', `flow.${action}`, eventContent, { type: action });
|
|
167
169
|
};
|
|
168
170
|
|
|
169
171
|
function ScriptCondition(owner, script, language) {
|