feat (SW-2864): Move booking router to trpc package * Add env to trpc package * Add eslint to trpc package * Apply lint rules * Use direct imports from trpc package * Add lint-staged config to trpc * Move lang enum to common * Restructure trpc package folder structure * WIP first step * update internal imports in trpc * Fix most errors in scandic-web Just 100 left... * Move Props type out of trpc * Fix CategorizedFilters types * Move more schemas in hotel router * Fix deps * fix getNonContentstackUrls * Fix import error * Fix entry error handling * Fix generateMetadata metrics * Fix alertType enum * Fix duplicated types * lint:fix * Merge branch 'master' into feat/sw-2863-move-contentstack-router-to-trpc-package * Fix broken imports * Move booking router to trpc package * Merge branch 'master' into feat/sw-2864-move-hotels-router-to-trpc-package Approved-by: Linus Flood
135 lines
3.4 KiB
TypeScript
135 lines
3.4 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { imageSchema } from "@scandic-hotels/trpc/routers/hotels/schemas/image"
|
|
|
|
// Schema is the same for upcoming and previous stays endpoints
|
|
export const getStaysSchema = z.object({
|
|
data: z.array(
|
|
z.object({
|
|
attributes: z.object({
|
|
hotelOperaId: z.string(),
|
|
hotelInformation: z.object({
|
|
hotelContent: z.object({
|
|
images: imageSchema,
|
|
}),
|
|
hotelName: z.string(),
|
|
cityName: z.string().nullable(),
|
|
}),
|
|
confirmationNumber: z.string(),
|
|
checkinDate: z.string(),
|
|
checkoutDate: z.string(),
|
|
isWebAppOrigin: z.boolean(),
|
|
bookingUrl: z.string().default(""),
|
|
}),
|
|
relationships: z.object({
|
|
hotel: z.object({
|
|
links: z.object({
|
|
related: z.string().nullable().optional(),
|
|
}),
|
|
data: z.object({
|
|
id: z.string(),
|
|
type: z.string(),
|
|
}),
|
|
}),
|
|
}),
|
|
type: z.string(),
|
|
id: z.string(),
|
|
links: z.object({
|
|
self: z.object({
|
|
href: z.string(),
|
|
meta: z.object({
|
|
method: z.string(),
|
|
}),
|
|
}),
|
|
}),
|
|
})
|
|
),
|
|
links: z
|
|
.object({
|
|
self: z.string(),
|
|
offset: z.number(),
|
|
limit: z.number(),
|
|
totalCount: z.number(),
|
|
})
|
|
.optional()
|
|
.nullable(),
|
|
})
|
|
|
|
type GetStaysData = z.infer<typeof getStaysSchema>
|
|
|
|
export type Stay = GetStaysData["data"][number]
|
|
|
|
export const getFriendTransactionsSchema = z.object({
|
|
data: z.array(
|
|
z.object({
|
|
attributes: z.object({
|
|
awardPoints: z.number().default(0),
|
|
checkinDate: z.string().default(""),
|
|
checkoutDate: z.string().default(""),
|
|
confirmationNumber: z.string().default(""),
|
|
hotelOperaId: z.string().default(""),
|
|
nights: z.number().default(1),
|
|
pointsCalculated: z.boolean().default(true),
|
|
transactionDate: z.string().default(""),
|
|
bookingUrl: z.string().default(""),
|
|
hotelInformation: z
|
|
.object({
|
|
city: z.string().default(""),
|
|
name: z.string().default(""),
|
|
hotelContent: z.object({
|
|
images: imageSchema,
|
|
}),
|
|
})
|
|
.optional(),
|
|
}),
|
|
relationships: z.object({
|
|
booking: z.object({
|
|
data: z.object({
|
|
id: z.string().default(""),
|
|
type: z.string().default(""),
|
|
}),
|
|
links: z.object({
|
|
related: z.string().default(""),
|
|
}),
|
|
}),
|
|
hotel: z
|
|
.object({
|
|
data: z.object({
|
|
id: z.string().default(""),
|
|
type: z.string().default(""),
|
|
}),
|
|
links: z.object({
|
|
related: z.string().default(""),
|
|
}),
|
|
})
|
|
.optional(),
|
|
}),
|
|
type: z.string().default(""),
|
|
})
|
|
),
|
|
links: z
|
|
.object({
|
|
self: z.string(),
|
|
})
|
|
.nullable(),
|
|
})
|
|
|
|
type GetFriendTransactionsData = z.infer<typeof getFriendTransactionsSchema>
|
|
|
|
export type FriendTransaction = GetFriendTransactionsData["data"][number]
|
|
|
|
export const initiateSaveCardSchema = z.object({
|
|
data: z.object({
|
|
attribute: z.object({
|
|
transactionId: z.string(),
|
|
link: z.string(),
|
|
mobileToken: z.string().optional(),
|
|
}),
|
|
type: z.string(),
|
|
}),
|
|
})
|
|
|
|
export const subscriberIdSchema = z.object({
|
|
subscriberId: z.string(),
|
|
})
|