From 159698804e0631b0acb735dadab7f4669722acc7 Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Thu, 27 Feb 2020 13:30:47 -0500 Subject: [PATCH] simplifying --- .../plugins/spaces/server/saved_objects/mappings.ts | 4 +++- .../saved_objects/spaces_saved_objects_client.ts | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/spaces/server/saved_objects/mappings.ts b/x-pack/plugins/spaces/server/saved_objects/mappings.ts index a8d57d420f63c32..00e1ab732a8a528 100644 --- a/x-pack/plugins/spaces/server/saved_objects/mappings.ts +++ b/x-pack/plugins/spaces/server/saved_objects/mappings.ts @@ -4,7 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export const SpacesSavedObjectMappings = Object.freeze({ +import { deepFreeze } from '../../../../../src/core/utils'; + +export const SpacesSavedObjectMappings = deepFreeze({ properties: { name: { type: 'text', diff --git a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.ts b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.ts index d7792a05b9e487d..f216d5743cf89e5 100644 --- a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.ts +++ b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.ts @@ -42,7 +42,7 @@ const throwErrorIfNamespaceSpecified = (options: any) => { export class SpacesSavedObjectsClient implements SavedObjectsClientContract { private readonly client: SavedObjectsClientContract; private readonly spaceId: string; - private readonly typeRegistry: ISavedObjectTypeRegistry; + private readonly types: string[]; public readonly errors: SavedObjectsClientContract['errors']; constructor(options: SpacesSavedObjectsClientOptions) { @@ -50,7 +50,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { this.client = baseClient; this.spaceId = spacesService.getSpaceId(request); - this.typeRegistry = typeRegistry; + this.types = typeRegistry.getAllTypes().map(t => t.name); this.errors = baseClient.errors; } @@ -138,10 +138,9 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { return await this.client.find({ ...options, - type: (options.type - ? coerceToArray(options.type) - : this.typeRegistry.getAllTypes().map(t => t.name) - ).filter(type => type !== 'space'), + type: (options.type ? coerceToArray(options.type) : this.types).filter( + type => type !== 'space' + ), namespace: spaceIdToNamespace(this.spaceId), }); }