* refactor: getUserAvailability into service with DI
* chore: bump platform libs
* disable bull queue in e2e for bookings
* chore: bump platform libs
* chore: bump platform libs
* fix: should update event type bookingFields test
---------
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-08-05 13:13:42 +01:00
Eunjae LeeGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* refactor: use dependency injection for InsightsBookingService
- Add DI tokens for InsightsBookingService and module
- Rename InsightsBookingService to InsightsBookingBaseService
- Create InsightsBookingService DI interface with create method
- Add DI module and container for InsightsBookingService
- Update tRPC router to use getInsightsBookingService DI container
- Update test file to use InsightsBookingBaseService
- Update documentation to reflect new DI pattern
Follows the same dependency injection pattern established for InsightsRoutingService in PR #22677
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* refactor: restore createInsightsBookingService helper using DI internally
- Keep createInsightsBookingService helper function for cleaner API
- Use getInsightsBookingService DI container internally
- Maintain same function signature and behavior
- All existing calls continue to work unchanged
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* refactor: rename service files with proper capitalization
- Rename insightsBookingBase.ts to InsightsBookingBaseService.ts
- Rename insightsBookingDI.ts to InsightsBookingDIService.ts
- Update all import statements to use new file names
- Maintain existing handler functionality using createInsightsBookingService(ctx, input)
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* revert some changes
* rename
* update doc
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix: add backfill migration for routing response denormalized tables
* update script
* implement select type
* improve number handling
* clean up queries
* rename
* handle zero record case
* revert
* rename
* fix division problem
* log clean up
* force adding new rows after removing existing rows
* backfill only missing or wrong data
* remove sleep
* perf: use repository for webhooks list query & caching in /settings/developer/webhooks/... RSC
* fix type check
* invalidate cache on webhook list item actions
* fix review comment
* fix merge conflicts
* send bookingId in BOOKING_CANCELLED through requestReschedule
* fix: make customInputs nullable in BookingWebhookFactory
* fix: make customInputs nullable in BookingWebhookFactory
* fix: increment iCalSequence when changing booking location
- Add iCalSequence parameter to buildCalEventFromBooking function
- Update editLocation handler to increment sequence by 1 in CalendarEvent
- Update database with incremented iCalSequence when location changes
- Update buildCalEventFromBooking test to include new fields
- Ensures ICS files properly update existing calendar events instead of creating duplicates
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* `BookingRepository.updateLocationById` to accept responses and iCalSequence
* `editLocation.handler` use `BookingRepository`
* Update iCalSequence
* Use iCalSequence from booking param
* Add iCalUID to evt object
* Clean up
* Fix test
* Fix test
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* refactor: convert getShouldServeCache to CacheService with dependency injection
- Create CacheService class following AvailableSlotsService DI pattern
- Add FeaturesRepository and CacheService to DI tokens and modules
- Create cache container with proper dependency injection setup
- Update handleNewBooking.ts and slots/util.ts to use new service
- Maintain backward compatibility with error-throwing wrapper function
- Follow established service patterns for clean architecture
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* feat: inject CacheService into AvailableSlotsService via dependency injection
- Add cacheService to IAvailableSlotsService interface
- Update available-slots container to load cache modules
- Update available-slots module to inject CacheService dependency
- Replace direct getShouldServeCache call with injected service method
- Add CacheService import to util.ts for proper typing
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* chore: DI api v2 cache service
* refactor: convert FeaturesRepository to use factory pattern in DI
- Change from constructor injection to factory pattern to avoid PRISMA_CLIENT binding issues in tests
- FeaturesRepository now uses default prisma instance instead of DI injection
- Resolves test failures while maintaining DI container compatibility
- Tests reduced from 123+ failures to only 5 unrelated failures
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* revert: use direct FeaturesRepository instantiation in most usage points
- Revert getFeaturesRepository() calls back to new FeaturesRepository()
- Tests require direct instantiation for mocking compatibility
- Keep DI container for specific use cases that need dependency injection
- Resolves test failures while maintaining both DI and direct usage patterns
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* fix: resolve FeaturesRepository DI container issues
- Update cache module to use factory pattern with proper ICacheService interface
- Remove featuresModule loading from cache and available-slots containers
- Use direct FeaturesRepository instantiation via getFeaturesRepository()
- Resolves 'No binding found for key: Symbol(FeaturesRepository)' errors
- Reduces test failures from 125 to 7 (remaining failures appear unrelated)
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* fix: update all FeaturesRepository instantiations to include prisma parameter
- Add prisma parameter to all new FeaturesRepository() calls across the codebase
- Update API v2 services to match main repo interfaces
- Fix PrismaFeaturesRepository to implement IFeaturesRepository directly
- Update CacheService in API v2 to expose required dependencies and getShouldServeCache
- Implement CheckBookingLimitsService in API v2 with proper interface
- Resolves type assignment errors between API v2 and main repo implementations
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* fix: add prisma parameter to remaining FeaturesRepository instantiations in apps/web/lib
- Update getServerSideProps files to pass prisma parameter to FeaturesRepository
- Ensures all FeaturesRepository instantiations follow the new constructor pattern
- Completes the refactoring to use direct instantiation with prisma parameter
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* refactor clean and fix devin issues
* chore: bump platform libs
* chore: bump platform libs
* chore: bump platform libs
* chore: bump platform libs
* fix: missing di
* fix workflow test
* fix workflow test
* fix integration test
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
* fix: resolve username constraint violation in removeMember
- Update username to - format when removing users from organizations
- Fix unique constraint violation on (username, organizationId) when organizationId is null
- Add test case to verify username format change and successful removal
- Fix skipped test by adding proper imports and removing describe.skip
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* test: update removeMember test to verify constraint violation scenario
- Create two users with same username (one with null orgId, one with orgId)
- Verify removing org user updates username without unique constraint error
- Test ensures username gets updated to - format
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* test: add comprehensive unit tests for handleInstantMeeting
- Revert previous removeMember changes
- Add full test coverage for instant meeting functionality
- Test team validation, booking creation, token generation
- Test webhook triggers and browser notifications
- Mock external dependencies for isolated unit tests
- Translation issue to be addressed in future iteration
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* update
* Update handleInstantMeeting.test.ts
* fix: redir parameter for connect atoms (#22815)
* encode redirect url to make sure it has all parameters
* add changesets
* feat: Support an array response for a field when used as `Value of Field` (#22740)
* Passing tests and fixed
* self review addressed adn more tests
* fix: flaky e2e (#22819)
* fix: merge working hours when adjacent (#21912)
* fix: Adjacency issue when working hours connect over multiple days
* Add tests to validate the new merging of day end logic
* Update to correct annotation.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
* Implement subsequent date ranges for date overrides also
* The map needs to be updated on successful resolve.
* test: add failing test for overlapping ranges with same end time
Demonstrates bug where overlapping working hour ranges (6:00-10:00 and 8:00-10:00)
lose the earlier portion (6:00-8:00), showing only 8:00 and 9:00 slots
instead of all 4 slots (6:00, 7:00, 8:00, 9:00).
Related to Carina's comment on PR #21912.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* fix: properly merge overlapping ranges with same end time
Fixes bug where overlapping working hour ranges with the same end time
(e.g., 6:00-10:00 and 8:00-10:00) would lose the earlier portion of the
first range. The merging logic now correctly preserves the earliest
start time when ranges overlap and share the same end time.
This ensures all expected time slots are available (6:00, 7:00, 8:00, 9:00)
instead of losing the earlier slots (6:00, 7:00).
Resolves the issue identified in Carina's comment on PR #21912.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* perf: optimize overlapping range detection from O(n²) to O(n)
Replaces Object.keys().find() with Map-based lookup for ranges with same end time.
This optimization handles 2000+ date ranges efficiently, reducing complexity from
4M operations to linear time while maintaining the same merging behavior.
Performance improvement for high-volume event types with many availability ranges.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
---------
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* feat: Improving Booking Visibility at Month-End (#22770)
* remove first weeks and add last
* fix added last week
* prefetch availability of next month
* don't switch month
* On hover show month
* only show new UI in monthly view
* show month tooldtip only when needed
* show month on first day of month
* remove isFirstDayOfNextMonth
* fix prefetching next month
* fix datePicker tests
* preventMonthSwitching in monthly view
* add tests
* code clean up
* code clean up
* code clena up for ooo days
* push first day of month
* remove bg color for the month badge
* fix text colour
* remove not needed
* use object param
* revert: use object param
* use object param
* fix DatePicker tests
---------
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Sean Brydon <sean@cal.com>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
* chore: Refactor logs (#22824)
* Refactor logs
* Add specific info to log
* fix: Errors in org onboarding in some edge cases (#22711)
* Automatically enable migration of a team that conflicts with Orgs slug
* Allow changing the orgs slug and name if user goes back and changes it
* avoid crashing on some scenarios
* Revert "Allow changing the orgs slug and name if user goes back and changes it"
This reverts commit f8872b0116868d59757ef911c4940df79f93c6e0.
* fix: handle unpublished teams gracefully in org migration
- Change 'No oldSlug for team' from error to warning for unpublished teams
- Keep 'No slug for team' as error since org onboarding ensures teams have names
- Add test for migrating unpublished teams without oldSlug
- Add clarifying comments about when each condition can occur
* feat: enable PBAC checking on organization settings page (#22467)
* refactor: convert checkBookingLimits to class service with dependency injection (#22768)
* refactor: convert checkBookingLimits to class service with dependency injection
- Create CheckBookingLimitsService class following AvailableSlotsService pattern
- Add countBookingsByEventTypeAndDateRange method to BookingRepository
- Move direct prisma calls from service to repository layer
- Implement dependency injection with proper DI tokens and modules
- Update all usage points to use the new service through DI
- Maintain backward compatibility with error-throwing wrapper functions
- Update tests to use the new service pattern
- Resolve TODO comment in AvailableSlotsService for DI integration
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* chore: DI CheckBookingLimitsService in v2 slots service
* chore: bump libraries
* chore: create getCheckBookingLimitsService
* refactor: convert checkBookingAndDurationLimits to service class with DI
- Create CheckBookingAndDurationLimitsService class following DI pattern
- Add DI tokens and module for the new service
- Update booking-limits container to provide the new service
- Refactor handleNewBooking.ts to use service through DI
- Maintain backward compatibility with deprecated function export
- Preserve all existing functionality while improving code organization
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* chore: CheckBookingAndDurationLimitsService
* chore: bump platform libs
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
* fix: Return empty available days if error querying calendar (#22828)
* Return a busy block placeholder if calendar throws an error
* Refactor `getCalendarsEvents` to return an object with a success prop
* Throw error in `getBusyTimes` if failed to fetch calendar availability
* Return empty available days if error getting busy times
* yeet.
* Type fix
* Fix type error in getLuckyUsers
* Type fixes
* Type fix
* Type fix
* Fix test
* Fix test mocks
* Refactor calendars.service to use new calendarBusyTimesQuery
---------
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* chore: release v5.5.9
* include mobile layout (#22836)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
* test: fix handleInstantMeeting test with setupAndTeardown and proper mocking
- Add setupAndTeardown() for proper test environment setup
- Use mockNoTranslations() to fix translation function mocking
- Simplify NextApiRequest mock to resolve TypeScript errors
- Both test cases now pass successfully
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* fix typo
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Rajiv Sahal <sahalrajiv-extc@atharvacoe.ac.in>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
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>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Sean Brydon <sean@cal.com>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
* Return a busy block placeholder if calendar throws an error
* Refactor `getCalendarsEvents` to return an object with a success prop
* Throw error in `getBusyTimes` if failed to fetch calendar availability
* Return empty available days if error getting busy times
* yeet.
* Type fix
* Fix type error in getLuckyUsers
* Type fixes
* Type fix
* Type fix
* Fix test
* Fix test mocks
* Refactor calendars.service to use new calendarBusyTimesQuery
---------
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* refactor: convert checkBookingLimits to class service with dependency injection
- Create CheckBookingLimitsService class following AvailableSlotsService pattern
- Add countBookingsByEventTypeAndDateRange method to BookingRepository
- Move direct prisma calls from service to repository layer
- Implement dependency injection with proper DI tokens and modules
- Update all usage points to use the new service through DI
- Maintain backward compatibility with error-throwing wrapper functions
- Update tests to use the new service pattern
- Resolve TODO comment in AvailableSlotsService for DI integration
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* chore: DI CheckBookingLimitsService in v2 slots service
* chore: bump libraries
* chore: create getCheckBookingLimitsService
* refactor: convert checkBookingAndDurationLimits to service class with DI
- Create CheckBookingAndDurationLimitsService class following DI pattern
- Add DI tokens and module for the new service
- Update booking-limits container to provide the new service
- Refactor handleNewBooking.ts to use service through DI
- Maintain backward compatibility with deprecated function export
- Preserve all existing functionality while improving code organization
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* chore: CheckBookingAndDurationLimitsService
* chore: bump platform libs
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
* Automatically enable migration of a team that conflicts with Orgs slug
* Allow changing the orgs slug and name if user goes back and changes it
* avoid crashing on some scenarios
* Revert "Allow changing the orgs slug and name if user goes back and changes it"
This reverts commit f8872b0116868d59757ef911c4940df79f93c6e0.
* fix: handle unpublished teams gracefully in org migration
- Change 'No oldSlug for team' from error to warning for unpublished teams
- Keep 'No slug for team' as error since org onboarding ensures teams have names
- Add test for migrating unpublished teams without oldSlug
- Add clarifying comments about when each condition can occur
* remove first weeks and add last
* fix added last week
* prefetch availability of next month
* don't switch month
* On hover show month
* only show new UI in monthly view
* show month tooldtip only when needed
* show month on first day of month
* remove isFirstDayOfNextMonth
* fix prefetching next month
* fix datePicker tests
* preventMonthSwitching in monthly view
* add tests
* code clean up
* code clean up
* code clena up for ooo days
* push first day of month
* remove bg color for the month badge
* fix text colour
* remove not needed
* use object param
* revert: use object param
* use object param
* fix DatePicker tests
---------
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Sean Brydon <sean@cal.com>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
2025-07-30 16:20:16 +00:00
Alex van AndelGitHubcubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix: Adjacency issue when working hours connect over multiple days
* Add tests to validate the new merging of day end logic
* Update to correct annotation.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
* Implement subsequent date ranges for date overrides also
* The map needs to be updated on successful resolve.
* test: add failing test for overlapping ranges with same end time
Demonstrates bug where overlapping working hour ranges (6:00-10:00 and 8:00-10:00)
lose the earlier portion (6:00-8:00), showing only 8:00 and 9:00 slots
instead of all 4 slots (6:00, 7:00, 8:00, 9:00).
Related to Carina's comment on PR #21912.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* fix: properly merge overlapping ranges with same end time
Fixes bug where overlapping working hour ranges with the same end time
(e.g., 6:00-10:00 and 8:00-10:00) would lose the earlier portion of the
first range. The merging logic now correctly preserves the earliest
start time when ranges overlap and share the same end time.
This ensures all expected time slots are available (6:00, 7:00, 8:00, 9:00)
instead of losing the earlier slots (6:00, 7:00).
Resolves the issue identified in Carina's comment on PR #21912.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* perf: optimize overlapping range detection from O(n²) to O(n)
Replaces Object.keys().find() with Map-based lookup for ranges with same end time.
This optimization handles 2000+ date ranges efficiently, reducing complexity from
4M operations to linear time while maintaining the same merging behavior.
Performance improvement for high-volume event types with many availability ranges.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
---------
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* only make api call once access token is verified
* add date fns tz
* use date-fns to format ranges for platform
* update yarn.lock
* fix merge conflicts
* fix updating overrides for atoms
* add changesets
* feat: rename repository files to include Repository suffix
- Rename apiKey.ts to apiKeyRepository.ts
- Rename assignmentReason.ts to assignmentReasonRepository.ts
- Update all import statements to use new file names
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* feat: rename repository files to PrismaRepository with Prisma prefix
- Rename apiKeyRepository.ts to PrismaApiKeyRepository.ts
- Rename assignmentReasonRepository.ts to PrismaAssignmentReasonRepository.ts
- Update class names to PrismaApiKeyRepository and PrismaAssignmentReasonRepository
- Update all import statements and usages across 3 files
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-07-30 13:17:18 +02:00
Eunjae LeeGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Add userAvailability type
* Add user availability to return value of getUsersAvailability
* Log availabilitySnapshot when booking is created
* Type fix
* app initialization
* btcpay-calcom payment
* include logo and images
* resolve comments
* include USD and webhook cleaning
* currency display
* fix type error
* payment service create error
* type error fix
* icon update
* bot feedback update
* Remove console
* Remove currency suffix in price
* fix coderRabbit comment
* resolve extra comments
* Use repositories and declarative installation ocode for app
* use PrismaBookingPaymentRepository as well as fix UI view
* Avoid fetching booking just for title which is already passed to create fn in handlePayment
* fix type issues
* return 200 if payment is already processed
---------
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Omar López <zomars@me.com>