import { map , reduce } from 'rxjs/operators' ; import { Plugin , CoreSetup , CoreStart , AppMountParameters } from 'kibana/public' ; import { GlobalSearchPluginSetup , GlobalSearchPluginStart , GlobalSearchResult , } from '../../../../../plugins/global_search/public' ; export interface GlobalSearchTestPluginSetup { } export interface GlobalSearchTestPluginStart { find : ( term : string ) => Promise < GlobalSearchResult [ ] > ; } export interface GlobalSearchTestPluginSetupDeps { globalSearch : GlobalSearchPluginSetup ; } export interface GlobalSearchTestPluginStartDeps { globalSearch : GlobalSearchPluginStart ; } export class GlobalSearchTestPlugin implements Plugin < GlobalSearchTestPluginSetup , GlobalSearchTestPluginStart , GlobalSearchTestPluginSetupDeps , GlobalSearchTestPluginStartDeps > { public setup ( { application , getStartServices } , { globalSearch } ) { application . register ( { id : 'globalSearchTestApp' , title : 'GlobalSearch test' , mount : ( params ) => { return ( ) => undefined ; } , } ) ; return { } ; } public start ( { } , { globalSearch } ) { return { find : ( term ) => globalSearch . find ( { term } , { } ) . pipe ( map ( ( batch ) => batch . results ) , reduce ( ( memo , results ) => [ ... memo , ... results ] ) ) . toPromise ( ) , } ; } }