Skip to content

Commit

Permalink
[Core] Public saved objects client (#39891)
Browse files Browse the repository at this point in the history
* Move SavedObjectClient files to core/public

* Initial SavedObjectsService in public Core

* Public SavedObjectsClient tests

* Import SimpleSavedObject from src/core/public

* Use types from source files for kibana.d.ts

* Add html raw loader to x-pack/jest

* Cleanup

* Drop case utilities and improve test coverage

* Update types and documentation

* Fix build breaking when importing directly from /server in /public

* Ensure that all option paramaters are picked and renamed

* Fix option mapping and introduce stronger types

* Eslint: allow imports from src/core/*/types

* Add compatibility layer for kfetch vs http.fetch error responses

* Improve documentation

* Expose SavedObjectsMigrationLogger

* Documentation and type tweaks

* Revert type changes from 73e601f and update api docs

* Refactor request into savedObjectFetch + test

* Make legacy SavedObject compatible with http.fetch exceptions

* Fix types and tests

* simple_saved_object import from src/core/server

* server imports from root instead of server/types

* Make SavedObjectsService a class

* Don't pick unkown keys from server response

* Rename SavedObjectsFindResponse to SavedObjectsFindResponsePublic

* Remove err.response from SavedObjects fetch errors

* Revert "Remove err.response from SavedObjects fetch errors"

This reverts commit 61705ca.

* Don't introduce err.response until we deprecate err.res
  • Loading branch information
rudolf authored Aug 6, 2019
1 parent fe1389c commit e137477
Show file tree
Hide file tree
Showing 167 changed files with 2,586 additions and 712 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export interface CoreStart
| [i18n](./kibana-plugin-public.corestart.i18n.md) | <code>I18nStart</code> | [I18nStart](./kibana-plugin-public.i18nstart.md) |
| [notifications](./kibana-plugin-public.corestart.notifications.md) | <code>NotificationsStart</code> | [NotificationsStart](./kibana-plugin-public.notificationsstart.md) |
| [overlays](./kibana-plugin-public.corestart.overlays.md) | <code>OverlayStart</code> | [OverlayStart](./kibana-plugin-public.overlaystart.md) |
| [savedObjects](./kibana-plugin-public.corestart.savedobjects.md) | <code>SavedObjectsStart</code> | [SavedObjectsStart](./kibana-plugin-public.savedobjectsstart.md) |
| [uiSettings](./kibana-plugin-public.corestart.uisettings.md) | <code>UiSettingsClientContract</code> | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) |

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-public](./kibana-plugin-public.md) &gt; [CoreStart](./kibana-plugin-public.corestart.md) &gt; [savedObjects](./kibana-plugin-public.corestart.savedobjects.md)

## CoreStart.savedObjects property

[SavedObjectsStart](./kibana-plugin-public.savedobjectsstart.md)

<b>Signature:</b>

```typescript
savedObjects: SavedObjectsStart;
```
17 changes: 17 additions & 0 deletions docs/development/core/public/kibana-plugin-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->

| Class | Description |
| --- | --- |
| [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state. The client-side SavedObjectsClient is a thin convenience library around the SavedObjects HTTP API for interacting with Saved Objects. |
| [SimpleSavedObject](./kibana-plugin-public.simplesavedobject.md) | This class is a very simple wrapper for SavedObjects loaded from the server with the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md)<!-- -->.<!-- -->It provides basic functionality for creating/saving/deleting saved objects, but doesn't include any type-specific implementations. |
| [ToastsApi](./kibana-plugin-public.toastsapi.md) | |
| [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | |

Expand Down Expand Up @@ -59,6 +61,19 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [OverlayStart](./kibana-plugin-public.overlaystart.md) | |
| [Plugin](./kibana-plugin-public.plugin.md) | The interface that should be returned by a <code>PluginInitializer</code>. |
| [PluginInitializerContext](./kibana-plugin-public.plugininitializercontext.md) | The available core services passed to a <code>PluginInitializer</code> |
| [SavedObject](./kibana-plugin-public.savedobject.md) | |
| [SavedObjectAttributes](./kibana-plugin-public.savedobjectattributes.md) | The data for a Saved Object is stored in the <code>attributes</code> key as either an object or an array of objects. |
| [SavedObjectReference](./kibana-plugin-public.savedobjectreference.md) | A reference to another saved object. |
| [SavedObjectsBaseOptions](./kibana-plugin-public.savedobjectsbaseoptions.md) | |
| [SavedObjectsBatchResponse](./kibana-plugin-public.savedobjectsbatchresponse.md) | |
| [SavedObjectsBulkCreateObject](./kibana-plugin-public.savedobjectsbulkcreateobject.md) | |
| [SavedObjectsBulkCreateOptions](./kibana-plugin-public.savedobjectsbulkcreateoptions.md) | |
| [SavedObjectsCreateOptions](./kibana-plugin-public.savedobjectscreateoptions.md) | |
| [SavedObjectsFindOptions](./kibana-plugin-public.savedobjectsfindoptions.md) | |
| [SavedObjectsFindResponsePublic](./kibana-plugin-public.savedobjectsfindresponsepublic.md) | Return type of the Saved Objects <code>find()</code> method.<!-- -->\*Note\*: this type is different between the Public and Server Saved Objects clients. |
| [SavedObjectsMigrationVersion](./kibana-plugin-public.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. |
| [SavedObjectsStart](./kibana-plugin-public.savedobjectsstart.md) | |
| [SavedObjectsUpdateOptions](./kibana-plugin-public.savedobjectsupdateoptions.md) | |
| [UiSettingsState](./kibana-plugin-public.uisettingsstate.md) | |

## Type Aliases
Expand All @@ -76,6 +91,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [PluginInitializer](./kibana-plugin-public.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>public</code> directory should conform to this interface. |
| [PluginOpaqueId](./kibana-plugin-public.pluginopaqueid.md) | |
| [RecursiveReadonly](./kibana-plugin-public.recursivereadonly.md) | |
| [SavedObjectAttribute](./kibana-plugin-public.savedobjectattribute.md) | |
| [SavedObjectsClientContract](./kibana-plugin-public.savedobjectsclientcontract.md) | SavedObjectsClientContract as implemented by the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) |
| [ToastInput](./kibana-plugin-public.toastinput.md) | |
| [UiSettingsClientContract](./kibana-plugin-public.uisettingsclientcontract.md) | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) |

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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [attributes](./kibana-plugin-public.savedobject.attributes.md)

## SavedObject.attributes property

The data for a Saved Object is stored in the `attributes` key as either an object or an array of objects.

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [error](./kibana-plugin-public.savedobject.error.md)

## SavedObject.error property

<b>Signature:</b>

```typescript
error?: {
message: string;
statusCode: number;
};
```
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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [id](./kibana-plugin-public.savedobject.id.md)

## SavedObject.id property

The ID of this Saved Object, guaranteed to be unique for all objects of the same `type`

<b>Signature:</b>

```typescript
id: string;
```
26 changes: 26 additions & 0 deletions docs/development/core/public/kibana-plugin-public.savedobject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md)

## SavedObject interface


<b>Signature:</b>

```typescript
export interface SavedObject<T extends SavedObjectAttributes = any>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [attributes](./kibana-plugin-public.savedobject.attributes.md) | <code>T</code> | The data for a Saved Object is stored in the <code>attributes</code> key as either an object or an array of objects. |
| [error](./kibana-plugin-public.savedobject.error.md) | <code>{</code><br/><code> message: string;</code><br/><code> statusCode: number;</code><br/><code> }</code> | |
| [id](./kibana-plugin-public.savedobject.id.md) | <code>string</code> | The ID of this Saved Object, guaranteed to be unique for all objects of the same <code>type</code> |
| [migrationVersion](./kibana-plugin-public.savedobject.migrationversion.md) | <code>SavedObjectsMigrationVersion</code> | 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. |
| [references](./kibana-plugin-public.savedobject.references.md) | <code>SavedObjectReference[]</code> | A reference to another saved object. |
| [type](./kibana-plugin-public.savedobject.type.md) | <code>string</code> | The type of Saved Object. Each plugin can define it's own custom Saved Object types. |
| [updated\_at](./kibana-plugin-public.savedobject.updated_at.md) | <code>string</code> | Timestamp of the last time this document had been updated. |
| [version](./kibana-plugin-public.savedobject.version.md) | <code>string</code> | An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. |

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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [migrationVersion](./kibana-plugin-public.savedobject.migrationversion.md)

## SavedObject.migrationVersion property

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.

<b>Signature:</b>

```typescript
migrationVersion?: SavedObjectsMigrationVersion;
```
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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [references](./kibana-plugin-public.savedobject.references.md)

## SavedObject.references property

A reference to another saved object.

<b>Signature:</b>

```typescript
references: SavedObjectReference[];
```
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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [type](./kibana-plugin-public.savedobject.type.md)

## SavedObject.type property

The type of Saved Object. Each plugin can define it's own custom Saved Object types.

<b>Signature:</b>

```typescript
type: 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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [updated\_at](./kibana-plugin-public.savedobject.updated_at.md)

## SavedObject.updated\_at property

Timestamp of the last time this document had been updated.

<b>Signature:</b>

```typescript
updated_at?: 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-public](./kibana-plugin-public.md) &gt; [SavedObject](./kibana-plugin-public.savedobject.md) &gt; [version](./kibana-plugin-public.savedobject.version.md)

## SavedObject.version property

An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control.

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectAttribute](./kibana-plugin-public.savedobjectattribute.md)

## SavedObjectAttribute type


<b>Signature:</b>

```typescript
export declare type SavedObjectAttribute = string | number | boolean | null | undefined | SavedObjectAttributes | SavedObjectAttributes[];
```
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-public](./kibana-plugin-public.md) &gt; [SavedObjectAttributes](./kibana-plugin-public.savedobjectattributes.md)

## SavedObjectAttributes interface

The data for a Saved Object is stored in the `attributes` key as either an object or an array of objects.

<b>Signature:</b>

```typescript
export interface SavedObjectAttributes
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectReference](./kibana-plugin-public.savedobjectreference.md) &gt; [id](./kibana-plugin-public.savedobjectreference.id.md)

## SavedObjectReference.id property

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectReference](./kibana-plugin-public.savedobjectreference.md)

## SavedObjectReference interface

A reference to another saved object.

<b>Signature:</b>

```typescript
export interface SavedObjectReference
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [id](./kibana-plugin-public.savedobjectreference.id.md) | <code>string</code> | |
| [name](./kibana-plugin-public.savedobjectreference.name.md) | <code>string</code> | |
| [type](./kibana-plugin-public.savedobjectreference.type.md) | <code>string</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectReference](./kibana-plugin-public.savedobjectreference.md) &gt; [name](./kibana-plugin-public.savedobjectreference.name.md)

## SavedObjectReference.name property

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectReference](./kibana-plugin-public.savedobjectreference.md) &gt; [type](./kibana-plugin-public.savedobjectreference.type.md)

## SavedObjectReference.type property

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsBaseOptions](./kibana-plugin-public.savedobjectsbaseoptions.md)

## SavedObjectsBaseOptions interface


<b>Signature:</b>

```typescript
export interface SavedObjectsBaseOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [namespace](./kibana-plugin-public.savedobjectsbaseoptions.namespace.md) | <code>string</code> | Specify the namespace for this operation |

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-public](./kibana-plugin-public.md) &gt; [SavedObjectsBaseOptions](./kibana-plugin-public.savedobjectsbaseoptions.md) &gt; [namespace](./kibana-plugin-public.savedobjectsbaseoptions.namespace.md)

## SavedObjectsBaseOptions.namespace property

Specify the namespace for this operation

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsBatchResponse](./kibana-plugin-public.savedobjectsbatchresponse.md)

## SavedObjectsBatchResponse interface


<b>Signature:</b>

```typescript
export interface SavedObjectsBatchResponse<T extends SavedObjectAttributes = SavedObjectAttributes>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [savedObjects](./kibana-plugin-public.savedobjectsbatchresponse.savedobjects.md) | <code>Array&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsBatchResponse](./kibana-plugin-public.savedobjectsbatchresponse.md) &gt; [savedObjects](./kibana-plugin-public.savedobjectsbatchresponse.savedobjects.md)

## SavedObjectsBatchResponse.savedObjects property

<b>Signature:</b>

```typescript
savedObjects: Array<SimpleSavedObject<T>>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-public.savedobjectsbulkcreateobject.md) &gt; [attributes](./kibana-plugin-public.savedobjectsbulkcreateobject.attributes.md)

## SavedObjectsBulkCreateObject.attributes property

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-public.savedobjectsbulkcreateobject.md)

## SavedObjectsBulkCreateObject interface

<b>Signature:</b>

```typescript
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = SavedObjectAttributes> extends SavedObjectsCreateOptions
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [attributes](./kibana-plugin-public.savedobjectsbulkcreateobject.attributes.md) | <code>T</code> | |
| [type](./kibana-plugin-public.savedobjectsbulkcreateobject.type.md) | <code>string</code> | |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-public.savedobjectsbulkcreateobject.md) &gt; [type](./kibana-plugin-public.savedobjectsbulkcreateobject.type.md)

## SavedObjectsBulkCreateObject.type property

<b>Signature:</b>

```typescript
type: string;
```
Loading

0 comments on commit e137477

Please sign in to comment.