refactor: Remove trpc/server dependency from @calcom/atoms#42
Conversation
WalkthroughThis refactoring consolidates type definitions by relocating the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/platform/atoms/package.json (1)
44-59: Export points to a file that isn’t published in the npm package
./booker/types.tsis outside the current"files"whitelist (Line 44-48), so consumers of@calcom/atoms/booker/typeswill fail after publish. Either publish that source path or point the export to built output indist.🔧 Suggested fix (publish the source path)
"files": [ "dist", "globals.min.css", - "fonts" + "fonts", + "booker" ],
🤖 Fix all issues with AI agents
In `@packages/platform/atoms/booker/types.ts`:
- Around line 17-23: The callback mismatch: onTimeslotsLoaded expects
Record<string, Slot[]> but schedule.data.slots is Record<string, SlotInfo[]>
with different fields (Slot.userIds vs SlotInfo.toUser/fromUser). Fix by either
transforming schedule.data.slots into the Slot shape before invoking
onTimeslotsLoaded (map each SlotInfo to Slot by converting toUser/fromUser ids
into userIds:string[] and normalizing bookingUid/attendees/users), or by
changing the callback/type to accept Record<string, SlotInfo[]> and update any
downstream consumers; locate the types Slot and SlotInfo in types.ts and the
call site where onTimeslotsLoaded is invoked with schedule.data.slots to apply
the transformation or signature change.
🧹 Nitpick comments (1)
packages/platform/atoms/hooks/schedules/types.ts (1)
38-49: Validation helper is too permissive for its name
validateCreateScheduleInputonly validatesname, yet returnsCreateScheduleInput. Consider validatingeventTypeIdandscheduleshape (or renaming to reflect partial validation) to avoid false confidence.♻️ Minimal shape checks
export function validateCreateScheduleInput(input: unknown): CreateScheduleInput { if (!input || typeof input !== 'object') { throw new Error('Invalid input: must be an object'); } const data = input as Record<string, unknown>; if (typeof data.name !== 'string' || data.name.length === 0) { throw new Error('Invalid input: name must be a non-empty string'); } + + if ('eventTypeId' in data && typeof data.eventTypeId !== 'number') { + throw new Error('Invalid input: eventTypeId must be a number'); + } + + if ('schedule' in data) { + if (!Array.isArray(data.schedule) || !data.schedule.every(Array.isArray)) { + throw new Error('Invalid input: schedule must be a 2D array'); + } + } return data as CreateScheduleInput; }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
apps/web/test/lib/getSchedule/expects.tsbiome.jsonpackages/platform/atoms/booker/types.tspackages/platform/atoms/hooks/schedules/types.tspackages/platform/atoms/hooks/schedules/useAtomCreateSchedule.tspackages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.tspackages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.tspackages/platform/atoms/hooks/useAvailableSlots.tspackages/platform/atoms/package.jsonpackages/platform/atoms/tsconfig.jsonpackages/trpc/server/routers/viewer/slots/types.ts
💤 Files with no reviewable changes (2)
- packages/trpc/server/routers/viewer/slots/types.ts
- packages/platform/atoms/tsconfig.json
🔇 Additional comments (6)
packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts (1)
7-8: LGTM — local type import aligns with the refactor.packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts (1)
7-8: LGTM — consistent type sourcing.packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts (1)
7-8: LGTM — type import migration looks correct.packages/platform/atoms/hooks/useAvailableSlots.ts (1)
11-11: Type import relocation looks good.Localizing
GetAvailableSlotsResponsekeeps this hook decoupled from TRPC server internals as intended.apps/web/test/lib/getSchedule/expects.ts (1)
4-4: Updated Slot type source is consistent with the refactor.biome.json (1)
339-351: Restricted import patterns updated appropriately.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| export type Slot = { | ||
| time: string; | ||
| userIds?: string[]; | ||
| attendees?: number; | ||
| bookingUid?: string; | ||
| users?: string[]; | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's look at the Slot type definition (lines 17-23)
cat -n packages/platform/atoms/booker/types.ts | sed -n '1,50p'Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 1870
🏁 Script executed:
# Let's also see the lines around 115-136 to view SlotInfo
cat -n packages/platform/atoms/booker/types.ts | sed -n '100,150p'Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 1207
🏁 Script executed:
# Search for usage of these types and ID comparisons
rg -n --type=ts 'userIds|toUser|fromUser' packages/platform/atoms/booker/ -A 2 -B 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 1477
🏁 Script executed:
# Search for where Slot and SlotInfo are used/compared
rg -n --type=ts 'Slot\[|SlotInfo\[|\.userIds|\.toUser\.id|\.fromUser\.id' packages/platform/atoms/booker/ -A 1 -B 1Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 562
🏁 Script executed:
# Search for onTimeslotsLoaded callback usage to see how Slot[] is used
rg -n --type=ts --type=tsx 'onTimeslotsLoaded' packages/platform/ -A 5 -B 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 113
🏁 Script executed:
# Search for GetAvailableSlotsResponse usage to see how SlotInfo is converted or used
rg -n --type=ts --type=tsx 'GetAvailableSlotsResponse' packages/platform/ -A 3 -B 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 113
🏁 Script executed:
# Look for any slot transformation/conversion logic
rg -n --type=ts --type=tsx 'SlotInfo|toUser|fromUser' packages/platform/ -A 3 -B 1 | head -100Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 113
🏁 Script executed:
# Search for Slot type usage and API calls in the booker directory
rg -n --type=ts --type=tsx 'slots.*=|availableSlots' packages/platform/atoms/booker/ -A 2 -B 1Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 113
🏁 Script executed:
# Search for onTimeslotsLoaded callback usage
rg -n 'onTimeslotsLoaded' packages/platform/atoms/booker/ -A 5 -B 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 2488
🏁 Script executed:
# Search for GetAvailableSlotsResponse usage to see how SlotInfo is converted
rg -n 'GetAvailableSlotsResponse' packages/platform/ -A 3 -B 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 1849
🏁 Script executed:
# Look for slot transformation/conversion logic in the booker directory
rg -n 'SlotInfo|toUser.*id|fromUser.*id' packages/platform/atoms/booker/ -A 2 -B 1Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 535
🏁 Script executed:
# Search for where Slot type is mapped from API response (SlotInfo)
rg -n 'map.*Slot|transform.*Slot|convert.*Slot' packages/platform/atoms/booker/ -A 3Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 68
🏁 Script executed:
# Check if there are any type assertions or casting between Slot and SlotInfo
rg -n 'as Slot|as SlotInfo' packages/platform/atoms/booker/ -B 2 -A 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 68
🏁 Script executed:
# Find where schedule is defined in BookerPlatformWrapper.tsx
rg -n 'const schedule|useAvailableSlots' packages/platform/atoms/booker/BookerPlatformWrapper.tsx -A 5 -B 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 861
🏁 Script executed:
# Check the useAvailableSlots hook implementation for any transformation
cat -n packages/platform/atoms/hooks/useAvailableSlots.tsRepository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 1753
🏁 Script executed:
# Search for any slot transformation or mapping logic in the booker directory
rg -n 'SlotInfo.*Slot|Slot.*SlotInfo|slots\.map|slots\.forEach' packages/platform/atoms/booker/ -A 2Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 68
🏁 Script executed:
# Check for actual property access patterns on the slots passed to onTimeslotsLoaded
rg -n 'onTimeslotsLoaded' packages/platform/ -A 20 | head -60Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 5525
🏁 Script executed:
# Look for userIds or toUser access patterns in the booker component files
rg -n '\.userIds|\.toUser|\.fromUser' packages/platform/atoms/booker/ -B 3 -A 1Repository: qodo-benchmark/cal.com-combined-coderabbit
Length of output: 68
Reconcile Slot and SlotInfo type definitions or transform API response before callback
onTimeslotsLoaded expects Record<string, Slot[]> but receives schedule.data.slots which is Record<string, SlotInfo[]>. These types have incompatible structures: Slot uses userIds: string[] while SlotInfo uses toUser: { id: number } and fromUser: { id: string }. Either transform the API response to match the Slot type before passing to the callback, or update the callback signature to accept SlotInfo.
🤖 Prompt for AI Agents
In `@packages/platform/atoms/booker/types.ts` around lines 17 - 23, The callback
mismatch: onTimeslotsLoaded expects Record<string, Slot[]> but
schedule.data.slots is Record<string, SlotInfo[]> with different fields
(Slot.userIds vs SlotInfo.toUser/fromUser). Fix by either transforming
schedule.data.slots into the Slot shape before invoking onTimeslotsLoaded (map
each SlotInfo to Slot by converting toUser/fromUser ids into userIds:string[]
and normalizing bookingUid/attendees/users), or by changing the callback/type to
accept Record<string, SlotInfo[]> and update any downstream consumers; locate
the types Slot and SlotInfo in types.ts and the call site where
onTimeslotsLoaded is invoked with schedule.data.slots to apply the
transformation or signature change.
Benchmark PR from agentic-review-benchmarks#15
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.