bpmnlint-plugin-camunda-compat 2.12.0 → 2.13.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,178 +1,179 @@
|
|
1
|
-
const { omit } = require('min-dash');
|
2
|
-
|
3
|
-
const camundaCloud10Rules = withConfig({
|
4
|
-
'implementation': 'error',
|
5
|
-
'called-element': 'error',
|
6
|
-
'collapsed-subprocess': 'error',
|
7
|
-
'duplicate-task-headers': 'error',
|
8
|
-
'element-type': 'error',
|
9
|
-
'error-reference': 'error',
|
10
|
-
'event-based-gateway-target': 'error',
|
11
|
-
'executable-process': 'error',
|
12
|
-
'loop-characteristics': 'error',
|
13
|
-
'message-reference': 'error',
|
14
|
-
'no-candidate-users': 'error',
|
15
|
-
'no-expression': 'error',
|
16
|
-
'no-loop': 'error',
|
17
|
-
'no-multiple-none-start-events': 'error',
|
18
|
-
'no-propagate-all-parent-variables': 'error',
|
19
|
-
'no-task-schedule': 'error',
|
20
|
-
'no-template': 'error',
|
21
|
-
'no-zeebe-properties': 'error',
|
22
|
-
'sequence-flow-condition': 'error',
|
23
|
-
'start-event-form': 'error',
|
24
|
-
'subscription': 'error',
|
25
|
-
'timer': 'error',
|
26
|
-
'user-task-form': 'error',
|
27
|
-
'feel': 'error'
|
28
|
-
}, { version: '1.0' });
|
29
|
-
|
30
|
-
const camundaCloud11Rules = withConfig(camundaCloud10Rules, { version: '1.1' });
|
31
|
-
|
32
|
-
const camundaCloud12Rules = withConfig(camundaCloud11Rules, { version: '1.2' });
|
33
|
-
|
34
|
-
const camundaCloud13Rules = withConfig(camundaCloud12Rules, { version: '1.3' });
|
35
|
-
|
36
|
-
const camundaCloud80Rules = withConfig({
|
37
|
-
...omit(camundaCloud13Rules, 'no-template'),
|
38
|
-
}, { version: '8.0' });
|
39
|
-
|
40
|
-
const camundaCloud81Rules = withConfig({
|
41
|
-
...omit(camundaCloud80Rules, 'no-zeebe-properties'),
|
42
|
-
'inclusive-gateway': 'error'
|
43
|
-
}, { version: '8.1' });
|
44
|
-
|
45
|
-
const camundaCloud82Rules = withConfig({
|
46
|
-
...omit(camundaCloud81Rules, [
|
47
|
-
'no-candidate-users',
|
48
|
-
'no-propagate-all-parent-variables',
|
49
|
-
'no-task-schedule'
|
50
|
-
]),
|
51
|
-
'escalation-boundary-event-attached-to-ref': 'error',
|
52
|
-
'escalation-reference': 'error',
|
53
|
-
'link-event': 'error',
|
54
|
-
'no-signal-event-sub-process': 'error',
|
55
|
-
'task-schedule': 'error'
|
56
|
-
}, { version: '8.2' });
|
57
|
-
|
58
|
-
const camundaCloud83Rules = withConfig({
|
59
|
-
...omit(camundaCloud82Rules, 'no-signal-event-sub-process'),
|
60
|
-
'secrets': 'warn',
|
61
|
-
'signal-reference': 'error'
|
62
|
-
}, { version: '8.3' });
|
63
|
-
|
64
|
-
const camundaCloud84Rules = withConfig(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
'
|
86
|
-
'
|
87
|
-
'
|
88
|
-
'
|
89
|
-
'
|
90
|
-
'escalation-
|
91
|
-
'
|
92
|
-
'
|
93
|
-
'
|
94
|
-
'
|
95
|
-
'
|
96
|
-
'
|
97
|
-
'
|
98
|
-
'
|
99
|
-
'
|
100
|
-
'
|
101
|
-
'no-
|
102
|
-
'no-
|
103
|
-
'no-
|
104
|
-
'no-
|
105
|
-
'no-
|
106
|
-
'no-
|
107
|
-
'no-
|
108
|
-
'no-
|
109
|
-
'
|
110
|
-
'
|
111
|
-
'
|
112
|
-
'
|
113
|
-
'
|
114
|
-
'
|
115
|
-
'
|
116
|
-
'
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
1
|
+
const { omit } = require('min-dash');
|
2
|
+
|
3
|
+
const camundaCloud10Rules = withConfig({
|
4
|
+
'implementation': 'error',
|
5
|
+
'called-element': 'error',
|
6
|
+
'collapsed-subprocess': 'error',
|
7
|
+
'duplicate-task-headers': 'error',
|
8
|
+
'element-type': 'error',
|
9
|
+
'error-reference': 'error',
|
10
|
+
'event-based-gateway-target': 'error',
|
11
|
+
'executable-process': 'error',
|
12
|
+
'loop-characteristics': 'error',
|
13
|
+
'message-reference': 'error',
|
14
|
+
'no-candidate-users': 'error',
|
15
|
+
'no-expression': 'error',
|
16
|
+
'no-loop': 'error',
|
17
|
+
'no-multiple-none-start-events': 'error',
|
18
|
+
'no-propagate-all-parent-variables': 'error',
|
19
|
+
'no-task-schedule': 'error',
|
20
|
+
'no-template': 'error',
|
21
|
+
'no-zeebe-properties': 'error',
|
22
|
+
'sequence-flow-condition': 'error',
|
23
|
+
'start-event-form': 'error',
|
24
|
+
'subscription': 'error',
|
25
|
+
'timer': 'error',
|
26
|
+
'user-task-form': 'error',
|
27
|
+
'feel': 'error'
|
28
|
+
}, { version: '1.0' });
|
29
|
+
|
30
|
+
const camundaCloud11Rules = withConfig(camundaCloud10Rules, { version: '1.1' });
|
31
|
+
|
32
|
+
const camundaCloud12Rules = withConfig(camundaCloud11Rules, { version: '1.2' });
|
33
|
+
|
34
|
+
const camundaCloud13Rules = withConfig(camundaCloud12Rules, { version: '1.3' });
|
35
|
+
|
36
|
+
const camundaCloud80Rules = withConfig({
|
37
|
+
...omit(camundaCloud13Rules, 'no-template'),
|
38
|
+
}, { version: '8.0' });
|
39
|
+
|
40
|
+
const camundaCloud81Rules = withConfig({
|
41
|
+
...omit(camundaCloud80Rules, 'no-zeebe-properties'),
|
42
|
+
'inclusive-gateway': 'error'
|
43
|
+
}, { version: '8.1' });
|
44
|
+
|
45
|
+
const camundaCloud82Rules = withConfig({
|
46
|
+
...omit(camundaCloud81Rules, [
|
47
|
+
'no-candidate-users',
|
48
|
+
'no-propagate-all-parent-variables',
|
49
|
+
'no-task-schedule'
|
50
|
+
]),
|
51
|
+
'escalation-boundary-event-attached-to-ref': 'error',
|
52
|
+
'escalation-reference': 'error',
|
53
|
+
'link-event': 'error',
|
54
|
+
'no-signal-event-sub-process': 'error',
|
55
|
+
'task-schedule': 'error'
|
56
|
+
}, { version: '8.2' });
|
57
|
+
|
58
|
+
const camundaCloud83Rules = withConfig({
|
59
|
+
...omit(camundaCloud82Rules, 'no-signal-event-sub-process'),
|
60
|
+
'secrets': 'warn',
|
61
|
+
'signal-reference': 'error'
|
62
|
+
}, { version: '8.3' });
|
63
|
+
|
64
|
+
const camundaCloud84Rules = withConfig(
|
65
|
+
omit(camundaCloud83Rules, 'collapsed-subprocess'), { version: '8.4' });
|
66
|
+
|
67
|
+
const camundaPlatform719Rules = withConfig({
|
68
|
+
'history-time-to-live': 'error'
|
69
|
+
}, {
|
70
|
+
platform: 'camunda-platform',
|
71
|
+
version: '7.19'
|
72
|
+
});
|
73
|
+
|
74
|
+
const camundaPlatform720Rules = withConfig(camundaPlatform719Rules, {
|
75
|
+
platform: 'camunda-platform',
|
76
|
+
version: '7.20'
|
77
|
+
});
|
78
|
+
|
79
|
+
const camundaPlatform721Rules = withConfig(camundaPlatform720Rules, {
|
80
|
+
platform: 'camunda-platform',
|
81
|
+
version: '7.21'
|
82
|
+
});
|
83
|
+
|
84
|
+
const rules = {
|
85
|
+
'element-type': './rules/camunda-cloud/element-type',
|
86
|
+
'called-element': './rules/camunda-cloud/called-element',
|
87
|
+
'collapsed-subprocess': './rules/camunda-cloud/collapsed-subprocess',
|
88
|
+
'duplicate-task-headers': './rules/camunda-cloud/duplicate-task-headers',
|
89
|
+
'error-reference': './rules/camunda-cloud/error-reference',
|
90
|
+
'escalation-boundary-event-attached-to-ref': './rules/camunda-cloud/escalation-boundary-event-attached-to-ref',
|
91
|
+
'escalation-reference': './rules/camunda-cloud/escalation-reference',
|
92
|
+
'event-based-gateway-target': './rules/camunda-cloud/event-based-gateway-target',
|
93
|
+
'executable-process': './rules/camunda-cloud/executable-process',
|
94
|
+
'feel': './rules/camunda-cloud/feel',
|
95
|
+
'history-time-to-live': './rules/camunda-platform/history-time-to-live',
|
96
|
+
'implementation': './rules/camunda-cloud/implementation',
|
97
|
+
'inclusive-gateway': './rules/camunda-cloud/inclusive-gateway',
|
98
|
+
'link-event': './rules/camunda-cloud/link-event',
|
99
|
+
'loop-characteristics': './rules/camunda-cloud/loop-characteristics',
|
100
|
+
'message-reference': './rules/camunda-cloud/message-reference',
|
101
|
+
'no-candidate-users': './rules/camunda-cloud/no-candidate-users',
|
102
|
+
'no-expression': './rules/camunda-cloud/no-expression',
|
103
|
+
'no-loop': './rules/camunda-cloud/no-loop',
|
104
|
+
'no-multiple-none-start-events': './rules/camunda-cloud/no-multiple-none-start-events',
|
105
|
+
'no-propagate-all-parent-variables': './rules/camunda-cloud/no-propagate-all-parent-variables',
|
106
|
+
'no-signal-event-sub-process': './rules/camunda-cloud/no-signal-event-sub-process',
|
107
|
+
'no-task-schedule': './rules/camunda-cloud/no-task-schedule',
|
108
|
+
'no-template': './rules/camunda-cloud/no-template',
|
109
|
+
'no-zeebe-properties': './rules/camunda-cloud/no-zeebe-properties',
|
110
|
+
'secrets': './rules/camunda-cloud/secrets',
|
111
|
+
'sequence-flow-condition': './rules/camunda-cloud/sequence-flow-condition',
|
112
|
+
'signal-reference': './rules/camunda-cloud/signal-reference',
|
113
|
+
'start-event-form': './rules/camunda-cloud/start-event-form',
|
114
|
+
'subscription': './rules/camunda-cloud/subscription',
|
115
|
+
'task-schedule': './rules/camunda-cloud/task-schedule',
|
116
|
+
'timer': './rules/camunda-cloud/timer',
|
117
|
+
'user-task-form': './rules/camunda-cloud/user-task-form'
|
118
|
+
};
|
119
|
+
|
120
|
+
module.exports = {
|
121
|
+
configs: {
|
122
|
+
'camunda-cloud-1-0': {
|
123
|
+
rules: camundaCloud10Rules
|
124
|
+
},
|
125
|
+
'camunda-cloud-1-1': {
|
126
|
+
rules: camundaCloud11Rules
|
127
|
+
},
|
128
|
+
'camunda-cloud-1-2': {
|
129
|
+
rules: camundaCloud12Rules
|
130
|
+
},
|
131
|
+
'camunda-cloud-1-3': {
|
132
|
+
rules: camundaCloud13Rules
|
133
|
+
},
|
134
|
+
'camunda-cloud-8-0': {
|
135
|
+
rules: camundaCloud80Rules
|
136
|
+
},
|
137
|
+
'camunda-cloud-8-1': {
|
138
|
+
rules: camundaCloud81Rules
|
139
|
+
},
|
140
|
+
'camunda-cloud-8-2': {
|
141
|
+
rules: camundaCloud82Rules
|
142
|
+
},
|
143
|
+
'camunda-cloud-8-3': {
|
144
|
+
rules: camundaCloud83Rules
|
145
|
+
},
|
146
|
+
'camunda-cloud-8-4': {
|
147
|
+
rules: camundaCloud84Rules
|
148
|
+
},
|
149
|
+
'camunda-platform-7-19': {
|
150
|
+
rules: camundaPlatform719Rules
|
151
|
+
},
|
152
|
+
'camunda-platform-7-20': {
|
153
|
+
rules: camundaPlatform720Rules
|
154
|
+
},
|
155
|
+
'camunda-platform-7-21': {
|
156
|
+
rules: camundaPlatform721Rules
|
157
|
+
},
|
158
|
+
'all': {
|
159
|
+
rules: Object.keys(rules).reduce((allRules, rule) => {
|
160
|
+
return {
|
161
|
+
...allRules,
|
162
|
+
[ rule ]: 'error'
|
163
|
+
};
|
164
|
+
}, {})
|
165
|
+
}
|
166
|
+
},
|
167
|
+
rules
|
168
|
+
};
|
169
|
+
|
170
|
+
function withConfig(rules, config) {
|
171
|
+
let rulesWithConfig = {};
|
172
|
+
|
173
|
+
for (let name in rules) {
|
174
|
+
const type = Array.isArray(rules[ name ]) ? rules[ name ][0] : rules[ name ];
|
175
|
+
rulesWithConfig[ name ] = [ type, config ];
|
176
|
+
}
|
177
|
+
|
178
|
+
return rulesWithConfig;
|
178
179
|
}
|
package/package.json
CHANGED
@@ -1,98 +1,98 @@
|
|
1
|
-
const { is } = require('bpmnlint-utils');
|
2
|
-
|
3
|
-
const {
|
4
|
-
findExtensionElement,
|
5
|
-
findExtensionElements,
|
6
|
-
findParent,
|
7
|
-
hasProperties,
|
8
|
-
hasProperty
|
9
|
-
} = require('../utils/element');
|
10
|
-
|
11
|
-
const { hasNoExtensionElement } = require('../utils/element');
|
12
|
-
|
13
|
-
const { reportErrors } = require('../utils/reporter');
|
14
|
-
|
15
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
16
|
-
|
17
|
-
const { greaterOrEqual } = require('../utils/version');
|
18
|
-
|
19
|
-
const allowedVersion = '8.3';
|
20
|
-
|
21
|
-
module.exports = skipInNonExecutableProcess(function({ version }) {
|
22
|
-
function check(node, reporter) {
|
23
|
-
if (!is(node, 'bpmn:StartEvent')) {
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
|
27
|
-
// Camunda 8.2 and older
|
28
|
-
if (!greaterOrEqual(version, allowedVersion)) {
|
29
|
-
let errors = hasNoExtensionElement(node, 'zeebe:FormDefinition', node, allowedVersion);
|
30
|
-
|
31
|
-
if (errors.length) {
|
32
|
-
reportErrors(node, reporter, errors);
|
33
|
-
}
|
34
|
-
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Camunda 8.3 and newer
|
39
|
-
const formDefinition = findExtensionElement(node, 'zeebe:FormDefinition');
|
40
|
-
|
41
|
-
if (!formDefinition) {
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
|
45
|
-
let errors = hasProperty(formDefinition, [
|
46
|
-
'formKey',
|
47
|
-
'formId'
|
48
|
-
], node);
|
49
|
-
|
50
|
-
if (errors.length) {
|
51
|
-
reportErrors(node, reporter, errors);
|
52
|
-
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
|
56
|
-
const formKey = formDefinition.get('formKey');
|
57
|
-
|
58
|
-
const userTaskForm = findUserTaskForm(node, formKey);
|
59
|
-
|
60
|
-
if (!userTaskForm) {
|
61
|
-
return;
|
62
|
-
}
|
63
|
-
|
64
|
-
errors = hasProperties(userTaskForm, {
|
65
|
-
body: {
|
66
|
-
required: true
|
67
|
-
}
|
68
|
-
}, node);
|
69
|
-
|
70
|
-
if (errors.length) {
|
71
|
-
reportErrors(node, reporter, errors);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
return {
|
76
|
-
check
|
77
|
-
};
|
78
|
-
});
|
79
|
-
|
80
|
-
// helpers //////////
|
81
|
-
|
82
|
-
function findUserTaskForm(node, formKey) {
|
83
|
-
const process = findParent(node, 'bpmn:Process');
|
84
|
-
|
85
|
-
if (!process) {
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
|
89
|
-
const userTaskForms = findExtensionElements(process, 'zeebe:UserTaskForm');
|
90
|
-
|
91
|
-
if (userTaskForms && userTaskForms.length) {
|
92
|
-
return userTaskForms.find(userTaskForm => {
|
93
|
-
const id = userTaskForm.get('id');
|
94
|
-
|
95
|
-
return `camunda-forms:bpmn:${ id }` === formKey;
|
96
|
-
});
|
97
|
-
}
|
1
|
+
const { is } = require('bpmnlint-utils');
|
2
|
+
|
3
|
+
const {
|
4
|
+
findExtensionElement,
|
5
|
+
findExtensionElements,
|
6
|
+
findParent,
|
7
|
+
hasProperties,
|
8
|
+
hasProperty
|
9
|
+
} = require('../utils/element');
|
10
|
+
|
11
|
+
const { hasNoExtensionElement } = require('../utils/element');
|
12
|
+
|
13
|
+
const { reportErrors } = require('../utils/reporter');
|
14
|
+
|
15
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
16
|
+
|
17
|
+
const { greaterOrEqual } = require('../utils/version');
|
18
|
+
|
19
|
+
const allowedVersion = '8.3';
|
20
|
+
|
21
|
+
module.exports = skipInNonExecutableProcess(function({ version }) {
|
22
|
+
function check(node, reporter) {
|
23
|
+
if (!is(node, 'bpmn:StartEvent')) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
|
27
|
+
// Camunda 8.2 and older
|
28
|
+
if (!greaterOrEqual(version, allowedVersion)) {
|
29
|
+
let errors = hasNoExtensionElement(node, 'zeebe:FormDefinition', node, allowedVersion);
|
30
|
+
|
31
|
+
if (errors.length) {
|
32
|
+
reportErrors(node, reporter, errors);
|
33
|
+
}
|
34
|
+
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Camunda 8.3 and newer
|
39
|
+
const formDefinition = findExtensionElement(node, 'zeebe:FormDefinition');
|
40
|
+
|
41
|
+
if (!formDefinition) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
let errors = hasProperty(formDefinition, [
|
46
|
+
'formKey',
|
47
|
+
'formId'
|
48
|
+
], node);
|
49
|
+
|
50
|
+
if (errors.length) {
|
51
|
+
reportErrors(node, reporter, errors);
|
52
|
+
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
const formKey = formDefinition.get('formKey');
|
57
|
+
|
58
|
+
const userTaskForm = findUserTaskForm(node, formKey);
|
59
|
+
|
60
|
+
if (!userTaskForm) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
errors = hasProperties(userTaskForm, {
|
65
|
+
body: {
|
66
|
+
required: true
|
67
|
+
}
|
68
|
+
}, node);
|
69
|
+
|
70
|
+
if (errors.length) {
|
71
|
+
reportErrors(node, reporter, errors);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
return {
|
76
|
+
check
|
77
|
+
};
|
78
|
+
});
|
79
|
+
|
80
|
+
// helpers //////////
|
81
|
+
|
82
|
+
function findUserTaskForm(node, formKey) {
|
83
|
+
const process = findParent(node, 'bpmn:Process');
|
84
|
+
|
85
|
+
if (!process) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
|
89
|
+
const userTaskForms = findExtensionElements(process, 'zeebe:UserTaskForm');
|
90
|
+
|
91
|
+
if (userTaskForms && userTaskForms.length) {
|
92
|
+
return userTaskForms.find(userTaskForm => {
|
93
|
+
const id = userTaskForm.get('id');
|
94
|
+
|
95
|
+
return `camunda-forms:bpmn:${ id }` === formKey;
|
96
|
+
});
|
97
|
+
}
|
98
98
|
}
|
@@ -1,116 +1,116 @@
|
|
1
|
-
const { is } = require('bpmnlint-utils');
|
2
|
-
|
3
|
-
const {
|
4
|
-
findExtensionElement,
|
5
|
-
findExtensionElements,
|
6
|
-
findParent,
|
7
|
-
hasProperties,
|
8
|
-
hasProperty
|
9
|
-
} = require('../utils/element');
|
10
|
-
|
11
|
-
const { reportErrors } = require('../utils/reporter');
|
12
|
-
|
13
|
-
const { skipInNonExecutableProcess } = require('../utils/rule');
|
14
|
-
|
15
|
-
const { greaterOrEqual } = require('../utils/version');
|
16
|
-
|
17
|
-
const formIdAllowedVersions = {
|
18
|
-
desktop: '8.4',
|
19
|
-
web: '8.0'
|
20
|
-
};
|
21
|
-
|
22
|
-
module.exports = skipInNonExecutableProcess(function({ modeler = 'desktop', version }) {
|
23
|
-
function check(node, reporter) {
|
24
|
-
if (!is(node, 'bpmn:UserTask')) {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
|
28
|
-
const formDefinition = findExtensionElement(node, 'zeebe:FormDefinition');
|
29
|
-
|
30
|
-
if (!formDefinition) {
|
31
|
-
return;
|
32
|
-
}
|
33
|
-
|
34
|
-
let errors = [];
|
35
|
-
|
36
|
-
const formIdAllowedVersion = formIdAllowedVersions[ modeler ];
|
37
|
-
|
38
|
-
if (isFormIdAllowed(version, formIdAllowedVersion)) {
|
39
|
-
errors = hasProperty(formDefinition, [
|
40
|
-
'formKey',
|
41
|
-
'formId'
|
42
|
-
], node);
|
43
|
-
} else {
|
44
|
-
errors = hasProperties(formDefinition, {
|
45
|
-
formId: {
|
46
|
-
allowed: false,
|
47
|
-
allowedVersion: formIdAllowedVersion
|
48
|
-
}
|
49
|
-
}, node);
|
50
|
-
|
51
|
-
if (errors.length) {
|
52
|
-
reportErrors(node, reporter, errors);
|
53
|
-
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
|
57
|
-
errors = hasProperties(formDefinition, {
|
58
|
-
formKey: {
|
59
|
-
required: true
|
60
|
-
}
|
61
|
-
}, node);
|
62
|
-
}
|
63
|
-
|
64
|
-
if (errors.length) {
|
65
|
-
reportErrors(node, reporter, errors);
|
66
|
-
|
67
|
-
return;
|
68
|
-
}
|
69
|
-
|
70
|
-
const formKey = formDefinition.get('formKey');
|
71
|
-
|
72
|
-
const userTaskForm = findUserTaskForm(node, formKey);
|
73
|
-
|
74
|
-
if (!userTaskForm) {
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
|
78
|
-
errors = hasProperties(userTaskForm, {
|
79
|
-
body: {
|
80
|
-
required: true
|
81
|
-
}
|
82
|
-
}, node);
|
83
|
-
|
84
|
-
if (errors.length) {
|
85
|
-
reportErrors(node, reporter, errors);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
return {
|
90
|
-
check
|
91
|
-
};
|
92
|
-
});
|
93
|
-
|
94
|
-
// helpers //////////
|
95
|
-
|
96
|
-
function findUserTaskForm(node, formKey) {
|
97
|
-
const process = findParent(node, 'bpmn:Process');
|
98
|
-
|
99
|
-
if (!process) {
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
|
103
|
-
const userTaskForms = findExtensionElements(process, 'zeebe:UserTaskForm');
|
104
|
-
|
105
|
-
if (userTaskForms && userTaskForms.length) {
|
106
|
-
return userTaskForms.find(userTaskForm => {
|
107
|
-
const id = userTaskForm.get('id');
|
108
|
-
|
109
|
-
return `camunda-forms:bpmn:${ id }` === formKey;
|
110
|
-
});
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
function isFormIdAllowed(version, formIdAllowedVersion) {
|
115
|
-
return greaterOrEqual(version, formIdAllowedVersion);
|
1
|
+
const { is } = require('bpmnlint-utils');
|
2
|
+
|
3
|
+
const {
|
4
|
+
findExtensionElement,
|
5
|
+
findExtensionElements,
|
6
|
+
findParent,
|
7
|
+
hasProperties,
|
8
|
+
hasProperty
|
9
|
+
} = require('../utils/element');
|
10
|
+
|
11
|
+
const { reportErrors } = require('../utils/reporter');
|
12
|
+
|
13
|
+
const { skipInNonExecutableProcess } = require('../utils/rule');
|
14
|
+
|
15
|
+
const { greaterOrEqual } = require('../utils/version');
|
16
|
+
|
17
|
+
const formIdAllowedVersions = {
|
18
|
+
desktop: '8.4',
|
19
|
+
web: '8.0'
|
20
|
+
};
|
21
|
+
|
22
|
+
module.exports = skipInNonExecutableProcess(function({ modeler = 'desktop', version }) {
|
23
|
+
function check(node, reporter) {
|
24
|
+
if (!is(node, 'bpmn:UserTask')) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
|
28
|
+
const formDefinition = findExtensionElement(node, 'zeebe:FormDefinition');
|
29
|
+
|
30
|
+
if (!formDefinition) {
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
|
34
|
+
let errors = [];
|
35
|
+
|
36
|
+
const formIdAllowedVersion = formIdAllowedVersions[ modeler ];
|
37
|
+
|
38
|
+
if (isFormIdAllowed(version, formIdAllowedVersion)) {
|
39
|
+
errors = hasProperty(formDefinition, [
|
40
|
+
'formKey',
|
41
|
+
'formId'
|
42
|
+
], node);
|
43
|
+
} else {
|
44
|
+
errors = hasProperties(formDefinition, {
|
45
|
+
formId: {
|
46
|
+
allowed: false,
|
47
|
+
allowedVersion: formIdAllowedVersion
|
48
|
+
}
|
49
|
+
}, node);
|
50
|
+
|
51
|
+
if (errors.length) {
|
52
|
+
reportErrors(node, reporter, errors);
|
53
|
+
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
|
57
|
+
errors = hasProperties(formDefinition, {
|
58
|
+
formKey: {
|
59
|
+
required: true
|
60
|
+
}
|
61
|
+
}, node);
|
62
|
+
}
|
63
|
+
|
64
|
+
if (errors.length) {
|
65
|
+
reportErrors(node, reporter, errors);
|
66
|
+
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
|
70
|
+
const formKey = formDefinition.get('formKey');
|
71
|
+
|
72
|
+
const userTaskForm = findUserTaskForm(node, formKey);
|
73
|
+
|
74
|
+
if (!userTaskForm) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
|
78
|
+
errors = hasProperties(userTaskForm, {
|
79
|
+
body: {
|
80
|
+
required: true
|
81
|
+
}
|
82
|
+
}, node);
|
83
|
+
|
84
|
+
if (errors.length) {
|
85
|
+
reportErrors(node, reporter, errors);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
return {
|
90
|
+
check
|
91
|
+
};
|
92
|
+
});
|
93
|
+
|
94
|
+
// helpers //////////
|
95
|
+
|
96
|
+
function findUserTaskForm(node, formKey) {
|
97
|
+
const process = findParent(node, 'bpmn:Process');
|
98
|
+
|
99
|
+
if (!process) {
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
|
103
|
+
const userTaskForms = findExtensionElements(process, 'zeebe:UserTaskForm');
|
104
|
+
|
105
|
+
if (userTaskForms && userTaskForms.length) {
|
106
|
+
return userTaskForms.find(userTaskForm => {
|
107
|
+
const id = userTaskForm.get('id');
|
108
|
+
|
109
|
+
return `camunda-forms:bpmn:${ id }` === formKey;
|
110
|
+
});
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
function isFormIdAllowed(version, formIdAllowedVersion) {
|
115
|
+
return greaterOrEqual(version, formIdAllowedVersion);
|
116
116
|
}
|