diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md
index 7b7d3a9f0662e..b6a5f43459a31 100644
--- a/docs/development/core/server/kibana-plugin-server.md
+++ b/docs/development/core/server/kibana-plugin-server.md
@@ -17,6 +17,7 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [ClusterClient](./kibana-plugin-server.clusterclient.md) | Represents an Elasticsearch cluster API client and allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)
). |
| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
| [Router](./kibana-plugin-server.router.md) | |
+| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.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 |
## Interfaces
@@ -43,6 +44,20 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [PluginsServiceSetup](./kibana-plugin-server.pluginsservicesetup.md) | |
| [PluginsServiceStart](./kibana-plugin-server.pluginsservicestart.md) | |
| [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md) | Route specific configuration. |
+| [SavedObject](./kibana-plugin-server.savedobject.md) | |
+| [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md) | |
+| [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) | |
+| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
+| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
+| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | |
+| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | A dictionary of saved object type -> version used to determine what migrations need to be applied to a saved object. |
+| [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) | |
+| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
+| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
| [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request |
@@ -60,4 +75,5 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [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. |
| [RecursiveReadonly](./kibana-plugin-server.recursivereadonly.md) | |
| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
+| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | \#\# 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 [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) |
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.attributes.md b/docs/development/core/server/kibana-plugin-server.savedobject.attributes.md
new file mode 100644
index 0000000000000..b58408fe5f6b6
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.attributes.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [attributes](./kibana-plugin-server.savedobject.attributes.md)
+
+## SavedObject.attributes property
+
+Signature:
+
+```typescript
+attributes: T;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.error.md b/docs/development/core/server/kibana-plugin-server.savedobject.error.md
new file mode 100644
index 0000000000000..910f1fa32d5df
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.error.md
@@ -0,0 +1,14 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [error](./kibana-plugin-server.savedobject.error.md)
+
+## SavedObject.error property
+
+Signature:
+
+```typescript
+error?: {
+ message: string;
+ statusCode: number;
+ };
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.id.md b/docs/development/core/server/kibana-plugin-server.savedobject.id.md
new file mode 100644
index 0000000000000..f0ee1e9770f85
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.id.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [id](./kibana-plugin-server.savedobject.id.md)
+
+## SavedObject.id property
+
+Signature:
+
+```typescript
+id: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.md b/docs/development/core/server/kibana-plugin-server.savedobject.md
new file mode 100644
index 0000000000000..3b2417c56d5e5
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.md
@@ -0,0 +1,26 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md)
+
+## SavedObject interface
+
+
+Signature:
+
+```typescript
+export interface SavedObject
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [attributes](./kibana-plugin-server.savedobject.attributes.md) | T
| |
+| [error](./kibana-plugin-server.savedobject.error.md) | {
message: string;
statusCode: number;
}
| |
+| [id](./kibana-plugin-server.savedobject.id.md) | string
| |
+| [migrationVersion](./kibana-plugin-server.savedobject.migrationversion.md) | SavedObjectsMigrationVersion
| |
+| [references](./kibana-plugin-server.savedobject.references.md) | SavedObjectReference[]
| |
+| [type](./kibana-plugin-server.savedobject.type.md) | string
| |
+| [updated\_at](./kibana-plugin-server.savedobject.updated_at.md) | string
| |
+| [version](./kibana-plugin-server.savedobject.version.md) | string
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.migrationversion.md b/docs/development/core/server/kibana-plugin-server.savedobject.migrationversion.md
new file mode 100644
index 0000000000000..f9150a96b22cb
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.migrationversion.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [migrationVersion](./kibana-plugin-server.savedobject.migrationversion.md)
+
+## SavedObject.migrationVersion property
+
+Signature:
+
+```typescript
+migrationVersion?: SavedObjectsMigrationVersion;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.references.md b/docs/development/core/server/kibana-plugin-server.savedobject.references.md
new file mode 100644
index 0000000000000..08476527a446d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.references.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [references](./kibana-plugin-server.savedobject.references.md)
+
+## SavedObject.references property
+
+Signature:
+
+```typescript
+references: SavedObjectReference[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.type.md b/docs/development/core/server/kibana-plugin-server.savedobject.type.md
new file mode 100644
index 0000000000000..172de52d305f7
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [type](./kibana-plugin-server.savedobject.type.md)
+
+## SavedObject.type property
+
+Signature:
+
+```typescript
+type: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.updated_at.md b/docs/development/core/server/kibana-plugin-server.savedobject.updated_at.md
new file mode 100644
index 0000000000000..0de1b1a0e816f
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.updated_at.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [updated\_at](./kibana-plugin-server.savedobject.updated_at.md)
+
+## SavedObject.updated\_at property
+
+Signature:
+
+```typescript
+updated_at?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobject.version.md b/docs/development/core/server/kibana-plugin-server.savedobject.version.md
new file mode 100644
index 0000000000000..25fbd536fcc38
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobject.version.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObject](./kibana-plugin-server.savedobject.md) > [version](./kibana-plugin-server.savedobject.version.md)
+
+## SavedObject.version property
+
+Signature:
+
+```typescript
+version?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectattributes.md b/docs/development/core/server/kibana-plugin-server.savedobjectattributes.md
new file mode 100644
index 0000000000000..b629d8fad0c7b
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectattributes.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md)
+
+## SavedObjectAttributes interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectAttributes
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectreference.id.md b/docs/development/core/server/kibana-plugin-server.savedobjectreference.id.md
new file mode 100644
index 0000000000000..f6e11c0228743
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectreference.id.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) > [id](./kibana-plugin-server.savedobjectreference.id.md)
+
+## SavedObjectReference.id property
+
+Signature:
+
+```typescript
+id: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectreference.md b/docs/development/core/server/kibana-plugin-server.savedobjectreference.md
new file mode 100644
index 0000000000000..75cf59ea3b925
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectreference.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md)
+
+## SavedObjectReference interface
+
+A reference to another saved object.
+
+Signature:
+
+```typescript
+export interface SavedObjectReference
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [id](./kibana-plugin-server.savedobjectreference.id.md) | string
| |
+| [name](./kibana-plugin-server.savedobjectreference.name.md) | string
| |
+| [type](./kibana-plugin-server.savedobjectreference.type.md) | string
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectreference.name.md b/docs/development/core/server/kibana-plugin-server.savedobjectreference.name.md
new file mode 100644
index 0000000000000..8a88128c3fbc1
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectreference.name.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) > [name](./kibana-plugin-server.savedobjectreference.name.md)
+
+## SavedObjectReference.name property
+
+Signature:
+
+```typescript
+name: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectreference.type.md b/docs/development/core/server/kibana-plugin-server.savedobjectreference.type.md
new file mode 100644
index 0000000000000..5347256dfa2dc
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectreference.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) > [type](./kibana-plugin-server.savedobjectreference.type.md)
+
+## SavedObjectReference.type property
+
+Signature:
+
+```typescript
+type: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbaseoptions.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbaseoptions.md
new file mode 100644
index 0000000000000..6eace924490cc
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbaseoptions.md
@@ -0,0 +1,19 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md)
+
+## SavedObjectsBaseOptions interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsBaseOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [namespace](./kibana-plugin-server.savedobjectsbaseoptions.namespace.md) | string
| Specify the namespace for this operation |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbaseoptions.namespace.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbaseoptions.namespace.md
new file mode 100644
index 0000000000000..6e921dc8ab60e
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbaseoptions.namespace.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md) > [namespace](./kibana-plugin-server.savedobjectsbaseoptions.namespace.md)
+
+## SavedObjectsBaseOptions.namespace property
+
+Specify the namespace for this operation
+
+Signature:
+
+```typescript
+namespace?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md
new file mode 100644
index 0000000000000..cfa19c5fb3fd8
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) > [attributes](./kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md)
+
+## SavedObjectsBulkCreateObject.attributes property
+
+Signature:
+
+```typescript
+attributes: T;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.id.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.id.md
new file mode 100644
index 0000000000000..6b8b65339ffa3
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.id.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) > [id](./kibana-plugin-server.savedobjectsbulkcreateobject.id.md)
+
+## SavedObjectsBulkCreateObject.id property
+
+Signature:
+
+```typescript
+id?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.md
new file mode 100644
index 0000000000000..056de4b634b50
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md)
+
+## SavedObjectsBulkCreateObject interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsBulkCreateObject
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [attributes](./kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md) | T
| |
+| [id](./kibana-plugin-server.savedobjectsbulkcreateobject.id.md) | string
| |
+| [migrationVersion](./kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md) | SavedObjectsMigrationVersion
| |
+| [references](./kibana-plugin-server.savedobjectsbulkcreateobject.references.md) | SavedObjectReference[]
| |
+| [type](./kibana-plugin-server.savedobjectsbulkcreateobject.type.md) | string
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md
new file mode 100644
index 0000000000000..9b33ab9a1b077
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) > [migrationVersion](./kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md)
+
+## SavedObjectsBulkCreateObject.migrationVersion property
+
+Signature:
+
+```typescript
+migrationVersion?: SavedObjectsMigrationVersion;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.references.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.references.md
new file mode 100644
index 0000000000000..0a96787de03a9
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.references.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) > [references](./kibana-plugin-server.savedobjectsbulkcreateobject.references.md)
+
+## SavedObjectsBulkCreateObject.references property
+
+Signature:
+
+```typescript
+references?: SavedObjectReference[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.type.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.type.md
new file mode 100644
index 0000000000000..8db44a46d7f3f
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkcreateobject.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) > [type](./kibana-plugin-server.savedobjectsbulkcreateobject.type.md)
+
+## SavedObjectsBulkCreateObject.type property
+
+Signature:
+
+```typescript
+type: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.fields.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.fields.md
new file mode 100644
index 0000000000000..d67df82b123e7
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.fields.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) > [fields](./kibana-plugin-server.savedobjectsbulkgetobject.fields.md)
+
+## SavedObjectsBulkGetObject.fields property
+
+SavedObject fields to include in the response
+
+Signature:
+
+```typescript
+fields?: string[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.id.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.id.md
new file mode 100644
index 0000000000000..3476d3276181c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.id.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) > [id](./kibana-plugin-server.savedobjectsbulkgetobject.id.md)
+
+## SavedObjectsBulkGetObject.id property
+
+Signature:
+
+```typescript
+id: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.md
new file mode 100644
index 0000000000000..ae89f30b9f754
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md)
+
+## SavedObjectsBulkGetObject interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsBulkGetObject
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [fields](./kibana-plugin-server.savedobjectsbulkgetobject.fields.md) | string[]
| SavedObject fields to include in the response |
+| [id](./kibana-plugin-server.savedobjectsbulkgetobject.id.md) | string
| |
+| [type](./kibana-plugin-server.savedobjectsbulkgetobject.type.md) | string
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.type.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.type.md
new file mode 100644
index 0000000000000..c3fef3704faa7
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkgetobject.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) > [type](./kibana-plugin-server.savedobjectsbulkgetobject.type.md)
+
+## SavedObjectsBulkGetObject.type property
+
+Signature:
+
+```typescript
+type: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkresponse.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkresponse.md
new file mode 100644
index 0000000000000..7ff4934a2af66
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkresponse.md
@@ -0,0 +1,19 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md)
+
+## SavedObjectsBulkResponse interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsBulkResponse
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [saved\_objects](./kibana-plugin-server.savedobjectsbulkresponse.saved_objects.md) | Array<SavedObject<T>>
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsbulkresponse.saved_objects.md b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkresponse.saved_objects.md
new file mode 100644
index 0000000000000..78f0fe36eaedc
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsbulkresponse.saved_objects.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md) > [saved\_objects](./kibana-plugin-server.savedobjectsbulkresponse.saved_objects.md)
+
+## SavedObjectsBulkResponse.saved\_objects property
+
+Signature:
+
+```typescript
+saved_objects: Array>;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsclientcontract.md b/docs/development/core/server/kibana-plugin-server.savedobjectsclientcontract.md
new file mode 100644
index 0000000000000..3603904c2f89c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsclientcontract.md
@@ -0,0 +1,41 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md)
+
+## SavedObjectsClientContract type
+
+\#\# SavedObjectsClient errors
+
+Since 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 index
+
+From 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 index
+
+Unlike 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 [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md)
+
+Signature:
+
+```typescript
+export declare type SavedObjectsClientContract = Pick;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.id.md b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.id.md
new file mode 100644
index 0000000000000..1c55342bb0430
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.id.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) > [id](./kibana-plugin-server.savedobjectscreateoptions.id.md)
+
+## SavedObjectsCreateOptions.id property
+
+(not recommended) Specify an id for the document
+
+Signature:
+
+```typescript
+id?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.md b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.md
new file mode 100644
index 0000000000000..61d65bfbf7b90
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md)
+
+## SavedObjectsCreateOptions interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [id](./kibana-plugin-server.savedobjectscreateoptions.id.md) | string
| (not recommended) Specify an id for the document |
+| [migrationVersion](./kibana-plugin-server.savedobjectscreateoptions.migrationversion.md) | SavedObjectsMigrationVersion
| |
+| [overwrite](./kibana-plugin-server.savedobjectscreateoptions.overwrite.md) | boolean
| Overwrite existing documents (defaults to false) |
+| [references](./kibana-plugin-server.savedobjectscreateoptions.references.md) | SavedObjectReference[]
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.migrationversion.md b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.migrationversion.md
new file mode 100644
index 0000000000000..fcbec639312e6
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.migrationversion.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) > [migrationVersion](./kibana-plugin-server.savedobjectscreateoptions.migrationversion.md)
+
+## SavedObjectsCreateOptions.migrationVersion property
+
+Signature:
+
+```typescript
+migrationVersion?: SavedObjectsMigrationVersion;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.overwrite.md b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.overwrite.md
new file mode 100644
index 0000000000000..cb58e87795300
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.overwrite.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) > [overwrite](./kibana-plugin-server.savedobjectscreateoptions.overwrite.md)
+
+## SavedObjectsCreateOptions.overwrite property
+
+Overwrite existing documents (defaults to false)
+
+Signature:
+
+```typescript
+overwrite?: boolean;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.references.md b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.references.md
new file mode 100644
index 0000000000000..bdf88b021c06c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectscreateoptions.references.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) > [references](./kibana-plugin-server.savedobjectscreateoptions.references.md)
+
+## SavedObjectsCreateOptions.references property
+
+Signature:
+
+```typescript
+references?: SavedObjectReference[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createbadrequesterror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createbadrequesterror.md
new file mode 100644
index 0000000000000..03ad9d29c1cc3
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createbadrequesterror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [createBadRequestError](./kibana-plugin-server.savedobjectserrorhelpers.createbadrequesterror.md)
+
+## SavedObjectsErrorHelpers.createBadRequestError() method
+
+Signature:
+
+```typescript
+static createBadRequestError(reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createesautocreateindexerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createesautocreateindexerror.md
new file mode 100644
index 0000000000000..62cec4bfa38fc
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createesautocreateindexerror.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [createEsAutoCreateIndexError](./kibana-plugin-server.savedobjectserrorhelpers.createesautocreateindexerror.md)
+
+## SavedObjectsErrorHelpers.createEsAutoCreateIndexError() method
+
+Signature:
+
+```typescript
+static createEsAutoCreateIndexError(): DecoratedError;
+```
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.creategenericnotfounderror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.creategenericnotfounderror.md
new file mode 100644
index 0000000000000..1abe1cf0067ec
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.creategenericnotfounderror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [createGenericNotFoundError](./kibana-plugin-server.savedobjectserrorhelpers.creategenericnotfounderror.md)
+
+## SavedObjectsErrorHelpers.createGenericNotFoundError() method
+
+Signature:
+
+```typescript
+static createGenericNotFoundError(type?: string | null, id?: string | null): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| type | string | null
| |
+| id | string | null
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createinvalidversionerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createinvalidversionerror.md
new file mode 100644
index 0000000000000..fc65c93fde946
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createinvalidversionerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [createInvalidVersionError](./kibana-plugin-server.savedobjectserrorhelpers.createinvalidversionerror.md)
+
+## SavedObjectsErrorHelpers.createInvalidVersionError() method
+
+Signature:
+
+```typescript
+static createInvalidVersionError(versionInput?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| versionInput | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createunsupportedtypeerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createunsupportedtypeerror.md
new file mode 100644
index 0000000000000..1b22f86df6796
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.createunsupportedtypeerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [createUnsupportedTypeError](./kibana-plugin-server.savedobjectserrorhelpers.createunsupportedtypeerror.md)
+
+## SavedObjectsErrorHelpers.createUnsupportedTypeError() method
+
+Signature:
+
+```typescript
+static createUnsupportedTypeError(type: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| type | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoratebadrequesterror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoratebadrequesterror.md
new file mode 100644
index 0000000000000..deccee473eaa4
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoratebadrequesterror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateBadRequestError](./kibana-plugin-server.savedobjectserrorhelpers.decoratebadrequesterror.md)
+
+## SavedObjectsErrorHelpers.decorateBadRequestError() method
+
+Signature:
+
+```typescript
+static decorateBadRequestError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateconflicterror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateconflicterror.md
new file mode 100644
index 0000000000000..ac999903d3a21
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateconflicterror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateConflictError](./kibana-plugin-server.savedobjectserrorhelpers.decorateconflicterror.md)
+
+## SavedObjectsErrorHelpers.decorateConflictError() method
+
+Signature:
+
+```typescript
+static decorateConflictError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateesunavailableerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateesunavailableerror.md
new file mode 100644
index 0000000000000..54a420913390b
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateesunavailableerror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateEsUnavailableError](./kibana-plugin-server.savedobjectserrorhelpers.decorateesunavailableerror.md)
+
+## SavedObjectsErrorHelpers.decorateEsUnavailableError() method
+
+Signature:
+
+```typescript
+static decorateEsUnavailableError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateforbiddenerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateforbiddenerror.md
new file mode 100644
index 0000000000000..c5130dfb12400
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorateforbiddenerror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateForbiddenError](./kibana-plugin-server.savedobjectserrorhelpers.decorateforbiddenerror.md)
+
+## SavedObjectsErrorHelpers.decorateForbiddenError() method
+
+Signature:
+
+```typescript
+static decorateForbiddenError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorategeneralerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorategeneralerror.md
new file mode 100644
index 0000000000000..6086df058483f
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decorategeneralerror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateGeneralError](./kibana-plugin-server.savedobjectserrorhelpers.decorategeneralerror.md)
+
+## SavedObjectsErrorHelpers.decorateGeneralError() method
+
+Signature:
+
+```typescript
+static decorateGeneralError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoratenotauthorizederror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoratenotauthorizederror.md
new file mode 100644
index 0000000000000..3977b58c945bc
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoratenotauthorizederror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateNotAuthorizedError](./kibana-plugin-server.savedobjectserrorhelpers.decoratenotauthorizederror.md)
+
+## SavedObjectsErrorHelpers.decorateNotAuthorizedError() method
+
+Signature:
+
+```typescript
+static decorateNotAuthorizedError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoraterequestentitytoolargeerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoraterequestentitytoolargeerror.md
new file mode 100644
index 0000000000000..58cba64fd3139
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.decoraterequestentitytoolargeerror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [decorateRequestEntityTooLargeError](./kibana-plugin-server.savedobjectserrorhelpers.decoraterequestentitytoolargeerror.md)
+
+## SavedObjectsErrorHelpers.decorateRequestEntityTooLargeError() method
+
+Signature:
+
+```typescript
+static decorateRequestEntityTooLargeError(error: Error, reason?: string): DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error
| |
+| reason | string
| |
+
+Returns:
+
+`DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isbadrequesterror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isbadrequesterror.md
new file mode 100644
index 0000000000000..79805e371884d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isbadrequesterror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isBadRequestError](./kibana-plugin-server.savedobjectserrorhelpers.isbadrequesterror.md)
+
+## SavedObjectsErrorHelpers.isBadRequestError() method
+
+Signature:
+
+```typescript
+static isBadRequestError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isconflicterror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isconflicterror.md
new file mode 100644
index 0000000000000..99e636bf006ad
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isconflicterror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isConflictError](./kibana-plugin-server.savedobjectserrorhelpers.isconflicterror.md)
+
+## SavedObjectsErrorHelpers.isConflictError() method
+
+Signature:
+
+```typescript
+static isConflictError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isesautocreateindexerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isesautocreateindexerror.md
new file mode 100644
index 0000000000000..37b845d336203
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isesautocreateindexerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isEsAutoCreateIndexError](./kibana-plugin-server.savedobjectserrorhelpers.isesautocreateindexerror.md)
+
+## SavedObjectsErrorHelpers.isEsAutoCreateIndexError() method
+
+Signature:
+
+```typescript
+static isEsAutoCreateIndexError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isesunavailableerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isesunavailableerror.md
new file mode 100644
index 0000000000000..0672c92a0c80f
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isesunavailableerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isEsUnavailableError](./kibana-plugin-server.savedobjectserrorhelpers.isesunavailableerror.md)
+
+## SavedObjectsErrorHelpers.isEsUnavailableError() method
+
+Signature:
+
+```typescript
+static isEsUnavailableError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isforbiddenerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isforbiddenerror.md
new file mode 100644
index 0000000000000..6350de9b6403c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isforbiddenerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isForbiddenError](./kibana-plugin-server.savedobjectserrorhelpers.isforbiddenerror.md)
+
+## SavedObjectsErrorHelpers.isForbiddenError() method
+
+Signature:
+
+```typescript
+static isForbiddenError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isinvalidversionerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isinvalidversionerror.md
new file mode 100644
index 0000000000000..c91056b92e456
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isinvalidversionerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isInvalidVersionError](./kibana-plugin-server.savedobjectserrorhelpers.isinvalidversionerror.md)
+
+## SavedObjectsErrorHelpers.isInvalidVersionError() method
+
+Signature:
+
+```typescript
+static isInvalidVersionError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isnotauthorizederror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isnotauthorizederror.md
new file mode 100644
index 0000000000000..6cedc87f52db9
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isnotauthorizederror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isNotAuthorizedError](./kibana-plugin-server.savedobjectserrorhelpers.isnotauthorizederror.md)
+
+## SavedObjectsErrorHelpers.isNotAuthorizedError() method
+
+Signature:
+
+```typescript
+static isNotAuthorizedError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isnotfounderror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isnotfounderror.md
new file mode 100644
index 0000000000000..125730454e4d0
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isnotfounderror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isNotFoundError](./kibana-plugin-server.savedobjectserrorhelpers.isnotfounderror.md)
+
+## SavedObjectsErrorHelpers.isNotFoundError() method
+
+Signature:
+
+```typescript
+static isNotFoundError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isrequestentitytoolargeerror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isrequestentitytoolargeerror.md
new file mode 100644
index 0000000000000..63a8862a6d84c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.isrequestentitytoolargeerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isRequestEntityTooLargeError](./kibana-plugin-server.savedobjectserrorhelpers.isrequestentitytoolargeerror.md)
+
+## SavedObjectsErrorHelpers.isRequestEntityTooLargeError() method
+
+Signature:
+
+```typescript
+static isRequestEntityTooLargeError(error: Error | DecoratedError): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | DecoratedError
| |
+
+Returns:
+
+`boolean`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.issavedobjectsclienterror.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.issavedobjectsclienterror.md
new file mode 100644
index 0000000000000..8e22e2df805f8
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.issavedobjectsclienterror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) > [isSavedObjectsClientError](./kibana-plugin-server.savedobjectserrorhelpers.issavedobjectsclienterror.md)
+
+## SavedObjectsErrorHelpers.isSavedObjectsClientError() method
+
+Signature:
+
+```typescript
+static isSavedObjectsClientError(error: any): error is DecoratedError;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | any
| |
+
+Returns:
+
+`error is DecoratedError`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.md b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.md
new file mode 100644
index 0000000000000..ffa4b06028c2a
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectserrorhelpers.md
@@ -0,0 +1,40 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md)
+
+## SavedObjectsErrorHelpers class
+
+
+Signature:
+
+```typescript
+export declare class SavedObjectsErrorHelpers
+```
+
+## Methods
+
+| Method | Modifiers | Description |
+| --- | --- | --- |
+| [createBadRequestError(reason)](./kibana-plugin-server.savedobjectserrorhelpers.createbadrequesterror.md) | static
| |
+| [createEsAutoCreateIndexError()](./kibana-plugin-server.savedobjectserrorhelpers.createesautocreateindexerror.md) | static
| |
+| [createGenericNotFoundError(type, id)](./kibana-plugin-server.savedobjectserrorhelpers.creategenericnotfounderror.md) | static
| |
+| [createInvalidVersionError(versionInput)](./kibana-plugin-server.savedobjectserrorhelpers.createinvalidversionerror.md) | static
| |
+| [createUnsupportedTypeError(type)](./kibana-plugin-server.savedobjectserrorhelpers.createunsupportedtypeerror.md) | static
| |
+| [decorateBadRequestError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decoratebadrequesterror.md) | static
| |
+| [decorateConflictError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decorateconflicterror.md) | static
| |
+| [decorateEsUnavailableError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decorateesunavailableerror.md) | static
| |
+| [decorateForbiddenError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decorateforbiddenerror.md) | static
| |
+| [decorateGeneralError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decorategeneralerror.md) | static
| |
+| [decorateNotAuthorizedError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decoratenotauthorizederror.md) | static
| |
+| [decorateRequestEntityTooLargeError(error, reason)](./kibana-plugin-server.savedobjectserrorhelpers.decoraterequestentitytoolargeerror.md) | static
| |
+| [isBadRequestError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isbadrequesterror.md) | static
| |
+| [isConflictError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isconflicterror.md) | static
| |
+| [isEsAutoCreateIndexError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isesautocreateindexerror.md) | static
| |
+| [isEsUnavailableError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isesunavailableerror.md) | static
| |
+| [isForbiddenError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isforbiddenerror.md) | static
| |
+| [isInvalidVersionError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isinvalidversionerror.md) | static
| |
+| [isNotAuthorizedError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isnotauthorizederror.md) | static
| |
+| [isNotFoundError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isnotfounderror.md) | static
| |
+| [isRequestEntityTooLargeError(error)](./kibana-plugin-server.savedobjectserrorhelpers.isrequestentitytoolargeerror.md) | static
| |
+| [isSavedObjectsClientError(error)](./kibana-plugin-server.savedobjectserrorhelpers.issavedobjectsclienterror.md) | static
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.defaultsearchoperator.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.defaultsearchoperator.md
new file mode 100644
index 0000000000000..c3b7f35e351ff
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.defaultsearchoperator.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [defaultSearchOperator](./kibana-plugin-server.savedobjectsfindoptions.defaultsearchoperator.md)
+
+## SavedObjectsFindOptions.defaultSearchOperator property
+
+Signature:
+
+```typescript
+defaultSearchOperator?: 'AND' | 'OR';
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.fields.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.fields.md
new file mode 100644
index 0000000000000..6d2cac4f14439
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.fields.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [fields](./kibana-plugin-server.savedobjectsfindoptions.fields.md)
+
+## SavedObjectsFindOptions.fields property
+
+Signature:
+
+```typescript
+fields?: string[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.hasreference.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.hasreference.md
new file mode 100644
index 0000000000000..01d20d898c1ef
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.hasreference.md
@@ -0,0 +1,14 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [hasReference](./kibana-plugin-server.savedobjectsfindoptions.hasreference.md)
+
+## SavedObjectsFindOptions.hasReference property
+
+Signature:
+
+```typescript
+hasReference?: {
+ type: string;
+ id: string;
+ };
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.md
new file mode 100644
index 0000000000000..140b447c0002a
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.md
@@ -0,0 +1,28 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md)
+
+## SavedObjectsFindOptions interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [defaultSearchOperator](./kibana-plugin-server.savedobjectsfindoptions.defaultsearchoperator.md) | 'AND' | 'OR'
| |
+| [fields](./kibana-plugin-server.savedobjectsfindoptions.fields.md) | string[]
| |
+| [hasReference](./kibana-plugin-server.savedobjectsfindoptions.hasreference.md) | {
type: string;
id: string;
}
| |
+| [page](./kibana-plugin-server.savedobjectsfindoptions.page.md) | number
| |
+| [perPage](./kibana-plugin-server.savedobjectsfindoptions.perpage.md) | number
| |
+| [search](./kibana-plugin-server.savedobjectsfindoptions.search.md) | string
| |
+| [searchFields](./kibana-plugin-server.savedobjectsfindoptions.searchfields.md) | string[]
| see Elasticsearch Simple Query String Query field argument for more information |
+| [sortField](./kibana-plugin-server.savedobjectsfindoptions.sortfield.md) | string
| |
+| [sortOrder](./kibana-plugin-server.savedobjectsfindoptions.sortorder.md) | string
| |
+| [type](./kibana-plugin-server.savedobjectsfindoptions.type.md) | string | string[]
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.page.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.page.md
new file mode 100644
index 0000000000000..ab6faaf6649ee
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.page.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [page](./kibana-plugin-server.savedobjectsfindoptions.page.md)
+
+## SavedObjectsFindOptions.page property
+
+Signature:
+
+```typescript
+page?: number;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.perpage.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.perpage.md
new file mode 100644
index 0000000000000..f775aa450b93a
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.perpage.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [perPage](./kibana-plugin-server.savedobjectsfindoptions.perpage.md)
+
+## SavedObjectsFindOptions.perPage property
+
+Signature:
+
+```typescript
+perPage?: number;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.search.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.search.md
new file mode 100644
index 0000000000000..7dca45e58123f
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.search.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [search](./kibana-plugin-server.savedobjectsfindoptions.search.md)
+
+## SavedObjectsFindOptions.search property
+
+Signature:
+
+```typescript
+search?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.searchfields.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.searchfields.md
new file mode 100644
index 0000000000000..fdd157299c144
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.searchfields.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [searchFields](./kibana-plugin-server.savedobjectsfindoptions.searchfields.md)
+
+## SavedObjectsFindOptions.searchFields property
+
+see Elasticsearch Simple Query String Query field argument for more information
+
+Signature:
+
+```typescript
+searchFields?: string[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.sortfield.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.sortfield.md
new file mode 100644
index 0000000000000..3ba2916c3b068
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.sortfield.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [sortField](./kibana-plugin-server.savedobjectsfindoptions.sortfield.md)
+
+## SavedObjectsFindOptions.sortField property
+
+Signature:
+
+```typescript
+sortField?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.sortorder.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.sortorder.md
new file mode 100644
index 0000000000000..bae922313db34
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.sortorder.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [sortOrder](./kibana-plugin-server.savedobjectsfindoptions.sortorder.md)
+
+## SavedObjectsFindOptions.sortOrder property
+
+Signature:
+
+```typescript
+sortOrder?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.type.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.type.md
new file mode 100644
index 0000000000000..f22eca5e1474c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) > [type](./kibana-plugin-server.savedobjectsfindoptions.type.md)
+
+## SavedObjectsFindOptions.type property
+
+Signature:
+
+```typescript
+type?: string | string[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.md
new file mode 100644
index 0000000000000..e4f7d15042985
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md)
+
+## SavedObjectsFindResponse interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsFindResponse
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [page](./kibana-plugin-server.savedobjectsfindresponse.page.md) | number
| |
+| [per\_page](./kibana-plugin-server.savedobjectsfindresponse.per_page.md) | number
| |
+| [saved\_objects](./kibana-plugin-server.savedobjectsfindresponse.saved_objects.md) | Array<SavedObject<T>>
| |
+| [total](./kibana-plugin-server.savedobjectsfindresponse.total.md) | number
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.page.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.page.md
new file mode 100644
index 0000000000000..82cd16cd7b48a
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.page.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) > [page](./kibana-plugin-server.savedobjectsfindresponse.page.md)
+
+## SavedObjectsFindResponse.page property
+
+Signature:
+
+```typescript
+page: number;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.per_page.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.per_page.md
new file mode 100644
index 0000000000000..d93b302488382
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.per_page.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) > [per\_page](./kibana-plugin-server.savedobjectsfindresponse.per_page.md)
+
+## SavedObjectsFindResponse.per\_page property
+
+Signature:
+
+```typescript
+per_page: number;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.saved_objects.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.saved_objects.md
new file mode 100644
index 0000000000000..9e4247be4e02d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.saved_objects.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) > [saved\_objects](./kibana-plugin-server.savedobjectsfindresponse.saved_objects.md)
+
+## SavedObjectsFindResponse.saved\_objects property
+
+Signature:
+
+```typescript
+saved_objects: Array>;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.total.md b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.total.md
new file mode 100644
index 0000000000000..12e86e8d3a4e7
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsfindresponse.total.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) > [total](./kibana-plugin-server.savedobjectsfindresponse.total.md)
+
+## SavedObjectsFindResponse.total property
+
+Signature:
+
+```typescript
+total: number;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsmigrationversion.md b/docs/development/core/server/kibana-plugin-server.savedobjectsmigrationversion.md
new file mode 100644
index 0000000000000..434e46041cf7d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsmigrationversion.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md)
+
+## SavedObjectsMigrationVersion interface
+
+A dictionary of saved object type -> version used to determine what migrations need to be applied to a saved object.
+
+Signature:
+
+```typescript
+export interface SavedObjectsMigrationVersion
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservice.addscopedsavedobjectsclientwrapperfactory.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.addscopedsavedobjectsclientwrapperfactory.md
new file mode 100644
index 0000000000000..6e0d1a827750c
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.addscopedsavedobjectsclientwrapperfactory.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [addScopedSavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsservice.addscopedsavedobjectsclientwrapperfactory.md)
+
+## SavedObjectsService.addScopedSavedObjectsClientWrapperFactory property
+
+Signature:
+
+```typescript
+addScopedSavedObjectsClientWrapperFactory: ScopedSavedObjectsClientProvider['addClientWrapperFactory'];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservice.getsavedobjectsrepository.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.getsavedobjectsrepository.md
new file mode 100644
index 0000000000000..13ccad7ed01ae
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.getsavedobjectsrepository.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [getSavedObjectsRepository](./kibana-plugin-server.savedobjectsservice.getsavedobjectsrepository.md)
+
+## SavedObjectsService.getSavedObjectsRepository() method
+
+Signature:
+
+```typescript
+getSavedObjectsRepository(...rest: any[]): any;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| rest | any[]
| |
+
+Returns:
+
+`any`
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservice.getscopedsavedobjectsclient.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.getscopedsavedobjectsclient.md
new file mode 100644
index 0000000000000..c762de041edf5
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.getscopedsavedobjectsclient.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [getScopedSavedObjectsClient](./kibana-plugin-server.savedobjectsservice.getscopedsavedobjectsclient.md)
+
+## SavedObjectsService.getScopedSavedObjectsClient property
+
+Signature:
+
+```typescript
+getScopedSavedObjectsClient: ScopedSavedObjectsClientProvider['getClient'];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservice.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.md
new file mode 100644
index 0000000000000..ad281002854b3
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.md
@@ -0,0 +1,28 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md)
+
+## SavedObjectsService interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsService
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [addScopedSavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsservice.addscopedsavedobjectsclientwrapperfactory.md) | ScopedSavedObjectsClientProvider<Request>['addClientWrapperFactory']
| |
+| [getScopedSavedObjectsClient](./kibana-plugin-server.savedobjectsservice.getscopedsavedobjectsclient.md) | ScopedSavedObjectsClientProvider<Request>['getClient']
| |
+| [SavedObjectsClient](./kibana-plugin-server.savedobjectsservice.savedobjectsclient.md) | typeof SavedObjectsClient
| |
+| [types](./kibana-plugin-server.savedobjectsservice.types.md) | string[]
| |
+
+## Methods
+
+| Method | Description |
+| --- | --- |
+| [getSavedObjectsRepository(rest)](./kibana-plugin-server.savedobjectsservice.getsavedobjectsrepository.md) | |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservice.savedobjectsclient.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.savedobjectsclient.md
new file mode 100644
index 0000000000000..4a7722928e85e
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.savedobjectsclient.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [SavedObjectsClient](./kibana-plugin-server.savedobjectsservice.savedobjectsclient.md)
+
+## SavedObjectsService.SavedObjectsClient property
+
+Signature:
+
+```typescript
+SavedObjectsClient: typeof SavedObjectsClient;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsservice.types.md b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.types.md
new file mode 100644
index 0000000000000..a783ef4270f18
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsservice.types.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [types](./kibana-plugin-server.savedobjectsservice.types.md)
+
+## SavedObjectsService.types property
+
+Signature:
+
+```typescript
+types: string[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.md b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.md
new file mode 100644
index 0000000000000..577fd632be9cb
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md)
+
+## SavedObjectsUpdateOptions interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsUpdateOptions extends SavedObjectsBaseOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [references](./kibana-plugin-server.savedobjectsupdateoptions.references.md) | SavedObjectReference[]
| |
+| [version](./kibana-plugin-server.savedobjectsupdateoptions.version.md) | string
| Ensures version matches that of persisted object |
+
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.references.md b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.references.md
new file mode 100644
index 0000000000000..500be57041756
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.references.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) > [references](./kibana-plugin-server.savedobjectsupdateoptions.references.md)
+
+## SavedObjectsUpdateOptions.references property
+
+Signature:
+
+```typescript
+references?: SavedObjectReference[];
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.version.md b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.version.md
new file mode 100644
index 0000000000000..8461181222238
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateoptions.version.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) > [version](./kibana-plugin-server.savedobjectsupdateoptions.version.md)
+
+## SavedObjectsUpdateOptions.version property
+
+Ensures version matches that of persisted object
+
+Signature:
+
+```typescript
+version?: string;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsupdateresponse.attributes.md b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateresponse.attributes.md
new file mode 100644
index 0000000000000..7d1edb3bb6594
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateresponse.attributes.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) > [attributes](./kibana-plugin-server.savedobjectsupdateresponse.attributes.md)
+
+## SavedObjectsUpdateResponse.attributes property
+
+Signature:
+
+```typescript
+attributes: Partial;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.savedobjectsupdateresponse.md b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateresponse.md
new file mode 100644
index 0000000000000..c49f391df986d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.savedobjectsupdateresponse.md
@@ -0,0 +1,19 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md)
+
+## SavedObjectsUpdateResponse interface
+
+
+Signature:
+
+```typescript
+export interface SavedObjectsUpdateResponse extends Omit, 'attributes'>
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [attributes](./kibana-plugin-server.savedobjectsupdateresponse.attributes.md) | Partial<T>
| |
+
diff --git a/src/core/server/index.ts b/src/core/server/index.ts
index f901b25e1ae87..78fae75bf986a 100644
--- a/src/core/server/index.ts
+++ b/src/core/server/index.ts
@@ -75,6 +75,26 @@ export {
PluginName,
} from './plugins';
+export {
+ SavedObject,
+ SavedObjectAttributes,
+ SavedObjectReference,
+ SavedObjectsBaseOptions,
+ SavedObjectsBulkCreateObject,
+ SavedObjectsBulkGetObject,
+ SavedObjectsBulkResponse,
+ SavedObjectsClient,
+ SavedObjectsClientContract,
+ SavedObjectsCreateOptions,
+ SavedObjectsErrorHelpers,
+ SavedObjectsFindOptions,
+ SavedObjectsFindResponse,
+ SavedObjectsMigrationVersion,
+ SavedObjectsService,
+ SavedObjectsUpdateOptions,
+ SavedObjectsUpdateResponse,
+} from './saved_objects';
+
export { RecursiveReadonly } from '../utils';
/**
diff --git a/src/legacy/server/saved_objects/export/get_sorted_objects_for_export.test.ts b/src/core/server/saved_objects/export/get_sorted_objects_for_export.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/get_sorted_objects_for_export.test.ts
rename to src/core/server/saved_objects/export/get_sorted_objects_for_export.test.ts
diff --git a/src/legacy/server/saved_objects/export/get_sorted_objects_for_export.ts b/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/get_sorted_objects_for_export.ts
rename to src/core/server/saved_objects/export/get_sorted_objects_for_export.ts
diff --git a/src/legacy/server/saved_objects/export/index.ts b/src/core/server/saved_objects/export/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/index.ts
rename to src/core/server/saved_objects/export/index.ts
diff --git a/src/legacy/server/saved_objects/export/inject_nested_depdendencies.test.ts b/src/core/server/saved_objects/export/inject_nested_depdendencies.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/inject_nested_depdendencies.test.ts
rename to src/core/server/saved_objects/export/inject_nested_depdendencies.test.ts
diff --git a/src/legacy/server/saved_objects/export/inject_nested_depdendencies.ts b/src/core/server/saved_objects/export/inject_nested_depdendencies.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/inject_nested_depdendencies.ts
rename to src/core/server/saved_objects/export/inject_nested_depdendencies.ts
diff --git a/src/legacy/server/saved_objects/export/sort_objects.test.ts b/src/core/server/saved_objects/export/sort_objects.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/sort_objects.test.ts
rename to src/core/server/saved_objects/export/sort_objects.test.ts
diff --git a/src/legacy/server/saved_objects/export/sort_objects.ts b/src/core/server/saved_objects/export/sort_objects.ts
similarity index 100%
rename from src/legacy/server/saved_objects/export/sort_objects.ts
rename to src/core/server/saved_objects/export/sort_objects.ts
diff --git a/src/legacy/server/saved_objects/import/collect_saved_objects.test.ts b/src/core/server/saved_objects/import/collect_saved_objects.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/collect_saved_objects.test.ts
rename to src/core/server/saved_objects/import/collect_saved_objects.test.ts
diff --git a/src/legacy/server/saved_objects/import/collect_saved_objects.ts b/src/core/server/saved_objects/import/collect_saved_objects.ts
similarity index 98%
rename from src/legacy/server/saved_objects/import/collect_saved_objects.ts
rename to src/core/server/saved_objects/import/collect_saved_objects.ts
index 95e32528149f8..3445fe9b42406 100644
--- a/src/legacy/server/saved_objects/import/collect_saved_objects.ts
+++ b/src/core/server/saved_objects/import/collect_saved_objects.ts
@@ -24,7 +24,7 @@ import {
createMapStream,
createPromiseFromStreams,
createSplitStream,
-} from '../../../utils/streams';
+} from '../../../../legacy/utils/streams';
import { SavedObject } from '../service';
import { createLimitStream } from './create_limit_stream';
import { ImportError } from './types';
diff --git a/src/legacy/server/saved_objects/import/create_limit_stream.test.ts b/src/core/server/saved_objects/import/create_limit_stream.test.ts
similarity index 97%
rename from src/legacy/server/saved_objects/import/create_limit_stream.test.ts
rename to src/core/server/saved_objects/import/create_limit_stream.test.ts
index ece1de2da752b..736cfadcb6222 100644
--- a/src/legacy/server/saved_objects/import/create_limit_stream.test.ts
+++ b/src/core/server/saved_objects/import/create_limit_stream.test.ts
@@ -21,7 +21,7 @@ import {
createConcatStream,
createListStream,
createPromiseFromStreams,
-} from '../../../utils/streams';
+} from '../../../../legacy/utils/streams';
import { createLimitStream } from './create_limit_stream';
describe('createLimitStream()', () => {
diff --git a/src/legacy/server/saved_objects/import/create_limit_stream.ts b/src/core/server/saved_objects/import/create_limit_stream.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/create_limit_stream.ts
rename to src/core/server/saved_objects/import/create_limit_stream.ts
diff --git a/src/legacy/server/saved_objects/import/create_objects_filter.test.ts b/src/core/server/saved_objects/import/create_objects_filter.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/create_objects_filter.test.ts
rename to src/core/server/saved_objects/import/create_objects_filter.test.ts
diff --git a/src/legacy/server/saved_objects/import/create_objects_filter.ts b/src/core/server/saved_objects/import/create_objects_filter.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/create_objects_filter.ts
rename to src/core/server/saved_objects/import/create_objects_filter.ts
diff --git a/src/legacy/server/saved_objects/import/extract_errors.test.ts b/src/core/server/saved_objects/import/extract_errors.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/extract_errors.test.ts
rename to src/core/server/saved_objects/import/extract_errors.test.ts
diff --git a/src/legacy/server/saved_objects/import/extract_errors.ts b/src/core/server/saved_objects/import/extract_errors.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/extract_errors.ts
rename to src/core/server/saved_objects/import/extract_errors.ts
diff --git a/src/legacy/server/saved_objects/import/import_saved_objects.test.ts b/src/core/server/saved_objects/import/import_saved_objects.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/import_saved_objects.test.ts
rename to src/core/server/saved_objects/import/import_saved_objects.test.ts
diff --git a/src/legacy/server/saved_objects/import/import_saved_objects.ts b/src/core/server/saved_objects/import/import_saved_objects.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/import_saved_objects.ts
rename to src/core/server/saved_objects/import/import_saved_objects.ts
diff --git a/src/legacy/server/saved_objects/import/index.ts b/src/core/server/saved_objects/import/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/index.ts
rename to src/core/server/saved_objects/import/index.ts
diff --git a/src/legacy/server/saved_objects/import/resolve_import_errors.test.ts b/src/core/server/saved_objects/import/resolve_import_errors.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/resolve_import_errors.test.ts
rename to src/core/server/saved_objects/import/resolve_import_errors.test.ts
diff --git a/src/legacy/server/saved_objects/import/resolve_import_errors.ts b/src/core/server/saved_objects/import/resolve_import_errors.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/resolve_import_errors.ts
rename to src/core/server/saved_objects/import/resolve_import_errors.ts
diff --git a/src/legacy/server/saved_objects/import/split_overwrites.test.ts b/src/core/server/saved_objects/import/split_overwrites.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/split_overwrites.test.ts
rename to src/core/server/saved_objects/import/split_overwrites.test.ts
diff --git a/src/legacy/server/saved_objects/import/split_overwrites.ts b/src/core/server/saved_objects/import/split_overwrites.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/split_overwrites.ts
rename to src/core/server/saved_objects/import/split_overwrites.ts
diff --git a/src/legacy/server/saved_objects/import/types.ts b/src/core/server/saved_objects/import/types.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/types.ts
rename to src/core/server/saved_objects/import/types.ts
diff --git a/src/legacy/server/saved_objects/import/validate_references.test.ts b/src/core/server/saved_objects/import/validate_references.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/validate_references.test.ts
rename to src/core/server/saved_objects/import/validate_references.test.ts
diff --git a/src/legacy/server/saved_objects/import/validate_references.ts b/src/core/server/saved_objects/import/validate_references.ts
similarity index 100%
rename from src/legacy/server/saved_objects/import/validate_references.ts
rename to src/core/server/saved_objects/import/validate_references.ts
diff --git a/src/legacy/server/saved_objects/index.ts b/src/core/server/saved_objects/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/index.ts
rename to src/core/server/saved_objects/index.ts
diff --git a/src/legacy/server/saved_objects/management/index.ts b/src/core/server/saved_objects/management/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/management/index.ts
rename to src/core/server/saved_objects/management/index.ts
diff --git a/src/legacy/server/saved_objects/management/management.mock.ts b/src/core/server/saved_objects/management/management.mock.ts
similarity index 100%
rename from src/legacy/server/saved_objects/management/management.mock.ts
rename to src/core/server/saved_objects/management/management.mock.ts
diff --git a/src/legacy/server/saved_objects/management/management.test.ts b/src/core/server/saved_objects/management/management.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/management/management.test.ts
rename to src/core/server/saved_objects/management/management.test.ts
diff --git a/src/legacy/server/saved_objects/management/management.ts b/src/core/server/saved_objects/management/management.ts
similarity index 100%
rename from src/legacy/server/saved_objects/management/management.ts
rename to src/core/server/saved_objects/management/management.ts
diff --git a/src/legacy/server/mappings/index.ts b/src/core/server/saved_objects/mappings/index.ts
similarity index 99%
rename from src/legacy/server/mappings/index.ts
rename to src/core/server/saved_objects/mappings/index.ts
index 40bc62d42cc23..0d3bfd00c415e 100644
--- a/src/legacy/server/mappings/index.ts
+++ b/src/core/server/saved_objects/mappings/index.ts
@@ -16,6 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-
export { getTypes, getProperty, getRootProperties, getRootPropertiesObjects } from './lib';
export { FieldMapping, MappingMeta, MappingProperties, IndexMapping } from './types';
diff --git a/src/legacy/server/mappings/lib/get_property.test.ts b/src/core/server/saved_objects/mappings/lib/get_property.test.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/get_property.test.ts
rename to src/core/server/saved_objects/mappings/lib/get_property.test.ts
diff --git a/src/legacy/server/mappings/lib/get_property.ts b/src/core/server/saved_objects/mappings/lib/get_property.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/get_property.ts
rename to src/core/server/saved_objects/mappings/lib/get_property.ts
diff --git a/src/legacy/server/mappings/lib/get_root_properties.ts b/src/core/server/saved_objects/mappings/lib/get_root_properties.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/get_root_properties.ts
rename to src/core/server/saved_objects/mappings/lib/get_root_properties.ts
diff --git a/src/legacy/server/mappings/lib/get_root_properties_objects.test.ts b/src/core/server/saved_objects/mappings/lib/get_root_properties_objects.test.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/get_root_properties_objects.test.ts
rename to src/core/server/saved_objects/mappings/lib/get_root_properties_objects.test.ts
diff --git a/src/legacy/server/mappings/lib/get_root_properties_objects.ts b/src/core/server/saved_objects/mappings/lib/get_root_properties_objects.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/get_root_properties_objects.ts
rename to src/core/server/saved_objects/mappings/lib/get_root_properties_objects.ts
diff --git a/src/legacy/server/mappings/lib/get_types.ts b/src/core/server/saved_objects/mappings/lib/get_types.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/get_types.ts
rename to src/core/server/saved_objects/mappings/lib/get_types.ts
diff --git a/src/legacy/server/mappings/lib/index.ts b/src/core/server/saved_objects/mappings/lib/index.ts
similarity index 100%
rename from src/legacy/server/mappings/lib/index.ts
rename to src/core/server/saved_objects/mappings/lib/index.ts
diff --git a/src/legacy/server/mappings/types.ts b/src/core/server/saved_objects/mappings/types.ts
similarity index 100%
rename from src/legacy/server/mappings/types.ts
rename to src/core/server/saved_objects/mappings/types.ts
diff --git a/src/legacy/server/saved_objects/migrations/README.md b/src/core/server/saved_objects/migrations/README.md
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/README.md
rename to src/core/server/saved_objects/migrations/README.md
diff --git a/src/legacy/server/saved_objects/migrations/core/__snapshots__/build_active_mappings.test.ts.snap b/src/core/server/saved_objects/migrations/core/__snapshots__/build_active_mappings.test.ts.snap
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/__snapshots__/build_active_mappings.test.ts.snap
rename to src/core/server/saved_objects/migrations/core/__snapshots__/build_active_mappings.test.ts.snap
diff --git a/src/legacy/server/saved_objects/migrations/core/__snapshots__/elastic_index.test.ts.snap b/src/core/server/saved_objects/migrations/core/__snapshots__/elastic_index.test.ts.snap
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/__snapshots__/elastic_index.test.ts.snap
rename to src/core/server/saved_objects/migrations/core/__snapshots__/elastic_index.test.ts.snap
diff --git a/src/legacy/server/saved_objects/migrations/core/build_active_mappings.test.ts b/src/core/server/saved_objects/migrations/core/build_active_mappings.test.ts
similarity index 99%
rename from src/legacy/server/saved_objects/migrations/core/build_active_mappings.test.ts
rename to src/core/server/saved_objects/migrations/core/build_active_mappings.test.ts
index d9baccfcadb80..71f589f24369a 100644
--- a/src/legacy/server/saved_objects/migrations/core/build_active_mappings.test.ts
+++ b/src/core/server/saved_objects/migrations/core/build_active_mappings.test.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IndexMapping } from './../../../mappings';
+import { IndexMapping } from './../../mappings';
import { buildActiveMappings, diffMappings } from './build_active_mappings';
describe('buildActiveMappings', () => {
diff --git a/src/legacy/server/saved_objects/migrations/core/build_active_mappings.ts b/src/core/server/saved_objects/migrations/core/build_active_mappings.ts
similarity index 98%
rename from src/legacy/server/saved_objects/migrations/core/build_active_mappings.ts
rename to src/core/server/saved_objects/migrations/core/build_active_mappings.ts
index f28da1c5db74a..2cf640cceea83 100644
--- a/src/legacy/server/saved_objects/migrations/core/build_active_mappings.ts
+++ b/src/core/server/saved_objects/migrations/core/build_active_mappings.ts
@@ -23,7 +23,7 @@
import crypto from 'crypto';
import _ from 'lodash';
-import { IndexMapping, MappingProperties } from './../../../mappings';
+import { IndexMapping, MappingProperties } from './../../mappings';
/**
* Creates an index mapping with the core properties required by saved object
diff --git a/src/legacy/server/saved_objects/migrations/core/build_index_map.ts b/src/core/server/saved_objects/migrations/core/build_index_map.ts
similarity index 95%
rename from src/legacy/server/saved_objects/migrations/core/build_index_map.ts
rename to src/core/server/saved_objects/migrations/core/build_index_map.ts
index 5c0f08bf4046b..365c79692ba0d 100644
--- a/src/legacy/server/saved_objects/migrations/core/build_index_map.ts
+++ b/src/core/server/saved_objects/migrations/core/build_index_map.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { MappingProperties } from 'src/legacy/server/mappings';
+import { MappingProperties } from '../../mappings';
import { SavedObjectsSchemaDefinition } from '../../schema';
/*
diff --git a/src/legacy/server/saved_objects/migrations/core/call_cluster.ts b/src/core/server/saved_objects/migrations/core/call_cluster.ts
similarity index 99%
rename from src/legacy/server/saved_objects/migrations/core/call_cluster.ts
rename to src/core/server/saved_objects/migrations/core/call_cluster.ts
index 961961597855a..f5b4f787a61d4 100644
--- a/src/legacy/server/saved_objects/migrations/core/call_cluster.ts
+++ b/src/core/server/saved_objects/migrations/core/call_cluster.ts
@@ -23,7 +23,7 @@
* funcationality contained here.
*/
-import { IndexMapping } from '../../../mappings';
+import { IndexMapping } from '../../mappings';
/* eslint-disable @typescript-eslint/unified-signatures */
export interface CallCluster {
diff --git a/src/legacy/server/saved_objects/migrations/core/document_migrator.test.ts b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/document_migrator.test.ts
rename to src/core/server/saved_objects/migrations/core/document_migrator.test.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/document_migrator.ts b/src/core/server/saved_objects/migrations/core/document_migrator.ts
similarity index 97%
rename from src/legacy/server/saved_objects/migrations/core/document_migrator.ts
rename to src/core/server/saved_objects/migrations/core/document_migrator.ts
index bcff2988f4afe..578fe49b2d3cc 100644
--- a/src/legacy/server/saved_objects/migrations/core/document_migrator.ts
+++ b/src/core/server/saved_objects/migrations/core/document_migrator.ts
@@ -65,7 +65,7 @@ import _ from 'lodash';
import cloneDeep from 'lodash.clonedeep';
import Semver from 'semver';
import { RawSavedObjectDoc } from '../../serialization';
-import { MigrationVersion } from '../../';
+import { SavedObjectsMigrationVersion } from '../../';
import { LogFn, Logger, MigrationLogger } from './migration_logger';
export type TransformFn = (doc: RawSavedObjectDoc, log?: Logger) => RawSavedObjectDoc;
@@ -97,7 +97,7 @@ interface ActiveMigrations {
* Manages migration of individual documents.
*/
export interface VersionedTransformer {
- migrationVersion: MigrationVersion;
+ migrationVersion: SavedObjectsMigrationVersion;
migrate: TransformFn;
}
@@ -134,10 +134,10 @@ export class DocumentMigrator implements VersionedTransformer {
* Gets the latest version of each migratable property.
*
* @readonly
- * @type {MigrationVersion}
+ * @type {SavedObjectsMigrationVersion}
* @memberof DocumentMigrator
*/
- public get migrationVersion(): MigrationVersion {
+ public get migrationVersion(): SavedObjectsMigrationVersion {
return _.mapValues(this.migrations, ({ latestVersion }) => latestVersion);
}
@@ -387,7 +387,7 @@ function applicableTransforms(migrations: ActiveMigrations, doc: RawSavedObjectD
*/
function updateMigrationVersion(
doc: RawSavedObjectDoc,
- migrationVersion: MigrationVersion,
+ migrationVersion: SavedObjectsMigrationVersion,
prop: string,
version: string
) {
@@ -403,7 +403,7 @@ function updateMigrationVersion(
*/
function assertNoDowngrades(
doc: RawSavedObjectDoc,
- migrationVersion: MigrationVersion,
+ migrationVersion: SavedObjectsMigrationVersion,
prop: string,
version: string
) {
diff --git a/src/legacy/server/saved_objects/migrations/core/elastic_index.test.ts b/src/core/server/saved_objects/migrations/core/elastic_index.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/elastic_index.test.ts
rename to src/core/server/saved_objects/migrations/core/elastic_index.test.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/elastic_index.ts b/src/core/server/saved_objects/migrations/core/elastic_index.ts
similarity index 97%
rename from src/legacy/server/saved_objects/migrations/core/elastic_index.ts
rename to src/core/server/saved_objects/migrations/core/elastic_index.ts
index 1e55bd3d01688..9606a46edef95 100644
--- a/src/legacy/server/saved_objects/migrations/core/elastic_index.ts
+++ b/src/core/server/saved_objects/migrations/core/elastic_index.ts
@@ -23,8 +23,8 @@
*/
import _ from 'lodash';
-import { IndexMapping } from '../../../mappings';
-import { MigrationVersion } from '../../';
+import { IndexMapping } from '../../mappings';
+import { SavedObjectsMigrationVersion } from '../../';
import { AliasAction, CallCluster, NotFound, RawDoc, ShardsInfo } from './call_cluster';
const settings = { number_of_shards: 1, auto_expand_replicas: '0-1' };
@@ -147,12 +147,12 @@ export async function write(callCluster: CallCluster, index: string, docs: RawDo
*
* @param {CallCluster} callCluster
* @param {string} index
- * @param {MigrationVersion} migrationVersion - The latest versions of the migrations
+ * @param {SavedObjectsMigrationVersion} migrationVersion - The latest versions of the migrations
*/
export async function migrationsUpToDate(
callCluster: CallCluster,
index: string,
- migrationVersion: MigrationVersion,
+ migrationVersion: SavedObjectsMigrationVersion,
retryCount: number = 10
): Promise {
try {
diff --git a/src/legacy/server/saved_objects/migrations/core/index.ts b/src/core/server/saved_objects/migrations/core/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/index.ts
rename to src/core/server/saved_objects/migrations/core/index.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/index_migrator.test.ts b/src/core/server/saved_objects/migrations/core/index_migrator.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/index_migrator.test.ts
rename to src/core/server/saved_objects/migrations/core/index_migrator.test.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/index_migrator.ts b/src/core/server/saved_objects/migrations/core/index_migrator.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/index_migrator.ts
rename to src/core/server/saved_objects/migrations/core/index_migrator.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/migrate_raw_docs.test.ts b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/migrate_raw_docs.test.ts
rename to src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/migrate_raw_docs.ts b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/migrate_raw_docs.ts
rename to src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/migration_context.ts b/src/core/server/saved_objects/migrations/core/migration_context.ts
similarity index 98%
rename from src/legacy/server/saved_objects/migrations/core/migration_context.ts
rename to src/core/server/saved_objects/migrations/core/migration_context.ts
index 33d1b9635f54f..f3c4b271c3a72 100644
--- a/src/legacy/server/saved_objects/migrations/core/migration_context.ts
+++ b/src/core/server/saved_objects/migrations/core/migration_context.ts
@@ -25,7 +25,7 @@
*/
import { SavedObjectsSerializer } from '../../serialization';
-import { MappingProperties } from './../../../mappings';
+import { MappingProperties } from '../../mappings';
import { buildActiveMappings } from './build_active_mappings';
import { CallCluster } from './call_cluster';
import { VersionedTransformer } from './document_migrator';
diff --git a/src/legacy/server/saved_objects/migrations/core/migration_coordinator.test.ts b/src/core/server/saved_objects/migrations/core/migration_coordinator.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/migration_coordinator.test.ts
rename to src/core/server/saved_objects/migrations/core/migration_coordinator.test.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/migration_coordinator.ts b/src/core/server/saved_objects/migrations/core/migration_coordinator.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/migration_coordinator.ts
rename to src/core/server/saved_objects/migrations/core/migration_coordinator.ts
diff --git a/src/legacy/server/saved_objects/migrations/core/migration_logger.ts b/src/core/server/saved_objects/migrations/core/migration_logger.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/core/migration_logger.ts
rename to src/core/server/saved_objects/migrations/core/migration_logger.ts
diff --git a/src/legacy/server/saved_objects/migrations/index.ts b/src/core/server/saved_objects/migrations/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/index.ts
rename to src/core/server/saved_objects/migrations/index.ts
diff --git a/src/legacy/server/saved_objects/migrations/kibana/__snapshots__/kibana_migrator.test.ts.snap b/src/core/server/saved_objects/migrations/kibana/__snapshots__/kibana_migrator.test.ts.snap
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/kibana/__snapshots__/kibana_migrator.test.ts.snap
rename to src/core/server/saved_objects/migrations/kibana/__snapshots__/kibana_migrator.test.ts.snap
diff --git a/src/legacy/server/saved_objects/migrations/kibana/index.ts b/src/core/server/saved_objects/migrations/kibana/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/kibana/index.ts
rename to src/core/server/saved_objects/migrations/kibana/index.ts
diff --git a/src/legacy/server/saved_objects/migrations/kibana/kibana_migrator.test.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/migrations/kibana/kibana_migrator.test.ts
rename to src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts
diff --git a/src/legacy/server/saved_objects/migrations/kibana/kibana_migrator.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.ts
similarity index 99%
rename from src/legacy/server/saved_objects/migrations/kibana/kibana_migrator.ts
rename to src/core/server/saved_objects/migrations/kibana/kibana_migrator.ts
index 69322ef0a8b23..ebc8e90871970 100644
--- a/src/legacy/server/saved_objects/migrations/kibana/kibana_migrator.ts
+++ b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.ts
@@ -23,7 +23,7 @@
*/
import { once } from 'lodash';
-import { MappingProperties } from '../../../mappings';
+import { MappingProperties } from '../../mappings';
import { SavedObjectsSchema, SavedObjectsSchemaDefinition } from '../../schema';
import { SavedObjectsManagementDefinition } from '../../management';
import { RawSavedObjectDoc, SavedObjectsSerializer } from '../../serialization';
diff --git a/src/legacy/server/saved_objects/schema/index.ts b/src/core/server/saved_objects/schema/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/schema/index.ts
rename to src/core/server/saved_objects/schema/index.ts
diff --git a/src/legacy/server/saved_objects/schema/schema.mock.ts b/src/core/server/saved_objects/schema/schema.mock.ts
similarity index 100%
rename from src/legacy/server/saved_objects/schema/schema.mock.ts
rename to src/core/server/saved_objects/schema/schema.mock.ts
diff --git a/src/legacy/server/saved_objects/schema/schema.test.ts b/src/core/server/saved_objects/schema/schema.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/schema/schema.test.ts
rename to src/core/server/saved_objects/schema/schema.test.ts
diff --git a/src/legacy/server/saved_objects/schema/schema.ts b/src/core/server/saved_objects/schema/schema.ts
similarity index 100%
rename from src/legacy/server/saved_objects/schema/schema.ts
rename to src/core/server/saved_objects/schema/schema.ts
diff --git a/src/legacy/server/saved_objects/serialization/index.ts b/src/core/server/saved_objects/serialization/index.ts
similarity index 97%
rename from src/legacy/server/saved_objects/serialization/index.ts
rename to src/core/server/saved_objects/serialization/index.ts
index 72071ae8866fa..86a448ba8a5be 100644
--- a/src/legacy/server/saved_objects/serialization/index.ts
+++ b/src/core/server/saved_objects/serialization/index.ts
@@ -27,7 +27,10 @@
import uuid from 'uuid';
import { SavedObjectsSchema } from '../schema';
import { decodeVersion, encodeVersion } from '../version';
-import { MigrationVersion, SavedObjectReference } from '../service/saved_objects_client';
+import {
+ SavedObjectsMigrationVersion,
+ SavedObjectReference,
+} from '../service/saved_objects_client';
/**
* A raw document as represented directly in the saved object index.
@@ -51,7 +54,7 @@ interface SavedObjectDoc {
id?: string; // NOTE: SavedObjectDoc is used for uncreated objects where `id` is optional
type: string;
namespace?: string;
- migrationVersion?: MigrationVersion;
+ migrationVersion?: SavedObjectsMigrationVersion;
version?: string;
updated_at?: string;
diff --git a/src/legacy/server/saved_objects/serialization/serialization.test.ts b/src/core/server/saved_objects/serialization/serialization.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/serialization/serialization.test.ts
rename to src/core/server/saved_objects/serialization/serialization.test.ts
diff --git a/src/legacy/server/saved_objects/service/index.ts b/src/core/server/saved_objects/service/index.ts
similarity index 96%
rename from src/legacy/server/saved_objects/service/index.ts
rename to src/core/server/saved_objects/service/index.ts
index c4e0d66eb95b8..3b146b2b3ada9 100644
--- a/src/legacy/server/saved_objects/service/index.ts
+++ b/src/core/server/saved_objects/service/index.ts
@@ -20,6 +20,9 @@
import { ScopedSavedObjectsClientProvider } from './lib';
import { SavedObjectsClient } from './saved_objects_client';
+/**
+ * @public
+ */
export interface SavedObjectsService {
// ATTENTION: these types are incomplete
addScopedSavedObjectsClientWrapperFactory: ScopedSavedObjectsClientProvider<
@@ -35,6 +38,7 @@ export {
SavedObjectsRepository,
ScopedSavedObjectsClientProvider,
SavedObjectsClientWrapperFactory,
+ SavedObjectsErrorHelpers,
} from './lib';
export * from './saved_objects_client';
diff --git a/src/legacy/server/saved_objects/service/lib/__snapshots__/priority_collection.test.ts.snap b/src/core/server/saved_objects/service/lib/__snapshots__/priority_collection.test.ts.snap
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/__snapshots__/priority_collection.test.ts.snap
rename to src/core/server/saved_objects/service/lib/__snapshots__/priority_collection.test.ts.snap
diff --git a/src/legacy/server/saved_objects/service/lib/__snapshots__/repository.test.js.snap b/src/core/server/saved_objects/service/lib/__snapshots__/repository.test.js.snap
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/__snapshots__/repository.test.js.snap
rename to src/core/server/saved_objects/service/lib/__snapshots__/repository.test.js.snap
diff --git a/src/legacy/server/saved_objects/service/lib/__snapshots__/scoped_client_provider.test.js.snap b/src/core/server/saved_objects/service/lib/__snapshots__/scoped_client_provider.test.js.snap
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/__snapshots__/scoped_client_provider.test.js.snap
rename to src/core/server/saved_objects/service/lib/__snapshots__/scoped_client_provider.test.js.snap
diff --git a/src/legacy/server/saved_objects/service/lib/decorate_es_error.test.ts b/src/core/server/saved_objects/service/lib/decorate_es_error.test.ts
similarity index 66%
rename from src/legacy/server/saved_objects/service/lib/decorate_es_error.test.ts
rename to src/core/server/saved_objects/service/lib/decorate_es_error.test.ts
index 272a26327b808..2fd9b487f470a 100644
--- a/src/legacy/server/saved_objects/service/lib/decorate_es_error.test.ts
+++ b/src/core/server/saved_objects/service/lib/decorate_es_error.test.ts
@@ -20,15 +20,7 @@
import { errors as esErrors } from 'elasticsearch';
import { decorateEsError } from './decorate_es_error';
-import {
- isBadRequestError,
- isConflictError,
- isEsUnavailableError,
- isForbiddenError,
- isNotAuthorizedError,
- isNotFoundError,
- isRequestEntityTooLargeError,
-} from './errors';
+import { SavedObjectsErrorHelpers } from './errors';
describe('savedObjectsClient/decorateEsError', () => {
it('always returns the same error it receives', () => {
@@ -38,74 +30,74 @@ describe('savedObjectsClient/decorateEsError', () => {
it('makes es.ConnectionFault a SavedObjectsClient/EsUnavailable error', () => {
const error = new esErrors.ConnectionFault();
- expect(isEsUnavailableError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isEsUnavailableError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true);
});
it('makes es.ServiceUnavailable a SavedObjectsClient/EsUnavailable error', () => {
const error = new esErrors.ServiceUnavailable();
- expect(isEsUnavailableError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isEsUnavailableError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true);
});
it('makes es.NoConnections a SavedObjectsClient/EsUnavailable error', () => {
const error = new esErrors.NoConnections();
- expect(isEsUnavailableError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isEsUnavailableError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true);
});
it('makes es.RequestTimeout a SavedObjectsClient/EsUnavailable error', () => {
const error = new esErrors.RequestTimeout();
- expect(isEsUnavailableError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isEsUnavailableError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true);
});
it('makes es.Conflict a SavedObjectsClient/Conflict error', () => {
const error = new esErrors.Conflict();
- expect(isConflictError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isConflictError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isConflictError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isConflictError(error)).toBe(true);
});
it('makes es.AuthenticationException a SavedObjectsClient/NotAuthorized error', () => {
const error = new esErrors.AuthenticationException();
- expect(isNotAuthorizedError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isNotAuthorizedError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isNotAuthorizedError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isNotAuthorizedError(error)).toBe(true);
});
it('makes es.Forbidden a SavedObjectsClient/Forbidden error', () => {
const error = new esErrors.Forbidden();
- expect(isForbiddenError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isForbiddenError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isForbiddenError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isForbiddenError(error)).toBe(true);
});
it('makes es.RequestEntityTooLarge a SavedObjectsClient/RequestEntityTooLarge error', () => {
const error = new esErrors.RequestEntityTooLarge();
- expect(isRequestEntityTooLargeError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isRequestEntityTooLargeError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isRequestEntityTooLargeError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isRequestEntityTooLargeError(error)).toBe(true);
});
it('discards es.NotFound errors and returns a generic NotFound error', () => {
const error = new esErrors.NotFound();
- expect(isNotFoundError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false);
const genericError = decorateEsError(error);
expect(genericError).not.toBe(error);
- expect(isNotFoundError(error)).toBe(false);
- expect(isNotFoundError(genericError)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isNotFoundError(genericError)).toBe(true);
});
it('makes es.BadRequest a SavedObjectsClient/BadRequest error', () => {
const error = new esErrors.BadRequest();
- expect(isBadRequestError(error)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isBadRequestError(error)).toBe(false);
expect(decorateEsError(error)).toBe(error);
- expect(isBadRequestError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isBadRequestError(error)).toBe(true);
});
it('returns other errors as Boom errors', () => {
diff --git a/src/legacy/server/saved_objects/service/lib/decorate_es_error.ts b/src/core/server/saved_objects/service/lib/decorate_es_error.ts
similarity index 72%
rename from src/legacy/server/saved_objects/service/lib/decorate_es_error.ts
rename to src/core/server/saved_objects/service/lib/decorate_es_error.ts
index becb41b78dad4..af66348a98eb3 100644
--- a/src/legacy/server/saved_objects/service/lib/decorate_es_error.ts
+++ b/src/core/server/saved_objects/service/lib/decorate_es_error.ts
@@ -36,16 +36,7 @@ const {
BadRequest,
} = elasticsearch.errors;
-import {
- createGenericNotFoundError,
- decorateBadRequestError,
- decorateConflictError,
- decorateEsUnavailableError,
- decorateForbiddenError,
- decorateGeneralError,
- decorateNotAuthorizedError,
- decorateRequestEntityTooLargeError,
-} from './errors';
+import { SavedObjectsErrorHelpers } from './errors';
export function decorateEsError(error: Error) {
if (!(error instanceof Error)) {
@@ -59,32 +50,32 @@ export function decorateEsError(error: Error) {
error instanceof NoConnections ||
error instanceof RequestTimeout
) {
- return decorateEsUnavailableError(error, reason);
+ return SavedObjectsErrorHelpers.decorateEsUnavailableError(error, reason);
}
if (error instanceof Conflict) {
- return decorateConflictError(error, reason);
+ return SavedObjectsErrorHelpers.decorateConflictError(error, reason);
}
if (error instanceof NotAuthorized) {
- return decorateNotAuthorizedError(error, reason);
+ return SavedObjectsErrorHelpers.decorateNotAuthorizedError(error, reason);
}
if (error instanceof Forbidden) {
- return decorateForbiddenError(error, reason);
+ return SavedObjectsErrorHelpers.decorateForbiddenError(error, reason);
}
if (error instanceof RequestEntityTooLarge) {
- return decorateRequestEntityTooLargeError(error, reason);
+ return SavedObjectsErrorHelpers.decorateRequestEntityTooLargeError(error, reason);
}
if (error instanceof NotFound) {
- return createGenericNotFoundError();
+ return SavedObjectsErrorHelpers.createGenericNotFoundError();
}
if (error instanceof BadRequest) {
- return decorateBadRequestError(error, reason);
+ return SavedObjectsErrorHelpers.decorateBadRequestError(error, reason);
}
- return decorateGeneralError(error, reason);
+ return SavedObjectsErrorHelpers.decorateGeneralError(error, reason);
}
diff --git a/src/legacy/server/saved_objects/service/lib/errors.test.ts b/src/core/server/saved_objects/service/lib/errors.test.ts
similarity index 63%
rename from src/legacy/server/saved_objects/service/lib/errors.test.ts
rename to src/core/server/saved_objects/service/lib/errors.test.ts
index facbacae84d07..12fc913f93090 100644
--- a/src/legacy/server/saved_objects/service/lib/errors.test.ts
+++ b/src/core/server/saved_objects/service/lib/errors.test.ts
@@ -19,30 +19,12 @@
import Boom from 'boom';
-import {
- createBadRequestError,
- createEsAutoCreateIndexError,
- createGenericNotFoundError,
- createUnsupportedTypeError,
- decorateBadRequestError,
- decorateConflictError,
- decorateEsUnavailableError,
- decorateForbiddenError,
- decorateGeneralError,
- decorateNotAuthorizedError,
- isBadRequestError,
- isConflictError,
- isEsAutoCreateIndexError,
- isEsUnavailableError,
- isForbiddenError,
- isNotAuthorizedError,
- isNotFoundError,
-} from './errors';
+import { SavedObjectsErrorHelpers } from './errors';
describe('savedObjectsClient/errorTypes', () => {
describe('BadRequest error', () => {
describe('createUnsupportedTypeError', () => {
- const errorObj = createUnsupportedTypeError('someType');
+ const errorObj = SavedObjectsErrorHelpers.createUnsupportedTypeError('someType');
it('should have the unsupported type message', () => {
expect(errorObj).toHaveProperty(
@@ -60,18 +42,18 @@ describe('savedObjectsClient/errorTypes', () => {
});
it("should be identified by 'isBadRequestError' method", () => {
- expect(isBadRequestError(errorObj)).toBeTruthy();
+ expect(SavedObjectsErrorHelpers.isBadRequestError(errorObj)).toBeTruthy();
});
});
describe('createBadRequestError', () => {
- const errorObj = createBadRequestError('test reason message');
+ const errorObj = SavedObjectsErrorHelpers.createBadRequestError('test reason message');
it('should create an appropriately structured error object', () => {
expect(errorObj.message).toEqual('test reason message: Bad Request');
});
it("should be identified by 'isBadRequestError' method", () => {
- expect(isBadRequestError(errorObj)).toBeTruthy();
+ expect(SavedObjectsErrorHelpers.isBadRequestError(errorObj)).toBeTruthy();
});
it('has boom properties', () => {
@@ -86,39 +68,42 @@ describe('savedObjectsClient/errorTypes', () => {
describe('decorateBadRequestError', () => {
it('returns original object', () => {
const error = new Error();
- expect(decorateBadRequestError(error)).toBe(error);
+ expect(SavedObjectsErrorHelpers.decorateBadRequestError(error)).toBe(error);
});
it('makes the error identifiable as a BadRequest error', () => {
const error = new Error();
- expect(isBadRequestError(error)).toBe(false);
- decorateBadRequestError(error);
- expect(isBadRequestError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isBadRequestError(error)).toBe(false);
+ SavedObjectsErrorHelpers.decorateBadRequestError(error);
+ expect(SavedObjectsErrorHelpers.isBadRequestError(error)).toBe(true);
});
it('adds boom properties', () => {
- const error = decorateBadRequestError(new Error());
+ const error = SavedObjectsErrorHelpers.decorateBadRequestError(new Error());
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(400);
});
it('preserves boom properties of input', () => {
const error = Boom.notFound();
- decorateBadRequestError(error);
+ SavedObjectsErrorHelpers.decorateBadRequestError(error);
expect(error.output.statusCode).toBe(404);
});
describe('error.output', () => {
it('defaults to message of error', () => {
- const error = decorateBadRequestError(new Error('foobar'));
+ const error = SavedObjectsErrorHelpers.decorateBadRequestError(new Error('foobar'));
expect(error.output.payload).toHaveProperty('message', 'foobar');
});
it('prefixes message with passed reason', () => {
- const error = decorateBadRequestError(new Error('foobar'), 'biz');
+ const error = SavedObjectsErrorHelpers.decorateBadRequestError(
+ new Error('foobar'),
+ 'biz'
+ );
expect(error.output.payload).toHaveProperty('message', 'biz: foobar');
});
it('sets statusCode to 400', () => {
- const error = decorateBadRequestError(new Error('foo'));
+ const error = SavedObjectsErrorHelpers.decorateBadRequestError(new Error('foo'));
expect(error.output).toHaveProperty('statusCode', 400);
});
});
@@ -128,39 +113,42 @@ describe('savedObjectsClient/errorTypes', () => {
describe('decorateNotAuthorizedError', () => {
it('returns original object', () => {
const error = new Error();
- expect(decorateNotAuthorizedError(error)).toBe(error);
+ expect(SavedObjectsErrorHelpers.decorateNotAuthorizedError(error)).toBe(error);
});
it('makes the error identifiable as a NotAuthorized error', () => {
const error = new Error();
- expect(isNotAuthorizedError(error)).toBe(false);
- decorateNotAuthorizedError(error);
- expect(isNotAuthorizedError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isNotAuthorizedError(error)).toBe(false);
+ SavedObjectsErrorHelpers.decorateNotAuthorizedError(error);
+ expect(SavedObjectsErrorHelpers.isNotAuthorizedError(error)).toBe(true);
});
it('adds boom properties', () => {
- const error = decorateNotAuthorizedError(new Error());
+ const error = SavedObjectsErrorHelpers.decorateNotAuthorizedError(new Error());
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(401);
});
it('preserves boom properties of input', () => {
const error = Boom.notFound();
- decorateNotAuthorizedError(error);
+ SavedObjectsErrorHelpers.decorateNotAuthorizedError(error);
expect(error.output.statusCode).toBe(404);
});
describe('error.output', () => {
it('defaults to message of error', () => {
- const error = decorateNotAuthorizedError(new Error('foobar'));
+ const error = SavedObjectsErrorHelpers.decorateNotAuthorizedError(new Error('foobar'));
expect(error.output.payload).toHaveProperty('message', 'foobar');
});
it('prefixes message with passed reason', () => {
- const error = decorateNotAuthorizedError(new Error('foobar'), 'biz');
+ const error = SavedObjectsErrorHelpers.decorateNotAuthorizedError(
+ new Error('foobar'),
+ 'biz'
+ );
expect(error.output.payload).toHaveProperty('message', 'biz: foobar');
});
it('sets statusCode to 401', () => {
- const error = decorateNotAuthorizedError(new Error('foo'));
+ const error = SavedObjectsErrorHelpers.decorateNotAuthorizedError(new Error('foo'));
expect(error.output).toHaveProperty('statusCode', 401);
});
});
@@ -170,39 +158,39 @@ describe('savedObjectsClient/errorTypes', () => {
describe('decorateForbiddenError', () => {
it('returns original object', () => {
const error = new Error();
- expect(decorateForbiddenError(error)).toBe(error);
+ expect(SavedObjectsErrorHelpers.decorateForbiddenError(error)).toBe(error);
});
it('makes the error identifiable as a Forbidden error', () => {
const error = new Error();
- expect(isForbiddenError(error)).toBe(false);
- decorateForbiddenError(error);
- expect(isForbiddenError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isForbiddenError(error)).toBe(false);
+ SavedObjectsErrorHelpers.decorateForbiddenError(error);
+ expect(SavedObjectsErrorHelpers.isForbiddenError(error)).toBe(true);
});
it('adds boom properties', () => {
- const error = decorateForbiddenError(new Error());
+ const error = SavedObjectsErrorHelpers.decorateForbiddenError(new Error());
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(403);
});
it('preserves boom properties of input', () => {
const error = Boom.notFound();
- decorateForbiddenError(error);
+ SavedObjectsErrorHelpers.decorateForbiddenError(error);
expect(error.output.statusCode).toBe(404);
});
describe('error.output', () => {
it('defaults to message of error', () => {
- const error = decorateForbiddenError(new Error('foobar'));
+ const error = SavedObjectsErrorHelpers.decorateForbiddenError(new Error('foobar'));
expect(error.output.payload).toHaveProperty('message', 'foobar');
});
it('prefixes message with passed reason', () => {
- const error = decorateForbiddenError(new Error('foobar'), 'biz');
+ const error = SavedObjectsErrorHelpers.decorateForbiddenError(new Error('foobar'), 'biz');
expect(error.output.payload).toHaveProperty('message', 'biz: foobar');
});
it('sets statusCode to 403', () => {
- const error = decorateForbiddenError(new Error('foo'));
+ const error = SavedObjectsErrorHelpers.decorateForbiddenError(new Error('foo'));
expect(error.output).toHaveProperty('statusCode', 403);
});
});
@@ -211,12 +199,12 @@ describe('savedObjectsClient/errorTypes', () => {
describe('NotFound error', () => {
describe('createGenericNotFoundError', () => {
it('makes an error identifiable as a NotFound error', () => {
- const error = createGenericNotFoundError();
- expect(isNotFoundError(error)).toBe(true);
+ const error = SavedObjectsErrorHelpers.createGenericNotFoundError();
+ expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(true);
});
it('is a boom error, has boom properties', () => {
- const error = createGenericNotFoundError();
+ const error = SavedObjectsErrorHelpers.createGenericNotFoundError();
expect(error).toHaveProperty('isBoom');
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(404);
@@ -224,11 +212,11 @@ describe('savedObjectsClient/errorTypes', () => {
describe('error.output', () => {
it('Uses "Not Found" message', () => {
- const error = createGenericNotFoundError();
+ const error = SavedObjectsErrorHelpers.createGenericNotFoundError();
expect(error.output.payload).toHaveProperty('message', 'Not Found');
});
it('sets statusCode to 404', () => {
- const error = createGenericNotFoundError();
+ const error = SavedObjectsErrorHelpers.createGenericNotFoundError();
expect(error.output).toHaveProperty('statusCode', 404);
});
});
@@ -238,39 +226,39 @@ describe('savedObjectsClient/errorTypes', () => {
describe('decorateConflictError', () => {
it('returns original object', () => {
const error = new Error();
- expect(decorateConflictError(error)).toBe(error);
+ expect(SavedObjectsErrorHelpers.decorateConflictError(error)).toBe(error);
});
it('makes the error identifiable as a Conflict error', () => {
const error = new Error();
- expect(isConflictError(error)).toBe(false);
- decorateConflictError(error);
- expect(isConflictError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isConflictError(error)).toBe(false);
+ SavedObjectsErrorHelpers.decorateConflictError(error);
+ expect(SavedObjectsErrorHelpers.isConflictError(error)).toBe(true);
});
it('adds boom properties', () => {
- const error = decorateConflictError(new Error());
+ const error = SavedObjectsErrorHelpers.decorateConflictError(new Error());
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(409);
});
it('preserves boom properties of input', () => {
const error = Boom.notFound();
- decorateConflictError(error);
+ SavedObjectsErrorHelpers.decorateConflictError(error);
expect(error.output.statusCode).toBe(404);
});
describe('error.output', () => {
it('defaults to message of error', () => {
- const error = decorateConflictError(new Error('foobar'));
+ const error = SavedObjectsErrorHelpers.decorateConflictError(new Error('foobar'));
expect(error.output.payload).toHaveProperty('message', 'foobar');
});
it('prefixes message with passed reason', () => {
- const error = decorateConflictError(new Error('foobar'), 'biz');
+ const error = SavedObjectsErrorHelpers.decorateConflictError(new Error('foobar'), 'biz');
expect(error.output.payload).toHaveProperty('message', 'biz: foobar');
});
it('sets statusCode to 409', () => {
- const error = decorateConflictError(new Error('foo'));
+ const error = SavedObjectsErrorHelpers.decorateConflictError(new Error('foo'));
expect(error.output).toHaveProperty('statusCode', 409);
});
});
@@ -280,39 +268,42 @@ describe('savedObjectsClient/errorTypes', () => {
describe('decorateEsUnavailableError', () => {
it('returns original object', () => {
const error = new Error();
- expect(decorateEsUnavailableError(error)).toBe(error);
+ expect(SavedObjectsErrorHelpers.decorateEsUnavailableError(error)).toBe(error);
});
it('makes the error identifiable as a EsUnavailable error', () => {
const error = new Error();
- expect(isEsUnavailableError(error)).toBe(false);
- decorateEsUnavailableError(error);
- expect(isEsUnavailableError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(false);
+ SavedObjectsErrorHelpers.decorateEsUnavailableError(error);
+ expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true);
});
it('adds boom properties', () => {
- const error = decorateEsUnavailableError(new Error());
+ const error = SavedObjectsErrorHelpers.decorateEsUnavailableError(new Error());
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(503);
});
it('preserves boom properties of input', () => {
const error = Boom.notFound();
- decorateEsUnavailableError(error);
+ SavedObjectsErrorHelpers.decorateEsUnavailableError(error);
expect(error.output.statusCode).toBe(404);
});
describe('error.output', () => {
it('defaults to message of error', () => {
- const error = decorateEsUnavailableError(new Error('foobar'));
+ const error = SavedObjectsErrorHelpers.decorateEsUnavailableError(new Error('foobar'));
expect(error.output.payload).toHaveProperty('message', 'foobar');
});
it('prefixes message with passed reason', () => {
- const error = decorateEsUnavailableError(new Error('foobar'), 'biz');
+ const error = SavedObjectsErrorHelpers.decorateEsUnavailableError(
+ new Error('foobar'),
+ 'biz'
+ );
expect(error.output.payload).toHaveProperty('message', 'biz: foobar');
});
it('sets statusCode to 503', () => {
- const error = decorateEsUnavailableError(new Error('foo'));
+ const error = SavedObjectsErrorHelpers.decorateEsUnavailableError(new Error('foo'));
expect(error.output).toHaveProperty('statusCode', 503);
});
});
@@ -322,28 +313,28 @@ describe('savedObjectsClient/errorTypes', () => {
describe('decorateGeneralError', () => {
it('returns original object', () => {
const error = new Error();
- expect(decorateGeneralError(error)).toBe(error);
+ expect(SavedObjectsErrorHelpers.decorateGeneralError(error)).toBe(error);
});
it('adds boom properties', () => {
- const error = decorateGeneralError(new Error());
+ const error = SavedObjectsErrorHelpers.decorateGeneralError(new Error());
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(500);
});
it('preserves boom properties of input', () => {
const error = Boom.notFound();
- decorateGeneralError(error);
+ SavedObjectsErrorHelpers.decorateGeneralError(error);
expect(error.output.statusCode).toBe(404);
});
describe('error.output', () => {
it('ignores error message', () => {
- const error = decorateGeneralError(new Error('foobar'));
+ const error = SavedObjectsErrorHelpers.decorateGeneralError(new Error('foobar'));
expect(error.output.payload.message).toMatch(/internal server error/i);
});
it('sets statusCode to 500', () => {
- const error = decorateGeneralError(new Error('foo'));
+ const error = SavedObjectsErrorHelpers.decorateGeneralError(new Error('foo'));
expect(error.output).toHaveProperty('statusCode', 500);
});
});
@@ -355,19 +346,23 @@ describe('savedObjectsClient/errorTypes', () => {
it('does not take an error argument', () => {
const error = new Error();
// @ts-ignore
- expect(createEsAutoCreateIndexError(error)).not.toBe(error);
+ expect(SavedObjectsErrorHelpers.createEsAutoCreateIndexError(error)).not.toBe(error);
});
it('returns a new Error', () => {
- expect(createEsAutoCreateIndexError()).toBeInstanceOf(Error);
+ expect(SavedObjectsErrorHelpers.createEsAutoCreateIndexError()).toBeInstanceOf(Error);
});
it('makes errors identifiable as EsAutoCreateIndex errors', () => {
- expect(isEsAutoCreateIndexError(createEsAutoCreateIndexError())).toBe(true);
+ expect(
+ SavedObjectsErrorHelpers.isEsAutoCreateIndexError(
+ SavedObjectsErrorHelpers.createEsAutoCreateIndexError()
+ )
+ ).toBe(true);
});
it('returns a boom error', () => {
- const error = createEsAutoCreateIndexError();
+ const error = SavedObjectsErrorHelpers.createEsAutoCreateIndexError();
expect(error).toHaveProperty('isBoom');
expect(typeof error.output).toBe('object');
expect(error.output.statusCode).toBe(503);
@@ -375,11 +370,11 @@ describe('savedObjectsClient/errorTypes', () => {
describe('error.output', () => {
it('uses "Automatic index creation failed" message', () => {
- const error = createEsAutoCreateIndexError();
+ const error = SavedObjectsErrorHelpers.createEsAutoCreateIndexError();
expect(error.output.payload).toHaveProperty('message', 'Automatic index creation failed');
});
it('sets statusCode to 503', () => {
- const error = createEsAutoCreateIndexError();
+ const error = SavedObjectsErrorHelpers.createEsAutoCreateIndexError();
expect(error.output).toHaveProperty('statusCode', 503);
});
});
diff --git a/src/core/server/saved_objects/service/lib/errors.ts b/src/core/server/saved_objects/service/lib/errors.ts
new file mode 100644
index 0000000000000..e9138e9b8a347
--- /dev/null
+++ b/src/core/server/saved_objects/service/lib/errors.ts
@@ -0,0 +1,182 @@
+/*
+ * 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 Boom from 'boom';
+
+// 400 - badRequest
+const CODE_BAD_REQUEST = 'SavedObjectsClient/badRequest';
+// 400 - invalid version
+const CODE_INVALID_VERSION = 'SavedObjectsClient/invalidVersion';
+// 401 - Not Authorized
+const CODE_NOT_AUTHORIZED = 'SavedObjectsClient/notAuthorized';
+// 403 - Forbidden
+const CODE_FORBIDDEN = 'SavedObjectsClient/forbidden';
+// 413 - Request Entity Too Large
+const CODE_REQUEST_ENTITY_TOO_LARGE = 'SavedObjectsClient/requestEntityTooLarge';
+// 404 - Not Found
+const CODE_NOT_FOUND = 'SavedObjectsClient/notFound';
+// 409 - Conflict
+const CODE_CONFLICT = 'SavedObjectsClient/conflict';
+// 503 - Es Unavailable
+const CODE_ES_UNAVAILABLE = 'SavedObjectsClient/esUnavailable';
+// 503 - Unable to automatically create index because of action.auto_create_index setting
+const CODE_ES_AUTO_CREATE_INDEX_ERROR = 'SavedObjectsClient/autoCreateIndex';
+// 500 - General Error
+const CODE_GENERAL_ERROR = 'SavedObjectsClient/generalError';
+
+const code = Symbol('SavedObjectsClientErrorCode');
+
+export interface DecoratedError extends Boom {
+ [code]?: string;
+}
+
+function decorate(
+ error: Error | DecoratedError,
+ errorCode: string,
+ statusCode: number,
+ message?: string
+): DecoratedError {
+ if (isSavedObjectsClientError(error)) {
+ return error;
+ }
+
+ const boom = Boom.boomify(error, {
+ statusCode,
+ message,
+ override: false,
+ }) as DecoratedError;
+
+ boom[code] = errorCode;
+
+ return boom;
+}
+
+function isSavedObjectsClientError(error: any): error is DecoratedError {
+ return Boolean(error && error[code]);
+}
+
+function decorateBadRequestError(error: Error, reason?: string) {
+ return decorate(error, CODE_BAD_REQUEST, 400, reason);
+}
+
+/**
+ * @public
+ */
+export class SavedObjectsErrorHelpers {
+ public static isSavedObjectsClientError(error: any): error is DecoratedError {
+ return isSavedObjectsClientError(error);
+ }
+
+ public static decorateBadRequestError(error: Error, reason?: string) {
+ return decorateBadRequestError(error, reason);
+ }
+
+ public static createBadRequestError(reason?: string) {
+ return decorateBadRequestError(new Error('Bad Request'), reason);
+ }
+
+ public static createUnsupportedTypeError(type: string) {
+ return decorateBadRequestError(
+ new Error('Bad Request'),
+ `Unsupported saved object type: '${type}'`
+ );
+ }
+
+ public static isBadRequestError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_BAD_REQUEST;
+ }
+
+ public static createInvalidVersionError(versionInput?: string) {
+ return decorate(
+ Boom.badRequest(`Invalid version [${versionInput}]`),
+ CODE_INVALID_VERSION,
+ 400
+ );
+ }
+
+ public static isInvalidVersionError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_INVALID_VERSION;
+ }
+
+ public static decorateNotAuthorizedError(error: Error, reason?: string) {
+ return decorate(error, CODE_NOT_AUTHORIZED, 401, reason);
+ }
+
+ public static isNotAuthorizedError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_NOT_AUTHORIZED;
+ }
+
+ public static decorateForbiddenError(error: Error, reason?: string) {
+ return decorate(error, CODE_FORBIDDEN, 403, reason);
+ }
+
+ public static isForbiddenError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_FORBIDDEN;
+ }
+
+ public static decorateRequestEntityTooLargeError(error: Error, reason?: string) {
+ return decorate(error, CODE_REQUEST_ENTITY_TOO_LARGE, 413, reason);
+ }
+ public static isRequestEntityTooLargeError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_REQUEST_ENTITY_TOO_LARGE;
+ }
+
+ public static createGenericNotFoundError(type: string | null = null, id: string | null = null) {
+ if (type && id) {
+ return decorate(Boom.notFound(`Saved object [${type}/${id}] not found`), CODE_NOT_FOUND, 404);
+ }
+ return decorate(Boom.notFound(), CODE_NOT_FOUND, 404);
+ }
+
+ public static isNotFoundError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_NOT_FOUND;
+ }
+
+ public static decorateConflictError(error: Error, reason?: string) {
+ return decorate(error, CODE_CONFLICT, 409, reason);
+ }
+
+ public static isConflictError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_CONFLICT;
+ }
+
+ public static decorateEsUnavailableError(error: Error, reason?: string) {
+ return decorate(error, CODE_ES_UNAVAILABLE, 503, reason);
+ }
+
+ public static isEsUnavailableError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_ES_UNAVAILABLE;
+ }
+
+ public static createEsAutoCreateIndexError() {
+ const error = Boom.serverUnavailable('Automatic index creation failed');
+ error.output.payload.attributes = error.output.payload.attributes || {};
+ error.output.payload.attributes.code = 'ES_AUTO_CREATE_INDEX_ERROR';
+
+ return decorate(error, CODE_ES_AUTO_CREATE_INDEX_ERROR, 503);
+ }
+
+ public static isEsAutoCreateIndexError(error: Error | DecoratedError) {
+ return isSavedObjectsClientError(error) && error[code] === CODE_ES_AUTO_CREATE_INDEX_ERROR;
+ }
+
+ public static decorateGeneralError(error: Error, reason?: string) {
+ return decorate(error, CODE_GENERAL_ERROR, 500, reason);
+ }
+}
diff --git a/src/legacy/server/saved_objects/service/lib/included_fields.test.ts b/src/core/server/saved_objects/service/lib/included_fields.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/included_fields.test.ts
rename to src/core/server/saved_objects/service/lib/included_fields.test.ts
diff --git a/src/legacy/server/saved_objects/service/lib/included_fields.ts b/src/core/server/saved_objects/service/lib/included_fields.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/included_fields.ts
rename to src/core/server/saved_objects/service/lib/included_fields.ts
diff --git a/src/legacy/server/saved_objects/service/lib/index.ts b/src/core/server/saved_objects/service/lib/index.ts
similarity index 94%
rename from src/legacy/server/saved_objects/service/lib/index.ts
rename to src/core/server/saved_objects/service/lib/index.ts
index 68fa240584100..19fdc3d75f603 100644
--- a/src/legacy/server/saved_objects/service/lib/index.ts
+++ b/src/core/server/saved_objects/service/lib/index.ts
@@ -24,5 +24,4 @@ export {
ScopedSavedObjectsClientProvider,
} from './scoped_client_provider';
-import * as errors from './errors';
-export { errors };
+export { SavedObjectsErrorHelpers } from './errors';
diff --git a/src/legacy/server/saved_objects/service/lib/priority_collection.test.ts b/src/core/server/saved_objects/service/lib/priority_collection.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/priority_collection.test.ts
rename to src/core/server/saved_objects/service/lib/priority_collection.test.ts
diff --git a/src/legacy/server/saved_objects/service/lib/priority_collection.ts b/src/core/server/saved_objects/service/lib/priority_collection.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/priority_collection.ts
rename to src/core/server/saved_objects/service/lib/priority_collection.ts
diff --git a/src/legacy/server/saved_objects/service/lib/repository.test.js b/src/core/server/saved_objects/service/lib/repository.test.js
similarity index 96%
rename from src/legacy/server/saved_objects/service/lib/repository.test.js
rename to src/core/server/saved_objects/service/lib/repository.test.js
index 29ccdb3b8002a..5a2e6a617fbb5 100644
--- a/src/legacy/server/saved_objects/service/lib/repository.test.js
+++ b/src/core/server/saved_objects/service/lib/repository.test.js
@@ -20,11 +20,11 @@
import { delay } from 'bluebird';
import { SavedObjectsRepository } from './repository';
import * as getSearchDslNS from './search_dsl/search_dsl';
-import * as errors from './errors';
+import { SavedObjectsErrorHelpers } from './errors';
import elasticsearch from 'elasticsearch';
import { SavedObjectsSchema } from '../../schema';
import { SavedObjectsSerializer } from '../../serialization';
-import { getRootPropertiesObjects } from '../../../mappings/lib/get_root_properties_objects';
+import { getRootPropertiesObjects } from '../../mappings/lib/get_root_properties_objects';
import { encodeHitVersion } from '../../version';
jest.mock('./search_dsl/search_dsl', () => ({ getSearchDsl: jest.fn() }));
@@ -1154,26 +1154,27 @@ describe('SavedObjectsRepository', () => {
}
});
- it('passes mappings, schema, search, defaultSearchOperator, searchFields, type, sortField, sortOrder and hasReference to getSearchDsl', async () => {
- callAdminCluster.mockReturnValue(namespacedSearchResults);
- const relevantOpts = {
- namespace: 'foo-namespace',
- search: 'foo*',
- searchFields: ['foo'],
- type: ['bar'],
- sortField: 'name',
- sortOrder: 'desc',
- defaultSearchOperator: 'AND',
- hasReference: {
- type: 'foo',
- id: '1',
- },
- };
+ it('passes mappings, schema, search, defaultSearchOperator, searchFields, type, sortField, sortOrder and hasReference to getSearchDsl',
+ async () => {
+ callAdminCluster.mockReturnValue(namespacedSearchResults);
+ const relevantOpts = {
+ namespace: 'foo-namespace',
+ search: 'foo*',
+ searchFields: ['foo'],
+ type: ['bar'],
+ sortField: 'name',
+ sortOrder: 'desc',
+ defaultSearchOperator: 'AND',
+ hasReference: {
+ type: 'foo',
+ id: '1',
+ },
+ };
- await savedObjectsRepository.find(relevantOpts);
- expect(getSearchDslNS.getSearchDsl).toHaveBeenCalledTimes(1);
- expect(getSearchDslNS.getSearchDsl).toHaveBeenCalledWith(mappings, schema, relevantOpts);
- });
+ await savedObjectsRepository.find(relevantOpts);
+ expect(getSearchDslNS.getSearchDsl).toHaveBeenCalledTimes(1);
+ expect(getSearchDslNS.getSearchDsl).toHaveBeenCalledWith(mappings, schema, relevantOpts);
+ });
it('merges output of getSearchDsl into es request body', async () => {
callAdminCluster.mockReturnValue(noNamespaceSearchResults);
@@ -1627,7 +1628,7 @@ describe('SavedObjectsRepository', () => {
{
error: {
error: 'Bad Request',
- message: "Unsupported saved object type: 'invalidtype': Bad Request",
+ message: 'Unsupported saved object type: \'invalidtype\': Bad Request',
statusCode: 400,
},
id: 'two',
@@ -1636,7 +1637,7 @@ describe('SavedObjectsRepository', () => {
{
error: {
error: 'Bad Request',
- message: "Unsupported saved object type: 'invalidtype': Bad Request",
+ message: 'Unsupported saved object type: \'invalidtype\': Bad Request',
statusCode: 400,
},
id: 'four',
@@ -2072,7 +2073,7 @@ describe('SavedObjectsRepository', () => {
expect.assertions(4);
const es401 = new elasticsearch.errors[401]();
- expect(errors.isNotAuthorizedError(es401)).toBe(false);
+ expect(SavedObjectsErrorHelpers.isNotAuthorizedError(es401)).toBe(false);
onBeforeWrite.mockImplementation(() => {
throw es401;
});
@@ -2082,13 +2083,13 @@ describe('SavedObjectsRepository', () => {
} catch (error) {
expect(onBeforeWrite).toHaveBeenCalledTimes(1);
expect(error).toBe(es401);
- expect(errors.isNotAuthorizedError(error)).toBe(true);
+ expect(SavedObjectsErrorHelpers.isNotAuthorizedError(error)).toBe(true);
}
});
});
describe('types on custom index', () => {
- it("should error when attempting to 'update' an unsupported type", async () => {
+ it('should error when attempting to \'update\' an unsupported type', async () => {
await expect(
savedObjectsRepository.update('hiddenType', 'bogus', { title: 'some title' })
).rejects.toEqual(new Error('Saved object [hiddenType/bogus] not found'));
@@ -2096,25 +2097,25 @@ describe('SavedObjectsRepository', () => {
});
describe('unsupported types', () => {
- it("should error when attempting to 'update' an unsupported type", async () => {
+ it('should error when attempting to \'update\' an unsupported type', async () => {
await expect(
savedObjectsRepository.update('hiddenType', 'bogus', { title: 'some title' })
).rejects.toEqual(new Error('Saved object [hiddenType/bogus] not found'));
});
- it("should error when attempting to 'get' an unsupported type", async () => {
+ it('should error when attempting to \'get\' an unsupported type', async () => {
await expect(savedObjectsRepository.get('hiddenType')).rejects.toEqual(
new Error('Not Found')
);
});
- it("should return an error object when attempting to 'create' an unsupported type", async () => {
+ it('should return an error object when attempting to \'create\' an unsupported type', async () => {
await expect(
savedObjectsRepository.create('hiddenType', { title: 'some title' })
- ).rejects.toEqual(new Error("Unsupported saved object type: 'hiddenType': Bad Request"));
+ ).rejects.toEqual(new Error('Unsupported saved object type: \'hiddenType\': Bad Request'));
});
- it("should not return hidden saved ojects when attempting to 'find' support and unsupported types", async () => {
+ it('should not return hidden saved ojects when attempting to \'find\' support and unsupported types', async () => {
callAdminCluster.mockReturnValue({
hits: {
total: 1,
@@ -2146,7 +2147,7 @@ describe('SavedObjectsRepository', () => {
});
});
- it("should return empty results when attempting to 'find' an unsupported type", async () => {
+ it('should return empty results when attempting to \'find\' an unsupported type', async () => {
callAdminCluster.mockReturnValue({
hits: {
total: 0,
@@ -2162,7 +2163,7 @@ describe('SavedObjectsRepository', () => {
});
});
- it("should return empty results when attempting to 'find' more than one unsupported types", async () => {
+ it('should return empty results when attempting to \'find\' more than one unsupported types', async () => {
const findParams = { type: ['hiddenType', 'hiddenType2'] };
callAdminCluster.mockReturnValue({
status: 200,
@@ -2180,13 +2181,13 @@ describe('SavedObjectsRepository', () => {
});
});
- it("should error when attempting to 'delete' hidden types", async () => {
+ it('should error when attempting to \'delete\' hidden types', async () => {
await expect(savedObjectsRepository.delete('hiddenType')).rejects.toEqual(
new Error('Not Found')
);
});
- it("should error when attempting to 'bulkCreate' an unsupported type", async () => {
+ it('should error when attempting to \'bulkCreate\' an unsupported type', async () => {
callAdminCluster.mockReturnValue({
items: [
{
@@ -2219,7 +2220,7 @@ describe('SavedObjectsRepository', () => {
{
error: {
error: 'Bad Request',
- message: "Unsupported saved object type: 'hiddenType': Bad Request",
+ message: 'Unsupported saved object type: \'hiddenType\': Bad Request',
statusCode: 400,
},
id: 'two',
@@ -2229,10 +2230,10 @@ describe('SavedObjectsRepository', () => {
});
});
- it("should error when attempting to 'incrementCounter' for an unsupported type", async () => {
+ it('should error when attempting to \'incrementCounter\' for an unsupported type', async () => {
await expect(
savedObjectsRepository.incrementCounter('hiddenType', 'doesntmatter', 'fieldArg')
- ).rejects.toEqual(new Error("Unsupported saved object type: 'hiddenType': Bad Request"));
+ ).rejects.toEqual(new Error('Unsupported saved object type: \'hiddenType\': Bad Request'));
});
});
});
diff --git a/src/legacy/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts
similarity index 91%
rename from src/legacy/server/saved_objects/service/lib/repository.ts
rename to src/core/server/saved_objects/service/lib/repository.ts
index ef4b17f5106c9..eb41df3a19d2d 100644
--- a/src/legacy/server/saved_objects/service/lib/repository.ts
+++ b/src/core/server/saved_objects/service/lib/repository.ts
@@ -19,28 +19,28 @@
import { omit } from 'lodash';
import { CallCluster } from 'src/legacy/core_plugins/elasticsearch';
-import { getRootPropertiesObjects, IndexMapping } from '../../../mappings';
+import { getRootPropertiesObjects, IndexMapping } from '../../mappings';
import { getSearchDsl } from './search_dsl';
import { includedFields } from './included_fields';
import { decorateEsError } from './decorate_es_error';
-import * as errors from './errors';
+import { SavedObjectsErrorHelpers } from './errors';
import { decodeRequestVersion, encodeVersion, encodeHitVersion } from '../../version';
import { SavedObjectsSchema } from '../../schema';
import { KibanaMigrator } from '../../migrations';
import { SavedObjectsSerializer, SanitizedSavedObjectDoc, RawDoc } from '../../serialization';
import {
- BulkCreateObject,
- CreateOptions,
SavedObject,
- FindOptions,
SavedObjectAttributes,
- FindResponse,
- BulkGetObject,
- BulkResponse,
- UpdateOptions,
- BaseOptions,
- MigrationVersion,
- UpdateResponse,
+ SavedObjectsBaseOptions,
+ SavedObjectsBulkCreateObject,
+ SavedObjectsBulkGetObject,
+ SavedObjectsBulkResponse,
+ SavedObjectsCreateOptions,
+ SavedObjectsFindOptions,
+ SavedObjectsFindResponse,
+ SavedObjectsMigrationVersion,
+ SavedObjectsUpdateOptions,
+ SavedObjectsUpdateResponse,
} from '../saved_objects_client';
// BEWARE: The SavedObjectClient depends on the implementation details of the SavedObjectsRepository
@@ -73,8 +73,8 @@ export interface SavedObjectsRepositoryOptions {
onBeforeWrite?: (...args: Parameters) => Promise;
}
-export interface IncrementCounterOptions extends BaseOptions {
- migrationVersion?: MigrationVersion;
+export interface IncrementCounterOptions extends SavedObjectsBaseOptions {
+ migrationVersion?: SavedObjectsMigrationVersion;
}
export class SavedObjectsRepository {
@@ -141,12 +141,12 @@ export class SavedObjectsRepository {
public async create(
type: string,
attributes: T,
- options: CreateOptions = { overwrite: false, references: [] }
+ options: SavedObjectsCreateOptions = { overwrite: false, references: [] }
): Promise> {
const { id, migrationVersion, overwrite, namespace, references } = options;
if (!this._allowedTypes.includes(type)) {
- throw errors.createUnsupportedTypeError(type);
+ throw SavedObjectsErrorHelpers.createUnsupportedTypeError(type);
}
const method = id && !overwrite ? 'create' : 'index';
@@ -177,9 +177,9 @@ export class SavedObjectsRepository {
...response,
});
} catch (error) {
- if (errors.isNotFoundError(error)) {
+ if (SavedObjectsErrorHelpers.isNotFoundError(error)) {
// See "503s from missing index" above
- throw errors.createEsAutoCreateIndexError();
+ throw SavedObjectsErrorHelpers.createEsAutoCreateIndexError();
}
throw error;
@@ -196,9 +196,9 @@ export class SavedObjectsRepository {
* @returns {promise} - {saved_objects: [[{ id, type, version, references, attributes, error: { message } }]}
*/
async bulkCreate(
- objects: Array>,
- options: CreateOptions = {}
- ): Promise> {
+ objects: Array>,
+ options: SavedObjectsCreateOptions = {}
+ ): Promise> {
const { namespace, overwrite = false } = options;
const time = this._getCurrentTime();
const bulkCreateParams: object[] = [];
@@ -211,7 +211,7 @@ export class SavedObjectsRepository {
error: {
id: object.id,
type: object.type,
- error: errors.createUnsupportedTypeError(object.type).output.payload,
+ error: SavedObjectsErrorHelpers.createUnsupportedTypeError(object.type).output.payload,
},
};
}
@@ -307,9 +307,9 @@ export class SavedObjectsRepository {
* @property {string} [options.namespace]
* @returns {promise}
*/
- async delete(type: string, id: string, options: BaseOptions = {}): Promise<{}> {
+ async delete(type: string, id: string, options: SavedObjectsBaseOptions = {}): Promise<{}> {
if (!this._allowedTypes.includes(type)) {
- throw errors.createGenericNotFoundError();
+ throw SavedObjectsErrorHelpers.createGenericNotFoundError();
}
const { namespace } = options;
@@ -330,7 +330,7 @@ export class SavedObjectsRepository {
const indexNotFound = response.error && response.error.type === 'index_not_found_exception';
if (docNotFound || indexNotFound) {
// see "404s from missing index" above
- throw errors.createGenericNotFoundError(type, id);
+ throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
throw new Error(
@@ -397,7 +397,7 @@ export class SavedObjectsRepository {
fields,
namespace,
type,
- }: FindOptions): Promise> {
+ }: SavedObjectsFindOptions): Promise> {
if (!type) {
throw new TypeError(`options.type must be a string or an array of strings`);
}
@@ -479,9 +479,9 @@ export class SavedObjectsRepository {
* ])
*/
async bulkGet(
- objects: BulkGetObject[] = [],
- options: BaseOptions = {}
- ): Promise> {
+ objects: SavedObjectsBulkGetObject[] = [],
+ options: SavedObjectsBaseOptions = {}
+ ): Promise> {
const { namespace } = options;
if (objects.length === 0) {
@@ -494,7 +494,7 @@ export class SavedObjectsRepository {
return ({
id,
type,
- error: errors.createUnsupportedTypeError(type).output.payload,
+ error: SavedObjectsErrorHelpers.createUnsupportedTypeError(type).output.payload,
} as any) as SavedObject;
});
@@ -552,10 +552,10 @@ export class SavedObjectsRepository {
async get(
type: string,
id: string,
- options: BaseOptions = {}
+ options: SavedObjectsBaseOptions = {}
): Promise> {
if (!this._allowedTypes.includes(type)) {
- throw errors.createGenericNotFoundError(type, id);
+ throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
const { namespace } = options;
@@ -570,7 +570,7 @@ export class SavedObjectsRepository {
const indexNotFound = response.status === 404;
if (docNotFound || indexNotFound) {
// see "404s from missing index" above
- throw errors.createGenericNotFoundError(type, id);
+ throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
const { updated_at: updatedAt } = response._source;
@@ -601,10 +601,10 @@ export class SavedObjectsRepository {
type: string,
id: string,
attributes: Partial,
- options: UpdateOptions = {}
- ): Promise> {
+ options: SavedObjectsUpdateOptions = {}
+ ): Promise> {
if (!this._allowedTypes.includes(type)) {
- throw errors.createGenericNotFoundError(type, id);
+ throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
const { version, namespace, references = [] } = options;
@@ -627,7 +627,7 @@ export class SavedObjectsRepository {
if (response.status === 404) {
// see "404s from missing index" above
- throw errors.createGenericNotFoundError(type, id);
+ throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
return {
@@ -663,7 +663,7 @@ export class SavedObjectsRepository {
throw new Error('"counterFieldName" argument must be a string');
}
if (!this._allowedTypes.includes(type)) {
- throw errors.createUnsupportedTypeError(type);
+ throw SavedObjectsErrorHelpers.createUnsupportedTypeError(type);
}
const { migrationVersion, namespace } = options;
diff --git a/src/legacy/server/saved_objects/service/lib/scoped_client_provider.test.js b/src/core/server/saved_objects/service/lib/scoped_client_provider.test.js
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/scoped_client_provider.test.js
rename to src/core/server/saved_objects/service/lib/scoped_client_provider.test.js
diff --git a/src/legacy/server/saved_objects/service/lib/scoped_client_provider.ts b/src/core/server/saved_objects/service/lib/scoped_client_provider.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/scoped_client_provider.ts
rename to src/core/server/saved_objects/service/lib/scoped_client_provider.ts
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/__snapshots__/sorting_params.test.ts.snap b/src/core/server/saved_objects/service/lib/search_dsl/__snapshots__/sorting_params.test.ts.snap
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/__snapshots__/sorting_params.test.ts.snap
rename to src/core/server/saved_objects/service/lib/search_dsl/__snapshots__/sorting_params.test.ts.snap
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/index.ts b/src/core/server/saved_objects/service/lib/search_dsl/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/index.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/index.ts
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/query_params.test.ts b/src/core/server/saved_objects/service/lib/search_dsl/query_params.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/query_params.test.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/query_params.test.ts
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/query_params.ts b/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts
similarity index 99%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/query_params.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/query_params.ts
index 8e1dc1ded3f2c..9c145258a755f 100644
--- a/src/legacy/server/saved_objects/service/lib/search_dsl/query_params.ts
+++ b/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { getRootPropertiesObjects, IndexMapping } from '../../../../mappings';
+import { getRootPropertiesObjects, IndexMapping } from '../../../mappings';
import { SavedObjectsSchema } from '../../../schema';
/**
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/search_dsl.test.ts b/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/search_dsl.test.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/search_dsl.test.ts
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/search_dsl.ts b/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts
similarity index 97%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/search_dsl.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts
index 83e06eb17ccf2..1c2c87bca6ea7 100644
--- a/src/legacy/server/saved_objects/service/lib/search_dsl/search_dsl.ts
+++ b/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts
@@ -19,7 +19,7 @@
import Boom from 'boom';
-import { IndexMapping } from '../../../../mappings';
+import { IndexMapping } from '../../../mappings';
import { SavedObjectsSchema } from '../../../schema';
import { getQueryParams } from './query_params';
import { getSortingParams } from './sorting_params';
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/sorting_params.test.ts b/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/sorting_params.test.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/sorting_params.test.ts
diff --git a/src/legacy/server/saved_objects/service/lib/search_dsl/sorting_params.ts b/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts
similarity index 96%
rename from src/legacy/server/saved_objects/service/lib/search_dsl/sorting_params.ts
rename to src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts
index 444ab0774e7eb..d96d43eb9e7f6 100644
--- a/src/legacy/server/saved_objects/service/lib/search_dsl/sorting_params.ts
+++ b/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts
@@ -18,7 +18,7 @@
*/
import Boom from 'boom';
-import { getProperty, IndexMapping } from '../../../../mappings';
+import { getProperty, IndexMapping } from '../../../mappings';
const TOP_LEVEL_FIELDS = ['_id'];
diff --git a/src/legacy/server/saved_objects/service/saved_objects_client.mock.ts b/src/core/server/saved_objects/service/saved_objects_client.mock.ts
similarity index 92%
rename from src/legacy/server/saved_objects/service/saved_objects_client.mock.ts
rename to src/core/server/saved_objects/service/saved_objects_client.mock.ts
index 16de6e4eb5b52..4d1ceeaf552b6 100644
--- a/src/legacy/server/saved_objects/service/saved_objects_client.mock.ts
+++ b/src/core/server/saved_objects/service/saved_objects_client.mock.ts
@@ -18,10 +18,10 @@
*/
import { SavedObjectsClientContract } from './saved_objects_client';
-import * as errors from './lib/errors';
+import { SavedObjectsErrorHelpers } from './lib/errors';
const create = (): jest.Mocked => ({
- errors,
+ errors: SavedObjectsErrorHelpers,
create: jest.fn(),
bulkCreate: jest.fn(),
delete: jest.fn(),
diff --git a/src/legacy/server/saved_objects/service/saved_objects_client.test.js b/src/core/server/saved_objects/service/saved_objects_client.test.js
similarity index 100%
rename from src/legacy/server/saved_objects/service/saved_objects_client.test.js
rename to src/core/server/saved_objects/service/saved_objects_client.test.js
diff --git a/src/legacy/server/saved_objects/service/saved_objects_client.ts b/src/core/server/saved_objects/service/saved_objects_client.ts
similarity index 50%
rename from src/legacy/server/saved_objects/service/saved_objects_client.ts
rename to src/core/server/saved_objects/service/saved_objects_client.ts
index a0d378bfc5a97..14a4f99314e03 100644
--- a/src/legacy/server/saved_objects/service/saved_objects_client.ts
+++ b/src/core/server/saved_objects/service/saved_objects_client.ts
@@ -17,37 +17,59 @@
* under the License.
*/
-import { errors, SavedObjectsRepository } from './lib';
+import { SavedObjectsRepository } from './lib';
+
+import { SavedObjectsErrorHelpers } from './lib/errors';
type Omit = Pick>;
-export interface BaseOptions {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsBaseOptions {
/** Specify the namespace for this operation */
namespace?: string;
}
-export interface CreateOptions extends BaseOptions {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
/** (not recommended) Specify an id for the document */
id?: string;
/** Overwrite existing documents (defaults to false) */
overwrite?: boolean;
- migrationVersion?: MigrationVersion;
+ migrationVersion?: SavedObjectsMigrationVersion;
references?: SavedObjectReference[];
}
-export interface BulkCreateObject {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsBulkCreateObject {
id?: string;
type: string;
attributes: T;
references?: SavedObjectReference[];
- migrationVersion?: MigrationVersion;
+ migrationVersion?: SavedObjectsMigrationVersion;
}
-export interface BulkResponse {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsBulkResponse {
saved_objects: Array>;
}
-export interface FindOptions extends BaseOptions {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions {
type?: string | string[];
page?: number;
perPage?: number;
@@ -61,31 +83,51 @@ export interface FindOptions extends BaseOptions {
defaultSearchOperator?: 'AND' | 'OR';
}
-export interface FindResponse {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsFindResponse {
saved_objects: Array>;
total: number;
per_page: number;
page: number;
}
-export interface UpdateOptions extends BaseOptions {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsUpdateOptions extends SavedObjectsBaseOptions {
/** Ensures version matches that of persisted object */
version?: string;
references?: SavedObjectReference[];
}
-export interface BulkGetObject {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsBulkGetObject {
id: string;
type: string;
/** SavedObject fields to include in the response */
fields?: string[];
}
-export interface BulkResponse {
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsBulkResponse {
saved_objects: Array>;
}
-export interface UpdateResponse
+/**
+ *
+ * @public
+ */
+export interface SavedObjectsUpdateResponse
extends Omit, 'attributes'> {
attributes: Partial;
}
@@ -93,19 +135,25 @@ export interface UpdateResponse
/**
* A dictionary of saved object type -> version used to determine
* what migrations need to be applied to a saved object.
+ *
+ * @public
*/
-export interface MigrationVersion {
+export interface SavedObjectsMigrationVersion {
[pluginName: string]: string;
}
+/**
+ *
+ * @public
+ */
export interface SavedObjectAttributes {
[key: string]: SavedObjectAttributes | string | number | boolean | null;
}
-export interface VisualizationAttributes extends SavedObjectAttributes {
- visState: string;
-}
-
+/**
+ *
+ * @public
+ */
export interface SavedObject {
id: string;
type: string;
@@ -117,11 +165,13 @@ export interface SavedObject {
};
attributes: T;
references: SavedObjectReference[];
- migrationVersion?: MigrationVersion;
+ migrationVersion?: SavedObjectsMigrationVersion;
}
/**
* A reference to another saved object.
+ *
+ * @public
*/
export interface SavedObjectReference {
name: string;
@@ -129,76 +179,82 @@ export interface SavedObjectReference {
id: string;
}
+/**
+ * ## SavedObjectsClient errors
+ *
+ * Since 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 {@link SavedObjectsErrorHelpers}
+ *
+ * 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 index
+ *
+ * From 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 index
+ *
+ * Unlike 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 {@link SavedObjectsErrorHelpers}
+ *
+ * @public
+ */
export type SavedObjectsClientContract = Pick;
+/**
+ *
+ * @internal
+ */
export class SavedObjectsClient {
- /**
- * ## SavedObjectsClient errors
- *
- * Since 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 `./lib/errors`
- *
- * Type 1 errors are inevitable, but since all expected/handle-able errors
- * should be Type 2 the `isXYZError()` helpers exposed at
- * `savedObjectsClient.errors` 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 (savedObjectsClient.errors.isNotFoundError(error)) {
- * // handle 404
- * }
- *
- * if (savedObjectsClient.errors.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 index
- *
- * From 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 index
- *
- * Unlike 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.
- *
- * @type {ErrorHelpers} see ./lib/errors
- */
- public static errors = errors;
- public errors = errors;
+ public static errors = SavedObjectsErrorHelpers;
+ public errors = SavedObjectsErrorHelpers;
private _repository: SavedObjectsRepository;
@@ -216,7 +272,7 @@ export class SavedObjectsClient {
async create(
type: string,
attributes: T,
- options?: CreateOptions
+ options?: SavedObjectsCreateOptions
) {
return await this._repository.create(type, attributes, options);
}
@@ -228,8 +284,8 @@ export class SavedObjectsClient {
* @param options
*/
async bulkCreate(
- objects: Array>,
- options?: CreateOptions
+ objects: Array>,
+ options?: SavedObjectsCreateOptions
) {
return await this._repository.bulkCreate(objects, options);
}
@@ -241,7 +297,7 @@ export class SavedObjectsClient {
* @param id
* @param options
*/
- async delete(type: string, id: string, options: BaseOptions = {}) {
+ async delete(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
return await this._repository.delete(type, id, options);
}
@@ -251,8 +307,8 @@ export class SavedObjectsClient {
* @param options
*/
async find(
- options: FindOptions
- ): Promise> {
+ options: SavedObjectsFindOptions
+ ): Promise> {
return await this._repository.find(options);
}
@@ -268,9 +324,9 @@ export class SavedObjectsClient {
* ])
*/
async bulkGet(
- objects: BulkGetObject[] = [],
- options: BaseOptions = {}
- ): Promise> {
+ objects: SavedObjectsBulkGetObject[] = [],
+ options: SavedObjectsBaseOptions = {}
+ ): Promise> {
return await this._repository.bulkGet(objects, options);
}
@@ -284,7 +340,7 @@ export class SavedObjectsClient {
async get(
type: string,
id: string,
- options: BaseOptions = {}
+ options: SavedObjectsBaseOptions = {}
): Promise> {
return await this._repository.get(type, id, options);
}
@@ -300,8 +356,8 @@ export class SavedObjectsClient {
type: string,
id: string,
attributes: Partial,
- options: UpdateOptions = {}
- ): Promise> {
+ options: SavedObjectsUpdateOptions = {}
+ ): Promise> {
return await this._repository.update(type, id, attributes, options);
}
}
diff --git a/src/legacy/server/saved_objects/validation/index.ts b/src/core/server/saved_objects/validation/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/validation/index.ts
rename to src/core/server/saved_objects/validation/index.ts
diff --git a/src/legacy/server/saved_objects/validation/readme.md b/src/core/server/saved_objects/validation/readme.md
similarity index 100%
rename from src/legacy/server/saved_objects/validation/readme.md
rename to src/core/server/saved_objects/validation/readme.md
diff --git a/src/legacy/server/saved_objects/validation/validation.test.ts b/src/core/server/saved_objects/validation/validation.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/validation/validation.test.ts
rename to src/core/server/saved_objects/validation/validation.test.ts
diff --git a/src/legacy/server/saved_objects/version/base64.ts b/src/core/server/saved_objects/version/base64.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/base64.ts
rename to src/core/server/saved_objects/version/base64.ts
diff --git a/src/legacy/server/saved_objects/version/decode_request_version.test.ts b/src/core/server/saved_objects/version/decode_request_version.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/decode_request_version.test.ts
rename to src/core/server/saved_objects/version/decode_request_version.test.ts
diff --git a/src/legacy/server/saved_objects/version/decode_request_version.ts b/src/core/server/saved_objects/version/decode_request_version.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/decode_request_version.ts
rename to src/core/server/saved_objects/version/decode_request_version.ts
diff --git a/src/legacy/server/saved_objects/version/decode_version.test.ts b/src/core/server/saved_objects/version/decode_version.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/decode_version.test.ts
rename to src/core/server/saved_objects/version/decode_version.test.ts
diff --git a/src/legacy/server/saved_objects/version/decode_version.ts b/src/core/server/saved_objects/version/decode_version.ts
similarity index 91%
rename from src/legacy/server/saved_objects/version/decode_version.ts
rename to src/core/server/saved_objects/version/decode_version.ts
index 92e06c080b087..73e8ca9639799 100644
--- a/src/legacy/server/saved_objects/version/decode_version.ts
+++ b/src/core/server/saved_objects/version/decode_version.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { createInvalidVersionError } from '../service/lib/errors';
+import { SavedObjectsErrorHelpers } from '../service/lib/errors';
import { decodeBase64 } from './base64';
/**
@@ -46,6 +46,6 @@ export function decodeVersion(version?: string) {
_primary_term: seqParams[1],
};
} catch (_) {
- throw createInvalidVersionError(version);
+ throw SavedObjectsErrorHelpers.createInvalidVersionError(version);
}
}
diff --git a/src/legacy/server/saved_objects/version/encode_hit_version.test.ts b/src/core/server/saved_objects/version/encode_hit_version.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/encode_hit_version.test.ts
rename to src/core/server/saved_objects/version/encode_hit_version.test.ts
diff --git a/src/legacy/server/saved_objects/version/encode_hit_version.ts b/src/core/server/saved_objects/version/encode_hit_version.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/encode_hit_version.ts
rename to src/core/server/saved_objects/version/encode_hit_version.ts
diff --git a/src/legacy/server/saved_objects/version/encode_version.test.ts b/src/core/server/saved_objects/version/encode_version.test.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/encode_version.test.ts
rename to src/core/server/saved_objects/version/encode_version.test.ts
diff --git a/src/legacy/server/saved_objects/version/encode_version.ts b/src/core/server/saved_objects/version/encode_version.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/encode_version.ts
rename to src/core/server/saved_objects/version/encode_version.ts
diff --git a/src/legacy/server/saved_objects/version/index.ts b/src/core/server/saved_objects/version/index.ts
similarity index 100%
rename from src/legacy/server/saved_objects/version/index.ts
rename to src/core/server/saved_objects/version/index.ts
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index c0e1ce9028706..30beee4784bbf 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -4,7 +4,9 @@
```ts
+import Boom from 'boom';
import { ByteSizeValue } from '@kbn/config-schema';
+import { CallCluster } from 'src/legacy/core_plugins/elasticsearch';
import { ConfigOptions } from 'elasticsearch';
import { Duration } from 'moment';
import { ObjectType } from '@kbn/config-schema';
@@ -380,6 +382,244 @@ export class Router {
routes: Array>;
}
+// @public (undocumented)
+export interface SavedObject {
+ // (undocumented)
+ attributes: T;
+ // (undocumented)
+ error?: {
+ message: string;
+ statusCode: number;
+ };
+ // (undocumented)
+ id: string;
+ // (undocumented)
+ migrationVersion?: SavedObjectsMigrationVersion;
+ // (undocumented)
+ references: SavedObjectReference[];
+ // (undocumented)
+ type: string;
+ // (undocumented)
+ updated_at?: string;
+ // (undocumented)
+ version?: string;
+}
+
+// @public (undocumented)
+export interface SavedObjectAttributes {
+ // (undocumented)
+ [key: string]: SavedObjectAttributes | string | number | boolean | null;
+}
+
+// @public
+export interface SavedObjectReference {
+ // (undocumented)
+ id: string;
+ // (undocumented)
+ name: string;
+ // (undocumented)
+ type: string;
+}
+
+// @public (undocumented)
+export interface SavedObjectsBaseOptions {
+ namespace?: string;
+}
+
+// @public (undocumented)
+export interface SavedObjectsBulkCreateObject {
+ // (undocumented)
+ attributes: T;
+ // (undocumented)
+ id?: string;
+ // (undocumented)
+ migrationVersion?: SavedObjectsMigrationVersion;
+ // (undocumented)
+ references?: SavedObjectReference[];
+ // (undocumented)
+ type: string;
+}
+
+// @public (undocumented)
+export interface SavedObjectsBulkGetObject {
+ fields?: string[];
+ // (undocumented)
+ id: string;
+ // (undocumented)
+ type: string;
+}
+
+// @public (undocumented)
+export interface SavedObjectsBulkResponse {
+ // (undocumented)
+ saved_objects: Array>;
+}
+
+// @public (undocumented)
+export interface SavedObjectsBulkResponse {
+ // (undocumented)
+ saved_objects: Array>;
+}
+
+// @internal (undocumented)
+export class SavedObjectsClient {
+ // Warning: (ae-forgotten-export) The symbol "SavedObjectsRepository" needs to be exported by the entry point index.d.ts
+ constructor(repository: SavedObjectsRepository);
+ bulkCreate(objects: Array>, options?: SavedObjectsCreateOptions): Promise>;
+ bulkGet(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise>;
+ create(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise>;
+ delete(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<{}>;
+ // (undocumented)
+ errors: typeof SavedObjectsErrorHelpers;
+ // (undocumented)
+ static errors: typeof SavedObjectsErrorHelpers;
+ find(options: SavedObjectsFindOptions): Promise>;
+ get(type: string, id: string, options?: SavedObjectsBaseOptions): Promise>;
+ update(type: string, id: string, attributes: Partial, options?: SavedObjectsUpdateOptions): Promise>;
+}
+
+// Warning: (ae-incompatible-release-tags) The symbol "SavedObjectsClientContract" is marked as @public, but its signature references "SavedObjectsClient" which is marked as @internal
+//
+// @public
+export type SavedObjectsClientContract = Pick;
+
+// @public (undocumented)
+export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
+ id?: string;
+ // (undocumented)
+ migrationVersion?: SavedObjectsMigrationVersion;
+ overwrite?: boolean;
+ // (undocumented)
+ references?: SavedObjectReference[];
+}
+
+// @public (undocumented)
+export class SavedObjectsErrorHelpers {
+ // (undocumented)
+ static createBadRequestError(reason?: string): DecoratedError;
+ // (undocumented)
+ static createEsAutoCreateIndexError(): DecoratedError;
+ // (undocumented)
+ static createGenericNotFoundError(type?: string | null, id?: string | null): DecoratedError;
+ // (undocumented)
+ static createInvalidVersionError(versionInput?: string): DecoratedError;
+ // (undocumented)
+ static createUnsupportedTypeError(type: string): DecoratedError;
+ // (undocumented)
+ static decorateBadRequestError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static decorateConflictError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static decorateEsUnavailableError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static decorateForbiddenError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static decorateGeneralError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static decorateNotAuthorizedError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static decorateRequestEntityTooLargeError(error: Error, reason?: string): DecoratedError;
+ // (undocumented)
+ static isBadRequestError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isConflictError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isEsAutoCreateIndexError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isEsUnavailableError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isForbiddenError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isInvalidVersionError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isNotAuthorizedError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isNotFoundError(error: Error | DecoratedError): boolean;
+ // (undocumented)
+ static isRequestEntityTooLargeError(error: Error | DecoratedError): boolean;
+ // Warning: (ae-forgotten-export) The symbol "DecoratedError" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ static isSavedObjectsClientError(error: any): error is DecoratedError;
+}
+
+// @public (undocumented)
+export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions {
+ // (undocumented)
+ defaultSearchOperator?: 'AND' | 'OR';
+ // (undocumented)
+ fields?: string[];
+ // (undocumented)
+ hasReference?: {
+ type: string;
+ id: string;
+ };
+ // (undocumented)
+ page?: number;
+ // (undocumented)
+ perPage?: number;
+ // (undocumented)
+ search?: string;
+ searchFields?: string[];
+ // (undocumented)
+ sortField?: string;
+ // (undocumented)
+ sortOrder?: string;
+ // (undocumented)
+ type?: string | string[];
+}
+
+// @public (undocumented)
+export interface SavedObjectsFindResponse {
+ // (undocumented)
+ page: number;
+ // (undocumented)
+ per_page: number;
+ // (undocumented)
+ saved_objects: Array>;
+ // (undocumented)
+ total: number;
+}
+
+// @public
+export interface SavedObjectsMigrationVersion {
+ // (undocumented)
+ [pluginName: string]: string;
+}
+
+// @public (undocumented)
+export interface SavedObjectsService {
+ // Warning: (ae-forgotten-export) The symbol "ScopedSavedObjectsClientProvider" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ addScopedSavedObjectsClientWrapperFactory: ScopedSavedObjectsClientProvider['addClientWrapperFactory'];
+ // (undocumented)
+ getSavedObjectsRepository(...rest: any[]): any;
+ // (undocumented)
+ getScopedSavedObjectsClient: ScopedSavedObjectsClientProvider['getClient'];
+ // Warning: (ae-incompatible-release-tags) The symbol "SavedObjectsClient" is marked as @public, but its signature references "SavedObjectsClient" which is marked as @internal
+ //
+ // (undocumented)
+ SavedObjectsClient: typeof SavedObjectsClient;
+ // (undocumented)
+ types: string[];
+}
+
+// @public (undocumented)
+export interface SavedObjectsUpdateOptions extends SavedObjectsBaseOptions {
+ // (undocumented)
+ references?: SavedObjectReference[];
+ version?: string;
+}
+
+// Warning: (ae-forgotten-export) The symbol "Omit" needs to be exported by the entry point index.d.ts
+//
+// @public (undocumented)
+export interface SavedObjectsUpdateResponse extends Omit, 'attributes'> {
+ // (undocumented)
+ attributes: Partial;
+}
+
// @public
export class ScopedClusterClient {
constructor(internalAPICaller: APICaller, scopedAPICaller: APICaller, headers?: Record | undefined);
diff --git a/src/es_archiver/lib/indices/kibana_index.js b/src/es_archiver/lib/indices/kibana_index.js
index 1ab3c59e48376..b775a2e8e6765 100644
--- a/src/es_archiver/lib/indices/kibana_index.js
+++ b/src/es_archiver/lib/indices/kibana_index.js
@@ -26,7 +26,7 @@ import wreck from '@hapi/wreck';
import { deleteIndex } from './delete_index';
import { collectUiExports } from '../../../legacy/ui/ui_exports';
-import { KibanaMigrator } from '../../../legacy/server/saved_objects/migrations';
+import { KibanaMigrator } from '../../../core/server/saved_objects/migrations';
import { findPluginSpecs } from '../../../legacy/plugin_discovery';
/**
diff --git a/src/legacy/core_plugins/embeddable_api/public/embeddables/embeddable_factory.ts b/src/legacy/core_plugins/embeddable_api/public/embeddables/embeddable_factory.ts
index 545514a452f95..0fa7724e7eccd 100644
--- a/src/legacy/core_plugins/embeddable_api/public/embeddables/embeddable_factory.ts
+++ b/src/legacy/core_plugins/embeddable_api/public/embeddables/embeddable_factory.ts
@@ -18,7 +18,7 @@
*/
import { SavedObjectMetaData } from 'ui/saved_objects/components/saved_object_finder';
-import { SavedObjectAttributes } from '../../../../server/saved_objects';
+import { SavedObjectAttributes } from 'src/core/server';
import { EmbeddableInput, EmbeddableOutput } from './i_embeddable';
import { ErrorEmbeddable } from './error_embeddable';
import { IContainer } from '../containers/i_container';
diff --git a/src/legacy/core_plugins/embeddable_api/public/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx b/src/legacy/core_plugins/embeddable_api/public/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx
index 48e127fb063e8..962ab1989ec62 100644
--- a/src/legacy/core_plugins/embeddable_api/public/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx
+++ b/src/legacy/core_plugins/embeddable_api/public/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx
@@ -38,7 +38,7 @@ import {
EuiText,
} from '@elastic/eui';
-import { SavedObjectAttributes } from '../../../../../../../server/saved_objects';
+import { SavedObjectAttributes } from 'src/core/server/saved_objects';
import { EmbeddableFactoryNotFoundError } from '../../../../embeddables/embeddable_factory_not_found_error';
import { IContainer } from '../../../../containers';
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/top_nav/add_panel.tsx b/src/legacy/core_plugins/kibana/public/dashboard/top_nav/add_panel.tsx
index bf36c20ceb6e8..27595e2ecd548 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/top_nav/add_panel.tsx
+++ b/src/legacy/core_plugins/kibana/public/dashboard/top_nav/add_panel.tsx
@@ -37,7 +37,7 @@ import {
EuiButton,
EuiTitle,
} from '@elastic/eui';
-import { SavedObjectAttributes } from 'src/legacy/server/saved_objects';
+import { SavedObjectAttributes } from 'src/core/server/saved_objects';
import { EmbeddableFactoryRegistry } from '../types';
interface Props {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts
index e10cfb3cdb6c7..954c0962ba7ef 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts
@@ -29,12 +29,16 @@ import {
OnEmbeddableStateChanged,
} from 'ui/embeddable/embeddable_factory';
import { VisTypesRegistry } from 'ui/registry/vis_types';
+import { SavedObjectAttributes } from 'src/core/server';
import { VisualizeEmbeddable } from './visualize_embeddable';
-import { VisualizationAttributes } from '../../../../../server/saved_objects/service/saved_objects_client';
import { SavedVisualizations } from '../types';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';
import { getIndexPattern } from './get_index_pattern';
+export interface VisualizationAttributes extends SavedObjectAttributes {
+ visState: string;
+}
+
export class VisualizeEmbeddableFactory extends EmbeddableFactory {
private savedVisualizations: SavedVisualizations;
private config: Legacy.KibanaConfig;
diff --git a/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.test.ts b/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.test.ts
index 282730ad0e4db..89a7e2bc01818 100644
--- a/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.test.ts
+++ b/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.test.ts
@@ -17,10 +17,7 @@
* under the License.
*/
-import {
- SavedObject,
- SavedObjectsClient,
-} from '../../../../../server/saved_objects/service/saved_objects_client';
+import { SavedObject, SavedObjectsClient } from 'src/core/server';
import { collectReferencesDeep } from './collect_references_deep';
const data = [
diff --git a/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.ts b/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.ts
index 7fbcb02a51619..9d620b69bf2e3 100644
--- a/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.ts
+++ b/src/legacy/core_plugins/kibana/server/lib/export/collect_references_deep.ts
@@ -17,10 +17,7 @@
* under the License.
*/
-import {
- SavedObject,
- SavedObjectsClient,
-} from '../../../../../server/saved_objects/service/saved_objects_client';
+import { SavedObject, SavedObjectsClientContract } from 'src/core/server';
const MAX_BULK_GET_SIZE = 10000;
@@ -30,7 +27,7 @@ interface ObjectsToCollect {
}
export async function collectReferencesDeep(
- savedObjectClient: SavedObjectsClient,
+ savedObjectClient: SavedObjectsClientContract,
objects: ObjectsToCollect[]
) {
let result: SavedObject[] = [];
diff --git a/src/legacy/plugin_discovery/types.ts b/src/legacy/plugin_discovery/types.ts
index d7cc1aff7fa1e..eb772e9970ed4 100644
--- a/src/legacy/plugin_discovery/types.ts
+++ b/src/legacy/plugin_discovery/types.ts
@@ -19,7 +19,9 @@
import { Server } from '../server/kbn_server';
import { Capabilities } from '../../core/public';
-import { SavedObjectsSchemaDefinition } from '../server/saved_objects/schema';
+// Disable lint errors for imports from src/core/* until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { SavedObjectsSchemaDefinition } from '../../core/server/saved_objects/schema';
/**
* Usage
diff --git a/src/legacy/server/kbn_server.d.ts b/src/legacy/server/kbn_server.d.ts
index c86b967019b0a..09d274af330ac 100644
--- a/src/legacy/server/kbn_server.d.ts
+++ b/src/legacy/server/kbn_server.d.ts
@@ -20,23 +20,22 @@
import { ResponseObject, Server } from 'hapi';
import {
- ElasticsearchServiceSetup,
ConfigService,
- LoggerFactory,
+ ElasticsearchServiceSetup,
InternalCoreSetup,
InternalCoreStart,
+ LoggerFactory,
+ SavedObjectsClientContract,
+ SavedObjectsService,
} from '../../core/server';
+// Disable lint errors for imports from src/core/server/saved_objects until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { SavedObjectsManagement } from '../../core/server/saved_objects/management';
import { ApmOssPlugin } from '../core_plugins/apm_oss';
import { CallClusterWithRequest, ElasticsearchPlugin } from '../core_plugins/elasticsearch';
import { CapabilitiesModifier } from './capabilities';
import { IndexPatternsServiceFactory } from './index_patterns';
-import {
- SavedObjectsClient,
- SavedObjectsService,
- SavedObjectsSchema,
- SavedObjectsManagement,
-} from './saved_objects';
import { Capabilities } from '../../core/public';
export interface KibanaConfig {
@@ -75,7 +74,7 @@ declare module 'hapi' {
}
interface Request {
- getSavedObjectsClient(): SavedObjectsClient;
+ getSavedObjectsClient(): SavedObjectsClientContract;
getBasePath(): string;
getUiSettingsService(): any;
getCapabilities(): Promise;
@@ -127,4 +126,4 @@ export { Server, Request, ResponseToolkit } from 'hapi';
// Re-export commonly accessed api types.
export { IndexPatternsService } from './index_patterns';
-export { SavedObject, SavedObjectsClient, SavedObjectsService } from './saved_objects';
+export { SavedObjectsService, SavedObjectsClient } from 'src/core/server';
diff --git a/src/legacy/server/saved_objects/routes/bulk_create.test.ts b/src/legacy/server/saved_objects/routes/bulk_create.test.ts
index f981b0a62f605..1e041bb28f75f 100644
--- a/src/legacy/server/saved_objects/routes/bulk_create.test.ts
+++ b/src/legacy/server/saved_objects/routes/bulk_create.test.ts
@@ -20,7 +20,9 @@
import Hapi from 'hapi';
import { createMockServer } from './_mock_server';
import { createBulkCreateRoute } from './bulk_create';
-import { SavedObjectsClientMock } from '../service/saved_objects_client.mock';
+// Disable lint errors for imports from src/core/* until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { SavedObjectsClientMock } from '../../../../core/server/saved_objects/service/saved_objects_client.mock';
describe('POST /api/saved_objects/_bulk_create', () => {
let server: Hapi.Server;
diff --git a/src/legacy/server/saved_objects/routes/bulk_create.ts b/src/legacy/server/saved_objects/routes/bulk_create.ts
index 35b90ecbcd853..b185650494f94 100644
--- a/src/legacy/server/saved_objects/routes/bulk_create.ts
+++ b/src/legacy/server/saved_objects/routes/bulk_create.ts
@@ -19,7 +19,7 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectAttributes, SavedObjectsClientContract } from '../';
+import { SavedObjectAttributes, SavedObjectsClientContract } from 'src/core/server';
import { Prerequisites, SavedObjectReference, WithoutQueryAndParams } from './types';
interface SavedObject {
diff --git a/src/legacy/server/saved_objects/routes/bulk_get.ts b/src/legacy/server/saved_objects/routes/bulk_get.ts
index c3cb3ab4da400..e9eca8e557982 100644
--- a/src/legacy/server/saved_objects/routes/bulk_get.ts
+++ b/src/legacy/server/saved_objects/routes/bulk_get.ts
@@ -19,12 +19,12 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectsClient } from '../';
+import { SavedObjectsClientContract } from 'src/core/server';
import { Prerequisites } from './types';
interface BulkGetRequest extends Hapi.Request {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
payload: Array<{
type: string;
diff --git a/src/legacy/server/saved_objects/routes/create.ts b/src/legacy/server/saved_objects/routes/create.ts
index cd5c9af098864..a3f4a926972ca 100644
--- a/src/legacy/server/saved_objects/routes/create.ts
+++ b/src/legacy/server/saved_objects/routes/create.ts
@@ -19,7 +19,7 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectAttributes, SavedObjectsClient } from '../';
+import { SavedObjectAttributes, SavedObjectsClient } from 'src/core/server';
import { Prerequisites, SavedObjectReference, WithoutQueryAndParams } from './types';
interface CreateRequest extends WithoutQueryAndParams {
diff --git a/src/legacy/server/saved_objects/routes/delete.ts b/src/legacy/server/saved_objects/routes/delete.ts
index f5398fd1638df..a718f26bc2014 100644
--- a/src/legacy/server/saved_objects/routes/delete.ts
+++ b/src/legacy/server/saved_objects/routes/delete.ts
@@ -19,12 +19,12 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectsClient } from '../';
+import { SavedObjectsClientContract } from 'src/core/server';
import { Prerequisites } from './types';
interface DeleteRequest extends Hapi.Request {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
params: {
type: string;
diff --git a/src/legacy/server/saved_objects/routes/export.test.ts b/src/legacy/server/saved_objects/routes/export.test.ts
index 8096bce269bf2..c74548ab1bbd3 100644
--- a/src/legacy/server/saved_objects/routes/export.test.ts
+++ b/src/legacy/server/saved_objects/routes/export.test.ts
@@ -17,12 +17,14 @@
* under the License.
*/
-jest.mock('../export', () => ({
+jest.mock('../../../../core/server/saved_objects/export', () => ({
getSortedObjectsForExport: jest.fn(),
}));
import Hapi from 'hapi';
-import * as exportMock from '../export';
+// Disable lint errors for imports from src/core/server/saved_objects until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import * as exportMock from '../../../../core/server/saved_objects/export';
import { createMockServer } from './_mock_server';
import { createExportRoute } from './export';
diff --git a/src/legacy/server/saved_objects/routes/export.ts b/src/legacy/server/saved_objects/routes/export.ts
index 4b41c8b58c574..4bc5d04b5585a 100644
--- a/src/legacy/server/saved_objects/routes/export.ts
+++ b/src/legacy/server/saved_objects/routes/export.ts
@@ -20,13 +20,15 @@
import Hapi from 'hapi';
import Joi from 'joi';
import stringify from 'json-stable-stringify';
-import { SavedObjectsClient } from '../';
-import { getSortedObjectsForExport } from '../export';
+import { SavedObjectsClientContract } from 'src/core/server';
+// Disable lint errors for imports from src/core/server/saved_objects until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { getSortedObjectsForExport } from '../../../../core/server/saved_objects/export';
import { Prerequisites } from './types';
interface ExportRequest extends Hapi.Request {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
payload: {
type?: string[];
diff --git a/src/legacy/server/saved_objects/routes/find.ts b/src/legacy/server/saved_objects/routes/find.ts
index 0d7661af5c171..bb8fb21aea29c 100644
--- a/src/legacy/server/saved_objects/routes/find.ts
+++ b/src/legacy/server/saved_objects/routes/find.ts
@@ -19,12 +19,12 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectsClient } from '../';
+import { SavedObjectsClientContract } from 'src/core/server';
import { Prerequisites, WithoutQueryAndParams } from './types';
interface FindRequest extends WithoutQueryAndParams {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
query: {
per_page: number;
diff --git a/src/legacy/server/saved_objects/routes/get.ts b/src/legacy/server/saved_objects/routes/get.ts
index db4ab6374402a..4dbb06d53425a 100644
--- a/src/legacy/server/saved_objects/routes/get.ts
+++ b/src/legacy/server/saved_objects/routes/get.ts
@@ -19,12 +19,12 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectsClient } from '../';
+import { SavedObjectsClientContract } from 'src/core/server';
import { Prerequisites } from './types';
interface GetRequest extends Hapi.Request {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
params: {
type: string;
diff --git a/src/legacy/server/saved_objects/routes/import.ts b/src/legacy/server/saved_objects/routes/import.ts
index 5fccee1614028..ea83328231718 100644
--- a/src/legacy/server/saved_objects/routes/import.ts
+++ b/src/legacy/server/saved_objects/routes/import.ts
@@ -22,8 +22,10 @@ import Hapi from 'hapi';
import Joi from 'joi';
import { extname } from 'path';
import { Readable } from 'stream';
-import { SavedObjectsClient } from '../';
-import { importSavedObjects } from '../import';
+import { SavedObjectsClientContract } from 'src/core/server';
+// Disable lint errors for imports from src/core/server/saved_objects until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { importSavedObjects } from '../../../../core/server/saved_objects/import';
import { Prerequisites, WithoutQueryAndParams } from './types';
interface HapiReadableStream extends Readable {
@@ -34,7 +36,7 @@ interface HapiReadableStream extends Readable {
interface ImportRequest extends WithoutQueryAndParams {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
query: {
overwrite: boolean;
diff --git a/src/legacy/server/saved_objects/routes/resolve_import_errors.ts b/src/legacy/server/saved_objects/routes/resolve_import_errors.ts
index 516a80988ce05..24390df9b6ecb 100644
--- a/src/legacy/server/saved_objects/routes/resolve_import_errors.ts
+++ b/src/legacy/server/saved_objects/routes/resolve_import_errors.ts
@@ -22,8 +22,10 @@ import Hapi from 'hapi';
import Joi from 'joi';
import { extname } from 'path';
import { Readable } from 'stream';
-import { SavedObjectsClient } from '../';
-import { resolveImportErrors } from '../import';
+import { SavedObjectsClientContract } from 'src/core/server';
+// Disable lint errors for imports from src/core/server/saved_objects until SavedObjects migration is complete
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { resolveImportErrors } from '../../../../core/server/saved_objects/import';
import { Prerequisites } from './types';
interface HapiReadableStream extends Readable {
@@ -34,7 +36,7 @@ interface HapiReadableStream extends Readable {
interface ImportRequest extends Hapi.Request {
pre: {
- savedObjectsClient: SavedObjectsClient;
+ savedObjectsClient: SavedObjectsClientContract;
};
payload: {
file: HapiReadableStream;
diff --git a/src/legacy/server/saved_objects/routes/types.ts b/src/legacy/server/saved_objects/routes/types.ts
index f658a61117890..b3f294b66499b 100644
--- a/src/legacy/server/saved_objects/routes/types.ts
+++ b/src/legacy/server/saved_objects/routes/types.ts
@@ -18,7 +18,7 @@
*/
import Hapi from 'hapi';
-import { SavedObjectsClientContract } from '../';
+import { SavedObjectsClientContract } from 'src/core/server';
export interface SavedObjectReference {
name: string;
diff --git a/src/legacy/server/saved_objects/routes/update.ts b/src/legacy/server/saved_objects/routes/update.ts
index 9d0cde0816dfe..7782253f9b542 100644
--- a/src/legacy/server/saved_objects/routes/update.ts
+++ b/src/legacy/server/saved_objects/routes/update.ts
@@ -19,7 +19,7 @@
import Hapi from 'hapi';
import Joi from 'joi';
-import { SavedObjectAttributes, SavedObjectsClient } from '../';
+import { SavedObjectAttributes, SavedObjectsClient } from 'src/core/server';
import { Prerequisites, SavedObjectReference } from './types';
interface UpdateRequest extends Hapi.Request {
diff --git a/src/legacy/server/saved_objects/saved_objects_mixin.js b/src/legacy/server/saved_objects/saved_objects_mixin.js
index 0ab126abdd995..52845abbf08c2 100644
--- a/src/legacy/server/saved_objects/saved_objects_mixin.js
+++ b/src/legacy/server/saved_objects/saved_objects_mixin.js
@@ -17,16 +17,19 @@
* under the License.
*/
-import { KibanaMigrator } from './migrations';
-import { SavedObjectsSchema } from './schema';
-import { SavedObjectsSerializer } from './serialization';
+// Disable lint errors for imports from src/core/server/saved_objects until SavedObjects migration is complete
+/* eslint-disable @kbn/eslint/no-restricted-paths */
+
+import { KibanaMigrator } from '../../../core/server/saved_objects/migrations';
+import { SavedObjectsSchema } from '../../../core/server/saved_objects/schema';
+import { SavedObjectsSerializer } from '../../../core/server/saved_objects/serialization';
import {
SavedObjectsClient,
SavedObjectsRepository,
ScopedSavedObjectsClientProvider,
-} from './service';
-import { getRootPropertiesObjects } from '../mappings';
-import { SavedObjectsManagement } from './management';
+} from '../../../core/server/saved_objects/service';
+import { getRootPropertiesObjects } from '../../../core/server/saved_objects/mappings';
+import { SavedObjectsManagement } from '../../../core/server/saved_objects/management';
import {
createBulkCreateRoute,
diff --git a/src/legacy/server/saved_objects/service/lib/errors.ts b/src/legacy/server/saved_objects/service/lib/errors.ts
deleted file mode 100644
index e1df155022b11..0000000000000
--- a/src/legacy/server/saved_objects/service/lib/errors.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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 Boom from 'boom';
-
-const code = Symbol('SavedObjectsClientErrorCode');
-
-interface DecoratedError extends Boom {
- [code]?: string;
-}
-
-function decorate(
- error: Error | DecoratedError,
- errorCode: string,
- statusCode: number,
- message?: string
-): DecoratedError {
- if (isSavedObjectsClientError(error)) {
- return error;
- }
-
- const boom = Boom.boomify(error, {
- statusCode,
- message,
- override: false,
- }) as DecoratedError;
-
- boom[code] = errorCode;
-
- return boom;
-}
-
-export function isSavedObjectsClientError(error: any): error is DecoratedError {
- return Boolean(error && error[code]);
-}
-
-// 400 - badRequest
-const CODE_BAD_REQUEST = 'SavedObjectsClient/badRequest';
-export function decorateBadRequestError(error: Error, reason?: string) {
- return decorate(error, CODE_BAD_REQUEST, 400, reason);
-}
-export function createBadRequestError(reason?: string) {
- return decorateBadRequestError(new Error('Bad Request'), reason);
-}
-export function createUnsupportedTypeError(type: string) {
- return createBadRequestError(`Unsupported saved object type: '${type}'`);
-}
-export function isBadRequestError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_BAD_REQUEST;
-}
-
-// 400 - invalid version
-const CODE_INVALID_VERSION = 'SavedObjectsClient/invalidVersion';
-export function createInvalidVersionError(versionInput?: string) {
- return decorate(Boom.badRequest(`Invalid version [${versionInput}]`), CODE_INVALID_VERSION, 400);
-}
-export function isInvalidVersionError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_INVALID_VERSION;
-}
-
-// 401 - Not Authorized
-const CODE_NOT_AUTHORIZED = 'SavedObjectsClient/notAuthorized';
-export function decorateNotAuthorizedError(error: Error, reason?: string) {
- return decorate(error, CODE_NOT_AUTHORIZED, 401, reason);
-}
-export function isNotAuthorizedError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_NOT_AUTHORIZED;
-}
-
-// 403 - Forbidden
-const CODE_FORBIDDEN = 'SavedObjectsClient/forbidden';
-export function decorateForbiddenError(error: Error, reason?: string) {
- return decorate(error, CODE_FORBIDDEN, 403, reason);
-}
-export function isForbiddenError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_FORBIDDEN;
-}
-
-// 413 - Request Entity Too Large
-const CODE_REQUEST_ENTITY_TOO_LARGE = 'SavedObjectsClient/requestEntityTooLarge';
-export function decorateRequestEntityTooLargeError(error: Error, reason?: string) {
- return decorate(error, CODE_REQUEST_ENTITY_TOO_LARGE, 413, reason);
-}
-export function isRequestEntityTooLargeError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_REQUEST_ENTITY_TOO_LARGE;
-}
-
-// 404 - Not Found
-const CODE_NOT_FOUND = 'SavedObjectsClient/notFound';
-export function createGenericNotFoundError(type: string | null = null, id: string | null = null) {
- if (type && id) {
- return decorate(Boom.notFound(`Saved object [${type}/${id}] not found`), CODE_NOT_FOUND, 404);
- }
- return decorate(Boom.notFound(), CODE_NOT_FOUND, 404);
-}
-export function isNotFoundError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_NOT_FOUND;
-}
-
-// 409 - Conflict
-const CODE_CONFLICT = 'SavedObjectsClient/conflict';
-export function decorateConflictError(error: Error, reason?: string) {
- return decorate(error, CODE_CONFLICT, 409, reason);
-}
-export function isConflictError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_CONFLICT;
-}
-
-// 503 - Es Unavailable
-const CODE_ES_UNAVAILABLE = 'SavedObjectsClient/esUnavailable';
-export function decorateEsUnavailableError(error: Error, reason?: string) {
- return decorate(error, CODE_ES_UNAVAILABLE, 503, reason);
-}
-export function isEsUnavailableError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_ES_UNAVAILABLE;
-}
-
-// 503 - Unable to automatically create index because of action.auto_create_index setting
-const CODE_ES_AUTO_CREATE_INDEX_ERROR = 'SavedObjectsClient/autoCreateIndex';
-export function createEsAutoCreateIndexError() {
- const error = Boom.serverUnavailable('Automatic index creation failed');
- error.output.payload.attributes = error.output.payload.attributes || {};
- error.output.payload.attributes.code = 'ES_AUTO_CREATE_INDEX_ERROR';
-
- return decorate(error, CODE_ES_AUTO_CREATE_INDEX_ERROR, 503);
-}
-export function isEsAutoCreateIndexError(error: Error | DecoratedError) {
- return isSavedObjectsClientError(error) && error[code] === CODE_ES_AUTO_CREATE_INDEX_ERROR;
-}
-
-// 500 - General Error
-const CODE_GENERAL_ERROR = 'SavedObjectsClient/generalError';
-export function decorateGeneralError(error: Error, reason?: string) {
- return decorate(error, CODE_GENERAL_ERROR, 500, reason);
-}
diff --git a/src/legacy/server/url_shortening/routes/lib/short_url_lookup.test.js b/src/legacy/server/url_shortening/routes/lib/short_url_lookup.test.js
index 837a062868ee7..033aeb92926a5 100644
--- a/src/legacy/server/url_shortening/routes/lib/short_url_lookup.test.js
+++ b/src/legacy/server/url_shortening/routes/lib/short_url_lookup.test.js
@@ -19,7 +19,7 @@
import sinon from 'sinon';
import { shortUrlLookupProvider } from './short_url_lookup';
-import { SavedObjectsClient } from '../../../saved_objects';
+import { SavedObjectsClient } from '../../../../../core/server';
describe('shortUrlLookupProvider', () => {
const ID = 'bf00ad16941fc51420f91a93428b27a0';
diff --git a/src/legacy/ui/public/embeddable/embeddable_factory.ts b/src/legacy/ui/public/embeddable/embeddable_factory.ts
index e71813b22995f..782b8053498a9 100644
--- a/src/legacy/ui/public/embeddable/embeddable_factory.ts
+++ b/src/legacy/ui/public/embeddable/embeddable_factory.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { SavedObjectAttributes } from '../../../server/saved_objects';
+import { SavedObjectAttributes } from 'src/core/server';
import { SavedObjectMetaData } from '../saved_objects/components/saved_object_finder';
import { Embeddable } from './embeddable';
import { EmbeddableState } from './types';
diff --git a/src/legacy/ui/public/saved_objects/components/saved_object_finder.tsx b/src/legacy/ui/public/saved_objects/components/saved_object_finder.tsx
index 69aecc8b78625..a5930ee38a662 100644
--- a/src/legacy/ui/public/saved_objects/components/saved_object_finder.tsx
+++ b/src/legacy/ui/public/saved_objects/components/saved_object_finder.tsx
@@ -45,7 +45,7 @@ import {
import { Direction } from '@elastic/eui/src/services/sort/sort_direction';
import { i18n } from '@kbn/i18n';
-import { SavedObjectAttributes } from '../../../../server/saved_objects';
+import { SavedObjectAttributes } from 'src/core/server';
import { SimpleSavedObject } from '../simple_saved_object';
// TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted
diff --git a/src/legacy/ui/public/saved_objects/find_object_by_title.ts b/src/legacy/ui/public/saved_objects/find_object_by_title.ts
index 5e83dd32e80eb..e27326249f5c9 100644
--- a/src/legacy/ui/public/saved_objects/find_object_by_title.ts
+++ b/src/legacy/ui/public/saved_objects/find_object_by_title.ts
@@ -18,7 +18,7 @@
*/
import { find } from 'lodash';
-import { SavedObjectAttributes } from '../../../server/saved_objects';
+import { SavedObjectAttributes } from 'src/core/server';
import { SavedObjectsClient } from './saved_objects_client';
import { SimpleSavedObject } from './simple_saved_object';
diff --git a/src/legacy/ui/public/saved_objects/saved_objects_client.test.ts b/src/legacy/ui/public/saved_objects/saved_objects_client.test.ts
index f922d4446c3a3..fed3b8807cddd 100644
--- a/src/legacy/ui/public/saved_objects/saved_objects_client.test.ts
+++ b/src/legacy/ui/public/saved_objects/saved_objects_client.test.ts
@@ -20,7 +20,7 @@
jest.mock('ui/kfetch', () => ({}));
import * as sinon from 'sinon';
-import { FindOptions } from '../../../server/saved_objects/service';
+import { SavedObjectsFindOptions } from 'src/core/server';
import { SavedObjectsClient } from './saved_objects_client';
import { SimpleSavedObject } from './simple_saved_object';
@@ -341,7 +341,7 @@ describe('SavedObjectsClient', () => {
});
test('accepts pagination params', () => {
- const options: FindOptions = { perPage: 10, page: 6 };
+ const options: SavedObjectsFindOptions = { perPage: 10, page: 6 };
savedObjectsClient.find(options);
sinon.assert.calledOnce(kfetchStub);
diff --git a/src/legacy/ui/public/saved_objects/saved_objects_client.ts b/src/legacy/ui/public/saved_objects/saved_objects_client.ts
index 6fee8826d1638..d8fb3af1c66ac 100644
--- a/src/legacy/ui/public/saved_objects/saved_objects_client.ts
+++ b/src/legacy/ui/public/saved_objects/saved_objects_client.ts
@@ -21,13 +21,13 @@ import { cloneDeep, pick, throttle } from 'lodash';
import { resolve as resolveUrl } from 'url';
import {
- MigrationVersion,
SavedObject,
SavedObjectAttributes,
SavedObjectReference,
- SavedObjectsClient as SavedObjectsApi,
-} from '../../../server/saved_objects';
-import { FindOptions } from '../../../server/saved_objects/service';
+ SavedObjectsClientContract as SavedObjectsApi,
+ SavedObjectsFindOptions,
+ SavedObjectsMigrationVersion,
+} from 'src/core/server';
import { isAutoCreateIndexError, showAutoCreateIndexErrorPage } from '../error_auto_create_index';
import { kfetch, KFetchQuery } from '../kfetch';
import { keysToCamelCaseShallow, keysToSnakeCaseShallow } from '../utils/case_conversion';
@@ -43,7 +43,7 @@ interface RequestParams {
interface CreateOptions {
id?: string;
overwrite?: boolean;
- migrationVersion?: MigrationVersion;
+ migrationVersion?: SavedObjectsMigrationVersion;
references?: SavedObjectReference[];
}
@@ -55,7 +55,7 @@ interface BulkCreateOptions(
- options: FindOptions = {}
+ options: SavedObjectsFindOptions = {}
): Promise> => {
const path = this.getPath(['_find']);
const query = keysToSnakeCaseShallow(options);
diff --git a/src/legacy/ui/public/saved_objects/simple_saved_object.ts b/src/legacy/ui/public/saved_objects/simple_saved_object.ts
index d742b103afdd0..26488bdeb1ab1 100644
--- a/src/legacy/ui/public/saved_objects/simple_saved_object.ts
+++ b/src/legacy/ui/public/saved_objects/simple_saved_object.ts
@@ -18,10 +18,7 @@
*/
import { get, has, set } from 'lodash';
-import {
- SavedObject as SavedObjectType,
- SavedObjectAttributes,
-} from '../../../server/saved_objects';
+import { SavedObject as SavedObjectType, SavedObjectAttributes } from 'src/core/server';
import { SavedObjectsClient } from './saved_objects_client';
/**
diff --git a/src/legacy/ui/ui_settings/__tests__/lib/create_objects_client_stub.js b/src/legacy/ui/ui_settings/__tests__/lib/create_objects_client_stub.js
index 457ddd866c758..9a6d44c313248 100644
--- a/src/legacy/ui/ui_settings/__tests__/lib/create_objects_client_stub.js
+++ b/src/legacy/ui/ui_settings/__tests__/lib/create_objects_client_stub.js
@@ -19,7 +19,7 @@
import sinon from 'sinon';
import expect from '@kbn/expect';
-import { SavedObjectsClient } from '../../../../server/saved_objects';
+import { SavedObjectsClient } from '../../../../../core/server';
export const savedObjectsClientErrors = SavedObjectsClient.errors;
diff --git a/test/api_integration/apis/saved_objects/migrations.js b/test/api_integration/apis/saved_objects/migrations.js
index 976b4a22d5bd9..03b0baf1da92b 100644
--- a/test/api_integration/apis/saved_objects/migrations.js
+++ b/test/api_integration/apis/saved_objects/migrations.js
@@ -26,9 +26,9 @@ import { assert } from 'chai';
import {
DocumentMigrator,
IndexMigrator,
-} from '../../../../src/legacy/server/saved_objects/migrations/core';
-import { SavedObjectsSerializer } from '../../../../src/legacy/server/saved_objects/serialization';
-import { SavedObjectsSchema } from '../../../../src/legacy/server/saved_objects/schema';
+} from '../../../../src/core/server/saved_objects/migrations/core';
+import { SavedObjectsSerializer } from '../../../../src/core/server/saved_objects/serialization';
+import { SavedObjectsSchema } from '../../../../src/core/server/saved_objects/schema';
export default ({ getService }) => {
const es = getService('es');
diff --git a/tsconfig.types.json b/tsconfig.types.json
index 634a423b96e30..fd3624dd8e31b 100644
--- a/tsconfig.types.json
+++ b/tsconfig.types.json
@@ -9,6 +9,7 @@
},
"include": [
"src/core/server/index.ts",
- "src/core/public/index.ts"
+ "src/core/public/index.ts",
+ "typings"
]
}
diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts
index d5a438aacb6cf..6db6e8848ef07 100644
--- a/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts
+++ b/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { SavedObjectAttributes } from 'src/legacy/server/saved_objects/service/saved_objects_client';
+import { SavedObjectAttributes } from 'src/core/server';
import {
APM_TELEMETRY_DOC_ID,
createApmTelementry,
diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts
index 7156580698540..007d08594d036 100644
--- a/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts
+++ b/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts
@@ -6,7 +6,7 @@
import { Server } from 'hapi';
import { countBy } from 'lodash';
-import { SavedObjectAttributes } from 'src/legacy/server/saved_objects/service/saved_objects_client';
+import { SavedObjectAttributes } from 'src/core/server';
import { isAgentName } from '../../../common/agent_name';
import { getSavedObjectsClient } from '../helpers/saved_objects_client';
diff --git a/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.test.ts b/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.test.ts
index 2ea2e55eee8f5..392f945ab00c5 100644
--- a/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.test.ts
+++ b/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.test.ts
@@ -9,8 +9,8 @@ jest.mock('uuid', () => ({ v4: jest.fn().mockReturnValue('uuid-v4-id') }));
import { EncryptedSavedObjectsClientWrapper } from './encrypted_saved_objects_client_wrapper';
import { EncryptedSavedObjectsService } from './encrypted_saved_objects_service';
import { createEncryptedSavedObjectsServiceMock } from './encrypted_saved_objects_service.mock';
-import { SavedObjectsClientMock } from '../../../../../src/legacy/server/saved_objects/service/saved_objects_client.mock';
-import { SavedObjectsClientContract } from 'src/legacy/server/saved_objects';
+import { SavedObjectsClientMock } from 'src/core/server/saved_objects/service/saved_objects_client.mock';
+import { SavedObjectsClientContract } from 'src/core/server';
let wrapper: EncryptedSavedObjectsClientWrapper;
let mockBaseClient: jest.Mocked;
diff --git a/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.ts b/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.ts
index 35fa46f4e3739..1cef26d08d734 100644
--- a/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.ts
+++ b/x-pack/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.ts
@@ -6,19 +6,19 @@
import uuid from 'uuid';
import {
- BaseOptions,
- BulkCreateObject,
- BulkGetObject,
- BulkResponse,
- CreateOptions,
- FindOptions,
- FindResponse,
+ SavedObject,
SavedObjectAttributes,
+ SavedObjectsBaseOptions,
+ SavedObjectsBulkCreateObject,
+ SavedObjectsBulkGetObject,
+ SavedObjectsBulkResponse,
SavedObjectsClientContract,
- UpdateOptions,
- UpdateResponse,
- SavedObject,
-} from 'src/legacy/server/saved_objects';
+ SavedObjectsCreateOptions,
+ SavedObjectsFindOptions,
+ SavedObjectsFindResponse,
+ SavedObjectsUpdateOptions,
+ SavedObjectsUpdateResponse,
+} from 'src/core/server';
import { EncryptedSavedObjectsService } from './encrypted_saved_objects_service';
interface EncryptedSavedObjectsClientOptions {
@@ -43,7 +43,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
public async create(
type: string,
attributes: T = {} as T,
- options: CreateOptions = {}
+ options: SavedObjectsCreateOptions = {}
) {
if (!this.options.service.isRegistered(type)) {
return await this.options.baseClient.create(type, attributes, options);
@@ -71,7 +71,10 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
);
}
- public async bulkCreate(objects: BulkCreateObject[], options?: BaseOptions) {
+ public async bulkCreate(
+ objects: SavedObjectsBulkCreateObject[],
+ options?: SavedObjectsBaseOptions
+ ) {
// We encrypt attributes for every object in parallel and that can potentially exhaust libuv or
// NodeJS thread pool. If it turns out to be a problem, we can consider switching to the
// sequential processing.
@@ -107,23 +110,26 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
);
}
- public async delete(type: string, id: string, options?: BaseOptions) {
+ public async delete(type: string, id: string, options?: SavedObjectsBaseOptions) {
return await this.options.baseClient.delete(type, id, options);
}
- public async find(options: FindOptions = {}) {
+ public async find(options: SavedObjectsFindOptions = {}) {
return this.stripEncryptedAttributesFromBulkResponse(
await this.options.baseClient.find(options)
);
}
- public async bulkGet(objects: BulkGetObject[] = [], options?: BaseOptions) {
+ public async bulkGet(
+ objects: SavedObjectsBulkGetObject[] = [],
+ options?: SavedObjectsBaseOptions
+ ) {
return this.stripEncryptedAttributesFromBulkResponse(
await this.options.baseClient.bulkGet(objects, options)
);
}
- public async get(type: string, id: string, options?: BaseOptions) {
+ public async get(type: string, id: string, options?: SavedObjectsBaseOptions) {
return this.stripEncryptedAttributesFromResponse(
await this.options.baseClient.get(type, id, options)
);
@@ -133,7 +139,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
type: string,
id: string,
attributes: Partial,
- options?: UpdateOptions
+ options?: SavedObjectsUpdateOptions
) {
if (!this.options.service.isRegistered(type)) {
return await this.options.baseClient.update(type, id, attributes, options);
@@ -157,7 +163,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
* registered, response is returned as is.
* @param response Raw response returned by the underlying base client.
*/
- private stripEncryptedAttributesFromResponse(
+ private stripEncryptedAttributesFromResponse(
response: T
): T {
if (this.options.service.isRegistered(response.type)) {
@@ -175,9 +181,9 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
* response portion isn't registered, it is returned as is.
* @param response Raw response returned by the underlying base client.
*/
- private stripEncryptedAttributesFromBulkResponse(
- response: T
- ): T {
+ private stripEncryptedAttributesFromBulkResponse<
+ T extends SavedObjectsBulkResponse | SavedObjectsFindResponse
+ >(response: T): T {
for (const savedObject of response.saved_objects) {
if (this.options.service.isRegistered(savedObject.type)) {
savedObject.attributes = this.options.service.stripEncryptedAttributes(
diff --git a/x-pack/plugins/encrypted_saved_objects/server/plugin.ts b/x-pack/plugins/encrypted_saved_objects/server/plugin.ts
index 5a7d8ba0f6f34..02b20798afc59 100644
--- a/x-pack/plugins/encrypted_saved_objects/server/plugin.ts
+++ b/x-pack/plugins/encrypted_saved_objects/server/plugin.ts
@@ -6,12 +6,8 @@
import crypto from 'crypto';
import { Legacy, Server } from 'kibana';
-import { SavedObjectsRepository } from 'src/legacy/server/saved_objects/service/lib';
-import {
- BaseOptions,
- SavedObject,
- SavedObjectAttributes,
-} from 'src/legacy/server/saved_objects/service/saved_objects_client';
+import { SavedObjectsRepository } from 'src/core/server/saved_objects/service';
+import { SavedObjectsBaseOptions, SavedObject, SavedObjectAttributes } from 'src/core/server';
import {
EncryptedSavedObjectsService,
EncryptedSavedObjectTypeRegistration,
@@ -78,7 +74,7 @@ export class Plugin {
getDecryptedAsInternalUser: async (
type: string,
id: string,
- options?: BaseOptions
+ options?: SavedObjectsBaseOptions
): Promise> => {
const savedObject = await internalRepository.get(type, id, options);
return {
diff --git a/x-pack/plugins/siem/server/lib/note/saved_object.ts b/x-pack/plugins/siem/server/lib/note/saved_object.ts
index ee3c4127d2779..11f693b693f3a 100644
--- a/x-pack/plugins/siem/server/lib/note/saved_object.ts
+++ b/x-pack/plugins/siem/server/lib/note/saved_object.ts
@@ -9,7 +9,7 @@ import { RequestAuth } from 'hapi';
import { Legacy } from 'kibana';
import { getOr } from 'lodash/fp';
-import { FindOptions } from 'src/legacy/server/saved_objects/service';
+import { SavedObjectsFindOptions } from 'src/core/server';
import { Pick3 } from '../../../common/utility_types';
import { PageInfoNote, ResponseNote, ResponseNotes, SortNote } from '../../graphql/types';
@@ -39,7 +39,7 @@ export class Note {
}
public async deleteNoteByTimelineId(request: FrameworkRequest, timelineId: string) {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
search: timelineId,
searchFields: ['timelineId'],
};
@@ -61,7 +61,7 @@ export class Note {
request: FrameworkRequest,
eventId: string
): Promise {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
search: eventId,
searchFields: ['eventId'],
};
@@ -73,7 +73,7 @@ export class Note {
request: FrameworkRequest,
timelineId: string
): Promise {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
search: timelineId,
searchFields: ['timelineId'],
};
@@ -87,7 +87,7 @@ export class Note {
search: string | null,
sort: SortNote | null
): Promise {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
perPage: pageInfo != null ? pageInfo.pageSize : undefined,
page: pageInfo != null ? pageInfo.pageIndex : undefined,
search: search != null ? search : undefined,
@@ -166,7 +166,7 @@ export class Note {
return convertSavedObjectToSavedNote(savedObject);
}
- private async getAllSavedNote(request: FrameworkRequest, options: FindOptions) {
+ private async getAllSavedNote(request: FrameworkRequest, options: SavedObjectsFindOptions) {
const savedObjectsClient = this.libs.savedObjects.getScopedSavedObjectsClient(
request[internalFrameworkRequest]
);
diff --git a/x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts b/x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts
index b160cfa47c3c7..a2507cc798707 100644
--- a/x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts
+++ b/x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts
@@ -9,7 +9,7 @@ import { RequestAuth } from 'hapi';
import { Legacy } from 'kibana';
import { getOr } from 'lodash/fp';
-import { FindOptions } from 'src/legacy/server/saved_objects/service';
+import { SavedObjectsFindOptions } from 'src/core/server';
import { Pick3 } from '../../../common/utility_types';
import { FrameworkRequest, internalFrameworkRequest } from '../framework';
@@ -42,7 +42,7 @@ export class PinnedEvent {
}
public async deleteAllPinnedEventsOnTimeline(request: FrameworkRequest, timelineId: string) {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
search: timelineId,
searchFields: ['timelineId'],
};
@@ -67,7 +67,7 @@ export class PinnedEvent {
request: FrameworkRequest,
timelineId: string
): Promise {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
search: timelineId,
searchFields: ['timelineId'],
};
@@ -80,7 +80,7 @@ export class PinnedEvent {
search: string | null,
sort: SortNote | null
): Promise {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
perPage: pageInfo != null ? pageInfo.pageSize : undefined,
page: pageInfo != null ? pageInfo.pageIndex : undefined,
search: search != null ? search : undefined,
@@ -156,7 +156,10 @@ export class PinnedEvent {
return convertSavedObjectToSavedPinnedEvent(savedObject);
}
- private async getAllSavedPinnedEvents(request: FrameworkRequest, options: FindOptions) {
+ private async getAllSavedPinnedEvents(
+ request: FrameworkRequest,
+ options: SavedObjectsFindOptions
+ ) {
const savedObjectsClient = this.libs.savedObjects.getScopedSavedObjectsClient(
request[internalFrameworkRequest]
);
diff --git a/x-pack/plugins/siem/server/lib/timeline/saved_object.ts b/x-pack/plugins/siem/server/lib/timeline/saved_object.ts
index 335e6ae6935be..433fc175b642f 100644
--- a/x-pack/plugins/siem/server/lib/timeline/saved_object.ts
+++ b/x-pack/plugins/siem/server/lib/timeline/saved_object.ts
@@ -7,7 +7,7 @@
import { Legacy } from 'kibana';
import { getOr } from 'lodash/fp';
-import { FindOptions } from 'src/legacy/server/saved_objects/service';
+import { SavedObjectsFindOptions } from 'src/core/server';
import { Pick3 } from '../../../common/utility_types';
import {
@@ -59,7 +59,7 @@ export class Timeline {
search: string | null,
sort: SortTimeline | null
): Promise {
- const options: FindOptions = {
+ const options: SavedObjectsFindOptions = {
perPage: pageInfo != null ? pageInfo.pageSize : undefined,
page: pageInfo != null ? pageInfo.pageIndex : undefined,
search: search != null ? search : undefined,
@@ -226,7 +226,7 @@ export class Timeline {
return timelineWithReduxProperties(notes, pinnedEvents, timeline, userName);
}
- private async getAllSavedTimeline(request: FrameworkRequest, options: FindOptions) {
+ private async getAllSavedTimeline(request: FrameworkRequest, options: SavedObjectsFindOptions) {
const userName = getOr(null, 'credentials.username', request[internalFrameworkRequest].auth);
const savedObjectsClient = this.libs.savedObjects.getScopedSavedObjectsClient(
diff --git a/x-pack/plugins/spaces/index.ts b/x-pack/plugins/spaces/index.ts
index 443243581434d..9037b988badd4 100644
--- a/x-pack/plugins/spaces/index.ts
+++ b/x-pack/plugins/spaces/index.ts
@@ -6,7 +6,7 @@
import { resolve } from 'path';
-import { SavedObjectsService } from 'src/legacy/server/saved_objects';
+import { SavedObjectsService } from 'src/core/server';
import { Request, Server } from 'hapi';
// @ts-ignore
import { AuditLogger } from '../../server/lib/audit_logger';
diff --git a/x-pack/plugins/spaces/server/lib/request_inteceptors/on_post_auth_interceptor.test.ts b/x-pack/plugins/spaces/server/lib/request_inteceptors/on_post_auth_interceptor.test.ts
index 0e6585ee48922..b2a937a8cd790 100644
--- a/x-pack/plugins/spaces/server/lib/request_inteceptors/on_post_auth_interceptor.test.ts
+++ b/x-pack/plugins/spaces/server/lib/request_inteceptors/on_post_auth_interceptor.test.ts
@@ -7,7 +7,7 @@
import { Server } from 'hapi';
import sinon from 'sinon';
-import { SavedObject } from 'src/legacy/server/saved_objects';
+import { SavedObject } from 'src/core/server';
import { Feature } from '../../../../xpack_main/types';
import { convertSavedObjectToSpace } from '../../routes/lib';
import { initSpacesOnPostAuthRequestInterceptor } from './on_post_auth_interceptor';
diff --git a/x-pack/plugins/spaces/server/lib/saved_objects_client/saved_objects_client_wrapper_factory.ts b/x-pack/plugins/spaces/server/lib/saved_objects_client/saved_objects_client_wrapper_factory.ts
index a10b98625225c..bf092b0ca7ee2 100644
--- a/x-pack/plugins/spaces/server/lib/saved_objects_client/saved_objects_client_wrapper_factory.ts
+++ b/x-pack/plugins/spaces/server/lib/saved_objects_client/saved_objects_client_wrapper_factory.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { SavedObjectsClientWrapperFactory } from 'src/legacy/server/saved_objects';
+import { SavedObjectsClientWrapperFactory } from 'src/core/server/saved_objects';
import { SpacesService } from '../create_spaces_service';
import { SpacesSavedObjectsClient } from './spaces_saved_objects_client';
diff --git a/x-pack/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts b/x-pack/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts
index c1873e52a2b8e..b23c9910d8096 100644
--- a/x-pack/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts
+++ b/x-pack/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts
@@ -5,15 +5,15 @@
*/
import {
- BaseOptions,
- BulkCreateObject,
- BulkGetObject,
- CreateOptions,
- FindOptions,
SavedObjectAttributes,
+ SavedObjectsBaseOptions,
+ SavedObjectsBulkCreateObject,
+ SavedObjectsBulkGetObject,
SavedObjectsClientContract,
- UpdateOptions,
-} from 'src/legacy/server/saved_objects';
+ SavedObjectsCreateOptions,
+ SavedObjectsFindOptions,
+ SavedObjectsUpdateOptions,
+} from 'src/core/server';
import { DEFAULT_SPACE_ID } from '../../../common/constants';
import { SpacesService } from '../create_spaces_service';
@@ -87,7 +87,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
public async create(
type: string,
attributes: T = {} as T,
- options: CreateOptions = {}
+ options: SavedObjectsCreateOptions = {}
) {
throwErrorIfTypeIsSpace(type);
throwErrorIfNamespaceSpecified(options);
@@ -107,7 +107,10 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise} - { saved_objects: [{ id, type, version, attributes, error: { message } }]}
*/
- public async bulkCreate(objects: BulkCreateObject[], options: BaseOptions = {}) {
+ public async bulkCreate(
+ objects: SavedObjectsBulkCreateObject[],
+ options: SavedObjectsBaseOptions = {}
+ ) {
throwErrorIfTypesContainsSpace(objects.map(object => object.type));
throwErrorIfNamespaceSpecified(options);
@@ -126,7 +129,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise}
*/
- public async delete(type: string, id: string, options: BaseOptions = {}) {
+ public async delete(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
throwErrorIfTypeIsSpace(type);
throwErrorIfNamespaceSpecified(options);
@@ -152,7 +155,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {object} [options.hasReference] - { type, id }
* @returns {promise} - { saved_objects: [{ id, type, version, attributes }], total, per_page, page }
*/
- public async find(options: FindOptions = {}) {
+ public async find(options: SavedObjectsFindOptions = {}) {
if (options.type) {
throwErrorIfTypesContainsSpace(coerceToArray(options.type));
}
@@ -182,7 +185,10 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* { id: 'foo', type: 'index-pattern' }
* ])
*/
- public async bulkGet(objects: BulkGetObject[] = [], options: BaseOptions = {}) {
+ public async bulkGet(
+ objects: SavedObjectsBulkGetObject[] = [],
+ options: SavedObjectsBaseOptions = {}
+ ) {
throwErrorIfTypesContainsSpace(objects.map(object => object.type));
throwErrorIfNamespaceSpecified(options);
@@ -201,7 +207,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise} - { id, type, version, attributes }
*/
- public async get(type: string, id: string, options: BaseOptions = {}) {
+ public async get(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
throwErrorIfTypeIsSpace(type);
throwErrorIfNamespaceSpecified(options);
@@ -225,7 +231,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
type: string,
id: string,
attributes: Partial,
- options: UpdateOptions = {}
+ options: SavedObjectsUpdateOptions = {}
) {
throwErrorIfTypeIsSpace(type);
throwErrorIfNamespaceSpecified(options);
diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts
index 903d52524a810..60018173781a0 100644
--- a/x-pack/plugins/upgrade_assistant/common/types.ts
+++ b/x-pack/plugins/upgrade_assistant/common/types.ts
@@ -5,10 +5,7 @@
*/
import { Legacy } from 'kibana';
-import {
- SavedObject,
- SavedObjectAttributes,
-} from 'src/legacy/server/saved_objects/service/saved_objects_client';
+import { SavedObject, SavedObjectAttributes } from 'src/core/server';
export enum ReindexStep {
// Enum values are spaced out by 10 to give us room to insert steps in between.
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
index 98325200d645a..d3297dbbf122e 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts
@@ -7,10 +7,7 @@
import moment from 'moment';
import { CallCluster } from 'src/legacy/core_plugins/elasticsearch';
-import {
- FindResponse,
- SavedObjectsClient,
-} from 'src/legacy/server/saved_objects/service/saved_objects_client';
+import { SavedObjectsFindResponse, SavedObjectsClientContract } from 'src/core/server';
import {
IndexGroup,
REINDEX_OP_TYPE,
@@ -71,7 +68,7 @@ export interface ReindexActions {
* Finds the reindex operation saved object for the given index.
* @param indexName
*/
- findReindexOperations(indexName: string): Promise>;
+ findReindexOperations(indexName: string): Promise>;
/**
* Returns an array of all reindex operations that have a status.
@@ -113,7 +110,7 @@ export interface ReindexActions {
}
export const reindexActionsFactory = (
- client: SavedObjectsClient,
+ client: SavedObjectsClientContract,
callCluster: CallCluster
): ReindexActions => {
// ----- Internal functions
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
index d48d3b596f0b2..669eea623851c 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/worker.ts
@@ -5,7 +5,7 @@
*/
import { CallCluster, CallClusterWithRequest } from 'src/legacy/core_plugins/elasticsearch';
import { Request, Server } from 'src/legacy/server/kbn_server';
-import { SavedObjectsClient } from 'src/legacy/server/saved_objects';
+import { SavedObjectsClientContract } from 'src/core/server';
import moment from 'moment';
import { XPackInfo } from '../../../../xpack_main/server/lib/xpack_info';
@@ -43,7 +43,7 @@ export class ReindexWorker {
private readonly reindexService: ReindexService;
constructor(
- private client: SavedObjectsClient,
+ private client: SavedObjectsClientContract,
private credentialStore: CredentialStore,
private callWithRequest: CallClusterWithRequest,
private callWithInternalUser: CallCluster,
diff --git a/x-pack/plugins/upgrade_assistant/server/lib/telemetry/usage_collector.ts b/x-pack/plugins/upgrade_assistant/server/lib/telemetry/usage_collector.ts
index a52ee1c01c526..8c01db82a7075 100644
--- a/x-pack/plugins/upgrade_assistant/server/lib/telemetry/usage_collector.ts
+++ b/x-pack/plugins/upgrade_assistant/server/lib/telemetry/usage_collector.ts
@@ -5,7 +5,7 @@
*/
import { set } from 'lodash';
-import { SavedObjectsRepository } from 'src/legacy/server/saved_objects/service/lib/repository';
+import { SavedObjectsRepository } from 'src/core/server/saved_objects/service/lib/repository';
import {
UPGRADE_ASSISTANT_DOC_ID,
UPGRADE_ASSISTANT_TYPE,
diff --git a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices.ts b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices.ts
index f81443b488b11..43e4c9899d233 100644
--- a/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices.ts
+++ b/x-pack/plugins/upgrade_assistant/server/routes/reindex_indices.ts
@@ -8,7 +8,7 @@ import Boom from 'boom';
import { Server } from 'hapi';
import { CallCluster } from 'src/legacy/core_plugins/elasticsearch';
-import { SavedObjectsClient } from 'src/legacy/server/saved_objects';
+import { SavedObjectsClientContract } from 'src/core/server';
import { ReindexStatus } from '../../common/types';
import { EsVersionPrecheck } from '../lib/es_version_precheck';
import { reindexServiceFactory, ReindexWorker } from '../lib/reindexing';
@@ -25,7 +25,7 @@ export function registerReindexWorker(server: Server, credentialStore: Credentia
);
const savedObjectsClient = new server.savedObjects.SavedObjectsClient(
savedObjectsRepository
- ) as SavedObjectsClient;
+ ) as SavedObjectsClientContract;
// Cannot pass server.log directly because it's value changes during startup (?).
// Use this function to proxy through.
diff --git a/x-pack/test/plugin_api_integration/test_suites/encrypted_saved_objects/encrypted_saved_objects_api.ts b/x-pack/test/plugin_api_integration/test_suites/encrypted_saved_objects/encrypted_saved_objects_api.ts
index 8cb1971ee6936..40563f5c068c3 100644
--- a/x-pack/test/plugin_api_integration/test_suites/encrypted_saved_objects/encrypted_saved_objects_api.ts
+++ b/x-pack/test/plugin_api_integration/test_suites/encrypted_saved_objects/encrypted_saved_objects_api.ts
@@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
-import { SavedObject } from 'src/legacy/server/saved_objects/service';
+import { SavedObject } from 'src/core/server';
import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';
// eslint-disable-next-line import/no-default-export