bpmnlint-plugin-camunda-compat 0.16.0 → 0.18.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 +15 -7
- package/index.js +14 -7
- package/package.json +2 -2
- package/rules/{called-decision-or-task-definition → implementation}/config.js +4 -1
- package/rules/{called-decision-or-task-definition → implementation}/index.js +67 -13
- package/rules/no-expression.js +117 -0
- package/rules/utils/error-types.js +1 -0
package/README.md
CHANGED
@@ -2,28 +2,36 @@
|
|
2
2
|
|
3
3
|
[](https://github.com/camunda/bpmnlint-plugin-camunda-compat/actions?query=workflow%3ACI)
|
4
4
|
|
5
|
-
|
5
|
+
A [bpmnlint](https://github.com/bpmn-io/bpmnlint) plug-in that checks whether a given BPMN process can be executed with [Camunda](https://camunda.com/).
|
6
6
|
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
|
-
|
10
|
+
Add configuration corresponding to your execution platform and version to your [`.bpmnlintrc` configuration](https://github.com/bpmn-io/bpmnlint#configuration):
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
```
|
12
|
+
```json
|
15
13
|
{
|
16
14
|
"extends": [
|
17
15
|
"bpmnlint:recommended",
|
18
16
|
"plugin:camunda-compat/camunda-cloud-8-0"
|
19
|
-
]
|
17
|
+
],
|
18
|
+
"rules": {
|
19
|
+
"camunda-compat/timer": "off"
|
20
|
+
}
|
20
21
|
}
|
21
22
|
```
|
22
23
|
|
24
|
+
Use [`@camunda/linting`](https://github.com/camunda/linting) to configure the linter dynamically based on the [execution platform and version](https://github.com/camunda/modeler-moddle).
|
25
|
+
|
26
|
+
|
23
27
|
## Resources
|
24
28
|
|
25
29
|
* [Issues](https://github.com/camunda/bpmnlint-plugin-camunda-compat/issues)
|
26
|
-
|
30
|
+
|
31
|
+
|
32
|
+
## Related
|
33
|
+
|
34
|
+
* BPMN coverage for [Camunda 8](https://docs.camunda.io/docs/reference/bpmn-processes/bpmn-coverage/) and [Camunda 7](https://docs.camunda.org/manual/latest/reference/bpmn20/)
|
27
35
|
|
28
36
|
|
29
37
|
## License
|
package/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
const { omit } = require('min-dash');
|
2
2
|
|
3
3
|
const camundaCloud10Rules = {
|
4
|
-
'
|
4
|
+
'implementation': [ 'error', { version: '1.0' } ],
|
5
5
|
'called-element': 'error',
|
6
6
|
'collapsed-subprocess': 'error',
|
7
7
|
'duplicate-task-headers': 'error',
|
@@ -10,6 +10,7 @@ const camundaCloud10Rules = {
|
|
10
10
|
'executable-process': 'error',
|
11
11
|
'loop-characteristics': 'error',
|
12
12
|
'message-reference': 'error',
|
13
|
+
'no-expression': [ 'error', { version: '1.0' } ],
|
13
14
|
'no-template': 'error',
|
14
15
|
'no-zeebe-properties': 'error',
|
15
16
|
'sequence-flow-condition': 'error',
|
@@ -21,44 +22,50 @@ const camundaCloud10Rules = {
|
|
21
22
|
|
22
23
|
const camundaCloud11Rules = {
|
23
24
|
...camundaCloud10Rules,
|
24
|
-
'
|
25
|
+
'implementation': [ 'error', { version: '1.1' } ],
|
25
26
|
'element-type': [ 'error', { version: '1.1' } ],
|
27
|
+
'no-expression': [ 'error', { version: '1.1' } ],
|
26
28
|
'timer': [ 'error', { version: '1.1' } ]
|
27
29
|
};
|
28
30
|
|
29
31
|
const camundaCloud12Rules = {
|
30
32
|
...camundaCloud11Rules,
|
31
|
-
'
|
33
|
+
'implementation': [ 'error', { version: '1.2' } ],
|
32
34
|
'element-type': [ 'error', { version: '1.2' } ],
|
35
|
+
'no-expression': [ 'error', { version: '1.2' } ],
|
33
36
|
'timer': [ 'error', { version: '1.2' } ]
|
34
37
|
};
|
35
38
|
|
36
39
|
const camundaCloud13Rules = {
|
37
40
|
...camundaCloud12Rules,
|
38
|
-
'
|
41
|
+
'implementation': [ 'error', { version: '1.3' } ],
|
39
42
|
'element-type': [ 'error', { version: '1.3' } ],
|
43
|
+
'no-expression': [ 'error', { version: '1.3' } ],
|
40
44
|
'timer': [ 'error', { version: '1.3' } ]
|
41
45
|
};
|
42
46
|
|
43
47
|
const camundaCloud80Rules = {
|
44
48
|
...omit(camundaCloud13Rules, 'no-template'),
|
45
|
-
'
|
49
|
+
'implementation': [ 'error', { version: '8.0' } ],
|
46
50
|
'element-type': [ 'error', { version: '8.0' } ],
|
51
|
+
'no-expression': [ 'error', { version: '8.0' } ],
|
47
52
|
'timer': [ 'error', { version: '8.0' } ]
|
48
53
|
};
|
49
54
|
|
50
55
|
const camundaCloud81Rules = {
|
51
56
|
...omit(camundaCloud80Rules, 'no-zeebe-properties'),
|
52
|
-
'
|
57
|
+
'implementation': [ 'error', { version: '8.1' } ],
|
53
58
|
'element-type': [ 'error', { version: '8.1' } ],
|
54
59
|
'inclusive-gateway': 'error',
|
60
|
+
'no-expression': [ 'error', { version: '8.1' } ],
|
55
61
|
'timer': [ 'error', { version: '8.1' } ]
|
56
62
|
};
|
57
63
|
|
58
64
|
const camundaCloud82Rules = {
|
59
65
|
...camundaCloud81Rules,
|
60
|
-
'
|
66
|
+
'implementation': [ 'error', { version: '8.2' } ],
|
61
67
|
'element-type': [ 'error', { version: '8.2' } ],
|
68
|
+
'no-expression': [ 'error', { version: '8.2' } ],
|
62
69
|
'timer': [ 'error', { version: '8.2' } ]
|
63
70
|
};
|
64
71
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "bpmnlint-plugin-camunda-compat",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.18.0",
|
4
4
|
"description": "A bpmnlint plug-in for Camunda Platform compatibility",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"modeler-moddle": "^0.1.0",
|
34
34
|
"sinon": "^14.0.0",
|
35
35
|
"sinon-chai": "^3.7.0",
|
36
|
-
"zeebe-bpmn-moddle": "^0.
|
36
|
+
"zeebe-bpmn-moddle": "^0.17.0"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
39
|
"@bpmn-io/feel-lint": "^0.1.1",
|
@@ -5,10 +5,13 @@ module.exports = {
|
|
5
5
|
taskDefinition: {
|
6
6
|
'bpmn:BusinessRuleTask': '1.1',
|
7
7
|
'bpmn:IntermediateThrowEvent': {
|
8
|
-
'bpmn:MessageEventDefinition': '1.2'
|
8
|
+
'bpmn:MessageEventDefinition': '1.2'
|
9
9
|
},
|
10
10
|
'bpmn:ScriptTask': '1.1',
|
11
11
|
'bpmn:SendTask': '1.1',
|
12
12
|
'bpmn:ServiceTask': '1.0'
|
13
|
+
},
|
14
|
+
script: {
|
15
|
+
'bpmn:ScriptTask': '8.2'
|
13
16
|
}
|
14
17
|
};
|
@@ -22,10 +22,12 @@ const { ERROR_TYPES } = require('../utils/error-types');
|
|
22
22
|
module.exports = function({ version }) {
|
23
23
|
function check(node, reporter) {
|
24
24
|
const calledDecisionConfig = config.calledDecision[ node.$type ];
|
25
|
+
const scriptConfig = config.script[ node.$type ];
|
25
26
|
const taskDefinitionConfig = config.taskDefinition[ node.$type ];
|
26
27
|
|
27
28
|
if (
|
28
29
|
(!calledDecisionConfig || (isString(calledDecisionConfig) && !greaterOrEqual(version, calledDecisionConfig)))
|
30
|
+
&& (!scriptConfig || (isString(scriptConfig) && !greaterOrEqual(version, scriptConfig)))
|
29
31
|
&& (!taskDefinitionConfig || (isString(taskDefinitionConfig) && !greaterOrEqual(version, taskDefinitionConfig)))) {
|
30
32
|
return;
|
31
33
|
}
|
@@ -37,9 +39,10 @@ module.exports = function({ version }) {
|
|
37
39
|
let errors;
|
38
40
|
|
39
41
|
const calledDecision = findExtensionElement(node, 'zeebe:CalledDecision'),
|
42
|
+
script = findExtensionElement(node, 'zeebe:Script'),
|
40
43
|
taskDefinition = findExtensionElement(node, 'zeebe:TaskDefinition');
|
41
44
|
|
42
|
-
if (calledDecision && !taskDefinition) {
|
45
|
+
if (calledDecision && !script && !taskDefinition) {
|
43
46
|
|
44
47
|
if (!isCalledDecisionAllowed(node, version)) {
|
45
48
|
const allowedVersion = getAllowedVersion(calledDecisionConfig, node);
|
@@ -77,7 +80,45 @@ module.exports = function({ version }) {
|
|
77
80
|
}
|
78
81
|
}
|
79
82
|
|
80
|
-
if (!calledDecision && taskDefinition) {
|
83
|
+
if (!calledDecision && script && !taskDefinition) {
|
84
|
+
|
85
|
+
if (!isScriptAllowed(node, version)) {
|
86
|
+
const allowedVersion = getAllowedVersion(scriptConfig, node);
|
87
|
+
|
88
|
+
reportErrors(node, reporter, {
|
89
|
+
message: allowedVersion
|
90
|
+
? `Extension element of type <zeebe:Script> only allowed by Camunda Platform ${ allowedVersion } or newer`
|
91
|
+
: 'Extension element of type <zeebe:Script> not allowed',
|
92
|
+
path: getPath(script, node),
|
93
|
+
data: {
|
94
|
+
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
95
|
+
node,
|
96
|
+
parentNode: null,
|
97
|
+
extensionElement: script,
|
98
|
+
allowedVersion
|
99
|
+
}
|
100
|
+
});
|
101
|
+
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
|
105
|
+
errors = hasProperties(script, {
|
106
|
+
expression: {
|
107
|
+
required: true
|
108
|
+
},
|
109
|
+
resultVariable: {
|
110
|
+
required: true
|
111
|
+
}
|
112
|
+
}, node);
|
113
|
+
|
114
|
+
if (errors && errors.length) {
|
115
|
+
reportErrors(node, reporter, errors);
|
116
|
+
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
if (!calledDecision && !script && taskDefinition) {
|
81
122
|
|
82
123
|
if (!isTaskDefinitionAllowed(node, version)) {
|
83
124
|
const allowedVersion = getAllowedVersion(taskDefinitionConfig, node);
|
@@ -110,15 +151,18 @@ module.exports = function({ version }) {
|
|
110
151
|
}
|
111
152
|
}
|
112
153
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
154
|
+
const allowedTypes = [
|
155
|
+
isCalledDecisionAllowed(node, version) ? 'zeebe:CalledDecision' : false,
|
156
|
+
isScriptAllowed(node, version) ? 'zeebe:Script' : false,
|
157
|
+
isTaskDefinitionAllowed(node, version) ? 'zeebe:TaskDefinition' : false
|
158
|
+
].filter(isAllowed => isAllowed);
|
159
|
+
|
160
|
+
if (allowedTypes.length === 0) {
|
161
|
+
return;
|
162
|
+
} else if (allowedTypes.length === 1) {
|
163
|
+
errors = hasExtensionElement(node, allowedTypes[0], node);
|
164
|
+
} else {
|
165
|
+
errors = hasExtensionElement(node, allowedTypes, node);
|
122
166
|
}
|
123
167
|
|
124
168
|
if (errors && errors.length) {
|
@@ -136,7 +180,17 @@ module.exports = function({ version }) {
|
|
136
180
|
function isCalledDecisionAllowed(node, version) {
|
137
181
|
const { calledDecision } = config;
|
138
182
|
|
139
|
-
|
183
|
+
const allowedVersion = getAllowedVersion(calledDecision[ node.$type ], node);
|
184
|
+
|
185
|
+
return calledDecision[ node.$type ] && greaterOrEqual(version, allowedVersion);
|
186
|
+
}
|
187
|
+
|
188
|
+
function isScriptAllowed(node, version) {
|
189
|
+
const { script } = config;
|
190
|
+
|
191
|
+
const allowedVersion = getAllowedVersion(script[ node.$type ], node);
|
192
|
+
|
193
|
+
return allowedVersion && greaterOrEqual(version, allowedVersion);
|
140
194
|
}
|
141
195
|
|
142
196
|
function isTaskDefinitionAllowed(node, version) {
|
@@ -159,4 +213,4 @@ function getAllowedVersion(config, node) {
|
|
159
213
|
const eventDefinition = getEventDefinition(node);
|
160
214
|
|
161
215
|
return eventDefinition && config[ eventDefinition.$type ];
|
162
|
-
}
|
216
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
const {
|
2
|
+
is,
|
3
|
+
isAny
|
4
|
+
} = require('bpmnlint-utils');
|
5
|
+
|
6
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
7
|
+
|
8
|
+
const {
|
9
|
+
ERROR_TYPES,
|
10
|
+
getEventDefinition
|
11
|
+
} = require('./utils/element');
|
12
|
+
|
13
|
+
const { reportErrors } = require('./utils/reporter');
|
14
|
+
|
15
|
+
const handlersMap = {
|
16
|
+
'1.0': [
|
17
|
+
checkErrorCode
|
18
|
+
],
|
19
|
+
'1.1': [
|
20
|
+
checkErrorCode
|
21
|
+
],
|
22
|
+
'1.2': [
|
23
|
+
checkErrorCode
|
24
|
+
],
|
25
|
+
'1.3': [
|
26
|
+
checkErrorCode
|
27
|
+
],
|
28
|
+
'8.0': [
|
29
|
+
checkErrorCode
|
30
|
+
],
|
31
|
+
'8.1': [
|
32
|
+
checkErrorCode
|
33
|
+
],
|
34
|
+
'8.2': []
|
35
|
+
};
|
36
|
+
|
37
|
+
module.exports = noExpressionRule;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Make sure that certain properties do not contain expressions in older versions.
|
41
|
+
* @param {{ version: string }} config
|
42
|
+
*/
|
43
|
+
function noExpressionRule({ version }) {
|
44
|
+
function check(node, reporter) {
|
45
|
+
const errors = checkForVersion(node, version);
|
46
|
+
|
47
|
+
if (errors && errors.length) {
|
48
|
+
reportErrors(node, reporter, errors);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
return {
|
53
|
+
check
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
function checkForVersion(node, version) {
|
58
|
+
const handlers = handlersMap[version];
|
59
|
+
|
60
|
+
return handlers.reduce((errors, handler) => {
|
61
|
+
const handlerErrors = handler(node, version) || [];
|
62
|
+
return errors.concat(handlerErrors);
|
63
|
+
}, []);
|
64
|
+
}
|
65
|
+
|
66
|
+
function noExpression(node, propertyName, parentNode, allowedVersion) {
|
67
|
+
const propertyValue = node.get(propertyName);
|
68
|
+
const path = getPath(node, parentNode);
|
69
|
+
|
70
|
+
if (!isExpression(propertyValue)) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
return {
|
75
|
+
message: `Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform 8.2 or newer`,
|
76
|
+
path: path
|
77
|
+
? [ ...path, propertyName ]
|
78
|
+
: [ propertyName ],
|
79
|
+
data: {
|
80
|
+
type: ERROR_TYPES.EXPRESSION_NOT_ALLOWED,
|
81
|
+
node,
|
82
|
+
parentNode: parentNode == node ? null : parentNode,
|
83
|
+
property: propertyName,
|
84
|
+
allowedVersion
|
85
|
+
}
|
86
|
+
};
|
87
|
+
}
|
88
|
+
|
89
|
+
function isExpression(value) {
|
90
|
+
return value && value.startsWith('=');
|
91
|
+
}
|
92
|
+
|
93
|
+
function checkErrorCode(node) {
|
94
|
+
if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
|
98
|
+
const eventDefinition = getEventDefinition(node);
|
99
|
+
|
100
|
+
if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
const errorRef = eventDefinition.get('errorRef');
|
105
|
+
|
106
|
+
if (!errorRef) {
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
|
110
|
+
return errorRef && noExpression(errorRef, 'errorCode', node, '8.2');
|
111
|
+
}
|
112
|
+
|
113
|
+
function truncate(string, maxLength = 10) {
|
114
|
+
const stringified = `${ string }`;
|
115
|
+
|
116
|
+
return stringified.length > maxLength ? `${ stringified.slice(0, maxLength) }...` : stringified;
|
117
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module.exports.ERROR_TYPES = Object.freeze({
|
2
2
|
ELEMENT_COLLAPSED_NOT_ALLOWED: 'camunda.elementCollapsedNotAllowed',
|
3
3
|
ELEMENT_TYPE_NOT_ALLOWED: 'camunda.elementTypeNotAllowed',
|
4
|
+
EXPRESSION_NOT_ALLOWED: 'camunda.expressionNotAllowed',
|
4
5
|
EXPRESSION_REQUIRED: 'camunda.expressionRequired',
|
5
6
|
EXPRESSION_VALUE_NOT_ALLOWED: 'camunda.expressionValueNotAllowed',
|
6
7
|
EXTENSION_ELEMENT_NOT_ALLOWED: 'camunda.extensionElementNotAllowed',
|