Skip to content

Commit

Permalink
simplifying
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Feb 28, 2020
1 parent 7337228 commit 1596988
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/spaces/server/saved_objects/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ 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) {
const { baseClient, request, spacesService, typeRegistry } = options;

this.client = baseClient;
this.spaceId = spacesService.getSpaceId(request);
this.typeRegistry = typeRegistry;
this.types = typeRegistry.getAllTypes().map(t => t.name);
this.errors = baseClient.errors;
}

Expand Down Expand Up @@ -138,10 +138,9 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {

return await this.client.find<T>({
...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),
});
}
Expand Down

0 comments on commit 1596988

Please sign in to comment.