bpmnlint-plugin-camunda-compat 2.5.0 → 2.6.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
@@ -50,6 +50,7 @@ const camundaCloud82Rules = withConfig({
50
50
  ]),
51
51
  'escalation-boundary-event-attached-to-ref': 'error',
52
52
  'escalation-reference': 'error',
53
+ 'link-event': 'error',
53
54
  'no-signal-event-sub-process': 'error',
54
55
  'task-schedule': 'error'
55
56
  }, { version: '8.2' });
@@ -87,6 +88,7 @@ const rules = {
87
88
  'history-time-to-live': './rules/camunda-platform/history-time-to-live',
88
89
  'implementation': './rules/camunda-cloud/implementation',
89
90
  'inclusive-gateway': './rules/camunda-cloud/inclusive-gateway',
91
+ 'link-event': './rules/camunda-cloud/link-event',
90
92
  'loop-characteristics': './rules/camunda-cloud/loop-characteristics',
91
93
  'message-reference': './rules/camunda-cloud/message-reference',
92
94
  'no-candidate-users': './rules/camunda-cloud/no-candidate-users',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  "modeler-moddle": "^0.1.0",
34
34
  "sinon": "^14.0.0",
35
35
  "sinon-chai": "^3.7.0",
36
- "zeebe-bpmn-moddle": "^0.18.0"
36
+ "zeebe-bpmn-moddle": "^1.0.0"
37
37
  },
38
38
  "dependencies": {
39
39
  "@bpmn-io/feel-lint": "^0.1.1",
@@ -0,0 +1,139 @@
1
+ const { getPath } = require('@bpmn-io/moddle-utils');
2
+
3
+ const {
4
+ is,
5
+ isAny
6
+ } = require('bpmnlint-utils');
7
+
8
+ const {
9
+ getEventDefinition,
10
+ hasProperties
11
+ } = require('../utils/element');
12
+
13
+ const { ERROR_TYPES } = require('../utils/error-types');
14
+
15
+ const { reportErrors } = require('../utils/reporter');
16
+
17
+ const { skipInNonExecutableProcess } = require('../utils/rule');
18
+
19
+ module.exports = skipInNonExecutableProcess(function() {
20
+ function check(node, reporter) {
21
+
22
+ // check for duplicate link catch event names
23
+ if (is(node, 'bpmn:Process')) {
24
+ const linkCatchEvents = getLinkCatchEvents(node);
25
+
26
+ const { duplicateNames } = linkCatchEvents.reduce(({ duplicateNames, names }, linkCatchEvent, index) => {
27
+ const linkEventDefinition = getEventDefinition(linkCatchEvent, 'bpmn:LinkEventDefinition');
28
+
29
+ const name = linkEventDefinition.get('name');
30
+
31
+ if (!name) {
32
+ return {
33
+ duplicateNames,
34
+ names
35
+ };
36
+ }
37
+
38
+ names = [
39
+ ...names,
40
+ name
41
+ ];
42
+
43
+ if (names.indexOf(name) !== index && !duplicateNames.includes(name)) {
44
+ duplicateNames = [
45
+ ...duplicateNames,
46
+ name
47
+ ];
48
+ }
49
+
50
+ return {
51
+ duplicateNames,
52
+ names
53
+ };
54
+ }, {
55
+ duplicateNames: [],
56
+ names: []
57
+ });
58
+
59
+ duplicateNames.forEach((name) => {
60
+ const duplicates = linkCatchEvents
61
+ .filter(linkCatchEvent => {
62
+ const linkEventDefinition = getEventDefinition(linkCatchEvent, 'bpmn:LinkEventDefinition');
63
+
64
+ return linkEventDefinition.get('name') === name;
65
+ });
66
+
67
+ duplicates
68
+ .forEach(linkCatchEvent => {
69
+ const linkEventDefinition = getEventDefinition(linkCatchEvent, 'bpmn:LinkEventDefinition');
70
+
71
+ const path = getPath(linkEventDefinition, linkCatchEvent);
72
+
73
+ reportErrors(linkCatchEvent, reporter, {
74
+ message: `Property of type <bpmn:LinkEventDefinition> has property <name> with duplicate value of <${ name }>`,
75
+ path: path
76
+ ? [ ...path, 'name' ]
77
+ : [ 'name' ],
78
+ data: {
79
+ type: ERROR_TYPES.ELEMENT_PROPERTY_VALUE_DUPLICATED,
80
+ node: linkEventDefinition,
81
+ parentNode: linkCatchEvent,
82
+ duplicatedProperty: 'name',
83
+ duplicatedPropertyValue: name
84
+ }
85
+ });
86
+ });
87
+ });
88
+ }
89
+
90
+ // check for missing link catch & throw event names
91
+ if (isLinkEvent(node)) {
92
+ const linkEventDefinition = getEventDefinition(node, 'bpmn:LinkEventDefinition');
93
+
94
+ const errors = hasProperties(linkEventDefinition, {
95
+ name: {
96
+ required: true
97
+ }
98
+ }, node);
99
+
100
+ if (errors.length) {
101
+ reportErrors(node, reporter, errors);
102
+ }
103
+ }
104
+ }
105
+
106
+ return {
107
+ check
108
+ };
109
+ });
110
+
111
+ function isLinkEvent(element) {
112
+ return isAny(element, [
113
+ 'bpmn:IntermediateCatchEvent',
114
+ 'bpmn:IntermediateThrowEvent'
115
+ ]) && getEventDefinition(element, 'bpmn:LinkEventDefinition');
116
+ }
117
+
118
+ function isLinkCatchEvent(element) {
119
+ return is(element, 'bpmn:IntermediateCatchEvent')
120
+ && getEventDefinition(element, 'bpmn:LinkEventDefinition');
121
+ }
122
+
123
+ function getLinkCatchEvents(flowElementsContainer) {
124
+ return flowElementsContainer.get('flowElements').reduce((linkCatchEvents, flowElement) => {
125
+ if (isLinkCatchEvent(flowElement)) {
126
+ return [
127
+ ...linkCatchEvents,
128
+ flowElement
129
+ ];
130
+ } else if (is(flowElement, 'bpmn:SubProcess')) {
131
+ return [
132
+ ...linkCatchEvents,
133
+ ...getLinkCatchEvents(flowElement)
134
+ ];
135
+ }
136
+
137
+ return linkCatchEvents;
138
+ }, []);
139
+ }
@@ -23,7 +23,13 @@ module.exports = skipInNonExecutableProcess(function() {
23
23
 
24
24
  const errors = hasProperties(calledElement, {
25
25
  propagateAllParentVariables: {
26
- allowed: false,
26
+ allowed: function(value) {
27
+
28
+ // `propergateAllParentVariables` is not recognized by Camunda 8.1 and older
29
+ // setting it to `true` is therefore allowed for all versions
30
+ // setting it to `false` is only allowed for Camunda 8.2 and newer
31
+ return value;
32
+ },
27
33
  allowedVersion: '8.2'
28
34
  }
29
35
  }, node);
@@ -1,8 +1,9 @@
1
1
  module.exports.ERROR_TYPES = Object.freeze({
2
- ELEMENT_COLLAPSED_NOT_ALLOWED: 'camunda.elementCollapsedNotAllowed',
3
2
  CHILD_ELEMENT_TYPE_NOT_ALLOWED: 'camunda.childElementTypeNotAllowed',
3
+ ELEMENT_COLLAPSED_NOT_ALLOWED: 'camunda.elementCollapsedNotAllowed',
4
4
  ELEMENT_MULTIPLE_NOT_ALLOWED: 'camunda.elementMultipleNotAllowed',
5
5
  ELEMENT_TYPE_NOT_ALLOWED: 'camunda.elementTypeNotAllowed',
6
+ ELEMENT_PROPERTY_VALUE_DUPLICATED: 'camunda.elementPropertyValueDuplicated',
6
7
  EVENT_BASED_GATEWAY_TARGET_NOT_ALLOWED: 'camunda.eventBasedGatewayTargetNotAllowed',
7
8
  EXPRESSION_NOT_ALLOWED: 'camunda.expressionNotAllowed',
8
9
  EXPRESSION_REQUIRED: 'camunda.expressionRequired',