Merged in feat/support-for-all-page-links (pull request #1212)
Feat/support for all page links * feat: added all page link connections to queries * feat: updated output files Approved-by: Fredrik Thorsson Approved-by: Matilda Landström
This commit is contained in:
@@ -74,6 +74,12 @@ export const destinationCountryPageRefSchema = z.object({
|
||||
system: systemSchema,
|
||||
})
|
||||
|
||||
export const destinationOverviewPageSchema = z
|
||||
.object({
|
||||
__typename: z.literal(ContentEnum.blocks.DestinationOverviewPage),
|
||||
})
|
||||
.merge(pageLinkSchema)
|
||||
|
||||
export const destinationOverviewPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.DestinationOverviewPage),
|
||||
system: systemSchema,
|
||||
@@ -101,19 +107,50 @@ export const loyaltyPageRefSchema = z.object({
|
||||
system: systemSchema,
|
||||
})
|
||||
|
||||
export const startPageSchema = z
|
||||
.object({
|
||||
__typename: z.literal(ContentEnum.blocks.StartPage),
|
||||
})
|
||||
.merge(pageLinkSchema)
|
||||
|
||||
export const startPageRefSchema = z.object({
|
||||
__typename: z.literal(ContentEnum.blocks.StartPage),
|
||||
system: systemSchema,
|
||||
})
|
||||
|
||||
export const linkUnionSchema = z.discriminatedUnion("__typename", [
|
||||
accountPageSchema,
|
||||
collectionPageSchema,
|
||||
contentPageSchema,
|
||||
destinationCityPageSchema,
|
||||
destinationCountryPageSchema,
|
||||
destinationOverviewPageSchema,
|
||||
hotelPageSchema,
|
||||
loyaltyPageSchema,
|
||||
startPageSchema,
|
||||
])
|
||||
|
||||
type Data =
|
||||
| z.output<typeof accountPageSchema>
|
||||
| z.output<typeof contentPageSchema>
|
||||
| z.output<typeof collectionPageSchema>
|
||||
| z.output<typeof contentPageSchema>
|
||||
| z.output<typeof destinationCityPageSchema>
|
||||
| z.output<typeof destinationCountryPageSchema>
|
||||
| z.output<typeof destinationOverviewPageSchema>
|
||||
| z.output<typeof hotelPageSchema>
|
||||
| z.output<typeof loyaltyPageSchema>
|
||||
| z.output<typeof startPageSchema>
|
||||
| Object
|
||||
|
||||
export function transform(data: Data) {
|
||||
export function transformPageLink(data: Data) {
|
||||
if (data && "__typename" in data) {
|
||||
switch (data.__typename) {
|
||||
case ContentEnum.blocks.AccountPage:
|
||||
case ContentEnum.blocks.HotelPage:
|
||||
case ContentEnum.blocks.DestinationCityPage:
|
||||
case ContentEnum.blocks.DestinationCountryPage:
|
||||
case ContentEnum.blocks.DestinationOverviewPage:
|
||||
case ContentEnum.blocks.StartPage:
|
||||
return {
|
||||
__typename: data.__typename,
|
||||
system: data.system,
|
||||
@@ -139,15 +176,31 @@ export function transform(data: Data) {
|
||||
}
|
||||
}
|
||||
|
||||
export const linkRefsUnionSchema = z.discriminatedUnion("__typename", [
|
||||
contentPageRefSchema,
|
||||
hotelPageRefSchema,
|
||||
loyaltyPageRefSchema,
|
||||
accountPageRefSchema,
|
||||
collectionPageRefSchema,
|
||||
destinationCityPageRefSchema,
|
||||
destinationCountryPageRefSchema,
|
||||
destinationOverviewPageRefSchema,
|
||||
startPageRefSchema,
|
||||
])
|
||||
|
||||
type RefData =
|
||||
| z.output<typeof accountPageRefSchema>
|
||||
| z.output<typeof collectionPageRefSchema>
|
||||
| z.output<typeof contentPageRefSchema>
|
||||
| z.output<typeof hotelPageRefSchema>
|
||||
| z.output<typeof loyaltyPageRefSchema>
|
||||
| z.output<typeof destinationCountryPageRefSchema>
|
||||
| z.output<typeof destinationCityPageRefSchema>
|
||||
| z.output<typeof destinationOverviewPageRefSchema>
|
||||
| z.output<typeof startPageRefSchema>
|
||||
| Object
|
||||
|
||||
export function transformRef(data: RefData) {
|
||||
export function transformPageLinkRef(data: RefData) {
|
||||
if (data && "__typename" in data) {
|
||||
switch (data.__typename) {
|
||||
case ContentEnum.blocks.AccountPage:
|
||||
@@ -155,6 +208,10 @@ export function transformRef(data: RefData) {
|
||||
case ContentEnum.blocks.CollectionPage:
|
||||
case ContentEnum.blocks.HotelPage:
|
||||
case ContentEnum.blocks.LoyaltyPage:
|
||||
case ContentEnum.blocks.DestinationCityPage:
|
||||
case ContentEnum.blocks.DestinationCountryPage:
|
||||
case ContentEnum.blocks.DestinationOverviewPage:
|
||||
case ContentEnum.blocks.StartPage:
|
||||
return data.system
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user