* refactor: optimize google's getAvailability with caching
Refactored the getAvailability method to improve readability and efficiency by extracting logic into helper methods for cache checking, calendar ID retrieval, and chunked API fetching. Added early cache lookup for selected calendar IDs, improved cache hit logging, and modularized the code for easier maintenance and future enhancements.
* Update CalendarService.test.ts
* Update CalendarService.ts
* Update CalendarService.test.ts
* Update CalendarService.ts
* Update CalendarService.test.ts
* Update CalendarService.ts
* Apply suggestion from @hbjORbj
Co-authored-by: Benny Joo <sldisek783@gmail.com>
---------
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Keith WilliamsGitHubcubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
* Revert "fix: atoms for local development (#22178)"
This reverts commit d74d99dde7.
* chore: remove comment
* feat: local dev scripts
* feat: local dev scripts
* feat: add formatPeriodStraightforward method for comprehensive date formatting
- Add new formatPeriodStraightforward method that always shows full date information
- Update DateRange interface to include formattedDateStraightforward field
- Modify getDateRanges to generate both formatted versions
- Add comprehensive unit tests for the new straightforward formatting
- Maintain backward compatibility with existing formatPeriod method
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* refactor: rename formatPeriodStraightforward to formatPeriodFull
- Rename method from formatPeriodStraightforward to formatPeriodFull
- Rename interface field from formattedDateStraightforward to formattedDateFull
- Update all test cases to use new method name
- All tests continue to pass with new naming
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* test: add comprehensive getDateRanges formatting comparison tests
- Add 7 new test cases that call getDateRanges directly
- Demonstrate side-by-side comparison of formattedDate vs formattedDateFull
- Cover daily, weekly, and monthly view formatting differences
- Include real-world usage examples showing practical benefits
- All 65 tests pass including new formatting comparison tests
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
* refactor: extract formattedDate arrays in getDateRanges comparison tests
- Refactor all 6 tests in 'getDateRanges - Formatting Comparison' suite
- Extract formattedDate and formattedDateFull arrays separately
- Use clean expect statements for easier visual review
- Remove startDate/endDate checks as requested
- Maintain all existing test scenarios and expected values
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: Benny Joo <sldisek783@gmail.com>
* fix: Process base64 avatar image (#22165)
* fix: process base64 avatar image
* better name
* more
* fix import
* Attempt to fix sharp dependency issue by upgrading next
---------
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-07-03 12:52:14 +01:00
devin-ai-integration[bot]GitHubalex@cal.com <me@alexvanandel.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>alex@cal.com <me@alexvanandel.com>
* fix: add explicit type annotation to CalComAdapter function
Resolves TS7056 error where inferred type exceeded maximum length
the compiler will serialize. Added custom CalComAdapterType type
annotation to provide explicit typing while preserving existing
functionality of the authentication adapter.
The custom type annotation matches the actual implementation structure
and resolves the TypeScript compilation error without breaking the
existing NextAuth adapter functionality.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* fix: replace any types with proper NextAuth Adapter typing
- Import Awaitable type from next-auth for proper async typing
- Define CalComAdapter type using Cal.com's actual Prisma types
- Remove all any types following TypeScript best practices
- Maintain compatibility with NextAuth's expected interface
- Resolves TS7056 compilation error with explicit typing
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: alex@cal.com <me@alexvanandel.com>
* perf: optimize filterRedundantDateRanges from O(n²) to O(n log n)
- Replace nested loop with optimized algorithm that leverages sorted ranges
- Add valueOf caching to avoid repeated .valueOf() calls (similar to PR #22076)
- Implement early termination for ranges that start after current range ends
- Handle identical ranges correctly by keeping first occurrence
- Add comprehensive test coverage with 8 new test cases covering:
- Multiple nested containments
- Identical ranges
- Same start/end time edge cases
- Invalid ranges (end before start)
- Large dataset performance (100 ranges)
- Touching ranges (adjacent ranges)
All 11 tests pass, maintaining behavioral compatibility while improving performance.
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* revert: remove valueOf caching optimization, keep O(n log n) algorithm
- Remove cached valueOf() variables to address user feedback
- Keep algorithmic optimization with early termination logic
- Maintain O(n log n) complexity through sorted range leveraging
- All 11 tests continue to pass with identical functionality
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: correct identical range handling in O(n log n) optimization
- Remove complex conditional logic that caused incorrect filtering of identical ranges
- Revert to simple containment check while preserving O(n log n) performance
- All 10 comprehensive unit tests now pass
- Maintains early termination optimization for performance gains
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: correct identical range handling to keep first occurrence
- Update test expectation from 0 to 1 for three identical ranges
- Modify implementation to keep first occurrence of identical ranges
- Maintain O(n log n) performance optimization
- All 10 unit tests now pass
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* feat: implement interval tree for O(n log n) worst-case complexity
- Replace nested loop with interval tree data structure
- Achieve O(n log n) worst-case complexity vs previous O(n²)
- Maintain identical range handling logic
- Preserve all existing test compatibility
- Performance improvements: 1.08x-2.46x speedup across scenarios
- Note: Enterprise pattern correctness issue requires investigation
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* feat: implement interval tree for O(n log n) worst-case complexity
- Replace segment tree with interval tree data structure
- Achieve O(n log n) worst-case complexity vs previous O(n²)
- Maintain identical range handling logic
- All unit tests (10/10) and integration tests (5/5) pass
- Type checking passes with no errors
- Still investigating enterprise pattern correctness issue (499 vs 379 results)
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* feat: implement interval tree for O(n log n) worst-case complexity
- Replace nested loop with interval tree data structure
- Achieve O(n log n) worst-case complexity vs previous O(n²)
- Maintain identical range handling logic
- Preserve all existing test compatibility
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: remove redundant sort in interval tree constructor
- Fix index misalignment issue causing correctness problems
- Remove duplicate sorting of nodes after mapping
- Maintain proper index references for containment queries
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* feat: implement interval tree for O(n log n) worst-case complexity
- Replace nested loop with interval tree data structure
- Achieve O(n log n) worst-case complexity vs previous O(n²)
- Maintain identical range handling logic
- Preserve all existing test compatibility
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: simplify interval tree logic to match original behavior
- Remove complex identical range handling logic
- Filter out any range that has containing intervals
- Achieve O(n log n) worst-case complexity with correct behavior
- Fix 'should handle three identical ranges' test failure
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* feat: implement interval tree for O(n log n) worst-case complexity
- Replace hybrid algorithm with interval tree data structure
- Achieve O(n log n) worst-case complexity vs previous O(n²)
- Fix identical range handling to keep first occurrence
- Maintain all existing test compatibility
- Update test expectation for three identical ranges to return 1 result
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: resolve TypeScript errors in interval tree implementation
- Add explicit type annotations for sort function parameters
- Use Array.from() for Map iteration to ensure TypeScript compatibility
- Maintain O(n log n) worst-case complexity with type safety
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* feat: implement interval tree for O(n log n) worst-case complexity
- Replace hybrid algorithm with pure interval tree data structure
- Achieve O(n log n) worst-case complexity vs previous O(n²)
- Maintain balanced tree structure for efficient containment queries
- Preserve all existing test compatibility
- Performance improvements: 1.12x-2.36x speedup depending on scenario
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* refactor: extract IntervalTree to generic reusable implementation
- Move IntervalTree and IntervalNode to separate packages/lib/intervalTree.ts
- Make IntervalTree generic with type parameter <T> and function parameters for start/end extraction
- Update filterRedundantDateRanges.ts to use generic IntervalTree implementation
- Maintain O(n log n) worst-case complexity and all existing functionality
- All unit tests (10/10) and integration tests (5/5) passing
Addresses GitHub comment from @keithwillcode requesting generic, reusable interval tree
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: correct containment logic in interval tree implementation
- Fix unconditional 'return false' that incorrectly filtered non-contained ranges
- Maintain O(n log n) complexity while ensuring correct containment behavior
- Add test case for overlapping but non-containing ranges
- Addresses cubic-dev-ai[bot] comment on PR #22093
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* test: add comprehensive test coverage for cubic-dev-ai bug scenario
- Add test for overlapping but non-containing ranges
- Add test for complex overlapping pattern that exposed the cubic-dev-ai bug
- These tests would have caught the unconditional 'return false;' logic error
- Addresses test coverage gap that allowed the bug to slip through
The original test suite focused on clear containment scenarios but missed
complex overlapping patterns where interval tree finds false positives
that need proper filtering logic.
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* refactor: separate IntervalTree structure from search algorithm
- Extract ContainmentSearchAlgorithm to separate class
- Make IntervalTree generic and reusable for different search patterns
- Maintain existing API compatibility for filterRedundantDateRanges
- Address GitHub feedback from @keithwillcode
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* refactor: make IntervalTree truly generic by moving node construction outside
- Extract createIntervalNodes helper function for date-specific node construction
- Remove start/end/maxEnd property handling from IntervalTree constructor
- Make IntervalTree accept pre-constructed nodes instead of raw items
- Move date-specific logic to filterRedundantDateRanges caller
- Addresses GitHub feedback from @keithwillcode about generic tree structure
- Maintains O(n log n) performance and all existing functionality
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* perf: eliminate redundant sorting in IntervalTree implementation
- Remove duplicate sort in IntervalTree constructor
- Sort interval nodes once in filterRedundantDateRanges after creation
- Addresses @Udit-takkar's performance feedback on PR #22093
- Maintains O(n log n) complexity while reducing constant factors
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: remove redundant sorting of interval nodes
- Eliminates unnecessary .sort() operation on interval nodes
- Nodes are already sorted from initial sortedRanges sort
- Addresses @keithwillcode's performance feedback
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Simplify conditional logic in check-label job output
- Remove redundant condition that caused race condition
- Maintain event filtering to only run when ready-for-e2e label is added
- Fixes issue where workflow failed despite script finding the label correctly
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Import extractUserContext function from @/lib/extract-user-context
- Extract user context from request in intercept method
- Add user context to logger output using spread operator
- Follow same pattern as exception filters for consistency
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: morgan@cal.com <morgan@cal.com>
* Revert "chore: add test for updateProfilePhotoGoogle (#22169)"
This reverts commit 67032ddaf1.
* Revert "fix: Process base64 avatar image (#22165)"
This reverts commit d8d8bc4d00.
* feat: adds timezone indicator on insights informing user that user settings timezone is used instead of browser timezone
* added i18 helper for translation
* chore: use entities.decodeHTML instead of custom decoder
* feat(insights): align TimezoneBadge with new timeZone prop flow
* chore
* chore: smaller icon
* do not escape value
---------
Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com>
Co-authored-by: Eunjae Lee <hey@eunjae.dev>
* refactor: destination calendars when rescheduling
* test: add unit test for collective evnet type
* chore: remove log
* chore: bump libraries
* fix: test
* chore: bump libraries
* fix: tests
* reset lock file
* Revert "reset lock file"
This reverts commit 4d48b678778b0daa19624338b302478e4655d200.
* Revert "Revert "reset lock file""
This reverts commit a7c3120c926a0d37a2b55a6ff8d2a070969ec0f4.
* regenerate lock file
---------
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
2025-07-01 12:07:48 +03:00
devin-ai-integration[bot]GitHubmorgan@cal.com <morgan@cal.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>morgan@cal.com <morgan@cal.com>Morgan
* feat: enhance API v2 exception filters with user context for improved Axiom observability
- Add extractUserContext utility to safely extract user/org/team context from request
- Enhance all 5 exception filters (HTTP, TRPC, Prisma, Zod, Calendar) with user context
- Include userId, userEmail, organizationId, teamId in Axiom logs when available
- Improve observability for debugging and monitoring authenticated requests
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* chore: update yarn.lock from lint-staged hooks
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* fix: use request.organization instead of request.organizationId
- Address GitHub comment feedback from ThyMinimalDev
- Extract organization ID from organization object for consistency
- Follows same pattern as user and team extraction
Co-Authored-By: morgan@cal.com <morgan@cal.com>
* fix: revert to using request.organizationId as requested in GitHub comment
- Change back from request.organization to request.organizationId
- This aligns with how auth strategies actually populate the request object
- Addresses GitHub comment from ThyMinimalDev
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>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>