Skip to content

refactor: Move repositories from @calcom/lib to @calcom/features domain folders#27570

Merged
hbjORbj merged 20 commits intomainfrom
devin/1770121796-move-lib-repos-to-features
Feb 9, 2026
Merged

refactor: Move repositories from @calcom/lib to @calcom/features domain folders#27570
hbjORbj merged 20 commits intomainfrom
devin/1770121796-move-lib-repos-to-features

Conversation

@hbjORbj
Copy link
Copy Markdown
Contributor

@hbjORbj hbjORbj commented Feb 3, 2026

What does this PR do?

Reorganizes repository files following the vertical slice architecture pattern by moving repositories from packages/lib/server/repository/ to their respective domain folders in packages/features/.

Repositories moved:

  • SelectedCalendarRepositoryfeatures/selectedCalendar/repositories/
  • VerificationTokenRepositoryfeatures/auth/repositories/
  • WorkspacePlatformRepositoryfeatures/workspace-platform/repositories/
  • PrismaTrackingRepositoryfeatures/bookings/repositories/
  • RoutingFormResponseRepositoryfeatures/routing-forms/repositories/
  • PrismaBookingPaymentRepositoryfeatures/bookings/repositories/
  • DTO files → respective feature domains

Note: DestinationCalendarRepository and SelectedCalendarRepository support both static methods (for direct usage) and instance methods (for dependency injection).

- Move HolidayRepository to features/holidays/repositories
- Move PrismaTrackingRepository to features/bookings/repositories
- Move PrismaBookingPaymentRepository to features/bookings/repositories
- Move PrismaRoutingFormResponseRepository to features/routing-forms/repositories
- Move PrismaAssignmentReasonRepository to features/assignment-reason/repositories
- Move VerificationTokenRepository to features/auth/repositories
- Move WorkspacePlatformRepository to features/workspace-platform/repositories
- Move DTO files to their respective feature domains
- Merge lib DestinationCalendarRepository into features version
- Merge lib SelectedCalendarRepository into features version
- Update all import paths across the codebase

This follows the vertical slice architecture pattern by organizing
repositories by domain rather than by technical layer.

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 3 commits February 3, 2026 13:12
Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
Comment on lines -1 to -13
import { prisma } from "@calcom/prisma";
import type { Prisma } from "@calcom/prisma/client";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import type { SelectedCalendarEventTypeIds } from "@calcom/types/Calendar";

import { buildCredentialPayloadForPrisma } from "../buildCredentialPayloadForCalendar";

export type UpdateArguments = {
where: FindManyArgs["where"];
data: Prisma.SelectedCalendarUpdateManyArgs["data"];
};
export type FindManyArgs = {
// https://github.com/microsoft/TypeScript/issues/55217 It crashes atoms build with this if we become too generic here. Seems like a TS bug with complex prisma types.
Copy link
Copy Markdown
Contributor Author

@hbjORbj hbjORbj Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged into packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts

Comment on lines -1 to -9
import type { PrismaClient } from "@calcom/prisma";

export class DestinationCalendarRepository {
constructor(private prisma: PrismaClient) {}

async getCustomReminderByCredentialId(credentialId: number): Promise<number | null> {
const destinationCalendar = await this.prisma.destinationCalendar.findFirst({
where: { credentialId },
select: { customCalendarReminder: true },
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged into packages/features/calendars/repositories/DestinationCalendarRepository.ts

@devin-ai-integration devin-ai-integration bot changed the title refactor: move repositories from lib to features domain folders refactor: move repositories from lib to features and app-store Feb 6, 2026
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1770121796-move-lib-repos-to-features branch from 671dd9b to 1f399d8 Compare February 6, 2026 08:19
@devin-ai-integration devin-ai-integration bot changed the title refactor: move repositories from lib to features and app-store refactor: move repositories from lib to features domain folders Feb 6, 2026
@hbjORbj hbjORbj marked this pull request as ready for review February 6, 2026 08:32
@hbjORbj hbjORbj requested review from a team as code owners February 6, 2026 08:32
@hbjORbj hbjORbj changed the title refactor: move repositories from lib to features domain folders refactor: Move repositories from @calcom/lib to @calcom/features domain folders Feb 6, 2026
@graphite-app graphite-app bot added foundation core area: core, team members only labels Feb 6, 2026
}

// Static methods for direct usage (from lib version)
private static async findConflicting(data: {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow-up PR, I will turn the static methods into instance methods

Comment on lines +10 to +24
private prismaClient: PrismaClient;

constructor(prismaClient?: PrismaClient) {
this.prismaClient = prismaClient ?? prisma;
}

async getCustomReminderByCredentialId(credentialId: number): Promise<number | null> {
const destinationCalendar = await this.prismaClient.destinationCalendar.findFirst({
where: { credentialId },
select: { customCalendarReminder: true },
});
return destinationCalendar?.customCalendarReminder ?? null;
}

async updateCustomReminder({
Copy link
Copy Markdown
Contributor Author

@hbjORbj hbjORbj Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow-up PR, I will turn the static methods (the existing ones in this repository) into instance methods for consistency

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 75 files

@@ -1,493 +0,0 @@
import prismock from "@calcom/testing/lib/__mocks__/prisma";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged into packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts

… file

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
@hbjORbj hbjORbj enabled auto-merge (squash) February 6, 2026 09:09
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/app-store/salesforce/lib/repositories/PrismaAssignmentReasonRepository.ts">

<violation number="1">
P2: Add a `select` to limit the Prisma query to the fields actually needed (e.g., `reasonString`) to avoid fetching the full AssignmentReason row.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

E2E results are ready!

keithwillcode
keithwillcode previously approved these changes Feb 6, 2026
Copy link
Copy Markdown
Contributor

@keithwillcode keithwillcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a new rule to disallow this moving forward?

@hbjORbj
Copy link
Copy Markdown
Contributor Author

hbjORbj commented Feb 6, 2026

@keithwillcode Done! useFilenamingConvention rule is perfect for this but it doesn't support exclusion patterns, so I did something a bit hacky, but it achieves what we want. I basically applied an impossible regex to repository files (*Repository*, *repository*, /repository/**, /repositories/**) so they fail validation immediately.

Screenshot 2026-02-06 at 9 12 36 PM

Below is an evidence that it works:

Screenshot 2026-02-06 at 9 18 34 PM

@hbjORbj hbjORbj requested a review from keithwillcode February 6, 2026 12:21
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="biome.json">

<violation number="1" location="biome.json:263">
P1: Circular dependency detected: `VerificationTokenService` in `packages/lib` now imports from `packages/features`, creating a dependency cycle (`lib` → `features` → `lib`).

The refactor moved `VerificationTokenRepository` to `features`, but `VerificationTokenService` remains in `lib` and now imports the repository from `features`. This violates the architectural rule that `lib` cannot depend on `features`.

**Action Required:**
1. Move `packages/lib/server/service/VerificationTokenService.ts` (and its tests) to `packages/features/auth`.
2. Update the `noRestrictedImports` rule for `packages/lib` (lines 224-250) to explicitly ban `@calcom/features` and `@calcom/features/**` to prevent future circular dependencies via alias imports.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/app-store/stripepayment/lib/VerificationTokenService.test.ts">

<violation number="1" location="packages/app-store/stripepayment/lib/VerificationTokenService.test.ts:3">
P2: The import path was updated to "./repositories/..." but the test still mocks "../repositories/...", so the mock no longer matches the imported module. Update the mock path to match the new import so the repository is properly mocked.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

…ts rule

Addresses Cubic AI review feedback (confidence 9/10): the existing
noRestrictedImports rule for packages/lib only banned relative imports
(../features/**) but not alias imports (@calcom/features). This could
allow circular dependencies via alias imports to bypass the lint rule.

Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

Cubic AI Review Feedback - Addressed

Reviewed all Cubic AI comments and their confidence scores:

Fixed (confidence 9/10):

  • biome.json (Comment 16): Added @calcom/features and @calcom/features/** alias patterns to the packages/lib noRestrictedImports rule. The existing rule only banned relative imports (../features/**) but not alias imports, which could allow circular dependencies to bypass the lint check. This completes the preventive measure identified by cubic.

Skipped (confidence below 9/10):

  • PrismaAssignmentReasonRepository.ts (confidence 8/10): Adding select to Prisma query — already resolved as out of scope by PR author.
  • VerificationTokenService.test.ts (confidence 8/10): Mock path mismatch — below confidence threshold.

@hbjORbj hbjORbj force-pushed the devin/1770121796-move-lib-repos-to-features branch from 05e4f95 to 90ffee4 Compare February 6, 2026 13:56
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="biome.json">

<violation number="1">
P2: Dropping the @calcom/trpc alias patterns lets lib import from trpc via package aliases, bypassing the intended circular-dependency restriction. Restore the alias patterns.</violation>

<violation number="2">
P2: This removes @calcom/features alias restrictions, allowing lib to bypass the circular-dependency guard via package imports. Keep the alias patterns in the restricted group.</violation>

<violation number="3">
P2: This change allows lib to import from app-store via @calcom/app-store aliases, which defeats the circular-dependency restriction. Keep the alias patterns so both relative and package imports are blocked.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ Pushed commit 0e04c2e

@hbjORbj hbjORbj force-pushed the devin/1770121796-move-lib-repos-to-features branch from 40750e8 to f92e7b3 Compare February 6, 2026 14:36
@hbjORbj hbjORbj merged commit 96bec9f into main Feb 9, 2026
53 of 54 checks passed
@hbjORbj hbjORbj deleted the devin/1770121796-move-lib-repos-to-features branch February 9, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants