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:
@@ -1,17 +1,9 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||
import { ContentEnum } from "../../../../types/content"
|
||||
import {
|
||||
rawLinkRefsUnionSchema,
|
||||
rawLinkUnionSchema,
|
||||
transformPageLink,
|
||||
} from "../pageLinks"
|
||||
import {
|
||||
imageContainerRefsSchema,
|
||||
imageContainerSchema,
|
||||
} from "./imageContainer"
|
||||
import { sysAssetRefsSchema, sysAssetSchema } from "./sysAsset"
|
||||
import { rawLinkUnionSchema, transformPageLink } from "../pageLinks"
|
||||
import { imageContainerSchema } from "./imageContainer"
|
||||
import { sysAssetSchema } from "./sysAsset"
|
||||
|
||||
export const contentSchema = z.object({
|
||||
typename: z
|
||||
@@ -50,39 +42,3 @@ export const contentSchema = z.object({
|
||||
return data?.content
|
||||
}),
|
||||
})
|
||||
|
||||
export const contentRefsSchema = z.object({
|
||||
content: z
|
||||
.object({
|
||||
content: z
|
||||
.object({
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.discriminatedUnion("__typename", [
|
||||
sysAssetRefsSchema,
|
||||
imageContainerRefsSchema,
|
||||
...rawLinkRefsUnionSchema.options,
|
||||
]),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.nullish(),
|
||||
})
|
||||
.nullish()
|
||||
.transform((data) => {
|
||||
return data?.content?.embedded_itemsConnection.edges
|
||||
.map(({ node }) => {
|
||||
switch (node.__typename) {
|
||||
case ContentEnum.blocks.SysAsset:
|
||||
return node.system && (node.permanent_url || node.url)
|
||||
? { system: node.system, url: node.permanent_url || node.url }
|
||||
: null
|
||||
default:
|
||||
return node.system
|
||||
}
|
||||
})
|
||||
.filter((node) => !!node)
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user