2022-04-01 15:53:52 +00:00
|
|
|
import { z } from "zod";
|
2022-03-26 21:29:30 +00:00
|
|
|
|
2022-03-30 15:37:51 +00:00
|
|
|
import { _BookingModel as Booking } from "@calcom/prisma/zod";
|
|
|
|
|
2022-04-27 17:25:36 +00:00
|
|
|
const schemaBookingBaseBodyParams = Booking.pick({
|
|
|
|
uid: true,
|
|
|
|
userId: true,
|
|
|
|
eventTypeId: true,
|
|
|
|
title: true,
|
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
|
|
|
}).partial();
|
2022-04-01 21:03:03 +00:00
|
|
|
|
2022-04-27 17:25:36 +00:00
|
|
|
const schemaBookingCreateParams = z.object({
|
2022-04-01 15:53:52 +00:00
|
|
|
uid: z.string(),
|
2022-04-27 17:25:36 +00:00
|
|
|
userId: z.number(),
|
|
|
|
eventTypeId: z.number(),
|
2022-04-01 15:53:52 +00:00
|
|
|
title: z.string(),
|
|
|
|
startTime: z.date(),
|
|
|
|
endTime: z.date(),
|
|
|
|
});
|
|
|
|
|
2022-04-27 17:25:36 +00:00
|
|
|
export const schemaBookingCreateBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingCreateParams);
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-27 17:25:36 +00:00
|
|
|
// @note: disallowing userId/eventTypeId changes in booking endpoint via PATCH for now as it would introduce side effects
|
|
|
|
const schemaBookingEditParams = z.object({
|
|
|
|
uid: z.string(),
|
|
|
|
title: z.string(),
|
|
|
|
startTime: z.date(),
|
|
|
|
endTime: z.date(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const schemaBookingEditBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingEditParams);
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-27 17:25:36 +00:00
|
|
|
export const schemaBookingReadPublic = Booking.pick({
|
|
|
|
id: true,
|
|
|
|
userId: true,
|
|
|
|
eventTypeId: true,
|
|
|
|
uid: true,
|
|
|
|
title: true,
|
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
2022-03-26 21:29:30 +00:00
|
|
|
});
|