bpmn-engine 15.1.2 → 16.0.0

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
+ # 16.0.0
5
+
6
+ - Refactor type declarations using types from bpmn-elements, smqp, etc
7
+ - add activity status property
8
+ - Bump [`bpmn-elements@9.1.0`](https://github.com/paed01/bpmn-elements/blob/master/CHANGELOG.md)
9
+
10
+ # 15.1.3
11
+
12
+ - fix(types): add missing `settings` option
13
+
4
14
  # 15.1.2
5
15
 
6
16
  - Patch [`bpmn-elements@8.2.2`](https://github.com/paed01/bpmn-elements/blob/master/CHANGELOG.md)
package/index.js CHANGED
@@ -107,6 +107,15 @@ Object.defineProperty(Engine.prototype, 'execution', {
107
107
  },
108
108
  });
109
109
 
110
+ Object.defineProperty(Engine.prototype, 'activityStatus', {
111
+ enumerable: true,
112
+ get() {
113
+ const execution = this.execution;
114
+ if (execution) return execution.activityStatus;
115
+ return 'idle';
116
+ },
117
+ });
118
+
110
119
  Engine.prototype.execute = async function execute(...args) {
111
120
  const [executeOptions, callback] = getOptionsAndCallback(...args);
112
121
  try {
@@ -306,6 +315,30 @@ Object.defineProperty(Execution.prototype, 'environment', {
306
315
  },
307
316
  });
308
317
 
318
+ Object.defineProperty(Execution.prototype, 'activityStatus', {
319
+ get() {
320
+ let status = 'idle';
321
+ const running = this[kExecuting];
322
+ if (!running.length) return status;
323
+
324
+ for (const def of running) {
325
+ const bpStatus = def.activityStatus;
326
+ switch (def.activityStatus) {
327
+ case 'executing':
328
+ return bpStatus;
329
+ case 'timer':
330
+ status = bpStatus;
331
+ break;
332
+ case 'wait':
333
+ if (status === 'idle') status = bpStatus;
334
+ break;
335
+ }
336
+ }
337
+
338
+ return status;
339
+ },
340
+ });
341
+
309
342
  Execution.prototype._execute = function execute(executeOptions, callback) {
310
343
  this._setup(executeOptions);
311
344
  this[kStopped] = false;
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": "15.1.2",
4
+ "version": "16.0.0",
5
5
  "main": "index.js",
6
6
  "types": "types/bpmn-engine.d.ts",
7
7
  "repository": {
@@ -22,10 +22,11 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "test": "mocha -R dot",
25
- "posttest": "eslint . --cache && npm run toc",
25
+ "posttest": "npm run lint && npm run toc",
26
+ "lint": "eslint . --cache",
26
27
  "wintest": "mocha",
27
- "cov:html": "nyc mocha -R dot && nyc report --reporter=html",
28
- "test:lcov": "nyc mocha -R dot && nyc report --reporter lcov && npm run posttest",
28
+ "cov:html": "c8 -r html -r text mocha -R dot",
29
+ "test:lcov": "c8 -r lcov mocha && npm run lint",
29
30
  "toc": "node scripts/generate-api-toc ./docs/API.md,./docs/Examples.md",
30
31
  "test-md": "node scripts/test-markdown.js ./docs/API.md && node scripts/test-markdown.js ./docs/Examples.md"
31
32
  },
@@ -44,29 +45,24 @@
44
45
  "url": "https://github.com/paed01/bpmn-engine/master/LICENSE"
45
46
  }
46
47
  ],
47
- "nyc": {
48
- "exclude": [
49
- "test"
50
- ]
51
- },
52
48
  "devDependencies": {
53
49
  "bent": "^7.3.12",
54
- "camunda-bpmn-moddle": "^6.1.2",
50
+ "c8": "^7.13.0",
51
+ "camunda-bpmn-moddle": "^7.0.1",
55
52
  "chai": "^4.3.7",
56
- "chronokinesis": "^3.0.0",
57
- "eslint": "^8.27.0",
53
+ "chronokinesis": "^4.0.1",
54
+ "eslint": "^8.37.0",
58
55
  "markdown-toc": "^1.2.0",
59
- "mocha": "^10.1.0",
56
+ "mocha": "^10.2.0",
60
57
  "mocha-cakes-2": "^3.3.0",
61
- "nock": "^13.2.9",
62
- "nyc": "^15.1.0"
58
+ "nock": "^13.3.0"
63
59
  },
64
60
  "dependencies": {
65
61
  "@types/bpmn-moddle": "^5.1.6",
66
- "bpmn-elements": "^8.2.2",
67
- "bpmn-moddle": "^7.1.3",
62
+ "bpmn-elements": "^9.1.0",
63
+ "bpmn-moddle": "^8.0.1",
68
64
  "debug": "^4.3.4",
69
- "moddle-context-serializer": "^2.0.0",
70
- "smqp": "^6.1.0"
65
+ "moddle-context-serializer": "^3.2.2",
66
+ "smqp": "^7.1.3"
71
67
  }
72
68
  }
@@ -1,7 +1,10 @@
1
1
  // Author : Saeed Tabrizi
2
+ // Refactored by : Pål Edman
2
3
 
3
- import {EventEmitter} from 'events';
4
- import {Definitions} from 'bpmn-moddle';
4
+ import { EventEmitter } from 'events';
5
+ import { Definitions as BpmnModdleDefinitions } from 'bpmn-moddle';
6
+ import { extendFn, SerializableContext } from 'moddle-context-serializer';
7
+ import { ActivityStatus, ElementBroker, EnvironmentOptions, Definition, DefinitionState, Environment, Api, ElementBase, ILogger, EnvironmentState } from 'bpmn-elements';
5
8
 
6
9
  declare module 'bpmn-engine' {
7
10
 
@@ -43,13 +46,8 @@ declare module 'bpmn-engine' {
43
46
  flow.looped: The sequence is looped
44
47
  */
45
48
  export type BpmnSequenceFlowEvent = 'flow.take' | 'flow.discard' | 'flow.looped';
46
- export type BpmnEngineVariable = Record<string, any>;
47
-
48
- export interface BpmnLogger {
49
- debug(...args: any[]): void;
50
- error(...args: any[]): void;
51
- warn(...args: any[]): void;
52
- }
49
+ // export type BpmnEngineVariable = Record<string, any>;
50
+ // export type BpmnEngineSetting = Record<string, any>;
53
51
 
54
52
  export interface BpmnMessage {
55
53
  id?: string,
@@ -57,152 +55,11 @@ declare module 'bpmn-engine' {
57
55
  [name: string]: any
58
56
  }
59
57
 
60
- export interface BpmnEngineBrokerExchange {
61
- name: string;
62
- type: 'topic' | 'direct';
63
- options: any;
64
- bindingCount: number;
65
- bindings: any[];
66
- stopped: boolean;
67
- bind(queue: string, pattern: string, bindOptions?: any): void;
68
- close(): void;
69
- emit(eventName: string, content?: any): void;
70
- getBinding(queueName: string, pattern: string): any;
71
- getState<S>(): S;
72
- on(pattern: string, handler: () => void, consumeOptions?: any): void;
73
- off(pattern: string, handler: () => void): void;
74
- publish(routingKey: string, content?: any, properties?: any): void;
75
- recover<S>(state: S, getQueue?: boolean): void;
76
- stop(): void;
77
- unbind(queue: string, pattern: string): void;
78
- unbindQueueByName(queueName: string): void;
79
- }
80
-
81
- export interface BpmnEngineBrokerQueue {
82
- name: string;
83
- options: any;
84
- messages: any[];
85
- messageCount: number;
86
- consumerCount: number;
87
- stopped: boolean;
88
- exclusive: boolean;
89
- maxLength: number;
90
- readonly capacity: number;
91
- messageTtl: number;
92
- ack(message: any): void;
93
- ackAll(): void;
94
- assertConsumer(onMessage: () => void, consumeOptions?: any, owner?: any): void;
95
- cancel(consumerTag: string): void;
96
- close(): void;
97
- consume(onMessage: () => void, consumeOptions?: any, owner?: any): void;
98
- delete(deleteOptions?: any): void;
99
- dequeueMessage(message: any): void;
100
- dismiss(onMessage: () => void): void;
101
- get<T>(consumeOptions?: any): T;
102
- getState<S>(): S;
103
- nack(message: any, allUpTo?: boolean, requeue?: boolean): void;
104
- nackAll(requeue: boolean): void;
105
- off(eventName: string, handler: () => void): void;
106
-
107
- on(eventName: string, handler: () => void): void;
108
-
109
- peek(ignoreDelivered?: boolean): void;
110
- purge(): void;
111
-
112
- queueMessage(fields: any[], content?: any, properties?: any, onMessageQueued?: () => void): void;
113
- recover<S>(state: S): void;
114
- reject(message: any, requeue?: boolean): void;
115
- stop(): void;
116
- unbindConsumer(): void;
117
- }
118
-
119
- export interface BpmnEngineBrokerConsumer {
120
- consumerTag: string;
121
- noAck: any;
122
- onMessage: () => void;
123
- options: any;
124
- priority: number;
125
- queueName: string;
126
- ackAll(): void;
127
- nackAll(requeue: boolean): void;
128
- cancel(): void;
129
- }
130
-
131
- export interface BpmnEngineBrokerMessage {
132
- fields: {routingKey: string, redelivered: boolean, exchange: any, consumerTag: string}[];
133
- content: any;
134
- properties: {messageId: string, persistent: boolean, timestamp: Date, expiration: number};
135
- ack(allUpTo?: boolean): void;
136
- nack(allUpTo?: boolean, requeue?: boolean): void;
137
- reject(requeue?: boolean): void;
138
- getRoutingKeyPattern(pattern: string): (test: string) => boolean;
139
- }
140
-
141
- export interface BpmnEngineBroker<W> {
142
- new(owner: W): BpmnEngineBroker<W>;
143
- readonly owner: W;
144
- assertExchange(exchangeName: string, type: string, options?: any): void;
145
- deleteExchange(exchangeName: string, ifUnused?: boolean): void;
146
- bindExchange(source: string, destination: string, pattern: string, ...args: any[]): void;
147
-
148
- unbindExchange(source: string, destination: string, pattern?: string): void;
149
- assertQueue(queueName: string, options?: any): void;
150
- bindQueue(queueName: string, exchangeName: string, pattern: string, options?: any): void;
151
- unbindQueue(queueName: string, exchangeName: string, pattern: string): void;
152
-
153
- consume(queueName: string, onMessage: () => void, options?: any): void;
154
- cancel(consumerTag: string): void;
155
- createQueue<Q>(): Q;
156
- deleteQueue(queueName: string, options?: {ifUnused: boolean, ifEmpty?: boolean}): void;
157
-
158
- getExchange<T>(exchangeName: string): T;
159
- getQueue<Q>(queueName: string): Q;
160
- getConsumers<C>(): C[];
161
- getConsumer<C>(consumerTag: string): C;
162
- getState<S>(): S;
163
- recover<S>(state?: S): void;
164
- purgeQueue(queueName: string): void;
165
- sendToQueue(queueName: string, content: any, options?: any): void;
166
- stop(): void;
167
- get(queueName: string, options?: any): void;
168
-
169
- ack(message: any, allUpTo?: boolean): void;
170
- ackAll(): void;
171
- nack(message: any, allUpTo?: boolean, requeue?: boolean): void;
172
- nackAll(requeue?: boolean): void;
173
- reject(message: any, requeue?: boolean): void;
174
-
175
- createShovel<S>(name: string, source: string, destination: string, options?: any): S;
176
- getShovel<S>(name: string): S;
177
- closeShovel(name: string): void;
178
- prefetch(count: number): void;
179
-
180
- reset(): void;
181
- on(eventName: string, handler: () => void): void;
182
- off(eventName: string, handler: () => void): void;
183
- unsubscribe(queueName: string, onMessage: () => void): void;
184
- cancel(eventName: string): void;
185
- subscribe(exchangeName: string, pattern: string, queueName: string, onMessage: () => void, options?: any): void;
186
- subscribeTmp(exchangeName: string, pattern: string, queueName: string, onMessage: () => void, options?: any): void;
187
- subscribeOnce(exchangeName: string, pattern: string, queueName: string, onMessage: () => void, options?: any): void;
188
- publish(exchangeName: string, routingKey: string, content?: any, options?: any): void;
189
- close(): void;
190
-
191
- }
192
-
193
- export interface BpmnEngineExecuteOptions {
194
- variables?: BpmnEngineVariable;
58
+ export interface BpmnEngineExecuteOptions extends EnvironmentOptions {
195
59
  listener?: EventEmitter;
196
- services?: BpmnEngineService;
197
-
198
- /**
199
- * optional override expressions handler
200
- */
201
- expressions?: BpmnEngineExpressions;
202
60
  }
203
61
 
204
- export interface BpmnEngineOptions {
205
-
62
+ export interface BpmnEngineOptions extends BpmnEngineExecuteOptions {
206
63
  /**
207
64
  * optional name of engine,
208
65
  */
@@ -212,55 +69,46 @@ declare module 'bpmn-engine' {
212
69
  */
213
70
  source?: string;
214
71
  /**
215
- * optional serialized context supplied by moddle-context-serializer
72
+ * optional serialized context supplied by moddle-context-serializer
216
73
  */
217
- sourceContext?: any;
218
- variables?: BpmnEngineVariable;
74
+ sourceContext?: SerializableContext;
219
75
  /**
220
- * optional Logger factory, defaults to debug logger
76
+ * optional override of BPMN Elements behaviors, defaults to bpmn-elements
221
77
  */
222
- Logger?: (scope: string) => BpmnLogger;
223
-
78
+ elements?: Record<string, any>;
224
79
  /**
225
- * optional inline script handler, defaults to nodejs vm module handling, i.e. JavaScript
80
+ * Passed to moddle-context-serializer as extendFn
226
81
  */
227
- scripts?: any;
228
-
229
- listener?: EventEmitter;
230
- // tslint:disable-next-line:ban-types
231
- services?: BpmnEngineService;
232
-
233
- elements?: any;
234
-
235
- typeResolver?: <R>(...elements: any) => R;
82
+ typeResolver?: extendFn;
236
83
  /**
237
84
  * optional bpmn-moddle options to be passed to bpmn-moddle
238
85
  */
239
86
  moddleOptions?: any;
240
- moddleContext?: Definitions;
87
+ moddleContext?: BpmnModdleDefinitions;
88
+ }
241
89
 
242
- extensions?: BpmnEngineExtension;
90
+ const enum BpmnEngineRunningStatus {
243
91
  /**
244
- * optional override expressions handler
92
+ * Engine is not executing
245
93
  */
246
- expressions?: BpmnEngineExpressions;
247
- }
248
-
249
- export interface BpmnEngineExtension {
250
- [name: string]: (activiy?: BpmnEngineActivity, environment?: BpmnEngineExecutionEnvironment) => void;
251
- }
252
-
253
- export interface BpmnEngineExpressions {
254
- resolveExpression<R>(
255
- expression: string,
256
- message?: any,
257
- expressionFnContext?: any,
258
- ): R;
94
+ Idle = 'idle',
95
+ /**
96
+ * Engine is executing
97
+ */
98
+ Running = 'running',
99
+ /**
100
+ * Engine execution is stopped
101
+ */
102
+ Stopped = 'stopped',
103
+ /**
104
+ * Engine execution has errored
105
+ */
106
+ Error = 'error',
259
107
  }
260
108
 
261
- export interface BpmnEngine {
262
- new(options?: BpmnEngineOptions): BpmnEngine;
263
-
109
+ export function Engine(options?: BpmnEngineOptions): Engine;
110
+ export class Engine extends EventEmitter {
111
+ constructor(options?: BpmnEngineOptions);
264
112
  /**
265
113
  * engine name
266
114
  */
@@ -268,11 +116,11 @@ declare module 'bpmn-engine' {
268
116
  /**
269
117
  * engine broker
270
118
  */
271
- broker: BpmnEngineBroker<BpmnEngine>;
119
+ broker: ElementBroker<Engine>;
272
120
  /**
273
121
  * engine state
274
122
  */
275
- readonly state: any;
123
+ readonly state: BpmnEngineRunningStatus;
276
124
  /**
277
125
  * boolean stopped
278
126
  */
@@ -280,15 +128,16 @@ declare module 'bpmn-engine' {
280
128
  /**
281
129
  * current engine execution
282
130
  */
283
- readonly execution: BpmnEngineExecutionApi;
131
+ readonly execution: Execution;
284
132
  /**
285
133
  * engine environment
286
134
  */
287
- readonly environment: BpmnEngineExecutionEnvironment;
135
+ readonly environment: Environment;
288
136
  /**
289
137
  * engine logger
290
138
  */
291
- readonly logger: BpmnLogger;
139
+ readonly logger: ILogger;
140
+ get activityStatus(): ActivityStatus;
292
141
 
293
142
  /**
294
143
  * execute definition
@@ -296,18 +145,21 @@ declare module 'bpmn-engine' {
296
145
  * @param cb Callback called before the throw
297
146
  * @summary Execute options overrides the initial options passed to the engine before executing the definition.
298
147
  */
299
- execute(options?:BpmnEngineExecuteOptions, cb?: (err) => void): Promise<BpmnEngineExecutionApi>;
148
+ execute(): Promise<Execution>;
149
+ execute(options: BpmnEngineExecuteOptions): Promise<Execution>;
150
+ execute(options: BpmnEngineExecuteOptions, cb: (err: Error) => void): Promise<Execution>;
151
+ execute(cb: (err: Error) => void): Promise<Execution>;
300
152
 
301
153
  /**
302
154
  * get definition by id
303
155
  * @param id id of definition
304
156
  */
305
- getDefinitionById(id: string): Promise<any>;
157
+ getDefinitionById(id: string): Promise<Definition>;
306
158
 
307
159
  /**
308
160
  * get all definitions
309
161
  */
310
- getDefinitions(): Promise<any[]>;
162
+ getDefinitions(): Promise<Definition[]>;
311
163
 
312
164
  /**
313
165
  * get execution serialized state
@@ -319,348 +171,46 @@ declare module 'bpmn-engine' {
319
171
  * @param state engine state
320
172
  * @param recoverOptions optional object with options that will completely override the options passed to the engine at init
321
173
  */
322
- recover(state: any, recoverOptions?: BpmnEngineOptions): BpmnEngine;
174
+ recover(state: any, recoverOptions?: BpmnEngineOptions): Engine;
323
175
 
324
176
  /**
325
177
  * Resume execution function with previously saved engine state.
326
178
  * @param options
327
179
  * @param callback
328
180
  */
329
- resume(options?: BpmnEngineExecuteOptions, callback?: () => void): Promise<BpmnEngineExecutionApi>;
181
+ resume(options?: BpmnEngineExecuteOptions, callback?: () => void): Promise<Execution>;
330
182
 
331
183
  /**
332
184
  * Stop execution. The instance is terminated.
333
185
  */
334
186
  stop(): void;
335
187
 
336
- waitFor<R>(eventName: string): Promise<R>;
188
+ waitFor<R>(eventName: BpmnEngineEvent): Promise<R>;
337
189
 
338
190
  /**
339
191
  * Add definition source by source context.
340
192
  * @param options
341
193
  */
342
194
  addSource(options?: {sourceContext: any}): void;
343
-
344
- }
345
-
346
- export function Engine(options?: BpmnEngineOptions): BpmnEngine;
347
-
348
- export interface BpmnEngineExecution {
349
- definitions: BpmnEngineExecutionDefinition[];
350
- state: 'idle' | 'running';
351
- environment: BpmnEngineExecutionEnvironment;
352
-
353
- stopped: boolean;
354
- execute(executeOptions?: any): BpmnEngineExecutionApi;
355
- getState<R>(): R;
356
-
357
- resume(resumeOptions?: any): void;
358
-
359
- stop(): void;
360
-
361
- }
362
-
363
- export interface BpmnEngineExecutionContext {
364
- id: string;
365
- name: string;
366
- type: string;
367
- sid: any;
368
- definitionContext: any;
369
- environment: BpmnEngineExecutionEnvironment;
370
-
371
- clone(
372
- environment?: BpmnEngineExecutionEnvironment
373
- ): BpmnEngineExecutionContext;
374
- getActivities(scopeId?: string): BpmnEngineActivity[];
375
- getActivityById(id: string): BpmnEngineActivity;
376
- getExecutableProcesses(): any[];
377
- getDataObjectById(id: string): any;
378
-
379
- getMessageFlows(): any[];
380
-
381
- getProcessById(id: string): any;
382
-
383
- getProcesses(): any;
384
-
385
- getSequenceFlowById(id: string): any;
386
-
387
- getSequenceFlows(scopeId: string): any[];
388
-
389
- getInboundSequenceFlows(activityId: string): any[];
390
- getOutboundSequenceFlows(activityId: string): any[];
391
-
392
- loadExtensions(activity: BpmnEngineActivity): void;
393
- }
394
-
395
- export interface BpmnProcess {
396
- new(processDefinition: any, context: BpmnEngineExecutionContext): BpmnProcess;
397
-
398
- readonly id: string;
399
- readonly type: string;
400
- readonly name: string;
401
- readonly isExecutable: boolean;
402
- readonly broker: BpmnEngineBroker<BpmnEngine>;
403
-
404
- readonly context: BpmnEngineExecutionContext;
405
- readonly counters: Record<string, number>;
406
- readonly environment: BpmnEngineExecutionEnvironment;
407
- readonly execution: BpmnEngineExecutionApi;
408
- readonly executionId: string;
409
- readonly isRunning: boolean;
410
-
411
- readonly logger: BpmnLogger;
412
- readonly parent: BpmnProcess;
413
- readonly status: any;
414
-
415
- readonly stopped: boolean;
416
-
417
- getApi(message: any): BpmnEngineExecutionApi;
418
- getActivities(): BpmnEngineActivity[];
419
- getActivityById(id: string): BpmnEngineActivity;
420
-
421
- getSequenceFlows(): any[];
422
- getPostponed(): BpmnEngineActivity[];
423
-
424
- getState<S>(): S;
425
-
426
- recover<S>(state: S): void;
427
- resume(): void;
428
- run(): void;
429
- stop(): void;
430
- waitFor<R>(eventName: string): Promise<R>;
431
- }
432
-
433
- export interface BpmnEngineActivity extends EventEmitter {
434
- readonly id: string;
435
- readonly type: string;
436
- readonly name: string;
437
-
438
- readonly attachedTo: any;
439
-
440
- readonly Behaviour: any;
441
-
442
- readonly behaviour: any;
443
-
444
- readonly broker: BpmnEngineBroker<BpmnEngine>;
445
-
446
- readonly counters: Record<string, number>;
447
- readonly environment: BpmnEngineExecutionEnvironment;
448
- readonly execution: BpmnEngineExecutionApi;
449
- readonly executionId: string;
450
- readonly extensions: BpmnEngineExtension;
451
- readonly logger: BpmnLogger;
452
- readonly inbound: any[];
453
- readonly isRunning: boolean;
454
- readonly isStart: boolean;
455
- readonly isSubProcess: boolean;
456
-
457
- readonly outbound: any[];
458
- readonly parent?: BpmnEngineActivity | BpmnProcess;
459
- readonly status: any;
460
- readonly stopped: boolean;
461
-
462
- activate(): void;
463
-
464
- deactivate(): void;
465
-
466
- discard(): void;
467
-
468
- getApi(message?: any): BpmnEngineExecutionApi;
469
-
470
- getActivityById(id: string): BpmnEngineActivity;
471
-
472
- getState<S>(): S;
473
-
474
- message(messageContent: any): void;
475
- signal: (message?: BpmnMessage, options?: any) => void;
476
- next(): void;
477
-
478
- recover<S>(state: S): void;
479
-
480
- resume(): void;
481
-
482
- run(runContent?: any): void;
483
-
484
- stop(): void;
485
-
486
- waitFor<R>(eventName: string): Promise<R>;
487
195
  }
488
196
 
489
- export interface BpmnEngineService {
490
- [name: string]: Function;
491
- }
492
-
493
- export interface BpmnEngineExecutionEnvironment {
494
- readonly options: any;
495
- readonly extensions: BpmnEngineExtension;
496
-
497
- readonly scripts: any;
498
- readonly output: any;
499
- readonly variables: BpmnEngineVariable;
500
-
501
- readonly settings: any;
502
-
503
- readonly Logger: BpmnLogger;
504
- readonly services: BpmnEngineService;
505
-
506
- // tslint:disable: ban-types
507
- addService(name: string, serviceFn: Function): void;
508
- assignVariables(...vars: any): void;
509
- clone(overrideOptions?: any): BpmnEngineExecutionEnvironment;
510
- getScript(scriptType: string, activity: any): any;
511
- getServiceByName(name: string): any;
512
-
513
- getState(): BpmnEngineExecutionState;
514
-
515
- registerScript(activity: any): void;
516
-
517
- resolveExpression<R>(
518
- expression: any,
519
- message?: any,
520
- expressionFnContext?: any,
521
- ): R;
522
-
523
- recover(state: any): void;
524
- }
525
-
526
- export interface BpmnExecutionEventMessageContent {
527
- id: string;
528
- type: string;
529
- executionId: string;
530
- parent?: BpmnExecutionEventMessageContent;
531
- path?: BpmnExecutionEventMessageContent[];
532
- }
533
-
534
- export interface BpmnExecutionEventMessageApi {
535
- readonly id: string;
536
- readonly type: string;
537
- readonly name: string;
538
- readonly executionId: string;
539
- readonly environment: BpmnEngineExecutionEnvironment;
540
- readonly fields: any;
541
-
542
- readonly content: BpmnExecutionEventMessageContent;
543
- readonly messageProperties: any;
544
- readonly owner: BpmnEngine;
545
-
546
- cancel(): void;
547
- discard(): void;
548
- signal(message: string, options: any): void;
549
- stop(): void;
550
-
551
- resolveExpression<R>(expression: any): R;
552
- createMessage(overrideContent?: any): BpmnExecutionEventMessageApi;
553
- }
554
-
555
- export interface BpmnEngineExecutionDefinition extends EventEmitter {
556
- state: 'pending' | 'running' | 'completed';
557
- run: (callback?: any) => void;
558
- resume: (callback?: any) => void;
559
-
560
- recover: (state?: any) => void;
561
-
562
- sendMessage: (message: any) => void;
563
-
564
- executionId: string;
565
- execution: BpmnEngineExecutionApi;
566
- getProcesses: () => any[];
567
-
568
- getExecutableProcesses: () => any[];
569
- getApi: <T>(message: any) => T;
570
- getElementById: (elementId: string) => any;
571
- getActivityById: (childId: string) => any;
572
- environment: BpmnEngineExecutionEnvironment;
573
- status: string;
574
- stopped: boolean;
575
- type: string;
576
- signal: (message: BpmnMessage, options?: any) => void;
577
- cancelActivity: (message?: any) => void;
578
- shake: (activityId?: string) => any;
579
- broker: BpmnEngineBroker<BpmnEngine>;
580
- id: string;
581
- isRunning: boolean;
582
- name: string;
583
- logger: BpmnLogger;
584
- waitFor(name: string, fn: Function): void;
585
- }
586
-
587
- export interface BpmnEngineExecutionDefinitionState {
588
- readonly state: 'pending' | 'running' | 'completed';
589
- readonly processes: {
590
- [processId: string]: {
591
- variables: BpmnEngineVariable;
592
- services: BpmnEngineService;
593
- children: BpmnEngineExecutionState[];
594
- };
595
- };
197
+ interface BpmnEngineDefinitionState extends DefinitionState {
198
+ /**
199
+ * Serialized moddle-context-serializer context
200
+ */
201
+ source?: string;
596
202
  }
597
203
 
598
204
  export interface BpmnEngineExecutionState {
599
- readonly name: string;
600
- readonly state: 'idle' | 'running';
601
- readonly stopped: boolean;
602
- readonly engineVersion: string;
603
- readonly environment: BpmnEngineExecutionEnvironment;
604
- readonly definitions: BpmnEngineExecutionDefinitionState[];
605
-
606
- readonly entered: boolean;
607
- }
608
-
609
- export interface BpmnEngineEventApi {
610
- /**
611
- * engine name
612
- *
613
- * @type {string}
614
- *
615
- */
616
205
  name: string;
617
- /**
618
- * state of execution, i.e running or idle
619
- *
620
- * @type {("running"| "idle")}
621
- *
622
- */
623
- state: 'running' | 'idle';
624
- /**
625
- * is the execution stopped
626
- *
627
- * @type {boolean}
628
- *
629
- */
206
+ engineVersion: string;
207
+ state: BpmnEngineRunningStatus;
630
208
  stopped: boolean;
631
- /**
632
- * engine environment
633
- *
634
- * @type {BpmnEngineExecutionEnvironment}
635
- *
636
- */
637
- environment: BpmnEngineExecutionEnvironment;
638
-
639
- /**
640
- * executing definitions
641
- *
642
- * @type {BpmnEngineExecutionDefinition}
643
- *
644
- */
645
- definitions: BpmnEngineExecutionDefinition;
646
-
647
- /**
648
- * get execution serializable state
649
- *
650
- * @returns {BpmnEngineExecutionState}
651
- *
652
- */
653
- getState(): BpmnEngineExecutionState;
654
-
655
- /**
656
- * get activities in a postponed state
657
- *
658
- *
659
- */
660
- getPostponed(): any[];
209
+ environment: EnvironmentState;
210
+ definitions: BpmnEngineDefinitionState[];
661
211
  }
662
212
 
663
- export interface BpmnEngineExecutionApi {
213
+ export interface Execution {
664
214
  /**
665
215
  * engine name
666
216
  *
@@ -685,24 +235,26 @@ declare module 'bpmn-engine' {
685
235
  /**
686
236
  * engine environment
687
237
  *
688
- * @type {BpmnEngineExecutionEnvironment}
238
+ * @type {Environment}
689
239
  *
690
240
  */
691
- readonly environment: BpmnEngineExecutionEnvironment;
241
+ readonly environment: Environment;
692
242
 
693
243
  /**
694
244
  * executing definitions
695
245
  *
696
- * @type {BpmnEngineExecutionDefinition}
246
+ * @type {Definition}
697
247
  *
698
248
  */
699
- readonly definitions: BpmnEngineExecutionDefinition[];
249
+ readonly definitions: Definition[];
250
+ get activityStatus(): ActivityStatus;
700
251
 
701
252
  /**
702
253
  * Get activity/element by id. Loops the definitions and returns the first found activity with id.
703
254
  * @param activityId Activity or element id
704
255
  */
705
- getActivityById(activityId: string): BpmnEngineActivity;
256
+ getActivityById(activityId: string): ElementBase;
257
+ getActivityById<R>(activityId: string): R;
706
258
 
707
259
  /**
708
260
  * get execution serializable state
@@ -724,7 +276,7 @@ declare module 'bpmn-engine' {
724
276
  *
725
277
  *
726
278
  */
727
- getPostponed(): BpmnEngineActivity[];
279
+ getPostponed(): Api<ElementBase>[];
728
280
 
729
281
  /**
730
282
  * send signal to execution, distributed to all definitions
@@ -746,7 +298,5 @@ declare module 'bpmn-engine' {
746
298
  * @param event
747
299
  */
748
300
  waitFor<T>(event: BpmnEngineEvent): Promise<T>;
749
-
750
301
  }
751
-
752
302
  }