bpmnlint 11.9.0 → 11.11.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/config/all.js +1 -0
- package/config/correctness.js +1 -0
- package/lib/testers/helper.js +33 -8
- package/package.json +3 -3
- package/rules/ad-hoc-sub-process.js +0 -1
- package/rules/conditional-event.js +52 -0
- package/rules/helper.js +16 -0
package/config/all.js
CHANGED
package/config/correctness.js
CHANGED
package/lib/testers/helper.js
CHANGED
|
@@ -3,16 +3,37 @@ const { BpmnModdle } = require('bpmn-moddle');
|
|
|
3
3
|
|
|
4
4
|
const { readFileSync } = require('node:fs');
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef { any } ModdleElement
|
|
8
|
+
*
|
|
9
|
+
* @typedef { {
|
|
10
|
+
* root: ModdleElement,
|
|
11
|
+
* moddle: BpmnModdle,
|
|
12
|
+
* warnings: any[]
|
|
13
|
+
* } } CreatedModdle
|
|
14
|
+
*/
|
|
6
15
|
|
|
7
16
|
/**
|
|
8
17
|
* Create moddle instance.
|
|
9
18
|
*
|
|
10
|
-
* @param {
|
|
19
|
+
* @param {string} xml the XML string
|
|
20
|
+
* @param {string} [elementType]
|
|
21
|
+
* @param {Object} [moddleExtensions]
|
|
11
22
|
*
|
|
12
|
-
* @return {Promise<
|
|
23
|
+
* @return {Promise<CreatedModdle>}
|
|
13
24
|
*/
|
|
14
|
-
async function createModdle(xml, elementType = 'bpmn:Definitions') {
|
|
15
|
-
|
|
25
|
+
async function createModdle(xml, elementType = 'bpmn:Definitions', moddleExtensions) {
|
|
26
|
+
|
|
27
|
+
if (typeof elementType !== 'string') {
|
|
28
|
+
moddleExtensions = elementType;
|
|
29
|
+
elementType = undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof elementType === 'undefined') {
|
|
33
|
+
elementType = 'bpmn:Definitions';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const moddle = new BpmnModdle(moddleExtensions);
|
|
16
37
|
|
|
17
38
|
const {
|
|
18
39
|
rootElement: root,
|
|
@@ -22,6 +43,8 @@ async function createModdle(xml, elementType = 'bpmn:Definitions') {
|
|
|
22
43
|
return {
|
|
23
44
|
root,
|
|
24
45
|
moddle,
|
|
46
|
+
|
|
47
|
+
// @ts-ignore-next-line "legacy"
|
|
25
48
|
context: {
|
|
26
49
|
warnings
|
|
27
50
|
},
|
|
@@ -35,14 +58,16 @@ module.exports.createModdle = createModdle;
|
|
|
35
58
|
/**
|
|
36
59
|
* Return moddle instance, read from the given file.
|
|
37
60
|
*
|
|
38
|
-
* @param {
|
|
61
|
+
* @param {string|URL} filePath
|
|
62
|
+
* @param {string} [elementType]
|
|
63
|
+
* @param {Object} [moddleExtensions]
|
|
39
64
|
*
|
|
40
|
-
* @return {Promise<
|
|
65
|
+
* @return {Promise<CreatedModdle>}
|
|
41
66
|
*/
|
|
42
|
-
function readModdle(filePath) {
|
|
67
|
+
function readModdle(filePath, elementType, moddleExtensions) {
|
|
43
68
|
const contents = readFileSync(filePath, 'utf8');
|
|
44
69
|
|
|
45
|
-
return createModdle(contents);
|
|
70
|
+
return createModdle(contents, elementType, moddleExtensions);
|
|
46
71
|
}
|
|
47
72
|
|
|
48
73
|
module.exports.readModdle = readModdle;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmnlint",
|
|
3
3
|
"description": "Validate your BPMN diagrams based on configurable lint rules",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.11.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"bpmnlint",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"lint": "eslint .",
|
|
32
32
|
"lint:types": "tsc",
|
|
33
33
|
"dev": "npm test -- --watch",
|
|
34
|
-
"test": "mocha --exclude
|
|
34
|
+
"test": "mocha --exclude \"test/integration/*/**\" \"test/**/*.*js\"",
|
|
35
35
|
"test-coverage": "nyc --reporter=lcov --reporter=html npm test",
|
|
36
36
|
"generate-docs-images": "npx @bpmn-io/bpmnlint-generate-docs-images ."
|
|
37
37
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tiny-glob": "^0.2.9"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@bpmn-io/bpmnlint-generate-docs-images": "^1.
|
|
54
|
+
"@bpmn-io/bpmnlint-generate-docs-images": "^1.2.0",
|
|
55
55
|
"@types/mocha": "^10.0.10",
|
|
56
56
|
"chai": "^6.2.2",
|
|
57
57
|
"eslint": "^9.39.2",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const {
|
|
2
|
+
is
|
|
3
|
+
} = require('bpmnlint-utils');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
annotateRule,
|
|
7
|
+
isInExecutableProcess
|
|
8
|
+
} = require('./helper');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Ensures that a conditional event has a condition specified.
|
|
13
|
+
*
|
|
14
|
+
* @type { import('../lib/types.js').RuleFactory }
|
|
15
|
+
*/
|
|
16
|
+
module.exports = function() {
|
|
17
|
+
|
|
18
|
+
function check(node, reporter) {
|
|
19
|
+
|
|
20
|
+
if (!isInExecutableProcess(node)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const eventDefinition = getConditionalEventDefinition(node);
|
|
25
|
+
|
|
26
|
+
if (!eventDefinition) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!hasCondition(eventDefinition)) {
|
|
31
|
+
reporter.report(node.id, 'Conditional event is missing a condition', [ 'condition' ]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return annotateRule('conditional-event', {
|
|
36
|
+
check
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function getConditionalEventDefinition(node) {
|
|
42
|
+
if (!is(node, 'bpmn:Event')) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const eventDefinitions = node.eventDefinitions || [];
|
|
47
|
+
return eventDefinitions.find(def => is(def, 'bpmn:ConditionalEventDefinition'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hasCondition(eventDefinition) {
|
|
51
|
+
return !!eventDefinition.condition?.body;
|
|
52
|
+
}
|
package/rules/helper.js
CHANGED
|
@@ -71,6 +71,22 @@ function findParent(node, type) {
|
|
|
71
71
|
module.exports.findParent = findParent;
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Check if the node is inside of an executable process.
|
|
76
|
+
*
|
|
77
|
+
* @param { ModdleElement } node
|
|
78
|
+
*
|
|
79
|
+
* @return { boolean }
|
|
80
|
+
*/
|
|
81
|
+
function isInExecutableProcess(node) {
|
|
82
|
+
const process = findParent(node, 'bpmn:Process');
|
|
83
|
+
|
|
84
|
+
return process && process.isExecutable;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports.isInExecutableProcess = isInExecutableProcess;
|
|
88
|
+
|
|
89
|
+
|
|
74
90
|
const documentationBaseUrl = 'https://github.com/bpmn-io/bpmnlint/blob/main/docs/rules';
|
|
75
91
|
|
|
76
92
|
/**
|