refactor: Remove trpc/server dependency from @calcom/atoms#15
Conversation
📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
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.
Benchmark PR from agentic-review-benchmarks#15
Summary by CodeRabbit
Refactor
Chores