bpmn-elements 7.0.0 → 8.1.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 (72) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/src/Context.js +50 -40
  3. package/dist/src/Environment.js +39 -19
  4. package/dist/src/MessageFormatter.js +11 -11
  5. package/dist/src/activity/Activity.js +106 -106
  6. package/dist/src/activity/ActivityExecution.js +37 -37
  7. package/dist/src/activity/Message.js +2 -2
  8. package/dist/src/activity/Signal.js +2 -2
  9. package/dist/src/definition/Definition.js +50 -50
  10. package/dist/src/definition/DefinitionExecution.js +114 -125
  11. package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
  12. package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
  13. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  14. package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  15. package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  16. package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  17. package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
  18. package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
  19. package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
  20. package/dist/src/eventDefinitions/TimerEventDefinition.js +76 -53
  21. package/dist/src/events/BoundaryEvent.js +67 -38
  22. package/dist/src/events/EndEvent.js +3 -3
  23. package/dist/src/events/IntermediateCatchEvent.js +3 -3
  24. package/dist/src/events/IntermediateThrowEvent.js +3 -3
  25. package/dist/src/events/StartEvent.js +9 -9
  26. package/dist/src/flows/Association.js +7 -7
  27. package/dist/src/flows/MessageFlow.js +9 -9
  28. package/dist/src/flows/SequenceFlow.js +7 -7
  29. package/dist/src/gateways/EventBasedGateway.js +11 -11
  30. package/dist/src/io/InputOutputSpecification.js +4 -4
  31. package/dist/src/io/Properties.js +9 -9
  32. package/dist/src/process/Process.js +64 -61
  33. package/dist/src/process/ProcessExecution.js +93 -90
  34. package/dist/src/tasks/ReceiveTask.js +16 -16
  35. package/dist/src/tasks/SubProcess.js +16 -18
  36. package/package.json +15 -16
  37. package/src/Context.js +48 -40
  38. package/src/Environment.js +48 -20
  39. package/src/EventBroker.js +1 -1
  40. package/src/MessageFormatter.js +11 -11
  41. package/src/activity/Activity.js +99 -100
  42. package/src/activity/ActivityExecution.js +35 -35
  43. package/src/activity/Message.js +1 -1
  44. package/src/activity/Signal.js +1 -1
  45. package/src/definition/Definition.js +51 -50
  46. package/src/definition/DefinitionExecution.js +111 -113
  47. package/src/eventDefinitions/CancelEventDefinition.js +16 -16
  48. package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
  49. package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  50. package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  51. package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  52. package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  53. package/src/eventDefinitions/LinkEventDefinition.js +15 -15
  54. package/src/eventDefinitions/MessageEventDefinition.js +23 -23
  55. package/src/eventDefinitions/SignalEventDefinition.js +24 -24
  56. package/src/eventDefinitions/TimerEventDefinition.js +61 -44
  57. package/src/events/BoundaryEvent.js +53 -36
  58. package/src/events/EndEvent.js +3 -3
  59. package/src/events/IntermediateCatchEvent.js +3 -3
  60. package/src/events/IntermediateThrowEvent.js +3 -3
  61. package/src/events/StartEvent.js +9 -9
  62. package/src/flows/Association.js +7 -7
  63. package/src/flows/MessageFlow.js +9 -9
  64. package/src/flows/SequenceFlow.js +7 -7
  65. package/src/gateways/EventBasedGateway.js +11 -11
  66. package/src/io/BpmnIO.js +5 -1
  67. package/src/io/InputOutputSpecification.js +4 -4
  68. package/src/io/Properties.js +9 -9
  69. package/src/process/Process.js +62 -58
  70. package/src/process/ProcessExecution.js +86 -88
  71. package/src/tasks/ReceiveTask.js +16 -16
  72. package/src/tasks/SubProcess.js +16 -16
@@ -13,11 +13,11 @@ var _messageHelper = require("../messageHelper");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- const completedSymbol = Symbol.for('completed');
17
- const messageQSymbol = Symbol.for('messageQ');
18
- const executeMessageSymbol = Symbol.for('executeMessage');
19
- const referenceElementSymbol = Symbol.for('referenceElement');
20
- const referenceInfoSymbol = Symbol.for('referenceInfo');
16
+ const kCompleted = Symbol.for('completed');
17
+ const kMessageQ = Symbol.for('messageQ');
18
+ const kExecuteMessage = Symbol.for('executeMessage');
19
+ const kReferenceElement = Symbol.for('referenceElement');
20
+ const kReferenceInfo = Symbol.for('referenceInfo');
21
21
 
22
22
  function MessageEventDefinition(activity, eventDefinition) {
23
23
  const {
@@ -41,13 +41,13 @@ function MessageEventDefinition(activity, eventDefinition) {
41
41
  this.activity = activity;
42
42
  this.broker = broker;
43
43
  this.logger = environment.Logger(type.toLowerCase());
44
- const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
44
+ const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
45
45
 
46
46
  if (!isThrowing) {
47
- this[completedSymbol] = false;
47
+ this[kCompleted] = false;
48
48
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
49
49
  const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
50
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {
50
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {
51
51
  autoDelete: false,
52
52
  durable: true
53
53
  });
@@ -60,7 +60,7 @@ function MessageEventDefinition(activity, eventDefinition) {
60
60
  const proto = MessageEventDefinition.prototype;
61
61
  Object.defineProperty(proto, 'executionId', {
62
62
  get() {
63
- const message = this[executeMessageSymbol];
63
+ const message = this[kExecuteMessage];
64
64
  return message && message.content.executionId;
65
65
  }
66
66
 
@@ -71,8 +71,8 @@ proto.execute = function execute(executeMessage) {
71
71
  };
72
72
 
73
73
  proto.executeCatch = function executeCatch(executeMessage) {
74
- this[executeMessageSymbol] = executeMessage;
75
- this[completedSymbol] = false;
74
+ this[kExecuteMessage] = executeMessage;
75
+ this[kCompleted] = false;
76
76
  const executeContent = executeMessage.content;
77
77
  const {
78
78
  executionId,
@@ -80,7 +80,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
80
80
  } = executeContent;
81
81
  const parentExecutionId = parent && parent.executionId;
82
82
 
83
- const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
83
+ const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
84
84
 
85
85
  this._debug(`expect ${info.description}`);
86
86
 
@@ -88,11 +88,11 @@ proto.executeCatch = function executeCatch(executeMessage) {
88
88
 
89
89
  const onCatchMessage = this._onCatchMessage.bind(this);
90
90
 
91
- this[messageQSymbol].consume(onCatchMessage, {
91
+ this[kMessageQ].consume(onCatchMessage, {
92
92
  noAck: true,
93
93
  consumerTag: `_api-message-${executionId}`
94
94
  });
95
- if (this[completedSymbol]) return;
95
+ if (this[kCompleted]) return;
96
96
 
97
97
  const onApiMessage = this._onApiMessage.bind(this);
98
98
 
@@ -146,12 +146,12 @@ proto.executeThrow = function executeThrow(executeMessage) {
146
146
  };
147
147
 
148
148
  proto._onCatchMessage = function onCatchMessage(routingKey, message) {
149
- if ((0, _getPropertyValue.default)(message, 'content.message.id') !== this[referenceInfoSymbol].message.id) return;
149
+ if ((0, _getPropertyValue.default)(message, 'content.message.id') !== this[kReferenceInfo].message.id) return;
150
150
  const {
151
151
  type,
152
152
  correlationId
153
153
  } = message.properties;
154
- this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
154
+ this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
155
155
  message: { ...message.content.message
156
156
  }
157
157
  }), {
@@ -181,11 +181,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
181
181
 
182
182
  case 'discard':
183
183
  {
184
- this[completedSymbol] = true;
184
+ this[kCompleted] = true;
185
185
 
186
186
  this._stop();
187
187
 
188
- return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content), {
188
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content), {
189
189
  correlationId
190
190
  });
191
191
  }
@@ -198,14 +198,14 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
198
198
  };
199
199
 
200
200
  proto._complete = function complete(verb, output, options) {
201
- this[completedSymbol] = true;
201
+ this[kCompleted] = true;
202
202
 
203
203
  this._stop();
204
204
 
205
- this._debug(`${verb} ${this[referenceInfoSymbol].description}`);
205
+ this._debug(`${verb} ${this[kReferenceInfo].description}`);
206
206
 
207
207
  const broker = this.broker;
208
- const executeContent = this[executeMessageSymbol].content;
208
+ const executeContent = this[kExecuteMessage].content;
209
209
  const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
210
210
  message: { ...output
211
211
  },
@@ -228,11 +228,11 @@ proto._stop = function stop() {
228
228
  broker.cancel(`_api-${executionId}`);
229
229
  broker.cancel(`_api-parent-${executionId}`);
230
230
  broker.cancel(`_api-delegated-${executionId}`);
231
- this[messageQSymbol].purge();
231
+ this[kMessageQ].purge();
232
232
  };
233
233
 
234
234
  proto._getReferenceInfo = function getReferenceInfo(message) {
235
- const referenceElement = this[referenceElementSymbol];
235
+ const referenceElement = this[kReferenceElement];
236
236
 
237
237
  if (!referenceElement) {
238
238
  return {
@@ -13,11 +13,11 @@ var _messageHelper = require("../messageHelper");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- const completedSymbol = Symbol.for('completed');
17
- const messageQSymbol = Symbol.for('messageQ');
18
- const executeMessageSymbol = Symbol.for('executeMessage');
19
- const referenceElementSymbol = Symbol.for('referenceElement');
20
- const referenceInfoSymbol = Symbol.for('referenceInfo');
16
+ const kCompleted = Symbol.for('completed');
17
+ const kMessageQ = Symbol.for('messageQ');
18
+ const kExecuteMessage = Symbol.for('executeMessage');
19
+ const kReferenceElement = Symbol.for('referenceElement');
20
+ const kReferenceInfo = Symbol.for('referenceInfo');
21
21
 
22
22
  function SignalEventDefinition(activity, eventDefinition) {
23
23
  const {
@@ -42,13 +42,13 @@ function SignalEventDefinition(activity, eventDefinition) {
42
42
  this.activity = activity;
43
43
  this.broker = broker;
44
44
  this.logger = environment.Logger(type.toLowerCase());
45
- const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
45
+ const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
46
46
 
47
47
  if (!isThrowing && isStart) {
48
- this[completedSymbol] = false;
48
+ this[kCompleted] = false;
49
49
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
50
50
  const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
51
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {
51
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {
52
52
  autoDelete: false,
53
53
  durable: true
54
54
  });
@@ -61,7 +61,7 @@ function SignalEventDefinition(activity, eventDefinition) {
61
61
  const proto = SignalEventDefinition.prototype;
62
62
  Object.defineProperty(proto, 'executionId', {
63
63
  get() {
64
- const message = this[executeMessageSymbol];
64
+ const message = this[kExecuteMessage];
65
65
  return message && message.content.executionId;
66
66
  }
67
67
 
@@ -72,8 +72,8 @@ proto.execute = function execute(executeMessage) {
72
72
  };
73
73
 
74
74
  proto.executeCatch = function executeCatch(executeMessage) {
75
- this[executeMessageSymbol] = executeMessage;
76
- this[completedSymbol] = false;
75
+ this[kExecuteMessage] = executeMessage;
76
+ this[kCompleted] = false;
77
77
  const executeContent = executeMessage.content;
78
78
  const {
79
79
  executionId,
@@ -81,18 +81,18 @@ proto.executeCatch = function executeCatch(executeMessage) {
81
81
  } = executeContent;
82
82
  const parentExecutionId = parent && parent.executionId;
83
83
 
84
- const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
84
+ const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
85
85
 
86
86
  const broker = this.broker;
87
87
 
88
88
  const onCatchMessage = this._onCatchMessage.bind(this);
89
89
 
90
90
  if (this.activity.isStart) {
91
- this[messageQSymbol].consume(onCatchMessage, {
91
+ this[kMessageQ].consume(onCatchMessage, {
92
92
  noAck: true,
93
93
  consumerTag: `_api-signal-${executionId}`
94
94
  });
95
- if (this[completedSymbol]) return;
95
+ if (this[kCompleted]) return;
96
96
  }
97
97
 
98
98
  const onApiMessage = this._onApiMessage.bind(this);
@@ -147,9 +147,9 @@ proto.executeThrow = function executeThrow(executeMessage) {
147
147
  };
148
148
 
149
149
  proto._onCatchMessage = function onCatchMessage(routingKey, message) {
150
- const info = this[referenceInfoSymbol];
150
+ const info = this[kReferenceInfo];
151
151
  if ((0, _getPropertyValue.default)(message, 'content.message.id') !== info.message.id) return;
152
- this[completedSymbol] = true;
152
+ this[kCompleted] = true;
153
153
 
154
154
  this._stop();
155
155
 
@@ -157,7 +157,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
157
157
  type,
158
158
  correlationId
159
159
  } = message.properties;
160
- this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
160
+ this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
161
161
  message: { ...message.content.message
162
162
  }
163
163
  }), {
@@ -183,11 +183,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
183
183
 
184
184
  case 'discard':
185
185
  {
186
- this[completedSymbol] = true;
186
+ this[kCompleted] = true;
187
187
 
188
188
  this._stop();
189
189
 
190
- return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content), {
190
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content), {
191
191
  correlationId
192
192
  });
193
193
  }
@@ -202,13 +202,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
202
202
  };
203
203
 
204
204
  proto._complete = function complete(output, options) {
205
- this[completedSymbol] = true;
205
+ this[kCompleted] = true;
206
206
 
207
207
  this._stop();
208
208
 
209
- this._debug(`signaled with ${this[referenceInfoSymbol].description}`);
209
+ this._debug(`signaled with ${this[kReferenceInfo].description}`);
210
210
 
211
- return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
211
+ return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
212
212
  output,
213
213
  state: 'signal'
214
214
  }), options);
@@ -221,11 +221,11 @@ proto._stop = function stop() {
221
221
  broker.cancel(`_api-parent-${executionId}`);
222
222
  broker.cancel(`_api-${executionId}`);
223
223
  broker.cancel(`_api-delegated-${executionId}`);
224
- if (this.activity.isStart) this[messageQSymbol].purge();
224
+ if (this.activity.isStart) this[kMessageQ].purge();
225
225
  };
226
226
 
227
227
  proto._getReferenceInfo = function getReferenceInfo(message) {
228
- const referenceElement = this[referenceElementSymbol];
228
+ const referenceElement = this[kReferenceElement];
229
229
 
230
230
  if (!referenceElement) {
231
231
  return {
@@ -9,9 +9,10 @@ var _messageHelper = require("../messageHelper");
9
9
 
10
10
  var _iso8601Duration = require("iso8601-duration");
11
11
 
12
- const stoppedSymbol = Symbol.for('stopped');
13
- const timerContentSymbol = Symbol.for('timerContent');
14
- const timerSymbol = Symbol.for('timer');
12
+ const kStopped = Symbol.for('stopped');
13
+ const kTimerContent = Symbol.for('timerContent');
14
+ const kTimer = Symbol.for('timer');
15
+ const repeatPattern = /^\s*R(\d+)\//;
15
16
 
16
17
  function TimerEventDefinition(activity, eventDefinition) {
17
18
  const type = this.type = eventDefinition.type || 'TimerEventDefinition';
@@ -28,14 +29,14 @@ function TimerEventDefinition(activity, eventDefinition) {
28
29
  if (timeDate) this.timeDate = timeDate;
29
30
  this.broker = activity.broker;
30
31
  this.logger = environment.Logger(type.toLowerCase());
31
- this[stoppedSymbol] = false;
32
- this[timerSymbol] = null;
32
+ this[kStopped] = false;
33
+ this[kTimer] = null;
33
34
  }
34
35
 
35
36
  const proto = TimerEventDefinition.prototype;
36
37
  Object.defineProperty(proto, 'executionId', {
37
38
  get() {
38
- const content = this[timerContentSymbol];
39
+ const content = this[kTimerContent];
39
40
  return content && content.executionId;
40
41
  }
41
42
 
@@ -44,7 +45,7 @@ Object.defineProperty(proto, 'stopped', {
44
45
  enumerable: true,
45
46
 
46
47
  get() {
47
- return this[stoppedSymbol];
48
+ return this[kStopped];
48
49
  }
49
50
 
50
51
  });
@@ -52,7 +53,7 @@ Object.defineProperty(proto, 'timer', {
52
53
  enumerable: true,
53
54
 
54
55
  get() {
55
- return this[timerSymbol];
56
+ return this[kTimer];
56
57
  }
57
58
 
58
59
  });
@@ -62,24 +63,24 @@ proto.execute = function execute(executeMessage) {
62
63
  routingKey: executeKey,
63
64
  redelivered: isResumed
64
65
  } = executeMessage.fields;
65
- const timer = this[timerSymbol];
66
+ const timer = this[kTimer];
66
67
 
67
68
  if (timer && executeKey === 'execute.timer') {
68
69
  return;
69
70
  }
70
71
 
71
- if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
72
- this[stoppedSymbol] = false;
72
+ if (timer) this[kTimer] = this.environment.timers.clearTimeout(timer);
73
+ this[kStopped] = false;
73
74
  const content = executeMessage.content;
74
75
  const executionId = content.executionId;
75
76
  const startedAt = this.startedAt = 'startedAt' in content ? new Date(content.startedAt) : new Date();
76
77
 
77
78
  const resolvedTimer = this._getTimers(executeMessage);
78
79
 
79
- const timerContent = this[timerContentSymbol] = (0, _messageHelper.cloneContent)(content, { ...resolvedTimer,
80
- ...(isResumed ? {
80
+ const timerContent = this[kTimerContent] = (0, _messageHelper.cloneContent)(content, { ...resolvedTimer,
81
+ ...(isResumed && {
81
82
  isResumed
82
- } : undefined),
83
+ }),
83
84
  startedAt,
84
85
  state: 'timer'
85
86
  });
@@ -99,7 +100,7 @@ proto.execute = function execute(executeMessage) {
99
100
  if (timerContent.timeout === undefined) return this._debug(`waiting for ${timerContent.timerType || 'signal'}`);
100
101
  if (timerContent.timeout <= 0) return this._completed();
101
102
  const timers = this.environment.timers.register(timerContent);
102
- this[timerSymbol] = timers.setTimeout(this._completed.bind(this), timerContent.timeout, {
103
+ this[kTimer] = timers.setTimeout(this._completed.bind(this), timerContent.timeout, {
103
104
  id: content.id,
104
105
  type: this.type,
105
106
  executionId,
@@ -108,8 +109,8 @@ proto.execute = function execute(executeMessage) {
108
109
  };
109
110
 
110
111
  proto.stop = function stopTimer() {
111
- const timer = this[timerSymbol];
112
- if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
112
+ const timer = this[kTimer];
113
+ if (timer) this[kTimer] = this.environment.timers.clearTimeout(timer);
113
114
  };
114
115
 
115
116
  proto._completed = function completed(completeContent, options) {
@@ -120,7 +121,7 @@ proto._completed = function completed(completeContent, options) {
120
121
 
121
122
  this._debug(`completed in ${runningTime}ms`);
122
123
 
123
- const timerContent = this[timerContentSymbol];
124
+ const timerContent = this[kTimerContent];
124
125
  const content = {
125
126
  stoppedAt,
126
127
  runningTime,
@@ -129,6 +130,14 @@ proto._completed = function completed(completeContent, options) {
129
130
  };
130
131
  const broker = this.broker;
131
132
  broker.publish('event', 'activity.timeout', (0, _messageHelper.cloneContent)(timerContent, content), options);
133
+
134
+ if (timerContent.repeat > 1) {
135
+ const repeat = timerContent.repeat - 1;
136
+ broker.publish('execution', 'execute.repeat', (0, _messageHelper.cloneContent)(timerContent, { ...content,
137
+ repeat
138
+ }), options);
139
+ }
140
+
132
141
  broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(timerContent, content), options);
133
142
  };
134
143
 
@@ -148,7 +157,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, messag
148
157
  type,
149
158
  correlationId
150
159
  } = message.properties;
151
- this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[timerContentSymbol], {
160
+ this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[kTimerContent], {
152
161
  message: { ...content.message
153
162
  }
154
163
  }), {
@@ -171,9 +180,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
171
180
 
172
181
  return this._completed({
173
182
  state: 'cancel',
174
- ...(message.content.message ? {
183
+ ...(message.content.message && {
175
184
  message: message.content.message
176
- } : undefined)
185
+ })
177
186
  }, {
178
187
  correlationId
179
188
  });
@@ -192,7 +201,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
192
201
 
193
202
  this._debug('discarded');
194
203
 
195
- return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[timerContentSymbol], {
204
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kTimerContent], {
196
205
  state: 'discard'
197
206
  }), {
198
207
  correlationId
@@ -202,9 +211,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
202
211
  };
203
212
 
204
213
  proto._stop = function stop() {
205
- this[stoppedSymbol] = true;
206
- const timer = this[timerSymbol];
207
- if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
214
+ this[kStopped] = true;
215
+ const timer = this[kTimer];
216
+ if (timer) this[kTimer] = this.environment.timers.clearTimeout(timer);
208
217
  const broker = this.broker;
209
218
  broker.cancel(`_api-${this.executionId}`);
210
219
  broker.cancel(`_api-delegated-${this.executionId}`);
@@ -213,39 +222,48 @@ proto._stop = function stop() {
213
222
  proto._getTimers = function getTimers(executeMessage) {
214
223
  const content = executeMessage.content;
215
224
  const now = Date.now();
216
- const result = { ...('expireAt' in content ? {
225
+ const result = { ...('expireAt' in content && {
217
226
  expireAt: new Date(content.expireAt)
218
- } : undefined)
227
+ })
219
228
  };
220
229
 
221
230
  for (const t of ['timeDuration', 'timeDate', 'timeCycle']) {
222
231
  if (t in content) result[t] = content[t];else if (t in this) result[t] = this.environment.resolveExpression(this[t], executeMessage);else continue;
223
- let expireAtDate;
224
-
225
- if (t === 'timeDuration') {
226
- const durationStr = result[t];
227
-
228
- if (durationStr) {
229
- const delay = this._getDurationInMilliseconds(durationStr);
230
-
231
- if (delay !== undefined) expireAtDate = new Date(now + delay);
232
- } else {
233
- expireAtDate = new Date(now);
234
- }
235
- } else if (t === 'timeDate') {
236
- const dateStr = result[t];
237
-
238
- if (dateStr) {
239
- const ms = Date.parse(dateStr);
240
-
241
- if (!isNaN(ms)) {
242
- expireAtDate = new Date(ms);
243
- } else {
244
- this._warn(`invalid timeDate >${dateStr}<`);
245
- }
246
- } else {
247
- expireAtDate = new Date(now);
232
+ let expireAtDate, repeat;
233
+ const timerStr = result[t];
234
+
235
+ if (timerStr) {
236
+ switch (t) {
237
+ case 'timeCycle':
238
+ {
239
+ const mRepeat = timerStr.match(repeatPattern);
240
+ if (mRepeat && mRepeat.length) repeat = parseInt(mRepeat[1]);
241
+ }
242
+
243
+ case 'timeDuration':
244
+ {
245
+ const delay = this._getDurationInMilliseconds(timerStr);
246
+
247
+ if (delay !== undefined) expireAtDate = new Date(now + delay);
248
+ break;
249
+ }
250
+
251
+ case 'timeDate':
252
+ {
253
+ const dateStr = result[t];
254
+ const ms = Date.parse(dateStr);
255
+
256
+ if (!isNaN(ms)) {
257
+ expireAtDate = new Date(ms);
258
+ } else {
259
+ this._warn(`invalid timeDate >${dateStr}<`);
260
+ }
261
+
262
+ break;
263
+ }
248
264
  }
265
+ } else {
266
+ expireAtDate = new Date(now);
249
267
  }
250
268
 
251
269
  if (!expireAtDate) continue;
@@ -253,6 +271,7 @@ proto._getTimers = function getTimers(executeMessage) {
253
271
  if (!('expireAt' in result) || result.expireAt > expireAtDate) {
254
272
  result.timerType = t;
255
273
  result.expireAt = expireAtDate;
274
+ if (repeat) result.repeat = repeat;
256
275
  }
257
276
  }
258
277
 
@@ -264,6 +283,10 @@ proto._getTimers = function getTimers(executeMessage) {
264
283
  result.timeout = 0;
265
284
  }
266
285
 
286
+ if (content.inbound && 'repeat' in content.inbound[0]) {
287
+ result.repeat = content.inbound[0].repeat;
288
+ }
289
+
267
290
  return result;
268
291
  };
269
292
 
@@ -271,7 +294,7 @@ proto._getDurationInMilliseconds = function getDurationInMilliseconds(duration)
271
294
  try {
272
295
  return (0, _iso8601Duration.toSeconds)((0, _iso8601Duration.parse)(duration)) * 1000;
273
296
  } catch (err) {
274
- this._warn(`failed to parse timeDuration >${duration}<: ${err.message}`);
297
+ this._warn(`failed to parse ${this.timerType} >${duration}<: ${err.message}`);
275
298
  }
276
299
  };
277
300