import * as _spinque_query_api from '@spinque/query-api'; import { FacetedSearch, Query, FacetType } from '@spinque/query-api'; import { Observable } from 'rxjs'; import * as _angular_core from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; /** * This file used to contain helper functions to encode and decode sets of Query objects. * Used when Query's must be stored in the URL of a page. * * They've now moves to @spinque/query-api but these exports remain to keep existing apps * from breaking. */ /** * Expects a string generated by stringifyQueries and returns an array of Query's * * @deprecated please use parseQueries from @spinque/query-api */ declare const parseQueries: (stringified: string) => _spinque_query_api.Query[]; /** * Expects an array of Query's and turns them into a string * * @deprecated please use stringifyQueries from @spinque/query-api */ declare const stringifyQueries: (queries: _spinque_query_api.Query[]) => string; /** * Extends the FacetedSearch class from @spinque/query-api. * Exposes an observable 'state' property that will emit whenever the state changes. */ declare class ObservableFacetedSearch extends FacetedSearch { private options; /** * Observable that emits whenever the state of the FacetedSearch changes */ state: Observable<{ /** * Query stack to fetch search results (main search endpoint + applied facets) */ results: Query[]; /** * Query stack to get facet options for each facet. */ facets: { [facetOptionsEndpoint: string]: Query[]; }; /** * Selected options for each facet. Note that FacetType.single facets will also have * their values wrapped in an array. */ facetsSelection: { [facetOptionsEndpoint: string]: string[]; }; }>; private _change$; constructor(options: { /** * The main search query */ searchQuery: Query; /** * Query to use when the search query parameter is empty */ emptyParameterQuery?: Query; /** * List of facets to add */ facets?: { /** * Endpoint of the facet */ endpoint: string; /** * The selection type (single, multiple) of the facet */ type?: FacetType; /** * Whether the facet should reset when the search query changes. */ resetOnQueryChange?: boolean; /** * The postfix to add to `endpoint` to get the filter endpoint. * Defaults to `:FILTER`, as is common practice. */ filterEndpointPostfix?: string; /** * Parameter to use for filtering. Defaults to `value`. */ filterEndpointParameterName?: string; }[]; /** * Modifier queries can change the results but do not have options. * An example is a query to sort results of a previous query. */ modifiers?: Query[]; }); /** * Add a facet to the ObservableFacetedSearch object. */ addFacet(endpoint: string, type?: FacetType, resetOnQueryChange?: boolean, filterEndpointPostfix?: string, filterEndpointParameterName?: string): void; setModifier(modifier: Query | undefined): void; /** * Set a parameter value for the searchQuery */ setParameter(name: string, value: string): void; setSearchQuery(query: Query): void; /** * Clear all searchQuery parameters */ clearParameters(): void; /** * Set the selected options for a given facet. */ setFacetSelection(facetEndpoint: string, selection: string | string[]): void; /** * Clear the selection for a given facet. */ clearFacetSelection(facetEndpoint?: string): void; /** * Set the entire state at once. To be used when getting state from a store, such as the URL query parameters. */ setState(results: Query[], allowChangingSearchQuery?: boolean): void; } /** * Extends the FacetedSearch class from @spinque/query-api. * Exposes a signal 'state' property that holds the latest state. */ declare class SignalFacetedSearch extends FacetedSearch { private options; /** * Signal holding the state of the FacetedSearch */ state: _angular_core.WritableSignal<{ /** * Query stack to fetch search results (main search endpoint + applied facets) */ results: Query[]; /** * Query stack to get facet options for each facet. */ facets: { [facetOptionsEndpoint: string]: Query[]; }; /** * Selected options for each facet. Note that FacetType.single facets will also have * their values wrapped in an array. */ facetsSelection: { [facetOptionsEndpoint: string]: string[]; }; }>; constructor(options: { /** * The main search query */ searchQuery: Query; /** * Query to use when the search query parameter is empty */ emptyParameterQuery?: Query; /** * List of facets to add */ facets?: { /** * Endpoint of the facet */ endpoint: string; /** * The selection type (single, multiple) of the facet */ type?: FacetType; /** * Whether the facet should reset when the search query changes. */ resetOnQueryChange?: boolean; /** * The postfix to add to `endpoint` to get the filter endpoint. * Defaults to `:FILTER`, as is common practice. */ filterEndpointPostfix?: string; /** * Parameter to use for filtering. Defaults to `value`. */ filterEndpointParameterName?: string; }[]; /** * Modifier queries can change the results but do not have options. * An example is a query to sort results of a previous query. */ modifiers?: Query[]; }); setNewState(): void; /** * Add a facet to the ObservableFacetedSearch object. */ addFacet(endpoint: string, type?: FacetType, resetOnQueryChange?: boolean, filterEndpointPostfix?: string, filterEndpointParameterName?: string): void; setModifier(modifier: Query | undefined): void; /** * Set a parameter value for the searchQuery */ setParameter(name: string, value: string): void; setSearchQuery(query: Query): void; /** * Clear all searchQuery parameters */ clearParameters(): void; /** * Set the selected options for a given facet. */ setFacetSelection(facetEndpoint: string, selection: string | string[] | undefined): void; /** * Clear the selection for a given facet. */ clearFacetSelection(facetEndpoint?: string): void; /** * Set the entire state at once. To be used when getting state from a store, such as the URL query parameters. */ setState(results: Query[], allowChangingSearchQuery?: boolean): void; } declare const syncWithRouter: (fs: ObservableFacetedSearch | SignalFacetedSearch, router: Router, route: ActivatedRoute) => void; export { ObservableFacetedSearch, SignalFacetedSearch, parseQueries, stringifyQueries, syncWithRouter };