The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.
TypeScript ai-receptionistanswering-serviceappointment-bookinglivekitlocal-firstmcpopen-sourceself-hostedsiptelephonytypescriptvoice-agentvoice-ai
// What Server admin › Partners shows, kept out of the components so it can be tested: what waits for an instance
// admin (partners to approve and partners whose brand waits for review: one list on the "Waiting for approval" view,
// its number there and in Overview › Needs you), and which of a partner row's actions it offers.
import type { AdminPartner, PartnerBrandReview } from '@linedesk/actions'
/** Brands with a change no instance admin approved yet (never approved, or changed since). */
export const waitingBrands = <B extends Pick<PartnerBrandReview, 'state'>>(brands: readonly B[]) =>
brands.filter(b => b.state !== 'approved')
/** The brand of each partner, by partner id. */
export const brandsByPartner = <B extends Pick<PartnerBrandReview, 'partnerId'>>(brands: readonly B[]) =>
new Map(brands.map(b => [b.partnerId, b]))
/**
* Partners that wait for an instance admin: still to approve, or with a brand change to review (one row each, even
* when both wait).
*/
export const waitingPartners = <P extends Pick<AdminPartner, 'id' | 'status'>>(
partners: readonly P[],
brands: readonly Pick<PartnerBrandReview, 'partnerId' | 'state'>[],
) => {
const toReview = new Set(waitingBrands(brands).map(b => b.partnerId))
return partners.filter(p => p.status === 'pending' || toReview.has(p.id))
}
/** The Status column's order, sorted up: the partners to approve first, then the suspended, then the approved. */
export const PARTNER_STATUS_ORDER: Record<AdminPartner['status'], number> = { pending: 0, suspended: 1, approved: 2 }
/** How many partners wait for an instance admin: the "Waiting for approval" view's rows. */
export const waitingCount = (
partners: readonly Pick<AdminPartner, 'id' | 'status'>[],
brands: readonly Pick<PartnerBrandReview, 'partnerId' | 'state'>[],
) => waitingPartners(partners, brands).length
/**
* "Turn off AI keys" (or "Turn on AI keys" after it): only for a partner with a bill (own keys exist only on White-label
* Cloud) that stored keys of its own, or whose keys an instance admin already turned off. A partner without keys has
* nothing to turn off.
*/
export const offersKeysSwitch = (p: Pick<AdminPartner, 'billingAccountId' | 'ownKeys' | 'ownKeysDisabled'>) =>
!!p.billingAccountId && (p.ownKeys > 0 || !!p.ownKeysDisabled)