bpmn-elements 15.0.3 → 16.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/README.md +1 -1
- package/dist/activity/Activity.js +1 -1
- package/dist/condition.js +65 -0
- package/dist/eventDefinitions/ConditionalEventDefinition.js +101 -106
- package/dist/eventDefinitions/ErrorEventDefinition.js +2 -2
- package/dist/eventDefinitions/index.js +76 -0
- package/dist/events/index.js +67 -55
- package/dist/flows/SequenceFlow.js +4 -37
- package/dist/flows/index.js +27 -0
- package/dist/gateways/index.js +54 -44
- package/dist/index.js +39 -64
- package/dist/process/Process.js +3 -2
- package/dist/tasks/index.js +101 -88
- package/eventDefinitions.d.ts +1 -0
- package/flows.d.ts +1 -0
- package/package.json +20 -5
- package/src/activity/Activity.js +1 -1
- package/src/condition.js +58 -0
- package/src/eventDefinitions/ConditionalEventDefinition.js +96 -106
- package/src/eventDefinitions/ErrorEventDefinition.js +2 -2
- package/src/eventDefinitions/index.js +23 -0
- package/src/events/index.js +18 -5
- package/src/flows/SequenceFlow.js +3 -38
- package/src/flows/index.js +5 -0
- package/src/gateways/index.js +15 -4
- package/src/index.js +16 -30
- package/src/process/Process.js +3 -2
- package/src/tasks/index.js +26 -8
- package/types/index.d.ts +31 -25
- package/types/types.d.ts +52 -1
- package/dist/ExtensionsMapper.js +0 -41
- package/dist/iso-duration.js +0 -88
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ The following elements are tested and supported.
|
|
|
18
18
|
- BoundaryEvent
|
|
19
19
|
- [CallActivity](/docs/CallActivity.md)
|
|
20
20
|
- CancelEventDefinition
|
|
21
|
-
- ConditionalEventDefinition
|
|
21
|
+
- [ConditionalEventDefinition](/docs/ConditionalEventDefinition.md)
|
|
22
22
|
- CompensateEventDefinition
|
|
23
23
|
- compensate by outbound Association
|
|
24
24
|
- [DataObject](/docs/BpmnIO.md)
|
|
@@ -112,7 +112,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
112
112
|
onApiMessage: this._onApiMessage.bind(this),
|
|
113
113
|
onExecutionMessage: this._onExecutionMessage.bind(this)
|
|
114
114
|
};
|
|
115
|
-
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed,
|
|
115
|
+
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map((ed, idx) => new ed.Behaviour(this, ed, context, idx));
|
|
116
116
|
this[kExtensions] = context.loadExtensions(this);
|
|
117
117
|
this[kConsuming] = false;
|
|
118
118
|
this[kConsumingRunQ] = undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ExpressionCondition = ExpressionCondition;
|
|
7
|
+
exports.ScriptCondition = ScriptCondition;
|
|
8
|
+
var _ExecutionScope = _interopRequireDefault(require("./activity/ExecutionScope.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
/**
|
|
11
|
+
* Script condition
|
|
12
|
+
* @param {import('types').ElementBase} owner
|
|
13
|
+
* @param {any} script
|
|
14
|
+
* @param {string} language
|
|
15
|
+
*/
|
|
16
|
+
function ScriptCondition(owner, script, language) {
|
|
17
|
+
this.type = 'script';
|
|
18
|
+
this.language = language;
|
|
19
|
+
this._owner = owner;
|
|
20
|
+
this._script = script;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Execute
|
|
25
|
+
* @param {any} message
|
|
26
|
+
* @param {CallableFunction} callback
|
|
27
|
+
*/
|
|
28
|
+
ScriptCondition.prototype.execute = function execute(message, callback) {
|
|
29
|
+
const owner = this._owner;
|
|
30
|
+
try {
|
|
31
|
+
return this._script.execute((0, _ExecutionScope.default)(owner, message), callback);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (!callback) throw err;
|
|
34
|
+
owner.logger.error(`<${owner.id}>`, err);
|
|
35
|
+
callback(err);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Expression condition
|
|
41
|
+
* @param {import('types').ElementBase} owner
|
|
42
|
+
* @param {string} expression
|
|
43
|
+
*/
|
|
44
|
+
function ExpressionCondition(owner, expression) {
|
|
45
|
+
this.type = 'expression';
|
|
46
|
+
this.expression = expression;
|
|
47
|
+
this._owner = owner;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Execute
|
|
52
|
+
* @param {any} message
|
|
53
|
+
* @param {CallableFunction} callback
|
|
54
|
+
*/
|
|
55
|
+
ExpressionCondition.prototype.execute = function execute(message, callback) {
|
|
56
|
+
const owner = this._owner;
|
|
57
|
+
try {
|
|
58
|
+
const result = owner.environment.resolveExpression(this.expression, message);
|
|
59
|
+
if (callback) return callback(null, result);
|
|
60
|
+
return result;
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (callback) return callback(err);
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = ConditionalEventDefinition;
|
|
7
7
|
var _messageHelper = require("../messageHelper.js");
|
|
8
8
|
var _Errors = require("../error/Errors.js");
|
|
9
|
+
var _condition = require("../condition.js");
|
|
9
10
|
const kExecuteMessage = Symbol.for('executeMessage');
|
|
10
|
-
function ConditionalEventDefinition(activity, eventDefinition) {
|
|
11
|
+
function ConditionalEventDefinition(activity, eventDefinition, _context, index) {
|
|
11
12
|
const {
|
|
12
13
|
id,
|
|
13
14
|
broker,
|
|
14
|
-
environment
|
|
15
|
-
attachedTo
|
|
15
|
+
environment
|
|
16
16
|
} = activity;
|
|
17
17
|
const {
|
|
18
18
|
type = 'ConditionalEventDefinition',
|
|
@@ -20,12 +20,12 @@ function ConditionalEventDefinition(activity, eventDefinition) {
|
|
|
20
20
|
} = eventDefinition;
|
|
21
21
|
this.id = id;
|
|
22
22
|
this.type = type;
|
|
23
|
-
this.
|
|
24
|
-
this.condition = behaviour.expression;
|
|
23
|
+
this.behaviour = behaviour;
|
|
25
24
|
this.activity = activity;
|
|
26
25
|
this.environment = environment;
|
|
27
26
|
this.broker = broker;
|
|
28
27
|
this.logger = environment.Logger(type.toLowerCase());
|
|
28
|
+
this.condition = this.getCondition(index);
|
|
29
29
|
}
|
|
30
30
|
Object.defineProperty(ConditionalEventDefinition.prototype, 'executionId', {
|
|
31
31
|
get() {
|
|
@@ -35,141 +35,137 @@ Object.defineProperty(ConditionalEventDefinition.prototype, 'executionId', {
|
|
|
35
35
|
});
|
|
36
36
|
ConditionalEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
37
37
|
this[kExecuteMessage] = executeMessage;
|
|
38
|
-
|
|
38
|
+
if (!this.condition) return this._setup(executeMessage);
|
|
39
|
+
this.evaluate(executeMessage, (err, result) => {
|
|
40
|
+
this.evaluateCallback(err, result);
|
|
41
|
+
if (!err && !result) {
|
|
42
|
+
this._setup(executeMessage);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
39
45
|
};
|
|
40
|
-
ConditionalEventDefinition.prototype.
|
|
46
|
+
ConditionalEventDefinition.prototype._setup = function setup(executeMessage) {
|
|
47
|
+
const broker = this.broker;
|
|
41
48
|
const executeContent = executeMessage.content;
|
|
42
49
|
const {
|
|
43
50
|
executionId,
|
|
44
51
|
parent
|
|
45
52
|
} = executeContent;
|
|
46
53
|
const parentExecutionId = parent.executionId;
|
|
47
|
-
|
|
48
|
-
const broker = this.broker;
|
|
49
|
-
const onApiMessage = this._onWaitApiMessage.bind(this);
|
|
54
|
+
const onApiMessage = this._onApiMessage.bind(this);
|
|
50
55
|
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
51
56
|
noAck: true,
|
|
52
57
|
consumerTag: `_api-${executionId}`
|
|
53
58
|
});
|
|
54
|
-
broker.subscribeTmp('api', `activity
|
|
59
|
+
broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
|
|
55
60
|
noAck: true,
|
|
56
61
|
consumerTag: `_parent-signal-${executionId}`
|
|
57
62
|
});
|
|
58
|
-
|
|
59
|
-
executionId: parentExecutionId,
|
|
60
|
-
condition: this.condition
|
|
61
|
-
});
|
|
62
|
-
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
63
|
-
broker.publish('event', 'activity.wait', waitContent);
|
|
64
|
-
};
|
|
65
|
-
ConditionalEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
|
|
66
|
-
const executeContent = executeMessage.content;
|
|
67
|
-
const {
|
|
68
|
-
executionId,
|
|
69
|
-
index,
|
|
70
|
-
parent
|
|
71
|
-
} = executeContent;
|
|
72
|
-
const parentExecutionId = parent.executionId;
|
|
73
|
-
const broker = this.broker;
|
|
74
|
-
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onCatchApiMessage.bind(this), {
|
|
63
|
+
broker.subscribeTmp('api', '#.signal.*', this._onDelegateApiMessage.bind(this), {
|
|
75
64
|
noAck: true,
|
|
76
|
-
consumerTag: `_api-${executionId}
|
|
77
|
-
});
|
|
78
|
-
const {
|
|
79
|
-
id: attachedToId,
|
|
80
|
-
broker: attachedToBroker
|
|
81
|
-
} = this.activity.attachedTo;
|
|
82
|
-
this._debug(`listen for execute completed from <${attachedToId}>`);
|
|
83
|
-
attachedToBroker.subscribeOnce('execution', 'execute.completed', this._onAttachedCompleted.bind(this), {
|
|
84
|
-
priority: 300,
|
|
85
|
-
consumerTag: `_onend-${executionId}_${index}`
|
|
65
|
+
consumerTag: `_api-delegated-${executionId}`
|
|
86
66
|
});
|
|
87
67
|
const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
88
68
|
executionId: parentExecutionId,
|
|
89
|
-
|
|
69
|
+
...(this.condition && {
|
|
70
|
+
condition: this.condition.type
|
|
71
|
+
})
|
|
90
72
|
});
|
|
91
73
|
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
92
74
|
broker.publish('event', 'activity.wait', waitContent);
|
|
93
75
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
state: 'discard'
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
case 'stop':
|
|
109
|
-
{
|
|
110
|
-
return this._stopWait();
|
|
111
|
-
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Evaluate condition
|
|
79
|
+
* @param {import('types').ElementBrokerMessage} message
|
|
80
|
+
* @param {CallableFunction} callback
|
|
81
|
+
*/
|
|
82
|
+
ConditionalEventDefinition.prototype.evaluate = function evaluate(message, callback) {
|
|
83
|
+
const condition = this.condition;
|
|
84
|
+
if (!condition) {
|
|
85
|
+
this._debug(`condition is empty <${condition}>`);
|
|
86
|
+
return callback();
|
|
112
87
|
}
|
|
88
|
+
condition.execute(message, callback);
|
|
113
89
|
};
|
|
114
|
-
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Handle evaluate result or error
|
|
93
|
+
* @param {Error|null} err Condition evaluation error
|
|
94
|
+
* @param {any} result Result from evaluated condition, completes execution if truthy
|
|
95
|
+
*/
|
|
96
|
+
ConditionalEventDefinition.prototype.evaluateCallback = function evaluateCallback(err, result) {
|
|
97
|
+
const broker = this.broker;
|
|
115
98
|
const executeMessage = this[kExecuteMessage];
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
|
|
120
|
-
} catch (err) {
|
|
99
|
+
const executeContent = executeMessage.content;
|
|
100
|
+
if (err) {
|
|
121
101
|
return broker.publish('execution', 'execute.error', (0, _messageHelper.cloneContent)(executeContent, {
|
|
122
102
|
error: new _Errors.ActivityError(err.message, executeMessage, err)
|
|
123
103
|
}, {
|
|
124
104
|
mandatory: true
|
|
125
105
|
}));
|
|
126
106
|
}
|
|
127
|
-
this._debug(`condition evaluated to ${!!
|
|
128
|
-
broker.publish('event', 'activity.condition', (0, _messageHelper.cloneContent)(
|
|
129
|
-
conditionResult:
|
|
107
|
+
this._debug(`condition evaluated to ${!!result}`);
|
|
108
|
+
this.broker.publish('event', 'activity.condition', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
109
|
+
conditionResult: result
|
|
130
110
|
}));
|
|
131
|
-
if (!
|
|
132
|
-
this.
|
|
111
|
+
if (!result) return;
|
|
112
|
+
this._stop();
|
|
133
113
|
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
134
|
-
output
|
|
114
|
+
output: result
|
|
135
115
|
}));
|
|
136
116
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
ConditionalEventDefinition.prototype.
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get condition
|
|
120
|
+
* @param {number} index Eventdefinition sequence number, used to name registered script
|
|
121
|
+
* @returns {ExpressionCondition|ScriptCondition|null}
|
|
122
|
+
*/
|
|
123
|
+
ConditionalEventDefinition.prototype.getCondition = function getCondition(index) {
|
|
124
|
+
const behaviour = this.behaviour;
|
|
125
|
+
if (behaviour.script) {
|
|
126
|
+
const {
|
|
127
|
+
language,
|
|
128
|
+
body,
|
|
129
|
+
resource
|
|
130
|
+
} = behaviour.script;
|
|
131
|
+
const scriptId = `${this.id}/${index}`;
|
|
132
|
+
const script = this.environment.scripts.register({
|
|
133
|
+
id: scriptId,
|
|
134
|
+
type: this.type,
|
|
135
|
+
environment: this.environment,
|
|
136
|
+
behaviour: {
|
|
137
|
+
scriptFormat: language,
|
|
138
|
+
...(body && {
|
|
139
|
+
script: body
|
|
140
|
+
}),
|
|
141
|
+
...(resource && {
|
|
142
|
+
resource
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
if (script) {
|
|
147
|
+
return new _condition.ScriptCondition(this, script, language);
|
|
148
|
+
}
|
|
149
|
+
} else if (behaviour.expression) {
|
|
150
|
+
return new _condition.ExpressionCondition(this, behaviour.expression);
|
|
156
151
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (output) {
|
|
162
|
-
broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
163
|
-
output
|
|
164
|
-
}));
|
|
152
|
+
};
|
|
153
|
+
ConditionalEventDefinition.prototype._onDelegateApiMessage = function onDelegateApiMessage(routingKey, message) {
|
|
154
|
+
if (message.content.message && message.content.message.id === this.id) {
|
|
155
|
+
this._onApiMessage(routingKey, message);
|
|
165
156
|
}
|
|
166
157
|
};
|
|
167
|
-
ConditionalEventDefinition.prototype.
|
|
158
|
+
ConditionalEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
168
159
|
const messageType = message.properties.type;
|
|
169
160
|
switch (messageType) {
|
|
161
|
+
case 'signal':
|
|
162
|
+
{
|
|
163
|
+
if (!this.condition) break;
|
|
164
|
+
return this.evaluate(message, (err, result) => this.evaluateCallback(err, result));
|
|
165
|
+
}
|
|
170
166
|
case 'discard':
|
|
171
167
|
{
|
|
172
|
-
this.
|
|
168
|
+
this._stop();
|
|
173
169
|
this._debug('discarded');
|
|
174
170
|
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
175
171
|
state: 'discard'
|
|
@@ -177,18 +173,17 @@ ConditionalEventDefinition.prototype._onCatchApiMessage = function onCatchApiMes
|
|
|
177
173
|
}
|
|
178
174
|
case 'stop':
|
|
179
175
|
{
|
|
180
|
-
this.
|
|
176
|
+
this._stop();
|
|
181
177
|
return this._debug('stopped');
|
|
182
178
|
}
|
|
183
179
|
}
|
|
184
180
|
};
|
|
185
|
-
ConditionalEventDefinition.prototype.
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
this.broker.cancel(`_api-${executionId}_${index}`);
|
|
181
|
+
ConditionalEventDefinition.prototype._stop = function stop() {
|
|
182
|
+
const executionId = this.executionId;
|
|
183
|
+
const broker = this.broker;
|
|
184
|
+
broker.cancel(`_api-${executionId}`);
|
|
185
|
+
broker.cancel(`_parent-signal-${executionId}`);
|
|
186
|
+
broker.cancel(`_api-delegated-${executionId}`);
|
|
192
187
|
};
|
|
193
188
|
ConditionalEventDefinition.prototype._debug = function debug(msg) {
|
|
194
189
|
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
@@ -189,8 +189,8 @@ ErrorEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey,
|
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
191
|
ErrorEventDefinition.prototype._stop = function stop() {
|
|
192
|
-
const broker = this.broker
|
|
193
|
-
|
|
192
|
+
const broker = this.broker;
|
|
193
|
+
const executionId = this.executionId;
|
|
194
194
|
broker.cancel(`_onthrow-${executionId}`);
|
|
195
195
|
broker.cancel(`_onerror-${executionId}`);
|
|
196
196
|
broker.cancel(`_api-${executionId}`);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CancelEventDefinition", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _CancelEventDefinition.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "CompensateEventDefinition", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _CompensateEventDefinition.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ConditionalEventDefinition", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _ConditionalEventDefinition.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ErrorEventDefinition", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ErrorEventDefinition.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "EscalationEventDefinition", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _EscalationEventDefinition.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "LinkEventDefinition", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _LinkEventDefinition.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "MessageEventDefinition", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _MessageEventDefinition.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "SignalEventDefinition", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _SignalEventDefinition.default;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "TerminateEventDefinition", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _TerminateEventDefinition.default;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "TimerEventDefinition", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _TimerEventDefinition.default;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
var _CancelEventDefinition = _interopRequireDefault(require("./CancelEventDefinition.js"));
|
|
67
|
+
var _CompensateEventDefinition = _interopRequireDefault(require("./CompensateEventDefinition.js"));
|
|
68
|
+
var _ConditionalEventDefinition = _interopRequireDefault(require("./ConditionalEventDefinition.js"));
|
|
69
|
+
var _ErrorEventDefinition = _interopRequireDefault(require("./ErrorEventDefinition.js"));
|
|
70
|
+
var _EscalationEventDefinition = _interopRequireDefault(require("./EscalationEventDefinition.js"));
|
|
71
|
+
var _LinkEventDefinition = _interopRequireDefault(require("./LinkEventDefinition.js"));
|
|
72
|
+
var _MessageEventDefinition = _interopRequireDefault(require("./MessageEventDefinition.js"));
|
|
73
|
+
var _SignalEventDefinition = _interopRequireDefault(require("./SignalEventDefinition.js"));
|
|
74
|
+
var _TerminateEventDefinition = _interopRequireDefault(require("./TerminateEventDefinition.js"));
|
|
75
|
+
var _TimerEventDefinition = _interopRequireDefault(require("./TimerEventDefinition.js"));
|
|
76
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/dist/events/index.js
CHANGED
|
@@ -3,58 +3,70 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Object.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
6
|
+
Object.defineProperty(exports, "BoundaryEvent", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _BoundaryEvent.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "BoundaryEventBehaviour", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _BoundaryEvent.BoundaryEventBehaviour;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "EndEvent", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _EndEvent.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "EndEventBehaviour", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _EndEvent.EndEventBehaviour;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "IntermediateCatchEvent", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _IntermediateCatchEvent.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "IntermediateCatchEventBehaviour", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _IntermediateCatchEvent.IntermediateCatchEventBehaviour;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "IntermediateThrowEvent", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _IntermediateThrowEvent.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "IntermediateThrowEventBehaviour", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _IntermediateThrowEvent.IntermediateThrowEventBehaviour;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "StartEvent", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _StartEvent.default;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "StartEventBehaviour", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _StartEvent.StartEventBehaviour;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
var _BoundaryEvent = _interopRequireWildcard(require("./BoundaryEvent.js"));
|
|
67
|
+
var _EndEvent = _interopRequireWildcard(require("./EndEvent.js"));
|
|
68
|
+
var _IntermediateCatchEvent = _interopRequireWildcard(require("./IntermediateCatchEvent.js"));
|
|
69
|
+
var _IntermediateThrowEvent = _interopRequireWildcard(require("./IntermediateThrowEvent.js"));
|
|
70
|
+
var _StartEvent = _interopRequireWildcard(require("./StartEvent.js"));
|
|
71
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
72
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _ExecutionScope = _interopRequireDefault(require("../activity/ExecutionScope.js"));
|
|
8
7
|
var _messageHelper = require("../messageHelper.js");
|
|
9
8
|
var _shared = require("../shared.js");
|
|
10
9
|
var _EventBroker = require("../EventBroker.js");
|
|
11
10
|
var _Api = require("../Api.js");
|
|
12
|
-
|
|
11
|
+
var _condition = require("../condition.js");
|
|
13
12
|
const kCounters = Symbol.for('counters');
|
|
14
13
|
var _default = exports.default = SequenceFlow;
|
|
15
14
|
function SequenceFlow(flowDef, {
|
|
@@ -41,7 +40,6 @@ function SequenceFlow(flowDef, {
|
|
|
41
40
|
take: 0,
|
|
42
41
|
discard: 0
|
|
43
42
|
};
|
|
44
|
-
environment.registerScript(this);
|
|
45
43
|
const {
|
|
46
44
|
broker,
|
|
47
45
|
on,
|
|
@@ -58,6 +56,7 @@ function SequenceFlow(flowDef, {
|
|
|
58
56
|
this.once = once;
|
|
59
57
|
this.waitFor = waitFor;
|
|
60
58
|
this.emitFatal = emitFatal;
|
|
59
|
+
environment.registerScript(this);
|
|
61
60
|
logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
|
|
62
61
|
}
|
|
63
62
|
Object.defineProperty(SequenceFlow.prototype, 'counters', {
|
|
@@ -145,13 +144,13 @@ SequenceFlow.prototype.getCondition = function getCondition() {
|
|
|
145
144
|
} = conditionExpression;
|
|
146
145
|
const script = this.environment.getScript(language, this);
|
|
147
146
|
if (script) {
|
|
148
|
-
return new ScriptCondition(this, script, language);
|
|
147
|
+
return new _condition.ScriptCondition(this, script, language);
|
|
149
148
|
}
|
|
150
149
|
if (!conditionExpression.body) {
|
|
151
150
|
const msg = language ? `Condition expression script ${language} is unsupported or was not registered` : 'Condition expression without body is unsupported';
|
|
152
151
|
return this.emitFatal(new Error(msg), this.createMessage());
|
|
153
152
|
}
|
|
154
|
-
return new ExpressionCondition(this, conditionExpression.body);
|
|
153
|
+
return new _condition.ExpressionCondition(this, conditionExpression.body);
|
|
155
154
|
};
|
|
156
155
|
SequenceFlow.prototype.createMessage = function createMessage(override) {
|
|
157
156
|
return {
|
|
@@ -184,36 +183,4 @@ SequenceFlow.prototype._publishEvent = function publishEvent(action, content) {
|
|
|
184
183
|
this.broker.publish('event', `flow.${action}`, eventContent, {
|
|
185
184
|
type: action
|
|
186
185
|
});
|
|
187
|
-
};
|
|
188
|
-
function ScriptCondition(owner, script, language) {
|
|
189
|
-
this.type = 'script';
|
|
190
|
-
this.language = language;
|
|
191
|
-
this._owner = owner;
|
|
192
|
-
this._script = script;
|
|
193
|
-
}
|
|
194
|
-
ScriptCondition.prototype.execute = function execute(message, callback) {
|
|
195
|
-
const owner = this._owner;
|
|
196
|
-
try {
|
|
197
|
-
return this._script.execute((0, _ExecutionScope.default)(owner, message), callback);
|
|
198
|
-
} catch (err) {
|
|
199
|
-
if (!callback) throw err;
|
|
200
|
-
owner.logger.error(`<${owner.id}>`, err);
|
|
201
|
-
callback(err);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
function ExpressionCondition(owner, expression) {
|
|
205
|
-
this.type = 'expression';
|
|
206
|
-
this.expression = expression;
|
|
207
|
-
this._owner = owner;
|
|
208
|
-
}
|
|
209
|
-
ExpressionCondition.prototype.execute = function execute(message, callback) {
|
|
210
|
-
const owner = this._owner;
|
|
211
|
-
try {
|
|
212
|
-
const result = owner.environment.resolveExpression(this.expression, owner.createMessage(message));
|
|
213
|
-
if (callback) return callback(null, result);
|
|
214
|
-
return result;
|
|
215
|
-
} catch (err) {
|
|
216
|
-
if (callback) return callback(err);
|
|
217
|
-
throw err;
|
|
218
|
-
}
|
|
219
186
|
};
|