@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,446 @@
|
|
|
1
|
+
import { parseExpression } from "@bpmnkit/feel";
|
|
2
|
+
import { feelChildren } from "../../camunda-compat-feel.js";
|
|
3
|
+
import { feelError, feelFailure, isExpression, staticValueMessage, } from "../context.js";
|
|
4
|
+
/** Whether a process is validated: Zeebe skips a non-executable process, contents included. */
|
|
5
|
+
function executable(ctx, processId) {
|
|
6
|
+
return ctx.defs.processes.some((p) => p.id === processId && p.isExecutable === true);
|
|
7
|
+
}
|
|
8
|
+
/** The flow elements of executable processes. */
|
|
9
|
+
function nodes(ctx) {
|
|
10
|
+
return ctx.nodes.filter((n) => executable(ctx, n.scope.processId));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Every element that can carry Zeebe extension elements: the processes, every
|
|
14
|
+
* flow element of every scope, and every sequence flow. Zeebe validates a
|
|
15
|
+
* `zeebe:taskDefinition`, `zeebe:input` or `zeebe:taskHeaders` wherever it is,
|
|
16
|
+
* so the job-worker checks cover every element that has one.
|
|
17
|
+
*/
|
|
18
|
+
function owners(ctx) {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const p of ctx.defs.processes)
|
|
21
|
+
if (p.isExecutable === true)
|
|
22
|
+
out.push({ id: p.id, extensionElements: p.extensionElements, isProcess: true });
|
|
23
|
+
for (const { node } of nodes(ctx))
|
|
24
|
+
out.push({
|
|
25
|
+
id: node.id,
|
|
26
|
+
extensionElements: node.extensionElements ?? [],
|
|
27
|
+
node,
|
|
28
|
+
isProcess: false,
|
|
29
|
+
});
|
|
30
|
+
for (const { flow, scope } of ctx.flows)
|
|
31
|
+
if (executable(ctx, scope.processId))
|
|
32
|
+
out.push({ id: flow.id, extensionElements: flow.extensionElements, isProcess: false });
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The value Zeebe's model reads for an attribute: the XML model reads an empty
|
|
37
|
+
* attribute as absent, so `""` counts as missing (but `" "` does not).
|
|
38
|
+
*/
|
|
39
|
+
function attr(el, name) {
|
|
40
|
+
const v = el.attributes[name];
|
|
41
|
+
return v === undefined || v === "" ? undefined : v;
|
|
42
|
+
}
|
|
43
|
+
/** What `ExpressionVerification` reports for one attribute, or `undefined`. */
|
|
44
|
+
function expressionProblem(value, opts) {
|
|
45
|
+
if (value === undefined)
|
|
46
|
+
return opts.mandatory ? "Expected expression but not found." : undefined;
|
|
47
|
+
if (feelError(value) !== undefined)
|
|
48
|
+
return feelFailure(value);
|
|
49
|
+
if (opts.nonStatic && !isExpression(value))
|
|
50
|
+
return staticValueMessage(value);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const PATH_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*$/;
|
|
54
|
+
const PATH_PATTERN_TEXT = "[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*";
|
|
55
|
+
const PATH_RESERVED_WORDS = [
|
|
56
|
+
"null",
|
|
57
|
+
"true",
|
|
58
|
+
"false",
|
|
59
|
+
"function",
|
|
60
|
+
"if",
|
|
61
|
+
"then",
|
|
62
|
+
"else",
|
|
63
|
+
"for",
|
|
64
|
+
"between",
|
|
65
|
+
"instance",
|
|
66
|
+
"of",
|
|
67
|
+
];
|
|
68
|
+
/** `ZeebeExpressionValidator.verifyPath`: both pattern and reserved-word errors can apply. */
|
|
69
|
+
function pathProblems(target) {
|
|
70
|
+
if (target === undefined)
|
|
71
|
+
return ["Expected path expression but not found."];
|
|
72
|
+
const out = [];
|
|
73
|
+
if (!PATH_PATTERN.test(target))
|
|
74
|
+
out.push(`Expected path expression '${target}' but doesn't match the pattern '${PATH_PATTERN_TEXT}'.`);
|
|
75
|
+
if (PATH_RESERVED_WORDS.includes(target))
|
|
76
|
+
out.push(`Expected path expression '${target}' but is one of the reserved words (${PATH_RESERVED_WORDS.join(", ")}).`);
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
function duplicateMessage(local) {
|
|
80
|
+
return `Must have exactly one 'zeebe:${local}' extension element when exists. Please check process definition XML and retain only one extension element.`;
|
|
81
|
+
}
|
|
82
|
+
const JOB_WORKER_MODE_MESSAGE = "'zeebe:jobPriorityDefinition' is only allowed in job-worker mode ('zeebe:taskDefinition')";
|
|
83
|
+
const FLOW_NODE_EXCLUDED = new Set(["dataObject", "dataObjectReference", "dataStoreReference"]);
|
|
84
|
+
/** Inputs and outputs of an owner's `zeebe:ioMapping` elements. */
|
|
85
|
+
function mappings(ctx, owner, local) {
|
|
86
|
+
return ctx.zeebe(owner, "ioMapping").flatMap((m) => ctx.zeebeChildren(m, local));
|
|
87
|
+
}
|
|
88
|
+
// Z90
|
|
89
|
+
const serviceTaskDefinition = (ctx) => {
|
|
90
|
+
for (const { node } of nodes(ctx)) {
|
|
91
|
+
if (node.type !== "serviceTask")
|
|
92
|
+
continue;
|
|
93
|
+
if (ctx.zeebe(node, "taskDefinition").length !== 1)
|
|
94
|
+
ctx.report("service-task-definition", node.id, "Must have exactly one 'zeebe:taskDefinition' extension element", "Add one zeebe:taskDefinition with a job type to the service task.");
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// Z91, Z92 (retries: an empty value falls back to the default "3", so only a
|
|
98
|
+
// value the model reads as absent could fail, which never happens), Z93
|
|
99
|
+
const taskDefinitionAttributes = (ctx) => {
|
|
100
|
+
for (const owner of owners(ctx)) {
|
|
101
|
+
for (const td of ctx.zeebe(owner, "taskDefinition")) {
|
|
102
|
+
const type = attr(td, "type");
|
|
103
|
+
if (type === undefined)
|
|
104
|
+
ctx.report("task-definition-type", owner.id, "Attribute 'type' must be present and not empty", "Set the job type on zeebe:taskDefinition.");
|
|
105
|
+
const retries = attr(td, "retries") ?? "3";
|
|
106
|
+
for (const value of [type, retries]) {
|
|
107
|
+
const problem = expressionProblem(value, { mandatory: true, nonStatic: false });
|
|
108
|
+
if (problem !== undefined)
|
|
109
|
+
ctx.report("task-definition-expression", owner.id, problem, "Write the job type and retries as a static value or a valid FEEL expression.");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* The extension elements Zeebe allows at most once per element type
|
|
116
|
+
* (`ExtensionElementDuplicationValidators`), without those of other rules:
|
|
117
|
+
* the process (Z33), user-task specific ones (Z114), `calledDecision` (Z137)
|
|
118
|
+
* and the ad-hoc sub-process (Z165).
|
|
119
|
+
*/
|
|
120
|
+
function singleExtensions(ctx, node) {
|
|
121
|
+
const out = FLOW_NODE_EXCLUDED.has(node.type) ? [] : ["ioMapping", "executionListeners"];
|
|
122
|
+
// jobPriorityDefinition and agentDefinition only exist from the version their own rules start at
|
|
123
|
+
const priority = ctx.applies("job-priority-value") ? ["jobPriorityDefinition"] : [];
|
|
124
|
+
switch (node.type) {
|
|
125
|
+
case "serviceTask":
|
|
126
|
+
out.push("taskHeaders", "linkedResources", ...priority, ...(ctx.applies("agent-type-required") ? ["agentDefinition"] : []));
|
|
127
|
+
break;
|
|
128
|
+
case "sendTask":
|
|
129
|
+
out.push("taskHeaders", "linkedResources", ...priority);
|
|
130
|
+
break;
|
|
131
|
+
case "businessRuleTask":
|
|
132
|
+
out.push("taskDefinition", "taskHeaders", ...priority);
|
|
133
|
+
break;
|
|
134
|
+
case "scriptTask":
|
|
135
|
+
out.push("script", "taskDefinition", "taskHeaders", ...priority);
|
|
136
|
+
break;
|
|
137
|
+
case "endEvent":
|
|
138
|
+
case "intermediateThrowEvent":
|
|
139
|
+
out.push("taskDefinition");
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
// Z94
|
|
145
|
+
const duplicateTaskExtension = (ctx) => {
|
|
146
|
+
for (const { node } of nodes(ctx)) {
|
|
147
|
+
for (const local of singleExtensions(ctx, node)) {
|
|
148
|
+
if (ctx.zeebe(node, local).length > 1)
|
|
149
|
+
ctx.report("duplicate-task-extension", node.id, duplicateMessage(local), `Merge the zeebe:${local} elements into one.`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const RESERVED_HEADER_PREFIX = "io.camunda.zeebe:";
|
|
154
|
+
// Z95, Z96
|
|
155
|
+
const taskHeaders = (ctx) => {
|
|
156
|
+
for (const owner of owners(ctx)) {
|
|
157
|
+
for (const headers of ctx.zeebe(owner, "taskHeaders")) {
|
|
158
|
+
const keys = ctx.zeebeChildren(headers, "header").map((h) => attr(h, "key"));
|
|
159
|
+
for (const key of keys) {
|
|
160
|
+
if (key?.startsWith(RESERVED_HEADER_PREFIX))
|
|
161
|
+
ctx.report("header-reserved-key", owner.id, `Attribute 'key' contains '${key}', but header keys starting with '${RESERVED_HEADER_PREFIX}' are reserved for internal use.`, `Rename the header so it does not start with '${RESERVED_HEADER_PREFIX}'.`);
|
|
162
|
+
}
|
|
163
|
+
// a missing key is Java's null: distinct from the text "null", but printed the same
|
|
164
|
+
const seen = [];
|
|
165
|
+
const reported = [];
|
|
166
|
+
for (const key of keys) {
|
|
167
|
+
if (!seen.includes(key)) {
|
|
168
|
+
seen.push(key);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (reported.includes(key))
|
|
172
|
+
continue;
|
|
173
|
+
reported.push(key);
|
|
174
|
+
ctx.report("duplicate-header-key", owner.id, `Headers contain duplicate entries for key '${key ?? "null"}'`, "Give every task header a distinct key.");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
// Z98
|
|
180
|
+
const scriptTaskImplementation = (ctx) => {
|
|
181
|
+
for (const { node } of nodes(ctx)) {
|
|
182
|
+
if (node.type !== "scriptTask")
|
|
183
|
+
continue;
|
|
184
|
+
const scripts = ctx.zeebe(node, "script").length;
|
|
185
|
+
const definitions = ctx.zeebe(node, "taskDefinition").length;
|
|
186
|
+
if (!((scripts === 1 && definitions === 0) || (scripts === 0 && definitions === 1)))
|
|
187
|
+
ctx.report("script-task-implementation", node.id, "Must have either one 'zeebe:script' or one 'zeebe:taskDefinition' extension element", "Give the script task one zeebe:script or one zeebe:taskDefinition.");
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
// Z99, Z100
|
|
191
|
+
const scripts = (ctx) => {
|
|
192
|
+
for (const owner of owners(ctx)) {
|
|
193
|
+
for (const script of ctx.zeebe(owner, "script")) {
|
|
194
|
+
const expression = attr(script, "expression");
|
|
195
|
+
for (const name of ["expression", "resultVariable"]) {
|
|
196
|
+
if (attr(script, name) === undefined)
|
|
197
|
+
ctx.report("script-attributes", owner.id, `Attribute '${name}' must be present and not empty`, `Set ${name} on zeebe:script.`);
|
|
198
|
+
}
|
|
199
|
+
const problem = expressionProblem(expression, { mandatory: true, nonStatic: true });
|
|
200
|
+
if (problem !== undefined)
|
|
201
|
+
ctx.report("script-expression", owner.id, problem, "Write the script as a valid FEEL expression starting with '='.");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
// Z101
|
|
206
|
+
const jobPriorityMode = (ctx) => {
|
|
207
|
+
for (const { node } of nodes(ctx)) {
|
|
208
|
+
if (node.type !== "scriptTask" && node.type !== "businessRuleTask" && node.type !== "sendTask")
|
|
209
|
+
continue;
|
|
210
|
+
if (ctx.zeebe(node, "jobPriorityDefinition").length > 0 &&
|
|
211
|
+
ctx.zeebe(node, "taskDefinition").length === 0)
|
|
212
|
+
ctx.report("job-priority-mode", node.id, JOB_WORKER_MODE_MESSAGE, "Remove zeebe:jobPriorityDefinition, or implement the task as a job worker.");
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
/** Java's `Integer.parseInt`: an optional sign, ASCII digits, within 32 bits. */
|
|
216
|
+
function isJavaInt(text) {
|
|
217
|
+
if (!/^[+-]?[0-9]+$/.test(text))
|
|
218
|
+
return false;
|
|
219
|
+
const n = Number(text);
|
|
220
|
+
return n >= -2147483648 && n <= 2147483647;
|
|
221
|
+
}
|
|
222
|
+
// Z102 (an absent or empty priority falls back to the model's default, so only the format can fail)
|
|
223
|
+
const jobPriorityValue = (ctx) => {
|
|
224
|
+
for (const owner of owners(ctx)) {
|
|
225
|
+
for (const def of ctx.zeebe(owner, "jobPriorityDefinition")) {
|
|
226
|
+
const priority = attr(def, "priority");
|
|
227
|
+
if (priority === undefined || priority.startsWith("=") || isJavaInt(priority))
|
|
228
|
+
continue;
|
|
229
|
+
ctx.report("job-priority-value", owner.id, `Expected 'priority' to be a literal integer or a FEEL expression (starting with '='), but got '${priority}'.`, "Write the priority as an integer or a FEEL expression starting with '='.");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
// Z103, Z104
|
|
234
|
+
const sendTasks = (ctx) => {
|
|
235
|
+
for (const { node } of nodes(ctx)) {
|
|
236
|
+
if (node.type !== "sendTask")
|
|
237
|
+
continue;
|
|
238
|
+
const publish = ctx.zeebe(node, "publishMessage").length;
|
|
239
|
+
const definitions = ctx.zeebe(node, "taskDefinition").length;
|
|
240
|
+
if (!((publish === 1 && definitions === 0) || (publish === 0 && definitions === 1)))
|
|
241
|
+
ctx.report("send-task-implementation", node.id, "Must have either one 'zeebe:publishMessage' or one 'zeebe:taskDefinition' extension element", "Give the send task one zeebe:taskDefinition (or one zeebe:publishMessage).");
|
|
242
|
+
if (publish > 0 && ctx.message(node.messageRef) === undefined)
|
|
243
|
+
ctx.report("send-task-message", node.id, "Must reference a message", "Set messageRef to a message defined in the file.");
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
// Z105
|
|
247
|
+
const inputMappings = (ctx) => {
|
|
248
|
+
for (const owner of owners(ctx)) {
|
|
249
|
+
for (const input of mappings(ctx, owner, "input")) {
|
|
250
|
+
const problems = [
|
|
251
|
+
expressionProblem(attr(input, "source"), { mandatory: false, nonStatic: false }),
|
|
252
|
+
...pathProblems(attr(input, "target")),
|
|
253
|
+
];
|
|
254
|
+
for (const problem of problems) {
|
|
255
|
+
if (problem !== undefined)
|
|
256
|
+
ctx.report("input-mapping", owner.id, problem, "Use a valid FEEL source and a variable name or dotted path as target.");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
// Z106
|
|
262
|
+
const outputMappings = (ctx) => {
|
|
263
|
+
for (const owner of owners(ctx)) {
|
|
264
|
+
for (const output of mappings(ctx, owner, "output")) {
|
|
265
|
+
const problems = [
|
|
266
|
+
expressionProblem(attr(output, "source"), { mandatory: true, nonStatic: true }),
|
|
267
|
+
...pathProblems(attr(output, "target")),
|
|
268
|
+
];
|
|
269
|
+
for (const problem of problems) {
|
|
270
|
+
if (problem !== undefined)
|
|
271
|
+
ctx.report("output-mapping", owner.id, problem, "Use a FEEL expression starting with '=' as source and a variable name or dotted path as target.");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
/** `SecretReference.REFERENCE_PATTERN` (Java's `\p{Alnum}` is ASCII). */
|
|
277
|
+
const SECRET_REFERENCE = /camunda\.secrets\.[A-Za-z0-9_-]+/g;
|
|
278
|
+
/** One whole double-quoted FEEL string literal, escapes included. */
|
|
279
|
+
const STRING_LITERAL = /"[^"\\]*(?:\\.[^"\\]*)*"/g;
|
|
280
|
+
/** Zeebe parses the source; an invalid expression is reported by the expression rules instead. */
|
|
281
|
+
function parses(source) {
|
|
282
|
+
return feelError(source) === undefined;
|
|
283
|
+
}
|
|
284
|
+
/** `SecretReferenceLiteralValidator`: the references written as literal text, in order, once each. */
|
|
285
|
+
function literalSecretReferences(source) {
|
|
286
|
+
const text = isExpression(source)
|
|
287
|
+
? (source.slice(1).match(STRING_LITERAL) ?? []).join("\n")
|
|
288
|
+
: source;
|
|
289
|
+
const out = [];
|
|
290
|
+
for (const m of text.match(SECRET_REFERENCE) ?? [])
|
|
291
|
+
if (!out.includes(m))
|
|
292
|
+
out.push(m);
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
295
|
+
// Z107
|
|
296
|
+
const secretLiteral = (ctx) => {
|
|
297
|
+
const check = (owner, source, location) => {
|
|
298
|
+
if (source === undefined || !parses(source))
|
|
299
|
+
return;
|
|
300
|
+
const refs = literalSecretReferences(source);
|
|
301
|
+
if (refs.length === 0)
|
|
302
|
+
return;
|
|
303
|
+
ctx.report("secret-literal", owner.id, `Secret reference(s) ${refs.map((r) => `'${r}'`).join(", ")} must be used as an expression (e.g. '=camunda.secrets.<name>'), not as a string literal, in ${location} '${source}'.`, "Write the secret reference as a FEEL expression, outside quotes.");
|
|
304
|
+
};
|
|
305
|
+
for (const owner of owners(ctx)) {
|
|
306
|
+
for (const input of mappings(ctx, owner, "input"))
|
|
307
|
+
check(owner, attr(input, "source"), "input mapping source");
|
|
308
|
+
for (const props of ctx.zeebe(owner, "properties"))
|
|
309
|
+
for (const prop of ctx.zeebeChildren(props, "property"))
|
|
310
|
+
check(owner, attr(prop, "value"), "property value");
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
/** `camunda.secrets.<name>` exactly: feel-scala's three-segment qualified name. */
|
|
314
|
+
function isSecretPath(node) {
|
|
315
|
+
return (node.kind === "path" &&
|
|
316
|
+
node.base.kind === "path" &&
|
|
317
|
+
node.base.key === "secrets" &&
|
|
318
|
+
node.base.base.kind === "name" &&
|
|
319
|
+
node.base.base.name === "camunda");
|
|
320
|
+
}
|
|
321
|
+
/** Whether a secret reference is anywhere below the node; a longer path is not one. */
|
|
322
|
+
function containsSecret(node, isPathBase = false) {
|
|
323
|
+
if (!isPathBase && isSecretPath(node))
|
|
324
|
+
return true;
|
|
325
|
+
return feelChildren(node).some((child) => containsSecret(child, node.kind === "path" && child === node.base));
|
|
326
|
+
}
|
|
327
|
+
/** `SecretReference.containsReferenceInsideContainerLiteral`. */
|
|
328
|
+
function insideContainer(node) {
|
|
329
|
+
if (node.kind === "list" || node.kind === "context")
|
|
330
|
+
return containsSecret(node);
|
|
331
|
+
if (node.kind === "if")
|
|
332
|
+
return insideContainer(node.then) || insideContainer(node.else);
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
/** `SecretReference.isImprecise`: a root context is descended entry by entry. */
|
|
336
|
+
function isImprecise(node) {
|
|
337
|
+
if (node.kind === "context")
|
|
338
|
+
return node.entries.some((e) => isImprecise(e.value));
|
|
339
|
+
return insideContainer(node);
|
|
340
|
+
}
|
|
341
|
+
// Z108
|
|
342
|
+
const secretInList = (ctx) => {
|
|
343
|
+
for (const owner of owners(ctx)) {
|
|
344
|
+
for (const input of mappings(ctx, owner, "input")) {
|
|
345
|
+
const source = attr(input, "source");
|
|
346
|
+
if (source === undefined || !isExpression(source) || !parses(source))
|
|
347
|
+
continue;
|
|
348
|
+
const { ast } = parseExpression(source.slice(1));
|
|
349
|
+
if (ast === null || !isImprecise(ast))
|
|
350
|
+
continue;
|
|
351
|
+
ctx.report("secret-in-list", owner.id, `Input mapping source '${source}' puts a secret reference inside a list, or inside a context built by an 'if' branch. Camunda can only replace a secret where the mapping assigns it directly to a value, so this secret would never be filled in. Assign each secret reference to its own input mapping instead.`, "Map each secret reference to its own input variable.");
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const BINDING_TYPES = ["latest", "deployment", "versionTag"];
|
|
356
|
+
function linkedResources(ctx, owner) {
|
|
357
|
+
return ctx.zeebe(owner, "linkedResources").flatMap((r) => ctx.zeebeChildren(r, "linkedResource"));
|
|
358
|
+
}
|
|
359
|
+
// Z110
|
|
360
|
+
const linkedResourceAttributes = (ctx) => {
|
|
361
|
+
for (const owner of owners(ctx)) {
|
|
362
|
+
for (const res of linkedResources(ctx, owner)) {
|
|
363
|
+
const binding = attr(res, "bindingType");
|
|
364
|
+
if (binding !== undefined && !BINDING_TYPES.includes(binding)) {
|
|
365
|
+
// the model throws reading an unknown enum value, before any validator reports
|
|
366
|
+
ctx.report("linked-resource-attributes", owner.id, `No enum constant io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeBindingType.${binding}`, `Set bindingType to one of: ${BINDING_TYPES.join(", ")}.`);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
for (const name of ["resourceId", "resourceType"]) {
|
|
370
|
+
if (attr(res, name) === undefined)
|
|
371
|
+
ctx.report("linked-resource-attributes", owner.id, `Attribute '${name}' must be present and not empty`, `Set ${name} on zeebe:linkedResource.`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
// Z111: Zeebe looks only at the process's direct flow elements, and at their first zeebe:linkedResources
|
|
377
|
+
const linkedResourceDeployment = (ctx) => {
|
|
378
|
+
const resolver = ctx.resolver;
|
|
379
|
+
if (resolver === undefined)
|
|
380
|
+
return;
|
|
381
|
+
for (const { node, scope } of nodes(ctx)) {
|
|
382
|
+
if (scope.kind !== "process")
|
|
383
|
+
continue;
|
|
384
|
+
const first = ctx.zeebe(node, "linkedResources")[0];
|
|
385
|
+
for (const res of ctx.zeebeChildren(first, "linkedResource")) {
|
|
386
|
+
const id = attr(res, "resourceId");
|
|
387
|
+
if (attr(res, "bindingType") !== "deployment" || id === undefined || id.startsWith("="))
|
|
388
|
+
continue;
|
|
389
|
+
if (id.trim() === "")
|
|
390
|
+
continue;
|
|
391
|
+
const isForm = (attr(res, "resourceType") ?? "").toLowerCase() === "form";
|
|
392
|
+
const found = isForm ? resolver.hasForm?.(id) : resolver.hasResource?.(id);
|
|
393
|
+
if (found !== false)
|
|
394
|
+
continue;
|
|
395
|
+
ctx.report("linked-resource-deployment", node.id, `Expected to find ${isForm ? "form" : "resource"} with id '${id}' in current deployment, but not found.`, `Deploy the ${isForm ? "form" : "resource"} '${id}' together with the process, or bind it by 'latest'.`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const AGENT_TYPES = ["aiAgentSubProcess", "aiAgentTask", "external"];
|
|
400
|
+
// Z112 (an unknown value makes the model throw while reading it), Z113
|
|
401
|
+
const agentDefinitions = (ctx) => {
|
|
402
|
+
for (const owner of owners(ctx)) {
|
|
403
|
+
const defs = ctx.zeebe(owner, "agentDefinition");
|
|
404
|
+
for (const def of defs) {
|
|
405
|
+
const type = attr(def, "agentType");
|
|
406
|
+
if (type === undefined)
|
|
407
|
+
ctx.report("agent-type-required", owner.id, "Attribute 'agentType' must be present and not empty", `Set agentType on zeebe:agentDefinition to one of: ${AGENT_TYPES.join(", ")}.`);
|
|
408
|
+
else if (!AGENT_TYPES.includes(type))
|
|
409
|
+
ctx.report("agent-type-required", owner.id, `No enum constant io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeAgentType.${type}`, `Set agentType to one of: ${AGENT_TYPES.join(", ")}.`);
|
|
410
|
+
}
|
|
411
|
+
// AgentDefinitionValidator applies to flow elements, and only to the first definition
|
|
412
|
+
if (owner.isProcess)
|
|
413
|
+
continue;
|
|
414
|
+
const type = defs[0] === undefined ? undefined : attr(defs[0], "agentType");
|
|
415
|
+
const kind = owner.node?.type;
|
|
416
|
+
const message = type === "aiAgentSubProcess" && kind !== "adHocSubProcess"
|
|
417
|
+
? "agentType 'aiAgentSubProcess' is only allowed on an ad-hoc sub-process."
|
|
418
|
+
: type === "aiAgentTask" && kind !== "serviceTask"
|
|
419
|
+
? "agentType 'aiAgentTask' is only allowed on a service task."
|
|
420
|
+
: type === "external" && kind !== "serviceTask" && kind !== "adHocSubProcess"
|
|
421
|
+
? "agentType 'external' is only allowed on a service task or an ad-hoc sub-process."
|
|
422
|
+
: undefined;
|
|
423
|
+
if (message !== undefined)
|
|
424
|
+
ctx.report("agent-type-placement", owner.id, message, "Use the agent type that matches the element, or move the agent definition.");
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
/** Checks for zeebe-rules.md section F (see index.ts), in spec order. */
|
|
428
|
+
export const checks = [
|
|
429
|
+
serviceTaskDefinition,
|
|
430
|
+
taskDefinitionAttributes,
|
|
431
|
+
duplicateTaskExtension,
|
|
432
|
+
taskHeaders,
|
|
433
|
+
scriptTaskImplementation,
|
|
434
|
+
scripts,
|
|
435
|
+
jobPriorityMode,
|
|
436
|
+
jobPriorityValue,
|
|
437
|
+
sendTasks,
|
|
438
|
+
inputMappings,
|
|
439
|
+
outputMappings,
|
|
440
|
+
secretLiteral,
|
|
441
|
+
secretInList,
|
|
442
|
+
linkedResourceAttributes,
|
|
443
|
+
linkedResourceDeployment,
|
|
444
|
+
agentDefinitions,
|
|
445
|
+
];
|
|
446
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OptimizationFinding } from "../optimize/types.js";
|
|
2
|
+
import type { ZeebeContext } from "./context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Zeebe's parse and XSD stage (zeebe-rules.md section A, `check: "xml"`): what
|
|
5
|
+
* the text must satisfy before BPMN Kit's tolerant parser reads it. Also the
|
|
6
|
+
* missing ids Zeebe rejects (`id-present`), which BPMN Kit's parser cannot model,
|
|
7
|
+
* and `incoming`/`outgoing` references Zeebe's validators fail to resolve.
|
|
8
|
+
*
|
|
9
|
+
* @returns `fatal` when Zeebe would stop at parsing, so the model rules are not run.
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkXml(xml: string, ctx: ZeebeContext): {
|
|
12
|
+
fatal: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type { OptimizationFinding };
|
|
15
|
+
//# sourceMappingURL=xml.d.ts.map
|