import { PluginInitializerContext , CoreSetup , CoreStart , Plugin , Logger } from 'src/core/server' ; import { ExpressionsServerSetup } from 'src/plugins/expressions/server' ; import { ConfigSchema } from '../config' ; import { IndexPatternsService , IndexPatternsServiceStart } from './index_patterns' ; import { ISearchSetup , ISearchStart , SearchEnhancements } from './search' ; import { SearchService } from './search/search_service' ; import { QueryService } from './query/query_service' ; import { ScriptsService } from './scripts' ; import { DqlTelemetryService } from './dql_telemetry' ; import { UsageCollectionSetup } from '../../usage_collection/server' ; import { AutocompleteService } from './autocomplete' ; import { FieldFormatsService , FieldFormatsSetup , FieldFormatsStart } from './field_formats' ; import { getUiSettings } from './ui_settings' ; export interface DataEnhancements { search : SearchEnhancements ; } export interface DataPluginSetup { search : ISearchSetup ; fieldFormats : FieldFormatsSetup ; internal __enhance : ( enhancements : DataEnhancements ) => void ; } export interface DataPluginStart { search : ISearchStart ; fieldFormats : FieldFormatsStart ; indexPatterns : IndexPatternsServiceStart ; } export interface DataPluginSetupDependencies { expressions : ExpressionsServerSetup ; usageCollection ? : UsageCollectionSetup ; } export interface DataPluginStartDependencies { } export class DataServerPlugin implements Plugin < DataPluginSetup , DataPluginStart , DataPluginSetupDependencies , DataPluginStartDependencies > { private readonly searchService : SearchService ; private readonly scriptsService : ScriptsService ; private readonly dqlTelemetryService : DqlTelemetryService ; private readonly autocompleteService : AutocompleteService ; private readonly indexPatterns = new IndexPatternsService ( ) ; private readonly fieldFormats = new FieldFormatsService ( ) ; private readonly queryService = new QueryService ( ) ; private readonly logger : Logger ; constructor ( initializerContext ) { this . logger = initializerContext . logger . get ( 'data' ) ; this . searchService = new SearchService ( initializerContext , this . logger ) ; this . scriptsService = new ScriptsService ( ) ; this . dqlTelemetryService = new DqlTelemetryService ( initializerContext ) ; this . autocompleteService = new AutocompleteService ( initializerContext ) ; } public setup ( core , { expressions , usageCollection } ) { this . indexPatterns . setup ( core ) ; this . scriptsService . setup ( core ) ; this . queryService . setup ( core ) ; this . autocompleteService . setup ( core ) ; this . dqlTelemetryService . setup ( core , { usageCollection } ) ; core . uiSettings . register ( getUiSettings ( ) ) ; const searchSetup = this . searchService . setup ( core , { registerFunction : expressions . registerFunction , usageCollection , } ) ; return { __enhance : ( enhancements ) => { searchSetup . __enhance ( enhancements . search ) ; } , search : searchSetup , fieldFormats : this . fieldFormats . setup ( ) , } ; } public start ( core ) { const fieldFormats = this . fieldFormats . start ( ) ; const indexPatterns = this . indexPatterns . start ( core , { fieldFormats , logger : this . logger . get ( 'indexPatterns' ) , } ) ; return { fieldFormats , indexPatterns , search : this . searchService . start ( core , { fieldFormats , indexPatterns } ) , } ; } public stop ( ) { this . searchService . stop ( ) ; } } export { DataServerPlugin as Plugin } ;