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
@@ -5,22 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.StartEventBehaviour = StartEventBehaviour;
7
7
  exports.default = StartEvent;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _EventDefinitionExecution = _interopRequireDefault(require("../eventDefinitions/EventDefinitionExecution"));
12
-
13
10
  var _messageHelper = require("../messageHelper");
14
-
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
12
  const kExecuteMessage = Symbol.for('executeMessage');
18
13
  const kExecution = Symbol.for('execution');
19
-
20
14
  function StartEvent(activityDef, context) {
21
15
  return new _Activity.default(StartEventBehaviour, activityDef, context);
22
16
  }
23
-
24
17
  function StartEventBehaviour(activity) {
25
18
  this.id = activity.id;
26
19
  this.type = activity.type;
@@ -28,30 +21,23 @@ function StartEventBehaviour(activity) {
28
21
  this.broker = activity.broker;
29
22
  this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
30
23
  }
31
-
32
24
  const proto = StartEventBehaviour.prototype;
33
25
  Object.defineProperty(proto, 'executionId', {
34
26
  get() {
35
27
  const message = this[kExecuteMessage];
36
28
  return message && message.content.executionId;
37
29
  }
38
-
39
30
  });
40
-
41
31
  proto.execute = function execute(executeMessage) {
42
32
  const execution = this[kExecution];
43
-
44
33
  if (execution) {
45
34
  return execution.execute(executeMessage);
46
35
  }
47
-
48
36
  const content = (0, _messageHelper.cloneContent)(executeMessage.content);
49
37
  const broker = this.broker;
50
-
51
38
  if (!content.form) {
52
39
  return broker.publish('execution', 'execute.completed', content);
53
40
  }
54
-
55
41
  const executionId = content.executionId;
56
42
  this[kExecuteMessage] = executeMessage;
57
43
  broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => this._onApiMessage(...args), {
@@ -63,26 +49,23 @@ proto.execute = function execute(executeMessage) {
63
49
  noAck: true,
64
50
  consumerTag: `_api-delegated-${executionId}`
65
51
  });
66
- broker.publish('event', 'activity.wait', { ...content,
52
+ broker.publish('event', 'activity.wait', {
53
+ ...content,
67
54
  executionId,
68
55
  state: 'wait'
69
56
  });
70
57
  };
71
-
72
58
  proto._onApiMessage = function onApiMessage(routingKey, message) {
73
59
  const {
74
60
  type: messageType,
75
61
  correlationId
76
62
  } = message.properties;
77
-
78
63
  switch (messageType) {
79
64
  case 'stop':
80
65
  return this._stop();
81
-
82
66
  case 'signal':
83
67
  {
84
68
  this._stop();
85
-
86
69
  const content = this[kExecuteMessage].content;
87
70
  return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
88
71
  output: message.content.message,
@@ -91,11 +74,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
91
74
  correlationId
92
75
  });
93
76
  }
94
-
95
77
  case 'discard':
96
78
  {
97
79
  this._stop();
98
-
99
80
  const content = this[kExecuteMessage].content;
100
81
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content), {
101
82
  correlationId
@@ -103,7 +84,6 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
103
84
  }
104
85
  }
105
86
  };
106
-
107
87
  proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, message) {
108
88
  if (!message.properties.delegate) return;
109
89
  const content = message.content;
@@ -119,7 +99,8 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, messag
119
99
  } = message.properties;
120
100
  const executeContent = this[kExecuteMessage].content;
121
101
  this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
122
- message: { ...content.message
102
+ message: {
103
+ ...content.message
123
104
  }
124
105
  }), {
125
106
  correlationId,
@@ -127,10 +108,9 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, messag
127
108
  });
128
109
  return this._onApiMessage(routingKey, message);
129
110
  };
130
-
131
111
  proto._stop = function stop() {
132
112
  const broker = this.broker,
133
- executionId = this.executionId;
113
+ executionId = this.executionId;
134
114
  broker.cancel(`_api-${executionId}`);
135
115
  broker.cancel(`_api-delegated-${executionId}`);
136
116
  };
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Association;
7
-
8
7
  var _messageHelper = require("../messageHelper");
9
-
10
8
  var _EventBroker = require("../EventBroker");
11
-
12
9
  var _Api = require("../Api");
13
-
14
10
  var _shared = require("../shared");
15
-
16
11
  const kCounters = Symbol.for('counters');
17
-
18
12
  function Association(associationDef, {
19
13
  environment
20
14
  }) {
@@ -58,81 +52,64 @@ function Association(associationDef, {
58
52
  this.waitFor = waitFor;
59
53
  logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
60
54
  }
61
-
62
55
  const proto = Association.prototype;
63
56
  Object.defineProperty(proto, 'counters', {
64
57
  enumerable: true,
65
-
66
58
  get() {
67
- return { ...this[kCounters]
59
+ return {
60
+ ...this[kCounters]
68
61
  };
69
62
  }
70
-
71
63
  });
72
-
73
64
  proto.take = function take(content = {}) {
74
65
  this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
75
66
  ++this[kCounters].take;
76
-
77
67
  this._publishEvent('take', content);
78
-
79
68
  return true;
80
69
  };
81
-
82
70
  proto.discard = function discard(content = {}) {
83
71
  this.logger.debug(`<${this.id}> discard target <${this.targetId}>`);
84
72
  ++this[kCounters].discard;
85
-
86
73
  this._publishEvent('discard', content);
87
-
88
74
  return true;
89
75
  };
90
-
91
76
  proto.complete = function complete(content = {}) {
92
77
  this.logger.debug(`<${this.id}> completed target <${this.targetId}>`);
93
78
  ++this[kCounters].complete;
94
-
95
79
  this._publishEvent('complete', content);
96
-
97
80
  return true;
98
81
  };
99
-
100
82
  proto.getState = function getState() {
101
83
  return this._createMessageContent({
102
84
  counters: this.counters,
103
85
  broker: this.broker.getState(true)
104
86
  });
105
87
  };
106
-
107
88
  proto.recover = function recover(state) {
108
89
  Object.assign(this[kCounters], state.counters);
109
90
  this.broker.recover(state.broker);
110
91
  };
111
-
112
92
  proto.getApi = function getApi(message) {
113
93
  return (0, _Api.FlowApi)(this.broker, message || {
114
94
  content: this._createMessageContent()
115
95
  });
116
96
  };
117
-
118
97
  proto.stop = function stop() {
119
98
  this.broker.stop();
120
99
  };
121
-
122
100
  proto._publishEvent = function publishEvent(action, content) {
123
101
  const eventContent = this._createMessageContent({
124
102
  action,
125
103
  message: content,
126
104
  sequenceId: (0, _shared.getUniqueId)(this.id)
127
105
  });
128
-
129
106
  this.broker.publish('event', `association.${action}`, eventContent, {
130
107
  type: action
131
108
  });
132
109
  };
133
-
134
110
  proto._createMessageContent = function createMessageContent(override) {
135
- return { ...override,
111
+ return {
112
+ ...override,
136
113
  id: this.id,
137
114
  type: this.type,
138
115
  name: this.name,
@@ -4,16 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = MessageFlow;
7
-
8
7
  var _shared = require("../shared");
9
-
10
8
  var _messageHelper = require("../messageHelper");
11
-
12
9
  var _EventBroker = require("../EventBroker");
13
-
14
10
  const kCounters = Symbol.for('counters');
15
11
  const kSourceElement = Symbol.for('sourceElement');
16
-
17
12
  function MessageFlow(flowDef, context) {
18
13
  const {
19
14
  id,
@@ -51,18 +46,15 @@ function MessageFlow(flowDef, context) {
51
46
  this[kSourceElement] = context.getActivityById(source.id) || context.getProcessById(source.processId);
52
47
  this.logger = context.environment.Logger(type.toLowerCase());
53
48
  }
54
-
55
49
  const proto = MessageFlow.prototype;
56
50
  Object.defineProperty(proto, 'counters', {
57
51
  enumerable: true,
58
-
59
52
  get() {
60
- return { ...this[kCounters]
53
+ return {
54
+ ...this[kCounters]
61
55
  };
62
56
  }
63
-
64
57
  });
65
-
66
58
  proto.getState = function getState() {
67
59
  return {
68
60
  id: this.id,
@@ -70,15 +62,12 @@ proto.getState = function getState() {
70
62
  counters: this.counters
71
63
  };
72
64
  };
73
-
74
65
  proto.recover = function recover(state) {
75
66
  Object.assign(this[kCounters], state.counters);
76
67
  };
77
-
78
68
  proto.getApi = function getApi() {
79
69
  return this;
80
70
  };
81
-
82
71
  proto.activate = function activate() {
83
72
  const sourceElement = this[kSourceElement];
84
73
  const safeId = (0, _shared.brokerSafeId)(this.id);
@@ -89,14 +78,12 @@ proto.activate = function activate() {
89
78
  consumerTag: `_message-on-end-${safeId}`
90
79
  });
91
80
  };
92
-
93
81
  proto.deactivate = function deactivate() {
94
82
  const sourceElement = this[kSourceElement];
95
83
  const safeId = (0, _shared.brokerSafeId)(this.id);
96
84
  sourceElement.broker.cancel(`_message-on-end-${safeId}`);
97
85
  sourceElement.broker.cancel(`_message-on-message-${safeId}`);
98
86
  };
99
-
100
87
  proto._onSourceEnd = function onSourceEnd({
101
88
  content
102
89
  }) {
@@ -106,15 +93,16 @@ proto._onSourceEnd = function onSourceEnd({
106
93
  this.logger.debug(`<${this.id}> sending message from <${source.processId}.${source.id}> to <${target.id ? `${target.processId}.${target.id}` : target.processId}>`);
107
94
  this.broker.publish('event', 'message.outbound', this._createMessage(content.message));
108
95
  };
109
-
110
96
  proto._createMessage = function createMessage(message) {
111
97
  return {
112
98
  id: this.id,
113
99
  type: this.type,
114
100
  name: this.name,
115
- source: { ...this.source
101
+ source: {
102
+ ...this.source
116
103
  },
117
- target: { ...this.target
104
+ target: {
105
+ ...this.target
118
106
  },
119
107
  parent: (0, _messageHelper.cloneParent)(this.parent),
120
108
  message
@@ -4,23 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _ExecutionScope = _interopRequireDefault(require("../activity/ExecutionScope"));
9
-
10
8
  var _messageHelper = require("../messageHelper");
11
-
12
9
  var _shared = require("../shared");
13
-
14
10
  var _EventBroker = require("../EventBroker");
15
-
16
11
  var _Api = require("../Api");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  const kCounters = Symbol.for('counters');
21
14
  var _default = SequenceFlow;
22
15
  exports.default = _default;
23
-
24
16
  function SequenceFlow(flowDef, {
25
17
  environment
26
18
  }) {
@@ -69,18 +61,15 @@ function SequenceFlow(flowDef, {
69
61
  this.emitFatal = emitFatal;
70
62
  logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
71
63
  }
72
-
73
64
  const proto = SequenceFlow.prototype;
74
65
  Object.defineProperty(proto, 'counters', {
75
66
  enumerable: true,
76
-
77
67
  get() {
78
- return { ...this[kCounters]
68
+ return {
69
+ ...this[kCounters]
79
70
  };
80
71
  }
81
-
82
72
  });
83
-
84
73
  proto.take = function take(content = {}) {
85
74
  this.looped = undefined;
86
75
  const {
@@ -88,53 +77,42 @@ proto.take = function take(content = {}) {
88
77
  } = content;
89
78
  this.logger.debug(`<${sequenceId} (${this.id})> take, target <${this.targetId}>`);
90
79
  ++this[kCounters].take;
91
-
92
80
  this._publishEvent('take', content);
93
-
94
81
  return true;
95
82
  };
96
-
97
83
  proto.discard = function discard(content = {}) {
98
84
  const {
99
85
  sequenceId = (0, _shared.getUniqueId)(this.id)
100
86
  } = content;
101
87
  const discardSequence = content.discardSequence = (content.discardSequence || []).slice();
102
-
103
88
  if (discardSequence.indexOf(this.targetId) > -1) {
104
89
  ++this[kCounters].looped;
105
90
  this.logger.debug(`<${this.id}> discard loop detected <${this.sourceId}> -> <${this.targetId}>. Stop.`);
106
91
  return this._publishEvent('looped', content);
107
92
  }
108
-
109
93
  discardSequence.push(this.sourceId);
110
94
  this.logger.debug(`<${sequenceId} (${this.id})> discard, target <${this.targetId}>`);
111
95
  ++this[kCounters].discard;
112
-
113
96
  this._publishEvent('discard', content);
114
97
  };
115
-
116
98
  proto.getState = function getState() {
117
99
  return this.createMessage({
118
100
  counters: this.counters,
119
101
  broker: this.broker.getState(true)
120
102
  });
121
103
  };
122
-
123
104
  proto.recover = function recover(state) {
124
105
  Object.assign(this[kCounters], state.counters);
125
106
  this.broker.recover(state.broker);
126
107
  };
127
-
128
108
  proto.getApi = function getApi(message) {
129
109
  return (0, _Api.FlowApi)(this.broker, message || {
130
110
  content: this.createMessage()
131
111
  });
132
112
  };
133
-
134
113
  proto.stop = function stop() {
135
114
  this.broker.stop();
136
115
  };
137
-
138
116
  proto.shake = function shake(message) {
139
117
  const content = (0, _messageHelper.cloneContent)(message.content);
140
118
  content.sequence = content.sequence || [];
@@ -148,20 +126,17 @@ proto.shake = function shake(message) {
148
126
  persistent: false,
149
127
  type: 'shake'
150
128
  });
151
-
152
129
  for (const s of message.content.sequence) {
153
130
  if (s.id === this.id) return this.broker.publish('event', 'flow.shake.loop', content, {
154
131
  persistent: false,
155
132
  type: 'shake'
156
133
  });
157
134
  }
158
-
159
135
  this.broker.publish('event', 'flow.shake', content, {
160
136
  persistent: false,
161
137
  type: 'shake'
162
138
  });
163
139
  };
164
-
165
140
  proto.getCondition = function getCondition() {
166
141
  const conditionExpression = this.behaviour.conditionExpression;
167
142
  if (!conditionExpression) return null;
@@ -169,21 +144,18 @@ proto.getCondition = function getCondition() {
169
144
  language
170
145
  } = conditionExpression;
171
146
  const script = this.environment.getScript(language, this);
172
-
173
147
  if (script) {
174
148
  return new ScriptCondition(this, script, language);
175
149
  }
176
-
177
150
  if (!conditionExpression.body) {
178
151
  const msg = language ? `Condition expression script ${language} is unsupported or was not registered` : 'Condition expression without body is unsupported';
179
152
  return this.emitFatal(new Error(msg), this.createMessage());
180
153
  }
181
-
182
154
  return new ExpressionCondition(this, conditionExpression.body);
183
155
  };
184
-
185
156
  proto.createMessage = function createMessage(override) {
186
- return { ...override,
157
+ return {
158
+ ...override,
187
159
  id: this.id,
188
160
  type: this.type,
189
161
  name: this.name,
@@ -194,7 +166,6 @@ proto.createMessage = function createMessage(override) {
194
166
  parent: (0, _messageHelper.cloneParent)(this.parent)
195
167
  };
196
168
  };
197
-
198
169
  proto._publishEvent = function publishEvent(action, content) {
199
170
  const eventContent = this.createMessage({
200
171
  action,
@@ -204,17 +175,14 @@ proto._publishEvent = function publishEvent(action, content) {
204
175
  type: action
205
176
  });
206
177
  };
207
-
208
178
  function ScriptCondition(owner, script, language) {
209
179
  this.type = 'script';
210
180
  this.language = language;
211
181
  this._owner = owner;
212
182
  this._script = script;
213
183
  }
214
-
215
184
  ScriptCondition.prototype.execute = function execute(message, callback) {
216
185
  const owner = this._owner;
217
-
218
186
  try {
219
187
  return this._script.execute((0, _ExecutionScope.default)(owner, message), callback);
220
188
  } catch (err) {
@@ -223,16 +191,13 @@ ScriptCondition.prototype.execute = function execute(message, callback) {
223
191
  callback(err);
224
192
  }
225
193
  };
226
-
227
194
  function ExpressionCondition(owner, expression) {
228
195
  this.type = 'expression';
229
196
  this.expression = expression;
230
197
  this._owner = owner;
231
198
  }
232
-
233
199
  ExpressionCondition.prototype.execute = function execute(message, callback) {
234
200
  const owner = this._owner;
235
-
236
201
  try {
237
202
  const result = owner.environment.resolveExpression(this.expression, owner.createMessage(message));
238
203
  if (callback) return callback(null, result);
@@ -5,20 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.EventBasedGatewayBehaviour = EventBasedGatewayBehaviour;
7
7
  exports.default = EventBasedGateway;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _messageHelper = require("../messageHelper");
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  const kCompleted = Symbol.for('completed');
16
12
  const kTargets = Symbol.for('targets');
17
-
18
13
  function EventBasedGateway(activityDef, context) {
19
14
  return new _Activity.default(EventBasedGatewayBehaviour, activityDef, context);
20
15
  }
21
-
22
16
  function EventBasedGatewayBehaviour(activity, context) {
23
17
  this.id = activity.id;
24
18
  this.type = activity.type;
@@ -27,7 +21,6 @@ function EventBasedGatewayBehaviour(activity, context) {
27
21
  this.context = context;
28
22
  this[kTargets] = activity.outbound.map(flow => context.getActivityById(flow.targetId));
29
23
  }
30
-
31
24
  EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage) {
32
25
  const executeContent = executeMessage.content;
33
26
  const {
@@ -38,25 +31,20 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
38
31
  const targets = this[kTargets];
39
32
  this[kCompleted] = false;
40
33
  if (!targets.length) return this._complete(executeContent);
41
-
42
34
  for (const flow of this.activity.outbound) {
43
35
  outbound.push({
44
36
  id: flow.id,
45
37
  action: 'take'
46
38
  });
47
39
  }
48
-
49
40
  if (!this[kCompleted] && outboundTaken) return;
50
41
  const targetConsumerTag = `_gateway-listener-${this.id}`;
51
-
52
42
  const onTargetCompleted = this._onTargetCompleted.bind(this, executeMessage);
53
-
54
43
  for (const target of this[kTargets]) {
55
44
  target.broker.subscribeOnce('event', 'activity.end', onTargetCompleted, {
56
45
  consumerTag: targetConsumerTag
57
46
  });
58
47
  }
59
-
60
48
  const broker = this.activity.broker;
61
49
  broker.subscribeOnce('api', `activity.stop.${executionId}`, () => this._stop(), {
62
50
  noAck: true,
@@ -67,7 +55,6 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
67
55
  outboundTaken: true
68
56
  }));
69
57
  };
70
-
71
58
  EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompleted(executeMessage, _, message, owner) {
72
59
  const {
73
60
  id: targetId,
@@ -76,14 +63,11 @@ EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompl
76
63
  const executeContent = executeMessage.content;
77
64
  const executionId = executeContent.executionId;
78
65
  this.activity.logger.debug(`<${executionId} (${this.id})> <${targetExecutionId}> completed run, discarding the rest`);
79
-
80
66
  this._stop();
81
-
82
67
  for (const target of this[kTargets]) {
83
68
  if (target === owner) continue;
84
69
  target.discard();
85
70
  }
86
-
87
71
  const completedContent = (0, _messageHelper.cloneContent)(executeContent, {
88
72
  taken: {
89
73
  id: targetId,
@@ -91,19 +75,14 @@ EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompl
91
75
  },
92
76
  ignoreOutbound: true
93
77
  });
94
-
95
78
  this._complete(completedContent);
96
79
  };
97
-
98
80
  EventBasedGatewayBehaviour.prototype._complete = function complete(completedContent) {
99
81
  this[kCompleted] = true;
100
82
  this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(completedContent));
101
83
  };
102
-
103
84
  EventBasedGatewayBehaviour.prototype._stop = function stop() {
104
85
  const targetConsumerTag = `_gateway-listener-${this.id}`;
105
-
106
86
  for (const target of this[kTargets]) target.broker.cancel(targetConsumerTag);
107
-
108
87
  this.broker.cancel('_api-stop-execution');
109
88
  };
@@ -5,17 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ExclusiveGatewayBehaviour = ExclusiveGatewayBehaviour;
7
7
  exports.default = ExclusiveGateway;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _messageHelper = require("../messageHelper");
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  function ExclusiveGateway(activityDef, context) {
16
12
  return new _Activity.default(ExclusiveGatewayBehaviour, activityDef, context);
17
13
  }
18
-
19
14
  function ExclusiveGatewayBehaviour(activity) {
20
15
  const {
21
16
  id,
@@ -26,7 +21,6 @@ function ExclusiveGatewayBehaviour(activity) {
26
21
  this.type = type;
27
22
  this.broker = broker;
28
23
  }
29
-
30
24
  ExclusiveGatewayBehaviour.prototype.execute = function execute({
31
25
  content
32
26
  }) {
@@ -5,17 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.InclusiveGatewayBehaviour = InclusiveGatewayBehaviour;
7
7
  exports.default = InclusiveGateway;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _messageHelper = require("../messageHelper");
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  function InclusiveGateway(activityDef, context) {
16
12
  return new _Activity.default(InclusiveGatewayBehaviour, activityDef, context);
17
13
  }
18
-
19
14
  function InclusiveGatewayBehaviour(activity) {
20
15
  const {
21
16
  id,
@@ -26,7 +21,6 @@ function InclusiveGatewayBehaviour(activity) {
26
21
  this.type = type;
27
22
  this.broker = broker;
28
23
  }
29
-
30
24
  InclusiveGatewayBehaviour.prototype.execute = function execute({
31
25
  content
32
26
  }) {
@@ -5,19 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ParallelGatewayBehaviour = ParallelGatewayBehaviour;
7
7
  exports.default = ParallelGateway;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _messageHelper = require("../messageHelper");
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  function ParallelGateway(activityDef, context) {
16
- return new _Activity.default(ParallelGatewayBehaviour, { ...activityDef,
12
+ return new _Activity.default(ParallelGatewayBehaviour, {
13
+ ...activityDef,
17
14
  isParallelGateway: true
18
15
  }, context);
19
16
  }
20
-
21
17
  function ParallelGatewayBehaviour(activity) {
22
18
  const {
23
19
  id,
@@ -28,7 +24,6 @@ function ParallelGatewayBehaviour(activity) {
28
24
  this.type = type;
29
25
  this.broker = broker;
30
26
  }
31
-
32
27
  ParallelGatewayBehaviour.prototype.execute = function execute({
33
28
  content
34
29
  }) {