import { History } from 'history' ; import { Capabilities , ChromeStart , CoreStart , DocLinksStart , ToastsStart , IUiSettingsClient , PluginInitializerContext , } from 'opensearch-dashboards/public' ; import { FilterManager , TimefilterContract , IndexPatternsContract , DataPublicPluginStart , } from 'src/plugins/data/public' ; import { Start as InspectorPublicPluginStart } from 'src/plugins/inspector/public' ; import { SharePluginStart } from 'src/plugins/share/public' ; import { ChartsPluginStart } from 'src/plugins/charts/public' ; import { VisualizationsStart } from 'src/plugins/visualizations/public' ; import { SavedObjectOpenSearchDashboardsServices } from 'src/plugins/saved_objects/public' ; import { DiscoverStartPlugins } from './plugin' ; import { createSavedSearchesLoader , SavedSearch } from './saved_searches' ; import { getHistory } from './opensearch_dashboards_services' ; import { OpenSearchDashboardsLegacyStart } from '../../opensearch_dashboards_legacy/public' ; import { UrlForwardingStart } from '../../url_forwarding/public' ; import { NavigationPublicPluginStart } from '../../navigation/public' ; export interface DiscoverServices { addBasePath : ( path : string ) => string ; capabilities : Capabilities ; chrome : ChromeStart ; core : CoreStart ; data : DataPublicPluginStart ; docLinks : DocLinksStart ; history : ( ) => History ; theme : ChartsPluginStart [ 'theme' ] ; filterManager : FilterManager ; indexPatterns : IndexPatternsContract ; inspector : InspectorPublicPluginStart ; metadata : { branch : string ; } ; navigation : NavigationPublicPluginStart ; share ? : SharePluginStart ; opensearchDashboardsLegacy : OpenSearchDashboardsLegacyStart ; urlForwarding : UrlForwardingStart ; timefilter : TimefilterContract ; toastNotifications : ToastsStart ; getSavedSearchById : ( id : string ) => Promise < SavedSearch > ; getSavedSearchUrlById : ( id : string ) => Promise < string > ; getEmbeddableInjector : any ; uiSettings : IUiSettingsClient ; visualizations : VisualizationsStart ; } export async function buildServices ( core , plugins , context , getEmbeddableInjector ) { const services = { savedObjectsClient : core . savedObjects . client , indexPatterns : plugins . data . indexPatterns , search : plugins . data . search , chrome : core . chrome , overlays : core . overlays , } ; const savedObjectService = createSavedSearchesLoader ( services ) ; return { addBasePath : core . http . basePath . prepend , capabilities : core . application . capabilities , chrome : core . chrome , core , data : plugins . data , docLinks : core . docLinks , theme : plugins . charts . theme , filterManager : plugins . data . query . filterManager , getEmbeddableInjector , getSavedSearchById : async ( id ) => savedObjectService . get ( id ) , getSavedSearchUrlById : async ( id ) => savedObjectService . urlFor ( id ) , history : getHistory , indexPatterns : plugins . data . indexPatterns , inspector : plugins . inspector , metadata : { branch : context . env . packageInfo . branch , } , navigation : plugins . navigation , share : plugins . share , opensearchDashboardsLegacy : plugins . opensearchDashboardsLegacy , urlForwarding : plugins . urlForwarding , timefilter : plugins . data . query . timefilter . timefilter , toastNotifications : core . notifications . toasts , uiSettings : core . uiSettings , visualizations : plugins . visualizations , } ; }