bpmn-elements 9.1.0 → 9.1.2

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,15 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ # 9.1.2
5
+
6
+ - allow type IScripts.register to return undefined
7
+
8
+ # 9.1.1
9
+
10
+ - fix type Logger declaration
11
+ - type declare element `getState` return states
12
+
4
13
  # 9.1.0
5
14
 
6
15
  - refactor compensation and transaction functionality
package/dist/Tracker.js CHANGED
@@ -22,6 +22,7 @@ Object.defineProperty(ActivityTracker.prototype, 'activityStatus', {
22
22
  });
23
23
  ActivityTracker.prototype.track = function track(routingKey, message) {
24
24
  const content = message.content;
25
+ if (content.isAssociation) return;
25
26
  if (content.isSequenceFlow) return;
26
27
  if (content.isSubProcess) return;
27
28
  const executionId = content.executionId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "9.1.0",
3
+ "version": "9.1.2",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -53,9 +53,9 @@
53
53
  "c8": "^7.13.0",
54
54
  "camunda-bpmn-moddle": "^7.0.1",
55
55
  "chai": "^4.3.7",
56
- "chronokinesis": "^4.0.1",
56
+ "chronokinesis": "^5.0.2",
57
57
  "debug": "^4.3.4",
58
- "eslint": "^8.37.0",
58
+ "eslint": "^8.38.0",
59
59
  "eslint-plugin-import": "^2.27.5",
60
60
  "got": "^12.6.0",
61
61
  "mocha": "^10.1.0",
@@ -65,6 +65,6 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "iso8601-duration": "^2.1.1",
68
- "smqp": "^7.1.3"
68
+ "smqp": "^7.1.4"
69
69
  }
70
70
  }
package/src/Tracker.js CHANGED
@@ -14,6 +14,7 @@ Object.defineProperty(ActivityTracker.prototype, 'activityStatus', {
14
14
 
15
15
  ActivityTracker.prototype.track = function track(routingKey, message) {
16
16
  const content = message.content;
17
+ if (content.isAssociation) return;
17
18
  if (content.isSequenceFlow) return;
18
19
  if (content.isSubProcess) return;
19
20
  const executionId = content.executionId;
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare module 'bpmn-elements' {
2
2
  import { Broker } from 'smqp';
3
+ import { BrokerState } from 'smqp/types/Broker';
3
4
  import { Consumer } from 'smqp/types/Queue';
4
5
  import { MessageMessage } from 'smqp/types/Message';
5
6
  import { SerializableContext, SerializableElement } from 'moddle-context-serializer';
@@ -43,7 +44,7 @@ declare module 'bpmn-elements' {
43
44
  get isThrowing(): boolean;
44
45
  get activity(): Activity;
45
46
  get broker(): Broker;
46
- get logger(): Logger;
47
+ get logger(): ILogger;
47
48
  get reference(): {
48
49
  id?: string,
49
50
  name: string,
@@ -62,14 +63,12 @@ declare module 'bpmn-elements' {
62
63
  get broker(): Broker;
63
64
  get environment(): Environment;
64
65
  get context(): Context;
65
- get logger(): Logger;
66
+ get logger(): ILogger;
66
67
  }
67
68
 
68
69
  abstract class Element<T> extends ElementBase {
69
70
  get broker(): ElementBroker<T>;
70
- getState(): any;
71
71
  stop(): void;
72
- recover(state?: any): T;
73
72
  resume(): void;
74
73
  getApi(message?: ElementBrokerMessage): Api<T>;
75
74
  on(eventName: string, callback: CallableFunction, options?: any): Consumer;
@@ -110,10 +109,13 @@ declare module 'bpmn-elements' {
110
109
  settings?: EnvironmentSettings;
111
110
  variables?: Record<string, any>;
112
111
  services?: Record<string, CallableFunction>;
113
- logger?: Logger;
112
+ Logger?: LoggerFactory;
114
113
  timers?: ITimers;
115
114
  scripts?: IScripts;
116
115
  extensions?: Record<string, Extension>;
116
+ /**
117
+ * optional override expressions handler
118
+ */
117
119
  expressions?: IExpressions;
118
120
  }
119
121
 
@@ -163,7 +165,6 @@ declare module 'bpmn-elements' {
163
165
  get processes(): Process[];
164
166
  get postponedCount(): number;
165
167
  get isRunning(): boolean;
166
- get isRunning(): boolean;
167
168
  get activityStatus(): ActivityStatus;
168
169
  execute(executeMessage: ElementBrokerMessage): void;
169
170
  getProcesses(): Process[];
@@ -235,14 +236,14 @@ declare module 'bpmn-elements' {
235
236
  extensions: Record<string, IExtension>;
236
237
  scripts: IScripts;
237
238
  timers: ITimers;
238
- Logger: Logger;
239
+ Logger: LoggerFactory;
239
240
  get settings(): EnvironmentSettings;
240
241
  get variables(): Record<string, any>;
241
242
  get output(): Record<string, any>;
242
243
  set services(arg: any);
243
244
  get services(): any;
244
- getState(): any;
245
- recover(state?: any): Environment;
245
+ getState(): EnvironmentState;
246
+ recover(state?: EnvironmentState): Environment;
246
247
  clone(overrideOptions?: EnvironmentOptions): Environment;
247
248
  assignVariables(newVars: Record<string, any>): void;
248
249
  assignSettings(newSettings: Record<string, any>): void;
@@ -284,10 +285,93 @@ declare module 'bpmn-elements' {
284
285
  loadExtensions(activity: ElementBase): IExtension;
285
286
  }
286
287
 
288
+ interface ElementState {
289
+ id: string;
290
+ type: string;
291
+ name: string;
292
+ broker?: BrokerState;
293
+ [x: string]: any;
294
+ }
295
+
296
+ interface EnvironmentState {
297
+ settings: EnvironmentSettings;
298
+ variables: Record<string, any>;
299
+ output: Record<string, any>;
300
+ }
301
+
302
+ type completedCounters = { completed: number, discarded: number };
303
+
304
+ interface ActivityExecutionState {
305
+ completed: boolean;
306
+ [x: string]: any;
307
+ }
308
+
309
+ interface ActivityState extends ElementState {
310
+ executionId: string;
311
+ stopped: boolean;
312
+ behaviour: Record<string, any>;
313
+ counters: { taken: number, discarded: number };
314
+ execution?: ActivityExecutionState;
315
+ }
316
+
317
+ interface SequenceFlowState extends ElementState {
318
+ counters: {take: number, discard: number, looped: number};
319
+ }
320
+
321
+ interface MessageFlowState {
322
+ id: string;
323
+ type: string;
324
+ counters: {messages: number};
325
+ }
326
+
327
+ interface AssociationState extends ElementState {
328
+ counters: {take: number, discard: number };
329
+ sourceId: string;
330
+ targetId: string;
331
+ isAssociation: boolean;
332
+ }
333
+
334
+ interface ProcessExecutionState {
335
+ executionId: string;
336
+ stopped: boolean;
337
+ completed: boolean;
338
+ status: string;
339
+ children: ActivityState[];
340
+ flows?: SequenceFlowState[];
341
+ messageFlows?: MessageFlowState[];
342
+ associations?: AssociationState[];
343
+ }
344
+
345
+ interface ProcessState extends ElementState {
346
+ status: string;
347
+ stopped: boolean,
348
+ executionId?: string;
349
+ counters: completedCounters;
350
+ environment: EnvironmentState;
351
+ execution?: ProcessExecutionState;
352
+ }
353
+
354
+ interface DefinitionExecutionState {
355
+ executionId: string;
356
+ stopped: boolean;
357
+ completed: boolean;
358
+ status: string;
359
+ processes: ProcessState[];
360
+ }
361
+
362
+ interface DefinitionState extends ElementState {
363
+ status: string;
364
+ stopped: boolean,
365
+ executionId?: string;
366
+ counters: completedCounters;
367
+ environment: EnvironmentState;
368
+ execution?: DefinitionExecutionState;
369
+ }
370
+
287
371
  type runCallback = (err: Error, definitionApi: Api<Definition>) => void;
288
372
  class Definition extends Element<Definition> {
289
373
  constructor(context: Context, options?: EnvironmentOptions);
290
- get counters(): { completed: number, discarded: number };
374
+ get counters(): completedCounters;
291
375
  get execution(): DefinitionExecution;
292
376
  get executionId(): string;
293
377
  get isRunning(): boolean;
@@ -298,6 +382,10 @@ declare module 'bpmn-elements' {
298
382
  run(runContent: Record<string, any>): Definition;
299
383
  run(runContent: Record<string, any>, callback: runCallback): Definition;
300
384
  run(callback: runCallback): Definition;
385
+ getState(): DefinitionState;
386
+ recover(state?: DefinitionState): Definition;
387
+ resume(): void;
388
+ resume(callback: (err: Error, definitionApi: Api<Definition>) => void): void;
301
389
  shake(startId?: string): object;
302
390
  getProcesses(): Process[];
303
391
  /** get processes marked with isExecutable=true */
@@ -316,7 +404,7 @@ declare module 'bpmn-elements' {
316
404
  class Process extends Element<Process> {
317
405
  constructor(processDef: SerializableElement, context: Context);
318
406
  get isExecutable(): boolean;
319
- get counters(): { completed: number, discarded: number };
407
+ get counters(): completedCounters;
320
408
  get extensions(): IExtension;
321
409
  get stopped(): boolean;
322
410
  get isRunning(): boolean;
@@ -326,6 +414,8 @@ declare module 'bpmn-elements' {
326
414
  get activityStatus(): ActivityStatus;
327
415
  init(useAsExecutionId?: string): void;
328
416
  run(runContent?: Record<string, any>): void;
417
+ getState(): ProcessState;
418
+ recover(state?: ProcessState): Process;
329
419
  shake(startId?: string): void;
330
420
  signal(message: any): any;
331
421
  cancelActivity(message: any): any;
@@ -392,7 +482,9 @@ declare module 'bpmn-elements' {
392
482
  discard(content?: any): boolean;
393
483
  }
394
484
 
395
- interface Logger {
485
+ type LoggerFactory = (scope: string) => ILogger;
486
+
487
+ interface ILogger {
396
488
  debug(...args: any[]): void;
397
489
  error(...args: any[]): void;
398
490
  warn(...args: any[]): void;
@@ -411,7 +503,7 @@ declare module 'bpmn-elements' {
411
503
  }
412
504
 
413
505
  interface IScripts {
414
- register(activity: any): Script;
506
+ register(activity: any): Script | undefined;
415
507
  getScript(language: string, identifier: {id: string, [x: string]: any}): Script;
416
508
  }
417
509