@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.
- package/AGENTS.md +19 -0
- package/README.md +2 -0
- package/agent-cards/bpmn.md +88 -0
- package/agent-cards/dmn.md +105 -0
- package/agent-cards/form.md +72 -0
- package/dist/bpmn/auto-layout.js +2 -1
- package/dist/bpmn/bpmn-builder.d.ts +2 -2
- package/dist/bpmn/bpmn-builder.js +27 -6
- package/dist/bpmn/camunda7/migrate.d.ts +1 -1
- package/dist/bpmn/camunda7/migrate.js +1 -1
- package/dist/bpmn/compact.js +3 -0
- package/dist/bpmn/full-operations.js +2 -0
- package/dist/bpmn/index.d.ts +9 -1
- package/dist/bpmn/index.js +18 -23
- package/dist/bpmn/optimize/deploy.js +14 -0
- package/dist/bpmn/optimize/index.d.ts +2 -0
- package/dist/bpmn/optimize/index.js +5 -0
- package/dist/bpmn/optimize/types.d.ts +7 -0
- package/dist/bpmn/stable-ids.d.ts +15 -0
- package/dist/bpmn/stable-ids.js +26 -0
- package/dist/bpmn/svg.js +5 -6
- package/dist/bpmn/xsd-guards.d.ts +8 -0
- package/dist/bpmn/xsd-guards.js +56 -0
- package/dist/check-finding.d.ts +19 -0
- package/dist/check-finding.js +5 -0
- package/dist/dmn/compact.js +14 -5
- package/dist/dmn/dmn-builder.js +3 -3
- package/dist/dmn/drd-builder.d.ts +53 -0
- package/dist/dmn/drd-builder.js +100 -0
- package/dist/dmn/index.d.ts +35 -0
- package/dist/dmn/index.js +36 -0
- package/dist/dmn/lint.d.ts +19 -0
- package/dist/dmn/lint.js +414 -0
- package/dist/form/form-builder.d.ts +9 -1
- package/dist/form/form-builder.js +34 -1
- package/dist/form/form-model.d.ts +7 -0
- package/dist/form/form-parser.js +22 -0
- package/dist/form/form-serializer.js +10 -0
- package/dist/form/index.d.ts +11 -2
- package/dist/form/index.js +10 -1
- package/dist/form/lint.d.ts +19 -0
- package/dist/form/lint.js +356 -0
- package/dist/index.d.ts +14 -3
- package/dist/index.js +10 -2
- package/dist/layout/grid/edge-labels.d.ts +7 -1
- package/dist/layout/grid/edge-labels.js +62 -1
- package/dist/layout/semantic/index.js +78 -8
- package/dist/layout/semantic/place.d.ts +19 -4
- package/dist/layout/semantic/place.js +232 -34
- package/dist/layout/semantic/route.js +47 -14
- package/llms.txt +9 -0
- package/package.json +5 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @bpmnkit/core for agents
|
|
2
|
+
|
|
3
|
+
Do not read README.md (20 KB) or the .d.ts files first. Read the one card for your task (~1k tokens each). Each has a runnable script, the top options and the known traps.
|
|
4
|
+
|
|
5
|
+
| You write | Read |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| BPMN process | `node_modules/@bpmnkit/core/agent-cards/bpmn.md` |
|
|
8
|
+
| DMN decision table or DRD | `node_modules/@bpmnkit/core/agent-cards/dmn.md` |
|
|
9
|
+
| Camunda form | `node_modules/@bpmnkit/core/agent-cards/form.md` |
|
|
10
|
+
|
|
11
|
+
Rules that hold for all three:
|
|
12
|
+
|
|
13
|
+
- Build with the builders (`Bpmn`, `Dmn`, `Form`). Never write XML or form JSON by hand.
|
|
14
|
+
- Edit an existing file with `Bpmn.parse` and the `export*Preserving` writers, so layout and formatting stay.
|
|
15
|
+
- `formId` and `decisionId` must equal the deployed form id and decision id exactly.
|
|
16
|
+
- Validate before you finish: `npx @bpmnkit/cli check order.bpmn risk.dmn review.form --deploy` (`casen check` if the CLI is installed). Fix every error.
|
|
17
|
+
- Builder errors and check findings end with `agent-cards/<type>.md#traps`. Read that section.
|
|
18
|
+
|
|
19
|
+
The full API reference is `builder-reference.md` in this folder. Open it only when a card does not cover an option.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> **Agents:** read `node_modules/@bpmnkit/core/AGENTS.md`, then `node_modules/@bpmnkit/core/agent-cards/<bpmn|dmn|form>.md` (~1k tokens) instead of this README.
|
|
2
|
+
|
|
1
3
|
<div align="center">
|
|
2
4
|
<a href="https://bpmnkit.com"><img src="https://bpmnkit.com/favicon.svg" width="72" height="72" alt="BPMN Kit logo"></a>
|
|
3
5
|
<h1>@bpmnkit/core</h1>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# BPMN agent card
|
|
2
|
+
|
|
3
|
+
Write a Camunda 8 BPMN process with `@bpmnkit/core` in one script: create, export, edit, validate. Run it with `node --experimental-strip-types build.ts` (Node 22.6+) or `npx tsx build.ts`. Never write BPMN XML by hand.
|
|
4
|
+
|
|
5
|
+
<!-- docspack: tags=agent-card,cheat-sheet,build-script,bpmn,process,create,write,script,builder -->
|
|
6
|
+
|
|
7
|
+
## Minimal BPMN build script: create, export, edit, validate
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
11
|
+
import { Bpmn, exportPreserving, lintDiagram } from "@bpmnkit/core"
|
|
12
|
+
|
|
13
|
+
// 1. Create. The process id is the deploy key: same id = new version of that process.
|
|
14
|
+
const definitions = Bpmn.createProcess("order")
|
|
15
|
+
.name("Order")
|
|
16
|
+
.withAutoLayout()
|
|
17
|
+
.startEvent("received", { name: "Order received" })
|
|
18
|
+
.businessRuleTask("score", { name: "Score risk", decisionId: "risk", resultVariable: "risk" })
|
|
19
|
+
.exclusiveGateway("check", { name: "Risky?" })
|
|
20
|
+
.branch("yes", (b) =>
|
|
21
|
+
b
|
|
22
|
+
.condition('=risk = "high"')
|
|
23
|
+
.label("Yes")
|
|
24
|
+
.userTask("review", { name: "Review order", formId: "review-order", zeebeUserTask: true })
|
|
25
|
+
.connectTo("ship"),
|
|
26
|
+
)
|
|
27
|
+
.branch("no", (b) => b.defaultFlow().label("No").connectTo("ship"))
|
|
28
|
+
.serviceTask("ship", { name: "Ship order", taskType: "ship-order", retries: "3" })
|
|
29
|
+
.endEvent("done", { name: "Order shipped" })
|
|
30
|
+
.build()
|
|
31
|
+
|
|
32
|
+
// 2. Export.
|
|
33
|
+
writeFileSync("order.bpmn", Bpmn.export(definitions))
|
|
34
|
+
|
|
35
|
+
// 3. Edit an existing file: parse, change, write with exportPreserving to keep layout and formatting.
|
|
36
|
+
const original = readFileSync("order.bpmn", "utf8")
|
|
37
|
+
const edited = Bpmn.parse(original)
|
|
38
|
+
const ship = edited.processes[0]?.flowElements.find((e) => e.id === "ship")
|
|
39
|
+
if (ship) ship.name = "Ship parcel"
|
|
40
|
+
writeFileSync("order.bpmn", exportPreserving(original, edited))
|
|
41
|
+
|
|
42
|
+
// 4. Validate: Camunda 8 deployability and modelling rules.
|
|
43
|
+
const report = lintDiagram(Bpmn.parse(readFileSync("order.bpmn", "utf8")))
|
|
44
|
+
for (const d of report.diagnostics.filter((d) => d.severity !== "info"))
|
|
45
|
+
console.log(`${d.severity} ${d.elementIds.join(",")}: ${d.message}`)
|
|
46
|
+
if (report.counts.error > 0) process.exit(1)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`npm i @bpmnkit/core`. The script writes `order.bpmn`, re-opens it, renames a task without moving a shape, and exits 1 on a lint error.
|
|
50
|
+
|
|
51
|
+
## Top builder options
|
|
52
|
+
|
|
53
|
+
- `Bpmn.createProcess(id)` … `.build()`; `.withAutoLayout()` before `.build()`, or the file has no shapes.
|
|
54
|
+
- Every element takes `(id, options)`; ids are unique and each element connects to the previous one.
|
|
55
|
+
- `serviceTask(id, { name, taskType, retries, ioMapping: { inputs, outputs }, taskHeaders })`: `taskType` is the job type a worker subscribes to.
|
|
56
|
+
- `userTask(id, { name, zeebeUserTask: true, formId, assignee, candidateGroups, dueDate })`.
|
|
57
|
+
- `businessRuleTask(id, { decisionId, resultVariable })`: both are required to deploy.
|
|
58
|
+
- `scriptTask(id, { expression: "=a + b", resultVariable })`; `callActivity(id, { processId })`.
|
|
59
|
+
- Gateways: `.exclusiveGateway(id)` then `.branch(name, (b) => b.condition("=x > 1")...)`, one branch `b.defaultFlow()`; `.label(text)` sets the flow label. Merge with `.connectTo(id)` and declare that id after the last branch.
|
|
60
|
+
- Events take named options: `timerDuration: "PT1H"`, `messageName` + `correlationKey`, `errorCode`, `signalName`. `.withBoundary(id, { errorCode }, (b) => ...)` hangs a boundary on the previous task.
|
|
61
|
+
- `multiInstance: { collection: "=items", elementVariable: "item" }` on any task.
|
|
62
|
+
- Full method list: `packages/core/builder-reference.md` in `@bpmnkit/core`, or `npx bpmnkit-docs ask "<option>"`.
|
|
63
|
+
|
|
64
|
+
## Traps
|
|
65
|
+
|
|
66
|
+
- **Camunda 8.10 is the default target.** To target an older cluster, call `.executionPlatformVersion("8.8.0")` so lint checks that version.
|
|
67
|
+
- **User tasks default to job-worker tasks**, which 8.10 deprecates. Pass `zeebeUserTask: true` for a Camunda user task.
|
|
68
|
+
- **Deploy ids.** The engine keys a process by its process id (`createProcess("order")`), a decision by its `<decision id>`, a form by its JSON `id`. File names and display names do not count. `formId` and `decisionId` must equal those ids exactly; by default they bind to the latest deployed version, so deploy the `.dmn` and `.form` before an instance reaches the task. Redeploying the same id makes a new version.
|
|
69
|
+
- **Reference a DMN decision by its decision id**, not the DMN `definitions` id, the file name or the decision name.
|
|
70
|
+
- **Edit with the preserving writer.** For an existing file, `Bpmn.parse` it, change the model, and write `exportPreserving(original, edited)`. Rebuilding it with `withAutoLayout()`, or `Bpmn.export` alone, moves every shape and reformats the diff.
|
|
71
|
+
- FEEL in the builder starts with `=` (`"=amount > 1000"`); a value without `=` is a literal string.
|
|
72
|
+
- Unknown option names are silently dropped: `timer: { duration }` does nothing; use `timerDuration`.
|
|
73
|
+
|
|
74
|
+
- **Gate the export.** `Bpmn.export(defs, { validate: "error" })` lints first and throws on what a deploy would reject (`"warn"` logs; default off). `build()` already rejects invalid ids (NCName), non-boolean `cancelActivity`/`isInterrupting`/`isSequential` and non-numeric `retries`.
|
|
75
|
+
|
|
76
|
+
## Lint before you deploy or test
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
casen check order.bpmn risk.dmn review-order.form --deploy # one gate: BPMN + DMN + forms, and the ids that link them
|
|
80
|
+
casen lint lint order.bpmn --profile deploy # BPMN only, errors only
|
|
81
|
+
casen deploy deploy order.bpmn # local Reebe; --target camunda8 for a cluster
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
In code, `lintDiagram(definitions)` returns `{ diagnostics, counts }`; fail on `counts.error > 0`. Warnings (no timer boundary, no output mapping) are advice.
|
|
85
|
+
|
|
86
|
+
## Writing a process as text instead
|
|
87
|
+
|
|
88
|
+
A model writing the diagram itself can use the line format: `parseProcessText(text)` then `expand(result.diagram)` from `@bpmnkit/core`. `casen agent-card bpmn --text` prints its guide. Related cards: `casen agent-card dmn`, `casen agent-card form`.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# DMN agent card
|
|
2
|
+
|
|
3
|
+
Write a Camunda 8 DMN decision table with `@bpmnkit/core` in one script: create, export, edit, validate. Run it with `node --experimental-strip-types build.ts` (Node 22.6+) or `npx tsx build.ts`. Never write DMN XML by hand.
|
|
4
|
+
|
|
5
|
+
<!-- docspack: tags=agent-card,cheat-sheet,build-script,dmn,decision,decision-table,rules,create,write,script -->
|
|
6
|
+
|
|
7
|
+
## Minimal DMN build script: create, export, edit, validate
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
11
|
+
import { Dmn, exportDmnPreserving } from "@bpmnkit/core"
|
|
12
|
+
|
|
13
|
+
// 1. Create. "risk" is the decision id a BPMN businessRuleTask references as decisionId.
|
|
14
|
+
const definitions = Dmn.createDecisionTable("risk")
|
|
15
|
+
.name("Order risk")
|
|
16
|
+
.hitPolicy("FIRST")
|
|
17
|
+
.input({ label: "Amount", expression: "amount", typeRef: "number" })
|
|
18
|
+
.input({ label: "Country", expression: "country", typeRef: "string" })
|
|
19
|
+
.output({ label: "Risk", name: "risk", typeRef: "string" })
|
|
20
|
+
.rule({ inputs: ["> 1000", "-"], outputs: ['"high"'], description: "Large order" })
|
|
21
|
+
.rule({ inputs: ["-", 'not("DE", "AT")'], outputs: ['"medium"'] })
|
|
22
|
+
.rule({ inputs: ["-", "-"], outputs: ['"low"'] })
|
|
23
|
+
.build()
|
|
24
|
+
|
|
25
|
+
// 2. Export.
|
|
26
|
+
writeFileSync("risk.dmn", Dmn.export(definitions))
|
|
27
|
+
|
|
28
|
+
// 3. Edit an existing file: parse, change, write with exportDmnPreserving to keep the diagram.
|
|
29
|
+
const original = readFileSync("risk.dmn", "utf8")
|
|
30
|
+
const edited = Dmn.parse(original)
|
|
31
|
+
const decision = edited.decisions.find((d) => d.id === "risk")
|
|
32
|
+
if (decision) decision.name = "Order risk level"
|
|
33
|
+
writeFileSync("risk.dmn", exportDmnPreserving(original, edited))
|
|
34
|
+
|
|
35
|
+
// 4. Validate: it parses back and the decision id the process calls is there.
|
|
36
|
+
const check = Dmn.parse(readFileSync("risk.dmn", "utf8"))
|
|
37
|
+
if (!check.decisions.some((d) => d.id === "risk")) {
|
|
38
|
+
console.error("decision 'risk' missing")
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`npm i @bpmnkit/core`. The script writes `risk.dmn` with its diagram, re-opens it, renames the decision without touching the layout, and checks the decision id.
|
|
44
|
+
|
|
45
|
+
## Several decisions in one file: `Dmn.drd()`
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { writeFileSync } from "node:fs"
|
|
49
|
+
import { Dmn } from "@bpmnkit/core"
|
|
50
|
+
|
|
51
|
+
// Two decisions in one file: "approval" reads the result of "riskScore".
|
|
52
|
+
const drd = Dmn.drd("Order approval")
|
|
53
|
+
const riskScore = drd.decision("riskScore", (t) =>
|
|
54
|
+
t
|
|
55
|
+
.name("Risk score")
|
|
56
|
+
.hitPolicy("FIRST")
|
|
57
|
+
.input({ label: "Amount", expression: "amount", typeRef: "number" })
|
|
58
|
+
.output({ label: "Risk", name: "risk", typeRef: "string" })
|
|
59
|
+
.rule({ inputs: ["> 1000"], outputs: ['"high"'] })
|
|
60
|
+
.rule({ inputs: ["-"], outputs: ['"low"'] }),
|
|
61
|
+
)
|
|
62
|
+
drd.decision(
|
|
63
|
+
"approval",
|
|
64
|
+
(t) =>
|
|
65
|
+
t
|
|
66
|
+
.name("Approval")
|
|
67
|
+
.input({ label: "Risk", expression: "risk", typeRef: "string" })
|
|
68
|
+
.output({ label: "Approved", name: "approved", typeRef: "boolean" })
|
|
69
|
+
.rule({ inputs: ['"low"'], outputs: ["true"] })
|
|
70
|
+
.rule({ inputs: ["-"], outputs: ["false"] }),
|
|
71
|
+
{ requires: [riskScore] }, // pass the handle; a name or label is a type error
|
|
72
|
+
)
|
|
73
|
+
writeFileSync("approval.dmn", drd.toXml())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`drd.decision(id, table, { requires })` returns a handle; `requires` takes handles (or `drd.inputData(id, name)` handles), never names. A `requires` that points at an unknown id throws at `build()`/`toXml()`.
|
|
77
|
+
|
|
78
|
+
## Top builder options
|
|
79
|
+
|
|
80
|
+
- `Dmn.createDecisionTable(decisionId)` … `.build()` returns `DmnDefinitions`; `Dmn.export(defs)` gives the XML with DMNDI shapes.
|
|
81
|
+
- `.name(text)` is the display name; `.hitPolicy("UNIQUE" | "FIRST" | "ANY" | "COLLECT" | "RULE ORDER" | "OUTPUT ORDER" | "PRIORITY")`.
|
|
82
|
+
- `.input({ label, expression, typeRef })`: `expression` is a FEEL expression over process variables (`amount`, `order.total`).
|
|
83
|
+
- `.output({ label, name, typeRef })`: `name` is the key in the result.
|
|
84
|
+
- `.rule({ inputs, outputs, description })`: one entry per column, in column order, or `build` throws.
|
|
85
|
+
- `typeRef`: `"string" | "number" | "boolean" | "date"`.
|
|
86
|
+
- Read or change an existing file: `Dmn.parse(xml)` → `defs.decisions[i].decisionTable`.
|
|
87
|
+
|
|
88
|
+
## Traps
|
|
89
|
+
|
|
90
|
+
- **The process calls the decision id.** A BPMN `businessRuleTask(id, { decisionId: "risk", resultVariable: "risk" })` must use the argument of `createDecisionTable("risk")`, not the DMN `definitions` id, the file name or `.name()`. Ids are unique across the cluster: a second file with decision `risk` deploys as a new version of the same decision.
|
|
91
|
+
- **Deploy the `.dmn` before an instance reaches the task.** The call binds to the latest deployed version: `casen deploy deploy risk.dmn` first.
|
|
92
|
+
- **Hit policy `UNIQUE` is the default.** Two matching rules is a runtime incident. Use `FIRST` for a catch-all last row, or `COLLECT` for a list.
|
|
93
|
+
- **Input entries are FEEL unary tests, outputs are FEEL expressions,** and neither starts with `=`. `-` matches anything; `> 1000`, `[1..10]`, `"DE"`, `not("DE", "AT")`. A string output needs quotes: `'"high"'`, not `"high"`.
|
|
94
|
+
- **Result shape.** With one output column the result variable holds the value; with several it holds an object keyed by output `name`; `COLLECT` gives a list.
|
|
95
|
+
- **Edit with the preserving writer.** Write `exportDmnPreserving(original, edited)`; `Dmn.export` alone reformats the file and its diagram.
|
|
96
|
+
|
|
97
|
+
## Validate
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
casen check risk.dmn order.bpmn --deploy # DMN lint + every decisionId in the BPMN resolves
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`casen check <files...>` takes `.bpmn`, `.dmn` and `.form` together and exits 1 on errors; add `--json` for an agent loop. The script above also re-parses the file and checks the decision id.
|
|
104
|
+
|
|
105
|
+
Related cards: `casen agent-card bpmn`, `casen agent-card form`. More: `npx bpmnkit-docs ask "decision table hit policy"`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Form agent card
|
|
2
|
+
|
|
3
|
+
Write a Camunda 8 form (`.form` JSON) with `@bpmnkit/core` in one script: create, export, edit, validate. Run it with `node --experimental-strip-types build.ts` (Node 22.6+) or `npx tsx build.ts`. Never write form JSON by hand.
|
|
4
|
+
|
|
5
|
+
<!-- docspack: tags=agent-card,cheat-sheet,build-script,form,camunda-form,user-task-form,start-form,create,write,script -->
|
|
6
|
+
|
|
7
|
+
## Minimal form build script: create, export, edit, validate
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
11
|
+
import { Form, exportFormPreserving } from "@bpmnkit/core"
|
|
12
|
+
|
|
13
|
+
// 1. Create. "review-order" is the form id a userTask or startEvent references as formId.
|
|
14
|
+
const form = Form.create("review-order")
|
|
15
|
+
.text("## Review order")
|
|
16
|
+
.textfield("Customer", "customer", { validate: { required: true } })
|
|
17
|
+
.select("Decision", "decision", {
|
|
18
|
+
values: [
|
|
19
|
+
{ label: "Approve", value: "approve" },
|
|
20
|
+
{ label: "Reject", value: "reject" },
|
|
21
|
+
],
|
|
22
|
+
validate: { required: true },
|
|
23
|
+
})
|
|
24
|
+
.textarea("Comment", "comment")
|
|
25
|
+
.checkbox("Notify customer", "notify")
|
|
26
|
+
.build()
|
|
27
|
+
|
|
28
|
+
// 2. Export.
|
|
29
|
+
writeFileSync("review-order.form", Form.export(form))
|
|
30
|
+
|
|
31
|
+
// 3. Edit an existing file: parse, change, write with exportFormPreserving to keep key order and ids.
|
|
32
|
+
const original = readFileSync("review-order.form", "utf8")
|
|
33
|
+
const edited = Form.parse(original)
|
|
34
|
+
edited.components.push({
|
|
35
|
+
id: "Field_note",
|
|
36
|
+
type: "text",
|
|
37
|
+
text: "Reviewed orders ship the same day.",
|
|
38
|
+
})
|
|
39
|
+
writeFileSync("review-order.form", exportFormPreserving(original, edited))
|
|
40
|
+
|
|
41
|
+
// 4. Validate: it parses back with the id the process references.
|
|
42
|
+
const check = Form.parse(readFileSync("review-order.form", "utf8"))
|
|
43
|
+
if (check.id !== "review-order") {
|
|
44
|
+
console.error(`form id is ${check.id}, expected review-order`)
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`npm i @bpmnkit/core`. The script writes `review-order.form`, re-opens it, adds a component without reordering the rest, and checks the form id.
|
|
50
|
+
|
|
51
|
+
## Top builder options
|
|
52
|
+
|
|
53
|
+
- `Form.create(id)` … `.build()` returns a `FormDefinition`; `Form.export(form)` gives the JSON.
|
|
54
|
+
- Fields take `(label, key, options)`: `textfield`, `textarea`, `select` (`values` or `valuesKey`), `checkbox`; `radio(label, key, values)`.
|
|
55
|
+
- `text(markdown)` is static text; `group(label, (g) => g.textfield(...))` nests fields.
|
|
56
|
+
- `options.validate`: `{ required, minLength, maxLength }`; `defaultValue`; `id` for a fixed component id.
|
|
57
|
+
- The builder stamps `8.10.0`; override with `.executionPlatformVersion("8.8.0")`.
|
|
58
|
+
- Read or change an existing file: `Form.parse(json)` → `form.components`.
|
|
59
|
+
|
|
60
|
+
## Traps
|
|
61
|
+
|
|
62
|
+
- **The process calls the form id.** `userTask(id, { zeebeUserTask: true, formId: "review-order" })` and `startEvent(id, { formId })` must equal `Form.create("review-order")`, the JSON `id`, not the file name.
|
|
63
|
+
- **Deploy the `.form` before an instance reaches the task.** `formId` binds to the latest deployed form with that id: `casen deploy deploy review-order.form` first. With `formBindingType: "deployment"` it must be in the same deployment as the process.
|
|
64
|
+
- **`key` is the process variable** the field reads and writes. Keep keys equal to the variable names the process and its gateways use; a typo silently creates a new variable.
|
|
65
|
+
- **Use a Camunda user task** (`zeebeUserTask: true`) for a linked form; Camunda 8.10 deprecates job-worker user tasks.
|
|
66
|
+
- **Edit with the preserving writer.** Write `exportFormPreserving(original, edited)`; it keeps key order and component ids, so the diff shows only your change.
|
|
67
|
+
|
|
68
|
+
## Validate
|
|
69
|
+
|
|
70
|
+
The script re-parses the file and checks the form id. Before deploying, run `casen check review-order.form order.bpmn --deploy`: it lints the form and checks that every `formId` in the `.bpmn` names a form. Check by hand that each `key` is a variable the process expects.
|
|
71
|
+
|
|
72
|
+
Related cards: `casen agent-card bpmn`, `casen agent-card dmn`. More: `npx bpmnkit-docs ask "form on a start event"`.
|
package/dist/bpmn/auto-layout.js
CHANGED
|
@@ -752,7 +752,8 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
752
752
|
}
|
|
753
753
|
else {
|
|
754
754
|
dx = PADDING - minX;
|
|
755
|
-
|
|
755
|
+
// Below any pools already stacked; poolY is 0 without a collaboration.
|
|
756
|
+
dy = (process?.id === primaryProcessId ? poolY : 0) + PADDING - minY;
|
|
756
757
|
}
|
|
757
758
|
// Only the primary process shares the root plane; any other root process
|
|
758
759
|
// owns one, instead of being stacked on top of the first at the origin.
|
|
@@ -841,7 +841,7 @@ export declare class ProcessBuilder {
|
|
|
841
841
|
private resolvePendingSplice;
|
|
842
842
|
/** Enable auto-layout: `build()` will run the layout engine and populate diagram interchange data. */
|
|
843
843
|
withAutoLayout(): this;
|
|
844
|
-
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.
|
|
844
|
+
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
|
|
845
845
|
executionPlatformVersion(version: string): this;
|
|
846
846
|
/** Set process-wide defaults applied to subsequently added elements. */
|
|
847
847
|
defaults(options: {
|
|
@@ -1097,7 +1097,7 @@ export declare class DiagramBuilder {
|
|
|
1097
1097
|
private _collaborationId;
|
|
1098
1098
|
private _executionPlatformVersion;
|
|
1099
1099
|
constructor(id: string);
|
|
1100
|
-
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.
|
|
1100
|
+
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
|
|
1101
1101
|
executionPlatformVersion(version: string): this;
|
|
1102
1102
|
process(id: string, callback: (b: ProcessBuilder) => void): this;
|
|
1103
1103
|
/** Renames the collaboration element. Defaults to `"Collaboration_1"`. */
|
|
@@ -3,7 +3,8 @@ import { generateId } from "../types/id-generator.js";
|
|
|
3
3
|
import { applyAutoLayout } from "./auto-layout.js";
|
|
4
4
|
import { createFlowElement } from "./element-shape.js";
|
|
5
5
|
import { REST_CONNECTOR_TEMPLATE_VERSION, restConnectorRetries, restConnectorTaskType, restConnectorToIoMappingInputs, restConnectorToTaskHeaders, } from "./rest-connector.js";
|
|
6
|
-
import { assertExplicitFlowIdsUnique, assignStableFlowIds, markExplicitFlowId, rootDefinitionId, setFlowDiscriminatorSource, } from "./stable-ids.js";
|
|
6
|
+
import { assertExplicitFlowIdsUnique, assignEventDefinitionIds, assignStableFlowIds, markExplicitFlowId, rootDefinitionId, setFlowDiscriminatorSource, } from "./stable-ids.js";
|
|
7
|
+
import { assertRetriesOption, assertXsdValues } from "./xsd-guards.js";
|
|
7
8
|
import { assertZeebePlacement, bpmnElementName, ensureZeebeExtension, makeConditionalDefinition, zeebeExtensionsToXmlElements, } from "./zeebe-extensions.js";
|
|
8
9
|
// Keep in sync with packages/core/package.json version
|
|
9
10
|
const EXPORTER_VERSION = "0.0.23";
|
|
@@ -349,6 +350,7 @@ function buildMappingExtensions(options) {
|
|
|
349
350
|
return extensions;
|
|
350
351
|
}
|
|
351
352
|
function buildServiceTaskExtensions(options) {
|
|
353
|
+
assertRetriesOption(options.retries, options.taskType);
|
|
352
354
|
const extensions = {
|
|
353
355
|
taskDefinition: {
|
|
354
356
|
type: options.taskType,
|
|
@@ -706,7 +708,7 @@ function resolveBoundaryEventArgs(id, attachedToOrOptions, maybeOptions) {
|
|
|
706
708
|
? { ...maybeOptions, attachedTo: attachedToOrOptions }
|
|
707
709
|
: attachedToOrOptions;
|
|
708
710
|
if (typeof options?.attachedTo !== "string" || options.attachedTo === "") {
|
|
709
|
-
throw new ValidationError(`boundaryEvent("${id}") requires the id of the activity it attaches to. Pass it as options.attachedTo, as boundaryEvent("${id}", hostId, options), or use withBoundary() to attach to the preceding activity.`);
|
|
711
|
+
throw new ValidationError(`boundaryEvent("${id}") requires the id of the activity it attaches to. Pass it as options.attachedTo, as boundaryEvent("${id}", hostId, options), or use withBoundary() to attach to the preceding activity. See agent-cards/bpmn.md#traps.`);
|
|
710
712
|
}
|
|
711
713
|
return options;
|
|
712
714
|
}
|
|
@@ -832,6 +834,10 @@ function insertJoinGateways(elements, flows) {
|
|
|
832
834
|
* final until join inference has run, and its id is not final until this pass.
|
|
833
835
|
*/
|
|
834
836
|
function finalizeScope(elements, flows) {
|
|
837
|
+
for (const el of elements) {
|
|
838
|
+
if ("eventDefinitions" in el)
|
|
839
|
+
assignEventDefinitionIds(el.id, el.eventDefinitions);
|
|
840
|
+
}
|
|
835
841
|
insertJoinGateways(elements, flows);
|
|
836
842
|
assignStableFlowIds(elements, flows);
|
|
837
843
|
recomputeIncomingOutgoing(elements, flows);
|
|
@@ -1824,7 +1830,7 @@ export class ProcessBuilder {
|
|
|
1824
1830
|
currentGatewayId;
|
|
1825
1831
|
openBranchEnds = [];
|
|
1826
1832
|
_autoLayout = false;
|
|
1827
|
-
_executionPlatformVersion = "8.
|
|
1833
|
+
_executionPlatformVersion = "8.10.0";
|
|
1828
1834
|
_serviceTaskDefaults = {};
|
|
1829
1835
|
_savedMainFlowId = undefined;
|
|
1830
1836
|
/** Set by {@link ProcessBuilder.from}; makes `build()` update rather than generate. */
|
|
@@ -1975,7 +1981,7 @@ export class ProcessBuilder {
|
|
|
1975
1981
|
this._autoLayout = true;
|
|
1976
1982
|
return this;
|
|
1977
1983
|
}
|
|
1978
|
-
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.
|
|
1984
|
+
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
|
|
1979
1985
|
executionPlatformVersion(version) {
|
|
1980
1986
|
this._executionPlatformVersion = version;
|
|
1981
1987
|
return this;
|
|
@@ -2590,6 +2596,13 @@ export class ProcessBuilder {
|
|
|
2590
2596
|
// not renumber the part the caller did not touch.
|
|
2591
2597
|
assignStableFlowIds(this.flowElements, this.sequenceFlows, this._source === undefined ? undefined : new Set(this._sourceFlowTargets.keys()));
|
|
2592
2598
|
assertExplicitFlowIdsUnique(this.flowElements, this.sequenceFlows);
|
|
2599
|
+
// A continued document keeps its untouched part byte-for-byte, ids included.
|
|
2600
|
+
if (this._source === undefined) {
|
|
2601
|
+
for (const el of this.flowElements) {
|
|
2602
|
+
if ("eventDefinitions" in el)
|
|
2603
|
+
assignEventDefinitionIds(el.id, el.eventDefinitions);
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2593
2606
|
recomputeIncomingOutgoing(this.flowElements, this.sequenceFlows);
|
|
2594
2607
|
if (this._source !== undefined)
|
|
2595
2608
|
return this.buildOntoSource(this._source);
|
|
@@ -2736,6 +2749,14 @@ export class ProcessBuilder {
|
|
|
2736
2749
|
}
|
|
2737
2750
|
}
|
|
2738
2751
|
validate() {
|
|
2752
|
+
// A parsed document keeps whatever ids it came with; only new builds are held to the XSD.
|
|
2753
|
+
if (this._source === undefined) {
|
|
2754
|
+
assertXsdValues({
|
|
2755
|
+
id: this.processId,
|
|
2756
|
+
flowElements: this.flowElements,
|
|
2757
|
+
sequenceFlows: this.sequenceFlows,
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2739
2760
|
const elementIds = new Set(this.flowElements.map((el) => el.id));
|
|
2740
2761
|
for (const flow of this.sequenceFlows) {
|
|
2741
2762
|
if (!elementIds.has(flow.targetRef)) {
|
|
@@ -2831,11 +2852,11 @@ export class DiagramBuilder {
|
|
|
2831
2852
|
_participants = [];
|
|
2832
2853
|
_messageFlows = [];
|
|
2833
2854
|
_collaborationId = "Collaboration_1";
|
|
2834
|
-
_executionPlatformVersion = "8.
|
|
2855
|
+
_executionPlatformVersion = "8.10.0";
|
|
2835
2856
|
constructor(id) {
|
|
2836
2857
|
this._id = id;
|
|
2837
2858
|
}
|
|
2838
|
-
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.
|
|
2859
|
+
/** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
|
|
2839
2860
|
executionPlatformVersion(version) {
|
|
2840
2861
|
this._executionPlatformVersion = version;
|
|
2841
2862
|
return this;
|
|
@@ -36,7 +36,7 @@ export interface Camunda7Report {
|
|
|
36
36
|
total: number;
|
|
37
37
|
}
|
|
38
38
|
export interface Camunda7ConvertOptions {
|
|
39
|
-
/** Written as `modeler:executionPlatformVersion`. Default `"8.
|
|
39
|
+
/** Written as `modeler:executionPlatformVersion`. Default `"8.10.0"`. */
|
|
40
40
|
executionPlatformVersion?: string;
|
|
41
41
|
/**
|
|
42
42
|
* Ignored. Kept for compatibility: earlier versions read `camunda:` attributes
|
|
@@ -6,7 +6,7 @@ import { containsJuel, feelString, isFeelName, translateJuelToFeel } from "./jue
|
|
|
6
6
|
export const CAMUNDA7_NS = "http://camunda.org/schema/1.0/bpmn";
|
|
7
7
|
export const ZEEBE_NS = "http://camunda.org/schema/zeebe/1.0";
|
|
8
8
|
export const MODELER_NS = "http://camunda.org/schema/modeler/1.0";
|
|
9
|
-
const DEFAULT_PLATFORM_VERSION = "8.
|
|
9
|
+
const DEFAULT_PLATFORM_VERSION = "8.10.0";
|
|
10
10
|
/** The event definitions and loop of a flow element, which carry attributes of their own. */
|
|
11
11
|
function nestedHolders(owner) {
|
|
12
12
|
const holders = [];
|
package/dist/bpmn/compact.js
CHANGED
|
@@ -3,6 +3,7 @@ import { layoutProcess } from "../layout/index.js";
|
|
|
3
3
|
import { assertBpmnDefinitions, assertCompactDiagram } from "./argument-guards.js";
|
|
4
4
|
import { addAnnotationShapes } from "./auto-layout.js";
|
|
5
5
|
import { restConnectorTaskType } from "./rest-connector.js";
|
|
6
|
+
import { assignEventDefinitionIds } from "./stable-ids.js";
|
|
6
7
|
import { makeConditionalDefinition } from "./zeebe-extensions.js";
|
|
7
8
|
// ── Default flows ────────────────────────────────────────────────────────────
|
|
8
9
|
/**
|
|
@@ -575,6 +576,8 @@ defaultFlow) {
|
|
|
575
576
|
? makeConditionalDefinition(el.condition)
|
|
576
577
|
: made;
|
|
577
578
|
const eventDefs = eventDef ? [eventDef] : [];
|
|
579
|
+
// Zeebe rejects an id-less definition at deploy time; the builder derives the same ids.
|
|
580
|
+
assignEventDefinitionIds(el.id, eventDefs);
|
|
578
581
|
const subContent = buildSubContent(el.children);
|
|
579
582
|
const loop = el.multiInstance && {
|
|
580
583
|
loopCharacteristics: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertBpmnDefinitions, assertCompactDiagram } from "./argument-guards.js";
|
|
2
2
|
import { buildFlowElement, defaultFlows, makeEventDef, } from "./compact.js";
|
|
3
|
+
import { assignEventDefinitionIds } from "./stable-ids.js";
|
|
3
4
|
import { assertZeebePlacement, bpmnElementName, ensureZeebeExtension, isZeebePlacementAllowed, zeebeExtensionsToXmlElements, } from "./zeebe-extensions.js";
|
|
4
5
|
/** Thrown by {@link applyBpmnOperations} in strict mode. */
|
|
5
6
|
export class OperationError extends Error {
|
|
@@ -568,6 +569,7 @@ function patchElement(definitions, element, patch) {
|
|
|
568
569
|
if (current !== patch.eventType) {
|
|
569
570
|
const replacement = makeEventDef(patch.eventType);
|
|
570
571
|
element.eventDefinitions = replacement ? [replacement] : [];
|
|
572
|
+
assignEventDefinitionIds(element.id, element.eventDefinitions);
|
|
571
573
|
}
|
|
572
574
|
}
|
|
573
575
|
return undefined;
|
package/dist/bpmn/index.d.ts
CHANGED
|
@@ -23,7 +23,14 @@ export declare const SAMPLE_BPMN_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"
|
|
|
23
23
|
*
|
|
24
24
|
* const xml2 = Bpmn.export(defs2)
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see node_modules/@bpmnkit/core/agent-cards/bpmn.md — runnable script and traps (~1k tokens)
|
|
26
28
|
*/
|
|
29
|
+
/** Options for {@link Bpmn.export}. */
|
|
30
|
+
export interface ExportOptions {
|
|
31
|
+
/** Lint before writing: `"warn"` logs deploy errors, `"error"` throws; `false` (default) skips. */
|
|
32
|
+
validate?: "warn" | "error" | false;
|
|
33
|
+
}
|
|
27
34
|
export declare const Bpmn: {
|
|
28
35
|
/**
|
|
29
36
|
* Create a new BPMN process using the fluent builder API.
|
|
@@ -98,6 +105,7 @@ export declare const Bpmn: {
|
|
|
98
105
|
* Serialise a {@link BpmnDefinitions} model back to BPMN 2.0 XML.
|
|
99
106
|
*
|
|
100
107
|
* @param definitions - The typed BPMN model to export.
|
|
108
|
+
* @param options - `validate: "warn" | "error"` lints first and reports what a deploy would reject (default `false`: no lint).
|
|
101
109
|
* @returns A BPMN 2.0 XML string.
|
|
102
110
|
*
|
|
103
111
|
* @example
|
|
@@ -106,7 +114,7 @@ export declare const Bpmn: {
|
|
|
106
114
|
* fs.writeFileSync("diagram.bpmn", xml, "utf-8")
|
|
107
115
|
* ```
|
|
108
116
|
*/
|
|
109
|
-
readonly export: (definitions: BpmnDefinitions) => string;
|
|
117
|
+
readonly export: (definitions: BpmnDefinitions, options?: ExportOptions) => string;
|
|
110
118
|
/**
|
|
111
119
|
* Returns a minimal valid BPMN XML string containing one process with a
|
|
112
120
|
* single start event. Useful for "New Diagram" / empty-canvas actions.
|
package/dist/bpmn/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ValidationError } from "../errors.js";
|
|
1
2
|
import { applyAutoLayout } from "./auto-layout.js";
|
|
2
3
|
import { DiagramBuilder, ProcessBuilder } from "./bpmn-builder.js";
|
|
3
4
|
import { parseBpmn } from "./bpmn-parser.js";
|
|
4
5
|
import { serializeBpmn } from "./bpmn-serializer.js";
|
|
6
|
+
import { lintDiagram } from "./lint.js";
|
|
5
7
|
/** A minimal 3-element BPMN diagram useful for first-launch or "New Diagram" defaults. */
|
|
6
8
|
export const SAMPLE_BPMN_XML = `<?xml version="1.0" encoding="UTF-8"?>
|
|
7
9
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
|
@@ -45,28 +47,6 @@ export const SAMPLE_BPMN_XML = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
45
47
|
</bpmndi:BPMNPlane>
|
|
46
48
|
</bpmndi:BPMNDiagram>
|
|
47
49
|
</bpmn:definitions>`;
|
|
48
|
-
/**
|
|
49
|
-
* Entry point for all BPMN operations — parsing, building, exporting, and
|
|
50
|
-
* creating empty diagrams.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* import { Bpmn } from "@bpmnkit/core"
|
|
55
|
-
*
|
|
56
|
-
* // Parse existing XML
|
|
57
|
-
* const defs = Bpmn.parse(xml)
|
|
58
|
-
*
|
|
59
|
-
* // Build a new process
|
|
60
|
-
* const defs2 = Bpmn.createProcess("order")
|
|
61
|
-
* .startEvent("start")
|
|
62
|
-
* .serviceTask("task", { name: "Process", taskType: "process" })
|
|
63
|
-
* .endEvent("end")
|
|
64
|
-
* .withAutoLayout()
|
|
65
|
-
* .build()
|
|
66
|
-
*
|
|
67
|
-
* const xml2 = Bpmn.export(defs2)
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
50
|
export const Bpmn = {
|
|
71
51
|
/**
|
|
72
52
|
* Create a new BPMN process using the fluent builder API.
|
|
@@ -149,6 +129,7 @@ export const Bpmn = {
|
|
|
149
129
|
* Serialise a {@link BpmnDefinitions} model back to BPMN 2.0 XML.
|
|
150
130
|
*
|
|
151
131
|
* @param definitions - The typed BPMN model to export.
|
|
132
|
+
* @param options - `validate: "warn" | "error"` lints first and reports what a deploy would reject (default `false`: no lint).
|
|
152
133
|
* @returns A BPMN 2.0 XML string.
|
|
153
134
|
*
|
|
154
135
|
* @example
|
|
@@ -157,7 +138,21 @@ export const Bpmn = {
|
|
|
157
138
|
* fs.writeFileSync("diagram.bpmn", xml, "utf-8")
|
|
158
139
|
* ```
|
|
159
140
|
*/
|
|
160
|
-
export(definitions) {
|
|
141
|
+
export(definitions, options = {}) {
|
|
142
|
+
const mode = options.validate ?? false;
|
|
143
|
+
if (mode !== false) {
|
|
144
|
+
// Only the errors a Camunda 8 deploy would reject; an engine-neutral model is not judged.
|
|
145
|
+
const errors = lintDiagram(definitions).diagnostics.filter((d) => d.severity === "error");
|
|
146
|
+
if (errors.length > 0) {
|
|
147
|
+
const text = errors
|
|
148
|
+
.map((d) => `${d.id} [${d.elementIds.join(", ")}]: ${d.message} Fix: ${d.suggestion}`)
|
|
149
|
+
.join("\n");
|
|
150
|
+
if (mode === "error") {
|
|
151
|
+
throw new ValidationError(`Bpmn.export: ${errors.length} deploy error(s):\n${text}`);
|
|
152
|
+
}
|
|
153
|
+
console.warn(`Bpmn.export: ${errors.length} deploy error(s):\n${text}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
161
156
|
return serializeBpmn(definitions);
|
|
162
157
|
},
|
|
163
158
|
/**
|
|
@@ -35,6 +35,20 @@ messages = []) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
for (const el of p.flowElements) {
|
|
38
|
+
if ("eventDefinitions" in el) {
|
|
39
|
+
const missingId = el.eventDefinitions.filter((d) => !d.id);
|
|
40
|
+
if (missingId.length > 0) {
|
|
41
|
+
findings.push({
|
|
42
|
+
id: "deploy/event-definition-no-id",
|
|
43
|
+
category: "deploy",
|
|
44
|
+
severity: "error",
|
|
45
|
+
message: `"${el.name ?? el.id}" has ${missingId.length} event definition(s) without an id.`,
|
|
46
|
+
suggestion: "Give every event definition an id (e.g. <ElementId>_TimerEventDefinition) — Zeebe rejects a definition without one.",
|
|
47
|
+
processId,
|
|
48
|
+
elementIds: [el.id],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
38
52
|
if (el.type === "serviceTask" || el.type === "sendTask") {
|
|
39
53
|
const type = readZeebeTaskType(el.extensionElements);
|
|
40
54
|
if (!type) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BpmnDefinitions } from "../bpmn-model.js";
|
|
2
2
|
import type { OptimizationReport, OptimizeOptions } from "./types.js";
|
|
3
|
+
/** The finding a user task with no form raises; see `OptimizeOptions.userTaskForms`. */
|
|
4
|
+
export declare const USER_TASK_FORM_RULE = "compat/user-task-definition";
|
|
3
5
|
/** Run static analysis on a BPMN definitions object. */
|
|
4
6
|
export declare function optimize(defs: BpmnDefinitions, options?: OptimizeOptions): OptimizationReport;
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -8,6 +8,8 @@ import { analyzeNaming } from "./naming.js";
|
|
|
8
8
|
import { analyzePatterns } from "./patterns.js";
|
|
9
9
|
import { analyzeTasks } from "./tasks.js";
|
|
10
10
|
import { analyzeVariableFlow } from "./variable-flow.js";
|
|
11
|
+
/** The finding a user task with no form raises; see `OptimizeOptions.userTaskForms`. */
|
|
12
|
+
export const USER_TASK_FORM_RULE = "compat/user-task-definition";
|
|
11
13
|
const ALL_CATEGORIES = [
|
|
12
14
|
"feel",
|
|
13
15
|
"feel-syntax",
|
|
@@ -74,6 +76,9 @@ export function optimize(defs, options) {
|
|
|
74
76
|
if (resolved.categories.includes("deploy") || options?.camundaVersion !== undefined) {
|
|
75
77
|
findings.push(...analyzeCamundaCompat(defs, resolved.camundaVersion));
|
|
76
78
|
findings = dedupeCamundaCompat(findings);
|
|
79
|
+
if (options?.userTaskForms === "off") {
|
|
80
|
+
findings = findings.filter((f) => f.id !== USER_TASK_FORM_RULE);
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
const byCategory = Object.fromEntries(ALL_CATEGORIES.map((c) => [c, findings.filter((f) => f.category === c).length]));
|
|
79
84
|
const bySeverity = Object.fromEntries(["info", "warning", "error"].map((s) => [
|
|
@@ -57,6 +57,13 @@ export interface OptimizeOptions {
|
|
|
57
57
|
* `compat` reports nothing.
|
|
58
58
|
*/
|
|
59
59
|
camundaVersion?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a user task with no `zeebe:formDefinition` is reported
|
|
62
|
+
* (`compat/user-task-definition`). Default `"require"`. Zeebe deploys such a
|
|
63
|
+
* task fine; `"off"` suits a sketch or a gate that should not push an author
|
|
64
|
+
* to invent a form reference.
|
|
65
|
+
*/
|
|
66
|
+
userTaskForms?: "require" | "off";
|
|
60
67
|
}
|
|
61
68
|
export interface ResolvedOptions {
|
|
62
69
|
feelLengthThreshold: number;
|