diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/index.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/index.ts index ab84387e525a..db96a742b2bb 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/index.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/index.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -export { getSavedObjectNamespaces } from './namespaces'; export { isFoundGetResponse, type GetResponseFound } from './es_responses'; export { findSharedOriginObjects } from './find_shared_origin_objects'; export { @@ -20,6 +19,7 @@ export { getSavedObjectFromSource, setManaged, normalizeNamespace, + getSavedObjectNamespaces, type GetSavedObjectFromSourceOptions, } from './internal_utils'; export { type Left, type Either, type Right, isLeft, isRight } from './either'; diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/internal_utils.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/internal_utils.ts index 49f02df61414..f06894bcca1e 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/internal_utils.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/internal_utils.ts @@ -263,6 +263,24 @@ export function setManaged({ return optionsManaged ?? objectManaged ?? false; } +/** + * Returns a string array of namespaces for a given saved object. If the saved object is undefined, the result is an array that contains the + * current namespace. Value may be undefined if an existing saved object has no namespaces attribute; this should not happen in normal + * operations, but it is possible if the Elasticsearch document is manually modified. + * + * @param namespace The current namespace. + * @param document Optional existing saved object that was obtained in a preflight operation. + */ +export function getSavedObjectNamespaces( + namespace?: string, + document?: SavedObjectsRawDoc +): string[] | undefined { + if (document) { + return document._source?.namespaces; + } + return [SavedObjectsUtils.namespaceIdToString(namespace)]; +} + /** * Extracts the contents of a decorated error to return the attributes for bulk operations. */ diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/namespaces.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/namespaces.ts deleted file mode 100644 index 1592d00c0c42..000000000000 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/apis/utils/namespaces.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server'; -import { SavedObjectsUtils } from '@kbn/core-saved-objects-utils-server'; - -/** - * Returns a string array of namespaces for a given saved object. If the saved object is undefined, the result is an array that contains the - * current namespace. Value may be undefined if an existing saved object has no namespaces attribute; this should not happen in normal - * operations, but it is possible if the Elasticsearch document is manually modified. - * - * @param namespace The current namespace. - * @param document Optional existing saved object that was obtained in a preflight operation. - */ -export function getSavedObjectNamespaces( - namespace?: string, - document?: SavedObjectsRawDoc -): string[] | undefined { - if (document) { - return document._source?.namespaces; - } - return [SavedObjectsUtils.namespaceIdToString(namespace)]; -}