fix: post / patch attendees docs w examples
This commit is contained in:
1 parent
14e2964a6d
commit
e52af0bbef
55 files changed
+246
-233
No files matched your search
+19
-12
@@ -1,8 +1,9 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _AttendeeModel as Attendee } from "@calcom/prisma/zod";
|
||||
|
||||
import { timeZone } from "@lib/validations/shared/timeZone";
|
||||
|
||||
export const schemaAttendeeBaseBodyParams = Attendee.pick({
|
||||
bookingId: true,
|
||||
email: true,
|
||||
@@ -10,22 +11,28 @@ export const schemaAttendeeBaseBodyParams = Attendee.pick({
|
||||
timeZone: true,
|
||||
}).partial();
|
||||
|
||||
const schemaAttendeeCreateParams = z.object({
|
||||
bookingId: z.any(),
|
||||
email: z.string().email(),
|
||||
name: z.string(),
|
||||
timeZone: z.string(),
|
||||
});
|
||||
const schemaAttendeeCreateParams = z
|
||||
.object({
|
||||
bookingId: z.number().int(),
|
||||
email: z.string().email(),
|
||||
name: z.string(),
|
||||
timeZone: timeZone,
|
||||
})
|
||||
.strict();
|
||||
|
||||
const schemaAttendeeEditParams = z.object({
|
||||
// @note: disallowing email/bookingId changes in attendee via API for now as it would introduce side effects
|
||||
name: z.string(),
|
||||
timeZone: z.string(),
|
||||
});
|
||||
const schemaAttendeeEditParams = z
|
||||
.object({
|
||||
// @note: disallowing bookingId changes in attendee via API for now as it would introduce side effects
|
||||
name: z.string().optional(),
|
||||
email: z.string().email().optional(),
|
||||
timeZone: timeZone.optional(),
|
||||
})
|
||||
.strict();
|
||||
export const schemaAttendeeEditBodyParams = schemaAttendeeBaseBodyParams.merge(schemaAttendeeEditParams);
|
||||
export const schemaAttendeeCreateBodyParams = schemaAttendeeBaseBodyParams.merge(schemaAttendeeCreateParams);
|
||||
|
||||
export const schemaAttendeeReadPublic = Attendee.pick({
|
||||
id: true,
|
||||
bookingId: true,
|
||||
name: true,
|
||||
email: true,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _AvailabilityModel as Availability } from "@calcom/prisma/zod";
|
||||
@@ -12,6 +11,7 @@ export const schemaAvailabilityBaseBodyParams = Availability.pick({
|
||||
}).partial();
|
||||
|
||||
export const schemaAvailabilityReadPublic = Availability.pick({
|
||||
id: true,
|
||||
startTime: true,
|
||||
endTime: true,
|
||||
date: true,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _BookingReferenceModel as BookingReference } from "@calcom/prisma/zod";
|
||||
@@ -14,6 +13,7 @@ export const schemaBookingReferenceBaseBodyParams = BookingReference.pick({
|
||||
}).partial();
|
||||
|
||||
export const schemaBookingReferenceReadPublic = BookingReference.pick({
|
||||
id: true,
|
||||
type: true,
|
||||
bookingId: true,
|
||||
uid: true,
|
||||
|
||||
+30
-10
@@ -1,23 +1,43 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _BookingModel as Booking } from "@calcom/prisma/zod";
|
||||
|
||||
const schemaBookingBaseBodyParams = Booking.omit({ id: true }).partial();
|
||||
const schemaBookingBaseBodyParams = Booking.pick({
|
||||
uid: true,
|
||||
userId: true,
|
||||
eventTypeId: true,
|
||||
title: true,
|
||||
startTime: true,
|
||||
endTime: true,
|
||||
}).partial();
|
||||
|
||||
const schemaBookingRequiredParams = z.object({
|
||||
const schemaBookingCreateParams = z.object({
|
||||
uid: z.string(),
|
||||
userId: z.number(),
|
||||
eventTypeId: z.number(),
|
||||
title: z.string(),
|
||||
startTime: z.date(),
|
||||
endTime: z.date(),
|
||||
});
|
||||
|
||||
export const schemaBookingCreateBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingCreateParams);
|
||||
|
||||
// @note: disallowing userId/eventTypeId changes in booking endpoint via PATCH for now as it would introduce side effects
|
||||
const schemaBookingEditParams = z.object({
|
||||
uid: z.string(),
|
||||
title: z.string(),
|
||||
startTime: z.date(),
|
||||
endTime: z.date(),
|
||||
});
|
||||
|
||||
export const schemaBookingBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingRequiredParams);
|
||||
export const schemaBookingEditBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingEditParams);
|
||||
|
||||
export const schemaBookingPublic = Booking.omit({});
|
||||
|
||||
export const withValidBooking = withValidation({
|
||||
schema: schemaBookingBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
export const schemaBookingReadPublic = Booking.pick({
|
||||
id: true,
|
||||
userId: true,
|
||||
eventTypeId: true,
|
||||
uid: true,
|
||||
title: true,
|
||||
startTime: true,
|
||||
endTime: true,
|
||||
});
|
||||
@@ -1,25 +0,0 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _CredentialModel as Credential } from "@calcom/prisma/zod";
|
||||
|
||||
import { jsonSchema } from "./shared/jsonSchema";
|
||||
|
||||
const schemaCredentialBaseBodyParams = Credential.omit({ id: true, userId: true }).partial();
|
||||
|
||||
const schemaCredentialRequiredParams = z.object({
|
||||
type: z.string(),
|
||||
key: jsonSchema,
|
||||
});
|
||||
|
||||
export const schemaCredentialBodyParams = schemaCredentialBaseBodyParams.merge(
|
||||
schemaCredentialRequiredParams
|
||||
);
|
||||
|
||||
export const schemaCredentialPublic = Credential.omit({});
|
||||
|
||||
export const withValidCredential = withValidation({
|
||||
schema: schemaCredentialBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,22 +1,35 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _DailyEventReferenceModel as DailyEventReference } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaDailyEventReferenceBaseBodyParams = DailyEventReference.omit({ id: true });
|
||||
export const schemaDailyEventReferenceBaseBodyParams = DailyEventReference.pick({
|
||||
dailytoken: true,
|
||||
dailyurl: true,
|
||||
bookingId: true,
|
||||
}).partial();
|
||||
|
||||
const schemaDailyEventReferenceRequiredParams = z.object({
|
||||
email: z.string().email(),
|
||||
const schemaDailyEventReferenceCreateParams = z.object({
|
||||
dailytoken: z.string(),
|
||||
dailyurl: z.string(),
|
||||
bookingId: z.number(),
|
||||
});
|
||||
|
||||
export const schemaDailyEventReferenceBodyParams = schemaDailyEventReferenceBaseBodyParams.merge(
|
||||
schemaDailyEventReferenceRequiredParams
|
||||
export const schemaDailyEventReferenceCreateBodyParams = schemaDailyEventReferenceBaseBodyParams.merge(
|
||||
schemaDailyEventReferenceCreateParams
|
||||
);
|
||||
|
||||
export const schemaDailyEventReferencePublic = DailyEventReference.omit({});
|
||||
const schemaDailyEventReferenceEditParams = z.object({
|
||||
dailytoken: z.string(),
|
||||
dailyurl: z.string(),
|
||||
// @note: disallowing bookingId changes in daily-event-reference via API endpoint for now as it would introduce side effects
|
||||
});
|
||||
|
||||
export const withValidDailyEventReference = withValidation({
|
||||
schema: schemaDailyEventReferenceBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
export const schemaDailyEventReferenceEditBodyParams = schemaDailyEventReferenceBaseBodyParams.merge(
|
||||
schemaDailyEventReferenceEditParams
|
||||
);
|
||||
export const schemaDailyEventReferenceReadPublic = DailyEventReference.pick({
|
||||
id: true,
|
||||
dailytoken: true,
|
||||
dailyurl: true,
|
||||
bookingId: true,
|
||||
});
|
||||
@@ -1,23 +1,43 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _DestinationCalendarModel as DestinationCalendar } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaDestinationCalendarBaseBodyParams = DestinationCalendar.omit({ id: true }).partial();
|
||||
export const schemaDestinationCalendarBaseBodyParams = DestinationCalendar.pick({
|
||||
integration: true,
|
||||
externalId: true,
|
||||
eventTypeId: true,
|
||||
bookingId: true,
|
||||
userId: true,
|
||||
}).partial();
|
||||
|
||||
const schemaDestinationCalendarRequiredParams = z.object({
|
||||
const schemaDestinationCalendarEditParams = z.object({
|
||||
integration: z.string(),
|
||||
externalId: z.string(),
|
||||
eventTypeId: z.number(),
|
||||
bookingId: z.number(),
|
||||
userId: z.number(),
|
||||
});
|
||||
|
||||
export const schemaDestinationCalendarBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
|
||||
schemaDestinationCalendarRequiredParams
|
||||
export const schemaDestinationCalendarEditBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
|
||||
schemaDestinationCalendarEditParams
|
||||
);
|
||||
const schemaDestinationCalendarCreateParams = z.object({
|
||||
integration: z.string(),
|
||||
externalId: z.string(),
|
||||
eventTypeId: z.number(),
|
||||
bookingId: z.number(),
|
||||
userId: z.number(),
|
||||
});
|
||||
|
||||
export const schemaDestinationCalendarCreateBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
|
||||
schemaDestinationCalendarCreateParams
|
||||
);
|
||||
|
||||
export const schemaDestinationCalendarPublic = DestinationCalendar.omit({});
|
||||
|
||||
export const withValidDestinationCalendar = withValidation({
|
||||
schema: schemaDestinationCalendarBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
export const schemaDestinationCalendarReadPublic = DestinationCalendar.pick({
|
||||
id: true,
|
||||
integration: true,
|
||||
externalId: true,
|
||||
eventTypeId: true,
|
||||
bookingId: true,
|
||||
userId: true,
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _EventTypeCustomInputModel as EventTypeCustomInput } from "@calcom/prisma/zod";
|
||||
@@ -17,8 +16,6 @@ const schemaEventTypeCustomInputRequiredParams = z.object({
|
||||
eventType: z.object({
|
||||
connect: z.object({
|
||||
id: z.number().optional(),
|
||||
// username: z.string().optional(),
|
||||
// email: z.string().optional(),
|
||||
}),
|
||||
// FIXME: Provide valid EventTypeModel schema here, but not sure how yet.
|
||||
create: z.any(),
|
||||
@@ -28,9 +25,3 @@ const schemaEventTypeCustomInputRequiredParams = z.object({
|
||||
export const schemaEventTypeCustomInputBodyParams = schemaEventTypeCustomInputBaseBodyParams.merge(
|
||||
schemaEventTypeCustomInputRequiredParams
|
||||
);
|
||||
|
||||
export const withValidEventTypeCustomInput = withValidation({
|
||||
schema: schemaEventTypeCustomInputBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _EventTypeModel as EventType } from "@calcom/prisma/zod";
|
||||
@@ -14,9 +13,3 @@ const schemaEventTypeRequiredParams = z.object({
|
||||
export const schemaEventTypeBodyParams = schemaEventTypeBaseBodyParams.merge(schemaEventTypeRequiredParams);
|
||||
// @NOTE: Removing locations and metadata properties before validation, add them later if required
|
||||
export const schemaEventTypePublic = EventType.omit({ locations: true, metadata: true });
|
||||
|
||||
export const withValidEventType = withValidation({
|
||||
schema: schemaEventTypeBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _MembershipModel as Membership } from "@calcom/prisma/zod";
|
||||
@@ -13,9 +12,3 @@ export const schemaMembershipBodyParams = schemaMembershipBaseBodyParams.merge(
|
||||
);
|
||||
|
||||
export const schemaMembershipPublic = Membership.omit({});
|
||||
|
||||
export const withValidMembership = withValidation({
|
||||
schema: schemaMembershipBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,13 +1,5 @@
|
||||
import { withValidation } from "next-validations";
|
||||
|
||||
import { _PaymentModel as Payment } from "@calcom/prisma/zod";
|
||||
|
||||
// FIXME: Payment seems a delicate endpoint, do we need to remove anything here?
|
||||
export const schemaPaymentBodyParams = Payment.omit({ id: true });
|
||||
export const schemaPaymentPublic = Payment.omit({ externalId: true });
|
||||
|
||||
export const withValidPayment = withValidation({
|
||||
schema: schemaPaymentBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _ReminderMailModel as ReminderMail } from "@calcom/prisma/zod";
|
||||
@@ -16,9 +15,3 @@ const schemaReminderMailRequiredParams = z.object({
|
||||
export const schemaReminderMailBodyParams = schemaReminderMailBaseBodyParams.merge(
|
||||
schemaReminderMailRequiredParams
|
||||
);
|
||||
|
||||
export const withValidReminderMail = withValidation({
|
||||
schema: schemaReminderMailBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _ScheduleModel as Schedule } from "@calcom/prisma/zod";
|
||||
@@ -13,9 +12,3 @@ const schemaScheduleRequiredParams = z.object({
|
||||
export const schemaScheduleBodyParams = schemaScheduleBaseBodyParams.merge(schemaScheduleRequiredParams);
|
||||
|
||||
export const schemaSchedulePublic = Schedule.omit({});
|
||||
|
||||
export const withValidSchedule = withValidation({
|
||||
schema: schemaScheduleBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _SelectedCalendarModel as SelectedCalendar } from "@calcom/prisma/zod";
|
||||
@@ -24,9 +23,3 @@ const schemaSelectedCalendarRequiredParams = z.object({
|
||||
export const schemaSelectedCalendarBodyParams = schemaSelectedCalendarBaseBodyParams.merge(
|
||||
schemaSelectedCalendarRequiredParams
|
||||
);
|
||||
|
||||
export const withValidSelectedCalendar = withValidation({
|
||||
schema: schemaSelectedCalendarBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import * as tzdb from "tzdata";
|
||||
import * as z from "zod";
|
||||
|
||||
// @note: This is a custom validation that checks if the timezone is valid and exists in the tzdb library
|
||||
export const timeZone = z.string().refine((tz: string) => Object.keys(tzdb.zones).includes(tz));
|
||||
@@ -1,4 +1,3 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _TeamModel as Team } from "@calcom/prisma/zod";
|
||||
@@ -10,9 +9,3 @@ const schemaTeamRequiredParams = z.object({});
|
||||
export const schemaTeamBodyParams = schemaTeamBaseBodyParams.merge(schemaTeamRequiredParams);
|
||||
|
||||
export const schemaTeamPublic = Team.omit({});
|
||||
|
||||
export const withValidTeam = withValidation({
|
||||
schema: schemaTeamBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
@@ -1,9 +1,9 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import * as tzdb from "tzdata";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _UserModel as User } from "@calcom/prisma/zod";
|
||||
|
||||
import { timeZone } from "@lib/validations/shared/timeZone";
|
||||
|
||||
// @note: These are the ONLY values allowed as weekStart. So user don't introduce bad data.
|
||||
enum weekdays {
|
||||
MONDAY = "Monday",
|
||||
@@ -77,11 +77,7 @@ export const schemaUserBaseBodyParams = User.pick({
|
||||
const schemaUserEditParams = z.object({
|
||||
weekStart: z.nativeEnum(weekdays).optional(),
|
||||
brandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
||||
timeZone: z
|
||||
.string()
|
||||
// @note: This is a custom validation that checks if the timezone is valid and exists in the tzdb library
|
||||
.refine((tz: string) => Object.keys(tzdb.zones).includes(tz))
|
||||
.optional(),
|
||||
timeZone: timeZone.optional(),
|
||||
bufferTime: z.number().min(0).max(86400).optional(),
|
||||
startTime: z.number().min(0).max(86400).optional(),
|
||||
endTime: z.number().min(0).max(86400).optional(),
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import { withValidation } from "next-validations";
|
||||
|
||||
import { _WebhookModel as Webhook } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaWebhookBodyParams = Webhook.omit({ id: true }).partial();
|
||||
|
||||
export const schemaWebhookPublic = Webhook.omit({});
|
||||
|
||||
export const withValidWebhook = withValidation({
|
||||
schema: schemaWebhookBodyParams,
|
||||
type: "Zod",
|
||||
mode: "body",
|
||||
});
|
||||
Reference in new issue
Block a user