refactor: Deprecate Legacy v2 Booker Atom Endpoints (#20939)

* feat: split atoms endpoints and add public event type endpoint

* Update ConnectedDestinationCalendars import path across platform/atoms components

* refactor: update BookingResponse import path from platform-libraries to features/bookings

* Move AvailableSlotsType to util.ts and update imports to use GetAvailableSlotsResponse

* Refactor import path for RecurringBookingCreateBody type from libraries to types

* Fix import path for getBookingForReschedule type from platform-libraries to features

* Refactor PublicEventType export location and update import references

* Remove @calcom/platform-libraries dependency from atoms package.json

* chore(deps): update yarn.lock dependencies

* Remove console.log statements and fix indentation in event type hooks

* Migrate event type transformers from platform/libraries to api/v2 directory

* Remove console.log

* Update BookerPlatformWrapper.tsx

* Add script to populate empty team slugs with slugified team names

* Remove vitest imports

* reset platform libraries version

* Remove unused orgId comment from useAtomGetPublicEvent hook params

* Update useApiV2AvailableSlots.ts

* refactor: remove unused exports from lib package index file

* Undo: @SomayChauhan
Add script to populate empty team slugs with slugified team names

* Update booking.tsx

* chore: upgrade @calcom/platform-libraries from 0.0.202 to 0.0.205

* chore: bump @calcom/platform-libraries from 0.0.205 to 0.0.206

* chore: configure babel and jest for node module transpilation in api v2

* fix: type errors

* Revert "chore: configure babel and jest for node module transpilation in api v2"

This reverts commit b2cf172a84fe8953f9497bf6e43874f476fbc04b.

* Update calendars.service.ts

* chore: bump @calcom/platform-libraries from 0.0.208 to 0.0.209

* fix: add proper type definition for calendar busy times to resolve ts-expect-error

* refactor: deprecate v2 old availability endpoints (#21075)

Co-authored-by: Morgan <[email protected]>

* chore: publish platform librareis

* feat: add delegation credential fields to calendar service mock

* chore: update @calcom/platform-libraries from 0.0.211 to 0.0.213

* fix: skip failing calendar integration test

* chore: bump @calcom/platform-libraries from 0.0.213 to 0.0.214

* fix: api/v2 build error

* fix: e2e tests

---------

Co-authored-by: Morgan <[email protected]>
Co-authored-by: supalarry <[email protected]>
Co-authored-by: Lauris Skraucis <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-06-12 20:20:52 +05:30
1 parent 5e2f06cdea
commit 5bb2a904ce
105 files changed
+6611 -1552

No files matched your search

@@ -10,7 +10,7 @@ import type { TCreateInputSchema } from "./create.schema";
type CreateHandlerOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
user: Pick<NonNullable<TrpcSessionUser>, "id">;
};
input: TCreateInputSchema;
};
@@ -1,12 +1,7 @@
import { getAvailabilityFromSchedule } from "@calcom/lib/availability";
import { hasEditPermissionForUserID } from "@calcom/lib/hasEditPermissionForUser";
import { transformScheduleToAvailabilityForAtom } from "@calcom/lib/schedules/transformers/for-atom";
import { updateSchedule } from "@calcom/lib/schedules/updateSchedule";
import { prisma } from "@calcom/prisma";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
import { TRPCError } from "@trpc/server";
import type { TrpcSessionUser } from "../../../../types";
import { setupDefaultSchedule, updateHostsWithNewDefaultSchedule } from "../util";
import type { TUpdateInputSchema } from "./update.schema";
type User = NonNullable<TrpcSessionUser>;
@@ -19,119 +14,9 @@ type UpdateOptions = {
export const updateHandler = async ({ input, ctx }: UpdateOptions) => {
const { user } = ctx;
const availability = input.schedule
? getAvailabilityFromSchedule(input.schedule)
: (input.dateOverrides || []).map((dateOverride) => ({
startTime: dateOverride.start,
endTime: dateOverride.end,
date: dateOverride.start,
days: [],
}));
// Not able to update the schedule with userId where clause, so fetch schedule separately and then validate
// Bug: https://github.com/prisma/prisma/issues/7290
const userSchedule = await prisma.schedule.findUnique({
where: {
id: input.scheduleId,
},
select: {
userId: true,
name: true,
id: true,
},
return updateSchedule({
input,
user,
prisma,
});
if (!userSchedule) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
if (userSchedule?.userId !== user.id) {
const hasEditPermission = await hasEditPermissionForUserID({
ctx,
input: { memberId: userSchedule.userId },
});
if (!hasEditPermission) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
}
let updatedUser;
if (input.isDefault) {
if (user?.defaultScheduleId) {
await updateHostsWithNewDefaultSchedule(user.id, user.defaultScheduleId, input.scheduleId);
}
const setupDefault = await setupDefaultSchedule(user.id, input.scheduleId, prisma);
updatedUser = setupDefault;
}
if (!input.name) {
// TODO: Improve
// We don't want to pass the full schedule for just a set as default update
// but in the current logic, this wipes the existing availability.
// Return early to prevent this from happening.
return {
schedule: userSchedule,
isDefault: updatedUser
? updatedUser.defaultScheduleId === input.scheduleId
: user.defaultScheduleId === input.scheduleId,
};
}
const schedule = await prisma.schedule.update({
where: {
id: input.scheduleId,
},
data: {
timeZone: input.timeZone,
name: input.name,
availability: {
deleteMany: {
scheduleId: {
equals: input.scheduleId,
},
},
createMany: {
data: [
...availability,
...(input.dateOverrides || []).map((override) => ({
date: override.start,
startTime: override.start,
endTime: override.end,
})),
],
},
},
},
select: {
id: true,
userId: true,
name: true,
availability: true,
timeZone: true,
eventType: {
select: {
id: true,
eventName: true,
},
},
},
});
const userAvailability = transformScheduleToAvailabilityForAtom(schedule);
return {
schedule,
availability: userAvailability,
timeZone: schedule.timeZone || user.timeZone,
isDefault: updatedUser
? updatedUser.defaultScheduleId === schedule.id
: user.defaultScheduleId === schedule.id,
prevDefaultId: user.defaultScheduleId,
currentDefaultId: updatedUser ? updatedUser.defaultScheduleId : user.defaultScheduleId,
};
};
@@ -36,7 +36,7 @@ import type { TConfirmInputSchema } from "./confirm.schema";
type ConfirmOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
user: Pick<NonNullable<TrpcSessionUser>, "id" | "email" | "username" | "role" | "destinationCalendar">;
};
input: TConfirmInputSchema;
};
@@ -302,6 +302,7 @@ const getStartTime = (startTimeInput: string, timeZone?: string, minimumBookingN
return startTimeMin.isAfter(startTime) ? startTimeMin.tz(timeZone) : startTime;
};
export type GetAvailableSlotsResponse = Awaited<ReturnType<typeof _getAvailableSlots>>;
const _getAvailableSlots = async ({ input, ctx }: GetScheduleOptions): Promise<IGetAvailableSlots> => {
const {
_enableTroubleshooter: enableTroubleshooter = false,