New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

brave-search

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brave-search - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

47

dist/braveSearch.d.ts
import { BraveSearchOptions, LocalDescriptionsOptions, LocalDescriptionsSearchApiResponse, LocalPoiOptions, LocalPoiSearchApiResponse, SummarizerOptions, SummarizerSearchApiResponse, WebSearchApiResponse } from "./types";
/**
* An error class specific to BraveSearch API interactions.
* It includes additional information about the response data that caused the error.
*/
declare class BraveSearchError extends Error {
responseData: any;
/**
* Initializes a new instance of the BraveSearchError class.
* @param message The error message.
* @param responseData The response data that caused the error.
*/
constructor(message: string, responseData?: any);
}
/**
* The main class for interacting with the Brave Search API.
* It provides methods for web search, local POI search, and summarization.
*/
declare class BraveSearch {

@@ -11,2 +24,9 @@ private apiKey;

private maxPollAttempts;
/**
* Initializes a new instance of the BraveSearch class.
* @param apiKey The API key for accessing the Brave Search API.
* @param options Optional settings to configure the search behavior.
* - maxPollAttempts: Maximum number of attempts to poll for a summary.
* - pollInterval: Interval in milliseconds between polling attempts.
*/
constructor(apiKey: string, options?: {

@@ -16,8 +36,33 @@ maxPollAttempts?: number;

});
/**
* Performs a web search using the provided query and options.
* @param query The search query string.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
webSearch(query: string, options?: BraveSearchOptions): Promise<WebSearchApiResponse>;
getSummarizedAnswer(query: string, options?: Omit<BraveSearchOptions, 'summary'>, summarizerOptions?: SummarizerOptions): {
/**
* Executes a web search for the provided query and polls for a summary if available.
* @param query The search query string.
* @param options Optional settings to configure the search behavior.
* @param summarizerOptions Optional settings specific to summarization.
* @returns An object containing promises for the web search results and the summarized answer.
*/
getSummarizedAnswer(query: string, options?: Omit<BraveSearchOptions, "summary">, summarizerOptions?: SummarizerOptions): {
summary: Promise<SummarizerSearchApiResponse | undefined>;
webSearch: Promise<WebSearchApiResponse>;
};
/**
* Searches for local points of interest using the provided IDs and options.
* @param ids The IDs of the local points of interest.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
localPoiSearch(ids: string[], options?: LocalPoiOptions): Promise<LocalPoiSearchApiResponse>;
/**
* Retrieves descriptions for local points of interest using the provided IDs and options.
* @param ids The IDs of the local points of interest.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
localDescriptionsSearch(ids: string[], options?: LocalDescriptionsOptions): Promise<LocalDescriptionsSearchApiResponse>;

@@ -24,0 +69,0 @@ private pollForSummary;

@@ -23,3 +23,12 @@ "use strict";

const DEFAULT_POLLING_TIMEOUT = 20000;
/**
* An error class specific to BraveSearch API interactions.
* It includes additional information about the response data that caused the error.
*/
class BraveSearchError extends Error {
/**
* Initializes a new instance of the BraveSearchError class.
* @param message The error message.
* @param responseData The response data that caused the error.
*/
constructor(message, responseData) {

@@ -32,3 +41,14 @@ super(message);

exports.BraveSearchError = BraveSearchError;
/**
* The main class for interacting with the Brave Search API.
* It provides methods for web search, local POI search, and summarization.
*/
class BraveSearch {
/**
* Initializes a new instance of the BraveSearch class.
* @param apiKey The API key for accessing the Brave Search API.
* @param options Optional settings to configure the search behavior.
* - maxPollAttempts: Maximum number of attempts to poll for a summary.
* - pollInterval: Interval in milliseconds between polling attempts.
*/
constructor(apiKey, options) {

@@ -45,2 +65,8 @@ var _a, _b;

}
/**
* Performs a web search using the provided query and options.
* @param query The search query string.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
async webSearch(query, options = {}) {

@@ -62,2 +88,9 @@ const params = new URLSearchParams({

}
/**
* Executes a web search for the provided query and polls for a summary if available.
* @param query The search query string.
* @param options Optional settings to configure the search behavior.
* @param summarizerOptions Optional settings specific to summarization.
* @returns An object containing promises for the web search results and the summarized answer.
*/
getSummarizedAnswer(query, options = {}, summarizerOptions = {}) {

@@ -80,2 +113,8 @@ try {

}
/**
* Searches for local points of interest using the provided IDs and options.
* @param ids The IDs of the local points of interest.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
async localPoiSearch(ids, options = {}) {

@@ -96,2 +135,8 @@ const params = new URLSearchParams({

}
/**
* Retrieves descriptions for local points of interest using the provided IDs and options.
* @param ids The IDs of the local points of interest.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
async localDescriptionsSearch(ids, options = {}) {

@@ -98,0 +143,0 @@ const params = new URLSearchParams({

4

package.json
{
"name": "brave-search",
"version": "0.6.0",
"description": "A TypeScript library for interacting with the Brave Search API, including web search, local POI search, and automatic summarization features.",
"version": "0.6.1",
"description": "A fully typed Brave Search API wrapper, providing easy access to web search, local POI search, and automatic polling for web search summary feature.",
"scripts": {

@@ -6,0 +6,0 @@ "build": "tsc",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc