@bpmnkit/core 1.8.0 → 1.10.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.
- package/agent-cards/bpmn.md +4 -2
- package/builder-reference.md +11 -9
- package/dist/bpmn/auto-layout.js +82 -26
- package/dist/bpmn/bpmn-builder.d.ts +84 -7
- package/dist/bpmn/bpmn-builder.js +321 -76
- package/dist/bpmn/bpmn-model.d.ts +2 -0
- package/dist/bpmn/bpmn-parser.js +68 -76
- package/dist/bpmn/bpmn-serializer.js +60 -19
- package/dist/bpmn/bpmnlint.js +4 -69
- package/dist/bpmn/builder-rules.d.ts +20 -0
- package/dist/bpmn/builder-rules.js +120 -0
- package/dist/bpmn/camunda-compat-data.d.ts +10 -148
- package/dist/bpmn/camunda-compat-data.js +16 -407
- package/dist/bpmn/camunda-compat-feel.d.ts +3 -0
- package/dist/bpmn/camunda-compat-feel.js +1 -1
- package/dist/bpmn/camunda-compat.js +7 -6
- package/dist/bpmn/camunda7/export.js +4 -1
- package/dist/bpmn/camunda7/juel.js +2 -1
- package/dist/bpmn/camunda7/migrate.d.ts +23 -0
- package/dist/bpmn/camunda7/migrate.js +75 -3
- package/dist/bpmn/compact-stream.js +2 -1
- package/dist/bpmn/compact.d.ts +80 -4
- package/dist/bpmn/compact.js +220 -38
- package/dist/bpmn/feel-condition.d.ts +9 -0
- package/dist/bpmn/feel-condition.js +19 -0
- package/dist/bpmn/full-operations.js +31 -4
- package/dist/bpmn/index.d.ts +17 -1
- package/dist/bpmn/index.js +19 -25
- package/dist/bpmn/operations.d.ts +4 -4
- package/dist/bpmn/operations.js +14 -2
- package/dist/bpmn/optimize/bpmnlint-rules.js +7 -40
- package/dist/bpmn/optimize/index.js +15 -1
- package/dist/bpmn/optimize/tasks.js +12 -3
- package/dist/bpmn/process-delta.d.ts +18 -0
- package/dist/bpmn/process-delta.js +20 -2
- package/dist/bpmn/process-text-writer.js +27 -1
- package/dist/bpmn/process-text.d.ts +9 -3
- package/dist/bpmn/process-text.js +122 -16
- package/dist/bpmn/stable-ids.d.ts +2 -0
- package/dist/bpmn/stable-ids.js +8 -0
- package/dist/bpmn/xsd-guards.d.ts +8 -0
- package/dist/bpmn/xsd-guards.js +56 -0
- package/dist/bpmn/zeebe-extensions.js +2 -1
- package/dist/bpmn/zeebe-placement.js +6 -129
- package/dist/bpmn/zeebe-validate/context.d.ts +132 -0
- package/dist/bpmn/zeebe-validate/context.js +241 -0
- package/dist/bpmn/zeebe-validate/gate.d.ts +87 -0
- package/dist/bpmn/zeebe-validate/gate.js +492 -0
- package/dist/bpmn/zeebe-validate/index.d.ts +37 -0
- package/dist/bpmn/zeebe-validate/index.js +106 -0
- package/dist/bpmn/zeebe-validate/rules/events.d.ts +4 -0
- package/dist/bpmn/zeebe-validate/rules/events.js +580 -0
- package/dist/bpmn/zeebe-validate/rules/extensions.d.ts +4 -0
- package/dist/bpmn/zeebe-validate/rules/extensions.js +411 -0
- package/dist/bpmn/zeebe-validate/rules/gateways.d.ts +3 -0
- package/dist/bpmn/zeebe-validate/rules/gateways.js +296 -0
- package/dist/bpmn/zeebe-validate/rules/references.d.ts +3 -0
- package/dist/bpmn/zeebe-validate/rules/references.js +495 -0
- package/dist/bpmn/zeebe-validate/rules/structure.d.ts +3 -0
- package/dist/bpmn/zeebe-validate/rules/structure.js +629 -0
- package/dist/bpmn/zeebe-validate/rules/tasks.d.ts +4 -0
- package/dist/bpmn/zeebe-validate/rules/tasks.js +446 -0
- package/dist/bpmn/zeebe-validate/xml.d.ts +15 -0
- package/dist/bpmn/zeebe-validate/xml.js +1062 -0
- package/dist/bpmn/zeebe-validate/xsd.d.ts +19 -0
- package/dist/bpmn/zeebe-validate/xsd.js +350 -0
- package/dist/connectors/apply-element.d.ts +5 -2
- package/dist/connectors/apply-element.js +6 -0
- package/dist/connectors/apply-many.d.ts +9 -2
- package/dist/connectors/apply-many.js +17 -2
- package/dist/connectors/apply.d.ts +4 -2
- package/dist/connectors/deployability.d.ts +27 -0
- package/dist/connectors/deployability.js +41 -0
- package/dist/connectors/index.d.ts +1 -0
- package/dist/connectors/lines.d.ts +10 -0
- package/dist/connectors/lines.js +13 -4
- package/dist/dmn/dmn-model.d.ts +24 -4
- package/dist/dmn/dmn-parser.js +37 -3
- package/dist/dmn/dmn-serializer.js +48 -47
- package/dist/dmn/lint.js +4 -11
- package/dist/errors.d.ts +30 -1
- package/dist/errors.js +31 -0
- package/dist/form/form-model.d.ts +11 -0
- package/dist/form/form-parser.d.ts +1 -0
- package/dist/form/form-parser.js +48 -12
- package/dist/form/form-serializer.js +40 -17
- package/dist/form/lint.js +6 -40
- package/dist/generated/bpmn-elements.d.ts +5 -0
- package/dist/generated/bpmn-elements.js +151 -0
- package/dist/generated/camunda-compat-data.d.ts +148 -0
- package/dist/generated/camunda-compat-data.js +371 -0
- package/dist/generated/dmn-elements.d.ts +12 -0
- package/dist/generated/dmn-elements.js +45 -0
- package/dist/generated/form-elements.d.ts +5 -0
- package/dist/generated/form-elements.js +45 -0
- package/dist/generated/lint-rules.d.ts +17 -0
- package/dist/generated/lint-rules.js +116 -0
- package/dist/generated/zeebe-elements.d.ts +10 -0
- package/dist/generated/zeebe-elements.js +168 -0
- package/dist/generated/zeebe-rules.d.ts +25 -0
- package/dist/generated/zeebe-rules.js +202 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.js +4 -1
- package/dist/layout/annotations.js +21 -1
- package/dist/layout/orthogonal.js +9 -3
- package/dist/plan/compile.d.ts +26 -1
- package/dist/plan/compile.js +48 -6
- package/dist/plan/merge.d.ts +2 -1
- package/dist/plan/merge.js +13 -5
- package/package.json +2 -2
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { feelError, feelFailure, isExpression, } from "../context.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for zeebe-rules.md sections G (user tasks), H (call activity),
|
|
4
|
+
* I (business rule task), M (generic FEEL), N (listeners) and O (deployment).
|
|
5
|
+
*
|
|
6
|
+
* Zeebe reads an attribute set to "" as absent, so `attr` does too.
|
|
7
|
+
*/
|
|
8
|
+
/** An attribute value; "" counts as absent because Zeebe's model reads it as null. */
|
|
9
|
+
function attr(el, name) {
|
|
10
|
+
const value = el.attributes[name];
|
|
11
|
+
return value === undefined || value === "" ? undefined : value;
|
|
12
|
+
}
|
|
13
|
+
const isBlank = (value) => value === undefined || value.trim() === "";
|
|
14
|
+
/** The BPMN element name Zeebe's model reports for a flow element (its `getTypeName()`). */
|
|
15
|
+
function typeName(node) {
|
|
16
|
+
return node.type === "eventSubProcess" ? "subProcess" : node.type;
|
|
17
|
+
}
|
|
18
|
+
/** Everything that can carry `extensionElements` with listeners: the processes, flow nodes and flows. */
|
|
19
|
+
function owners(ctx) {
|
|
20
|
+
const out = ctx.defs.processes.map((p) => ({ id: p.id, typeName: "process", holder: p }));
|
|
21
|
+
for (const { node } of ctx.nodes)
|
|
22
|
+
out.push({ id: node.id, typeName: typeName(node), holder: node });
|
|
23
|
+
for (const { flow } of ctx.flows)
|
|
24
|
+
out.push({ id: flow.id, typeName: "sequenceFlow", holder: flow });
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function nodeOwners(ctx) {
|
|
28
|
+
return owners(ctx).filter((o) => o.typeName !== "process" && o.typeName !== "sequenceFlow");
|
|
29
|
+
}
|
|
30
|
+
/** The static priority/number text Java's `new BigDecimal(text)` accepts. */
|
|
31
|
+
const DECIMAL = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
32
|
+
/** Zeebe's static-number test: a decimal with no fraction. */
|
|
33
|
+
function isStaticInteger(text) {
|
|
34
|
+
return DECIMAL.test(text) && Number(text) % 1 === 0;
|
|
35
|
+
}
|
|
36
|
+
const ZONED = /^(\d{4}|[+-]\d{5,10})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?([Zz]|[+-]\d{2}:\d{2}(?::\d{2})?)(\[[^\]\s]+\])?$/;
|
|
37
|
+
/** `ZonedDateTime.parse`: an ISO date-time with an offset, e.g. `2023-03-02T15:35+02:00`. */
|
|
38
|
+
function isZonedDateTime(text) {
|
|
39
|
+
const m = ZONED.exec(text);
|
|
40
|
+
if (m === null)
|
|
41
|
+
return false;
|
|
42
|
+
const year = Number(m[1]);
|
|
43
|
+
const month = Number(m[2]);
|
|
44
|
+
const day = Number(m[3]);
|
|
45
|
+
const hour = Number(m[4]);
|
|
46
|
+
const minute = Number(m[5]);
|
|
47
|
+
const second = m[6] === undefined ? 0 : Number(m[6]);
|
|
48
|
+
const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
49
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
|
|
50
|
+
if (days === undefined || day < 1 || day > days)
|
|
51
|
+
return false;
|
|
52
|
+
if (hour > 24 || minute > 59 || second > 60)
|
|
53
|
+
return false;
|
|
54
|
+
if (hour === 24 && (minute !== 0 || second !== 0))
|
|
55
|
+
return false;
|
|
56
|
+
const offset = /^[+-](\d{2}):(\d{2})/.exec(m[7] ?? "");
|
|
57
|
+
return offset === null || (Number(offset[1]) <= 18 && Number(offset[2]) <= 59);
|
|
58
|
+
}
|
|
59
|
+
/** Zeebe's `parseListOfCsv`: no blank entry between commas (Java's split drops trailing empties). */
|
|
60
|
+
function isListOfCsv(text) {
|
|
61
|
+
if (text === "")
|
|
62
|
+
return true;
|
|
63
|
+
const parts = text.split(",");
|
|
64
|
+
while (parts.length > 0 && parts[parts.length - 1] === "")
|
|
65
|
+
parts.pop();
|
|
66
|
+
const values = parts.filter((p) => p.trim() !== "").length;
|
|
67
|
+
return values >= text.split(",").length;
|
|
68
|
+
}
|
|
69
|
+
const DUPLICATE = "Must have exactly one 'zeebe:%s' extension element when exists. Please check process definition XML and retain only one extension element.";
|
|
70
|
+
const dupMessage = (name) => DUPLICATE.replace("%s", name);
|
|
71
|
+
const USER_TASK_SINGLES = [
|
|
72
|
+
"userTask",
|
|
73
|
+
"assignmentDefinition",
|
|
74
|
+
"formDefinition",
|
|
75
|
+
"taskHeaders",
|
|
76
|
+
"taskSchedule",
|
|
77
|
+
"priorityDefinition",
|
|
78
|
+
"taskListeners",
|
|
79
|
+
];
|
|
80
|
+
/** Z114 */
|
|
81
|
+
const duplicateUserTaskExtension = (ctx) => {
|
|
82
|
+
for (const { node } of ctx.nodes) {
|
|
83
|
+
if (node.type !== "userTask")
|
|
84
|
+
continue;
|
|
85
|
+
for (const name of USER_TASK_SINGLES) {
|
|
86
|
+
if (ctx.zeebe(node, name).length > 1)
|
|
87
|
+
ctx.report("duplicate-user-task-extension", node.id, dupMessage(name), `Keep a single zeebe:${name} element on the user task.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/** Z115, Z116, Z117: every zeebe:formDefinition. */
|
|
92
|
+
const formDefinition = (ctx) => {
|
|
93
|
+
for (const { id, holder } of nodeOwners(ctx)) {
|
|
94
|
+
const native = ctx.zeebe(holder, "userTask").length > 0;
|
|
95
|
+
for (const form of ctx.zeebe(holder, "formDefinition")) {
|
|
96
|
+
const formId = attr(form, "formId");
|
|
97
|
+
if (native) {
|
|
98
|
+
if (isBlank(attr(form, "externalReference")) === isBlank(formId))
|
|
99
|
+
ctx.report("form-definition-native", id, "Exactly one of the attributes 'formId, externalReference' must be present and not blank for native user tasks", "Set either formId or externalReference on the form definition, not both.");
|
|
100
|
+
}
|
|
101
|
+
else if (isBlank(attr(form, "formKey")) === isBlank(formId)) {
|
|
102
|
+
ctx.report("form-definition-job-worker", id, "Exactly one of the attributes 'formId, formKey' must be present and not blank", "Set either formId or formKey on the form definition, not both.");
|
|
103
|
+
}
|
|
104
|
+
bindingType(ctx, form, id, "form-binding-type");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const BINDING_TYPES = ["deployment", "latest", "versionTag"];
|
|
109
|
+
/** The binding-type rules shared by calledElement, calledDecision and formDefinition (Z117, Z129, Z135). */
|
|
110
|
+
function bindingType(ctx, el, id, rule) {
|
|
111
|
+
const type = attr(el, "bindingType");
|
|
112
|
+
const versionTag = attr(el, "versionTag");
|
|
113
|
+
if (type !== undefined && !BINDING_TYPES.includes(type))
|
|
114
|
+
ctx.report(rule, id, "Attribute 'bindingType' must be one of: deployment, latest, versionTag", "Use bindingType deployment, latest or versionTag.");
|
|
115
|
+
if (type === "versionTag" && isBlank(versionTag))
|
|
116
|
+
ctx.report(rule, id, "Attribute 'versionTag' must be present and not empty if 'bindingType' is 'versionTag'", "Set versionTag, or use another bindingType.");
|
|
117
|
+
else if (type !== "versionTag" && !isBlank(versionTag))
|
|
118
|
+
ctx.report(rule, id, "Attribute 'versionTag' may only be used if 'bindingType' is 'versionTag'", "Remove versionTag, or set bindingType to versionTag.");
|
|
119
|
+
}
|
|
120
|
+
/** The top-level flow nodes of executable processes: all Zeebe's deployment-binding validators visit. */
|
|
121
|
+
function topLevel(ctx, type) {
|
|
122
|
+
const executable = new Set(ctx.defs.processes.filter((p) => p.isExecutable === true).map((p) => p.id));
|
|
123
|
+
return ctx.nodes
|
|
124
|
+
.filter((n) => n.scope.kind === "process" && executable.has(n.scope.id) && n.node.type === type)
|
|
125
|
+
.map((n) => n.node);
|
|
126
|
+
}
|
|
127
|
+
/** Z118: bindingType=deployment needs the form in the deployment. */
|
|
128
|
+
const formDeployment = (ctx) => {
|
|
129
|
+
const has = ctx.resolver?.hasForm;
|
|
130
|
+
if (has === undefined)
|
|
131
|
+
return;
|
|
132
|
+
for (const node of topLevel(ctx, "userTask")) {
|
|
133
|
+
const form = ctx.zeebe(node, "formDefinition")[0];
|
|
134
|
+
const formId = form === undefined ? undefined : attr(form, "formId");
|
|
135
|
+
if (form === undefined || formId === undefined || attr(form, "bindingType") !== "deployment")
|
|
136
|
+
continue;
|
|
137
|
+
if (formId.startsWith("=") || has(formId))
|
|
138
|
+
continue;
|
|
139
|
+
ctx.report("form-deployment", node.id, `Expected to find form with id '${formId}' in current deployment, but not found.`, "Deploy the form together with the process, or use another bindingType.");
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
/** Z119: the embedded form. */
|
|
143
|
+
const embeddedForm = (ctx) => {
|
|
144
|
+
for (const { id, holder } of nodeOwners(ctx)) {
|
|
145
|
+
for (const form of ctx.zeebe(holder, "userTaskForm")) {
|
|
146
|
+
if (attr(form, "id") === undefined)
|
|
147
|
+
ctx.report("embedded-form", id, "Element id must be present and not empty.", "Give the embedded form an id.");
|
|
148
|
+
if ((form.text ?? "").trim() === "")
|
|
149
|
+
ctx.report("embedded-form", id, "User task form text content has to be present and not empty", "Add the form schema as the content of the userTaskForm element.");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
/** Z120, Z121, Z122 and the FEEL parse of their attributes (Z167). */
|
|
154
|
+
const userTaskExpressions = (ctx) => {
|
|
155
|
+
for (const { node } of ctx.nodes) {
|
|
156
|
+
if (node.type !== "userTask")
|
|
157
|
+
continue;
|
|
158
|
+
const parse = (value) => {
|
|
159
|
+
if (value === undefined)
|
|
160
|
+
return;
|
|
161
|
+
if (feelError(value) !== undefined)
|
|
162
|
+
ctx.report("feel-parse", node.id, feelFailure(value), "Fix the FEEL expression, or remove the leading '=' for a static value.");
|
|
163
|
+
};
|
|
164
|
+
for (const assignment of ctx.zeebe(node, "assignmentDefinition")) {
|
|
165
|
+
parse(attr(assignment, "assignee"));
|
|
166
|
+
for (const name of ["candidateGroups", "candidateUsers"]) {
|
|
167
|
+
const value = attr(assignment, name);
|
|
168
|
+
parse(value);
|
|
169
|
+
if (value !== undefined && !isExpression(value) && !isListOfCsv(value))
|
|
170
|
+
ctx.report("assignment-expression", node.id, `Expected static value to be a list of comma-separated values, e.g. 'a,b,c', but found '${value}'.`, `Write ${name} as comma-separated values without empty entries, or as a FEEL expression.`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const schedule of ctx.zeebe(node, "taskSchedule")) {
|
|
174
|
+
for (const name of ["dueDate", "followUpDate"]) {
|
|
175
|
+
const value = attr(schedule, name);
|
|
176
|
+
parse(value);
|
|
177
|
+
if (value !== undefined && !isExpression(value) && !isZonedDateTime(value))
|
|
178
|
+
ctx.report("task-schedule-date", node.id, `Expected static value to be a valid DateTime String, e.g. '2023-03-02T15:35+02:00', but found '${value}'.`, `Write ${name} as an ISO 8601 date-time with an offset, or as a FEEL expression.`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (const definition of ctx.zeebe(node, "priorityDefinition")) {
|
|
182
|
+
// An absent priority defaults to 50 in Zeebe's model, so it is never missing.
|
|
183
|
+
const value = attr(definition, "priority");
|
|
184
|
+
parse(value);
|
|
185
|
+
if (value === undefined || isExpression(value))
|
|
186
|
+
continue;
|
|
187
|
+
if (!isStaticInteger(value))
|
|
188
|
+
ctx.report("user-task-priority", node.id, `Expected static value to be a valid Number between 0 and 100, but found '${value}'.`, "Set the priority to a whole number from 0 to 100, or a FEEL expression.");
|
|
189
|
+
else if (/^[+-]?\d+$/.test(value)) {
|
|
190
|
+
const n = Number(value);
|
|
191
|
+
if (Math.abs(n) <= 2147483647 && (n < 0 || n > 100))
|
|
192
|
+
ctx.report("user-task-priority", node.id, `Priority must be a number between 0 and 100, but was '${value}'.`, "Set the priority to a whole number from 0 to 100.");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const TASK_LISTENER_EVENTS = [
|
|
198
|
+
"create",
|
|
199
|
+
"assignment",
|
|
200
|
+
"update",
|
|
201
|
+
"complete",
|
|
202
|
+
"cancel",
|
|
203
|
+
"creating",
|
|
204
|
+
"assigning",
|
|
205
|
+
"updating",
|
|
206
|
+
"completing",
|
|
207
|
+
"canceling",
|
|
208
|
+
];
|
|
209
|
+
/** Z123, Z124: task listeners. */
|
|
210
|
+
const taskListeners = (ctx) => {
|
|
211
|
+
for (const { id, holder } of nodeOwners(ctx)) {
|
|
212
|
+
const native = ctx.zeebe(holder, "userTask").length > 0;
|
|
213
|
+
for (const listeners of ctx.zeebe(holder, "taskListeners")) {
|
|
214
|
+
const children = ctx.zeebeChildren(listeners, "taskListener");
|
|
215
|
+
if (children.length > 0 && !native)
|
|
216
|
+
ctx.report("task-listener-placement", id, "Task listeners are only allowed on Camunda user tasks.", "Add zeebe:userTask to the user task, or remove the task listeners.");
|
|
217
|
+
for (const listener of children) {
|
|
218
|
+
const eventType = attr(listener, "eventType");
|
|
219
|
+
if (eventType === undefined)
|
|
220
|
+
ctx.report("task-listener-attributes", id, "Attribute 'eventType' must be present and not empty", "Set eventType on the task listener.");
|
|
221
|
+
else if (!TASK_LISTENER_EVENTS.includes(eventType))
|
|
222
|
+
ctx.report("task-listener-attributes", id, `No enum constant io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeTaskListenerEventType.${eventType}`, "Use a task listener event type such as creating, assigning or completing.");
|
|
223
|
+
if (attr(listener, "type") === undefined)
|
|
224
|
+
ctx.report("task-listener-attributes", id, "Attribute 'type' must be present and not empty", "Set type on the task listener.");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
/** Z125, Z126, Z127: call activity and its calledElement. */
|
|
230
|
+
const calledElement = (ctx) => {
|
|
231
|
+
for (const { node } of ctx.nodes) {
|
|
232
|
+
if (node.type !== "callActivity")
|
|
233
|
+
continue;
|
|
234
|
+
const elements = ctx.zeebe(node, "calledElement");
|
|
235
|
+
if (elements.length !== 1)
|
|
236
|
+
ctx.report("call-activity-called-element", node.id, "Must have exactly one 'zeebe:calledElement' extension element", "Add a single zeebe:calledElement with the called process id.");
|
|
237
|
+
for (const el of elements) {
|
|
238
|
+
const processId = attr(el, "processId");
|
|
239
|
+
if (processId === undefined) {
|
|
240
|
+
ctx.report("called-element-process-id", node.id, "Attribute 'processId' must be present and not empty", "Set processId on the zeebe:calledElement.");
|
|
241
|
+
ctx.report("called-element-expression", node.id, "Expected expression but not found.", "Set processId on the zeebe:calledElement.");
|
|
242
|
+
}
|
|
243
|
+
else if (feelError(processId) !== undefined)
|
|
244
|
+
ctx.report("called-element-expression", node.id, feelFailure(processId), "Fix the FEEL expression in processId, or remove the leading '='.");
|
|
245
|
+
// businessId arrived after 8.9.28, whose model does not know the attribute; the rule is
|
|
246
|
+
// read from the spec (EngineConfiguration / BusinessIdValidator), not confirmed by ZCheck.
|
|
247
|
+
const businessId = attr(el, "businessId");
|
|
248
|
+
if (businessId !== undefined) {
|
|
249
|
+
if (feelError(businessId) !== undefined)
|
|
250
|
+
ctx.report("called-element-business-id", node.id, feelFailure(businessId), "Fix the FEEL expression in businessId, or remove the leading '='.");
|
|
251
|
+
else if (!isExpression(businessId) && businessId.length > 256)
|
|
252
|
+
ctx.report("called-element-business-id", node.id, `Expected static value to be no longer than 256 characters, but found '${businessId}'.`, "Shorten businessId to at most 256 characters.");
|
|
253
|
+
}
|
|
254
|
+
bindingType(ctx, el, node.id, "called-element-binding-type");
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
/** Z130: bindingType=deployment needs the called process in the deployment. */
|
|
259
|
+
const calledElementDeployment = (ctx) => {
|
|
260
|
+
const has = ctx.resolver?.hasProcess;
|
|
261
|
+
if (has === undefined)
|
|
262
|
+
return;
|
|
263
|
+
const own = new Set(ctx.defs.processes.filter((p) => p.isExecutable === true).map((p) => p.id));
|
|
264
|
+
for (const node of topLevel(ctx, "callActivity")) {
|
|
265
|
+
const el = ctx.zeebe(node, "calledElement")[0];
|
|
266
|
+
const processId = el === undefined ? undefined : attr(el, "processId");
|
|
267
|
+
if (el === undefined || processId === undefined || attr(el, "bindingType") !== "deployment")
|
|
268
|
+
continue;
|
|
269
|
+
if (processId.startsWith("=") || own.has(processId) || has(processId))
|
|
270
|
+
continue;
|
|
271
|
+
ctx.report("called-element-deployment", node.id, `Expected to find process with id '${processId}' in current deployment, but not found.`, "Deploy the called process together with this one, or use another bindingType.");
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
/** Z132, Z133, Z134, Z135, Z137: business rule task. */
|
|
275
|
+
const businessRuleTask = (ctx) => {
|
|
276
|
+
for (const { node } of ctx.nodes) {
|
|
277
|
+
if (node.type !== "businessRuleTask")
|
|
278
|
+
continue;
|
|
279
|
+
const decisions = ctx.zeebe(node, "calledDecision");
|
|
280
|
+
const definitions = ctx.zeebe(node, "taskDefinition");
|
|
281
|
+
if (!((decisions.length === 1 && definitions.length === 0) ||
|
|
282
|
+
(decisions.length === 0 && definitions.length === 1)))
|
|
283
|
+
ctx.report("business-rule-task-implementation", node.id, "Must have either one 'zeebe:calledDecision' or one 'zeebe:taskDefinition' extension element", "Give the task one zeebe:calledDecision or one zeebe:taskDefinition, not both.");
|
|
284
|
+
if (decisions.length > 1)
|
|
285
|
+
ctx.report("duplicate-called-decision", node.id, dupMessage("calledDecision"), "Keep a single zeebe:calledDecision element on the task.");
|
|
286
|
+
for (const el of decisions) {
|
|
287
|
+
const decisionId = attr(el, "decisionId");
|
|
288
|
+
if (decisionId === undefined) {
|
|
289
|
+
ctx.report("called-decision-attributes", node.id, "Attribute 'decisionId' must be present and not empty", "Set decisionId on the zeebe:calledDecision.");
|
|
290
|
+
ctx.report("called-decision-expression", node.id, "Expected expression but not found.", "Set decisionId on the zeebe:calledDecision.");
|
|
291
|
+
}
|
|
292
|
+
else if (feelError(decisionId) !== undefined)
|
|
293
|
+
ctx.report("called-decision-expression", node.id, feelFailure(decisionId), "Fix the FEEL expression in decisionId, or remove the leading '='.");
|
|
294
|
+
if (attr(el, "resultVariable") === undefined)
|
|
295
|
+
ctx.report("called-decision-attributes", node.id, "Attribute 'resultVariable' must be present and not empty", "Set resultVariable on the zeebe:calledDecision.");
|
|
296
|
+
bindingType(ctx, el, node.id, "called-decision-binding-type");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
/** Z136: bindingType=deployment needs the decision in the deployment. */
|
|
301
|
+
const calledDecisionDeployment = (ctx) => {
|
|
302
|
+
const has = ctx.resolver?.hasDecision;
|
|
303
|
+
if (has === undefined)
|
|
304
|
+
return;
|
|
305
|
+
for (const node of topLevel(ctx, "businessRuleTask")) {
|
|
306
|
+
const el = ctx.zeebe(node, "calledDecision")[0];
|
|
307
|
+
const decisionId = el === undefined ? undefined : attr(el, "decisionId");
|
|
308
|
+
if (el === undefined || decisionId === undefined || attr(el, "bindingType") !== "deployment")
|
|
309
|
+
continue;
|
|
310
|
+
if (decisionId.startsWith("=") || has(decisionId))
|
|
311
|
+
continue;
|
|
312
|
+
ctx.report("called-decision-deployment", node.id, `Expected to find decision with id '${decisionId}' in current deployment, but not found.`, "Deploy the decision together with the process, or use another bindingType.");
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const EXECUTION_LISTENER_ELEMENTS = [
|
|
316
|
+
"process",
|
|
317
|
+
"subProcess",
|
|
318
|
+
"callActivity",
|
|
319
|
+
"adHocSubProcess",
|
|
320
|
+
"task",
|
|
321
|
+
"sendTask",
|
|
322
|
+
"serviceTask",
|
|
323
|
+
"scriptTask",
|
|
324
|
+
"userTask",
|
|
325
|
+
"receiveTask",
|
|
326
|
+
"businessRuleTask",
|
|
327
|
+
"manualTask",
|
|
328
|
+
"startEvent",
|
|
329
|
+
"intermediateThrowEvent",
|
|
330
|
+
"intermediateCatchEvent",
|
|
331
|
+
"boundaryEvent",
|
|
332
|
+
"endEvent",
|
|
333
|
+
"exclusiveGateway",
|
|
334
|
+
"inclusiveGateway",
|
|
335
|
+
"parallelGateway",
|
|
336
|
+
"eventBasedGateway",
|
|
337
|
+
];
|
|
338
|
+
/** Z175, Z177, Z178, Z179: execution listeners. */
|
|
339
|
+
const executionListeners = (ctx) => {
|
|
340
|
+
// 'cancel' and 'beforeAll' only became event types together with their placement rules.
|
|
341
|
+
const cancelKnown = ctx.applies("cancel-listener-placement");
|
|
342
|
+
const beforeAllKnown = ctx.applies("before-all-listener");
|
|
343
|
+
for (const { id, typeName: type, holder } of owners(ctx)) {
|
|
344
|
+
for (const listeners of ctx.zeebe(holder, "executionListeners")) {
|
|
345
|
+
const children = ctx.zeebeChildren(listeners, "executionListener");
|
|
346
|
+
for (const listener of children) {
|
|
347
|
+
const eventType = attr(listener, "eventType");
|
|
348
|
+
if (eventType === undefined)
|
|
349
|
+
ctx.report("execution-listener-attributes", id, "Attribute 'eventType' must be present and not empty", "Set eventType on the execution listener.");
|
|
350
|
+
else if (eventType !== "start" &&
|
|
351
|
+
eventType !== "end" &&
|
|
352
|
+
!(cancelKnown && eventType === "cancel") &&
|
|
353
|
+
!(beforeAllKnown && eventType === "beforeAll"))
|
|
354
|
+
ctx.report("execution-listener-attributes", id, `No enum constant io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeExecutionListenerEventType.${eventType}`, "Use the execution listener event type start or end.");
|
|
355
|
+
if (attr(listener, "type") === undefined)
|
|
356
|
+
ctx.report("execution-listener-attributes", id, "Attribute 'type' must be present and not empty", "Set type on the execution listener.");
|
|
357
|
+
}
|
|
358
|
+
if (children.length === 0)
|
|
359
|
+
continue;
|
|
360
|
+
if (!EXECUTION_LISTENER_ELEMENTS.includes(type)) {
|
|
361
|
+
ctx.report("execution-listener-placement", id, `Execution listeners are not supported for the '${type}' element. Currently, only [${EXECUTION_LISTENER_ELEMENTS.join(", ")}] elements can have execution listeners.`, "Move the execution listeners to a supported element or remove them.");
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
for (const listener of children) {
|
|
365
|
+
if (attr(listener, "eventType") === "cancel" && type !== "process")
|
|
366
|
+
ctx.report("cancel-listener-placement", id, `The 'cancel' execution listener event type is not supported for the '${type}' element. The 'cancel' event type is only supported on the 'process' element.`, "Use the cancel event type on the process only.");
|
|
367
|
+
}
|
|
368
|
+
const groups = new Map();
|
|
369
|
+
for (const listener of children) {
|
|
370
|
+
const eventType = attr(listener, "eventType") ?? "null";
|
|
371
|
+
const listenerType = attr(listener, "type") ?? "null";
|
|
372
|
+
const key = `${eventType}|${listenerType}`;
|
|
373
|
+
const group = groups.get(key);
|
|
374
|
+
if (group === undefined)
|
|
375
|
+
groups.set(key, { eventType, type: listenerType, count: 1 });
|
|
376
|
+
else
|
|
377
|
+
group.count += 1;
|
|
378
|
+
}
|
|
379
|
+
for (const group of groups.values()) {
|
|
380
|
+
if (group.count > 1)
|
|
381
|
+
ctx.report("duplicate-execution-listener", id, `Found '${group.count}' duplicates based on eventType[${group.eventType}] and type[${group.type}], these combinations should be unique.`, "Remove the repeated execution listeners.");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
/** Z183: a process id another resource of the deployment already defines. */
|
|
387
|
+
const duplicateProcessId = (ctx) => {
|
|
388
|
+
const has = ctx.resolver?.hasProcess;
|
|
389
|
+
if (has === undefined)
|
|
390
|
+
return;
|
|
391
|
+
for (const process of ctx.defs.processes) {
|
|
392
|
+
if (has(process.id))
|
|
393
|
+
ctx.report("duplicate-process-id", process.id, `Duplicated process id in resources, '${process.id}' is also defined in another resource of the deployment`, "Give each process in the deployment its own id.");
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
/** Checks for zeebe-rules.md sections (see index.ts). */
|
|
397
|
+
export const checks = [
|
|
398
|
+
duplicateUserTaskExtension,
|
|
399
|
+
formDefinition,
|
|
400
|
+
formDeployment,
|
|
401
|
+
embeddedForm,
|
|
402
|
+
userTaskExpressions,
|
|
403
|
+
taskListeners,
|
|
404
|
+
calledElement,
|
|
405
|
+
calledElementDeployment,
|
|
406
|
+
businessRuleTask,
|
|
407
|
+
calledDecisionDeployment,
|
|
408
|
+
executionListeners,
|
|
409
|
+
duplicateProcessId,
|
|
410
|
+
];
|
|
411
|
+
//# sourceMappingURL=extensions.js.map
|