Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Sep 9, 2024
1 parent c685ba9 commit d47406c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/modules/sync/sync/collections.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CollectionModels, ManagementClient } from "@kontent-ai/management-sdk";

import { omit } from "../../../utils/object.js";
import { DiffModel } from "../types/diffModel.js";
import { getTargetCodename, PatchOperation } from "../types/patchOperation.js";

Expand All @@ -20,14 +21,12 @@ const transformCollectionsReferences = (operation: PatchOperation): CollectionMo
const codename = getTargetCodename(operation);

return {
...operation,
path: undefined,
...operation.op === "replace" ? omit(operation, ["path", "oldValue"]) : omit(operation, ["path"]),
reference: codename
? {
codename: codename,
}
: undefined,
property_name: operation.op === "replace" ? propertyName : undefined,
oldValue: undefined,
} as unknown as CollectionModels.ISetCollectionData;
};
2 changes: 1 addition & 1 deletion src/modules/sync/utils/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ export const fetchCollections = (client: ManagementClient) =>
client
.listCollections()
.toPromise()
.then(res => res.data.collections.map(c => c._raw));
.then(res => res.rawData.collections);

0 comments on commit d47406c

Please sign in to comment.