node-red-contrib-agilite
Advanced tools
Comparing version 6.1.1 to 6.2.0
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -22,4 +20,7 @@ function Adhoc(config) { | ||
var url = ""; | ||
var action = ""; | ||
var method = "get"; | ||
var data = null; | ||
var headers = {}; | ||
var params = {}; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
@@ -87,8 +88,2 @@ | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
dateTimeValue = Mustache.render(dateTimeValue, msg); | ||
@@ -101,29 +96,59 @@ formatKey = Mustache.render(formatKey, msg); | ||
//Perform a HTTP Post to Agilit-e for Numbering, passing the body content | ||
var axios = require("axios"); | ||
headers = { | ||
"api-key": apiKey, | ||
"Content-Type": "text/plain" | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers["log-process-id"] = logProcessId; | ||
switch (config.actionType) { | ||
case "1": //Encode XML | ||
action = "encodeXML"; | ||
method = "post"; | ||
url = url + "/utils/encodeXML"; | ||
break; | ||
case "2": //Convert HTML to JSON | ||
action = "html2json"; | ||
method = "post"; | ||
url = url + "/utils/html2json"; | ||
break; | ||
case "3": //Generate PDF | ||
action = "generatePDF"; | ||
method = "post"; | ||
headers["Content-Type"] = "application/json"; | ||
url = url + "/utils/generatePDF"; | ||
break; | ||
case "4": //Generate UUID | ||
action = "generateUUID"; | ||
url = url + "/utils/generateUUID"; | ||
break; | ||
case "5": //Format Dated/Time Value | ||
action = "formatDateTime"; | ||
headers["date-time-value"] = dateTimeValue; | ||
headers["format-key"] = formatKey; | ||
url = url + "/utils/formatDateTime"; | ||
break; | ||
case "6": //Decode XML | ||
action = "decodeXML"; | ||
method = "post"; | ||
url = url + "/utils/decodeXML"; | ||
break; | ||
case "7": //XML to JS | ||
action = "XMLToJS"; | ||
method = "post"; | ||
url = url + "/utils/XMLToJS"; | ||
break; | ||
case "8": //JS to XML | ||
action = "JSToXML"; | ||
method = "post"; | ||
headers["Content-Type"] = "application/json"; | ||
url = url + "/utils/JSToXML"; | ||
break; | ||
} | ||
params = { | ||
maxContentLength: 99999999, | ||
method, | ||
url, | ||
headers, | ||
data | ||
}; | ||
node.status({ | ||
@@ -135,5 +160,4 @@ fill: "yellow", | ||
agilite.Utils[action](action !== "formatDateTime" ? data : dateTimeValue, formatKey) | ||
.then(function (response){ | ||
axios.request(params) | ||
.then(function (response) { | ||
msg.agilite.message = response.data.errorMessage; | ||
@@ -197,3 +221,3 @@ | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -200,0 +224,0 @@ } |
369
bpm/bpm.js
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -30,72 +28,11 @@ function Bpm(config) { | ||
var visibleObjects = config.excludeVisibleObjects; | ||
var recordId = config.recordId; | ||
var relevantUser = config.relevantUser; | ||
var profileKeys = config.profileKeys; | ||
var comments = ""; | ||
var url = ""; | ||
var requestType = ""; | ||
var data = {}; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
// Function that is called inside .then of requests | ||
var reqSuccess = function(response){ | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}; | ||
// Function that is used inside the .catch of requests | ||
var reqCatch = function(error){ | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
url = serverConfig.server; | ||
@@ -111,2 +48,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -167,2 +110,14 @@ if (msg.agilite.apiKey !== "") { | ||
if (msg.agilite.bpm.recordId) { | ||
if (msg.agilite.bpm.recordId !== "") { | ||
recordId = msg.agilite.bpm.recordId; | ||
} | ||
} | ||
if (msg.agilite.bpm.relevantUser) { | ||
if (msg.agilite.bpm.relevantUser !== "") { | ||
relevantUser = msg.agilite.bpm.relevantUser; | ||
} | ||
} | ||
if (msg.agilite.bpm.profileKeys) { | ||
@@ -174,3 +129,3 @@ if (msg.agilite.bpm.profileKeys !== "") { | ||
} | ||
} | ||
} | ||
@@ -225,9 +180,16 @@ if (apiKey === "") { | ||
case "3": //Get Record State | ||
if (profileKeys === "") { | ||
if (profileKey === "") { | ||
success = false; | ||
errorMessage = "No Profile Keys found"; | ||
errorMessage = "No Profile Key found"; | ||
} | ||
break; | ||
case "4": //Get By Profile Key | ||
case "4": //Get By Id | ||
if (recordId === "") { | ||
success = false; | ||
errorMessage = "No Record Id found"; | ||
} | ||
break; | ||
case "5": //Get By Profile Key | ||
if (profileKey === "") { | ||
@@ -239,4 +201,11 @@ success = false; | ||
break; | ||
case "5": //Get Active Steps | ||
case "6": //Get Active Users | ||
case "6": //Get Relevant Records | ||
if (relevantUser === "") { | ||
success = false; | ||
errorMessage = "No Relevant User found"; | ||
} | ||
break; | ||
case "7": //Get Active Steps | ||
case "8": //Get Active Users | ||
if (profileKey === "") { | ||
@@ -257,9 +226,3 @@ success = false; | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
// Format Mustache properties | ||
//Mustache | ||
profileKey = Mustache.render(profileKey, msg); | ||
@@ -273,11 +236,6 @@ currentUser = Mustache.render(currentUser, msg); | ||
relevantUsers = Mustache.render(relevantUsers, msg); | ||
recordId = Mustache.render(recordId, msg); | ||
relevantUser = Mustache.render(relevantUser, msg); | ||
profileKeys = Mustache.render(profileKeys, msg); | ||
// Finalize array properties | ||
profileKeys = profileKeys.split(','); | ||
bpmRecordIds = bpmRecordIds.split(','); | ||
stepNames = stepNames.split(','); | ||
responsibleUsers = responsibleUsers.split(','); | ||
relevantUsers = relevantUsers.split(','); | ||
//Create msg.agilite if it's null so we can store the result | ||
@@ -287,2 +245,69 @@ if (!msg.agilite) | ||
//Perform a HTTP Post to Agilit-e, passing the body content | ||
var axios = require("axios"); | ||
requestType = "get"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers.headers["log-process-id"] = logProcessId; | ||
switch (config.actionType) { | ||
case "1": //Register BPM Record | ||
url = url + "/bpm/registerBPMRecord"; | ||
headers.headers["process-key"] = profileKey; | ||
headers.headers["current-user"] = currentUser; | ||
break; | ||
case "2": //Execute | ||
url = url + "/bpm/execute"; | ||
headers.headers["process-key"] = profileKey; | ||
headers.headers["bpm-record-id"] = bpmRecordId; | ||
headers.headers["option-selected"] = optionSelected; | ||
headers.headers["current-user"] = currentUser; | ||
requestType = "post"; | ||
break; | ||
case "3": //Get Record State | ||
url = url + "/bpm/getRecordState"; | ||
headers.headers["process-key"] = profileKey; | ||
headers.headers["bpm-record-ids"] = bpmRecordIds; | ||
headers.headers["responsible-users"] = responsibleUsers; | ||
headers.headers["step-names"] = stepNames; | ||
headers.headers["relevant-users"] = relevantUsers; | ||
headers.headers["include-history"] = history; | ||
headers.headers["include-step-options"] = stepOptions; | ||
headers.headers["include-visible-objects"] = visibleObjects; | ||
break; | ||
case "4": //Get By Id | ||
url = url + "/bpm/data/getById"; | ||
headers.headers["record-id"] = recordId; | ||
break; | ||
case "5": //Get By Profile Key | ||
url = url + "/bpm/data/getByProfileKey"; | ||
headers.headers["profile-key"] = profileKey; | ||
break; | ||
case "6": //Get Relevant Records | ||
url = url + "/bpm/getRelevantRecords"; | ||
headers.headers["relevant-user"] = relevantUser; | ||
headers.headers["process-keys"] = profileKeys; | ||
headers.headers["include-history"] = history; | ||
headers.headers["include-step-options"] = stepOptions; | ||
headers.headers["include-visible-objects"] = visibleObjects; | ||
break; | ||
case "7": //Get Active Steps | ||
url = url + "/bpm/getActiveSteps"; | ||
headers.headers["process-key"] = profileKey; | ||
break; | ||
case "8": //Get Active Users | ||
url = url + "/bpm/getActiveUsers"; | ||
headers.headers["process-key"] = profileKey; | ||
break; | ||
} | ||
node.status({ | ||
@@ -294,62 +319,134 @@ fill: "yellow", | ||
switch (config.actionType) { | ||
case "1": //Register BPM Record | ||
agilite.BPM.registerBPMRecord(profileKey, currentUser) | ||
switch (requestType) { | ||
case "get": | ||
axios.get(url, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "2": //Execute | ||
agilite.BPM.execute(profileKey, bpmRecordId, optionSelected, currentUser, comments, data) | ||
case "post": | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
break; | ||
case "3": //Get Record State | ||
agilite.BPM.getRecordState(profileKeys, bpmRecordIds, stepNames, responsibleUsers, relevantUsers, history, stepOptions, visibleObjects) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
break; | ||
case "4": //Get By Profile Key | ||
agilite.BPM.getByProfileKey(profileKey) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.data.success) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "5": //Get Active Steps | ||
agilite.BPM.getActiveSteps(profileKey) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
break; | ||
case "6": //Get Active Users | ||
agilite.BPM.getActiveUsers(profileKey) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
break; | ||
} | ||
}); | ||
} | ||
break; | ||
} | ||
}); | ||
} | ||
RED.nodes.registerType("bpm", Bpm); | ||
} |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -23,2 +21,3 @@ function IoEConnectors(config) { | ||
var url = ""; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
@@ -36,2 +35,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -95,8 +100,2 @@ if (msg.agilite.apiKey !== "") { | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
@@ -107,2 +106,21 @@ if (!msg.agilite) { | ||
//Perform a HTTP Post to Agilit-e for Data Mapping, passing the body content | ||
var axios = require("axios"); | ||
url = url + "/connectors/execute"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"profile-key": profileKey, | ||
"route-key": routeKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) { | ||
headers.headers["log-process-id"] = logProcessId; | ||
} | ||
node.status({ | ||
@@ -114,3 +132,3 @@ fill: "yellow", | ||
agilite.Connectors.execute(profileKey, routeKey, data) | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
@@ -137,7 +155,5 @@ msg.agilite.message = response.data.errorMessage; | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
@@ -144,0 +160,0 @@ fill: "red", |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -22,2 +20,3 @@ function DataMapping(config) { | ||
var url = ""; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
@@ -35,2 +34,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -80,8 +85,24 @@ if (msg.agilite.apiKey !== "") { | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
if (!msg.agilite) { | ||
msg.agilite = {}; | ||
} | ||
//Perform a HTTP Post to Agilit-e for Data Mapping, passing the body content | ||
var axios = require("axios"); | ||
url = url + "/datamappings/execute"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"profile-key": profileKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers.headers["log-process-id"] = logProcessId; | ||
node.status({ | ||
@@ -93,4 +114,6 @@ fill: "yellow", | ||
agilite.DataMappings.execute(profileKey, data) | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
@@ -114,7 +137,5 @@ switch (node.fieldType) { | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
@@ -139,5 +160,4 @@ fill: "red", | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
msg.agilite.messages = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
@@ -144,0 +164,0 @@ fill: "red", |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -19,72 +17,11 @@ function Files(config) { | ||
var apiKey = ""; | ||
var actionType = ""; | ||
var responseType = ""; | ||
var recordId = config.recordId; | ||
var data = {}; | ||
var url = ""; | ||
var requestType = ""; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
// Function that is called inside .then of requests | ||
var reqSuccess = function(response){ | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}; | ||
// Function that is used inside the .catch of requests | ||
var reqCatch = function(error){ | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
url = serverConfig.server; | ||
@@ -100,2 +37,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -158,8 +101,2 @@ if (msg.agilite.apiKey !== "") { | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
@@ -170,2 +107,33 @@ if (!msg.agilite) { | ||
//Perform a HTTP Post to Agilit-e for Numbering, passing the body content | ||
var axios = require("axios"); | ||
requestType = "get"; | ||
var httpConfig = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"record-id": recordId, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
httpConfig.headers["log-process-id"] = logProcessId; | ||
switch (config.actionType) { | ||
case "1": //Get File | ||
url = url + "/files"; | ||
httpConfig.responseType = responseType; | ||
break; | ||
case "2": //Get File Name | ||
url = url + "/files/getFileName"; | ||
break; | ||
case "3": //Delete File | ||
url = url + "/files"; | ||
requestType = "delete" | ||
break; | ||
} | ||
node.status({ | ||
@@ -177,30 +145,150 @@ fill: "yellow", | ||
switch (config.actionType) { | ||
case "1": //Get File | ||
agilite.Files.getFile(recordId, responseType) | ||
switch (requestType) { | ||
case "get": | ||
axios.get(url, httpConfig) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
if (config.actionType === "1") { | ||
msg.agilite.message = ""; | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "2": //Get File Name | ||
agilite.Files.getFileName(recordId) | ||
case "delete": | ||
axios.delete(url, httpConfig) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "3": //Delete File | ||
agilite.Files.deleteFile(recordId) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
break; | ||
} | ||
@@ -207,0 +295,0 @@ }); |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -26,68 +24,7 @@ function Keywords(config) { | ||
var url = ""; | ||
var requestType = ""; | ||
var data = {}; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
// Function that is called inside .then of requests | ||
var reqSuccess = function(response){ | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}; | ||
// Function that is used inside the .catch of requests | ||
var reqCatch = function(error){ | ||
console.log(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
url = serverConfig.server; | ||
@@ -103,2 +40,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -240,68 +183,274 @@ if (msg.agilite.apiKey !== "") { | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
if (!msg.agilite) | ||
msg.agilite = {}; | ||
node.status({ | ||
fill: "yellow", | ||
text: "Running", | ||
shape: "ring" | ||
}); | ||
//Perform a HTTP Post to Agilit-e, passing the body content | ||
var axios = require("axios"); | ||
requestType = "get"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers.headers["log-process-id"] = logProcessId; | ||
switch (config.actionType) { | ||
case "1": //Get Keywords By Profile Key | ||
agilite.Keywords.getByProfileKey(profileKey, sortBy) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
url = url + "/keywords/getByProfileKey"; | ||
headers.headers["profile-key"] = profileKey; | ||
break; | ||
case "2": //Get Profile Keys By Group | ||
agilite.Keywords.getProfileKeysByGroup(groupName, sortBy) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
url = url + "/keywords/getProfileKeysByGroup"; | ||
headers.headers["group-name"] = groupName; | ||
break; | ||
case "3": //Get Keyword Value by Label | ||
agilite.Keywords.getValueByLabel(profileKey, labelKey) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
url = url + "/keywords/getValueByLabel"; | ||
headers.headers["profile-key"] = profileKey; | ||
headers.headers["label-key"] = labelKey; | ||
break; | ||
case "4": //Get Keyword Label by Value | ||
agilite.Keywords.getLabelByValue(profileKey, valueKey) | ||
url = url + "/keywords/getLabelByValue"; | ||
headers.headers["profile-key"] = profileKey; | ||
headers.headers["value-key"] = valueKey; | ||
break; | ||
case "7": //Get Keyword Record By Id | ||
url = url + "/keywords/data/getById"; | ||
headers.headers["record-id"] = recordId; | ||
break; | ||
case "5": //Create Keyword Record | ||
url = url + "/keywords/data"; | ||
requestType = "post"; | ||
break; | ||
case "6": //Update Keyword Record | ||
url = url + "/keywords/data"; | ||
headers.headers["record-id"] = recordId; | ||
requestType = "put"; | ||
break; | ||
} | ||
node.status({ | ||
fill: "yellow", | ||
text: "Running", | ||
shape: "ring" | ||
}); | ||
switch (requestType) { | ||
case "get": | ||
axios.get(url, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if(error.response.data){ | ||
msg.agilite.message = error.response.data.errorMessage; | ||
}else{ | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "5": //Create Keyword Record | ||
agilite.Keywords.postData(data) | ||
case "post": | ||
if(data.data.groupName && data.data.groupName !== ""){ | ||
var groupName = data.data.groupName; | ||
function capitalizeFirstLetter(groupName) { | ||
return groupName.charAt(0).toUpperCase() + groupName.slice(1); | ||
} | ||
data.data.groupName = capitalizeFirstLetter(data.data.groupName); | ||
} | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if(error.response.data){ | ||
msg.agilite.message = error.response.data.errorMessage; | ||
}else{ | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "6": //Update Keyword Record | ||
agilite.Keywords.putData(recordId ,data) | ||
case "put": | ||
if(data.data.groupName && data.data.groupName !== ""){ | ||
var groupName = data.data.groupName; | ||
function capitalizeFirstLetter(groupName) { | ||
return groupName.charAt(0).toUpperCase() + groupName.slice(1); | ||
} | ||
data.data.groupName = capitalizeFirstLetter(data.data.groupName); | ||
} | ||
axios.put(url, data, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if(error.response.data){ | ||
msg.agilite.message = error.response.data.errorMessage; | ||
}else{ | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
@@ -308,0 +457,0 @@ } |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -22,2 +20,3 @@ function Numbering(config) { | ||
var data = {}; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
@@ -35,2 +34,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -80,8 +85,2 @@ if (msg.agilite.apiKey !== "") { | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
@@ -91,2 +90,19 @@ if (!msg.agilite) | ||
//Perform a HTTP Post to Agilit-e for Numbering, passing the body content | ||
var axios = require("axios"); | ||
url = url + "/numbering/generate"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"profile-key": profileKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers.headers["log-process-id"] = logProcessId; | ||
node.status({ | ||
@@ -98,4 +114,6 @@ fill: "yellow", | ||
agilite.Numbering.generate(profileKey, null, data) | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
@@ -102,0 +120,0 @@ switch (node.fieldType) { |
{ | ||
"_from": "node-red-contrib-agilite@6.1.0", | ||
"_id": "node-red-contrib-agilite@6.1.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-bittYTSpH/AQiX0Wndvwq+TT+08GaPgh11Hu+adkblRw5YmZ5z16ZfxDpHAZb3hKkTvMSWjU9N5O3amoTlu3yw==", | ||
"_location": "/node-red-contrib-agilite", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "node-red-contrib-agilite@6.1.0", | ||
"name": "node-red-contrib-agilite", | ||
"escapedName": "node-red-contrib-agilite", | ||
"rawSpec": "6.1.0", | ||
"saveSpec": null, | ||
"fetchSpec": "6.1.0" | ||
"name": "node-red-contrib-agilite", | ||
"license": "MIT", | ||
"version": "6.2.0", | ||
"description": "Node-RED nodes to integrate with Agilit-e cloud or Agilit-e on-prem", | ||
"homepage": "https://agilite.io", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/agilitehub/node-red-modules/node-red-contrib-agilite" | ||
}, | ||
"_requiredBy": [ | ||
"/" | ||
], | ||
"_resolved": "https://registry.npmjs.org/node-red-contrib-agilite/-/node-red-contrib-agilite-6.1.0.tgz", | ||
"_shasum": "324eaa6126f8b42ee68fd44eda1e10253ca5e01b", | ||
"_spec": "node-red-contrib-agilite@6.1.0", | ||
"_where": "/Users/armandsmit/Documents/SourceTree/agilite/agilite-node-red", | ||
"author": { | ||
"name": "Agilit-e" | ||
}, | ||
"bundleDependencies": false, | ||
"bugs": { | ||
"url": "https://github.com/agilitehub/node-red-modules/issues", | ||
"email": "support@agilite.io" | ||
}, | ||
"author": "Agilit-e", | ||
"contributors": [ | ||
@@ -42,9 +29,5 @@ { | ||
"dependencies": { | ||
"agilite": "6.1.1", | ||
"agilite": "6.1.6", | ||
"axios": "0.18.0" | ||
}, | ||
"version": "6.1.1", | ||
"deprecated": false, | ||
"description": "Node-RED nodes to integrate with Agilit-e cloud or Agilit-e on-prem", | ||
"homepage": "https://portal.agilite.io", | ||
"keywords": [ | ||
@@ -73,4 +56,2 @@ "node-red", | ||
], | ||
"license": "MIT", | ||
"name": "node-red-contrib-agilite", | ||
"node-red": { | ||
@@ -90,2 +71,2 @@ "nodes": { | ||
} | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -25,70 +23,9 @@ function Roles(config) { | ||
var responsibleUsers = config.responsibleUsers; | ||
var includeHidden = ""; | ||
var url = ""; | ||
var requestType = ""; | ||
var data = {}; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
// Function that is called inside .then of requests | ||
var reqSuccess = function(response){ | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}; | ||
// Function that is used inside the .catch of requests | ||
var reqCatch = function(error){ | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
url = serverConfig.server; | ||
@@ -152,2 +89,8 @@ | ||
} | ||
if (msg.agilite.roles.includeHidden) { | ||
if (msg.agilite.roles.includeHidden !== "") { | ||
includeHidden = msg.agilite.roles.includeHidden; | ||
} | ||
} | ||
} | ||
@@ -184,2 +127,10 @@ } | ||
if (includeHidden === "") { | ||
includeHidden = config.includeHidden; | ||
if (includeHidden === "") { | ||
includeHidden = "false"; | ||
} | ||
} | ||
//Mustache | ||
@@ -193,7 +144,2 @@ roleName = Mustache.render(roleName, msg); | ||
// Finalize array properties | ||
roleName = roleName.split(','); | ||
conditionalLevels = conditionalLevels.split(','); | ||
responsibleUsers = responsibleUsers.split(','); | ||
//We need a apiKey, key and data to proceed | ||
@@ -208,3 +154,3 @@ if (apiKey === "") { | ||
switch (config.actionType) { | ||
case "3": //Get Role | ||
case "2": //Get Role | ||
if (roleName === "") { | ||
@@ -216,3 +162,3 @@ success = false; | ||
break; | ||
case "2": //Get Assigned Roles | ||
case "3": //Get Assigned Roles | ||
if (processKey === "") { | ||
@@ -230,3 +176,3 @@ success = false; | ||
break; | ||
case "1": //Assign Role | ||
case "4": //Assign Role | ||
if (processKey === "") { | ||
@@ -259,8 +205,2 @@ success = false; | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
@@ -270,2 +210,45 @@ if (!msg.agilite) | ||
//Perform a HTTP Post to Agilit-e, passing the body content | ||
var axios = require("axios"); | ||
requestType = "get"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers.headers["log-process-id"] = logProcessId; | ||
switch (config.actionType) { | ||
case "1": //Get All Roles | ||
url = url + "/roles/data"; | ||
headers.headers["include-hidden"] = includeHidden; | ||
break; | ||
case "2": //Get Role | ||
requestType = "post"; | ||
url = url + "/roles/getRole"; | ||
headers.headers["role-names"] = roleName; | ||
headers.headers["conditional-levels"] = conditionalLevels; | ||
break; | ||
case "3": //Get Assigned Roles | ||
url = url + "/roles/getAssignedRoles"; | ||
headers.headers["process-key"] = processKey; | ||
headers.headers["bpm-record-id"] = bpmRecordId; | ||
headers.headers["role-name"] = roleName; | ||
break; | ||
case "4": //Assign Role | ||
url = url + "/roles/assignRole"; | ||
headers.headers["process-key"] = processKey; | ||
headers.headers["bpm-record-id"] = bpmRecordId; | ||
headers.headers["current-user"] = currentUser; | ||
headers.headers["responsible-users"] = responsibleUsers; | ||
headers.headers["role-name"] = roleName; | ||
break; | ||
} | ||
node.status({ | ||
@@ -277,29 +260,129 @@ fill: "yellow", | ||
switch (config.actionType) { | ||
case "3": //Get Role | ||
agilite.Roles.getRole(roleName, conditionalLevels, data) | ||
switch (requestType) { | ||
case "get": | ||
axios.get(url, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
case "2": //Get Assigned Roles | ||
agilite.Roles.getAssignedRoles(processKey, bpmRecordId, roleName) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
}); | ||
break; | ||
case "1": //Assign Role | ||
agilite.Roles.assignRole(processKey, bpmRecordId, roleName, currentUser, responsibleUsers) | ||
case "post": | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
reqSuccess(response); | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
switch (node.fieldType) { | ||
case "msg": | ||
RED.util.setMessageProperty(msg, node.field, response.data); | ||
break; | ||
case "flow": | ||
node.context().flow.set(node.field, response.data); | ||
break; | ||
case "global": | ||
node.context().global.set(node.field, response.data); | ||
break; | ||
} | ||
node.status({ | ||
fill: "green", | ||
text: "Success", | ||
shape: "ring" | ||
}); | ||
node.send(msg); | ||
} else { | ||
msg.payload = {}; | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
reqCatch(error); | ||
msg.payload = {}; | ||
if (error.response.data) { | ||
msg.agilite.message = error.response.data.errorMessage; | ||
} else { | ||
msg.agilite.message = "Unknown Error Occurred"; | ||
} | ||
node.status({ | ||
fill: "red", | ||
text: "Error", | ||
shape: "ring" | ||
}); | ||
if (failFlow) { | ||
node.error(msg.agilite.message, msg); | ||
} else { | ||
node.send(msg); | ||
} | ||
}); | ||
break; | ||
@@ -306,0 +389,0 @@ } |
@@ -1,3 +0,1 @@ | ||
const Agilite = require('agilite'); | ||
module.exports = function (RED) { | ||
@@ -22,2 +20,3 @@ function Templates(config) { | ||
var data = {}; | ||
var logProcessId = null; | ||
var failFlow = config.failFlow; | ||
@@ -35,2 +34,8 @@ | ||
if (msg.agilite) { | ||
if (msg.agilite.logProcessId) { | ||
if (msg.agilite.logProcessId !== "") { | ||
logProcessId = msg.agilite.logProcessId; | ||
} | ||
} | ||
if (msg.agilite.apiKey) { | ||
@@ -80,8 +85,2 @@ if (msg.agilite.apiKey !== "") { | ||
// Create New instance of Agilite Module that will be performing requests | ||
const agilite = new Agilite({ | ||
apiServerUrl: url, | ||
apiKey | ||
}); | ||
//Create msg.agilite if it's null so we can store the result | ||
@@ -92,2 +91,19 @@ if (!msg.agilite) { | ||
//Perform a HTTP Post to Agilit-e for Numbering, passing the body content | ||
var axios = require("axios"); | ||
url = url + "/templates/execute"; | ||
var headers = { | ||
maxContentLength: 99999999, | ||
headers: { | ||
"api-key": apiKey, | ||
"profile-key": profileKey, | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
//Check if we need to pass a Log Process Id | ||
if (logProcessId) | ||
headers.headers["log-process-id"] = logProcessId; | ||
node.status({ | ||
@@ -99,4 +115,6 @@ fill: "yellow", | ||
agilite.Templates.execute(profileKey ,data) | ||
axios.post(url, data, headers) | ||
.then(function (response) { | ||
msg.agilite.message = response.data.errorMessage; | ||
if (response.status === 200) { | ||
@@ -103,0 +121,0 @@ switch (node.fieldType) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
0
206083
36
2331
2
+ Addedagilite@6.1.6(transitive)
- Removedagilite@6.1.1(transitive)
Updatedagilite@6.1.6