import { Observable } from 'rxjs' ; import { Type } from '@kbn/config-schema' ; import { RecursiveReadonly } from '@kbn/utility-types' ; import { PathConfigType } from '@kbn/utils' ; import { ConfigPath , EnvironmentMode , PackageInfo , ConfigDeprecationProvider } from '../config' ; import { LoggerFactory } from '../logging' ; import { ElasticsearchConfigType } from '../elasticsearch/elasticsearch_config' ; import { SavedObjectsConfigType } from '../saved_objects/saved_objects_config' ; import { CorePreboot , CoreSetup , CoreStart } from '..' ; type Maybe < T > = T | undefined ; 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 > ; /**
     * Expose non-default configs to usage collection to be sent via telemetry.
     * set a config to `true` to report the actual changed config value.
     * set a config to `false` to report the changed config value as [redacted].
     *
     * All changed configs except booleans and numbers will be reported
     * as [redacted] unless otherwise specified.
     *
     *  MakeUsageFromSchema exposeToUsage ? : MakeUsageFromSchema < T > ; } public export type MakeUsageFromSchema < T > = { [ Key in keyof T ] ? : T [ Key ] extends Maybe < object [ ] > ? false : T [ Key ] extends Maybe < any [ ] > ? boolean : T [ Key ] extends Maybe < object > ? MakeUsageFromSchema < T [ Key ] > | boolean : boolean ; } ; public export type PluginName = string ; public export type PluginOpaqueId = symbol ; public export enum PluginType { /**
     * Preboot plugins are special-purpose plugins that only function during preboot stage.
     */ preboot = 'preboot' , /**
     * Standard plugins are plugins that start to function as soon as Kibana is fully booted and are active until it shuts down.
     */ standard = 'standard' } 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 Kibana the plugin is compatible with, defaults to "version".
     */ readonly kibanaVersion : string ; /**
     * Type of the plugin, defaults to `standard`.
     */ readonly type : PluginType ; /**
     * 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 [ ] ; /**
     * Only used for the automatically generated API documentation. Specifying service
     * folders will cause your plugin API reference to be broken up into sub sections.
     */ readonly serviceFolders ? : readonly string [ ] ; readonly owner : { /**
         * The name of the team that currently owns this plugin.
         */ readonly name : string ; /**
         * All internal plugins should have a github team specified. GitHub teams can be viewed here:
         * https://github.com/orgs/elastic/teams
         */ readonly githubTeam ? : string ; } ; /**
     * TODO: make required once all plugins specify this.
     * A brief description of what this plugin does and any capabilities it provides.
     */ readonly description ? : 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 ; /**
     * Type of the plugin, defaults to `standard`.
     */ readonly type : PluginType ; /**
     * 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 { /**
     * Version of the plugin
     */ readonly version : string ; /**
     * Bundles that must be loaded for this plugin
     */ 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 PrebootPlugin < TSetup = void , TPluginsSetup extends object = object > { setup ( core , plugins ) : TSetup ; stop ? ( ) : void ; } public export interface Plugin < TSetup = void , TStart = void , TPluginsSetup extends object = object , TPluginsStart extends object = object > { setup ( core , plugins ) : TSetup ; start ( core , plugins ) : TStart ; stop ? ( ) : void ; } deprecated Asynchronous lifecycles are deprecated, and should be migrated to sync  Plugin public export interface AsyncPlugin < 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 = { elasticsearch : [ 'shardTimeout' , 'requestTimeout' , 'pingTimeout' ] as const , path : [ 'data' ] as const , savedObjects : [ 'maxImportPayloadBytes' ] as const , } ; public export type SharedGlobalConfig = RecursiveReadonly < { elasticsearch : Pick < ElasticsearchConfigType , typeof SharedGlobalConfigKeys . elasticsearch [ 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 ; configs : readonly string [ ] ; } ; /**
     *  LoggerFactory instance already bound to the plugin's logging context
     *
     *  example logger : LoggerFactory ; /**
     * Accessors for the plugin's configuration
     */ config : { remarks deprecated legacy : { globalConfig$ : Observable < SharedGlobalConfig > ; get : ( ) => SharedGlobalConfig ; } ; example example remarks create : < T = ConfigSchema > ( ) => Observable < T > ; example remarks This should only be used when synchronous access is an absolute necessity, such
         *          as during the plugin's setup or start lifecycle. For all other usages,
         *           create should be used instead.
          get : < T = ConfigSchema > ( ) => T ; } ; } public export type PluginInitializer < TSetup , TStart , TPluginsSetup extends object = object , TPluginsStart extends object = object > = ( core : PluginInitializerContext ) => Plugin < TSetup , TStart , TPluginsSetup , TPluginsStart > | PrebootPlugin < TSetup , TPluginsSetup > | AsyncPlugin < TSetup , TStart , TPluginsSetup , TPluginsStart > ;