bpmn-engine 26.0.3 → 26.0.5

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 CHANGED
@@ -2,24 +2,31 @@
2
2
 
3
3
  [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
4
4
 
5
- [![Build](https://github.com/paed01/bpmn-engine/actions/workflows/build.yaml/badge.svg)](https://github.com/paed01/bpmn-engine/actions/workflows/build.yaml)[![Build status](https://ci.appveyor.com/api/projects/status/670n39fivq1g3nu5/branch/master?svg=true)](https://ci.appveyor.com/project/paed01/bpmn-engine/branch/master)[![Coverage Status](https://coveralls.io/repos/github/paed01/bpmn-engine/badge.svg?branch=master)](https://coveralls.io/github/paed01/bpmn-engine?branch=master)
5
+ [![Build](https://github.com/paed01/bpmn-engine/actions/workflows/build.yaml/badge.svg)](https://github.com/paed01/bpmn-engine/actions/workflows/build.yaml)[![Build (Windows)](https://github.com/paed01/bpmn-engine/actions/workflows/build-windows.yaml/badge.svg)](https://github.com/paed01/bpmn-engine/actions/workflows/build-windows.yaml)[![Coverage Status](https://coveralls.io/repos/github/paed01/bpmn-engine/badge.svg?branch=master)](https://coveralls.io/github/paed01/bpmn-engine?branch=master)
6
6
 
7
7
  # Introduction
8
8
 
9
9
  BPMN 2.0 execution engine. Open source javascript workflow engine.
10
10
 
11
+ Documentation:
12
+
11
13
  - [API](/docs/API.md)
12
- - [Changelog](/CHANGELOG.md)
13
14
  - [Examples](/docs/Examples.md)
14
15
  - [Upgrade version](/docs/Upgrade.md)
15
- - [Peer dependencies](#peer-dependencies)
16
16
  - [bpmn-moddle 9 vs 10](/docs/bpmn-moddle.md)
17
+ - [Changelog](/CHANGELOG.md)
18
+
19
+ <!-- toc -->
20
+
21
+ - [Peer dependencies](#peer-dependencies)
17
22
  - [Supported elements](#supported-elements)
18
23
  - [Extensions](#extensions)
19
24
  - [Debug](#debug)
20
- - [Example process](#a-pretty-image-of-a-process)
25
+ - [A pretty image of a process](#a-pretty-image-of-a-process)
21
26
  - [Acknowledgments](#acknowledgments)
22
27
 
28
+ <!-- /toc -->
29
+
23
30
  # Peer dependencies
24
31
 
25
32
  The runtime dependencies are declared as **peer dependencies**, so you install and pin them yourself and the engine reuses your single copy:
@@ -28,13 +35,13 @@ The runtime dependencies are declared as **peer dependencies**, so you install a
28
35
  npm install bpmn-engine bpmn-elements bpmn-moddle moddle-context-serializer debug smqp
29
36
  ```
30
37
 
31
- | Peer dependency | Range | Role |
32
- | ---------------------------------------------------------------------------------- | --------- | ------------------------------------------------- |
33
- | [`bpmn-elements`](https://github.com/paed01/bpmn-elements) | `>=18` | element behaviour functions |
34
- | [`bpmn-moddle`](https://github.com/bpmn-io/bpmn-moddle) | `>=9` | BPMN XML parser ([9 vs 10](/docs/bpmn-moddle.md)) |
35
- | [`moddle-context-serializer`](https://github.com/paed01/moddle-context-serializer) | `>=6` | persistable source context |
36
- | [`smqp`](https://github.com/paed01/smqp) | `^13.0.1` | message broker driving execution |
37
- | [`debug`](https://github.com/debug-js/debug) | `>=4` | logging |
38
+ | Peer dependency | Range | Role |
39
+ | ---------------------------------------------------------------------------------- | ----------- | ------------------------------------------------- |
40
+ | [`bpmn-elements`](https://github.com/paed01/bpmn-elements) | `>=18.0.25` | element behaviour functions |
41
+ | [`bpmn-moddle`](https://github.com/bpmn-io/bpmn-moddle) | `>=9` | BPMN XML parser ([9 vs 10](/docs/bpmn-moddle.md)) |
42
+ | [`moddle-context-serializer`](https://github.com/paed01/moddle-context-serializer) | `>=6` | persistable source context |
43
+ | [`smqp`](https://github.com/paed01/smqp) | `>=15` | message broker driving execution |
44
+ | [`debug`](https://github.com/debug-js/debug) | `>=4` | logging |
38
45
 
39
46
  `bpmn-moddle` spans a major version on purpose — see [bpmn-moddle 9 vs 10](/docs/bpmn-moddle.md) for the import change and how persisted state stays compatible across the upgrade.
40
47
 
package/lib/index.cjs CHANGED
@@ -412,7 +412,7 @@ Engine.prototype.getState = async function getState() {
412
412
 
413
413
  /**
414
414
  * @template R
415
- * @param {import('bpmn-engine').BpmnEngineEvent} eventName
415
+ * @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
416
416
  * @returns {Promise<R>}
417
417
  */
418
418
  Engine.prototype.waitFor = function waitFor(eventName) {
@@ -481,7 +481,7 @@ Engine.prototype._getModdleContext = function getModdleContext(source) {
481
481
 
482
482
  /**
483
483
  * @param {Engine} engine
484
- * @param {any[]} definitions
484
+ * @param {import('bpmn-elements').Definition[]} definitions
485
485
  * @param {import('bpmn-engine').BpmnEngineExecuteOptions} [options]
486
486
  * @param {boolean} [isRecovered]
487
487
  */
@@ -820,7 +820,7 @@ Execution.prototype.cancelActivity = function cancelActivity(payload) {
820
820
 
821
821
  /**
822
822
  * @template T
823
- * @param {import('bpmn-engine').BpmnEngineEvent} eventName
823
+ * @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
824
824
  * @returns {Promise<T>}
825
825
  */
826
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.3",
4
+ "version": "26.0.5",
5
5
  "type": "module",
6
6
  "module": "./src/index.js",
7
7
  "main": "./lib/index.cjs",
@@ -34,10 +34,9 @@
34
34
  "test": "mocha -p -R @bonniernews/hot-bev",
35
35
  "posttest": "npm run lint && npm run toc && npm run dist && npm run test:md",
36
36
  "lint": "eslint . --cache && prettier . -c --cache",
37
- "wintest": "mocha",
38
37
  "cov:html": "c8 -r html -r text mocha -p -R @bonniernews/hot-bev",
39
38
  "test:lcov": "c8 -r lcov mocha && npm run lint",
40
- "toc": "node scripts/generate-api-toc ./docs/API.md,./docs/Examples.md",
39
+ "toc": "toc README.md docs/API.md docs/Examples.md docs/Upgrade.md",
41
40
  "test:md": "texample ./docs/API.md,./docs/Examples.md,./docs/Upgrade.md -c .mocharc.json",
42
41
  "dist": "rollup -c",
43
42
  "prepack": "npm run dist"
@@ -63,6 +62,7 @@
63
62
  }
64
63
  },
65
64
  "devDependencies": {
65
+ "@0dep/toc": "^1.0.1",
66
66
  "@bonniernews/hot-bev": "^0.4.0",
67
67
  "@eslint/js": "^10.0.1",
68
68
  "@rollup/plugin-commonjs": "^29.0.0",
@@ -71,11 +71,11 @@
71
71
  "@types/mocha": "^10.0.10",
72
72
  "@types/node": "^20.19.40",
73
73
  "bent": "^7.3.12",
74
- "bpmn-elements": "^18.0.15",
74
+ "bpmn-elements": "^18.0.24",
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": "^7.0.1",
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",
@@ -91,10 +91,10 @@
91
91
  "typescript": "^7.0.2"
92
92
  },
93
93
  "peerDependencies": {
94
- "bpmn-elements": ">=18",
94
+ "bpmn-elements": ">=18.0.25",
95
95
  "bpmn-moddle": ">=9",
96
96
  "debug": ">=4",
97
97
  "moddle-context-serializer": ">=6",
98
- "smqp": "^13.0.1"
98
+ "smqp": ">=15"
99
99
  }
100
100
  }
package/src/index.js CHANGED
@@ -265,7 +265,7 @@ Engine.prototype.getState = async function getState() {
265
265
 
266
266
  /**
267
267
  * @template R
268
- * @param {import('bpmn-engine').BpmnEngineEvent} eventName
268
+ * @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
269
269
  * @returns {Promise<R>}
270
270
  */
271
271
  Engine.prototype.waitFor = function waitFor(eventName) {
@@ -334,7 +334,7 @@ Engine.prototype._getModdleContext = function getModdleContext(source) {
334
334
 
335
335
  /**
336
336
  * @param {Engine} engine
337
- * @param {any[]} definitions
337
+ * @param {import('bpmn-elements').Definition[]} definitions
338
338
  * @param {import('bpmn-engine').BpmnEngineExecuteOptions} [options]
339
339
  * @param {boolean} [isRecovered]
340
340
  */
@@ -673,7 +673,7 @@ Execution.prototype.cancelActivity = function cancelActivity(payload) {
673
673
 
674
674
  /**
675
675
  * @template T
676
- * @param {import('bpmn-engine').BpmnEngineEvent} eventName
676
+ * @param {import('bpmn-engine').BpmnEngineEvent | string} eventName
677
677
  * @returns {Promise<T>}
678
678
  */
679
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
- export type BpmnEngineEvent = 'error' | 'stop' | 'end' | 'wait';
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
- export type BpmnSequenceFlowEvent = 'flow.take' | 'flow.discard' | 'flow.looped';
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
- emit(eventName: string, ...args: any[]): void;
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,15 +180,9 @@ 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
- export function Execution(
118
- engine: Engine,
119
- definitions: Definition[],
120
- options?: BpmnEngineExecuteOptions,
121
- isRecovered?: boolean
122
- ): Execution;
123
186
  export class Execution {
124
187
  constructor(engine: Engine, definitions: Definition[], options?: BpmnEngineExecuteOptions, isRecovered?: boolean);
125
188
  options: BpmnEngineExecuteOptions;
@@ -141,7 +204,7 @@ declare module 'bpmn-engine' {
141
204
  signal(message?: BpmnMessage, options?: { ignoreSameDefinition?: boolean }): void;
142
205
  cancelActivity(message?: BpmnMessage): void;
143
206
 
144
- waitFor<R>(eventName: BpmnEngineEvent): Promise<R>;
207
+ waitFor<R>(eventName: BpmnEngineEvent | string): Promise<R>;
145
208
  }
146
209
 
147
210
  export interface JavaScripts extends IScripts {