diff --git a/src/core/server/saved_objects/import/regenerate_ids.ts b/src/core/server/saved_objects/import/regenerate_ids.ts index 3b5a6ba46a85..f1092bed7f55 100644 --- a/src/core/server/saved_objects/import/regenerate_ids.ts +++ b/src/core/server/saved_objects/import/regenerate_ids.ts @@ -37,16 +37,13 @@ import { SavedObject } from '../types'; * @param objects The saved objects to generate new IDs for. */ export const regenerateIds = (objects: SavedObject[], dataSourceId: string | undefined) => { - const importIdMap = objects - .filter((object) => object.type !== 'data-source') - .reduce((acc, object) => { - if (dataSourceId) { - return acc.set(`${object.type}:${object.id}`, { - id: `${dataSourceId}_${uuidv4()}`, + const importIdMap = objects.reduce((acc, object) => { + return object.type === 'data-source' + ? acc + : acc.set(`${object.type}:${object.id}`, { + id: dataSourceId ? `${dataSourceId}_${uuidv4()}` : uuidv4(), omitOriginId: true, }); - } - return acc.set(`${object.type}:${object.id}`, { id: uuidv4(), omitOriginId: true }); - }, new Map()); + }, new Map()); return importIdMap; };