Files
calendar/packages/features/calAIPhone/providers/interfaces/PhoneNumberRepositoryInterface.ts
T
02c86d0268 feat: cal ai self serve architecture #1 (#22919)
* feat: cal ai self serve architecture

* chore: add package

* chore: update evnet controller

* refactor: improvements

* chore: rename

* chore: type error and naming

* chore: just set it to nul

* chore: just set it to nul

* chore: some more improvements

* chore: packate version

* fix: API v2

* chore: change name of files

* chore: add select

* chore: add missing teamId

* chore: save progress

* refactor: split into multiple services

* refactor: make schema provider agonistic

* chore: improvements

* chore:

* chore: remove duplicate files

* chore: semicolon

* chore: formatting

* refactor: logging and error handling

* chore: rename variable

* refactor: use trpc error

* chore: replace with HttpError

* chore: remove from option

* We need the enum and not just the type

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2025-08-08 15:57:13 +00:00

92 lines
2.2 KiB
TypeScript

import { 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;
}): Promise<PhoneNumberData>;
/**
* Delete phone number by phone number
*/
deletePhoneNumber(params: { phoneNumber: string }): Promise<void>;
/**
* Update subscription status
*/
updateSubscriptionStatus(params: {
id: number;
subscriptionStatus: PhoneNumberSubscriptionStatus;
disconnectOutboundAgent?: boolean;
}): Promise<void>;
/**
* Update agents for a phone number
*/
updateAgents(params: {
id: number;
inboundProviderAgentId?: string | null;
outboundProviderAgentId?: string | null;
}): Promise<void>;
}
/**
* 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;
}