fix(SW-188): use camelCase for schemas
This commit is contained in:
@@ -2,7 +2,7 @@ import { z } from "zod"
|
||||
|
||||
import { toLang } from "@/server/utils"
|
||||
|
||||
const RatingsSchema = z
|
||||
const ratingsSchema = z
|
||||
.object({
|
||||
tripAdvisor: z.object({
|
||||
numberOfReviews: z.number(),
|
||||
@@ -28,63 +28,63 @@ const RatingsSchema = z
|
||||
})
|
||||
.optional()
|
||||
|
||||
const AddressSchema = z.object({
|
||||
const addressSchema = z.object({
|
||||
streetAddress: z.string(),
|
||||
city: z.string(),
|
||||
zipCode: z.string(),
|
||||
country: z.string(),
|
||||
})
|
||||
|
||||
const ContactInformationSchema = z.object({
|
||||
const contactInformationSchema = z.object({
|
||||
phoneNumber: z.string(),
|
||||
faxNumber: z.string().optional(),
|
||||
email: z.string(),
|
||||
websiteUrl: z.string(),
|
||||
})
|
||||
|
||||
const CheckinSchema = z.object({
|
||||
const checkinSchema = z.object({
|
||||
checkInTime: z.string(),
|
||||
checkOutTime: z.string(),
|
||||
onlineCheckOutAvailableFrom: z.string().nullable().optional(),
|
||||
onlineCheckout: z.boolean(),
|
||||
})
|
||||
|
||||
const EcoLabelsSchema = z.object({
|
||||
const ecoLabelsSchema = z.object({
|
||||
euEcoLabel: z.boolean(),
|
||||
greenGlobeLabel: z.boolean(),
|
||||
nordicEcoLabel: z.boolean(),
|
||||
svanenEcoLabelCertificateNumber: z.string().optional(),
|
||||
})
|
||||
|
||||
const HotelFacilityDetailSchema = z.object({
|
||||
const hotelFacilityDetailSchema = z.object({
|
||||
heading: z.string(),
|
||||
description: z.string(),
|
||||
})
|
||||
|
||||
const HotelFacilitySchema = z.object({
|
||||
breakfast: HotelFacilityDetailSchema,
|
||||
checkout: HotelFacilityDetailSchema,
|
||||
gym: HotelFacilityDetailSchema,
|
||||
internet: HotelFacilityDetailSchema,
|
||||
laundry: HotelFacilityDetailSchema,
|
||||
luggage: HotelFacilityDetailSchema,
|
||||
shop: HotelFacilityDetailSchema,
|
||||
telephone: HotelFacilityDetailSchema,
|
||||
const hotelFacilitySchema = z.object({
|
||||
breakfast: hotelFacilityDetailSchema,
|
||||
checkout: hotelFacilityDetailSchema,
|
||||
gym: hotelFacilityDetailSchema,
|
||||
internet: hotelFacilityDetailSchema,
|
||||
laundry: hotelFacilityDetailSchema,
|
||||
luggage: hotelFacilityDetailSchema,
|
||||
shop: hotelFacilityDetailSchema,
|
||||
telephone: hotelFacilityDetailSchema,
|
||||
})
|
||||
|
||||
const HotelInformationDetailSchema = z.object({
|
||||
const hotelInformationDetailSchema = z.object({
|
||||
heading: z.string(),
|
||||
description: z.string(),
|
||||
link: z.string().optional(),
|
||||
})
|
||||
|
||||
const HotelInformationSchema = z.object({
|
||||
accessibility: HotelInformationDetailSchema,
|
||||
safety: HotelInformationDetailSchema,
|
||||
sustainability: HotelInformationDetailSchema,
|
||||
const hotelInformationSchema = z.object({
|
||||
accessibility: hotelInformationDetailSchema,
|
||||
safety: hotelInformationDetailSchema,
|
||||
sustainability: hotelInformationDetailSchema,
|
||||
})
|
||||
|
||||
const InteriorSchema = z.object({
|
||||
const interiorSchema = z.object({
|
||||
numberOfBeds: z.number(),
|
||||
numberOfCribs: z.number(),
|
||||
numberOfFloors: z.number(),
|
||||
@@ -99,37 +99,37 @@ const InteriorSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const ReceptionHoursSchema = z.object({
|
||||
const receptionHoursSchema = z.object({
|
||||
alwaysOpen: z.boolean(),
|
||||
isClosed: z.boolean(),
|
||||
openingTime: z.string().optional(),
|
||||
closingTime: z.string().optional(),
|
||||
})
|
||||
|
||||
const LocationSchema = z.object({
|
||||
const locationSchema = z.object({
|
||||
distanceToCentre: z.number(),
|
||||
latitude: z.number(),
|
||||
longitude: z.number(),
|
||||
})
|
||||
|
||||
const ImageMetaDataSchema = z.object({
|
||||
const imageMetaDataSchema = z.object({
|
||||
title: z.string(),
|
||||
altText: z.string(),
|
||||
altText_En: z.string(),
|
||||
copyRight: z.string(),
|
||||
})
|
||||
|
||||
const ImageSizesSchema = z.object({
|
||||
const imageSizesSchema = z.object({
|
||||
tiny: z.string(),
|
||||
small: z.string(),
|
||||
medium: z.string(),
|
||||
large: z.string(),
|
||||
})
|
||||
|
||||
const HotelContentSchema = z.object({
|
||||
const hotelContentSchema = z.object({
|
||||
images: z.object({
|
||||
metaData: ImageMetaDataSchema,
|
||||
imageSizes: ImageSizesSchema,
|
||||
metaData: imageMetaDataSchema,
|
||||
imageSizes: imageSizesSchema,
|
||||
}),
|
||||
texts: z.object({
|
||||
facilityInformation: z.string(),
|
||||
@@ -147,7 +147,7 @@ const HotelContentSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const DetailedFacilitySchema = z.object({
|
||||
const detailedFacilitySchema = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
code: z.string().optional(),
|
||||
@@ -158,13 +158,13 @@ const DetailedFacilitySchema = z.object({
|
||||
sortOrder: z.number(),
|
||||
})
|
||||
|
||||
const HealthFacilitySchema = z.object({
|
||||
const healthFacilitySchema = z.object({
|
||||
type: z.string(),
|
||||
content: z.object({
|
||||
images: z.array(
|
||||
z.object({
|
||||
metaData: ImageMetaDataSchema,
|
||||
imageSizes: ImageSizesSchema,
|
||||
metaData: imageMetaDataSchema,
|
||||
imageSizes: imageSizesSchema,
|
||||
})
|
||||
),
|
||||
texts: z.object({
|
||||
@@ -205,7 +205,7 @@ const HealthFacilitySchema = z.object({
|
||||
),
|
||||
})
|
||||
|
||||
const RewardNightSchema = z.object({
|
||||
const rewardNightSchema = z.object({
|
||||
points: z.number(),
|
||||
campaign: z.object({
|
||||
start: z.string(),
|
||||
@@ -214,18 +214,18 @@ const RewardNightSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const PointsOfInterestSchema = z.object({
|
||||
const pointsOfInterestSchema = z.object({
|
||||
name: z.string(),
|
||||
distance: z.number(),
|
||||
category: z.object({
|
||||
name: z.string(),
|
||||
group: z.string(),
|
||||
}),
|
||||
location: LocationSchema,
|
||||
location: locationSchema,
|
||||
isHighlighted: z.boolean(),
|
||||
})
|
||||
|
||||
const ParkingPricingSchema = z.object({
|
||||
const parkingPricingSchema = z.object({
|
||||
freeParking: z.boolean(),
|
||||
paymentType: z.string(),
|
||||
localCurrency: z.object({
|
||||
@@ -278,7 +278,7 @@ const ParkingPricingSchema = z.object({
|
||||
.optional(),
|
||||
})
|
||||
|
||||
const ParkingSchema = z.object({
|
||||
const parkingSchema = z.object({
|
||||
type: z.string(),
|
||||
name: z.string(),
|
||||
address: z.string(),
|
||||
@@ -286,25 +286,25 @@ const ParkingSchema = z.object({
|
||||
numberOfChargingSpaces: z.number(),
|
||||
distanceToHotel: z.number(),
|
||||
canMakeReservation: z.boolean(),
|
||||
pricing: ParkingPricingSchema,
|
||||
pricing: parkingPricingSchema,
|
||||
})
|
||||
|
||||
const SpecialNeedSchema = z.object({
|
||||
const specialNeedSchema = z.object({
|
||||
name: z.string(),
|
||||
details: z.string(),
|
||||
})
|
||||
|
||||
const SpecialNeedGroupSchema = z.object({
|
||||
const specialNeedGroupSchema = z.object({
|
||||
name: z.string(),
|
||||
specialNeeds: z.array(SpecialNeedSchema),
|
||||
specialNeeds: z.array(specialNeedSchema),
|
||||
})
|
||||
|
||||
const SocialMediaSchema = z.object({
|
||||
const socialMediaSchema = z.object({
|
||||
instagram: z.string().optional(),
|
||||
facebook: z.string().optional(),
|
||||
})
|
||||
|
||||
const MetaSpecialAlertSchema = z.object({
|
||||
const metaSpecialAlertSchema = z.object({
|
||||
type: z.string(),
|
||||
description: z.string().optional(),
|
||||
displayInBookingFlow: z.boolean(),
|
||||
@@ -312,11 +312,11 @@ const MetaSpecialAlertSchema = z.object({
|
||||
endDate: z.string(),
|
||||
})
|
||||
|
||||
const MetaSchema = z.object({
|
||||
specialAlerts: z.array(MetaSpecialAlertSchema),
|
||||
const metaSchema = z.object({
|
||||
specialAlerts: z.array(metaSpecialAlertSchema),
|
||||
})
|
||||
|
||||
const RelationshipsSchema = z.object({
|
||||
const relationshipsSchema = z.object({
|
||||
restaurants: z.object({
|
||||
links: z.object({
|
||||
related: z.string(),
|
||||
@@ -339,11 +339,11 @@ const RelationshipsSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const RoomContentSchema = z.object({
|
||||
const roomContentSchema = z.object({
|
||||
images: z.array(
|
||||
z.object({
|
||||
metaData: ImageMetaDataSchema,
|
||||
imageSizes: ImageSizesSchema,
|
||||
metaData: imageMetaDataSchema,
|
||||
imageSizes: imageSizesSchema,
|
||||
})
|
||||
),
|
||||
texts: z.object({
|
||||
@@ -354,7 +354,7 @@ const RoomContentSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const RoomTypesSchema = z.object({
|
||||
const roomTypesSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
code: z.string(),
|
||||
@@ -388,20 +388,20 @@ const RoomTypesSchema = z.object({
|
||||
isLackingExtraBeds: z.boolean(),
|
||||
})
|
||||
|
||||
const RoomFacilitiesSchema = z.object({
|
||||
const roomFacilitiesSchema = z.object({
|
||||
availableInAllRooms: z.boolean(),
|
||||
name: z.string(),
|
||||
isUniqueSellingPoint: z.boolean(),
|
||||
sortOrder: z.number(),
|
||||
})
|
||||
|
||||
export const RoomSchema = z.object({
|
||||
export const roomSchema = z.object({
|
||||
attributes: z.object({
|
||||
name: z.string(),
|
||||
sortOrder: z.number(),
|
||||
content: RoomContentSchema,
|
||||
roomTypes: z.array(RoomTypesSchema),
|
||||
roomFacilities: z.array(RoomFacilitiesSchema),
|
||||
content: roomContentSchema,
|
||||
roomTypes: z.array(roomTypesSchema),
|
||||
roomFacilities: z.array(roomFacilitiesSchema),
|
||||
occupancy: z.object({
|
||||
total: z.number(),
|
||||
adults: z.number(),
|
||||
@@ -440,35 +440,35 @@ export const getHotelDataSchema = z.object({
|
||||
isPublished: z.boolean(),
|
||||
cityId: z.string(),
|
||||
cityName: z.string(),
|
||||
ratings: RatingsSchema,
|
||||
address: AddressSchema,
|
||||
contactInformation: ContactInformationSchema,
|
||||
ratings: ratingsSchema,
|
||||
address: addressSchema,
|
||||
contactInformation: contactInformationSchema,
|
||||
hotelFacts: z.object({
|
||||
checkin: CheckinSchema,
|
||||
ecoLabels: EcoLabelsSchema,
|
||||
hotelFacilityDetail: HotelFacilitySchema,
|
||||
hotelInformation: HotelInformationSchema,
|
||||
interior: InteriorSchema,
|
||||
receptionHours: ReceptionHoursSchema,
|
||||
checkin: checkinSchema,
|
||||
ecoLabels: ecoLabelsSchema,
|
||||
hotelFacilityDetail: hotelFacilitySchema,
|
||||
hotelInformation: hotelInformationSchema,
|
||||
interior: interiorSchema,
|
||||
receptionHours: receptionHoursSchema,
|
||||
yearBuilt: z.string(),
|
||||
}),
|
||||
location: LocationSchema,
|
||||
hotelContent: HotelContentSchema,
|
||||
detailedFacilities: z.array(DetailedFacilitySchema),
|
||||
healthFacilities: z.array(HealthFacilitySchema),
|
||||
rewardNight: RewardNightSchema,
|
||||
pointsOfInterest: z.array(PointsOfInterestSchema),
|
||||
parking: z.array(ParkingSchema),
|
||||
specialNeedGroups: z.array(SpecialNeedGroupSchema),
|
||||
socialMedia: SocialMediaSchema,
|
||||
meta: MetaSchema.optional(),
|
||||
location: locationSchema,
|
||||
hotelContent: hotelContentSchema,
|
||||
detailedFacilities: z.array(detailedFacilitySchema),
|
||||
healthFacilities: z.array(healthFacilitySchema),
|
||||
rewardNight: rewardNightSchema,
|
||||
pointsOfInterest: z.array(pointsOfInterestSchema),
|
||||
parking: z.array(parkingSchema),
|
||||
specialNeedGroups: z.array(specialNeedGroupSchema),
|
||||
socialMedia: socialMediaSchema,
|
||||
meta: metaSchema.optional(),
|
||||
isActive: z.boolean(),
|
||||
}),
|
||||
relationships: RelationshipsSchema,
|
||||
relationships: relationshipsSchema,
|
||||
}),
|
||||
// NOTE: We can pass an "include" param to the hotel API to retrieve
|
||||
// additional data for an individual hotel.
|
||||
included: z.array(RoomSchema).optional(),
|
||||
included: z.array(roomSchema).optional(),
|
||||
})
|
||||
|
||||
const rate = z.object({
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
getFiltersSchema,
|
||||
getHotelDataSchema,
|
||||
getRatesSchema,
|
||||
RoomSchema,
|
||||
roomSchema,
|
||||
} from "./output"
|
||||
import tempFilterData from "./tempFilterData.json"
|
||||
import tempRatesData from "./tempRatesData.json"
|
||||
@@ -63,7 +63,7 @@ export const hotelQueryRouter = router({
|
||||
? included
|
||||
.filter((item) => item.type === "roomcategories")
|
||||
.map((roomCategory) => {
|
||||
const validatedRoom = RoomSchema.safeParse(roomCategory)
|
||||
const validatedRoom = roomSchema.safeParse(roomCategory)
|
||||
if (!validatedRoom.success) {
|
||||
console.error(`Get Room Category Data - Verified Data Error`)
|
||||
console.error(validatedRoom.error)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { getHotelDataSchema, RoomSchema } from "@/server/routers/hotels/output"
|
||||
import { getHotelDataSchema, roomSchema } from "@/server/routers/hotels/output"
|
||||
|
||||
export type HotelData = z.infer<typeof getHotelDataSchema>
|
||||
|
||||
@@ -13,4 +13,4 @@ export type HotelTripAdvisor =
|
||||
| NonNullable<HotelRatings>["tripAdvisor"]
|
||||
| undefined
|
||||
|
||||
export type RoomData = z.infer<typeof RoomSchema>
|
||||
export type RoomData = z.infer<typeof roomSchema>
|
||||
|
||||
Reference in New Issue
Block a user