bpmnlint-plugin-camunda-compat 1.0.0 → 1.1.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
@@ -47,6 +47,11 @@ const camundaCloud82Rules = withConfig({
47
47
  'task-schedule': 'error'
48
48
  }, { version: '8.2' });
49
49
 
50
+ const camundaCloud83Rules = withConfig({
51
+ ...camundaCloud82Rules,
52
+ 'signal-reference': 'error'
53
+ }, { version: '8.3' });
54
+
50
55
  const camundaPlatform719Rules = withConfig({
51
56
  'history-time-to-live': 'error'
52
57
  }, { platform: 'camunda-platform', version: '7.19' });
@@ -74,6 +79,9 @@ module.exports = {
74
79
  'camunda-cloud-8-2': {
75
80
  rules: camundaCloud82Rules
76
81
  },
82
+ 'camunda-cloud-8-3': {
83
+ rules: camundaCloud83Rules
84
+ },
77
85
  'camunda-platform-7-19': {
78
86
  rules: camundaPlatform719Rules
79
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@ module.exports = {
18
18
  'bpmn:ErrorEventDefinition': '1.0',
19
19
  'bpmn:EscalationEventDefinition': '8.2',
20
20
  'bpmn:MessageEventDefinition': '1.2',
21
+ 'bpmn:SignalEventDefinition': '8.3',
21
22
  'bpmn:TerminateEventDefinition': '8.1'
22
23
  },
23
24
  'bpmn:EventBasedGateway': '1.0',
@@ -26,14 +27,15 @@ module.exports = {
26
27
  'bpmn:InclusiveGateway': '8.1',
27
28
  'bpmn:IntermediateCatchEvent': {
28
29
  'bpmn:MessageEventDefinition': '1.0',
29
- 'bpmn:TimerEventDefinition': '1.0',
30
- 'bpmn:LinkEventDefinition': '8.2'
30
+ 'bpmn:LinkEventDefinition': '8.2',
31
+ 'bpmn:TimerEventDefinition': '1.0'
31
32
  },
32
33
  'bpmn:IntermediateThrowEvent': {
33
34
  '_': '1.1',
34
35
  'bpmn:EscalationEventDefinition': '8.2',
36
+ 'bpmn:LinkEventDefinition': '8.2',
35
37
  'bpmn:MessageEventDefinition': '1.2',
36
- 'bpmn:LinkEventDefinition': '8.2'
38
+ 'bpmn:SignalEventDefinition': '8.3'
37
39
  },
38
40
  'bpmn:ManualTask': '1.1',
39
41
  'bpmn:MessageFlow': '1.0',
@@ -14,44 +14,50 @@ const { skipInNonExecutableProcess } = require('./utils/rule');
14
14
 
15
15
  const { greaterOrEqual } = require('./utils/version');
16
16
 
17
+ const noErrorRefAllowedVersion = '8.2';
18
+
17
19
  module.exports = skipInNonExecutableProcess(function({ version }) {
18
20
  function check(node, reporter) {
19
21
  if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
20
22
  return;
21
23
  }
22
24
 
23
- if (is(node, 'bpmn:CatchEvent') && greaterOrEqual(version, '8.2')) {
24
- return;
25
- }
26
-
27
25
  const eventDefinition = getEventDefinition(node);
28
26
 
29
27
  if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
30
28
  return;
31
29
  }
32
30
 
33
- let errors = hasProperties(eventDefinition, {
34
- errorRef: {
35
- required: true,
36
- allowedVersion: '8.2'
37
- }
38
- }, node);
31
+ let errors = [];
39
32
 
40
- if (errors && errors.length) {
41
- reportErrors(node, reporter, errors);
33
+ if (!isNoErrorRefAllowed(node, version)) {
34
+ errors = hasProperties(eventDefinition, {
35
+ errorRef: {
36
+ required: true,
37
+ allowedVersion: '8.2'
38
+ }
39
+ }, node);
42
40
 
43
- return;
41
+ if (errors.length) {
42
+ reportErrors(node, reporter, errors);
43
+
44
+ return;
45
+ }
44
46
  }
45
47
 
46
48
  const errorRef = eventDefinition.get('errorRef');
47
49
 
50
+ if (!errorRef) {
51
+ return;
52
+ }
53
+
48
54
  errors = hasProperties(errorRef, {
49
55
  errorCode: {
50
56
  required: true
51
57
  }
52
58
  }, node);
53
59
 
54
- if (errors && errors.length) {
60
+ if (errors.length) {
55
61
  reportErrors(node, reporter, errors);
56
62
  }
57
63
  }
@@ -59,4 +65,8 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
59
65
  return {
60
66
  check
61
67
  };
62
- });
68
+ });
69
+
70
+ function isNoErrorRefAllowed(node, version) {
71
+ return is(node, 'bpmn:CatchEvent') && greaterOrEqual(version, noErrorRefAllowedVersion);
72
+ }
@@ -35,6 +35,10 @@ const handlersMap = {
35
35
  '8.2': [
36
36
  checkErrorCatchEvent,
37
37
  checkEscalationCatchEvent
38
+ ],
39
+ '8.3': [
40
+ checkErrorCatchEvent,
41
+ checkEscalationCatchEvent
38
42
  ]
39
43
  };
40
44
 
@@ -61,6 +65,10 @@ function noExpressionRule({ version }) {
61
65
  function checkForVersion(node, version) {
62
66
  const handlers = handlersMap[version];
63
67
 
68
+ if (!handlers) {
69
+ return [];
70
+ }
71
+
64
72
  return handlers.reduce((errors, handler) => {
65
73
  const handlerErrors = handler(node) || [];
66
74
  return errors.concat(handlerErrors);
@@ -0,0 +1,59 @@
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:StartEvent', 'bpmn:IntermediateThrowEvent', 'bpmn:EndEvent' ])) {
18
+ return;
19
+ }
20
+
21
+ const eventDefinition = getEventDefinition(node);
22
+
23
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:SignalEventDefinition')) {
24
+ return;
25
+ }
26
+
27
+ let errors = hasProperties(eventDefinition, {
28
+ signalRef: {
29
+ required: true
30
+ }
31
+ }, node);
32
+
33
+ if (errors.length) {
34
+ reportErrors(node, reporter, errors);
35
+
36
+ return;
37
+ }
38
+
39
+ const signalRef = eventDefinition.get('signalRef');
40
+
41
+ if (!signalRef) {
42
+ return;
43
+ }
44
+
45
+ errors = hasProperties(signalRef, {
46
+ name: {
47
+ required: true
48
+ }
49
+ }, node);
50
+
51
+ if (errors.length) {
52
+ reportErrors(node, reporter, errors);
53
+ }
54
+ }
55
+
56
+ return {
57
+ check
58
+ };
59
+ });