bpmn-engine 26.0.2 → 26.0.4
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/lib/index.cjs +9 -5
- package/package.json +3 -3
- package/src/index.js +8 -5
- package/types/index.d.ts +75 -6
package/lib/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var node_module = require('node:module');
|
|
6
6
|
var node_events = require('node:events');
|
|
7
7
|
var node_url = require('node:url');
|
|
8
|
-
var
|
|
8
|
+
var bpmnModdle = require('bpmn-moddle');
|
|
9
9
|
var Elements = require('bpmn-elements');
|
|
10
10
|
var smqp = require('smqp');
|
|
11
11
|
var moddleContextSerializer = require('moddle-context-serializer');
|
|
@@ -30,6 +30,7 @@ function _interopNamespaceDefault(e) {
|
|
|
30
30
|
return Object.freeze(n);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
var bpmnModdle__namespace = /*#__PURE__*/_interopNamespaceDefault(bpmnModdle);
|
|
33
34
|
var Elements__namespace = /*#__PURE__*/_interopNamespaceDefault(Elements);
|
|
34
35
|
|
|
35
36
|
function Logger(scope) {
|
|
@@ -164,6 +165,9 @@ ProcessOutputDataObject.prototype.write = function writeDataObject(broker, excha
|
|
|
164
165
|
const nodeRequire = node_module.createRequire(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
165
166
|
const { version: engineVersion } = nodeRequire('../package.json');
|
|
166
167
|
|
|
168
|
+
// bpmn-moddle@9 exposes the parser as default export, bpmn-moddle@10 as the named export BpmnModdle
|
|
169
|
+
const BpmnModdle = bpmnModdle__namespace.BpmnModdle ?? bpmnModdle__namespace.default;
|
|
170
|
+
|
|
167
171
|
const kEngine = Symbol.for('engine');
|
|
168
172
|
const kEnvironment = Symbol.for('environment');
|
|
169
173
|
const kExecuting = Symbol.for('executing');
|
|
@@ -408,7 +412,7 @@ Engine.prototype.getState = async function getState() {
|
|
|
408
412
|
|
|
409
413
|
/**
|
|
410
414
|
* @template R
|
|
411
|
-
* @param {import('bpmn-engine').BpmnEngineEvent} eventName
|
|
415
|
+
* @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
|
|
412
416
|
* @returns {Promise<R>}
|
|
413
417
|
*/
|
|
414
418
|
Engine.prototype.waitFor = function waitFor(eventName) {
|
|
@@ -471,8 +475,8 @@ Engine.prototype._serializeModdleContext = function serializeModdleContext(moddl
|
|
|
471
475
|
|
|
472
476
|
/** @internal */
|
|
473
477
|
Engine.prototype._getModdleContext = function getModdleContext(source) {
|
|
474
|
-
const
|
|
475
|
-
return
|
|
478
|
+
const moddle = new BpmnModdle(this.options.moddleOptions);
|
|
479
|
+
return moddle.fromXML(Buffer.isBuffer(source) ? source.toString() : source.trim());
|
|
476
480
|
};
|
|
477
481
|
|
|
478
482
|
/**
|
|
@@ -816,7 +820,7 @@ Execution.prototype.cancelActivity = function cancelActivity(payload) {
|
|
|
816
820
|
|
|
817
821
|
/**
|
|
818
822
|
* @template T
|
|
819
|
-
* @param {import('bpmn-engine').BpmnEngineEvent} eventName
|
|
823
|
+
* @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
|
|
820
824
|
* @returns {Promise<T>}
|
|
821
825
|
*/
|
|
822
826
|
Execution.prototype.waitFor = function waitFor(...args) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-engine",
|
|
3
3
|
"description": "BPMN 2.0 execution engine. Open source javascript workflow engine.",
|
|
4
|
-
"version": "26.0.
|
|
4
|
+
"version": "26.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./src/index.js",
|
|
7
7
|
"main": "./lib/index.cjs",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"bpmn-moddle": "^9.0.4",
|
|
76
76
|
"bpmn-moddle-10": "npm:bpmn-moddle@^10.0.0",
|
|
77
77
|
"c8": "^12.0.0",
|
|
78
|
-
"camunda-bpmn-moddle": "^
|
|
78
|
+
"camunda-bpmn-moddle": "^8.0.1",
|
|
79
79
|
"chai": "^6.2.0",
|
|
80
80
|
"chronokinesis": "^8.0.0",
|
|
81
81
|
"debug": "^4.4.3",
|
|
@@ -95,6 +95,6 @@
|
|
|
95
95
|
"bpmn-moddle": ">=9",
|
|
96
96
|
"debug": ">=4",
|
|
97
97
|
"moddle-context-serializer": ">=6",
|
|
98
|
-
"smqp": "
|
|
98
|
+
"smqp": ">=13"
|
|
99
99
|
}
|
|
100
100
|
}
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as bpmnModdle from 'bpmn-moddle';
|
|
6
6
|
import * as Elements from 'bpmn-elements';
|
|
7
7
|
import { Broker } from 'smqp';
|
|
8
8
|
import { Serializer, deserialize, TypeResolver } from 'moddle-context-serializer';
|
|
@@ -15,6 +15,9 @@ import ProcessOutputDataObject from './extensions/ProcessOutputDataObject.js';
|
|
|
15
15
|
const nodeRequire = createRequire(fileURLToPath(import.meta.url));
|
|
16
16
|
const { version: engineVersion } = nodeRequire('../package.json');
|
|
17
17
|
|
|
18
|
+
// bpmn-moddle@9 exposes the parser as default export, bpmn-moddle@10 as the named export BpmnModdle
|
|
19
|
+
const BpmnModdle = bpmnModdle.BpmnModdle ?? bpmnModdle.default;
|
|
20
|
+
|
|
18
21
|
const kEngine = Symbol.for('engine');
|
|
19
22
|
const kEnvironment = Symbol.for('environment');
|
|
20
23
|
const kExecuting = Symbol.for('executing');
|
|
@@ -262,7 +265,7 @@ Engine.prototype.getState = async function getState() {
|
|
|
262
265
|
|
|
263
266
|
/**
|
|
264
267
|
* @template R
|
|
265
|
-
* @param {import('bpmn-engine').BpmnEngineEvent} eventName
|
|
268
|
+
* @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
|
|
266
269
|
* @returns {Promise<R>}
|
|
267
270
|
*/
|
|
268
271
|
Engine.prototype.waitFor = function waitFor(eventName) {
|
|
@@ -325,8 +328,8 @@ Engine.prototype._serializeModdleContext = function serializeModdleContext(moddl
|
|
|
325
328
|
|
|
326
329
|
/** @internal */
|
|
327
330
|
Engine.prototype._getModdleContext = function getModdleContext(source) {
|
|
328
|
-
const
|
|
329
|
-
return
|
|
331
|
+
const moddle = new BpmnModdle(this.options.moddleOptions);
|
|
332
|
+
return moddle.fromXML(Buffer.isBuffer(source) ? source.toString() : source.trim());
|
|
330
333
|
};
|
|
331
334
|
|
|
332
335
|
/**
|
|
@@ -670,7 +673,7 @@ Execution.prototype.cancelActivity = function cancelActivity(payload) {
|
|
|
670
673
|
|
|
671
674
|
/**
|
|
672
675
|
* @template T
|
|
673
|
-
* @param {import('bpmn-engine').BpmnEngineEvent} eventName
|
|
676
|
+
* @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
|
|
674
677
|
* @returns {Promise<T>}
|
|
675
678
|
*/
|
|
676
679
|
Execution.prototype.waitFor = function waitFor(...args) {
|
package/types/index.d.ts
CHANGED
|
@@ -16,20 +16,82 @@ declare module 'bpmn-engine' {
|
|
|
16
16
|
Script,
|
|
17
17
|
} from 'bpmn-elements';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Engine events.
|
|
21
|
+
* - `error`: A non-recoverable error has occurred
|
|
22
|
+
* - `stop`: Execution was stopped
|
|
23
|
+
* - `end`: Execution completed
|
|
24
|
+
*/
|
|
25
|
+
export type BpmnEngineEvent = 'error' | 'stop' | 'end';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Activity events emitted to the listener.
|
|
29
|
+
* - `activity.enter`: An activity is entered
|
|
30
|
+
* - `activity.start`: An activity is started
|
|
31
|
+
* - `activity.wait`: The activity is postponed for some reason, e.g. a user task is waiting to be signaled or a message is expected
|
|
32
|
+
* - `wait`: Same as above
|
|
33
|
+
* - `activity.timer`: A timer was started
|
|
34
|
+
* - `activity.timeout`: A timer timed out
|
|
35
|
+
* - `activity.signal`: The activity was signaled
|
|
36
|
+
* - `activity.catch`: The activity caught a message, signal, error, etc
|
|
37
|
+
* - `activity.discard`: The activity was discarded
|
|
38
|
+
* - `activity.cancel`: The activity was cancelled
|
|
39
|
+
* - `activity.end`: An activity has ended successfully
|
|
40
|
+
* - `activity.leave`: The execution left the activity
|
|
41
|
+
* - `activity.stop`: Activity run was stopped
|
|
42
|
+
* - `activity.throw`: A recoverable error was thrown
|
|
43
|
+
* - `activity.error`: A non-recoverable error has occurred
|
|
44
|
+
*/
|
|
21
45
|
export type BpmnActivityEvent =
|
|
22
46
|
| 'activity.enter'
|
|
23
47
|
| 'activity.start'
|
|
24
48
|
| 'activity.wait'
|
|
25
49
|
| 'wait'
|
|
50
|
+
| 'activity.timer'
|
|
51
|
+
| 'activity.timeout'
|
|
52
|
+
| 'activity.signal'
|
|
53
|
+
| 'activity.catch'
|
|
54
|
+
| 'activity.discard'
|
|
55
|
+
| 'activity.cancel'
|
|
26
56
|
| 'activity.end'
|
|
27
57
|
| 'activity.leave'
|
|
28
58
|
| 'activity.stop'
|
|
29
59
|
| 'activity.throw'
|
|
30
60
|
| 'activity.error';
|
|
31
61
|
|
|
32
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Sequence flow events emitted to the listener.
|
|
64
|
+
* - `flow.take`: The sequence flow was taken
|
|
65
|
+
*
|
|
66
|
+
* Since bpmn-elements@18 non-selected sequence flows are no longer discarded, so
|
|
67
|
+
* `flow.discard` and `flow.looped` are never emitted during execution.
|
|
68
|
+
*/
|
|
69
|
+
export type BpmnSequenceFlowEvent = 'flow.take';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Process events emitted to the listener.
|
|
73
|
+
*/
|
|
74
|
+
export type BpmnProcessEvent =
|
|
75
|
+
'process.enter' | 'process.end' | 'process.leave' | 'process.error' | 'process.terminate' | 'process.discarded';
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Definition events emitted to the listener.
|
|
79
|
+
*/
|
|
80
|
+
export type BpmnDefinitionEvent = 'definition.leave' | 'definition.stop' | 'definition.error';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* All events emitted to the listener. Every `definition.#`, `process.#`, `activity.#`, and `flow.#`
|
|
84
|
+
* routing key published by bpmn-elements is forwarded verbatim, the named unions are the documented ones.
|
|
85
|
+
*/
|
|
86
|
+
export type BpmnListenerEvent =
|
|
87
|
+
| BpmnDefinitionEvent
|
|
88
|
+
| BpmnProcessEvent
|
|
89
|
+
| BpmnActivityEvent
|
|
90
|
+
| BpmnSequenceFlowEvent
|
|
91
|
+
| `definition.${string}`
|
|
92
|
+
| `process.${string}`
|
|
93
|
+
| `activity.${string}`
|
|
94
|
+
| `flow.${string}`;
|
|
33
95
|
|
|
34
96
|
export type BpmnEngineRunningStatus = 'idle' | 'running' | 'stopped' | 'error';
|
|
35
97
|
|
|
@@ -40,7 +102,14 @@ declare module 'bpmn-engine' {
|
|
|
40
102
|
}
|
|
41
103
|
|
|
42
104
|
export interface IListenerEmitter {
|
|
43
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Receive engine execution events
|
|
107
|
+
* @param eventName routing key of the event
|
|
108
|
+
* @param elementApi api of the element that emitted the event
|
|
109
|
+
* @param execution the engine execution
|
|
110
|
+
*/
|
|
111
|
+
emit(eventName: BpmnListenerEvent, elementApi: IApi<ElementBase>, execution: Execution): unknown;
|
|
112
|
+
emit(eventName: string, ...args: any[]): unknown;
|
|
44
113
|
}
|
|
45
114
|
|
|
46
115
|
export interface BpmnEngineExecuteOptions extends EnvironmentOptions {
|
|
@@ -111,7 +180,7 @@ declare module 'bpmn-engine' {
|
|
|
111
180
|
|
|
112
181
|
addSource(options?: { sourceContext: SerializableContext }): void;
|
|
113
182
|
|
|
114
|
-
waitFor<R>(eventName: BpmnEngineEvent): Promise<R>;
|
|
183
|
+
waitFor<R>(eventName: BpmnEngineEvent | string): Promise<R>;
|
|
115
184
|
}
|
|
116
185
|
|
|
117
186
|
export function Execution(
|
|
@@ -141,7 +210,7 @@ declare module 'bpmn-engine' {
|
|
|
141
210
|
signal(message?: BpmnMessage, options?: { ignoreSameDefinition?: boolean }): void;
|
|
142
211
|
cancelActivity(message?: BpmnMessage): void;
|
|
143
212
|
|
|
144
|
-
waitFor<R>(eventName: BpmnEngineEvent): Promise<R>;
|
|
213
|
+
waitFor<R>(eventName: BpmnEngineEvent | string): Promise<R>;
|
|
145
214
|
}
|
|
146
215
|
|
|
147
216
|
export interface JavaScripts extends IScripts {
|