Comparing version 1.0.13 to 1.0.14-beta.0
@@ -14,2 +14,4 @@ /** | ||
* @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company. | ||
* @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words. | ||
* @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words. | ||
*/ | ||
@@ -25,7 +27,8 @@ type BaseSearchOptions = { | ||
category?: string; | ||
includeText?: string[]; | ||
excludeText?: string[]; | ||
}; | ||
/** | ||
* Search options for performing a search query. | ||
* @typedef {Object} ContentsOptions | ||
* @property {string[]} [formats] - An array of format types asked for. Currently supports `extract` (first 1000 tokens) and `text` (full parsed HTML text). If this isn't specified, defaults to `extract`. | ||
* @typedef {Object} RegularSearchOptions | ||
*/ | ||
@@ -48,2 +51,4 @@ type RegularSearchOptions = BaseSearchOptions & { | ||
* @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company. | ||
* @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words. | ||
* @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words. | ||
*/ | ||
@@ -59,2 +64,4 @@ type FindSimilarOptions = BaseSearchOptions & { | ||
* @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary. | ||
* @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is "never" for neural/auto search, "fallback" for keyword search. | ||
* @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true. | ||
*/ | ||
@@ -65,4 +72,11 @@ type ContentsOptions = { | ||
summary?: SummaryContentsOptions | true; | ||
livecrawl?: LivecrawlOptions; | ||
filterEmptyResults?: boolean; | ||
}; | ||
/** | ||
* Options for livecrawling contents | ||
* @typedef {string} LivecrawlOptions | ||
*/ | ||
type LivecrawlOptions = "never" | "fallback" | "always"; | ||
/** | ||
* Options for retrieving text from page. | ||
@@ -127,3 +141,3 @@ * @typedef {Object} TextContentsOptions | ||
*/ | ||
type ContentsResultComponent<T extends ContentsOptions> = Default<(T['text'] extends (object | true) ? TextResponse : {}) & (T['highlights'] extends (object | true) ? HighlightsResponse : {}) & (T['summary'] extends (object | true) ? SummaryResponse : {}), TextResponse>; | ||
type ContentsResultComponent<T extends ContentsOptions> = Default<(T["text"] extends object | true ? TextResponse : {}) & (T["highlights"] extends object | true ? HighlightsResponse : {}) & (T["summary"] extends object | true ? SummaryResponse : {}), TextResponse>; | ||
/** | ||
@@ -214,2 +228,2 @@ * Represents a search result object. | ||
export { BaseSearchOptions, ContentsOptions, ContentsResultComponent, Default, FindSimilarOptions, HighlightsContentsOptions, HighlightsResponse, RegularSearchOptions, SearchResponse, SearchResult, SummaryContentsOptions, SummaryResponse, TextContentsOptions, TextResponse, Exa as default }; | ||
export { BaseSearchOptions, ContentsOptions, ContentsResultComponent, Default, FindSimilarOptions, HighlightsContentsOptions, HighlightsResponse, LivecrawlOptions, RegularSearchOptions, SearchResponse, SearchResult, SummaryContentsOptions, SummaryResponse, TextContentsOptions, TextResponse, Exa as default }; |
@@ -48,3 +48,5 @@ "use strict"; | ||
if (!apiKey) { | ||
throw new Error("API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)"); | ||
throw new Error( | ||
"API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)" | ||
); | ||
} | ||
@@ -95,9 +97,18 @@ } | ||
async searchAndContents(query, options) { | ||
const { text, highlights, summary, ...rest } = options || {}; | ||
const { | ||
text, | ||
highlights, | ||
summary, | ||
livecrawl, | ||
filterEmptyResults, | ||
...rest | ||
} = options || {}; | ||
const isBeta = process.env.NPM_CONFIG_TAG === "beta"; | ||
return await this.request("/search", "POST", { | ||
query, | ||
contents: !text && !highlights && !summary ? { text: true } : { | ||
contents: !text && !highlights && !summary ? { text: true, ...isBeta ? { livecrawl, filterEmptyResults } : {} } : { | ||
...text ? { text } : {}, | ||
...highlights ? { highlights } : {}, | ||
...summary ? { summary } : {} | ||
...summary ? { summary } : {}, | ||
...isBeta ? { livecrawl, filterEmptyResults } : {} | ||
}, | ||
@@ -123,9 +134,18 @@ ...rest | ||
async findSimilarAndContents(url, options) { | ||
const { text, highlights, summary, ...rest } = options || {}; | ||
const { | ||
text, | ||
highlights, | ||
summary, | ||
livecrawl, | ||
filterEmptyResults, | ||
...rest | ||
} = options || {}; | ||
const isBeta = process.env.NPM_CONFIG_TAG === "beta"; | ||
return await this.request("/findSimilar", "POST", { | ||
url, | ||
contents: !text && !highlights && !summary ? { text: true } : { | ||
contents: !text && !highlights && !summary ? { text: true, ...isBeta ? { livecrawl, filterEmptyResults } : {} } : { | ||
...text ? { text } : {}, | ||
...highlights ? { highlights } : {}, | ||
...summary ? { summary } : {} | ||
...summary ? { summary } : {}, | ||
...isBeta ? { livecrawl, filterEmptyResults } : {} | ||
}, | ||
@@ -142,2 +162,4 @@ ...rest | ||
async getContents(ids, options) { | ||
const { livecrawl, filterEmptyResults, ...rest } = options || {}; | ||
const isBeta = process.env.NPM_CONFIG_TAG === "beta"; | ||
if (ids.length === 0) { | ||
@@ -154,3 +176,7 @@ throw new Error("Must provide at least one ID"); | ||
} | ||
return await this.request(`/contents`, "POST", { ids: requestIds, ...options }); | ||
return await this.request(`/contents`, "POST", { | ||
ids: requestIds, | ||
...isBeta ? { livecrawl, filterEmptyResults } : {}, | ||
...rest | ||
}); | ||
} | ||
@@ -157,0 +183,0 @@ }; |
{ | ||
"name": "exa-js", | ||
"version": "1.0.13", | ||
"version": "1.0.14-beta.0", | ||
"description": "Exa SDK for Node.js and the browser", | ||
@@ -28,2 +28,7 @@ "publishConfig": { | ||
"generate-docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts", | ||
"build:beta": "cross-env NPM_CONFIG_TAG=beta npm run build", | ||
"version:beta": "npm version --no-git-tag-version 1.0.14-beta.0", | ||
"version:stable": "npm version patch", | ||
"publish:beta": "npm run version:beta && npm run build:beta && npm publish --tag beta", | ||
"publish:stable": "npm run version:stable && npm run build && npm publish", | ||
"prepublishOnly": "npm run build" | ||
@@ -33,7 +38,8 @@ }, | ||
"devDependencies": { | ||
"cross-env": "^7.0.3", | ||
"prettier": "2.8.4", | ||
"tsup": "6.6.3", | ||
"typescript": "4.9.5", | ||
"typedoc": "^0.25.4", | ||
"typedoc-plugin-markdown": "^3.17.1", | ||
"typescript": "4.9.5", | ||
"vitest": "0.28.5" | ||
@@ -40,0 +46,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
62489
548
7
1
8