import { UserAgent } from '../UserAgent'; import { MultipleQueriesQuery, SearchClient, SearchForFacetValuesResponse, SearchResponse } from './algoliasearch'; export interface SearchParams { /** * The initialized Algolia search client. */ searchClient: SearchClient; /** * A list of queries to execute. */ queries: MultipleQueriesQuery[]; /** * A list of user agents to add to the search client. * * This is useful to track usage of an integration. */ userAgents?: UserAgent[]; } export declare type Fetcher = ({ searchClient, queries, userAgents, }: SearchParams) => Promise>>; declare type FacetHit = { label: string; count: number; _highlightResult: { label: { value: string; }; }; }; export declare type FetcherParams = Pick[0], 'searchClient' | 'queries'>; export declare type RequesterParams = { transformResponse(response: TransformResponseParams): TransformedRequesterResponse; }; declare type TransformResponseParams = { results: Array | SearchForFacetValuesResponse>; hits: Array['hits']>; facetHits: FacetHit[][]; }; export declare type TransformedRequesterResponse = Array['hits']> | SearchResponse['hits'] | FacetHit[][] | FacetHit[]; export declare type TransformResponse = (response: TransformResponseParams) => TransformedRequesterResponse; declare type FetcherParamsQuery = { query: MultipleQueriesQuery; sourceId: string; transformResponse: TransformResponse; }; export declare type ExecuteParams = { searchClient: SearchClient; requests: Array>; }; export declare type Execute = (params: ExecuteParams) => Promise>; export declare type ExecuteResponse = Array<{ items: SearchResponse | SearchForFacetValuesResponse; sourceId: string; transformResponse: TransformResponse; }>; export declare type RequestParams = FetcherParams & { /** * The function to transform the Algolia response before passing it to the Autocomplete state. You have access to the full Algolia results, as well as the pre-computed hits and facet hits. * * This is useful to manipulate the hits, or store data from the results in the [context](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/context/). */ transformResponse?: TransformResponse; }; export declare type RequesterDescription = { /** * The search client used for this request. Multiple queries with the same client are batched (if `requesterId` is also the same). */ searchClient: SearchClient; /** * Identifies requesters to confirm their queries should be batched. * This ensures that requesters with the same client but different * post-processing functions don't get batched. * When falsy, batching is disabled. * For example, the Algolia requesters use "algolia". */ requesterId?: string; /** * The search parameters used for this query. */ queries: MultipleQueriesQuery[]; /** * Transforms the response of this search before returning it to the caller. */ transformResponse: TransformResponse; /** * Post-processing function for multi-queries. */ execute: Execute; }; export {};