Merged in fix/book-453-linkconnection (pull request #2972)
fix(BOOK-453): avoid linkConnection invalid * fix(BOOK-453): avoid linkConnection invalid * test * test * test * Merge master
This commit is contained in:
@@ -4,6 +4,7 @@ import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
|
||||
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
|
||||
|
||||
import { ContentEnum } from "../../../types/content"
|
||||
import { safeUnion } from "../base/utils"
|
||||
import { systemSchema } from "./system"
|
||||
|
||||
export const pageLinkSchema = z.object({
|
||||
@@ -20,7 +21,7 @@ export const accountPageSchema = z
|
||||
|
||||
export const accountPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.AccountPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const extendedPageLinkSchema = pageLinkSchema.merge(
|
||||
@@ -41,7 +42,7 @@ export const campaignOverviewPageSchema = z
|
||||
|
||||
export const campaignOverviewPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.CampaignOverviewPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const collectionPageSchema = z
|
||||
@@ -52,7 +53,7 @@ export const collectionPageSchema = z
|
||||
|
||||
export const collectionPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.CollectionPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const contentPageSchema = z
|
||||
@@ -63,7 +64,7 @@ export const contentPageSchema = z
|
||||
|
||||
export const contentPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.ContentPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const destinationCityPageSchema = z
|
||||
@@ -74,7 +75,7 @@ export const destinationCityPageSchema = z
|
||||
|
||||
export const destinationCityPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.DestinationCityPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const campaignPageSchema = z
|
||||
@@ -85,7 +86,7 @@ export const campaignPageSchema = z
|
||||
|
||||
export const campaignPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.CampaignPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const destinationCountryPageSchema = z
|
||||
@@ -96,7 +97,7 @@ export const destinationCountryPageSchema = z
|
||||
|
||||
export const destinationCountryPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.DestinationCountryPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const destinationOverviewPageSchema = z
|
||||
@@ -107,7 +108,7 @@ export const destinationOverviewPageSchema = z
|
||||
|
||||
export const destinationOverviewPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.DestinationOverviewPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const hotelPageSchema = z
|
||||
@@ -118,7 +119,7 @@ export const hotelPageSchema = z
|
||||
|
||||
export const hotelPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.HotelPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const loyaltyPageSchema = z
|
||||
@@ -129,7 +130,7 @@ export const loyaltyPageSchema = z
|
||||
|
||||
export const loyaltyPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.LoyaltyPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const startPageSchema = z
|
||||
@@ -140,7 +141,7 @@ export const startPageSchema = z
|
||||
|
||||
export const startPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.StartPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const promoCampaignPageSchema = z
|
||||
@@ -151,10 +152,10 @@ export const promoCampaignPageSchema = z
|
||||
|
||||
export const promoCampaignPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.PromoCampaignPage),
|
||||
system: systemSchema,
|
||||
system: systemSchema.nullable(),
|
||||
})
|
||||
|
||||
export const linkUnionSchema = z.discriminatedUnion("__typename", [
|
||||
export const rawLinkUnionSchema = z.discriminatedUnion("__typename", [
|
||||
accountPageSchema,
|
||||
campaignOverviewPageSchema,
|
||||
campaignPageSchema,
|
||||
@@ -169,6 +170,7 @@ export const linkUnionSchema = z.discriminatedUnion("__typename", [
|
||||
promoCampaignPageSchema,
|
||||
])
|
||||
|
||||
export const linkUnionSchema = safeUnion(rawLinkUnionSchema)
|
||||
type Data =
|
||||
| z.output<typeof accountPageSchema>
|
||||
| z.output<typeof campaignOverviewPageSchema>
|
||||
@@ -262,7 +264,7 @@ export const internalOrExternalLinkSchema = z
|
||||
}
|
||||
)
|
||||
|
||||
export const linkRefsUnionSchema = z.discriminatedUnion("__typename", [
|
||||
export const rawLinkRefsUnionSchema = z.discriminatedUnion("__typename", [
|
||||
accountPageRefSchema,
|
||||
campaignOverviewPageRefSchema,
|
||||
campaignPageRefSchema,
|
||||
@@ -277,6 +279,8 @@ export const linkRefsUnionSchema = z.discriminatedUnion("__typename", [
|
||||
promoCampaignPageRefSchema,
|
||||
])
|
||||
|
||||
export const linkRefsUnionSchema = safeUnion(rawLinkRefsUnionSchema)
|
||||
|
||||
type RefData =
|
||||
| z.output<typeof accountPageRefSchema>
|
||||
| z.output<typeof campaignOverviewPageRefSchema>
|
||||
|
||||
Reference in New Issue
Block a user