e073cbd5ea54d59cd8a2bfa8e0287587d5aa692c
13
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b7340f7151 | feat: add upgrade banners for teams and organizations (#27650) | ||
|
|
512002aaef |
refactor: replace FeaturesRepository with DI-based feature repositories (#27200)
* refactor: replace FeaturesRepository with DI-based feature repositories Migrate from the legacy FeaturesRepository pattern to separate DI-based repositories: - Add checkIfFeatureIsEnabledGlobally to IFeatureRepository - Add getTeamsWithFeatureEnabled to ITeamFeatureRepository - Update CalendarSubscriptionService to use featureRepository, teamFeatureRepository, and userFeatureRepository - Update SelectedCalendarRepository.findNextSubscriptionBatch to filter by teamIds instead of featureIds - Update OnboardingPathService to use DI via getFeatureRepository() - Remove prisma parameter from OnboardingPathService callsites Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: update tests to use new DI-based feature repositories Update CalendarSubscriptionService and SelectedCalendarRepository tests to use the new separate repository interfaces: - featureRepository for global feature checks - teamFeatureRepository for team-level feature checks - userFeatureRepository for user-level feature checks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update API routes to use DI-based feature repositories Update cron and webhook routes to use the new separate repository interfaces instead of the combined FeaturesRepository. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove prisma arg from getGettingStartedPathWithParams call The OnboardingPathService method no longer requires a prisma argument as it now uses DI containers internally. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: update route tests to expect new DI-based feature repositories Update service instantiation tests to expect featureRepository, teamFeatureRepository, and userFeatureRepository instead of the old featuresRepository. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: optimize global feature check and add guard in checkForNewSubscriptions - Use targeted select for only `enabled` field in checkIfFeatureIsEnabledGlobally - Add global feature flag guard in checkForNewSubscriptions to avoid unnecessary DB queries and API calls when the cache feature is globally disabled Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * remove redundant comment --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
7e4d9e26c6 |
refactor: implement DI in team billing service and team billing data repository factory (#24803)
* Move TeamBillingRepositories * WIP refactor team internal billing service * Remove duplicate billing repository files * Remove logic check in repository for billing is enabled * Rename repository to `TeamBillingData` * Use repository factory in main service * Fix new import paths * Rename to * Ensure `IS_TEAM_BILLING_ENABLED` is of type boolean * Rename classes to TeamBillingService and TeamBillingServiceFactory * Implement DI in `BookingServiceFactory` * `TeamBillingService` use repository in `getOrgIfNeeded` * DI `isTeamBillingEnabled` to `TeamBillingServiceFactory` * Rename files for consistency * Return stub BillingRepository if billing is not enabled * Move Stripe billing service to service folder * Rename file * `StripeBillingService.getSubscriptionStatus` return `SubscriptionStatus` * Type fices in StripeBillingService * Type fix in `stubTeamBillingService` * DI the `BillingProviderService` into the `TeamBillingService` * Implement DI in `skipTeamTrials.handler` * Implement DI for team billing in `inviteMember.handler` * `skipTeamTrials.handler` use `team.isOrganization` * Implement DI for billing in `hasActiveTeamPlan.handler` * Type fixes * Implement DI in `bulkDeleteUsers.handler` * Implement `BillingProviderServiceFactory` in `updateProfile.handler` * Implment `BillingProviderServiceFactory` in `buyCredits.handler` * Fix import in `stripeCustomer.handler` * Add a constructor to `teamBillingServiceFactory` * Add DI to `PrismaTeamBillingRepository` * Add DI to `StripeBillingService` * Implement singleton in `BillingProviderServiceFactory` * Add DI folder and contents to billing folder * Use `getTeamBillingServiceFactory` in `inviteMember.handler` * Add `saveTeamBilling` method to `ITeamBillingService` * Implement DI in new team route * Implement DI in `teamService` * Implement DI in `OrganizationPaymentService` * Implement DI in `credit-service` * In `StripeBillingService` remove `static` from status methods * Implemnt DI in `_invoice.paid.org` * Refactor `hasActiveTeamPlan` to use `getTeamBillingFactory` * Refactor `skipTeamTrials` to use `getTeamBillingFactory` * Refactor `skipTeamTrials` to use `getTeamBillingServiceFactory` * `stripeCustomer.handler` to use `getBillingProviderService` * Remove old factories * Type fix * Remove unused factory * Refactor `updateProfile.handler` to use `getBillingProviderService` * Change name to `TeamBillingDataRepositoryFactory` * Type Prisma return in `prisma.module` * Type fix * Refactor `buyCredits.handler` to use `getBillingProviderService` * Refactor `credit-service` to use billing DI containers * Type fix * Add `getTeamBillingDataRepository` * Refactor `_invoice.paid.org` to use DI container * Refactor `_customer.subscription.deleted.team-plan` to use DI container * Refactor `calcomHandler` to use DI container * Refactor `getCustomerAndCheckoutSession` to use DI container * Refactor `verify-email` to use DI containers * Refactor `api/create/route` to use DI container * Refactor downgradeUsers to use DI container * Type fix * Clean up console.logs * Add await to `this.billingRepository.create` in `saveTeamBilling` Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Fix type errors * Address comments * fix: update tests to work with new DI pattern - Update teamBillingService.test.ts to properly inject DI dependencies - Remove unused billingModule import and mock - Fix import naming in teamService.integration-test.ts (remove unused rename) - Fix import path for TeamBillingPublishResponseStatus All tests now properly mock IBillingProviderService, ITeamBillingDataRepository, and IBillingRepository instead of using the old BillingRepositoryFactory pattern. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: add compatibility layer and env setup for unit tests - Add STRIPE_PRIVATE_KEY dummy value to vitest.config.ts to prevent DI module errors - Fix import paths in credit-service.test.ts (StripeBillingService, TeamBillingService) - Create compatibility barrel at packages/features/ee/billing/teams/index.ts for test mocking Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: update unit tests to mock DI container properly - Update teamService.test.ts to mock getTeamBillingServiceFactory() instead of TeamBilling.findAndInit - Update teamService.alternative.test.ts to mock DI container - Update credit-service.test.ts to mock getBillingProviderService() and use SubscriptionStatus enum values - Update OrganizationPaymentService.test.ts to mock DI container instead of direct StripeBillingService import - Remove all 'as any' type casting to comply with Cal.com coding standards - Fix unused variable warnings by prefixing with underscore All 53 tests now passing (16 + 1 + 30 + 6) Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: update remaining unit tests to use DI pattern - Fix StripeBillingService.test.ts to inject mock Stripe client directly - Fix teamBillingFactory.test.ts to mock getTeamBillingServiceFactory() from DI container - Fix skipTeamTrials.test.ts to mock DI container and use SubscriptionStatus enum All 11 previously failing tests now pass (5 + 5 + 1) Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Undo changes made to Prisma module * fix: address test-related PR comments - Fix OrganizationPaymentService.test.ts mock path from @calcom/ee to @calcom/features/ee - Refactor teamBillingFactory.test.ts to test real factory logic instead of mocking container - Remove duplicate teamBillingService.test..ts file with incorrect double-dot filename All three test files now pass successfully with proper DI patterns. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Address feedback * fix: update teamService integration test to mock new DI factory pattern Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * refactor: remove duplicate imports in credit-service.test.ts Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Remove unused index file * `getBySubscriptionId` to return team or null * Address feedback * Merge fix * Refactor file names * fix: correct mockStripe variable name to stripeMock in StripeBillingService.test.ts Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * refactor: update internal-team-billing.test.ts to use new DI structure with TeamBillingService - Replace InternalTeamBilling with TeamBillingService - Use constructor injection with mock dependencies instead of factory pattern - Remove BillingRepositoryFactory mock and import - Update all test cases to use mockBillingProviderService, mockTeamBillingDataRepository, and mockBillingRepository - Simplify saveTeamBilling tests to focus on repository.create calls - All 11 tests now pass with the new DI structure Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: update createWithPaymentIntent.handler.test.ts to mock DI container's getBillingProviderService - OrganizationPaymentService now uses getBillingProviderService() from DI container - Test was mocking @calcom/features/ee/payments/server/stripe directly, which no longer works - Added mock for @calcom/features/ee/billing/di/containers/Billing module - Mock returns fake billing provider that delegates to mockSharedStripe - Preserves all existing test assertions and helpers - Fixed lint error by prefixing unused lastCreatedSessionId with underscore - All 11 tests now pass (1 skipped as expected) Co-Authored-By: joe@cal.com <j.auyeung419@gmail.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> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> |
||
|
|
787828d0ca |
feat: Toggle auto adding users to an org if they signup without an invite (#25051)
* Remove auto adding users to an org * Update tests * Fix tests * fix: Update organization invitation E2E tests to not expect auto-accept before signup - Changed isMemberShipAccepted expectations from true to false before signup - Users with emails matching orgAutoAcceptEmail are no longer auto-accepted - They must explicitly accept the invitation after signup - Fixed lint warnings for unused parameters Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: Update E2E tests to expect pending membership after signup without auto-accept Since auto-accept functionality was removed, users with emails matching orgAutoAcceptEmail are no longer automatically accepted into organizations after signup. They remain in pending state until explicitly accepted. Updated assertions in: - 'nonexisting user is invited to Org' test - 'nonexisting user is invited to a team inside organization' test Both tests now correctly expect isMemberShipAccepted: false after signup. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Restore `verify-email` and tests from `main` * Add `orgAutoJoinOnSignup` to `organizationSettings` * Update `OrganizationRepository.findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail` to find orgs where `orgAutoJoinOnSignup` is true * `organization.update` lint fix * `organization.update` to handle `orgAutoJoinOnSignup` * Create toggle for `orgAutoJoinOnSignup` * test: Add comprehensive tests for orgAutoJoinOnSignup functionality - Update existing test to expect null instead of error when multiple orgs match - Add test for when orgAutoJoinOnSignup is false (should return null) - Add test for when orgAutoJoinOnSignup is true (should return org) - Add test for default behavior (orgAutoJoinOnSignup defaults to true) These tests verify that the new orgAutoJoinOnSignup setting correctly controls whether users are automatically added to organizations during email verification. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Type fix * e2e: invited users should be accepted after signup (address cubic r2511916791) Reverted post-signup isMemberShipAccepted assertions from false to true for explicit invite scenarios. When users are explicitly invited to an org/team and complete signup via invite link, their membership should be accepted. This is distinct from auto-join by domain (controlled by orgAutoJoinOnSignup), which only affects users who sign up without an invite but match the org's email domain. Backend sets membership.accepted = true on invite completion in: packages/features/auth/signup/utils/createOrUpdateMemberships.ts:61,67,77,83 Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Fix API V2 build --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
bc665cbeab |
fix: APIV2 team membership - Member not getting added to event-type automatically (#24780)
* fix: APIV2 team membership addition * feat: Add trimming for email domain and orgAutoAcceptEmail in auto-accept logic - Trim whitespace from both user email domain and orgAutoAcceptEmail - Ensures consistent matching even with accidental whitespace - Addresses feedback from PR review Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * simplify * feat: Use shared OrganizationMembershipService in TRPC for consistent auto-accept logic - Create OrganizationMembershipService.container.ts for DI in TRPC - Update getOrgConnectionInfo to apply trimming + case-insensitive comparison - Precompute auto-accept decisions in createNewUsersConnectToOrgIfExists using the service - Use service in handleNewUsersInvites for consistent auto-accept determination - Ensures both API v2 and TRPC paths use identical trimming and normalization logic Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * Revert "feat: Use shared OrganizationMembershipService in TRPC for consistent auto-accept logic" This reverts commit 0b2bd28b6e32e8c1d3dea139ca8ff9cbf402ac00. * refactor: Unify OrganizationRepository and remove duplicate PrismaOrganizationRepository (#24869) * refactor: Convert OrganizationRepository from static to instance methods - Add constructor accepting deps object with prismaClient - Convert all static methods to instance methods - Add getOrganizationAutoAcceptSettings method - Create singleton instance export in repository barrel file - Update API v2 OrganizationsRepository to extend from OrganizationRepository - Update all call sites to use singleton instance - Add platform-libraries organizations.ts export - Fix mock imports to use repository barrel - Fix unsafe optional chaining in next-auth-options.ts - Fix any types in test files with proper type inference Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Update all imports to use OrganizationRepository barrel export - Update imports from direct OrganizationRepository file to barrel export - This ensures mocks work correctly in tests - Fixes 202 failing tests related to organizationRepository mock Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Update test mocks to use partial mock pattern - Convert organizationMock to partial mock that preserves real class - Add proper prisma mocks to failing test files - Remove old OrganizationRepository mocks from test files - This fixes test failures related to mock interception Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Export mocked singleton and update tests to use it directly - Export mockedSingleton as organizationRepositoryMock from organizationMock - Update delegationCredential.test.ts to import and use the exported mock - This fixes 'vi.mocked(...).mockResolvedValue is not a function' errors Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Use platform-libraries import for API v2 OrganizationRepository API v2 should import shared features through @calcom/platform-libraries instead of directly from @calcom/features to maintain proper architectural boundaries and packaging/licensing separation. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * refactor: Implement DI pattern for OrganizationRepository - Create OrganizationRepository.module.ts and .container.ts for DI - Replace singleton pattern with getOrganizationRepository() across 20 files - Update platform-libraries to export getOrganizationRepository - Delete duplicate PrismaOrganizationRepository.ts - Remove singleton export file (repositories/index.ts) - Update test mocks to use DI container pattern - All type checks and unit tests passing Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Implement read/write client separation in OrganizationRepository - Updated OrganizationRepository constructor to accept optional prismaWriteClient parameter - Routed all write operations (create, update) through prismaWrite client - Routed all read operations (find, get) through prismaRead client - Updated API v2 OrganizationsRepository to pass both dbRead.prisma and dbWrite.prisma to super() - Optimized getOrganizationRepository() calls by storing in local variables to avoid repeated function calls - This fixes the critical issue where API v2 was passing read-only client to base class with write methods Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Fix mock setup and optimize getOrganizationRepository() calls - Fixed verify-email.test.ts mock to return mocked repository instance instead of scenario helper object - Added mockReset to organizationMock.ts beforeEach to properly reset mock implementations between tests - Added local variables in page.tsx to store getOrganizationRepository() result for consistency This fixes the issue where getOrganizationRepository() was returning organizationScenarios.organizationRepository (scenario helper) instead of the actual mocked repository instance, causing findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail to be undefined. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * refactor: Simplify OrganizationRepository to use single prismaClient - Updated base OrganizationRepository constructor to accept only { prismaClient } instead of { prismaClient, prismaWriteClient? } - Replaced this.prismaRead and this.prismaWrite with single this.prismaClient property - Updated API v2 OrganizationsRepository to pass only dbWrite.prisma as prismaClient - Removed unused PrismaReadService import from API v2 - All read and write operations now use the same client instance This simplifies the architecture as requested - API v2 uses write client for all operations, and apps/web uses the client from DI container. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: Match OrganizationsRepository.findById signature with base class The findById method in OrganizationsRepository was using a different signature than the base OrganizationRepository class, causing type errors in CI. Changed from: findById(organizationId: number) Changed to: findById({ id }: { id: number }) This matches the base class signature and resolves the CI unit test failures. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Update all findById call sites to use object parameter Fixed 6 call sites in API v2 that were calling findById with a number instead of the required { id: number } object parameter: - is-org.guard.ts - is-admin-api-enabled.guard.ts - is-webhook-in-org.guard.ts - organizations.service.ts - managed-organizations.service.ts (2 call sites) This resolves the API v2 build failure caused by the signature change in OrganizationsRepository.findById to match the base class. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: Remove redundant findById override from OrganizationsRepository The findById method was duplicating the base class OrganizationRepository implementation. Both methods had identical logic (filtering by isOrganization: true), so the override was unnecessary. Since OrganizationsRepository extends OrganizationRepository and passes dbWrite.prisma to the base constructor, the base class method already provides the exact same functionality. This resolves the API v2 build failure by eliminating the duplicate method that was causing conflicts. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * Remove unncessary changes * Store in variable * Revert "Remove unncessary changes" This reverts commit af9351786a21616c9508c441191c17f2374fb2cc. * Revert dbRead/dbWrite changes * Add organizations library to tsconfig.json --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> |
||
|
|
fa884e8516 |
chore: Onboarding path service plus redirects (#24679)
* i18n * WIP icon stuff * More icon work * More gradient tuning * Mvoe plan-icon to planicon.tsx * Fix cubic suggestion * Fix darkmode icon and gradients * Fix type error * Onboarding path service * Update usages of onboarding path and getting started hook |
||
|
|
6923b97cd2 |
feat: upgrade Prisma to 6.16.0 with no-rust engine (#23816)
* feat: upgrade Prisma to 6.16.0 with no-rust engine - Update Prisma packages to 6.16.0 - Add PostgreSQL adapter dependency - Configure engineType: 'client' and provider: 'prisma-client' in schema - Update Prisma client instantiation with PostgreSQL adapter - Remove binaryTargets from generators (not needed with library engine) - Fix schema view issue by removing @id decorator from BookingTimeStatusDenormalized - Fix ESLint warning by removing non-null assertion Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Web app running but types wrecked * web app running but build and type issues * Removed the connection pool * Fixed zod type issue * Fixed types in booking reference extension * Fixed test issues * Type checks passing it seems * Using cjs as moduleFormat * Fixing Prisma undefined * fix: update prismock initialization for Prisma 6.16 compatibility - Add @prisma/internals dependency for getDMMF() - Restructure prismock initialization to use createPrismock() with DMMF - Create Proxy that's returned from mock factory for proper spy support - Fixes 89 failing unit tests with 'Cannot read properties of undefined (reading datamodel)' error - Based on workaround from prismock issue #1482 All unit tests now pass (375 test files, 3323 tests passed) Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: cast serviceAccountKey to Prisma.InputJsonValue in bookingScenario.ts - Apply type cast at lines 2493 and 2535 - Fixes type errors from Prisma 6.16 upgrade - Follows established pattern from delegationCredential.ts - Add eslint-disable for pre-existing any types - Rename unused appStoreLookupKey parameter to satisfy lint - All 3323 tests passing Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * chore: remove whitespace-only lines from bookingScenario.ts - Remove blank lines where eslint-disable comments were replaced - Cleanup from pre-commit hook formatting Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Update is-prisma-available-check.ts * fix: remove datasources config when using Prisma Driver Adapters - Update customPrisma to create new adapter when datasources URL is provided - Remove datasources config from API v2 Prisma services (already in adapter) - Fixes 'Custom datasource configuration is not compatible with Prisma Driver Adapters' error Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use Pool instances for PrismaPg adapters in index.ts - Create Pool instance before passing to PrismaPg adapter - Update customPrisma to create Pool for custom connection strings - Matches working pattern from API v2 services - Fixes 'Invalid `prisma.$queryRawUnsafe()` invocation' error Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Not using queryRawUnsafe * Trying anything at this point * Make sure the DB is ready first * Don't auto run migrations in CI mode * Revert "Make sure the DB is ready first" This reverts commit 2b20bd45c974f3d7e07d8b904bc7fcdae37cce03. * Dynamic import of prisma * Commenting where it seems to break * Backwards compatability for API v2 * fix: add explicit type annotations for map callbacks in API v2 - Add type annotation for map parameter in memberships.repository.ts - Add type annotation for map parameter in stripe.service.ts - Fixes implicit 'any' type errors from stricter Prisma 6.16.0 type inference Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add explicit type annotations for API v2 map callbacks - users.repository.ts:292: add Profile & { user: User } type - memberships.service.ts:19-20: add Membership type to filter callbacks Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add explicit type annotation for attributeToUser in organizations-users.repository.ts - organizations-users.repository.ts:63: add AttributeToUser with nested relations type Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add explicit Membership type annotations in teams.repository.ts Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use API v2 dedicated Prisma client to support adapter in PrismaClientOptions Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Running API v2 build commands together so they all get the space size var * Fixing Maximum call depth exceeded error * fixed type issues * Trying to make the seed more stable * Revert "Trying to make the seed more stable" This reverts commit 1fd4495e6af7acd7981cda7dedec3168979b0e9d. * Fixed path to prisma client * Fixed type check * Fix eslint warnings * fix: externalize @prisma/adapter-pg and pg in platform-libraries Vite config - Add @prisma/adapter-pg and pg to external dependencies list - Add corresponding globals for these packages - Fix Prisma client aliases to point to packages/prisma/client instead of node_modules - Add Node.js resolve conditions to prefer Node.js exports - Keep commonjsOptions.include for proper CommonJS transformation - Add eslint-disable for __dirname in Vite config file - Remove problematic prettier/prettier eslint comment This fixes the 'Extensions.defineExtension is unable to run in this browser environment' error when running yarn generate-swagger in apps/api/v2 after upgrading to Prisma v6.16 with the no-rust engine approach. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: update Prisma imports in API v2 services to use package path - Change imports from '../../../generated/prisma/client' to '@calcom/prisma/client' - Fixes CI error: Cannot find module '../../../../../packages/prisma/generated/prisma/client.ts' - Aligns with backwards compatibility re-export structure after Prisma v6.16 upgrade Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: remove .ts extension from Prisma client path mapping in tsconfig - Remove file extension from @calcom/prisma/client path mapping - Fixes runtime error: Cannot find module '../../../../../packages/prisma/generated/prisma/client.ts' - TypeScript path mappings should not include file extensions per best practices - Allows Node.js to correctly resolve to .js files at runtime Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: resolve Prisma 6.16.0 type incompatibilities in bookingScenario tests - Changed InputPayment.data type from PaymentData to Prisma.InputJsonValue - Changed createCredentials key parameter from JsonValue to InputJsonValue - Removed unused PaymentData type definition - Resolves type errors at lines 709 and 1088 without using 'as any' casts Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: remove non-existent Watchlist fields from test fixtures - Remove createdById from isLockedOrBlocked.test.ts (lines 15, 20) - Remove severity and createdById from _post.test.ts (line 110) - These fields don't exist in Watchlist model schema after Prisma 6.16.0 upgrade - Resolves TS2353 errors without using 'as any' casts Relates to PR #23816 Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: api v2 imports generated prisma and platform libraries * fix: resolve type errors from Prisma 6.16 upgrade - Add missing markdownToSafeHTML import in AppCard.tsx - Fix organizationId null handling in fresh-booking.test.ts - Remove non-existent createdById field from Watchlist test utils Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Put back some external rollups * Added back the resolve conditions * Stop using Pool directly * chore: remove prisma bookingReferenceExtension and update calls * fix: organizations-admin-not-team-member-event-types.e2e-spec.ts * chore: bring back POOL in api v2 prisma clients * chore: remove Pool but await connect * fixup! chore: remove Pool but await connect * chore: bring back Pool on all clients * chore: end pool manually * chore: test with pool max 1 * chore: e2e test prisma max pool of 1 connection * chore: give more control over pool for prisma module with env * remove pool from base prisma client * chore: prisma client in libraries use pool * Fixed types * chore: log pool events and improve pooling * Fixing some types and tests * Changing the parsing of USE_POOL * fix: ensure Prisma client is connected before seeding to prevent transaction errors Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * chore: adjust pools * chore: add process.env.USE_POOL to libraries vite config * fix: v1 _patch reference check bookingRef on the booking find * fix: v1 get references deleted null for system admin * test: add integration tests for bookingReference soft-delete behavior - Add bookingReference.integration-test.ts to test repository methods - Add handleDeleteCredential.integration-test.ts to test credential deletion cascade - Add booking-references.integration-test.ts for API v1 integration tests - All tests verify soft-delete behavior without using mocks - Tests use real database operations to ensure soft-deleted records persist - Cover scenarios: replacing references, credential deletion, querying with filters Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: convert booking-references test to actual API endpoint testing - Modified _get.ts to export handler function for testing - Refactored integration test to call API handler instead of directly testing Prisma - Added timestamps to test data to avoid conflicts - Tests now verify API layer correctly filters soft-deleted references - All 4 tests passing Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add explicit prisma.$connect() call to seed-insights script With Prisma 6.16 and the PostgreSQL adapter, scripts need to explicitly call $connect() before running database operations to ensure the connection pool is properly initialized. This prevents 'Transaction already closed' errors. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add $connect() to main() execution in seed-insights Both main() and createPerformanceData() entry points need explicit prisma.$connect() calls with the Prisma 6.16 PostgreSQL adapter. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: always use connection pool for Prisma PostgreSQL adapter Enable connection pooling by default for the Prisma adapter to prevent transaction state issues during seed operations. Without a pool, each operation creates a new connection which can lead to 'Transaction already closed' errors during heavy database operations like seeding. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Revert "fix: always use connection pool for Prisma PostgreSQL adapter" This reverts commit 6724bb08e42bc0a94846069de83b04db0aeb8e8b. * fix: enable connection pool for db-seed in cache-db action Set USE_POOL=true when running yarn db-seed to use connection pooling with the Prisma PostgreSQL adapter. This prevents 'Transaction already closed' errors during seeding by maintaining stable database connections. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add safety check for undefined ownerForEvent in seed script Prevent 'Cannot read properties of undefined' error when orgMembersInDBWithProfileId is empty. This can happen if organization members fail to create or when there's a duplicate constraint violation causing early return. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: v1 _patch reference check bookingRef * fix: increase pool size and add timeout settings to prevent transaction errors - Increase max connections from 5 to 10 - Add connectionTimeoutMillis: 30000 (30 seconds) - Add statement_timeout: 60000 (60 seconds) These settings help prevent 'Unknown transaction status' errors during heavy database operations like seeding by giving transactions more time to complete and allowing more concurrent connections. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Revert "fix: increase pool size and add timeout settings to prevent transaction errors" This reverts commit 148264f1f1861dfb09a082937a3e2b49e78fc41a. * fix: remove standalone execution in seed-app-store to prevent premature disconnect The seed-app-store.ts file had a standalone main() call at the bottom that would execute immediately when imported, including a prisma.$disconnect() in its .finally() block. This caused issues because: 1. seed.ts imports and calls mainAppStore() 2. The import triggers the standalone main() execution 3. This standalone execution disconnects prisma after completion 4. seed.ts then tries to call mainHugeEventTypesSeed() but prisma is disconnected 5. This leads to 'Unknown transaction status' errors Fixed by removing the standalone execution since mainAppStore() is already called programmatically from seed.ts which manages the connection lifecycle. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use require.main check to prevent premature disconnect when imported Added require.main === module check so seed-app-store.ts: - Runs standalone with proper connection management when executed directly via 'yarn seed-app-store' or 'ts-node seed-app-store.ts' - Does NOT run standalone when imported as a module by seed.ts, preventing premature prisma disconnect This fixes 'Unknown transaction status' errors while maintaining backward compatibility for direct execution. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: seed apps before creating users to prevent foreign key constraint violation Reordered seeding operations to call mainAppStore() before main() because: - main() creates users with credentials that reference apps via appId foreign key - mainAppStore() seeds the App table with app records - Apps must exist before credentials can reference them This fixes the 'Foreign key constraint violated on Credential_appId_fkey' error that occurred when creating credentials before the apps they reference existed. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Removing functional changes of deleted: null * Apply suggestion from @keithwillcode * refactor: move seedAppData call to bottom of main() in seed.ts Moved seedAppData() call from seed-app-store.ts to the bottom of main() in seed.ts to ensure the 'pro' user is created before attempting to create routing form data for them. Changes: - Exported seedAppData function from seed-app-store.ts - Removed seedAppData() call from the main() export in seed-app-store.ts - Added seedAppData() call at the bottom of main() in seed.ts - Updated standalone execution in seed-app-store.ts to still call seedAppData() when run directly via 'yarn seed-app-store' This ensures proper ordering: apps seeded → users created → routing form data created for existing users. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: move routing form seeding from seed-app-store.ts to seed.ts Moved the routing form seeding logic (previously in seedAppData function) from seed-app-store.ts to be inline at the bottom of main() in seed.ts. This ensures the 'pro' user is created before attempting to create routing form data for them. Changes: - Removed seedAppData function and seededForm export from seed-app-store.ts - Removed import of seedAppData from seed.ts - Added routing form seeding logic inline at bottom of main() in seed.ts Seeding order: apps → users (including 'pro') → routing forms Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add deleted: null filter to bookingReference update operations - Add deleted: null filter to API v1 PATCH endpoint to prevent updating soft-deleted booking references - Add deleted: null filter to DailyVideo updateMeetingTokenIfExpired and setEnableRecordingUIAndUserIdForOrganizer - Add comprehensive test coverage for PATCH endpoint soft-delete behavior - Tests verify that soft-deleted booking references cannot be updated - Tests verify that only active booking references can be updated successfully Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * revert: remove deleted: null filters to preserve existing functionality Per @keithwillcode's feedback, reverting the soft-delete filtering changes to preserve existing functionality in this PR. This PR should focus only on the Prisma upgrade itself. - Reverted API v1 PATCH endpoint change - Reverted DailyVideo adapter changes (updateMeetingTokenIfExpired and setEnableRecordingUIAndUserIdForOrganizer) - Removed test file that was added for soft-delete behavior testing Addresses comments: - https://github.com/calcom/cal.com/pull/23816#discussion_r2448854197 - https://github.com/calcom/cal.com/pull/23816#discussion_r2448860594 - https://github.com/calcom/cal.com/pull/23816#discussion_r2448860833 Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * test: restore and update booking reference tests to match existing functionality Updated tests to verify existing behavior where PATCH endpoint can update booking references regardless of their deleted status. This matches the current implementation after reverting the deleted: null filters. Changes: - Restored test file that was previously deleted - Updated PATCH tests to expect successful updates of soft-deleted references - Renamed test suite to 'Existing functionality' to clarify intent - Tests now verify that the PATCH endpoint preserves existing behavior Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * test: rename booking-references test to integration-test The test requires a database connection and should run in the integration test job, not the unit test job. Renamed from .test.ts to .integration-test.ts to match the repository's testing conventions. 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: cal.com <morgan@cal.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> |
||
|
|
e91bf53d80 |
refactor: Remove circular deps between @calcom/lib and @calcom/features [2] (#24438)
* move SystemField to features * migrate workflow service * merge two tests for team repository * update imports and migrate team repository * migrate delegation credential repository * migrate credential repository * migrate entityPermissionUtils * migrate hashedLink service and repository * migrate membership service * update imports * remove file * migrate buildEventUrlFromBooking * migrate getAllUserBookings to features * update imports * update organizationMock * migrate slots * migrate date-ranges to schedules dir * migrate getAggregatedAvailability * fix * refactor * migrate useCreateEventType hook to features * migrate assignValueToUser * migrate validateUsername to auth features * migrate system field back to lib * migrate getLabelValueMapFromResponses back to lib * update imports * use relative path * fix type checks * fix * fix * fix tests * update gh codeowners * fix * fix |
||
|
|
b312955838 |
feat: Add subscription start, trial end, and dates to billing tables (#24408)
* Add subscription start, trial end, and end dates to db * Add subscription start, trial end, and end date to db * Write subscription start date on new team subscriptions * Write subscription start date for new orgs * Fix typo in stripe billing service file (billling -> billing) * Use `StripeBillingService.extractSubscriptionDates` * Remove comments * Address comment * Fix typo in file import * Fix typo in file import * Add missing SubscriptionStatus enum values - Add INCOMPLETE, INCOMPLETE_EXPIRED, UNPAID, PAUSED enum values - These values are referenced in stripe-billing-service.ts status mapping - Fixes type errors in billing-related code Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
ff38d6c7db |
refactor: Remove circular deps between @calcom/lib and @calcom/features [1] (#24399)
* add eslint config * migrate autoLock to features * migrate teamService to features * migrate userCreationService * migrate insights services to features * migrate ProfileRepository * update imports * migrate filter segmen tests * migrate filter segment repository * migrate getBusyTimes * migrate getLocaleFromRequest * refactor csvUtils * make filename clearer * migrate getLuckyUser integration test * migrate autoLock test to features * wip * refactors * migrate useBookerUrl * migrate more * wip * Migrate eventTypeRepository * membership repository * update imports * update imports * migrate * move organization repository * update imports * update imports * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix tests * fix type checks * fix * fix * migrate * update imports * fix tests * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix |
||
|
|
c28eb90928 |
chore: Upgrade prisma to 6.7.0 (#21264)
* chore: Upgrade prisma to 6.7.0 * Build fixes * type fixes Signed-off-by: Omar López <zomars@me.com> * Update schema.prisma * Patching * Revert "Update schema.prisma" This reverts commit 47d8618bf89ef4d007b30084df766f17281e21a1. * Revert "Patching" This reverts commit a1d2e3040e71690a44d4324db95d73b4d68c6adb. * Revert schema changes Signed-off-by: Omar López <zomars@me.com> * WIP Signed-off-by: Omar López <zomars@me.com> * Update getPublicEvent.ts * Update imports Signed-off-by: Omar López <zomars@me.com> * Update gitignore Signed-off-by: Omar López <zomars@me.com> * update remaining imports Signed-off-by: Omar López <zomars@me.com> * Delete .cursor/config.json * Discard changes to packages/features/eventtypes/lib/getPublicEvent.ts * Update _get.ts * Update user.ts * Update .gitignore * update * Update WorkflowStepContainer.tsx * Update next-auth-custom-adapter.ts * Update getPublicEvent.ts * Update workflow.ts * Update next-auth-custom-adapter.ts * Update next-auth-options.ts * Update bookingScenario.ts * fix missing imports * upgrades prismock Signed-off-by: Omar López <zomars@me.com> * patches prismock Signed-off-by: Omar López <zomars@me.com> * Update reschedule.test.ts * Update prisma.ts * patch prismock Signed-off-by: Omar López <zomars@me.com> * fix enums imports Signed-off-by: Omar López <zomars@me.com> * Revert "Update prisma.ts" This reverts commit 64edcf8db54171ff4456c209d563b5d431d99619. * Revert "patch prismock" This reverts commit e95819113dc9d88e7130947aa120cd42710977c8. * fix patch * Fix test that overrun the boundary, it shouldn't test too much * Move prisma import to changeSMSLockState * Bring back broken test without illegal imports * Merge with main and fix filter hosts by same round robin host * Fixed buildDryRunBooking fn tests * Fix and move ooo create or update handler test * Fix packages/features/eventtypes/lib/isCurrentlyAvailable.test.ts * Fix packages/trpc/server/routers/viewer/organizations/listMembers.handler.test.ts * Mock @calcom/prisma * Fix: verify-email.test.ts * fix: Moved WebhookService test and fixed default import mock * Fix: Added missing prisma mock, handleNewBooking uses that of course * We're not testing createContext here * fix: Prisma mock fix for listMembers.test.ts * More fixes to broken testcases * Forgot to remove borked test * Prevent the need to mock a lot of dependencies by moving out buildBaseWhereCondition to its own file * Temporarily skip getCalendarEvents, needs a rewrite * Fix: turns out you can access protected in testcases * fix further mocks * Added packages/features/insights/server/buildBaseWhereCondition.ts, types * Always great to have a mock and then not use it * And one less again. * fix: confirm.handler.test, didn't mock prisma * fix: Address minor nit by @eunjae & fix ImpersonationProvider test * Updated isPrismaAvailableCheck that doesn't crash on import * fix: Get Prisma directly from the client, it usually involves the Validator and does not need 'local' inclusion * Add zod-prisma-types without the generator enabled (commented out) * Uncomment and see what happens * Change method of import as imports did not work in Input Schemas * Remove custom 'zod' booking model, it does not belong with Prisma * Fix all other global Model imports * Rewrite most schema includes AND remove barrel file * Add bookingCreateBodySchema to features/bookings * Flurry of type fixes for compatibility with new zod gen * Refactor out the custom prisma type createEventTypeInput * Work around nullable eventTypeLocations * HandlePayment type fix * More fixes, final fix remaining is CompleteEventType * Should fix a bunch more booking related type errors * Missed one * Some props missing from BookingCreateBodySchema * Fix location type in handleChildrenEventTypes * Little bit hacky imo but it works * Final type error \o/ * Forgot to include Prisma * Do not include zod-utils in booker/types * Oops, was already including Booker/types * Fix membership type, also disallow updating createdAt/updatedAt, make part of patch/post * Fix api v1 type errors * Fix EventTypeDescription typings * Remove getParserWithGeneric, use userBodySchema with UserSchema * use centralized timeZoneSchema * Implement feedback by @zomars * Couple of WIP pushes * Fix tests * Type fixes in `handleChildrenEventTypes` test * Try and parse metadata before use * Change zod-prisma-types configuration for optimal performance * Fix prisma validator error in `prisma/selects/credential` * Disable seperate relations model, hits a bug * Import absolute - this makes rollup work in @platform/libraries * Attempt at removing resolutions override * Refactor using `Prisma.validator` to `satisfies` * Build atoms using @calcom/prisma/client * Build atoms using @calcom/prisma/client * fixes * Update eventTypeSelect.ts * Adjust `eventTypeMetaDataSchemaWithUntypedApps` from `unknown` to `record(any)` * `EventTypeDescription` rely on `descriptionAsSafeHTML` instead of `description` * Add `seatsPerTimeSlot` to event type public select * Fix typing in `users-public-view` getServerSide props * Add missing `schedulingType` to prop * chore: bump platform libraries * Function return type is illegal, not sure how this passed eslint (#21567) * Merged with main * Update updateTokenObject.ts * Update handleResponse.ts * Update index.ts * Update handleChildrenEventTypes.ts * Update booking-idempotency-key.ts * Update WebhookService.test.ts * Update events.test.ts * Update queued-response.test.ts * Update events.test.ts * Update getRoutedUrl.test.ts * fix: type checks Signed-off-by: Omar López <zomars@me.com> * fixes Signed-off-by: Omar López <zomars@me.com> * chore: bump platform libraries * Update yarn.lock * more fixes Signed-off-by: Omar López <zomars@me.com> * fixes Signed-off-by: Omar López <zomars@me.com> * biuld fixes * chore: bump platform libraries * Update conferencing.repository.ts * Update conferencing.repository.ts * Update getCalendarsEvents.test.ts * Update vite.config.js * chore: bump platform libraries * Update users.ts * Discard changes to docs/api-reference/v2/openapi.json * Update vite.config.ts * updated platform libraries * Update get.handler.test.ts * Update get.handler.test.ts * Update schema.prisma * Discard changes to docs/api-reference/v2/openapi.json * Update next-auth-custom-adapter.ts * Update team.ts * Flurry of type fixes * Fix majority of insight related type errors * Type fixes for unlink of account * Make user nullable again * Fixed a bunch of unit tests and one type error * Attempted mock fix * Attempted fix for Attribute type * Ensure default import becomes prisma, but not direct usage * Import default as prisma in prisma.module * Add attributeOption to attribute type * Fix calcom/prisma mock * Refactor Prisma client imports to @calcom/prisma/client Updated all imports from '@prisma/client' to '@calcom/prisma/client' across tests and repository files for consistency and to use the correct Prisma client package. This change improves maintainability and ensures the correct client is referenced throughout the codebase. * Undo removal of max-warnings=0 to get main to merge * Remove unit tests for e2e fixtures, provide new prisma mock * Mock @calcom/prisma in event manager * Mock @calcom/prisma in event manager * Add correct format even with --no-verify * Mock prisma in CalendarManager * Add mock for permission-check.service * Better injection in PrismaApiKeyRepository imports * More mock fixes :) * Fix listMembers.handler.test * Fix User import * Appropriately adjust all types to be imported as types, there were a lot of types imported as normal deps * Why was this a thing? * Strictly speaking; Not using prismock anymore * Ditched patch file for prismock * Fix output.service.ts platform type imports, need concrete for plainToClass * Better typing and tests for unlinkConnectedAccount.handler * Small type fix * Disable calendar cache tests as they are dependent on prismock * chore: bump platform lib * getRoutedUrl test remove of unused import * Extract select to external const on getEventTypesFromDB * Direct select of userSelect from selects/user * fix type error from merging 23653 * Fixed integration tests by removing hardcoded values that were possible due to mocking, but as its now directly hitting the db no longer * fix: vite config atoms prisma client type location * revert: example app prisma client * revert: example app prisma client * bump platform libs * fix: use class instead of type for DI of PlatformBookingsService * update platform libs * remove unused variable * chore: generate prisma client for api v2 * fix: api v2 e2e * fix: atoms e2e * fix: atoms e2e * fix: atoms e2e * fix: api v2 e2e * fix: tsconfig apiv2 enums * publish libraries * Simplify check for existence teamId --------- Signed-off-by: Omar López <zomars@me.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: supalarry <laurisskraucis@gmail.com> Co-authored-by: cal.com <morgan@cal.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: Benny Joo <sldisek783@gmail.com> |
||
|
|
7bf5d9cf64 |
perf: import enums from @calcom/prisma/enums (#23582)
* wip * fix imports in the rest * rest * fix mistake |
||
|
|
096026b92a |
fix: Vitest is being bundled to client + bump lingo.dev version (#23502)
* Fix vitest on prod * Also extract out verify-email for the purpose of stopping test bundling * Address NIT * Fix lingo.dev imports --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> |