feat(SW-1818): Refactored sysAsset handling to support PDF links

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-06-09 09:28:17 +00:00
parent bff34b034e
commit ac953ccd97
23 changed files with 86 additions and 84 deletions

View File

@@ -0,0 +1,36 @@
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),
})