bpmn-elements 8.2.3 → 9.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{src/Api.js → Api.js} +11 -12
  3. package/dist/{src/Context.js → Context.js} +26 -27
  4. package/dist/{src/Environment.js → Environment.js} +15 -16
  5. package/dist/{src/EventBroker.js → EventBroker.js} +8 -2
  6. package/dist/{src/Expressions.js → Expressions.js} +1 -1
  7. package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
  8. package/dist/{src/activity → activity}/Activity.js +62 -63
  9. package/dist/{src/activity → activity}/ActivityExecution.js +23 -24
  10. package/dist/{src/activity → activity}/Dummy.js +1 -1
  11. package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
  12. package/dist/{src/definition → definition}/Definition.js +41 -42
  13. package/dist/{src/definition → definition}/DefinitionExecution.js +45 -46
  14. package/dist/{src/error → error}/Errors.js +1 -1
  15. package/dist/{src/eventDefinitions → eventDefinitions}/CancelEventDefinition.js +12 -13
  16. package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +12 -13
  17. package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +13 -14
  18. package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +13 -14
  19. package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
  20. package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
  21. package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
  22. package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
  23. package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
  24. package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
  25. package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
  26. package/dist/{src/events → events}/BoundaryEvent.js +15 -16
  27. package/dist/{src/events → events}/EndEvent.js +3 -3
  28. package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
  29. package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
  30. package/dist/{src/events → events}/StartEvent.js +8 -9
  31. package/dist/{src/flows → flows}/Association.js +15 -16
  32. package/dist/{src/flows → flows}/MessageFlow.js +16 -14
  33. package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
  34. package/dist/{src/gateways → gateways}/EventBasedGateway.js +2 -2
  35. package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
  36. package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
  37. package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
  38. package/dist/index.js +48 -48
  39. package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
  40. package/dist/{src/io → io}/Properties.js +7 -8
  41. package/dist/package.json +3 -0
  42. package/dist/{src/process → process}/Process.js +39 -40
  43. package/dist/{src/process → process}/ProcessExecution.js +55 -48
  44. package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
  45. package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
  46. package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
  47. package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
  48. package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
  49. package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
  50. package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
  51. package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
  52. package/dist/{src/tasks → tasks}/SubProcess.js +17 -18
  53. package/dist/{src/tasks → tasks}/Task.js +2 -2
  54. package/dist/{src/tasks → tasks}/Transaction.js +1 -1
  55. package/package.json +31 -31
  56. package/src/Api.js +11 -13
  57. package/src/Context.js +26 -28
  58. package/src/Environment.js +15 -17
  59. package/src/EventBroker.js +5 -2
  60. package/src/Expressions.js +1 -1
  61. package/src/MessageFormatter.js +3 -3
  62. package/src/activity/Activity.js +62 -64
  63. package/src/activity/ActivityExecution.js +23 -25
  64. package/src/activity/Dummy.js +1 -1
  65. package/src/activity/ExecutionScope.js +2 -2
  66. package/src/definition/Definition.js +41 -43
  67. package/src/definition/DefinitionExecution.js +45 -47
  68. package/src/error/Errors.js +1 -1
  69. package/src/eventDefinitions/CancelEventDefinition.js +12 -14
  70. package/src/eventDefinitions/CompensateEventDefinition.js +12 -14
  71. package/src/eventDefinitions/ConditionalEventDefinition.js +13 -15
  72. package/src/eventDefinitions/ErrorEventDefinition.js +13 -15
  73. package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
  74. package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
  75. package/src/eventDefinitions/LinkEventDefinition.js +14 -16
  76. package/src/eventDefinitions/MessageEventDefinition.js +13 -15
  77. package/src/eventDefinitions/SignalEventDefinition.js +13 -15
  78. package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
  79. package/src/eventDefinitions/TimerEventDefinition.js +15 -17
  80. package/src/events/BoundaryEvent.js +15 -17
  81. package/src/events/EndEvent.js +3 -3
  82. package/src/events/IntermediateCatchEvent.js +3 -3
  83. package/src/events/IntermediateThrowEvent.js +3 -3
  84. package/src/events/StartEvent.js +8 -10
  85. package/src/flows/Association.js +15 -17
  86. package/src/flows/MessageFlow.js +14 -15
  87. package/src/flows/SequenceFlow.js +16 -20
  88. package/src/gateways/EventBasedGateway.js +2 -2
  89. package/src/gateways/ExclusiveGateway.js +2 -2
  90. package/src/gateways/InclusiveGateway.js +2 -2
  91. package/src/gateways/ParallelGateway.js +2 -2
  92. package/src/index.js +106 -0
  93. package/src/io/InputOutputSpecification.js +8 -10
  94. package/src/io/Properties.js +7 -9
  95. package/src/process/Process.js +39 -41
  96. package/src/process/ProcessExecution.js +55 -49
  97. package/src/tasks/CallActivity.js +7 -9
  98. package/src/tasks/LoopCharacteristics.js +2 -2
  99. package/src/tasks/ReceiveTask.js +215 -217
  100. package/src/tasks/ScriptTask.js +4 -4
  101. package/src/tasks/ServiceImplementation.js +1 -1
  102. package/src/tasks/ServiceTask.js +6 -8
  103. package/src/tasks/SignalTask.js +7 -9
  104. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  105. package/src/tasks/SubProcess.js +17 -19
  106. package/src/tasks/Task.js +2 -2
  107. package/src/tasks/Transaction.js +1 -1
  108. package/types/index.d.ts +491 -0
  109. package/index.js +0 -106
  110. /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
  111. /package/dist/{src/Scripts.js → Scripts.js} +0 -0
  112. /package/dist/{src/Timers.js → Timers.js} +0 -0
  113. /package/dist/{src/activity → activity}/Escalation.js +0 -0
  114. /package/dist/{src/activity → activity}/Message.js +0 -0
  115. /package/dist/{src/activity → activity}/Signal.js +0 -0
  116. /package/dist/{src/error → error}/BpmnError.js +0 -0
  117. /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
  118. /package/dist/{src/io → io}/BpmnIO.js +0 -0
  119. /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
  120. /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
  121. /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
  122. /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
  123. /package/dist/{src/shared.js → shared.js} +0 -0
@@ -1,6 +1,6 @@
1
- import Activity from '../activity/Activity';
2
- import ProcessExecution from '../process/ProcessExecution';
3
- import {cloneContent} from '../messageHelper';
1
+ import Activity from '../activity/Activity.js';
2
+ import ProcessExecution from '../process/ProcessExecution.js';
3
+ import {cloneContent} from '../messageHelper.js';
4
4
 
5
5
  const kExecutions = Symbol.for('executions');
6
6
  const kMessageHandlers = Symbol.for('messageHandlers');
@@ -44,21 +44,19 @@ export function SubProcessBehaviour(activity, context) {
44
44
  };
45
45
  }
46
46
 
47
- const proto = SubProcessBehaviour.prototype;
48
-
49
- Object.defineProperty(proto, 'execution', {
47
+ Object.defineProperty(SubProcessBehaviour.prototype, 'execution', {
50
48
  get() {
51
49
  return this[kExecutions][0];
52
50
  },
53
51
  });
54
52
 
55
- Object.defineProperty(proto, 'executions', {
53
+ Object.defineProperty(SubProcessBehaviour.prototype, 'executions', {
56
54
  get() {
57
55
  return this[kExecutions].slice();
58
56
  },
59
57
  });
60
58
 
61
- proto.execute = function execute(executeMessage) {
59
+ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
62
60
  const content = executeMessage.content;
63
61
 
64
62
  let executionId = this.executionId;
@@ -83,7 +81,7 @@ proto.execute = function execute(executeMessage) {
83
81
  return processExecution.execute(executeMessage);
84
82
  };
85
83
 
86
- proto.stop = function stop() {
84
+ SubProcessBehaviour.prototype.stop = function stop() {
87
85
  for (const execution of this[kExecutions]) {
88
86
  this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
89
87
  this.broker.cancel(`_sub-process-api-${execution.executionId}`);
@@ -91,7 +89,7 @@ proto.stop = function stop() {
91
89
  }
92
90
  };
93
91
 
94
- proto.discard = function discard() {
92
+ SubProcessBehaviour.prototype.discard = function discard() {
95
93
  for (const execution of this[kExecutions]) {
96
94
  this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
97
95
  this.broker.cancel(`_sub-process-api-${execution.executionId}`);
@@ -99,7 +97,7 @@ proto.discard = function discard() {
99
97
  }
100
98
  };
101
99
 
102
- proto.getState = function getState() {
100
+ SubProcessBehaviour.prototype.getState = function getState() {
103
101
  if (this.loopCharacteristics) {
104
102
  return {
105
103
  executions: this[kExecutions].map((pe) => {
@@ -118,7 +116,7 @@ proto.getState = function getState() {
118
116
  }
119
117
  };
120
118
 
121
- proto.recover = function recover(state) {
119
+ SubProcessBehaviour.prototype.recover = function recover(state) {
122
120
  if (!state) return;
123
121
 
124
122
  const executions = this[kExecutions];
@@ -145,14 +143,14 @@ proto.recover = function recover(state) {
145
143
  return execution;
146
144
  };
147
145
 
148
- proto.getPostponed = function getPostponed() {
146
+ SubProcessBehaviour.prototype.getPostponed = function getPostponed() {
149
147
  return this[kExecutions].reduce((result, pe) => {
150
148
  result = result.concat(pe.getPostponed());
151
149
  return result;
152
150
  }, []);
153
151
  };
154
152
 
155
- proto._onApiRootMessage = function onApiRootMessage(_, message) {
153
+ SubProcessBehaviour.prototype._onApiRootMessage = function onApiRootMessage(_, message) {
156
154
  const messageType = message.properties.type;
157
155
 
158
156
  switch (messageType) {
@@ -167,7 +165,7 @@ proto._onApiRootMessage = function onApiRootMessage(_, message) {
167
165
  }
168
166
  };
169
167
 
170
- proto._upsertExecution = function upsertExecution(executeMessage) {
168
+ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(executeMessage) {
171
169
  const content = executeMessage.content;
172
170
  const executionId = content.executionId;
173
171
 
@@ -188,14 +186,14 @@ proto._upsertExecution = function upsertExecution(executeMessage) {
188
186
  return execution;
189
187
  };
190
188
 
191
- proto._addListeners = function addListeners(processExecution, executionId) {
189
+ SubProcessBehaviour.prototype._addListeners = function addListeners(processExecution, executionId) {
192
190
  this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[kMessageHandlers].onExecutionCompleted, {
193
191
  noAck: true,
194
192
  consumerTag: `_sub-process-execution-${executionId}`,
195
193
  });
196
194
  };
197
195
 
198
- proto._onExecutionCompleted = function onExecutionCompleted(_, message) {
196
+ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionCompleted(_, message) {
199
197
  if (message.fields.redelivered && message.properties.persistent === false) return;
200
198
 
201
199
  const content = message.content;
@@ -228,7 +226,7 @@ proto._onExecutionCompleted = function onExecutionCompleted(_, message) {
228
226
  }
229
227
  };
230
228
 
231
- proto.getApi = function getApi(apiMessage) {
229
+ SubProcessBehaviour.prototype.getApi = function getApi(apiMessage) {
232
230
  const content = apiMessage.content;
233
231
 
234
232
  if (content.id === this.id) return;
@@ -244,6 +242,6 @@ proto.getApi = function getApi(apiMessage) {
244
242
  }
245
243
  };
246
244
 
247
- proto._getExecutionById = function getExecutionById(executionId) {
245
+ SubProcessBehaviour.prototype._getExecutionById = function getExecutionById(executionId) {
248
246
  return this[kExecutions].find((pe) => pe.executionId === executionId);
249
247
  };
package/src/tasks/Task.js CHANGED
@@ -1,5 +1,5 @@
1
- import Activity from '../activity/Activity';
2
- import {cloneContent} from '../messageHelper';
1
+ import Activity from '../activity/Activity.js';
2
+ import {cloneContent} from '../messageHelper.js';
3
3
 
4
4
  export default function Task(activityDef, context) {
5
5
  return new Activity(TaskBehaviour, activityDef, context);
@@ -1,4 +1,4 @@
1
- import SubProcess from './SubProcess';
1
+ import SubProcess from './SubProcess.js';
2
2
 
3
3
  export default function Transaction(activityDef, context) {
4
4
  const transaction = {type: 'transaction', ...activityDef, isTransaction: true};
@@ -0,0 +1,491 @@
1
+ declare module 'bpmn-elements' {
2
+ import { Broker } from 'smqp';
3
+ import { Consumer } from 'smqp/types/Queue';
4
+ import { MessageMessage } from 'smqp/types/Message';
5
+ import { SerializableContext, SerializableElement } from 'moddle-context-serializer';
6
+
7
+ interface ElementBroker<T> extends Broker {
8
+ get owner(): T;
9
+ }
10
+
11
+ type signalMessage = {
12
+ /**
13
+ * Optional signal id
14
+ * - Activity id
15
+ * - Signal-, Message-, Escalation id, etc
16
+ */
17
+ id?: string,
18
+ /**
19
+ * Optional execution id
20
+ * e.g. excutionId of a parallel multi instance user task
21
+ */
22
+ executionId?: string,
23
+ /** Any other input that will be added to completed activity output */
24
+ [x: string]: any,
25
+ }
26
+
27
+ type elementContent = {
28
+ id?: string,
29
+ type?: string,
30
+ executionId?: string,
31
+ parent?: ElementParent,
32
+ [x: string]: any,
33
+ }
34
+
35
+ interface ElementBrokerMessage extends MessageMessage {
36
+ content: elementContent,
37
+ }
38
+
39
+ interface EventDefinition {
40
+ get id(): string;
41
+ get type(): string;
42
+ get executionId(): string;
43
+ get isThrowing(): boolean;
44
+ get activity(): Activity;
45
+ get broker(): Broker;
46
+ get logger(): Logger;
47
+ get reference(): {
48
+ id?: string,
49
+ name: string,
50
+ referenceType: string,
51
+ };
52
+ [x: string]: any;
53
+ execute(executeMessage: ElementBrokerMessage): void;
54
+ }
55
+
56
+ abstract class ElementBase {
57
+ get id(): string;
58
+ get type(): string;
59
+ get name(): string;
60
+ get parent(): ElementParent;
61
+ get behaviour(): SerializableElement;
62
+ get broker(): Broker;
63
+ get environment(): Environment;
64
+ get context(): Context;
65
+ get logger(): Logger;
66
+ }
67
+
68
+ abstract class Element<T> extends ElementBase {
69
+ get broker(): ElementBroker<T>;
70
+ getState(): any;
71
+ stop(): void;
72
+ recover(state?: any): T;
73
+ resume(): void;
74
+ getApi(message?: ElementBrokerMessage): Api<T>;
75
+ on(eventName: string, callback: CallableFunction, options?: any): Consumer;
76
+ once(eventName: string, callback: CallableFunction, options?: any): Consumer;
77
+ waitFor(eventName: string, options?: any): Promise<Api<T>>;
78
+ }
79
+
80
+ interface ElementParent {
81
+ get id(): string;
82
+ get type(): string;
83
+ get executionId(): string;
84
+ get path(): ElementParent[];
85
+ }
86
+
87
+ type Extension = (activity: ElementBase, context: Context) => IExtension;
88
+ interface IExtension {
89
+ activate(message: ElementBrokerMessage): void;
90
+ deactivate(message: ElementBrokerMessage): void;
91
+ }
92
+
93
+ interface IExpressions {
94
+ resolveExpression(templatedString: string, context?: any, expressionFnContext?: any): any;
95
+ }
96
+
97
+ interface EnvironmentSettings {
98
+ /** true returns dummy service function for service task if not found */
99
+ enableDummyService?: boolean;
100
+ /** true makes activity runs to go forward in steps, defaults to false */
101
+ step?: boolean;
102
+ /** strict mode, see documentation, defaults to false */
103
+ strict?: boolean;
104
+ /** positive integer to control parallel loop batch size, defaults to 50 */
105
+ batchSize?: number;
106
+ [x: string]: any;
107
+ }
108
+
109
+ interface EnvironmentOptions {
110
+ settings?: EnvironmentSettings;
111
+ variables?: Record<string, any>;
112
+ services?: Record<string, CallableFunction>;
113
+ logger?: Logger;
114
+ timers?: ITimers;
115
+ scripts?: IScripts;
116
+ extensions?: Record<string, Extension>;
117
+ expressions?: IExpressions;
118
+ }
119
+
120
+ type startActivityFilterOptions = {
121
+ /** Event definition id, i.e. Message, Signal, Error, etc */
122
+ referenceId?: string,
123
+ /** Event definition type, i.e. message, signal, error, etc */
124
+ referenceType?: string
125
+ };
126
+
127
+ type filterPostponed = (elementApi: Api<ElementBase>) => boolean;
128
+
129
+ interface DefinitionExecution {
130
+ get id(): string;
131
+ get type(): string;
132
+ get broker(): Broker;
133
+ get environment(): Environment;
134
+ get context(): Context;
135
+ get executionId(): string;
136
+ get stopped(): boolean;
137
+ get completed(): boolean;
138
+ get status(): boolean;
139
+ get processes(): Process[];
140
+ get postponedCount(): number;
141
+ get isRunning(): boolean;
142
+ execute(executeMessage: ElementBrokerMessage): void;
143
+ getProcesses(): Process[];
144
+ getProcessById(processId: string): Process;
145
+ getProcessesById(processId: string): Process[];
146
+ getProcessByExecutionId(processExecutionId: string): Process;
147
+ getRunningProcesses(): Process[];
148
+ getExecutableProcesses(): Process[];
149
+ getPostponed(filterFn: filterPostponed): Api<ElementBase>[];
150
+ }
151
+
152
+ interface ActivityExecution {
153
+ get completed(): boolean;
154
+ get executionId(): string;
155
+ get source(): ActivityBehaviour;
156
+ execute(executeMessage: ElementBrokerMessage): void;
157
+ }
158
+
159
+ function ActivityBehaviour(activityDef: SerializableElement, context: Context): Activity;
160
+ interface ActivityBehaviour {
161
+ id: string;
162
+ type: string;
163
+ activity: Activity;
164
+ environment: Environment;
165
+ execute(executeMessage: ElementBrokerMessage): void;
166
+ }
167
+
168
+ interface Api<T> extends ElementBrokerMessage {
169
+ get id(): string;
170
+ get type(): string;
171
+ get name(): string;
172
+ get executionId(): string;
173
+ get environment(): Environment;
174
+ get broker(): ElementBroker<T>;
175
+ get owner(): T;
176
+ cancel(message?: signalMessage, options?: any): void;
177
+ discard(): void;
178
+ fail(error: Error): void;
179
+ signal(message?: signalMessage, options?: any): void;
180
+ stop(): void;
181
+ resolveExpression(expression: string): any;
182
+ sendApiMessage(action: string, content?: signalMessage, options?: any): void;
183
+ getPostponed(...args: any[]): any[];
184
+ createMessage(content?: Record<string, any>): any;
185
+ }
186
+
187
+ interface Script {
188
+ execute(executionContext: any, callback: CallableFunction): void;
189
+ }
190
+
191
+ abstract class MessageElement {
192
+ get id(): string;
193
+ get type(): string;
194
+ get name(): string;
195
+ get parent(): ElementParent;
196
+ resolve(executionMessage: ElementBrokerMessage): {
197
+ parent: ElementParent;
198
+ name: string;
199
+ id: string;
200
+ type: string;
201
+ messageType: string;
202
+ };
203
+ }
204
+
205
+ class Environment {
206
+ constructor(options?: EnvironmentOptions);
207
+ options: Record<string, any>;
208
+ expressions: IExpressions;
209
+ extensions: Record<string, IExtension>;
210
+ scripts: IScripts;
211
+ timers: ITimers;
212
+ Logger: Logger;
213
+ get settings(): EnvironmentSettings;
214
+ get variables(): Record<string, any>;
215
+ get output(): Record<string, any>;
216
+ set services(arg: any);
217
+ get services(): any;
218
+ getState(): any;
219
+ recover(state?: any): Environment;
220
+ clone(overrideOptions?: EnvironmentOptions): Environment;
221
+ assignVariables(newVars: Record<string, any>): void;
222
+ assignSettings(newSettings: Record<string, any>): void;
223
+ registerScript(activity: any): Script;
224
+ getScript(language: string, identifier: {id: string, [x: string]: any}): Script;
225
+ getServiceByName(serviceName: string): CallableFunction;
226
+ resolveExpression(expression: string, message?: ElementBrokerMessage, expressionFnContext?: any): any;
227
+ addService(name: string, fn: CallableFunction): void;
228
+ }
229
+
230
+ function Context(definitionContext: SerializableContext, environment?: Environment): Context;
231
+ class Context {
232
+ constructor(definitionContext: SerializableContext, environment?: Environment);
233
+ get id(): string;
234
+ get name(): string;
235
+ get type(): string;
236
+ /** Unique context instance id */
237
+ get sid(): string;
238
+ get definitionContext(): SerializableContext;
239
+ get environment(): Environment;
240
+ getActivityById<T>(activityId: string): T;
241
+ getSequenceFlowById(sequenceFlowId: string): SequenceFlow;
242
+ getInboundSequenceFlows(activityId: string): SequenceFlow[];
243
+ getOutboundSequenceFlows(activityId: string): SequenceFlow[];
244
+ getInboundAssociations(activityId: string): Association[];
245
+ getOutboundAssociations(activityId: string): Association[];
246
+ getActivities(scopeId?: string): ElementBase[];
247
+ getSequenceFlows(scopeId?: string): SequenceFlow[];
248
+ getAssociations(scopeId?: string): Association[];
249
+ clone(newEnvironment?: Environment): Context;
250
+ getProcessById(processId: string): Process;
251
+ getNewProcessById(processId: string): Process;
252
+ getProcesses(): Process[];
253
+ getExecutableProcesses(): Process[];
254
+ getMessageFlows(sourceId: string): MessageFlow[];
255
+ getDataObjectById(referenceId: string): any;
256
+ getDataStoreById(referenceId: string): any;
257
+ getStartActivities(filterOptions?: startActivityFilterOptions, scopeId?: string): Activity[];
258
+ loadExtensions(activity: ElementBase): IExtension;
259
+ }
260
+
261
+ type runCallback = (err: Error, definitionApi: Api<Definition>) => void;
262
+ class Definition extends Element<Definition> {
263
+ constructor(context: Context, options?: EnvironmentOptions);
264
+ get counters(): { completed: number, discarded: number };
265
+ get execution(): DefinitionExecution;
266
+ get executionId(): string;
267
+ get isRunning(): boolean;
268
+ get status(): string;
269
+ get stopped(): boolean;
270
+ run(): Definition;
271
+ run(runContent: Record<string, any>): Definition;
272
+ run(runContent: Record<string, any>, callback: runCallback): Definition;
273
+ run(callback: runCallback): Definition;
274
+ shake(startId?: string): object;
275
+ getProcesses(): Process[];
276
+ /** get processes marked with isExecutable=true */
277
+ getExecutableProcesses(): Process[];
278
+ getRunningProcesses(): Process[];
279
+ getProcessById(processId: string): Process;
280
+ getActivityById(childId: string): Activity;
281
+ getElementById<T>(elementId: string): Element<T>;
282
+ getPostponed(filterFn?: filterPostponed): Api<ElementBase>[];
283
+ /** Send delegated signal message */
284
+ signal(message: any): void;
285
+ cancelActivity(message: any): void;
286
+ sendMessage(message: any): void;
287
+ }
288
+
289
+ class Process extends Element<Process> {
290
+ constructor(processDef: SerializableElement, context: Context);
291
+ get isExecutable(): boolean;
292
+ get counters(): { completed: number, discarded: number };
293
+ get extensions(): IExtension;
294
+ get stopped(): boolean;
295
+ get isRunning(): boolean;
296
+ get executionId(): string;
297
+ get execution(): ProcessExecution;
298
+ get status(): string;
299
+ init(useAsExecutionId?: string): void;
300
+ run(runContent?: Record<string, any>): void;
301
+ shake(startId?: string): void;
302
+ signal(message: any): any;
303
+ cancelActivity(message: any): any;
304
+ sendMessage(message: any): void;
305
+ getActivityById<T>(childId: string): T;
306
+ getActivities(): Activity[];
307
+ getStartActivities(filterOptions?: startActivityFilterOptions): Activity[];
308
+ getSequenceFlows(): SequenceFlow[];
309
+ getPostponed(filterFn: filterPostponed): Api<ElementBase>[];
310
+ }
311
+
312
+ interface ProcessExecution {
313
+ get isSubProcess(): boolean;
314
+ get broker(): Broker;
315
+ get environment(): Environment;
316
+ get context(): Context;
317
+ get executionId(): string;
318
+ get stopped(): boolean;
319
+ get completed(): boolean;
320
+ get status(): string;
321
+ get postponedCount(): number;
322
+ get isRunning(): boolean;
323
+ execute(executeMessage: ElementBrokerMessage): void;
324
+ getPostponed(filterFn: filterPostponed): Api<ElementBase>[];
325
+ getActivities(): Activity[];
326
+ getActivityById<T>(activityId: string): T;
327
+ getSequenceFlows(): SequenceFlow[];
328
+ getApi(message?: ElementBrokerMessage): Api<ElementBase>;
329
+ }
330
+
331
+ class SequenceFlow extends Element<SequenceFlow> {
332
+ get sourceId(): string;
333
+ get targetId(): string;
334
+ get isDefault(): boolean;
335
+ get isSequenceFlow(): boolean;
336
+ get counters(): {take: number, discard: number, looped: number};
337
+ take(content?: any): boolean;
338
+ discard(content?: any): void;
339
+ shake(message: any): number;
340
+ getCondition(): any;
341
+ createMessage(override?: any): object;
342
+ }
343
+
344
+ interface MessageFlowReference {
345
+ /** activity id */
346
+ get id(): string;
347
+ get processId(): string;
348
+ }
349
+ class MessageFlow extends Element<MessageFlow> {
350
+ get source(): MessageFlowReference;
351
+ get target(): MessageFlowReference;
352
+ get counters(): { messages: number };
353
+ activate(): void;
354
+ deactivate(): void;
355
+ }
356
+
357
+ class Association extends Element<Association> {
358
+ get sourceId(): string;
359
+ get targetId(): string;
360
+ get isAssociation(): boolean;
361
+ get counters(): {take: number, discard: number };
362
+ take(content?: any): boolean;
363
+ discard(content?: any): boolean;
364
+ }
365
+
366
+ interface Logger {
367
+ debug(...args: any[]): void;
368
+ error(...args: any[]): void;
369
+ warn(...args: any[]): void;
370
+ [x: string]: any,
371
+ }
372
+
373
+ type wrappedSetTimeout = (handler: CallableFunction, timeout: number, ...args: unknown[]) => any;
374
+ type wrappedClearTimeout = (id?: any) => void;
375
+
376
+ interface ITimers {
377
+ get executing(): any[];
378
+ get setTimeout(): wrappedSetTimeout;
379
+ get clearTimeout(): wrappedClearTimeout;
380
+ register(owner?: any): { setTimeout: wrappedSetTimeout, clearTimeout: wrappedClearTimeout };
381
+ [x: string]: any,
382
+ }
383
+
384
+ interface IScripts {
385
+ register(activity: any): Script;
386
+ getScript(language: string, identifier: {id: string, [x: string]: any}): Script;
387
+ }
388
+
389
+ interface Activity extends Element<Activity> {
390
+ get Behaviour(): ActivityBehaviour;
391
+ get stopped(): boolean;
392
+ get status(): string;
393
+ get counters(): { taken: number, discarded: number };
394
+ get execution(): ActivityExecution;
395
+ get executionId(): string;
396
+ get extensions(): IExtension;
397
+ get isRunning(): boolean;
398
+ get outbound(): SequenceFlow[];
399
+ get inbound(): SequenceFlow[];
400
+ get isEnd(): boolean;
401
+ get isStart(): boolean;
402
+ get isSubProcess(): boolean;
403
+ get isMultiInstance(): boolean;
404
+ get isThrowing(): boolean;
405
+ get isForCompensation(): boolean;
406
+ get triggeredByEvent(): boolean;
407
+ get attachedTo(): Activity;
408
+ get eventDefinitions(): EventDefinition[];
409
+ activate(): void;
410
+ deactivate(): void;
411
+ init(initContent?: any): void;
412
+ run(runContent?: any): void;
413
+ discard(discardContent?: any): void;
414
+ next(): ElementBrokerMessage;
415
+ shake(): void;
416
+ evaluateOutbound(fromMessage: ElementBrokerMessage, discardRestAtTake: boolean, callback: (err: Error, evaluationResult: any) => void): void;
417
+ }
418
+
419
+ var BoundaryEvent: typeof ActivityBehaviour;
420
+ var CallActivity: typeof ActivityBehaviour;
421
+ var Dummy: typeof ActivityBehaviour;
422
+ var TextAnnotation: typeof Dummy;
423
+ var Group: typeof Dummy;
424
+ var Category: typeof Dummy;
425
+ var EndEvent: typeof ActivityBehaviour;
426
+ var EventBasedGateway: typeof ActivityBehaviour;
427
+ var ExclusiveGateway: typeof ActivityBehaviour;
428
+ var InclusiveGateway: typeof ActivityBehaviour;
429
+ var IntermediateCatchEvent: typeof ActivityBehaviour;
430
+ var IntermediateThrowEvent: typeof ActivityBehaviour;
431
+ var ParallelGateway: typeof ActivityBehaviour;
432
+ var ReceiveTask: typeof ActivityBehaviour;
433
+ var ScriptTask: typeof ActivityBehaviour;
434
+ var ServiceTask: typeof ActivityBehaviour;
435
+ var SendTask: typeof ServiceTask;
436
+ var BusinessRuleTask: typeof ServiceTask;
437
+ var SignalTask: typeof ActivityBehaviour;
438
+ var ManualTask: typeof SignalTask;
439
+ var UserTask: typeof SignalTask;
440
+ var StartEvent: typeof ActivityBehaviour;
441
+ var SubProcess: typeof ActivityBehaviour;
442
+ var Task: typeof ActivityBehaviour;
443
+ var Transaction: typeof ActivityBehaviour;
444
+
445
+ var CancelEventDefinition: EventDefinition;
446
+ var CompensateEventDefinition: EventDefinition;
447
+ var ConditionalEventDefinition: EventDefinition;
448
+ var ErrorEventDefinition: EventDefinition;
449
+ var EscalationEventDefinition: EventDefinition;
450
+ var LinkEventDefinition: EventDefinition;
451
+ var MessageEventDefinition: EventDefinition;
452
+ var SignalEventDefinition: EventDefinition;
453
+ var TerminateEventDefinition: EventDefinition;
454
+ var TimerEventDefinition: EventDefinition;
455
+
456
+ class BpmnError {
457
+ get id(): string;
458
+ get type(): string;
459
+ get name(): string;
460
+ get errorCode(): string;
461
+ resolve(executionMessage: ElementBrokerMessage, error: any): {
462
+ id: string;
463
+ type: string;
464
+ messageType: string;
465
+ name: string;
466
+ code: string;
467
+ inner?: any
468
+ };
469
+ }
470
+
471
+ class ServiceImplementation {
472
+ constructor(activity: Activity);
473
+ get type(): string;
474
+ get implementation(): string;
475
+ get activity(): Activity;
476
+ execute(executionMessage: ElementBrokerMessage, callback: CallableFunction): void;
477
+ }
478
+
479
+ class Message extends MessageElement {}
480
+ class Signal extends MessageElement {}
481
+ class Escalation extends MessageElement {}
482
+
483
+ interface ActivityError extends Error {
484
+ type: string;
485
+ description: string;
486
+ /** Activity that threw error */
487
+ source?: ElementBrokerMessage;
488
+ /** Original error */
489
+ inner?: Error;
490
+ }
491
+ }