bpmn-elements 6.0.1 → 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.
- package/CHANGELOG.md +322 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +169 -175
- package/dist/src/Environment.js +90 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/activity/Activity.js +1106 -916
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +722 -409
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +433 -359
- package/dist/src/process/ProcessExecution.js +744 -645
- package/dist/src/shared.js +2 -2
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +195 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +13 -13
- package/src/Api.js +65 -59
- package/src/Context.js +138 -141
- package/src/Environment.js +88 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +915 -775
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +436 -401
- package/src/definition/DefinitionExecution.js +603 -343
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +16 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +374 -333
- package/src/process/ProcessExecution.js +606 -554
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- 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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(proto, 'stopped', {
|
|
44
|
+
enumerable: true,
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
115
|
+
proto._completed = function completed(completeContent, options) {
|
|
116
|
+
this._stop();
|
|
68
117
|
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
broker.cancel(`_api-${executionId}`);
|
|
185
|
-
broker.cancel(`_api-delegated-${executionId}`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
182
|
+
case 'stop':
|
|
183
|
+
{
|
|
184
|
+
this._stop();
|
|
188
185
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
let expireAt;
|
|
186
|
+
return this._debug('stopped');
|
|
187
|
+
}
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
case 'discard':
|
|
190
|
+
{
|
|
191
|
+
this._stop();
|
|
196
192
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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 (
|
|
228
|
+
if (durationStr) {
|
|
229
|
+
const delay = this._getDurationInMilliseconds(durationStr);
|
|
239
230
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
251
|
+
if (!expireAtDate) continue;
|
|
260
252
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
+
};
|