import { CoreSetup , CoreStart , Plugin , PluginInitializerContext } from 'src/core/public' ; import { LicensingPluginStart } from '../../licensing/public' ; import { LicenseChecker , ILicenseChecker } from '../common/license_checker' ; import { GlobalSearchPluginSetup , GlobalSearchPluginStart } from './types' ; import { GlobalSearchClientConfigType } from './config' ; import { SearchService } from './services' ; export interface GlobalSearchPluginSetupDeps { } export interface GlobalSearchPluginStartDeps { licensing : LicensingPluginStart ; } export class GlobalSearchPlugin implements Plugin < GlobalSearchPluginSetup , GlobalSearchPluginStart , GlobalSearchPluginSetupDeps , GlobalSearchPluginStartDeps > { private readonly config : GlobalSearchClientConfigType ; private licenseChecker ? : ILicenseChecker ; private readonly searchService = new SearchService ( ) ; constructor ( context ) { this . config = context . config . get < GlobalSearchClientConfigType > ( ) ; } setup ( core ) { const { registerResultProvider } = this . searchService . setup ( { config : this . config , } ) ; return { registerResultProvider , } ; } start ( { http } , { licensing } ) { this . licenseChecker = new LicenseChecker ( licensing . license$ ) ; const { find , getSearchableTypes } = this . searchService . start ( { http , licenseChecker : this . licenseChecker , } ) ; return { find , getSearchableTypes , } ; } public stop ( ) { if ( this . licenseChecker ) { this . licenseChecker . clean ( ) ; } } }