bpmn-elements 7.0.0 → 8.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 +13 -0
- package/dist/src/Context.js +50 -40
- package/dist/src/Environment.js +39 -19
- package/dist/src/MessageFormatter.js +11 -11
- package/dist/src/activity/Activity.js +91 -91
- package/dist/src/activity/ActivityExecution.js +35 -35
- package/dist/src/definition/Definition.js +50 -50
- package/dist/src/definition/DefinitionExecution.js +114 -125
- package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
- package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
- package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
- package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
- package/dist/src/eventDefinitions/TimerEventDefinition.js +21 -21
- package/dist/src/events/BoundaryEvent.js +20 -20
- package/dist/src/events/EndEvent.js +3 -3
- package/dist/src/events/IntermediateCatchEvent.js +3 -3
- package/dist/src/events/IntermediateThrowEvent.js +3 -3
- package/dist/src/events/StartEvent.js +9 -9
- package/dist/src/flows/Association.js +7 -7
- package/dist/src/flows/MessageFlow.js +9 -9
- package/dist/src/flows/SequenceFlow.js +7 -7
- package/dist/src/gateways/EventBasedGateway.js +11 -11
- package/dist/src/io/InputOutputSpecification.js +4 -4
- package/dist/src/io/Properties.js +9 -9
- package/dist/src/process/Process.js +64 -61
- package/dist/src/process/ProcessExecution.js +93 -90
- package/dist/src/tasks/ReceiveTask.js +16 -16
- package/dist/src/tasks/SubProcess.js +16 -18
- package/package.json +9 -9
- package/src/Context.js +48 -40
- package/src/Environment.js +48 -20
- package/src/EventBroker.js +1 -1
- package/src/MessageFormatter.js +11 -11
- package/src/activity/Activity.js +91 -91
- package/src/activity/ActivityExecution.js +34 -34
- package/src/definition/Definition.js +51 -50
- package/src/definition/DefinitionExecution.js +111 -113
- package/src/eventDefinitions/CancelEventDefinition.js +16 -16
- package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
- package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
- package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
- package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
- package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
- package/src/eventDefinitions/LinkEventDefinition.js +15 -15
- package/src/eventDefinitions/MessageEventDefinition.js +23 -23
- package/src/eventDefinitions/SignalEventDefinition.js +24 -24
- package/src/eventDefinitions/TimerEventDefinition.js +21 -21
- package/src/events/BoundaryEvent.js +20 -20
- 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 +9 -9
- package/src/flows/Association.js +7 -7
- package/src/flows/MessageFlow.js +9 -9
- package/src/flows/SequenceFlow.js +7 -7
- package/src/gateways/EventBasedGateway.js +11 -11
- package/src/io/BpmnIO.js +5 -1
- package/src/io/InputOutputSpecification.js +4 -4
- package/src/io/Properties.js +9 -9
- package/src/process/Process.js +62 -58
- package/src/process/ProcessExecution.js +86 -88
- package/src/tasks/ReceiveTask.js +16 -16
- package/src/tasks/SubProcess.js +16 -16
|
@@ -20,15 +20,15 @@ var _Errors = require("../error/Errors");
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
23
|
+
const kConsuming = Symbol.for('consuming');
|
|
24
|
+
const kCounters = Symbol.for('counters');
|
|
25
|
+
const kExec = Symbol.for('execution');
|
|
26
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
27
|
+
const kExtensions = Symbol.for('extensions');
|
|
28
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
29
|
+
const kStateMessage = Symbol.for('stateMessage');
|
|
30
|
+
const kStatus = Symbol.for('status');
|
|
31
|
+
const kStopped = Symbol.for('stopped');
|
|
32
32
|
var _default = Process;
|
|
33
33
|
exports.default = _default;
|
|
34
34
|
|
|
@@ -51,12 +51,14 @@ function Process(processDef, context) {
|
|
|
51
51
|
this.isExecutable = isExecutable;
|
|
52
52
|
const environment = this.environment = context.environment;
|
|
53
53
|
this.context = context;
|
|
54
|
-
this[
|
|
54
|
+
this[kCounters] = {
|
|
55
55
|
completed: 0,
|
|
56
56
|
discarded: 0
|
|
57
57
|
};
|
|
58
|
-
this[
|
|
59
|
-
this[
|
|
58
|
+
this[kConsuming] = false;
|
|
59
|
+
this[kExec] = {};
|
|
60
|
+
this[kStatus] = undefined;
|
|
61
|
+
this[kStopped] = false;
|
|
60
62
|
const {
|
|
61
63
|
broker,
|
|
62
64
|
on,
|
|
@@ -67,13 +69,13 @@ function Process(processDef, context) {
|
|
|
67
69
|
this.on = on;
|
|
68
70
|
this.once = once;
|
|
69
71
|
this.waitFor = waitFor;
|
|
70
|
-
this[
|
|
72
|
+
this[kMessageHandlers] = {
|
|
71
73
|
onApiMessage: this._onApiMessage.bind(this),
|
|
72
74
|
onRunMessage: this._onRunMessage.bind(this),
|
|
73
75
|
onExecutionMessage: this._onExecutionMessage.bind(this)
|
|
74
76
|
};
|
|
75
77
|
this.logger = environment.Logger(type.toLowerCase());
|
|
76
|
-
this[
|
|
78
|
+
this[kExtensions] = context.loadExtensions(this);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
const proto = Process.prototype;
|
|
@@ -81,7 +83,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
81
83
|
enumerable: true,
|
|
82
84
|
|
|
83
85
|
get() {
|
|
84
|
-
return { ...this[
|
|
86
|
+
return { ...this[kCounters]
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -90,7 +92,7 @@ Object.defineProperty(proto, 'extensions', {
|
|
|
90
92
|
enumerable: true,
|
|
91
93
|
|
|
92
94
|
get() {
|
|
93
|
-
return this[
|
|
95
|
+
return this[kExtensions];
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
});
|
|
@@ -98,7 +100,7 @@ Object.defineProperty(proto, 'stopped', {
|
|
|
98
100
|
enumerable: true,
|
|
99
101
|
|
|
100
102
|
get() {
|
|
101
|
-
return this[
|
|
103
|
+
return this[kStopped];
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
});
|
|
@@ -106,7 +108,7 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
106
108
|
enumerable: true,
|
|
107
109
|
|
|
108
110
|
get() {
|
|
109
|
-
if (!this[
|
|
111
|
+
if (!this[kConsuming]) return false;
|
|
110
112
|
return !!this.status;
|
|
111
113
|
}
|
|
112
114
|
|
|
@@ -118,7 +120,7 @@ Object.defineProperty(proto, 'executionId', {
|
|
|
118
120
|
const {
|
|
119
121
|
executionId,
|
|
120
122
|
initExecutionId
|
|
121
|
-
} = this[
|
|
123
|
+
} = this[kExec];
|
|
122
124
|
return executionId || initExecutionId;
|
|
123
125
|
}
|
|
124
126
|
|
|
@@ -127,7 +129,7 @@ Object.defineProperty(proto, 'execution', {
|
|
|
127
129
|
enumerable: true,
|
|
128
130
|
|
|
129
131
|
get() {
|
|
130
|
-
return this[
|
|
132
|
+
return this[kExec].execution;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
});
|
|
@@ -135,13 +137,13 @@ Object.defineProperty(proto, 'status', {
|
|
|
135
137
|
enumerable: true,
|
|
136
138
|
|
|
137
139
|
get() {
|
|
138
|
-
return this[
|
|
140
|
+
return this[kStatus];
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
});
|
|
142
144
|
|
|
143
145
|
proto.init = function init(useAsExecutionId) {
|
|
144
|
-
const exec = this[
|
|
146
|
+
const exec = this[kExec];
|
|
145
147
|
const initExecutionId = exec.initExecutionId = useAsExecutionId || (0, _shared.getUniqueId)(this.id);
|
|
146
148
|
|
|
147
149
|
this._debug(`initialized with executionId <${initExecutionId}>`);
|
|
@@ -153,7 +155,7 @@ proto.init = function init(useAsExecutionId) {
|
|
|
153
155
|
|
|
154
156
|
proto.run = function run(runContent) {
|
|
155
157
|
if (this.isRunning) throw new Error(`process <${this.id}> is already running`);
|
|
156
|
-
const exec = this[
|
|
158
|
+
const exec = this[kExec];
|
|
157
159
|
const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(this.id);
|
|
158
160
|
exec.initExecutionId = undefined;
|
|
159
161
|
|
|
@@ -172,7 +174,7 @@ proto.run = function run(runContent) {
|
|
|
172
174
|
proto.resume = function resume() {
|
|
173
175
|
if (this.isRunning) throw new Error(`cannot resume running process <${this.id}>`);
|
|
174
176
|
if (!this.status) return this;
|
|
175
|
-
this[
|
|
177
|
+
this[kStopped] = false;
|
|
176
178
|
|
|
177
179
|
const content = this._createMessage();
|
|
178
180
|
|
|
@@ -188,11 +190,11 @@ proto.resume = function resume() {
|
|
|
188
190
|
proto.recover = function recover(state) {
|
|
189
191
|
if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
|
|
190
192
|
if (!state) return this;
|
|
191
|
-
this[
|
|
192
|
-
this[
|
|
193
|
-
const exec = this[
|
|
193
|
+
this[kStopped] = !!state.stopped;
|
|
194
|
+
this[kStatus] = state.status;
|
|
195
|
+
const exec = this[kExec];
|
|
194
196
|
exec.executionId = state.executionId;
|
|
195
|
-
this[
|
|
197
|
+
this[kCounters] = { ...this[kCounters],
|
|
196
198
|
...state.counters
|
|
197
199
|
};
|
|
198
200
|
this.environment.recover(state.environment);
|
|
@@ -218,7 +220,7 @@ proto.stop = function stop() {
|
|
|
218
220
|
proto.getApi = function getApi(message) {
|
|
219
221
|
const execution = this.execution;
|
|
220
222
|
if (execution) return execution.getApi(message);
|
|
221
|
-
return (0, _Api.ProcessApi)(this.broker, message || this[
|
|
223
|
+
return (0, _Api.ProcessApi)(this.broker, message || this[kStateMessage]);
|
|
222
224
|
};
|
|
223
225
|
|
|
224
226
|
proto.signal = function signal(message) {
|
|
@@ -234,9 +236,7 @@ proto.getState = function getState() {
|
|
|
234
236
|
stopped: this.stopped,
|
|
235
237
|
counters: this.counters,
|
|
236
238
|
broker: this.broker.getState(true),
|
|
237
|
-
execution: this.execution && this.execution.getState()
|
|
238
|
-
output: { ...this.environment.output
|
|
239
|
-
}
|
|
239
|
+
execution: this.execution && this.execution.getState()
|
|
240
240
|
});
|
|
241
241
|
};
|
|
242
242
|
|
|
@@ -247,12 +247,12 @@ proto.cancelActivity = function cancelActivity(message) {
|
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
proto._activateRunConsumers = function activateRunConsumers() {
|
|
250
|
-
this[
|
|
250
|
+
this[kConsuming] = true;
|
|
251
251
|
const broker = this.broker;
|
|
252
252
|
const {
|
|
253
253
|
onApiMessage,
|
|
254
254
|
onRunMessage
|
|
255
|
-
} = this[
|
|
255
|
+
} = this[kMessageHandlers];
|
|
256
256
|
broker.subscribeTmp('api', `process.*.${this.executionId}`, onApiMessage, {
|
|
257
257
|
noAck: true,
|
|
258
258
|
consumerTag: '_process-api',
|
|
@@ -269,7 +269,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
|
269
269
|
broker.cancel('_process-api');
|
|
270
270
|
broker.cancel('_process-run');
|
|
271
271
|
broker.cancel('_process-execution');
|
|
272
|
-
this[
|
|
272
|
+
this[kConsuming] = false;
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
@@ -282,15 +282,15 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
282
282
|
return this._onResumeMessage(message);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
const exec = this[
|
|
286
|
-
this[
|
|
285
|
+
const exec = this[kExec];
|
|
286
|
+
this[kStateMessage] = message;
|
|
287
287
|
|
|
288
288
|
switch (routingKey) {
|
|
289
289
|
case 'run.enter':
|
|
290
290
|
{
|
|
291
291
|
this._debug('enter');
|
|
292
292
|
|
|
293
|
-
this[
|
|
293
|
+
this[kStatus] = 'entered';
|
|
294
294
|
if (fields.redelivered) break;
|
|
295
295
|
exec.execution = undefined;
|
|
296
296
|
|
|
@@ -303,7 +303,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
303
303
|
{
|
|
304
304
|
this._debug('start');
|
|
305
305
|
|
|
306
|
-
this[
|
|
306
|
+
this[kStatus] = 'start';
|
|
307
307
|
|
|
308
308
|
this._publishEvent('start', content);
|
|
309
309
|
|
|
@@ -312,15 +312,15 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
312
312
|
|
|
313
313
|
case 'run.execute':
|
|
314
314
|
{
|
|
315
|
-
this[
|
|
315
|
+
this[kStatus] = 'executing';
|
|
316
316
|
const executeMessage = (0, _messageHelper.cloneMessage)(message);
|
|
317
317
|
|
|
318
318
|
if (fields.redelivered && !exec.execution) {
|
|
319
319
|
executeMessage.fields.redelivered = undefined;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
this[
|
|
323
|
-
this.broker.getQueue('execution-q').assertConsumer(this[
|
|
322
|
+
this[kExecuteMessage] = message;
|
|
323
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
|
|
324
324
|
exclusive: true,
|
|
325
325
|
consumerTag: '_process-execution'
|
|
326
326
|
});
|
|
@@ -330,6 +330,8 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
330
330
|
|
|
331
331
|
case 'run.error':
|
|
332
332
|
{
|
|
333
|
+
this[kStatus] = 'errored';
|
|
334
|
+
|
|
333
335
|
this._publishEvent('error', (0, _messageHelper.cloneContent)(content, {
|
|
334
336
|
error: fields.redelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
|
|
335
337
|
}));
|
|
@@ -339,12 +341,12 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
339
341
|
|
|
340
342
|
case 'run.end':
|
|
341
343
|
{
|
|
342
|
-
this[
|
|
344
|
+
this[kStatus] = 'end';
|
|
343
345
|
if (fields.redelivered) break;
|
|
344
346
|
|
|
345
347
|
this._debug('completed');
|
|
346
348
|
|
|
347
|
-
this[
|
|
349
|
+
this[kCounters].completed++;
|
|
348
350
|
this.broker.publish('run', 'run.leave', content);
|
|
349
351
|
|
|
350
352
|
this._publishEvent('end', content);
|
|
@@ -354,9 +356,9 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
354
356
|
|
|
355
357
|
case 'run.discarded':
|
|
356
358
|
{
|
|
357
|
-
this[
|
|
359
|
+
this[kStatus] = 'discarded';
|
|
358
360
|
if (fields.redelivered) break;
|
|
359
|
-
this[
|
|
361
|
+
this[kCounters].discarded++;
|
|
360
362
|
this.broker.publish('run', 'run.leave', content);
|
|
361
363
|
|
|
362
364
|
this._publishEvent('discarded', content);
|
|
@@ -366,7 +368,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
366
368
|
|
|
367
369
|
case 'run.leave':
|
|
368
370
|
{
|
|
369
|
-
this[
|
|
371
|
+
this[kStatus] = undefined;
|
|
370
372
|
this.broker.cancel('_process-api');
|
|
371
373
|
const {
|
|
372
374
|
output,
|
|
@@ -384,7 +386,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
384
386
|
|
|
385
387
|
proto._onResumeMessage = function onResumeMessage(message) {
|
|
386
388
|
message.ack();
|
|
387
|
-
const stateMessage = this[
|
|
389
|
+
const stateMessage = this[kStateMessage];
|
|
388
390
|
|
|
389
391
|
switch (stateMessage.fields.routingKey) {
|
|
390
392
|
case 'run.enter':
|
|
@@ -433,12 +435,9 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
437
|
|
|
436
|
-
const executeMessage = this[
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
this[executeMessageSymbol] = null;
|
|
440
|
-
executeMessage.ack();
|
|
441
|
-
}
|
|
438
|
+
const executeMessage = this[kExecuteMessage];
|
|
439
|
+
this[kExecuteMessage] = null;
|
|
440
|
+
executeMessage.ack();
|
|
442
441
|
};
|
|
443
442
|
|
|
444
443
|
proto._publishEvent = function publishEvent(state, content) {
|
|
@@ -453,7 +452,7 @@ proto._publishEvent = function publishEvent(state, content) {
|
|
|
453
452
|
};
|
|
454
453
|
|
|
455
454
|
proto.sendMessage = function sendMessage(message) {
|
|
456
|
-
const messageContent = message.content;
|
|
455
|
+
const messageContent = message && message.content;
|
|
457
456
|
if (!messageContent) return;
|
|
458
457
|
let targetsFound = false;
|
|
459
458
|
|
|
@@ -474,12 +473,14 @@ proto.sendMessage = function sendMessage(message) {
|
|
|
474
473
|
};
|
|
475
474
|
|
|
476
475
|
proto.getActivityById = function getActivityById(childId) {
|
|
477
|
-
|
|
476
|
+
const execution = this.execution;
|
|
477
|
+
if (execution) return execution.getActivityById(childId);
|
|
478
478
|
return this.context.getActivityById(childId);
|
|
479
479
|
};
|
|
480
480
|
|
|
481
481
|
proto.getActivities = function getActivities() {
|
|
482
|
-
|
|
482
|
+
const execution = this.execution;
|
|
483
|
+
if (execution) return execution.getActivities();
|
|
483
484
|
return this.context.getActivities(this.id);
|
|
484
485
|
};
|
|
485
486
|
|
|
@@ -488,13 +489,15 @@ proto.getStartActivities = function getStartActivities(filterOptions) {
|
|
|
488
489
|
};
|
|
489
490
|
|
|
490
491
|
proto.getSequenceFlows = function getSequenceFlows() {
|
|
491
|
-
|
|
492
|
+
const execution = this.execution;
|
|
493
|
+
if (execution) return execution.getSequenceFlows();
|
|
492
494
|
return this.context.getSequenceFlows();
|
|
493
495
|
};
|
|
494
496
|
|
|
495
497
|
proto.getPostponed = function getPostponed(...args) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
+
const execution = this.execution;
|
|
499
|
+
if (!execution) return [];
|
|
500
|
+
return execution.getPostponed(...args);
|
|
498
501
|
};
|
|
499
502
|
|
|
500
503
|
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
@@ -513,7 +516,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
513
516
|
};
|
|
514
517
|
|
|
515
518
|
proto._onStop = function onStop() {
|
|
516
|
-
this[
|
|
519
|
+
this[kStopped] = true;
|
|
517
520
|
|
|
518
521
|
this._deactivateRunConsumers();
|
|
519
522
|
|