@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.
- package/README.md +25 -3
- package/dist/bpmn/agentic.js +3 -1
- package/dist/bpmn/auto-layout.js +184 -15
- package/dist/bpmn/bpmn-builder.js +69 -7
- package/dist/bpmn/bpmn-model.d.ts +78 -0
- package/dist/bpmn/bpmn-parser.js +195 -37
- package/dist/bpmn/bpmn-serializer.js +121 -72
- package/dist/bpmn/bpmnlint.d.ts +153 -0
- package/dist/bpmn/bpmnlint.js +364 -0
- package/dist/bpmn/camunda-compat-data.d.ts +165 -0
- package/dist/bpmn/camunda-compat-data.js +423 -0
- package/dist/bpmn/camunda-compat-feel.d.ts +68 -0
- package/dist/bpmn/camunda-compat-feel.js +338 -0
- package/dist/bpmn/camunda-compat.d.ts +120 -0
- package/dist/bpmn/camunda-compat.js +1677 -0
- package/dist/bpmn/camunda7/juel.d.ts +41 -0
- package/dist/bpmn/camunda7/juel.js +333 -0
- package/dist/bpmn/camunda7/migrate.d.ts +72 -0
- package/dist/bpmn/camunda7/migrate.js +1152 -0
- package/dist/bpmn/full-operations.js +5 -2
- package/dist/bpmn/label-style.d.ts +51 -0
- package/dist/bpmn/label-style.js +116 -0
- package/dist/bpmn/lint.d.ts +23 -3
- package/dist/bpmn/lint.js +47 -10
- package/dist/bpmn/optimize/bpmnlint-rules.d.ts +31 -0
- package/dist/bpmn/optimize/bpmnlint-rules.js +916 -0
- package/dist/bpmn/optimize/deploy.d.ts +8 -2
- package/dist/bpmn/optimize/deploy.js +16 -3
- package/dist/bpmn/optimize/index.js +11 -2
- package/dist/bpmn/optimize/types.d.ts +14 -0
- package/dist/bpmn/optimize/variable-flow.js +4 -1
- package/dist/bpmn/process-types.d.ts +112 -0
- package/dist/bpmn/process-types.js +490 -0
- package/dist/bpmn/svg.js +51 -22
- package/dist/doc/docx.d.ts +20 -0
- package/dist/doc/docx.js +253 -0
- package/dist/doc/html.d.ts +21 -0
- package/dist/doc/html.js +303 -0
- package/dist/doc/index.d.ts +7 -0
- package/dist/doc/index.js +5 -0
- package/dist/doc/markdown.d.ts +11 -0
- package/dist/doc/markdown.js +160 -0
- package/dist/doc/model.d.ts +129 -0
- package/dist/doc/model.js +617 -0
- package/dist/doc/zip.d.ts +5 -0
- package/dist/doc/zip.js +75 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +8 -0
- package/dist/layout/annotations.d.ts +4 -2
- package/dist/layout/annotations.js +31 -2
- package/dist/layout/collaboration/ordering.d.ts +8 -0
- package/dist/layout/collaboration/ordering.js +57 -18
- package/dist/layout/orthogonal.d.ts +32 -0
- package/dist/layout/orthogonal.js +367 -0
- package/dist/layout/repair.d.ts +31 -0
- package/dist/layout/repair.js +220 -0
- package/dist/layout/semantic/route.js +45 -3
- package/dist/node/bpmnlint.d.ts +109 -0
- package/dist/node/bpmnlint.js +198 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +1 -0
- package/dist/xml/xml-patch.d.ts +21 -0
- package/dist/xml/xml-patch.js +27 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BpmnProcess } from "../bpmn-model.js";
|
|
1
|
+
import type { BpmnMessage, BpmnProcess } from "../bpmn-model.js";
|
|
2
2
|
import type { OptimizationFinding } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Given a bundled connector template id and the set of value keys bound on
|
|
@@ -12,5 +12,11 @@ export type ConnectorRequirementsResolver = (templateId: string, boundKeys: stri
|
|
|
12
12
|
* deployment time (`apps/reebe/crates/reebe-bpmn/src/validator.rs`), so a
|
|
13
13
|
* process that passes this profile deploys without a validation error.
|
|
14
14
|
*/
|
|
15
|
-
export declare function analyzeDeploy(p: BpmnProcess, resolveConnectorRequirements?: ConnectorRequirementsResolver
|
|
15
|
+
export declare function analyzeDeploy(p: BpmnProcess, resolveConnectorRequirements?: ConnectorRequirementsResolver,
|
|
16
|
+
/**
|
|
17
|
+
* The document's root messages. Camunda reads a catch's correlation key from
|
|
18
|
+
* the `zeebe:subscription` on the message it references; without these only
|
|
19
|
+
* a key placed on the element itself is seen.
|
|
20
|
+
*/
|
|
21
|
+
messages?: readonly BpmnMessage[]): OptimizationFinding[];
|
|
16
22
|
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -7,9 +7,22 @@ function findExt(el, name) {
|
|
|
7
7
|
* deployment time (`apps/reebe/crates/reebe-bpmn/src/validator.rs`), so a
|
|
8
8
|
* process that passes this profile deploys without a validation error.
|
|
9
9
|
*/
|
|
10
|
-
export function analyzeDeploy(p, resolveConnectorRequirements
|
|
10
|
+
export function analyzeDeploy(p, resolveConnectorRequirements,
|
|
11
|
+
/**
|
|
12
|
+
* The document's root messages. Camunda reads a catch's correlation key from
|
|
13
|
+
* the `zeebe:subscription` on the message it references; without these only
|
|
14
|
+
* a key placed on the element itself is seen.
|
|
15
|
+
*/
|
|
16
|
+
messages = []) {
|
|
11
17
|
const findings = [];
|
|
12
18
|
const processId = p.id;
|
|
19
|
+
const messageById = new Map(messages.map((message) => [message.id, message]));
|
|
20
|
+
const hasCorrelationKey = (element, messageRef) => {
|
|
21
|
+
if (findExt(element, "zeebe:subscription")?.attributes.correlationKey)
|
|
22
|
+
return true;
|
|
23
|
+
const message = messageRef === undefined ? undefined : messageById.get(messageRef);
|
|
24
|
+
return (message?.extensionElements?.some((ext) => ext.name.endsWith(":subscription") && Boolean(ext.attributes.correlationKey)) ?? false);
|
|
25
|
+
};
|
|
13
26
|
if (p.isExecutable !== true) {
|
|
14
27
|
findings.push({
|
|
15
28
|
id: "deploy/process-not-executable",
|
|
@@ -86,9 +99,9 @@ export function analyzeDeploy(p, resolveConnectorRequirements) {
|
|
|
86
99
|
? undefined
|
|
87
100
|
: el.eventDefinitions.find((d) => d.type === "message");
|
|
88
101
|
const isMessageCatch = el.type === "receiveTask" ? el.messageRef !== undefined : messageDef !== undefined;
|
|
102
|
+
const messageRef = el.type === "receiveTask" ? el.messageRef : messageDef?.messageRef;
|
|
89
103
|
if (isMessageCatch) {
|
|
90
|
-
|
|
91
|
-
if (!subscription?.attributes.correlationKey) {
|
|
104
|
+
if (!hasCorrelationKey(el, messageRef)) {
|
|
92
105
|
findings.push({
|
|
93
106
|
id: "deploy/message-catch-no-correlation",
|
|
94
107
|
category: "deploy",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { analyzeCamundaCompat, dedupeCamundaCompat } from "../camunda-compat.js";
|
|
1
2
|
import { analyzeAgentic } from "./agentic.js";
|
|
2
3
|
import { analyzeDeploy } from "./deploy.js";
|
|
3
4
|
import { analyzeFeelSyntax } from "./feel-syntax.js";
|
|
@@ -29,12 +30,13 @@ function resolveOptions(opts) {
|
|
|
29
30
|
reuseThreshold: opts?.reuseThreshold ?? 2,
|
|
30
31
|
categories: opts?.categories ?? [...ALL_CATEGORIES],
|
|
31
32
|
resolveConnectorRequirements: opts?.resolveConnectorRequirements,
|
|
33
|
+
camundaVersion: opts?.camundaVersion,
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
/** Run static analysis on a BPMN definitions object. */
|
|
35
37
|
export function optimize(defs, options) {
|
|
36
38
|
const resolved = resolveOptions(options);
|
|
37
|
-
|
|
39
|
+
let findings = [];
|
|
38
40
|
for (const process of defs.processes) {
|
|
39
41
|
if (resolved.categories.includes("feel")) {
|
|
40
42
|
findings.push(...analyzeFeel(process, resolved));
|
|
@@ -58,7 +60,7 @@ export function optimize(defs, options) {
|
|
|
58
60
|
findings.push(...analyzeVariableFlow(process));
|
|
59
61
|
}
|
|
60
62
|
if (resolved.categories.includes("deploy") || resolved.categories.includes("connector")) {
|
|
61
|
-
const deployFindings = analyzeDeploy(process, resolved.resolveConnectorRequirements);
|
|
63
|
+
const deployFindings = analyzeDeploy(process, resolved.resolveConnectorRequirements, defs.messages);
|
|
62
64
|
findings.push(...deployFindings.filter((f) => (f.category === "deploy" && resolved.categories.includes("deploy")) ||
|
|
63
65
|
(f.category === "connector" && resolved.categories.includes("connector"))));
|
|
64
66
|
}
|
|
@@ -66,6 +68,13 @@ export function optimize(defs, options) {
|
|
|
66
68
|
findings.push(...analyzeAgentic(process));
|
|
67
69
|
}
|
|
68
70
|
}
|
|
71
|
+
// Camunda-version compatibility findings are deployability findings (category
|
|
72
|
+
// `deploy`, ids `compat/…`); a version pinned by a `.bpmnlintrc` asks for them
|
|
73
|
+
// even when the `deploy` category is off, as on a model that names no platform.
|
|
74
|
+
if (resolved.categories.includes("deploy") || options?.camundaVersion !== undefined) {
|
|
75
|
+
findings.push(...analyzeCamundaCompat(defs, resolved.camundaVersion));
|
|
76
|
+
findings = dedupeCamundaCompat(findings);
|
|
77
|
+
}
|
|
69
78
|
const byCategory = Object.fromEntries(ALL_CATEGORIES.map((c) => [c, findings.filter((f) => f.category === c).length]));
|
|
70
79
|
const bySeverity = Object.fromEntries(["info", "warning", "error"].map((s) => [
|
|
71
80
|
s,
|
|
@@ -20,6 +20,11 @@ export interface OptimizationFinding {
|
|
|
20
20
|
produces?: string[];
|
|
21
21
|
/** Data-flow: variable names consumed (read) by the associated element. */
|
|
22
22
|
consumes?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* The bpmnlint rule this finding was reported under, when a `.bpmnlintrc`
|
|
25
|
+
* governs it (see `applyBpmnlintConfig`).
|
|
26
|
+
*/
|
|
27
|
+
bpmnlintRule?: string;
|
|
23
28
|
}
|
|
24
29
|
export interface OptimizationReport {
|
|
25
30
|
findings: OptimizationFinding[];
|
|
@@ -44,6 +49,14 @@ export interface OptimizeOptions {
|
|
|
44
49
|
* are skipped (core has no dependency on the connector catalog).
|
|
45
50
|
*/
|
|
46
51
|
resolveConnectorRequirements?: (templateId: string, boundKeys: string[]) => string[];
|
|
52
|
+
/**
|
|
53
|
+
* The Camunda 8 version the `compat/…` findings check against, e.g. `"8.6"`.
|
|
54
|
+
* Given explicitly, the compatibility check runs even when the `deploy`
|
|
55
|
+
* category is not requested.
|
|
56
|
+
* Defaults to the model's `modeler:executionPlatformVersion`; without either,
|
|
57
|
+
* `compat` reports nothing.
|
|
58
|
+
*/
|
|
59
|
+
camundaVersion?: string;
|
|
47
60
|
}
|
|
48
61
|
export interface ResolvedOptions {
|
|
49
62
|
feelLengthThreshold: number;
|
|
@@ -53,5 +66,6 @@ export interface ResolvedOptions {
|
|
|
53
66
|
reuseThreshold: number;
|
|
54
67
|
categories: OptimizationCategory[];
|
|
55
68
|
resolveConnectorRequirements?: (templateId: string, boundKeys: string[]) => string[];
|
|
69
|
+
camundaVersion?: string;
|
|
56
70
|
}
|
|
57
71
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { parseExpression } from "@bpmnkit/feel";
|
|
1
|
+
import { builtinNames, parseExpression } from "@bpmnkit/feel";
|
|
2
2
|
import { buildFlowIndex, readZeebeIoMapping, readZeebeTaskType } from "./utils.js";
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
4
|
// FEEL built-in names (excluded from variable references)
|
|
5
5
|
// ---------------------------------------------------------------------------
|
|
6
|
+
// The engine's own registry, so a built-in added there is never mistaken for a
|
|
7
|
+
// variable here. The names listed below were here first and stay as a floor.
|
|
6
8
|
const FEEL_BUILTINS = new Set([
|
|
9
|
+
...builtinNames(),
|
|
7
10
|
"string",
|
|
8
11
|
"string length",
|
|
9
12
|
"substring",
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed code generation from BPMN — the contract between a process model and
|
|
3
|
+
* the job workers, message publishers and error throwers written against it.
|
|
4
|
+
*
|
|
5
|
+
* {@link extractProcessContract} reads what a set of definitions promises
|
|
6
|
+
* (process ids, job types with their variables and headers, message / signal /
|
|
7
|
+
* error / escalation names) and {@link generateProcessTypes} renders it as
|
|
8
|
+
* TypeScript source.
|
|
9
|
+
*
|
|
10
|
+
* The types are necessarily approximate — FEEL cannot be fully typed — so
|
|
11
|
+
* every value is `unknown`, but the keys are exact. The rules:
|
|
12
|
+
*
|
|
13
|
+
* - **Jobs** are every element carrying `zeebe:taskDefinition` with a static
|
|
14
|
+
* type: service, send, script and business rule tasks implemented by a job
|
|
15
|
+
* worker, message throw events, and ad-hoc sub-processes (AI Agent job
|
|
16
|
+
* workers). User tasks are left out: Camunda user tasks have no job, and
|
|
17
|
+
* job-based user tasks all share the engine's own type. A type written as a
|
|
18
|
+
* FEEL expression (`=…`) is dynamic and is skipped.
|
|
19
|
+
* - **Variables** (what the worker receives): the targets of the element's
|
|
20
|
+
* `zeebe:input` mappings, all required. With no input mappings, the
|
|
21
|
+
* variables the variable-flow analysis finds in scope on the element's
|
|
22
|
+
* incoming flows (other elements' input targets are local to them and left
|
|
23
|
+
* out), all optional.
|
|
24
|
+
* - **Output** (what the worker should complete with): the root variables the
|
|
25
|
+
* element's `zeebe:output` sources read, minus its own input targets —
|
|
26
|
+
* required when the source is a plain reference (`=total`), optional
|
|
27
|
+
* otherwise. With no output mappings, the variables read downstream that
|
|
28
|
+
* nothing in the process sets, all optional.
|
|
29
|
+
* - **Headers**: `zeebe:taskHeaders` with their literal values; a key missing
|
|
30
|
+
* from some of the elements sharing the job type is optional.
|
|
31
|
+
* - **Errors** a job can throw: the codes caught by error boundary events on the
|
|
32
|
+
* element or its enclosing sub-processes, and by error event sub-processes in
|
|
33
|
+
* those scopes. A catch-all error event widens this to `string`; no catch at
|
|
34
|
+
* all gives `never` (an uncaught error raises an incident).
|
|
35
|
+
* - Elements sharing a job type are merged: a key is required only when every
|
|
36
|
+
* element requires it.
|
|
37
|
+
* - Only executable processes (`isExecutable="true"`) are read.
|
|
38
|
+
*/
|
|
39
|
+
import type { BpmnDefinitions, BpmnFlowElement } from "./bpmn-model.js";
|
|
40
|
+
/** A variable key in a job contract. */
|
|
41
|
+
export interface ContractVariable {
|
|
42
|
+
name: string;
|
|
43
|
+
/** False when the model does not guarantee the key is present. */
|
|
44
|
+
required: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** A task header key and the literal values it takes across elements. */
|
|
47
|
+
export interface ContractHeader {
|
|
48
|
+
key: string;
|
|
49
|
+
values: string[];
|
|
50
|
+
required: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Where a job type, message, signal, error or escalation is used. */
|
|
53
|
+
export interface ContractElementRef {
|
|
54
|
+
processId: string;
|
|
55
|
+
elementId: string;
|
|
56
|
+
elementType: BpmnFlowElement["type"];
|
|
57
|
+
}
|
|
58
|
+
/** Everything a worker for one job type can rely on. */
|
|
59
|
+
export interface JobContract {
|
|
60
|
+
type: string;
|
|
61
|
+
elements: ContractElementRef[];
|
|
62
|
+
variables: ContractVariable[];
|
|
63
|
+
output: ContractVariable[];
|
|
64
|
+
headers: ContractHeader[];
|
|
65
|
+
/** Error codes a worker may throw and have caught; `"any"` when a catch-all exists. */
|
|
66
|
+
errors: string[] | "any";
|
|
67
|
+
}
|
|
68
|
+
/** A message name and the correlation keys its catch events subscribe with. */
|
|
69
|
+
export interface MessageContract {
|
|
70
|
+
name: string;
|
|
71
|
+
correlationKeys: string[];
|
|
72
|
+
elements: ContractElementRef[];
|
|
73
|
+
}
|
|
74
|
+
/** A signal name, error code or escalation code. */
|
|
75
|
+
export interface CodeContract {
|
|
76
|
+
code: string;
|
|
77
|
+
elements: ContractElementRef[];
|
|
78
|
+
}
|
|
79
|
+
/** The contract a set of BPMN definitions promises its workers and clients. */
|
|
80
|
+
export interface ProcessContract {
|
|
81
|
+
processIds: string[];
|
|
82
|
+
jobs: JobContract[];
|
|
83
|
+
messages: MessageContract[];
|
|
84
|
+
signals: CodeContract[];
|
|
85
|
+
errors: CodeContract[];
|
|
86
|
+
escalations: CodeContract[];
|
|
87
|
+
/** Job types written as FEEL expressions — resolved at runtime, so not typed. */
|
|
88
|
+
dynamicJobTypes: ContractElementRef[];
|
|
89
|
+
}
|
|
90
|
+
/** Options for {@link generateProcessTypes}. */
|
|
91
|
+
export interface ProcessTypesOptions {
|
|
92
|
+
/** First line of the header comment. Default: "generated by casen gen types — do not edit". */
|
|
93
|
+
banner?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read the worker-facing contract out of one or more BPMN definitions. Pure and
|
|
97
|
+
* deterministic: every list is sorted.
|
|
98
|
+
*/
|
|
99
|
+
export declare function extractProcessContract(definitions: BpmnDefinitions | readonly BpmnDefinitions[]): ProcessContract;
|
|
100
|
+
/**
|
|
101
|
+
* Render the {@link ProcessContract} of one or more BPMN definitions as
|
|
102
|
+
* TypeScript source. The output is deterministic (everything sorted) and
|
|
103
|
+
* starts with a "do not edit" header.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { Bpmn, generateProcessTypes } from "@bpmnkit/core"
|
|
108
|
+
* const source = generateProcessTypes(Bpmn.parse(xml))
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function generateProcessTypes(definitions: BpmnDefinitions | readonly BpmnDefinitions[], options?: ProcessTypesOptions): string;
|
|
112
|
+
//# sourceMappingURL=process-types.d.ts.map
|