From 2bdd88efa4f757e1a9a2a967c8f2e4ec3d30cd2a Mon Sep 17 00:00:00 2001 From: Ivan Kiral Date: Thu, 14 Mar 2024 10:37:17 +0100 Subject: [PATCH] add skeleton for transforming snippets --- .../modelTransfomers/contentTypeSnippets.ts | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/modules/sync/modelTransfomers/contentTypeSnippets.ts b/src/modules/sync/modelTransfomers/contentTypeSnippets.ts index 5e075708..e87332a9 100644 --- a/src/modules/sync/modelTransfomers/contentTypeSnippets.ts +++ b/src/modules/sync/modelTransfomers/contentTypeSnippets.ts @@ -1,11 +1,35 @@ +import { omit } from "../../../utils/object.js"; import { EnvironmentModel } from "../generateSyncModel.js"; import { ContentTypeSnippetsSyncModel } from "../types/fileContentModel.js"; export const transformContentTypeSnippetsModel = ( - environmentModel: EnvironmentModel, + environmentModel: EnvironmentModel ) => { - // TODO - environmentModel as never; + environmentModel.contentTypeSnippets.map(snippet => { + const syncSnippetElements: ContentTypeSnippetsSyncModel["elements"] = snippet.elements + .map(element => { + switch (element.type) { + case "guidelines": + return { ...element, codename: element.codename as string }; + case "modular_content": + return { ...element, codename: element.codename as string }; + case "taxonomy": + return { ...element, codename: element.codename as string }; + case "multiple_choice": + return { ...element, codename: element.codename as string }; + case "custom": + return { ...element, codename: element.codename as string }; + case "asset": + return { ...element, codename: element.codename as string }; + case "rich_text": + return { ...element, codename: element.codename as string }; + default: + return { ...omit(element, ["id"]), codename: element.codename as string }; + } + }); + + return { ...omit(snippet, ["id", "last_modified"]), elements: syncSnippetElements }; + }); return [] as ContentTypeSnippetsSyncModel[]; };