Skip to content

Commit

Permalink
feat: support compensation
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac authored and merge-me[bot] committed Mar 22, 2024
1 parent 8fb3d2c commit 759c295
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `[email protected]`

## 3.17.0

`FEAT`: handle `no-zeebe-user-task` rule ([#101](https://github.com/camunda/linting/pull/101))
Expand Down
9 changes: 7 additions & 2 deletions lib/compiled-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
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;
11 changes: 9 additions & 2 deletions lib/utils/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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 <Wait for completion> disabled`, executionPlatform, executionPlatformVersion, allowedVersion);
}

return message;
}

Expand Down
8 changes: 8 additions & 0 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ export function getEntryIds(report) {
return [ 'linkName' ];
}

if (isPropertyError(data, 'waitForCompletion', 'bpmn:CompensateEventDefinition')) {
return [ 'waitForCompletion' ];
}

return [];
}

Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 21 additions & 0 deletions test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,27 @@ describe('utils/error-messages', function() {
expect(errorMessage).to.equal('A <Call Activity> with <Propagate all variables> 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 <Compensate End Event> with <Wait for completion> disabled is not supported by Camunda 8 (Zeebe 1.0)');
});

});


Expand Down
24 changes: 24 additions & 0 deletions test/spec/utils/properties-panel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});


Expand Down

0 comments on commit 759c295

Please sign in to comment.