bpmn-elements 5.1.3 → 7.0.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 (119) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +9 -3
  3. package/dist/index.js +71 -39
  4. package/dist/src/Api.js +77 -76
  5. package/dist/src/Context.js +169 -164
  6. package/dist/src/Environment.js +90 -102
  7. package/dist/src/EventBroker.js +89 -88
  8. package/dist/src/ExtensionsMapper.js +2 -2
  9. package/dist/src/MessageFormatter.js +164 -95
  10. package/dist/src/Scripts.js +6 -2
  11. package/dist/src/Timers.js +4 -6
  12. package/dist/src/activity/Activity.js +1108 -901
  13. package/dist/src/activity/ActivityExecution.js +342 -297
  14. package/dist/src/activity/Dummy.js +3 -3
  15. package/dist/src/definition/Definition.js +498 -444
  16. package/dist/src/definition/DefinitionExecution.js +722 -409
  17. package/dist/src/error/Errors.js +17 -7
  18. package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
  19. package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
  20. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
  21. package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
  22. package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
  23. package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
  24. package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
  25. package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
  26. package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
  27. package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
  28. package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
  29. package/dist/src/events/BoundaryEvent.js +180 -144
  30. package/dist/src/events/EndEvent.js +18 -23
  31. package/dist/src/events/IntermediateCatchEvent.js +44 -58
  32. package/dist/src/events/IntermediateThrowEvent.js +18 -23
  33. package/dist/src/events/StartEvent.js +109 -94
  34. package/dist/src/flows/Association.js +94 -101
  35. package/dist/src/flows/MessageFlow.js +86 -103
  36. package/dist/src/flows/SequenceFlow.js +172 -184
  37. package/dist/src/gateways/EventBasedGateway.js +88 -84
  38. package/dist/src/gateways/ExclusiveGateway.js +13 -16
  39. package/dist/src/gateways/InclusiveGateway.js +11 -14
  40. package/dist/src/gateways/ParallelGateway.js +11 -14
  41. package/dist/src/getPropertyValue.js +34 -34
  42. package/dist/src/io/BpmnIO.js +31 -0
  43. package/dist/src/io/EnvironmentDataObject.js +33 -29
  44. package/dist/src/io/EnvironmentDataStore.js +52 -0
  45. package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
  46. package/dist/src/io/InputOutputSpecification.js +177 -168
  47. package/dist/src/io/Properties.js +252 -0
  48. package/dist/src/messageHelper.js +1 -1
  49. package/dist/src/process/Process.js +433 -359
  50. package/dist/src/process/ProcessExecution.js +744 -645
  51. package/dist/src/shared.js +3 -6
  52. package/dist/src/tasks/CallActivity.js +160 -0
  53. package/dist/src/tasks/LoopCharacteristics.js +309 -330
  54. package/dist/src/tasks/ReceiveTask.js +233 -182
  55. package/dist/src/tasks/ScriptTask.js +35 -41
  56. package/dist/src/tasks/ServiceImplementation.js +13 -20
  57. package/dist/src/tasks/ServiceTask.js +82 -75
  58. package/dist/src/tasks/SignalTask.js +97 -93
  59. package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
  60. package/dist/src/tasks/SubProcess.js +195 -175
  61. package/dist/src/tasks/Task.js +17 -19
  62. package/index.js +8 -0
  63. package/package.json +16 -15
  64. package/src/Api.js +65 -59
  65. package/src/Context.js +142 -132
  66. package/src/Environment.js +88 -100
  67. package/src/EventBroker.js +67 -68
  68. package/src/ExtensionsMapper.js +2 -2
  69. package/src/MessageFormatter.js +132 -74
  70. package/src/Timers.js +4 -4
  71. package/src/activity/Activity.js +916 -757
  72. package/src/activity/ActivityExecution.js +293 -247
  73. package/src/activity/Dummy.js +2 -2
  74. package/src/definition/Definition.js +436 -401
  75. package/src/definition/DefinitionExecution.js +603 -343
  76. package/src/error/Errors.js +11 -6
  77. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  78. package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
  79. package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
  80. package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
  81. package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
  82. package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
  83. package/src/eventDefinitions/LinkEventDefinition.js +160 -129
  84. package/src/eventDefinitions/MessageEventDefinition.js +178 -121
  85. package/src/eventDefinitions/SignalEventDefinition.js +162 -106
  86. package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
  87. package/src/eventDefinitions/TimerEventDefinition.js +202 -167
  88. package/src/events/BoundaryEvent.js +156 -115
  89. package/src/events/EndEvent.js +15 -18
  90. package/src/events/IntermediateCatchEvent.js +40 -44
  91. package/src/events/IntermediateThrowEvent.js +15 -18
  92. package/src/events/StartEvent.js +84 -50
  93. package/src/flows/Association.js +98 -113
  94. package/src/flows/MessageFlow.js +81 -97
  95. package/src/flows/SequenceFlow.js +145 -163
  96. package/src/gateways/EventBasedGateway.js +75 -68
  97. package/src/gateways/ExclusiveGateway.js +8 -13
  98. package/src/gateways/InclusiveGateway.js +8 -13
  99. package/src/gateways/ParallelGateway.js +8 -13
  100. package/src/getPropertyValue.js +34 -33
  101. package/src/io/BpmnIO.js +20 -0
  102. package/src/io/EnvironmentDataObject.js +29 -18
  103. package/src/io/EnvironmentDataStore.js +33 -0
  104. package/src/io/EnvironmentDataStoreReference.js +33 -0
  105. package/src/io/InputOutputSpecification.js +154 -157
  106. package/src/io/Properties.js +199 -0
  107. package/src/process/Process.js +374 -333
  108. package/src/process/ProcessExecution.js +606 -554
  109. package/src/shared.js +1 -5
  110. package/src/tasks/CallActivity.js +130 -0
  111. package/src/tasks/LoopCharacteristics.js +290 -289
  112. package/src/tasks/ReceiveTask.js +174 -107
  113. package/src/tasks/ScriptTask.js +27 -30
  114. package/src/tasks/ServiceImplementation.js +13 -18
  115. package/src/tasks/ServiceTask.js +67 -60
  116. package/src/tasks/SignalTask.js +77 -52
  117. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  118. package/src/tasks/SubProcess.js +184 -157
  119. package/src/tasks/Task.js +15 -19
@@ -9,261 +9,276 @@ 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');
15
+
12
16
  function TimerEventDefinition(activity, eventDefinition) {
13
- const {
14
- id,
15
- broker,
16
- environment
17
- } = activity;
18
- const {
19
- type = 'TimerEventDefinition',
20
- behaviour = {}
21
- } = eventDefinition;
22
- const logger = environment.Logger(type.toLowerCase());
17
+ const type = this.type = eventDefinition.type || 'TimerEventDefinition';
18
+ this.activity = activity;
19
+ const environment = this.environment = activity.environment;
20
+ this.eventDefinition = eventDefinition;
23
21
  const {
24
22
  timeDuration,
25
23
  timeCycle,
26
24
  timeDate
27
- } = behaviour;
28
- const foundTimers = { ...(timeDuration ? {
29
- timeDuration
30
- } : undefined),
31
- ...(timeCycle ? {
32
- timeCycle
33
- } : undefined),
34
- ...(timeDate ? {
35
- timeDate
36
- } : undefined)
37
- };
38
- let stopped = false;
39
- let timerRef;
40
- const source = {
41
- type,
42
- ...foundTimers,
43
- execute,
25
+ } = eventDefinition.behaviour || {};
26
+ if (timeDuration) this.timeDuration = timeDuration;
27
+ if (timeCycle) this.timeCycle = timeCycle;
28
+ if (timeDate) this.timeDate = timeDate;
29
+ this.broker = activity.broker;
30
+ this.logger = environment.Logger(type.toLowerCase());
31
+ this[stoppedSymbol] = false;
32
+ this[timerSymbol] = null;
33
+ }
34
+
35
+ const proto = TimerEventDefinition.prototype;
36
+ Object.defineProperty(proto, 'executionId', {
37
+ get() {
38
+ const content = this[timerContentSymbol];
39
+ return content && content.executionId;
40
+ }
44
41
 
45
- stop() {
46
- if (timerRef) timerRef = environment.timers.clearTimeout(timerRef);
47
- }
42
+ });
43
+ Object.defineProperty(proto, 'stopped', {
44
+ enumerable: true,
48
45
 
49
- };
50
- Object.defineProperty(source, 'timer', {
51
- get() {
52
- return timerRef;
53
- }
46
+ get() {
47
+ return this[stoppedSymbol];
48
+ }
49
+
50
+ });
51
+ Object.defineProperty(proto, 'timer', {
52
+ enumerable: true,
54
53
 
54
+ get() {
55
+ return this[timerSymbol];
56
+ }
57
+
58
+ });
59
+
60
+ proto.execute = function execute(executeMessage) {
61
+ const {
62
+ routingKey: executeKey,
63
+ redelivered: isResumed
64
+ } = executeMessage.fields;
65
+ const timer = this[timerSymbol];
66
+
67
+ if (timer && executeKey === 'execute.timer') {
68
+ return;
69
+ }
70
+
71
+ if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
72
+ this[stoppedSymbol] = false;
73
+ const content = executeMessage.content;
74
+ const executionId = content.executionId;
75
+ const startedAt = this.startedAt = 'startedAt' in content ? new Date(content.startedAt) : new Date();
76
+
77
+ const resolvedTimer = this._getTimers(executeMessage);
78
+
79
+ const timerContent = this[timerContentSymbol] = (0, _messageHelper.cloneContent)(content, { ...resolvedTimer,
80
+ ...(isResumed ? {
81
+ isResumed
82
+ } : undefined),
83
+ startedAt,
84
+ state: 'timer'
85
+ });
86
+ const broker = this.broker;
87
+ broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
88
+ noAck: true,
89
+ consumerTag: `_api-${executionId}`,
90
+ priority: 400
55
91
  });
56
- return source;
92
+ broker.subscribeTmp('api', '#.cancel.*', this._onDelegatedApiMessage.bind(this), {
93
+ noAck: true,
94
+ consumerTag: `_api-delegated-${executionId}`
95
+ });
96
+ broker.publish('execution', 'execute.timer', (0, _messageHelper.cloneContent)(timerContent));
97
+ broker.publish('event', 'activity.timer', (0, _messageHelper.cloneContent)(timerContent));
98
+ if (this.stopped) return;
99
+ if (timerContent.timeout === undefined) return this._debug(`waiting for ${timerContent.timerType || 'signal'}`);
100
+ if (timerContent.timeout <= 0) return this._completed();
101
+ const timers = this.environment.timers.register(timerContent);
102
+ this[timerSymbol] = timers.setTimeout(this._completed.bind(this), timerContent.timeout, {
103
+ id: content.id,
104
+ type: this.type,
105
+ executionId,
106
+ state: 'timeout'
107
+ });
108
+ };
57
109
 
58
- function execute(executeMessage) {
59
- const {
60
- routingKey: executeKey,
61
- redelivered: isResumed
62
- } = executeMessage.fields;
63
- const running = !!timerRef;
110
+ proto.stop = function stopTimer() {
111
+ const timer = this[timerSymbol];
112
+ if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
113
+ };
64
114
 
65
- if (running && executeKey === 'execute.timer') {
66
- return;
67
- }
115
+ proto._completed = function completed(completeContent, options) {
116
+ this._stop();
68
117
 
69
- if (timerRef) timerRef = environment.timers.clearTimeout(timerRef);
70
- stopped = false;
71
- const {
72
- executionId
73
- } = executeMessage.content;
74
- const messageContent = executeMessage.content;
75
- const startedAt = 'startedAt' in messageContent ? new Date(messageContent.startedAt) : new Date();
76
- const resolvedTimer = getTimers(foundTimers, executeMessage);
77
- const timerContent = (0, _messageHelper.cloneContent)(messageContent, { ...resolvedTimer,
78
- ...(isResumed ? {
79
- isResumed
80
- } : undefined),
81
- startedAt,
82
- state: 'timer'
83
- });
84
- broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
85
- noAck: true,
86
- consumerTag: `_api-${executionId}`,
87
- priority: 400
88
- });
89
- broker.subscribeTmp('api', '#.cancel.*', onDelegatedApiMessage, {
90
- noAck: true,
91
- consumerTag: `_api-delegated-${executionId}`
92
- });
93
- broker.publish('execution', 'execute.timer', timerContent);
94
- broker.publish('event', 'activity.timer', (0, _messageHelper.cloneContent)(timerContent));
95
- if (stopped) return;
96
- if (timerContent.timeout === undefined) return logger.debug(`<${executionId} (${id})> waiting for ${timerContent.timerType || 'signal'}`);
97
- if (timerContent.timeout <= 0) return completed();
98
- const timers = environment.timers.register(timerContent);
99
- timerRef = timers.setTimeout(completed, timerContent.timeout, (0, _messageHelper.cloneMessage)(executeMessage, timerContent));
100
-
101
- function completed(completeContent, options) {
102
- stop();
103
- const stoppedAt = new Date();
104
- const runningTime = stoppedAt.getTime() - startedAt.getTime();
105
- logger.debug(`<${executionId} (${id})> completed in ${runningTime}ms`);
106
- const completedContent = { ...timerContent,
107
- stoppedAt,
108
- runningTime,
109
- state: 'timeout',
110
- ...completeContent
111
- };
112
- broker.publish('event', 'activity.timeout', (0, _messageHelper.cloneContent)(messageContent, completedContent), options);
113
- broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(messageContent, completedContent), options);
114
- }
118
+ const stoppedAt = new Date();
119
+ const runningTime = stoppedAt.getTime() - this.startedAt.getTime();
115
120
 
116
- function onDelegatedApiMessage(routingKey, message) {
117
- if (!message.properties.delegate) return;
118
- const {
119
- content: delegateContent
120
- } = message;
121
- if (!delegateContent.message) return;
122
- const {
123
- id: signalId,
124
- executionId: signalExecutionId
125
- } = delegateContent.message;
126
- if (signalId !== id && signalExecutionId !== executionId) return;
127
- if (signalExecutionId && signalId === id && signalExecutionId !== executionId) return;
128
- const {
129
- type: messageType,
130
- correlationId
131
- } = message.properties;
132
- broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(timerContent, {
133
- message: { ...delegateContent.message
134
- }
135
- }), {
136
- correlationId,
137
- type: messageType
138
- });
139
- return onApiMessage(routingKey, message);
121
+ this._debug(`completed in ${runningTime}ms`);
122
+
123
+ const timerContent = this[timerContentSymbol];
124
+ const content = {
125
+ stoppedAt,
126
+ runningTime,
127
+ state: 'timeout',
128
+ ...completeContent
129
+ };
130
+ const broker = this.broker;
131
+ broker.publish('event', 'activity.timeout', (0, _messageHelper.cloneContent)(timerContent, content), options);
132
+ broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(timerContent, content), options);
133
+ };
134
+
135
+ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, message) {
136
+ if (!message.properties.delegate) return;
137
+ const content = message.content;
138
+ if (!content.message) return;
139
+ const {
140
+ id: signalId,
141
+ executionId: signalExecutionId
142
+ } = content.message;
143
+ const executionId = this.executionId;
144
+ const id = this.activity.id;
145
+ if (signalId !== id && signalExecutionId !== executionId) return;
146
+ if (signalExecutionId && signalId === id && signalExecutionId !== executionId) return;
147
+ const {
148
+ type,
149
+ correlationId
150
+ } = message.properties;
151
+ this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[timerContentSymbol], {
152
+ message: { ...content.message
140
153
  }
154
+ }), {
155
+ correlationId,
156
+ type
157
+ });
158
+ return this._onApiMessage(routingKey, message);
159
+ };
141
160
 
142
- function onApiMessage(routingKey, message) {
143
- const {
144
- type: messageType,
145
- correlationId
146
- } = message.properties;
147
-
148
- switch (messageType) {
149
- case 'cancel':
150
- {
151
- stop();
152
- return completed({
153
- state: 'cancel',
154
- ...(message.content.message ? {
155
- message: message.content.message
156
- } : undefined)
157
- }, {
158
- correlationId
159
- });
160
- }
161
-
162
- case 'stop':
163
- {
164
- stop();
165
- return logger.debug(`<${executionId} (${id})> stopped`);
166
- }
167
-
168
- case 'discard':
169
- {
170
- stop();
171
- logger.debug(`<${executionId} (${id})> discarded`);
172
- return broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(timerContent, {
173
- state: 'discard'
174
- }), {
175
- correlationId
176
- });
177
- }
161
+ proto._onApiMessage = function onApiMessage(routingKey, message) {
162
+ const {
163
+ type: messageType,
164
+ correlationId
165
+ } = message.properties;
166
+
167
+ switch (messageType) {
168
+ case 'cancel':
169
+ {
170
+ this._stop();
171
+
172
+ return this._completed({
173
+ state: 'cancel',
174
+ ...(message.content.message ? {
175
+ message: message.content.message
176
+ } : undefined)
177
+ }, {
178
+ correlationId
179
+ });
178
180
  }
179
- }
180
181
 
181
- function stop() {
182
- stopped = true;
183
- if (timerRef) timerRef = environment.timers.clearTimeout(timerRef);
184
- broker.cancel(`_api-${executionId}`);
185
- broker.cancel(`_api-delegated-${executionId}`);
186
- }
187
- }
182
+ case 'stop':
183
+ {
184
+ this._stop();
188
185
 
189
- function getTimers(timers, executionMessage) {
190
- const content = executionMessage.content;
191
- let expireAt;
186
+ return this._debug('stopped');
187
+ }
192
188
 
193
- if ('expireAt' in content) {
194
- expireAt = new Date(content.expireAt);
195
- }
189
+ case 'discard':
190
+ {
191
+ this._stop();
196
192
 
197
- const now = Date.now();
198
- const timerContent = ['timeDuration', 'timeDate', 'timeCycle'].reduce((result, t) => {
199
- if (t in content) result[t] = content[t];else if (t in timers) result[t] = environment.resolveExpression(timers[t], executionMessage);else return result;
200
- let expireAtDate;
201
-
202
- switch (t) {
203
- case 'timeDuration':
204
- {
205
- const durationStr = result[t];
206
-
207
- if (durationStr) {
208
- const delay = getDurationInMilliseconds(durationStr);
209
- if (delay !== undefined) expireAtDate = new Date(now + delay);
210
- } else {
211
- expireAtDate = new Date(now);
212
- }
213
-
214
- break;
215
- }
216
-
217
- case 'timeDate':
218
- {
219
- const dateStr = result[t];
220
-
221
- if (dateStr) {
222
- const ms = Date.parse(dateStr);
223
-
224
- if (isNaN(ms)) {
225
- logger.warn(`<${content.executionId} (${id})> invalid timeDate >${dateStr}<`);
226
- break;
227
- }
228
-
229
- expireAtDate = new Date(ms);
230
- } else {
231
- expireAtDate = new Date(now);
232
- }
233
-
234
- break;
235
- }
193
+ this._debug('discarded');
194
+
195
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[timerContentSymbol], {
196
+ state: 'discard'
197
+ }), {
198
+ correlationId
199
+ });
236
200
  }
201
+ }
202
+ };
203
+
204
+ proto._stop = function stop() {
205
+ this[stoppedSymbol] = true;
206
+ const timer = this[timerSymbol];
207
+ if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
208
+ const broker = this.broker;
209
+ broker.cancel(`_api-${this.executionId}`);
210
+ broker.cancel(`_api-delegated-${this.executionId}`);
211
+ };
212
+
213
+ proto._getTimers = function getTimers(executeMessage) {
214
+ const content = executeMessage.content;
215
+ const now = Date.now();
216
+ const result = { ...('expireAt' in content ? {
217
+ expireAt: new Date(content.expireAt)
218
+ } : undefined)
219
+ };
220
+
221
+ for (const t of ['timeDuration', 'timeDate', 'timeCycle']) {
222
+ 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];
237
227
 
238
- if (!expireAtDate) return result;
228
+ if (durationStr) {
229
+ const delay = this._getDurationInMilliseconds(durationStr);
239
230
 
240
- if (!('expireAt' in result) || result.expireAt > expireAtDate) {
241
- result.timerType = t;
242
- result.expireAt = expireAtDate;
231
+ if (delay !== undefined) expireAtDate = new Date(now + delay);
232
+ } else {
233
+ expireAtDate = new Date(now);
243
234
  }
235
+ } else if (t === 'timeDate') {
236
+ const dateStr = result[t];
244
237
 
245
- return result;
246
- }, { ...(expireAt ? {
247
- expireAt
248
- } : undefined)
249
- });
250
-
251
- if ('expireAt' in timerContent) {
252
- timerContent.timeout = timerContent.expireAt - now;
253
- } else if ('timeout' in content) {
254
- timerContent.timeout = content.timeout;
255
- } else if (!Object.keys(timerContent).length) {
256
- timerContent.timeout = 0;
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);
248
+ }
257
249
  }
258
250
 
259
- return timerContent;
251
+ if (!expireAtDate) continue;
260
252
 
261
- function getDurationInMilliseconds(duration) {
262
- try {
263
- return (0, _iso8601Duration.toSeconds)((0, _iso8601Duration.parse)(duration)) * 1000;
264
- } catch (err) {
265
- logger.warn(`<${content.executionId} (${id})> failed to parse timeDuration >${duration}<: ${err.message}`);
266
- }
253
+ if (!('expireAt' in result) || result.expireAt > expireAtDate) {
254
+ result.timerType = t;
255
+ result.expireAt = expireAtDate;
267
256
  }
268
257
  }
269
- }
258
+
259
+ if ('expireAt' in result) {
260
+ result.timeout = result.expireAt - now;
261
+ } else if ('timeout' in content) {
262
+ result.timeout = content.timeout;
263
+ } else if (!Object.keys(result).length) {
264
+ result.timeout = 0;
265
+ }
266
+
267
+ return result;
268
+ };
269
+
270
+ proto._getDurationInMilliseconds = function getDurationInMilliseconds(duration) {
271
+ try {
272
+ return (0, _iso8601Duration.toSeconds)((0, _iso8601Duration.parse)(duration)) * 1000;
273
+ } catch (err) {
274
+ this._warn(`failed to parse timeDuration >${duration}<: ${err.message}`);
275
+ }
276
+ };
277
+
278
+ proto._debug = function debug(msg) {
279
+ this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
280
+ };
281
+
282
+ proto._warn = function debug(msg) {
283
+ this.logger.warn(`<${this.executionId} (${this.activity.id})> ${msg}`);
284
+ };