@bpmnkit/core 1.6.1 → 1.7.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/builder-reference.md +211 -0
- package/dist/bpmn/auto-layout.js +32 -4
- package/dist/bpmn/bpmn-builder.d.ts +125 -3
- package/dist/bpmn/bpmn-builder.js +253 -34
- 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 +3 -0
- package/dist/bpmn/camunda7/migrate.js +3 -3
- package/dist/bpmn/compact.d.ts +21 -0
- package/dist/bpmn/compact.js +83 -1
- package/dist/bpmn/full-operations.js +336 -3
- package/dist/bpmn/operations.d.ts +42 -1
- package/dist/bpmn/operations.js +12 -2
- package/dist/bpmn/strip-camunda8.d.ts +22 -0
- package/dist/bpmn/strip-camunda8.js +55 -0
- 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/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/index.d.ts +6 -2
- package/dist/index.js +2 -0
- package/dist/layout/annotations.d.ts +3 -1
- package/dist/layout/annotations.js +72 -14
- package/dist/layout/semantic/place.js +23 -5
- package/dist/layout/semantic/route.js +15 -0
- package/dist/layout/types.d.ts +2 -1
- package/package.json +2 -1
package/dist/bpmn/utils.js
CHANGED
|
@@ -131,6 +131,24 @@ function findChildren(elements, tag) {
|
|
|
131
131
|
function findChild(elements, tag) {
|
|
132
132
|
return elements.find((c) => localName(c.name) === tag);
|
|
133
133
|
}
|
|
134
|
+
function readListeners(container, tag) {
|
|
135
|
+
return findChildren(container.children, tag).map((c) => {
|
|
136
|
+
const listener = {
|
|
137
|
+
eventType: c.attributes.eventType ?? "",
|
|
138
|
+
type: c.attributes.type ?? "",
|
|
139
|
+
};
|
|
140
|
+
if (c.attributes.retries !== undefined)
|
|
141
|
+
listener.retries = c.attributes.retries;
|
|
142
|
+
const headers = findChild(c.children, "taskHeaders");
|
|
143
|
+
if (headers) {
|
|
144
|
+
listener.headers = findChildren(headers.children, "header").map((h) => ({
|
|
145
|
+
key: h.attributes.key ?? "",
|
|
146
|
+
value: h.attributes.value ?? "",
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return listener;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
134
152
|
/**
|
|
135
153
|
* Extracts Zeebe extension data from the raw `extensionElements` array of a
|
|
136
154
|
* flow element. This is the inverse of {@link zeebeExtensionsToXmlElements}.
|
|
@@ -191,13 +209,51 @@ export function getZeebeExtensions(extensionElements) {
|
|
|
191
209
|
}
|
|
192
210
|
const formDefEl = findChild(extensionElements, "formDefinition");
|
|
193
211
|
if (formDefEl) {
|
|
194
|
-
const
|
|
212
|
+
const { formId, formKey, externalReference, bindingType, versionTag } = formDefEl.attributes;
|
|
213
|
+
let formDefinition;
|
|
214
|
+
if (formKey !== undefined && formId === undefined)
|
|
215
|
+
formDefinition = { formKey };
|
|
216
|
+
else if (externalReference !== undefined && formId === undefined) {
|
|
217
|
+
formDefinition = { externalReference };
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
formDefinition = { formId: formId ?? "" };
|
|
221
|
+
if (bindingType === "latest" ||
|
|
222
|
+
bindingType === "deployment" ||
|
|
223
|
+
bindingType === "versionTag") {
|
|
224
|
+
formDefinition.bindingType = bindingType;
|
|
225
|
+
}
|
|
226
|
+
if (versionTag !== undefined)
|
|
227
|
+
formDefinition.versionTag = versionTag;
|
|
228
|
+
}
|
|
195
229
|
ext.formDefinition = formDefinition;
|
|
196
230
|
}
|
|
197
231
|
const agentDefEl = findChild(extensionElements, "agentDefinition");
|
|
198
232
|
if (agentDefEl) {
|
|
199
233
|
ext.agentDefinition = { agentType: agentDefEl.attributes.agentType ?? "" };
|
|
200
234
|
}
|
|
235
|
+
const linkedEl = findChild(extensionElements, "linkedResources");
|
|
236
|
+
if (linkedEl) {
|
|
237
|
+
const linked = linkedEl.children
|
|
238
|
+
.filter((c) => localName(c.name) === "linkedResource")
|
|
239
|
+
.map((c) => {
|
|
240
|
+
const { resourceType, resourceId, linkName, bindingType, versionTag } = c.attributes;
|
|
241
|
+
const r = {
|
|
242
|
+
resourceType: resourceType ?? "",
|
|
243
|
+
resourceId: resourceId ?? "",
|
|
244
|
+
linkName: linkName ?? "",
|
|
245
|
+
};
|
|
246
|
+
if (bindingType === "latest" ||
|
|
247
|
+
bindingType === "deployment" ||
|
|
248
|
+
bindingType === "versionTag")
|
|
249
|
+
r.bindingType = bindingType;
|
|
250
|
+
if (versionTag !== undefined)
|
|
251
|
+
r.versionTag = versionTag;
|
|
252
|
+
return r;
|
|
253
|
+
});
|
|
254
|
+
if (linked.length > 0)
|
|
255
|
+
ext.linkedResources = linked;
|
|
256
|
+
}
|
|
201
257
|
const calledDecEl = findChild(extensionElements, "calledDecision");
|
|
202
258
|
if (calledDecEl) {
|
|
203
259
|
const calledDecision = {
|
|
@@ -206,6 +262,100 @@ export function getZeebeExtensions(extensionElements) {
|
|
|
206
262
|
};
|
|
207
263
|
ext.calledDecision = calledDecision;
|
|
208
264
|
}
|
|
265
|
+
const calledElEl = findChild(extensionElements, "calledElement");
|
|
266
|
+
if (calledElEl) {
|
|
267
|
+
const a = calledElEl.attributes;
|
|
268
|
+
const calledElement = { processId: a.processId ?? "" };
|
|
269
|
+
if (a.propagateAllChildVariables !== undefined) {
|
|
270
|
+
calledElement.propagateAllChildVariables = a.propagateAllChildVariables === "true";
|
|
271
|
+
}
|
|
272
|
+
if (a.propagateAllParentVariables !== undefined) {
|
|
273
|
+
calledElement.propagateAllParentVariables = a.propagateAllParentVariables === "true";
|
|
274
|
+
}
|
|
275
|
+
if (a.bindingType === "latest" ||
|
|
276
|
+
a.bindingType === "deployment" ||
|
|
277
|
+
a.bindingType === "versionTag") {
|
|
278
|
+
calledElement.bindingType = a.bindingType;
|
|
279
|
+
}
|
|
280
|
+
if (a.versionTag !== undefined)
|
|
281
|
+
calledElement.versionTag = a.versionTag;
|
|
282
|
+
ext.calledElement = calledElement;
|
|
283
|
+
}
|
|
284
|
+
const adHocEl = findChild(extensionElements, "adHoc");
|
|
285
|
+
if (adHocEl) {
|
|
286
|
+
const { outputCollection, outputElement, activeElementsCollection } = adHocEl.attributes;
|
|
287
|
+
const adHoc = {};
|
|
288
|
+
if (outputCollection !== undefined)
|
|
289
|
+
adHoc.outputCollection = outputCollection;
|
|
290
|
+
if (outputElement !== undefined)
|
|
291
|
+
adHoc.outputElement = outputElement;
|
|
292
|
+
if (activeElementsCollection !== undefined) {
|
|
293
|
+
adHoc.activeElementsCollection = activeElementsCollection;
|
|
294
|
+
}
|
|
295
|
+
ext.adHoc = adHoc;
|
|
296
|
+
}
|
|
297
|
+
if (findChild(extensionElements, "userTask"))
|
|
298
|
+
ext.userTask = true;
|
|
299
|
+
const assignEl = findChild(extensionElements, "assignmentDefinition");
|
|
300
|
+
if (assignEl) {
|
|
301
|
+
const { assignee, candidateGroups, candidateUsers } = assignEl.attributes;
|
|
302
|
+
const assignmentDefinition = {};
|
|
303
|
+
if (assignee !== undefined)
|
|
304
|
+
assignmentDefinition.assignee = assignee;
|
|
305
|
+
if (candidateGroups !== undefined)
|
|
306
|
+
assignmentDefinition.candidateGroups = candidateGroups;
|
|
307
|
+
if (candidateUsers !== undefined)
|
|
308
|
+
assignmentDefinition.candidateUsers = candidateUsers;
|
|
309
|
+
ext.assignmentDefinition = assignmentDefinition;
|
|
310
|
+
}
|
|
311
|
+
const scheduleEl = findChild(extensionElements, "taskSchedule");
|
|
312
|
+
if (scheduleEl) {
|
|
313
|
+
const { dueDate, followUpDate } = scheduleEl.attributes;
|
|
314
|
+
const taskSchedule = {};
|
|
315
|
+
if (dueDate !== undefined)
|
|
316
|
+
taskSchedule.dueDate = dueDate;
|
|
317
|
+
if (followUpDate !== undefined)
|
|
318
|
+
taskSchedule.followUpDate = followUpDate;
|
|
319
|
+
ext.taskSchedule = taskSchedule;
|
|
320
|
+
}
|
|
321
|
+
const priorityEl = findChild(extensionElements, "priorityDefinition");
|
|
322
|
+
if (priorityEl) {
|
|
323
|
+
ext.priorityDefinition = { priority: priorityEl.attributes.priority ?? "" };
|
|
324
|
+
}
|
|
325
|
+
const subscriptionEl = findChild(extensionElements, "subscription");
|
|
326
|
+
if (subscriptionEl) {
|
|
327
|
+
ext.subscription = { correlationKey: subscriptionEl.attributes.correlationKey ?? "" };
|
|
328
|
+
}
|
|
329
|
+
const execListenersEl = findChild(extensionElements, "executionListeners");
|
|
330
|
+
if (execListenersEl) {
|
|
331
|
+
ext.executionListeners = readListeners(execListenersEl, "executionListener");
|
|
332
|
+
}
|
|
333
|
+
const taskListenersEl = findChild(extensionElements, "taskListeners");
|
|
334
|
+
if (taskListenersEl)
|
|
335
|
+
ext.taskListeners = readListeners(taskListenersEl, "taskListener");
|
|
336
|
+
// Anything we have no typed field for must survive a read-modify-write.
|
|
337
|
+
const unknownElements = extensionElements.filter((c) => !KNOWN_ZEEBE_ELEMENTS.has(localName(c.name)));
|
|
338
|
+
if (unknownElements.length > 0)
|
|
339
|
+
ext.unknownElements = unknownElements;
|
|
209
340
|
return ext;
|
|
210
341
|
}
|
|
342
|
+
const KNOWN_ZEEBE_ELEMENTS = new Set([
|
|
343
|
+
"taskDefinition",
|
|
344
|
+
"ioMapping",
|
|
345
|
+
"taskHeaders",
|
|
346
|
+
"properties",
|
|
347
|
+
"adHoc",
|
|
348
|
+
"agentDefinition",
|
|
349
|
+
"linkedResources",
|
|
350
|
+
"formDefinition",
|
|
351
|
+
"calledDecision",
|
|
352
|
+
"calledElement",
|
|
353
|
+
"userTask",
|
|
354
|
+
"assignmentDefinition",
|
|
355
|
+
"taskSchedule",
|
|
356
|
+
"priorityDefinition",
|
|
357
|
+
"subscription",
|
|
358
|
+
"executionListeners",
|
|
359
|
+
"taskListeners",
|
|
360
|
+
]);
|
|
211
361
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { XmlElement } from "../types/xml-element.js";
|
|
2
|
+
import type { BpmnConditionalEventDefinition } from "./bpmn-model.js";
|
|
2
3
|
/** Zeebe task definition extension. */
|
|
3
4
|
export interface ZeebeTaskDefinition {
|
|
4
5
|
type: string;
|
|
@@ -49,11 +50,29 @@ export interface ZeebeAdHoc {
|
|
|
49
50
|
export interface ZeebeAgentDefinition {
|
|
50
51
|
agentType: string;
|
|
51
52
|
}
|
|
53
|
+
/** One `zeebe:linkedResource` (e.g. the RPA script a service task runs). */
|
|
54
|
+
export interface ZeebeLinkedResource {
|
|
55
|
+
resourceType: string;
|
|
56
|
+
resourceId: string;
|
|
57
|
+
linkName: string;
|
|
58
|
+
bindingType?: "latest" | "deployment" | "versionTag";
|
|
59
|
+
versionTag?: string;
|
|
60
|
+
}
|
|
52
61
|
/** Zeebe form definition extension for user tasks. */
|
|
53
|
-
export
|
|
62
|
+
export type ZeebeFormDefinition = {
|
|
54
63
|
/** ID of the Camunda Form linked to this user task. */
|
|
55
64
|
formId: string;
|
|
56
|
-
|
|
65
|
+
/** What `formId` resolves against (`bindingType`, Camunda 8.6+ unless `latest`). */
|
|
66
|
+
bindingType?: "latest" | "deployment" | "versionTag";
|
|
67
|
+
/** Version tag of the form; only meaningful with `bindingType: "versionTag"`. */
|
|
68
|
+
versionTag?: string;
|
|
69
|
+
} | {
|
|
70
|
+
/** Embedded form (`camunda-forms:bpmn:<id>`) or a legacy form key. */
|
|
71
|
+
formKey: string;
|
|
72
|
+
} | {
|
|
73
|
+
/** External form URL, for a Camunda user task (`zeebe:userTask`). */
|
|
74
|
+
externalReference: string;
|
|
75
|
+
};
|
|
57
76
|
/** Zeebe called decision extension for business rule tasks. */
|
|
58
77
|
export interface ZeebeCalledDecision {
|
|
59
78
|
/** ID of the DMN decision to invoke. */
|
|
@@ -80,6 +99,31 @@ export interface ZeebePriorityDefinition {
|
|
|
80
99
|
export interface ZeebeSubscription {
|
|
81
100
|
correlationKey: string;
|
|
82
101
|
}
|
|
102
|
+
/** Zeebe called element extension for call activities (zeebe:calledElement). */
|
|
103
|
+
export interface ZeebeCalledElement {
|
|
104
|
+
/** ID of the process to call. */
|
|
105
|
+
processId: string;
|
|
106
|
+
/** Held as booleans; the XML attributes are the strings "true"/"false". */
|
|
107
|
+
propagateAllChildVariables?: boolean;
|
|
108
|
+
propagateAllParentVariables?: boolean;
|
|
109
|
+
bindingType?: "latest" | "deployment" | "versionTag";
|
|
110
|
+
/** Only meaningful with `bindingType: "versionTag"`. */
|
|
111
|
+
versionTag?: string;
|
|
112
|
+
}
|
|
113
|
+
/** A job-worker listener (`zeebe:executionListener` / `zeebe:taskListener`). */
|
|
114
|
+
export interface ZeebeListener {
|
|
115
|
+
/** Lifecycle event, such as `start`, `end` (execution) or `completing` (task). */
|
|
116
|
+
eventType: string;
|
|
117
|
+
/** Job type the listener's worker subscribes to. */
|
|
118
|
+
type: string;
|
|
119
|
+
retries?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Listener headers (`zeebe:taskHeaders`). Read and written back so a
|
|
122
|
+
* read-modify-write of a diagram that has them does not drop them; the
|
|
123
|
+
* builder does not offer them.
|
|
124
|
+
*/
|
|
125
|
+
headers?: ZeebeTaskHeaderEntry[];
|
|
126
|
+
}
|
|
83
127
|
/** Collected Zeebe extensions on a service task. */
|
|
84
128
|
export interface ZeebeExtensions {
|
|
85
129
|
taskDefinition?: ZeebeTaskDefinition;
|
|
@@ -89,10 +133,14 @@ export interface ZeebeExtensions {
|
|
|
89
133
|
adHoc?: ZeebeAdHoc;
|
|
90
134
|
/** AI agent marker (zeebe:agentDefinition). */
|
|
91
135
|
agentDefinition?: ZeebeAgentDefinition;
|
|
136
|
+
/** Resources linked to a service task (zeebe:linkedResources). */
|
|
137
|
+
linkedResources?: ZeebeLinkedResource[];
|
|
92
138
|
/** Camunda Form linked to a user task (zeebe:formDefinition). */
|
|
93
139
|
formDefinition?: ZeebeFormDefinition;
|
|
94
140
|
/** DMN decision invoked by a business rule task (zeebe:calledDecision). */
|
|
95
141
|
calledDecision?: ZeebeCalledDecision;
|
|
142
|
+
/** Process invoked by a call activity (zeebe:calledElement). */
|
|
143
|
+
calledElement?: ZeebeCalledElement;
|
|
96
144
|
/** Marks this as a Camunda 8 native user task (zeebe:userTask). */
|
|
97
145
|
userTask?: true;
|
|
98
146
|
/** User task assignee/candidates (zeebe:assignmentDefinition). */
|
|
@@ -103,6 +151,10 @@ export interface ZeebeExtensions {
|
|
|
103
151
|
priorityDefinition?: ZeebePriorityDefinition;
|
|
104
152
|
/** Message correlation key for a message catch/boundary/receive element (zeebe:subscription). */
|
|
105
153
|
subscription?: ZeebeSubscription;
|
|
154
|
+
/** Execution listeners (zeebe:executionListeners). */
|
|
155
|
+
executionListeners?: ZeebeListener[];
|
|
156
|
+
/** User task listeners (zeebe:taskListeners). */
|
|
157
|
+
taskListeners?: ZeebeListener[];
|
|
106
158
|
/** Unrecognized extension elements preserved for roundtrip. */
|
|
107
159
|
unknownElements?: XmlElement[];
|
|
108
160
|
}
|
|
@@ -164,4 +216,9 @@ export declare function ensureZeebeExtension(owner: {
|
|
|
164
216
|
type: string;
|
|
165
217
|
extensionElements: XmlElement[];
|
|
166
218
|
}, extension: string): XmlElement;
|
|
219
|
+
/**
|
|
220
|
+
* A conditional event definition with a FEEL `condition` and, when `variableEvents`
|
|
221
|
+
* is given, a `zeebe:conditionalFilter` limiting which variable changes re-evaluate it.
|
|
222
|
+
*/
|
|
223
|
+
export declare function makeConditionalDefinition(condition: string, variableEvents?: readonly ("create" | "update")[]): BpmnConditionalEventDefinition;
|
|
167
224
|
//# sourceMappingURL=zeebe-extensions.d.ts.map
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { ZEEBE_PLACEMENT } from "./zeebe-placement.js";
|
|
2
|
+
function listenersToXml(container, child, listeners) {
|
|
3
|
+
return {
|
|
4
|
+
name: `zeebe:${container}`,
|
|
5
|
+
attributes: {},
|
|
6
|
+
children: listeners.map((l) => ({
|
|
7
|
+
name: `zeebe:${child}`,
|
|
8
|
+
attributes: {
|
|
9
|
+
eventType: l.eventType,
|
|
10
|
+
type: l.type,
|
|
11
|
+
...(l.retries !== undefined ? { retries: l.retries } : {}),
|
|
12
|
+
},
|
|
13
|
+
children: l.headers?.length
|
|
14
|
+
? [
|
|
15
|
+
{
|
|
16
|
+
name: "zeebe:taskHeaders",
|
|
17
|
+
attributes: {},
|
|
18
|
+
children: l.headers.map((h) => ({
|
|
19
|
+
name: "zeebe:header",
|
|
20
|
+
attributes: { key: h.key, value: h.value },
|
|
21
|
+
children: [],
|
|
22
|
+
})),
|
|
23
|
+
},
|
|
24
|
+
]
|
|
25
|
+
: [],
|
|
26
|
+
})),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
2
29
|
/** Convert Zeebe extensions to XmlElement array for the BPMN model. */
|
|
3
30
|
export function zeebeExtensionsToXmlElements(extensions) {
|
|
4
31
|
const elements = [];
|
|
@@ -79,13 +106,30 @@ export function zeebeExtensionsToXmlElements(extensions) {
|
|
|
79
106
|
children: [],
|
|
80
107
|
});
|
|
81
108
|
}
|
|
109
|
+
if (extensions.linkedResources?.length) {
|
|
110
|
+
elements.push({
|
|
111
|
+
name: "zeebe:linkedResources",
|
|
112
|
+
attributes: {},
|
|
113
|
+
children: extensions.linkedResources.map((r) => ({
|
|
114
|
+
name: "zeebe:linkedResource",
|
|
115
|
+
attributes: {
|
|
116
|
+
resourceType: r.resourceType,
|
|
117
|
+
resourceId: r.resourceId,
|
|
118
|
+
linkName: r.linkName,
|
|
119
|
+
...(r.bindingType !== undefined ? { bindingType: r.bindingType } : {}),
|
|
120
|
+
...(r.versionTag !== undefined ? { versionTag: r.versionTag } : {}),
|
|
121
|
+
},
|
|
122
|
+
children: [],
|
|
123
|
+
})),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
82
126
|
if (extensions.userTask) {
|
|
83
127
|
elements.push({ name: "zeebe:userTask", attributes: {}, children: [] });
|
|
84
128
|
}
|
|
85
129
|
if (extensions.formDefinition) {
|
|
86
130
|
elements.push({
|
|
87
131
|
name: "zeebe:formDefinition",
|
|
88
|
-
attributes: {
|
|
132
|
+
attributes: { ...extensions.formDefinition },
|
|
89
133
|
children: [],
|
|
90
134
|
});
|
|
91
135
|
}
|
|
@@ -99,6 +143,22 @@ export function zeebeExtensionsToXmlElements(extensions) {
|
|
|
99
143
|
children: [],
|
|
100
144
|
});
|
|
101
145
|
}
|
|
146
|
+
if (extensions.calledElement) {
|
|
147
|
+
const { processId, propagateAllChildVariables, propagateAllParentVariables } = extensions.calledElement;
|
|
148
|
+
const { bindingType, versionTag } = extensions.calledElement;
|
|
149
|
+
const attrs = { processId };
|
|
150
|
+
if (propagateAllChildVariables !== undefined) {
|
|
151
|
+
attrs.propagateAllChildVariables = String(propagateAllChildVariables);
|
|
152
|
+
}
|
|
153
|
+
if (propagateAllParentVariables !== undefined) {
|
|
154
|
+
attrs.propagateAllParentVariables = String(propagateAllParentVariables);
|
|
155
|
+
}
|
|
156
|
+
if (bindingType !== undefined)
|
|
157
|
+
attrs.bindingType = bindingType;
|
|
158
|
+
if (versionTag !== undefined)
|
|
159
|
+
attrs.versionTag = versionTag;
|
|
160
|
+
elements.push({ name: "zeebe:calledElement", attributes: attrs, children: [] });
|
|
161
|
+
}
|
|
102
162
|
if (extensions.assignmentDefinition) {
|
|
103
163
|
const attrs = {};
|
|
104
164
|
const { assignee, candidateGroups, candidateUsers } = extensions.assignmentDefinition;
|
|
@@ -137,6 +197,12 @@ export function zeebeExtensionsToXmlElements(extensions) {
|
|
|
137
197
|
children: [],
|
|
138
198
|
});
|
|
139
199
|
}
|
|
200
|
+
if (extensions.executionListeners?.length) {
|
|
201
|
+
elements.push(listenersToXml("executionListeners", "executionListener", extensions.executionListeners));
|
|
202
|
+
}
|
|
203
|
+
if (extensions.taskListeners?.length) {
|
|
204
|
+
elements.push(listenersToXml("taskListeners", "taskListener", extensions.taskListeners));
|
|
205
|
+
}
|
|
140
206
|
if (extensions.unknownElements) {
|
|
141
207
|
elements.push(...extensions.unknownElements);
|
|
142
208
|
}
|
|
@@ -220,4 +286,26 @@ export function ensureZeebeExtension(owner, extension) {
|
|
|
220
286
|
owner.extensionElements.push(created);
|
|
221
287
|
return created;
|
|
222
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* A conditional event definition with a FEEL `condition` and, when `variableEvents`
|
|
291
|
+
* is given, a `zeebe:conditionalFilter` limiting which variable changes re-evaluate it.
|
|
292
|
+
*/
|
|
293
|
+
export function makeConditionalDefinition(condition, variableEvents) {
|
|
294
|
+
return {
|
|
295
|
+
type: "conditional",
|
|
296
|
+
condition,
|
|
297
|
+
conditionAttributes: { "xsi:type": "bpmn:tFormalExpression" },
|
|
298
|
+
...(variableEvents && variableEvents.length > 0
|
|
299
|
+
? {
|
|
300
|
+
extensionElements: [
|
|
301
|
+
{
|
|
302
|
+
name: "zeebe:conditionalFilter",
|
|
303
|
+
attributes: { variableEvents: variableEvents.join(",") },
|
|
304
|
+
children: [],
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
}
|
|
308
|
+
: {}),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
223
311
|
//# sourceMappingURL=zeebe-extensions.js.map
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* option reaches. This writes all of it onto an element that already exists.
|
|
9
9
|
*/
|
|
10
10
|
import type { BpmnDefinitions, BpmnFlowElement } from "../index.js";
|
|
11
|
-
import { type ApplyProblem } from "./apply.js";
|
|
11
|
+
import { type ApplyOptions, type ApplyProblem } from "./apply.js";
|
|
12
12
|
import type { ElementTemplate } from "./template-types.js";
|
|
13
13
|
/** The one `elementType.eventDefinition` this toolkit writes. */
|
|
14
14
|
export declare const APPLIED_EVENT_DEFINITION = "bpmn:MessageEventDefinition";
|
|
@@ -43,7 +43,9 @@ export declare function messageRefOf(element: BpmnFlowElement): string | undefin
|
|
|
43
43
|
* references, and is otherwise derived from the template and element ids,
|
|
44
44
|
* never from a clock or random source.
|
|
45
45
|
* - **Extensions.** `zeebe:taskDefinition`, `ioMapping`, `taskHeaders`,
|
|
46
|
-
* `properties`, `adHoc
|
|
46
|
+
* `properties`, `adHoc`, `linkedResources` and the task-level ones (`calledElement`,
|
|
47
|
+
* `calledDecision`, `userTask`, `formDefinition`, `assignmentDefinition`, `taskSchedule`,
|
|
48
|
+
* `priorityDefinition`, `script`) are replaced wholesale when the
|
|
47
49
|
* template declares a binding of that kind, in place, and left alone when it
|
|
48
50
|
* does not. `zeebe:modelerTemplate`, `…Version` and `…Icon` are stamped.
|
|
49
51
|
*
|
|
@@ -54,6 +56,8 @@ export declare function messageRefOf(element: BpmnFlowElement): string | undefin
|
|
|
54
56
|
* @param elementId - A flow element anywhere in its processes, sub-processes included.
|
|
55
57
|
* @param template - Any element template, bundled or a workspace's own.
|
|
56
58
|
* @param values - Keyed as in {@link applyElementTemplate}; `name` sets the element's name.
|
|
59
|
+
* @param options - `omitDefaults` leaves out properties carrying only the template's default;
|
|
60
|
+
* re-applying replaces the extensions wholesale, so an earlier apply's default does not survive.
|
|
57
61
|
*/
|
|
58
|
-
export declare function applyTemplateToElement(definitions: BpmnDefinitions, elementId: string, template: ElementTemplate, values?: Record<string, string
|
|
62
|
+
export declare function applyTemplateToElement(definitions: BpmnDefinitions, elementId: string, template: ElementTemplate, values?: Record<string, string>, options?: ApplyOptions): ApplyToElementResult;
|
|
59
63
|
//# sourceMappingURL=apply-element.d.ts.map
|
|
@@ -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;
|