@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.
Files changed (78) hide show
  1. package/AGENTS.md +19 -0
  2. package/README.md +2 -0
  3. package/agent-cards/bpmn.md +86 -0
  4. package/agent-cards/dmn.md +105 -0
  5. package/agent-cards/form.md +72 -0
  6. package/builder-reference.md +211 -0
  7. package/dist/bpmn/auto-layout.js +34 -5
  8. package/dist/bpmn/bpmn-builder.d.ts +127 -5
  9. package/dist/bpmn/bpmn-builder.js +270 -40
  10. package/dist/bpmn/bpmn-model.d.ts +2 -0
  11. package/dist/bpmn/bpmn-parser.js +8 -0
  12. package/dist/bpmn/bpmn-serializer.js +1 -1
  13. package/dist/bpmn/builder-coverage.js +4 -12
  14. package/dist/bpmn/camunda7/export.d.ts +25 -0
  15. package/dist/bpmn/camunda7/export.js +218 -0
  16. package/dist/bpmn/camunda7/migrate.d.ts +4 -1
  17. package/dist/bpmn/camunda7/migrate.js +4 -4
  18. package/dist/bpmn/compact.d.ts +21 -0
  19. package/dist/bpmn/compact.js +86 -1
  20. package/dist/bpmn/full-operations.js +338 -3
  21. package/dist/bpmn/index.d.ts +2 -0
  22. package/dist/bpmn/index.js +2 -0
  23. package/dist/bpmn/operations.d.ts +42 -1
  24. package/dist/bpmn/operations.js +12 -2
  25. package/dist/bpmn/optimize/deploy.js +14 -0
  26. package/dist/bpmn/optimize/index.d.ts +2 -0
  27. package/dist/bpmn/optimize/index.js +5 -0
  28. package/dist/bpmn/optimize/types.d.ts +7 -0
  29. package/dist/bpmn/stable-ids.d.ts +15 -0
  30. package/dist/bpmn/stable-ids.js +26 -0
  31. package/dist/bpmn/strip-camunda8.d.ts +22 -0
  32. package/dist/bpmn/strip-camunda8.js +55 -0
  33. package/dist/bpmn/svg.js +5 -6
  34. package/dist/bpmn/utils.js +151 -1
  35. package/dist/bpmn/zeebe-extensions.d.ts +59 -2
  36. package/dist/bpmn/zeebe-extensions.js +89 -1
  37. package/dist/check-finding.d.ts +19 -0
  38. package/dist/check-finding.js +5 -0
  39. package/dist/connectors/apply-element.d.ts +7 -3
  40. package/dist/connectors/apply-element.js +115 -4
  41. package/dist/connectors/apply-many.d.ts +5 -1
  42. package/dist/connectors/apply-many.js +5 -2
  43. package/dist/connectors/apply.d.ts +24 -3
  44. package/dist/connectors/apply.js +103 -3
  45. package/dist/connectors/catalog.js +5 -0
  46. package/dist/connectors/index.d.ts +1 -1
  47. package/dist/connectors/template-types.d.ts +30 -0
  48. package/dist/connectors/validate.js +33 -0
  49. package/dist/dmn/compact.js +14 -5
  50. package/dist/dmn/dmn-builder.js +3 -3
  51. package/dist/dmn/drd-builder.d.ts +53 -0
  52. package/dist/dmn/drd-builder.js +100 -0
  53. package/dist/dmn/index.d.ts +35 -0
  54. package/dist/dmn/index.js +36 -0
  55. package/dist/dmn/lint.d.ts +19 -0
  56. package/dist/dmn/lint.js +414 -0
  57. package/dist/form/form-builder.d.ts +9 -1
  58. package/dist/form/form-builder.js +34 -1
  59. package/dist/form/form-model.d.ts +7 -0
  60. package/dist/form/form-parser.js +22 -0
  61. package/dist/form/form-serializer.js +10 -0
  62. package/dist/form/index.d.ts +11 -2
  63. package/dist/form/index.js +10 -1
  64. package/dist/form/lint.d.ts +19 -0
  65. package/dist/form/lint.js +356 -0
  66. package/dist/index.d.ts +19 -5
  67. package/dist/index.js +12 -2
  68. package/dist/layout/annotations.d.ts +3 -1
  69. package/dist/layout/annotations.js +72 -14
  70. package/dist/layout/grid/edge-labels.d.ts +7 -1
  71. package/dist/layout/grid/edge-labels.js +62 -1
  72. package/dist/layout/semantic/index.js +78 -8
  73. package/dist/layout/semantic/place.d.ts +19 -4
  74. package/dist/layout/semantic/place.js +245 -29
  75. package/dist/layout/semantic/route.js +60 -12
  76. package/dist/layout/types.d.ts +2 -1
  77. package/llms.txt +9 -0
  78. package/package.json +6 -1
@@ -3,10 +3,44 @@ import { generateId } from "../types/id-generator.js";
3
3
  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
- import { assertExplicitFlowIdsUnique, assignStableFlowIds, markExplicitFlowId, rootDefinitionId, setFlowDiscriminatorSource, } from "./stable-ids.js";
7
- import { ensureZeebeExtension, zeebeExtensionsToXmlElements, } from "./zeebe-extensions.js";
6
+ import { assertExplicitFlowIdsUnique, assignEventDefinitionIds, assignStableFlowIds, markExplicitFlowId, rootDefinitionId, setFlowDiscriminatorSource, } from "./stable-ids.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
- return createFlowElement(id, type, options);
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
- inputCollection: options.collection,
203
- };
204
- if (options.elementVariable) {
251
+ const attrs = { inputCollection: options.collection };
252
+ if (options.elementVariable)
205
253
  attrs.inputElement = options.elementVariable;
206
- }
207
- extChildren.push({
208
- name: "zeebe:loopCharacteristics",
209
- attributes: attrs,
210
- children: [],
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 { isSequential: options.isSequential || undefined, extensionElements: extChildren };
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 and user tasks. */
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
- ...(options?.formId ? { formDefinition: { formId: options.formId } } : {}),
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
- const attrs = { processId: options.processId };
484
- if (options.propagateAllChildVariables !== undefined) {
485
- attrs.propagateAllChildVariables = String(options.propagateAllChildVariables);
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
- extensionElements: zeebeExtensionsToXmlElements({
491
- unknownElements: [{ name: "zeebe:calledElement", attributes: attrs, children: [] }],
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);
@@ -560,7 +706,7 @@ function resolveBoundaryEventArgs(id, attachedToOrOptions, maybeOptions) {
560
706
  ? { ...maybeOptions, attachedTo: attachedToOrOptions }
561
707
  : attachedToOrOptions;
562
708
  if (typeof options?.attachedTo !== "string" || options.attachedTo === "") {
563
- throw new ValidationError(`boundaryEvent("${id}") requires the id of the activity it attaches to. Pass it as options.attachedTo, as boundaryEvent("${id}", hostId, options), or use withBoundary() to attach to the preceding activity.`);
709
+ throw new ValidationError(`boundaryEvent("${id}") requires the id of the activity it attaches to. Pass it as options.attachedTo, as boundaryEvent("${id}", hostId, options), or use withBoundary() to attach to the preceding activity. See agent-cards/bpmn.md#traps.`);
564
710
  }
565
711
  return options;
566
712
  }
@@ -686,6 +832,10 @@ function insertJoinGateways(elements, flows) {
686
832
  * final until join inference has run, and its id is not final until this pass.
687
833
  */
688
834
  function finalizeScope(elements, flows) {
835
+ for (const el of elements) {
836
+ if ("eventDefinitions" in el)
837
+ assignEventDefinitionIds(el.id, el.eventDefinitions);
838
+ }
689
839
  insertJoinGateways(elements, flows);
690
840
  assignStableFlowIds(elements, flows);
691
841
  recomputeIncomingOutgoing(elements, flows);
@@ -883,6 +1033,27 @@ export class BranchBuilder {
883
1033
  get _openBranchEnds() {
884
1034
  return this.openBranchEnds;
885
1035
  }
1036
+ // ---- Data elements (beside the chain; no sequence flows) ----
1037
+ /** Declares a data object. Link it to an activity via a `dataObjectReference()`. */
1038
+ dataObject(id, options) {
1039
+ addDataElement(this._elements, this._ids, makeDataElement(id, "dataObject", undefined, options));
1040
+ return this;
1041
+ }
1042
+ /** Draws a reference to the data object `dataObjectRef`. */
1043
+ dataObjectReference(id, dataObjectRef, options) {
1044
+ addDataElement(this._elements, this._ids, makeDataElement(id, "dataObjectReference", dataObjectRef, options));
1045
+ return this;
1046
+ }
1047
+ /** Draws a reference to the data store `dataStoreRef`. */
1048
+ dataStoreReference(id, dataStoreRef, options) {
1049
+ addDataElement(this._elements, this._ids, makeDataElement(id, "dataStoreReference", dataStoreRef, options));
1050
+ return this;
1051
+ }
1052
+ /** Links an activity to a data reference: `input` reads it, `output` writes it. */
1053
+ dataAssociation(activityId, dataRefId, direction) {
1054
+ addDataAssociation(this._elements, activityId, dataRefId, direction);
1055
+ return this;
1056
+ }
886
1057
  // ---- Annotations ----
887
1058
  /** Attach a text annotation to the element at the current cursor position. */
888
1059
  textAnnotation(text) {
@@ -922,7 +1093,7 @@ export class BranchBuilder {
922
1093
  el.isForCompensation = true;
923
1094
  if (options?.messageName)
924
1095
  el.messageRef = resolveMessage(options.messageName, this.rootMessages);
925
- return this.addElement(el);
1096
+ return this.addElement(withMultiInstance(el, options?.multiInstance));
926
1097
  }
927
1098
  receiveTask(id, options) {
928
1099
  const el = makeFlowElement(id, "receiveTask", {
@@ -933,7 +1104,7 @@ export class BranchBuilder {
933
1104
  el.isForCompensation = true;
934
1105
  if (options?.messageName)
935
1106
  el.messageRef = resolveMessage(options.messageName, this.rootMessages);
936
- return this.addElement(el);
1107
+ return this.addElement(withMultiInstance(el, options?.multiInstance));
937
1108
  }
938
1109
  businessRuleTask(id, options) {
939
1110
  return this.addElement(makeBusinessRuleTaskEl(id, options));
@@ -1107,6 +1278,7 @@ export class BranchBuilder {
1107
1278
  const element = makeFlowElement(id, "adHocSubProcess", {
1108
1279
  name: resolved.options?.name,
1109
1280
  documentation: resolved.options?.documentation,
1281
+ executionListeners: resolved.options?.executionListeners,
1110
1282
  extensionElements,
1111
1283
  });
1112
1284
  finalizeAdHocSubProcessEl(element, resolved.options, sub, completionCondition);
@@ -1344,7 +1516,7 @@ export class SubProcessContentBuilder {
1344
1516
  el.isForCompensation = true;
1345
1517
  if (options?.messageName)
1346
1518
  el.messageRef = resolveMessage(options.messageName, this.rootMessages);
1347
- return this.addElement(el);
1519
+ return this.addElement(withMultiInstance(el, options?.multiInstance));
1348
1520
  }
1349
1521
  receiveTask(id, options) {
1350
1522
  const el = makeFlowElement(id, "receiveTask", {
@@ -1355,7 +1527,7 @@ export class SubProcessContentBuilder {
1355
1527
  el.isForCompensation = true;
1356
1528
  if (options?.messageName)
1357
1529
  el.messageRef = resolveMessage(options.messageName, this.rootMessages);
1358
- return this.addElement(el);
1530
+ return this.addElement(withMultiInstance(el, options?.multiInstance));
1359
1531
  }
1360
1532
  /** Add a manual task — work performed outside the engine, with no job worker. */
1361
1533
  manualTask(id, options) {
@@ -1392,6 +1564,27 @@ export class SubProcessContentBuilder {
1392
1564
  this.currentGatewayId = id;
1393
1565
  return this.addElement(makeComplexGatewayEl(id, options));
1394
1566
  }
1567
+ // ---- Data elements (beside the chain; no sequence flows) ----
1568
+ /** Declares a data object. Link it to an activity via a `dataObjectReference()`. */
1569
+ dataObject(id, options) {
1570
+ addDataElement(this._elements, this._ids, makeDataElement(id, "dataObject", undefined, options));
1571
+ return this;
1572
+ }
1573
+ /** Draws a reference to the data object `dataObjectRef`. */
1574
+ dataObjectReference(id, dataObjectRef, options) {
1575
+ addDataElement(this._elements, this._ids, makeDataElement(id, "dataObjectReference", dataObjectRef, options));
1576
+ return this;
1577
+ }
1578
+ /** Draws a reference to the data store `dataStoreRef`. */
1579
+ dataStoreReference(id, dataStoreRef, options) {
1580
+ addDataElement(this._elements, this._ids, makeDataElement(id, "dataStoreReference", dataStoreRef, options));
1581
+ return this;
1582
+ }
1583
+ /** Links an activity to a data reference: `input` reads it, `output` writes it. */
1584
+ dataAssociation(activityId, dataRefId, direction) {
1585
+ addDataAssociation(this._elements, activityId, dataRefId, direction);
1586
+ return this;
1587
+ }
1395
1588
  // ---- Annotations ----
1396
1589
  /** Attach a text annotation to the element at the current cursor position. */
1397
1590
  textAnnotation(text) {
@@ -1578,6 +1771,7 @@ export class SubProcessContentBuilder {
1578
1771
  const element = makeFlowElement(id, "adHocSubProcess", {
1579
1772
  name: resolved.options?.name,
1580
1773
  documentation: resolved.options?.documentation,
1774
+ executionListeners: resolved.options?.executionListeners,
1581
1775
  extensionElements,
1582
1776
  });
1583
1777
  finalizeAdHocSubProcessEl(element, resolved.options, sub, completionCondition);
@@ -1634,7 +1828,7 @@ export class ProcessBuilder {
1634
1828
  currentGatewayId;
1635
1829
  openBranchEnds = [];
1636
1830
  _autoLayout = false;
1637
- _executionPlatformVersion = "8.9.0";
1831
+ _executionPlatformVersion = "8.10.0";
1638
1832
  _serviceTaskDefaults = {};
1639
1833
  _savedMainFlowId = undefined;
1640
1834
  /** Set by {@link ProcessBuilder.from}; makes `build()` update rather than generate. */
@@ -1785,7 +1979,7 @@ export class ProcessBuilder {
1785
1979
  this._autoLayout = true;
1786
1980
  return this;
1787
1981
  }
1788
- /** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.9.0"`. */
1982
+ /** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
1789
1983
  executionPlatformVersion(version) {
1790
1984
  this._executionPlatformVersion = version;
1791
1985
  return this;
@@ -2062,7 +2256,7 @@ export class ProcessBuilder {
2062
2256
  el.isForCompensation = true;
2063
2257
  if (options?.messageName)
2064
2258
  el.messageRef = resolveMessage(options.messageName, this.rootMessages);
2065
- this.addFlowElement(el);
2259
+ this.addFlowElement(withMultiInstance(el, options?.multiInstance));
2066
2260
  return this;
2067
2261
  }
2068
2262
  /** Add a receive task (aspirational). */
@@ -2075,7 +2269,7 @@ export class ProcessBuilder {
2075
2269
  el.isForCompensation = true;
2076
2270
  if (options?.messageName)
2077
2271
  el.messageRef = resolveMessage(options.messageName, this.rootMessages);
2078
- this.addFlowElement(el);
2272
+ this.addFlowElement(withMultiInstance(el, options?.multiInstance));
2079
2273
  return this;
2080
2274
  }
2081
2275
  /** Add a business rule task. */
@@ -2247,6 +2441,7 @@ export class ProcessBuilder {
2247
2441
  const element = makeFlowElement(id, "adHocSubProcess", {
2248
2442
  name: resolved.options?.name,
2249
2443
  documentation: resolved.options?.documentation,
2444
+ executionListeners: resolved.options?.executionListeners,
2250
2445
  extensionElements,
2251
2446
  });
2252
2447
  finalizeAdHocSubProcessEl(element, resolved.options, sub, completionCondition);
@@ -2303,6 +2498,27 @@ export class ProcessBuilder {
2303
2498
  this.elementIds.add(element.id);
2304
2499
  return this;
2305
2500
  }
2501
+ // ---- Data elements (beside the chain; no sequence flows) ----
2502
+ /** Declares a data object. Link it to an activity via a `dataObjectReference()`. */
2503
+ dataObject(id, options) {
2504
+ addDataElement(this.flowElements, this.elementIds, makeDataElement(id, "dataObject", undefined, options));
2505
+ return this;
2506
+ }
2507
+ /** Draws a reference to the data object `dataObjectRef`. */
2508
+ dataObjectReference(id, dataObjectRef, options) {
2509
+ addDataElement(this.flowElements, this.elementIds, makeDataElement(id, "dataObjectReference", dataObjectRef, options));
2510
+ return this;
2511
+ }
2512
+ /** Draws a reference to the data store `dataStoreRef`. */
2513
+ dataStoreReference(id, dataStoreRef, options) {
2514
+ addDataElement(this.flowElements, this.elementIds, makeDataElement(id, "dataStoreReference", dataStoreRef, options));
2515
+ return this;
2516
+ }
2517
+ /** Links an activity to a data reference: `input` reads it, `output` writes it. */
2518
+ dataAssociation(activityId, dataRefId, direction) {
2519
+ addDataAssociation(this.flowElements, activityId, dataRefId, direction);
2520
+ return this;
2521
+ }
2306
2522
  // ---- Annotations ----
2307
2523
  /** Attach a text annotation to the element at the current cursor position. */
2308
2524
  textAnnotation(text) {
@@ -2378,10 +2594,17 @@ export class ProcessBuilder {
2378
2594
  // not renumber the part the caller did not touch.
2379
2595
  assignStableFlowIds(this.flowElements, this.sequenceFlows, this._source === undefined ? undefined : new Set(this._sourceFlowTargets.keys()));
2380
2596
  assertExplicitFlowIdsUnique(this.flowElements, this.sequenceFlows);
2597
+ // A continued document keeps its untouched part byte-for-byte, ids included.
2598
+ if (this._source === undefined) {
2599
+ for (const el of this.flowElements) {
2600
+ if ("eventDefinitions" in el)
2601
+ assignEventDefinitionIds(el.id, el.eventDefinitions);
2602
+ }
2603
+ }
2381
2604
  recomputeIncomingOutgoing(this.flowElements, this.sequenceFlows);
2382
2605
  if (this._source !== undefined)
2383
2606
  return this.buildOntoSource(this._source);
2384
- const extensionElements = [];
2607
+ const extensionElements = embeddedFormElements(this.flowElements);
2385
2608
  if (this._versionTag) {
2386
2609
  extensionElements.push({
2387
2610
  name: "zeebe:versionTag",
@@ -2472,6 +2695,13 @@ export class ProcessBuilder {
2472
2695
  // bag: a real process carries other extensions next to it.
2473
2696
  ensureZeebeExtension({ type: "process", extensionElements: process.extensionElements }, "zeebe:versionTag").attributes.value = this._versionTag;
2474
2697
  }
2698
+ for (const form of embeddedFormElements(this.flowElements)) {
2699
+ const at = process.extensionElements.findIndex((e) => e.name === form.name && e.attributes.id === form.attributes.id);
2700
+ if (at >= 0)
2701
+ process.extensionElements[at] = form;
2702
+ else
2703
+ process.extensionElements.push(form);
2704
+ }
2475
2705
  definitions.errors = this.rootErrors;
2476
2706
  definitions.messages = this.rootMessages;
2477
2707
  definitions.signals = this.rootSignals;
@@ -2612,11 +2842,11 @@ export class DiagramBuilder {
2612
2842
  _participants = [];
2613
2843
  _messageFlows = [];
2614
2844
  _collaborationId = "Collaboration_1";
2615
- _executionPlatformVersion = "8.9.0";
2845
+ _executionPlatformVersion = "8.10.0";
2616
2846
  constructor(id) {
2617
2847
  this._id = id;
2618
2848
  }
2619
- /** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.9.0"`. */
2849
+ /** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
2620
2850
  executionPlatformVersion(version) {
2621
2851
  this._executionPlatformVersion = version;
2622
2852
  return this;
@@ -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
  }
@@ -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: { exempt: NOT_A_CHAIN_PARTICIPANT },
48
- dataObjectReference: { exempt: NOT_A_CHAIN_PARTICIPANT },
49
- dataStoreReference: { exempt: NOT_A_CHAIN_PARTICIPANT },
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