From 759c2956bf1eba8d881c31374811f7f092e568a9 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 22 Mar 2024 14:28:23 +0100 Subject: [PATCH] feat: support compensation Related to https://github.com/camunda/camunda-modeler/issues/3945 --- CHANGELOG.md | 5 +++++ lib/compiled-config.js | 9 +++++++-- lib/utils/error-messages.js | 11 +++++++++-- lib/utils/properties-panel.js | 8 ++++++++ package-lock.json | 14 +++++++------- package.json | 2 +- test/spec/utils/error-messages.spec.js | 21 +++++++++++++++++++++ test/spec/utils/properties-panel.spec.js | 24 ++++++++++++++++++++++++ 8 files changed, 82 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73a8c15..b575dc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to [@camunda/linting](https://github.com/camunda/linting) ar ___Note:__ Yet to be released changes appear here._ +## 3.18.0 + +`FEAT`: handle `wait-for-completion` rule ([#103](https://github.com/camunda/linting/pull/103)) +`DEPS`: update to `bpmnlint-plugin-camunda-compat@2.18.0` + ## 3.17.0 `FEAT`: handle `no-zeebe-user-task` rule ([#101](https://github.com/camunda/linting/pull/101)) diff --git a/lib/compiled-config.js b/lib/compiled-config.js index 38d36e1..d29597c 100644 --- a/lib/compiled-config.js +++ b/lib/compiled-config.js @@ -63,7 +63,8 @@ const rules = { "camunda-compat/task-schedule": "error", "camunda-compat/timer": "error", "camunda-compat/user-task-definition": "warn", - "camunda-compat/user-task-form": "error" + "camunda-compat/user-task-form": "error", + "camunda-compat/wait-for-completion": "error" }; const config = { @@ -217,4 +218,8 @@ cache['bpmnlint-plugin-camunda-compat/user-task-definition'] = rule_33; import rule_34 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-form'; -cache['bpmnlint-plugin-camunda-compat/user-task-form'] = rule_34; \ No newline at end of file +cache['bpmnlint-plugin-camunda-compat/user-task-form'] = rule_34; + +import rule_35 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion'; + +cache['bpmnlint-plugin-camunda-compat/wait-for-completion'] = rule_35; \ No newline at end of file diff --git a/lib/utils/error-messages.js b/lib/utils/error-messages.js index 28dac94..85d013a 100644 --- a/lib/utils/error-messages.js +++ b/lib/utils/error-messages.js @@ -126,7 +126,7 @@ export function getErrorMessage(report, executionPlatform, executionPlatformVers } if (type === ERROR_TYPES.PROPERTY_VALUE_REQUIRED) { - return getPropertyValueRequiredErrorMessage(report); + return getPropertyValueRequiredErrorMessage(report, executionPlatform, executionPlatformVersion); } if (type === ERROR_TYPES.EXPRESSION_REQUIRED) { @@ -228,13 +228,14 @@ function getPropertyValueDuplicatedErrorMessage(report) { return message; } -function getPropertyValueRequiredErrorMessage(report) { +function getPropertyValueRequiredErrorMessage(report, executionPlatform, executionPlatformVersion) { const { data, message } = report; const { + allowedVersion, node, property, parentNode @@ -248,6 +249,12 @@ function getPropertyValueRequiredErrorMessage(report) { } } + const typeString = getTypeString(parentNode || node); + + if (is(node, 'bpmn:CompensateEventDefinition') && property === 'waitForCompletion') { + return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with disabled`, executionPlatform, executionPlatformVersion, allowedVersion); + } + return message; } diff --git a/lib/utils/properties-panel.js b/lib/utils/properties-panel.js index 8e8d9e0..2358c55 100644 --- a/lib/utils/properties-panel.js +++ b/lib/utils/properties-panel.js @@ -312,6 +312,10 @@ export function getEntryIds(report) { return [ 'linkName' ]; } + if (isPropertyError(data, 'waitForCompletion', 'bpmn:CompensateEventDefinition')) { + return [ 'waitForCompletion' ]; + } + return []; } @@ -515,6 +519,10 @@ export function getErrorMessage(id, report) { return 'Must be defined.'; } } + + if (id === 'waitForCompletion') { + return 'Must wait for completion.'; + } } function isExtensionElementNotAllowedError(data, extensionElement, type) { diff --git a/package-lock.json b/package-lock.json index df7228f..c05c982 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@bpmn-io/diagram-js-ui": "^0.2.2", "bpmn-moddle": "^8.1.0", "bpmnlint": "^10.2.0", - "bpmnlint-plugin-camunda-compat": "^2.17.0", + "bpmnlint-plugin-camunda-compat": "^2.18.0", "bpmnlint-utils": "^1.0.2", "camunda-bpmn-moddle": "^7.0.1", "clsx": "^2.0.0", @@ -1392,9 +1392,9 @@ } }, "node_modules/bpmnlint-plugin-camunda-compat": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/bpmnlint-plugin-camunda-compat/-/bpmnlint-plugin-camunda-compat-2.17.0.tgz", - "integrity": "sha512-4FAyDNl93DGQNmk4NCxdQqYbcNwgMAh2rJ7jDYSGRc6y/Nue2kub6FN1zLHP/88RAyUZ1gpkbvVDM/1eBEjm3A==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/bpmnlint-plugin-camunda-compat/-/bpmnlint-plugin-camunda-compat-2.18.0.tgz", + "integrity": "sha512-BC/8L/0G6putMIAgp04QmZZXC1HCkGIW5D33/EzaBQZbqb5Z0UPdNyev6gqGjGaffkyowdzH/xqndonONVplCA==", "dependencies": { "@bpmn-io/feel-lint": "^1.2.0", "@bpmn-io/moddle-utils": "^0.2.1", @@ -7376,9 +7376,9 @@ } }, "bpmnlint-plugin-camunda-compat": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/bpmnlint-plugin-camunda-compat/-/bpmnlint-plugin-camunda-compat-2.17.0.tgz", - "integrity": "sha512-4FAyDNl93DGQNmk4NCxdQqYbcNwgMAh2rJ7jDYSGRc6y/Nue2kub6FN1zLHP/88RAyUZ1gpkbvVDM/1eBEjm3A==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/bpmnlint-plugin-camunda-compat/-/bpmnlint-plugin-camunda-compat-2.18.0.tgz", + "integrity": "sha512-BC/8L/0G6putMIAgp04QmZZXC1HCkGIW5D33/EzaBQZbqb5Z0UPdNyev6gqGjGaffkyowdzH/xqndonONVplCA==", "requires": { "@bpmn-io/feel-lint": "^1.2.0", "@bpmn-io/moddle-utils": "^0.2.1", diff --git a/package.json b/package.json index 82beca4..d233953 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@bpmn-io/diagram-js-ui": "^0.2.2", "bpmn-moddle": "^8.1.0", "bpmnlint": "^10.2.0", - "bpmnlint-plugin-camunda-compat": "^2.17.0", + "bpmnlint-plugin-camunda-compat": "^2.18.0", "bpmnlint-utils": "^1.0.2", "camunda-bpmn-moddle": "^7.0.1", "clsx": "^2.0.0", diff --git a/test/spec/utils/error-messages.spec.js b/test/spec/utils/error-messages.spec.js index 6d8a211..9cdf050 100644 --- a/test/spec/utils/error-messages.spec.js +++ b/test/spec/utils/error-messages.spec.js @@ -1762,6 +1762,27 @@ describe('utils/error-messages', function() { expect(errorMessage).to.equal('A with disabled is only supported by Camunda 8.2 or newer'); }); + + it('should adjust wait for completion', async function() { + + // given + const node = createElement('bpmn:EndEvent', { + eventDefinitions: [ + createElement('bpmn:CompensateEventDefinition', { waitForCompletion: false }) + ] + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0'); + + // then + expect(errorMessage).to.equal('A with disabled is not supported by Camunda 8 (Zeebe 1.0)'); + }); + }); diff --git a/test/spec/utils/properties-panel.spec.js b/test/spec/utils/properties-panel.spec.js index 1351063..457dc5c 100644 --- a/test/spec/utils/properties-panel.spec.js +++ b/test/spec/utils/properties-panel.spec.js @@ -1910,6 +1910,30 @@ describe('utils/properties-panel', function() { }); + + it('should support `waitForCompletion`', async function() { + + // given + const node = createElement('bpmn:IntermediateThrowEvent', { + eventDefinitions: [ + createElement('bpmn:CompensateEventDefinition', { + waitForCompletion: false + }) + ] + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'waitForCompletion' ]); + + expectErrorMessage(entryIds[ 0 ], 'Must wait for completion.', report); + }); });