@aranzatech/diagrams-bpmn 0.2.4 → 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.
- package/dist/{catalog-m8fHIiKH.d.cts → catalog-CZsXqhL9.d.cts} +1 -1
- package/dist/{catalog-DIBySQqA.d.ts → catalog-Clz8sN9x.d.ts} +1 -1
- package/dist/{chunk-33AR3PXF.js → chunk-L64NM77A.js} +290 -20
- package/dist/chunk-L64NM77A.js.map +1 -0
- package/dist/{chunk-QOGZITWB.js → chunk-M46UDUN3.js} +2 -2
- package/dist/{chunk-QOGZITWB.js.map → chunk-M46UDUN3.js.map} +1 -1
- package/dist/{chunk-7MKU37XQ.js → chunk-XTUYPA3E.js} +191 -15
- package/dist/chunk-XTUYPA3E.js.map +1 -0
- package/dist/elements/index.d.cts +3 -3
- package/dist/elements/index.d.ts +3 -3
- package/dist/index.cjs +477 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -4
- package/dist/modeling/index.cjs +197 -10
- package/dist/modeling/index.cjs.map +1 -1
- package/dist/modeling/index.d.cts +103 -7
- package/dist/modeling/index.d.ts +103 -7
- package/dist/modeling/index.js +1 -1
- package/dist/simulation/index.cjs.map +1 -1
- package/dist/simulation/index.d.cts +36 -0
- package/dist/simulation/index.d.ts +36 -0
- package/dist/simulation/index.js +1 -1
- package/dist/{types-DznxZxpV.d.cts → types-BPqNeIU-.d.cts} +63 -1
- package/dist/{types-DznxZxpV.d.ts → types-BPqNeIU-.d.ts} +63 -1
- package/dist/{types-BxjCV2oX.d.ts → types-D0Flgue2.d.ts} +11 -2
- package/dist/{types-vVi5T7qj.d.cts → types-exnfq24-.d.cts} +11 -2
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +7 -2
- package/dist/validation/index.d.ts +7 -2
- package/dist/validation/index.js +224 -3
- package/dist/validation/index.js.map +1 -1
- package/dist/xml/index.cjs +287 -20
- package/dist/xml/index.cjs.map +1 -1
- package/dist/xml/index.d.cts +18 -2
- package/dist/xml/index.d.ts +18 -2
- package/dist/xml/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-33AR3PXF.js.map +0 -1
- package/dist/chunk-7MKU37XQ.js.map +0 -1
- package/dist/chunk-ZFGQVLHB.js +0 -226
- package/dist/chunk-ZFGQVLHB.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-BPqNeIU-.cjs';
|
|
2
2
|
|
|
3
3
|
declare const BPMN_ELEMENT_CATALOG: Record<BpmnElementType, BpmnElementMeta>;
|
|
4
4
|
declare function getElementMeta(type: BpmnElementType): BpmnElementMeta;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as BpmnElementType, d as BpmnElementMeta, e as BpmnElementSize } from './types-BPqNeIU-.js';
|
|
2
2
|
|
|
3
3
|
declare const BPMN_ELEMENT_CATALOG: Record<BpmnElementType, BpmnElementMeta>;
|
|
4
4
|
declare function getElementMeta(type: BpmnElementType): BpmnElementMeta;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { BPMN_ELEMENT_CATALOG } from './chunk-L5Z22RLX.js';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// src/xml/aranza-descriptor.ts
|
|
4
|
+
var ARANZA_DESCRIPTOR = {
|
|
5
|
+
name: "Aranza",
|
|
6
|
+
uri: "http://aranzatech.io/schema/bpmn-extension/1.0",
|
|
7
|
+
prefix: "aranza",
|
|
8
|
+
xml: { tagAlias: "lowerCase" },
|
|
9
|
+
types: [
|
|
10
|
+
{
|
|
11
|
+
name: "TaskConfig",
|
|
12
|
+
superClass: ["Element"],
|
|
13
|
+
properties: [
|
|
14
|
+
{ name: "priority", isAttr: true, type: "String" },
|
|
15
|
+
{ name: "owner", isAttr: true, type: "String" },
|
|
16
|
+
{ name: "sla", isAttr: true, type: "String" }
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
enumerations: [],
|
|
21
|
+
associations: []
|
|
22
|
+
};
|
|
3
23
|
|
|
4
24
|
// src/xml/mapper.ts
|
|
5
25
|
var MODDLE_TO_ELEMENT_TYPE = {
|
|
@@ -182,9 +202,84 @@ function extractLaneMembership(process) {
|
|
|
182
202
|
function extractTrigger(el) {
|
|
183
203
|
const defs = asElements(el.eventDefinitions);
|
|
184
204
|
if (defs.length === 0) return void 0;
|
|
185
|
-
if (defs.length > 1)
|
|
205
|
+
if (defs.length > 1) {
|
|
206
|
+
return defs.some((def) => def.$type === "bpmn:ParallelMultipleEventDefinition") ? "parallelMultiple" : "multiple";
|
|
207
|
+
}
|
|
186
208
|
return EVENT_DEF_TO_TRIGGER[defs[0].$type];
|
|
187
209
|
}
|
|
210
|
+
function parseVariableType(value) {
|
|
211
|
+
const text = asString(value) ?? "";
|
|
212
|
+
if (text.includes("int")) return "integer";
|
|
213
|
+
if (text.includes("boolean")) return "boolean";
|
|
214
|
+
if (text.includes("date")) return "date";
|
|
215
|
+
if (text.includes("array")) return "array";
|
|
216
|
+
if (text.includes("anyType")) return "object";
|
|
217
|
+
return "string";
|
|
218
|
+
}
|
|
219
|
+
function extractEventDefinition(el) {
|
|
220
|
+
const defs = asElements(el.eventDefinitions);
|
|
221
|
+
if (defs.length === 0) return void 0;
|
|
222
|
+
if (defs.length > 1) {
|
|
223
|
+
return {
|
|
224
|
+
type: defs.some((def2) => def2.$type === "bpmn:ParallelMultipleEventDefinition") ? "parallelMultiple" : "multiple"
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const [def] = defs;
|
|
228
|
+
const type = EVENT_DEF_TO_TRIGGER[def.$type];
|
|
229
|
+
if (!type) return void 0;
|
|
230
|
+
const eventDefinition = {
|
|
231
|
+
type,
|
|
232
|
+
...asString(def.messageRef?.id) ? { messageRef: def.messageRef.id } : {},
|
|
233
|
+
...asString(def.signalRef?.id) ? { signalRef: def.signalRef.id } : {},
|
|
234
|
+
...asString(def.errorRef?.id) ? { errorRef: def.errorRef.id } : {},
|
|
235
|
+
...asString(def.escalationRef?.id) ? { escalationRef: def.escalationRef.id } : {},
|
|
236
|
+
...asString(def.condition?.body) ? { conditionExpression: def.condition.body } : {}
|
|
237
|
+
};
|
|
238
|
+
const timeDate = asString(def.timeDate?.body);
|
|
239
|
+
const timeDuration = asString(def.timeDuration?.body);
|
|
240
|
+
const timeCycle = asString(def.timeCycle?.body);
|
|
241
|
+
if (timeDate) eventDefinition.timer = { kind: "date", value: timeDate };
|
|
242
|
+
else if (timeCycle) eventDefinition.timer = { kind: "cycle", value: timeCycle };
|
|
243
|
+
else if (timeDuration) eventDefinition.timer = { kind: "duration", value: timeDuration };
|
|
244
|
+
if (type === "link") {
|
|
245
|
+
const linkName = asString(el.name) ?? asString(def.name);
|
|
246
|
+
if (linkName) eventDefinition.linkName = linkName;
|
|
247
|
+
}
|
|
248
|
+
return eventDefinition;
|
|
249
|
+
}
|
|
250
|
+
function extractDefinitions(rootElement) {
|
|
251
|
+
const definitions = {};
|
|
252
|
+
const rootElements = asElements(rootElement.rootElements);
|
|
253
|
+
const messages = rootElements.filter((element) => element.$type === "bpmn:Message" && asString(element.id)).map((message) => ({
|
|
254
|
+
id: message.id,
|
|
255
|
+
name: asString(message.name) ?? message.id
|
|
256
|
+
}));
|
|
257
|
+
if (messages.length > 0) definitions.messages = messages;
|
|
258
|
+
const signals = rootElements.filter((element) => element.$type === "bpmn:Signal" && asString(element.id)).map((signal) => ({
|
|
259
|
+
id: signal.id,
|
|
260
|
+
name: asString(signal.name) ?? signal.id
|
|
261
|
+
}));
|
|
262
|
+
if (signals.length > 0) definitions.signals = signals;
|
|
263
|
+
const errors = rootElements.filter((element) => element.$type === "bpmn:Error" && asString(element.id)).map((error) => ({
|
|
264
|
+
id: error.id,
|
|
265
|
+
name: asString(error.name) ?? error.id,
|
|
266
|
+
...asString(error.errorCode) ? { errorCode: error.errorCode } : {}
|
|
267
|
+
}));
|
|
268
|
+
if (errors.length > 0) definitions.errors = errors;
|
|
269
|
+
const escalations = rootElements.filter((element) => element.$type === "bpmn:Escalation" && asString(element.id)).map((escalation) => ({
|
|
270
|
+
id: escalation.id,
|
|
271
|
+
name: asString(escalation.name) ?? escalation.id,
|
|
272
|
+
...asString(escalation.escalationCode) ? { escalationCode: escalation.escalationCode } : {}
|
|
273
|
+
}));
|
|
274
|
+
if (escalations.length > 0) definitions.escalations = escalations;
|
|
275
|
+
const itemDefinitions = asElements(rootElement.itemDefinitions).filter((item) => asString(item.id)).map((item) => ({
|
|
276
|
+
id: String(item.id).replace(/_item$/, ""),
|
|
277
|
+
name: String(item.id).replace(/_item$/, ""),
|
|
278
|
+
type: parseVariableType(item.structureRef)
|
|
279
|
+
}));
|
|
280
|
+
if (itemDefinitions.length > 0) definitions.variables = itemDefinitions;
|
|
281
|
+
return Object.keys(definitions).length > 0 ? definitions : void 0;
|
|
282
|
+
}
|
|
188
283
|
function extractSubProcessVariant(el) {
|
|
189
284
|
if (el.$type === "bpmn:Transaction") return "transaction";
|
|
190
285
|
if (el.$type === "bpmn:AdHocSubProcess") return "adhoc";
|
|
@@ -192,6 +287,22 @@ function extractSubProcessVariant(el) {
|
|
|
192
287
|
if (el.triggeredByEvent === true) return "event";
|
|
193
288
|
return "embedded";
|
|
194
289
|
}
|
|
290
|
+
function extractAranzaExtensions(el) {
|
|
291
|
+
const ext = el.extensionElements;
|
|
292
|
+
if (!ext) return {};
|
|
293
|
+
const taskConfig = asElements(ext.values).find((v) => v.$type === "aranza:TaskConfig");
|
|
294
|
+
if (!taskConfig) return {};
|
|
295
|
+
const result = {};
|
|
296
|
+
const priority = asString(taskConfig.priority);
|
|
297
|
+
if (priority === "critical" || priority === "high" || priority === "medium" || priority === "low") {
|
|
298
|
+
result.priority = priority;
|
|
299
|
+
}
|
|
300
|
+
const owner = asString(taskConfig.owner);
|
|
301
|
+
if (owner) result.owner = owner;
|
|
302
|
+
const sla = asString(taskConfig.sla);
|
|
303
|
+
if (sla) result.sla = sla;
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
195
306
|
function walkFlowElements(elements, parentId, ctx, nodes, edges) {
|
|
196
307
|
for (const el of elements) {
|
|
197
308
|
const { $type, id } = el;
|
|
@@ -225,15 +336,29 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
|
|
|
225
336
|
const label = asString(el.name);
|
|
226
337
|
const documentation = extractDocumentation(el);
|
|
227
338
|
const trigger = extractTrigger(el);
|
|
339
|
+
const eventDefinition = extractEventDefinition(el);
|
|
228
340
|
const isNonInterrupting = el.cancelActivity === false;
|
|
229
341
|
const attachedToRef = el.attachedToRef?.id;
|
|
342
|
+
const calledElement = elementType === "CallActivity" ? asString(el.calledElement) : void 0;
|
|
343
|
+
const aranzaExt = extractAranzaExtensions(el);
|
|
230
344
|
const data = {
|
|
231
345
|
elementType,
|
|
232
346
|
...label ? { label } : {},
|
|
233
347
|
...documentation ? { documentation } : {},
|
|
234
348
|
...trigger ? { trigger } : {},
|
|
349
|
+
...eventDefinition ? { eventDefinition } : {},
|
|
235
350
|
...isNonInterrupting ? { isNonInterrupting: true } : {},
|
|
236
|
-
...
|
|
351
|
+
...elementType === "BoundaryEvent" ? { cancelActivity: el.cancelActivity !== false } : {},
|
|
352
|
+
...attachedToRef ? { attachedToRef } : {},
|
|
353
|
+
...eventDefinition?.timer ? { timer: eventDefinition.timer, timerExpression: eventDefinition.timer } : {},
|
|
354
|
+
...eventDefinition?.messageRef ? { messageRef: eventDefinition.messageRef } : {},
|
|
355
|
+
...eventDefinition?.signalRef ? { signalRef: eventDefinition.signalRef } : {},
|
|
356
|
+
...eventDefinition?.errorRef ? { errorRef: eventDefinition.errorRef } : {},
|
|
357
|
+
...eventDefinition?.escalationRef ? { escalationRef: eventDefinition.escalationRef } : {},
|
|
358
|
+
...eventDefinition?.conditionExpression ? { conditionExpression: eventDefinition.conditionExpression } : {},
|
|
359
|
+
...eventDefinition?.linkName ? { linkName: eventDefinition.linkName } : {},
|
|
360
|
+
...calledElement ? { calledElement } : {},
|
|
361
|
+
...aranzaExt
|
|
237
362
|
};
|
|
238
363
|
if (elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess") {
|
|
239
364
|
const variant = extractSubProcessVariant(el);
|
|
@@ -333,7 +458,8 @@ function addLaneNodes(laneSet, poolId, ctx, nodes) {
|
|
|
333
458
|
}
|
|
334
459
|
}
|
|
335
460
|
async function parseBpmnXml(xml) {
|
|
336
|
-
const
|
|
461
|
+
const { BpmnModdle } = await import('bpmn-moddle');
|
|
462
|
+
const moddle = new BpmnModdle({ aranza: ARANZA_DESCRIPTOR });
|
|
337
463
|
const warnings = [];
|
|
338
464
|
let rootElement;
|
|
339
465
|
try {
|
|
@@ -383,10 +509,23 @@ async function parseBpmnXml(xml) {
|
|
|
383
509
|
};
|
|
384
510
|
return { ...edge, data };
|
|
385
511
|
});
|
|
512
|
+
const firstProcess = asElements(rootElement.rootElements).find((rootEl) => rootEl.$type === "bpmn:Process");
|
|
513
|
+
const importedDefinitions = extractDefinitions(rootElement);
|
|
514
|
+
const process = firstProcess ? (() => {
|
|
515
|
+
const importedProcess = {};
|
|
516
|
+
const processId = asString(firstProcess.id);
|
|
517
|
+
const documentation = extractDocumentation(firstProcess);
|
|
518
|
+
if (processId) importedProcess.processId = processId;
|
|
519
|
+
if (typeof firstProcess.isExecutable === "boolean") importedProcess.executable = firstProcess.isExecutable;
|
|
520
|
+
if (documentation) importedProcess.documentation = documentation;
|
|
521
|
+
if (importedDefinitions) importedProcess.definitions = importedDefinitions;
|
|
522
|
+
return importedProcess;
|
|
523
|
+
})() : importedDefinitions ? { definitions: importedDefinitions } : void 0;
|
|
386
524
|
return {
|
|
387
525
|
nodes: normalizeChildPositions(nodes, nodeIds),
|
|
388
526
|
edges: normalizedEdges,
|
|
389
|
-
warnings
|
|
527
|
+
warnings,
|
|
528
|
+
...process ? { process } : {}
|
|
390
529
|
};
|
|
391
530
|
}
|
|
392
531
|
function collectDefaultFlows(el, defaultFlowById) {
|
|
@@ -410,12 +549,117 @@ function normalizeChildPositions(nodes, nodeIds) {
|
|
|
410
549
|
};
|
|
411
550
|
});
|
|
412
551
|
}
|
|
552
|
+
|
|
553
|
+
// src/xml/exporter.ts
|
|
413
554
|
function uid(prefix, id) {
|
|
414
555
|
return `${prefix}_${id}`;
|
|
415
556
|
}
|
|
416
557
|
function asNodes(nodes, types) {
|
|
417
558
|
return nodes.filter((n) => types.includes(n.data.elementType));
|
|
418
559
|
}
|
|
560
|
+
function normalizeEventDefinition(data) {
|
|
561
|
+
const trigger = data.eventDefinition?.type ?? data.trigger;
|
|
562
|
+
if (!trigger || trigger === "none") return void 0;
|
|
563
|
+
const normalized = { type: trigger };
|
|
564
|
+
const timer = data.eventDefinition?.timer ?? data.timer ?? data.timerExpression;
|
|
565
|
+
const messageRef = data.eventDefinition?.messageRef ?? (typeof data.messageRef === "string" ? data.messageRef : void 0);
|
|
566
|
+
const signalRef = data.eventDefinition?.signalRef ?? (typeof data.signalRef === "string" ? data.signalRef : void 0);
|
|
567
|
+
const errorRef = data.eventDefinition?.errorRef ?? (typeof data.errorRef === "string" ? data.errorRef : void 0);
|
|
568
|
+
const escalationRef = data.eventDefinition?.escalationRef ?? (typeof data.escalationRef === "string" ? data.escalationRef : void 0);
|
|
569
|
+
const conditionExpression = data.eventDefinition?.conditionExpression ?? (typeof data.conditionExpression === "string" ? data.conditionExpression : void 0);
|
|
570
|
+
const linkName = data.eventDefinition?.linkName ?? (typeof data.linkName === "string" ? data.linkName : void 0);
|
|
571
|
+
if (timer) normalized.timer = timer;
|
|
572
|
+
if (messageRef) normalized.messageRef = messageRef;
|
|
573
|
+
if (signalRef) normalized.signalRef = signalRef;
|
|
574
|
+
if (errorRef) normalized.errorRef = errorRef;
|
|
575
|
+
if (escalationRef) normalized.escalationRef = escalationRef;
|
|
576
|
+
if (conditionExpression) normalized.conditionExpression = conditionExpression;
|
|
577
|
+
if (linkName) normalized.linkName = linkName;
|
|
578
|
+
return normalized;
|
|
579
|
+
}
|
|
580
|
+
function parseVariableType2(type) {
|
|
581
|
+
switch (type) {
|
|
582
|
+
case "integer":
|
|
583
|
+
return "xsd:int";
|
|
584
|
+
case "boolean":
|
|
585
|
+
return "xsd:boolean";
|
|
586
|
+
case "date":
|
|
587
|
+
return "xsd:dateTime";
|
|
588
|
+
case "object":
|
|
589
|
+
return "xsd:anyType";
|
|
590
|
+
case "array":
|
|
591
|
+
return "xsd:anyType";
|
|
592
|
+
default:
|
|
593
|
+
return "xsd:string";
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function buildGlobalDefinitions(moddle, definitionsSet) {
|
|
597
|
+
if (!definitionsSet) return [];
|
|
598
|
+
const rootElements = [];
|
|
599
|
+
for (const message of definitionsSet.messages ?? []) {
|
|
600
|
+
rootElements.push(moddle.create("bpmn:Message", { id: message.id, name: message.name }));
|
|
601
|
+
}
|
|
602
|
+
for (const signal of definitionsSet.signals ?? []) {
|
|
603
|
+
rootElements.push(moddle.create("bpmn:Signal", { id: signal.id, name: signal.name }));
|
|
604
|
+
}
|
|
605
|
+
for (const error of definitionsSet.errors ?? []) {
|
|
606
|
+
rootElements.push(moddle.create("bpmn:Error", {
|
|
607
|
+
id: error.id,
|
|
608
|
+
name: error.name,
|
|
609
|
+
...error.errorCode ? { errorCode: error.errorCode } : {}
|
|
610
|
+
}));
|
|
611
|
+
}
|
|
612
|
+
for (const escalation of definitionsSet.escalations ?? []) {
|
|
613
|
+
rootElements.push(moddle.create("bpmn:Escalation", {
|
|
614
|
+
id: escalation.id,
|
|
615
|
+
name: escalation.name,
|
|
616
|
+
...escalation.escalationCode ? { escalationCode: escalation.escalationCode } : {}
|
|
617
|
+
}));
|
|
618
|
+
}
|
|
619
|
+
return rootElements;
|
|
620
|
+
}
|
|
621
|
+
function buildItemDefinitions(moddle, variables) {
|
|
622
|
+
return (variables ?? []).map(
|
|
623
|
+
(variable) => moddle.create("bpmn:ItemDefinition", {
|
|
624
|
+
id: `${variable.id}_item`,
|
|
625
|
+
itemKind: "Information",
|
|
626
|
+
structureRef: parseVariableType2(variable.type)
|
|
627
|
+
})
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
function buildEventDefinitions(moddle, node, eventDefinition) {
|
|
631
|
+
if (eventDefinition.type === "multiple" || eventDefinition.type === "parallelMultiple") {
|
|
632
|
+
return [];
|
|
633
|
+
}
|
|
634
|
+
const defType = TRIGGER_TO_EVENT_DEF[eventDefinition.type];
|
|
635
|
+
if (!defType) return [];
|
|
636
|
+
const attrs = { id: uid("EventDef", node.id) };
|
|
637
|
+
if (eventDefinition.messageRef) attrs.messageRef = { id: eventDefinition.messageRef };
|
|
638
|
+
if (eventDefinition.signalRef) attrs.signalRef = { id: eventDefinition.signalRef };
|
|
639
|
+
if (eventDefinition.errorRef) attrs.errorRef = { id: eventDefinition.errorRef };
|
|
640
|
+
if (eventDefinition.escalationRef) attrs.escalationRef = { id: eventDefinition.escalationRef };
|
|
641
|
+
if (eventDefinition.conditionExpression) {
|
|
642
|
+
attrs.condition = moddle.create("bpmn:FormalExpression", {
|
|
643
|
+
body: eventDefinition.conditionExpression
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
if (eventDefinition.timer?.value) {
|
|
647
|
+
attrs[eventDefinition.timer.kind === "date" ? "timeDate" : eventDefinition.timer.kind === "cycle" ? "timeCycle" : "timeDuration"] = moddle.create("bpmn:FormalExpression", {
|
|
648
|
+
body: eventDefinition.timer.value
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return [moddle.create(defType, attrs)];
|
|
652
|
+
}
|
|
653
|
+
function buildAranzaExtensionElements(moddle, node) {
|
|
654
|
+
const { priority, owner, sla } = node.data;
|
|
655
|
+
if (!priority && !owner && !sla) return null;
|
|
656
|
+
const configAttrs = {};
|
|
657
|
+
if (priority) configAttrs.priority = priority;
|
|
658
|
+
if (owner) configAttrs.owner = owner;
|
|
659
|
+
if (sla) configAttrs.sla = sla;
|
|
660
|
+
const taskConfig = moddle.create("aranza:TaskConfig", configAttrs);
|
|
661
|
+
return moddle.create("bpmn:ExtensionElements", { values: [taskConfig] });
|
|
662
|
+
}
|
|
419
663
|
function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
420
664
|
const defId = opts.id ?? "Definitions_1";
|
|
421
665
|
const defName = opts.name;
|
|
@@ -427,13 +671,19 @@ function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
|
427
671
|
targetNamespace: "http://bpmn.io/schema/bpmn",
|
|
428
672
|
...defName ? { name: defName } : {}
|
|
429
673
|
});
|
|
430
|
-
const rootElements = [
|
|
674
|
+
const rootElements = [
|
|
675
|
+
...buildGlobalDefinitions(moddle, opts.process?.definitions)
|
|
676
|
+
];
|
|
677
|
+
const itemDefinitions = buildItemDefinitions(moddle, opts.process?.definitions?.variables);
|
|
678
|
+
if (itemDefinitions.length > 0) {
|
|
679
|
+
definitions.itemDefinitions = itemDefinitions;
|
|
680
|
+
}
|
|
431
681
|
if (isCollaboration) {
|
|
432
682
|
const participants = [];
|
|
433
683
|
const processes = [];
|
|
434
684
|
for (const pool of poolNodes) {
|
|
435
685
|
const processId = `Process_${pool.id}`;
|
|
436
|
-
const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId);
|
|
686
|
+
const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId, opts);
|
|
437
687
|
processes.push(process);
|
|
438
688
|
const participant = moddle.create("bpmn:Participant", {
|
|
439
689
|
id: pool.id,
|
|
@@ -467,13 +717,21 @@ function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
|
467
717
|
});
|
|
468
718
|
rootElements.push(collaboration, ...processes);
|
|
469
719
|
} else {
|
|
470
|
-
const process = buildProcess(
|
|
720
|
+
const process = buildProcess(
|
|
721
|
+
moddle,
|
|
722
|
+
nodes,
|
|
723
|
+
edges,
|
|
724
|
+
void 0,
|
|
725
|
+
laneNodes,
|
|
726
|
+
opts.process?.processId ?? "Process_1",
|
|
727
|
+
opts
|
|
728
|
+
);
|
|
471
729
|
rootElements.push(process);
|
|
472
730
|
}
|
|
473
731
|
definitions.rootElements = rootElements;
|
|
474
732
|
return definitions;
|
|
475
733
|
}
|
|
476
|
-
function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId) {
|
|
734
|
+
function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId, opts) {
|
|
477
735
|
const subProcessIds = new Set(
|
|
478
736
|
allNodes.filter(
|
|
479
737
|
(n) => n.data.elementType === "SubProcess" || n.data.elementType === "Transaction" || n.data.elementType === "EventSubProcess" || n.data.elementType === "AdHocSubProcess"
|
|
@@ -523,9 +781,14 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId)
|
|
|
523
781
|
}
|
|
524
782
|
const process = moddle.create("bpmn:Process", {
|
|
525
783
|
id: processId,
|
|
526
|
-
isExecutable: true,
|
|
784
|
+
isExecutable: opts.process?.executable ?? true,
|
|
527
785
|
flowElements
|
|
528
786
|
});
|
|
787
|
+
if (opts.process?.documentation) {
|
|
788
|
+
process.documentation = [
|
|
789
|
+
moddle.create("bpmn:Documentation", { text: opts.process.documentation })
|
|
790
|
+
];
|
|
791
|
+
}
|
|
529
792
|
if (myLanes.length > 0) {
|
|
530
793
|
const laneElements = myLanes.map(
|
|
531
794
|
(l) => moddle.create("bpmn:Lane", {
|
|
@@ -542,7 +805,8 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId)
|
|
|
542
805
|
return process;
|
|
543
806
|
}
|
|
544
807
|
function buildFlowElement(moddle, node, allNodes, allEdges) {
|
|
545
|
-
const { elementType, label
|
|
808
|
+
const { elementType, label } = node.data;
|
|
809
|
+
const eventDefinition = normalizeEventDefinition(node.data);
|
|
546
810
|
if (elementType === "Pool" || elementType === "Lane") return null;
|
|
547
811
|
const moddleType = ELEMENT_TYPE_TO_MODDLE[elementType];
|
|
548
812
|
if (!moddleType) return null;
|
|
@@ -555,16 +819,21 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
|
|
|
555
819
|
moddle.create("bpmn:Documentation", { text: node.data.documentation })
|
|
556
820
|
];
|
|
557
821
|
}
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
|
|
562
|
-
}
|
|
822
|
+
if (eventDefinition) {
|
|
823
|
+
const eventDefinitions = buildEventDefinitions(moddle, node, eventDefinition);
|
|
824
|
+
if (eventDefinitions.length > 0) attrs.eventDefinitions = eventDefinitions;
|
|
825
|
+
if (eventDefinition.linkName) attrs.name = eventDefinition.linkName;
|
|
563
826
|
}
|
|
564
827
|
if (elementType === "BoundaryEvent") {
|
|
565
828
|
attrs.attachedToRef = { id: node.data.attachedToRef ?? node.parentId };
|
|
566
|
-
|
|
829
|
+
const interrupting = node.data.cancelActivity ?? !node.data.isNonInterrupting;
|
|
830
|
+
attrs.cancelActivity = interrupting;
|
|
831
|
+
}
|
|
832
|
+
if (elementType === "CallActivity" && node.data.calledElement) {
|
|
833
|
+
attrs.calledElement = node.data.calledElement;
|
|
567
834
|
}
|
|
835
|
+
const aranzaConfig = buildAranzaExtensionElements(moddle, node);
|
|
836
|
+
if (aranzaConfig) attrs.extensionElements = aranzaConfig;
|
|
568
837
|
const isSubProcess = elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess";
|
|
569
838
|
if (isSubProcess) {
|
|
570
839
|
attrs.flowElements = buildNestedFlowElements(moddle, node, allNodes, allEdges);
|
|
@@ -702,7 +971,8 @@ function buildAbsolutePositionMap(nodes) {
|
|
|
702
971
|
return absoluteById;
|
|
703
972
|
}
|
|
704
973
|
async function serializeBpmnXml(nodes, edges, opts = {}) {
|
|
705
|
-
const
|
|
974
|
+
const { BpmnModdle } = await import('bpmn-moddle');
|
|
975
|
+
const moddle = new BpmnModdle({ aranza: ARANZA_DESCRIPTOR });
|
|
706
976
|
const definitions = buildSemanticModel(moddle, nodes, edges, opts);
|
|
707
977
|
buildBpmnDI(moddle, definitions, nodes, edges);
|
|
708
978
|
const { xml } = await moddle.toXML(definitions, {
|
|
@@ -712,5 +982,5 @@ async function serializeBpmnXml(nodes, edges, opts = {}) {
|
|
|
712
982
|
}
|
|
713
983
|
|
|
714
984
|
export { parseBpmnXml, serializeBpmnXml };
|
|
715
|
-
//# sourceMappingURL=chunk-
|
|
716
|
-
//# sourceMappingURL=chunk-
|
|
985
|
+
//# sourceMappingURL=chunk-L64NM77A.js.map
|
|
986
|
+
//# sourceMappingURL=chunk-L64NM77A.js.map
|