bpmn-elements 17.3.0 → 18.0.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.
Files changed (155) hide show
  1. package/README.md +3 -1
  2. package/dist/Api.js +83 -0
  3. package/dist/Context.js +228 -22
  4. package/dist/Environment.js +111 -31
  5. package/dist/EventBroker.js +57 -1
  6. package/dist/Expressions.js +3 -4
  7. package/dist/MessageFormatter.js +29 -16
  8. package/dist/Timers.js +13 -9
  9. package/dist/Tracker.js +1 -0
  10. package/dist/activity/Activity.js +434 -233
  11. package/dist/activity/ActivityExecution.js +113 -40
  12. package/dist/activity/Dummy.js +6 -1
  13. package/dist/activity/Escalation.js +36 -24
  14. package/dist/activity/ExecutionScope.js +1 -1
  15. package/dist/activity/Message.js +36 -24
  16. package/dist/activity/Signal.js +36 -24
  17. package/dist/activity/outbound-evaluator.js +1 -1
  18. package/dist/condition.js +12 -6
  19. package/dist/constants.js +27 -0
  20. package/dist/definition/Definition.js +187 -64
  21. package/dist/definition/DefinitionExecution.js +198 -84
  22. package/dist/error/BpmnError.js +12 -1
  23. package/dist/error/Errors.js +50 -9
  24. package/dist/eventDefinitions/CancelEventDefinition.js +29 -11
  25. package/dist/eventDefinitions/CompensateEventDefinition.js +51 -31
  26. package/dist/eventDefinitions/ConditionalEventDefinition.js +21 -9
  27. package/dist/eventDefinitions/ErrorEventDefinition.js +46 -30
  28. package/dist/eventDefinitions/EscalationEventDefinition.js +44 -27
  29. package/dist/eventDefinitions/EventDefinitionExecution.js +30 -23
  30. package/dist/eventDefinitions/LinkEventDefinition.js +45 -120
  31. package/dist/eventDefinitions/MessageEventDefinition.js +44 -29
  32. package/dist/eventDefinitions/SignalEventDefinition.js +46 -31
  33. package/dist/eventDefinitions/TerminateEventDefinition.js +10 -1
  34. package/dist/eventDefinitions/TimerEventDefinition.js +57 -37
  35. package/dist/eventDefinitions/index.js +20 -21
  36. package/dist/events/BoundaryEvent.js +52 -40
  37. package/dist/events/EndEvent.js +22 -8
  38. package/dist/events/IntermediateCatchEvent.js +26 -8
  39. package/dist/events/IntermediateThrowEvent.js +24 -9
  40. package/dist/events/StartEvent.js +30 -14
  41. package/dist/events/index.js +10 -11
  42. package/dist/flows/Association.js +50 -7
  43. package/dist/flows/MessageFlow.js +49 -10
  44. package/dist/flows/SequenceFlow.js +93 -22
  45. package/dist/flows/index.js +6 -7
  46. package/dist/gateways/EventBasedGateway.js +29 -15
  47. package/dist/gateways/ExclusiveGateway.js +20 -5
  48. package/dist/gateways/InclusiveGateway.js +21 -5
  49. package/dist/gateways/ParallelGateway.js +253 -15
  50. package/dist/gateways/index.js +8 -9
  51. package/dist/getPropertyValue.js +1 -1
  52. package/dist/index.js +42 -43
  53. package/dist/io/BpmnIO.js +15 -1
  54. package/dist/io/EnvironmentDataObject.js +29 -1
  55. package/dist/io/EnvironmentDataStore.js +24 -1
  56. package/dist/io/EnvironmentDataStoreReference.js +24 -1
  57. package/dist/io/InputOutputSpecification.js +21 -11
  58. package/dist/io/Properties.js +28 -17
  59. package/dist/messageHelper.js +41 -4
  60. package/dist/process/Lane.js +15 -4
  61. package/dist/process/Process.js +176 -77
  62. package/dist/process/ProcessExecution.js +397 -178
  63. package/dist/shared.js +2 -0
  64. package/dist/tasks/CallActivity.js +19 -4
  65. package/dist/tasks/LoopCharacteristics.js +94 -9
  66. package/dist/tasks/ReceiveTask.js +36 -21
  67. package/dist/tasks/ScriptTask.js +22 -6
  68. package/dist/tasks/ServiceImplementation.js +7 -4
  69. package/dist/tasks/ServiceTask.js +19 -4
  70. package/dist/tasks/SignalTask.js +19 -4
  71. package/dist/tasks/StandardLoopCharacteristics.js +8 -4
  72. package/dist/tasks/SubProcess.js +44 -29
  73. package/dist/tasks/Task.js +19 -4
  74. package/dist/tasks/Transaction.js +8 -4
  75. package/dist/tasks/index.js +16 -18
  76. package/package.json +31 -13
  77. package/src/Api.js +70 -0
  78. package/src/Context.js +200 -19
  79. package/src/Environment.js +99 -30
  80. package/src/EventBroker.js +46 -1
  81. package/src/Expressions.js +2 -3
  82. package/src/MessageFormatter.js +24 -16
  83. package/src/Timers.js +12 -9
  84. package/src/Tracker.js +1 -0
  85. package/src/activity/Activity.js +372 -218
  86. package/src/activity/ActivityExecution.js +93 -42
  87. package/src/activity/Dummy.js +6 -1
  88. package/src/activity/Escalation.js +25 -18
  89. package/src/activity/ExecutionScope.js +1 -1
  90. package/src/activity/Message.js +25 -18
  91. package/src/activity/Signal.js +25 -18
  92. package/src/activity/outbound-evaluator.js +1 -1
  93. package/src/condition.js +11 -5
  94. package/src/constants.js +21 -0
  95. package/src/definition/Definition.js +165 -63
  96. package/src/definition/DefinitionExecution.js +164 -85
  97. package/src/error/BpmnError.js +11 -1
  98. package/src/error/Errors.js +44 -5
  99. package/src/eventDefinitions/CancelEventDefinition.js +27 -13
  100. package/src/eventDefinitions/CompensateEventDefinition.js +48 -32
  101. package/src/eventDefinitions/ConditionalEventDefinition.js +20 -10
  102. package/src/eventDefinitions/ErrorEventDefinition.js +44 -33
  103. package/src/eventDefinitions/EscalationEventDefinition.js +39 -26
  104. package/src/eventDefinitions/EventDefinitionExecution.js +30 -24
  105. package/src/eventDefinitions/LinkEventDefinition.js +34 -120
  106. package/src/eventDefinitions/MessageEventDefinition.js +42 -31
  107. package/src/eventDefinitions/SignalEventDefinition.js +43 -32
  108. package/src/eventDefinitions/TerminateEventDefinition.js +9 -1
  109. package/src/eventDefinitions/TimerEventDefinition.js +53 -35
  110. package/src/eventDefinitions/index.js +10 -23
  111. package/src/events/BoundaryEvent.js +50 -39
  112. package/src/events/EndEvent.js +19 -7
  113. package/src/events/IntermediateCatchEvent.js +24 -8
  114. package/src/events/IntermediateThrowEvent.js +24 -8
  115. package/src/events/StartEvent.js +25 -14
  116. package/src/events/index.js +5 -18
  117. package/src/flows/Association.js +43 -9
  118. package/src/flows/MessageFlow.js +41 -10
  119. package/src/flows/SequenceFlow.js +82 -19
  120. package/src/flows/index.js +3 -4
  121. package/src/gateways/EventBasedGateway.js +27 -15
  122. package/src/gateways/ExclusiveGateway.js +16 -3
  123. package/src/gateways/InclusiveGateway.js +16 -3
  124. package/src/gateways/ParallelGateway.js +301 -10
  125. package/src/gateways/index.js +4 -4
  126. package/src/getPropertyValue.js +1 -1
  127. package/src/index.js +19 -19
  128. package/src/io/BpmnIO.js +13 -1
  129. package/src/io/EnvironmentDataObject.js +26 -1
  130. package/src/io/EnvironmentDataStore.js +22 -1
  131. package/src/io/EnvironmentDataStoreReference.js +22 -1
  132. package/src/io/InputOutputSpecification.js +17 -8
  133. package/src/io/Properties.js +23 -13
  134. package/src/messageHelper.js +36 -4
  135. package/src/process/Lane.js +14 -4
  136. package/src/process/Process.js +157 -74
  137. package/src/process/ProcessExecution.js +363 -176
  138. package/src/shared.js +1 -0
  139. package/src/tasks/CallActivity.js +16 -2
  140. package/src/tasks/LoopCharacteristics.js +77 -11
  141. package/src/tasks/ReceiveTask.js +33 -22
  142. package/src/tasks/ScriptTask.js +17 -3
  143. package/src/tasks/ServiceImplementation.js +6 -3
  144. package/src/tasks/ServiceTask.js +16 -2
  145. package/src/tasks/SignalTask.js +16 -2
  146. package/src/tasks/StandardLoopCharacteristics.js +7 -3
  147. package/src/tasks/SubProcess.js +37 -23
  148. package/src/tasks/Task.js +16 -2
  149. package/src/tasks/Transaction.js +7 -3
  150. package/src/tasks/index.js +8 -9
  151. package/types/bundle-errors.d.ts +1 -0
  152. package/types/bundle.d.ts +97 -0
  153. package/types/index.d.ts +2619 -84
  154. package/types/interfaces.d.ts +638 -0
  155. package/types/types.d.ts +0 -765
package/types/index.d.ts CHANGED
@@ -1,101 +1,2636 @@
1
- export * from './types.js';
2
- import {
3
- Association,
4
- MessageFlow,
5
- SequenceFlow,
6
- IActivityBehaviour,
7
- ActivityBehaviour,
8
- EventDefinition,
9
- MessageElement,
10
- ConditionalEventDefinition,
11
- TimerEventDefinition,
12
- } from './types.js';
13
-
14
1
  declare module 'bpmn-elements' {
15
- export var BoundaryEvent: typeof ActivityBehaviour;
16
- export var CallActivity: typeof ActivityBehaviour;
17
- export var Dummy: typeof ActivityBehaviour;
18
- export var TextAnnotation: typeof Dummy;
19
- export var Group: typeof Dummy;
20
- export var Category: typeof Dummy;
21
- export var EndEvent: typeof ActivityBehaviour;
22
- export var EventBasedGateway: typeof ActivityBehaviour;
23
- export var ExclusiveGateway: typeof ActivityBehaviour;
24
- export var InclusiveGateway: typeof ActivityBehaviour;
25
- export var IntermediateCatchEvent: typeof ActivityBehaviour;
26
- export var IntermediateThrowEvent: typeof ActivityBehaviour;
27
- export var ParallelGateway: typeof ActivityBehaviour;
28
- export var ReceiveTask: typeof ActivityBehaviour;
29
- export var ScriptTask: typeof ActivityBehaviour;
30
- export var ServiceTask: typeof ActivityBehaviour;
31
- export var SendTask: typeof ServiceTask;
32
- export var BusinessRuleTask: typeof ServiceTask;
33
- export var SignalTask: typeof ActivityBehaviour;
34
- export var ManualTask: typeof SignalTask;
35
- export var UserTask: typeof SignalTask;
36
- export var StartEvent: typeof ActivityBehaviour;
37
- export var SubProcess: typeof ActivityBehaviour;
38
- export var Task: typeof ActivityBehaviour;
39
- export var Transaction: typeof ActivityBehaviour;
40
-
41
- export var CancelEventDefinition: EventDefinition;
42
- export var CompensateEventDefinition: EventDefinition;
43
- export var ConditionalEventDefinition: EventDefinition;
44
- export var ErrorEventDefinition: EventDefinition;
45
- export var EscalationEventDefinition: EventDefinition;
46
- export var LinkEventDefinition: EventDefinition;
47
- export var MessageEventDefinition: EventDefinition;
48
- export var SignalEventDefinition: EventDefinition;
49
- export var TerminateEventDefinition: EventDefinition;
50
- export var TimerEventDefinition: TimerEventDefinition;
51
-
52
- export class Message extends MessageElement {}
53
- export class Signal extends MessageElement {}
54
- export class Escalation extends MessageElement {}
2
+ import type { Broker, BrokerState, Consumer, MessageEnvelope, MessageFields, MessageProperties } from 'smqp';
3
+ import type { SerializableContext, SerializableElement } from 'moddle-context-serializer';
4
+ // --- Broker / message contracts -----------------------------------------------
5
+
6
+ export interface ElementBroker<T> extends Broker {
7
+ get owner(): T;
8
+ }
9
+
10
+ /**
11
+ * Wrapper returned by `ActivityBroker`, `ProcessBroker`, `DefinitionBroker`,
12
+ * `MessageFlowBroker`, and `new EventBroker(owner, options)`. Owns an underlying
13
+ * smqp Broker and exposes bound, prefixed event helpers.
14
+ *
15
+ * @template T Broker owner element type (Activity, Process, Definition, ...).
16
+ */
17
+ export interface EventBroker<T> {
18
+ options: { prefix: string; autoDelete?: boolean; durable?: boolean };
19
+ eventPrefix: string;
20
+ broker: ElementBroker<T>;
21
+ on(eventName: string, callback: CallableFunction, eventOptions?: { once?: boolean; [x: string]: any }): Consumer;
22
+ once(eventName: string, callback: CallableFunction, eventOptions?: { [x: string]: any }): Consumer;
23
+ waitFor(eventName: string, onMessage?: (routingKey: string, message: ElementBrokerMessage, owner: T) => boolean): Promise<IApi<T>>;
24
+ emit(eventName: string, content?: Record<string, any>, props?: any): void;
25
+ emitFatal(error: Error, content?: Record<string, any>): void;
26
+ }
27
+
28
+ export type signalMessage = {
29
+ /**
30
+ * Optional signal id
31
+ * - Activity id
32
+ * - Signal-, Message-, Escalation id, etc
33
+ */
34
+ id?: string;
35
+ /**
36
+ * Optional execution id
37
+ * e.g. excutionId of a parallel multi instance user task
38
+ */
39
+ executionId?: string;
40
+ /** Any other input that will be added to completed activity output */
41
+ [x: string]: any;
42
+ };
43
+
44
+ export interface ElementMessageContent {
45
+ /** Element id */
46
+ id?: string;
47
+ /** Element type */
48
+ type?: string;
49
+ /** Element execution id */
50
+ executionId?: string;
51
+ parent?: ElementParent;
52
+ [x: string]: any;
53
+ }
54
+
55
+ export interface ElementBrokerMessage extends MessageEnvelope {
56
+ content: ElementMessageContent;
57
+ }
58
+
59
+ export interface ElementParent {
60
+ id: string;
61
+ type: string;
62
+ executionId: string;
63
+ path?: Omit<ElementParent, 'path'>[];
64
+ }
65
+
66
+ // --- Shake results ------------------------------------------------------------
67
+
68
+ /** A single hop (activity or sequence flow) recorded during a shake walk. */
69
+ export interface ShakeSequenceItem {
70
+ id: string;
71
+ type: string;
72
+ count?: number;
73
+ sourceId?: string;
74
+ targetId?: string;
75
+ }
76
+
77
+ /** A single end-to-end sequence discovered while shaking an activity graph. */
78
+ export interface ShakenSequence extends ElementMessageContent {
79
+ /** The activity- and flow-id steps that were walked, in order. */
80
+ sequence: ShakeSequenceItem[];
81
+ /** true when the walk revisited an already-seen activity. */
82
+ isLooped: boolean;
83
+ }
84
+
85
+ /** Result of shaking an activity graph, keyed by the starting activity id. */
86
+ export type ShakeResult = Record<string, ShakenSequence[]>;
87
+
88
+ // --- Element abstract bases ---------------------------------------------------
89
+
90
+ export class ElementBase {
91
+ get id(): string;
92
+ get type(): string;
93
+ get name(): string;
94
+ get parent(): ElementParent;
95
+ get behaviour(): SerializableElement;
96
+ get broker(): Broker;
97
+ get environment(): Environment;
98
+ /** Per-execution context registry (see `Context`/`ContextInstance` from src). */
99
+ get context(): ContextInstance;
100
+ get logger(): ILogger;
101
+ }
102
+
103
+ // --- Event definitions --------------------------------------------------------
104
+
105
+ export interface EventReference {
106
+ id?: string;
107
+ name?: string;
108
+ referenceType: string;
109
+ [x: string]: any;
110
+ }
111
+
112
+ // Common ancestor for the typed event definitions; concrete types live in src/eventDefinitions.
113
+ export class EventDefinition {
114
+ constructor(activity: Activity, eventDefinitionElement: SerializableElement, context?: ContextInstance, index?: number);
115
+ get id(): string;
116
+ get type(): string;
117
+ get executionId(): string;
118
+ get isThrowing(): boolean;
119
+ get activity(): Activity;
120
+ get broker(): Broker;
121
+ get logger(): ILogger;
122
+ get reference(): EventReference;
123
+ [x: string]: any;
124
+ execute(executeMessage: ElementBrokerMessage): void;
125
+ }
126
+
127
+ /** Supported BPMN timer event definition types. */
128
+ export enum TimerTypeValue {
129
+ TimeCycle = 'timeCycle',
130
+ TimeDuration = 'timeDuration',
131
+ TimeDate = 'timeDate',
132
+ }
133
+
134
+ /** Accepts either a `TimerTypeValue` enum member or its underlying string literal. */
135
+ export type TimerType = TimerTypeValue | `${TimerTypeValue}`;
136
+
137
+ export type parsedTimer = {
138
+ /** Expires at date time */
139
+ expireAt?: Date;
140
+ /** Repeat number of times */
141
+ repeat?: number;
142
+ /** Delay in milliseconds */
143
+ delay?: number;
144
+ };
145
+
146
+ // --- Conditions ---------------------------------------------------------------
147
+
148
+ export interface ICondition {
149
+ /** Condition type */
150
+ get type(): string;
151
+ [x: string]: any;
152
+ /**
153
+ * Execute condition
154
+ * @param message Source element execution message
155
+ * @param callback Callback with truthy result if flow should be taken
156
+ */
157
+ execute(message: ElementBrokerMessage, callback: CallableFunction): void;
158
+ }
159
+
160
+ // --- Activity behaviour & extensions ------------------------------------------
161
+
162
+ export interface IActivityBehaviour {
163
+ id: string;
164
+ type: string;
165
+ activity: Activity;
166
+ environment: Environment;
167
+ new (activity: Activity, context: ContextInstance): IActivityBehaviour;
168
+ execute(executeMessage: ElementBrokerMessage): void;
169
+ }
170
+
171
+ export type Extension = (activity: any, context: any) => IExtension;
172
+
173
+ export interface IExtension {
174
+ activate(message: ElementBrokerMessage): void;
175
+ deactivate(message: ElementBrokerMessage): void;
176
+ }
177
+
178
+ export interface IExpressions {
179
+ resolveExpression(templatedString: string, context?: any, expressionFnContext?: any): any;
180
+ }
181
+
182
+ // --- Environment --------------------------------------------------------------
183
+
184
+ export interface EnvironmentSettings {
185
+ /** true returns dummy service function for service task if not found */
186
+ enableDummyService?: boolean;
187
+ /** true forces activity runs to go forward in steps, defaults to false */
188
+ step?: boolean;
189
+ /** strict mode, see documentation, defaults to false */
190
+ strict?: boolean;
191
+ /** positive integer to control parallel loop batch size, defaults to 50 */
192
+ batchSize?: number;
193
+ /**
194
+ * disable tracking state between recover and resume
195
+ * true will only return state for elements that are actually running
196
+ * Defaults to falsy
197
+ */
198
+ disableTrackState?: boolean;
199
+ [x: string]: any;
200
+ }
201
+
202
+ export interface EnvironmentOptions {
203
+ settings?: EnvironmentSettings;
204
+ variables?: Record<string, any>;
205
+ services?: Record<string, CallableFunction>;
206
+ Logger?: LoggerFactory;
207
+ timers?: ITimers;
208
+ scripts?: IScripts;
209
+ extensions?: Record<string, Extension>;
210
+ /**
211
+ * optional override expressions handler
212
+ */
213
+ expressions?: IExpressions;
214
+ }
215
+
216
+ // --- Filter / callback shapes -------------------------------------------------
217
+
218
+ export type startActivityFilterOptions = {
219
+ /** Event definition id, i.e. Message, Signal, Error, etc */
220
+ referenceId?: string;
221
+ /** Event definition type, i.e. message, signal, error, etc */
222
+ referenceType?: string;
223
+ };
224
+
225
+ export type filterPostponed = (elementApi: any) => boolean;
226
+
227
+ export type runCallback = (err: Error, definitionApi: any) => void;
228
+
229
+ // --- Run-status enums ---------------------------------------------------------
230
+
231
+ /**
232
+ * Definition status values. Covers both the entity (`Definition.status`) and
233
+ * the execution (`DefinitionExecution.status`) lifecycles.
234
+ */
235
+ export enum DefinitionStatusValue {
236
+ /** DefinitionExecution constructed, not yet started */
237
+ Init = 'init',
238
+ /** Definition run entered */
239
+ Entered = 'entered',
240
+ /** Definition run started */
241
+ Start = 'start',
242
+ /** Definition is executing */
243
+ Executing = 'executing',
244
+ /** Definition run ended */
245
+ End = 'end',
246
+ /** Definition run discarded */
247
+ Discarded = 'discarded',
248
+ /** Definition execution completed successfully */
249
+ Completed = 'completed',
250
+ /** Definition execution failed */
251
+ Error = 'error',
252
+ }
253
+
254
+ /** Accepts either a `DefinitionStatusValue` enum member or its string literal. */
255
+ export type DefinitionStatus = DefinitionStatusValue | `${DefinitionStatusValue}`;
256
+
257
+ /**
258
+ * Process status values. Covers both the entity (`Process.status`) and the
259
+ * execution (`ProcessExecution.status`) lifecycles.
260
+ */
261
+ export enum ProcessStatusValue {
262
+ /** ProcessExecution constructed, not yet started */
263
+ Init = 'init',
264
+ /** Process run entered */
265
+ Entered = 'entered',
266
+ /** Process run started */
267
+ Start = 'start',
268
+ /** Process is executing */
269
+ Executing = 'executing',
270
+ /** Process run errored */
271
+ Errored = 'errored',
272
+ /** Process run ended */
273
+ End = 'end',
274
+ /** Process run discarded */
275
+ Discarded = 'discarded',
276
+ /** Process execution discard in progress */
277
+ Discard = 'discard',
278
+ /** Process execution cancelled */
279
+ Cancel = 'cancel',
280
+ /** Process execution completed successfully */
281
+ Completed = 'completed',
282
+ /** Process execution failed */
283
+ Error = 'error',
284
+ /** Process execution terminated by a terminate end event */
285
+ Terminated = 'terminated',
286
+ }
287
+
288
+ /** Accepts either a `ProcessStatusValue` enum member or its string literal. */
289
+ export type ProcessStatus = ProcessStatusValue | `${ProcessStatusValue}`;
290
+
291
+ /**
292
+ * Activity status values. Covers both the per-activity run lifecycle and the
293
+ * rollup states surfaced by Process/Definition `activityStatus` getters. Save
294
+ * point candidates are `Timer` and `Wait`.
295
+ */
296
+ export enum ActivityStatusValue {
297
+ /** Idle, not running anything */
298
+ Idle = 'idle',
299
+ /** Run entered, triggered by taken inbound flow */
300
+ Entered = 'entered',
301
+ /** Run started */
302
+ Started = 'started',
303
+ /**
304
+ * At least one activity is executing,
305
+ * e.g. a service task making a asynchronous request
306
+ */
307
+ Executing = 'executing',
308
+ /** Activity behaviour execution completed successfully */
309
+ Executed = 'executed',
310
+ /** Run end, take outbound flows */
311
+ End = 'end',
312
+ /** Entering discard run, triggered by discarded inbound flow */
313
+ Discard = 'discard',
314
+ /** Run was discarded, discard outbound flows */
315
+ Discarded = 'discarded',
316
+ /** Activity behaviour execution failed, discard run */
317
+ Error = 'error',
318
+ /** Formatting next run message */
319
+ Formatting = 'formatting',
320
+ /**
321
+ * At least one activity is waiting for a timer to complete,
322
+ * usually only TimerEventDefinition's
323
+ */
324
+ Timer = 'timer',
325
+ /**
326
+ * At least one activity is waiting for a signal of some sort,
327
+ * e.g. user tasks, intermediate catch events, etc
328
+ */
329
+ Wait = 'wait',
330
+ }
331
+
332
+ /**
333
+ * Accepts either an `ActivityStatusValue` enum member or its underlying string
334
+ * literal, so JSDoc-typed assignments like `this.status = 'entered'` keep
335
+ * type-checking.
336
+ */
337
+ export type ActivityStatus = ActivityStatusValue | `${ActivityStatusValue}`;
338
+
339
+ // --- State snapshots ----------------------------------------------------------
340
+
341
+ export interface ElementState {
342
+ id: string;
343
+ type: string;
344
+ broker?: BrokerState;
345
+ [x: string]: any;
346
+ }
347
+
348
+ export interface EnvironmentState {
349
+ settings: EnvironmentSettings;
350
+ variables: Record<string, any>;
351
+ output: Record<string, any>;
352
+ }
353
+
354
+ export type completedCounters = { completed: number; discarded: number };
355
+
356
+ export interface ActivityExecutionState {
357
+ completed: boolean;
358
+ [x: string]: any;
359
+ }
360
+
361
+ export interface ActivityState extends ElementState {
362
+ status?: ActivityStatus;
363
+ executionId: string;
364
+ stopped: boolean;
365
+ counters: { taken: number; discarded: number };
366
+ execution?: ActivityExecutionState;
367
+ }
368
+
369
+ export interface SequenceFlowState extends ElementState {
370
+ counters: { take: number; discard: number; looped: number };
371
+ }
372
+
373
+ export interface MessageFlowState extends ElementState {
374
+ counters: { messages: number };
375
+ }
376
+
377
+ export interface AssociationState extends ElementState {
378
+ counters: { take: number; discard: number };
379
+ }
380
+
381
+ export interface ProcessExecutionState {
382
+ executionId: string;
383
+ stopped: boolean;
384
+ completed: boolean;
385
+ status: ProcessStatus;
386
+ children: ActivityState[];
387
+ flows?: SequenceFlowState[];
388
+ messageFlows?: MessageFlowState[];
389
+ associations?: AssociationState[];
390
+ }
391
+
392
+ export interface ProcessState extends ElementState {
393
+ status: ProcessStatus;
394
+ stopped: boolean;
395
+ executionId?: string;
396
+ counters: completedCounters;
397
+ environment: EnvironmentState;
398
+ execution?: ProcessExecutionState;
399
+ }
400
+
401
+ export interface DefinitionExecutionState {
402
+ executionId: string;
403
+ stopped: boolean;
404
+ completed: boolean;
405
+ status: DefinitionStatus;
406
+ processes: ProcessState[];
407
+ }
408
+
409
+ export interface DefinitionState extends ElementState {
410
+ /** State version. Absent on states saved before versioning. */
411
+ stateVersion?: number;
412
+ status: DefinitionStatus;
413
+ stopped: boolean;
414
+ executionId?: string;
415
+ counters: completedCounters;
416
+ environment: EnvironmentState;
417
+ execution?: DefinitionExecutionState;
418
+ }
419
+
420
+ // --- Logging ------------------------------------------------------------------
421
+
422
+ export type LoggerFactory = (scope: string) => ILogger;
423
+
424
+ export interface ILogger {
425
+ debug(...args: any[]): void;
426
+ error(...args: any[]): void;
427
+ warn(...args: any[]): void;
428
+ [x: string]: any;
429
+ }
430
+
431
+ // --- Timers -------------------------------------------------------------------
432
+
433
+ export type wrappedSetTimeout = (handler: CallableFunction, delay: number, ...args: any[]) => Timer;
434
+ export type wrappedClearTimeout = (ref: any) => void;
435
+
436
+ export interface Timer {
437
+ /** The function to call when the timer elapses */
438
+ readonly callback: CallableFunction;
439
+ /** The number of milliseconds to wait before calling the callback */
440
+ readonly delay: number;
441
+ /** Optional arguments to pass when the callback is called */
442
+ readonly args?: any[];
443
+ /** Timer owner if any */
444
+ readonly owner?: any;
445
+ /** Timer Id */
446
+ readonly timerId: string;
447
+ /** Timeout, return from setTimeout */
448
+ readonly timerRef: any;
449
+ [x: string]: any;
450
+ }
451
+
452
+ export interface RegisteredTimer {
453
+ owner?: any;
454
+ get setTimeout(): wrappedSetTimeout;
455
+ get clearTimeout(): wrappedClearTimeout;
456
+ }
457
+
458
+ export interface ITimers {
459
+ get setTimeout(): wrappedSetTimeout;
460
+ get clearTimeout(): wrappedClearTimeout;
461
+ register(owner?: any): RegisteredTimer;
462
+ [x: string]: any;
463
+ }
464
+
465
+ export interface TimersOptions {
466
+ /** Defaults to builtin setTimeout */
467
+ setTimeout?: typeof setTimeout;
468
+ /** Defaults to builtin clearTimeout */
469
+ clearTimeout?: typeof clearTimeout;
470
+ [x: string]: any;
471
+ }
472
+
473
+ // --- Scripts ------------------------------------------------------------------
474
+
475
+ export interface IScripts {
476
+ register(activity: Activity): Script | undefined;
477
+ getScript(language: string, identifier: { id: string; [x: string]: any }): Script;
478
+ }
479
+
480
+ export interface Script {
481
+ execute(executionContext: ExecutionScope, callback: CallableFunction): void;
482
+ }
483
+
484
+ // --- Generic api shape; constructed via Activity/Process/Definition/Flow Api factories.
485
+
486
+ export interface IApi<T> extends ElementBrokerMessage {
487
+ get id(): string;
488
+ get type(): string;
489
+ get name(): string;
490
+ get executionId(): string;
491
+ get environment(): Environment;
492
+ get broker(): ElementBroker<T>;
493
+ get owner(): T;
494
+ cancel(message?: signalMessage, options?: any): void;
495
+ discard(): void;
496
+ fail(error: Error): void;
497
+ signal(message?: signalMessage, options?: any): void;
498
+ stop(): void;
499
+ resolveExpression(expression: string): any;
500
+ sendApiMessage(action: string, content?: signalMessage, options?: any): void;
501
+ getPostponed(...args: any[]): any[];
502
+ createMessage(content?: Record<string, any>): any;
503
+ getExecuting(): IApi<T>[];
504
+ }
505
+
506
+ // --- Scope passed to user scripts/services -----------------------------------
507
+
508
+ export interface ExecutionScope extends ElementBrokerMessage {
509
+ /** Calling element id */
510
+ id: string;
511
+ /** Calling element type */
512
+ type: string;
513
+ environment: Environment;
514
+ /** Calling element logger instance */
515
+ logger?: ILogger;
516
+ /**
517
+ * Resolve expression with the current scope
518
+ * @param expression expression string
519
+ * @returns Whatever the expression returns
520
+ */
521
+ resolveExpression: (expression: string) => any;
522
+ ActivityError: ActivityError;
523
+ }
524
+
525
+ // --- Context --
526
+ export interface IExtensionsMapper {
527
+ get(activity: any): IExtensions[];
528
+ }
529
+
530
+ export interface IExtensions extends IExtension {
531
+ readonly count: number;
532
+ }
533
+
534
+ // --- IO ---
535
+
536
+ export interface IIOData {
537
+ [x: string]: any;
538
+ read(broker: Broker, exchange: string, routingKeyPrefix: string, messageProperties?: Record<string, any>): void;
539
+ write(broker: Broker, exchange: string, routingKeyPrefix: string, value: any, messageProperties?: Record<string, any>): void;
540
+ }
541
+ /**
542
+ * Activity wraps any element (task, event, gateway) and orchestrates its lifecycle through the broker.
543
+ * @param Behaviour Element-specific behaviour constructor invoked per execution
544
+ * @param activityDef Parsed BPMN element definition
545
+ * @param context Per-execution registry and factory
546
+ */
547
+ export class Activity {
548
+ /**
549
+ * Activity wraps any element (task, event, gateway) and orchestrates its lifecycle through the broker.
550
+ * @param Behaviour Element-specific behaviour constructor invoked per execution
551
+ * @param activityDef Parsed BPMN element definition
552
+ * @param context Per-execution registry and factory
553
+ */
554
+ constructor(Behaviour: IActivityBehaviour, activityDef: import("moddle-context-serializer").Activity, context: ContextInstance);
555
+ id: string | undefined;
556
+ type: string;
557
+ name: string | undefined;
558
+
559
+ behaviour: import("moddle-context-serializer").ActivityBehaviour;
560
+ Behaviour: IActivityBehaviour;
561
+
562
+ parent: import("moddle-context-serializer").Parent;
563
+
564
+ logger: ILogger;
565
+ environment: Environment;
566
+ context: ContextInstance;
567
+
568
+ status: ActivityStatus | undefined;
569
+ broker: ElementBroker<Activity>;
570
+ on: (eventName: string, callback: CallableFunction, eventOptions?: {
571
+ once?: boolean;
572
+ [x: string]: any;
573
+ }) => import("smqp").Consumer;
574
+ once: (eventName: string, callback: CallableFunction, eventOptions?: {
575
+ [x: string]: any;
576
+ }) => import("smqp").Consumer;
577
+ waitFor: (eventName: string, onMessage?: ((routingKey: string, message: ElementBrokerMessage, owner: Activity) => boolean) | undefined) => Promise<IApi<Activity>>;
578
+ emitFatal: (error: Error, content?: Record<string, any>) => void;
579
+ /**
580
+ * Subscribe to inbound flows and start consuming the inbound queue.
581
+ * */
582
+ activate(): void;
583
+ /**
584
+ * Cancel inbound subscriptions and any pending run/format consumers.
585
+ */
586
+ deactivate(): void;
587
+ /**
588
+ * Initialise activity executionId and emit init event without starting the run.
589
+ * @param initContent Optional content merged into the init message
590
+ */
591
+ init(initContent?: Record<string, any>): void;
592
+ /**
593
+ * Start running the activity by publishing run.enter and run.start.
594
+ * @param runContent Optional content merged into the run message
595
+ * @throws {Error} if the activity is already running
596
+ */
597
+ run(runContent?: Record<string, any>): void;
598
+ /**
599
+ * Snapshot activity state for recover.
600
+ * Returns undefined when nothing is running and `disableTrackState` is set.
601
+ * */
602
+ getState(): ActivityState;
603
+ /**
604
+ * Restore activity state captured by getState. Cannot be called while running.
605
+ * @returns this when state was applied
606
+ * @throws {Error} when activity is currently running
607
+ */
608
+ recover(state?: ActivityState): this;
609
+ stopped: boolean | undefined;
610
+ /**
611
+ * Resume after recover. If no run has been started, falls back to activate.
612
+ * @throws {Error} when called on a running activity
613
+ */
614
+ resume(): void;
615
+ /**
616
+ * Discard the activity. Stops execution if running; the activity leaves without taking any outbound flow.
617
+ * @param discardContent Optional content propagated with the discard
618
+ * */
619
+ discard(discardContent?: Record<string, any>): void;
620
+ /**
621
+ * Subscribe to inbound triggers (sequence flows, attached activity, or compensation associations).
622
+ * @returns count of subscribed triggers
623
+ */
624
+ addInboundListeners(): number;
625
+ /**
626
+ * Cancel inbound trigger subscriptions added by addInboundListeners.
627
+ */
628
+ removeInboundListeners(): void;
629
+ /**
630
+ * Stop the activity. If not currently running, just cancels the inbound consumer.
631
+ */
632
+ stop(): boolean | void;
633
+ /**
634
+ * Advance one run-step when the environment runs in step mode. No-op otherwise.
635
+ */
636
+ next(): false | ElementBrokerMessage | undefined;
637
+ /**
638
+ * Walk outbound flows to discover the activity graph from this point.
639
+ */
640
+ shake(): void;
641
+ /**
642
+ * Evaluate outbound sequence flows for the given source message.
643
+ * @param fromMessage Source run message
644
+ * @param discardRestAtTake When true, take only the first matching flow and discard the rest
645
+ * */
646
+ evaluateOutbound(fromMessage: ElementBrokerMessage, discardRestAtTake: boolean, callback: (err: Error, evaluationResult: any) => void): void;
647
+ /**
648
+ * Resolve an Api wrapper for the activity, preferring the running execution if any.
649
+ * */
650
+ getApi(message?: ElementBrokerMessage): IApi<Activity>;
651
+ /**
652
+ * Look up another activity in the same context.
653
+ * */
654
+ getActivityById(elementId: string): Activity | null;
655
+ get counters(): {
656
+ taken: number;
657
+ discarded: number;
658
+ };
659
+ get execution(): ActivityExecution | undefined;
660
+ get executionId(): string | undefined;
661
+ get extensions(): IExtension;
662
+ get bpmnIo(): IExtension | undefined;
663
+ get formatter(): Formatter;
664
+ get isRunning(): boolean;
665
+ get outbound(): SequenceFlow[];
666
+ get inbound(): SequenceFlow[];
667
+ get isEnd(): boolean;
668
+ get isStart(): boolean;
669
+ get isSubProcess(): boolean;
670
+ get isTransaction(): boolean;
671
+ get isMultiInstance(): boolean;
672
+ get isThrowing(): boolean;
673
+ get isCatching(): boolean;
674
+ get isForCompensation(): boolean;
675
+ get isParallelJoin(): boolean;
676
+ get isParallelGateway(): boolean;
677
+ get isStartEvent(): boolean;
678
+ get triggeredByEvent(): boolean;
679
+ get attachedTo(): Activity | null;
680
+ get lane(): Lane | undefined;
681
+ get eventDefinitions(): EventDefinition[] | undefined;
682
+ get parentElement(): Activity | Process;
683
+ get initialized(): boolean;
684
+ }
685
+ /**
686
+ * Per-run execution orchestrator for an Activity. Instantiates the element-specific behaviour
687
+ * and drives the execute message flow over the activity broker.
688
+ * */
689
+ export class ActivityExecution {
690
+ /**
691
+ * Per-run execution orchestrator for an Activity. Instantiates the element-specific behaviour
692
+ * and drives the execute message flow over the activity broker.
693
+ * */
694
+ constructor(activity: Activity, context: ContextInstance);
695
+ activity: Activity;
696
+ context: ContextInstance;
697
+ id: string | undefined;
698
+ broker: ElementBroker<Activity>;
699
+ get completed(): boolean;
700
+ /**
701
+ * Begin executing the activity behaviour. Resumes if the message is redelivered.
702
+ * @throws {Error} when message or executionId is missing
703
+ */
704
+ execute(executeMessage: ElementBrokerMessage): number | undefined;
705
+ executionId: string | undefined;
706
+ source: IActivityBehaviour | undefined;
707
+ /**
708
+ * Bind the execute queue and start consuming execute and api messages.
709
+ */
710
+ activate(): void;
711
+ /**
712
+ * Cancel execute and api consumers and unbind the execute queue.
713
+ */
714
+ deactivate(): void;
715
+ /**
716
+ * Discard the running execution.
717
+ */
718
+ discard(): void;
719
+ /**
720
+ * Resolve an Api wrapper, preferring a behaviour-specific Api when the source exposes one.
721
+ * */
722
+ getApi(apiMessage?: ElementBrokerMessage): IApi<Activity>;
723
+ /**
724
+ * Pass an execute message straight to the behaviour, executing first if no source is set up yet.
725
+ * */
726
+ passthrough(executeMessage: ElementBrokerMessage): void;
727
+ /**
728
+ * List currently postponed executions as Api wrappers, including those from sub-process behaviours.
729
+ */
730
+ getPostponed(): IApi<Activity>[];
731
+ /**
732
+ * Snapshot execution state, merging behaviour-specific state when the source provides it.
733
+ * */
734
+ getState(): ActivityExecutionState;
735
+ /**
736
+ * Restore execution state captured by getState.
737
+ * */
738
+ recover(state?: ActivityExecutionState): this;
739
+ /**
740
+ * Stop the execution via the activity api.
741
+ */
742
+ stop(): void;
743
+ }
744
+ /**
745
+ * BPMN error.
746
+ * */
747
+ export function BpmnError(errorDef: import("moddle-context-serializer").SerializableElement, context: ContextInstance): {
748
+ id: string | undefined;
749
+ type: string | undefined;
750
+ name: string;
751
+ errorCode: any;
752
+ resolve: (executionMessage: ElementBrokerMessage, error?: Error) => {
753
+ id?: string;
754
+ type?: string;
755
+ messageType: string;
756
+ name: string;
757
+ code: string | undefined;
758
+ inner?: Error;
759
+ };
760
+ };
761
+ /**
762
+ * Build a runtime Context from a parsed BPMN definition.
763
+ * @param environment Existing environment to clone; a fresh one is created when omitted
764
+ */
765
+ export function Context(definitionContext: import("moddle-context-serializer").SerializableContext, environment?: Environment): ContextInstance;
766
+ /**
767
+ * Per-execution registry that lazily upserts activities, flows, and processes from the parsed BPMN definition.
768
+ * @param owner Process or sub-process activity that owns this context
769
+ * @param peersCache Shared converging parallel gateway peer cache; created at the root and propagated to every clone
770
+ */
771
+ export class ContextInstance {
772
+ /**
773
+ * Per-execution registry that lazily upserts activities, flows, and processes from the parsed BPMN definition.
774
+ * @param owner Process or sub-process activity that owns this context
775
+ * @param peersCache Shared converging parallel gateway peer cache; created at the root and propagated to every clone
776
+ */
777
+ constructor(definitionContext: import("moddle-context-serializer").SerializableContext, environment: Environment, owner?: Process | Activity, peersCache?: Map<string, any>);
778
+ id: string;
779
+ name: string;
780
+ type: string;
781
+ /** Unique instance id */
782
+ sid: string;
783
+ definitionContext: import("moddle-context-serializer").SerializableContext;
784
+ environment: Environment;
785
+ /** Discovered parallel gateway peers, keyed by gateway id, shared with all clones. Runtime-only, not serialized. */
786
+ peersCache: Map<any, any>;
787
+
788
+ extensionsMapper: IExtensionsMapper;
789
+ get owner(): Activity | Process | undefined;
790
+ /**
791
+ * Get or create the activity instance for the given id.
792
+ * */
793
+ getActivityById(activityId: string): Activity | null;
794
+ /**
795
+ * Return the cached activity instance, instantiating it the first time it is referenced.
796
+ * */
797
+ upsertActivity(activityDef: import("moddle-context-serializer").SerializableElement): Activity;
798
+ /**
799
+ * Get or create the sequence flow instance for the given id.
800
+ * */
801
+ getSequenceFlowById(sequenceFlowId: string): SequenceFlow | null;
802
+
803
+ getInboundSequenceFlows(activityId: string): SequenceFlow[];
804
+
805
+ getOutboundSequenceFlows(activityId: string): SequenceFlow[];
806
+
807
+ getInboundAssociations(activityId: string): Association[];
808
+
809
+ getOutboundAssociations(activityId: string): Association[];
810
+ /**
811
+ * Get every activity in the definition, optionally narrowed to a parent scope.
812
+ * @param scopeId Process or sub-process id
813
+ */
814
+ getActivities(scopeId?: string): Activity[];
815
+ /**
816
+ * Get every sequence flow in the definition, optionally narrowed to a parent scope.
817
+ * @param scopeId Process or sub-process id
818
+ */
819
+ getSequenceFlows(scopeId?: string): SequenceFlow[];
820
+ /**
821
+ * Return the cached sequence flow, instantiating it the first time it is referenced.
822
+ * */
823
+ upsertSequenceFlow(flowDefinition: import("moddle-context-serializer").SerializableElement): SequenceFlow;
824
+ /**
825
+ * Get association flows
826
+ * @param scopeId Process or sub-process id
827
+ */
828
+ getAssociations(scopeId?: string): Association[];
829
+
830
+ upsertAssociation(associationDefinition: import("moddle-context-serializer").SerializableElement): Association;
831
+ /**
832
+ * Create a new context that shares the parsed definition but optionally swaps environment and owner.
833
+ *
834
+ */
835
+ clone(newEnvironment?: Environment, newOwner?: Process | Activity): ContextInstance;
836
+ /**
837
+ * Cached converging parallel gateway peers discovered by an earlier shake.
838
+ * */
839
+ getShakenPeers(gatewayId: string): Array<[string, string[]]> | undefined;
840
+ /**
841
+ * Store converging parallel gateway peers so subsequent runs can skip the graph shake.
842
+ * */
843
+ setShakenPeers(gatewayId: string, peers: Array<[string, string[]]>): void;
844
+ /**
845
+ * Get or create the process instance for the given id. Each process gets its own cloned environment.
846
+ * */
847
+ getProcessById(processId: string): Process | null;
848
+ /**
849
+ * Build a fresh, uncached process instance for the given id. Used by call activities.
850
+ * */
851
+ getNewProcessById(processId: string): Process | null;
852
+ /**
853
+ * Get every process in the definition.
854
+ * */
855
+ getProcesses(): Process[];
856
+ /**
857
+ * Get processes flagged executable in the definition.
858
+ * */
859
+ getExecutableProcesses(): Process[];
860
+ /**
861
+ * Get message flows that originate from the given process id.
862
+ * @param sourceId Source process id
863
+ * */
864
+ getMessageFlows(sourceId: string): MessageFlow[];
865
+ /**
866
+ * Get or create a data object instance for the given reference id.
867
+ * */
868
+ getDataObjectById(referenceId: string): IIOData | undefined;
869
+ /**
870
+ * Get or create a data store instance for the given reference id.
871
+ * */
872
+ getDataStoreById(referenceId: string): IIOData | undefined;
873
+ /**
874
+ * Get start activities, optionally filtered by referenced event definition or restricted to a parent scope.
875
+ * @param scopeId Process or sub-process id
876
+ */
877
+ getStartActivities(filterOptions?: startActivityFilterOptions, scopeId?: string): Activity[];
878
+ /**
879
+ * Inspect an activity def for link event definitions.
880
+ * */
881
+ getLinkEventDefinitionInfo(activityDef: import("moddle-context-serializer").Activity): {
882
+ linkBehaviour?: Function;
883
+ linkNames?: string[];
884
+ };
885
+ /**
886
+ * Get activities whose event definitions include the given Behaviour with a matching name.
887
+ * @param Behaviour Behaviour constructor to match against `ed.Behaviour`
888
+ * @param scopeId Process or sub-process id
889
+ */
890
+ getActivitiesByEventDefinitionBehaviour(Behaviour: Function, names: string[] | Iterable<string>, scopeId?: string): Activity[];
891
+ /**
892
+ * Resolve user-registered extensions and the built-in BpmnIO extension for an activity.
893
+ * Returns undefined when the activity has no extensions to attach.
894
+ * */
895
+ loadExtensions(activity: ElementBase): IExtension | undefined;
896
+ /**
897
+ * Resolve the parent process or sub-process activity that owns the given activity.
898
+ * */
899
+ getActivityParentById(activityId: string): Activity | Process | null;
900
+ }
901
+ /**
902
+ * Top-level wrapper for an executable BPMN definition. Owns its DefinitionExecution and
903
+ * mediates inter-process messaging.
904
+ * @param options When provided, environment is cloned and settings merged
905
+ */
906
+ export class Definition {
907
+ /**
908
+ * Top-level wrapper for an executable BPMN definition. Owns its DefinitionExecution and
909
+ * mediates inter-process messaging.
910
+ * @param options When provided, environment is cloned and settings merged
911
+ */
912
+ constructor(context: ContextInstance, options?: EnvironmentOptions);
913
+ id: string;
914
+
915
+ type: string;
916
+ name: string;
917
+
918
+ environment: Environment;
919
+ context: ContextInstance;
920
+ broker: ElementBroker<Definition>;
921
+ on: (eventName: string, callback: CallableFunction, eventOptions?: {
922
+ once?: boolean;
923
+ [x: string]: any;
924
+ }) => import("smqp").Consumer;
925
+ once: (eventName: string, callback: CallableFunction, eventOptions?: {
926
+ [x: string]: any;
927
+ }) => import("smqp").Consumer;
928
+ waitFor: (eventName: string, onMessage?: ((routingKey: string, message: ElementBrokerMessage, owner: Definition) => boolean) | undefined) => Promise<IApi<Definition>>;
929
+ emit: (eventName: string, content?: Record<string, any>, props?: any) => void;
930
+ emitFatal: (error: Error, content?: Record<string, any>) => void;
931
+
932
+ logger: ILogger;
933
+ /**
934
+ * Start running the definition. Accepts run options, a callback, or both.
935
+ * The callback fires once on leave, stop, or error.
936
+ * @throws {Error} when already running and no callback is supplied
937
+ */
938
+ run(optionsOrCallback?: Record<string, any> | runCallback, optionalCallback?: runCallback): this;
939
+ /**
940
+ * Resume after recover by republishing the last run message. The callback fires once on
941
+ * leave, stop, or error.
942
+ * */
943
+ resume(callback?: runCallback): this;
944
+ /**
945
+ * Snapshot definition state for recover.
946
+ * */
947
+ getState(): DefinitionState;
948
+ /**
949
+ * Restore definition state captured by getState.
950
+ * @throws {Error} when called on a running definition
951
+ */
952
+ recover(state?: DefinitionState): this;
953
+ /**
954
+ * Walk activity graphs to discover sequences. Limited to the activity's owning process
955
+ * when startId is given, otherwise all processes are shaken.
956
+ * */
957
+ shake(startId?: string): ShakeResult | undefined;
958
+ /**
959
+ * Get every process in the definition.
960
+ */
961
+ getProcesses(): Process[];
962
+ /**
963
+ * Get processes flagged executable in the definition.
964
+ */
965
+ getExecutableProcesses(): Process[];
966
+ /**
967
+ * Get processes that are currently running.
968
+ */
969
+ getRunningProcesses(): Process[];
970
+
971
+ getProcessById(processId: string): Process | undefined;
972
+ /**
973
+ * Find an activity by id across all processes in the definition.
974
+ * */
975
+ getActivityById(childId: string): Activity | null;
976
+ /**
977
+ * Lookup any element (activity, flow, etc.) in the parsed definition by id.
978
+ * */
979
+ getElementById(elementId: string): Activity | null;
980
+ /**
981
+ * List currently postponed activities as Api wrappers.
982
+ *
983
+ */
984
+ getPostponed(...args: any[]): never[] | IApi<Activity>;
985
+ /**
986
+ * Resolve a Definition Api wrapper, preferring the running execution if any.
987
+ * @throws {Error} when the definition is not running and no message is given
988
+ */
989
+ getApi(message?: ElementBrokerMessage): IApi<this>;
990
+ /**
991
+ * Send a delegated signal to the running definition.
992
+ *
993
+ */
994
+ signal(message?: signalMessage): void;
995
+ /**
996
+ * Cancel a running activity inside the definition by delegated api message.
997
+ *
998
+ */
999
+ cancelActivity(message?: signalMessage): void;
1000
+ /**
1001
+ * Deliver a message to a referenced element. Resolves the message reference when the
1002
+ * target element exposes a `resolve` method (e.g. message-, signal-, escalation events).
1003
+ * */
1004
+ sendMessage(message: {
1005
+ id?: string;
1006
+ [x: string]: any;
1007
+ }): void;
1008
+ /**
1009
+ * Stop the definition if running.
1010
+ */
1011
+ stop(): void;
1012
+ get counters(): {
1013
+ completed: number;
1014
+ discarded: number;
1015
+ };
1016
+ get execution(): DefinitionExecution | undefined;
1017
+ get executionId(): string | undefined;
1018
+ get isRunning(): boolean;
1019
+ get status(): DefinitionStatus | undefined;
1020
+ get stopped(): boolean;
1021
+ get activityStatus(): ActivityStatus;
1022
+ }
1023
+ /**
1024
+ * Drives the execution of a Definition. Activates executable processes, routes inter-process
1025
+ * delegate messages and call activity hand-offs, and rolls completion up to the Definition.
1026
+ * */
1027
+ export class DefinitionExecution {
1028
+ /**
1029
+ * Drives the execution of a Definition. Activates executable processes, routes inter-process
1030
+ * delegate messages and call activity hand-offs, and rolls completion up to the Definition.
1031
+ * */
1032
+ constructor(definition: Definition, context: ContextInstance);
1033
+ id: string;
1034
+ type: string;
1035
+ broker: ElementBroker<Definition>;
1036
+ environment: Environment;
1037
+ context: ContextInstance;
1038
+ executionId: string | undefined;
1039
+ /**
1040
+ * Activate executable processes and start the definition execution. Resumes if the message
1041
+ * is redelivered. When `content.processId` is set, only that process is started.
1042
+ * @throws {Error} when message or executionId is missing
1043
+ */
1044
+ execute(executeMessage: ElementBrokerMessage): number | true | undefined;
1045
+ /**
1046
+ * Resume after recover by reactivating running processes.
1047
+ */
1048
+ resume(): number | undefined;
1049
+ /**
1050
+ * Restore execution state captured by getState. Reinstates running processes from the snapshot.
1051
+ * @param recoveredVersion State version
1052
+ * */
1053
+ recover(state?: DefinitionExecutionState, recoveredVersion?: number): this;
1054
+ /**
1055
+ * Stop the running execution via the api.
1056
+ */
1057
+ stop(): void;
1058
+ /**
1059
+ * Get every process in the definition (running first, then any non-running by id).
1060
+ * */
1061
+ getProcesses(): Process[];
1062
+
1063
+ getProcessById(processId: string): Process | undefined;
1064
+ /**
1065
+ * Get every process matching the given id (call activities can spawn duplicates).
1066
+ * */
1067
+ getProcessesById(processId: string): Process[];
1068
+
1069
+ getProcessByExecutionId(processExecutionId: string): Process | undefined;
1070
+ /**
1071
+ * Get processes that have an executionId, i.e. are currently running.
1072
+ * */
1073
+ getRunningProcesses(): Process[];
1074
+ /**
1075
+ * Get processes flagged executable in the definition.
1076
+ * */
1077
+ getExecutableProcesses(): Process[];
1078
+ /**
1079
+ * Snapshot execution state for recover.
1080
+ * */
1081
+ getState(): DefinitionExecutionState;
1082
+ /**
1083
+ * Resolve a Definition Api or, when the message belongs to a child process, its process Api.
1084
+ * */
1085
+ getApi(apiMessage?: ElementBrokerMessage): IApi<Definition>;
1086
+ /**
1087
+ * List currently postponed activities across every running process.
1088
+ * */
1089
+ getPostponed(...args: any[]): IApi<Activity>;
1090
+ get stopped(): boolean;
1091
+ get completed(): boolean;
1092
+ get status(): DefinitionStatus;
1093
+ get processes(): Process[];
1094
+ get postponedCount(): number;
1095
+ get isRunning(): boolean;
1096
+ get activityStatus(): ActivityStatus;
1097
+ }
1098
+ /**
1099
+ * Placeholder activity for non-executable elements (text annotations, groups, categories).
1100
+ * */
1101
+ export function Category(activityDef: import("moddle-context-serializer").Activity): {
1102
+ id: string;
1103
+ type: string;
1104
+ name: string | undefined;
1105
+ behaviour: Record<string, any>;
1106
+ parent: ElementParent;
1107
+ placeholder: true;
1108
+ };
1109
+ /**
1110
+ * Holds global execution config: variables, injected services, timers, scripts engine,
1111
+ * expressions, Logger factory, and settings such as `batchSize`. Cloned and merged per Definition.
1112
+ *
1113
+ */
1114
+ export class Environment {
1115
+ /**
1116
+ * Holds global execution config: variables, injected services, timers, scripts engine,
1117
+ * expressions, Logger factory, and settings such as `batchSize`. Cloned and merged per Definition.
1118
+ *
1119
+ */
1120
+ constructor(options?: EnvironmentOptions);
1121
+ options: EnvironmentOptions;
1122
+
1123
+ expressions: IExpressions;
1124
+ extensions: Record<string, Extension> | undefined;
1125
+ output: any;
1126
+
1127
+ scripts: IScripts;
1128
+
1129
+ timers: ITimers;
1130
+
1131
+ settings: EnvironmentSettings;
1132
+
1133
+ Logger: LoggerFactory;
1134
+ get variables(): Record<string, any>;
1135
+ set services(value: Record<string, CallableFunction>);
1136
+ get services(): Record<string, CallableFunction>;
1137
+ /**
1138
+ * Snapshot environment state for recover.
1139
+ * */
1140
+ getState(): EnvironmentState;
1141
+ /**
1142
+ * Restore environment state captured by getState. Merges into the existing settings,
1143
+ * variables, and output rather than replacing them.
1144
+ * */
1145
+ recover(state?: EnvironmentState): this;
1146
+ /**
1147
+ * Clone the environment, optionally overriding options. Services are merged when
1148
+ * `overrideOptions.services` is supplied.
1149
+ * */
1150
+ clone(overrideOptions?: EnvironmentOptions): Environment;
1151
+ /**
1152
+ * Merge variables into the environment. Non-objects are ignored.
1153
+ * */
1154
+ assignVariables(newVars: Record<string, any>): void;
1155
+ /**
1156
+ * Merge settings into the environment. Non-objects are ignored.
1157
+ * */
1158
+ assignSettings(newSettings: EnvironmentSettings): this;
1159
+ /**
1160
+ * Resolve a registered script by language and identifier.
1161
+ * */
1162
+ getScript(...args: any[]): Script;
1163
+ /**
1164
+ * Register a script for an activity, delegating to the configured scripts engine.
1165
+ * */
1166
+ registerScript(...args: any[]): Script | undefined;
1167
+ /**
1168
+ * Lookup a registered service by name.
1169
+ * */
1170
+ getServiceByName(serviceName: string): CallableFunction;
1171
+ /**
1172
+ * Resolve an expression with the environment as scope, optionally extended by an element message.
1173
+ * @param message Element message merged onto the resolution scope
1174
+ *
1175
+ */
1176
+ resolveExpression(expression: string, message?: ElementBrokerMessage, expressionFnContext?: any): any;
1177
+ /**
1178
+ * Register a service callable by name.
1179
+ * @param name service function name
1180
+ * @param fn service function
1181
+ */
1182
+ addService(name: string, fn: CallableFunction): void;
1183
+ }
1184
+ /**
1185
+ * Builtin data object. Reads from / writes to `environment.variables._data`.
1186
+ * */
1187
+ export class DataObject {
1188
+ /**
1189
+ * Builtin data object. Reads from / writes to `environment.variables._data`.
1190
+ * */
1191
+ constructor(dataObjectDef: import("moddle-context-serializer").DataObject, { environment }: ContextInstance);
1192
+ id: string | undefined;
1193
+ type: string | undefined;
1194
+ name: string | undefined;
1195
+
1196
+ behaviour: Record<string, any>;
1197
+
1198
+ parent: import("moddle-context-serializer").Parent | undefined;
1199
+ environment: Environment;
1200
+
1201
+ read(broker: import("smqp").Broker, exchange: string, routingKeyPrefix: string, messageProperties?: Record<string, any>): number | undefined;
1202
+
1203
+ write(broker: import("smqp").Broker, exchange: string, routingKeyPrefix: string, value: any, messageProperties?: Record<string, any>): number | undefined;
1204
+ }
1205
+ /**
1206
+ * Builtin data store. Reads from / writes to `environment.variables._data`.
1207
+ * */
1208
+ export class DataStore {
1209
+ /**
1210
+ * Builtin data store. Reads from / writes to `environment.variables._data`.
1211
+ * */
1212
+ constructor(dataStoreDef: import("moddle-context-serializer").DataStore, { environment }: ContextInstance);
1213
+ id: string | undefined;
1214
+ type: string | undefined;
1215
+ name: string | undefined;
1216
+
1217
+ behaviour: Record<string, any>;
1218
+
1219
+ parent: import("moddle-context-serializer").Parent | undefined;
1220
+ environment: Environment;
1221
+
1222
+ read(broker: import("smqp").Broker, exchange: string, routingKeyPrefix: string, messageProperties?: Record<string, any>): number | undefined;
1223
+
1224
+ write(broker: import("smqp").Broker, exchange: string, routingKeyPrefix: string, value: any, messageProperties?: Record<string, any>): number | undefined;
1225
+ }
1226
+ /**
1227
+ * Builtin data store reference. Reads from / writes to `environment.variables._data`.
1228
+ * */
1229
+ export class DataStoreReference {
1230
+ /**
1231
+ * Builtin data store reference. Reads from / writes to `environment.variables._data`.
1232
+ * */
1233
+ constructor(dataObjectDef: import("moddle-context-serializer").DataStore, { environment }: ContextInstance);
1234
+ id: string | undefined;
1235
+ type: string | undefined;
1236
+ name: string | undefined;
1237
+
1238
+ behaviour: Record<string, any>;
1239
+
1240
+ parent: import("moddle-context-serializer").Parent | undefined;
1241
+ environment: Environment;
1242
+
1243
+ read(broker: import("smqp").Broker, exchange: string, routingKeyPrefix: string, messageProperties?: Record<string, any>): number | undefined;
1244
+
1245
+ write(broker: import("smqp").Broker, exchange: string, routingKeyPrefix: string, value: any, messageProperties?: Record<string, any>): number | undefined;
1246
+ }
1247
+ /**
1248
+ * Escalation reference element. Resolves the escalation name expression against the execution message.
1249
+ * */
1250
+ export class Escalation {
1251
+ /**
1252
+ * Escalation reference element. Resolves the escalation name expression against the execution message.
1253
+ * */
1254
+ constructor(escalationDef: import("moddle-context-serializer").SerializableElement, context: ContextInstance);
1255
+ id: string | undefined;
1256
+ type: string | undefined;
1257
+ name: string | undefined;
1258
+
1259
+ parent: ElementParent;
1260
+ environment: Environment | undefined;
1261
+ /**
1262
+ * Resolve escalation reference for the given execution message.
1263
+ * */
1264
+ resolve(executionMessage: ElementBrokerMessage): {
1265
+ id: string | undefined;
1266
+ type: string | undefined;
1267
+ messageType: string;
1268
+ name: any;
1269
+ parent: {
1270
+ id: string;
1271
+ type: string;
1272
+ executionId: string;
1273
+ path?: Omit<ElementParent, "path">[];
1274
+ };
1275
+ };
1276
+ }
1277
+ /**
1278
+ * Activity ioSpecification behaviour. Reads bound data objects on enter and writes them on completion.
1279
+ * */
1280
+ export class InputOutputSpecification {
1281
+ /**
1282
+ * Activity ioSpecification behaviour. Reads bound data objects on enter and writes them on completion.
1283
+ * */
1284
+ constructor(activity: Activity, ioSpecificationDef: import("moddle-context-serializer").IoSpecification, context: ContextInstance);
1285
+ id: string | undefined;
1286
+ type: string;
1287
+ behaviour: {
1288
+ dataInputs?: import("moddle-context-serializer").IElement[];
1289
+ dataOutputs?: import("moddle-context-serializer").IElement[];
1290
+ };
1291
+ activity: Activity;
1292
+ broker: ElementBroker<Activity>;
1293
+ context: ContextInstance;
1294
+
1295
+ activate(message?: ElementBrokerMessage): void;
1296
+ deactivate(): void;
1297
+ }
1298
+ /**
1299
+ * Process lane. Wraps a `<bpmn:lane>` definition and points back to its owning process;
1300
+ * activities reference their lane through `Activity.lane`.
1301
+ * */
1302
+ export class Lane {
1303
+ /**
1304
+ * Process lane. Wraps a `<bpmn:lane>` definition and points back to its owning process;
1305
+ * activities reference their lane through `Activity.lane`.
1306
+ * */
1307
+ constructor(process: Process, laneDefinition: import("moddle-context-serializer").SerializableElement);
1308
+ id: string | undefined;
1309
+ type: string | undefined;
1310
+
1311
+ name: string;
1312
+
1313
+ parent: import("moddle-context-serializer").Parent;
1314
+
1315
+ behaviour: Record<string, any>;
1316
+ environment: Environment;
1317
+ broker: ElementBroker<Process>;
1318
+ context: ContextInstance;
1319
+ logger: ILogger;
1320
+ get process(): Process;
1321
+ }
1322
+ /**
1323
+ * Loop characteristics
1324
+ * */
1325
+ export class MultiInstanceLoopCharacteristics {
1326
+ /**
1327
+ * Loop characteristics
1328
+ * */
1329
+ constructor(activity: Activity, loopCharacteristics: import("moddle-context-serializer").SerializableElement);
1330
+ activity: Activity;
1331
+ loopCharacteristics: import("moddle-context-serializer").SerializableElement<Record<string, any>>;
1332
+ type: string;
1333
+
1334
+ isSequential: boolean;
1335
+
1336
+ collection: string | undefined;
1337
+
1338
+ loopCardinality: number | undefined;
1339
+ loopType: string | undefined;
1340
+
1341
+ elementVariable: string | undefined;
1342
+
1343
+ characteristics: Characteristics;
1344
+ execution: any;
1345
+
1346
+ execute(executeMessage: ElementBrokerMessage): void;
1347
+ }
1348
+ /**
1349
+ * Per-execution snapshot of resolved loop characteristics (cardinality, collection, conditions).
1350
+ * */
1351
+ class Characteristics {
1352
+ /**
1353
+ * Per-execution snapshot of resolved loop characteristics (cardinality, collection, conditions).
1354
+ * */
1355
+ constructor(activity: Activity, loopCharacteristics: import("moddle-context-serializer").SerializableElement, executeMessage: ElementBrokerMessage);
1356
+ activity: Activity;
1357
+ behaviour: Record<string, any>;
1358
+ message: ElementBrokerMessage;
1359
+ type: string;
1360
+ id: string | undefined;
1361
+ broker: ElementBroker<Activity>;
1362
+ parentExecutionId: string | undefined;
1363
+
1364
+ isSequential: boolean;
1365
+ output: any;
1366
+ parent: ElementParent;
1367
+ loopCardinality: number | undefined;
1368
+ startCondition: string | undefined;
1369
+ completionCondition: string;
1370
+ collection: any[] | undefined;
1371
+
1372
+ elementVariable: string;
1373
+ cardinality: number | undefined;
1374
+ logger: ILogger;
1375
+ batchSize: number;
1376
+
1377
+ getContent(): ElementMessageContent;
1378
+
1379
+ next(index: number): ElementMessageContent;
1380
+ /**
1381
+ * @returns cardinality
1382
+ */
1383
+ getCardinality(collection?: any): number | undefined;
1384
+
1385
+ getCollection(): any[] | undefined;
1386
+
1387
+ isStartConditionMet(message: ElementBrokerMessage): any;
1388
+
1389
+ isCompletionConditionMet(message: ElementBrokerMessage): any;
1390
+
1391
+ complete(content: ElementMessageContent, allDiscarded?: boolean): void;
1392
+
1393
+ subscribe(onIterationCompleteMessage: ElementBrokerMessage): void;
1394
+ stop(): void;
1395
+ }
1396
+ /**
1397
+ * Message reference element. Resolves the message name expression against the execution message.
1398
+ * */
1399
+ export class Message {
1400
+ /**
1401
+ * Message reference element. Resolves the message name expression against the execution message.
1402
+ * */
1403
+ constructor(messageDef: import("moddle-context-serializer").SerializableElement, context: ContextInstance);
1404
+ id: string | undefined;
1405
+ type: string | undefined;
1406
+ name: string | undefined;
1407
+
1408
+ parent: ElementParent;
1409
+ environment: Environment | undefined;
1410
+ /**
1411
+ * Resolve message reference for the given execution message.
1412
+ * */
1413
+ resolve(executionMessage: ElementBrokerMessage): {
1414
+ parent: {
1415
+ id: string;
1416
+ type: string;
1417
+ executionId: string;
1418
+ path?: Omit<ElementParent, "path">[];
1419
+ };
1420
+ name?: any;
1421
+ id: string | undefined;
1422
+ type: string | undefined;
1423
+ messageType: string;
1424
+ };
1425
+ }
1426
+ /**
1427
+ * Owns one `<bpmn:process>`. Wraps the structural definition and orchestrates flow traversal,
1428
+ * joins, and parallel activation through ProcessExecution.
1429
+ * */
1430
+ export class Process {
1431
+ /**
1432
+ * Owns one `<bpmn:process>`. Wraps the structural definition and orchestrates flow traversal,
1433
+ * joins, and parallel activation through ProcessExecution.
1434
+ * */
1435
+ constructor(processDef: import("moddle-context-serializer").Process, context: ContextInstance);
1436
+ id: string | undefined;
1437
+ type: string;
1438
+ name: string | undefined;
1439
+
1440
+ parent: ElementParent;
1441
+
1442
+ behaviour: import("moddle-context-serializer").Process["behaviour"];
1443
+ isExecutable: any;
1444
+ environment: Environment;
1445
+ context: ContextInstance;
1446
+ broker: ElementBroker<Process>;
1447
+ on: (eventName: string, callback: CallableFunction, eventOptions?: {
1448
+ once?: boolean;
1449
+ [x: string]: any;
1450
+ }) => import("smqp").Consumer;
1451
+ once: (eventName: string, callback: CallableFunction, eventOptions?: {
1452
+ [x: string]: any;
1453
+ }) => import("smqp").Consumer;
1454
+ waitFor: (eventName: string, onMessage?: ((routingKey: string, message: ElementBrokerMessage, owner: Process) => boolean) | undefined) => Promise<IApi<Process>>;
1455
+ logger: ILogger;
1456
+ /**
1457
+ * Allocate an executionId and emit init event without starting the run.
1458
+ * @param useAsExecutionId Override for the generated execution id
1459
+ */
1460
+ init(useAsExecutionId?: string): void;
1461
+ /**
1462
+ * Start running the process by publishing run.enter, run.start, and run.execute.
1463
+ * @param runContent Optional content merged into the run message
1464
+ * @throws {Error} when the process is already running
1465
+ */
1466
+ run(runContent?: Record<string, any>): void;
1467
+ /**
1468
+ * Resume after recover by republishing the last run message.
1469
+ * @throws {Error} when called on a running process
1470
+ */
1471
+ resume(): this;
1472
+ /**
1473
+ * Snapshot process state for recover.
1474
+ * */
1475
+ getState(): ProcessState;
1476
+ /**
1477
+ * Restore process state captured by getState.
1478
+ * @param recoveredVersion State version
1479
+ * @throws {Error} when called on a running process
1480
+ */
1481
+ recover(state?: ProcessState, recoveredVersion?: number): this;
1482
+ /**
1483
+ * Walk activity graph from the given start id, or every start activity when omitted.
1484
+ * */
1485
+ shake(startId?: string): ShakeResult;
1486
+ /**
1487
+ * Stop the process if running.
1488
+ */
1489
+ stop(): void;
1490
+ /**
1491
+ * Resolve a Process Api wrapper, preferring the running execution if any.
1492
+ * */
1493
+ getApi(message?: ElementBrokerMessage): IApi<this>;
1494
+ /**
1495
+ * Send a delegated signal to the running process.
1496
+ *
1497
+ */
1498
+ signal(message?: signalMessage): void;
1499
+ /**
1500
+ * Cancel a running activity inside the process by delegated api message.
1501
+ *
1502
+ */
1503
+ cancelActivity(message?: signalMessage): void;
1504
+ /**
1505
+ * Deliver a message to a target activity or start activity that references it.
1506
+ * Starts the process if a target is found and the process is idle.
1507
+ * */
1508
+ sendMessage(message: ElementBrokerMessage): void;
1509
+
1510
+ getActivityById(childId: string): Activity | null;
1511
+ /**
1512
+ * Get every activity in the process scope.
1513
+ */
1514
+ getActivities(): Activity[];
1515
+ /**
1516
+ * Get start activities, optionally filtered by referenced event definition.
1517
+ *
1518
+ */
1519
+ getStartActivities(filterOptions?: startActivityFilterOptions): Activity[];
1520
+ /**
1521
+ * Get sequence flows in the process scope.
1522
+ */
1523
+ getSequenceFlows(): SequenceFlow | SequenceFlow[];
1524
+
1525
+ getLaneById(laneId: string): Lane | undefined;
1526
+ /**
1527
+ * List currently postponed activities as Api wrappers.
1528
+ *
1529
+ */
1530
+ getPostponed(...args: any[]): IApi<Activity>[];
1531
+ get counters(): {
1532
+ completed: number;
1533
+ discarded: number;
1534
+ };
1535
+ get lanes(): Lane[] | undefined;
1536
+ get extensions(): IExtension | undefined;
1537
+ get stopped(): boolean;
1538
+ get isRunning(): boolean;
1539
+ get executionId(): string | undefined;
1540
+ get execution(): ProcessExecution | undefined;
1541
+ get status(): ProcessStatus | undefined;
1542
+ get activityStatus(): ActivityStatus;
1543
+ }
1544
+ /**
1545
+ * Activity properties behaviour. Resolves bound data input/output references during the run.
1546
+ * */
1547
+ export function Properties(activity: Activity, propertiesDef: {
1548
+ type: "properties";
1549
+ values: import("moddle-context-serializer").IElement[];
1550
+ }, context: ContextInstance): void;
1551
+ export class Properties {
1552
+ /**
1553
+ * Activity properties behaviour. Resolves bound data input/output references during the run.
1554
+ * */
1555
+ constructor(activity: Activity, propertiesDef: {
1556
+ type: "properties";
1557
+ values: import("moddle-context-serializer").IElement[];
1558
+ }, context: ContextInstance);
1559
+ activity: Activity;
1560
+ broker: ElementBroker<Activity>;
1561
+
1562
+ activate(message: ElementBrokerMessage): void;
1563
+ deactivate(): void;
1564
+ }
1565
+ /**
1566
+ * Service implementation
1567
+ * */
1568
+ export class ServiceImplementation {
1569
+ /**
1570
+ * Service implementation
1571
+ * */
1572
+ constructor(activity: Activity);
1573
+ type: string;
1574
+ implementation: any;
1575
+ activity: Activity;
1576
+ execute(executionMessage: any, callback: any): any;
1577
+ }
1578
+ /**
1579
+ * Signal reference element. Resolves the signal name expression against the execution message.
1580
+ * */
1581
+ export class Signal {
1582
+ /**
1583
+ * Signal reference element. Resolves the signal name expression against the execution message.
1584
+ * */
1585
+ constructor(signalDef: import("moddle-context-serializer").SerializableElement, context: ContextInstance);
1586
+ id: string | undefined;
1587
+ type: string | undefined;
1588
+ name: string | undefined;
1589
+
1590
+ parent: ElementParent;
1591
+ environment: Environment | undefined;
1592
+ /**
1593
+ * Resolve signal reference for the given execution message.
1594
+ * */
1595
+ resolve(executionMessage: ElementBrokerMessage): {
1596
+ parent: {
1597
+ id: string;
1598
+ type: string;
1599
+ executionId: string;
1600
+ path?: Omit<ElementParent, "path">[];
1601
+ };
1602
+ name?: any;
1603
+ id: string | undefined;
1604
+ type: string | undefined;
1605
+ messageType: string;
1606
+ };
1607
+ }
1608
+ /**
1609
+ * Standard loop characteristics
1610
+ * */
1611
+ export function StandardLoopCharacteristics(activity: Activity, loopCharacteristics: import("moddle-context-serializer").SerializableElement): MultiInstanceLoopCharacteristics;
1612
+ export class ActivityError extends Error {
1613
+
1614
+ constructor(description: string, sourceMessage?: ElementBrokerMessage, inner?: Error | {
1615
+ name?: string;
1616
+ code?: string | number;
1617
+ });
1618
+
1619
+ type: string;
1620
+
1621
+ description: string;
1622
+
1623
+ source: Pick<ElementBrokerMessage, "fields" | "content" | "properties"> | undefined;
1624
+
1625
+ inner: Error | {
1626
+ name?: string;
1627
+ code?: string | number;
1628
+ } | undefined;
1629
+
1630
+ code: string | number | undefined;
1631
+ }
1632
+ export class RunError extends ActivityError {
1633
+ }
1634
+ /**
1635
+ * Drives the execution of a single process or sub-process: activates children, routes activity
1636
+ * events, and rolls completion up to the owning Process or sub-process Activity.
1637
+ * */
1638
+ class ProcessExecution {
1639
+ /**
1640
+ * Drives the execution of a single process or sub-process: activates children, routes activity
1641
+ * events, and rolls completion up to the owning Process or sub-process Activity.
1642
+ * */
1643
+ constructor(parentActivity: Process | Activity, context: ContextInstance);
1644
+ id: string | undefined;
1645
+ type: string;
1646
+ isSubProcess: any;
1647
+ isTransaction: any;
1648
+ broker: ElementBroker<Process> | ElementBroker<Activity>;
1649
+ environment: Environment;
1650
+ context: ContextInstance;
1651
+ executionId: string | undefined;
1652
+ /**
1653
+ * Activate children and start the process execution. Resumes if the message is redelivered.
1654
+ * @throws {Error} when message or executionId is missing
1655
+ */
1656
+ execute(executeMessage: ElementBrokerMessage): true | void;
1657
+ /**
1658
+ * Resume after recover, resuming any postponed children.
1659
+ */
1660
+ resume(): void;
1661
+ /**
1662
+ * Snapshot execution state including children, flows, message flows, and associations.
1663
+ * */
1664
+ getState(): ProcessExecutionState;
1665
+ /**
1666
+ * Restore execution state captured by getState.
1667
+ * @param recoveredVersion State version
1668
+ * */
1669
+ recover(state?: ProcessExecutionState, recoveredVersion?: number): this;
1670
+ /**
1671
+ * Walk activity graph from the given start id, or every start activity when omitted.
1672
+ * */
1673
+ shake(fromId?: string): ShakeResult;
1674
+ /**
1675
+ * Stop the running process execution via the api.
1676
+ */
1677
+ stop(): void;
1678
+ /**
1679
+ * List currently postponed children as Api wrappers.
1680
+ *
1681
+ */
1682
+ getPostponed(filterFn?: filterPostponed): IApi<Activity>[];
1683
+ /**
1684
+ * Queue a discard message that propagates to all running children.
1685
+ */
1686
+ discard(): void;
1687
+ /**
1688
+ * Queue a cancel message that propagates to all running children.
1689
+ */
1690
+ cancel(): void;
1691
+ /**
1692
+ * Get child activities in the process scope.
1693
+ * */
1694
+ getActivities(): Activity[];
1695
+
1696
+ getActivityById(activityId: string): Activity;
1697
+ /**
1698
+ * Get sequence flows in the process scope.
1699
+ * */
1700
+ getSequenceFlows(): SequenceFlow;
1701
+ /**
1702
+ * Get associations in the process scope.
1703
+ * */
1704
+ getAssociations(): Association;
1705
+ /**
1706
+ * Resolve a process or child Api for the given message.
1707
+ * */
1708
+ getApi(message?: ElementBrokerMessage): IApi<Process>;
1709
+ get stopped(): boolean;
1710
+ get completed(): boolean;
1711
+ get status(): ProcessStatus;
1712
+ get postponedCount(): number;
1713
+ get isRunning(): boolean;
1714
+ get activityStatus(): ActivityStatus;
1715
+ }
1716
+ /**
1717
+ * Sequence flow connecting two activities. Owns its broker and publishes take/discard/looped
1718
+ * events; activities subscribe to drive their inbound queue.
1719
+ * */
1720
+ export class SequenceFlow {
1721
+ /**
1722
+ * Sequence flow connecting two activities. Owns its broker and publishes take/discard/looped
1723
+ * events; activities subscribe to drive their inbound queue.
1724
+ * */
1725
+ constructor(flowDef: import("moddle-context-serializer").SequenceFlow, { environment }: ContextInstance);
1726
+ id: string | undefined;
1727
+ type: string;
1728
+ name: string | undefined;
1729
+ parent: ElementParent;
1730
+
1731
+ behaviour: Record<string, any>;
1732
+ sourceId: string;
1733
+ targetId: string;
1734
+ isDefault: boolean | undefined;
1735
+ isSequenceFlow: boolean;
1736
+ environment: Environment;
1737
+ logger: ILogger;
1738
+ broker: import("smqp").Broker;
1739
+ on: any;
1740
+ once: any;
1741
+ waitFor: any;
1742
+ emitFatal: any;
1743
+ get counters(): {
1744
+ take: number;
1745
+ discard: number;
1746
+ looped: number;
1747
+ };
1748
+ /**
1749
+ * Take the flow and publish flow.take.
1750
+ *
1751
+ */
1752
+ take(content?: Record<string, any>): boolean;
1753
+ /**
1754
+ * Discard the flow and publish flow.discard.
1755
+ *
1756
+ * @deprecated The execution runtime no longer discards sequence flows, so this is a no-op during a run. It will be removed in a future version.
1757
+ *
1758
+ */
1759
+ discard(content?: Record<string, any>): void;
1760
+ /**
1761
+ * Snapshot flow state. Returns undefined when the broker has no state and `disableTrackState`
1762
+ * is set.
1763
+ * */
1764
+ getState(): SequenceFlowState | undefined;
1765
+ /**
1766
+ * Restore flow state captured by getState.
1767
+ * */
1768
+ recover(state: SequenceFlowState): void;
1769
+ /**
1770
+ * Resolve a Flow Api wrapper.
1771
+ * */
1772
+ getApi(message?: ElementBrokerMessage): IApi<this>;
1773
+ /**
1774
+ * Stop the flow's broker.
1775
+ */
1776
+ stop(): void;
1777
+ /**
1778
+ * Walk the flow as part of a process shake. Detects loops and publishes flow.shake.loop
1779
+ * when the target was already visited, otherwise flow.shake.
1780
+ * */
1781
+ shake(message: ElementBrokerMessage): number | undefined;
1782
+ /**
1783
+ * Resolve the flow's condition (script or expression). Returns null when no condition is set.
1784
+ * Emits a fatal error when the script language is missing or unsupported.
1785
+ * */
1786
+ getCondition(): ICondition | null;
1787
+ /**
1788
+ * Build a flow event message body, optionally merging override content.
1789
+ * */
1790
+ createMessage(override?: Record<string, any>): ElementMessageContent;
1791
+ /**
1792
+ * Evaluate the flow's condition for the source activity message. Default flows are always taken.
1793
+ * @param fromMessage Source activity message
1794
+ * @param callback Callback with truthy result if flow should be taken
1795
+ */
1796
+ evaluate(fromMessage: ElementBrokerMessage, callback: (err: Error | null, result?: boolean | unknown) => void): void;
1797
+ }
1798
+ /**
1799
+ * Enriches an element run message via async format start/end messages on the `format` exchange
1800
+ * before the run message is continued. Handlers publish enrichment by responding to a start
1801
+ * message with a matching end (or error) routing key.
1802
+ * */
1803
+ class Formatter {
1804
+ /**
1805
+ * Enriches an element run message via async format start/end messages on the `format` exchange
1806
+ * before the run message is continued. Handlers publish enrichment by responding to a start
1807
+ * message with a matching end (or error) routing key.
1808
+ * */
1809
+ constructor(element: ElementBase);
1810
+ id: string;
1811
+ broker: import("smqp").Broker;
1812
+ logger: ILogger;
1813
+ /**
1814
+ * Format the given run message. Callback fires with `(err, content, formatted)` once
1815
+ * formatting completes; `formatted` is true when content was actually enriched.
1816
+ * */
1817
+ format(message: ElementBrokerMessage, callback: (err: Error | null, content?: ElementMessageContent, formatted?: boolean) => void): void;
1818
+ }
1819
+ /**
1820
+ * Association connecting a source and target activity. Used to drive compensation —
1821
+ * activities marked `isForCompensation` subscribe to inbound association events.
1822
+ * */
1823
+ export class Association {
1824
+ /**
1825
+ * Association connecting a source and target activity. Used to drive compensation —
1826
+ * activities marked `isForCompensation` subscribe to inbound association events.
1827
+ * */
1828
+ constructor(associationDef: import("moddle-context-serializer").Association, { environment }: ContextInstance);
1829
+ id: string | undefined;
1830
+ type: string;
1831
+ name: string | undefined;
1832
+ parent: ElementParent;
1833
+
1834
+ behaviour: Record<string, any>;
1835
+ sourceId: string;
1836
+ targetId: string;
1837
+ isAssociation: boolean;
1838
+ environment: Environment;
1839
+ logger: ILogger;
1840
+ broker: import("smqp").Broker;
1841
+ on: any;
1842
+ once: any;
1843
+ waitFor: any;
1844
+ get counters(): {
1845
+ take: number;
1846
+ discard: number;
1847
+ };
1848
+ /**
1849
+ * Take the association and publish association.take.
1850
+ *
1851
+ */
1852
+ take(content?: Record<string, any>): boolean;
1853
+ /**
1854
+ * Discard the association and publish association.discard.
1855
+ *
1856
+ */
1857
+ discard(content?: Record<string, any>): boolean;
1858
+ /**
1859
+ * Snapshot association state. Returns undefined when broker has no state and
1860
+ * `disableTrackState` is set.
1861
+ * */
1862
+ getState(): AssociationState | undefined;
1863
+ /**
1864
+ * Restore association state captured by getState.
1865
+ * */
1866
+ recover(state: AssociationState): void;
1867
+ /**
1868
+ * Resolve an association-scoped Api wrapper.
1869
+ * */
1870
+ getApi(message?: ElementBrokerMessage): IApi<this>;
1871
+ /**
1872
+ * Stop the association's broker.
1873
+ */
1874
+ stop(): void;
1875
+ }
1876
+ /**
1877
+ * Message flow connecting a source activity (or process) to a target. Subscribes to the
1878
+ * source's `end` event and publishes `message.outbound` whenever the source completes,
1879
+ * carrying any message payload through to the target.
1880
+ * */
1881
+ export class MessageFlow {
1882
+ /**
1883
+ * Message flow connecting a source activity (or process) to a target. Subscribes to the
1884
+ * source's `end` event and publishes `message.outbound` whenever the source completes,
1885
+ * carrying any message payload through to the target.
1886
+ * */
1887
+ constructor(flowDef: import("moddle-context-serializer").MessageFlow, context: ContextInstance);
1888
+ id: string | undefined;
1889
+ type: string;
1890
+ name: string | undefined;
1891
+ parent: ElementParent;
1892
+ source: import("moddle-context-serializer").MessageFlowEndpoint;
1893
+ target: import("moddle-context-serializer").MessageFlowEndpoint;
1894
+
1895
+ behaviour: Record<string, any>;
1896
+ environment: Environment;
1897
+ context: ContextInstance;
1898
+ broker: ElementBroker<MessageFlow>;
1899
+ on: (eventName: string, callback: CallableFunction, eventOptions?: {
1900
+ once?: boolean;
1901
+ [x: string]: any;
1902
+ }) => import("smqp").Consumer;
1903
+ once: (eventName: string, callback: CallableFunction, eventOptions?: {
1904
+ [x: string]: any;
1905
+ }) => import("smqp").Consumer;
1906
+ emit: (eventName: string, content?: Record<string, any>, props?: any) => void;
1907
+ waitFor: (eventName: string, onMessage?: ((routingKey: string, message: ElementBrokerMessage, owner: MessageFlow) => boolean) | undefined) => Promise<IApi<MessageFlow>>;
1908
+ logger: ILogger;
1909
+ get counters(): {
1910
+ messages: number;
1911
+ };
1912
+ /**
1913
+ * Snapshot message-flow state. Returns undefined when broker has no state and
1914
+ * `disableTrackState` is set.
1915
+ * */
1916
+ getState(): MessageFlowState | undefined;
1917
+ /**
1918
+ * Restore message-flow state captured by getState.
1919
+ * */
1920
+ recover(state: MessageFlowState): void;
1921
+ /**
1922
+ * Resolve a message-scoped Api wrapper.
1923
+ * */
1924
+ getApi(message?: ElementBrokerMessage): IApi<this>;
1925
+ /**
1926
+ * Subscribe to the source element's message and end events to bridge the message across.
1927
+ */
1928
+ activate(): void;
1929
+ /**
1930
+ * Cancel the source element subscriptions added by activate.
1931
+ */
1932
+ deactivate(): void;
1933
+ }
1934
+ /**
1935
+ * Boundary event
1936
+ * */
1937
+ export function BoundaryEvent(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
1938
+ /**
1939
+ * Boundary event behaviour
1940
+ * */
1941
+ export class BoundaryEventBehaviour {
1942
+ /**
1943
+ * Boundary event behaviour
1944
+ * */
1945
+ constructor(activity: Activity);
1946
+ id: string | undefined;
1947
+ type: string;
1948
+ attachedTo: Activity | null;
1949
+ activity: Activity;
1950
+ environment: Environment;
1951
+ broker: ElementBroker<Activity>;
1952
+ get executionId(): string | undefined;
1953
+ get cancelActivity(): any;
1954
+
1955
+ execute(executeMessage: ElementBrokerMessage): void;
1956
+ }
1957
+ /**
1958
+ * End event
1959
+ * */
1960
+ export function EndEvent(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
1961
+ /**
1962
+ * End event behaviour
1963
+ * */
1964
+ export class EndEventBehaviour {
1965
+ /**
1966
+ * End event behaviour
1967
+ * */
1968
+ constructor(activity: Activity);
1969
+ id: string | undefined;
1970
+ type: string;
1971
+ broker: ElementBroker<Activity>;
1972
+
1973
+ execute(executeMessage: ElementBrokerMessage): void;
1974
+ }
1975
+ /**
1976
+ * Intermediate catch event
1977
+ * */
1978
+ export function IntermediateCatchEvent(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
1979
+ /**
1980
+ * Intermediate catch event behaviour
1981
+ * */
1982
+ export class IntermediateCatchEventBehaviour {
1983
+ /**
1984
+ * Intermediate catch event behaviour
1985
+ * */
1986
+ constructor(activity: Activity);
1987
+ id: string | undefined;
1988
+ type: string;
1989
+ broker: ElementBroker<Activity>;
1990
+
1991
+ execute(executeMessage: ElementBrokerMessage): void;
1992
+ }
1993
+ /**
1994
+ * Intermediate throw event
1995
+ * */
1996
+ export function IntermediateThrowEvent(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
1997
+ /**
1998
+ * Intermediate throw event behaviour
1999
+ * */
2000
+ export class IntermediateThrowEventBehaviour {
2001
+ /**
2002
+ * Intermediate throw event behaviour
2003
+ * */
2004
+ constructor(activity: Activity);
2005
+ id: string | undefined;
2006
+ type: string;
2007
+ broker: ElementBroker<Activity>;
2008
+
2009
+ execute(executeMessage: ElementBrokerMessage): void;
2010
+ }
2011
+ /**
2012
+ * Start event
2013
+ * */
2014
+ export function StartEvent(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2015
+ /**
2016
+ * Start event behaviour
2017
+ * */
2018
+ export class StartEventBehaviour {
2019
+ /**
2020
+ * Start event behaviour
2021
+ * */
2022
+ constructor(activity: Activity);
2023
+ id: string | undefined;
2024
+ type: string;
2025
+ activity: Activity;
2026
+ broker: ElementBroker<Activity>;
2027
+ get executionId(): string | undefined;
2028
+
2029
+ execute(executeMessage: ElementBrokerMessage): void;
2030
+ }
2031
+ /**
2032
+ * Event based gateway
2033
+ * */
2034
+ export function EventBasedGateway(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2035
+ /**
2036
+ * Event based gateway behaviour
2037
+ * */
2038
+ export class EventBasedGatewayBehaviour {
2039
+ /**
2040
+ * Event based gateway behaviour
2041
+ * */
2042
+ constructor(activity: Activity, context: ContextInstance);
2043
+ id: string | undefined;
2044
+ type: string;
2045
+ activity: Activity;
2046
+ broker: ElementBroker<Activity>;
2047
+ context: ContextInstance;
2048
+
2049
+ execute(executeMessage: ElementBrokerMessage): void;
2050
+ }
2051
+ /**
2052
+ * Exclusive gateway
2053
+ * */
2054
+ export function ExclusiveGateway(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2055
+ /**
2056
+ * Exclusive gateway behaviour
2057
+ * */
2058
+ export class ExclusiveGatewayBehaviour {
2059
+ /**
2060
+ * Exclusive gateway behaviour
2061
+ * */
2062
+ constructor(activity: Activity);
2063
+ id: string | undefined;
2064
+ type: string;
2065
+ broker: ElementBroker<Activity>;
2066
+
2067
+ execute({ content }: ElementBrokerMessage): void;
2068
+ }
2069
+ /**
2070
+ * Inclusive gateway
2071
+ * */
2072
+ export function InclusiveGateway(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2073
+ /**
2074
+ * Inclusive gateway behaviour
2075
+ * */
2076
+ export class InclusiveGatewayBehaviour {
2077
+ /**
2078
+ * Inclusive gateway behaviour
2079
+ * */
2080
+ constructor(activity: Activity);
2081
+ id: string | undefined;
2082
+ type: string;
2083
+ broker: ElementBroker<Activity>;
2084
+
2085
+ execute({ content }: ElementBrokerMessage): void;
2086
+ }
2087
+ /**
2088
+ * Parallel gateway
2089
+ * */
2090
+ export class ParallelGateway {
2091
+ /**
2092
+ * Parallel gateway
2093
+ * */
2094
+ constructor(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance);
2095
+ id: string | undefined;
2096
+ }
2097
+ /**
2098
+ * Parallel gateway behaviour
2099
+ * */
2100
+ export class ParallelGatewayBehaviour {
2101
+ /**
2102
+ * Parallel gateway behaviour
2103
+ * */
2104
+ constructor(activity: Activity);
2105
+ id: string | undefined;
2106
+ type: string;
2107
+ activity: Activity;
2108
+ broker: ElementBroker<Activity>;
2109
+ inbound: Set<any>;
2110
+ isConverging: boolean;
2111
+ get executionId(): any;
2112
+
2113
+ execute(executeMessage: ElementBrokerMessage): void;
2114
+ setup(executeMessage: any): number | undefined;
2115
+ peerMonitor: PeerMonitor | undefined;
2116
+ }
2117
+ class PeerMonitor {
2118
+ constructor(activity: any, targets: any);
2119
+ activity: any;
2120
+ id: any;
2121
+ broker: any;
2122
+ running: Map<any, any>;
2123
+ index: number;
2124
+ discarded: number;
2125
+ watching: Map<any, any>;
2126
+ targets: any;
2127
+ touched: Set<any>;
2128
+ inbound: any[];
2129
+ get isRunning(): boolean;
2130
+ execute(executeMessage: any): number;
2131
+ monitor(peerActivity: any): void;
2132
+ stop(): void;
2133
+ }
2134
+ /**
2135
+ * Call activity
2136
+ * */
2137
+ export function CallActivity(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2138
+ /**
2139
+ * Call activity behaviour
2140
+ * */
2141
+ export class CallActivityBehaviour {
2142
+ /**
2143
+ * Call activity behaviour
2144
+ * */
2145
+ constructor(activity: Activity);
2146
+ id: string | undefined;
2147
+ type: string;
2148
+ calledElement: any;
2149
+
2150
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2151
+ activity: Activity;
2152
+ broker: ElementBroker<Activity>;
2153
+ environment: Environment;
2154
+
2155
+ execute(executeMessage: ElementBrokerMessage): void;
2156
+ }
2157
+ /**
2158
+ * Receive task
2159
+ * */
2160
+ export function ReceiveTask(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2161
+ /**
2162
+ * Receive task behaviour
2163
+ * */
2164
+ export class ReceiveTaskBehaviour {
2165
+ /**
2166
+ * Receive task behaviour
2167
+ * */
2168
+ constructor(activity: Activity);
2169
+ id: string | undefined;
2170
+ type: string;
2171
+
2172
+ reference: EventReference;
2173
+
2174
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2175
+ activity: Activity;
2176
+ broker: ElementBroker<Activity>;
2177
+
2178
+ execute(executeMessage: ElementBrokerMessage): void;
2179
+ }
2180
+ /**
2181
+ * Script task
2182
+ * */
2183
+ export function ScriptTask(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2184
+ /**
2185
+ * Script task behaviour
2186
+ * */
2187
+ export class ScriptTaskBehaviour {
2188
+ /**
2189
+ * Script task behaviour
2190
+ * */
2191
+ constructor(activity: Activity);
2192
+ id: string | undefined;
2193
+ type: string;
2194
+ scriptFormat: string | undefined;
2195
+
2196
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2197
+ activity: Activity;
2198
+ environment: Environment;
2199
+
2200
+ execute(executeMessage: ElementBrokerMessage): void;
2201
+ }
2202
+ /**
2203
+ * Service task
2204
+ * */
2205
+ export function ServiceTask(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2206
+ /**
2207
+ * Service task behaviour
2208
+ * */
2209
+ export class ServiceTaskBehaviour {
2210
+ /**
2211
+ * Service task behaviour
2212
+ * */
2213
+ constructor(activity: Activity);
2214
+ id: string | undefined;
2215
+ type: string;
2216
+
2217
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2218
+ activity: Activity;
2219
+ environment: Environment;
2220
+ broker: ElementBroker<Activity>;
2221
+
2222
+ execute(executeMessage: ElementBrokerMessage): void;
2223
+ service: any;
2224
+ getService(message: any): any;
2225
+ }
2226
+ /**
2227
+ * Signal task
2228
+ * */
2229
+ export function SignalTask(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2230
+ /**
2231
+ * Signal task behaviour
2232
+ * */
2233
+ export class SignalTaskBehaviour {
2234
+ /**
2235
+ * Signal task behaviour
2236
+ * */
2237
+ constructor(activity: Activity);
2238
+ id: string | undefined;
2239
+ type: string;
2240
+
2241
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2242
+ activity: Activity;
2243
+ broker: ElementBroker<Activity>;
2244
+
2245
+ execute(executeMessage: ElementBrokerMessage): void;
2246
+ }
2247
+ /**
2248
+ * Sub process
2249
+ * */
2250
+ export function SubProcess(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2251
+ /**
2252
+ * Sub process behaviour
2253
+ * */
2254
+ export class SubProcessBehaviour {
2255
+ /**
2256
+ * Sub process behaviour
2257
+ * */
2258
+ constructor(activity: Activity, context: ContextInstance);
2259
+ id: string | undefined;
2260
+ type: string;
2261
+
2262
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2263
+ activity: Activity;
2264
+ context: ContextInstance;
2265
+ environment: Environment;
2266
+ broker: ElementBroker<Activity>;
2267
+ executionId: string | undefined;
2268
+ get execution(): any;
2269
+ get executions(): any[];
2270
+
2271
+ execute(executeMessage: ElementBrokerMessage): void;
2272
+ getState(): any;
2273
+ recover(state: any): this | undefined;
2274
+ getPostponed(): any[];
2275
+ getApi(apiMessage: any): any;
2276
+ }
2277
+ /**
2278
+ * Task
2279
+ * */
2280
+ export function Task(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2281
+ /**
2282
+ * Task behaviour
2283
+ * */
2284
+ export class TaskBehaviour {
2285
+ /**
2286
+ * Task behaviour
2287
+ * */
2288
+ constructor(activity: Activity);
2289
+ id: string | undefined;
2290
+ type: string;
2291
+
2292
+ loopCharacteristics: MultiInstanceLoopCharacteristics | undefined;
2293
+ broker: ElementBroker<Activity>;
2294
+
2295
+ execute(executeMessage: ElementBrokerMessage): void;
2296
+ }
2297
+ /**
2298
+ * Transaction
2299
+ * */
2300
+ export function Transaction(activityDef: import("moddle-context-serializer").Activity, context: ContextInstance): Activity;
2301
+ /**
2302
+ * Cancel event definition
2303
+ * */
2304
+ export class CancelEventDefinition {
2305
+ /**
2306
+ * Cancel event definition
2307
+ * */
2308
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2309
+ id: string | undefined;
2310
+ type: string | undefined;
2311
+
2312
+ reference: EventReference;
2313
+ isThrowing: boolean;
2314
+ activity: Activity;
2315
+ environment: Environment;
2316
+ broker: ElementBroker<Activity>;
2317
+ logger: ILogger;
2318
+ get executionId(): string;
2319
+
2320
+ execute(executeMessage: ElementBrokerMessage): void;
2321
+
2322
+ executeCatch(executeMessage: ElementBrokerMessage): void;
2323
+
2324
+ executeThrow(executeMessage: ElementBrokerMessage): void;
2325
+ }
2326
+ /**
2327
+ * Compensate event definition
2328
+ * */
2329
+ export class CompensateEventDefinition {
2330
+ /**
2331
+ * Compensate event definition
2332
+ * */
2333
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition, context: ContextInstance);
2334
+ id: string | undefined;
2335
+ type: string | undefined;
2336
+
2337
+ reference: EventReference;
2338
+ isThrowing: boolean;
2339
+ activity: Activity;
2340
+ broker: ElementBroker<Activity>;
2341
+ logger: ILogger;
2342
+ get executionId(): string;
2343
+
2344
+ execute(executeMessage: ElementBrokerMessage): number | import("smqp").Consumer | undefined;
2345
+
2346
+ executeCatch(executeMessage: ElementBrokerMessage): import("smqp").Consumer | undefined;
2347
+
2348
+ executeThrow(executeMessage: ElementBrokerMessage): number | undefined;
2349
+ }
2350
+ /**
2351
+ * Conditional event definition
2352
+ * @param index event definition index
2353
+ */
2354
+ export class ConditionalEventDefinition {
2355
+ /**
2356
+ * Conditional event definition
2357
+ * @param index event definition index
2358
+ */
2359
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition, _context: ContextInstance, index: number);
2360
+ id: string | undefined;
2361
+ type: string;
2362
+ behaviour: {};
2363
+ activity: Activity;
2364
+ environment: Environment;
2365
+ broker: ElementBroker<Activity>;
2366
+ logger: ILogger;
2367
+ condition: ICondition | null;
2368
+ get executionId(): string;
2369
+
2370
+ execute(executeMessage: ElementBrokerMessage): void;
2371
+ /**
2372
+ * Evaluate condition
2373
+ * */
2374
+ evaluate(message: ElementBrokerMessage, callback: CallableFunction): any;
2375
+ /**
2376
+ * Handle evaluate result or error
2377
+ * @param err Condition evaluation error
2378
+ * @param result Result from evaluated condition, completes execution if truthy
2379
+ */
2380
+ evaluateCallback(err: Error | null, result: any): number | undefined;
2381
+ /**
2382
+ * Get condition
2383
+ * @param index Eventdefinition sequence number, used to name registered script
2384
+ * */
2385
+ getCondition(index: number): ICondition | null;
2386
+ }
2387
+ /**
2388
+ * Error event definition
2389
+ * */
2390
+ export class ErrorEventDefinition {
2391
+ /**
2392
+ * Error event definition
2393
+ * */
2394
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2395
+ id: string | undefined;
2396
+ type: string;
2397
+
2398
+ reference: EventReference;
2399
+ isThrowing: boolean;
2400
+ activity: Activity;
2401
+ environment: Environment;
2402
+ broker: ElementBroker<Activity>;
2403
+ logger: ILogger;
2404
+ get executionId(): string;
2405
+
2406
+ execute(executeMessage: ElementBrokerMessage): number | void;
2407
+
2408
+ executeCatch(executeMessage: ElementBrokerMessage): void;
2409
+
2410
+ executeThrow(executeMessage: ElementBrokerMessage): number | undefined;
2411
+ }
2412
+ /**
2413
+ * Escalation event definition
2414
+ * */
2415
+ export class EscalationEventDefinition {
2416
+ /**
2417
+ * Escalation event definition
2418
+ * */
2419
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2420
+ id: string | undefined;
2421
+ type: string | undefined;
2422
+
2423
+ reference: EventReference;
2424
+ isThrowing: boolean;
2425
+ activity: Activity;
2426
+ broker: ElementBroker<Activity>;
2427
+ logger: ILogger;
2428
+ get executionId(): string;
2429
+
2430
+ execute(executeMessage: ElementBrokerMessage): number | void;
2431
+
2432
+ executeCatch(executeMessage: ElementBrokerMessage): void;
2433
+
2434
+ executeThrow(executeMessage: ElementBrokerMessage): number | undefined;
2435
+ }
2436
+ /**
2437
+ * Link event definition
2438
+ * */
2439
+ export class LinkEventDefinition {
2440
+ /**
2441
+ * Link event definition
2442
+ * */
2443
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2444
+ id: string | undefined;
2445
+ type: string;
2446
+
2447
+ reference: EventReference;
2448
+ isThrowing: boolean;
2449
+ activity: Activity;
2450
+ broker: ElementBroker<Activity>;
2451
+ logger: ILogger;
2452
+ get executionId(): string;
2453
+
2454
+ execute(executeMessage: ElementBrokerMessage): number | undefined;
2455
+
2456
+ executeCatch(executeMessage: ElementBrokerMessage): number | undefined;
2457
+
2458
+ executeThrow(executeMessage: ElementBrokerMessage): number | undefined;
2459
+ }
2460
+ /**
2461
+ * Message event definition
2462
+ * */
2463
+ export class MessageEventDefinition {
2464
+ /**
2465
+ * Message event definition
2466
+ * */
2467
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2468
+ id: string | undefined;
2469
+ type: string;
2470
+
2471
+ reference: EventReference;
2472
+ isThrowing: boolean;
2473
+ activity: Activity;
2474
+ broker: ElementBroker<Activity>;
2475
+ logger: ILogger;
2476
+ get executionId(): string;
2477
+
2478
+ execute(executeMessage: ElementBrokerMessage): number | void;
2479
+
2480
+ executeCatch(executeMessage: ElementBrokerMessage): void;
2481
+
2482
+ executeThrow(executeMessage: ElementBrokerMessage): number | undefined;
2483
+ }
2484
+ /**
2485
+ * Signal event definition
2486
+ * */
2487
+ export class SignalEventDefinition {
2488
+ /**
2489
+ * Signal event definition
2490
+ * */
2491
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2492
+ id: string | undefined;
2493
+ type: string | undefined;
2494
+
2495
+ reference: EventReference;
2496
+ isThrowing: boolean;
2497
+ activity: Activity;
2498
+ broker: ElementBroker<Activity>;
2499
+ logger: ILogger;
2500
+ get executionId(): string;
2501
+
2502
+ execute(executeMessage: ElementBrokerMessage): number | void;
2503
+
2504
+ executeCatch(executeMessage: ElementBrokerMessage): void;
2505
+
2506
+ executeThrow(executeMessage: ElementBrokerMessage): number | undefined;
2507
+ }
2508
+ /**
2509
+ * Terminate event definition
2510
+ * */
2511
+ export class TerminateEventDefinition {
2512
+ /**
2513
+ * Terminate event definition
2514
+ * */
2515
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2516
+ id: string | undefined;
2517
+ type: string;
2518
+ activity: Activity;
2519
+ broker: ElementBroker<Activity>;
2520
+ logger: ILogger;
2521
+
2522
+ execute(executeMessage: ElementBrokerMessage): void;
2523
+ }
2524
+ /**
2525
+ * Timer event definition
2526
+ * */
2527
+ export class TimerEventDefinition {
2528
+ /**
2529
+ * Timer event definition
2530
+ * */
2531
+ constructor(activity: Activity, eventDefinition: import("moddle-context-serializer").EventDefinition);
2532
+ type: string;
2533
+ activity: Activity;
2534
+ environment: Environment;
2535
+ eventDefinition: import("moddle-context-serializer").EventDefinition;
2536
+ timeDuration: string | undefined;
2537
+ timeCycle: string | undefined;
2538
+ timeDate: string | undefined;
2539
+ broker: ElementBroker<Activity>;
2540
+ logger: ILogger;
2541
+ get executionId(): string;
2542
+ get stopped(): boolean;
2543
+ get timer(): Timer | null;
2544
+
2545
+ execute(executeMessage: ElementBrokerMessage): void;
2546
+ startedAt: Date | undefined;
2547
+ stop(): void;
2548
+ /**
2549
+ * Parse timer
2550
+ * */
2551
+ parse(timerType: TimerType, value: string): parsedTimer;
2552
+ }
2553
+ /**
2554
+ * Event definition execution orchestrator. Drives a sequence of event definitions for the
2555
+ * activity and publishes the completed routing key when the last definition completes.
2556
+ * @param completedRoutingKey Routing key to publish on completion, defaults to `execute.completed`
2557
+ */
2558
+ class EventDefinitionExecution {
2559
+ /**
2560
+ * Event definition execution orchestrator. Drives a sequence of event definitions for the
2561
+ * activity and publishes the completed routing key when the last definition completes.
2562
+ * @param completedRoutingKey Routing key to publish on completion, defaults to `execute.completed`
2563
+ */
2564
+ constructor(activity: Activity, eventDefinitions: EventDefinition[], completedRoutingKey?: string);
2565
+ id: string | undefined;
2566
+ activity: Activity;
2567
+ broker: ElementBroker<Activity>;
2568
+ eventDefinitions: EventDefinition[];
2569
+ completedRoutingKey: string;
2570
+ get completed(): boolean;
2571
+ get stopped(): boolean;
2572
+
2573
+ execute(executeMessage: ElementBrokerMessage): void;
2574
+ }
2575
+
2576
+ export { Consumer, MessageFields, MessageProperties, SerializableContext, SerializableElement };
2577
+ export const BusinessRuleTask: typeof ServiceTask;
2578
+ export const SendTask: typeof ServiceTask;
2579
+ export const ManualTask: typeof SignalTask;
2580
+ export const UserTask: typeof SignalTask;
2581
+ export const AdHocSubProcess: typeof SubProcess;
55
2582
  }
56
2583
 
2584
+ declare module 'bpmn-elements/errors' {
2585
+ import type { MessageEnvelope } from 'smqp';
2586
+ import type { ElementBrokerMessage, ElementMessageContent, ElementParent } from 'bpmn-elements';
2587
+ import { ActivityError, RunError } from 'bpmn-elements';
2588
+ export { ActivityError, RunError };
2589
+
2590
+ /**
2591
+ * Get an Error from an error message.
2592
+ * */
2593
+ export function makeErrorFromMessage(errorMessage: ElementBrokerMessage): Error | ActivityError | RunError | BpmnError;
2594
+ export class BpmnError extends Error {
2595
+
2596
+ constructor(description: string, behaviour?: {
2597
+ id?: string;
2598
+ name?: string;
2599
+ errorCode?: string | number;
2600
+ code?: string;
2601
+ }, sourceMessage?: ElementBrokerMessage);
2602
+
2603
+ type: string;
2604
+
2605
+ description: string;
2606
+
2607
+ code: string | undefined;
2608
+
2609
+ id: string | undefined;
2610
+
2611
+ source: Pick<ElementBrokerMessage, "fields" | "content" | "properties"> | undefined;
2612
+ }
2613
+
2614
+ export {};
2615
+ }
2616
+
2617
+
57
2618
  declare module 'bpmn-elements/events' {
58
- export var BoundaryEventBehaviour: IActivityBehaviour;
59
- export var EndEventBehaviour: IActivityBehaviour;
60
- export var IntermediateCatchEventBehaviour: IActivityBehaviour;
61
- export var IntermediateThrowEventBehaviour: IActivityBehaviour;
62
- export var StartEventBehaviour: IActivityBehaviour;
2619
+ export { BoundaryEvent, BoundaryEventBehaviour, EndEvent, EndEventBehaviour, IntermediateCatchEvent, IntermediateCatchEventBehaviour, IntermediateThrowEvent, IntermediateThrowEventBehaviour, StartEvent, StartEventBehaviour } from 'bpmn-elements';
63
2620
  }
64
2621
 
65
2622
  declare module 'bpmn-elements/eventDefinitions' {
66
- export var CancelEventDefinition: EventDefinition;
67
- export var CompensateEventDefinition: EventDefinition;
68
- export var ConditionalEventDefinition: ConditionalEventDefinition;
69
- export var ErrorEventDefinition: EventDefinition;
70
- export var EscalationEventDefinition: EventDefinition;
71
- export var LinkEventDefinition: EventDefinition;
72
- export var MessageEventDefinition: EventDefinition;
73
- export var SignalEventDefinition: EventDefinition;
74
- export var TerminateEventDefinition: EventDefinition;
75
- export var TimerEventDefinition: TimerEventDefinition;
2623
+ export { CancelEventDefinition, CompensateEventDefinition, ConditionalEventDefinition, ErrorEventDefinition, EscalationEventDefinition, LinkEventDefinition, MessageEventDefinition, SignalEventDefinition, TerminateEventDefinition, TimerEventDefinition } from 'bpmn-elements';
76
2624
  }
77
2625
 
78
2626
  declare module 'bpmn-elements/flows' {
79
- export var Association: Association;
80
- export var SequenceFlow: SequenceFlow;
81
- export var MessageFlow: MessageFlow;
2627
+ export { Association, MessageFlow, SequenceFlow } from 'bpmn-elements';
82
2628
  }
83
2629
 
84
2630
  declare module 'bpmn-elements/gateways' {
85
- export var EventBasedGatewayBehaviour: IActivityBehaviour;
86
- export var ExclusiveGatewayBehaviour: IActivityBehaviour;
87
- export var InclusiveGatewayBehaviour: IActivityBehaviour;
88
- export var ParallelGatewayBehaviour: IActivityBehaviour;
2631
+ export { EventBasedGateway, EventBasedGatewayBehaviour, ExclusiveGateway, ExclusiveGatewayBehaviour, InclusiveGateway, InclusiveGatewayBehaviour, ParallelGateway, ParallelGatewayBehaviour } from 'bpmn-elements';
89
2632
  }
90
2633
 
91
2634
  declare module 'bpmn-elements/tasks' {
92
- export var CallActivityBehaviour: IActivityBehaviour;
93
- export var ReceiveTaskBehaviour: IActivityBehaviour;
94
- export var ScriptTaskBehaviour: IActivityBehaviour;
95
- export var ServiceTaskBehaviour: IActivityBehaviour;
96
- /** Signal-, Manual-, and User-task behaviour */
97
- export var SignalTaskBehaviour: IActivityBehaviour;
98
- /** Sub process and Transaction behaviour */
99
- export var SubProcessBehaviour: IActivityBehaviour;
100
- export var TaskBehaviour: IActivityBehaviour;
2635
+ export { CallActivity, CallActivityBehaviour, ReceiveTask, ReceiveTaskBehaviour, ScriptTask, ScriptTaskBehaviour, ServiceTask, ServiceTaskBehaviour, SignalTask, SignalTaskBehaviour, SubProcess, SubProcessBehaviour, Task, TaskBehaviour, Transaction } from 'bpmn-elements';
101
2636
  }