Files
web/apps/scandic-web/server/routers/contentstack/schemas/blocks/sysAsset.ts
Erik Tiekstra ac953ccd97 feat(SW-1818): Refactored sysAsset handling to support PDF links
Approved-by: Matilda Landström
2025-06-09 09:28:17 +00:00

37 lines
1.2 KiB
TypeScript

import { z } from "zod"
import { ContentEnum } from "@/types/enums/content"
// SysAsset is used for several different assets in ContentStack, such as images, pdf-files, etc.
// It is a generic asset type that can represent any file type.
// A lot of the fields are optional/nullable, hence the use of `.nullish()`.
// The properties of this schema should be handled inside the components that use it, fe. web/apps/scandic-web/components/JsonToHtml/renderOptions.tsx.
export const sysAssetSchema = z.object({
__typename: z.literal(ContentEnum.blocks.SysAsset),
content_type: z.string().nullish(),
description: z.string().nullish(),
dimension: z
.object({
height: z.number(),
width: z.number(),
})
.nullish(),
metadata: z.any(), // JSON
// system for SysAssets is not the same type
// as for all other types eventhough they have
// the exact same structure, that's why systemSchema
// is not used as that correlates to the
// EntrySystemField type
system: z
.object({
uid: z.string(),
})
.nullish(),
title: z.string().nullish(),
url: z.string().nullish(),
})
export const sysAssetRefsSchema = z.object({
__typename: z.literal(ContentEnum.blocks.SysAsset),
})