@bpmnkit/core 1.9.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 +3 -3
- 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 +313 -78
- 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 +13 -3
- package/dist/bpmn/index.js +16 -15
- 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/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 +10 -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,580 @@
|
|
|
1
|
+
import { isBpmnActivity } from "../../type-guards.js";
|
|
2
|
+
import { feelError, feelFailure, isExpression, staticValueMessage, } from "../context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks for zeebe-rules.md section D (events and timers): event definition
|
|
5
|
+
* counts, event sub-process start events, timers (including the static values
|
|
6
|
+
* Zeebe evaluates at deploy time), boundary and end event shape, execution
|
|
7
|
+
* listener restrictions and conditional events.
|
|
8
|
+
*/
|
|
9
|
+
function eventDefinitions(node) {
|
|
10
|
+
switch (node.type) {
|
|
11
|
+
case "startEvent":
|
|
12
|
+
case "endEvent":
|
|
13
|
+
case "intermediateCatchEvent":
|
|
14
|
+
case "intermediateThrowEvent":
|
|
15
|
+
case "boundaryEvent":
|
|
16
|
+
return node.eventDefinitions;
|
|
17
|
+
default:
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function isEventSubProcess(node) {
|
|
22
|
+
return (node.type === "eventSubProcess" ||
|
|
23
|
+
(node.type === "subProcess" && node.triggeredByEvent === true));
|
|
24
|
+
}
|
|
25
|
+
/** The flow elements of a container, empty for anything else. */
|
|
26
|
+
function children(node) {
|
|
27
|
+
return "flowElements" in node && Array.isArray(node.flowElements) ? node.flowElements : [];
|
|
28
|
+
}
|
|
29
|
+
/** The flow elements Zeebe validates: those of executable processes, contents included. */
|
|
30
|
+
function nodes(ctx) {
|
|
31
|
+
const executable = new Set(ctx.defs.processes.filter((p) => p.isExecutable === true).map((p) => p.id));
|
|
32
|
+
return ctx.nodes.filter((n) => executable.has(n.scope.processId));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The `zeebe:executionListener` children of the single `zeebe:executionListeners`,
|
|
36
|
+
* or `undefined` when there is none or more than one: Zeebe only applies the
|
|
37
|
+
* per-element listener restrictions when exactly one is defined.
|
|
38
|
+
*/
|
|
39
|
+
function executionListeners(ctx, node) {
|
|
40
|
+
const lists = ctx.zeebe(node, "executionListeners");
|
|
41
|
+
const [list] = lists;
|
|
42
|
+
if (lists.length !== 1 || list === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
return ctx.zeebeChildren(list, "executionListener");
|
|
45
|
+
}
|
|
46
|
+
function hasListener(listeners, eventType) {
|
|
47
|
+
return listeners.some((l) => l.attributes.eventType === eventType);
|
|
48
|
+
}
|
|
49
|
+
/** Java's `Boolean.parseBoolean`. */
|
|
50
|
+
function javaBoolean(value) {
|
|
51
|
+
return value.toLowerCase() === "true";
|
|
52
|
+
}
|
|
53
|
+
/** Java's `String.trim()`: strips code points up to U+0020 only. */
|
|
54
|
+
function javaTrim(value) {
|
|
55
|
+
let start = 0;
|
|
56
|
+
let end = value.length;
|
|
57
|
+
while (start < end && value.charCodeAt(start) <= 32)
|
|
58
|
+
start += 1;
|
|
59
|
+
while (end > start && value.charCodeAt(end - 1) <= 32)
|
|
60
|
+
end -= 1;
|
|
61
|
+
return value.slice(start, end);
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// java.time parsing, as Zeebe evaluates static timer values
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
/** A failed parse: the `DateTimeParseException` message, or its prefix when Java adds detail we don't reproduce. */
|
|
67
|
+
class TimeParseError extends Error {
|
|
68
|
+
}
|
|
69
|
+
const INT_MAX = 2147483647;
|
|
70
|
+
const INT_MIN = -2147483648;
|
|
71
|
+
/** Java's `Integer.parseInt`, or `undefined` on `NumberFormatException`. */
|
|
72
|
+
function javaInt(text) {
|
|
73
|
+
if (!/^[+-]?[0-9]+$/.test(text))
|
|
74
|
+
return undefined;
|
|
75
|
+
const n = Number(text);
|
|
76
|
+
return n >= INT_MIN && n <= INT_MAX ? n : undefined;
|
|
77
|
+
}
|
|
78
|
+
const PERIOD = /^([-+]?)P(?:([-+]?[0-9]+)Y)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)W)?(?:([-+]?[0-9]+)D)?$/i;
|
|
79
|
+
/** `java.time.Period.parse`. */
|
|
80
|
+
function parsePeriod(text) {
|
|
81
|
+
const m = PERIOD.exec(text);
|
|
82
|
+
const fail = new TimeParseError("Text cannot be parsed to a Period");
|
|
83
|
+
if (m === null)
|
|
84
|
+
throw fail;
|
|
85
|
+
const groups = [m[2], m[3], m[4], m[5]];
|
|
86
|
+
if (groups.every((g) => g === undefined))
|
|
87
|
+
throw fail;
|
|
88
|
+
const values = groups.map((g) => (g === undefined ? 0 : javaInt(g)));
|
|
89
|
+
if (values.some((v) => v === undefined))
|
|
90
|
+
throw fail;
|
|
91
|
+
const days = (values[2] ?? 0) * 7 + (values[3] ?? 0);
|
|
92
|
+
if (days < INT_MIN || days > INT_MAX)
|
|
93
|
+
throw fail;
|
|
94
|
+
}
|
|
95
|
+
const DURATION = /^([-+]?)P(?:([-+]?[0-9]+)D)?(T(?:([-+]?[0-9]+)H)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)(?:[.,]([0-9]{0,9}))?S)?)?$/i;
|
|
96
|
+
/** `java.time.Duration.parse`; a number too large for a `long` overflows. */
|
|
97
|
+
function parseDuration(text) {
|
|
98
|
+
const m = DURATION.exec(text);
|
|
99
|
+
if (m === null || m[3]?.toUpperCase() === "T")
|
|
100
|
+
throw new TimeParseError("Text cannot be parsed to a Duration");
|
|
101
|
+
if (m[2] === undefined && m[3] === undefined)
|
|
102
|
+
throw new TimeParseError("Text cannot be parsed to a Duration");
|
|
103
|
+
for (const g of [m[2], m[4], m[5], m[6]]) {
|
|
104
|
+
if (g !== undefined && g.replace(/^[-+]/, "").replace(/^0+/, "").length > 18)
|
|
105
|
+
throw new TimeParseError("Text cannot be parsed to a Duration");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const ZONED = /^([-+]?[0-9]{4,10})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2})(?::([0-9]{2})(?:\.[0-9]{0,9})?)?(Z|[-+][0-9]{2}(?::[0-9]{2}(?::[0-9]{2})?)?)(?:\[([^\]]+)\])?$/i;
|
|
109
|
+
function leapYear(year) {
|
|
110
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
111
|
+
}
|
|
112
|
+
const MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
113
|
+
/**
|
|
114
|
+
* `java.time.ZonedDateTime.parse` (ISO_ZONED_DATE_TIME, strict resolver). The
|
|
115
|
+
* bracketed zone id is only checked for shape: which region ids exist depends on
|
|
116
|
+
* the JVM's time-zone data.
|
|
117
|
+
*/
|
|
118
|
+
function parseZonedDateTime(text) {
|
|
119
|
+
const fail = new TimeParseError(`Text '${text}' could not be parsed`);
|
|
120
|
+
const m = ZONED.exec(text);
|
|
121
|
+
if (m === null)
|
|
122
|
+
throw fail;
|
|
123
|
+
const yearText = m[1] ?? "";
|
|
124
|
+
const digits = yearText.replace(/^[-+]/, "").length;
|
|
125
|
+
// SignStyle.EXCEEDS_PAD: more than four digits need a sign, and a plus only comes with them.
|
|
126
|
+
if (digits > 4 && !/^[-+]/.test(yearText))
|
|
127
|
+
throw fail;
|
|
128
|
+
if (digits === 4 && yearText.startsWith("+"))
|
|
129
|
+
throw fail;
|
|
130
|
+
const year = Number(yearText);
|
|
131
|
+
const month = Number(m[2]);
|
|
132
|
+
const day = Number(m[3]);
|
|
133
|
+
if (Math.abs(year) > 999999999 || month < 1 || month > 12)
|
|
134
|
+
throw fail;
|
|
135
|
+
const maxDay = month === 2 && leapYear(Math.abs(year)) ? 29 : (MONTH_DAYS[month - 1] ?? 31);
|
|
136
|
+
if (day < 1 || day > maxDay)
|
|
137
|
+
throw fail;
|
|
138
|
+
if (Number(m[4]) > 23 || Number(m[5]) > 59 || (m[6] !== undefined && Number(m[6]) > 59))
|
|
139
|
+
throw fail;
|
|
140
|
+
const offset = m[7] ?? "Z";
|
|
141
|
+
if (offset.toUpperCase() !== "Z") {
|
|
142
|
+
const [h, min = "0", s = "0"] = offset.slice(1).split(":");
|
|
143
|
+
const seconds = Number(h) * 3600 + Number(min) * 60 + Number(s);
|
|
144
|
+
if (Number(min) > 59 || Number(s) > 59 || seconds > 18 * 3600)
|
|
145
|
+
throw fail;
|
|
146
|
+
}
|
|
147
|
+
const zone = m[8];
|
|
148
|
+
if (zone !== undefined && !/^[A-Za-z0-9~/._+:-]+$/.test(zone))
|
|
149
|
+
throw fail;
|
|
150
|
+
}
|
|
151
|
+
/** Zeebe's `Interval.parse`: `[<start>/]<period or duration>`. */
|
|
152
|
+
function parseInterval(text) {
|
|
153
|
+
const index = text.lastIndexOf("/");
|
|
154
|
+
if (index > 0)
|
|
155
|
+
parseZonedDateTime(text.slice(0, index));
|
|
156
|
+
const exp = text.slice(index + 1);
|
|
157
|
+
let sign = "";
|
|
158
|
+
let startOffset = 0;
|
|
159
|
+
if (exp.startsWith("-")) {
|
|
160
|
+
startOffset = 1;
|
|
161
|
+
sign = "-";
|
|
162
|
+
}
|
|
163
|
+
else if (exp.startsWith("+")) {
|
|
164
|
+
startOffset = 1;
|
|
165
|
+
}
|
|
166
|
+
// Case-sensitive 'T', unlike Period/Duration: a lower-case `pt5m` is read as a period.
|
|
167
|
+
const durationOffset = exp.indexOf("T");
|
|
168
|
+
if (durationOffset === -1)
|
|
169
|
+
parsePeriod(exp);
|
|
170
|
+
else if (durationOffset === startOffset + 1)
|
|
171
|
+
parseDuration(exp);
|
|
172
|
+
else {
|
|
173
|
+
parsePeriod(exp.slice(0, durationOffset));
|
|
174
|
+
parseDuration(`${sign}P${exp.slice(durationOffset)}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** Zeebe's `RepeatingInterval.parse`, for a text starting with `R`. */
|
|
178
|
+
function parseRepeatingInterval(text) {
|
|
179
|
+
const offset = text.indexOf("/");
|
|
180
|
+
if (offset === -1)
|
|
181
|
+
throw new TimeParseError("No interval given");
|
|
182
|
+
if (offset === 1) {
|
|
183
|
+
parseInterval(text.slice(2));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (javaInt(text.slice(1, offset)) === undefined)
|
|
187
|
+
throw new TimeParseError("Cannot parse repetitions count");
|
|
188
|
+
parseInterval(text.slice(offset + 1));
|
|
189
|
+
}
|
|
190
|
+
const CRON_NICKNAMES = [
|
|
191
|
+
"@yearly",
|
|
192
|
+
"@annually",
|
|
193
|
+
"@monthly",
|
|
194
|
+
"@weekly",
|
|
195
|
+
"@daily",
|
|
196
|
+
"@midnight",
|
|
197
|
+
"@hourly",
|
|
198
|
+
];
|
|
199
|
+
const CRON_RANGES = [
|
|
200
|
+
[0, 59],
|
|
201
|
+
[0, 59],
|
|
202
|
+
[0, 23],
|
|
203
|
+
[1, 31],
|
|
204
|
+
[1, 12],
|
|
205
|
+
[0, 7],
|
|
206
|
+
];
|
|
207
|
+
/**
|
|
208
|
+
* Zeebe's `CronTimer.parse` (cron-utils, Spring 5.3 definition). Only the
|
|
209
|
+
* failures that are certain are reproduced: emptiness, nicknames, the field
|
|
210
|
+
* count and plain numbers or numeric ranges out of the field's range; names,
|
|
211
|
+
* `L`, `W`, `#` and steps are accepted as they are.
|
|
212
|
+
*/
|
|
213
|
+
function parseCron(text) {
|
|
214
|
+
const trimmed = javaTrim(text);
|
|
215
|
+
if (trimmed === "")
|
|
216
|
+
throw new TimeParseError("Empty expression!");
|
|
217
|
+
// Nicknames match exactly (lower case, untrimmed); anything else starting with '@' is read as fields.
|
|
218
|
+
if (CRON_NICKNAMES.includes(text))
|
|
219
|
+
return;
|
|
220
|
+
if (text === "@reboot")
|
|
221
|
+
throw new TimeParseError("Nickname @reboot not supported!");
|
|
222
|
+
const fields = trimmed.split(/\s+/);
|
|
223
|
+
if (fields.length !== 6)
|
|
224
|
+
throw new TimeParseError(`Cron expression contains ${fields.length} parts but we expect one of [6]`);
|
|
225
|
+
const fail = (detail) => new TimeParseError(`Failed to parse cron expression. ${detail}`);
|
|
226
|
+
fields.forEach((field, i) => {
|
|
227
|
+
const [lo, hi] = CRON_RANGES[i] ?? [0, 59];
|
|
228
|
+
for (const part of field.split(",")) {
|
|
229
|
+
// `?` is only for day-of-month and day-of-week.
|
|
230
|
+
if (part === "?" && i !== 3 && i !== 5)
|
|
231
|
+
throw fail("Invalid expression: ?");
|
|
232
|
+
const m = /^(?:\*|([0-9]+)(?:-([0-9]+))?)(?:\/([0-9]+))?$/.exec(part);
|
|
233
|
+
if (m === null)
|
|
234
|
+
continue;
|
|
235
|
+
const values = [m[1], m[2]].filter((v) => v !== undefined).map(Number);
|
|
236
|
+
for (const v of values) {
|
|
237
|
+
if (v < lo || v > hi)
|
|
238
|
+
throw fail(`Value ${v} not in range [${lo}, ${hi}]`);
|
|
239
|
+
}
|
|
240
|
+
const [from = 0, to = from] = values;
|
|
241
|
+
// Day-of-month, month and day-of-week ranges may wrap around; the time fields may not.
|
|
242
|
+
if (i < 3 && from > to)
|
|
243
|
+
throw fail(`Invalid range! [${from},${to}]`);
|
|
244
|
+
const step = m[3] === undefined ? undefined : Number(m[3]);
|
|
245
|
+
if (step !== undefined && (step < 1 || step > hi))
|
|
246
|
+
throw fail(`Period ${step} not in range [${lo}, ${hi}]`);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/** The result type of Zeebe's `StaticExpression` for a static text. */
|
|
251
|
+
function staticType(text) {
|
|
252
|
+
if (text === "null")
|
|
253
|
+
return "NULL";
|
|
254
|
+
if (text === "true" || text === "false")
|
|
255
|
+
return "BOOLEAN";
|
|
256
|
+
// java.math.BigDecimal's grammar.
|
|
257
|
+
if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?$/.test(text))
|
|
258
|
+
return "NUMBER";
|
|
259
|
+
return "STRING";
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* The failure of evaluating a static timer value the way `TimerCatchEventExpressionValidator`
|
|
263
|
+
* does, or `undefined` when it is valid. A message whose Java detail we can't
|
|
264
|
+
* reproduce is cut to a prefix of Zeebe's.
|
|
265
|
+
*/
|
|
266
|
+
function staticTimerFailure(kind, text) {
|
|
267
|
+
const wrap = (detail) => `Invalid timer ${kind} expression (${detail})`;
|
|
268
|
+
const type = staticType(text);
|
|
269
|
+
if (kind === "cycle") {
|
|
270
|
+
if (type !== "STRING")
|
|
271
|
+
return wrap(`Expected result of the expression '${text}' to be 'STRING', but was '${type}'.`);
|
|
272
|
+
try {
|
|
273
|
+
if (text.startsWith("R"))
|
|
274
|
+
parseRepeatingInterval(text);
|
|
275
|
+
else
|
|
276
|
+
parseCron(text);
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
const message = e.message;
|
|
281
|
+
return message.startsWith("Text '")
|
|
282
|
+
? `Invalid timer cycle expression (${message}`
|
|
283
|
+
: wrap(message);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const types = kind === "duration" ? "[DURATION, PERIOD, STRING]" : "[DATE_TIME, STRING]";
|
|
287
|
+
if (type !== "STRING")
|
|
288
|
+
return wrap(`Expected result of the expression '${text}' to be one of '${types}', but was '${type}'.`);
|
|
289
|
+
try {
|
|
290
|
+
if (kind === "duration")
|
|
291
|
+
parseInterval(text);
|
|
292
|
+
else
|
|
293
|
+
parseZonedDateTime(text);
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
const label = kind === "duration" ? "duration" : "date-time";
|
|
298
|
+
return wrap(`Invalid ${label} format '${text}' for expression '${text}'.`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// ---------------------------------------------------------------------------
|
|
302
|
+
// Checks
|
|
303
|
+
// ---------------------------------------------------------------------------
|
|
304
|
+
function interruptingTimerCycle(ctx, elementId, defs) {
|
|
305
|
+
if (defs.some((d) => d.type === "timer" && d.timeCycle !== undefined))
|
|
306
|
+
ctx.report("interrupting-timer-cycle", elementId, "Interrupting timer event with time cycle is not allowed.", "Use a time duration or date, or make the event non-interrupting.");
|
|
307
|
+
}
|
|
308
|
+
/** Z37, Z39: start event definition count and start listeners. */
|
|
309
|
+
const startEvents = (ctx) => {
|
|
310
|
+
for (const { node } of nodes(ctx)) {
|
|
311
|
+
if (node.type !== "startEvent")
|
|
312
|
+
continue;
|
|
313
|
+
if (node.eventDefinitions.length > 1)
|
|
314
|
+
ctx.report("start-event-definitions", node.id, "Start event can't have more than one type", "Keep one event definition on the start event.");
|
|
315
|
+
const listeners = executionListeners(ctx, node);
|
|
316
|
+
if (listeners !== undefined && hasListener(listeners, "start"))
|
|
317
|
+
ctx.report("start-event-start-listener", node.id, "Execution listeners of type 'start' are not supported by start events", "Use an 'end' execution listener on the start event.");
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
/** Z38: a start event form with public access, unsupported since public forms were removed. */
|
|
321
|
+
const publicAccessForm = (ctx) => {
|
|
322
|
+
for (const { node } of nodes(ctx)) {
|
|
323
|
+
if (node.type !== "startEvent")
|
|
324
|
+
continue;
|
|
325
|
+
const enabled = ctx
|
|
326
|
+
.zeebe(node, "properties")
|
|
327
|
+
.flatMap((p) => ctx.zeebeChildren(p, "property"))
|
|
328
|
+
.some((p) => p.attributes.name === "publicAccess" && javaBoolean(p.attributes.value ?? ""));
|
|
329
|
+
if (enabled)
|
|
330
|
+
ctx.report("start-form-public-access", node.id, "Start event forms with public access enabled are not supported. Please remove the 'publicAccess' property or set it to 'false'", "Remove the 'publicAccess' property from the start event.");
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Z40-Z43 for event sub-processes. Zeebe validates only the first start event,
|
|
335
|
+
* and names the event sub-process.
|
|
336
|
+
*/
|
|
337
|
+
const eventSubProcessStarts = (ctx) => {
|
|
338
|
+
for (const { node, scope } of nodes(ctx)) {
|
|
339
|
+
if (!isEventSubProcess(node))
|
|
340
|
+
continue;
|
|
341
|
+
const start = children(node).find((c) => c.type === "startEvent");
|
|
342
|
+
if (start === undefined || start.type !== "startEvent")
|
|
343
|
+
continue;
|
|
344
|
+
const defs = start.eventDefinitions;
|
|
345
|
+
const typed = "Start events in event subprocesses must be one of: message, timer, error, signal, escalation or conditional";
|
|
346
|
+
const suggestion = "Give the event sub-process start event a message, timer, error, signal, escalation or conditional trigger.";
|
|
347
|
+
if (defs.length === 0)
|
|
348
|
+
ctx.report("event-sub-process-start-typed", node.id, typed, suggestion);
|
|
349
|
+
if (defs.some((d) => d.type === "compensate") && scope.kind === "process")
|
|
350
|
+
ctx.report("compensation-event-sub-process-level", node.id, "A compensation event subprocess is not allowed on the process level", "Move the compensation event sub-process into a sub-process.");
|
|
351
|
+
// A typed but unsupported trigger is Z17 (event-sub-process-start-type, structure.ts).
|
|
352
|
+
const interrupting = start.isInterrupting !== false;
|
|
353
|
+
if (interrupting)
|
|
354
|
+
interruptingTimerCycle(ctx, node.id, defs);
|
|
355
|
+
if (interrupting && scope.kind === "adHocSubProcess")
|
|
356
|
+
ctx.report("interrupting-event-sub-process-in-ad-hoc", node.id, "An interrupting event subprocess is not allowed inside an ad-hoc subprocess", "Make the event sub-process non-interrupting.");
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
/** Z43 for boundary events: `cancelActivity` defaults to true. */
|
|
360
|
+
const boundaryTimerCycle = (ctx) => {
|
|
361
|
+
for (const { node } of nodes(ctx)) {
|
|
362
|
+
if (node.type === "boundaryEvent" && node.cancelActivity !== false)
|
|
363
|
+
interruptingTimerCycle(ctx, node.id, node.eventDefinitions);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
function timerDefs(node) {
|
|
367
|
+
return eventDefinitions(node).filter((d) => d.type === "timer");
|
|
368
|
+
}
|
|
369
|
+
/** Z44: exactly one of timeDuration / timeDate / timeCycle, on any timer definition. */
|
|
370
|
+
const timerOneValue = (ctx) => {
|
|
371
|
+
for (const { node } of nodes(ctx)) {
|
|
372
|
+
for (const def of timerDefs(node)) {
|
|
373
|
+
const count = [def.timeDate, def.timeDuration, def.timeCycle].filter((v) => v !== undefined).length;
|
|
374
|
+
if (count !== 1)
|
|
375
|
+
ctx.report("timer-one-value", node.id, "Must be exactly one type of timer: timeDuration, timeDate or timeCycle", "Give the timer exactly one of time duration, time date or time cycle.");
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
/** Z45, Z57: an intermediate catch event has one definition; a timer one needs a duration or date. */
|
|
380
|
+
const intermediateCatch = (ctx) => {
|
|
381
|
+
for (const { node } of nodes(ctx)) {
|
|
382
|
+
if (node.type !== "intermediateCatchEvent")
|
|
383
|
+
continue;
|
|
384
|
+
const [def] = node.eventDefinitions;
|
|
385
|
+
if (node.eventDefinitions.length !== 1 || def === undefined) {
|
|
386
|
+
ctx.report("intermediate-catch-definitions", node.id, "Must have exactly one event definition", "Give the intermediate catch event exactly one event definition.");
|
|
387
|
+
}
|
|
388
|
+
else if (def.type === "timer" &&
|
|
389
|
+
def.timeDuration === undefined &&
|
|
390
|
+
def.timeDate === undefined) {
|
|
391
|
+
ctx.report("intermediate-timer-value", node.id, "Intermediate timer catch event must have either a time duration or a time date.", "Use a time duration or time date on the intermediate timer.");
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
function isCatchEvent(node) {
|
|
396
|
+
return (node.type === "startEvent" ||
|
|
397
|
+
node.type === "intermediateCatchEvent" ||
|
|
398
|
+
node.type === "boundaryEvent");
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Z46: every timer value must parse as FEEL; on catch events Zeebe also
|
|
402
|
+
* evaluates the static value (duration, then cycle, then date, whichever comes
|
|
403
|
+
* first). Process start events evaluate FEEL too, without variables; that needs
|
|
404
|
+
* a FEEL engine identical to Zeebe's, so only static values are evaluated here.
|
|
405
|
+
*/
|
|
406
|
+
const timerExpression = (ctx) => {
|
|
407
|
+
for (const { node } of nodes(ctx)) {
|
|
408
|
+
for (const def of timerDefs(node)) {
|
|
409
|
+
for (const text of [def.timeDate, def.timeDuration, def.timeCycle]) {
|
|
410
|
+
if (text !== undefined && feelError(text) !== undefined)
|
|
411
|
+
ctx.report("timer-expression", node.id, feelFailure(text), "Fix the FEEL syntax of the timer expression.");
|
|
412
|
+
}
|
|
413
|
+
if (!isCatchEvent(node))
|
|
414
|
+
continue;
|
|
415
|
+
const [kind, text] = def.timeDuration !== undefined
|
|
416
|
+
? ["duration", def.timeDuration]
|
|
417
|
+
: def.timeCycle !== undefined
|
|
418
|
+
? ["cycle", def.timeCycle]
|
|
419
|
+
: ["date", def.timeDate];
|
|
420
|
+
if (text === undefined || isExpression(text))
|
|
421
|
+
continue;
|
|
422
|
+
const failure = staticTimerFailure(kind, text);
|
|
423
|
+
if (failure !== undefined)
|
|
424
|
+
ctx.report("timer-expression", node.id, failure, kind === "duration"
|
|
425
|
+
? "Use an ISO-8601 duration such as PT5M, or a FEEL expression starting with '='."
|
|
426
|
+
: kind === "date"
|
|
427
|
+
? "Use an ISO-8601 date-time with offset such as 2030-01-01T09:00:00Z, or a FEEL expression."
|
|
428
|
+
: "Use an ISO-8601 repeating interval such as R3/PT10M or a 6-field cron expression.");
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
/** Every association of the model, as Zeebe's `getModelElementsByType(Association)` sees them. */
|
|
433
|
+
function associations(ctx) {
|
|
434
|
+
const out = [];
|
|
435
|
+
for (const c of ctx.defs.collaborations)
|
|
436
|
+
out.push(...(c.associations ?? []));
|
|
437
|
+
for (const p of ctx.defs.processes)
|
|
438
|
+
out.push(...p.associations);
|
|
439
|
+
for (const { node } of ctx.nodes) {
|
|
440
|
+
if ("associations" in node && Array.isArray(node.associations))
|
|
441
|
+
out.push(...node.associations);
|
|
442
|
+
}
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
/** Z48-Z52: boundary event attachment, flows, definition count and listeners. */
|
|
446
|
+
const boundaryEvents = (ctx) => {
|
|
447
|
+
let all;
|
|
448
|
+
for (const { node } of nodes(ctx)) {
|
|
449
|
+
if (node.type !== "boundaryEvent")
|
|
450
|
+
continue;
|
|
451
|
+
const host = ctx.node(node.attachedToRef)?.node;
|
|
452
|
+
// A reference to a non-activity fails Zeebe's parse with a ClassCastException; it is just as undeployable.
|
|
453
|
+
if (host === undefined || !isBpmnActivity(host))
|
|
454
|
+
ctx.report("boundary-attached", node.id, "Must be attached to an activity", "Attach the boundary event to an activity.");
|
|
455
|
+
if (ctx.incoming(node.id).length > 0)
|
|
456
|
+
ctx.report("boundary-incoming", node.id, "Cannot have incoming sequence flows", "Remove the sequence flows into the boundary event.");
|
|
457
|
+
const defs = node.eventDefinitions;
|
|
458
|
+
if (defs.some((d) => d.type === "compensate")) {
|
|
459
|
+
all ??= associations(ctx);
|
|
460
|
+
const associated = all.some((a) => a.sourceRef === node.id);
|
|
461
|
+
if (ctx.outgoing(node.id).length > 0 || !associated)
|
|
462
|
+
ctx.report("compensation-boundary-shape", node.id, "Compensation boundary events must have a compensation association and no outgoing sequence flows", "Connect the compensation boundary event to its handler with an association, not a sequence flow.");
|
|
463
|
+
}
|
|
464
|
+
if (defs.length !== 1)
|
|
465
|
+
ctx.report("boundary-event-definitions", node.id, "Must have exactly one event definition", "Give the boundary event exactly one event definition.");
|
|
466
|
+
const listeners = executionListeners(ctx, node);
|
|
467
|
+
const [first] = defs;
|
|
468
|
+
if (listeners === undefined || first === undefined)
|
|
469
|
+
continue;
|
|
470
|
+
if (first.type === "compensate")
|
|
471
|
+
ctx.report("boundary-listeners", node.id, "Execution listeners of type 'start' and 'end' are not supported by [compensation] boundary events", "Remove the execution listeners from the compensation boundary event.");
|
|
472
|
+
else if (hasListener(listeners, "start"))
|
|
473
|
+
ctx.report("boundary-listeners", node.id, "Execution listeners of type 'start' are not supported by boundary events", "Use an 'end' execution listener on the boundary event.");
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
/** Z53-Z56: end event flows, definition count, waitForCompletion and error end listeners. */
|
|
477
|
+
const endEvents = (ctx) => {
|
|
478
|
+
for (const { node } of nodes(ctx)) {
|
|
479
|
+
if (node.type === "intermediateThrowEvent") {
|
|
480
|
+
const compensations = node.eventDefinitions.filter((d) => d.type === "compensate");
|
|
481
|
+
const wait = compensations.length === 1
|
|
482
|
+
? compensations[0]?.unknownAttributes?.waitForCompletion
|
|
483
|
+
: undefined;
|
|
484
|
+
if (wait !== undefined && !javaBoolean(wait))
|
|
485
|
+
ctx.report("compensation-wait-for-completion", node.id, "A compensation intermediate throwing event waitForCompletion attribute must be true or not present", "Remove waitForCompletion or set it to true.");
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (node.type !== "endEvent")
|
|
489
|
+
continue;
|
|
490
|
+
if (ctx.outgoing(node.id).length > 0)
|
|
491
|
+
ctx.report("end-event-outgoing", node.id, "End events must not have outgoing sequence flows to other elements.", "Remove the outgoing sequence flows of the end event.");
|
|
492
|
+
const defs = node.eventDefinitions;
|
|
493
|
+
if (defs.length > 1)
|
|
494
|
+
ctx.report("end-event-definitions", node.id, "Must have at most one event definition", "Keep at most one event definition on the end event.");
|
|
495
|
+
for (const def of defs) {
|
|
496
|
+
const wait = def.type === "compensate" ? def.unknownAttributes?.waitForCompletion : undefined;
|
|
497
|
+
if (wait !== undefined && !javaBoolean(wait))
|
|
498
|
+
ctx.report("compensation-wait-for-completion", node.id, "A compensation end event waitForCompletion attribute must be true or not present", "Remove waitForCompletion or set it to true.");
|
|
499
|
+
}
|
|
500
|
+
const listeners = executionListeners(ctx, node);
|
|
501
|
+
if (listeners !== undefined && defs[0]?.type === "error" && hasListener(listeners, "end"))
|
|
502
|
+
ctx.report("error-end-end-listener", node.id, "Execution listeners of type 'end' are not supported by [error] end events", "Use a 'start' execution listener on the error end event.");
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
/** Z58: a conditional event's condition must be a FEEL expression that parses. */
|
|
506
|
+
const conditionalCondition = (ctx) => {
|
|
507
|
+
for (const { node } of nodes(ctx)) {
|
|
508
|
+
for (const def of eventDefinitions(node)) {
|
|
509
|
+
if (def.type !== "conditional" || def.condition === undefined)
|
|
510
|
+
continue;
|
|
511
|
+
const text = def.condition;
|
|
512
|
+
if (!isExpression(text))
|
|
513
|
+
ctx.report("conditional-condition", node.id, staticValueMessage(text), "Write the condition as a FEEL expression starting with '='.");
|
|
514
|
+
else if (feelError(text) !== undefined)
|
|
515
|
+
ctx.report("conditional-condition", node.id, feelFailure(text), "Fix the FEEL syntax of the condition.");
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
/** Z59: `zeebe:conditionalFilter` variableEvents, wherever the filter is. */
|
|
520
|
+
const conditionalFilter = (ctx) => {
|
|
521
|
+
const check = (entry, filters) => {
|
|
522
|
+
for (const filter of filters) {
|
|
523
|
+
const events = filter.attributes.variableEvents;
|
|
524
|
+
if (events === undefined || javaTrim(events) === "")
|
|
525
|
+
continue;
|
|
526
|
+
for (const raw of events.split(",")) {
|
|
527
|
+
const event = javaTrim(raw);
|
|
528
|
+
if (event !== "" && event !== "create" && event !== "update")
|
|
529
|
+
ctx.report("conditional-filter-events", entry.node.id, `Variable event '${event}' is not valid. Must be one of: create, update or a comma-separated list of both.`, "Use 'create', 'update' or 'create,update' as variable events.");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
for (const entry of nodes(ctx)) {
|
|
534
|
+
check(entry, ctx.zeebe(entry.node, "conditionalFilter"));
|
|
535
|
+
for (const def of eventDefinitions(entry.node)) {
|
|
536
|
+
if (def.type === "conditional")
|
|
537
|
+
check(entry, ctx.zeebe(def, "conditionalFilter"));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
/** Z60: the conditional catch events after an event-based gateway need distinct conditions. */
|
|
542
|
+
const eventBasedGatewayConditions = (ctx) => {
|
|
543
|
+
for (const { node } of nodes(ctx)) {
|
|
544
|
+
if (node.type !== "eventBasedGateway")
|
|
545
|
+
continue;
|
|
546
|
+
const conditions = [];
|
|
547
|
+
for (const { flow } of ctx.outgoing(node.id)) {
|
|
548
|
+
const target = ctx.node(flow.targetRef)?.node;
|
|
549
|
+
if (target?.type !== "intermediateCatchEvent")
|
|
550
|
+
continue;
|
|
551
|
+
for (const def of target.eventDefinitions) {
|
|
552
|
+
if (def.type === "conditional" && def.condition !== undefined && def.condition !== "")
|
|
553
|
+
conditions.push(javaTrim(def.condition));
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const reported = [];
|
|
557
|
+
conditions.forEach((c, i) => {
|
|
558
|
+
if (conditions.indexOf(c) !== i && !reported.includes(c)) {
|
|
559
|
+
reported.push(c);
|
|
560
|
+
ctx.report("event-based-gateway-duplicate-condition", node.id, `Multiple conditional event definitions with the same condition expression '${c}' are not allowed.`, "Give each conditional event after the gateway a different condition.");
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
/** Checks for zeebe-rules.md section D, in spec order (see index.ts). */
|
|
566
|
+
export const checks = [
|
|
567
|
+
startEvents,
|
|
568
|
+
publicAccessForm,
|
|
569
|
+
eventSubProcessStarts,
|
|
570
|
+
boundaryTimerCycle,
|
|
571
|
+
timerOneValue,
|
|
572
|
+
intermediateCatch,
|
|
573
|
+
timerExpression,
|
|
574
|
+
boundaryEvents,
|
|
575
|
+
endEvents,
|
|
576
|
+
conditionalCondition,
|
|
577
|
+
conditionalFilter,
|
|
578
|
+
eventBasedGatewayConditions,
|
|
579
|
+
];
|
|
580
|
+
//# sourceMappingURL=events.js.map
|