-
Notifications
You must be signed in to change notification settings - Fork 0
Code Review Bench PR #26717 - refactor: Remove trpc/server dependency from @calcom/atoms #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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?: string[]; | ||||||||
| 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 = BookerPlatformWrapperAtomPro | |||||||
| routingFormSearchParams?: RoutingFormSearchParams; | ||||||||
| rrHostSubsetIds?: number[]; | ||||||||
| }; | ||||||||
|
|
||||||||
| type SlotInfo = { | ||||||||
| time: string; | ||||||||
| attendees?: number; | ||||||||
| bookingUid?: string; | ||||||||
| away?: boolean; | ||||||||
| fromUser?: { | ||||||||
| id: string; | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 Bug:
|
||||||||
| id: string; | |
| id: number; | |
- Apply suggested fix
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||
| 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: string[]; | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 Bug:
|
||||||||
| days: string[]; | |
| days: number[]; | |
- Apply suggested fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Edge Case: validateCreateScheduleInput doesn't validate schedule or eventTypeId
The validation function only checks that name is a non-empty string, then casts the entire object to CreateScheduleInput via as. This means the schedule and eventTypeId fields are completely unvalidated — a caller could pass { name: "foo", schedule: "not-an-array", eventTypeId: "not-a-number" } and it would be returned as a valid CreateScheduleInput.
The original implementation used a Zod schema (ZCreateInputSchema) that validated all fields including the nested schedule array structure (z.array(z.array(z.object({ start: z.date(), end: z.date() })))) and eventTypeId as z.number().optional().
Since this function's purpose is to provide runtime validation for external npm package consumers, the unsafe as cast defeats that goal. Consider either:
- Adding validation for
scheduleandeventTypeIdfields - Documenting that only
nameis validated - Using a schema validation library (the atoms package could add a lightweight one)
Was this helpful? React with 👍 / 👎
- Apply suggested fix
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "./selected-calendars/SelectedCalendarsSettings": "./selected-calendars/SelectedCalendarsSettings.tsx", | ||
| "./components/ui/shell": "./src/components/ui/shell.tsx", | ||
| "./dist/index.ts": "./index.ts", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 Bug:
Slot.userIds: string[]contradicts upstreamnumber[]typeThe
Slot.userIdsfield was changed fromnumber[]tostring[], but the upstream code that produces this data (inpackages/features/schedules/lib/slots.ts) consistently typesuserIdsasnumber[]. TheTimeFrametype is{ userIds?: number[]; startTime: number; endTime: number }, and all slot generation code works with numeric user IDs.The original type in
packages/trpc/server/routers/viewer/slots/types.ts(being deleted in this PR) haduserIds?: number[]. Changing this tostring[]in the atoms package means the type no longer matches the actual runtime data, which will cause type errors for any code that tries to use both the atom types and the internal slot types together (e.g.,apps/web/test/lib/getSchedule/expects.tswhich now imports from@calcom/atoms/booker/types).Was this helpful? React with 👍 / 👎