Skip to content

Commit

Permalink
feat: implement zeebe:PriorityDefinition lint adjustments and props…
Browse files Browse the repository at this point in the history
… panel messages

Closes #113
  • Loading branch information
Skaiir authored Aug 19, 2024
1 parent 4960d84 commit 51717e8
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 57 deletions.
74 changes: 42 additions & 32 deletions lib/compiled-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ const rules = {
"camunda-compat/no-expression": "error",
"camunda-compat/no-loop": "error",
"camunda-compat/no-multiple-none-start-events": "error",
"camunda-compat/no-priority-definition": "error",
"camunda-compat/no-propagate-all-parent-variables": "error",
"camunda-compat/no-signal-event-sub-process": "error",
"camunda-compat/no-task-schedule": "error",
"camunda-compat/no-template": "error",
"camunda-compat/no-zeebe-properties": "error",
"camunda-compat/no-zeebe-user-task": "error",
"camunda-compat/priority-definition": "error",
"camunda-compat/secrets": "warn",
"camunda-compat/sequence-flow-condition": "error",
"camunda-compat/signal-reference": "error",
Expand Down Expand Up @@ -185,66 +187,74 @@ import rule_24 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-multi

cache['bpmnlint-plugin-camunda-compat/no-multiple-none-start-events'] = rule_24;

import rule_25 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-propagate-all-parent-variables';
import rule_25 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-priority-definition';

cache['bpmnlint-plugin-camunda-compat/no-propagate-all-parent-variables'] = rule_25;
cache['bpmnlint-plugin-camunda-compat/no-priority-definition'] = rule_25;

import rule_26 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-signal-event-sub-process';
import rule_26 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-propagate-all-parent-variables';

cache['bpmnlint-plugin-camunda-compat/no-signal-event-sub-process'] = rule_26;
cache['bpmnlint-plugin-camunda-compat/no-propagate-all-parent-variables'] = rule_26;

import rule_27 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-task-schedule';
import rule_27 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-signal-event-sub-process';

cache['bpmnlint-plugin-camunda-compat/no-task-schedule'] = rule_27;
cache['bpmnlint-plugin-camunda-compat/no-signal-event-sub-process'] = rule_27;

import rule_28 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-template';
import rule_28 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-task-schedule';

cache['bpmnlint-plugin-camunda-compat/no-template'] = rule_28;
cache['bpmnlint-plugin-camunda-compat/no-task-schedule'] = rule_28;

import rule_29 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-properties';
import rule_29 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-template';

cache['bpmnlint-plugin-camunda-compat/no-zeebe-properties'] = rule_29;
cache['bpmnlint-plugin-camunda-compat/no-template'] = rule_29;

import rule_30 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-user-task';
import rule_30 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-properties';

cache['bpmnlint-plugin-camunda-compat/no-zeebe-user-task'] = rule_30;
cache['bpmnlint-plugin-camunda-compat/no-zeebe-properties'] = rule_30;

import rule_31 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/secrets';
import rule_31 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-user-task';

cache['bpmnlint-plugin-camunda-compat/secrets'] = rule_31;
cache['bpmnlint-plugin-camunda-compat/no-zeebe-user-task'] = rule_31;

import rule_32 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/sequence-flow-condition';
import rule_32 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/priority-definition';

cache['bpmnlint-plugin-camunda-compat/sequence-flow-condition'] = rule_32;
cache['bpmnlint-plugin-camunda-compat/priority-definition'] = rule_32;

import rule_33 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/signal-reference';
import rule_33 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/secrets';

cache['bpmnlint-plugin-camunda-compat/signal-reference'] = rule_33;
cache['bpmnlint-plugin-camunda-compat/secrets'] = rule_33;

import rule_34 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/start-event-form';
import rule_34 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/sequence-flow-condition';

cache['bpmnlint-plugin-camunda-compat/start-event-form'] = rule_34;
cache['bpmnlint-plugin-camunda-compat/sequence-flow-condition'] = rule_34;

import rule_35 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/subscription';
import rule_35 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/signal-reference';

cache['bpmnlint-plugin-camunda-compat/subscription'] = rule_35;
cache['bpmnlint-plugin-camunda-compat/signal-reference'] = rule_35;

import rule_36 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/task-schedule';
import rule_36 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/start-event-form';

cache['bpmnlint-plugin-camunda-compat/task-schedule'] = rule_36;
cache['bpmnlint-plugin-camunda-compat/start-event-form'] = rule_36;

import rule_37 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/timer';
import rule_37 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/subscription';

cache['bpmnlint-plugin-camunda-compat/timer'] = rule_37;
cache['bpmnlint-plugin-camunda-compat/subscription'] = rule_37;

import rule_38 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-definition';
import rule_38 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/task-schedule';

cache['bpmnlint-plugin-camunda-compat/user-task-definition'] = rule_38;
cache['bpmnlint-plugin-camunda-compat/task-schedule'] = rule_38;

import rule_39 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-form';
import rule_39 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/timer';

cache['bpmnlint-plugin-camunda-compat/user-task-form'] = rule_39;
cache['bpmnlint-plugin-camunda-compat/timer'] = rule_39;

import rule_40 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion';
import rule_40 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-definition';

cache['bpmnlint-plugin-camunda-compat/wait-for-completion'] = rule_40;
cache['bpmnlint-plugin-camunda-compat/user-task-definition'] = rule_40;

import rule_41 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-form';

cache['bpmnlint-plugin-camunda-compat/user-task-form'] = rule_41;

import rule_42 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion';

cache['bpmnlint-plugin-camunda-compat/wait-for-completion'] = rule_42;
8 changes: 8 additions & 0 deletions lib/utils/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ function getExtensionElementNotAllowedErrorMessage(report, executionPlatform, ex
return getSupportedMessage('A <User Task> with <Due date> or <Follow up date>', executionPlatform, executionPlatformVersion, allowedVersion);
}

if (is(node, 'bpmn:UserTask') && is(extensionElement, 'zeebe:PriorityDefinition')) {
return getSupportedMessage('A <User Task> with <Priority>', executionPlatform, executionPlatformVersion, allowedVersion);
}

if (is(node, 'bpmn:StartEvent') && is(extensionElement, 'zeebe:FormDefinition')) {
return getSupportedMessage('A <Start Event> with <User Task Form>', executionPlatform, executionPlatformVersion, allowedVersion);
}
Expand Down Expand Up @@ -648,6 +652,10 @@ function getExpressionValueNotAllowedErrorMessage(report, executionPlatform, exe
return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Follow up date> must be an ISO 8601 date`;
}

if (is(node, 'zeebe:PriorityDefinition') && property === 'priority') {
return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Priority> must be an expression, or an integer between 0 and 100`;
}

return message;
}

Expand Down
16 changes: 16 additions & 0 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ export function getEntryIds(report) {
return ids;
}

if (isExpressionValueNotAllowedError(data, 'priority', 'zeebe:PriorityDefinition')) {
return [ 'priorityDefinitionPriority' ];
}

if (isExtensionElementNotAllowedError(data, 'zeebe:PriorityDefinition', 'bpmn:UserTask')) {
return [ 'priorityDefinition' ];
}

if (isPropertyError(data, 'propagateAllParentVariables', 'zeebe:CalledElement')) {
return [ 'propagateAllParentVariables' ];
}
Expand Down Expand Up @@ -533,6 +541,14 @@ export function getErrorMessage(id, report) {
}
}

if (id === 'priorityDefinitionPriority') {
if (type === ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED) {
return getNotSupportedMessage('', allowedVersion);
} else {
return 'Must be an expression, or an integer between 0 and 100.';
}
}

if (id === 'propagateAllParentVariables') {
return getNotSupportedMessage('', allowedVersion);
}
Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
"@bpmn-io/diagram-js-ui": "^0.2.3",
"bpmn-moddle": "^9.0.1",
"bpmnlint": "^10.3.0",
"bpmnlint-plugin-camunda-compat": "^2.23.0",
"bpmnlint-plugin-camunda-compat": "^2.24.0",
"bpmnlint-utils": "^1.0.2",
"camunda-bpmn-moddle": "^7.0.1",
"clsx": "^2.0.0",
"min-dash": "^4.0.0",
"min-dom": "^5.1.1",
"modeler-moddle": "^0.2.0",
"semver-compare": "^1.0.0",
"zeebe-bpmn-moddle": "^1.4.0"
"zeebe-bpmn-moddle": "^1.5.1"
},
"devDependencies": {
"bpmn-js": "^17.9.0",
"bpmn-js-element-templates": "^1.16.0",
"bpmn-js-properties-panel": "^5.21.0",
"bpmn-js-properties-panel": "^5.22.0",
"camunda-bpmn-js-behaviors": "^1.5.0",
"chai": "^4.4.1",
"cross-env": "^7.0.3",
Expand Down
55 changes: 54 additions & 1 deletion test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ describe('utils/error-messages', function() {
const errorMessage = getErrorMessage(report, 'Camunda Cloud', '8.3');

// then
console.log(errorMessage);
expect(errorMessage).to.equal('A collapsed <Ad Hoc Sub Process> is only supported by Camunda 8.4 or newer');
});

Expand Down Expand Up @@ -426,6 +425,33 @@ describe('utils/error-messages', function() {
});


it('should adjust (user task with zeebe:PriorityDefinition)', async function() {

// given
const executionPlatformVersion = '8.5';

const node = createElement('bpmn:UserTask', {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:PriorityDefinition', {
priority: '40'
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-priority-definition');

const report = await getLintError(node, rule, { version: executionPlatformVersion });

// when
const errorMessage = getErrorMessage(report, 'Camunda Cloud', executionPlatformVersion);

// then
expect(errorMessage).to.equal('A <User Task> with <Priority> is only supported by Camunda 8.6 or newer');
});


it('should adjust (start event with zeebe:FormDefinition)', async function() {

// given
Expand Down Expand Up @@ -1751,6 +1777,33 @@ describe('utils/error-messages', function() {
expect(errorMessage).to.equal('A <User Task> <Follow up date> must be an ISO 8601 date');
});


it('should adjust (priority)', async function() {

// given
const executionPlatformVersion = '8.6';

const node = createElement('bpmn:UserTask', {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:PriorityDefinition', {
priority: 'foo'
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/priority-definition');

const report = await getLintError(node, rule, { version: executionPlatformVersion });

// when
const errorMessage = getErrorMessage(report, 'Camunda Cloud', executionPlatformVersion);

// then
expect(errorMessage).to.equal('A <User Task> <Priority> must be an expression, or an integer between 0 and 100');
});

});


Expand Down
Loading

0 comments on commit 51717e8

Please sign in to comment.