bpmn-elements 8.2.4 → 9.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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/{src/Api.js → Api.js} +11 -12
- package/dist/{src/Context.js → Context.js} +26 -27
- package/dist/{src/Environment.js → Environment.js} +15 -16
- package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/Tracker.js +89 -0
- package/dist/{src/activity → activity}/Activity.js +109 -120
- package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
- package/dist/{src/activity → activity}/Dummy.js +1 -1
- package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
- package/dist/{src/definition → definition}/Definition.js +64 -59
- package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
- package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
- package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
- package/dist/{src/events → events}/BoundaryEvent.js +39 -25
- package/dist/{src/events → events}/EndEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
- package/dist/{src/events → events}/StartEvent.js +8 -9
- package/dist/{src/flows → flows}/Association.js +14 -22
- package/dist/{src/flows → flows}/MessageFlow.js +16 -14
- package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
- package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
- package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
- package/dist/index.js +48 -48
- package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
- package/dist/{src/io → io}/Properties.js +7 -8
- package/dist/package.json +3 -0
- package/dist/{src/process → process}/Process.js +44 -40
- package/dist/{src/process → process}/ProcessExecution.js +169 -78
- package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
- package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
- package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
- package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
- package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
- package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
- package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
- package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
- package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +31 -31
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +2 -1
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/Tracker.js +73 -0
- package/src/activity/Activity.js +106 -114
- package/src/activity/ActivityExecution.js +28 -32
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +65 -64
- package/src/definition/DefinitionExecution.js +71 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +32 -78
- package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
- package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
- package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
- package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
- package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
- package/src/eventDefinitions/LinkEventDefinition.js +14 -16
- package/src/eventDefinitions/MessageEventDefinition.js +13 -15
- package/src/eventDefinitions/SignalEventDefinition.js +13 -15
- package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +15 -17
- package/src/events/BoundaryEvent.js +34 -24
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +8 -10
- package/src/flows/Association.js +14 -26
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +3 -4
- package/src/gateways/ExclusiveGateway.js +2 -2
- package/src/gateways/InclusiveGateway.js +2 -2
- package/src/gateways/ParallelGateway.js +2 -2
- package/src/index.js +106 -0
- package/src/io/InputOutputSpecification.js +8 -10
- package/src/io/Properties.js +7 -9
- package/src/process/Process.js +45 -41
- package/src/process/ProcessExecution.js +167 -79
- package/src/tasks/CallActivity.js +7 -9
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ReceiveTask.js +215 -217
- package/src/tasks/ScriptTask.js +4 -4
- package/src/tasks/ServiceImplementation.js +1 -1
- package/src/tasks/ServiceTask.js +6 -8
- package/src/tasks/SignalTask.js +7 -9
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +19 -20
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +520 -0
- package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
- package/index.js +0 -106
- /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
- /package/dist/{src/Scripts.js → Scripts.js} +0 -0
- /package/dist/{src/Timers.js → Timers.js} +0 -0
- /package/dist/{src/activity → activity}/Escalation.js +0 -0
- /package/dist/{src/activity → activity}/Message.js +0 -0
- /package/dist/{src/activity → activity}/Signal.js +0 -0
- /package/dist/{src/error → error}/BpmnError.js +0 -0
- /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
- /package/dist/{src/io → io}/BpmnIO.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
- /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
- /package/dist/{src/shared.js → shared.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ActivityApi} from '../Api';
|
|
2
|
-
import {cloneContent, cloneMessage} from '../messageHelper';
|
|
1
|
+
import {ActivityApi} from '../Api.js';
|
|
2
|
+
import {cloneContent, cloneMessage} from '../messageHelper.js';
|
|
3
3
|
|
|
4
4
|
const kCompleted = Symbol.for('completed');
|
|
5
5
|
const kExecuteQ = Symbol.for('executeQ');
|
|
@@ -24,16 +24,14 @@ function ActivityExecution(activity, context) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(proto, 'completed', {
|
|
27
|
+
Object.defineProperty(ActivityExecution.prototype, 'completed', {
|
|
30
28
|
enumerable: true,
|
|
31
29
|
get() {
|
|
32
30
|
return this[kCompleted];
|
|
33
31
|
},
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
ActivityExecution.prototype.execute = function execute(executeMessage) {
|
|
37
35
|
if (!executeMessage) throw new Error('Execution requires message');
|
|
38
36
|
const executionId = executeMessage.content && executeMessage.content.executionId;
|
|
39
37
|
if (!executionId) throw new Error('Execution requires execution id');
|
|
@@ -61,7 +59,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
61
59
|
this.broker.publish('execution', 'execute.start', cloneContent(initMessage.content));
|
|
62
60
|
};
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
ActivityExecution.prototype.activate = function activate() {
|
|
65
63
|
if (this[kCompleted]) return;
|
|
66
64
|
|
|
67
65
|
const broker = this.broker;
|
|
@@ -85,21 +83,21 @@ proto.activate = function activate() {
|
|
|
85
83
|
});
|
|
86
84
|
};
|
|
87
85
|
|
|
88
|
-
|
|
86
|
+
ActivityExecution.prototype.deactivate = function deactivate() {
|
|
89
87
|
const broker = this.broker;
|
|
90
88
|
broker.cancel('_activity-api-execution');
|
|
91
89
|
broker.cancel('_activity-execute');
|
|
92
90
|
broker.unbindQueue('execute-q', 'execution', 'execute.#');
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
ActivityExecution.prototype.discard = function discard() {
|
|
96
94
|
if (this[kCompleted]) return;
|
|
97
95
|
const initMessage = this[kExecuteMessage];
|
|
98
96
|
if (!initMessage) return this.activity.logger.warn(`<${this.id}> is not executing`);
|
|
99
97
|
this.getApi(initMessage).discard();
|
|
100
98
|
};
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
ActivityExecution.prototype.getApi = function getApi(apiMessage) {
|
|
103
101
|
const self = this;
|
|
104
102
|
if (!apiMessage) apiMessage = this[kExecuteMessage];
|
|
105
103
|
|
|
@@ -121,19 +119,19 @@ proto.getApi = function getApi(apiMessage) {
|
|
|
121
119
|
return api;
|
|
122
120
|
};
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
ActivityExecution.prototype.passthrough = function passthrough(executeMessage) {
|
|
125
123
|
if (!this.source) return this.execute(executeMessage);
|
|
126
124
|
return this._sourceExecute(executeMessage);
|
|
127
125
|
};
|
|
128
126
|
|
|
129
|
-
|
|
127
|
+
ActivityExecution.prototype.getPostponed = function getPostponed() {
|
|
130
128
|
let apis = this[kPostponed].map((msg) => this.getApi(msg));
|
|
131
129
|
if (!this.activity.isSubProcess || !this.source) return apis;
|
|
132
130
|
apis = apis.concat(this.source.getPostponed());
|
|
133
131
|
return apis;
|
|
134
132
|
};
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
ActivityExecution.prototype.getState = function getState() {
|
|
137
135
|
const result = {completed: this[kCompleted]};
|
|
138
136
|
const source = this.source;
|
|
139
137
|
|
|
@@ -141,7 +139,7 @@ proto.getState = function getState() {
|
|
|
141
139
|
return {...result, ...source.getState()};
|
|
142
140
|
};
|
|
143
141
|
|
|
144
|
-
|
|
142
|
+
ActivityExecution.prototype.recover = function recover(state) {
|
|
145
143
|
this[kPostponed].splice(0);
|
|
146
144
|
|
|
147
145
|
if (!state) return this;
|
|
@@ -155,13 +153,13 @@ proto.recover = function recover(state) {
|
|
|
155
153
|
return this;
|
|
156
154
|
};
|
|
157
155
|
|
|
158
|
-
|
|
156
|
+
ActivityExecution.prototype.stop = function stop() {
|
|
159
157
|
const executeMessage = this[kExecuteMessage];
|
|
160
158
|
if (!executeMessage) return;
|
|
161
159
|
this.getApi(executeMessage).stop();
|
|
162
160
|
};
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
ActivityExecution.prototype._sourceExecute = function sourceExecute(executeMessage) {
|
|
165
163
|
try {
|
|
166
164
|
return this.source.execute(executeMessage);
|
|
167
165
|
} catch (error) {
|
|
@@ -169,7 +167,7 @@ proto._sourceExecute = function sourceExecute(executeMessage) {
|
|
|
169
167
|
}
|
|
170
168
|
};
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
173
171
|
const {fields, content, properties} = message;
|
|
174
172
|
const isRedelivered = fields.redelivered;
|
|
175
173
|
|
|
@@ -180,10 +178,12 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
|
180
178
|
if (!this[kPostponed].length) return this.broker.publish('execution', 'execute.start', cloneContent(this[kExecuteMessage].content));
|
|
181
179
|
break;
|
|
182
180
|
}
|
|
181
|
+
case 'execute.cancel':
|
|
182
|
+
return this._onExecutionDiscarded('cancel', message);
|
|
183
183
|
case 'execute.error':
|
|
184
|
+
return this._onExecutionDiscarded('error', message);
|
|
184
185
|
case 'execute.discard':
|
|
185
|
-
return this._onExecutionDiscarded(message);
|
|
186
|
-
case 'execute.cancel':
|
|
186
|
+
return this._onExecutionDiscarded('discard', message);
|
|
187
187
|
case 'execute.completed': {
|
|
188
188
|
if (isRedelivered) {
|
|
189
189
|
message.ack();
|
|
@@ -213,7 +213,7 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
ActivityExecution.prototype._onStateChangeMessage = function onStateChangeMessage(message) {
|
|
217
217
|
const {ignoreIfExecuting, executionId} = message.content;
|
|
218
218
|
const postponed = this[kPostponed];
|
|
219
219
|
const idx = postponed.findIndex((msg) => msg.content.executionId === executionId);
|
|
@@ -234,7 +234,7 @@ proto._onStateChangeMessage = function onStateChangeMessage(message) {
|
|
|
234
234
|
return true;
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
ActivityExecution.prototype._onExecutionCompleted = function onExecutionCompleted(message) {
|
|
238
238
|
const postponedMsg = this._ackPostponed(message);
|
|
239
239
|
if (!postponedMsg) return;
|
|
240
240
|
const postponed = this[kPostponed];
|
|
@@ -263,7 +263,7 @@ proto._onExecutionCompleted = function onExecutionCompleted(message) {
|
|
|
263
263
|
this._publishExecutionCompleted('completed', {...postponedMsg.content, ...message.content}, message.properties.correlationId);
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarded(discardType, message) {
|
|
267
267
|
const postponedMsg = this._ackPostponed(message);
|
|
268
268
|
const {isRootScope, error} = message.content;
|
|
269
269
|
if (!isRootScope && !postponedMsg) return;
|
|
@@ -286,14 +286,10 @@ proto._onExecutionDiscarded = function onExecutionDiscarded(message) {
|
|
|
286
286
|
postponed.splice(0);
|
|
287
287
|
for (const api of subApis) api.discard();
|
|
288
288
|
|
|
289
|
-
|
|
290
|
-
return this._publishExecutionCompleted('error', cloneContent(message.content, {error}), correlationId);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
this._publishExecutionCompleted('discard', message.content, correlationId);
|
|
289
|
+
this._publishExecutionCompleted(discardType, cloneContent(message.content), correlationId);
|
|
294
290
|
};
|
|
295
291
|
|
|
296
|
-
|
|
292
|
+
ActivityExecution.prototype._publishExecutionCompleted = function publishExecutionCompleted(completionType, completeContent, correlationId) {
|
|
297
293
|
this[kCompleted] = true;
|
|
298
294
|
|
|
299
295
|
this.broker.publish('execution', `execution.${completionType}`, {
|
|
@@ -302,7 +298,7 @@ proto._publishExecutionCompleted = function publishExecutionCompleted(completion
|
|
|
302
298
|
}, {type: completionType, correlationId});
|
|
303
299
|
};
|
|
304
300
|
|
|
305
|
-
|
|
301
|
+
ActivityExecution.prototype._ackPostponed = function ackPostponed(completeMessage) {
|
|
306
302
|
const {executionId: eid} = completeMessage.content;
|
|
307
303
|
|
|
308
304
|
const postponed = this[kPostponed];
|
|
@@ -313,7 +309,7 @@ proto._ackPostponed = function ackPostponed(completeMessage) {
|
|
|
313
309
|
return msg;
|
|
314
310
|
};
|
|
315
311
|
|
|
316
|
-
|
|
312
|
+
ActivityExecution.prototype._onParentApiMessage = function onParentApiMessage(routingKey, message) {
|
|
317
313
|
switch (message.properties.type) {
|
|
318
314
|
case 'error':
|
|
319
315
|
return this[kExecuteQ].queueMessage({routingKey: 'execute.error'}, {error: message.content.error});
|
|
@@ -325,7 +321,7 @@ proto._onParentApiMessage = function onParentApiMessage(routingKey, message) {
|
|
|
325
321
|
}
|
|
326
322
|
};
|
|
327
323
|
|
|
328
|
-
|
|
324
|
+
ActivityExecution.prototype._onStop = function onStop(message) {
|
|
329
325
|
const stoppedId = message && message.content && message.content.executionId;
|
|
330
326
|
const running = this.getPostponed();
|
|
331
327
|
for (const api of running) {
|
|
@@ -338,7 +334,7 @@ proto._onStop = function onStop(message) {
|
|
|
338
334
|
this.broker.cancel('_activity-api-execution');
|
|
339
335
|
};
|
|
340
336
|
|
|
341
|
-
|
|
337
|
+
ActivityExecution.prototype._debug = function debug(logMessage, executionId) {
|
|
342
338
|
executionId = executionId || this.executionId;
|
|
343
339
|
this.activity.logger.debug(`<${executionId} (${this.id})> ${logMessage}`);
|
|
344
340
|
};
|
package/src/activity/Dummy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {cloneMessage} from '../messageHelper';
|
|
2
|
-
import {ActivityError, BpmnError} from '../error/Errors';
|
|
1
|
+
import {cloneMessage} from '../messageHelper.js';
|
|
2
|
+
import {ActivityError, BpmnError} from '../error/Errors.js';
|
|
3
3
|
|
|
4
4
|
export default function ExecutionScope(activity, initMessage) {
|
|
5
5
|
const {id, type, environment, logger} = activity;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import DefinitionExecution from './DefinitionExecution';
|
|
2
|
-
import {DefinitionApi} from '../Api';
|
|
3
|
-
import {DefinitionBroker} from '../EventBroker';
|
|
4
|
-
import {getUniqueId, getOptionsAndCallback} from '../shared';
|
|
5
|
-
import {makeErrorFromMessage} from '../error/Errors';
|
|
6
|
-
import {cloneMessage, cloneContent} from '../messageHelper';
|
|
1
|
+
import DefinitionExecution from './DefinitionExecution.js';
|
|
2
|
+
import {DefinitionApi} from '../Api.js';
|
|
3
|
+
import {DefinitionBroker} from '../EventBroker.js';
|
|
4
|
+
import {getUniqueId, getOptionsAndCallback} from '../shared.js';
|
|
5
|
+
import {makeErrorFromMessage} from '../error/Errors.js';
|
|
6
|
+
import {cloneMessage, cloneContent} from '../messageHelper.js';
|
|
7
7
|
|
|
8
8
|
const kConsuming = Symbol.for('consuming');
|
|
9
9
|
const kCounters = Symbol.for('counters');
|
|
@@ -63,30 +63,28 @@ export function Definition(context, options) {
|
|
|
63
63
|
this.logger = environment.Logger(type.toLowerCase());
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Object.defineProperty(proto, 'counters', {
|
|
66
|
+
Object.defineProperty(Definition.prototype, 'counters', {
|
|
69
67
|
enumerable: true,
|
|
70
68
|
get() {
|
|
71
69
|
return {...this[kCounters]};
|
|
72
70
|
},
|
|
73
71
|
});
|
|
74
72
|
|
|
75
|
-
Object.defineProperty(
|
|
73
|
+
Object.defineProperty(Definition.prototype, 'execution', {
|
|
76
74
|
enumerable: true,
|
|
77
75
|
get() {
|
|
78
76
|
return this[kExec].execution;
|
|
79
77
|
},
|
|
80
78
|
});
|
|
81
79
|
|
|
82
|
-
Object.defineProperty(
|
|
80
|
+
Object.defineProperty(Definition.prototype, 'executionId', {
|
|
83
81
|
enumerable: true,
|
|
84
82
|
get() {
|
|
85
83
|
return this[kExec].executionId;
|
|
86
84
|
},
|
|
87
85
|
});
|
|
88
86
|
|
|
89
|
-
Object.defineProperty(
|
|
87
|
+
Object.defineProperty(Definition.prototype, 'isRunning', {
|
|
90
88
|
enumerable: true,
|
|
91
89
|
get() {
|
|
92
90
|
if (!this[kConsuming]) return false;
|
|
@@ -94,21 +92,27 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
94
92
|
},
|
|
95
93
|
});
|
|
96
94
|
|
|
97
|
-
Object.defineProperty(
|
|
95
|
+
Object.defineProperty(Definition.prototype, 'status', {
|
|
98
96
|
enumerable: true,
|
|
99
97
|
get() {
|
|
100
98
|
return this[kStatus];
|
|
101
99
|
},
|
|
102
100
|
});
|
|
103
101
|
|
|
104
|
-
Object.defineProperty(
|
|
102
|
+
Object.defineProperty(Definition.prototype, 'stopped', {
|
|
105
103
|
enumerable: true,
|
|
106
104
|
get() {
|
|
107
105
|
return this[kStopped];
|
|
108
106
|
},
|
|
109
107
|
});
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
Object.defineProperty(Definition.prototype, 'activityStatus', {
|
|
110
|
+
get() {
|
|
111
|
+
return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
Definition.prototype.run = function run(optionsOrCallback, optionalCallback) {
|
|
112
116
|
const [runOptions, callback] = getOptionsAndCallback(optionsOrCallback, optionalCallback);
|
|
113
117
|
if (this.isRunning) {
|
|
114
118
|
const err = new Error('definition is already running');
|
|
@@ -136,7 +140,7 @@ proto.run = function run(optionsOrCallback, optionalCallback) {
|
|
|
136
140
|
return this;
|
|
137
141
|
};
|
|
138
142
|
|
|
139
|
-
|
|
143
|
+
Definition.prototype.resume = function resume(callback) {
|
|
140
144
|
if (this.isRunning) {
|
|
141
145
|
const err = new Error('cannot resume running definition');
|
|
142
146
|
if (callback) return callback(err);
|
|
@@ -158,7 +162,7 @@ proto.resume = function resume(callback) {
|
|
|
158
162
|
return this;
|
|
159
163
|
};
|
|
160
164
|
|
|
161
|
-
|
|
165
|
+
Definition.prototype.recover = function recover(state) {
|
|
162
166
|
if (this.isRunning) throw new Error('cannot recover running definition');
|
|
163
167
|
if (!state) return this;
|
|
164
168
|
|
|
@@ -182,10 +186,8 @@ proto.recover = function recover(state) {
|
|
|
182
186
|
return this;
|
|
183
187
|
};
|
|
184
188
|
|
|
185
|
-
|
|
189
|
+
Definition.prototype.shake = function shake(startId) {
|
|
186
190
|
let result = {};
|
|
187
|
-
const broker = this.broker;
|
|
188
|
-
|
|
189
191
|
let bps;
|
|
190
192
|
if (startId) {
|
|
191
193
|
const startActivity = this.getActivityById(startId);
|
|
@@ -195,33 +197,32 @@ proto.shake = function shake(startId) {
|
|
|
195
197
|
bps = [bp];
|
|
196
198
|
} else bps = this.getProcesses();
|
|
197
199
|
|
|
198
|
-
bps.forEach(
|
|
200
|
+
bps.forEach((bp) => {
|
|
201
|
+
result = {...result, ...this._shakeProcess(bp, startId)};
|
|
202
|
+
});
|
|
199
203
|
|
|
200
204
|
return result;
|
|
205
|
+
};
|
|
201
206
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
Definition.prototype._shakeProcess = function shakeProcess(shakeBp, startId) {
|
|
208
|
+
let shovel;
|
|
209
|
+
if (!shakeBp.isRunning) {
|
|
210
|
+
shovel = shakeBp.broker.createShovel('shaker', {
|
|
211
|
+
exchange: 'event',
|
|
212
|
+
pattern: '*.shake#',
|
|
213
|
+
}, {
|
|
214
|
+
broker: this.broker,
|
|
215
|
+
exchange: 'event',
|
|
216
|
+
});
|
|
217
|
+
}
|
|
213
218
|
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
const shakeResult = shakeBp.shake(startId);
|
|
220
|
+
if (shovel) shakeBp.broker.closeShovel('shaker');
|
|
216
221
|
|
|
217
|
-
|
|
218
|
-
...result,
|
|
219
|
-
...shakeResult,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
+
return shakeResult;
|
|
222
223
|
};
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
Definition.prototype.getState = function getState() {
|
|
225
226
|
return this._createMessage({
|
|
226
227
|
status: this.status,
|
|
227
228
|
stopped: this.stopped,
|
|
@@ -232,29 +233,29 @@ proto.getState = function getState() {
|
|
|
232
233
|
});
|
|
233
234
|
};
|
|
234
235
|
|
|
235
|
-
|
|
236
|
+
Definition.prototype.getProcesses = function getProcesses() {
|
|
236
237
|
const execution = this.execution;
|
|
237
238
|
if (execution) return execution.getProcesses();
|
|
238
239
|
return this.context.getProcesses();
|
|
239
240
|
};
|
|
240
241
|
|
|
241
|
-
|
|
242
|
+
Definition.prototype.getExecutableProcesses = function getExecutableProcesses() {
|
|
242
243
|
const execution = this.execution;
|
|
243
244
|
if (execution) return execution.getExecutableProcesses();
|
|
244
245
|
return this.context.getExecutableProcesses();
|
|
245
246
|
};
|
|
246
247
|
|
|
247
|
-
|
|
248
|
+
Definition.prototype.getRunningProcesses = function getRunningProcesses() {
|
|
248
249
|
const execution = this.execution;
|
|
249
250
|
if (!execution) return [];
|
|
250
251
|
return execution.getRunningProcesses();
|
|
251
252
|
};
|
|
252
253
|
|
|
253
|
-
|
|
254
|
+
Definition.prototype.getProcessById = function getProcessById(processId) {
|
|
254
255
|
return this.getProcesses().find((p) => p.id === processId);
|
|
255
256
|
};
|
|
256
257
|
|
|
257
|
-
|
|
258
|
+
Definition.prototype.getActivityById = function getActivityById(childId) {
|
|
258
259
|
const bps = this.getProcesses();
|
|
259
260
|
for (const bp of bps) {
|
|
260
261
|
const child = bp.getActivityById(childId);
|
|
@@ -263,17 +264,17 @@ proto.getActivityById = function getActivityById(childId) {
|
|
|
263
264
|
return null;
|
|
264
265
|
};
|
|
265
266
|
|
|
266
|
-
|
|
267
|
+
Definition.prototype.getElementById = function getElementById(elementId) {
|
|
267
268
|
return this.context.getActivityById(elementId);
|
|
268
269
|
};
|
|
269
270
|
|
|
270
|
-
|
|
271
|
+
Definition.prototype.getPostponed = function getPostponed(...args) {
|
|
271
272
|
const execution = this.execution;
|
|
272
273
|
if (!execution) return [];
|
|
273
274
|
return execution.getPostponed(...args);
|
|
274
275
|
};
|
|
275
276
|
|
|
276
|
-
|
|
277
|
+
Definition.prototype.getApi = function getApi(message) {
|
|
277
278
|
const execution = this.execution;
|
|
278
279
|
if (execution) return execution.getApi(message);
|
|
279
280
|
message = message || this[kStateMessage];
|
|
@@ -281,15 +282,15 @@ proto.getApi = function getApi(message) {
|
|
|
281
282
|
return DefinitionApi(this.broker, message);
|
|
282
283
|
};
|
|
283
284
|
|
|
284
|
-
|
|
285
|
+
Definition.prototype.signal = function signal(message) {
|
|
285
286
|
return this.getApi().signal(message, {delegate: true});
|
|
286
287
|
};
|
|
287
288
|
|
|
288
|
-
|
|
289
|
+
Definition.prototype.cancelActivity = function cancelActivity(message) {
|
|
289
290
|
return this.getApi().cancel(message, {delegate: true});
|
|
290
291
|
};
|
|
291
292
|
|
|
292
|
-
|
|
293
|
+
Definition.prototype.sendMessage = function sendMessage(message) {
|
|
293
294
|
const messageContent = {message};
|
|
294
295
|
let messageType = 'message';
|
|
295
296
|
const reference = message && message.id && this.getElementById(message.id);
|
|
@@ -302,12 +303,12 @@ proto.sendMessage = function sendMessage(message) {
|
|
|
302
303
|
return this.getApi().sendApiMessage(messageType, messageContent, {delegate: true});
|
|
303
304
|
};
|
|
304
305
|
|
|
305
|
-
|
|
306
|
+
Definition.prototype.stop = function stop() {
|
|
306
307
|
if (!this.isRunning) return;
|
|
307
308
|
this.getApi().stop();
|
|
308
309
|
};
|
|
309
310
|
|
|
310
|
-
|
|
311
|
+
Definition.prototype._activateRunConsumers = function activateRunConsumers() {
|
|
311
312
|
this[kConsuming] = true;
|
|
312
313
|
const broker = this.broker;
|
|
313
314
|
const {onApiMessage, onRunMessage} = this[kMessageHandlers];
|
|
@@ -321,7 +322,7 @@ proto._activateRunConsumers = function activateRunConsumers() {
|
|
|
321
322
|
});
|
|
322
323
|
};
|
|
323
324
|
|
|
324
|
-
|
|
325
|
+
Definition.prototype._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
325
326
|
const broker = this.broker;
|
|
326
327
|
broker.cancel('_definition-api');
|
|
327
328
|
broker.cancel('_definition-run');
|
|
@@ -329,7 +330,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
|
329
330
|
this[kConsuming] = false;
|
|
330
331
|
};
|
|
331
332
|
|
|
332
|
-
|
|
333
|
+
Definition.prototype._createMessage = function createMessage(override) {
|
|
333
334
|
return {
|
|
334
335
|
id: this.id,
|
|
335
336
|
type: this.type,
|
|
@@ -339,7 +340,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
339
340
|
};
|
|
340
341
|
};
|
|
341
342
|
|
|
342
|
-
|
|
343
|
+
Definition.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
343
344
|
const {content, fields} = message;
|
|
344
345
|
if (routingKey === 'run.resume') {
|
|
345
346
|
return this._onResumeMessage(message);
|
|
@@ -425,7 +426,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
425
426
|
message.ack();
|
|
426
427
|
};
|
|
427
428
|
|
|
428
|
-
|
|
429
|
+
Definition.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
429
430
|
message.ack();
|
|
430
431
|
|
|
431
432
|
const stateMessage = this[kStateMessage];
|
|
@@ -446,7 +447,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
446
447
|
return this.broker.publish('run', stateMessage.fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
|
|
447
448
|
};
|
|
448
449
|
|
|
449
|
-
|
|
450
|
+
Definition.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
450
451
|
const {content, properties} = message;
|
|
451
452
|
const messageType = properties.type;
|
|
452
453
|
|
|
@@ -471,7 +472,7 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
471
472
|
executeMessage.ack();
|
|
472
473
|
};
|
|
473
474
|
|
|
474
|
-
|
|
475
|
+
Definition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
475
476
|
if (message.properties.type === 'stop') {
|
|
476
477
|
const execution = this.execution;
|
|
477
478
|
if (!execution || execution.completed) {
|
|
@@ -480,7 +481,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
480
481
|
}
|
|
481
482
|
};
|
|
482
483
|
|
|
483
|
-
|
|
484
|
+
Definition.prototype._publishEvent = function publishEvent(action, content, msgOpts) {
|
|
484
485
|
const execution = this.execution;
|
|
485
486
|
this.broker.publish('event', `definition.${action}`, execution ? execution._createMessage(content) : cloneContent(content), {
|
|
486
487
|
type: action,
|
|
@@ -488,13 +489,13 @@ proto._publishEvent = function publishEvent(action, content, msgOpts) {
|
|
|
488
489
|
});
|
|
489
490
|
};
|
|
490
491
|
|
|
491
|
-
|
|
492
|
+
Definition.prototype._onStop = function onStop() {
|
|
492
493
|
this[kStopped] = true;
|
|
493
494
|
this._deactivateRunConsumers();
|
|
494
495
|
return this._publishEvent('stop', this._createMessage());
|
|
495
496
|
};
|
|
496
497
|
|
|
497
|
-
|
|
498
|
+
Definition.prototype._onBrokerReturnFn = function onBrokerReturn(message) {
|
|
498
499
|
if (message.properties.type === 'error') {
|
|
499
500
|
this._deactivateRunConsumers();
|
|
500
501
|
const err = makeErrorFromMessage(message);
|
|
@@ -502,14 +503,14 @@ proto._onBrokerReturnFn = function onBrokerReturn(message) {
|
|
|
502
503
|
}
|
|
503
504
|
};
|
|
504
505
|
|
|
505
|
-
|
|
506
|
+
Definition.prototype._reset = function reset() {
|
|
506
507
|
this[kExec].executionId = undefined;
|
|
507
508
|
this._deactivateRunConsumers();
|
|
508
509
|
this.broker.purgeQueue('run-q');
|
|
509
510
|
this.broker.purgeQueue('execution-q');
|
|
510
511
|
};
|
|
511
512
|
|
|
512
|
-
|
|
513
|
+
Definition.prototype._debug = function debug(msg) {
|
|
513
514
|
this.logger.debug(`<${this.id}> ${msg}`);
|
|
514
515
|
};
|
|
515
516
|
|