2022-04-01 23:55:41 +00:00
|
|
|
import { z } from "zod";
|
2022-03-26 23:58:22 +00:00
|
|
|
|
2022-10-06 18:38:17 +00:00
|
|
|
import { _ScheduleModel as Schedule, _AvailabilityModel as Availability } from "@calcom/prisma/zod";
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-04-01 23:55:41 +00:00
|
|
|
const schemaScheduleBaseBodyParams = Schedule.omit({ id: true }).partial();
|
|
|
|
|
|
|
|
const schemaScheduleRequiredParams = z.object({
|
2022-10-06 18:38:17 +00:00
|
|
|
name: z.string().optional(),
|
|
|
|
userId: z.union([z.number(), z.array(z.number())]).optional(),
|
2022-04-01 23:55:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export const schemaScheduleBodyParams = schemaScheduleBaseBodyParams.merge(schemaScheduleRequiredParams);
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-10-06 19:06:07 +00:00
|
|
|
export const schemaSingleScheduleBodyParams = schemaScheduleBaseBodyParams.merge(
|
|
|
|
z.object({ userId: z.number().optional() })
|
|
|
|
);
|
|
|
|
|
|
|
|
export const schemaCreateScheduleBodyParams = schemaScheduleBaseBodyParams.merge(
|
|
|
|
z.object({ userId: z.number().optional(), name: z.string() })
|
|
|
|
);
|
|
|
|
|
2022-10-05 15:04:58 +00:00
|
|
|
export const schemaSchedulePublic = z
|
|
|
|
.object({ id: z.number() })
|
|
|
|
.merge(Schedule)
|
|
|
|
.merge(
|
|
|
|
z.object({
|
2022-10-06 18:38:17 +00:00
|
|
|
availability: z
|
|
|
|
.array(Availability.pick({ id: true, eventTypeId: true, days: true, startTime: true, endTime: true }))
|
|
|
|
.optional(),
|
2022-10-05 15:04:58 +00:00
|
|
|
})
|
|
|
|
);
|