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
358
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.5.11 to 1.5.12-develop-571171-m4sfus1z

41

endevent-finished-listener.js

@@ -9,13 +9,2 @@ module.exports = function (RED) {

const eventEmitter = node.engine.eventEmitter;
eventEmitter.on('engine-client-dispose', () => {
node.engine.engineClient.events.removeSubscription(subscription, node.engine.identity);
});
eventEmitter.on('engine-client-changed', () => {
node.log('new engineClient received');
register();
});
const register = async () => {

@@ -29,27 +18,7 @@ const client = node.engine.engineClient;

let currentIdentity = node.engine.identity;
try {
subscription = await client.events.onEndEventFinished(
(endEventFinished) => {
node.send({
payload: endEventFinished,
});
},
{ identity: currentIdentity }
);
node.engine.registerOnIdentityChanged(async (identity) => {
client.events.removeSubscription(subscription, currentIdentity);
currentIdentity = identity;
subscription = await client.events.onEndEventFinished(
(endEventFinished) => {
node.send({
payload: endEventFinished,
});
},
{ identity: currentIdentity }
);
subscription = await client.events.onEndEventFinished((endEventFinished) => {
node.send({
payload: endEventFinished,
});
});

@@ -62,3 +31,3 @@ } catch (error) {

if (node.engine && node.engine.engineClient && client) {
client.events.removeSubscription(subscription, currentIdentity);
client.events.removeSubscription(subscription);
}

@@ -65,0 +34,0 @@ });

@@ -9,16 +9,3 @@ module.exports = function (RED) {

const eventEmitter = node.engine.eventEmitter;
eventEmitter.on('engine-client-dispose', () => {
node.engine.engineClient.notification.removeSubscription(subscription, node.engine.identity);
});
eventEmitter.on('engine-client-changed', () => {
node.log('new engineClient received');
register();
});
const register = async () => {
let currentIdentity = node.engine.identity;
const client = node.engine.engineClient;

@@ -48,13 +35,7 @@

case 'created':
return await client.notification.onExternalTaskCreated(externalTaskCallback(), {
identity: currentIdentity,
});
return await client.notification.onExternalTaskCreated(externalTaskCallback());
case 'locked':
return await client.notification.onExternalTaskLocked(externalTaskCallback(), {
identity: currentIdentity,
});
return await client.notification.onExternalTaskLocked(externalTaskCallback());
case 'unlocked':
return await client.notification.onExternalTaskUnlocked(externalTaskCallback(), {
identity: currentIdentity,
});
return await client.notification.onExternalTaskUnlocked(externalTaskCallback());
default:

@@ -65,18 +46,7 @@ console.error('no such event: ' + config.eventtype);

if (node.engine.isIdentityReady()) {
subscription = subscribe();
}
subscription = subscribe();
node.engine.registerOnIdentityChanged(async (identity) => {
if (subscription) {
client.notification.removeSubscription(subscription, currentIdentity);
}
currentIdentity = identity;
subscription = subscribe();
});
node.on('close', async () => {
if (node.engine && node.engine.engineClient && client) {
client.notification.removeSubscription(subscription, currentIdentity);
client.notification.removeSubscription(subscription);
}

@@ -83,0 +53,0 @@ });

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

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

@@ -29,9 +29,2 @@ var eventEmitter = flowContext.get('emitter');

const engineEventEmitter = engine.eventEmitter;
engineEventEmitter.on('engine-client-changed', () => {
node.log('new engineClient received');
register();
});
const register = async () => {

@@ -46,3 +39,3 @@ if (node.etw) {

}
const client = engine.engineClient;
const client = node.engine.engineClient;

@@ -139,7 +132,2 @@ if (!client) {

externalTaskWorker.identity = engine.identity;
engine.registerOnIdentityChanged((identity) => {
externalTaskWorker.identity = identity;
});
// export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;

@@ -192,3 +180,3 @@ externalTaskWorker.onWorkerError((errorType, error, externalTask) => {

if (engine) {
if (node.engine) {
register();

@@ -195,0 +183,0 @@ }

8

message-event-trigger.js

@@ -7,6 +7,5 @@ module.exports = function (RED) {

node.on('input', function (msg) {
node.engine = RED.nodes.getNode(config.engine);
const client = node.engine.engineClient;
const engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
if (!client) {

@@ -17,7 +16,6 @@ node.error('No engine configured.');

engine.engineClient.events
node.engine.engineClient.events
.triggerMessageEvent(config.messagename, {
processInstanceId: msg.processinstanceid,
payload: msg.payload,
identity: engine.identity,
})

@@ -24,0 +22,0 @@ .then((result) => {

{
"name": "@5minds/node-red-contrib-processcube",
"version": "1.5.11",
"version": "1.5.12-develop-571171-m4sfus1z",
"license": "MIT",

@@ -60,3 +60,3 @@ "description": "Node-RED nodes for ProcessCube",

"dependencies": {
"@5minds/processcube_engine_client": "5.1.0-hotfix-a73235-m346kg1n",
"@5minds/processcube_engine_client": "release~v5.1.3",
"jwt-decode": "^4.0.0",

@@ -63,0 +63,0 @@ "openid-client": "^5.5.0"

@@ -9,13 +9,2 @@ module.exports = function (RED) {

const engineEventEmitter = node.engine.eventEmitter;
engineEventEmitter.on('engine-client-dispose', () => {
node.engine.engineClient.notification.removeSubscription(subscription, node.engine.identity);
});
engineEventEmitter.on('engine-client-changed', () => {
node.log('new engineClient received');
register();
});
const register = async () => {

@@ -29,4 +18,2 @@ const client = node.engine.engineClient;

let currentIdentity = node.engine.identity;
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);

@@ -37,393 +24,316 @@

case 'starting':
return await client.notification.onProcessStarting(
async (processNotification) => {
return await client.notification.onProcessStarting(async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
) {
return;
}
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
return;
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
processInstance: processInstance,
action: 'starting',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'started':
return await client.notification.onProcessStarted(async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
) {
return;
}
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
});
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
processInstance: processInstance,
action: 'starting',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
case 'started':
return await client.notification.onProcessStarted(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
return;
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
flowNodeId: processNotification.flowNodeId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'started',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'resumed':
return await client.notification.onProcessResumed(async (processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
});
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
flowNodeId: processNotification.flowNodeId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'started',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
case 'resumed':
return await client.notification.onProcessResumed(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'resumed',
type: 'processInstance',
},
});
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'resumed',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'finished':
return await client.notification.onProcessEnded(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
return await client.notification.onProcessEnded(async (processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
flowNodeId: processNotification.flowNodeId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'finished',
type: 'processInstance',
},
});
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
flowNodeId: processNotification.flowNodeId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'finished',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'terminated':
return await client.notification.onProcessTerminated(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
return await client.notification.onProcessTerminated(async (processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'terminated',
type: 'processInstance',
},
});
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'terminated',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'error':
return await client.notification.onProcessError(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
return await client.notification.onProcessError(async (processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'error',
type: 'processInstance',
},
});
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
processInstance: processInstance,
action: 'error',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'owner-changed':
return await client.notification.onProcessOwnerChanged(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
return await client.notification.onProcessOwnerChanged(async (processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
processInstance: processInstance,
action: 'owner-changed',
type: 'processInstance',
},
});
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
processInstance: processInstance,
action: 'owner-changed',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'instances-deleted':
return await client.notification.onProcessInstancesDeleted(
async (processNotification) => {
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
return await client.notification.onProcessInstancesDeleted(async (processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
const newQuery = {
processInstanceId: processNotification.processInstanceId,
...query,
};
try {
const matchingInstances = await client.processInstances.query(newQuery, {
identity: currentIdentity,
try {
const matchingInstances = await client.processInstances.query(newQuery);
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
processInstance: processInstance,
action: 'instances-deleted',
type: 'processInstance',
},
});
if (
matchingInstances.processInstances &&
matchingInstances.processInstances.length == 1
) {
const processInstance = matchingInstances.processInstances[0];
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
processInstance: processInstance,
action: 'instances-deleted',
type: 'processInstance',
},
});
}
} catch (error) {
node.error(JSON.stringify(error));
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});
case 'is-executable-changed':
return await client.notification.onProcessIsExecutableChanged(
(processNotification) => {
return await client.notification.onProcessIsExecutableChanged((processNotification) => {
node.log(
'processNotification (is-executable-changed): ' + JSON.stringify(processNotification)
);
node.log('processNotification (is-executable-changed): ' + JSON.stringify(processNotification));
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
node.send({
payload: {
processModelId: processNotification.processModelId,
action: 'is-executable-changed',
type: 'processModel',
},
});
},
{ identity: currentIdentity }
);
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
node.send({
payload: {
processModelId: processNotification.processModelId,
action: 'is-executable-changed',
type: 'processModel',
},
});
});
case 'deployed':
return await client.notification.onProcessDeployed(
(processNotification) => {
return await client.notification.onProcessDeployed((processNotification) => {
node.log('processNotification (deployed): ' + JSON.stringify(processNotification));
node.log('processNotification (deployed): ' + JSON.stringify(processNotification));
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
node.send({
payload: {
processModelId: processNotification.processModelId,
action: 'deployed',
type: 'processModel',
},
});
},
{ identity: currentIdentity }
);
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
node.send({
payload: {
processModelId: processNotification.processModelId,
action: 'deployed',
type: 'processModel',
},
});
});
case 'undeployed':
return await client.notification.onProcessUndeployed(
(processNotification) => {
return await client.notification.onProcessUndeployed((processNotification) => {
node.log('processNotification (undeployed): ' + JSON.stringify(processNotification));
node.log('processNotification (undeployed): ' + JSON.stringify(processNotification));
if (
config.processmodel != '' &&
config.processmodel != processNotification.processModelId
)
return;
node.send({
payload: {
processModelId: processNotification.processModelId,
action: 'undeployed',
type: 'processModel',
},
});
},
{ identity: currentIdentity }
);
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
node.send({
payload: {
processModelId: processNotification.processModelId,
action: 'undeployed',
type: 'processModel',
},
});
});
default:

@@ -435,34 +345,7 @@ console.error('no such event: ' + eventType);

if (node.engine.isIdentityReady()) {
subscription = await subscribe(config.eventtype);
}
subscription = await subscribe(config.eventtype);
node.engine.registerOnIdentityChanged(async (identity) => {
if (subscription) {
client.notification.removeSubscription(subscription, currentIdentity);
}
currentIdentity = identity;
subscription = await client.notification.onProcessResumed(
(processNotification) => {
if (config.processmodel != '' && config.processmodel != processNotification.processModelId)
return;
node.send({
payload: {
processInstanceId: processNotification.processInstanceId,
processModelId: processNotification.processModelId,
token: processNotification.currentToken,
action: 'resumed',
type: 'processInstance',
},
});
},
{ identity: currentIdentity }
);
});
node.on('close', () => {
if (node.engine && node.engine.engineClient && client) {
client.notification.removeSubscription(subscription, currentIdentity);
client.notification.removeSubscription(subscription);
}

@@ -469,0 +352,0 @@ });

@@ -25,4 +25,4 @@ module.exports = function (RED) {

const engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
node.engine = RED.nodes.getNode(config.engine);
const client = node.engine.engineClient;

@@ -35,3 +35,3 @@ if (!client) {

client.processDefinitions
.startProcessInstance(startParameters, engine.identity)
.startProcessInstance(startParameters)
.then((result) => {

@@ -38,0 +38,0 @@ msg.payload = result;

@@ -7,4 +7,4 @@ module.exports = function (RED) {

node.on('input', function (msg) {
const engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
node.engine = RED.nodes.getNode(config.engine);
const client = node.engine.engineClient;

@@ -17,3 +17,3 @@ if (!client) {

client.processInstances
.terminateProcessInstance(msg.payload, engine.identity)
.terminateProcessInstance(msg.payload)
.then(() => {

@@ -20,0 +20,0 @@ node.send(msg);

@@ -1,2 +0,1 @@

const EventEmitter = require('node:events');
const engine_client = require('@5minds/processcube_engine_client');

@@ -10,134 +9,29 @@ const jwt = require('jwt-decode');

const node = this;
const identityChangedCallbacks = [];
this.identity = null;
this.credentials.clientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
this.credentials.clientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
node.url = RED.util.evaluateNodeProperty(n.url, n.urlType, node);
node.credentials.clientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
node.credentials.clientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
node.eventEmitter = new EventEmitter();
// set the engine url
const stopRefreshing = periodicallyRefreshEngineClient(this, n, 10000);
this.registerOnIdentityChanged = function (callback) {
identityChangedCallbacks.push(callback);
};
this.isIdentityReady = function () {
if (this.credentials.clientId && this.credentials.clientSecret) {
return this.identity != null;
} else {
return true;
}
};
this.setIdentity = (identity) => {
node.log(`setIdentity: ${JSON.stringify(identity)}`);
this.identity = identity;
for (const callback of identityChangedCallbacks) {
callback(identity);
}
};
function periodicallyRefreshEngineClient(node, n, intervalMs) {
function refreshUrl() {
const newUrl = RED.util.evaluateNodeProperty(n.url, n.urlType, node);
const newClientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
const newClientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
if (
node.url === newUrl &&
node.credentials.clientId === newClientId &&
node.credentials.clientSecret === newClientSecret
) {
return;
}
node.url = newUrl;
node.credentials.clientId = newClientId;
node.credentials.clientSecret = newClientSecret;
if (node.credentials.clientId && node.credentials.clientSecret) {
if (node.engineClient) {
node.eventEmitter.emit('engine-client-dispose');
node.engineClient.dispose();
}
node.engineClient = new engine_client.EngineClient(node.url, () =>
getFreshIdentity(node.url, node)
);
node.eventEmitter.emit('engine-client-changed');
} else {
if (node.engineClient) {
node.eventEmitter.emit('engine-client-dispose');
node.engineClient.dispose();
}
node.engineClient = new engine_client.EngineClient(node.url);
node.eventEmitter.emit('engine-client-changed');
}
}
refreshUrl();
const intervalId = setInterval(refreshUrl, intervalMs);
return () => clearInterval(intervalId);
}
async function getFreshIdentity(url, node) {
try {
if (
!RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node) ||
!RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node)
) {
return null;
}
const res = await fetch(url + '/atlas_engine/api/v1/authority', {
method: 'GET',
headers: {
Authorization: `Bearer ZHVtbXlfdG9rZW4=`,
'Content-Type': 'application/json',
},
});
const body = await res.json();
const issuer = await oidc.Issuer.discover(body);
const client = new issuer.Client({
client_id: RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node),
client_secret: RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node),
});
const tokenSet = await client.grant({
grant_type: 'client_credentials',
try {
if (node.credentials.clientId && node.credentials.clientSecret) {
node.engineClient = new engine_client.EngineClient(node.url, {
clientId: node.credentials.clientId,
clientSecret: node.credentials.clientSecret,
scope: 'engine_etw engine_read engine_write',
});
const accessToken = tokenSet.access_token;
const decodedToken = jwt.jwtDecode(accessToken);
const freshIdentity = {
token: tokenSet.access_token,
userId: decodedToken.sub,
};
node.setIdentity(freshIdentity);
return freshIdentity;
} catch (e) {
node.error(`Could not get fresh identity: ${JSON.stringify(e)}`);
} else {
node.engineClient = new engine_client.EngineClient(node.url);
}
} catch (error) {
node.error(JSON.stringify(error));
}
node.on('close', async () => {
if (this.engineClient) {
stopRefreshing();
this.engineClient.dispose();
this.engineClient = null;
if (node.engineClient) {
node.engineClient.dispose();
node.engineClient = null;
}
});
}
RED.nodes.registerType('processcube-engine-config', ProcessCubeEngineNode, {

@@ -144,0 +38,0 @@ credentials: {

@@ -7,4 +7,3 @@ module.exports = function (RED) {

node.on('input', function (msg) {
const engine = RED.nodes.getNode(config.engine);
node.engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;

@@ -18,33 +17,30 @@

let query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
query = {
...query,
identity: engine.identity,
};
node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
let models = [];
client.processDefinitions
.getAll(query)
.then((matchingProcessDefinitions) => {
if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
let models = [];
matchingProcessDefinitions.processDefinitions.forEach((processDefinition) => {
processDefinition.processModels.forEach((model) => {
models.push(model);
matchingProcessDefinitions.processDefinitions.forEach((processDefinition) => {
processDefinition.processModels.forEach((model) => {
models.push(model);
});
});
});
msg.payload = {
models: models,
totalCount: models.length,
};
} else {
msg.payload = matchingProcessDefinitions;
}
msg.payload = {
models: models,
totalCount: models.length,
};
} else {
msg.payload = matchingProcessDefinitions;
}
node.send(msg);
}).catch((error) => {
node.error(JSON.stringify(error));
});
node.send(msg);
})
.catch((error) => {
node.error(JSON.stringify(error));
});
});

@@ -51,0 +47,0 @@ }

@@ -7,4 +7,4 @@ module.exports = function (RED) {

node.on('input', async function (msg) {
const engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
node.engine = RED.nodes.getNode(config.engine);
const client = node.engine.engineClient;

@@ -37,3 +37,3 @@ if (!client) {

processModelId: modelId
}, { identity: engine.identity });
}, { identity: node.engine.identity });

@@ -69,3 +69,2 @@ let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended' && instance.state != 'running');

}
node.send(msg);

@@ -72,0 +71,0 @@ } catch (queryError) {

@@ -9,4 +9,4 @@ module.exports = function (RED) {

const engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
node.engine = RED.nodes.getNode(config.engine);
const client = node.engine.engineClient;

@@ -19,3 +19,3 @@ if (!client) {

client.processInstances
.query(query, { identity: engine.identity })
.query(query)
.then((matchingInstances) => {

@@ -22,0 +22,0 @@ msg.payload = matchingInstances;

@@ -7,5 +7,5 @@ module.exports = function (RED) {

node.on('input', function (msg) {
const engine = RED.nodes.getNode(config.engine);
node.engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
const client = node.engine.engineClient;

@@ -16,3 +16,3 @@ if (!client) {

}
client.events

@@ -22,3 +22,2 @@ .triggerSignalEvent(config.signalname, {

payload: msg.payload,
identity: engine.identity,
})

@@ -25,0 +24,0 @@ .then((result) => {

@@ -9,16 +9,3 @@ module.exports = function (RED) {

const eventEmitter = node.engine.eventEmitter;
eventEmitter.on('engine-client-dispose', () => {
node.engine.engineClient.userTasks.removeSubscription(subscription, node.engine.identity);
});
eventEmitter.on('engine-client-changed', () => {
node.log('new engineClient received');
register();
});
const register = async () => {
let currentIdentity = node.engine.identity;
const client = node.engine.engineClient;

@@ -43,5 +30,3 @@

try {
const matchingFlowNodes = await client.userTasks.query(newQuery, {
identity: currentIdentity,
});
const matchingFlowNodes = await client.userTasks.query(newQuery);

@@ -70,17 +55,9 @@ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {

case 'new':
return await client.userTasks.onUserTaskWaiting(userTaskCallback(), {
identity: currentIdentity,
});
return await client.userTasks.onUserTaskWaiting(userTaskCallback());
case 'finished':
return await client.userTasks.onUserTaskFinished(userTaskCallback(), {
identity: currentIdentity,
});
return await client.userTasks.onUserTaskFinished(userTaskCallback());
case 'reserved':
return await client.userTasks.onUserTaskReserved(userTaskCallback(), {
identity: currentIdentity,
});
return await client.userTasks.onUserTaskReserved(userTaskCallback());
case 'reservation-canceled':
return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
identity: currentIdentity,
});
return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback());
default:

@@ -91,18 +68,7 @@ console.error('no such event: ' + config.eventtype);

if (node.engine.isIdentityReady()) {
subscription = subscribe();
}
subscription = subscribe();
node.engine.registerOnIdentityChanged(async (identity) => {
if (subscription) {
client.userTasks.removeSubscription(subscription, currentIdentity);
}
currentIdentity = identity;
subscription = subscribe();
});
node.on('close', async () => {
if (node.engine && node.engine.engineClient && client) {
client.userTasks.removeSubscription(subscription, currentIdentity);
client.userTasks.removeSubscription(subscription);
}

@@ -109,0 +75,0 @@ });

@@ -7,5 +7,5 @@ module.exports = function (RED) {

node.on('input', function (msg) {
const engine = RED.nodes.getNode(config.engine);
node.engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
const client = node.engine.engineClient;

@@ -19,8 +19,4 @@ if (!client) {

query = {
...query,
};
client.userTasks
.query(query, { identity: engine.identity })
.query(query)
.then((matchingFlowNodes) => {

@@ -27,0 +23,0 @@ if (config.sendtype === 'array') {

@@ -12,5 +12,5 @@ module.exports = function (RED) {

const engine = RED.nodes.getNode(config.engine);
node.engine = RED.nodes.getNode(config.engine);
const client = engine.engineClient;
const client = node.engine.engineClient;

@@ -21,5 +21,5 @@ if (!client) {

}
client.userTasks
.finishUserTask(flowNodeInstanceId, userTaskResult, engine.identity)
.finishUserTask(flowNodeInstanceId, userTaskResult)
.then(() => {

@@ -26,0 +26,0 @@ node.send(msg);

@@ -9,3 +9,2 @@ module.exports = function (RED) {

let subscription = null;
let currentIdentity = node.engine.identity;
let subscribe = null;

@@ -23,31 +22,26 @@

subscription = await client.userTasks.onUserTaskWaiting(
async (userTaskWaitingNotification) => {
const newQuery = {
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
...query,
};
subscription = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
const newQuery = {
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
...query,
};
try {
const matchingFlowNodes = await client.userTasks.query(newQuery, {
identity: currentIdentity,
});
try {
const matchingFlowNodes = await client.userTasks.query(newQuery);
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
// remove subscription
client.userTasks.removeSubscription(subscription, currentIdentity);
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
// remove subscription
client.userTasks.removeSubscription(subscription);
const userTask = matchingFlowNodes.userTasks[0];
const userTask = matchingFlowNodes.userTasks[0];
msg.payload = { userTask: userTask };
node.send(msg);
} else {
// nothing todo - wait for next notification
}
} catch (error) {
node.error(JSON.stringify(error));
msg.payload = { userTask: userTask };
node.send(msg);
} else {
// nothing todo - wait for next notification
}
},
{ identity: currentIdentity }
);
} catch (error) {
node.error(JSON.stringify(error));
}
});

@@ -64,5 +58,3 @@ node.log({ 'Handling old userTasks config.only_for_new': config.only_for_new });

try {
const matchingFlowNodes = await client.userTasks.query(suspendedQuery, {
identity: currentIdentity,
});
const matchingFlowNodes = await client.userTasks.query(suspendedQuery);

@@ -76,3 +68,3 @@ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {

// remove subscription
client.userTasks.removeSubscription(subscription, currentIdentity);
client.userTasks.removeSubscription(subscription);
} else {

@@ -90,15 +82,5 @@ // let the *currentIdentity* be active

node.engine.registerOnIdentityChanged(async (identity) => {
if (subscription) {
client.userTasks.removeSubscription(subscription, currentIdentity);
currentIdentity = identity;
subscribe();
} else {
currentIdentity = identity;
}
});
node.on('close', async () => {
if (client != null && subscription != null) {
client.userTasks.removeSubscription(subscription, currentIdentity);
client.userTasks.removeSubscription(subscription);
}

@@ -105,0 +87,0 @@ });

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