diff --git a/README.md b/README.md index d779f45..41e5317 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# n8n-tavily-nodes +# n8n-nodes-tavilyapi -**n8n-tavily-nodes** is an n8n community node package that integrates the [Tavily API](https://api.tavily.com) for powerful **web search** and **content extraction**. +**n8n-nodes-tavilyapi** is an n8n community node package that integrates the [Tavily API](https://api.tavily.com) for powerful **web search** and **content extraction**. It contains two nodes: @@ -51,7 +51,7 @@ It contains two nodes: 1. From your n8n root directory, run: ```bash - npm install n8n-tavily-nodes + npm install n8n-nodes-tavilyapi ``` 2. Restart n8n. diff --git a/package-lock.json b/package-lock.json index 252d125..8fbf98a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "n8n-tavily-nodes", - "version": "1.0.0", + "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "n8n-tavily-nodes", - "version": "1.0.0", + "version": "1.0.5", "license": "MIT", "dependencies": { "axios": "^1.6.0", diff --git a/package.json b/package.json index f0f4f7e..4a6faae 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "n8n-tavily-nodes", - "version": "1.0.0", + "name": "n8n-nodes-tavilyapi", + "version": "1.0.5", "description": "n8n Community Nodes for Tavily API integration", "author": "Steven Milanese (https://StevenMilanese.com)", "license": "MIT", "main": "dist/index.js", "scripts": { - "build": "tsc", + "build": "tsc && node copy-assets.js", "prepublishOnly": "npm run build" }, "keywords": [ diff --git a/src/nodes/Tavily/TavilySearch.node.ts b/src/nodes/Tavily/TavilySearch.node.ts index 772f9b3..63b72ee 100644 --- a/src/nodes/Tavily/TavilySearch.node.ts +++ b/src/nodes/Tavily/TavilySearch.node.ts @@ -6,11 +6,9 @@ import { INodeTypeDescription, INodeProperties, } from 'n8n-workflow'; -// REMOVED import { IExecuteFunctions } from 'n8n-core'; import { tavilyApiRequest } from './tavilyApi.utils'; -// For older n8n usage, ALLOWED_TIME_RANGES is fine here const ALLOWED_TIME_RANGES = ['', 'day', 'week', 'month', 'year', 'd', 'w', 'm', 'y']; export class TavilySearch implements INodeType { @@ -217,11 +215,15 @@ export class TavilySearch implements INodeType { const searchDepth = this.getNodeParameter('searchDepth', i) as string; const maxResults = this.getNodeParameter('maxResults', i) as number; const timeRange = this.getNodeParameter('timeRange', i) as string; - const days = this.getNodeParameter('days', i) as number; const includeAnswer = this.getNodeParameter('includeAnswer', i) as string; const includeRawContent = this.getNodeParameter('includeRawContent', i) as boolean; const includeImages = this.getNodeParameter('includeImages', i) as boolean; - const includeImageDescriptions = this.getNodeParameter('includeImageDescriptions', i) as boolean; + let includeImageDescriptions = false; + + if (includeImages) { + includeImageDescriptions = this.getNodeParameter('includeImageDescriptions', i) as boolean; + } + const includeDomains = this.getNodeParameter('includeDomains', i, []) as string[]; const excludeDomains = this.getNodeParameter('excludeDomains', i, []) as string[]; @@ -237,9 +239,6 @@ export class TavilySearch implements INodeType { message: `Invalid timeRange value. Allowed: ${ALLOWED_TIME_RANGES.join(', ')}`, }); } - if (topic === 'news' && days < 0) { - throw new NodeApiError(this.getNode(), { message: 'Days must be >= 0 when topic is "news".' }); - } const body: Record = { query, @@ -254,9 +253,16 @@ export class TavilySearch implements INodeType { if (timeRange) { body.time_range = timeRange; } + + // Only get and add days parameter when topic is news if (topic === 'news') { + const days = this.getNodeParameter('days', i) as number; + if (days < 0) { + throw new NodeApiError(this.getNode(), { message: 'Days must be >= 0 when topic is "news".' }); + } body.days = days; } + if (includeAnswer !== 'false') { body.include_answer = includeAnswer; } @@ -286,4 +292,4 @@ export class TavilySearch implements INodeType { return [returnData]; } -} +} \ No newline at end of file diff --git a/src/nodes/Tavily/tavily.svg b/src/nodes/Tavily/tavily.svg new file mode 100644 index 0000000..5c62dc0 --- /dev/null +++ b/src/nodes/Tavily/tavily.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file