bpmnlint-plugin-camunda-compat 2.35.0 → 2.36.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/LICENSE +20 -20
- package/README.md +39 -39
- package/index.js +286 -286
- package/package.json +53 -53
- package/rules/camunda-cloud/ad-hoc-sub-process.js +60 -60
- package/rules/camunda-cloud/called-element.js +44 -44
- package/rules/camunda-cloud/collapsed-subprocess.js +40 -40
- package/rules/camunda-cloud/connector-properties/config.js +90 -90
- package/rules/camunda-cloud/connector-properties/index.js +47 -47
- package/rules/camunda-cloud/duplicate-execution-listeners.js +33 -33
- package/rules/camunda-cloud/duplicate-task-headers.js +58 -58
- package/rules/camunda-cloud/element-type/config.js +67 -67
- package/rules/camunda-cloud/element-type/index.js +135 -135
- package/rules/camunda-cloud/error-reference.js +72 -72
- package/rules/camunda-cloud/escalation-boundary-event-attached-to-ref.js +47 -47
- package/rules/camunda-cloud/escalation-reference.js +67 -67
- package/rules/camunda-cloud/event-based-gateway-target.js +38 -38
- package/rules/camunda-cloud/executable-process.js +61 -61
- package/rules/camunda-cloud/execution-listener.js +33 -33
- package/rules/camunda-cloud/feel.js +86 -86
- package/rules/camunda-cloud/implementation/config.js +19 -19
- package/rules/camunda-cloud/implementation/index.js +218 -218
- package/rules/camunda-cloud/inclusive-gateway.js +35 -35
- package/rules/camunda-cloud/link-event.js +142 -142
- package/rules/camunda-cloud/loop-characteristics.js +66 -66
- package/rules/camunda-cloud/message-reference.js +61 -61
- package/rules/camunda-cloud/no-binding-type.js +43 -43
- package/rules/camunda-cloud/no-candidate-users.js +38 -38
- package/rules/camunda-cloud/no-execution-listeners.js +21 -21
- package/rules/camunda-cloud/no-expression.js +173 -173
- package/rules/camunda-cloud/no-loop.js +316 -316
- package/rules/camunda-cloud/no-multiple-none-start-events.js +41 -41
- package/rules/camunda-cloud/no-priority-definition.js +18 -18
- package/rules/camunda-cloud/no-propagate-all-parent-variables.js +44 -44
- package/rules/camunda-cloud/no-signal-event-sub-process.js +45 -45
- package/rules/camunda-cloud/no-task-listeners.js +21 -21
- package/rules/camunda-cloud/no-task-schedule.js +18 -18
- package/rules/camunda-cloud/no-template.js +23 -23
- package/rules/camunda-cloud/no-version-tag.js +24 -24
- package/rules/camunda-cloud/no-zeebe-properties.js +18 -18
- package/rules/camunda-cloud/no-zeebe-user-task.js +27 -27
- package/rules/camunda-cloud/priority-definition.js +61 -61
- package/rules/camunda-cloud/secrets.js +119 -119
- package/rules/camunda-cloud/sequence-flow-condition.js +56 -56
- package/rules/camunda-cloud/signal-reference.js +64 -64
- package/rules/camunda-cloud/start-event-form.js +97 -97
- package/rules/camunda-cloud/subscription.js +65 -65
- package/rules/camunda-cloud/task-listener.js +39 -39
- package/rules/camunda-cloud/task-schedule.js +67 -67
- package/rules/camunda-cloud/timer/config.js +46 -46
- package/rules/camunda-cloud/timer/index.js +183 -183
- package/rules/camunda-cloud/user-task-definition.js +24 -24
- package/rules/camunda-cloud/user-task-form.js +142 -142
- package/rules/camunda-cloud/wait-for-completion.js +46 -46
- package/rules/camunda-cloud/zeebe-user-task.js +30 -30
- package/rules/camunda-platform/history-time-to-live.js +24 -21
- package/rules/helper.js +38 -38
- package/rules/utils/cron.js +95 -95
- package/rules/utils/element.js +533 -533
- package/rules/utils/error-types.js +26 -26
- package/rules/utils/iso8601.js +52 -52
- package/rules/utils/reporter.js +37 -37
- package/rules/utils/rule.js +46 -46
- package/rules/utils/version.js +4 -4
@@ -1,87 +1,87 @@
|
|
1
|
-
const { isString } = require('min-dash');
|
2
|
-
|
3
|
-
const {
|
4
|
-
is,
|
5
|
-
isAny
|
6
|
-
} = require('bpmnlint-utils');
|
7
|
-
|
8
|
-
const { lintExpression } = require('@bpmn-io/feel-lint');
|
9
|
-
|
10
|
-
const { getPath } = require('@bpmn-io/moddle-utils');
|
11
|
-
|
12
|
-
const { reportErrors } = require('../utils/reporter');
|
13
|
-
|
14
|
-
const { ERROR_TYPES } = require('../utils/error-types');
|
15
|
-
|
16
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
17
|
-
const { annotateRule } = require('../helper');
|
18
|
-
|
19
|
-
module.exports = skipInNonExecutableProcess(function() {
|
20
|
-
function check(node, reporter) {
|
21
|
-
if (is(node, 'bpmn:Expression')) {
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
|
25
|
-
const parentNode = findParentNode(node);
|
26
|
-
|
27
|
-
if (!parentNode) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
|
31
|
-
const errors = [];
|
32
|
-
|
33
|
-
Object.entries(node).forEach(([ propertyName, propertyValue ]) => {
|
34
|
-
if (propertyValue && is(propertyValue, 'bpmn:Expression')) {
|
35
|
-
propertyValue = propertyValue.get('body');
|
36
|
-
}
|
37
|
-
|
38
|
-
if (isFeelProperty([ propertyName, propertyValue ])) {
|
39
|
-
const lintErrors = lintExpression(propertyValue.substring(1));
|
40
|
-
|
41
|
-
// syntax error
|
42
|
-
if (lintErrors.find(({ type }) => type === 'Syntax Error')) {
|
43
|
-
const path = getPath(node, parentNode);
|
44
|
-
|
45
|
-
errors.push(
|
46
|
-
{
|
47
|
-
message: `Property <${ propertyName }> is not a valid FEEL expression`,
|
48
|
-
path: path
|
49
|
-
? [ ...path, propertyName ]
|
50
|
-
: [ propertyName ],
|
51
|
-
data: {
|
52
|
-
type: ERROR_TYPES.FEEL_EXPRESSION_INVALID,
|
53
|
-
node,
|
54
|
-
parentNode,
|
55
|
-
property: propertyName
|
56
|
-
}
|
57
|
-
}
|
58
|
-
);
|
59
|
-
}
|
60
|
-
}
|
61
|
-
});
|
62
|
-
|
63
|
-
if (errors && errors.length) {
|
64
|
-
reportErrors(parentNode, reporter, errors);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
return annotateRule('feel', {
|
69
|
-
check
|
70
|
-
});
|
71
|
-
});
|
72
|
-
|
73
|
-
const isFeelProperty = ([ propertyName, value ]) => {
|
74
|
-
return !isIgnoredProperty(propertyName) && isString(value) && value.startsWith('=');
|
75
|
-
};
|
76
|
-
|
77
|
-
const isIgnoredProperty = propertyName => {
|
78
|
-
return propertyName.startsWith('$');
|
79
|
-
};
|
80
|
-
|
81
|
-
const findParentNode = node => {
|
82
|
-
while (node && !isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
|
83
|
-
node = node.$parent;
|
84
|
-
}
|
85
|
-
|
86
|
-
return node;
|
1
|
+
const { isString } = require('min-dash');
|
2
|
+
|
3
|
+
const {
|
4
|
+
is,
|
5
|
+
isAny
|
6
|
+
} = require('bpmnlint-utils');
|
7
|
+
|
8
|
+
const { lintExpression } = require('@bpmn-io/feel-lint');
|
9
|
+
|
10
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
11
|
+
|
12
|
+
const { reportErrors } = require('../utils/reporter');
|
13
|
+
|
14
|
+
const { ERROR_TYPES } = require('../utils/error-types');
|
15
|
+
|
16
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
17
|
+
const { annotateRule } = require('../helper');
|
18
|
+
|
19
|
+
module.exports = skipInNonExecutableProcess(function() {
|
20
|
+
function check(node, reporter) {
|
21
|
+
if (is(node, 'bpmn:Expression')) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
25
|
+
const parentNode = findParentNode(node);
|
26
|
+
|
27
|
+
if (!parentNode) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
|
31
|
+
const errors = [];
|
32
|
+
|
33
|
+
Object.entries(node).forEach(([ propertyName, propertyValue ]) => {
|
34
|
+
if (propertyValue && is(propertyValue, 'bpmn:Expression')) {
|
35
|
+
propertyValue = propertyValue.get('body');
|
36
|
+
}
|
37
|
+
|
38
|
+
if (isFeelProperty([ propertyName, propertyValue ])) {
|
39
|
+
const lintErrors = lintExpression(propertyValue.substring(1));
|
40
|
+
|
41
|
+
// syntax error
|
42
|
+
if (lintErrors.find(({ type }) => type === 'Syntax Error')) {
|
43
|
+
const path = getPath(node, parentNode);
|
44
|
+
|
45
|
+
errors.push(
|
46
|
+
{
|
47
|
+
message: `Property <${ propertyName }> is not a valid FEEL expression`,
|
48
|
+
path: path
|
49
|
+
? [ ...path, propertyName ]
|
50
|
+
: [ propertyName ],
|
51
|
+
data: {
|
52
|
+
type: ERROR_TYPES.FEEL_EXPRESSION_INVALID,
|
53
|
+
node,
|
54
|
+
parentNode,
|
55
|
+
property: propertyName
|
56
|
+
}
|
57
|
+
}
|
58
|
+
);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
});
|
62
|
+
|
63
|
+
if (errors && errors.length) {
|
64
|
+
reportErrors(parentNode, reporter, errors);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
return annotateRule('feel', {
|
69
|
+
check
|
70
|
+
});
|
71
|
+
});
|
72
|
+
|
73
|
+
const isFeelProperty = ([ propertyName, value ]) => {
|
74
|
+
return !isIgnoredProperty(propertyName) && isString(value) && value.startsWith('=');
|
75
|
+
};
|
76
|
+
|
77
|
+
const isIgnoredProperty = propertyName => {
|
78
|
+
return propertyName.startsWith('$');
|
79
|
+
};
|
80
|
+
|
81
|
+
const findParentNode = node => {
|
82
|
+
while (node && !isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
|
83
|
+
node = node.$parent;
|
84
|
+
}
|
85
|
+
|
86
|
+
return node;
|
87
87
|
};
|
@@ -1,20 +1,20 @@
|
|
1
|
-
module.exports = {
|
2
|
-
calledDecision: {
|
3
|
-
'bpmn:BusinessRuleTask': '1.3'
|
4
|
-
},
|
5
|
-
taskDefinition: {
|
6
|
-
'bpmn:BusinessRuleTask': '1.1',
|
7
|
-
'bpmn:IntermediateThrowEvent': {
|
8
|
-
'bpmn:MessageEventDefinition': '1.2'
|
9
|
-
},
|
10
|
-
'bpmn:EndEvent': {
|
11
|
-
'bpmn:MessageEventDefinition': '1.2'
|
12
|
-
},
|
13
|
-
'bpmn:ScriptTask': '1.1',
|
14
|
-
'bpmn:SendTask': '1.1',
|
15
|
-
'bpmn:ServiceTask': '1.0'
|
16
|
-
},
|
17
|
-
script: {
|
18
|
-
'bpmn:ScriptTask': '8.2'
|
19
|
-
}
|
1
|
+
module.exports = {
|
2
|
+
calledDecision: {
|
3
|
+
'bpmn:BusinessRuleTask': '1.3'
|
4
|
+
},
|
5
|
+
taskDefinition: {
|
6
|
+
'bpmn:BusinessRuleTask': '1.1',
|
7
|
+
'bpmn:IntermediateThrowEvent': {
|
8
|
+
'bpmn:MessageEventDefinition': '1.2'
|
9
|
+
},
|
10
|
+
'bpmn:EndEvent': {
|
11
|
+
'bpmn:MessageEventDefinition': '1.2'
|
12
|
+
},
|
13
|
+
'bpmn:ScriptTask': '1.1',
|
14
|
+
'bpmn:SendTask': '1.1',
|
15
|
+
'bpmn:ServiceTask': '1.0'
|
16
|
+
},
|
17
|
+
script: {
|
18
|
+
'bpmn:ScriptTask': '8.2'
|
19
|
+
}
|
20
20
|
};
|
@@ -1,218 +1,218 @@
|
|
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
|
-
const { skipInNonExecutableProcess } = require('../../utils/rule');
|
23
|
-
|
24
|
-
module.exports = skipInNonExecutableProcess(function({ version }) {
|
25
|
-
function check(node, reporter) {
|
26
|
-
const calledDecisionConfig = config.calledDecision[ node.$type ];
|
27
|
-
const scriptConfig = config.script[ node.$type ];
|
28
|
-
const taskDefinitionConfig = config.taskDefinition[ node.$type ];
|
29
|
-
|
30
|
-
if (
|
31
|
-
(!calledDecisionConfig || (isString(calledDecisionConfig) && !greaterOrEqual(version, calledDecisionConfig)))
|
32
|
-
&& (!scriptConfig || (isString(scriptConfig) && !greaterOrEqual(version, scriptConfig)))
|
33
|
-
&& (!taskDefinitionConfig || (isString(taskDefinitionConfig) && !greaterOrEqual(version, taskDefinitionConfig)))) {
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
|
37
|
-
if (is(node, 'bpmn:ThrowEvent') && !getEventDefinition(node)) {
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
|
41
|
-
let errors;
|
42
|
-
|
43
|
-
const calledDecision = findExtensionElement(node, 'zeebe:CalledDecision'),
|
44
|
-
script = findExtensionElement(node, 'zeebe:Script'),
|
45
|
-
taskDefinition = findExtensionElement(node, 'zeebe:TaskDefinition');
|
46
|
-
|
47
|
-
if (calledDecision && !script && !taskDefinition) {
|
48
|
-
|
49
|
-
if (!isCalledDecisionAllowed(node, version)) {
|
50
|
-
const allowedVersion = getAllowedVersion(calledDecisionConfig, node);
|
51
|
-
|
52
|
-
reportErrors(node, reporter, {
|
53
|
-
message: allowedVersion
|
54
|
-
? `Extension element of type <zeebe:CalledDecision> only allowed by Camunda ${ allowedVersion } or newer`
|
55
|
-
: 'Extension element of type <zeebe:CalledDecision> not allowed',
|
56
|
-
path: getPath(calledDecision, node),
|
57
|
-
data: {
|
58
|
-
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
59
|
-
node,
|
60
|
-
parentNode: null,
|
61
|
-
extensionElement: calledDecision,
|
62
|
-
allowedVersion
|
63
|
-
}
|
64
|
-
});
|
65
|
-
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
|
69
|
-
errors = hasProperties(calledDecision, {
|
70
|
-
decisionId: {
|
71
|
-
required: true
|
72
|
-
},
|
73
|
-
resultVariable: {
|
74
|
-
required: true
|
75
|
-
}
|
76
|
-
}, node);
|
77
|
-
|
78
|
-
if (errors && errors.length) {
|
79
|
-
reportErrors(node, reporter, errors);
|
80
|
-
|
81
|
-
return;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
if (!calledDecision && script && !taskDefinition) {
|
86
|
-
|
87
|
-
if (!isScriptAllowed(node, version)) {
|
88
|
-
const allowedVersion = getAllowedVersion(scriptConfig, node);
|
89
|
-
|
90
|
-
reportErrors(node, reporter, {
|
91
|
-
message: allowedVersion
|
92
|
-
? `Extension element of type <zeebe:Script> only allowed by Camunda ${ allowedVersion } or newer`
|
93
|
-
: 'Extension element of type <zeebe:Script> not allowed',
|
94
|
-
path: getPath(script, node),
|
95
|
-
data: {
|
96
|
-
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
97
|
-
node,
|
98
|
-
parentNode: null,
|
99
|
-
extensionElement: script,
|
100
|
-
allowedVersion
|
101
|
-
}
|
102
|
-
});
|
103
|
-
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
|
107
|
-
errors = hasProperties(script, {
|
108
|
-
expression: {
|
109
|
-
required: true
|
110
|
-
},
|
111
|
-
resultVariable: {
|
112
|
-
required: true
|
113
|
-
}
|
114
|
-
}, node);
|
115
|
-
|
116
|
-
if (errors && errors.length) {
|
117
|
-
reportErrors(node, reporter, errors);
|
118
|
-
|
119
|
-
return;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
|
123
|
-
if (!calledDecision && !script && taskDefinition) {
|
124
|
-
|
125
|
-
if (!isTaskDefinitionAllowed(node, version)) {
|
126
|
-
const allowedVersion = getAllowedVersion(taskDefinitionConfig, node);
|
127
|
-
|
128
|
-
reportErrors(node, reporter, {
|
129
|
-
message: allowedVersion
|
130
|
-
? `Extension element of type <zeebe:TaskDefinition> only allowed by Camunda ${ allowedVersion } or newer`
|
131
|
-
: 'Extension element of type <zeebe:TaskDefinition> not allowed',
|
132
|
-
path: getPath(taskDefinition, node),
|
133
|
-
data: {
|
134
|
-
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
135
|
-
node,
|
136
|
-
parentNode: null,
|
137
|
-
extensionElement: taskDefinition,
|
138
|
-
allowedVersion
|
139
|
-
}
|
140
|
-
});
|
141
|
-
|
142
|
-
return;
|
143
|
-
}
|
144
|
-
|
145
|
-
errors = hasProperties(taskDefinition, {
|
146
|
-
type: {
|
147
|
-
required: true
|
148
|
-
}
|
149
|
-
}, node);
|
150
|
-
|
151
|
-
if (errors && errors.length) {
|
152
|
-
reportErrors(node, reporter, errors);
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
const allowedTypes = [
|
157
|
-
isCalledDecisionAllowed(node, version) ? 'zeebe:CalledDecision' : false,
|
158
|
-
isScriptAllowed(node, version) ? 'zeebe:Script' : false,
|
159
|
-
isTaskDefinitionAllowed(node, version) ? 'zeebe:TaskDefinition' : false
|
160
|
-
].filter(isAllowed => isAllowed);
|
161
|
-
|
162
|
-
if (allowedTypes.length === 0) {
|
163
|
-
return;
|
164
|
-
} else if (allowedTypes.length === 1) {
|
165
|
-
errors = hasExtensionElement(node, allowedTypes[0], node);
|
166
|
-
} else {
|
167
|
-
errors = hasExtensionElement(node, allowedTypes, node);
|
168
|
-
}
|
169
|
-
|
170
|
-
if (errors && errors.length) {
|
171
|
-
reportErrors(node, reporter, errors);
|
172
|
-
|
173
|
-
return;
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
return {
|
178
|
-
check
|
179
|
-
};
|
180
|
-
});
|
181
|
-
|
182
|
-
function isCalledDecisionAllowed(node, version) {
|
183
|
-
const { calledDecision } = config;
|
184
|
-
|
185
|
-
const allowedVersion = getAllowedVersion(calledDecision[ node.$type ], node);
|
186
|
-
|
187
|
-
return calledDecision[ node.$type ] && greaterOrEqual(version, allowedVersion);
|
188
|
-
}
|
189
|
-
|
190
|
-
function isScriptAllowed(node, version) {
|
191
|
-
const { script } = config;
|
192
|
-
|
193
|
-
const allowedVersion = getAllowedVersion(script[ node.$type ], node);
|
194
|
-
|
195
|
-
return allowedVersion && greaterOrEqual(version, allowedVersion);
|
196
|
-
}
|
197
|
-
|
198
|
-
function isTaskDefinitionAllowed(node, version) {
|
199
|
-
const { taskDefinition } = config;
|
200
|
-
|
201
|
-
const allowedVersion = getAllowedVersion(taskDefinition[ node.$type ], node);
|
202
|
-
|
203
|
-
return allowedVersion && greaterOrEqual(version, allowedVersion);
|
204
|
-
}
|
205
|
-
|
206
|
-
function getAllowedVersion(config, node) {
|
207
|
-
if (!config) {
|
208
|
-
return null;
|
209
|
-
}
|
210
|
-
|
211
|
-
if (isString(config)) {
|
212
|
-
return config;
|
213
|
-
}
|
214
|
-
|
215
|
-
const eventDefinition = getEventDefinition(node);
|
216
|
-
|
217
|
-
return eventDefinition && config[ eventDefinition.$type ];
|
218
|
-
}
|
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
|
+
const { skipInNonExecutableProcess } = require('../../utils/rule');
|
23
|
+
|
24
|
+
module.exports = skipInNonExecutableProcess(function({ version }) {
|
25
|
+
function check(node, reporter) {
|
26
|
+
const calledDecisionConfig = config.calledDecision[ node.$type ];
|
27
|
+
const scriptConfig = config.script[ node.$type ];
|
28
|
+
const taskDefinitionConfig = config.taskDefinition[ node.$type ];
|
29
|
+
|
30
|
+
if (
|
31
|
+
(!calledDecisionConfig || (isString(calledDecisionConfig) && !greaterOrEqual(version, calledDecisionConfig)))
|
32
|
+
&& (!scriptConfig || (isString(scriptConfig) && !greaterOrEqual(version, scriptConfig)))
|
33
|
+
&& (!taskDefinitionConfig || (isString(taskDefinitionConfig) && !greaterOrEqual(version, taskDefinitionConfig)))) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
if (is(node, 'bpmn:ThrowEvent') && !getEventDefinition(node)) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
|
41
|
+
let errors;
|
42
|
+
|
43
|
+
const calledDecision = findExtensionElement(node, 'zeebe:CalledDecision'),
|
44
|
+
script = findExtensionElement(node, 'zeebe:Script'),
|
45
|
+
taskDefinition = findExtensionElement(node, 'zeebe:TaskDefinition');
|
46
|
+
|
47
|
+
if (calledDecision && !script && !taskDefinition) {
|
48
|
+
|
49
|
+
if (!isCalledDecisionAllowed(node, version)) {
|
50
|
+
const allowedVersion = getAllowedVersion(calledDecisionConfig, node);
|
51
|
+
|
52
|
+
reportErrors(node, reporter, {
|
53
|
+
message: allowedVersion
|
54
|
+
? `Extension element of type <zeebe:CalledDecision> only allowed by Camunda ${ allowedVersion } or newer`
|
55
|
+
: 'Extension element of type <zeebe:CalledDecision> not allowed',
|
56
|
+
path: getPath(calledDecision, node),
|
57
|
+
data: {
|
58
|
+
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
59
|
+
node,
|
60
|
+
parentNode: null,
|
61
|
+
extensionElement: calledDecision,
|
62
|
+
allowedVersion
|
63
|
+
}
|
64
|
+
});
|
65
|
+
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
69
|
+
errors = hasProperties(calledDecision, {
|
70
|
+
decisionId: {
|
71
|
+
required: true
|
72
|
+
},
|
73
|
+
resultVariable: {
|
74
|
+
required: true
|
75
|
+
}
|
76
|
+
}, node);
|
77
|
+
|
78
|
+
if (errors && errors.length) {
|
79
|
+
reportErrors(node, reporter, errors);
|
80
|
+
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
if (!calledDecision && script && !taskDefinition) {
|
86
|
+
|
87
|
+
if (!isScriptAllowed(node, version)) {
|
88
|
+
const allowedVersion = getAllowedVersion(scriptConfig, node);
|
89
|
+
|
90
|
+
reportErrors(node, reporter, {
|
91
|
+
message: allowedVersion
|
92
|
+
? `Extension element of type <zeebe:Script> only allowed by Camunda ${ allowedVersion } or newer`
|
93
|
+
: 'Extension element of type <zeebe:Script> not allowed',
|
94
|
+
path: getPath(script, node),
|
95
|
+
data: {
|
96
|
+
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
97
|
+
node,
|
98
|
+
parentNode: null,
|
99
|
+
extensionElement: script,
|
100
|
+
allowedVersion
|
101
|
+
}
|
102
|
+
});
|
103
|
+
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
errors = hasProperties(script, {
|
108
|
+
expression: {
|
109
|
+
required: true
|
110
|
+
},
|
111
|
+
resultVariable: {
|
112
|
+
required: true
|
113
|
+
}
|
114
|
+
}, node);
|
115
|
+
|
116
|
+
if (errors && errors.length) {
|
117
|
+
reportErrors(node, reporter, errors);
|
118
|
+
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
if (!calledDecision && !script && taskDefinition) {
|
124
|
+
|
125
|
+
if (!isTaskDefinitionAllowed(node, version)) {
|
126
|
+
const allowedVersion = getAllowedVersion(taskDefinitionConfig, node);
|
127
|
+
|
128
|
+
reportErrors(node, reporter, {
|
129
|
+
message: allowedVersion
|
130
|
+
? `Extension element of type <zeebe:TaskDefinition> only allowed by Camunda ${ allowedVersion } or newer`
|
131
|
+
: 'Extension element of type <zeebe:TaskDefinition> not allowed',
|
132
|
+
path: getPath(taskDefinition, node),
|
133
|
+
data: {
|
134
|
+
type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
|
135
|
+
node,
|
136
|
+
parentNode: null,
|
137
|
+
extensionElement: taskDefinition,
|
138
|
+
allowedVersion
|
139
|
+
}
|
140
|
+
});
|
141
|
+
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
|
145
|
+
errors = hasProperties(taskDefinition, {
|
146
|
+
type: {
|
147
|
+
required: true
|
148
|
+
}
|
149
|
+
}, node);
|
150
|
+
|
151
|
+
if (errors && errors.length) {
|
152
|
+
reportErrors(node, reporter, errors);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
const allowedTypes = [
|
157
|
+
isCalledDecisionAllowed(node, version) ? 'zeebe:CalledDecision' : false,
|
158
|
+
isScriptAllowed(node, version) ? 'zeebe:Script' : false,
|
159
|
+
isTaskDefinitionAllowed(node, version) ? 'zeebe:TaskDefinition' : false
|
160
|
+
].filter(isAllowed => isAllowed);
|
161
|
+
|
162
|
+
if (allowedTypes.length === 0) {
|
163
|
+
return;
|
164
|
+
} else if (allowedTypes.length === 1) {
|
165
|
+
errors = hasExtensionElement(node, allowedTypes[0], node);
|
166
|
+
} else {
|
167
|
+
errors = hasExtensionElement(node, allowedTypes, node);
|
168
|
+
}
|
169
|
+
|
170
|
+
if (errors && errors.length) {
|
171
|
+
reportErrors(node, reporter, errors);
|
172
|
+
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
return {
|
178
|
+
check
|
179
|
+
};
|
180
|
+
});
|
181
|
+
|
182
|
+
function isCalledDecisionAllowed(node, version) {
|
183
|
+
const { calledDecision } = config;
|
184
|
+
|
185
|
+
const allowedVersion = getAllowedVersion(calledDecision[ node.$type ], node);
|
186
|
+
|
187
|
+
return calledDecision[ node.$type ] && greaterOrEqual(version, allowedVersion);
|
188
|
+
}
|
189
|
+
|
190
|
+
function isScriptAllowed(node, version) {
|
191
|
+
const { script } = config;
|
192
|
+
|
193
|
+
const allowedVersion = getAllowedVersion(script[ node.$type ], node);
|
194
|
+
|
195
|
+
return allowedVersion && greaterOrEqual(version, allowedVersion);
|
196
|
+
}
|
197
|
+
|
198
|
+
function isTaskDefinitionAllowed(node, version) {
|
199
|
+
const { taskDefinition } = config;
|
200
|
+
|
201
|
+
const allowedVersion = getAllowedVersion(taskDefinition[ node.$type ], node);
|
202
|
+
|
203
|
+
return allowedVersion && greaterOrEqual(version, allowedVersion);
|
204
|
+
}
|
205
|
+
|
206
|
+
function getAllowedVersion(config, node) {
|
207
|
+
if (!config) {
|
208
|
+
return null;
|
209
|
+
}
|
210
|
+
|
211
|
+
if (isString(config)) {
|
212
|
+
return config;
|
213
|
+
}
|
214
|
+
|
215
|
+
const eventDefinition = getEventDefinition(node);
|
216
|
+
|
217
|
+
return eventDefinition && config[ eventDefinition.$type ];
|
218
|
+
}
|