@bpmnkit/core 1.0.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 (64) hide show
  1. package/README.md +25 -3
  2. package/dist/bpmn/agentic.js +3 -1
  3. package/dist/bpmn/auto-layout.js +184 -15
  4. package/dist/bpmn/bpmn-builder.js +69 -7
  5. package/dist/bpmn/bpmn-model.d.ts +78 -0
  6. package/dist/bpmn/bpmn-parser.js +195 -37
  7. package/dist/bpmn/bpmn-serializer.js +121 -72
  8. package/dist/bpmn/bpmnlint.d.ts +153 -0
  9. package/dist/bpmn/bpmnlint.js +364 -0
  10. package/dist/bpmn/camunda-compat-data.d.ts +165 -0
  11. package/dist/bpmn/camunda-compat-data.js +423 -0
  12. package/dist/bpmn/camunda-compat-feel.d.ts +68 -0
  13. package/dist/bpmn/camunda-compat-feel.js +338 -0
  14. package/dist/bpmn/camunda-compat.d.ts +120 -0
  15. package/dist/bpmn/camunda-compat.js +1677 -0
  16. package/dist/bpmn/camunda7/juel.d.ts +41 -0
  17. package/dist/bpmn/camunda7/juel.js +333 -0
  18. package/dist/bpmn/camunda7/migrate.d.ts +72 -0
  19. package/dist/bpmn/camunda7/migrate.js +1152 -0
  20. package/dist/bpmn/full-operations.js +5 -2
  21. package/dist/bpmn/label-style.d.ts +51 -0
  22. package/dist/bpmn/label-style.js +116 -0
  23. package/dist/bpmn/lint.d.ts +23 -3
  24. package/dist/bpmn/lint.js +47 -10
  25. package/dist/bpmn/optimize/bpmnlint-rules.d.ts +31 -0
  26. package/dist/bpmn/optimize/bpmnlint-rules.js +916 -0
  27. package/dist/bpmn/optimize/deploy.d.ts +8 -2
  28. package/dist/bpmn/optimize/deploy.js +16 -3
  29. package/dist/bpmn/optimize/index.js +11 -2
  30. package/dist/bpmn/optimize/types.d.ts +14 -0
  31. package/dist/bpmn/optimize/variable-flow.js +4 -1
  32. package/dist/bpmn/process-types.d.ts +112 -0
  33. package/dist/bpmn/process-types.js +490 -0
  34. package/dist/bpmn/svg.js +51 -22
  35. package/dist/doc/docx.d.ts +20 -0
  36. package/dist/doc/docx.js +253 -0
  37. package/dist/doc/html.d.ts +21 -0
  38. package/dist/doc/html.js +303 -0
  39. package/dist/doc/index.d.ts +7 -0
  40. package/dist/doc/index.js +5 -0
  41. package/dist/doc/markdown.d.ts +11 -0
  42. package/dist/doc/markdown.js +160 -0
  43. package/dist/doc/model.d.ts +129 -0
  44. package/dist/doc/model.js +617 -0
  45. package/dist/doc/zip.d.ts +5 -0
  46. package/dist/doc/zip.js +75 -0
  47. package/dist/index.d.ts +16 -0
  48. package/dist/index.js +8 -0
  49. package/dist/layout/annotations.d.ts +4 -2
  50. package/dist/layout/annotations.js +31 -2
  51. package/dist/layout/collaboration/ordering.d.ts +8 -0
  52. package/dist/layout/collaboration/ordering.js +57 -18
  53. package/dist/layout/orthogonal.d.ts +32 -0
  54. package/dist/layout/orthogonal.js +367 -0
  55. package/dist/layout/repair.d.ts +31 -0
  56. package/dist/layout/repair.js +220 -0
  57. package/dist/layout/semantic/route.js +45 -3
  58. package/dist/node/bpmnlint.d.ts +109 -0
  59. package/dist/node/bpmnlint.js +198 -0
  60. package/dist/node/index.d.ts +2 -0
  61. package/dist/node/index.js +1 -0
  62. package/dist/xml/xml-patch.d.ts +21 -0
  63. package/dist/xml/xml-patch.js +27 -1
  64. package/package.json +2 -2
@@ -0,0 +1,160 @@
1
+ import { buildProcessDocumentation, } from "./model.js";
2
+ /**
3
+ * Escapes text for Markdown that wikis may render as HTML: markup characters
4
+ * become entities, Markdown syntax is backslash-escaped, and line starts that
5
+ * would open a heading, quote or list are neutralised.
6
+ */
7
+ function md(s) {
8
+ return s
9
+ .replace(/&/g, "&")
10
+ .replace(/</g, "&lt;")
11
+ .replace(/>/g, "&gt;")
12
+ .replace(/[\\`*_[\]|~]/g, "\\$&")
13
+ .replace(/^(\s*)([#+-]|\d+\.)/gm, "$1\\$2");
14
+ }
15
+ /** A table cell: one line, pipes escaped. */
16
+ function cell(s) {
17
+ return md(s).replace(/\r?\n/g, "<br>");
18
+ }
19
+ function code(s) {
20
+ // A code span shows its content literally — renderers escape markup inside
21
+ // it themselves — so only what breaks the span or the table needs handling:
22
+ // backticks (longer fence) and pipes.
23
+ const body = s.replace(/\r?\n/g, " ").replace(/\|/g, "\\|");
24
+ const fence = body.includes("`") ? "``" : "`";
25
+ return `${fence}${fence.length > 1 ? " " : ""}${body}${fence.length > 1 ? " " : ""}${fence}`;
26
+ }
27
+ function prose(s) {
28
+ return s
29
+ .split(/\r?\n/)
30
+ .map((line) => md(line))
31
+ .join(" \n");
32
+ }
33
+ function value(v) {
34
+ return v.startsWith("=") ? code(v) : cell(v);
35
+ }
36
+ function propertyValue(p) {
37
+ return Array.isArray(p.value) ? p.value.map(value).join("<br>") : value(p.value);
38
+ }
39
+ function table(head, rows) {
40
+ return [
41
+ `| ${head.join(" | ")} |`,
42
+ `| ${head.map(() => "---").join(" | ")} |`,
43
+ ...rows.map((r) => `| ${r.join(" | ")} |`),
44
+ ];
45
+ }
46
+ function processMd(p) {
47
+ const out = [`## ${md(p.title)}`, ""];
48
+ const meta = [`Process ID ${code(p.id)}`];
49
+ if (p.participant)
50
+ meta.push("drawn as a pool");
51
+ meta.push(p.executable ? "executable" : "not executable");
52
+ out.push(meta.join(" · "), "");
53
+ if (p.documentation)
54
+ out.push(prose(p.documentation), "");
55
+ if (p.lanes.length > 0) {
56
+ out.push("### Lanes and performers", "");
57
+ out.push(...table(["Lane", "Responsible for"], p.lanes.map((l) => [
58
+ cell([...l.path, l.name].join(" / ")),
59
+ l.elements.length > 0 ? cell(l.elements.join(", ")) : "—",
60
+ ])), "");
61
+ }
62
+ if (p.elements.length === 0) {
63
+ out.push("_This process has no elements._", "");
64
+ return out;
65
+ }
66
+ const laneCol = p.lanes.length > 0;
67
+ out.push("### Steps at a glance", "");
68
+ out.push(...table(["#", "Name", "Type", ...(laneCol ? ["Lane"] : [])], p.elements.map((el) => [
69
+ el.number,
70
+ cell(el.name ?? el.id),
71
+ cell(el.typeLabel),
72
+ ...(laneCol ? [cell(el.lane ?? "")] : []),
73
+ ])), "");
74
+ out.push("### Step details", "");
75
+ for (const el of p.elements) {
76
+ out.push(`#### ${el.number} ${md(el.name ?? el.id)}`, "", `_${md(el.typeLabel)}_`, "");
77
+ if (el.documentation)
78
+ out.push(prose(el.documentation), "");
79
+ const rows = [];
80
+ if (el.lane)
81
+ rows.push(["Lane", cell(el.lane)]);
82
+ for (const prop of el.properties)
83
+ rows.push([cell(prop.label), propertyValue(prop)]);
84
+ rows.push(["ID", code(el.id)]);
85
+ out.push(...table(["Property", "Value"], rows), "");
86
+ }
87
+ return out;
88
+ }
89
+ /** Renders already-built documentation as Markdown (GitHub-flavoured tables). */
90
+ export function documentationToMarkdown(doc) {
91
+ const out = [`# ${md(doc.title)}`, ""];
92
+ if (doc.subtitle)
93
+ out.push(md(doc.subtitle), "");
94
+ if (doc.documentation)
95
+ out.push(prose(doc.documentation), "");
96
+ out.push("## Contents", "");
97
+ for (const p of doc.processes)
98
+ out.push(`- ${md(p.title)}`);
99
+ if (doc.messageFlows.length > 0)
100
+ out.push("- Message flows");
101
+ if (doc.decisions.length > 0)
102
+ out.push("- Decisions");
103
+ if (doc.forms.length > 0)
104
+ out.push("- Forms");
105
+ out.push("");
106
+ for (const p of doc.processes)
107
+ out.push(...processMd(p));
108
+ if (doc.messageFlows.length > 0) {
109
+ out.push("## Message flows", "");
110
+ out.push(...table(["From", "To", "Message"], doc.messageFlows.map((m) => [cell(m.from), cell(m.to), cell(m.name ?? m.message ?? "")])), "");
111
+ }
112
+ if (doc.decisions.length > 0) {
113
+ out.push("## Decisions", "");
114
+ for (const d of doc.decisions) {
115
+ out.push(`### ${md(d.name)}`, "");
116
+ const meta = [`Decision ID ${code(d.id)}`, `hit policy ${md(d.hitPolicy)}`];
117
+ if (d.calledBy.length > 0)
118
+ meta.push(`called by ${md(d.calledBy.join(", "))}`);
119
+ out.push(meta.join(" · "), "");
120
+ out.push(...table([
121
+ "#",
122
+ ...d.inputs.map((i) => `When: ${cell(i)}`),
123
+ ...d.outputs.map((o) => `Then: ${cell(o)}`),
124
+ "Note",
125
+ ], d.rules.map((r, i) => [
126
+ String(i + 1),
127
+ ...r.map((c, j) => (j < r.length - 1 ? code(c) : cell(c))),
128
+ ])), "");
129
+ }
130
+ }
131
+ if (doc.forms.length > 0) {
132
+ out.push("## Forms", "");
133
+ for (const f of doc.forms) {
134
+ out.push(`### ${md(f.id)}`, "");
135
+ if (f.usedBy.length > 0)
136
+ out.push(`Shown by ${md(f.usedBy.join(", "))}`, "");
137
+ if (f.fields.length === 0) {
138
+ out.push("_This form has no input fields._", "");
139
+ continue;
140
+ }
141
+ out.push(...table(["Field", "Variable", "Type", "Required", "Options"], f.fields.map((field) => [
142
+ cell(field.label),
143
+ code(field.key),
144
+ cell(field.type),
145
+ field.required ? "Yes" : "No",
146
+ cell(field.options),
147
+ ])), "");
148
+ }
149
+ }
150
+ return `${out.join("\n").trimEnd()}\n`;
151
+ }
152
+ /**
153
+ * Renders a BPMN model as Markdown for wikis and Confluence imports: the same
154
+ * sections as {@link renderDocumentationHtml}, without the diagram (Markdown
155
+ * cannot carry an inline SVG portably — export it with `exportSvg` and link it).
156
+ */
157
+ export function renderDocumentationMarkdown(defs, options) {
158
+ return documentationToMarkdown(buildProcessDocumentation(defs, { ...options, diagram: false }));
159
+ }
160
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1,129 @@
1
+ import type { BpmnDefinitions, BpmnFlowElement } from "../bpmn/bpmn-model.js";
2
+ import type { DmnDefinitions } from "../dmn/dmn-model.js";
3
+ import type { FormDefinition } from "../form/form-model.js";
4
+ /** Options shared by every process documentation renderer. */
5
+ export interface DocumentationOptions {
6
+ /** Document title. Defaults to the first pool / process name, then the definitions id. */
7
+ title?: string;
8
+ /** DMN models whose decision tables are documented after the processes. */
9
+ decisions?: DmnDefinitions[];
10
+ /** Camunda forms whose fields are documented after the processes. */
11
+ forms?: FormDefinition[];
12
+ /** Include the diagram as an SVG image. Default `true`. Needs diagram interchange (DI) data. */
13
+ diagram?: boolean;
14
+ /**
15
+ * A line printed under the title, e.g. a version or a date. Nothing is added
16
+ * by default, so the same model always produces byte-identical output.
17
+ */
18
+ subtitle?: string;
19
+ }
20
+ /** A reference from an element to a decision or form documented in the same document. */
21
+ export interface DocumentationLink {
22
+ kind: "decision" | "form";
23
+ id: string;
24
+ }
25
+ /** One labelled fact about an element, e.g. `Job type: payment-charge`. */
26
+ export interface DocumentedProperty {
27
+ label: string;
28
+ /** One value, or several (rendered as a list). */
29
+ value: string | string[];
30
+ /** Set when the value names a decision or form included in the document. */
31
+ link?: DocumentationLink;
32
+ }
33
+ /** A flow element, in flow order, with everything a reader needs to know about it. */
34
+ export interface DocumentedElement {
35
+ id: string;
36
+ name?: string;
37
+ /** The BPMN element type, e.g. `serviceTask`. */
38
+ type: BpmnFlowElement["type"];
39
+ /** Readable type, e.g. `Timer start event` or `Error boundary event (non-interrupting)`. */
40
+ typeLabel: string;
41
+ /** Outline number: `3`, or `3.2` for the second element inside element 3. */
42
+ number: string;
43
+ /** Nesting depth: 0 for a process-level element, 1 inside a sub-process, and so on. */
44
+ depth: number;
45
+ /** The lane (performer) the element sits in, if the process has lanes. */
46
+ lane?: string;
47
+ documentation?: string;
48
+ properties: DocumentedProperty[];
49
+ }
50
+ /** A lane (performer) and the elements it owns. */
51
+ export interface DocumentedLane {
52
+ id: string;
53
+ name: string;
54
+ /** Parent lane names, outermost first, for nested lanes. */
55
+ path: string[];
56
+ documentation?: string;
57
+ /** Names (or ids) of the lane's elements, in flow order. */
58
+ elements: string[];
59
+ }
60
+ /** One process, or the process behind one pool. */
61
+ export interface DocumentedProcess {
62
+ id: string;
63
+ /** Pool name, process name or id, in that order. */
64
+ title: string;
65
+ /** The pool (participant) name, when the process is drawn as a pool. */
66
+ participant?: string;
67
+ documentation?: string;
68
+ executable: boolean;
69
+ lanes: DocumentedLane[];
70
+ elements: DocumentedElement[];
71
+ }
72
+ /** A message flow between pools. */
73
+ export interface DocumentedMessageFlow {
74
+ id: string;
75
+ name?: string;
76
+ from: string;
77
+ to: string;
78
+ message?: string;
79
+ documentation?: string;
80
+ }
81
+ /** A DMN decision table. */
82
+ export interface DocumentedDecision {
83
+ id: string;
84
+ name: string;
85
+ hitPolicy: string;
86
+ inputs: string[];
87
+ outputs: string[];
88
+ /** One row per rule: input entries, then output entries, then the annotation. */
89
+ rules: string[][];
90
+ /** Names of the elements that call this decision. */
91
+ calledBy: string[];
92
+ }
93
+ /** A form field. Group and dynamic-list children are flattened, their label path joined by ` / `. */
94
+ export interface DocumentedFormField {
95
+ label: string;
96
+ key: string;
97
+ type: string;
98
+ required: boolean;
99
+ /** Selectable values, or the expression / key they come from. */
100
+ options: string;
101
+ }
102
+ /** A Camunda form. */
103
+ export interface DocumentedForm {
104
+ id: string;
105
+ fields: DocumentedFormField[];
106
+ /** Names of the user tasks and start events that show this form. */
107
+ usedBy: string[];
108
+ }
109
+ /** The documentation of one BPMN model, ready for a renderer. */
110
+ export interface ProcessDocumentation {
111
+ title: string;
112
+ subtitle?: string;
113
+ documentation?: string;
114
+ /** The diagram as SVG, or undefined when disabled or when the model has no DI. */
115
+ diagramSvg?: string;
116
+ processes: DocumentedProcess[];
117
+ messageFlows: DocumentedMessageFlow[];
118
+ decisions: DocumentedDecision[];
119
+ forms: DocumentedForm[];
120
+ }
121
+ /** `PT48H` → `48 hours`. Returns undefined for anything that is not a plain ISO duration. */
122
+ export declare function humanizeDuration(value: string): string | undefined;
123
+ /**
124
+ * Collects everything a process document needs from a parsed model, in flow
125
+ * order. The HTML, Markdown and Word renderers all draw from this, so a custom
126
+ * renderer can too.
127
+ */
128
+ export declare function buildProcessDocumentation(defs: BpmnDefinitions, options?: DocumentationOptions): ProcessDocumentation;
129
+ //# sourceMappingURL=model.d.ts.map