@aranzatech/diagrams-bpmn 0.2.11 → 0.2.12

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.
@@ -1,4 +1,4 @@
1
- import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-BTuiBv7p.js';
1
+ import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-hgmLfRA9.js';
2
2
 
3
3
  declare const BPMN_ELEMENT_CATALOG: Record<BpmnElementType, BpmnElementMeta>;
4
4
  declare function getElementMeta(type: BpmnElementType): BpmnElementMeta;
@@ -1,4 +1,4 @@
1
- import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-BTuiBv7p.cjs';
1
+ import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-hgmLfRA9.cjs';
2
2
 
3
3
  declare const BPMN_ELEMENT_CATALOG: Record<BpmnElementType, BpmnElementMeta>;
4
4
  declare function getElementMeta(type: BpmnElementType): BpmnElementMeta;
@@ -26,7 +26,11 @@ var ARANZA_DESCRIPTOR = {
26
26
  { name: "formKey", isAttr: true, type: "String" },
27
27
  // UserTask: Flowable task assignment — comma-separated ids
28
28
  { name: "candidateUsers", isAttr: true, type: "String" },
29
- { name: "candidateGroups", isAttr: true, type: "String" }
29
+ { name: "candidateGroups", isAttr: true, type: "String" },
30
+ // UserTask: scheduling + skip expression
31
+ { name: "dueDate", isAttr: true, type: "String" },
32
+ { name: "skipExpression", isAttr: true, type: "String" },
33
+ { name: "businessCalendarName", isAttr: true, type: "String" }
30
34
  ]
31
35
  }
32
36
  ],
@@ -343,6 +347,12 @@ function extractAranzaExtensions(el) {
343
347
  if (candidateUsers) result.candidateUsers = candidateUsers;
344
348
  const candidateGroups = asString(taskConfig.candidateGroups);
345
349
  if (candidateGroups) result.candidateGroups = candidateGroups;
350
+ const dueDate = asString(taskConfig.dueDate);
351
+ if (dueDate) result.dueDate = dueDate;
352
+ const skipExpression = asString(taskConfig.skipExpression);
353
+ if (skipExpression) result.skipExpression = skipExpression;
354
+ const businessCalendarName = asString(taskConfig.businessCalendarName);
355
+ if (businessCalendarName) result.businessCalendarName = businessCalendarName;
346
356
  return result;
347
357
  }
348
358
  function extractCompletionCondition(el) {
@@ -351,6 +361,25 @@ function extractCompletionCondition(el) {
351
361
  if (typeof cc === "string") return cc.trim() || void 0;
352
362
  return asString(cc.body);
353
363
  }
364
+ function extractLoopCharacteristics(el) {
365
+ const lc = el.loopCharacteristics;
366
+ if (!lc) return {};
367
+ if (lc.$type === "bpmn:StandardLoopCharacteristics") {
368
+ const loopCondition = asString(lc.loopCondition?.body);
369
+ return { loopType: "loop", ...loopCondition ? { loopCondition } : {} };
370
+ }
371
+ if (lc.$type === "bpmn:MultiInstanceLoopCharacteristics") {
372
+ const loopType = lc.isSequential === true ? "sequentialMultiple" : "parallelMultiple";
373
+ const loopCardinality = asString(lc.loopCardinality?.body);
374
+ const loopCompletionCondition = asString(lc.completionCondition?.body);
375
+ return {
376
+ loopType,
377
+ ...loopCardinality ? { loopCardinality } : {},
378
+ ...loopCompletionCondition ? { loopCompletionCondition } : {}
379
+ };
380
+ }
381
+ return {};
382
+ }
354
383
  function walkFlowElements(elements, parentId, ctx, nodes, edges) {
355
384
  for (const el of elements) {
356
385
  const { $type, id } = el;
@@ -368,7 +397,7 @@ function walkFlowElements(elements, parentId, ctx, nodes, edges) {
368
397
  }
369
398
  buildNode(el, elementType, parentId, ctx, nodes);
370
399
  if ($type === "bpmn:SubProcess" || $type === "bpmn:Transaction" || $type === "bpmn:AdHocSubProcess") {
371
- const children = asElements(el.flowElements);
400
+ const children = [...asElements(el.flowElements), ...asElements(el.artifacts)];
372
401
  const laneMembership = extractLaneMembership(el);
373
402
  walkFlowElements(children, id, { ...ctx, laneMembership }, nodes, edges);
374
403
  }
@@ -381,7 +410,7 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
381
410
  const x = shape?.x ?? ctx.autoX.value;
382
411
  const y = shape?.y ?? 100;
383
412
  if (!shape) ctx.autoX.value += (meta?.defaultWidth ?? 120) + 20;
384
- const label = asString(el.name);
413
+ const label = elementType === "Annotation" ? asString(el.text) ?? asString(el.name) : asString(el.name);
385
414
  const documentation = extractDocumentation(el);
386
415
  const trigger = extractTrigger(el);
387
416
  const eventDefinition = extractEventDefinition(el);
@@ -392,6 +421,8 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
392
421
  const scriptFormat = elementType === "ScriptTask" ? asString(el.scriptFormat) : void 0;
393
422
  const script = elementType === "ScriptTask" ? asString(el.script) : void 0;
394
423
  const completionCondition = elementType === "AdHocSubProcess" ? extractCompletionCondition(el) : void 0;
424
+ const loopChars = extractLoopCharacteristics(el);
425
+ const dataObjectRef = elementType === "DataObjectReference" ? asString(el.dataObjectRef?.id) : void 0;
395
426
  const data = {
396
427
  elementType,
397
428
  ...label ? { label } : {},
@@ -412,6 +443,8 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
412
443
  ...scriptFormat ? { scriptFormat } : {},
413
444
  ...script ? { script } : {},
414
445
  ...completionCondition ? { completionCondition } : {},
446
+ ...dataObjectRef ? { dataObjectRef } : {},
447
+ ...loopChars,
415
448
  ...aranzaExt
416
449
  };
417
450
  if (elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess") {
@@ -444,11 +477,14 @@ function buildEdge(el, edgeType, ctx, edges) {
444
477
  const label = asString(el.name);
445
478
  const documentation = extractDocumentation(el);
446
479
  const condExpr = el.conditionExpression;
480
+ const rawDir = asString(el.associationDirection);
481
+ const associationDirection = edgeType === "association" && rawDir ? rawDir.toLowerCase() : void 0;
447
482
  const data = {
448
483
  edgeType,
449
484
  ...label ? { label } : {},
450
485
  ...documentation ? { documentation } : {},
451
- ...condExpr?.body ? { conditionExpression: condExpr.body } : {}
486
+ ...condExpr?.body ? { conditionExpression: condExpr.body } : {},
487
+ ...associationDirection ? { associationDirection } : {}
452
488
  };
453
489
  const waypoints = ctx.waypoints.get(id);
454
490
  if (waypoints?.length) data.routingPoints = waypoints;
@@ -473,7 +509,7 @@ function handleCollaboration(collaboration, ctx, nodes, edges) {
473
509
  if (processRef) {
474
510
  const laneMembership = extractLaneMembership(processRef);
475
511
  walkFlowElements(
476
- asElements(processRef.flowElements),
512
+ [...asElements(processRef.flowElements), ...asElements(processRef.artifacts)],
477
513
  id,
478
514
  { ...ctx, laneMembership },
479
515
  nodes,
@@ -505,7 +541,7 @@ function addLaneNodes(laneSet, poolId, ctx, nodes) {
505
541
  data: { elementType: "Lane", ...label ? { label } : {} },
506
542
  width: shape?.width ?? 570,
507
543
  height: shape?.height ?? 120,
508
- parentId: poolId
544
+ ...poolId ? { parentId: poolId } : {}
509
545
  });
510
546
  const child = lane.childLaneSet;
511
547
  if (child) addLaneNodes(child, poolId, ctx, nodes);
@@ -539,9 +575,9 @@ async function parseBpmnXml(xml) {
539
575
  } else if (rootEl.$type === "bpmn:Process") {
540
576
  const laneMembership = extractLaneMembership(rootEl);
541
577
  const laneSet = rootEl.laneSet;
542
- if (laneSet) addLaneNodes(laneSet, "", ctx, nodes);
578
+ if (laneSet) addLaneNodes(laneSet, void 0, ctx, nodes);
543
579
  walkFlowElements(
544
- asElements(rootEl.flowElements),
580
+ [...asElements(rootEl.flowElements), ...asElements(rootEl.artifacts)],
545
581
  void 0,
546
582
  { ...ctx, laneMembership },
547
583
  nodes,
@@ -714,7 +750,10 @@ function buildAranzaExtensionElements(moddle, node) {
714
750
  const formKey = typeof node.data.formKey === "string" ? node.data.formKey : void 0;
715
751
  const candidateUsers = typeof node.data.candidateUsers === "string" ? node.data.candidateUsers : void 0;
716
752
  const candidateGroups = typeof node.data.candidateGroups === "string" ? node.data.candidateGroups : void 0;
717
- if (!priority && !owner && !sla && !connector && !action && !flowableType && !flowableDelegateExpression && !decisionRef && !formKey && !candidateUsers && !candidateGroups) {
753
+ const dueDate = typeof node.data.dueDate === "string" ? node.data.dueDate : void 0;
754
+ const skipExpression = typeof node.data.skipExpression === "string" ? node.data.skipExpression : void 0;
755
+ const businessCalendarName = typeof node.data.businessCalendarName === "string" ? node.data.businessCalendarName : void 0;
756
+ if (!priority && !owner && !sla && !connector && !action && !flowableType && !flowableDelegateExpression && !decisionRef && !formKey && !candidateUsers && !candidateGroups && !dueDate && !skipExpression && !businessCalendarName) {
718
757
  return null;
719
758
  }
720
759
  const configAttrs = {};
@@ -729,9 +768,13 @@ function buildAranzaExtensionElements(moddle, node) {
729
768
  if (formKey) configAttrs.formKey = formKey;
730
769
  if (candidateUsers) configAttrs.candidateUsers = candidateUsers;
731
770
  if (candidateGroups) configAttrs.candidateGroups = candidateGroups;
771
+ if (dueDate) configAttrs.dueDate = dueDate;
772
+ if (skipExpression) configAttrs.skipExpression = skipExpression;
773
+ if (businessCalendarName) configAttrs.businessCalendarName = businessCalendarName;
732
774
  const taskConfig = moddle.create("aranza:TaskConfig", configAttrs);
733
775
  return moddle.create("bpmn:ExtensionElements", { values: [taskConfig] });
734
776
  }
777
+ var ARTIFACT_ELEMENT_TYPES = /* @__PURE__ */ new Set(["Annotation", "Group"]);
735
778
  function buildSemanticModel(moddle, nodes, edges, opts) {
736
779
  const defId = opts.id ?? "Definitions_1";
737
780
  const defName = opts.name;
@@ -827,10 +870,31 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
827
870
  };
828
871
  const myNodes = (poolId ? allNodes.filter((n) => belongsToPool(n)) : allNodes.filter((n) => n.data.elementType !== "Pool" && n.data.elementType !== "Lane")).filter((n) => !isInsideSubProcess(n));
829
872
  const myLanes = laneNodes.filter((l) => poolId ? l.parentId === poolId : true);
873
+ const presentDataObjectIds = new Set(
874
+ myNodes.filter((n) => n.data.elementType === "DataObject").map((n) => n.id)
875
+ );
830
876
  const flowElements = [];
877
+ const artifacts = [];
878
+ for (const node of myNodes) {
879
+ if (node.data.elementType === "DataObjectReference") {
880
+ const explicitRef = typeof node.data.dataObjectRef === "string" ? node.data.dataObjectRef : null;
881
+ if (!explicitRef || !presentDataObjectIds.has(explicitRef)) {
882
+ const syntheticId = `DataObject_${node.id}`;
883
+ if (!presentDataObjectIds.has(syntheticId)) {
884
+ flowElements.push(moddle.create("bpmn:DataObject", { id: syntheticId }));
885
+ presentDataObjectIds.add(syntheticId);
886
+ }
887
+ }
888
+ }
889
+ }
831
890
  for (const node of myNodes) {
832
891
  const el = buildFlowElement(moddle, node, allNodes, allEdges);
833
- if (el) flowElements.push(el);
892
+ if (!el) continue;
893
+ if (ARTIFACT_ELEMENT_TYPES.has(node.data.elementType)) {
894
+ artifacts.push(el);
895
+ } else {
896
+ flowElements.push(el);
897
+ }
834
898
  }
835
899
  const myNodeIds = new Set(myNodes.map((n) => n.id));
836
900
  const myEdges = allEdges.filter(
@@ -838,7 +902,12 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
838
902
  );
839
903
  for (const edge of myEdges) {
840
904
  const edgeMeta = buildEdgeElement(moddle, edge);
841
- if (edgeMeta) flowElements.push(edgeMeta);
905
+ if (!edgeMeta) continue;
906
+ if (edge.data?.edgeType === "association") {
907
+ artifacts.push(edgeMeta);
908
+ } else {
909
+ flowElements.push(edgeMeta);
910
+ }
842
911
  }
843
912
  const elementById = new Map(
844
913
  flowElements.filter((element) => typeof element.id === "string").map((element) => [element.id, element])
@@ -854,7 +923,8 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
854
923
  const process = moddle.create("bpmn:Process", {
855
924
  id: processId,
856
925
  isExecutable: opts.process?.executable ?? true,
857
- flowElements
926
+ flowElements,
927
+ ...artifacts.length > 0 ? { artifacts } : {}
858
928
  });
859
929
  if (opts.process?.documentation) {
860
930
  process.documentation = [
@@ -886,6 +956,10 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
886
956
  id: node.id,
887
957
  name: label ?? ""
888
958
  };
959
+ if (elementType === "Annotation") {
960
+ delete attrs.name;
961
+ attrs.text = label ?? "";
962
+ }
889
963
  if (node.data.documentation) {
890
964
  attrs.documentation = [
891
965
  moddle.create("bpmn:Documentation", { text: node.data.documentation })
@@ -904,22 +978,16 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
904
978
  if (elementType === "CallActivity" && node.data.calledElement) {
905
979
  attrs.calledElement = node.data.calledElement;
906
980
  }
981
+ if (elementType === "DataObjectReference") {
982
+ const refId = typeof node.data.dataObjectRef === "string" ? node.data.dataObjectRef : `DataObject_${node.id}`;
983
+ attrs.dataObjectRef = { id: refId };
984
+ }
907
985
  if (elementType === "ScriptTask") {
908
986
  const scriptFormat = typeof node.data.scriptFormat === "string" ? node.data.scriptFormat : void 0;
909
987
  const script = typeof node.data.script === "string" ? node.data.script : void 0;
910
988
  if (scriptFormat) attrs.scriptFormat = scriptFormat;
911
989
  if (script) attrs.script = script;
912
990
  }
913
- if (elementType === "UserTask") {
914
- const flowableAttrs = {};
915
- const fk = typeof node.data.formKey === "string" ? node.data.formKey : void 0;
916
- const cu = typeof node.data.candidateUsers === "string" ? node.data.candidateUsers : void 0;
917
- const cg = typeof node.data.candidateGroups === "string" ? node.data.candidateGroups : void 0;
918
- if (fk) flowableAttrs["flowable:formKey"] = fk;
919
- if (cu) flowableAttrs["flowable:candidateUsers"] = cu;
920
- if (cg) flowableAttrs["flowable:candidateGroups"] = cg;
921
- if (Object.keys(flowableAttrs).length > 0) attrs.$attrs = flowableAttrs;
922
- }
923
991
  if (elementType === "ServiceTask") {
924
992
  const flowableAttrs = {};
925
993
  const flowableType = typeof node.data.flowableType === "string" ? node.data.flowableType : void 0;
@@ -936,7 +1004,9 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
936
1004
  if (aranzaConfig) attrs.extensionElements = aranzaConfig;
937
1005
  const isSubProcess = elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess";
938
1006
  if (isSubProcess) {
939
- attrs.flowElements = buildNestedFlowElements(moddle, node, allNodes, allEdges);
1007
+ const nested = buildNestedFlowElements(moddle, node, allNodes, allEdges);
1008
+ attrs.flowElements = nested.flowElements;
1009
+ if (nested.artifacts.length > 0) attrs.artifacts = nested.artifacts;
940
1010
  if (elementType === "EventSubProcess" || node.data.subProcessVariant === "event") {
941
1011
  attrs.triggeredByEvent = true;
942
1012
  }
@@ -946,6 +1016,29 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
946
1016
  });
947
1017
  }
948
1018
  }
1019
+ const loopType = typeof node.data.loopType === "string" ? node.data.loopType : "none";
1020
+ if (loopType && loopType !== "none") {
1021
+ if (loopType === "loop") {
1022
+ const lcAttrs = { id: uid("LoopChar", node.id) };
1023
+ const loopCondition = typeof node.data.loopCondition === "string" ? node.data.loopCondition : void 0;
1024
+ if (loopCondition) {
1025
+ lcAttrs.loopCondition = moddle.create("bpmn:FormalExpression", { body: loopCondition });
1026
+ }
1027
+ attrs.loopCharacteristics = moddle.create("bpmn:StandardLoopCharacteristics", lcAttrs);
1028
+ } else {
1029
+ const isSequential = loopType === "sequentialMultiple";
1030
+ const lcAttrs = { id: uid("LoopChar", node.id), isSequential };
1031
+ const loopCardinality = typeof node.data.loopCardinality === "string" ? node.data.loopCardinality : void 0;
1032
+ const loopCompletionCondition = typeof node.data.loopCompletionCondition === "string" ? node.data.loopCompletionCondition : void 0;
1033
+ if (loopCardinality) {
1034
+ lcAttrs.loopCardinality = moddle.create("bpmn:FormalExpression", { body: loopCardinality });
1035
+ }
1036
+ if (loopCompletionCondition) {
1037
+ lcAttrs.completionCondition = moddle.create("bpmn:FormalExpression", { body: loopCompletionCondition });
1038
+ }
1039
+ attrs.loopCharacteristics = moddle.create("bpmn:MultiInstanceLoopCharacteristics", lcAttrs);
1040
+ }
1041
+ }
949
1042
  const element = moddle.create(moddleType, attrs);
950
1043
  return element;
951
1044
  }
@@ -953,16 +1046,42 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
953
1046
  const childNodes = allNodes.filter((node) => node.parentId === parent.id);
954
1047
  const childNodeIds = new Set(childNodes.map((node) => node.id));
955
1048
  const flowElements = [];
1049
+ const artifacts = [];
1050
+ const presentDataObjectIds = new Set(
1051
+ childNodes.filter((n) => n.data.elementType === "DataObject").map((n) => n.id)
1052
+ );
1053
+ for (const node of childNodes) {
1054
+ if (node.data.elementType === "DataObjectReference") {
1055
+ const explicitRef = typeof node.data.dataObjectRef === "string" ? node.data.dataObjectRef : null;
1056
+ if (!explicitRef || !presentDataObjectIds.has(explicitRef)) {
1057
+ const syntheticId = `DataObject_${node.id}`;
1058
+ if (!presentDataObjectIds.has(syntheticId)) {
1059
+ flowElements.push(moddle.create("bpmn:DataObject", { id: syntheticId }));
1060
+ presentDataObjectIds.add(syntheticId);
1061
+ }
1062
+ }
1063
+ }
1064
+ }
956
1065
  for (const child of childNodes) {
957
1066
  const element = buildFlowElement(moddle, child, allNodes, allEdges);
958
- if (element) flowElements.push(element);
1067
+ if (!element) continue;
1068
+ if (ARTIFACT_ELEMENT_TYPES.has(child.data.elementType)) {
1069
+ artifacts.push(element);
1070
+ } else {
1071
+ flowElements.push(element);
1072
+ }
959
1073
  }
960
1074
  for (const edge of allEdges) {
961
1075
  if (!childNodeIds.has(edge.source) || !childNodeIds.has(edge.target)) continue;
962
1076
  const element = buildEdgeElement(moddle, edge);
963
- if (element) flowElements.push(element);
1077
+ if (!element) continue;
1078
+ if (edge.data?.edgeType === "association") {
1079
+ artifacts.push(element);
1080
+ } else {
1081
+ flowElements.push(element);
1082
+ }
964
1083
  }
965
- return flowElements;
1084
+ return { flowElements, artifacts };
966
1085
  }
967
1086
  function buildEdgeElement(moddle, edge) {
968
1087
  if (!edge.data) return null;
@@ -984,6 +1103,9 @@ function buildEdgeElement(moddle, edge) {
984
1103
  body: edge.data.conditionExpression
985
1104
  });
986
1105
  }
1106
+ if (edge.data.edgeType === "association" && edge.data.associationDirection && edge.data.associationDirection !== "none") {
1107
+ attrs.associationDirection = edge.data.associationDirection === "both" ? "Both" : "One";
1108
+ }
987
1109
  return moddle.create(moddleType, attrs);
988
1110
  }
989
1111
  function buildBpmnDI(moddle, definitions, nodes, edges) {
@@ -1087,5 +1209,5 @@ async function serializeBpmnXml(nodes, edges, opts = {}) {
1087
1209
  }
1088
1210
 
1089
1211
  export { parseBpmnXml, serializeBpmnXml };
1090
- //# sourceMappingURL=chunk-HLCUGTEK.js.map
1091
- //# sourceMappingURL=chunk-HLCUGTEK.js.map
1212
+ //# sourceMappingURL=chunk-MZVDC6FU.js.map
1213
+ //# sourceMappingURL=chunk-MZVDC6FU.js.map