Skip to content

Commit

Permalink
Revert "use relative imports for SavedObjectsNamespace"
Browse files Browse the repository at this point in the history
This reverts commit 348ef98.
  • Loading branch information
legrego committed Jun 24, 2019
1 parent 968d8f8 commit e2796ff
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 31 deletions.
10 changes: 1 addition & 9 deletions src/core/server/saved_objects/serialization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/* eslint-disable @typescript-eslint/camelcase */

import uuid from 'uuid';
import { SavedObjectsNamespace } from '../';
import { SavedObjectsNamespace } from 'src/core/server/saved_objects';
import { SavedObjectsSchema } from '../schema';
import { decodeVersion, encodeVersion } from '../version';
import {
Expand Down Expand Up @@ -81,12 +81,6 @@ function assertNonEmptyString(value: string, name: string) {
}
}

function assertNotSymbol(value: unknown, name: string) {
if (typeof value === 'symbol') {
throw new TypeError(`Expected "${String(value)}" to be a ${name}`);
}
}

export class SavedObjectsSerializer {
private readonly schema: SavedObjectsSchema;

Expand Down Expand Up @@ -175,7 +169,6 @@ export class SavedObjectsSerializer {
* @param {string} id - The id of the saved object
*/
public generateRawId(namespace: SavedObjectsNamespace, type: string, id?: string) {
assertNotSymbol(namespace, 'namespace');
const namespacePrefix =
namespace && !this.schema.isNamespaceAgnostic(type) ? `${String(namespace)}:` : '';
return `${namespacePrefix}${type}:${id || uuid.v1()}`;
Expand All @@ -184,7 +177,6 @@ export class SavedObjectsSerializer {
private trimIdPrefix(namespace: SavedObjectsNamespace, type: string, id: string) {
assertNonEmptyString(id, 'document id');
assertNonEmptyString(type, 'saved object type');
assertNotSymbol(namespace, 'namespace');

const namespacePrefix =
namespace && !this.schema.isNamespaceAgnostic(type) ? `${String(namespace)}:` : '';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/server/saved_objects/service/lib/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
* Saved Objects Namespace.
* @public
*/
export type SavedObjectsNamespace = string | undefined | symbol;
export type SavedObjectsNamespace = string | undefined;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { SavedObjectsNamespace } from '../namespace';
import { SavedObjectsNamespace } from 'src/core/server/saved_objects';
import { getRootPropertiesObjects, IndexMapping } from '../../../mappings';
import { SavedObjectsSchema } from '../../../schema';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import Boom from 'boom';

import { SavedObjectsNamespace } from '../namespace';
import { SavedObjectsNamespace } from 'src/core/server/saved_objects';
import { IndexMapping } from '../../../mappings';
import { SavedObjectsSchema } from '../../../schema';
import { getQueryParams } from './query_params';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObjectsRepository, SavedObjectsNamespace } from './lib';
import { SavedObjectsNamespace } from 'src/core/server';
import { SavedObjectsRepository } from './lib';

import { SavedObjectsErrorHelpers } from './lib/errors';

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
Expand Down
13 changes: 13 additions & 0 deletions x-pack/typings/core.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { SavedObjectsClient } from 'src/core/server/saved_objects';

declare module 'src/core/server/saved_objects' {
type SavedObjectsNamespace = string | undefined | symbol;
interface SavedObjectsBaseOptions {
namespace?: SavedObjectsNamespace;
}
}

0 comments on commit e2796ff

Please sign in to comment.