import { z } from 'zod'; import { ListSchema } from './common'; export const RatingSchema = z.object({ id: z.uuid(), productionId: z.uuid(), rating: z.coerce.number().multipleOf(0.5).min(0).max(5), }); export type Rating = z.infer; export const RatingHalSchema = RatingSchema.extend({ _links: z.object({ self: z.object({ href: z.string(), }), }), }); export type RatingHalSchemaType = z.infer; export const RatingHalListSchema = ListSchema.extend({ _embedded: z.object({ ratings: z.array(RatingHalSchema), }), }); export type RatingHalListSchemaType = z.infer; export const ProductionRatingSchema = z.object({ rating: z.coerce.number().min(0).max(5).nullable(), count: z.number(), }); export type ProductionRating = z.infer; export const ProductionRatingHalSchema = ProductionRatingSchema.pick({ rating: true, count: true, }).extend({ _links: z.object({ self: z.object({ href: z.string(), }), }), }); export type ProductionRatingHalSchemaType = z.infer< typeof ProductionRatingHalSchema >;