import { Observable } from 'rxjs' ; import type { ISavedObjectTypeRegistry , IUiSettingsClient , SavedObjectsClientContract , Capabilities , IRouter , RequestHandlerContext , } from 'src/core/server' ; import { GlobalSearchBatchedResults , GlobalSearchProviderFindOptions , GlobalSearchProviderResult , GlobalSearchProviderFindParams , GlobalSearchFindParams , } from '../common/types' ; import { SearchServiceSetup , SearchServiceStart } from './services' ; export type GlobalSearchPluginSetup = Pick < SearchServiceSetup , 'registerResultProvider' > ; export type GlobalSearchPluginStart = Pick < SearchServiceStart , 'find' | 'getSearchableTypes' > ; internal export interface GlobalSearchRequestHandlerContext extends RequestHandlerContext { globalSearch : RouteHandlerGlobalSearchContext ; } internal export type GlobalSearchRouter = IRouter < GlobalSearchRequestHandlerContext > ; public export interface RouteHandlerGlobalSearchContext { /**
     * See  SearchServiceStart . find find ( params , options ) : Observable < GlobalSearchBatchedResults > ; /**
     * See  SearchServiceStart . getSearchableTypes getSearchableTypes : ( ) => Promise < string [ ] > ; } public export interface GlobalSearchProviderContext { core : { savedObjects : { client : SavedObjectsClientContract ; typeRegistry : ISavedObjectTypeRegistry ; } ; uiSettings : { client : IUiSettingsClient ; } ; capabilities : Observable < Capabilities > ; } ; } /**
 * Options for the server-side  GlobalSearchPluginStart . find public export interface GlobalSearchFindOptions { /**
     * A custom preference token associated with a search 'session' that should be used to get consistent scoring
     * when performing calls to ES. Can also be used as a 'session' token for providers returning data from elsewhere
     * than an elasticsearch cluster.
     * If not specified, a random token will be generated and used.
     */ preference ? : string ; /**
     * Optional observable to notify that the associated `find` call should be canceled.
     * If/when provided and emitting, no further result emission will be performed and the result observable will be completed.
     */ aborted$ ? : Observable < void > ; } /**
 * GlobalSearch result provider, to be registered using the  GlobalSearchPluginSetup public export interface GlobalSearchResultProvider { /**
     * id of the provider
     */ id : string ; example find ( search , options , context ) : Observable < GlobalSearchProviderResult [ ] > ; /**
     * Method that should return all the possible  GlobalSearchProviderResult . type of results that
     * this provider can return.
      getSearchableTypes : ( context : GlobalSearchProviderContext ) => string [ ] | Promise < string [ ] > ; }