@bpmnkit/core 0.8.0 → 1.1.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 (69) hide show
  1. package/README.md +49 -3
  2. package/dist/bpmn/agentic.js +3 -1
  3. package/dist/bpmn/auto-layout.js +184 -15
  4. package/dist/bpmn/bpmn-builder.d.ts +1 -12
  5. package/dist/bpmn/bpmn-builder.js +71 -10
  6. package/dist/bpmn/bpmn-model.d.ts +78 -0
  7. package/dist/bpmn/bpmn-parser.js +199 -41
  8. package/dist/bpmn/bpmn-serializer.js +121 -72
  9. package/dist/bpmn/bpmnlint.d.ts +153 -0
  10. package/dist/bpmn/bpmnlint.js +364 -0
  11. package/dist/bpmn/camunda-compat-data.d.ts +165 -0
  12. package/dist/bpmn/camunda-compat-data.js +423 -0
  13. package/dist/bpmn/camunda-compat-feel.d.ts +68 -0
  14. package/dist/bpmn/camunda-compat-feel.js +338 -0
  15. package/dist/bpmn/camunda-compat.d.ts +120 -0
  16. package/dist/bpmn/camunda-compat.js +1677 -0
  17. package/dist/bpmn/camunda7/juel.d.ts +41 -0
  18. package/dist/bpmn/camunda7/juel.js +333 -0
  19. package/dist/bpmn/camunda7/migrate.d.ts +72 -0
  20. package/dist/bpmn/camunda7/migrate.js +1152 -0
  21. package/dist/bpmn/compact-stream.d.ts +64 -0
  22. package/dist/bpmn/compact-stream.js +167 -0
  23. package/dist/bpmn/full-operations.js +5 -2
  24. package/dist/bpmn/label-style.d.ts +51 -0
  25. package/dist/bpmn/label-style.js +116 -0
  26. package/dist/bpmn/lint.d.ts +23 -3
  27. package/dist/bpmn/lint.js +47 -10
  28. package/dist/bpmn/optimize/bpmnlint-rules.d.ts +31 -0
  29. package/dist/bpmn/optimize/bpmnlint-rules.js +916 -0
  30. package/dist/bpmn/optimize/deploy.d.ts +8 -2
  31. package/dist/bpmn/optimize/deploy.js +16 -3
  32. package/dist/bpmn/optimize/index.js +11 -2
  33. package/dist/bpmn/optimize/types.d.ts +14 -0
  34. package/dist/bpmn/optimize/variable-flow.js +4 -1
  35. package/dist/bpmn/process-types.d.ts +112 -0
  36. package/dist/bpmn/process-types.js +490 -0
  37. package/dist/bpmn/svg.js +51 -22
  38. package/dist/dmn/dmn-parser.js +4 -3
  39. package/dist/doc/docx.d.ts +20 -0
  40. package/dist/doc/docx.js +253 -0
  41. package/dist/doc/html.d.ts +21 -0
  42. package/dist/doc/html.js +303 -0
  43. package/dist/doc/index.d.ts +7 -0
  44. package/dist/doc/index.js +5 -0
  45. package/dist/doc/markdown.d.ts +11 -0
  46. package/dist/doc/markdown.js +160 -0
  47. package/dist/doc/model.d.ts +129 -0
  48. package/dist/doc/model.js +617 -0
  49. package/dist/doc/zip.d.ts +5 -0
  50. package/dist/doc/zip.js +75 -0
  51. package/dist/form/form-parser.js +29 -28
  52. package/dist/index.d.ts +18 -0
  53. package/dist/index.js +9 -0
  54. package/dist/layout/annotations.d.ts +4 -2
  55. package/dist/layout/annotations.js +31 -2
  56. package/dist/layout/collaboration/ordering.d.ts +8 -0
  57. package/dist/layout/collaboration/ordering.js +57 -18
  58. package/dist/layout/orthogonal.d.ts +32 -0
  59. package/dist/layout/orthogonal.js +367 -0
  60. package/dist/layout/repair.d.ts +31 -0
  61. package/dist/layout/repair.js +220 -0
  62. package/dist/layout/semantic/route.js +45 -3
  63. package/dist/node/bpmnlint.d.ts +109 -0
  64. package/dist/node/bpmnlint.js +198 -0
  65. package/dist/node/index.d.ts +2 -0
  66. package/dist/node/index.js +1 -0
  67. package/dist/xml/xml-patch.d.ts +21 -0
  68. package/dist/xml/xml-patch.js +27 -1
  69. package/package.json +5 -2
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The diagram a model is writing, read out of the tokens as they arrive.
3
+ *
4
+ * A language model emits a diagram one character at a time, so the shape of a
5
+ * process is knowable long before its last token. Nothing downstream can use a
6
+ * half-written document, though: `JSON.parse` wants the closing brace, and the
7
+ * outermost one — the tool argument's own wrapper — is the very last character
8
+ * sent.
9
+ *
10
+ * So this does not parse the document. It picks complete `{…}` object literals
11
+ * out of the text as they close and keeps the ones shaped like a
12
+ * {@link CompactElement} or a {@link CompactFlow}, which are the innermost
13
+ * objects and therefore the first to finish. That is also what makes it
14
+ * indifferent to what it is reading: a `replace_diagram` argument, a ```json
15
+ * block in an assistant's prose, or the body of a `compose_diagram` snippet all
16
+ * carry the same literals, and none of them have to be valid as a whole.
17
+ *
18
+ * **Frames are advisory.** Everything here is a guess at an unfinished
19
+ * document, and the caller is expected to have an authoritative result coming.
20
+ * That is what lets it drop what it cannot place instead of reporting an error,
21
+ * and why it never throws on input.
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ import type { BpmnDefinitions } from "./bpmn-model.js";
26
+ import type { CompactDiagram } from "./compact.js";
27
+ /** Options for {@link createCompactStream}. */
28
+ export interface CompactStreamOptions {
29
+ /**
30
+ * The diagram being edited.
31
+ *
32
+ * A model changing an existing process streams only what it is adding, so
33
+ * without this a frame is a disconnected fragment rather than the diagram
34
+ * with the fragment in it. Only the first process is previewed; a frame is
35
+ * one process, whatever the document turns out to hold.
36
+ */
37
+ base?: CompactDiagram | null;
38
+ }
39
+ /** A diagram assembled from a text stream. See {@link createCompactStream}. */
40
+ export interface CompactStream {
41
+ /**
42
+ * Adds the next piece of text.
43
+ *
44
+ * @returns The diagram as it now stands, or `null` when this chunk added
45
+ * nothing renderable — no new element, or not enough for a diagram yet.
46
+ */
47
+ push(chunk: string): BpmnDefinitions | null;
48
+ }
49
+ /**
50
+ * Reads a diagram out of a stream of text.
51
+ *
52
+ * @param options - See {@link CompactStreamOptions}.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const stream = createCompactStream({ base: currentDiagram })
57
+ * for await (const chunk of tokens) {
58
+ * const defs = stream.push(chunk)
59
+ * if (defs) render(defs)
60
+ * }
61
+ * ```
62
+ */
63
+ export declare function createCompactStream(options?: CompactStreamOptions): CompactStream;
64
+ //# sourceMappingURL=compact-stream.d.ts.map
@@ -0,0 +1,167 @@
1
+ /**
2
+ * The diagram a model is writing, read out of the tokens as they arrive.
3
+ *
4
+ * A language model emits a diagram one character at a time, so the shape of a
5
+ * process is knowable long before its last token. Nothing downstream can use a
6
+ * half-written document, though: `JSON.parse` wants the closing brace, and the
7
+ * outermost one — the tool argument's own wrapper — is the very last character
8
+ * sent.
9
+ *
10
+ * So this does not parse the document. It picks complete `{…}` object literals
11
+ * out of the text as they close and keeps the ones shaped like a
12
+ * {@link CompactElement} or a {@link CompactFlow}, which are the innermost
13
+ * objects and therefore the first to finish. That is also what makes it
14
+ * indifferent to what it is reading: a `replace_diagram` argument, a ```json
15
+ * block in an assistant's prose, or the body of a `compose_diagram` snippet all
16
+ * carry the same literals, and none of them have to be valid as a whole.
17
+ *
18
+ * **Frames are advisory.** Everything here is a guess at an unfinished
19
+ * document, and the caller is expected to have an authoritative result coming.
20
+ * That is what lets it drop what it cannot place instead of reporting an error,
21
+ * and why it never throws on input.
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ import { expand } from "./compact.js";
26
+ import { ELEMENT_TYPE_GROUPS } from "./element-catalog.js";
27
+ function isRecord(value) {
28
+ return typeof value === "object" && value !== null && !Array.isArray(value);
29
+ }
30
+ /**
31
+ * Reads a diagram out of a stream of text.
32
+ *
33
+ * @param options - See {@link CompactStreamOptions}.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const stream = createCompactStream({ base: currentDiagram })
38
+ * for await (const chunk of tokens) {
39
+ * const defs = stream.push(chunk)
40
+ * if (defs) render(defs)
41
+ * }
42
+ * ```
43
+ */
44
+ export function createCompactStream(options) {
45
+ const baseProcess = options?.base?.processes[0];
46
+ const elements = new Map();
47
+ const flows = new Map();
48
+ for (const element of baseProcess?.elements ?? [])
49
+ elements.set(element.id, element);
50
+ for (const flow of baseProcess?.flows ?? [])
51
+ flows.set(flow.id, flow);
52
+ const documentId = options?.base?.id ?? "Definitions_1";
53
+ const processId = baseProcess?.id ?? "Process_1";
54
+ const processName = baseProcess?.name;
55
+ let text = "";
56
+ /** How far `scan` has read. Every character is looked at exactly once. */
57
+ let read = 0;
58
+ /** Offsets of the `{`s that are still open, outermost first. */
59
+ const open = [];
60
+ let inString = false;
61
+ let escaped = false;
62
+ let changed = false;
63
+ /** Drops a container's contents from the top level — they belong to it. */
64
+ function forget(children) {
65
+ for (const child of children?.elements ?? []) {
66
+ elements.delete(child.id);
67
+ forget(child.children);
68
+ }
69
+ for (const flow of children?.flows ?? [])
70
+ flows.delete(flow.id);
71
+ }
72
+ /** Keeps `value` if it is an element or a flow. */
73
+ function take(value) {
74
+ if (!isRecord(value) || typeof value.id !== "string" || value.id === "")
75
+ return;
76
+ if (typeof value.type === "string" && Object.hasOwn(ELEMENT_TYPE_GROUPS, value.type)) {
77
+ const element = value;
78
+ forget(element.children);
79
+ elements.set(element.id, element);
80
+ changed = true;
81
+ return;
82
+ }
83
+ if (typeof value.from === "string" && typeof value.to === "string") {
84
+ // `isDefault` is dropped rather than carried: `expand` throws when a flow
85
+ // claims a gateway that has not been written yet, which during a stream is
86
+ // most of the time. A preview without the marker beats no preview.
87
+ const { isDefault: _dropped, ...flow } = value;
88
+ flows.set(flow.id, flow);
89
+ changed = true;
90
+ }
91
+ }
92
+ /**
93
+ * Reads the new text once, taking each literal at the `}` that closes it.
94
+ *
95
+ * A brace stack rather than a re-scan: every character is looked at exactly
96
+ * once across the whole stream, and each literal is considered exactly once,
97
+ * innermost first — so a container is seen after the children it has to
98
+ * reclaim, and the tool argument's own wrapper is not waited on.
99
+ */
100
+ function scan() {
101
+ for (; read < text.length; read++) {
102
+ const ch = text[read];
103
+ if (escaped) {
104
+ escaped = false;
105
+ continue;
106
+ }
107
+ if (ch === "\\") {
108
+ escaped = true;
109
+ continue;
110
+ }
111
+ if (ch === '"') {
112
+ inString = !inString;
113
+ continue;
114
+ }
115
+ if (inString)
116
+ continue;
117
+ if (ch === "{") {
118
+ open.push(read);
119
+ continue;
120
+ }
121
+ if (ch !== "}")
122
+ continue;
123
+ const start = open.pop();
124
+ if (start === undefined)
125
+ continue; // a stray brace in prose
126
+ try {
127
+ take(JSON.parse(text.slice(start, read + 1)));
128
+ }
129
+ catch {
130
+ /* not a literal we can read */
131
+ }
132
+ }
133
+ }
134
+ return {
135
+ push(chunk) {
136
+ text += chunk;
137
+ scan();
138
+ if (!changed)
139
+ return null;
140
+ changed = false;
141
+ const kept = [...elements.values()];
142
+ if (kept.length === 0)
143
+ return null;
144
+ const known = new Set(kept.map((element) => element.id));
145
+ const diagram = {
146
+ id: documentId,
147
+ processes: [
148
+ {
149
+ id: processId,
150
+ name: processName,
151
+ elements: kept,
152
+ // A flow whose other end has not been written yet lays out as
153
+ // nothing; one naming an element that never arrives would too.
154
+ flows: [...flows.values()].filter((flow) => known.has(flow.from) && known.has(flow.to)),
155
+ },
156
+ ],
157
+ };
158
+ try {
159
+ return expand(diagram);
160
+ }
161
+ catch {
162
+ return null; // an element whose fields have not all arrived
163
+ }
164
+ },
165
+ };
166
+ }
167
+ //# sourceMappingURL=compact-stream.js.map
@@ -468,8 +468,11 @@ function operationsForCompact(definitions, compact) {
468
468
  replacedFlows.add(flow.id);
469
469
  continue;
470
470
  }
471
- const sameLabel = (want.name ?? undefined) === (flow.name ?? undefined);
472
- const sameCondition = (want.condition ?? undefined) === (flow.conditionExpression?.text ?? undefined);
471
+ // An empty label or condition is the same as none: the compact view omits
472
+ // both, and treating "" as a change would delete and re-add the flow,
473
+ // taking its extensions and condition attributes with it.
474
+ const sameLabel = (want.name || undefined) === (flow.name || undefined);
475
+ const sameCondition = (want.condition || undefined) === (flow.conditionExpression?.text || undefined);
473
476
  if (!sameLabel || !sameCondition) {
474
477
  operations.push({ op: "delete_flow", id: flow.id });
475
478
  replacedFlows.add(flow.id);
@@ -0,0 +1,51 @@
1
+ import type { BpmnDefinitions, BpmnDiLabel } from "./bpmn-model.js";
2
+ /**
3
+ * The `dc:Font` of a `bpmndi:BPMNLabelStyle`. Every field is optional: an
4
+ * attribute the file omits (or carries an unusable value for) is left unset,
5
+ * and the renderer's default applies to it.
6
+ */
7
+ export interface BpmnLabelFont {
8
+ /** Font family (`name`), as written — may be a comma-separated list. */
9
+ name?: string;
10
+ /** Font size (`size`), drawn as CSS pixels — DI coordinates are pixels. */
11
+ size?: number;
12
+ isBold?: boolean;
13
+ isItalic?: boolean;
14
+ isUnderline?: boolean;
15
+ isStrikeThrough?: boolean;
16
+ }
17
+ /** CSS values for a resolved label font, ready for inline styles or `ctx.font`. */
18
+ export interface LabelFontCss {
19
+ fontFamily: string;
20
+ /** In px. */
21
+ fontSize: number;
22
+ fontWeight: "normal" | "bold";
23
+ fontStyle: "normal" | "italic";
24
+ /** `"none"`, or `underline` / `line-through` / both. */
25
+ textDecoration: string;
26
+ }
27
+ /**
28
+ * Indexes every `bpmndi:BPMNLabelStyle` in the document by id.
29
+ *
30
+ * Styles are owned by a `BPMNDiagram`, but a label's `labelStyle` is an id
31
+ * reference, and ids are document-unique — so all diagrams are indexed and a
32
+ * label may use a style defined under another diagram.
33
+ */
34
+ export declare function collectLabelStyles(defs: BpmnDefinitions): Map<string, BpmnLabelFont>;
35
+ /**
36
+ * The font a DI label is drawn in: the style its `labelStyle` attribute
37
+ * references, or `undefined` for the renderer default.
38
+ *
39
+ * BPMN DI has no default label style on the diagram or plane and no
40
+ * inheritance between labels, so a label without a (resolvable) `labelStyle`
41
+ * gets the default. `labelStyle` is typed `xsd:QName`, so a prefixed value
42
+ * (`di:LS1`) falls back to its local part.
43
+ */
44
+ export declare function resolveLabelFont(label: BpmnDiLabel | undefined, styles: ReadonlyMap<string, BpmnLabelFont>): BpmnLabelFont | undefined;
45
+ /**
46
+ * Converts a label font into CSS values. Missing fields take the defaults
47
+ * given; the file's family (each entry of a comma-separated `name`, quoted)
48
+ * goes in front of `defaultFamily`, which stays as the fallback stack.
49
+ */
50
+ export declare function labelFontCss(font: BpmnLabelFont | undefined, defaultFamily: string, defaultSize: number): LabelFontCss;
51
+ //# sourceMappingURL=label-style.d.ts.map
@@ -0,0 +1,116 @@
1
+ const localName = (name) => name.slice(name.indexOf(":") + 1);
2
+ function parseBool(v) {
3
+ if (v === "true" || v === "1")
4
+ return true;
5
+ if (v === "false" || v === "0")
6
+ return false;
7
+ return undefined;
8
+ }
9
+ function parseFont(style) {
10
+ const font = style.children.find((c) => localName(c.name) === "Font");
11
+ if (!font)
12
+ return {};
13
+ const a = font.attributes;
14
+ const out = {};
15
+ const name = a.name?.trim();
16
+ if (name)
17
+ out.name = name;
18
+ const size = a.size === undefined ? Number.NaN : Number(a.size);
19
+ if (Number.isFinite(size) && size > 0)
20
+ out.size = size;
21
+ const bold = parseBool(a.isBold);
22
+ if (bold !== undefined)
23
+ out.isBold = bold;
24
+ const italic = parseBool(a.isItalic);
25
+ if (italic !== undefined)
26
+ out.isItalic = italic;
27
+ const underline = parseBool(a.isUnderline);
28
+ if (underline !== undefined)
29
+ out.isUnderline = underline;
30
+ const strike = parseBool(a.isStrikeThrough);
31
+ if (strike !== undefined)
32
+ out.isStrikeThrough = strike;
33
+ return out;
34
+ }
35
+ /**
36
+ * Indexes every `bpmndi:BPMNLabelStyle` in the document by id.
37
+ *
38
+ * Styles are owned by a `BPMNDiagram`, but a label's `labelStyle` is an id
39
+ * reference, and ids are document-unique — so all diagrams are indexed and a
40
+ * label may use a style defined under another diagram.
41
+ */
42
+ export function collectLabelStyles(defs) {
43
+ const styles = new Map();
44
+ for (const diagram of defs.diagrams) {
45
+ for (const child of diagram.unknownChildren ?? []) {
46
+ if (localName(child.name) !== "BPMNLabelStyle")
47
+ continue;
48
+ const id = child.attributes.id;
49
+ if (id)
50
+ styles.set(id, parseFont(child));
51
+ }
52
+ }
53
+ return styles;
54
+ }
55
+ /**
56
+ * The font a DI label is drawn in: the style its `labelStyle` attribute
57
+ * references, or `undefined` for the renderer default.
58
+ *
59
+ * BPMN DI has no default label style on the diagram or plane and no
60
+ * inheritance between labels, so a label without a (resolvable) `labelStyle`
61
+ * gets the default. `labelStyle` is typed `xsd:QName`, so a prefixed value
62
+ * (`di:LS1`) falls back to its local part.
63
+ */
64
+ export function resolveLabelFont(label, styles) {
65
+ const ref = label?.unknownAttributes?.labelStyle?.trim();
66
+ if (!ref)
67
+ return undefined;
68
+ return styles.get(ref) ?? styles.get(localName(ref));
69
+ }
70
+ const GENERIC_FAMILIES = new Set([
71
+ "serif",
72
+ "sans-serif",
73
+ "monospace",
74
+ "cursive",
75
+ "fantasy",
76
+ "system-ui",
77
+ "ui-serif",
78
+ "ui-sans-serif",
79
+ "ui-monospace",
80
+ "ui-rounded",
81
+ "math",
82
+ "emoji",
83
+ "fangsong",
84
+ ]);
85
+ /** Quotes one family name as a CSS string; generic keywords stay bare. */
86
+ function cssFamily(family) {
87
+ if (GENERIC_FAMILIES.has(family.toLowerCase()))
88
+ return family.toLowerCase();
89
+ const escaped = family.replace(/[\\"]/g, "\\$&").replace(/[\n\r\f]/g, " ");
90
+ return `"${escaped}"`;
91
+ }
92
+ /**
93
+ * Converts a label font into CSS values. Missing fields take the defaults
94
+ * given; the file's family (each entry of a comma-separated `name`, quoted)
95
+ * goes in front of `defaultFamily`, which stays as the fallback stack.
96
+ */
97
+ export function labelFontCss(font, defaultFamily, defaultSize) {
98
+ const families = (font?.name ?? "")
99
+ .split(",")
100
+ .map((f) => f.trim().replace(/^(["'])(.*)\1$/, "$2"))
101
+ .filter((f) => f.length > 0)
102
+ .map(cssFamily);
103
+ const decorations = [];
104
+ if (font?.isUnderline)
105
+ decorations.push("underline");
106
+ if (font?.isStrikeThrough)
107
+ decorations.push("line-through");
108
+ return {
109
+ fontFamily: [...families, defaultFamily].join(", "),
110
+ fontSize: font?.size ?? defaultSize,
111
+ fontWeight: font?.isBold ? "bold" : "normal",
112
+ fontStyle: font?.isItalic ? "italic" : "normal",
113
+ textDecoration: decorations.length > 0 ? decorations.join(" ") : "none",
114
+ };
115
+ }
116
+ //# sourceMappingURL=label-style.js.map
@@ -1,4 +1,5 @@
1
1
  import type { BpmnDefinitions } from "./bpmn-model.js";
2
+ import { type ResolvedBpmnlintConfig, type UnsupportedBpmnlintRule } from "./bpmnlint.js";
2
3
  import type { OptimizationCategory, OptimizationSeverity, OptimizeOptions } from "./optimize/types.js";
3
4
  /**
4
5
  * The engine a model says it targets, read from `modeler:executionPlatform`.
@@ -31,6 +32,8 @@ export interface LintDiagnostic {
31
32
  plane?: string;
32
33
  /** Whether the live report carries an automatic fix for this finding. */
33
34
  fixable: boolean;
35
+ /** The bpmnlint rule it was reported under, when a `.bpmnlintrc` governs it. */
36
+ bpmnlintRule?: string;
34
37
  }
35
38
  export interface LintReport {
36
39
  diagnostics: LintDiagnostic[];
@@ -40,6 +43,11 @@ export interface LintReport {
40
43
  categories: OptimizationCategory[];
41
44
  counts: Record<OptimizationSeverity, number>;
42
45
  total: number;
46
+ /**
47
+ * Present when a `.bpmnlintrc` was applied: the configured rules (or
48
+ * `extends` entries) BPMN Kit has no equivalent for.
49
+ */
50
+ bpmnlintUnsupported?: UnsupportedBpmnlintRule[];
43
51
  }
44
52
  export interface LintOptions extends OptimizeOptions {
45
53
  /**
@@ -47,6 +55,17 @@ export interface LintOptions extends OptimizeOptions {
47
55
  * an engine-neutral diagram should not be told it is undeployable.
48
56
  */
49
57
  forceEngineRules?: boolean;
58
+ /**
59
+ * A resolved `.bpmnlintrc` to apply — see `applyBpmnlintConfig`. Its
60
+ * severities govern the findings that stand in for bpmnlint rules, and the
61
+ * native equivalents of the rules it enables are run.
62
+ */
63
+ bpmnlint?: ResolvedBpmnlintConfig;
64
+ /**
65
+ * Real bpmnlint already reported the configured rules; drop BPMN Kit's
66
+ * equivalents instead of re-levelling them. Only meaningful with `bpmnlint`.
67
+ */
68
+ bpmnlintDelegated?: boolean;
50
69
  }
51
70
  /**
52
71
  * Reads the execution platform a model declares.
@@ -90,8 +109,9 @@ export declare function lintDiagram(definitions: BpmnDefinitions, options?: Lint
90
109
  * that `LintDiagnostic` deliberately drops. Both ask here which rules apply.
91
110
  *
92
111
  * @param definitions - The model whose execution platform decides.
93
- * @param options - `categories` to narrow to, and `forceEngineRules` to keep
94
- * the engine layer on a model that names no platform.
112
+ * @param options - `categories` to narrow to, `forceEngineRules` to keep the
113
+ * engine layer on a model that names no platform, and `camundaVersion` — a
114
+ * version a `.bpmnlintrc` pins — to keep `compat` on such a model.
95
115
  */
96
- export declare function lintCategories(definitions: BpmnDefinitions, options?: Pick<LintOptions, "categories" | "forceEngineRules">): OptimizationCategory[];
116
+ export declare function lintCategories(definitions: BpmnDefinitions, options?: Pick<LintOptions, "categories" | "forceEngineRules" | "camundaVersion">): OptimizationCategory[];
97
117
  //# sourceMappingURL=lint.d.ts.map
package/dist/bpmn/lint.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { applyBpmnlintConfig, } from "./bpmnlint.js";
2
+ import { applyCamundaCompatConfig, dedupeCamundaCompat, isCamundaCompatFinding, splitCamundaCompatConfig, } from "./camunda-compat.js";
1
3
  import { optimize } from "./optimize/index.js";
2
4
  /**
3
5
  * Categories whose findings only mean something against a Camunda 8 engine.
@@ -6,8 +8,8 @@ import { optimize } from "./optimize/index.js";
6
8
  * Zeebe extensions, every other category either stays quiet or reports
7
9
  * something structural that holds regardless, while `deploy` reports
8
10
  * "serviceTask has no zeebe:taskDefinition type" as an **error** — a demand the
9
- * author never signed up for. `connector` and `agentic` are the same kind of
10
- * claim about the same engine.
11
+ * author never signed up for. `connector` and `agentic` (and the `compat/…` findings `deploy` carries) are the same
12
+ * kind of claim about the same engine.
11
13
  */
12
14
  const ENGINE_CATEGORIES = ["deploy", "connector", "agentic"];
13
15
  /**
@@ -69,12 +71,35 @@ function planeIndex(definitions) {
69
71
  export function lintDiagram(definitions, options = {}) {
70
72
  const platform = detectExecutionPlatform(definitions);
71
73
  const engineRules = options.forceEngineRules === true || platform.id !== "none";
72
- const { forceEngineRules: _ignored, ...optimizeOptions } = options;
73
- const report = optimize(definitions, optimizeOptions);
74
+ const { forceEngineRules: _ignored, bpmnlint, bpmnlintDelegated, ...optimizeOptions } = options;
75
+ // A `.bpmnlintrc` extending `plugin:camunda-compat/camunda-cloud-X-Y`, or an
76
+ // explicit `camundaVersion`, pins the version the `compat/…` findings check —
77
+ // even on a model that names no platform.
78
+ const split = bpmnlint === undefined ? undefined : splitCamundaCompatConfig(bpmnlint);
79
+ const pinned = split?.compat?.version ?? optimizeOptions.camundaVersion;
80
+ const report = optimize(definitions, {
81
+ ...optimizeOptions,
82
+ ...(pinned !== undefined ? { camundaVersion: pinned } : {}),
83
+ });
74
84
  const requested = optimizeOptions.categories;
75
- const findings = engineRules
85
+ const engineFiltered = engineRules
76
86
  ? report.findings
77
- : report.findings.filter((f) => !ENGINE_CATEGORIES.includes(f.category));
87
+ : report.findings.filter((f) => !ENGINE_CATEGORIES.includes(f.category) ||
88
+ (isCamundaCompatFinding(f) && pinned !== undefined));
89
+ const compat = split?.compat === undefined
90
+ ? undefined
91
+ : applyCamundaCompatConfig(engineFiltered, split.compat, {
92
+ delegated: bpmnlintDelegated === true,
93
+ });
94
+ const applied = split === undefined
95
+ ? undefined
96
+ : applyBpmnlintConfig(definitions, compat?.findings ?? engineFiltered, split.rest, {
97
+ delegated: bpmnlintDelegated === true,
98
+ ...(requested !== undefined ? { categories: requested } : {}),
99
+ });
100
+ // bpmnlint's own rules run last, so a compatibility finding one of them now
101
+ // reports on the same element (`link-event`) is dropped here.
102
+ const findings = applied === undefined ? engineFiltered : dedupeCamundaCompat(applied.findings);
78
103
  const planes = planeIndex(definitions);
79
104
  const diagnostics = findings.map((finding) => {
80
105
  const plane = finding.elementIds.map((id) => planes.get(id)).find((p) => p !== undefined);
@@ -87,6 +112,7 @@ export function lintDiagram(definitions, options = {}) {
87
112
  processId: finding.processId,
88
113
  elementIds: finding.elementIds,
89
114
  fixable: finding.applyFix !== undefined,
115
+ ...(finding.bpmnlintRule !== undefined ? { bpmnlintRule: finding.bpmnlintRule } : {}),
90
116
  };
91
117
  return plane === undefined ? base : { ...base, plane };
92
118
  });
@@ -96,9 +122,15 @@ export function lintDiagram(definitions, options = {}) {
96
122
  return {
97
123
  diagnostics,
98
124
  platform,
99
- categories: lintCategories(definitions, options),
125
+ categories: lintCategories(definitions, {
126
+ ...options,
127
+ ...(pinned !== undefined ? { camundaVersion: pinned } : {}),
128
+ }),
100
129
  counts,
101
130
  total: diagnostics.length,
131
+ ...(applied !== undefined
132
+ ? { bpmnlintUnsupported: [...applied.unsupported, ...(compat?.unsupported ?? [])] }
133
+ : {}),
102
134
  };
103
135
  }
104
136
  /** Every category the optimizer knows, in the order it runs them. */
@@ -124,12 +156,17 @@ const ALL_CATEGORIES = [
124
156
  * that `LintDiagnostic` deliberately drops. Both ask here which rules apply.
125
157
  *
126
158
  * @param definitions - The model whose execution platform decides.
127
- * @param options - `categories` to narrow to, and `forceEngineRules` to keep
128
- * the engine layer on a model that names no platform.
159
+ * @param options - `categories` to narrow to, `forceEngineRules` to keep the
160
+ * engine layer on a model that names no platform, and `camundaVersion` — a
161
+ * version a `.bpmnlintrc` pins — to keep `compat` on such a model.
129
162
  */
130
163
  export function lintCategories(definitions, options = {}) {
131
164
  const base = options.categories ?? ALL_CATEGORIES;
132
165
  const engineRules = options.forceEngineRules === true || detectExecutionPlatform(definitions).id !== "none";
133
- return engineRules ? [...base] : base.filter((c) => !ENGINE_CATEGORIES.includes(c));
166
+ if (engineRules)
167
+ return [...base];
168
+ // A pinned `camundaVersion` still runs the compatibility check: `optimize`
169
+ // runs it whenever a version is given, and `lintDiagram` keeps its findings.
170
+ return base.filter((c) => !ENGINE_CATEGORIES.includes(c));
134
171
  }
135
172
  //# sourceMappingURL=lint.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Native equivalents of bpmnlint rules BPMN Kit had no finding for, or whose
3
+ * finding checks only the top-level process or a different set of elements.
4
+ *
5
+ * These are opt-in: nothing here runs unless a `.bpmnlintrc` enables the
6
+ * bpmnlint rule it stands in for (see `../bpmnlint.ts`). The default
7
+ * `casen lint` report is unchanged by their existence — several of them
8
+ * (`no-inclusive-gateway`, `standard-size`, …) are house style rather than
9
+ * correctness, and a team that never asked for them should not see them.
10
+ *
11
+ * Every rule walks every scope — processes and the sub-processes nested in
12
+ * them — because bpmnlint does. Connectivity is read from the sequence flows
13
+ * of each scope rather than from the `<incoming>`/`<outgoing>` children, which
14
+ * hand-written and generated XML routinely omits.
15
+ */
16
+ import type { BpmnDefinitions } from "../bpmn-model.js";
17
+ import type { OptimizationCategory, OptimizationFinding } from "./types.js";
18
+ /** The bpmnlint rules this module implements natively. */
19
+ export declare const NATIVE_BPMNLINT_RULES: readonly string[];
20
+ /**
21
+ * Runs the native equivalents of the given bpmnlint rules.
22
+ *
23
+ * Findings come back at `warning` severity; the caller applies the severity
24
+ * the `.bpmnlintrc` asked for.
25
+ *
26
+ * @param defs - The model to check.
27
+ * @param rules - bpmnlint rule name → that rule's options from the config.
28
+ * @param categories - When given, rules outside these categories are skipped.
29
+ */
30
+ export declare function analyzeBpmnlintRules(defs: BpmnDefinitions, rules: ReadonlyMap<string, unknown>, categories?: readonly OptimizationCategory[]): OptimizationFinding[];
31
+ //# sourceMappingURL=bpmnlint-rules.d.ts.map