2022-04-01 15:53:52 +00:00
|
|
|
import { z } from "zod";
|
2022-03-26 21:29:30 +00:00
|
|
|
|
2023-05-31 12:35:30 +00:00
|
|
|
import { _BookingModel as Booking, _AttendeeModel, _UserModel, _PaymentModel } 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,
|
2023-03-03 20:20:27 +00:00
|
|
|
status: true,
|
2022-04-27 17:25:36 +00:00
|
|
|
}).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(),
|
2023-04-18 13:47:29 +00:00
|
|
|
// Not supporting responses in edit as that might require re-triggering emails
|
|
|
|
// responses
|
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(),
|
2023-05-31 12:35:30 +00:00
|
|
|
payment: z
|
|
|
|
.array(
|
|
|
|
_PaymentModel.pick({
|
|
|
|
id: true,
|
|
|
|
success: true,
|
|
|
|
paymentOption: true,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.optional(),
|
2023-10-10 21:27:16 +00:00
|
|
|
responses: z.record(z.any()).nullable(),
|
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,
|
2023-05-31 12:35:30 +00:00
|
|
|
payment: true,
|
2022-10-19 16:03:54 +00:00
|
|
|
metadata: true,
|
2022-10-21 13:04:20 +00:00
|
|
|
status: true,
|
2023-04-18 13:47:29 +00:00
|
|
|
responses: true,
|
2022-03-26 21:29:30 +00:00
|
|
|
});
|