@bpmnkit/core 1.6.0 → 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 +86 -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/optimize/flow.js +2 -0
- 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
|
@@ -4,9 +4,43 @@ import { applyAutoLayout } from "./auto-layout.js";
|
|
|
4
4
|
import { createFlowElement } from "./element-shape.js";
|
|
5
5
|
import { REST_CONNECTOR_TEMPLATE_VERSION, restConnectorRetries, restConnectorTaskType, restConnectorToIoMappingInputs, restConnectorToTaskHeaders, } from "./rest-connector.js";
|
|
6
6
|
import { assertExplicitFlowIdsUnique, assignStableFlowIds, markExplicitFlowId, rootDefinitionId, setFlowDiscriminatorSource, } from "./stable-ids.js";
|
|
7
|
-
import { ensureZeebeExtension, zeebeExtensionsToXmlElements, } from "./zeebe-extensions.js";
|
|
7
|
+
import { assertZeebePlacement, bpmnElementName, ensureZeebeExtension, makeConditionalDefinition, zeebeExtensionsToXmlElements, } from "./zeebe-extensions.js";
|
|
8
8
|
// Keep in sync with packages/core/package.json version
|
|
9
9
|
const EXPORTER_VERSION = "0.0.23";
|
|
10
|
+
/**
|
|
11
|
+
* Data elements sit beside the chain: no sequence flow in or out, and the flow
|
|
12
|
+
* cursor does not move. They are linked to activities by data associations.
|
|
13
|
+
*/
|
|
14
|
+
function addDataElement(elements, ids, element) {
|
|
15
|
+
if (ids.has(element.id))
|
|
16
|
+
throw new Error(`Duplicate element ID "${element.id}"`);
|
|
17
|
+
elements.push(element);
|
|
18
|
+
ids.add(element.id);
|
|
19
|
+
}
|
|
20
|
+
function makeDataElement(id, type, ref, options) {
|
|
21
|
+
const el = createFlowElement(id, type, { name: options?.name });
|
|
22
|
+
if (el.type === "dataObjectReference")
|
|
23
|
+
el.dataObjectRef = ref;
|
|
24
|
+
if (el.type === "dataStoreReference")
|
|
25
|
+
el.dataStoreRef = ref;
|
|
26
|
+
if (options?.isCollection && (el.type === "dataObject" || el.type === "dataObjectReference"))
|
|
27
|
+
el.isCollection = true;
|
|
28
|
+
return el;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Input: the data reference is the association's source. Output: it is the
|
|
32
|
+
* target. Either way the activity owns the association element.
|
|
33
|
+
*/
|
|
34
|
+
function addDataAssociation(elements, activityId, dataRefId, direction) {
|
|
35
|
+
const activity = elements.find((e) => e.id === activityId);
|
|
36
|
+
if (!activity)
|
|
37
|
+
throw new Error(`dataAssociation(): no element "${activityId}" in this scope`);
|
|
38
|
+
const association = direction === "input"
|
|
39
|
+
? { sourceRefs: [dataRefId], unknownAttributes: {} }
|
|
40
|
+
: { sourceRefs: [], targetRef: dataRefId, unknownAttributes: {} };
|
|
41
|
+
const key = direction === "input" ? "dataInputAssociations" : "dataOutputAssociations";
|
|
42
|
+
activity[key] = [...(activity[key] ?? []), association];
|
|
43
|
+
}
|
|
10
44
|
// ---------------------------------------------------------------------------
|
|
11
45
|
// Internal helpers
|
|
12
46
|
// ---------------------------------------------------------------------------
|
|
@@ -174,6 +208,9 @@ function buildEventDefinitions(opts, rootErrors, rootMessages, rootSignals, root
|
|
|
174
208
|
if (opts.linkName !== undefined) {
|
|
175
209
|
defs.push({ type: "link", name: opts.linkName });
|
|
176
210
|
}
|
|
211
|
+
if (opts.condition !== undefined) {
|
|
212
|
+
defs.push(makeConditionalDefinition(opts.condition, opts.conditionVariableEvents));
|
|
213
|
+
}
|
|
177
214
|
return defs;
|
|
178
215
|
}
|
|
179
216
|
/**
|
|
@@ -193,24 +230,59 @@ function isLinkEvent(element, type) {
|
|
|
193
230
|
* shorter local name.
|
|
194
231
|
*/
|
|
195
232
|
function makeFlowElement(id, type, options) {
|
|
196
|
-
|
|
233
|
+
const el = createFlowElement(id, type, options);
|
|
234
|
+
el.extensionElements = [...el.extensionElements];
|
|
235
|
+
// Placement is checked here, so a listener on an element the schema forbids it on
|
|
236
|
+
// fails at build time, not at deploy time.
|
|
237
|
+
const listeners = zeebeExtensionsToXmlElements({
|
|
238
|
+
...(options?.executionListeners ? { executionListeners: options.executionListeners } : {}),
|
|
239
|
+
...(options?.taskListeners ? { taskListeners: options.taskListeners } : {}),
|
|
240
|
+
});
|
|
241
|
+
for (const listener of listeners) {
|
|
242
|
+
assertZeebePlacement(bpmnElementName(el), listener.name);
|
|
243
|
+
el.extensionElements.push(listener);
|
|
244
|
+
}
|
|
245
|
+
return el;
|
|
197
246
|
}
|
|
198
247
|
function buildMultiInstance(options) {
|
|
199
248
|
const extChildren = [];
|
|
249
|
+
// Zeebe needs inputCollection, so output-only options emit nothing (as before).
|
|
200
250
|
if (options.collection) {
|
|
201
|
-
const attrs = {
|
|
202
|
-
|
|
203
|
-
};
|
|
204
|
-
if (options.elementVariable) {
|
|
251
|
+
const attrs = { inputCollection: options.collection };
|
|
252
|
+
if (options.elementVariable)
|
|
205
253
|
attrs.inputElement = options.elementVariable;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
});
|
|
254
|
+
if (options.outputCollection)
|
|
255
|
+
attrs.outputCollection = options.outputCollection;
|
|
256
|
+
if (options.outputElement)
|
|
257
|
+
attrs.outputElement = options.outputElement;
|
|
258
|
+
extChildren.push({ name: "zeebe:loopCharacteristics", attributes: attrs, children: [] });
|
|
212
259
|
}
|
|
213
|
-
return {
|
|
260
|
+
return {
|
|
261
|
+
isSequential: options.isSequential || undefined,
|
|
262
|
+
completionCondition: options.completionCondition
|
|
263
|
+
? {
|
|
264
|
+
text: options.completionCondition,
|
|
265
|
+
attributes: { "xsi:type": "bpmn:tFormalExpression" },
|
|
266
|
+
}
|
|
267
|
+
: undefined,
|
|
268
|
+
extensionElements: extChildren,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/** Sets `multiInstance` on an activity; the one place every task type shares. */
|
|
272
|
+
function withMultiInstance(el, mi) {
|
|
273
|
+
if (!mi)
|
|
274
|
+
return el;
|
|
275
|
+
switch (el.type) {
|
|
276
|
+
case "serviceTask":
|
|
277
|
+
case "userTask":
|
|
278
|
+
case "scriptTask":
|
|
279
|
+
case "sendTask":
|
|
280
|
+
case "receiveTask":
|
|
281
|
+
case "businessRuleTask":
|
|
282
|
+
case "callActivity":
|
|
283
|
+
el.loopCharacteristics = buildMultiInstance(mi);
|
|
284
|
+
}
|
|
285
|
+
return el;
|
|
214
286
|
}
|
|
215
287
|
function buildAdHocLoopCharacteristics(lc) {
|
|
216
288
|
const attrs = {
|
|
@@ -254,7 +326,7 @@ function recomputeIncomingOutgoing(elements, flows) {
|
|
|
254
326
|
elementMap.get(flow.targetRef)?.incoming.push(flow.id);
|
|
255
327
|
}
|
|
256
328
|
}
|
|
257
|
-
/** The ioMapping / taskHeaders / properties extensions shared by service
|
|
329
|
+
/** The ioMapping / taskHeaders / properties extensions shared by service tasks, user tasks and call activities. */
|
|
258
330
|
function buildMappingExtensions(options) {
|
|
259
331
|
const extensions = {};
|
|
260
332
|
if (options.ioMapping) {
|
|
@@ -286,6 +358,8 @@ function buildServiceTaskExtensions(options) {
|
|
|
286
358
|
};
|
|
287
359
|
if (options.agentDefinition)
|
|
288
360
|
extensions.agentDefinition = options.agentDefinition;
|
|
361
|
+
if (options.linkedResources)
|
|
362
|
+
extensions.linkedResources = options.linkedResources;
|
|
289
363
|
return zeebeExtensionsToXmlElements(extensions);
|
|
290
364
|
}
|
|
291
365
|
function makeConditionExpression(expression) {
|
|
@@ -377,16 +451,20 @@ function makeServiceTaskEl(id, options) {
|
|
|
377
451
|
name: options.name,
|
|
378
452
|
documentation: options.documentation,
|
|
379
453
|
extensionElements: buildServiceTaskExtensions(options),
|
|
454
|
+
executionListeners: options.executionListeners,
|
|
455
|
+
// Not in ServiceTaskOptions; forwarded so an untyped caller gets the placement error, not a silent drop.
|
|
456
|
+
taskListeners: options.taskListeners,
|
|
380
457
|
});
|
|
381
458
|
el.unknownAttributes = unknownAttributes;
|
|
382
459
|
if (options.isForCompensation)
|
|
383
460
|
el.isForCompensation = true;
|
|
384
|
-
return el;
|
|
461
|
+
return withMultiInstance(el, options.multiInstance);
|
|
385
462
|
}
|
|
386
463
|
function makeScriptTaskEl(id, options) {
|
|
387
464
|
const el = makeFlowElement(id, "scriptTask", {
|
|
388
465
|
name: options.name,
|
|
389
466
|
documentation: options.documentation,
|
|
467
|
+
executionListeners: options.executionListeners,
|
|
390
468
|
extensionElements: zeebeExtensionsToXmlElements({
|
|
391
469
|
unknownElements: [
|
|
392
470
|
{
|
|
@@ -399,7 +477,7 @@ function makeScriptTaskEl(id, options) {
|
|
|
399
477
|
});
|
|
400
478
|
if (options.isForCompensation)
|
|
401
479
|
el.isForCompensation = true;
|
|
402
|
-
return el;
|
|
480
|
+
return withMultiInstance(el, options.multiInstance);
|
|
403
481
|
}
|
|
404
482
|
function applyModelerTemplate(el, options) {
|
|
405
483
|
if (options.modelerTemplate)
|
|
@@ -416,6 +494,7 @@ function makeStartEventEl(id, options) {
|
|
|
416
494
|
const el = makeFlowElement(id, "startEvent", {
|
|
417
495
|
name: options?.name,
|
|
418
496
|
documentation: options?.documentation,
|
|
497
|
+
executionListeners: options?.executionListeners,
|
|
419
498
|
extensionElements: zeebeExtensionsToXmlElements({
|
|
420
499
|
...(options?.formId ? { formDefinition: { formId: options.formId } } : {}),
|
|
421
500
|
...(options?.zeebeProperties ? { properties: { properties: options.zeebeProperties } } : {}),
|
|
@@ -425,10 +504,35 @@ function makeStartEventEl(id, options) {
|
|
|
425
504
|
applyModelerTemplate(el, options);
|
|
426
505
|
return el;
|
|
427
506
|
}
|
|
507
|
+
/** Embedded forms by the user task that declared them; `build()` hoists them to the process. */
|
|
508
|
+
const embeddedForms = new WeakMap();
|
|
509
|
+
function userTaskFormDefinition(options) {
|
|
510
|
+
if (!options)
|
|
511
|
+
return undefined;
|
|
512
|
+
const { formId, formKey, externalReference, embeddedForm } = options;
|
|
513
|
+
const set = [formId, formKey, externalReference, embeddedForm].filter((v) => v !== undefined);
|
|
514
|
+
if (set.length > 1) {
|
|
515
|
+
throw new Error("userTask: set only one of formId, formKey, externalReference or embeddedForm");
|
|
516
|
+
}
|
|
517
|
+
if (embeddedForm)
|
|
518
|
+
return { formKey: `camunda-forms:bpmn:${embeddedForm.id}` };
|
|
519
|
+
if (formKey)
|
|
520
|
+
return { formKey };
|
|
521
|
+
if (externalReference)
|
|
522
|
+
return { externalReference };
|
|
523
|
+
if (!formId)
|
|
524
|
+
return undefined;
|
|
525
|
+
return {
|
|
526
|
+
formId,
|
|
527
|
+
...(options.formBindingType !== undefined && { bindingType: options.formBindingType }),
|
|
528
|
+
...(options.formVersionTag !== undefined && { versionTag: options.formVersionTag }),
|
|
529
|
+
};
|
|
530
|
+
}
|
|
428
531
|
function makeUserTaskEl(id, options) {
|
|
532
|
+
const formDefinition = userTaskFormDefinition(options);
|
|
429
533
|
const ext = zeebeExtensionsToXmlElements({
|
|
430
534
|
...(options?.zeebeUserTask ? { userTask: true } : {}),
|
|
431
|
-
...(
|
|
535
|
+
...(formDefinition ? { formDefinition } : {}),
|
|
432
536
|
...(options?.assignee || options?.candidateGroups || options?.candidateUsers
|
|
433
537
|
? {
|
|
434
538
|
assignmentDefinition: {
|
|
@@ -449,13 +553,43 @@ function makeUserTaskEl(id, options) {
|
|
|
449
553
|
const el = makeFlowElement(id, "userTask", {
|
|
450
554
|
name: options?.name,
|
|
451
555
|
documentation: options?.documentation,
|
|
556
|
+
executionListeners: options?.executionListeners,
|
|
557
|
+
taskListeners: options?.taskListeners,
|
|
452
558
|
extensionElements: ext,
|
|
453
559
|
});
|
|
454
560
|
if (options)
|
|
455
561
|
applyModelerTemplate(el, options);
|
|
562
|
+
if (options?.embeddedForm)
|
|
563
|
+
embeddedForms.set(el, options.embeddedForm);
|
|
456
564
|
if (options?.isForCompensation)
|
|
457
565
|
el.isForCompensation = true;
|
|
458
|
-
return el;
|
|
566
|
+
return withMultiInstance(el, options?.multiInstance);
|
|
567
|
+
}
|
|
568
|
+
/** `zeebe:userTaskForm` elements for every embedded form under `elements`, nested scopes included. */
|
|
569
|
+
function embeddedFormElements(elements) {
|
|
570
|
+
const byId = new Map();
|
|
571
|
+
const visit = (list) => {
|
|
572
|
+
for (const el of list) {
|
|
573
|
+
const form = embeddedForms.get(el);
|
|
574
|
+
if (form) {
|
|
575
|
+
const seen = byId.get(form.id);
|
|
576
|
+
// Two tasks may share a form, but one id can't hold two schemas.
|
|
577
|
+
if (seen !== undefined && seen.text !== form.schema) {
|
|
578
|
+
throw new Error(`embedded form "${form.id}" is declared with two different schemas`);
|
|
579
|
+
}
|
|
580
|
+
byId.set(form.id, {
|
|
581
|
+
name: "zeebe:userTaskForm",
|
|
582
|
+
attributes: { id: form.id },
|
|
583
|
+
children: [],
|
|
584
|
+
text: form.schema,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
if ("flowElements" in el)
|
|
588
|
+
visit(el.flowElements);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
visit(elements);
|
|
592
|
+
return [...byId.values()];
|
|
459
593
|
}
|
|
460
594
|
function makeBusinessRuleTaskEl(id, options) {
|
|
461
595
|
const ext = [];
|
|
@@ -473,27 +607,39 @@ function makeBusinessRuleTaskEl(id, options) {
|
|
|
473
607
|
const el = makeFlowElement(id, "businessRuleTask", {
|
|
474
608
|
name: options?.name,
|
|
475
609
|
documentation: options?.documentation,
|
|
610
|
+
executionListeners: options?.executionListeners,
|
|
476
611
|
extensionElements: ext,
|
|
477
612
|
});
|
|
478
613
|
if (options?.isForCompensation)
|
|
479
614
|
el.isForCompensation = true;
|
|
480
|
-
return el;
|
|
615
|
+
return withMultiInstance(el, options?.multiInstance);
|
|
481
616
|
}
|
|
482
617
|
function makeCallActivityEl(id, options) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
618
|
+
// Pick explicitly so a stray taskHeaders from an untyped caller is dropped, not emitted.
|
|
619
|
+
const extensions = buildMappingExtensions({
|
|
620
|
+
ioMapping: options.ioMapping,
|
|
621
|
+
zeebeProperties: options.zeebeProperties,
|
|
622
|
+
});
|
|
623
|
+
extensions.calledElement = {
|
|
624
|
+
processId: options.processId,
|
|
625
|
+
...(options.propagateAllChildVariables !== undefined && {
|
|
626
|
+
propagateAllChildVariables: options.propagateAllChildVariables,
|
|
627
|
+
}),
|
|
628
|
+
...(options.propagateAllParentVariables !== undefined && {
|
|
629
|
+
propagateAllParentVariables: options.propagateAllParentVariables,
|
|
630
|
+
}),
|
|
631
|
+
...(options.bindingType !== undefined && { bindingType: options.bindingType }),
|
|
632
|
+
...(options.versionTag !== undefined && { versionTag: options.versionTag }),
|
|
633
|
+
};
|
|
487
634
|
const el = makeFlowElement(id, "callActivity", {
|
|
488
635
|
name: options.name,
|
|
489
636
|
documentation: options.documentation,
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}),
|
|
637
|
+
executionListeners: options.executionListeners,
|
|
638
|
+
extensionElements: zeebeExtensionsToXmlElements(extensions),
|
|
493
639
|
});
|
|
494
640
|
if (options.isForCompensation)
|
|
495
641
|
el.isForCompensation = true;
|
|
496
|
-
return el;
|
|
642
|
+
return withMultiInstance(el, options.multiInstance);
|
|
497
643
|
}
|
|
498
644
|
function makeExclusiveGatewayEl(id, options) {
|
|
499
645
|
const el = makeFlowElement(id, "exclusiveGateway", options);
|
|
@@ -883,6 +1029,27 @@ export class BranchBuilder {
|
|
|
883
1029
|
get _openBranchEnds() {
|
|
884
1030
|
return this.openBranchEnds;
|
|
885
1031
|
}
|
|
1032
|
+
// ---- Data elements (beside the chain; no sequence flows) ----
|
|
1033
|
+
/** Declares a data object. Link it to an activity via a `dataObjectReference()`. */
|
|
1034
|
+
dataObject(id, options) {
|
|
1035
|
+
addDataElement(this._elements, this._ids, makeDataElement(id, "dataObject", undefined, options));
|
|
1036
|
+
return this;
|
|
1037
|
+
}
|
|
1038
|
+
/** Draws a reference to the data object `dataObjectRef`. */
|
|
1039
|
+
dataObjectReference(id, dataObjectRef, options) {
|
|
1040
|
+
addDataElement(this._elements, this._ids, makeDataElement(id, "dataObjectReference", dataObjectRef, options));
|
|
1041
|
+
return this;
|
|
1042
|
+
}
|
|
1043
|
+
/** Draws a reference to the data store `dataStoreRef`. */
|
|
1044
|
+
dataStoreReference(id, dataStoreRef, options) {
|
|
1045
|
+
addDataElement(this._elements, this._ids, makeDataElement(id, "dataStoreReference", dataStoreRef, options));
|
|
1046
|
+
return this;
|
|
1047
|
+
}
|
|
1048
|
+
/** Links an activity to a data reference: `input` reads it, `output` writes it. */
|
|
1049
|
+
dataAssociation(activityId, dataRefId, direction) {
|
|
1050
|
+
addDataAssociation(this._elements, activityId, dataRefId, direction);
|
|
1051
|
+
return this;
|
|
1052
|
+
}
|
|
886
1053
|
// ---- Annotations ----
|
|
887
1054
|
/** Attach a text annotation to the element at the current cursor position. */
|
|
888
1055
|
textAnnotation(text) {
|
|
@@ -922,7 +1089,7 @@ export class BranchBuilder {
|
|
|
922
1089
|
el.isForCompensation = true;
|
|
923
1090
|
if (options?.messageName)
|
|
924
1091
|
el.messageRef = resolveMessage(options.messageName, this.rootMessages);
|
|
925
|
-
return this.addElement(el);
|
|
1092
|
+
return this.addElement(withMultiInstance(el, options?.multiInstance));
|
|
926
1093
|
}
|
|
927
1094
|
receiveTask(id, options) {
|
|
928
1095
|
const el = makeFlowElement(id, "receiveTask", {
|
|
@@ -933,7 +1100,7 @@ export class BranchBuilder {
|
|
|
933
1100
|
el.isForCompensation = true;
|
|
934
1101
|
if (options?.messageName)
|
|
935
1102
|
el.messageRef = resolveMessage(options.messageName, this.rootMessages);
|
|
936
|
-
return this.addElement(el);
|
|
1103
|
+
return this.addElement(withMultiInstance(el, options?.multiInstance));
|
|
937
1104
|
}
|
|
938
1105
|
businessRuleTask(id, options) {
|
|
939
1106
|
return this.addElement(makeBusinessRuleTaskEl(id, options));
|
|
@@ -1107,6 +1274,7 @@ export class BranchBuilder {
|
|
|
1107
1274
|
const element = makeFlowElement(id, "adHocSubProcess", {
|
|
1108
1275
|
name: resolved.options?.name,
|
|
1109
1276
|
documentation: resolved.options?.documentation,
|
|
1277
|
+
executionListeners: resolved.options?.executionListeners,
|
|
1110
1278
|
extensionElements,
|
|
1111
1279
|
});
|
|
1112
1280
|
finalizeAdHocSubProcessEl(element, resolved.options, sub, completionCondition);
|
|
@@ -1344,7 +1512,7 @@ export class SubProcessContentBuilder {
|
|
|
1344
1512
|
el.isForCompensation = true;
|
|
1345
1513
|
if (options?.messageName)
|
|
1346
1514
|
el.messageRef = resolveMessage(options.messageName, this.rootMessages);
|
|
1347
|
-
return this.addElement(el);
|
|
1515
|
+
return this.addElement(withMultiInstance(el, options?.multiInstance));
|
|
1348
1516
|
}
|
|
1349
1517
|
receiveTask(id, options) {
|
|
1350
1518
|
const el = makeFlowElement(id, "receiveTask", {
|
|
@@ -1355,7 +1523,7 @@ export class SubProcessContentBuilder {
|
|
|
1355
1523
|
el.isForCompensation = true;
|
|
1356
1524
|
if (options?.messageName)
|
|
1357
1525
|
el.messageRef = resolveMessage(options.messageName, this.rootMessages);
|
|
1358
|
-
return this.addElement(el);
|
|
1526
|
+
return this.addElement(withMultiInstance(el, options?.multiInstance));
|
|
1359
1527
|
}
|
|
1360
1528
|
/** Add a manual task — work performed outside the engine, with no job worker. */
|
|
1361
1529
|
manualTask(id, options) {
|
|
@@ -1392,6 +1560,27 @@ export class SubProcessContentBuilder {
|
|
|
1392
1560
|
this.currentGatewayId = id;
|
|
1393
1561
|
return this.addElement(makeComplexGatewayEl(id, options));
|
|
1394
1562
|
}
|
|
1563
|
+
// ---- Data elements (beside the chain; no sequence flows) ----
|
|
1564
|
+
/** Declares a data object. Link it to an activity via a `dataObjectReference()`. */
|
|
1565
|
+
dataObject(id, options) {
|
|
1566
|
+
addDataElement(this._elements, this._ids, makeDataElement(id, "dataObject", undefined, options));
|
|
1567
|
+
return this;
|
|
1568
|
+
}
|
|
1569
|
+
/** Draws a reference to the data object `dataObjectRef`. */
|
|
1570
|
+
dataObjectReference(id, dataObjectRef, options) {
|
|
1571
|
+
addDataElement(this._elements, this._ids, makeDataElement(id, "dataObjectReference", dataObjectRef, options));
|
|
1572
|
+
return this;
|
|
1573
|
+
}
|
|
1574
|
+
/** Draws a reference to the data store `dataStoreRef`. */
|
|
1575
|
+
dataStoreReference(id, dataStoreRef, options) {
|
|
1576
|
+
addDataElement(this._elements, this._ids, makeDataElement(id, "dataStoreReference", dataStoreRef, options));
|
|
1577
|
+
return this;
|
|
1578
|
+
}
|
|
1579
|
+
/** Links an activity to a data reference: `input` reads it, `output` writes it. */
|
|
1580
|
+
dataAssociation(activityId, dataRefId, direction) {
|
|
1581
|
+
addDataAssociation(this._elements, activityId, dataRefId, direction);
|
|
1582
|
+
return this;
|
|
1583
|
+
}
|
|
1395
1584
|
// ---- Annotations ----
|
|
1396
1585
|
/** Attach a text annotation to the element at the current cursor position. */
|
|
1397
1586
|
textAnnotation(text) {
|
|
@@ -1578,6 +1767,7 @@ export class SubProcessContentBuilder {
|
|
|
1578
1767
|
const element = makeFlowElement(id, "adHocSubProcess", {
|
|
1579
1768
|
name: resolved.options?.name,
|
|
1580
1769
|
documentation: resolved.options?.documentation,
|
|
1770
|
+
executionListeners: resolved.options?.executionListeners,
|
|
1581
1771
|
extensionElements,
|
|
1582
1772
|
});
|
|
1583
1773
|
finalizeAdHocSubProcessEl(element, resolved.options, sub, completionCondition);
|
|
@@ -2062,7 +2252,7 @@ export class ProcessBuilder {
|
|
|
2062
2252
|
el.isForCompensation = true;
|
|
2063
2253
|
if (options?.messageName)
|
|
2064
2254
|
el.messageRef = resolveMessage(options.messageName, this.rootMessages);
|
|
2065
|
-
this.addFlowElement(el);
|
|
2255
|
+
this.addFlowElement(withMultiInstance(el, options?.multiInstance));
|
|
2066
2256
|
return this;
|
|
2067
2257
|
}
|
|
2068
2258
|
/** Add a receive task (aspirational). */
|
|
@@ -2075,7 +2265,7 @@ export class ProcessBuilder {
|
|
|
2075
2265
|
el.isForCompensation = true;
|
|
2076
2266
|
if (options?.messageName)
|
|
2077
2267
|
el.messageRef = resolveMessage(options.messageName, this.rootMessages);
|
|
2078
|
-
this.addFlowElement(el);
|
|
2268
|
+
this.addFlowElement(withMultiInstance(el, options?.multiInstance));
|
|
2079
2269
|
return this;
|
|
2080
2270
|
}
|
|
2081
2271
|
/** Add a business rule task. */
|
|
@@ -2247,6 +2437,7 @@ export class ProcessBuilder {
|
|
|
2247
2437
|
const element = makeFlowElement(id, "adHocSubProcess", {
|
|
2248
2438
|
name: resolved.options?.name,
|
|
2249
2439
|
documentation: resolved.options?.documentation,
|
|
2440
|
+
executionListeners: resolved.options?.executionListeners,
|
|
2250
2441
|
extensionElements,
|
|
2251
2442
|
});
|
|
2252
2443
|
finalizeAdHocSubProcessEl(element, resolved.options, sub, completionCondition);
|
|
@@ -2303,6 +2494,27 @@ export class ProcessBuilder {
|
|
|
2303
2494
|
this.elementIds.add(element.id);
|
|
2304
2495
|
return this;
|
|
2305
2496
|
}
|
|
2497
|
+
// ---- Data elements (beside the chain; no sequence flows) ----
|
|
2498
|
+
/** Declares a data object. Link it to an activity via a `dataObjectReference()`. */
|
|
2499
|
+
dataObject(id, options) {
|
|
2500
|
+
addDataElement(this.flowElements, this.elementIds, makeDataElement(id, "dataObject", undefined, options));
|
|
2501
|
+
return this;
|
|
2502
|
+
}
|
|
2503
|
+
/** Draws a reference to the data object `dataObjectRef`. */
|
|
2504
|
+
dataObjectReference(id, dataObjectRef, options) {
|
|
2505
|
+
addDataElement(this.flowElements, this.elementIds, makeDataElement(id, "dataObjectReference", dataObjectRef, options));
|
|
2506
|
+
return this;
|
|
2507
|
+
}
|
|
2508
|
+
/** Draws a reference to the data store `dataStoreRef`. */
|
|
2509
|
+
dataStoreReference(id, dataStoreRef, options) {
|
|
2510
|
+
addDataElement(this.flowElements, this.elementIds, makeDataElement(id, "dataStoreReference", dataStoreRef, options));
|
|
2511
|
+
return this;
|
|
2512
|
+
}
|
|
2513
|
+
/** Links an activity to a data reference: `input` reads it, `output` writes it. */
|
|
2514
|
+
dataAssociation(activityId, dataRefId, direction) {
|
|
2515
|
+
addDataAssociation(this.flowElements, activityId, dataRefId, direction);
|
|
2516
|
+
return this;
|
|
2517
|
+
}
|
|
2306
2518
|
// ---- Annotations ----
|
|
2307
2519
|
/** Attach a text annotation to the element at the current cursor position. */
|
|
2308
2520
|
textAnnotation(text) {
|
|
@@ -2381,7 +2593,7 @@ export class ProcessBuilder {
|
|
|
2381
2593
|
recomputeIncomingOutgoing(this.flowElements, this.sequenceFlows);
|
|
2382
2594
|
if (this._source !== undefined)
|
|
2383
2595
|
return this.buildOntoSource(this._source);
|
|
2384
|
-
const extensionElements =
|
|
2596
|
+
const extensionElements = embeddedFormElements(this.flowElements);
|
|
2385
2597
|
if (this._versionTag) {
|
|
2386
2598
|
extensionElements.push({
|
|
2387
2599
|
name: "zeebe:versionTag",
|
|
@@ -2472,6 +2684,13 @@ export class ProcessBuilder {
|
|
|
2472
2684
|
// bag: a real process carries other extensions next to it.
|
|
2473
2685
|
ensureZeebeExtension({ type: "process", extensionElements: process.extensionElements }, "zeebe:versionTag").attributes.value = this._versionTag;
|
|
2474
2686
|
}
|
|
2687
|
+
for (const form of embeddedFormElements(this.flowElements)) {
|
|
2688
|
+
const at = process.extensionElements.findIndex((e) => e.name === form.name && e.attributes.id === form.attributes.id);
|
|
2689
|
+
if (at >= 0)
|
|
2690
|
+
process.extensionElements[at] = form;
|
|
2691
|
+
else
|
|
2692
|
+
process.extensionElements.push(form);
|
|
2693
|
+
}
|
|
2475
2694
|
definitions.errors = this.rootErrors;
|
|
2476
2695
|
definitions.messages = this.rootMessages;
|
|
2477
2696
|
definitions.signals = this.rootSignals;
|
|
@@ -72,6 +72,8 @@ export interface BpmnConditionalEventDefinition {
|
|
|
72
72
|
condition?: string;
|
|
73
73
|
/** Attributes of the `<condition>` element, e.g. `xsi:type` and `language`. */
|
|
74
74
|
conditionAttributes?: Record<string, string>;
|
|
75
|
+
/** `<extensionElements>` of the definition, e.g. `zeebe:conditionalFilter`. */
|
|
76
|
+
extensionElements?: XmlElement[];
|
|
75
77
|
/** Attributes the SDK does not model (e.g. `camunda:type`), kept for round-trip. */
|
|
76
78
|
unknownAttributes?: Record<string, string>;
|
|
77
79
|
}
|
package/dist/bpmn/bpmn-parser.js
CHANGED
|
@@ -954,12 +954,19 @@ class ConditionalDefinitionFrame extends Frame {
|
|
|
954
954
|
conditionSeen = false;
|
|
955
955
|
condition;
|
|
956
956
|
conditionAttributes;
|
|
957
|
+
extensionElements = null;
|
|
957
958
|
constructor(attrs, target) {
|
|
958
959
|
super();
|
|
959
960
|
this.attrs = attrs;
|
|
960
961
|
this.target = target;
|
|
961
962
|
}
|
|
962
963
|
child(local, _name, attrs) {
|
|
964
|
+
if (local === "extensionElements") {
|
|
965
|
+
if (this.extensionElements !== null)
|
|
966
|
+
return null;
|
|
967
|
+
this.extensionElements = [];
|
|
968
|
+
return new TreeFrame(this.extensionElements);
|
|
969
|
+
}
|
|
963
970
|
if (local !== "condition" || this.conditionSeen)
|
|
964
971
|
return null;
|
|
965
972
|
this.conditionSeen = true;
|
|
@@ -977,6 +984,7 @@ class ConditionalDefinitionFrame extends Frame {
|
|
|
977
984
|
// Present but empty stays "", like a timer part: the element is still there.
|
|
978
985
|
condition: this.conditionSeen ? (this.condition?.trim() ?? "") : undefined,
|
|
979
986
|
...(this.conditionAttributes ? { conditionAttributes: this.conditionAttributes } : {}),
|
|
987
|
+
...(this.extensionElements ? { extensionElements: this.extensionElements } : {}),
|
|
980
988
|
...definitionExtras(this.attrs, ID_ATTRS),
|
|
981
989
|
});
|
|
982
990
|
}
|
|
@@ -109,7 +109,7 @@ function serializeEventDefinitions(defs, bp) {
|
|
|
109
109
|
const attrs = {};
|
|
110
110
|
if (d.id)
|
|
111
111
|
attrs.id = d.id;
|
|
112
|
-
const condChildren = [];
|
|
112
|
+
const condChildren = serializeExtensionElements(d.extensionElements ?? [], bp);
|
|
113
113
|
if (d.condition !== undefined) {
|
|
114
114
|
condChildren.push(el(`${bp}condition`, d.conditionAttributes ?? {}, [], d.condition));
|
|
115
115
|
}
|
|
@@ -2,14 +2,6 @@
|
|
|
2
2
|
export function hasBuilderMethod(support) {
|
|
3
3
|
return "method" in support;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
6
|
-
* Data elements are not sequence-flow participants, and the fluent builder has
|
|
7
|
-
* no data-association API. Every builder method appends to the chain and wires
|
|
8
|
-
* a sequence flow from the previous node, so a `.dataObject()` would either
|
|
9
|
-
* emit invalid BPMN or leave an orphan shape. Parsing and serialising keep
|
|
10
|
-
* these types; authoring them is a separate API, not a chain method.
|
|
11
|
-
*/
|
|
12
|
-
const NOT_A_CHAIN_PARTICIPANT = "Connected by data associations, not sequence flows; the chain has nowhere to put it";
|
|
13
5
|
/**
|
|
14
6
|
* Every `BpmnElementType`, mapped to the builder method that creates it.
|
|
15
7
|
*
|
|
@@ -43,10 +35,10 @@ export const BUILDER_COVERAGE = {
|
|
|
43
35
|
adHocSubProcess: { method: "adHocSubProcess" },
|
|
44
36
|
eventSubProcess: { method: "eventSubProcess", emits: "subProcess" },
|
|
45
37
|
transaction: { method: "transaction" },
|
|
46
|
-
// ---- Data ----
|
|
47
|
-
dataObject: {
|
|
48
|
-
dataObjectReference: {
|
|
49
|
-
dataStoreReference: {
|
|
38
|
+
// ---- Data: non-chain methods — they add no sequence flow and leave the cursor alone ----
|
|
39
|
+
dataObject: { method: "dataObject" },
|
|
40
|
+
dataObjectReference: { method: "dataObjectReference" },
|
|
41
|
+
dataStoreReference: { method: "dataStoreReference" },
|
|
50
42
|
};
|
|
51
43
|
/**
|
|
52
44
|
* The builders the table applies to — every class that builds a flow chain.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BpmnDefinitions } from "../bpmn-model.js";
|
|
2
|
+
import { type Camunda7Finding } from "./migrate.js";
|
|
3
|
+
/** What {@link convertCamunda8To7} did and could not do, in the forward converter's finding shape. */
|
|
4
|
+
export type Camunda8ExportFinding = Camunda7Finding;
|
|
5
|
+
export interface Camunda8To7Conversion {
|
|
6
|
+
definitions: BpmnDefinitions;
|
|
7
|
+
findings: Camunda8ExportFinding[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Best-effort Camunda 8 → Camunda 7 / Operaton export. The input is not modified.
|
|
11
|
+
*
|
|
12
|
+
* Maps job types, I/O mappings, assignment, form keys, call activities and
|
|
13
|
+
* version tags to `camunda:` equivalents and removes every `zeebe:` and
|
|
14
|
+
* `modeler:` construct and namespace. FEEL is not translated to JUEL: it is
|
|
15
|
+
* kept raw with a `manual` finding. Connectors and Zeebe-only features are
|
|
16
|
+
* dropped with an `unsupported` finding.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { definitions, findings } = convertCamunda8To7(Bpmn.parse(xml))
|
|
21
|
+
* const c7Xml = Bpmn.export(definitions)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function convertCamunda8To7(definitions: BpmnDefinitions): Camunda8To7Conversion;
|
|
25
|
+
//# sourceMappingURL=export.d.ts.map
|