@aranzatech/diagrams-bpmn 0.2.0 → 0.2.1

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 (63) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/catalog-OVnBDD8R.d.ts +9 -0
  3. package/dist/catalog-OWfI_yHU.d.cts +9 -0
  4. package/dist/{chunk-MF2WE3OM.js → chunk-33AR3PXF.js} +36 -8
  5. package/dist/chunk-33AR3PXF.js.map +1 -0
  6. package/dist/{chunk-3AFZDIMQ.js → chunk-ECTJRD7Z.js} +3 -3
  7. package/dist/{chunk-3AFZDIMQ.js.map → chunk-ECTJRD7Z.js.map} +1 -1
  8. package/dist/{chunk-S3GGEEA5.js → chunk-H3YMTGFG.js} +50 -32
  9. package/dist/chunk-H3YMTGFG.js.map +1 -0
  10. package/dist/chunk-KALSGH4D.js +36 -0
  11. package/dist/chunk-KALSGH4D.js.map +1 -0
  12. package/dist/{chunk-DNR5WBQH.js → chunk-L5Z22RLX.js} +81 -20
  13. package/dist/chunk-L5Z22RLX.js.map +1 -0
  14. package/dist/{chunk-5GRCJ5X6.js → chunk-RLAJNRF2.js} +3 -3
  15. package/dist/{chunk-5GRCJ5X6.js.map → chunk-RLAJNRF2.js.map} +1 -1
  16. package/dist/chunk-YQTIODXH.js +532 -0
  17. package/dist/chunk-YQTIODXH.js.map +1 -0
  18. package/dist/chunk-ZFGQVLHB.js +226 -0
  19. package/dist/chunk-ZFGQVLHB.js.map +1 -0
  20. package/dist/edges/index.cjs +1 -1
  21. package/dist/edges/index.cjs.map +1 -1
  22. package/dist/edges/index.js +2 -2
  23. package/dist/elements/index.cjs +81 -17
  24. package/dist/elements/index.cjs.map +1 -1
  25. package/dist/elements/index.d.cts +4 -6
  26. package/dist/elements/index.d.ts +4 -6
  27. package/dist/elements/index.js +2 -2
  28. package/dist/index.cjs +689 -75
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +6 -4
  31. package/dist/index.d.ts +6 -4
  32. package/dist/index.js +8 -7
  33. package/dist/modeling/index.cjs +383 -36
  34. package/dist/modeling/index.cjs.map +1 -1
  35. package/dist/modeling/index.d.cts +61 -3
  36. package/dist/modeling/index.d.ts +61 -3
  37. package/dist/modeling/index.js +3 -3
  38. package/dist/nodes/index.cjs +62 -32
  39. package/dist/nodes/index.cjs.map +1 -1
  40. package/dist/nodes/index.js +2 -2
  41. package/dist/{types-hj621ZRJ.d.ts → types-BxjCV2oX.d.ts} +1 -1
  42. package/dist/{types-BKA0GZz5.d.cts → types-DznxZxpV.d.cts} +11 -1
  43. package/dist/{types-BKA0GZz5.d.ts → types-DznxZxpV.d.ts} +11 -1
  44. package/dist/{types-CCkHqtC_.d.cts → types-vVi5T7qj.d.cts} +1 -1
  45. package/dist/validation/index.cjs +848 -0
  46. package/dist/validation/index.cjs.map +1 -0
  47. package/dist/validation/index.d.cts +25 -0
  48. package/dist/validation/index.d.ts +25 -0
  49. package/dist/validation/index.js +5 -0
  50. package/dist/validation/index.js.map +1 -0
  51. package/dist/xml/index.cjs +74 -22
  52. package/dist/xml/index.cjs.map +1 -1
  53. package/dist/xml/index.d.cts +2 -2
  54. package/dist/xml/index.d.ts +2 -2
  55. package/dist/xml/index.js +2 -2
  56. package/package.json +8 -3
  57. package/dist/chunk-23B2IGK5.js +0 -24
  58. package/dist/chunk-23B2IGK5.js.map +0 -1
  59. package/dist/chunk-DNR5WBQH.js.map +0 -1
  60. package/dist/chunk-G5S4ASP3.js +0 -277
  61. package/dist/chunk-G5S4ASP3.js.map +0 -1
  62. package/dist/chunk-MF2WE3OM.js.map +0 -1
  63. package/dist/chunk-S3GGEEA5.js.map +0 -1
@@ -0,0 +1,848 @@
1
+ 'use strict';
2
+
3
+ // src/elements/catalog.ts
4
+ var BPMN_ELEMENT_CATALOG = {
5
+ // ─── Events ──────────────────────────────────────────────────────────────────
6
+ StartEvent: {
7
+ label: "Start Event",
8
+ icon: "Circle",
9
+ category: "event",
10
+ defaultWidth: 36,
11
+ defaultHeight: 36,
12
+ handlePolicy: "source",
13
+ orientation: "free",
14
+ isContainer: false,
15
+ acceptsBoundaryEvents: false,
16
+ eventSemantics: "start",
17
+ canBeStart: true,
18
+ canBeEnd: false,
19
+ maxIncoming: 0,
20
+ maxOutgoing: 1
21
+ },
22
+ EndEvent: {
23
+ label: "End Event",
24
+ icon: "CircleDot",
25
+ category: "event",
26
+ defaultWidth: 36,
27
+ defaultHeight: 36,
28
+ handlePolicy: "target",
29
+ orientation: "free",
30
+ isContainer: false,
31
+ acceptsBoundaryEvents: false,
32
+ eventSemantics: "end",
33
+ canBeStart: false,
34
+ canBeEnd: true,
35
+ maxOutgoing: 0
36
+ },
37
+ IntermediateCatchEvent: {
38
+ label: "Intermediate Catch Event",
39
+ icon: "Clock3",
40
+ category: "event",
41
+ defaultWidth: 36,
42
+ defaultHeight: 36,
43
+ handlePolicy: "all",
44
+ orientation: "free",
45
+ isContainer: false,
46
+ acceptsBoundaryEvents: false,
47
+ eventSemantics: "intermediateCatch",
48
+ canBeStart: false,
49
+ canBeEnd: false
50
+ },
51
+ IntermediateThrowEvent: {
52
+ label: "Intermediate Throw Event",
53
+ icon: "Send",
54
+ category: "event",
55
+ defaultWidth: 36,
56
+ defaultHeight: 36,
57
+ handlePolicy: "all",
58
+ orientation: "free",
59
+ isContainer: false,
60
+ acceptsBoundaryEvents: false,
61
+ eventSemantics: "intermediateThrow",
62
+ canBeStart: false,
63
+ canBeEnd: false
64
+ },
65
+ BoundaryEvent: {
66
+ label: "Boundary Event",
67
+ icon: "AlarmClock",
68
+ category: "event",
69
+ defaultWidth: 36,
70
+ defaultHeight: 36,
71
+ handlePolicy: "source",
72
+ orientation: "free",
73
+ isContainer: false,
74
+ acceptsBoundaryEvents: false,
75
+ eventSemantics: "boundary",
76
+ canBeStart: false,
77
+ canBeEnd: false,
78
+ maxIncoming: 0
79
+ },
80
+ // ─── Tasks ───────────────────────────────────────────────────────────────────
81
+ Task: {
82
+ label: "Task",
83
+ icon: "CheckSquare",
84
+ category: "task",
85
+ defaultWidth: 120,
86
+ defaultHeight: 60,
87
+ handlePolicy: "all",
88
+ orientation: "free",
89
+ isContainer: false,
90
+ acceptsBoundaryEvents: true,
91
+ supportsMarkers: true,
92
+ canBeStart: false,
93
+ canBeEnd: false
94
+ },
95
+ UserTask: {
96
+ label: "User Task",
97
+ icon: "UserRound",
98
+ category: "task",
99
+ defaultWidth: 120,
100
+ defaultHeight: 60,
101
+ handlePolicy: "all",
102
+ orientation: "free",
103
+ isContainer: false,
104
+ acceptsBoundaryEvents: true,
105
+ supportsMarkers: true,
106
+ canBeStart: false,
107
+ canBeEnd: false
108
+ },
109
+ ServiceTask: {
110
+ label: "Service Task",
111
+ icon: "Cog",
112
+ category: "task",
113
+ defaultWidth: 120,
114
+ defaultHeight: 60,
115
+ handlePolicy: "all",
116
+ orientation: "free",
117
+ isContainer: false,
118
+ acceptsBoundaryEvents: true,
119
+ supportsMarkers: true,
120
+ canBeStart: false,
121
+ canBeEnd: false
122
+ },
123
+ ScriptTask: {
124
+ label: "Script Task",
125
+ icon: "FileCode",
126
+ category: "task",
127
+ defaultWidth: 120,
128
+ defaultHeight: 60,
129
+ handlePolicy: "all",
130
+ orientation: "free",
131
+ isContainer: false,
132
+ acceptsBoundaryEvents: true,
133
+ supportsMarkers: true,
134
+ canBeStart: false,
135
+ canBeEnd: false
136
+ },
137
+ ManualTask: {
138
+ label: "Manual Task",
139
+ icon: "Hand",
140
+ category: "task",
141
+ defaultWidth: 120,
142
+ defaultHeight: 60,
143
+ handlePolicy: "all",
144
+ orientation: "free",
145
+ isContainer: false,
146
+ acceptsBoundaryEvents: true,
147
+ supportsMarkers: true,
148
+ canBeStart: false,
149
+ canBeEnd: false
150
+ },
151
+ BusinessRuleTask: {
152
+ label: "Business Rule Task",
153
+ icon: "Table2",
154
+ category: "task",
155
+ defaultWidth: 120,
156
+ defaultHeight: 60,
157
+ handlePolicy: "all",
158
+ orientation: "free",
159
+ isContainer: false,
160
+ acceptsBoundaryEvents: true,
161
+ supportsMarkers: true,
162
+ canBeStart: false,
163
+ canBeEnd: false
164
+ },
165
+ ReceiveTask: {
166
+ label: "Receive Task",
167
+ icon: "Inbox",
168
+ category: "task",
169
+ defaultWidth: 120,
170
+ defaultHeight: 60,
171
+ handlePolicy: "all",
172
+ orientation: "free",
173
+ isContainer: false,
174
+ acceptsBoundaryEvents: true,
175
+ supportsMarkers: true,
176
+ canBeStart: false,
177
+ canBeEnd: false
178
+ },
179
+ SendTask: {
180
+ label: "Send Task",
181
+ icon: "Send",
182
+ category: "task",
183
+ defaultWidth: 120,
184
+ defaultHeight: 60,
185
+ handlePolicy: "all",
186
+ orientation: "free",
187
+ isContainer: false,
188
+ acceptsBoundaryEvents: true,
189
+ supportsMarkers: true,
190
+ canBeStart: false,
191
+ canBeEnd: false
192
+ },
193
+ CallActivity: {
194
+ label: "Call Activity",
195
+ icon: "ExternalLink",
196
+ category: "task",
197
+ defaultWidth: 120,
198
+ defaultHeight: 60,
199
+ handlePolicy: "all",
200
+ orientation: "free",
201
+ isContainer: false,
202
+ acceptsBoundaryEvents: true,
203
+ supportsMarkers: true,
204
+ canBeStart: false,
205
+ canBeEnd: false
206
+ },
207
+ // ─── Gateways ────────────────────────────────────────────────────────────────
208
+ ExclusiveGateway: {
209
+ label: "Exclusive Gateway",
210
+ icon: "X",
211
+ category: "gateway",
212
+ defaultWidth: 50,
213
+ defaultHeight: 50,
214
+ handlePolicy: "all",
215
+ orientation: "free",
216
+ isContainer: false,
217
+ acceptsBoundaryEvents: false,
218
+ canBeStart: false,
219
+ canBeEnd: false
220
+ },
221
+ InclusiveGateway: {
222
+ label: "Inclusive Gateway",
223
+ icon: "Circle",
224
+ category: "gateway",
225
+ defaultWidth: 50,
226
+ defaultHeight: 50,
227
+ handlePolicy: "all",
228
+ orientation: "free",
229
+ isContainer: false,
230
+ acceptsBoundaryEvents: false,
231
+ canBeStart: false,
232
+ canBeEnd: false
233
+ },
234
+ ParallelGateway: {
235
+ label: "Parallel Gateway",
236
+ icon: "Plus",
237
+ category: "gateway",
238
+ defaultWidth: 50,
239
+ defaultHeight: 50,
240
+ handlePolicy: "all",
241
+ orientation: "free",
242
+ isContainer: false,
243
+ acceptsBoundaryEvents: false,
244
+ canBeStart: false,
245
+ canBeEnd: false
246
+ },
247
+ EventBasedGateway: {
248
+ label: "Event-Based Gateway",
249
+ icon: "Radio",
250
+ category: "gateway",
251
+ defaultWidth: 50,
252
+ defaultHeight: 50,
253
+ handlePolicy: "all",
254
+ orientation: "free",
255
+ isContainer: false,
256
+ acceptsBoundaryEvents: false,
257
+ canBeStart: false,
258
+ canBeEnd: false,
259
+ maxIncoming: 1
260
+ },
261
+ ComplexGateway: {
262
+ label: "Complex Gateway",
263
+ icon: "Asterisk",
264
+ category: "gateway",
265
+ defaultWidth: 50,
266
+ defaultHeight: 50,
267
+ handlePolicy: "all",
268
+ orientation: "free",
269
+ isContainer: false,
270
+ acceptsBoundaryEvents: false,
271
+ canBeStart: false,
272
+ canBeEnd: false
273
+ },
274
+ // ─── Containers ───────────────────────────────────────────────────────────────
275
+ SubProcess: {
276
+ label: "Sub-Process",
277
+ icon: "PlusSquare",
278
+ category: "container",
279
+ defaultWidth: 350,
280
+ defaultHeight: 200,
281
+ handlePolicy: "all",
282
+ orientation: "horizontal",
283
+ isContainer: true,
284
+ acceptsBoundaryEvents: true,
285
+ supportsCollapse: true,
286
+ supportsMarkers: true,
287
+ canBeStart: false,
288
+ canBeEnd: false
289
+ },
290
+ Transaction: {
291
+ label: "Transaction",
292
+ icon: "Receipt",
293
+ category: "container",
294
+ defaultWidth: 350,
295
+ defaultHeight: 200,
296
+ handlePolicy: "all",
297
+ orientation: "horizontal",
298
+ isContainer: true,
299
+ acceptsBoundaryEvents: true,
300
+ supportsCollapse: true,
301
+ supportsMarkers: true,
302
+ canBeStart: false,
303
+ canBeEnd: false
304
+ },
305
+ EventSubProcess: {
306
+ label: "Event Sub-Process",
307
+ icon: "CircleDotDashed",
308
+ category: "container",
309
+ defaultWidth: 350,
310
+ defaultHeight: 200,
311
+ handlePolicy: "all",
312
+ orientation: "horizontal",
313
+ isContainer: true,
314
+ acceptsBoundaryEvents: false,
315
+ supportsCollapse: true,
316
+ supportsMarkers: true,
317
+ canBeStart: false,
318
+ canBeEnd: false
319
+ },
320
+ AdHocSubProcess: {
321
+ label: "Ad-Hoc Sub-Process",
322
+ icon: "Waves",
323
+ category: "container",
324
+ defaultWidth: 350,
325
+ defaultHeight: 200,
326
+ handlePolicy: "all",
327
+ orientation: "horizontal",
328
+ isContainer: true,
329
+ acceptsBoundaryEvents: true,
330
+ supportsCollapse: true,
331
+ supportsMarkers: true,
332
+ canBeStart: false,
333
+ canBeEnd: false
334
+ },
335
+ Pool: {
336
+ label: "Pool",
337
+ icon: "Rows3",
338
+ category: "container",
339
+ defaultWidth: 600,
340
+ defaultHeight: 200,
341
+ handlePolicy: "none",
342
+ orientation: "horizontal",
343
+ isContainer: true,
344
+ acceptsBoundaryEvents: false,
345
+ canBeStart: false,
346
+ canBeEnd: false,
347
+ maxIncoming: 0,
348
+ maxOutgoing: 0
349
+ },
350
+ Lane: {
351
+ label: "Lane",
352
+ icon: "PanelTop",
353
+ category: "container",
354
+ defaultWidth: 600,
355
+ defaultHeight: 120,
356
+ handlePolicy: "none",
357
+ orientation: "horizontal",
358
+ isContainer: true,
359
+ acceptsBoundaryEvents: false,
360
+ canBeStart: false,
361
+ canBeEnd: false,
362
+ maxIncoming: 0,
363
+ maxOutgoing: 0
364
+ },
365
+ // ─── Artifacts ────────────────────────────────────────────────────────────────
366
+ Annotation: {
367
+ label: "Text Annotation",
368
+ icon: "StickyNote",
369
+ category: "artifact",
370
+ defaultWidth: 100,
371
+ defaultHeight: 60,
372
+ handlePolicy: "none",
373
+ orientation: "free",
374
+ isContainer: false,
375
+ acceptsBoundaryEvents: false,
376
+ canBeStart: false,
377
+ canBeEnd: false,
378
+ maxIncoming: 0,
379
+ maxOutgoing: 0
380
+ },
381
+ Group: {
382
+ label: "Group",
383
+ icon: "Group",
384
+ category: "artifact",
385
+ defaultWidth: 300,
386
+ defaultHeight: 200,
387
+ handlePolicy: "none",
388
+ orientation: "free",
389
+ isContainer: false,
390
+ acceptsBoundaryEvents: false,
391
+ canBeStart: false,
392
+ canBeEnd: false,
393
+ maxIncoming: 0,
394
+ maxOutgoing: 0
395
+ },
396
+ // ─── Data (BPMN 2.0 §10.3) ───────────────────────────────────────────────────
397
+ DataObject: {
398
+ label: "Data Object",
399
+ icon: "File",
400
+ category: "data",
401
+ defaultWidth: 36,
402
+ defaultHeight: 50,
403
+ handlePolicy: "all",
404
+ orientation: "free",
405
+ isContainer: false,
406
+ acceptsBoundaryEvents: false,
407
+ canBeStart: false,
408
+ canBeEnd: false,
409
+ maxIncoming: 0,
410
+ maxOutgoing: 0
411
+ },
412
+ DataObjectReference: {
413
+ label: "Data Object Reference",
414
+ icon: "FileSymlink",
415
+ category: "data",
416
+ defaultWidth: 36,
417
+ defaultHeight: 50,
418
+ handlePolicy: "all",
419
+ orientation: "free",
420
+ isContainer: false,
421
+ acceptsBoundaryEvents: false,
422
+ canBeStart: false,
423
+ canBeEnd: false,
424
+ maxIncoming: 0,
425
+ maxOutgoing: 0
426
+ },
427
+ DataInput: {
428
+ label: "Data Input",
429
+ icon: "FileInput",
430
+ category: "data",
431
+ defaultWidth: 36,
432
+ defaultHeight: 50,
433
+ handlePolicy: "all",
434
+ orientation: "free",
435
+ isContainer: false,
436
+ acceptsBoundaryEvents: false,
437
+ canBeStart: false,
438
+ canBeEnd: false,
439
+ maxIncoming: 0
440
+ },
441
+ DataOutput: {
442
+ label: "Data Output",
443
+ icon: "FileOutput",
444
+ category: "data",
445
+ defaultWidth: 36,
446
+ defaultHeight: 50,
447
+ handlePolicy: "all",
448
+ orientation: "free",
449
+ isContainer: false,
450
+ acceptsBoundaryEvents: false,
451
+ canBeStart: false,
452
+ canBeEnd: false,
453
+ maxOutgoing: 0
454
+ },
455
+ DataStore: {
456
+ label: "Data Store",
457
+ icon: "Database",
458
+ category: "data",
459
+ defaultWidth: 50,
460
+ defaultHeight: 50,
461
+ handlePolicy: "all",
462
+ orientation: "free",
463
+ isContainer: false,
464
+ acceptsBoundaryEvents: false,
465
+ canBeStart: false,
466
+ canBeEnd: false,
467
+ maxIncoming: 0,
468
+ maxOutgoing: 0
469
+ },
470
+ DataStoreReference: {
471
+ label: "Data Store Reference",
472
+ icon: "DatabaseZap",
473
+ category: "data",
474
+ defaultWidth: 50,
475
+ defaultHeight: 50,
476
+ handlePolicy: "all",
477
+ orientation: "free",
478
+ isContainer: false,
479
+ acceptsBoundaryEvents: false,
480
+ canBeStart: false,
481
+ canBeEnd: false,
482
+ maxIncoming: 0,
483
+ maxOutgoing: 0
484
+ },
485
+ // ─── Conversation (BPMN 2.0 §12) ─────────────────────────────────────────────
486
+ Conversation: {
487
+ label: "Conversation",
488
+ icon: "MessageCircle",
489
+ category: "conversation",
490
+ defaultWidth: 60,
491
+ defaultHeight: 52,
492
+ handlePolicy: "all",
493
+ orientation: "free",
494
+ isContainer: false,
495
+ acceptsBoundaryEvents: false,
496
+ canBeStart: false,
497
+ canBeEnd: false
498
+ },
499
+ SubConversation: {
500
+ label: "Sub-Conversation",
501
+ icon: "MessagesSquare",
502
+ category: "conversation",
503
+ defaultWidth: 60,
504
+ defaultHeight: 52,
505
+ handlePolicy: "all",
506
+ orientation: "free",
507
+ isContainer: true,
508
+ acceptsBoundaryEvents: false,
509
+ supportsCollapse: true,
510
+ canBeStart: false,
511
+ canBeEnd: false
512
+ },
513
+ CallConversation: {
514
+ label: "Call Conversation",
515
+ icon: "PhoneCall",
516
+ category: "conversation",
517
+ defaultWidth: 60,
518
+ defaultHeight: 52,
519
+ handlePolicy: "all",
520
+ orientation: "free",
521
+ isContainer: false,
522
+ acceptsBoundaryEvents: false,
523
+ canBeStart: false,
524
+ canBeEnd: false
525
+ },
526
+ // ─── Choreography (BPMN 2.0 §11) ─────────────────────────────────────────────
527
+ ChoreographyTask: {
528
+ label: "Choreography Task",
529
+ icon: "ArrowLeftRight",
530
+ category: "choreography",
531
+ defaultWidth: 120,
532
+ defaultHeight: 80,
533
+ handlePolicy: "all",
534
+ orientation: "horizontal",
535
+ isContainer: false,
536
+ acceptsBoundaryEvents: false,
537
+ canBeStart: false,
538
+ canBeEnd: false
539
+ },
540
+ SubChoreography: {
541
+ label: "Sub-Choreography",
542
+ icon: "BoxSelect",
543
+ category: "choreography",
544
+ defaultWidth: 120,
545
+ defaultHeight: 80,
546
+ handlePolicy: "all",
547
+ orientation: "horizontal",
548
+ isContainer: true,
549
+ acceptsBoundaryEvents: false,
550
+ supportsCollapse: true,
551
+ canBeStart: false,
552
+ canBeEnd: false
553
+ },
554
+ CallChoreography: {
555
+ label: "Call Choreography",
556
+ icon: "Phone",
557
+ category: "choreography",
558
+ defaultWidth: 120,
559
+ defaultHeight: 80,
560
+ handlePolicy: "all",
561
+ orientation: "horizontal",
562
+ isContainer: false,
563
+ acceptsBoundaryEvents: false,
564
+ canBeStart: false,
565
+ canBeEnd: false
566
+ }
567
+ };
568
+ var BPMN_RESIZABLE_ELEMENT_TYPES = [
569
+ "Task",
570
+ "UserTask",
571
+ "ServiceTask",
572
+ "ScriptTask",
573
+ "ManualTask",
574
+ "BusinessRuleTask",
575
+ "ReceiveTask",
576
+ "SendTask",
577
+ "CallActivity",
578
+ "SubProcess",
579
+ "Transaction",
580
+ "EventSubProcess",
581
+ "AdHocSubProcess",
582
+ "Pool",
583
+ "Lane",
584
+ "Annotation",
585
+ "Group",
586
+ "SubConversation",
587
+ "ChoreographyTask",
588
+ "SubChoreography",
589
+ "CallChoreography"
590
+ ];
591
+ new Set(BPMN_RESIZABLE_ELEMENT_TYPES);
592
+
593
+ // src/elements/guards.ts
594
+ var GATEWAY_TYPES = /* @__PURE__ */ new Set([
595
+ "ExclusiveGateway",
596
+ "InclusiveGateway",
597
+ "ParallelGateway",
598
+ "EventBasedGateway",
599
+ "ComplexGateway"
600
+ ]);
601
+ var EVENT_TYPES = /* @__PURE__ */ new Set([
602
+ "StartEvent",
603
+ "EndEvent",
604
+ "IntermediateCatchEvent",
605
+ "IntermediateThrowEvent",
606
+ "BoundaryEvent"
607
+ ]);
608
+ var DATA_TYPES = /* @__PURE__ */ new Set([
609
+ "DataObject",
610
+ "DataObjectReference",
611
+ "DataInput",
612
+ "DataOutput",
613
+ "DataStore",
614
+ "DataStoreReference"
615
+ ]);
616
+ function isGatewayType(type) {
617
+ return GATEWAY_TYPES.has(type);
618
+ }
619
+ function isEventType(type) {
620
+ return EVENT_TYPES.has(type);
621
+ }
622
+ function isDataType(type) {
623
+ return DATA_TYPES.has(type);
624
+ }
625
+
626
+ // src/validation/index.ts
627
+ function isFlowNode(type) {
628
+ return isEventType(type) || isGatewayType(type) || type.includes("Task") || type === "CallActivity" || type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess" || type === "ChoreographyTask" || type === "SubChoreography" || type === "CallChoreography";
629
+ }
630
+ function isProcessNode(type) {
631
+ return isFlowNode(type) && type !== "BoundaryEvent";
632
+ }
633
+ function isSubProcess(type) {
634
+ return type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess";
635
+ }
636
+ function isCatchTarget(type) {
637
+ return type === "IntermediateCatchEvent" || type === "ReceiveTask";
638
+ }
639
+ function poolAncestor(node, nodeById) {
640
+ let current = node;
641
+ const visited = /* @__PURE__ */ new Set();
642
+ while (current?.parentId && !visited.has(current.id)) {
643
+ visited.add(current.id);
644
+ const parent = nodeById.get(current.parentId);
645
+ if (parent?.data.elementType === "Pool") return parent.id;
646
+ current = parent;
647
+ }
648
+ return void 0;
649
+ }
650
+ function countSequenceEdges(edges, nodeId, direction) {
651
+ return edges.filter((edge) => {
652
+ if (edge.data?.edgeType !== "sequenceFlow") return false;
653
+ return direction === "in" ? edge.target === nodeId : edge.source === nodeId;
654
+ }).length;
655
+ }
656
+ function sequenceEdges(edges) {
657
+ return edges.filter((edge) => (edge.data?.edgeType ?? edge.type) === "sequenceFlow");
658
+ }
659
+ function sequenceOut(edges, nodeId) {
660
+ return sequenceEdges(edges).filter((edge) => edge.source === nodeId);
661
+ }
662
+ function sequenceIn(edges, nodeId) {
663
+ return sequenceEdges(edges).filter((edge) => edge.target === nodeId);
664
+ }
665
+ function issue(code, severity, message, elementId, relatedElementIds) {
666
+ return {
667
+ id: `${code}:${elementId ?? relatedElementIds?.join(",") ?? "diagram"}`,
668
+ code,
669
+ severity,
670
+ message,
671
+ ...elementId ? { elementId } : {},
672
+ ...relatedElementIds ? { relatedElementIds } : {}
673
+ };
674
+ }
675
+ function validateBpmnDiagram(nodes, edges, options = {}) {
676
+ const opts = {
677
+ requireStartEvent: true,
678
+ requireEndEvent: true,
679
+ strictNames: false,
680
+ ...options
681
+ };
682
+ const issues = [];
683
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
684
+ const seqEdges = sequenceEdges(edges);
685
+ const processNodes = nodes.filter((node) => isProcessNode(node.data.elementType));
686
+ if (opts.requireStartEvent && !processNodes.some((node) => node.data.elementType === "StartEvent")) {
687
+ issues.push(issue("bpmn/start-event-required", "error", "The diagram must contain at least one start event."));
688
+ }
689
+ if (opts.requireEndEvent && !processNodes.some((node) => node.data.elementType === "EndEvent")) {
690
+ issues.push(issue("bpmn/end-event-required", "error", "The diagram must contain at least one end event."));
691
+ }
692
+ for (const edge of edges) {
693
+ const edgeType = edge.data?.edgeType ?? edge.type;
694
+ const source = nodeById.get(edge.source);
695
+ const target = nodeById.get(edge.target);
696
+ if (!source || !target) {
697
+ issues.push(issue(
698
+ "bpmn/no-orphan-edges",
699
+ "error",
700
+ `Edge "${edge.id}" references a missing ${!source ? "source" : "target"} node.`,
701
+ edge.id,
702
+ [edge.source, edge.target]
703
+ ));
704
+ continue;
705
+ }
706
+ if (edge.source === edge.target) {
707
+ issues.push(issue("bpmn/no-self-loop", "error", "BPMN edges cannot connect an element to itself.", edge.id, [edge.source]));
708
+ }
709
+ if (edgeType === "sequenceFlow") {
710
+ if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType) || isDataType(source.data.elementType) || isDataType(target.data.elementType)) {
711
+ issues.push(issue("bpmn/sequence-flow-valid-endpoints", "error", "Sequence flows must connect BPMN flow nodes.", edge.id, [source.id, target.id]));
712
+ }
713
+ const sourcePool = poolAncestor(source, nodeById);
714
+ const targetPool = poolAncestor(target, nodeById);
715
+ if (sourcePool && targetPool && sourcePool !== targetPool) {
716
+ 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]));
717
+ }
718
+ }
719
+ if (edgeType === "messageFlow") {
720
+ const sourcePool = poolAncestor(source, nodeById);
721
+ const targetPool = poolAncestor(target, nodeById);
722
+ if (!sourcePool || !targetPool || sourcePool === targetPool) {
723
+ issues.push(issue("bpmn/message-flow-valid-endpoints", "error", "Message flows must connect flow nodes in different pools.", edge.id, [source.id, target.id]));
724
+ }
725
+ if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType)) {
726
+ issues.push(issue("bpmn/message-flow-valid-endpoints", "error", "Message flows must connect BPMN flow nodes, not containers.", edge.id, [source.id, target.id]));
727
+ }
728
+ }
729
+ if (edgeType === "dataAssociation") {
730
+ const hasDataEndpoint = isDataType(source.data.elementType) || isDataType(target.data.elementType);
731
+ const hasFlowEndpoint = isFlowNode(source.data.elementType) || isFlowNode(target.data.elementType);
732
+ if (!hasDataEndpoint || !hasFlowEndpoint) {
733
+ issues.push(issue("bpmn/data-association-valid-endpoints", "error", "Data associations must connect data elements with flow nodes.", edge.id, [source.id, target.id]));
734
+ }
735
+ }
736
+ }
737
+ const duplicateSequenceKeys = /* @__PURE__ */ new Set();
738
+ const reportedDuplicateKeys = /* @__PURE__ */ new Set();
739
+ for (const edge of seqEdges) {
740
+ const key = `${edge.source}->${edge.target}`;
741
+ if (duplicateSequenceKeys.has(key) && !reportedDuplicateKeys.has(key)) {
742
+ reportedDuplicateKeys.add(key);
743
+ 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]));
744
+ }
745
+ duplicateSequenceKeys.add(key);
746
+ }
747
+ for (const node of nodes) {
748
+ const type = node.data.elementType;
749
+ const incoming = countSequenceEdges(edges, node.id, "in");
750
+ const outgoing = countSequenceEdges(edges, node.id, "out");
751
+ const meta = BPMN_ELEMENT_CATALOG[type];
752
+ if (type === "StartEvent" && incoming > 0) {
753
+ issues.push(issue("bpmn/start-event-no-incoming", "error", "Start events cannot have incoming sequence flows.", node.id));
754
+ }
755
+ if (type === "EndEvent") {
756
+ if (outgoing > 0) issues.push(issue("bpmn/no-outgoing-from-end-event", "error", "End events cannot have outgoing sequence flows.", node.id));
757
+ if (incoming === 0) issues.push(issue("bpmn/end-event-has-incoming", "error", "End events should have at least one incoming sequence flow.", node.id));
758
+ }
759
+ if ((type === "IntermediateCatchEvent" || type === "IntermediateThrowEvent") && (incoming === 0 || outgoing === 0)) {
760
+ issues.push(issue("bpmn/intermediate-event-both-flows", "error", "Intermediate events should have both incoming and outgoing sequence flows.", node.id));
761
+ }
762
+ if (type === "BoundaryEvent") {
763
+ const hostId = node.data.attachedToRef ?? node.parentId;
764
+ const host = hostId ? nodeById.get(hostId) : void 0;
765
+ if (!host || !BPMN_ELEMENT_CATALOG[host.data.elementType]?.acceptsBoundaryEvents) {
766
+ issues.push(issue("bpmn/boundary-event-attached", "error", "Boundary events must be attached to an activity or subprocess.", node.id, hostId ? [hostId] : void 0));
767
+ }
768
+ if (sequenceIn(edges, node.id).length > 0) {
769
+ issues.push(issue("bpmn/boundary-no-incoming", "error", "Boundary events cannot have incoming sequence flows.", node.id));
770
+ }
771
+ if (sequenceOut(edges, node.id).length === 0) {
772
+ issues.push(issue("bpmn/boundary-has-outgoing", "warning", "Boundary events should define an outgoing exception path.", node.id));
773
+ }
774
+ }
775
+ if (isGatewayType(type)) {
776
+ if (incoming === 0) issues.push(issue("bpmn/gateway-has-incoming", "error", "Gateways should have at least one incoming sequence flow.", node.id));
777
+ if (outgoing === 0) issues.push(issue("bpmn/gateway-has-outgoing", "error", "Gateways should have at least one outgoing sequence flow.", node.id));
778
+ }
779
+ if (type === "ExclusiveGateway" || type === "InclusiveGateway" || type === "ComplexGateway") {
780
+ const outgoingEdges = sequenceOut(edges, node.id);
781
+ const defaults = outgoingEdges.filter((edge) => edge.data?.isDefault);
782
+ if (defaults.length > 1) {
783
+ issues.push(issue("bpmn/gateway-single-default", "error", "Gateways can have at most one default sequence flow.", node.id, defaults.map((edge) => edge.id)));
784
+ }
785
+ if (outgoingEdges.length >= 2) {
786
+ for (const edge of outgoingEdges) {
787
+ if (!edge.data?.isDefault && !edge.data?.conditionExpression) {
788
+ 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]));
789
+ }
790
+ }
791
+ }
792
+ }
793
+ if (type === "EventBasedGateway") {
794
+ const outgoingEdges = edges.filter((edge) => edge.data?.edgeType === "sequenceFlow" && edge.source === node.id);
795
+ if (outgoingEdges.length < 2) {
796
+ issues.push(issue("bpmn/event-based-gateway-min-outgoing", "error", "Event-based gateways should have at least two outgoing sequence flows.", node.id));
797
+ }
798
+ for (const edge of outgoingEdges) {
799
+ const target = nodeById.get(edge.target);
800
+ if (target && !isCatchTarget(target.data.elementType)) {
801
+ 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]));
802
+ }
803
+ }
804
+ }
805
+ if (meta.maxIncoming !== void 0 && incoming > meta.maxIncoming) {
806
+ issues.push(issue("bpmn/max-incoming", "error", `${type} cannot have more than ${meta.maxIncoming} incoming sequence flow(s).`, node.id));
807
+ }
808
+ if (meta.maxOutgoing !== void 0 && outgoing > meta.maxOutgoing) {
809
+ issues.push(issue("bpmn/max-outgoing", "error", `${type} cannot have more than ${meta.maxOutgoing} outgoing sequence flow(s).`, node.id));
810
+ }
811
+ if (opts.strictNames && (type.includes("Task") || isGatewayType(type)) && !node.data.label) {
812
+ issues.push(issue("bpmn/name-required", "warning", `${type} should have a label.`, node.id));
813
+ }
814
+ if (isSubProcess(type)) {
815
+ const childNodes = nodes.filter((child) => child.parentId === node.id);
816
+ if (childNodes.length > 0) {
817
+ if (!childNodes.some((child) => child.data.elementType === "StartEvent")) {
818
+ issues.push(issue("bpmn/subprocess-has-start-end", "error", "Expanded subprocesses should contain a start event.", node.id));
819
+ }
820
+ if (!childNodes.some((child) => child.data.elementType === "EndEvent")) {
821
+ issues.push(issue("bpmn/subprocess-has-start-end", "error", "Expanded subprocesses should contain an end event.", node.id));
822
+ }
823
+ }
824
+ if (type === "EventSubProcess") {
825
+ const starts = childNodes.filter((child) => child.data.elementType === "StartEvent");
826
+ for (const start of starts) {
827
+ if (!start.data.trigger || start.data.trigger === "none") {
828
+ issues.push(issue("bpmn/event-subprocess-triggered-start", "error", "Event subprocess start events must define an event trigger.", start.id, [node.id]));
829
+ }
830
+ }
831
+ }
832
+ }
833
+ if (type === "Lane") {
834
+ const parent = node.parentId ? nodeById.get(node.parentId) : void 0;
835
+ if (parent?.data.elementType !== "Pool") {
836
+ issues.push(issue("bpmn/lane-parent-pool", "error", "Lanes must be contained by a pool.", node.id));
837
+ }
838
+ }
839
+ }
840
+ return {
841
+ valid: issues.every((item) => item.severity !== "error"),
842
+ issues
843
+ };
844
+ }
845
+
846
+ exports.validateBpmnDiagram = validateBpmnDiagram;
847
+ //# sourceMappingURL=index.cjs.map
848
+ //# sourceMappingURL=index.cjs.map