// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from 'rxjs'; import { PartFromPartiumAPI } from '../../../data/models/part'; import { ServiceProvider } from '../../../core/services/service-provider'; import { EventContext } from '../../../core/models/log'; import { RecentTextSearchQueriesService } from './recent-text-search-queries.service'; import { SmartFilterFromAPI } from '../../models/smart-filter'; import { SearchInput } from '../../models/search-input'; import { SEARCH_OUTPUT_STATUS, SearchOutput } from '../../models/search-output'; import { BaseLoginInitService, Organization, PartiumConfig } from '../../../core'; import { ImageCropArea } from '../../models/image-crop-area'; export interface SearchEventContext extends EventContext { languageUi?: string; } export interface SearchApiResponse { sessionId: string; resultsTotalCount: number; results: PartFromPartiumAPI[]; smartFilters?: SmartFilterFromAPI[]; imageId?: string; status?: SEARCH_OUTPUT_STATUS; request: { language: string; imageOptions?: { areaOfInterest?: ImageCropArea; }; reusableImageId?: string; matches: { organization: string; text?: string; /** @deprecated */ exact?: string; hierarchy?: string[]; hierarchyPartiumIds?: string[]; filters?: FilterFromAPIResponse[]; similarTo?: { id?: string; partiumId?: string; }; duplicateOf?: { id?: string; partiumId?: string; }; hasRelatedParts?: boolean; }; }; } interface FilterFromAPIResponse { label: string; values: string[]; } type SearchResultOptions = Record; /** * This service is the central service for managing all search-related interaction. * It allows to perform searches or load search-results from a previous search. */ export interface SearchService { recentTextSearchQueries: RecentTextSearchQueriesService; /** * Perform a search with the given input synchronously (uses the new synchronous Search-API). * To continue a previous search, pass the according searchSessionId in the searchInput object * * @param searchInput the search-input * @param searchEventContext (optional) SearchEventContext object to add the missing data that will be logged using the log format V2 * @param projection (optional) Specify the data to be included in the response object. Check API-documentation for options. * @param resultOptions (optional) Specify result-options, such as amount of result-items to retrieve * @param skipDeviceInfoEventLog (optional) if true, no device-info-log will be sent * @returns object of type SearchOutput that contains all search-input + result-list, smart-filters, ... (depending on projection) */ performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: SearchResultOptions, skipDeviceInfoEventLog?: boolean): Observable; /** * Fetch all the details of an existing search-session. Use the projection-attribute to specify exactly which information should be retrieved. * Input and output of this function work analogue to performSearch. * * @param searchSessionId id of the search-session to retrieve * @param projection (optional) Specify the data to be included in the response object. Check API-documentation for options. * @param resultOptions (optional) Specify result-options, such as amount of result-items to retrieve * @returns object of type SearchOutput that contains all search-details, such as search-input + result-list, smart-filters, ... (depending on projection) */ getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: SearchResultOptions, organizationName?: string): Observable; } export declare class SearchServiceImpl extends BaseLoginInitService implements SearchService { private httpsService; private logService; private deviceStatusService; private organizationService; constructor(serviceProvider: ServiceProvider); onCreate(): void; /** * Initializes the SearchService */ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable): Observable; get recentTextSearchQueries(): RecentTextSearchQueriesService; performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: SearchResultOptions, skipDeviceInfoEventLog?: boolean): Observable; getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: SearchResultOptions, organizationName?: string): Observable; private logDeviceInfo; private getOrganizationId; private prepareFilters; private processSearchApiResponse; private removeDuplicatesFromArray; /** * Add text-searches to recent text-searches if set * @param searchInput the new search-input */ private updateRecentTextSearch; } export {};