import { Observable } from 'rxjs' ; import { Type } from '@osd/config-schema' ; import { RecursiveReadonly } from '@osd/utility-types' ; import { PathConfigType } from '@osd/utils' ; import { ConfigPath , EnvironmentMode , PackageInfo , ConfigDeprecationProvider } from '../config' ; import { LoggerFactory } from '../logging' ; import { OpenSearchDashboardsConfigType } from '../opensearch_dashboards_config' ; import { OpenSearchConfigType } from '../opensearch/opensearch_config' ; import { SavedObjectsConfigType } from '../saved_objects/saved_objects_config' ; import { CoreSetup , CoreStart } from '..' ; public export type PluginConfigSchema < T > = Type < T > ; example public export interface PluginConfigDescriptor < T = any > { /**
     * Provider for the  ConfigDeprecation to apply to the plugin configuration.
      deprecations ? : ConfigDeprecationProvider ; /**
     * List of configuration properties that will be available on the client-side plugin.
     */ exposeToBrowser ? : { [ P in keyof T ] ? : boolean ; } ; /**
     * Schema to use to validate the plugin configuration.
     *
     *  PluginConfigSchema schema : PluginConfigSchema < T > ; } public export type PluginName = string ; public export type PluginOpaqueId = symbol ; internal export interface PluginDependencies { asNames : ReadonlyMap < PluginName , PluginName [ ] > ; asOpaqueIds : ReadonlyMap < PluginOpaqueId , PluginOpaqueId [ ] > ; } remarks public export interface PluginManifest { /**
     * Identifier of the plugin. Must be a string in camelCase. Part of a plugin public contract.
     * Other plugins leverage it to access plugin API, navigate to the plugin, etc.
     */ readonly id : PluginName ; /**
     * Version of the plugin.
     */ readonly version : string ; /**
     * The version of OpenSearch Dashboards the plugin is compatible with, defaults to "version".
     */ readonly opensearchDashboardsVersion : string ; /**
     * Root  ConfigPath used by the plugin, defaults
     * to "id" in snake_case format.
     *
     *  example readonly configPath : ConfigPath ; /**
     * An optional list of the other plugins that **must be** installed and enabled
     * for this plugin to function properly.
     */ readonly requiredPlugins : readonly PluginName [ ] ; remarks readonly requiredBundles : readonly string [ ] ; /**
     * An optional list of the other plugins that if installed and enabled **may be**
     * leveraged by this plugin for some additional functionality but otherwise are
     * not required for this plugin to work properly.
     */ readonly optionalPlugins : readonly PluginName [ ] ; /**
     * Specifies whether plugin includes some client/browser specific functionality
     * that should be included into client bundle via `public/ui_plugin.js` file.
     */ readonly ui : boolean ; /**
     * Specifies whether plugin includes some server-side specific functionality.
     */ readonly server : boolean ; deprecated readonly extraPublicDirs ? : string [ ] ; } public export interface DiscoveredPlugin { /**
     * Identifier of the plugin.
     */ readonly id : PluginName ; /**
     * Root configuration path used by the plugin, defaults to "id" in snake_case format.
     */ readonly configPath : ConfigPath ; /**
     * An optional list of the other plugins that **must be** installed and enabled
     * for this plugin to function properly.
     */ readonly requiredPlugins : readonly PluginName [ ] ; /**
     * An optional list of the other plugins that if installed and enabled **may be**
     * leveraged by this plugin for some additional functionality but otherwise are
     * not required for this plugin to work properly.
     */ readonly optionalPlugins : readonly PluginName [ ] ; remarks readonly requiredBundles : readonly PluginName [ ] ; } internal export interface InternalPluginInfo { /**
     * Bundles that must be loaded for this plugoin
     */ readonly requiredBundles : readonly string [ ] ; /**
     * Path to the target/public directory of the plugin which should be
     * served
     */ readonly publicTargetDir : string ; /**
     * Path to the plugin assets directory.
     */ readonly publicAssetsDir : string ; } public export interface Plugin < TSetup = void , TStart = void , TPluginsSetup extends object = object , TPluginsStart extends object = object > { setup ( core , plugins ) : TSetup | Promise < TSetup > ; start ( core , plugins ) : TStart | Promise < TStart > ; stop ? ( ) : void ; } export const SharedGlobalConfigKeys = { opensearchDashboards : [ 'index' , 'autocompleteTerminateAfter' , 'autocompleteTimeout' ] as const , opensearch : [ 'shardTimeout' , 'requestTimeout' , 'pingTimeout' ] as const , path : [ 'data' ] as const , savedObjects : [ 'maxImportPayloadBytes' ] as const , } ; public export type SharedGlobalConfig = RecursiveReadonly < { opensearchDashboards : Pick < OpenSearchDashboardsConfigType , typeof SharedGlobalConfigKeys . opensearchDashboards [ number ] > ; opensearch : Pick < OpenSearchConfigType , typeof SharedGlobalConfigKeys . opensearch [ number ] > ; path : Pick < PathConfigType , typeof SharedGlobalConfigKeys . path [ number ] > ; savedObjects : Pick < SavedObjectsConfigType , typeof SharedGlobalConfigKeys . savedObjects [ number ] > ; } > ; public export interface PluginInitializerContext < ConfigSchema = unknown > { opaqueId : PluginOpaqueId ; env : { mode : EnvironmentMode ; packageInfo : Readonly < PackageInfo > ; instanceUuid : string ; } ; logger : LoggerFactory ; config : { legacy : { globalConfig$ : Observable < SharedGlobalConfig > ; } ; create : < T = ConfigSchema > ( ) => Observable < T > ; createIfExists : < T = ConfigSchema > ( ) => Observable < T | undefined > ; } ; } public export type PluginInitializer < TSetup , TStart , TPluginsSetup extends object = object , TPluginsStart extends object = object > = ( core : PluginInitializerContext ) => Plugin < TSetup , TStart , TPluginsSetup , TPluginsStart > ;