@aranzatech/diagrams-bpmn 0.2.5 → 0.2.6

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 (43) hide show
  1. package/dist/{catalog-D2AcvrDO.d.cts → catalog-CZsXqhL9.d.cts} +1 -1
  2. package/dist/{catalog-CQtKEV7q.d.ts → catalog-Clz8sN9x.d.ts} +1 -1
  3. package/dist/{chunk-ASZ3TFNQ.js → chunk-L64NM77A.js} +65 -6
  4. package/dist/chunk-L64NM77A.js.map +1 -0
  5. package/dist/{chunk-QOGZITWB.js → chunk-M46UDUN3.js} +2 -2
  6. package/dist/{chunk-QOGZITWB.js.map → chunk-M46UDUN3.js.map} +1 -1
  7. package/dist/{chunk-7MKU37XQ.js → chunk-XTUYPA3E.js} +191 -15
  8. package/dist/chunk-XTUYPA3E.js.map +1 -0
  9. package/dist/elements/index.d.cts +3 -3
  10. package/dist/elements/index.d.ts +3 -3
  11. package/dist/index.cjs +252 -227
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +5 -5
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.js +3 -4
  16. package/dist/modeling/index.cjs +197 -10
  17. package/dist/modeling/index.cjs.map +1 -1
  18. package/dist/modeling/index.d.cts +103 -7
  19. package/dist/modeling/index.d.ts +103 -7
  20. package/dist/modeling/index.js +1 -1
  21. package/dist/simulation/index.cjs.map +1 -1
  22. package/dist/simulation/index.d.cts +36 -0
  23. package/dist/simulation/index.d.ts +36 -0
  24. package/dist/simulation/index.js +1 -1
  25. package/dist/{types-rWbKYrHH.d.cts → types-BPqNeIU-.d.cts} +2 -0
  26. package/dist/{types-rWbKYrHH.d.ts → types-BPqNeIU-.d.ts} +2 -0
  27. package/dist/{types-CIBColRi.d.ts → types-D0Flgue2.d.ts} +1 -1
  28. package/dist/{types-fDlPLIHd.d.cts → types-exnfq24-.d.cts} +1 -1
  29. package/dist/validation/index.cjs.map +1 -1
  30. package/dist/validation/index.d.cts +7 -2
  31. package/dist/validation/index.d.ts +7 -2
  32. package/dist/validation/index.js +224 -3
  33. package/dist/validation/index.js.map +1 -1
  34. package/dist/xml/index.cjs +62 -6
  35. package/dist/xml/index.cjs.map +1 -1
  36. package/dist/xml/index.d.cts +18 -3
  37. package/dist/xml/index.d.ts +18 -3
  38. package/dist/xml/index.js +1 -1
  39. package/package.json +2 -2
  40. package/dist/chunk-7MKU37XQ.js.map +0 -1
  41. package/dist/chunk-ASZ3TFNQ.js.map +0 -1
  42. package/dist/chunk-ZFGQVLHB.js +0 -226
  43. package/dist/chunk-ZFGQVLHB.js.map +0 -1
@@ -1,226 +0,0 @@
1
- import { isDataType, isGatewayType, isEventType } from './chunk-RLAJNRF2.js';
2
- import { BPMN_ELEMENT_CATALOG } from './chunk-L5Z22RLX.js';
3
-
4
- // src/validation/index.ts
5
- function isFlowNode(type) {
6
- return isEventType(type) || isGatewayType(type) || type.includes("Task") || type === "CallActivity" || type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess" || type === "ChoreographyTask" || type === "SubChoreography" || type === "CallChoreography";
7
- }
8
- function isProcessNode(type) {
9
- return isFlowNode(type) && type !== "BoundaryEvent";
10
- }
11
- function isSubProcess(type) {
12
- return type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess";
13
- }
14
- function isCatchTarget(type) {
15
- return type === "IntermediateCatchEvent" || type === "ReceiveTask";
16
- }
17
- function poolAncestor(node, nodeById) {
18
- let current = node;
19
- const visited = /* @__PURE__ */ new Set();
20
- while (current?.parentId && !visited.has(current.id)) {
21
- visited.add(current.id);
22
- const parent = nodeById.get(current.parentId);
23
- if (parent?.data.elementType === "Pool") return parent.id;
24
- current = parent;
25
- }
26
- return void 0;
27
- }
28
- function countSequenceEdges(edges, nodeId, direction) {
29
- return edges.filter((edge) => {
30
- if (edge.data?.edgeType !== "sequenceFlow") return false;
31
- return direction === "in" ? edge.target === nodeId : edge.source === nodeId;
32
- }).length;
33
- }
34
- function sequenceEdges(edges) {
35
- return edges.filter((edge) => (edge.data?.edgeType ?? edge.type) === "sequenceFlow");
36
- }
37
- function sequenceOut(edges, nodeId) {
38
- return sequenceEdges(edges).filter((edge) => edge.source === nodeId);
39
- }
40
- function sequenceIn(edges, nodeId) {
41
- return sequenceEdges(edges).filter((edge) => edge.target === nodeId);
42
- }
43
- function issue(code, severity, message, elementId, relatedElementIds) {
44
- return {
45
- id: `${code}:${elementId ?? relatedElementIds?.join(",") ?? "diagram"}`,
46
- code,
47
- severity,
48
- message,
49
- ...elementId ? { elementId } : {},
50
- ...relatedElementIds ? { relatedElementIds } : {}
51
- };
52
- }
53
- function validateBpmnDiagram(nodes, edges, options = {}) {
54
- const opts = {
55
- requireStartEvent: true,
56
- requireEndEvent: true,
57
- strictNames: false,
58
- ...options
59
- };
60
- const issues = [];
61
- const nodeById = new Map(nodes.map((node) => [node.id, node]));
62
- const seqEdges = sequenceEdges(edges);
63
- const processNodes = nodes.filter((node) => isProcessNode(node.data.elementType));
64
- if (opts.requireStartEvent && !processNodes.some((node) => node.data.elementType === "StartEvent")) {
65
- issues.push(issue("bpmn/start-event-required", "error", "The diagram must contain at least one start event."));
66
- }
67
- if (opts.requireEndEvent && !processNodes.some((node) => node.data.elementType === "EndEvent")) {
68
- issues.push(issue("bpmn/end-event-required", "error", "The diagram must contain at least one end event."));
69
- }
70
- for (const edge of edges) {
71
- const edgeType = edge.data?.edgeType ?? edge.type;
72
- const source = nodeById.get(edge.source);
73
- const target = nodeById.get(edge.target);
74
- if (!source || !target) {
75
- issues.push(issue(
76
- "bpmn/no-orphan-edges",
77
- "error",
78
- `Edge "${edge.id}" references a missing ${!source ? "source" : "target"} node.`,
79
- edge.id,
80
- [edge.source, edge.target]
81
- ));
82
- continue;
83
- }
84
- if (edge.source === edge.target) {
85
- issues.push(issue("bpmn/no-self-loop", "error", "BPMN edges cannot connect an element to itself.", edge.id, [edge.source]));
86
- }
87
- if (edgeType === "sequenceFlow") {
88
- if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType) || isDataType(source.data.elementType) || isDataType(target.data.elementType)) {
89
- issues.push(issue("bpmn/sequence-flow-valid-endpoints", "error", "Sequence flows must connect BPMN flow nodes.", edge.id, [source.id, target.id]));
90
- }
91
- const sourcePool = poolAncestor(source, nodeById);
92
- const targetPool = poolAncestor(target, nodeById);
93
- if (sourcePool && targetPool && sourcePool !== targetPool) {
94
- issues.push(issue("bpmn/sequence-flow-no-cross-pool", "error", "Sequence flows cannot cross pools. Use message flow between participants.", edge.id, [source.id, target.id]));
95
- }
96
- }
97
- if (edgeType === "messageFlow") {
98
- const sourcePool = poolAncestor(source, nodeById);
99
- const targetPool = poolAncestor(target, nodeById);
100
- if (!sourcePool || !targetPool || sourcePool === targetPool) {
101
- issues.push(issue("bpmn/message-flow-valid-endpoints", "error", "Message flows must connect flow nodes in different pools.", edge.id, [source.id, target.id]));
102
- }
103
- if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType)) {
104
- issues.push(issue("bpmn/message-flow-valid-endpoints", "error", "Message flows must connect BPMN flow nodes, not containers.", edge.id, [source.id, target.id]));
105
- }
106
- }
107
- if (edgeType === "dataAssociation") {
108
- const hasDataEndpoint = isDataType(source.data.elementType) || isDataType(target.data.elementType);
109
- const hasFlowEndpoint = isFlowNode(source.data.elementType) || isFlowNode(target.data.elementType);
110
- if (!hasDataEndpoint || !hasFlowEndpoint) {
111
- issues.push(issue("bpmn/data-association-valid-endpoints", "error", "Data associations must connect data elements with flow nodes.", edge.id, [source.id, target.id]));
112
- }
113
- }
114
- }
115
- const duplicateSequenceKeys = /* @__PURE__ */ new Set();
116
- const reportedDuplicateKeys = /* @__PURE__ */ new Set();
117
- for (const edge of seqEdges) {
118
- const key = `${edge.source}->${edge.target}`;
119
- if (duplicateSequenceKeys.has(key) && !reportedDuplicateKeys.has(key)) {
120
- reportedDuplicateKeys.add(key);
121
- issues.push(issue("bpmn/no-duplicate-sequence-flow", "error", "Only one sequence flow is allowed between the same source and target.", edge.id, [edge.source, edge.target]));
122
- }
123
- duplicateSequenceKeys.add(key);
124
- }
125
- for (const node of nodes) {
126
- const type = node.data.elementType;
127
- const incoming = countSequenceEdges(edges, node.id, "in");
128
- const outgoing = countSequenceEdges(edges, node.id, "out");
129
- const meta = BPMN_ELEMENT_CATALOG[type];
130
- if (type === "StartEvent" && incoming > 0) {
131
- issues.push(issue("bpmn/start-event-no-incoming", "error", "Start events cannot have incoming sequence flows.", node.id));
132
- }
133
- if (type === "EndEvent") {
134
- if (outgoing > 0) issues.push(issue("bpmn/no-outgoing-from-end-event", "error", "End events cannot have outgoing sequence flows.", node.id));
135
- if (incoming === 0) issues.push(issue("bpmn/end-event-has-incoming", "error", "End events should have at least one incoming sequence flow.", node.id));
136
- }
137
- if ((type === "IntermediateCatchEvent" || type === "IntermediateThrowEvent") && (incoming === 0 || outgoing === 0)) {
138
- issues.push(issue("bpmn/intermediate-event-both-flows", "error", "Intermediate events should have both incoming and outgoing sequence flows.", node.id));
139
- }
140
- if (type === "BoundaryEvent") {
141
- const hostId = node.data.attachedToRef ?? node.parentId;
142
- const host = hostId ? nodeById.get(hostId) : void 0;
143
- if (!host || !BPMN_ELEMENT_CATALOG[host.data.elementType]?.acceptsBoundaryEvents) {
144
- issues.push(issue("bpmn/boundary-event-attached", "error", "Boundary events must be attached to an activity or subprocess.", node.id, hostId ? [hostId] : void 0));
145
- }
146
- if (sequenceIn(edges, node.id).length > 0) {
147
- issues.push(issue("bpmn/boundary-no-incoming", "error", "Boundary events cannot have incoming sequence flows.", node.id));
148
- }
149
- if (sequenceOut(edges, node.id).length === 0) {
150
- issues.push(issue("bpmn/boundary-has-outgoing", "warning", "Boundary events should define an outgoing exception path.", node.id));
151
- }
152
- }
153
- if (isGatewayType(type)) {
154
- if (incoming === 0) issues.push(issue("bpmn/gateway-has-incoming", "error", "Gateways should have at least one incoming sequence flow.", node.id));
155
- if (outgoing === 0) issues.push(issue("bpmn/gateway-has-outgoing", "error", "Gateways should have at least one outgoing sequence flow.", node.id));
156
- }
157
- if (type === "ExclusiveGateway" || type === "InclusiveGateway" || type === "ComplexGateway") {
158
- const outgoingEdges = sequenceOut(edges, node.id);
159
- const defaults = outgoingEdges.filter((edge) => edge.data?.isDefault);
160
- if (defaults.length > 1) {
161
- issues.push(issue("bpmn/gateway-single-default", "error", "Gateways can have at most one default sequence flow.", node.id, defaults.map((edge) => edge.id)));
162
- }
163
- if (outgoingEdges.length >= 2) {
164
- for (const edge of outgoingEdges) {
165
- if (!edge.data?.isDefault && !edge.data?.conditionExpression) {
166
- issues.push(issue("bpmn/gateway-condition", "error", "Conditional gateway branches should have a condition or be marked as default.", edge.id, [node.id, edge.target]));
167
- }
168
- }
169
- }
170
- }
171
- if (type === "EventBasedGateway") {
172
- const outgoingEdges = edges.filter((edge) => edge.data?.edgeType === "sequenceFlow" && edge.source === node.id);
173
- if (outgoingEdges.length < 2) {
174
- issues.push(issue("bpmn/event-based-gateway-min-outgoing", "error", "Event-based gateways should have at least two outgoing sequence flows.", node.id));
175
- }
176
- for (const edge of outgoingEdges) {
177
- const target = nodeById.get(edge.target);
178
- if (target && !isCatchTarget(target.data.elementType)) {
179
- issues.push(issue("bpmn/event-based-gateway-valid-targets", "error", "Event-based gateways must target catch events or receive tasks.", edge.id, [node.id, target.id]));
180
- }
181
- }
182
- }
183
- if (meta.maxIncoming !== void 0 && incoming > meta.maxIncoming) {
184
- issues.push(issue("bpmn/max-incoming", "error", `${type} cannot have more than ${meta.maxIncoming} incoming sequence flow(s).`, node.id));
185
- }
186
- if (meta.maxOutgoing !== void 0 && outgoing > meta.maxOutgoing) {
187
- issues.push(issue("bpmn/max-outgoing", "error", `${type} cannot have more than ${meta.maxOutgoing} outgoing sequence flow(s).`, node.id));
188
- }
189
- if (opts.strictNames && (type.includes("Task") || isGatewayType(type)) && !node.data.label) {
190
- issues.push(issue("bpmn/name-required", "warning", `${type} should have a label.`, node.id));
191
- }
192
- if (isSubProcess(type)) {
193
- const childNodes = nodes.filter((child) => child.parentId === node.id);
194
- if (childNodes.length > 0) {
195
- if (!childNodes.some((child) => child.data.elementType === "StartEvent")) {
196
- issues.push(issue("bpmn/subprocess-has-start-end", "error", "Expanded subprocesses should contain a start event.", node.id));
197
- }
198
- if (!childNodes.some((child) => child.data.elementType === "EndEvent")) {
199
- issues.push(issue("bpmn/subprocess-has-start-end", "error", "Expanded subprocesses should contain an end event.", node.id));
200
- }
201
- }
202
- if (type === "EventSubProcess") {
203
- const starts = childNodes.filter((child) => child.data.elementType === "StartEvent");
204
- for (const start of starts) {
205
- if (!start.data.trigger || start.data.trigger === "none") {
206
- issues.push(issue("bpmn/event-subprocess-triggered-start", "error", "Event subprocess start events must define an event trigger.", start.id, [node.id]));
207
- }
208
- }
209
- }
210
- }
211
- if (type === "Lane") {
212
- const parent = node.parentId ? nodeById.get(node.parentId) : void 0;
213
- if (parent?.data.elementType !== "Pool") {
214
- issues.push(issue("bpmn/lane-parent-pool", "error", "Lanes must be contained by a pool.", node.id));
215
- }
216
- }
217
- }
218
- return {
219
- valid: issues.every((item) => item.severity !== "error"),
220
- issues
221
- };
222
- }
223
-
224
- export { validateBpmnDiagram };
225
- //# sourceMappingURL=chunk-ZFGQVLHB.js.map
226
- //# sourceMappingURL=chunk-ZFGQVLHB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/validation/index.ts"],"names":[],"mappings":";;;;AA+BA,SAAS,WAAW,IAAA,EAAgC;AAClD,EAAA,OACE,WAAA,CAAY,IAAI,CAAA,IAChB,aAAA,CAAc,IAAI,KAClB,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,IACpB,IAAA,KAAS,cAAA,IACT,SAAS,YAAA,IACT,IAAA,KAAS,aAAA,IACT,IAAA,KAAS,iBAAA,IACT,IAAA,KAAS,qBACT,IAAA,KAAS,kBAAA,IACT,IAAA,KAAS,iBAAA,IACT,IAAA,KAAS,kBAAA;AAEb;AAEA,SAAS,cAAc,IAAA,EAAgC;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AM,+BAAA,EAAiC,SAAS,oDAAA,EAAsD,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,QAC5H;AAAA,MACF;AACA,MAAA,IAAI,SAAS,iBAAA,EAAmB;AAC9B,QAAA,MAAM,MAAA,GAAS,WAAW,MAAA,CAAO,CAAC,UAAU,KAAA,CAAM,IAAA,CAAK,gBAAgB,YAAY,CAAA;AACnF,QAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,UAAA,IAAI,CAAC,KAAA,CAAM,IAAA,CAAK,WAAW,KAAA,CAAM,IAAA,CAAK,YAAY,MAAA,EAAQ;AACxD,YAAA,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,uCAAA,EAAyC,OAAA,EAAS,6DAAA,EAA+D,KAAA,CAAM,EAAA,EAAI,CAAC,IAAA,CAAK,EAAE,CAAC,CAAC,CAAA;AAAA,UACzJ;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,IAAA,IAAI,SAAS,MAAA,EAAQ;AACnB,MAAA,MAAM,SAAS,IAAA,CAAK,QAAA,GAAW,SAAS,GAAA,CAAI,IAAA,CAAK,QAAQ,CAAA,GAAI,MAAA;AAC7D,MAAA,IAAI,MAAA,EAAQ,IAAA,CAAK,WAAA,KAAgB,MAAA,EAAQ;AACvC,QAAA,MAAA,CAAO,KAAK,KAAA,CAAM,uBAAA,EAAyB,SAAS,oCAAA,EAAsC,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,MACpG;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,OAAO,MAAA,CAAO,KAAA,CAAM,CAAC,IAAA,KAAS,IAAA,CAAK,aAAa,OAAO,CAAA;AAAA,IACvD;AAAA,GACF;AACF","file":"chunk-ZFGQVLHB.js","sourcesContent":["import { BPMN_ELEMENT_CATALOG } from \"../elements/catalog\";\nimport {\n isDataType,\n isEventType,\n isGatewayType,\n} from \"../elements/guards\";\nimport type { BpmnElementType } from \"../elements/types\";\nimport type { BpmnRFEdge, BpmnRFNode } from \"../xml/types\";\n\nexport type BpmnValidationSeverity = \"error\" | \"warning\" | \"info\";\n\nexport interface BpmnValidationIssue {\n id: string;\n severity: BpmnValidationSeverity;\n code: string;\n message: string;\n elementId?: string;\n relatedElementIds?: string[];\n}\n\nexport interface BpmnValidationResult {\n valid: boolean;\n issues: BpmnValidationIssue[];\n}\n\nexport interface BpmnValidationOptions {\n requireStartEvent?: boolean;\n requireEndEvent?: boolean;\n strictNames?: boolean;\n}\n\nfunction isFlowNode(type: BpmnElementType): boolean {\n return (\n isEventType(type) ||\n isGatewayType(type) ||\n type.includes(\"Task\") ||\n type === \"CallActivity\" ||\n type === \"SubProcess\" ||\n type === \"Transaction\" ||\n type === \"EventSubProcess\" ||\n type === \"AdHocSubProcess\" ||\n type === \"ChoreographyTask\" ||\n type === \"SubChoreography\" ||\n type === \"CallChoreography\"\n );\n}\n\nfunction isProcessNode(type: BpmnElementType): boolean {\n return isFlowNode(type) && type !== \"BoundaryEvent\";\n}\n\nfunction isSubProcess(type: BpmnElementType): boolean {\n return (\n type === \"SubProcess\" ||\n type === \"Transaction\" ||\n type === \"EventSubProcess\" ||\n type === \"AdHocSubProcess\"\n );\n}\n\nfunction isCatchTarget(type: BpmnElementType): boolean {\n return type === \"IntermediateCatchEvent\" || type === \"ReceiveTask\";\n}\n\nfunction poolAncestor(\n node: BpmnRFNode | undefined,\n nodeById: Map<string, BpmnRFNode>,\n): string | undefined {\n let current = node;\n const visited = new Set<string>();\n while (current?.parentId && !visited.has(current.id)) {\n visited.add(current.id);\n const parent = nodeById.get(current.parentId);\n if (parent?.data.elementType === \"Pool\") return parent.id;\n current = parent;\n }\n return undefined;\n}\n\nfunction countSequenceEdges(edges: BpmnRFEdge[], nodeId: string, direction: \"in\" | \"out\"): number {\n return edges.filter((edge) => {\n if (edge.data?.edgeType !== \"sequenceFlow\") return false;\n return direction === \"in\" ? edge.target === nodeId : edge.source === nodeId;\n }).length;\n}\n\nfunction sequenceEdges(edges: BpmnRFEdge[]): BpmnRFEdge[] {\n return edges.filter((edge) => (edge.data?.edgeType ?? edge.type) === \"sequenceFlow\");\n}\n\nfunction sequenceOut(edges: BpmnRFEdge[], nodeId: string): BpmnRFEdge[] {\n return sequenceEdges(edges).filter((edge) => edge.source === nodeId);\n}\n\nfunction sequenceIn(edges: BpmnRFEdge[], nodeId: string): BpmnRFEdge[] {\n return sequenceEdges(edges).filter((edge) => edge.target === nodeId);\n}\n\nfunction issue(\n code: string,\n severity: BpmnValidationSeverity,\n message: string,\n elementId?: string,\n relatedElementIds?: string[],\n): BpmnValidationIssue {\n return {\n id: `${code}:${elementId ?? relatedElementIds?.join(\",\") ?? \"diagram\"}`,\n code,\n severity,\n message,\n ...(elementId ? { elementId } : {}),\n ...(relatedElementIds ? { relatedElementIds } : {}),\n };\n}\n\nexport function validateBpmnDiagram(\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n options: BpmnValidationOptions = {},\n): BpmnValidationResult {\n const opts = {\n requireStartEvent: true,\n requireEndEvent: true,\n strictNames: false,\n ...options,\n };\n const issues: BpmnValidationIssue[] = [];\n const nodeById = new Map(nodes.map((node) => [node.id, node]));\n const seqEdges = sequenceEdges(edges);\n\n const processNodes = nodes.filter((node) => isProcessNode(node.data.elementType));\n if (opts.requireStartEvent && !processNodes.some((node) => node.data.elementType === \"StartEvent\")) {\n issues.push(issue(\"bpmn/start-event-required\", \"error\", \"The diagram must contain at least one start event.\"));\n }\n if (opts.requireEndEvent && !processNodes.some((node) => node.data.elementType === \"EndEvent\")) {\n issues.push(issue(\"bpmn/end-event-required\", \"error\", \"The diagram must contain at least one end event.\"));\n }\n\n for (const edge of edges) {\n const edgeType = edge.data?.edgeType ?? edge.type;\n const source = nodeById.get(edge.source);\n const target = nodeById.get(edge.target);\n\n if (!source || !target) {\n issues.push(issue(\n \"bpmn/no-orphan-edges\",\n \"error\",\n `Edge \"${edge.id}\" references a missing ${!source ? \"source\" : \"target\"} node.`,\n edge.id,\n [edge.source, edge.target],\n ));\n continue;\n }\n\n if (edge.source === edge.target) {\n issues.push(issue(\"bpmn/no-self-loop\", \"error\", \"BPMN edges cannot connect an element to itself.\", edge.id, [edge.source]));\n }\n\n if (edgeType === \"sequenceFlow\") {\n if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType) || isDataType(source.data.elementType) || isDataType(target.data.elementType)) {\n issues.push(issue(\"bpmn/sequence-flow-valid-endpoints\", \"error\", \"Sequence flows must connect BPMN flow nodes.\", edge.id, [source.id, target.id]));\n }\n const sourcePool = poolAncestor(source, nodeById);\n const targetPool = poolAncestor(target, nodeById);\n if (sourcePool && targetPool && sourcePool !== targetPool) {\n issues.push(issue(\"bpmn/sequence-flow-no-cross-pool\", \"error\", \"Sequence flows cannot cross pools. Use message flow between participants.\", edge.id, [source.id, target.id]));\n }\n }\n\n if (edgeType === \"messageFlow\") {\n const sourcePool = poolAncestor(source, nodeById);\n const targetPool = poolAncestor(target, nodeById);\n if (!sourcePool || !targetPool || sourcePool === targetPool) {\n issues.push(issue(\"bpmn/message-flow-valid-endpoints\", \"error\", \"Message flows must connect flow nodes in different pools.\", edge.id, [source.id, target.id]));\n }\n if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType)) {\n issues.push(issue(\"bpmn/message-flow-valid-endpoints\", \"error\", \"Message flows must connect BPMN flow nodes, not containers.\", edge.id, [source.id, target.id]));\n }\n }\n\n if (edgeType === \"dataAssociation\") {\n const hasDataEndpoint = isDataType(source.data.elementType) || isDataType(target.data.elementType);\n const hasFlowEndpoint = isFlowNode(source.data.elementType) || isFlowNode(target.data.elementType);\n if (!hasDataEndpoint || !hasFlowEndpoint) {\n issues.push(issue(\"bpmn/data-association-valid-endpoints\", \"error\", \"Data associations must connect data elements with flow nodes.\", edge.id, [source.id, target.id]));\n }\n }\n }\n\n const duplicateSequenceKeys = new Set<string>();\n const reportedDuplicateKeys = new Set<string>();\n for (const edge of seqEdges) {\n const key = `${edge.source}->${edge.target}`;\n if (duplicateSequenceKeys.has(key) && !reportedDuplicateKeys.has(key)) {\n reportedDuplicateKeys.add(key);\n issues.push(issue(\"bpmn/no-duplicate-sequence-flow\", \"error\", \"Only one sequence flow is allowed between the same source and target.\", edge.id, [edge.source, edge.target]));\n }\n duplicateSequenceKeys.add(key);\n }\n\n for (const node of nodes) {\n const type = node.data.elementType;\n const incoming = countSequenceEdges(edges, node.id, \"in\");\n const outgoing = countSequenceEdges(edges, node.id, \"out\");\n const meta = BPMN_ELEMENT_CATALOG[type];\n\n if (type === \"StartEvent\" && incoming > 0) {\n issues.push(issue(\"bpmn/start-event-no-incoming\", \"error\", \"Start events cannot have incoming sequence flows.\", node.id));\n }\n if (type === \"EndEvent\") {\n if (outgoing > 0) issues.push(issue(\"bpmn/no-outgoing-from-end-event\", \"error\", \"End events cannot have outgoing sequence flows.\", node.id));\n if (incoming === 0) issues.push(issue(\"bpmn/end-event-has-incoming\", \"error\", \"End events should have at least one incoming sequence flow.\", node.id));\n }\n if ((type === \"IntermediateCatchEvent\" || type === \"IntermediateThrowEvent\") && (incoming === 0 || outgoing === 0)) {\n issues.push(issue(\"bpmn/intermediate-event-both-flows\", \"error\", \"Intermediate events should have both incoming and outgoing sequence flows.\", node.id));\n }\n if (type === \"BoundaryEvent\") {\n const hostId = node.data.attachedToRef ?? node.parentId;\n const host = hostId ? nodeById.get(hostId) : undefined;\n if (!host || !BPMN_ELEMENT_CATALOG[host.data.elementType]?.acceptsBoundaryEvents) {\n issues.push(issue(\"bpmn/boundary-event-attached\", \"error\", \"Boundary events must be attached to an activity or subprocess.\", node.id, hostId ? [hostId] : undefined));\n }\n if (sequenceIn(edges, node.id).length > 0) {\n issues.push(issue(\"bpmn/boundary-no-incoming\", \"error\", \"Boundary events cannot have incoming sequence flows.\", node.id));\n }\n if (sequenceOut(edges, node.id).length === 0) {\n issues.push(issue(\"bpmn/boundary-has-outgoing\", \"warning\", \"Boundary events should define an outgoing exception path.\", node.id));\n }\n }\n if (isGatewayType(type)) {\n if (incoming === 0) issues.push(issue(\"bpmn/gateway-has-incoming\", \"error\", \"Gateways should have at least one incoming sequence flow.\", node.id));\n if (outgoing === 0) issues.push(issue(\"bpmn/gateway-has-outgoing\", \"error\", \"Gateways should have at least one outgoing sequence flow.\", node.id));\n }\n if (type === \"ExclusiveGateway\" || type === \"InclusiveGateway\" || type === \"ComplexGateway\") {\n const outgoingEdges = sequenceOut(edges, node.id);\n const defaults = outgoingEdges.filter((edge) => edge.data?.isDefault);\n if (defaults.length > 1) {\n issues.push(issue(\"bpmn/gateway-single-default\", \"error\", \"Gateways can have at most one default sequence flow.\", node.id, defaults.map((edge) => edge.id)));\n }\n if (outgoingEdges.length >= 2) {\n for (const edge of outgoingEdges) {\n if (!edge.data?.isDefault && !edge.data?.conditionExpression) {\n issues.push(issue(\"bpmn/gateway-condition\", \"error\", \"Conditional gateway branches should have a condition or be marked as default.\", edge.id, [node.id, edge.target]));\n }\n }\n }\n }\n if (type === \"EventBasedGateway\") {\n const outgoingEdges = edges.filter((edge) => edge.data?.edgeType === \"sequenceFlow\" && edge.source === node.id);\n if (outgoingEdges.length < 2) {\n issues.push(issue(\"bpmn/event-based-gateway-min-outgoing\", \"error\", \"Event-based gateways should have at least two outgoing sequence flows.\", node.id));\n }\n for (const edge of outgoingEdges) {\n const target = nodeById.get(edge.target);\n if (target && !isCatchTarget(target.data.elementType)) {\n issues.push(issue(\"bpmn/event-based-gateway-valid-targets\", \"error\", \"Event-based gateways must target catch events or receive tasks.\", edge.id, [node.id, target.id]));\n }\n }\n }\n if (meta.maxIncoming !== undefined && incoming > meta.maxIncoming) {\n issues.push(issue(\"bpmn/max-incoming\", \"error\", `${type} cannot have more than ${meta.maxIncoming} incoming sequence flow(s).`, node.id));\n }\n if (meta.maxOutgoing !== undefined && outgoing > meta.maxOutgoing) {\n issues.push(issue(\"bpmn/max-outgoing\", \"error\", `${type} cannot have more than ${meta.maxOutgoing} outgoing sequence flow(s).`, node.id));\n }\n if (opts.strictNames && (type.includes(\"Task\") || isGatewayType(type)) && !node.data.label) {\n issues.push(issue(\"bpmn/name-required\", \"warning\", `${type} should have a label.`, node.id));\n }\n if (isSubProcess(type)) {\n const childNodes = nodes.filter((child) => child.parentId === node.id);\n if (childNodes.length > 0) {\n if (!childNodes.some((child) => child.data.elementType === \"StartEvent\")) {\n issues.push(issue(\"bpmn/subprocess-has-start-end\", \"error\", \"Expanded subprocesses should contain a start event.\", node.id));\n }\n if (!childNodes.some((child) => child.data.elementType === \"EndEvent\")) {\n issues.push(issue(\"bpmn/subprocess-has-start-end\", \"error\", \"Expanded subprocesses should contain an end event.\", node.id));\n }\n }\n if (type === \"EventSubProcess\") {\n const starts = childNodes.filter((child) => child.data.elementType === \"StartEvent\");\n for (const start of starts) {\n if (!start.data.trigger || start.data.trigger === \"none\") {\n issues.push(issue(\"bpmn/event-subprocess-triggered-start\", \"error\", \"Event subprocess start events must define an event trigger.\", start.id, [node.id]));\n }\n }\n }\n }\n if (type === \"Lane\") {\n const parent = node.parentId ? nodeById.get(node.parentId) : undefined;\n if (parent?.data.elementType !== \"Pool\") {\n issues.push(issue(\"bpmn/lane-parent-pool\", \"error\", \"Lanes must be contained by a pool.\", node.id));\n }\n }\n }\n\n return {\n valid: issues.every((item) => item.severity !== \"error\"),\n issues,\n };\n}\n"]}