initail work on paid booking, improve validations
This commit is contained in:
@@ -2,7 +2,7 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _ApiKeyModel as ApiKey } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaApiKeyBodyParams = ApiKey.omit({ id: true, userId: true, createdAt: true });
|
||||
export const schemaApiKeyBodyParams = ApiKey.omit({ id: true, userId: true, createdAt: true }).partial();
|
||||
|
||||
export const schemaApiKeyPublic = ApiKey.omit({
|
||||
id: true,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _AttendeeModel as Attendee } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaAttendeeBodyParams = Attendee.omit({ id: true });
|
||||
export const schemaAttendeeBodyParams = Attendee.omit({ id: true }).partial();
|
||||
|
||||
export const schemaAttendeePublic = Attendee.omit({});
|
||||
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _BookingModel as Booking } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaBookingBodyParams = Booking.omit({ id: true });
|
||||
// Here we remove any parameters that are not needed for the API with omit.
|
||||
const schemaBookingBaseBodyParams = Booking.omit({ id: true }).partial();
|
||||
// Here we redeclare the required ones after removing the ones we don't need.
|
||||
// and making the rest optional with .partial()
|
||||
const schemaBookingRequiredParams = z.object({
|
||||
uid: z.string(),
|
||||
title: z.string(),
|
||||
startTime: z.date(),
|
||||
endTime: z.date(),
|
||||
});
|
||||
|
||||
export const schemaBookingBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingRequiredParams);
|
||||
|
||||
export const schemaBookingPublic = Booking.omit({});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _ScheduleModel as Schedule } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaScheduleBodyParams = Schedule.omit({ id: true });
|
||||
export const schemaScheduleBodyParams = Schedule.omit({ id: true }).partial();
|
||||
|
||||
export const schemaSchedulePublic = Schedule.omit({});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _SelectedCalendarModel as SelectedCalendar } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaSelectedCalendarBodyParams = SelectedCalendar.omit({});
|
||||
export const schemaSelectedCalendarBodyParams = SelectedCalendar.omit({}).partial();
|
||||
|
||||
export const schemaSelectedCalendarPublic = SelectedCalendar.omit({ userId: true });
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _TeamModel as Team } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaTeamBodyParams = Team.omit({ id: true });
|
||||
export const schemaTeamBodyParams = Team.omit({ id: true }).partial();
|
||||
|
||||
export const schemaTeamPublic = Team.omit({});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export const schemaUserBodyParams = User.omit({
|
||||
password: true,
|
||||
twoFactorEnabled: true,
|
||||
twoFactorSecret: true,
|
||||
});
|
||||
}).partial();
|
||||
|
||||
export const schemaUserPublic = User.omit({
|
||||
identityProvider: true,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _WebhookModel as Webhook } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaWebhookBodyParams = Webhook.omit({ id: true });
|
||||
export const schemaWebhookBodyParams = Webhook.omit({ id: true }).partial();
|
||||
|
||||
export const schemaWebhookPublic = Webhook.omit({});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user