bpmn-elements 17.2.2 → 18.0.0

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