Skip to content

refactor: Remove trpc/server dependency from @calcom/atoms#15

Open
tomerqodo wants to merge 2 commits into
coderabbit_full_base_refactor_remove_trpc_server_dependency_from_calcom_atoms_pr15from
coderabbit_full_head_refactor_remove_trpc_server_dependency_from_calcom_atoms_pr15
Open

refactor: Remove trpc/server dependency from @calcom/atoms#15
tomerqodo wants to merge 2 commits into
coderabbit_full_base_refactor_remove_trpc_server_dependency_from_calcom_atoms_pr15from
coderabbit_full_head_refactor_remove_trpc_server_dependency_from_calcom_atoms_pr15

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 30, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#15

Summary by CodeRabbit

  • Refactor

    • Reorganized type definitions for slots and schedules, consolidating them into dedicated modules within the platform atoms package.
    • Updated import paths across hooks to reference local type definitions instead of external sources.
  • Chores

    • Updated package exports to expose booker type definitions.
    • Adjusted import restrictions to reflect the new type organization.

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This refactoring consolidates type definitions by moving Slot and schedule-related types from the TRPC server layer to the platform atoms package, updating all import paths accordingly and removing the original type exports.

Changes

Cohort / File(s) Summary
Type Definition Consolidation
packages/platform/atoms/booker/types.ts, packages/platform/atoms/hooks/schedules/types.ts
Introduces locally-defined Slot, GetAvailableSlotsResponse, Schedule, and schedule handler types to replace external TRPC imports. Adds validateCreateScheduleInput validation function for input validation.
Import Path Updates
apps/web/test/lib/getSchedule/expects.ts, packages/platform/atoms/hooks/schedules/useAtomCreateSchedule.ts, packages/platform/atoms/hooks/schedules/useAtomDuplicateSchedule.ts, packages/platform/atoms/hooks/schedules/useAtomGetAllSchedules.ts, packages/platform/atoms/hooks/useAvailableSlots.ts
Updates type imports to reference new local type sources from the atoms package instead of TRPC server paths.
Configuration Updates
biome.json, packages/platform/atoms/package.json, packages/platform/atoms/tsconfig.json
Restricts imports from the base @calcom/trpc path, exports the new booker types module endpoint, and removes TRPC path references from TypeScript config.
Type Removal
packages/trpc/server/routers/viewer/slots/types.ts
Removes exported Slot type definition that has been relocated to atoms package.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Types hop from server to atoms bright,
Consolidating slots with all their might,
No more scattered across the trpc maze,
Validation shines in local displays,
A cleaner path for bookings to race!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing the trpc/server dependency from the @calcom/atoms package, which aligns with the refactored imports and type relocations across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head_refactor_remove_trpc_server_dependency_from_calcom_atoms_pr15

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

1 similar comment
@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/platform/atoms/hooks/schedules/types.ts`:
- Around line 38-49: validateCreateScheduleInput currently only checks name;
extend it to fully validate the expected CreateScheduleInput shape (or rename it
to indicate partial validation). Specifically, in validateCreateScheduleInput
ensure eventTypeId exists and is a non-empty string, ensure schedule is an
array, and for each entry in schedule validate required fields (e.g., startTime
and endTime are valid Dates or ISO date strings and any numeric/enum fields have
correct types); throw clear errors for each failure; update any callers/tests if
you opt to rename the function to something like validateCreateScheduleNameOnly
to reflect partial checks.

Comment on lines +38 to +49
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');
}

return data as CreateScheduleInput;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Validator is partial; schedule/eventTypeId remain unchecked.

validateCreateScheduleInput only validates name, so malformed schedule or eventTypeId can slip through and fail later. Either validate the full shape (including nested arrays and dates) or rename this to reflect partial validation.

✅ 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 (data.eventTypeId !== undefined && typeof data.eventTypeId !== 'number') {
+    throw new Error('Invalid input: eventTypeId must be a number');
+  }
+
+  if (data.schedule !== undefined && !Array.isArray(data.schedule)) {
+    throw new Error('Invalid input: schedule must be a 2D array');
+  }
 
   return data as CreateScheduleInput;
 }
🤖 Prompt for AI Agents
In `@packages/platform/atoms/hooks/schedules/types.ts` around lines 38 - 49,
validateCreateScheduleInput currently only checks name; extend it to fully
validate the expected CreateScheduleInput shape (or rename it to indicate
partial validation). Specifically, in validateCreateScheduleInput ensure
eventTypeId exists and is a non-empty string, ensure schedule is an array, and
for each entry in schedule validate required fields (e.g., startTime and endTime
are valid Dates or ISO date strings and any numeric/enum fields have correct
types); throw clear errors for each failure; update any callers/tests if you opt
to rename the function to something like validateCreateScheduleNameOnly to
reflect partial checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant