Skip to content

Comments

feat: v2 api hidden event types#22602

Closed
RadheyMugdal wants to merge 39 commits intocalcom:mainfrom
RadheyMugdal:feat/api-v2-hidden-event-types
Closed

feat: v2 api hidden event types#22602
RadheyMugdal wants to merge 39 commits intocalcom:mainfrom
RadheyMugdal:feat/api-v2-hidden-event-types

Conversation

@RadheyMugdal
Copy link
Contributor

@RadheyMugdal RadheyMugdal commented Jul 17, 2025

What does this PR do?

This PR adds support for creating and updating hidden event types via API v2.

Summary of Changes

  • Adds hidden?: boolean field to:
    • BaseCreateEventTypeInput
    • BaseUpdateEventTypeInput
  • Returns the hidden field in:
    • BaseEventTypeOutput_2024_06_14
    • getResponseEventType() service
  • Adds E2E tests for:
    • Creating a hidden event type
    • Updating the hidden property of an event type

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. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • E2E tests have been added to cover the functionality:

  • Location:
    apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts

  • What’s covered:

    • Creating an event type with hidden: true and verifying it in the response.
    • Updating an existing event type to hidden: false and verifying the updated value.

RadheyMugdal and others added 30 commits May 16, 2025 22:50
@RadheyMugdal RadheyMugdal requested a review from a team July 17, 2025 17:11
@RadheyMugdal RadheyMugdal requested a review from a team as a code owner July 17, 2025 17:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Walkthrough

A new optional boolean property, hidden, was introduced across several layers of the event type system. The property was added to the input classes for creating and updating event types, as well as to the output class representing event type data. The service responsible for formatting event type responses was updated to include the hidden property in its output. Additionally, new end-to-end tests were implemented to verify the correct handling of the hidden property during event type creation and update operations. No changes were made to existing logic or control flow beyond supporting this new property.

Assessment against linked issues

Objective Addressed Explanation
Add optional hidden property to BaseCreateEventTypeInput and BaseUpdateEventTypeInput classes (#22377)
Include hidden property in the output type BaseEventTypeOutput_2024_06_14 (#22377)
Update getResponseEventType method to return hidden property (#22377)
Add end-to-end tests for creating and updating event types with hidden property (#22377)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were identified in this pull request.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/apps/api/v2".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "apps/api/v2/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

apps/api/v2/src/ee/bookings/2024-08-13/outputs/update-booking-location.output.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/apps/api/v2".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "apps/api/v2/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/apps/api/v2".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "apps/api/v2/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 5 others

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CAL-22377: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team July 17, 2025 17:11
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jul 17, 2025
@vercel
Copy link

vercel bot commented Jul 17, 2025

@RadheyMugdal is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added event-types area: event types, event-types ✨ feature New feature or request labels Jul 17, 2025
@graphite-app
Copy link

graphite-app bot commented Jul 17, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/17/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (07/17/25)

1 label was added to this PR based on Keith Williams's automation.

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 (3)
packages/platform/types/event-types/event-types_2024_06_14/outputs/event-type.output.ts (1)

443-446: Consider adding a description to the @DocsProperty() decorator.

While the implementation is correct, adding a description would improve the API documentation and help developers understand the purpose of the hidden property.

  @IsOptional()
  @IsBoolean()
- @DocsProperty()
+ @DocsProperty({
+   description: "If true, the event type will be hidden from public view"
+ })
  hidden?: boolean;
packages/platform/types/event-types/event-types_2024_06_14/inputs/update-event-type.input.ts (1)

418-421: Consider adding a description to the @DocsPropertyOptional() decorator.

The implementation is correct, but adding a description would improve the API documentation consistency and help developers understand the purpose of the hidden property.

  @IsOptional()
  @IsBoolean()
- @DocsPropertyOptional()
+ @DocsPropertyOptional({
+   description: "If true, the event type will be hidden from public view"
+ })
  hidden?: boolean;
packages/platform/types/event-types/event-types_2024_06_14/inputs/create-event-type.input.ts (1)

443-446: Consider adding a description to the @DocsPropertyOptional() decorator.

The implementation is correct and consistent with the other files in this PR. Adding a description would improve the API documentation.

  @IsOptional()
  @IsBoolean()
- @DocsPropertyOptional()
+ @DocsPropertyOptional({
+   description: "If true, the event type will be hidden from public view"
+ })
  hidden?: boolean;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4dc2260 and 9a5d8b8.

📒 Files selected for processing (5)
  • apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts (1 hunks)
  • apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts (3 hunks)
  • packages/platform/types/event-types/event-types_2024_06_14/inputs/create-event-type.input.ts (1 hunks)
  • packages/platform/types/event-types/event-types_2024_06_14/inputs/update-event-type.input.ts (1 hunks)
  • packages/platform/types/event-types/event-types_2024_06_14/outputs/event-type.output.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
🔇 Additional comments (4)
packages/platform/types/event-types/event-types_2024_06_14/inputs/create-event-type.input.ts (1)

443-446: Excellent implementation consistency across the PR.

The hidden property has been consistently implemented across all input and output types with proper validation decorators and optional typing. This demonstrates good attention to detail and maintains type safety throughout the API.

apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts (3)

92-92: LGTM: Property added to Input type correctly.

The addition of the "hidden" property to the Input type is properly implemented and follows the same pattern as other properties.


131-131: LGTM: Property destructuring implemented correctly.

The destructuring of the "hidden" property follows the established pattern and is properly implemented.


208-208: LGTM: Property correctly included in response object.

The inclusion of the "hidden" property in the response object completes the implementation correctly and maintains consistency with the existing code structure.

@github-actions github-actions bot added api area: API, enterprise API, access token, OAuth High priority Created by Linear-GitHub Sync platform Anything related to our platform plan Private Created by Linear-GitHub Sync labels Jul 17, 2025
Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

Can you pls upload a loom video of the change?

Getting an error on running the api after the changes. I am not getting this error on main. Can you please fix it?

src/modules/organizations/event-types/services/output.service.ts:92:7 - error TS2345: Argument of type 'Input' is not assignable to parameter of type 'Input'.
Property 'hidden' is missing in type 'Input' but required in type 'Input'.

92 databaseEventType,
~~~~~~~~~~~~~~~~~

../../../node_modules/.prisma/client/index.d.ts:14553:7
14553 hidden: boolean
~~~~~~
'hidden' is declared here.

[10:59:41 am] Found 1 error. Watching for file changes.

@RadheyMugdal
Copy link
Contributor Author

Can you pls upload a loom video of the change?

Getting an error on running the api after the changes. I am not getting this error on main. Can you please fix it?

src/modules/organizations/event-types/services/output.service.ts:92:7 - error TS2345: Argument of type 'Input' is not assignable to parameter of type 'Input'. Property 'hidden' is missing in type 'Input' but required in type 'Input'.

92 databaseEventType, ~~~~~~~~~~~~~~~~~

../../../node_modules/.prisma/client/index.d.ts:14553:7 14553 hidden: boolean ~~~~~~ 'hidden' is declared here.

[10:59:41 am] Found 1 error. Watching for file changes.

Got it! I’ll upload the Loom video of the changes soon and will look into the issue and push a fix ASAP.

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 (3)
apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts (2)

31-31: Remove unused import.

The createBooking import appears to be unused in this test file. Consider removing it to keep imports clean.

-import { createBooking } from "@calcom/features/bookings/lib/handleNewBooking/createBooking";

2312-2348: LGTM! Well-structured test with proper setup and cleanup.

This test effectively validates the PATCH endpoint for updating booking locations. The implementation follows existing patterns and includes comprehensive assertions.

Consider these minor enhancements:

  1. The test description could be more specific (e.g., "should update booking location to attendee phone via PATCH")
  2. Consider adding an assertion to verify the location was persisted in the database
  3. The phone number format follows E.164 standard, which is good

The test properly:

  • Creates mock data with appropriate initial state
  • Tests the specific location transformation (attendeePhone type → phone number string)
  • Verifies all critical response fields
  • Performs cleanup to prevent test pollution
packages/platform/types/bookings/2024-08-13/inputs/location.input.ts (1)

215-306: Fix typo and consider error handling improvements

The transformLocation function provides comprehensive location type handling with proper validation and mapping. However, there are a few issues to address:

  1. Fix typo in comment (line 222):
-    // or whatever check that they are not providing a string for bookign location but one of the input objects.
+    // or whatever check that they are not providing a string for booking location but one of the input objects.
  1. Consider improving error message consistency:
    The function throws BadRequestException in two places with different message formats. Consider standardizing the error messages for better consistency.

The logic for handling different location types is comprehensive and the backward compatibility support is well-implemented.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1bcae4 and 9029a20.

📒 Files selected for processing (8)
  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts (1 hunks)
  • apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts (4 hunks)
  • apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts (4 hunks)
  • apps/api/v2/src/ee/bookings/2024-08-13/outputs/update-booking-location.output.ts (1 hunks)
  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts (2 hunks)
  • packages/platform/types/bookings/2024-08-13/inputs/location.input.ts (2 hunks)
  • packages/platform/types/bookings/2024-08-13/inputs/update-booking-location.input.ts (1 hunks)
  • packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.

Files:

  • packages/platform/types/bookings/2024-08-13/inputs/update-booking-location.input.ts
  • apps/api/v2/src/ee/bookings/2024-08-13/outputs/update-booking-location.output.ts
  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
  • apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts
  • packages/platform/types/bookings/2024-08-13/inputs/location.input.ts
  • apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts
  • packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts
🧠 Learnings (3)
apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts (1)

Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.

apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts (1)

Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.

apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts (1)

Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.

🧬 Code Graph Analysis (5)
packages/platform/types/bookings/2024-08-13/inputs/update-booking-location.input.ts (1)
packages/platform/types/bookings/2024-08-13/inputs/location.input.ts (10)
  • ValidateBookingLocation_2024_08_13 (202-213)
  • BookingInputAddressLocation_2024_08_13 (21-28)
  • BookingInputAttendeeAddressLocation_2024_08_13 (101-113)
  • BookingInputAttendeeDefinedLocation_2024_08_13 (124-136)
  • BookingInputAttendeePhoneLocation_2024_08_13 (114-122)
  • BookingInputIntegrationLocation_2024_08_13 (72-80)
  • BookingInputLinkLocation_2024_08_13 (30-37)
  • BookingInputPhoneLocation_2024_08_13 (82-89)
  • BookingInputOrganizersDefaultAppLocation_2024_08_13 (91-99)
  • BookingInputLocation_2024_08_13 (138-146)
apps/api/v2/src/ee/bookings/2024-08-13/outputs/update-booking-location.output.ts (2)
packages/platform/constants/api.ts (2)
  • SUCCESS_STATUS (9-9)
  • ERROR_STATUS (10-10)
packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts (1)
  • UpdateBookingLocationOutputData_2024_08_13 (421-436)
apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts (5)
apps/api/v2/src/modules/auth/guards/api-auth/api-auth.guard.ts (1)
  • ApiAuthGuard (7-20)
apps/api/v2/src/lib/docs/headers.ts (1)
  • API_KEY_OR_ACCESS_TOKEN_HEADER (42-47)
packages/platform/types/bookings/2024-08-13/inputs/update-booking-location.input.ts (1)
  • UpdateBookingLocationInput_2024_08_13 (17-36)
apps/api/v2/src/ee/bookings/2024-08-13/outputs/update-booking-location.output.ts (1)
  • UpdateBookingLocationOutput_2024_08_13 (8-20)
packages/platform/constants/api.ts (1)
  • SUCCESS_STATUS (9-9)
packages/platform/types/bookings/2024-08-13/inputs/location.input.ts (2)
apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts (1)
  • transformLocation (276-367)
apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/api-to-internal/locations.ts (1)
  • apiToInternalintegrationsMapping (14-44)
packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts (1)
packages/platform/types/bookings/2024-08-13/inputs/location.input.ts (1)
  • ValidateBookingLocation_2024_08_13 (202-213)
⏰ Context from checks skipped due to timeout of 90000ms. 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 (10)
apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts (2)

55-56: LGTM: Clean import additions for the new functionality.

The imports are correctly structured and necessary for the new updateBookingLocation method implementation.


1023-1030: LGTM: Well-implemented location update method with proper error handling.

The method implementation follows good practices:

  • Proper input validation by checking if booking exists
  • Appropriate error handling with NotFoundException
  • Clean separation of concerns by delegating location transformation to a utility function
  • Consistent with the service's existing patterns

The method correctly retrieves the booking, validates its existence, transforms the location data using the imported transformLocation function, and delegates the actual update to the repository layer.

apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts (2)

10-10: LGTM: Imports are properly organized

The new imports for UpdateBookingLocationOutput_2024_08_13 and UpdateBookingLocationInput_2024_08_13 are correctly placed and follow the established import structure.

Also applies to: 74-74


32-32: LGTM: Patch decorator import added correctly

The Patch decorator import is properly added to support the new PATCH endpoint.

packages/platform/types/bookings/2024-08-13/inputs/update-booking-location.input.ts (1)

17-36: LGTM: Well-structured input DTO with proper validation

The UpdateBookingLocationInput_2024_08_13 class is well-designed with:

  • Appropriate custom validation using ValidateBookingLocation_2024_08_13
  • Comprehensive Swagger documentation with oneOf schema references
  • Backward compatibility support for string inputs
  • Proper transformation decorator @Type(() => Object)

The implementation follows established patterns and provides good API documentation.

apps/api/v2/src/ee/bookings/2024-08-13/outputs/update-booking-location.output.ts (1)

8-20: LGTM: Standard and well-structured output DTO

The UpdateBookingLocationOutput_2024_08_13 class follows the established pattern for API responses with:

  • Proper status field validation using enum constraints
  • Nested data validation with @ValidateNested() and @Type(() => Object)
  • Comprehensive Swagger documentation with schema references
  • Consistent use of platform constants for status values

The implementation is clean and follows the codebase conventions.

packages/platform/types/bookings/2024-08-13/inputs/location.input.ts (1)

1-1: LGTM: Proper imports added for the new functionality

The new imports for BadRequestException, validation functions (isPhoneNumber, isURL), and the integrations mapping are correctly added to support the transformLocation function.

Also applies to: 4-4, 8-8

packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts (3)

20-20: LGTM: Import added for location validation

The import for ValidateBookingLocation_2024_08_13 is correctly added to support the enhanced location validation in the booking output classes.


240-249: LGTM: Enhanced location property with proper validation

The updates to the location property are well-implemented:

  • Added custom validation decorator ValidateBookingLocation_2024_08_13()
  • Updated API documentation to clarify the location string format
  • Added @Type(() => Object) decorator for proper transformation
  • Made the property optional which aligns with the update functionality
  • Updated example to phone number format for better clarity

These changes enhance the validation and documentation of the location field.


421-436: LGTM: Well-structured output data class

The UpdateBookingLocationOutputData_2024_08_13 class is properly designed with:

  • Consistent validation decorators matching the base booking output
  • Proper Swagger documentation with clear descriptions
  • Required location! field with appropriate typing
  • Consistent use of the custom location validator

The implementation follows the established patterns and provides the necessary structure for the update location response.

Comment on lines +468 to +490
@Patch("/:bookingUid")
@UseGuards(ApiAuthGuard, BookingUidGuard)
@Permissions([BOOKING_WRITE])
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Update the location of a booking",
description:
"Allows updating the location of an existing booking using one of the supported location types.",
})
@HttpCode(HttpStatus.OK)
async updateBookingLocation(
@Body() body: UpdateBookingLocationInput_2024_08_13,
@Param("bookingUid") bookingUid: string
): Promise<UpdateBookingLocationOutput_2024_08_13> {
const booking = await this.bookingsService.updateBookingLocation(bookingUid, body);
return {
status: SUCCESS_STATUS,
data: {
bookingUid: booking.uid,
location: booking.location!,
},
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review the non-null assertion on booking.location

The endpoint implementation looks good overall with proper guards, permissions, and structure. However, there's a potential issue with the non-null assertion on line 487.

-        location: booking.location!,
+        location: booking.location ?? "",

The non-null assertion (!) assumes that booking.location will always be defined after the update operation, but this might not be guaranteed. Consider using nullish coalescing or proper null checking to avoid potential runtime errors.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Patch("/:bookingUid")
@UseGuards(ApiAuthGuard, BookingUidGuard)
@Permissions([BOOKING_WRITE])
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Update the location of a booking",
description:
"Allows updating the location of an existing booking using one of the supported location types.",
})
@HttpCode(HttpStatus.OK)
async updateBookingLocation(
@Body() body: UpdateBookingLocationInput_2024_08_13,
@Param("bookingUid") bookingUid: string
): Promise<UpdateBookingLocationOutput_2024_08_13> {
const booking = await this.bookingsService.updateBookingLocation(bookingUid, body);
return {
status: SUCCESS_STATUS,
data: {
bookingUid: booking.uid,
location: booking.location!,
},
};
}
@Patch("/:bookingUid")
@UseGuards(ApiAuthGuard, BookingUidGuard)
@Permissions([BOOKING_WRITE])
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Update the location of a booking",
description:
"Allows updating the location of an existing booking using one of the supported location types.",
})
@HttpCode(HttpStatus.OK)
async updateBookingLocation(
@Body() body: UpdateBookingLocationInput_2024_08_13,
@Param("bookingUid") bookingUid: string
): Promise<UpdateBookingLocationOutput_2024_08_13> {
const booking = await this.bookingsService.updateBookingLocation(bookingUid, body);
return {
status: SUCCESS_STATUS,
data: {
bookingUid: booking.uid,
location: booking.location ?? "",
},
};
}
🤖 Prompt for AI Agents
In apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts
around lines 468 to 490, the code uses a non-null assertion on booking.location
which may cause runtime errors if location is undefined. To fix this, replace
the non-null assertion with a null check or nullish coalescing operator to
safely handle cases where booking.location might be null or undefined, ensuring
the response does not throw an error.

@RadheyMugdal RadheyMugdal closed this by deleting the head repository Jul 24, 2025
@RadheyMugdal
Copy link
Contributor Author

@kart1ka Hey Sorry, this PR was based on the wrong branch which caused the error you're seeing. I’ve created a clean PR here: #22715

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

Labels

api area: API, enterprise API, access token, OAuth community Created by Linear-GitHub Sync event-types area: event types, event-types ✨ feature New feature or request High priority Created by Linear-GitHub Sync platform Anything related to our platform plan Private Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: v2 api hidden event types

2 participants