From b30162d98bc659a61aae023cdeaead4ce25c7ae9 Mon Sep 17 00:00:00 2001 From: Guy Ben-Aharon Date: Tue, 29 Jul 2025 12:49:28 +0300 Subject: [PATCH] fix: clone of custom types (#804) --- src/lib/clone.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib/clone.ts b/src/lib/clone.ts index 14200a67..2050764e 100644 --- a/src/lib/clone.ts +++ b/src/lib/clone.ts @@ -1,3 +1,4 @@ +import type { DBCustomType } from './domain'; import type { Area } from './domain/area'; import type { DBDependency } from './domain/db-dependency'; import type { DBField } from './domain/db-field'; @@ -48,6 +49,10 @@ const generateIdsMapFromDiagram = ( idsMap.set(area.id, generateId()); }); + diagram.customTypes?.forEach((customType) => { + idsMap.set(customType.id, generateId()); + }); + return idsMap; }; @@ -213,6 +218,22 @@ export const cloneDiagram = ( }) .filter((area): area is Area => area !== null) ?? []; + const customTypes: DBCustomType[] = + diagram.customTypes + ?.map((customType) => { + const id = getNewId(customType.id); + if (!id) { + return null; + } + return { + ...customType, + id, + } satisfies DBCustomType; + }) + .filter( + (customType): customType is DBCustomType => customType !== null + ) ?? []; + return { diagram: { ...diagram, @@ -221,6 +242,7 @@ export const cloneDiagram = ( relationships, tables, areas, + customTypes, createdAt: diagram.createdAt ? new Date(diagram.createdAt) : new Date(),