-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
task-schedule
and no-task-schedule
rules
Closes #84
- Loading branch information
1 parent
6612f36
commit 9bf5c8c
Showing
13 changed files
with
477 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { hasNoExtensionElement } = require('./utils/element'); | ||
|
||
const { reportErrors } = require('./utils/reporter'); | ||
|
||
const { skipInNonExecutableProcess } = require('./utils/rule'); | ||
|
||
module.exports = skipInNonExecutableProcess(function() { | ||
function check(node, reporter) { | ||
const errors = hasNoExtensionElement(node, 'zeebe:TaskSchedule', node, '8.2'); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
|
||
const { isDefined } = require('min-dash'); | ||
|
||
const { | ||
findExtensionElement, | ||
hasExpression | ||
} = require('./utils/element'); | ||
|
||
const { validateDate: validateISO8601Date } = require('./utils/iso8601'); | ||
|
||
const { reportErrors } = require('./utils/reporter'); | ||
|
||
const { skipInNonExecutableProcess } = require('./utils/rule'); | ||
|
||
module.exports = skipInNonExecutableProcess(function() { | ||
function check(node, reporter) { | ||
if (!is(node, 'bpmn:UserTask')) { | ||
return; | ||
} | ||
|
||
const taskSchedule = findExtensionElement(node, 'zeebe:TaskSchedule'); | ||
|
||
if (!taskSchedule) { | ||
return; | ||
} | ||
|
||
const dueDate = taskSchedule.get('dueDate'); | ||
|
||
let errors = []; | ||
|
||
if (isDefined(dueDate)) { | ||
errors = [ | ||
...errors, | ||
...hasExpression(taskSchedule, 'dueDate', { | ||
allowed: date => isValidDate(date) | ||
}, node) | ||
]; | ||
} | ||
|
||
const followUpDate = taskSchedule.get('followUpDate'); | ||
|
||
if (isDefined(followUpDate)) { | ||
errors = [ | ||
...errors, | ||
...hasExpression(taskSchedule, 'followUpDate', { | ||
allowed: date => isValidDate(date) | ||
}, node) | ||
]; | ||
} | ||
|
||
if (errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); | ||
|
||
function isValidDate(value) { | ||
return isExpression(value) || validateISO8601Date(value); | ||
} | ||
|
||
function isExpression(value) { | ||
return value.startsWith('='); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/camunda-cloud/integration/no-task-schedule-errors.bpmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0q117j9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.8.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:userTask id="UserTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:TaskSchedule dueDate="2022-09-21T00:00:00Z" followUpDate="2022-09-21T00:00:00Z" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="Activity_1hsskmv_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="160" y="77" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0q117j9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.8.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:userTask id="UserTask_1" /> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="Activity_1hsskmv_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="160" y="77" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const { expect } = require('chai'); | ||
|
||
const Linter = require('bpmnlint/lib/linter'); | ||
|
||
const NodeResolver = require('bpmnlint/lib/resolver/node-resolver'); | ||
|
||
const { readModdle } = require('../../helper'); | ||
|
||
const versions = [ | ||
'1.0', | ||
'1.1', | ||
'1.2', | ||
'1.3', | ||
'8.0', | ||
'8.1' | ||
]; | ||
|
||
describe('integration - no-task-schedule', function() { | ||
|
||
versions.forEach(function(version) { | ||
|
||
let linter; | ||
|
||
beforeEach(function() { | ||
linter = new Linter({ | ||
config: { | ||
extends: `plugin:camunda-compat/camunda-cloud-${ version.replace('.', '-') }` | ||
}, | ||
resolver: new NodeResolver() | ||
}); | ||
}); | ||
|
||
|
||
describe(`Camunda Cloud ${ version }`, function() { | ||
|
||
describe('no errors', function() { | ||
|
||
it('should not have errors', async function() { | ||
|
||
// given | ||
const { root } = await readModdle('test/camunda-cloud/integration/no-task-schedule.bpmn'); | ||
|
||
// when | ||
const reports = await linter.lint(root); | ||
|
||
// then | ||
expect(reports[ 'camunda-compat/no-task-schedule' ]).not.to.exist; | ||
}); | ||
|
||
}); | ||
|
||
|
||
describe('errors', function() { | ||
|
||
it('should have errors', async function() { | ||
|
||
// given | ||
const { root } = await readModdle('test/camunda-cloud/integration/no-task-schedule-errors.bpmn'); | ||
|
||
// when | ||
const reports = await linter.lint(root); | ||
|
||
// then | ||
expect(reports[ 'camunda-compat/no-task-schedule' ]).to.exist; | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0q117j9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.8.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:userTask id="UserTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:TaskSchedule dueDate="invalid" followUpDate="invalid" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="Activity_1hsskmv_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="160" y="77" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0q117j9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.8.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:userTask id="UserTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:TaskSchedule dueDate="2022-09-21T00:00:00Z" followUpDate="2022-09-21T00:00:00Z" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="Activity_1hsskmv_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="160" y="77" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { expect } = require('chai'); | ||
|
||
const Linter = require('bpmnlint/lib/linter'); | ||
|
||
const NodeResolver = require('bpmnlint/lib/resolver/node-resolver'); | ||
|
||
const { readModdle } = require('../../helper'); | ||
|
||
const versions = [ | ||
'8.2' | ||
]; | ||
|
||
describe('integration - task schedule', function() { | ||
|
||
versions.forEach(function(version) { | ||
|
||
let linter; | ||
|
||
beforeEach(function() { | ||
linter = new Linter({ | ||
config: { | ||
extends: `plugin:camunda-compat/camunda-cloud-${ version.replace('.', '-') }` | ||
}, | ||
resolver: new NodeResolver() | ||
}); | ||
}); | ||
|
||
|
||
describe(`Camunda Cloud ${ version }`, function() { | ||
|
||
describe('no errors', function() { | ||
|
||
it('should not have errors', async function() { | ||
|
||
// given | ||
const { root } = await readModdle('test/camunda-cloud/integration/task-schedule.bpmn'); | ||
|
||
// when | ||
const reports = await linter.lint(root); | ||
|
||
// then | ||
expect(reports[ 'camunda-compat/task-schedule' ]).not.to.exist; | ||
}); | ||
|
||
}); | ||
|
||
|
||
describe('errors', function() { | ||
|
||
it('should have errors', async function() { | ||
|
||
// given | ||
const { root } = await readModdle('test/camunda-cloud/integration/task-schedule-errors.bpmn'); | ||
|
||
// when | ||
const reports = await linter.lint(root); | ||
|
||
// then | ||
expect(reports[ 'camunda-compat/task-schedule' ]).to.exist; | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
Oops, something went wrong.