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,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = BpmnErrorActivity;
7
-
8
7
  function BpmnErrorActivity(errorDef, context) {
9
8
  const {
10
9
  id,
@@ -22,9 +21,9 @@ function BpmnErrorActivity(errorDef, context) {
22
21
  errorCode: behaviour.errorCode,
23
22
  resolve
24
23
  };
25
-
26
24
  function resolve(executionMessage, error) {
27
- const resolveCtx = { ...executionMessage,
25
+ const resolveCtx = {
26
+ ...executionMessage,
28
27
  error
29
28
  };
30
29
  const result = {
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.RunError = exports.BpmnError = exports.ActivityError = void 0;
7
7
  exports.makeErrorFromMessage = makeErrorFromMessage;
8
-
9
8
  var _messageHelper = require("../messageHelper");
10
-
11
9
  class ActivityError extends Error {
12
10
  constructor(description, sourceMessage, inner) {
13
11
  super(description);
@@ -17,22 +15,16 @@ class ActivityError extends Error {
17
15
  if (sourceMessage) this.source = (0, _messageHelper.cloneMessage)(sourceMessage, sourceMessage.content && sourceMessage.content.error && {
18
16
  error: undefined
19
17
  });
20
-
21
18
  if (inner) {
22
19
  this.inner = inner;
23
20
  if (inner.name) this.name = inner.name;
24
21
  if (inner.code) this.code = inner.code;
25
22
  }
26
23
  }
27
-
28
24
  }
29
-
30
25
  exports.ActivityError = ActivityError;
31
-
32
26
  class RunError extends ActivityError {}
33
-
34
27
  exports.RunError = RunError;
35
-
36
28
  class BpmnError extends Error {
37
29
  constructor(description, behaviour = {}, sourceMessage, inner) {
38
30
  const {
@@ -49,11 +41,8 @@ class BpmnError extends Error {
49
41
  });
50
42
  if (inner) this.inner = inner;
51
43
  }
52
-
53
44
  }
54
-
55
45
  exports.BpmnError = BpmnError;
56
-
57
46
  function makeErrorFromMessage(errorMessage) {
58
47
  const {
59
48
  content
@@ -64,27 +53,22 @@ function makeErrorFromMessage(errorMessage) {
64
53
  } = content;
65
54
  if (!error) return new Error(`Malformatted error message with routing key ${errorMessage.fields && errorMessage.fields.routingKey}`);
66
55
  if (isKnownError(error)) return error;
67
-
68
56
  switch (error.type) {
69
57
  case 'ActivityError':
70
58
  return new ActivityError(error.message || error.description, error.source, error.inner ? error.inner : {
71
59
  code: error.code,
72
60
  name: error.name
73
61
  });
74
-
75
62
  case 'RunError':
76
63
  return new RunError(error.message || error.description, error.source, error.inner ? error.inner : {
77
64
  code: error.code,
78
65
  name: error.name
79
66
  });
80
-
81
67
  case 'BpmnError':
82
68
  return new BpmnError(error.message || error.description, error, error.source);
83
69
  }
84
-
85
70
  return error;
86
71
  }
87
-
88
72
  function isKnownError(test) {
89
73
  if (test instanceof ActivityError) return test;
90
74
  if (test instanceof BpmnError) return test;
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = CancelEventDefinition;
7
-
8
7
  var _shared = require("../shared");
9
-
10
8
  var _messageHelper = require("../messageHelper");
11
-
12
9
  const kMessageQ = Symbol.for('cancelQ');
13
10
  const kCompleted = Symbol.for('completed');
14
11
  const kExecuteMessage = Symbol.for('executeMessage');
15
-
16
12
  function CancelEventDefinition(activity, eventDefinition) {
17
13
  const {
18
14
  id,
@@ -31,7 +27,6 @@ function CancelEventDefinition(activity, eventDefinition) {
31
27
  this.environment = environment;
32
28
  this.broker = broker;
33
29
  this.logger = environment.Logger(type.toLowerCase());
34
-
35
30
  if (!isThrowing) {
36
31
  this[kCompleted] = false;
37
32
  const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-q`;
@@ -45,20 +40,16 @@ function CancelEventDefinition(activity, eventDefinition) {
45
40
  });
46
41
  }
47
42
  }
48
-
49
43
  const proto = CancelEventDefinition.prototype;
50
44
  Object.defineProperty(proto, 'executionId', {
51
45
  get() {
52
46
  const message = this[kExecuteMessage];
53
47
  return message && message.content.executionId;
54
48
  }
55
-
56
49
  });
57
-
58
50
  proto.execute = function execute(executeMessage) {
59
51
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
60
52
  };
61
-
62
53
  proto.executeCatch = function executeCatch(executeMessage) {
63
54
  this[kExecuteMessage] = executeMessage;
64
55
  this[kCompleted] = false;
@@ -69,17 +60,13 @@ proto.executeCatch = function executeCatch(executeMessage) {
69
60
  } = executeContent;
70
61
  const parentExecutionId = parent.executionId;
71
62
  const broker = this.broker;
72
-
73
63
  const onCatchMessage = this._onCatchMessage.bind(this);
74
-
75
64
  this[kMessageQ].consume(onCatchMessage, {
76
65
  noAck: true,
77
66
  consumerTag: `_oncancel-${executionId}`
78
67
  });
79
68
  if (this[kCompleted]) return;
80
-
81
69
  const onApiMessage = this._onApiMessage.bind(this);
82
-
83
70
  broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
84
71
  noAck: true,
85
72
  consumerTag: `_api-parent-${executionId}`
@@ -88,9 +75,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
88
75
  noAck: true,
89
76
  consumerTag: `_api-${executionId}`
90
77
  });
91
-
92
78
  this._debug('expect cancel');
93
-
94
79
  const exchangeKey = `execute.canceled.${executionId}`;
95
80
  broker.subscribeOnce('execution', exchangeKey, onCatchMessage, {
96
81
  consumerTag: `_onattached-cancel-${executionId}`
@@ -101,7 +86,6 @@ proto.executeCatch = function executeCatch(executeMessage) {
101
86
  exchangeKey
102
87
  }));
103
88
  };
104
-
105
89
  proto.executeThrow = function executeThrow(executeMessage) {
106
90
  const {
107
91
  isTransaction
@@ -125,23 +109,17 @@ proto.executeThrow = function executeThrow(executeMessage) {
125
109
  });
126
110
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
127
111
  };
128
-
129
112
  proto._onCatchMessage = function onCatchMessage(_, message) {
130
113
  if (message.content && message.content.isTransaction) return this._onCancelTransaction(_, message);
131
-
132
114
  this._debug(`cancel caught from <${message.content.id}>`);
133
-
134
115
  return this._complete(message.content.message);
135
116
  };
136
-
137
117
  proto._onCancelTransaction = function onCancelTransaction(_, message) {
138
118
  const broker = this.broker,
139
- executionId = this.executionId;
119
+ executionId = this.executionId;
140
120
  const executeContent = this[kExecuteMessage].content;
141
121
  broker.cancel(`_oncancel-${executionId}`);
142
-
143
122
  this._debug(`cancel transaction thrown by <${message.content.id}>`);
144
-
145
123
  broker.assertExchange('cancel', 'topic');
146
124
  broker.publish('execution', 'execute.detach', (0, _messageHelper.cloneContent)(executeContent, {
147
125
  pattern: '#',
@@ -165,45 +143,35 @@ proto._onCancelTransaction = function onCancelTransaction(_, message) {
165
143
  consumerTag: `_oncancelend-${executionId}`
166
144
  });
167
145
  };
168
-
169
146
  proto._complete = function complete(output) {
170
147
  this[kCompleted] = true;
171
-
172
148
  this._stop();
173
-
174
149
  this._debug('completed');
175
-
176
150
  const content = (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
177
151
  output,
178
152
  state: 'cancel'
179
153
  });
180
154
  return this.broker.publish('execution', 'execute.completed', content);
181
155
  };
182
-
183
156
  proto._onApiMessage = function onApiMessage(routingKey, message) {
184
157
  switch (message.properties.type) {
185
158
  case 'discard':
186
159
  {
187
160
  this[kCompleted] = true;
188
-
189
161
  this._stop();
190
-
191
162
  const content = (0, _messageHelper.cloneContent)(this[kExecuteMessage].content);
192
163
  return this.broker.publish('execution', 'execute.discard', content);
193
164
  }
194
-
195
165
  case 'stop':
196
166
  {
197
167
  this._stop();
198
-
199
168
  break;
200
169
  }
201
170
  }
202
171
  };
203
-
204
172
  proto._stop = function stop() {
205
173
  const broker = this.broker,
206
- executionId = this.executionId;
174
+ executionId = this.executionId;
207
175
  broker.cancel(`_api-parent-${executionId}`);
208
176
  broker.cancel(`_api-${executionId}`);
209
177
  broker.cancel(`_oncancel-${executionId}`);
@@ -211,7 +179,6 @@ proto._stop = function stop() {
211
179
  broker.cancel(`_onattached-cancel-${executionId}`);
212
180
  this[kMessageQ].purge();
213
181
  };
214
-
215
182
  proto._debug = function debug(msg) {
216
183
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
217
184
  };
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = CompensateEventDefinition;
7
-
8
7
  var _shared = require("../shared");
9
-
10
8
  var _messageHelper = require("../messageHelper");
11
-
12
9
  const kCompleted = Symbol.for('completed');
13
10
  const kExecuteMessage = Symbol.for('executeMessage');
14
11
  const kMessageQ = Symbol.for('messageQ');
15
12
  const kCompensateQ = Symbol.for('compensateQ');
16
13
  const kAssociations = Symbol.for('associations');
17
-
18
14
  function CompensateEventDefinition(activity, eventDefinition, context) {
19
15
  const {
20
16
  id,
@@ -31,7 +27,6 @@ function CompensateEventDefinition(activity, eventDefinition, context) {
31
27
  this.activity = activity;
32
28
  this.broker = broker;
33
29
  this.logger = environment.Logger(type.toLowerCase());
34
-
35
30
  if (!isThrowing) {
36
31
  this[kCompleted] = false;
37
32
  this[kAssociations] = context.getOutboundAssociations(id) || [];
@@ -46,20 +41,16 @@ function CompensateEventDefinition(activity, eventDefinition, context) {
46
41
  });
47
42
  }
48
43
  }
49
-
50
44
  const proto = CompensateEventDefinition.prototype;
51
45
  Object.defineProperty(proto, 'executionId', {
52
46
  get() {
53
47
  const message = this[kExecuteMessage];
54
48
  return message && message.content.executionId;
55
49
  }
56
-
57
50
  });
58
-
59
51
  proto.execute = function execute(executeMessage) {
60
52
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
61
53
  };
62
-
63
54
  proto.executeCatch = function executeCatch(executeMessage) {
64
55
  this[kExecuteMessage] = executeMessage;
65
56
  this[kCompleted] = false;
@@ -68,9 +59,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
68
59
  executionId,
69
60
  parent
70
61
  } = executeContent;
71
-
72
62
  this._debug('expect compensate');
73
-
74
63
  const broker = this.broker;
75
64
  broker.assertExchange('compensate', 'topic');
76
65
  this[kCompensateQ] = broker.assertQueue('compensate-q', {
@@ -90,9 +79,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
90
79
  consumerTag: `_oncompensate-${executionId}`
91
80
  });
92
81
  if (this[kCompleted]) return;
93
-
94
82
  const onApiMessage = this._onApiMessage.bind(this);
95
-
96
83
  broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
97
84
  noAck: true,
98
85
  consumerTag: `_api-${executionId}`
@@ -104,7 +91,6 @@ proto.executeCatch = function executeCatch(executeMessage) {
104
91
  detachContent.parent = (0, _messageHelper.shiftParent)(parent);
105
92
  broker.publish('event', 'activity.detach', detachContent);
106
93
  };
107
-
108
94
  proto.executeThrow = function executeThrow(executeMessage) {
109
95
  const executeContent = executeMessage.content;
110
96
  const {
@@ -125,7 +111,6 @@ proto.executeThrow = function executeThrow(executeMessage) {
125
111
  });
126
112
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
127
113
  };
128
-
129
114
  proto._onCollect = function onCollect(routingKey, message) {
130
115
  switch (routingKey) {
131
116
  case 'execute.error':
@@ -135,19 +120,16 @@ proto._onCollect = function onCollect(routingKey, message) {
135
120
  }
136
121
  }
137
122
  };
138
-
139
123
  proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
140
124
  const output = message.content.message;
141
125
  this[kCompleted] = true;
142
-
143
126
  this._stop();
144
-
145
127
  this._debug('caught compensate event');
146
-
147
128
  const broker = this.broker;
148
129
  const executeContent = this[kExecuteMessage].content;
149
130
  const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
150
- message: { ...output
131
+ message: {
132
+ ...output
151
133
  },
152
134
  executionId: executeContent.parent.executionId
153
135
  });
@@ -161,9 +143,7 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
161
143
  noAck: true,
162
144
  consumerTag: '_convey-messages'
163
145
  });
164
-
165
146
  for (const association of this[kAssociations]) association.complete((0, _messageHelper.cloneMessage)(message));
166
-
167
147
  function onDepleted() {
168
148
  compensateQ.off('depleted', onDepleted);
169
149
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
@@ -172,50 +152,39 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
172
152
  }));
173
153
  }
174
154
  };
175
-
176
155
  proto._onCollected = function onCollected(routingKey, message) {
177
156
  for (const association of this[kAssociations]) association.take((0, _messageHelper.cloneMessage)(message));
178
157
  };
179
-
180
158
  proto._onApiMessage = function onApiMessage(routingKey, message) {
181
159
  const messageType = message.properties.type;
182
-
183
160
  switch (messageType) {
184
161
  case 'compensate':
185
162
  {
186
163
  return this._onCompensateApiMessage(routingKey, message);
187
164
  }
188
-
189
165
  case 'discard':
190
166
  {
191
167
  this[kCompleted] = true;
192
-
193
168
  this._stop();
194
-
195
169
  for (const association of this[kAssociations]) association.discard((0, _messageHelper.cloneMessage)(message));
196
-
197
170
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
198
171
  }
199
-
200
172
  case 'stop':
201
173
  {
202
174
  this._stop();
203
-
204
175
  break;
205
176
  }
206
177
  }
207
178
  };
208
-
209
179
  proto._stop = function stop() {
210
180
  const broker = this.broker,
211
- executionId = this.executionId;
181
+ executionId = this.executionId;
212
182
  broker.cancel(`_api-${executionId}`);
213
183
  broker.cancel(`_oncompensate-${executionId}`);
214
184
  broker.cancel('_oncollect-messages');
215
185
  broker.cancel('_convey-messages');
216
186
  this[kMessageQ].purge();
217
187
  };
218
-
219
188
  proto._debug = function debug(msg) {
220
189
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
221
190
  };
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ConditionalEventDefinition;
7
-
8
7
  var _messageHelper = require("../messageHelper");
9
-
10
8
  var _Errors = require("../error/Errors");
11
-
12
9
  const kExecuteMessage = Symbol.for('executeMessage');
13
-
14
10
  function ConditionalEventDefinition(activity, eventDefinition) {
15
11
  const {
16
12
  id,
@@ -31,21 +27,17 @@ function ConditionalEventDefinition(activity, eventDefinition) {
31
27
  this.broker = broker;
32
28
  this.logger = environment.Logger(type.toLowerCase());
33
29
  }
34
-
35
30
  const proto = ConditionalEventDefinition.prototype;
36
31
  Object.defineProperty(proto, 'executionId', {
37
32
  get() {
38
33
  const message = this[kExecuteMessage];
39
34
  return message && message.content.executionId;
40
35
  }
41
-
42
36
  });
43
-
44
37
  proto.execute = function execute(executeMessage) {
45
38
  this[kExecuteMessage] = executeMessage;
46
39
  return this.isWaiting ? this.executeWait(executeMessage) : this.executeCatch(executeMessage);
47
40
  };
48
-
49
41
  proto.executeWait = function executeWait(executeMessage) {
50
42
  const executeContent = executeMessage.content;
51
43
  const {
@@ -55,9 +47,7 @@ proto.executeWait = function executeWait(executeMessage) {
55
47
  const parentExecutionId = parent.executionId;
56
48
  if (this._evaluateWait(executeMessage)) return;
57
49
  const broker = this.broker;
58
-
59
50
  const onApiMessage = this._onWaitApiMessage.bind(this);
60
-
61
51
  broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
62
52
  noAck: true,
63
53
  consumerTag: `_api-${executionId}`
@@ -73,7 +63,6 @@ proto.executeWait = function executeWait(executeMessage) {
73
63
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
74
64
  broker.publish('event', 'activity.wait', waitContent);
75
65
  };
76
-
77
66
  proto.executeCatch = function executeCatch(executeMessage) {
78
67
  const executeContent = executeMessage.content;
79
68
  const {
@@ -88,45 +77,36 @@ proto.executeCatch = function executeCatch(executeMessage) {
88
77
  id: attachedToId,
89
78
  broker: attachedToBroker
90
79
  } = this.activity.attachedTo;
91
-
92
80
  this._debug(`listen for execute completed from <${attachedToId}>`);
93
-
94
81
  attachedToBroker.subscribeOnce('execution', 'execute.completed', this._onAttachedCompleted.bind(this), {
95
82
  priority: 300,
96
83
  consumerTag: `_onend-${executionId}_${index}`
97
84
  });
98
85
  };
99
-
100
86
  proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
101
87
  const messageType = message.properties.type;
102
-
103
88
  switch (messageType) {
104
89
  case 'signal':
105
90
  {
106
91
  return this._evaluateWait(message);
107
92
  }
108
-
109
93
  case 'discard':
110
94
  {
111
95
  this._stopWait();
112
-
113
96
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
114
97
  state: 'discard'
115
98
  }));
116
99
  }
117
-
118
100
  case 'stop':
119
101
  {
120
102
  return this._stopWait();
121
103
  }
122
104
  }
123
105
  };
124
-
125
106
  proto._evaluateWait = function evaluate(message) {
126
107
  const executeMessage = this[kExecuteMessage];
127
108
  const broker = this.broker,
128
- executeContent = executeMessage.content;
129
-
109
+ executeContent = executeMessage.content;
130
110
  try {
131
111
  var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
132
112
  } catch (err) {
@@ -136,35 +116,27 @@ proto._evaluateWait = function evaluate(message) {
136
116
  mandatory: true
137
117
  }));
138
118
  }
139
-
140
119
  this._debug(`condition evaluated to ${!!output}`);
141
-
142
120
  broker.publish('event', 'activity.condition', (0, _messageHelper.cloneContent)(executeContent, {
143
121
  conditionResult: output
144
122
  }));
145
123
  if (!output) return;
146
-
147
124
  this._stopWait();
148
-
149
125
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
150
126
  output
151
127
  }));
152
128
  };
153
-
154
129
  proto._stopWait = function stopWait() {
155
130
  const broker = this.broker,
156
- executionId = this.executionId;
131
+ executionId = this.executionId;
157
132
  broker.cancel(`_api-${executionId}`);
158
133
  broker.cancel(`_parent-signal-${executionId}`);
159
134
  };
160
-
161
135
  proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
162
136
  this._stopCatch();
163
-
164
137
  const executeMessage = this[kExecuteMessage];
165
138
  const broker = this.broker,
166
- executeContent = executeMessage.content;
167
-
139
+ executeContent = executeMessage.content;
168
140
  try {
169
141
  var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
170
142
  } catch (err) {
@@ -174,44 +146,34 @@ proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
174
146
  mandatory: true
175
147
  }));
176
148
  }
177
-
178
149
  this._debug(`condition from <${message.content.executionId}> evaluated to ${!!output}`);
179
-
180
150
  broker.publish('event', 'activity.condition', (0, _messageHelper.cloneContent)(executeContent, {
181
151
  conditionResult: output
182
152
  }));
183
-
184
153
  if (output) {
185
154
  broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
186
155
  output
187
156
  }));
188
157
  }
189
158
  };
190
-
191
159
  proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
192
160
  const messageType = message.properties.type;
193
-
194
161
  switch (messageType) {
195
162
  case 'discard':
196
163
  {
197
164
  this._stopCatch();
198
-
199
165
  this._debug('discarded');
200
-
201
166
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
202
167
  state: 'discard'
203
168
  }));
204
169
  }
205
-
206
170
  case 'stop':
207
171
  {
208
172
  this._stopCatch();
209
-
210
173
  return this._debug('stopped');
211
174
  }
212
175
  }
213
176
  };
214
-
215
177
  proto._stopCatch = function stopCatch() {
216
178
  const {
217
179
  executionId,
@@ -220,7 +182,6 @@ proto._stopCatch = function stopCatch() {
220
182
  this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
221
183
  this.broker.cancel(`_api-${executionId}_${index}`);
222
184
  };
223
-
224
185
  proto._debug = function debug(msg) {
225
186
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
226
187
  };