n8n-nodes-tenable-community
Version:
n8n node for the Tenable One platform
55 lines (54 loc) • 2.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductStatusTrigger = void 0;
const GenericFunctions_1 = require("./GenericFunctions");
class ProductStatusTrigger {
constructor() {
this.description = {
displayName: 'Tenable Product Status Trigger',
name: 'tenableProductStatusTrigger',
icon: 'file:tenable.svg',
group: ['trigger'],
version: 1,
description: 'Triggers when a Tenable product status changes',
defaults: {
name: 'Tenable Product Status Trigger',
},
inputs: [],
outputs: ["main" /* NodeConnectionType.Main */],
properties: [],
};
}
async trigger() {
const returnData = [];
const previousStatusData = this.getWorkflowStaticData('node').previousStatus;
const currentStatusData = {};
const response = await GenericFunctions_1.productStatusApiRequest.call(this, 'GET', '/components.json');
if (!Array.isArray(response.components)) {
// If the response is not as expected, do nothing.
return {
closeFunction: async () => { },
};
}
const components = response.components;
for (const component of components) {
currentStatusData[component.id] = component.status;
if (previousStatusData && previousStatusData[component.id] !== component.status) {
returnData.push({
component_id: component.id,
component_name: component.name,
previous_status: previousStatusData[component.id],
current_status: component.status,
});
}
}
this.getWorkflowStaticData('node').previousStatus = currentStatusData;
if (returnData.length > 0) {
this.emit([this.helpers.returnJsonArray(returnData)]);
}
return {
closeFunction: async () => { },
};
}
}
exports.ProductStatusTrigger = ProductStatusTrigger;