@aranzatech/diagrams-bpmn 0.3.1 → 0.3.2

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 (36) hide show
  1. package/dist/{catalog-DAGDhO-D.d.cts → catalog-DG-sz0VM.d.cts} +1 -1
  2. package/dist/{catalog-Q1QmKLDD.d.ts → catalog-DNIyjHbl.d.ts} +1 -1
  3. package/dist/{chunk-334WN4JZ.js → chunk-NYIYQUGX.js} +104 -23
  4. package/dist/chunk-NYIYQUGX.js.map +1 -0
  5. package/dist/elements/index.d.cts +3 -3
  6. package/dist/elements/index.d.ts +3 -3
  7. package/dist/extensions/index.d.cts +2 -2
  8. package/dist/extensions/index.d.ts +2 -2
  9. package/dist/index.cjs +102 -21
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +4 -4
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +1 -1
  14. package/dist/layout/index.cjs +60 -29
  15. package/dist/layout/index.cjs.map +1 -1
  16. package/dist/layout/index.d.cts +4 -4
  17. package/dist/layout/index.d.ts +4 -4
  18. package/dist/layout/index.js +60 -29
  19. package/dist/layout/index.js.map +1 -1
  20. package/dist/modeling/index.d.cts +4 -4
  21. package/dist/modeling/index.d.ts +4 -4
  22. package/dist/{types-CggktCqr.d.cts → types-CDp9kWQ4.d.cts} +2 -2
  23. package/dist/{types-DmDODKlh.d.ts → types-CuDL2YGL.d.ts} +2 -2
  24. package/dist/{types-D7zel9dq.d.ts → types-X5FyP8oS.d.ts} +1 -1
  25. package/dist/{types-BX_o95GC.d.cts → types-dQUuSnV5.d.cts} +1 -1
  26. package/dist/{types-BYN4Zuee.d.cts → types-nvF59RGF.d.cts} +12 -0
  27. package/dist/{types-BYN4Zuee.d.ts → types-nvF59RGF.d.ts} +12 -0
  28. package/dist/validation/index.d.cts +3 -3
  29. package/dist/validation/index.d.ts +3 -3
  30. package/dist/xml/index.cjs +102 -21
  31. package/dist/xml/index.cjs.map +1 -1
  32. package/dist/xml/index.d.cts +4 -4
  33. package/dist/xml/index.d.ts +4 -4
  34. package/dist/xml/index.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-334WN4JZ.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -2720,6 +2720,9 @@ var TRIGGER_TO_EVENT_DEF = {
2720
2720
  function asElements(v) {
2721
2721
  return Array.isArray(v) ? v : [];
2722
2722
  }
2723
+ function asLaneSets(value) {
2724
+ return asElements(value);
2725
+ }
2723
2726
  function asString(v) {
2724
2727
  return typeof v === "string" && v.trim() ? v.trim() : void 0;
2725
2728
  }
@@ -2774,6 +2777,11 @@ function extractLaneMembership(process) {
2774
2777
  if (child) walkLaneSet(child);
2775
2778
  }
2776
2779
  }
2780
+ const laneSets = asLaneSets(process.laneSets);
2781
+ if (laneSets.length > 0) {
2782
+ for (const laneSet2 of laneSets) walkLaneSet(laneSet2);
2783
+ return map;
2784
+ }
2777
2785
  const laneSet = process.laneSet;
2778
2786
  if (laneSet) walkLaneSet(laneSet);
2779
2787
  return map;
@@ -2874,15 +2882,39 @@ function extractAranzaExtensions(el) {
2874
2882
  if (ft) result.flowableType = ft;
2875
2883
  const fde = asString(elAttrs["flowable:delegateExpression"]);
2876
2884
  if (fde) result.flowableDelegateExpression = fde;
2885
+ const fc = asString(elAttrs["flowable:class"]);
2886
+ if (fc) result.flowableClass = fc;
2887
+ const fe = asString(elAttrs["flowable:expression"]);
2888
+ if (fe) result.flowableExpression = fe;
2877
2889
  const fk = asString(elAttrs["flowable:formKey"]);
2878
2890
  if (fk) result.formKey = fk;
2879
2891
  const cu = asString(elAttrs["flowable:candidateUsers"]);
2880
2892
  if (cu) result.candidateUsers = cu;
2881
2893
  const cg = asString(elAttrs["flowable:candidateGroups"]);
2882
2894
  if (cg) result.candidateGroups = cg;
2895
+ const dueDate2 = asString(elAttrs["flowable:dueDate"]);
2896
+ if (dueDate2) result.dueDate = dueDate2;
2897
+ const skipExpression2 = asString(elAttrs["flowable:skipExpression"]);
2898
+ if (skipExpression2) result.skipExpression = skipExpression2;
2899
+ const businessCalendarName2 = asString(elAttrs["flowable:businessCalendarName"]);
2900
+ if (businessCalendarName2) result.businessCalendarName = businessCalendarName2;
2901
+ const resultVariable = asString(elAttrs["flowable:resultVariable"]);
2902
+ if (resultVariable) result.resultVariable = resultVariable;
2903
+ const ruleVariablesInput = asString(elAttrs["flowable:ruleVariablesInput"]);
2904
+ if (ruleVariablesInput) result.ruleVariablesInput = ruleVariablesInput;
2905
+ const ruleNames = asString(elAttrs["flowable:rules"]);
2906
+ if (ruleNames) result.ruleNames = ruleNames;
2907
+ const exclude = asString(elAttrs["flowable:exclude"]);
2908
+ if (exclude === "true") result.excludeRules = true;
2909
+ else if (exclude === "false") result.excludeRules = false;
2883
2910
  }
2884
2911
  const ext = el.extensionElements;
2885
- if (!ext) return result;
2912
+ if (!ext) {
2913
+ if (result.flowableType === "http" && !result.serviceConfig) {
2914
+ result.serviceConfig = { implementation: "http" };
2915
+ }
2916
+ return result;
2917
+ }
2886
2918
  const extValues = asElements(ext.values);
2887
2919
  const inlineDecision = extValues.find((v) => v.$type === "aranza:InlineDecision");
2888
2920
  if (inlineDecision) {
@@ -2897,7 +2929,12 @@ function extractAranzaExtensions(el) {
2897
2929
  }
2898
2930
  }
2899
2931
  const taskConfig = extValues.find((v) => v.$type === "aranza:TaskConfig");
2900
- if (!taskConfig) return result;
2932
+ if (!taskConfig) {
2933
+ if (result.flowableType === "http" && !result.serviceConfig) {
2934
+ result.serviceConfig = { implementation: "http" };
2935
+ }
2936
+ return result;
2937
+ }
2901
2938
  const priority = asString(taskConfig.priority);
2902
2939
  if (priority === "critical" || priority === "high" || priority === "medium" || priority === "low") {
2903
2940
  result.priority = priority;
@@ -2957,6 +2994,9 @@ function extractAranzaExtensions(el) {
2957
2994
  if (skipExpression) result.skipExpression = skipExpression;
2958
2995
  const businessCalendarName = asString(taskConfig.businessCalendarName);
2959
2996
  if (businessCalendarName) result.businessCalendarName = businessCalendarName;
2997
+ if (!result.serviceConfig && result.flowableType === "http") {
2998
+ result.serviceConfig = { implementation: "http" };
2999
+ }
2960
3000
  return result;
2961
3001
  }
2962
3002
  function extractCompletionCondition(el) {
@@ -3074,8 +3114,8 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
3074
3114
  }
3075
3115
  function buildEdge(el, edgeType, ctx, edges) {
3076
3116
  const id = el.id;
3077
- const source = el.sourceRef?.id;
3078
- const target = el.targetRef?.id;
3117
+ const source = extractReferenceId(el.sourceRef);
3118
+ const target = extractReferenceId(el.targetRef);
3079
3119
  if (!source || !target) {
3080
3120
  ctx.warnings.push(`Edge "${id}" missing source or target \u2014 skipped.`);
3081
3121
  return;
@@ -3110,6 +3150,21 @@ function buildEdge(el, edgeType, ctx, edges) {
3110
3150
  if (waypoints?.length) data.routingPoints = waypoints;
3111
3151
  edges.push({ id, type: edgeType, source, target, data });
3112
3152
  }
3153
+ function extractReferenceId(value) {
3154
+ if (Array.isArray(value)) {
3155
+ for (const entry of value) {
3156
+ const id = extractReferenceId(entry);
3157
+ if (id) return id;
3158
+ }
3159
+ return void 0;
3160
+ }
3161
+ if (typeof value === "string") return value;
3162
+ if (value && typeof value === "object") {
3163
+ const id = value.id;
3164
+ return typeof id === "string" ? id : void 0;
3165
+ }
3166
+ return void 0;
3167
+ }
3113
3168
  function handleCollaboration(collaboration, ctx, nodes, edges) {
3114
3169
  for (const participant of asElements(collaboration.participants)) {
3115
3170
  const id = participant.id;
@@ -3135,9 +3190,12 @@ function handleCollaboration(collaboration, ctx, nodes, edges) {
3135
3190
  nodes,
3136
3191
  edges
3137
3192
  );
3138
- const laneSet = processRef.laneSet;
3139
- if (laneSet) {
3140
- addLaneNodes(laneSet, id, ctx, nodes);
3193
+ const laneSets = asLaneSets(processRef.laneSets);
3194
+ if (laneSets.length > 0) {
3195
+ for (const laneSet of laneSets) addLaneNodes(laneSet, id, ctx, nodes);
3196
+ } else {
3197
+ const laneSet = processRef.laneSet;
3198
+ if (laneSet) addLaneNodes(laneSet, id, ctx, nodes);
3141
3199
  }
3142
3200
  }
3143
3201
  }
@@ -3194,8 +3252,13 @@ async function parseBpmnXml(xml) {
3194
3252
  handleCollaboration(rootEl, ctx, nodes, edges);
3195
3253
  } else if (rootEl.$type === "bpmn:Process") {
3196
3254
  const laneMembership = extractLaneMembership(rootEl);
3197
- const laneSet = rootEl.laneSet;
3198
- if (laneSet) addLaneNodes(laneSet, void 0, ctx, nodes);
3255
+ const laneSets = asLaneSets(rootEl.laneSets);
3256
+ if (laneSets.length > 0) {
3257
+ for (const laneSet of laneSets) addLaneNodes(laneSet, void 0, ctx, nodes);
3258
+ } else {
3259
+ const laneSet = rootEl.laneSet;
3260
+ if (laneSet) addLaneNodes(laneSet, void 0, ctx, nodes);
3261
+ }
3199
3262
  walkFlowElements(
3200
3263
  [...asElements(rootEl.flowElements), ...asElements(rootEl.artifacts)],
3201
3264
  void 0,
@@ -3461,6 +3524,13 @@ function buildAranzaExtensionElements(moddle, node) {
3461
3524
  return moddle.create("bpmn:ExtensionElements", { values });
3462
3525
  }
3463
3526
  var ARTIFACT_ELEMENT_TYPES = /* @__PURE__ */ new Set(["Annotation", "Group"]);
3527
+ var DATA_ASSOCIATION_SOURCE_TYPES = /* @__PURE__ */ new Set([
3528
+ "DataObject",
3529
+ "DataObjectReference",
3530
+ "DataStore",
3531
+ "DataStoreReference",
3532
+ "DataInput"
3533
+ ]);
3464
3534
  function buildSemanticModel(moddle, nodes, edges, opts) {
3465
3535
  const defId = opts.id ?? "Definitions_1";
3466
3536
  const defName = opts.name;
@@ -3568,6 +3638,7 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
3568
3638
  };
3569
3639
  const myNodes = (poolId ? allNodes.filter((n) => belongsToPool(n)) : allNodes.filter((n) => n.data.elementType !== "Pool" && n.data.elementType !== "Lane")).filter((n) => !isInsideSubProcess(n)).filter((n) => !(n.data.elementType === "DataStore" && referencedDataStoreIds.has(n.id)));
3570
3640
  const myLanes = laneNodes.filter((l) => poolId ? l.parentId === poolId : true);
3641
+ const nodeById2 = new Map(myNodes.map((node) => [node.id, node]));
3571
3642
  const presentDataObjectIds = new Set(
3572
3643
  myNodes.filter((n) => n.data.elementType === "DataObject").map((n) => n.id)
3573
3644
  );
@@ -3599,7 +3670,7 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
3599
3670
  (e) => (e.data?.edgeType === "sequenceFlow" || e.data?.edgeType === "association" || e.data?.edgeType === "dataAssociation") && myNodeIds.has(e.source) && myNodeIds.has(e.target)
3600
3671
  );
3601
3672
  for (const edge of myEdges) {
3602
- const edgeMeta = buildEdgeElement(moddle, edge);
3673
+ const edgeMeta = buildEdgeElement(moddle, edge, nodeById2);
3603
3674
  if (!edgeMeta) continue;
3604
3675
  if (edge.data?.edgeType === "association") {
3605
3676
  artifacts.push(edgeMeta);
@@ -3645,10 +3716,12 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
3645
3716
  flowNodeRef: myNodes.filter((n) => n.parentId === l.id).map((n) => ({ id: n.id }))
3646
3717
  })
3647
3718
  );
3648
- process.laneSet = moddle.create("bpmn:LaneSet", {
3649
- id: `LaneSet_${processId}`,
3650
- lanes: laneElements
3651
- });
3719
+ process.laneSets = [
3720
+ moddle.create("bpmn:LaneSet", {
3721
+ id: `LaneSet_${processId}`,
3722
+ lanes: laneElements
3723
+ })
3724
+ ];
3652
3725
  }
3653
3726
  return process;
3654
3727
  }
@@ -3756,6 +3829,7 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
3756
3829
  const referencedDataStoreIds = collectReferencedDataStoreIds(allNodes);
3757
3830
  const childNodes = allNodes.filter((node) => node.parentId === parent.id).filter((node) => !(node.data.elementType === "DataStore" && referencedDataStoreIds.has(node.id)));
3758
3831
  const childNodeIds = new Set(childNodes.map((node) => node.id));
3832
+ const childNodeById = new Map(childNodes.map((node) => [node.id, node]));
3759
3833
  const flowElements = [];
3760
3834
  const artifacts = [];
3761
3835
  const presentDataObjectIds = new Set(
@@ -3784,7 +3858,7 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
3784
3858
  }
3785
3859
  for (const edge of allEdges) {
3786
3860
  if (!childNodeIds.has(edge.source) || !childNodeIds.has(edge.target)) continue;
3787
- const element = buildEdgeElement(moddle, edge);
3861
+ const element = buildEdgeElement(moddle, edge, childNodeById);
3788
3862
  if (!element) continue;
3789
3863
  if (edge.data?.edgeType === "association") {
3790
3864
  artifacts.push(element);
@@ -3794,16 +3868,23 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
3794
3868
  }
3795
3869
  return { flowElements, artifacts };
3796
3870
  }
3797
- function buildEdgeElement(moddle, edge) {
3871
+ function buildEdgeElement(moddle, edge, nodeById2) {
3798
3872
  if (!edge.data) return null;
3799
- const moddleType = EDGE_TYPE_TO_MODDLE[edge.data.edgeType];
3873
+ const sourceNode = nodeById2.get(edge.source);
3874
+ const dataAssociationIsInput = edge.data.edgeType === "dataAssociation" && DATA_ASSOCIATION_SOURCE_TYPES.has(sourceNode?.data.elementType ?? "");
3875
+ const moddleType = edge.data.edgeType === "dataAssociation" ? dataAssociationIsInput ? "bpmn:DataInputAssociation" : "bpmn:DataOutputAssociation" : EDGE_TYPE_TO_MODDLE[edge.data.edgeType];
3800
3876
  if (!moddleType) return null;
3801
3877
  const attrs = {
3802
3878
  id: edge.id,
3803
- name: edge.data.label ?? "",
3804
- sourceRef: { id: edge.source },
3805
- targetRef: { id: edge.target }
3879
+ name: edge.data.label ?? ""
3806
3880
  };
3881
+ if (edge.data.edgeType === "dataAssociation") {
3882
+ attrs.sourceRef = [{ id: edge.source }];
3883
+ attrs.targetRef = { id: edge.target };
3884
+ } else {
3885
+ attrs.sourceRef = { id: edge.source };
3886
+ attrs.targetRef = { id: edge.target };
3887
+ }
3807
3888
  if (edge.data.documentation) {
3808
3889
  attrs.documentation = [
3809
3890
  moddle.create("bpmn:Documentation", { text: edge.data.documentation })
@@ -3856,7 +3937,7 @@ function buildBpmnDI(moddle, definitions, nodes, edges) {
3856
3937
  );
3857
3938
  }
3858
3939
  const rootEls = definitions.rootElements;
3859
- const planeElement = rootEls?.[0];
3940
+ const planeElement = rootEls?.find((element) => element.$type === "bpmn:Collaboration") ?? rootEls?.find((element) => element.$type === "bpmn:Process") ?? rootEls?.[0];
3860
3941
  const plane = moddle.create("bpmndi:BPMNPlane", {
3861
3942
  id: "BPMNPlane_1",
3862
3943
  bpmnElement: planeElement ?? { id: "unknown" },