2022-04-01 15:53:52 +00:00
|
|
|
import { z } from "zod";
|
2022-03-26 21:29:30 +00:00
|
|
|
|
2022-10-19 16:03:54 +00:00
|
|
|
import { _BookingModel as Booking, _AttendeeModel, _UserModel } from "@calcom/prisma/zod";
|
2022-10-20 17:26:43 +00:00
|
|
|
import { extendedBookingCreateBody, iso8601 } from "@calcom/prisma/zod-utils";
|
2022-10-13 18:29:30 +00:00
|
|
|
|
|
|
|
import { schemaQueryUserId } from "./shared/queryUserId";
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-27 17:25:36 +00:00
|
|
|
const schemaBookingBaseBodyParams = Booking.pick({
|
2022-10-13 18:29:30 +00:00
|
|
|
uid: true,
|
2022-04-27 17:25:36 +00:00
|
|
|
userId: true,
|
|
|
|
eventTypeId: true,
|
|
|
|
title: true,
|
2022-10-14 17:42:05 +00:00
|
|
|
description: true,
|
2022-04-27 17:25:36 +00:00
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
|
|
|
}).partial();
|
2022-04-01 21:03:03 +00:00
|
|
|
|
2022-10-13 18:29:30 +00:00
|
|
|
export const schemaBookingCreateBodyParams = extendedBookingCreateBody.merge(schemaQueryUserId.partial());
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-27 17:45:59 +00:00
|
|
|
const schemaBookingEditParams = z
|
|
|
|
.object({
|
|
|
|
title: z.string().optional(),
|
2022-10-20 17:26:43 +00:00
|
|
|
startTime: iso8601.optional(),
|
|
|
|
endTime: iso8601.optional(),
|
2022-04-27 17:45:59 +00:00
|
|
|
})
|
|
|
|
.strict();
|
2022-04-27 17:25:36 +00:00
|
|
|
|
|
|
|
export const schemaBookingEditBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingEditParams);
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-10-19 16:03:54 +00:00
|
|
|
export const schemaBookingReadPublic = Booking.extend({
|
2022-10-20 17:26:43 +00:00
|
|
|
attendees: z
|
|
|
|
.array(
|
|
|
|
_AttendeeModel.pick({
|
|
|
|
email: true,
|
|
|
|
name: true,
|
|
|
|
timeZone: true,
|
|
|
|
locale: true,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.optional(),
|
|
|
|
user: _UserModel
|
|
|
|
.pick({
|
2022-10-19 16:03:54 +00:00
|
|
|
email: true,
|
|
|
|
name: true,
|
|
|
|
timeZone: true,
|
|
|
|
locale: true,
|
|
|
|
})
|
2022-10-20 17:26:43 +00:00
|
|
|
.optional(),
|
2022-10-19 16:03:54 +00:00
|
|
|
}).pick({
|
2022-04-27 17:25:36 +00:00
|
|
|
id: true,
|
|
|
|
userId: true,
|
2022-10-14 21:52:17 +00:00
|
|
|
description: true,
|
2022-04-27 17:25:36 +00:00
|
|
|
eventTypeId: true,
|
|
|
|
uid: true,
|
|
|
|
title: true,
|
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
2022-10-19 16:03:54 +00:00
|
|
|
timeZone: true,
|
|
|
|
attendees: true,
|
|
|
|
user: true,
|
|
|
|
metadata: true,
|
2022-03-26 21:29:30 +00:00
|
|
|
});
|