-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
394 additions
and
141 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
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,29 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
|
||
|
||
/** | ||
* Rule that reports missing Script format on bpmn:ScriptTask. | ||
* Script format can supports js or javascript | ||
*/ | ||
module.exports = function () { | ||
|
||
function check(node, reporter) { | ||
if (is(node, 'bpmn:ScriptTask')) { | ||
if (!node.scriptFormat) { | ||
return reporter.report(node.id, 'Script format must be defined'); | ||
} | ||
|
||
if (node.scriptFormat !== 'js' && node.scriptFormat !== 'javascript') { | ||
return reporter.report(node.id, 'Only `js/javascript` are supported script formats'); | ||
} | ||
|
||
if (!node.script) { | ||
reporter.report(node.id, 'Script must be defined'); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: 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,21 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
|
||
|
||
/** | ||
* Rule that reports missing Script format on bpmn:ScriptTask. | ||
* Script format can supports js or javascript | ||
*/ | ||
module.exports = function () { | ||
|
||
function check(node, reporter) { | ||
if (is(node, 'bpmn:ScriptTask') && (node.scriptFormat === 'js' || node.scriptFormat === 'javascript')) { | ||
if (node.script && !node.script.includes('next()')) { | ||
reporter.report(node.id, 'next() functions does not exist'); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: check | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
bpmnlint-plugin-custom/rules/service-task-httpRequest-error.js
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,34 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
const { findElement } = require('../utils'); | ||
|
||
/** | ||
* Rule that reports missing responseType on bpmn:ServiceTask. | ||
*/ | ||
module.exports = function () { | ||
|
||
function check(node, reporter) { | ||
if (is(node, 'bpmn:ServiceTask')) { | ||
const connector = findElement(node.extensionElements && node.extensionElements.values, 'camunda:Connector'); | ||
|
||
if (!connector || connector.connectorId !== 'httpRequest') { | ||
return; | ||
} | ||
|
||
const url = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'url'); | ||
const json = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'json'); | ||
const method = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'method'); | ||
|
||
if (!url) { | ||
reporter.report(node.id, 'Connector input parameter `url` must be defined'); | ||
} | ||
|
||
if (method && (method.value.toUpperCase() === 'POST' || method.value.toUpperCase() === 'PUT' || method.value.toUpperCase() === 'PATCH') && !json) { | ||
reporter.report(node.id, 'Connector input parameter `json` must be defined when `method` is POST, PUT or PATCH'); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: check | ||
}; | ||
}; |
28 changes: 28 additions & 0 deletions
28
bpmnlint-plugin-custom/rules/service-task-httpRequest-warn.js
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,28 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
const { findElement } = require('../utils'); | ||
|
||
/** | ||
* Rule that reports missing responseType on bpmn:ServiceTask. | ||
*/ | ||
module.exports = function () { | ||
|
||
function check(node, reporter) { | ||
if (is(node, 'bpmn:ServiceTask')) { | ||
const connector = findElement(node.extensionElements && node.extensionElements.values, 'camunda:Connector'); | ||
|
||
if (!connector || connector.connectorId !== 'httpRequest') { | ||
return; | ||
} | ||
|
||
const responseType = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'responseType'); | ||
|
||
if (!responseType) { | ||
reporter.report(node.id, 'Connector input parameter `responseType` is not defined'); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: check | ||
}; | ||
}; |
34 changes: 34 additions & 0 deletions
34
bpmnlint-plugin-custom/rules/service-task-onifyApiRequest-error.js
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,34 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
const { findElement } = require('../utils'); | ||
|
||
/** | ||
* Rule for onifyApiRequest and onifyElevatedApiRequest | ||
*/ | ||
module.exports = function () { | ||
|
||
function check(node, reporter) { | ||
if (is(node, 'bpmn:ServiceTask')) { | ||
const connector = findElement(node.extensionElements && node.extensionElements.values, 'camunda:Connector'); | ||
|
||
if (!connector || (connector.connectorId !== 'onifyApiRequest' && connector.connectorId !== 'onifyElevatedApiRequest')) { | ||
return; | ||
} | ||
|
||
const url = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'url'); | ||
const payload = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'payload'); | ||
const method = connector.inputOutput && connector.inputOutput.inputParameters && connector.inputOutput.inputParameters.find((input) => input.name === 'method'); | ||
|
||
if (!url) { | ||
reporter.report(node.id, 'Connector input parameter `url` must be defined'); | ||
} | ||
|
||
if (method && (method.value.toUpperCase() === 'POST' || method.value.toUpperCase() === 'PUT' || method.value.toUpperCase() === 'PATCH') && !payload) { | ||
reporter.report(node.id, 'Connector input parameter `payload` must be defined when `method` is POST, PUT or PATCH'); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: 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
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,12 @@ | ||
const { | ||
is | ||
} = require('bpmnlint-utils'); | ||
|
||
module.exports = { | ||
findElement, | ||
}; | ||
|
||
function findElement(elements, name) { | ||
if (!elements || !elements.length) return false; | ||
return elements.find((element) => is(element, name)); | ||
} |
Oops, something went wrong.