@sajari/sdk-react
Version:
React SDK for the Sajari API
81 lines (80 loc) • 2.51 kB
TypeScript
import { Analytics, GoogleAnalytics } from "./analytics";
import { CallbackFn } from "./listener";
import { Response } from "./response";
import { ClickTracking, NoTracking } from "./tracking";
export declare class Pipeline {
config: {
project: string;
collection: string;
endpoint?: string;
};
private pipeline;
private name;
private version?;
private tracking;
private listeners;
private searchCount;
private response;
private analytics;
/**
* Constructs a Pipeline object.
* @param config Project, Collection config
* @param name Name of the pipeline.
* @param [tracking=ClickTracking()] Default tracking to use in searches.
* @param [analyticsAdapters=GoogleAnalytics]
*/
constructor(config: {
project: string;
collection: string;
endpoint?: string;
}, name: string | {
name: string;
version?: string;
}, tracking?: ClickTracking | NoTracking, analyticsAdapters?: (typeof GoogleAnalytics)[]);
/**
* Register a listener for a specific event.
* @param event Event to listen for
* @param callback Callback to run when the event happens.
* @return The unregister function to remove the callback from the listener.
*/
listen(event: string, callback: CallbackFn): import("./listener").UnlistenFn;
/**
* Emits a search event to the search event listener.
* @private
*/
_emitSearchSent(values: {
[k: string]: string;
}): void;
/**
* Emits a results event to the results event listener.
* @private
*/
_emitResponseUpdated(response: Response): void;
/**
* Emits a result clicked event to the results clicked event listeners.
* @param value Value to send to the listeners.
*/
emitResultClicked(value: string): void;
/**
* Perform a search.
* @param values Key-value parameters to pass to the pipeline.
*/
search(values: {
[k: string]: string;
}): void;
/**
* Clears the error, response, and response values from this object.
* @param values Key-value pair parameters.
*/
clearResponse(values: {
[k: string]: string;
}): void;
/**
* The current response.
*/
getResponse(): Response;
/**
* The analytics adaptor connected to this pipeline.
*/
getAnalytics(): Analytics;
}