@bpmnkit/core 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/AGENTS.md +19 -0
  2. package/README.md +2 -0
  3. package/agent-cards/bpmn.md +88 -0
  4. package/agent-cards/dmn.md +105 -0
  5. package/agent-cards/form.md +72 -0
  6. package/dist/bpmn/auto-layout.js +2 -1
  7. package/dist/bpmn/bpmn-builder.d.ts +2 -2
  8. package/dist/bpmn/bpmn-builder.js +27 -6
  9. package/dist/bpmn/camunda7/migrate.d.ts +1 -1
  10. package/dist/bpmn/camunda7/migrate.js +1 -1
  11. package/dist/bpmn/compact.js +3 -0
  12. package/dist/bpmn/full-operations.js +2 -0
  13. package/dist/bpmn/index.d.ts +9 -1
  14. package/dist/bpmn/index.js +18 -23
  15. package/dist/bpmn/optimize/deploy.js +14 -0
  16. package/dist/bpmn/optimize/index.d.ts +2 -0
  17. package/dist/bpmn/optimize/index.js +5 -0
  18. package/dist/bpmn/optimize/types.d.ts +7 -0
  19. package/dist/bpmn/stable-ids.d.ts +15 -0
  20. package/dist/bpmn/stable-ids.js +26 -0
  21. package/dist/bpmn/svg.js +5 -6
  22. package/dist/bpmn/xsd-guards.d.ts +8 -0
  23. package/dist/bpmn/xsd-guards.js +56 -0
  24. package/dist/check-finding.d.ts +19 -0
  25. package/dist/check-finding.js +5 -0
  26. package/dist/dmn/compact.js +14 -5
  27. package/dist/dmn/dmn-builder.js +3 -3
  28. package/dist/dmn/drd-builder.d.ts +53 -0
  29. package/dist/dmn/drd-builder.js +100 -0
  30. package/dist/dmn/index.d.ts +35 -0
  31. package/dist/dmn/index.js +36 -0
  32. package/dist/dmn/lint.d.ts +19 -0
  33. package/dist/dmn/lint.js +414 -0
  34. package/dist/form/form-builder.d.ts +9 -1
  35. package/dist/form/form-builder.js +34 -1
  36. package/dist/form/form-model.d.ts +7 -0
  37. package/dist/form/form-parser.js +22 -0
  38. package/dist/form/form-serializer.js +10 -0
  39. package/dist/form/index.d.ts +11 -2
  40. package/dist/form/index.js +10 -1
  41. package/dist/form/lint.d.ts +19 -0
  42. package/dist/form/lint.js +356 -0
  43. package/dist/index.d.ts +14 -3
  44. package/dist/index.js +10 -2
  45. package/dist/layout/grid/edge-labels.d.ts +7 -1
  46. package/dist/layout/grid/edge-labels.js +62 -1
  47. package/dist/layout/semantic/index.js +78 -8
  48. package/dist/layout/semantic/place.d.ts +19 -4
  49. package/dist/layout/semantic/place.js +232 -34
  50. package/dist/layout/semantic/route.js +47 -14
  51. package/llms.txt +9 -0
  52. package/package.json +5 -1
@@ -0,0 +1,414 @@
1
+ import { parseExpression, parseUnaryTests } from "@bpmnkit/feel";
2
+ import { withCardHint } from "../check-finding.js";
3
+ import { parseXml } from "../xml/xml-parser.js";
4
+ const HIT_POLICIES = [
5
+ "UNIQUE",
6
+ "FIRST",
7
+ "PRIORITY",
8
+ "ANY",
9
+ "COLLECT",
10
+ "RULE ORDER",
11
+ "OUTPUT ORDER",
12
+ ];
13
+ const AGGREGATIONS = ["SUM", "MIN", "MAX", "COUNT"];
14
+ /** The type names Camunda's DMN engine resolves; anything else is silently treated as `Any`. */
15
+ const TYPE_REFS = new Set([
16
+ "string",
17
+ "number",
18
+ "boolean",
19
+ "date",
20
+ "time",
21
+ "dateTime",
22
+ "date and time",
23
+ "dayTimeDuration",
24
+ "days and time duration",
25
+ "yearMonthDuration",
26
+ "years and months duration",
27
+ "duration",
28
+ "context",
29
+ "list",
30
+ "Any",
31
+ ]);
32
+ /** Which DRG element each requirement reference must point at. */
33
+ const REQUIREMENT_TARGET = {
34
+ requiredDecision: "decision",
35
+ requiredInput: "inputData",
36
+ requiredKnowledge: "businessKnowledgeModel",
37
+ requiredAuthority: "knowledgeSource",
38
+ };
39
+ const DRG_ELEMENTS = new Set(["decision", "inputData", "businessKnowledgeModel", "knowledgeSource"]);
40
+ function local(el) {
41
+ const i = el.name.indexOf(":");
42
+ return i === -1 ? el.name : el.name.slice(i + 1);
43
+ }
44
+ function child(el, name) {
45
+ return el.children.find((c) => local(c) === name);
46
+ }
47
+ function childrenNamed(el, name) {
48
+ return el.children.filter((c) => local(c) === name);
49
+ }
50
+ function textOf(el) {
51
+ if (el === undefined)
52
+ return "";
53
+ return (child(el, "text")?.text ?? "").trim();
54
+ }
55
+ function* walk(el) {
56
+ yield el;
57
+ for (const c of el.children)
58
+ yield* walk(c);
59
+ }
60
+ /**
61
+ * Checks a DMN document for the mistakes Zeebe either rejects at deploy time
62
+ * or reports with an error that hides the cause: malformed XML, duplicate ids,
63
+ * requirement references that resolve to nothing, FEEL that does not parse,
64
+ * invalid hit policies and unknown types.
65
+ *
66
+ * Reads the raw XML rather than the `Dmn` model so a document the model
67
+ * cannot represent is still reported on instead of thrown away.
68
+ *
69
+ * @param xml - The DMN document's text.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * for (const f of lintDmn(xml)) console.log(`${f.rule} [${f.elementId}] ${f.message} — ${f.fix}`)
74
+ * ```
75
+ */
76
+ export function lintDmn(xml) {
77
+ return withCardHint(lintDmnFindings(xml), "dmn");
78
+ }
79
+ function lintDmnFindings(xml) {
80
+ let root;
81
+ try {
82
+ root = parseXml(xml);
83
+ }
84
+ catch (err) {
85
+ return [
86
+ {
87
+ rule: "dmn/malformed-xml",
88
+ severity: "error",
89
+ message: `The document is not well-formed XML: ${err.message}`,
90
+ fix: "Fix the XML syntax (unclosed or mismatched tags, unquoted attributes, a stray `&` written instead of `&`).",
91
+ },
92
+ ];
93
+ }
94
+ if (local(root) !== "definitions") {
95
+ return [
96
+ {
97
+ rule: "dmn/not-dmn",
98
+ severity: "error",
99
+ message: `The root element is <${root.name}>, not <definitions>.`,
100
+ fix: 'Wrap the decisions in <definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/">.',
101
+ },
102
+ ];
103
+ }
104
+ const findings = [];
105
+ const byId = new Map();
106
+ for (const el of walk(root)) {
107
+ const id = el.attributes.id;
108
+ if (id === undefined)
109
+ continue;
110
+ if (byId.has(id)) {
111
+ findings.push({
112
+ rule: "dmn/duplicate-id",
113
+ severity: "error",
114
+ elementId: id,
115
+ message: `The id "${id}" is used by more than one element (<${byId.get(id)?.name}> and <${el.name}>).`,
116
+ fix: "Give one of them a different id; ids must be unique across the whole document.",
117
+ });
118
+ }
119
+ else {
120
+ byId.set(id, el);
121
+ }
122
+ }
123
+ const drg = root.children.filter((c) => DRG_ELEMENTS.has(local(c)));
124
+ for (const el of drg) {
125
+ if (el.attributes.id === undefined || el.attributes.id === "") {
126
+ findings.push({
127
+ rule: "dmn/missing-id",
128
+ severity: "error",
129
+ message: `A <${el.name}>${el.attributes.name ? ` named "${el.attributes.name}"` : ""} has no id.`,
130
+ fix: "Add an id attribute — requirements and zeebe:calledDecision reference elements by id.",
131
+ });
132
+ }
133
+ }
134
+ const decisions = drg.filter((el) => local(el) === "decision");
135
+ if (decisions.length === 0) {
136
+ findings.push({
137
+ rule: "dmn/no-decision",
138
+ severity: "error",
139
+ message: "The document contains no <decision>.",
140
+ fix: "Add at least one <decision> with a <decisionTable> or <literalExpression>; Zeebe rejects a DRG without decisions.",
141
+ });
142
+ }
143
+ for (const el of drg)
144
+ checkRequirements(el, byId, findings);
145
+ checkCycles(decisions, findings);
146
+ for (const decision of decisions)
147
+ checkDecision(decision, findings);
148
+ return findings;
149
+ }
150
+ function hrefTarget(href) {
151
+ if (href === undefined || !href.startsWith("#"))
152
+ return undefined;
153
+ return href.slice(1);
154
+ }
155
+ function checkRequirements(owner, byId, findings) {
156
+ const ownerId = owner.attributes.id;
157
+ for (const req of owner.children) {
158
+ const kind = local(req);
159
+ if (!kind.endsWith("Requirement"))
160
+ continue;
161
+ for (const ref of req.children) {
162
+ const refKind = local(ref);
163
+ const expected = REQUIREMENT_TARGET[refKind];
164
+ if (expected === undefined)
165
+ continue;
166
+ const href = ref.attributes.href;
167
+ // A reference into another file (`other.dmn#id`) is resolved at deploy time, not here.
168
+ if (href !== undefined && href !== "" && !href.startsWith("#"))
169
+ continue;
170
+ const id = hrefTarget(href);
171
+ const target = id === undefined ? undefined : byId.get(id);
172
+ if (id === undefined || id === "") {
173
+ findings.push({
174
+ rule: "dmn/unresolved-requirement",
175
+ severity: "error",
176
+ ...(ownerId !== undefined ? { elementId: ownerId } : {}),
177
+ message: `<${kind}> on "${ownerId ?? "?"}" has a <${refKind}> with no href.`,
178
+ fix: `Set href="#<id of the ${expected}>".`,
179
+ });
180
+ }
181
+ else if (target === undefined) {
182
+ findings.push({
183
+ rule: "dmn/unresolved-requirement",
184
+ severity: "error",
185
+ ...(ownerId !== undefined ? { elementId: ownerId } : {}),
186
+ message: `<${refKind} href="${href}"> on "${ownerId ?? "?"}" points at "${id}", which does not exist.`,
187
+ fix: `Point it at the id of an existing <${expected}>, or add a <${expected} id="${id}">.`,
188
+ });
189
+ }
190
+ else if (local(target) !== expected) {
191
+ findings.push({
192
+ rule: "dmn/unresolved-requirement",
193
+ severity: "error",
194
+ ...(ownerId !== undefined ? { elementId: ownerId } : {}),
195
+ message: `<${refKind} href="${href}"> on "${ownerId ?? "?"}" points at a <${target.name}>, not a <${expected}>.`,
196
+ fix: local(target) === "inputData"
197
+ ? "Use <requiredInput> for input data."
198
+ : local(target) === "decision"
199
+ ? "Use <requiredDecision> for a decision."
200
+ : `Point it at a <${expected}>.`,
201
+ });
202
+ }
203
+ }
204
+ }
205
+ }
206
+ function checkCycles(decisions, findings) {
207
+ const requires = new Map();
208
+ for (const d of decisions) {
209
+ const id = d.attributes.id;
210
+ if (id === undefined)
211
+ continue;
212
+ const deps = [];
213
+ for (const req of childrenNamed(d, "informationRequirement")) {
214
+ const target = hrefTarget(child(req, "requiredDecision")?.attributes.href);
215
+ if (target !== undefined)
216
+ deps.push(target);
217
+ }
218
+ requires.set(id, deps);
219
+ }
220
+ const state = new Map();
221
+ const reported = new Set();
222
+ const visit = (id, path) => {
223
+ if (state.get(id) === "done")
224
+ return;
225
+ if (state.get(id) === "visiting") {
226
+ const cycle = [...path.slice(path.indexOf(id)), id];
227
+ if (!reported.has(id)) {
228
+ reported.add(id);
229
+ findings.push({
230
+ rule: "dmn/requirement-cycle",
231
+ severity: "error",
232
+ elementId: id,
233
+ message: `Decisions require each other in a cycle: ${cycle.join(" → ")}.`,
234
+ fix: "Remove one of the <requiredDecision> references so the requirement graph is acyclic.",
235
+ });
236
+ }
237
+ return;
238
+ }
239
+ state.set(id, "visiting");
240
+ for (const dep of requires.get(id) ?? []) {
241
+ if (requires.has(dep))
242
+ visit(dep, [...path, id]);
243
+ }
244
+ state.set(id, "done");
245
+ };
246
+ for (const id of requires.keys())
247
+ visit(id, []);
248
+ }
249
+ function checkTypeRef(el, elementId, what, findings) {
250
+ const typeRef = el.attributes.typeRef;
251
+ if (typeRef === undefined || typeRef === "" || TYPE_REFS.has(typeRef))
252
+ return;
253
+ const lower = typeRef.toLowerCase();
254
+ const suggestion = [...TYPE_REFS].find((t) => t.toLowerCase() === lower);
255
+ findings.push({
256
+ rule: "dmn/invalid-type-ref",
257
+ severity: "warning",
258
+ ...(elementId !== undefined ? { elementId } : {}),
259
+ message: `${what} has typeRef "${typeRef}", which is not a DMN/FEEL type; the engine treats the value as untyped.`,
260
+ fix: suggestion !== undefined
261
+ ? `Use typeRef="${suggestion}" (type names are case-sensitive).`
262
+ : "Use one of string, number, boolean, date, time, dateTime, dayTimeDuration, yearMonthDuration, context, list or Any.",
263
+ });
264
+ }
265
+ function checkFeel(text, mode, elementId, what, findings) {
266
+ if (text === "")
267
+ return;
268
+ const { errors } = mode === "unary" ? parseUnaryTests(text) : parseExpression(text);
269
+ const first = errors[0];
270
+ if (first === undefined)
271
+ return;
272
+ findings.push({
273
+ rule: "dmn/feel-syntax",
274
+ severity: "error",
275
+ ...(elementId !== undefined ? { elementId } : {}),
276
+ message: `${what} is not valid FEEL${mode === "unary" ? " unary tests" : ""}: ${first.message} (at ${first.start}) in \`${text}\`.`,
277
+ fix: mode === "unary"
278
+ ? 'Write unary tests: a value (`"gold"`, `42`), a comparison (`> 10`), a range (`[1..5]`), a list (`"a","b"`), `not(...)`, or `-` for any.'
279
+ : "Fix the FEEL expression; strings need double quotes and DMN entries have no leading `=`.",
280
+ });
281
+ }
282
+ function checkDecision(decision, findings) {
283
+ const decisionId = decision.attributes.id;
284
+ const label = `Decision "${decision.attributes.name ?? decisionId ?? "?"}"`;
285
+ const table = child(decision, "decisionTable");
286
+ const literal = child(decision, "literalExpression");
287
+ const variable = child(decision, "variable");
288
+ if (variable !== undefined)
289
+ checkTypeRef(variable, decisionId, `${label}'s variable`, findings);
290
+ if (literal !== undefined) {
291
+ checkTypeRef(literal, decisionId, `${label}'s literal expression`, findings);
292
+ const text = textOf(literal);
293
+ if (text === "") {
294
+ findings.push({
295
+ rule: "dmn/empty-expression",
296
+ severity: "error",
297
+ ...(decisionId !== undefined ? { elementId: decisionId } : {}),
298
+ message: `${label} has an empty literal expression.`,
299
+ fix: "Put a FEEL expression in <literalExpression><text>…</text></literalExpression>.",
300
+ });
301
+ }
302
+ checkFeel(text, "expression", decisionId, `${label}'s literal expression`, findings);
303
+ }
304
+ if (table === undefined) {
305
+ if (literal === undefined) {
306
+ findings.push({
307
+ rule: "dmn/decision-no-logic",
308
+ severity: "error",
309
+ ...(decisionId !== undefined ? { elementId: decisionId } : {}),
310
+ message: `${label} has neither a <decisionTable> nor a <literalExpression>.`,
311
+ fix: "Add a decision table or a literal expression; Zeebe cannot evaluate an empty decision.",
312
+ });
313
+ }
314
+ return;
315
+ }
316
+ const tableId = table.attributes.id ?? decisionId;
317
+ const hitPolicy = table.attributes.hitPolicy;
318
+ if (hitPolicy !== undefined && !HIT_POLICIES.includes(hitPolicy)) {
319
+ const upper = hitPolicy.toUpperCase().replace(/_/g, " ");
320
+ findings.push({
321
+ rule: "dmn/invalid-hit-policy",
322
+ severity: "error",
323
+ ...(tableId !== undefined ? { elementId: tableId } : {}),
324
+ message: `${label} has hitPolicy "${hitPolicy}".`,
325
+ fix: HIT_POLICIES.includes(upper)
326
+ ? `Write hitPolicy="${upper}".`
327
+ : `Use one of ${HIT_POLICIES.join(", ")} (UNIQUE when omitted).`,
328
+ });
329
+ }
330
+ const aggregation = table.attributes.aggregation;
331
+ if (aggregation !== undefined) {
332
+ if (!AGGREGATIONS.includes(aggregation)) {
333
+ findings.push({
334
+ rule: "dmn/invalid-aggregation",
335
+ severity: "error",
336
+ ...(tableId !== undefined ? { elementId: tableId } : {}),
337
+ message: `${label} has aggregation "${aggregation}".`,
338
+ fix: `Use one of ${AGGREGATIONS.join(", ")}.`,
339
+ });
340
+ }
341
+ else if (hitPolicy !== "COLLECT") {
342
+ findings.push({
343
+ rule: "dmn/invalid-aggregation",
344
+ severity: "error",
345
+ ...(tableId !== undefined ? { elementId: tableId } : {}),
346
+ message: `${label} sets aggregation "${aggregation}" with hitPolicy "${hitPolicy ?? "UNIQUE"}".`,
347
+ fix: 'Aggregation only applies to hitPolicy="COLLECT" — set that, or remove the aggregation.',
348
+ });
349
+ }
350
+ }
351
+ const inputs = childrenNamed(table, "input");
352
+ const outputs = childrenNamed(table, "output");
353
+ if (outputs.length === 0) {
354
+ findings.push({
355
+ rule: "dmn/no-output",
356
+ severity: "error",
357
+ ...(tableId !== undefined ? { elementId: tableId } : {}),
358
+ message: `${label}'s decision table has no <output>.`,
359
+ fix: 'Add an <output id="…" name="result" typeRef="string"/> column.',
360
+ });
361
+ }
362
+ for (const input of inputs) {
363
+ const inputId = input.attributes.id;
364
+ const expr = child(input, "inputExpression");
365
+ const what = `Input "${input.attributes.label ?? inputId ?? "?"}" of ${label}`;
366
+ if (expr === undefined || textOf(expr) === "") {
367
+ findings.push({
368
+ rule: "dmn/empty-input-expression",
369
+ severity: "error",
370
+ ...(inputId !== undefined ? { elementId: inputId } : {}),
371
+ message: `${what} has no input expression.`,
372
+ fix: "Set <inputExpression><text>variableName</text></inputExpression> to the value the column tests.",
373
+ });
374
+ continue;
375
+ }
376
+ checkTypeRef(expr, inputId, what, findings);
377
+ checkFeel(textOf(expr), "expression", inputId, `${what}'s expression`, findings);
378
+ }
379
+ for (const output of outputs) {
380
+ const outputId = output.attributes.id;
381
+ checkTypeRef(output, outputId, `Output "${output.attributes.name ?? outputId}"`, findings);
382
+ if (outputs.length > 1 && (output.attributes.name ?? "") === "") {
383
+ findings.push({
384
+ rule: "dmn/missing-output-name",
385
+ severity: "error",
386
+ ...(outputId !== undefined ? { elementId: outputId } : {}),
387
+ message: `Output "${output.attributes.label ?? outputId ?? "?"}" of ${label} has no name, and the table has ${outputs.length} outputs.`,
388
+ fix: "Give every output a name — with several outputs the result is a context keyed by output name.",
389
+ });
390
+ }
391
+ }
392
+ for (const rule of childrenNamed(table, "rule")) {
393
+ const ruleId = rule.attributes.id;
394
+ const inEntries = childrenNamed(rule, "inputEntry");
395
+ const outEntries = childrenNamed(rule, "outputEntry");
396
+ if (inEntries.length !== inputs.length || outEntries.length !== outputs.length) {
397
+ findings.push({
398
+ rule: "dmn/rule-entry-count",
399
+ severity: "error",
400
+ ...(ruleId !== undefined ? { elementId: ruleId } : {}),
401
+ message: `Rule "${ruleId ?? "?"}" of ${label} has ${inEntries.length} input and ${outEntries.length} output entries; the table has ${inputs.length} inputs and ${outputs.length} outputs.`,
402
+ fix: "Give every rule exactly one <inputEntry> per input and one <outputEntry> per output, in column order (use `-` for any).",
403
+ });
404
+ }
405
+ for (const entry of inEntries) {
406
+ const text = textOf(entry);
407
+ checkFeel(text === "-" ? "" : text, "unary", entry.attributes.id ?? ruleId, `Input entry of rule "${ruleId ?? "?"}"`, findings);
408
+ }
409
+ for (const entry of outEntries) {
410
+ checkFeel(textOf(entry), "expression", entry.attributes.id ?? ruleId, `Output entry of rule "${ruleId ?? "?"}"`, findings);
411
+ }
412
+ }
413
+ }
414
+ //# sourceMappingURL=lint.js.map
@@ -1,4 +1,4 @@
1
- import type { FormComponent, FormDefinition, FormLayoutInput, FormValidation, FormValueOption } from "./form-model.js";
1
+ import type { FormComponent, FormConditional, FormDefinition, FormLayoutInput, FormValidation, FormValueOption } from "./form-model.js";
2
2
  /** Builder for constructing Camunda Forms programmatically. */
3
3
  export declare class FormBuilder {
4
4
  private _id;
@@ -36,6 +36,7 @@ export declare class FormBuilder {
36
36
  id?: string;
37
37
  label?: string;
38
38
  layout?: FormLayoutInput;
39
+ conditional?: FormConditional;
39
40
  }): this;
40
41
  /** Adds a text field component. */
41
42
  textfield(label: string, key: string, options?: TextFieldOptions): this;
@@ -73,6 +74,7 @@ export declare class GroupBuilder {
73
74
  id?: string;
74
75
  label?: string;
75
76
  layout?: FormLayoutInput;
77
+ conditional?: FormConditional;
76
78
  }): this;
77
79
  textfield(label: string, key: string, options?: TextFieldOptions): this;
78
80
  textarea(label: string, key: string, options?: TextFieldOptions): this;
@@ -88,6 +90,7 @@ export interface TextFieldOptions {
88
90
  validate?: FormValidation;
89
91
  defaultValue?: string;
90
92
  layout?: FormLayoutInput;
93
+ conditional?: FormConditional;
91
94
  }
92
95
  /** Options for select components. */
93
96
  export interface SelectOptions {
@@ -98,6 +101,7 @@ export interface SelectOptions {
98
101
  searchable?: boolean;
99
102
  defaultValue?: string;
100
103
  layout?: FormLayoutInput;
104
+ conditional?: FormConditional;
101
105
  }
102
106
  /** Options for radio components. */
103
107
  export interface RadioOptions {
@@ -105,6 +109,7 @@ export interface RadioOptions {
105
109
  validate?: FormValidation;
106
110
  defaultValue?: string;
107
111
  layout?: FormLayoutInput;
112
+ conditional?: FormConditional;
108
113
  }
109
114
  /** Options for checkbox components. */
110
115
  export interface CheckboxOptions {
@@ -112,17 +117,20 @@ export interface CheckboxOptions {
112
117
  validate?: FormValidation;
113
118
  defaultValue?: boolean;
114
119
  layout?: FormLayoutInput;
120
+ conditional?: FormConditional;
115
121
  }
116
122
  /** Options for checklist components. */
117
123
  export interface ChecklistOptions {
118
124
  id?: string;
119
125
  validate?: FormValidation;
120
126
  layout?: FormLayoutInput;
127
+ conditional?: FormConditional;
121
128
  }
122
129
  /** Options for group components. */
123
130
  export interface GroupOptions {
124
131
  id?: string;
125
132
  showOutline?: boolean;
126
133
  layout?: FormLayoutInput;
134
+ conditional?: FormConditional;
127
135
  }
128
136
  //# sourceMappingURL=form-builder.d.ts.map
@@ -44,6 +44,7 @@ class ScopeNames {
44
44
  row: options?.layout?.row ?? stableToken("Row", [...segments, "row"]),
45
45
  columns: options?.layout?.columns ?? null,
46
46
  },
47
+ ...(options?.conditional !== undefined ? { conditional: options.conditional } : {}),
47
48
  };
48
49
  }
49
50
  }
@@ -52,7 +53,7 @@ export class FormBuilder {
52
53
  _id;
53
54
  _type = "default";
54
55
  _executionPlatform = "Camunda Cloud";
55
- _executionPlatformVersion = "8.7.0";
56
+ _executionPlatformVersion = "8.10.0";
56
57
  _exporter;
57
58
  _schemaVersion;
58
59
  _generated;
@@ -112,6 +113,8 @@ export class FormBuilder {
112
113
  if (options?.label !== undefined)
113
114
  component.label = options.label;
114
115
  component.layout = names.layout;
116
+ if (names.conditional !== undefined)
117
+ component.conditional = names.conditional;
115
118
  this._components.push(component);
116
119
  return this;
117
120
  }
@@ -129,6 +132,8 @@ export class FormBuilder {
129
132
  if (options?.defaultValue !== undefined)
130
133
  component.defaultValue = options.defaultValue;
131
134
  component.layout = names.layout;
135
+ if (names.conditional !== undefined)
136
+ component.conditional = names.conditional;
132
137
  this._components.push(component);
133
138
  return this;
134
139
  }
@@ -146,6 +151,8 @@ export class FormBuilder {
146
151
  if (options?.defaultValue !== undefined)
147
152
  component.defaultValue = options.defaultValue;
148
153
  component.layout = names.layout;
154
+ if (names.conditional !== undefined)
155
+ component.conditional = names.conditional;
149
156
  this._components.push(component);
150
157
  return this;
151
158
  }
@@ -169,6 +176,8 @@ export class FormBuilder {
169
176
  if (options?.defaultValue !== undefined)
170
177
  component.defaultValue = options.defaultValue;
171
178
  component.layout = names.layout;
179
+ if (names.conditional !== undefined)
180
+ component.conditional = names.conditional;
172
181
  this._components.push(component);
173
182
  return this;
174
183
  }
@@ -187,6 +196,8 @@ export class FormBuilder {
187
196
  if (options?.defaultValue !== undefined)
188
197
  component.defaultValue = options.defaultValue;
189
198
  component.layout = names.layout;
199
+ if (names.conditional !== undefined)
200
+ component.conditional = names.conditional;
190
201
  this._components.push(component);
191
202
  return this;
192
203
  }
@@ -204,6 +215,8 @@ export class FormBuilder {
204
215
  if (options?.defaultValue !== undefined)
205
216
  component.defaultValue = options.defaultValue;
206
217
  component.layout = names.layout;
218
+ if (names.conditional !== undefined)
219
+ component.conditional = names.conditional;
207
220
  this._components.push(component);
208
221
  return this;
209
222
  }
@@ -220,6 +233,8 @@ export class FormBuilder {
220
233
  if (options?.validate !== undefined)
221
234
  component.validate = options.validate;
222
235
  component.layout = names.layout;
236
+ if (names.conditional !== undefined)
237
+ component.conditional = names.conditional;
223
238
  this._components.push(component);
224
239
  return this;
225
240
  }
@@ -237,6 +252,8 @@ export class FormBuilder {
237
252
  if (options?.showOutline !== undefined)
238
253
  component.showOutline = options.showOutline;
239
254
  component.layout = names.layout;
255
+ if (names.conditional !== undefined)
256
+ component.conditional = names.conditional;
240
257
  this._components.push(component);
241
258
  return this;
242
259
  }
@@ -290,6 +307,8 @@ export class GroupBuilder {
290
307
  if (options?.label !== undefined)
291
308
  component.label = options.label;
292
309
  component.layout = names.layout;
310
+ if (names.conditional !== undefined)
311
+ component.conditional = names.conditional;
293
312
  this._components.push(component);
294
313
  return this;
295
314
  }
@@ -306,6 +325,8 @@ export class GroupBuilder {
306
325
  if (options?.defaultValue !== undefined)
307
326
  component.defaultValue = options.defaultValue;
308
327
  component.layout = names.layout;
328
+ if (names.conditional !== undefined)
329
+ component.conditional = names.conditional;
309
330
  this._components.push(component);
310
331
  return this;
311
332
  }
@@ -322,6 +343,8 @@ export class GroupBuilder {
322
343
  if (options?.defaultValue !== undefined)
323
344
  component.defaultValue = options.defaultValue;
324
345
  component.layout = names.layout;
346
+ if (names.conditional !== undefined)
347
+ component.conditional = names.conditional;
325
348
  this._components.push(component);
326
349
  return this;
327
350
  }
@@ -344,6 +367,8 @@ export class GroupBuilder {
344
367
  if (options?.defaultValue !== undefined)
345
368
  component.defaultValue = options.defaultValue;
346
369
  component.layout = names.layout;
370
+ if (names.conditional !== undefined)
371
+ component.conditional = names.conditional;
347
372
  this._components.push(component);
348
373
  return this;
349
374
  }
@@ -361,6 +386,8 @@ export class GroupBuilder {
361
386
  if (options?.defaultValue !== undefined)
362
387
  component.defaultValue = options.defaultValue;
363
388
  component.layout = names.layout;
389
+ if (names.conditional !== undefined)
390
+ component.conditional = names.conditional;
364
391
  this._components.push(component);
365
392
  return this;
366
393
  }
@@ -377,6 +404,8 @@ export class GroupBuilder {
377
404
  if (options?.defaultValue !== undefined)
378
405
  component.defaultValue = options.defaultValue;
379
406
  component.layout = names.layout;
407
+ if (names.conditional !== undefined)
408
+ component.conditional = names.conditional;
380
409
  this._components.push(component);
381
410
  return this;
382
411
  }
@@ -392,6 +421,8 @@ export class GroupBuilder {
392
421
  if (options?.validate !== undefined)
393
422
  component.validate = options.validate;
394
423
  component.layout = names.layout;
424
+ if (names.conditional !== undefined)
425
+ component.conditional = names.conditional;
395
426
  this._components.push(component);
396
427
  return this;
397
428
  }
@@ -408,6 +439,8 @@ export class GroupBuilder {
408
439
  if (options?.showOutline !== undefined)
409
440
  component.showOutline = options.showOutline;
410
441
  component.layout = names.layout;
442
+ if (names.conditional !== undefined)
443
+ component.conditional = names.conditional;
411
444
  this._components.push(component);
412
445
  return this;
413
446
  }
@@ -30,11 +30,18 @@ export interface FormValueOption {
30
30
  label: string;
31
31
  value: string;
32
32
  }
33
+ /** form-js `conditional` block: the component is hidden while the FEEL expression is true. */
34
+ export interface FormConditional {
35
+ hide: string;
36
+ }
33
37
  /** Base properties shared by all form components. */
34
38
  interface FormComponentBase {
35
39
  id: string;
36
40
  type: string;
37
41
  layout?: FormLayout;
42
+ conditional?: FormConditional;
43
+ /** Properties the model does not know, kept verbatim so a round trip is lossless. */
44
+ extraProps?: Record<string, unknown>;
38
45
  }
39
46
  /** Static text/markdown display component. */
40
47
  export interface FormTextComponent extends FormComponentBase {
@@ -72,6 +72,28 @@ export function parseForm(json) {
72
72
  return definition;
73
73
  }
74
74
  function parseComponent(raw, path) {
75
+ const component = parseKnownComponent(raw, path);
76
+ const obj = raw;
77
+ const cond = obj.conditional;
78
+ if (typeof cond === "object" && cond !== null && !Array.isArray(cond)) {
79
+ const { hide, ...rest } = cond;
80
+ // A conditional form-js adds keys to later is kept whole, never narrowed to `hide`.
81
+ if (typeof hide === "string" && Object.keys(rest).length === 0) {
82
+ component.conditional = { hide };
83
+ }
84
+ }
85
+ const known = component;
86
+ const extra = {};
87
+ for (const [key, value] of Object.entries(obj)) {
88
+ if (!(key in known) && !(key === "conditional" && component.conditional))
89
+ extra[key] = value;
90
+ }
91
+ if (Object.keys(extra).length > 0 && component.extraProps === undefined) {
92
+ component.extraProps = extra;
93
+ }
94
+ return component;
95
+ }
96
+ function parseKnownComponent(raw, path) {
75
97
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
76
98
  throw new ParseError(`${path}: component must be an object`);
77
99
  }