* 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>
106 lines
2.8 KiB
TypeScript
106 lines
2.8 KiB
TypeScript
import type { PhoneNumberSubscriptionStatus } from "@calcom/prisma/enums";
|
|
|
|
/**
|
|
* Abstract interface for Phone Number repository operations
|
|
* This interface defines only the operations that the provider layer needs
|
|
* Allows for loose coupling between provider and application layers
|
|
*/
|
|
export interface PhoneNumberRepositoryInterface {
|
|
/**
|
|
* Find phone number by phone number and user ID
|
|
*/
|
|
findByPhoneNumberAndUserId(params: {
|
|
phoneNumber: string;
|
|
userId: number;
|
|
}): Promise<PhoneNumberData | null>;
|
|
|
|
/**
|
|
* Find phone number by phone number and team ID with user access validation
|
|
*/
|
|
findByPhoneNumberAndTeamId(params: {
|
|
phoneNumber: string;
|
|
teamId: number;
|
|
userId: number;
|
|
}): Promise<PhoneNumberData | null>;
|
|
|
|
/**
|
|
* Find phone number by ID and user ID
|
|
*/
|
|
findByIdAndUserId(params: { id: number; userId: number }): Promise<PhoneNumberData | null>;
|
|
|
|
/**
|
|
* Find phone number by ID with team access validation
|
|
*/
|
|
findByIdWithTeamAccess(params: {
|
|
id: number;
|
|
teamId: number;
|
|
userId: number;
|
|
}): Promise<PhoneNumberData | null>;
|
|
|
|
/**
|
|
* Create a new phone number record
|
|
*/
|
|
createPhoneNumber(params: {
|
|
phoneNumber: string;
|
|
provider?: string;
|
|
userId: number;
|
|
teamId?: number;
|
|
outboundAgentId?: string | null;
|
|
providerPhoneNumberId?: string;
|
|
subscriptionStatus?: import("@calcom/prisma/enums").PhoneNumberSubscriptionStatus;
|
|
stripeCustomerId?: string;
|
|
stripeSubscriptionId?: string;
|
|
}): Promise<PhoneNumberData>;
|
|
|
|
/**
|
|
* Delete phone number by phone number
|
|
*/
|
|
deletePhoneNumber(params: { phoneNumber: string }): Promise<void>;
|
|
|
|
/**
|
|
* Update subscription status
|
|
*/
|
|
updateSubscriptionStatus(params: {
|
|
id: number;
|
|
subscriptionStatus: PhoneNumberSubscriptionStatus;
|
|
disconnectAgents?: boolean;
|
|
}): Promise<void>;
|
|
|
|
/**
|
|
* Update agents for a phone number
|
|
*/
|
|
updateAgents(params: {
|
|
id: number;
|
|
inboundProviderAgentId?: string | null;
|
|
outboundProviderAgentId?: string | null;
|
|
}): Promise<void>;
|
|
|
|
/**
|
|
* Conditionally set inbound agent only if currently unset (atomic operation to prevent race conditions)
|
|
*/
|
|
updateInboundAgentId(params: { id: number; agentId: string }): Promise<{ count: number }>;
|
|
|
|
/**
|
|
* Find inbound agent by phone number ID
|
|
*/
|
|
findInboundAgentIdByPhoneNumberId(params: { phoneNumberId: number }): Promise<{ inboundAgentId: string | null } | null>;
|
|
}
|
|
|
|
/**
|
|
* Phone Number data structure
|
|
*/
|
|
export interface PhoneNumberData {
|
|
id: number;
|
|
phoneNumber: string;
|
|
userId: number | null;
|
|
teamId: number | null;
|
|
subscriptionStatus: string | null;
|
|
stripeSubscriptionId: string | null;
|
|
stripeCustomerId: string | null;
|
|
provider: string | null;
|
|
inboundAgentId: string | null;
|
|
outboundAgentId: string | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|