* 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
Fixes CAL-5372
# Delegation Credentials with CalendarCache.
Following content is a snapshot of the [internal document](https://calendso.slack.com/docs/T08B8KA2BNF/F08L5JYU3V3)
**Problem-1 :**
CalendarCache needs SelectedCalendar records to work but SelectedCalendar record is only created when a user connects their calendar and then enables some calendar for conflict checking. Because with Delegation, no manual connection is done by any of the members, we need a way to create SelectedCalendar records automatically.
**Problem-2**
CalendarCache connects to credential(regular credential) which doesn’t exist for Delegation Credential scenario. Also, DelegationCredential is common for all the members(different from Credential which is different for different members) of the organization and we need to identify to which user the CalendarCache belongs.
**Solution for both problems**
- Create credential records for Delegation Credentials as well - Through Cron(new - we could schedule it every 5mins)
- Now create SelectedCalendar records for those Credential records - Through another Cron(new - we could schedule it every 5mins)
- Now CalendarCache records will automatically be created for those SelectedCalendar records -existing cron
## Fixed some Delegation Credentials bugs unrelated to calendar-cache
- If DestinationCalendar wasn't set(which is possible only with Delegation Credentials), then Google Meet wasn't used as a conferencing app - [Added a test]
- If no SelectedCalendar is there but Google Calendar connection exists(possible only with Delegation Credential) then we were not doing conflict checking. It is expected to not do it for Regular Credentials, but for Delegation Credential we must check for conflict in that case too [Added a test]
- Earlier if a user has Regular Credential as well as Delegation Credential for the same external id which is the member email(say member1@acme.com) then availability were retrieved twice because we weren't deduplicating credentials as it wasn't a trivial thing to do. Now that is being done.
**Env Variables:**
Note this PR doesn't introduce any new env variable. The existing env variable has been added to .env.example. But if this env variable isn't already set, it must be set.
`CALCOM_SERVICE_ACCOUNT_ENCRYPTION_KEY={SAME_AS_SET_FOR_V2_API}`
**Deployment Plan:**
1. Add Observability for SelectedCalendar when _error_ field is set
2. Follow https://github.com/calcom/cal.com/blob/calendar-cache-dwd-support/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/delegation-credential/delegation-credential.md#setting-up-delegation-credential-for-google-calendar-api to enable Delegation Credential for i.cal.com
3. Note that to be able to see the option to enable Delegation Credential for an organization, you need to enable `teamFeature` and `feature` for `delegation-credential`
## Automation Tests
- Introduced tests for calendar-cache.repository.ts
- Tests all methods of the repository
- Added more tests for handleNewBooking/delegation-credential flow.
- Added test to verify the bug fix when no DestinationCalendar exists and Google Meet should be used still
- Added more tests for Google Calendar/CalendarService targeting DelegationCredential
- Added more tests for getCalendarsEvents.
- To test the new logic of calling getAvailability still if there are no selectedCalendars in case of Delegation Credential
- Also introduced tests for `getAvailabitlityWithTimezones` which was an existing function but now has some new changes.
- Added tests for deduplication logic in CalendarManager.ts
## How to Test
Enable Calendar Cache and Delegation Credential feature for acme org through `features` and `teamFeatures` tables.
- Enable Delegation Credential for acme org
- Enable atleast 1 calendar for conflict checking for one of the users(say owner1)
- Ensure GOOGLE_WEBHOOK_TOKEN is set in .env file
- Ensure GOOGLE_WEBHOOK_URL is set to ngrok url of webapp in .env file
- Hit cron endpoint `curl http://localhost:3000/api/calendar-cache/cron\?apiKey\={API_KEY}` that would cache the freebusy result for the selected calendars
Followup
- https://github.com/calcom/cal.com/pull/20698
- https://github.com/calcom/cal.com/pull/18619/files#r2046795643
* init
* updated typing, english localization text, used existing calculatePeriodLimits and isTimeViolatingFutureLimit to determine if go to next month button should be disabled
* improving copy
* semantic dialog heading tag, proper EN localization,
* reverting
* force local to origin
* Translations by LLM
* intit tests
* moving NoAvailability to its own file.
* refactor overlay component to encpsulate logic in hooks
* improved tests
* remove unintended change
* fix: period data type import. Providing default periodData values
* fix: type errors on event object
* fix: updates case in type import
* removing translations
* remove unnecessary import
* remove unnecessary import
* improving mocks for booker and logger
* moving tests to __tests__ folder
---------
Co-authored-by: Tushar Bhatt <95581504+TusharBhatt1@users.noreply.github.com>
* Type app options
* Refactor `writeToPersonRecord` to `writeToRecord`
* Abstract writing to salesforce record options component
* Add option to write to event object on cancellation
* Add on booking cancel write to event object to schema
* Refactor writing to record on booking option to use `<WriteToObjectSettings />`
* Pass event object to crm delete method
* When cancelling booking write to event object
- App data isn't being read
* V1 pass app data to crm service
* Undo .env commit
* Fix passing event to cancel crm cancel event method
* Pass event type metadata to `EventManager` in `handleCancelBooking`
* Handle writing to event record
* Type fix
* fix: Do not self import @calcom/ui
* Make translations optional
* Fix mocking implementation of Button (never worked)
* Ensure other libraries can resolve AppListCard
* refactor: Remove intervalLimits from @calcom/lib and export directly
* Tackle other places that use parseBookingLimit/parseDurationLimit
* More type fixups that were hidden by previous fails
* Fixed up booking-limits file
* Remove server-only
* Revert "Revert "chore: rename DWD to DelegationCredential (#19703)" (#19734)"
This reverts commit 340b5ab061.
* chore: fix schema and types for now
* fix: domainWideDelegationCredentialId error type
* Add endpoints for testing the flow
* Add MVP
* new route
* Fixes
* Fixes
* Remove enable toggle support from domainWideDelegation
* Fixes
* Revert "Remove enable toggle support from domainWideDelegation"
This reverts commit c29e729206cd1fa063f9c9ce0cf148ef1577d60b.
* Revert yarn.lock
* More fixes
* Fix new workspace platform add
* refactor: improvements
* refactor: bug fixes and improvements
* fix: type errors
* fix: conflicts
* chore: update test
* fix: logic
* chore: improvements
* fix: toglle
* fix: bugs
* fix: type err
* chore: check number type
* fix: after conflicts
* chore: fix type err
* fix: type errors and tests
* fix: tets
* test
* chore: remove unused
* fix: google meet url on booking page and secondary calendar
* fix: add property
* fix: type err
* fix: re assingment bug
* fix: use getAllCredentials
* chore: fix import
* fix: installed count
* fix: pass event type
* fix: import
* fix: [Stacked PR] Review fixes (#17958)
* Review fixes
* fix: destination calendar bug
---------
Co-authored-by: Udit Takkar <udit222001@gmail.com>
* refactor: use repository
* chore: remove duplicate
* fix: More review fixes for domain wide delegation (#17969)
* Reuse buildCredentialPayloadForCalendar
* fixes
---------
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
* fix ts error
* Fix getSchedule not using dwd credentials (#17995)
* fix: Remove direct DWD table access from google-calendar and remove delegatedToId column from Credential (#18015)
* Remove fn rename to reduce number of files changed
* chore: check feature globally
* test: add unit tests
* chore: move function
* test: add booking test
* wip
* Remove domain-wide-delegation team feature flag
* Make sure duplicate calendars are not shown due to DWD. Show DWD when there is conflict
* Fix tests and their ts errors
* Fix more tests
* Move findUsersForAvailabilityCheck to separate file as it has AppStore dependency causing problem with Routing Forms. Build crashes
* fix: Multiple calendar connections from Google not showing up in apps/installed
* DestinationCalendar must have either credentialId or domainWideDeelgationId. Also handle the case when DWD is disabled and there was a non-dwd credential that could be used
* Disable deletetion of DWD as it is destructive and prefer disabling instead
* Show DWD credential calendars at the top
* Fixed tests
* Calendar Cache DWD support
* Self-Review: Verify email required and add more selectedCalendar tests
* Self Review: shorten names
* Self ReviewL Dead code removal
* Revert "Calendar Cache DWD support"
This reverts commit 009f236470fa21eba5986117d4f6e4d4c5e38c34.
* Some misc fixes
* fixes
* Performance improvememt in slots loading and booking
* More cases for handling dwd credentials
* simplify the logic. Ensure that EventManager and the modules below it in the flow have CredentialForCalendarService available
* Fix tests
* Fix installed/conferencing not showing gogole meet
* Shorten name
* Fix ApI v2 tests
* Add some more tests
* add getSchedule tests
* Improve tests
* Make Google Meet default when DWD for google is enabled
* Enable feature flagging for DWD
* chore: bump libraries
* Encrypt serviceaccount private key
* Fix ts errors
* bump platform libraries
* org add dwd
* org add dwd
* bump platform libraries
* fix selected calendars
* fix remove selected dwd calendar
* remove oauthclient id aliad in authedCalendar
* remove oauthclient id aliad in authedCalendar
* refactor: OrganizationsDwdController
* chore: export toggleDwdEnabled from platform-libraries
* feat: v2 update (enable / disable) dwd
* refactor: SelectedCalendarsController check if user belongs to dwd org & for not dwd use previous logic
* wip: DestinationCalendar send domainWideDelegationCredentialId from frontend to api
* try fix set destination calendar api v2
* fixup! try fix set destination calendar api v2
* setting google meet as default location working for dwd
* bump platform libraries version
* allow office 365 workspace slug
* allow office 365 workspace slug
* chore: v2 create dwd MS and Google service keys input
* fix: CreateDwdInput serviceAccountKey
* fix: CredentialForCalendarService type
* fix: check workspace slug
* feat: update serviceAccessKey of DWD
* testing
* fixup! testing
* fix: getAuthUtl bug
* fix: unit tests
* fix: type err and unit test
* fix: e2e test
* fix: credentials bug and failing unit tests
* Update CalendarService.ts
* chore: refactor office365 calendar service and add testDomainWideDelegationSetup
* fix: office365Calendar use correct clientId/Secret for DWD
* fix: office365Calendar dwd no need refresh token
* test: add unit test for outlook dwd and setup
* feat: added dwd support for office365 calendar
* feat: added dwd support for office365 video
* test: finish test for outlook dwd
* fix: create dialog bug
* chore: remove console logs
* fix: refreshToken bug
* bump version libraries
* refactor: fetch dwd credentials only in findQualifiedHosts
* fixup! refactor: fetch dwd credentials only in findQualifiedHosts
* fix: type err
* fix: type err
* fix: getUserDisplayName
* fix: unit test
* chore: bump platform lib
---------
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Morgan Vernay <morgan@cal.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
* Refactors related to enabling typescript 5.3.3 in @calcom/trpc
* Also skip respective tests (obviously logic is broken)
* This causes problems for some reason, revert
* Bring back QueryCell as it's used by atoms
* wip
* fix
* fix
* refactor
* rename to routingServerSidePropsConfig
* refactor
* refactor
* add routing-link to useIsBookingPage hook
* remove Head component
* fix
* redirect user to apps/routing-forms/forms if user goes to apps/routing-forms
* refactor
* remove log
* remove client component not needed
* clean up code
* remove unneeded metadata
* clean up further
* clean up further 2
* fix type check
* routing-link does not need shell
* Fix title for Routing Form public link and also remove any
* Remove ; in HTML
* Remove unnecessary page reload
---------
Co-authored-by: Hariom Balhara <hariombalhara@gmgmail.com>
* first version of ooo calibration
* decrease precision when checking for full day event
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* improve variable naming
* don't include hosts created after OOO
* fix failing tests
* fix all tests
* add test for ooo calibration
* first implementation to fix full day busy event reaching the current month
* allow mutiple day events
* make getAvailabilityWithTimeZones optional
* fix type error
* fix type errors
* fix tests
* fix type error
* fix test
* code clean up
* remove time adjustment from map
* code clean up
* fix tests
* getAllCalendars -> this.getAllCalendars
* fix typo
* extract mergeOverlappingRanges
* code improvements from feedback
* fix getCalIdsWithTimeZone
---------
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
* Reapply "feat: add text & numeric filters to insights routing responses (#18016)"
This reverts commit 49070b96ae.
* support SINGLE_SELECT
* fix type error
* put back ts-expect-error
* remove playground
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: improve text filters (WIP)
* move function to bottom
* apply some styles
* fix selection of TextFilterOptions
* rename value to operand
* remove unused file
* merge filters/filters into filters/utils
* fix regression of not putting url params correctly
* move makeWhereClause to filters/utils
* fix negative, empty, and not empty operators
* fix initial filtering from search state (url)
* fix type errors
* do not send an empty array to query
* update yarn.lock
* i18n for text filter operators
* extract logic as useColumnFilters()
* add missing import
* fix type error
* revert yarn.lock
* use i18n
* insensitive text match
* move data-table to @calcom/features
* fix type errors
* fix type errors
* fix type errors
* feat: support DataTable filters for Insights Routing WIP
* remove unused filters
* remove additionalFilters and fix types
* clean up filter components
* support icons for ActiveFilters
* support filters on json
* fix filter ui
* fix type error and clean up
* revert changes
* revert change
* clean up
* revert change
* fix compatibility with insights booking page
* remove unused params
* fix type errors
* update yarn.lock
* fix field filter and adjust ui
* chore: update yarn.lock
* fix text filter
* add Clear Filters button
* add more test data
* feat: support numeric filter WIP
* feat: support numeric filter
* feat: move People to an external filter
* fixing query states
* rename state to activeFilters
* add useDataTable
* fix ResponseCellValue bug and enable resizing for RoutingFormResponsesTable
* fix response values
* truncate attribute text
* seed booking attendees
* fix accessor (no actual change though)
* add a gap
* rename
* use pathname as default identifier for DataTable
* fix type error
* support text filter for assignment reason
* Apply suggestions from code review
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* rename fields to headers
* use safeParse
* fix type error
* push yarn.lock with faker
* fix MemberList
---------
Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: sean-brydon <sean@cal.com>
* fix: able to create consecutive ooo
* added e2e test
* chore
* update to allow overlapping ooo and test for same
* refactor to reduce repeating code in tests
* nit
* added testcases for consecutive and reverse redirects
* fix:duplicate OOO creation
* prevent duplicate entries, also added test
* chore
* update after merges
* correct datetype in prisma query
* update to changes in rdp after merge
---------
Co-authored-by: Prashant Varma <prashantvarma5083@gmail.com>
* revert: "feat: refactor filters on insights response table (#17796)"
This reverts commit 5d88858995.
* Put back the search columns and options english terms
* feat: improve text filters (WIP)
* move function to bottom
* apply some styles
* fix selection of TextFilterOptions
* rename value to operand
* remove unused file
* merge filters/filters into filters/utils
* fix regression of not putting url params correctly
* move makeWhereClause to filters/utils
* fix negative, empty, and not empty operators
* fix initial filtering from search state (url)
* fix type errors
* do not send an empty array to query
* update yarn.lock
* i18n for text filter operators
* extract logic as useColumnFilters()
* add missing import
* fix type error
* revert yarn.lock
* use i18n
* insensitive text match
* move data-table to @calcom/features
* fix type errors
* fix type errors
* fix type errors
* feat: support DataTable filters for Insights Routing WIP
* remove unused filters
* remove additionalFilters and fix types
* clean up filter components
* support icons for ActiveFilters
* support filters on json
* fix filter ui
* fix type error and clean up
* revert changes
* revert change
* clean up
* revert change
* fix compatibility with insights booking page
* remove unused params
* fix type errors
* update yarn.lock
* fix field filter and adjust ui
* chore: update yarn.lock
* fix text filter
* add Clear Filters button
* add more test data
---------
Co-authored-by: Udit Takkar <udit222001@gmail.com>
* Catch undefined app option properties
* Add `getCompanyNameFromBookingResponse` method
* Pass bookingResponse when Lead is being created
* Pass bookingResponse from CRMManager
* Handle empty company response
* Return the company value
* feat: improve text filters (WIP)
* move function to bottom
* apply some styles
* fix selection of TextFilterOptions
* rename value to operand
* remove unused file
* merge filters/filters into filters/utils
* fix regression of not putting url params correctly
* move makeWhereClause to filters/utils
* fix negative, empty, and not empty operators
* fix initial filtering from search state (url)
* fix type errors
* do not send an empty array to query
* update yarn.lock
* i18n for text filter operators
* extract logic as useColumnFilters()
* add missing import
* fix type error
* revert yarn.lock
* use i18n
* insensitive text match
* move data-table to @calcom/features
* fix type errors
* fix type errors
* fix type errors
---------
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
* fix: make actions column sticky in members list
* clean up import
* change type definition
* remove old export
* include tanstack.d.ts
* fix declaration file
* move type def to packages/types/tanstack-table.d.ts
---------
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
* adding posthog libs for node + js
* updating lock
* move to init posthog client - pageview component
* adding identify in shell
* removing test event captures
* add signout tracking to dropdown as it was missed in merge
---------
Co-authored-by: sean <sean@brydon.io>
Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk>
* Refactor get SF user and create event
* Add new Salesforce options
* Pass app options to CrmService
* Add record enum
* Add creating new lead and contact under an account
* Handle if the contact already exists but not connected to account
* Create a lead if an account doesn't exist
* Merge fix
* Refactor - add generateCreateRecordBody
* Type fix
* Clean up
* Add getAppOptions to other CRM services
* Type fixes
* Fix typo
* feat: Salesforce round robin skip - choose which entity to search on (#17038)
* Add option to search which entity for the owner
* Add logic to search entity for skipping RR assignment
* Type fixes
* Disable license
* Skip license check in component
* Revert license changes
---------
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>