Merged in feat/rework-contentstack (pull request #3493)
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
This commit is contained in:
@@ -6,21 +6,11 @@ import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
|
||||
import { DestinationCityPageEnum } from "../../../types/destinationCityPage"
|
||||
import { isDefined } from "../../../utils"
|
||||
import { discriminatedUnionArray } from "../../../utils/discriminatedUnion"
|
||||
import {
|
||||
accordionRefsSchema,
|
||||
accordionSchema,
|
||||
} from "../schemas/blocks/accordion"
|
||||
import { contentRefsSchema, contentSchema } from "../schemas/blocks/content"
|
||||
import {
|
||||
destinationFiltersRefsSchema,
|
||||
transformedDestinationFiltersSchema,
|
||||
} from "../schemas/destinationFilters"
|
||||
import { accordionSchema } from "../schemas/blocks/accordion"
|
||||
import { contentSchema } from "../schemas/blocks/content"
|
||||
import { transformedDestinationFiltersSchema } from "../schemas/destinationFilters"
|
||||
import { mapLocationSchema } from "../schemas/mapLocation"
|
||||
import {
|
||||
linkRefsUnionSchema,
|
||||
linkUnionSchema,
|
||||
transformPageLink,
|
||||
} from "../schemas/pageLinks"
|
||||
import { linkUnionSchema, transformPageLink } from "../schemas/pageLinks"
|
||||
import { systemSchema } from "../schemas/system"
|
||||
|
||||
import type { ImageVaultAsset } from "@scandic-hotels/common/utils/imageVault"
|
||||
@@ -227,47 +217,3 @@ export const batchedCityPageUrlsSchema = z
|
||||
.transform((allItems) => {
|
||||
return allItems.flatMap((item) => item.data)
|
||||
})
|
||||
|
||||
/** REFS */
|
||||
const destinationCityPageContentRefs = z
|
||||
.object({
|
||||
__typename: z.literal(DestinationCityPageEnum.ContentStack.blocks.Content),
|
||||
})
|
||||
.merge(contentRefsSchema)
|
||||
|
||||
const destinationCityPageAccordionRefs = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCityPageEnum.ContentStack.blocks.Accordion
|
||||
),
|
||||
})
|
||||
.merge(accordionRefsSchema)
|
||||
|
||||
const blocksRefsSchema = z.discriminatedUnion("__typename", [
|
||||
destinationCityPageAccordionRefs,
|
||||
destinationCityPageContentRefs,
|
||||
])
|
||||
|
||||
export const destinationCityPageRefsSchema = z.object({
|
||||
destination_city_page: z.object({
|
||||
destination_settings: destinationCityPageDestinationSettingsSchema,
|
||||
sidepeek_content: z
|
||||
.object({
|
||||
content: z
|
||||
.object({
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkRefsUnionSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.nullish(),
|
||||
})
|
||||
.nullish(),
|
||||
blocks: discriminatedUnionArray(blocksRefsSchema.options).nullable(),
|
||||
seo_filters: destinationFiltersRefsSchema,
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user