import { Params } from '@angular/router'; import { Observable } from 'rxjs'; import { FacetCount, Filter, OptionalSearchQuery, SearchField, SearchQuery, SearchResult, SearchTarget, SortField } from '@mtna/search-manager-ui'; export interface MtnaSearchFacade { /** Whether there are any more results that can be loaded. */ canLoadMore$: Observable; /** Search fields marked for display. */ displayFields$: Observable; /** All the facet counts from the most recent search result. Keyed on the `FacetCount`'s `field` property. */ facetCounts$: Observable<{ [key: string]: FacetCount; }>; /** * A filtered down list of the current * `SearchTarget`'s `searchFields` that * have a `facetType` of `'FIELD'`. * Sorted by the `SearchField`'s `facetOrder` property. */ filterableFields$: Observable; /** The currently applied filters from the latest search result. */ filters$: Observable; /** The last successfully executed search query. */ lastQuery$: Observable; /** The router `Params` from the last search or null. */ lastQueryParams$: Observable; /** Whether SearchTargets are loading */ loading$: Observable; /** Whether SearchTargets are loading or a search is in progress */ loadingOrSearching$: Observable; /** The current, zero based, page index of the search results. Derrived by `query.start/query.limit`. */ pageIndex$: Observable; /** The current result's page size, i.e. the `limit`. */ pageSize$: Observable; /** All of the current SortFields */ querySortFields$: Observable; /** The search result. */ results$: Observable; /** The total number of search results found, not limited to what is in the current page. i.e. `result.found`. */ resultsFound$: Observable; /** The total number of search results showing/loaded. i.e. Math.min(pageSize, resultsFound) */ resultsShowing$: Observable; /** Whether a search is in progress. */ searching$: Observable; /** The search text from the last run query. Wild card has been stripped out. */ searchText$: Observable; /** All the search fields that can be sorted by. */ sortableFields$: Observable; /** The current, active `SearchTarget`. */ target$: Observable; /** All the `SearchTarget`s available from the current search controller. */ targets$: Observable; /** Removes the search result from the state. */ clearResults(): void; /** * Change the current fitlers * * @param filter the filter that changed. */ filter(filter: Filter): void; /** * Load more results. * * @param more The number of more results to load. Will default to the injection token config and the finally 25. */ loadMore(more?: number): void; /** * Load a specific `SearchTarget` onto the state. * Optionally by ID, this is determined by the capabilities of the API's SearchController. * * @param targetId the optional id of the specific search target. */ loadTarget(targetId?: string): void; /** Load all the search target that the API supports. */ loadTargets(): void; /** * Changes the paginator page. * @param start index of the item for the start of the page * @param limit number of items */ paginate(start: number, limit: number): void; /** * Reset the shared state to initial values. * Intended to be used when switching between features that * both use the shared search state. * * @param pageSize optional default page size (limit) to initialize the state with. * @param target optional search target ID to initialize the state with. */ reset(pageSize?: number, target?: string): void; /** Reset all filters. */ resetFilters(): void; /** * Execute a search. * * @param query the search query to execute. * @param targetId optionally specify what search target to use. * @param useDefaults whether to use the default sorting and filters specified by the {@link SearchTarget}. * @param concatResults whether to concatenate the results on the state's existing results. This is typical for a load more. * This will override any values passed in the {@link query}. Defaults to false. */ search(query: OptionalSearchQuery, targetId?: string, useDefaults?: boolean, concatResults?: boolean): void; /** * @param text the text to search */ searchText(text?: string): void; /** * @param target the {@link SearchTarget} to set on the state to use for future searches */ setTarget(target: SearchTarget): void; /** * @param order The order to sort the codes * @param field The sort field to sort on */ sort(order: 'ASC' | 'DESC' | null, field: string): void; }