bpmnlint-plugin-camunda-compat 0.6.1 → 0.7.1

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/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ All notable changes to [bpmnlint-plugin-camunda-compat](https://github.com/camun
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
+ ## 0.7.1
10
+
11
+ * `FIX`: lint subscription only if start event child of sub process ([#34](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/34))
12
+
13
+ ## 0.7.0
14
+
15
+ * `FEAT`: refactor plugin structure ([#29](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/29))
16
+ * `DEPS`: update to `bpmnlint@7.8.0` ([#29](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/29))
17
+
18
+ ### Breaking Changes
19
+
20
+ * configuration not selected based on execution platform and version anymore
21
+ * error message not adjusted to be shown in Camunda Modeler anymore
22
+ * error type ELEMENT_TYPE changed to ELEMENT_TYPE_NOT_ALLOWED
23
+ * error type PROPERTY_TYPE changed to PROPERTY_TYPE_NOT_ALLOWED
24
+ * error data changed (cf. docs/ERRORS.md)
25
+
26
+ ## 0.6.2
27
+
28
+ * `FIX`: fix error message formatting ([#27](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/27))
29
+
9
30
  ## 0.6.1
10
31
 
11
32
  * `FIX`: lanes supported ([#26](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/26))
package/index.js CHANGED
@@ -1,43 +1,61 @@
1
+ const hasCalledDecisionOrTaskDefinitionConfig = require('./rules/has-called-decision-or-task-definition/config'),
2
+ isElementConfig = require('./rules/is-element/config');
3
+
1
4
  module.exports = {
2
5
  configs: {
3
- all: {
6
+ 'camunda-cloud-1-0': {
4
7
  rules: {
5
- 'camunda-cloud-1-0': 'error',
6
- 'camunda-cloud-1-1': 'error',
7
- 'camunda-cloud-1-2': 'error',
8
- 'camunda-cloud-1-3': 'error',
9
- 'camunda-cloud-8-0': 'error',
10
- 'camunda-platform-7-15': 'error',
11
- 'camunda-platform-7-16': 'error',
12
- 'camunda-platform-7-17': 'error'
8
+ 'has-called-decision-or-task-definition': [ 'error', hasCalledDecisionOrTaskDefinitionConfig.camundaCloud10 ],
9
+ 'has-called-element': 'error',
10
+ 'has-error-reference': 'error',
11
+ 'has-loop-characteristics': 'error',
12
+ 'has-message-reference': 'error',
13
+ 'has-subscription': 'error',
14
+ 'is-element': [ 'error', isElementConfig.camundaCloud10 ]
13
15
  }
14
16
  },
15
- recommended: {
17
+ 'camunda-cloud-1-1': {
16
18
  rules: {
17
- 'camunda-cloud-1-0': 'error',
18
- 'camunda-cloud-1-1': 'error',
19
- 'camunda-cloud-1-2': 'error',
20
- 'camunda-cloud-1-3': 'error',
21
- 'camunda-cloud-8-0': 'error',
22
- 'camunda-platform-7-15': 'error',
23
- 'camunda-platform-7-16': 'error',
24
- 'camunda-platform-7-17': 'error'
19
+ 'has-called-decision-or-task-definition': [ 'error', hasCalledDecisionOrTaskDefinitionConfig.camundaCloud11 ],
20
+ 'has-called-element': 'error',
21
+ 'has-error-reference': 'error',
22
+ 'has-loop-characteristics': 'error',
23
+ 'has-message-reference': 'error',
24
+ 'has-subscription': 'error',
25
+ 'is-element': [ 'error', isElementConfig.camundaCloud11 ]
25
26
  }
26
27
  },
27
- cloud: {
28
+ 'camunda-cloud-1-2': {
28
29
  rules: {
29
- 'camunda-cloud-1-0': 'error',
30
- 'camunda-cloud-1-1': 'error',
31
- 'camunda-cloud-1-2': 'error',
32
- 'camunda-cloud-1-3': 'error',
33
- 'camunda-cloud-8-0': 'error'
30
+ 'has-called-decision-or-task-definition': [ 'error', hasCalledDecisionOrTaskDefinitionConfig.camundaCloud12 ],
31
+ 'has-called-element': 'error',
32
+ 'has-error-reference': 'error',
33
+ 'has-loop-characteristics': 'error',
34
+ 'has-message-reference': 'error',
35
+ 'has-subscription': 'error',
36
+ 'is-element': [ 'error', isElementConfig.camundaCloud12 ]
34
37
  }
35
38
  },
36
- platform: {
39
+ 'camunda-cloud-1-3': {
37
40
  rules: {
38
- 'camunda-platform-7-15': 'error',
39
- 'camunda-platform-7-16': 'error',
40
- 'camunda-platform-7-17': 'error'
41
+ 'has-called-decision-or-task-definition': [ 'error', hasCalledDecisionOrTaskDefinitionConfig.camundaCloud13 ],
42
+ 'has-called-element': 'error',
43
+ 'has-error-reference': 'error',
44
+ 'has-loop-characteristics': 'error',
45
+ 'has-message-reference': 'error',
46
+ 'has-subscription': 'error',
47
+ 'is-element': [ 'error', isElementConfig.camundaCloud12 ]
48
+ }
49
+ },
50
+ 'camunda-cloud-8-0': {
51
+ rules: {
52
+ 'has-called-decision-or-task-definition': [ 'error', hasCalledDecisionOrTaskDefinitionConfig.camundaCloud13 ],
53
+ 'has-called-element': 'error',
54
+ 'has-error-reference': 'error',
55
+ 'has-loop-characteristics': 'error',
56
+ 'has-message-reference': 'error',
57
+ 'has-subscription': 'error',
58
+ 'is-element': [ 'error', isElementConfig.camundaCloud12 ]
41
59
  }
42
60
  }
43
61
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.6.1",
4
- "description": "A bpmnlint plug-in for Camunda Cloud and Platform compatibility",
3
+ "version": "0.7.1",
4
+ "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "all": "npm run lint && npm test",
@@ -24,7 +24,7 @@
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
26
  "bpmn-moddle": "^7.1.2",
27
- "bpmnlint": "^7.6.0",
27
+ "bpmnlint": "^7.8.0",
28
28
  "camunda-bpmn-moddle": "^6.1.1",
29
29
  "chai": "^4.3.5",
30
30
  "eslint": "^7.32.0",
@@ -0,0 +1,36 @@
1
+ module.exports = {
2
+ camundaCloud10: {
3
+ elementsTaskDefinition: [
4
+ 'bpmn:ServiceTask'
5
+ ]
6
+ },
7
+ camundaCloud11: {
8
+ elementsTaskDefinition: [
9
+ 'bpmn:BusinessRuleTask',
10
+ 'bpmn:ServiceTask',
11
+ 'bpmn:ScriptTask',
12
+ 'bpmn:SendTask'
13
+ ]
14
+ },
15
+ camundaCloud12: {
16
+ elementsTaskDefinition: [
17
+ 'bpmn:BusinessRuleTask',
18
+ 'bpmn:IntermediateThrowEvent',
19
+ 'bpmn:ServiceTask',
20
+ 'bpmn:ScriptTask',
21
+ 'bpmn:SendTask'
22
+ ]
23
+ },
24
+ camundaCloud13: {
25
+ elementsCalledDecision: [
26
+ 'bpmn:BusinessRuleTask'
27
+ ],
28
+ elementsTaskDefinition: [
29
+ 'bpmn:BusinessRuleTask',
30
+ 'bpmn:IntermediateThrowEvent',
31
+ 'bpmn:ServiceTask',
32
+ 'bpmn:ScriptTask',
33
+ 'bpmn:SendTask'
34
+ ]
35
+ }
36
+ };
@@ -0,0 +1,122 @@
1
+ const {
2
+ is,
3
+ isAny
4
+ } = require('bpmnlint-utils');
5
+
6
+ const { getPath } = require('@philippfromme/moddle-helpers');
7
+
8
+ const {
9
+ findExtensionElement,
10
+ getEventDefinition,
11
+ hasProperties,
12
+ hasExtensionElementOfType,
13
+ hasExtensionElementsOfTypes
14
+ } = require('../utils/element');
15
+
16
+ const { reportErrors } = require('../utils/reporter');
17
+
18
+ const { ERROR_TYPES } = require('../utils/error-types');
19
+
20
+ module.exports = function(config) {
21
+ const {
22
+ elementsCalledDecision = [],
23
+ elementsTaskDefinition = []
24
+ } = config;
25
+
26
+ function check(node, reporter) {
27
+ if (!isAny(node, elementsCalledDecision) && !isAny(node, elementsTaskDefinition)) {
28
+ return;
29
+ }
30
+
31
+ if (is(node, 'bpmn:ThrowEvent') && !getEventDefinition(node)) {
32
+ return;
33
+ }
34
+
35
+ let errors;
36
+
37
+ const calledDecision = findExtensionElement(node, 'zeebe:CalledDecision'),
38
+ taskDefinition = findExtensionElement(node, 'zeebe:TaskDefinition');
39
+
40
+ if (calledDecision && !taskDefinition) {
41
+
42
+ if (!isAny(node, elementsCalledDecision)) {
43
+ reportErrors(node, reporter, {
44
+ message: 'Extension element of type <zeebe:CalledDecision> not allowed',
45
+ path: getPath(calledDecision, node),
46
+ error: {
47
+ type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
48
+ node,
49
+ parentNode: null,
50
+ extensionElement: calledDecision
51
+ }
52
+ });
53
+
54
+ return;
55
+ }
56
+
57
+ errors = hasProperties(calledDecision, {
58
+ decisionId: {
59
+ required: true
60
+ },
61
+ resultVariable: {
62
+ required: true
63
+ }
64
+ }, node);
65
+
66
+ if (errors && errors.length) {
67
+ reportErrors(node, reporter, errors);
68
+
69
+ return;
70
+ }
71
+ }
72
+
73
+ if (!calledDecision && taskDefinition) {
74
+
75
+ if (!isAny(node, elementsTaskDefinition)) {
76
+ reportErrors(node, reporter, {
77
+ message: 'Extension element of type <zeebe:TaskDefinition> not allowed',
78
+ path: getPath(taskDefinition, node),
79
+ error: {
80
+ type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
81
+ node,
82
+ parentNode: null,
83
+ extensionElement: taskDefinition
84
+ }
85
+ });
86
+
87
+ return;
88
+ }
89
+
90
+ errors = hasProperties(taskDefinition, {
91
+ type: {
92
+ required: true
93
+ }
94
+ }, node);
95
+
96
+ if (errors && errors.length) {
97
+ reportErrors(node, reporter, errors);
98
+ }
99
+ }
100
+
101
+ if (isAny(node, elementsCalledDecision) && isAny(node, elementsTaskDefinition)) {
102
+ errors = hasExtensionElementsOfTypes(node, [
103
+ 'zeebe:CalledDecision',
104
+ 'zeebe:TaskDefinition'
105
+ ], node, true);
106
+ } else if (isAny(node, elementsCalledDecision)) {
107
+ errors = hasExtensionElementOfType(node, 'zeebe:CalledDecision', node);
108
+ } else {
109
+ errors = hasExtensionElementOfType(node, 'zeebe:TaskDefinition', node);
110
+ }
111
+
112
+ if (errors && errors.length) {
113
+ reportErrors(node, reporter, errors);
114
+
115
+ return;
116
+ }
117
+ }
118
+
119
+ return {
120
+ check
121
+ };
122
+ };
@@ -0,0 +1,41 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const {
4
+ findExtensionElement,
5
+ hasExtensionElementOfType,
6
+ hasProperties
7
+ } = require('./utils/element');
8
+
9
+ const { reportErrors } = require('./utils/reporter');
10
+
11
+ module.exports = function() {
12
+ function check(node, reporter) {
13
+ if (!is(node, 'bpmn:CallActivity')) {
14
+ return;
15
+ }
16
+
17
+ let errors = hasExtensionElementOfType(node, 'zeebe:CalledElement', node);
18
+
19
+ if (errors && errors.length) {
20
+ reportErrors(node, reporter, errors);
21
+
22
+ return;
23
+ }
24
+
25
+ const calledElement = findExtensionElement(node, 'zeebe:CalledElement');
26
+
27
+ errors = hasProperties(calledElement, {
28
+ processId: {
29
+ required: true
30
+ }
31
+ }, node);
32
+
33
+ if (errors && errors.length) {
34
+ reportErrors(node, reporter, errors);
35
+ }
36
+ }
37
+
38
+ return {
39
+ check
40
+ };
41
+ };
@@ -0,0 +1,53 @@
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
+ module.exports = function() {
14
+ function check(node, reporter) {
15
+ if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
16
+ return;
17
+ }
18
+
19
+ const eventDefinition = getEventDefinition(node);
20
+
21
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
22
+ return;
23
+ }
24
+
25
+ let errors = hasProperties(eventDefinition, {
26
+ errorRef: {
27
+ required: true
28
+ }
29
+ }, node);
30
+
31
+ if (errors && errors.length) {
32
+ reportErrors(node, reporter, errors);
33
+
34
+ return;
35
+ }
36
+
37
+ const errorRef = eventDefinition.get('errorRef');
38
+
39
+ errors = hasProperties(errorRef, {
40
+ errorCode: {
41
+ required: true
42
+ }
43
+ }, node);
44
+
45
+ if (errors && errors.length) {
46
+ reportErrors(node, reporter, errors);
47
+ }
48
+ }
49
+
50
+ return {
51
+ check
52
+ };
53
+ };
@@ -0,0 +1,65 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const {
4
+ findExtensionElement,
5
+ hasProperties,
6
+ hasExtensionElementOfType
7
+ } = require('./utils/element');
8
+
9
+ const { reportErrors } = require('./utils/reporter');
10
+
11
+ module.exports = function() {
12
+ function check(node, reporter) {
13
+ if (!is(node, 'bpmn:Activity')) {
14
+ return;
15
+ }
16
+
17
+ let loopCharacteristics = node.get('loopCharacteristics');
18
+
19
+ if (!loopCharacteristics) {
20
+ return;
21
+ }
22
+
23
+ let errors = hasProperties(node, {
24
+ loopCharacteristics: {
25
+ type: 'bpmn:MultiInstanceLoopCharacteristics'
26
+ }
27
+ }, node);
28
+
29
+ if (errors && errors.length) {
30
+ reportErrors(node, reporter, errors);
31
+
32
+ return;
33
+ }
34
+
35
+ errors = hasExtensionElementOfType(loopCharacteristics, 'zeebe:LoopCharacteristics', node);
36
+
37
+ if (errors && errors.length) {
38
+ reportErrors(node, reporter, errors);
39
+
40
+ return;
41
+ }
42
+
43
+ loopCharacteristics = findExtensionElement(loopCharacteristics, 'zeebe:LoopCharacteristics');
44
+
45
+ errors = hasProperties(loopCharacteristics, {
46
+ inputCollection: {
47
+ required: true
48
+ },
49
+ outputCollection: {
50
+ dependendRequired: 'outputElement'
51
+ },
52
+ outputElement: {
53
+ dependendRequired: 'outputCollection'
54
+ }
55
+ }, node);
56
+
57
+ if (errors && errors.length) {
58
+ reportErrors(node, reporter, errors);
59
+ }
60
+ }
61
+
62
+ return {
63
+ check
64
+ };
65
+ };
@@ -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
+ module.exports = function() {
14
+ function check(node, reporter) {
15
+ if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ReceiveTask' ])) {
16
+ return;
17
+ }
18
+
19
+ let eventDefinitionOrReceiveTask = node;
20
+
21
+ if (!is(node, 'bpmn:ReceiveTask')) {
22
+ const eventDefinition = getEventDefinition(node);
23
+
24
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:MessageEventDefinition')) {
25
+ return;
26
+ }
27
+
28
+ eventDefinitionOrReceiveTask = eventDefinition;
29
+ }
30
+
31
+ let errors = hasProperties(eventDefinitionOrReceiveTask, {
32
+ messageRef: {
33
+ required: true
34
+ }
35
+ }, node);
36
+
37
+ if (errors && errors.length) {
38
+ reportErrors(node, reporter, errors);
39
+
40
+ return;
41
+ }
42
+
43
+ const messageRef = eventDefinitionOrReceiveTask.get('messageRef');
44
+
45
+ errors = hasProperties(messageRef, {
46
+ name: {
47
+ required: true
48
+ }
49
+ }, node);
50
+
51
+ if (errors && errors.length) {
52
+ reportErrors(node, reporter, errors);
53
+ }
54
+ }
55
+
56
+ return {
57
+ check
58
+ };
59
+ };
@@ -0,0 +1,64 @@
1
+ const {
2
+ is,
3
+ isAny
4
+ } = require('bpmnlint-utils');
5
+
6
+ const {
7
+ findExtensionElement,
8
+ getEventDefinition,
9
+ hasExtensionElementOfType,
10
+ hasProperties
11
+ } = require('./utils/element');
12
+
13
+ const { reportErrors } = require('./utils/reporter');
14
+
15
+ module.exports = function() {
16
+ function check(node, reporter) {
17
+ if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent', 'bpmn:ReceiveTask' ])
18
+ || (is(node, 'bpmn:StartEvent') && !is(node.$parent, 'bpmn:SubProcess'))) {
19
+ return;
20
+ }
21
+
22
+ let eventDefinitionOrReceiveTask = node;
23
+
24
+ if (!is(node, 'bpmn:ReceiveTask')) {
25
+ const eventDefinition = getEventDefinition(node);
26
+
27
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:MessageEventDefinition')) {
28
+ return;
29
+ }
30
+
31
+ eventDefinitionOrReceiveTask = eventDefinition;
32
+ }
33
+
34
+ const messageRef = eventDefinitionOrReceiveTask.get('messageRef');
35
+
36
+ if (!messageRef) {
37
+ return;
38
+ }
39
+
40
+ let errors = hasExtensionElementOfType(messageRef, 'zeebe:Subscription', node);
41
+
42
+ if (errors && errors.length) {
43
+ reportErrors(node, reporter, errors);
44
+
45
+ return;
46
+ }
47
+
48
+ const subscription = findExtensionElement(messageRef, 'zeebe:Subscription');
49
+
50
+ errors = hasProperties(subscription, {
51
+ correlationKey: {
52
+ required: true
53
+ }
54
+ }, node);
55
+
56
+ if (errors && errors.length) {
57
+ reportErrors(node, reporter, errors);
58
+ }
59
+ }
60
+
61
+ return {
62
+ check
63
+ };
64
+ };