@bpmnkit/core 0.8.0 → 1.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/README.md +49 -3
- package/dist/bpmn/agentic.js +3 -1
- package/dist/bpmn/auto-layout.js +184 -15
- package/dist/bpmn/bpmn-builder.d.ts +1 -12
- package/dist/bpmn/bpmn-builder.js +71 -10
- package/dist/bpmn/bpmn-model.d.ts +78 -0
- package/dist/bpmn/bpmn-parser.js +199 -41
- package/dist/bpmn/bpmn-serializer.js +121 -72
- package/dist/bpmn/bpmnlint.d.ts +153 -0
- package/dist/bpmn/bpmnlint.js +364 -0
- package/dist/bpmn/camunda-compat-data.d.ts +165 -0
- package/dist/bpmn/camunda-compat-data.js +423 -0
- package/dist/bpmn/camunda-compat-feel.d.ts +68 -0
- package/dist/bpmn/camunda-compat-feel.js +338 -0
- package/dist/bpmn/camunda-compat.d.ts +120 -0
- package/dist/bpmn/camunda-compat.js +1677 -0
- package/dist/bpmn/camunda7/juel.d.ts +41 -0
- package/dist/bpmn/camunda7/juel.js +333 -0
- package/dist/bpmn/camunda7/migrate.d.ts +72 -0
- package/dist/bpmn/camunda7/migrate.js +1152 -0
- package/dist/bpmn/compact-stream.d.ts +64 -0
- package/dist/bpmn/compact-stream.js +167 -0
- package/dist/bpmn/full-operations.js +5 -2
- package/dist/bpmn/label-style.d.ts +51 -0
- package/dist/bpmn/label-style.js +116 -0
- package/dist/bpmn/lint.d.ts +23 -3
- package/dist/bpmn/lint.js +47 -10
- package/dist/bpmn/optimize/bpmnlint-rules.d.ts +31 -0
- package/dist/bpmn/optimize/bpmnlint-rules.js +916 -0
- package/dist/bpmn/optimize/deploy.d.ts +8 -2
- package/dist/bpmn/optimize/deploy.js +16 -3
- package/dist/bpmn/optimize/index.js +11 -2
- package/dist/bpmn/optimize/types.d.ts +14 -0
- package/dist/bpmn/optimize/variable-flow.js +4 -1
- package/dist/bpmn/process-types.d.ts +112 -0
- package/dist/bpmn/process-types.js +490 -0
- package/dist/bpmn/svg.js +51 -22
- package/dist/dmn/dmn-parser.js +4 -3
- package/dist/doc/docx.d.ts +20 -0
- package/dist/doc/docx.js +253 -0
- package/dist/doc/html.d.ts +21 -0
- package/dist/doc/html.js +303 -0
- package/dist/doc/index.d.ts +7 -0
- package/dist/doc/index.js +5 -0
- package/dist/doc/markdown.d.ts +11 -0
- package/dist/doc/markdown.js +160 -0
- package/dist/doc/model.d.ts +129 -0
- package/dist/doc/model.js +617 -0
- package/dist/doc/zip.d.ts +5 -0
- package/dist/doc/zip.js +75 -0
- package/dist/form/form-parser.js +29 -28
- package/dist/index.d.ts +18 -0
- package/dist/index.js +9 -0
- package/dist/layout/annotations.d.ts +4 -2
- package/dist/layout/annotations.js +31 -2
- package/dist/layout/collaboration/ordering.d.ts +8 -0
- package/dist/layout/collaboration/ordering.js +57 -18
- package/dist/layout/orthogonal.d.ts +32 -0
- package/dist/layout/orthogonal.js +367 -0
- package/dist/layout/repair.d.ts +31 -0
- package/dist/layout/repair.js +220 -0
- package/dist/layout/semantic/route.js +45 -3
- package/dist/node/bpmnlint.d.ts +109 -0
- package/dist/node/bpmnlint.js +198 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +1 -0
- package/dist/xml/xml-patch.d.ts +21 -0
- package/dist/xml/xml-patch.js +27 -1
- package/package.json +5 -2
package/dist/bpmn/bpmn-parser.js
CHANGED
|
@@ -29,11 +29,16 @@ function requiredAttr(attributes, name, elementName) {
|
|
|
29
29
|
}
|
|
30
30
|
return value;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The attributes `BpmnDefinitions` models. Checked against its own list rather than
|
|
34
|
+
* `KNOWN_ATTRS`, which names flow-node attributes: a `name` on `<definitions>` is
|
|
35
|
+
* not modelled, so it has to travel in `unknownAttributes` or it is lost.
|
|
36
|
+
*/
|
|
37
|
+
const DEFINITIONS_ATTRS = new Set(["id", "targetNamespace", "exporter", "exporterVersion"]);
|
|
32
38
|
/** Known attribute names on flow nodes — everything else goes to unknownAttributes. */
|
|
33
39
|
const KNOWN_ATTRS = new Set([
|
|
34
40
|
"id",
|
|
35
41
|
"name",
|
|
36
|
-
"default",
|
|
37
42
|
"attachedToRef",
|
|
38
43
|
"cancelActivity",
|
|
39
44
|
"isForCompensation",
|
|
@@ -73,6 +78,36 @@ function unknownAttrs(attributes) {
|
|
|
73
78
|
}
|
|
74
79
|
return result;
|
|
75
80
|
}
|
|
81
|
+
const NO_ATTRS = new Set();
|
|
82
|
+
const ID_ATTRS = new Set(["id"]);
|
|
83
|
+
const DI_REF_ATTRS = new Set(["id", "bpmnElement"]);
|
|
84
|
+
const POINT_ATTRS = new Set(["x", "y"]);
|
|
85
|
+
/**
|
|
86
|
+
* The attributes of a DI element that its model does not name, or `undefined` when
|
|
87
|
+
* there are none — so a model built from a plain diagram carries no empty objects.
|
|
88
|
+
*/
|
|
89
|
+
function otherAttrs(attributes, modelled) {
|
|
90
|
+
let result;
|
|
91
|
+
for (const key in attributes) {
|
|
92
|
+
if (modelled.has(key) || key === "xmlns" || key.startsWith("xmlns:"))
|
|
93
|
+
continue;
|
|
94
|
+
result ??= {};
|
|
95
|
+
result[key] = attributes[key];
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A gateway's base fields without `default` in its unknown attributes: the gateway
|
|
101
|
+
* models it, so leaving a copy there would re-emit a stale value after an edit.
|
|
102
|
+
* Activities keep theirs in `unknownAttributes` — BPMN allows a default flow on any
|
|
103
|
+
* activity, and the SDK does not model it there.
|
|
104
|
+
*/
|
|
105
|
+
function gatewayBase(base) {
|
|
106
|
+
if (!("default" in base.unknownAttributes))
|
|
107
|
+
return base;
|
|
108
|
+
const { default: _, ...unknownAttributes } = base.unknownAttributes;
|
|
109
|
+
return { ...base, unknownAttributes };
|
|
110
|
+
}
|
|
76
111
|
/** Known child local names for flow nodes — anything else is an extension. */
|
|
77
112
|
const KNOWN_FLOW_CHILDREN = new Set([
|
|
78
113
|
"incoming",
|
|
@@ -224,6 +259,10 @@ function dropLayoutWhitespace(element) {
|
|
|
224
259
|
element.text = undefined;
|
|
225
260
|
}
|
|
226
261
|
}
|
|
262
|
+
/** A `<documentation>`'s attributes (`id`, `textFormat`), or `undefined` when it has none. */
|
|
263
|
+
function documentationAttrs(attrs) {
|
|
264
|
+
return otherAttrs(attrs, NO_ATTRS);
|
|
265
|
+
}
|
|
227
266
|
/**
|
|
228
267
|
* Shared handling of the two children every BPMN base element may have.
|
|
229
268
|
*
|
|
@@ -233,6 +272,7 @@ function dropLayoutWhitespace(element) {
|
|
|
233
272
|
*/
|
|
234
273
|
class BaseElementFrame extends Frame {
|
|
235
274
|
documentation;
|
|
275
|
+
documentationAttributes;
|
|
236
276
|
documentationSeen = false;
|
|
237
277
|
extensions = null;
|
|
238
278
|
/** A base child's frame, or `undefined` when `local` is not one. */
|
|
@@ -257,6 +297,8 @@ class BaseElementFrame extends Frame {
|
|
|
257
297
|
const fields = {};
|
|
258
298
|
if (this.documentation !== undefined)
|
|
259
299
|
fields.documentation = this.documentation;
|
|
300
|
+
if (this.documentationAttributes)
|
|
301
|
+
fields.documentationAttributes = this.documentationAttributes;
|
|
260
302
|
if (this.extensions !== null && this.extensions.length > 0) {
|
|
261
303
|
fields.extensionElements = this.extensions;
|
|
262
304
|
}
|
|
@@ -265,6 +307,7 @@ class BaseElementFrame extends Frame {
|
|
|
265
307
|
setText(slot, text, attrs) {
|
|
266
308
|
if (slot === SLOT_DOCUMENTATION) {
|
|
267
309
|
this.documentation = text;
|
|
310
|
+
this.documentationAttributes = documentationAttrs(attrs);
|
|
268
311
|
return;
|
|
269
312
|
}
|
|
270
313
|
this.baseText(slot, text, attrs);
|
|
@@ -497,6 +540,7 @@ class FlowNodeFrame extends Frame {
|
|
|
497
540
|
incoming = [];
|
|
498
541
|
outgoing = [];
|
|
499
542
|
documentation;
|
|
543
|
+
documentationAttributes;
|
|
500
544
|
documentationSeen = false;
|
|
501
545
|
extensionElements = null;
|
|
502
546
|
eventDefinitions;
|
|
@@ -586,6 +630,7 @@ class FlowNodeFrame extends Frame {
|
|
|
586
630
|
}
|
|
587
631
|
case SLOT_DOCUMENTATION:
|
|
588
632
|
this.documentation = text;
|
|
633
|
+
this.documentationAttributes = documentationAttrs(attrs);
|
|
589
634
|
break;
|
|
590
635
|
case SLOT_COMPLETION_CONDITION:
|
|
591
636
|
this.completionCondition = { text: text ?? "", attributes: { ...attrs } };
|
|
@@ -613,6 +658,9 @@ class FlowNodeFrame extends Frame {
|
|
|
613
658
|
incoming: this.incoming,
|
|
614
659
|
outgoing: this.outgoing,
|
|
615
660
|
documentation: this.documentation,
|
|
661
|
+
...(this.documentationAttributes
|
|
662
|
+
? { documentationAttributes: this.documentationAttributes }
|
|
663
|
+
: {}),
|
|
616
664
|
extensionElements: this.extensionElements ?? [],
|
|
617
665
|
unknownAttributes: unknownAttrs(attrs),
|
|
618
666
|
};
|
|
@@ -706,19 +754,19 @@ class FlowNodeFrame extends Frame {
|
|
|
706
754
|
};
|
|
707
755
|
break;
|
|
708
756
|
case "exclusiveGateway":
|
|
709
|
-
el = { ...base, type: "exclusiveGateway", default: attr(attrs, "default") };
|
|
757
|
+
el = { ...gatewayBase(base), type: "exclusiveGateway", default: attr(attrs, "default") };
|
|
710
758
|
break;
|
|
711
759
|
case "parallelGateway":
|
|
712
760
|
el = { ...base, type: "parallelGateway" };
|
|
713
761
|
break;
|
|
714
762
|
case "inclusiveGateway":
|
|
715
|
-
el = { ...base, type: "inclusiveGateway", default: attr(attrs, "default") };
|
|
763
|
+
el = { ...gatewayBase(base), type: "inclusiveGateway", default: attr(attrs, "default") };
|
|
716
764
|
break;
|
|
717
765
|
case "eventBasedGateway":
|
|
718
766
|
el = { ...base, type: "eventBasedGateway" };
|
|
719
767
|
break;
|
|
720
768
|
case "complexGateway":
|
|
721
|
-
el = { ...base, type: "complexGateway", default: attr(attrs, "default") };
|
|
769
|
+
el = { ...gatewayBase(base), type: "complexGateway", default: attr(attrs, "default") };
|
|
722
770
|
break;
|
|
723
771
|
case "dataObject":
|
|
724
772
|
el = {
|
|
@@ -751,6 +799,18 @@ class FlowNodeFrame extends Frame {
|
|
|
751
799
|
// ---------------------------------------------------------------------------
|
|
752
800
|
// Event definitions
|
|
753
801
|
// ---------------------------------------------------------------------------
|
|
802
|
+
/** An event definition's unmodelled attributes, spread into the definition when present. */
|
|
803
|
+
function definitionExtras(attrs, modelled) {
|
|
804
|
+
const unknownAttributes = otherAttrs(attrs, modelled);
|
|
805
|
+
return unknownAttributes ? { unknownAttributes } : {};
|
|
806
|
+
}
|
|
807
|
+
const ERROR_DEF_ATTRS = new Set(["id", "errorRef"]);
|
|
808
|
+
const ESCALATION_DEF_ATTRS = new Set(["id", "escalationRef"]);
|
|
809
|
+
const MESSAGE_DEF_ATTRS = new Set(["id", "messageRef"]);
|
|
810
|
+
const SIGNAL_DEF_ATTRS = new Set(["id", "signalRef"]);
|
|
811
|
+
const LINK_DEF_ATTRS = new Set(["id", "name"]);
|
|
812
|
+
const COMPENSATE_DEF_ATTRS = new Set(["id", "activityRef"]);
|
|
813
|
+
const LOOP_ATTRS = new Set(["id", "isSequential"]);
|
|
754
814
|
function eventDefinitionFrame(local, attrs, target) {
|
|
755
815
|
switch (local) {
|
|
756
816
|
case "timerEventDefinition":
|
|
@@ -758,35 +818,61 @@ function eventDefinitionFrame(local, attrs, target) {
|
|
|
758
818
|
case "conditionalEventDefinition":
|
|
759
819
|
return new ConditionalDefinitionFrame(attrs, target);
|
|
760
820
|
case "errorEventDefinition":
|
|
761
|
-
target.push({
|
|
821
|
+
target.push({
|
|
822
|
+
type: "error",
|
|
823
|
+
id: attr(attrs, "id"),
|
|
824
|
+
errorRef: attr(attrs, "errorRef"),
|
|
825
|
+
...definitionExtras(attrs, ERROR_DEF_ATTRS),
|
|
826
|
+
});
|
|
762
827
|
return null;
|
|
763
828
|
case "escalationEventDefinition":
|
|
764
829
|
target.push({
|
|
765
830
|
type: "escalation",
|
|
766
831
|
id: attr(attrs, "id"),
|
|
767
832
|
escalationRef: attr(attrs, "escalationRef"),
|
|
833
|
+
...definitionExtras(attrs, ESCALATION_DEF_ATTRS),
|
|
768
834
|
});
|
|
769
835
|
return null;
|
|
770
836
|
case "messageEventDefinition":
|
|
771
|
-
target.push({
|
|
837
|
+
target.push({
|
|
838
|
+
type: "message",
|
|
839
|
+
id: attr(attrs, "id"),
|
|
840
|
+
messageRef: attr(attrs, "messageRef"),
|
|
841
|
+
...definitionExtras(attrs, MESSAGE_DEF_ATTRS),
|
|
842
|
+
});
|
|
772
843
|
return null;
|
|
773
844
|
case "signalEventDefinition":
|
|
774
|
-
target.push({
|
|
845
|
+
target.push({
|
|
846
|
+
type: "signal",
|
|
847
|
+
id: attr(attrs, "id"),
|
|
848
|
+
signalRef: attr(attrs, "signalRef"),
|
|
849
|
+
...definitionExtras(attrs, SIGNAL_DEF_ATTRS),
|
|
850
|
+
});
|
|
775
851
|
return null;
|
|
776
852
|
case "linkEventDefinition":
|
|
777
|
-
target.push({
|
|
853
|
+
target.push({
|
|
854
|
+
type: "link",
|
|
855
|
+
id: attr(attrs, "id"),
|
|
856
|
+
name: attr(attrs, "name"),
|
|
857
|
+
...definitionExtras(attrs, LINK_DEF_ATTRS),
|
|
858
|
+
});
|
|
778
859
|
return null;
|
|
779
860
|
case "cancelEventDefinition":
|
|
780
|
-
target.push({ type: "cancel", id: attr(attrs, "id") });
|
|
861
|
+
target.push({ type: "cancel", id: attr(attrs, "id"), ...definitionExtras(attrs, ID_ATTRS) });
|
|
781
862
|
return null;
|
|
782
863
|
case "terminateEventDefinition":
|
|
783
|
-
target.push({
|
|
864
|
+
target.push({
|
|
865
|
+
type: "terminate",
|
|
866
|
+
id: attr(attrs, "id"),
|
|
867
|
+
...definitionExtras(attrs, ID_ATTRS),
|
|
868
|
+
});
|
|
784
869
|
return null;
|
|
785
870
|
case "compensateEventDefinition":
|
|
786
871
|
target.push({
|
|
787
872
|
type: "compensate",
|
|
788
873
|
id: attr(attrs, "id"),
|
|
789
874
|
activityRef: attr(attrs, "activityRef"),
|
|
875
|
+
...definitionExtras(attrs, COMPENSATE_DEF_ATTRS),
|
|
790
876
|
});
|
|
791
877
|
return null;
|
|
792
878
|
default:
|
|
@@ -837,15 +923,26 @@ class TimerDefinitionFrame extends Frame {
|
|
|
837
923
|
this.target.push({
|
|
838
924
|
type: "timer",
|
|
839
925
|
id: attr(this.attrs, "id"),
|
|
840
|
-
timeDuration: this.duration
|
|
926
|
+
timeDuration: partText(this.duration),
|
|
841
927
|
timeDurationAttributes: partAttributes(this.duration),
|
|
842
|
-
timeDate: this.date
|
|
928
|
+
timeDate: partText(this.date),
|
|
843
929
|
timeDateAttributes: partAttributes(this.date),
|
|
844
|
-
timeCycle: this.cycle
|
|
930
|
+
timeCycle: partText(this.cycle),
|
|
845
931
|
timeCycleAttributes: partAttributes(this.cycle),
|
|
932
|
+
...definitionExtras(this.attrs, ID_ATTRS),
|
|
846
933
|
});
|
|
847
934
|
}
|
|
848
935
|
}
|
|
936
|
+
/**
|
|
937
|
+
* A present-but-empty part reads as `""`, not `undefined`: modelers emit an empty
|
|
938
|
+
* `<timeDate/>` for a timer whose value is still to be filled in, and dropping it
|
|
939
|
+
* would change which kind of timer the event is.
|
|
940
|
+
*/
|
|
941
|
+
function partText(part) {
|
|
942
|
+
if (!part)
|
|
943
|
+
return undefined;
|
|
944
|
+
return part.text?.trim() ?? "";
|
|
945
|
+
}
|
|
849
946
|
function partAttributes(part) {
|
|
850
947
|
if (!part)
|
|
851
948
|
return undefined;
|
|
@@ -856,6 +953,7 @@ class ConditionalDefinitionFrame extends Frame {
|
|
|
856
953
|
target;
|
|
857
954
|
conditionSeen = false;
|
|
858
955
|
condition;
|
|
956
|
+
conditionAttributes;
|
|
859
957
|
constructor(attrs, target) {
|
|
860
958
|
super();
|
|
861
959
|
this.attrs = attrs;
|
|
@@ -865,6 +963,8 @@ class ConditionalDefinitionFrame extends Frame {
|
|
|
865
963
|
if (local !== "condition" || this.conditionSeen)
|
|
866
964
|
return null;
|
|
867
965
|
this.conditionSeen = true;
|
|
966
|
+
if (Object.keys(attrs).length > 0)
|
|
967
|
+
this.conditionAttributes = { ...attrs };
|
|
868
968
|
return new TextFrame(this, SLOT_CONDITION, attrs);
|
|
869
969
|
}
|
|
870
970
|
setText(_slot, text) {
|
|
@@ -874,7 +974,10 @@ class ConditionalDefinitionFrame extends Frame {
|
|
|
874
974
|
this.target.push({
|
|
875
975
|
type: "conditional",
|
|
876
976
|
id: attr(this.attrs, "id"),
|
|
877
|
-
|
|
977
|
+
// Present but empty stays "", like a timer part: the element is still there.
|
|
978
|
+
condition: this.conditionSeen ? (this.condition?.trim() ?? "") : undefined,
|
|
979
|
+
...(this.conditionAttributes ? { conditionAttributes: this.conditionAttributes } : {}),
|
|
980
|
+
...definitionExtras(this.attrs, ID_ATTRS),
|
|
878
981
|
});
|
|
879
982
|
}
|
|
880
983
|
}
|
|
@@ -925,11 +1028,13 @@ class LoopFrame extends Frame {
|
|
|
925
1028
|
}
|
|
926
1029
|
finish() {
|
|
927
1030
|
this.owner.setLoopCharacteristics({
|
|
1031
|
+
...(this.attrs.id !== undefined ? { id: this.attrs.id } : {}),
|
|
928
1032
|
isSequential: this.attrs.isSequential === "true" ? true : undefined,
|
|
929
1033
|
loopCardinality: this.loopCardinality,
|
|
930
1034
|
completionCondition: this.completionCondition,
|
|
931
1035
|
extensionElements: this.extensionElements ?? [],
|
|
932
1036
|
...(this.unknownChildren.length > 0 ? { unknownChildren: this.unknownChildren } : {}),
|
|
1037
|
+
...definitionExtras(this.attrs, LOOP_ATTRS),
|
|
933
1038
|
});
|
|
934
1039
|
}
|
|
935
1040
|
}
|
|
@@ -944,7 +1049,11 @@ class SequenceFlowFrame extends Frame {
|
|
|
944
1049
|
targetRef;
|
|
945
1050
|
conditionExpression;
|
|
946
1051
|
conditionSeen = false;
|
|
1052
|
+
documentation;
|
|
1053
|
+
documentationAttributes;
|
|
1054
|
+
documentationSeen = false;
|
|
947
1055
|
extensionElements = null;
|
|
1056
|
+
unknownChildren = [];
|
|
948
1057
|
constructor(name, attrs, target) {
|
|
949
1058
|
super();
|
|
950
1059
|
this.attrs = attrs;
|
|
@@ -953,23 +1062,33 @@ class SequenceFlowFrame extends Frame {
|
|
|
953
1062
|
this.sourceRef = requiredAttr(attrs, "sourceRef", name);
|
|
954
1063
|
this.targetRef = requiredAttr(attrs, "targetRef", name);
|
|
955
1064
|
}
|
|
956
|
-
child(local,
|
|
1065
|
+
child(local, name, attrs) {
|
|
957
1066
|
switch (local) {
|
|
958
1067
|
case "conditionExpression":
|
|
959
1068
|
if (this.conditionSeen)
|
|
960
1069
|
return null;
|
|
961
1070
|
this.conditionSeen = true;
|
|
962
1071
|
return new TextFrame(this, SLOT_CONDITION_EXPRESSION, attrs);
|
|
1072
|
+
case "documentation":
|
|
1073
|
+
if (this.documentationSeen)
|
|
1074
|
+
return null;
|
|
1075
|
+
this.documentationSeen = true;
|
|
1076
|
+
return new TextFrame(this, SLOT_DOCUMENTATION, attrs);
|
|
963
1077
|
case "extensionElements":
|
|
964
1078
|
if (this.extensionElements !== null)
|
|
965
1079
|
return null;
|
|
966
1080
|
this.extensionElements = [];
|
|
967
1081
|
return new TreeFrame(this.extensionElements);
|
|
968
1082
|
default:
|
|
969
|
-
return
|
|
1083
|
+
return captureUnknown(this.unknownChildren, name, attrs);
|
|
970
1084
|
}
|
|
971
1085
|
}
|
|
972
|
-
setText(
|
|
1086
|
+
setText(slot, text, attrs) {
|
|
1087
|
+
if (slot === SLOT_DOCUMENTATION) {
|
|
1088
|
+
this.documentation = text;
|
|
1089
|
+
this.documentationAttributes = documentationAttrs(attrs);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
973
1092
|
this.conditionExpression = { text: text ?? "", attributes: { ...attrs } };
|
|
974
1093
|
}
|
|
975
1094
|
finish() {
|
|
@@ -978,9 +1097,14 @@ class SequenceFlowFrame extends Frame {
|
|
|
978
1097
|
name: attr(this.attrs, "name"),
|
|
979
1098
|
sourceRef: this.sourceRef,
|
|
980
1099
|
targetRef: this.targetRef,
|
|
1100
|
+
...(this.documentation !== undefined ? { documentation: this.documentation } : {}),
|
|
1101
|
+
...(this.documentationAttributes
|
|
1102
|
+
? { documentationAttributes: this.documentationAttributes }
|
|
1103
|
+
: {}),
|
|
981
1104
|
conditionExpression: this.conditionExpression,
|
|
982
1105
|
extensionElements: this.extensionElements ?? [],
|
|
983
1106
|
unknownAttributes: unknownAttrs(this.attrs),
|
|
1107
|
+
...(this.unknownChildren.length > 0 ? { unknownChildren: this.unknownChildren } : {}),
|
|
984
1108
|
});
|
|
985
1109
|
}
|
|
986
1110
|
}
|
|
@@ -1094,6 +1218,7 @@ class DataAssociationFrame extends BaseElementFrame {
|
|
|
1094
1218
|
finish() {
|
|
1095
1219
|
this.target.push({
|
|
1096
1220
|
id: attr(this.attrs, "id"),
|
|
1221
|
+
...this.baseFields(),
|
|
1097
1222
|
sourceRefs: this.sourceRefs,
|
|
1098
1223
|
targetRef: this.targetRef,
|
|
1099
1224
|
unknownAttributes: unknownAttrs(this.attrs),
|
|
@@ -1179,6 +1304,7 @@ class ProcessFrame extends Frame {
|
|
|
1179
1304
|
id;
|
|
1180
1305
|
unknownChildren = [];
|
|
1181
1306
|
documentation;
|
|
1307
|
+
documentationAttributes;
|
|
1182
1308
|
documentationSeen = false;
|
|
1183
1309
|
extensionElements = null;
|
|
1184
1310
|
laneSet;
|
|
@@ -1213,9 +1339,11 @@ class ProcessFrame extends Frame {
|
|
|
1213
1339
|
}
|
|
1214
1340
|
}
|
|
1215
1341
|
}
|
|
1216
|
-
setText(slot, text) {
|
|
1217
|
-
if (slot
|
|
1218
|
-
|
|
1342
|
+
setText(slot, text, attrs) {
|
|
1343
|
+
if (slot !== SLOT_DOCUMENTATION)
|
|
1344
|
+
return;
|
|
1345
|
+
this.documentation = text;
|
|
1346
|
+
this.documentationAttributes = documentationAttrs(attrs);
|
|
1219
1347
|
}
|
|
1220
1348
|
setLaneSet(laneSet) {
|
|
1221
1349
|
this.laneSet = laneSet;
|
|
@@ -1227,6 +1355,9 @@ class ProcessFrame extends Frame {
|
|
|
1227
1355
|
name: attr(attrs, "name"),
|
|
1228
1356
|
isExecutable: attr(attrs, "isExecutable") === "true" ? true : undefined,
|
|
1229
1357
|
...(this.documentation !== undefined ? { documentation: this.documentation } : {}),
|
|
1358
|
+
...(this.documentationAttributes
|
|
1359
|
+
? { documentationAttributes: this.documentationAttributes }
|
|
1360
|
+
: {}),
|
|
1230
1361
|
extensionElements: this.extensionElements ?? [],
|
|
1231
1362
|
unknownAttributes: unknownAttrs(attrs),
|
|
1232
1363
|
laneSet: this.laneSet,
|
|
@@ -1279,6 +1410,7 @@ class CollaborationFrame extends Frame {
|
|
|
1279
1410
|
finish() {
|
|
1280
1411
|
this.target.push({
|
|
1281
1412
|
id: this.id,
|
|
1413
|
+
name: attr(this.attrs, "name"),
|
|
1282
1414
|
participants: this.participants,
|
|
1283
1415
|
messageFlows: this.messageFlows,
|
|
1284
1416
|
textAnnotations: this.textAnnotations,
|
|
@@ -1292,11 +1424,13 @@ class CollaborationFrame extends Frame {
|
|
|
1292
1424
|
}
|
|
1293
1425
|
class LabelFrame extends Frame {
|
|
1294
1426
|
owner;
|
|
1427
|
+
attrs;
|
|
1295
1428
|
bounds;
|
|
1296
1429
|
boundsSeen = false;
|
|
1297
|
-
constructor(owner) {
|
|
1430
|
+
constructor(owner, attrs) {
|
|
1298
1431
|
super();
|
|
1299
1432
|
this.owner = owner;
|
|
1433
|
+
this.attrs = attrs;
|
|
1300
1434
|
}
|
|
1301
1435
|
child(local, _name, attrs) {
|
|
1302
1436
|
if (local === "Bounds" && !this.boundsSeen) {
|
|
@@ -1306,7 +1440,11 @@ class LabelFrame extends Frame {
|
|
|
1306
1440
|
return null;
|
|
1307
1441
|
}
|
|
1308
1442
|
finish() {
|
|
1309
|
-
|
|
1443
|
+
const unknownAttributes = otherAttrs(this.attrs, NO_ATTRS);
|
|
1444
|
+
this.owner.setLabel({
|
|
1445
|
+
bounds: this.bounds,
|
|
1446
|
+
...(unknownAttributes ? { unknownAttributes } : {}),
|
|
1447
|
+
});
|
|
1310
1448
|
}
|
|
1311
1449
|
}
|
|
1312
1450
|
class ShapeFrame extends Frame {
|
|
@@ -1332,7 +1470,7 @@ class ShapeFrame extends Frame {
|
|
|
1332
1470
|
if (this.labelSeen)
|
|
1333
1471
|
return null;
|
|
1334
1472
|
this.labelSeen = true;
|
|
1335
|
-
return new LabelFrame(this);
|
|
1473
|
+
return new LabelFrame(this, attrs);
|
|
1336
1474
|
default:
|
|
1337
1475
|
return null;
|
|
1338
1476
|
}
|
|
@@ -1343,10 +1481,10 @@ class ShapeFrame extends Frame {
|
|
|
1343
1481
|
finish() {
|
|
1344
1482
|
const attrs = this.attrs;
|
|
1345
1483
|
if (!this.bounds)
|
|
1346
|
-
throw new
|
|
1484
|
+
throw new ParseError(`Missing <dc:Bounds> in shape "${attr(attrs, "id")}"`);
|
|
1347
1485
|
this.target.push({
|
|
1348
|
-
id:
|
|
1349
|
-
bpmnElement:
|
|
1486
|
+
id: attr(attrs, "id") ?? "",
|
|
1487
|
+
bpmnElement: attr(attrs, "bpmnElement") ?? "",
|
|
1350
1488
|
isMarkerVisible: attr(attrs, "isMarkerVisible") !== undefined
|
|
1351
1489
|
? attr(attrs, "isMarkerVisible") === "true"
|
|
1352
1490
|
: undefined,
|
|
@@ -1375,17 +1513,20 @@ class EdgeFrame extends Frame {
|
|
|
1375
1513
|
}
|
|
1376
1514
|
child(local, _name, attrs) {
|
|
1377
1515
|
switch (local) {
|
|
1378
|
-
case "waypoint":
|
|
1516
|
+
case "waypoint": {
|
|
1517
|
+
const unknownAttributes = otherAttrs(attrs, POINT_ATTRS);
|
|
1379
1518
|
this.waypoints.push({
|
|
1380
1519
|
x: Number(attr(attrs, "x") ?? "0"),
|
|
1381
1520
|
y: Number(attr(attrs, "y") ?? "0"),
|
|
1521
|
+
...(unknownAttributes ? { unknownAttributes } : {}),
|
|
1382
1522
|
});
|
|
1383
1523
|
return null;
|
|
1524
|
+
}
|
|
1384
1525
|
case "BPMNLabel":
|
|
1385
1526
|
if (this.labelSeen)
|
|
1386
1527
|
return null;
|
|
1387
1528
|
this.labelSeen = true;
|
|
1388
|
-
return new LabelFrame(this);
|
|
1529
|
+
return new LabelFrame(this, attrs);
|
|
1389
1530
|
default:
|
|
1390
1531
|
return null;
|
|
1391
1532
|
}
|
|
@@ -1396,8 +1537,8 @@ class EdgeFrame extends Frame {
|
|
|
1396
1537
|
finish() {
|
|
1397
1538
|
const attrs = this.attrs;
|
|
1398
1539
|
this.target.push({
|
|
1399
|
-
id:
|
|
1400
|
-
bpmnElement:
|
|
1540
|
+
id: attr(attrs, "id") ?? "",
|
|
1541
|
+
bpmnElement: attr(attrs, "bpmnElement") ?? "",
|
|
1401
1542
|
waypoints: this.waypoints,
|
|
1402
1543
|
label: this.label,
|
|
1403
1544
|
unknownAttributes: unknownAttrs(attrs),
|
|
@@ -1433,6 +1574,7 @@ class DiagramFrame extends Frame {
|
|
|
1433
1574
|
target;
|
|
1434
1575
|
plane;
|
|
1435
1576
|
planeSeen = false;
|
|
1577
|
+
unknownChildren = [];
|
|
1436
1578
|
constructor(name, attrs, target) {
|
|
1437
1579
|
super();
|
|
1438
1580
|
this.name = name;
|
|
@@ -1440,7 +1582,9 @@ class DiagramFrame extends Frame {
|
|
|
1440
1582
|
this.target = target;
|
|
1441
1583
|
}
|
|
1442
1584
|
child(local, name, attrs) {
|
|
1443
|
-
if (local !== "BPMNPlane"
|
|
1585
|
+
if (local !== "BPMNPlane")
|
|
1586
|
+
return captureUnknown(this.unknownChildren, name, attrs);
|
|
1587
|
+
if (this.planeSeen)
|
|
1444
1588
|
return null;
|
|
1445
1589
|
this.planeSeen = true;
|
|
1446
1590
|
return new PlaneFrame(name, attrs, this);
|
|
@@ -1451,15 +1595,23 @@ class DiagramFrame extends Frame {
|
|
|
1451
1595
|
finish() {
|
|
1452
1596
|
const plane = this.plane;
|
|
1453
1597
|
if (!plane)
|
|
1454
|
-
throw new
|
|
1598
|
+
throw new ParseError("Missing <bpmndi:BPMNPlane> in diagram");
|
|
1599
|
+
// BPMN DI makes every `id` and `bpmnElement` here optional, and real models
|
|
1600
|
+
// (the OMG interchange suite among them) omit them. An absent one reads as ""
|
|
1601
|
+
// and is written back absent.
|
|
1602
|
+
const diagramAttributes = otherAttrs(this.attrs, ID_ATTRS);
|
|
1603
|
+
const planeAttributes = otherAttrs(plane.attrs, DI_REF_ATTRS);
|
|
1455
1604
|
this.target.push({
|
|
1456
|
-
id:
|
|
1605
|
+
id: attr(this.attrs, "id") ?? "",
|
|
1457
1606
|
plane: {
|
|
1458
|
-
id:
|
|
1459
|
-
bpmnElement:
|
|
1607
|
+
id: attr(plane.attrs, "id") ?? "",
|
|
1608
|
+
bpmnElement: attr(plane.attrs, "bpmnElement") ?? "",
|
|
1460
1609
|
shapes: plane.shapes,
|
|
1461
1610
|
edges: plane.edges,
|
|
1611
|
+
...(planeAttributes ? { unknownAttributes: planeAttributes } : {}),
|
|
1462
1612
|
},
|
|
1613
|
+
...(diagramAttributes ? { unknownAttributes: diagramAttributes } : {}),
|
|
1614
|
+
...(this.unknownChildren.length > 0 ? { unknownChildren: this.unknownChildren } : {}),
|
|
1463
1615
|
});
|
|
1464
1616
|
}
|
|
1465
1617
|
}
|
|
@@ -1472,6 +1624,7 @@ class DefinitionsFrame extends Frame {
|
|
|
1472
1624
|
sink;
|
|
1473
1625
|
categories = [];
|
|
1474
1626
|
documentation;
|
|
1627
|
+
documentationAttributes;
|
|
1475
1628
|
documentationSeen = false;
|
|
1476
1629
|
errors = [];
|
|
1477
1630
|
escalations = [];
|
|
@@ -1514,9 +1667,11 @@ class DefinitionsFrame extends Frame {
|
|
|
1514
1667
|
return captureUnknown(this.unknownChildren, name, attrs);
|
|
1515
1668
|
}
|
|
1516
1669
|
}
|
|
1517
|
-
setText(slot, text) {
|
|
1518
|
-
if (slot
|
|
1519
|
-
|
|
1670
|
+
setText(slot, text, attrs) {
|
|
1671
|
+
if (slot !== SLOT_DOCUMENTATION)
|
|
1672
|
+
return;
|
|
1673
|
+
this.documentation = text;
|
|
1674
|
+
this.documentationAttributes = documentationAttrs(attrs);
|
|
1520
1675
|
}
|
|
1521
1676
|
finish() {
|
|
1522
1677
|
const attrs = this.attrs;
|
|
@@ -1530,7 +1685,7 @@ class DefinitionsFrame extends Frame {
|
|
|
1530
1685
|
else if (key === "xmlns") {
|
|
1531
1686
|
namespaces[""] = value;
|
|
1532
1687
|
}
|
|
1533
|
-
else if (
|
|
1688
|
+
else if (DEFINITIONS_ATTRS.has(key)) {
|
|
1534
1689
|
}
|
|
1535
1690
|
else {
|
|
1536
1691
|
unknownAttributes[key] = value;
|
|
@@ -1544,6 +1699,9 @@ class DefinitionsFrame extends Frame {
|
|
|
1544
1699
|
namespaces,
|
|
1545
1700
|
unknownAttributes,
|
|
1546
1701
|
...(this.documentation !== undefined ? { documentation: this.documentation } : {}),
|
|
1702
|
+
...(this.documentationAttributes
|
|
1703
|
+
? { documentationAttributes: this.documentationAttributes }
|
|
1704
|
+
: {}),
|
|
1547
1705
|
...(this.categories.length > 0 ? { categories: this.categories } : {}),
|
|
1548
1706
|
errors: this.errors,
|
|
1549
1707
|
escalations: this.escalations,
|
|
@@ -1596,9 +1754,9 @@ class BpmnSink {
|
|
|
1596
1754
|
export function parseBpmn(xml) {
|
|
1597
1755
|
const sink = new BpmnSink();
|
|
1598
1756
|
if (!scanXml(xml, sink))
|
|
1599
|
-
throw new
|
|
1757
|
+
throw new ParseError("Failed to parse XML: no root element found");
|
|
1600
1758
|
if (sink.rootName !== undefined) {
|
|
1601
|
-
throw new
|
|
1759
|
+
throw new ParseError(`Expected <definitions> root element, got <${sink.rootName}>`);
|
|
1602
1760
|
}
|
|
1603
1761
|
return sink.result;
|
|
1604
1762
|
}
|