diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md
index cd469fe6a98c2..15f5329d494c2 100644
--- a/docs/development/core/server/kibana-plugin-server.md
+++ b/docs/development/core/server/kibana-plugin-server.md
@@ -1,224 +1,226 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md)
-
-## kibana-plugin-server package
-
-The Kibana Core APIs for server-side plugins.
-
-A plugin requires a `kibana.json` file at it's root directory that follows [the manfiest schema](./kibana-plugin-server.pluginmanifest.md) to define static plugin information required to load the plugin.
-
-A plugin's `server/index` file must contain a named import, `plugin`, that implements [PluginInitializer](./kibana-plugin-server.plugininitializer.md) which returns an object that implements [Plugin](./kibana-plugin-server.plugin.md).
-
-The plugin integrates with the core system via lifecycle events: `setup`, `start`, and `stop`. In each lifecycle method, the plugin will receive the corresponding core services available (either [CoreSetup](./kibana-plugin-server.coresetup.md) or [CoreStart](./kibana-plugin-server.corestart.md)) and any interfaces returned by dependency plugins' lifecycle method. Anything returned by the plugin's lifecycle method will be exposed to downstream dependencies when their corresponding lifecycle methods are invoked.
-
-## Classes
-
-| Class | Description |
-| --- | --- |
-| [BasePath](./kibana-plugin-server.basepath.md) | Access or manipulate the Kibana base path |
-| [ClusterClient](./kibana-plugin-server.clusterclient.md) | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
).See [ClusterClient](./kibana-plugin-server.clusterclient.md). |
-| [CspConfig](./kibana-plugin-server.cspconfig.md) | CSP configuration for use in Kibana. |
-| [ElasticsearchErrorHelpers](./kibana-plugin-server.elasticsearcherrorhelpers.md) | Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as body.error.header[WWW-Authenticate]
|
-| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
-| [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) | Error to return when the validation is not successful. |
-| [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) | |
-| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) | |
-| [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) | |
-| [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md) | Serves the same purpose as "normal" ClusterClient
but exposes additional callAsCurrentUser
method that doesn't use credentials of the Kibana internal user (as callAsInternalUser
does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md). |
-
-## Enumerations
-
-| Enumeration | Description |
-| --- | --- |
-| [AuthResultType](./kibana-plugin-server.authresulttype.md) | |
-| [AuthStatus](./kibana-plugin-server.authstatus.md) | Status indicating an outcome of the authentication. |
-
-## Interfaces
-
-| Interface | Description |
-| --- | --- |
-| [APICaller](./kibana-plugin-server.apicaller.md) | |
-| [AssistanceAPIResponse](./kibana-plugin-server.assistanceapiresponse.md) | |
-| [AssistantAPIClientParams](./kibana-plugin-server.assistantapiclientparams.md) | |
-| [Authenticated](./kibana-plugin-server.authenticated.md) | |
-| [AuthResultParams](./kibana-plugin-server.authresultparams.md) | Result of an incoming request authentication. |
-| [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. |
-| [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. |
-| [Capabilities](./kibana-plugin-server.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
-| [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | APIs to manage the [Capabilities](./kibana-plugin-server.capabilities.md) that will be used by the application.Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the registerProvider
method.Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the registerSwitcher
method.Refers to the methods documentation for complete description and examples. |
-| [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) | APIs to access the application [Capabilities](./kibana-plugin-server.capabilities.md). |
-| [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) | Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md).See methods documentation for more detailed examples. |
-| [ContextSetup](./kibana-plugin-server.contextsetup.md) | An object that handles registration of context providers and configuring handlers with context. |
-| [CoreSetup](./kibana-plugin-server.coresetup.md) | Context passed to the plugins setup
method. |
-| [CoreStart](./kibana-plugin-server.corestart.md) | Context passed to the plugins start
method. |
-| [CustomHttpResponseOptions](./kibana-plugin-server.customhttpresponseoptions.md) | HTTP response parameters for a response with adjustable status code. |
-| [DeprecationAPIClientParams](./kibana-plugin-server.deprecationapiclientparams.md) | |
-| [DeprecationAPIResponse](./kibana-plugin-server.deprecationapiresponse.md) | |
-| [DeprecationInfo](./kibana-plugin-server.deprecationinfo.md) | |
-| [DeprecationSettings](./kibana-plugin-server.deprecationsettings.md) | UiSettings deprecation field options. |
-| [DiscoveredPlugin](./kibana-plugin-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
-| [ElasticsearchError](./kibana-plugin-server.elasticsearcherror.md) | |
-| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
-| [EnvironmentMode](./kibana-plugin-server.environmentmode.md) | |
-| [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters |
-| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
-| [HttpResponseOptions](./kibana-plugin-server.httpresponseoptions.md) | HTTP response parameters |
-| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to hapi
server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
-| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
-| [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. |
-| [ICspConfig](./kibana-plugin-server.icspconfig.md) | CSP configuration for use in Kibana. |
-| [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution |
-| [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. |
-| [ImageValidation](./kibana-plugin-server.imagevalidation.md) | |
-| [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | |
-| [IRenderOptions](./kibana-plugin-server.irenderoptions.md) | |
-| [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. |
-| [IScopedRenderingClient](./kibana-plugin-server.iscopedrenderingclient.md) | |
-| [IUiSettingsClient](./kibana-plugin-server.iuisettingsclient.md) | Server-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. |
-| [KibanaRequestEvents](./kibana-plugin-server.kibanarequestevents.md) | Request events. |
-| [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. |
-| [LegacyRequest](./kibana-plugin-server.legacyrequest.md) | |
-| [LegacyServiceSetupDeps](./kibana-plugin-server.legacyservicesetupdeps.md) | |
-| [LegacyServiceStartDeps](./kibana-plugin-server.legacyservicestartdeps.md) | |
-| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
-| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of LoggerFactory
interface is to define a way to retrieve a context-based logger instance. |
-| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
-| [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
-| [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
-| [OnPreResponseExtensions](./kibana-plugin-server.onpreresponseextensions.md) | Additional data to extend a response. |
-| [OnPreResponseInfo](./kibana-plugin-server.onpreresponseinfo.md) | Response status code. |
-| [OnPreResponseToolkit](./kibana-plugin-server.onpreresponsetoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
-| [PackageInfo](./kibana-plugin-server.packageinfo.md) | |
-| [Plugin](./kibana-plugin-server.plugin.md) | The interface that should be returned by a PluginInitializer
. |
-| [PluginConfigDescriptor](./kibana-plugin-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. |
-| [PluginInitializerContext](./kibana-plugin-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. |
-| [PluginManifest](./kibana-plugin-server.pluginmanifest.md) | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. |
-| [PluginsServiceSetup](./kibana-plugin-server.pluginsservicesetup.md) | |
-| [PluginsServiceStart](./kibana-plugin-server.pluginsservicestart.md) | |
-| [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.Provides the following clients: - [rendering](./kibana-plugin-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [elasticsearch.dataClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
-| [RouteConfig](./kibana-plugin-server.routeconfig.md) | Route specific configuration. |
-| [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md) | Additional route options. |
-| [RouteConfigOptionsBody](./kibana-plugin-server.routeconfigoptionsbody.md) | Additional body options for a route |
-| [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) | Validation result factory to be used in the custom validation function to return the valid data or validation errorsSee [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md). |
-| [RouteValidatorConfig](./kibana-plugin-server.routevalidatorconfig.md) | The configuration object to the RouteValidator class. Set params
, query
and/or body
to specify the validation logic to follow for that property. |
-| [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) | Additional options for the RouteValidator class to modify its default behaviour. |
-| [SavedObject](./kibana-plugin-server.savedobject.md) | |
-| [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md) | The data for a Saved Object is stored as an object in the attributes
property. |
-| [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) | A reference to another saved object. |
-| [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md) | |
-| [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) | |
-| [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) | |
-| [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md) | |
-| [SavedObjectsBulkUpdateObject](./kibana-plugin-server.savedobjectsbulkupdateobject.md) | |
-| [SavedObjectsBulkUpdateOptions](./kibana-plugin-server.savedobjectsbulkupdateoptions.md) | |
-| [SavedObjectsBulkUpdateResponse](./kibana-plugin-server.savedobjectsbulkupdateresponse.md) | |
-| [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
-| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
-| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
-| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-server.savedobjectsdeletebynamespaceoptions.md) | |
-| [SavedObjectsDeleteOptions](./kibana-plugin-server.savedobjectsdeleteoptions.md) | |
-| [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) | Options controlling the export operation. |
-| [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) | Structure of the export result details entry |
-| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
-| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | Return type of the Saved Objects find()
method.\*Note\*: this type is different between the Public and Server Saved Objects clients. |
-| [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
-| [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) | Represents a failure to import. |
-| [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
-| [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) | Options to control the import operation. |
-| [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) | The response describing the result of an import. |
-| [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
-| [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
-| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
-| [SavedObjectsIncrementCounterOptions](./kibana-plugin-server.savedobjectsincrementcounteroptions.md) | |
-| [SavedObjectsMigrationLogger](./kibana-plugin-server.savedobjectsmigrationlogger.md) | |
-| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
-| [SavedObjectsRawDoc](./kibana-plugin-server.savedobjectsrawdoc.md) | A raw document as represented directly in the saved object index. |
-| [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) | Options to control the "resolve import" operation. |
-| [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for creating and registering Saved Object client wrappers. |
-| [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects. |
-| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
-| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
-| [SessionCookieValidationResult](./kibana-plugin-server.sessioncookievalidationresult.md) | Return type from a function to validate cookie contents. |
-| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
-| [SessionStorageCookieOptions](./kibana-plugin-server.sessionstoragecookieoptions.md) | Configuration used to create HTTP session storage based on top of cookie mechanism. |
-| [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request |
-| [StringValidation](./kibana-plugin-server.stringvalidation.md) | |
-| [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | UiSettings parameters defined by the plugins. |
-| [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) | |
-| [UiSettingsServiceStart](./kibana-plugin-server.uisettingsservicestart.md) | |
-| [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) | Describes the values explicitly set by user. |
-| [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) | APIs to access the application's instance uuid. |
-
-## Variables
-
-| Variable | Description |
-| --- | --- |
-| [kibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Set of helpers used to create KibanaResponse
to form HTTP response on an incoming request. Should be returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution. |
-| [validBodyOutput](./kibana-plugin-server.validbodyoutput.md) | The set of valid body.output |
-
-## Type Aliases
-
-| Type Alias | Description |
-| --- | --- |
-| [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | See [AuthToolkit](./kibana-plugin-server.authtoolkit.md). |
-| [AuthHeaders](./kibana-plugin-server.authheaders.md) | Auth Headers map |
-| [AuthResult](./kibana-plugin-server.authresult.md) | |
-| [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
-| [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
-| [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) | Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. |
-| [ConfigDeprecationLogger](./kibana-plugin-server.configdeprecationlogger.md) | Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) |
-| [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) | A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md).See [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) for more usage examples. |
-| [ConfigPath](./kibana-plugin-server.configpath.md) | |
-| [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | |
-| [GetAuthHeaders](./kibana-plugin-server.getauthheaders.md) | Get headers to authenticate a user against Elasticsearch. |
-| [GetAuthState](./kibana-plugin-server.getauthstate.md) | Get authentication state for a request. Returned by auth
interceptor. |
-| [HandlerContextType](./kibana-plugin-server.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md) to represent the type of the context. |
-| [HandlerFunction](./kibana-plugin-server.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-server.icontextcontainer.md) |
-| [HandlerParameters](./kibana-plugin-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md). |
-| [Headers](./kibana-plugin-server.headers.md) | Http request headers to read. |
-| [HttpResponsePayload](./kibana-plugin-server.httpresponsepayload.md) | Data send to the client as a response payload. |
-| [IBasePath](./kibana-plugin-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-server.basepath.md) |
-| [IClusterClient](./kibana-plugin-server.iclusterclient.md) | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
).See [ClusterClient](./kibana-plugin-server.clusterclient.md). |
-| [IContextProvider](./kibana-plugin-server.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
-| [ICustomClusterClient](./kibana-plugin-server.icustomclusterclient.md) | Represents an Elasticsearch cluster API client created by a plugin. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
).See [ClusterClient](./kibana-plugin-server.clusterclient.md). |
-| [IsAuthenticated](./kibana-plugin-server.isauthenticated.md) | Return authentication status for a request. |
-| [ISavedObjectsRepository](./kibana-plugin-server.isavedobjectsrepository.md) | See [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) |
-| [IScopedClusterClient](./kibana-plugin-server.iscopedclusterclient.md) | Serves the same purpose as "normal" ClusterClient
but exposes additional callAsCurrentUser
method that doesn't use credentials of the Kibana internal user (as callAsInternalUser
does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md). |
-| [KibanaRequestRouteOptions](./kibana-plugin-server.kibanarequestrouteoptions.md) | Route options: If 'GET' or 'OPTIONS' method, body options won't be returned. |
-| [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
-| [KnownHeaders](./kibana-plugin-server.knownheaders.md) | Set of well-known HTTP headers. |
-| [LifecycleResponseFactory](./kibana-plugin-server.lifecycleresponsefactory.md) | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. |
-| [MIGRATION\_ASSISTANCE\_INDEX\_ACTION](./kibana-plugin-server.migration_assistance_index_action.md) | |
-| [MIGRATION\_DEPRECATION\_LEVEL](./kibana-plugin-server.migration_deprecation_level.md) | |
-| [MutatingOperationRefreshSetting](./kibana-plugin-server.mutatingoperationrefreshsetting.md) | Elasticsearch Refresh setting for mutating operation |
-| [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md) | See [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md). |
-| [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md). |
-| [OnPreResponseHandler](./kibana-plugin-server.onpreresponsehandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md). |
-| [PluginConfigSchema](./kibana-plugin-server.pluginconfigschema.md) | Dedicated type for plugin configuration schema. |
-| [PluginInitializer](./kibana-plugin-server.plugininitializer.md) | The plugin
export at the root of a plugin's server
directory should conform to this interface. |
-| [PluginName](./kibana-plugin-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |
-| [PluginOpaqueId](./kibana-plugin-server.pluginopaqueid.md) | |
-| [RecursiveReadonly](./kibana-plugin-server.recursivereadonly.md) | |
-| [RedirectResponseOptions](./kibana-plugin-server.redirectresponseoptions.md) | HTTP response parameters for redirection response |
-| [RequestHandler](./kibana-plugin-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) functions. |
-| [RequestHandlerContextContainer](./kibana-plugin-server.requesthandlercontextcontainer.md) | An object that handles registration of http request context providers. |
-| [RequestHandlerContextProvider](./kibana-plugin-server.requesthandlercontextprovider.md) | Context provider for request handler. Extends request context object with provided functionality or data. |
-| [ResponseError](./kibana-plugin-server.responseerror.md) | Error message and optional data send to the client in case of error. |
-| [ResponseErrorAttributes](./kibana-plugin-server.responseerrorattributes.md) | Additional data to provide error details. |
-| [ResponseHeaders](./kibana-plugin-server.responseheaders.md) | Http response headers to set. |
-| [RouteContentType](./kibana-plugin-server.routecontenttype.md) | The set of supported parseable Content-Types |
-| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
-| [RouteRegistrar](./kibana-plugin-server.routeregistrar.md) | Route handler common definition |
-| [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) | The custom validation function if @kbn/config-schema is not a valid solution for your specific plugin requirements. |
-| [RouteValidationSpec](./kibana-plugin-server.routevalidationspec.md) | Allowed property validation options: either @kbn/config-schema validations or custom validation functionsSee [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) for custom validation. |
-| [RouteValidatorFullConfig](./kibana-plugin-server.routevalidatorfullconfig.md) | Route validations config and options merged into one object |
-| [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) | Type definition for a Saved Object attribute value |
-| [SavedObjectAttributeSingle](./kibana-plugin-server.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) |
-| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state.\#\# SavedObjectsClient errorsSince the SavedObjectsClient has its hands in everything we are a little paranoid about the way we present errors back to to application code. Ideally, all errors will be either:1. Caused by bad implementation (ie. undefined is not a function) and as such unpredictable 2. An error that has been classified and decorated appropriately by the decorators in [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md)Type 1 errors are inevitable, but since all expected/handle-able errors should be Type 2 the isXYZError()
helpers exposed at SavedObjectsErrorHelpers
should be used to understand and manage error responses from the SavedObjectsClient
.Type 2 errors are decorated versions of the source error, so if the elasticsearch client threw an error it will be decorated based on its type. That means that rather than looking for error.body.error.type
or doing substring checks on error.body.error.reason
, just use the helpers to understand the meaning of the error:\`\`\`js if (SavedObjectsErrorHelpers.isNotFoundError(error)) { // handle 404 }if (SavedObjectsErrorHelpers.isNotAuthorizedError(error)) { // 401 handling should be automatic, but in case you wanted to know }// always rethrow the error unless you handle it throw error; \`\`\`\#\#\# 404s from missing indexFrom the perspective of application code and APIs the SavedObjectsClient is a black box that persists objects. One of the internal details that users have no control over is that we use an elasticsearch index for persistance and that index might be missing.At the time of writing we are in the process of transitioning away from the operating assumption that the SavedObjects index is always available. Part of this transition is handling errors resulting from an index missing. These used to trigger a 500 error in most cases, and in others cause 404s with different error messages.From my (Spencer) perspective, a 404 from the SavedObjectsApi is a 404; The object the request/call was targeting could not be found. This is why \#14141 takes special care to ensure that 404 errors are generic and don't distinguish between index missing or document missing.\#\#\# 503s from missing indexUnlike all other methods, create requests are supposed to succeed even when the Kibana index does not exist because it will be automatically created by elasticsearch. When that is not the case it is because Elasticsearch's action.auto_create_index
setting prevents it from being created automatically so we throw a special 503 with the intention of informing the user that their Elasticsearch settings need to be updated.See [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) See [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) |
-| [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md) | Describes the factory used to create instances of the Saved Objects Client. |
-| [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) | Describes the factory used to create instances of Saved Objects Client Wrappers. |
-| [ScopeableRequest](./kibana-plugin-server.scopeablerequest.md) | A user credentials container. It accommodates the necessary auth credentials to impersonate the current user.See [KibanaRequest](./kibana-plugin-server.kibanarequest.md). |
-| [SharedGlobalConfig](./kibana-plugin-server.sharedglobalconfig.md) | |
-| [UiSettingsType](./kibana-plugin-server.uisettingstype.md) | UI element type to represent the settings. |
-
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md)
+
+## kibana-plugin-server package
+
+The Kibana Core APIs for server-side plugins.
+
+A plugin requires a `kibana.json` file at it's root directory that follows [the manfiest schema](./kibana-plugin-server.pluginmanifest.md) to define static plugin information required to load the plugin.
+
+A plugin's `server/index` file must contain a named import, `plugin`, that implements [PluginInitializer](./kibana-plugin-server.plugininitializer.md) which returns an object that implements [Plugin](./kibana-plugin-server.plugin.md).
+
+The plugin integrates with the core system via lifecycle events: `setup`, `start`, and `stop`. In each lifecycle method, the plugin will receive the corresponding core services available (either [CoreSetup](./kibana-plugin-server.coresetup.md) or [CoreStart](./kibana-plugin-server.corestart.md)) and any interfaces returned by dependency plugins' lifecycle method. Anything returned by the plugin's lifecycle method will be exposed to downstream dependencies when their corresponding lifecycle methods are invoked.
+
+## Classes
+
+| Class | Description |
+| --- | --- |
+| [BasePath](./kibana-plugin-server.basepath.md) | Access or manipulate the Kibana base path |
+| [ClusterClient](./kibana-plugin-server.clusterclient.md) | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
).See [ClusterClient](./kibana-plugin-server.clusterclient.md). |
+| [CspConfig](./kibana-plugin-server.cspconfig.md) | CSP configuration for use in Kibana. |
+| [ElasticsearchErrorHelpers](./kibana-plugin-server.elasticsearcherrorhelpers.md) | Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as body.error.header[WWW-Authenticate]
|
+| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
+| [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) | Error to return when the validation is not successful. |
+| [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) | |
+| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) | |
+| [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) | |
+| [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md) | Serves the same purpose as "normal" ClusterClient
but exposes additional callAsCurrentUser
method that doesn't use credentials of the Kibana internal user (as callAsInternalUser
does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md). |
+
+## Enumerations
+
+| Enumeration | Description |
+| --- | --- |
+| [AuthResultType](./kibana-plugin-server.authresulttype.md) | |
+| [AuthStatus](./kibana-plugin-server.authstatus.md) | Status indicating an outcome of the authentication. |
+
+## Interfaces
+
+| Interface | Description |
+| --- | --- |
+| [APICaller](./kibana-plugin-server.apicaller.md) | |
+| [AssistanceAPIResponse](./kibana-plugin-server.assistanceapiresponse.md) | |
+| [AssistantAPIClientParams](./kibana-plugin-server.assistantapiclientparams.md) | |
+| [Authenticated](./kibana-plugin-server.authenticated.md) | |
+| [AuthResultParams](./kibana-plugin-server.authresultparams.md) | Result of an incoming request authentication. |
+| [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. |
+| [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. |
+| [Capabilities](./kibana-plugin-server.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
+| [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | APIs to manage the [Capabilities](./kibana-plugin-server.capabilities.md) that will be used by the application.Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the registerProvider
method.Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the registerSwitcher
method.Refers to the methods documentation for complete description and examples. |
+| [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) | APIs to access the application [Capabilities](./kibana-plugin-server.capabilities.md). |
+| [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) | Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md).See methods documentation for more detailed examples. |
+| [ContextSetup](./kibana-plugin-server.contextsetup.md) | An object that handles registration of context providers and configuring handlers with context. |
+| [CoreSetup](./kibana-plugin-server.coresetup.md) | Context passed to the plugins setup
method. |
+| [CoreStart](./kibana-plugin-server.corestart.md) | Context passed to the plugins start
method. |
+| [CustomHttpResponseOptions](./kibana-plugin-server.customhttpresponseoptions.md) | HTTP response parameters for a response with adjustable status code. |
+| [DeprecationAPIClientParams](./kibana-plugin-server.deprecationapiclientparams.md) | |
+| [DeprecationAPIResponse](./kibana-plugin-server.deprecationapiresponse.md) | |
+| [DeprecationInfo](./kibana-plugin-server.deprecationinfo.md) | |
+| [DeprecationSettings](./kibana-plugin-server.deprecationsettings.md) | UiSettings deprecation field options. |
+| [DiscoveredPlugin](./kibana-plugin-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
+| [ElasticsearchError](./kibana-plugin-server.elasticsearcherror.md) | |
+| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
+| [EnvironmentMode](./kibana-plugin-server.environmentmode.md) | |
+| [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters |
+| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
+| [HttpResponseOptions](./kibana-plugin-server.httpresponseoptions.md) | HTTP response parameters |
+| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to hapi
server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
+| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
+| [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. |
+| [ICspConfig](./kibana-plugin-server.icspconfig.md) | CSP configuration for use in Kibana. |
+| [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution |
+| [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. |
+| [ImageValidation](./kibana-plugin-server.imagevalidation.md) | |
+| [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | |
+| [IRenderOptions](./kibana-plugin-server.irenderoptions.md) | |
+| [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. |
+| [IScopedRenderingClient](./kibana-plugin-server.iscopedrenderingclient.md) | |
+| [IUiSettingsClient](./kibana-plugin-server.iuisettingsclient.md) | Server-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. |
+| [KibanaRequestEvents](./kibana-plugin-server.kibanarequestevents.md) | Request events. |
+| [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. |
+| [LegacyRequest](./kibana-plugin-server.legacyrequest.md) | |
+| [LegacyServiceSetupDeps](./kibana-plugin-server.legacyservicesetupdeps.md) | |
+| [LegacyServiceStartDeps](./kibana-plugin-server.legacyservicestartdeps.md) | |
+| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
+| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of LoggerFactory
interface is to define a way to retrieve a context-based logger instance. |
+| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
+| [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
+| [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
+| [OnPreResponseExtensions](./kibana-plugin-server.onpreresponseextensions.md) | Additional data to extend a response. |
+| [OnPreResponseInfo](./kibana-plugin-server.onpreresponseinfo.md) | Response status code. |
+| [OnPreResponseToolkit](./kibana-plugin-server.onpreresponsetoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
+| [PackageInfo](./kibana-plugin-server.packageinfo.md) | |
+| [Plugin](./kibana-plugin-server.plugin.md) | The interface that should be returned by a PluginInitializer
. |
+| [PluginConfigDescriptor](./kibana-plugin-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. |
+| [PluginInitializerContext](./kibana-plugin-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. |
+| [PluginManifest](./kibana-plugin-server.pluginmanifest.md) | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. |
+| [PluginsServiceSetup](./kibana-plugin-server.pluginsservicesetup.md) | |
+| [PluginsServiceStart](./kibana-plugin-server.pluginsservicestart.md) | |
+| [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.Provides the following clients: - [rendering](./kibana-plugin-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [elasticsearch.dataClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
+| [RouteConfig](./kibana-plugin-server.routeconfig.md) | Route specific configuration. |
+| [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md) | Additional route options. |
+| [RouteConfigOptionsBody](./kibana-plugin-server.routeconfigoptionsbody.md) | Additional body options for a route |
+| [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) | Validation result factory to be used in the custom validation function to return the valid data or validation errorsSee [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md). |
+| [RouteValidatorConfig](./kibana-plugin-server.routevalidatorconfig.md) | The configuration object to the RouteValidator class. Set params
, query
and/or body
to specify the validation logic to follow for that property. |
+| [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) | Additional options for the RouteValidator class to modify its default behaviour. |
+| [SavedObject](./kibana-plugin-server.savedobject.md) | |
+| [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md) | The data for a Saved Object is stored as an object in the attributes
property. |
+| [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) | A reference to another saved object. |
+| [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md) | |
+| [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) | |
+| [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) | |
+| [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md) | |
+| [SavedObjectsBulkUpdateObject](./kibana-plugin-server.savedobjectsbulkupdateobject.md) | |
+| [SavedObjectsBulkUpdateOptions](./kibana-plugin-server.savedobjectsbulkupdateoptions.md) | |
+| [SavedObjectsBulkUpdateResponse](./kibana-plugin-server.savedobjectsbulkupdateresponse.md) | |
+| [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
+| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
+| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
+| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-server.savedobjectsdeletebynamespaceoptions.md) | |
+| [SavedObjectsDeleteOptions](./kibana-plugin-server.savedobjectsdeleteoptions.md) | |
+| [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) | Options controlling the export operation. |
+| [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) | Structure of the export result details entry |
+| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
+| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | Return type of the Saved Objects find()
method.\*Note\*: this type is different between the Public and Server Saved Objects clients. |
+| [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
+| [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) | Represents a failure to import. |
+| [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
+| [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) | Options to control the import operation. |
+| [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) | The response describing the result of an import. |
+| [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
+| [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
+| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
+| [SavedObjectsIncrementCounterOptions](./kibana-plugin-server.savedobjectsincrementcounteroptions.md) | |
+| [SavedObjectsMigrationLogger](./kibana-plugin-server.savedobjectsmigrationlogger.md) | |
+| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
+| [SavedObjectsRawDoc](./kibana-plugin-server.savedobjectsrawdoc.md) | A raw document as represented directly in the saved object index. |
+| [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) | Factory provided when invoking a [client factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) See [SavedObjectsServiceSetup.setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) |
+| [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) | Options to control the "resolve import" operation. |
+| [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) | Saved Objects is Kibana's data persistence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for creating and registering Saved Object client wrappers. |
+| [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects. |
+| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
+| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
+| [SessionCookieValidationResult](./kibana-plugin-server.sessioncookievalidationresult.md) | Return type from a function to validate cookie contents. |
+| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
+| [SessionStorageCookieOptions](./kibana-plugin-server.sessionstoragecookieoptions.md) | Configuration used to create HTTP session storage based on top of cookie mechanism. |
+| [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request |
+| [StringValidation](./kibana-plugin-server.stringvalidation.md) | |
+| [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | UiSettings parameters defined by the plugins. |
+| [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) | |
+| [UiSettingsServiceStart](./kibana-plugin-server.uisettingsservicestart.md) | |
+| [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) | Describes the values explicitly set by user. |
+| [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) | APIs to access the application's instance uuid. |
+
+## Variables
+
+| Variable | Description |
+| --- | --- |
+| [kibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Set of helpers used to create KibanaResponse
to form HTTP response on an incoming request. Should be returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution. |
+| [validBodyOutput](./kibana-plugin-server.validbodyoutput.md) | The set of valid body.output |
+
+## Type Aliases
+
+| Type Alias | Description |
+| --- | --- |
+| [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | See [AuthToolkit](./kibana-plugin-server.authtoolkit.md). |
+| [AuthHeaders](./kibana-plugin-server.authheaders.md) | Auth Headers map |
+| [AuthResult](./kibana-plugin-server.authresult.md) | |
+| [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
+| [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
+| [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) | Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. |
+| [ConfigDeprecationLogger](./kibana-plugin-server.configdeprecationlogger.md) | Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) |
+| [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) | A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md).See [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) for more usage examples. |
+| [ConfigPath](./kibana-plugin-server.configpath.md) | |
+| [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | |
+| [GetAuthHeaders](./kibana-plugin-server.getauthheaders.md) | Get headers to authenticate a user against Elasticsearch. |
+| [GetAuthState](./kibana-plugin-server.getauthstate.md) | Get authentication state for a request. Returned by auth
interceptor. |
+| [HandlerContextType](./kibana-plugin-server.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md) to represent the type of the context. |
+| [HandlerFunction](./kibana-plugin-server.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-server.icontextcontainer.md) |
+| [HandlerParameters](./kibana-plugin-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md). |
+| [Headers](./kibana-plugin-server.headers.md) | Http request headers to read. |
+| [HttpResponsePayload](./kibana-plugin-server.httpresponsepayload.md) | Data send to the client as a response payload. |
+| [IBasePath](./kibana-plugin-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-server.basepath.md) |
+| [IClusterClient](./kibana-plugin-server.iclusterclient.md) | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
).See [ClusterClient](./kibana-plugin-server.clusterclient.md). |
+| [IContextProvider](./kibana-plugin-server.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
+| [ICustomClusterClient](./kibana-plugin-server.icustomclusterclient.md) | Represents an Elasticsearch cluster API client created by a plugin. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
).See [ClusterClient](./kibana-plugin-server.clusterclient.md). |
+| [IsAuthenticated](./kibana-plugin-server.isauthenticated.md) | Return authentication status for a request. |
+| [ISavedObjectsRepository](./kibana-plugin-server.isavedobjectsrepository.md) | See [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) |
+| [IScopedClusterClient](./kibana-plugin-server.iscopedclusterclient.md) | Serves the same purpose as "normal" ClusterClient
but exposes additional callAsCurrentUser
method that doesn't use credentials of the Kibana internal user (as callAsInternalUser
does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md). |
+| [KibanaRequestRouteOptions](./kibana-plugin-server.kibanarequestrouteoptions.md) | Route options: If 'GET' or 'OPTIONS' method, body options won't be returned. |
+| [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
+| [KnownHeaders](./kibana-plugin-server.knownheaders.md) | Set of well-known HTTP headers. |
+| [LifecycleResponseFactory](./kibana-plugin-server.lifecycleresponsefactory.md) | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. |
+| [MIGRATION\_ASSISTANCE\_INDEX\_ACTION](./kibana-plugin-server.migration_assistance_index_action.md) | |
+| [MIGRATION\_DEPRECATION\_LEVEL](./kibana-plugin-server.migration_deprecation_level.md) | |
+| [MutatingOperationRefreshSetting](./kibana-plugin-server.mutatingoperationrefreshsetting.md) | Elasticsearch Refresh setting for mutating operation |
+| [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md) | See [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md). |
+| [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md). |
+| [OnPreResponseHandler](./kibana-plugin-server.onpreresponsehandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md). |
+| [PluginConfigSchema](./kibana-plugin-server.pluginconfigschema.md) | Dedicated type for plugin configuration schema. |
+| [PluginInitializer](./kibana-plugin-server.plugininitializer.md) | The plugin
export at the root of a plugin's server
directory should conform to this interface. |
+| [PluginName](./kibana-plugin-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |
+| [PluginOpaqueId](./kibana-plugin-server.pluginopaqueid.md) | |
+| [RecursiveReadonly](./kibana-plugin-server.recursivereadonly.md) | |
+| [RedirectResponseOptions](./kibana-plugin-server.redirectresponseoptions.md) | HTTP response parameters for redirection response |
+| [RequestHandler](./kibana-plugin-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) functions. |
+| [RequestHandlerContextContainer](./kibana-plugin-server.requesthandlercontextcontainer.md) | An object that handles registration of http request context providers. |
+| [RequestHandlerContextProvider](./kibana-plugin-server.requesthandlercontextprovider.md) | Context provider for request handler. Extends request context object with provided functionality or data. |
+| [ResponseError](./kibana-plugin-server.responseerror.md) | Error message and optional data send to the client in case of error. |
+| [ResponseErrorAttributes](./kibana-plugin-server.responseerrorattributes.md) | Additional data to provide error details. |
+| [ResponseHeaders](./kibana-plugin-server.responseheaders.md) | Http response headers to set. |
+| [RouteContentType](./kibana-plugin-server.routecontenttype.md) | The set of supported parseable Content-Types |
+| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
+| [RouteRegistrar](./kibana-plugin-server.routeregistrar.md) | Route handler common definition |
+| [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) | The custom validation function if @kbn/config-schema is not a valid solution for your specific plugin requirements. |
+| [RouteValidationSpec](./kibana-plugin-server.routevalidationspec.md) | Allowed property validation options: either @kbn/config-schema validations or custom validation functionsSee [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) for custom validation. |
+| [RouteValidatorFullConfig](./kibana-plugin-server.routevalidatorfullconfig.md) | Route validations config and options merged into one object |
+| [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) | Type definition for a Saved Object attribute value |
+| [SavedObjectAttributeSingle](./kibana-plugin-server.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) |
+| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state.\#\# SavedObjectsClient errorsSince the SavedObjectsClient has its hands in everything we are a little paranoid about the way we present errors back to to application code. Ideally, all errors will be either:1. Caused by bad implementation (ie. undefined is not a function) and as such unpredictable 2. An error that has been classified and decorated appropriately by the decorators in [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md)Type 1 errors are inevitable, but since all expected/handle-able errors should be Type 2 the isXYZError()
helpers exposed at SavedObjectsErrorHelpers
should be used to understand and manage error responses from the SavedObjectsClient
.Type 2 errors are decorated versions of the source error, so if the elasticsearch client threw an error it will be decorated based on its type. That means that rather than looking for error.body.error.type
or doing substring checks on error.body.error.reason
, just use the helpers to understand the meaning of the error:\`\`\`js if (SavedObjectsErrorHelpers.isNotFoundError(error)) { // handle 404 }if (SavedObjectsErrorHelpers.isNotAuthorizedError(error)) { // 401 handling should be automatic, but in case you wanted to know }// always rethrow the error unless you handle it throw error; \`\`\`\#\#\# 404s from missing indexFrom the perspective of application code and APIs the SavedObjectsClient is a black box that persists objects. One of the internal details that users have no control over is that we use an elasticsearch index for persistance and that index might be missing.At the time of writing we are in the process of transitioning away from the operating assumption that the SavedObjects index is always available. Part of this transition is handling errors resulting from an index missing. These used to trigger a 500 error in most cases, and in others cause 404s with different error messages.From my (Spencer) perspective, a 404 from the SavedObjectsApi is a 404; The object the request/call was targeting could not be found. This is why \#14141 takes special care to ensure that 404 errors are generic and don't distinguish between index missing or document missing.\#\#\# 503s from missing indexUnlike all other methods, create requests are supposed to succeed even when the Kibana index does not exist because it will be automatically created by elasticsearch. When that is not the case it is because Elasticsearch's action.auto_create_index
setting prevents it from being created automatically so we throw a special 503 with the intention of informing the user that their Elasticsearch settings need to be updated.See [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) See [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) |
+| [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md) | Describes the factory used to create instances of the Saved Objects Client. |
+| [SavedObjectsClientFactoryProvider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) | Provider to invoke to retrieve a [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md). |
+| [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) | Describes the factory used to create instances of Saved Objects Client Wrappers. |
+| [ScopeableRequest](./kibana-plugin-server.scopeablerequest.md) | A user credentials container. It accommodates the necessary auth credentials to impersonate the current user.See [KibanaRequest](./kibana-plugin-server.kibanarequest.md). |
+| [SharedGlobalConfig](./kibana-plugin-server.sharedglobalconfig.md) | |
+| [UiSettingsType](./kibana-plugin-server.uisettingstype.md) | UI element type to represent the settings. |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactory.md b/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactory.md
index 9e30759720680..01c6c6a108b7b 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactory.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactory.md
@@ -1,15 +1,15 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md)
-
-## SavedObjectsClientFactory type
-
-Describes the factory used to create instances of the Saved Objects Client.
-
-Signature:
-
-```typescript
-export declare type SavedObjectsClientFactory = ({ request, }: {
- request: Request;
-}) => SavedObjectsClientContract;
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md)
+
+## SavedObjectsClientFactory type
+
+Describes the factory used to create instances of the Saved Objects Client.
+
+Signature:
+
+```typescript
+export declare type SavedObjectsClientFactory = ({ request, }: {
+ request: KibanaRequest;
+}) => SavedObjectsClientContract;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactoryprovider.md b/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactoryprovider.md
new file mode 100644
index 0000000000000..59617b6be443c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsclientfactoryprovider.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientFactoryProvider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md)
+
+## SavedObjectsClientFactoryProvider type
+
+Provider to invoke to retrieve a [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md).
+
+Signature:
+
+```typescript
+export declare type SavedObjectsClientFactoryProvider = (repositoryFactory: SavedObjectsRepositoryFactory) => SavedObjectsClientFactory;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperfactory.md b/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperfactory.md
index 3ef2fac727b01..f429c92209900 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperfactory.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperfactory.md
@@ -1,13 +1,13 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md)
-
-## SavedObjectsClientWrapperFactory type
-
-Describes the factory used to create instances of Saved Objects Client Wrappers.
-
-Signature:
-
-```typescript
-export declare type SavedObjectsClientWrapperFactory = (options: SavedObjectsClientWrapperOptions) => SavedObjectsClientContract;
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md)
+
+## SavedObjectsClientWrapperFactory type
+
+Describes the factory used to create instances of Saved Objects Client Wrappers.
+
+Signature:
+
+```typescript
+export declare type SavedObjectsClientWrapperFactory = (options: SavedObjectsClientWrapperOptions) => SavedObjectsClientContract;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.md b/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.md
index 65e7cfa64c2a6..dfff863898a2b 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.md
@@ -1,21 +1,21 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md)
-
-## SavedObjectsClientWrapperOptions interface
-
-Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
-
-Signature:
-
-```typescript
-export interface SavedObjectsClientWrapperOptions
-```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [client](./kibana-plugin-server.savedobjectsclientwrapperoptions.client.md) | SavedObjectsClientContract
| |
-| [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md) | Request
| |
-
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md)
+
+## SavedObjectsClientWrapperOptions interface
+
+Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
+
+Signature:
+
+```typescript
+export interface SavedObjectsClientWrapperOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [client](./kibana-plugin-server.savedobjectsclientwrapperoptions.client.md) | SavedObjectsClientContract
| |
+| [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md) | KibanaRequest
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.request.md b/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.request.md
index 0ff75028612d0..89c7e0ed207ff 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.request.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.request.md
@@ -1,11 +1,11 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) > [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md)
-
-## SavedObjectsClientWrapperOptions.request property
-
-Signature:
-
-```typescript
-request: Request;
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) > [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md)
+
+## SavedObjectsClientWrapperOptions.request property
+
+Signature:
+
+```typescript
+request: KibanaRequest;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md
new file mode 100644
index 0000000000000..b808d38793fff
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) > [createInternalRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md)
+
+## SavedObjectsRepositoryFactory.createInternalRepository property
+
+Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch.
+
+Signature:
+
+```typescript
+createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md
new file mode 100644
index 0000000000000..20322d809dce7
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) > [createScopedRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md)
+
+## SavedObjectsRepositoryFactory.createScopedRepository property
+
+Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch.
+
+Signature:
+
+```typescript
+createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.md b/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.md
new file mode 100644
index 0000000000000..fc6c4a516284a
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md)
+
+## SavedObjectsRepositoryFactory interface
+
+Factory provided when invoking a [client factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) See [SavedObjectsServiceSetup.setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md)
+
+Signature:
+
+```typescript
+export interface SavedObjectsRepositoryFactory
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [createInternalRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md) | (extraTypes?: string[]) => ISavedObjectsRepository
| Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch. |
+| [createScopedRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md) | (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository
| Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md
index e787d737ada17..becff5bd2821e 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md
@@ -1,13 +1,13 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md)
-
-## SavedObjectsServiceSetup.addClientWrapper property
-
-Add a client wrapper with the given priority.
-
-Signature:
-
-```typescript
-addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md)
+
+## SavedObjectsServiceSetup.addClientWrapper property
+
+Add a [client wrapper factory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) with the given priority.
+
+Signature:
+
+```typescript
+addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md
deleted file mode 100644
index 492aa1a2453a1..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [createInternalRepository](./kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md)
-
-## SavedObjectsServiceSetup.createInternalRepository property
-
-Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch.
-
-Signature:
-
-```typescript
-createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
-```
-
-## Remarks
-
-The repository should only be used for creating and registering a client factory or client wrapper. Using the repository directly for interacting with Saved Objects is an anti-pattern. Use the Saved Objects client from the [SavedObjectsServiceStart\#getScopedClient](./kibana-plugin-server.savedobjectsservicestart.md) method or the [route handler context](./kibana-plugin-server.requesthandlercontext.md) instead.
-
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md
deleted file mode 100644
index fc5aa40c21a20..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [createScopedRepository](./kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md)
-
-## SavedObjectsServiceSetup.createScopedRepository property
-
-Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch.
-
-Signature:
-
-```typescript
-createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
-```
-
-## Remarks
-
-The repository should only be used for creating and registering a client factory or client wrapper. Using the repository directly for interacting with Saved Objects is an anti-pattern. Use the Saved Objects client from the [SavedObjectsServiceStart\#getScopedClient](./kibana-plugin-server.savedobjectsservicestart.md) method or the [route handler context](./kibana-plugin-server.requesthandlercontext.md) instead.
-
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md
index 95bd817a43da6..64fb1f4a5f638 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md
@@ -1,35 +1,33 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md)
-
-## SavedObjectsServiceSetup interface
-
-Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for creating and registering Saved Object client wrappers.
-
-Signature:
-
-```typescript
-export interface SavedObjectsServiceSetup
-```
-
-## Remarks
-
-Note: The Saved Object setup API's should only be used for creating and registering client wrappers. Constructing a Saved Objects client or repository for use within your own plugin won't have any of the registered wrappers applied and is considered an anti-pattern. Use the Saved Objects client from the [SavedObjectsServiceStart\#getScopedClient](./kibana-plugin-server.savedobjectsservicestart.md) method or the [route handler context](./kibana-plugin-server.requesthandlercontext.md) instead.
-
-When plugins access the Saved Objects client, a new client is created using the factory provided to `setClientFactory` and wrapped by all wrappers registered through `addClientWrapper`. To create a factory or wrapper, plugins will have to construct a Saved Objects client. First create a repository by calling `scopedRepository` or `internalRepository` and then use this repository as the argument to the [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) constructor.
-
-## Example
-
-import {SavedObjectsClient, CoreSetup} from 'src/core/server';
-
-export class Plugin() { setup: (core: CoreSetup) => { core.savedObjects.setClientFactory(({request: KibanaRequest}) => { return new SavedObjectsClient(core.savedObjects.scopedRepository(request)); }) } }
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | (priority: number, id: string, factory: SavedObjectsClientWrapperFactory<KibanaRequest>) => void
| Add a client wrapper with the given priority. |
-| [createInternalRepository](./kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md) | (extraTypes?: string[]) => ISavedObjectsRepository
| Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch. |
-| [createScopedRepository](./kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md) | (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository
| Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. |
-| [setClientFactory](./kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md) | (customClientFactory: SavedObjectsClientFactory<KibanaRequest>) => void
| Set a default factory for creating Saved Objects clients. Only one client factory can be set, subsequent calls to this method will fail. |
-
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md)
+
+## SavedObjectsServiceSetup interface
+
+Saved Objects is Kibana's data persistence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for creating and registering Saved Object client wrappers.
+
+Signature:
+
+```typescript
+export interface SavedObjectsServiceSetup
+```
+
+## Remarks
+
+Note: The Saved Object setup API's should only be used for creating and registering client wrappers. Constructing a Saved Objects client or repository for use within your own plugin won't have any of the registered wrappers applied and is considered an anti-pattern. Use the Saved Objects client from the [SavedObjectsServiceStart\#getScopedClient](./kibana-plugin-server.savedobjectsservicestart.md) method or the [route handler context](./kibana-plugin-server.requesthandlercontext.md) instead.
+
+When plugins access the Saved Objects client, a new client is created using the factory provided to `setClientFactory` and wrapped by all wrappers registered through `addClientWrapper`. To create a factory or wrapper, plugins will have to construct a Saved Objects client. First create a repository by calling `scopedRepository` or `internalRepository` and then use this repository as the argument to the [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) constructor.
+
+## Example
+
+import { SavedObjectsClient, CoreSetup } from 'src/core/server';
+
+export class Plugin() { setup: (core: CoreSetup) => { core.savedObjects.setClientFactory(({ request: KibanaRequest }) => { return new SavedObjectsClient(core.savedObjects.scopedRepository(request)); }) } }
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void
| Add a [client wrapper factory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) with the given priority. |
+| [setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void
| Set the default [factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md
deleted file mode 100644
index 544e0b9d5fa73..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [setClientFactory](./kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md)
-
-## SavedObjectsServiceSetup.setClientFactory property
-
-Set a default factory for creating Saved Objects clients. Only one client factory can be set, subsequent calls to this method will fail.
-
-Signature:
-
-```typescript
-setClientFactory: (customClientFactory: SavedObjectsClientFactory) => void;
-```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md
new file mode 100644
index 0000000000000..ed11255048f19
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md)
+
+## SavedObjectsServiceSetup.setClientFactoryProvider property
+
+Set the default [factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail.
+
+Signature:
+
+```typescript
+setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md
new file mode 100644
index 0000000000000..d639a8bc66b7e
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) > [createInternalRepository](./kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md)
+
+## SavedObjectsServiceStart.createInternalRepository property
+
+Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch.
+
+Signature:
+
+```typescript
+createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md
new file mode 100644
index 0000000000000..7683a9e46c51d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md
@@ -0,0 +1,18 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) > [createScopedRepository](./kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md)
+
+## SavedObjectsServiceStart.createScopedRepository property
+
+Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch.
+
+Signature:
+
+```typescript
+createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
+```
+
+## Remarks
+
+Prefer using `getScopedClient`. This should only be used when using methods not exposed on [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md)
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.md
index 5a869b3b6c1cb..cf2b4f57a7461 100644
--- a/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.md
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.md
@@ -1,20 +1,22 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md)
-
-## SavedObjectsServiceStart interface
-
-Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects.
-
-Signature:
-
-```typescript
-export interface SavedObjectsServiceStart
-```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [getScopedClient](./kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | (req: KibanaRequest, options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract
| Creates a [Saved Objects client](./kibana-plugin-server.savedobjectsclientcontract.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. If other plugins have registered Saved Objects client wrappers, these will be applied to extend the functionality of the client.A client that is already scoped to the incoming request is also exposed from the route handler context see [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md). |
-
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md)
+
+## SavedObjectsServiceStart interface
+
+Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects.
+
+Signature:
+
+```typescript
+export interface SavedObjectsServiceStart
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [createInternalRepository](./kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md) | (extraTypes?: string[]) => ISavedObjectsRepository
| Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch. |
+| [createScopedRepository](./kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md) | (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository
| Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. |
+| [getScopedClient](./kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | (req: KibanaRequest, options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract
| Creates a [Saved Objects client](./kibana-plugin-server.savedobjectsclientcontract.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. If other plugins have registered Saved Objects client wrappers, these will be applied to extend the functionality of the client.A client that is already scoped to the incoming request is also exposed from the route handler context see [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md). |
+
diff --git a/src/core/server/elasticsearch/retry_call_cluster.ts b/src/core/server/elasticsearch/retry_call_cluster.ts
index 89d7b88b1675a..bd72ecf726461 100644
--- a/src/core/server/elasticsearch/retry_call_cluster.ts
+++ b/src/core/server/elasticsearch/retry_call_cluster.ts
@@ -22,6 +22,7 @@ import { defer, throwError, iif, timer } from 'rxjs';
import * as legacyElasticsearch from 'elasticsearch';
import { CallAPIOptions } from '.';
+import { APICaller } from './api_types';
import { Logger } from '../logging';
const esErrors = legacyElasticsearch.errors;
@@ -34,15 +35,11 @@ const esErrors = legacyElasticsearch.errors;
* different error is received.
*
* @param apiCaller
+ * @param log
+ * @param delay
*/
-
-// TODO: Replace with APICaller from './scoped_cluster_client' once #46668 is merged
export function migrationsRetryCallCluster(
- apiCaller: (
- endpoint: string,
- clientParams: Record,
- options?: CallAPIOptions
- ) => Promise,
+ apiCaller: APICaller,
log: Logger,
delay: number = 2500
) {
diff --git a/src/core/server/index.ts b/src/core/server/index.ts
index a97d2970dca88..cdc2ec91134ed 100644
--- a/src/core/server/index.ts
+++ b/src/core/server/index.ts
@@ -180,6 +180,7 @@ export {
SavedObjectsClientWrapperFactory,
SavedObjectsClientWrapperOptions,
SavedObjectsClientFactory,
+ SavedObjectsClientFactoryProvider,
SavedObjectsCreateOptions,
SavedObjectsErrorHelpers,
SavedObjectsExportOptions,
@@ -195,6 +196,7 @@ export {
SavedObjectsImportUnsupportedTypeError,
SavedObjectsMigrationLogger,
SavedObjectsRawDoc,
+ SavedObjectsRepositoryFactory,
SavedObjectsResolveImportErrorsOptions,
SavedObjectsSchema,
SavedObjectsSerializer,
diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts
index 7862412fbad06..ca1204f0ac05c 100644
--- a/src/core/server/legacy/legacy_service.ts
+++ b/src/core/server/legacy/legacy_service.ts
@@ -258,7 +258,11 @@ export class LegacyService implements CoreService {
) {
const coreStart: CoreStart = {
capabilities: startDeps.core.capabilities,
- savedObjects: { getScopedClient: startDeps.core.savedObjects.getScopedClient },
+ savedObjects: {
+ getScopedClient: startDeps.core.savedObjects.getScopedClient,
+ createScopedRepository: startDeps.core.savedObjects.createScopedRepository,
+ createInternalRepository: startDeps.core.savedObjects.createInternalRepository,
+ },
uiSettings: { asScopedToClient: startDeps.core.uiSettings.asScopedToClient },
};
@@ -286,10 +290,8 @@ export class LegacyService implements CoreService {
isTlsEnabled: setupDeps.core.http.isTlsEnabled,
},
savedObjects: {
- setClientFactory: setupDeps.core.savedObjects.setClientFactory,
+ setClientFactoryProvider: setupDeps.core.savedObjects.setClientFactoryProvider,
addClientWrapper: setupDeps.core.savedObjects.addClientWrapper,
- createInternalRepository: setupDeps.core.savedObjects.createInternalRepository,
- createScopedRepository: setupDeps.core.savedObjects.createScopedRepository,
},
uiSettings: {
register: setupDeps.core.uiSettings.register,
diff --git a/src/core/server/plugins/plugin_context.ts b/src/core/server/plugins/plugin_context.ts
index f266172cb4bd9..99cd4eda7374c 100644
--- a/src/core/server/plugins/plugin_context.ts
+++ b/src/core/server/plugins/plugin_context.ts
@@ -165,10 +165,8 @@ export function createPluginSetupContext(
isTlsEnabled: deps.http.isTlsEnabled,
},
savedObjects: {
- setClientFactory: deps.savedObjects.setClientFactory,
+ setClientFactoryProvider: deps.savedObjects.setClientFactoryProvider,
addClientWrapper: deps.savedObjects.addClientWrapper,
- createInternalRepository: deps.savedObjects.createInternalRepository,
- createScopedRepository: deps.savedObjects.createScopedRepository,
},
uiSettings: {
register: deps.uiSettings.register,
@@ -203,6 +201,8 @@ export function createPluginStartContext(
},
savedObjects: {
getScopedClient: deps.savedObjects.getScopedClient,
+ createInternalRepository: deps.savedObjects.createInternalRepository,
+ createScopedRepository: deps.savedObjects.createScopedRepository,
},
uiSettings: {
asScopedToClient: deps.uiSettings.asScopedToClient,
diff --git a/src/core/server/saved_objects/index.ts b/src/core/server/saved_objects/index.ts
index 1100c18bcc72f..181025d73817d 100644
--- a/src/core/server/saved_objects/index.ts
+++ b/src/core/server/saved_objects/index.ts
@@ -41,6 +41,7 @@ export {
SavedObjectsServiceStart,
SavedObjectsServiceSetup,
InternalSavedObjectsServiceSetup,
+ SavedObjectsRepositoryFactory,
} from './saved_objects_service';
export {
diff --git a/src/core/server/saved_objects/saved_objects_service.mock.ts b/src/core/server/saved_objects/saved_objects_service.mock.ts
index b2596146a02d4..a15d1f5b864b7 100644
--- a/src/core/server/saved_objects/saved_objects_service.mock.ts
+++ b/src/core/server/saved_objects/saved_objects_service.mock.ts
@@ -33,29 +33,27 @@ const createStartContractMock = () => {
const startContract: jest.Mocked = {
clientProvider: savedObjectsClientProviderMock.create(),
getScopedClient: jest.fn(),
+ createInternalRepository: jest.fn(),
+ createScopedRepository: jest.fn(),
migrator: mockKibanaMigrator.create(),
};
+ startContract.getScopedClient.mockReturnValue(savedObjectsClientMock.create());
+ startContract.createInternalRepository.mockReturnValue(savedObjectsRepositoryMock.create());
+ startContract.createScopedRepository.mockReturnValue(savedObjectsRepositoryMock.create());
+
return startContract;
};
const createSetupContractMock = () => {
const setupContract: jest.Mocked = {
- getScopedClient: jest.fn(),
- setClientFactory: jest.fn(),
+ setClientFactoryProvider: jest.fn(),
addClientWrapper: jest.fn(),
- createInternalRepository: jest.fn(),
- createScopedRepository: jest.fn(),
};
-
- setupContract.getScopedClient.mockReturnValue(savedObjectsClientMock.create());
- setupContract.createInternalRepository.mockReturnValue(savedObjectsRepositoryMock.create());
- setupContract.createScopedRepository.mockReturnValue(savedObjectsRepositoryMock.create());
-
return setupContract;
};
-const createsavedObjectsServiceMock = () => {
+const createSavedObjectsServiceMock = () => {
const mocked: jest.Mocked = {
setup: jest.fn(),
start: jest.fn(),
@@ -69,7 +67,7 @@ const createsavedObjectsServiceMock = () => {
};
export const savedObjectsServiceMock = {
- create: createsavedObjectsServiceMock,
+ create: createSavedObjectsServiceMock,
createSetupContract: createSetupContractMock,
createStartContract: createStartContractMock,
};
diff --git a/src/core/server/saved_objects/saved_objects_service.test.mocks.ts b/src/core/server/saved_objects/saved_objects_service.test.mocks.ts
new file mode 100644
index 0000000000000..a9ad0778d4757
--- /dev/null
+++ b/src/core/server/saved_objects/saved_objects_service.test.mocks.ts
@@ -0,0 +1,32 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { mockKibanaMigrator } from './migrations/kibana/kibana_migrator.mock';
+import { savedObjectsClientProviderMock } from './service/lib/scoped_client_provider.mock';
+
+export const migratorInstanceMock = mockKibanaMigrator.create();
+export const KibanaMigratorMock = jest.fn().mockImplementation(() => migratorInstanceMock);
+jest.doMock('./migrations/kibana/kibana_migrator', () => ({
+ KibanaMigrator: KibanaMigratorMock,
+}));
+
+export const clientProviderInstanceMock = savedObjectsClientProviderMock.create();
+jest.doMock('./service/lib/scoped_client_provider', () => ({
+ SavedObjectsClientProvider: jest.fn().mockImplementation(() => clientProviderInstanceMock),
+}));
diff --git a/src/core/server/saved_objects/saved_objects_service.test.ts b/src/core/server/saved_objects/saved_objects_service.test.ts
index deb6f98e17b7b..6668d57045a95 100644
--- a/src/core/server/saved_objects/saved_objects_service.test.ts
+++ b/src/core/server/saved_objects/saved_objects_service.test.ts
@@ -17,95 +17,149 @@
* under the License.
*/
-jest.mock('./migrations/kibana/kibana_migrator');
+import {
+ KibanaMigratorMock,
+ migratorInstanceMock,
+ clientProviderInstanceMock,
+} from './saved_objects_service.test.mocks';
-import { SavedObjectsService, SavedObjectsSetupDeps } from './saved_objects_service';
+import { SavedObjectsService } from './saved_objects_service';
import { mockCoreContext } from '../core_context.mock';
-// @ts-ignore Typescript doesn't know about the jest mock
-import { KibanaMigrator, mockKibanaMigratorInstance } from './migrations/kibana/kibana_migrator';
import * as legacyElasticsearch from 'elasticsearch';
import { Env } from '../config';
import { configServiceMock } from '../mocks';
-
-afterEach(() => {
- jest.clearAllMocks();
-});
+import { elasticsearchServiceMock } from '../elasticsearch/elasticsearch_service.mock';
+import { legacyServiceMock } from '../legacy/legacy_service.mock';
+import { SavedObjectsClientFactoryProvider } from './service/lib';
describe('SavedObjectsService', () => {
+ const createSetupDeps = () => {
+ return {
+ elasticsearch: elasticsearchServiceMock.createInternalSetup(),
+ legacyPlugins: legacyServiceMock.createDiscoverPlugins(),
+ };
+ };
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
describe('#setup()', () => {
+ describe('#setClientFactoryProvider', () => {
+ it('registers the factory to the clientProvider', async () => {
+ const coreContext = mockCoreContext.create();
+ const soService = new SavedObjectsService(coreContext);
+ const setup = await soService.setup(createSetupDeps());
+
+ const factory = jest.fn();
+ const factoryProvider: SavedObjectsClientFactoryProvider = () => factory;
+
+ setup.setClientFactoryProvider(factoryProvider);
+
+ await soService.start({});
+
+ expect(clientProviderInstanceMock.setClientFactory).toHaveBeenCalledWith(factory);
+ });
+ it('throws if a factory is already registered', async () => {
+ const coreContext = mockCoreContext.create();
+ const soService = new SavedObjectsService(coreContext);
+ const setup = await soService.setup(createSetupDeps());
+
+ const firstFactory = () => jest.fn();
+ const secondFactory = () => jest.fn();
+
+ setup.setClientFactoryProvider(firstFactory);
+
+ expect(() => {
+ setup.setClientFactoryProvider(secondFactory);
+ }).toThrowErrorMatchingInlineSnapshot(
+ `"custom client factory is already set, and can only be set once"`
+ );
+ });
+ });
+
+ describe('#addClientWrapper', () => {
+ it('registers the wrapper to the clientProvider', async () => {
+ const coreContext = mockCoreContext.create();
+ const soService = new SavedObjectsService(coreContext);
+ const setup = await soService.setup(createSetupDeps());
+
+ const wrapperA = jest.fn();
+ const wrapperB = jest.fn();
+
+ setup.addClientWrapper(1, 'A', wrapperA);
+ setup.addClientWrapper(2, 'B', wrapperB);
+
+ await soService.start({});
+
+ expect(clientProviderInstanceMock.addClientWrapperFactory).toHaveBeenCalledTimes(2);
+ expect(clientProviderInstanceMock.addClientWrapperFactory).toHaveBeenCalledWith(
+ 1,
+ 'A',
+ wrapperA
+ );
+ expect(clientProviderInstanceMock.addClientWrapperFactory).toHaveBeenCalledWith(
+ 2,
+ 'B',
+ wrapperB
+ );
+ });
+ });
+ });
+
+ describe('#start()', () => {
it('creates a KibanaMigrator which retries NoConnections errors from callAsInternalUser', async () => {
const coreContext = mockCoreContext.create();
- let i = 0;
- const clusterClient = {
- callAsInternalUser: jest
- .fn()
- .mockImplementation(() =>
- i++ <= 2
- ? Promise.reject(new legacyElasticsearch.errors.NoConnections())
- : Promise.resolve('success')
- ),
- };
const soService = new SavedObjectsService(coreContext);
- const coreSetup = ({
- elasticsearch: { adminClient: clusterClient },
- legacyPlugins: { uiExports: { savedObjectMappings: [] }, pluginExtendedConfig: {} },
- } as unknown) as SavedObjectsSetupDeps;
+ const coreSetup = createSetupDeps();
+
+ let i = 0;
+ coreSetup.elasticsearch.adminClient.callAsInternalUser = jest
+ .fn()
+ .mockImplementation(() =>
+ i++ <= 2
+ ? Promise.reject(new legacyElasticsearch.errors.NoConnections())
+ : Promise.resolve('success')
+ );
- await soService.setup(coreSetup, 1);
+ await soService.setup(coreSetup);
+ await soService.start({}, 1);
- return expect((KibanaMigrator as jest.Mock).mock.calls[0][0].callCluster()).resolves.toMatch(
- 'success'
- );
+ return expect(KibanaMigratorMock.mock.calls[0][0].callCluster()).resolves.toMatch('success');
});
- });
- describe('#start()', () => {
it('skips KibanaMigrator migrations when --optimize=true', async () => {
const coreContext = mockCoreContext.create({
env: ({ cliArgs: { optimize: true }, packageInfo: { version: 'x.x.x' } } as unknown) as Env,
});
const soService = new SavedObjectsService(coreContext);
- const coreSetup = ({
- elasticsearch: { adminClient: { callAsInternalUser: jest.fn() } },
- legacyPlugins: { uiExports: {}, pluginExtendedConfig: {} },
- } as unknown) as SavedObjectsSetupDeps;
- await soService.setup(coreSetup);
+ await soService.setup(createSetupDeps());
await soService.start({});
- expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledWith(true);
+ expect(migratorInstanceMock.runMigrations).toHaveBeenCalledWith(true);
});
it('skips KibanaMigrator migrations when migrations.skip=true', async () => {
const configService = configServiceMock.create({ atPath: { skip: true } });
const coreContext = mockCoreContext.create({ configService });
const soService = new SavedObjectsService(coreContext);
- const coreSetup = ({
- elasticsearch: { adminClient: { callAsInternalUser: jest.fn() } },
- legacyPlugins: { uiExports: {}, pluginExtendedConfig: {} },
- } as unknown) as SavedObjectsSetupDeps;
-
- await soService.setup(coreSetup);
+ await soService.setup(createSetupDeps());
await soService.start({});
- expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledWith(true);
+ expect(migratorInstanceMock.runMigrations).toHaveBeenCalledWith(true);
});
it('resolves with KibanaMigrator after waiting for migrations to complete', async () => {
const configService = configServiceMock.create({ atPath: { skip: false } });
const coreContext = mockCoreContext.create({ configService });
const soService = new SavedObjectsService(coreContext);
- const coreSetup = ({
- elasticsearch: { adminClient: { callAsInternalUser: jest.fn() } },
- legacyPlugins: { uiExports: {}, pluginExtendedConfig: {} },
- } as unknown) as SavedObjectsSetupDeps;
-
- await soService.setup(coreSetup);
- expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledTimes(0);
+ await soService.setup(createSetupDeps());
+ expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(0);
const startContract = await soService.start({});
- expect(startContract.migrator).toBe(mockKibanaMigratorInstance);
- expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledWith(false);
- expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledTimes(1);
+ expect(startContract.migrator).toBe(migratorInstanceMock);
+ expect(migratorInstanceMock.runMigrations).toHaveBeenCalledWith(false);
+ expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(1);
});
});
});
diff --git a/src/core/server/saved_objects/saved_objects_service.ts b/src/core/server/saved_objects/saved_objects_service.ts
index 69ca8306ca4da..b08033a19242b 100644
--- a/src/core/server/saved_objects/saved_objects_service.ts
+++ b/src/core/server/saved_objects/saved_objects_service.ts
@@ -37,13 +37,17 @@ import { KibanaRequest } from '../http';
import { SavedObjectsClientContract } from './types';
import { ISavedObjectsRepository, SavedObjectsRepository } from './service/lib/repository';
import {
- SavedObjectsClientFactory,
+ SavedObjectsClientFactoryProvider,
SavedObjectsClientWrapperFactory,
} from './service/lib/scoped_client_provider';
-import { Logger } from '..';
+import { Logger } from '../logging';
+import { SavedObjectsMapping } from './mappings';
+import { MigrationDefinition } from './migrations/core/document_migrator';
+import { SavedObjectsSchemaDefinition } from './schema';
+import { PropertyValidators } from './validation';
/**
- * Saved Objects is Kibana's data persisentence mechanism allowing plugins to
+ * Saved Objects is Kibana's data persistence mechanism allowing plugins to
* use Elasticsearch for storing and querying state. The
* SavedObjectsServiceSetup API exposes methods for creating and registering
* Saved Object client wrappers.
@@ -66,11 +70,11 @@ import { Logger } from '..';
* constructor.
*
* @example
- * import {SavedObjectsClient, CoreSetup} from 'src/core/server';
+ * import { SavedObjectsClient, CoreSetup } from 'src/core/server';
*
* export class Plugin() {
* setup: (core: CoreSetup) => {
- * core.savedObjects.setClientFactory(({request: KibanaRequest}) => {
+ * core.savedObjects.setClientFactory(({ request: KibanaRequest }) => {
* return new SavedObjectsClient(core.savedObjects.scopedRepository(request));
* })
* }
@@ -80,61 +84,25 @@ import { Logger } from '..';
*/
export interface SavedObjectsServiceSetup {
/**
- * Set a default factory for creating Saved Objects clients. Only one client
- * factory can be set, subsequent calls to this method will fail.
+ * Set the default {@link SavedObjectsClientFactoryProvider | factory provider} for creating Saved Objects clients.
+ * Only one provider can be set, subsequent calls to this method will fail.
*/
- setClientFactory: (customClientFactory: SavedObjectsClientFactory) => void;
+ setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
/**
- * Add a client wrapper with the given priority.
+ * Add a {@link SavedObjectsClientWrapperFactory | client wrapper factory} with the given priority.
*/
addClientWrapper: (
priority: number,
id: string,
- factory: SavedObjectsClientWrapperFactory
+ factory: SavedObjectsClientWrapperFactory
) => void;
-
- /**
- * Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
- * uses the credentials from the passed in request to authenticate with
- * Elasticsearch.
- *
- * @remarks
- * The repository should only be used for creating and registering a client
- * factory or client wrapper. Using the repository directly for interacting
- * with Saved Objects is an anti-pattern. Use the Saved Objects client from
- * the
- * {@link SavedObjectsServiceStart | SavedObjectsServiceStart#getScopedClient }
- * method or the {@link RequestHandlerContext | route handler context}
- * instead.
- */
- createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
-
- /**
- * Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
- * uses the internal Kibana user for authenticating with Elasticsearch.
- *
- * @remarks
- * The repository should only be used for creating and registering a client
- * factory or client wrapper. Using the repository directly for interacting
- * with Saved Objects is an anti-pattern. Use the Saved Objects client from
- * the
- * {@link SavedObjectsServiceStart | SavedObjectsServiceStart#getScopedClient }
- * method or the {@link RequestHandlerContext | route handler context}
- * instead.
- */
- createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
}
/**
* @internal
*/
-export interface InternalSavedObjectsServiceSetup extends SavedObjectsServiceSetup {
- getScopedClient: (
- req: KibanaRequest,
- options?: SavedObjectsClientProviderOptions
- ) => SavedObjectsClientContract;
-}
+export type InternalSavedObjectsServiceSetup = SavedObjectsServiceSetup;
/**
* Saved Objects is Kibana's data persisentence mechanism allowing plugins to
@@ -158,6 +126,26 @@ export interface SavedObjectsServiceStart {
req: KibanaRequest,
options?: SavedObjectsClientProviderOptions
) => SavedObjectsClientContract;
+ /**
+ * Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
+ * uses the credentials from the passed in request to authenticate with
+ * Elasticsearch.
+ *
+ * @param req - The request to create the scoped repository from.
+ * @param extraTypes - A list of additional hidden types the repository should have access to.
+ *
+ * @remarks
+ * Prefer using `getScopedClient`. This should only be used when using methods
+ * not exposed on {@link SavedObjectsClientContract}
+ */
+ createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
+ /**
+ * Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
+ * uses the internal Kibana user for authenticating with Elasticsearch.
+ *
+ * @param extraTypes - A list of additional hidden types the repository should have access to.
+ */
+ createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
}
export interface InternalSavedObjectsServiceStart extends SavedObjectsServiceStart {
@@ -171,130 +159,200 @@ export interface InternalSavedObjectsServiceStart extends SavedObjectsServiceSta
clientProvider: ISavedObjectsClientProvider;
}
+/**
+ * Factory provided when invoking a {@link SavedObjectsClientFactoryProvider | client factory provider}
+ * See {@link SavedObjectsServiceSetup.setClientFactoryProvider}
+ *
+ * @public
+ */
+export interface SavedObjectsRepositoryFactory {
+ /**
+ * Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
+ * uses the credentials from the passed in request to authenticate with
+ * Elasticsearch.
+ *
+ * @param extraTypes - A list of additional hidden types the repository should have access to.
+ */
+ createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
+ /**
+ * Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
+ * uses the internal Kibana user for authenticating with Elasticsearch.
+ *
+ * @param extraTypes - A list of additional hidden types the repository should have access to.
+ */
+ createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
+}
+
/** @internal */
export interface SavedObjectsSetupDeps {
legacyPlugins: LegacyServiceDiscoverPlugins;
elasticsearch: InternalElasticsearchServiceSetup;
}
+interface WrappedClientFactoryWrapper {
+ priority: number;
+ id: string;
+ factory: SavedObjectsClientWrapperFactory;
+}
+
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SavedObjectsStartDeps {}
export class SavedObjectsService
implements CoreService {
- private migrator: KibanaMigrator | undefined;
private logger: Logger;
- private clientProvider: ISavedObjectsClientProvider | undefined;
+
+ private setupDeps?: SavedObjectsSetupDeps;
+ private clientFactoryProvider?: SavedObjectsClientFactoryProvider;
+ private clientFactoryWrappers: WrappedClientFactoryWrapper[] = [];
+
+ private mappings: SavedObjectsMapping[] = [];
+ private migrations: MigrationDefinition = {};
+ private schemas: SavedObjectsSchemaDefinition = {};
+ private validations: PropertyValidators = {};
constructor(private readonly coreContext: CoreContext) {
this.logger = coreContext.logger.get('savedobjects-service');
}
- public async setup(
- setupDeps: SavedObjectsSetupDeps,
- migrationsRetryDelay?: number
- ): Promise {
+ public async setup(setupDeps: SavedObjectsSetupDeps): Promise {
this.logger.debug('Setting up SavedObjects service');
+ this.setupDeps = setupDeps;
+
const {
savedObjectSchemas: savedObjectsSchemasDefinition,
savedObjectMappings,
savedObjectMigrations,
savedObjectValidations,
} = setupDeps.legacyPlugins.uiExports;
+ this.mappings = savedObjectMappings;
+ this.migrations = savedObjectMigrations;
+ this.schemas = savedObjectsSchemasDefinition;
+ this.validations = savedObjectValidations;
- const savedObjectSchemas = new SavedObjectsSchema(savedObjectsSchemasDefinition);
+ return {
+ setClientFactoryProvider: provider => {
+ if (this.clientFactoryProvider) {
+ throw new Error('custom client factory is already set, and can only be set once');
+ }
+ this.clientFactoryProvider = provider;
+ },
+ addClientWrapper: (priority, id, factory) => {
+ this.clientFactoryWrappers.push({
+ priority,
+ id,
+ factory,
+ });
+ },
+ };
+ }
+
+ public async start(
+ core: SavedObjectsStartDeps,
+ migrationsRetryDelay?: number
+ ): Promise {
+ if (!this.setupDeps) {
+ throw new Error('#setup() needs to be run first');
+ }
+
+ this.logger.debug('Starting SavedObjects service');
const kibanaConfig = await this.coreContext.configService
.atPath('kibana')
.pipe(first())
.toPromise();
-
const savedObjectsConfig = await this.coreContext.configService
.atPath('migrations')
.pipe(first())
.toPromise();
+ const adminClient = this.setupDeps!.elasticsearch.adminClient;
+ const migrator = this.createMigrator(kibanaConfig, savedObjectsConfig, migrationsRetryDelay);
- const adminClient = setupDeps.elasticsearch.adminClient;
+ /**
+ * Note: We want to ensure that migrations have completed before
+ * continuing with further Core start steps that might use SavedObjects
+ * such as running the legacy server, legacy plugins and allowing incoming
+ * HTTP requests.
+ *
+ * However, our build system optimize step and some tests depend on the
+ * HTTP server running without an Elasticsearch server being available.
+ * So, when the `migrations.skip` is true, we skip migrations altogether.
+ */
+ const cliArgs = this.coreContext.env.cliArgs;
+ const skipMigrations = cliArgs.optimize || savedObjectsConfig.skip;
- const migrator = (this.migrator = new KibanaMigrator({
- savedObjectSchemas,
- savedObjectMappings,
- savedObjectMigrations,
- savedObjectValidations,
- logger: this.coreContext.logger.get('migrations'),
- kibanaVersion: this.coreContext.env.packageInfo.version,
- config: setupDeps.legacyPlugins.pluginExtendedConfig,
- savedObjectsConfig,
- kibanaConfig,
- callCluster: migrationsRetryCallCluster(
- adminClient.callAsInternalUser,
- this.coreContext.logger.get('migrations'),
- migrationsRetryDelay
- ),
- }));
+ this.logger.debug('Starting saved objects migration');
+ await migrator.runMigrations(skipMigrations);
+ this.logger.debug('Saved objects migration completed');
- const createSORepository = (callCluster: APICaller, extraTypes: string[] = []) => {
+ const createRepository = (callCluster: APICaller, extraTypes: string[] = []) => {
return SavedObjectsRepository.createRepository(
migrator,
- savedObjectSchemas,
- setupDeps.legacyPlugins.pluginExtendedConfig,
+ new SavedObjectsSchema(this.schemas),
+ this.setupDeps!.legacyPlugins.pluginExtendedConfig,
kibanaConfig.index,
callCluster,
extraTypes
);
};
- this.clientProvider = new SavedObjectsClientProvider({
+ const repositoryFactory: SavedObjectsRepositoryFactory = {
+ createInternalRepository: (extraTypes?: string[]) =>
+ createRepository(adminClient.callAsInternalUser, extraTypes),
+ createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) =>
+ createRepository(adminClient.asScoped(req).callAsCurrentUser, extraTypes),
+ };
+
+ const clientProvider = new SavedObjectsClientProvider({
defaultClientFactory({ request }) {
- const repository = createSORepository(adminClient.asScoped(request).callAsCurrentUser);
+ const repository = repositoryFactory.createScopedRepository(request);
return new SavedObjectsClient(repository);
},
});
+ if (this.clientFactoryProvider) {
+ const clientFactory = this.clientFactoryProvider(repositoryFactory);
+ clientProvider.setClientFactory(clientFactory);
+ }
+ this.clientFactoryWrappers.forEach(({ id, factory, priority }) => {
+ clientProvider.addClientWrapperFactory(priority, id, factory);
+ });
return {
- getScopedClient: this.clientProvider.getClient.bind(this.clientProvider),
- setClientFactory: this.clientProvider.setClientFactory.bind(this.clientProvider),
- addClientWrapper: this.clientProvider.addClientWrapperFactory.bind(this.clientProvider),
- createInternalRepository: (extraTypes?: string[]) =>
- createSORepository(adminClient.callAsInternalUser, extraTypes),
- createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) =>
- createSORepository(adminClient.asScoped(req).callAsCurrentUser, extraTypes),
+ migrator,
+ clientProvider,
+ getScopedClient: clientProvider.getClient.bind(clientProvider),
+ createScopedRepository: repositoryFactory.createScopedRepository,
+ createInternalRepository: repositoryFactory.createInternalRepository,
};
}
- public async start(core: SavedObjectsStartDeps): Promise {
- if (!this.clientProvider) {
- throw new Error('#setup() needs to be run first');
- }
-
- this.logger.debug('Starting SavedObjects service');
+ public async stop() {}
- /**
- * Note: We want to ensure that migrations have completed before
- * continuing with further Core startup steps that might use SavedObjects
- * such as running the legacy server, legacy plugins and allowing incoming
- * HTTP requests.
- *
- * However, our build system optimize step and some tests depend on the
- * HTTP server running without an Elasticsearch server being available.
- * So, when the `migrations.skip` is true, we skip migrations altogether.
- */
- const cliArgs = this.coreContext.env.cliArgs;
- const savedObjectsConfig = await this.coreContext.configService
- .atPath('migrations')
- .pipe(first())
- .toPromise();
- const skipMigrations = cliArgs.optimize || savedObjectsConfig.skip;
- await this.migrator!.runMigrations(skipMigrations);
+ private createMigrator(
+ kibanaConfig: KibanaConfigType,
+ savedObjectsConfig: SavedObjectsConfigType,
+ migrationsRetryDelay?: number
+ ): KibanaMigrator {
+ const savedObjectSchemas = new SavedObjectsSchema(this.schemas);
+ const adminClient = this.setupDeps!.elasticsearch.adminClient;
- return {
- migrator: this.migrator!,
- clientProvider: this.clientProvider,
- getScopedClient: this.clientProvider.getClient.bind(this.clientProvider),
- };
+ return new KibanaMigrator({
+ savedObjectSchemas,
+ savedObjectMappings: this.mappings,
+ savedObjectMigrations: this.migrations,
+ savedObjectValidations: this.validations,
+ logger: this.coreContext.logger.get('migrations'),
+ kibanaVersion: this.coreContext.env.packageInfo.version,
+ config: this.setupDeps!.legacyPlugins.pluginExtendedConfig,
+ savedObjectsConfig,
+ kibanaConfig,
+ callCluster: migrationsRetryCallCluster(
+ adminClient.callAsInternalUser,
+ this.coreContext.logger.get('migrations'),
+ migrationsRetryDelay
+ ),
+ });
}
-
- public async stop() {}
}
diff --git a/src/core/server/saved_objects/service/index.ts b/src/core/server/saved_objects/service/index.ts
index f50ee1759dad7..9f625b4732e26 100644
--- a/src/core/server/saved_objects/service/index.ts
+++ b/src/core/server/saved_objects/service/index.ts
@@ -29,13 +29,11 @@ import { SavedObjectsResolveImportErrorsOptions } from '../import/types';
* @internal
* @deprecated
*/
-export interface SavedObjectsLegacyService {
+export interface SavedObjectsLegacyService {
// ATTENTION: these types are incomplete
- addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider<
- Request
- >['addClientWrapperFactory'];
- setScopedSavedObjectsClientFactory: SavedObjectsClientProvider['setClientFactory'];
- getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
+ addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider['addClientWrapperFactory'];
+ setScopedSavedObjectsClientFactory: SavedObjectsClientProvider['setClientFactory'];
+ getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
SavedObjectsClient: typeof SavedObjectsClient;
types: string[];
schema: SavedObjectsSchema;
@@ -59,6 +57,7 @@ export {
SavedObjectsClientWrapperOptions,
SavedObjectsErrorHelpers,
SavedObjectsClientFactory,
+ SavedObjectsClientFactoryProvider,
} from './lib';
export * from './saved_objects_client';
diff --git a/src/core/server/saved_objects/service/lib/index.ts b/src/core/server/saved_objects/service/lib/index.ts
index c26128acc5050..e103120388e35 100644
--- a/src/core/server/saved_objects/service/lib/index.ts
+++ b/src/core/server/saved_objects/service/lib/index.ts
@@ -26,6 +26,7 @@ export {
SavedObjectsClientProvider,
SavedObjectsClientProviderOptions,
SavedObjectsClientFactory,
+ SavedObjectsClientFactoryProvider,
} from './scoped_client_provider';
export { SavedObjectsErrorHelpers } from './errors';
diff --git a/src/core/server/saved_objects/service/lib/scoped_client_provider.ts b/src/core/server/saved_objects/service/lib/scoped_client_provider.ts
index 42f75e2517126..8aadc4f57317c 100644
--- a/src/core/server/saved_objects/service/lib/scoped_client_provider.ts
+++ b/src/core/server/saved_objects/service/lib/scoped_client_provider.ts
@@ -18,34 +18,44 @@
*/
import { PriorityCollection } from './priority_collection';
import { SavedObjectsClientContract } from '../../types';
+import { SavedObjectsRepositoryFactory } from '../../saved_objects_service';
+import { KibanaRequest } from '../../../http';
/**
* Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
* @public
*/
-export interface SavedObjectsClientWrapperOptions {
+export interface SavedObjectsClientWrapperOptions {
client: SavedObjectsClientContract;
- request: Request;
+ request: KibanaRequest;
}
/**
* Describes the factory used to create instances of Saved Objects Client Wrappers.
* @public
*/
-export type SavedObjectsClientWrapperFactory = (
- options: SavedObjectsClientWrapperOptions
+export type SavedObjectsClientWrapperFactory = (
+ options: SavedObjectsClientWrapperOptions
) => SavedObjectsClientContract;
/**
* Describes the factory used to create instances of the Saved Objects Client.
* @public
*/
-export type SavedObjectsClientFactory = ({
+export type SavedObjectsClientFactory = ({
request,
}: {
- request: Request;
+ request: KibanaRequest;
}) => SavedObjectsClientContract;
+/**
+ * Provider to invoke to retrieve a {@link SavedObjectsClientFactory}.
+ * @public
+ */
+export type SavedObjectsClientFactoryProvider = (
+ repositoryFactory: SavedObjectsRepositoryFactory
+) => SavedObjectsClientFactory;
+
/**
* Options to control the creation of the Saved Objects Client.
* @public
@@ -57,8 +67,8 @@ export interface SavedObjectsClientProviderOptions {
/**
* @internal
*/
-export type ISavedObjectsClientProvider = Pick<
- SavedObjectsClientProvider,
+export type ISavedObjectsClientProvider = Pick<
+ SavedObjectsClientProvider,
keyof SavedObjectsClientProvider
>;
@@ -67,26 +77,22 @@ export type ISavedObjectsClientProvider = Pick<
*
* @internal
*/
-export class SavedObjectsClientProvider {
+export class SavedObjectsClientProvider {
private readonly _wrapperFactories = new PriorityCollection<{
id: string;
- factory: SavedObjectsClientWrapperFactory;
+ factory: SavedObjectsClientWrapperFactory;
}>();
- private _clientFactory: SavedObjectsClientFactory;
- private readonly _originalClientFactory: SavedObjectsClientFactory;
-
- constructor({
- defaultClientFactory,
- }: {
- defaultClientFactory: SavedObjectsClientFactory;
- }) {
+ private _clientFactory: SavedObjectsClientFactory;
+ private readonly _originalClientFactory: SavedObjectsClientFactory;
+
+ constructor({ defaultClientFactory }: { defaultClientFactory: SavedObjectsClientFactory }) {
this._originalClientFactory = this._clientFactory = defaultClientFactory;
}
addClientWrapperFactory(
priority: number,
id: string,
- factory: SavedObjectsClientWrapperFactory
+ factory: SavedObjectsClientWrapperFactory
): void {
if (this._wrapperFactories.has(entry => entry.id === id)) {
throw new Error(`wrapper factory with id ${id} is already defined`);
@@ -95,7 +101,7 @@ export class SavedObjectsClientProvider {
this._wrapperFactories.add(priority, { id, factory });
}
- setClientFactory(customClientFactory: SavedObjectsClientFactory) {
+ setClientFactory(customClientFactory: SavedObjectsClientFactory) {
if (this._clientFactory !== this._originalClientFactory) {
throw new Error(`custom client factory is already set, unable to replace the current one`);
}
@@ -104,7 +110,7 @@ export class SavedObjectsClientProvider {
}
getClient(
- request: Request,
+ request: KibanaRequest,
options: SavedObjectsClientProviderOptions = {}
): SavedObjectsClientContract {
const client = this._clientFactory({
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index aa9ed8ecdbd40..060587448642f 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -1498,10 +1498,13 @@ export class SavedObjectsClient {
export type SavedObjectsClientContract = Pick;
// @public
-export type SavedObjectsClientFactory = ({ request, }: {
- request: Request;
+export type SavedObjectsClientFactory = ({ request, }: {
+ request: KibanaRequest;
}) => SavedObjectsClientContract;
+// @public
+export type SavedObjectsClientFactoryProvider = (repositoryFactory: SavedObjectsRepositoryFactory) => SavedObjectsClientFactory;
+
// @public
export interface SavedObjectsClientProviderOptions {
// (undocumented)
@@ -1509,14 +1512,14 @@ export interface SavedObjectsClientProviderOptions {
}
// @public
-export type SavedObjectsClientWrapperFactory = (options: SavedObjectsClientWrapperOptions) => SavedObjectsClientContract;
+export type SavedObjectsClientWrapperFactory = (options: SavedObjectsClientWrapperOptions) => SavedObjectsClientContract;
// @public
-export interface SavedObjectsClientWrapperOptions {
+export interface SavedObjectsClientWrapperOptions {
// (undocumented)
client: SavedObjectsClientContract;
// (undocumented)
- request: Request;
+ request: KibanaRequest;
}
// @public (undocumented)
@@ -1752,15 +1755,15 @@ export interface SavedObjectsIncrementCounterOptions extends SavedObjectsBaseOpt
}
// @internal @deprecated (undocumented)
-export interface SavedObjectsLegacyService {
+export interface SavedObjectsLegacyService {
// Warning: (ae-forgotten-export) The symbol "SavedObjectsClientProvider" needs to be exported by the entry point index.d.ts
//
// (undocumented)
- addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider['addClientWrapperFactory'];
+ addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider['addClientWrapperFactory'];
// (undocumented)
getSavedObjectsRepository(...rest: any[]): any;
// (undocumented)
- getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
+ getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
// (undocumented)
importExport: {
objectLimit: number;
@@ -1773,7 +1776,7 @@ export interface SavedObjectsLegacyService {
// (undocumented)
schema: SavedObjectsSchema;
// (undocumented)
- setScopedSavedObjectsClientFactory: SavedObjectsClientProvider['setClientFactory'];
+ setScopedSavedObjectsClientFactory: SavedObjectsClientProvider['setClientFactory'];
// (undocumented)
types: string[];
}
@@ -1836,6 +1839,12 @@ export class SavedObjectsRepository {
update(type: string, id: string, attributes: Partial, options?: SavedObjectsUpdateOptions): Promise>;
}
+// @public
+export interface SavedObjectsRepositoryFactory {
+ createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
+ createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
+}
+
// @public
export interface SavedObjectsResolveImportErrorsOptions {
// (undocumented)
@@ -1878,14 +1887,14 @@ export class SavedObjectsSerializer {
// @public
export interface SavedObjectsServiceSetup {
- addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
- createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
- createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
- setClientFactory: (customClientFactory: SavedObjectsClientFactory) => void;
+ addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
+ setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
}
// @public
export interface SavedObjectsServiceStart {
+ createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
+ createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
getScopedClient: (req: KibanaRequest, options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract;
}
diff --git a/src/core/server/server.ts b/src/core/server/server.ts
index 89a5bdc4802fd..96adb3bbcd210 100644
--- a/src/core/server/server.ts
+++ b/src/core/server/server.ts
@@ -47,7 +47,7 @@ import { config as uiSettingsConfig } from './ui_settings';
import { mapToObject } from '../utils';
import { ContextService } from './context';
import { RequestHandlerContext } from '.';
-import { InternalCoreSetup } from './internal_types';
+import { InternalCoreSetup, InternalCoreStart } from './internal_types';
import { CapabilitiesService } from './capabilities';
import { UuidService } from './uuid';
@@ -68,6 +68,8 @@ export class Server {
private readonly uiSettings: UiSettingsService;
private readonly uuid: UuidService;
+ private coreStart?: InternalCoreStart;
+
constructor(
rawConfigProvider: RawConfigurationProvider,
public readonly env: Env,
@@ -174,21 +176,24 @@ export class Server {
uiSettings: uiSettingsStart,
});
- const coreStart = {
+ this.coreStart = {
capabilities: capabilitiesStart,
savedObjects: savedObjectsStart,
uiSettings: uiSettingsStart,
- plugins: pluginsStart,
};
+
await this.legacy.start({
- core: coreStart,
+ core: {
+ ...this.coreStart,
+ plugins: pluginsStart,
+ },
plugins: mapToObject(pluginsStart.contracts),
});
await this.http.start();
await this.rendering.start();
- return coreStart;
+ return this.coreStart;
}
public async stop() {
@@ -215,7 +220,7 @@ export class Server {
coreId,
'core',
async (context, req, res): Promise => {
- const savedObjectsClient = coreSetup.savedObjects.getScopedClient(req);
+ const savedObjectsClient = this.coreStart!.savedObjects.getScopedClient(req);
const uiSettingsClient = coreSetup.uiSettings.asScopedToClient(savedObjectsClient);
return {
diff --git a/src/core/server/ui_settings/create_or_upgrade_saved_config/integration_tests/create_or_upgrade.test.ts b/src/core/server/ui_settings/create_or_upgrade_saved_config/integration_tests/create_or_upgrade.test.ts
index f7dbf992e8728..218de8e7acb3a 100644
--- a/src/core/server/ui_settings/create_or_upgrade_saved_config/integration_tests/create_or_upgrade.test.ts
+++ b/src/core/server/ui_settings/create_or_upgrade_saved_config/integration_tests/create_or_upgrade.test.ts
@@ -27,6 +27,7 @@ import {
} from '../../../../../test_utils/kbn_server';
import { createOrUpgradeSavedConfig } from '../create_or_upgrade_saved_config';
import { loggingServiceMock } from '../../../logging/logging_service.mock';
+import { httpServerMock } from '../../../http/http_server.mocks';
const logger = loggingServiceMock.create().get();
describe('createOrUpgradeSavedConfig()', () => {
@@ -48,7 +49,9 @@ describe('createOrUpgradeSavedConfig()', () => {
kbnServer = kbn.kbnServer;
const savedObjects = kbnServer.server.savedObjects;
- savedObjectsClient = savedObjects.getScopedSavedObjectsClient({});
+ savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
+ httpServerMock.createKibanaRequest()
+ );
await savedObjectsClient.bulkCreate([
{
diff --git a/src/core/server/ui_settings/integration_tests/lib/servers.ts b/src/core/server/ui_settings/integration_tests/lib/servers.ts
index 1abe6dc2d0683..57448541d68c5 100644
--- a/src/core/server/ui_settings/integration_tests/lib/servers.ts
+++ b/src/core/server/ui_settings/integration_tests/lib/servers.ts
@@ -26,6 +26,7 @@ import {
TestUtils,
} from '../../../../../test_utils/kbn_server';
import { APICaller } from '../../../elasticsearch/';
+import { httpServerMock } from '../../../http/http_server.mocks';
let servers: TestUtils;
let esServer: TestElasticsearchUtils;
@@ -83,7 +84,9 @@ export function getServices() {
const callCluster = esServer.es.getCallCluster();
const savedObjects = kbnServer.server.savedObjects;
- const savedObjectsClient = savedObjects.getScopedSavedObjectsClient({});
+ const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
+ httpServerMock.createKibanaRequest()
+ );
const uiSettings = kbnServer.server.uiSettingsServiceFactory({
savedObjectsClient,
diff --git a/src/legacy/core_plugins/telemetry/server/collectors/management/telemetry_management_collector.ts b/src/legacy/core_plugins/telemetry/server/collectors/management/telemetry_management_collector.ts
index 44926b644ced5..481b1e9af2a79 100644
--- a/src/legacy/core_plugins/telemetry/server/collectors/management/telemetry_management_collector.ts
+++ b/src/legacy/core_plugins/telemetry/server/collectors/management/telemetry_management_collector.ts
@@ -32,7 +32,7 @@ export async function getTranslationCount(loader: any, locale: string): Promise<
export function createCollectorFetch(server: Server) {
return async function fetchUsageStats(): Promise {
- const internalRepo = server.newPlatform.setup.core.savedObjects.createInternalRepository();
+ const internalRepo = server.newPlatform.start.core.savedObjects.createInternalRepository();
const uiSettingsClient = server.newPlatform.start.core.uiSettings.asScopedToClient(
new SavedObjectsClient(internalRepo)
);
diff --git a/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts b/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts
index 8f68e63703d40..e45ad796bd9d4 100644
--- a/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts
+++ b/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts
@@ -27,12 +27,12 @@ export class KqlTelemetryService implements Plugin {
constructor(private initializerContext: PluginInitializerContext) {}
public setup(
- { http, savedObjects }: CoreSetup,
+ { http, getStartServices }: CoreSetup,
{ usageCollection }: { usageCollection?: UsageCollectionSetup }
) {
registerKqlTelemetryRoute(
http.createRouter(),
- savedObjects,
+ getStartServices,
this.initializerContext.logger.get('data', 'kql-telemetry')
);
diff --git a/src/plugins/data/server/kql_telemetry/route.ts b/src/plugins/data/server/kql_telemetry/route.ts
index 3185da22b12b3..d5725c859c9a9 100644
--- a/src/plugins/data/server/kql_telemetry/route.ts
+++ b/src/plugins/data/server/kql_telemetry/route.ts
@@ -22,7 +22,7 @@ import { schema } from '@kbn/config-schema';
export function registerKqlTelemetryRoute(
router: IRouter,
- savedObjects: CoreSetup['savedObjects'],
+ getStartServices: CoreSetup['getStartServices'],
logger: Logger
) {
router.post(
@@ -35,6 +35,7 @@ export function registerKqlTelemetryRoute(
},
},
async (context, request, response) => {
+ const [{ savedObjects }] = await getStartServices();
const internalRepository = savedObjects.createScopedRepository(request);
const {
diff --git a/src/plugins/home/server/services/sample_data/sample_data_registry.ts b/src/plugins/home/server/services/sample_data/sample_data_registry.ts
index 7a4909668fff2..aac680211e52e 100644
--- a/src/plugins/home/server/services/sample_data/sample_data_registry.ts
+++ b/src/plugins/home/server/services/sample_data/sample_data_registry.ts
@@ -51,7 +51,7 @@ export class SampleDataRegistry {
makeSampleDataUsageCollector(usageCollections, this.initContext);
}
const usageTracker = usage(
- core.savedObjects,
+ core.getStartServices().then(([coreStart]) => coreStart.savedObjects),
this.initContext.logger.get('sample_data', 'telemetry')
);
const router = core.http.createRouter();
diff --git a/src/plugins/home/server/services/sample_data/usage/usage.ts b/src/plugins/home/server/services/sample_data/usage/usage.ts
index a06dde387bb36..59599a1bee68f 100644
--- a/src/plugins/home/server/services/sample_data/usage/usage.ts
+++ b/src/plugins/home/server/services/sample_data/usage/usage.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { Logger, SavedObjectsServiceSetup } from 'kibana/server';
+import { Logger, SavedObjectsServiceStart } from 'kibana/server';
const SAVED_OBJECT_ID = 'sample-data-telemetry';
@@ -27,7 +27,7 @@ export interface SampleDataUsageTracker {
}
export function usage(
- savedObjects: SavedObjectsServiceSetup,
+ savedObjects: Promise,
logger: Logger
): SampleDataUsageTracker {
const handleIncrementError = (err: Error) => {
@@ -37,11 +37,12 @@ export function usage(
logger.warn(`saved objects repository incrementCounter encountered an error: ${err}`);
};
- const internalRepository = savedObjects.createInternalRepository();
+ const internalRepositoryPromise = savedObjects.then(so => so.createInternalRepository());
return {
addInstall: async (dataSet: string) => {
try {
+ const internalRepository = await internalRepositoryPromise;
await internalRepository.incrementCounter(SAVED_OBJECT_ID, dataSet, `installCount`);
} catch (err) {
handleIncrementError(err);
@@ -49,6 +50,7 @@ export function usage(
},
addUninstall: async (dataSet: string) => {
try {
+ const internalRepository = await internalRepositoryPromise;
await internalRepository.incrementCounter(SAVED_OBJECT_ID, dataSet, `unInstallCount`);
} catch (err) {
handleIncrementError(err);
diff --git a/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts b/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts
index 136f5b9e5cfad..e49664265b8bb 100644
--- a/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts
+++ b/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts
@@ -64,11 +64,14 @@ export class ValidationTelemetryService implements Plugin start.savedObjects.createInternalRepository());
return {
logFailedValidation: async () => {
try {
+ const internalRepository = await internalRepositoryPromise;
await internalRepository.incrementCounter(
'tsvb-validation-telemetry',
'tsvb-validation-telemetry',
diff --git a/x-pack/legacy/plugins/alerting/server/plugin.ts b/x-pack/legacy/plugins/alerting/server/plugin.ts
index 357db9e3df97e..3218d9eeb2ef4 100644
--- a/x-pack/legacy/plugins/alerting/server/plugin.ts
+++ b/x-pack/legacy/plugins/alerting/server/plugin.ts
@@ -128,11 +128,12 @@ export class Plugin {
this.taskRunnerFactory.initialize({
logger: this.logger,
- getServices(request: Hapi.Request): Services {
+ getServices(rawRequest: Hapi.Request): Services {
+ const request = KibanaRequest.from(rawRequest);
return {
- callCluster: (...args) =>
- adminClient!.asScoped(KibanaRequest.from(request)).callAsCurrentUser(...args),
- savedObjectsClient: core.savedObjects.getScopedSavedObjectsClient(request),
+ callCluster: (...args) => adminClient!.asScoped(request).callAsCurrentUser(...args),
+ // rawRequest is actually a fake request, converting it to KibanaRequest causes issue in SO access
+ savedObjectsClient: core.savedObjects.getScopedSavedObjectsClient(rawRequest as any),
};
},
spaceIdToNamespace,
diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts
index f35ffa0e45bfe..83bcc90ba92ed 100644
--- a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts
+++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts
@@ -5,6 +5,8 @@
*/
import { i18n } from '@kbn/i18n';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { KibanaRequest } from '../../../../../../../src/core/server';
import {
ExecuteJobFactory,
ESQueueWorkerExecuteFn,
@@ -82,7 +84,9 @@ export const executeJobFactory: ExecuteJobFactory {
const { savedObjects, uiSettingsServiceFactory } = server;
- const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(req.getRawRequest());
+ const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
+ KibanaRequest.from(req.getRawRequest())
+ );
const { indexPatternSavedObjectId, timerange } = searchPanel;
const savedSearchObjectAttr = searchPanel.attributes as SavedSearchObjectAttributes;
const { indexPatternSavedObject } = await getDataSource(
diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts
index b490bf17e292c..2f72081a70988 100644
--- a/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts
+++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts
@@ -48,7 +48,7 @@ export interface UptimeCoreSetup {
}
export interface UptimeCorePlugins {
- savedObjects: SavedObjectsLegacyService;
+ savedObjects: SavedObjectsLegacyService;
usageCollection: UsageCollectionSetup;
xpack: any;
}
diff --git a/x-pack/plugins/encrypted_saved_objects/server/plugin.ts b/x-pack/plugins/encrypted_saved_objects/server/plugin.ts
index 39da4c7d2d353..ecd917ff90d00 100644
--- a/x-pack/plugins/encrypted_saved_objects/server/plugin.ts
+++ b/x-pack/plugins/encrypted_saved_objects/server/plugin.ts
@@ -71,7 +71,11 @@ export class Plugin {
)
);
- this.savedObjectsSetup = setupSavedObjects({ service, savedObjects: core.savedObjects });
+ this.savedObjectsSetup = setupSavedObjects({
+ service,
+ savedObjects: core.savedObjects,
+ getStartServices: core.getStartServices,
+ });
return {
registerType: (typeRegistration: EncryptedSavedObjectTypeRegistration) =>
diff --git a/x-pack/plugins/encrypted_saved_objects/server/saved_objects/index.ts b/x-pack/plugins/encrypted_saved_objects/server/saved_objects/index.ts
index c967c92deb6ff..80bd2ab7b5171 100644
--- a/x-pack/plugins/encrypted_saved_objects/server/saved_objects/index.ts
+++ b/x-pack/plugins/encrypted_saved_objects/server/saved_objects/index.ts
@@ -16,6 +16,7 @@ import { EncryptedSavedObjectsClientWrapper } from './encrypted_saved_objects_cl
interface SetupSavedObjectsParams {
service: PublicMethodsOf;
savedObjects: CoreSetup['savedObjects'];
+ getStartServices: CoreSetup['getStartServices'];
}
export interface SavedObjectsSetup {
@@ -29,6 +30,7 @@ export interface SavedObjectsSetup {
export function setupSavedObjects({
service,
savedObjects,
+ getStartServices,
}: SetupSavedObjectsParams): SavedObjectsSetup {
// Register custom saved object client that will encrypt, decrypt and strip saved object
// attributes where appropriate for any saved object repository request. We choose max possible
@@ -41,13 +43,16 @@ export function setupSavedObjects({
({ client: baseClient }) => new EncryptedSavedObjectsClientWrapper({ baseClient, service })
);
- const internalRepository = savedObjects.createInternalRepository();
+ const internalRepositoryPromise = getStartServices().then(([core]) =>
+ core.savedObjects.createInternalRepository()
+ );
return {
getDecryptedAsInternalUser: async (
type: string,
id: string,
options?: SavedObjectsBaseOptions
): Promise> => {
+ const internalRepository = await internalRepositoryPromise;
const savedObject = await internalRepository.get(type, id, options);
return {
...savedObject,
diff --git a/x-pack/plugins/security/server/saved_objects/index.ts b/x-pack/plugins/security/server/saved_objects/index.ts
index 556dc4fda85cf..5954729562847 100644
--- a/x-pack/plugins/security/server/saved_objects/index.ts
+++ b/x-pack/plugins/security/server/saved_objects/index.ts
@@ -24,12 +24,12 @@ export function setupSavedObjects({ auditLogger, authz, savedObjects }: SetupSav
const getKibanaRequest = (request: KibanaRequest | LegacyRequest) =>
request instanceof KibanaRequest ? request : KibanaRequest.from(request);
- savedObjects.setClientFactory(({ request }) => {
+ savedObjects.setClientFactoryProvider(repositoryFactory => ({ request }) => {
const kibanaRequest = getKibanaRequest(request);
return new SavedObjectsClient(
authz.mode.useRbacForRequest(kibanaRequest)
- ? savedObjects.createInternalRepository()
- : savedObjects.createScopedRepository(kibanaRequest)
+ ? repositoryFactory.createInternalRepository()
+ : repositoryFactory.createScopedRepository(kibanaRequest)
);
});
diff --git a/x-pack/plugins/task_manager/server/plugin.ts b/x-pack/plugins/task_manager/server/plugin.ts
index 9bdd1ce6d8748..8b09f8f2b445a 100644
--- a/x-pack/plugins/task_manager/server/plugin.ts
+++ b/x-pack/plugins/task_manager/server/plugin.ts
@@ -38,12 +38,13 @@ export class TaskManagerPlugin
public setup(core: CoreSetup, plugins: any): TaskManagerSetupContract {
const logger = this.initContext.logger.get('taskManager');
const config$ = this.initContext.config.create();
- const savedObjectsRepository = core.savedObjects.createInternalRepository(['task']);
const elasticsearch = core.elasticsearch.adminClient;
return {
config$,
registerLegacyAPI: once((__LEGACY: PluginLegacyDependencies) => {
config$.subscribe(async config => {
+ const [{ savedObjects }] = await core.getStartServices();
+ const savedObjectsRepository = savedObjects.createInternalRepository(['task']);
this.legacyTaskManager$.next(
createTaskManager(core, {
logger,