@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
@@ -1,4 +1,4 @@
1
- import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-BYN4Zuee.cjs';
1
+ import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-nvF59RGF.cjs';
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-BYN4Zuee.js';
1
+ import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-nvF59RGF.js';
2
2
 
3
3
  declare const BPMN_ELEMENT_CATALOG: Record<BpmnElementType, BpmnElementMeta>;
4
4
  declare function getElementMeta(type: BpmnElementType): BpmnElementMeta;
@@ -126,6 +126,9 @@ var TRIGGER_TO_EVENT_DEF = {
126
126
  function asElements(v) {
127
127
  return Array.isArray(v) ? v : [];
128
128
  }
129
+ function asLaneSets(value) {
130
+ return asElements(value);
131
+ }
129
132
  function asString(v) {
130
133
  return typeof v === "string" && v.trim() ? v.trim() : void 0;
131
134
  }
@@ -180,6 +183,11 @@ function extractLaneMembership(process) {
180
183
  if (child) walkLaneSet(child);
181
184
  }
182
185
  }
186
+ const laneSets = asLaneSets(process.laneSets);
187
+ if (laneSets.length > 0) {
188
+ for (const laneSet2 of laneSets) walkLaneSet(laneSet2);
189
+ return map;
190
+ }
183
191
  const laneSet = process.laneSet;
184
192
  if (laneSet) walkLaneSet(laneSet);
185
193
  return map;
@@ -280,15 +288,39 @@ function extractAranzaExtensions(el) {
280
288
  if (ft) result.flowableType = ft;
281
289
  const fde = asString(elAttrs["flowable:delegateExpression"]);
282
290
  if (fde) result.flowableDelegateExpression = fde;
291
+ const fc = asString(elAttrs["flowable:class"]);
292
+ if (fc) result.flowableClass = fc;
293
+ const fe = asString(elAttrs["flowable:expression"]);
294
+ if (fe) result.flowableExpression = fe;
283
295
  const fk = asString(elAttrs["flowable:formKey"]);
284
296
  if (fk) result.formKey = fk;
285
297
  const cu = asString(elAttrs["flowable:candidateUsers"]);
286
298
  if (cu) result.candidateUsers = cu;
287
299
  const cg = asString(elAttrs["flowable:candidateGroups"]);
288
300
  if (cg) result.candidateGroups = cg;
301
+ const dueDate2 = asString(elAttrs["flowable:dueDate"]);
302
+ if (dueDate2) result.dueDate = dueDate2;
303
+ const skipExpression2 = asString(elAttrs["flowable:skipExpression"]);
304
+ if (skipExpression2) result.skipExpression = skipExpression2;
305
+ const businessCalendarName2 = asString(elAttrs["flowable:businessCalendarName"]);
306
+ if (businessCalendarName2) result.businessCalendarName = businessCalendarName2;
307
+ const resultVariable = asString(elAttrs["flowable:resultVariable"]);
308
+ if (resultVariable) result.resultVariable = resultVariable;
309
+ const ruleVariablesInput = asString(elAttrs["flowable:ruleVariablesInput"]);
310
+ if (ruleVariablesInput) result.ruleVariablesInput = ruleVariablesInput;
311
+ const ruleNames = asString(elAttrs["flowable:rules"]);
312
+ if (ruleNames) result.ruleNames = ruleNames;
313
+ const exclude = asString(elAttrs["flowable:exclude"]);
314
+ if (exclude === "true") result.excludeRules = true;
315
+ else if (exclude === "false") result.excludeRules = false;
289
316
  }
290
317
  const ext = el.extensionElements;
291
- if (!ext) return result;
318
+ if (!ext) {
319
+ if (result.flowableType === "http" && !result.serviceConfig) {
320
+ result.serviceConfig = { implementation: "http" };
321
+ }
322
+ return result;
323
+ }
292
324
  const extValues = asElements(ext.values);
293
325
  const inlineDecision = extValues.find((v) => v.$type === "aranza:InlineDecision");
294
326
  if (inlineDecision) {
@@ -303,7 +335,12 @@ function extractAranzaExtensions(el) {
303
335
  }
304
336
  }
305
337
  const taskConfig = extValues.find((v) => v.$type === "aranza:TaskConfig");
306
- if (!taskConfig) return result;
338
+ if (!taskConfig) {
339
+ if (result.flowableType === "http" && !result.serviceConfig) {
340
+ result.serviceConfig = { implementation: "http" };
341
+ }
342
+ return result;
343
+ }
307
344
  const priority = asString(taskConfig.priority);
308
345
  if (priority === "critical" || priority === "high" || priority === "medium" || priority === "low") {
309
346
  result.priority = priority;
@@ -363,6 +400,9 @@ function extractAranzaExtensions(el) {
363
400
  if (skipExpression) result.skipExpression = skipExpression;
364
401
  const businessCalendarName = asString(taskConfig.businessCalendarName);
365
402
  if (businessCalendarName) result.businessCalendarName = businessCalendarName;
403
+ if (!result.serviceConfig && result.flowableType === "http") {
404
+ result.serviceConfig = { implementation: "http" };
405
+ }
366
406
  return result;
367
407
  }
368
408
  function extractCompletionCondition(el) {
@@ -480,8 +520,8 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
480
520
  }
481
521
  function buildEdge(el, edgeType, ctx, edges) {
482
522
  const id = el.id;
483
- const source = el.sourceRef?.id;
484
- const target = el.targetRef?.id;
523
+ const source = extractReferenceId(el.sourceRef);
524
+ const target = extractReferenceId(el.targetRef);
485
525
  if (!source || !target) {
486
526
  ctx.warnings.push(`Edge "${id}" missing source or target \u2014 skipped.`);
487
527
  return;
@@ -516,6 +556,21 @@ function buildEdge(el, edgeType, ctx, edges) {
516
556
  if (waypoints?.length) data.routingPoints = waypoints;
517
557
  edges.push({ id, type: edgeType, source, target, data });
518
558
  }
559
+ function extractReferenceId(value) {
560
+ if (Array.isArray(value)) {
561
+ for (const entry of value) {
562
+ const id = extractReferenceId(entry);
563
+ if (id) return id;
564
+ }
565
+ return void 0;
566
+ }
567
+ if (typeof value === "string") return value;
568
+ if (value && typeof value === "object") {
569
+ const id = value.id;
570
+ return typeof id === "string" ? id : void 0;
571
+ }
572
+ return void 0;
573
+ }
519
574
  function handleCollaboration(collaboration, ctx, nodes, edges) {
520
575
  for (const participant of asElements(collaboration.participants)) {
521
576
  const id = participant.id;
@@ -541,9 +596,12 @@ function handleCollaboration(collaboration, ctx, nodes, edges) {
541
596
  nodes,
542
597
  edges
543
598
  );
544
- const laneSet = processRef.laneSet;
545
- if (laneSet) {
546
- addLaneNodes(laneSet, id, ctx, nodes);
599
+ const laneSets = asLaneSets(processRef.laneSets);
600
+ if (laneSets.length > 0) {
601
+ for (const laneSet of laneSets) addLaneNodes(laneSet, id, ctx, nodes);
602
+ } else {
603
+ const laneSet = processRef.laneSet;
604
+ if (laneSet) addLaneNodes(laneSet, id, ctx, nodes);
547
605
  }
548
606
  }
549
607
  }
@@ -600,8 +658,13 @@ async function parseBpmnXml(xml) {
600
658
  handleCollaboration(rootEl, ctx, nodes, edges);
601
659
  } else if (rootEl.$type === "bpmn:Process") {
602
660
  const laneMembership = extractLaneMembership(rootEl);
603
- const laneSet = rootEl.laneSet;
604
- if (laneSet) addLaneNodes(laneSet, void 0, ctx, nodes);
661
+ const laneSets = asLaneSets(rootEl.laneSets);
662
+ if (laneSets.length > 0) {
663
+ for (const laneSet of laneSets) addLaneNodes(laneSet, void 0, ctx, nodes);
664
+ } else {
665
+ const laneSet = rootEl.laneSet;
666
+ if (laneSet) addLaneNodes(laneSet, void 0, ctx, nodes);
667
+ }
605
668
  walkFlowElements(
606
669
  [...asElements(rootEl.flowElements), ...asElements(rootEl.artifacts)],
607
670
  void 0,
@@ -867,6 +930,13 @@ function buildAranzaExtensionElements(moddle, node) {
867
930
  return moddle.create("bpmn:ExtensionElements", { values });
868
931
  }
869
932
  var ARTIFACT_ELEMENT_TYPES = /* @__PURE__ */ new Set(["Annotation", "Group"]);
933
+ var DATA_ASSOCIATION_SOURCE_TYPES = /* @__PURE__ */ new Set([
934
+ "DataObject",
935
+ "DataObjectReference",
936
+ "DataStore",
937
+ "DataStoreReference",
938
+ "DataInput"
939
+ ]);
870
940
  function buildSemanticModel(moddle, nodes, edges, opts) {
871
941
  const defId = opts.id ?? "Definitions_1";
872
942
  const defName = opts.name;
@@ -974,6 +1044,7 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
974
1044
  };
975
1045
  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)));
976
1046
  const myLanes = laneNodes.filter((l) => poolId ? l.parentId === poolId : true);
1047
+ const nodeById = new Map(myNodes.map((node) => [node.id, node]));
977
1048
  const presentDataObjectIds = new Set(
978
1049
  myNodes.filter((n) => n.data.elementType === "DataObject").map((n) => n.id)
979
1050
  );
@@ -1005,7 +1076,7 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
1005
1076
  (e) => (e.data?.edgeType === "sequenceFlow" || e.data?.edgeType === "association" || e.data?.edgeType === "dataAssociation") && myNodeIds.has(e.source) && myNodeIds.has(e.target)
1006
1077
  );
1007
1078
  for (const edge of myEdges) {
1008
- const edgeMeta = buildEdgeElement(moddle, edge);
1079
+ const edgeMeta = buildEdgeElement(moddle, edge, nodeById);
1009
1080
  if (!edgeMeta) continue;
1010
1081
  if (edge.data?.edgeType === "association") {
1011
1082
  artifacts.push(edgeMeta);
@@ -1051,10 +1122,12 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId,
1051
1122
  flowNodeRef: myNodes.filter((n) => n.parentId === l.id).map((n) => ({ id: n.id }))
1052
1123
  })
1053
1124
  );
1054
- process.laneSet = moddle.create("bpmn:LaneSet", {
1055
- id: `LaneSet_${processId}`,
1056
- lanes: laneElements
1057
- });
1125
+ process.laneSets = [
1126
+ moddle.create("bpmn:LaneSet", {
1127
+ id: `LaneSet_${processId}`,
1128
+ lanes: laneElements
1129
+ })
1130
+ ];
1058
1131
  }
1059
1132
  return process;
1060
1133
  }
@@ -1162,6 +1235,7 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
1162
1235
  const referencedDataStoreIds = collectReferencedDataStoreIds(allNodes);
1163
1236
  const childNodes = allNodes.filter((node) => node.parentId === parent.id).filter((node) => !(node.data.elementType === "DataStore" && referencedDataStoreIds.has(node.id)));
1164
1237
  const childNodeIds = new Set(childNodes.map((node) => node.id));
1238
+ const childNodeById = new Map(childNodes.map((node) => [node.id, node]));
1165
1239
  const flowElements = [];
1166
1240
  const artifacts = [];
1167
1241
  const presentDataObjectIds = new Set(
@@ -1190,7 +1264,7 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
1190
1264
  }
1191
1265
  for (const edge of allEdges) {
1192
1266
  if (!childNodeIds.has(edge.source) || !childNodeIds.has(edge.target)) continue;
1193
- const element = buildEdgeElement(moddle, edge);
1267
+ const element = buildEdgeElement(moddle, edge, childNodeById);
1194
1268
  if (!element) continue;
1195
1269
  if (edge.data?.edgeType === "association") {
1196
1270
  artifacts.push(element);
@@ -1200,16 +1274,23 @@ function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
1200
1274
  }
1201
1275
  return { flowElements, artifacts };
1202
1276
  }
1203
- function buildEdgeElement(moddle, edge) {
1277
+ function buildEdgeElement(moddle, edge, nodeById) {
1204
1278
  if (!edge.data) return null;
1205
- const moddleType = EDGE_TYPE_TO_MODDLE[edge.data.edgeType];
1279
+ const sourceNode = nodeById.get(edge.source);
1280
+ const dataAssociationIsInput = edge.data.edgeType === "dataAssociation" && DATA_ASSOCIATION_SOURCE_TYPES.has(sourceNode?.data.elementType ?? "");
1281
+ const moddleType = edge.data.edgeType === "dataAssociation" ? dataAssociationIsInput ? "bpmn:DataInputAssociation" : "bpmn:DataOutputAssociation" : EDGE_TYPE_TO_MODDLE[edge.data.edgeType];
1206
1282
  if (!moddleType) return null;
1207
1283
  const attrs = {
1208
1284
  id: edge.id,
1209
- name: edge.data.label ?? "",
1210
- sourceRef: { id: edge.source },
1211
- targetRef: { id: edge.target }
1285
+ name: edge.data.label ?? ""
1212
1286
  };
1287
+ if (edge.data.edgeType === "dataAssociation") {
1288
+ attrs.sourceRef = [{ id: edge.source }];
1289
+ attrs.targetRef = { id: edge.target };
1290
+ } else {
1291
+ attrs.sourceRef = { id: edge.source };
1292
+ attrs.targetRef = { id: edge.target };
1293
+ }
1213
1294
  if (edge.data.documentation) {
1214
1295
  attrs.documentation = [
1215
1296
  moddle.create("bpmn:Documentation", { text: edge.data.documentation })
@@ -1262,7 +1343,7 @@ function buildBpmnDI(moddle, definitions, nodes, edges) {
1262
1343
  );
1263
1344
  }
1264
1345
  const rootEls = definitions.rootElements;
1265
- const planeElement = rootEls?.[0];
1346
+ const planeElement = rootEls?.find((element) => element.$type === "bpmn:Collaboration") ?? rootEls?.find((element) => element.$type === "bpmn:Process") ?? rootEls?.[0];
1266
1347
  const plane = moddle.create("bpmndi:BPMNPlane", {
1267
1348
  id: "BPMNPlane_1",
1268
1349
  bpmnElement: planeElement ?? { id: "unknown" },
@@ -1444,5 +1525,5 @@ async function serializeBpmnXml(nodes, edges, opts = {}) {
1444
1525
  }
1445
1526
 
1446
1527
  export { parseBpmnXml, serializeBpmnXml };
1447
- //# sourceMappingURL=chunk-334WN4JZ.js.map
1448
- //# sourceMappingURL=chunk-334WN4JZ.js.map
1528
+ //# sourceMappingURL=chunk-NYIYQUGX.js.map
1529
+ //# sourceMappingURL=chunk-NYIYQUGX.js.map