Scheduling infrastructure for absolutely everyone.
fix: removes daily-event-reference endpoints and types
Agusti Fernandez Pardo3caee6c697b1
diff --git a/lib/types.ts b/lib/types.tsindex b5d9ac46635..db806fa3aa8 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -1,4 +1,4 @@-import { AppStoreLocationType, DefaultLocationType } from "@calcom/app-store/locations";+import { AppStoreLocationType, DefaultEventLocationType } from "@calcom/app-store/locations";import {User,Team,@@ -9,7 +9,6 @@ import {Availability,BookingReference,Booking,- DailyEventReference,Webhook,DestinationCalendar,Membership,@@ -93,14 +92,6 @@ export type CredentialsResponse = BaseResponse & {credentials?: Partial<Credential>[];};-// DailyEventReference-export type DailyEventReferenceResponse = BaseResponse & {- daily_event_reference?: Partial<DailyEventReference>;-};-export type DailyEventReferencesResponse = BaseResponse & {- daily_event_references?: Partial<DailyEventReference>[];-};-// DestinationCalendarexport type DestinationCalendarResponse = BaseResponse & {destination_calendar?: Partial<DestinationCalendar>;@@ -148,9 +139,11 @@ interface EventTypeExtended extends Omit<EventType, "recurringEvent" | "locationlink?: string | undefined;address?: string | undefined;hostPhoneNumber?: string | undefined;- type: DefaultLocationType | AppStoreLocationType;+ type: DefaultEventLocationType | typeof AppStoreLocationType;}[]- | null;+ | null+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ | any;}// EventTypediff --git a/lib/utils/sendPayload.ts b/lib/utils/sendPayload.tsindex a6234a1d372..e8d29a2d6d5 100644--- a/lib/utils/sendPayload.ts+++ b/lib/utils/sendPayload.ts@@ -1,3 +1,4 @@+/* eslint-disable @typescript-eslint/no-explicit-any */import { Webhook } from "@prisma/client";import { compile } from "handlebars";diff --git a/lib/validations/event-reference.ts b/lib/validations/event-reference.tsdeleted file mode 100644index 0ce79e63246..00000000000--- a/lib/validations/event-reference.ts+++ /dev/null@@ -1,38 +0,0 @@-import { z } from "zod";--import { _DailyEventReferenceModel as DailyEventReference } from "@calcom/prisma/zod";--export const schemaDailyEventReferenceBaseBodyParams = DailyEventReference.pick({- dailytoken: true,- dailyurl: true,- bookingId: true,-}).partial();--const schemaDailyEventReferenceCreateParams = z- .object({- dailytoken: z.string(),- dailyurl: z.string(),- bookingId: z.number(),- })- .strict();--export const schemaDailyEventReferenceCreateBodyParams = schemaDailyEventReferenceBaseBodyParams.merge(- schemaDailyEventReferenceCreateParams-);--const schemaDailyEventReferenceEditParams = z- .object({- dailytoken: z.string().optional(),- dailyurl: z.string().optional(),- })- .strict();--export const schemaDailyEventReferenceEditBodyParams = schemaDailyEventReferenceBaseBodyParams.merge(- schemaDailyEventReferenceEditParams-);-export const schemaDailyEventReferenceReadPublic = DailyEventReference.pick({- id: true,- dailytoken: true,- dailyurl: true,- bookingId: true,-});diff --git a/lib/validations/event-type.ts b/lib/validations/event-type.tsindex b67f13fa6a7..16065e668c6 100644--- a/lib/validations/event-type.ts+++ b/lib/validations/event-type.ts@@ -1,6 +1,5 @@import { z } from "zod";-import { AppStoreLocationType, DefaultLocationType } from "@calcom/app-store/locations";import { _EventTypeModel as EventType } from "@calcom/prisma/zod";import { Frequency } from "@lib/types";@@ -110,7 +109,7 @@ export const schemaEventTypeReadPublic = EventType.pick({link: z.string().optional(),address: z.string().optional(),hostPhoneNumber: z.string().optional(),- type: z.nativeEnum(DefaultLocationType).or(z.nativeEnum(AppStoreLocationType)),+ type: z.any().optional(),})).nullable(),diff --git a/lib/validations/user.ts b/lib/validations/user.tsindex 15a66ed3717..20114014395 100644--- a/lib/validations/user.ts+++ b/lib/validations/user.ts@@ -4,8 +4,6 @@ import { _UserModel as User } from "@calcom/prisma/zod";import { timeZone } from "@lib/validations/shared/timeZone";-import { jsonSchema } from "./shared/jsonSchema";-// @note: These are the ONLY values allowed as weekStart. So user don't introduce bad data.enum weekdays {MONDAY = "Monday",diff --git a/pages/api/event-references/[id].ts b/pages/api/event-references/[id].tsdeleted file mode 100644index 58bc27599d1..00000000000--- a/pages/api/event-references/[id].ts+++ /dev/null@@ -1,164 +0,0 @@-import type { NextApiRequest, NextApiResponse } from "next";--import { withMiddleware } from "@lib/helpers/withMiddleware";-import type { DailyEventReferenceResponse } from "@lib/types";-import {- schemaDailyEventReferenceEditBodyParams,- schemaDailyEventReferenceReadPublic,-} from "@lib/validations/event-reference";-import {- schemaQueryIdParseInt,- withValidQueryIdTransformParseInt,-} from "@lib/validations/shared/queryIdTransformParseInt";--export async function dailyEventReferenceById(- { method, query, body, userId, prisma }: NextApiRequest,- res: NextApiResponse<DailyEventReferenceResponse>-) {- const safeQuery = schemaQueryIdParseInt.safeParse(query);- const safeBody = schemaDailyEventReferenceEditBodyParams.safeParse(body);- if (!safeQuery.success) {- res.status(400).json({ message: "Your query was invalid" });- return;- }- const userBookings = await prisma.booking.findMany({ where: { userId } });- const userBookingIds: number[] = userBookings.map((booking) => booking.id);- const userBookingDailyEventReferences = await prisma.dailyEventReference.findMany({- where: { bookingId: { in: userBookingIds } },- });- const userBookingDailyEventReferenceIds = userBookingDailyEventReferences.map(- (dailyEventReference) => dailyEventReference.id- );- if (!userBookingDailyEventReferenceIds.includes(safeQuery.data.id))- res.status(401).json({ message: "Unauthorized" });- else {- switch (method) {- /**- * @swagger- * /event-references/{id}:- * get:- * summary: Find a event reference- * operationId: getEventReferenceById- * parameters:- * - in: path- * name: id- * schema:- * type: integer- * required: true- * description: ID of the event reference to get- * tags:- * - event-references- * responses:- * 200:- * description: OK- * 401:- * description: Authorization information is missing or invalid.- * 404:- * description: EventReference was not found- */- case "GET":- await prisma.dailyEventReference- .findUnique({ where: { id: safeQuery.data.id } })- .then((data) => schemaDailyEventReferenceReadPublic.parse(data))- .then((daily_event_reference) => res.status(200).json({ daily_event_reference }))- .catch((error: Error) =>- res.status(404).json({- message: `DailyEventReference with id: ${safeQuery.data.id} not found`,- error,- })- );- break;-- /**- * @swagger- * /event-references/{id}:- * patch:- * summary: Edit an existing event reference- * operationId: editEventReferenceById- * parameters:- * - in: path- * name: id- * schema:- * type: integer- * required: true- * description: ID of the event reference to edit- * tags:- * - event-references- * responses:- * 201:- * description: OK, EventReference edited successfuly- * 400:- * description: Bad request. EventReference body is invalid.- * 401:- * description: Authorization information is missing or invalid.- */- case "PATCH":- if (!safeBody.success) {- {- res.status(400).json({ message: "Invalid request body" });- return;- }- }- await prisma.dailyEventReference- .update({ where: { id: safeQuery.data.id }, data: safeBody.data })- .then((data) => schemaDailyEventReferenceReadPublic.parse(data))- .then((daily_event_reference) => res.status(200).json({ daily_event_reference }))- .catch((error: Error) =>- res.status(404).json({- message: `DailyEventReference with id: ${safeQuery.data.id} not found`,- error,- })- );- break;-- /**- * @swagger- * /event-references/{id}:- * delete:- * summary: Remove an existing event reference- * operationId: removeEventReferenceById- * parameters:- * - in: path- * name: id- * schema:- * type: integer- * required: true- * description: ID of the event reference to delete- * tags:- * - event-references- * responses:- * 201:- * description: OK, EventReference removed successfuly- * 400:- * description: Bad request. EventReference id is invalid.- * 401:- * description: Authorization information is missing or invalid.- */- case "DELETE":- await prisma.dailyEventReference- .delete({- where: { id: safeQuery.data.id },- })- .then(() =>- res.status(200).json({- message: `DailyEventReference with id: ${safeQuery.data.id} deleted`,- })- )- .catch((error: Error) =>- res.status(404).json({- message: `DailyEventReference with id: ${safeQuery.data.id} not found`,- error,- })- );- break;-- default:- res.status(405).json({ message: "Method not allowed" });- break;- }- }-}--export default withMiddleware("HTTP_GET_DELETE_PATCH")(- withValidQueryIdTransformParseInt(dailyEventReferenceById)-);diff --git a/pages/api/event-references/index.ts b/pages/api/event-references/index.tsdeleted file mode 100644index 449737cd064..00000000000--- a/pages/api/event-references/index.ts+++ /dev/null@@ -1,84 +0,0 @@-import type { NextApiRequest, NextApiResponse } from "next";--import { withMiddleware } from "@lib/helpers/withMiddleware";-import { DailyEventReferenceResponse, DailyEventReferencesResponse } from "@lib/types";-import {- schemaDailyEventReferenceCreateBodyParams,- schemaDailyEventReferenceReadPublic,-} from "@lib/validations/event-reference";--async function createOrlistAllDailyEventReferences(- { method, body, userId, prisma }: NextApiRequest,- res: NextApiResponse<DailyEventReferencesResponse | DailyEventReferenceResponse>-) {- const userBookings = await prisma.booking.findMany({ where: { userId } });- const userBookingIds = userBookings.map((booking) => booking.id);-- if (method === "GET") {- /**- * @swagger- * /event-references:- * get:- * summary: Find all event reference- * operationId: listEventReferences- * tags:- * - event-references- * responses:- * 200:- * description: OK- * 401:- * description: Authorization information is missing or invalid.- * 404:- * description: No event references were found- */- const data = await prisma.dailyEventReference.findMany({- where: { bookingId: { in: userBookingIds } },- });- const daily_event_references = data.map((dailyEventReference) =>- schemaDailyEventReferenceReadPublic.parse(dailyEventReference)- );- if (daily_event_references) res.status(200).json({ daily_event_references });- else- (error: Error) =>- res.status(404).json({- message: "No DailyEventReferences were found",- error,- });- } else if (method === "POST") {- /**- * @swagger- * /event-references:- * post:- * summary: Creates a new event reference- * operationId: addEventReference- * tags:- * - event-references- * responses:- * 201:- * description: OK, event reference created- * 400:- * description: Bad request. DailyEventReference body is invalid.- * 401:- * description: Authorization information is missing or invalid.- */- const safe = schemaDailyEventReferenceCreateBodyParams.safeParse(body);- if (!safe.success) {- res.status(400).json({ message: "Invalid request body" });- return;- }-- const data = await prisma.dailyEventReference.create({ data: safe.data });- const daily_event_reference = schemaDailyEventReferenceReadPublic.parse(data);-- if (daily_event_reference)- res.status(201).json({ daily_event_reference, message: "DailyEventReference created successfully" });- else- (error: Error) =>- res.status(400).json({- message: "Could not create new event reference",- error,- });- } else res.status(405).json({ message: `Method ${method} not allowed` });-}--export default withMiddleware("HTTP_GET_OR_POST")(createOrlistAllDailyEventReferences);