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,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ErrorEventDefinition;
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 kMessageQ = Symbol.for('messageQ');
14
11
  const kExecuteMessage = Symbol.for('executeMessage');
15
12
  const kReferenceElement = Symbol.for('referenceElement');
16
13
  const kReferenceInfo = Symbol.for('referenceInfo');
17
-
18
14
  function ErrorEventDefinition(activity, eventDefinition) {
19
15
  const {
20
16
  id,
@@ -39,7 +35,6 @@ function ErrorEventDefinition(activity, eventDefinition) {
39
35
  this.broker = broker;
40
36
  this.logger = environment.Logger(type.toLowerCase());
41
37
  const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
42
-
43
38
  if (!isThrowing) {
44
39
  this[kCompleted] = false;
45
40
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
@@ -54,20 +49,16 @@ function ErrorEventDefinition(activity, eventDefinition) {
54
49
  });
55
50
  }
56
51
  }
57
-
58
52
  const proto = ErrorEventDefinition.prototype;
59
53
  Object.defineProperty(proto, 'executionId', {
60
54
  get() {
61
55
  const message = this[kExecuteMessage];
62
56
  return message && message.content.executionId;
63
57
  }
64
-
65
58
  });
66
-
67
59
  proto.execute = function execute(executeMessage) {
68
60
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
69
61
  };
70
-
71
62
  proto.executeCatch = function executeCatch(executeMessage) {
72
63
  this[kExecuteMessage] = executeMessage;
73
64
  this[kCompleted] = false;
@@ -77,23 +68,18 @@ proto.executeCatch = function executeCatch(executeMessage) {
77
68
  parent
78
69
  } = executeContent;
79
70
  const parentExecutionId = parent && parent.executionId;
80
-
81
71
  const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
82
-
83
72
  this[kMessageQ].consume(this._onThrowApiMessage.bind(this), {
84
73
  noAck: true,
85
74
  consumerTag: `_onthrow-${executionId}`
86
75
  });
87
76
  if (this[kCompleted]) return;
88
-
89
77
  this._debug(`expect ${info.description}`);
90
-
91
78
  const broker = this.broker;
92
79
  broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
93
80
  noAck: true,
94
81
  consumerTag: `_api-${executionId}`
95
82
  });
96
-
97
83
  if (!this.environment.settings.strict) {
98
84
  const expectRoutingKey = `execute.throw.${executionId}`;
99
85
  broker.subscribeTmp('execution', expectRoutingKey, this._onErrorMessage.bind(this), {
@@ -102,35 +88,34 @@ proto.executeCatch = function executeCatch(executeMessage) {
102
88
  });
103
89
  broker.publish('execution', 'execute.expect', (0, _messageHelper.cloneContent)(executeContent, {
104
90
  expectRoutingKey,
105
- expect: { ...info.message
91
+ expect: {
92
+ ...info.message
106
93
  }
107
94
  }));
108
95
  if (this[kCompleted]) return this._stop();
109
96
  }
110
-
111
97
  const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
112
98
  executionId: parentExecutionId,
113
- expect: { ...info.message
99
+ expect: {
100
+ ...info.message
114
101
  }
115
102
  });
116
103
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
117
104
  broker.publish('event', 'activity.wait', waitContent);
118
105
  };
119
-
120
106
  proto.executeThrow = function executeThrow(executeMessage) {
121
107
  const executeContent = executeMessage.content;
122
108
  const {
123
109
  executionId,
124
110
  parent
125
111
  } = executeContent;
126
-
127
112
  const info = this._getReferenceInfo(executeMessage);
128
-
129
113
  this.logger.debug(`<${executionId} (${this.activity.id})> throw ${info.description}`);
130
114
  const broker = this.broker;
131
115
  const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
132
116
  executionId: parent.executionId,
133
- message: { ...info.message
117
+ message: {
118
+ ...info.message
134
119
  },
135
120
  state: 'throw'
136
121
  });
@@ -140,11 +125,11 @@ proto.executeThrow = function executeThrow(executeMessage) {
140
125
  delegate: true
141
126
  });
142
127
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
143
- message: { ...info.message
128
+ message: {
129
+ ...info.message
144
130
  }
145
131
  }));
146
132
  };
147
-
148
133
  proto._onErrorMessage = function onErrorMessage(routingKey, message) {
149
134
  const error = message.content.error;
150
135
  if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
@@ -153,7 +138,6 @@ proto._onErrorMessage = function onErrorMessage(routingKey, message) {
153
138
  if ('' + error.code !== '' + info.message.code) return;
154
139
  return this._catchError(routingKey, message, error);
155
140
  };
156
-
157
141
  proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
158
142
  const error = message.content.message;
159
143
  if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
@@ -161,14 +145,10 @@ proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
161
145
  if (info.message.id !== (error && error.id)) return;
162
146
  return this._catchError(routingKey, message, error);
163
147
  };
164
-
165
148
  proto._catchError = function catchError(routingKey, message, error) {
166
149
  this[kCompleted] = true;
167
-
168
150
  this._stop();
169
-
170
151
  this._debug(`caught ${this[kReferenceInfo].description}`);
171
-
172
152
  const executeContent = this[kExecuteMessage].content;
173
153
  const parent = executeContent.parent;
174
154
  const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
@@ -191,49 +171,40 @@ proto._catchError = function catchError(routingKey, message, error) {
191
171
  state: 'catch'
192
172
  }));
193
173
  };
194
-
195
174
  proto._onApiMessage = function onApiMessage(routingKey, message) {
196
175
  const messageType = message.properties.type;
197
-
198
176
  switch (messageType) {
199
177
  case 'discard':
200
178
  {
201
179
  this[kCompleted] = true;
202
-
203
180
  this._stop();
204
-
205
181
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
206
182
  }
207
-
208
183
  case 'stop':
209
184
  {
210
185
  this._stop();
211
-
212
186
  break;
213
187
  }
214
188
  }
215
189
  };
216
-
217
190
  proto._stop = function stop() {
218
191
  const broker = this.broker,
219
- executionId = this.executionId;
192
+ executionId = this.executionId;
220
193
  broker.cancel(`_onthrow-${executionId}`);
221
194
  broker.cancel(`_onerror-${executionId}`);
222
195
  broker.cancel(`_api-${executionId}`);
223
196
  this[kMessageQ].purge();
224
197
  };
225
-
226
198
  proto._getReferenceInfo = function getReferenceInfo(message) {
227
199
  const referenceElement = this[kReferenceElement];
228
-
229
200
  if (!referenceElement) {
230
201
  return {
231
- message: { ...this.reference
202
+ message: {
203
+ ...this.reference
232
204
  },
233
205
  description: 'anonymous error'
234
206
  };
235
207
  }
236
-
237
208
  const result = {
238
209
  message: referenceElement.resolve(message)
239
210
  };
@@ -241,7 +212,6 @@ proto._getReferenceInfo = function getReferenceInfo(message) {
241
212
  if (result.message.code) result.description += ` code ${result.message.code}`;
242
213
  return result;
243
214
  };
244
-
245
215
  proto._debug = function debug(msg) {
246
216
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
247
217
  };
@@ -4,21 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EscalationEventDefinition;
7
-
8
7
  var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
9
-
10
8
  var _shared = require("../shared");
11
-
12
9
  var _messageHelper = require("../messageHelper");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  const kCompleted = Symbol.for('completed');
17
12
  const kMessageQ = Symbol.for('messageQ');
18
13
  const kExecuteMessage = Symbol.for('executeMessage');
19
14
  const kReferenceElement = Symbol.for('referenceElement');
20
15
  const kReference = Symbol.for('reference');
21
-
22
16
  function EscalationEventDefinition(activity, eventDefinition) {
23
17
  const {
24
18
  id,
@@ -42,7 +36,6 @@ function EscalationEventDefinition(activity, eventDefinition) {
42
36
  this.broker = broker;
43
37
  this.logger = environment.Logger(type.toLowerCase());
44
38
  const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
45
-
46
39
  if (!isThrowing) {
47
40
  this[kCompleted] = false;
48
41
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
@@ -57,20 +50,16 @@ function EscalationEventDefinition(activity, eventDefinition) {
57
50
  });
58
51
  }
59
52
  }
60
-
61
53
  const proto = EscalationEventDefinition.prototype;
62
54
  Object.defineProperty(proto, 'executionId', {
63
55
  get() {
64
56
  const message = this[kExecuteMessage];
65
57
  return message && message.content.executionId;
66
58
  }
67
-
68
59
  });
69
-
70
60
  proto.execute = function execute(executeMessage) {
71
61
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
72
62
  };
73
-
74
63
  proto.executeCatch = function executeCatch(executeMessage) {
75
64
  this[kExecuteMessage] = executeMessage;
76
65
  this[kCompleted] = false;
@@ -79,9 +68,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
79
68
  executionId,
80
69
  parent
81
70
  } = executeContent;
82
-
83
71
  const info = this[kReference] = this._getReferenceInfo(executeMessage);
84
-
85
72
  const broker = this.broker;
86
73
  this[kMessageQ].consume(this._onCatchMessage.bind(this), {
87
74
  noAck: true,
@@ -92,28 +79,24 @@ proto.executeCatch = function executeCatch(executeMessage) {
92
79
  noAck: true,
93
80
  consumerTag: `_api-${executionId}`
94
81
  });
95
-
96
82
  this._debug(`expect ${info.description}`);
97
-
98
83
  const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
99
84
  executionId: parent.executionId,
100
85
  parent: (0, _messageHelper.shiftParent)(parent),
101
- escalation: { ...info.message
86
+ escalation: {
87
+ ...info.message
102
88
  }
103
89
  });
104
90
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
105
91
  broker.publish('event', 'activity.wait', waitContent);
106
92
  };
107
-
108
93
  proto.executeThrow = function executeThrow(executeMessage) {
109
94
  const executeContent = executeMessage.content;
110
95
  const {
111
96
  executionId,
112
97
  parent
113
98
  } = executeContent;
114
-
115
99
  const info = this._getReferenceInfo(executeMessage);
116
-
117
100
  this.logger.debug(`<${executionId} (${this.activity.id})> escalate ${info.description}`);
118
101
  const broker = this.broker;
119
102
  const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
@@ -128,24 +111,21 @@ proto.executeThrow = function executeThrow(executeMessage) {
128
111
  });
129
112
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
130
113
  };
131
-
132
114
  proto._onCatchMessage = function onCatchMessage(routingKey, message) {
133
115
  const info = this[kReference];
134
116
  if ((0, _getPropertyValue.default)(message, 'content.message.id') !== info.message.id) return;
135
117
  const output = message.content.message;
136
118
  this[kCompleted] = true;
137
-
138
119
  this._stop();
139
-
140
120
  this._debug(`caught ${info.description}`);
141
-
142
121
  const executeContent = this[kExecuteMessage].content;
143
122
  const {
144
123
  parent,
145
124
  ...content
146
125
  } = executeContent;
147
126
  const catchContent = (0, _messageHelper.cloneContent)(content, {
148
- message: { ...output
127
+ message: {
128
+ ...output
149
129
  },
150
130
  executionId: parent.executionId
151
131
  });
@@ -159,57 +139,47 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
159
139
  state: 'catch'
160
140
  }));
161
141
  };
162
-
163
142
  proto._onApiMessage = function onApiMessage(routingKey, message) {
164
143
  switch (message.properties.type) {
165
144
  case 'escalate':
166
145
  {
167
146
  return this._onCatchMessage(routingKey, message);
168
147
  }
169
-
170
148
  case 'discard':
171
149
  {
172
150
  this[kCompleted] = true;
173
-
174
151
  this._stop();
175
-
176
152
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
177
153
  }
178
-
179
154
  case 'stop':
180
155
  {
181
156
  this._stop();
182
-
183
157
  break;
184
158
  }
185
159
  }
186
160
  };
187
-
188
161
  proto._stop = function stop() {
189
162
  const broker = this.broker,
190
- executionId = this.executionId;
163
+ executionId = this.executionId;
191
164
  broker.cancel(`_api-${executionId}`);
192
165
  broker.cancel(`_onescalate-${executionId}`);
193
166
  };
194
-
195
167
  proto._getReferenceInfo = function getReferenceInfo(message) {
196
168
  const referenceElement = this[kReferenceElement];
197
-
198
169
  if (!referenceElement) {
199
170
  return {
200
- message: { ...this.reference
171
+ message: {
172
+ ...this.reference
201
173
  },
202
174
  description: 'anonymous escalation'
203
175
  };
204
176
  }
205
-
206
177
  const result = {
207
178
  message: referenceElement.resolve(message)
208
179
  };
209
180
  result.description = `${result.message.name} <${result.message.id}>`;
210
181
  return result;
211
182
  };
212
-
213
183
  proto._debug = function debug(msg) {
214
184
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
215
185
  };
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EventDefinitionExecution;
7
-
8
7
  var _messageHelper = require("../messageHelper");
9
-
10
8
  const kCompleted = Symbol.for('completed');
11
9
  const kExecuteMessage = Symbol.for('executeMessage');
12
10
  const kStopped = Symbol.for('stopped');
13
-
14
11
  function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKey = 'execute.completed') {
15
12
  this.id = activity.id;
16
13
  this.activity = activity;
@@ -21,25 +18,19 @@ function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKe
21
18
  this[kStopped] = false;
22
19
  this[kExecuteMessage] = null;
23
20
  }
24
-
25
21
  const proto = EventDefinitionExecution.prototype;
26
22
  Object.defineProperty(proto, 'completed', {
27
23
  enumerable: true,
28
-
29
24
  get() {
30
25
  return this[kCompleted];
31
26
  }
32
-
33
27
  });
34
28
  Object.defineProperty(proto, 'stopped', {
35
29
  enumerable: true,
36
-
37
30
  get() {
38
31
  return this[kStopped];
39
32
  }
40
-
41
33
  });
42
-
43
34
  proto.execute = function execute(executeMessage) {
44
35
  const content = executeMessage.content;
45
36
  if (content.isDefinitionScope) return this._executeDefinition(executeMessage);
@@ -63,15 +54,12 @@ proto.execute = function execute(executeMessage) {
63
54
  if (executeMessage.fields.redelivered) return;
64
55
  const parent = (0, _messageHelper.unshiftParent)(content.parent, content);
65
56
  const eventDefinitions = this.eventDefinitions;
66
-
67
57
  for (let index = 0; index < eventDefinitions.length; ++index) {
68
58
  if (this[kCompleted]) break;
69
59
  if (this[kStopped]) break;
70
60
  const ed = eventDefinitions[index];
71
61
  const edExecutionId = `${executionId}_${index}`;
72
-
73
62
  this._debug(executionId, `start event definition ${ed.type}, index ${index}`);
74
-
75
63
  const edContent = (0, _messageHelper.cloneContent)(content, {
76
64
  isRootScope: undefined,
77
65
  type: ed.type,
@@ -83,49 +71,38 @@ proto.execute = function execute(executeMessage) {
83
71
  broker.publish('execution', 'execute.start', edContent);
84
72
  }
85
73
  };
86
-
87
74
  proto._onApiMessage = function onApiMessage(_, message) {
88
75
  const messageType = message.properties.type;
89
-
90
76
  switch (messageType) {
91
77
  case 'stop':
92
78
  case 'discard':
93
79
  return this._stop();
94
80
  }
95
81
  };
96
-
97
82
  proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
98
83
  switch (routingKey) {
99
84
  case 'execute.completed':
100
85
  {
101
86
  this._stop();
102
-
103
87
  if (message.content.isDefinitionScope) return this._complete(message);
104
88
  break;
105
89
  }
106
-
107
90
  case 'execute.discard':
108
91
  {
109
92
  const {
110
93
  executionId,
111
94
  isDefinitionScope
112
95
  } = message.content;
113
-
114
96
  if (isDefinitionScope) {
115
97
  this._debug(executionId, `event definition ${message.content.type} discarded, index ${message.content.index}`);
116
-
117
98
  break;
118
99
  }
119
-
120
100
  this._stop();
121
-
122
101
  this._debug(executionId, 'event definition parent execution discarded');
123
-
124
102
  break;
125
103
  }
126
104
  }
127
105
  };
128
-
129
106
  proto._complete = function complete(message) {
130
107
  const {
131
108
  executionId,
@@ -134,9 +111,7 @@ proto._complete = function complete(message) {
134
111
  parent
135
112
  } = message.content;
136
113
  this[kCompleted] = true;
137
-
138
114
  this._debug(executionId, `event definition ${type} completed, index ${index}`);
139
-
140
115
  const completeContent = (0, _messageHelper.cloneContent)(message.content, {
141
116
  executionId: this[kExecuteMessage].content.executionId,
142
117
  isRootScope: true
@@ -146,7 +121,6 @@ proto._complete = function complete(message) {
146
121
  correlationId: message.properties.correlationId
147
122
  });
148
123
  };
149
-
150
124
  proto._executeDefinition = function executeDefinition(message) {
151
125
  const {
152
126
  executionId,
@@ -154,18 +128,14 @@ proto._executeDefinition = function executeDefinition(message) {
154
128
  } = message.content;
155
129
  const ed = this.eventDefinitions[index];
156
130
  if (!ed) return this.activity.logger.warn(`<${executionId} (${this.id})> found no event definition on index ${index}`);
157
-
158
131
  this._debug(executionId, `execute event definition ${ed.type}, index ${index}`);
159
-
160
132
  ed.execute(message);
161
133
  };
162
-
163
134
  proto._stop = function stop() {
164
135
  this[kStopped] = true;
165
136
  this.broker.cancel('_eventdefinition-execution-execute-tag');
166
137
  this.broker.cancel('_eventdefinition-execution-api-tag');
167
138
  };
168
-
169
139
  proto._debug = function debug(executionId, msg) {
170
140
  this.activity.logger.debug(`<${executionId} (${this.id})> ${msg}`);
171
141
  };
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = LinkEventDefinition;
7
-
8
7
  var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
9
-
10
8
  var _shared = require("../shared");
11
-
12
9
  var _messageHelper = require("../messageHelper");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  const kCompleted = Symbol.for('completed');
17
12
  const kMessageQ = Symbol.for('messageQ');
18
13
  const kExecuteMessage = Symbol.for('executeMessage');
19
-
20
14
  function LinkEventDefinition(activity, eventDefinition) {
21
15
  const {
22
16
  id,
@@ -39,7 +33,6 @@ function LinkEventDefinition(activity, eventDefinition) {
39
33
  this.broker = broker;
40
34
  this.logger = environment.Logger(type.toLowerCase());
41
35
  this[kCompleted] = false;
42
-
43
36
  if (!isThrowing) {
44
37
  const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
45
38
  this[kMessageQ] = broker.assertQueue(messageQueueName, {
@@ -56,20 +49,16 @@ function LinkEventDefinition(activity, eventDefinition) {
56
49
  });
57
50
  }
58
51
  }
59
-
60
52
  const proto = LinkEventDefinition.prototype;
61
53
  Object.defineProperty(proto, 'executionId', {
62
54
  get() {
63
55
  const message = this[kExecuteMessage];
64
56
  return message && message.content.executionId;
65
57
  }
66
-
67
58
  });
68
-
69
59
  proto.execute = function execute(executeMessage) {
70
60
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
71
61
  };
72
-
73
62
  proto.executeCatch = function executeCatch(executeMessage) {
74
63
  this[kExecuteMessage] = executeMessage;
75
64
  this[kCompleted] = false;
@@ -85,9 +74,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
85
74
  });
86
75
  if (this[kCompleted]) return;
87
76
  const broker = this.broker;
88
-
89
77
  const onApiMessage = this._onApiMessage.bind(this);
90
-
91
78
  broker.subscribeTmp('api', `activity.stop.${parentExecutionId}`, onApiMessage, {
92
79
  noAck: true,
93
80
  consumerTag: `_api-parent-${executionId}`
@@ -96,18 +83,16 @@ proto.executeCatch = function executeCatch(executeMessage) {
96
83
  noAck: true,
97
84
  consumerTag: `_api-${executionId}`
98
85
  });
99
-
100
86
  this._debug(`expect link ${this.reference.linkName}`);
101
-
102
87
  const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
103
88
  executionId: parentExecutionId,
104
- link: { ...this.reference
89
+ link: {
90
+ ...this.reference
105
91
  }
106
92
  });
107
93
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
108
94
  broker.publish('event', 'activity.wait', waitContent);
109
95
  };
110
-
111
96
  proto.executeThrow = function executeThrow(executeMessage) {
112
97
  const executeContent = executeMessage.content;
113
98
  const {
@@ -119,7 +104,8 @@ proto.executeThrow = function executeThrow(executeMessage) {
119
104
  const broker = this.broker;
120
105
  const linkContent = (0, _messageHelper.cloneContent)(executeContent, {
121
106
  executionId: parentExecutionId,
122
- message: { ...this.reference
107
+ message: {
108
+ ...this.reference
123
109
  },
124
110
  state: 'throw'
125
111
  });
@@ -130,44 +116,37 @@ proto.executeThrow = function executeThrow(executeMessage) {
130
116
  });
131
117
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
132
118
  };
133
-
134
119
  proto._onCatchLink = function onCatchLink(routingKey, message) {
135
120
  if ((0, _getPropertyValue.default)(message, 'content.message.linkName') !== this.reference.linkName) return;
136
121
  if (message.content.state === 'discard') return this._discard();
137
122
  return this._complete('caught', message.content.message);
138
123
  };
139
-
140
124
  proto._onApiMessage = function onApiMessage(routingKey, message) {
141
125
  const messageType = message.properties.type;
142
-
143
126
  switch (messageType) {
144
127
  case 'discard':
145
128
  {
146
129
  return this._discard();
147
130
  }
148
-
149
131
  case 'stop':
150
132
  {
151
133
  this._stop();
152
-
153
134
  break;
154
135
  }
155
136
  }
156
137
  };
157
-
158
138
  proto._complete = function complete(verb, output) {
159
139
  this[kCompleted] = true;
160
-
161
140
  this._stop();
162
-
163
141
  this._debug(`${verb} link ${this.reference.linkName}`);
164
-
165
142
  const executeContent = this[kExecuteMessage].content;
166
143
  const parent = executeContent.parent;
167
144
  const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
168
- link: { ...this.reference
145
+ link: {
146
+ ...this.reference
169
147
  },
170
- message: { ...output
148
+ message: {
149
+ ...output
171
150
  },
172
151
  executionId: parent.executionId
173
152
  });
@@ -181,27 +160,23 @@ proto._complete = function complete(verb, output) {
181
160
  state: 'catch'
182
161
  }));
183
162
  };
184
-
185
163
  proto._discard = function discard() {
186
164
  this[kCompleted] = true;
187
-
188
165
  this._stop();
189
-
190
166
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
191
167
  };
192
-
193
168
  proto._stop = function stop() {
194
169
  const broker = this.broker,
195
- executionId = this.executionId;
170
+ executionId = this.executionId;
196
171
  broker.cancel(`_api-link-${executionId}`);
197
172
  broker.cancel(`_api-parent-${executionId}`);
198
173
  broker.cancel(`_api-${executionId}`);
199
174
  this[kMessageQ].purge();
200
175
  };
201
-
202
176
  proto._onDiscard = function onDiscard(_, message) {
203
177
  this.broker.publish('event', 'activity.link.discard', (0, _messageHelper.cloneContent)(message.content, {
204
- message: { ...this.reference
178
+ message: {
179
+ ...this.reference
205
180
  },
206
181
  state: 'discard'
207
182
  }), {
@@ -209,7 +184,6 @@ proto._onDiscard = function onDiscard(_, message) {
209
184
  delegate: true
210
185
  });
211
186
  };
212
-
213
187
  proto._debug = function debug(msg) {
214
188
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
215
189
  };