mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* expose saved object import/export from core * additional tests * removing unused mock * updater snapshots * add objectLimit to saved objects service * don't export the import/export functionality from core; only types * documenting exported types * export missing type
This commit is contained in:
parent
1597b30132
commit
d107d0845e
82 changed files with 2247 additions and 978 deletions
|
@ -58,12 +58,23 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) | |
|
||||
| [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) | |
|
||||
| [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md) | |
|
||||
| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | |
|
||||
| [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
|
||||
| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
|
||||
| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
|
||||
| [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) | Options controlling the export operation. |
|
||||
| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
|
||||
| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | |
|
||||
| [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
|
||||
| [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) | Represents a failure to import. |
|
||||
| [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
|
||||
| [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) | Options to control the import operation. |
|
||||
| [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) | The response describing the result of an import. |
|
||||
| [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
|
||||
| [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
|
||||
| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
|
||||
| [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. |
|
||||
| [SavedObjectsRawDoc](./kibana-plugin-server.savedobjectsrawdoc.md) | A raw document as represented directly in the saved object index. |
|
||||
| [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) | Options to control the "resolve import" operation. |
|
||||
| [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) | |
|
||||
| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
|
||||
| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
|
||||
|
@ -89,5 +100,5 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [ResponseError](./kibana-plugin-server.responseerror.md) | Error message and optional data send to the client in case of error. |
|
||||
| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
|
||||
| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | \#\# 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 <code>isXYZError()</code> helpers exposed at <code>SavedObjectsErrorHelpers</code> should be used to understand and manage error responses from the <code>SavedObjectsClient</code>.<!-- -->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 <code>error.body.error.type</code> or doing substring checks on <code>error.body.error.reason</code>, 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 <code>action.auto_create_index</code> 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) |
|
||||
| [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) | |
|
||||
| [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) | Describes the factory used to create instances of Saved Objects Client Wrappers. |
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md) > [excludedWrappers](./kibana-plugin-server.savedobjectsclientprovideroptions.excludedwrappers.md)
|
||||
|
||||
## SavedObjectsClientProviderOptions.excludedWrappers property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
excludedWrappers?: string[];
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md)
|
||||
|
||||
## SavedObjectsClientProviderOptions interface
|
||||
|
||||
Options to control the creation of the Saved Objects Client.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsClientProviderOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [excludedWrappers](./kibana-plugin-server.savedobjectsclientprovideroptions.excludedwrappers.md) | <code>string[]</code> | |
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
## SavedObjectsClientWrapperFactory type
|
||||
|
||||
Describes the factory used to create instances of Saved Objects Client Wrappers.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
## SavedObjectsClientWrapperOptions interface
|
||||
|
||||
Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) > [exportSizeLimit](./kibana-plugin-server.savedobjectsexportoptions.exportsizelimit.md)
|
||||
|
||||
## SavedObjectsExportOptions.exportSizeLimit property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
exportSizeLimit: number;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) > [includeReferencesDeep](./kibana-plugin-server.savedobjectsexportoptions.includereferencesdeep.md)
|
||||
|
||||
## SavedObjectsExportOptions.includeReferencesDeep property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
includeReferencesDeep?: boolean;
|
||||
```
|
|
@ -0,0 +1,25 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md)
|
||||
|
||||
## SavedObjectsExportOptions interface
|
||||
|
||||
Options controlling the export operation.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsExportOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [exportSizeLimit](./kibana-plugin-server.savedobjectsexportoptions.exportsizelimit.md) | <code>number</code> | |
|
||||
| [includeReferencesDeep](./kibana-plugin-server.savedobjectsexportoptions.includereferencesdeep.md) | <code>boolean</code> | |
|
||||
| [namespace](./kibana-plugin-server.savedobjectsexportoptions.namespace.md) | <code>string</code> | |
|
||||
| [objects](./kibana-plugin-server.savedobjectsexportoptions.objects.md) | <code>Array<{</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }></code> | |
|
||||
| [savedObjectsClient](./kibana-plugin-server.savedobjectsexportoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
|
||||
| [types](./kibana-plugin-server.savedobjectsexportoptions.types.md) | <code>string[]</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) > [namespace](./kibana-plugin-server.savedobjectsexportoptions.namespace.md)
|
||||
|
||||
## SavedObjectsExportOptions.namespace property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
namespace?: string;
|
||||
```
|
|
@ -0,0 +1,14 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) > [objects](./kibana-plugin-server.savedobjectsexportoptions.objects.md)
|
||||
|
||||
## SavedObjectsExportOptions.objects property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
objects?: Array<{
|
||||
id: string;
|
||||
type: string;
|
||||
}>;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) > [savedObjectsClient](./kibana-plugin-server.savedobjectsexportoptions.savedobjectsclient.md)
|
||||
|
||||
## SavedObjectsExportOptions.savedObjectsClient property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) > [types](./kibana-plugin-server.savedobjectsexportoptions.types.md)
|
||||
|
||||
## SavedObjectsExportOptions.types property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
types?: string[];
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md)
|
||||
|
||||
## SavedObjectsImportConflictError interface
|
||||
|
||||
Represents a failure to import due to a conflict.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportConflictError
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [type](./kibana-plugin-server.savedobjectsimportconflicterror.type.md) | <code>'conflict'</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md) > [type](./kibana-plugin-server.savedobjectsimportconflicterror.type.md)
|
||||
|
||||
## SavedObjectsImportConflictError.type property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
type: 'conflict';
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) > [error](./kibana-plugin-server.savedobjectsimporterror.error.md)
|
||||
|
||||
## SavedObjectsImportError.error property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
error: SavedObjectsImportConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) > [id](./kibana-plugin-server.savedobjectsimporterror.id.md)
|
||||
|
||||
## SavedObjectsImportError.id property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
id: string;
|
||||
```
|
|
@ -0,0 +1,23 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md)
|
||||
|
||||
## SavedObjectsImportError interface
|
||||
|
||||
Represents a failure to import.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportError
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [error](./kibana-plugin-server.savedobjectsimporterror.error.md) | <code>SavedObjectsImportConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError</code> | |
|
||||
| [id](./kibana-plugin-server.savedobjectsimporterror.id.md) | <code>string</code> | |
|
||||
| [title](./kibana-plugin-server.savedobjectsimporterror.title.md) | <code>string</code> | |
|
||||
| [type](./kibana-plugin-server.savedobjectsimporterror.type.md) | <code>string</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) > [title](./kibana-plugin-server.savedobjectsimporterror.title.md)
|
||||
|
||||
## SavedObjectsImportError.title property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
title?: string;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) > [type](./kibana-plugin-server.savedobjectsimporterror.type.md)
|
||||
|
||||
## SavedObjectsImportError.type property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
type: string;
|
||||
```
|
|
@ -0,0 +1,14 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) > [blocking](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.blocking.md)
|
||||
|
||||
## SavedObjectsImportMissingReferencesError.blocking property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
blocking: Array<{
|
||||
type: string;
|
||||
id: string;
|
||||
}>;
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md)
|
||||
|
||||
## SavedObjectsImportMissingReferencesError interface
|
||||
|
||||
Represents a failure to import due to missing references.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportMissingReferencesError
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [blocking](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.blocking.md) | <code>Array<{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }></code> | |
|
||||
| [references](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.references.md) | <code>Array<{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }></code> | |
|
||||
| [type](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.type.md) | <code>'missing_references'</code> | |
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) > [references](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.references.md)
|
||||
|
||||
## SavedObjectsImportMissingReferencesError.references property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
references: Array<{
|
||||
type: string;
|
||||
id: string;
|
||||
}>;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) > [type](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.type.md)
|
||||
|
||||
## SavedObjectsImportMissingReferencesError.type property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
type: 'missing_references';
|
||||
```
|
|
@ -0,0 +1,25 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md)
|
||||
|
||||
## SavedObjectsImportOptions interface
|
||||
|
||||
Options to control the import operation.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [namespace](./kibana-plugin-server.savedobjectsimportoptions.namespace.md) | <code>string</code> | |
|
||||
| [objectLimit](./kibana-plugin-server.savedobjectsimportoptions.objectlimit.md) | <code>number</code> | |
|
||||
| [overwrite](./kibana-plugin-server.savedobjectsimportoptions.overwrite.md) | <code>boolean</code> | |
|
||||
| [readStream](./kibana-plugin-server.savedobjectsimportoptions.readstream.md) | <code>Readable</code> | |
|
||||
| [savedObjectsClient](./kibana-plugin-server.savedobjectsimportoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
|
||||
| [supportedTypes](./kibana-plugin-server.savedobjectsimportoptions.supportedtypes.md) | <code>string[]</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) > [namespace](./kibana-plugin-server.savedobjectsimportoptions.namespace.md)
|
||||
|
||||
## SavedObjectsImportOptions.namespace property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
namespace?: string;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) > [objectLimit](./kibana-plugin-server.savedobjectsimportoptions.objectlimit.md)
|
||||
|
||||
## SavedObjectsImportOptions.objectLimit property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
objectLimit: number;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) > [overwrite](./kibana-plugin-server.savedobjectsimportoptions.overwrite.md)
|
||||
|
||||
## SavedObjectsImportOptions.overwrite property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
overwrite: boolean;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) > [readStream](./kibana-plugin-server.savedobjectsimportoptions.readstream.md)
|
||||
|
||||
## SavedObjectsImportOptions.readStream property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readStream: Readable;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) > [savedObjectsClient](./kibana-plugin-server.savedobjectsimportoptions.savedobjectsclient.md)
|
||||
|
||||
## SavedObjectsImportOptions.savedObjectsClient property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) > [supportedTypes](./kibana-plugin-server.savedobjectsimportoptions.supportedtypes.md)
|
||||
|
||||
## SavedObjectsImportOptions.supportedTypes property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
supportedTypes: string[];
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) > [errors](./kibana-plugin-server.savedobjectsimportresponse.errors.md)
|
||||
|
||||
## SavedObjectsImportResponse.errors property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
errors?: SavedObjectsImportError[];
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md)
|
||||
|
||||
## SavedObjectsImportResponse interface
|
||||
|
||||
The response describing the result of an import.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportResponse
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [errors](./kibana-plugin-server.savedobjectsimportresponse.errors.md) | <code>SavedObjectsImportError[]</code> | |
|
||||
| [success](./kibana-plugin-server.savedobjectsimportresponse.success.md) | <code>boolean</code> | |
|
||||
| [successCount](./kibana-plugin-server.savedobjectsimportresponse.successcount.md) | <code>number</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) > [success](./kibana-plugin-server.savedobjectsimportresponse.success.md)
|
||||
|
||||
## SavedObjectsImportResponse.success property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
success: boolean;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) > [successCount](./kibana-plugin-server.savedobjectsimportresponse.successcount.md)
|
||||
|
||||
## SavedObjectsImportResponse.successCount property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
successCount: number;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) > [id](./kibana-plugin-server.savedobjectsimportretry.id.md)
|
||||
|
||||
## SavedObjectsImportRetry.id property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
id: string;
|
||||
```
|
|
@ -0,0 +1,23 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md)
|
||||
|
||||
## SavedObjectsImportRetry interface
|
||||
|
||||
Describes a retry operation for importing a saved object.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportRetry
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [id](./kibana-plugin-server.savedobjectsimportretry.id.md) | <code>string</code> | |
|
||||
| [overwrite](./kibana-plugin-server.savedobjectsimportretry.overwrite.md) | <code>boolean</code> | |
|
||||
| [replaceReferences](./kibana-plugin-server.savedobjectsimportretry.replacereferences.md) | <code>Array<{</code><br/><code> type: string;</code><br/><code> from: string;</code><br/><code> to: string;</code><br/><code> }></code> | |
|
||||
| [type](./kibana-plugin-server.savedobjectsimportretry.type.md) | <code>string</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) > [overwrite](./kibana-plugin-server.savedobjectsimportretry.overwrite.md)
|
||||
|
||||
## SavedObjectsImportRetry.overwrite property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
overwrite: boolean;
|
||||
```
|
|
@ -0,0 +1,15 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) > [replaceReferences](./kibana-plugin-server.savedobjectsimportretry.replacereferences.md)
|
||||
|
||||
## SavedObjectsImportRetry.replaceReferences property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
replaceReferences: Array<{
|
||||
type: string;
|
||||
from: string;
|
||||
to: string;
|
||||
}>;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) > [type](./kibana-plugin-server.savedobjectsimportretry.type.md)
|
||||
|
||||
## SavedObjectsImportRetry.type property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
type: string;
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md)
|
||||
|
||||
## SavedObjectsImportUnknownError interface
|
||||
|
||||
Represents a failure to import due to an unknown reason.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportUnknownError
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [message](./kibana-plugin-server.savedobjectsimportunknownerror.message.md) | <code>string</code> | |
|
||||
| [statusCode](./kibana-plugin-server.savedobjectsimportunknownerror.statuscode.md) | <code>number</code> | |
|
||||
| [type](./kibana-plugin-server.savedobjectsimportunknownerror.type.md) | <code>'unknown'</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) > [message](./kibana-plugin-server.savedobjectsimportunknownerror.message.md)
|
||||
|
||||
## SavedObjectsImportUnknownError.message property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
message: string;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) > [statusCode](./kibana-plugin-server.savedobjectsimportunknownerror.statuscode.md)
|
||||
|
||||
## SavedObjectsImportUnknownError.statusCode property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
statusCode: number;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) > [type](./kibana-plugin-server.savedobjectsimportunknownerror.type.md)
|
||||
|
||||
## SavedObjectsImportUnknownError.type property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
type: 'unknown';
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md)
|
||||
|
||||
## SavedObjectsImportUnsupportedTypeError interface
|
||||
|
||||
Represents a failure to import due to having an unsupported saved object type.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsImportUnsupportedTypeError
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [type](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.type.md) | <code>'unsupported_type'</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md) > [type](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.type.md)
|
||||
|
||||
## SavedObjectsImportUnsupportedTypeError.type property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
type: 'unsupported_type';
|
||||
```
|
|
@ -0,0 +1,25 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions interface
|
||||
|
||||
Options to control the "resolve import" operation.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsResolveImportErrorsOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [namespace](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.namespace.md) | <code>string</code> | |
|
||||
| [objectLimit](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.objectlimit.md) | <code>number</code> | |
|
||||
| [readStream](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.readstream.md) | <code>Readable</code> | |
|
||||
| [retries](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.retries.md) | <code>SavedObjectsImportRetry[]</code> | |
|
||||
| [savedObjectsClient](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
|
||||
| [supportedTypes](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.supportedtypes.md) | <code>string[]</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) > [namespace](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.namespace.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions.namespace property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
namespace?: string;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) > [objectLimit](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.objectlimit.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions.objectLimit property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
objectLimit: number;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) > [readStream](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.readstream.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions.readStream property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readStream: Readable;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) > [retries](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.retries.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions.retries property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
retries: SavedObjectsImportRetry[];
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) > [savedObjectsClient](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.savedobjectsclient.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions.savedObjectsClient property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) > [supportedTypes](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.supportedtypes.md)
|
||||
|
||||
## SavedObjectsResolveImportErrorsOptions.supportedTypes property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
supportedTypes: string[];
|
||||
```
|
|
@ -0,0 +1,16 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [importExport](./kibana-plugin-server.savedobjectsservice.importexport.md)
|
||||
|
||||
## SavedObjectsService.importExport property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
importExport: {
|
||||
objectLimit: number;
|
||||
importSavedObjects(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
|
||||
resolveImportErrors(options: SavedObjectsResolveImportErrorsOptions): Promise<SavedObjectsImportResponse>;
|
||||
getSortedObjectsForExport(options: SavedObjectsExportOptions): Promise<Readable>;
|
||||
};
|
||||
```
|
|
@ -17,7 +17,9 @@ export interface SavedObjectsService<Request = any>
|
|||
| --- | --- | --- |
|
||||
| [addScopedSavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsservice.addscopedsavedobjectsclientwrapperfactory.md) | <code>ScopedSavedObjectsClientProvider<Request>['addClientWrapperFactory']</code> | |
|
||||
| [getScopedSavedObjectsClient](./kibana-plugin-server.savedobjectsservice.getscopedsavedobjectsclient.md) | <code>ScopedSavedObjectsClientProvider<Request>['getClient']</code> | |
|
||||
| [importExport](./kibana-plugin-server.savedobjectsservice.importexport.md) | <code>{</code><br/><code> objectLimit: number;</code><br/><code> importSavedObjects(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;</code><br/><code> resolveImportErrors(options: SavedObjectsResolveImportErrorsOptions): Promise<SavedObjectsImportResponse>;</code><br/><code> getSortedObjectsForExport(options: SavedObjectsExportOptions): Promise<Readable>;</code><br/><code> }</code> | |
|
||||
| [SavedObjectsClient](./kibana-plugin-server.savedobjectsservice.savedobjectsclient.md) | <code>typeof SavedObjectsClient</code> | |
|
||||
| [schema](./kibana-plugin-server.savedobjectsservice.schema.md) | <code>SavedObjectsSchema</code> | |
|
||||
| [types](./kibana-plugin-server.savedobjectsservice.types.md) | <code>string[]</code> | |
|
||||
|
||||
## Methods
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) > [schema](./kibana-plugin-server.savedobjectsservice.schema.md)
|
||||
|
||||
## SavedObjectsService.schema property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
schema: SavedObjectsSchema;
|
||||
```
|
|
@ -99,6 +99,7 @@ export {
|
|||
SavedObjectsClient,
|
||||
SavedObjectsClientContract,
|
||||
SavedObjectsCreateOptions,
|
||||
SavedObjectsClientProviderOptions,
|
||||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsClientWrapperOptions,
|
||||
SavedObjectsErrorHelpers,
|
||||
|
@ -111,6 +112,16 @@ export {
|
|||
SavedObjectsService,
|
||||
SavedObjectsUpdateOptions,
|
||||
SavedObjectsUpdateResponse,
|
||||
SavedObjectsExportOptions,
|
||||
SavedObjectsImportError,
|
||||
SavedObjectsImportConflictError,
|
||||
SavedObjectsImportMissingReferencesError,
|
||||
SavedObjectsImportUnknownError,
|
||||
SavedObjectsImportUnsupportedTypeError,
|
||||
SavedObjectsImportOptions,
|
||||
SavedObjectsImportResponse,
|
||||
SavedObjectsImportRetry,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
} from './saved_objects';
|
||||
|
||||
export { RecursiveReadonly } from '../utils';
|
||||
|
|
|
@ -74,50 +74,134 @@ describe('getSortedObjectsForExport()', () => {
|
|||
const response = await readStreamToCompletion(exportStream);
|
||||
|
||||
expect(response).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.find).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"perPage": 500,
|
||||
"sortField": "_id",
|
||||
"sortOrder": "asc",
|
||||
"type": Array [
|
||||
"index-pattern",
|
||||
"search",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
"perPage": 500,
|
||||
"sortField": "_id",
|
||||
"sortOrder": "asc",
|
||||
"type": Array [
|
||||
"index-pattern",
|
||||
"search",
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('exports from the provided namespace when present', async () => {
|
||||
savedObjectsClient.find.mockResolvedValueOnce({
|
||||
total: 2,
|
||||
saved_objects: [
|
||||
{
|
||||
id: '2',
|
||||
type: 'search',
|
||||
attributes: {},
|
||||
references: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'index-pattern',
|
||||
id: '1',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: '1',
|
||||
type: 'index-pattern',
|
||||
attributes: {},
|
||||
references: [],
|
||||
},
|
||||
],
|
||||
per_page: 1,
|
||||
page: 0,
|
||||
});
|
||||
const exportStream = await getSortedObjectsForExport({
|
||||
savedObjectsClient,
|
||||
exportSizeLimit: 500,
|
||||
types: ['index-pattern', 'search'],
|
||||
namespace: 'foo',
|
||||
});
|
||||
|
||||
const response = await readStreamToCompletion(exportStream);
|
||||
|
||||
expect(response).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.find).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"namespace": "foo",
|
||||
"perPage": 500,
|
||||
"sortField": "_id",
|
||||
"sortOrder": "asc",
|
||||
"type": Array [
|
||||
"index-pattern",
|
||||
"search",
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('export selected types throws error when exceeding exportSizeLimit', async () => {
|
||||
|
@ -195,51 +279,54 @@ Array [
|
|||
});
|
||||
const response = await readStreamToCompletion(exportStream);
|
||||
expect(response).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('includes nested dependencies when passed in', async () => {
|
||||
|
@ -283,59 +370,65 @@ Array [
|
|||
});
|
||||
const response = await readStreamToCompletion(exportStream);
|
||||
expect(response).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
],
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "name",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('export selected objects throws error when exceeding exportSizeLimit', async () => {
|
||||
|
|
|
@ -23,17 +23,20 @@ import { SavedObjectsClientContract } from '../';
|
|||
import { injectNestedDependencies } from './inject_nested_depdendencies';
|
||||
import { sortObjects } from './sort_objects';
|
||||
|
||||
interface ObjectToExport {
|
||||
id: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface ExportObjectsOptions {
|
||||
/**
|
||||
* Options controlling the export operation.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsExportOptions {
|
||||
types?: string[];
|
||||
objects?: ObjectToExport[];
|
||||
objects?: Array<{
|
||||
id: string;
|
||||
type: string;
|
||||
}>;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
exportSizeLimit: number;
|
||||
includeReferencesDeep?: boolean;
|
||||
namespace?: string;
|
||||
}
|
||||
|
||||
async function fetchObjectsToExport({
|
||||
|
@ -41,17 +44,19 @@ async function fetchObjectsToExport({
|
|||
types,
|
||||
exportSizeLimit,
|
||||
savedObjectsClient,
|
||||
namespace,
|
||||
}: {
|
||||
objects?: ObjectToExport[];
|
||||
objects?: SavedObjectsExportOptions['objects'];
|
||||
types?: string[];
|
||||
exportSizeLimit: number;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
namespace?: string;
|
||||
}) {
|
||||
if (objects) {
|
||||
if (objects.length > exportSizeLimit) {
|
||||
throw Boom.badRequest(`Can't export more than ${exportSizeLimit} objects`);
|
||||
}
|
||||
const bulkGetResult = await savedObjectsClient.bulkGet(objects);
|
||||
const bulkGetResult = await savedObjectsClient.bulkGet(objects, { namespace });
|
||||
const erroredObjects = bulkGetResult.saved_objects.filter(obj => !!obj.error);
|
||||
if (erroredObjects.length) {
|
||||
const err = Boom.badRequest();
|
||||
|
@ -67,6 +72,7 @@ async function fetchObjectsToExport({
|
|||
sortField: '_id',
|
||||
sortOrder: 'asc',
|
||||
perPage: exportSizeLimit,
|
||||
namespace,
|
||||
});
|
||||
if (findResponse.total > exportSizeLimit) {
|
||||
throw Boom.badRequest(`Can't export more than ${exportSizeLimit} objects`);
|
||||
|
@ -80,17 +86,19 @@ export async function getSortedObjectsForExport({
|
|||
savedObjectsClient,
|
||||
exportSizeLimit,
|
||||
includeReferencesDeep = false,
|
||||
}: ExportObjectsOptions) {
|
||||
namespace,
|
||||
}: SavedObjectsExportOptions) {
|
||||
const objectsToExport = await fetchObjectsToExport({
|
||||
types,
|
||||
objects,
|
||||
savedObjectsClient,
|
||||
exportSizeLimit,
|
||||
namespace,
|
||||
});
|
||||
|
||||
const exportedObjects = sortObjects(
|
||||
includeReferencesDeep
|
||||
? await injectNestedDependencies(objectsToExport, savedObjectsClient)
|
||||
? await injectNestedDependencies(objectsToExport, savedObjectsClient, namespace)
|
||||
: objectsToExport
|
||||
);
|
||||
|
||||
|
|
|
@ -17,4 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { getSortedObjectsForExport } from './get_sorted_objects_for_export';
|
||||
export {
|
||||
getSortedObjectsForExport,
|
||||
SavedObjectsExportOptions,
|
||||
} from './get_sorted_objects_for_export';
|
||||
|
|
|
@ -70,13 +70,13 @@ describe('getObjectReferencesToFetch()', () => {
|
|||
});
|
||||
const result = getObjectReferencesToFetch(map);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test(`doesn't deal with circular dependencies`, () => {
|
||||
|
@ -137,15 +137,15 @@ describe('injectNestedDependencies', () => {
|
|||
];
|
||||
const result = await injectNestedDependencies(savedObjects, savedObjectsClient);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test(`doesn't fetch references that are already fetched`, async () => {
|
||||
|
@ -171,27 +171,27 @@ Array [
|
|||
];
|
||||
const result = await injectNestedDependencies(savedObjects, savedObjectsClient);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test('fetches dependencies at least one level deep', async () => {
|
||||
|
@ -221,47 +221,50 @@ Array [
|
|||
});
|
||||
const result = await injectNestedDependencies(savedObjects, savedObjectsClient);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('fetches dependencies multiple levels deep', async () => {
|
||||
|
@ -336,108 +339,114 @@ Array [
|
|||
});
|
||||
const result = await injectNestedDependencies(savedObjects, savedObjectsClient);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "5",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "4",
|
||||
"name": "panel_0",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"id": "3",
|
||||
"name": "panel_1",
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
"type": "dashboard",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "4",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"name": "ref_0",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "3",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "5",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "4",
|
||||
"name": "panel_0",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"id": "3",
|
||||
"name": "panel_1",
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
"type": "dashboard",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "4",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"name": "ref_0",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "3",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
],
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "4",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"id": "3",
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('throws error when bulkGet returns an error', async () => {
|
||||
|
@ -505,52 +514,55 @@ Array [
|
|||
});
|
||||
const result = await injectNestedDependencies(savedObjects, savedObjectsClient);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"name": "ref_0",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "2",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {},
|
||||
"id": "1",
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"name": "ref_0",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
]
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,7 +34,8 @@ export function getObjectReferencesToFetch(savedObjectsMap: Map<string, SavedObj
|
|||
|
||||
export async function injectNestedDependencies(
|
||||
savedObjects: SavedObject[],
|
||||
savedObjectsClient: SavedObjectsClientContract
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
namespace?: string
|
||||
) {
|
||||
const savedObjectsMap = new Map<string, SavedObject>();
|
||||
for (const savedObject of savedObjects) {
|
||||
|
@ -42,7 +43,7 @@ export async function injectNestedDependencies(
|
|||
}
|
||||
let objectsToFetch = getObjectReferencesToFetch(savedObjectsMap);
|
||||
while (objectsToFetch.length > 0) {
|
||||
const bulkGetResponse = await savedObjectsClient.bulkGet(objectsToFetch);
|
||||
const bulkGetResponse = await savedObjectsClient.bulkGet(objectsToFetch, { namespace });
|
||||
// Check for errors
|
||||
const erroredObjects = bulkGetResponse.saved_objects.filter(obj => !!obj.error);
|
||||
if (erroredObjects.length) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
} from '../../../../legacy/utils/streams';
|
||||
import { SavedObject } from '../service';
|
||||
import { createLimitStream } from './create_limit_stream';
|
||||
import { ImportError } from './types';
|
||||
import { SavedObjectsImportError } from './types';
|
||||
|
||||
interface CollectSavedObjectsOptions {
|
||||
readStream: Readable;
|
||||
|
@ -41,7 +41,7 @@ export async function collectSavedObjects({
|
|||
filter,
|
||||
supportedTypes,
|
||||
}: CollectSavedObjectsOptions) {
|
||||
const errors: ImportError[] = [];
|
||||
const errors: SavedObjectsImportError[] = [];
|
||||
const collectedObjects: SavedObject[] = await createPromiseFromStreams([
|
||||
readStream,
|
||||
createLimitStream(objectLimit),
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
|
||||
import { SavedObject } from '../service';
|
||||
import { Retry } from './types';
|
||||
import { SavedObjectsImportRetry } from './types';
|
||||
|
||||
export function createObjectsFilter(retries: Retry[]) {
|
||||
export function createObjectsFilter(retries: SavedObjectsImportRetry[]) {
|
||||
const retryKeys = new Set<string>(retries.map(retry => `${retry.type}:${retry.id}`));
|
||||
return (obj: SavedObject) => {
|
||||
return retryKeys.has(`${obj.type}:${obj.id}`);
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
|
||||
import { SavedObject } from '../service';
|
||||
import { ImportError } from './types';
|
||||
import { SavedObjectsImportError } from './types';
|
||||
|
||||
export function extractErrors(
|
||||
savedObjectResults: SavedObject[],
|
||||
savedObjectsToImport: SavedObject[]
|
||||
) {
|
||||
const errors: ImportError[] = [];
|
||||
const errors: SavedObjectsImportError[] = [];
|
||||
const originalSavedObjectsMap = new Map<string, SavedObject>();
|
||||
for (const savedObject of savedObjectsToImport) {
|
||||
originalSavedObjectsMap.set(`${savedObject.type}:${savedObject.id}`, savedObject);
|
||||
|
|
|
@ -86,11 +86,11 @@ describe('importSavedObjects()', () => {
|
|||
supportedTypes: [],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('calls bulkCreate without overwrite', async () => {
|
||||
|
@ -113,66 +113,151 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"overwrite": false,
|
||||
"success": true,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
"overwrite": false,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('uses the provided namespace when present', async () => {
|
||||
const readStream = new Readable({
|
||||
objectMode: true,
|
||||
read() {
|
||||
savedObjects.forEach(obj => this.push(obj));
|
||||
this.push(null);
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
savedObjectsClient.find.mockResolvedValueOnce({ saved_objects: [] });
|
||||
savedObjectsClient.bulkCreate.mockResolvedValue({
|
||||
saved_objects: savedObjects,
|
||||
});
|
||||
const result = await importSavedObjects({
|
||||
readStream,
|
||||
objectLimit: 4,
|
||||
overwrite: false,
|
||||
savedObjectsClient,
|
||||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
namespace: 'foo',
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": "foo",
|
||||
"overwrite": false,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('calls bulkCreate with overwrite', async () => {
|
||||
|
@ -195,66 +280,67 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"overwrite": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
"success": true,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
"overwrite": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('extracts errors for conflicts', async () => {
|
||||
|
@ -284,45 +370,45 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Index Pattern",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "2",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "3",
|
||||
"title": "My Visualization",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "4",
|
||||
"title": "My Dashboard",
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Index Pattern",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "2",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "3",
|
||||
"title": "My Visualization",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "4",
|
||||
"title": "My Dashboard",
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('validates references', async () => {
|
||||
|
@ -380,56 +466,59 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"blocking": Array [
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"id": "3",
|
||||
"type": "visualization",
|
||||
"error": Object {
|
||||
"blocking": Array [
|
||||
Object {
|
||||
"id": "3",
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "missing_references",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "missing_references",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"fields": Array [
|
||||
"id",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"fields": Array [
|
||||
"id",
|
||||
],
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('validates supported types', async () => {
|
||||
|
@ -453,75 +542,76 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "unsupported_type",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "my title",
|
||||
"type": "wigwags",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"overwrite": false,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "unsupported_type",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "my title",
|
||||
"type": "wigwags",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 4,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Search",
|
||||
},
|
||||
"id": "2",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
"overwrite": false,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,26 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Readable } from 'stream';
|
||||
import { collectSavedObjects } from './collect_saved_objects';
|
||||
import { extractErrors } from './extract_errors';
|
||||
import { ImportError } from './types';
|
||||
import {
|
||||
SavedObjectsImportError,
|
||||
SavedObjectsImportResponse,
|
||||
SavedObjectsImportOptions,
|
||||
} from './types';
|
||||
import { validateReferences } from './validate_references';
|
||||
import { SavedObjectsClientContract } from '../';
|
||||
|
||||
interface ImportSavedObjectsOptions {
|
||||
readStream: Readable;
|
||||
objectLimit: number;
|
||||
overwrite: boolean;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
supportedTypes: string[];
|
||||
}
|
||||
|
||||
interface ImportResponse {
|
||||
success: boolean;
|
||||
successCount: number;
|
||||
errors?: ImportError[];
|
||||
}
|
||||
|
||||
export async function importSavedObjects({
|
||||
readStream,
|
||||
|
@ -44,8 +32,9 @@ export async function importSavedObjects({
|
|||
overwrite,
|
||||
savedObjectsClient,
|
||||
supportedTypes,
|
||||
}: ImportSavedObjectsOptions): Promise<ImportResponse> {
|
||||
let errorAccumulator: ImportError[] = [];
|
||||
namespace,
|
||||
}: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse> {
|
||||
let errorAccumulator: SavedObjectsImportError[] = [];
|
||||
|
||||
// Get the objects to import
|
||||
const {
|
||||
|
@ -57,7 +46,8 @@ export async function importSavedObjects({
|
|||
// Validate references
|
||||
const { filteredObjects, errors: validationErrors } = await validateReferences(
|
||||
objectsFromStream,
|
||||
savedObjectsClient
|
||||
savedObjectsClient,
|
||||
namespace
|
||||
);
|
||||
errorAccumulator = [...errorAccumulator, ...validationErrors];
|
||||
|
||||
|
@ -73,6 +63,7 @@ export async function importSavedObjects({
|
|||
// Create objects in bulk
|
||||
const bulkCreateResult = await savedObjectsClient.bulkCreate(filteredObjects, {
|
||||
overwrite,
|
||||
namespace,
|
||||
});
|
||||
errorAccumulator = [
|
||||
...errorAccumulator,
|
||||
|
|
|
@ -19,3 +19,14 @@
|
|||
|
||||
export { importSavedObjects } from './import_saved_objects';
|
||||
export { resolveImportErrors } from './resolve_import_errors';
|
||||
export {
|
||||
SavedObjectsImportResponse,
|
||||
SavedObjectsImportError,
|
||||
SavedObjectsImportOptions,
|
||||
SavedObjectsImportConflictError,
|
||||
SavedObjectsImportMissingReferencesError,
|
||||
SavedObjectsImportUnknownError,
|
||||
SavedObjectsImportUnsupportedTypeError,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
SavedObjectsImportRetry,
|
||||
} from './types';
|
||||
|
|
|
@ -96,11 +96,11 @@ describe('resolveImportErrors()', () => {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`[MockFunction]`);
|
||||
});
|
||||
|
||||
|
@ -130,36 +130,39 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Visualization",
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
"id": "3",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('works with overwrites', async () => {
|
||||
|
@ -188,39 +191,40 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"overwrite": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Index Pattern",
|
||||
},
|
||||
"id": "1",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [],
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
"overwrite": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('works wtih replaceReferences', async () => {
|
||||
|
@ -255,42 +259,45 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "My Dashboard",
|
||||
},
|
||||
"id": "4",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "13",
|
||||
"name": "panel_0",
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"id": "13",
|
||||
"name": "panel_0",
|
||||
"type": "visualization",
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('extracts errors for conflicts', async () => {
|
||||
|
@ -324,45 +331,45 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Index Pattern",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "2",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "3",
|
||||
"title": "My Visualization",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "4",
|
||||
"title": "My Dashboard",
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Index Pattern",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "2",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "3",
|
||||
"title": "My Visualization",
|
||||
"type": "visualization",
|
||||
},
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "conflict",
|
||||
},
|
||||
"id": "4",
|
||||
"title": "My Dashboard",
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('validates references', async () => {
|
||||
|
@ -433,56 +440,59 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"blocking": Array [
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"id": "3",
|
||||
"type": "visualization",
|
||||
"error": Object {
|
||||
"blocking": Array [
|
||||
Object {
|
||||
"id": "3",
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "missing_references",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "missing_references",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "My Search",
|
||||
"type": "search",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"fields": Array [
|
||||
"id",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"fields": Array [
|
||||
"id",
|
||||
],
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
"id": "2",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('validates object types', async () => {
|
||||
|
@ -512,21 +522,67 @@ Object {
|
|||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "unsupported_type",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "my title",
|
||||
"type": "wigwags",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"error": Object {
|
||||
"type": "unsupported_type",
|
||||
},
|
||||
"id": "1",
|
||||
"title": "my title",
|
||||
"type": "wigwags",
|
||||
},
|
||||
],
|
||||
"success": false,
|
||||
"successCount": 0,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`[MockFunction]`);
|
||||
});
|
||||
|
||||
test('uses namespace when provided', async () => {
|
||||
const readStream = new Readable({
|
||||
objectMode: true,
|
||||
read() {
|
||||
savedObjects.forEach(obj => this.push(obj));
|
||||
this.push(null);
|
||||
},
|
||||
});
|
||||
savedObjectsClient.bulkCreate.mockResolvedValue({
|
||||
saved_objects: savedObjects.filter(obj => obj.type === 'index-pattern' && obj.id === '1'),
|
||||
});
|
||||
const result = await resolveImportErrors({
|
||||
readStream,
|
||||
objectLimit: 4,
|
||||
retries: [
|
||||
{
|
||||
type: 'index-pattern',
|
||||
id: '1',
|
||||
overwrite: true,
|
||||
replaceReferences: [],
|
||||
},
|
||||
],
|
||||
savedObjectsClient,
|
||||
supportedTypes: ['index-pattern', 'search', 'visualization', 'dashboard'],
|
||||
namespace: 'foo',
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"success": true,
|
||||
"successCount": 1,
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkCreate).toHaveBeenCalledWith(
|
||||
[
|
||||
{
|
||||
attributes: { title: 'My Index Pattern' },
|
||||
id: '1',
|
||||
migrationVersion: {},
|
||||
references: [],
|
||||
type: 'index-pattern',
|
||||
},
|
||||
],
|
||||
{ namespace: 'foo', overwrite: true }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,38 +17,27 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Readable } from 'stream';
|
||||
import { SavedObjectsClientContract } from '../';
|
||||
import { collectSavedObjects } from './collect_saved_objects';
|
||||
import { createObjectsFilter } from './create_objects_filter';
|
||||
import { extractErrors } from './extract_errors';
|
||||
import { splitOverwrites } from './split_overwrites';
|
||||
import { ImportError, Retry } from './types';
|
||||
import {
|
||||
SavedObjectsImportError,
|
||||
SavedObjectsImportResponse,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
} from './types';
|
||||
import { validateReferences } from './validate_references';
|
||||
|
||||
interface ResolveImportErrorsOptions {
|
||||
readStream: Readable;
|
||||
objectLimit: number;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
retries: Retry[];
|
||||
supportedTypes: string[];
|
||||
}
|
||||
|
||||
interface ImportResponse {
|
||||
success: boolean;
|
||||
successCount: number;
|
||||
errors?: ImportError[];
|
||||
}
|
||||
|
||||
export async function resolveImportErrors({
|
||||
readStream,
|
||||
objectLimit,
|
||||
retries,
|
||||
savedObjectsClient,
|
||||
supportedTypes,
|
||||
}: ResolveImportErrorsOptions): Promise<ImportResponse> {
|
||||
namespace,
|
||||
}: SavedObjectsResolveImportErrorsOptions): Promise<SavedObjectsImportResponse> {
|
||||
let successCount = 0;
|
||||
let errorAccumulator: ImportError[] = [];
|
||||
let errorAccumulator: SavedObjectsImportError[] = [];
|
||||
const filter = createObjectsFilter(retries);
|
||||
|
||||
// Get the objects to resolve errors
|
||||
|
@ -89,7 +78,8 @@ export async function resolveImportErrors({
|
|||
// Validate references
|
||||
const { filteredObjects, errors: validationErrors } = await validateReferences(
|
||||
objectsToResolve,
|
||||
savedObjectsClient
|
||||
savedObjectsClient,
|
||||
namespace
|
||||
);
|
||||
errorAccumulator = [...errorAccumulator, ...validationErrors];
|
||||
|
||||
|
@ -98,6 +88,7 @@ export async function resolveImportErrors({
|
|||
if (objectsToOverwrite.length) {
|
||||
const bulkCreateResult = await savedObjectsClient.bulkCreate(objectsToOverwrite, {
|
||||
overwrite: true,
|
||||
namespace,
|
||||
});
|
||||
errorAccumulator = [
|
||||
...errorAccumulator,
|
||||
|
@ -106,7 +97,9 @@ export async function resolveImportErrors({
|
|||
successCount += bulkCreateResult.saved_objects.filter(obj => !obj.error).length;
|
||||
}
|
||||
if (objectsToNotOverwrite.length) {
|
||||
const bulkCreateResult = await savedObjectsClient.bulkCreate(objectsToNotOverwrite);
|
||||
const bulkCreateResult = await savedObjectsClient.bulkCreate(objectsToNotOverwrite, {
|
||||
namespace,
|
||||
});
|
||||
errorAccumulator = [
|
||||
...errorAccumulator,
|
||||
...extractErrors(bulkCreateResult.saved_objects, objectsToNotOverwrite),
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
|
||||
import { SavedObject } from '../service';
|
||||
import { Retry } from './types';
|
||||
import { SavedObjectsImportRetry } from './types';
|
||||
|
||||
export function splitOverwrites(savedObjects: SavedObject[], retries: Retry[]) {
|
||||
export function splitOverwrites(savedObjects: SavedObject[], retries: SavedObjectsImportRetry[]) {
|
||||
const objectsToOverwrite: SavedObject[] = [];
|
||||
const objectsToNotOverwrite: SavedObject[] = [];
|
||||
const overwrites = retries
|
||||
|
|
|
@ -17,7 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export interface Retry {
|
||||
import { Readable } from 'stream';
|
||||
import { SavedObjectsClientContract } from '../service';
|
||||
|
||||
/**
|
||||
* Describes a retry operation for importing a saved object.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportRetry {
|
||||
type: string;
|
||||
id: string;
|
||||
overwrite: boolean;
|
||||
|
@ -28,21 +35,37 @@ export interface Retry {
|
|||
}>;
|
||||
}
|
||||
|
||||
export interface ConflictError {
|
||||
/**
|
||||
* Represents a failure to import due to a conflict.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportConflictError {
|
||||
type: 'conflict';
|
||||
}
|
||||
|
||||
export interface UnsupportedTypeError {
|
||||
/**
|
||||
* Represents a failure to import due to having an unsupported saved object type.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportUnsupportedTypeError {
|
||||
type: 'unsupported_type';
|
||||
}
|
||||
|
||||
export interface UnknownError {
|
||||
/**
|
||||
* Represents a failure to import due to an unknown reason.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportUnknownError {
|
||||
type: 'unknown';
|
||||
message: string;
|
||||
statusCode: number;
|
||||
}
|
||||
|
||||
export interface MissingReferencesError {
|
||||
/**
|
||||
* Represents a failure to import due to missing references.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportMissingReferencesError {
|
||||
type: 'missing_references';
|
||||
references: Array<{
|
||||
type: string;
|
||||
|
@ -54,9 +77,53 @@ export interface MissingReferencesError {
|
|||
}>;
|
||||
}
|
||||
|
||||
export interface ImportError {
|
||||
/**
|
||||
* Represents a failure to import.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportError {
|
||||
id: string;
|
||||
type: string;
|
||||
title?: string;
|
||||
error: ConflictError | UnsupportedTypeError | MissingReferencesError | UnknownError;
|
||||
error:
|
||||
| SavedObjectsImportConflictError
|
||||
| SavedObjectsImportUnsupportedTypeError
|
||||
| SavedObjectsImportMissingReferencesError
|
||||
| SavedObjectsImportUnknownError;
|
||||
}
|
||||
|
||||
/**
|
||||
* The response describing the result of an import.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportResponse {
|
||||
success: boolean;
|
||||
successCount: number;
|
||||
errors?: SavedObjectsImportError[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control the import operation.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsImportOptions {
|
||||
readStream: Readable;
|
||||
objectLimit: number;
|
||||
overwrite: boolean;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
supportedTypes: string[];
|
||||
namespace?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control the "resolve import" operation.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsResolveImportErrorsOptions {
|
||||
readStream: Readable;
|
||||
objectLimit: number;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
retries: SavedObjectsImportRetry[];
|
||||
supportedTypes: string[];
|
||||
namespace?: string;
|
||||
}
|
||||
|
|
|
@ -107,6 +107,9 @@ describe('getNonExistingReferenceAsKeys()', () => {
|
|||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
|
@ -206,6 +209,9 @@ describe('getNonExistingReferenceAsKeys()', () => {
|
|||
"type": "search",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
|
@ -434,6 +440,9 @@ Object {
|
|||
"type": "search",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import Boom from 'boom';
|
||||
import { SavedObject, SavedObjectsClientContract } from '../';
|
||||
import { ImportError } from './types';
|
||||
import { SavedObjectsImportError } from './types';
|
||||
|
||||
const REF_TYPES_TO_VLIDATE = ['index-pattern', 'search'];
|
||||
|
||||
|
@ -29,7 +29,8 @@ function filterReferencesToValidate({ type }: { type: string }) {
|
|||
|
||||
export async function getNonExistingReferenceAsKeys(
|
||||
savedObjects: SavedObject[],
|
||||
savedObjectsClient: SavedObjectsClientContract
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
namespace?: string
|
||||
) {
|
||||
const collector = new Map();
|
||||
// Collect all references within objects
|
||||
|
@ -50,7 +51,7 @@ export async function getNonExistingReferenceAsKeys(
|
|||
|
||||
// Fetch references to see if they exist
|
||||
const bulkGetOpts = Array.from(collector.values()).map(obj => ({ ...obj, fields: ['id'] }));
|
||||
const bulkGetResponse = await savedObjectsClient.bulkGet(bulkGetOpts);
|
||||
const bulkGetResponse = await savedObjectsClient.bulkGet(bulkGetOpts, { namespace });
|
||||
|
||||
// Error handling
|
||||
const erroredObjects = bulkGetResponse.saved_objects.filter(
|
||||
|
@ -77,12 +78,14 @@ export async function getNonExistingReferenceAsKeys(
|
|||
|
||||
export async function validateReferences(
|
||||
savedObjects: SavedObject[],
|
||||
savedObjectsClient: SavedObjectsClientContract
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
namespace?: string
|
||||
) {
|
||||
const errorMap: { [key: string]: ImportError } = {};
|
||||
const errorMap: { [key: string]: SavedObjectsImportError } = {};
|
||||
const nonExistingReferenceKeys = await getNonExistingReferenceAsKeys(
|
||||
savedObjects,
|
||||
savedObjectsClient
|
||||
savedObjectsClient,
|
||||
namespace
|
||||
);
|
||||
|
||||
// Filter out objects with missing references, add to error object
|
||||
|
|
|
@ -23,4 +23,8 @@ export { SavedObjectsSchema } from './schema';
|
|||
|
||||
export { SavedObjectsManagement } from './management';
|
||||
|
||||
export * from './import';
|
||||
|
||||
export { getSortedObjectsForExport, SavedObjectsExportOptions } from './export';
|
||||
|
||||
export { SavedObjectsSerializer, RawDoc as SavedObjectsRawDoc } from './serialization';
|
||||
|
|
|
@ -17,8 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Readable } from 'stream';
|
||||
import { ScopedSavedObjectsClientProvider } from './lib';
|
||||
import { SavedObjectsClient } from './saved_objects_client';
|
||||
import { SavedObjectsExportOptions } from '../export';
|
||||
import { SavedObjectsImportOptions, SavedObjectsImportResponse } from '../import';
|
||||
import { SavedObjectsSchema } from '../schema';
|
||||
import { SavedObjectsResolveImportErrorsOptions } from '../import/types';
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -31,12 +36,22 @@ export interface SavedObjectsService<Request = any> {
|
|||
getScopedSavedObjectsClient: ScopedSavedObjectsClientProvider<Request>['getClient'];
|
||||
SavedObjectsClient: typeof SavedObjectsClient;
|
||||
types: string[];
|
||||
schema: SavedObjectsSchema;
|
||||
getSavedObjectsRepository(...rest: any[]): any;
|
||||
importExport: {
|
||||
objectLimit: number;
|
||||
importSavedObjects(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
|
||||
resolveImportErrors(
|
||||
options: SavedObjectsResolveImportErrorsOptions
|
||||
): Promise<SavedObjectsImportResponse>;
|
||||
getSortedObjectsForExport(options: SavedObjectsExportOptions): Promise<Readable>;
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
SavedObjectsRepository,
|
||||
ScopedSavedObjectsClientProvider,
|
||||
SavedObjectsClientProviderOptions,
|
||||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsClientWrapperOptions,
|
||||
SavedObjectsErrorHelpers,
|
||||
|
|
|
@ -22,6 +22,7 @@ export {
|
|||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsClientWrapperOptions,
|
||||
ScopedSavedObjectsClientProvider,
|
||||
SavedObjectsClientProviderOptions,
|
||||
} from './scoped_client_provider';
|
||||
|
||||
export { SavedObjectsErrorHelpers } from './errors';
|
||||
|
|
|
@ -19,21 +19,37 @@
|
|||
import { PriorityCollection } from './priority_collection';
|
||||
import { SavedObjectsClientContract } from '..';
|
||||
|
||||
/**
|
||||
* Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsClientWrapperOptions<Request = unknown> {
|
||||
client: SavedObjectsClientContract;
|
||||
request: Request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the factory used to create instances of Saved Objects Client Wrappers.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientWrapperFactory<Request = unknown> = (
|
||||
options: SavedObjectsClientWrapperOptions<Request>
|
||||
) => SavedObjectsClientContract;
|
||||
|
||||
/**
|
||||
* Describes the factory used to create instances of the Saved Objects Client.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientFactory<Request = unknown> = ({
|
||||
request,
|
||||
}: {
|
||||
request: Request;
|
||||
}) => SavedObjectsClientContract;
|
||||
|
||||
/**
|
||||
* Options to control the creation of the Saved Objects Client.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsClientProviderOptions {
|
||||
excludedWrappers?: string[];
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import { Duration } from 'moment';
|
|||
import { IncomingHttpHeaders } from 'http';
|
||||
import { ObjectType } from '@kbn/config-schema';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Readable } from 'stream';
|
||||
import { Request } from 'hapi';
|
||||
import { ResponseObject } from 'hapi';
|
||||
import { ResponseToolkit } from 'hapi';
|
||||
|
@ -533,14 +534,16 @@ export class SavedObjectsClient {
|
|||
// @public
|
||||
export type SavedObjectsClientContract = Pick<SavedObjectsClient, keyof SavedObjectsClient>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "SavedObjectsClientWrapperFactory" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export interface SavedObjectsClientProviderOptions {
|
||||
// (undocumented)
|
||||
excludedWrappers?: string[];
|
||||
}
|
||||
|
||||
// @public
|
||||
export type SavedObjectsClientWrapperFactory<Request = unknown> = (options: SavedObjectsClientWrapperOptions<Request>) => SavedObjectsClientContract;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "SavedObjectsClientWrapperOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export interface SavedObjectsClientWrapperOptions<Request = unknown> {
|
||||
// (undocumented)
|
||||
client: SavedObjectsClientContract;
|
||||
|
@ -608,6 +611,25 @@ export class SavedObjectsErrorHelpers {
|
|||
static isSavedObjectsClientError(error: any): error is DecoratedError;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsExportOptions {
|
||||
// (undocumented)
|
||||
exportSizeLimit: number;
|
||||
// (undocumented)
|
||||
includeReferencesDeep?: boolean;
|
||||
// (undocumented)
|
||||
namespace?: string;
|
||||
// (undocumented)
|
||||
objects?: Array<{
|
||||
id: string;
|
||||
type: string;
|
||||
}>;
|
||||
// (undocumented)
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
// (undocumented)
|
||||
types?: string[];
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions {
|
||||
// (undocumented)
|
||||
|
@ -646,6 +668,98 @@ export interface SavedObjectsFindResponse<T extends SavedObjectAttributes = any>
|
|||
total: number;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportConflictError {
|
||||
// (undocumented)
|
||||
type: 'conflict';
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportError {
|
||||
// (undocumented)
|
||||
error: SavedObjectsImportConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError;
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
title?: string;
|
||||
// (undocumented)
|
||||
type: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportMissingReferencesError {
|
||||
// (undocumented)
|
||||
blocking: Array<{
|
||||
type: string;
|
||||
id: string;
|
||||
}>;
|
||||
// (undocumented)
|
||||
references: Array<{
|
||||
type: string;
|
||||
id: string;
|
||||
}>;
|
||||
// (undocumented)
|
||||
type: 'missing_references';
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportOptions {
|
||||
// (undocumented)
|
||||
namespace?: string;
|
||||
// (undocumented)
|
||||
objectLimit: number;
|
||||
// (undocumented)
|
||||
overwrite: boolean;
|
||||
// (undocumented)
|
||||
readStream: Readable;
|
||||
// (undocumented)
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
// (undocumented)
|
||||
supportedTypes: string[];
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportResponse {
|
||||
// (undocumented)
|
||||
errors?: SavedObjectsImportError[];
|
||||
// (undocumented)
|
||||
success: boolean;
|
||||
// (undocumented)
|
||||
successCount: number;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportRetry {
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
overwrite: boolean;
|
||||
// (undocumented)
|
||||
replaceReferences: Array<{
|
||||
type: string;
|
||||
from: string;
|
||||
to: string;
|
||||
}>;
|
||||
// (undocumented)
|
||||
type: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportUnknownError {
|
||||
// (undocumented)
|
||||
message: string;
|
||||
// (undocumented)
|
||||
statusCode: number;
|
||||
// (undocumented)
|
||||
type: 'unknown';
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsImportUnsupportedTypeError {
|
||||
// (undocumented)
|
||||
type: 'unsupported_type';
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsMigrationVersion {
|
||||
// (undocumented)
|
||||
|
@ -668,6 +782,22 @@ export interface SavedObjectsRawDoc {
|
|||
_type?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsResolveImportErrorsOptions {
|
||||
// (undocumented)
|
||||
namespace?: string;
|
||||
// (undocumented)
|
||||
objectLimit: number;
|
||||
// (undocumented)
|
||||
readStream: Readable;
|
||||
// (undocumented)
|
||||
retries: SavedObjectsImportRetry[];
|
||||
// (undocumented)
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
// (undocumented)
|
||||
supportedTypes: string[];
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "SavedObjectsSchema" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
|
@ -704,11 +834,20 @@ export interface SavedObjectsService<Request = any> {
|
|||
getSavedObjectsRepository(...rest: any[]): any;
|
||||
// (undocumented)
|
||||
getScopedSavedObjectsClient: ScopedSavedObjectsClientProvider<Request>['getClient'];
|
||||
// (undocumented)
|
||||
importExport: {
|
||||
objectLimit: number;
|
||||
importSavedObjects(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
|
||||
resolveImportErrors(options: SavedObjectsResolveImportErrorsOptions): Promise<SavedObjectsImportResponse>;
|
||||
getSortedObjectsForExport(options: SavedObjectsExportOptions): Promise<Readable>;
|
||||
};
|
||||
// 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)
|
||||
schema: SavedObjectsSchema;
|
||||
// (undocumented)
|
||||
types: string[];
|
||||
}
|
||||
|
||||
|
|
3
src/legacy/server/kbn_server.d.ts
vendored
3
src/legacy/server/kbn_server.d.ts
vendored
|
@ -19,6 +19,7 @@
|
|||
|
||||
import { ResponseObject, Server } from 'hapi';
|
||||
|
||||
import { SavedObjectsClientProviderOptions } from 'src/core/server';
|
||||
import {
|
||||
ConfigService,
|
||||
ElasticsearchServiceSetup,
|
||||
|
@ -74,7 +75,7 @@ declare module 'hapi' {
|
|||
}
|
||||
|
||||
interface Request {
|
||||
getSavedObjectsClient(): SavedObjectsClientContract;
|
||||
getSavedObjectsClient(options?: SavedObjectsClientProviderOptions): SavedObjectsClientContract;
|
||||
getBasePath(): string;
|
||||
getUiSettingsService(): any;
|
||||
getCapabilities(): Promise<Capabilities>;
|
||||
|
|
|
@ -301,6 +301,9 @@ describe('POST /api/saved_objects/_import', () => {
|
|||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
|
|
|
@ -161,29 +161,32 @@ describe('POST /api/saved_objects/_resolve_import_errors', () => {
|
|||
expect(statusCode).toBe(200);
|
||||
expect(response).toEqual({ success: true, successCount: 1 });
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "Look at my dashboard",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "Look at my dashboard",
|
||||
},
|
||||
"id": "my-dashboard",
|
||||
"migrationVersion": Object {},
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
"id": "my-dashboard",
|
||||
"migrationVersion": Object {},
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('resolves conflicts for dashboard', async () => {
|
||||
|
@ -224,32 +227,33 @@ describe('POST /api/saved_objects/_resolve_import_errors', () => {
|
|||
expect(statusCode).toBe(200);
|
||||
expect(response).toEqual({ success: true, successCount: 1 });
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "Look at my dashboard",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "Look at my dashboard",
|
||||
},
|
||||
"id": "my-dashboard",
|
||||
"migrationVersion": Object {},
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
"overwrite": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
"id": "my-dashboard",
|
||||
"migrationVersion": Object {},
|
||||
"type": "dashboard",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"overwrite": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('resolves conflicts by replacing the visualization references', async () => {
|
||||
|
@ -306,58 +310,64 @@ describe('POST /api/saved_objects/_resolve_import_errors', () => {
|
|||
expect(statusCode).toBe(200);
|
||||
expect(response).toEqual({ success: true, successCount: 1 });
|
||||
expect(savedObjectsClient.bulkCreate).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "Look at my visualization",
|
||||
},
|
||||
"id": "my-vis",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"title": "Look at my visualization",
|
||||
},
|
||||
"id": "my-vis",
|
||||
"migrationVersion": Object {},
|
||||
"references": Array [
|
||||
Object {
|
||||
"id": "existing",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"id": "existing",
|
||||
"name": "ref_0",
|
||||
"type": "index-pattern",
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
"type": "visualization",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
expect(savedObjectsClient.bulkGet).toMatchInlineSnapshot(`
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"fields": Array [
|
||||
"id",
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"fields": Array [
|
||||
"id",
|
||||
],
|
||||
"id": "existing",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
Object {
|
||||
"namespace": undefined,
|
||||
},
|
||||
],
|
||||
"id": "existing",
|
||||
"type": "index-pattern",
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Promise {},
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,7 +27,10 @@ import {
|
|||
SavedObjectsClient,
|
||||
SavedObjectsRepository,
|
||||
ScopedSavedObjectsClientProvider,
|
||||
} from '../../../core/server/saved_objects/service';
|
||||
getSortedObjectsForExport,
|
||||
importSavedObjects,
|
||||
resolveImportErrors,
|
||||
} from '../../../core/server/saved_objects';
|
||||
import { getRootPropertiesObjects } from '../../../core/server/saved_objects/mappings';
|
||||
import { SavedObjectsManagement } from '../../../core/server/saved_objects/management';
|
||||
|
||||
|
@ -144,6 +147,13 @@ export function savedObjectsMixin(kbnServer, server) {
|
|||
setScopedSavedObjectsClientFactory: (...args) => provider.setClientFactory(...args),
|
||||
addScopedSavedObjectsClientWrapperFactory: (...args) =>
|
||||
provider.addClientWrapperFactory(...args),
|
||||
importExport: {
|
||||
objectLimit: server.config().get('savedObjects.maxImportExportSize'),
|
||||
importSavedObjects,
|
||||
resolveImportErrors,
|
||||
getSortedObjectsForExport,
|
||||
},
|
||||
schema,
|
||||
};
|
||||
server.decorate('server', 'savedObjects', service);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue