import './index.scss' ; import { PluginInitializerContext , CoreSetup , CoreStart , Plugin , ApplicationStart , SavedObjectsClientContract , } from '../../../core/public' ; import { TypesService , TypesSetup , TypesStart } from './vis_types' ; import { setUISettings , setTypes , setI18n , setApplication , setCapabilities , setHttp , setIndexPatterns , setSearch , setSavedObjects , setUsageCollector , setFilterManager , setExpressions , setUiActions , setSavedVisualizationsLoader , setTimeFilter , setAggs , setChrome , setOverlays , setSavedSearchLoader , setEmbeddable , } from './services' ; import { VISUALIZE_EMBEDDABLE_TYPE , VisualizeEmbeddableFactory , createVisEmbeddableFromObject , } from './embeddable' ; import { ExpressionsSetup , ExpressionsStart } from '../../expressions/public' ; import { EmbeddableSetup , EmbeddableStart } from '../../embeddable/public' ; import { visualization as visualizationFunction } from './expressions/visualization_function' ; import { visualization as visualizationRenderer } from './expressions/visualization_renderer' ; import { range as rangeExpressionFunction } from './expression_functions/range' ; import { visDimension as visDimensionExpressionFunction } from './expression_functions/vis_dimension' ; import { DataPublicPluginSetup , DataPublicPluginStart } from '../../data/public' ; import { Setup as InspectorSetup , Start as InspectorStart , } from '../../../plugins/inspector/public' ; import { UsageCollectionSetup } from '../../usage_collection/public' ; import { createStartServicesGetter , StartServicesGetter , } from '../../opensearch_dashboards_utils/public' ; import { createSavedVisLoader , SavedVisualizationsLoader } from './saved_visualizations' ; import { SerializedVis , Vis } from './vis' ; import { showNewVisModal } from './wizard' ; import { UiActionsStart } from '../../ui_actions/public' ; import { convertFromSerializedVis , convertToSerializedVis , } from './saved_visualizations/_saved_vis' ; import { createSavedSearchesLoader } from '../../discover/public' ; import { DashboardStart } from '../../dashboard/public' ; public export type VisualizationsSetup = TypesSetup ; export interface VisualizationsStart extends TypesStart { savedVisualizationsLoader : SavedVisualizationsLoader ; createVis : ( visType : string , visState : SerializedVis ) => Promise < Vis > ; convertToSerializedVis : typeof convertToSerializedVis ; convertFromSerializedVis : typeof convertFromSerializedVis ; showNewVisModal : typeof showNewVisModal ; __LEGACY : { createVisEmbeddableFromObject : ReturnType < typeof createVisEmbeddableFromObject > ; } ; } export interface VisualizationsSetupDeps { data : DataPublicPluginSetup ; embeddable : EmbeddableSetup ; expressions : ExpressionsSetup ; inspector : InspectorSetup ; usageCollection : UsageCollectionSetup ; } export interface VisualizationsStartDeps { data : DataPublicPluginStart ; expressions : ExpressionsStart ; embeddable : EmbeddableStart ; inspector : InspectorStart ; uiActions : UiActionsStart ; application : ApplicationStart ; dashboard : DashboardStart ; getAttributeService : DashboardStart [ 'getAttributeService' ] ; savedObjectsClient : SavedObjectsClientContract ; } internal export class VisualizationsPlugin implements Plugin < VisualizationsSetup , VisualizationsStart , VisualizationsSetupDeps , VisualizationsStartDeps > { private readonly types : TypesService = new TypesService ( ) ; private getStartServicesOrDie ? : StartServicesGetter < VisualizationsStartDeps , VisualizationsStart > ; constructor ( initializerContext ) { } public setup ( core , { expressions , embeddable , usageCollection , data } ) { const start = ( this . getStartServicesOrDie = createStartServicesGetter ( core . getStartServices ) ) ; setUISettings ( core . uiSettings ) ; setUsageCollector ( usageCollection ) ; expressions . registerFunction ( visualizationFunction ) ; expressions . registerRenderer ( visualizationRenderer ) ; expressions . registerFunction ( rangeExpressionFunction ) ; expressions . registerFunction ( visDimensionExpressionFunction ) ; const embeddableFactory = new VisualizeEmbeddableFactory ( { start } ) ; embeddable . registerEmbeddableFactory ( VISUALIZE_EMBEDDABLE_TYPE , embeddableFactory ) ; return { ... this . types . setup ( ) , } ; } public start ( core , { data , expressions , uiActions , embeddable , dashboard } ) { const types = this . types . start ( ) ; setI18n ( core . i18n ) ; setTypes ( types ) ; setEmbeddable ( embeddable ) ; setApplication ( core . application ) ; setCapabilities ( core . application . capabilities ) ; setHttp ( core . http ) ; setSavedObjects ( core . savedObjects ) ; setIndexPatterns ( data . indexPatterns ) ; setSearch ( data . search ) ; setFilterManager ( data . query . filterManager ) ; setExpressions ( expressions ) ; setUiActions ( uiActions ) ; setTimeFilter ( data . query . timefilter . timefilter ) ; setAggs ( data . search . aggs ) ; setOverlays ( core . overlays ) ; setChrome ( core . chrome ) ; const savedVisualizationsLoader = createSavedVisLoader ( { savedObjectsClient : core . savedObjects . client , indexPatterns : data . indexPatterns , search : data . search , chrome : core . chrome , overlays : core . overlays , visualizationTypes : types , } ) ; setSavedVisualizationsLoader ( savedVisualizationsLoader ) ; const savedSearchLoader = createSavedSearchesLoader ( { savedObjectsClient : core . savedObjects . client , indexPatterns : data . indexPatterns , search : data . search , chrome : core . chrome , overlays : core . overlays , } ) ; setSavedSearchLoader ( savedSearchLoader ) ; return { ... types , showNewVisModal , param { IIndexPattern } indexPattern param { VisState } visState createVis : async ( visType , visState ) => { const vis = new Vis ( visType ) ; await vis . setState ( visState ) ; return vis ; } , convertToSerializedVis , convertFromSerializedVis , savedVisualizationsLoader , __LEGACY : { createVisEmbeddableFromObject : createVisEmbeddableFromObject ( { start : this . getStartServicesOrDie ! , } ) , } , } ; } public stop ( ) { this . types . stop ( ) ; } }