Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Apr 2, 2024
1 parent b819c56 commit 418ad1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions src/modules/sync/modelTransfomers/contentTypeSnippets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ContentTypeElements } from "@kontent-ai/management-sdk";

import { omit } from "../../../utils/object.js";
import { EnvironmentModel } from "../generateSyncModel.js";
import {
Expand All @@ -9,7 +7,7 @@ import {
transformGuidelinesElement,
transformLinkedItemsElement,
transformMultipleChoiceElement,
transformRichText,
transformRichTextElement,
transformTaxonomyElement,
} from "./elementTransformers.js";

Expand All @@ -22,7 +20,7 @@ export const transformContentTypeSnippetsModel = (
switch (element.type) {
case "guidelines":
return transformGuidelinesElement(
element as unknown as ContentTypeElements.IGuidelinesElement,
element,
environmentModel.assets,
environmentModel.items,
);
Expand All @@ -38,13 +36,13 @@ export const transformContentTypeSnippetsModel = (
environmentModel.taxonomyGroups,
);
case "multiple_choice":
return transformMultipleChoiceElement(element as ContentTypeElements.IMultipleChoiceElement);
return transformMultipleChoiceElement(element);
case "custom":
return transformCustomElement(element as ContentTypeElements.ICustomElement, snippet);
return transformCustomElement(element, snippet);
case "asset":
return transformAssetElement(element as ContentTypeElements.IAssetElement, environmentModel.assets);
return transformAssetElement(element, environmentModel.assets);
case "rich_text":
return transformRichText(element as ContentTypeElements.IRichTextElement, environmentModel.contentTypes);
return transformRichTextElement(element, environmentModel.contentTypes);
default:
return transformDefaultElement(element);
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/sync/modelTransfomers/elementTransformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const findContentType = (
return { codename: type.codename };
};

export const replaceRichTextReferences = (
const replaceRichTextReferences = (
richText: string,
assets: ReadonlyArray<AssetContracts.IAssetModelContract>,
items: ReadonlyArray<ContentItemContracts.IContentItemModelContract>,
Expand Down Expand Up @@ -130,7 +130,7 @@ export const transformAssetElement = (
};
};

export const transformRichText = (
export const transformRichTextElement = (
element: ContentTypeElements.IRichTextElement,
contentTypes: ReadonlyArray<ContentTypeContracts.IContentTypeContract>,
): SyncSnippetRichTextElement => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/sync/elementTransformers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
transformGuidelinesElement,
transformLinkedItemsElement,
transformMultipleChoiceElement,
transformRichText,
transformRichTextElement,
transformTaxonomyElement,
} from "../../../src/modules/sync/modelTransfomers/elementTransformers";

Expand Down Expand Up @@ -221,7 +221,7 @@ describe("elementTransfomers test", () => {
allowed_item_link_types: [{ codename: contentTypes[0].codename }],
};

const transformedElement = transformRichText(element, contentTypes);
const transformedElement = transformRichTextElement(element, contentTypes);

expect(transformedElement).toEqual(expectedOutput);
});
Expand Down

0 comments on commit 418ad1b

Please sign in to comment.