Compare commits

...
Author SHA1 Message Date
github-actions[bot]andLauris Skraucis 979e1fd28b chore: version packages (#22143)
* chore: version packages

* Update package.json

* Update CHANGELOG.md

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
2025-06-30 07:51:11 +00:00
Lauris Skraucis 3437c4331d fix: changesets atoms size (#22134)
* fix: changesets atoms npm package size

* test changesets entry
2025-06-30 07:22:09 +00:00
github-actions[bot] 616d62094c chore: version packages (#22116)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-29 13:25:48 +02:00
ce7ff1c43c fix(signup): add missing key prop to feature list (#21437) (#21506)
* fix(signup): add missing key prop to feature list (#21437)

* refactor

---------

Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-28 09:27:25 +00:00
Romit e27e41bc16 fix (#22112) 2025-06-28 14:30:54 +05:30
Hariom Balhara 93e183e6c3 fix: Zoom - More logging and fix for unexpected errors seen in logs (#22118)
* fix: Use WEBAPP_URL_FOR_OAUTH to be able to use http://localhost:3000
for local testing

* In case of JSON.parse crash that could happen if zoom reponsed with xml

* Fix cases where auto_recording and default_password_for_scheduled_meetings could be nullish
2025-06-28 08:11:25 +00:00
Lauris Skraucis 88a2bd3317 fix: changesets release memory (#22107)
* chore: increase instance size for changesets

* test release

* Update CHANGELOG.md
2025-06-28 04:37:47 +00:00
Keith Williams 45caaa55b0 chore: Use DBA team for prisma CODEOWNER (#22109) 2025-06-27 23:01:32 +00:00
GitHub Actions 8c9b7a701d chore: release v5.4.9
Post release / release (push) Canceled after 0s
2025-06-27 22:17:36 +00:00
c47b992125 perf: optimize slot conflict checking from O(n²) to O(n log n) (#22101)
* perf: optimize slot conflict checking from O(n²) to O(n log n)

- Replace nested mapping with pre-sorted busy slots for faster lookups
- Use early termination when busy slots are sorted by start time
- Maintain exact same interface and behavior as original checkForConflicts
- All existing tests pass, preserving edge case handling
- Reduces complexity from O(available slots × busy slots) to O(n log n)

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* refactor: move O(n log n) optimization to checkForConflicts function

- Replace inline optimization with optimized checkForConflicts function
- Maintain same performance while improving code architecture
- Avoid duplication of conflict checking logic
- Keep all existing interfaces and behavior unchanged

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* test: add comprehensive unit tests for checkForConflicts function

- Add 20 additional test cases covering edge cases and boundary conditions
- Test multiple busy periods scenarios and complex overlaps
- Comprehensive currentSeats handling scenarios
- Timezone and cross-day boundary testing
- Performance testing with large datasets
- Fix invalid date generation in test data that was causing NaN conflicts
- Achieve near 100% coverage of all conflict scenarios documented in function comments
- Verify behavioral equivalence between original O(n²) and optimized O(n log n) implementations

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* Simple, safe performance tweak

* Explicitly define the input of busy to be either Date or Dayjs, not string

* EventBusyDate must ALWAYS be a type that supports valueOf

* Revert "EventBusyDate must ALWAYS be a type that supports valueOf"

This reverts commit 35b572266219d64c22db3c3e24b0cb6ca7a901a6.

* Revert "Explicitly define the input of busy to be either Date or Dayjs, not string"

This reverts commit 902f29708e4b7990a4e5e2865cab2f18ab3e44f0.

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-06-27 22:10:17 +00:00
Alex van Andel 493c4f89dc Remove redundant logging (#22108) 2025-06-27 21:01:01 +00:00
Lauris Skraucis 27234dc809 fix: changesets memory issue (#22105) 2025-06-27 16:06:13 +00:00
github-actions[bot] 5690b8e1d5 chore: version packages (#22104)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-27 15:19:56 +00:00
Lauris Skraucis 61274bc7ef fix: changesets release (#22103) 2025-06-27 14:37:23 +00:00
github-actions[bot] e66be23996 chore: version packages (#22098)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-27 12:35:20 +00:00
Lauris Skraucis 3c43ce4165 chore: test changesets (#22095)
* chore: test changesets

* bump atoms package.json

* Revert "bump atoms package.json"

This reverts commit 6105f8cf2486085e5da317a6969044693f4a3aa0.

* chore: set packages to private

* ignore private packages

* ignore private
2025-06-27 13:49:28 +02:00
Somay Chauhan 5060824795 fix: EventAvailabilityTab atom breaking (#22059) 2025-06-27 09:40:38 +00:00
c4941f25a2 fix: no available users found (recurring events) (#22033)
* only check first slot

* skip test for second slot availability check

* fixing tests in handleNewRecurringBooking.test.ts

* skip test

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2025-06-27 09:31:56 +00:00
e7c219905f fix: add shape docs to avatar (#20552)
Co-authored-by: Sean Brydon <sean@Seans-Mac-mini.local>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
2025-06-27 09:09:13 +00:00
Udit TakkarandHariom Balhara 499cbd08ca feat: Phone based bookings for everyone (#21320) (#22024)
* Revert "Revert "feat: Phone based bookings for everyone (#21320)" (#22018)"

This reverts commit 80e2118e68.

* chore: don't use repository

* chore: create getTeamWithOrganizationSettings function

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2025-06-27 10:09:04 +01:00
Eunjae Lee 0a3b3a69e3 fix: add InsightsRoutingService and refactor InsightsBookingRepository (#22057)
* chore: convert InsightsBookingRepository to service

* remove repository

* rename

* clean up

* add InsightsRoutingService

* add tests
2025-06-27 11:08:46 +02:00
Lauris Skraucis e8607845e2 fix: changesets atoms release (#22090) 2025-06-27 09:07:02 +00:00
02ef4db0eb feat: Add rerouting to AssignmentReasonRecorder (#19252)
* Add `rerouting` to `AssignmentReasonRecorder`

* Pass session email as `rescheduledBy`

* Write reassign reason

* Edit message

* Use `routingFormRoute` when rerouting

* Pass isRerouting & reroutedByEmail to `routingFormRoute` method

* Type fix

* Fix test

* Fix test

* Fix test

* Type fix

* Refactor to use UserRepository

* Show rerouted by email

* Replace isReroutingCase

* Fix rescheduledBy for new tab reschduling

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Hariom <hariombalhara@gmail.com>
2025-06-27 10:06:39 +01:00
sean-brydon f8d48a341d show icon button when one item in array (#22054) 2025-06-27 07:52:18 +00:00
GitHub Actions 251393101a chore: release v5.4.8
Post release / release (push) Canceled after 0s
2025-06-26 23:56:56 +00:00
Joe Au-Yeung b50430114f Disable setting profile picture (#22074) 2025-06-26 23:48:38 +00:00
Joe Au-Yeung b0999abc68 fix: Generate new idempotency key when round robin reassigning (#22065)
* Create idempotencyKeyService

* Use `idempotencyKeyService` in middleware

* Use `idempotencyKeyService` in RR reassignments
2025-06-26 17:43:31 +00:00
Lauris Skraucis 2bbd92db13 chore: bump platform libraries (#22063) 2025-06-26 15:26:07 +00:00
Eunjae Lee 64092abdca fix: make uuid of App_RoutingForms_FormResponse nullable (#22056) 2025-06-26 10:42:45 +00:00
Sarthak KapilaandKartik Saini b7b631f0b0 fix: Persist filters across tabs to improve user experience (#21706)
* fix: Persist filters across tabs to improve user experience

* fixes unnecessary renders

---------

Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com>
2025-06-26 10:04:53 +00:00
Anik Dhabal Babu c10f15e75b fix: google calendar event creation failure due to invalid timezone (#22048)
* fix: google calendar event creation failure

* update

* fix type error

* Update TimezoneSelect.tsx
2025-06-26 09:36:44 +00:00
Somay Chauhan 6983179b2f fix: handle existing oAuth client ID in user email to prevent duplication (#22021)
* fix: handle existing oAuth client ID in user email to prevent duplication

* fix: update OAuth user email validation
2025-06-26 08:29:29 +00:00
devin-ai-integration[bot]andeunjae@cal.com aea0661303 feat: disable changing field type of routing forms if responses exist (#21911)
* feat: add field type change warning dialog to routing forms

- Add FieldTypeChangeWarningDialog component to prevent field type changes
- Show informative dialog explaining data integrity concerns when users try to change field types
- Provide alternative suggestion to create new field instead of changing existing one
- Add i18n translations for dialog messages
- Integrate dialog into routing form edit page field type selector
- Bypass Teams plan restriction for testing routing forms functionality
- Fix ESLint error by properly handling scrollIntoView in embed mode with disable comment

Prevents data integrity issues by blocking field type changes (e.g. multiselect → text)
that could make existing form responses incompatible and cause data loss.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: make field type dialog more selective to allow legitimate changes during form creation

- Only show warning dialog when there's actual data integrity risk
- Allow field type changes for new fields or fields without meaningful labels
- Fixes E2E test timeout by not blocking legitimate field type changes
- Maintains data protection for existing fields with real data

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: complete field type dialog implementation with translations and component

- Add FieldTypeChangeWarningDialog component with proper i18n support
- Add all required translation strings for dialog messages
- Ensure dialog only shows for actual data integrity risks
- Allow legitimate field type changes during form creation

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* simplify field type dialog: one button, button replaces SelectField, remove forms page changes

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* use Button component

* feat: restore SelectField with conditional dialog for field type changes

- Restore original SelectField dropdown to allow users to see available field types
- Add conditional logic to show dialog only when different type is selected AND form has responses
- Prevent field type changes by not calling onChange when dialog is shown
- Pass hasFormResponses prop from FormEdit to Field component
- Maintain data integrity while providing clear user guidance

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* controlled value

* convert dialog to tooltip

* Update common.json

* remove unused texts

* allow type changing for new field

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-06-26 07:58:05 +00:00
Eunjae LeeandBenny Joo 3fd9ef366f fix: add InsightsBookingRepository (#22003)
* fix: add InsightsBookingRepository WIP

* write integration tests

* remove log

---------

Co-authored-by: Benny Joo <sldisek783@gmail.com>
2025-06-26 07:57:08 +00:00
GitHub Actions cf79a3f580 chore: release v5.4.7
Post release / release (push) Canceled after 0s
2025-06-25 23:25:56 +00:00
Joe Au-Yeung c5da78593a Fix import (#22020) 2025-06-25 23:15:04 +01:00
Benny Joo 801b0be414 perf: optimize fetch for primary google calendar (#22041)
* perf: optimize getting primary google calendar

* add test

* use calendars

* safer
2025-06-25 23:10:25 +01:00
RomitandBenny Joo 29aad2c535 fix: error because Seated slot reservations do not pass bookingUid (#22022)
* fixed query

* Update reserveSlot.handler.ts

---------

Co-authored-by: Benny Joo <sldisek783@gmail.com>
2025-06-25 21:56:32 +00:00
Carina WollendorferandCarinaWolli 82d3b9d29d only update reminders for EMAIL_HOST action (#22027)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-06-25 20:54:19 +00:00
devin-ai-integration[bot]andmorgan@cal.com a542ba486c feat: add graceful webhook secret validation to billing controller (#22034)
* feat: add graceful webhook secret validation to billing controller

- Wrap Stripe constructEventAsync in try-catch block
- Add proper error logging for failed webhook signature validation
- Return appropriate error responses for invalid webhook secrets
- Follow existing webhook handler patterns from payments module

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

* refactor: use specific Stripe error type for webhook signature validation

- Import Stripe types to access StripeSignatureVerificationError
- Check for specific Stripe signature verification error type
- Throw BadRequestException for invalid webhook signatures
- Maintain generic error handling for other webhook processing errors

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

* refactor: throw BadRequestException for missing webhook signature and secret

- Use BadRequestException instead of generic Error for missing stripe-signature header
- Use BadRequestException instead of generic Error for missing webhook secret configuration
- Consistent error handling with appropriate HTTP status codes

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

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
2025-06-25 20:39:46 +00:00
Benny Joo d50e1a0e15 feat: Leverage ErrorCode cases for correct error codes in server responses (#22023)
* Leverage ErrorCode cases for correct error codes in server responses

* better test

* fix
2025-06-25 13:18:01 -07:00
Anik Dhabal Babu 79a0071d65 fix: e2e tests failure (#22043)
* fix: delete dilog button not visible

* fix: test failure
2025-06-25 15:59:03 -03:00
MorganandAlex van Andel 2f1f989266 feat: allow setting DAILY VIDEO region via env (#21939)
* feat: allow setting DAILY VIDEO region via env

* add comments

* Cleaner approach to Daily video region type assertion

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-06-25 18:01:40 +03:00
Eunjae Lee 2303eb7908 fix: add uuid to App_RoutingForms_FormResponse (#21910)
* fix: add uuid to App_RoutingForms_FormResponse

* update RoutingFormResponseDenormalized

* fix type error
2025-06-25 10:49:20 -04:00
Benny Joo c3666dd064 feat: correct error codes in responses for /social/og/image (#22015)
* fix error codes in og/image route

* test

* simplify
2025-06-25 11:24:34 -03:00
6ed197d35c fix: Org creation for self-hosters (#21994)
* Restart form if admin is not org admin

* Show pricing is admin and hosted

* Only show billing specific fields when enabled

* Create user onboarding only if valid valid license when self hosting

* Reset store when org creation is completed

* Create schema for trpc input when creating an org

* Add `organization.createSelfHosted` trpc endpoint

* `createOrganizationFromOnboarding` do not require stripe data

* Create organization without billing if self-hosted admin

* Update organizationOnboarding record as completed

* Handle updating subscription for self hosters

* Refactor `isBillingEnabled` to store

* Type fix

* Fix admin org creation for hosted

* Hide UI from admin

* Add tests

* fix: Fix LicenseKeySingleton mocking in organization tests

- Add proper vi.mock() module-level mocking for LicenseKeySingleton
- Replace incorrect casting syntax with vi.mocked() approach
- Add LicenseKeySingleton mock to hosted tests in intentToCreateOrg.handler.test.ts
- Fix IS_SELF_HOSTED mocking for hosted vs self-hosted test scenarios
- All organization creation tests now pass locally

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

* Fix tests

* Fix tests

* Test fixes

* Type fix

* Type fix

* Type fix

* Update packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.test.ts

Fix typo

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* fix: Add IS_SELF_HOSTED mocking for E2E organization creation tests

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

* Fix E2E test

* Address feedback

* Type fix

* Fix e2e tests

* Remove unused code

* Small fixes

* fix unit tests

* review fixes

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: joe@cal.com <joe@cal.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Hariom <hariombalhara@gmail.com>
2025-06-25 16:58:18 +03:00
devin-ai-integration[bot]andmorgan@cal.com 164c9e37d7 feat: add /v2/billing/webhook route to RawBodyMiddleware configuration (#22032)
- Add /v2/billing/webhook alongside existing /api/v2/billing/webhook route
- Both routes now use RawBodyMiddleware for proper Stripe webhook signature verification
- Leverages NestJS forRoutes() method to accept multiple route configurations

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
2025-06-25 15:21:56 +03:00
Hariom Balharaandcubic-dev-ai[bot] fa0a18b31d fix: Allow backgroundSlotsFetch option to disable slots fetching during prerender (#21999)
* fix: Allow noBackgroundSlotsFetch option to disable slots fetching
during prerender

* Update packages/embeds/embed-core/src/embed-iframe.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-25 10:38:35 +00:00
Benny Joo 80e2118e68 Revert "feat: Phone based bookings for everyone (#21320)" (#22018)
This reverts commit 866a0e2596.
2025-06-25 02:32:09 +00:00
GitHub Actions ed5086df6b chore: release v5.4.6
Post release / release (push) Canceled after 0s
2025-06-24 23:10:17 +00:00
Alex van Andel 218ec9140c Revert "perf: Refactor getPublicEvent to fetch org data using DB index key (#21850)"
This reverts commit a37f1d9798.
2025-06-24 16:37:36 +01:00
Hariom Balhara 6dad0e7679 fix-avoid-cross-domain-xhr (#22008) 2025-06-24 15:08:43 +00:00
Dhairyashil ShindeandKartik Saini cb96a56960 feat: Preserve past SMS workflow reminders by disabling deletion (#21906)
* Preserve past SMS workflow reminders by disabling deletion

* Restored code to delete SMS reminder worflows that fallback to EMAIL

---------

Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com>
2025-06-24 12:01:08 +02:00
thegrasshopper104 b35eb77edb fixing hungarian translation (#21995) 2025-06-24 09:21:05 +00:00
Syed Ali Shahbaz 89408ce12b Update webhooks.mdx (#21900) 2025-06-24 07:50:07 +00:00
e22d9a551c fix: Theme class names for embed elements (#21275)
* refactor(embed-core): update theme class names for consistency

Standardize theme class names to use 'cal-element-embed-dark' and 'cal-element-embed-light' to improve maintainability and clarity.

* refactor(embed-core): replace theme class strings with constants

* fix theme not changing

---------

Co-authored-by: Tushar Bhatt <95581504+TusharBhatt1@users.noreply.github.com>
Co-authored-by: Hariom <hariombalhara@gmail.com>
2025-06-24 07:26:48 +00:00
Carina WollendorferandCarinaWolli c215dc5864 fix: credit balance issues (#21904)
* fix creating user balance

* fix org check if teamId is given

* adjust hasAvailableCredits function

* improve comments

* fix creditBalance.create

* adjust test

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-06-24 09:18:14 +02:00
Benny Joo a37f1d9798 perf: Refactor getPublicEvent to fetch org data using DB index key (#21850)
* wip

* fix

* fix naming

* fix typecheck
2025-06-23 23:01:06 +01:00
Benny Joo 07c8bbc562 fix: crash due to lack of input validation in WizardForm (#21990)
* fix: crash due to lack of input validation in WizardForm

* server side validation

* refactor

* refactor
2025-06-23 17:03:51 -03:00
Omar López b381cfe207 fix: Downgrades typescript to 5.7.2 (#21956) 2025-06-23 18:31:47 +00:00
Anik Dhabal Babu a560b9c8f4 fix: Add error log for zoom (#21991)
* fix: delete dilog button not visible

* fix: add log
2025-06-23 18:29:12 +00:00
Anik Dhabal Babu e5b8cc6912 fix: booking title translation issue (#21943)
* fix: add log to check organizer

* update

* Update CalendarService.ts
2025-06-23 18:23:31 +00:00
Somay ChauhanandRajiv Sahal 18b5612c0d feat: add apps filter and bulk update toggle to conferencing apps atom (#21973)
* feat: add apps filter and bulk update toggle to conferencing apps atom

* docs: clarify description of disableBulkUpdateEventTypes flag in conferencing apps docs

* docs: update valid conferencing app slugs in atoms documentation

---------

Co-authored-by: Rajiv Sahal <sahalrajiv-extc@atharvacoe.ac.in>
2025-06-23 22:59:44 +05:30
Anik Dhabal Babu fad488623f Revert "fix: multi-line formatted correctly for sms (#21779)" (#21979)
This reverts commit 5e2f06cdea.
2025-06-23 16:00:43 +00:00
Romit.andAnik Dhabal Babu c490f084dc fix: background of event advanced questions section in dark theme (#21985)
* fixed bg of event advanced questions

* Update EventAdvancedTab.tsx

* Update EventAdvancedTab.tsx

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-23 15:33:32 +00:00
Joe Au-Yeung b1caacd643 Disable tRPC endpoint on slots fetch failure (#21986) 2025-06-23 15:17:33 +00:00
Udit Takkar 76c8876923 fix: don't fetch calendar for top banner (#21908) 2025-06-23 09:00:44 -03:00
Hariom Balhara a911c9cb8d Make props optiona (#21977) 2025-06-23 11:52:10 +00:00
devin-ai-integration[bot]andeunjae@cal.com 07d5594085 feat: add integration test for RoutingFormResponseField triggers (#21586)
* feat: add integration test for RoutingFormResponseField triggers

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor: remove changing field types test case

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-06-23 10:11:20 +00:00
Benny JooandAnik Dhabal Babu a745d8a60a fix: error in /auth/session (#21972)
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-23 08:32:14 +00:00
Dhairyashil ShindeandSomay Chauhan 8b83d39ac3 feat: Add onTimeslotsLoaded prop to Booker atom (#21871)
* [CAL-5926] Add 'onTimeslotsLoaded' prop to 'Booker' atom

* Added 'onTimeslotsLoaded' to BookerPlatformWrapperAtomProps

* fixed type error and added onTimeslotsLoaded prop to doc

---------

Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
2025-06-23 08:13:36 +00:00
4edb39616d feat: download credit expense log button (#21771)
* add smsSegments to creditExpenseLog

* add download button

* download only data from selected month

* improvements

* improve design

* use repository function

* add tests for credit repository

* fix type error

* fix unit test

* fix type error

* fix unit test

* code clean up

* fix skeleton loader

* remove empty mt

* code clean up

* move csv headers out of function

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
2025-06-23 03:57:32 -04:00
Somay ChauhanandAnik Dhabal Babu 7a2060fe08 fix: dont expose credential.key in api output (#21970)
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-23 07:09:44 +00:00
Omar López d009682d4a Revert "perf: deduplicating DB fetches + leverage unique DB index for team ty…" (#21969)
This reverts commit 7900be3a30.
2025-06-23 04:12:20 +00:00
Amit Sharma 8adb720a80 fix: Double skeleton apps page (#21965) 2025-06-22 18:24:16 -04:00
Omar López 4d6f338f0c Revert "Update draft-release.yml (#21932)" (#21966)
This reverts commit 04e60611ed.
2025-06-22 19:50:46 +00:00
Morgan ffe9d43d09 chore: better trpc error handling (#21948) 2025-06-21 11:56:23 +05:30
Alex van AndelandOmar López 2227b4ff91 chore: Lower the threshold for eager token expiration (#20964)
Co-authored-by: Omar López <zomars@me.com>
2025-06-20 14:33:23 -04:00
Benny JooandKeith Williams 5dd4937a1a chore: add e2e test for ai translation (#18061)
* make createNewEventType receive description arg

* remove @test tag

* wip

* wip2

* remove @test tag

* modify EventMetaProps

* add test id event-meta-description

* improve test

* better name

* try

* finalized

* fix

* fix type check

* address comment

* cleann up

* cleann up

* fix

* Update ai-translation.e2e.ts

* fix

* simplify

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-06-20 23:00:39 +05:30
866a0e2596 feat: Phone based bookings for everyone (#21320)
* feat: Phone based bookings for everyone

* chore: save progress

* feat: add UI

* chore: UI

* chore: remove sms notification

* chore: remove none

* chore: remove ligs

* chore: remove log

* test: add unit tests

* test: add unit tests

* chore: cache _isSMSNotificationEnabled

* chore: cache _isSMSNotificationEnabled

* refactor: get value from fields

* fix: type err

* chore: also pass  user id

* fix: unit test for sms manager

---------

Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-06-20 12:42:32 -04:00
GitHub Actions 64bfda9dbe chore: release v5.4.5
Post release / release (push) Canceled after 0s
2025-06-20 14:53:05 +00:00
Udit TakkarandHariom aacbbc1785 fix: Rate limit /router endpoint (#21940)
* fix: add rate limiting for /router/embed

* Abstract out hashing code

---------

Co-authored-by: Hariom <hariombalhara@gmail.com>
2025-06-20 14:47:56 +00:00
Anik Dhabal Babuandcubic-dev-ai[bot] 3714d5faab fix: routing form redirects to use app.cal.com instead of cal.com (#21924)
* fix: routing form redirects to use app.cal.com instead of cal.com

* Update packages/lib/hooks/useBookerUrl.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* update

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-20 17:22:53 +05:30
Kartik Saini 12cb94950a fix: ui (#21936) 2025-06-20 10:16:09 +00:00
Somay Chauhan 795fd788e2 feat: add response status to calendar event host details (#21934)
* feat: add response status to calendar event host details

* docs: update calendar event response status description from attendee to host
2025-06-20 07:23:18 +00:00
devin-ai-integration[bot]andeunjae@cal.com 956fd6ae2f feat: add attendee data to CSV export with seated event support (#21842)
* feat: add attendee data to CSV export with seated event support

- Add up to 3 attendees to CSV export in 'name (email)' format
- Use booking.seatsReferences for seated events, booking.attendees for regular events
- Maintain backward compatibility with existing bookerEmail/bookerName fields
- Add attendee1, attendee2, attendee3 columns to CSV output

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: restore missing comment as requested in PR review

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* Update packages/features/insights/server/events.ts

* feat: remove duplicate booker columns from CSV export

- Remove bookerEmail and bookerName columns as they duplicate attendee data
- Remove noShowGuest field which was based on booker data
- Remove unused booker field from bookingMap
- Keep only attendee1, attendee2, attendee3 columns with name (email) format

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* feat: restore noShowGuest field to CSV export

- Add noShowGuest field mapping from first attendee's noShow property
- Maintain existing attendee1, attendee2, attendee3 columns
- Default to false when no attendees exist
- Works with both seated events and regular events

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* rename column

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-06-20 08:11:08 +01:00
Omar López 04e60611ed Update draft-release.yml (#21932) 2025-06-20 03:31:45 +00:00
GitHub Actions bc99e9e504 chore: release v5.4.4
Post release / release (push) Canceled after 0s
2025-06-19 21:18:47 +00:00
FaizandKartik Saini 2f35428232 fix: align tick icon, text, and cross icon inside toaster (#21607)
* Fix: align tick icon, text, and cross icon inside toaster

* fix: align elements in toaster

* fix: toaster icon changes

* test approval recheck

* fix: toast message id fixed

* fix: merge conflict resolved

* fix:test recheck

---------

Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com>
2025-06-19 16:27:35 +00:00
Adarsh Tiwari 00aac89ed7 fix:multiple buttons (#21928) 2025-06-19 15:08:47 +00:00
Anik Dhabal Babu f390e91bd7 fix: can save an event type without a slug (#21922) 2025-06-19 15:03:58 +00:00
Ayush Mukkanwar e413359c8c fix(i18n): correct Serbian translation for scheduled event (#21235) (#21925)
* fix(i18n): correct Serbian translation for scheduled event (#21235)

* fix(i18n): normalize all Serbian translations to use correct 'događaj' forms
2025-06-19 20:09:40 +05:30
Anik Dhabal Babu 601df7f808 fix: Slots are available even after exceeding the booking limits for the team event (#21801)
* fix: slots available

* fix type error

* update

* update
2025-06-19 20:05:43 +05:30
Syed Ali Shahbazandsupalarry e160a4add0 feat: Schedule restriction and booker timezone (#21452)
* init migration and fix name for team event availability toggle

* show and save restriction schedule

* better naming around

* fix loading stored restricted schedule instead of default

* add the booker timezone checkbox in the form

* restriction schedule application babbbyyyy

* remove logs

* test

* typefix

* fix

* fix??

* fix???

* ---

* typefix

* functional fix

* restrictionschedule logic --1

* timezone adjustment for regular constraint

* noice

* test suite for restrictionSchedule

* auth restrictionschedule for eventtype

* remove unnecessary comments

* index

* type fix

* add concurrent

* resolve change request

* fix unauth erro

* type fix

* schedule select extracted from select

* revert

* fix auth vulnerabililty

* fix e22

* chore: hide restriction schedule on platform

* init review feedback resolutions

* fixes

* fix type

* multiple windows of recurring rule-same day

* team feature flag

* fix type err

* fix type

* improvements

* fix test

* improve

* fix error propagation

* fix unused var lint

* cleanup and using buildDateRanges

* travel schedule inclusion

* address comment

---------

Co-authored-by: supalarry <laurisskraucis@gmail.com>
2025-06-19 14:08:51 +01:00
GitHub Actions 3bea03f4b1 chore: release v5.4.3
Post release / release (push) Canceled after 0s
2025-06-19 07:57:24 +00:00
Hariom Balhara 19dbde8a3c Add comment (#21920) 2025-06-19 05:55:42 +00:00
Syed Ali Shahbaz a5fe10189f fix: Banner uploader fix error handling and reduce image size jump (#21903)
* improve uploader

* better error handling

* unnecessary check

* more adjustments

* remove logs
2025-06-19 03:35:41 +00:00
Adarsh Tiwari 7075384313 fix:hover on delete action on event-types (#21884) 2025-06-18 21:47:47 +00:00
Udit Takkar 25bf43cddd perf: improve invalid app credential query (#21909) 2025-06-19 02:29:33 +05:30
Udit Takkar 2880a681a8 feat: disable transcription setting in cal video (#21755)
* feat: disable transcription setting in cal video

* fix: type err
2025-06-18 14:36:36 +00:00
bbcd0b7e78 test: add unit tests to various important fns in routing flow (#21902)
* Add unit tests to routing flow

* fix: resolve TypeScript errors in routing forms test files

- Fix mock form structure to match TargetRoutingFormForResponse type
- Add missing properties like selectText, deleted, updatedById to form fields
- Correct route action types to use valid RouteActionType enum values
- Fix response objects to include required label property
- Update mock return values for findTeamMembersMatchingAttributeLogic
- Use proper type assertions for complex route objects

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

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: hariom@cal.com <hariom@cal.com>
2025-06-18 14:14:14 +00:00
Adarsh Tiwari 916ed13bea fix the height of buttons in override list (#21898) 2025-06-18 12:41:28 +00:00
Alex van Andel 11a06324be fix: 'handles OOO correctly' test fail in non-UTC servertime (#21899) 2025-06-18 12:28:32 +01:00
Hariom Balhara bcb340d97e fix: Dry Run for non-pre-render scenario (#21893)
* Fix dry-run non-prerender scenario

* Add test

* Enable logging through cal.embed.logging=1
2025-06-18 10:27:44 +01:00
Somay Chauhanandcubic-dev-ai[bot] aabef47ff1 fix: microsoft oAuth in api/v2 (#21890)
* fix: microsoft oAuth in api/v2

* Update apps/api/v2/src/ee/calendars/services/gcal.service.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* Update gcal.service.ts

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-18 07:34:42 +00:00
Benny Joo e27de47d9f perf: leverage DB index for user profile fetching (booking page & payment page) (#21814)
* leverage DB index for findByUserIdAndOrgSlug method

* booking view

* payment view

* fix

* fix

* address comment
2025-06-18 09:53:12 +03:00
Benny Joo 7900be3a30 perf: deduplicating DB fetches + leverage unique DB index for team type booking page (#21811)
* wip

* refactor

* refactor

* fix

* optimize

* better

* comment

* better code

* do not use cache for now

* simplify
2025-06-18 09:53:04 +03:00
Joe Au-YeungandOmar López ddc5838c7b Change to OR operator (#21881)
Co-authored-by: Omar López <zomars@me.com>
2025-06-17 23:04:38 +00:00
6a13d7c5c6 fix: update trigger function for RoutingFormResponseField (#21868)
* fix: update trigger function for RoutingFormResponseField

* Update packages/prisma/migrations/20250617123959_update_handle_routing_form_response_fields/migration.sql

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* add reusable function

* handle number type more flexibly

* handle multiselect value flexibly

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
2025-06-17 20:47:43 +02:00
GitHub Actions 4f0b35d9e2 chore: release v5.4.2
Post release / release (push) Canceled after 0s
2025-06-17 16:11:09 +00:00
Joe Au-Yeung 3b19ede6a3 Add logging (#21874) 2025-06-17 15:58:58 +00:00
Hariom Balhara 1a0ce47404 fix: Dry run in prerender flow (#21876)
* fix dry run in queued flow

* All zeros uuid
2025-06-17 15:53:23 +00:00
22f136d19b feat: Headless router - queue recording booking response (#21805)
* Add queued booking response table

* Create `RoutingFormResponseRepository`

* Pass `queueFormResponse` param

* Queue up form response if param is passed

* Forward queued form response parma to booker

* Pass `queuedFormResponse` from booker to `handleNewBooking`

* Write queued routing form response

* Type fixes

* Clean up

* Allow dry run to work which wont have any QueuedFormResponse or FormResponse

* Support passing the time when the modal was actually shown to the user and consider that time as the time of form submission

* fix ts error

* Queue -> Response through separate endpoint that would be triggered by
embed

* Make queueResponseId a non-guessable uid

* Change queueFormResponse query param

* fix ts error

* Support useQueuedResponse to record new response data

* revert handleNewBooking

* Remove dead code formResponse

* Refactor use repository

* Unify migration files

* refactor: moved api endpoint to app dir

Signed-off-by: Omar López <zomars@me.com>

* Update formResponse.ts

* Refactor use-queued-response for test

* Add tests

* Fix ts error and unit test. recordFormResponse cant return nullish response

* fix schema

* feat: Support full reuse of preloaded iframe (#21803)

* feat: support updating cal video settings in API v2 (#21784)

* feat: support updating cal video settings in API v2

* chore: update descriptio

* feat: support create event type

* test: add test for updating event type

* test: add test for create event type

* chore: undo openapi

* chore: bump libraries

* Revert "chore: bump libraries"

This reverts commit bdf36d09b021fc531497a7b7ea66ab9c52b7d136.

* chore: bump libraries

---------

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

* fix tests and ts

* Fix tests

* wip-useQueuedResponseEndpoint

* Add one more test

* Change queueFormResponse query param

* wip

* Support useQueuedResponse to record new response data

* Use the update useQueuedResponse endpoint

* self-review addressed

* Use queuedResponse if available in slots/utils

* Add documentation

* Remove use-queued-response from critical-path

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>

* Update schema.prisma

* refactor: renamed to avoid react hooks confusion

Signed-off-by: Omar López <zomars@me.com>

---------

Signed-off-by: Omar López <zomars@me.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
2025-06-17 12:11:49 -03:00
Lauris Skraucis 9a40e54159 refactor: seated booking reschedule error message (#21841) 2025-06-17 14:11:50 +00:00
229f2627c8 fix: Add Guests dialog for Bookings (#21669)
* fixedAddUsers

* Update packages/ui/components/address/MultiEmailLazy.tsx

---------

Co-authored-by: layand12 <d.layan@unque.me>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
2025-06-17 13:32:23 +00:00
GitHub Actions 6f6454df40 chore: release v5.4.1
Post release / release (push) Canceled after 0s
2025-06-17 13:27:30 +00:00
Morgan 3da9fc5500 chore: add global prefix to api v2 via env variable for selfhost (#21860) 2025-06-17 12:55:15 +00:00
Lauris Skraucis 540bf868b5 fix: event type settings atom not saving (#21864)
* chore: specify atoms version

* fix: saving event type settings
2025-06-17 12:09:37 +00:00
Anik Dhabal Babu 1674ecc585 fix: replyTo includes the correct email (#21843)
* fix: delete dilog button not visible

* fix: replyTo includes the correct email

* Update getReplyToHeader.ts
2025-06-17 10:45:44 +00:00
4920abdaf7 feat: optimize Prisma queries by replacing findFirst with findUnique where applicable (#21826)
* feat: optimize Prisma queries by replacing findFirst with findUnique where applicable

- Replace findFirst/findFirstOrThrow with findUnique/findUniqueOrThrow for queries using unique constraints
- Maintain existing functionality and error handling behavior
- Focus on queries using primary keys and unique index fields from schema
- Revert problematic changes that caused test failures to maintain stability

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

* revert: exclude API files from Prisma query optimizations per user request

- Reverted all 55 API-related files to their original state
- Kept all non-API Prisma query optimizations intact
- API files include apps/api/v1, apps/api/v2, apps/web/app/api, and packages/app-store/*/api
- Non-API optimizations remain for packages/lib, packages/features, apps/web (non-api), etc.

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

* feat: optimize membership query in attributeUtils to use findUnique with userId_teamId constraint

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

* revert: exclude test files from Prisma query optimizations per user request

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

* revert: revert attributeUtils.ts to use findFirst for test compatibility

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

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: benny@cal.com <benny@cal.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-17 09:52:02 +03:00
Somay Chauhan a6b98bd35d docs: expand Google Calendar event ID description with API endpoint references (#21857) 2025-06-17 07:02:50 +02:00
Lauris Skraucis 34d4f394fc fix: v2 event type disable guests (#21753)
* fix: v2 event type disable guests

* fix: implement cubic feedback
2025-06-17 10:15:46 +05:30
Joe Au-Yeung a4ef8d4200 Auto review seeded orgs (#21856) 2025-06-17 03:40:56 +00:00
Lauris Skraucis 9d9662687e docs: v2 cancelling seated booking as a host (#21744)
* docs: cancel seated bookings as attendee or host

* test: cancelling seated booking as host
2025-06-17 09:06:17 +05:30
Anik Dhabal Babu 2d41c719c4 fix: reschedule and cancel unconfirmed event from email (#21844) 2025-06-16 17:13:38 +00:00
b69bd966a6 fix: duplicate workflow reminders caused by scanWorkflowBody (#21767)
* don't scan if there is newer task

* create seperate tasks per workflowStepId

* revert changed constant

* fix comment

* add back missing import

* code clean up

* fix PR feedback

* change function to hasNewerScanTaskForStepId

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-16 14:25:41 +00:00
GitHub Actions 09a49dd0fd chore: release v5.4.0
Post release / release (push) Canceled after 0s
2025-06-16 13:00:34 +00:00
MorganandAnik Dhabal Babu 3dd3372c35 fix: getBookings for team admins within orgs (#21833)
* fix: getBookings for team admins within orgs

* fixup! fix: getBookings for team admins within orgs

* chore: update getUserIdsAndEmailsWhereUserIsAdminOrOwner and remove unused orgId

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-16 09:34:02 -03:00
Anik Dhabal Babu 0a60864310 fix: Few flaky e2e test (#21818)
* fix: delete dilog button not visible

* fix: flaky e2e tests

* Update booking.e2e.ts

* update

* Update booking.e2e.ts

* update

* Update booking.e2e.ts

* Update booking.e2e.ts
2025-06-16 09:51:37 +00:00
Benny Joo cb24e5d0aa perf: remove 2 DB fetches by removing getFacetedValues (#21808)
* perf: remove 2 server fetches by removing getFacetedValues

* fix

* fix

* use set

* fix
2025-06-15 11:31:11 +00:00
Romit. 8c5aebdca1 ux improve (#21815) 2025-06-15 11:30:34 +00:00
GitHub Actions 4e2cff0fd5 chore: release v5.3.13
Post release / release (push) Canceled after 0s
2025-06-14 00:13:45 +00:00
Joe Au-Yeungandromit 54e518efad feat: Allow reschedule when max booker bookings have been reached (#21778)
* feat - Restrict same email to create more than 'n' active bookings at a time

* updated checkbookerbookinglimit function

* type fix

* minor change

* import fix

* minor fixes

* back to null on disable

* back

* type check

* managed edge cases

* chore: name changes

* name changes

* fix

* minor change

* changed name

* use default value for maxactivebookingsperbooker, and some minor changes

* disabling bookerbooking limit for recurring event

* disabling bookerbooking limit for recurring event

* type fix

* ui fix and backend eventtype update check

* Add `maxActiveBookingPerBookerOfferReschedule` to schema

* Create `MaxActiveBookingsPerBookerController` and offer reschedule option

* Add offer reschedule to event type form data

* Pass data through to HttpError

* When checking max bookings, return last booking info if applicable

* removed unused code

* minor changes

* update validation

* chore

* Do not check booking limits if rescheduling

* Add data for reschedule

* Add reschedule specific error code

* On maximum booking error, write to booker store reschedule params

* Add translations for error codes

* Write to error message previous booking time

* minor fix

* Write to error message previous booking time

* Type fixes

* Clean up comment

* Refactor eventType update errors

* Typo fix

* Type fix

* Type fix

* Type fix

* Fix test

* Fix test

* Add migration

* Addressed feedback and missed merges

---------

Co-authored-by: romit <romitgabani@icloud.com>
2025-06-13 23:54:33 +00:00
Joe Au-Yeung ad93099171 refactor: Do not consider event type id in idempotency key (#21681)
* Update idempotency key

* Remove console.log
2025-06-13 21:54:49 +01:00
Romit.andJoe Au-Yeung 630065ca89 feat: Restrict same email to create more than 'n' active bookings at… (#21745)
* feat - Restrict same email to create more than 'n' active bookings at a time

* updated checkbookerbookinglimit function

* type fix

* minor change

* import fix

* minor fixes

* back to null on disable

* back

* type check

* managed edge cases

* chore: name changes

* name changes

* fix

* minor change

* changed name

* use default value for maxactivebookingsperbooker, and some minor changes

* disabling bookerbooking limit for recurring event

* disabling bookerbooking limit for recurring event

* type fix

* ui fix and backend eventtype update check

* removed unused code

* minor changes

* update validation

* chore

* Do not check booking limits if rescheduling

* minor fix

* Refactor eventType update errors

* Typo fix

---------

Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
2025-06-13 20:52:22 +00:00
Sarthak Kapila ddf5717992 fix: slots rescheduleUid (#21626) 2025-06-13 17:36:20 +00:00
Lauris Skraucis 4a53ec0b74 feat: platform toggle calendar event creation (#21788)
* feat: add areCalendarEventsEnabled to PlatformOAuthClient table

* feat: areCalendarEvents enabled in handleNewBooking and v2

* feat: v2 handle areCalendarEventsEnabled

* feat: toggle areCalendarEventsEnabled on frontend

* feat: enable areCalendarEventsEnabled for recurring,confirm,paid

* refactor: use placeholder calendar event

* remove merge conflicts

* chore: bump libraries

* chore: bump libraries
2025-06-13 14:15:47 +00:00
Morgan d7fd055171 chore: Org Team workflows endpoints [v2] (#21329)
* chore: workflow endpoints init

* chore: org teams workflow endpoints

* chore: org teams workflow endpoints

* chore: org teams workflow endpoints and tests

* chore: refactor and improvements

* chore: bump libraries

* remove empty module

* update docs and remove AI comments

* chore: only enable workflows for SCALE orgs atm

* bump libraries

* improve dtos

* add hashmaps of enums

* remove unnecessary isOptional

* fix docs

* code review fix controller

* improve docs

* sort steps and improve docs

* fix: add services and rename triggers

* chore: platform libraries bump

* chore: platform libraries bump
2025-06-13 15:10:44 +02:00
874973d78f feat: add api v2 endpoints for cal video (#21775)
* feat: add api v2 endpoints for cal video

* feat: add endpoint for fetching transcripts

* chore: fetch only references

* feat: add cal video and transcript

* chore: undp open api

* chore: move it to service

* chore: bump libraries

---------

Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
2025-06-13 12:02:58 +00:00
Eunjae Leeandsean-brydon 8078c5657b chore: move logics to FilterSegmentRepository (#21648)
* chore: move logics to FilterSegmentRepository

* add explicit select

* replace TRPCError with Error

* convert to non static methods and implement the interface

* apply feedback

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
2025-06-13 13:49:26 +02:00
Alex van Andel b39404860f chore: Remove cascade on profile deletion for EventType (#21792) 2025-06-13 10:24:01 +00:00
Morgan 860eae8dcb fix: ensure failed apiv2 slots workers are terminated (#21797)
* fix: ensure failed apiv2 slots workers are terminated

* fixup! fix: ensure failed apiv2 slots workers are terminated
2025-06-13 07:05:00 -03:00
Benny Joo b931d3ee13 feat: restructure org pages based on permission levels (#21611) 2025-06-13 10:42:04 +01:00
ba8a71bf3a feat: support updating cal video settings in API v2 (#21784)
* feat: support updating cal video settings in API v2

* chore: update descriptio

* feat: support create event type

* test: add test for updating event type

* test: add test for create event type

* chore: undo openapi

* chore: bump libraries

* Revert "chore: bump libraries"

This reverts commit bdf36d09b021fc531497a7b7ea66ab9c52b7d136.

* chore: bump libraries

---------

Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
2025-06-13 12:05:29 +03:00
8de4897042 feat: enable transcription automatically (#21691)
* fest: Add enableAutomaticTranscription field to CalVideoSettings schema

* fest: Update backend logic for enableAutomaticTranscription in event types

* fest: Add frontend support for enableAutomaticTranscription in video meetings and event types

* fest: Add localization strings for enableAutomaticTranscription feature

* fix: enable transcription feature

* Update apps/web/lib/video/[uid]/getServerSideProps.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: akarsh-jain-790 <akarsh.jain.790@gmail.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-13 07:51:57 +00:00
Somay Chauhan 6de6f8e697 feat: api v2 get google-calendar event details (#21336)
* feat: add API endpoint to fetch Google Calendar meeting details and metrics

* refactor: rename eventId to eventUid and update calendar event details endpoint

* feat: implement Google Calendar service account delegation for event details

* refactor: simplify Google Calendar event response

* refactor: simplify calendar event details endpoint

* feat: add calendar event details endpoint with schema and controller implementation

* chore: reset platform libraries package version to 0.0.0

* refactor: migrate calendar event details to unified calendars module

* Update gcal.service.ts

* refactor: update calendar event schema with title and locations fields replacing summary and conferenceData

* feat: update calendar event source to use enum type for better validation

* update api description

* refactor: make Google Calendar service methods private

* refactor: remove location field from unified calendar event output

* fix: update Google Calendar event location type property to match unified schema

* feat: add CalendarEventStatus enum and map Google Calendar statuses to standardized values

* docs: add property descriptions to calendar event schema and remove organizer field

* fix: change calendar event locations type from null to empty array in unified calendar API

* feat: make calendar source field required

* refactor: replace organizer field with hosts array in Google calendar event mapping

* feat: enhance calendar event location API documentation with detailed property descriptions

* feat: add calendar event details endpoint documentation

* fix: typo

* docs: update calendar event details API description to remove reschedule history reference

* refactor: rename uri to url in calendar event location interfaces and mappings

* refactor: improve calendar event response status handling and code organization

* Update get-unified-calendar-event.ts

* update docs

* chore: update @calcom/platform-libraries to version 0.0.215
2025-06-13 13:08:54 +05:30
Kartik Saini e55ecff899 fix: hovering over insights tab does not show pointer (#21772) 2025-06-13 07:13:43 +00:00
Muhammad Aiman Sulaiman 3895ef002e fix: Updates to HitPay app (#21175)
* reapplied my changes after syncing with upstream

* fix: changed raw error to sanitized error

* fix: added try/catch to create catch
2025-06-13 12:10:28 +05:30
Eunjae Lee afc28503a5 fix: apply user timeZone for Event Trends on /insights (#21787) 2025-06-13 08:47:47 +04:00
Amit Sharma e6497c87ca perf: use repository for apiKeys list query & caching in /settings/developer/api-keys RSC (#21776) 2025-06-12 21:11:06 +00:00
GitHub Actions cbb020911d chore: release v5.3.12
Post release / release (push) Canceled after 0s
2025-06-12 20:58:13 +00:00
Udit Takkar 200b9d037c fix: remove deprecated fields from retell ai (#21790) 2025-06-12 20:45:55 +00:00
GitHub Actions 69667a7528 chore: release v5.3.12 2025-06-12 18:30:15 +00:00
9f655ed819 feat: added validation to limit event duration to 1440 minutes (24 ho… (#21379)
* feat: added validation to limit event duration to 1440 minutes (24 hours)

* Update English locale strings in common.json

* feat: introduce minimum event duration constant and update validations and fixed some suggested changes

* fix: remove static error message for maximum event duration validation

* fix: update minimum event duration to 1 minute and adjust validations accordingly

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: amrit <iamamrit27@gmail.com>
2025-06-12 17:09:21 +00:00
Carina WollendorferandCarinaWolli 5a1e1e231b add credit purchase log (#21768)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-06-12 11:29:12 -04:00
Eunjae Lee 6cccb1725f fix: provide timeZone to /insights from the server side (#21580) 2025-06-12 15:26:44 +00:00
5bb2a904ce refactor: Deprecate Legacy v2 Booker Atom Endpoints (#20939)
* feat: split atoms endpoints and add public event type endpoint

* Update ConnectedDestinationCalendars import path across platform/atoms components

* refactor: update BookingResponse import path from platform-libraries to features/bookings

* Move AvailableSlotsType to util.ts and update imports to use GetAvailableSlotsResponse

* Refactor import path for RecurringBookingCreateBody type from libraries to types

* Fix import path for getBookingForReschedule type from platform-libraries to features

* Refactor PublicEventType export location and update import references

* Remove @calcom/platform-libraries dependency from atoms package.json

* chore(deps): update yarn.lock dependencies

* Remove console.log statements and fix indentation in event type hooks

* Migrate event type transformers from platform/libraries to api/v2 directory

* Remove console.log

* Update BookerPlatformWrapper.tsx

* Add script to populate empty team slugs with slugified team names

* Remove vitest imports

* reset platform libraries version

* Remove unused orgId comment from useAtomGetPublicEvent hook params

* Update useApiV2AvailableSlots.ts

* refactor: remove unused exports from lib package index file

* Undo: @SomayChauhan
Add script to populate empty team slugs with slugified team names

* Update booking.tsx

* chore: upgrade @calcom/platform-libraries from 0.0.202 to 0.0.205

* chore: bump @calcom/platform-libraries from 0.0.205 to 0.0.206

* chore: configure babel and jest for node module transpilation in api v2

* fix: type errors

* Revert "chore: configure babel and jest for node module transpilation in api v2"

This reverts commit b2cf172a84fe8953f9497bf6e43874f476fbc04b.

* Update calendars.service.ts

* chore: bump @calcom/platform-libraries from 0.0.208 to 0.0.209

* fix: add proper type definition for calendar busy times to resolve ts-expect-error

* refactor: deprecate v2 old availability endpoints (#21075)

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>

* chore: publish platform librareis

* feat: add delegation credential fields to calendar service mock

* chore: update @calcom/platform-libraries from 0.0.211 to 0.0.213

* fix: skip failing calendar integration test

* chore: bump @calcom/platform-libraries from 0.0.213 to 0.0.214

* fix: api/v2 build error

* fix: e2e tests

---------

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
2025-06-12 20:20:52 +05:30
Chai 5e2f06cdea fix: multi-line formatted correctly for sms (#21779)
* fix: multi-line formatted correctly for sms

* fix: tests iteration2
2025-06-12 14:26:34 +00:00
Parteek malik cf83038a7a fix: cal atoms schedule container class in availability settings custom class names not being applied (#21733)
* fix: classname not used

* fix types

* added type
2025-06-12 11:02:00 -03:00
Udit Takkar c7662cad61 feat: override name in daily video (#21758)
* feat: override name in daily vide

* refactor: simplify operation
2025-06-12 09:54:24 -04:00
Alex van Andel 86912e0cbc refactor: async constructor is an anti-pattern, use init instead (#21785) 2025-06-12 13:13:44 +00:00
Syed Ali Shahbaz 74234b4ed1 docs: Cleanup false info (#21741)
* Delete docs/developing/guides/appstore-and-integration/oauth.mdx

* Update mint.json
2025-06-12 12:21:34 +00:00
devin-ai-integration[bot]andHariom Balhara 2fcb8a750d fix: cascade organization hideBranding setting to user and team events (#21703)
- Add utility function for cascading hideBranding logic
- Update all getServerSideProps files to check organization hideBranding as fallback
- Ensure team queries include parent hideBranding data
- Fix hideBranding not working for organization members and teams

Fixes the issue where organization-level branding settings were not
being applied to user and team event pages when the direct entity
didn't have hideBranding enabled.

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2025-06-12 09:14:55 -03:00
2aaf672b10 perf: Implement worker threads for getAvailableSlots to prevent CPU blocking (#21479)
* Implement worker threads for getAvailableSlots to prevent CPU blocking

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: resolve TypeScript errors in worker implementation

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* chore: fix slot-worker-service.ts

* fix: do not use workers in E2E

* fix: try to fix memory leak

* chore: remove unecessary comments

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: keith@cal.com <keithwillcode@gmail.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
Co-authored-by: cal.com <morgan@cal.com>
2025-06-12 11:56:13 +00:00
nav 34beadeef6 chore(docs): update 'Calendso' to 'Cal.com' in documentation (#21661) 2025-06-12 11:29:15 +00:00
Carina WollendorferandCarinaWolli 6de715b884 feat: Round Robin timestamp basis (#21337)
* add rrTimeStampBasis to prisma schema

* add rr time stamp basis setting

* update migration

* add getLuckyUser logic

* add rrTimestampBasis to tests

* add load balancing warning message

* disable load balancing logic

* disable load balancing in event type settings

* add missing translations

* fix UI

* disable load balancing on all team event types

* don't show routing forms in router position

* use correct interval times

* fix variable naming

* fix event type update handler

* add test to booking.test.ts

* add test for getting interval times

* remove not needed prop

* fix label

* improve warning message

* fix removing maxLeadTreshold

* fix typo

* fix disabling maxLeadThreshold

* add back missing translation

* improve rr reset interval label

* fix rr_load_balancing_disabled text

* improve test

* fix description

* only use rrTimestampBasis in weights round robin

* fix dropdown width

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-06-12 11:37:38 +01:00
GitHub Actions 84717ca73e chore: release v5.3.11
Post release / release (push) Canceled after 0s
2025-06-11 23:50:19 +00:00
86b1db57d5 fix: Resending team invites now updates token expiry date (#21774)
* Create `VerificationTokenRepository`

* Update the verification token expiry when resending the invite

* Handle error

* Fix import

* Get past unique constraint

* Update packages/trpc/server/routers/viewer/teams/resendInvitation.handler.ts

Co-authored-by: Alex van Andel <me@alexvanandel.com>

* Update packages/lib/server/repository/verificationToken.ts

Update set expiry time

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* Type fix

* Update how we're fetching the token

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-11 22:21:58 +00:00
Amit Sharmaandcubic-dev-ai[bot] 50c15f0d51 fix: dub installation on teams (#21654)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-11 18:17:55 +02:00
Romit.andEunjae Lee 86d5c43307 fix: select component icons misaligned (#21688)
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
2025-06-11 13:22:00 +00:00
Anik Dhabal Babuandcubic-dev-ai[bot] e82bd45b55 fix: Incorrect RR host is shown in the email and calendar event for a seated RR event (#21684)
* fix: seated rr event

* Update packages/features/bookings/lib/handleNewBooking.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* update

* Update handleNewBooking.ts

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-11 11:21:21 +00:00
13966e0ec8 perf: use repository for queries & caching in /teams RSC (#21399)
* cache trpc queries in /teams

* fix

* revalidate

* refactor: migrate listHandler to TeamRepository.findTeamsByUserId

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

* add comment

* refactor

* refactor

* make it even more performant

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: benny@cal.com <benny@cal.com>
2025-06-10 20:44:51 -04:00
GitHub Actions 14b9e0c032 chore: release v5.3.10
Post release / release (push) Canceled after 0s
2025-06-10 22:43:07 +00:00
Anik Dhabal BabuandSyed Ali Shahbaz f0f168e920 fix: improve updatehostineventname function (#21734)
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
2025-06-10 21:47:30 +00:00
devin-ai-integration[bot] dd37caf32c feat: move team privacy settings to dedicated settings page (#21590) 2025-06-10 22:23:28 +02:00
Hariom Balhara 856d223535 fix: Use setTimeout instead of requestAnimationFrame which is more reliable and support calOrigin in prerender #21205 (#21730) 2025-06-10 11:00:57 -04:00
Sarthak KapilaandMorgan ad697365ce fix: Add onFormStateChange callback on EventTypeSettings atom [CAL-5856] (#21615)
* Adds onFormStateChange callback on EventTypeSettings atom

* updated docs for event-type

* added watch all form values

---------

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2025-06-10 12:36:34 +00:00
Morgan 84171928cb chore: enable disable rewrite for apiv2 selfhost (#21742) 2025-06-10 11:04:25 +00:00
Sebastian BrunowandSebastian Brunow e781a78eea fix: Prevent Timing Attacks by Removing await in Password Reset Flow (#21747)
* fix: correct password reset request handling logic

* fix: handle password reset request errors more gracefully

---------

Co-authored-by: Sebastian Brunow <90863358+Bratpfanne-4000@users.noreply.github.com>
2025-06-09 22:44:24 +00:00
Keith Williams 7d08c6724b chore: @Foundation required for embeds changes (#21748) 2025-06-09 23:13:04 +01:00
GitHub Actions 899da51f06 chore: release v5.3.9
Post release / release (push) Canceled after 0s
2025-06-09 21:56:25 +00:00
Joe Au-Yeung 4e085e404a Downgrade Next to 15.3.0 (#21746) 2025-06-09 17:21:02 +00:00
Morgan ff3aaadbaa fix: update delegation credentials api-v2 (#21739)
* fix: update delegation credentials api-v2

* fixup! fix: update delegation credentials api-v2
2025-06-09 11:46:38 +00:00
11bddbb71d feat: add setting to allow booking through a reschedule link (#21652)
* feat: add setting to disable rescheduling cancelled bookings

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

* fix: resolve type errors for disableReschedulingCancelledBookings field

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

* fix: update test expectations and builder to include disableReschedulingCancelledBookings field

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

* fix: add disableReschedulingCancelledBookings field to managed event types

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

* fix: remove duplicate disableReschedulingCancelledBookings property in test

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

* fix: change default value to true for disableReschedulingCancelledBookings

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

* fix: update managed event types to use true as default for disableReschedulingCancelledBookings

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

* test: add comprehensive tests for disableReschedulingCancelledBookings feature

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

* update and remove unnecesarry test

* update e2e test

* Update reschedule.e2e.ts

* update

* fix

* Reverse the meaning of column

* Simpify logic of rescheduling redirects

* fix test

* revert

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: hariom@cal.com <hariom@cal.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: unknown <adhabal2002@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2025-06-07 22:30:54 +02:00
devklepacki 55a80ba253 Fixed pl translation typo (#21723) 2025-06-06 13:59:58 +00:00
Hariom Balhara 32a89c30de fix: [object object] for name when rescheduling a past booking (#21695) 2025-06-05 09:42:48 +01:00
Parteek malikandAnik Dhabal Babu 5404eeedc2 fix: no show not updating in sync (#21687)
* fix: no show not updating in sync

* fix footer in no show dialog

* using await

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-06-04 10:14:08 +00:00
Hariom Balhara d54ba90304 fix-wrong-url-on-auth-error (#21693) 2025-06-04 09:55:19 +05:30
Omar López ca206915bf fix: self hosted feature check (#21690) 2025-06-03 17:00:48 +00:00
Anik Dhabal Babu 8461b82f0d fix: Update handlers and refactor code (#21686)
* fix: update safeCredentialSelect

* Update credential.ts

* Update

* update
2025-06-03 15:32:40 +00:00
Alex van Andel 07ffc3fade fix: Remove hard dependency on NEXT_PUBLIC_API_V2_URL (#21682)
* fix: Remove hard dependency on NEXT_PUBLIC_API_V2_URL

* turn spread into a push, simpler
2025-06-02 19:21:38 +01:00
sean-brydon c2240f0bad only use event api v2 call if route is in env (#21680) 2025-06-02 17:31:35 +00:00
Zenrac 36a712f979 fix: Correct typo 'siège' to 'place' in French translation (#21671) 2025-06-02 08:54:24 +05:30
Lauris Skraucis 842ba09896 refactor: v2 reschedule booking error messages (#21647) 2025-05-30 13:24:06 +00:00
devin-ai-integration[bot] b3c822abf7 feat: move filter segment selection from localStorage to database (#21523) 2025-05-30 12:56:49 +00:00
Akarsh JainandMorgan 1f52ed7290 feat: Add loadingStateChildren prop to AvailabilitySettingsPlatformWrapper (#21602)
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2025-05-30 10:39:02 +00:00
Lauris Skraucis a2c13e576e refactor: v2 dont allow rescheduling cancelled,rescheduled bookings (#21643) 2025-05-30 10:23:51 +00:00
Morgan 24bb52d2e9 fix: platformPlanGuard per active users plan (#21642)
* fix: platformPlanGuard per active users plan

* fix: refactor
2025-05-30 09:42:23 +00:00
Joe Au-Yeung d8145bbc78 Remove error if team members and hosts do not match (#21598) 2025-05-30 08:31:34 +00:00
Hariom BalharaandAlex van Andel 8753a6e4d6 Function return type is illegal, not sure how this passed eslint (#21567) (#21622)
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-05-30 13:18:04 +05:30
Benny Joo b91607b5b4 fix: missing places for revalidations (#21632) 2025-05-29 22:45:41 +01:00
Sarthak Kapila af0e839f27 feat: Enable Adding Custom children components at the bottom of EventMeta within Booker using children component props (#21618)
* feat: Enable Adding Custom children components at the bottom of EventMeta

* removed default style

* added prop in BookerPlatformWrapper
2025-05-29 21:26:30 +00:00
Udit Takkar b6de03de96 Revert "perf: use app dir to fetch team feature flags in settings (#21433)" (#21628)
This reverts commit 1dca160db0.
2025-05-29 20:10:12 +00:00
e115095198 perf: migrate listHandler to AttributeRepository + cache attributes fetching in RSCs (#21552)
* refactor: migrate listHandler to AttributeRepository

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

* cache attributes list

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: benny@cal.com <benny@cal.com>
Co-authored-by: hbjORbj <sldisek783@gmail.com>
2025-05-29 15:01:44 -04:00
Lauris Skraucis c3add4bae8 fix: v2 slots reservation (#21623)
* feat: return team event type hosts username

* docs: team event types hosts username in return

* fix: ignore cancelled and rejected bookings from slot reservation

* fix: dont allow slot to overlap existing active booking

* refactor: remove log
2025-05-29 16:25:33 +00:00
Alex van Andel 3040e14624 refactor: Use a deployment repository to interact with license keys (#21613) 2025-05-29 10:58:33 -04:00
Calcom BotandLingo.dev 34993e3f36 feat: update translations via @LingoDotDev (#21260)
Co-authored-by: Lingo.dev <support@lingo.dev>
2025-05-29 14:58:17 +00:00
Sarthak Kapilaandcubic-dev-ai[bot] 8d5c6b8877 feat: OnformChange on Availability Settings Atom (#21560)
* feat: OnformChange on Availability Settings Atom

* docs: update availability-settings

* Update docs/platform/atoms/availability-settings.mdx

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-05-29 20:05:01 +05:30
Devanshu SharmaandMorgan c9eac73fec feat: add support for custom no schedule children in AvailabilitySettingsPlatformWrapper (#21601)
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2025-05-29 20:02:56 +05:30
Udit Takkar ab475b80f3 fix: recording button bug (#21609)
* fix: recording btn visible bug

* fix: check for showRecordingButton

* refactor: create a reusable function
2025-05-29 14:23:51 +00:00
Benny Joo 2b79039b70 perf: upgrade to next 15.3.2 (#21610)
* perf: upgrade nextjs to 15.3.2

* update yarn lock
2025-05-29 14:50:42 +01:00
Lauris Skraucis 044df04d3f feat: v2 return team event type hosts username (#21617)
* feat: return team event type hosts username

* docs: team event types hosts username in return
2025-05-29 14:58:40 +03:00
Layan Jyoti Duttaandlayand12 2cbf805ffb Fixed generator enums in prisma db (#21595)
Co-authored-by: layand12 <d.layan@unque.me>
2025-05-28 22:49:20 +00:00
GitHub Actions d208074063 chore: release v5.3.8
Post release / release (push) Canceled after 0s
2025-05-28 21:11:43 +00:00
Joe Au-Yeung 30541da1fa Fix logging (#21593) 2025-05-28 16:30:14 +00:00
Carina WollendorferandCarinaWolli 97af0af0ba fix: only generate sms message bodies when needed (#21566)
* only generate template when needed

* rename function to getSMSMessageWithVariables

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-28 16:01:40 +00:00
Faiz e9b26921da fix: misaligned and undersized tick mark in timezone dropdown (#21550) 2025-05-28 12:37:16 +00:00
Alex van Andel e4434f199d Function return type is illegal, not sure how this passed eslint (#21567) 2025-05-28 13:21:14 +01:00
Joe Au-Yeung f4b0219a0e Variable fix (#21557) 2025-05-28 02:38:20 +01:00
Joe Au-Yeung 6f1eaaa02e fix: Create separate calendar events to hide organizer (#21555)
* Add notes to `EventManager.create`

* Create `CalendarServiceEvent`

* Generate calendar description and remove attendees if event is private in `CalendarManager`

* Process event for reschedule method

* Refactor calendar services

* Clean up comment

* Type fixes

* Type fix

* Type fix
2025-05-27 20:46:26 -04:00
Udit TakkarandAlex van Andel e5868837d5 perf: service worker lifecycle method (#21532)
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-05-27 23:12:25 +00:00
GitHub Actions 71a5d8b261 chore: release v5.3.7
Post release / release (push) Canceled after 0s
2025-05-27 22:35:54 +00:00
Alex van Andel dfc022d890 Revert "perf: parallelize getBusyTimes calls to improve performance (#21372)"
This reverts commit a06b2009ab.
2025-05-27 23:30:30 +01:00
GitHub Actions 68cb0cf197 chore: release v5.3.7 2025-05-27 22:28:37 +00:00
Syed Ali ShahbazandUdit Takkar 14592de6c4 fix: Anonymize host email in ics (#21544)
* add virta check for anonymizing host

* move to env var

* move env var to constants

* fix: filter empty string

* fix test

* fix test

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
2025-05-27 19:28:03 +01:00
Omar López d41dcc69ad refactor: prevent mixed imports (#21500)
Signed-off-by: Omar López <zomars@me.com>
2025-05-27 11:55:02 -04:00
Eunjae Lee 0a28b5825b fix: date range computation on /insights (#21436)
* fix: date range computation on /insights

* remove log

* error handling

* update test cases

* WIP

* fix implementation

* support weekStart

* clean up

* fix date range presets

* clean up timeView

* fix timeView

* clean up

* fix event trends

* remove unused variables

* fix flaky e2e tests

* fix date range

* update formatting logic
2025-05-27 17:47:40 +02:00
Eunjae Lee 3131318b6a fix: hide organizer info on rescheduled events (#21541)
* fix(email): hide organizer info on rescheduled events

* hide organizer email on bookings-single-view

* replace organizer email with name

* sanitize previous booking only

* clean up code

* fix dumb error
2025-05-27 15:35:16 +00:00
sean-brydonandAlex van Andel 08e35e4698 perf: stop merging routers twice. (#21538)
* move away from merging twice

* move to use loggedIn Router directly

* fix router outputs types

* fix mocks in create button with teasm tests

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-05-27 15:42:14 +01:00
ed4b3f082a feat: cal video settings (#21347)
* feat: cal video settings

* fix: var names

* feat: finish setting

* chore: add enabled

* chore: remove logs

* feat: support redirect url on exit

* feat: finish settings

* refactor: improve UI

* chore: remove logs

* fix: type err

* fix: finish redirect url

* fix: add type

* chore: change schema

* fix: type error

* chore: improvements

* chore: remove index

* feat: add organizer

* chore: remove log

* chore: use safe parse

* fix: add nullable

* refactor: hide toggles if platorm

* chore: update description

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
2025-05-27 10:13:24 -04:00
Rajiv SahalandAnik Dhabal Babu a1007398f6 fix: update stripe webhooks to handle past due subscriptions (#20466)
* handle case for past due subscriptions

* update user subscription again if active

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-05-27 13:06:42 +00:00
Lauris Skraucis 2aafa1c163 feat: v2 managed organizations pagination (#21359)
* feat: getPagination helper

* refactor: bookings use getPagination helper

* feat: getPagination helper

* refactor: group pagination inputs and outputs in types/pagination

* feat: paginated managed orgs

* fix tests

* swagger
2025-05-27 13:50:31 +03:00
FaizandUdit Takkar 008178480a fix: 'Hide from profile' toggle background not sized correctly on mobile (#21535)
* Fix: 'Hide from profile' toggle background not sized correctly on mobile

* fix: changed padding back to original

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2025-05-26 18:15:29 -04:00
Amit SharmaandPeer Richelsen 2334c3bef8 fix: optimize SEO healthscore (#21509)
Post release / release (push) Canceled after 0s
* compress app store images

* replace http linkages with https

* fix link raycast

* update http links to https

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
2025-05-26 20:24:08 +00:00
GitHub Actions 9542116ec1 chore: release v5.3.6 2025-05-26 19:58:52 +00:00
Anik Dhabal Babu f9c11c2856 fix: (Reschedule) Email Settings being ignored for RR event (#21520)
* fix: delete dilog button not visible

* fix: (Reschedule) Email Settings being ignored for RR event

* update
2025-05-26 16:17:05 +00:00
Hariom BalharaandOmar López 30060f03eb fix: GoogleCalendar - Ensure that Delegation Credentials are able to reuse access_token (#21389)
Co-authored-by: Omar López <zomars@me.com>
2025-05-26 15:19:52 +01:00
Vijay b8ffcef45e fix: Remove global GTM container on private booking page. (#21490)
* add route filter to inject script

* update middleware for pathname as Referer might not work all time

* move d to (booking-page-wrapper) instead of route filter and change in middleware

* add e2e tests
2025-05-26 10:14:24 +05:30
Rajiv Sahal 999882b795 dont pass attribues and facetedTeamValues for platform (#21508) 2025-05-25 22:17:42 +00:00
Omar López bda963b851 refactor: prevents mixed server/clients imports (#21499) 2025-05-25 09:07:49 +00:00
GitHub Actions 8511494d68 chore: release v5.3.5
Post release / release (push) Canceled after 0s
2025-05-25 00:08:53 +00:00
Benny Joo 1c3ad9dad6 refactor: make routing forms code more maintainable (#21478)
* create layout for routing/forms

* refactor

* refators

* fix

* clean up
2025-05-24 22:44:05 +00:00
Anik Dhabal Babu d43afe7dbd fix: e2e test failure in ci (#21510)
* fix: delete dilog button not visible

* fix: global e2e fialure

* update

* tweak
2025-05-24 13:11:36 -04:00
devin-ai-integration[bot]andkeith@cal.com a06b2009ab perf: parallelize getBusyTimes calls to improve performance (#21372)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: keith@cal.com <keithwillcode@gmail.com>
2025-05-24 08:43:06 -04:00
Omar López 2a786b4652 Revert "test: fix few e2e flakes (#21408)" (#21501) 2025-05-23 15:30:33 -07:00
Anik Dhabal Babu ef1844557f fix: Host schedule not updating upon updating/deleting default schedule (#20750)
* fix: host schdule not updating

* Update util.ts

* tweak

* Update delete.handler.ts

* add test

* update

* Update util.test.ts
2025-05-23 17:53:40 -04:00
Alex van Andel d1f7b043e8 chore: Improve error handling for avatar API, shouldn't result in timeouts (#21493) 2025-05-23 18:08:04 +00:00
3a8e40d029 feat(calendar): add error tracking with attempts to SelectedCalendar (#21326)
Co-authored-by: hariom@cal.com <hariom@cal.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
2025-05-23 16:38:54 +00:00
bca46228e7 feat: upgrade typescript to 5.8.3 (#21449)
* feat: upgrade typescript to 5.8.3

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

* chore: fix TypeScript 5.8.3 compatibility issues

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

* Uncomment `optmizeImage`

* Type fix

* Type fix

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: joe@cal.com <joe@cal.com>
Co-authored-by: Joe <j.auyeung419@gmail.com>
2025-05-23 13:57:37 +01:00
Omar López d15b24b8ea ci: remove deprecated submodule code (#20731) 2025-05-23 12:25:33 +00:00
Udit TakkarandSyed Ali Shahbaz d9df9b3d01 feat: recording url with 6 months expiry time (#18707)
* feat: store cal video recording on s3

* feat: create new route to fetch download link

* tests: add unit test

* fix: unit test

* fix: type error

* chore: add env var

* fix: open in new tab

* fix: type err

* chore: update test

* fix: import

* chore: use cal video recording token secret

---------

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
2025-05-23 13:01:33 +01:00
Lauris Skraucis fc1d6ae402 refactor: platform docs and oauth webhook auth (#21488)
* fix: Cannot read properties of undefined (reading 'id')

* docs: managed users dont have cal.com page

* docs: reassign works only for round robin bookings

* refactor: put OAuthClientWebhooksController behind ApiAuthGuard

* fix: tests

* fix: typo
2025-05-23 14:06:47 +03:00
Peer Richelsen 26b4b7a868 fixed two dark mode app logos (#21482) 2025-05-23 08:08:27 +00:00
Anik Dhabal Babu a839630ca3 test: fix few e2e flakes (#21408)
* fix flakes

* update

* Update booking.e2e.ts

* update

* Update booking.e2e.ts

* Update booking.e2e.ts
2025-05-23 12:40:27 +05:30
Hariom Balhara e21dbb704e fix error in selected-calendars cron for delegation credential (#21465) 2025-05-23 03:37:24 +00:00
GitHub Actions 53a06797a9 chore: release v5.3.4
Post release / release (push) Canceled after 0s
2025-05-22 23:03:42 +00:00
Carina WollendorferandCarinaWolli 99eb743772 add verifiedAt timestamp (#21477)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-22 22:42:25 +00:00
73adfb0cec fix: header in routing forms (#21445)
* fix header

* remove unused variables

---------

Co-authored-by: Eunjae Lee <hey@eunjae.dev>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2025-05-22 19:47:10 +00:00
Rajiv SahalandMorgan 7127c60116 fix: stripe integration in EventTypeSettings atom (#20919)
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2025-05-22 12:18:28 -07:00
Joe Au-Yeung a6d37fd167 feat: Round robin, when attendee books same timeslot return original booking (#21455) 2025-05-22 12:06:28 -07:00
Benny Joo 16ea15076d fix: increase timeout to 800 seconds for workflow reminders (#21476) 2025-05-22 18:31:02 +00:00
Anik Dhabal Babu 041871f1b6 fix: only fixed hosts added (#21407) 2025-05-22 18:14:46 +00:00
Carina WollendorferandCarinaWolli 8c8ae127fe feat: allow custom SMS templates for free users (#21469)
* charge free users for SMS to CA an US

* allow custom template for free users

* fix backend + some UI fixes

* make text editable

* rename back to needsTeamsUpgrade

* add twilio webhook handler tests

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-22 19:09:49 +01:00
357c82129c feat: Dub App integration (#21321)
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
2025-05-22 09:18:45 -07:00
Eunjae Lee 324ac691eb fix: use local date range on /insights (based on profile's timezone) (#21472)
* fix: use local date range on /insights (based on profile's timezone)

* update test case
2025-05-22 16:03:56 +00:00
devin-ai-integration[bot]andeunjae@cal.com da99001a7a - Prefer the implementation in packages/trpc/react/hooks as it's used by most of the codebase (#21468)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-05-22 11:24:58 -04:00
Anik Dhabal Babu bd10d07083 fix: delete dilog button not visible (#21470) 2025-05-22 14:42:35 +00:00
Hariom BalharaandUdit Takkar 0e9b419a07 fix: Delegation Credentials - Use Cal Video if set as the default conferencing app (#21431)
* fix google-meet being used instead of Default Cal Video preference if
set

* Review addressed

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2025-05-22 08:21:25 -04:00
Hariom Balhara d5bd08d279 improve-delegation-disable-email-communication (#21456) 2025-05-22 09:06:31 +00:00
devin-ai-integration[bot]andeunjae@cal.com 4cc83530f9 refactor(e2e): use filter helper methods instead of raw selectors (#21460)
* refactor(e2e): use filter helper methods instead of raw selectors

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor(e2e): rename selectFilter to addFilter and update all usages

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-05-22 08:46:51 +00:00
Hariom BalharaandOmar López 4fcf4081d0 feat: Send emails to potentially affected Organization Members on disabling delegation credential (#21276)
* mvp

* Improve UI

* wip

* self-review

* self-review

---------

Co-authored-by: Omar López <zomars@me.com>
2025-05-22 03:28:21 +00:00
GitHub Actions d84d80eea6 chore: release v5.3.3
Post release / release (push) Canceled after 0s
2025-05-22 01:05:29 +00:00
f3e1d67de1 feat: internationalize user table column headers (#21444)
* feat: internationalize user table column headers

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

* revert

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: benny@cal.com <benny@cal.com>
Co-authored-by: hbjORbj <sldisek783@gmail.com>
2025-05-21 20:10:28 +00:00
Benny Joo 2ce25f54d4 refactor: simplify arg of useBookerLayout hook (#21425) 2025-05-21 10:29:02 -07:00
Benny Joo 25eac5d29b chore: remove last booking response dead code (#21426) 2025-05-21 10:27:52 -07:00
Benny Joo 1710e30719 perf: use server fetched data in instant-meeting and private booking pages (#21424)
* remove useEvent hook

* refactor

* use repository functions

* remove trpc event

* wip

* fix

* remove

* fix

* revert some files

* revert Embed

* revert useEvent hook

* fix

* fix

* revert

* refactor
2025-05-21 10:27:23 -07:00
devin-ai-integration[bot]andeunjae@cal.com 6d970d0b57 fix: improve date selection behavior in DateRangePicker (#21438)
* fix: implement Airbnb-style date selection in DateRangePicker

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: add behavior for clicking on start/end date in DateRangePicker

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-05-21 16:13:55 +00:00
41a6035a12 fix: replace bookingTimeStatus with bookingTimeStatusDenormalized (#21028)
* test: Add unit tests for buildBaseWhereCondition function

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

* refactor: Export buildBaseWhereCondition function instead of copying it

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

* refactor: Remove implementation detail checks from tests

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

* test: Fix tests to match actual function behavior

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

* test: Fix test issues with buildBaseWhereCondition

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

* test: Update tests to match actual function behavior

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

* fix: Address security issues in buildBaseWhereCondition function

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

* refactor: Simplify buildBaseWhereCondition function

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

* refactor: Simplify code and remove isEmptyResponse property

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

* refactor: Use array of conditions approach for buildBaseWhereCondition

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

* refactor: Make buildBaseWhereCondition implementation consistent and update tests

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

* fix: Fix incorrect usage of buildBaseWhereCondition function

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

* chore: Revert yarn.lock changes

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

* fix: Comment out non-existent Sentry API method to fix type error

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

* Revert "fix: Comment out non-existent Sentry API method to fix type error"

This reverts commit 44c21a7396a518c63047b33967cd8af7e6e4f268.

* remove unnecessary if-statement

* fix: replace bookingTimeStatus with bookingTimeStatusDenormalized

* change column

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <eunjae@cal.com>
2025-05-21 16:10:43 +00:00
Akarsh Jain f84c8239e7 feat(bookings): implement Booking UID filter for bookings data table. (#21380)
Fixes: #21357
2025-05-21 11:51:50 -04:00
sean-brydon 1dca160db0 perf: use app dir to fetch team feature flags in settings (#21433)
* use app dir to fetch team feature flags

* guard against type error if teamId does not exist in teamfeatures

* remove redundant router
2025-05-21 12:41:45 +00:00
Carina WollendorferandCarinaWolli 4ff366cd99 fix: canceling workflow reminders (#21416)
* fix deleting reminders

* schedule reminders if iffy is disabled

* fix unit test

* clean up code

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-21 12:35:31 +00:00
Carina WollendorferandCarinaWolli 21a4711f07 fix: don't schedule past workflow reminders with tasker (#21434)
* don't schedule past reminders

* add test

* fix dates in tests

* add early return

* fix sms test

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-21 12:24:34 +00:00
Anik Dhabal Babu f1dd217de7 fix: don’t let the booking page crash on invalid metadata (#21410)
* fix: booking tab crash

* Update zod-utils.ts

* Update zod-utils.ts

* update
2025-05-21 09:44:17 +01:00
Anik Dhabal BabuandCarinaWolli 3e8f0b125d fix: WhatsApp workflows are not working (#21421)
* fix: whatsapp template

* update

* fixes for sending whatsapp messages

* add message service id when scheduling

* add timezone to startTime variable

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-21 08:12:12 +00:00
devin-ai-integration[bot]andeunjae@cal.com 25246ef8ff test: add e2e tests for filters on /insights/routing (#21332)
* test: add e2e tests for insights routing filters

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: improve stability of insights routing filters e2e tests

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: address PR feedback for insights routing filters e2e tests

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: add explicit page navigation to resolve timeout issues in filters.e2e.ts

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: navigate to routing tab after loading insights page

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix e2e tests

* fix tests

* rename

* fix tests

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-05-20 18:23:57 -04:00
Benny Joo bb98143e2e perf: Server Fetching for platform members and org members pages (#21342)
* remove members page

* refactor to server fetch

* same for /members

* use server fetches for all queires

* fix

* add skeletons

* refactor

* fix loading page

* fix

* fix type checks

* fix details

* refactor platform members page
2025-05-20 16:36:34 -04:00
devin-ai-integration[bot]andeunjae@cal.com 6258ca14d0 feat: add segments prop to DataTableProvider (#21409)
* feat: add segments prop to DataTableProvider

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor: modify useSegments hook instead of creating a new one

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: implement PR feedback and fix failing test

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* clean up

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <hey@eunjae.dev>
2025-05-20 22:30:32 +02:00
Eunjae Lee d0e17e8611 fix: add migration to backfill BookingDenormalized (#21420) 2025-05-20 10:01:09 -07:00
Eunjae Lee 79dc76239b fix: apply transaction to public methods of CreditService (#21356) 2025-05-20 18:20:45 +02:00
Eunjae Lee 95d62354d9 test: update flaky tests (#21419)
* test: update flaky integration tests

* change limit
2025-05-20 14:57:43 +00:00
b9fadf82a7 feat: pbac (#21296)
* inital pbac setup

* fix tests

* docs intro

* more docs

* add comments in docs

* revert pr_todo

* update to use action + custom as defaults

* use enums

* move to change user role + multi check

* add beforeEach import

* docs: add PERMISSIONS.md documenting team/organization role usages

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

* docs: add permission string alternatives for helper functions

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

* feat: enhance permission registry and default role permissions

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

* add routers

* add hooks + rsc. Also adjsuted test to use prismock

* make hooks type safe + add some tests

* add a permission context - trpc router to populate context

* update docs

* explore global and default roles member,admin,owner

* fix tests

* use kysley and abstract uril

* tidy up

* update trpc to use pbac route in endpoint + distinct on teamId

* make transform util

* remove role service dependancy from permission check class

* checkTeamId fall back to orgId if team is parent

* todos

* remove manual migrations to launch softly

* address feedback

* move permission checks to a repo

* move role service database calls to repo. improve mocks

* update tests to have describe import

* fix types

* remove router that is not used to pass build

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-05-20 15:22:52 +01:00
devin-ai-integration[bot]andalex@cal.com 1740e34c79 perf: remove unused submitFeedback tRPC route to reduce type generation load (#21418)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: alex@cal.com <me@alexvanandel.com>
2025-05-20 15:14:51 +01:00
Eunjae Lee 9e09066e99 chore: use correct import path for AppRouter (#21415) 2025-05-20 13:50:20 +00:00
Benny Joo 0a9cfd3a08 perf: cache TRPC queries in /availability RSC (#21398)
* cache trpc queries in /availability

* fix

* fix

* add comments

* use undefined
2025-05-20 08:04:52 +01:00
Benny Joo 0be711ad6e perf: cache TRPC queries in /event-types/[eventTypeId] RSC (#21401)
* cache /event-types details page

* fix
2025-05-20 08:04:01 +01:00
Alex van Andel 1c507b8169 chore: Increase workflows/trpc timeout to 800s (#21397) 2025-05-20 06:44:12 +00:00
81bdb3dc91 fix: Handle invalid non-delegation credential in cron (#21270)
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
2025-05-20 03:17:13 +00:00
devin-ai-integration[bot]andkeith@cal.com 5efc7f3856 perf: optimize O(n²) algorithms in slot generation to O(n) or O(n log n) (#21373)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: keith@cal.com <keithwillcode@gmail.com>
2025-05-19 18:40:18 -04:00
Benny Joo 0afecec607 perf: follow up of server query caching in /event-types (#21402) 2025-05-19 19:39:51 +00:00
Benny Joo 920574de65 perf: cache TRPC queries in /event-types RSC (#21381)
* improve trpc funcs

* cache /event-types

* remove unused code

* add comments

* add keys

* improve typing
2025-05-19 18:23:06 +00:00
GitHub Actions d15490d5aa chore: release v5.3.2
Post release / release (push) Canceled after 0s
2025-05-19 16:45:11 +00:00
Lauris Skraucis ba6e547f6c chore: bump platform libraries for v2 (#21391) 2025-05-19 16:30:13 +00:00
Anik Dhabal Babu 2493315f92 fix: wrong event details (#21390) 2025-05-19 16:20:07 +00:00
Keith Williams ec117d4034 revert: "perf: add p-limit to _getUsersAvailability to limit concurrent executions to 10 (#21374)" (#21396)
This reverts commit 6cb3bdc567.
2025-05-19 11:47:27 -04:00
Eunjae Lee 646058b8a1 chore: add missing migration for RoutingFormResponseDenormalized (#21388)
* chore: add missing migration for RoutingFormResponseDenormalized

* more changes

* remove cascade deleting

* update migration

* updates

* update

* update schema

* update

* update

* update

* update
2025-05-19 11:28:57 -04:00
Keith Williams 06c359ac9b revert: "chore: release v5.3.2"
This reverts commit 0d96d9c44c.
2025-05-19 08:44:37 -04:00
GitHub Actions 0d96d9c44c chore: release v5.3.2 2025-05-19 12:43:24 +00:00
Udit Takkar e5f8d4a1ac feat: support no show webhook for instant meetings (#21251)
* feat: support no show webhook for instant meetings

* fix: type error
2025-05-19 13:05:06 +04:00
Alex van Andel 19c72323b8 chore: Delete .github/workflows/advisories-to-slack.yml 2025-05-18 23:17:33 +01:00
Alex van Andel f19b2804b6 Update advisories-to-slack.yml (#21384) 2025-05-18 20:03:49 +01:00
Alex van Andel f387fdb166 chore: Add workflow to post security advisories to Slack (#21383) 2025-05-18 17:45:17 +00:00
ec8f9d5f7a feat: option to enforce language for bookingPage (#18782)
* feature eventType specific language or bookingPage language

* chore

* fix type checks

* chore

* chore: remove log

* improvement: this updates in DatePicker is not required with context provider method

* added e2e tests for InterfaceLanguage feature

* corrected prev merge conflict issues

* update to align with hooks usage pattern

* chore

* unrelated auto-formatting changes

* unrelated auto-formatting changes

* unrelated auto-formatting changes

* update to affect interfaceLanguage on success page

* undone prettier changes

* update test for success page translation

* chore

* return null from memo

* fix typecheck error due to atom imports in useLocale

* set default interfaceLanguage as null

* updated to use null instead of constant

* enhancements

* fix latest unit test, use prop instead of useSession hook

* fix build issue

* chore

* fix atom build issue

* fix unit test with reqd mock

* update to use server i18n rendering

* nit

* Move import localeOptions to EventSetupTabWebWrapper

* make sure we only display interface language option in web app

* using customI18nProvider

---------

Co-authored-by: amrit <iamamrit27@gmail.com>
Co-authored-by: Tushar Bhatt <95581504+TusharBhatt1@users.noreply.github.com>
Co-authored-by: Tushar <tusharbhatt0135@gmail.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Ryukemeister <sahalrajiv6900@gmail.com>
Co-authored-by: Rajiv Sahal <sahalrajiv-extc@atharvacoe.ac.in>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
2025-05-18 01:12:26 -04:00
devin-ai-integration[bot]andkeith@cal.com 6cb3bdc567 perf: add p-limit to _getUsersAvailability to limit concurrent executions to 10 (#21374)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: keith@cal.com <keithwillcode@gmail.com>
2025-05-17 17:05:45 -04:00
NISHANT SINGH d574840c3f fix: make 'Send reset email' button text visible on hover (#21334) (#21335)
* fix: ensure button text remains visible on hover in forgot password page

Before: Button text turned black on hover, blending with the dark background.
After: Added 'enabled:hover:text-white' to maintain readability.

* Re-update forgot-password-view.tsx

* Update globals.css brand-text

* Update globals.css --cal-brand-text: white

* Reverted globals.css update

* Update forgot-password-view.tsx , change brand-text color

change "--cal-brand-text": 
white to Black
2025-05-17 09:48:21 +00:00
devin-ai-integration[bot]andkeith@cal.com 6a85d0e10b perf: optimize getSlots performance by selectively merging overlapping date ranges (#21370)
* perf: optimize getSlots performance by selectively merging overlapping date ranges

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: handle date ranges with end time before start time in filterRedundantDateRanges

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* perf: apply filterRedundantDateRanges to all scheduling types

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: preserve uniqueness check before filtering redundant date ranges

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: keith@cal.com <keithwillcode@gmail.com>
2025-05-17 03:44:56 +00:00
devin-ai-integration[bot]andkeith@cal.com 816df3704e perf: Optimize getSlots function to handle large dateRanges arrays efficiently (#21371)
* perf: Optimize getSlots function to handle large dateRanges arrays efficiently

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* Update packages/lib/slots.test.ts

* test: Update performance test to use 2000 date ranges

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* test: Update performance test to process 2000 date ranges across multiple days

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: keith@cal.com <keithwillcode@gmail.com>
2025-05-17 04:00:13 +01:00
Alex van Andel badd9a5698 perf: Better perf by going event type first w/o booking (#21369)
* perf: Better perf by going event type first w/o booking

* minor fixup

* Use an IN with children instead of an OR with parent

* Turns out we already had a variable with the right values

* Make sure the right event type is used even for children

* few fixes

* Full select is needed to keep typings working

* Fix last remaining issue
2025-05-16 17:55:57 -07:00
GitHub Actions 4e02fe4251 chore: release v5.3.1
Post release / release (push) Canceled after 0s
2025-05-17 00:03:32 +00:00
Benny Joo 01b9780938 perf: ignore Object Not Found Matching Id error (#21365) 2025-05-16 23:11:33 +00:00
Anik Dhabal Babu 6be144f95f fix: unable to send verifiation code (#21367) 2025-05-16 23:09:19 +00:00
Anik Dhabal Babu 37dd6d888b fix: add reschedule by (#21363) 2025-05-16 17:14:06 +00:00
Lauris Skraucis f5ffee0a20 feat: automated changelogs and releases by changesets (#21299)
* feat: automated changesets

* chore: update changesets to latest

* readme
2025-05-16 12:52:45 -04:00
Carina WollendorferandCarinaWolli 6cd51e0a8d remove disabled state in addActionDialog (#21362)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-05-16 16:36:29 +00:00
Lauris Skraucis 80fad2aab9 fix: create event type with output of another create event type (#21273)
* feat: accept location booking field with label customization

* feat: return location label

* chore: bump libraries

* test

* fix: tests
2025-05-16 16:34:44 +03:00
Lauris Skraucis 1ccfc65766 fix: POST /v2/bookings validate submitted booking fields (#21163) 2025-05-16 13:00:58 +00:00
Lauris Skraucis 86918b03cf fix: booker atom seated events reservation (#21339)
* fix: reserving first seated booking slot

* fix: input type in useReserveSlot

* fix: handleReserveSlot submit bookingUid to api

* null -> undefined

* dont touch web app
2025-05-16 14:32:06 +02:00
a5b684af1f test: add unit tests for getWhereForTeamOrAllTeams function (#21152)
* test: add unit tests for getWhereForTeamOrAllTeams function

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

* test: remove implementation details and add tests for invalid parameter combinations

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

* test: update mock values to use more distinct numbers

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

* test: update mock values to use completely distinct numbers

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

* test: update mock values to maintain data integrity

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

* test: convert to integration tests for getWhereForTeamOrAllTeams function

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

* chore: remove integration test file

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

* test: reorganize tests with proper describe blocks

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

* test: move test file to __tests__ directory

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

* test: update import path for routing-events in test file

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

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <eunjae@cal.com>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
2025-05-16 08:19:17 +00:00
8889e8566c fix: eventType filter on /insights and add unit tests for buildBaseWhereCondition (#21154)
* test: Add unit tests for buildBaseWhereCondition function

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

* refactor: Export buildBaseWhereCondition function instead of copying it

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

* refactor: Remove implementation detail checks from tests

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

* test: Fix tests to match actual function behavior

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

* test: Fix test issues with buildBaseWhereCondition

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

* test: Update tests to match actual function behavior

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

* fix: Address security issues in buildBaseWhereCondition function

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

* refactor: Simplify buildBaseWhereCondition function

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

* refactor: Simplify code and remove isEmptyResponse property

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

* refactor: Use array of conditions approach for buildBaseWhereCondition

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

* refactor: Make buildBaseWhereCondition implementation consistent and update tests

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

* fix: Fix incorrect usage of buildBaseWhereCondition function

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

* chore: Revert yarn.lock changes

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

* fix: Comment out non-existent Sentry API method to fix type error

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

* Revert "fix: Comment out non-existent Sentry API method to fix type error"

This reverts commit 44c21a7396a518c63047b33967cd8af7e6e4f268.

* remove unnecessary if-statement

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: eunjae@cal.com <eunjae@cal.com>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
2025-05-16 10:10:57 +02:00
fab364f084 fix: Allow zero routingFormResponseId in API v2 available endpoint (#21301)
* Allow zero routingFormResponseId

* fix: conditionally validate routingFormResponseId to allow 0 only for dry run operations

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

* fix: pass _isDryRun parameter to API v2 available endpoint

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

* fix runtime error and improve message

* Add e2e test to verify the constraint works

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: hariom@cal.com <hariom@cal.com>
2025-05-16 12:23:11 +05:30
Devanshu Sharma 5bc9d71a88 fix: (hu) correct typo 'ektávolítás' to 'eltávolítás' in Hungarian translation (#21348) 2025-05-16 03:27:58 +00:00
1083 changed files with 39669 additions and 9367 deletions
+6 -2
View File
@@ -1,11 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": "@changesets/cli/changelog",
"changelog": ["@changesets/changelog-github", { "repo": "calcom/cal.com" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": ["@calcom/platform-libraries"],
"privatePackages": {
"version": false,
"tag": false
}
}
+8
View File
@@ -188,6 +188,10 @@ TWILIO_TOKEN=
TWILIO_MESSAGING_SID=
TWILIO_PHONE_NUMBER=
TWILIO_WHATSAPP_PHONE_NUMBER=
TWILIO_WHATSAPP_REMINDER_CONTENT_SID=
TWILIO_WHATSAPP_CANCELLED_CONTENT_SID=
TWILIO_WHATSAPP_RESCHEDULED_CONTENT_SID=
TWILIO_WHATSAPP_COMPLETED_CONTENT_SID=
# For NEXT_PUBLIC_SENDER_ID only letters, numbers and spaces are allowed (max. 11 characters)
NEXT_PUBLIC_SENDER_ID=
TWILIO_VERIFY_SID=
@@ -441,6 +445,10 @@ NEXT_PUBLIC_INVALIDATE_AVAILABLE_SLOTS_ON_BOOKING_FORM=0
# Used to enable quick availability checks for x% of all visitors
NEXT_PUBLIC_QUICK_AVAILABILITY_ROLLOUT=10
# Used to generate token for cal video recordings expiry token
# You can use: `openssl rand -base64 32` to generate one
CAL_VIDEO_RECORDING_TOKEN_SECRET=
# Deprecated. Use NEXT_PUBLIC_BODY_SCRIPTS instead. NEXT_PUBLIC_HEAD_SCRIPTS are now injected into the body only.
NEXT_PUBLIC_HEAD_SCRIPTS=
NEXT_PUBLIC_BODY_SCRIPTS=
+2 -1
View File
@@ -17,13 +17,14 @@
/packages/app-store/larkcalendar/**/* @calcom/Foundation
/packages/app-store/office365calendar/**/* @calcom/Foundation
/packages/app-store/zohocalendar/**/* @calcom/Foundation
/packages/embeds/**/* @calcom/Foundation
/packages/features/bookings/lib/**/* @calcom/Foundation
/packages/lib/getAggregatedAvailability.ts @calcom/Foundation
/packages/lib/getUserAvailability.ts @calcom/Foundation
/packages/lib/server/getLuckyUser.ts @calcom/Foundation
/packages/lib/slots.ts @calcom/Foundation
/packages/platform/**/* @calcom/Platform @calcom/Foundation
/packages/prisma/**/* @calcom/Foundation
/packages/prisma/**/* @calcom/DBA
/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts @calcom/Foundation
/packages/trpc/server/routers/viewer/bookings/get.handler.ts @calcom/Foundation
/packages/trpc/server/routers/viewer/slots/**/* @calcom/Foundation
+37
View File
@@ -0,0 +1,37 @@
name: Create PR containing updated CHANGELOG.md and release packages to NPM once PR is merged
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions: {} # remove permissions and set explicitly under "permissions:" below
jobs:
release:
if: github.repository == 'calcom/cal.com' # prevent this action from running on forks
permissions:
id-token: write # for NPM provenance - developers can verify where and how it was built
contents: write # to create release by changesets/action below
pull-requests: write # to create pull request by changesets/action below
name: Release
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node, yarn and install dependencies
uses: ./.github/actions/yarn-install
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: yarn changesets-version
publish: yarn changesets-release
commit: "chore: version packages" # commit message
title: "chore: version packages" # PR title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
-21
View File
@@ -1,21 +0,0 @@
name: Submodule Sync
on:
schedule:
# Runs "At minute 15 past every 4th hour." (see https://crontab.guru)
- cron: "15 */4 * * *"
workflow_dispatch: ~
jobs:
submodule-sync:
name: Submodule update
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Commit
run: |
git config user.email "actions@github.com"
git config user.name "github-actions"
git commit -am "Auto updated submodule references" && git push || echo "No changes to commit"
-6
View File
@@ -1,6 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "Updating submodules recursively"
pwd
git submodule update --init --recursive
+2
View File
@@ -0,0 +1,2 @@
undecided:
- "@calcom/prisma"
View File
+2
View File
@@ -0,0 +1,2 @@
undecided:
- "@calcom/prisma"
View File
+6
View File
@@ -0,0 +1,6 @@
undecided:
- "@calcom/platform-constants"
- "@calcom/platform-enums"
- "@calcom/platform-types"
- "@calcom/platform-utils"
- "@calcom/prisma"
View File
+3
View File
@@ -0,0 +1,3 @@
undecided:
- calcom-monorepo
- "@calcom/prisma"
View File
View File
View File
+6
View File
@@ -0,0 +1,6 @@
undecided:
- "@calcom/app-store-cli"
- "@calcom/platform-constants"
- "@calcom/platform-enums"
- "@calcom/platform-types"
- "@calcom/platform-utils"
+8
View File
@@ -0,0 +1,8 @@
undecided:
- calcom-monorepo
- "@calcom/app-store-cli"
- "@calcom/platform-constants"
- "@calcom/platform-enums"
- "@calcom/platform-types"
- "@calcom/platform-utils"
- "@calcom/prisma"
View File
+2
View File
@@ -0,0 +1,2 @@
undecided:
- "@calcom/prisma"
View File
+6
View File
@@ -0,0 +1,6 @@
undecided:
- "@calcom/app-store-cli"
- "@calcom/platform-constants"
- "@calcom/platform-enums"
- "@calcom/platform-types"
- "@calcom/platform-utils"
+3
View File
@@ -0,0 +1,3 @@
undecided:
- calcom-monorepo
- "@calcom/prisma"
+7
View File
@@ -0,0 +1,7 @@
undecided:
- "@calcom/app-store-cli"
- "@calcom/platform-constants"
- "@calcom/platform-enums"
- "@calcom/platform-types"
- "@calcom/platform-utils"
- "@calcom/prisma"
+8
View File
@@ -0,0 +1,8 @@
undecided:
- calcom-monorepo
- "@calcom/app-store-cli"
- "@calcom/platform-constants"
- "@calcom/platform-enums"
- "@calcom/platform-types"
- "@calcom/platform-utils"
- "@calcom/prisma"
View File
View File
View File
+3
View File
@@ -0,0 +1,3 @@
undecided:
- calcom-monorepo
- "@calcom/prisma"
View File
+3
View File
@@ -0,0 +1,3 @@
undecided:
- calcom-monorepo
- "@calcom/prisma"
+189
View File
@@ -0,0 +1,189 @@
# Cal.com Permission Documentation
This document maps existing role-based permission checks to the new PBAC (Permission-Based Access Control) system's permission strings in the format `resource.action`.
## Permissions by Resource
### Team Permissions
| Permission String | Description | File Path | Line |
|------------------|-------------|-----------|------|
| team.create | Create teams | [packages/trpc/server/routers/viewer/teams/create.handler.ts](packages/trpc/server/routers/viewer/teams/create.handler.ts) | 55-57 |
| team.update | Update team settings | [packages/trpc/server/routers/viewer/teams/update.handler.ts](packages/trpc/server/routers/viewer/teams/update.handler.ts) | 18 |
| team.changeMemberRole | Change role of team members | [packages/trpc/server/routers/viewer/teams/changeMemberRole.handler.ts](packages/trpc/server/routers/viewer/teams/changeMemberRole.handler.ts) | 18-21 |
| team.remove | Remove members from team | [packages/trpc/server/routers/viewer/teams/removeMember.handler.ts](packages/trpc/server/routers/viewer/teams/removeMember.handler.ts) | 35-36, 51-55 |
| team.invite | Invite members to team | [packages/trpc/server/routers/viewer/teams/invite.handler.ts](packages/trpc/server/routers/viewer/teams/invite.handler.ts) | - |
### Event Type Permissions
| Permission String | Description | File Path | Line |
|------------------|-------------|-----------|------|
| eventType.create | Create event types | [packages/trpc/server/routers/viewer/eventTypes/create.handler.ts](packages/trpc/server/routers/viewer/eventTypes/create.handler.ts) | - |
| eventType.update | Update event types | [packages/trpc/server/routers/viewer/eventTypes/update.handler.ts](packages/trpc/server/routers/viewer/eventTypes/update.handler.ts) | 162-164 |
| eventType.delete | Delete event types | [packages/trpc/server/routers/viewer/eventTypes/delete.handler.ts](packages/trpc/server/routers/viewer/eventTypes/delete.handler.ts) | 13-31 |
### Booking Permissions
| Permission String | Description | File Path | Line |
|------------------|-------------|-----------|------|
| booking.read | Read booking details | [packages/trpc/server/routers/viewer/bookings/get.handler.ts](packages/trpc/server/routers/viewer/bookings/get.handler.ts) | 95-107, 132-134 |
| booking.readTeamBookings | Read team bookings | [packages/trpc/server/routers/viewer/bookings/get.handler.ts](packages/trpc/server/routers/viewer/bookings/get.handler.ts) | 240-252 |
| booking.readOrgBookings | Read organization bookings | [packages/trpc/server/routers/viewer/bookings/get.handler.ts](packages/trpc/server/routers/viewer/bookings/get.handler.ts) | 240-252 |
### Organization Permissions
| Permission String | Description | File Path | Line |
|------------------|-------------|-----------|------|
| organization.read | Read organization details | [packages/trpc/server/routers/viewer/organizations/get.handler.ts](packages/trpc/server/routers/viewer/organizations/get.handler.ts) | - |
| organization.listMembers | List organization members | [packages/trpc/server/routers/viewer/organizations/listMembers.handler.ts](packages/trpc/server/routers/viewer/organizations/listMembers.handler.ts) | 68-76 |
| organization.create | Create organization | [packages/trpc/server/routers/viewer/organizations/create.handler.ts](packages/trpc/server/routers/viewer/organizations/create.handler.ts) | - |
### API Key Permissions
| Permission String | Description | File Path | Line |
|------------------|-------------|-----------|------|
| apiKey.create | Create API keys | [packages/trpc/server/routers/viewer/apiKeys/create.handler.ts](packages/trpc/server/routers/viewer/apiKeys/create.handler.ts) | 25-26 |
| apiKey.findKeyOfType | Find API keys by type | [packages/trpc/server/routers/viewer/apiKeys/findKeyOfType.handler.ts](packages/trpc/server/routers/viewer/apiKeys/findKeyOfType.handler.ts) | 18-19 |
## Helper Functions and Utilities
The following helper functions are commonly used for permission checks:
| Function | Description | File Path |
|----------|-------------|-----------|
| isTeamAdmin | Checks if user is admin or owner of a team | [packages/lib/server/queries/teams/index.ts](packages/lib/server/queries/teams/index.ts#L385-L405) |
| isTeamOwner | Checks if user is owner of a team | [packages/lib/server/queries/teams/index.ts](packages/lib/server/queries/teams/index.ts#L407-L416) |
| isTeamMember | Checks if user is a member of a team | [packages/lib/server/queries/teams/index.ts](packages/lib/server/queries/teams/index.ts#L418-L426) |
| canEditEntity | Checks if user can edit an entity | [packages/lib/entityPermissionUtils.ts](packages/lib/entityPermissionUtils.ts#L13-L22) |
| canAccessEntity | Checks if user can access an entity | [packages/lib/entityPermissionUtils.ts](packages/lib/entityPermissionUtils.ts#L24-L34) |
| getEntityPermissionLevel | Gets permission level for an entity | [packages/lib/entityPermissionUtils.ts](packages/lib/entityPermissionUtils.ts#L36-L73) |
| canCreateEntity | Checks if user can create an entity | [packages/lib/entityPermissionUtils.ts](packages/lib/entityPermissionUtils.ts#L102-L115) |
| withRoleCanCreateEntity | Checks if role allows entity creation | [packages/lib/entityPermissionUtils.ts](packages/lib/entityPermissionUtils.ts#L119-L121) |
## Permission Level Enums
The codebase uses several enums to define permission levels:
### MembershipRole Enum
```typescript
enum MembershipRole {
OWNER = "OWNER",
ADMIN = "ADMIN",
MEMBER = "MEMBER"
}
```
### Entity Permission Level Enum
```typescript
enum ENTITY_PERMISSION_LEVEL {
NONE,
USER_ONLY_WRITE,
TEAM_READ_ONLY,
TEAM_WRITE
}
```
## Common Permission Patterns
1. **Team Admin/Owner Check**: Many operations require the user to be a team admin or owner.
```typescript
if (!(await isTeamAdmin(ctx.user?.id, input.teamId))) throw new TRPCError({ code: "UNAUTHORIZED" });
```
2. **Team Owner Check**: Some operations (like changing an owner's role) require the user to be a team owner.
```typescript
if (input.role === MembershipRole.OWNER && !(await isTeamOwner(ctx.user?.id, input.teamId)))
throw new TRPCError({ code: "UNAUTHORIZED" });
```
3. **Organization Admin Check**: Operations within an organization require the user to be an organization admin.
```typescript
if (user.profile?.organizationId && !user.organization.isOrgAdmin) {
throw new TRPCError({ code: "FORBIDDEN", message: "org_admins_can_create_new_teams" });
}
```
4. **Entity Permission Check**: Entity operations use permission level checks.
```typescript
const permissionLevel = await getEntityPermissionLevel(entity, userId);
return permissionLevel === ENTITY_PERMISSION_LEVEL.TEAM_WRITE ||
permissionLevel === ENTITY_PERMISSION_LEVEL.USER_ONLY_WRITE;
```
5. **Booking Access Control**: Complex permission checks for retrieving bookings based on user roles and team/organization membership.
```typescript
const membershipIdsWhereUserIsAdminOwner = (
await prisma.membership.findMany({
where: {
userId: user.id,
role: {
in: ["ADMIN", "OWNER"],
},
},
select: {
id: true,
},
})
).map((membership) => membership.id);
```
## Migration to PBAC
When migrating to the new PBAC system, these existing role-based checks should be replaced with permission string checks using the `permissionMatches` function:
```typescript
import { permissionMatches } from "@calcom/features/pbac/types/permission-registry";
// Instead of:
if (!(await isTeamAdmin(ctx.user?.id, input.teamId))) throw new TRPCError({ code: "UNAUTHORIZED" });
// Use:
if (!permissionMatches("team.update", userPermissions)) throw new TRPCError({ code: "UNAUTHORIZED" });
```
## Permission String Alternatives for Helper Functions
The following table provides permission string alternatives for common helper functions:
| Helper Function | Permission String Alternative | Description |
|-----------------|-------------------------------|-------------|
| isTeamAdmin | `team.*` | Grants all team permissions |
| isTeamAdmin | `team.update` | Update team settings |
| isTeamAdmin | `team.invite` | Invite team members |
| isTeamAdmin | `team.remove` | Remove team members |
| isTeamOwner | `team.changeMemberRole` | Change role of team members |
| isTeamOwner | `team.delete` | Delete team |
| isTeamMember | `team.read` | Read-only access to team |
## Entity Permission Functions and Resources
The following functions are used to check permissions for entities with userId and teamId properties:
| Function | Description | Permission String Alternative |
|----------|-------------|-------------------------------|
| canEditEntity | Checks if user can edit an entity | `{resource}.update` |
| canAccessEntity | Checks if user can access an entity | `{resource}.read` |
| getEntityPermissionLevel | Gets permission level for an entity | N/A - Implementation detail |
| canCreateEntity | Checks if user can create an entity | `{resource}.create` |
### Resources Used with Entity Permission Functions
| Resource | canEditEntity Usage | canAccessEntity Usage | Permission String |
|----------|-------------------|---------------------|------------------|
| routingForm | [packages/app-store/routing-forms/trpc/forms.handler.ts](packages/app-store/routing-forms/trpc/forms.handler.ts#L72) | [packages/app-store/routing-forms/trpc/getResponseWithFormFields.handler.ts](packages/app-store/routing-forms/trpc/getResponseWithFormFields.handler.ts#L78) | `routingForm.update`, `routingForm.read` |
| routingForm | [packages/app-store/routing-forms/trpc/formMutation.handler.ts](packages/app-store/routing-forms/trpc/formMutation.handler.ts#L315) | | `routingForm.update` |
| routingForm | [packages/app-store/routing-forms/api/responses/[formId].ts](packages/app-store/routing-forms/api/responses/[formId].ts#L96) | | `routingForm.update` |
These functions can be used with any entity that has userId and teamId properties. When migrating to PBAC, replace these checks with appropriate permission string checks:
```typescript
// Instead of:
if (!(await canEditEntity(form, user.id))) throw new TRPCError({ code: "UNAUTHORIZED" });
// Use:
if (!permissionMatches("routingForm.update", userPermissions)) throw new TRPCError({ code: "UNAUTHORIZED" });
```
This allows for more granular permission control and the creation of custom roles with specific permissions.
+8
View File
@@ -646,6 +646,14 @@ following
15. Create a verify service
16. Copy Verify Service SID to your `.env` file into the `TWILIO_VERIFY_SID` field
## Changesets
We use changesets to generate changelogs and publish public packages (packages with `private: true` are ignored).
An example of good readme is [atoms readme](https://github.com/calcom/cal.com/blob/main/packages/platform/atoms/README.md). Every public package must:
1. Follow semantic versioning when using changesets.
2. Mark breaking changes using `❗️Breaking change`
<!-- LICENSE -->
## License
+1
View File
@@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"scripts": {
"dev": "node ./index.js"
},
@@ -1,4 +1,4 @@
import prismock from "../../../../../../tests/libs/__mocks__/prisma";
import prismock from "../../../../../tests/libs/__mocks__/prisma";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -7,12 +7,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { ILicenseKeyService } from "@calcom/ee/common/server/LicenseKeyService";
import LicenseKeyService from "@calcom/ee/common/server/LicenseKeyService";
import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys";
import type { IDeploymentRepository } from "@calcom/lib/server/repository/deployment.interface";
import prisma from "@calcom/prisma";
import { MembershipRole, UserPermissionRole } from "@calcom/prisma/enums";
import { hashAPIKey } from "~/../../../packages/features/ee/api-keys/lib/apiKeys";
import { verifyApiKey } from "../../../lib/helpers/verifyApiKey";
import { verifyApiKey } from "./verifyApiKey";
type CustomNextApiRequest = NextApiRequest & Request;
type CustomNextApiResponse = NextApiResponse & Response;
@@ -21,11 +21,16 @@ afterEach(() => {
vi.resetAllMocks();
});
describe("Verify API key", () => {
const mockDeploymentRepository: IDeploymentRepository = {
getLicenseKeyWithId: vi.fn().mockResolvedValue("mockLicenseKey"), // Mocked return value
};
// TODO: Fix the skip condition for this test suite
describe.skip("Verify API key", () => {
let service: ILicenseKeyService;
beforeEach(async () => {
service = await LicenseKeyService.create();
service = await LicenseKeyService.create(mockDeploymentRepository);
vi.spyOn(service, "checkLicense");
});
+4 -2
View File
@@ -3,6 +3,7 @@ import type { NextMiddleware } from "next-api-middleware";
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys";
import { IS_PRODUCTION } from "@calcom/lib/constants";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import prisma from "@calcom/prisma";
import { isAdminGuard } from "../utils/isAdmin";
@@ -19,11 +20,12 @@ export const dateNotInPast = function (date: Date) {
// This verifies the apiKey and sets the user if it is valid.
export const verifyApiKey: NextMiddleware = async (req, res, next) => {
const licenseKeyService = await LicenseKeySingleton.getInstance();
const deploymentRepo = new DeploymentRepository(prisma);
const licenseKeyService = await LicenseKeySingleton.getInstance(deploymentRepo);
const hasValidLicense = await licenseKeyService.checkLicense();
if (!hasValidLicense && IS_PRODUCTION) {
return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" });
return res.status(401).json({ message: "Invalid or missing CALCOM_LICENSE_KEY environment variable" });
}
if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" });
+6 -2
View File
@@ -1,6 +1,10 @@
import { z } from "zod";
import { MAX_SEATS_PER_TIME_SLOT } from "@calcom/lib/constants";
import {
MAX_SEATS_PER_TIME_SLOT,
MAX_EVENT_DURATION_MINUTES,
MIN_EVENT_DURATION_MINUTES,
} from "@calcom/lib/constants";
import slugify from "@calcom/lib/slugify";
import { _EventTypeModel as EventType, _HostModel } from "@calcom/prisma/zod";
import { customInputSchema, eventTypeBookingFields } from "@calcom/prisma/zod-utils";
@@ -80,7 +84,7 @@ const schemaEventTypeCreateParams = z
title: z.string(),
slug: z.string().transform((s) => slugify(s)),
description: z.string().optional().nullable(),
length: z.number().int(),
length: z.number().int().min(MIN_EVENT_DURATION_MINUTES).max(MAX_EVENT_DURATION_MINUTES),
metadata: z.any().optional(),
recurringEvent: recurringEventInputSchema.optional(),
seatsPerTimeSlot: z.number().optional(),
@@ -18,6 +18,11 @@ export const schemaSelectedCalendarBodyParams = schemaSelectedCalendarBaseBodyPa
id: true,
// No eventTypeId support in API v1
eventTypeId: true,
/** No watch related fields support in API v1 */
watchAttempts: true,
unwatchAttempts: true,
maxAttempts: true,
});
export const schemaSelectedCalendarUpdateBodyParams = schemaSelectedCalendarBaseBodyParams
+1 -1
View File
@@ -38,7 +38,7 @@
"next-axiom": "^0.17.0",
"next-swagger-doc": "^0.3.6",
"next-validations": "^0.2.0",
"typescript": "^4.9.4",
"typescript": "^5.7.2",
"tzdata": "^1.0.30",
"uuid": "^8.3.2",
"zod": "^3.22.4"
-5
View File
@@ -42,11 +42,6 @@ describe("GET /api/slots", () => {
await handler(req, res);
expect(res.statusCode).toBe(400);
expect(JSON.parse(res._getData())).toMatchInlineSnapshot(`
{
"message": "invalid_type in 'startTime': Required; invalid_type in 'endTime': Required",
}
`);
});
});
@@ -38,7 +38,8 @@ describe("GET /api/bookings", async () => {
expect(responseData.bookings.find((b) => b.userId === memberUser.id)).toBeDefined();
expect(groupedUsers.size).toBe(1);
expect(groupedUsers.entries().next().value[0]).toBe(memberUser.id);
const firstEntry = groupedUsers.entries().next().value;
expect(firstEntry?.[0]).toBe(memberUser.id);
});
it("Returns bookings for regular user", async () => {
@@ -89,6 +89,10 @@ describe("POST /api/selected-calendars", () => {
googleChannelResourceUri: null,
googleChannelExpiration: null,
error: null,
lastErrorAt: null,
watchAttempts: 0,
maxAttempts: 3,
unwatchAttempts: 0,
});
await handler(req, res);
@@ -128,6 +132,10 @@ describe("POST /api/selected-calendars", () => {
domainWideDelegationCredentialId: null,
eventTypeId: null,
error: null,
lastErrorAt: null,
watchAttempts: 0,
maxAttempts: 3,
unwatchAttempts: 0,
});
await handler(req, res);
+5 -1
View File
@@ -37,4 +37,8 @@ AXIOM_TOKEN=
# INFO: 1
# WARN: 2
# ERROR: 3
LOGGER_BRIDGE_LOG_LEVEL="1"
LOGGER_BRIDGE_LOG_LEVEL="1"
# 1: Rewrite /api/v2 to /v2
# 0: Don't rewrite
REWRITE_API_V2_PREFIX="1"
+3 -3
View File
@@ -3,8 +3,8 @@
"version": "0.0.1",
"description": "Platform API for Cal.com",
"author": "Cal.com Inc.",
"private": true,
"license": "UNLICENSED",
"private": true,
"scripts": {
"build": "yarn dev:build && nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
@@ -38,7 +38,7 @@
"@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*",
"@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.197",
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.231",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2",
"@calcom/platform-types": "*",
"@calcom/platform-utils": "*",
@@ -109,7 +109,7 @@
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.0",
"typescript": "^5.8.2"
"typescript": "^5.7.2"
},
"prisma": {
"schema": "../../../packages/prisma/schema.prisma"
+10 -4
View File
@@ -86,10 +86,16 @@ export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer): void {
consumer
.apply(RawBodyMiddleware)
.forRoutes({
path: "/api/v2/billing/webhook",
method: RequestMethod.POST,
})
.forRoutes(
{
path: "/api/v2/billing/webhook",
method: RequestMethod.POST,
},
{
path: "/v2/billing/webhook",
method: RequestMethod.POST,
}
)
.apply(JsonBodyMiddleware)
.forRoutes("*")
.apply(RequestIdMiddleware)
+4
View File
@@ -81,5 +81,9 @@ export const bootstrap = (app: NestExpressApplication): NestExpressApplication =
app.use(cookieParser());
if (process?.env?.API_GLOBAL_PREFIX) {
app.setGlobalPrefix(process?.env?.API_GLOBAL_PREFIX);
}
return app;
};
+1 -1
View File
@@ -36,7 +36,7 @@ const loadConfig = (): AppConfig => {
app: {
baseUrl: getEnv("WEB_APP_URL", "https://app.cal.com"),
},
e2e: getEnv("IS_E2E", false),
e2e: getEnv("IS_E2E", "false") === "true" ? true : false,
};
};
@@ -77,6 +77,7 @@ type OAuthRequestParams = {
platformBookingUrl: string;
platformBookingLocation?: string;
arePlatformEmailsEnabled: boolean;
areCalendarEventsEnabled: boolean;
};
const DEFAULT_PLATFORM_PARAMS = {
@@ -86,6 +87,7 @@ const DEFAULT_PLATFORM_PARAMS = {
platformBookingUrl: "",
arePlatformEmailsEnabled: false,
platformBookingLocation: undefined,
areCalendarEventsEnabled: false,
};
@Controller({
@@ -135,9 +137,13 @@ export class BookingsController_2024_04_15 {
},
});
let nextCursor = null;
if (bookings.totalCount > (cursor ?? 0) + (limit ?? 10)) {
nextCursor = (cursor ?? 0) + (limit ?? 10);
}
return {
status: SUCCESS_STATUS,
data: bookings,
data: { ...bookings, nextCursor },
};
}
@@ -191,6 +197,7 @@ export class BookingsController_2024_04_15 {
platformCancelUrl: bookingRequest.platformCancelUrl,
platformBookingUrl: bookingRequest.platformBookingUrl,
platformBookingLocation: bookingRequest.platformBookingLocation,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
});
if (booking.userId && booking.uid && booking.startTime) {
void (await this.billingService.increaseUsageByUserId(booking.userId, {
@@ -424,7 +431,7 @@ export class BookingsController_2024_04_15 {
if (isEmbed) {
// embed should ignore oauth client settings and enable emails by default
return { ...res, arePlatformEmailsEnabled: true };
return { ...res, arePlatformEmailsEnabled: true, areCalendarEventsEnabled: true };
}
try {
@@ -436,6 +443,7 @@ export class BookingsController_2024_04_15 {
res.platformRescheduleUrl = client.bookingRescheduleRedirectUri ?? "";
res.platformBookingUrl = client.bookingRedirectUri ?? "";
res.arePlatformEmailsEnabled = client.areEmailsEnabled ?? false;
res.areCalendarEventsEnabled = client.areCalendarEventsEnabled;
}
return res;
} catch (err) {
@@ -16,13 +16,15 @@ import {
import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants";
enum Status {
CANCELLED = "CANCELLED",
REJECTED = "REJECTED",
ACCEPTED = "ACCEPTED",
PENDING = "PENDING",
AWAITING_HOST = "AWAITING_HOST",
}
const Status = {
CANCELLED: "CANCELLED",
REJECTED: "REJECTED",
ACCEPTED: "ACCEPTED",
PENDING: "PENDING",
AWAITING_HOST: "AWAITING_HOST",
} as const;
export type Status = (typeof Status)[keyof typeof Status];
class Attendee {
@IsInt()
@@ -24,4 +24,26 @@ export class BookingReferencesRepository_2024_08_13 {
},
});
}
async getBookingReferencesIncludeSensitiveCredentials(eventUid: string) {
return this.dbRead.prisma.bookingReference.findFirst({
where: {
uid: eventUid,
},
include: {
credential: true,
delegationCredential: true,
booking: {
select: {
user: {
select: {
id: true,
email: true,
},
},
},
},
},
});
}
}
@@ -3,6 +3,7 @@ import { BookingsRepository_2024_08_13 } from "@/ee/bookings/2024-08-13/bookings
import { BookingsController_2024_08_13 } from "@/ee/bookings/2024-08-13/controllers/bookings.controller";
import { BookingReferencesService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-references.service";
import { BookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/bookings.service";
import { CalVideoService } from "@/ee/bookings/2024-08-13/services/cal-video.service";
import { ErrorsBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/errors.service";
import { InputBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/input.service";
import { OutputBookingReferencesService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/output-booking-references.service";
@@ -77,6 +78,7 @@ import { Module } from "@nestjs/common";
ErrorsBookingsService_2024_08_13,
BookingReferencesService_2024_08_13,
BookingReferencesRepository_2024_08_13,
CalVideoService,
],
controllers: [BookingsController_2024_08_13],
exports: [InputBookingsService_2024_08_13, OutputBookingsService_2024_08_13, BookingsService_2024_08_13],
@@ -169,4 +169,15 @@ export class BookingsRepository_2024_08_13 {
},
});
}
async getByUidWithBookingReference(uid: string) {
return this.dbRead.prisma.booking.findUnique({
where: {
uid,
},
select: {
references: true,
},
});
}
}
@@ -9,6 +9,7 @@ import { ReassignBookingOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outpu
import { RescheduleBookingOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outputs/reschedule-booking.output";
import { BookingReferencesService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-references.service";
import { BookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/bookings.service";
import { CalVideoService } from "@/ee/bookings/2024-08-13/services/cal-video.service";
import { VERSION_2024_08_13_VALUE, VERSION_2024_08_13 } from "@/lib/api-versions";
import { API_KEY_OR_ACCESS_TOKEN_HEADER } from "@/lib/docs/headers";
import { PlatformPlan } from "@/modules/auth/decorators/billing/platform-plan.decorator";
@@ -54,6 +55,8 @@ import {
RescheduleBookingInput_2024_08_13,
RescheduleBookingInputPipe,
RescheduleSeatedBookingInput_2024_08_13,
GetBookingRecordingsOutput,
GetBookingTranscriptsOutput,
} from "@calcom/platform-types";
import {
CreateBookingInputPipe,
@@ -88,7 +91,8 @@ export class BookingsController_2024_08_13 {
constructor(
private readonly bookingsService: BookingsService_2024_08_13,
private readonly usersService: UsersService,
private readonly bookingReferencesService: BookingReferencesService_2024_08_13
private readonly bookingReferencesService: BookingReferencesService_2024_08_13,
private readonly calVideoService: CalVideoService
) {}
@Post("/")
@@ -171,6 +175,36 @@ export class BookingsController_2024_08_13 {
};
}
@Get("/:bookingUid/recordings")
@UseGuards(BookingUidGuard)
@ApiOperation({
summary: "Get all the recordings for the booking",
description: `Fetches all the recordings for the booking \`:bookingUid\``,
})
async getBookingRecordings(@Param("bookingUid") bookingUid: string): Promise<GetBookingRecordingsOutput> {
const recordings = await this.calVideoService.getRecordings(bookingUid);
return {
status: SUCCESS_STATUS,
data: recordings,
};
}
@Get("/:bookingUid/transcripts")
@UseGuards(BookingUidGuard)
@ApiOperation({
summary: "Get all the transcripts download links for the booking",
description: `Fetches all the transcripts download links for the booking \`:bookingUid\``,
})
async getBookingTranscripts(@Param("bookingUid") bookingUid: string): Promise<GetBookingTranscriptsOutput> {
const transcripts = await this.calVideoService.getTranscripts(bookingUid);
return {
status: SUCCESS_STATUS,
data: transcripts ?? [],
};
}
@Get("/")
@UseGuards(ApiAuthGuard)
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@@ -233,7 +267,14 @@ export class BookingsController_2024_08_13 {
@ApiOperation({
summary: "Cancel a booking",
description: `:bookingUid can be :bookingUid of an usual booking, individual recurrence or recurring booking to cancel all recurrences.
For seated bookings to cancel one individual booking provide :bookingUid and :seatUid in the request body. For recurring seated bookings it is not possible to cancel all of them with 1 call
\nCancelling seated bookings:
It is possible to cancel specific seat within a booking as an attendee or all of the seats as the host.
\n1. As an attendee - provide :bookingUid in the request URL \`/bookings/:bookingUid/cancel\` and seatUid in the request body \`{"seatUid": "123-123-123"}\` . This will remove this particular attendance from the booking.
\n2. As the host - host can cancel booking for all attendees aka for every seat. Provide :bookingUid in the request URL \`/bookings/:bookingUid/cancel\` and cancellationReason in the request body \`{"cancellationReason": "Will travel"}\` and \`Authorization: Bearer token\` request header where token is event type owner (host) credential. This will cancel the booking for all attendees.
\nCancelling recurring seated bookings:
For recurring seated bookings it is not possible to cancel all of them with 1 call
like with non-seated recurring bookings by providing recurring bookind uid - you have to cancel each recurrence booking by its bookingUid + seatUid.`,
})
@ApiBody({
@@ -290,7 +331,8 @@ export class BookingsController_2024_08_13 {
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Reassign a booking to auto-selected host",
description: "The provided authorization header refers to the owner of the booking.",
description:
"Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
})
async reassignBooking(
@Param("bookingUid") bookingUid: string,
@@ -311,7 +353,8 @@ export class BookingsController_2024_08_13 {
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Reassign a booking to a specific host",
description: "The provided authorization header refers to the owner of the booking.",
description:
"Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
})
async reassignBookingToUser(
@Param("bookingUid") bookingUid: string,
@@ -55,6 +55,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
let eventTypeId: number;
let seatedEvent: EventType;
let eventTypeWithBookingFields: EventType;
let eventTypeWithBookingFielsCustom: EventType;
const eventTypeSlug = `booking-fields-2024-08-13-event-type-${randomString()}`;
const eventTypeWithBookingFieldsSlug = `booking-fields-2024-08-13-event-type-${randomString()}`;
const seatedEventTypeSlug = `booking-fields-2024-08-13-event-type-${randomString()}`;
@@ -331,6 +332,313 @@ describe("Bookings Endpoints 2024-08-13", () => {
user.id
);
eventTypeWithBookingFielsCustom = await eventTypesRepositoryFixture.create(
{
title: "test booking field types",
slug: "test-booking-field-types",
length: 30,
bookingFields: [
{
name: "name",
type: "name",
sources: [{ id: "default", type: "default", label: "Default" }],
variant: "fullName",
editable: "system",
required: true,
defaultLabel: "your_name",
variantsConfig: {
variants: {
fullName: {
fields: [
{
name: "fullName",
type: "text",
required: true,
},
],
},
firstAndLastName: {
fields: [
{
name: "firstName",
type: "text",
label: "",
required: true,
placeholder: "",
},
{
name: "lastName",
type: "text",
label: "",
required: false,
placeholder: "",
},
],
},
},
},
},
{
name: "email",
type: "email",
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system",
required: true,
defaultLabel: "email_address",
},
{
name: "location",
type: "radioInput",
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system",
required: false,
defaultLabel: "location",
getOptionsAt: "locations",
optionsInputs: {
phone: { type: "phone", required: true, placeholder: "" },
somewhereElse: { type: "text", required: true, placeholder: "" },
attendeeInPerson: { type: "address", required: true, placeholder: "" },
},
hideWhenJustOneOption: true,
},
{
name: "test-phone",
type: "phone",
label: "test-phone",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-address",
type: "address",
label: "test-address",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-text",
type: "text",
label: "test-text",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-number",
type: "number",
label: "test-number",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-textarea",
type: "textarea",
label: "test-textarea",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-boolean",
type: "boolean",
label: "test-boolean",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
labelAsSafeHtml: "<p>test-boolean</p>\n",
disableOnPrefill: false,
},
{
name: "test-url",
type: "url",
label: "test-url",
hidden: false,
sources: [{ id: "user", type: "user", label: "User", fieldRequired: true }],
editable: "user",
required: false,
placeholder: "",
labelAsSafeHtml: "<p>test-url</p>\n",
disableOnPrefill: false,
},
{
name: "test-multiemail",
type: "multiemail",
label: "test-multiemail",
hidden: false,
sources: [
{
id: "user",
type: "user",
label: "User",
fieldRequired: true,
},
],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-multiselect",
type: "multiselect",
label: "test-multiselect",
hidden: false,
options: [
{
label: "apple",
value: "apple",
},
{
label: "orange",
value: "orange",
},
],
sources: [
{
id: "user",
type: "user",
label: "User",
fieldRequired: true,
},
],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-checkbox",
type: "checkbox",
label: "test-checkbox",
hidden: false,
options: [
{
label: "blue",
value: "blue",
},
{
label: "red",
value: "red",
},
],
sources: [
{
id: "user",
type: "user",
label: "User",
fieldRequired: true,
},
],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-radio",
type: "radio",
label: "test-radio",
hidden: false,
options: [
{
label: "pineapple",
value: "pineapple",
},
],
sources: [
{
id: "user",
type: "user",
label: "User",
fieldRequired: true,
},
],
editable: "user",
required: false,
disableOnPrefill: false,
},
{
name: "test-select",
type: "select",
label: "test-select",
options: [
{
label: "water",
value: "water",
},
{
label: "juice",
value: "juice",
},
],
sources: [
{
id: "user",
type: "user",
label: "User",
fieldRequired: true,
},
],
editable: "user",
required: true,
placeholder: "",
disableOnPrefill: false,
},
{
name: "title",
type: "text",
hidden: true,
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system-but-optional",
required: true,
defaultLabel: "what_is_this_meeting_about",
defaultPlaceholder: "",
},
{
name: "notes",
type: "textarea",
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system-but-optional",
required: false,
defaultLabel: "additional_notes",
defaultPlaceholder: "share_additional_notes",
},
{
name: "guests",
type: "multiemail",
hidden: false,
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system-but-optional",
required: false,
defaultLabel: "additional_guests",
defaultPlaceholder: "email",
},
{
name: "rescheduleReason",
type: "textarea",
views: [{ id: "reschedule", label: "Reschedule View" }],
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system-but-optional",
required: false,
defaultLabel: "reason_for_reschedule",
defaultPlaceholder: "reschedule_placeholder",
},
],
},
user.id
);
bookingWithSplitName = await bookingsRepositoryFixture.create({
user: {
connect: {
@@ -543,6 +851,318 @@ describe("Bookings Endpoints 2024-08-13", () => {
});
});
describe("Booking Field Type Validation", () => {
const basePayload = {
start: "2025-06-19T11:00:00.000Z",
attendee: {
name: "Charlie TypeTest",
email: "charlie.typetest@example.com",
timeZone: "Europe/Madrid",
language: "en",
},
};
it("should reject with 400 if 'test-phone' (phone) is not a string", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-phone": 12345,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-phone'. Expected type string (compatible with field type 'phone'), but received number."
);
});
it("should reject with 400 if 'test-address' (address) is not a string", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-address": true,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-address'. Expected type string (compatible with field type 'address'), but received boolean."
);
});
it("should reject with 400 if 'test-text' (text) is not a string", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-text": 123,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-text'. Expected type string (compatible with field type 'text'), but received number."
);
});
it("should reject with 400 if 'test-number' (number) is not a number", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-number": "123",
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-number'. Expected type number (compatible with field type 'number'), but received string."
);
});
it("should reject with 400 if 'test-textarea' (textarea) is not a string", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-textarea": { text: "invalid" },
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-textarea'. Expected type string (compatible with field type 'textarea'), but received object."
);
});
it("should reject with 400 if 'test-boolean' (boolean) is not a boolean", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-boolean": "true",
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-boolean'. Expected type boolean (compatible with field type 'boolean'), but received string."
);
});
it("should reject with 400 if 'test-url' (url) is not a string", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-url": 12345,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-url'. Expected type string (compatible with field type 'url'), but received number."
);
});
it("should reject with 400 if 'test-multiemail' (multiemail) is not an array", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-multiemail": "not-an-array@example.com",
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-multiemail'. Expected type array (compatible with field type 'multiemail'), but received string."
);
});
it("should reject with 400 if 'test-multiselect' (multiselect) is not an array", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-multiselect": "not-an-array",
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-multiselect'. Expected type array (compatible with field type 'multiselect'), but received string."
);
});
it("should reject with 400 if 'test-checkbox' (checkbox) is not an array", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-checkbox": true,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-checkbox'. Expected type array (compatible with field type 'checkbox'), but received boolean."
);
});
it("should reject with 400 if 'test-radio' (radio) is not a string or number", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-radio": true,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-radio'. Expected type string or number (compatible with field type 'radio'), but received boolean."
);
});
it("should reject with 400 if 'test-select' (select) is not a string or number", async () => {
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
"test-select": true,
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13);
expect(response.status).toBe(400);
expect(response.body.error.message).toBe(
"Invalid type for booking field 'test-select'. Expected type string or number (compatible with field type 'select'), but received boolean."
);
});
it("should throw BadRequestException for test-select field with invalid option", async () => {
const fieldName = "test-select";
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
[fieldName]: "INVALID_DRINK",
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toBe(
`Invalid option 'INVALID_DRINK' for booking field '${fieldName}'. Allowed options are: water, juice.`
);
});
it("should throw BadRequestException for test-radio field with invalid option", async () => {
const fieldName = "test-radio";
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
[fieldName]: "INVALID_FRUIT_FOR_RADIO",
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toBe(
`Invalid option 'INVALID_FRUIT_FOR_RADIO' for booking field '${fieldName}'. Allowed options are: pineapple.`
);
});
it("should throw BadRequestException for test-multiselect field with an invalid option", async () => {
const fieldName = "test-multiselect";
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
[fieldName]: ["apple", "INVALID_FRUIT"],
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toBe(
`One or more invalid options for booking field '${fieldName}'. Allowed options are: apple, orange.`
);
});
it("should throw BadRequestException for test-checkbox field with invalid options", async () => {
const fieldName = "test-checkbox";
const payload = {
...basePayload,
eventTypeId: eventTypeWithBookingFielsCustom.id,
bookingFieldsResponses: {
[fieldName]: ["blue", "INVALID_COLOR"],
},
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings`)
.send(payload)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toBe(
`One or more invalid options for booking field '${fieldName}'. Allowed options are: blue, red.`
);
});
});
afterAll(async () => {
await oauthClientRepositoryFixture.delete(oAuthClient.id);
await teamRepositoryFixture.delete(organization.id);
@@ -874,9 +874,8 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => {
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(AttendeeScheduledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(AttendeeRescheduledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(AttendeeRescheduledEmail.prototype.getHtml).toHaveBeenCalled();
expect(OrganizerRescheduledEmail.prototype.getHtml).toHaveBeenCalled();
expect(OrganizerScheduledEmail.prototype.getHtml).toHaveBeenCalled();
expect(OrganizerCancelledEmail.prototype.getHtml).toHaveBeenCalled();
emailsEnabledSetup.roundRobinEventType.rescheduledBookingUid = responseBody.data.uid;
@@ -14,29 +14,27 @@ import { Test } from "@nestjs/testing";
import { User } from "@prisma/client";
import { DateTime } from "luxon";
import * as request from "supertest";
import { ApiKeysRepositoryFixture } from "test/fixtures/repository/api-keys.repository.fixture";
import { BookingSeatRepositoryFixture } from "test/fixtures/repository/booking-seat.repository.fixture";
import { BookingsRepositoryFixture } from "test/fixtures/repository/bookings.repository.fixture";
import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-types.repository.fixture";
import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture";
import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture";
import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture";
import { randomString } from "test/utils/randomString";
import { withApiAuth } from "test/utils/withApiAuth";
import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants";
import {
CancelBookingInput_2024_08_13,
CancelSeatedBookingInput_2024_08_13,
CreateRecurringSeatedBookingOutput_2024_08_13,
CreateSeatedBookingOutput_2024_08_13,
GetBookingOutput_2024_08_13,
GetBookingsOutput_2024_08_13,
GetRecurringSeatedBookingOutput_2024_08_13,
GetSeatedBookingOutput_2024_08_13,
RescheduleSeatedBookingInput_2024_08_13,
} from "@calcom/platform-types";
import {
CreateBookingInput_2024_08_13,
CreateRecurringBookingInput_2024_08_13,
} from "@calcom/platform-types";
import { CreateBookingInput_2024_08_13 } from "@calcom/platform-types";
import { PlatformOAuthClient, Team } from "@calcom/prisma/client";
describe("Bookings Endpoints 2024-08-13", () => {
@@ -51,11 +49,13 @@ describe("Bookings Endpoints 2024-08-13", () => {
let schedulesService: SchedulesService_2024_04_15;
let eventTypesRepositoryFixture: EventTypesRepositoryFixture;
let oauthClientRepositoryFixture: OAuthClientRepositoryFixture;
let oAuthClient: PlatformOAuthClient;
let teamRepositoryFixture: TeamRepositoryFixture;
let apiKeysRepositoryFixture: ApiKeysRepositoryFixture;
let bookingSeatRepositoryFixture: BookingSeatRepositoryFixture;
const userEmail = `seated-bookings-user-${randomString()}@api.com`;
let user: User;
let apiKeyString: string;
let seatedEventTypeId: number;
const maxRecurrenceCount = 3;
@@ -63,6 +63,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
const seatedEventSlug = `seated-bookings-event-type-${randomString()}`;
let createdSeatedBooking: CreateSeatedBookingOutput_2024_08_13;
let createdSeatedBooking2: CreateSeatedBookingOutput_2024_08_13;
const emailAttendeeOne = `seated-bookings-attendee1-${randomString()}@api.com`;
const nameAttendeeOne = `Attendee One ${randomString()}`;
@@ -70,12 +71,9 @@ describe("Bookings Endpoints 2024-08-13", () => {
const nameAttendeeTwo = `Attendee Two ${randomString()}`;
beforeAll(async () => {
const moduleRef = await withApiAuth(
userEmail,
Test.createTestingModule({
imports: [AppModule, PrismaModule, UsersModule, SchedulesModule_2024_04_15],
})
)
const moduleRef = await Test.createTestingModule({
imports: [AppModule, PrismaModule, UsersModule, SchedulesModule_2024_04_15],
})
.overrideGuard(PermissionsGuard)
.useValue({
canActivate: () => true,
@@ -87,22 +85,21 @@ describe("Bookings Endpoints 2024-08-13", () => {
eventTypesRepositoryFixture = new EventTypesRepositoryFixture(moduleRef);
oauthClientRepositoryFixture = new OAuthClientRepositoryFixture(moduleRef);
teamRepositoryFixture = new TeamRepositoryFixture(moduleRef);
apiKeysRepositoryFixture = new ApiKeysRepositoryFixture(moduleRef);
schedulesService = moduleRef.get<SchedulesService_2024_04_15>(SchedulesService_2024_04_15);
bookingSeatRepositoryFixture = new BookingSeatRepositoryFixture(moduleRef);
organization = await teamRepositoryFixture.create({
name: `seated-bookings-organization-${randomString()}`,
});
oAuthClient = await createOAuthClient(organization.id);
user = await userRepositoryFixture.create({
email: userEmail,
platformOAuthClients: {
connect: {
id: oAuthClient.id,
},
},
});
const { keyString } = await apiKeysRepositoryFixture.createApiKey(user.id, null);
apiKeyString = `cal_test_${keyString}`;
const userSchedule: CreateScheduleInput_2024_04_15 = {
name: `seated-bookings-2024-08-13-schedule-${randomString()}`,
timeZone: "Europe/Rome",
@@ -118,6 +115,14 @@ describe("Bookings Endpoints 2024-08-13", () => {
seatsShowAttendees: true,
seatsShowAvailabilityCount: true,
locations: [{ type: "inPerson", address: "via 10, rome, italy" }],
metadata: {
disableStandardEmails: {
all: {
attendee: true,
host: true,
},
},
},
},
user.id
);
@@ -129,19 +134,6 @@ describe("Bookings Endpoints 2024-08-13", () => {
await app.init();
});
async function createOAuthClient(organizationId: number) {
const data = {
logo: "logo-url",
name: "name",
redirectUris: ["http://localhost:5555"],
permissions: 32,
};
const secret = "secret";
const client = await oauthClientRepositoryFixture.create(organizationId, data, secret);
return client;
}
it("should book an event type with seats for the first time", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2030, 0, 8, 13, 0, 0)).toISOString(),
@@ -333,6 +325,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
return request(app.getHttpServer())
.get("/v2/bookings?sortCreated=asc")
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.set("Authorization", `Bearer ${apiKeyString}`)
.expect(200)
.then(async (response) => {
const responseBody: GetBookingsOutput_2024_08_13 = response.body;
@@ -350,6 +343,22 @@ describe("Bookings Endpoints 2024-08-13", () => {
});
});
it("should not be able to reschedule seated booking if seatUid is not provided", async () => {
const body = {
start: new Date(Date.UTC(2030, 0, 8, 15, 0, 0)).toISOString(),
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings/${createdSeatedBooking.uid}/reschedule`)
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toEqual(
`Booking with uid=${createdSeatedBooking.uid} is a seated booking which means you have to provide seatUid in the request body to specify which seat specifically you want to reschedule. First, fetch the booking using https://cal.com/docs/api-reference/v2/bookings/get-a-booking and then within the attendees array you will find the seatUid of the booking you want to reschedule. Second, provide the seatUid in the request body to specify which seat specifically you want to reschedule using the reschedule endpoint https://cal.com/docs/api-reference/v2/bookings/reschedule-a-booking#option-2`
);
});
it("should reschedule seated booking", async () => {
const body: RescheduleSeatedBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2030, 0, 8, 15, 0, 0)).toISOString(),
@@ -409,67 +418,186 @@ describe("Bookings Endpoints 2024-08-13", () => {
});
});
it("should cancel seated booking", async () => {
const body: CancelSeatedBookingInput_2024_08_13 = {
seatUid: createdSeatedBooking.seatUid,
};
describe("cancel seated booking", () => {
describe("cancel seated booking as attendee", () => {
it("should cancel seated booking", async () => {
const body: CancelSeatedBookingInput_2024_08_13 = {
seatUid: createdSeatedBooking.seatUid,
};
return request(app.getHttpServer())
.post(`/v2/bookings/${createdSeatedBooking.uid}/cancel`)
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(200)
.then(async (response) => {
const responseBody: RescheduleBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsGetSeatedBooking(responseBody.data)).toBe(true);
return request(app.getHttpServer())
.post(`/v2/bookings/${createdSeatedBooking.uid}/cancel`)
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(200)
.then(async (response) => {
const responseBody: RescheduleBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsGetSeatedBooking(responseBody.data)).toBe(true);
if (responseDataIsGetSeatedBooking(responseBody.data)) {
const data: GetSeatedBookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(data.hosts[0].id).toEqual(user.id);
expect(data.status).toEqual("cancelled");
expect(data.start).toEqual(createdSeatedBooking.start);
expect(data.end).toEqual(createdSeatedBooking.end);
expect(data.duration).toEqual(60);
expect(data.eventTypeId).toEqual(seatedEventTypeId);
expect(data.eventType).toEqual({
id: seatedEventTypeId,
slug: seatedEventSlug,
if (responseDataIsGetSeatedBooking(responseBody.data)) {
const data: GetSeatedBookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(data.hosts[0].id).toEqual(user.id);
expect(data.status).toEqual("cancelled");
expect(data.start).toEqual(createdSeatedBooking.start);
expect(data.end).toEqual(createdSeatedBooking.end);
expect(data.duration).toEqual(60);
expect(data.eventTypeId).toEqual(seatedEventTypeId);
expect(data.eventType).toEqual({
id: seatedEventTypeId,
slug: seatedEventSlug,
});
expect(data.attendees.length).toEqual(0);
expect(data.location).toBeDefined();
expect(data.absentHost).toEqual(false);
} else {
throw new Error("Invalid response data - expected booking but received array response");
}
});
expect(data.attendees.length).toEqual(0);
expect(data.location).toBeDefined();
expect(data.absentHost).toEqual(false);
} else {
throw new Error("Invalid response data - expected booking but received array response");
}
});
});
describe("cancel seated booking as host", () => {
it("should book an event type with seats", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2030, 0, 8, 14, 0, 0)).toISOString(),
eventTypeId: seatedEventTypeId,
attendee: {
name: nameAttendeeOne,
email: emailAttendeeOne,
timeZone: "Europe/Rome",
language: "it",
},
bookingFieldsResponses: {
codingLanguage: "TypeScript",
},
metadata: {
userId: "100",
},
};
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsCreateSeatedBooking(responseBody.data)).toBe(true);
if (responseDataIsCreateSeatedBooking(responseBody.data)) {
const data: CreateSeatedBookingOutput_2024_08_13 = responseBody.data;
expect(data.seatUid).toBeDefined();
const seatUid = data.seatUid;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(data.hosts[0].id).toEqual(user.id);
expect(data.status).toEqual("accepted");
expect(data.start).toEqual(body.start);
expect(data.end).toEqual(
DateTime.fromISO(body.start, { zone: "utc" }).plus({ hours: 1 }).toISO()
);
expect(data.duration).toEqual(60);
expect(data.eventTypeId).toEqual(seatedEventTypeId);
expect(data.eventType).toEqual({
id: seatedEventTypeId,
slug: seatedEventSlug,
});
expect(data.attendees.length).toEqual(1);
expect(data.attendees[0]).toEqual({
name: body.attendee.name,
email: body.attendee.email,
timeZone: body.attendee.timeZone,
language: body.attendee.language,
absent: false,
seatUid,
bookingFieldsResponses: {
name: body.attendee.name,
...body.bookingFieldsResponses,
},
metadata: body.metadata,
});
expect(data.location).toBeDefined();
expect(data.absentHost).toEqual(false);
createdSeatedBooking2 = data;
} else {
throw new Error(
"Invalid response data - expected recurring booking but received non array response"
);
}
});
});
it("should not be able to cancel without cancellation reason", async () => {
const response = await request(app.getHttpServer())
.post(`/v2/bookings/${createdSeatedBooking2.uid}/cancel`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.set("Authorization", `Bearer ${apiKeyString}`)
.expect(400);
expect(response.body.message).toEqual("Cancellation reason is required when you are the host");
});
it("should cancel seated booking", async () => {
const body: CancelBookingInput_2024_08_13 = {
cancellationReason: "I will be travelling without internet",
};
return request(app.getHttpServer())
.post(`/v2/bookings/${createdSeatedBooking2.uid}/cancel`)
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.set("Authorization", `Bearer ${apiKeyString}`)
.expect(200)
.then(async (response) => {
const responseBody: RescheduleBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsGetSeatedBooking(responseBody.data)).toBe(true);
if (responseDataIsGetSeatedBooking(responseBody.data)) {
const data: GetSeatedBookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(data.hosts[0].id).toEqual(user.id);
expect(data.status).toEqual("cancelled");
expect(data.start).toEqual(createdSeatedBooking2.start);
expect(data.end).toEqual(createdSeatedBooking2.end);
expect(data.duration).toEqual(60);
expect(data.eventTypeId).toEqual(seatedEventTypeId);
expect(data.eventType).toEqual({
id: seatedEventTypeId,
slug: seatedEventSlug,
});
expect(data.attendees.length).toEqual(0);
expect(data.location).toBeDefined();
expect(data.absentHost).toEqual(false);
expect(data.cancellationReason).toEqual("I will be travelling without internet");
const seats = await bookingSeatRepositoryFixture.findAllByBookingId(data.id);
expect(seats.length).toEqual(0);
} else {
throw new Error("Invalid response data - expected booking but received array response");
}
});
});
});
});
function responseDataIsCreateSeatedBooking(data: any): data is CreateSeatedBookingOutput_2024_08_13 {
return data.hasOwnProperty("seatUid");
}
function responseDataIsCreateRecurringSeatedBooking(
data: any
): data is CreateRecurringSeatedBookingOutput_2024_08_13[] {
return Array.isArray(data);
}
function responseDataIsGetSeatedBooking(data: any): data is GetSeatedBookingOutput_2024_08_13 {
return data?.attendees?.every((attendee: any) => attendee?.hasOwnProperty("seatUid"));
}
function responseDataIsGetRecurringSeatedBooking(
data: any
): data is GetRecurringSeatedBookingOutput_2024_08_13[] {
return Array.isArray(data);
}
afterAll(async () => {
await oauthClientRepositoryFixture.delete(oAuthClient.id);
await teamRepositoryFixture.delete(organization.id);
await userRepositoryFixture.deleteByEmail(user.email);
await bookingsRepositoryFixture.deleteAllBookings(user.id, user.email);
@@ -35,6 +35,7 @@ import {
X_CAL_CLIENT_ID,
} from "@calcom/platform-constants";
import { AttendeeScheduledEmail, OrganizerScheduledEmail } from "@calcom/platform-libraries/emails";
import { EventManager } from "@calcom/platform-libraries/event-types";
import {
CreateEventTypeInput_2024_06_14,
FAILED_EVENT_TYPE_IDENTIFICATION_ERROR_MESSAGE,
@@ -78,6 +79,8 @@ describe("Bookings Endpoints 2024-08-13", () => {
const eventTypeSlug = `user-bookings-event-type-${randomString()}`;
let recurringEventTypeId: number;
const recurringEventTypeSlug = `user-bookings-event-type-${randomString()}`;
let eventTypeRequiresConfirmationId: number;
const eventTypeRequiresConfirmationSlug = `user-bookings-event-type-requires-confirmation-${randomString()}`;
let createdBooking: BookingOutput_2024_08_13;
let rescheduledBooking: BookingOutput_2024_08_13;
@@ -153,6 +156,17 @@ describe("Bookings Endpoints 2024-08-13", () => {
);
recurringEventTypeId = recurringEvent.id;
const eventTypeRequiresConfirmation = await eventTypesRepositoryFixture.create(
{
title: `user-bookings-2024-08-13-event-type-requires-confirmation-${randomString()}`,
slug: eventTypeRequiresConfirmationSlug,
length: 60,
requiresConfirmation: true,
},
user.id
);
eventTypeRequiresConfirmationId = eventTypeRequiresConfirmation.id;
bookingInThePast = await bookingsRepositoryFixture.create({
user: {
connect: {
@@ -2399,6 +2413,425 @@ describe("Bookings Endpoints 2024-08-13", () => {
});
});
describe("cant't reschedule cancelled booking", () => {
it("should not be able to reschedule cancelled booking", async () => {
const cancelledBooking = await bookingsRepositoryFixture.create({
status: "CANCELLED",
user: {
connect: {
id: user.id,
},
},
startTime: new Date(Date.UTC(2050, 0, 8, 13, 0, 0)),
endTime: new Date(Date.UTC(2050, 0, 8, 14, 0, 0)),
title: "peer coding lets goo",
uid: `cancelled-booking-${randomString()}`,
eventType: {
connect: {
id: eventTypeId,
},
},
location: "integrations:daily",
customInputs: {},
metadata: {},
responses: {
name: "Oldie",
email: "oldie@gmail.com",
},
attendees: {
create: {
email: "oldie@gmail.com",
name: "Oldie",
locale: "lv",
timeZone: "Europe/Rome",
},
},
});
const body: RescheduleBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 9, 14, 0, 0)).toISOString(),
reschedulingReason: "Flying to mars that day",
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings/${cancelledBooking.uid}/reschedule`)
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toEqual(
`Can't reschedule booking with uid=${cancelledBooking.uid} because it has been cancelled. Please provide uid of a booking that is not cancelled.`
);
await bookingsRepositoryFixture.deleteById(cancelledBooking.id);
});
it("should not be able to reschedule rescheduled booking", async () => {
const rescheduledBooking = await bookingsRepositoryFixture.create({
status: "CANCELLED",
rescheduled: true,
user: {
connect: {
id: user.id,
},
},
startTime: new Date(Date.UTC(2050, 0, 8, 13, 0, 0)),
endTime: new Date(Date.UTC(2050, 0, 8, 14, 0, 0)),
title: "peer coding lets goo",
uid: `cancelled-booking-${randomString()}`,
eventType: {
connect: {
id: eventTypeId,
},
},
location: "integrations:daily",
customInputs: {},
metadata: {},
responses: {
name: "Oldie",
email: "oldie@gmail.com",
},
attendees: {
create: {
email: "oldie@gmail.com",
name: "Oldie",
locale: "lv",
timeZone: "Europe/Rome",
},
},
});
const newBooking = await bookingsRepositoryFixture.create({
status: "ACCEPTED",
user: {
connect: {
id: user.id,
},
},
fromReschedule: rescheduledBooking.uid,
startTime: new Date(Date.UTC(2050, 0, 8, 13, 0, 0)),
endTime: new Date(Date.UTC(2050, 0, 8, 14, 0, 0)),
title: "peer coding lets goo",
uid: `new-booking-${randomString()}`,
eventType: {
connect: {
id: eventTypeId,
},
},
location: "integrations:daily",
customInputs: {},
metadata: {},
responses: {
name: "Oldie",
email: "oldie@gmail.com",
},
attendees: {
create: {
email: "oldie@gmail.com",
name: "Oldie",
locale: "lv",
timeZone: "Europe/Rome",
},
},
});
const body: RescheduleBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 9, 14, 0, 0)).toISOString(),
reschedulingReason: "Flying to mars that day",
};
const response = await request(app.getHttpServer())
.post(`/v2/bookings/${rescheduledBooking.uid}/reschedule`)
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(400);
expect(response.body.error.message).toEqual(
`Can't reschedule booking with uid=${rescheduledBooking.uid} because it has been cancelled and rescheduled already to booking with uid=${newBooking.uid}. You probably want to reschedule ${newBooking.uid} instead by passing it within the request URL.`
);
await bookingsRepositoryFixture.deleteById(rescheduledBooking.id);
await bookingsRepositoryFixture.deleteById(newBooking.id);
});
});
describe("calendar events", () => {
beforeEach(() => {
jest.restoreAllMocks();
jest
.spyOn(EventManager.prototype, "create")
.mockImplementation(() => Promise.resolve({ results: [], referencesToCreate: [] }));
});
describe("platform oAuth client has calendar events enabled", () => {
beforeAll(async () => {
await oauthClientRepositoryFixture.update(oAuthClient.id, {
areCalendarEventsEnabled: true,
});
});
it("should create calendar event when booking normal event", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 9, 9, 0, 0)).toISOString(),
eventTypeId,
attendee: {
name: "Mr Proper",
email: "mr_proper@gmail.com",
timeZone: "Europe/Rome",
language: "it",
},
};
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);
if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(1);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
);
}
});
});
it("should create calendar events when booking recurring event", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 10, 9, 0, 0)).toISOString(),
eventTypeId: recurringEventTypeId,
attendee: {
name: "Mr Proper",
email: "mr_proper@gmail.com",
timeZone: "Europe/Rome",
language: "it",
},
};
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(3);
});
});
describe("event type requires confirmation", () => {
let bookingThatRequiresConfirmationUid: string;
it("should not create calendar event when booking event that requires confirmation", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 12, 9, 0, 0)).toISOString(),
eventTypeId: eventTypeRequiresConfirmationId,
attendee: {
name: "Mr Proper",
email: "mr_proper@gmail.com",
timeZone: "Europe/Rome",
language: "it",
},
};
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);
if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(0);
bookingThatRequiresConfirmationUid = data.uid;
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
);
}
});
});
it("should create calendar event when confirming event that requires confirmation", async () => {
return request(app.getHttpServer())
.post(`/v2/bookings/${bookingThatRequiresConfirmationUid}/confirm`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(200)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);
if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(1);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
);
}
});
});
});
});
describe("platform oAuth client has calendar events disabled", () => {
beforeAll(async () => {
await oauthClientRepositoryFixture.update(oAuthClient.id, {
areCalendarEventsEnabled: false,
});
});
it("should not create calendar event when booking", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 9, 10, 0, 0)).toISOString(),
eventTypeId,
attendee: {
name: "Mr Proper",
email: "mr_proper@gmail.com",
timeZone: "Europe/Rome",
language: "it",
},
};
const beforeCreate = new Date();
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const afterCreate = new Date();
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);
if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(0);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
);
}
});
});
it("should not create calendar events when booking recurring event", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 11, 10, 0, 0)).toISOString(),
eventTypeId: recurringEventTypeId,
attendee: {
name: "Mr Proper",
email: "mr_proper@gmail.com",
timeZone: "Europe/Rome",
language: "it",
},
};
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(0);
});
});
describe("event type requires confirmation", () => {
let bookingThatRequiresConfirmationUid: string;
it("should not create calendar event when booking event that requires confirmation", async () => {
const body: CreateBookingInput_2024_08_13 = {
start: new Date(Date.UTC(2040, 0, 12, 10, 0, 0)).toISOString(),
eventTypeId: eventTypeRequiresConfirmationId,
attendee: {
name: "Mr Proper",
email: "mr_proper@gmail.com",
timeZone: "Europe/Rome",
language: "it",
},
};
return request(app.getHttpServer())
.post("/v2/bookings")
.send(body)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(201)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);
if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(0);
bookingThatRequiresConfirmationUid = data.uid;
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
);
}
});
});
it("should not create calendar event when confirming event that requires confirmation", async () => {
return request(app.getHttpServer())
.post(`/v2/bookings/${bookingThatRequiresConfirmationUid}/confirm`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(200)
.then(async (response) => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);
if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.create).toHaveBeenCalledTimes(0);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
);
}
});
});
});
});
});
function responseDataIsRecurranceBooking(data: any): data is RecurringBookingOutput_2024_08_13 {
return (
!Array.isArray(data) &&
@@ -5,6 +5,7 @@ import { InputBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/servic
import { OutputBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/output.service";
import { PlatformBookingsService } from "@/ee/bookings/shared/platform-bookings.service";
import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/event-types.repository";
import { getPagination } from "@/lib/pagination/pagination";
import { BillingService } from "@/modules/billing/services/billing.service";
import { BookingSeatRepository } from "@/modules/booking-seat/booking-seat.repository";
import { KyselyReadService } from "@/modules/kysely/kysely-read.service";
@@ -60,11 +61,15 @@ type CreatedBooking = {
start: string;
};
const eventTypeBookingFieldSchema = z.object({
name: z.string(),
required: z.boolean(),
editable: z.string(),
});
const eventTypeBookingFieldSchema = z
.object({
name: z.string(),
required: z.boolean(),
editable: z.string(),
type: z.string(),
options: z.array(z.object({ value: z.string() })).optional(),
})
.passthrough();
export const eventTypeBookingFieldsSchema = z.array(eventTypeBookingFieldSchema);
@@ -104,6 +109,12 @@ export class BookingsService_2024_08_13 {
this.errorsBookingsService.handleEventTypeToBeBookedNotFound(body);
}
if (eventType.schedulingType === "MANAGED") {
throw new BadRequestException(
`Event type with id=${eventType.id} is the parent managed event type that can't be booked. You have to provide the child event type id aka id of event type that has been assigned to one of the users.`
);
}
body.eventTypeId = eventType.id;
if ("instant" in body && body.instant) {
@@ -172,7 +183,7 @@ export class BookingsService_2024_08_13 {
}
async hasRequiredBookingFieldsResponses(body: CreateBookingInput, eventType: EventType | null) {
const bookingFields: Record<string, unknown> = {
const bookingFieldsResponses: Record<string, unknown> = {
...body.bookingFieldsResponses,
attendeePhoneNumber: body.attendee.phoneNumber,
smsReminderNumber: body.attendee.phoneNumber,
@@ -191,22 +202,168 @@ export class BookingsService_2024_08_13 {
return true;
}
for (const field of eventTypeBookingFields) {
if (field.required && (bookingFields[field.name] === null || bookingFields[field.name] === undefined)) {
if (field.name === "attendeePhoneNumber" || field.name === "smsReminderNumber") {
for (const eventTypeBookingField of eventTypeBookingFields) {
if (
eventTypeBookingField.required &&
(bookingFieldsResponses[eventTypeBookingField.name] === null ||
bookingFieldsResponses[eventTypeBookingField.name] === undefined)
) {
if (
eventTypeBookingField.name === "attendeePhoneNumber" ||
eventTypeBookingField.name === "smsReminderNumber"
) {
throw new BadRequestException(
`Missing attendee phone number - it is required by the event type. Pass it as "attendee.phoneNumber" string in the request.`
);
}
throw new BadRequestException(
`Missing required booking field response: ${field.name} - it is required by the event type booking fields, but missing in the bookingFieldsResponses. You can fetch the event type with ID ${eventType.id} to see the required fields.`
`Missing required booking field response: ${eventTypeBookingField.name} - it is required by the event type booking fields, but missing in the bookingFieldsResponses. You can fetch the event type with ID ${eventType.id} to see the required fields.`
);
}
const bookingFieldResponseValue = bookingFieldsResponses[eventTypeBookingField.name];
if (bookingFieldResponseValue !== undefined) {
const bookingFieldResponseValueType = typeof bookingFieldResponseValue;
let expectedBookingFieldResponseValueType = "";
let isValidType = false;
const eventTypeBookingFieldType = eventTypeBookingField.type;
switch (eventTypeBookingFieldType) {
case "phone":
expectedBookingFieldResponseValueType = "string";
isValidType = bookingFieldResponseValueType === "string";
break;
case "address":
expectedBookingFieldResponseValueType = "string";
isValidType = bookingFieldResponseValueType === "string";
break;
case "text":
expectedBookingFieldResponseValueType = "string";
isValidType = bookingFieldResponseValueType === "string";
break;
case "number":
expectedBookingFieldResponseValueType = "number";
isValidType = bookingFieldResponseValueType === "number";
break;
case "textarea":
expectedBookingFieldResponseValueType = "string";
isValidType = bookingFieldResponseValueType === "string";
break;
case "multiemail":
expectedBookingFieldResponseValueType = "array";
isValidType = Array.isArray(bookingFieldResponseValue);
break;
case "boolean":
expectedBookingFieldResponseValueType = "boolean";
isValidType = bookingFieldResponseValueType === "boolean";
break;
case "select":
expectedBookingFieldResponseValueType = "string or number";
isValidType =
bookingFieldResponseValueType === "string" || bookingFieldResponseValueType === "number";
if (isValidType && Array.isArray(eventTypeBookingField.options)) {
const submittedValue = bookingFieldResponseValue as string | number;
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.isValidSingleOptionValue(submittedValue, allowedOptionValues)) {
throw new BadRequestException(
`Invalid option '${submittedValue}' for booking field '${
eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
}
break;
case "multiselect":
expectedBookingFieldResponseValueType = "array";
isValidType = Array.isArray(bookingFieldResponseValue);
if (isValidType && Array.isArray(eventTypeBookingField.options)) {
const submittedValues = bookingFieldResponseValue as (string | number)[];
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.areValidMultipleOptionValues(submittedValues, allowedOptionValues)) {
throw new BadRequestException(
`One or more invalid options for booking field '${
eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
}
break;
case "checkbox":
expectedBookingFieldResponseValueType = "array";
isValidType = Array.isArray(bookingFieldResponseValue);
if (isValidType && Array.isArray(eventTypeBookingField.options)) {
const submittedValues = bookingFieldResponseValue as (string | number)[];
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.areValidMultipleOptionValues(submittedValues, allowedOptionValues)) {
throw new BadRequestException(
`One or more invalid options for booking field '${
eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
}
break;
case "radio":
expectedBookingFieldResponseValueType = "string or number";
isValidType =
bookingFieldResponseValueType === "string" || bookingFieldResponseValueType === "number";
if (isValidType && Array.isArray(eventTypeBookingField.options)) {
const submittedValue = bookingFieldResponseValue as string | number;
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.isValidSingleOptionValue(submittedValue, allowedOptionValues)) {
throw new BadRequestException(
`Invalid option '${submittedValue}' for booking field '${
eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
}
break;
case "url":
expectedBookingFieldResponseValueType = "string";
isValidType = bookingFieldResponseValueType === "string";
break;
default:
// note(Lauris): by default pass the field if we have a missing "case" in the switch
isValidType = true;
break;
}
if (!isValidType) {
throw new BadRequestException(
`Invalid type for booking field '${eventTypeBookingField.name}'. Expected type ${expectedBookingFieldResponseValueType} (compatible with field type '${eventTypeBookingFieldType}'), but received ${bookingFieldResponseValueType}.`
);
}
}
}
return true;
}
private isValidSingleOptionValue(
bookingFieldResponseValue: string | number,
eventTypeBookingFieldOptions: string[]
): boolean {
if (eventTypeBookingFieldOptions.length === 0) {
// note(Lauris): If no options defined, cannot validate against them, so pass.
return true;
}
return eventTypeBookingFieldOptions.some((val) => val === String(bookingFieldResponseValue));
}
private areValidMultipleOptionValues(
bookingFieldResponseValues: (string | number)[],
eventTypeBookingFieldOptions: string[]
): boolean {
if (eventTypeBookingFieldOptions.length === 0) {
// note(Lauris): If no options defined, cannot validate against them, so pass.
return true;
}
return bookingFieldResponseValues.every((submittedVal) =>
eventTypeBookingFieldOptions.some((allowedVal) => allowedVal === String(submittedVal))
);
}
async createInstantBooking(
request: Request,
body: CreateInstantBookingInput_2024_08_13,
@@ -247,6 +404,7 @@ export class BookingsService_2024_08_13 {
platformBookingUrl: bookingRequest.platformBookingUrl,
platformBookingLocation: bookingRequest.platformBookingLocation,
noEmail: bookingRequest.noEmail,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
});
const ids = bookings.map((booking) => booking.id || 0);
return this.outputService.getOutputRecurringBookings(ids);
@@ -267,6 +425,7 @@ export class BookingsService_2024_08_13 {
platformCancelUrl: bookingRequest.platformCancelUrl,
platformBookingUrl: bookingRequest.platformBookingUrl,
platformBookingLocation: bookingRequest.platformBookingLocation,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
});
return this.outputService.getOutputCreateRecurringSeatedBookings(
bookings.map((booking) => ({ uid: booking.uid || "", seatUid: booking.seatReferenceUid || "" }))
@@ -288,6 +447,7 @@ export class BookingsService_2024_08_13 {
platformCancelUrl: bookingRequest.platformCancelUrl,
platformBookingUrl: bookingRequest.platformBookingUrl,
platformBookingLocation: bookingRequest.platformBookingLocation,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
});
if (!booking.uid) {
@@ -318,6 +478,7 @@ export class BookingsService_2024_08_13 {
platformCancelUrl: bookingRequest.platformCancelUrl,
platformBookingUrl: bookingRequest.platformBookingUrl,
platformBookingLocation: bookingRequest.platformBookingLocation,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
});
if (!booking.uid) {
@@ -382,10 +543,13 @@ export class BookingsService_2024_08_13 {
queryParams.attendeeEmail = await this.getAttendeeEmail(queryParams.attendeeEmail, user);
}
const skip = Math.abs(queryParams?.skip ?? 0);
const take = Math.abs(queryParams?.take ?? 100);
const fetchedBookings: { bookings: { id: number }[]; totalCount: number } = await getAllUserBookings({
bookingListingByStatus: queryParams.status || [],
skip: queryParams.skip ?? 0,
take: queryParams.take ?? 100,
skip,
take,
filters: {
...this.inputService.transformGetBookingsFilters(queryParams),
...(userIds?.length ? { userIds } : {}),
@@ -438,28 +602,11 @@ export class BookingsService_2024_08_13 {
}
}
const skip = Math.abs(queryParams?.skip ?? 0);
const take = Math.abs(queryParams?.take ?? 100);
const itemsPerPage = take;
const totalPages = itemsPerPage !== 0 ? Math.ceil(fetchedBookings.totalCount / itemsPerPage) : 0;
const currentPage = Math.floor(skip / itemsPerPage) + 1;
const hasNextPage = skip + itemsPerPage < fetchedBookings.totalCount;
const hasPreviousPage = skip > 0;
const pagination = getPagination({ skip, take, totalCount: fetchedBookings.totalCount });
return {
bookings: formattedBookings,
pagination: {
totalItems: fetchedBookings.totalCount,
// clamp remainingItems between 0 and totalCount
remainingItems: Math.min(
Math.max(fetchedBookings.totalCount - (skip + take), 0),
fetchedBookings.totalCount
),
itemsPerPage: itemsPerPage,
currentPage: currentPage,
totalPages: totalPages,
hasNextPage: hasNextPage,
hasPreviousPage: hasPreviousPage,
},
pagination,
};
}
@@ -494,6 +641,7 @@ export class BookingsService_2024_08_13 {
async rescheduleBooking(request: Request, bookingUid: string, body: RescheduleBookingInput) {
try {
await this.canRescheduleBooking(bookingUid);
const bookingRequest = await this.inputService.createRescheduleBookingRequest(
request,
bookingUid,
@@ -508,6 +656,7 @@ export class BookingsService_2024_08_13 {
platformCancelUrl: bookingRequest.platformCancelUrl,
platformBookingUrl: bookingRequest.platformBookingUrl,
platformBookingLocation: bookingRequest.platformBookingLocation,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
});
if (!booking.uid) {
throw new Error("Booking missing uid");
@@ -539,15 +688,29 @@ export class BookingsService_2024_08_13 {
}
return this.outputService.getOutputBooking(databaseBooking);
} catch (error) {
if (error instanceof Error) {
if (error.message === "no_available_users_found_error") {
throw new BadRequestException("User either already has booking at this time or is not available");
}
}
throw error;
this.errorsBookingsService.handleBookingError(error, false);
}
}
async canRescheduleBooking(bookingUid: string) {
const booking = await this.bookingsRepository.getByUid(bookingUid);
if (!booking) {
throw new Error(`Booking with uid=${bookingUid} was not found in the database`);
}
if (booking.status === "CANCELLED" && !booking.rescheduled) {
throw new BadRequestException(
`Can't reschedule booking with uid=${bookingUid} because it has been cancelled. Please provide uid of a booking that is not cancelled.`
);
}
if (booking.status === "CANCELLED" && booking.rescheduled) {
const rescheduledTo = await this.bookingsRepository.getByFromReschedule(bookingUid);
throw new BadRequestException(
`Can't reschedule booking with uid=${bookingUid} because it has been cancelled and rescheduled already to booking with uid=${rescheduledTo?.uid}. You probably want to reschedule ${rescheduledTo?.uid} instead by passing it within the request URL.`
);
}
return booking;
}
async cancelBooking(request: Request, bookingUid: string, body: CancelBookingInput) {
if (this.inputService.isCancelSeatedBody(body)) {
const seat = await this.bookingSeatRepository.getByReferenceUid(body.seatUid);
@@ -772,15 +935,19 @@ export class BookingsService_2024_08_13 {
: undefined;
const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;
const userCalendars = await this.usersRepository.findByIdWithCalendars(requestUser.id);
await confirmBookingHandler({
ctx: {
user: requestUser,
user: {
...requestUser,
destinationCalendar: userCalendars?.destinationCalendar ?? null,
},
},
input: {
bookingId: booking.id,
confirmed: true,
recurringEventId: booking.recurringEventId,
recurringEventId: booking.recurringEventId ?? undefined,
emailsEnabled,
platformClientParams,
},
@@ -800,15 +967,19 @@ export class BookingsService_2024_08_13 {
: undefined;
const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;
const userCalendars = await this.usersRepository.findByIdWithCalendars(requestUser.id);
await confirmBookingHandler({
ctx: {
user: requestUser,
user: {
...requestUser,
destinationCalendar: userCalendars?.destinationCalendar ?? null,
},
},
input: {
bookingId: booking.id,
confirmed: false,
recurringEventId: booking.recurringEventId,
recurringEventId: booking.recurringEventId ?? undefined,
reason,
emailsEnabled,
platformClientParams,
@@ -0,0 +1,83 @@
import { BookingsRepository_2024_08_13 } from "@/ee/bookings/2024-08-13/bookings.repository";
import { OutputBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/output.service";
import { Injectable, Logger, NotFoundException } from "@nestjs/common";
import {
getRecordingsOfCalVideoByRoomName,
getAllTranscriptsAccessLinkFromRoomName,
getDownloadLinkOfCalVideoByRecordingId,
} from "@calcom/platform-libraries/conferencing";
@Injectable()
export class CalVideoService {
private readonly logger = new Logger("CalVideoService");
constructor(
private readonly bookingsRepository: BookingsRepository_2024_08_13,
private readonly outputService: OutputBookingsService_2024_08_13
) {}
async getRecordings(bookingUid: string) {
const booking = await this.bookingsRepository.getByUidWithBookingReference(bookingUid);
if (!booking) {
throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
}
const roomName =
booking?.references?.filter((reference) => reference.type === "daily_video")?.pop()?.meetingId ??
undefined;
if (!roomName) {
throw new NotFoundException(`No Cal Video reference found with booking uid ${bookingUid}`);
}
const recordings = await getRecordingsOfCalVideoByRoomName(roomName);
if (!recordings || !("data" in recordings)) return [];
const recordingWithDownloadLink = recordings.data.map((recording) => {
return getDownloadLinkOfCalVideoByRecordingId(recording.id)
.then((res: { download_link: string } | undefined) => ({
id: recording.id,
roomName: recording.room_name,
startTs: recording.start_ts,
status: recording.status,
maxParticipants: recording.max_participants,
duration: recording.duration,
shareToken: recording.share_token,
downloadLink: res?.download_link,
}))
.catch((err: Error) => ({
id: recording.id,
roomName: recording.room_name,
startTs: recording.start_ts,
status: recording.status,
maxParticipants: recording.max_participants,
duration: recording.duration,
shareToken: recording.share_token,
downloadLink: null,
error: err.message,
}));
});
const allRecordingsWithDownloadLink = await Promise.all(recordingWithDownloadLink);
return allRecordingsWithDownloadLink;
}
async getTranscripts(bookingUid: string) {
const booking = await this.bookingsRepository.getByUidWithBookingReference(bookingUid);
if (!booking) {
throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
}
const roomName =
booking?.references?.filter((reference) => reference.type === "daily_video")?.pop()?.meetingId ??
undefined;
if (!roomName) {
throw new NotFoundException(`No Cal Video reference found with booking uid ${bookingUid}`);
}
const transcripts = await getAllTranscriptsAccessLinkFromRoomName(roomName);
return transcripts;
}
}
@@ -10,6 +10,7 @@ import {
import { PlatformBookingsService } from "@/ee/bookings/shared/platform-bookings.service";
import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/event-types.repository";
import { OutputEventTypesService_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/services/output-event-types.service";
import { apiToInternalintegrationsMapping } from "@/ee/event-types/event-types_2024_06_14/transformers";
import { hashAPIKey, isApiKey, stripApiKey } from "@/lib/api-key";
import { defaultBookingResponses } from "@/lib/safe-parse/default-responses-booking";
import { safeParse } from "@/lib/safe-parse/safe-parse";
@@ -29,10 +30,7 @@ import { NextApiRequest } from "next/types";
import { v4 as uuidv4 } from "uuid";
import { z } from "zod";
import {
EventTypeMetaDataSchema,
apiToInternalintegrationsMapping,
} from "@calcom/platform-libraries/event-types";
import { EventTypeMetaDataSchema } from "@calcom/platform-libraries/event-types";
import {
CancelBookingInput,
CancelBookingInput_2024_08_13,
@@ -61,6 +59,7 @@ type OAuthRequestParams = {
platformBookingUrl: string;
platformBookingLocation?: string;
arePlatformEmailsEnabled: boolean;
areCalendarEventsEnabled: boolean;
};
export enum Frequency {
@@ -587,6 +586,11 @@ export class InputBookingsService_2024_08_13 {
if (!eventType) {
throw new NotFoundException(`Event type with id=${booking.eventTypeId} not found`);
}
if (eventType.seatsPerTimeSlot) {
throw new BadRequestException(
`Booking with uid=${bookingUid} is a seated booking which means you have to provide seatUid in the request body to specify which seat specifically you want to reschedule. First, fetch the booking using https://cal.com/docs/api-reference/v2/bookings/get-a-booking and then within the attendees array you will find the seatUid of the booking you want to reschedule. Second, provide the seatUid in the request body to specify which seat specifically you want to reschedule using the reschedule endpoint https://cal.com/docs/api-reference/v2/bookings/reschedule-a-booking#option-2`
);
}
const bookingResponses = safeParse(
bookingResponsesSchema,
@@ -22,7 +22,7 @@ import {
RecurringBookingOutput_2024_08_13,
SeatedAttendee,
} from "@calcom/platform-types";
import { Booking, BookingReference, BookingSeat } from "@calcom/prisma/client";
import { Booking, BookingSeat } from "@calcom/prisma/client";
export const bookingResponsesSchema = z
.object({
@@ -266,6 +266,7 @@ export class OutputBookingsService_2024_08_13 {
description: databaseBooking.description,
hosts: [this.getHost(databaseBooking.user)],
status: databaseBooking.status.toLowerCase(),
cancellationReason: databaseBooking.cancellationReason || undefined,
rescheduledFromUid: databaseBooking.fromReschedule || undefined,
start: databaseBooking.startTime,
end: databaseBooking.endTime,
@@ -54,6 +54,7 @@ export class PlatformBookingsService {
platformRescheduleUrl: oAuthClient.bookingRescheduleRedirectUri,
platformBookingUrl: oAuthClient.bookingRedirectUri,
arePlatformEmailsEnabled: oAuthClient.areEmailsEnabled,
areCalendarEventsEnabled: oAuthClient.areCalendarEventsEnabled,
};
}
@@ -78,6 +79,7 @@ export class PlatformBookingsService {
platformRescheduleUrl: oAuthClient.bookingRescheduleRedirectUri,
platformBookingUrl: oAuthClient.bookingRedirectUri,
arePlatformEmailsEnabled: oAuthClient.areEmailsEnabled,
areCalendarEventsEnabled: oAuthClient.areCalendarEventsEnabled,
};
}
@@ -1,3 +1,5 @@
import { BookingReferencesRepository_2024_08_13 } from "@/ee/bookings/2024-08-13/booking-references.repository";
import { BookingsRepository_2024_08_13 } from "@/ee/bookings/2024-08-13/bookings.repository";
import { CalendarsRepository } from "@/ee/calendars/calendars.repository";
import { CalendarsController } from "@/ee/calendars/controllers/calendars.controller";
import { AppleCalendarService } from "@/ee/calendars/services/apple-calendar.service";
@@ -25,8 +27,10 @@ import { Module } from "@nestjs/common";
SelectedCalendarsRepository,
AppsRepository,
CalendarsRepository,
BookingsRepository_2024_08_13,
BookingReferencesRepository_2024_08_13,
],
controllers: [CalendarsController],
exports: [CalendarsService],
exports: [CalendarsService, GoogleCalendarService],
})
export class CalendarsModule {}
@@ -54,6 +54,23 @@ import {
} from "@calcom/platform-constants";
import { ApiResponse, CalendarBusyTimesInput, CreateCalendarCredentialsInput } from "@calcom/platform-types";
export interface CalendarState {
accessToken: string;
origin: string;
redir?: string;
isDryRun?: boolean;
}
const calendarStateSchema = z.object({
accessToken: z.string(),
origin: z.string(),
redir: z.string().optional(),
isDryRun: z
.string()
.optional()
.transform((val) => val === "true"),
});
@Controller({
path: "/v2/calendars",
version: API_VERSIONS_VALUES,
@@ -181,32 +198,31 @@ export class CalendarsController {
@Query("code") code: string,
@Param("calendar") calendar: string
): Promise<{ url: string }> {
// state params contains our user access token
const stateParams = new URLSearchParams(state);
const { accessToken, origin, redir, isDryRun } = z
.object({
accessToken: z.string(),
origin: z.string(),
redir: z.string().nullish().optional(),
isDryRun: z.string().nullish().optional(),
})
.parse({
let stateObj: CalendarState;
try {
// First try to parse as JSON
stateObj = JSON.parse(state) as CalendarState;
} catch (e) {
// If JSON parsing fails, try URL params
const stateParams = new URLSearchParams(state);
const parsedState = calendarStateSchema.parse({
accessToken: stateParams.get("accessToken"),
origin: stateParams.get("origin"),
redir: stateParams.get("redir"),
redir: stateParams.get("redir") || undefined,
isDryRun: stateParams.get("isDryRun"),
});
stateObj = parsedState;
}
const { accessToken, origin, redir, isDryRun } = stateObj;
switch (calendar) {
case OFFICE_365_CALENDAR:
return await this.outlookService.save(code, accessToken, origin, redir ?? "", isDryRun === "true");
return await this.outlookService.save(code, accessToken, origin, redir ?? "", !!isDryRun);
case GOOGLE_CALENDAR:
return await this.googleCalendarService.save(
code,
accessToken,
origin,
redir ?? "",
isDryRun === "true"
);
return await this.googleCalendarService.save(code, accessToken, origin, redir ?? "", !!isDryRun);
default:
throw new BadRequestException(
"Invalid calendar type, available calendars are: ",
@@ -22,6 +22,7 @@ import { APPS_TYPE_ID_MAPPING } from "@calcom/platform-constants";
import {
getConnectedDestinationCalendarsAndEnsureDefaultsInDb,
getBusyCalendarTimes,
type EventBusyDate,
} from "@calcom/platform-libraries";
import { Calendar } from "@calcom/platform-types";
import { PrismaClient } from "@calcom/prisma";
@@ -45,6 +46,7 @@ export class CalendarsService {
...credential,
delegatedTo: null,
delegatedToId: null,
delegationCredentialId: null,
}))
.filter((credential) => !!credential);
}
@@ -88,18 +90,19 @@ export class CalendarsService {
dateTo,
composedSelectedCalendars
);
// @ts-expect-error Element implicitly has any type
const calendarBusyTimesConverted = calendarBusyTimes.map((busyTime) => {
const busyTimeStart = DateTime.fromJSDate(new Date(busyTime.start)).setZone(timezone);
const busyTimeEnd = DateTime.fromJSDate(new Date(busyTime.end)).setZone(timezone);
const busyTimeStartDate = busyTimeStart.toJSDate();
const busyTimeEndDate = busyTimeEnd.toJSDate();
return {
...busyTime,
start: busyTimeStartDate,
end: busyTimeEndDate,
};
});
const calendarBusyTimesConverted = calendarBusyTimes.map(
(busyTime: EventBusyDate & { timeZone?: string }) => {
const busyTimeStart = DateTime.fromJSDate(new Date(busyTime.start)).setZone(timezone);
const busyTimeEnd = DateTime.fromJSDate(new Date(busyTime.end)).setZone(timezone);
const busyTimeStartDate = busyTimeStart.toJSDate();
const busyTimeEndDate = busyTimeEnd.toJSDate();
return {
...busyTime,
start: busyTimeStartDate,
end: busyTimeEndDate,
};
}
);
return calendarBusyTimesConverted;
} catch (error) {
throw new InternalServerErrorException(
@@ -1,4 +1,5 @@
import { OAuthCalendarApp } from "@/ee/calendars/calendars.interface";
import type { CalendarState } from "@/ee/calendars/controllers/calendars.controller";
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
import { AppsRepository } from "@/modules/apps/apps.repository";
import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
@@ -23,7 +24,7 @@ const CALENDAR_SCOPES = [
@Injectable()
export class GoogleCalendarService implements OAuthCalendarApp {
private redirectUri = `${this.config.get("api.url")}/gcal/oauth/save`;
public readonly redirectUri = `${this.config.get("api.url")}/gcal/oauth/save`;
private gcalResponseSchema = z.object({ client_id: z.string(), client_secret: z.string() });
private logger = new Logger("GcalService");
@@ -65,12 +66,18 @@ export class GoogleCalendarService implements OAuthCalendarApp {
async getCalendarRedirectUrl(accessToken: string, origin: string, redir?: string, isDryRun?: boolean) {
const oAuth2Client = await this.getOAuthClient(this.redirectUri);
const state: CalendarState = {
accessToken,
origin,
redir,
isDryRun,
};
const authUrl = oAuth2Client.generateAuthUrl({
access_type: "offline",
scope: CALENDAR_SCOPES,
prompt: "consent",
state: `accessToken=${accessToken}&origin=${origin}&redir=${redir ?? ""}&isDryRun=${isDryRun}`,
state: JSON.stringify(state),
});
return authUrl;
@@ -1,4 +1,5 @@
import { OAuthCalendarApp } from "@/ee/calendars/calendars.interface";
import { CalendarState } from "@/ee/calendars/controllers/calendars.controller";
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository";
@@ -60,6 +61,13 @@ export class OutlookService implements OAuthCalendarApp {
async getCalendarRedirectUrl(accessToken: string, origin: string, redir?: string, isDryRun?: boolean) {
const { client_id } = await this.calendarsService.getAppKeys(OFFICE_365_CALENDAR_ID);
const state: CalendarState = {
accessToken,
origin,
redir,
isDryRun,
};
const scopes = ["User.Read", "Calendars.Read", "Calendars.ReadWrite", "offline_access"];
const params = {
response_type: "code",
@@ -67,7 +75,7 @@ export class OutlookService implements OAuthCalendarApp {
client_id,
prompt: "select_account",
redirect_uri: this.redirectUri,
state: `accessToken=${accessToken}&origin=${origin}&redir=${redir ?? ""}&isDryRun=${isDryRun}`,
state: JSON.stringify(state),
};
const query = stringify(params);
@@ -5,6 +5,7 @@ import { Editable } from "@/ee/event-types/event-types_2024_04_15/inputs/enums/e
import { BaseField } from "@/ee/event-types/event-types_2024_04_15/inputs/enums/field-type";
import { UpdateEventTypeInput_2024_04_15 } from "@/ee/event-types/event-types_2024_04_15/inputs/update-event-type.input";
import { EventTypeOutput } from "@/ee/event-types/event-types_2024_04_15/outputs/event-type.output";
import { systemBeforeFieldEmail } from "@/ee/event-types/event-types_2024_06_14/transformers";
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository";
@@ -17,7 +18,6 @@ import {
updateEventType,
EventTypesPublic,
getEventTypesPublic,
systemBeforeFieldEmail,
} from "@calcom/platform-libraries/event-types";
import { EventType } from "@calcom/prisma/client";
@@ -1,4 +1,4 @@
import { OrganizerIntegrationLocation } from "@calcom/lib/event-types/transformers/internal/locations";
import { OrganizerIntegrationLocation } from "@/ee/event-types/event-types_2024_06_14/transformers";
type BaseEventType = {
length: number;
@@ -34,6 +34,7 @@ import {
ApiSuccessResponse,
CreateEventTypeInput_2024_06_14,
EventTypeOutput_2024_06_14,
GuestsDefaultFieldOutput_2024_06_14,
NameDefaultFieldInput_2024_06_14,
NotesDefaultFieldInput_2024_06_14,
UpdateEventTypeInput_2024_06_14,
@@ -535,6 +536,7 @@ describe("Event types Endpoints", () => {
body.lockTimeZoneToggleOnBookingPage
);
expect(createdEventType.color).toEqual(body.color);
expect(createdEventType.disableGuests).toEqual(false);
const expectedBookingFields = [
{ ...defaultResponseBookingFieldName, ...nameBookingField },
@@ -962,6 +964,10 @@ describe("Event types Endpoints", () => {
title: newTitle,
scheduleId: secondSchedule.id,
lengthInMinutesOptions: [15, 30],
calVideoSettings: {
disableRecordingForGuests: true,
disableRecordingForOrganizer: true,
},
bookingFields: [
nameBookingField,
{
@@ -1037,6 +1043,7 @@ describe("Event types Endpoints", () => {
expect(updatedEventType.description).toEqual(eventType.description);
expect(updatedEventType.lengthInMinutes).toEqual(eventType.lengthInMinutes);
expect(updatedEventType.locations).toEqual(eventType.locations);
expect(updatedEventType.disableGuests).toEqual(false);
const expectedBookingFields = [
{ ...defaultResponseBookingFieldName, ...nameBookingField },
@@ -1082,6 +1089,12 @@ describe("Event types Endpoints", () => {
body.lockTimeZoneToggleOnBookingPage
);
expect(updatedEventType.color).toEqual(body.color);
expect(updatedEventType.calVideoSettings?.disableRecordingForGuests).toEqual(
body.calVideoSettings?.disableRecordingForGuests
);
expect(updatedEventType.calVideoSettings?.disableRecordingForOrganizer).toEqual(
body.calVideoSettings?.disableRecordingForOrganizer
);
eventType.title = newTitle;
eventType.scheduleId = secondSchedule.id;
@@ -1428,7 +1441,6 @@ describe("Event types Endpoints", () => {
{
name: "location",
type: "radioInput",
label: "",
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system",
required: false,
@@ -1558,7 +1570,6 @@ describe("Event types Endpoints", () => {
{
name: "location",
type: "radioInput",
label: "",
sources: [{ id: "default", type: "default", label: "Default" }],
editable: "system",
required: false,
@@ -1783,6 +1794,192 @@ describe("Event types Endpoints", () => {
});
});
describe("creating event type with input of another event type output", () => {
let firstCreatedEventType: EventTypeOutput_2024_06_14;
let secondCreatedEventType: EventTypeOutput_2024_06_14;
it("should create first event type", async () => {
const body: CreateEventTypeInput_2024_06_14 = {
title: "first created coding class",
slug: "first-created-coding-class",
lengthInMinutes: 60,
locations: [
{
type: "address",
address: "via volturno 10, Roma",
public: true,
},
],
};
return request(app.getHttpServer())
.post("/api/v2/event-types")
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(201)
.then(async (response) => {
const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body;
const createdEventType = responseBody.data;
expect(createdEventType).toHaveProperty("id");
expect(createdEventType.title).toEqual(body.title);
expect(createdEventType.locations).toEqual(body.locations);
firstCreatedEventType = responseBody.data;
});
});
it("should create second event type using first as input", async () => {
const body = {
...firstCreatedEventType,
title: "second created coding class",
slug: "second-created-coding-class",
};
return request(app.getHttpServer())
.post("/api/v2/event-types")
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(201)
.then(async (response) => {
const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body;
const createdEventType = responseBody.data;
expect(createdEventType).toHaveProperty("id");
expect(createdEventType.title).toEqual(body.title);
secondCreatedEventType = responseBody.data;
const { id, title, slug, ...restFirst } = firstCreatedEventType;
const { id: id2, title: title2, slug: slug2, ...restSecond } = secondCreatedEventType;
expect(restFirst).toEqual(restSecond);
expect(id2).not.toEqual(id);
expect(title2).not.toEqual(title);
expect(slug2).not.toEqual(slug);
});
});
it("should create event type with cal video settings", async () => {
const body: CreateEventTypeInput_2024_06_14 = {
title: "event type with cal video settings",
slug: "event-type-with-cal-video-settings",
lengthInMinutes: 60,
calVideoSettings: {
disableRecordingForGuests: true,
disableRecordingForOrganizer: true,
},
locations: [
{
type: "integration",
integration: "cal-video",
},
],
};
return request(app.getHttpServer())
.post("/api/v2/event-types")
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(201)
.then(async (response) => {
const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body;
const createdEventType = responseBody.data;
expect(createdEventType).toHaveProperty("id");
expect(createdEventType.title).toEqual(body.title);
expect(createdEventType.locations).toEqual(body.locations);
expect(createdEventType.calVideoSettings?.disableRecordingForGuests).toEqual(true);
expect(createdEventType.calVideoSettings?.disableRecordingForOrganizer).toEqual(true);
firstCreatedEventType = responseBody.data;
});
});
});
describe("toggle disable guests", () => {
let eventTypeWithGuestsDisabledId: number;
it("should create an event type with guests disabled", async () => {
const body: CreateEventTypeInput_2024_06_14 = {
title: "Coding class guests disabled",
slug: "coding-class-guests-disabled",
description: "Let's learn how to code like a pro.",
lengthInMinutes: 60,
disableGuests: true,
};
return request(app.getHttpServer())
.post("/api/v2/event-types")
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(201)
.then(async (response) => {
const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body;
const createdEventType = responseBody.data;
expect(createdEventType).toHaveProperty("id");
expect(createdEventType.title).toEqual(body.title);
expect(createdEventType.description).toEqual(body.description);
expect(createdEventType.lengthInMinutes).toEqual(body.lengthInMinutes);
expect(createdEventType.disableGuests).toEqual(true);
const guestsBookingField = createdEventType.bookingFields.find(
(field) => field.slug === "guests"
) as GuestsDefaultFieldOutput_2024_06_14 | undefined;
expect(guestsBookingField?.hidden).toEqual(true);
eventTypeWithGuestsDisabledId = createdEventType.id;
});
});
it("should update an event type with guests enabled", async () => {
const body: UpdateEventTypeInput_2024_06_14 = {
disableGuests: false,
};
return request(app.getHttpServer())
.patch(`/api/v2/event-types/${eventTypeWithGuestsDisabledId}`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(200)
.then(async (response) => {
const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body;
const updatedEventType = responseBody.data;
expect(updatedEventType.disableGuests).toEqual(false);
const guestsBookingField = updatedEventType.bookingFields.find(
(field) => field.slug === "guests"
) as GuestsDefaultFieldOutput_2024_06_14 | undefined;
expect(guestsBookingField?.hidden).toEqual(false);
eventTypeWithGuestsDisabledId = updatedEventType.id;
});
});
it("should update an event type with guests disabled", async () => {
const body: UpdateEventTypeInput_2024_06_14 = {
disableGuests: true,
};
return request(app.getHttpServer())
.patch(`/api/v2/event-types/${eventTypeWithGuestsDisabledId}`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(200)
.then(async (response) => {
const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body;
const updatedEventType = responseBody.data;
expect(updatedEventType.disableGuests).toEqual(true);
const guestsBookingField = updatedEventType.bookingFields.find(
(field) => field.slug === "guests"
) as GuestsDefaultFieldOutput_2024_06_14 | undefined;
expect(guestsBookingField?.hidden).toEqual(true);
eventTypeWithGuestsDisabledId = updatedEventType.id;
});
});
afterAll(async () => {
if (eventTypeWithGuestsDisabledId) {
await eventTypesRepositoryFixture.delete(eventTypeWithGuestsDisabledId);
}
});
});
afterAll(async () => {
await oauthClientRepositoryFixture.delete(oAuthClient.id);
await teamRepositoryFixture.delete(organization.id);
@@ -114,6 +114,9 @@ export class EventTypesController_2024_06_14 {
@Query() queryParams: GetEventTypesQuery_2024_06_14
): Promise<GetEventTypesOutput_2024_06_14> {
const eventTypes = await this.eventTypesService.getEventTypes(queryParams);
if (!eventTypes || eventTypes.length === 0) {
throw new NotFoundException(`Event types not found`);
}
const eventTypesFormatted = this.eventTypeResponseTransformPipe.transform(eventTypes);
const eventTypesWithoutHiddenFields = eventTypesFormatted.map((eventType) => {
return {
@@ -1,10 +1,9 @@
import { InputEventTransformed_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/transformed";
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
import { Injectable } from "@nestjs/common";
import type { Prisma } from "@prisma/client";
import { InputEventTransformed_2024_06_14 } from "@calcom/platform-types";
@Injectable()
export class EventTypesRepository_2024_06_14 {
constructor(private readonly dbRead: PrismaReadService, private readonly dbWrite: PrismaWriteService) {}
@@ -13,13 +12,20 @@ export class EventTypesRepository_2024_06_14 {
userId: number,
body: Omit<InputEventTransformed_2024_06_14, "destinationCalendar">
) {
const { calVideoSettings, ...restBody } = body;
return this.dbWrite.prisma.eventType.create({
data: {
...body,
...restBody,
userId,
locations: body.locations,
bookingFields: body.bookingFields,
users: { connect: { id: userId } },
...(calVideoSettings && {
calVideoSettings: {
create: calVideoSettings,
},
}),
},
});
}
@@ -72,7 +78,7 @@ export class EventTypesRepository_2024_06_14 {
async getEventTypeById(eventTypeId: number) {
return this.dbRead.prisma.eventType.findUnique({
where: { id: eventTypeId },
include: { users: true, schedule: true, destinationCalendar: true },
include: { users: true, schedule: true, destinationCalendar: true, calVideoSettings: true },
});
}
@@ -1,5 +1,7 @@
import { DEFAULT_EVENT_TYPES } from "@/ee/event-types/event-types_2024_06_14/constants/constants";
import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/event-types.repository";
import { InputEventTransformed_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/transformed";
import { SystemField, CustomField } from "@/ee/event-types/event-types_2024_06_14/transformers";
import { SchedulesRepository_2024_06_11 } from "@/ee/schedules/schedules_2024_06_11/schedules.repository";
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
@@ -14,10 +16,8 @@ import {
updateEventType,
getEventTypesPublic,
EventTypesPublic,
SystemField,
CustomField,
} from "@calcom/platform-libraries/event-types";
import { GetEventTypesQuery_2024_06_14, InputEventTransformed_2024_06_14 } from "@calcom/platform-types";
import { GetEventTypesQuery_2024_06_14 } from "@calcom/platform-types";
import { EventType } from "@calcom/prisma/client";
@Injectable()
@@ -1,13 +1,7 @@
import { ConnectedCalendarsData } from "@/ee/calendars/outputs/connected-calendars.output";
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/event-types.repository";
import { ConferencingService } from "@/modules/conferencing/services/conferencing.service";
import { UserWithProfile } from "@/modules/users/users.repository";
import { Injectable, BadRequestException } from "@nestjs/common";
import { CONFERENCING_APPS } from "@calcom/platform-constants";
import { getUsersCredentials } from "@calcom/platform-libraries";
import { getApps } from "@calcom/platform-libraries/app-store";
import { InputEventTransformed_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/transformed";
import {
transformBookingFieldsApiToInternal,
transformLocationsApiToInternal,
@@ -21,21 +15,24 @@ import {
systemAfterFieldNotes,
systemAfterFieldGuests,
systemAfterFieldRescheduleReason,
EventTypeMetaDataSchema,
transformBookerLayoutsApiToInternal,
transformConfirmationPolicyApiToInternal,
transformEventColorsApiToInternal,
validateCustomEventName,
transformSeatsApiToInternal,
SystemField,
CustomField,
InternalLocation,
InternalLocationSchema,
} from "@calcom/platform-libraries/event-types";
} from "@/ee/event-types/event-types_2024_06_14/transformers";
import { UserWithProfile } from "@/modules/users/users.repository";
import { Injectable, BadRequestException } from "@nestjs/common";
import { getApps, getUsersCredentialsIncludeServiceAccountKey } from "@calcom/platform-libraries/app-store";
import { validateCustomEventName, EventTypeMetaDataSchema } from "@calcom/platform-libraries/event-types";
import {
CreateEventTypeInput_2024_06_14,
DestinationCalendar_2024_06_14,
InputEventTransformed_2024_06_14,
InputBookingField_2024_06_14,
OutputUnknownLocation_2024_06_14,
UpdateEventTypeInput_2024_06_14,
} from "@calcom/platform-types";
@@ -121,16 +118,23 @@ export class InputEventTypesService_2024_06_14 {
seats,
customName,
useDestinationCalendarEmail,
disableGuests,
...rest
} = inputEventType;
const confirmationPolicyTransformed = this.transformInputConfirmationPolicy(confirmationPolicy);
const locationsTransformed = locations?.length ? this.transformInputLocations(locations) : undefined;
const effectiveBookingFields =
disableGuests !== undefined
? this.getBookingFieldsWithGuestsToggled(bookingFields, disableGuests)
: bookingFields;
const eventType = {
...rest,
length: lengthInMinutes,
locations: locationsTransformed,
bookingFields: this.transformInputBookingFields(bookingFields),
bookingFields: this.transformInputBookingFields(effectiveBookingFields),
bookingLimits: bookingLimitsCount ? this.transformInputIntervalLimits(bookingLimitsCount) : undefined,
durationLimits: bookingLimitsDuration
? this.transformInputIntervalLimits(bookingLimitsDuration)
@@ -171,6 +175,7 @@ export class InputEventTypesService_2024_06_14 {
seats,
customName,
useDestinationCalendarEmail,
disableGuests,
...rest
} = inputEventType;
const eventTypeDb = await this.eventTypesRepository.getEventTypeWithMetaData(eventTypeId);
@@ -180,11 +185,18 @@ export class InputEventTypesService_2024_06_14 {
const confirmationPolicyTransformed = this.transformInputConfirmationPolicy(confirmationPolicy);
const effectiveBookingFields =
disableGuests !== undefined
? this.getBookingFieldsWithGuestsToggled(bookingFields, disableGuests)
: bookingFields;
const eventType = {
...rest,
length: lengthInMinutes,
locations: locations ? this.transformInputLocations(locations) : undefined,
bookingFields: bookingFields ? this.transformInputBookingFields(bookingFields) : undefined,
bookingFields: effectiveBookingFields
? this.transformInputBookingFields(effectiveBookingFields)
: undefined,
bookingLimits: bookingLimitsCount ? this.transformInputIntervalLimits(bookingLimitsCount) : undefined,
durationLimits: bookingLimitsDuration
? this.transformInputIntervalLimits(bookingLimitsDuration)
@@ -210,6 +222,27 @@ export class InputEventTypesService_2024_06_14 {
return eventType;
}
getBookingFieldsWithGuestsToggled(
bookingFields: InputBookingField_2024_06_14[] | undefined,
hideGuests: boolean
) {
const toggledGuestsBookingField: InputBookingField_2024_06_14 = { slug: "guests", hidden: hideGuests };
if (!bookingFields) {
return [toggledGuestsBookingField];
}
const bookingFieldsCopy = [...bookingFields];
const guestsBookingField = bookingFieldsCopy.find((field) => "slug" in field && field.slug === "guests");
if (guestsBookingField) {
Object.assign(guestsBookingField, { hidden: hideGuests });
return bookingFieldsCopy;
}
bookingFieldsCopy.push(toggledGuestsBookingField);
return bookingFieldsCopy;
}
transformInputLocations(inputLocations: CreateEventTypeInput_2024_06_14["locations"]) {
return transformLocationsApiToInternal(inputLocations);
}
@@ -224,6 +257,7 @@ export class InputEventTypesService_2024_06_14 {
const systemCustomNameField = systemCustomFields?.find((field) => field.type === "name");
const systemCustomEmailField = systemCustomFields?.find((field) => field.type === "email");
const systemCustomTitleField = systemCustomFields?.find((field) => field.name === "title");
const systemCustomLocationField = systemCustomFields?.find((field) => field.name === "location");
const systemCustomNotesField = systemCustomFields?.find((field) => field.name === "notes");
const systemCustomGuestsField = systemCustomFields?.find((field) => field.name === "guests");
const systemCustomRescheduleReasonField = systemCustomFields?.find(
@@ -233,7 +267,7 @@ export class InputEventTypesService_2024_06_14 {
const defaultFieldsBefore: (SystemField | CustomField)[] = [
systemCustomNameField || systemBeforeFieldName,
systemCustomEmailField || systemBeforeFieldEmail,
systemBeforeFieldLocation,
systemCustomLocationField || systemBeforeFieldLocation,
];
const defaultFieldsAfter = [
@@ -274,7 +308,8 @@ export class InputEventTypesService_2024_06_14 {
field.name !== "title" &&
field.name !== "notes" &&
field.name !== "guests" &&
field.name !== "rescheduleReason"
field.name !== "rescheduleReason" &&
field.name !== "location"
);
}
@@ -476,7 +511,7 @@ export class InputEventTypesService_2024_06_14 {
appSlug = "msteams";
}
const credentials = await getUsersCredentials(user);
const credentials = await getUsersCredentialsIncludeServiceAccountKey(user);
const foundApp = getApps(credentials, true).filter((app) => app.slug === appSlug)[0];
@@ -1,14 +1,4 @@
import { Injectable } from "@nestjs/common";
import type { EventType, User, Schedule, DestinationCalendar } from "@prisma/client";
import {
userMetadata,
parseBookingLimit,
parseRecurringEvent,
getBookingFieldsWithSystemFields,
} from "@calcom/platform-libraries";
import {
EventTypeMetaDataSchema,
transformLocationsInternalToApi,
transformBookingFieldsInternalToApi,
InternalLocationSchema,
@@ -20,11 +10,20 @@ import {
transformBookerLayoutsInternalToApi,
transformRequiresConfirmationInternalToApi,
transformEventTypeColorsInternalToApi,
parseEventTypeColor,
transformSeatsInternalToApi,
InternalLocation,
BookingFieldSchema,
} from "@calcom/platform-libraries/event-types";
} from "@/ee/event-types/event-types_2024_06_14/transformers";
import { Injectable } from "@nestjs/common";
import type { EventType, User, Schedule, DestinationCalendar, CalVideoSettings } from "@prisma/client";
import {
userMetadata,
parseBookingLimit,
parseRecurringEvent,
getBookingFieldsWithSystemFields,
} from "@calcom/platform-libraries";
import { EventTypeMetaDataSchema, parseEventTypeColor } from "@calcom/platform-libraries/event-types";
import {
TransformFutureBookingsLimitSchema_2024_06_14,
BookerLayoutsTransformedSchema,
@@ -38,8 +37,9 @@ type EventTypeRelations = {
users: User[];
schedule: Schedule | null;
destinationCalendar?: DestinationCalendar | null;
calVideoSettings?: CalVideoSettings | null;
};
export type DatabaseEventType = EventType & EventTypeRelations;
export type DatabaseEventType = Omit<EventType, "allowReschedulingCancelledBookings"> & EventTypeRelations;
type Input = Pick<
DatabaseEventType,
@@ -88,6 +88,7 @@ type Input = Pick<
| "useEventTypeDestinationCalendarEmail"
| "hideCalendarEventDetails"
| "hideOrganizerEmail"
| "calVideoSettings"
>;
@Injectable()
@@ -125,6 +126,7 @@ export class OutputEventTypesService_2024_06_14 {
useEventTypeDestinationCalendarEmail,
hideCalendarEventDetails,
hideOrganizerEmail,
calVideoSettings,
} = databaseEventType;
const locations = this.transformLocations(databaseEventType.locations);
@@ -200,6 +202,7 @@ export class OutputEventTypesService_2024_06_14 {
useDestinationCalendarEmail: useEventTypeDestinationCalendarEmail,
hideCalendarEventDetails,
hideOrganizerEmail,
calVideoSettings,
};
}
@@ -1,5 +1,3 @@
import type { z } from "zod";
import type {
transformEventColorsApiToInternal,
transformFutureBookingLimitsApiToInternal,
@@ -8,9 +6,13 @@ import type {
transformSeatsApiToInternal,
transformBookingFieldsApiToInternal,
InternalLocationsSchema,
} from "@calcom/lib/event-types/transformers";
} from "@/ee/event-types/event-types_2024_06_14/transformers";
import type { z } from "zod";
import type { CreateEventTypeInput_2024_06_14, ConfirmationPolicyTransformedSchema } from "../inputs";
import type {
CreateEventTypeInput_2024_06_14,
ConfirmationPolicyTransformedSchema,
} from "@calcom/platform-types";
export type InputEventTransformed_2024_06_14 = Omit<
CreateEventTypeInput_2024_06_14,
@@ -1,12 +1,10 @@
import { describe, expect, it } from "vitest";
import {
BookerLayoutsInputEnum_2024_06_14,
BookerLayoutsOutputEnum_2024_06_14,
ConfirmationPolicyEnum,
NoticeThresholdUnitEnum,
FrequencyInput,
} from "@calcom/platform-enums/monorepo";
} from "@calcom/platform-enums";
import type {
InputBookingField_2024_06_14,
InputLocation_2024_06_14,
@@ -1,7 +1,7 @@
import {
BookerLayoutsInputEnum_2024_06_14,
BookerLayoutsOutputEnum_2024_06_14,
} from "@calcom/platform-enums/monorepo";
} from "@calcom/platform-enums";
import { type CreateEventTypeInput_2024_06_14 } from "@calcom/platform-types";
export function transformBookerLayoutsApiToInternal(
@@ -1,6 +1,5 @@
import type {
InputBookingField_2024_06_14,
LocationDefaultFieldOutput_2024_06_14,
PhoneDefaultFieldOutput_2024_06_14,
MultiSelectFieldInput_2024_06_14,
CheckboxGroupFieldInput_2024_06_14,
@@ -8,6 +7,7 @@ import type {
NameDefaultFieldInput_2024_06_14,
EmailDefaultFieldInput_2024_06_14,
TitleDefaultFieldInput_2024_06_14,
LocationDefaultFieldInput_2024_06_14,
NotesDefaultFieldInput_2024_06_14,
GuestsDefaultFieldInput_2024_06_14,
RescheduleReasonDefaultFieldInput_2024_06_14,
@@ -28,10 +28,7 @@ import {
systemBeforeFieldNameSplit,
} from "../internal-to-api";
type InputBookingField =
| InputBookingField_2024_06_14
| LocationDefaultFieldOutput_2024_06_14
| PhoneDefaultFieldOutput_2024_06_14;
type InputBookingField = InputBookingField_2024_06_14 | PhoneDefaultFieldOutput_2024_06_14;
export function transformBookingFieldsApiToInternal(bookingFields: InputBookingField[]) {
const customBookingFields = bookingFields.map((field) => {
@@ -77,8 +74,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
if (fieldIsDefaultSystemLocation(field)) {
return {
...systemBeforeFieldLocation,
required: field.required,
hidden: field.hidden,
label: field.label,
};
}
@@ -157,7 +153,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
required: !!field.required,
hidden: !!field.hidden,
label: field.label,
placeholder: "placeholder" in field ? field.placeholder : "",
placeholder: "placeholder" in field ? field.placeholder : undefined,
disableOnPrefill: !!field.disableOnPrefill,
};
}
@@ -168,7 +164,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
required: !!field.required,
hidden: !!field.hidden,
label: field.label,
placeholder: "placeholder" in field ? field.placeholder : "",
placeholder: "placeholder" in field ? field.placeholder : undefined,
disableOnPrefill: !!field.disableOnPrefill,
};
}
@@ -179,7 +175,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
required: !!field.required,
hidden: !!field.hidden,
label: field.label,
placeholder: "placeholder" in field ? field.placeholder : "",
placeholder: "placeholder" in field ? field.placeholder : undefined,
disableOnPrefill: !!field.disableOnPrefill,
};
}
@@ -190,7 +186,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
required: !!field.required,
hidden: !!field.hidden,
label: field.label,
placeholder: "placeholder" in field ? field.placeholder : "",
placeholder: "placeholder" in field ? field.placeholder : undefined,
disableOnPrefill: !!field.disableOnPrefill,
};
}
@@ -298,7 +294,7 @@ function fieldIsDefaultAttendeePhone(field: InputBookingField): field is PhoneDe
function fieldIsDefaultSystemLocation(
field: InputBookingField
): field is LocationDefaultFieldOutput_2024_06_14 {
): field is LocationDefaultFieldInput_2024_06_14 {
return "slug" in field && field.slug === "location";
}
@@ -1,4 +1,4 @@
import { ConfirmationPolicyEnum } from "@calcom/platform-enums/monorepo";
import { ConfirmationPolicyEnum } from "@calcom/platform-enums";
import type {
ConfirmationPolicyTransformedSchema,
NoticeThresholdTransformedSchema,
@@ -1,7 +1,7 @@
import {
BookingWindowPeriodInputTypeEnum_2024_06_14,
BookingWindowPeriodOutputTypeEnum_2024_06_14,
} from "@calcom/platform-enums/monorepo";
} from "@calcom/platform-enums";
import {
type CreateEventTypeInput_2024_06_14,
type BusinessDaysWindow_2024_06_14,
@@ -1,4 +1,4 @@
import { BookingLimitsEnum_2024_06_14 } from "@calcom/platform-enums/monorepo";
import { BookingLimitsEnum_2024_06_14 } from "@calcom/platform-enums";
import {
type CreateEventTypeInput_2024_06_14,
type BookingLimitsKeyOutputType_2024_06_14,
@@ -1,4 +1,4 @@
import { Frequency } from "@calcom/platform-enums/monorepo";
import { Frequency } from "@calcom/platform-enums";
import type { Recurrence_2024_06_14 } from "@calcom/platform-types";
import { type TransformRecurringEventSchema_2024_06_14 } from "@calcom/platform-types";
@@ -1,7 +1,7 @@
import {
BookerLayoutsInputEnum_2024_06_14,
BookerLayoutsOutputEnum_2024_06_14,
} from "@calcom/platform-enums/monorepo";
} from "@calcom/platform-enums";
import type { BookerLayoutsTransformedSchema } from "@calcom/platform-types";
export function transformBookerLayoutsInternalToApi(
@@ -82,6 +82,7 @@ export function transformBookingFieldsInternalToApi(
slug: "location",
required: !!field.required,
hidden: !!field.hidden,
label: field.label,
} satisfies LocationDefaultFieldOutput_2024_06_14;
case "rescheduleReason":
return {
@@ -1,7 +1,7 @@
import {
BookingWindowPeriodInputTypeEnum_2024_06_14,
BookingWindowPeriodOutputTypeEnum_2024_06_14,
} from "@calcom/platform-enums/monorepo";
} from "@calcom/platform-enums";
import type {
TransformFutureBookingsLimitSchema_2024_06_14,
BookingWindow_2024_06_14,
@@ -1,11 +1,9 @@
import { describe, expect, it } from "vitest";
import {
BookerLayoutsInputEnum_2024_06_14,
BookerLayoutsOutputEnum_2024_06_14,
ConfirmationPolicyEnum,
NoticeThresholdUnitEnum,
} from "@calcom/platform-enums/monorepo";
} from "@calcom/platform-enums";
import type {
TransformBookingLimitsSchema_2024_06_14,
TransformFutureBookingsLimitSchema_2024_06_14,
@@ -1,4 +1,4 @@
import { BookingLimitsEnum_2024_06_14 } from "@calcom/platform-enums/monorepo";
import { BookingLimitsEnum_2024_06_14 } from "@calcom/platform-enums";
import type {
BookingLimitsKeysInputType,
TransformBookingLimitsSchema_2024_06_14,
@@ -1,4 +1,4 @@
import { Frequency, FrequencyInput } from "@calcom/platform-enums/monorepo";
import { Frequency, FrequencyInput } from "@calcom/platform-enums";
import type { Recurrence_2024_06_14, TransformRecurringEventSchema_2024_06_14 } from "@calcom/platform-types";
export function transformRecurrenceInternalToApi(
@@ -1,4 +1,4 @@
import { ConfirmationPolicyEnum } from "@calcom/platform-enums/monorepo";
import { ConfirmationPolicyEnum } from "@calcom/platform-enums";
import type { NoticeThresholdTransformedSchema, ConfirmationPolicy_2024_06_14 } from "@calcom/platform-types";
export function transformRequiresConfirmationInternalToApi(

Some files were not shown because too many files have changed in this diff Show More