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:45:59 +00:00
|
|
|
const schemaBookingCreateParams = z
|
|
|
|
.object({
|
|
|
|
uid: z.string(),
|
|
|
|
userId: z.number(),
|
|
|
|
eventTypeId: z.number(),
|
|
|
|
title: z.string(),
|
|
|
|
startTime: z.date(),
|
|
|
|
endTime: z.date(),
|
|
|
|
})
|
|
|
|
.strict();
|
2022-04-01 15:53:52 +00:00
|
|
|
|
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:45:59 +00:00
|
|
|
const schemaBookingEditParams = z
|
|
|
|
.object({
|
|
|
|
uid: z.string().optional(),
|
|
|
|
title: z.string().optional(),
|
|
|
|
startTime: z.date().optional(),
|
|
|
|
endTime: z.date().optional(),
|
|
|
|
})
|
|
|
|
.strict();
|
2022-04-27 17:25:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
});
|