diff --git a/nodes/MarkdownifyDescription.ts b/nodes/MarkdownifyDescription.ts index 3dbbfd7..c021c79 100644 --- a/nodes/MarkdownifyDescription.ts +++ b/nodes/MarkdownifyDescription.ts @@ -1,27 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -export const markdownifyOperations: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: ['markdownify'], - }, - }, - options: [ - { - name: 'Convert', - value: 'convert', - action: 'Convert a webpage or article to clean markdown useful for blogs dev docs and more', - description: 'Convert a webpage or article to clean markdown – useful for blogs, dev docs and more', - }, - ], - default: 'convert', - }, -]; +export const markdownifyOperations: INodeProperties[] = []; export const markdownifyFields: INodeProperties[] = [ { @@ -34,7 +13,6 @@ export const markdownifyFields: INodeProperties[] = [ displayOptions: { show: { resource: ['markdownify'], - operation: ['convert'], }, }, }, diff --git a/nodes/ScrapegraphAI/ScrapegraphAi.node.ts b/nodes/ScrapegraphAI/ScrapegraphAi.node.ts index 51291e6..2b96e43 100644 --- a/nodes/ScrapegraphAI/ScrapegraphAi.node.ts +++ b/nodes/ScrapegraphAI/ScrapegraphAi.node.ts @@ -21,7 +21,7 @@ export class ScrapegraphAi implements INodeType { icon: 'file:../scrapegraphAI.svg', group: ['transform'], version: 1, - subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', + subtitle: '={{$parameter["operation"] ? $parameter["operation"] + ": " + $parameter["resource"] : $parameter["resource"]}}', description: 'Turn any webpage into usable data in one shot – ScrapegraphAI explores the website and extracts the content you need.', defaults: { name: 'ScrapegraphAI', @@ -88,8 +88,11 @@ export class ScrapegraphAi implements INodeType { const items = this.getInputData(); const returnData: INodeExecutionData[] = []; const resource = this.getNodeParameter('resource', 0) as string; - const operation = this.getNodeParameter('operation', 0) as string; - + // Only load operation for resources that still use it + const operation = (resource === 'scrape' || resource === 'agenticscraper') + ? this.getNodeParameter('operation', 0) as string + : undefined; + const baseUrl = 'https://api.scrapegraphai.com/v1'; for (let i = 0; i < items.length; i++) { @@ -205,64 +208,47 @@ export class ScrapegraphAi implements INodeType { } if (resource === 'smartcrawler') { - if (operation === 'crawl') { - const url = this.getNodeParameter('url', i) as string; - const prompt = this.getNodeParameter('prompt', i) as string; - const cacheWebsite = this.getNodeParameter('cacheWebsite', i) as boolean; - const depth = this.getNodeParameter('depth', i) as number; - const maxPages = this.getNodeParameter('maxPages', i) as number; - const sameDomainOnly = this.getNodeParameter('sameDomainOnly', i) as boolean; - const useOutputSchema = this.getNodeParameter('useOutputSchema', i, false) as boolean; - const renderHeavyJs = this.getNodeParameter('renderHeavyJs', i, false) as boolean; - - const requestBody: any = { - url: url, - prompt: prompt, - cache_website: cacheWebsite, - depth: depth, - max_pages: maxPages, - same_domain_only: sameDomainOnly, - render_heavy_js: renderHeavyJs, - }; - - // Add output_schema if enabled and provided - if (useOutputSchema) { - const outputSchema = this.getNodeParameter('outputSchema', i) as string; - try { - requestBody.output_schema = JSON.parse(outputSchema); - } catch (error) { - throw new NodeOperationError(this.getNode(), `Invalid JSON in Output Schema: ${error.message}`); - } + const url = this.getNodeParameter('url', i) as string; + const prompt = this.getNodeParameter('prompt', i) as string; + const cacheWebsite = this.getNodeParameter('cacheWebsite', i) as boolean; + const depth = this.getNodeParameter('depth', i) as number; + const maxPages = this.getNodeParameter('maxPages', i) as number; + const sameDomainOnly = this.getNodeParameter('sameDomainOnly', i) as boolean; + const useOutputSchema = this.getNodeParameter('useOutputSchema', i, false) as boolean; + const renderHeavyJs = this.getNodeParameter('renderHeavyJs', i, false) as boolean; + + const requestBody: any = { + url: url, + prompt: prompt, + cache_website: cacheWebsite, + depth: depth, + max_pages: maxPages, + same_domain_only: sameDomainOnly, + render_heavy_js: renderHeavyJs, + }; + + // Add output_schema if enabled and provided + if (useOutputSchema) { + const outputSchema = this.getNodeParameter('outputSchema', i) as string; + try { + requestBody.output_schema = JSON.parse(outputSchema); + } catch (error) { + throw new NodeOperationError(this.getNode(), `Invalid JSON in Output Schema: ${error.message}`); } - - const response = await this.helpers.httpRequestWithAuthentication.call(this, 'scrapegraphAIApi', { - method: 'POST', - url: `${baseUrl}/crawl`, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - }, - body: requestBody, - json: true, - }); - - returnData.push({ json: response, pairedItem: { item: i } }); } - if (operation === 'getStatus') { - const taskId = this.getNodeParameter('taskId', i) as string; - - const response = await this.helpers.httpRequestWithAuthentication.call(this, 'scrapegraphAIApi', { - method: 'GET', - url: `${baseUrl}/crawl/${taskId}`, - headers: { - 'Accept': 'application/json', - }, - json: true, - }); - - returnData.push({ json: response, pairedItem: { item: i } }); - } + const response = await this.helpers.httpRequestWithAuthentication.call(this, 'scrapegraphAIApi', { + method: 'POST', + url: `${baseUrl}/crawl`, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: requestBody, + json: true, + }); + + returnData.push({ json: response, pairedItem: { item: i } }); } if (resource === 'markdownify') { diff --git a/nodes/SearchscraperDescription.ts b/nodes/SearchscraperDescription.ts index 1a67aac..e95394c 100644 --- a/nodes/SearchscraperDescription.ts +++ b/nodes/SearchscraperDescription.ts @@ -1,27 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -export const searchscraperOperations: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: ['searchscraper'], - }, - }, - options: [ - { - name: 'Search', - value: 'search', - action: 'Perform ai powered site wide search and structured data extraction ideal for knowledge retrieval', - description: 'Perform AI-powered site-wide search and structured data extraction – ideal for knowledge retrieval', - }, - ], - default: 'search', - }, -]; +export const searchscraperOperations: INodeProperties[] = []; export const searchscraperFields: INodeProperties[] = [ { @@ -34,7 +13,6 @@ export const searchscraperFields: INodeProperties[] = [ displayOptions: { show: { resource: ['searchscraper'], - operation: ['search'], }, }, }, diff --git a/nodes/SmartcrawlerDescription.ts b/nodes/SmartcrawlerDescription.ts index 25726a0..3234d13 100644 --- a/nodes/SmartcrawlerDescription.ts +++ b/nodes/SmartcrawlerDescription.ts @@ -1,49 +1,8 @@ import type { INodeProperties } from 'n8n-workflow'; -export const smartcrawlerOperations: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: ['smartcrawler'], - }, - }, - options: [ - { - name: 'Crawl', - value: 'crawl', - action: 'Give a single URL – the AI crawler follows internal links to extract structured data across multiple pages', - description: 'Give a single URL – the AI crawler follows internal links to extract structured data across multiple pages', - }, - { - name: 'Get Status', - value: 'getStatus', - action: 'Get the status and results of a crawl job using its task ID', - description: 'Get the status and results of a crawl job using its task ID', - }, - ], - default: 'crawl', - }, -]; +export const smartcrawlerOperations: INodeProperties[] = []; export const smartcrawlerFields: INodeProperties[] = [ - { - displayName: 'Task ID', - name: 'taskId', - type: 'string', - required: true, - default: '', - description: 'The task ID returned from a crawl operation', - displayOptions: { - show: { - resource: ['smartcrawler'], - operation: ['getStatus'], - }, - }, - }, { displayName: 'URL', name: 'url', @@ -54,7 +13,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -68,7 +26,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -81,7 +38,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -94,7 +50,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -107,7 +62,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -120,7 +74,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -133,7 +86,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, @@ -147,7 +99,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], useOutputSchema: [true], }, }, @@ -161,7 +112,6 @@ export const smartcrawlerFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartcrawler'], - operation: ['crawl'], }, }, }, diff --git a/nodes/SmartscraperDescription.ts b/nodes/SmartscraperDescription.ts index 86d6ff2..23ad1dd 100644 --- a/nodes/SmartscraperDescription.ts +++ b/nodes/SmartscraperDescription.ts @@ -1,27 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -export const smartscraperOperations: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: ['smartscraper'], - }, - }, - options: [ - { - name: 'Scrape', - value: 'scrape', - action: 'Autonomously extract live data from any website perfect for e commerce job boards lead capture and more', - description: 'Autonomously extract live data from any website – perfect for e-commerce, job boards, lead capture and more', - }, - ], - default: 'scrape', - }, -]; +export const smartscraperOperations: INodeProperties[] = []; export const smartscraperFields: INodeProperties[] = [ { @@ -34,7 +13,6 @@ export const smartscraperFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartscraper'], - operation: ['scrape'], }, }, }, @@ -48,7 +26,6 @@ export const smartscraperFields: INodeProperties[] = [ displayOptions: { show: { resource: ['smartscraper'], - operation: ['scrape'], }, }, },