bpmn-elements 8.1.0 → 8.2.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/index.js +0 -49
  3. package/dist/src/Api.js +4 -19
  4. package/dist/src/Context.js +7 -36
  5. package/dist/src/Environment.js +18 -44
  6. package/dist/src/EventBroker.js +8 -27
  7. package/dist/src/Expressions.js +0 -13
  8. package/dist/src/ExtensionsMapper.js +32 -44
  9. package/dist/src/MessageFormatter.js +0 -33
  10. package/dist/src/Scripts.js +2 -9
  11. package/dist/src/Timers.js +0 -9
  12. package/dist/src/activity/Activity.js +62 -294
  13. package/dist/src/activity/ActivityExecution.js +8 -76
  14. package/dist/src/activity/Dummy.js +2 -3
  15. package/dist/src/activity/Escalation.js +4 -4
  16. package/dist/src/activity/ExecutionScope.js +0 -4
  17. package/dist/src/activity/Message.js +4 -4
  18. package/dist/src/activity/Signal.js +4 -4
  19. package/dist/src/definition/Definition.js +12 -133
  20. package/dist/src/definition/DefinitionExecution.js +10 -160
  21. package/dist/src/error/BpmnError.js +2 -3
  22. package/dist/src/error/Errors.js +0 -16
  23. package/dist/src/eventDefinitions/CancelEventDefinition.js +2 -35
  24. package/dist/src/eventDefinitions/CompensateEventDefinition.js +3 -34
  25. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +3 -42
  26. package/dist/src/eventDefinitions/ErrorEventDefinition.js +11 -41
  27. package/dist/src/eventDefinitions/EscalationEventDefinition.js +7 -37
  28. package/dist/src/eventDefinitions/EventDefinitionExecution.js +0 -30
  29. package/dist/src/eventDefinitions/LinkEventDefinition.js +11 -37
  30. package/dist/src/eventDefinitions/MessageEventDefinition.js +11 -44
  31. package/dist/src/eventDefinitions/SignalEventDefinition.js +9 -46
  32. package/dist/src/eventDefinitions/TerminateEventDefinition.js +0 -3
  33. package/dist/src/eventDefinitions/TimerEventDefinition.js +8 -52
  34. package/dist/src/events/BoundaryEvent.js +4 -44
  35. package/dist/src/events/EndEvent.js +2 -11
  36. package/dist/src/events/IntermediateCatchEvent.js +0 -13
  37. package/dist/src/events/IntermediateThrowEvent.js +2 -11
  38. package/dist/src/events/StartEvent.js +5 -25
  39. package/dist/src/flows/Association.js +4 -27
  40. package/dist/src/flows/MessageFlow.js +6 -18
  41. package/dist/src/flows/SequenceFlow.js +4 -39
  42. package/dist/src/gateways/EventBasedGateway.js +0 -21
  43. package/dist/src/gateways/ExclusiveGateway.js +0 -6
  44. package/dist/src/gateways/InclusiveGateway.js +0 -6
  45. package/dist/src/gateways/ParallelGateway.js +2 -7
  46. package/dist/src/getPropertyValue.js +0 -30
  47. package/dist/src/io/BpmnIO.js +8 -5
  48. package/dist/src/io/EnvironmentDataObject.js +0 -8
  49. package/dist/src/io/EnvironmentDataStore.js +0 -8
  50. package/dist/src/io/EnvironmentDataStoreReference.js +0 -8
  51. package/dist/src/io/InputOutputSpecification.js +25 -36
  52. package/dist/src/io/Properties.js +15 -47
  53. package/dist/src/messageHelper.js +10 -23
  54. package/dist/src/process/Process.js +10 -112
  55. package/dist/src/process/ProcessExecution.js +14 -170
  56. package/dist/src/shared.js +0 -7
  57. package/dist/src/tasks/CallActivity.js +2 -23
  58. package/dist/src/tasks/LoopCharacteristics.js +16 -67
  59. package/dist/src/tasks/ReceiveTask.js +8 -48
  60. package/dist/src/tasks/ScriptTask.js +1 -15
  61. package/dist/src/tasks/ServiceImplementation.js +0 -4
  62. package/dist/src/tasks/ServiceTask.js +1 -25
  63. package/dist/src/tasks/SignalTask.js +2 -21
  64. package/dist/src/tasks/StandardLoopCharacteristics.js +4 -5
  65. package/dist/src/tasks/SubProcess.js +4 -52
  66. package/dist/src/tasks/Task.js +0 -8
  67. package/dist/src/tasks/Transaction.js +0 -3
  68. package/package.json +8 -8
  69. package/src/Context.js +7 -3
  70. package/src/ExtensionsMapper.js +35 -35
  71. package/src/activity/Activity.js +22 -51
  72. package/src/gateways/EventBasedGateway.js +0 -1
  73. package/src/io/BpmnIO.js +7 -0
  74. package/src/io/EnvironmentDataObject.js +1 -0
  75. package/src/io/InputOutputSpecification.js +17 -6
  76. package/src/io/Properties.js +9 -11
  77. package/src/process/ProcessExecution.js +2 -1
  78. package/src/tasks/ServiceTask.js +1 -3
  79. package/src/tasks/StandardLoopCharacteristics.js +0 -1
@@ -4,27 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _ActivityExecution = _interopRequireDefault(require("./ActivityExecution"));
9
-
10
- var _BpmnIO = _interopRequireDefault(require("../io/BpmnIO"));
11
-
12
8
  var _shared = require("../shared");
13
-
14
9
  var _Api = require("../Api");
15
-
16
10
  var _EventBroker = require("../EventBroker");
17
-
18
11
  var _MessageFormatter = require("../MessageFormatter");
19
-
20
12
  var _messageHelper = require("../messageHelper");
21
-
22
13
  var _Errors = require("../error/Errors");
23
-
24
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
15
  const kActivityDef = Symbol.for('activityDefinition');
27
- const kBpmnIo = Symbol.for('bpmnIo');
28
16
  const kConsuming = Symbol.for('consuming');
29
17
  const kCounters = Symbol.for('counters');
30
18
  const kEventDefinitions = Symbol.for('eventDefinitions');
@@ -38,7 +26,6 @@ const kMessageHandlers = Symbol.for('messageHandlers');
38
26
  const kStateMessage = Symbol.for('stateMessage');
39
27
  var _default = Activity;
40
28
  exports.default = _default;
41
-
42
29
  function Activity(Behaviour, activityDef, context) {
43
30
  const {
44
31
  id,
@@ -54,7 +41,8 @@ function Activity(Behaviour, activityDef, context) {
54
41
  this.id = id;
55
42
  this.type = type;
56
43
  this.name = name;
57
- this.behaviour = { ...behaviour,
44
+ this.behaviour = {
45
+ ...behaviour,
58
46
  eventDefinitions
59
47
  };
60
48
  this.Behaviour = Behaviour;
@@ -67,12 +55,10 @@ function Activity(Behaviour, activityDef, context) {
67
55
  discarded: 0
68
56
  };
69
57
  let attachedToActivity, attachedTo;
70
-
71
58
  if (attachedToRef) {
72
59
  attachedTo = attachedToRef.id;
73
60
  attachedToActivity = context.getActivityById(attachedToRef.id);
74
61
  }
75
-
76
62
  const {
77
63
  broker,
78
64
  on,
@@ -117,14 +103,11 @@ function Activity(Behaviour, activityDef, context) {
117
103
  onApiMessage: this._onApiMessage.bind(this),
118
104
  onExecutionMessage: this._onExecutionMessage.bind(this)
119
105
  };
120
-
121
106
  const onInboundEvent = this._onInboundEvent.bind(this);
122
-
123
107
  broker.assertQueue('inbound-q', {
124
108
  durable: true,
125
109
  autoDelete: false
126
110
  });
127
-
128
111
  if (isForCompensation) {
129
112
  for (const trigger of inboundAssociations) {
130
113
  trigger.broker.subscribeTmp('event', '#', onInboundEvent, {
@@ -143,59 +126,45 @@ function Activity(Behaviour, activityDef, context) {
143
126
  });
144
127
  }
145
128
  }
146
-
147
129
  this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
130
+ this[kExtensions] = context.loadExtensions(this);
148
131
  }
149
-
150
132
  const proto = Activity.prototype;
151
133
  Object.defineProperty(proto, 'counters', {
152
134
  enumerable: true,
153
-
154
135
  get() {
155
- return { ...this[kCounters]
136
+ return {
137
+ ...this[kCounters]
156
138
  };
157
139
  }
158
-
159
140
  });
160
141
  Object.defineProperty(proto, 'execution', {
161
142
  enumerable: true,
162
-
163
143
  get() {
164
144
  return this[kExec].execution;
165
145
  }
166
-
167
146
  });
168
147
  Object.defineProperty(proto, 'executionId', {
169
148
  enumerable: true,
170
-
171
149
  get() {
172
150
  return this[kExec].executionId;
173
151
  }
174
-
175
152
  });
176
- Object.defineProperty(proto, 'bpmnIo', {
153
+ Object.defineProperty(proto, 'extensions', {
177
154
  enumerable: true,
178
-
179
155
  get() {
180
- if (kBpmnIo in this) return this[kBpmnIo];
181
- const bpmnIo = this[kBpmnIo] = new _BpmnIO.default(this, this.context);
182
- return bpmnIo;
156
+ return this[kExtensions];
183
157
  }
184
-
185
158
  });
186
- Object.defineProperty(proto, 'extensions', {
159
+ Object.defineProperty(proto, 'bpmnIo', {
187
160
  enumerable: true,
188
-
189
161
  get() {
190
- if (kExtensions in this) return this[kExtensions];
191
- const extensions = this[kExtensions] = this.context.loadExtensions(this);
192
- return extensions;
162
+ const extensions = this[kExtensions];
163
+ return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
193
164
  }
194
-
195
165
  });
196
166
  Object.defineProperty(proto, 'formatter', {
197
167
  enumerable: true,
198
-
199
168
  get() {
200
169
  let formatter = this[kFormatter];
201
170
  if (formatter) return formatter;
@@ -207,150 +176,117 @@ Object.defineProperty(proto, 'formatter', {
207
176
  }, broker.getQueue('format-run-q'));
208
177
  return formatter;
209
178
  }
210
-
211
179
  });
212
180
  Object.defineProperty(proto, 'isRunning', {
213
181
  enumerable: true,
214
-
215
182
  get() {
216
183
  if (!this[kConsuming]) return false;
217
184
  return !!this.status;
218
185
  }
219
-
220
186
  });
221
187
  Object.defineProperty(proto, 'outbound', {
222
188
  enumerable: true,
223
-
224
189
  get() {
225
190
  return this[kFlows].outboundSequenceFlows;
226
191
  }
227
-
228
192
  });
229
193
  Object.defineProperty(proto, 'inbound', {
230
194
  enumerable: true,
231
-
232
195
  get() {
233
196
  return this[kFlows].inboundSequenceFlows;
234
197
  }
235
-
236
198
  });
237
199
  Object.defineProperty(proto, 'isEnd', {
238
200
  enumerable: true,
239
-
240
201
  get() {
241
202
  return this[kFlags].isEnd;
242
203
  }
243
-
244
204
  });
245
205
  Object.defineProperty(proto, 'isStart', {
246
206
  enumerable: true,
247
-
248
207
  get() {
249
208
  return this[kFlags].isStart;
250
209
  }
251
-
252
210
  });
253
211
  Object.defineProperty(proto, 'isSubProcess', {
254
212
  enumerable: true,
255
-
256
213
  get() {
257
214
  return this[kFlags].isSubProcess;
258
215
  }
259
-
260
216
  });
261
217
  Object.defineProperty(proto, 'isMultiInstance', {
262
218
  enumerable: true,
263
-
264
219
  get() {
265
220
  return this[kFlags].isMultiInstance;
266
221
  }
267
-
268
222
  });
269
223
  Object.defineProperty(proto, 'isThrowing', {
270
224
  enumerable: true,
271
-
272
225
  get() {
273
226
  return this[kFlags].isThrowing;
274
227
  }
275
-
276
228
  });
277
229
  Object.defineProperty(proto, 'isForCompensation', {
278
230
  enumerable: true,
279
-
280
231
  get() {
281
232
  return this[kFlags].isForCompensation;
282
233
  }
283
-
284
234
  });
285
235
  Object.defineProperty(proto, 'triggeredByEvent', {
286
236
  enumerable: true,
287
-
288
237
  get() {
289
238
  return this[kActivityDef].triggeredByEvent;
290
239
  }
291
-
292
240
  });
293
241
  Object.defineProperty(proto, 'attachedTo', {
294
242
  enumerable: true,
295
-
296
243
  get() {
297
244
  const attachedToId = this[kFlags].attachedTo;
298
245
  if (!attachedToId) return null;
299
246
  return this.getActivityById(attachedToId);
300
247
  }
301
-
302
248
  });
303
249
  Object.defineProperty(proto, 'eventDefinitions', {
304
250
  enumerable: true,
305
-
306
251
  get() {
307
252
  return this[kEventDefinitions];
308
253
  }
309
-
310
254
  });
311
-
312
255
  proto.activate = function activate() {
313
256
  if (this[kFlags].isForCompensation) return;
314
257
  return this._consumeInbound();
315
258
  };
316
-
317
259
  proto.deactivate = function deactivate() {
318
260
  const broker = this.broker;
319
261
  broker.cancel('_run-on-inbound');
320
262
  broker.cancel('_format-consumer');
321
263
  };
322
-
323
264
  proto.init = function init(initContent) {
324
265
  const id = this.id;
325
266
  const exec = this[kExec];
326
267
  const executionId = exec.initExecutionId = exec.initExecutionId || (0, _shared.getUniqueId)(id);
327
268
  this.logger.debug(`<${id}> initialized with executionId <${executionId}>`);
328
-
329
- this._publishEvent('init', this._createMessage({ ...initContent,
269
+ this._publishEvent('init', this._createMessage({
270
+ ...initContent,
330
271
  executionId
331
272
  }));
332
273
  };
333
-
334
274
  proto.run = function run(runContent) {
335
275
  const id = this.id;
336
276
  if (this.isRunning) throw new Error(`activity <${id}> is already running`);
337
277
  const exec = this[kExec];
338
278
  const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(id);
339
279
  exec.initExecutionId = null;
340
-
341
280
  this._consumeApi();
342
-
343
- const content = this._createMessage({ ...runContent,
281
+ const content = this._createMessage({
282
+ ...runContent,
344
283
  executionId
345
284
  });
346
-
347
285
  const broker = this.broker;
348
286
  broker.publish('run', 'run.enter', content);
349
287
  broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
350
-
351
288
  this._consumeRunQ();
352
289
  };
353
-
354
290
  proto.recover = function recover(state) {
355
291
  if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
356
292
  if (!state) return;
@@ -358,56 +294,43 @@ proto.recover = function recover(state) {
358
294
  this.status = state.status;
359
295
  const exec = this[kExec];
360
296
  exec.executionId = state.executionId;
361
- this[kCounters] = { ...this[kCounters],
297
+ this[kCounters] = {
298
+ ...this[kCounters],
362
299
  ...state.counters
363
300
  };
364
-
365
301
  if (state.execution) {
366
302
  exec.execution = new _ActivityExecution.default(this, this.context).recover(state.execution);
367
303
  }
368
-
369
304
  this.broker.recover(state.broker);
370
305
  return this;
371
306
  };
372
-
373
307
  proto.resume = function resume() {
374
308
  if (this[kConsuming]) {
375
309
  throw new Error(`cannot resume running activity <${this.id}>`);
376
310
  }
377
-
378
311
  if (!this.status) return this.activate();
379
312
  this.stopped = false;
380
-
381
313
  this._consumeApi();
382
-
383
314
  const content = this._createMessage();
384
-
385
315
  this.broker.publish('run', 'run.resume', content, {
386
316
  persistent: false
387
317
  });
388
-
389
318
  this._consumeRunQ();
390
319
  };
391
-
392
320
  proto.discard = function discard(discardContent) {
393
321
  if (!this.status) return this._runDiscard(discardContent);
394
322
  const execution = this[kExec].execution;
395
323
  if (execution && !execution.completed) return execution.discard();
396
-
397
324
  this._deactivateRunConsumers();
398
-
399
325
  const broker = this.broker;
400
326
  broker.getQueue('run-q').purge();
401
327
  broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[kStateMessage].content));
402
-
403
328
  this._consumeRunQ();
404
329
  };
405
-
406
330
  proto.stop = function stop() {
407
331
  if (!this[kConsuming]) return;
408
332
  return this.getApi().stop();
409
333
  };
410
-
411
334
  proto.next = function next() {
412
335
  if (!this.environment.settings.step) return;
413
336
  const stateMessage = this[kStateMessage];
@@ -418,81 +341,68 @@ proto.next = function next() {
418
341
  stateMessage.ack();
419
342
  return current;
420
343
  };
421
-
422
344
  proto.shake = function shake() {
423
345
  this._shakeOutbound({
424
346
  content: this._createMessage()
425
347
  });
426
348
  };
427
-
428
349
  proto.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
429
350
  return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
430
351
  };
431
-
432
352
  proto.getState = function getState() {
433
353
  const msg = this._createMessage();
434
-
435
354
  const exec = this[kExec];
436
- return { ...msg,
355
+ return {
356
+ ...msg,
437
357
  executionId: exec.executionId,
438
358
  stopped: this.stopped,
439
- behaviour: { ...this.behaviour
359
+ behaviour: {
360
+ ...this.behaviour
440
361
  },
441
362
  counters: this.counters,
442
363
  broker: this.broker.getState(true),
443
364
  execution: exec.execution && exec.execution.getState()
444
365
  };
445
366
  };
446
-
447
367
  proto.getApi = function getApi(message) {
448
368
  const execution = this[kExec].execution;
449
369
  if (execution && !execution.completed) return execution.getApi(message);
450
370
  return (0, _Api.ActivityApi)(this.broker, message || this[kStateMessage]);
451
371
  };
452
-
453
372
  proto.getActivityById = function getActivityById(elementId) {
454
373
  return this.context.getActivityById(elementId);
455
374
  };
456
-
457
375
  proto._runDiscard = function runDiscard(discardContent) {
458
376
  const exec = this[kExec];
459
377
  const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(this.id);
460
378
  exec.initExecutionId = null;
461
-
462
379
  this._consumeApi();
463
-
464
- const content = this._createMessage({ ...discardContent,
380
+ const content = this._createMessage({
381
+ ...discardContent,
465
382
  executionId
466
383
  });
467
-
468
384
  this.broker.publish('run', 'run.discard', content);
469
-
470
385
  this._consumeRunQ();
471
386
  };
472
-
473
387
  proto._discardRun = function discardRun() {
474
388
  const status = this.status;
475
389
  if (!status) return;
476
390
  const execution = this[kExec].execution;
477
391
  if (execution && !execution.completed) return;
478
-
479
392
  switch (status) {
480
393
  case 'executing':
481
394
  case 'error':
482
395
  case 'discarded':
483
396
  return;
484
397
  }
485
-
486
398
  this._deactivateRunConsumers();
487
-
488
- if (this.extensions) this.extensions.deactivate();
399
+ const message = this[kStateMessage];
400
+ if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(message));
489
401
  const broker = this.broker;
490
402
  broker.getQueue('run-q').purge();
491
- broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[kStateMessage].content));
492
-
403
+ broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(message.content));
493
404
  this._consumeRunQ();
494
405
  };
495
-
496
406
  proto._shakeOutbound = function shakeOutbound(sourceMessage) {
497
407
  const message = (0, _messageHelper.cloneMessage)(sourceMessage);
498
408
  message.content.sequence = message.content.sequence || [];
@@ -505,33 +415,27 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
505
415
  persistent: false,
506
416
  type: 'shake'
507
417
  });
508
-
509
418
  if (this[kFlags].isEnd) {
510
419
  return broker.publish('event', 'activity.shake.end', message.content, {
511
420
  persistent: false,
512
421
  type: 'shake'
513
422
  });
514
423
  }
515
-
516
424
  for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
517
425
  };
518
-
519
426
  proto._consumeInbound = function consumeInbound() {
520
427
  if (this.status) return;
521
428
  const inboundQ = this.broker.getQueue('inbound-q');
522
-
523
429
  if (this[kFlags].isParallelJoin) {
524
430
  return inboundQ.consume(this[kMessageHandlers].onInbound, {
525
431
  consumerTag: '_run-on-inbound',
526
432
  prefetch: 1000
527
433
  });
528
434
  }
529
-
530
435
  return inboundQ.consume(this[kMessageHandlers].onInbound, {
531
436
  consumerTag: '_run-on-inbound'
532
437
  });
533
438
  };
534
-
535
439
  proto._onInbound = function onInbound(routingKey, message) {
536
440
  message.ack();
537
441
  const id = this.id;
@@ -539,7 +443,6 @@ proto._onInbound = function onInbound(routingKey, message) {
539
443
  broker.cancel('_run-on-inbound');
540
444
  const content = message.content;
541
445
  const inbound = [(0, _messageHelper.cloneContent)(content)];
542
-
543
446
  switch (routingKey) {
544
447
  case 'association.take':
545
448
  case 'flow.take':
@@ -549,7 +452,6 @@ proto._onInbound = function onInbound(routingKey, message) {
549
452
  message: content.message,
550
453
  inbound
551
454
  });
552
-
553
455
  case 'flow.discard':
554
456
  case 'activity.discard':
555
457
  {
@@ -560,7 +462,6 @@ proto._onInbound = function onInbound(routingKey, message) {
560
462
  discardSequence
561
463
  });
562
464
  }
563
-
564
465
  case 'association.complete':
565
466
  {
566
467
  broker.cancel('_run-on-inbound');
@@ -572,7 +473,6 @@ proto._onInbound = function onInbound(routingKey, message) {
572
473
  }
573
474
  }
574
475
  };
575
-
576
476
  proto._onJoinInbound = function onJoinInbound(routingKey, message) {
577
477
  const {
578
478
  content
@@ -586,12 +486,10 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
586
486
  inboundJoinFlows.push(message);
587
487
  if (idx > -1) return;
588
488
  const allTouched = inboundJoinFlows.length >= inboundTriggers.length;
589
-
590
489
  if (!allTouched) {
591
490
  const remaining = inboundSequenceFlows.filter((inb, i, list) => list.indexOf(inb) === i).length - inboundJoinFlows.length;
592
491
  return this.logger.debug(`<${this.id}> inbound ${message.content.action} from <${message.content.id}>, ${remaining} remaining`);
593
492
  }
594
-
595
493
  const evaluatedInbound = inboundJoinFlows.splice(0);
596
494
  let taken;
597
495
  const inbound = evaluatedInbound.map(im => {
@@ -601,11 +499,9 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
601
499
  });
602
500
  const discardSequence = !taken && evaluatedInbound.reduce((result, im) => {
603
501
  if (!im.content.discardSequence) return result;
604
-
605
502
  for (const sourceId of im.content.discardSequence) {
606
503
  if (result.indexOf(sourceId) === -1) result.push(sourceId);
607
504
  }
608
-
609
505
  return result;
610
506
  }, []);
611
507
  this.broker.cancel('_run-on-inbound');
@@ -617,7 +513,6 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
617
513
  inbound
618
514
  });
619
515
  };
620
-
621
516
  proto._onInboundEvent = function onInboundEvent(routingKey, message) {
622
517
  const {
623
518
  fields,
@@ -626,7 +521,6 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
626
521
  } = message;
627
522
  const id = this.id;
628
523
  const inboundQ = this.broker.getQueue('inbound-q');
629
-
630
524
  switch (routingKey) {
631
525
  case 'activity.enter':
632
526
  case 'activity.discard':
@@ -634,43 +528,35 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
634
528
  if (content.id === this[kFlags].attachedTo) {
635
529
  inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
636
530
  }
637
-
638
531
  break;
639
532
  }
640
-
641
533
  case 'flow.shake':
642
534
  {
643
535
  return this._shakeOutbound(message);
644
536
  }
645
-
646
537
  case 'association.take':
647
538
  case 'flow.take':
648
539
  case 'flow.discard':
649
540
  return inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
650
-
651
541
  case 'association.discard':
652
542
  {
653
543
  this.logger.debug(`<${id}> compensation discarded`);
654
544
  return inboundQ.purge();
655
545
  }
656
-
657
546
  case 'association.complete':
658
547
  {
659
548
  if (!this[kFlags].isForCompensation) break;
660
549
  inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
661
550
  const compensationId = `${(0, _shared.brokerSafeId)(id)}_${(0, _shared.brokerSafeId)(content.sequenceId)}`;
662
-
663
551
  this._publishEvent('compensation.start', this._createMessage({
664
552
  executionId: compensationId,
665
553
  placeholder: true
666
554
  }));
667
-
668
555
  this.logger.debug(`<${id}> start compensation with id <${compensationId}>`);
669
556
  return this._consumeInbound();
670
557
  }
671
558
  }
672
559
  };
673
-
674
560
  proto._consumeRunQ = function consumeRunQ() {
675
561
  if (this[kConsuming]) return;
676
562
  this[kConsuming] = true;
@@ -679,31 +565,26 @@ proto._consumeRunQ = function consumeRunQ() {
679
565
  consumerTag: '_activity-run'
680
566
  });
681
567
  };
682
-
683
568
  proto._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
684
569
  switch (routingKey) {
685
570
  case 'run.outbound.discard':
686
571
  case 'run.outbound.take':
687
572
  case 'run.next':
688
573
  return this._continueRunMessage(routingKey, message, messageProperties);
689
-
690
574
  case 'run.resume':
691
575
  {
692
576
  return this._onResumeMessage(message);
693
577
  }
694
578
  }
695
-
696
579
  const preStatus = this.status;
697
580
  this.status = 'formatting';
698
581
  return this.formatter.format(message, (err, formattedContent, formatted) => {
699
582
  if (err) return this.emitFatal(err, message.content);
700
583
  if (formatted) message.content = formattedContent;
701
584
  this.status = preStatus;
702
-
703
585
  this._continueRunMessage(routingKey, message, messageProperties);
704
586
  });
705
587
  };
706
-
707
588
  proto._continueRunMessage = function continueRunMessage(routingKey, message) {
708
589
  const isRedelivered = message.fields.redelivered;
709
590
  const content = (0, _messageHelper.cloneContent)(message.content);
@@ -711,196 +592,152 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
711
592
  const id = this.id;
712
593
  const step = this.environment.settings.step;
713
594
  this[kStateMessage] = message;
714
-
715
595
  switch (routingKey) {
716
596
  case 'run.enter':
717
597
  {
718
598
  this.logger.debug(`<${id}> enter`, isRedelivered ? 'redelivered' : '');
719
599
  this.status = 'entered';
720
-
721
600
  if (!isRedelivered) {
722
601
  this[kExec].execution = null;
602
+ if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message));
603
+ this._publishEvent('enter', content, {
604
+ correlationId
605
+ });
723
606
  }
724
-
725
- if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message), this);
726
- if (this.bpmnIo) this.bpmnIo.activate(message);
727
- if (!isRedelivered) this._publishEvent('enter', content, {
728
- correlationId
729
- });
730
607
  break;
731
608
  }
732
-
733
609
  case 'run.discard':
734
610
  {
735
611
  this.logger.debug(`<${id}> discard`, isRedelivered ? 'redelivered' : '');
736
612
  this.status = 'discard';
737
613
  this[kExec].execution = null;
738
- if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message), this);
739
- if (this.bpmnIo) this.bpmnIo.activate(message);
740
-
614
+ if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message));
741
615
  if (!isRedelivered) {
742
616
  this.broker.publish('run', 'run.discarded', content, {
743
617
  correlationId
744
618
  });
745
-
746
619
  this._publishEvent('discard', content);
747
620
  }
748
-
749
621
  break;
750
622
  }
751
-
752
623
  case 'run.start':
753
624
  {
754
625
  this.logger.debug(`<${id}> start`, isRedelivered ? 'redelivered' : '');
755
626
  this.status = 'started';
756
-
757
627
  if (!isRedelivered) {
758
628
  this.broker.publish('run', 'run.execute', content, {
759
629
  correlationId
760
630
  });
761
-
762
631
  this._publishEvent('start', content, {
763
632
  correlationId
764
633
  });
765
634
  }
766
-
767
635
  break;
768
636
  }
769
-
770
637
  case 'run.execute.passthrough':
771
638
  {
772
639
  const execution = this.execution;
773
-
774
640
  if (!isRedelivered && execution) {
775
641
  this[kExecuteMessage] = message;
776
642
  return execution.passthrough(message);
777
643
  }
778
644
  }
779
-
780
645
  case 'run.execute':
781
646
  {
782
647
  this.status = 'executing';
783
648
  this[kExecuteMessage] = message;
649
+ const exec = this[kExec];
650
+ if (isRedelivered && this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message));
651
+ if (!exec.execution) exec.execution = new _ActivityExecution.default(this, this.context);
784
652
  this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
785
653
  exclusive: true,
786
654
  consumerTag: '_activity-execution'
787
655
  });
788
- const exec = this[kExec];
789
- if (!exec.execution) exec.execution = new _ActivityExecution.default(this, this.context);
790
-
791
- if (isRedelivered) {
792
- return this._resumeExtensions(message, (err, formattedContent) => {
793
- if (err) return this.emitFatal(err, message.content);
794
- if (formattedContent) message.content = formattedContent;
795
- this.status = 'executing';
796
- return exec.execution.execute(message);
797
- });
798
- }
799
-
800
656
  return exec.execution.execute(message);
801
657
  }
802
-
803
658
  case 'run.end':
804
659
  {
805
- if (this.status === 'end') break;
660
+ this.logger.debug(`<${id}> end`, isRedelivered ? 'redelivered' : '');
661
+ if (isRedelivered) break;
806
662
  this[kCounters].taken++;
807
663
  this.status = 'end';
808
664
  return this._doRunLeave(message, false, () => {
809
665
  this._publishEvent('end', content, {
810
666
  correlationId
811
667
  });
812
-
813
668
  if (!step) message.ack();
814
669
  });
815
670
  }
816
-
817
671
  case 'run.error':
818
672
  {
819
- this._publishEvent('error', { ...content,
673
+ this._publishEvent('error', {
674
+ ...content,
820
675
  error: isRedelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
821
676
  }, {
822
677
  correlationId
823
678
  });
824
-
825
679
  break;
826
680
  }
827
-
828
681
  case 'run.discarded':
829
682
  {
830
683
  this.logger.debug(`<${content.executionId} (${id})> discarded`);
831
684
  this[kCounters].discarded++;
832
685
  this.status = 'discarded';
833
686
  content.outbound = undefined;
834
-
835
687
  if (!isRedelivered) {
836
688
  return this._doRunLeave(message, true, () => {
837
689
  if (!step) message.ack();
838
690
  });
839
691
  }
840
-
841
692
  break;
842
693
  }
843
-
844
694
  case 'run.outbound.take':
845
695
  {
846
696
  const flow = this._getOutboundSequenceFlowById(content.flow.id);
847
-
848
697
  message.ack();
849
698
  return flow.take(content.flow);
850
699
  }
851
-
852
700
  case 'run.outbound.discard':
853
701
  {
854
702
  const flow = this._getOutboundSequenceFlowById(content.flow.id);
855
-
856
703
  message.ack();
857
704
  return flow.discard(content.flow);
858
705
  }
859
-
860
706
  case 'run.leave':
861
707
  {
862
708
  this.status = undefined;
863
- if (this.bpmnIo) this.bpmnIo.deactivate(message);
864
- if (this.extensions) this.extensions.deactivate(message);
865
-
709
+ if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(message));
866
710
  if (!isRedelivered) {
867
711
  this.broker.publish('run', 'run.next', content, {
868
712
  persistent: false
869
713
  });
870
-
871
714
  this._publishEvent('leave', content, {
872
715
  correlationId
873
716
  });
874
717
  }
875
-
876
718
  break;
877
719
  }
878
-
879
720
  case 'run.next':
880
721
  this._consumeInbound();
881
-
882
722
  break;
883
723
  }
884
-
885
724
  if (!step) message.ack();
886
725
  };
887
-
888
726
  proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
889
727
  const executeMessage = this[kExecuteMessage];
890
- const content = (0, _messageHelper.cloneContent)({ ...executeMessage.content,
728
+ const content = (0, _messageHelper.cloneContent)({
729
+ ...executeMessage.content,
891
730
  ...message.content,
892
731
  executionId: executeMessage.content.executionId,
893
- parent: { ...this.parent
732
+ parent: {
733
+ ...this.parent
894
734
  }
895
735
  });
896
736
  const {
897
737
  correlationId
898
738
  } = message.properties;
899
-
900
739
  this._publishEvent(routingKey, content, message.properties);
901
-
902
740
  const broker = this.broker;
903
-
904
741
  switch (routingKey) {
905
742
  case 'execution.outbound.take':
906
743
  {
@@ -913,7 +750,6 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
913
750
  return this._ackRunExecuteMessage();
914
751
  });
915
752
  }
916
-
917
753
  case 'execution.error':
918
754
  {
919
755
  this.status = 'error';
@@ -925,14 +761,12 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
925
761
  });
926
762
  break;
927
763
  }
928
-
929
764
  case 'execution.discard':
930
765
  this.status = 'discarded';
931
766
  broker.publish('run', 'run.discarded', content, {
932
767
  correlationId
933
768
  });
934
769
  break;
935
-
936
770
  default:
937
771
  {
938
772
  this.status = 'executed';
@@ -941,43 +775,38 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
941
775
  });
942
776
  }
943
777
  }
944
-
945
778
  message.ack();
946
-
947
779
  this._ackRunExecuteMessage();
948
780
  };
949
-
950
781
  proto._ackRunExecuteMessage = function ackRunExecuteMessage() {
951
782
  if (this.environment.settings.step) return;
952
783
  const executeMessage = this[kExecuteMessage];
953
784
  this[kExecuteMessage] = null;
954
785
  executeMessage.ack();
955
786
  };
956
-
957
787
  proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
958
788
  const {
959
789
  content,
960
790
  properties
961
791
  } = message;
962
792
  const correlationId = properties.correlationId;
963
-
964
793
  if (content.ignoreOutbound) {
965
794
  this.broker.publish('run', 'run.leave', (0, _messageHelper.cloneContent)(content), {
966
795
  correlationId
967
796
  });
968
797
  return onOutbound();
969
798
  }
970
-
971
799
  return this._doOutbound((0, _messageHelper.cloneMessage)(message), isDiscarded, (err, outbound) => {
972
800
  if (err) {
973
- return this._publishEvent('error', { ...content,
801
+ return this._publishEvent('error', {
802
+ ...content,
974
803
  error: err
975
804
  }, {
976
805
  correlationId
977
806
  });
978
807
  }
979
-
980
- this.broker.publish('run', 'run.leave', (0, _messageHelper.cloneContent)(content, { ...(outbound.length && {
808
+ this.broker.publish('run', 'run.leave', (0, _messageHelper.cloneContent)(content, {
809
+ ...(outbound.length && {
981
810
  outbound
982
811
  })
983
812
  }), {
@@ -986,19 +815,15 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
986
815
  onOutbound();
987
816
  });
988
817
  };
989
-
990
818
  proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
991
819
  const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
992
820
  if (!outboundSequenceFlows.length) return callback(null, []);
993
821
  const fromContent = fromMessage.content;
994
822
  let discardSequence = fromContent.discardSequence;
995
-
996
823
  if (isDiscarded && !discardSequence && this[kFlags].attachedTo && fromContent.inbound && fromContent.inbound[0]) {
997
824
  discardSequence = [fromContent.inbound[0].id];
998
825
  }
999
-
1000
826
  let outboundFlows;
1001
-
1002
827
  if (isDiscarded) {
1003
828
  outboundFlows = outboundSequenceFlows.map(flow => formatFlowAction(flow, {
1004
829
  action: 'discard'
@@ -1006,22 +831,16 @@ proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
1006
831
  } else if (fromContent.outbound && fromContent.outbound.length) {
1007
832
  outboundFlows = outboundSequenceFlows.map(flow => formatFlowAction(flow, fromContent.outbound.filter(f => f.id === flow.id).pop()));
1008
833
  }
1009
-
1010
834
  if (outboundFlows) {
1011
835
  this._doRunOutbound(outboundFlows, fromContent, discardSequence);
1012
-
1013
836
  return callback(null, outboundFlows);
1014
837
  }
1015
-
1016
838
  return this.evaluateOutbound(fromMessage, fromContent.outboundTakeOne, (err, evaluatedOutbound) => {
1017
839
  if (err) return callback(new _Errors.ActivityError(err.message, fromMessage, err));
1018
-
1019
840
  const outbound = this._doRunOutbound(evaluatedOutbound, fromContent, discardSequence);
1020
-
1021
841
  return callback(null, outbound);
1022
842
  });
1023
843
  };
1024
-
1025
844
  proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequence) {
1026
845
  for (const outboundFlow of outboundList) {
1027
846
  const {
@@ -1029,7 +848,8 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
1029
848
  action
1030
849
  } = outboundFlow;
1031
850
  this.broker.publish('run', 'run.outbound.' + action, (0, _messageHelper.cloneContent)(content, {
1032
- flow: { ...outboundFlow,
851
+ flow: {
852
+ ...outboundFlow,
1033
853
  sequenceId: (0, _shared.getUniqueId)(`${flowId}_${action}`),
1034
854
  ...(discardSequence && {
1035
855
  discardSequence: discardSequence.slice()
@@ -1037,17 +857,13 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
1037
857
  }
1038
858
  }));
1039
859
  }
1040
-
1041
860
  return outboundList;
1042
861
  };
1043
-
1044
862
  proto._onResumeMessage = function onResumeMessage(message) {
1045
863
  message.ack();
1046
864
  const stateMessage = this[kStateMessage];
1047
- const {
1048
- fields
1049
- } = stateMessage;
1050
-
865
+ const fields = stateMessage.fields;
866
+ if (!fields.redelivered) return;
1051
867
  switch (fields.routingKey) {
1052
868
  case 'run.enter':
1053
869
  case 'run.start':
@@ -1055,26 +871,23 @@ proto._onResumeMessage = function onResumeMessage(message) {
1055
871
  case 'run.end':
1056
872
  case 'run.leave':
1057
873
  break;
1058
-
1059
874
  default:
1060
875
  return;
1061
876
  }
1062
-
1063
- if (!fields.redelivered) return;
877
+ if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(stateMessage));
1064
878
  this.logger.debug(`<${this.id}> resume from ${message.content.status}`);
1065
879
  return this.broker.publish('run', fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
1066
880
  };
1067
-
1068
881
  proto._publishEvent = function publishEvent(state, content, properties = {}) {
1069
882
  this.broker.publish('event', `activity.${state}`, (0, _messageHelper.cloneContent)(content, {
1070
883
  state
1071
- }), { ...properties,
884
+ }), {
885
+ ...properties,
1072
886
  type: state,
1073
887
  mandatory: state === 'error',
1074
888
  persistent: 'persistent' in properties ? properties.persistent : state !== 'stop'
1075
889
  });
1076
890
  };
1077
-
1078
891
  proto._onStop = function onStop(message) {
1079
892
  const running = this[kConsuming];
1080
893
  this.stopped = true;
@@ -1085,14 +898,11 @@ proto._onStop = function onStop(message) {
1085
898
  broker.cancel('_activity-execution');
1086
899
  broker.cancel('_run-on-inbound');
1087
900
  broker.cancel('_format-consumer');
1088
-
1089
901
  if (running) {
1090
- if (this.extensions) this.extensions.deactivate(message || this._createMessage());
1091
-
902
+ if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(message));
1092
903
  this._publishEvent('stop', this._createMessage());
1093
904
  }
1094
905
  };
1095
-
1096
906
  proto._consumeApi = function consumeApi() {
1097
907
  const executionId = this[kExec].executionId;
1098
908
  if (!executionId) return;
@@ -1104,31 +914,28 @@ proto._consumeApi = function consumeApi() {
1104
914
  priority: 100
1105
915
  });
1106
916
  };
1107
-
1108
917
  proto._onApiMessage = function onApiMessage(routingKey, message) {
1109
918
  switch (message.properties.type) {
1110
919
  case 'discard':
1111
920
  {
1112
921
  return this._discardRun(message);
1113
922
  }
1114
-
1115
923
  case 'stop':
1116
924
  {
1117
925
  return this._onStop(message);
1118
926
  }
1119
-
1120
927
  case 'shake':
1121
928
  {
1122
929
  return this._shakeOutbound(message);
1123
930
  }
1124
931
  }
1125
932
  };
1126
-
1127
933
  proto._createMessage = function createMessage(override) {
1128
934
  const name = this.name,
1129
- status = this.status,
1130
- parent = this.parent;
1131
- const result = { ...override,
935
+ status = this.status,
936
+ parent = this.parent;
937
+ const result = {
938
+ ...override,
1132
939
  id: this.id,
1133
940
  type: this.type,
1134
941
  ...(name && {
@@ -1141,31 +948,14 @@ proto._createMessage = function createMessage(override) {
1141
948
  parent: (0, _messageHelper.cloneParent)(parent)
1142
949
  })
1143
950
  };
1144
-
1145
951
  for (const [flag, value] of Object.entries(this[kFlags])) {
1146
952
  if (value) result[flag] = value;
1147
953
  }
1148
-
1149
954
  return result;
1150
955
  };
1151
-
1152
956
  proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
1153
957
  return this[kFlows].outboundSequenceFlows.find(flow => flow.id === flowId);
1154
958
  };
1155
-
1156
- proto._resumeExtensions = function resumeExtensions(message, callback) {
1157
- const extensions = this.extensions,
1158
- bpmnIo = this.bpmnIo;
1159
- if (!extensions && !bpmnIo) return callback();
1160
- if (extensions) extensions.activate((0, _messageHelper.cloneMessage)(message), this);
1161
- if (bpmnIo) bpmnIo.activate((0, _messageHelper.cloneMessage)(message), this);
1162
- this.status = 'formatting';
1163
- return this.formatter.format(message, (err, formattedContent, formatted) => {
1164
- if (err) return callback(err);
1165
- return callback(null, formatted && formattedContent);
1166
- });
1167
- };
1168
-
1169
959
  proto._deactivateRunConsumers = function _deactivateRunConsumers() {
1170
960
  const broker = this.broker;
1171
961
  broker.cancel('_activity-api');
@@ -1173,7 +963,6 @@ proto._deactivateRunConsumers = function _deactivateRunConsumers() {
1173
963
  broker.cancel('_activity-execution');
1174
964
  this[kConsuming] = false;
1175
965
  };
1176
-
1177
966
  function OutboundEvaluator(activity, outboundFlows) {
1178
967
  this.activity = activity;
1179
968
  this.broker = activity.broker;
@@ -1181,19 +970,16 @@ function OutboundEvaluator(activity, outboundFlows) {
1181
970
  const defaultFlowIdx = flows.findIndex(({
1182
971
  isDefault
1183
972
  }) => isDefault);
1184
-
1185
973
  if (defaultFlowIdx > -1) {
1186
974
  const [defaultFlow] = flows.splice(defaultFlowIdx, 1);
1187
975
  flows.push(defaultFlow);
1188
976
  }
1189
-
1190
977
  this.defaultFlowIdx = outboundFlows.findIndex(({
1191
978
  isDefault
1192
979
  }) => isDefault);
1193
980
  this._onEvaluated = this.onEvaluated.bind(this);
1194
981
  this.evaluateArgs = {};
1195
982
  }
1196
-
1197
983
  OutboundEvaluator.prototype.evaluate = function evaluate(fromMessage, discardRestAtTake, callback) {
1198
984
  const outboundFlows = this.outboundFlows;
1199
985
  const args = this.evaluateArgs = {
@@ -1212,7 +998,6 @@ OutboundEvaluator.prototype.evaluate = function evaluate(fromMessage, discardRes
1212
998
  });
1213
999
  return this.evaluateFlow(flows.shift());
1214
1000
  };
1215
-
1216
1001
  OutboundEvaluator.prototype.onEvaluated = function onEvaluated(routingKey, message) {
1217
1002
  const content = message.content;
1218
1003
  const {
@@ -1221,45 +1006,35 @@ OutboundEvaluator.prototype.onEvaluated = function onEvaluated(routingKey, messa
1221
1006
  evaluationId
1222
1007
  } = message.content;
1223
1008
  const args = this.evaluateArgs;
1224
-
1225
1009
  if (action === 'take') {
1226
1010
  args.takenCount++;
1227
1011
  args.conditionMet = true;
1228
1012
  }
1229
-
1230
1013
  args.result[flowId] = content;
1231
-
1232
1014
  if ('result' in content) {
1233
1015
  this.activity.logger.debug(`<${evaluationId} (${this.activity.id})> flow <${flowId}> evaluated to: ${!!content.result}`);
1234
1016
  }
1235
-
1236
1017
  let nextFlow = args.flows.shift();
1237
1018
  if (!nextFlow) return this.completed();
1238
-
1239
1019
  if (args.discardRestAtTake && args.conditionMet) {
1240
1020
  do {
1241
1021
  args.result[nextFlow.id] = formatFlowAction(nextFlow, {
1242
1022
  action: 'discard'
1243
1023
  });
1244
1024
  } while (nextFlow = args.flows.shift());
1245
-
1246
1025
  return this.completed();
1247
1026
  }
1248
-
1249
1027
  if (args.conditionMet && nextFlow.isDefault) {
1250
1028
  args.result[nextFlow.id] = formatFlowAction(nextFlow, {
1251
1029
  action: 'discard'
1252
1030
  });
1253
1031
  return this.completed();
1254
1032
  }
1255
-
1256
1033
  message.ack();
1257
1034
  this.evaluateFlow(nextFlow);
1258
1035
  };
1259
-
1260
1036
  OutboundEvaluator.prototype.evaluateFlow = function evaluateFlow(flow) {
1261
1037
  const broker = this.broker;
1262
-
1263
1038
  if (flow.isDefault) {
1264
1039
  return broker.publish('execution', 'evaluate.flow.take', formatFlowAction(flow, {
1265
1040
  action: 'take'
@@ -1267,9 +1042,7 @@ OutboundEvaluator.prototype.evaluateFlow = function evaluateFlow(flow) {
1267
1042
  persistent: false
1268
1043
  });
1269
1044
  }
1270
-
1271
1045
  const flowCondition = flow.getCondition();
1272
-
1273
1046
  if (!flowCondition) {
1274
1047
  return broker.publish('execution', 'evaluate.flow.take', formatFlowAction(flow, {
1275
1048
  action: 'take'
@@ -1277,7 +1050,6 @@ OutboundEvaluator.prototype.evaluateFlow = function evaluateFlow(flow) {
1277
1050
  persistent: false
1278
1051
  });
1279
1052
  }
1280
-
1281
1053
  const {
1282
1054
  fromMessage,
1283
1055
  evaluationId
@@ -1294,7 +1066,6 @@ OutboundEvaluator.prototype.evaluateFlow = function evaluateFlow(flow) {
1294
1066
  });
1295
1067
  });
1296
1068
  };
1297
-
1298
1069
  OutboundEvaluator.prototype.completed = function completed(err) {
1299
1070
  const {
1300
1071
  callback,
@@ -1305,28 +1076,25 @@ OutboundEvaluator.prototype.completed = function completed(err) {
1305
1076
  } = this.evaluateArgs;
1306
1077
  this.broker.cancel(`_flow-evaluation-${evaluationId}`);
1307
1078
  if (err) return callback(err);
1308
-
1309
1079
  if (!takenCount && this.outboundFlows.length) {
1310
1080
  const nonTakenError = new _Errors.ActivityError(`<${this.activity.id}> no conditional flow taken`, fromMessage);
1311
1081
  return callback(nonTakenError);
1312
1082
  }
1313
-
1314
1083
  const message = fromMessage.content.message;
1315
1084
  const evaluationResult = [];
1316
-
1317
1085
  for (const flow of Object.values(result)) {
1318
- evaluationResult.push({ ...flow,
1086
+ evaluationResult.push({
1087
+ ...flow,
1319
1088
  ...(message !== undefined && {
1320
1089
  message
1321
1090
  })
1322
1091
  });
1323
1092
  }
1324
-
1325
1093
  return callback(null, evaluationResult);
1326
1094
  };
1327
-
1328
1095
  function formatFlowAction(flow, options) {
1329
- return { ...options,
1096
+ return {
1097
+ ...options,
1330
1098
  id: flow.id,
1331
1099
  action: options.action,
1332
1100
  ...(flow.isDefault && {