@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
package/dist/xml/index.cjs
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
};
|
|
6
23
|
|
|
7
24
|
// src/elements/catalog.ts
|
|
8
25
|
var BPMN_ELEMENT_CATALOG = {
|
|
@@ -775,9 +792,84 @@ function extractLaneMembership(process) {
|
|
|
775
792
|
function extractTrigger(el) {
|
|
776
793
|
const defs = asElements(el.eventDefinitions);
|
|
777
794
|
if (defs.length === 0) return void 0;
|
|
778
|
-
if (defs.length > 1)
|
|
795
|
+
if (defs.length > 1) {
|
|
796
|
+
return defs.some((def) => def.$type === "bpmn:ParallelMultipleEventDefinition") ? "parallelMultiple" : "multiple";
|
|
797
|
+
}
|
|
779
798
|
return EVENT_DEF_TO_TRIGGER[defs[0].$type];
|
|
780
799
|
}
|
|
800
|
+
function parseVariableType(value) {
|
|
801
|
+
const text = asString(value) ?? "";
|
|
802
|
+
if (text.includes("int")) return "integer";
|
|
803
|
+
if (text.includes("boolean")) return "boolean";
|
|
804
|
+
if (text.includes("date")) return "date";
|
|
805
|
+
if (text.includes("array")) return "array";
|
|
806
|
+
if (text.includes("anyType")) return "object";
|
|
807
|
+
return "string";
|
|
808
|
+
}
|
|
809
|
+
function extractEventDefinition(el) {
|
|
810
|
+
const defs = asElements(el.eventDefinitions);
|
|
811
|
+
if (defs.length === 0) return void 0;
|
|
812
|
+
if (defs.length > 1) {
|
|
813
|
+
return {
|
|
814
|
+
type: defs.some((def2) => def2.$type === "bpmn:ParallelMultipleEventDefinition") ? "parallelMultiple" : "multiple"
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
const [def] = defs;
|
|
818
|
+
const type = EVENT_DEF_TO_TRIGGER[def.$type];
|
|
819
|
+
if (!type) return void 0;
|
|
820
|
+
const eventDefinition = {
|
|
821
|
+
type,
|
|
822
|
+
...asString(def.messageRef?.id) ? { messageRef: def.messageRef.id } : {},
|
|
823
|
+
...asString(def.signalRef?.id) ? { signalRef: def.signalRef.id } : {},
|
|
824
|
+
...asString(def.errorRef?.id) ? { errorRef: def.errorRef.id } : {},
|
|
825
|
+
...asString(def.escalationRef?.id) ? { escalationRef: def.escalationRef.id } : {},
|
|
826
|
+
...asString(def.condition?.body) ? { conditionExpression: def.condition.body } : {}
|
|
827
|
+
};
|
|
828
|
+
const timeDate = asString(def.timeDate?.body);
|
|
829
|
+
const timeDuration = asString(def.timeDuration?.body);
|
|
830
|
+
const timeCycle = asString(def.timeCycle?.body);
|
|
831
|
+
if (timeDate) eventDefinition.timer = { kind: "date", value: timeDate };
|
|
832
|
+
else if (timeCycle) eventDefinition.timer = { kind: "cycle", value: timeCycle };
|
|
833
|
+
else if (timeDuration) eventDefinition.timer = { kind: "duration", value: timeDuration };
|
|
834
|
+
if (type === "link") {
|
|
835
|
+
const linkName = asString(el.name) ?? asString(def.name);
|
|
836
|
+
if (linkName) eventDefinition.linkName = linkName;
|
|
837
|
+
}
|
|
838
|
+
return eventDefinition;
|
|
839
|
+
}
|
|
840
|
+
function extractDefinitions(rootElement) {
|
|
841
|
+
const definitions = {};
|
|
842
|
+
const rootElements = asElements(rootElement.rootElements);
|
|
843
|
+
const messages = rootElements.filter((element) => element.$type === "bpmn:Message" && asString(element.id)).map((message) => ({
|
|
844
|
+
id: message.id,
|
|
845
|
+
name: asString(message.name) ?? message.id
|
|
846
|
+
}));
|
|
847
|
+
if (messages.length > 0) definitions.messages = messages;
|
|
848
|
+
const signals = rootElements.filter((element) => element.$type === "bpmn:Signal" && asString(element.id)).map((signal) => ({
|
|
849
|
+
id: signal.id,
|
|
850
|
+
name: asString(signal.name) ?? signal.id
|
|
851
|
+
}));
|
|
852
|
+
if (signals.length > 0) definitions.signals = signals;
|
|
853
|
+
const errors = rootElements.filter((element) => element.$type === "bpmn:Error" && asString(element.id)).map((error) => ({
|
|
854
|
+
id: error.id,
|
|
855
|
+
name: asString(error.name) ?? error.id,
|
|
856
|
+
...asString(error.errorCode) ? { errorCode: error.errorCode } : {}
|
|
857
|
+
}));
|
|
858
|
+
if (errors.length > 0) definitions.errors = errors;
|
|
859
|
+
const escalations = rootElements.filter((element) => element.$type === "bpmn:Escalation" && asString(element.id)).map((escalation) => ({
|
|
860
|
+
id: escalation.id,
|
|
861
|
+
name: asString(escalation.name) ?? escalation.id,
|
|
862
|
+
...asString(escalation.escalationCode) ? { escalationCode: escalation.escalationCode } : {}
|
|
863
|
+
}));
|
|
864
|
+
if (escalations.length > 0) definitions.escalations = escalations;
|
|
865
|
+
const itemDefinitions = asElements(rootElement.itemDefinitions).filter((item) => asString(item.id)).map((item) => ({
|
|
866
|
+
id: String(item.id).replace(/_item$/, ""),
|
|
867
|
+
name: String(item.id).replace(/_item$/, ""),
|
|
868
|
+
type: parseVariableType(item.structureRef)
|
|
869
|
+
}));
|
|
870
|
+
if (itemDefinitions.length > 0) definitions.variables = itemDefinitions;
|
|
871
|
+
return Object.keys(definitions).length > 0 ? definitions : void 0;
|
|
872
|
+
}
|
|
781
873
|
function extractSubProcessVariant(el) {
|
|
782
874
|
if (el.$type === "bpmn:Transaction") return "transaction";
|
|
783
875
|
if (el.$type === "bpmn:AdHocSubProcess") return "adhoc";
|
|
@@ -785,6 +877,22 @@ function extractSubProcessVariant(el) {
|
|
|
785
877
|
if (el.triggeredByEvent === true) return "event";
|
|
786
878
|
return "embedded";
|
|
787
879
|
}
|
|
880
|
+
function extractAranzaExtensions(el) {
|
|
881
|
+
const ext = el.extensionElements;
|
|
882
|
+
if (!ext) return {};
|
|
883
|
+
const taskConfig = asElements(ext.values).find((v) => v.$type === "aranza:TaskConfig");
|
|
884
|
+
if (!taskConfig) return {};
|
|
885
|
+
const result = {};
|
|
886
|
+
const priority = asString(taskConfig.priority);
|
|
887
|
+
if (priority === "critical" || priority === "high" || priority === "medium" || priority === "low") {
|
|
888
|
+
result.priority = priority;
|
|
889
|
+
}
|
|
890
|
+
const owner = asString(taskConfig.owner);
|
|
891
|
+
if (owner) result.owner = owner;
|
|
892
|
+
const sla = asString(taskConfig.sla);
|
|
893
|
+
if (sla) result.sla = sla;
|
|
894
|
+
return result;
|
|
895
|
+
}
|
|
788
896
|
function walkFlowElements(elements, parentId, ctx, nodes, edges) {
|
|
789
897
|
for (const el of elements) {
|
|
790
898
|
const { $type, id } = el;
|
|
@@ -818,15 +926,29 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
|
|
|
818
926
|
const label = asString(el.name);
|
|
819
927
|
const documentation = extractDocumentation(el);
|
|
820
928
|
const trigger = extractTrigger(el);
|
|
929
|
+
const eventDefinition = extractEventDefinition(el);
|
|
821
930
|
const isNonInterrupting = el.cancelActivity === false;
|
|
822
931
|
const attachedToRef = el.attachedToRef?.id;
|
|
932
|
+
const calledElement = elementType === "CallActivity" ? asString(el.calledElement) : void 0;
|
|
933
|
+
const aranzaExt = extractAranzaExtensions(el);
|
|
823
934
|
const data = {
|
|
824
935
|
elementType,
|
|
825
936
|
...label ? { label } : {},
|
|
826
937
|
...documentation ? { documentation } : {},
|
|
827
938
|
...trigger ? { trigger } : {},
|
|
939
|
+
...eventDefinition ? { eventDefinition } : {},
|
|
828
940
|
...isNonInterrupting ? { isNonInterrupting: true } : {},
|
|
829
|
-
...
|
|
941
|
+
...elementType === "BoundaryEvent" ? { cancelActivity: el.cancelActivity !== false } : {},
|
|
942
|
+
...attachedToRef ? { attachedToRef } : {},
|
|
943
|
+
...eventDefinition?.timer ? { timer: eventDefinition.timer, timerExpression: eventDefinition.timer } : {},
|
|
944
|
+
...eventDefinition?.messageRef ? { messageRef: eventDefinition.messageRef } : {},
|
|
945
|
+
...eventDefinition?.signalRef ? { signalRef: eventDefinition.signalRef } : {},
|
|
946
|
+
...eventDefinition?.errorRef ? { errorRef: eventDefinition.errorRef } : {},
|
|
947
|
+
...eventDefinition?.escalationRef ? { escalationRef: eventDefinition.escalationRef } : {},
|
|
948
|
+
...eventDefinition?.conditionExpression ? { conditionExpression: eventDefinition.conditionExpression } : {},
|
|
949
|
+
...eventDefinition?.linkName ? { linkName: eventDefinition.linkName } : {},
|
|
950
|
+
...calledElement ? { calledElement } : {},
|
|
951
|
+
...aranzaExt
|
|
830
952
|
};
|
|
831
953
|
if (elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess") {
|
|
832
954
|
const variant = extractSubProcessVariant(el);
|
|
@@ -926,7 +1048,8 @@ function addLaneNodes(laneSet, poolId, ctx, nodes) {
|
|
|
926
1048
|
}
|
|
927
1049
|
}
|
|
928
1050
|
async function parseBpmnXml(xml) {
|
|
929
|
-
const
|
|
1051
|
+
const { BpmnModdle } = await import('bpmn-moddle');
|
|
1052
|
+
const moddle = new BpmnModdle({ aranza: ARANZA_DESCRIPTOR });
|
|
930
1053
|
const warnings = [];
|
|
931
1054
|
let rootElement;
|
|
932
1055
|
try {
|
|
@@ -976,10 +1099,23 @@ async function parseBpmnXml(xml) {
|
|
|
976
1099
|
};
|
|
977
1100
|
return { ...edge, data };
|
|
978
1101
|
});
|
|
1102
|
+
const firstProcess = asElements(rootElement.rootElements).find((rootEl) => rootEl.$type === "bpmn:Process");
|
|
1103
|
+
const importedDefinitions = extractDefinitions(rootElement);
|
|
1104
|
+
const process = firstProcess ? (() => {
|
|
1105
|
+
const importedProcess = {};
|
|
1106
|
+
const processId = asString(firstProcess.id);
|
|
1107
|
+
const documentation = extractDocumentation(firstProcess);
|
|
1108
|
+
if (processId) importedProcess.processId = processId;
|
|
1109
|
+
if (typeof firstProcess.isExecutable === "boolean") importedProcess.executable = firstProcess.isExecutable;
|
|
1110
|
+
if (documentation) importedProcess.documentation = documentation;
|
|
1111
|
+
if (importedDefinitions) importedProcess.definitions = importedDefinitions;
|
|
1112
|
+
return importedProcess;
|
|
1113
|
+
})() : importedDefinitions ? { definitions: importedDefinitions } : void 0;
|
|
979
1114
|
return {
|
|
980
1115
|
nodes: normalizeChildPositions(nodes, nodeIds),
|
|
981
1116
|
edges: normalizedEdges,
|
|
982
|
-
warnings
|
|
1117
|
+
warnings,
|
|
1118
|
+
...process ? { process } : {}
|
|
983
1119
|
};
|
|
984
1120
|
}
|
|
985
1121
|
function collectDefaultFlows(el, defaultFlowById) {
|
|
@@ -1003,12 +1139,117 @@ function normalizeChildPositions(nodes, nodeIds) {
|
|
|
1003
1139
|
};
|
|
1004
1140
|
});
|
|
1005
1141
|
}
|
|
1142
|
+
|
|
1143
|
+
// src/xml/exporter.ts
|
|
1006
1144
|
function uid(prefix, id) {
|
|
1007
1145
|
return `${prefix}_${id}`;
|
|
1008
1146
|
}
|
|
1009
1147
|
function asNodes(nodes, types) {
|
|
1010
1148
|
return nodes.filter((n) => types.includes(n.data.elementType));
|
|
1011
1149
|
}
|
|
1150
|
+
function normalizeEventDefinition(data) {
|
|
1151
|
+
const trigger = data.eventDefinition?.type ?? data.trigger;
|
|
1152
|
+
if (!trigger || trigger === "none") return void 0;
|
|
1153
|
+
const normalized = { type: trigger };
|
|
1154
|
+
const timer = data.eventDefinition?.timer ?? data.timer ?? data.timerExpression;
|
|
1155
|
+
const messageRef = data.eventDefinition?.messageRef ?? (typeof data.messageRef === "string" ? data.messageRef : void 0);
|
|
1156
|
+
const signalRef = data.eventDefinition?.signalRef ?? (typeof data.signalRef === "string" ? data.signalRef : void 0);
|
|
1157
|
+
const errorRef = data.eventDefinition?.errorRef ?? (typeof data.errorRef === "string" ? data.errorRef : void 0);
|
|
1158
|
+
const escalationRef = data.eventDefinition?.escalationRef ?? (typeof data.escalationRef === "string" ? data.escalationRef : void 0);
|
|
1159
|
+
const conditionExpression = data.eventDefinition?.conditionExpression ?? (typeof data.conditionExpression === "string" ? data.conditionExpression : void 0);
|
|
1160
|
+
const linkName = data.eventDefinition?.linkName ?? (typeof data.linkName === "string" ? data.linkName : void 0);
|
|
1161
|
+
if (timer) normalized.timer = timer;
|
|
1162
|
+
if (messageRef) normalized.messageRef = messageRef;
|
|
1163
|
+
if (signalRef) normalized.signalRef = signalRef;
|
|
1164
|
+
if (errorRef) normalized.errorRef = errorRef;
|
|
1165
|
+
if (escalationRef) normalized.escalationRef = escalationRef;
|
|
1166
|
+
if (conditionExpression) normalized.conditionExpression = conditionExpression;
|
|
1167
|
+
if (linkName) normalized.linkName = linkName;
|
|
1168
|
+
return normalized;
|
|
1169
|
+
}
|
|
1170
|
+
function parseVariableType2(type) {
|
|
1171
|
+
switch (type) {
|
|
1172
|
+
case "integer":
|
|
1173
|
+
return "xsd:int";
|
|
1174
|
+
case "boolean":
|
|
1175
|
+
return "xsd:boolean";
|
|
1176
|
+
case "date":
|
|
1177
|
+
return "xsd:dateTime";
|
|
1178
|
+
case "object":
|
|
1179
|
+
return "xsd:anyType";
|
|
1180
|
+
case "array":
|
|
1181
|
+
return "xsd:anyType";
|
|
1182
|
+
default:
|
|
1183
|
+
return "xsd:string";
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
function buildGlobalDefinitions(moddle, definitionsSet) {
|
|
1187
|
+
if (!definitionsSet) return [];
|
|
1188
|
+
const rootElements = [];
|
|
1189
|
+
for (const message of definitionsSet.messages ?? []) {
|
|
1190
|
+
rootElements.push(moddle.create("bpmn:Message", { id: message.id, name: message.name }));
|
|
1191
|
+
}
|
|
1192
|
+
for (const signal of definitionsSet.signals ?? []) {
|
|
1193
|
+
rootElements.push(moddle.create("bpmn:Signal", { id: signal.id, name: signal.name }));
|
|
1194
|
+
}
|
|
1195
|
+
for (const error of definitionsSet.errors ?? []) {
|
|
1196
|
+
rootElements.push(moddle.create("bpmn:Error", {
|
|
1197
|
+
id: error.id,
|
|
1198
|
+
name: error.name,
|
|
1199
|
+
...error.errorCode ? { errorCode: error.errorCode } : {}
|
|
1200
|
+
}));
|
|
1201
|
+
}
|
|
1202
|
+
for (const escalation of definitionsSet.escalations ?? []) {
|
|
1203
|
+
rootElements.push(moddle.create("bpmn:Escalation", {
|
|
1204
|
+
id: escalation.id,
|
|
1205
|
+
name: escalation.name,
|
|
1206
|
+
...escalation.escalationCode ? { escalationCode: escalation.escalationCode } : {}
|
|
1207
|
+
}));
|
|
1208
|
+
}
|
|
1209
|
+
return rootElements;
|
|
1210
|
+
}
|
|
1211
|
+
function buildItemDefinitions(moddle, variables) {
|
|
1212
|
+
return (variables ?? []).map(
|
|
1213
|
+
(variable) => moddle.create("bpmn:ItemDefinition", {
|
|
1214
|
+
id: `${variable.id}_item`,
|
|
1215
|
+
itemKind: "Information",
|
|
1216
|
+
structureRef: parseVariableType2(variable.type)
|
|
1217
|
+
})
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
function buildEventDefinitions(moddle, node, eventDefinition) {
|
|
1221
|
+
if (eventDefinition.type === "multiple" || eventDefinition.type === "parallelMultiple") {
|
|
1222
|
+
return [];
|
|
1223
|
+
}
|
|
1224
|
+
const defType = TRIGGER_TO_EVENT_DEF[eventDefinition.type];
|
|
1225
|
+
if (!defType) return [];
|
|
1226
|
+
const attrs = { id: uid("EventDef", node.id) };
|
|
1227
|
+
if (eventDefinition.messageRef) attrs.messageRef = { id: eventDefinition.messageRef };
|
|
1228
|
+
if (eventDefinition.signalRef) attrs.signalRef = { id: eventDefinition.signalRef };
|
|
1229
|
+
if (eventDefinition.errorRef) attrs.errorRef = { id: eventDefinition.errorRef };
|
|
1230
|
+
if (eventDefinition.escalationRef) attrs.escalationRef = { id: eventDefinition.escalationRef };
|
|
1231
|
+
if (eventDefinition.conditionExpression) {
|
|
1232
|
+
attrs.condition = moddle.create("bpmn:FormalExpression", {
|
|
1233
|
+
body: eventDefinition.conditionExpression
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
if (eventDefinition.timer?.value) {
|
|
1237
|
+
attrs[eventDefinition.timer.kind === "date" ? "timeDate" : eventDefinition.timer.kind === "cycle" ? "timeCycle" : "timeDuration"] = moddle.create("bpmn:FormalExpression", {
|
|
1238
|
+
body: eventDefinition.timer.value
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
return [moddle.create(defType, attrs)];
|
|
1242
|
+
}
|
|
1243
|
+
function buildAranzaExtensionElements(moddle, node) {
|
|
1244
|
+
const { priority, owner, sla } = node.data;
|
|
1245
|
+
if (!priority && !owner && !sla) return null;
|
|
1246
|
+
const configAttrs = {};
|
|
1247
|
+
if (priority) configAttrs.priority = priority;
|
|
1248
|
+
if (owner) configAttrs.owner = owner;
|
|
1249
|
+
if (sla) configAttrs.sla = sla;
|
|
1250
|
+
const taskConfig = moddle.create("aranza:TaskConfig", configAttrs);
|
|
1251
|
+
return moddle.create("bpmn:ExtensionElements", { values: [taskConfig] });
|
|
1252
|
+
}
|
|
1012
1253
|
function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
1013
1254
|
const defId = opts.id ?? "Definitions_1";
|
|
1014
1255
|
const defName = opts.name;
|
|
@@ -1020,13 +1261,19 @@ function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
|
1020
1261
|
targetNamespace: "http://bpmn.io/schema/bpmn",
|
|
1021
1262
|
...defName ? { name: defName } : {}
|
|
1022
1263
|
});
|
|
1023
|
-
const rootElements = [
|
|
1264
|
+
const rootElements = [
|
|
1265
|
+
...buildGlobalDefinitions(moddle, opts.process?.definitions)
|
|
1266
|
+
];
|
|
1267
|
+
const itemDefinitions = buildItemDefinitions(moddle, opts.process?.definitions?.variables);
|
|
1268
|
+
if (itemDefinitions.length > 0) {
|
|
1269
|
+
definitions.itemDefinitions = itemDefinitions;
|
|
1270
|
+
}
|
|
1024
1271
|
if (isCollaboration) {
|
|
1025
1272
|
const participants = [];
|
|
1026
1273
|
const processes = [];
|
|
1027
1274
|
for (const pool of poolNodes) {
|
|
1028
1275
|
const processId = `Process_${pool.id}`;
|
|
1029
|
-
const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId);
|
|
1276
|
+
const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId, opts);
|
|
1030
1277
|
processes.push(process);
|
|
1031
1278
|
const participant = moddle.create("bpmn:Participant", {
|
|
1032
1279
|
id: pool.id,
|
|
@@ -1060,13 +1307,21 @@ function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
|
1060
1307
|
});
|
|
1061
1308
|
rootElements.push(collaboration, ...processes);
|
|
1062
1309
|
} else {
|
|
1063
|
-
const process = buildProcess(
|
|
1310
|
+
const process = buildProcess(
|
|
1311
|
+
moddle,
|
|
1312
|
+
nodes,
|
|
1313
|
+
edges,
|
|
1314
|
+
void 0,
|
|
1315
|
+
laneNodes,
|
|
1316
|
+
opts.process?.processId ?? "Process_1",
|
|
1317
|
+
opts
|
|
1318
|
+
);
|
|
1064
1319
|
rootElements.push(process);
|
|
1065
1320
|
}
|
|
1066
1321
|
definitions.rootElements = rootElements;
|
|
1067
1322
|
return definitions;
|
|
1068
1323
|
}
|
|
1069
|
-
function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId) {
|
|
1324
|
+
function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId, opts) {
|
|
1070
1325
|
const subProcessIds = new Set(
|
|
1071
1326
|
allNodes.filter(
|
|
1072
1327
|
(n) => n.data.elementType === "SubProcess" || n.data.elementType === "Transaction" || n.data.elementType === "EventSubProcess" || n.data.elementType === "AdHocSubProcess"
|
|
@@ -1116,9 +1371,14 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId)
|
|
|
1116
1371
|
}
|
|
1117
1372
|
const process = moddle.create("bpmn:Process", {
|
|
1118
1373
|
id: processId,
|
|
1119
|
-
isExecutable: true,
|
|
1374
|
+
isExecutable: opts.process?.executable ?? true,
|
|
1120
1375
|
flowElements
|
|
1121
1376
|
});
|
|
1377
|
+
if (opts.process?.documentation) {
|
|
1378
|
+
process.documentation = [
|
|
1379
|
+
moddle.create("bpmn:Documentation", { text: opts.process.documentation })
|
|
1380
|
+
];
|
|
1381
|
+
}
|
|
1122
1382
|
if (myLanes.length > 0) {
|
|
1123
1383
|
const laneElements = myLanes.map(
|
|
1124
1384
|
(l) => moddle.create("bpmn:Lane", {
|
|
@@ -1135,7 +1395,8 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId)
|
|
|
1135
1395
|
return process;
|
|
1136
1396
|
}
|
|
1137
1397
|
function buildFlowElement(moddle, node, allNodes, allEdges) {
|
|
1138
|
-
const { elementType, label
|
|
1398
|
+
const { elementType, label } = node.data;
|
|
1399
|
+
const eventDefinition = normalizeEventDefinition(node.data);
|
|
1139
1400
|
if (elementType === "Pool" || elementType === "Lane") return null;
|
|
1140
1401
|
const moddleType = ELEMENT_TYPE_TO_MODDLE[elementType];
|
|
1141
1402
|
if (!moddleType) return null;
|
|
@@ -1148,16 +1409,21 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
|
|
|
1148
1409
|
moddle.create("bpmn:Documentation", { text: node.data.documentation })
|
|
1149
1410
|
];
|
|
1150
1411
|
}
|
|
1151
|
-
if (
|
|
1152
|
-
const
|
|
1153
|
-
if (
|
|
1154
|
-
|
|
1155
|
-
}
|
|
1412
|
+
if (eventDefinition) {
|
|
1413
|
+
const eventDefinitions = buildEventDefinitions(moddle, node, eventDefinition);
|
|
1414
|
+
if (eventDefinitions.length > 0) attrs.eventDefinitions = eventDefinitions;
|
|
1415
|
+
if (eventDefinition.linkName) attrs.name = eventDefinition.linkName;
|
|
1156
1416
|
}
|
|
1157
1417
|
if (elementType === "BoundaryEvent") {
|
|
1158
1418
|
attrs.attachedToRef = { id: node.data.attachedToRef ?? node.parentId };
|
|
1159
|
-
|
|
1419
|
+
const interrupting = node.data.cancelActivity ?? !node.data.isNonInterrupting;
|
|
1420
|
+
attrs.cancelActivity = interrupting;
|
|
1421
|
+
}
|
|
1422
|
+
if (elementType === "CallActivity" && node.data.calledElement) {
|
|
1423
|
+
attrs.calledElement = node.data.calledElement;
|
|
1160
1424
|
}
|
|
1425
|
+
const aranzaConfig = buildAranzaExtensionElements(moddle, node);
|
|
1426
|
+
if (aranzaConfig) attrs.extensionElements = aranzaConfig;
|
|
1161
1427
|
const isSubProcess = elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess";
|
|
1162
1428
|
if (isSubProcess) {
|
|
1163
1429
|
attrs.flowElements = buildNestedFlowElements(moddle, node, allNodes, allEdges);
|
|
@@ -1295,7 +1561,8 @@ function buildAbsolutePositionMap(nodes) {
|
|
|
1295
1561
|
return absoluteById;
|
|
1296
1562
|
}
|
|
1297
1563
|
async function serializeBpmnXml(nodes, edges, opts = {}) {
|
|
1298
|
-
const
|
|
1564
|
+
const { BpmnModdle } = await import('bpmn-moddle');
|
|
1565
|
+
const moddle = new BpmnModdle({ aranza: ARANZA_DESCRIPTOR });
|
|
1299
1566
|
const definitions = buildSemanticModel(moddle, nodes, edges, opts);
|
|
1300
1567
|
buildBpmnDI(moddle, definitions, nodes, edges);
|
|
1301
1568
|
const { xml } = await moddle.toXML(definitions, {
|