bpmnlint-plugin-camunda-compat 2.17.0 → 2.19.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.
Files changed (50) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +39 -39
  3. package/index.js +221 -205
  4. package/package.json +53 -53
  5. package/rules/camunda-cloud/called-element.js +42 -42
  6. package/rules/camunda-cloud/collapsed-subprocess.js +40 -40
  7. package/rules/camunda-cloud/duplicate-task-headers.js +58 -58
  8. package/rules/camunda-cloud/element-type/config.js +66 -63
  9. package/rules/camunda-cloud/element-type/index.js +133 -133
  10. package/rules/camunda-cloud/error-reference.js +71 -71
  11. package/rules/camunda-cloud/escalation-boundary-event-attached-to-ref.js +48 -48
  12. package/rules/camunda-cloud/escalation-reference.js +66 -66
  13. package/rules/camunda-cloud/event-based-gateway-target.js +38 -38
  14. package/rules/camunda-cloud/executable-process.js +61 -61
  15. package/rules/camunda-cloud/feel.js +82 -82
  16. package/rules/camunda-cloud/implementation/config.js +16 -16
  17. package/rules/camunda-cloud/implementation/index.js +218 -218
  18. package/rules/camunda-cloud/inclusive-gateway.js +35 -35
  19. package/rules/camunda-cloud/link-event.js +142 -142
  20. package/rules/camunda-cloud/loop-characteristics.js +66 -66
  21. package/rules/camunda-cloud/message-reference.js +60 -60
  22. package/rules/camunda-cloud/no-candidate-users.js +38 -38
  23. package/rules/camunda-cloud/no-expression.js +173 -173
  24. package/rules/camunda-cloud/no-loop.js +145 -145
  25. package/rules/camunda-cloud/no-multiple-none-start-events.js +41 -41
  26. package/rules/camunda-cloud/no-propagate-all-parent-variables.js +44 -44
  27. package/rules/camunda-cloud/no-signal-event-sub-process.js +45 -45
  28. package/rules/camunda-cloud/no-task-schedule.js +18 -18
  29. package/rules/camunda-cloud/no-template.js +23 -23
  30. package/rules/camunda-cloud/no-zeebe-properties.js +18 -18
  31. package/rules/camunda-cloud/no-zeebe-user-task.js +27 -27
  32. package/rules/camunda-cloud/secrets.js +119 -119
  33. package/rules/camunda-cloud/sequence-flow-condition.js +56 -56
  34. package/rules/camunda-cloud/signal-reference.js +64 -64
  35. package/rules/camunda-cloud/start-event-form.js +97 -97
  36. package/rules/camunda-cloud/subscription.js +65 -65
  37. package/rules/camunda-cloud/task-schedule.js +67 -67
  38. package/rules/camunda-cloud/timer/config.js +46 -46
  39. package/rules/camunda-cloud/timer/index.js +183 -183
  40. package/rules/camunda-cloud/user-task-definition.js +24 -24
  41. package/rules/camunda-cloud/user-task-form.js +142 -142
  42. package/rules/camunda-cloud/wait-for-completion.js +46 -0
  43. package/rules/camunda-platform/history-time-to-live.js +19 -19
  44. package/rules/utils/cron.js +95 -95
  45. package/rules/utils/element.js +484 -484
  46. package/rules/utils/error-types.js +23 -23
  47. package/rules/utils/iso8601.js +52 -52
  48. package/rules/utils/reporter.js +37 -37
  49. package/rules/utils/rule.js +46 -46
  50. package/rules/utils/version.js +4 -4
@@ -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
+ }
@@ -1,36 +1,36 @@
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:InclusiveGateway')) {
12
- return;
13
- }
14
-
15
- const incoming = node.get('incoming');
16
-
17
- if (incoming && incoming.length > 1) {
18
- const error = {
19
- message: `Element of type <${ node.$type }> must have one property <incoming> of type <bpmn:SequenceFlow>`,
20
- path: [ 'incoming' ],
21
- data: {
22
- type: ERROR_TYPES.PROPERTY_NOT_ALLOWED,
23
- node,
24
- parentNode: null,
25
- property: 'incoming'
26
- }
27
- };
28
-
29
- reportErrors(node, reporter, error);
30
- }
31
- }
32
-
33
- return {
34
- check
35
- };
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:InclusiveGateway')) {
12
+ return;
13
+ }
14
+
15
+ const incoming = node.get('incoming');
16
+
17
+ if (incoming && incoming.length > 1) {
18
+ const error = {
19
+ message: `Element of type <${ node.$type }> must have one property <incoming> of type <bpmn:SequenceFlow>`,
20
+ path: [ 'incoming' ],
21
+ data: {
22
+ type: ERROR_TYPES.PROPERTY_NOT_ALLOWED,
23
+ node,
24
+ parentNode: null,
25
+ property: 'incoming'
26
+ }
27
+ };
28
+
29
+ reportErrors(node, reporter, error);
30
+ }
31
+ }
32
+
33
+ return {
34
+ check
35
+ };
36
36
  });