bpmnlint-plugin-camunda-compat 2.23.0 → 2.24.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 +242 -237
- package/package.json +53 -53
- package/rules/camunda-cloud/called-element.js +42 -42
- 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 +66 -66
- package/rules/camunda-cloud/element-type/index.js +133 -133
- package/rules/camunda-cloud/error-reference.js +71 -71
- package/rules/camunda-cloud/escalation-boundary-event-attached-to-ref.js +48 -48
- package/rules/camunda-cloud/escalation-reference.js +66 -66
- 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 +34 -34
- package/rules/camunda-cloud/feel.js +82 -82
- package/rules/camunda-cloud/implementation/config.js +16 -16
- 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 +60 -60
- 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 +19 -0
- 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-schedule.js +18 -18
- package/rules/camunda-cloud/no-template.js +23 -23
- 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 +62 -0
- 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-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-platform/history-time-to-live.js +19 -19
- package/rules/utils/cron.js +95 -95
- package/rules/utils/element.js +533 -533
- package/rules/utils/error-types.js +25 -25
- 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,48 +1,48 @@
|
|
1
|
-
const {
|
2
|
-
is,
|
3
|
-
isAny
|
4
|
-
} = require('bpmnlint-utils');
|
5
|
-
|
6
|
-
const {
|
7
|
-
getEventDefinition,
|
8
|
-
isAnyExactly
|
9
|
-
} = require('../utils/element');
|
10
|
-
|
11
|
-
const { ERROR_TYPES } = require('../utils/error-types');
|
12
|
-
|
13
|
-
const { reportErrors } = require('../utils/reporter');
|
14
|
-
|
15
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
16
|
-
|
17
|
-
module.exports = skipInNonExecutableProcess(function() {
|
18
|
-
function check(node, reporter) {
|
19
|
-
if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
|
20
|
-
return;
|
21
|
-
}
|
22
|
-
|
23
|
-
const eventDefinition = getEventDefinition(node);
|
24
|
-
|
25
|
-
if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
|
29
|
-
const attachedToRef = node.get('attachedToRef');
|
30
|
-
|
31
|
-
if (attachedToRef && !isAnyExactly(attachedToRef, [ 'bpmn:CallActivity', 'bpmn:SubProcess' ])) {
|
32
|
-
reportErrors(node, reporter, {
|
33
|
-
message: `Element of type <bpmn:BoundaryEvent> with event definition of type <bpmn:EscalationEventDefinition> is not allowed to be attached to element of type <${ attachedToRef.$type }>`,
|
34
|
-
path: null,
|
35
|
-
data: {
|
36
|
-
type: ERROR_TYPES.ATTACHED_TO_REF_ELEMENT_TYPE_NOT_ALLOWED,
|
37
|
-
node,
|
38
|
-
parentNode: null,
|
39
|
-
attachedToRef
|
40
|
-
}
|
41
|
-
});
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
return {
|
46
|
-
check
|
47
|
-
};
|
48
|
-
});
|
1
|
+
const {
|
2
|
+
is,
|
3
|
+
isAny
|
4
|
+
} = require('bpmnlint-utils');
|
5
|
+
|
6
|
+
const {
|
7
|
+
getEventDefinition,
|
8
|
+
isAnyExactly
|
9
|
+
} = require('../utils/element');
|
10
|
+
|
11
|
+
const { ERROR_TYPES } = require('../utils/error-types');
|
12
|
+
|
13
|
+
const { reportErrors } = require('../utils/reporter');
|
14
|
+
|
15
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
16
|
+
|
17
|
+
module.exports = skipInNonExecutableProcess(function() {
|
18
|
+
function check(node, reporter) {
|
19
|
+
if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
|
23
|
+
const eventDefinition = getEventDefinition(node);
|
24
|
+
|
25
|
+
if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
|
29
|
+
const attachedToRef = node.get('attachedToRef');
|
30
|
+
|
31
|
+
if (attachedToRef && !isAnyExactly(attachedToRef, [ 'bpmn:CallActivity', 'bpmn:SubProcess' ])) {
|
32
|
+
reportErrors(node, reporter, {
|
33
|
+
message: `Element of type <bpmn:BoundaryEvent> with event definition of type <bpmn:EscalationEventDefinition> is not allowed to be attached to element of type <${ attachedToRef.$type }>`,
|
34
|
+
path: null,
|
35
|
+
data: {
|
36
|
+
type: ERROR_TYPES.ATTACHED_TO_REF_ELEMENT_TYPE_NOT_ALLOWED,
|
37
|
+
node,
|
38
|
+
parentNode: null,
|
39
|
+
attachedToRef
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
return {
|
46
|
+
check
|
47
|
+
};
|
48
|
+
});
|
@@ -1,67 +1,67 @@
|
|
1
|
-
const {
|
2
|
-
is,
|
3
|
-
isAny
|
4
|
-
} = require('bpmnlint-utils');
|
5
|
-
|
6
|
-
const {
|
7
|
-
getEventDefinition,
|
8
|
-
hasProperties
|
9
|
-
} = require('../utils/element');
|
10
|
-
|
11
|
-
const { reportErrors } = require('../utils/reporter');
|
12
|
-
|
13
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
14
|
-
|
15
|
-
module.exports = skipInNonExecutableProcess(function() {
|
16
|
-
function check(node, reporter) {
|
17
|
-
if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
|
21
|
-
const eventDefinition = getEventDefinition(node);
|
22
|
-
|
23
|
-
if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
|
27
|
-
let errors = [];
|
28
|
-
|
29
|
-
if (!isNoEscalationRefAllowed(node)) {
|
30
|
-
errors = hasProperties(eventDefinition, {
|
31
|
-
escalationRef: {
|
32
|
-
required: true
|
33
|
-
}
|
34
|
-
}, node);
|
35
|
-
|
36
|
-
if (errors.length) {
|
37
|
-
reportErrors(node, reporter, errors);
|
38
|
-
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
const escalationRef = eventDefinition.get('escalationRef');
|
44
|
-
|
45
|
-
if (!escalationRef) {
|
46
|
-
return;
|
47
|
-
}
|
48
|
-
|
49
|
-
errors = hasProperties(escalationRef, {
|
50
|
-
escalationCode: {
|
51
|
-
required: true
|
52
|
-
}
|
53
|
-
}, node);
|
54
|
-
|
55
|
-
if (errors.length) {
|
56
|
-
reportErrors(node, reporter, errors);
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
return {
|
61
|
-
check
|
62
|
-
};
|
63
|
-
});
|
64
|
-
|
65
|
-
function isNoEscalationRefAllowed(node) {
|
66
|
-
return isAny(node, [ 'bpmn:CatchEvent', 'bpmn:BoundaryEvent' ]);
|
1
|
+
const {
|
2
|
+
is,
|
3
|
+
isAny
|
4
|
+
} = require('bpmnlint-utils');
|
5
|
+
|
6
|
+
const {
|
7
|
+
getEventDefinition,
|
8
|
+
hasProperties
|
9
|
+
} = require('../utils/element');
|
10
|
+
|
11
|
+
const { reportErrors } = require('../utils/reporter');
|
12
|
+
|
13
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
14
|
+
|
15
|
+
module.exports = skipInNonExecutableProcess(function() {
|
16
|
+
function check(node, reporter) {
|
17
|
+
if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
|
21
|
+
const eventDefinition = getEventDefinition(node);
|
22
|
+
|
23
|
+
if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
|
27
|
+
let errors = [];
|
28
|
+
|
29
|
+
if (!isNoEscalationRefAllowed(node)) {
|
30
|
+
errors = hasProperties(eventDefinition, {
|
31
|
+
escalationRef: {
|
32
|
+
required: true
|
33
|
+
}
|
34
|
+
}, node);
|
35
|
+
|
36
|
+
if (errors.length) {
|
37
|
+
reportErrors(node, reporter, errors);
|
38
|
+
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
const escalationRef = eventDefinition.get('escalationRef');
|
44
|
+
|
45
|
+
if (!escalationRef) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
49
|
+
errors = hasProperties(escalationRef, {
|
50
|
+
escalationCode: {
|
51
|
+
required: true
|
52
|
+
}
|
53
|
+
}, node);
|
54
|
+
|
55
|
+
if (errors.length) {
|
56
|
+
reportErrors(node, reporter, errors);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
return {
|
61
|
+
check
|
62
|
+
};
|
63
|
+
});
|
64
|
+
|
65
|
+
function isNoEscalationRefAllowed(node) {
|
66
|
+
return isAny(node, [ 'bpmn:CatchEvent', 'bpmn:BoundaryEvent' ]);
|
67
67
|
}
|
@@ -1,39 +1,39 @@
|
|
1
|
-
const { is } = require('bpmnlint-utils');
|
2
|
-
|
3
|
-
const { ERROR_TYPES } = require('../utils/element');
|
4
|
-
|
5
|
-
const { reportErrors } = require('../utils/reporter');
|
6
|
-
|
7
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
8
|
-
|
9
|
-
module.exports = skipInNonExecutableProcess(function() {
|
10
|
-
function check(node, reporter) {
|
11
|
-
if (!is(node, 'bpmn:ReceiveTask')) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
|
15
|
-
// receive task as event-based gateway target is allowed by BPMN 2.0 but not
|
16
|
-
// supported by Zeebe
|
17
|
-
const error = node.get('incoming').some((sequenceFlow) => {
|
18
|
-
const source = sequenceFlow.get('sourceRef');
|
19
|
-
|
20
|
-
return is(source, 'bpmn:EventBasedGateway');
|
21
|
-
});
|
22
|
-
|
23
|
-
if (error) {
|
24
|
-
reportErrors(node, reporter, {
|
25
|
-
message: 'Element of type <bpmn:ReceiveTask> not allowed as event-based gateway target',
|
26
|
-
path: null,
|
27
|
-
data: {
|
28
|
-
type: ERROR_TYPES.EVENT_BASED_GATEWAY_TARGET_NOT_ALLOWED,
|
29
|
-
node,
|
30
|
-
parentNode: null
|
31
|
-
}
|
32
|
-
});
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
return {
|
37
|
-
check
|
38
|
-
};
|
1
|
+
const { is } = require('bpmnlint-utils');
|
2
|
+
|
3
|
+
const { ERROR_TYPES } = require('../utils/element');
|
4
|
+
|
5
|
+
const { reportErrors } = require('../utils/reporter');
|
6
|
+
|
7
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
8
|
+
|
9
|
+
module.exports = skipInNonExecutableProcess(function() {
|
10
|
+
function check(node, reporter) {
|
11
|
+
if (!is(node, 'bpmn:ReceiveTask')) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
|
15
|
+
// receive task as event-based gateway target is allowed by BPMN 2.0 but not
|
16
|
+
// supported by Zeebe
|
17
|
+
const error = node.get('incoming').some((sequenceFlow) => {
|
18
|
+
const source = sequenceFlow.get('sourceRef');
|
19
|
+
|
20
|
+
return is(source, 'bpmn:EventBasedGateway');
|
21
|
+
});
|
22
|
+
|
23
|
+
if (error) {
|
24
|
+
reportErrors(node, reporter, {
|
25
|
+
message: 'Element of type <bpmn:ReceiveTask> not allowed as event-based gateway target',
|
26
|
+
path: null,
|
27
|
+
data: {
|
28
|
+
type: ERROR_TYPES.EVENT_BASED_GATEWAY_TARGET_NOT_ALLOWED,
|
29
|
+
node,
|
30
|
+
parentNode: null
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
return {
|
37
|
+
check
|
38
|
+
};
|
39
39
|
});
|
@@ -1,62 +1,62 @@
|
|
1
|
-
const { is } = require('bpmnlint-utils');
|
2
|
-
|
3
|
-
const { hasProperties } = require('../utils/element');
|
4
|
-
|
5
|
-
const { reportErrors } = require('../utils/reporter');
|
6
|
-
|
7
|
-
module.exports = function() {
|
8
|
-
function check(node, reporter) {
|
9
|
-
if (!is(node, 'bpmn:Definitions')) {
|
10
|
-
return;
|
11
|
-
}
|
12
|
-
|
13
|
-
const rootElements = node.get('rootElements'),
|
14
|
-
collaboration = rootElements.find(rootElement => is(rootElement, 'bpmn:Collaboration')),
|
15
|
-
processes = rootElements.filter(rootElement => is(rootElement, 'bpmn:Process'));
|
16
|
-
|
17
|
-
let errors = [];
|
18
|
-
|
19
|
-
for (const process of processes) {
|
20
|
-
const parentNode = getParentNode(process, collaboration);
|
21
|
-
|
22
|
-
errors = [
|
23
|
-
...errors,
|
24
|
-
...hasProperties(process, {
|
25
|
-
isExecutable: {
|
26
|
-
value: true
|
27
|
-
}
|
28
|
-
}, parentNode)
|
29
|
-
];
|
30
|
-
}
|
31
|
-
|
32
|
-
if (errors.length > processes.length - 1) {
|
33
|
-
errors.forEach(error => {
|
34
|
-
const { data } = error;
|
35
|
-
|
36
|
-
const { node: process } = data;
|
37
|
-
|
38
|
-
reportErrors(getParentNode(process, collaboration), reporter, error);
|
39
|
-
});
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
return {
|
44
|
-
check
|
45
|
-
};
|
46
|
-
};
|
47
|
-
|
48
|
-
function getParentNode(process, collaboration) {
|
49
|
-
if (!collaboration) {
|
50
|
-
return process;
|
51
|
-
}
|
52
|
-
|
53
|
-
const participants = collaboration.get('participants');
|
54
|
-
|
55
|
-
const participant = participants.find(participant => participant.get('processRef') === process);
|
56
|
-
|
57
|
-
if (participant) {
|
58
|
-
return participant;
|
59
|
-
}
|
60
|
-
|
61
|
-
return process;
|
1
|
+
const { is } = require('bpmnlint-utils');
|
2
|
+
|
3
|
+
const { hasProperties } = require('../utils/element');
|
4
|
+
|
5
|
+
const { reportErrors } = require('../utils/reporter');
|
6
|
+
|
7
|
+
module.exports = function() {
|
8
|
+
function check(node, reporter) {
|
9
|
+
if (!is(node, 'bpmn:Definitions')) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
|
13
|
+
const rootElements = node.get('rootElements'),
|
14
|
+
collaboration = rootElements.find(rootElement => is(rootElement, 'bpmn:Collaboration')),
|
15
|
+
processes = rootElements.filter(rootElement => is(rootElement, 'bpmn:Process'));
|
16
|
+
|
17
|
+
let errors = [];
|
18
|
+
|
19
|
+
for (const process of processes) {
|
20
|
+
const parentNode = getParentNode(process, collaboration);
|
21
|
+
|
22
|
+
errors = [
|
23
|
+
...errors,
|
24
|
+
...hasProperties(process, {
|
25
|
+
isExecutable: {
|
26
|
+
value: true
|
27
|
+
}
|
28
|
+
}, parentNode)
|
29
|
+
];
|
30
|
+
}
|
31
|
+
|
32
|
+
if (errors.length > processes.length - 1) {
|
33
|
+
errors.forEach(error => {
|
34
|
+
const { data } = error;
|
35
|
+
|
36
|
+
const { node: process } = data;
|
37
|
+
|
38
|
+
reportErrors(getParentNode(process, collaboration), reporter, error);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
return {
|
44
|
+
check
|
45
|
+
};
|
46
|
+
};
|
47
|
+
|
48
|
+
function getParentNode(process, collaboration) {
|
49
|
+
if (!collaboration) {
|
50
|
+
return process;
|
51
|
+
}
|
52
|
+
|
53
|
+
const participants = collaboration.get('participants');
|
54
|
+
|
55
|
+
const participant = participants.find(participant => participant.get('processRef') === process);
|
56
|
+
|
57
|
+
if (participant) {
|
58
|
+
return participant;
|
59
|
+
}
|
60
|
+
|
61
|
+
return process;
|
62
62
|
}
|
@@ -1,34 +1,34 @@
|
|
1
|
-
const {
|
2
|
-
findExtensionElement,
|
3
|
-
hasProperties
|
4
|
-
} = require('../utils/element');
|
5
|
-
|
6
|
-
const { reportErrors } = require('../utils/reporter');
|
7
|
-
|
8
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
9
|
-
|
10
|
-
|
11
|
-
module.exports = skipInNonExecutableProcess(function() {
|
12
|
-
function check(node, reporter) {
|
13
|
-
const executionListeners = findExtensionElement(node, 'zeebe:ExecutionListeners');
|
14
|
-
|
15
|
-
if (!executionListeners) {
|
16
|
-
return;
|
17
|
-
}
|
18
|
-
|
19
|
-
const listeners = executionListeners.get('listeners');
|
20
|
-
const errors = listeners.flatMap(listener => hasProperties(listener, {
|
21
|
-
type: {
|
22
|
-
required: true
|
23
|
-
}
|
24
|
-
}, node));
|
25
|
-
|
26
|
-
if (errors.length) {
|
27
|
-
reportErrors(node, reporter, errors);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
return {
|
32
|
-
check
|
33
|
-
};
|
34
|
-
});
|
1
|
+
const {
|
2
|
+
findExtensionElement,
|
3
|
+
hasProperties
|
4
|
+
} = require('../utils/element');
|
5
|
+
|
6
|
+
const { reportErrors } = require('../utils/reporter');
|
7
|
+
|
8
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
9
|
+
|
10
|
+
|
11
|
+
module.exports = skipInNonExecutableProcess(function() {
|
12
|
+
function check(node, reporter) {
|
13
|
+
const executionListeners = findExtensionElement(node, 'zeebe:ExecutionListeners');
|
14
|
+
|
15
|
+
if (!executionListeners) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
const listeners = executionListeners.get('listeners');
|
20
|
+
const errors = listeners.flatMap(listener => hasProperties(listener, {
|
21
|
+
type: {
|
22
|
+
required: true
|
23
|
+
}
|
24
|
+
}, node));
|
25
|
+
|
26
|
+
if (errors.length) {
|
27
|
+
reportErrors(node, reporter, errors);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
return {
|
32
|
+
check
|
33
|
+
};
|
34
|
+
});
|
@@ -1,83 +1,83 @@
|
|
1
|
-
const { isString } = require('min-dash');
|
2
|
-
|
3
|
-
const { is } = require('bpmnlint-utils');
|
4
|
-
|
5
|
-
const { lintExpression } = require('@bpmn-io/feel-lint');
|
6
|
-
|
7
|
-
const { getPath } = require('@bpmn-io/moddle-utils');
|
8
|
-
|
9
|
-
const { reportErrors } = require('../utils/reporter');
|
10
|
-
|
11
|
-
const { ERROR_TYPES } = require('../utils/error-types');
|
12
|
-
|
13
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
14
|
-
|
15
|
-
module.exports = skipInNonExecutableProcess(function() {
|
16
|
-
function check(node, reporter) {
|
17
|
-
if (is(node, 'bpmn:Expression')) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
|
21
|
-
const parentNode = findFlowElement(node);
|
22
|
-
|
23
|
-
if (!parentNode) {
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
|
27
|
-
const errors = [];
|
28
|
-
|
29
|
-
Object.entries(node).forEach(([ propertyName, propertyValue ]) => {
|
30
|
-
if (propertyValue && is(propertyValue, 'bpmn:Expression')) {
|
31
|
-
propertyValue = propertyValue.get('body');
|
32
|
-
}
|
33
|
-
|
34
|
-
if (isFeelProperty([ propertyName, propertyValue ])) {
|
35
|
-
const lintErrors = lintExpression(propertyValue.substring(1));
|
36
|
-
|
37
|
-
// syntax error
|
38
|
-
if (lintErrors.find(({ type }) => type === 'Syntax Error')) {
|
39
|
-
const path = getPath(node, parentNode);
|
40
|
-
|
41
|
-
errors.push(
|
42
|
-
{
|
43
|
-
message: `Property <${ propertyName }> is not a valid FEEL expression`,
|
44
|
-
path: path
|
45
|
-
? [ ...path, propertyName ]
|
46
|
-
: [ propertyName ],
|
47
|
-
data: {
|
48
|
-
type: ERROR_TYPES.FEEL_EXPRESSION_INVALID,
|
49
|
-
node,
|
50
|
-
parentNode,
|
51
|
-
property: propertyName
|
52
|
-
}
|
53
|
-
}
|
54
|
-
);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
});
|
58
|
-
|
59
|
-
if (errors && errors.length) {
|
60
|
-
reportErrors(parentNode, reporter, errors);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
return {
|
65
|
-
check
|
66
|
-
};
|
67
|
-
});
|
68
|
-
|
69
|
-
const isFeelProperty = ([ propertyName, value ]) => {
|
70
|
-
return !isIgnoredProperty(propertyName) && isString(value) && value.startsWith('=');
|
71
|
-
};
|
72
|
-
|
73
|
-
const isIgnoredProperty = propertyName => {
|
74
|
-
return propertyName.startsWith('$');
|
75
|
-
};
|
76
|
-
|
77
|
-
const findFlowElement = node => {
|
78
|
-
while (node && !is(node, 'bpmn:FlowElement')) {
|
79
|
-
node = node.$parent;
|
80
|
-
}
|
81
|
-
|
82
|
-
return node;
|
1
|
+
const { isString } = require('min-dash');
|
2
|
+
|
3
|
+
const { is } = require('bpmnlint-utils');
|
4
|
+
|
5
|
+
const { lintExpression } = require('@bpmn-io/feel-lint');
|
6
|
+
|
7
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
8
|
+
|
9
|
+
const { reportErrors } = require('../utils/reporter');
|
10
|
+
|
11
|
+
const { ERROR_TYPES } = require('../utils/error-types');
|
12
|
+
|
13
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
14
|
+
|
15
|
+
module.exports = skipInNonExecutableProcess(function() {
|
16
|
+
function check(node, reporter) {
|
17
|
+
if (is(node, 'bpmn:Expression')) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
|
21
|
+
const parentNode = findFlowElement(node);
|
22
|
+
|
23
|
+
if (!parentNode) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
|
27
|
+
const errors = [];
|
28
|
+
|
29
|
+
Object.entries(node).forEach(([ propertyName, propertyValue ]) => {
|
30
|
+
if (propertyValue && is(propertyValue, 'bpmn:Expression')) {
|
31
|
+
propertyValue = propertyValue.get('body');
|
32
|
+
}
|
33
|
+
|
34
|
+
if (isFeelProperty([ propertyName, propertyValue ])) {
|
35
|
+
const lintErrors = lintExpression(propertyValue.substring(1));
|
36
|
+
|
37
|
+
// syntax error
|
38
|
+
if (lintErrors.find(({ type }) => type === 'Syntax Error')) {
|
39
|
+
const path = getPath(node, parentNode);
|
40
|
+
|
41
|
+
errors.push(
|
42
|
+
{
|
43
|
+
message: `Property <${ propertyName }> is not a valid FEEL expression`,
|
44
|
+
path: path
|
45
|
+
? [ ...path, propertyName ]
|
46
|
+
: [ propertyName ],
|
47
|
+
data: {
|
48
|
+
type: ERROR_TYPES.FEEL_EXPRESSION_INVALID,
|
49
|
+
node,
|
50
|
+
parentNode,
|
51
|
+
property: propertyName
|
52
|
+
}
|
53
|
+
}
|
54
|
+
);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
});
|
58
|
+
|
59
|
+
if (errors && errors.length) {
|
60
|
+
reportErrors(parentNode, reporter, errors);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
return {
|
65
|
+
check
|
66
|
+
};
|
67
|
+
});
|
68
|
+
|
69
|
+
const isFeelProperty = ([ propertyName, value ]) => {
|
70
|
+
return !isIgnoredProperty(propertyName) && isString(value) && value.startsWith('=');
|
71
|
+
};
|
72
|
+
|
73
|
+
const isIgnoredProperty = propertyName => {
|
74
|
+
return propertyName.startsWith('$');
|
75
|
+
};
|
76
|
+
|
77
|
+
const findFlowElement = node => {
|
78
|
+
while (node && !is(node, 'bpmn:FlowElement')) {
|
79
|
+
node = node.$parent;
|
80
|
+
}
|
81
|
+
|
82
|
+
return node;
|
83
83
|
};
|