bpmnlint-plugin-camunda-compat 0.24.0 → 1.0.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
@@ -43,6 +43,7 @@ const camundaCloud82Rules = withConfig({
43
43
  'no-task-schedule'
44
44
  ]),
45
45
  'escalation-reference': 'error',
46
+ 'no-signal-event-sub-process': 'error',
46
47
  'task-schedule': 'error'
47
48
  }, { version: '8.2' });
48
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.24.0",
3
+ "version": "1.0.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -50,6 +50,7 @@ module.exports = {
50
50
  'bpmn:ErrorEventDefinition': '1.0',
51
51
  'bpmn:EscalationEventDefinition': '8.2',
52
52
  'bpmn:MessageEventDefinition': '1.0',
53
+ 'bpmn:SignalEventDefinition': '8.2',
53
54
  'bpmn:TimerEventDefinition': '1.0'
54
55
  },
55
56
  'bpmn:SubProcess': '1.0',
@@ -27,17 +27,27 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
27
27
  // (1) Element not allowed
28
28
  const allowedVersion = element || null;
29
29
 
30
+ let message = `Element of type <${ node.$type }> not allowed`;
31
+
32
+ let data = {
33
+ type: ERROR_TYPES.ELEMENT_TYPE_NOT_ALLOWED,
34
+ node,
35
+ parentNode: null
36
+ };
37
+
38
+ if (allowedVersion) {
39
+ message = `Element of type <${ node.$type }> only allowed by Camunda Platform ${ allowedVersion } or newer`;
40
+
41
+ data = {
42
+ ...data,
43
+ allowedVersion
44
+ };
45
+ }
46
+
30
47
  const error = {
31
- message: allowedVersion
32
- ? `Element of type <${ node.$type }> only allowed by Camunda Platform ${ allowedVersion } or newer`
33
- : `Element of type <${ node.$type }> not allowed`,
48
+ message,
34
49
  path: null,
35
- data: {
36
- type: ERROR_TYPES.ELEMENT_TYPE_NOT_ALLOWED,
37
- node,
38
- parentNode: null,
39
- allowedVersion
40
- }
50
+ data
41
51
  };
42
52
 
43
53
  reportErrors(node, reporter, error);
@@ -57,18 +67,28 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
57
67
  // (2) Element with event definition not allowed
58
68
  const allowedVersion = element[ eventDefinition.$type ] || null;
59
69
 
70
+ let message = `Element of type <${ node.$type }> with event definition of type <${ eventDefinition.$type }> not allowed`;
71
+
72
+ let data = {
73
+ type: ERROR_TYPES.ELEMENT_TYPE_NOT_ALLOWED,
74
+ node,
75
+ parentNode: null,
76
+ eventDefinition
77
+ };
78
+
79
+ if (allowedVersion) {
80
+ message = `Element of type <${ node.$type }> with event definition of type <${ eventDefinition.$type }> only allowed by Camunda Platform ${ allowedVersion } or newer`;
81
+
82
+ data = {
83
+ ...data,
84
+ allowedVersion
85
+ };
86
+ }
87
+
60
88
  const error = {
61
- message: allowedVersion
62
- ? `Element of type <${ node.$type }> with event definition of type <${ eventDefinition.$type }> only allowed by Camunda Platform ${ allowedVersion } or newer`
63
- : `Element of type <${ node.$type }> with event definition of type <${ eventDefinition.$type }> not allowed`,
89
+ message,
64
90
  path: null,
65
- data: {
66
- type: ERROR_TYPES.ELEMENT_TYPE_NOT_ALLOWED,
67
- node,
68
- parentNode: null,
69
- eventDefinition,
70
- allowedVersion
71
- }
91
+ data
72
92
  };
73
93
 
74
94
  reportErrors(node, reporter, error);
@@ -79,18 +99,28 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
79
99
  // (3) Element without event definition not allowed
80
100
  const allowedVersion = element[ '_' ] || null;
81
101
 
102
+ let message = `Element of type <${ node.$type }> with no event definition not allowed`;
103
+
104
+ let data = {
105
+ type: ERROR_TYPES.ELEMENT_TYPE_NOT_ALLOWED,
106
+ node,
107
+ parentNode: null,
108
+ eventDefinition
109
+ };
110
+
111
+ if (allowedVersion) {
112
+ message = `Element of type <${ node.$type }> with no event definition only allowed by Camunda Platform ${ allowedVersion } or newer`;
113
+
114
+ data = {
115
+ ...data,
116
+ allowedVersion
117
+ };
118
+ }
119
+
82
120
  const error = {
83
- message: allowedVersion
84
- ? `Element of type <${ node.$type }> with no event definition only allowed by Camunda Platform ${ allowedVersion } or newer`
85
- : `Element of type <${ node.$type }> with no event definition not allowed`,
121
+ message,
86
122
  path: null,
87
- data: {
88
- type: ERROR_TYPES.ELEMENT_TYPE_NOT_ALLOWED,
89
- node,
90
- parentNode: null,
91
- eventDefinition,
92
- allowedVersion
93
- }
123
+ data
94
124
  };
95
125
 
96
126
  reportErrors(node, reporter, error);
@@ -47,8 +47,7 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
47
47
 
48
48
  errors = hasProperties(errorRef, {
49
49
  errorCode: {
50
- required: true,
51
- allowedVersion: '8.2'
50
+ required: true
52
51
  }
53
52
  }, node);
54
53
 
@@ -49,10 +49,10 @@ module.exports = skipInNonExecutableProcess(function() {
49
49
  required: true
50
50
  },
51
51
  outputCollection: {
52
- dependendRequired: 'outputElement'
52
+ dependentRequired: 'outputElement'
53
53
  },
54
54
  outputElement: {
55
- dependendRequired: 'outputCollection'
55
+ dependentRequired: 'outputCollection'
56
56
  }
57
57
  }, node);
58
58
 
@@ -68,29 +68,37 @@ function checkForVersion(node, version) {
68
68
  }
69
69
 
70
70
  function noExpression(node, propertyName, parentNode, allowedVersion) {
71
- const propertyValue = node.get(propertyName);
72
- const path = getPath(node, parentNode);
71
+ const path = getPath(node, parentNode),
72
+ propertyValue = node.get(propertyName);
73
73
 
74
74
  if (!isExpression(propertyValue)) {
75
75
  return;
76
76
  }
77
77
 
78
- const errorMessage = allowedVersion ?
79
- `Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform ${allowedVersion} or newer` :
80
- `Expression statement <${truncate(propertyValue)}> not supported`;
78
+ let message = `Expression statement <${truncate(propertyValue)}> not supported`;
79
+
80
+ let data = {
81
+ type: ERROR_TYPES.EXPRESSION_NOT_ALLOWED,
82
+ node,
83
+ parentNode: parentNode == node ? null : parentNode,
84
+ property: propertyName
85
+ };
86
+
87
+ if (allowedVersion) {
88
+ message = `Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform ${allowedVersion} or newer`;
89
+
90
+ data = {
91
+ ...data,
92
+ allowedVersion
93
+ };
94
+ }
81
95
 
82
96
  return {
83
- message: errorMessage,
97
+ message,
84
98
  path: path
85
99
  ? [ ...path, propertyName ]
86
100
  : [ propertyName ],
87
- data: {
88
- type: ERROR_TYPES.EXPRESSION_NOT_ALLOWED,
89
- node,
90
- parentNode: parentNode == node ? null : parentNode,
91
- property: propertyName,
92
- allowedVersion
93
- }
101
+ data
94
102
  };
95
103
  }
96
104
 
@@ -0,0 +1,45 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const { reportErrors } = require('./utils/reporter');
4
+
5
+ const { getEventDefinition } = require('./utils/element');
6
+
7
+ const { ERROR_TYPES } = require('./utils/error-types');
8
+
9
+ const { skipInNonExecutableProcess } = require('./utils/rule');
10
+
11
+ module.exports = skipInNonExecutableProcess(function() {
12
+ function check(node, reporter) {
13
+ if (!is(node, 'bpmn:StartEvent')) {
14
+ return;
15
+ }
16
+
17
+ const eventDefinition = getEventDefinition(node);
18
+
19
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:SignalEventDefinition')) {
20
+ return;
21
+ }
22
+
23
+ const { $parent: parent } = node;
24
+
25
+ if (parent && is(parent, 'bpmn:SubProcess')) {
26
+ const error = {
27
+ message: 'Element of type <bpmn:StartEvent> with event definition of type <bpmn:SignalEventDefinition> not allowed as child of <bpmn:SubProcess>',
28
+ path: null,
29
+ data: {
30
+ type: ERROR_TYPES.CHILD_ELEMENT_TYPE_NOT_ALLOWED,
31
+ node,
32
+ parentNode: null,
33
+ eventDefinition,
34
+ parent
35
+ }
36
+ };
37
+
38
+ reportErrors(node, reporter, error);
39
+ }
40
+ }
41
+
42
+ return {
43
+ check
44
+ };
45
+ });
@@ -161,23 +161,23 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
161
161
  ];
162
162
  }
163
163
 
164
- if (propertyChecks.dependendRequired) {
165
- const dependency = node.get(propertyChecks.dependendRequired);
164
+ if (propertyChecks.dependentRequired) {
165
+ const dependency = node.get(propertyChecks.dependentRequired);
166
166
 
167
167
  if (dependency && !propertyValue) {
168
168
  return [
169
169
  ...results,
170
170
  {
171
- message: `Element of type <${ node.$type }> must have property <${ propertyName }> if it has property <${ propertyChecks.dependendRequired }>`,
171
+ message: `Element of type <${ node.$type }> must have property <${ propertyName }> if it has property <${ propertyChecks.dependentRequired }>`,
172
172
  path: path
173
173
  ? [ ...path, propertyName ]
174
174
  : [ propertyName ],
175
175
  data: {
176
- type: ERROR_TYPES.PROPERTY_DEPENDEND_REQUIRED,
176
+ type: ERROR_TYPES.PROPERTY_DEPENDENT_REQUIRED,
177
177
  node,
178
178
  parentNode: parentNode == node ? null : parentNode,
179
- property: propertyChecks.dependendRequired,
180
- dependendRequiredProperty: propertyName
179
+ property: propertyChecks.dependentRequired,
180
+ dependentRequiredProperty: propertyName
181
181
  }
182
182
  }
183
183
  ];
@@ -1,5 +1,6 @@
1
1
  module.exports.ERROR_TYPES = Object.freeze({
2
2
  ELEMENT_COLLAPSED_NOT_ALLOWED: 'camunda.elementCollapsedNotAllowed',
3
+ CHILD_ELEMENT_TYPE_NOT_ALLOWED: 'camunda.childElementTypeNotAllowed',
3
4
  ELEMENT_TYPE_NOT_ALLOWED: 'camunda.elementTypeNotAllowed',
4
5
  EXPRESSION_NOT_ALLOWED: 'camunda.expressionNotAllowed',
5
6
  EXPRESSION_REQUIRED: 'camunda.expressionRequired',
@@ -7,7 +8,7 @@ module.exports.ERROR_TYPES = Object.freeze({
7
8
  EXTENSION_ELEMENT_NOT_ALLOWED: 'camunda.extensionElementNotAllowed',
8
9
  EXTENSION_ELEMENT_REQUIRED: 'camunda.extensionElementRequired',
9
10
  FEEL_EXPRESSION_INVALID: 'camunda.feelExpressionInvalid',
10
- PROPERTY_DEPENDEND_REQUIRED: 'camunda.propertyDependendRequired',
11
+ PROPERTY_DEPENDENT_REQUIRED: 'camunda.propertyDependentRequired',
11
12
  PROPERTY_NOT_ALLOWED: 'camunda.propertyNotAllowed',
12
13
  PROPERTY_REQUIRED: 'camunda.propertyRequired',
13
14
  PROPERTY_TYPE_NOT_ALLOWED: 'camunda.propertyTypeNotAllowed',