bpmn-engine 17.0.0 → 17.1.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/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ # 17.1.1
5
+
6
+ - Finetuning Engine.execute and Engine.resume callback arg typization by @bestmazzo
7
+ - Patch [`bpmn-elements`](https://github.com/paed01/bpmn-elements/blob/master/CHANGELOG.md)
8
+
9
+ # 17.1.0
10
+
11
+ - Clear arbitrary engine timers on end and error, not just on stop as it was before
12
+ - Bump [`smqp@8`](https://github.com/paed01/smqp/blob/default/CHANGELOG.md)
13
+
4
14
  # 17.0.0
5
15
 
6
16
  - Even slimmer state from [`bpmn-elements@11`](https://github.com/paed01/bpmn-elements/blob/master/CHANGELOG.md). In most cases it should be safe to update, unless you inspect element states for some reason
package/index.js CHANGED
@@ -432,10 +432,10 @@ Execution.prototype._setup = function setup(setupOptions = {}) {
432
432
  for (const definition of this.definitions) {
433
433
  if (listener) definition.environment.options.listener = listener;
434
434
 
435
- definition.broker.subscribeTmp('event', 'definition.#', onChildMessage, {noAck: true, consumerTag: '_engine_definition'});
436
- definition.broker.subscribeTmp('event', 'process.#', onChildMessage, {noAck: true, consumerTag: '_engine_process'});
437
- definition.broker.subscribeTmp('event', 'activity.#', onChildMessage, {noAck: true, consumerTag: '_engine_activity'});
438
- definition.broker.subscribeTmp('event', 'flow.#', onChildMessage, {noAck: true, consumerTag: '_engine_flow'});
435
+ const {queueName} = definition.broker.subscribeTmp('event', 'definition.#', onChildMessage, {noAck: true, consumerTag: '_engine_definition'});
436
+ definition.broker.bindQueue(queueName, 'event', 'process.#');
437
+ definition.broker.bindQueue(queueName, 'event', 'activity.#');
438
+ definition.broker.bindQueue(queueName, 'event', 'flow.#');
439
439
  }
440
440
  };
441
441
 
@@ -513,27 +513,29 @@ Execution.prototype._onChildMessage = function onChildMessage(routingKey, messag
513
513
  switch (newState) {
514
514
  case 'stopped':
515
515
  this._debug('stopped');
516
- broker.publish('event', 'engine.stop', {}, {type: 'stop'});
517
- return this[kEngine].emit('stop', this);
516
+ return this._complete('stop', {}, {type: 'stop'});
518
517
  case 'idle':
519
518
  this._debug('completed');
520
- broker.publish('event', 'engine.end', {}, {type: 'end'});
521
- return this[kEngine].emit('end', this);
519
+ return this._complete('end', {}, {type: 'end'});
522
520
  case 'error':
523
521
  this._debug('error');
524
- return broker.publish('event', 'engine.error', message.content.error, {type: 'error', mandatory: true});
522
+ return this._complete('error', message.content.error, {type: 'error', mandatory: true});
525
523
  }
526
524
  };
527
525
 
526
+ Execution.prototype._complete = function complete(eventType, content, messageProperties) {
527
+ const timers = this.environment.timers;
528
+ timers.executing.slice().forEach((ref) => timers.clearTimeout(ref));
529
+ this.broker.publish('event', 'engine.' + eventType, content, messageProperties);
530
+ return eventType !== 'error' && this[kEngine].emit(eventType, this);
531
+ };
532
+
528
533
  Execution.prototype._teardownDefinition = function teardownDefinition(definition) {
529
534
  const executing = this[kExecuting];
530
535
  const idx = executing.indexOf(definition);
531
536
  if (idx > -1) executing.splice(idx, 1);
532
537
 
533
538
  definition.broker.cancel('_engine_definition');
534
- definition.broker.cancel('_engine_process');
535
- definition.broker.cancel('_engine_activity');
536
- definition.broker.cancel('_engine_flow');
537
539
  };
538
540
 
539
541
  Execution.prototype.getState = function getState() {
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": "17.0.0",
4
+ "version": "17.1.1",
5
5
  "main": "index.js",
6
6
  "types": "types/bpmn-engine.d.ts",
7
7
  "repository": {
@@ -51,18 +51,18 @@
51
51
  "camunda-bpmn-moddle": "^7.0.1",
52
52
  "chai": "^4.3.7",
53
53
  "chronokinesis": "^5.0.2",
54
- "eslint": "^8.43.0",
54
+ "eslint": "^8.45.0",
55
55
  "markdown-toc": "^1.2.0",
56
56
  "mocha": "^10.2.0",
57
57
  "mocha-cakes-2": "^3.3.0",
58
- "nock": "^13.3.1"
58
+ "nock": "^13.3.2"
59
59
  },
60
60
  "dependencies": {
61
61
  "@types/bpmn-moddle": "^5.1.6",
62
- "bpmn-elements": "^11.0.1",
62
+ "bpmn-elements": "^11.1.1",
63
63
  "bpmn-moddle": "^8.0.1",
64
64
  "debug": "^4.3.4",
65
65
  "moddle-context-serializer": "^4.0.0",
66
- "smqp": "^7.1.3"
66
+ "smqp": "^8.0.0"
67
67
  }
68
68
  }
@@ -128,7 +128,7 @@ declare module 'bpmn-engine' {
128
128
  /**
129
129
  * current engine execution
130
130
  */
131
- readonly execution: Execution;
131
+ readonly execution: Execution;
132
132
  /**
133
133
  * engine environment
134
134
  */
@@ -147,7 +147,7 @@ declare module 'bpmn-engine' {
147
147
  */
148
148
  execute(): Promise<Execution>;
149
149
  execute(options: BpmnEngineExecuteOptions): Promise<Execution>;
150
- execute(options: BpmnEngineExecuteOptions, cb: (err: Error) => void): Promise<Execution>;
150
+ execute(options: BpmnEngineExecuteOptions, cb: (err: Error, execution?: Execution) => void): Promise<Execution>;
151
151
  execute(cb: (err: Error) => void): Promise<Execution>;
152
152
 
153
153
  /**
@@ -178,7 +178,7 @@ declare module 'bpmn-engine' {
178
178
  * @param options
179
179
  * @param callback
180
180
  */
181
- resume(options?: BpmnEngineExecuteOptions, callback?: () => void): Promise<Execution>;
181
+ resume(options?: BpmnEngineExecuteOptions, callback?: (err: Error, execution?: Execution) => void): Promise<Execution>;
182
182
 
183
183
  /**
184
184
  * Stop execution. The instance is terminated.
@@ -191,7 +191,7 @@ declare module 'bpmn-engine' {
191
191
  * Add definition source by source context.
192
192
  * @param options
193
193
  */
194
- addSource(options?: {sourceContext: any}): void;
194
+ addSource(options?: { sourceContext: any }): void;
195
195
  }
196
196
 
197
197
  interface BpmnEngineDefinitionState extends DefinitionState {
@@ -284,7 +284,7 @@ declare module 'bpmn-engine' {
284
284
  * @param message {BpmnMessage}
285
285
  * @param options
286
286
  */
287
- signal(message?: BpmnMessage, options?: {ignoreSameDefinition?: boolean}): void;
287
+ signal(message?: BpmnMessage, options?: { ignoreSameDefinition?: boolean }): void;
288
288
 
289
289
  /**
290
290
  * send cancel activity to execution, distributed to all definitions