Skip to content

Commit

Permalink
feat: support task listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
misiekhardcore committed Nov 12, 2024
1 parent 41f1ad6 commit 013f324
Show file tree
Hide file tree
Showing 11 changed files with 707 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to [bpmnlint-plugin-camunda-compat](https://github.com/camun

___Note:__ Yet to be released changes appear here._

* `DEPS`: bump `[email protected]`
* `FEAT`: support task listeners ([#181](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/181))
* `FEAT`: add `no-duplicate-task-listeners` rule
* `FEAT`: add `no-task-listeners` rule
* `FEAT`: add `task-listener` rule

# 2.27.0

* `FEAT`: add `zeebe-user-task` rule ([#179](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/179))
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const camundaCloud10Rules = withConfig({
'no-propagate-all-parent-variables': 'error',
'no-task-schedule': 'error',
'no-template': 'error',
'no-task-listeners': 'error',
'no-version-tag': 'error',
'no-zeebe-properties': 'error',
'no-zeebe-user-task': 'error',
Expand Down Expand Up @@ -94,8 +95,10 @@ const camundaCloud86Rules = withConfig({
}, { version: '8.6' });

const camundaCloud87Rules = withConfig({
...camundaCloud86Rules,
'zeebe-user-task': 'error'
...omit(camundaCloud86Rules, [ 'no-task-listeners' ]),
'zeebe-user-task': 'error',
'duplicate-task-listeners': 'error',
'task-listener': 'error'
}, { version: '8.7' });

const camundaPlatform719Rules = withConfig({
Expand Down Expand Up @@ -132,6 +135,7 @@ const rules = {
'connector-properties': './rules/camunda-cloud/connector-properties',
'duplicate-execution-listeners': './rules/camunda-cloud/duplicate-execution-listeners',
'duplicate-task-headers': './rules/camunda-cloud/duplicate-task-headers',
'duplicate-task-listeners': './rules/camunda-cloud/duplicate-task-listeners',
'error-reference': './rules/camunda-cloud/error-reference',
'escalation-boundary-event-attached-to-ref': './rules/camunda-cloud/escalation-boundary-event-attached-to-ref',
'escalation-reference': './rules/camunda-cloud/escalation-reference',
Expand All @@ -155,6 +159,7 @@ const rules = {
'no-propagate-all-parent-variables': './rules/camunda-cloud/no-propagate-all-parent-variables',
'no-signal-event-sub-process': './rules/camunda-cloud/no-signal-event-sub-process',
'no-task-schedule': './rules/camunda-cloud/no-task-schedule',
'no-task-listeners': './rules/camunda-cloud/no-task-listeners',
'no-template': './rules/camunda-cloud/no-template',
'no-version-tag': './rules/camunda-cloud/no-version-tag',
'no-zeebe-properties': './rules/camunda-cloud/no-zeebe-properties',
Expand All @@ -165,6 +170,7 @@ const rules = {
'signal-reference': './rules/camunda-cloud/signal-reference',
'start-event-form': './rules/camunda-cloud/start-event-form',
'subscription': './rules/camunda-cloud/subscription',
'task-listener': './rules/camunda-cloud/task-listener',
'task-schedule': './rules/camunda-cloud/task-schedule',
'timer': './rules/camunda-cloud/timer',
'user-task-definition': './rules/camunda-cloud/user-task-definition',
Expand Down
17 changes: 9 additions & 8 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 @@ -34,7 +34,7 @@
"modeler-moddle": "^0.2.0",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"zeebe-bpmn-moddle": "^1.6.0"
"zeebe-bpmn-moddle": "^1.7.0"
},
"dependencies": {
"@bpmn-io/feel-lint": "^1.2.0",
Expand Down
33 changes: 33 additions & 0 deletions rules/camunda-cloud/duplicate-task-listeners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const {
findExtensionElement,
hasDuplicatedPropertiesValues
} = require('../utils/element');

const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');

module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
const taskListeners = findExtensionElement(node, 'zeebe:TaskListeners');

if (!taskListeners) {
return;
}

const errors = hasDuplicatedTaskListeners(taskListeners, node);

if (errors && errors.length) {
reportErrors(node, reporter, errors);
}
}

return {
check
};
});

// helpers //////////
function hasDuplicatedTaskListeners(taskListeners, parentNode = null) {
return hasDuplicatedPropertiesValues(taskListeners, 'listeners', [ 'eventType', 'type' ], parentNode);
}
21 changes: 21 additions & 0 deletions rules/camunda-cloud/no-task-listeners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');

const { hasNoExtensionElement } = require('../utils/element');

const ALLOWED_VERSION = '8.7';

module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
const errors = hasNoExtensionElement(node, 'zeebe:TaskListeners', node, ALLOWED_VERSION);

if (errors && errors.length) {
reportErrors(node, reporter, errors);
}
}

return {
check
};
});
47 changes: 47 additions & 0 deletions rules/camunda-cloud/task-listener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { is } = require('bpmnlint-utils');

const {
findExtensionElement,
hasProperties,
hasExtensionElement
} = require('../utils/element');

const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');


module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
if (!is(node, 'bpmn:UserTask')) {
return;
}

let errors = hasExtensionElement(node, 'zeebe:UserTask', node);

if (errors && errors.length) {
reportErrors(node, reporter, errors);
}

const taskListeners = findExtensionElement(node, 'zeebe:TaskListeners');

if (!taskListeners) {
return;
}

const listeners = taskListeners.get('listeners');
errors = listeners.flatMap(listener => hasProperties(listener, {
type: {
required: true
}
}, node));

if (errors.length) {
reportErrors(node, reporter, errors);
}
}

return {
check
};
});
Loading

0 comments on commit 013f324

Please sign in to comment.