bpmnlint-plugin-camunda-compat 0.1.1
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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/index.js +20 -0
- package/package.json +39 -0
- package/rules/camunda-cloud-1-0-checks.js +94 -0
- package/rules/camunda-cloud-1-0.js +5 -0
- package/rules/camunda-cloud-1-1-checks.js +44 -0
- package/rules/camunda-cloud-1-1.js +5 -0
- package/rules/camunda-cloud-1-2-checks.js +19 -0
- package/rules/camunda-cloud-1-2.js +5 -0
- package/rules/camunda-cloud-1-3-checks.js +5 -0
- package/rules/camunda-cloud-1-3.js +5 -0
- package/rules/utils/engine-profile.js +10 -0
- package/rules/utils/rule.js +236 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to [bpmnlint-plugin-example](https://github.com/camunda/bpmnlint-plugin-camunda-compat) are documented here. We use [semantic versioning](http://semver.org/) for releases.
|
4
|
+
|
5
|
+
## Unreleased
|
6
|
+
|
7
|
+
___Note:__ Yet to be released changes appear here._
|
8
|
+
|
9
|
+
## 0.0.1
|
10
|
+
|
11
|
+
* `FEAT`: initial support for Camunda Cloud 1.0, 1.1, 1.2, and 1.3
|
12
|
+
|
13
|
+
## ...
|
14
|
+
|
15
|
+
Check `git log` for earlier history.
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021-present bpmn.io Contributors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# bpmnlint-plugin-camunda-compat
|
2
|
+
|
3
|
+
[](https://github.com/camunda/bpmnlint-plugin-camunda-compat/actions?query=workflow%3ACI)
|
4
|
+
|
5
|
+
Camunda BPMN compatibility, packed as a [bpmnlint](https://github.com/bpmn-io/bpmnlint) plug-in.
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
Add the plug-in via your `.bpmnlintrc` file:
|
11
|
+
|
12
|
+
```
|
13
|
+
{
|
14
|
+
"extends": [
|
15
|
+
"bpmnlint:recommended",
|
16
|
+
"plugin:camunda-compat/recommended"
|
17
|
+
]
|
18
|
+
}
|
19
|
+
```
|
20
|
+
|
21
|
+
To validate a diagram it must be pinned to a particular execution platform via the [`modeler`](https://github.com/camunda/modeler-moddle) BPMN 2.0 extension.
|
22
|
+
|
23
|
+
|
24
|
+
## Resources
|
25
|
+
|
26
|
+
* [Documentation](https://github.com/camunda/bpmnlint-plugin-camunda-compat/tree/master/docs/rules)
|
27
|
+
* [Issues](https://github.com/camunda/bpmnlint-plugin-camunda-compat/issues)
|
28
|
+
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
MIT
|
package/index.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module.exports = {
|
2
|
+
configs: {
|
3
|
+
recommended: {
|
4
|
+
rules: {
|
5
|
+
'camunda-cloud-1-0': 'error',
|
6
|
+
'camunda-cloud-1-1': 'error',
|
7
|
+
'camunda-cloud-1-2': 'error',
|
8
|
+
'camunda-cloud-1-3': 'error'
|
9
|
+
}
|
10
|
+
},
|
11
|
+
all: {
|
12
|
+
rules: {
|
13
|
+
'camunda-cloud-1-0': 'warn',
|
14
|
+
'camunda-cloud-1-1': 'warn',
|
15
|
+
'camunda-cloud-1-2': 'warn',
|
16
|
+
'camunda-cloud-1-3': 'warn'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"name": "bpmnlint-plugin-camunda-compat",
|
3
|
+
"version": "0.1.1",
|
4
|
+
"description": "A bpmnlint plug-in for Camunda Cloud and Platform compatibility",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"all": "npm test",
|
8
|
+
"test": "mocha test/**/*.spec.js"
|
9
|
+
},
|
10
|
+
"repository": {
|
11
|
+
"type": "git",
|
12
|
+
"url": "https://github.com/camunda/bpmnlint-plugin-camunda-compat"
|
13
|
+
},
|
14
|
+
"keywords": [
|
15
|
+
"bpmnlint",
|
16
|
+
"plugin"
|
17
|
+
],
|
18
|
+
"author": {
|
19
|
+
"name": "Philipp Fromme",
|
20
|
+
"url": "https://github.com/philippfromme"
|
21
|
+
},
|
22
|
+
"license": "MIT",
|
23
|
+
"devDependencies": {
|
24
|
+
"bpmn-moddle": "^7.1.2",
|
25
|
+
"bpmnlint": "^6.1.0",
|
26
|
+
"chai": "^4.2.0",
|
27
|
+
"mocha": "^5.2.0",
|
28
|
+
"modeler-moddle": "^0.1.0",
|
29
|
+
"zeebe-bpmn-moddle": "^0.10.0"
|
30
|
+
},
|
31
|
+
"dependencies": {
|
32
|
+
"bpmnlint-utils": "^1.0.2",
|
33
|
+
"min-dash": "^3.8.0"
|
34
|
+
},
|
35
|
+
"files": [
|
36
|
+
"rules",
|
37
|
+
"index.js"
|
38
|
+
]
|
39
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
const {
|
2
|
+
checkSome,
|
3
|
+
hasEventDefinitionOfType,
|
4
|
+
hasLoopCharacteristicsOfType,
|
5
|
+
hasNoEventDefinition,
|
6
|
+
hasNoLanes,
|
7
|
+
hasNoLoopCharacteristics,
|
8
|
+
isNotBpmn
|
9
|
+
} = require('./utils/rule');
|
10
|
+
|
11
|
+
module.exports = [
|
12
|
+
{
|
13
|
+
check: isNotBpmn
|
14
|
+
},
|
15
|
+
'bpmn:Association',
|
16
|
+
'bpmn:CallActivity',
|
17
|
+
'bpmn:Collaboration',
|
18
|
+
'bpmn:DataObject',
|
19
|
+
'bpmn:DataObjectReference',
|
20
|
+
'bpmn:DataStoreReference',
|
21
|
+
'bpmn:Definitions',
|
22
|
+
'bpmn:EventBasedGateway',
|
23
|
+
'bpmn:ExclusiveGateway',
|
24
|
+
'bpmn:Group',
|
25
|
+
'bpmn:MessageFlow',
|
26
|
+
'bpmn:ParallelGateway',
|
27
|
+
'bpmn:Participant',
|
28
|
+
'bpmn:SequenceFlow',
|
29
|
+
'bpmn:TextAnnotation',
|
30
|
+
{
|
31
|
+
type: 'bpmn:BoundaryEvent',
|
32
|
+
check: hasEventDefinitionOfType([
|
33
|
+
'bpmn:ErrorEventDefinition',
|
34
|
+
'bpmn:MessageEventDefinition',
|
35
|
+
'bpmn:TimerEventDefinition'
|
36
|
+
])
|
37
|
+
},
|
38
|
+
{
|
39
|
+
type: 'bpmn:EndEvent',
|
40
|
+
check: checkSome(
|
41
|
+
hasNoEventDefinition,
|
42
|
+
hasEventDefinitionOfType([
|
43
|
+
'bpmn:ErrorEventDefinition'
|
44
|
+
])
|
45
|
+
)
|
46
|
+
},
|
47
|
+
{
|
48
|
+
type: 'bpmn:IntermediateCatchEvent',
|
49
|
+
check: hasEventDefinitionOfType([
|
50
|
+
'bpmn:MessageEventDefinition',
|
51
|
+
'bpmn:TimerEventDefinition'
|
52
|
+
])
|
53
|
+
},
|
54
|
+
{
|
55
|
+
type: 'bpmn:Process',
|
56
|
+
check: hasNoLanes
|
57
|
+
},
|
58
|
+
{
|
59
|
+
type: 'bpmn:ReceiveTask',
|
60
|
+
check: checkSome(
|
61
|
+
hasNoLoopCharacteristics,
|
62
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
63
|
+
)
|
64
|
+
},
|
65
|
+
{
|
66
|
+
type: 'bpmn:ServiceTask',
|
67
|
+
check: checkSome(
|
68
|
+
hasNoLoopCharacteristics,
|
69
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
70
|
+
)
|
71
|
+
},
|
72
|
+
{
|
73
|
+
type: 'bpmn:StartEvent',
|
74
|
+
check: checkSome(
|
75
|
+
hasNoEventDefinition,
|
76
|
+
hasEventDefinitionOfType([
|
77
|
+
'bpmn:ErrorEventDefinition',
|
78
|
+
'bpmn:MessageEventDefinition',
|
79
|
+
'bpmn:TimerEventDefinition'
|
80
|
+
])
|
81
|
+
)
|
82
|
+
},
|
83
|
+
{
|
84
|
+
type: 'bpmn:SubProcess',
|
85
|
+
check: hasNoLoopCharacteristics
|
86
|
+
},
|
87
|
+
{
|
88
|
+
type: 'bpmn:UserTask',
|
89
|
+
check: checkSome(
|
90
|
+
hasNoLoopCharacteristics,
|
91
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
92
|
+
)
|
93
|
+
}
|
94
|
+
];
|
@@ -0,0 +1,44 @@
|
|
1
|
+
const camundaCloud10Checks = require('./camunda-cloud-1-0-checks');
|
2
|
+
|
3
|
+
const {
|
4
|
+
checkSome,
|
5
|
+
hasLoopCharacteristicsOfType,
|
6
|
+
hasNoEventDefinition,
|
7
|
+
hasNoLoopCharacteristics
|
8
|
+
} = require('./utils/rule');
|
9
|
+
|
10
|
+
module.exports = [
|
11
|
+
...camundaCloud10Checks,
|
12
|
+
{
|
13
|
+
type: 'bpmn:BusinessRuleTask',
|
14
|
+
check: checkSome(
|
15
|
+
hasNoLoopCharacteristics,
|
16
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
17
|
+
)
|
18
|
+
},
|
19
|
+
{
|
20
|
+
type: 'bpmn:IntermediateThrowEvent',
|
21
|
+
check: hasNoEventDefinition
|
22
|
+
},
|
23
|
+
{
|
24
|
+
type: 'bpmn:ManualTask',
|
25
|
+
check: checkSome(
|
26
|
+
hasNoLoopCharacteristics,
|
27
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
28
|
+
)
|
29
|
+
},
|
30
|
+
{
|
31
|
+
type: 'bpmn:ScriptTask',
|
32
|
+
check: checkSome(
|
33
|
+
hasNoLoopCharacteristics,
|
34
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
35
|
+
)
|
36
|
+
},
|
37
|
+
{
|
38
|
+
type: 'bpmn:SendTask',
|
39
|
+
check: checkSome(
|
40
|
+
hasNoLoopCharacteristics,
|
41
|
+
hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
|
42
|
+
)
|
43
|
+
}
|
44
|
+
];
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const camundaCloud11Checks = require('./camunda-cloud-1-1-checks');
|
2
|
+
|
3
|
+
const { hasEventDefinitionOfType } = require('./utils/rule');
|
4
|
+
|
5
|
+
module.exports = [
|
6
|
+
...camundaCloud11Checks,
|
7
|
+
{
|
8
|
+
type: 'bpmn:EndEvent',
|
9
|
+
check: hasEventDefinitionOfType([
|
10
|
+
'bpmn:MessageEventDefinition'
|
11
|
+
])
|
12
|
+
},
|
13
|
+
{
|
14
|
+
type: 'bpmn:IntermediateThrowEvent',
|
15
|
+
check: hasEventDefinitionOfType([
|
16
|
+
'bpmn:MessageEventDefinition'
|
17
|
+
])
|
18
|
+
}
|
19
|
+
];
|
@@ -0,0 +1,236 @@
|
|
1
|
+
const {
|
2
|
+
isArray,
|
3
|
+
isNil,
|
4
|
+
isString,
|
5
|
+
} = require('min-dash');
|
6
|
+
|
7
|
+
const {
|
8
|
+
is,
|
9
|
+
isAny
|
10
|
+
} = require('bpmnlint-utils');
|
11
|
+
|
12
|
+
const { toSemverMinor } = require('./engine-profile');
|
13
|
+
|
14
|
+
module.exports.createRule = function(version, checks) {
|
15
|
+
return () => {
|
16
|
+
return {
|
17
|
+
check: (node, reporter) => {
|
18
|
+
|
19
|
+
// do not lint properties (yet)
|
20
|
+
if (!isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
|
24
|
+
const engineProfile = getEngineProfile(node);
|
25
|
+
|
26
|
+
if (!engineProfile) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
const {
|
31
|
+
executionPlatform,
|
32
|
+
executionPlatformVersion
|
33
|
+
} = engineProfile;
|
34
|
+
|
35
|
+
if (!executionPlatformVersion || toSemverMinor(executionPlatformVersion) !== version) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
|
39
|
+
const result = checkNode(node, checks);
|
40
|
+
|
41
|
+
if (result === false) {
|
42
|
+
reporter.report(node.get('id') || '', `Element of type <${ node.$type }> not supported by ${ executionPlatform } ${ toSemverMinor(executionPlatformVersion) }`);
|
43
|
+
}
|
44
|
+
|
45
|
+
if (isString(result)) {
|
46
|
+
reporter.report(node.get('id') || '', `Element of type <${ result }> not supported by ${ executionPlatform } ${ toSemverMinor(executionPlatformVersion) }`);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
};
|
50
|
+
};
|
51
|
+
}
|
52
|
+
|
53
|
+
function getDefinitions(node) {
|
54
|
+
if (is(node, 'bpmn:Definitions')) {
|
55
|
+
return node;
|
56
|
+
}
|
57
|
+
|
58
|
+
const parent = node.$parent;
|
59
|
+
|
60
|
+
if (!parent) {
|
61
|
+
return null;
|
62
|
+
}
|
63
|
+
|
64
|
+
return getDefinitions(parent);
|
65
|
+
}
|
66
|
+
|
67
|
+
function getEngineProfile(node) {
|
68
|
+
const definitions = getDefinitions(node);
|
69
|
+
|
70
|
+
if (!definitions) {
|
71
|
+
return null;
|
72
|
+
}
|
73
|
+
|
74
|
+
const executionPlatform = definitions.get('modeler:executionPlatform'),
|
75
|
+
executionPlatformVersion = definitions.get('modeler:executionPlatformVersion');
|
76
|
+
|
77
|
+
if (!executionPlatform) {
|
78
|
+
return null;
|
79
|
+
}
|
80
|
+
|
81
|
+
return {
|
82
|
+
executionPlatform,
|
83
|
+
executionPlatformVersion
|
84
|
+
};
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* @param {ModdleElement} node
|
89
|
+
* @param {Array<Function>} checks
|
90
|
+
*
|
91
|
+
* @returns boolean|String
|
92
|
+
*/
|
93
|
+
function checkNode(node, checks) {
|
94
|
+
return checks.reduce((previousResult, check) => {
|
95
|
+
if (previousResult === true) {
|
96
|
+
return previousResult;
|
97
|
+
}
|
98
|
+
|
99
|
+
// (1) check using type only
|
100
|
+
if (isString(check)) {
|
101
|
+
return is(node, check) || previousResult;
|
102
|
+
}
|
103
|
+
|
104
|
+
const { type } = check;
|
105
|
+
|
106
|
+
// (2) check using function only
|
107
|
+
if (!type) {
|
108
|
+
return check.check(node) || previousResult;
|
109
|
+
}
|
110
|
+
|
111
|
+
// (3) check using type and function
|
112
|
+
if (!is(node, type)) {
|
113
|
+
return previousResult;
|
114
|
+
}
|
115
|
+
|
116
|
+
return check.check(node) || previousResult;
|
117
|
+
}, false);
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* If every check returns true return true.
|
122
|
+
* Otherwise return the first false or string returned by a check.
|
123
|
+
*
|
124
|
+
* @param {Array<Function>} checks
|
125
|
+
*
|
126
|
+
* @returns {boolean|String}
|
127
|
+
*/
|
128
|
+
module.exports.checkEvery = function(...checks) {
|
129
|
+
return function(node) {
|
130
|
+
return checks.reduce((previousResult, check) => {
|
131
|
+
if (!isNil(previousResult) && previousResult !== true) {
|
132
|
+
return previousResult;
|
133
|
+
}
|
134
|
+
|
135
|
+
const result = check(node);
|
136
|
+
|
137
|
+
return result;
|
138
|
+
}, null);
|
139
|
+
};
|
140
|
+
}
|
141
|
+
|
142
|
+
/**
|
143
|
+
* If some check returns true return true.
|
144
|
+
* Otherwise return the first false or string returned by a check.
|
145
|
+
*
|
146
|
+
* @param {Array<Function>} checks
|
147
|
+
*
|
148
|
+
* @returns {boolean|String}
|
149
|
+
*/
|
150
|
+
module.exports.checkSome = function(...checks) {
|
151
|
+
return function(node) {
|
152
|
+
return checks.reduce((previousResult, check) => {
|
153
|
+
if (previousResult === true) {
|
154
|
+
return previousResult;
|
155
|
+
}
|
156
|
+
|
157
|
+
const result = check(node);
|
158
|
+
|
159
|
+
if (isNil(previousResult) || result === true) {
|
160
|
+
return result;
|
161
|
+
}
|
162
|
+
|
163
|
+
return previousResult;
|
164
|
+
}, null);
|
165
|
+
};
|
166
|
+
}
|
167
|
+
|
168
|
+
module.exports.hasEventDefinition = function(node) {
|
169
|
+
const eventDefinitions = node.get('eventDefinitions');
|
170
|
+
|
171
|
+
return eventDefinitions && eventDefinitions.length === 1;
|
172
|
+
}
|
173
|
+
|
174
|
+
module.exports.hasNoEventDefinition = function(node) {
|
175
|
+
const eventDefinitions = node.get('eventDefinitions');
|
176
|
+
|
177
|
+
return !eventDefinitions || !eventDefinitions.length || `${ node.$type} (${ eventDefinitions[ 0 ].$type })`;
|
178
|
+
}
|
179
|
+
|
180
|
+
module.exports.hasEventDefinitionOfType = function(types) {
|
181
|
+
return function(node) {
|
182
|
+
if (!isArray(types)) {
|
183
|
+
types = [ types ];
|
184
|
+
}
|
185
|
+
|
186
|
+
const eventDefinitions = node.get('eventDefinitions');
|
187
|
+
|
188
|
+
if (!eventDefinitions || eventDefinitions.length !== 1) {
|
189
|
+
return false;
|
190
|
+
}
|
191
|
+
|
192
|
+
const eventDefinition = eventDefinitions[ 0 ];
|
193
|
+
|
194
|
+
return isAny(eventDefinition, types) || `${ node.$type} (${ eventDefinition.$type })`;
|
195
|
+
};
|
196
|
+
}
|
197
|
+
|
198
|
+
module.exports.hasLoopCharacteristics = function(node) {
|
199
|
+
const loopCharacteristics = node.get('loopCharacteristics');
|
200
|
+
|
201
|
+
return !!loopCharacteristics;
|
202
|
+
}
|
203
|
+
|
204
|
+
module.exports.hasNoLoopCharacteristics = function(node) {
|
205
|
+
const loopCharacteristics = node.get('loopCharacteristics');
|
206
|
+
|
207
|
+
return !loopCharacteristics || `${ node.$type} (${ loopCharacteristics.$type })`;
|
208
|
+
}
|
209
|
+
|
210
|
+
module.exports.hasNoLanes = function(node) {
|
211
|
+
const laneSets = node.get('laneSets');
|
212
|
+
|
213
|
+
return !laneSets || !laneSets.length || `${ node.$type} (bpmn:LaneSet)`;
|
214
|
+
}
|
215
|
+
|
216
|
+
module.exports.hasLoopCharacteristicsOfType = function(type) {
|
217
|
+
return function(node) {
|
218
|
+
const loopCharacteristics = node.get('loopCharacteristics');
|
219
|
+
|
220
|
+
if (!loopCharacteristics) {
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
|
224
|
+
return is(loopCharacteristics, type) || `${ node.$type} (${ loopCharacteristics.$type })`;
|
225
|
+
};
|
226
|
+
}
|
227
|
+
|
228
|
+
module.exports.isNotBpmn = function(node) {
|
229
|
+
const { $descriptor: descriptor } = node;
|
230
|
+
|
231
|
+
const { $pkg: package } = descriptor;
|
232
|
+
|
233
|
+
const { uri } = package;
|
234
|
+
|
235
|
+
return uri !== 'http://www.omg.org/spec/BPMN/20100524/MODEL';
|
236
|
+
}
|