bpmn-elements 13.1.1 → 13.2.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 (73) hide show
  1. package/README.md +1 -2
  2. package/dist/Context.js +36 -2
  3. package/dist/definition/DefinitionExecution.js +2 -1
  4. package/dist/getPropertyValue.js +1 -2
  5. package/dist/index.js +1 -1
  6. package/package.json +14 -13
  7. package/src/Api.js +18 -20
  8. package/src/Context.js +49 -7
  9. package/src/Environment.js +10 -20
  10. package/src/EventBroker.js +21 -27
  11. package/src/MessageFormatter.js +23 -19
  12. package/src/Tracker.js +4 -4
  13. package/src/activity/Activity.js +141 -109
  14. package/src/activity/ActivityExecution.js +38 -29
  15. package/src/activity/Dummy.js +3 -3
  16. package/src/activity/Escalation.js +4 -4
  17. package/src/activity/ExecutionScope.js +4 -4
  18. package/src/activity/Message.js +5 -5
  19. package/src/activity/Signal.js +5 -5
  20. package/src/definition/Definition.js +44 -36
  21. package/src/definition/DefinitionExecution.js +98 -66
  22. package/src/error/BpmnError.js +3 -3
  23. package/src/error/Errors.js +19 -14
  24. package/src/eventDefinitions/CancelEventDefinition.js +16 -11
  25. package/src/eventDefinitions/CompensateEventDefinition.js +28 -23
  26. package/src/eventDefinitions/ConditionalEventDefinition.js +42 -23
  27. package/src/eventDefinitions/ErrorEventDefinition.js +47 -34
  28. package/src/eventDefinitions/EscalationEventDefinition.js +21 -20
  29. package/src/eventDefinitions/EventDefinitionExecution.js +6 -6
  30. package/src/eventDefinitions/LinkEventDefinition.js +28 -22
  31. package/src/eventDefinitions/MessageEventDefinition.js +47 -36
  32. package/src/eventDefinitions/SignalEventDefinition.js +42 -31
  33. package/src/eventDefinitions/TerminateEventDefinition.js +4 -4
  34. package/src/eventDefinitions/TimerEventDefinition.js +41 -29
  35. package/src/events/BoundaryEvent.js +81 -46
  36. package/src/events/EndEvent.js +2 -2
  37. package/src/events/IntermediateCatchEvent.js +8 -4
  38. package/src/events/IntermediateThrowEvent.js +2 -2
  39. package/src/events/StartEvent.js +29 -18
  40. package/src/flows/Association.js +11 -11
  41. package/src/flows/MessageFlow.js +16 -14
  42. package/src/flows/SequenceFlow.js +22 -20
  43. package/src/gateways/EventBasedGateway.js +7 -6
  44. package/src/gateways/ExclusiveGateway.js +4 -4
  45. package/src/gateways/InclusiveGateway.js +3 -3
  46. package/src/gateways/ParallelGateway.js +4 -4
  47. package/src/getPropertyValue.js +3 -6
  48. package/src/index.js +1 -1
  49. package/src/io/BpmnIO.js +5 -6
  50. package/src/io/EnvironmentDataObject.js +2 -3
  51. package/src/io/EnvironmentDataStore.js +2 -2
  52. package/src/io/EnvironmentDataStoreReference.js +2 -2
  53. package/src/io/InputOutputSpecification.js +60 -54
  54. package/src/io/Properties.js +45 -33
  55. package/src/iso-duration.js +9 -13
  56. package/src/messageHelper.js +16 -23
  57. package/src/process/Lane.js +3 -3
  58. package/src/process/Process.js +40 -34
  59. package/src/process/ProcessExecution.js +122 -78
  60. package/src/tasks/CallActivity.js +109 -57
  61. package/src/tasks/LoopCharacteristics.js +30 -18
  62. package/src/tasks/ReceiveTask.js +59 -38
  63. package/src/tasks/ScriptTask.js +17 -8
  64. package/src/tasks/ServiceTask.js +16 -9
  65. package/src/tasks/SignalTask.js +47 -28
  66. package/src/tasks/StandardLoopCharacteristics.js +3 -3
  67. package/src/tasks/SubProcess.js +9 -8
  68. package/src/tasks/Task.js +4 -3
  69. package/src/tasks/Transaction.js +1 -1
  70. package/types/index.d.ts +6 -6
  71. package/types/types.d.ts +39 -35
  72. package/CHANGELOG.md +0 -455
  73. package/src/ExtensionsMapper.js +0 -42
@@ -1,6 +1,6 @@
1
1
  import getPropertyValue from '../getPropertyValue.js';
2
- import {brokerSafeId} from '../shared.js';
3
- import {cloneContent, shiftParent} from '../messageHelper.js';
2
+ import { brokerSafeId } from '../shared.js';
3
+ import { cloneContent, shiftParent } from '../messageHelper.js';
4
4
 
5
5
  const kCompleted = Symbol.for('completed');
6
6
  const kMessageQ = Symbol.for('messageQ');
@@ -9,30 +9,30 @@ const kReferenceElement = Symbol.for('referenceElement');
9
9
  const kReferenceInfo = Symbol.for('referenceInfo');
10
10
 
11
11
  export default function MessageEventDefinition(activity, eventDefinition) {
12
- const {id, broker, environment, isThrowing} = activity;
13
- const {type = 'MessageEventDefinition', behaviour = {}} = eventDefinition;
12
+ const { id, broker, environment, isThrowing } = activity;
13
+ const { type = 'MessageEventDefinition', behaviour = {} } = eventDefinition;
14
14
 
15
15
  this.id = id;
16
16
  this.type = type;
17
17
 
18
- const reference = this.reference = {
18
+ const reference = (this.reference = {
19
19
  name: 'anonymous',
20
20
  ...behaviour.messageRef,
21
21
  referenceType: 'message',
22
- };
22
+ });
23
23
 
24
24
  this.isThrowing = isThrowing;
25
25
  this.activity = activity;
26
26
  this.broker = broker;
27
27
  this.logger = environment.Logger(type.toLowerCase());
28
28
 
29
- const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
29
+ const referenceElement = (this[kReferenceElement] = reference.id && activity.getActivityById(reference.id));
30
30
  if (!isThrowing) {
31
31
  this[kCompleted] = false;
32
32
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
33
33
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(referenceId)}-q`;
34
- this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
35
- broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
34
+ this[kMessageQ] = broker.assertQueue(messageQueueName, { autoDelete: false, durable: true });
35
+ broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, { durable: true });
36
36
  }
37
37
  }
38
38
 
@@ -52,10 +52,10 @@ MessageEventDefinition.prototype.executeCatch = function executeCatch(executeMes
52
52
  this[kCompleted] = false;
53
53
 
54
54
  const executeContent = executeMessage.content;
55
- const {executionId, parent} = executeContent;
55
+ const { executionId, parent } = executeContent;
56
56
  const parentExecutionId = parent && parent.executionId;
57
57
 
58
- const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
58
+ const info = (this[kReferenceInfo] = this._getReferenceInfo(executeMessage));
59
59
  this._debug(`expect ${info.description}`);
60
60
 
61
61
  const broker = this.broker;
@@ -85,7 +85,7 @@ MessageEventDefinition.prototype.executeCatch = function executeCatch(executeMes
85
85
 
86
86
  const waitContent = cloneContent(executeContent, {
87
87
  executionId: parentExecutionId,
88
- message: {...info.message},
88
+ message: { ...info.message },
89
89
  });
90
90
  waitContent.parent = shiftParent(parent);
91
91
 
@@ -94,7 +94,7 @@ MessageEventDefinition.prototype.executeCatch = function executeCatch(executeMes
94
94
 
95
95
  MessageEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
96
96
  const executeContent = executeMessage.content;
97
- const {executionId, parent} = executeContent;
97
+ const { executionId, parent } = executeContent;
98
98
  const info = this._getReferenceInfo(executeMessage);
99
99
 
100
100
  this.logger.debug(`<${executionId} (${this.activity.id})> message ${info.description}`);
@@ -102,12 +102,12 @@ MessageEventDefinition.prototype.executeThrow = function executeThrow(executeMes
102
102
  const broker = this.broker;
103
103
  const throwContent = cloneContent(executeContent, {
104
104
  executionId: parent.executionId,
105
- message: {...executeContent.input, ...info.message},
105
+ message: { ...executeContent.input, ...info.message },
106
106
  state: 'throw',
107
107
  });
108
108
  throwContent.parent = shiftParent(parent);
109
109
 
110
- broker.publish('event', 'activity.message', throwContent, {type: 'message', delegate: true});
110
+ broker.publish('event', 'activity.message', throwContent, { type: 'message', delegate: true });
111
111
 
112
112
  return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
113
113
  };
@@ -115,28 +115,33 @@ MessageEventDefinition.prototype.executeThrow = function executeThrow(executeMes
115
115
  MessageEventDefinition.prototype._onCatchMessage = function onCatchMessage(routingKey, message) {
116
116
  if (getPropertyValue(message, 'content.message.id') !== this[kReferenceInfo].message.id) return;
117
117
 
118
- const {type, correlationId} = message.properties;
119
- this.broker.publish('event', 'activity.consumed', cloneContent(this[kExecuteMessage].content, {
120
- message: {...message.content.message},
121
- }), {
122
- correlationId,
123
- type,
124
- });
125
-
126
- this._complete('caught', message.content.message, {correlationId});
118
+ const { type, correlationId } = message.properties;
119
+ this.broker.publish(
120
+ 'event',
121
+ 'activity.consumed',
122
+ cloneContent(this[kExecuteMessage].content, {
123
+ message: { ...message.content.message },
124
+ }),
125
+ {
126
+ correlationId,
127
+ type,
128
+ },
129
+ );
130
+
131
+ this._complete('caught', message.content.message, { correlationId });
127
132
  };
128
133
 
129
134
  MessageEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
130
- const {type, correlationId} = message.properties;
135
+ const { type, correlationId } = message.properties;
131
136
  switch (type) {
132
137
  case 'message':
133
138
  case 'signal': {
134
- return this._complete('got signal with', message.content.message, {correlationId});
139
+ return this._complete('got signal with', message.content.message, { correlationId });
135
140
  }
136
141
  case 'discard': {
137
142
  this[kCompleted] = true;
138
143
  this._stop();
139
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
144
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), { correlationId });
140
145
  }
141
146
  case 'stop': {
142
147
  return this._stop();
@@ -153,21 +158,27 @@ MessageEventDefinition.prototype._complete = function complete(verb, output, opt
153
158
  const broker = this.broker;
154
159
  const executeContent = this[kExecuteMessage].content;
155
160
  const catchContent = cloneContent(executeContent, {
156
- message: {...output},
161
+ message: { ...output },
157
162
  executionId: executeContent.parent.executionId,
158
163
  });
159
164
  catchContent.parent = shiftParent(executeContent.parent);
160
165
 
161
- broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
162
-
163
- return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {
164
- output,
165
- state: 'catch',
166
- }), options);
166
+ broker.publish('event', 'activity.catch', catchContent, { type: 'catch' });
167
+
168
+ return broker.publish(
169
+ 'execution',
170
+ 'execute.completed',
171
+ cloneContent(executeContent, {
172
+ output,
173
+ state: 'catch',
174
+ }),
175
+ options,
176
+ );
167
177
  };
168
178
 
169
179
  MessageEventDefinition.prototype._stop = function stop() {
170
- const broker = this.broker, executionId = this.executionId;
180
+ const broker = this.broker,
181
+ executionId = this.executionId;
171
182
  broker.cancel(`_api-message-${executionId}`);
172
183
  broker.cancel(`_api-${executionId}`);
173
184
  broker.cancel(`_api-parent-${executionId}`);
@@ -179,7 +190,7 @@ MessageEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(m
179
190
  const referenceElement = this[kReferenceElement];
180
191
  if (!referenceElement) {
181
192
  return {
182
- message: {...this.reference},
193
+ message: { ...this.reference },
183
194
  description: 'anonymous message',
184
195
  };
185
196
  }
@@ -1,6 +1,6 @@
1
1
  import getPropertyValue from '../getPropertyValue.js';
2
- import {brokerSafeId} from '../shared.js';
3
- import {cloneContent, shiftParent} from '../messageHelper.js';
2
+ import { brokerSafeId } from '../shared.js';
3
+ import { cloneContent, shiftParent } from '../messageHelper.js';
4
4
 
5
5
  const kCompleted = Symbol.for('completed');
6
6
  const kMessageQ = Symbol.for('messageQ');
@@ -9,30 +9,30 @@ const kReferenceElement = Symbol.for('referenceElement');
9
9
  const kReferenceInfo = Symbol.for('referenceInfo');
10
10
 
11
11
  export default function SignalEventDefinition(activity, eventDefinition) {
12
- const {id, broker, environment, isStart, isThrowing} = activity;
13
- const {type, behaviour = {}} = eventDefinition;
12
+ const { id, broker, environment, isStart, isThrowing } = activity;
13
+ const { type, behaviour = {} } = eventDefinition;
14
14
 
15
15
  this.id = id;
16
16
  this.type = type;
17
17
 
18
- const reference = this.reference = {
18
+ const reference = (this.reference = {
19
19
  name: 'anonymous',
20
20
  ...behaviour.signalRef,
21
21
  referenceType: 'signal',
22
- };
22
+ });
23
23
 
24
24
  this.isThrowing = isThrowing;
25
25
  this.activity = activity;
26
26
  this.broker = broker;
27
27
  this.logger = environment.Logger(type.toLowerCase());
28
28
 
29
- const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
29
+ const referenceElement = (this[kReferenceElement] = reference.id && activity.getActivityById(reference.id));
30
30
  if (!isThrowing && isStart) {
31
31
  this[kCompleted] = false;
32
32
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
33
33
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(referenceId)}-q`;
34
- this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
35
- broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
34
+ this[kMessageQ] = broker.assertQueue(messageQueueName, { autoDelete: false, durable: true });
35
+ broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, { durable: true });
36
36
  }
37
37
  }
38
38
 
@@ -52,10 +52,10 @@ SignalEventDefinition.prototype.executeCatch = function executeCatch(executeMess
52
52
  this[kCompleted] = false;
53
53
 
54
54
  const executeContent = executeMessage.content;
55
- const {executionId, parent} = executeContent;
55
+ const { executionId, parent } = executeContent;
56
56
  const parentExecutionId = parent && parent.executionId;
57
57
 
58
- const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
58
+ const info = (this[kReferenceInfo] = this._getReferenceInfo(executeMessage));
59
59
  const broker = this.broker;
60
60
 
61
61
  const onCatchMessage = this._onCatchMessage.bind(this);
@@ -85,7 +85,7 @@ SignalEventDefinition.prototype.executeCatch = function executeCatch(executeMess
85
85
 
86
86
  const waitContent = cloneContent(executeContent, {
87
87
  executionId: parent.executionId,
88
- signal: {...info.message},
88
+ signal: { ...info.message },
89
89
  });
90
90
  waitContent.parent = shiftParent(parent);
91
91
 
@@ -94,7 +94,7 @@ SignalEventDefinition.prototype.executeCatch = function executeCatch(executeMess
94
94
 
95
95
  SignalEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
96
96
  const executeContent = executeMessage.content;
97
- const {executionId, parent} = executeContent;
97
+ const { executionId, parent } = executeContent;
98
98
 
99
99
  const info = this._getReferenceInfo(executeMessage);
100
100
 
@@ -102,13 +102,13 @@ SignalEventDefinition.prototype.executeThrow = function executeThrow(executeMess
102
102
 
103
103
  const throwContent = cloneContent(executeContent, {
104
104
  executionId: parent.executionId,
105
- message: {...executeContent.input, ...info.message},
105
+ message: { ...executeContent.input, ...info.message },
106
106
  state: 'throw',
107
107
  });
108
108
  throwContent.parent = shiftParent(parent);
109
109
 
110
110
  const broker = this.broker;
111
- broker.publish('event', 'activity.signal', throwContent, {type: 'signal'});
111
+ broker.publish('event', 'activity.signal', throwContent, { type: 'signal' });
112
112
 
113
113
  return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
114
114
  };
@@ -119,28 +119,33 @@ SignalEventDefinition.prototype._onCatchMessage = function onCatchMessage(routin
119
119
  this[kCompleted] = true;
120
120
  this._stop();
121
121
 
122
- const {type, correlationId} = message.properties;
123
- this.broker.publish('event', 'activity.consumed', cloneContent(this[kExecuteMessage].content, {
124
- message: { ...message.content.message},
125
- }), {
126
- correlationId,
127
- type,
128
- });
122
+ const { type, correlationId } = message.properties;
123
+ this.broker.publish(
124
+ 'event',
125
+ 'activity.consumed',
126
+ cloneContent(this[kExecuteMessage].content, {
127
+ message: { ...message.content.message },
128
+ }),
129
+ {
130
+ correlationId,
131
+ type,
132
+ },
133
+ );
129
134
 
130
135
  return this._complete(message.content.message, message.properties);
131
136
  };
132
137
 
133
138
  SignalEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
134
- const {type, correlationId} = message.properties;
139
+ const { type, correlationId } = message.properties;
135
140
 
136
141
  switch (type) {
137
142
  case 'signal': {
138
- return this._complete(message.content.message, {correlationId});
143
+ return this._complete(message.content.message, { correlationId });
139
144
  }
140
145
  case 'discard': {
141
146
  this[kCompleted] = true;
142
147
  this._stop();
143
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
148
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), { correlationId });
144
149
  }
145
150
  case 'stop': {
146
151
  this._stop();
@@ -153,14 +158,20 @@ SignalEventDefinition.prototype._complete = function complete(output, options) {
153
158
  this[kCompleted] = true;
154
159
  this._stop();
155
160
  this._debug(`signaled with ${this[kReferenceInfo].description}`);
156
- return this.broker.publish('execution', 'execute.completed', cloneContent(this[kExecuteMessage].content, {
157
- output,
158
- state: 'signal',
159
- }), options);
161
+ return this.broker.publish(
162
+ 'execution',
163
+ 'execute.completed',
164
+ cloneContent(this[kExecuteMessage].content, {
165
+ output,
166
+ state: 'signal',
167
+ }),
168
+ options,
169
+ );
160
170
  };
161
171
 
162
172
  SignalEventDefinition.prototype._stop = function stop() {
163
- const broker = this.broker, executionId = this.executionId;
173
+ const broker = this.broker,
174
+ executionId = this.executionId;
164
175
  broker.cancel(`_api-signal-${executionId}`);
165
176
  broker.cancel(`_api-parent-${executionId}`);
166
177
  broker.cancel(`_api-${executionId}`);
@@ -172,7 +183,7 @@ SignalEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(me
172
183
  const referenceElement = this[kReferenceElement];
173
184
  if (!referenceElement) {
174
185
  return {
175
- message: {...this.reference},
186
+ message: { ...this.reference },
176
187
  description: 'anonymous signal',
177
188
  };
178
189
  }
@@ -1,8 +1,8 @@
1
- import {cloneContent, shiftParent} from '../messageHelper.js';
1
+ import { cloneContent, shiftParent } from '../messageHelper.js';
2
2
 
3
3
  export default function TerminateEventDefinition(activity, eventDefinition) {
4
- const {id, broker, environment} = activity;
5
- const {type = 'TerminateEventDefinition'} = eventDefinition;
4
+ const { id, broker, environment } = activity;
5
+ const { type = 'TerminateEventDefinition' } = eventDefinition;
6
6
 
7
7
  this.id = id;
8
8
  this.type = type;
@@ -21,6 +21,6 @@ TerminateEventDefinition.prototype.execute = function execute(executeMessage) {
21
21
 
22
22
  this.logger.debug(`<${executeContent.executionId} (${executeContent.id})> terminate`);
23
23
  const broker = this.broker;
24
- broker.publish('event', 'process.terminate', throwContent, {type: 'terminate'});
24
+ broker.publish('event', 'process.terminate', throwContent, { type: 'terminate' });
25
25
  broker.publish('execution', 'execute.completed', cloneContent(executeContent));
26
26
  };
@@ -1,17 +1,17 @@
1
- import {cloneContent} from '../messageHelper.js';
2
- import {toSeconds, parse as parseIsoDuration} from '../iso-duration.js';
1
+ import { cloneContent } from '../messageHelper.js';
2
+ import { toSeconds, parse as parseIsoDuration } from '../iso-duration.js';
3
3
 
4
4
  const kStopped = Symbol.for('stopped');
5
5
  const kTimerContent = Symbol.for('timerContent');
6
6
  const kTimer = Symbol.for('timer');
7
7
 
8
8
  export default function TimerEventDefinition(activity, eventDefinition) {
9
- const type = this.type = eventDefinition.type || 'TimerEventDefinition';
9
+ const type = (this.type = eventDefinition.type || 'TimerEventDefinition');
10
10
  this.activity = activity;
11
- const environment = this.environment = activity.environment;
11
+ const environment = (this.environment = activity.environment);
12
12
  this.eventDefinition = eventDefinition;
13
13
 
14
- const {timeDuration, timeCycle, timeDate} = eventDefinition.behaviour || {};
14
+ const { timeDuration, timeCycle, timeDate } = eventDefinition.behaviour || {};
15
15
  if (timeDuration) this.timeDuration = timeDuration;
16
16
  if (timeCycle) this.timeCycle = timeCycle;
17
17
  if (timeDate) this.timeDate = timeDate;
@@ -43,7 +43,7 @@ Object.defineProperties(TimerEventDefinition.prototype, {
43
43
  });
44
44
 
45
45
  TimerEventDefinition.prototype.execute = function execute(executeMessage) {
46
- const {routingKey: executeKey, redelivered: isResumed} = executeMessage.fields;
46
+ const { routingKey: executeKey, redelivered: isResumed } = executeMessage.fields;
47
47
  const timer = this[kTimer];
48
48
  if (timer && executeKey === 'execute.timer') {
49
49
  return;
@@ -54,23 +54,25 @@ TimerEventDefinition.prototype.execute = function execute(executeMessage) {
54
54
 
55
55
  const content = executeMessage.content;
56
56
  const executionId = content.executionId;
57
- const startedAt = this.startedAt = 'startedAt' in content ? new Date(content.startedAt) : new Date();
57
+ const startedAt = (this.startedAt = 'startedAt' in content ? new Date(content.startedAt) : new Date());
58
58
 
59
59
  const resolvedTimer = this._getTimers(executeMessage);
60
- const timerContent = this[kTimerContent] = cloneContent(content, {
60
+ const timerContent = (this[kTimerContent] = cloneContent(content, {
61
61
  ...resolvedTimer,
62
- ...(isResumed && {isResumed}),
62
+ ...(isResumed && { isResumed }),
63
63
  startedAt,
64
64
  state: 'timer',
65
- });
65
+ }));
66
66
 
67
67
  const broker = this.broker;
68
68
  broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
69
- noAck: true, consumerTag: `_api-${executionId}`,
69
+ noAck: true,
70
+ consumerTag: `_api-${executionId}`,
70
71
  priority: 400,
71
72
  });
72
73
  broker.subscribeTmp('api', '#.cancel.*', this._onDelegatedApiMessage.bind(this), {
73
- noAck: true, consumerTag: `_api-delegated-${executionId}`,
74
+ noAck: true,
75
+ consumerTag: `_api-delegated-${executionId}`,
74
76
  });
75
77
 
76
78
  broker.publish('execution', 'execute.timer', cloneContent(timerContent));
@@ -106,14 +108,14 @@ TimerEventDefinition.prototype._completed = function completed(completeContent,
106
108
  this._debug(`completed in ${runningTime}ms`);
107
109
 
108
110
  const timerContent = this[kTimerContent];
109
- const content = {stoppedAt, runningTime, state: 'timeout', ...completeContent};
111
+ const content = { stoppedAt, runningTime, state: 'timeout', ...completeContent };
110
112
 
111
113
  const broker = this.broker;
112
114
  broker.publish('event', 'activity.timeout', cloneContent(timerContent, content), options);
113
115
 
114
116
  if (timerContent.repeat > 1) {
115
117
  const repeat = timerContent.repeat - 1;
116
- broker.publish('execution', 'execute.repeat', cloneContent(timerContent, {...content, repeat}), options);
118
+ broker.publish('execution', 'execute.repeat', cloneContent(timerContent, { ...content, repeat }), options);
117
119
  }
118
120
 
119
121
  broker.publish('execution', 'execute.completed', cloneContent(timerContent, content), options);
@@ -125,33 +127,41 @@ TimerEventDefinition.prototype._onDelegatedApiMessage = function onDelegatedApiM
125
127
  const content = message.content;
126
128
  if (!content.message) return;
127
129
 
128
- const {id: signalId, executionId: signalExecutionId} = content.message;
130
+ const { id: signalId, executionId: signalExecutionId } = content.message;
129
131
 
130
132
  const executionId = this.executionId;
131
133
  const id = this.activity.id;
132
134
  if (signalId !== id && signalExecutionId !== executionId) return;
133
135
  if (signalExecutionId && signalId === id && signalExecutionId !== executionId) return;
134
136
 
135
- const {type, correlationId} = message.properties;
136
- this.broker.publish('event', 'activity.consumed', cloneContent(this[kTimerContent], {
137
- message: {
138
- ...content.message,
139
- },
140
- }), {correlationId, type});
137
+ const { type, correlationId } = message.properties;
138
+ this.broker.publish(
139
+ 'event',
140
+ 'activity.consumed',
141
+ cloneContent(this[kTimerContent], {
142
+ message: {
143
+ ...content.message,
144
+ },
145
+ }),
146
+ { correlationId, type },
147
+ );
141
148
 
142
149
  return this._onApiMessage(routingKey, message);
143
150
  };
144
151
 
145
152
  TimerEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
146
- const {type: messageType, correlationId} = message.properties;
153
+ const { type: messageType, correlationId } = message.properties;
147
154
 
148
155
  switch (messageType) {
149
156
  case 'cancel': {
150
157
  this._stop();
151
- return this._completed({
152
- state: 'cancel',
153
- ...(message.content.message && {message: message.content.message}),
154
- }, {correlationId});
158
+ return this._completed(
159
+ {
160
+ state: 'cancel',
161
+ ...(message.content.message && { message: message.content.message }),
162
+ },
163
+ { correlationId },
164
+ );
155
165
  }
156
166
  case 'stop': {
157
167
  this._stop();
@@ -160,7 +170,9 @@ TimerEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey,
160
170
  case 'discard': {
161
171
  this._stop();
162
172
  this._debug('discarded');
163
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[kTimerContent], {state: 'discard'}), {correlationId});
173
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kTimerContent], { state: 'discard' }), {
174
+ correlationId,
175
+ });
164
176
  }
165
177
  }
166
178
  };
@@ -208,7 +220,7 @@ TimerEventDefinition.prototype._getTimers = function getTimers(executeMessage) {
208
220
  const content = executeMessage.content;
209
221
 
210
222
  const result = {
211
- ...('expireAt' in content && {expireAt: new Date(content.expireAt)}),
223
+ ...('expireAt' in content && { expireAt: new Date(content.expireAt) }),
212
224
  };
213
225
 
214
226
  let parseErr;
@@ -221,7 +233,7 @@ TimerEventDefinition.prototype._getTimers = function getTimers(executeMessage) {
221
233
  const timerStr = result[t];
222
234
  if (timerStr) {
223
235
  try {
224
- const {repeat: parsedRepeat, expireAt: parsedExpireAt} = this.parse(t, timerStr);
236
+ const { repeat: parsedRepeat, expireAt: parsedExpireAt } = this.parse(t, timerStr);
225
237
  repeat = parsedRepeat;
226
238
  expireAtDate = parsedExpireAt;
227
239
  } catch (err) {