fix: remove circular dependency in packages/prisma (#24596)
- Replaced DeploymentRepository import with inline implementation - Created InlineDeploymentRepository class implementing IDeploymentRepository - Breaks circular dependency: deployment.ts -> prisma/index.ts -> usage-tracking.ts -> deployment.ts - Verified with madge: no circular dependencies found Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI
parent
17944311c3
commit
e310931417
@@ -1,12 +1,32 @@
|
||||
import { waitUntil } from "@vercel/functions";
|
||||
|
||||
import { UsageEvent, LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
|
||||
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
|
||||
import type { IDeploymentRepository } from "@calcom/lib/server/repository/deployment.interface";
|
||||
import { Prisma } from "@calcom/prisma/client";
|
||||
import type { PrismaClient } from "@calcom/prisma/client";
|
||||
|
||||
class InlineDeploymentRepository implements IDeploymentRepository {
|
||||
constructor(private prisma: PrismaClient) {}
|
||||
|
||||
async getLicenseKeyWithId(id: number): Promise<string | null> {
|
||||
const deployment = await this.prisma.deployment.findUnique({
|
||||
where: { id },
|
||||
select: { licenseKey: true },
|
||||
});
|
||||
return deployment?.licenseKey || null;
|
||||
}
|
||||
|
||||
async getSignatureToken(id: number): Promise<string | null> {
|
||||
const deployment = await this.prisma.deployment.findUnique({
|
||||
where: { id },
|
||||
select: { signatureTokenEncrypted: true },
|
||||
});
|
||||
return deployment?.signatureTokenEncrypted || null;
|
||||
}
|
||||
}
|
||||
|
||||
async function incrementUsage(prismaClient: PrismaClient, event?: UsageEvent) {
|
||||
const deploymentRepo = new DeploymentRepository(prismaClient);
|
||||
const deploymentRepo = new InlineDeploymentRepository(prismaClient);
|
||||
try {
|
||||
const licenseKeyService = await LicenseKeySingleton.getInstance(deploymentRepo);
|
||||
await licenseKeyService.incrementUsage(event);
|
||||
|
||||
Reference in New Issue
Block a user