From 03baffdc3c5cd2710acf4cf72822eeb6330645ce Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sat, 11 May 2024 22:04:50 +0200 Subject: [PATCH] Added createdAt, updatedAt, updatedBy to collectibles and pages --- .../Collectibles/endpoints/getBySlugEndpoint.ts | 14 ++++++++++++-- .../Pages/endpoints/getBySlugEndpoint.ts | 7 +++++++ src/sdk.ts | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts b/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts index 92cc8a9..17895cd 100644 --- a/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts @@ -19,6 +19,7 @@ import { import { convertAudioToEndpointAudio } from "../../Audios/endpoints/getByID"; import { convertImageToEndpointImage } from "../../Images/endpoints/getByID"; import { convertPageToEndpointPage } from "../../Pages/endpoints/getBySlugEndpoint"; +import { convertRecorderToEndpointRecorder } from "../../Recorders/endpoints/getByUsername"; import { convertVideoToEndpointVideo } from "../../Videos/endpoints/getByID"; export const getBySlugEndpoint = createGetByEndpoint({ @@ -52,9 +53,13 @@ export const convertCollectibleToEndpointCollectible = ({ languages, scans: rawScans, tags, + createdAt, + updatedAt, + scansEnabled, + updatedBy, }: Collectible): EndpointCollectible => { const gallery = handleGallery(rawGallery); - const scans = handleScans(rawScans); + const scans = scansEnabled ? handleScans(rawScans) : undefined; return { slug, @@ -80,7 +85,6 @@ export const convertCollectibleToEndpointCollectible = ({ ...(gallery ? { gallery } : {}), ...(scans ? { scans } : {}), nature: nature === "Physical" ? CollectibleNature.Physical : CollectibleNature.Digital, - parentPages: convertSourceToEndpointSource({ collectibles: parentItems, folders }), subitems: isPayloadArrayType(subitems) ? subitems.filter(isPublished).map(convertCollectibleToEndpointCollectible) : [], @@ -89,6 +93,12 @@ export const convertCollectibleToEndpointCollectible = ({ ...handleSize(size, sizeEnabled), ...handlePageInfo(pageInfo, pageInfoEnabled), ...handlePrice(price, priceEnabled), + createdAt, + updatedAt, + ...(isPayloadType(updatedBy) + ? { updatedBy: convertRecorderToEndpointRecorder(updatedBy) } + : {}), + parentPages: convertSourceToEndpointSource({ collectibles: parentItems, folders }), }; }; diff --git a/src/collections/Pages/endpoints/getBySlugEndpoint.ts b/src/collections/Pages/endpoints/getBySlugEndpoint.ts index ddecefa..f20188f 100644 --- a/src/collections/Pages/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Pages/endpoints/getBySlugEndpoint.ts @@ -17,6 +17,7 @@ import { convertTagsEndpointTagsGroups, } from "../../../utils/endpoints"; import { convertImageToEndpointImage } from "../../Images/endpoints/getByID"; +import { convertRecorderToEndpointRecorder } from "../../Recorders/endpoints/getByUsername"; export const getBySlugEndpoint = createGetByEndpoint({ collection: Collections.Pages, @@ -32,6 +33,9 @@ export const convertPageToEndpointPage = ({ slug, tags, thumbnail, + createdAt, + updatedAt, + updatedBy, }: Page): EndpointPage => ({ slug, ...(isValidPayloadImage(thumbnail) ? { thumbnail: convertImageToEndpointImage(thumbnail) } : {}), @@ -52,6 +56,9 @@ export const convertPageToEndpointPage = ({ credits: convertCreditsToEndpointCredits(credits), }) ), + createdAt, + updatedAt, + ...(isPayloadType(updatedBy) ? { updatedBy: convertRecorderToEndpointRecorder(updatedBy) } : {}), parentPages: convertSourceToEndpointSource({ collectibles, folders }), }); diff --git a/src/sdk.ts b/src/sdk.ts index 6fa5e3c..fcb8839 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -215,6 +215,9 @@ export type EndpointPage = { credits: EndpointCredit[]; toc: TableOfContentEntry[]; }[]; + createdAt: string; + updatedAt: string; + updatedBy?: EndpointRecorder; parentPages: EndpointSource[]; }; @@ -295,6 +298,9 @@ export type EndpointCollectible = { }[]; }; }[]; + createdAt: string; + updatedAt: string; + updatedBy?: EndpointRecorder; parentPages: EndpointSource[]; };