mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
* feat: lang support * fix: type errors * feat: select voice agent * refactor: address feedback * refactor: address feedback * refactor: missing import * fix: types * feat: add inbound calls * chore: formatting * chore * feat: finish inbound call * chore: formatting * fix: update bug * fix: types * refactor: Agent Configuration Sheet (#23930) * refactor: agent configuration sheet * chore: use default phone numbre * refactor: improvements * refactor: improvements * fix: types * fix: feedback * chore: * fix: feedback * fix: prompt * fix: review * fix: review * refactor: class * refactor: class * refactor: rename * Update apps/web/public/static/locales/en/common.json * Update apps/web/public/static/locales/en/common.json * chore: update set value * fix: remove index * fix: type error * fix: update tetss * fix: use logger * refactor: don't use static * fix: type * fix: schema * refactor: --------- Co-authored-by: Carina Wollendorfer <[email protected]>
93 lines
3.1 KiB
TypeScript
93 lines
3.1 KiB
TypeScript
import { PrismaAgentRepository } from "@calcom/lib/server/repository/PrismaAgentRepository";
|
|
import prisma from "@calcom/prisma";
|
|
import type {
|
|
AgentRepositoryInterface,
|
|
AgentData,
|
|
AgentWithDetailsData,
|
|
AgentWithPhoneNumbersData,
|
|
} from "../interfaces/AgentRepositoryInterface";
|
|
|
|
/**
|
|
* Adapter that bridges the provider interface to the Prisma implementation
|
|
* This adapter provides a clean abstraction layer between provider and application
|
|
*/
|
|
export class PrismaAgentRepositoryAdapter implements AgentRepositoryInterface {
|
|
async canManageTeamResources(params: { userId: number; teamId: number }): Promise<boolean> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.canManageTeamResources(params);
|
|
}
|
|
|
|
async findByIdWithUserAccess(params: { agentId: string; userId: number }): Promise<AgentData | null> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.findByIdWithUserAccess(params);
|
|
}
|
|
|
|
async findByProviderAgentIdWithUserAccess(params: {
|
|
providerAgentId: string;
|
|
userId: number;
|
|
}): Promise<AgentData | null> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.findByProviderAgentIdWithUserAccess(params);
|
|
}
|
|
|
|
async findManyWithUserAccess(params: {
|
|
userId: number;
|
|
teamId?: number;
|
|
scope?: "personal" | "team" | "all";
|
|
}): Promise<AgentWithDetailsData[]> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.findManyWithUserAccess(params);
|
|
}
|
|
|
|
async findByIdWithUserAccessAndDetails(params: {
|
|
id: string;
|
|
userId: number;
|
|
teamId?: number;
|
|
}): Promise<AgentWithDetailsData | null> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.findByIdWithUserAccessAndDetails(params);
|
|
}
|
|
|
|
async create(params: {
|
|
name: string;
|
|
providerAgentId: string;
|
|
userId: number;
|
|
teamId?: number;
|
|
}): Promise<AgentData> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.create(params);
|
|
}
|
|
|
|
async findByIdWithAdminAccess(params: {
|
|
id: string;
|
|
userId: number;
|
|
teamId?: number;
|
|
}): Promise<AgentData | null> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.findByIdWithAdminAccess(params);
|
|
}
|
|
|
|
async findByIdWithCallAccess(params: {
|
|
id: string;
|
|
userId: number;
|
|
}): Promise<AgentWithPhoneNumbersData | null> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
return await agentRepo.findByIdWithCallAccess(params);
|
|
}
|
|
|
|
async delete(params: { id: string }): Promise<void> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
await agentRepo.delete(params);
|
|
}
|
|
|
|
async linkOutboundAgentToWorkflow(params: { workflowStepId: number; agentId: string }): Promise<void> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
await agentRepo.linkOutboundAgentToWorkflow(params);
|
|
}
|
|
|
|
async linkInboundAgentToWorkflow(params: { workflowStepId: number; agentId: string }): Promise<void> {
|
|
const agentRepo = new PrismaAgentRepository(prisma);
|
|
await agentRepo.linkInboundAgentToWorkflow(params);
|
|
}
|
|
}
|