bpmn-engine 26.0.3 → 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 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) {
@@ -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.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": "^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",
@@ -95,6 +95,6 @@
95
95
  "bpmn-moddle": ">=9",
96
96
  "debug": ">=4",
97
97
  "moddle-context-serializer": ">=6",
98
- "smqp": "^13.0.1"
98
+ "smqp": ">=13"
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) {
@@ -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,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 {