bpmn-elements 17.3.0 → 18.0.1
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 +3 -1
- package/dist/Api.js +83 -0
- package/dist/Context.js +228 -22
- package/dist/Environment.js +111 -31
- package/dist/EventBroker.js +57 -1
- package/dist/Expressions.js +3 -4
- package/dist/MessageFormatter.js +29 -16
- package/dist/Timers.js +13 -9
- package/dist/Tracker.js +1 -0
- package/dist/activity/Activity.js +434 -233
- package/dist/activity/ActivityExecution.js +113 -40
- package/dist/activity/Dummy.js +6 -1
- package/dist/activity/Escalation.js +36 -24
- package/dist/activity/ExecutionScope.js +1 -1
- package/dist/activity/Message.js +36 -24
- package/dist/activity/Signal.js +36 -24
- package/dist/activity/outbound-evaluator.js +1 -1
- package/dist/condition.js +12 -6
- package/dist/constants.js +27 -0
- package/dist/definition/Definition.js +187 -64
- package/dist/definition/DefinitionExecution.js +198 -84
- package/dist/error/BpmnError.js +12 -1
- package/dist/error/Errors.js +50 -9
- package/dist/eventDefinitions/CancelEventDefinition.js +29 -11
- package/dist/eventDefinitions/CompensateEventDefinition.js +51 -31
- package/dist/eventDefinitions/ConditionalEventDefinition.js +21 -9
- package/dist/eventDefinitions/ErrorEventDefinition.js +46 -30
- package/dist/eventDefinitions/EscalationEventDefinition.js +44 -27
- package/dist/eventDefinitions/EventDefinitionExecution.js +30 -23
- package/dist/eventDefinitions/LinkEventDefinition.js +45 -120
- package/dist/eventDefinitions/MessageEventDefinition.js +44 -29
- package/dist/eventDefinitions/SignalEventDefinition.js +46 -31
- package/dist/eventDefinitions/TerminateEventDefinition.js +10 -1
- package/dist/eventDefinitions/TimerEventDefinition.js +57 -37
- package/dist/eventDefinitions/index.js +20 -21
- package/dist/events/BoundaryEvent.js +52 -40
- package/dist/events/EndEvent.js +22 -8
- package/dist/events/IntermediateCatchEvent.js +26 -8
- package/dist/events/IntermediateThrowEvent.js +24 -9
- package/dist/events/StartEvent.js +30 -14
- package/dist/events/index.js +10 -11
- package/dist/flows/Association.js +50 -7
- package/dist/flows/MessageFlow.js +49 -10
- package/dist/flows/SequenceFlow.js +93 -22
- package/dist/flows/index.js +6 -7
- package/dist/gateways/EventBasedGateway.js +29 -15
- package/dist/gateways/ExclusiveGateway.js +20 -5
- package/dist/gateways/InclusiveGateway.js +21 -5
- package/dist/gateways/ParallelGateway.js +253 -15
- package/dist/gateways/index.js +8 -9
- package/dist/getPropertyValue.js +1 -1
- package/dist/index.js +42 -43
- package/dist/io/BpmnIO.js +15 -1
- package/dist/io/EnvironmentDataObject.js +29 -1
- package/dist/io/EnvironmentDataStore.js +24 -1
- package/dist/io/EnvironmentDataStoreReference.js +24 -1
- package/dist/io/InputOutputSpecification.js +21 -11
- package/dist/io/Properties.js +28 -17
- package/dist/messageHelper.js +41 -4
- package/dist/process/Lane.js +15 -4
- package/dist/process/Process.js +176 -77
- package/dist/process/ProcessExecution.js +397 -178
- package/dist/shared.js +2 -0
- package/dist/tasks/CallActivity.js +19 -4
- package/dist/tasks/LoopCharacteristics.js +94 -9
- package/dist/tasks/ReceiveTask.js +36 -21
- package/dist/tasks/ScriptTask.js +22 -6
- package/dist/tasks/ServiceImplementation.js +7 -4
- package/dist/tasks/ServiceTask.js +19 -4
- package/dist/tasks/SignalTask.js +19 -4
- package/dist/tasks/StandardLoopCharacteristics.js +8 -4
- package/dist/tasks/SubProcess.js +44 -29
- package/dist/tasks/Task.js +19 -4
- package/dist/tasks/Transaction.js +8 -4
- package/dist/tasks/index.js +16 -18
- package/package.json +31 -13
- package/src/Api.js +70 -0
- package/src/Context.js +200 -19
- package/src/Environment.js +99 -30
- package/src/EventBroker.js +46 -1
- package/src/Expressions.js +2 -3
- package/src/MessageFormatter.js +24 -16
- package/src/Timers.js +12 -9
- package/src/Tracker.js +1 -0
- package/src/activity/Activity.js +372 -218
- package/src/activity/ActivityExecution.js +93 -42
- package/src/activity/Dummy.js +6 -1
- package/src/activity/Escalation.js +25 -18
- package/src/activity/ExecutionScope.js +1 -1
- package/src/activity/Message.js +25 -18
- package/src/activity/Signal.js +25 -18
- package/src/activity/outbound-evaluator.js +1 -1
- package/src/condition.js +11 -5
- package/src/constants.js +21 -0
- package/src/definition/Definition.js +165 -63
- package/src/definition/DefinitionExecution.js +164 -85
- package/src/error/BpmnError.js +11 -1
- package/src/error/Errors.js +44 -5
- package/src/eventDefinitions/CancelEventDefinition.js +27 -13
- package/src/eventDefinitions/CompensateEventDefinition.js +48 -32
- package/src/eventDefinitions/ConditionalEventDefinition.js +20 -10
- package/src/eventDefinitions/ErrorEventDefinition.js +44 -33
- package/src/eventDefinitions/EscalationEventDefinition.js +39 -26
- package/src/eventDefinitions/EventDefinitionExecution.js +30 -24
- package/src/eventDefinitions/LinkEventDefinition.js +34 -120
- package/src/eventDefinitions/MessageEventDefinition.js +42 -31
- package/src/eventDefinitions/SignalEventDefinition.js +43 -32
- package/src/eventDefinitions/TerminateEventDefinition.js +9 -1
- package/src/eventDefinitions/TimerEventDefinition.js +53 -35
- package/src/eventDefinitions/index.js +10 -23
- package/src/events/BoundaryEvent.js +50 -39
- package/src/events/EndEvent.js +19 -7
- package/src/events/IntermediateCatchEvent.js +24 -8
- package/src/events/IntermediateThrowEvent.js +24 -8
- package/src/events/StartEvent.js +25 -14
- package/src/events/index.js +5 -18
- package/src/flows/Association.js +43 -9
- package/src/flows/MessageFlow.js +41 -10
- package/src/flows/SequenceFlow.js +82 -19
- package/src/flows/index.js +3 -4
- package/src/gateways/EventBasedGateway.js +27 -15
- package/src/gateways/ExclusiveGateway.js +16 -3
- package/src/gateways/InclusiveGateway.js +16 -3
- package/src/gateways/ParallelGateway.js +301 -10
- package/src/gateways/index.js +4 -4
- package/src/getPropertyValue.js +1 -1
- package/src/index.js +19 -19
- package/src/io/BpmnIO.js +13 -1
- package/src/io/EnvironmentDataObject.js +26 -1
- package/src/io/EnvironmentDataStore.js +22 -1
- package/src/io/EnvironmentDataStoreReference.js +22 -1
- package/src/io/InputOutputSpecification.js +17 -8
- package/src/io/Properties.js +23 -13
- package/src/messageHelper.js +36 -4
- package/src/process/Lane.js +14 -4
- package/src/process/Process.js +157 -74
- package/src/process/ProcessExecution.js +363 -176
- package/src/shared.js +1 -0
- package/src/tasks/CallActivity.js +16 -2
- package/src/tasks/LoopCharacteristics.js +77 -11
- package/src/tasks/ReceiveTask.js +33 -22
- package/src/tasks/ScriptTask.js +17 -3
- package/src/tasks/ServiceImplementation.js +6 -3
- package/src/tasks/ServiceTask.js +16 -2
- package/src/tasks/SignalTask.js +16 -2
- package/src/tasks/StandardLoopCharacteristics.js +7 -3
- package/src/tasks/SubProcess.js +37 -23
- package/src/tasks/Task.js +16 -2
- package/src/tasks/Transaction.js +7 -3
- package/src/tasks/index.js +8 -9
- package/types/bundle-errors.d.ts +1 -0
- package/types/bundle.d.ts +97 -0
- package/types/index.d.ts +2619 -84
- package/types/interfaces.d.ts +638 -0
- package/types/types.d.ts +0 -765
package/dist/process/Process.js
CHANGED
|
@@ -4,25 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Process = Process;
|
|
7
|
-
|
|
8
|
-
var _ProcessExecution = _interopRequireDefault(require("./ProcessExecution.js"));
|
|
7
|
+
var _ProcessExecution = require("./ProcessExecution.js");
|
|
9
8
|
var _shared = require("../shared.js");
|
|
10
9
|
var _Api = require("../Api.js");
|
|
11
10
|
var _EventBroker = require("../EventBroker.js");
|
|
12
11
|
var _messageHelper = require("../messageHelper.js");
|
|
13
12
|
var _Errors = require("../error/Errors.js");
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const kStatus = Symbol.for('status');
|
|
24
|
-
const kStopped = Symbol.for('stopped');
|
|
25
|
-
var _default = exports.default = Process;
|
|
13
|
+
var _constants = require("../constants.js");
|
|
14
|
+
const K_LANES = Symbol.for('lanes');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Owns one `<bpmn:process>`. Wraps the structural definition and orchestrates flow traversal,
|
|
18
|
+
* joins, and parallel activation through ProcessExecution.
|
|
19
|
+
* @param {import('moddle-context-serializer').Process} processDef
|
|
20
|
+
* @param {import('#types').ContextInstance} context
|
|
21
|
+
*/
|
|
26
22
|
function Process(processDef, context) {
|
|
27
23
|
const {
|
|
28
24
|
id,
|
|
@@ -34,22 +30,21 @@ function Process(processDef, context) {
|
|
|
34
30
|
this.id = id;
|
|
35
31
|
this.type = type;
|
|
36
32
|
this.name = name;
|
|
33
|
+
/** @type {import('#types').ElementParent} */
|
|
37
34
|
this.parent = parent ? (0, _messageHelper.cloneParent)(parent) : {};
|
|
35
|
+
/** @type {import('moddle-context-serializer').Process['behaviour']} */
|
|
38
36
|
this.behaviour = behaviour;
|
|
39
|
-
|
|
40
|
-
isExecutable
|
|
41
|
-
} = behaviour;
|
|
42
|
-
this.isExecutable = isExecutable;
|
|
37
|
+
this.isExecutable = behaviour.isExecutable;
|
|
43
38
|
const environment = this.environment = context.environment;
|
|
44
39
|
this.context = context;
|
|
45
|
-
this[
|
|
40
|
+
this[_constants.K_COUNTERS] = {
|
|
46
41
|
completed: 0,
|
|
47
42
|
discarded: 0
|
|
48
43
|
};
|
|
49
|
-
this[
|
|
50
|
-
this[
|
|
51
|
-
this[
|
|
52
|
-
this[
|
|
44
|
+
this[_constants.K_CONSUMING] = false;
|
|
45
|
+
this[_constants.K_EXECUTION] = new Map();
|
|
46
|
+
this[_constants.K_STATUS] = undefined;
|
|
47
|
+
this[_constants.K_STOPPED] = false;
|
|
53
48
|
const {
|
|
54
49
|
broker,
|
|
55
50
|
on,
|
|
@@ -60,79 +55,90 @@ function Process(processDef, context) {
|
|
|
60
55
|
this.on = on;
|
|
61
56
|
this.once = once;
|
|
62
57
|
this.waitFor = waitFor;
|
|
63
|
-
this[
|
|
58
|
+
this[_constants.K_MESSAGE_HANDLERS] = {
|
|
64
59
|
onApiMessage: this._onApiMessage.bind(this),
|
|
65
60
|
onRunMessage: this._onRunMessage.bind(this),
|
|
66
61
|
onExecutionMessage: this._onExecutionMessage.bind(this)
|
|
67
62
|
};
|
|
68
63
|
this.logger = environment.Logger(type.toLowerCase());
|
|
69
64
|
if (behaviour.lanes) {
|
|
70
|
-
this[
|
|
65
|
+
this[K_LANES] = behaviour.lanes.map(lane => new lane.Behaviour(this, lane));
|
|
71
66
|
}
|
|
72
|
-
this[
|
|
67
|
+
this[_constants.K_EXTENSIONS] = context.loadExtensions(this);
|
|
73
68
|
}
|
|
74
69
|
Object.defineProperties(Process.prototype, {
|
|
75
70
|
counters: {
|
|
76
71
|
get() {
|
|
77
72
|
return {
|
|
78
|
-
...this[
|
|
73
|
+
...this[_constants.K_COUNTERS]
|
|
79
74
|
};
|
|
80
75
|
}
|
|
81
76
|
},
|
|
82
77
|
lanes: {
|
|
83
78
|
get() {
|
|
84
|
-
return this[
|
|
79
|
+
return this[K_LANES]?.slice();
|
|
85
80
|
}
|
|
86
81
|
},
|
|
87
82
|
extensions: {
|
|
88
83
|
get() {
|
|
89
|
-
return this[
|
|
84
|
+
return this[_constants.K_EXTENSIONS];
|
|
90
85
|
}
|
|
91
86
|
},
|
|
92
87
|
stopped: {
|
|
93
88
|
get() {
|
|
94
|
-
return this[
|
|
89
|
+
return this[_constants.K_STOPPED];
|
|
95
90
|
}
|
|
96
91
|
},
|
|
97
92
|
isRunning: {
|
|
98
93
|
get() {
|
|
99
|
-
if (!this[
|
|
94
|
+
if (!this[_constants.K_CONSUMING]) return false;
|
|
100
95
|
return !!this.status;
|
|
101
96
|
}
|
|
102
97
|
},
|
|
103
98
|
executionId: {
|
|
104
99
|
get() {
|
|
105
|
-
const exec = this[
|
|
100
|
+
const exec = this[_constants.K_EXECUTION];
|
|
106
101
|
return exec.get('executionId') || exec.get('initExecutionId');
|
|
107
102
|
}
|
|
108
103
|
},
|
|
109
104
|
execution: {
|
|
110
105
|
get() {
|
|
111
|
-
return this[
|
|
106
|
+
return this[_constants.K_EXECUTION].get('execution');
|
|
112
107
|
}
|
|
113
108
|
},
|
|
114
109
|
status: {
|
|
115
110
|
get() {
|
|
116
|
-
return this[
|
|
111
|
+
return this[_constants.K_STATUS];
|
|
117
112
|
}
|
|
118
113
|
},
|
|
119
114
|
activityStatus: {
|
|
120
115
|
get() {
|
|
121
|
-
return this[
|
|
116
|
+
return this[_constants.K_EXECUTION].get('execution')?.activityStatus || 'idle';
|
|
122
117
|
}
|
|
123
118
|
}
|
|
124
119
|
});
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Allocate an executionId and emit init event without starting the run.
|
|
123
|
+
* @param {string} [useAsExecutionId] Override for the generated execution id
|
|
124
|
+
*/
|
|
125
125
|
Process.prototype.init = function init(useAsExecutionId) {
|
|
126
126
|
const initExecutionId = useAsExecutionId || (0, _shared.getUniqueId)(this.id);
|
|
127
|
-
this[
|
|
127
|
+
this[_constants.K_EXECUTION].set('initExecutionId', initExecutionId);
|
|
128
128
|
this._debug(`initialized with executionId <${initExecutionId}>`);
|
|
129
129
|
this._publishEvent('init', this._createMessage({
|
|
130
130
|
executionId: initExecutionId
|
|
131
131
|
}));
|
|
132
132
|
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Start running the process by publishing run.enter, run.start, and run.execute.
|
|
136
|
+
* @param {Record<string, any>} [runContent] Optional content merged into the run message
|
|
137
|
+
* @throws {Error} when the process is already running
|
|
138
|
+
*/
|
|
133
139
|
Process.prototype.run = function run(runContent) {
|
|
134
140
|
if (this.isRunning) throw new Error(`process <${this.id}> is already running`);
|
|
135
|
-
const exec = this[
|
|
141
|
+
const exec = this[_constants.K_EXECUTION];
|
|
136
142
|
const executionId = exec.get('initExecutionId') || (0, _shared.getUniqueId)(this.id);
|
|
137
143
|
exec.delete('initExecutionId');
|
|
138
144
|
exec.set('executionId', executionId);
|
|
@@ -146,10 +152,16 @@ Process.prototype.run = function run(runContent) {
|
|
|
146
152
|
broker.publish('run', 'run.execute', (0, _messageHelper.cloneContent)(content));
|
|
147
153
|
this._activateRunConsumers();
|
|
148
154
|
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Resume after recover by republishing the last run message.
|
|
158
|
+
* @returns {this}
|
|
159
|
+
* @throws {Error} when called on a running process
|
|
160
|
+
*/
|
|
149
161
|
Process.prototype.resume = function resume() {
|
|
150
162
|
if (this.isRunning) throw new Error(`cannot resume running process <${this.id}>`);
|
|
151
163
|
if (!this.status) return this;
|
|
152
|
-
this[
|
|
164
|
+
this[_constants.K_STOPPED] = false;
|
|
153
165
|
const content = this._createMessage();
|
|
154
166
|
this.broker.publish('run', 'run.resume', content, {
|
|
155
167
|
persistent: false
|
|
@@ -157,6 +169,11 @@ Process.prototype.resume = function resume() {
|
|
|
157
169
|
this._activateRunConsumers();
|
|
158
170
|
return this;
|
|
159
171
|
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Snapshot process state for recover.
|
|
175
|
+
* @returns {import('#types').ProcessState}
|
|
176
|
+
*/
|
|
160
177
|
Process.prototype.getState = function getState() {
|
|
161
178
|
return {
|
|
162
179
|
id: this.id,
|
|
@@ -170,54 +187,90 @@ Process.prototype.getState = function getState() {
|
|
|
170
187
|
execution: this.execution?.getState()
|
|
171
188
|
};
|
|
172
189
|
};
|
|
173
|
-
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Restore process state captured by getState.
|
|
193
|
+
* @param {import('#types').ProcessState} [state]
|
|
194
|
+
* @param {number} [recoveredVersion] State version
|
|
195
|
+
* @returns {this}
|
|
196
|
+
* @throws {Error} when called on a running process
|
|
197
|
+
*/
|
|
198
|
+
Process.prototype.recover = function recover(state, recoveredVersion) {
|
|
174
199
|
if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
|
|
175
200
|
if (!state) return this;
|
|
176
|
-
this[
|
|
177
|
-
this[
|
|
178
|
-
const exec = this[
|
|
201
|
+
this[_constants.K_STOPPED] = !!state.stopped;
|
|
202
|
+
this[_constants.K_STATUS] = state.status;
|
|
203
|
+
const exec = this[_constants.K_EXECUTION];
|
|
179
204
|
exec.set('executionId', state.executionId);
|
|
180
|
-
this[
|
|
181
|
-
...this[
|
|
205
|
+
this[_constants.K_COUNTERS] = {
|
|
206
|
+
...this[_constants.K_COUNTERS],
|
|
182
207
|
...state.counters
|
|
183
208
|
};
|
|
184
209
|
this.environment.recover(state.environment);
|
|
185
210
|
if (state.execution) {
|
|
186
|
-
exec.set('execution', new _ProcessExecution.
|
|
211
|
+
exec.set('execution', new _ProcessExecution.ProcessExecution(this, this.context).recover(state.execution, recoveredVersion));
|
|
187
212
|
}
|
|
188
213
|
this.broker.recover(state.broker);
|
|
189
214
|
return this;
|
|
190
215
|
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Walk activity graph from the given start id, or every start activity when omitted.
|
|
219
|
+
* @param {string} [startId]
|
|
220
|
+
* @returns {import('#types').ShakeResult}
|
|
221
|
+
*/
|
|
191
222
|
Process.prototype.shake = function shake(startId) {
|
|
192
223
|
if (this.isRunning) return this.execution.shake(startId);
|
|
193
|
-
return new _ProcessExecution.
|
|
224
|
+
return new _ProcessExecution.ProcessExecution(this, this.context).shake(startId);
|
|
194
225
|
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Stop the process if running.
|
|
229
|
+
*/
|
|
195
230
|
Process.prototype.stop = function stop() {
|
|
196
231
|
if (!this.isRunning) return;
|
|
197
232
|
this.getApi().stop();
|
|
198
233
|
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Resolve a Process Api wrapper, preferring the running execution if any.
|
|
237
|
+
* @param {import('#types').ElementBrokerMessage} [message]
|
|
238
|
+
* @returns {import('#types').IApi<this>}
|
|
239
|
+
*/
|
|
199
240
|
Process.prototype.getApi = function getApi(message) {
|
|
200
241
|
const execution = this.execution;
|
|
201
242
|
if (execution) return execution.getApi(message);
|
|
202
|
-
return (0, _Api.ProcessApi)(this.broker, message || this[
|
|
243
|
+
return (0, _Api.ProcessApi)(this.broker, message || this[_constants.K_STATE_MESSAGE]);
|
|
203
244
|
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Send a delegated signal to the running process.
|
|
248
|
+
* @param {import('#types').signalMessage} [message]
|
|
249
|
+
*/
|
|
204
250
|
Process.prototype.signal = function signal(message) {
|
|
205
251
|
return this.getApi().signal(message, {
|
|
206
252
|
delegate: true
|
|
207
253
|
});
|
|
208
254
|
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Cancel a running activity inside the process by delegated api message.
|
|
258
|
+
* @param {import('#types').signalMessage} [message]
|
|
259
|
+
*/
|
|
209
260
|
Process.prototype.cancelActivity = function cancelActivity(message) {
|
|
210
261
|
return this.getApi().cancel(message, {
|
|
211
262
|
delegate: true
|
|
212
263
|
});
|
|
213
264
|
};
|
|
265
|
+
|
|
266
|
+
/** @internal */
|
|
214
267
|
Process.prototype._activateRunConsumers = function activateRunConsumers() {
|
|
215
|
-
this[
|
|
268
|
+
this[_constants.K_CONSUMING] = true;
|
|
216
269
|
const broker = this.broker;
|
|
217
270
|
const {
|
|
218
271
|
onApiMessage,
|
|
219
272
|
onRunMessage
|
|
220
|
-
} = this[
|
|
273
|
+
} = this[_constants.K_MESSAGE_HANDLERS];
|
|
221
274
|
broker.subscribeTmp('api', `process.*.${this.executionId}`, onApiMessage, {
|
|
222
275
|
noAck: true,
|
|
223
276
|
consumerTag: '_process-api',
|
|
@@ -228,13 +281,17 @@ Process.prototype._activateRunConsumers = function activateRunConsumers() {
|
|
|
228
281
|
consumerTag: '_process-run'
|
|
229
282
|
});
|
|
230
283
|
};
|
|
284
|
+
|
|
285
|
+
/** @internal */
|
|
231
286
|
Process.prototype._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
232
287
|
const broker = this.broker;
|
|
233
288
|
broker.cancel('_process-api');
|
|
234
289
|
broker.cancel('_process-run');
|
|
235
290
|
broker.cancel('_process-execution');
|
|
236
|
-
this[
|
|
291
|
+
this[_constants.K_CONSUMING] = false;
|
|
237
292
|
};
|
|
293
|
+
|
|
294
|
+
/** @internal */
|
|
238
295
|
Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
239
296
|
const {
|
|
240
297
|
content,
|
|
@@ -243,45 +300,45 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
243
300
|
if (routingKey === 'run.resume') {
|
|
244
301
|
return this._onResumeMessage(message);
|
|
245
302
|
}
|
|
246
|
-
this[
|
|
303
|
+
this[_constants.K_STATE_MESSAGE] = message;
|
|
247
304
|
switch (routingKey) {
|
|
248
305
|
case 'run.enter':
|
|
249
306
|
{
|
|
250
307
|
this._debug('enter');
|
|
251
|
-
this[
|
|
308
|
+
this[_constants.K_STATUS] = 'entered';
|
|
252
309
|
if (fields.redelivered) break;
|
|
253
|
-
this[
|
|
310
|
+
this[_constants.K_EXECUTION].delete('execution');
|
|
254
311
|
this._publishEvent('enter', content);
|
|
255
312
|
break;
|
|
256
313
|
}
|
|
257
314
|
case 'run.start':
|
|
258
315
|
{
|
|
259
316
|
this._debug('start');
|
|
260
|
-
this[
|
|
317
|
+
this[_constants.K_STATUS] = 'start';
|
|
261
318
|
this._publishEvent('start', content);
|
|
262
319
|
break;
|
|
263
320
|
}
|
|
264
321
|
case 'run.execute':
|
|
265
322
|
{
|
|
266
|
-
const exec = this[
|
|
267
|
-
this[
|
|
323
|
+
const exec = this[_constants.K_EXECUTION];
|
|
324
|
+
this[_constants.K_STATUS] = 'executing';
|
|
268
325
|
const executeMessage = (0, _messageHelper.cloneMessage)(message);
|
|
269
326
|
let execution = exec.get('execution');
|
|
270
327
|
if (fields.redelivered && !execution) {
|
|
271
328
|
executeMessage.fields.redelivered = undefined;
|
|
272
329
|
}
|
|
273
|
-
this[
|
|
274
|
-
this.broker.getQueue('execution-q').assertConsumer(this[
|
|
330
|
+
this[_constants.K_EXECUTE_MESSAGE] = message;
|
|
331
|
+
this.broker.getQueue('execution-q').assertConsumer(this[_constants.K_MESSAGE_HANDLERS].onExecutionMessage, {
|
|
275
332
|
exclusive: true,
|
|
276
333
|
consumerTag: '_process-execution'
|
|
277
334
|
});
|
|
278
|
-
execution = execution || new _ProcessExecution.
|
|
335
|
+
execution = execution || new _ProcessExecution.ProcessExecution(this, this.context);
|
|
279
336
|
exec.set('execution', execution);
|
|
280
337
|
return execution.execute(executeMessage);
|
|
281
338
|
}
|
|
282
339
|
case 'run.error':
|
|
283
340
|
{
|
|
284
|
-
this[
|
|
341
|
+
this[_constants.K_STATUS] = 'errored';
|
|
285
342
|
this._publishEvent('error', (0, _messageHelper.cloneContent)(content, {
|
|
286
343
|
error: fields.redelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
|
|
287
344
|
}));
|
|
@@ -289,26 +346,26 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
289
346
|
}
|
|
290
347
|
case 'run.end':
|
|
291
348
|
{
|
|
292
|
-
this[
|
|
349
|
+
this[_constants.K_STATUS] = 'end';
|
|
293
350
|
if (fields.redelivered) break;
|
|
294
351
|
this._debug('completed');
|
|
295
|
-
this[
|
|
352
|
+
this[_constants.K_COUNTERS].completed++;
|
|
296
353
|
this.broker.publish('run', 'run.leave', content);
|
|
297
354
|
this._publishEvent('end', content);
|
|
298
355
|
break;
|
|
299
356
|
}
|
|
300
357
|
case 'run.discarded':
|
|
301
358
|
{
|
|
302
|
-
this[
|
|
359
|
+
this[_constants.K_STATUS] = 'discarded';
|
|
303
360
|
if (fields.redelivered) break;
|
|
304
|
-
this[
|
|
361
|
+
this[_constants.K_COUNTERS].discarded++;
|
|
305
362
|
this.broker.publish('run', 'run.leave', content);
|
|
306
363
|
this._publishEvent('discarded', content);
|
|
307
364
|
break;
|
|
308
365
|
}
|
|
309
366
|
case 'run.leave':
|
|
310
367
|
{
|
|
311
|
-
this[
|
|
368
|
+
this[_constants.K_STATUS] = undefined;
|
|
312
369
|
message.ack();
|
|
313
370
|
this._deactivateRunConsumers();
|
|
314
371
|
const {
|
|
@@ -321,9 +378,11 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
321
378
|
}
|
|
322
379
|
message.ack();
|
|
323
380
|
};
|
|
381
|
+
|
|
382
|
+
/** @internal */
|
|
324
383
|
Process.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
325
384
|
message.ack();
|
|
326
|
-
const stateMessage = this[
|
|
385
|
+
const stateMessage = this[_constants.K_STATE_MESSAGE];
|
|
327
386
|
switch (stateMessage.fields.routingKey) {
|
|
328
387
|
case 'run.enter':
|
|
329
388
|
case 'run.start':
|
|
@@ -338,6 +397,8 @@ Process.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
|
338
397
|
this._debug(`resume from ${this.status}`);
|
|
339
398
|
return this.broker.publish('run', stateMessage.fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
|
|
340
399
|
};
|
|
400
|
+
|
|
401
|
+
/** @internal */
|
|
341
402
|
Process.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
342
403
|
const content = message.content;
|
|
343
404
|
const messageType = message.properties.type;
|
|
@@ -361,10 +422,12 @@ Process.prototype._onExecutionMessage = function onExecutionMessage(routingKey,
|
|
|
361
422
|
this.broker.publish('run', 'run.end', content);
|
|
362
423
|
}
|
|
363
424
|
}
|
|
364
|
-
const executeMessage = this[
|
|
365
|
-
this[
|
|
425
|
+
const executeMessage = this[_constants.K_EXECUTE_MESSAGE];
|
|
426
|
+
this[_constants.K_EXECUTE_MESSAGE] = null;
|
|
366
427
|
executeMessage.ack();
|
|
367
428
|
};
|
|
429
|
+
|
|
430
|
+
/** @internal */
|
|
368
431
|
Process.prototype._publishEvent = function publishEvent(state, content) {
|
|
369
432
|
const eventContent = this._createMessage({
|
|
370
433
|
...content,
|
|
@@ -375,6 +438,12 @@ Process.prototype._publishEvent = function publishEvent(state, content) {
|
|
|
375
438
|
mandatory: state === 'error'
|
|
376
439
|
});
|
|
377
440
|
};
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Deliver a message to a target activity or start activity that references it.
|
|
444
|
+
* Starts the process if a target is found and the process is idle.
|
|
445
|
+
* @param {import('#types').ElementBrokerMessage} message
|
|
446
|
+
*/
|
|
378
447
|
Process.prototype.sendMessage = function sendMessage(message) {
|
|
379
448
|
const messageContent = message?.content;
|
|
380
449
|
if (!messageContent) return;
|
|
@@ -393,37 +462,61 @@ Process.prototype.sendMessage = function sendMessage(message) {
|
|
|
393
462
|
delegate: true
|
|
394
463
|
});
|
|
395
464
|
};
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @param {string} childId
|
|
468
|
+
*/
|
|
396
469
|
Process.prototype.getActivityById = function getActivityById(childId) {
|
|
397
470
|
const execution = this.execution;
|
|
398
471
|
if (execution) return execution.getActivityById(childId);
|
|
399
472
|
return this.context.getActivityById(childId);
|
|
400
473
|
};
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Get every activity in the process scope.
|
|
477
|
+
*/
|
|
401
478
|
Process.prototype.getActivities = function getActivities() {
|
|
402
479
|
const execution = this.execution;
|
|
403
480
|
if (execution) return execution.getActivities();
|
|
404
481
|
return this.context.getActivities(this.id);
|
|
405
482
|
};
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Get start activities, optionally filtered by referenced event definition.
|
|
486
|
+
* @param {import('#types').startActivityFilterOptions} [filterOptions]
|
|
487
|
+
*/
|
|
406
488
|
Process.prototype.getStartActivities = function getStartActivities(filterOptions) {
|
|
407
489
|
return this.context.getStartActivities(filterOptions, this.id);
|
|
408
490
|
};
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Get sequence flows in the process scope.
|
|
494
|
+
*/
|
|
409
495
|
Process.prototype.getSequenceFlows = function getSequenceFlows() {
|
|
410
496
|
const execution = this.execution;
|
|
411
497
|
if (execution) return execution.getSequenceFlows();
|
|
412
498
|
return this.context.getSequenceFlows();
|
|
413
499
|
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* @param {string} laneId
|
|
503
|
+
* @returns {import('./Lane.js').Lane | undefined}
|
|
504
|
+
*/
|
|
414
505
|
Process.prototype.getLaneById = function getLaneById(laneId) {
|
|
415
|
-
|
|
416
|
-
if (!lanes) return;
|
|
417
|
-
return lanes.find(lane => lane.id === laneId);
|
|
506
|
+
return this[K_LANES]?.find(lane => lane.id === laneId);
|
|
418
507
|
};
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* List currently postponed activities as Api wrappers.
|
|
511
|
+
* @param {import('#types').filterPostponed} [filterFn]
|
|
512
|
+
*/
|
|
419
513
|
Process.prototype.getPostponed = function getPostponed(...args) {
|
|
420
|
-
|
|
421
|
-
if (!execution) return [];
|
|
422
|
-
return execution.getPostponed(...args);
|
|
514
|
+
return this.execution?.getPostponed(...args) || [];
|
|
423
515
|
};
|
|
516
|
+
|
|
517
|
+
/** @internal */
|
|
424
518
|
Process.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
425
|
-
|
|
426
|
-
switch (messageType) {
|
|
519
|
+
switch (message.properties.type) {
|
|
427
520
|
case 'stop':
|
|
428
521
|
{
|
|
429
522
|
if (this.execution && !this.execution.completed) return;
|
|
@@ -432,11 +525,15 @@ Process.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
432
525
|
}
|
|
433
526
|
}
|
|
434
527
|
};
|
|
528
|
+
|
|
529
|
+
/** @internal */
|
|
435
530
|
Process.prototype._onStop = function onStop() {
|
|
436
|
-
this[
|
|
531
|
+
this[_constants.K_STOPPED] = true;
|
|
437
532
|
this._deactivateRunConsumers();
|
|
438
533
|
return this._publishEvent('stop');
|
|
439
534
|
};
|
|
535
|
+
|
|
536
|
+
/** @internal */
|
|
440
537
|
Process.prototype._createMessage = function createMessage(override) {
|
|
441
538
|
return {
|
|
442
539
|
id: this.id,
|
|
@@ -449,6 +546,8 @@ Process.prototype._createMessage = function createMessage(override) {
|
|
|
449
546
|
...override
|
|
450
547
|
};
|
|
451
548
|
};
|
|
549
|
+
|
|
550
|
+
/** @internal */
|
|
452
551
|
Process.prototype._debug = function debug(msg) {
|
|
453
552
|
this.logger.debug(`<${this.id}> ${msg}`);
|
|
454
553
|
};
|