bpmn-elements 9.0.0 → 9.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 +11 -0
- package/README.md +1 -1
- package/dist/EventBroker.js +4 -0
- package/dist/Tracker.js +89 -0
- package/dist/activity/Activity.js +47 -57
- package/dist/activity/ActivityExecution.js +6 -9
- package/dist/definition/Definition.js +23 -17
- package/dist/definition/DefinitionExecution.js +23 -0
- package/dist/eventDefinitions/CancelEventDefinition.js +20 -76
- package/dist/eventDefinitions/CompensateEventDefinition.js +54 -41
- package/dist/eventDefinitions/ConditionalEventDefinition.js +11 -2
- package/dist/eventDefinitions/ErrorEventDefinition.js +2 -0
- package/dist/events/BoundaryEvent.js +25 -10
- package/dist/flows/Association.js +0 -7
- package/dist/gateways/EventBasedGateway.js +1 -2
- package/dist/process/Process.js +5 -0
- package/dist/process/ProcessExecution.js +128 -36
- package/dist/tasks/SubProcess.js +2 -1
- package/package.json +5 -5
- package/src/EventBroker.js +1 -0
- package/src/Tracker.js +73 -0
- package/src/activity/Activity.js +45 -51
- package/src/activity/ActivityExecution.js +6 -8
- package/src/definition/Definition.js +24 -21
- package/src/definition/DefinitionExecution.js +26 -0
- package/src/eventDefinitions/CancelEventDefinition.js +22 -66
- package/src/eventDefinitions/CompensateEventDefinition.js +48 -40
- package/src/eventDefinitions/ConditionalEventDefinition.js +12 -2
- package/src/eventDefinitions/ErrorEventDefinition.js +2 -0
- package/src/events/BoundaryEvent.js +20 -8
- package/src/flows/Association.js +0 -10
- package/src/gateways/EventBasedGateway.js +1 -2
- package/src/process/Process.js +6 -0
- package/src/process/ProcessExecution.js +126 -36
- package/src/tasks/SubProcess.js +2 -1
- package/types/index.d.ts +132 -11
package/src/tasks/SubProcess.js
CHANGED
|
@@ -205,9 +205,10 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
|
|
|
205
205
|
broker.cancel(message.fields.consumerTag);
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
|
+
case 'cancel':
|
|
208
209
|
case 'discard': {
|
|
209
210
|
broker.cancel(message.fields.consumerTag);
|
|
210
|
-
broker.publish('execution', 'execute.
|
|
211
|
+
broker.publish('execution', 'execute.' + messageType, cloneContent(content));
|
|
211
212
|
break;
|
|
212
213
|
}
|
|
213
214
|
case 'completed': {
|
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():
|
|
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():
|
|
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
|
-
|
|
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
|
|
|
@@ -126,6 +128,30 @@ declare module 'bpmn-elements' {
|
|
|
126
128
|
|
|
127
129
|
type filterPostponed = (elementApi: Api<ElementBase>) => boolean;
|
|
128
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Activity status
|
|
133
|
+
* Can be used to decide when to save states, Timer and Wait is recommended.
|
|
134
|
+
*/
|
|
135
|
+
const enum ActivityStatus {
|
|
136
|
+
/** Idle, not running anything */
|
|
137
|
+
Idle = 'idle',
|
|
138
|
+
/**
|
|
139
|
+
* At least one activity is executing,
|
|
140
|
+
* e.g. a service task making a asynchronous request
|
|
141
|
+
*/
|
|
142
|
+
Executing = 'executing',
|
|
143
|
+
/**
|
|
144
|
+
* At least one activity is waiting for a timer to complete,
|
|
145
|
+
* usually only TimerEventDefinition's
|
|
146
|
+
*/
|
|
147
|
+
Timer = 'timer',
|
|
148
|
+
/**
|
|
149
|
+
* At least one activity is waiting for a signal of some sort,
|
|
150
|
+
* e.g. user tasks, intermediate catch events, etc
|
|
151
|
+
*/
|
|
152
|
+
Wait = 'wait',
|
|
153
|
+
}
|
|
154
|
+
|
|
129
155
|
interface DefinitionExecution {
|
|
130
156
|
get id(): string;
|
|
131
157
|
get type(): string;
|
|
@@ -139,6 +165,7 @@ declare module 'bpmn-elements' {
|
|
|
139
165
|
get processes(): Process[];
|
|
140
166
|
get postponedCount(): number;
|
|
141
167
|
get isRunning(): boolean;
|
|
168
|
+
get activityStatus(): ActivityStatus;
|
|
142
169
|
execute(executeMessage: ElementBrokerMessage): void;
|
|
143
170
|
getProcesses(): Process[];
|
|
144
171
|
getProcessById(processId: string): Process;
|
|
@@ -209,14 +236,14 @@ declare module 'bpmn-elements' {
|
|
|
209
236
|
extensions: Record<string, IExtension>;
|
|
210
237
|
scripts: IScripts;
|
|
211
238
|
timers: ITimers;
|
|
212
|
-
Logger:
|
|
239
|
+
Logger: LoggerFactory;
|
|
213
240
|
get settings(): EnvironmentSettings;
|
|
214
241
|
get variables(): Record<string, any>;
|
|
215
242
|
get output(): Record<string, any>;
|
|
216
243
|
set services(arg: any);
|
|
217
244
|
get services(): any;
|
|
218
|
-
getState():
|
|
219
|
-
recover(state?:
|
|
245
|
+
getState(): EnvironmentState;
|
|
246
|
+
recover(state?: EnvironmentState): Environment;
|
|
220
247
|
clone(overrideOptions?: EnvironmentOptions): Environment;
|
|
221
248
|
assignVariables(newVars: Record<string, any>): void;
|
|
222
249
|
assignSettings(newSettings: Record<string, any>): void;
|
|
@@ -258,19 +285,107 @@ declare module 'bpmn-elements' {
|
|
|
258
285
|
loadExtensions(activity: ElementBase): IExtension;
|
|
259
286
|
}
|
|
260
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
|
+
|
|
261
371
|
type runCallback = (err: Error, definitionApi: Api<Definition>) => void;
|
|
262
372
|
class Definition extends Element<Definition> {
|
|
263
373
|
constructor(context: Context, options?: EnvironmentOptions);
|
|
264
|
-
get counters():
|
|
374
|
+
get counters(): completedCounters;
|
|
265
375
|
get execution(): DefinitionExecution;
|
|
266
376
|
get executionId(): string;
|
|
267
377
|
get isRunning(): boolean;
|
|
268
378
|
get status(): string;
|
|
269
379
|
get stopped(): boolean;
|
|
380
|
+
get activityStatus(): ActivityStatus;
|
|
270
381
|
run(): Definition;
|
|
271
382
|
run(runContent: Record<string, any>): Definition;
|
|
272
383
|
run(runContent: Record<string, any>, callback: runCallback): Definition;
|
|
273
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;
|
|
274
389
|
shake(startId?: string): object;
|
|
275
390
|
getProcesses(): Process[];
|
|
276
391
|
/** get processes marked with isExecutable=true */
|
|
@@ -289,15 +404,18 @@ declare module 'bpmn-elements' {
|
|
|
289
404
|
class Process extends Element<Process> {
|
|
290
405
|
constructor(processDef: SerializableElement, context: Context);
|
|
291
406
|
get isExecutable(): boolean;
|
|
292
|
-
get counters():
|
|
407
|
+
get counters(): completedCounters;
|
|
293
408
|
get extensions(): IExtension;
|
|
294
409
|
get stopped(): boolean;
|
|
295
410
|
get isRunning(): boolean;
|
|
296
411
|
get executionId(): string;
|
|
297
412
|
get execution(): ProcessExecution;
|
|
298
413
|
get status(): string;
|
|
414
|
+
get activityStatus(): ActivityStatus;
|
|
299
415
|
init(useAsExecutionId?: string): void;
|
|
300
416
|
run(runContent?: Record<string, any>): void;
|
|
417
|
+
getState(): ProcessState;
|
|
418
|
+
recover(state?: ProcessState): Process;
|
|
301
419
|
shake(startId?: string): void;
|
|
302
420
|
signal(message: any): any;
|
|
303
421
|
cancelActivity(message: any): any;
|
|
@@ -320,6 +438,7 @@ declare module 'bpmn-elements' {
|
|
|
320
438
|
get status(): string;
|
|
321
439
|
get postponedCount(): number;
|
|
322
440
|
get isRunning(): boolean;
|
|
441
|
+
get activityStatus(): ActivityStatus;
|
|
323
442
|
execute(executeMessage: ElementBrokerMessage): void;
|
|
324
443
|
getPostponed(filterFn: filterPostponed): Api<ElementBase>[];
|
|
325
444
|
getActivities(): Activity[];
|
|
@@ -363,7 +482,9 @@ declare module 'bpmn-elements' {
|
|
|
363
482
|
discard(content?: any): boolean;
|
|
364
483
|
}
|
|
365
484
|
|
|
366
|
-
|
|
485
|
+
type LoggerFactory = (scope: string) => ILogger;
|
|
486
|
+
|
|
487
|
+
interface ILogger {
|
|
367
488
|
debug(...args: any[]): void;
|
|
368
489
|
error(...args: any[]): void;
|
|
369
490
|
warn(...args: any[]): void;
|