From c21723f55e1b159600ebae759cd636a6ff503d54 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Mon, 9 Dec 2019 17:02:03 -0500 Subject: [PATCH] Delete existing Installation type. Rename InstallationAttributes to Installation --- x-pack/legacy/plugins/epm/common/types.ts | 5 ++--- x-pack/legacy/plugins/epm/server/packages/get.ts | 8 ++++---- x-pack/legacy/plugins/epm/server/packages/index.ts | 6 +++++- x-pack/legacy/plugins/epm/server/packages/install.ts | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/x-pack/legacy/plugins/epm/common/types.ts b/x-pack/legacy/plugins/epm/common/types.ts index ec1fe98d1a1a4..6c1a34ae834a5 100644 --- a/x-pack/legacy/plugins/epm/common/types.ts +++ b/x-pack/legacy/plugins/epm/common/types.ts @@ -156,8 +156,7 @@ export type PackageListItem = Installable; export type PackageInfo = Installable; -export type Installation = SavedObject; -export interface InstallationAttributes extends SavedObjectAttributes { +export interface Installation extends SavedObjectAttributes { installed: AssetReference[]; } @@ -165,7 +164,7 @@ export type Installable = Installed | NotInstalled; export type Installed = T & { status: InstallationStatus.installed; - savedObject: Installation; + savedObject: SavedObject; }; export type NotInstalled = T & { diff --git a/x-pack/legacy/plugins/epm/server/packages/get.ts b/x-pack/legacy/plugins/epm/server/packages/get.ts index 7b8d258b9e5bd..f497d6e1c692d 100644 --- a/x-pack/legacy/plugins/epm/server/packages/get.ts +++ b/x-pack/legacy/plugins/epm/server/packages/get.ts @@ -6,7 +6,7 @@ import { SavedObjectsClientContract } from 'src/core/server/'; import { SAVED_OBJECT_TYPE_PACKAGES } from '../../common/constants'; -import { Installation, InstallationAttributes, Installed, NotInstalled } from '../../common/types'; +import { Installation, Installed, NotInstalled } from '../../common/types'; import * as Registry from '../registry'; import { createInstallableFrom } from './index'; @@ -35,7 +35,7 @@ export async function getPackages( type: SAVED_OBJECT_TYPE_PACKAGES, id: `${name}-${version}`, })); - const results = await savedObjectsClient.bulkGet(searchObjects); + const results = await savedObjectsClient.bulkGet(searchObjects); const savedObjects = results.saved_objects.filter(o => !o.error); // ignore errors for now const packageList = registryItems .map(item => @@ -74,10 +74,10 @@ export async function getPackageInfo(options: { export async function getInstallationObject(options: { savedObjectsClient: SavedObjectsClientContract; pkgkey: string; -}): Promise { +}) { const { savedObjectsClient, pkgkey } = options; return savedObjectsClient - .get(SAVED_OBJECT_TYPE_PACKAGES, pkgkey) + .get(SAVED_OBJECT_TYPE_PACKAGES, pkgkey) .catch(e => undefined); } diff --git a/x-pack/legacy/plugins/epm/server/packages/index.ts b/x-pack/legacy/plugins/epm/server/packages/index.ts index 1c744c67209cf..11e2aca58042c 100644 --- a/x-pack/legacy/plugins/epm/server/packages/index.ts +++ b/x-pack/legacy/plugins/epm/server/packages/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { SavedObject } from '../../../../../../src/core/server'; import { AssetType, // ElasticsearchAssetType, @@ -21,7 +22,10 @@ export * from './remove'; // only Kibana Assets use Saved Objects at this point export const savedObjectTypes: AssetType[] = Object.values(KibanaAssetType); -export function createInstallableFrom(from: T, savedObject?: Installation): Installable { +export function createInstallableFrom( + from: T, + savedObject?: SavedObject +): Installable { return savedObject ? { ...from, diff --git a/x-pack/legacy/plugins/epm/server/packages/install.ts b/x-pack/legacy/plugins/epm/server/packages/install.ts index 5159afa0ff816..267880e315524 100644 --- a/x-pack/legacy/plugins/epm/server/packages/install.ts +++ b/x-pack/legacy/plugins/epm/server/packages/install.ts @@ -6,7 +6,7 @@ import { SavedObject, SavedObjectsClientContract } from 'src/core/server/'; import { SAVED_OBJECT_TYPE_PACKAGES } from '../../common/constants'; -import { AssetReference, InstallationAttributes, KibanaAssetType } from '../../common/types'; +import { AssetReference, Installation, KibanaAssetType } from '../../common/types'; import { installIndexPattern } from '../lib/kibana/index_pattern/install'; import * as Registry from '../registry'; import { getObject } from './get_objects'; @@ -74,7 +74,7 @@ export async function saveInstallationReferences(options: { const toInstall = toSave.reduce(mergeRefsReducer, savedRefs || []); - await savedObjectsClient.create( + await savedObjectsClient.create( SAVED_OBJECT_TYPE_PACKAGES, { installed: toInstall }, { id: pkgkey, overwrite: true }