@bpmnkit/core 1.9.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/agent-cards/bpmn.md +3 -3
  2. package/builder-reference.md +11 -9
  3. package/dist/bpmn/auto-layout.js +82 -26
  4. package/dist/bpmn/bpmn-builder.d.ts +84 -7
  5. package/dist/bpmn/bpmn-builder.js +313 -78
  6. package/dist/bpmn/bpmn-model.d.ts +2 -0
  7. package/dist/bpmn/bpmn-parser.js +68 -76
  8. package/dist/bpmn/bpmn-serializer.js +60 -19
  9. package/dist/bpmn/bpmnlint.js +4 -69
  10. package/dist/bpmn/builder-rules.d.ts +20 -0
  11. package/dist/bpmn/builder-rules.js +120 -0
  12. package/dist/bpmn/camunda-compat-data.d.ts +10 -148
  13. package/dist/bpmn/camunda-compat-data.js +16 -407
  14. package/dist/bpmn/camunda-compat-feel.d.ts +3 -0
  15. package/dist/bpmn/camunda-compat-feel.js +1 -1
  16. package/dist/bpmn/camunda-compat.js +7 -6
  17. package/dist/bpmn/camunda7/export.js +4 -1
  18. package/dist/bpmn/camunda7/juel.js +2 -1
  19. package/dist/bpmn/camunda7/migrate.d.ts +23 -0
  20. package/dist/bpmn/camunda7/migrate.js +75 -3
  21. package/dist/bpmn/compact-stream.js +2 -1
  22. package/dist/bpmn/compact.d.ts +80 -4
  23. package/dist/bpmn/compact.js +220 -38
  24. package/dist/bpmn/feel-condition.d.ts +9 -0
  25. package/dist/bpmn/feel-condition.js +19 -0
  26. package/dist/bpmn/full-operations.js +31 -4
  27. package/dist/bpmn/index.d.ts +13 -3
  28. package/dist/bpmn/index.js +16 -15
  29. package/dist/bpmn/operations.d.ts +4 -4
  30. package/dist/bpmn/operations.js +14 -2
  31. package/dist/bpmn/optimize/bpmnlint-rules.js +7 -40
  32. package/dist/bpmn/optimize/index.js +15 -1
  33. package/dist/bpmn/optimize/tasks.js +12 -3
  34. package/dist/bpmn/process-delta.d.ts +18 -0
  35. package/dist/bpmn/process-delta.js +20 -2
  36. package/dist/bpmn/process-text-writer.js +27 -1
  37. package/dist/bpmn/process-text.d.ts +9 -3
  38. package/dist/bpmn/process-text.js +122 -16
  39. package/dist/bpmn/stable-ids.d.ts +2 -0
  40. package/dist/bpmn/stable-ids.js +8 -0
  41. package/dist/bpmn/zeebe-extensions.js +2 -1
  42. package/dist/bpmn/zeebe-placement.js +6 -129
  43. package/dist/bpmn/zeebe-validate/context.d.ts +132 -0
  44. package/dist/bpmn/zeebe-validate/context.js +241 -0
  45. package/dist/bpmn/zeebe-validate/gate.d.ts +87 -0
  46. package/dist/bpmn/zeebe-validate/gate.js +492 -0
  47. package/dist/bpmn/zeebe-validate/index.d.ts +37 -0
  48. package/dist/bpmn/zeebe-validate/index.js +106 -0
  49. package/dist/bpmn/zeebe-validate/rules/events.d.ts +4 -0
  50. package/dist/bpmn/zeebe-validate/rules/events.js +580 -0
  51. package/dist/bpmn/zeebe-validate/rules/extensions.d.ts +4 -0
  52. package/dist/bpmn/zeebe-validate/rules/extensions.js +411 -0
  53. package/dist/bpmn/zeebe-validate/rules/gateways.d.ts +3 -0
  54. package/dist/bpmn/zeebe-validate/rules/gateways.js +296 -0
  55. package/dist/bpmn/zeebe-validate/rules/references.d.ts +3 -0
  56. package/dist/bpmn/zeebe-validate/rules/references.js +495 -0
  57. package/dist/bpmn/zeebe-validate/rules/structure.d.ts +3 -0
  58. package/dist/bpmn/zeebe-validate/rules/structure.js +629 -0
  59. package/dist/bpmn/zeebe-validate/rules/tasks.d.ts +4 -0
  60. package/dist/bpmn/zeebe-validate/rules/tasks.js +446 -0
  61. package/dist/bpmn/zeebe-validate/xml.d.ts +15 -0
  62. package/dist/bpmn/zeebe-validate/xml.js +1062 -0
  63. package/dist/bpmn/zeebe-validate/xsd.d.ts +19 -0
  64. package/dist/bpmn/zeebe-validate/xsd.js +350 -0
  65. package/dist/connectors/aliases.js +1 -0
  66. package/dist/connectors/apply-element.d.ts +5 -2
  67. package/dist/connectors/apply-element.js +6 -0
  68. package/dist/connectors/apply-many.d.ts +9 -2
  69. package/dist/connectors/apply-many.js +17 -2
  70. package/dist/connectors/apply.d.ts +4 -2
  71. package/dist/connectors/deployability.d.ts +27 -0
  72. package/dist/connectors/deployability.js +41 -0
  73. package/dist/connectors/index.d.ts +1 -0
  74. package/dist/connectors/lines.d.ts +10 -0
  75. package/dist/connectors/lines.js +13 -4
  76. package/dist/connectors/templates/generated.js +10101 -3188
  77. package/dist/dmn/dmn-model.d.ts +24 -4
  78. package/dist/dmn/dmn-parser.js +37 -3
  79. package/dist/dmn/dmn-serializer.js +48 -47
  80. package/dist/dmn/lint.js +4 -11
  81. package/dist/errors.d.ts +30 -1
  82. package/dist/errors.js +31 -0
  83. package/dist/form/form-model.d.ts +11 -0
  84. package/dist/form/form-parser.d.ts +1 -0
  85. package/dist/form/form-parser.js +48 -12
  86. package/dist/form/form-serializer.js +40 -17
  87. package/dist/form/lint.js +6 -40
  88. package/dist/generated/bpmn-elements.d.ts +5 -0
  89. package/dist/generated/bpmn-elements.js +151 -0
  90. package/dist/generated/camunda-compat-data.d.ts +148 -0
  91. package/dist/generated/camunda-compat-data.js +371 -0
  92. package/dist/generated/dmn-elements.d.ts +12 -0
  93. package/dist/generated/dmn-elements.js +45 -0
  94. package/dist/generated/form-elements.d.ts +5 -0
  95. package/dist/generated/form-elements.js +45 -0
  96. package/dist/generated/lint-rules.d.ts +17 -0
  97. package/dist/generated/lint-rules.js +116 -0
  98. package/dist/generated/zeebe-elements.d.ts +10 -0
  99. package/dist/generated/zeebe-elements.js +168 -0
  100. package/dist/generated/zeebe-rules.d.ts +25 -0
  101. package/dist/generated/zeebe-rules.js +202 -0
  102. package/dist/index.d.ts +10 -4
  103. package/dist/index.js +4 -1
  104. package/dist/layout/annotations.js +21 -1
  105. package/dist/layout/orthogonal.js +9 -3
  106. package/dist/plan/compile.d.ts +26 -1
  107. package/dist/plan/compile.js +48 -6
  108. package/dist/plan/merge.d.ts +2 -1
  109. package/dist/plan/merge.js +13 -5
  110. package/package.json +2 -2
@@ -0,0 +1,296 @@
1
+ import { feelError, feelFailure, isExpression, staticValueMessage, } from "../context.js";
2
+ const GATEWAY_TYPES = new Set([
3
+ "exclusiveGateway",
4
+ "inclusiveGateway",
5
+ "parallelGateway",
6
+ "eventBasedGateway",
7
+ "complexGateway",
8
+ ]);
9
+ function isGateway(node) {
10
+ return GATEWAY_TYPES.has(node.type);
11
+ }
12
+ /**
13
+ * Zeebe reads element text through `getTextContent()`, which trims; a
14
+ * non-static expression must then match `=(.+)`.
15
+ */
16
+ function expressionText(expression) {
17
+ return expression === undefined ? undefined : expression.text.trim();
18
+ }
19
+ /**
20
+ * The problem with an expression that must not be static: a static value, or a
21
+ * FEEL parse failure; `undefined` when it is fine.
22
+ */
23
+ function nonStaticProblem(text) {
24
+ if (!isExpression(text))
25
+ return staticValueMessage(text);
26
+ return feelError(text) === undefined ? undefined : feelFailure(text);
27
+ }
28
+ /** An attribute the way Zeebe's getters see it: an empty value is the same as absent. */
29
+ function attr(el, name) {
30
+ const value = el.attributes[name];
31
+ return value === undefined || value === "" ? undefined : value;
32
+ }
33
+ function loopOf(node) {
34
+ return node.loopCharacteristics;
35
+ }
36
+ // J: gateways and sequence flows ---------------------------------------------
37
+ const defaultSource = (ctx) => {
38
+ for (const { node } of ctx.nodes) {
39
+ if (node.type !== "exclusiveGateway" && node.type !== "inclusiveGateway")
40
+ continue;
41
+ const flow = ctx.flow(node.default);
42
+ if (flow === undefined || flow.flow.sourceRef === node.id)
43
+ continue;
44
+ ctx.report(node.type === "exclusiveGateway" ? "exclusive-default-source" : "inclusive-default-source", node.id, "Default flow must start at gateway", "Make the default flow start at the gateway that declares it.");
45
+ }
46
+ };
47
+ const flowCondition = (ctx) => {
48
+ for (const { flow } of ctx.flows) {
49
+ const source = ctx.node(flow.sourceRef)?.node;
50
+ if (source === undefined || flow.conditionExpression !== undefined)
51
+ continue;
52
+ if (source.type !== "exclusiveGateway" && source.type !== "inclusiveGateway")
53
+ continue;
54
+ if (ctx.outgoing(source.id).length <= 1 || source.default === flow.id)
55
+ continue;
56
+ ctx.report(source.type === "exclusiveGateway" ? "exclusive-flow-condition" : "inclusive-flow-condition", flow.id, source.type === "exclusiveGateway"
57
+ ? "Must have a condition or be default flow"
58
+ : "Must have a condition", "Add a condition expression to the flow or make it the gateway's default flow.");
59
+ }
60
+ };
61
+ const conditionalFlowSource = (ctx) => {
62
+ for (const { node } of ctx.nodes) {
63
+ if (node.type === "exclusiveGateway" || node.type === "inclusiveGateway")
64
+ continue;
65
+ if (!ctx.outgoing(node.id).some((f) => f.flow.conditionExpression !== undefined))
66
+ continue;
67
+ ctx.report("conditional-flow-source", node.id, "Conditional sequence flows are only supported at exclusive or inclusive gateway", "Remove the condition or route the flow through an exclusive or inclusive gateway.");
68
+ }
69
+ };
70
+ const conditionExpression = (ctx) => {
71
+ for (const { flow } of ctx.flows) {
72
+ const text = expressionText(flow.conditionExpression);
73
+ if (text === undefined)
74
+ continue;
75
+ const problem = nonStaticProblem(text);
76
+ if (problem === undefined)
77
+ continue;
78
+ ctx.report("condition-expression", flow.id, problem, "Write the condition as a FEEL expression that starts with '='.");
79
+ }
80
+ };
81
+ const EVENT_BASED_TARGETS = new Set(["timer", "message", "signal", "conditional"]);
82
+ function duplicates(values) {
83
+ const seen = new Set();
84
+ const out = [];
85
+ for (const v of values) {
86
+ if (seen.has(v) && !out.includes(v))
87
+ out.push(v);
88
+ seen.add(v);
89
+ }
90
+ return out;
91
+ }
92
+ function eventBasedGateway(ctx) {
93
+ for (const { node } of ctx.nodes) {
94
+ if (node.type !== "eventBasedGateway")
95
+ continue;
96
+ const outgoing = ctx.outgoing(node.id);
97
+ if (outgoing.length < 2) {
98
+ ctx.report("event-based-gateway-outgoing", node.id, "Event-based gateway must have at least 2 outgoing sequence flows.", "Add a second outgoing flow to a catch event.");
99
+ }
100
+ const targets = outgoing.map((f) => ctx.node(f.flow.targetRef)?.node);
101
+ const valid = outgoing.every((f) => {
102
+ const target = ctx.node(f.flow.targetRef)?.node;
103
+ if (target?.type !== "intermediateCatchEvent")
104
+ return false;
105
+ const [only] = target.eventDefinitions;
106
+ return (target.eventDefinitions.length === 1 &&
107
+ only !== undefined &&
108
+ EVENT_BASED_TARGETS.has(only.type));
109
+ });
110
+ if (!valid) {
111
+ ctx.report("event-based-gateway-target", node.id, "Event-based gateway must not have an outgoing sequence flow to other elements than message/timer/signal/conditional intermediate catch events.", "Route each flow to an intermediate catch event with one message, timer, signal or conditional definition.");
112
+ }
113
+ const defs = targets.flatMap((t) => t?.type === "intermediateCatchEvent" ? t.eventDefinitions : []);
114
+ const messageNames = [];
115
+ const signalNames = [];
116
+ for (const def of defs) {
117
+ if (def.type === "message") {
118
+ const name = ctx.message(def.messageRef)?.name;
119
+ if (name !== undefined && name !== "")
120
+ messageNames.push(name);
121
+ }
122
+ else if (def.type === "signal") {
123
+ const name = ctx.signal(def.signalRef)?.name;
124
+ if (name !== undefined && name !== "")
125
+ signalNames.push(name);
126
+ }
127
+ }
128
+ for (const name of duplicates(messageNames)) {
129
+ ctx.report("event-based-gateway-duplicate-trigger", node.id, `Multiple message event definitions with the same name '${name}' are not allowed.`, "Give each branch of the event-based gateway a different message.");
130
+ }
131
+ for (const name of duplicates(signalNames)) {
132
+ ctx.report("event-based-gateway-duplicate-trigger", node.id, `Multiple signal event definitions with the same name '${name}' are not allowed.`, "Give each branch of the event-based gateway a different signal.");
133
+ }
134
+ // Duplicate conditions are Z60 (event-based-gateway-duplicate-condition, events.ts).
135
+ const shared = outgoing.some((f) => ctx.incoming(f.flow.targetRef).some((i) => i.flow.sourceRef !== node.id));
136
+ if (shared) {
137
+ ctx.report("event-based-gateway-target-incoming", node.id, "Target elements of an event gateway must not have any additional incoming sequence flows other than that from the event gateway.", "Remove the other incoming flows of the catch events behind the gateway.");
138
+ }
139
+ }
140
+ }
141
+ /** The `eventType` of every listener of an element with exactly one `zeebe:executionListeners`. */
142
+ function listenerEventTypes(ctx, el) {
143
+ const lists = ctx.zeebe(el, "executionListeners");
144
+ const [only] = lists;
145
+ if (lists.length !== 1 || only === undefined)
146
+ return [];
147
+ return ctx.zeebeChildren(only, "executionListener").map((l) => l.attributes.eventType ?? "");
148
+ }
149
+ const gatewayEndListener = (ctx) => {
150
+ for (const { node } of ctx.nodes) {
151
+ if (!isGateway(node) || !listenerEventTypes(ctx, node).includes("end"))
152
+ continue;
153
+ ctx.report("gateway-end-listener", node.id, "Execution listeners of type 'end' are not supported by gateway element", "Use a 'start' execution listener or move the listener to a neighbouring element.");
154
+ }
155
+ };
156
+ // K: multi-instance -----------------------------------------------------------
157
+ const multiInstance = (ctx) => {
158
+ for (const { node } of ctx.nodes) {
159
+ const loop = loopOf(node);
160
+ if (loop === undefined)
161
+ continue;
162
+ const configs = ctx.zeebe(loop, "loopCharacteristics");
163
+ if (configs.length !== 1) {
164
+ ctx.report("multi-instance-loop-characteristics", node.id, "Must have exactly one 'zeebe:loopCharacteristics' extension element", "Add a single zeebe:loopCharacteristics element to the multi-instance loop.");
165
+ }
166
+ for (const config of configs) {
167
+ const input = attr(config, "inputCollection");
168
+ if (input === undefined) {
169
+ ctx.report("multi-instance-input-collection", node.id, "Attribute 'inputCollection' must be present and not empty", "Set inputCollection to the FEEL expression of the collection to iterate.");
170
+ }
171
+ const outputCollection = attr(config, "outputCollection");
172
+ const outputElement = attr(config, "outputElement");
173
+ if (outputCollection !== undefined && outputElement === undefined) {
174
+ ctx.report("multi-instance-output-pair", node.id, "Attribute 'outputElement' must be present if the attribute 'outputCollection' is set", "Set outputElement or remove outputCollection.");
175
+ }
176
+ else if (outputElement !== undefined && outputCollection === undefined) {
177
+ ctx.report("multi-instance-output-pair", node.id, "Attribute 'outputCollection' must be present if the attribute 'outputElement' is set", "Set outputCollection or remove outputElement.");
178
+ }
179
+ // A missing inputCollection is Zeebe's "Expected expression but not found." (Z168), not ours.
180
+ for (const value of [input, outputElement]) {
181
+ const problem = value === undefined ? undefined : nonStaticProblem(value);
182
+ if (problem === undefined)
183
+ continue;
184
+ ctx.report("multi-instance-expression", node.id, problem, "Write the value as a FEEL expression that starts with '='.");
185
+ }
186
+ }
187
+ // The completion condition may be static; only a '=' expression is parsed.
188
+ const completion = expressionText(loop.completionCondition);
189
+ if (completion !== undefined &&
190
+ isExpression(completion) &&
191
+ feelError(completion) !== undefined) {
192
+ ctx.report("multi-instance-expression", node.id, feelFailure(completion), "Fix the FEEL syntax of the completion condition.");
193
+ }
194
+ }
195
+ };
196
+ const beforeAllListener = (ctx) => {
197
+ const check = (id, type, el, multi) => {
198
+ if (multi || !listenerEventTypes(ctx, el).includes("beforeAll"))
199
+ return;
200
+ ctx.report("before-all-listener", id, `Execution listeners with event type 'beforeAll' are only supported on multi-instance activities and are not valid on '${type}'`, "Remove the beforeAll listener or make the activity multi-instance.");
201
+ };
202
+ for (const process of ctx.defs.processes)
203
+ check(process.id, "process", process, false);
204
+ for (const { node } of ctx.nodes) {
205
+ // Zeebe has one `subProcess` type for embedded and event sub-processes.
206
+ const type = node.type === "eventSubProcess" ? "subProcess" : node.type;
207
+ check(node.id, type, node, loopOf(node) !== undefined);
208
+ }
209
+ };
210
+ // L: sub-processes and ad-hoc ---------------------------------------------------
211
+ const subProcessStart = (ctx) => {
212
+ for (const scope of ctx.scopes) {
213
+ const container = scope.container;
214
+ if (container === undefined)
215
+ continue;
216
+ const starts = scope.flowElements.filter((n) => n.type === "startEvent");
217
+ if (starts.length !== 1 && scope.kind !== "adHocSubProcess") {
218
+ ctx.report("sub-process-start-event", container.id, "Must have exactly one start event", "Give the sub-process exactly one start event.");
219
+ }
220
+ const [first] = starts;
221
+ if (first?.type === "startEvent" &&
222
+ scope.kind !== "eventSubProcess" &&
223
+ first.eventDefinitions.length > 0) {
224
+ ctx.report("sub-process-start-none", container.id, "Start events in subprocesses must be of type none", "Use a none start event inside an embedded sub-process.");
225
+ }
226
+ }
227
+ };
228
+ const adHocStructure = (ctx) => {
229
+ for (const scope of ctx.scopes) {
230
+ if (scope.kind !== "adHocSubProcess" || scope.container === undefined)
231
+ continue;
232
+ const id = scope.container.id;
233
+ if (scope.flowElements.length === 0 && scope.sequenceFlows.length === 0) {
234
+ ctx.report("ad-hoc-activity", id, "Must have at least one activity.", "Add at least one activity to the ad-hoc sub-process.");
235
+ }
236
+ if (scope.flowElements.some((n) => n.type === "startEvent")) {
237
+ ctx.report("ad-hoc-start-event", id, "Must not contain a start event.", "Remove the start event from the ad-hoc sub-process.");
238
+ }
239
+ if (scope.flowElements.some((n) => n.type === "endEvent")) {
240
+ ctx.report("ad-hoc-end-event", id, "Must not contain an end event.", "Remove the end event from the ad-hoc sub-process.");
241
+ }
242
+ }
243
+ };
244
+ const adHocExtensions = (ctx) => {
245
+ for (const { node } of ctx.nodes) {
246
+ if (node.type !== "adHocSubProcess")
247
+ continue;
248
+ const adHocs = ctx.zeebe(node, "adHoc");
249
+ if (ctx.zeebe(node, "taskDefinition").length > 0) {
250
+ if (node.cancelRemainingInstances === false) {
251
+ ctx.report("ad-hoc-agent-cancel-remaining", node.id, "Must not define cancelRemainingInstances in combination with zeebe:taskDefinition.", "Remove cancelRemainingInstances or the task definition.");
252
+ }
253
+ if (node.completionCondition !== undefined) {
254
+ ctx.report("ad-hoc-agent-completion-condition", node.id, "Must not define completionCondition in combination with zeebe:taskDefinition.", "Remove the completion condition or the task definition.");
255
+ }
256
+ const [first] = adHocs;
257
+ if (first !== undefined && attr(first, "activeElementsCollection") !== undefined) {
258
+ ctx.report("ad-hoc-agent-active-elements", node.id, "Must not define activeElementsCollection in combination with zeebe:taskDefinition.", "Remove activeElementsCollection or the task definition.");
259
+ }
260
+ }
261
+ for (const adHoc of adHocs) {
262
+ const element = attr(adHoc, "outputElement");
263
+ const collection = attr(adHoc, "outputCollection");
264
+ if ((element === undefined) !== (collection === undefined)) {
265
+ ctx.report("ad-hoc-output-pair", node.id, `OutputElement and OutputCollection must both be set, or neither of them set. outputElement:${element ?? "null"} and outputCollection:${collection ?? "null"}.`, "Set both outputElement and outputCollection or neither.");
266
+ }
267
+ }
268
+ const values = [
269
+ expressionText(node.completionCondition),
270
+ ...adHocs.flatMap((a) => [attr(a, "activeElementsCollection"), attr(a, "outputElement")]),
271
+ ];
272
+ for (const value of values) {
273
+ const problem = value === undefined ? undefined : nonStaticProblem(value);
274
+ if (problem === undefined)
275
+ continue;
276
+ ctx.report("ad-hoc-expression", node.id, problem, "Write the value as a FEEL expression that starts with '='.");
277
+ }
278
+ if (adHocs.length > 1) {
279
+ ctx.report("duplicate-ad-hoc-extension", node.id, "Must have exactly one 'zeebe:adHoc' extension element when exists. Please check process definition XML and retain only one extension element.", "Keep a single zeebe:adHoc extension element.");
280
+ }
281
+ }
282
+ };
283
+ export const checks = [
284
+ defaultSource,
285
+ flowCondition,
286
+ conditionalFlowSource,
287
+ conditionExpression,
288
+ eventBasedGateway,
289
+ gatewayEndListener,
290
+ multiInstance,
291
+ beforeAllListener,
292
+ subProcessStart,
293
+ adHocStructure,
294
+ adHocExtensions,
295
+ ];
296
+ //# sourceMappingURL=gateways.js.map
@@ -0,0 +1,3 @@
1
+ import { type ZeebeCheck } from "../context.js";
2
+ export declare const checks: ZeebeCheck[];
3
+ //# sourceMappingURL=references.d.ts.map