bpmnlint-plugin-camunda-compat 0.4.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -6,11 +6,17 @@ 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.5.0
10
+
11
+ * `FEAT`: update Camunda Cloud rules to lint extension elements and their properties ([#18](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/18))
12
+
9
13
  ## 0.4.0
14
+
10
15
  * `CHORE`: rename `Cloud` `1.4` to `8.0` ([#14](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/14))
11
16
  * `CHORE`: rename `Cloud` to `Platform`/`Zeebe` ([#15](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/15))
12
17
 
13
18
  ## 0.3.0
19
+
14
20
  * `FEAT`: support multiInstance for subprocesses with cloud 1.0 ([#6](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/6))
15
21
  * `FEAT`: add Camunda Platform rules ([#5](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/5))
16
22
  * `FEAT`: add Camunda Cloud 1.4 rule ([#5](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/5))
package/index.js CHANGED
@@ -41,4 +41,4 @@ module.exports = {
41
41
  }
42
42
  }
43
43
  }
44
- }
44
+ };
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Cloud and Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "all": "npm test",
8
- "test": "mocha test/**/*.spec.js"
7
+ "all": "npm run lint && npm test",
8
+ "lint": "eslint .",
9
+ "test": "mocha test/**/*.spec.js",
10
+ "test:watch": "npm run test -- --watch"
9
11
  },
10
12
  "repository": {
11
13
  "type": "git",
@@ -22,13 +24,19 @@
22
24
  "license": "MIT",
23
25
  "devDependencies": {
24
26
  "bpmn-moddle": "^7.1.2",
25
- "bpmnlint": "^6.1.0",
27
+ "bpmnlint": "^7.6.0",
28
+ "camunda-bpmn-moddle": "^6.1.1",
26
29
  "chai": "^4.3.5",
30
+ "eslint": "^7.32.0",
31
+ "eslint-plugin-bpmn-io": "^0.13.0",
27
32
  "mocha": "^5.2.0",
28
33
  "modeler-moddle": "^0.1.0",
34
+ "sinon": "^13.0.1",
35
+ "sinon-chai": "^3.7.0",
29
36
  "zeebe-bpmn-moddle": "^0.10.0"
30
37
  },
31
38
  "dependencies": {
39
+ "@philippfromme/moddle-helpers": "^0.1.0",
32
40
  "bpmnlint-utils": "^1.0.2",
33
41
  "min-dash": "^3.8.0"
34
42
  },
@@ -1,19 +1,29 @@
1
1
  const {
2
- checkSome,
2
+ checkEventDefinition,
3
+ checkFlowNode,
4
+ checkIf,
5
+ hasErrorReference,
3
6
  hasEventDefinitionOfType,
4
- hasLoopCharacteristicsOfType,
5
- hasNoEventDefinition,
7
+ hasEventDefinitionOfTypeOrNone,
6
8
  hasNoLanes,
7
- hasNoLoopCharacteristics,
8
- isNotBpmn
9
- } = require('./utils/rule');
9
+ isNotBpmn,
10
+ withTranslations
11
+ } = require('./utils/element');
12
+
13
+ const {
14
+ hasZeebeCalledElement,
15
+ hasZeebeLoopCharacteristics,
16
+ hasZeebeSubscription,
17
+ hasZeebeTaskDefinition
18
+ } = require('./utils/cloud/element');
19
+
20
+ const { checkEvery } = require('./utils/rule');
10
21
 
11
22
  module.exports = [
12
23
  {
13
24
  check: isNotBpmn
14
25
  },
15
26
  'bpmn:Association',
16
- 'bpmn:CallActivity',
17
27
  'bpmn:Collaboration',
18
28
  'bpmn:DataObject',
19
29
  'bpmn:DataObjectReference',
@@ -29,27 +39,51 @@ module.exports = [
29
39
  'bpmn:TextAnnotation',
30
40
  {
31
41
  type: 'bpmn:BoundaryEvent',
32
- check: hasEventDefinitionOfType([
33
- 'bpmn:ErrorEventDefinition',
34
- 'bpmn:MessageEventDefinition',
35
- 'bpmn:TimerEventDefinition'
36
- ])
42
+ check: checkEvery(
43
+ hasEventDefinitionOfType([
44
+ 'bpmn:ErrorEventDefinition',
45
+ 'bpmn:MessageEventDefinition',
46
+ 'bpmn:TimerEventDefinition'
47
+ ]),
48
+ checkIf(
49
+ checkEventDefinition(hasErrorReference),
50
+ hasEventDefinitionOfType('bpmn:ErrorEventDefinition')
51
+ ),
52
+ checkIf(
53
+ checkEventDefinition(hasZeebeSubscription),
54
+ hasEventDefinitionOfType('bpmn:MessageEventDefinition')
55
+ )
56
+ )
57
+ },
58
+ {
59
+ type: 'bpmn:CallActivity',
60
+ check: checkEvery(
61
+ hasZeebeCalledElement,
62
+ hasZeebeLoopCharacteristics
63
+ )
37
64
  },
38
65
  {
39
66
  type: 'bpmn:EndEvent',
40
- check: checkSome(
41
- hasNoEventDefinition,
42
- hasEventDefinitionOfType([
43
- 'bpmn:ErrorEventDefinition'
44
- ])
67
+ check: checkEvery(
68
+ hasEventDefinitionOfTypeOrNone('bpmn:ErrorEventDefinition'),
69
+ checkIf(
70
+ checkEventDefinition(hasErrorReference),
71
+ hasEventDefinitionOfType('bpmn:ErrorEventDefinition')
72
+ )
45
73
  )
46
74
  },
47
75
  {
48
76
  type: 'bpmn:IntermediateCatchEvent',
49
- check: hasEventDefinitionOfType([
50
- 'bpmn:MessageEventDefinition',
51
- 'bpmn:TimerEventDefinition'
52
- ])
77
+ check: checkEvery(
78
+ hasEventDefinitionOfType([
79
+ 'bpmn:TimerEventDefinition',
80
+ 'bpmn:MessageEventDefinition'
81
+ ]),
82
+ checkIf(
83
+ checkEventDefinition(hasZeebeSubscription),
84
+ hasEventDefinitionOfType('bpmn:MessageEventDefinition')
85
+ )
86
+ )
53
87
  },
54
88
  {
55
89
  type: 'bpmn:Process',
@@ -57,41 +91,47 @@ module.exports = [
57
91
  },
58
92
  {
59
93
  type: 'bpmn:ReceiveTask',
60
- check: checkSome(
61
- hasNoLoopCharacteristics,
62
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
94
+ check: checkEvery(
95
+ checkFlowNode(hasZeebeSubscription),
96
+ hasZeebeLoopCharacteristics
63
97
  )
64
98
  },
65
99
  {
66
100
  type: 'bpmn:ServiceTask',
67
- check: checkSome(
68
- hasNoLoopCharacteristics,
69
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
101
+ check: withTranslations(
102
+ checkEvery(
103
+ hasZeebeLoopCharacteristics,
104
+ hasZeebeTaskDefinition
105
+ ),
106
+ {
107
+ 'foo': 'bar'
108
+ }
70
109
  )
71
110
  },
72
111
  {
73
112
  type: 'bpmn:StartEvent',
74
- check: checkSome(
75
- hasNoEventDefinition,
76
- hasEventDefinitionOfType([
113
+ check: checkEvery(
114
+ hasEventDefinitionOfTypeOrNone([
77
115
  'bpmn:ErrorEventDefinition',
78
116
  'bpmn:MessageEventDefinition',
79
117
  'bpmn:TimerEventDefinition'
80
- ])
118
+ ]),
119
+ checkIf(
120
+ checkEventDefinition(hasErrorReference),
121
+ hasEventDefinitionOfType('bpmn:ErrorEventDefinition')
122
+ ),
123
+ checkIf(
124
+ checkEventDefinition(hasZeebeSubscription),
125
+ hasEventDefinitionOfType('bpmn:MessageEventDefinition')
126
+ )
81
127
  )
82
128
  },
83
129
  {
84
130
  type: 'bpmn:SubProcess',
85
- check: checkSome(
86
- hasNoLoopCharacteristics,
87
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
88
- )
131
+ check: hasZeebeLoopCharacteristics
89
132
  },
90
133
  {
91
134
  type: 'bpmn:UserTask',
92
- check: checkSome(
93
- hasNoLoopCharacteristics,
94
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
95
- )
135
+ check: hasZeebeLoopCharacteristics
96
136
  }
97
137
  ];
@@ -1,19 +1,21 @@
1
1
  const camundaCloud10Checks = require('./camunda-cloud-1-0-checks');
2
2
 
3
+ const { checkEvery } = require('./utils/rule');
4
+
5
+ const { hasNoEventDefinition } = require('./utils/element');
6
+
3
7
  const {
4
- checkSome,
5
- hasLoopCharacteristicsOfType,
6
- hasNoEventDefinition,
7
- hasNoLoopCharacteristics
8
- } = require('./utils/rule');
8
+ hasZeebeTaskDefinition,
9
+ hasZeebeLoopCharacteristics
10
+ } = require('./utils/cloud/element');
9
11
 
10
12
  module.exports = [
11
13
  ...camundaCloud10Checks,
12
14
  {
13
15
  type: 'bpmn:BusinessRuleTask',
14
- check: checkSome(
15
- hasNoLoopCharacteristics,
16
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
16
+ check: checkEvery(
17
+ hasZeebeLoopCharacteristics,
18
+ hasZeebeTaskDefinition
17
19
  )
18
20
  },
19
21
  {
@@ -22,23 +24,20 @@ module.exports = [
22
24
  },
23
25
  {
24
26
  type: 'bpmn:ManualTask',
25
- check: checkSome(
26
- hasNoLoopCharacteristics,
27
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
28
- )
27
+ check: hasZeebeLoopCharacteristics
29
28
  },
30
29
  {
31
30
  type: 'bpmn:ScriptTask',
32
- check: checkSome(
33
- hasNoLoopCharacteristics,
34
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
31
+ check: checkEvery(
32
+ hasZeebeLoopCharacteristics,
33
+ hasZeebeTaskDefinition
35
34
  )
36
35
  },
37
36
  {
38
37
  type: 'bpmn:SendTask',
39
- check: checkSome(
40
- hasNoLoopCharacteristics,
41
- hasLoopCharacteristicsOfType('bpmn:MultiInstanceLoopCharacteristics')
38
+ check: checkEvery(
39
+ hasZeebeLoopCharacteristics,
40
+ hasZeebeTaskDefinition
42
41
  )
43
42
  }
44
43
  ];
@@ -1,19 +1,47 @@
1
1
  const camundaCloud11Checks = require('./camunda-cloud-1-1-checks');
2
2
 
3
- const { hasEventDefinitionOfType } = require('./utils/rule');
4
-
3
+ const {
4
+ checkEvery,
5
+ replaceChecks
6
+ } = require('./utils/rule');
7
+
8
+ const {
9
+ checkEventDefinition,
10
+ checkIf,
11
+ hasErrorReference,
12
+ hasEventDefinitionOfType,
13
+ hasEventDefinitionOfTypeOrNone,
14
+ } = require('./utils/element');
15
+
16
+ const { hasZeebeTaskDefinition } = require('./utils/cloud/element');
17
+
5
18
  module.exports = [
6
- ...camundaCloud11Checks,
7
- {
8
- type: 'bpmn:EndEvent',
9
- check: hasEventDefinitionOfType([
10
- 'bpmn:MessageEventDefinition'
11
- ])
12
- },
13
- {
14
- type: 'bpmn:IntermediateThrowEvent',
15
- check: hasEventDefinitionOfType([
16
- 'bpmn:MessageEventDefinition'
17
- ])
18
- }
19
+ ...replaceChecks(
20
+ camundaCloud11Checks,
21
+ [
22
+ {
23
+ type: 'bpmn:IntermediateThrowEvent',
24
+ check: checkEvery(
25
+ hasEventDefinitionOfTypeOrNone('bpmn:MessageEventDefinition'),
26
+ checkIf(
27
+ hasZeebeTaskDefinition,
28
+ hasEventDefinitionOfType('bpmn:MessageEventDefinition')
29
+ )
30
+ )
31
+ },
32
+ {
33
+ type: 'bpmn:EndEvent',
34
+ check: checkEvery(
35
+ hasEventDefinitionOfTypeOrNone([
36
+ 'bpmn:ErrorEventDefinition',
37
+ 'bpmn:MessageEventDefinition'
38
+ ]),
39
+ checkIf(
40
+ checkEventDefinition(hasErrorReference),
41
+ hasEventDefinitionOfType('bpmn:ErrorEventDefinition')
42
+ )
43
+ )
44
+ }
45
+ ]
46
+ )
19
47
  ];
@@ -1,5 +1,22 @@
1
1
  const camundaCloud12Checks = require('./camunda-cloud-1-2-checks');
2
2
 
3
+ const {
4
+ checkEvery,
5
+ replaceCheck
6
+ } = require('./utils/rule');
7
+
8
+ const {
9
+ hasZeebeCalledDecisionOrTaskDefinition,
10
+ hasZeebeLoopCharacteristics
11
+ } = require('./utils/cloud/element');
12
+
3
13
  module.exports = [
4
- ...camundaCloud12Checks
14
+ ...replaceCheck(
15
+ camundaCloud12Checks,
16
+ 'bpmn:BusinessRuleTask',
17
+ checkEvery(
18
+ hasZeebeCalledDecisionOrTaskDefinition,
19
+ hasZeebeLoopCharacteristics
20
+ )
21
+ )
5
22
  ];
@@ -0,0 +1,111 @@
1
+ const { checkEvery } = require('../rule');
2
+
3
+ const {
4
+ checkFlowNode,
5
+ checkLoopCharacteristics,
6
+ checkMessage,
7
+ hasExtensionElementOfType,
8
+ hasExtensionElementsOfTypes,
9
+ checkIf,
10
+ hasMultiInstanceLoopCharacteristics,
11
+ hasLoopCharacteristics
12
+ } = require('../element');
13
+
14
+ module.exports.hasZeebeCalledDecisionOrTaskDefinition = checkFlowNode(
15
+ hasExtensionElementsOfTypes([
16
+ {
17
+ type: 'zeebe:CalledDecision',
18
+ properties: {
19
+ decisionId: {
20
+ required: true
21
+ },
22
+ resultVariable: {
23
+ required: true
24
+ }
25
+ }
26
+ },
27
+ {
28
+ type: 'zeebe:TaskDefinition',
29
+ properties: {
30
+ type: {
31
+ required: true
32
+ },
33
+ retries: {
34
+ required: true
35
+ }
36
+ }
37
+ }
38
+ ], true)
39
+ );
40
+
41
+ module.exports.hasZeebeCalledElement = checkFlowNode(
42
+ hasExtensionElementOfType({
43
+ type: 'zeebe:CalledElement',
44
+ properties: {
45
+ processId: {
46
+ required: true
47
+ }
48
+ }
49
+ })
50
+ );
51
+
52
+ /**
53
+ * Check if one of the following is true:
54
+ *
55
+ * 1. no loop characteristics
56
+ * 2. bpmn:MultiInstanceLoopCharacteristics with zeebe:LoopCharacteristics
57
+ * extension element with zeebe:inputCollection
58
+ */
59
+ module.exports.hasZeebeLoopCharacteristics = checkEvery(
60
+ checkIf(
61
+ hasMultiInstanceLoopCharacteristics,
62
+ hasLoopCharacteristics
63
+ ),
64
+ checkIf(
65
+ checkLoopCharacteristics(
66
+ hasExtensionElementOfType({
67
+ type: 'zeebe:LoopCharacteristics',
68
+ properties: {
69
+ inputCollection: {
70
+ required: true
71
+ },
72
+ outputCollection: {
73
+ dependendRequired: 'outputElement'
74
+ },
75
+ outputElement: {
76
+ dependendRequired: 'outputCollection'
77
+ }
78
+ }
79
+ })
80
+ ),
81
+ checkEvery(
82
+ hasLoopCharacteristics,
83
+ hasMultiInstanceLoopCharacteristics
84
+ )
85
+ )
86
+ );
87
+
88
+ module.exports.hasZeebeSubscription = checkMessage(
89
+ hasExtensionElementOfType({
90
+ type: 'zeebe:Subscription',
91
+ properties: {
92
+ correlationKey: {
93
+ required: true
94
+ }
95
+ }
96
+ })
97
+ );
98
+
99
+ module.exports.hasZeebeTaskDefinition = checkFlowNode(
100
+ hasExtensionElementOfType({
101
+ type: 'zeebe:TaskDefinition',
102
+ properties: {
103
+ type: {
104
+ required: true
105
+ },
106
+ retries: {
107
+ required: true
108
+ }
109
+ }
110
+ })
111
+ );