Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@5minds/node-red-contrib-processcube

Package Overview
Dependencies
Maintainers
0
Versions
249
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@5minds/node-red-contrib-processcube - npm Package Compare versions

Comparing version 1.2.3-develop-dd0a75-m1ypzayt to 1.2.3-feature-0915a5-m22z2faz

126

externaltask-input.js

@@ -19,3 +19,3 @@ const EventEmitter = require('node:events');

const engine = RED.nodes.getNode(config.engine);
const engine = RED.nodes.getNode(config.engine);

@@ -36,79 +36,81 @@ const client = engine.engineClient;

client.externalTasks
.subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
const saveHandleCallback = (data, callback) => {
try {
callback(data);
} catch (error) {
node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
}
};
const etwCallback = async (payload, externalTask) => {
const saveHandleCallback = (data, callback) => {
try {
callback(data);
} catch (error) {
node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
}
};
return await new Promise((resolve, reject) => {
const handleFinishTask = (msg) => {
let result = RED.util.encodeObject(msg.payload);
return await new Promise((resolve, reject) => {
const handleFinishTask = (msg) => {
let result = RED.util.encodeObject(msg.payload);
node.log(
`handle finish task *flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`,
);
node.log(
`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`
);
if (externalTask.flowNodeInstanceId) {
delete started_external_tasks[externalTask.flowNodeInstanceId];
}
if (externalTask.flowNodeInstanceId) {
delete started_external_tasks[externalTask.flowNodeInstanceId];
}
showStatus(node, Object.keys(started_external_tasks).length);
showStatus(node, Object.keys(started_external_tasks).length);
//resolve(result);
saveHandleCallback(result, resolve);
};
//resolve(result);
saveHandleCallback(result, resolve);
};
const handleErrorTask = (msg) => {
node.log(
`handle error task *flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`,
);
const handleErrorTask = (msg) => {
node.log(
`handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`
);
if (externalTask.flowNodeInstanceId) {
delete started_external_tasks[externalTask.flowNodeInstanceId];
}
if (externalTask.flowNodeInstanceId) {
delete started_external_tasks[externalTask.flowNodeInstanceId];
}
showStatus(node, Object.keys(started_external_tasks).length);
showStatus(node, Object.keys(started_external_tasks).length);
// TODO: with reject, the default error handling is proceed
// SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
// reject(result);
//resolve(msg);
saveHandleCallback(msg, resolve);
};
// TODO: with reject, the default error handling is proceed
// SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
// reject(result);
//resolve(msg);
saveHandleCallback(msg, resolve);
};
eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
node.log(
`handle-${externalTask.flowNodeInstanceId}: *flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`,
);
eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
node.log(
`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`
);
if (isError) {
handleErrorTask(msg);
} else {
handleFinishTask(msg);
}
});
if (isError) {
handleErrorTask(msg);
} else {
handleFinishTask(msg);
}
});
started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
showStatus(node, Object.keys(started_external_tasks).length);
showStatus(node, Object.keys(started_external_tasks).length);
let msg = {
_msgid: RED.util.generateId(),
task: RED.util.encodeObject(externalTask),
payload: payload,
flowNodeInstanceId: externalTask.flowNodeInstanceId,
processInstanceId: externalTask.processInstanceId
};
let msg = {
_msgid: RED.util.generateId(),
task: RED.util.encodeObject(externalTask),
payload: payload,
flowNodeInstanceId: externalTask.flowNodeInstanceId,
processInstanceId: externalTask.processInstanceId
};
node.log(
`new task *flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`,
);
node.log(
`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`
);
node.send(msg);
});
})
node.send(msg);
});
};
client.externalTasks
.subscribeToExternalTaskTopic(config.topic, etwCallback, config.workerConfig)
.then(async (externalTaskWorker) => {

@@ -115,0 +117,0 @@ node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });

{
"name": "@5minds/node-red-contrib-processcube",
"version": "1.2.3-develop-dd0a75-m1ypzayt",
"version": "1.2.3-feature-0915a5-m22z2faz",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Node-RED nodes for ProcessCube",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc