bpmn-engine 23.0.2 → 24.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/lib/index.cjs CHANGED
@@ -280,6 +280,12 @@ Engine.prototype.stop = function stop() {
280
280
  };
281
281
 
282
282
  Engine.prototype.recover = function recover(savedState, recoverOptions) {
283
+ if (this[kExecution]?.isRunning) {
284
+ this.logger.error('recover during running execution will be deprecated next major version');
285
+ this.logger.debug(`<${this.name}> stopping current running execution`);
286
+ this[kExecution].stop();
287
+ }
288
+
283
289
  if (!savedState) return this;
284
290
 
285
291
  let name = this.name;
@@ -287,7 +293,10 @@ Engine.prototype.recover = function recover(savedState, recoverOptions) {
287
293
 
288
294
  this.logger.debug(`<${name}> recover`);
289
295
 
290
- if (recoverOptions) this[kEnvironment] = new Elements__namespace.Environment(recoverOptions);
296
+ if (recoverOptions) {
297
+ this[kEnvironment] = this[kEnvironment].clone(recoverOptions);
298
+ }
299
+
291
300
  if (savedState.environment) this[kEnvironment] = this[kEnvironment].recover(savedState.environment);
292
301
 
293
302
  if (!savedState.definitions) return this;
@@ -577,7 +586,10 @@ Execution.prototype._setup = function setup(setupOptions) {
577
586
  for (const definition of this.definitions) {
578
587
  if (listener) definition.environment.options.listener = listener;
579
588
 
580
- const { queueName } = definition.broker.subscribeTmp('event', 'definition.#', onChildMessage, { noAck: true, consumerTag: '_engine_definition' });
589
+ const { queueName } = definition.broker.subscribeTmp('event', 'definition.#', onChildMessage, {
590
+ noAck: true,
591
+ consumerTag: '_engine_definition',
592
+ });
581
593
  definition.broker.bindQueue(queueName, 'event', 'process.#');
582
594
  definition.broker.bindQueue(queueName, 'event', 'activity.#');
583
595
  definition.broker.bindQueue(queueName, 'event', 'flow.#');
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": "23.0.2",
4
+ "version": "24.0.1",
5
5
  "type": "module",
6
6
  "module": "./src/index.js",
7
7
  "main": "./lib/index.cjs",
@@ -62,14 +62,14 @@
62
62
  "chronokinesis": "^6.0.0",
63
63
  "eslint": "^9.10.0",
64
64
  "markdown-toc": "^1.2.0",
65
- "mocha": "^10.2.0",
65
+ "mocha": "^11.0.1",
66
66
  "mocha-cakes-2": "^3.3.0",
67
67
  "prettier": "^3.2.5",
68
68
  "rollup": "^4.10.0",
69
- "texample": "^0.0.6"
69
+ "texample": "^0.0.7"
70
70
  },
71
71
  "dependencies": {
72
- "bpmn-elements": "^16.2.1",
72
+ "bpmn-elements": "^17.0.0",
73
73
  "bpmn-moddle": "^9.0.1",
74
74
  "debug": "^4.3.7",
75
75
  "moddle-context-serializer": "^4.2.1"
package/src/index.js CHANGED
@@ -134,6 +134,12 @@ Engine.prototype.stop = function stop() {
134
134
  };
135
135
 
136
136
  Engine.prototype.recover = function recover(savedState, recoverOptions) {
137
+ if (this[kExecution]?.isRunning) {
138
+ this.logger.error('recover during running execution will be deprecated next major version');
139
+ this.logger.debug(`<${this.name}> stopping current running execution`);
140
+ this[kExecution].stop();
141
+ }
142
+
137
143
  if (!savedState) return this;
138
144
 
139
145
  let name = this.name;
@@ -141,7 +147,10 @@ Engine.prototype.recover = function recover(savedState, recoverOptions) {
141
147
 
142
148
  this.logger.debug(`<${name}> recover`);
143
149
 
144
- if (recoverOptions) this[kEnvironment] = new Elements.Environment(recoverOptions);
150
+ if (recoverOptions) {
151
+ this[kEnvironment] = this[kEnvironment].clone(recoverOptions);
152
+ }
153
+
145
154
  if (savedState.environment) this[kEnvironment] = this[kEnvironment].recover(savedState.environment);
146
155
 
147
156
  if (!savedState.definitions) return this;
@@ -431,7 +440,10 @@ Execution.prototype._setup = function setup(setupOptions) {
431
440
  for (const definition of this.definitions) {
432
441
  if (listener) definition.environment.options.listener = listener;
433
442
 
434
- const { queueName } = definition.broker.subscribeTmp('event', 'definition.#', onChildMessage, { noAck: true, consumerTag: '_engine_definition' });
443
+ const { queueName } = definition.broker.subscribeTmp('event', 'definition.#', onChildMessage, {
444
+ noAck: true,
445
+ consumerTag: '_engine_definition',
446
+ });
435
447
  definition.broker.bindQueue(queueName, 'event', 'process.#');
436
448
  definition.broker.bindQueue(queueName, 'event', 'activity.#');
437
449
  definition.broker.bindQueue(queueName, 'event', 'flow.#');
@@ -3,11 +3,7 @@
3
3
 
4
4
  import { EventEmitter } from 'node:events';
5
5
  import { Definitions as BpmnModdleDefinitions } from 'bpmn-moddle';
6
- import {
7
- extendFn,
8
- SerializableContext,
9
- TypeResolver,
10
- } from 'moddle-context-serializer';
6
+ import { extendFn, SerializableContext, TypeResolver } from 'moddle-context-serializer';
11
7
  import {
12
8
  ActivityStatus,
13
9
  ElementBroker,
@@ -61,10 +57,7 @@ declare module 'bpmn-engine' {
61
57
  flow.discard: The sequence flow was discarded
62
58
  flow.looped: The sequence is looped
63
59
  */
64
- export type BpmnSequenceFlowEvent =
65
- | 'flow.take'
66
- | 'flow.discard'
67
- | 'flow.looped';
60
+ export type BpmnSequenceFlowEvent = 'flow.take' | 'flow.discard' | 'flow.looped';
68
61
 
69
62
  export interface BpmnMessage {
70
63
  id?: string;
@@ -173,10 +166,7 @@ declare module 'bpmn-engine' {
173
166
  */
174
167
  execute(): Promise<Execution>;
175
168
  execute(options: BpmnEngineExecuteOptions): Promise<Execution>;
176
- execute(
177
- options: BpmnEngineExecuteOptions,
178
- cb: (err: Error, execution?: Execution) => void
179
- ): Promise<Execution>;
169
+ execute(options: BpmnEngineExecuteOptions, cb: (err: Error, execution?: Execution) => void): Promise<Execution>;
180
170
  execute(cb: (err: Error) => void): Promise<Execution>;
181
171
 
182
172
  /**
@@ -207,10 +197,7 @@ declare module 'bpmn-engine' {
207
197
  * @param options
208
198
  * @param callback
209
199
  */
210
- resume(
211
- options?: BpmnEngineExecuteOptions,
212
- callback?: (err: Error, execution?: Execution) => void
213
- ): Promise<Execution>;
200
+ resume(options?: BpmnEngineExecuteOptions, callback?: (err: Error, execution?: Execution) => void): Promise<Execution>;
214
201
 
215
202
  /**
216
203
  * Stop execution. The instance is terminated.
@@ -320,10 +307,7 @@ declare module 'bpmn-engine' {
320
307
  * @param message {BpmnMessage}
321
308
  * @param options
322
309
  */
323
- signal(
324
- message?: BpmnMessage,
325
- options?: { ignoreSameDefinition?: boolean }
326
- ): void;
310
+ signal(message?: BpmnMessage, options?: { ignoreSameDefinition?: boolean }): void;
327
311
 
328
312
  /**
329
313
  * send cancel activity to execution, distributed to all definitions
@@ -345,9 +329,6 @@ declare module 'bpmn-engine' {
345
329
  */
346
330
  constructor(disableDummy?: boolean);
347
331
  register(activity: any): Script | undefined;
348
- getScript(
349
- language: string,
350
- identifier: { id: string; [x: string]: any }
351
- ): Script;
332
+ getScript(language: string, identifier: { id: string; [x: string]: any }): Script;
352
333
  }
353
334
  }