@aranzatech/diagrams-bpmn 0.1.0
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.
- package/dist/chunk-23B2IGK5.js +24 -0
- package/dist/chunk-23B2IGK5.js.map +1 -0
- package/dist/chunk-3AFZDIMQ.js +286 -0
- package/dist/chunk-3AFZDIMQ.js.map +1 -0
- package/dist/chunk-4OAEWYYU.js +579 -0
- package/dist/chunk-4OAEWYYU.js.map +1 -0
- package/dist/chunk-57LA2WSJ.js +476 -0
- package/dist/chunk-57LA2WSJ.js.map +1 -0
- package/dist/chunk-6TUC5QX5.js +491 -0
- package/dist/chunk-6TUC5QX5.js.map +1 -0
- package/dist/chunk-MLUJKUTG.js +86 -0
- package/dist/chunk-MLUJKUTG.js.map +1 -0
- package/dist/chunk-NXMUX67A.js +1443 -0
- package/dist/chunk-NXMUX67A.js.map +1 -0
- package/dist/edges/index.cjs +300 -0
- package/dist/edges/index.cjs.map +1 -0
- package/dist/edges/index.d.cts +17 -0
- package/dist/edges/index.d.ts +17 -0
- package/dist/edges/index.js +4 -0
- package/dist/edges/index.js.map +1 -0
- package/dist/elements/index.cjs +587 -0
- package/dist/elements/index.cjs.map +1 -0
- package/dist/elements/index.d.cts +20 -0
- package/dist/elements/index.d.ts +20 -0
- package/dist/elements/index.js +4 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/index.cjs +3442 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/index.cjs +1487 -0
- package/dist/nodes/index.cjs.map +1 -0
- package/dist/nodes/index.d.cts +45 -0
- package/dist/nodes/index.d.ts +45 -0
- package/dist/nodes/index.js +4 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/simulation/index.cjs +483 -0
- package/dist/simulation/index.cjs.map +1 -0
- package/dist/simulation/index.d.cts +62 -0
- package/dist/simulation/index.d.ts +62 -0
- package/dist/simulation/index.js +3 -0
- package/dist/simulation/index.js.map +1 -0
- package/dist/types-CxzazgBX.d.cts +111 -0
- package/dist/types-CxzazgBX.d.ts +111 -0
- package/dist/xml/index.cjs +1068 -0
- package/dist/xml/index.cjs.map +1 -0
- package/dist/xml/index.d.cts +24 -0
- package/dist/xml/index.d.ts +24 -0
- package/dist/xml/index.js +4 -0
- package/dist/xml/index.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bpmnModdle = require('bpmn-moddle');
|
|
4
|
+
|
|
5
|
+
// src/xml/importer.ts
|
|
6
|
+
|
|
7
|
+
// src/elements/catalog.ts
|
|
8
|
+
var BPMN_ELEMENT_CATALOG = {
|
|
9
|
+
// ─── Events ──────────────────────────────────────────────────────────────────
|
|
10
|
+
StartEvent: {
|
|
11
|
+
label: "Start Event",
|
|
12
|
+
category: "event",
|
|
13
|
+
defaultWidth: 36,
|
|
14
|
+
defaultHeight: 36,
|
|
15
|
+
handlePolicy: "source",
|
|
16
|
+
orientation: "free",
|
|
17
|
+
isContainer: false,
|
|
18
|
+
acceptsBoundaryEvents: false,
|
|
19
|
+
eventSemantics: "start",
|
|
20
|
+
canBeStart: true,
|
|
21
|
+
canBeEnd: false,
|
|
22
|
+
maxIncoming: 0,
|
|
23
|
+
maxOutgoing: 1
|
|
24
|
+
},
|
|
25
|
+
EndEvent: {
|
|
26
|
+
label: "End Event",
|
|
27
|
+
category: "event",
|
|
28
|
+
defaultWidth: 36,
|
|
29
|
+
defaultHeight: 36,
|
|
30
|
+
handlePolicy: "target",
|
|
31
|
+
orientation: "free",
|
|
32
|
+
isContainer: false,
|
|
33
|
+
acceptsBoundaryEvents: false,
|
|
34
|
+
eventSemantics: "end",
|
|
35
|
+
canBeStart: false,
|
|
36
|
+
canBeEnd: true,
|
|
37
|
+
maxOutgoing: 0
|
|
38
|
+
},
|
|
39
|
+
IntermediateCatchEvent: {
|
|
40
|
+
label: "Intermediate Catch Event",
|
|
41
|
+
category: "event",
|
|
42
|
+
defaultWidth: 36,
|
|
43
|
+
defaultHeight: 36,
|
|
44
|
+
handlePolicy: "all",
|
|
45
|
+
orientation: "free",
|
|
46
|
+
isContainer: false,
|
|
47
|
+
acceptsBoundaryEvents: false,
|
|
48
|
+
eventSemantics: "intermediateCatch",
|
|
49
|
+
canBeStart: false,
|
|
50
|
+
canBeEnd: false
|
|
51
|
+
},
|
|
52
|
+
IntermediateThrowEvent: {
|
|
53
|
+
label: "Intermediate Throw Event",
|
|
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
|
+
category: "event",
|
|
68
|
+
defaultWidth: 36,
|
|
69
|
+
defaultHeight: 36,
|
|
70
|
+
handlePolicy: "source",
|
|
71
|
+
orientation: "free",
|
|
72
|
+
isContainer: false,
|
|
73
|
+
acceptsBoundaryEvents: false,
|
|
74
|
+
eventSemantics: "boundary",
|
|
75
|
+
canBeStart: false,
|
|
76
|
+
canBeEnd: false,
|
|
77
|
+
maxIncoming: 0
|
|
78
|
+
},
|
|
79
|
+
// ─── Tasks ───────────────────────────────────────────────────────────────────
|
|
80
|
+
Task: {
|
|
81
|
+
label: "Task",
|
|
82
|
+
category: "task",
|
|
83
|
+
defaultWidth: 120,
|
|
84
|
+
defaultHeight: 60,
|
|
85
|
+
handlePolicy: "all",
|
|
86
|
+
orientation: "free",
|
|
87
|
+
isContainer: false,
|
|
88
|
+
acceptsBoundaryEvents: true,
|
|
89
|
+
supportsMarkers: true,
|
|
90
|
+
canBeStart: false,
|
|
91
|
+
canBeEnd: false
|
|
92
|
+
},
|
|
93
|
+
UserTask: {
|
|
94
|
+
label: "User Task",
|
|
95
|
+
category: "task",
|
|
96
|
+
defaultWidth: 120,
|
|
97
|
+
defaultHeight: 60,
|
|
98
|
+
handlePolicy: "all",
|
|
99
|
+
orientation: "free",
|
|
100
|
+
isContainer: false,
|
|
101
|
+
acceptsBoundaryEvents: true,
|
|
102
|
+
supportsMarkers: true,
|
|
103
|
+
canBeStart: false,
|
|
104
|
+
canBeEnd: false
|
|
105
|
+
},
|
|
106
|
+
ServiceTask: {
|
|
107
|
+
label: "Service Task",
|
|
108
|
+
category: "task",
|
|
109
|
+
defaultWidth: 120,
|
|
110
|
+
defaultHeight: 60,
|
|
111
|
+
handlePolicy: "all",
|
|
112
|
+
orientation: "free",
|
|
113
|
+
isContainer: false,
|
|
114
|
+
acceptsBoundaryEvents: true,
|
|
115
|
+
supportsMarkers: true,
|
|
116
|
+
canBeStart: false,
|
|
117
|
+
canBeEnd: false
|
|
118
|
+
},
|
|
119
|
+
ScriptTask: {
|
|
120
|
+
label: "Script Task",
|
|
121
|
+
category: "task",
|
|
122
|
+
defaultWidth: 120,
|
|
123
|
+
defaultHeight: 60,
|
|
124
|
+
handlePolicy: "all",
|
|
125
|
+
orientation: "free",
|
|
126
|
+
isContainer: false,
|
|
127
|
+
acceptsBoundaryEvents: true,
|
|
128
|
+
supportsMarkers: true,
|
|
129
|
+
canBeStart: false,
|
|
130
|
+
canBeEnd: false
|
|
131
|
+
},
|
|
132
|
+
ManualTask: {
|
|
133
|
+
label: "Manual Task",
|
|
134
|
+
category: "task",
|
|
135
|
+
defaultWidth: 120,
|
|
136
|
+
defaultHeight: 60,
|
|
137
|
+
handlePolicy: "all",
|
|
138
|
+
orientation: "free",
|
|
139
|
+
isContainer: false,
|
|
140
|
+
acceptsBoundaryEvents: true,
|
|
141
|
+
supportsMarkers: true,
|
|
142
|
+
canBeStart: false,
|
|
143
|
+
canBeEnd: false
|
|
144
|
+
},
|
|
145
|
+
BusinessRuleTask: {
|
|
146
|
+
label: "Business Rule Task",
|
|
147
|
+
category: "task",
|
|
148
|
+
defaultWidth: 120,
|
|
149
|
+
defaultHeight: 60,
|
|
150
|
+
handlePolicy: "all",
|
|
151
|
+
orientation: "free",
|
|
152
|
+
isContainer: false,
|
|
153
|
+
acceptsBoundaryEvents: true,
|
|
154
|
+
supportsMarkers: true,
|
|
155
|
+
canBeStart: false,
|
|
156
|
+
canBeEnd: false
|
|
157
|
+
},
|
|
158
|
+
ReceiveTask: {
|
|
159
|
+
label: "Receive Task",
|
|
160
|
+
category: "task",
|
|
161
|
+
defaultWidth: 120,
|
|
162
|
+
defaultHeight: 60,
|
|
163
|
+
handlePolicy: "all",
|
|
164
|
+
orientation: "free",
|
|
165
|
+
isContainer: false,
|
|
166
|
+
acceptsBoundaryEvents: true,
|
|
167
|
+
supportsMarkers: true,
|
|
168
|
+
canBeStart: false,
|
|
169
|
+
canBeEnd: false
|
|
170
|
+
},
|
|
171
|
+
SendTask: {
|
|
172
|
+
label: "Send Task",
|
|
173
|
+
category: "task",
|
|
174
|
+
defaultWidth: 120,
|
|
175
|
+
defaultHeight: 60,
|
|
176
|
+
handlePolicy: "all",
|
|
177
|
+
orientation: "free",
|
|
178
|
+
isContainer: false,
|
|
179
|
+
acceptsBoundaryEvents: true,
|
|
180
|
+
supportsMarkers: true,
|
|
181
|
+
canBeStart: false,
|
|
182
|
+
canBeEnd: false
|
|
183
|
+
},
|
|
184
|
+
CallActivity: {
|
|
185
|
+
label: "Call Activity",
|
|
186
|
+
category: "task",
|
|
187
|
+
defaultWidth: 120,
|
|
188
|
+
defaultHeight: 60,
|
|
189
|
+
handlePolicy: "all",
|
|
190
|
+
orientation: "free",
|
|
191
|
+
isContainer: false,
|
|
192
|
+
acceptsBoundaryEvents: true,
|
|
193
|
+
supportsMarkers: true,
|
|
194
|
+
canBeStart: false,
|
|
195
|
+
canBeEnd: false
|
|
196
|
+
},
|
|
197
|
+
// ─── Gateways ────────────────────────────────────────────────────────────────
|
|
198
|
+
ExclusiveGateway: {
|
|
199
|
+
label: "Exclusive Gateway",
|
|
200
|
+
category: "gateway",
|
|
201
|
+
defaultWidth: 50,
|
|
202
|
+
defaultHeight: 50,
|
|
203
|
+
handlePolicy: "all",
|
|
204
|
+
orientation: "free",
|
|
205
|
+
isContainer: false,
|
|
206
|
+
acceptsBoundaryEvents: false,
|
|
207
|
+
canBeStart: false,
|
|
208
|
+
canBeEnd: false
|
|
209
|
+
},
|
|
210
|
+
InclusiveGateway: {
|
|
211
|
+
label: "Inclusive Gateway",
|
|
212
|
+
category: "gateway",
|
|
213
|
+
defaultWidth: 50,
|
|
214
|
+
defaultHeight: 50,
|
|
215
|
+
handlePolicy: "all",
|
|
216
|
+
orientation: "free",
|
|
217
|
+
isContainer: false,
|
|
218
|
+
acceptsBoundaryEvents: false,
|
|
219
|
+
canBeStart: false,
|
|
220
|
+
canBeEnd: false
|
|
221
|
+
},
|
|
222
|
+
ParallelGateway: {
|
|
223
|
+
label: "Parallel Gateway",
|
|
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
|
+
EventBasedGateway: {
|
|
235
|
+
label: "Event-Based Gateway",
|
|
236
|
+
category: "gateway",
|
|
237
|
+
defaultWidth: 50,
|
|
238
|
+
defaultHeight: 50,
|
|
239
|
+
handlePolicy: "all",
|
|
240
|
+
orientation: "free",
|
|
241
|
+
isContainer: false,
|
|
242
|
+
acceptsBoundaryEvents: false,
|
|
243
|
+
canBeStart: false,
|
|
244
|
+
canBeEnd: false,
|
|
245
|
+
maxIncoming: 1
|
|
246
|
+
},
|
|
247
|
+
ComplexGateway: {
|
|
248
|
+
label: "Complex Gateway",
|
|
249
|
+
category: "gateway",
|
|
250
|
+
defaultWidth: 50,
|
|
251
|
+
defaultHeight: 50,
|
|
252
|
+
handlePolicy: "all",
|
|
253
|
+
orientation: "free",
|
|
254
|
+
isContainer: false,
|
|
255
|
+
acceptsBoundaryEvents: false,
|
|
256
|
+
canBeStart: false,
|
|
257
|
+
canBeEnd: false
|
|
258
|
+
},
|
|
259
|
+
// ─── Containers ───────────────────────────────────────────────────────────────
|
|
260
|
+
SubProcess: {
|
|
261
|
+
label: "Sub-Process",
|
|
262
|
+
category: "container",
|
|
263
|
+
defaultWidth: 350,
|
|
264
|
+
defaultHeight: 200,
|
|
265
|
+
handlePolicy: "all",
|
|
266
|
+
orientation: "horizontal",
|
|
267
|
+
isContainer: true,
|
|
268
|
+
acceptsBoundaryEvents: true,
|
|
269
|
+
supportsCollapse: true,
|
|
270
|
+
supportsMarkers: true,
|
|
271
|
+
canBeStart: false,
|
|
272
|
+
canBeEnd: false
|
|
273
|
+
},
|
|
274
|
+
Pool: {
|
|
275
|
+
label: "Pool",
|
|
276
|
+
category: "container",
|
|
277
|
+
defaultWidth: 600,
|
|
278
|
+
defaultHeight: 200,
|
|
279
|
+
handlePolicy: "none",
|
|
280
|
+
orientation: "horizontal",
|
|
281
|
+
isContainer: true,
|
|
282
|
+
acceptsBoundaryEvents: false,
|
|
283
|
+
canBeStart: false,
|
|
284
|
+
canBeEnd: false,
|
|
285
|
+
maxIncoming: 0,
|
|
286
|
+
maxOutgoing: 0
|
|
287
|
+
},
|
|
288
|
+
Lane: {
|
|
289
|
+
label: "Lane",
|
|
290
|
+
category: "container",
|
|
291
|
+
defaultWidth: 600,
|
|
292
|
+
defaultHeight: 120,
|
|
293
|
+
handlePolicy: "none",
|
|
294
|
+
orientation: "horizontal",
|
|
295
|
+
isContainer: true,
|
|
296
|
+
acceptsBoundaryEvents: false,
|
|
297
|
+
canBeStart: false,
|
|
298
|
+
canBeEnd: false,
|
|
299
|
+
maxIncoming: 0,
|
|
300
|
+
maxOutgoing: 0
|
|
301
|
+
},
|
|
302
|
+
// ─── Artifacts ────────────────────────────────────────────────────────────────
|
|
303
|
+
Annotation: {
|
|
304
|
+
label: "Text Annotation",
|
|
305
|
+
category: "artifact",
|
|
306
|
+
defaultWidth: 100,
|
|
307
|
+
defaultHeight: 60,
|
|
308
|
+
handlePolicy: "none",
|
|
309
|
+
orientation: "free",
|
|
310
|
+
isContainer: false,
|
|
311
|
+
acceptsBoundaryEvents: false,
|
|
312
|
+
canBeStart: false,
|
|
313
|
+
canBeEnd: false,
|
|
314
|
+
maxIncoming: 0,
|
|
315
|
+
maxOutgoing: 0
|
|
316
|
+
},
|
|
317
|
+
Group: {
|
|
318
|
+
label: "Group",
|
|
319
|
+
category: "artifact",
|
|
320
|
+
defaultWidth: 300,
|
|
321
|
+
defaultHeight: 200,
|
|
322
|
+
handlePolicy: "none",
|
|
323
|
+
orientation: "free",
|
|
324
|
+
isContainer: false,
|
|
325
|
+
acceptsBoundaryEvents: false,
|
|
326
|
+
canBeStart: false,
|
|
327
|
+
canBeEnd: false,
|
|
328
|
+
maxIncoming: 0,
|
|
329
|
+
maxOutgoing: 0
|
|
330
|
+
},
|
|
331
|
+
// ─── Data (BPMN 2.0 §10.3) ───────────────────────────────────────────────────
|
|
332
|
+
DataObject: {
|
|
333
|
+
label: "Data Object",
|
|
334
|
+
category: "data",
|
|
335
|
+
defaultWidth: 36,
|
|
336
|
+
defaultHeight: 50,
|
|
337
|
+
handlePolicy: "all",
|
|
338
|
+
orientation: "free",
|
|
339
|
+
isContainer: false,
|
|
340
|
+
acceptsBoundaryEvents: false,
|
|
341
|
+
canBeStart: false,
|
|
342
|
+
canBeEnd: false,
|
|
343
|
+
maxIncoming: 0,
|
|
344
|
+
maxOutgoing: 0
|
|
345
|
+
},
|
|
346
|
+
DataObjectReference: {
|
|
347
|
+
label: "Data Object Reference",
|
|
348
|
+
category: "data",
|
|
349
|
+
defaultWidth: 36,
|
|
350
|
+
defaultHeight: 50,
|
|
351
|
+
handlePolicy: "all",
|
|
352
|
+
orientation: "free",
|
|
353
|
+
isContainer: false,
|
|
354
|
+
acceptsBoundaryEvents: false,
|
|
355
|
+
canBeStart: false,
|
|
356
|
+
canBeEnd: false,
|
|
357
|
+
maxIncoming: 0,
|
|
358
|
+
maxOutgoing: 0
|
|
359
|
+
},
|
|
360
|
+
DataInput: {
|
|
361
|
+
label: "Data Input",
|
|
362
|
+
category: "data",
|
|
363
|
+
defaultWidth: 36,
|
|
364
|
+
defaultHeight: 50,
|
|
365
|
+
handlePolicy: "all",
|
|
366
|
+
orientation: "free",
|
|
367
|
+
isContainer: false,
|
|
368
|
+
acceptsBoundaryEvents: false,
|
|
369
|
+
canBeStart: false,
|
|
370
|
+
canBeEnd: false,
|
|
371
|
+
maxIncoming: 0
|
|
372
|
+
},
|
|
373
|
+
DataOutput: {
|
|
374
|
+
label: "Data Output",
|
|
375
|
+
category: "data",
|
|
376
|
+
defaultWidth: 36,
|
|
377
|
+
defaultHeight: 50,
|
|
378
|
+
handlePolicy: "all",
|
|
379
|
+
orientation: "free",
|
|
380
|
+
isContainer: false,
|
|
381
|
+
acceptsBoundaryEvents: false,
|
|
382
|
+
canBeStart: false,
|
|
383
|
+
canBeEnd: false,
|
|
384
|
+
maxOutgoing: 0
|
|
385
|
+
},
|
|
386
|
+
DataStore: {
|
|
387
|
+
label: "Data Store",
|
|
388
|
+
category: "data",
|
|
389
|
+
defaultWidth: 50,
|
|
390
|
+
defaultHeight: 50,
|
|
391
|
+
handlePolicy: "all",
|
|
392
|
+
orientation: "free",
|
|
393
|
+
isContainer: false,
|
|
394
|
+
acceptsBoundaryEvents: false,
|
|
395
|
+
canBeStart: false,
|
|
396
|
+
canBeEnd: false,
|
|
397
|
+
maxIncoming: 0,
|
|
398
|
+
maxOutgoing: 0
|
|
399
|
+
},
|
|
400
|
+
DataStoreReference: {
|
|
401
|
+
label: "Data Store Reference",
|
|
402
|
+
category: "data",
|
|
403
|
+
defaultWidth: 50,
|
|
404
|
+
defaultHeight: 50,
|
|
405
|
+
handlePolicy: "all",
|
|
406
|
+
orientation: "free",
|
|
407
|
+
isContainer: false,
|
|
408
|
+
acceptsBoundaryEvents: false,
|
|
409
|
+
canBeStart: false,
|
|
410
|
+
canBeEnd: false,
|
|
411
|
+
maxIncoming: 0,
|
|
412
|
+
maxOutgoing: 0
|
|
413
|
+
},
|
|
414
|
+
// ─── Conversation (BPMN 2.0 §12) ─────────────────────────────────────────────
|
|
415
|
+
Conversation: {
|
|
416
|
+
label: "Conversation",
|
|
417
|
+
category: "conversation",
|
|
418
|
+
defaultWidth: 60,
|
|
419
|
+
defaultHeight: 52,
|
|
420
|
+
handlePolicy: "all",
|
|
421
|
+
orientation: "free",
|
|
422
|
+
isContainer: false,
|
|
423
|
+
acceptsBoundaryEvents: false,
|
|
424
|
+
canBeStart: false,
|
|
425
|
+
canBeEnd: false
|
|
426
|
+
},
|
|
427
|
+
SubConversation: {
|
|
428
|
+
label: "Sub-Conversation",
|
|
429
|
+
category: "conversation",
|
|
430
|
+
defaultWidth: 60,
|
|
431
|
+
defaultHeight: 52,
|
|
432
|
+
handlePolicy: "all",
|
|
433
|
+
orientation: "free",
|
|
434
|
+
isContainer: true,
|
|
435
|
+
acceptsBoundaryEvents: false,
|
|
436
|
+
supportsCollapse: true,
|
|
437
|
+
canBeStart: false,
|
|
438
|
+
canBeEnd: false
|
|
439
|
+
},
|
|
440
|
+
CallConversation: {
|
|
441
|
+
label: "Call Conversation",
|
|
442
|
+
category: "conversation",
|
|
443
|
+
defaultWidth: 60,
|
|
444
|
+
defaultHeight: 52,
|
|
445
|
+
handlePolicy: "all",
|
|
446
|
+
orientation: "free",
|
|
447
|
+
isContainer: false,
|
|
448
|
+
acceptsBoundaryEvents: false,
|
|
449
|
+
canBeStart: false,
|
|
450
|
+
canBeEnd: false
|
|
451
|
+
},
|
|
452
|
+
// ─── Choreography (BPMN 2.0 §11) ─────────────────────────────────────────────
|
|
453
|
+
ChoreographyTask: {
|
|
454
|
+
label: "Choreography Task",
|
|
455
|
+
category: "choreography",
|
|
456
|
+
defaultWidth: 120,
|
|
457
|
+
defaultHeight: 80,
|
|
458
|
+
handlePolicy: "all",
|
|
459
|
+
orientation: "horizontal",
|
|
460
|
+
isContainer: false,
|
|
461
|
+
acceptsBoundaryEvents: false,
|
|
462
|
+
canBeStart: false,
|
|
463
|
+
canBeEnd: false
|
|
464
|
+
},
|
|
465
|
+
SubChoreography: {
|
|
466
|
+
label: "Sub-Choreography",
|
|
467
|
+
category: "choreography",
|
|
468
|
+
defaultWidth: 120,
|
|
469
|
+
defaultHeight: 80,
|
|
470
|
+
handlePolicy: "all",
|
|
471
|
+
orientation: "horizontal",
|
|
472
|
+
isContainer: true,
|
|
473
|
+
acceptsBoundaryEvents: false,
|
|
474
|
+
supportsCollapse: true,
|
|
475
|
+
canBeStart: false,
|
|
476
|
+
canBeEnd: false
|
|
477
|
+
},
|
|
478
|
+
CallChoreography: {
|
|
479
|
+
label: "Call Choreography",
|
|
480
|
+
category: "choreography",
|
|
481
|
+
defaultWidth: 120,
|
|
482
|
+
defaultHeight: 80,
|
|
483
|
+
handlePolicy: "all",
|
|
484
|
+
orientation: "horizontal",
|
|
485
|
+
isContainer: false,
|
|
486
|
+
acceptsBoundaryEvents: false,
|
|
487
|
+
canBeStart: false,
|
|
488
|
+
canBeEnd: false
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// src/xml/mapper.ts
|
|
493
|
+
var MODDLE_TO_ELEMENT_TYPE = {
|
|
494
|
+
"bpmn:StartEvent": "StartEvent",
|
|
495
|
+
"bpmn:EndEvent": "EndEvent",
|
|
496
|
+
"bpmn:IntermediateCatchEvent": "IntermediateCatchEvent",
|
|
497
|
+
"bpmn:IntermediateThrowEvent": "IntermediateThrowEvent",
|
|
498
|
+
"bpmn:BoundaryEvent": "BoundaryEvent",
|
|
499
|
+
"bpmn:Task": "Task",
|
|
500
|
+
"bpmn:UserTask": "UserTask",
|
|
501
|
+
"bpmn:ServiceTask": "ServiceTask",
|
|
502
|
+
"bpmn:ScriptTask": "ScriptTask",
|
|
503
|
+
"bpmn:ManualTask": "ManualTask",
|
|
504
|
+
"bpmn:BusinessRuleTask": "BusinessRuleTask",
|
|
505
|
+
"bpmn:ReceiveTask": "ReceiveTask",
|
|
506
|
+
"bpmn:SendTask": "SendTask",
|
|
507
|
+
"bpmn:CallActivity": "CallActivity",
|
|
508
|
+
"bpmn:ExclusiveGateway": "ExclusiveGateway",
|
|
509
|
+
"bpmn:InclusiveGateway": "InclusiveGateway",
|
|
510
|
+
"bpmn:ParallelGateway": "ParallelGateway",
|
|
511
|
+
"bpmn:EventBasedGateway": "EventBasedGateway",
|
|
512
|
+
"bpmn:ComplexGateway": "ComplexGateway",
|
|
513
|
+
"bpmn:SubProcess": "SubProcess",
|
|
514
|
+
"bpmn:AdHocSubProcess": "SubProcess",
|
|
515
|
+
"bpmn:Transaction": "SubProcess",
|
|
516
|
+
"bpmn:TextAnnotation": "Annotation",
|
|
517
|
+
"bpmn:Group": "Group",
|
|
518
|
+
"bpmn:DataObject": "DataObject",
|
|
519
|
+
"bpmn:DataObjectReference": "DataObjectReference",
|
|
520
|
+
"bpmn:DataInput": "DataInput",
|
|
521
|
+
"bpmn:DataOutput": "DataOutput",
|
|
522
|
+
"bpmn:DataStore": "DataStore",
|
|
523
|
+
"bpmn:DataStoreReference": "DataStoreReference",
|
|
524
|
+
"bpmn:Conversation": "Conversation",
|
|
525
|
+
"bpmn:SubConversation": "SubConversation",
|
|
526
|
+
"bpmn:CallConversation": "CallConversation",
|
|
527
|
+
"bpmn:ChoreographyTask": "ChoreographyTask",
|
|
528
|
+
"bpmn:SubChoreography": "SubChoreography",
|
|
529
|
+
"bpmn:CallChoreography": "CallChoreography",
|
|
530
|
+
"bpmn:Lane": "Lane"
|
|
531
|
+
};
|
|
532
|
+
var ELEMENT_TYPE_TO_MODDLE = {
|
|
533
|
+
StartEvent: "bpmn:StartEvent",
|
|
534
|
+
EndEvent: "bpmn:EndEvent",
|
|
535
|
+
IntermediateCatchEvent: "bpmn:IntermediateCatchEvent",
|
|
536
|
+
IntermediateThrowEvent: "bpmn:IntermediateThrowEvent",
|
|
537
|
+
BoundaryEvent: "bpmn:BoundaryEvent",
|
|
538
|
+
Task: "bpmn:Task",
|
|
539
|
+
UserTask: "bpmn:UserTask",
|
|
540
|
+
ServiceTask: "bpmn:ServiceTask",
|
|
541
|
+
ScriptTask: "bpmn:ScriptTask",
|
|
542
|
+
ManualTask: "bpmn:ManualTask",
|
|
543
|
+
BusinessRuleTask: "bpmn:BusinessRuleTask",
|
|
544
|
+
ReceiveTask: "bpmn:ReceiveTask",
|
|
545
|
+
SendTask: "bpmn:SendTask",
|
|
546
|
+
CallActivity: "bpmn:CallActivity",
|
|
547
|
+
ExclusiveGateway: "bpmn:ExclusiveGateway",
|
|
548
|
+
InclusiveGateway: "bpmn:InclusiveGateway",
|
|
549
|
+
ParallelGateway: "bpmn:ParallelGateway",
|
|
550
|
+
EventBasedGateway: "bpmn:EventBasedGateway",
|
|
551
|
+
ComplexGateway: "bpmn:ComplexGateway",
|
|
552
|
+
SubProcess: "bpmn:SubProcess",
|
|
553
|
+
Pool: "bpmn:Participant",
|
|
554
|
+
Lane: "bpmn:Lane",
|
|
555
|
+
Annotation: "bpmn:TextAnnotation",
|
|
556
|
+
Group: "bpmn:Group",
|
|
557
|
+
DataObject: "bpmn:DataObject",
|
|
558
|
+
DataObjectReference: "bpmn:DataObjectReference",
|
|
559
|
+
DataInput: "bpmn:DataInput",
|
|
560
|
+
DataOutput: "bpmn:DataOutput",
|
|
561
|
+
DataStore: "bpmn:DataStore",
|
|
562
|
+
DataStoreReference: "bpmn:DataStoreReference",
|
|
563
|
+
Conversation: "bpmn:Conversation",
|
|
564
|
+
SubConversation: "bpmn:SubConversation",
|
|
565
|
+
CallConversation: "bpmn:CallConversation",
|
|
566
|
+
ChoreographyTask: "bpmn:ChoreographyTask",
|
|
567
|
+
SubChoreography: "bpmn:SubChoreography",
|
|
568
|
+
CallChoreography: "bpmn:CallChoreography"
|
|
569
|
+
};
|
|
570
|
+
var MODDLE_TO_EDGE_TYPE = {
|
|
571
|
+
"bpmn:SequenceFlow": "sequenceFlow",
|
|
572
|
+
"bpmn:MessageFlow": "messageFlow",
|
|
573
|
+
"bpmn:Association": "association",
|
|
574
|
+
"bpmn:DataInputAssociation": "dataAssociation",
|
|
575
|
+
"bpmn:DataOutputAssociation": "dataAssociation",
|
|
576
|
+
"bpmn:ConversationLink": "conversationLink"
|
|
577
|
+
};
|
|
578
|
+
var EDGE_TYPE_TO_MODDLE = {
|
|
579
|
+
sequenceFlow: "bpmn:SequenceFlow",
|
|
580
|
+
messageFlow: "bpmn:MessageFlow",
|
|
581
|
+
association: "bpmn:Association",
|
|
582
|
+
dataAssociation: "bpmn:DataInputAssociation",
|
|
583
|
+
conversationLink: "bpmn:ConversationLink"
|
|
584
|
+
};
|
|
585
|
+
var EVENT_DEF_TO_TRIGGER = {
|
|
586
|
+
"bpmn:MessageEventDefinition": "message",
|
|
587
|
+
"bpmn:TimerEventDefinition": "timer",
|
|
588
|
+
"bpmn:EscalationEventDefinition": "escalation",
|
|
589
|
+
"bpmn:ConditionalEventDefinition": "conditional",
|
|
590
|
+
"bpmn:ErrorEventDefinition": "error",
|
|
591
|
+
"bpmn:CancelEventDefinition": "cancel",
|
|
592
|
+
"bpmn:CompensateEventDefinition": "compensation",
|
|
593
|
+
"bpmn:SignalEventDefinition": "signal",
|
|
594
|
+
"bpmn:LinkEventDefinition": "link",
|
|
595
|
+
"bpmn:TerminateEventDefinition": "terminate"
|
|
596
|
+
};
|
|
597
|
+
var TRIGGER_TO_EVENT_DEF = {
|
|
598
|
+
message: "bpmn:MessageEventDefinition",
|
|
599
|
+
timer: "bpmn:TimerEventDefinition",
|
|
600
|
+
escalation: "bpmn:EscalationEventDefinition",
|
|
601
|
+
conditional: "bpmn:ConditionalEventDefinition",
|
|
602
|
+
error: "bpmn:ErrorEventDefinition",
|
|
603
|
+
cancel: "bpmn:CancelEventDefinition",
|
|
604
|
+
compensation: "bpmn:CompensateEventDefinition",
|
|
605
|
+
signal: "bpmn:SignalEventDefinition",
|
|
606
|
+
link: "bpmn:LinkEventDefinition",
|
|
607
|
+
terminate: "bpmn:TerminateEventDefinition"
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// src/xml/importer.ts
|
|
611
|
+
function asElements(v) {
|
|
612
|
+
return Array.isArray(v) ? v : [];
|
|
613
|
+
}
|
|
614
|
+
function asString(v) {
|
|
615
|
+
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
616
|
+
}
|
|
617
|
+
function extractDiagramInfo(definitions) {
|
|
618
|
+
const shapes = /* @__PURE__ */ new Map();
|
|
619
|
+
const waypoints = /* @__PURE__ */ new Map();
|
|
620
|
+
for (const diagram of asElements(definitions.diagrams)) {
|
|
621
|
+
const plane = diagram.plane;
|
|
622
|
+
if (!plane) continue;
|
|
623
|
+
for (const el of asElements(plane.planeElement)) {
|
|
624
|
+
const bpmnEl = el.bpmnElement;
|
|
625
|
+
if (!bpmnEl?.id) continue;
|
|
626
|
+
const id = bpmnEl.id;
|
|
627
|
+
if (el.$type === "bpmndi:BPMNShape") {
|
|
628
|
+
const b = el.bounds;
|
|
629
|
+
if (b) {
|
|
630
|
+
shapes.set(id, {
|
|
631
|
+
x: b.x,
|
|
632
|
+
y: b.y,
|
|
633
|
+
width: b.width,
|
|
634
|
+
height: b.height,
|
|
635
|
+
...typeof el.isExpanded === "boolean" ? { isExpanded: el.isExpanded } : {}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
} else if (el.$type === "bpmndi:BPMNEdge") {
|
|
639
|
+
const pts = el.waypoint ?? [];
|
|
640
|
+
if (pts.length) waypoints.set(id, pts);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return { shapes, waypoints };
|
|
645
|
+
}
|
|
646
|
+
function extractLaneMembership(process) {
|
|
647
|
+
const map = /* @__PURE__ */ new Map();
|
|
648
|
+
function walkLaneSet(laneSet2) {
|
|
649
|
+
for (const lane of asElements(laneSet2.lanes)) {
|
|
650
|
+
const laneId = lane.id;
|
|
651
|
+
if (!laneId) continue;
|
|
652
|
+
for (const ref of asElements(lane.flowNodeRef)) {
|
|
653
|
+
if (ref.id) map.set(ref.id, laneId);
|
|
654
|
+
}
|
|
655
|
+
const child = lane.childLaneSet;
|
|
656
|
+
if (child) walkLaneSet(child);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const laneSet = process.laneSet;
|
|
660
|
+
if (laneSet) walkLaneSet(laneSet);
|
|
661
|
+
return map;
|
|
662
|
+
}
|
|
663
|
+
function extractTrigger(el) {
|
|
664
|
+
const defs = asElements(el.eventDefinitions);
|
|
665
|
+
if (defs.length === 0) return void 0;
|
|
666
|
+
if (defs.length > 1) return el.$type.includes("Parallel") ? "parallelMultiple" : "multiple";
|
|
667
|
+
return EVENT_DEF_TO_TRIGGER[defs[0].$type];
|
|
668
|
+
}
|
|
669
|
+
function extractSubProcessVariant(el) {
|
|
670
|
+
if (el.$type === "bpmn:Transaction") return "transaction";
|
|
671
|
+
if (el.$type === "bpmn:AdHocSubProcess") return "adhoc";
|
|
672
|
+
if (el.triggeredByEvent === true) return "event";
|
|
673
|
+
return "embedded";
|
|
674
|
+
}
|
|
675
|
+
function walkFlowElements(elements, parentId, ctx, nodes, edges) {
|
|
676
|
+
for (const el of elements) {
|
|
677
|
+
const { $type, id } = el;
|
|
678
|
+
if (!id) continue;
|
|
679
|
+
const edgeType = MODDLE_TO_EDGE_TYPE[$type];
|
|
680
|
+
if (edgeType !== void 0) {
|
|
681
|
+
buildEdge(el, edgeType, ctx, edges);
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
if ($type === "bpmn:LaneSet") continue;
|
|
685
|
+
const elementType = MODDLE_TO_ELEMENT_TYPE[$type];
|
|
686
|
+
if (!elementType) {
|
|
687
|
+
ctx.warnings.push(`Unknown element type "${$type}" (id=${id}) \u2014 skipped.`);
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
buildNode(el, elementType, parentId, ctx, nodes);
|
|
691
|
+
if ($type === "bpmn:SubProcess" || $type === "bpmn:Transaction" || $type === "bpmn:AdHocSubProcess") {
|
|
692
|
+
const children = asElements(el.flowElements);
|
|
693
|
+
const laneMembership = extractLaneMembership(el);
|
|
694
|
+
walkFlowElements(children, id, { ...ctx, laneMembership }, nodes, edges);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function buildNode(el, elementType, parentId, ctx, nodes) {
|
|
699
|
+
const id = el.id;
|
|
700
|
+
const meta = BPMN_ELEMENT_CATALOG[elementType];
|
|
701
|
+
const shape = ctx.shapes.get(id);
|
|
702
|
+
const x = shape?.x ?? ctx.autoX.value;
|
|
703
|
+
const y = shape?.y ?? 100;
|
|
704
|
+
if (!shape) ctx.autoX.value += (meta?.defaultWidth ?? 120) + 20;
|
|
705
|
+
const label = asString(el.name);
|
|
706
|
+
const trigger = extractTrigger(el);
|
|
707
|
+
const isNonInterrupting = el.cancelActivity === false;
|
|
708
|
+
const data = {
|
|
709
|
+
elementType,
|
|
710
|
+
...label ? { label } : {},
|
|
711
|
+
...trigger ? { trigger } : {},
|
|
712
|
+
...isNonInterrupting ? { isNonInterrupting: true } : {}
|
|
713
|
+
};
|
|
714
|
+
if (elementType === "SubProcess") {
|
|
715
|
+
const variant = extractSubProcessVariant(el);
|
|
716
|
+
if (variant) data.subProcessVariant = variant;
|
|
717
|
+
const isExpanded = shape?.isExpanded ?? true;
|
|
718
|
+
data.isExpanded = isExpanded;
|
|
719
|
+
}
|
|
720
|
+
const laneId = ctx.laneMembership.get(id);
|
|
721
|
+
const effectiveParentId = laneId ?? parentId;
|
|
722
|
+
const node = {
|
|
723
|
+
id,
|
|
724
|
+
type: elementType,
|
|
725
|
+
position: { x, y },
|
|
726
|
+
data,
|
|
727
|
+
width: shape?.width ?? meta?.defaultWidth,
|
|
728
|
+
height: shape?.height ?? meta?.defaultHeight,
|
|
729
|
+
...effectiveParentId ? { parentId: effectiveParentId } : {}
|
|
730
|
+
};
|
|
731
|
+
nodes.push(node);
|
|
732
|
+
}
|
|
733
|
+
function buildEdge(el, edgeType, ctx, edges) {
|
|
734
|
+
const id = el.id;
|
|
735
|
+
const source = el.sourceRef?.id;
|
|
736
|
+
const target = el.targetRef?.id;
|
|
737
|
+
if (!source || !target) {
|
|
738
|
+
ctx.warnings.push(`Edge "${id}" missing source or target \u2014 skipped.`);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const label = asString(el.name);
|
|
742
|
+
const condExpr = el.conditionExpression;
|
|
743
|
+
const data = {
|
|
744
|
+
edgeType,
|
|
745
|
+
...label ? { label } : {},
|
|
746
|
+
...condExpr?.body ? { conditionExpression: condExpr.body } : {}
|
|
747
|
+
};
|
|
748
|
+
const waypoints = ctx.waypoints.get(id);
|
|
749
|
+
if (waypoints?.length) data.routingPoints = waypoints;
|
|
750
|
+
edges.push({ id, type: edgeType, source, target, data });
|
|
751
|
+
}
|
|
752
|
+
function handleCollaboration(collaboration, ctx, nodes, edges) {
|
|
753
|
+
for (const participant of asElements(collaboration.participants)) {
|
|
754
|
+
const id = participant.id;
|
|
755
|
+
if (!id) continue;
|
|
756
|
+
const label = asString(participant.name);
|
|
757
|
+
const shape = ctx.shapes.get(id);
|
|
758
|
+
const poolNode = {
|
|
759
|
+
id,
|
|
760
|
+
type: "Pool",
|
|
761
|
+
position: { x: shape?.x ?? 0, y: shape?.y ?? 0 },
|
|
762
|
+
data: { elementType: "Pool", ...label ? { label } : {} },
|
|
763
|
+
width: shape?.width ?? 600,
|
|
764
|
+
height: shape?.height ?? 200
|
|
765
|
+
};
|
|
766
|
+
nodes.push(poolNode);
|
|
767
|
+
const processRef = participant.processRef;
|
|
768
|
+
if (processRef) {
|
|
769
|
+
const laneMembership = extractLaneMembership(processRef);
|
|
770
|
+
walkFlowElements(
|
|
771
|
+
asElements(processRef.flowElements),
|
|
772
|
+
id,
|
|
773
|
+
{ ...ctx, laneMembership },
|
|
774
|
+
nodes,
|
|
775
|
+
edges
|
|
776
|
+
);
|
|
777
|
+
const laneSet = processRef.laneSet;
|
|
778
|
+
if (laneSet) {
|
|
779
|
+
addLaneNodes(laneSet, id, ctx, nodes);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
for (const mf of asElements(collaboration.messageFlows)) {
|
|
784
|
+
buildEdge(mf, "messageFlow", ctx, edges);
|
|
785
|
+
}
|
|
786
|
+
for (const cl of asElements(collaboration.conversationLinks)) {
|
|
787
|
+
buildEdge(cl, "conversationLink", ctx, edges);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function addLaneNodes(laneSet, poolId, ctx, nodes) {
|
|
791
|
+
for (const lane of asElements(laneSet.lanes)) {
|
|
792
|
+
const id = lane.id;
|
|
793
|
+
if (!id) continue;
|
|
794
|
+
const label = asString(lane.name);
|
|
795
|
+
const shape = ctx.shapes.get(id);
|
|
796
|
+
nodes.push({
|
|
797
|
+
id,
|
|
798
|
+
type: "Lane",
|
|
799
|
+
position: { x: shape?.x ?? 30, y: shape?.y ?? 0 },
|
|
800
|
+
data: { elementType: "Lane", ...label ? { label } : {} },
|
|
801
|
+
width: shape?.width ?? 570,
|
|
802
|
+
height: shape?.height ?? 120,
|
|
803
|
+
parentId: poolId
|
|
804
|
+
});
|
|
805
|
+
const child = lane.childLaneSet;
|
|
806
|
+
if (child) addLaneNodes(child, poolId, ctx, nodes);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
async function parseBpmnXml(xml) {
|
|
810
|
+
const moddle = new bpmnModdle.BpmnModdle();
|
|
811
|
+
const warnings = [];
|
|
812
|
+
let rootElement;
|
|
813
|
+
try {
|
|
814
|
+
const result = await moddle.fromXML(xml);
|
|
815
|
+
rootElement = result.rootElement;
|
|
816
|
+
for (const w of result.warnings) warnings.push(w.message);
|
|
817
|
+
} catch (err) {
|
|
818
|
+
throw new Error(`Failed to parse BPMN XML: ${String(err)}`);
|
|
819
|
+
}
|
|
820
|
+
const nodes = [];
|
|
821
|
+
const edges = [];
|
|
822
|
+
const { shapes, waypoints } = extractDiagramInfo(rootElement);
|
|
823
|
+
const ctx = {
|
|
824
|
+
shapes,
|
|
825
|
+
waypoints,
|
|
826
|
+
laneMembership: /* @__PURE__ */ new Map(),
|
|
827
|
+
warnings,
|
|
828
|
+
autoX: { value: 50 }
|
|
829
|
+
};
|
|
830
|
+
for (const rootEl of asElements(rootElement.rootElements)) {
|
|
831
|
+
if (rootEl.$type === "bpmn:Collaboration") {
|
|
832
|
+
handleCollaboration(rootEl, ctx, nodes, edges);
|
|
833
|
+
} else if (rootEl.$type === "bpmn:Process") {
|
|
834
|
+
const laneMembership = extractLaneMembership(rootEl);
|
|
835
|
+
const laneSet = rootEl.laneSet;
|
|
836
|
+
if (laneSet) addLaneNodes(laneSet, "", ctx, nodes);
|
|
837
|
+
walkFlowElements(
|
|
838
|
+
asElements(rootEl.flowElements),
|
|
839
|
+
void 0,
|
|
840
|
+
{ ...ctx, laneMembership },
|
|
841
|
+
nodes,
|
|
842
|
+
edges
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return { nodes, edges, warnings };
|
|
847
|
+
}
|
|
848
|
+
function uid(prefix, id) {
|
|
849
|
+
return `${prefix}_${id}`;
|
|
850
|
+
}
|
|
851
|
+
function asNodes(nodes, types) {
|
|
852
|
+
return nodes.filter((n) => types.includes(n.data.elementType));
|
|
853
|
+
}
|
|
854
|
+
function buildFlowableAttrs(data) {
|
|
855
|
+
const attrs = {};
|
|
856
|
+
if (data.flowableAssignee) attrs["flowable:assignee"] = data.flowableAssignee;
|
|
857
|
+
if (data.flowableCandidateGroups) attrs["flowable:candidateGroups"] = data.flowableCandidateGroups;
|
|
858
|
+
if (data.flowableCandidateUsers) attrs["flowable:candidateUsers"] = data.flowableCandidateUsers;
|
|
859
|
+
if (data.flowableFormKey) attrs["flowable:formKey"] = data.flowableFormKey;
|
|
860
|
+
if (data.flowableDueDate) attrs["flowable:dueDate"] = data.flowableDueDate;
|
|
861
|
+
if (data.flowableType) attrs["flowable:type"] = data.flowableType;
|
|
862
|
+
if (data.flowableExpression) attrs["flowable:expression"] = data.flowableExpression;
|
|
863
|
+
if (data.flowableClass) attrs["flowable:class"] = data.flowableClass;
|
|
864
|
+
if (data.flowableDelegateExpression) attrs["flowable:delegateExpression"] = data.flowableDelegateExpression;
|
|
865
|
+
return attrs;
|
|
866
|
+
}
|
|
867
|
+
function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
868
|
+
const defId = opts.id ?? "Definitions_1";
|
|
869
|
+
const defName = opts.name;
|
|
870
|
+
const poolNodes = asNodes(nodes, ["Pool"]);
|
|
871
|
+
const laneNodes = asNodes(nodes, ["Lane"]);
|
|
872
|
+
const isCollaboration = poolNodes.length > 0;
|
|
873
|
+
const definitions = moddle.create("bpmn:Definitions", {
|
|
874
|
+
id: defId,
|
|
875
|
+
targetNamespace: "http://bpmn.io/schema/bpmn",
|
|
876
|
+
...defName ? { name: defName } : {}
|
|
877
|
+
});
|
|
878
|
+
const rootElements = [];
|
|
879
|
+
if (isCollaboration) {
|
|
880
|
+
const participants = [];
|
|
881
|
+
const processes = [];
|
|
882
|
+
for (const pool of poolNodes) {
|
|
883
|
+
const processId = `Process_${pool.id}`;
|
|
884
|
+
const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId);
|
|
885
|
+
processes.push(process);
|
|
886
|
+
const participant = moddle.create("bpmn:Participant", {
|
|
887
|
+
id: pool.id,
|
|
888
|
+
name: pool.data.label ?? "",
|
|
889
|
+
processRef: process
|
|
890
|
+
});
|
|
891
|
+
participants.push(participant);
|
|
892
|
+
}
|
|
893
|
+
const messageFlowEdges = edges.filter((e) => e.data?.edgeType === "messageFlow");
|
|
894
|
+
const conversationLinkEdges = edges.filter((e) => e.data?.edgeType === "conversationLink");
|
|
895
|
+
const messageFlows = messageFlowEdges.map(
|
|
896
|
+
(e) => moddle.create("bpmn:MessageFlow", {
|
|
897
|
+
id: e.id,
|
|
898
|
+
name: e.data?.label ?? "",
|
|
899
|
+
sourceRef: { id: e.source },
|
|
900
|
+
targetRef: { id: e.target }
|
|
901
|
+
})
|
|
902
|
+
);
|
|
903
|
+
const conversationLinks = conversationLinkEdges.map(
|
|
904
|
+
(e) => moddle.create("bpmn:ConversationLink", {
|
|
905
|
+
id: e.id,
|
|
906
|
+
sourceRef: { id: e.source },
|
|
907
|
+
targetRef: { id: e.target }
|
|
908
|
+
})
|
|
909
|
+
);
|
|
910
|
+
const collaboration = moddle.create("bpmn:Collaboration", {
|
|
911
|
+
id: `Collaboration_${defId}`,
|
|
912
|
+
participants,
|
|
913
|
+
messageFlows,
|
|
914
|
+
conversationLinks
|
|
915
|
+
});
|
|
916
|
+
rootElements.push(collaboration, ...processes);
|
|
917
|
+
} else {
|
|
918
|
+
const process = buildProcess(moddle, nodes, edges, void 0, laneNodes, "Process_1");
|
|
919
|
+
rootElements.push(process);
|
|
920
|
+
}
|
|
921
|
+
definitions.rootElements = rootElements;
|
|
922
|
+
return definitions;
|
|
923
|
+
}
|
|
924
|
+
function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId) {
|
|
925
|
+
const myNodes = poolId ? allNodes.filter(
|
|
926
|
+
(n) => n.parentId === poolId || laneNodes.some((l) => l.id === n.parentId && l.parentId === poolId)
|
|
927
|
+
) : allNodes.filter((n) => n.data.elementType !== "Pool" && n.data.elementType !== "Lane");
|
|
928
|
+
const myLanes = laneNodes.filter((l) => poolId ? l.parentId === poolId : true);
|
|
929
|
+
const flowElements = [];
|
|
930
|
+
for (const node of myNodes) {
|
|
931
|
+
const el = buildFlowElement(moddle, node);
|
|
932
|
+
if (el) flowElements.push(el);
|
|
933
|
+
}
|
|
934
|
+
const myNodeIds = new Set(myNodes.map((n) => n.id));
|
|
935
|
+
const myEdges = allEdges.filter(
|
|
936
|
+
(e) => (e.data?.edgeType === "sequenceFlow" || e.data?.edgeType === "association" || e.data?.edgeType === "dataAssociation") && myNodeIds.has(e.source) && myNodeIds.has(e.target)
|
|
937
|
+
);
|
|
938
|
+
for (const edge of myEdges) {
|
|
939
|
+
const edgeMeta = buildEdgeElement(moddle, edge);
|
|
940
|
+
if (edgeMeta) flowElements.push(edgeMeta);
|
|
941
|
+
}
|
|
942
|
+
const process = moddle.create("bpmn:Process", {
|
|
943
|
+
id: processId,
|
|
944
|
+
isExecutable: true,
|
|
945
|
+
flowElements
|
|
946
|
+
});
|
|
947
|
+
if (myLanes.length > 0) {
|
|
948
|
+
const laneElements = myLanes.map(
|
|
949
|
+
(l) => moddle.create("bpmn:Lane", {
|
|
950
|
+
id: l.id,
|
|
951
|
+
name: l.data.label ?? "",
|
|
952
|
+
flowNodeRef: myNodes.filter((n) => n.parentId === l.id).map((n) => ({ id: n.id }))
|
|
953
|
+
})
|
|
954
|
+
);
|
|
955
|
+
process.laneSet = moddle.create("bpmn:LaneSet", {
|
|
956
|
+
id: `LaneSet_${processId}`,
|
|
957
|
+
lanes: laneElements
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return process;
|
|
961
|
+
}
|
|
962
|
+
function buildFlowElement(moddle, node, _allNodes, _allEdges) {
|
|
963
|
+
const { elementType, label, trigger } = node.data;
|
|
964
|
+
if (elementType === "Pool" || elementType === "Lane") return null;
|
|
965
|
+
const moddleType = ELEMENT_TYPE_TO_MODDLE[elementType];
|
|
966
|
+
if (!moddleType) return null;
|
|
967
|
+
const attrs = {
|
|
968
|
+
id: node.id,
|
|
969
|
+
name: label ?? ""
|
|
970
|
+
};
|
|
971
|
+
if (trigger && trigger !== "none") {
|
|
972
|
+
const defType = TRIGGER_TO_EVENT_DEF[trigger];
|
|
973
|
+
if (defType) {
|
|
974
|
+
attrs.eventDefinitions = [moddle.create(defType, { id: uid("EventDef", node.id) })];
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
if (elementType === "SubProcess" && node.data.subProcessVariant === "transaction") {
|
|
978
|
+
return moddle.create("bpmn:Transaction", attrs);
|
|
979
|
+
}
|
|
980
|
+
if (elementType === "SubProcess" && node.data.subProcessVariant === "adhoc") {
|
|
981
|
+
return moddle.create("bpmn:AdHocSubProcess", attrs);
|
|
982
|
+
}
|
|
983
|
+
const element = moddle.create(moddleType, attrs);
|
|
984
|
+
const flowableAttrs = buildFlowableAttrs(node.data);
|
|
985
|
+
if (Object.keys(flowableAttrs).length > 0) {
|
|
986
|
+
element.$attrs = flowableAttrs;
|
|
987
|
+
}
|
|
988
|
+
return element;
|
|
989
|
+
}
|
|
990
|
+
function buildEdgeElement(moddle, edge) {
|
|
991
|
+
if (!edge.data) return null;
|
|
992
|
+
const moddleType = EDGE_TYPE_TO_MODDLE[edge.data.edgeType];
|
|
993
|
+
if (!moddleType) return null;
|
|
994
|
+
const attrs = {
|
|
995
|
+
id: edge.id,
|
|
996
|
+
name: edge.data.label ?? "",
|
|
997
|
+
sourceRef: { id: edge.source },
|
|
998
|
+
targetRef: { id: edge.target }
|
|
999
|
+
};
|
|
1000
|
+
if (edge.data.conditionExpression) {
|
|
1001
|
+
attrs.conditionExpression = moddle.create("bpmn:FormalExpression", {
|
|
1002
|
+
body: edge.data.conditionExpression
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
return moddle.create(moddleType, attrs);
|
|
1006
|
+
}
|
|
1007
|
+
function buildBpmnDI(moddle, definitions, nodes, edges) {
|
|
1008
|
+
const shapes = [];
|
|
1009
|
+
const edgeShapes = [];
|
|
1010
|
+
for (const node of nodes) {
|
|
1011
|
+
const meta = BPMN_ELEMENT_CATALOG[node.data.elementType];
|
|
1012
|
+
const w = node.width ?? meta?.defaultWidth ?? 120;
|
|
1013
|
+
const h = node.height ?? meta?.defaultHeight ?? 60;
|
|
1014
|
+
const bounds = moddle.create("dc:Bounds", {
|
|
1015
|
+
x: node.position.x,
|
|
1016
|
+
y: node.position.y,
|
|
1017
|
+
width: w,
|
|
1018
|
+
height: h
|
|
1019
|
+
});
|
|
1020
|
+
const shape = moddle.create("bpmndi:BPMNShape", {
|
|
1021
|
+
id: uid("BPMNShape", node.id),
|
|
1022
|
+
bpmnElement: { id: node.id },
|
|
1023
|
+
bounds
|
|
1024
|
+
});
|
|
1025
|
+
if (node.data.isExpanded !== void 0) {
|
|
1026
|
+
shape.isExpanded = node.data.isExpanded;
|
|
1027
|
+
}
|
|
1028
|
+
shapes.push(shape);
|
|
1029
|
+
}
|
|
1030
|
+
for (const edge of edges) {
|
|
1031
|
+
const waypoints = edge.data?.routingPoints?.map(
|
|
1032
|
+
(p) => moddle.create("dc:Point", { x: p.x, y: p.y })
|
|
1033
|
+
) ?? [];
|
|
1034
|
+
edgeShapes.push(
|
|
1035
|
+
moddle.create("bpmndi:BPMNEdge", {
|
|
1036
|
+
id: uid("BPMNEdge", edge.id),
|
|
1037
|
+
bpmnElement: { id: edge.id },
|
|
1038
|
+
waypoint: waypoints
|
|
1039
|
+
})
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
const rootEls = definitions.rootElements;
|
|
1043
|
+
const planeElement = rootEls?.[0];
|
|
1044
|
+
const plane = moddle.create("bpmndi:BPMNPlane", {
|
|
1045
|
+
id: "BPMNPlane_1",
|
|
1046
|
+
bpmnElement: planeElement ?? { id: "unknown" },
|
|
1047
|
+
planeElement: [...shapes, ...edgeShapes]
|
|
1048
|
+
});
|
|
1049
|
+
const diagram = moddle.create("bpmndi:BPMNDiagram", {
|
|
1050
|
+
id: "BPMNDiagram_1",
|
|
1051
|
+
plane
|
|
1052
|
+
});
|
|
1053
|
+
definitions.diagrams = [diagram];
|
|
1054
|
+
}
|
|
1055
|
+
async function serializeBpmnXml(nodes, edges, opts = {}) {
|
|
1056
|
+
const moddle = new bpmnModdle.BpmnModdle();
|
|
1057
|
+
const definitions = buildSemanticModel(moddle, nodes, edges, opts);
|
|
1058
|
+
buildBpmnDI(moddle, definitions, nodes, edges);
|
|
1059
|
+
const { xml } = await moddle.toXML(definitions, {
|
|
1060
|
+
format: opts.format ?? true
|
|
1061
|
+
});
|
|
1062
|
+
return xml;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
exports.parseBpmnXml = parseBpmnXml;
|
|
1066
|
+
exports.serializeBpmnXml = serializeBpmnXml;
|
|
1067
|
+
//# sourceMappingURL=index.cjs.map
|
|
1068
|
+
//# sourceMappingURL=index.cjs.map
|