bpmnlint-plugin-camunda-compat 0.15.2 → 0.17.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/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',
|
@@ -21,35 +21,35 @@ const camundaCloud10Rules = {
|
|
21
21
|
|
22
22
|
const camundaCloud11Rules = {
|
23
23
|
...camundaCloud10Rules,
|
24
|
-
'
|
24
|
+
'implementation': [ 'error', { version: '1.1' } ],
|
25
25
|
'element-type': [ 'error', { version: '1.1' } ],
|
26
26
|
'timer': [ 'error', { version: '1.1' } ]
|
27
27
|
};
|
28
28
|
|
29
29
|
const camundaCloud12Rules = {
|
30
30
|
...camundaCloud11Rules,
|
31
|
-
'
|
31
|
+
'implementation': [ 'error', { version: '1.2' } ],
|
32
32
|
'element-type': [ 'error', { version: '1.2' } ],
|
33
33
|
'timer': [ 'error', { version: '1.2' } ]
|
34
34
|
};
|
35
35
|
|
36
36
|
const camundaCloud13Rules = {
|
37
37
|
...camundaCloud12Rules,
|
38
|
-
'
|
38
|
+
'implementation': [ 'error', { version: '1.3' } ],
|
39
39
|
'element-type': [ 'error', { version: '1.3' } ],
|
40
40
|
'timer': [ 'error', { version: '1.3' } ]
|
41
41
|
};
|
42
42
|
|
43
43
|
const camundaCloud80Rules = {
|
44
44
|
...omit(camundaCloud13Rules, 'no-template'),
|
45
|
-
'
|
45
|
+
'implementation': [ 'error', { version: '8.0' } ],
|
46
46
|
'element-type': [ 'error', { version: '8.0' } ],
|
47
47
|
'timer': [ 'error', { version: '8.0' } ]
|
48
48
|
};
|
49
49
|
|
50
50
|
const camundaCloud81Rules = {
|
51
51
|
...omit(camundaCloud80Rules, 'no-zeebe-properties'),
|
52
|
-
'
|
52
|
+
'implementation': [ 'error', { version: '8.1' } ],
|
53
53
|
'element-type': [ 'error', { version: '8.1' } ],
|
54
54
|
'inclusive-gateway': 'error',
|
55
55
|
'timer': [ 'error', { version: '8.1' } ]
|
@@ -57,7 +57,7 @@ const camundaCloud81Rules = {
|
|
57
57
|
|
58
58
|
const camundaCloud82Rules = {
|
59
59
|
...camundaCloud81Rules,
|
60
|
-
'
|
60
|
+
'implementation': [ 'error', { version: '8.2' } ],
|
61
61
|
'element-type': [ 'error', { version: '8.2' } ],
|
62
62
|
'timer': [ 'error', { version: '8.2' } ]
|
63
63
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "bpmnlint-plugin-camunda-compat",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.17.0",
|
4
4
|
"description": "A bpmnlint plug-in for Camunda Platform compatibility",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -33,10 +33,10 @@
|
|
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
|
-
"@bpmn-io/feel-lint": "^0.1.
|
39
|
+
"@bpmn-io/feel-lint": "^0.1.1",
|
40
40
|
"@bpmn-io/moddle-utils": "^0.1.0",
|
41
41
|
"bpmnlint-utils": "^1.0.2",
|
42
42
|
"min-dash": "^3.8.1",
|
@@ -24,11 +24,13 @@ module.exports = {
|
|
24
24
|
'bpmn:InclusiveGateway': '8.1',
|
25
25
|
'bpmn:IntermediateCatchEvent': {
|
26
26
|
'bpmn:MessageEventDefinition': '1.0',
|
27
|
-
'bpmn:TimerEventDefinition': '1.0'
|
27
|
+
'bpmn:TimerEventDefinition': '1.0',
|
28
|
+
'bpmn:LinkEventDefinition': '8.2'
|
28
29
|
},
|
29
30
|
'bpmn:IntermediateThrowEvent': {
|
30
31
|
'_': '1.1',
|
31
|
-
'bpmn:MessageEventDefinition': '1.2'
|
32
|
+
'bpmn:MessageEventDefinition': '1.2',
|
33
|
+
'bpmn:LinkEventDefinition': '8.2'
|
32
34
|
},
|
33
35
|
'bpmn:ManualTask': '1.1',
|
34
36
|
'bpmn:MessageFlow': '1.0',
|
@@ -4,9 +4,14 @@ module.exports = {
|
|
4
4
|
},
|
5
5
|
taskDefinition: {
|
6
6
|
'bpmn:BusinessRuleTask': '1.1',
|
7
|
-
'bpmn:IntermediateThrowEvent':
|
7
|
+
'bpmn:IntermediateThrowEvent': {
|
8
|
+
'bpmn:MessageEventDefinition': '1.2'
|
9
|
+
},
|
8
10
|
'bpmn:ScriptTask': '1.1',
|
9
11
|
'bpmn:SendTask': '1.1',
|
10
12
|
'bpmn:ServiceTask': '1.0'
|
13
|
+
},
|
14
|
+
script: {
|
15
|
+
'bpmn:ScriptTask': '8.2'
|
11
16
|
}
|
12
17
|
};
|
@@ -0,0 +1,216 @@
|
|
1
|
+
const { is } = require('bpmnlint-utils');
|
2
|
+
|
3
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
4
|
+
|
5
|
+
const { isString } = require('min-dash');
|
6
|
+
|
7
|
+
const config = require('./config');
|
8
|
+
|
9
|
+
const { greaterOrEqual } = require('../utils/version');
|
10
|
+
|
11
|
+
const {
|
12
|
+
findExtensionElement,
|
13
|
+
getEventDefinition,
|
14
|
+
hasExtensionElement,
|
15
|
+
hasProperties
|
16
|
+
} = require('../utils/element');
|
17
|
+
|
18
|
+
const { reportErrors } = require('../utils/reporter');
|
19
|
+
|
20
|
+
const { ERROR_TYPES } = require('../utils/error-types');
|
21
|
+
|
22
|
+
module.exports = function({ version }) {
|
23
|
+
function check(node, reporter) {
|
24
|
+
const calledDecisionConfig = config.calledDecision[ node.$type ];
|
25
|
+
const scriptConfig = config.script[ node.$type ];
|
26
|
+
const taskDefinitionConfig = config.taskDefinition[ node.$type ];
|
27
|
+
|
28
|
+
if (
|
29
|
+
(!calledDecisionConfig || (isString(calledDecisionConfig) && !greaterOrEqual(version, calledDecisionConfig)))
|
30
|
+
&& (!scriptConfig || (isString(scriptConfig) && !greaterOrEqual(version, scriptConfig)))
|
31
|
+
&& (!taskDefinitionConfig || (isString(taskDefinitionConfig) && !greaterOrEqual(version, taskDefinitionConfig)))) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
if (is(node, 'bpmn:ThrowEvent') && !getEventDefinition(node)) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
|
39
|
+
let errors;
|
40
|
+
|
41
|
+
const calledDecision = findExtensionElement(node, 'zeebe:CalledDecision'),
|
42
|
+
script = findExtensionElement(node, 'zeebe:Script'),
|
43
|
+
taskDefinition = findExtensionElement(node, 'zeebe:TaskDefinition');
|
44
|
+
|
45
|
+
if (calledDecision && !script && !taskDefinition) {
|
46
|
+
|
47
|
+
if (!isCalledDecisionAllowed(node, version)) {
|
48
|
+
const allowedVersion = getAllowedVersion(calledDecisionConfig, node);
|
49
|
+
|
50
|
+
reportErrors(node, reporter, {
|
51
|
+
message: allowedVersion
|
52
|
+
? `Extension element of type <zeebe:CalledDecision> only allowed by Camunda Platform ${ allowedVersion } or newer`
|
53
|
+
: 'Extension element of type <zeebe:CalledDecision> not allowed',
|
54
|
+
path: getPath(calledDecision, node),
|
55
|
+
data: {
|
56
|
+
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
57
|
+
node,
|
58
|
+
parentNode: null,
|
59
|
+
extensionElement: calledDecision,
|
60
|
+
allowedVersion
|
61
|
+
}
|
62
|
+
});
|
63
|
+
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
errors = hasProperties(calledDecision, {
|
68
|
+
decisionId: {
|
69
|
+
required: true
|
70
|
+
},
|
71
|
+
resultVariable: {
|
72
|
+
required: true
|
73
|
+
}
|
74
|
+
}, node);
|
75
|
+
|
76
|
+
if (errors && errors.length) {
|
77
|
+
reportErrors(node, reporter, errors);
|
78
|
+
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
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) {
|
122
|
+
|
123
|
+
if (!isTaskDefinitionAllowed(node, version)) {
|
124
|
+
const allowedVersion = getAllowedVersion(taskDefinitionConfig, node);
|
125
|
+
|
126
|
+
reportErrors(node, reporter, {
|
127
|
+
message: allowedVersion
|
128
|
+
? `Extension element of type <zeebe:TaskDefinition> only allowed by Camunda Platform ${ allowedVersion } or newer`
|
129
|
+
: 'Extension element of type <zeebe:TaskDefinition> not allowed',
|
130
|
+
path: getPath(taskDefinition, node),
|
131
|
+
data: {
|
132
|
+
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
133
|
+
node,
|
134
|
+
parentNode: null,
|
135
|
+
extensionElement: taskDefinition,
|
136
|
+
allowedVersion
|
137
|
+
}
|
138
|
+
});
|
139
|
+
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
|
143
|
+
errors = hasProperties(taskDefinition, {
|
144
|
+
type: {
|
145
|
+
required: true
|
146
|
+
}
|
147
|
+
}, node);
|
148
|
+
|
149
|
+
if (errors && errors.length) {
|
150
|
+
reportErrors(node, reporter, errors);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
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);
|
166
|
+
}
|
167
|
+
|
168
|
+
if (errors && errors.length) {
|
169
|
+
reportErrors(node, reporter, errors);
|
170
|
+
|
171
|
+
return;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
return {
|
176
|
+
check
|
177
|
+
};
|
178
|
+
};
|
179
|
+
|
180
|
+
function isCalledDecisionAllowed(node, version) {
|
181
|
+
const { calledDecision } = config;
|
182
|
+
|
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);
|
194
|
+
}
|
195
|
+
|
196
|
+
function isTaskDefinitionAllowed(node, version) {
|
197
|
+
const { taskDefinition } = config;
|
198
|
+
|
199
|
+
const allowedVersion = getAllowedVersion(taskDefinition[ node.$type ], node);
|
200
|
+
|
201
|
+
return allowedVersion && greaterOrEqual(version, allowedVersion);
|
202
|
+
}
|
203
|
+
|
204
|
+
function getAllowedVersion(config, node) {
|
205
|
+
if (!config) {
|
206
|
+
return null;
|
207
|
+
}
|
208
|
+
|
209
|
+
if (isString(config)) {
|
210
|
+
return config;
|
211
|
+
}
|
212
|
+
|
213
|
+
const eventDefinition = getEventDefinition(node);
|
214
|
+
|
215
|
+
return eventDefinition && config[ eventDefinition.$type ];
|
216
|
+
}
|
@@ -1,141 +0,0 @@
|
|
1
|
-
const { is } = require('bpmnlint-utils');
|
2
|
-
|
3
|
-
const { getPath } = require('@bpmn-io/moddle-utils');
|
4
|
-
|
5
|
-
const config = require('./config');
|
6
|
-
|
7
|
-
const { greaterOrEqual } = require('../utils/version');
|
8
|
-
|
9
|
-
const {
|
10
|
-
findExtensionElement,
|
11
|
-
getEventDefinition,
|
12
|
-
hasExtensionElement,
|
13
|
-
hasProperties
|
14
|
-
} = require('../utils/element');
|
15
|
-
|
16
|
-
const { reportErrors } = require('../utils/reporter');
|
17
|
-
|
18
|
-
const { ERROR_TYPES } = require('../utils/error-types');
|
19
|
-
|
20
|
-
module.exports = function({ version }) {
|
21
|
-
function check(node, reporter) {
|
22
|
-
if (
|
23
|
-
(!config.calledDecision[ node.$type ] || !greaterOrEqual(version, config.calledDecision[ node.$type ]))
|
24
|
-
&& (!config.taskDefinition[ node.$type ] || !greaterOrEqual(version, config.taskDefinition[ node.$type ]))) {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
|
28
|
-
if (is(node, 'bpmn:ThrowEvent') && !getEventDefinition(node)) {
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
|
32
|
-
let errors;
|
33
|
-
|
34
|
-
const calledDecision = findExtensionElement(node, 'zeebe:CalledDecision'),
|
35
|
-
taskDefinition = findExtensionElement(node, 'zeebe:TaskDefinition');
|
36
|
-
|
37
|
-
if (calledDecision && !taskDefinition) {
|
38
|
-
|
39
|
-
if (!isCalledDecisionAllowed(node, version)) {
|
40
|
-
const allowedVersion = config.calledDecision[ node.$type ] || null;
|
41
|
-
|
42
|
-
reportErrors(node, reporter, {
|
43
|
-
message: allowedVersion
|
44
|
-
? `Extension element of type <zeebe:CalledDecision> only allowed by Camunda Platform ${ allowedVersion } or newer`
|
45
|
-
: 'Extension element of type <zeebe:CalledDecision> not allowed',
|
46
|
-
path: getPath(calledDecision, node),
|
47
|
-
data: {
|
48
|
-
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
49
|
-
node,
|
50
|
-
parentNode: null,
|
51
|
-
extensionElement: calledDecision,
|
52
|
-
allowedVersion
|
53
|
-
}
|
54
|
-
});
|
55
|
-
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
|
59
|
-
errors = hasProperties(calledDecision, {
|
60
|
-
decisionId: {
|
61
|
-
required: true
|
62
|
-
},
|
63
|
-
resultVariable: {
|
64
|
-
required: true
|
65
|
-
}
|
66
|
-
}, node);
|
67
|
-
|
68
|
-
if (errors && errors.length) {
|
69
|
-
reportErrors(node, reporter, errors);
|
70
|
-
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
if (!calledDecision && taskDefinition) {
|
76
|
-
|
77
|
-
if (!isTaskDefinitionAllowed(node, version)) {
|
78
|
-
const allowedVersion = config.taskDefinition[ node.$type ] || null;
|
79
|
-
|
80
|
-
reportErrors(node, reporter, {
|
81
|
-
message: allowedVersion
|
82
|
-
? `Extension element of type <zeebe:TaskDefinition> only allowed by Camunda Platform ${ allowedVersion } or newer`
|
83
|
-
: 'Extension element of type <zeebe:TaskDefinition> not allowed',
|
84
|
-
path: getPath(taskDefinition, node),
|
85
|
-
data: {
|
86
|
-
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
87
|
-
node,
|
88
|
-
parentNode: null,
|
89
|
-
extensionElement: taskDefinition,
|
90
|
-
allowedVersion
|
91
|
-
}
|
92
|
-
});
|
93
|
-
|
94
|
-
return;
|
95
|
-
}
|
96
|
-
|
97
|
-
errors = hasProperties(taskDefinition, {
|
98
|
-
type: {
|
99
|
-
required: true
|
100
|
-
}
|
101
|
-
}, node);
|
102
|
-
|
103
|
-
if (errors && errors.length) {
|
104
|
-
reportErrors(node, reporter, errors);
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
if (isCalledDecisionAllowed(node, version) && isTaskDefinitionAllowed(node, version)) {
|
109
|
-
errors = hasExtensionElement(node, [
|
110
|
-
'zeebe:CalledDecision',
|
111
|
-
'zeebe:TaskDefinition'
|
112
|
-
], node);
|
113
|
-
} else if (isCalledDecisionAllowed(node, version)) {
|
114
|
-
errors = hasExtensionElement(node, 'zeebe:CalledDecision', node);
|
115
|
-
} else {
|
116
|
-
errors = hasExtensionElement(node, 'zeebe:TaskDefinition', node);
|
117
|
-
}
|
118
|
-
|
119
|
-
if (errors && errors.length) {
|
120
|
-
reportErrors(node, reporter, errors);
|
121
|
-
|
122
|
-
return;
|
123
|
-
}
|
124
|
-
}
|
125
|
-
|
126
|
-
return {
|
127
|
-
check
|
128
|
-
};
|
129
|
-
};
|
130
|
-
|
131
|
-
function isCalledDecisionAllowed(node, version) {
|
132
|
-
const { calledDecision } = config;
|
133
|
-
|
134
|
-
return calledDecision[ node.$type ] && greaterOrEqual(version, calledDecision[ node.$type ]);
|
135
|
-
}
|
136
|
-
|
137
|
-
function isTaskDefinitionAllowed(node, version) {
|
138
|
-
const { taskDefinition } = config;
|
139
|
-
|
140
|
-
return taskDefinition[ node.$type ] && greaterOrEqual(version, taskDefinition[ node.$type ]);
|
141
|
-
}
|