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
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
|
import { rawLinkUnionSchema, transformPageLink } from "../pageLinks"
|
|
import { sysAssetSchema } from "./sysAsset"
|
|
|
|
export const textColsSchema = z.object({
|
|
typename: z
|
|
.literal(BlocksEnums.block.TextCols)
|
|
.optional()
|
|
.default(BlocksEnums.block.TextCols),
|
|
text_cols: z.object({
|
|
columns: z.array(
|
|
z.object({
|
|
title: z.string().optional().default(""),
|
|
text: z.object({
|
|
json: z.any(), // JSON
|
|
embedded_itemsConnection: z.object({
|
|
edges: z.array(
|
|
z.object({
|
|
node: z
|
|
.discriminatedUnion("__typename", [
|
|
sysAssetSchema,
|
|
...rawLinkUnionSchema.options,
|
|
])
|
|
.transform((data) => {
|
|
const link = transformPageLink(data)
|
|
if (link) {
|
|
return link
|
|
}
|
|
return data
|
|
}),
|
|
})
|
|
),
|
|
}),
|
|
}),
|
|
})
|
|
),
|
|
}),
|
|
})
|