Comparing version 1.0.14 to 1.0.15-beta.2
@@ -61,2 +61,4 @@ /** | ||
* @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. | ||
*/ | ||
@@ -67,4 +69,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. | ||
@@ -129,3 +138,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>; | ||
/** | ||
@@ -216,2 +225,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.14", | ||
"version": "1.0.15-beta.2", | ||
"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 prerelease --preid=beta", | ||
"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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
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
62478
548
7
1
1
8
2