Files
calendar/packages/features/calAIPhone/providers/interfaces/AgentRepositoryInterface.ts
T
aa48e72c12 feat: inbound calls in cal ai (#23890)
* 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 <30310907+CarinaWolli@users.noreply.github.com>
2025-10-09 11:40:37 +01:00

125 lines
3.0 KiB
TypeScript

/**
* Abstract interface for Agent repository operations
* This interface defines only the operations that the provider layer needs
* Allows for loose coupling between provider and application layers
*/
export interface AgentRepositoryInterface {
/**
* Check if user can manage team resources
*/
canManageTeamResources(params: { userId: number; teamId: number }): Promise<boolean>;
/**
* Find agent by ID with user access validation
*/
findByIdWithUserAccess(params: { agentId: string; userId: number }): Promise<AgentData | null>;
/**
* Find agent by provider agent ID with user access validation
*/
findByProviderAgentIdWithUserAccess(params: {
providerAgentId: string;
userId: number;
}): Promise<AgentData | null>;
/**
* Find many agents with user access validation
*/
findManyWithUserAccess(params: {
userId: number;
teamId?: number;
scope?: "personal" | "team" | "all";
}): Promise<AgentWithDetailsData[]>;
/**
* Find agent by ID with user access and additional details
*/
findByIdWithUserAccessAndDetails(params: {
id: string;
userId: number;
teamId?: number;
}): Promise<AgentWithDetailsData | null>;
/**
* Create a new agent
*/
create(params: {
name: string;
providerAgentId: string;
userId: number;
teamId?: number;
}): Promise<AgentData>;
/**
* Find agent by ID with admin access validation
*/
findByIdWithAdminAccess(params: { id: string; userId: number; teamId?: number }): Promise<AgentData | null>;
/**
* Find agent by ID with call access validation
*/
findByIdWithCallAccess(params: { id: string; userId: number }): Promise<AgentWithPhoneNumbersData | null>;
/**
* Delete agent by ID
*/
delete(params: { id: string }): Promise<void>;
/**
* Link agent to workflow step
*/
linkOutboundAgentToWorkflow(params: { workflowStepId: number; agentId: string }): Promise<void>;
/**
* Link inbound agent to workflow
*/
linkInboundAgentToWorkflow(params: { workflowStepId: number; agentId: string }): Promise<void>;
}
/**
* Basic agent data structure
*/
export interface AgentData {
id: string;
name: string;
providerAgentId: string;
enabled: boolean;
userId: number | null;
teamId: number | null;
inboundEventTypeId?: number | null;
createdAt: Date;
updatedAt: Date;
}
/**
* Agent data with additional details
*/
export interface AgentWithDetailsData extends AgentData {
user: {
id: number;
name: string | null;
email: string | null;
} | null;
team: {
id: number;
name: string | null;
slug: string | null;
logoUrl?: string | null;
} | null;
outboundPhoneNumbers: Array<{
id: number;
phoneNumber: string;
subscriptionStatus: string | null;
provider: string | null;
}>;
}
/**
* Agent data with phone numbers for call operations
*/
export interface AgentWithPhoneNumbersData extends AgentData {
outboundPhoneNumbers: Array<{
phoneNumber: string;
}>;
}