Feat(SW-3708): refactor contentstack fetching (removing all refs) and cache invalidation * Remove all REFS * Revalidate correct language * PR fixes * PR fixes * Throw when errors from contentstack api Approved-by: Joakim Jäderberg
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { ContentEnum } from "../../../../types/content"
|
|
import { assetSystemSchema } from "../system"
|
|
|
|
// 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: assetSystemSchema.nullish(),
|
|
title: z.string().nullish(),
|
|
url: z.string().nullish(),
|
|
permanent_url: z
|
|
.string()
|
|
.nullish()
|
|
.transform((val) => (val === "Permanent URL Not Defined!" ? null : val)), // ContentStack returns this string when permanent_url is not defined
|
|
})
|