Skip to content

Commit

Permalink
Add SavedObject management section registration in core (elastic#59291)
Browse files Browse the repository at this point in the history
* add management section to SavedObjectsType

* adapt import/export routes to get types accessor

* add documentation

* update generated doc

* update migration guide

* use request context to access exportable types

* update generated doc

* adapt SavedObjectsManagement to use the registry

* stop magical tricks about the config type, register it as any other so type.

* fix FTR assertions

* fix so_mixin tests

* register the `config` type from the uiSettings service

* nits and comments

* update generated doc

* remove true from dynamic property definition, use force-cast back for config type

* remove obsolete test comment
  • Loading branch information
pgayvallet authored and jkelastic committed Mar 12, 2020
1 parent 15bb9ef commit 982ae2d
Show file tree
Hide file tree
Showing 68 changed files with 952 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export interface AuthToolkit
| --- | --- | --- |
| [authenticated](./kibana-plugin-server.authtoolkit.authenticated.md) | <code>(data?: AuthResultParams) =&gt; AuthResult</code> | Authentication is successful with given credentials, allow request to pass through |
| [notHandled](./kibana-plugin-server.authtoolkit.nothandled.md) | <code>() =&gt; AuthResult</code> | User has no credentials. Allows user to access a resource when authRequired: 'optional' Rejects a request when authRequired: true |
| [redirected](./kibana-plugin-server.authtoolkit.redirected.md) | <code>(headers: {</code><br/><code> location: string;</code><br/><code> } &amp; ResponseHeaders) =&gt; AuthResult</code> | Redirect user to IdP when authRequired: true Allows user to access a resource without redirection when authRequired: 'optional' |
| [redirected](./kibana-plugin-server.authtoolkit.redirected.md) | <code>(headers: {</code><br/><code> location: string;</code><br/><code> } &amp; ResponseHeaders) =&gt; AuthResult</code> | Redirects user to another location to complete authentication when authRequired: true Allows user to access a resource without redirection when authRequired: 'optional' |

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## AuthToolkit.redirected property

Redirect user to IdP when authRequired: true Allows user to access a resource without redirection when authRequired: 'optional'
Redirects user to another location to complete authentication when authRequired: true Allows user to access a resource without redirection when authRequired: 'optional'

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ See [SavedObjectTypeRegistry](./kibana-plugin-server.savedobjecttyperegistry.md)
<b>Signature:</b>

```typescript
export declare type ISavedObjectTypeRegistry = Pick<SavedObjectTypeRegistry, 'getType' | 'getAllTypes' | 'getIndex' | 'isNamespaceAgnostic' | 'isHidden'>;
export declare type ISavedObjectTypeRegistry = Pick<SavedObjectTypeRegistry, 'getType' | 'getAllTypes' | 'getIndex' | 'isNamespaceAgnostic' | 'isHidden' | 'getImportableAndExportableTypes' | 'isImportableAndExportable'>;
```
3 changes: 2 additions & 1 deletion docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [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 |
| [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.<!-- -->Provides the following clients and services: - [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 - [savedObjects.typeRegistry](./kibana-plugin-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [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 |
Expand Down Expand Up @@ -164,6 +164,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [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 registering Saved Object types, creating and registering Saved Object client wrappers and factories. |
| [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. |
| [SavedObjectsType](./kibana-plugin-server.savedobjectstype.md) | |
| [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) | Configuration options for the [type](./kibana-plugin-server.savedobjectstype.md)<!-- -->'s management section. |
| [SavedObjectsTypeMappingDefinition](./kibana-plugin-server.savedobjectstypemappingdefinition.md) | Describe a saved object type mapping. |
| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ core: {
rendering: IScopedRenderingClient;
savedObjects: {
client: SavedObjectsClientContract;
typeRegistry: ISavedObjectTypeRegistry;
};
elasticsearch: {
dataClient: IScopedClusterClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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
Provides the following clients and services: - [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 - [savedObjects.typeRegistry](./kibana-plugin-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [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

<b>Signature:</b>

Expand All @@ -18,5 +18,5 @@ export interface RequestHandlerContext

| Property | Type | Description |
| --- | --- | --- |
| [core](./kibana-plugin-server.requesthandlercontext.core.md) | <code>{</code><br/><code> rendering: IScopedRenderingClient;</code><br/><code> savedObjects: {</code><br/><code> client: SavedObjectsClientContract;</code><br/><code> };</code><br/><code> elasticsearch: {</code><br/><code> dataClient: IScopedClusterClient;</code><br/><code> adminClient: IScopedClusterClient;</code><br/><code> };</code><br/><code> uiSettings: {</code><br/><code> client: IUiSettingsClient;</code><br/><code> };</code><br/><code> }</code> | |
| [core](./kibana-plugin-server.requesthandlercontext.core.md) | <code>{</code><br/><code> rendering: IScopedRenderingClient;</code><br/><code> savedObjects: {</code><br/><code> client: SavedObjectsClientContract;</code><br/><code> typeRegistry: ISavedObjectTypeRegistry;</code><br/><code> };</code><br/><code> elasticsearch: {</code><br/><code> dataClient: IScopedClusterClient;</code><br/><code> adminClient: IScopedClusterClient;</code><br/><code> };</code><br/><code> uiSettings: {</code><br/><code> client: IUiSettingsClient;</code><br/><code> };</code><br/><code> }</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsType](./kibana-plugin-server.savedobjectstype.md) &gt; [management](./kibana-plugin-server.savedobjectstype.management.md)

## SavedObjectsType.management property

An optional [saved objects management section](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) definition for the type.

<b>Signature:</b>

```typescript
management?: SavedObjectsTypeManagementDefinition;
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This is only internal for now, and will only be public when we expose the regist
| [convertToAliasScript](./kibana-plugin-server.savedobjectstype.converttoaliasscript.md) | <code>string</code> | If defined, will be used to convert the type to an alias. |
| [hidden](./kibana-plugin-server.savedobjectstype.hidden.md) | <code>boolean</code> | Is the type hidden by default. If true, repositories will not have access to this type unless explicitly declared as an <code>extraType</code> when creating the repository.<!-- -->See [createInternalRepository](./kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md)<!-- -->. |
| [indexPattern](./kibana-plugin-server.savedobjectstype.indexpattern.md) | <code>string</code> | If defined, the type instances will be stored in the given index instead of the default one. |
| [management](./kibana-plugin-server.savedobjectstype.management.md) | <code>SavedObjectsTypeManagementDefinition</code> | An optional [saved objects management section](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) definition for the type. |
| [mappings](./kibana-plugin-server.savedobjectstype.mappings.md) | <code>SavedObjectsTypeMappingDefinition</code> | The [mapping definition](./kibana-plugin-server.savedobjectstypemappingdefinition.md) for the type. |
| [migrations](./kibana-plugin-server.savedobjectstype.migrations.md) | <code>SavedObjectMigrationMap</code> | An optional map of [migrations](./kibana-plugin-server.savedobjectmigrationfn.md) to be used to migrate the type. |
| [name](./kibana-plugin-server.savedobjectstype.name.md) | <code>string</code> | The name of the type, which is also used as the internal id. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) &gt; [defaultSearchField](./kibana-plugin-server.savedobjectstypemanagementdefinition.defaultsearchfield.md)

## SavedObjectsTypeManagementDefinition.defaultSearchField property

The default search field to use for this type. Defaults to `id`<!-- -->.

<b>Signature:</b>

```typescript
defaultSearchField?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) &gt; [getEditUrl](./kibana-plugin-server.savedobjectstypemanagementdefinition.getediturl.md)

## SavedObjectsTypeManagementDefinition.getEditUrl property

Function returning the url to use to redirect to the editing page of this object. If not defined, editing will not be allowed.

<b>Signature:</b>

```typescript
getEditUrl?: (savedObject: SavedObject<any>) => string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) &gt; [getInAppUrl](./kibana-plugin-server.savedobjectstypemanagementdefinition.getinappurl.md)

## SavedObjectsTypeManagementDefinition.getInAppUrl property

Function returning the url to use to redirect to this object from the management section. If not defined, redirecting to the object will not be allowed.

<b>Signature:</b>

```typescript
getInAppUrl?: (savedObject: SavedObject<any>) => {
path: string;
uiCapabilitiesPath: string;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) &gt; [getTitle](./kibana-plugin-server.savedobjectstypemanagementdefinition.gettitle.md)

## SavedObjectsTypeManagementDefinition.getTitle property

Function returning the title to display in the management table. If not defined, will use the object's type and id to generate a label.

<b>Signature:</b>

```typescript
getTitle?: (savedObject: SavedObject<any>) => string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) &gt; [icon](./kibana-plugin-server.savedobjectstypemanagementdefinition.icon.md)

## SavedObjectsTypeManagementDefinition.icon property

The eui icon name to display in the management table. If not defined, the default icon will be used.

<b>Signature:</b>

```typescript
icon?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md) &gt; [importableAndExportable](./kibana-plugin-server.savedobjectstypemanagementdefinition.importableandexportable.md)

## SavedObjectsTypeManagementDefinition.importableAndExportable property

Is the type importable or exportable. Defaults to `false`<!-- -->.

<b>Signature:</b>

```typescript
importableAndExportable?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-server.savedobjectstypemanagementdefinition.md)

## SavedObjectsTypeManagementDefinition interface

Configuration options for the [type](./kibana-plugin-server.savedobjectstype.md)<!-- -->'s management section.

<b>Signature:</b>

```typescript
export interface SavedObjectsTypeManagementDefinition
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [defaultSearchField](./kibana-plugin-server.savedobjectstypemanagementdefinition.defaultsearchfield.md) | <code>string</code> | The default search field to use for this type. Defaults to <code>id</code>. |
| [getEditUrl](./kibana-plugin-server.savedobjectstypemanagementdefinition.getediturl.md) | <code>(savedObject: SavedObject&lt;any&gt;) =&gt; string</code> | Function returning the url to use to redirect to the editing page of this object. If not defined, editing will not be allowed. |
| [getInAppUrl](./kibana-plugin-server.savedobjectstypemanagementdefinition.getinappurl.md) | <code>(savedObject: SavedObject&lt;any&gt;) =&gt; {</code><br/><code> path: string;</code><br/><code> uiCapabilitiesPath: string;</code><br/><code> }</code> | Function returning the url to use to redirect to this object from the management section. If not defined, redirecting to the object will not be allowed. |
| [getTitle](./kibana-plugin-server.savedobjectstypemanagementdefinition.gettitle.md) | <code>(savedObject: SavedObject&lt;any&gt;) =&gt; string</code> | Function returning the title to display in the management table. If not defined, will use the object's type and id to generate a label. |
| [icon](./kibana-plugin-server.savedobjectstypemanagementdefinition.icon.md) | <code>string</code> | The eui icon name to display in the management table. If not defined, the default icon will be used. |
| [importableAndExportable](./kibana-plugin-server.savedobjectstypemanagementdefinition.importableandexportable.md) | <code>boolean</code> | Is the type importable or exportable. Defaults to <code>false</code>. |

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## SavedObjectsTypeMappingDefinition.dynamic property

The dynamic property of the mapping. either `false` or 'strict'. Defaults to strict
The dynamic property of the mapping. either `false` or 'strict'. Defaults to `false`

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ const typeDefinition: SavedObjectsTypeMappingDefinition = {

| Property | Type | Description |
| --- | --- | --- |
| [dynamic](./kibana-plugin-server.savedobjectstypemappingdefinition.dynamic.md) | <code>false &#124; 'strict'</code> | The dynamic property of the mapping. either <code>false</code> or 'strict'. Defaults to strict |
| [dynamic](./kibana-plugin-server.savedobjectstypemappingdefinition.dynamic.md) | <code>false &#124; 'strict'</code> | The dynamic property of the mapping. either <code>false</code> or 'strict'. Defaults to <code>false</code> |
| [properties](./kibana-plugin-server.savedobjectstypemappingdefinition.properties.md) | <code>SavedObjectsMappingProperties</code> | The underlying properties of the type mapping |

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectTypeRegistry](./kibana-plugin-server.savedobjecttyperegistry.md) &gt; [getImportableAndExportableTypes](./kibana-plugin-server.savedobjecttyperegistry.getimportableandexportabletypes.md)

## SavedObjectTypeRegistry.getImportableAndExportableTypes() method

Return all [types](./kibana-plugin-server.savedobjectstype.md) currently registered that are importable/exportable.

<b>Signature:</b>

```typescript
getImportableAndExportableTypes(): SavedObjectsType[];
```
<b>Returns:</b>

`SavedObjectsType[]`

Loading

0 comments on commit 982ae2d

Please sign in to comment.