Skip to content

feat: Add private links to API #22943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 11, 2025
Merged

Conversation

alishaz-polymath
Copy link
Member

@alishaz-polymath alishaz-polymath commented Aug 7, 2025

What does this PR do?

PR summary

  • Introduced Event Types Private Links API (v2)

    • Base path: /v2/event-types/{eventTypeId}/private-links
    • Endpoints:
      • POST / — create a private link
      • GET / — list private links for an event type
      • PATCH /{linkId} — update a private link
      • DELETE /{linkId} — delete a private link
  • New components

    • EventTypesPrivateLinksController
    • PrivateLinksService, PrivateLinksInputService, PrivateLinksOutputService
    • PrivateLinksRepository
    • Reused EventTypeOwnershipGuard for ownership checks
  • Validation and behavior

    • CreatePrivateLinkInput:
      • expiresAt: string, format date-time
      • maxUsageCount: integer, min 1, default 1
      • Input service enforces one-of semantics and rejects both being present
    • UpdatePrivateLinkInput: supports expiresAt and maxUsageCount updates
    • EventTypeOwnershipGuard returns 400 for missing/invalid eventTypeId, 404 when not owned/not found, and 403 if no user

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?

This is a V2 endpoint, so you would need to run the V2 API and then proceed with the following:

  • Auth

    • Header: Authorization: Bearer <token> (API key prefixed with cal_ or managed user token)
    • Permissions: EVENT_TYPE_READ for GET, EVENT_TYPE_WRITE for POST/PATCH/DELETE
    • Ownership: EventTypeOwnershipGuard enforces the event type belongs to the caller
  • Create

    • POST /v2/event-types/{eventTypeId}/private-links
    • Body (one-of):
      • { "expiresAt": "2025-12-31T23:59:59.000Z" }
      • { "maxUsageCount": 10 }
    • Response: { status: "success", data: TimeBasedPrivateLinkOutput | UsageBasedPrivateLinkOutput }

ℹ If neither expiresAt nor maxUsageCount is provided, it defaults to a one-time private link, so maxUsageCount is taken with the default value of 1

  • List

    • GET /v2/event-types/{eventTypeId}/private-links
    • Response: { status: "success", data: Array<TimeBasedPrivateLinkOutput | UsageBasedPrivateLinkOutput> }
  • Update

    • PATCH /v2/event-types/{eventTypeId}/private-links/{linkId}
    • Body: any subset of { "expiresAt": "…", "maxUsageCount": 5 }
    • Not found: 404 if link doesn’t exist for the event type
    • Response: { status: "success", data: TimeBasedPrivateLinkOutput | UsageBasedPrivateLinkOutput }
  • Delete

    • DELETE /v2/event-types/{eventTypeId}/private-links/{linkId}
    • Not found: 404 if no record was deleted
    • Response: { status: "success", data: { linkId, message } }

Checklist

Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

Adds an Event Types Private Links feature across the API and platform packages. Introduces a NestJS module, controller, repository, input/output/core services, an ownership guard, and e2e tests; wires the module into PlatformEndpointsModule. Adds type and DTO definitions (inputs/outputs) and OpenAPI/Swagger schemas for time-based and usage-based private links. Exposes generateHashedLink and isLinkExpired via a new platform library export and updates HashedLinkService with per-event-type CRUD helpers. Adds tsconfig path alias and updates package exports and versions for platform-libraries. Also appends cal_ai_phone_call to multiple workflow action enums.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/private-links-api-v2

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
🪧 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.
  • 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.

Support

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

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.

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Aug 7, 2025
Copy link

vercel bot commented Aug 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Aug 11, 2025 8:35am
cal-eu ⬜️ Ignored (Inspect) Aug 11, 2025 8:35am

supalarry

This comment was marked as resolved.

supalarry

This comment was marked as resolved.

Copy link
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

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

Review:

Comment on lines 11 to 12
expiresAt: input.expiresAt,
maxUsageCount: input.maxUsageCount,
Copy link
Member Author

Choose a reason for hiding this comment

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

These are both optional so if the user doesn't send either of these in the body, the default action is that it will create a one-time use private link

@dosubot dosubot bot added api area: API, enterprise API, access token, OAuth platform Anything related to our platform plan ✨ feature New feature or request labels Aug 11, 2025
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

This comment was marked as resolved.

2 similar comments

This comment was marked as resolved.

This comment was marked as resolved.

Copy link

graphite-app bot commented Aug 11, 2025

Graphite Automations

"Add ready-for-e2e label" took an action on this PR • (08/11/25)

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

Copy link
Contributor

github-actions bot commented Aug 11, 2025

E2E results are ready!

@alishaz-polymath alishaz-polymath merged commit af51df2 into main Aug 11, 2025
59 of 61 checks passed
@alishaz-polymath alishaz-polymath deleted the feat/private-links-api-v2 branch August 11, 2025 11:04
ThyMinimalDev pushed a commit that referenced this pull request Aug 11, 2025
* --init

* address change requests

* adding further changes

* address feedback

* further changes

* further clean-up

* clean up

* fix module import and others

* add guards

* remove unnecessary comments

* remove unnecessary comments

* cleanup

* sort coderabbig suggestions

* improve check

* chore: bump platform libraries

---------

Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
ThyMinimalDev added a commit that referenced this pull request Aug 11, 2025
…ice class with DI (#22974)

* refactor: convert findQualifiedHostsWithDelegationCredentials to service class with DI

- Create QualifiedHostsService class following UserAvailabilityService pattern
- Add IQualifiedHostsService interface with prisma and bookingRepo dependencies
- Create DI module and container for qualified hosts service
- Update filterHostsBySameRoundRobinHost to accept prisma as parameter
- Update all usage sites to use the new service:
  - loadAndValidateUsers.ts
  - slots/util.ts
  - test mocks in _post.test.ts
- Maintain backward compatibility with original function export
- Fix type issues in team properties (rrResetInterval, rrTimestampBasis)

Co-Authored-By: morgan@cal.com <morgan@cal.com>

* fix: update filterHostsBySameRoundRobinHost test to include prisma parameter

- Add missing prisma parameter to all test function calls
- Resolves unit test failure caused by function signature change

Co-Authored-By: morgan@cal.com <morgan@cal.com>

* fix: resolve type issues in FilterHostsService

- Import PrismaClient type instead of using unknown
- Fix type compatibility for BookingRepository constructor
- Update test mocks to use proper BookingRepository type
- Ensure all DI dependencies are properly typed

Co-Authored-By: morgan@cal.com <morgan@cal.com>

* refactor: rename DI files to CamelCase and update imports

- Rename all files in packages/lib/di from kebab-case to CamelCase
- Update 22 external files with import statements to use new file names
- Update internal DI module files with corrected imports
- Maintain consistency with TypeScript naming conventions

Co-Authored-By: morgan@cal.com <morgan@cal.com>

* chore: bump platform libs

* chore: bump platform libs

* fix: remove obsolete vitest mock after service class refactoring

- Remove obsolete mock for old function module
- Keep correct mock for new DI container
- Resolves CI unit test failures

Co-Authored-By: morgan@cal.com <morgan@cal.com>

* fix: correct import path for calAIPhone zod-utils module

Co-Authored-By: morgan@cal.com <morgan@cal.com>

* fix: Booker active booking limit can't be switched off (#23005)

* refactor: Get rid of `getServerSideProps` for /getting-started pages (#23003)

* refactor

* fix type check

* fix: Remove Reporting page within Routing Forms (#22990)

* fix error in handleNewBooking (#23011)

Co-authored-by: CarinaWolli <wollencarina@gmail.com>

* Documentation edits made through Mintlify web editor (#23007)

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>

* fix: Contact support button position changed from absolute to fixed (#23002)

* feat: Add private links to API (#22943)

* --init

* address change requests

* adding further changes

* address feedback

* further changes

* further clean-up

* clean up

* fix module import and others

* add guards

* remove unnecessary comments

* remove unnecessary comments

* cleanup

* sort coderabbig suggestions

* improve check

* chore: bump platform libraries

---------

Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>

* chore: release v5.5.15

* chore: bump platform libs

* chore: bump platform libs

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: Sahitya Chandra <sahityajb@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
Co-authored-by: Ayush Kumar <kumarayushkumar@protonmail.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
Co-authored-by: emrysal <me@alexvanandel.com>
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 automerge core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request platform Anything related to our platform plan ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants