@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
|
@@ -22,6 +22,16 @@ export function exportForm(form) {
|
|
|
22
22
|
return JSON.stringify(obj, null, 2);
|
|
23
23
|
}
|
|
24
24
|
function serializeComponent(component) {
|
|
25
|
+
const out = serializeKnownComponent(component);
|
|
26
|
+
if (component.conditional !== undefined)
|
|
27
|
+
out.conditional = { ...component.conditional };
|
|
28
|
+
for (const [key, value] of Object.entries(component.extraProps ?? {})) {
|
|
29
|
+
if (!(key in out))
|
|
30
|
+
out[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
function serializeKnownComponent(component) {
|
|
25
35
|
// Use the type discriminant, casting where TypeScript can't narrow through FormUnknownComponent
|
|
26
36
|
const type = component.type;
|
|
27
37
|
switch (type) {
|
package/dist/form/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { FormComponent, FormButtonComponent, FormCheckboxComponent, FormChecklistComponent, FormDatetimeComponent, FormDefinition, FormDocumentPreviewComponent, FormDynamicListComponent, FormExporter, FormExpressionComponent, FormFilepickerComponent, FormGroupComponent, FormHtmlComponent, FormIframeComponent, FormImageComponent, FormLayout, FormLayoutInput, FormNumberComponent, FormRadioComponent, FormSelectComponent, FormSeparatorComponent, FormSpacerComponent, FormTableComponent, FormTaglistComponent, FormTextAreaComponent, FormTextComponent, FormTextFieldComponent, FormUnknownComponent, FormValidation, FormValueOption, } from "./form-model.js";
|
|
1
|
+
export type { FormComponent, FormButtonComponent, FormCheckboxComponent, FormChecklistComponent, FormDatetimeComponent, FormDefinition, FormDocumentPreviewComponent, FormDynamicListComponent, FormExporter, FormExpressionComponent, FormFilepickerComponent, FormGroupComponent, FormHtmlComponent, FormIframeComponent, FormImageComponent, FormConditional, FormLayout, FormLayoutInput, FormNumberComponent, FormRadioComponent, FormSelectComponent, FormSeparatorComponent, FormSpacerComponent, FormTableComponent, FormTaglistComponent, FormTextAreaComponent, FormTextComponent, FormTextFieldComponent, FormUnknownComponent, FormValidation, FormValueOption, } from "./form-model.js";
|
|
2
2
|
export { parseForm } from "./form-parser.js";
|
|
3
3
|
export { exportForm } from "./form-serializer.js";
|
|
4
4
|
export { FormBuilder, GroupBuilder } from "./form-builder.js";
|
|
@@ -9,7 +9,16 @@ import { compactifyForm } from "./compact.js";
|
|
|
9
9
|
import type { CompactForm } from "./compact.js";
|
|
10
10
|
import { FormBuilder } from "./form-builder.js";
|
|
11
11
|
import type { FormDefinition } from "./form-model.js";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Top-level Form namespace providing create, parse, and export entry points.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const form = Form.create("review-order").textfield("Note", "note").build()
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see node_modules/@bpmnkit/core/agent-cards/form.md — runnable script and traps (~1k tokens)
|
|
21
|
+
*/
|
|
13
22
|
export declare const Form: {
|
|
14
23
|
/** Creates a new form using a fluent builder. */
|
|
15
24
|
readonly create: (id?: string) => FormBuilder;
|
package/dist/form/index.js
CHANGED
|
@@ -7,7 +7,16 @@ import { compactifyForm, expandForm } from "./compact.js";
|
|
|
7
7
|
import { FormBuilder } from "./form-builder.js";
|
|
8
8
|
import { parseForm } from "./form-parser.js";
|
|
9
9
|
import { exportForm } from "./form-serializer.js";
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Top-level Form namespace providing create, parse, and export entry points.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const form = Form.create("review-order").textfield("Note", "note").build()
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @see node_modules/@bpmnkit/core/agent-cards/form.md — runnable script and traps (~1k tokens)
|
|
19
|
+
*/
|
|
11
20
|
export const Form = {
|
|
12
21
|
/** Creates a new form using a fluent builder. */
|
|
13
22
|
create(id) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type CheckFinding } from "../check-finding.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks a Camunda form (form-js JSON schema) for what Zeebe deploys without
|
|
4
|
+
* complaint but Tasklist then fails on: invalid schema shape, duplicate
|
|
5
|
+
* component ids or keys, input fields bound to no variable, and FEEL in
|
|
6
|
+
* conditions and expressions that does not parse.
|
|
7
|
+
*
|
|
8
|
+
* Works on the raw JSON rather than `Form.parse`, so every problem in the
|
|
9
|
+
* document is reported instead of only the first one the parser throws on.
|
|
10
|
+
*
|
|
11
|
+
* @param json - The form's JSON text.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* for (const f of lintForm(json)) console.log(`${f.rule} [${f.elementId}] ${f.message} — ${f.fix}`)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function lintForm(json: string): CheckFinding[];
|
|
19
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { parseExpression } from "@bpmnkit/feel";
|
|
2
|
+
import { withCardHint } from "../check-finding.js";
|
|
3
|
+
/** form-js component types (form-js 1.x, as Camunda Tasklist renders them). */
|
|
4
|
+
const KNOWN_TYPES = new Set([
|
|
5
|
+
"text",
|
|
6
|
+
"textfield",
|
|
7
|
+
"textarea",
|
|
8
|
+
"number",
|
|
9
|
+
"datetime",
|
|
10
|
+
"select",
|
|
11
|
+
"radio",
|
|
12
|
+
"checkbox",
|
|
13
|
+
"checklist",
|
|
14
|
+
"taglist",
|
|
15
|
+
"button",
|
|
16
|
+
"group",
|
|
17
|
+
"dynamiclist",
|
|
18
|
+
"iframe",
|
|
19
|
+
"image",
|
|
20
|
+
"table",
|
|
21
|
+
"html",
|
|
22
|
+
"separator",
|
|
23
|
+
"spacer",
|
|
24
|
+
"expression",
|
|
25
|
+
"filepicker",
|
|
26
|
+
"documentPreview",
|
|
27
|
+
]);
|
|
28
|
+
/** Components that bind a value to a process variable, and so need a `key`. */
|
|
29
|
+
const KEYED_TYPES = new Set([
|
|
30
|
+
"textfield",
|
|
31
|
+
"textarea",
|
|
32
|
+
"number",
|
|
33
|
+
"datetime",
|
|
34
|
+
"select",
|
|
35
|
+
"radio",
|
|
36
|
+
"checkbox",
|
|
37
|
+
"checklist",
|
|
38
|
+
"taglist",
|
|
39
|
+
"expression",
|
|
40
|
+
"filepicker",
|
|
41
|
+
]);
|
|
42
|
+
/** Components that choose from a list of options. */
|
|
43
|
+
const OPTION_TYPES = new Set(["select", "radio", "checklist", "taglist"]);
|
|
44
|
+
/** Containers whose `path` opens a nested data scope for the keys inside them. */
|
|
45
|
+
const SCOPED_CONTAINERS = new Set(["group", "dynamiclist"]);
|
|
46
|
+
const KEY_PATTERN = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/;
|
|
47
|
+
/** Properties that are not expressions even though a value may happen to start with `=`. */
|
|
48
|
+
const NON_FEEL_KEYS = new Set(["components", "id", "type", "key", "path", "values"]);
|
|
49
|
+
function isObject(value) {
|
|
50
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks a Camunda form (form-js JSON schema) for what Zeebe deploys without
|
|
54
|
+
* complaint but Tasklist then fails on: invalid schema shape, duplicate
|
|
55
|
+
* component ids or keys, input fields bound to no variable, and FEEL in
|
|
56
|
+
* conditions and expressions that does not parse.
|
|
57
|
+
*
|
|
58
|
+
* Works on the raw JSON rather than `Form.parse`, so every problem in the
|
|
59
|
+
* document is reported instead of only the first one the parser throws on.
|
|
60
|
+
*
|
|
61
|
+
* @param json - The form's JSON text.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* for (const f of lintForm(json)) console.log(`${f.rule} [${f.elementId}] ${f.message} — ${f.fix}`)
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function lintForm(json) {
|
|
69
|
+
return withCardHint(lintFormFindings(json), "form");
|
|
70
|
+
}
|
|
71
|
+
function lintFormFindings(json) {
|
|
72
|
+
let root;
|
|
73
|
+
try {
|
|
74
|
+
root = JSON.parse(json);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
rule: "form/invalid-json",
|
|
80
|
+
severity: "error",
|
|
81
|
+
message: `The form is not valid JSON: ${err.message}`,
|
|
82
|
+
fix: "Fix the JSON syntax (trailing commas, unquoted keys and single quotes are not allowed).",
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
if (!isObject(root)) {
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
rule: "form/invalid-schema",
|
|
90
|
+
severity: "error",
|
|
91
|
+
message: "The form's top level is not a JSON object.",
|
|
92
|
+
fix: 'Write the form as { "id": "…", "type": "default", "components": [ … ] }.',
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
const findings = [];
|
|
97
|
+
if (typeof root.id !== "string" || root.id === "") {
|
|
98
|
+
findings.push({
|
|
99
|
+
rule: "form/missing-id",
|
|
100
|
+
severity: "error",
|
|
101
|
+
message: "The form has no id.",
|
|
102
|
+
fix: 'Add a top-level "id" — a user task links the form by it (zeebe:formDefinition formId).',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (root.type !== "default") {
|
|
106
|
+
findings.push({
|
|
107
|
+
rule: "form/invalid-schema",
|
|
108
|
+
severity: "error",
|
|
109
|
+
message: `The form's top-level "type" is ${JSON.stringify(root.type)}, not "default".`,
|
|
110
|
+
fix: 'Set "type": "default".',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (root.schemaVersion !== undefined && typeof root.schemaVersion !== "number") {
|
|
114
|
+
findings.push({
|
|
115
|
+
rule: "form/invalid-schema",
|
|
116
|
+
severity: "warning",
|
|
117
|
+
message: `"schemaVersion" is ${JSON.stringify(root.schemaVersion)}, not a number.`,
|
|
118
|
+
fix: 'Set "schemaVersion" to a number, e.g. 16, or remove it.',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (!Array.isArray(root.components)) {
|
|
122
|
+
findings.push({
|
|
123
|
+
rule: "form/invalid-schema",
|
|
124
|
+
severity: "error",
|
|
125
|
+
message: 'The form has no "components" array.',
|
|
126
|
+
fix: 'Add "components": [ … ] with the form\'s fields.',
|
|
127
|
+
});
|
|
128
|
+
return findings;
|
|
129
|
+
}
|
|
130
|
+
const walk = { findings, ids: new Map(), keys: new Map() };
|
|
131
|
+
if (typeof root.id === "string")
|
|
132
|
+
walk.ids.set(root.id, "the form");
|
|
133
|
+
walkComponents(root.components, "", "components", walk);
|
|
134
|
+
return findings;
|
|
135
|
+
}
|
|
136
|
+
function walkComponents(components, scope, path, w) {
|
|
137
|
+
components.forEach((component, index) => {
|
|
138
|
+
const at = `${path}[${index}]`;
|
|
139
|
+
if (!isObject(component)) {
|
|
140
|
+
w.findings.push({
|
|
141
|
+
rule: "form/invalid-schema",
|
|
142
|
+
severity: "error",
|
|
143
|
+
message: `${at} is not an object.`,
|
|
144
|
+
fix: 'Write each component as { "id": "…", "type": "…", … }.',
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
checkComponent(component, scope, at, w);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function checkComponent(c, scope, at, w) {
|
|
152
|
+
const id = typeof c.id === "string" && c.id !== "" ? c.id : undefined;
|
|
153
|
+
const where = id !== undefined ? { elementId: id } : {};
|
|
154
|
+
const label = id !== undefined ? `Component "${id}"` : at;
|
|
155
|
+
const type = typeof c.type === "string" ? c.type : undefined;
|
|
156
|
+
if (type === undefined) {
|
|
157
|
+
w.findings.push({
|
|
158
|
+
rule: "form/invalid-schema",
|
|
159
|
+
severity: "error",
|
|
160
|
+
...where,
|
|
161
|
+
message: `${label} has no "type".`,
|
|
162
|
+
fix: `Set "type" to one of ${[...KNOWN_TYPES].join(", ")}.`,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else if (!KNOWN_TYPES.has(type)) {
|
|
166
|
+
w.findings.push({
|
|
167
|
+
rule: "form/unknown-type",
|
|
168
|
+
severity: "warning",
|
|
169
|
+
...where,
|
|
170
|
+
message: `${label} has type "${type}", which form-js does not provide.`,
|
|
171
|
+
fix: `Use one of ${[...KNOWN_TYPES].join(", ")} — unless "${type}" is a custom component registered in your Tasklist.`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (id === undefined) {
|
|
175
|
+
w.findings.push({
|
|
176
|
+
rule: "form/missing-id",
|
|
177
|
+
severity: "error",
|
|
178
|
+
message: `${at}${type !== undefined ? ` (${type})` : ""} has no id.`,
|
|
179
|
+
fix: 'Give every component a unique "id", e.g. "Field_amount".',
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else if (w.ids.has(id)) {
|
|
183
|
+
w.findings.push({
|
|
184
|
+
rule: "form/duplicate-id",
|
|
185
|
+
severity: "error",
|
|
186
|
+
elementId: id,
|
|
187
|
+
message: `The id "${id}" is used by ${w.ids.get(id)} and by ${at}.`,
|
|
188
|
+
fix: "Give each component its own id.",
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
w.ids.set(id, at);
|
|
193
|
+
}
|
|
194
|
+
if (type !== undefined && KEYED_TYPES.has(type))
|
|
195
|
+
checkKey(c, type, scope, label, where, w);
|
|
196
|
+
if (type !== undefined && OPTION_TYPES.has(type)) {
|
|
197
|
+
const hasValues = Array.isArray(c.values) && c.values.length > 0;
|
|
198
|
+
const hasSource = typeof c.valuesKey === "string" || typeof c.valuesExpression === "string";
|
|
199
|
+
if (!hasValues && !hasSource) {
|
|
200
|
+
w.findings.push({
|
|
201
|
+
rule: "form/missing-options",
|
|
202
|
+
severity: "error",
|
|
203
|
+
...where,
|
|
204
|
+
message: `${label} (${type}) has no options.`,
|
|
205
|
+
fix: 'Add "values": [{ "label": "…", "value": "…" }], or take them from a variable with "valuesKey" or "valuesExpression".',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (type === "expression" && (typeof c.expression !== "string" || c.expression.trim() === "")) {
|
|
210
|
+
w.findings.push({
|
|
211
|
+
rule: "form/missing-expression",
|
|
212
|
+
severity: "error",
|
|
213
|
+
...where,
|
|
214
|
+
message: `${label} is an expression field with no "expression".`,
|
|
215
|
+
fix: 'Set "expression" to a FEEL expression starting with "=", e.g. "=amount * 1.2".',
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (type === "button" &&
|
|
219
|
+
c.action !== undefined &&
|
|
220
|
+
c.action !== "submit" &&
|
|
221
|
+
c.action !== "reset") {
|
|
222
|
+
w.findings.push({
|
|
223
|
+
rule: "form/invalid-schema",
|
|
224
|
+
severity: "error",
|
|
225
|
+
...where,
|
|
226
|
+
message: `${label} has button action ${JSON.stringify(c.action)}.`,
|
|
227
|
+
fix: 'Use "action": "submit" or "reset".',
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
checkConditional(c, label, where, w);
|
|
231
|
+
checkValidation(c, label, where, w);
|
|
232
|
+
checkFeelProperties(c, "", label, where, w);
|
|
233
|
+
if (Array.isArray(c.components)) {
|
|
234
|
+
const path = typeof c.path === "string" && c.path !== "" ? c.path : undefined;
|
|
235
|
+
const nested = type !== undefined && SCOPED_CONTAINERS.has(type) && path !== undefined
|
|
236
|
+
? scope === ""
|
|
237
|
+
? path
|
|
238
|
+
: `${scope}.${path}`
|
|
239
|
+
: scope;
|
|
240
|
+
walkComponents(c.components, nested, `${at}.components`, w);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function checkKey(c, type, scope, label, where, w) {
|
|
244
|
+
const key = c.key;
|
|
245
|
+
if (typeof key !== "string" || key === "") {
|
|
246
|
+
// An expression field may compute a value without binding it.
|
|
247
|
+
if (type === "expression")
|
|
248
|
+
return;
|
|
249
|
+
w.findings.push({
|
|
250
|
+
rule: "form/missing-key",
|
|
251
|
+
severity: "error",
|
|
252
|
+
...where,
|
|
253
|
+
message: `${label} (${type}) is not bound to a variable — it has no "key".`,
|
|
254
|
+
fix: 'Set "key" to the process variable the field reads and writes, e.g. "amount".',
|
|
255
|
+
});
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (!KEY_PATTERN.test(key)) {
|
|
259
|
+
w.findings.push({
|
|
260
|
+
rule: "form/invalid-key",
|
|
261
|
+
severity: "error",
|
|
262
|
+
...where,
|
|
263
|
+
message: `${label} has key "${key}", which is not a variable name or dotted path.`,
|
|
264
|
+
fix: "Use letters, digits, `_` and `$`, not starting with a digit; separate nested names with dots.",
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
const keys = w.keys.get(scope) ?? new Set();
|
|
268
|
+
w.keys.set(scope, keys);
|
|
269
|
+
if (keys.has(key)) {
|
|
270
|
+
w.findings.push({
|
|
271
|
+
rule: "form/duplicate-key",
|
|
272
|
+
severity: "error",
|
|
273
|
+
...where,
|
|
274
|
+
message: `${label} binds key "${key}"${scope === "" ? "" : ` (in "${scope}")`}, which another field already binds.`,
|
|
275
|
+
fix: "Give each field its own key; two fields on one key overwrite each other's value on submit.",
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
keys.add(key);
|
|
279
|
+
}
|
|
280
|
+
function checkConditional(c, label, where, w) {
|
|
281
|
+
if (!isObject(c.conditional))
|
|
282
|
+
return;
|
|
283
|
+
const hide = c.conditional.hide;
|
|
284
|
+
if (typeof hide === "string" && hide.trim() !== "" && !hide.trim().startsWith("=")) {
|
|
285
|
+
w.findings.push({
|
|
286
|
+
rule: "form/conditional-not-feel",
|
|
287
|
+
severity: "warning",
|
|
288
|
+
...where,
|
|
289
|
+
message: `${label}'s conditional.hide is "${hide}", which is not an expression.`,
|
|
290
|
+
fix: `Prefix it with "=" to make it FEEL, e.g. "=${hide.trim()}".`,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function checkValidation(c, label, where, w) {
|
|
295
|
+
if (!isObject(c.validate))
|
|
296
|
+
return;
|
|
297
|
+
const v = c.validate;
|
|
298
|
+
if (typeof v.pattern === "string") {
|
|
299
|
+
try {
|
|
300
|
+
new RegExp(v.pattern);
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
w.findings.push({
|
|
304
|
+
rule: "form/invalid-validation",
|
|
305
|
+
severity: "error",
|
|
306
|
+
...where,
|
|
307
|
+
message: `${label}'s validate.pattern is not a valid regular expression: ${err.message}`,
|
|
308
|
+
fix: "Fix the pattern; backslashes must be doubled in JSON (`\\\\d`).",
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
for (const [lo, hi] of [
|
|
313
|
+
["min", "max"],
|
|
314
|
+
["minLength", "maxLength"],
|
|
315
|
+
]) {
|
|
316
|
+
const a = v[lo];
|
|
317
|
+
const b = v[hi];
|
|
318
|
+
if (typeof a === "number" && typeof b === "number" && a > b) {
|
|
319
|
+
w.findings.push({
|
|
320
|
+
rule: "form/invalid-validation",
|
|
321
|
+
severity: "error",
|
|
322
|
+
...where,
|
|
323
|
+
message: `${label} has validate.${lo} ${a} greater than validate.${hi} ${b}; no value can pass.`,
|
|
324
|
+
fix: `Swap them, or lower ${lo} below ${hi}.`,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** Parses every string property that form-js reads as FEEL (one starting with `=`). */
|
|
330
|
+
function checkFeelProperties(value, prefix, label, where, w) {
|
|
331
|
+
for (const [key, v] of Object.entries(value)) {
|
|
332
|
+
if (prefix === "" && NON_FEEL_KEYS.has(key))
|
|
333
|
+
continue;
|
|
334
|
+
const prop = prefix === "" ? key : `${prefix}.${key}`;
|
|
335
|
+
if (typeof v === "string") {
|
|
336
|
+
const trimmed = v.trim();
|
|
337
|
+
if (!trimmed.startsWith("="))
|
|
338
|
+
continue;
|
|
339
|
+
const { errors } = parseExpression(trimmed.slice(1));
|
|
340
|
+
const first = errors[0];
|
|
341
|
+
if (first === undefined)
|
|
342
|
+
continue;
|
|
343
|
+
w.findings.push({
|
|
344
|
+
rule: "form/feel-syntax",
|
|
345
|
+
severity: "error",
|
|
346
|
+
...where,
|
|
347
|
+
message: `${label}'s ${prop} is not valid FEEL: ${first.message} in \`${trimmed}\`.`,
|
|
348
|
+
fix: "Fix the FEEL after the `=`; strings need double quotes, and `and`/`or` join conditions.",
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
else if (isObject(v)) {
|
|
352
|
+
checkFeelProperties(v, prop, label, where, w);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=lint.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* BPMN 2.0, DMN and Camunda Form SDK. **Agents: read
|
|
4
|
+
* `node_modules/@bpmnkit/core/AGENTS.md`, then the one card for your type
|
|
5
|
+
* (`agent-cards/bpmn.md`, `dmn.md` or `form.md`, ~1k tokens each) instead of the README.**
|
|
6
|
+
*/
|
|
1
7
|
export { BpmnSdkError, ParseError, ValidationError, WriteError, WriteVerificationError, } from "./errors.js";
|
|
2
8
|
export type { ErrorCode } from "./errors.js";
|
|
3
9
|
export { isBpmnActivity, isBpmnAdHocSubProcess, isBpmnBoundaryEvent, isBpmnBusinessRuleTask, isBpmnCallActivity, isBpmnComplexGateway, isBpmnDataObject, isBpmnDataObjectReference, isBpmnDataStoreReference, isBpmnEndEvent, isBpmnEvent, isBpmnEventBasedGateway, isBpmnEventSubProcess, isBpmnExclusiveGateway, isBpmnGateway, isBpmnInclusiveGateway, isBpmnIntermediateCatchEvent, isBpmnIntermediateThrowEvent, isBpmnManualTask, isBpmnParallelGateway, isBpmnReceiveTask, isBpmnScriptTask, isBpmnSendTask, isBpmnServiceTask, isBpmnStartEvent, isBpmnSubProcess, isBpmnTask, isBpmnTransaction, isBpmnUserTask, } from "./bpmn/type-guards.js";
|
|
4
10
|
export { findElement, findElementInProcess, findProcess, findSequenceFlow, getAllElements, getElementType, getZeebeExtensions, } from "./bpmn/utils.js";
|
|
5
11
|
export { Bpmn, SAMPLE_BPMN_XML } from "./bpmn/index.js";
|
|
12
|
+
export type { ExportOptions } from "./bpmn/index.js";
|
|
6
13
|
export { stripCamunda8 } from "./bpmn/strip-camunda8.js";
|
|
7
14
|
export type { DroppedCamunda8Item, StripCamunda8Result } from "./bpmn/strip-camunda8.js";
|
|
8
15
|
export { applyAutoLayout } from "./bpmn/auto-layout.js";
|
|
@@ -37,13 +44,17 @@ export { assertZeebePlacement, bpmnElementName, ensureZeebeExtension, isZeebePla
|
|
|
37
44
|
export { ZEEBE_PLACEMENT } from "./bpmn/zeebe-placement.js";
|
|
38
45
|
export { buildAiAgentSubProcess, AI_AGENT_JOB_WORKER_TASK_TYPE, AI_AGENT_DEFAULT_OUTPUT_ELEMENT, } from "./bpmn/agentic.js";
|
|
39
46
|
export type { AiAgentOptions, AiAgentModelConfig, AiAgentToolSpec, AiAgentToolParam, AiAgentToolParamType, AiAgentBuild, } from "./bpmn/agentic.js";
|
|
40
|
-
export { Dmn, layoutDmn, benchmarkDmnLayout, compactifyDmn, expandDmn } from "./dmn/index.js";
|
|
47
|
+
export { Dmn, drgId, layoutDmn, benchmarkDmnLayout, compactifyDmn, expandDmn } from "./dmn/index.js";
|
|
41
48
|
export type { DmnBenchmarkResult, DmnElementPosition, CompactDmn, CompactDmnDecision, CompactDmnInput, CompactDmnOutput, CompactDmnRule, } from "./dmn/index.js";
|
|
42
49
|
export { Form, compactifyForm, expandForm } from "./form/index.js";
|
|
50
|
+
export { lintForm } from "./form/lint.js";
|
|
51
|
+
export { lintDmn } from "./dmn/lint.js";
|
|
52
|
+
export type { CheckFinding, CheckSeverity } from "./check-finding.js";
|
|
43
53
|
export type { CompactForm, CompactFormField } from "./form/index.js";
|
|
44
54
|
export { FormBuilder, GroupBuilder } from "./form/form-builder.js";
|
|
45
55
|
export type { TextFieldOptions, SelectOptions, RadioOptions, CheckboxOptions, ChecklistOptions, GroupOptions, } from "./form/form-builder.js";
|
|
46
|
-
export type { FormComponent, FormCheckboxComponent, FormChecklistComponent, FormDefinition, FormExporter, FormGroupComponent, FormLayout, FormLayoutInput, FormRadioComponent, FormSelectComponent, FormTextAreaComponent, FormTextComponent, FormTextFieldComponent, FormValidation, FormValueOption, FormNumberComponent, FormDatetimeComponent, FormButtonComponent, FormTaglistComponent, FormTableComponent, FormImageComponent, FormDynamicListComponent, FormIframeComponent, FormSeparatorComponent, FormSpacerComponent, FormDocumentPreviewComponent, FormHtmlComponent, FormExpressionComponent, FormFilepickerComponent, FormUnknownComponent, } from "./form/form-model.js";
|
|
56
|
+
export type { FormComponent, FormCheckboxComponent, FormChecklistComponent, FormDefinition, FormExporter, FormGroupComponent, FormConditional, FormLayout, FormLayoutInput, FormRadioComponent, FormSelectComponent, FormTextAreaComponent, FormTextComponent, FormTextFieldComponent, FormValidation, FormValueOption, FormNumberComponent, FormDatetimeComponent, FormButtonComponent, FormTaglistComponent, FormTableComponent, FormImageComponent, FormDynamicListComponent, FormIframeComponent, FormSeparatorComponent, FormSpacerComponent, FormDocumentPreviewComponent, FormHtmlComponent, FormExpressionComponent, FormFilepickerComponent, FormUnknownComponent, } from "./form/form-model.js";
|
|
57
|
+
export type { DecisionHandle, DrdBuilder, DrdDecisionOptions, DrgId, DrgRef, InputDataHandle, } from "./dmn/drd-builder.js";
|
|
47
58
|
export type { DecisionTableBuilder, InputOptions, OutputOptions, RuleOptions, } from "./dmn/dmn-builder.js";
|
|
48
59
|
export type { DmnDefinitions, DmnDecision, DmnDecisionTable, DmnInput, DmnOutput, DmnRule, DmnInputEntry, DmnOutputEntry, DmnDiagram, DmnDiagramShape, DmnDiagramEdge, DmnWaypoint, DmnTypeRef, DmnAggregation, HitPolicy, DmnInformationRequirement, DmnKnowledgeRequirement, DmnAuthorityRequirement, DmnInputData, DmnKnowledgeSource, DmnBusinessKnowledgeModel, DmnTextAnnotation, DmnAssociation, } from "./dmn/dmn-model.js";
|
|
49
60
|
export type { XmlElement } from "./types/xml-element.js";
|
|
@@ -57,7 +68,7 @@ export { readDiColor, writeDiColor, BIOC_NS, COLOR_NS } from "./bpmn/di-color.js
|
|
|
57
68
|
export type { DiColor } from "./bpmn/di-color.js";
|
|
58
69
|
export { collectLabelStyles, labelFontCss, resolveLabelFont } from "./bpmn/label-style.js";
|
|
59
70
|
export type { BpmnLabelFont, LabelFontCss } from "./bpmn/label-style.js";
|
|
60
|
-
export { optimize } from "./bpmn/optimize/index.js";
|
|
71
|
+
export { optimize, USER_TASK_FORM_RULE } from "./bpmn/optimize/index.js";
|
|
61
72
|
export { renderStoryHtml } from "./bpmn/story.js";
|
|
62
73
|
export type { StoryRenderOptions } from "./bpmn/story.js";
|
|
63
74
|
export { analyzeVariableFlow, extractFeelIdentifiers } from "./bpmn/optimize/variable-flow.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* BPMN 2.0, DMN and Camunda Form SDK. **Agents: read
|
|
4
|
+
* `node_modules/@bpmnkit/core/AGENTS.md`, then the one card for your type
|
|
5
|
+
* (`agent-cards/bpmn.md`, `dmn.md` or `form.md`, ~1k tokens each) instead of the README.**
|
|
6
|
+
*/
|
|
1
7
|
export { BpmnSdkError, ParseError, ValidationError, WriteError, WriteVerificationError, } from "./errors.js";
|
|
2
8
|
export { isBpmnActivity, isBpmnAdHocSubProcess, isBpmnBoundaryEvent, isBpmnBusinessRuleTask, isBpmnCallActivity, isBpmnComplexGateway, isBpmnDataObject, isBpmnDataObjectReference, isBpmnDataStoreReference, isBpmnEndEvent, isBpmnEvent, isBpmnEventBasedGateway, isBpmnEventSubProcess, isBpmnExclusiveGateway, isBpmnGateway, isBpmnInclusiveGateway, isBpmnIntermediateCatchEvent, isBpmnIntermediateThrowEvent, isBpmnManualTask, isBpmnParallelGateway, isBpmnReceiveTask, isBpmnScriptTask, isBpmnSendTask, isBpmnServiceTask, isBpmnStartEvent, isBpmnSubProcess, isBpmnTask, isBpmnTransaction, isBpmnUserTask, } from "./bpmn/type-guards.js";
|
|
3
9
|
export { findElement, findElementInProcess, findProcess, findSequenceFlow, getAllElements, getElementType, getZeebeExtensions, } from "./bpmn/utils.js";
|
|
@@ -21,8 +27,10 @@ export { DiagramBuilder, ProcessBuilder } from "./bpmn/bpmn-builder.js";
|
|
|
21
27
|
export { assertZeebePlacement, bpmnElementName, ensureZeebeExtension, isZeebePlacementAllowed, ZeebePlacementError, zeebeExtensionsToXmlElements, } from "./bpmn/zeebe-extensions.js";
|
|
22
28
|
export { ZEEBE_PLACEMENT } from "./bpmn/zeebe-placement.js";
|
|
23
29
|
export { buildAiAgentSubProcess, AI_AGENT_JOB_WORKER_TASK_TYPE, AI_AGENT_DEFAULT_OUTPUT_ELEMENT, } from "./bpmn/agentic.js";
|
|
24
|
-
export { Dmn, layoutDmn, benchmarkDmnLayout, compactifyDmn, expandDmn } from "./dmn/index.js";
|
|
30
|
+
export { Dmn, drgId, layoutDmn, benchmarkDmnLayout, compactifyDmn, expandDmn } from "./dmn/index.js";
|
|
25
31
|
export { Form, compactifyForm, expandForm } from "./form/index.js";
|
|
32
|
+
export { lintForm } from "./form/lint.js";
|
|
33
|
+
export { lintDmn } from "./dmn/lint.js";
|
|
26
34
|
export { FormBuilder, GroupBuilder } from "./form/form-builder.js";
|
|
27
35
|
export { generateId, resetIdCounter } from "./types/id-generator.js";
|
|
28
36
|
export { parseXml, parseXmlSpans, preserveFormatting, preserveFormattingVerified, serializeXml, } from "./xml/index.js";
|
|
@@ -30,7 +38,7 @@ export { parseJsonSpans, preserveJsonFormatting } from "./json/index.js";
|
|
|
30
38
|
export { exportFormPreserving, preserveFormFormatting } from "./form/preserving-writer.js";
|
|
31
39
|
export { readDiColor, writeDiColor, BIOC_NS, COLOR_NS } from "./bpmn/di-color.js";
|
|
32
40
|
export { collectLabelStyles, labelFontCss, resolveLabelFont } from "./bpmn/label-style.js";
|
|
33
|
-
export { optimize } from "./bpmn/optimize/index.js";
|
|
41
|
+
export { optimize, USER_TASK_FORM_RULE } from "./bpmn/optimize/index.js";
|
|
34
42
|
export { renderStoryHtml } from "./bpmn/story.js";
|
|
35
43
|
export { analyzeVariableFlow, extractFeelIdentifiers } from "./bpmn/optimize/variable-flow.js";
|
|
36
44
|
export { layoutProcess, layoutFlowNodes } from "./layout/index.js";
|
|
@@ -4,5 +4,11 @@ import type { LayoutEdge, LayoutNode } from "../types.js";
|
|
|
4
4
|
* For each labeled edge, generates candidate positions on the longest segment
|
|
5
5
|
* and picks the first one that doesn't overlap nodes or already-placed labels.
|
|
6
6
|
*/
|
|
7
|
-
export declare function placeEdgeLabels(edges: LayoutEdge[], nodeMap: Map<string, LayoutNode
|
|
7
|
+
export declare function placeEdgeLabels(edges: LayoutEdge[], nodeMap: Map<string, LayoutNode>,
|
|
8
|
+
/**
|
|
9
|
+
* Edges whose label belongs next to their source — a gateway's branch
|
|
10
|
+
* conditions. These try the first segment, just past the exit, before the
|
|
11
|
+
* usual spots, and only where no other flow runs through the label.
|
|
12
|
+
*/
|
|
13
|
+
nearSource?: ReadonlySet<string>): void;
|
|
8
14
|
//# sourceMappingURL=edge-labels.d.ts.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { LABEL_CHAR_WIDTH, LABEL_HEIGHT, LABEL_MIN_WIDTH, LABEL_VERTICAL_OFFSET } from "../types.js";
|
|
2
2
|
/** Collision tolerance in pixels — small overlap allowed for rounding. */
|
|
3
3
|
const LABEL_COLLISION_TOLERANCE = 2;
|
|
4
|
+
/** Distance between a source's exit and a label placed beside it. */
|
|
5
|
+
const LABEL_SOURCE_GAP = 6;
|
|
4
6
|
/** Number of slide steps along a segment when searching for clear space. */
|
|
5
7
|
const LABEL_SLIDE_STEPS = 10;
|
|
6
8
|
function boundsOverlap(a, b) {
|
|
@@ -14,8 +16,23 @@ function boundsOverlap(a, b) {
|
|
|
14
16
|
* For each labeled edge, generates candidate positions on the longest segment
|
|
15
17
|
* and picks the first one that doesn't overlap nodes or already-placed labels.
|
|
16
18
|
*/
|
|
17
|
-
export function placeEdgeLabels(edges, nodeMap
|
|
19
|
+
export function placeEdgeLabels(edges, nodeMap,
|
|
20
|
+
/**
|
|
21
|
+
* Edges whose label belongs next to their source — a gateway's branch
|
|
22
|
+
* conditions. These try the first segment, just past the exit, before the
|
|
23
|
+
* usual spots, and only where no other flow runs through the label.
|
|
24
|
+
*/
|
|
25
|
+
nearSource = new Set()) {
|
|
18
26
|
const occupied = [];
|
|
27
|
+
const segments = [];
|
|
28
|
+
for (const edge of edges) {
|
|
29
|
+
for (let i = 0; i + 1 < edge.waypoints.length; i++) {
|
|
30
|
+
const a = edge.waypoints[i];
|
|
31
|
+
const b = edge.waypoints[i + 1];
|
|
32
|
+
if (a && b)
|
|
33
|
+
segments.push({ edge, a, b });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
19
36
|
// Collect all node bounds as obstacles
|
|
20
37
|
for (const node of nodeMap.values()) {
|
|
21
38
|
occupied.push(node.bounds);
|
|
@@ -27,6 +44,15 @@ export function placeEdgeLabels(edges, nodeMap) {
|
|
|
27
44
|
continue;
|
|
28
45
|
const labelWidth = Math.max(edge.label.length * LABEL_CHAR_WIDTH, LABEL_MIN_WIDTH);
|
|
29
46
|
const labelHeight = LABEL_HEIGHT;
|
|
47
|
+
if (nearSource.has(edge.id)) {
|
|
48
|
+
const spot = sourceCandidates(edge.waypoints, labelWidth, labelHeight).find((c) => !occupied.some((ob) => boundsOverlap(c, ob)) &&
|
|
49
|
+
!segments.some((s) => s.edge !== edge && segmentThrough(s.a, s.b, c)));
|
|
50
|
+
if (spot) {
|
|
51
|
+
edge.labelBounds = spot;
|
|
52
|
+
occupied.push(spot);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
30
56
|
// Find the longest segment
|
|
31
57
|
const { segStart, segEnd } = findLongestSegment(edge.waypoints);
|
|
32
58
|
// Generate candidate positions along the segment
|
|
@@ -52,6 +78,41 @@ export function placeEdgeLabels(edges, nodeMap) {
|
|
|
52
78
|
}
|
|
53
79
|
}
|
|
54
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Spots on an edge's first segment, just past where it leaves its source:
|
|
83
|
+
* above a horizontal exit, beside a vertical one (right first, then left).
|
|
84
|
+
* The first segment has to be long enough to hold the label.
|
|
85
|
+
*/
|
|
86
|
+
function sourceCandidates(waypoints, width, height) {
|
|
87
|
+
const a = waypoints[0];
|
|
88
|
+
const b = waypoints[1];
|
|
89
|
+
if (!a || !b)
|
|
90
|
+
return [];
|
|
91
|
+
const gap = LABEL_SOURCE_GAP;
|
|
92
|
+
if (Math.abs(a.y - b.y) < 1) {
|
|
93
|
+
if (Math.abs(b.x - a.x) < width + 2 * gap)
|
|
94
|
+
return [];
|
|
95
|
+
const x = b.x > a.x ? a.x + gap : a.x - gap - width;
|
|
96
|
+
return [
|
|
97
|
+
{ x, y: a.y - LABEL_SOURCE_GAP / 2 - height, width, height },
|
|
98
|
+
{ x, y: a.y + LABEL_SOURCE_GAP / 2, width, height },
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
if (Math.abs(b.y - a.y) < height + 2 * gap)
|
|
102
|
+
return [];
|
|
103
|
+
const y = b.y > a.y ? a.y + gap : a.y - gap - height;
|
|
104
|
+
return [
|
|
105
|
+
{ x: a.x + gap, y, width, height },
|
|
106
|
+
{ x: a.x - gap - width, y, width, height },
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
/** True when the axis-parallel segment a→b passes through the box. */
|
|
110
|
+
function segmentThrough(a, b, box) {
|
|
111
|
+
return (Math.max(a.x, b.x) > box.x &&
|
|
112
|
+
Math.min(a.x, b.x) < box.x + box.width &&
|
|
113
|
+
Math.max(a.y, b.y) > box.y &&
|
|
114
|
+
Math.min(a.y, b.y) < box.y + box.height);
|
|
115
|
+
}
|
|
55
116
|
function findLongestSegment(waypoints) {
|
|
56
117
|
let bestLen = 0;
|
|
57
118
|
let bestStart = waypoints[0] ?? { x: 0, y: 0 };
|