import { AppMountParameters , CoreSetup , Plugin , PluginInitializerContext , CoreStart , DEFAULT_APP_CATEGORIES , } from '../../../../src/core/public' ; import { Storage } from '../../../../src/plugins/kibana_utils/public' ; import { OsqueryPluginSetup , OsqueryPluginStart , StartPlugins , AppPluginStartDependencies , } from './types' ; import { OSQUERY_INTEGRATION_NAME , PLUGIN_NAME } from '../common' ; import { LazyOsqueryManagedPolicyCreateImportExtension , LazyOsqueryManagedPolicyEditExtension , LazyOsqueryManagedCustomButtonExtension , } from './fleet_integration' ; import { getLazyOsqueryAction } from './shared_components' ; export class OsqueryPlugin implements Plugin < OsqueryPluginSetup , OsqueryPluginStart > { private kibanaVersion : string ; private storage = new Storage ( localStorage ) ; constructor ( private readonly initializerContext ) { this . kibanaVersion = this . initializerContext . env . packageInfo . version ; } public setup ( core ) { const storage = this . storage ; const kibanaVersion = this . kibanaVersion ; core . application . register ( { id : 'osquery' , title : PLUGIN_NAME , order : 9030 , category : DEFAULT_APP_CATEGORIES . management , async mount ( params ) { const [ coreStart , depsStart ] = await core . getStartServices ( ) ; const { renderApp } = await import ( './application' ) ; return renderApp ( coreStart , depsStart as AppPluginStartDependencies , params , storage , kibanaVersion ) ; } , } ) ; return { } ; } public start ( core , plugins ) { if ( plugins . fleet ) { const { registerExtension } = plugins . fleet ; registerExtension ( { package : OSQUERY_INTEGRATION_NAME , view : 'package-policy-create' , Component : LazyOsqueryManagedPolicyCreateImportExtension , } ) ; registerExtension ( { package : OSQUERY_INTEGRATION_NAME , view : 'package-policy-edit' , Component : LazyOsqueryManagedPolicyEditExtension , } ) ; registerExtension ( { package : OSQUERY_INTEGRATION_NAME , view : 'package-detail-custom' , Component : LazyOsqueryManagedCustomButtonExtension , } ) ; } return { OsqueryAction : getLazyOsqueryAction ( { ... core , ... plugins , storage : this . storage , kibanaVersion : this . kibanaVersion , } ) , } ; } public stop ( ) { } }