bpmnlint-plugin-camunda-compat 0.21.0 → 0.23.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
@@ -41,6 +41,10 @@ const camundaCloud82Rules = withConfig({
41
41
  'escalation-reference': 'error'
42
42
  }, { version: '8.2' });
43
43
 
44
+ const camundaPlatform719Rules = withConfig({
45
+ 'history-time-to-live': 'error'
46
+ }, { platform: 'camunda-platform', version: '7.19' });
47
+
44
48
  module.exports = {
45
49
  configs: {
46
50
  'camunda-cloud-1-0': {
@@ -63,6 +67,9 @@ module.exports = {
63
67
  },
64
68
  'camunda-cloud-8-2': {
65
69
  rules: camundaCloud82Rules
70
+ },
71
+ 'camunda-platform-7-19': {
72
+ rules: camundaPlatform719Rules
66
73
  }
67
74
  }
68
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -39,6 +39,7 @@
39
39
  "@bpmn-io/feel-lint": "^0.1.1",
40
40
  "@bpmn-io/moddle-utils": "^0.1.0",
41
41
  "bpmnlint-utils": "^1.0.2",
42
+ "camunda-bpmn-moddle": "^7.0.1",
42
43
  "min-dash": "^3.8.1",
43
44
  "semver-compare": "^1.0.0"
44
45
  },
@@ -12,12 +12,18 @@ const { reportErrors } = require('./utils/reporter');
12
12
 
13
13
  const { skipInNonExecutableProcess } = require('./utils/rule');
14
14
 
15
- module.exports = skipInNonExecutableProcess(function() {
15
+ const { greaterOrEqual } = require('./utils/version');
16
+
17
+ module.exports = skipInNonExecutableProcess(function({ version }) {
16
18
  function check(node, reporter) {
17
19
  if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
18
20
  return;
19
21
  }
20
22
 
23
+ if (is(node, 'bpmn:CatchEvent') && greaterOrEqual(version, '8.2')) {
24
+ return;
25
+ }
26
+
21
27
  const eventDefinition = getEventDefinition(node);
22
28
 
23
29
  if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
@@ -26,7 +32,8 @@ module.exports = skipInNonExecutableProcess(function() {
26
32
 
27
33
  let errors = hasProperties(eventDefinition, {
28
34
  errorRef: {
29
- required: true
35
+ required: true,
36
+ allowedVersion: '8.2'
30
37
  }
31
38
  }, node);
32
39
 
@@ -40,7 +47,8 @@ module.exports = skipInNonExecutableProcess(function() {
40
47
 
41
48
  errors = hasProperties(errorRef, {
42
49
  errorCode: {
43
- required: true
50
+ required: true,
51
+ allowedVersion: '8.2'
44
52
  }
45
53
  }, node);
46
54
 
@@ -0,0 +1,31 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const { hasProperties } = 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
+
12
+ if (!is(node, 'bpmn:Process')) {
13
+ return;
14
+ }
15
+
16
+ let errors = hasProperties(node, {
17
+ 'historyTimeToLive': {
18
+ required: true
19
+ }
20
+ }, node);
21
+
22
+ if (errors) {
23
+ reportErrors(node, reporter, errors);
24
+ }
25
+ return;
26
+ }
27
+
28
+ return {
29
+ check
30
+ };
31
+ });
@@ -145,16 +145,18 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
145
145
  return [
146
146
  ...results,
147
147
  {
148
- message: `Element of type <${ node.$type }> must have property <${ propertyName }>`,
148
+ message: allowedVersion
149
+ ? `Element of type <${ node.$type }> without property <${ propertyName }> only allowed by Camunda Platform ${ allowedVersion } or newer`
150
+ : `Element of type <${ node.$type }> must have property <${ propertyName }>`,
149
151
  path: path
150
152
  ? [ ...path, propertyName ]
151
153
  : [ propertyName ],
152
- data: {
154
+ data: addAllowedVersion({
153
155
  type: ERROR_TYPES.PROPERTY_REQUIRED,
154
156
  node,
155
157
  parentNode: parentNode == node ? null : parentNode,
156
158
  requiredProperty: propertyName
157
- }
159
+ }, allowedVersion)
158
160
  }
159
161
  ];
160
162
  }
@@ -200,14 +202,13 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
200
202
  path: path
201
203
  ? [ ...path, propertyName ]
202
204
  : [ propertyName ],
203
- data: {
205
+ data: addAllowedVersion({
204
206
  type: ERROR_TYPES.PROPERTY_TYPE_NOT_ALLOWED,
205
207
  node,
206
208
  parentNode: parentNode == node ? null : parentNode,
207
209
  property: propertyName,
208
- allowedPropertyType: propertyChecks.type,
209
- allowedVersion
210
- }
210
+ allowedPropertyType: propertyChecks.type
211
+ }, allowedVersion)
211
212
  }
212
213
  ];
213
214
  }
@@ -241,13 +242,12 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
241
242
  path: path
242
243
  ? [ ...path, propertyName ]
243
244
  : [ propertyName ],
244
- data: {
245
+ data: addAllowedVersion({
245
246
  type: ERROR_TYPES.PROPERTY_NOT_ALLOWED,
246
247
  node,
247
248
  parentNode: parentNode == node ? null : parentNode,
248
- property: propertyName,
249
- allowedVersion
250
- }
249
+ property: propertyName
250
+ }, allowedVersion)
251
251
  }
252
252
  ];
253
253
  }
@@ -262,13 +262,12 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
262
262
  path: path
263
263
  ? [ ...path, propertyName ]
264
264
  : [ propertyName ],
265
- data: {
265
+ data: addAllowedVersion({
266
266
  type: ERROR_TYPES.PROPERTY_VALUE_NOT_ALLOWED,
267
267
  node,
268
268
  parentNode: parentNode == node ? null : parentNode,
269
- property: propertyName,
270
- allowedVersion
271
- }
269
+ property: propertyName
270
+ }, allowedVersion)
272
271
  }
273
272
  ];
274
273
  }
@@ -344,13 +343,12 @@ module.exports.hasNoExtensionElement = function(node, type, parentNode = null, a
344
343
  ? `Extension element of type <${ type }> only allowed by Camunda Platform ${ allowedVersion }`
345
344
  : `Extension element of type <${ type }> not allowed`,
346
345
  path: getPath(extensionElement, parentNode),
347
- data: {
346
+ data: addAllowedVersion({
348
347
  type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
349
348
  node,
350
349
  parentNode: parentNode == node ? null : parentNode,
351
- extensionElement,
352
- allowedVersion
353
- }
350
+ extensionElement
351
+ }, allowedVersion)
354
352
  }
355
353
  ];
356
354
  }
@@ -407,13 +405,12 @@ module.exports.hasExpression = function(node, propertyName, check, parentNode =
407
405
  path: path
408
406
  ? [ ...path, propertyName ]
409
407
  : null,
410
- data: {
408
+ data: addAllowedVersion({
411
409
  type: ERROR_TYPES.EXPRESSION_VALUE_NOT_ALLOWED,
412
410
  node: expression,
413
411
  parentNode,
414
- property: propertyName,
415
- allowedVersion
416
- }
412
+ property: propertyName
413
+ }, allowedVersion)
417
414
  }
418
415
  ];
419
416
  }
@@ -438,3 +435,14 @@ function truncate(string, maxLength = 10) {
438
435
 
439
436
  return stringified.length > maxLength ? `${ stringified.slice(0, maxLength) }...` : stringified;
440
437
  }
438
+
439
+ function addAllowedVersion(data, allowedVersion) {
440
+ if (!allowedVersion) {
441
+ return data;
442
+ }
443
+
444
+ return {
445
+ ...data,
446
+ allowedVersion
447
+ };
448
+ }
@@ -6,10 +6,14 @@ function skipInNonExecutableProcess(ruleFactory) {
6
6
  return function(config = {}) {
7
7
  const rule = ruleFactory(config);
8
8
 
9
- const { version } = config;
9
+ const { version, platform = 'camunda-cloud' } = config;
10
10
 
11
11
  function check(node, reporter) {
12
- if (version && greaterOrEqual(version, '8.2') && isNonExecutableProcess(node)) {
12
+ if (platform === 'camunda-cloud' && version && greaterOrEqual(version, '8.2') && isNonExecutableProcess(node)) {
13
+ return false;
14
+ }
15
+
16
+ if (platform === 'camunda-platform' && isNonExecutableProcess(node)) {
13
17
  return false;
14
18
  }
15
19