import { SearchRequest , SearchResponse } from '@empathyco/x-adapter' ; import { Banner , Facet , Filter , PartialResult , Promoted , Redirection , RelatedTag , Result , Sort , TaggingInfo } from '@empathyco/x-types' ; import { XActionContext , XStoreModule } from '../../../store' ; import { StatusMutations , StatusState } from '../../../store/utils/status-store.utils' ; import { QueryOrigin , QueryOriginInit } from '../../../types/origin' ; import { UrlParams } from '../../../types/url-params' ; import { Dictionary } from '../../../utils/types' ; import { SearchConfig } from '../config.types' ; import { InternalSearchRequest , WatchedInternalSearchRequest } from '../types' ; public export interface SearchState extends StatusState { /** The list of the banners, related to the `query` property of the state. */ banners : Banner [ ] ; /** The configuration of the search module. */ config : SearchConfig ; /** The list of the facets, related to the `query` property of the state. */ facets : Facet [ ] ; /** A flag to indicate if new results are append to the current instead of replacing them. */ isAppendResults : boolean ; /** The origin property of the request. */ origin : QueryOrigin | null ; /** The current page of the request. */ page : number ; /** The extra params property of the state. */ params : Dictionary < unknown > ; /** The list of the partial results, related to the `query` property of the state. */ partialResults : PartialResult [ ] ; /** The list of the promoted, related to the `query` property of the state. */ promoteds : Promoted [ ] ; /** The internal query of the module. Used to request the search results. */ query : string ; /** The query tagging used to track the search events. */ queryTagging : TaggingInfo ; /** The redirections associated to the `query`. */ redirections : Redirection [ ] ; /** The list of the related tags, related to the `query` property of the state. */ relatedTags : RelatedTag [ ] ; /** The list of the results, related to the `query` property of the state. */ results : Result [ ] ; /** The dictionary of selected filters, used to perform the search request.
     * The key is the facet id, and the value the list of filters for that facet. */ selectedFilters : Dictionary < Filter [ ] > ; /** The way of ordering the results. */ sort : Sort ; /** The spellcheckedQuery property of the state. */ spellcheckedQuery : string ; /** The total number of results, related to the `query` property of the state. */ totalResults : number ; } public export interface SearchGetters { /** The adapter request object for retrieving the results, or null if there is not
     * valid data to create a request. */ request : InternalSearchRequest | null ; } public export interface SearchMutations extends StatusMutations { param results appendResults ( results ) : void ; param banners setBanners ( banners ) : void ; param facets setFacets ( facets ) : void ; param isAppendResults setIsAppendResults ( isAppendResults ) : void ; param origin setOrigin ( origin ) : void ; param page setPage ( page ) : void ; param pageSize setPageSize ( pageSize ) : void ; param params setParams ( params ) : void ; param partialResults setPartialResults ( partialResults ) : void ; param promoteds setPromoteds ( promoteds ) : void ; param newQuery setQuery ( newQuery ) : void ; param queryTagging setQueryTagging ( queryTagging ) : void ; param redirections setRedirections ( redirections ) : void ; param relatedTags setRelatedTags ( relatedTags ) : void ; param results setResults ( results ) : void ; param selectedFilters setSelectedFilters ( selectedFilters ) : void ; param sort setSort ( sort ) : void ; param spellcheckedQuery setSpellcheck ( spellcheckedQuery ) : void ; param totalResults setTotalResults ( totalResults ) : void ; } public export interface SearchActions { /**
     * Batches state resets in a single action after  SearchGetters . request parameters update.
     *
     *  param watchedRequest resetState ( watchedRequest ) : void ; /**
     * Cancels / interrupt  SearchActions . fetchAndSaveSearchResponse synchronous promise.
      cancelFetchAndSaveSearchResponse ( ) : void ; /**
     * Fetches a new search response and stores them in the module state.
     */ fetchAndSaveSearchResponse ( request ) : void ; returns fetchSearchResponse ( request ) : SearchResponse ; /**
     * Checks if there are more pages of results to load. If there are, then increases the page
     * number in state and set to `true` the  SearchState . isAppendResults flag.
     *
     *  remarks This action is to implement the infinite scroll behaviour. To increase the page
     * for other purposes, please use the  SearchMutations . setPage mutation.
      increasePageAppendingResults ( ) : void ; param urlParams setUrlParams ( urlParams ) : void ; /**
     * Creates a  QueryOrigin and saves it.
     *
     *  param originInit saveOrigin ( originInit ) : void ; } public export type SearchXStoreModule = XStoreModule < SearchState , SearchGetters , SearchMutations , SearchActions > ; /**
 * Alias type for actions context of the  SearchXStoreModule .
 *
 *  public export type SearchActionContext = XActionContext < SearchState , SearchGetters , SearchMutations , SearchActions > ;