@bpmnkit/core 1.6.1 → 1.8.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 +86 -0
- package/agent-cards/dmn.md +105 -0
- package/agent-cards/form.md +72 -0
- package/builder-reference.md +211 -0
- package/dist/bpmn/auto-layout.js +34 -5
- package/dist/bpmn/bpmn-builder.d.ts +127 -5
- package/dist/bpmn/bpmn-builder.js +270 -40
- package/dist/bpmn/bpmn-model.d.ts +2 -0
- package/dist/bpmn/bpmn-parser.js +8 -0
- package/dist/bpmn/bpmn-serializer.js +1 -1
- package/dist/bpmn/builder-coverage.js +4 -12
- package/dist/bpmn/camunda7/export.d.ts +25 -0
- package/dist/bpmn/camunda7/export.js +218 -0
- package/dist/bpmn/camunda7/migrate.d.ts +4 -1
- package/dist/bpmn/camunda7/migrate.js +4 -4
- package/dist/bpmn/compact.d.ts +21 -0
- package/dist/bpmn/compact.js +86 -1
- package/dist/bpmn/full-operations.js +338 -3
- package/dist/bpmn/index.d.ts +2 -0
- package/dist/bpmn/index.js +2 -0
- package/dist/bpmn/operations.d.ts +42 -1
- package/dist/bpmn/operations.js +12 -2
- 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/strip-camunda8.d.ts +22 -0
- package/dist/bpmn/strip-camunda8.js +55 -0
- package/dist/bpmn/svg.js +5 -6
- package/dist/bpmn/utils.js +151 -1
- package/dist/bpmn/zeebe-extensions.d.ts +59 -2
- package/dist/bpmn/zeebe-extensions.js +89 -1
- package/dist/check-finding.d.ts +19 -0
- package/dist/check-finding.js +5 -0
- package/dist/connectors/apply-element.d.ts +7 -3
- package/dist/connectors/apply-element.js +115 -4
- package/dist/connectors/apply-many.d.ts +5 -1
- package/dist/connectors/apply-many.js +5 -2
- package/dist/connectors/apply.d.ts +24 -3
- package/dist/connectors/apply.js +103 -3
- package/dist/connectors/catalog.js +5 -0
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/template-types.d.ts +30 -0
- package/dist/connectors/validate.js +33 -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 +19 -5
- package/dist/index.js +12 -2
- package/dist/layout/annotations.d.ts +3 -1
- package/dist/layout/annotations.js +72 -14
- 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 +245 -29
- package/dist/layout/semantic/route.js +60 -12
- package/dist/layout/types.d.ts +2 -1
- package/llms.txt +9 -0
- package/package.json +6 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* option reaches. This writes all of it onto an element that already exists.
|
|
9
9
|
*/
|
|
10
10
|
import { bpmnElementName, isZeebePlacementAllowed, retypeElement, sha256Hex, zeebeExtensionsToXmlElements, } from "../index.js";
|
|
11
|
-
import { resolveBindings } from "./apply.js";
|
|
11
|
+
import { resolveBindings, } from "./apply.js";
|
|
12
12
|
/** The one `elementType.eventDefinition` this toolkit writes. */
|
|
13
13
|
export const APPLIED_EVENT_DEFINITION = "bpmn:MessageEventDefinition";
|
|
14
14
|
/** Every flow element type, so a template's `elementType` is checked rather than cast. */
|
|
@@ -172,6 +172,105 @@ function replaceExtension(extensions, name, replacement) {
|
|
|
172
172
|
function zeebeElement(extensions) {
|
|
173
173
|
return zeebeExtensionsToXmlElements(extensions)[0];
|
|
174
174
|
}
|
|
175
|
+
const TASK_EXTENSION_TYPES = [
|
|
176
|
+
"zeebe:userTask",
|
|
177
|
+
"zeebe:calledElement",
|
|
178
|
+
"zeebe:calledDecision",
|
|
179
|
+
"zeebe:formDefinition",
|
|
180
|
+
"zeebe:assignmentDefinition",
|
|
181
|
+
"zeebe:taskSchedule",
|
|
182
|
+
"zeebe:priorityDefinition",
|
|
183
|
+
"zeebe:script",
|
|
184
|
+
];
|
|
185
|
+
/** The booleans `zeebe:calledElement` holds as booleans and the XML carries as strings. */
|
|
186
|
+
const isTrue = (value) => value === undefined ? undefined : value === "true";
|
|
187
|
+
/**
|
|
188
|
+
* Task-level extensions (`zeebe:calledElement` … `zeebe:script`), via the typed writers in
|
|
189
|
+
* `zeebe-extensions.ts`. `zeebe:script` has no writer there, so it is built by hand.
|
|
190
|
+
*/
|
|
191
|
+
function ownedTaskExtensions(declared, accum) {
|
|
192
|
+
const owned = [];
|
|
193
|
+
const props = (type) => accum.taskExtensions.get(type) ?? {};
|
|
194
|
+
const withAttributes = (element, extra) => element && { ...element, attributes: { ...element.attributes, ...extra } };
|
|
195
|
+
if (declared.has("zeebe:userTask")) {
|
|
196
|
+
owned.push(["zeebe:userTask", accum.userTask ? zeebeElement({ userTask: true }) : undefined]);
|
|
197
|
+
}
|
|
198
|
+
if (declared.has("zeebe:calledElement")) {
|
|
199
|
+
const p = props("zeebe:calledElement");
|
|
200
|
+
owned.push([
|
|
201
|
+
"zeebe:calledElement",
|
|
202
|
+
p.processId === undefined
|
|
203
|
+
? undefined
|
|
204
|
+
: zeebeElement({
|
|
205
|
+
calledElement: {
|
|
206
|
+
processId: p.processId,
|
|
207
|
+
bindingType: p.bindingType,
|
|
208
|
+
versionTag: p.versionTag,
|
|
209
|
+
propagateAllParentVariables: isTrue(p.propagateAllParentVariables),
|
|
210
|
+
propagateAllChildVariables: isTrue(p.propagateAllChildVariables),
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
if (declared.has("zeebe:calledDecision")) {
|
|
216
|
+
const p = props("zeebe:calledDecision");
|
|
217
|
+
const base = p.decisionId === undefined || p.resultVariable === undefined
|
|
218
|
+
? undefined
|
|
219
|
+
: zeebeElement({
|
|
220
|
+
calledDecision: { decisionId: p.decisionId, resultVariable: p.resultVariable },
|
|
221
|
+
});
|
|
222
|
+
// The writer's type has no resource-binding fields; they belong on the same element.
|
|
223
|
+
owned.push([
|
|
224
|
+
"zeebe:calledDecision",
|
|
225
|
+
withAttributes(base, {
|
|
226
|
+
...(p.bindingType === undefined ? {} : { bindingType: p.bindingType }),
|
|
227
|
+
...(p.versionTag === undefined ? {} : { versionTag: p.versionTag }),
|
|
228
|
+
}),
|
|
229
|
+
]);
|
|
230
|
+
}
|
|
231
|
+
if (declared.has("zeebe:formDefinition")) {
|
|
232
|
+
const p = props("zeebe:formDefinition");
|
|
233
|
+
const form = p.externalReference !== undefined
|
|
234
|
+
? { externalReference: p.externalReference }
|
|
235
|
+
: p.formId === undefined
|
|
236
|
+
? undefined
|
|
237
|
+
: {
|
|
238
|
+
formId: p.formId,
|
|
239
|
+
bindingType: p.bindingType,
|
|
240
|
+
versionTag: p.versionTag,
|
|
241
|
+
};
|
|
242
|
+
owned.push([
|
|
243
|
+
"zeebe:formDefinition",
|
|
244
|
+
form === undefined ? undefined : zeebeElement({ formDefinition: form }),
|
|
245
|
+
]);
|
|
246
|
+
}
|
|
247
|
+
if (declared.has("zeebe:assignmentDefinition")) {
|
|
248
|
+
owned.push([
|
|
249
|
+
"zeebe:assignmentDefinition",
|
|
250
|
+
zeebeElement({ assignmentDefinition: props("zeebe:assignmentDefinition") }),
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
if (declared.has("zeebe:taskSchedule")) {
|
|
254
|
+
owned.push(["zeebe:taskSchedule", zeebeElement({ taskSchedule: props("zeebe:taskSchedule") })]);
|
|
255
|
+
}
|
|
256
|
+
if (declared.has("zeebe:priorityDefinition")) {
|
|
257
|
+
const { priority } = props("zeebe:priorityDefinition");
|
|
258
|
+
owned.push([
|
|
259
|
+
"zeebe:priorityDefinition",
|
|
260
|
+
priority === undefined ? undefined : zeebeElement({ priorityDefinition: { priority } }),
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
if (declared.has("zeebe:script")) {
|
|
264
|
+
const p = props("zeebe:script");
|
|
265
|
+
owned.push([
|
|
266
|
+
"zeebe:script",
|
|
267
|
+
p.expression === undefined
|
|
268
|
+
? undefined
|
|
269
|
+
: { name: "zeebe:script", attributes: { ...p }, children: [] },
|
|
270
|
+
]);
|
|
271
|
+
}
|
|
272
|
+
return owned;
|
|
273
|
+
}
|
|
175
274
|
/**
|
|
176
275
|
* The element-level extensions a template owns, each with what it now holds.
|
|
177
276
|
*
|
|
@@ -223,6 +322,7 @@ function ownedExtensions(declared, accum) {
|
|
|
223
322
|
agentType === undefined ? undefined : zeebeElement({ agentDefinition: { agentType } }),
|
|
224
323
|
]);
|
|
225
324
|
}
|
|
325
|
+
owned.push(...ownedTaskExtensions(declared, accum));
|
|
226
326
|
if (declared.has("zeebe:linkedResource")) {
|
|
227
327
|
const children = [...accum.linkedResources].map(([linkName, attributes]) => ({
|
|
228
328
|
name: "zeebe:linkedResource",
|
|
@@ -256,7 +356,9 @@ function ownedExtensions(declared, accum) {
|
|
|
256
356
|
* references, and is otherwise derived from the template and element ids,
|
|
257
357
|
* never from a clock or random source.
|
|
258
358
|
* - **Extensions.** `zeebe:taskDefinition`, `ioMapping`, `taskHeaders`,
|
|
259
|
-
* `properties`, `adHoc
|
|
359
|
+
* `properties`, `adHoc`, `linkedResources` and the task-level ones (`calledElement`,
|
|
360
|
+
* `calledDecision`, `userTask`, `formDefinition`, `assignmentDefinition`, `taskSchedule`,
|
|
361
|
+
* `priorityDefinition`, `script`) are replaced wholesale when the
|
|
260
362
|
* template declares a binding of that kind, in place, and left alone when it
|
|
261
363
|
* does not. `zeebe:modelerTemplate`, `…Version` and `…Icon` are stamped.
|
|
262
364
|
*
|
|
@@ -267,8 +369,10 @@ function ownedExtensions(declared, accum) {
|
|
|
267
369
|
* @param elementId - A flow element anywhere in its processes, sub-processes included.
|
|
268
370
|
* @param template - Any element template, bundled or a workspace's own.
|
|
269
371
|
* @param values - Keyed as in {@link applyElementTemplate}; `name` sets the element's name.
|
|
372
|
+
* @param options - `omitDefaults` leaves out properties carrying only the template's default;
|
|
373
|
+
* re-applying replaces the extensions wholesale, so an earlier apply's default does not survive.
|
|
270
374
|
*/
|
|
271
|
-
export function applyTemplateToElement(definitions, elementId, template, values = {}) {
|
|
375
|
+
export function applyTemplateToElement(definitions, elementId, template, values = {}, options = {}) {
|
|
272
376
|
const refuse = (message) => ({
|
|
273
377
|
definitions,
|
|
274
378
|
problems: [{ message }],
|
|
@@ -292,7 +396,7 @@ export function applyTemplateToElement(definitions, elementId, template, values
|
|
|
292
396
|
prop.binding.name === "name" &&
|
|
293
397
|
currentMessage?.name !== undefined
|
|
294
398
|
? currentMessage.name
|
|
295
|
-
: derivedUuid(`${template.id}\n${elementId}\n${key}`));
|
|
399
|
+
: derivedUuid(`${template.id}\n${elementId}\n${key}`), options);
|
|
296
400
|
let element = location.siblings[location.index];
|
|
297
401
|
if (targetType !== undefined)
|
|
298
402
|
element = retypeElement(element, targetType);
|
|
@@ -310,6 +414,13 @@ export function applyTemplateToElement(definitions, elementId, template, values
|
|
|
310
414
|
...stamps,
|
|
311
415
|
};
|
|
312
416
|
const declared = new Set(template.properties.map((prop) => prop.binding.type));
|
|
417
|
+
// Re-applying the template this element already carries (a new version, say) owns every
|
|
418
|
+
// task-level extension: the old version's bindings are not in hand, and one the new
|
|
419
|
+
// version dropped must not survive.
|
|
420
|
+
if (originalElement.unknownAttributes["zeebe:modelerTemplate"] === template.id) {
|
|
421
|
+
for (const type of TASK_EXTENSION_TYPES)
|
|
422
|
+
declared.add(type);
|
|
423
|
+
}
|
|
313
424
|
const owner = bpmnElementName(element);
|
|
314
425
|
for (const [name, extension] of ownedExtensions(declared, accum)) {
|
|
315
426
|
if (extension && !isZeebePlacementAllowed(owner, name)) {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* misspelt key with the key the template meant.
|
|
8
8
|
*/
|
|
9
9
|
import type { BpmnDefinitions } from "../index.js";
|
|
10
|
+
import { type ApplyOptions } from "./apply.js";
|
|
10
11
|
import type { ElementTemplate } from "./template-types.js";
|
|
11
12
|
export interface TemplateApplication {
|
|
12
13
|
elementId: string;
|
|
@@ -41,8 +42,11 @@ export interface TemplateApplicationProblem {
|
|
|
41
42
|
*
|
|
42
43
|
* @param definitions - The model; not mutated.
|
|
43
44
|
* @param entries - Elements anywhere in the model, nested ones included.
|
|
45
|
+
* @param options - `omitDefaults: true` leaves out properties whose value would only be the
|
|
46
|
+
* template's default (a key the entry does not give, on a property that is neither Hidden nor
|
|
47
|
+
* required), so the element carries what the caller chose. Default `false`.
|
|
44
48
|
*/
|
|
45
|
-
export declare function applyTemplates(definitions: BpmnDefinitions, entries: TemplateApplication[]): {
|
|
49
|
+
export declare function applyTemplates(definitions: BpmnDefinitions, entries: TemplateApplication[], options?: ApplyOptions): {
|
|
46
50
|
definitions: BpmnDefinitions;
|
|
47
51
|
problems: TemplateApplicationProblem[];
|
|
48
52
|
};
|
|
@@ -118,8 +118,11 @@ function unwrittenValues(template, elementId, values) {
|
|
|
118
118
|
*
|
|
119
119
|
* @param definitions - The model; not mutated.
|
|
120
120
|
* @param entries - Elements anywhere in the model, nested ones included.
|
|
121
|
+
* @param options - `omitDefaults: true` leaves out properties whose value would only be the
|
|
122
|
+
* template's default (a key the entry does not give, on a property that is neither Hidden nor
|
|
123
|
+
* required), so the element carries what the caller chose. Default `false`.
|
|
121
124
|
*/
|
|
122
|
-
export function applyTemplates(definitions, entries) {
|
|
125
|
+
export function applyTemplates(definitions, entries, options = {}) {
|
|
123
126
|
const problems = [];
|
|
124
127
|
let current = definitions;
|
|
125
128
|
for (const entry of entries) {
|
|
@@ -137,7 +140,7 @@ export function applyTemplates(definitions, entries) {
|
|
|
137
140
|
template = entry.template;
|
|
138
141
|
}
|
|
139
142
|
const values = Object.fromEntries(Object.entries(entry.values).map(([key, value]) => [key, String(value)]));
|
|
140
|
-
const result = applyTemplateToElement(current, elementId, template, values);
|
|
143
|
+
const result = applyTemplateToElement(current, elementId, template, values, options);
|
|
141
144
|
// A refusal returns the model it was given; its one problem says all there is.
|
|
142
145
|
const refused = result.definitions === current;
|
|
143
146
|
current = result.definitions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AdHocSubProcessOptions, BoundaryEventOptions, IntermediateCatchEventOptions, ServiceTaskOptions, StartEventOptions } from "../index.js";
|
|
2
|
-
import type { ElementTemplate, TemplateCondition, TemplateProperty } from "./template-types.js";
|
|
2
|
+
import type { ElementTemplate, TemplateBinding, TemplateCondition, TemplateProperty } from "./template-types.js";
|
|
3
3
|
export interface ApplyProblem {
|
|
4
4
|
/** The property key this problem is about, if any. */
|
|
5
5
|
key?: string;
|
|
@@ -62,7 +62,16 @@ export interface Accumulator {
|
|
|
62
62
|
subscription: Record<string, string>;
|
|
63
63
|
/** `zeebe:linkedResource` bindings, by `linkName` in template order. */
|
|
64
64
|
linkedResources: Map<string, Record<string, string>>;
|
|
65
|
+
/** `zeebe:userTask` — a flag binding, set by the property being active, not by a value. */
|
|
66
|
+
userTask: boolean;
|
|
67
|
+
/** Task-extension bindings (`zeebe:calledElement` …), attribute name to value, by binding type. */
|
|
68
|
+
taskExtensions: Map<TaskExtensionBinding["type"], Record<string, string>>;
|
|
65
69
|
}
|
|
70
|
+
export type TaskExtensionBinding = Extract<TemplateBinding, {
|
|
71
|
+
type: "zeebe:calledElement" | "zeebe:calledDecision" | "zeebe:formDefinition" | "zeebe:assignmentDefinition" | "zeebe:taskSchedule" | "zeebe:priorityDefinition" | "zeebe:script";
|
|
72
|
+
}>;
|
|
73
|
+
/** `bindingType` values Zeebe accepts on a called element, called decision or form. */
|
|
74
|
+
export declare const RESOURCE_BINDING_TYPES: ReadonlySet<string>;
|
|
66
75
|
export declare function evalCondition(cond: TemplateCondition, values: Record<string, string>): boolean;
|
|
67
76
|
/**
|
|
68
77
|
* The effective value of every active property: user override, else template
|
|
@@ -85,6 +94,14 @@ export declare function resolveValues(template: ElementTemplate, values: Record<
|
|
|
85
94
|
* one would apply silently and do nothing.
|
|
86
95
|
*/
|
|
87
96
|
export declare const APPLIED_BINDING_TYPES: ReadonlySet<string>;
|
|
97
|
+
export interface ApplyOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Leave out properties that would only carry the template's default, so the
|
|
100
|
+
* element holds what the caller chose. Hidden and required properties are
|
|
101
|
+
* always written. Default `false`.
|
|
102
|
+
*/
|
|
103
|
+
omitDefaults?: boolean;
|
|
104
|
+
}
|
|
88
105
|
/**
|
|
89
106
|
* Resolves a template and a set of values into the bindings its active
|
|
90
107
|
* properties write — the half of applying a template that does not depend on
|
|
@@ -94,8 +111,12 @@ export declare const APPLIED_BINDING_TYPES: ReadonlySet<string>;
|
|
|
94
111
|
* @param generate - Supplies a value for an active property that declares a
|
|
95
112
|
* `generatedValue` and was given none. Returning `undefined` leaves the
|
|
96
113
|
* binding unwritten; the callback reports that however suits its caller.
|
|
114
|
+
* @param options.omitDefaults - Skip a property whose value is only the
|
|
115
|
+
* template's default: not in `values`, not Hidden, not `notEmpty`, with no
|
|
116
|
+
* `generatedValue`. The default still counts when other properties'
|
|
117
|
+
* conditions are evaluated, so the template's own gating is unchanged.
|
|
97
118
|
*/
|
|
98
|
-
export declare function resolveBindings(template: ElementTemplate, values: Record<string, string>, generate: (key: string, prop: TemplateProperty) => string | undefined): {
|
|
119
|
+
export declare function resolveBindings(template: ElementTemplate, values: Record<string, string>, generate: (key: string, prop: TemplateProperty) => string | undefined, options?: ApplyOptions): {
|
|
99
120
|
accum: Accumulator;
|
|
100
121
|
problems: ApplyProblem[];
|
|
101
122
|
};
|
|
@@ -125,7 +146,7 @@ export declare function resolveBindings(template: ElementTemplate, values: Recor
|
|
|
125
146
|
* work the same way. Use {@link applyConnectorTemplate} to apply by bundled
|
|
126
147
|
* template id instead.
|
|
127
148
|
*/
|
|
128
|
-
export declare function applyElementTemplate(template: ElementTemplate, values?: Record<string, string
|
|
149
|
+
export declare function applyElementTemplate(template: ElementTemplate, values?: Record<string, string>, options?: ApplyOptions): ApplyResult;
|
|
129
150
|
/**
|
|
130
151
|
* Applies a bundled Camunda 8 out-of-the-box connector element template by
|
|
131
152
|
* id — see {@link applyElementTemplate} for the full binding-resolution
|
package/dist/connectors/apply.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { parseExpression } from "@bpmnkit/feel";
|
|
2
2
|
import { getTemplate, propertyKey } from "./catalog.js";
|
|
3
|
+
/** `bindingType` values Zeebe accepts on a called element, called decision or form. */
|
|
4
|
+
export const RESOURCE_BINDING_TYPES = new Set([
|
|
5
|
+
"latest",
|
|
6
|
+
"deployment",
|
|
7
|
+
"versionTag",
|
|
8
|
+
]);
|
|
3
9
|
export function evalCondition(cond, values) {
|
|
4
10
|
if ("allMatch" in cond) {
|
|
5
11
|
return cond.allMatch.every((c) => evalCondition(c, values));
|
|
@@ -75,6 +81,14 @@ export const APPLIED_BINDING_TYPES = new Set([
|
|
|
75
81
|
"zeebe:property",
|
|
76
82
|
"zeebe:adHoc",
|
|
77
83
|
"zeebe:agentDefinition",
|
|
84
|
+
"zeebe:userTask",
|
|
85
|
+
"zeebe:calledElement",
|
|
86
|
+
"zeebe:calledDecision",
|
|
87
|
+
"zeebe:formDefinition",
|
|
88
|
+
"zeebe:assignmentDefinition",
|
|
89
|
+
"zeebe:taskSchedule",
|
|
90
|
+
"zeebe:priorityDefinition",
|
|
91
|
+
"zeebe:script",
|
|
78
92
|
"property",
|
|
79
93
|
"bpmn:Message#property",
|
|
80
94
|
"bpmn:Message#zeebe:subscription#property",
|
|
@@ -111,6 +125,18 @@ function applyBinding(binding, value, accum) {
|
|
|
111
125
|
case "zeebe:agentDefinition":
|
|
112
126
|
accum.agentDefinition[binding.property] = value;
|
|
113
127
|
return;
|
|
128
|
+
case "zeebe:calledElement":
|
|
129
|
+
case "zeebe:calledDecision":
|
|
130
|
+
case "zeebe:formDefinition":
|
|
131
|
+
case "zeebe:assignmentDefinition":
|
|
132
|
+
case "zeebe:taskSchedule":
|
|
133
|
+
case "zeebe:priorityDefinition":
|
|
134
|
+
case "zeebe:script": {
|
|
135
|
+
const attributes = accum.taskExtensions.get(binding.type) ?? {};
|
|
136
|
+
attributes[binding.property] = value;
|
|
137
|
+
accum.taskExtensions.set(binding.type, attributes);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
114
140
|
case "property":
|
|
115
141
|
// "name" binds to the element's display name — handled by the caller, not here.
|
|
116
142
|
return;
|
|
@@ -130,6 +156,35 @@ function applyBinding(binding, value, accum) {
|
|
|
130
156
|
return;
|
|
131
157
|
}
|
|
132
158
|
}
|
|
159
|
+
/** An extension whose required attribute resolved to nothing is not written; say so. */
|
|
160
|
+
function incompleteTaskExtensions(accum) {
|
|
161
|
+
const required = [
|
|
162
|
+
["zeebe:calledElement", ["processId"]],
|
|
163
|
+
["zeebe:calledDecision", ["decisionId", "resultVariable"]],
|
|
164
|
+
["zeebe:script", ["expression"]],
|
|
165
|
+
["zeebe:priorityDefinition", ["priority"]],
|
|
166
|
+
];
|
|
167
|
+
const problems = [];
|
|
168
|
+
for (const [type, names] of required) {
|
|
169
|
+
const written = accum.taskExtensions.get(type);
|
|
170
|
+
const missing = written === undefined ? [] : names.filter((name) => written[name] === undefined);
|
|
171
|
+
if (missing.length > 0) {
|
|
172
|
+
problems.push({ message: `<${type}> needs ${missing.join(", ")}; it was not written` });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const form = accum.taskExtensions.get("zeebe:formDefinition");
|
|
176
|
+
if (form?.externalReference !== undefined && form.formId !== undefined) {
|
|
177
|
+
problems.push({
|
|
178
|
+
message: "<zeebe:formDefinition> has both formId and externalReference; only externalReference was written",
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (form && form.formId === undefined && form.externalReference === undefined) {
|
|
182
|
+
problems.push({
|
|
183
|
+
message: "<zeebe:formDefinition> needs formId or externalReference; it was not written",
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return problems;
|
|
187
|
+
}
|
|
133
188
|
/** A binding the template resolved but the builder options have no field for. */
|
|
134
189
|
function notExpressible(what) {
|
|
135
190
|
return {
|
|
@@ -148,8 +203,12 @@ function directionOf(template) {
|
|
|
148
203
|
* @param generate - Supplies a value for an active property that declares a
|
|
149
204
|
* `generatedValue` and was given none. Returning `undefined` leaves the
|
|
150
205
|
* binding unwritten; the callback reports that however suits its caller.
|
|
206
|
+
* @param options.omitDefaults - Skip a property whose value is only the
|
|
207
|
+
* template's default: not in `values`, not Hidden, not `notEmpty`, with no
|
|
208
|
+
* `generatedValue`. The default still counts when other properties'
|
|
209
|
+
* conditions are evaluated, so the template's own gating is unchanged.
|
|
151
210
|
*/
|
|
152
|
-
export function resolveBindings(template, values, generate) {
|
|
211
|
+
export function resolveBindings(template, values, generate, options = {}) {
|
|
153
212
|
const resolved = resolveValues(template, values);
|
|
154
213
|
const problems = [];
|
|
155
214
|
const knownKeys = new Set(template.properties.map(propertyKey).filter(Boolean));
|
|
@@ -172,11 +231,26 @@ export function resolveBindings(template, values, generate) {
|
|
|
172
231
|
message: {},
|
|
173
232
|
subscription: {},
|
|
174
233
|
linkedResources: new Map(),
|
|
234
|
+
userTask: false,
|
|
235
|
+
taskExtensions: new Map(),
|
|
175
236
|
};
|
|
176
237
|
for (const prop of template.properties) {
|
|
177
238
|
const key = propertyKey(prop);
|
|
178
239
|
if (prop.condition && !evalCondition(prop.condition, resolved))
|
|
179
240
|
continue;
|
|
241
|
+
if (options.omitDefaults &&
|
|
242
|
+
!(key in values) &&
|
|
243
|
+
prop.type !== "Hidden" &&
|
|
244
|
+
!prop.constraints?.notEmpty &&
|
|
245
|
+
!prop.generatedValue) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
// A flag binding has no value of its own: the property being active is the signal.
|
|
249
|
+
if (prop.binding.type === "zeebe:userTask") {
|
|
250
|
+
if (resolved[key] !== "false")
|
|
251
|
+
accum.userTask = true;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
180
254
|
let value = resolved[key];
|
|
181
255
|
if ((value === undefined || value === "") && prop.generatedValue) {
|
|
182
256
|
value = generate(key, prop);
|
|
@@ -201,8 +275,28 @@ export function resolveBindings(template, values, generate) {
|
|
|
201
275
|
});
|
|
202
276
|
}
|
|
203
277
|
}
|
|
278
|
+
if ("property" in prop.binding &&
|
|
279
|
+
prop.binding.property === "bindingType" &&
|
|
280
|
+
!RESOURCE_BINDING_TYPES.has(value)) {
|
|
281
|
+
problems.push({
|
|
282
|
+
key,
|
|
283
|
+
message: `Invalid bindingType "${value}" for "${key}": expected one of ${[...RESOURCE_BINDING_TYPES].join(", ")}; it was not written`,
|
|
284
|
+
});
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if ("property" in prop.binding &&
|
|
288
|
+
/^propagateAll(Parent|Child)Variables$/.test(prop.binding.property) &&
|
|
289
|
+
value !== "true" &&
|
|
290
|
+
value !== "false") {
|
|
291
|
+
problems.push({
|
|
292
|
+
key,
|
|
293
|
+
message: `Invalid value "${value}" for "${key}": expected true or false; it was not written`,
|
|
294
|
+
});
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
204
297
|
applyBinding(prop.binding, value, accum);
|
|
205
298
|
}
|
|
299
|
+
problems.push(...incompleteTaskExtensions(accum));
|
|
206
300
|
return { accum, problems };
|
|
207
301
|
}
|
|
208
302
|
/**
|
|
@@ -231,12 +325,12 @@ export function resolveBindings(template, values, generate) {
|
|
|
231
325
|
* work the same way. Use {@link applyConnectorTemplate} to apply by bundled
|
|
232
326
|
* template id instead.
|
|
233
327
|
*/
|
|
234
|
-
export function applyElementTemplate(template, values = {}) {
|
|
328
|
+
export function applyElementTemplate(template, values = {}, options = {}) {
|
|
235
329
|
const ungenerated = [];
|
|
236
330
|
const { accum, problems } = resolveBindings(template, values, (key) => {
|
|
237
331
|
ungenerated.push(key);
|
|
238
332
|
return undefined;
|
|
239
|
-
});
|
|
333
|
+
}, options);
|
|
240
334
|
// Builder options name no element, so there is nothing to derive a per-element value from.
|
|
241
335
|
for (const key of ungenerated) {
|
|
242
336
|
problems.push({
|
|
@@ -248,6 +342,12 @@ export function applyElementTemplate(template, values = {}) {
|
|
|
248
342
|
if (accum.linkedResources.size > 0) {
|
|
249
343
|
problems.push(notExpressible("zeebe:linkedResource bindings"));
|
|
250
344
|
}
|
|
345
|
+
for (const type of [
|
|
346
|
+
...(accum.userTask ? ["zeebe:userTask"] : []),
|
|
347
|
+
...accum.taskExtensions.keys(),
|
|
348
|
+
]) {
|
|
349
|
+
problems.push(notExpressible(`${type} bindings`));
|
|
350
|
+
}
|
|
251
351
|
const modelerTemplate = template.id;
|
|
252
352
|
const modelerTemplateVersion = template.version !== undefined ? String(template.version) : undefined;
|
|
253
353
|
const modelerTemplateIcon = template.icon?.contents;
|
|
@@ -27,6 +27,11 @@ export function propertyKey(prop) {
|
|
|
27
27
|
return `adHoc.${b.property}`;
|
|
28
28
|
if (b.type === "zeebe:agentDefinition")
|
|
29
29
|
return `agentDefinition.${b.property}`;
|
|
30
|
+
if (b.type === "zeebe:userTask")
|
|
31
|
+
return "userTask";
|
|
32
|
+
if ("property" in b && b.type.startsWith("zeebe:") && b.type !== "zeebe:linkedResource") {
|
|
33
|
+
return `${b.type.slice("zeebe:".length)}.${b.property}`;
|
|
34
|
+
}
|
|
30
35
|
if (b.type === "bpmn:Message#property")
|
|
31
36
|
return `message.${b.name}`;
|
|
32
37
|
if (b.type === "bpmn:Message#zeebe:subscription#property")
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export { listConnectors, searchConnectors, getTemplate, propertyKey, registerElementTemplates, clearRegisteredTemplates, summarizeTemplate, } from "./catalog.js";
|
|
14
14
|
export type { ConnectorSummary, ConnectorInputSpec, ConnectorDirection } from "./catalog.js";
|
|
15
15
|
export { applyConnectorTemplate, applyElementTemplate } from "./apply.js";
|
|
16
|
-
export type { ApplyResult, ApplyProblem } from "./apply.js";
|
|
16
|
+
export type { ApplyOptions, ApplyResult, ApplyProblem } from "./apply.js";
|
|
17
17
|
export { applyTemplateToElement } from "./apply-element.js";
|
|
18
18
|
export type { ApplyToElementResult } from "./apply-element.js";
|
|
19
19
|
export { applyTemplates } from "./apply-many.js";
|
|
@@ -136,6 +136,36 @@ export type TemplateBinding = {
|
|
|
136
136
|
type: "zeebe:adHoc";
|
|
137
137
|
property: "outputCollection" | "outputElement" | "activeElementsCollection";
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Task-level Zeebe extensions. `zeebe:userTask` is a flag (a Hidden property whose
|
|
141
|
+
* mere presence marks a Camunda user task); the rest name one attribute each.
|
|
142
|
+
* Camunda requires `zeebe:userTask` beside the user-task-only ones
|
|
143
|
+
* (`assignmentDefinition`, `taskSchedule`, `priorityDefinition`).
|
|
144
|
+
*/
|
|
145
|
+
| {
|
|
146
|
+
type: "zeebe:userTask";
|
|
147
|
+
} | {
|
|
148
|
+
type: "zeebe:calledElement";
|
|
149
|
+
property: "processId" | "bindingType" | "versionTag" | "propagateAllParentVariables" | "propagateAllChildVariables";
|
|
150
|
+
} | {
|
|
151
|
+
type: "zeebe:calledDecision";
|
|
152
|
+
property: "decisionId" | "resultVariable" | "bindingType" | "versionTag";
|
|
153
|
+
} | {
|
|
154
|
+
type: "zeebe:formDefinition";
|
|
155
|
+
property: "formId" | "externalReference" | "bindingType" | "versionTag";
|
|
156
|
+
} | {
|
|
157
|
+
type: "zeebe:assignmentDefinition";
|
|
158
|
+
property: "assignee" | "candidateGroups" | "candidateUsers";
|
|
159
|
+
} | {
|
|
160
|
+
type: "zeebe:taskSchedule";
|
|
161
|
+
property: "dueDate" | "followUpDate";
|
|
162
|
+
} | {
|
|
163
|
+
type: "zeebe:priorityDefinition";
|
|
164
|
+
property: "priority";
|
|
165
|
+
} | {
|
|
166
|
+
type: "zeebe:script";
|
|
167
|
+
property: "expression" | "resultVariable";
|
|
168
|
+
}
|
|
139
169
|
/** `zeebe:agentDefinition` (Camunda 8.10+), used by the AI Agent v2 templates. */
|
|
140
170
|
| {
|
|
141
171
|
type: "zeebe:agentDefinition";
|
|
@@ -39,6 +39,14 @@ const BINDING_FIELDS = {
|
|
|
39
39
|
"zeebe:property": ["name"],
|
|
40
40
|
"zeebe:adHoc": ["property"],
|
|
41
41
|
"zeebe:agentDefinition": ["property"],
|
|
42
|
+
"zeebe:userTask": [],
|
|
43
|
+
"zeebe:calledElement": ["property"],
|
|
44
|
+
"zeebe:calledDecision": ["property"],
|
|
45
|
+
"zeebe:formDefinition": ["property"],
|
|
46
|
+
"zeebe:assignmentDefinition": ["property"],
|
|
47
|
+
"zeebe:taskSchedule": ["property"],
|
|
48
|
+
"zeebe:priorityDefinition": ["property"],
|
|
49
|
+
"zeebe:script": ["property"],
|
|
42
50
|
"bpmn:Message#property": ["name"],
|
|
43
51
|
"bpmn:Message#zeebe:subscription#property": ["name"],
|
|
44
52
|
"zeebe:linkedResource": ["property", "linkName"],
|
|
@@ -46,6 +54,22 @@ const BINDING_FIELDS = {
|
|
|
46
54
|
const TASK_DEFINITION_PROPERTIES = new Set(["type", "retries"]);
|
|
47
55
|
const AD_HOC_PROPERTIES = new Set(["outputCollection", "outputElement", "activeElementsCollection"]);
|
|
48
56
|
const AGENT_DEFINITION_PROPERTIES = new Set(["agentType"]);
|
|
57
|
+
/** The `property` values the schema allows per task-extension binding. */
|
|
58
|
+
const TASK_EXTENSION_PROPERTIES = {
|
|
59
|
+
"zeebe:calledElement": new Set([
|
|
60
|
+
"processId",
|
|
61
|
+
"bindingType",
|
|
62
|
+
"versionTag",
|
|
63
|
+
"propagateAllParentVariables",
|
|
64
|
+
"propagateAllChildVariables",
|
|
65
|
+
]),
|
|
66
|
+
"zeebe:calledDecision": new Set(["decisionId", "resultVariable", "bindingType", "versionTag"]),
|
|
67
|
+
"zeebe:formDefinition": new Set(["formId", "externalReference", "bindingType", "versionTag"]),
|
|
68
|
+
"zeebe:assignmentDefinition": new Set(["assignee", "candidateGroups", "candidateUsers"]),
|
|
69
|
+
"zeebe:taskSchedule": new Set(["dueDate", "followUpDate"]),
|
|
70
|
+
"zeebe:priorityDefinition": new Set(["priority"]),
|
|
71
|
+
"zeebe:script": new Set(["expression", "resultVariable"]),
|
|
72
|
+
};
|
|
49
73
|
function isRecord(value) {
|
|
50
74
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
51
75
|
}
|
|
@@ -100,6 +124,15 @@ function checkBinding(binding, path, problems, warnings) {
|
|
|
100
124
|
});
|
|
101
125
|
}
|
|
102
126
|
}
|
|
127
|
+
const taskProperties = TASK_EXTENSION_PROPERTIES[type];
|
|
128
|
+
if (taskProperties !== undefined && isNonEmptyString(binding.property)) {
|
|
129
|
+
if (!taskProperties.has(binding.property)) {
|
|
130
|
+
problems.push({
|
|
131
|
+
path: `${path}.property`,
|
|
132
|
+
message: `expected one of ${[...taskProperties].join(", ")}`,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
103
136
|
if (type === "zeebe:agentDefinition" && isNonEmptyString(binding.property)) {
|
|
104
137
|
if (!AGENT_DEFINITION_PROPERTIES.has(binding.property)) {
|
|
105
138
|
problems.push({
|
package/dist/dmn/compact.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidationError } from "../errors.js";
|
|
1
2
|
import { generateId } from "../types/id-generator.js";
|
|
2
3
|
import { layoutDmn } from "./dmn-layout.js";
|
|
3
4
|
// ── Compactify ────────────────────────────────────────────────────────────────
|
|
@@ -50,11 +51,19 @@ export function expandDmn(compact) {
|
|
|
50
51
|
const inputData = compact.inputData.map((d) => ({ id: d.id, name: d.name }));
|
|
51
52
|
const decisions = compact.decisions.map((cd) => {
|
|
52
53
|
// Build requirement links
|
|
53
|
-
const informationRequirements = (cd.requires ?? []).map((srcId) =>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const informationRequirements = (cd.requires ?? []).map((srcId) => {
|
|
55
|
+
const isDecision = compact.decisions.some((d) => d.id === srcId);
|
|
56
|
+
const isInput = compact.inputData.some((d) => d.id === srcId);
|
|
57
|
+
if (!isDecision && !isInput) {
|
|
58
|
+
const valid = [...compact.decisions, ...compact.inputData].map((d) => d.id).join(", ");
|
|
59
|
+
throw new ValidationError(`Decision "${cd.id}" requires unknown id "${srcId}". Valid ids: ${valid || "(none)"}. Use ids, not names. See agent-cards/dmn.md#traps.`);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
id: generateId("InformationRequirement"),
|
|
63
|
+
requiredDecision: isDecision ? srcId : undefined,
|
|
64
|
+
requiredInput: isInput ? srcId : undefined,
|
|
65
|
+
};
|
|
66
|
+
});
|
|
58
67
|
// Build decision table
|
|
59
68
|
let decisionTable;
|
|
60
69
|
if (cd.inputs.length > 0 || cd.outputs.length > 0 || cd.rules.length > 0) {
|
package/dist/dmn/dmn-builder.js
CHANGED
|
@@ -64,10 +64,10 @@ export class DecisionTableBuilder {
|
|
|
64
64
|
*/
|
|
65
65
|
rule(options) {
|
|
66
66
|
if (options.inputs.length !== this.inputColumns.length) {
|
|
67
|
-
throw new ValidationError(`Rule has ${options.inputs.length} inputs but table has ${this.inputColumns.length} input columns
|
|
67
|
+
throw new ValidationError(`Rule has ${options.inputs.length} inputs but table has ${this.inputColumns.length} input columns. See agent-cards/dmn.md#traps.`);
|
|
68
68
|
}
|
|
69
69
|
if (options.outputs.length !== this.outputColumns.length) {
|
|
70
|
-
throw new ValidationError(`Rule has ${options.outputs.length} outputs but table has ${this.outputColumns.length} output columns
|
|
70
|
+
throw new ValidationError(`Rule has ${options.outputs.length} outputs but table has ${this.outputColumns.length} output columns. See agent-cards/dmn.md#traps.`);
|
|
71
71
|
}
|
|
72
72
|
const inputEntries = options.inputs.map((text) => ({
|
|
73
73
|
id: generateId("UnaryTests"),
|
|
@@ -125,7 +125,7 @@ export class DecisionTableBuilder {
|
|
|
125
125
|
},
|
|
126
126
|
modelerAttributes: {
|
|
127
127
|
executionPlatform: "Camunda Cloud",
|
|
128
|
-
executionPlatformVersion: "8.
|
|
128
|
+
executionPlatformVersion: "8.10.0",
|
|
129
129
|
},
|
|
130
130
|
decisions: [decision],
|
|
131
131
|
inputData: [],
|