UNPKG

n8n-nodes-dataforseo

Version:

DataForSEO is an SEO and marketing data provider, empowering businesses with invaluable insights via APIs and databases.

103 lines 4.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataForSeoDomainAnalyticsApi = void 0; const n8n_workflow_1 = require("n8n-workflow"); const technologies_1 = require("./execute/technologies"); const technologies_2 = require("./resources/technologies"); const whois_1 = require("./execute/whois"); const whois_2 = require("./resources/whois"); class DataForSeoDomainAnalyticsApi { constructor() { this.description = { displayName: 'DataForSEO Domain Analytics API', name: 'dataForSeoDomainAnalyticsApi', icon: 'file:dataforseo.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'DataForSEO Domain Analytics API', defaults: { name: 'DataForSeo Domain Analytics API', }, inputs: ["main"], outputs: ["main"], credentials: [ { name: 'dataForSeoApi', required: true, }, ], requestDefaults: { method: 'POST', baseURL: 'https://api.dataforseo.com/v3', headers: { 'Content-Type': 'application/json', }, }, properties: [ { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ { name: 'Technologies', value: 'technologies', }, { name: 'Whois', value: 'whois', } ], default: 'technologies', }, ...technologies_2.TechnologiesOperations, ...whois_2.WhoisOperations ], }; } async execute() { let responseData = []; const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); const mapping = { 'technologies': { 'get-live-aggregation-technologies': technologies_1.getLiveAggregationTechnologies, 'get-live-domains-by-technology': technologies_1.getLiveDomainsByTechnology, 'get-live-technologies-summary': technologies_1.getLiveTechnologiesSummary, 'get-live-domains-by-html-terms': technologies_1.getLiveDomainsByHTMLTerms, 'get-live-technology-stats': technologies_1.getLiveTechnologyStats, 'get-live-domain-technologies': technologies_1.getLiveDomainTechnologies }, 'whois': { 'get-live-domain-whois-overview': whois_1.getLiveDomainWhoisOverview } }; const fn = mapping[resource][operation]; if (!fn) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Something went wrong"); } try { const items = this.getInputData(); for (let i = 0; i < items.length; i++) { const result = await fn(this, i); responseData.push({ json: result, pairedItem: { item: i } }); } } catch (e) { if (e instanceof n8n_workflow_1.NodeOperationError) { throw e; } else { throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Something went wrong"); } } return [this.helpers.returnJsonArray(responseData)]; } } exports.DataForSeoDomainAnalyticsApi = DataForSeoDomainAnalyticsApi; //# sourceMappingURL=DataForSeoDomainAnalyticsApi.node.js.map