bpmnlint-plugin-camunda-compat 0.15.1 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -36,7 +36,7 @@
36
36
  "zeebe-bpmn-moddle": "^0.14.0"
37
37
  },
38
38
  "dependencies": {
39
- "@bpmn-io/feel-lint": "^0.1.0",
39
+ "@bpmn-io/feel-lint": "^0.1.1",
40
40
  "@bpmn-io/moddle-utils": "^0.1.0",
41
41
  "bpmnlint-utils": "^1.0.2",
42
42
  "min-dash": "^3.8.1",
@@ -4,7 +4,9 @@ module.exports = {
4
4
  },
5
5
  taskDefinition: {
6
6
  'bpmn:BusinessRuleTask': '1.1',
7
- 'bpmn:IntermediateThrowEvent': '1.2',
7
+ 'bpmn:IntermediateThrowEvent': {
8
+ 'bpmn:MessageEventDefinition': '1.2',
9
+ },
8
10
  'bpmn:ScriptTask': '1.1',
9
11
  'bpmn:SendTask': '1.1',
10
12
  'bpmn:ServiceTask': '1.0'
@@ -2,6 +2,8 @@ const { is } = require('bpmnlint-utils');
2
2
 
3
3
  const { getPath } = require('@bpmn-io/moddle-utils');
4
4
 
5
+ const { isString } = require('min-dash');
6
+
5
7
  const config = require('./config');
6
8
 
7
9
  const { greaterOrEqual } = require('../utils/version');
@@ -19,9 +21,12 @@ const { ERROR_TYPES } = require('../utils/error-types');
19
21
 
20
22
  module.exports = function({ version }) {
21
23
  function check(node, reporter) {
24
+ const calledDecisionConfig = config.calledDecision[ node.$type ];
25
+ const taskDefinitionConfig = config.taskDefinition[ node.$type ];
26
+
22
27
  if (
23
- (!config.calledDecision[ node.$type ] || !greaterOrEqual(version, config.calledDecision[ node.$type ]))
24
- && (!config.taskDefinition[ node.$type ] || !greaterOrEqual(version, config.taskDefinition[ node.$type ]))) {
28
+ (!calledDecisionConfig || (isString(calledDecisionConfig) && !greaterOrEqual(version, calledDecisionConfig)))
29
+ && (!taskDefinitionConfig || (isString(taskDefinitionConfig) && !greaterOrEqual(version, taskDefinitionConfig)))) {
25
30
  return;
26
31
  }
27
32
 
@@ -37,7 +42,7 @@ module.exports = function({ version }) {
37
42
  if (calledDecision && !taskDefinition) {
38
43
 
39
44
  if (!isCalledDecisionAllowed(node, version)) {
40
- const allowedVersion = config.calledDecision[ node.$type ] || null;
45
+ const allowedVersion = getAllowedVersion(calledDecisionConfig, node);
41
46
 
42
47
  reportErrors(node, reporter, {
43
48
  message: allowedVersion
@@ -75,7 +80,7 @@ module.exports = function({ version }) {
75
80
  if (!calledDecision && taskDefinition) {
76
81
 
77
82
  if (!isTaskDefinitionAllowed(node, version)) {
78
- const allowedVersion = config.taskDefinition[ node.$type ] || null;
83
+ const allowedVersion = getAllowedVersion(taskDefinitionConfig, node);
79
84
 
80
85
  reportErrors(node, reporter, {
81
86
  message: allowedVersion
@@ -112,7 +117,7 @@ module.exports = function({ version }) {
112
117
  ], node);
113
118
  } else if (isCalledDecisionAllowed(node, version)) {
114
119
  errors = hasExtensionElement(node, 'zeebe:CalledDecision', node);
115
- } else {
120
+ } else if (isTaskDefinitionAllowed(node, version)) {
116
121
  errors = hasExtensionElement(node, 'zeebe:TaskDefinition', node);
117
122
  }
118
123
 
@@ -137,5 +142,21 @@ function isCalledDecisionAllowed(node, version) {
137
142
  function isTaskDefinitionAllowed(node, version) {
138
143
  const { taskDefinition } = config;
139
144
 
140
- return taskDefinition[ node.$type ] && greaterOrEqual(version, taskDefinition[ node.$type ]);
145
+ const allowedVersion = getAllowedVersion(taskDefinition[ node.$type ], node);
146
+
147
+ return allowedVersion && greaterOrEqual(version, allowedVersion);
148
+ }
149
+
150
+ function getAllowedVersion(config, node) {
151
+ if (!config) {
152
+ return null;
153
+ }
154
+
155
+ if (isString(config)) {
156
+ return config;
157
+ }
158
+
159
+ const eventDefinition = getEventDefinition(node);
160
+
161
+ return eventDefinition && config[ eventDefinition.$type ];
141
162
  }
@@ -24,11 +24,13 @@ module.exports = {
24
24
  'bpmn:InclusiveGateway': '8.1',
25
25
  'bpmn:IntermediateCatchEvent': {
26
26
  'bpmn:MessageEventDefinition': '1.0',
27
- 'bpmn:TimerEventDefinition': '1.0'
27
+ 'bpmn:TimerEventDefinition': '1.0',
28
+ 'bpmn:LinkEventDefinition': '8.2'
28
29
  },
29
30
  'bpmn:IntermediateThrowEvent': {
30
31
  '_': '1.1',
31
- 'bpmn:MessageEventDefinition': '1.2'
32
+ 'bpmn:MessageEventDefinition': '1.2',
33
+ 'bpmn:LinkEventDefinition': '8.2'
32
34
  },
33
35
  'bpmn:ManualTask': '1.1',
34
36
  'bpmn:MessageFlow': '1.0',
@@ -9,7 +9,7 @@ const ZONE_ID = '(\\[[^\\]]+\\])';
9
9
  const TIMEZONE = `(Z|([+-](0[0-9]|1[0-3]):[0-5][0-9]${ZONE_ID}?))`;
10
10
 
11
11
  const ISO_DATE_REGEX = new RegExp(`^${DATE}T${HOUR}:${MINUTE}:${SECOND}${TIMEZONE}$`);
12
- const ISO_DURATION = 'P(?!$)(\\d+(\\.\\d+)?[Yy])?(\\d+(\\.\\d+)?[Mm])?(\\d+(\\.\\d+)?[Dd])?(T(?!$)(\\d+(\\.\\d+)?[Hh])?(\\d+(\\.\\d+)?[Mm])?(\\d+(\\.\\d+)?[Ss])?)?$';
12
+ const ISO_DURATION = 'P(?!$)(\\d+(\\.\\d+)?[Yy])?(\\d+(\\.\\d+)?[Mm])?(\\d+(\\.\\d+)?[Ww])?(\\d+(\\.\\d+)?[Dd])?(T(?!$)(\\d+(\\.\\d+)?[Hh])?(\\d+(\\.\\d+)?[Mm])?(\\d+(\\.\\d+)?[Ss])?)?$';
13
13
  const ISO_DURATION_REGEX = new RegExp(`^${ISO_DURATION}$`);
14
14
  const ISO_CYCLE = `R(-1|\\d+)?/${ISO_DURATION}`;
15
15
  const ISO_CYCLE_REGEX = new RegExp(`^${ISO_CYCLE}$`);