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
@@ -3,17 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.SubProcess = SubProcess;
6
7
  exports.SubProcessBehaviour = SubProcessBehaviour;
7
- exports.default = SubProcess;
8
- var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
9
- var _ProcessExecution = _interopRequireDefault(require("../process/ProcessExecution.js"));
8
+ var _Activity = require("../activity/Activity.js");
9
+ var _ProcessExecution = require("../process/ProcessExecution.js");
10
10
  var _messageHelper = require("../messageHelper.js");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const kExecutions = Symbol.for('executions');
13
- const kOnExecutionCompleted = Symbol.for('execution completed handler');
11
+ const K_EXECUTIONS = Symbol.for('executions');
12
+ const K_ON_EXECUTION_COMPLETED = Symbol.for('execution completed handler');
13
+
14
+ /**
15
+ * Sub process
16
+ * @param {import('moddle-context-serializer').Activity} activityDef
17
+ * @param {import('#types').ContextInstance} context
18
+ */
14
19
  function SubProcess(activityDef, context) {
15
20
  const triggeredByEvent = activityDef.behaviour && activityDef.behaviour.triggeredByEvent;
16
- const subProcess = new _Activity.default(SubProcessBehaviour, {
21
+ const subProcess = new _Activity.Activity(SubProcessBehaviour, {
17
22
  ...activityDef,
18
23
  isSubProcess: true,
19
24
  triggeredByEvent
@@ -32,7 +37,7 @@ function SubProcess(activityDef, context) {
32
37
  startId
33
38
  } = message.content;
34
39
  const last = message.content.sequence.pop();
35
- const sequence = new _ProcessExecution.default(subProcess, context).shake(startId);
40
+ const sequence = new _ProcessExecution.ProcessExecution(subProcess, context).shake(startId);
36
41
  message.content.sequence.push({
37
42
  ...last,
38
43
  isSubProcess: true,
@@ -40,6 +45,12 @@ function SubProcess(activityDef, context) {
40
45
  });
41
46
  }
42
47
  }
48
+
49
+ /**
50
+ * Sub process behaviour
51
+ * @param {import('#types').Activity} activity
52
+ * @param {import('#types').ContextInstance} context
53
+ */
43
54
  function SubProcessBehaviour(activity, context) {
44
55
  const {
45
56
  id,
@@ -48,27 +59,31 @@ function SubProcessBehaviour(activity, context) {
48
59
  } = activity;
49
60
  this.id = id;
50
61
  this.type = type;
62
+ /** @type {import('./LoopCharacteristics.js').LoopCharacteristics | undefined} */
51
63
  this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
52
64
  this.activity = activity;
53
65
  this.context = context;
54
66
  this.environment = activity.environment;
55
67
  this.broker = activity.broker;
56
68
  this.executionId = undefined;
57
- this[kExecutions] = new Set();
58
- this[kOnExecutionCompleted] = this._onExecutionCompleted.bind(this);
69
+ this[K_EXECUTIONS] = new Set();
70
+ this[K_ON_EXECUTION_COMPLETED] = this._onExecutionCompleted.bind(this);
59
71
  }
60
- Object.defineProperties(SubProcessBehaviour.prototype, {
61
- execution: {
62
- get() {
63
- return [...this[kExecutions]][0];
64
- }
65
- },
66
- executions: {
67
- get() {
68
- return [...this[kExecutions]];
69
- }
72
+ Object.defineProperty(SubProcessBehaviour.prototype, 'execution', {
73
+ get() {
74
+ return [...this[K_EXECUTIONS]][0];
70
75
  }
71
76
  });
77
+ Object.defineProperty(SubProcessBehaviour.prototype, 'executions', {
78
+ get() {
79
+ return [...this[K_EXECUTIONS]];
80
+ }
81
+ });
82
+
83
+ /**
84
+ * @param {import('#types').ElementBrokerMessage} executeMessage
85
+ * @returns {void}
86
+ */
72
87
  SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
73
88
  const {
74
89
  isRootScope,
@@ -86,7 +101,7 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
86
101
  };
87
102
  SubProcessBehaviour.prototype.getState = function getState() {
88
103
  const states = [];
89
- for (const pe of this[kExecutions]) {
104
+ for (const pe of this[K_EXECUTIONS]) {
90
105
  const state = pe.getState();
91
106
  state.environment = pe.environment.getState();
92
107
  states.push(state);
@@ -100,7 +115,7 @@ SubProcessBehaviour.prototype.getState = function getState() {
100
115
  };
101
116
  SubProcessBehaviour.prototype.recover = function recover(state) {
102
117
  if (!state) return;
103
- const executions = this[kExecutions];
118
+ const executions = this[K_EXECUTIONS];
104
119
  const loopCharacteristics = this.loopCharacteristics;
105
120
  if (loopCharacteristics && state.executions) {
106
121
  executions.clear();
@@ -114,13 +129,13 @@ SubProcessBehaviour.prototype.recover = function recover(state) {
114
129
  }
115
130
  const subEnvironment = this.environment.clone().recover(state.environment);
116
131
  const subContext = this.context.clone(subEnvironment, this.activity);
117
- const execution = new _ProcessExecution.default(this.activity, subContext).recover(state);
132
+ const execution = new _ProcessExecution.ProcessExecution(this.activity, subContext).recover(state);
118
133
  executions.add(execution);
119
134
  return execution;
120
135
  };
121
136
  SubProcessBehaviour.prototype.getPostponed = function getPostponed() {
122
137
  let postponed = [];
123
- for (const pe of this[kExecutions]) {
138
+ for (const pe of this[K_EXECUTIONS]) {
124
139
  postponed = postponed.concat(pe.getPostponed());
125
140
  }
126
141
  return postponed;
@@ -135,13 +150,13 @@ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(execut
135
150
  }
136
151
  const subEnvironment = this.environment.clone();
137
152
  const subContext = this.context.clone(subEnvironment, this.activity);
138
- execution = new _ProcessExecution.default(this.activity, subContext);
139
- this[kExecutions].add(execution);
153
+ execution = new _ProcessExecution.ProcessExecution(this.activity, subContext);
154
+ this[K_EXECUTIONS].add(execution);
140
155
  this._addListeners(executionId);
141
156
  return execution;
142
157
  };
143
158
  SubProcessBehaviour.prototype._addListeners = function addListeners(executionId) {
144
- this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[kOnExecutionCompleted], {
159
+ this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[K_ON_EXECUTION_COMPLETED], {
145
160
  noAck: true,
146
161
  consumerTag: `_sub-process-execution-${executionId}`
147
162
  });
@@ -177,7 +192,7 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
177
192
  SubProcessBehaviour.prototype._completeExecution = function completeExecution(completeRoutingKey, content) {
178
193
  if (this.loopCharacteristics) {
179
194
  const execution = this._getExecutionById(content.executionId);
180
- this[kExecutions].delete(execution);
195
+ this[K_EXECUTIONS].delete(execution);
181
196
  }
182
197
  this.broker.publish('execution', completeRoutingKey, (0, _messageHelper.cloneContent)(content));
183
198
  };
@@ -194,7 +209,7 @@ SubProcessBehaviour.prototype.getApi = function getApi(apiMessage) {
194
209
  }
195
210
  };
196
211
  SubProcessBehaviour.prototype._getExecutionById = function getExecutionById(executionId) {
197
- for (const pe of this[kExecutions]) {
212
+ for (const pe of this[K_EXECUTIONS]) {
198
213
  if (pe.executionId === executionId) return pe;
199
214
  }
200
215
  };
@@ -3,14 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.Task = Task;
6
7
  exports.TaskBehaviour = TaskBehaviour;
7
- exports.default = Task;
8
- var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
8
+ var _Activity = require("../activity/Activity.js");
9
9
  var _messageHelper = require("../messageHelper.js");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Task
12
+ * @param {import('moddle-context-serializer').Activity} activityDef
13
+ * @param {import('#types').ContextInstance} context
14
+ */
11
15
  function Task(activityDef, context) {
12
- return new _Activity.default(TaskBehaviour, activityDef, context);
16
+ return new _Activity.Activity(TaskBehaviour, activityDef, context);
13
17
  }
18
+
19
+ /**
20
+ * Task behaviour
21
+ * @param {import('#types').Activity} activity
22
+ */
14
23
  function TaskBehaviour(activity) {
15
24
  const {
16
25
  id,
@@ -20,9 +29,15 @@ function TaskBehaviour(activity) {
20
29
  } = activity;
21
30
  this.id = id;
22
31
  this.type = type;
32
+ /** @type {import('./LoopCharacteristics.js').LoopCharacteristics | undefined} */
23
33
  this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
24
34
  this.broker = broker;
25
35
  }
36
+
37
+ /**
38
+ * @param {import('#types').ElementBrokerMessage} executeMessage
39
+ * @returns {void}
40
+ */
26
41
  TaskBehaviour.prototype.execute = function execute(executeMessage) {
27
42
  const executeContent = executeMessage.content;
28
43
  const loopCharacteristics = this.loopCharacteristics;
@@ -3,15 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Transaction;
7
- var _SubProcess = _interopRequireDefault(require("./SubProcess.js"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
+ exports.Transaction = Transaction;
7
+ var _SubProcess = require("./SubProcess.js");
8
+ /**
9
+ * Transaction
10
+ * @param {import('moddle-context-serializer').Activity} activityDef
11
+ * @param {import('#types').ContextInstance} context
12
+ */
9
13
  function Transaction(activityDef, context) {
10
14
  const transaction = {
11
15
  type: 'transaction',
12
16
  ...activityDef,
13
17
  isTransaction: true
14
18
  };
15
- const activity = (0, _SubProcess.default)(transaction, context);
19
+ const activity = (0, _SubProcess.SubProcess)(transaction, context);
16
20
  return activity;
17
21
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "CallActivity", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _CallActivity.default;
9
+ return _CallActivity.CallActivity;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "CallActivityBehaviour", {
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "CallActivityBehaviour", {
18
18
  Object.defineProperty(exports, "ReceiveTask", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _ReceiveTask.default;
21
+ return _ReceiveTask.ReceiveTask;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "ReceiveTaskBehaviour", {
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "ReceiveTaskBehaviour", {
30
30
  Object.defineProperty(exports, "ScriptTask", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _ScriptTask.default;
33
+ return _ScriptTask.ScriptTask;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "ScriptTaskBehaviour", {
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "ScriptTaskBehaviour", {
42
42
  Object.defineProperty(exports, "ServiceTask", {
43
43
  enumerable: true,
44
44
  get: function () {
45
- return _ServiceTask.default;
45
+ return _ServiceTask.ServiceTask;
46
46
  }
47
47
  });
48
48
  Object.defineProperty(exports, "ServiceTaskBehaviour", {
@@ -54,7 +54,7 @@ Object.defineProperty(exports, "ServiceTaskBehaviour", {
54
54
  Object.defineProperty(exports, "SignalTask", {
55
55
  enumerable: true,
56
56
  get: function () {
57
- return _SignalTask.default;
57
+ return _SignalTask.SignalTask;
58
58
  }
59
59
  });
60
60
  Object.defineProperty(exports, "SignalTaskBehaviour", {
@@ -66,7 +66,7 @@ Object.defineProperty(exports, "SignalTaskBehaviour", {
66
66
  Object.defineProperty(exports, "SubProcess", {
67
67
  enumerable: true,
68
68
  get: function () {
69
- return _SubProcess.default;
69
+ return _SubProcess.SubProcess;
70
70
  }
71
71
  });
72
72
  Object.defineProperty(exports, "SubProcessBehaviour", {
@@ -78,7 +78,7 @@ Object.defineProperty(exports, "SubProcessBehaviour", {
78
78
  Object.defineProperty(exports, "Task", {
79
79
  enumerable: true,
80
80
  get: function () {
81
- return _Task.default;
81
+ return _Task.Task;
82
82
  }
83
83
  });
84
84
  Object.defineProperty(exports, "TaskBehaviour", {
@@ -90,16 +90,14 @@ Object.defineProperty(exports, "TaskBehaviour", {
90
90
  Object.defineProperty(exports, "Transaction", {
91
91
  enumerable: true,
92
92
  get: function () {
93
- return _Transaction.default;
93
+ return _Transaction.Transaction;
94
94
  }
95
95
  });
96
- var _CallActivity = _interopRequireWildcard(require("./CallActivity.js"));
97
- var _ReceiveTask = _interopRequireWildcard(require("./ReceiveTask.js"));
98
- var _ScriptTask = _interopRequireWildcard(require("./ScriptTask.js"));
99
- var _ServiceTask = _interopRequireWildcard(require("./ServiceTask.js"));
100
- var _SignalTask = _interopRequireWildcard(require("./SignalTask.js"));
101
- var _SubProcess = _interopRequireWildcard(require("./SubProcess.js"));
102
- var _Task = _interopRequireWildcard(require("./Task.js"));
103
- var _Transaction = _interopRequireDefault(require("./Transaction.js"));
104
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
105
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
96
+ var _CallActivity = require("./CallActivity.js");
97
+ var _ReceiveTask = require("./ReceiveTask.js");
98
+ var _ScriptTask = require("./ScriptTask.js");
99
+ var _ServiceTask = require("./ServiceTask.js");
100
+ var _SignalTask = require("./SignalTask.js");
101
+ var _SubProcess = require("./SubProcess.js");
102
+ var _Task = require("./Task.js");
103
+ var _Transaction = require("./Transaction.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "17.2.2",
3
+ "version": "18.0.0",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,11 @@
13
13
  "require": "./dist/index.js",
14
14
  "import": "./src/index.js"
15
15
  },
16
+ "./errors": {
17
+ "types": "./types/index.d.ts",
18
+ "require": "./dist/error/Errors.js",
19
+ "import": "./src/error/Errors.js"
20
+ },
16
21
  "./events": {
17
22
  "types": "./types/index.d.ts",
18
23
  "require": "./dist/events/index.js",
@@ -43,12 +48,14 @@
43
48
  "scripts": {
44
49
  "test": "mocha -R @bonniernews/hot-bev -p -t 3000",
45
50
  "posttest": "npm run lint && npm run dist",
46
- "lint": "eslint . --cache && prettier . --check --cache",
51
+ "lint": "eslint . --cache && prettier . --check --cache && npm run typecheck",
52
+ "typecheck": "tsc --noEmit",
47
53
  "prepack": "npm run dist",
48
54
  "test:md": "texample ./docs/Examples.md,./docs/StartEvent.md,./docs/Extension.md,./docs/ConditionalEventDefinition.md",
49
55
  "cov:html": "c8 -r html -r text mocha -R @bonniernews/hot-bev -p -t 3000",
50
56
  "test:lcov": "c8 -r lcov mocha && npm run lint",
51
- "dist": "babel src -d dist/"
57
+ "dist": "babel src -d dist/ && npm run build:types",
58
+ "build:types": "node scripts/build-types.js"
52
59
  },
53
60
  "repository": {
54
61
  "type": "git",
@@ -78,6 +85,14 @@
78
85
  "src/**/*"
79
86
  ]
80
87
  },
88
+ "overrides": {
89
+ "c8": {
90
+ "yargs": "^18.0.0"
91
+ },
92
+ "mocha": {
93
+ "yargs": "^18.0.0"
94
+ }
95
+ },
81
96
  "devDependencies": {
82
97
  "@aircall/expression-parser": "^1.0.4",
83
98
  "@babel/cli": "^7.24.1",
@@ -85,24 +100,27 @@
85
100
  "@babel/preset-env": "^7.24.4",
86
101
  "@babel/register": "^7.23.7",
87
102
  "@bonniernews/hot-bev": "^0.4.0",
88
- "@types/node": "^18.19.63",
89
- "bpmn-moddle": "^9.0.1",
90
- "c8": "^10.1.1",
103
+ "@eslint/js": "^10.0.1",
104
+ "@types/bpmn-moddle": "^10.0.0",
105
+ "@types/node": "^20.19.40",
106
+ "bpmn-moddle": "^10.0.0",
107
+ "c8": "^11.0.0",
91
108
  "camunda-bpmn-moddle": "^7.0.1",
92
109
  "chai": "^6.2.1",
93
- "chronokinesis": "^7.0.0",
110
+ "chronokinesis": "^8.0.0",
94
111
  "debug": "^4.3.4",
95
- "eslint": "^9.0.0",
96
- "globals": "^16.0.0",
112
+ "dts-buddy": "^0.8.0",
113
+ "eslint": "^10.3.0",
114
+ "globals": "^17.0.0",
97
115
  "mocha": "^11.0.1",
98
116
  "mocha-cakes-2": "^3.3.0",
99
- "moddle-context-serializer": "^4.2.1",
117
+ "moddle-context-serializer": "^6.0.0",
100
118
  "nock": "^14.0.0",
101
119
  "prettier": "^3.2.5",
102
- "texample": "^0.1.0"
120
+ "texample": "^1.0.1"
103
121
  },
104
122
  "dependencies": {
105
- "@0dep/piso": "^3.0.1",
106
- "smqp": "^10.0.0"
123
+ "@0dep/piso": "^4.0.0",
124
+ "smqp": "^13.0.0"
107
125
  }
108
126
  }
package/src/Api.js CHANGED
@@ -1,22 +1,54 @@
1
1
  import { cloneMessage } from './messageHelper.js';
2
2
  import { getUniqueId } from './shared.js';
3
3
 
4
+ /**
5
+ * Build an activity-scoped Api wrapper. Routing keys are published under `activity.*`.
6
+ * @param {any} broker
7
+ * @param {import('#types').ElementBrokerMessage} apiMessage
8
+ * @param {import('#types').Environment} [environment]
9
+ */
4
10
  export function ActivityApi(broker, apiMessage, environment) {
5
11
  return new Api('activity', broker, apiMessage, environment);
6
12
  }
7
13
 
14
+ /**
15
+ * Build a definition-scoped Api wrapper. Routing keys are published under `definition.*`.
16
+ * @param {any} broker
17
+ * @param {import('#types').ElementBrokerMessage} apiMessage
18
+ * @param {import('#types').Environment} [environment]
19
+ */
8
20
  export function DefinitionApi(broker, apiMessage, environment) {
9
21
  return new Api('definition', broker, apiMessage, environment);
10
22
  }
11
23
 
24
+ /**
25
+ * Build a process-scoped Api wrapper. Routing keys are published under `process.*`.
26
+ * @param {any} broker
27
+ * @param {import('#types').ElementBrokerMessage} apiMessage
28
+ * @param {import('#types').Environment} [environment]
29
+ */
12
30
  export function ProcessApi(broker, apiMessage, environment) {
13
31
  return new Api('process', broker, apiMessage, environment);
14
32
  }
15
33
 
34
+ /**
35
+ * Build a flow-scoped Api wrapper. Routing keys are published under `flow.*`.
36
+ * @param {any} broker
37
+ * @param {import('#types').ElementBrokerMessage} apiMessage
38
+ * @param {import('#types').Environment} [environment]
39
+ */
16
40
  export function FlowApi(broker, apiMessage, environment) {
17
41
  return new Api('flow', broker, apiMessage, environment);
18
42
  }
19
43
 
44
+ /**
45
+ * Lightweight wrapper over the broker that exposes signal/cancel/fail/stop and other api actions.
46
+ * @param {string} pfx Message prefix, e.g. `activity`, `process`, `definition`, `flow`
47
+ * @param {any} broker
48
+ * @param {import('#types').ElementBrokerMessage} sourceMessage Cloned to back the api
49
+ * @param {import('#types').Environment} [environment] Defaults to `broker.owner.environment`
50
+ * @throws {Error} when sourceMessage is missing
51
+ */
20
52
  export function Api(pfx, broker, sourceMessage, environment) {
21
53
  if (!sourceMessage) throw new Error('Api requires message');
22
54
 
@@ -36,26 +68,50 @@ export function Api(pfx, broker, sourceMessage, environment) {
36
68
  this.messagePrefix = pfx;
37
69
  }
38
70
 
71
+ /**
72
+ * Send a cancel api message.
73
+ * @param {import('#types').signalMessage} [message]
74
+ * @param {any} [options]
75
+ */
39
76
  Api.prototype.cancel = function cancel(message, options) {
40
77
  this.sendApiMessage('cancel', { message }, options);
41
78
  };
42
79
 
80
+ /**
81
+ * Send a discard api message.
82
+ */
43
83
  Api.prototype.discard = function discard() {
44
84
  this.sendApiMessage('discard');
45
85
  };
46
86
 
87
+ /**
88
+ * Send an error api message that fails the activity.
89
+ * @param {Error} error
90
+ */
47
91
  Api.prototype.fail = function fail(error) {
48
92
  this.sendApiMessage('error', { error });
49
93
  };
50
94
 
95
+ /**
96
+ * Send a signal api message.
97
+ * @param {import('#types').signalMessage} [message]
98
+ * @param {any} [options]
99
+ */
51
100
  Api.prototype.signal = function signal(message, options) {
52
101
  this.sendApiMessage('signal', { message }, options);
53
102
  };
54
103
 
104
+ /**
105
+ * Send a stop api message.
106
+ */
55
107
  Api.prototype.stop = function stop() {
56
108
  this.sendApiMessage('stop');
57
109
  };
58
110
 
111
+ /**
112
+ * Resolve an expression with the api message as scope and the broker owner as context.
113
+ * @param {string} expression
114
+ */
59
115
  Api.prototype.resolveExpression = function resolveExpression(expression) {
60
116
  return this.environment.resolveExpression(
61
117
  expression,
@@ -68,6 +124,12 @@ Api.prototype.resolveExpression = function resolveExpression(expression) {
68
124
  );
69
125
  };
70
126
 
127
+ /**
128
+ * Publish a custom api message to the broker.
129
+ * @param {string} action Routing key suffix, e.g. `signal`, `cancel`
130
+ * @param {import('#types').signalMessage} [content] Merged into the message content
131
+ * @param {any} [options]
132
+ */
71
133
  Api.prototype.sendApiMessage = function sendApiMessage(action, content, options) {
72
134
  const correlationId = options?.correlationId || getUniqueId(`${this.id || this.messagePrefix}_signal`);
73
135
  let key = `${this.messagePrefix}.${action}`;
@@ -75,12 +137,20 @@ Api.prototype.sendApiMessage = function sendApiMessage(action, content, options)
75
137
  this.broker.publish('api', key, this.createMessage(content), { ...options, correlationId, type: action });
76
138
  };
77
139
 
140
+ /**
141
+ * List currently postponed activities, falling back to a sub-process execution when applicable.
142
+ * @param {import('#types').filterPostponed} [filterFn]
143
+ */
78
144
  Api.prototype.getPostponed = function getPostponed(...args) {
79
145
  if (this.owner.getPostponed) return this.owner.getPostponed(...args);
80
146
  if (this.owner.isSubProcess && this.owner.execution) return this.owner.execution.getPostponed(...args);
81
147
  return [];
82
148
  };
83
149
 
150
+ /**
151
+ * Build a message body by merging the given content onto the source content.
152
+ * @param {Record<string, any>} [content]
153
+ */
84
154
  Api.prototype.createMessage = function createMessage(content) {
85
155
  return {
86
156
  ...this.content,