refactor: convert TeamRepository to use dependency injection pattern (#22383)

* refactor: convert TeamRepository to use dependency injection pattern

- Add constructor injection for PrismaClient in TeamRepository
- Convert all static methods to instance methods using this.prismaClient
- Update all usage sites to use two-step pattern: const teamRepo = new TeamRepository(prisma); teamRepo.method(...)
- Optimize instance reuse within same function scopes where possible
- Update test files to work with new instance pattern
- Preserve all existing functionality and method signatures

Follows the same dependency injection pattern as UserRepository refactoring

Co-Authored-By: [email protected] <[email protected]>

* chore: bump platform libs

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Morgan <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-07-10 14:03:50 +00:00
1 parent 7d02d1bb23
commit efd15c5a3e
15 files changed
+85 -55

No files matched your search

@@ -292,7 +292,8 @@ export class AvailableSlotsService {
organizationDetails: { currentOrgDomain: string | null; isValidOrgDomain: boolean }
) {
const { currentOrgDomain, isValidOrgDomain } = organizationDetails;
const team = await TeamRepository.findFirstBySlugAndParentSlug({
const teamRepo = new TeamRepository(prisma);
const team = await teamRepo.findFirstBySlugAndParentSlug({
slug,
parentSlug: isValidOrgDomain && currentOrgDomain ? currentOrgDomain : null,
select: { id: true },
@@ -1,4 +1,5 @@
import { TeamRepository } from "@calcom/lib/server/repository/team";
import prisma from "@calcom/prisma";
import type { TrpcSessionUser } from "../../../types";
import type { TGetListSchema } from "./list.schema";
@@ -11,7 +12,8 @@ type ListOptions = {
};
export const listHandler = async ({ ctx, input }: ListOptions) => {
return TeamRepository.findTeamsByUserId({
const teamRepo = new TeamRepository(prisma);
return teamRepo.findTeamsByUserId({
userId: ctx.user.id,
includeOrgs: input?.includeOrgs,
});