bpmnlint-plugin-camunda-compat 0.6.3 → 0.8.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/CHANGELOG.md +19 -2
- package/README.md +5 -6
- package/index.js +50 -28
- package/package.json +4 -5
- package/rules/called-decision-or-task-definition/config.js +36 -0
- package/rules/called-decision-or-task-definition/index.js +122 -0
- package/rules/called-element.js +41 -0
- package/rules/element-type/config.js +186 -0
- package/rules/element-type/index.js +86 -0
- package/rules/error-reference.js +53 -0
- package/rules/loop-characteristics.js +65 -0
- package/rules/message-reference.js +59 -0
- package/rules/no-template.js +21 -0
- package/rules/subscription.js +64 -0
- package/rules/utils/element.js +99 -517
- package/rules/utils/error-types.js +9 -0
- package/rules/utils/reporter.js +11 -0
- package/rules/camunda-cloud-1-0-checks.js +0 -245
- package/rules/camunda-cloud-1-0.js +0 -5
- package/rules/camunda-cloud-1-1-checks.js +0 -89
- package/rules/camunda-cloud-1-1.js +0 -5
- package/rules/camunda-cloud-1-2-checks.js +0 -60
- package/rules/camunda-cloud-1-2.js +0 -5
- package/rules/camunda-cloud-1-3-checks.js +0 -37
- package/rules/camunda-cloud-1-3.js +0 -5
- package/rules/camunda-cloud-8-0-checks.js +0 -5
- package/rules/camunda-cloud-8-0.js +0 -5
- package/rules/camunda-platform-7-15.js +0 -3
- package/rules/camunda-platform-7-16.js +0 -3
- package/rules/camunda-platform-7-17.js +0 -3
- package/rules/utils/cloud/element.js +0 -105
- package/rules/utils/engine-profile.js +0 -10
- package/rules/utils/rule.js +0 -324
- package/rules/utils/type.js +0 -47
package/rules/utils/rule.js
DELETED
@@ -1,324 +0,0 @@
|
|
1
|
-
const {
|
2
|
-
every,
|
3
|
-
isArray,
|
4
|
-
isObject,
|
5
|
-
isString,
|
6
|
-
some
|
7
|
-
} = require('min-dash');
|
8
|
-
|
9
|
-
const {
|
10
|
-
is,
|
11
|
-
isAny
|
12
|
-
} = require('bpmnlint-utils');
|
13
|
-
|
14
|
-
const { toSemverMinor } = require('./engine-profile');
|
15
|
-
|
16
|
-
const { ERROR_TYPES } = require('./element');
|
17
|
-
|
18
|
-
const { getTypeString } = require('./type');
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Factory function for rules. Returns a rule for a given execution platform,
|
22
|
-
* execution platform version and an array of checks. Must be run on
|
23
|
-
* bpmn:Definitions node. Returns early without traversing further if execution
|
24
|
-
* platform or execution platform version doesn't match. Returns early if node
|
25
|
-
* is not a bpmn:FlowElement or bpmn:FlowElementContainer.
|
26
|
-
*
|
27
|
-
* @param {string} ruleExecutionPlatform
|
28
|
-
* @param {string} ruleExecutionPlatformVersion
|
29
|
-
* @param {(Object|string)[]} checks
|
30
|
-
* @param {string} executionPlatformLabel
|
31
|
-
*
|
32
|
-
* @returns {Function}
|
33
|
-
*/
|
34
|
-
module.exports.createRule = function(ruleExecutionPlatform, ruleExecutionPlatformVersion, checks, executionPlatformLabel) {
|
35
|
-
return () => {
|
36
|
-
return {
|
37
|
-
check: (node, reporter) => {
|
38
|
-
if (is(node, 'bpmn:Definitions')) {
|
39
|
-
const executionPlatform = node.get('modeler:executionPlatform');
|
40
|
-
const executionPlatformVersion = node.get('modeler:executionPlatformVersion');
|
41
|
-
|
42
|
-
if (!executionPlatform
|
43
|
-
|| executionPlatform !== ruleExecutionPlatform
|
44
|
-
|| !executionPlatformVersion
|
45
|
-
|| toSemverMinor(executionPlatformVersion) !== ruleExecutionPlatformVersion) {
|
46
|
-
return false;
|
47
|
-
}
|
48
|
-
} else if (!isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
|
49
|
-
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
let results = checkNode(node, checks);
|
53
|
-
|
54
|
-
if (results === true) {
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
|
58
|
-
const id = node.get('id') || '';
|
59
|
-
|
60
|
-
const label = getLabel(node);
|
61
|
-
|
62
|
-
if (results === false) {
|
63
|
-
const message = getMessage(node, ruleExecutionPlatform, ruleExecutionPlatformVersion, executionPlatformLabel);
|
64
|
-
|
65
|
-
let options = {
|
66
|
-
error: {
|
67
|
-
type: ERROR_TYPES.ELEMENT_TYPE,
|
68
|
-
element: node.$type
|
69
|
-
}
|
70
|
-
};
|
71
|
-
|
72
|
-
if (label) {
|
73
|
-
options = {
|
74
|
-
...options,
|
75
|
-
label
|
76
|
-
};
|
77
|
-
}
|
78
|
-
|
79
|
-
reporter.report(id, message, options);
|
80
|
-
} else {
|
81
|
-
if (!isArray(results)) {
|
82
|
-
results = [ results ];
|
83
|
-
}
|
84
|
-
|
85
|
-
results.forEach((result) => {
|
86
|
-
if (isString(result)) {
|
87
|
-
result = { message: result };
|
88
|
-
}
|
89
|
-
|
90
|
-
let {
|
91
|
-
message,
|
92
|
-
...rest
|
93
|
-
} = result;
|
94
|
-
|
95
|
-
message = addExecutionPlatform(message, executionPlatformLabel || `${ ruleExecutionPlatform } ${ toSemverMinor(ruleExecutionPlatformVersion) }`);
|
96
|
-
|
97
|
-
let options = {
|
98
|
-
...rest
|
99
|
-
};
|
100
|
-
|
101
|
-
if (label) {
|
102
|
-
options = {
|
103
|
-
...options,
|
104
|
-
label
|
105
|
-
};
|
106
|
-
}
|
107
|
-
|
108
|
-
reporter.report(id, message, options);
|
109
|
-
});
|
110
|
-
}
|
111
|
-
}
|
112
|
-
};
|
113
|
-
};
|
114
|
-
};
|
115
|
-
|
116
|
-
/**
|
117
|
-
* Create no-op rule that always returns false resulting in early return.
|
118
|
-
*
|
119
|
-
* @returns {Function}
|
120
|
-
*/
|
121
|
-
module.exports.createNoopRule = function() {
|
122
|
-
return () => {
|
123
|
-
return {
|
124
|
-
check: () => false
|
125
|
-
};
|
126
|
-
};
|
127
|
-
};
|
128
|
-
|
129
|
-
/**
|
130
|
-
* Run checks on a node. Return true if at least one of the checks returns true.
|
131
|
-
* Otherwise return all errors or false.
|
132
|
-
*
|
133
|
-
* @param {ModdleElement} node
|
134
|
-
* @param {Array<Function>} checks
|
135
|
-
*
|
136
|
-
* @returns {boolean|Object|Object[]|string|string[]}
|
137
|
-
*/
|
138
|
-
function checkNode(node, checks) {
|
139
|
-
const results = checks.map((check) => {
|
140
|
-
|
141
|
-
// (1) check using type only
|
142
|
-
if (isString(check)) {
|
143
|
-
return isExactly(node, check);
|
144
|
-
}
|
145
|
-
|
146
|
-
const { type } = check;
|
147
|
-
|
148
|
-
// (2) check using function only
|
149
|
-
if (!type) {
|
150
|
-
return check.check(node);
|
151
|
-
}
|
152
|
-
|
153
|
-
// (3) check using type and function
|
154
|
-
if (!isExactly(node, type)) {
|
155
|
-
return false;
|
156
|
-
}
|
157
|
-
|
158
|
-
return check.check(node);
|
159
|
-
});
|
160
|
-
|
161
|
-
return results.find((result) => result === true) || getErrors(results);
|
162
|
-
}
|
163
|
-
|
164
|
-
module.exports.checkNode = checkNode;
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Create function that runs checks on a node. Return true if all checks return
|
168
|
-
* true. Otherwise return all errors or false.
|
169
|
-
*
|
170
|
-
* @param {Array<Function>} checks
|
171
|
-
*
|
172
|
-
* @returns {boolean|Object|Object[]|string|string[]}
|
173
|
-
*/
|
174
|
-
module.exports.checkEvery = function(...checks) {
|
175
|
-
return function(node) {
|
176
|
-
const results = checks.map((check) => check(node));
|
177
|
-
|
178
|
-
return every(results, result => result === true) || getErrors(results);
|
179
|
-
};
|
180
|
-
};
|
181
|
-
|
182
|
-
/**
|
183
|
-
* Create function that runs checks on a node. Return true if at least one of
|
184
|
-
* the checks returns true. Otherwise return all errors or false.
|
185
|
-
*
|
186
|
-
* @param {Array<Function>} checks
|
187
|
-
*
|
188
|
-
* @returns {boolean|Object|Object[]|string|string[]}
|
189
|
-
*/
|
190
|
-
module.exports.checkSome = function(...checks) {
|
191
|
-
return function(node) {
|
192
|
-
const results = checks.map((check) => check(node));
|
193
|
-
|
194
|
-
return some(results, result => result === true) || getErrors(results);
|
195
|
-
};
|
196
|
-
};
|
197
|
-
|
198
|
-
/**
|
199
|
-
* Replace check for element of type.
|
200
|
-
*
|
201
|
-
* @param {(Object|string)[]} checks
|
202
|
-
* @param {string} type
|
203
|
-
* @param {Function} check
|
204
|
-
*
|
205
|
-
* @returns {(Object|string)[]}
|
206
|
-
*/
|
207
|
-
module.exports.replaceCheck = function(checks, type, check) {
|
208
|
-
return replaceChecks(checks, [
|
209
|
-
{
|
210
|
-
type,
|
211
|
-
check
|
212
|
-
}
|
213
|
-
]);
|
214
|
-
};
|
215
|
-
|
216
|
-
function replaceChecks(checks, replacements) {
|
217
|
-
return checks.map((check) => {
|
218
|
-
if (isString(check)) {
|
219
|
-
const replacement = replacements.find((replacement) => check === replacement.type);
|
220
|
-
|
221
|
-
if (replacement) {
|
222
|
-
return {
|
223
|
-
check: replacement.check,
|
224
|
-
type: check
|
225
|
-
};
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
if (check.type) {
|
230
|
-
const replacement = replacements.find((replacement) => check.type === replacement.type);
|
231
|
-
|
232
|
-
if (replacement) {
|
233
|
-
return {
|
234
|
-
...check,
|
235
|
-
check: replacement.check
|
236
|
-
};
|
237
|
-
}
|
238
|
-
}
|
239
|
-
|
240
|
-
return check;
|
241
|
-
});
|
242
|
-
}
|
243
|
-
|
244
|
-
module.exports.replaceChecks = replaceChecks;
|
245
|
-
|
246
|
-
function addExecutionPlatform(string, executionPlatform) {
|
247
|
-
return string
|
248
|
-
.replace('{{ executionPlatform }}', executionPlatform);
|
249
|
-
}
|
250
|
-
|
251
|
-
/**
|
252
|
-
* Return all errors or false.
|
253
|
-
*
|
254
|
-
* @param {(boolean|Object|string)[]} result
|
255
|
-
*
|
256
|
-
* @returns {boolean|(Object|string)[]}
|
257
|
-
*/
|
258
|
-
function getErrors(results) {
|
259
|
-
const errors = results.reduce((errors, result) => {
|
260
|
-
if (isArray(result)) {
|
261
|
-
return [
|
262
|
-
...errors,
|
263
|
-
...result
|
264
|
-
];
|
265
|
-
}
|
266
|
-
|
267
|
-
if (isObject(result) || isString(result)) {
|
268
|
-
return [
|
269
|
-
...errors,
|
270
|
-
result
|
271
|
-
];
|
272
|
-
}
|
273
|
-
|
274
|
-
return errors;
|
275
|
-
}, []);
|
276
|
-
|
277
|
-
if (errors.length === 1) {
|
278
|
-
return errors[ 0 ];
|
279
|
-
} else if (errors.length > 1) {
|
280
|
-
return errors;
|
281
|
-
}
|
282
|
-
|
283
|
-
return false;
|
284
|
-
}
|
285
|
-
|
286
|
-
function isExactly(node, type) {
|
287
|
-
const { $model } = node;
|
288
|
-
|
289
|
-
return $model.getType(node.$type) === $model.getType(type);
|
290
|
-
}
|
291
|
-
|
292
|
-
function getIndefiniteArticle(type) {
|
293
|
-
if ([
|
294
|
-
'Error',
|
295
|
-
'Escalation',
|
296
|
-
'Event',
|
297
|
-
'Intermediate',
|
298
|
-
'Undefined'
|
299
|
-
].includes(type.split(' ')[ 0 ])) {
|
300
|
-
return 'An';
|
301
|
-
}
|
302
|
-
|
303
|
-
return 'A';
|
304
|
-
}
|
305
|
-
|
306
|
-
function getMessage(node, executionPlatform, executionPlatformVersion, label) {
|
307
|
-
const type = getTypeString(node);
|
308
|
-
|
309
|
-
const indefiniteArticle = getIndefiniteArticle(type);
|
310
|
-
|
311
|
-
return addExecutionPlatform(`${ indefiniteArticle } <${ type }> is not supported by {{ executionPlatform }}`, label || `${ executionPlatform } ${ toSemverMinor(executionPlatformVersion) }`);
|
312
|
-
}
|
313
|
-
|
314
|
-
function getLabel(node) {
|
315
|
-
if (is(node, 'bpmn:Group')) {
|
316
|
-
const categoryValueRef = node.get('categoryValueRef');
|
317
|
-
|
318
|
-
return categoryValueRef && categoryValueRef.get('value');
|
319
|
-
} else if (is(node, 'bpmn:TextAnnotation')) {
|
320
|
-
return node.get('text');
|
321
|
-
}
|
322
|
-
|
323
|
-
return node.get('name');
|
324
|
-
}
|
package/rules/utils/type.js
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
function getEventDefinition(node) {
|
2
|
-
const eventDefinitions = node.get('eventDefinitions');
|
3
|
-
|
4
|
-
return eventDefinitions && eventDefinitions[0];
|
5
|
-
}
|
6
|
-
|
7
|
-
function getEventDefinitionPrefix(eventDefinition) {
|
8
|
-
const localType = getLocalType(eventDefinition);
|
9
|
-
|
10
|
-
return localType.replace('EventDefinition', '');
|
11
|
-
}
|
12
|
-
|
13
|
-
function getLocalType(node) {
|
14
|
-
const { $descriptor } = node;
|
15
|
-
|
16
|
-
const { localName } = $descriptor.ns;
|
17
|
-
|
18
|
-
return localName;
|
19
|
-
}
|
20
|
-
|
21
|
-
function formatTypeString(string) {
|
22
|
-
return string.replace(/([a-z])([A-Z])/g, '$1 $2').trim();
|
23
|
-
}
|
24
|
-
|
25
|
-
module.exports.getTypeString = function(node) {
|
26
|
-
let type = getLocalType(node);
|
27
|
-
|
28
|
-
const eventDefinition = getEventDefinition(node);
|
29
|
-
|
30
|
-
if (eventDefinition) {
|
31
|
-
type = `${ getEventDefinitionPrefix(eventDefinition) }${ type }`;
|
32
|
-
} else if ([
|
33
|
-
'BoundaryEvent',
|
34
|
-
'EndEvent',
|
35
|
-
'IntermediateCatchEvent',
|
36
|
-
'IntermediateThrowEvent',
|
37
|
-
'StartEvent'
|
38
|
-
].includes(type)) {
|
39
|
-
type = `Undefined ${ type }`;
|
40
|
-
}
|
41
|
-
|
42
|
-
if (type === 'Task') {
|
43
|
-
type = 'Undefined Task';
|
44
|
-
}
|
45
|
-
|
46
|
-
return formatTypeString(type);
|
47
|
-
};
|