bpmn-elements 8.0.1 → 8.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.
- package/CHANGELOG.md +10 -0
- package/dist/src/Context.js +8 -2
- package/dist/src/ExtensionsMapper.js +40 -40
- package/dist/src/activity/Activity.js +40 -67
- package/dist/src/activity/ActivityExecution.js +2 -2
- package/dist/src/activity/Message.js +2 -2
- package/dist/src/activity/Signal.js +2 -2
- package/dist/src/eventDefinitions/TimerEventDefinition.js +55 -32
- package/dist/src/events/BoundaryEvent.js +48 -19
- package/dist/src/io/BpmnIO.js +8 -0
- package/dist/src/io/InputOutputSpecification.js +22 -8
- package/dist/src/io/Properties.js +10 -9
- package/dist/src/tasks/ServiceTask.js +1 -5
- package/package.json +8 -9
- package/src/Context.js +7 -2
- package/src/ExtensionsMapper.js +35 -35
- package/src/activity/Activity.js +30 -58
- package/src/activity/ActivityExecution.js +1 -1
- package/src/activity/Message.js +1 -1
- package/src/activity/Signal.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +40 -23
- package/src/events/BoundaryEvent.js +34 -17
- package/src/io/BpmnIO.js +7 -0
- package/src/io/EnvironmentDataObject.js +1 -0
- package/src/io/InputOutputSpecification.js +18 -6
- package/src/io/Properties.js +9 -11
- package/src/tasks/ServiceTask.js +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
# 8.2.0
|
|
5
|
+
|
|
6
|
+
- fix resume when activity has formatting status, extensions were not re-activated
|
|
7
|
+
- fix InputOutputSpecification output now passed as dataOutput instead of dataInput, as it should
|
|
8
|
+
- refactor Extensions loading, bpmn io is now pushed to the end of the extensions list
|
|
9
|
+
|
|
10
|
+
# 8.1.0
|
|
11
|
+
|
|
12
|
+
- support non-interrupting BoundaryEvent with ISO8601 repeating interval timeCycle
|
|
13
|
+
|
|
4
14
|
# 8.0.1
|
|
5
15
|
|
|
6
16
|
## Fix
|
package/dist/src/Context.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = Context;
|
|
7
7
|
|
|
8
|
+
var _BpmnIO = _interopRequireDefault(require("./io/BpmnIO"));
|
|
9
|
+
|
|
8
10
|
var _Environment = _interopRequireDefault(require("./Environment"));
|
|
9
11
|
|
|
10
12
|
var _ExtensionsMapper = _interopRequireDefault(require("./ExtensionsMapper"));
|
|
@@ -31,7 +33,7 @@ function ContextInstance(definitionContext, environment) {
|
|
|
31
33
|
this.sid = sid;
|
|
32
34
|
this.definitionContext = definitionContext;
|
|
33
35
|
this.environment = environment;
|
|
34
|
-
this.extensionsMapper =
|
|
36
|
+
this.extensionsMapper = new _ExtensionsMapper.default(this);
|
|
35
37
|
this.refs = {
|
|
36
38
|
activityRefs: {},
|
|
37
39
|
associationRefs: [],
|
|
@@ -204,5 +206,9 @@ proto.getStartActivities = function getStartActivities(filterOptions, scopeId) {
|
|
|
204
206
|
};
|
|
205
207
|
|
|
206
208
|
proto.loadExtensions = function loadExtensions(activity) {
|
|
207
|
-
|
|
209
|
+
const io = new _BpmnIO.default(activity, this);
|
|
210
|
+
const extensions = this.extensionsMapper.get(activity);
|
|
211
|
+
if (io.hasIo) extensions.extensions.push(io);
|
|
212
|
+
if (!extensions.extensions.length) return;
|
|
213
|
+
return extensions;
|
|
208
214
|
};
|
|
@@ -4,50 +4,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = ExtensionsMapper;
|
|
7
|
+
const kActivated = Symbol.for('activated');
|
|
7
8
|
|
|
8
9
|
function ExtensionsMapper(context) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} = context.environment;
|
|
12
|
-
const extensions = getExtensions();
|
|
13
|
-
return {
|
|
14
|
-
get
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
function get(activity) {
|
|
18
|
-
const activityExtensions = extensions.reduce(applyExtension, []);
|
|
19
|
-
return {
|
|
20
|
-
activate,
|
|
21
|
-
deactivate
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function applyExtension(result, Extension) {
|
|
25
|
-
const extension = Extension(activity, context);
|
|
26
|
-
if (extension) result.push(extension);
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function activate(message) {
|
|
31
|
-
for (const extension of activityExtensions) extension.activate(message);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function deactivate(message) {
|
|
35
|
-
for (const extension of activityExtensions) extension.deactivate(message);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
10
|
+
this.context = context;
|
|
11
|
+
}
|
|
38
12
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
ExtensionsMapper.prototype.get = function get(activity) {
|
|
14
|
+
return new Extensions(activity, this.context, this._getExtensions());
|
|
15
|
+
};
|
|
42
16
|
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
ExtensionsMapper.prototype._getExtensions = function getExtensions() {
|
|
18
|
+
let extensions;
|
|
19
|
+
if (!(extensions = this.context.environment.extensions)) return [];
|
|
20
|
+
return Object.values(extensions);
|
|
21
|
+
};
|
|
45
22
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
23
|
+
function Extensions(activity, context, extensions) {
|
|
24
|
+
const result = this.extensions = [];
|
|
50
25
|
|
|
51
|
-
|
|
26
|
+
for (const Extension of extensions) {
|
|
27
|
+
const extension = Extension(activity, context);
|
|
28
|
+
if (extension) result.push(extension);
|
|
52
29
|
}
|
|
53
|
-
|
|
30
|
+
|
|
31
|
+
this[kActivated] = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Object.defineProperty(Extensions.prototype, 'count', {
|
|
35
|
+
get() {
|
|
36
|
+
return this.extensions.length;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
Extensions.prototype.activate = function activate(message) {
|
|
42
|
+
if (this[kActivated]) return;
|
|
43
|
+
this[kActivated] = true;
|
|
44
|
+
|
|
45
|
+
for (const extension of this.extensions) extension.activate(message);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Extensions.prototype.deactivate = function deactivate(message) {
|
|
49
|
+
if (!this[kActivated]) return;
|
|
50
|
+
this[kActivated] = false;
|
|
51
|
+
|
|
52
|
+
for (const extension of this.extensions) extension.deactivate(message);
|
|
53
|
+
};
|
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _ActivityExecution = _interopRequireDefault(require("./ActivityExecution"));
|
|
9
9
|
|
|
10
|
-
var _BpmnIO = _interopRequireDefault(require("../io/BpmnIO"));
|
|
11
|
-
|
|
12
10
|
var _shared = require("../shared");
|
|
13
11
|
|
|
14
12
|
var _Api = require("../Api");
|
|
@@ -24,7 +22,6 @@ var _Errors = require("../error/Errors");
|
|
|
24
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
23
|
|
|
26
24
|
const kActivityDef = Symbol.for('activityDefinition');
|
|
27
|
-
const kBpmnIo = Symbol.for('bpmnIo');
|
|
28
25
|
const kConsuming = Symbol.for('consuming');
|
|
29
26
|
const kCounters = Symbol.for('counters');
|
|
30
27
|
const kEventDefinitions = Symbol.for('eventDefinitions');
|
|
@@ -145,6 +142,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
|
|
145
|
+
this[kExtensions] = context.loadExtensions(this);
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
const proto = Activity.prototype;
|
|
@@ -173,23 +171,20 @@ Object.defineProperty(proto, 'executionId', {
|
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
});
|
|
176
|
-
Object.defineProperty(proto, '
|
|
174
|
+
Object.defineProperty(proto, 'extensions', {
|
|
177
175
|
enumerable: true,
|
|
178
176
|
|
|
179
177
|
get() {
|
|
180
|
-
|
|
181
|
-
const bpmnIo = this[kBpmnIo] = new _BpmnIO.default(this, this.context);
|
|
182
|
-
return bpmnIo;
|
|
178
|
+
return this[kExtensions];
|
|
183
179
|
}
|
|
184
180
|
|
|
185
181
|
});
|
|
186
|
-
Object.defineProperty(proto, '
|
|
182
|
+
Object.defineProperty(proto, 'bpmnIo', {
|
|
187
183
|
enumerable: true,
|
|
188
184
|
|
|
189
185
|
get() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return extensions;
|
|
186
|
+
const extensions = this[kExtensions];
|
|
187
|
+
return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
});
|
|
@@ -485,10 +480,11 @@ proto._discardRun = function discardRun() {
|
|
|
485
480
|
|
|
486
481
|
this._deactivateRunConsumers();
|
|
487
482
|
|
|
488
|
-
|
|
483
|
+
const message = this[kStateMessage];
|
|
484
|
+
if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(message));
|
|
489
485
|
const broker = this.broker;
|
|
490
486
|
broker.getQueue('run-q').purge();
|
|
491
|
-
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(
|
|
487
|
+
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(message.content));
|
|
492
488
|
|
|
493
489
|
this._consumeRunQ();
|
|
494
490
|
};
|
|
@@ -543,6 +539,7 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
543
539
|
switch (routingKey) {
|
|
544
540
|
case 'association.take':
|
|
545
541
|
case 'flow.take':
|
|
542
|
+
case 'activity.restart':
|
|
546
543
|
case 'activity.enter':
|
|
547
544
|
return this.run({
|
|
548
545
|
message: content.message,
|
|
@@ -719,13 +716,13 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
719
716
|
|
|
720
717
|
if (!isRedelivered) {
|
|
721
718
|
this[kExec].execution = null;
|
|
719
|
+
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message));
|
|
720
|
+
|
|
721
|
+
this._publishEvent('enter', content, {
|
|
722
|
+
correlationId
|
|
723
|
+
});
|
|
722
724
|
}
|
|
723
725
|
|
|
724
|
-
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message), this);
|
|
725
|
-
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
726
|
-
if (!isRedelivered) this._publishEvent('enter', content, {
|
|
727
|
-
correlationId
|
|
728
|
-
});
|
|
729
726
|
break;
|
|
730
727
|
}
|
|
731
728
|
|
|
@@ -734,8 +731,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
734
731
|
this.logger.debug(`<${id}> discard`, isRedelivered ? 'redelivered' : '');
|
|
735
732
|
this.status = 'discard';
|
|
736
733
|
this[kExec].execution = null;
|
|
737
|
-
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message)
|
|
738
|
-
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
734
|
+
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message));
|
|
739
735
|
|
|
740
736
|
if (!isRedelivered) {
|
|
741
737
|
this.broker.publish('run', 'run.discarded', content, {
|
|
@@ -780,28 +776,20 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
780
776
|
{
|
|
781
777
|
this.status = 'executing';
|
|
782
778
|
this[kExecuteMessage] = message;
|
|
779
|
+
const exec = this[kExec];
|
|
780
|
+
if (isRedelivered && this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message));
|
|
781
|
+
if (!exec.execution) exec.execution = new _ActivityExecution.default(this, this.context);
|
|
783
782
|
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
|
|
784
783
|
exclusive: true,
|
|
785
784
|
consumerTag: '_activity-execution'
|
|
786
785
|
});
|
|
787
|
-
const exec = this[kExec];
|
|
788
|
-
if (!exec.execution) exec.execution = new _ActivityExecution.default(this, this.context);
|
|
789
|
-
|
|
790
|
-
if (isRedelivered) {
|
|
791
|
-
return this._resumeExtensions(message, (err, formattedContent) => {
|
|
792
|
-
if (err) return this.emitFatal(err, message.content);
|
|
793
|
-
if (formattedContent) message.content = formattedContent;
|
|
794
|
-
this.status = 'executing';
|
|
795
|
-
return exec.execution.execute(message);
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
|
|
799
786
|
return exec.execution.execute(message);
|
|
800
787
|
}
|
|
801
788
|
|
|
802
789
|
case 'run.end':
|
|
803
790
|
{
|
|
804
|
-
|
|
791
|
+
this.logger.debug(`<${id}> end`, isRedelivered ? 'redelivered' : '');
|
|
792
|
+
if (isRedelivered) break;
|
|
805
793
|
this[kCounters].taken++;
|
|
806
794
|
this.status = 'end';
|
|
807
795
|
return this._doRunLeave(message, false, () => {
|
|
@@ -859,8 +847,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
859
847
|
case 'run.leave':
|
|
860
848
|
{
|
|
861
849
|
this.status = undefined;
|
|
862
|
-
if (this.
|
|
863
|
-
if (this.extensions) this.extensions.deactivate(message);
|
|
850
|
+
if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(message));
|
|
864
851
|
|
|
865
852
|
if (!isRedelivered) {
|
|
866
853
|
this.broker.publish('run', 'run.next', content, {
|
|
@@ -976,9 +963,9 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
976
963
|
});
|
|
977
964
|
}
|
|
978
965
|
|
|
979
|
-
this.broker.publish('run', 'run.leave', (0, _messageHelper.cloneContent)(content, { ...(outbound.length
|
|
966
|
+
this.broker.publish('run', 'run.leave', (0, _messageHelper.cloneContent)(content, { ...(outbound.length && {
|
|
980
967
|
outbound
|
|
981
|
-
}
|
|
968
|
+
})
|
|
982
969
|
}), {
|
|
983
970
|
correlationId
|
|
984
971
|
});
|
|
@@ -1030,9 +1017,9 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
1030
1017
|
this.broker.publish('run', 'run.outbound.' + action, (0, _messageHelper.cloneContent)(content, {
|
|
1031
1018
|
flow: { ...outboundFlow,
|
|
1032
1019
|
sequenceId: (0, _shared.getUniqueId)(`${flowId}_${action}`),
|
|
1033
|
-
...(discardSequence
|
|
1020
|
+
...(discardSequence && {
|
|
1034
1021
|
discardSequence: discardSequence.slice()
|
|
1035
|
-
}
|
|
1022
|
+
})
|
|
1036
1023
|
}
|
|
1037
1024
|
}));
|
|
1038
1025
|
}
|
|
@@ -1043,9 +1030,8 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
1043
1030
|
proto._onResumeMessage = function onResumeMessage(message) {
|
|
1044
1031
|
message.ack();
|
|
1045
1032
|
const stateMessage = this[kStateMessage];
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1048
|
-
} = stateMessage;
|
|
1033
|
+
const fields = stateMessage.fields;
|
|
1034
|
+
if (!fields.redelivered) return;
|
|
1049
1035
|
|
|
1050
1036
|
switch (fields.routingKey) {
|
|
1051
1037
|
case 'run.enter':
|
|
@@ -1059,7 +1045,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
1059
1045
|
return;
|
|
1060
1046
|
}
|
|
1061
1047
|
|
|
1062
|
-
if (
|
|
1048
|
+
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(stateMessage));
|
|
1063
1049
|
this.logger.debug(`<${this.id}> resume from ${message.content.status}`);
|
|
1064
1050
|
return this.broker.publish('run', fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
|
|
1065
1051
|
};
|
|
@@ -1086,7 +1072,7 @@ proto._onStop = function onStop(message) {
|
|
|
1086
1072
|
broker.cancel('_format-consumer');
|
|
1087
1073
|
|
|
1088
1074
|
if (running) {
|
|
1089
|
-
if (this.extensions) this.extensions.deactivate(message
|
|
1075
|
+
if (this.extensions) this.extensions.deactivate(message ? (0, _messageHelper.cloneMessage)(message) : this._createMessage());
|
|
1090
1076
|
|
|
1091
1077
|
this._publishEvent('stop', this._createMessage());
|
|
1092
1078
|
}
|
|
@@ -1130,15 +1116,15 @@ proto._createMessage = function createMessage(override) {
|
|
|
1130
1116
|
const result = { ...override,
|
|
1131
1117
|
id: this.id,
|
|
1132
1118
|
type: this.type,
|
|
1133
|
-
...(name
|
|
1119
|
+
...(name && {
|
|
1134
1120
|
name
|
|
1135
|
-
}
|
|
1136
|
-
...(status
|
|
1121
|
+
}),
|
|
1122
|
+
...(status && {
|
|
1137
1123
|
status
|
|
1138
|
-
}
|
|
1139
|
-
...(parent
|
|
1124
|
+
}),
|
|
1125
|
+
...(parent && {
|
|
1140
1126
|
parent: (0, _messageHelper.cloneParent)(parent)
|
|
1141
|
-
}
|
|
1127
|
+
})
|
|
1142
1128
|
};
|
|
1143
1129
|
|
|
1144
1130
|
for (const [flag, value] of Object.entries(this[kFlags])) {
|
|
@@ -1152,19 +1138,6 @@ proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId
|
|
|
1152
1138
|
return this[kFlows].outboundSequenceFlows.find(flow => flow.id === flowId);
|
|
1153
1139
|
};
|
|
1154
1140
|
|
|
1155
|
-
proto._resumeExtensions = function resumeExtensions(message, callback) {
|
|
1156
|
-
const extensions = this.extensions,
|
|
1157
|
-
bpmnIo = this.bpmnIo;
|
|
1158
|
-
if (!extensions && !bpmnIo) return callback();
|
|
1159
|
-
if (extensions) extensions.activate((0, _messageHelper.cloneMessage)(message), this);
|
|
1160
|
-
if (bpmnIo) bpmnIo.activate((0, _messageHelper.cloneMessage)(message), this);
|
|
1161
|
-
this.status = 'formatting';
|
|
1162
|
-
return this.formatter.format(message, (err, formattedContent, formatted) => {
|
|
1163
|
-
if (err) return callback(err);
|
|
1164
|
-
return callback(null, formatted && formattedContent);
|
|
1165
|
-
});
|
|
1166
|
-
};
|
|
1167
|
-
|
|
1168
1141
|
proto._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
1169
1142
|
const broker = this.broker;
|
|
1170
1143
|
broker.cancel('_activity-api');
|
|
@@ -1315,9 +1288,9 @@ OutboundEvaluator.prototype.completed = function completed(err) {
|
|
|
1315
1288
|
|
|
1316
1289
|
for (const flow of Object.values(result)) {
|
|
1317
1290
|
evaluationResult.push({ ...flow,
|
|
1318
|
-
...(message !== undefined
|
|
1291
|
+
...(message !== undefined && {
|
|
1319
1292
|
message
|
|
1320
|
-
}
|
|
1293
|
+
})
|
|
1321
1294
|
});
|
|
1322
1295
|
}
|
|
1323
1296
|
|
|
@@ -1328,8 +1301,8 @@ function formatFlowAction(flow, options) {
|
|
|
1328
1301
|
return { ...options,
|
|
1329
1302
|
id: flow.id,
|
|
1330
1303
|
action: options.action,
|
|
1331
|
-
...(flow.isDefault
|
|
1304
|
+
...(flow.isDefault && {
|
|
1332
1305
|
isDefault: true
|
|
1333
|
-
}
|
|
1306
|
+
})
|
|
1334
1307
|
};
|
|
1335
1308
|
}
|
|
@@ -414,9 +414,9 @@ proto._debug = function debug(logMessage, executionId) {
|
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
function getExecuteMessage(message) {
|
|
417
|
-
const result = (0, _messageHelper.cloneMessage)(message, { ...(message.fields.redelivered
|
|
417
|
+
const result = (0, _messageHelper.cloneMessage)(message, { ...(message.fields.redelivered && {
|
|
418
418
|
isRecovered: true
|
|
419
|
-
}
|
|
419
|
+
}),
|
|
420
420
|
ignoreIfExecuting: undefined
|
|
421
421
|
});
|
|
422
422
|
return result;
|
|
@@ -12,6 +12,7 @@ var _iso8601Duration = require("iso8601-duration");
|
|
|
12
12
|
const kStopped = Symbol.for('stopped');
|
|
13
13
|
const kTimerContent = Symbol.for('timerContent');
|
|
14
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';
|
|
@@ -77,9 +78,9 @@ proto.execute = function execute(executeMessage) {
|
|
|
77
78
|
const resolvedTimer = this._getTimers(executeMessage);
|
|
78
79
|
|
|
79
80
|
const timerContent = this[kTimerContent] = (0, _messageHelper.cloneContent)(content, { ...resolvedTimer,
|
|
80
|
-
...(isResumed
|
|
81
|
+
...(isResumed && {
|
|
81
82
|
isResumed
|
|
82
|
-
}
|
|
83
|
+
}),
|
|
83
84
|
startedAt,
|
|
84
85
|
state: 'timer'
|
|
85
86
|
});
|
|
@@ -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
|
|
|
@@ -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
|
-
}
|
|
185
|
+
})
|
|
177
186
|
}, {
|
|
178
187
|
correlationId
|
|
179
188
|
});
|
|
@@ -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
|
-
}
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
297
|
+
this._warn(`failed to parse ${this.timerType} >${duration}<: ${err.message}`);
|
|
275
298
|
}
|
|
276
299
|
};
|
|
277
300
|
|