Skip to content

chore: [Booking Cancellation Refactor - 0] - Add skeleton for BookingCancelService#24038

Merged
hariombalhara merged 2 commits intomainfrom
ariom/pri-305-bookingCancelService-skeleton
Oct 21, 2025
Merged

chore: [Booking Cancellation Refactor - 0] - Add skeleton for BookingCancelService#24038
hariombalhara merged 2 commits intomainfrom
ariom/pri-305-bookingCancelService-skeleton

Conversation

@hariombalhara
Copy link
Member

@hariombalhara hariombalhara commented Sep 24, 2025

What does this PR do?

This PR adds a skeleton implementation for BookingCancelService following the same architectural pattern established in PR #23277. The changes include:

  • Service Class: New BookingCancelService class that extends the base service from handleCancelBooking.ts
  • Dependency Injection: Complete DI infrastructure including modules, containers, and tokens
  • Interface Definition: IBookingCancelService interface for future implementations
  • API v2 Integration: NestJS module and service for API v2 endpoint support
  • Refactored Handler: Modified existing handleCancelBooking.ts to support service-based architecture

This is a skeleton implementation only - the new service is not yet integrated into the booking flow and maintains full backward compatibility with existing functionality.

Link to Devin run: https://app.devin.ai/sessions/998e3ee36c87452785d024698dde8806
PR Description Requested by: @hariombalhara

Visual Demo (For contributors especially)

N/A - This is an architectural refactor with no user-facing changes.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - Internal architectural changes only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works. Note: This is skeleton code for future integration.

How should this be tested?

Since this is a skeleton implementation that doesn't modify existing behavior:

  1. Verify existing cancellation flow works unchanged:

    • Create a booking and cancel it
    • Test both regular and recurring booking cancellations
    • Ensure all notification flows (emails, webhooks) still function
  2. Verify DI container setup:

    • Check that getBookingCancelService() can be instantiated without errors
    • Confirm all dependencies are properly injected
  3. Type checking:

    • Run yarn type-check:ci to ensure no TypeScript errors
    • Verify the service class properly extends the base class

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my changes generate no new warnings

Human Review Focus Areas

⚠️ Critical Review Points:

  1. Dependency Injection Setup: Verify the DI module configuration in BookingCancelService.module.ts has all required dependencies and correct token bindings
  2. Service Class Implementation: Ensure BookingCancelService properly extends the base class and passes dependencies correctly
  3. Interface Design: Review if IBookingCancelService with generic any types is appropriate for future implementations
  4. Backward Compatibility: Confirm existing handleCancelBooking export remains functional and doesn't introduce breaking changes
  5. Type Safety: Check for any potential TypeScript issues with the service instantiation and dependency injection

@linear
Copy link

linear bot commented Sep 24, 2025

PRI-305

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

Adds a bookings cancellation service layer and DI wiring. Introduces a public BookingCancelService class, related DTO/types (CancelRegularBookingData, CancelBookingMeta, HandleCancelBookingResponse), and an IBookingCancelService interface in packages/features/bookings. Adds DI tokens, a BookingCancelService DI module, and a container helper (getBookingCancelService). Adds a NestJS BookingCancelModule and a NestJS BookingCancelService in apps/api/v2 wired to PrismaWriteService. Updates the web cancel route to retrieve server session and use session?.user?.id when invoking cancellation.

Possibly related PRs

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "chore: [Booking Cancellation Refactor - 0] - Add skeleton for BookingCancelService" directly and specifically describes the main change in the changeset. The changeset adds a skeleton implementation of BookingCancelService with complete DI infrastructure, interface definitions, and API v2 integration. The title is concise, clear, and accurately captures this primary objective without misleading information or vague phrasing.
Description Check ✅ Passed The PR description is clearly related to the changeset. It provides specific details about the skeleton implementation including the Service Class, Dependency Injection infrastructure, Interface Definition, API v2 Integration, and refactored handler—all of which align with the files and changes in the raw summary. The description includes testing guidance, a clear note that this is skeleton-only, and identifies human review focus areas, providing meaningful context about the changes without being off-topic or vague.
✨ 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 ariom/pri-305-bookingCancelService-skeleton

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.

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Sep 24, 2025
@hariombalhara hariombalhara changed the base branch from main to graphite-base/24038 September 24, 2025 10:36
@hariombalhara hariombalhara changed the base branch from graphite-base/24038 to hariom/pri-305-bookingcreateservice-rename-handlers-to-services September 24, 2025 10:36
Copy link
Member Author

hariombalhara commented Sep 24, 2025

@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from 2966093 to da0457a Compare September 24, 2025 10:47
@vercel
Copy link

vercel bot commented Sep 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Oct 17, 2025 10:51am
cal-eu Ignored Ignored Oct 17, 2025 10:51am

@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from da0457a to 713a4b5 Compare September 24, 2025 11:15
@hariombalhara hariombalhara force-pushed the hariom/pri-305-bookingcreateservice-rename-handlers-to-services branch from 80b66bb to 748408d Compare September 24, 2025 11:15
@hariombalhara hariombalhara changed the base branch from hariom/pri-305-bookingcreateservice-rename-handlers-to-services to graphite-base/24038 September 24, 2025 11:16
@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from 713a4b5 to fd1bece Compare September 24, 2025 11:16
@hariombalhara hariombalhara changed the base branch from graphite-base/24038 to main September 24, 2025 11:16
@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from fd1bece to f0e44e1 Compare September 24, 2025 11:23
@hariombalhara hariombalhara marked this pull request as ready for review September 24, 2025 11:23
@hariombalhara hariombalhara requested a review from a team as a code owner September 24, 2025 11:23
@hariombalhara hariombalhara requested a review from a team September 24, 2025 11:23
@graphite-app graphite-app bot requested a review from a team September 24, 2025 11:23
Comment on lines +35 to +41
// const bookingCancelService = getBookingCancelService();
// const result = await bookingCancelService.cancelBooking({
// bookingData: bookingData,
// bookingMeta: {
// userId: session?.user?.id || -1,
// },
// });
Copy link
Member Author

Choose a reason for hiding this comment

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

Example usage, will use in followup PR.

@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking 💻 refactor labels Sep 24, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/web/app/api/cancel/route.ts (1)

35-41: Consider the commented alternative implementation for future migration.

The commented code shows the intended future usage of BookingCancelService with proper separation of bookingData and bookingMeta. This demonstrates good architectural planning for the service-based approach.

Consider adding a TODO comment with a timeline or condition for when this alternative should be activated:

+  // TODO: Migrate to service-based approach once handler export is removed
   // const bookingCancelService = getBookingCancelService();
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 57150d9 and f0e44e1.

📒 Files selected for processing (8)
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts (1 hunks)
  • apps/api/v2/src/lib/services/booking-cancel.service.ts (1 hunks)
  • apps/web/app/api/cancel/route.ts (1 hunks)
  • packages/features/bookings/lib/handleCancelBooking.ts (4 hunks)
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1 hunks)
  • packages/lib/di/bookings/containers/BookingCancelService.container.ts (1 hunks)
  • packages/lib/di/bookings/modules/BookingCancelService.module.ts (1 hunks)
  • packages/lib/di/bookings/tokens.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*Service.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Service files must include Service suffix, use PascalCase matching exported class, and avoid generic names (e.g., MembershipService.ts)

Files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/lib/di/bookings/tokens.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/lib/di/bookings/containers/BookingCancelService.container.ts
  • packages/lib/di/bookings/modules/BookingCancelService.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
  • apps/web/app/api/cancel/route.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/lib/di/bookings/tokens.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/lib/di/bookings/containers/BookingCancelService.container.ts
  • packages/lib/di/bookings/modules/BookingCancelService.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
  • apps/web/app/api/cancel/route.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/lib/di/bookings/tokens.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/lib/di/bookings/containers/BookingCancelService.container.ts
  • packages/lib/di/bookings/modules/BookingCancelService.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
  • apps/web/app/api/cancel/route.ts
**/*.{service,repository}.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Avoid dot-suffixes like .service.ts or .repository.ts for new files; reserve .test.ts, .spec.ts, .types.ts for their specific purposes

Files:

  • apps/api/v2/src/lib/services/booking-cancel.service.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.
📚 Learning: 2025-09-03T09:52:51.182Z
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.

Applied to files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/lib/di/bookings/tokens.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/lib/di/bookings/containers/BookingCancelService.container.ts
  • packages/lib/di/bookings/modules/BookingCancelService.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
📚 Learning: 2025-08-21T13:55:23.470Z
Learnt from: alishaz-polymath
PR: calcom/cal.com#23247
File: packages/features/webhooks/lib/service/FormWebhookService.ts:0-0
Timestamp: 2025-08-21T13:55:23.470Z
Learning: In the new webhook architecture for Cal.com, schedulePayload is considered legacy code that doesn't fit the clean architecture. The new architecture keeps webhook scheduling logic within the Service layer, specifically through a new method WebhookService.scheduleDelayedWebhooks, rather than using the old centralized schedulePayload helper.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking.ts
📚 Learning: 2025-08-21T12:28:42.018Z
Learnt from: alishaz-polymath
PR: calcom/cal.com#23247
File: packages/features/webhooks/lib/factory/WebhookPayloadFactory.ts:274-282
Timestamp: 2025-08-21T12:28:42.018Z
Learning: In webhook DTOs in packages/features/webhooks/lib/dto/types.ts, the booking fields are restricted structures containing only specific fields (id, eventTypeId, userId, and sometimes additional fields like startTime or smsReminderNumber) rather than full database booking objects, so there are no security or PII leakage concerns when using these booking objects in webhook payloads.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking.ts
📚 Learning: 2025-09-12T11:23:34.158Z
Learnt from: hariombalhara
PR: calcom/cal.com#23736
File: packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.ts:73-84
Timestamp: 2025-09-12T11:23:34.158Z
Learning: The test file packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.test.ts explicitly documents on line 236 that the current behavior of forceRescheduleForCancelledBooking affecting both CANCELLED and REJECTED bookings is known to be incorrect, but is preserved as "Current Behavior" for backward compatibility. The test comment states the expected behavior should be that REJECTED bookings redirect to booking details even when forceRescheduleForCancelledBooking=true.

Applied to files:

  • apps/web/app/api/cancel/route.ts
🧬 Code graph analysis (6)
apps/api/v2/src/lib/services/booking-cancel.service.ts (2)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (609-620)
packages/lib/di/bookings/modules/BookingCancelService.module.ts (1)
  • BookingCancelService (27-27)
apps/api/v2/src/lib/modules/booking-cancel.module.ts (2)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (609-620)
packages/lib/di/bookings/modules/BookingCancelService.module.ts (1)
  • BookingCancelService (27-27)
packages/lib/di/bookings/containers/BookingCancelService.container.ts (1)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (609-620)
packages/lib/di/bookings/modules/BookingCancelService.module.ts (3)
packages/lib/di/di.ts (1)
  • bindModuleToClassOnToken (57-113)
packages/lib/di/tokens.ts (1)
  • DI_TOKENS (3-58)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (609-620)
packages/features/bookings/lib/handleCancelBooking.ts (2)
packages/lib/di/bookings/modules/BookingCancelService.module.ts (1)
  • BookingCancelService (27-27)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)
  • IBookingCancelService (2-5)
apps/web/app/api/cancel/route.ts (2)
packages/platform/libraries/index.ts (1)
  • handleCancelBooking (71-71)
packages/features/auth/lib/next-auth-options.ts (1)
  • session (746-771)
🔇 Additional comments (11)
packages/lib/di/bookings/tokens.ts (1)

4-5: LGTM!

The new DI tokens follow the existing naming convention and are properly grouped within the BOOKING_DI_TOKENS object. The Symbol usage ensures unique token identity for the DI system.

apps/api/v2/src/lib/modules/booking-cancel.module.ts (1)

5-10: LGTM!

The NestJS module correctly imports PrismaModule, provides the BookingCancelService, and exports it for consumption by other modules. The structure follows standard NestJS patterns.

apps/web/app/api/cancel/route.ts (2)

28-28: LGTM!

Session retrieval is properly implemented using the established pattern with getServerSession and buildLegacyRequest. The session data will be available for extracting userId in the cancellation flow.


30-33: LGTM!

The userId extraction from session follows the correct pattern with a fallback to -1. This maintains backward compatibility while properly integrating session data into the cancellation process.

packages/lib/di/bookings/modules/BookingCancelService.module.ts (2)

12-20: LGTM!

The DI module correctly uses bindModuleToClassOnToken with proper dependency mapping. The prismaClient dependency is correctly mapped to prismaModuleLoader, which aligns with the BookingCancelServiceDependencies interface.


22-25: LGTM!

The exported moduleLoader object provides the standard interface with token and loadModule for the DI container system. This follows the established pattern from other DI modules.

apps/api/v2/src/lib/services/booking-cancel.service.ts (1)

6-15: LGTM!

The NestJS service correctly extends the base BookingCancelService and properly injects the Prisma client through PrismaWriteService. The constructor delegation to super() with the extracted prisma client follows the expected DI pattern.

packages/features/bookings/lib/handleCancelBooking.ts (3)

32-34: Verify the TODO comment regarding Prisma imports.

The TODO suggests that Prisma imports will be handled through DI in a follow-up PR. Ensure this transition plan is tracked properly and the current direct import doesn't conflict with the DI architecture being introduced.

Consider adding a more specific TODO with tracking information:

-// TODO: Prisma import would be used from DI in a followup PR when we remove `handler` export
+// TODO: Remove direct prisma import when handler export is removed (tracked in issue/PR #XXXX)

591-600: LGTM!

The new type definitions CancelRegularBookingData and CancelBookingMeta provide good separation of concerns. CancelRegularBookingData correctly extracts the booking data type, and CancelBookingMeta contains all optional metadata fields for platform integration.


8-8: No duplicate EventManager import in handleCancelBooking.ts

Only one import exists at packages/features/bookings/lib/handleCancelBooking.ts:8; EventManager is imported in other files as expected — no conflict or import-order issue detected.

packages/lib/di/bookings/containers/BookingCancelService.container.ts (1)

7-13: Confirm idempotent module loading (avoid duplicate bindings/memory leaks).

bindModuleToClassOnToken's loadModule calls container.load(moduleToken, module) on every invocation (packages/lib/di/di.ts:101-112), and bookingCancelServiceContainer is created once at module scope while getBookingCancelService() calls loadModule on each use (packages/lib/di/bookings/containers/BookingCancelService.container.ts:7-12). Verify that @evyweb/ioctopus container.load is idempotent / deduplicates by moduleToken; if it re-registers bindings, change to load once (guard flag / API check) or create a per-call container to avoid leaking registrations.

Udit-takkar
Udit-takkar previously approved these changes Oct 13, 2025
@Udit-takkar
Copy link
Contributor

@hariombalhara can you fix the conflicts?

@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from da0a1e8 to 58eb2d0 Compare October 13, 2025 09:10
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
packages/features/bookings/lib/handleCancelBooking.ts (1)

603-621: Skeleton implementation is appropriate for this phase.

The BookingCancelService class correctly implements the service pattern:

  • Constructor accepts BookingCancelServiceDependencies (currently only prismaClient)
  • cancelBooking method merges bookingData and bookingMeta before delegating to the handler
  • TODO comment (line 618) acknowledges that dependencies aren't passed to the handler yet

This skeleton implementation preserves backward compatibility while establishing the DI infrastructure. The TODO is appropriate for this phase. Past reviewers have noted:

  • The interface type mismatch (any types) - acknowledged as follow-up work
  • Repository pattern suggestion - acknowledged and addressed in stacked PR #24159

The current implementation achieves the stated goal: "add skeleton for BookingCancelService without integrating into booking flow."

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between da0a1e8 and 58eb2d0.

📒 Files selected for processing (9)
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts (1 hunks)
  • apps/api/v2/src/lib/services/booking-cancel.service.ts (1 hunks)
  • apps/web/app/api/cancel/route.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.container.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.module.ts (1 hunks)
  • packages/features/bookings/di/tokens.ts (1 hunks)
  • packages/features/bookings/lib/handleCancelBooking.ts (4 hunks)
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1 hunks)
  • packages/features/di/tokens.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • apps/web/app/api/cancel/route.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • packages/features/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • packages/features/bookings/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.module.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • packages/features/bookings/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.module.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • packages/features/bookings/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.module.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{service,repository}.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Avoid dot-suffixes like .service.ts or .repository.ts for new files; reserve .test.ts, .spec.ts, .types.ts for their specific purposes

Files:

  • apps/api/v2/src/lib/services/booking-cancel.service.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.
📚 Learning: 2025-09-03T09:52:51.182Z
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.

Applied to files:

  • packages/features/bookings/di/BookingCancelService.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
🧬 Code graph analysis (4)
packages/features/bookings/di/BookingCancelService.container.ts (2)
packages/features/di/di.ts (1)
  • createContainer (114-114)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (610-621)
packages/features/bookings/di/BookingCancelService.module.ts (3)
packages/features/di/di.ts (1)
  • bindModuleToClassOnToken (57-113)
packages/features/di/tokens.ts (1)
  • DI_TOKENS (3-63)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (610-621)
apps/api/v2/src/lib/services/booking-cancel.service.ts (2)
packages/features/bookings/di/BookingCancelService.module.ts (1)
  • BookingCancelService (24-24)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (610-621)
packages/features/bookings/lib/handleCancelBooking.ts (2)
packages/features/bookings/di/BookingCancelService.module.ts (1)
  • BookingCancelService (24-24)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)
  • IBookingCancelService (2-5)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (4)
packages/features/bookings/di/BookingCancelService.container.ts (1)

8-14: LGTM! Standard DI container pattern.

The container creation and module loading follow the established DI pattern in the codebase. The module loader should be idempotent, so repeated calls to getBookingCancelService() won't cause issues.

packages/features/bookings/di/BookingCancelService.module.ts (1)

1-24: LGTM! Module wiring follows established patterns.

The DI module correctly:

  • Uses tokens from DI_TOKENS (which should spread from BOOKING_DI_TOKENS after fixing the duplication issue)
  • Binds BookingCancelService with depsMap containing only prismaClient, matching the BookingCancelServiceDependencies interface
  • Exports the moduleLoader pattern for container integration

Based on learnings from similar services (RegularBookingService), this structure aligns with the established DI architecture.

apps/api/v2/src/lib/services/booking-cancel.service.ts (1)

1-15: LGTM! Clean NestJS service integration.

The service correctly:

  • Extends the base BookingCancelService from the features layer
  • Injects PrismaWriteService via NestJS DI
  • Passes the Prisma client to the base class constructor

This follows the standard pattern for integrating feature-layer services into the NestJS API layer.

packages/features/bookings/lib/handleCancelBooking.ts (1)

592-601: Type definitions are adequate for skeleton phase.

The exported types provide the necessary structure for the service interface. The optional fields in CancelBookingMeta are appropriate as they represent optional platform-specific metadata.

Note: Past reviewer (Udit-takkar) suggested improving type safety by making some fields required. This can be addressed in a follow-up PR once the service is integrated into the booking flow and usage patterns are clearer.

@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from 58eb2d0 to 06460ee Compare October 13, 2025 09:58
@hariombalhara hariombalhara self-assigned this Oct 13, 2025
@hariombalhara
Copy link
Member Author

@Udit-takkar resolved conflicts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/features/bookings/lib/handleCancelBooking.ts (1)

589-607: Dependencies declared but not used in the skeleton.

The BookingCancelServiceDependencies are passed to the constructor (line 597) but remain unused in cancelBooking (lines 599-606). The method directly invokes the legacy handler without passing this.deps (line 605), making the deps parameter temporarily redundant.

This aligns with the PR's skeleton-only scope. The TODO comment (line 604) correctly indicates this will be addressed when migrating away from the exported handler.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 58eb2d0 and 06460ee.

📒 Files selected for processing (10)
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts (1 hunks)
  • apps/api/v2/src/lib/services/booking-cancel.service.ts (1 hunks)
  • apps/web/app/api/cancel/route.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.container.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.module.ts (1 hunks)
  • packages/features/bookings/di/tokens.ts (1 hunks)
  • packages/features/bookings/lib/dto/BookingCancel.d.ts (1 hunks)
  • packages/features/bookings/lib/handleCancelBooking.ts (3 hunks)
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1 hunks)
  • packages/features/di/tokens.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/features/di/tokens.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/features/bookings/di/BookingCancelService.module.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
  • packages/features/bookings/di/tokens.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
  • packages/features/bookings/di/tokens.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
  • packages/features/bookings/di/tokens.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
**/*.{service,repository}.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Avoid dot-suffixes like .service.ts or .repository.ts for new files; reserve .test.ts, .spec.ts, .types.ts for their specific purposes

Files:

  • apps/api/v2/src/lib/services/booking-cancel.service.ts
🧠 Learnings (1)
📚 Learning: 2025-09-03T09:52:51.182Z
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking.ts
🧬 Code graph analysis (6)
apps/web/app/api/cancel/route.ts (1)
packages/platform/libraries/index.ts (1)
  • handleCancelBooking (62-62)
packages/features/bookings/di/BookingCancelService.container.ts (3)
packages/features/di/di.ts (1)
  • createContainer (114-114)
packages/features/bookings/di/BookingCancelService.module.ts (1)
  • BookingCancelService (24-24)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (596-607)
packages/features/bookings/lib/dto/BookingCancel.d.ts (1)
packages/prisma/zod-utils.ts (1)
  • bookingCancelInput (294-297)
apps/api/v2/src/lib/modules/booking-cancel.module.ts (2)
packages/features/bookings/di/BookingCancelService.module.ts (1)
  • BookingCancelService (24-24)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (596-607)
packages/features/bookings/lib/handleCancelBooking.ts (2)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)
  • IBookingCancelService (7-12)
packages/features/bookings/lib/dto/BookingCancel.d.ts (2)
  • CancelRegularBookingData (12-12)
  • CancelBookingMeta (17-24)
apps/api/v2/src/lib/services/booking-cancel.service.ts (1)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (596-607)
🔇 Additional comments (5)
packages/features/bookings/lib/dto/BookingCancel.d.ts (1)

1-35: LGTM! Type definitions are well-structured.

The domain types are framework-agnostic and properly documented. The separation of concerns between booking data, metadata, and response is clear.

apps/api/v2/src/lib/modules/booking-cancel.module.ts (1)

1-10: LGTM! NestJS module correctly wired.

The module properly imports PrismaModule, provides BookingCancelService, and exports it for consumption by other modules. The structure follows standard NestJS patterns.

apps/web/app/api/cancel/route.ts (1)

28-41: Session retrieval added for future service integration.

The session is now retrieved before cancellation (line 28), and the commented-out code (lines 35-41) demonstrates the intended future usage with bookingCancelService. The current implementation correctly preserves backward compatibility while preparing for the DI-based approach.

apps/api/v2/src/lib/services/booking-cancel.service.ts (1)

1-15: LGTM! Service correctly extends base and wires Prisma.

The NestJS service properly extends the base BookingCancelService and injects PrismaWriteService through the constructor, passing the Prisma client to the base class via super(). This follows the established DI pattern.

packages/features/bookings/di/BookingCancelService.container.ts (1)

8-13: Confirm idempotent behavior of loadModule: getBookingCancelService() invokes container.load(moduleToken, module) on every call—verify that repeated loads via bindModuleToClassOnToken don’t register the module twice or throw errors.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/features/bookings/di/BookingCancelService.container.ts (1)

10-14: Avoid repeated module loading on every invocation.

Currently, loadModule is called every time getBookingCancelService() is invoked. Since the container is created once at module scope (line 8), repeatedly loading the same module into the same container could cause issues if the module loader attempts to register the same token multiple times, or is simply inefficient.

Consider loading the module once using lazy initialization:

 const bookingCancelServiceContainer = createContainer();
+let isModuleLoaded = false;

 export function getBookingCancelService(): BookingCancelService {
-  bookingCancelServiceModule.loadModule(bookingCancelServiceContainer);
+  if (!isModuleLoaded) {
+    bookingCancelServiceModule.loadModule(bookingCancelServiceContainer);
+    isModuleLoaded = true;
+  }

   return bookingCancelServiceContainer.get<BookingCancelService>(bookingCancelServiceModule.token);
 }

Alternatively, load the module at module scope if immediate initialization is acceptable:

 const bookingCancelServiceContainer = createContainer();
+bookingCancelServiceModule.loadModule(bookingCancelServiceContainer);

 export function getBookingCancelService(): BookingCancelService {
-  bookingCancelServiceModule.loadModule(bookingCancelServiceContainer);
-
   return bookingCancelServiceContainer.get<BookingCancelService>(bookingCancelServiceModule.token);
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 06460ee and 0cb48eb.

📒 Files selected for processing (10)
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts (1 hunks)
  • apps/api/v2/src/lib/services/booking-cancel.service.ts (1 hunks)
  • apps/web/app/api/cancel/route.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.container.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.module.ts (1 hunks)
  • packages/features/bookings/di/tokens.ts (1 hunks)
  • packages/features/bookings/lib/dto/BookingCancel.d.ts (1 hunks)
  • packages/features/bookings/lib/handleCancelBooking.ts (3 hunks)
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1 hunks)
  • packages/features/di/tokens.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/features/di/tokens.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/features/bookings/di/tokens.ts
  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • packages/features/bookings/di/BookingCancelService.module.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • packages/features/bookings/di/BookingCancelService.container.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/bookings/di/BookingCancelService.container.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/bookings/di/BookingCancelService.container.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
🧠 Learnings (1)
📚 Learning: 2025-09-03T09:52:51.182Z
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking.ts
🧬 Code graph analysis (3)
packages/features/bookings/di/BookingCancelService.container.ts (3)
packages/features/di/di.ts (1)
  • createContainer (114-114)
packages/features/bookings/di/BookingCancelService.module.ts (1)
  • BookingCancelService (24-24)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (598-609)
apps/api/v2/src/lib/modules/booking-cancel.module.ts (1)
packages/features/bookings/lib/handleCancelBooking.ts (1)
  • BookingCancelService (598-609)
packages/features/bookings/lib/handleCancelBooking.ts (2)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)
  • IBookingCancelService (7-12)
packages/features/bookings/lib/dto/BookingCancel.d.ts (2)
  • CancelRegularBookingData (12-12)
  • CancelBookingMeta (17-24)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (2)
apps/api/v2/src/lib/modules/booking-cancel.module.ts (1)

1-10: LGTM! NestJS module structure is correct.

The module correctly wires up BookingCancelService with PrismaModule, following standard NestJS dependency injection patterns. The service is both provided and exported, making it available for external use.

packages/features/bookings/lib/handleCancelBooking.ts (1)

591-609: LGTM! Skeleton structure is appropriate for this phase.

The BookingCancelService class correctly implements the IBookingCancelService interface and establishes the DI infrastructure. The TODO comment (Line 606) clearly indicates that dependency injection will be completed in a future phase when the handler export is removed, which aligns with the PR's skeleton-only objectives.

@hariombalhara hariombalhara force-pushed the ariom/pri-305-bookingCancelService-skeleton branch from 0cb48eb to 406d8fe Compare October 16, 2025 11:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/features/bookings/lib/dto/BookingCancel.d.ts (1)

17-24: Consider making userId required in future iterations.

While all fields being optional in CancelBookingMeta is acceptable for this skeleton implementation, the userId field is critical for authorization. As the service matures beyond the skeleton phase, consider making it required to enforce proper authorization checks.

This can be addressed in a follow-up PR when the service is fully integrated:

 export type CancelBookingMeta = {
-  userId?: number;
+  userId: number;
   platformClientId?: string;
   platformRescheduleUrl?: string;
   platformCancelUrl?: string;
   platformBookingUrl?: string;
   arePlatformEmailsEnabled?: boolean;
 };
packages/features/bookings/lib/handleCancelBooking.ts (1)

595-613: Skeleton implementation looks good; track the dependency injection completion.

The BookingCancelService class correctly implements the interface with proper types. The constructor accepts deps but doesn't pass them to the handler (as indicated by the TODO comment), which is acceptable for this skeleton phase.

However, to ensure this technical debt is addressed:

Do you want me to open a GitHub issue to track:

  1. Passing deps.prismaClient to the handler instead of using the global prisma import
  2. Migrating from direct Prisma usage to a Repository pattern (as suggested in previous reviews)
  3. Removing the exported handler function once all consumers migrate to the service
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0cb48eb and 406d8fe.

📒 Files selected for processing (10)
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts (1 hunks)
  • apps/api/v2/src/lib/services/booking-cancel.service.ts (1 hunks)
  • apps/web/app/api/cancel/route.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.container.ts (1 hunks)
  • packages/features/bookings/di/BookingCancelService.module.ts (1 hunks)
  • packages/features/bookings/di/tokens.ts (1 hunks)
  • packages/features/bookings/lib/dto/BookingCancel.d.ts (1 hunks)
  • packages/features/bookings/lib/handleCancelBooking.ts (4 hunks)
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1 hunks)
  • packages/features/di/tokens.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/features/di/tokens.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/features/bookings/di/tokens.ts
  • packages/features/bookings/di/BookingCancelService.container.ts
  • apps/api/v2/src/lib/services/booking-cancel.service.ts
  • apps/api/v2/src/lib/modules/booking-cancel.module.ts
  • packages/features/bookings/di/BookingCancelService.module.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/app/api/cancel/route.ts
  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/features/bookings/lib/dto/BookingCancel.d.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*Service.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Service files must include Service suffix, use PascalCase matching exported class, and avoid generic names (e.g., MembershipService.ts)

Files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
🧠 Learnings (2)
📚 Learning: 2025-09-03T09:52:51.182Z
Learnt from: hariombalhara
PR: calcom/cal.com#23541
File: packages/features/bookings/lib/di/modules/RegularBookingServiceModule.ts:22-28
Timestamp: 2025-09-03T09:52:51.182Z
Learning: The IBookingServiceDependencies interface in packages/features/bookings/lib/handleNewBooking.ts contains 6 properties: cacheService, checkBookingAndDurationLimitsService, prismaClient, bookingRepository, featuresRepository, and checkBookingLimitsService. This interface is used by RegularBookingService and matches the depsMap structure in RegularBookingServiceModule.

Applied to files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
📚 Learning: 2025-10-11T20:10:06.308Z
Learnt from: Udit-takkar
PR: calcom/cal.com#24324
File: packages/lib/server/repository/bookingReport.interface.ts:13-19
Timestamp: 2025-10-11T20:10:06.308Z
Learning: In `packages/lib/server/repository/bookingReport.interface.ts`, the `BookingReportSummary` interface intentionally does not include a `bookingId` field as per the design decision for the report booking feature.

Applied to files:

  • packages/features/bookings/lib/interfaces/IBookingCancelService.ts
🧬 Code graph analysis (4)
apps/web/app/api/cancel/route.ts (2)
packages/platform/libraries/index.ts (1)
  • handleCancelBooking (62-62)
packages/features/auth/lib/next-auth-options.ts (1)
  • session (746-771)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)
packages/features/bookings/lib/dto/BookingCancel.d.ts (3)
  • CancelRegularBookingData (12-12)
  • CancelBookingMeta (17-24)
  • HandleCancelBookingResponse (29-35)
packages/features/bookings/lib/dto/BookingCancel.d.ts (1)
packages/prisma/zod-utils.ts (1)
  • bookingCancelInput (295-298)
packages/features/bookings/lib/handleCancelBooking.ts (2)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)
  • IBookingCancelService (7-12)
packages/features/bookings/lib/dto/BookingCancel.d.ts (2)
  • CancelRegularBookingData (12-12)
  • CancelBookingMeta (17-24)
🔇 Additional comments (4)
packages/features/bookings/lib/interfaces/IBookingCancelService.ts (1)

1-12: LGTM! Clean interface definition with proper types.

The interface is well-defined with proper type safety. The previous concern about any types has been resolved.

packages/features/bookings/lib/handleCancelBooking.ts (3)

120-125: Approved: Improved condition formatting.

The reformatting of the multi-line condition improves readability without changing the logic.


615-615: Default export preserved for backward compatibility.

The coding guidelines recommend named exports over default exports for better tree-shaking and refactoring. However, this default export is intentionally preserved for backward compatibility as mentioned in the PR objectives.

As the service integration progresses, consider migrating consumers to the named BookingCancelService export and eventually removing this default export.


8-8: No duplicate EventManager import Confirmed only a single EventManager import remains in packages/features/bookings/lib/handleCancelBooking.ts.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 10 files

@hariombalhara hariombalhara merged commit 5e5e772 into main Oct 21, 2025
41 checks passed
@hariombalhara hariombalhara deleted the ariom/pri-305-bookingCancelService-skeleton branch October 21, 2025 06:59
KartikLabhshetwar pushed a commit to KartikLabhshetwar/cal.com that referenced this pull request Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e 💻 refactor size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments