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
353
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.6.0-process-instance-delete-hotfix-7eea00-m4vifhab to 1.6.0-process-instance-delete-hotfix-8d236b-m4wobqqt

2

package.json
{
"name": "@5minds/node-red-contrib-processcube",
"version": "1.6.0-process-instance-delete-hotfix-7eea00-m4vifhab",
"version": "1.6.0-process-instance-delete-hotfix-8d236b-m4wobqqt",
"license": "MIT",

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

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

const validTimeTypes = ['days', 'hours'];
const timeType = msg.payload.time_type
? msg.payload.time_type.toLowerCase()
const timeType = msg.payload.time_type
? msg.payload.time_type.toLowerCase()
: config.time_type?.toLowerCase();

@@ -33,11 +33,10 @@

}
// Zeitmultiplikator berechnen
const multiplier = timeType === 'hours' ? 1 : 24;
node.log(`Time type: ${timeType}, multiplier: ${multiplier}`);
const deletionDate = new Date(Date.now() - timeToUse * multiplier * 60 * 60 * 1000);
node.log(`Errechnetes Datum: ${deletionDate}`);
node.log(`Time type: ${timeType}`);
const deletionDate = new Date(Date.now() - timeToUse * multiplier * 60 * 60 * 1000);
const modelId = msg.payload.processModelId?.trim() || config.modelid?.trim();
if (!modelId) {

@@ -48,35 +47,45 @@ node.error('processModelId is not defined or empty.');

const batchSize = config.batch_size || 100;
// Prüfung und Festlegung von batch_size
let batchSize = msg.payload.batch_size || config.batch_size || 1000;
if (isNaN(batchSize) || batchSize <= 0 || batchSize > 1000) {
node.error(`Invalid batch_size: ${batchSize}. Must be a positive number and not exceed 1000.`);
return;
}
batchSize = Math.min(batchSize, 1000); // Sicherstellen, dass der Wert 1000 nicht überschreitet
try {
const result = await client.processInstances.query(
{
processModelId: modelId,
finishedBefore: deletionDate.toISOString(),
state: ["finished", "error", "terminated"],
},
{ identity: node.engine.identity }
);
msg.payload = { successfulDeletions: [], failedDeletions: [] };
if (result.processInstances.length === 0) {
node.log(`No process instances to delete for Model-ID: ${modelId} and given Date: ${deletionDate.toISOString()}`);
node.send(msg);
return;
}
let hasMoreResults = true;
const ids = result.processInstances.map((obj) => obj.processInstanceId);
while (hasMoreResults) {
const result = await client.processInstances.query(
{
processModelId: modelId,
finishedBefore: deletionDate.toISOString(),
state: ['finished', 'error', 'terminated'],
limit: batchSize,
},
{ includeXml: false }
);
msg.payload = { successfulDeletions: [], failedDeletions: [] };
const processInstances = result.processInstances || [];
if (processInstances.length === 0) {
node.log(`No more process instances to delete for Model-ID: ${modelId} with Date: ${deletionDate.toISOString()}`);
hasMoreResults = false;
continue;
}
for (let i = 0; i < ids.length; i += batchSize) {
var batch = ids.slice(i, i + batchSize);
try
{
await client.processInstances.deleteProcessInstances(batch, true);
msg.payload.successfulDeletions.push(...batch);
}
catch (deleteError)
{
batch.forEach((id) => {msg.payload.failedDeletions.push({ id, error: deleteError.message });});
//node.warn(`Failed to delete process instances in batch for Model-ID: ${modelId}: ${batch.join(', ')}. Error: ${deleteError.message}`);
const ids = processInstances.map((obj) => obj.processInstanceId);
try {
await client.processInstances.deleteProcessInstances(ids, true);
msg.payload.successfulDeletions.push(...ids);
node.log(`Successfully deleted ${ids.length} process instances for Model-ID: ${modelId}.`);
} catch (deleteError) {
var message = JSON.stringify(deleteError);
ids.forEach((id) => {
msg.payload.failedDeletions.push({ id, error: message });
});
node.warn(`Failed to delete some process instances for Model-ID: ${modelId}. Error: ${message}`);
}

@@ -87,3 +96,3 @@ }

} catch (queryError) {
node.error(`Failed to query process instances for Model-ID: ${modelId}: ${queryError.message}`);
node.error(`Failed to query process instances for Model-ID: ${modelId}. Error: ${queryError.message}`);
}

@@ -94,2 +103,2 @@ });

RED.nodes.registerType('processinstance-delete', ProcessInstanceDelete);
};
};
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