@bpmnkit/core 1.8.0 → 1.10.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/agent-cards/bpmn.md +4 -2
- package/builder-reference.md +11 -9
- package/dist/bpmn/auto-layout.js +82 -26
- package/dist/bpmn/bpmn-builder.d.ts +84 -7
- package/dist/bpmn/bpmn-builder.js +321 -76
- package/dist/bpmn/bpmn-model.d.ts +2 -0
- package/dist/bpmn/bpmn-parser.js +68 -76
- package/dist/bpmn/bpmn-serializer.js +60 -19
- package/dist/bpmn/bpmnlint.js +4 -69
- package/dist/bpmn/builder-rules.d.ts +20 -0
- package/dist/bpmn/builder-rules.js +120 -0
- package/dist/bpmn/camunda-compat-data.d.ts +10 -148
- package/dist/bpmn/camunda-compat-data.js +16 -407
- package/dist/bpmn/camunda-compat-feel.d.ts +3 -0
- package/dist/bpmn/camunda-compat-feel.js +1 -1
- package/dist/bpmn/camunda-compat.js +7 -6
- package/dist/bpmn/camunda7/export.js +4 -1
- package/dist/bpmn/camunda7/juel.js +2 -1
- package/dist/bpmn/camunda7/migrate.d.ts +23 -0
- package/dist/bpmn/camunda7/migrate.js +75 -3
- package/dist/bpmn/compact-stream.js +2 -1
- package/dist/bpmn/compact.d.ts +80 -4
- package/dist/bpmn/compact.js +220 -38
- package/dist/bpmn/feel-condition.d.ts +9 -0
- package/dist/bpmn/feel-condition.js +19 -0
- package/dist/bpmn/full-operations.js +31 -4
- package/dist/bpmn/index.d.ts +17 -1
- package/dist/bpmn/index.js +19 -25
- package/dist/bpmn/operations.d.ts +4 -4
- package/dist/bpmn/operations.js +14 -2
- package/dist/bpmn/optimize/bpmnlint-rules.js +7 -40
- package/dist/bpmn/optimize/index.js +15 -1
- package/dist/bpmn/optimize/tasks.js +12 -3
- package/dist/bpmn/process-delta.d.ts +18 -0
- package/dist/bpmn/process-delta.js +20 -2
- package/dist/bpmn/process-text-writer.js +27 -1
- package/dist/bpmn/process-text.d.ts +9 -3
- package/dist/bpmn/process-text.js +122 -16
- package/dist/bpmn/stable-ids.d.ts +2 -0
- package/dist/bpmn/stable-ids.js +8 -0
- package/dist/bpmn/xsd-guards.d.ts +8 -0
- package/dist/bpmn/xsd-guards.js +56 -0
- package/dist/bpmn/zeebe-extensions.js +2 -1
- package/dist/bpmn/zeebe-placement.js +6 -129
- package/dist/bpmn/zeebe-validate/context.d.ts +132 -0
- package/dist/bpmn/zeebe-validate/context.js +241 -0
- package/dist/bpmn/zeebe-validate/gate.d.ts +87 -0
- package/dist/bpmn/zeebe-validate/gate.js +492 -0
- package/dist/bpmn/zeebe-validate/index.d.ts +37 -0
- package/dist/bpmn/zeebe-validate/index.js +106 -0
- package/dist/bpmn/zeebe-validate/rules/events.d.ts +4 -0
- package/dist/bpmn/zeebe-validate/rules/events.js +580 -0
- package/dist/bpmn/zeebe-validate/rules/extensions.d.ts +4 -0
- package/dist/bpmn/zeebe-validate/rules/extensions.js +411 -0
- package/dist/bpmn/zeebe-validate/rules/gateways.d.ts +3 -0
- package/dist/bpmn/zeebe-validate/rules/gateways.js +296 -0
- package/dist/bpmn/zeebe-validate/rules/references.d.ts +3 -0
- package/dist/bpmn/zeebe-validate/rules/references.js +495 -0
- package/dist/bpmn/zeebe-validate/rules/structure.d.ts +3 -0
- package/dist/bpmn/zeebe-validate/rules/structure.js +629 -0
- package/dist/bpmn/zeebe-validate/rules/tasks.d.ts +4 -0
- package/dist/bpmn/zeebe-validate/rules/tasks.js +446 -0
- package/dist/bpmn/zeebe-validate/xml.d.ts +15 -0
- package/dist/bpmn/zeebe-validate/xml.js +1062 -0
- package/dist/bpmn/zeebe-validate/xsd.d.ts +19 -0
- package/dist/bpmn/zeebe-validate/xsd.js +350 -0
- package/dist/connectors/apply-element.d.ts +5 -2
- package/dist/connectors/apply-element.js +6 -0
- package/dist/connectors/apply-many.d.ts +9 -2
- package/dist/connectors/apply-many.js +17 -2
- package/dist/connectors/apply.d.ts +4 -2
- package/dist/connectors/deployability.d.ts +27 -0
- package/dist/connectors/deployability.js +41 -0
- package/dist/connectors/index.d.ts +1 -0
- package/dist/connectors/lines.d.ts +10 -0
- package/dist/connectors/lines.js +13 -4
- package/dist/dmn/dmn-model.d.ts +24 -4
- package/dist/dmn/dmn-parser.js +37 -3
- package/dist/dmn/dmn-serializer.js +48 -47
- package/dist/dmn/lint.js +4 -11
- package/dist/errors.d.ts +30 -1
- package/dist/errors.js +31 -0
- package/dist/form/form-model.d.ts +11 -0
- package/dist/form/form-parser.d.ts +1 -0
- package/dist/form/form-parser.js +48 -12
- package/dist/form/form-serializer.js +40 -17
- package/dist/form/lint.js +6 -40
- package/dist/generated/bpmn-elements.d.ts +5 -0
- package/dist/generated/bpmn-elements.js +151 -0
- package/dist/generated/camunda-compat-data.d.ts +148 -0
- package/dist/generated/camunda-compat-data.js +371 -0
- package/dist/generated/dmn-elements.d.ts +12 -0
- package/dist/generated/dmn-elements.js +45 -0
- package/dist/generated/form-elements.d.ts +5 -0
- package/dist/generated/form-elements.js +45 -0
- package/dist/generated/lint-rules.d.ts +17 -0
- package/dist/generated/lint-rules.js +116 -0
- package/dist/generated/zeebe-elements.d.ts +10 -0
- package/dist/generated/zeebe-elements.js +168 -0
- package/dist/generated/zeebe-rules.d.ts +25 -0
- package/dist/generated/zeebe-rules.js +202 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.js +4 -1
- package/dist/layout/annotations.js +21 -1
- package/dist/layout/orthogonal.js +9 -3
- package/dist/plan/compile.d.ts +26 -1
- package/dist/plan/compile.js +48 -6
- package/dist/plan/merge.d.ts +2 -1
- package/dist/plan/merge.js +13 -5
- package/package.json +2 -2
|
@@ -54,6 +54,8 @@ export interface BpmnMessageEventDefinition {
|
|
|
54
54
|
type: "message";
|
|
55
55
|
id?: string;
|
|
56
56
|
messageRef?: string;
|
|
57
|
+
/** `<extensionElements>` of the definition, e.g. `zeebe:publishMessage` of a message throw event. */
|
|
58
|
+
extensionElements?: XmlElement[];
|
|
57
59
|
/** Attributes the SDK does not model (e.g. `camunda:type`), kept for round-trip. */
|
|
58
60
|
unknownAttributes?: Record<string, string>;
|
|
59
61
|
}
|
package/dist/bpmn/bpmn-parser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ParseError } from "../errors.js";
|
|
2
|
+
import { BPMN_ELEMENTS_BY_TRAIT } from "../generated/bpmn-elements.js";
|
|
2
3
|
import { Visit, scanXml } from "../xml/xml-parser.js";
|
|
3
4
|
function localName(name) {
|
|
4
5
|
const idx = name.indexOf(":");
|
|
@@ -463,74 +464,13 @@ function contentsChild(contents, local, name, attrs) {
|
|
|
463
464
|
// ---------------------------------------------------------------------------
|
|
464
465
|
// Flow elements
|
|
465
466
|
// ---------------------------------------------------------------------------
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
"intermediateCatchEvent",
|
|
470
|
-
"intermediateThrowEvent",
|
|
471
|
-
"boundaryEvent",
|
|
472
|
-
"task",
|
|
473
|
-
"serviceTask",
|
|
474
|
-
"scriptTask",
|
|
475
|
-
"userTask",
|
|
476
|
-
"sendTask",
|
|
477
|
-
"receiveTask",
|
|
478
|
-
"businessRuleTask",
|
|
479
|
-
"manualTask",
|
|
480
|
-
"callActivity",
|
|
481
|
-
"subProcess",
|
|
482
|
-
"adHocSubProcess",
|
|
483
|
-
"eventSubProcess",
|
|
484
|
-
"transaction",
|
|
485
|
-
"exclusiveGateway",
|
|
486
|
-
"parallelGateway",
|
|
487
|
-
"inclusiveGateway",
|
|
488
|
-
"eventBasedGateway",
|
|
489
|
-
"complexGateway",
|
|
490
|
-
"dataObject",
|
|
491
|
-
"dataObjectReference",
|
|
492
|
-
"dataStoreReference",
|
|
493
|
-
]);
|
|
494
|
-
const EVENT_TYPES = new Set([
|
|
495
|
-
"startEvent",
|
|
496
|
-
"endEvent",
|
|
497
|
-
"intermediateCatchEvent",
|
|
498
|
-
"intermediateThrowEvent",
|
|
499
|
-
"boundaryEvent",
|
|
500
|
-
]);
|
|
467
|
+
// The type sets come from the spec (spec/elements/bpmn.json traits), shared with the Rust parser.
|
|
468
|
+
const FLOW_ELEMENT_TYPES = new Set(BPMN_ELEMENTS_BY_TRAIT.flowElement);
|
|
469
|
+
const EVENT_TYPES = new Set(BPMN_ELEMENTS_BY_TRAIT.event);
|
|
501
470
|
/** Types whose <multiInstanceLoopCharacteristics> child is read. */
|
|
502
|
-
const LOOP_TYPES = new Set(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
"scriptTask",
|
|
506
|
-
"userTask",
|
|
507
|
-
"businessRuleTask",
|
|
508
|
-
"manualTask",
|
|
509
|
-
"callActivity",
|
|
510
|
-
"sendTask",
|
|
511
|
-
"receiveTask",
|
|
512
|
-
"adHocSubProcess",
|
|
513
|
-
"subProcess",
|
|
514
|
-
"transaction",
|
|
515
|
-
]);
|
|
516
|
-
const CONTAINER_TYPES = new Set([
|
|
517
|
-
"adHocSubProcess",
|
|
518
|
-
"subProcess",
|
|
519
|
-
"eventSubProcess",
|
|
520
|
-
"transaction",
|
|
521
|
-
]);
|
|
522
|
-
const EVENT_DEFINITION_TYPES = new Set([
|
|
523
|
-
"timerEventDefinition",
|
|
524
|
-
"errorEventDefinition",
|
|
525
|
-
"escalationEventDefinition",
|
|
526
|
-
"messageEventDefinition",
|
|
527
|
-
"signalEventDefinition",
|
|
528
|
-
"conditionalEventDefinition",
|
|
529
|
-
"linkEventDefinition",
|
|
530
|
-
"cancelEventDefinition",
|
|
531
|
-
"terminateEventDefinition",
|
|
532
|
-
"compensateEventDefinition",
|
|
533
|
-
]);
|
|
471
|
+
const LOOP_TYPES = new Set(BPMN_ELEMENTS_BY_TRAIT.loop);
|
|
472
|
+
const CONTAINER_TYPES = new Set(BPMN_ELEMENTS_BY_TRAIT.container);
|
|
473
|
+
const EVENT_DEFINITION_TYPES = new Set(BPMN_ELEMENTS_BY_TRAIT.eventDefinition);
|
|
534
474
|
class FlowNodeFrame extends Frame {
|
|
535
475
|
type;
|
|
536
476
|
name;
|
|
@@ -723,6 +663,7 @@ class FlowNodeFrame extends Frame {
|
|
|
723
663
|
el = {
|
|
724
664
|
...base,
|
|
725
665
|
type: "adHocSubProcess",
|
|
666
|
+
isForCompensation: attr(attrs, "isForCompensation") === "true" ? true : undefined,
|
|
726
667
|
loopCharacteristics: this.loopCharacteristics,
|
|
727
668
|
completionCondition: this.completionCondition,
|
|
728
669
|
cancelRemainingInstances: attr(attrs, "cancelRemainingInstances") !== undefined
|
|
@@ -735,6 +676,7 @@ class FlowNodeFrame extends Frame {
|
|
|
735
676
|
el = {
|
|
736
677
|
...base,
|
|
737
678
|
type: "subProcess",
|
|
679
|
+
isForCompensation: attr(attrs, "isForCompensation") === "true" ? true : undefined,
|
|
738
680
|
triggeredByEvent: attr(attrs, "triggeredByEvent") !== undefined
|
|
739
681
|
? attr(attrs, "triggeredByEvent") === "true"
|
|
740
682
|
: undefined,
|
|
@@ -743,12 +685,18 @@ class FlowNodeFrame extends Frame {
|
|
|
743
685
|
};
|
|
744
686
|
break;
|
|
745
687
|
case "eventSubProcess":
|
|
746
|
-
el = {
|
|
688
|
+
el = {
|
|
689
|
+
...base,
|
|
690
|
+
type: "eventSubProcess",
|
|
691
|
+
isForCompensation: attr(attrs, "isForCompensation") === "true" ? true : undefined,
|
|
692
|
+
...contents,
|
|
693
|
+
};
|
|
747
694
|
break;
|
|
748
695
|
case "transaction":
|
|
749
696
|
el = {
|
|
750
697
|
...base,
|
|
751
698
|
type: "transaction",
|
|
699
|
+
isForCompensation: attr(attrs, "isForCompensation") === "true" ? true : undefined,
|
|
752
700
|
loopCharacteristics: this.loopCharacteristics,
|
|
753
701
|
...contents,
|
|
754
702
|
};
|
|
@@ -834,13 +782,7 @@ function eventDefinitionFrame(local, attrs, target) {
|
|
|
834
782
|
});
|
|
835
783
|
return null;
|
|
836
784
|
case "messageEventDefinition":
|
|
837
|
-
target
|
|
838
|
-
type: "message",
|
|
839
|
-
id: attr(attrs, "id"),
|
|
840
|
-
messageRef: attr(attrs, "messageRef"),
|
|
841
|
-
...definitionExtras(attrs, MESSAGE_DEF_ATTRS),
|
|
842
|
-
});
|
|
843
|
-
return null;
|
|
785
|
+
return new MessageDefinitionFrame(attrs, target);
|
|
844
786
|
case "signalEventDefinition":
|
|
845
787
|
target.push({
|
|
846
788
|
type: "signal",
|
|
@@ -879,6 +821,32 @@ function eventDefinitionFrame(local, attrs, target) {
|
|
|
879
821
|
return null;
|
|
880
822
|
}
|
|
881
823
|
}
|
|
824
|
+
/** Keeps `zeebe:publishMessage`, which Zeebe reads from the message event definition. */
|
|
825
|
+
class MessageDefinitionFrame extends Frame {
|
|
826
|
+
attrs;
|
|
827
|
+
target;
|
|
828
|
+
extensionElements = null;
|
|
829
|
+
constructor(attrs, target) {
|
|
830
|
+
super();
|
|
831
|
+
this.attrs = attrs;
|
|
832
|
+
this.target = target;
|
|
833
|
+
}
|
|
834
|
+
child(local) {
|
|
835
|
+
if (local !== "extensionElements" || this.extensionElements !== null)
|
|
836
|
+
return null;
|
|
837
|
+
this.extensionElements = [];
|
|
838
|
+
return new TreeFrame(this.extensionElements);
|
|
839
|
+
}
|
|
840
|
+
finish() {
|
|
841
|
+
this.target.push({
|
|
842
|
+
type: "message",
|
|
843
|
+
id: attr(this.attrs, "id"),
|
|
844
|
+
messageRef: attr(this.attrs, "messageRef"),
|
|
845
|
+
...(this.extensionElements ? { extensionElements: this.extensionElements } : {}),
|
|
846
|
+
...definitionExtras(this.attrs, MESSAGE_DEF_ATTRS),
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
}
|
|
882
850
|
class TimerDefinitionFrame extends Frame {
|
|
883
851
|
attrs;
|
|
884
852
|
target;
|
|
@@ -1361,7 +1329,11 @@ class ProcessFrame extends Frame {
|
|
|
1361
1329
|
this.target.push({
|
|
1362
1330
|
id: this.id,
|
|
1363
1331
|
name: attr(attrs, "name"),
|
|
1364
|
-
|
|
1332
|
+
// Absent, "true" and "false" are three states: BPMN reads an absent flag as
|
|
1333
|
+
// false, but a file that says "false" out loud should say it again.
|
|
1334
|
+
isExecutable: attr(attrs, "isExecutable") === undefined
|
|
1335
|
+
? undefined
|
|
1336
|
+
: attr(attrs, "isExecutable") === "true",
|
|
1365
1337
|
...(this.documentation !== undefined ? { documentation: this.documentation } : {}),
|
|
1366
1338
|
...(this.documentationAttributes
|
|
1367
1339
|
? { documentationAttributes: this.documentationAttributes }
|
|
@@ -1681,7 +1653,27 @@ class DefinitionsFrame extends Frame {
|
|
|
1681
1653
|
this.documentation = text;
|
|
1682
1654
|
this.documentationAttributes = documentationAttrs(attrs);
|
|
1683
1655
|
}
|
|
1656
|
+
/**
|
|
1657
|
+
* The serializer writes the definitions' documentation inside a bare `extension`
|
|
1658
|
+
* (the schema allows no `documentation` on `definitions`); read it back from there.
|
|
1659
|
+
*/
|
|
1660
|
+
adoptExtensionDocumentation() {
|
|
1661
|
+
if (this.documentationSeen)
|
|
1662
|
+
return;
|
|
1663
|
+
const index = this.unknownChildren.findIndex((c) => localName(c.name) === "extension" &&
|
|
1664
|
+
Object.keys(c.attributes).length === 0 &&
|
|
1665
|
+
c.children.length === 1 &&
|
|
1666
|
+
localName(c.children[0]?.name ?? "") === "documentation" &&
|
|
1667
|
+
c.children[0]?.children.length === 0);
|
|
1668
|
+
const doc = this.unknownChildren[index]?.children[0];
|
|
1669
|
+
if (doc === undefined)
|
|
1670
|
+
return;
|
|
1671
|
+
this.unknownChildren.splice(index, 1);
|
|
1672
|
+
this.documentation = doc.text ?? "";
|
|
1673
|
+
this.documentationAttributes = documentationAttrs(doc.attributes);
|
|
1674
|
+
}
|
|
1684
1675
|
finish() {
|
|
1676
|
+
this.adoptExtensionDocumentation();
|
|
1685
1677
|
const attrs = this.attrs;
|
|
1686
1678
|
const namespaces = {};
|
|
1687
1679
|
const unknownAttributes = {};
|
|
@@ -95,7 +95,7 @@ function serializeEventDefinitions(defs, bp) {
|
|
|
95
95
|
attrs.id = d.id;
|
|
96
96
|
if (d.messageRef)
|
|
97
97
|
attrs.messageRef = d.messageRef;
|
|
98
|
-
return el(`${bp}messageEventDefinition`, withUnknown(attrs, d), []);
|
|
98
|
+
return el(`${bp}messageEventDefinition`, withUnknown(attrs, d), serializeExtensionElements(d.extensionElements ?? [], bp));
|
|
99
99
|
}
|
|
100
100
|
case "signal": {
|
|
101
101
|
const attrs = {};
|
|
@@ -119,8 +119,8 @@ function serializeEventDefinitions(defs, bp) {
|
|
|
119
119
|
const attrs = {};
|
|
120
120
|
if (d.id)
|
|
121
121
|
attrs.id = d.id;
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// BPMN20.xsd requires `name`; an empty one is left for the validator to name.
|
|
123
|
+
attrs.name = d.name ?? "";
|
|
124
124
|
return el(`${bp}linkEventDefinition`, withUnknown(attrs, d), []);
|
|
125
125
|
}
|
|
126
126
|
case "cancel": {
|
|
@@ -224,6 +224,21 @@ function serializeLoopCharacteristics(lc, bp) {
|
|
|
224
224
|
function flowRefs(refs, tag, bp) {
|
|
225
225
|
return refs.map((r) => el(`${bp}${tag}`, {}, [], r));
|
|
226
226
|
}
|
|
227
|
+
/** An element name without its namespace prefix. */
|
|
228
|
+
function localName(name) {
|
|
229
|
+
return name.slice(name.indexOf(":") + 1);
|
|
230
|
+
}
|
|
231
|
+
/** Event children (tCatchEvent / tThrowEvent) that precede the data associations. */
|
|
232
|
+
const EVENT_DATA = new Set(["dataInput", "dataOutput"]);
|
|
233
|
+
/** Process children of tCallableElement and tProcess that precede the lane set and flow elements. */
|
|
234
|
+
const PROCESS_HEAD = new Set([
|
|
235
|
+
"supportedInterfaceRef",
|
|
236
|
+
"ioSpecification",
|
|
237
|
+
"ioBinding",
|
|
238
|
+
"auditing",
|
|
239
|
+
"monitoring",
|
|
240
|
+
"property",
|
|
241
|
+
]);
|
|
227
242
|
function serializeFlowElement(fe, ns) {
|
|
228
243
|
const bp = bpmnPrefix(ns);
|
|
229
244
|
const attrs = { id: fe.id, ...fe.unknownAttributes };
|
|
@@ -241,17 +256,25 @@ function serializeFlowElement(fe, ns) {
|
|
|
241
256
|
// Incoming / outgoing
|
|
242
257
|
children.push(...flowRefs(fe.incoming, "incoming", bp));
|
|
243
258
|
children.push(...flowRefs(fe.outgoing, "outgoing", bp));
|
|
244
|
-
// Data wiring
|
|
259
|
+
// Data wiring. Unmodelled children the schema places between the modelled ones go there:
|
|
260
|
+
// an activity's `ioSpecification` precedes its properties, and an event's data inputs and
|
|
261
|
+
// outputs precede its data associations; Zeebe's XSD stage rejects any other order.
|
|
262
|
+
const unknown = fe.unknownChildren ?? [];
|
|
263
|
+
children.push(...unknown.filter((c) => localName(c.name) === "ioSpecification"));
|
|
245
264
|
for (const property of fe.properties ?? []) {
|
|
246
265
|
children.push(serializeProperty(property, bp));
|
|
247
266
|
}
|
|
267
|
+
children.push(...unknown.filter((c) => EVENT_DATA.has(localName(c.name))));
|
|
248
268
|
for (const association of fe.dataInputAssociations ?? []) {
|
|
249
269
|
children.push(serializeDataAssociation(association, "dataInputAssociation", bp));
|
|
250
270
|
}
|
|
251
271
|
for (const association of fe.dataOutputAssociations ?? []) {
|
|
252
272
|
children.push(serializeDataAssociation(association, "dataOutputAssociation", bp));
|
|
253
273
|
}
|
|
254
|
-
children.push(...(
|
|
274
|
+
children.push(...unknown.filter((c) => {
|
|
275
|
+
const name = localName(c.name);
|
|
276
|
+
return name !== "ioSpecification" && !EVENT_DATA.has(name);
|
|
277
|
+
}));
|
|
255
278
|
switch (fe.type) {
|
|
256
279
|
case "startEvent":
|
|
257
280
|
if (fe.isInterrupting === false)
|
|
@@ -301,6 +324,8 @@ function serializeFlowElement(fe, ns) {
|
|
|
301
324
|
children.push(...serializeProcessContents(fe, ns));
|
|
302
325
|
break;
|
|
303
326
|
case "eventSubProcess":
|
|
327
|
+
// BPMN has no eventSubProcess element: it is a subProcess triggered by an event.
|
|
328
|
+
attrs.triggeredByEvent = "true";
|
|
304
329
|
children.push(...serializeProcessContents(fe, ns));
|
|
305
330
|
break;
|
|
306
331
|
case "transaction":
|
|
@@ -327,17 +352,16 @@ function serializeFlowElement(fe, ns) {
|
|
|
327
352
|
attrs.isCollection = "true";
|
|
328
353
|
break;
|
|
329
354
|
case "dataObjectReference":
|
|
355
|
+
// BPMN20.xsd allows isCollection only on dataObject; Zeebe rejects it here.
|
|
330
356
|
if (fe.dataObjectRef !== undefined)
|
|
331
357
|
attrs.dataObjectRef = fe.dataObjectRef;
|
|
332
|
-
if (fe.isCollection)
|
|
333
|
-
attrs.isCollection = "true";
|
|
334
358
|
break;
|
|
335
359
|
case "dataStoreReference":
|
|
336
360
|
if (fe.dataStoreRef !== undefined)
|
|
337
361
|
attrs.dataStoreRef = fe.dataStoreRef;
|
|
338
362
|
break;
|
|
339
363
|
}
|
|
340
|
-
return el(`${bp}${fe.type}`, attrs, children);
|
|
364
|
+
return el(`${bp}${fe.type === "eventSubProcess" ? "subProcess" : fe.type}`, attrs, children);
|
|
341
365
|
}
|
|
342
366
|
// ---------------------------------------------------------------------------
|
|
343
367
|
// Sequence flows
|
|
@@ -433,17 +457,18 @@ function serializeLane(lane, bp) {
|
|
|
433
457
|
const children = serializeBaseChildren(lane, bp);
|
|
434
458
|
children.push(...lane.flowNodeRefs.map((ref) => el(`${bp}flowNodeRef`, {}, [], ref)));
|
|
435
459
|
if (lane.childLaneSet) {
|
|
436
|
-
children.push(serializeLaneSet(lane.childLaneSet, bp));
|
|
460
|
+
children.push(serializeLaneSet(lane.childLaneSet, bp, "childLaneSet"));
|
|
437
461
|
}
|
|
438
462
|
return el(`${bp}lane`, attrs, children);
|
|
439
463
|
}
|
|
440
|
-
|
|
464
|
+
/** `tag` is `childLaneSet` inside a lane: BPMN names the nested set differently. */
|
|
465
|
+
function serializeLaneSet(laneSet, bp, tag = "laneSet") {
|
|
441
466
|
const attrs = { ...laneSet.unknownAttributes };
|
|
442
467
|
if (laneSet.id)
|
|
443
468
|
attrs.id = laneSet.id;
|
|
444
469
|
if (laneSet.name !== undefined)
|
|
445
470
|
attrs.name = laneSet.name;
|
|
446
|
-
return el(`${bp}
|
|
471
|
+
return el(`${bp}${tag}`, attrs, laneSet.lanes.map((l) => serializeLane(l, bp)));
|
|
447
472
|
}
|
|
448
473
|
// ---------------------------------------------------------------------------
|
|
449
474
|
// Process
|
|
@@ -453,18 +478,20 @@ function serializeProcess(process, ns) {
|
|
|
453
478
|
const attrs = { id: process.id, ...process.unknownAttributes };
|
|
454
479
|
if (process.name !== undefined)
|
|
455
480
|
attrs.name = process.name;
|
|
456
|
-
if (process.isExecutable)
|
|
457
|
-
attrs.isExecutable =
|
|
481
|
+
if (process.isExecutable !== undefined)
|
|
482
|
+
attrs.isExecutable = String(process.isExecutable);
|
|
458
483
|
const children = serializeBaseChildren({
|
|
459
484
|
documentation: process.documentation,
|
|
460
485
|
documentationAttributes: process.documentationAttributes,
|
|
461
486
|
extensionElements: process.extensionElements,
|
|
462
487
|
}, bp);
|
|
488
|
+
const unknown = process.unknownChildren ?? [];
|
|
489
|
+
children.push(...unknown.filter((c) => PROCESS_HEAD.has(localName(c.name))));
|
|
463
490
|
if (process.laneSet) {
|
|
464
491
|
children.push(serializeLaneSet(process.laneSet, bp));
|
|
465
492
|
}
|
|
466
493
|
children.push(...serializeProcessContents(process, ns));
|
|
467
|
-
children.push(...(
|
|
494
|
+
children.push(...unknown.filter((c) => !PROCESS_HEAD.has(localName(c.name))));
|
|
468
495
|
return el(`${bp}process`, attrs, children);
|
|
469
496
|
}
|
|
470
497
|
// ---------------------------------------------------------------------------
|
|
@@ -659,17 +686,26 @@ export function serializeBpmn(definitions) {
|
|
|
659
686
|
attrs[key] = value;
|
|
660
687
|
}
|
|
661
688
|
const children = [];
|
|
689
|
+
// Unmodelled children first: `import` and `extension` precede the root
|
|
690
|
+
// elements in the schema, and the rest are root elements themselves, so they
|
|
691
|
+
// sit legally alongside the modelled ones.
|
|
692
|
+
// `relationship` is the exception: the schema puts it after the diagrams.
|
|
693
|
+
const unknown = definitions.unknownChildren ?? [];
|
|
694
|
+
const isRelationship = (c) => localName(c.name) === "relationship";
|
|
695
|
+
const isImport = (c) => localName(c.name) === "import";
|
|
696
|
+
children.push(...unknown.filter(isImport));
|
|
697
|
+
// The schema's `tDefinitions` has no `documentation` child (Zeebe refuses one), but an
|
|
698
|
+
// `extension` may carry documentation; the parser reads it back from there.
|
|
662
699
|
if (definitions.documentation !== undefined) {
|
|
663
|
-
children.push(el(`${bp}
|
|
700
|
+
children.push(el(`${bp}extension`, {}, [
|
|
701
|
+
el(`${bp}documentation`, definitions.documentationAttributes ?? {}, [], definitions.documentation),
|
|
702
|
+
]));
|
|
664
703
|
}
|
|
665
704
|
// Categories supply the labels groups reference
|
|
666
705
|
for (const category of definitions.categories ?? []) {
|
|
667
706
|
children.push(serializeCategory(category, bp));
|
|
668
707
|
}
|
|
669
|
-
|
|
670
|
-
// elements in the schema, and the rest are root elements themselves, so they
|
|
671
|
-
// sit legally alongside the modelled ones.
|
|
672
|
-
children.push(...(definitions.unknownChildren ?? []));
|
|
708
|
+
children.push(...unknown.filter((c) => !isRelationship(c) && !isImport(c)));
|
|
673
709
|
// Root elements: errors, escalations, messages, signals first
|
|
674
710
|
for (const e of definitions.escalations) {
|
|
675
711
|
children.push(serializeEscalation(e, bp));
|
|
@@ -695,6 +731,7 @@ export function serializeBpmn(definitions) {
|
|
|
695
731
|
for (const d of definitions.diagrams) {
|
|
696
732
|
children.push(serializeDiagram(d, ns));
|
|
697
733
|
}
|
|
734
|
+
children.push(...unknown.filter(isRelationship));
|
|
698
735
|
const root = el(`${bp}definitions`, attrs, children);
|
|
699
736
|
declareUsedNamespaces(root, attrs);
|
|
700
737
|
return serializeXml(root);
|
|
@@ -720,6 +757,10 @@ const KNOWN_NAMESPACE_URIS = {
|
|
|
720
757
|
modeler: "http://camunda.org/schema/modeler/1.0",
|
|
721
758
|
bioc: "http://bpmn.io/schema/bpmn/biocolor/1.0",
|
|
722
759
|
color: "http://www.omg.org/spec/BPMN/non-normative/color/1.0",
|
|
760
|
+
// Not an extension, but `xsi:type` rides on content the serializer copies
|
|
761
|
+
// (condition expressions, timer values) and the builder can add it to a
|
|
762
|
+
// parsed document that never declared xsi.
|
|
763
|
+
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
|
723
764
|
};
|
|
724
765
|
/** Prefixes an element tree uses, and prefixes it declares — at any depth. */
|
|
725
766
|
function collectPrefixes(node, used, declared) {
|
package/dist/bpmn/bpmnlint.js
CHANGED
|
@@ -16,78 +16,13 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
|
+
import { CORRECTNESS_PRESET, RECOMMENDED_PRESET, RULE_NAMES_ALL } from "../generated/lint-rules.js";
|
|
19
20
|
import { NATIVE_BPMNLINT_RULES, analyzeBpmnlintRules } from "./optimize/bpmnlint-rules.js";
|
|
20
|
-
/** bpmnlint's built-in presets
|
|
21
|
-
const RULE_NAMES_ALL = [
|
|
22
|
-
"ad-hoc-sub-process",
|
|
23
|
-
"conditional-event",
|
|
24
|
-
"conditional-flows",
|
|
25
|
-
"end-event-required",
|
|
26
|
-
"event-based-gateway",
|
|
27
|
-
"event-sub-process-typed-start-event",
|
|
28
|
-
"fake-join",
|
|
29
|
-
"global",
|
|
30
|
-
"label-required",
|
|
31
|
-
"link-event",
|
|
32
|
-
"no-bpmndi",
|
|
33
|
-
"no-complex-gateway",
|
|
34
|
-
"no-disconnected",
|
|
35
|
-
"no-duplicate-sequence-flows",
|
|
36
|
-
"no-gateway-join-fork",
|
|
37
|
-
"no-implicit-end",
|
|
38
|
-
"no-implicit-split",
|
|
39
|
-
"no-implicit-start",
|
|
40
|
-
"no-inclusive-gateway",
|
|
41
|
-
"no-overlapping-elements",
|
|
42
|
-
"single-blank-start-event",
|
|
43
|
-
"single-event-definition",
|
|
44
|
-
"standard-size",
|
|
45
|
-
"start-event-required",
|
|
46
|
-
"sub-process-blank-start-event",
|
|
47
|
-
"superfluous-gateway",
|
|
48
|
-
"superfluous-label",
|
|
49
|
-
"superfluous-termination",
|
|
50
|
-
];
|
|
21
|
+
/** bpmnlint's built-in presets (see `BPMNLINT_VERSION`); the data lives in `spec/lint-rules.json`. */
|
|
51
22
|
const PRESETS = {
|
|
52
23
|
all: Object.fromEntries(RULE_NAMES_ALL.map((name) => [name, "error"])),
|
|
53
|
-
correctness:
|
|
54
|
-
|
|
55
|
-
"conditional-event": "error",
|
|
56
|
-
"event-based-gateway": "error",
|
|
57
|
-
"event-sub-process-typed-start-event": "error",
|
|
58
|
-
"link-event": "error",
|
|
59
|
-
"no-duplicate-sequence-flows": "warn",
|
|
60
|
-
"sub-process-blank-start-event": "error",
|
|
61
|
-
"single-blank-start-event": "error",
|
|
62
|
-
},
|
|
63
|
-
recommended: {
|
|
64
|
-
"ad-hoc-sub-process": "error",
|
|
65
|
-
"conditional-flows": "error",
|
|
66
|
-
"end-event-required": "error",
|
|
67
|
-
"event-based-gateway": "error",
|
|
68
|
-
"event-sub-process-typed-start-event": "error",
|
|
69
|
-
"fake-join": "warn",
|
|
70
|
-
global: "warn",
|
|
71
|
-
"label-required": "error",
|
|
72
|
-
"link-event": "error",
|
|
73
|
-
"no-bpmndi": "error",
|
|
74
|
-
"no-complex-gateway": "error",
|
|
75
|
-
"no-disconnected": "error",
|
|
76
|
-
"no-duplicate-sequence-flows": "error",
|
|
77
|
-
"no-gateway-join-fork": "error",
|
|
78
|
-
"no-implicit-split": "error",
|
|
79
|
-
"no-implicit-end": "error",
|
|
80
|
-
"no-implicit-start": "error",
|
|
81
|
-
"no-inclusive-gateway": "warn",
|
|
82
|
-
"no-overlapping-elements": "warn",
|
|
83
|
-
"single-blank-start-event": "error",
|
|
84
|
-
"single-event-definition": "error",
|
|
85
|
-
"start-event-required": "error",
|
|
86
|
-
"sub-process-blank-start-event": "error",
|
|
87
|
-
"superfluous-gateway": "warn",
|
|
88
|
-
"superfluous-label": "warn",
|
|
89
|
-
"superfluous-termination": "warn",
|
|
90
|
-
},
|
|
24
|
+
correctness: CORRECTNESS_PRESET,
|
|
25
|
+
recommended: RECOMMENDED_PRESET,
|
|
91
26
|
};
|
|
92
27
|
const NUMERIC_SEVERITY = ["off", "warn", "error", "info"];
|
|
93
28
|
function configError(message) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BpmnDefinitions } from "./bpmn-model.js";
|
|
2
|
+
/**
|
|
3
|
+
* The builder's Camunda 8 rules: what Zeebe would refuse, said in the builder's
|
|
4
|
+
* terms (the option or call that fixes it) before the generic deploy check runs.
|
|
5
|
+
* They read the built model, not the calls, so the Rust twin
|
|
6
|
+
* (`bpmnkit_builder::rules`) gives the same answer on the same (pinned) model.
|
|
7
|
+
* Walk order is the model's: processes, then each scope's elements in order,
|
|
8
|
+
* descending into sub-processes after the element itself.
|
|
9
|
+
*/
|
|
10
|
+
/** What `placeholders: true` fills, so the rules leave those gaps to the gate. */
|
|
11
|
+
export interface BuilderRuleOptions {
|
|
12
|
+
placeholders?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The first Camunda 8 builder rule the model breaks, or `undefined`.
|
|
16
|
+
* Only rules that are Camunda 8 requirements live here; structural ones
|
|
17
|
+
* (nothing after an end event) are refused at the call that breaks them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function camunda8BuilderProblem(defs: BpmnDefinitions, options?: BuilderRuleOptions): string | undefined;
|
|
20
|
+
//# sourceMappingURL=builder-rules.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const zeebe = (extensions, name) => extensions?.find((x) => x.name === `zeebe:${name}`);
|
|
2
|
+
/** Zeebe reads a value without a leading `=` as a static string. */
|
|
3
|
+
const isStatic = (value) => value !== undefined && value !== "" && !value.startsWith("=");
|
|
4
|
+
function staticFeel(field, value, elementId) {
|
|
5
|
+
return `${field} "${value}" of "${elementId}" is a static value; Camunda 8 needs a FEEL expression here, e.g. "=${value}"`;
|
|
6
|
+
}
|
|
7
|
+
/** The message a send task or message throw/end event refers to, if it is one. */
|
|
8
|
+
function messageJobLabel(el) {
|
|
9
|
+
if (el.type === "sendTask")
|
|
10
|
+
return "Send task";
|
|
11
|
+
if (el.type !== "intermediateThrowEvent" && el.type !== "endEvent")
|
|
12
|
+
return undefined;
|
|
13
|
+
if (!el.eventDefinitions.some((d) => d.type === "message"))
|
|
14
|
+
return undefined;
|
|
15
|
+
return el.type === "endEvent" ? "Message end event" : "Message throw event";
|
|
16
|
+
}
|
|
17
|
+
function hasMessageImplementation(el) {
|
|
18
|
+
if (zeebe(el.extensionElements, "taskDefinition") ||
|
|
19
|
+
zeebe(el.extensionElements, "publishMessage"))
|
|
20
|
+
return true;
|
|
21
|
+
if (!("eventDefinitions" in el))
|
|
22
|
+
return false;
|
|
23
|
+
return el.eventDefinitions.some((d) => d.type === "message" && zeebe(d.extensionElements, "publishMessage") !== undefined);
|
|
24
|
+
}
|
|
25
|
+
function messageRefOf(el) {
|
|
26
|
+
if ("messageRef" in el && typeof el.messageRef === "string")
|
|
27
|
+
return el.messageRef;
|
|
28
|
+
if (!("eventDefinitions" in el))
|
|
29
|
+
return undefined;
|
|
30
|
+
for (const d of el.eventDefinitions)
|
|
31
|
+
if (d.type === "message")
|
|
32
|
+
return d.messageRef;
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
function elementProblem(el, flows, defs, options) {
|
|
36
|
+
const fill = options.placeholders === true;
|
|
37
|
+
if (!fill && (el.type === "exclusiveGateway" || el.type === "inclusiveGateway")) {
|
|
38
|
+
const outgoing = flows.filter((f) => f.sourceRef === el.id);
|
|
39
|
+
if (outgoing.length > 1) {
|
|
40
|
+
const kind = el.type === "exclusiveGateway" ? "exclusive" : "inclusive";
|
|
41
|
+
for (const flow of outgoing) {
|
|
42
|
+
if (flow.conditionExpression !== undefined || el.default === flow.id)
|
|
43
|
+
continue;
|
|
44
|
+
return `Flow "${flow.id}" leaves ${kind} gateway "${el.id}" without a condition: give its branch .condition("=<FEEL>") or .defaultFlow(); Camunda 8 needs one when a gateway has several outgoing flows`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const label = messageJobLabel(el);
|
|
49
|
+
if (!fill && label !== undefined && !hasMessageImplementation(el)) {
|
|
50
|
+
return `${label} "${el.id}" needs a taskType: Camunda 8 hands the message to a job worker of that type (zeebe:taskDefinition)`;
|
|
51
|
+
}
|
|
52
|
+
if (el.type === "adHocSubProcess") {
|
|
53
|
+
const adHoc = zeebe(el.extensionElements, "adHoc");
|
|
54
|
+
if (zeebe(el.extensionElements, "taskDefinition")) {
|
|
55
|
+
const forbidden = [
|
|
56
|
+
adHoc?.attributes.activeElementsCollection !== undefined
|
|
57
|
+
? "activeElementsCollection"
|
|
58
|
+
: undefined,
|
|
59
|
+
el.completionCondition !== undefined ? "completionCondition" : undefined,
|
|
60
|
+
el.cancelRemainingInstances === false ? "cancelRemainingInstances: false" : undefined,
|
|
61
|
+
].find((x) => x !== undefined);
|
|
62
|
+
if (forbidden !== undefined) {
|
|
63
|
+
return `Ad-hoc sub-process "${el.id}" has a taskDefinition (an AI agent) and ${forbidden}; Camunda 8 refuses that combination: remove ${forbidden}, the agent job decides which tools run and when it is done`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const element = adHoc?.attributes.outputElement;
|
|
67
|
+
const collection = adHoc?.attributes.outputCollection;
|
|
68
|
+
if ((element === undefined) !== (collection === undefined)) {
|
|
69
|
+
const [set, missing] = element === undefined
|
|
70
|
+
? ["outputCollection", "outputElement"]
|
|
71
|
+
: ["outputElement", "outputCollection"];
|
|
72
|
+
return `Ad-hoc sub-process "${el.id}" sets ${set} without ${missing}: set both, or neither`;
|
|
73
|
+
}
|
|
74
|
+
const active = adHoc?.attributes.activeElementsCollection;
|
|
75
|
+
if (isStatic(active))
|
|
76
|
+
return staticFeel("activeElementsCollection", active, el.id);
|
|
77
|
+
}
|
|
78
|
+
const ref = messageRefOf(el);
|
|
79
|
+
if (ref !== undefined) {
|
|
80
|
+
const own = zeebe(el.extensionElements, "subscription");
|
|
81
|
+
const shared = zeebe(defs.messages?.find((m) => m.id === ref)?.extensionElements, "subscription");
|
|
82
|
+
const key = (own ?? shared)?.attributes.correlationKey;
|
|
83
|
+
if (isStatic(key))
|
|
84
|
+
return staticFeel("correlationKey", key, el.id);
|
|
85
|
+
}
|
|
86
|
+
if ("loopCharacteristics" in el && el.loopCharacteristics !== undefined) {
|
|
87
|
+
const loop = zeebe(el.loopCharacteristics.extensionElements, "loopCharacteristics");
|
|
88
|
+
const collection = loop?.attributes.inputCollection;
|
|
89
|
+
if (isStatic(collection))
|
|
90
|
+
return staticFeel("Multi-instance inputCollection", collection, el.id);
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
function scopeProblem(elements, flows, defs, options) {
|
|
95
|
+
for (const el of elements) {
|
|
96
|
+
const problem = elementProblem(el, flows, defs, options);
|
|
97
|
+
if (problem !== undefined)
|
|
98
|
+
return problem;
|
|
99
|
+
if ("flowElements" in el && Array.isArray(el.flowElements)) {
|
|
100
|
+
const inner = scopeProblem(el.flowElements, el.sequenceFlows ?? [], defs, options);
|
|
101
|
+
if (inner !== undefined)
|
|
102
|
+
return inner;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The first Camunda 8 builder rule the model breaks, or `undefined`.
|
|
109
|
+
* Only rules that are Camunda 8 requirements live here; structural ones
|
|
110
|
+
* (nothing after an end event) are refused at the call that breaks them.
|
|
111
|
+
*/
|
|
112
|
+
export function camunda8BuilderProblem(defs, options = {}) {
|
|
113
|
+
for (const process of defs.processes) {
|
|
114
|
+
const problem = scopeProblem(process.flowElements, process.sequenceFlows, defs, options);
|
|
115
|
+
if (problem !== undefined)
|
|
116
|
+
return problem;
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=builder-rules.js.map
|