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
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { DestinationOverviewPageEnum } from "../../../types/destinationOverviewPage"
|
|
import { discriminatedUnionArray } from "../../../utils/discriminatedUnion"
|
|
import { cardGallerySchema } from "../schemas/blocks/cardGallery"
|
|
import { mapLocationSchema } from "../schemas/mapLocation"
|
|
import { systemSchema } from "../schemas/system"
|
|
|
|
const destinationOverviewPageCardGallery = z
|
|
.object({
|
|
__typename: z.literal(
|
|
DestinationOverviewPageEnum.ContentStack.blocks.CardGallery
|
|
),
|
|
})
|
|
.merge(cardGallerySchema)
|
|
|
|
export const blocksSchema = z.discriminatedUnion("__typename", [
|
|
destinationOverviewPageCardGallery,
|
|
])
|
|
|
|
export const destinationOverviewPageSchema = z.object({
|
|
destination_overview_page: z.object({
|
|
heading: z.string().nullish(),
|
|
blocks: discriminatedUnionArray(blocksSchema.options),
|
|
location: mapLocationSchema,
|
|
system: systemSchema.merge(
|
|
z.object({
|
|
created_at: z.string(),
|
|
updated_at: z.string(),
|
|
})
|
|
),
|
|
}),
|
|
trackingProps: z.object({
|
|
url: z.string(),
|
|
}),
|
|
})
|