bpmn-elements 14.0.1 → 15.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.
Files changed (55) hide show
  1. package/README.md +0 -4
  2. package/dist/Context.js +41 -35
  3. package/dist/Environment.js +1 -1
  4. package/dist/Expressions.js +1 -1
  5. package/dist/MessageFormatter.js +0 -1
  6. package/dist/Timers.js +5 -9
  7. package/dist/Tracker.js +15 -19
  8. package/dist/activity/Activity.js +17 -11
  9. package/dist/activity/ActivityExecution.js +43 -29
  10. package/dist/definition/Definition.js +1 -1
  11. package/dist/definition/DefinitionExecution.js +64 -55
  12. package/dist/eventDefinitions/EscalationEventDefinition.js +1 -1
  13. package/dist/eventDefinitions/LinkEventDefinition.js +1 -1
  14. package/dist/eventDefinitions/MessageEventDefinition.js +1 -1
  15. package/dist/eventDefinitions/SignalEventDefinition.js +3 -2
  16. package/dist/events/BoundaryEvent.js +11 -9
  17. package/dist/events/EndEvent.js +1 -1
  18. package/dist/events/IntermediateCatchEvent.js +1 -1
  19. package/dist/events/IntermediateThrowEvent.js +1 -1
  20. package/dist/events/StartEvent.js +1 -1
  21. package/dist/flows/SequenceFlow.js +1 -1
  22. package/dist/gateways/EventBasedGateway.js +1 -1
  23. package/dist/gateways/ExclusiveGateway.js +1 -1
  24. package/dist/gateways/InclusiveGateway.js +1 -1
  25. package/dist/gateways/ParallelGateway.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/io/InputOutputSpecification.js +1 -1
  28. package/dist/io/Properties.js +1 -1
  29. package/dist/process/Process.js +1 -1
  30. package/dist/process/ProcessExecution.js +67 -40
  31. package/dist/tasks/CallActivity.js +1 -1
  32. package/dist/tasks/LoopCharacteristics.js +2 -2
  33. package/dist/tasks/ReceiveTask.js +1 -1
  34. package/dist/tasks/ScriptTask.js +1 -1
  35. package/dist/tasks/ServiceImplementation.js +1 -1
  36. package/dist/tasks/ServiceTask.js +1 -1
  37. package/dist/tasks/SignalTask.js +1 -1
  38. package/dist/tasks/StandardLoopCharacteristics.js +1 -1
  39. package/dist/tasks/SubProcess.js +27 -28
  40. package/dist/tasks/Task.js +1 -1
  41. package/dist/tasks/Transaction.js +1 -1
  42. package/package.json +5 -3
  43. package/src/Context.js +51 -35
  44. package/src/MessageFormatter.js +0 -3
  45. package/src/Timers.js +5 -9
  46. package/src/Tracker.js +13 -17
  47. package/src/activity/Activity.js +5 -3
  48. package/src/activity/ActivityExecution.js +43 -26
  49. package/src/definition/DefinitionExecution.js +64 -54
  50. package/src/eventDefinitions/SignalEventDefinition.js +1 -1
  51. package/src/events/BoundaryEvent.js +10 -8
  52. package/src/process/ProcessExecution.js +70 -40
  53. package/src/tasks/LoopCharacteristics.js +2 -2
  54. package/src/tasks/SubProcess.js +27 -27
  55. package/types/types.d.ts +1 -1
package/README.md CHANGED
@@ -76,7 +76,3 @@ The following elements are tested and supported.
76
76
  - Transaction
77
77
 
78
78
  All activities share the same [base](/docs/Activity.md) and and [api](/docs/SharedApi.md).
79
-
80
- # Acknowledgments
81
-
82
- ISO 8601 duration parser [iso8601-duration](https://www.npmjs.com/package/iso8601-duration) source is copied and extended with repeat pattern. License [MIT @ tolu](https://tolu.mit-license.org/)
package/dist/Context.js CHANGED
@@ -7,7 +7,7 @@ exports.default = Context;
7
7
  var _BpmnIO = _interopRequireDefault(require("./io/BpmnIO.js"));
8
8
  var _Environment = _interopRequireDefault(require("./Environment.js"));
9
9
  var _shared = require("./shared.js");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const kOwner = Symbol.for('owner');
12
12
  const kActivated = Symbol.for('activated');
13
13
  function Context(definitionContext, environment) {
@@ -28,17 +28,7 @@ function ContextInstance(definitionContext, environment, owner) {
28
28
  this.definitionContext = definitionContext;
29
29
  this.environment = environment;
30
30
  this.extensionsMapper = new ExtensionsMapper(this);
31
- this.refs = {
32
- activityRefs: {},
33
- associationRefs: [],
34
- dataObjectRefs: {},
35
- dataStoreRefs: {},
36
- messageFlows: [],
37
- processes: [],
38
- processRefs: {},
39
- sequenceFlowRefs: {},
40
- sequenceFlows: []
41
- };
31
+ this.refs = new Map([['activityRefs', new Map()], ['sequenceFlowRefs', new Map()], ['processRefs', new Map()], ['messageFlows', new Set()], ['associationRefs', new Map()], ['dataObjectRefs', new Map()], ['dataStoreRefs', new Map()]]);
42
32
  this[kOwner] = owner;
43
33
  }
44
34
  Object.defineProperty(ContextInstance.prototype, 'owner', {
@@ -47,20 +37,21 @@ Object.defineProperty(ContextInstance.prototype, 'owner', {
47
37
  }
48
38
  });
49
39
  ContextInstance.prototype.getActivityById = function getActivityById(activityId) {
50
- const activityInstance = this.refs.activityRefs[activityId];
40
+ const activityInstance = this.refs.get('activityRefs').get(activityId);
51
41
  if (activityInstance) return activityInstance;
52
42
  const activity = this.definitionContext.getActivityById(activityId);
53
43
  if (!activity) return null;
54
44
  return this.upsertActivity(activity);
55
45
  };
56
46
  ContextInstance.prototype.upsertActivity = function upsertActivity(activityDef) {
57
- let activityInstance = this.refs.activityRefs[activityDef.id];
47
+ let activityInstance = this.refs.get('activityRefs').get(activityDef.id);
58
48
  if (activityInstance) return activityInstance;
59
- activityInstance = this.refs.activityRefs[activityDef.id] = new activityDef.Behaviour(activityDef, this);
49
+ activityInstance = new activityDef.Behaviour(activityDef, this);
50
+ this.refs.get('activityRefs').set(activityDef.id, activityInstance);
60
51
  return activityInstance;
61
52
  };
62
53
  ContextInstance.prototype.getSequenceFlowById = function getSequenceFlowById(sequenceFlowId) {
63
- const flowInstance = this.refs.sequenceFlowRefs[sequenceFlowId];
54
+ const flowInstance = this.refs.get('sequenceFlowRefs').get(sequenceFlowId);
64
55
  if (flowInstance) return flowInstance;
65
56
  const flowDef = this.definitionContext.getSequenceFlowById(sequenceFlowId);
66
57
  if (!flowDef) return null;
@@ -85,36 +76,37 @@ ContextInstance.prototype.getSequenceFlows = function getSequenceFlows(scopeId)
85
76
  return (this.definitionContext.getSequenceFlows(scopeId) || []).map(flow => this.upsertSequenceFlow(flow));
86
77
  };
87
78
  ContextInstance.prototype.upsertSequenceFlow = function upsertSequenceFlow(flowDefinition) {
88
- const refs = this.refs.sequenceFlowRefs;
89
- let flowInstance = refs[flowDefinition.id];
79
+ const sequenceFlowRefs = this.refs.get('sequenceFlowRefs');
80
+ let flowInstance = sequenceFlowRefs.get(flowDefinition.id);
90
81
  if (flowInstance) return flowInstance;
91
- flowInstance = refs[flowDefinition.id] = new flowDefinition.Behaviour(flowDefinition, this);
92
- this.refs.sequenceFlows.push(flowInstance);
82
+ flowInstance = new flowDefinition.Behaviour(flowDefinition, this);
83
+ sequenceFlowRefs.set(flowDefinition.id, flowInstance);
93
84
  return flowInstance;
94
85
  };
95
86
  ContextInstance.prototype.getAssociations = function getAssociations(scopeId) {
96
87
  return (this.definitionContext.getAssociations(scopeId) || []).map(association => this.upsertAssociation(association));
97
88
  };
98
89
  ContextInstance.prototype.upsertAssociation = function upsertAssociation(associationDefinition) {
99
- const refs = this.refs.associationRefs;
100
- let instance = refs[associationDefinition.id];
90
+ const associationRefs = this.refs.get('associationRefs');
91
+ let instance = associationRefs.get(associationDefinition.id);
101
92
  if (instance) return instance;
102
- instance = refs[associationDefinition.id] = new associationDefinition.Behaviour(associationDefinition, this);
93
+ instance = new associationDefinition.Behaviour(associationDefinition, this);
94
+ associationRefs.set(associationDefinition.id, instance);
103
95
  return instance;
104
96
  };
105
97
  ContextInstance.prototype.clone = function clone(newEnvironment, newOwner) {
106
98
  return new ContextInstance(this.definitionContext, newEnvironment || this.environment, newOwner);
107
99
  };
108
100
  ContextInstance.prototype.getProcessById = function getProcessById(processId) {
109
- const refs = this.refs.processRefs;
110
- let bp = this.refs.processRefs[processId];
101
+ const processRefs = this.refs.get('processRefs');
102
+ let bp = processRefs.get(processId);
111
103
  if (bp) return bp;
112
104
  const processDefinition = this.definitionContext.getProcessById(processId);
113
105
  if (!processDefinition) return null;
114
106
  const bpContext = this.clone(this.environment.clone());
115
- bp = refs[processId] = new processDefinition.Behaviour(processDefinition, bpContext);
107
+ bp = new processDefinition.Behaviour(processDefinition, bpContext);
108
+ processRefs.set(processId, bp);
116
109
  bpContext[kOwner] = bp;
117
- this.refs.processes.push(bp);
118
110
  return bp;
119
111
  };
120
112
  ContextInstance.prototype.getNewProcessById = function getNewProcessById(processId) {
@@ -136,26 +128,40 @@ ContextInstance.prototype.getExecutableProcesses = function getExecutableProcess
136
128
  }) => this.getProcessById(processId));
137
129
  };
138
130
  ContextInstance.prototype.getMessageFlows = function getMessageFlows(sourceId) {
139
- if (!this.refs.messageFlows.length) {
140
- const flows = this.definitionContext.getMessageFlows() || [];
141
- this.refs.messageFlows.push(...flows.map(flow => new flow.Behaviour(flow, this)));
131
+ const messageFlowRefs = this.refs.get('messageFlows');
132
+ const result = [];
133
+ if (!messageFlowRefs.size) {
134
+ const msgFlows = this.definitionContext.getMessageFlows() || [];
135
+ for (const msgFlow of msgFlows) {
136
+ const flow = new msgFlow.Behaviour(msgFlow, this);
137
+ messageFlowRefs.add(flow);
138
+ if (flow.source.processId === sourceId) result.push(flow);
139
+ }
140
+ } else {
141
+ for (const flow of messageFlowRefs) {
142
+ if (flow.source.processId === sourceId) result.push(flow);
143
+ }
142
144
  }
143
- return this.refs.messageFlows.filter(flow => flow.source.processId === sourceId);
145
+ return result;
144
146
  };
145
147
  ContextInstance.prototype.getDataObjectById = function getDataObjectById(referenceId) {
148
+ const dataObjectRefs = this.refs.get('dataObjectRefs');
146
149
  let dataObject;
147
- if (dataObject = this.refs.dataObjectRefs[referenceId]) return dataObject;
150
+ if (dataObject = dataObjectRefs.get(referenceId)) return dataObject;
148
151
  const dataObjectDef = this.definitionContext.getDataObjectById(referenceId);
149
152
  if (!dataObjectDef) return;
150
- dataObject = this.refs.dataObjectRefs[dataObjectDef.id] = new dataObjectDef.Behaviour(dataObjectDef, this);
153
+ dataObject = new dataObjectDef.Behaviour(dataObjectDef, this);
154
+ dataObjectRefs.set(dataObjectDef.id, dataObject);
151
155
  return dataObject;
152
156
  };
153
157
  ContextInstance.prototype.getDataStoreById = function getDataStoreById(referenceId) {
158
+ const dataStoreRefs = this.refs.get('dataStoreRefs');
154
159
  let dataStore;
155
- if (dataStore = this.refs.dataStoreRefs[referenceId]) return dataStore;
160
+ if (dataStore = dataStoreRefs.get(referenceId)) return dataStore;
156
161
  const dataStoreDef = this.definitionContext.getDataStoreById(referenceId) || this.definitionContext.getDataStoreReferenceById(referenceId);
157
162
  if (!dataStoreDef) return;
158
- dataStore = this.refs.dataStoreRefs[dataStoreDef.id] = new dataStoreDef.Behaviour(dataStoreDef, this);
163
+ dataStore = new dataStoreDef.Behaviour(dataStoreDef, this);
164
+ dataStoreRefs.set(dataStoreDef.id, dataStore);
159
165
  return dataStore;
160
166
  };
161
167
  ContextInstance.prototype.getStartActivities = function getStartActivities(filterOptions, scopeId) {
@@ -7,7 +7,7 @@ exports.default = Environment;
7
7
  var _Expressions = _interopRequireDefault(require("./Expressions.js"));
8
8
  var _Scripts = require("./Scripts.js");
9
9
  var _Timers = require("./Timers.js");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const kServices = Symbol.for('services');
12
12
  const kVariables = Symbol.for('variables');
13
13
  const defaultOptions = ['expressions', 'extensions', 'Logger', 'output', 'scripts', 'services', 'settings', 'timers', 'variables'];
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = Expressions;
7
7
  var _getPropertyValue = _interopRequireDefault(require("./getPropertyValue.js"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  const isExpressionPattern = /^\${(.+?)}$/;
10
10
  const expressionPattern = /\${(.+?)}/;
11
11
  function Expressions() {
@@ -20,7 +20,6 @@ function Formatter(element, formatQ) {
20
20
  this.broker = broker;
21
21
  this.logger = logger;
22
22
  this.formatQ = formatQ;
23
- this.pendingFormats = [];
24
23
  this[kOnMessage] = this._onMessage.bind(this);
25
24
  }
26
25
  Formatter.prototype.format = function format(message, callback) {
package/dist/Timers.js CHANGED
@@ -14,13 +14,13 @@ function Timers(options) {
14
14
  clearTimeout,
15
15
  ...options
16
16
  };
17
- this[kExecuting] = [];
17
+ this[kExecuting] = new Set();
18
18
  this.setTimeout = this.setTimeout.bind(this);
19
19
  this.clearTimeout = this.clearTimeout.bind(this);
20
20
  }
21
21
  Object.defineProperty(Timers.prototype, 'executing', {
22
22
  get() {
23
- return this[kExecuting].slice();
23
+ return [...this[kExecuting]];
24
24
  }
25
25
  });
26
26
  Timers.prototype.register = function register(owner) {
@@ -30,10 +30,7 @@ Timers.prototype.setTimeout = function wrappedSetTimeout(callback, delay, ...arg
30
30
  return this._setTimeout(null, callback, delay, ...args);
31
31
  };
32
32
  Timers.prototype.clearTimeout = function wrappedClearTimeout(ref) {
33
- const executing = this[kExecuting];
34
- const idx = executing.indexOf(ref);
35
- if (idx > -1) {
36
- executing.splice(idx, 1);
33
+ if (this[kExecuting].delete(ref)) {
37
34
  ref.timerRef = this.options.clearTimeout(ref.timerRef);
38
35
  return;
39
36
  }
@@ -42,14 +39,13 @@ Timers.prototype.clearTimeout = function wrappedClearTimeout(ref) {
42
39
  Timers.prototype._setTimeout = function setTimeout(owner, callback, delay, ...args) {
43
40
  const executing = this[kExecuting];
44
41
  const ref = this._getReference(owner, callback, delay, args);
45
- executing.push(ref);
42
+ executing.add(ref);
46
43
  if (delay < MAX_DELAY) {
47
44
  ref.timerRef = this.options.setTimeout(onTimeout, ref.delay, ...ref.args);
48
45
  }
49
46
  return ref;
50
47
  function onTimeout(...rargs) {
51
- const idx = executing.indexOf(ref);
52
- if (idx > -1) executing.splice(idx, 1);
48
+ executing.delete(ref);
53
49
  return callback(...rargs);
54
50
  }
55
51
  };
package/dist/Tracker.js CHANGED
@@ -7,17 +7,17 @@ exports.ActivityTracker = ActivityTracker;
7
7
  function ActivityTracker(parentId) {
8
8
  this.id = parentId;
9
9
  this.status = {
10
- wait: [],
11
- execute: [],
12
- timer: []
10
+ wait: new Set(),
11
+ execute: new Set(),
12
+ timer: new Set()
13
13
  };
14
14
  }
15
15
  Object.defineProperty(ActivityTracker.prototype, 'activityStatus', {
16
16
  get() {
17
17
  const status = this.status;
18
- if (status.execute.length) return 'executing';
19
- if (status.timer.length) return 'timer';
20
- return status.wait.length ? 'wait' : 'idle';
18
+ if (status.execute.size) return 'executing';
19
+ if (status.timer.size) return 'timer';
20
+ return status.wait.size ? 'wait' : 'idle';
21
21
  }
22
22
  });
23
23
  ActivityTracker.prototype.track = function track(routingKey, message) {
@@ -55,27 +55,24 @@ ActivityTracker.prototype._executing = function executing(id) {
55
55
  wait,
56
56
  execute
57
57
  } = this.status;
58
- if (execute.indexOf(id) === -1) execute.push(id);
59
- let idx;
60
- if ((idx = wait.indexOf(id)) !== -1) wait.splice(idx, 1);
58
+ wait.delete(id);
59
+ execute.add(id);
61
60
  };
62
61
  ActivityTracker.prototype._waiting = function waiting(id) {
63
62
  const {
64
63
  wait,
65
64
  execute
66
65
  } = this.status;
67
- if (wait.indexOf(id) === -1) wait.push(id);
68
- let idx;
69
- if ((idx = execute.indexOf(id)) !== -1) execute.splice(idx, 1);
66
+ execute.delete(id);
67
+ wait.add(id);
70
68
  };
71
69
  ActivityTracker.prototype._timer = function timerFn(id) {
72
70
  const {
73
71
  timer,
74
72
  execute
75
73
  } = this.status;
76
- if (timer.indexOf(id) === -1) timer.push(id);
77
- let idx;
78
- if ((idx = execute.indexOf(id)) !== -1) execute.splice(idx, 1);
74
+ execute.delete(id);
75
+ timer.add(id);
79
76
  };
80
77
  ActivityTracker.prototype._leave = function leave(id) {
81
78
  const {
@@ -83,8 +80,7 @@ ActivityTracker.prototype._leave = function leave(id) {
83
80
  execute,
84
81
  timer
85
82
  } = this.status;
86
- let idx;
87
- if ((idx = wait.indexOf(id)) !== -1) wait.splice(idx, 1);
88
- if ((idx = execute.indexOf(id)) !== -1) execute.splice(idx, 1);
89
- if ((idx = timer.indexOf(id)) !== -1) timer.splice(idx, 1);
83
+ execute.delete(id);
84
+ timer.delete(id);
85
+ wait.delete(id);
90
86
  };
@@ -11,7 +11,7 @@ var _EventBroker = require("../EventBroker.js");
11
11
  var _MessageFormatter = require("../MessageFormatter.js");
12
12
  var _messageHelper = require("../messageHelper.js");
13
13
  var _Errors = require("../error/Errors.js");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  const kActivityDef = Symbol.for('activityDefinition');
16
16
  const kConsuming = Symbol.for('consuming');
17
17
  const kConsumingRunQ = Symbol.for('run queue consumer');
@@ -345,16 +345,22 @@ Activity.prototype.addInboundListeners = function addInboundListeners() {
345
345
  const onInboundEvent = this._onInboundEvent.bind(this);
346
346
  const triggerConsumerTag = `_inbound-${this.id}`;
347
347
  for (const trigger of this[kFlows].inboundTriggers) {
348
- if (trigger.isSequenceFlow) trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {
349
- noAck: true,
350
- consumerTag: triggerConsumerTag
351
- });else if (this.isForCompensation) trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, {
352
- noAck: true,
353
- consumerTag: triggerConsumerTag
354
- });else trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {
355
- noAck: true,
356
- consumerTag: triggerConsumerTag
357
- });
348
+ if (trigger.isSequenceFlow) {
349
+ trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {
350
+ noAck: true,
351
+ consumerTag: triggerConsumerTag
352
+ });
353
+ } else if (this.isForCompensation) {
354
+ trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, {
355
+ noAck: true,
356
+ consumerTag: triggerConsumerTag
357
+ });
358
+ } else {
359
+ trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {
360
+ noAck: true,
361
+ consumerTag: triggerConsumerTag
362
+ });
363
+ }
358
364
  }
359
365
  };
360
366
  Activity.prototype.removeInboundListeners = function removeInboundListeners() {
@@ -17,7 +17,7 @@ function ActivityExecution(activity, context) {
17
17
  this.context = context;
18
18
  this.id = activity.id;
19
19
  this.broker = activity.broker;
20
- this[kPostponed] = [];
20
+ this[kPostponed] = new Set();
21
21
  this[kCompleted] = false;
22
22
  this[kExecuteQ] = this.broker.assertQueue('execute-q', {
23
23
  durable: true,
@@ -44,7 +44,7 @@ ActivityExecution.prototype.execute = function execute(executeMessage) {
44
44
  isRootScope: true
45
45
  });
46
46
  if (executeMessage.fields.redelivered) {
47
- this[kPostponed].splice(0);
47
+ this[kPostponed].clear();
48
48
  this._debug('resume execution');
49
49
  if (!this.source) this.source = new this.activity.Behaviour(this.activity, this.context);
50
50
  this.activate();
@@ -102,11 +102,12 @@ ActivityExecution.prototype.getApi = function getApi(apiMessage) {
102
102
  }
103
103
  const api = (0, _Api.ActivityApi)(self.broker, apiMessage);
104
104
  api.getExecuting = function getExecuting() {
105
- return self[kPostponed].reduce((result, msg) => {
106
- if (msg.content.executionId === apiMessage.content.executionId) return result;
105
+ const result = [];
106
+ for (const msg of self[kPostponed]) {
107
+ if (msg.content.executionId === apiMessage.content.executionId) continue;
107
108
  result.push(self.getApi(msg));
108
- return result;
109
- }, []);
109
+ }
110
+ return result;
110
111
  };
111
112
  return api;
112
113
  };
@@ -115,7 +116,10 @@ ActivityExecution.prototype.passthrough = function passthrough(executeMessage) {
115
116
  return this._sourceExecute(executeMessage);
116
117
  };
117
118
  ActivityExecution.prototype.getPostponed = function getPostponed() {
118
- let apis = this[kPostponed].map(msg => this.getApi(msg));
119
+ let apis = [];
120
+ for (const msg of this[kPostponed]) {
121
+ apis.push(this.getApi(msg));
122
+ }
119
123
  if (!this.activity.isSubProcess || !this.source) return apis;
120
124
  apis = apis.concat(this.source.getPostponed());
121
125
  return apis;
@@ -132,7 +136,7 @@ ActivityExecution.prototype.getState = function getState() {
132
136
  };
133
137
  };
134
138
  ActivityExecution.prototype.recover = function recover(state) {
135
- this[kPostponed].splice(0);
139
+ this[kPostponed].clear();
136
140
  if (!state) return this;
137
141
  if ('completed' in state) this[kCompleted] = state.completed;
138
142
  const source = this.source = new this.activity.Behaviour(this.activity, this.context);
@@ -166,7 +170,7 @@ ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routin
166
170
  switch (routingKey) {
167
171
  case 'execute.resume.execution':
168
172
  {
169
- if (!this[kPostponed].length) return this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
173
+ if (!this[kPostponed].size) return this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
170
174
  break;
171
175
  }
172
176
  case 'execute.cancel':
@@ -214,19 +218,23 @@ ActivityExecution.prototype._onStateChangeMessage = function onStateChangeMessag
214
218
  executionId
215
219
  } = message.content;
216
220
  const postponed = this[kPostponed];
217
- const idx = postponed.findIndex(msg => msg.content.executionId === executionId);
218
221
  let previousMsg;
219
- if (idx > -1) {
222
+ for (const msg of postponed) {
223
+ if (msg.content.executionId === executionId) previousMsg = msg;
224
+ }
225
+ if (previousMsg) {
220
226
  if (ignoreIfExecuting) {
221
227
  message.ack();
222
228
  return false;
223
229
  }
224
- previousMsg = postponed.splice(idx, 1, message)[0];
230
+ postponed.delete(previousMsg);
231
+ postponed.add(message);
225
232
  previousMsg.ack();
226
233
  return true;
234
+ } else {
235
+ postponed.add(message);
236
+ return true;
227
237
  }
228
- postponed.push(message);
229
- return true;
230
238
  };
231
239
  ActivityExecution.prototype._onExecutionCompleted = function onExecutionCompleted(message) {
232
240
  const postponedMsg = this._ackPostponed(message);
@@ -240,8 +248,11 @@ ActivityExecution.prototype._onExecutionCompleted = function onExecutionComplete
240
248
  if (!isRootScope) {
241
249
  this._debug('completed sub execution');
242
250
  if (!keep) message.ack();
243
- if (postponed.length === 1 && postponed[0].content.isRootScope && !postponed[0].content.preventComplete) {
244
- return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(postponed[0].content));
251
+ if (postponed.size === 1) {
252
+ const onlyMessage = postponed.values().next().value;
253
+ if (onlyMessage.content.isRootScope && !onlyMessage.content.preventComplete) {
254
+ return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(onlyMessage.content));
255
+ }
245
256
  }
246
257
  return;
247
258
  }
@@ -250,7 +261,7 @@ ActivityExecution.prototype._onExecutionCompleted = function onExecutionComplete
250
261
  message.ack(true);
251
262
  this.deactivate();
252
263
  const subApis = this.getPostponed();
253
- postponed.splice(0);
264
+ postponed.clear();
254
265
  for (const api of subApis) api.discard();
255
266
  this._publishExecutionCompleted('completed', {
256
267
  ...postponedMsg.content,
@@ -268,17 +279,20 @@ ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarde
268
279
  const correlationId = message.properties.correlationId;
269
280
  if (!error && !isRootScope) {
270
281
  message.ack();
271
- if (postponed.length === 1 && postponed[0].content.isRootScope) {
272
- return this.broker.publish('execution', 'execute.discard', postponed[0].content, {
273
- correlationId
274
- });
282
+ if (postponed.size === 1) {
283
+ const onlyMessage = postponed.values().next().value;
284
+ if (onlyMessage.content.isRootScope) {
285
+ return this.broker.publish('execution', 'execute.discard', onlyMessage.content, {
286
+ correlationId
287
+ });
288
+ }
275
289
  }
276
290
  return;
277
291
  }
278
292
  message.ack(true);
279
293
  this.deactivate();
280
294
  const subApis = this.getPostponed();
281
- postponed.splice(0);
295
+ postponed.clear();
282
296
  for (const api of subApis) api.discard();
283
297
  this._publishExecutionCompleted(discardType, (0, _messageHelper.cloneContent)(message.content), correlationId);
284
298
  };
@@ -297,13 +311,13 @@ ActivityExecution.prototype._ackPostponed = function ackPostponed(completeMessag
297
311
  executionId: eid
298
312
  } = completeMessage.content;
299
313
  const postponed = this[kPostponed];
300
- const idx = postponed.findIndex(({
301
- content: c
302
- }) => c.executionId === eid);
303
- if (idx === -1) return;
304
- const [msg] = postponed.splice(idx, 1);
305
- msg.ack();
306
- return msg;
314
+ for (const msg of postponed) {
315
+ if (msg.content.executionId === eid) {
316
+ postponed.delete(msg);
317
+ msg.ack();
318
+ return msg;
319
+ }
320
+ }
307
321
  };
308
322
  ActivityExecution.prototype._onParentApiMessage = function onParentApiMessage(routingKey, message) {
309
323
  switch (message.properties.type) {
@@ -11,7 +11,7 @@ var _EventBroker = require("../EventBroker.js");
11
11
  var _shared = require("../shared.js");
12
12
  var _Errors = require("../error/Errors.js");
13
13
  var _messageHelper = require("../messageHelper.js");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  const kConsuming = Symbol.for('consuming');
16
16
  const kCounters = Symbol.for('counters');
17
17
  const kExec = Symbol.for('execution');