Scheduling infrastructure for absolutely everyone.
refactor: Remove trpc/server dependency from @calcom/atoms (#26717)
Benny Joofc0a2b5a37f1
diff --git a/apps/web/test/lib/getSchedule/expects.ts b/apps/web/test/lib/getSchedule/expects.tsindex 8c84c99f080..15a01218d6e 100644--- a/apps/web/test/lib/getSchedule/expects.ts+++ b/apps/web/test/lib/getSchedule/expects.ts@@ -1,7 +1,7 @@import { diff } from "jest-diff";import { expect } from "vitest";-import type { Slot } from "@calcom/trpc/server/routers/viewer/slots/types";+import type { Slot } from "@calcom/atoms/booker/types";export const expectedSlotsForSchedule = {IstWorkHours: {diff --git a/biome.json b/biome.jsonindex 4d0682229da..44cc714769f 100644--- a/biome.json+++ b/biome.json@@ -337,17 +337,17 @@"patterns": [{"group": [- "@calcom/trpc/react",- "@calcom/trpc/react/**"+ "@calcom/trpc",+ "@calcom/trpc/**"],- "message": "atoms package should not import from @calcom/trpc/react."+ "message": "atoms package should not import from @calcom/trpc."},{"group": [- "../../trpc/react",- "../../trpc/react/**"+ "../../trpc",+ "../../trpc/**"],- "message": "atoms package should not import from trpc/react."+ "message": "atoms package should not import from trpc."}]}diff --git a/packages/platform/atoms/booker/types.ts b/packages/platform/atoms/booker/types.tsindex 29c35a6800c..d57fa9f5fde 100644--- a/packages/platform/atoms/booker/types.ts+++ b/packages/platform/atoms/booker/types.ts@@ -11,10 +11,17 @@ import type {ApiSuccessResponseWithoutData,RoutingFormSearchParams,} from "@calcom/platform-types";-import type { Slot } from "@calcom/trpc/server/routers/viewer/slots/types";import type { UseCreateBookingInput } from "../hooks/bookings/useCreateBooking";+export type Slot = {+ time: string;+ userIds?: number[];+ attendees?: number;+ bookingUid?: string;+ users?: string[];+};+// Type that includes only the data values from BookerStore (excluding functions)export type BookerStoreValues = Omit<BookerStore,@@ -104,3 +111,26 @@ export type BookerPlatformWrapperAtomPropsForTeam = BookerPlatformWrapperAtomProroutingFormSearchParams?: RoutingFormSearchParams;rrHostSubsetIds?: number[];};++type SlotInfo = {+ time: string;+ attendees?: number;+ bookingUid?: string;+ away?: boolean;+ fromUser?: {+ id: number;+ displayName: string | null;+ };+ toUser?: {+ id: number;+ username: string | null;+ displayName: string | null;+ };+ reason?: string;+ emoji?: string;+ showNotePublicly?: boolean;+};++export type GetAvailableSlotsResponse = {+ slots: Record<string, SlotInfo[]>;+};diff --git a/packages/platform/atoms/hooks/schedules/types.ts b/packages/platform/atoms/hooks/schedules/types.tsnew file mode 100644index 00000000000..4c8bf1d3411--- /dev/null+++ b/packages/platform/atoms/hooks/schedules/types.ts@@ -0,0 +1,36 @@+type Schedule = {+ id: number;+ userId: number;+ name: string;+ timeZone: string | null;+};++export type CreateScheduleHandlerReturn = {+ schedule: Schedule;+};++export type DuplicateScheduleHandlerReturn = {+ schedule: Schedule;+};++export type GetAvailabilityListHandlerReturn = {+ schedules: (Omit<Schedule, "userId"> & {+ availability: {+ id: number;+ userId: number | null;+ eventTypeId: number | null;+ days: number[];+ startTime: Date;+ endTime: Date;+ date: Date | null;+ scheduleId: number | null;+ }[];+ isDefault: boolean;+ })[];+};++export type CreateScheduleInput = {+ name: string;+ schedule?: { start: Date; end: Date }[][];+ eventTypeId?: number;+};diff --git a/packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts b/packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.tsindex ef9d7fac11f..27538b03850 100644--- a/packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts+++ b/packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts@@ -2,10 +2,9 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";import { SUCCESS_STATUS } from "@calcom/platform-constants";import type { ApiResponse, ApiErrorResponse, ApiSuccessResponse } from "@calcom/platform-types";-import type { CreateScheduleHandlerReturn } from "@calcom/trpc/server/routers/viewer/availability/schedule/create.handler";-import { TCreateInputSchema as CreateScheduleSchema } from "@calcom/trpc/server/routers/viewer/availability/schedule/create.schema";import http from "../../lib/http";+import type { CreateScheduleHandlerReturn, CreateScheduleInput as CreateScheduleSchema } from "./types";import { QUERY_KEY as SchedulesQueryKey } from "./useAtomGetAllSchedules";import { QUERY_KEY as ScheduleQueryKey } from "./useAtomSchedule";diff --git a/packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts b/packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.tsindex 2d745848588..8c443f5c71c 100644--- a/packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts+++ b/packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts@@ -2,9 +2,9 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";import { SUCCESS_STATUS } from "@calcom/platform-constants";import type { ApiResponse, ApiErrorResponse } from "@calcom/platform-types";-import type { DuplicateScheduleHandlerReturn } from "@calcom/trpc/server/routers/viewer/availability/schedule/duplicate.handler";import http from "../../lib/http";+import type { DuplicateScheduleHandlerReturn } from "./types";import { QUERY_KEY as ScheduleQueryKey } from "./useAtomSchedule";interface useAtomDuplicateScheduleOptions {diff --git a/packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts b/packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.tsindex f0b1a1327ac..e785ecee9d7 100644--- a/packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts+++ b/packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts@@ -2,9 +2,9 @@ import { useQuery } from "@tanstack/react-query";import { SUCCESS_STATUS } from "@calcom/platform-constants";import type { ApiResponse } from "@calcom/platform-types";-import type { GetAvailabilityListHandlerReturn } from "@calcom/trpc/server/routers/viewer/availability/list.handler";import http from "../../lib/http";+import type { GetAvailabilityListHandlerReturn } from "./types";import { useAtomsContext } from "../useAtomsContext";export const QUERY_KEY = "use-atom-user-schedules";diff --git a/packages/platform/atoms/hooks/useAvailableSlots.ts b/packages/platform/atoms/hooks/useAvailableSlots.tsindex e2ac30bab53..11f93960ed0 100644--- a/packages/platform/atoms/hooks/useAvailableSlots.ts+++ b/packages/platform/atoms/hooks/useAvailableSlots.ts@@ -6,9 +6,9 @@ import type {ApiResponse,ApiSuccessResponse,} from "@calcom/platform-types";-import type { GetAvailableSlotsResponse } from "@calcom/trpc/server/routers/viewer/slots/util";import http from "../lib/http";+import type { GetAvailableSlotsResponse } from "../booker/types";export const QUERY_KEY = "get-available-slots";diff --git a/packages/platform/atoms/package.json b/packages/platform/atoms/package.jsonindex 48fe012df14..f7e77ed8431 100644--- a/packages/platform/atoms/package.json+++ b/packages/platform/atoms/package.json@@ -55,7 +55,7 @@},"./add-members-switch/AddMembersWithSwitchPlatformWrapper": "./add-members-switch/AddMembersWithSwitchPlatformWrapper.tsx","./availability/AvailabilitySettings": "./availability/AvailabilitySettings.tsx",- "./booker": "./booker/index.ts",+ "./booker/types": "./booker/types.ts","./selected-calendars/SelectedCalendarsSettings": "./selected-calendars/SelectedCalendarsSettings.tsx","./components/ui/shell": "./src/components/ui/shell.tsx","./dist/index.ts": "./index.ts",diff --git a/packages/platform/atoms/tsconfig.json b/packages/platform/atoms/tsconfig.jsonindex c53c46f2069..8ed76d79748 100644--- a/packages/platform/atoms/tsconfig.json+++ b/packages/platform/atoms/tsconfig.json@@ -38,8 +38,6 @@"../../dayjs","../../prisma/zod-utils.ts","../../prisma/zod",- "../../trpc/server/routers/viewer/slots",- "../../trpc/server/types","../../features/eventtypes","../../features/schedules","../../features/bookings/Booker",diff --git a/packages/trpc/server/routers/viewer/slots/types.ts b/packages/trpc/server/routers/viewer/slots/types.tsindex a2ccf214d17..01320ea4f4a 100644--- a/packages/trpc/server/routers/viewer/slots/types.ts+++ b/packages/trpc/server/routers/viewer/slots/types.ts@@ -76,14 +76,6 @@ export const reserveSlotSchema = z"Either slotUtcStartDate, slotUtcEndDate or eventTypeId should be filled in.");-export type Slot = {- time: string;- userIds?: number[];- attendees?: number;- bookingUid?: string;- users?: string[];-};-export const removeSelectedSlotSchema = z.object({uid: z.string().nullable(),});