import { IParseOptions } from 'qs'; import { IStringifyOptions } from 'qs'; import { ParsedQs } from 'qs'; /** * Version of the search API being used. * @public */ export declare const __API_VERSION__ = 6; /** * Current version of the library. * @public */ export declare const __VERSION__ = "7.0.2"; /** * Represents the information received for a banner for certain search. * @public */ export declare interface BannerInfo { /** Id of the banner. */ id: number; /** Desktop image of the banner. */ image: string; /** Mobile image of the banner. */ mobile_image: string; /** Custom HTML code of the banner. */ html_code: string; /** Target link of the banner. */ link: string; /** Whether to open the banner in a new window or not. */ blank: boolean; } /** * Represents a single search result when the `basic` transformer is * used. * * @public */ export declare interface BasicResult { /** Id of the result. */ id: string | number; /** Title of the result. */ title: string; /** Description of the result. */ description?: string; /** Link to the result. */ link: string; /** Image of the result. */ image_link?: string; /** Price of the result. Optional. */ price?: number; /** Sale price of the result. Optional. */ sale_price?: number; /** * Information provided from the data source to add the result * to the shopping cart. * * @deprecated Providing this kind of info in the data is a bad * practice because it can't be reutilized. */ add_to_cart?: string; /** Users score for the result. */ df_rating?: number; /** Id of the result in Doofinder. */ dfid: string; /** Type of the result in Doofinder. */ type: string; } /** * Parameters for the cart stats. * @public */ export declare interface CartItemStatsParams extends StatsParams { /** Unique ID of the item to be added/removed */ id: string; /** How many instances of the item are to be added/removed **/ amount: number | string; /** Name of the indice the item belongs to. i.e. "product" **/ index: string; /** The title that describe the item. Usually, the title of item's page **/ title: string; /** Price of the given item **/ price: number; } /** * Basic parameters for checkout requests. * @public */ export declare interface CheckoutParams extends StatsParams { /** Unique ID of the user. */ user_id?: string; } /** * Parameters for click stats with dfid. * @public */ export declare interface ClickStatsParamsWithDfid extends StatsParams { /** Optional ID of the custom results that produced the current set of results. */ custom_results_id?: string | number; /** Unique ID of the clicked result. */ dfid: string; /** Unique ID of the user. */ user_id?: string; /** Optional search terms. */ query?: string; } /** * Class that allows interacting with the Doofinder service. * @public */ export declare class Client { private _server; private _secret; private _endpoint; private _headers; /** * Returns the search server for this client. * @public */ get server(): string; /** * Returns the secret token for this client, if any. * @public */ get secret(): string; /** * Returns the headers set for this client. * @public */ get headers(): Record; /** * Returns the configured endpoint for this client. * @public */ get endpoint(): string; /** * Constructor. * * @remarks * * At least a search server is required. If none provided via the `server` * or the `secret` options, the default `'eu1-search.doofinder.com'` will be used. * * @param options - options to instantiate the client. */ constructor({ server, secret, headers }?: Partial); /** * Perform a request to a HTTP resource. * * @remarks * * If a payload is provided the request will be done via `POST` instead * of `GET`. * * @param resource - The resource to request. * @param params - An object with the parameters to serialize in the * URL querystring. Optional. * @param payload - Optional. * @param method - The method, by default will be GET. Optional. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ request(resource: string, params?: Record, payload?: Record, method?: Method): Promise; /** * Perform a search in Doofinder based on the provided parameters. * * @param query - An instance of `Query` or an object with valid * search parameters. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ search(query: Query | SearchParams): Promise; /** * Perform a search through indexed images of a search engine. * * @param query - An instance of `Query` or an object with valid * search parameters. * @param image - string image in base 64. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ searchImage(query: Query | SearchImageParams, image: string): Promise; /** * Perform a suggestion query in Doofinder based on the provided parameters. * * @param query - An instance of `Query` or an object with valid * search parameters. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ suggest(query: Query | SearchParams): Promise; /** * Perform a request to submit stats events to Doofinder. * * @param eventName - Type of stats to send. * @param params - Parameters for the query string. * @param method - HTTP method for the request.Default GET. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ stats(eventName: string, params: Record, method?: Method): Promise; /** * Build a URL for the provided resource. * * @param resource - URL part specifying the resource to be fetched * from the current version of the API. Should start by '/'. * @param querystring - A query string to be attached to the URL. * Must not start by '?' nor '&'. * @returns A valid URL. */ private _buildUrl; /** * Return a string representation of this class. * @returns A string. * @public */ toString(): string; /** * Normalize search params to a Query object. * * @param params - An instance of `Query` or an object with valid * search parameters. * @returns An instance of `Query`. */ private _buildSearchQueryObject; } /** * Options that can be used to create a Client instance. * @public */ export declare interface ClientOptions { /** * Search server: eu1-search.doofinder.com, us1-search.doofinder.com * @public */ server: string; /** * Secret token. May include or not the search server. */ secret: string; /** * Additional HTTP headers to send, if any. */ headers: Record; } /** * Manage clients for multiple servers as singletons with shared settings. * * @remarks * * GOLDEN RULE: Don't save references to clients obtained from the pool, * always request new ones. * * @example * * ```ts * ClientPool.getClient('eu1'); * ClientPool.getStatsClient('eu1'); * ``` * * @public */ export declare class ClientPool { private static _clientsPool; private static _statsClientsPool; private static _options; private constructor(); /** * Property to change shared options. * * When changed, all existing clients are removed so new ones get the * new options. * * @public */ static get options(): Partial; static set options(value: Partial); /** * Get a client for the given server with the shared options. * * @param server - A valid search server. * @returns An instance of `Client`. * * @public */ static getClient(server: string): Client; /** * Get a stats client for the given server with the shared options. * * @param server - A valid search server. * @returns An instance of `StatsClient`. * * @public */ static getStatsClient(server: string): StatsClient; /** * Reset the shared options of the pool. * @public */ static reset(): void; /** * Remove al existing clients from the pool. * @public */ static clear(): void; } /** * Represents an error response for a failed HTTP response from Doofinder. * @public */ export declare class ClientResponseError extends Error { /** * Status code of the HTTP response. * @public */ statusCode: number; /** * The Response received by the client. * @public */ response: Response; /** * The constructor for the response error. * @param response - An HTTP response from the fetch API. * @public */ constructor(response: Response); } /** * Create a copy of the provided data. * * @param src - The data to clone. * @returns A copy of the data. * * @public */ export declare function clone(src: any): any; /** * Parse a querystring into a parameters object. * * @remarks * * This is a wrapper of `qs.parse` from the `qs` library. * * See the {@link https://www.npmjs.com/package/qs | qs} package for more info. * * @param querystring - The querystring from a URL. * @param options - Options to parse the querystring. * * @returns A parameters object. * @public */ export declare function decode(str: string, options?: IParseOptions): ParsedQs | unknown; /** * Encode parameters for use in a querystring. * * @remarks * * This is a wrapper of `qs.stringify` from the `qs` library. * * See the {@link https://www.npmjs.com/package/qs | qs} package for more info. * * @param params - A plain object with request parameters * @param options - Options to serialize the parameters. * * @returns A valid querystring. * @public */ export declare function encode(obj: any, options?: IStringifyOptions): string; /** * Merge the contents of two or more objects together into the first object. * * @remarks * * Ported from {@link https://github.com/jquery/jquery/blob/7fb90a6beaeffe16699800f73746748f6a5cc2de/src/core.js#L118-L188 | jQuery}. * * @example * * ``` * extend( [deep ], target, object1 [, objectN ] ) * ``` * * @param deep - Boolean. If true, the merge becomes recursive * (aka. deep copy). Passing false for this argument is not supported. * Optional. * @param target - Object. The object to extend. It will receive the * new properties. * @param object1 - Object. An object containing additional properties * to merge in. * @param objectN - Object. Additional objects containing properties * to merge in. * @returns A copy of the provided object. * * @public */ export declare function extend(...args: unknown[]): Record | Array; /** * Union type of both the simplified range and terms facets. * * @public */ export declare type Facet = RangeFacet | TermsFacet; /** * Set of params that are dumped from a {@link Query}. * @public */ export declare interface FacetQuery { /** That is the field name that you want to aggregate results. */ field?: string; /** The number of results to return in each field. Only applicable to facet terms. Maximum: 50 by default to help maintaining the speed of the search function */ size?: string; /** The facet type. Indicates the type of the facet, one of term or range.It will return an error if the facet type is not correct. */ term?: string; } /** * Specification to sort by a field. * @public */ export declare interface FieldSorting { /** A regular field and the sort direction. */ [field: string]: SortOrder; } declare enum filterExecution { AND = "and", OR = "or" } /** * Represents a filter by geographical distance. * * @example * * If the name of the field is `position`: * * ```ts * { * geo_distance: { * distance: '200km', * position: '40,-70' * } * } * ``` * * @public */ export declare interface GeoDistanceFilter { /** To set the origin use the name of the geographical field as key and the lattitude,longitude as value. */ [field: string]: string; /** The distance to the origin of the filter. */ distance: string; } /** * Interface to specify a sorting by geo distance. * @public */ export declare interface GeoSorting { /** * The geo distance sorting info. * @public */ _geo_distance: GeoSortOrder; } /** * Specification to sort by geo distance. * @public */ export declare interface GeoSortOrder { /** A geo point field, the value is a valid position. */ [field: string]: string; /** How to sort relative to the provided geo point (asc or desc) */ order: SortOrder; } /** * Parameters for image stats. * @public */ export declare interface ImageStatsParams extends StatsParams { /** Unique ID of the banner clicked. */ id: string | number; /** Optional search terms. */ query?: string; } /** * Basic parameters for init session requests. * @public */ export declare interface InitParams extends StatsParams { /** Unique ID of the user. */ user_id?: string; } /** * Check if the provided value is an empty object. * @param value - The value to check. * @returns `true` if the value is an empty object, `false` otherwise. * @public */ export declare function isEmptyObject(obj: unknown): boolean; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule shallowEqual * @typechecks * @flow */ /** * Check whether two values are identical or not. * * @privateRemarks * * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is * * @param x - First value to check. * @param y - Second value to check. * @returns A boolean value indicating if both values are identical. * @public */ export declare function isIdentical(x: any, y: any): boolean; /** * Check if the provided value is a number. * @param value - The value to check. * @returns `true` if the value is a number, `false` otherwise. * @public */ export declare function isNumber(value: unknown): boolean; /** * Check if the provided value is an object. * @param value - The value to check. * @returns `true` if the value is an object, `false` otherwise. * @public */ export declare function isObject(value: unknown): boolean; /** * Check if the provided value is a plain object. * @param value - The value to check. * @returns `true` if the value is a plain object, `false` otherwise. * @public */ export declare function isPlainObject(value: unknown): boolean; /** * Check whether two values are equivalent or not. * * @remarks * * Performs equality by iterating through keys on an object and returning false * when any key has values which are not strictly equal between the arguments. * Returns true when the values of all keys are strictly equal. * * @param objA - First value to check. * @param objB - Second value to check. * @returns A boolean value. * @public */ export declare function isShallowEqual(objA: any, objB: any): boolean; /** * Check if the provided value is a string. * @param value - The value to check. * @returns `true` if the value is a string, `false` otherwise. * @public */ export declare function isString(value: unknown): boolean; /** * Check if the provided value is a valid Doofinder Id. * @param value - The value to check. * @returns `true` if the value is a valid Doofinder Id, `false` otherwise. * @public */ export declare function isValidDoofinderId(value: unknown): boolean; /** * Check if the provided value is a valid Hash Id. * @param value - The value to check. * @returns `true` if the value is a valid Hash Id, `false` otherwise. * @public */ export declare function isValidHashId(value: unknown): boolean; /** * Merge multiple objects into one. * * @remarks * * Heavily based on https://www.npmjs.com/package/extend. * * While extend() fully extends objects, this version only touches own * properties and not inherited ones. This is intended to extend only option * objects, not functions used as constructors or anything like that. * * Why? Try to use PrototypeJS in the same page as Doofinder and use extend * instead to have some fun debugging. * * Works the same as extend, but merge is always "deep" * * __WARNING:__ Be careful with arrays of objects, you can end having duplicates. * * @param objects - An undetermined number of objects to merge. * @returns An object resulting of merging the provided objects. * @public */ export declare function merge(...objects: Record[]): Record; declare enum Method { POST = "POST", GET = "GET", PUT = "PUT", PATCH = "PATCH", DELETE = "DELETE" } /** * Represents a single search result when the `onlyid` transformer is * used. * * @public */ export declare type OnlyIdResult = Pick; /** * Process a search response to make it easier to manage. * * @param response - A RAW search response. * @returns The processed response. * * @internal */ export declare function _processSearchResponse(response: RawSearchResponse): SearchResponse; /** * Allows creating a search query programmatically instead of creating * the JSON and parameters by hand. * @public */ export declare class Query { private _defaults; private _params; private _indices; private _filters; private _excludes; private _sort; /** * Get / set the default parameters set when the query is reset. * @public */ get defaults(): QueryParams; set defaults(value: QueryParams); /** * Constructor. * * @param params - Initial parameters to load for this query. * @public */ constructor(params?: QueryParams); /** * Reset the current query to the defaults. * @public */ reset(): void; /** * Configure the query with the provided params. * @param params - Params to load. * @public */ load(params?: QueryParams): void; /** * Export the query as a params object. * * @param validate - Whether to validate the exported data or not. * @returns An object with all the parameters in the query. * * @public */ dump(validate?: boolean): SearchParams; /** * Create a copy of the current query. * @returns A new instance of Query. * @public */ copy(): Query; /** * Retrieve the value of a given parameter. * * @param name - Name of the parameter to retrieve * @returns the value of the parameter, if any * @public */ getParam(name: keyof QueryParams): unknown; /** * Set the value of a given parameter. * * @remarks * * If the value is `undefined` the parameter is removed. * * @param name - Name of the parameter to set. * @param value - The value of the parameter. * @public */ setParam(name: keyof QueryParams, value?: unknown): void; /** * Get / set the `hashid` parameter. * @param value - The hashid as string. * @public */ get hashid(): string; set hashid(value: string); /** * Get / set the `query` parameter. * @param value - The query as string. * @public */ get text(): string; set text(value: string); /** * Get / set the `page` parameter. * @param value - The page as a number. * @public */ get page(): number; set page(value: number); /** * Get / set the `rpp` parameter. * @param value - The rpp as a number. * @public */ get rpp(): number; set rpp(value: number); /** * Get / set the `query_name` parameter. * @param value - The query name as string. * @public */ get queryName(): string; set queryName(value: string); /** * Return the instance of the query indices manager for the current query. * @public */ get indices(): QueryIndices; /** * Return the instance of the query filters manager for the current query. * @public */ get filters(): QueryFilter; /** * Return the instance of the query excludes manager for the current query. * @public */ get excludes(): QueryFilter; /** * Return the instance of the sort manager for the current query. * @public */ get sort(): QuerySort; } /** * Manage filters applied to a query. * @public */ export declare class QueryFilter { private _filters; /** * Retrieve the value of a filter. * * @param name - Name of the filter. * @returns The value of the filter. * @public */ get(name: string): unknown; /** * Set the value of a filter. * * @remarks * * Setting the value of a filter will replace any existing value. * * @param name - Name of the field. * @param value - Value of the filter. * @public */ set(name: string, value: unknown): void; /** * Check whether there's a filter for the provided name or not. * * @param name - Name of the field. * @returns A boolean value. */ has(name: string): boolean; /** * Check whether there's a filter for the provided name and it contains * the provided value or not. * * @param name - Name of the field. * @param value - The value for the filter. * @returns A boolean value. */ contains(name: string, value: unknown): boolean; /** * Check whether there's a filter for the provided name and it's * equal to the provided value or not. * * @param name - Name of the field. * @param value - The value for the filter. * @returns A boolean value. */ equals(name: string, value: unknown): boolean; /** * Add a value to filter by a field. * * @remarks * * - If the filter does not exist, it is created. * - If the value is an object, the value for the filter is replaced. * - Otherwise is supposed to be a Set of terms / numbers. * * @param name - Name of the filter. * @param value - Value to add to the filter. * @public */ add(name: string, value: unknown): void; /** * Remove a filter by a field. * * @remarks * * - If the value is not provided, the filter is removed. * - If the value is an object, the filter is removed. * - Otherwise the value is removed from the list of terms. * * @param name - Name of the filter. * @param value - Optional. Value to remove from the filter. * @public */ remove(name: string, value?: unknown): void; /** * Clear all filters. * @public */ clear(): void; /** * Set multiple filters at once. * * @param data - An object with all the filters to be set. * @param replace - Boolean value telling whether to replace any * existing filter or not. * * @public */ setMany(data: Record, replace?: boolean): void; /** * Dump all filters as an object. * @returns An object with fields as keys and filter values as values. * @public */ dump(): Record; private _normalize; private _denormalize; private _filterContainsOrEqualsValue; } /** * Class to easily manage Indices filtering in a query. * * @public */ export declare class QueryIndices { private _indices; /** * Set the Indices to use to filter a query. * * @param value - A string or an array of strings representing Indices. * * @public */ set(value: string | string[]): void; /** * Dump the Indices set as an array of strings. * @returns An array of strings. * @public */ dump(): string[]; /** * Clear all values used to filter by Index. * @public */ clear(): void; /** * Add a value to the set of Indices used to filter. * * @param value - A Index as string. * @public */ add(value: string): void; /** * Check whether the set of Indices selected contain the provided value. * @param value - A index name. * @returns A boolean value. * @public */ has(value: string): boolean; /** * Remove a index from the set of Indices selected. * @param value - The index name to be removed. * @public */ remove(value: string): void; } /** * Set of params that can be passed when creating a {@link Query}. * @public */ export declare type QueryParams = Partial; /** * Base parameters for a query. * @public */ export declare interface QueryParamsBase { /** Unique id of the search engine. */ hashid: string; /** Search terms. */ query?: string; /** Results page to retrieve. */ page?: string | number; /** Number of results to retrieve for each page. */ rpp?: string | number; /** Name of the query to use to get the results. */ query_name?: string; /** Whether to count the request in the search stats or not. */ stats?: boolean; /** Your search engine is composed by one or many Indices. With the indices parameter you can specify to search within one specific Index. If this parameter is not provided, the search will work with all Indices. */ indices?: string[]; /** Aggregates fields values in a facet, you could use a term facet or range facet. */ facets?: FacetQuery[]; /** Filters to include results in the response. */ filter?: Record; /** Filters to exclude results from the response. */ exclude?: Record; /** Enable/Disable excluded items feature in the search. Default: true */ excluded_results?: boolean; /** Filters are applied with "and" boolean logic than means that all filters conditions should be met. If you want to apply any of the filters conditions, you can change it to "or". */ filter_execution?: filterExecution; /** Parameters to sort the results */ sort?: SortingInput[]; /** Other custom parameters */ [key: string]: unknown; } /** * Class to manage sorting information for a search query. * @public */ export declare class QuerySort { private _sortings; /** * Set one or more values to sort the query. * * @param value - Field name to sort the query. * @param order - Order of the sorting. * @returns the new length of the list of sortings. * * @public */ set(value: string, order?: SortOrder): number; /** * Set one or more values to sort the query. * * @param value - Object describing the sorting. * @returns the new length of the list of sortings. * * @public */ set(value: Sorting): number; /** * Set one or more values to sort the query. * * @param value - Array of objects describing the sorting. * @returns the new length of the list of sortings. * * @public */ set(value: SortingInput[]): number; /** * Add a sorting to the end of the list of sortings. * * @param value - A field name as string. * @param order - The order of the sorting. * @returns the new length of the list of sortings. * * @public */ add(value: string, order?: SortOrder): number; /** * Add a sorting to the end of the list of sortings. * * @param value - A valid input sorting value. * @returns the new length of the list of sortings. * * @public */ add(value: FieldSorting | GeoSorting): number; /** * Get the current list of sortings. * @returns An array of sort values. * @public */ get(): Sorting[]; /** * Clear the current list of sortings. * @public */ clear(): void; /** * Get if certain FieldSorting is being used to sort. * * @privateRemarks * * TODO: Add support for GeoSorting * * @public */ has(value: FieldSorting): boolean; private _isLikeSorting; private _addFieldSorting; private _addGeoDistanceSorting; } /** * Represents an error thrown for a wrong value in a Query. * @public */ export declare class QueryValueError extends Error { } /** * Simplified version of a range facet info. * * @public */ export declare interface RangeFacet { /** Indicates this facet is of type range. */ type: 'range'; label: string; visible: boolean; order?: number; /** Stats for this facet. */ range: RangeStats; } /** * Represents a filter by numeric range. * @public */ export declare interface RangeFilter { /** Optional. Results will have a value smaller or equal than the provided value. */ lte?: number; /** Optional. Results will have a value greater or equal than the provided value. */ gte?: number; /** Optional. Results will have a value smaller than the provided value. */ lt?: number; /** Optional. Results will have a value greater than the provided value. */ gt?: number; } /** * Represents the information returned in the search response for a range filter. * @public */ export declare interface RangeStats { /** Average value for the field for all the matching results. */ avg: number; /** Number of matching results. */ count: number; /** Max value for the field for all the matching results. */ max: number; /** Min value for the field for all the matching results. */ min: number; /** Sum of the values for the field for all the matching results. */ sum: number; } /** * Union type of both the RAW range and terms facets. * * @public */ export declare type RawFacet = RawRangeFacet | RawTermsFacet; /** * RAW information received for a range filter. * * @public */ export declare interface RawRangeFacet { /** Number of matching documents. */ doc_count: number; label: string; visible: boolean; /** Range information. */ range: { buckets: { doc_count: number; from: number; key: string; /** Stats for the facet. */ stats: RangeStats; }[]; }; } /** * Represents the search response with no processing. * * @public */ export declare interface RawSearchResponse extends Omit { facets: Record; } /** * RAW information received as a facet for a terms filter. * * @public */ export declare interface RawTermsFacet { /** Number of matching documents. */ doc_count: number; /** Information about the selected terms. */ selected: RawTermsInfo; /** The terms returned for the filter. */ terms: RawTermsInfo; /** Label for facet. */ label: string; visible: boolean; /** Number of matching documents. */ total: { value: number; }; /** * Indicates that the facet is created as a partition of a numeric * range. In the front will be managed as a terms facet but will be * interpreted as a range in the back. * @beta */ slots?: boolean; /** * How pertinent is the facet compared to the other facets in the * response. If only one facet could be displayed, it should be the * one with the highest order. * @beta */ order?: number; } /** * RAW information for a set of terms belonging to a terms facet. * * @public */ export declare interface RawTermsInfo { /** The list of terms stats. */ buckets: RawTermStats[]; /** An upper bound of the error on the document counts for each term. */ doc_count_error_upper_bound: number; /** sum of the document counts that are not part of the response. */ sum_other_doc_count: number; } /** * RAW information for a term belonging to a terms facet. * * @public */ export declare interface RawTermStats { /** Number of matching documents. */ doc_count: number; /** Value of the term. */ key: string; /** @beta */ from?: number; /** @beta */ to?: number; } /** * Parameters for redirection stats. * @public */ export declare interface RedirectionStatsParams extends StatsParams { /** Unique ID of the redirection in Doofinder. */ id: string | number; /** Optional search terms. */ query?: string; } /** * Set of params that are dumped from a {@link Query}. * @public */ export declare interface SearchImageParams extends QueryParamsBase { image: string; } /** * Set of params that are dumped from a {@link Query}. * @public */ export declare interface SearchParams extends QueryParamsBase { /** Enable/Disable auto filters feature in search. Default: false */ auto_filters?: boolean; /** Enable/Disable custom_results feature in search. Default: true */ custom_results?: boolean; /** Enable/Disable the grouping of variants as single items. If not given, it's taken from the configuration set in the admin. */ grouping?: boolean; /** A list of fields to be skipped from auto_filters feature. */ skip_auto_filters?: string[]; /** A list of fields to be skipped from top_facet feature. */ skip_top_facet?: string[]; /** Enable/Disable title_facet feature. Default: false */ title_facet?: boolean; /** Enable/Disable top_facet feature. Default: false */ top_facet?: boolean; } /** * Represents the basic search response from Doofinder. * * @public */ export declare interface SearchResponse extends Record { /** The search terms provided. */ query: string; /** The name of the internal query chosen by Doofinder to provide the results. */ query_name: string; /** The counter sent in the request to control the flow of responses. */ query_counter: number; /** The number of search results that can be retrieved. May be lower than the total number of results. */ total: number; /** The number of results found for the current search. */ total_found: number; /** The maximum score of the results for the current search. */ max_score: number; /** The page number for the current set of results. */ page: number; /** The number of results sent for each page. */ results_per_page: number; /** Array of results. */ results: Record[]; /** Autocomplete suggestion. Optional. */ autocomplete_suggest?: string; /** Banner information for these search results, if any. Optional. */ banner?: BannerInfo; /** Facets information for this set of results. */ facets?: Record; /** RAW facets information received from the search server with no further processing. */ _rawFacets?: Record; /** Filters applied to the search. */ filter?: { /** Range filters applied to the search. */ range: { [key: string]: RangeFilter; }; /** Terms filters applied to the search. */ terms: { [key: string]: string[]; }; /** Geo distance filters applied to the search. */ geo_distance: GeoDistanceFilter; /** Other unknown types of filters. */ [key: string]: Record; }; } /** * A field or geo distance sorting. * @public */ export declare type Sorting = FieldSorting | GeoSorting; /** * Valid input for a field or geo distance sorting. * @public */ export declare type SortingInput = string | Sorting; /** * Valid sort order values. * @public */ export declare type SortOrder = 'asc' | 'desc'; /** * Wrapper class to simplify stats calls. * @public */ export declare class StatsClient { private _client; constructor(client: Client); get client(): Client; /** * Registers a session ID in Doofinder. * * @param params - An options object. See {@link StatsParams}. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ registerSession(params: InitParams): Promise; /** * Register a click on a result. * * @param params - An options object. See {@link ClickStatsParamsWithDfid}. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ registerClick(params: ClickStatsParamsWithDfid): Promise; /** * Register a checkout within the session. * * @param params - An options object. See {@link StatsParams}. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ registerCheckout(params: CheckoutParams): Promise; /** * Register an image click during the current session. * * @param params - An options object. See {@link ImageStatsParams}. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ registerImageClick(params: ImageStatsParams): Promise; /** * Register a redirection occurred during the current session. * * @param params - An options object. See {@link RedirectionStatsParams}. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ registerRedirection(params: RedirectionStatsParams): Promise; /** * Adds an amount of item to the cart in the current session. * * @remarks * * The cart will be automatically * stored in stats if there's any call to registerCheckout. If the item is already in the * cart, the amount is automatically added to the current amount. * * @param params - An options object. See {@link CartItemStatsParams}. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @beta */ addToCart(params: CartItemStatsParams): Promise; /** * Pass-through to register any custom event. * * @param eventName - The event name to register. * @param params - The params object associated to the event call. * @param method - HTTP method for the request.Default GET. * It should have at least a session_id and a hashid. * @returns A promise to be fullfilled with the response or rejected * with a `ClientResponseError`. * * @public */ registerEvent(eventName: string, params: Record, method?: Method): Promise; } /** * Basic parameters for stats requests. * @public */ export declare interface StatsParams { /** Unique ID of the user session. */ session_id: string; /** Unique ID of the search engine. */ hashid: string; } /** * Simplified version of the terms facet info. * * @public */ export declare interface TermsFacet { type: 'terms'; label: string; visible: boolean; order?: number; terms: TermStats[]; } /** * Simplified stats for a term in a terms facet. * * @public */ export declare interface TermStats extends RawTermStats { /** If the term was selected or not when filtering. */ selected?: boolean; } export { }