2022-04-01 20:04:42 +00:00
|
|
|
import { z } from "zod";
|
2022-03-26 23:58:22 +00:00
|
|
|
|
2022-03-30 15:37:51 +00:00
|
|
|
import { _AvailabilityModel as Availability } from "@calcom/prisma/zod";
|
2022-03-30 12:17:55 +00:00
|
|
|
|
2022-04-25 01:12:33 +00:00
|
|
|
export const schemaAvailabilityBaseBodyParams = Availability.pick({
|
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
|
|
|
date: true,
|
|
|
|
scheduleId: true,
|
|
|
|
days: true,
|
|
|
|
}).partial();
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-26 20:48:15 +00:00
|
|
|
export const schemaAvailabilityReadPublic = Availability.pick({
|
2022-04-27 17:25:36 +00:00
|
|
|
id: true,
|
2022-04-26 20:23:33 +00:00
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
|
|
|
date: true,
|
|
|
|
scheduleId: true,
|
|
|
|
days: true,
|
|
|
|
userId: true,
|
|
|
|
eventTypeId: true,
|
|
|
|
});
|
|
|
|
|
2022-04-27 17:45:59 +00:00
|
|
|
const schemaAvailabilityCreateParams = z
|
|
|
|
.object({
|
|
|
|
startTime: z.date().or(z.string()),
|
|
|
|
endTime: z.date().or(z.string()),
|
|
|
|
days: z.array(z.number()).optional(),
|
|
|
|
eventTypeId: z.number().optional(),
|
|
|
|
})
|
|
|
|
.strict();
|
|
|
|
|
|
|
|
const schemaAvailabilityEditParams = z
|
|
|
|
.object({
|
|
|
|
startTime: z.date().or(z.string()).optional(),
|
|
|
|
endTime: z.date().or(z.string()).optional(),
|
|
|
|
days: z.array(z.number()).optional(),
|
|
|
|
eventTypeId: z.number().optional(),
|
|
|
|
})
|
|
|
|
.strict();
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-26 20:23:33 +00:00
|
|
|
export const schemaAvailabilityEditBodyParams = schemaAvailabilityBaseBodyParams.merge(
|
|
|
|
schemaAvailabilityEditParams
|
|
|
|
);
|
|
|
|
export const schemaAvailabilityCreateBodyParams = schemaAvailabilityBaseBodyParams.merge(
|
|
|
|
schemaAvailabilityCreateParams
|
2022-04-01 20:04:42 +00:00
|
|
|
);
|