valyu-js 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ We do all the heavy lifting for you - one unified API for all data:
23
23
  Install the Valyu SDK using npm:
24
24
 
25
25
  ```bash
26
- npm install valyu
26
+ npm install valyu-js
27
27
  ```
28
28
 
29
29
  ## Quick Start
@@ -31,7 +31,7 @@ npm install valyu
31
31
  Here's what it looks like, make your first query in just 4 lines of code:
32
32
 
33
33
  ```javascript
34
- const { Valyu } = require('valyu');
34
+ const { Valyu } = require('valyu-js');
35
35
 
36
36
  const valyu = new Valyu("your-api-key-here");
37
37
 
@@ -196,7 +196,7 @@ Each `ContentResult` contains:
196
196
  ### Basic Search
197
197
 
198
198
  ```javascript
199
- const { Valyu } = require('valyu');
199
+ const { Valyu } = require('valyu-js');
200
200
 
201
201
  const valyu = new Valyu("your-api-key");
202
202
 
@@ -462,8 +462,8 @@ const response = await valyu.context(
462
462
  ## Getting Started
463
463
 
464
464
  1. Sign up for a free account at [Valyu](https://platform.valyu.ai)
465
- 2. Get your API key from the dashboard
466
- 3. Install the SDK: `npm install valyu`
465
+ 2. Get your API key from the dashboard
466
+ 3. Install the SDK: `npm install valyu-js`
467
467
  4. Start building with the examples above
468
468
 
469
469
  ## Testing
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n SearchResponse,\n SearchType,\n SearchOptions,\n ContentsOptions,\n ContentsResponse,\n AnswerOptions,\n AnswerResponse,\n} from \"./types\";\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(\n apiKey?: string,\n baseUrl: string = \"https://api.valyu.ai/v1\"\n ) {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Validates if a string is a valid URL\n */\n private validateUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Validates if a string is a valid domain (with optional path)\n */\n private validateDomain(domain: string): boolean {\n // Domain must have at least one dot and valid structure\n // Supports: example.com, example.com/path, subdomain.example.com/path/to/resource\n const domainRegex =\n /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\/.+)?$/;\n return domainRegex.test(domain);\n }\n\n /**\n * Validates if a string is a valid dataset identifier (provider/datasetname)\n */\n private validateDatasetId(datasetId: string): boolean {\n // Dataset format: provider/datasetname (exactly one slash)\n // Provider and dataset name can contain alphanumeric, hyphens, underscores\n const parts = datasetId.split(\"/\");\n if (parts.length !== 2) return false;\n\n const providerRegex = /^[a-zA-Z0-9_-]+$/;\n const datasetRegex = /^[a-zA-Z0-9_-]+$/;\n\n return (\n providerRegex.test(parts[0]) &&\n datasetRegex.test(parts[1]) &&\n parts[0].length > 0 &&\n parts[1].length > 0\n );\n }\n\n /**\n * Validates source strings (domains, URLs, or dataset IDs)\n */\n private validateSource(source: string): boolean {\n // Check if it's a valid URL\n if (this.validateUrl(source)) {\n return true;\n }\n\n // Check if it's a valid domain (with optional path)\n if (this.validateDomain(source)) {\n return true;\n }\n\n // Check if it's a valid dataset identifier\n if (this.validateDatasetId(source)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Validates an array of source strings\n */\n private validateSources(sources: string[]): {\n valid: boolean;\n invalidSources: string[];\n } {\n const invalidSources: string[] = [];\n\n for (const source of sources) {\n if (!this.validateSource(source)) {\n invalidSources.push(source);\n }\n }\n\n return {\n valid: invalidSources.length === 0,\n invalidSources,\n };\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to search results\n */\n async search(\n query: string,\n options: SearchOptions = {}\n ): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Validate excludeSources format\n if (options.excludeSources !== undefined) {\n if (!Array.isArray(options.excludeSources)) {\n return {\n success: false,\n error: \"excludeSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const excludeSourcesValidation = this.validateSources(\n options.excludeSources\n );\n if (!excludeSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludeSources format. Invalid sources: ${excludeSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold:\n options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/deepsearch`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Extract content from URLs with optional AI processing\n * @param urls - Array of URLs to process (max 10)\n * @param options - Content extraction configuration options\n * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n * @param options.extractEffort - Extraction thoroughness: \"normal\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(\n urls: string[],\n options: ContentsOptions = {}\n ): Promise<ContentsResponse> {\n try {\n // Validate URLs array\n if (!urls || !Array.isArray(urls)) {\n return {\n success: false,\n error: \"urls must be an array\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length === 0) {\n return {\n success: false,\n error: \"urls array cannot be empty\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 URLs allowed per request\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate extractEffort if provided\n if (\n options.extractEffort &&\n ![\"normal\", \"high\", \"auto\"].includes(options.extractEffort)\n ) {\n return {\n success: false,\n error: \"extractEffort must be 'normal', 'high', or 'auto'\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate responseLength if provided\n if (options.responseLength !== undefined) {\n const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n if (\n typeof options.responseLength === \"string\" &&\n !validLengths.includes(options.responseLength)\n ) {\n return {\n success: false,\n error:\n \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n if (\n typeof options.responseLength === \"number\" &&\n options.responseLength <= 0\n ) {\n return {\n success: false,\n error: \"responseLength number must be positive\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n urls,\n };\n\n // Add optional parameters only if provided\n if (options.summary !== undefined) {\n payload.summary = options.summary;\n }\n\n if (options.extractEffort !== undefined) {\n payload.extract_effort = options.extractEffort;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.maxPriceDollars !== undefined) {\n payload.max_price_dollars = options.maxPriceDollars;\n }\n\n const response = await axios.post(`${this.baseUrl}/contents`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Get AI-powered answers using the Valyu Answer API\n * @param query - The question or query string\n * @param options - Answer configuration options\n * @param options.structuredOutput - JSON Schema object for structured responses\n * @param options.systemInstructions - Custom system-level instructions (max 2000 chars)\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.dataMaxPrice - Maximum spend (USD) for data retrieval\n * @param options.countryCode - Country code filter for search results\n * @param options.includedSources - List of specific sources to include\n * @param options.excludedSources - List of URLs/domains to exclude from search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to answer response\n */\n async answer(\n query: string,\n options: AnswerOptions = {}\n ): Promise<AnswerResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultDataMaxPrice = 30.0;\n\n // Validate query\n if (!query || typeof query !== \"string\" || query.trim().length === 0) {\n return {\n success: false,\n error: \"Query is required and must be a non-empty string\",\n };\n }\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n };\n }\n\n // Validate systemInstructions length\n if (options.systemInstructions !== undefined) {\n if (typeof options.systemInstructions !== \"string\") {\n return {\n success: false,\n error: \"systemInstructions must be a string\",\n };\n }\n\n const trimmed = options.systemInstructions.trim();\n if (trimmed.length === 0) {\n return {\n success: false,\n error: \"systemInstructions cannot be empty when provided\",\n };\n }\n\n if (trimmed.length > 2000) {\n return {\n success: false,\n error: \"systemInstructions must be 2000 characters or less\",\n };\n }\n }\n\n // Validate dataMaxPrice\n if (options.dataMaxPrice !== undefined) {\n if (\n typeof options.dataMaxPrice !== \"number\" ||\n options.dataMaxPrice <= 0\n ) {\n return {\n success: false,\n error: \"dataMaxPrice must be a positive number\",\n };\n }\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n };\n }\n\n // Validate date order\n if (options.startDate && options.endDate) {\n const startDate = new Date(options.startDate);\n const endDate = new Date(options.endDate);\n if (startDate > endDate) {\n return {\n success: false,\n error: \"startDate must be before endDate\",\n };\n }\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Validate excludedSources format\n if (options.excludedSources !== undefined) {\n if (!Array.isArray(options.excludedSources)) {\n return {\n success: false,\n error: \"excludedSources must be an array\",\n };\n }\n\n const excludedSourcesValidation = this.validateSources(\n options.excludedSources\n );\n if (!excludedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludedSources format. Invalid sources: ${excludedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query: query.trim(),\n search_type: finalSearchType,\n data_max_price: options.dataMaxPrice ?? defaultDataMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.structuredOutput !== undefined) {\n payload.structured_output = options.structuredOutput;\n }\n\n if (options.systemInstructions !== undefined) {\n payload.system_instructions = options.systemInstructions.trim();\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludedSources !== undefined) {\n payload.excluded_sources = options.excludedSources;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/answer`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n };\n }\n }\n}\n\nexport type {\n SearchResponse,\n SearchType,\n FeedbackSentiment,\n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength,\n AnswerOptions,\n AnswerResponse,\n AnswerSuccessResponse,\n AnswerErrorResponse,\n SearchMetadata,\n AIUsage,\n Cost,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAWX,IAAM,QAAN,MAAY;AAAA,EAIjB,YACE,QACA,UAAkB,2BAClB;AACA,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AACA,UAAM,aAAa,IAAI,KAAK,IAAI;AAChC,WAAO,sBAAsB,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKQ,YAAY,KAAsB;AACxC,QAAI;AACF,UAAI,IAAI,GAAG;AACX,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,eAAe,QAAy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aAAa,QAAQ;AAAA,MAC/B;AAEA,UAAI,QAAQ,YAAY,QAAW;AACjC,gBAAQ,WAAW,QAAQ;AAAA,MAC7B;AAEA,UAAI,QAAQ,aAAa,QAAW;AAClC,gBAAQ,YAAY,QAAQ;AAAA,MAC9B;AAEA,YAAM,WAAW,MAAM,aAAAA,QAAM,KAAK,GAAG,KAAK,OAAO,WAAW,SAAS;AAAA,QACnE,SAAS,KAAK;AAAA,MAChB,CAAC;AAED,UAAI,CAAC,SAAS,UAAU,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACvE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,SAAS,MAAM,SAAS;AAAA,QACjC;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n SearchResponse,\n SearchType,\n SearchOptions,\n ContentsOptions,\n ContentsResponse,\n AnswerOptions,\n AnswerResponse,\n} from \"./types\";\n\n\n// Valyu API client\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(\n apiKey?: string,\n baseUrl: string = \"https://api.valyu.ai/v1\"\n ) {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Validates if a string is a valid URL\n */\n private validateUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Validates if a string is a valid domain (with optional path)\n */\n private validateDomain(domain: string): boolean {\n // Domain must have at least one dot and valid structure\n // Supports: example.com, example.com/path, subdomain.example.com/path/to/resource\n const domainRegex =\n /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\/.+)?$/;\n return domainRegex.test(domain);\n }\n\n /**\n * Validates if a string is a valid dataset identifier (provider/datasetname)\n */\n private validateDatasetId(datasetId: string): boolean {\n // Dataset format: provider/datasetname (exactly one slash)\n // Provider and dataset name can contain alphanumeric, hyphens, underscores\n const parts = datasetId.split(\"/\");\n if (parts.length !== 2) return false;\n\n const providerRegex = /^[a-zA-Z0-9_-]+$/;\n const datasetRegex = /^[a-zA-Z0-9_-]+$/;\n\n return (\n providerRegex.test(parts[0]) &&\n datasetRegex.test(parts[1]) &&\n parts[0].length > 0 &&\n parts[1].length > 0\n );\n }\n\n /**\n * Validates source strings (domains, URLs, or dataset IDs)\n */\n private validateSource(source: string): boolean {\n // Check if it's a valid URL\n if (this.validateUrl(source)) {\n return true;\n }\n\n // Check if it's a valid domain (with optional path)\n if (this.validateDomain(source)) {\n return true;\n }\n\n // Check if it's a valid dataset identifier\n if (this.validateDatasetId(source)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Validates an array of source strings\n */\n private validateSources(sources: string[]): {\n valid: boolean;\n invalidSources: string[];\n } {\n const invalidSources: string[] = [];\n\n for (const source of sources) {\n if (!this.validateSource(source)) {\n invalidSources.push(source);\n }\n }\n\n return {\n valid: invalidSources.length === 0,\n invalidSources,\n };\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to search results\n */\n async search(\n query: string,\n options: SearchOptions = {}\n ): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Validate excludeSources format\n if (options.excludeSources !== undefined) {\n if (!Array.isArray(options.excludeSources)) {\n return {\n success: false,\n error: \"excludeSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const excludeSourcesValidation = this.validateSources(\n options.excludeSources\n );\n if (!excludeSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludeSources format. Invalid sources: ${excludeSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold:\n options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/deepsearch`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Extract content from URLs with optional AI processing\n * @param urls - Array of URLs to process (max 10)\n * @param options - Content extraction configuration options\n * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n * @param options.extractEffort - Extraction thoroughness: \"normal\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(\n urls: string[],\n options: ContentsOptions = {}\n ): Promise<ContentsResponse> {\n try {\n // Validate URLs array\n if (!urls || !Array.isArray(urls)) {\n return {\n success: false,\n error: \"urls must be an array\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length === 0) {\n return {\n success: false,\n error: \"urls array cannot be empty\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 URLs allowed per request\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate extractEffort if provided\n if (\n options.extractEffort &&\n ![\"normal\", \"high\", \"auto\"].includes(options.extractEffort)\n ) {\n return {\n success: false,\n error: \"extractEffort must be 'normal', 'high', or 'auto'\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate responseLength if provided\n if (options.responseLength !== undefined) {\n const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n if (\n typeof options.responseLength === \"string\" &&\n !validLengths.includes(options.responseLength)\n ) {\n return {\n success: false,\n error:\n \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n if (\n typeof options.responseLength === \"number\" &&\n options.responseLength <= 0\n ) {\n return {\n success: false,\n error: \"responseLength number must be positive\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n urls,\n };\n\n // Add optional parameters only if provided\n if (options.summary !== undefined) {\n payload.summary = options.summary;\n }\n\n if (options.extractEffort !== undefined) {\n payload.extract_effort = options.extractEffort;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.maxPriceDollars !== undefined) {\n payload.max_price_dollars = options.maxPriceDollars;\n }\n\n const response = await axios.post(`${this.baseUrl}/contents`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Get AI-powered answers using the Valyu Answer API\n * @param query - The question or query string\n * @param options - Answer configuration options\n * @param options.structuredOutput - JSON Schema object for structured responses\n * @param options.systemInstructions - Custom system-level instructions (max 2000 chars)\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.dataMaxPrice - Maximum spend (USD) for data retrieval\n * @param options.countryCode - Country code filter for search results\n * @param options.includedSources - List of specific sources to include\n * @param options.excludedSources - List of URLs/domains to exclude from search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to answer response\n */\n async answer(\n query: string,\n options: AnswerOptions = {}\n ): Promise<AnswerResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultDataMaxPrice = 30.0;\n\n // Validate query\n if (!query || typeof query !== \"string\" || query.trim().length === 0) {\n return {\n success: false,\n error: \"Query is required and must be a non-empty string\",\n };\n }\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n };\n }\n\n // Validate systemInstructions length\n if (options.systemInstructions !== undefined) {\n if (typeof options.systemInstructions !== \"string\") {\n return {\n success: false,\n error: \"systemInstructions must be a string\",\n };\n }\n\n const trimmed = options.systemInstructions.trim();\n if (trimmed.length === 0) {\n return {\n success: false,\n error: \"systemInstructions cannot be empty when provided\",\n };\n }\n\n if (trimmed.length > 2000) {\n return {\n success: false,\n error: \"systemInstructions must be 2000 characters or less\",\n };\n }\n }\n\n // Validate dataMaxPrice\n if (options.dataMaxPrice !== undefined) {\n if (\n typeof options.dataMaxPrice !== \"number\" ||\n options.dataMaxPrice <= 0\n ) {\n return {\n success: false,\n error: \"dataMaxPrice must be a positive number\",\n };\n }\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n };\n }\n\n // Validate date order\n if (options.startDate && options.endDate) {\n const startDate = new Date(options.startDate);\n const endDate = new Date(options.endDate);\n if (startDate > endDate) {\n return {\n success: false,\n error: \"startDate must be before endDate\",\n };\n }\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Validate excludedSources format\n if (options.excludedSources !== undefined) {\n if (!Array.isArray(options.excludedSources)) {\n return {\n success: false,\n error: \"excludedSources must be an array\",\n };\n }\n\n const excludedSourcesValidation = this.validateSources(\n options.excludedSources\n );\n if (!excludedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludedSources format. Invalid sources: ${excludedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query: query.trim(),\n search_type: finalSearchType,\n data_max_price: options.dataMaxPrice ?? defaultDataMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.structuredOutput !== undefined) {\n payload.structured_output = options.structuredOutput;\n }\n\n if (options.systemInstructions !== undefined) {\n payload.system_instructions = options.systemInstructions.trim();\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludedSources !== undefined) {\n payload.excluded_sources = options.excludedSources;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/answer`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n };\n }\n }\n}\n\nexport type {\n SearchResponse,\n SearchType,\n FeedbackSentiment,\n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength,\n AnswerOptions,\n AnswerResponse,\n AnswerSuccessResponse,\n AnswerErrorResponse,\n SearchMetadata,\n AIUsage,\n Cost,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAaX,IAAM,QAAN,MAAY;AAAA,EAIjB,YACE,QACA,UAAkB,2BAClB;AACA,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AACA,UAAM,aAAa,IAAI,KAAK,IAAI;AAChC,WAAO,sBAAsB,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKQ,YAAY,KAAsB;AACxC,QAAI;AACF,UAAI,IAAI,GAAG;AACX,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,eAAe,QAAyB;AAG9C,UAAM,cACJ;AACF,WAAO,YAAY,KAAK,MAAM;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKQ,kBAAkB,WAA4B;AAGpD,UAAM,QAAQ,UAAU,MAAM,GAAG;AACjC,QAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,UAAM,gBAAgB;AACtB,UAAM,eAAe;AAErB,WACE,cAAc,KAAK,MAAM,CA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,SAAS,KAAK;AAAA,MAChB,CAAC;AAED,UAAI,CAAC,SAAS,UAAU,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACvE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,SAAS,MAAM,SAAS;AAAA,QACjC;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n SearchResponse,\n SearchType,\n SearchOptions,\n ContentsOptions,\n ContentsResponse,\n AnswerOptions,\n AnswerResponse,\n} from \"./types\";\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(\n apiKey?: string,\n baseUrl: string = \"https://api.valyu.ai/v1\"\n ) {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Validates if a string is a valid URL\n */\n private validateUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Validates if a string is a valid domain (with optional path)\n */\n private validateDomain(domain: string): boolean {\n // Domain must have at least one dot and valid structure\n // Supports: example.com, example.com/path, subdomain.example.com/path/to/resource\n const domainRegex =\n /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\/.+)?$/;\n return domainRegex.test(domain);\n }\n\n /**\n * Validates if a string is a valid dataset identifier (provider/datasetname)\n */\n private validateDatasetId(datasetId: string): boolean {\n // Dataset format: provider/datasetname (exactly one slash)\n // Provider and dataset name can contain alphanumeric, hyphens, underscores\n const parts = datasetId.split(\"/\");\n if (parts.length !== 2) return false;\n\n const providerRegex = /^[a-zA-Z0-9_-]+$/;\n const datasetRegex = /^[a-zA-Z0-9_-]+$/;\n\n return (\n providerRegex.test(parts[0]) &&\n datasetRegex.test(parts[1]) &&\n parts[0].length > 0 &&\n parts[1].length > 0\n );\n }\n\n /**\n * Validates source strings (domains, URLs, or dataset IDs)\n */\n private validateSource(source: string): boolean {\n // Check if it's a valid URL\n if (this.validateUrl(source)) {\n return true;\n }\n\n // Check if it's a valid domain (with optional path)\n if (this.validateDomain(source)) {\n return true;\n }\n\n // Check if it's a valid dataset identifier\n if (this.validateDatasetId(source)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Validates an array of source strings\n */\n private validateSources(sources: string[]): {\n valid: boolean;\n invalidSources: string[];\n } {\n const invalidSources: string[] = [];\n\n for (const source of sources) {\n if (!this.validateSource(source)) {\n invalidSources.push(source);\n }\n }\n\n return {\n valid: invalidSources.length === 0,\n invalidSources,\n };\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to search results\n */\n async search(\n query: string,\n options: SearchOptions = {}\n ): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Validate excludeSources format\n if (options.excludeSources !== undefined) {\n if (!Array.isArray(options.excludeSources)) {\n return {\n success: false,\n error: \"excludeSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const excludeSourcesValidation = this.validateSources(\n options.excludeSources\n );\n if (!excludeSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludeSources format. Invalid sources: ${excludeSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold:\n options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/deepsearch`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Extract content from URLs with optional AI processing\n * @param urls - Array of URLs to process (max 10)\n * @param options - Content extraction configuration options\n * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n * @param options.extractEffort - Extraction thoroughness: \"normal\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(\n urls: string[],\n options: ContentsOptions = {}\n ): Promise<ContentsResponse> {\n try {\n // Validate URLs array\n if (!urls || !Array.isArray(urls)) {\n return {\n success: false,\n error: \"urls must be an array\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length === 0) {\n return {\n success: false,\n error: \"urls array cannot be empty\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 URLs allowed per request\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate extractEffort if provided\n if (\n options.extractEffort &&\n ![\"normal\", \"high\", \"auto\"].includes(options.extractEffort)\n ) {\n return {\n success: false,\n error: \"extractEffort must be 'normal', 'high', or 'auto'\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate responseLength if provided\n if (options.responseLength !== undefined) {\n const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n if (\n typeof options.responseLength === \"string\" &&\n !validLengths.includes(options.responseLength)\n ) {\n return {\n success: false,\n error:\n \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n if (\n typeof options.responseLength === \"number\" &&\n options.responseLength <= 0\n ) {\n return {\n success: false,\n error: \"responseLength number must be positive\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n urls,\n };\n\n // Add optional parameters only if provided\n if (options.summary !== undefined) {\n payload.summary = options.summary;\n }\n\n if (options.extractEffort !== undefined) {\n payload.extract_effort = options.extractEffort;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.maxPriceDollars !== undefined) {\n payload.max_price_dollars = options.maxPriceDollars;\n }\n\n const response = await axios.post(`${this.baseUrl}/contents`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Get AI-powered answers using the Valyu Answer API\n * @param query - The question or query string\n * @param options - Answer configuration options\n * @param options.structuredOutput - JSON Schema object for structured responses\n * @param options.systemInstructions - Custom system-level instructions (max 2000 chars)\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.dataMaxPrice - Maximum spend (USD) for data retrieval\n * @param options.countryCode - Country code filter for search results\n * @param options.includedSources - List of specific sources to include\n * @param options.excludedSources - List of URLs/domains to exclude from search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to answer response\n */\n async answer(\n query: string,\n options: AnswerOptions = {}\n ): Promise<AnswerResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultDataMaxPrice = 30.0;\n\n // Validate query\n if (!query || typeof query !== \"string\" || query.trim().length === 0) {\n return {\n success: false,\n error: \"Query is required and must be a non-empty string\",\n };\n }\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n };\n }\n\n // Validate systemInstructions length\n if (options.systemInstructions !== undefined) {\n if (typeof options.systemInstructions !== \"string\") {\n return {\n success: false,\n error: \"systemInstructions must be a string\",\n };\n }\n\n const trimmed = options.systemInstructions.trim();\n if (trimmed.length === 0) {\n return {\n success: false,\n error: \"systemInstructions cannot be empty when provided\",\n };\n }\n\n if (trimmed.length > 2000) {\n return {\n success: false,\n error: \"systemInstructions must be 2000 characters or less\",\n };\n }\n }\n\n // Validate dataMaxPrice\n if (options.dataMaxPrice !== undefined) {\n if (\n typeof options.dataMaxPrice !== \"number\" ||\n options.dataMaxPrice <= 0\n ) {\n return {\n success: false,\n error: \"dataMaxPrice must be a positive number\",\n };\n }\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n };\n }\n\n // Validate date order\n if (options.startDate && options.endDate) {\n const startDate = new Date(options.startDate);\n const endDate = new Date(options.endDate);\n if (startDate > endDate) {\n return {\n success: false,\n error: \"startDate must be before endDate\",\n };\n }\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Validate excludedSources format\n if (options.excludedSources !== undefined) {\n if (!Array.isArray(options.excludedSources)) {\n return {\n success: false,\n error: \"excludedSources must be an array\",\n };\n }\n\n const excludedSourcesValidation = this.validateSources(\n options.excludedSources\n );\n if (!excludedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludedSources format. Invalid sources: ${excludedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query: query.trim(),\n search_type: finalSearchType,\n data_max_price: options.dataMaxPrice ?? defaultDataMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.structuredOutput !== undefined) {\n payload.structured_output = options.structuredOutput;\n }\n\n if (options.systemInstructions !== undefined) {\n payload.system_instructions = options.systemInstructions.trim();\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludedSources !== undefined) {\n payload.excluded_sources = options.excludedSources;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/answer`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n };\n }\n }\n}\n\nexport type {\n SearchResponse,\n SearchType,\n FeedbackSentiment,\n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength,\n AnswerOptions,\n AnswerResponse,\n AnswerSuccessResponse,\n AnswerErrorResponse,\n SearchMetadata,\n AIUsage,\n Cost,\n} from \"./types\";\n"],"mappings":";AAAA,OAAO,WAAW;AAWX,IAAM,QAAN,MAAY;AAAA,EAIjB,YACE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;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n SearchResponse,\n SearchType,\n SearchOptions,\n ContentsOptions,\n ContentsResponse,\n AnswerOptions,\n AnswerResponse,\n} from \"./types\";\n\n\n// Valyu API client\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(\n apiKey?: string,\n baseUrl: string = \"https://api.valyu.ai/v1\"\n ) {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Validates if a string is a valid URL\n */\n private validateUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Validates if a string is a valid domain (with optional path)\n */\n private validateDomain(domain: string): boolean {\n // Domain must have at least one dot and valid structure\n // Supports: example.com, example.com/path, subdomain.example.com/path/to/resource\n const domainRegex =\n /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\/.+)?$/;\n return domainRegex.test(domain);\n }\n\n /**\n * Validates if a string is a valid dataset identifier (provider/datasetname)\n */\n private validateDatasetId(datasetId: string): boolean {\n // Dataset format: provider/datasetname (exactly one slash)\n // Provider and dataset name can contain alphanumeric, hyphens, underscores\n const parts = datasetId.split(\"/\");\n if (parts.length !== 2) return false;\n\n const providerRegex = /^[a-zA-Z0-9_-]+$/;\n const datasetRegex = /^[a-zA-Z0-9_-]+$/;\n\n return (\n providerRegex.test(parts[0]) &&\n datasetRegex.test(parts[1]) &&\n parts[0].length > 0 &&\n parts[1].length > 0\n );\n }\n\n /**\n * Validates source strings (domains, URLs, or dataset IDs)\n */\n private validateSource(source: string): boolean {\n // Check if it's a valid URL\n if (this.validateUrl(source)) {\n return true;\n }\n\n // Check if it's a valid domain (with optional path)\n if (this.validateDomain(source)) {\n return true;\n }\n\n // Check if it's a valid dataset identifier\n if (this.validateDatasetId(source)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Validates an array of source strings\n */\n private validateSources(sources: string[]): {\n valid: boolean;\n invalidSources: string[];\n } {\n const invalidSources: string[] = [];\n\n for (const source of sources) {\n if (!this.validateSource(source)) {\n invalidSources.push(source);\n }\n }\n\n return {\n valid: invalidSources.length === 0,\n invalidSources,\n };\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to search results\n */\n async search(\n query: string,\n options: SearchOptions = {}\n ): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Validate excludeSources format\n if (options.excludeSources !== undefined) {\n if (!Array.isArray(options.excludeSources)) {\n return {\n success: false,\n error: \"excludeSources must be an array\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n const excludeSourcesValidation = this.validateSources(\n options.excludeSources\n );\n if (!excludeSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludeSources format. Invalid sources: ${excludeSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold:\n options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/deepsearch`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Extract content from URLs with optional AI processing\n * @param urls - Array of URLs to process (max 10)\n * @param options - Content extraction configuration options\n * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n * @param options.extractEffort - Extraction thoroughness: \"normal\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(\n urls: string[],\n options: ContentsOptions = {}\n ): Promise<ContentsResponse> {\n try {\n // Validate URLs array\n if (!urls || !Array.isArray(urls)) {\n return {\n success: false,\n error: \"urls must be an array\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length === 0) {\n return {\n success: false,\n error: \"urls array cannot be empty\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 URLs allowed per request\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate extractEffort if provided\n if (\n options.extractEffort &&\n ![\"normal\", \"high\", \"auto\"].includes(options.extractEffort)\n ) {\n return {\n success: false,\n error: \"extractEffort must be 'normal', 'high', or 'auto'\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n // Validate responseLength if provided\n if (options.responseLength !== undefined) {\n const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n if (\n typeof options.responseLength === \"string\" &&\n !validLengths.includes(options.responseLength)\n ) {\n return {\n success: false,\n error:\n \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n if (\n typeof options.responseLength === \"number\" &&\n options.responseLength <= 0\n ) {\n return {\n success: false,\n error: \"responseLength number must be positive\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n urls,\n };\n\n // Add optional parameters only if provided\n if (options.summary !== undefined) {\n payload.summary = options.summary;\n }\n\n if (options.extractEffort !== undefined) {\n payload.extract_effort = options.extractEffort;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.maxPriceDollars !== undefined) {\n payload.max_price_dollars = options.maxPriceDollars;\n }\n\n const response = await axios.post(`${this.baseUrl}/contents`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0,\n };\n }\n }\n\n /**\n * Get AI-powered answers using the Valyu Answer API\n * @param query - The question or query string\n * @param options - Answer configuration options\n * @param options.structuredOutput - JSON Schema object for structured responses\n * @param options.systemInstructions - Custom system-level instructions (max 2000 chars)\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.dataMaxPrice - Maximum spend (USD) for data retrieval\n * @param options.countryCode - Country code filter for search results\n * @param options.includedSources - List of specific sources to include\n * @param options.excludedSources - List of URLs/domains to exclude from search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n * @returns Promise resolving to answer response\n */\n async answer(\n query: string,\n options: AnswerOptions = {}\n ): Promise<AnswerResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultDataMaxPrice = 30.0;\n\n // Validate query\n if (!query || typeof query !== \"string\" || query.trim().length === 0) {\n return {\n success: false,\n error: \"Query is required and must be a non-empty string\",\n };\n }\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (\n providedSearchTypeString === \"web\" ||\n providedSearchTypeString === \"proprietary\" ||\n providedSearchTypeString === \"all\"\n ) {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error:\n \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n };\n }\n\n // Validate systemInstructions length\n if (options.systemInstructions !== undefined) {\n if (typeof options.systemInstructions !== \"string\") {\n return {\n success: false,\n error: \"systemInstructions must be a string\",\n };\n }\n\n const trimmed = options.systemInstructions.trim();\n if (trimmed.length === 0) {\n return {\n success: false,\n error: \"systemInstructions cannot be empty when provided\",\n };\n }\n\n if (trimmed.length > 2000) {\n return {\n success: false,\n error: \"systemInstructions must be 2000 characters or less\",\n };\n }\n }\n\n // Validate dataMaxPrice\n if (options.dataMaxPrice !== undefined) {\n if (\n typeof options.dataMaxPrice !== \"number\" ||\n options.dataMaxPrice <= 0\n ) {\n return {\n success: false,\n error: \"dataMaxPrice must be a positive number\",\n };\n }\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n };\n }\n\n // Validate date order\n if (options.startDate && options.endDate) {\n const startDate = new Date(options.startDate);\n const endDate = new Date(options.endDate);\n if (startDate > endDate) {\n return {\n success: false,\n error: \"startDate must be before endDate\",\n };\n }\n }\n\n // Validate includedSources format\n if (options.includedSources !== undefined) {\n if (!Array.isArray(options.includedSources)) {\n return {\n success: false,\n error: \"includedSources must be an array\",\n };\n }\n\n const includedSourcesValidation = this.validateSources(\n options.includedSources\n );\n if (!includedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Validate excludedSources format\n if (options.excludedSources !== undefined) {\n if (!Array.isArray(options.excludedSources)) {\n return {\n success: false,\n error: \"excludedSources must be an array\",\n };\n }\n\n const excludedSourcesValidation = this.validateSources(\n options.excludedSources\n );\n if (!excludedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludedSources format. Invalid sources: ${excludedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query: query.trim(),\n search_type: finalSearchType,\n data_max_price: options.dataMaxPrice ?? defaultDataMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.structuredOutput !== undefined) {\n payload.structured_output = options.structuredOutput;\n }\n\n if (options.systemInstructions !== undefined) {\n payload.system_instructions = options.systemInstructions.trim();\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludedSources !== undefined) {\n payload.excluded_sources = options.excludedSources;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/answer`, payload, {\n headers: this.headers,\n });\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n };\n }\n }\n}\n\nexport type {\n SearchResponse,\n SearchType,\n FeedbackSentiment,\n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength,\n AnswerOptions,\n AnswerResponse,\n AnswerSuccessResponse,\n AnswerErrorResponse,\n SearchMetadata,\n AIUsage,\n Cost,\n} from \"./types\";\n"],"mappings":";AAAA,OAAO,WAAW;AAaX,IAAM,QAAN,MAAY;AAAA,EAIjB,YACE,QACA,UAAkB,2BAClB;AACA,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI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QAAQ,mBAAmB,KAAK;AAAA,MAChE;AAEA,UAAI,QAAQ,gBAAgB,QAAW;AACrC,gBAAQ,eAAe,QAAQ;AAAA,MACjC;AAEA,UAAI,QAAQ,oBAAoB,QAAW;AACzC,gBAAQ,mBAAmB,QAAQ;AAAA,MACrC;AAEA,UAAI,QAAQ,oBAAoB,QAAW;AACzC,gBAAQ,mBAAmB,QAAQ;AAAA,MACrC;AAEA,UAAI,QAAQ,cAAc,QAAW;AACnC,gBAAQ,aAAa,QAAQ;AAAA,MAC/B;AAEA,UAAI,QAAQ,YAAY,QAAW;AACjC,gBAAQ,WAAW,QAAQ;AAAA,MAC7B;AAEA,UAAI,QAAQ,aAAa,QAAW;AAClC,gBAAQ,YAAY,QAAQ;AAAA,MAC9B;AAEA,YAAM,WAAW,MAAM,MAAM,KAAK,GAAG,KAAK,OAAO,WAAW,SAAS;AAAA,QACnE,SAAS,KAAK;AAAA,MAChB,CAAC;AAED,UAAI,CAAC,SAAS,UAAU,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACvE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,SAAS,MAAM,SAAS;AAAA,QACjC;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valyu-js",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Search for AIs - DeepSearch and Content API.",
5
5
  "files": [
6
6
  "dist"