import React from 'react'; /** * @fileoverview TypeScript Declaration File for SDK State Manager * @description Type declarations for the SDK state management system. * Provides type definitions for centralized state management in the Call Control SDK. * * @author CTI SDK Team * @version 6.x.x * @since 2024 */ /** * Inline type definitions to avoid Rollup DTS bundler resolution issues * with relative imports from handwritten .d.ts files. */ type SDKConfig$1 = { disableEndCallButton?: boolean; disableEndConference?: boolean; enableSmsServices?: boolean; enableQueueName?: boolean; enableRingtone?: boolean; disabledMoreOptionsButton?: boolean; disabledDialButton?: boolean; disableCallTransferButton?: boolean; disableBlindTransfer?: boolean; disableAttendedTransfer?: boolean; disableWarmTransfer?: boolean; isDraggable?: boolean; disableSoftPhone?: boolean; disableConferenceButton?: boolean; disableHoldButton?: boolean; disableMuteButton?: boolean; disableCallDisposition?: boolean; disabled?: any; enabled?: any; outlined?: any; auto_wrapup_time?: number; break_time?: number; breakDetailsVisible?: boolean; break_details_visible?: boolean; sdkPosition?: "horizontal" | "vertical"; }; type CallStatus = | "IDLE" | "READY" | "BREAK" | "ONCALL" | "WRAPUP" | "RINGING" | "DIALING" | "MISSED" | "HOLD" | "UNHOLD" | "MUTE" | "UNMUTE" | "DISCONNECTED" | "CONFERENCE" | string; type CallData$1 = { mode?: string; queue_name?: string; mobileNumber?: string; callReferenceId?: string; callId?: string; type?: string; status: string; agent_id: number; phone_number?: string; event_time?: string; call_id?: string; process_id?: string; process_name?: string; mute?: number; hold?: number; auto_wrapup_time?: number | null; }; type ConferenceLineTypes = { line: number; status: string; type: "external" | "internal" | ""; phone: string; isMute: boolean; isHold: boolean; isCallStart: boolean; isMergeCall: boolean; }; type SDKState$1 = { authorization: any; openConferenceDialog: boolean; openCallTransferDialog: boolean; process?: { process_id: number; process_name: string } | null; agentId: string; sessionId?: string; sdkConfig: SDKConfig$1 | null; urlConfig: any | null; isInitialized: boolean; call_id?: string; process_id?: number; callStartTime: number | null; position?: { x: number; y: number }; controlPanelPosition: { x: number; y: number }; iframePosition: { x: number; y: number }; callData: CallData$1; conferenceLine: ConferenceLineTypes[]; hold: number; mute: number; agentStatus: string; sdk: any | null; isPermissionsLoaded: boolean; userPermissions: string[] | null; menuEntitlements: Array<{ code: string; name: string; enabled: boolean }> | null; consultInfo: any | null; }; /** * @interface SDKStateManager * @description Interface for the SDK state manager class */ interface SDKStateManager { /** * Initialize the SDK with API key, tenant ID, agent ID, and optional configuration * @param apiKey - API key for authentication * @param tenantId - Tenant identifier * @param agentId - Agent identifier * @param urlConfig - Optional URL configuration * @param res - Optional initialization response * @param callControlConfig - Optional call control configuration */ initialize(apiKey: string, tenantId: string, agentId: string, urlConfig?: any, res?: any, callControlConfig?: SDKConfig$1): void; /** * Get the current state * @returns Current SDK state */ getState(): SDKState$1; /** * Tenant this session authenticated against, from the login response's * `tenantInfo`. Read from persisted state, so it resolves on any mount. * @returns Tenant id as a string, or undefined when not initialized */ getTenantId(): string | undefined; /** * Subscribe to state changes * @param listener - Callback function to be called on state changes * @returns Unsubscribe function */ subscribe(listener: () => void): () => void; /** * Set holding state * @param isHolding - Whether call is on hold */ setHolding(isHolding: boolean): void; /** * Set muted state * @param isMuted - Whether call is muted */ setMuted(isMuted: boolean): void; /** * Set call status * @param status - Current call status */ setStatus(status: CallStatus): void; /** * Set process information * @param process - Process data with ID and name */ setProcess(process: { process_id: number; process_name: string }): void; /** * Set control panel position * @param position - X and Y coordinates */ setControlPanelPosition(position: { x: number; y: number }): void; /** * Set iframe position * @param position - X and Y coordinates */ setIframePosition(position: { x: number; y: number }): void; /** * Start a call (set start time and status) */ startCall(): void; /** * End a call (reset call state) */ endCall(): void; /** * Set initialization check flag */ setInitCheck(): void; /** * Set conference dialog open state * @param open - Whether conference dialog is open */ setOpenConferenceDialog(open: boolean): void; /** * Set call transfer dialog open state * @param open - Whether call transfer dialog is open */ setOpenCallTransferDialog(open: boolean): void; /** * Update call data * @param data - Partial call data to update */ updateCallData(data: Partial): void; /** * Update conference data * @param data - Array of conference line data */ updateConferenceData(data: ConferenceLineTypes[]): void; /** * Set specific conference line * @param line - Conference line data */ setConferenceLine(line: ConferenceLineTypes): void; /** * Reset conference lines to initial state */ resetConferenceLines(): void; /** * Clear storage and reset to initial state */ clearStorageAndReset(): void; /** * Debug storage data */ debugStorage(): void; /** * Get conference lines * @returns Array of conference line data */ getConferenceLines(): ConferenceLineTypes[]; /** * Set SDK permissions from user info * @param userInfo - User info object from init response */ setSDKPermissions(userInfo: any): void; /** * Get entitlement-based controls configuration * @returns Controls configuration derived from permissions */ getControlsConfig(): Partial; } /** * @class SDKStateManager * @description Centralized state management class for the Call Control SDK. * Handles state persistence, subscriptions, and provides methods for state updates. */ declare class SDKStateManager implements SDKStateManager { /** * Initialize the SDK with API key, tenant ID, agent ID, and optional configuration * @param apiKey - API key for authentication * @param tenantId - Tenant identifier * @param agentId - Agent identifier * @param urlConfig - Optional URL configuration * @param res - Optional initialization response * @param callControlConfig - Optional call control configuration */ public initialize(apiKey: string, tenantId: string, agentId: string, urlConfig?: any, res?: any, callControlConfig?: SDKConfig$1): void; /** * Get the current state * @returns Current SDK state */ public getState(): SDKState$1; /** * Subscribe to state changes * @param listener - Callback function to be called on state changes * @returns Unsubscribe function */ public subscribe(listener: () => void): () => void; /** * Store lead data to be attached as lead_data in the transfer API payload. * Call this whenever lead details change in the host application. */ public setTransferLeadData(data: any): void; /** * Get the currently stored lead data. */ public getTransferLeadData(): any; /** * Clear stored lead data (called automatically when call goes IDLE). */ public clearTransferLeadData(): void; /** * Set holding state * @param isHolding - Whether call is on hold */ public setHolding(isHolding: boolean): void; /** * Set muted state * @param isMuted - Whether call is muted */ public setMuted(isMuted: boolean): void; /** * Set call status * @param status - Current call status */ public setStatus(status: CallStatus): void; /** * Set process information * @param process - Process data with ID and name */ public setProcess(process: { process_id: number; process_name: string }): void; /** * Set control panel position * @param position - X and Y coordinates */ public setControlPanelPosition(position: { x: number; y: number }): void; /** * Set iframe position * @param position - X and Y coordinates */ public setIframePosition(position: { x: number; y: number }): void; /** * Start a call (set start time and status) */ public startCall(): void; /** * End a call (reset call state) */ public endCall(): void; /** * Set initialization check flag */ public setInitCheck(): void; /** * Set conference dialog open state * @param open - Whether conference dialog is open */ public setOpenConferenceDialog(open: boolean): void; /** * Set call transfer dialog open state * @param open - Whether call transfer dialog is open */ public setOpenCallTransferDialog(open: boolean): void; /** * Update call data * @param data - Partial call data to update */ public updateCallData(data: Partial): void; /** * Update conference data * @param data - Array of conference line data */ public updateConferenceData(data: ConferenceLineTypes[]): void; /** * Set specific conference line * @param line - Conference line data */ public setConferenceLine(line: ConferenceLineTypes): void; /** * Reset conference lines to initial state */ public resetConferenceLines(): void; /** * Clear storage and reset to initial state */ public clearStorageAndReset(): void; /** * Debug storage data */ public debugStorage(): void; /** * Get conference lines * @returns Array of conference line data */ public getConferenceLines(): ConferenceLineTypes[]; /** * Set SDK permissions from user info * @param userInfo - User info object from init response */ public setSDKPermissions(userInfo: any): void; /** * Get entitlement-based controls configuration * @returns Controls configuration derived from permissions */ public getControlsConfig(): Partial; } /** * @constant sdkStateManager * @description Singleton instance of the SDK state manager * @type {SDKStateManager} */ declare const sdkStateManager: SDKStateManager; /** * @fileoverview πŸ“¦ TypeScript Declaration File for Call Control SDK * @description Comprehensive CTI (Computer Telephony Integration) SDK for agent platform applications. * Provides complete call control functionality including dialing, conferencing, transferring, * and real-time call management with WebSocket integration. * * @author CTI SDK Team * @version 6.x.x * @since 2024 */ // ============================================================================= // 🎯 MAIN SDK FUNCTIONS // ============================================================================= /** * πŸš€ SDK Initialization Parameters Interface * * @interface InitSDKParams * @description Parameters required for SDK initialization * * @properties * - `apiKey: string` - Authentication key for SDK access * - `tenantId: string` - Tenant identifier for multi-tenancy support * - `agentId: string` - Agent identifier for call management * - `sdkConfig?: SDKConfig` - Optional SDK configuration for customizing behavior * * @example * ```typescript * const initParams: InitSDKParams = { * apiKey: "your-api-key", * tenantId: "tenant-123", * agentId: "agent-456", * sdkConfig: { * isDraggable: true, * disableSoftPhone: false * } * }; * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface InitSDKParams { /** Authentication key for SDK access */ apiKey: string; /** Tenant identifier for multi-tenancy support */ tenantId: string; /** Agent identifier for call management */ agentId: string; /** Optional SDK configuration for customizing behavior */ sdkConfig?: SDKConfig; /** Optional URL configuration for SDK endpoints */ urlConfig?: URLConfig; } /** * πŸš€ Initialize the Call Control SDK * * @function initSDK * @description Initializes the Call Control SDK with authentication credentials and configuration. * Sets up event tracking, state management, and establishes connection to the CTI system. * * @param {InitSDKParams} params - Object containing API key, tenant ID, agent ID, and optional config * @returns {Promise} Promise that resolves when initialization is complete * * @example * ```typescript * // Basic initialization * await initSDK({ * apiKey: "your-api-key", * tenantId: "tenant-123", * agentId: "agent-456" * }); * * // With custom configuration * await initSDK({ * apiKey: "your-api-key", * tenantId: "tenant-123", * agentId: "agent-456", * sdkConfig: { * isDraggable: true, * disableSoftPhone: false, * disableEndCallButton: false * } * }); * ``` * * @throws {Error} When API key is missing or invalid * @throws {Error} When tenant ID is missing or invalid * @throws {Error} When agent ID is missing or invalid * @throws {Error} When initialization fails due to network or authentication issues * * @since 1.0.0 * @author CTI SDK Team */ interface SDKInitResult { accessToken: string; expiration: string; ticketId: string; callControls: any; userInfo: any; /** * Tenant this session authenticated against, forwarded from the login response. * Tenant-keyed pages (Caro Voice AI) resolve their tenant from here. */ tenantInfo?: { tenantId?: number | string; slug?: string; }; } declare function initSDK(params: InitSDKParams): Promise; /** * πŸ“‹ Get SDK Version * * @function getSDKVersion * @description Returns the current version of the Call Control SDK * * @returns {string} Current SDK version string * * @example * ```typescript * const version = getSDKVersion(); * console.log(`Using Call Control SDK version: ${version}`); * ``` * * @since 1.0.0 * @author CTI SDK Team */ declare function getSDKVersion(): string; /** * βœ… Check SDK Initialization Status * * @function isSDKInitialized * @description Checks if the SDK has been successfully initialized * * @returns {boolean} True if SDK is initialized, false otherwise * * @example * ```typescript * if (isSDKInitialized()) { * // SDK is ready to use * console.log("SDK is initialized and ready"); * } else { * console.log("SDK needs to be initialized first"); * } * ``` * * @since 1.0.0 * @author CTI SDK Team */ declare function isSDKInitialized(): boolean; // ============================================================================= // 🎭 COMPONENT EXPORTS // ============================================================================= /** * 🎭 Call Control Panel Component * * @component CallControlPanel * @description Main call control panel component for the CTI SDK. * Provides comprehensive call management interface with all necessary controls. * * @param {CallControlPanelProps} props - Component props * @returns {JSX.Element} Call control panel interface * * @example * ```tsx * * * { * console.log('Call Data:', data); * }} /> * ``` * * @since 1.0.0 * @author CTI SDK Team */ declare const CallControlPanel: React.ComponentType; /** * ☎️ Call Control Iframe β€” full iframe-hosted softphone * * @component CallControlIframe * @description The complete softphone surface (keypad, active-call controls, * transfer, conference, recents, agent bar) hosted in an iframe by the ahs-cti * Browser-Phone app. * * Use this **instead of** {@link CallControlPanel}, not alongside it. The phone * owns the agent-events websocket and forwards every event into SDK state, so * `useGetCallerData()` / `useSDKState()` stay live for the rest of the host app * with no changes at the call sites. Rendering both components opens two * sockets for the same agent. * * Works two ways: * - **Zero-config** β€” every prop omitted; the iframe URL, user id, token, theme * colour and control gating all come from the state `initSDK` populated. Pass * `urlConfig.iframeURL` to `initSDK` and nothing else is needed. * - **Host-driven** β€” pass `iframeBaseUrl` / `apiHost` / `wsUrl` / `token` / * `userId` / `primaryColor` and the SDK reads no state for those, for a host * that owns its own auth and theme. * * @param {CallControlIframeProps} props - Component props * @returns {JSX.Element | null} Draggable softphone panel, or `null` while the * config is still resolving / when `sdkConfig.disableSoftPhone` is set * * @example * ```tsx * // Zero-config β€” everything resolved from initSDK * * * // Host-driven β€” the SDK reads no state for these * * ``` * * @since 1.0.0 * @author CTI SDK Team */ declare const CallControlIframe: React.ComponentType; /** * @interface CallControlIframeProps * @description Props for {@link CallControlIframe}. Every field is optional β€” * anything omitted is resolved from the state `initSDK` populated. */ interface CallControlIframeProps { /** * URL the phone is served from. Defaults to `urlConfig.iframeURL` passed to * `initSDK`. A value that already carries a path is used verbatim; a bare * origin gets `entryPath` appended. */ iframeBaseUrl?: string; /** * Path appended when the resolved base is a bare origin. * Default `/static/phone/iframe_index.html`. */ entryPath?: string; /** REST API host passed to the phone as `api_url`. Defaults to `urlConfig.iframeAPIURL`. */ apiHost?: string; /** WebSocket host passed to the phone as `ws_url`. Defaults to `urlConfig.webSocketURL`. */ wsUrl?: string; /** Auth token; a leading `Bearer ` is added if missing. Defaults to the SDK's own access token. */ token?: string; /** Logged-in user id, passed as `user_id`. Defaults to `urlConfig.id`. */ userId?: string | number; /** User reference, passed as `user_ref`. Defaults to the SDK's `agentId`. */ userRef?: string; /** Theme primary color; the leading `#` is stripped before it is passed as `primary`. Defaults to the MUI theme's primary. */ primaryColor?: string; /** SIP extension pushed to the phone via `cti:ext` (cosmetic β€” the phone self-provisions). */ ext?: string; /** Agent display name shown in the phone's agent bar. */ agentName?: string; /** Auto wrap-up seconds; drives the phone's wrap-up countdown. */ autoWrapupTime?: number | null; /** Show the phone's break/status selector (passed as `can_break`). Default `true`. */ canBreak?: boolean; /** * Current call status, used to auto-reopen a collapsed panel and flag the * launcher. Defaults to the live status in SDK state, which this component * keeps current β€” so a host normally omits it. */ callStatus?: string; /** * Raw SDK entitlements (`userInfo.entitlements.sdk`) used to derive the * disabled-controls list. When passed at all it takes precedence over the * entitlement-resolved `sdkConfig`, including failing closed (everything * disabled) if the value is absent. Ignored when `disabledControls` is given. */ sdkEntitlements?: SDKEntitlements; /** Explicit comma-list of disabled controls; bypasses every derivation. */ disabledControls?: string; /** Render the panel expanded on mount. Default `true`. */ defaultOpen?: boolean; /** Panel width in px. Default 440. */ width?: number; /** Panel height in px. Default 640. */ height?: number; /** Same payload shape `CallControlPanel`'s `onDataChange` emits. */ onDataChange?: (_data: CallData) => void; } /** * πŸ“„ SDK Pages * * @description Pre-built pages provided by the SDK, automatically protected by permission guards. * * @properties * - `CallHistory` - Call History page component * - `Campaigns` - Campaigns / Call Scheduling page component * - `LoginReport` - Agent Login Report page component * - `CdrReports` - CDR (Call Detail Records) Report page component * - `AuditReportPage` - Stand-alone (full-tab) audit report page component * - `AgentPerformanceReport` - Agent Performance Report page component * - `AgentDetailReport` - Agent Detail Report page component * - `LiveStatus` - Supervisor Live Status / Wallboard page component * - `LeadIntegrations` - Lead Integrations page component (webhooks + form β†’ campaign mappings) * * @since 1.0.0 * @author CTI SDK Team */ interface LiveStatusPageProps { /** When true, renders the TV/wallboard variant: shows the top bar with clock, hides monitor action buttons */ isTvDashboard?: boolean; } declare const SDKPages: { readonly CallHistory: React.ComponentType; readonly Campaigns: React.ComponentType; readonly LoginReport: React.ComponentType; readonly CdrReports: React.ComponentType; readonly SummaryReport: React.ComponentType; readonly AuditReportPage: React.ComponentType<{ callUuid?: string }>; readonly AgentPerformanceReport: React.ComponentType; readonly AgentDetailReport: React.ComponentType; readonly LiveStatus: React.ComponentType; readonly ManagementDashboard: React.ComponentType; readonly CaroVoiceAI: React.ComponentType; readonly QualityAuditDashboard: React.ComponentType; readonly CaroQualityAuditDashboard: React.ComponentType; readonly LeadIntegrations: React.ComponentType; }; // ============================================================================= // πŸ“‹ STAND-ALONE PAGE / DIALOG COMPONENTS // ============================================================================= // These are exported at the top level (in addition to being reachable through // `SDKPages`) so hosts can mount them directly β€” e.g. a ticket list opening the // audit report for a `convoxid`, or a reports route wrapping AgentDetailReport // in its own layout. Keep this block in sync with the `export`s in index.ts. interface AuditReportDialogProps { open: boolean; onClose: () => void; /** Dialog width. Defaults to "80vw". */ width?: string; /** Full CDR row to audit. */ rowData?: any; /** * Call to audit. Use this when you have a bare call id (e.g. a ticket's * `convoxid`) rather than a full CDR row. Takes precedence over * `rowData.callUuid` when both are provided. */ callUuid?: string; /** * Per-instance override of the maximize behaviour. When provided it takes * precedence over the globally-configured resolver β€” useful for in-app * navigation instead of opening a new tab. */ onMaximize?: (callUuid: string) => void; } /** * πŸ” Audit report shown in a modal dialog. The maximize button opens the same * report full-screen in a new browser tab; the URL is built by the * host-configured resolver (see `setAuditReportUrlResolver`). * * @since 1.0.0 */ declare const AuditReportDialog: React.ComponentType; /** Builds the URL the audit-report maximize button opens for a given call. */ type AuditReportUrlResolver = (callUuid: string) => string; /** * Configure how the audit-report maximize button builds its new-tab URL. * Call once during host-app startup, alongside registering the route that * renders `SDKPages.AuditReportPage`. The default targets a ROOT-level * "/audit-report/:callUuid" route. * * @example * // Route registered at "/reports/audit-report/:callUuid": * setAuditReportUrlResolver((id) => `/reports/audit-report/${encodeURIComponent(id)}`); * // Hash router: * setAuditReportUrlResolver((id) => `/#/audit-report/${encodeURIComponent(id)}`); */ declare function setAuditReportUrlResolver( resolver: AuditReportUrlResolver, ): void; interface AgentDetailReportProps { /** Agent row from the Agent Performance Report list. */ agentRow?: any; /** Invoked when the user navigates back to the list. */ onBack?: () => void; /** Where the report was opened from; "REPORTS_LIST" renders the back affordance. */ from?: "REPORTS_LIST" | string; /** Initial date-range start (dayjs instance). */ initialStartDate?: any; /** Initial date-range end (dayjs instance). */ initialEndDate?: any; /** Initial quick-range preset key (e.g. "today", "last7days"). */ initialQuickRange?: string; } /** * πŸ“Š Agent Detail Report page component. * * @since 1.0.0 */ declare const AgentDetailReport: React.ComponentType; // ============================================================================= // πŸ—ƒοΈ TYPE EXPORTS // ============================================================================= /** * πŸ“ž Call Data Interface * * @interface CallData * @description Comprehensive interface defining call-related data structure for CTI operations. * Contains all necessary information about active calls, including metadata, status, and references. * * @properties * - `callReferenceId?: string` - Unique reference identifier for the call * - `status?: string` - Current status of the call (ONCALL, RINGING, WRAPUP, etc.) * - `agent_id?: string` - Agent identifier associated with the call * - `phone_number?: string` - Phone number involved in the call * - `process_id?: string` - Process identifier for the call * - `process_name?: string` - Name of the process handling the call * * @since 1.0.0 * @author CTI SDK Team */ interface CallData { mode?: string; queue_name?: string; mobileNumber?: string; callReferenceId?: string; convoxId?: string; type?: string; status: string; agent_id: number; phone_number?: string; event_time?: string; call_id?: string; process_id?: string; process_name?: string; mute?: number; hold?: number; auto_wrapup_time?: number | null; source?: string; call_details?: { extension?: string; call_type?: string; caller_direction?: string; agent_id?: number; queue_name?: string; did_number?: string; call_uuid?: string; source?: string; [key: string]: any; }; /** Lead data set by the host app; attached when available */ lead_data?: any; /** Raw socket payload from the most recent WebSocket message */ socket_info?: any; break_details?: { type: string; value: string; } | null; } /** * βš™οΈ SDK Configuration Interface * * @interface SDKConfig * @description Configuration interface for customizing the Call Control SDK behavior. * Allows disabling specific features and customizing the visual appearance of components. * * @properties * - `disableEndCallButton?: boolean` - Whether to disable the end call button * - `disabledDialButton?: boolean` - Whether to disable the dial button * - `disableCallTransferButton?: boolean` - Whether to disable the call transfer button * - `isDraggable?: boolean` - Whether the control panel should be draggable * - `disableSoftPhone?: boolean` - Whether to disable the soft phone iframe * - `disableConferenceButton?: boolean` - Whether to disable the conference button * - `disabled?: SxProps` - Custom styles for disabled button states * - `enabled?: SxProps` - Custom styles for enabled button states * - `outlined?: SxProps` - Custom styles for outlined button states * * @since 1.0.0 * @author CTI SDK Team */ interface SDKConfig { disableEndCallButton?: boolean; disableEndConference?: boolean; disabledDialButton?: boolean; enableSmsServices?: boolean; enableQueueName?: boolean; disableCallTransferButton?: boolean; isDraggable?: boolean; disableSoftPhone?: boolean; disableConferenceButton?: boolean; disabled?: any; enabled?: any; outlined?: any; } interface URLConfig { id?: string; baseURL: string; iframeURL: string; iframeAPIURL: string; password: string; webSocketURL: string; coreBaseURL: string; accessToken?: string; caroVoiceAIURL?: string; } /** * 🎭 Call Control Panel Props Interface * * @interface CallControlPanelProps * @description Props interface for the CallControlPanel component. * Defines the properties passed to the call control panel. * * @properties * - `onDataChange?: (data: CallData) => void` - Callback for call data changes * * @since 1.0.0 * @author CTI SDK Team */ interface CallControlPanelProps { onDataChange?: (data: CallData) => void; } // ============================================================================= // πŸ”§ HOOK EXPORTS // ============================================================================= /** * * This file contains TypeScript type definitions for the useEndCall custom hook * and its related interfaces. It provides comprehensive type safety and IntelliSense * support for developers using the CTI SDK call termination functionality. * * 🎯 Key Type Definitions: * - πŸ“ž EndCallPayload interface for call termination API data * - πŸ“ž useEndCall hook return type * - πŸ”„ Call termination function signature * - πŸ“Š State management types * - πŸ“… Callback scheduling types * * @author CTI SDK Team * @version 6.x.x * @since 1.0.0 */ /** * End Call Payload Interface * * @interface EndCallPayload * @description Defines the options for ending a call. All fields are optional β€” * any omitted field falls back to the current session/call state automatically. * * @properties * - `call_id?: string` - Convox call ID (defaults to active call's call_id) * - `agent_id?: string` - Agent identifier (defaults to logged-in agent) * - `set_followUp?: string` - Whether a follow-up is required: "Y" or "N" (default: "N") * - `callback_date?: string` - Scheduled callback date (YYYY-MM-DD) * - `callback_hrs?: number` - Scheduled callback hour (0–23) * - `callback_mins?: number` - Scheduled callback minute (0–59) * - `mobile_number?: string` - Customer phone number (defaults to active call's phone_number) * - `list_comments?: string` - Optional comments for the call log * - `call_reference_id?: string` - Call reference ID (defaults to active call's call_id) * - `disposition?: string` - Call outcome code (default: "RES") * - `line_number?: number` - Conference line number (default: 0) * - `reason?: string` - End reason sent to server (default: "normal") * - `is_mark_as_break?: boolean` - Whether agent is going on break after the call (sent in request body) * - `break_type?: string` - Break applied with `is_mark_as_break` (a backend break type from GET /cti/breaks); empty lets the backend pick its default post-call break * - `patientLog?: any` - Optional patient/contact log data * * @example * ```typescript * // Minimal β€” all defaults applied from session state * await endCall(); * * // With disposition and follow-up callback * await endCall({ * disposition: "RES", * set_followUp: "Y", * callback_date: "2026-05-20", * callback_hrs: 10, * callback_mins: 30, * }); * * // Agent going on break after call * await endCall({ disposition: "RES", is_mark_as_break: true }); * * // …on a named break from the tenant's breaks list * await endCall({ disposition: "RES", is_mark_as_break: true, break_type: "Lunch" }); * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface EndCallPayload { call_id?: string; agent_id?: string; set_followUp?: string; callback_date?: string; callback_hrs?: number; callback_mins?: number; mobile_number?: string; list_comments?: string; call_reference_id?: string; is_mark_as_break?: boolean; break_type?: string; disposition?: string; line_number?: number; reason?: string; patientLog?: any; } /** * πŸ“… End Call Data Interface * * @interface EndCallData * @description πŸ“Š Defines the structure for call termination input data * Contains disposition and callback information for ending calls * * @properties * - `disposition?: string` - πŸ“ Call outcome classification (default: "RES") * - `followUp?: string` - πŸ“… Follow-up requirement (default: "N") * - `callbackDate?: string` - πŸ“… Scheduled callback date (default: "") * - `callbackHrs?: string` - πŸ• Scheduled callback hour (default: "") * - `callbackMins?: string` - πŸ• Scheduled callback minute (default: "") * * @example * ```typescript * // Basic end call data * const endCallData: EndCallData = { * disposition: "RES", * followUp: "N" * }; * * // With callback scheduling * const endCallWithCallback: EndCallData = { * disposition: "RES", * followUp: "Y", * callbackDate: "2024-01-15", * callbackHrs: "14", * callbackMins: "30" * }; * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface EndCallData { /** * πŸ“ Call outcome classification * @description How the call ended (default: "RES" for Resolved) * @type {string | undefined} */ disposition?: string; /** * πŸ“… Follow-up requirement * @description Whether follow-up is required (default: "N" for No) * @type {string | undefined} */ followUp?: string; /** * πŸ“… Scheduled callback date * @description Date for callback scheduling (YYYY-MM-DD format) * @type {string | undefined} */ callbackDate?: string; /** * πŸ• Scheduled callback hour * @description Hour for callback scheduling (0-23) * @type {string | undefined} */ callbackHrs?: string; /** * πŸ• Scheduled callback minute * @description Minute for callback scheduling (0-59) * @type {string | undefined} */ callbackMins?: string; } /** * πŸ“ž Call Termination Function Type * * @type CallTerminationFunction * @description 🎯 Type definition for the call termination function * Handles call termination with disposition tracking and callback scheduling * * @param {EndCallData} data - πŸ“Š Call termination data containing disposition and callback info * @returns {Promise} Promise that resolves with API response data or rejects with error * * @example * ```typescript * const handleEndCall: CallTerminationFunction = async (data) => { * // Call termination logic * return await apiCall(data); * }; * ``` * * @since 1.0.0 * @author CTI SDK Team */ type CallTerminationFunction = (data: EndCallData) => Promise; /** * πŸ“Š Hook State Management Types * * @type HookStateTypes * @description πŸŽ›οΈ Type definitions for all hook state variables * Provides type safety for loading, success, error, and data states * * @since 1.0.0 * @author CTI SDK Team */ type HookStateTypes = { /** * ⏳ Loading state indicator * @description Boolean flag indicating if a call termination operation is in progress * @type {boolean} */ isLoading: boolean; /** * βœ… Success state indicator * @description Boolean flag indicating if the last call termination was successful * @type {boolean} */ isSuccess: boolean; /** * ❌ Error state indicator * @description Boolean flag indicating if the last call termination encountered an error * @type {boolean} */ isError: boolean; /** * πŸ›‘οΈ Error object * @description Contains the error object when a call termination fails * @type {any} */ error: any; /** * πŸ“Š Response data * @description Contains the response data from successful call terminations * @type {any} */ data: any; }; /** * πŸ“ž useEndCall Hook Return Type * * @interface UseEndCallReturn * @description 🎯 Complete return type for the useEndCall hook * Contains all functions and state for call termination functionality * * @properties * - `handleEndCall: CallTerminationFunction` - πŸ“ž Call termination function * - `isLoading: boolean` - ⏳ Loading state indicator * - `isSuccess: boolean` - βœ… Success state indicator * - `isError: boolean` - ❌ Error state indicator * - `error: any` - πŸ›‘οΈ Error object when call fails * - `data: any` - πŸ“Š Response data from successful calls * * @example * ```typescript * const EndCallButton = () => { * const hookReturn: UseEndCallReturn = useEndCall(); * const { * handleEndCall, * isLoading, * isSuccess, * isError, * error * } = hookReturn; * * // Use the hook functionality * }; * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface UseEndCallReturn extends HookStateTypes { /** * πŸ“ž Call termination function * @description Handles call termination with disposition tracking and callback scheduling * @type {CallTerminationFunction} */ handleEndCall: CallTerminationFunction; } /** * πŸ“ž End Call Custom Hook * * @function useEndCall * @description 🎯 Custom hook that provides comprehensive call termination functionality * for the CTI SDK. It handles call disposition capture, callback scheduling, * and proper call cleanup with intelligent state management and error handling. * * @returns {UseEndCallReturn} Hook return object containing: * - `handleEndCall: CallTerminationFunction` - πŸ“ž Call termination function * - `isLoading: boolean` - ⏳ Loading state indicator * - `isSuccess: boolean` - βœ… Success state indicator * - `isError: boolean` - ❌ Error state indicator * - `error: any` - πŸ›‘οΈ Error object when call fails * - `data: any` - πŸ“Š Response data from successful calls * * @example * ```typescript * // Basic usage in a component * const EndCallButton = () => { * const { * handleEndCall, * isLoading, * isSuccess, * isError, * error * } = useEndCall(); * * const endCall = async () => { * try { * const result = await handleEndCall({ * disposition: "RES", * followUp: "N" * }); * console.log('πŸ“ž Call ended:', result); * } catch (err) { * console.error('❌ End call failed:', err); * } * }; * * return ( * * ); * }; * ``` * * @features * - 🎯 Comprehensive call termination with disposition tracking * - πŸ“… Callback scheduling and follow-up management * - πŸ”„ Intelligent state cleanup and reset * - ⏳ Comprehensive loading state management * - πŸ›‘οΈ Robust error handling and recovery * - πŸ“Š Real-time state updates via SDK manager * - πŸ”„ Automatic call state management * * @since 1.0.0 * @author CTI SDK Team */ declare const useEndCall: () => UseEndCallReturn; /** * πŸ“ Disposition Types * * @type DispositionType * @description 🎯 Type definitions for call disposition values * Used for call outcome classification * * @since 1.0.0 * @author CTI SDK Team */ type DispositionType = string; /** * πŸ“… Follow-up Types * * @type FollowUpType * @description 🎯 Type definitions for follow-up requirement values * Used for callback scheduling * * @since 1.0.0 * @author CTI SDK Team */ type FollowUpType = string; /** * βš™οΈ Process Data Interface * * @interface ProcessData * @description πŸ“Š Type definition for process data structure * Contains information about the current process * * @properties * - `process_id: number` - πŸ”’ Process identifier * - `process_name: string` - πŸ“ Process name * * @since 1.0.0 * @author CTI SDK Team */ interface ProcessData { /** * πŸ”’ Process identifier * @description Unique identifier for the process * @type {number} */ process_id: number; /** * πŸ“ Process name * @description Human-readable name of the process * @type {string} */ process_name: string; } /** * πŸ“ž Call Data Interface * * @interface EndCallPayLoadData * @description πŸ“Š Type definition for call data structure * Contains information about the current call * * @properties * - `call_id: string` - πŸ”— Call reference identifier * - `phone_number: string` - πŸ“± Customer phone number * * @since 1.0.0 * @author CTI SDK Team */ interface EndCallPayLoadData { /** * πŸ”— Call reference identifier * @description Unique identifier for the call * @type {string} */ call_id: string; /** * πŸ“± Customer phone number * @description Phone number of the customer * @type {string} */ phone_number: string; } /** * πŸ“‹ Comprehensive Type Exports * * @description πŸ“¦ Re-exports all types for easy importing * Provides a single import point for all hook-related types * * @example * ```typescript * import { * EndCallPayload, * UseEndCallReturn, * CallTerminationFunction, * EndCallData * } from './useEndCall'; * ``` * * @since 1.0.0 * @author CTI SDK Team */ /** * * This file contains TypeScript type definitions for the useLogout custom hook * and its related interfaces. It provides comprehensive type safety and IntelliSense * support for developers using the CTI SDK logout functionality. * * 🎯 Key Type Definitions: * - πŸšͺ LogoutPayload interface for logout API data * - πŸšͺ useLogout hook return type * - πŸ”„ Logout function signature * - πŸ“Š State management types * - πŸ—‘οΈ Cleanup and storage management types * * @author CTI SDK Team * @version 6.x.x * @since 1.0.0 */ /** * πŸšͺ Logout Payload Interface * * @interface LogoutPayload * @description πŸ“Š Defines the structure for agent logout API payload data * Contains all necessary information for secure agent logout * * @properties * - `action: string` - 🎯 API action type ("LOGOUTUSER") * - `userId: string` - πŸ‘€ Agent identifier for logout * * @example * ```typescript * // Basic logout payload * const logoutPayload: LogoutPayload = { * action: "LOGOUTUSER", * userId: "agent123" * }; * * // Usage in component * const { logout } = useLogout(); * await logout(); * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface LogoutPayload { /** * 🎯 API action type * @description The action type for the logout API call * @type {string} */ action: string; /** * πŸ‘€ Agent identifier * @description Unique identifier for the agent being logged out * @type {string} */ userId: string; } /** * πŸšͺ Logout Function Type * * @type LogoutFunction * @description 🎯 Type definition for the logout function * Handles secure agent logout with comprehensive cleanup procedures * * @returns {Promise} Promise that resolves with API response data or rejects with error * * @example * ```typescript * const logout(); * ``` * * @since 1.0.0 * @author CTI SDK Team */ type LogoutFunction = () => Promise; /** * πŸ“Š Hook State Management Types * * @type LogoutHookStateTypes * @description πŸŽ›οΈ Type definitions for all hook state variables * Provides type safety for loading, success, error, and data states * * @since 1.0.0 * @author CTI SDK Team */ type LogoutHookStateTypes = { /** * ⏳ Loading state indicator * @description Boolean flag indicating if a logout operation is in progress * @type {boolean} */ isLoading: boolean; /** * βœ… Success state indicator * @description Boolean flag indicating if the last logout was successful * @type {boolean} */ isSuccess: boolean; /** * ❌ Error state indicator * @description Boolean flag indicating if the last logout encountered an error * @type {boolean} */ isError: boolean; /** * πŸ›‘οΈ Error object * @description Contains the error object when a logout fails * @type {any} */ error: any; /** * πŸ“Š Response data * @description Contains the response data from successful logout * @type {any} */ data: any; }; /** * πŸšͺ useLogout Hook Return Type * * @interface UseLogoutReturn * @description 🎯 Complete return type for the useLogout hook * Contains all functions and state for logout functionality * * @properties * - `logout: LogoutFunction` - πŸšͺ Logout function * - `isLoading: boolean` - ⏳ Loading state indicator * - `isSuccess: boolean` - βœ… Success state indicator * - `isError: boolean` - ❌ Error state indicator * - `error: any` - πŸ›‘οΈ Error object when logout fails * - `data: any` - πŸ“Š Response data from successful logout * * @example * ```typescript * const LogoutButton = () => { * const hookReturn: UseLogoutReturn = useLogout(); * const { * logout, * isLoading, * isSuccess, * isError, * error * } = hookReturn; * * // Use the hook functionality * }; * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface UseLogoutReturn extends LogoutHookStateTypes { /** * πŸšͺ Logout function * @description Handles secure agent logout with comprehensive cleanup procedures * @type {LogoutFunction} */ logout: LogoutFunction; } /** * πŸšͺ Logout Custom Hook * * @function useLogout * @description 🎯 Custom hook that provides comprehensive agent logout functionality * for the CTI SDK. It handles secure logout procedures, complete state cleanup, * and storage management with intelligent error handling and proper cleanup. * * @returns {UseLogoutReturn} Hook return object containing: * - `logout: LogoutFunction` - πŸšͺ Logout function * - `isLoading: boolean` - ⏳ Loading state indicator * - `isSuccess: boolean` - βœ… Success state indicator * - `isError: boolean` - ❌ Error state indicator * - `error: any` - πŸ›‘οΈ Error object when logout fails * - `data: any` - πŸ“Š Response data from successful logout * * @example * ```typescript * // Basic usage in a component * const LogoutButton = () => { * const { * logout, * isLoading, * isSuccess, * isError, * error * } = useLogout(); * * const handleLogout = async () => { * try { * const result = await logout(); * console.log('πŸšͺ Logout successful:', result); * // Redirect to login page or handle success * } catch (err) { * console.error('❌ Logout failed:', err); * } * }; * * return ( * * ); * }; * ``` * * @features * - πŸšͺ Secure agent logout with API validation * - πŸ—‘οΈ Complete state cleanup and reset * - πŸ’Ύ Storage management (localStorage & sessionStorage) * - ⏳ Comprehensive loading state management * - πŸ›‘οΈ Robust error handling and recovery * - πŸ“Š Real-time state updates via SDK manager * - πŸ”„ Automatic storage cleanup * * @since 1.0.0 * @author CTI SDK Team */ declare const useLogout: () => UseLogoutReturn; /** * πŸ” Authorization Token Custom Hook * * @function useGetAuthorizationToken * @description 🎯 Custom hook that provides reactive access to the current SDK authorization token. * Automatically updates when the token changes, making it perfect for external API calls * and authentication headers. * * @returns {string | undefined} Current authorization token or undefined if not available * * @example * ```typescript * // Basic usage in a component * const ApiCallComponent = () => { * const token = useGetAuthorizationToken(); * * const makeExternalApiCall = async () => { * if (!token) { * console.error('No authorization token available'); * return; * } * * try { * const response = await fetch('/api/external', { * headers: { * 'Authorization': `Bearer ${token}`, * 'Content-Type': 'application/json' * } * }); * const data = await response.json(); * console.log('External API response:', data); * } catch (error) { * console.error('API call failed:', error); * } * }; * * return ( * * ); * }; * ``` * * @example * ```typescript * // Usage with axios * const ApiService = () => { * const token = useGetAuthorizationToken(); * * useEffect(() => { * if (token) { * // Configure axios with the token * axios.defaults.headers.common['Authorization'] = `Bearer ${token}`; * } * }, [token]); * * return null; // This is just for token management * }; * ``` * * * @since 1.0.0 * @author CTI SDK Team */ declare const useGetAuthorizationToken: () => string | undefined; /** * πŸ“ž Caller Data Custom Hook * * @function useGetCallerData * @description 🎯 Custom hook that provides reactive access to current call data. * This is an independent alternative to the CallControlPanel's onDataChange prop, * allowing you to access call information anywhere in your application without * depending on the CallControlPanel component. * * @returns {CallData} Current call data object containing all available call information * * @example * ```typescript * // Basic usage in a component * const CallStatusWidget = () => { * const callerData = useGetCallerData(); * * return ( *
*

Current Call Status

* {callerData.status === "ONCALL" ? ( *
*

πŸ“ž Active Call: {callerData.phone_number}

*

Agent: {callerData.agent_id}

*

Process: {callerData.process_name}

*

Call ID: {callerData.callReferenceId}

*
* ) : ( *

No active call

* )} *
* ); * }; * ``` * * @example * ```typescript * // Usage for call analytics * const CallAnalytics = () => { * const callerData = useGetCallerData(); * * useEffect(() => { * if (callerData.status === "ONCALL") { * // Track call start * analytics.track('call_started', { * phone_number: callerData.phone_number, * agent_id: callerData.agent_id, * process_name: callerData.process_name * }); * } * }, [callerData.status]); * * return null; // This is just for analytics * }; * ``` * * * * @returns_data_structure * ```typescript * { * phone_number: string, // Phone number involved in the call * status: string, // Current call status (ONCALL, RINGING, WRAPUP, etc.) * callReferenceId: string, // Unique identifier for the call * agent_id: string, // ID of the agent handling the call * process_id: string, // Process identifier for the call * process_name: string // Name of the process handling the call * } * ``` * * @since 1.0.0 * @author CTI SDK Team */ declare const useGetCallerData: () => CallData; /** * πŸ—ƒοΈ SDK State Interface * * @interface SDKState * @description πŸ“Š Type definition for the SDK state structure * Used internally by the hook to access agent and call data * * @properties * - `agentId: string` - πŸ‘€ Agent identifier * - `process: ProcessData` - βš™οΈ Process information * - `callData: EndCallData` - πŸ“ž Current call data * * @since 1.0.0 * @author CTI SDK Team */ interface SDKState { /** * πŸ‘€ Agent identifier * @description Unique identifier for the current agent * @type {string} */ agentId: string; /** * βš™οΈ Process information * @description Information about the current process * @type {ProcessData} */ process: ProcessData; /** * πŸ“ž Current call data * @description Data about the current call * @type {EndCallData} */ callData: EndCallData; } /** * πŸ—ƒοΈ SDK State Interface * * @interface SDKState * @description πŸ“Š Type definition for the SDK state structure * Used internally by the hook to access agent data * * @properties * - `agentId: string` - πŸ‘€ Agent identifier * * @since 1.0.0 * @author CTI SDK Team */ interface SDKState { /** * πŸ‘€ Agent identifier * @description Unique identifier for the current agent * @type {string} */ agentId: string; } /** * πŸ—‘οΈ Storage Management Types * * @type StorageType * @description 🎯 Type definitions for storage management * Used for localStorage and sessionStorage operations * * @since 1.0.0 * @author CTI SDK Team */ type StorageType = "localStorage" | "sessionStorage"; /** * πŸ”„ Cleanup Operation Types * * @type CleanupOperation * @description 🎯 Type definitions for cleanup operations * Used for state and storage cleanup procedures * * @since 1.0.0 * @author CTI SDK Team */ type CleanupOperation = "clearStorage" | "resetState" | "clearAll"; /** * πŸ“‹ Comprehensive Type Exports * * @description πŸ“¦ Re-exports all types for easy importing * Provides a single import point for all hook-related types * * @example * ```typescript * import { * LogoutPayload, * UseLogoutReturn, * LogoutFunction, * SDKState * } from './useLogout'; * ``` * * @since 1.0.0 * @author CTI SDK Team */ /** * @fileoverview πŸ“ž TypeScript Declaration File for useClickToCall Hook * * This file contains TypeScript type definitions for the useClickToCall custom hook * and its related interfaces. It provides comprehensive type safety and IntelliSense * support for developers using the CTI SDK. * * 🎯 Key Type Definitions: * - πŸ“± StartCallPayload interface for call initiation data * - πŸ“ž useClickToCall hook return type * - πŸ”„ Call initiation function signature * - πŸ“Š State management types * * @author CTI SDK Team * @version 6.x.x * @since 1.0.0 */ /** * πŸ“± Start Call Payload Interface * * @interface StartCallPayload * @description πŸ“Š Defines the structure for call initiation payload data * Contains the mobile number required to initiate a call * * @properties * - `mobileNumber: string` - πŸ“± The phone number to call (required) * * @example * ```typescript * // Basic call initiation payload * const callPayload: StartCallPayload = { * mobileNumber: "1234567890" * }; * * // Usage in component * const { handleStartCall } = useClickToCall(); * await handleStartCall({ mobileNumber: "9876543210" }); * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface StartCallPayload { /** * πŸ“± Phone number to call * @description The mobile number that will be called * @type {string} */ mobileNumber: string; /** Optional user id; defaults to the logged-in agent id when omitted. */ user?: string; /** Optional auto-answer flag; defaults to false when omitted. */ auto_answer?: boolean; /** Optional Convox call id passthrough. */ call_id?: string; /** Optional caller-provided reference id. */ reference_id?: string; /** Optional source identifier (e.g. campaign, dialpad). */ call_source?: string; /** Optional case id passthrough. */ caseId?: string; /** Whether the call is being made during wrap-up. */ isWrapup?: boolean; /** Convox call UUID of the parent call; used for wrap-up chaining. */ parentCallUuid?: string; } interface ConferenceCallPayload { mobileNumber: string; lineNumber?: number; } /** * πŸ“ž Call Initiation Function Type * * @type CallInitiationFunction * @description 🎯 Type definition for the call initiation function * Handles both regular calls and conference calls based on agent state * * @param {StartCallPayload} data - πŸ“Š Call initiation data containing mobile number * @returns {Promise} Promise that resolves with API response data or rejects with error * * @example * ```typescript * const handleStartCall({ * mobileNumber: "1234567890" * }) * ``` * * @since 1.0.0 * @author CTI SDK Team */ type CallInitiationFunction = (data: StartCallPayload) => Promise; /** * πŸ“Š Hook State Management Types * * @type StartCalltHookStateTypes * @description πŸŽ›οΈ Type definitions for all hook state variables * Provides type safety for loading, success, error, and data states * * @since 1.0.0 * @author CTI SDK Team */ type StartCalltHookStateTypes = { /** * ⏳ Loading state indicator * @description Boolean flag indicating if a call operation is currently in progress * @type {boolean} */ isLoading: boolean; /** * βœ… Success state indicator * @description Boolean flag indicating if the last call operation was successful * @type {boolean} */ isSuccess: boolean; /** * ❌ Error state indicator * @description Boolean flag indicating if the last call operation encountered an error * @type {boolean} */ isError: boolean; /** * πŸ›‘οΈ Error object * @description Contains the error object when a call operation fails * @type {any} */ error: any; /** * πŸ“Š Response data * @description Contains the response data from successful call operations * @type {any} */ data: any; }; /** * πŸ“ž useClickToCall Hook Return Type * * @interface UseClickToCallReturn * @description 🎯 Complete return type for the useClickToCall hook * Contains all functions and state for call initiation functionality * * @properties * - `handleStartCall: CallInitiationFunction` - πŸ“ž Call initiation function * - `isLoading: boolean` - ⏳ Loading state indicator * - `isSuccess: boolean` - βœ… Success state indicator * - `isError: boolean` - ❌ Error state indicator * - `error: any` - πŸ›‘οΈ Error object when call fails * - `data: any` - πŸ“Š Response data from successful calls * * @example * ```typescript * const CallButton = () => { * const hookReturn: UseClickToCallReturn = useClickToCall(); * const { * handleStartCall, * isLoading, * isSuccess, * isError, * error * } = hookReturn; * * // Use the hook functionality * }; * ``` * * @since 1.0.0 * @author CTI SDK Team */ interface UseClickToCallReturn extends StartCalltHookStateTypes { /** * πŸ“ž Call initiation function * @description Handles call initiation with intelligent routing based on agent state * @type {CallInitiationFunction} */ handleStartCall: CallInitiationFunction; } /** * πŸ“ž Click-to-Call Custom Hook * * @function useClickToCall * @description 🎯 Custom hook that provides comprehensive call initiation functionality * for the CTI SDK. It intelligently handles both regular calls and conference calls * based on the current agent state, with proper loading states and error handling. * * @returns {UseClickToCallReturn} Hook return object containing: * - `handleStartCall: CallInitiationFunction` - πŸ“ž Call initiation function * - `isLoading: boolean` - ⏳ Loading state indicator * - `isSuccess: boolean` - βœ… Success state indicator * - `isError: boolean` - ❌ Error state indicator * - `error: any` - πŸ›‘οΈ Error object when call fails * - `data: any` - πŸ“Š Response data from successful calls * * @example * ```typescript * // Basic usage in a component * const CallButton = () => { * const { * handleStartCall, * isLoading, * isSuccess, * isError, * error * } = useClickToCall(); * * const makeCall = async () => { * try { * const result = await handleStartCall({ * mobileNumber: "1234567890" * }); * console.log('πŸ“ž Call initiated:', result); * } catch (err) { * console.error('❌ Call failed:', err); * } * }; * * return ( * * ); * }; * ``` * * @features * - 🎯 Intelligent call routing based on agent state * - πŸ“± Regular call initiation for idle agents * - πŸ‘₯ Conference call initiation for busy agents * - ⏳ Comprehensive loading state management * - πŸ›‘οΈ Robust error handling and recovery * - πŸ“Š Real-time state updates via SDK manager * - πŸ”„ Automatic conference dialog management * * @since 1.0.0 * @author CTI SDK Team */ declare const useClickToCall: () => UseClickToCallReturn; /** * πŸ“Š Agent State Types * * @type AgentStatus * @description 🎯 Type definitions for agent status values * Used internally by the hook to determine call routing logic * * @since 1.0.0 * @author CTI SDK Team */ type AgentStatus = string; /** * πŸ“ž Conference Line Interface * * @interface ConferenceLine * @description πŸ“Š Type definition for conference line data structure * Used internally by the hook for conference call management * * @properties * - `line: number` - πŸ“ž Line number identifier * - `status: AgentStatus` - πŸ“Š Current line status * - `isCallStart: boolean` - βœ… Whether call is active on this line * - `phone?: string` - πŸ“± Phone number for this line (optional) * * @since 1.0.0 * @author CTI SDK Team */ interface ConferenceLine { /** * πŸ“ž Line number identifier * @description Unique identifier for the conference line * @type {number} */ line: number; /** * πŸ“Š Current line status * @description Status of the conference line * @type {AgentStatus} */ status: AgentStatus; /** * βœ… Whether call is active on this line * @description Flag indicating if a call is currently active * @type {boolean} */ isCallStart: boolean; /** * πŸ“± Phone number for this line * @description Phone number associated with this line (optional) * @type {string | undefined} */ phone?: string; } /** * πŸ“ž Call Data Interface * * @interface StartCalltData * @description πŸ“Š Type definition for call data structure * Contains information about the current call * * @properties * - `status: AgentStatus` - πŸ“Š Current call status * - `agent_id: string` - πŸ‘€ Agent identifier * - `process_name: string` - βš™οΈ Process name * * @since 1.0.0 * @author CTI SDK Team */ interface StartCalltData { /** * πŸ“Š Current call status * @description Status of the current call * @type {AgentStatus} */ status: AgentStatus; /** * πŸ‘€ Agent identifier * @description Unique identifier for the agent * @type {string} */ agent_id: string; /** * βš™οΈ Process name * @description Name of the current process * @type {string} */ process_name: string; } /** * πŸ“‘ API Response Interface * * @interface APIResponse * @description πŸ“Š Type definition for API response structure * Used for type safety in API call responses * * @properties * - `data: any` - πŸ“Š Response data * - `status: number` - πŸ“Š HTTP status code * - `message?: string` - πŸ“ Optional response message * * @since 1.0.0 * @author CTI SDK Team */ interface APIResponse { /** * πŸ“Š Response data * @description The main response data from the API * @type {any} */ data: any; /** * πŸ“Š HTTP status code * @description HTTP status code of the response * @type {number} */ status: number; /** * πŸ“ Optional response message * @description Optional message from the API response * @type {string | undefined} */ message?: string; } /** * πŸ“‘ API Response Interface * * @interface APIResponse * @description πŸ“Š Type definition for API response structure * Used for type safety in API call responses * * @properties * - `data: any` - πŸ“Š Response data * - `status: number` - πŸ“Š HTTP status code * - `message?: string` - πŸ“ Optional response message * * @since 1.0.0 * @author CTI SDK Team */ interface APIResponse { /** * πŸ“Š Response data * @description The main response data from the API * @type {any} */ data: any; /** * πŸ“Š HTTP status code * @description HTTP status code of the response * @type {number} */ status: number; /** * πŸ“ Optional response message * @description Optional message from the API response * @type {string | undefined} */ message?: string; } /** * πŸ“‘ API Response Interface * * @interface APIResponse * @description πŸ“Š Type definition for API response structure * Used for type safety in API call responses * * @properties * - `data: any` - πŸ“Š Response data * - `status: number` - πŸ“Š HTTP status code * - `message?: string` - πŸ“ Optional response message * * @since 1.0.0 * @author CTI SDK Team */ interface APIResponse { /** * πŸ“Š Response data * @description The main response data from the API * @type {any} */ data: any; /** * πŸ“Š HTTP status code * @description HTTP status code of the response * @type {number} */ status: number; /** * πŸ“ Optional response message * @description Optional message from the API response * @type {string | undefined} */ message?: string; } /** * πŸ›‘οΈ Error Response Interface * * @interface ErrorResponse * @description πŸ“Š Type definition for error response structure * Used for type safety in error handling * * @properties * - `message: string` - πŸ“ Error message * - `code?: string` - πŸ”’ Optional error code * - `details?: any` - πŸ“Š Optional error details * * @since 1.0.0 * @author CTI SDK Team */ interface ErrorResponse { /** * πŸ“ Error message * @description Human-readable error message * @type {string} */ message: string; /** * πŸ”’ Optional error code * @description Optional error code for programmatic handling * @type {string | undefined} */ code?: string; /** * πŸ“Š Optional error details * @description Optional additional error details * @type {any} */ details?: any; } /** * πŸ›‘οΈ Error Response Interface * * @interface ErrorResponse * @description πŸ“Š Type definition for error response structure * Used for type safety in error handling * * @properties * - `message: string` - πŸ“ Error message * - `code?: string` - πŸ”’ Optional error code * - `details?: any` - πŸ“Š Optional error details * * @since 1.0.0 * @author CTI SDK Team */ interface ErrorResponse { /** * πŸ“ Error message * @description Human-readable error message * @type {string} */ message: string; /** * πŸ”’ Optional error code * @description Optional error code for programmatic handling * @type {string | undefined} */ code?: string; /** * πŸ“Š Optional error details * @description Optional additional error details * @type {any} */ details?: any; } /** * πŸ›‘οΈ Error Response Interface * * @interface ErrorResponse * @description πŸ“Š Type definition for error response structure * Used for type safety in error handling * * @properties * - `message: string` - πŸ“ Error message * - `code?: string` - πŸ”’ Optional error code * - `details?: any` - πŸ“Š Optional error details * * @since 1.0.0 * @author CTI SDK Team */ interface ErrorResponse { /** * πŸ“ Error message * @description Human-readable error message * @type {string} */ message: string; /** * πŸ”’ Optional error code * @description Optional error code for programmatic handling * @type {string | undefined} */ code?: string; /** * πŸ“Š Optional error details * @description Optional additional error details * @type {any} */ details?: any; } // ============================================================================= // ⚑ FRAMEWORK-AGNOSTIC ACTION EXPORTS (for Angular / non-React consumers) // ============================================================================= type SupervisorMonitorMode = "listen" | "whisper" | "barge"; interface StartMonitoringPayload { call_id: string; mode: SupervisorMonitorMode; supervisor_extension?: string; agent_extension?: string; } interface StopMonitoringPayload { call_uuid: string; session_id?: string; } interface ChangeModePayload { call_uuid: string; mode: SupervisorMonitorMode; session_id?: string; } declare function clickToCall(payload: StartCallPayload): Promise; declare function clickToConference(payload: ConferenceCallPayload): Promise; declare function endCall(options?: EndCallPayload): Promise; declare function logout(): Promise; declare function startMonitoring(payload: StartMonitoringPayload): Promise; declare function stopMonitoring(payload: StopMonitoringPayload): Promise; declare function changeMonitorMode(payload: ChangeModePayload): Promise; declare function setTransferLeadData(data: any): void; // ============================================================================= // βš›οΈ REACT HOOKS // ============================================================================= interface UseClickToConferenceReturn { handleStartConferenceCall: (payload: ConferenceCallPayload) => Promise; isLoading: boolean; isSuccess: boolean; isError: boolean; error: any; data: any; } declare function useClickToConference(): UseClickToConferenceReturn; // ============================================================================= // πŸ“Š CALL MONITORING HOOK // ============================================================================= interface UseCallMonitoringReturn { startMonitoring: (payload: StartMonitoringPayload) => Promise; stopMonitoring: (payload: StopMonitoringPayload) => Promise; changeMode: (payload: ChangeModePayload) => Promise; isLoading: boolean; isSuccess: boolean; isError: boolean; error: any; data: any; } declare const useCallMonitoring: () => UseCallMonitoringReturn; // ============================================================================= // πŸ—ƒοΈ SDK STATE HOOK // ============================================================================= declare const useSDKState: () => any; // ============================================================================= // πŸ›‘οΈ ENTITLEMENTS / PERMISSIONS // ============================================================================= /** "*" wildcard literal used in permission and menu codes. */ declare const SDK_WILDCARD: "*"; /** Menu entitlement codes (used by SDKPages and SDKPermissionGuard). */ declare const SDK_MENU_CODES: { readonly WILDCARD: "*"; readonly CALL_HISTORY: "call_history"; readonly CAMPAIGNS: "dialer_auto"; readonly LOGIN_REPORT: "login_report"; readonly CDR_REPORT: "cdr_report"; readonly AGENT_PERFORMANCE_REPORT: "agent_performance"; readonly AGENT_DETAIL_REPORT: "agent_detail"; readonly LIVE_STATUS: "live_status"; readonly MANAGEMENT_DASHBOARD: "management_dashboard"; readonly CARO_VOICE_AI: "caro_voice_ai"; readonly QUALITY_AUDIT_DASHBOARD: "quality_audit_dashboard"; readonly CARO_VOICE_AI_DASHBOARD: "caro_voice_ai_dashboard"; readonly LEAD_INTEGRATIONS: "lead_integrations"; }; /** SDK permission codes β€” feature-level entitlements. */ declare const SDK_PERMISSIONS: { readonly WILDCARD: "*"; readonly CALLS: "calls"; readonly CALL_TRANSFER: "call_transfer"; readonly CALL_CONFERENCE: "call_conference"; readonly CALL_INBOUND: "call_inbound"; readonly CALL_OUTBOUND: "call_outbound"; readonly CONFERENCE: "call_conference"; readonly TRANSFER_BLIND: "call_transfer_blind"; readonly TRANSFER_ATTENDED: "call_transfer_attended"; readonly TRANSFER_WARM: "call_transfer_warm"; readonly CAMPAIGNS_CREATE: "campaigns:create"; readonly CAMPAIGNS_READ: "campaigns:read"; readonly CAMPAIGNS_UPDATE: "campaigns:update"; readonly CAMPAIGNS_DELETE: "campaigns:delete"; readonly CAMPAIGNS_MANAGE: "campaigns:manage"; readonly CAMPAIGNS_CONTROL: "campaigns:control"; readonly CAMPAIGNS_LEADS_CREATE: "leads:create"; readonly CAMPAIGNS_LEADS_READ: "leads:read"; readonly CAMPAIGNS_LEADS_DELETE: "leads:delete"; readonly CAMPAIGNS_LEADS_IMPORT: "leads:import"; readonly LEAD_INTEGRATIONS_CREATE: "lead_integrations:create"; readonly LEAD_INTEGRATIONS_READ: "lead_integrations:read"; readonly LEAD_INTEGRATIONS_UPDATE: "lead_integrations:update"; readonly LEAD_INTEGRATIONS_DELETE: "lead_integrations:delete"; readonly LEAD_INTEGRATIONS_MANAGE: "lead_integrations:manage"; readonly REPORTS_AGENT_LOGIN_READ: "reports:agent_login:read"; readonly REPORTS_AGENT_LOGIN_EXPORT: "reports:agent_login:export"; readonly REPORTS_AGENT_LOGIN_MANAGE: "reports:agent_login:manage"; readonly REPORTS_CDR_READ: "reports:cdr:read"; readonly REPORTS_CDR_EXPORT: "reports:cdr:export"; readonly REPORTS_CDR_MANAGE: "reports:cdr:manage"; readonly REPORTS_AGENT_PERFORMANCE_READ: "reports:agent_performance:read"; readonly REPORTS_AGENT_PERFORMANCE_EXPORT: "reports:agent_performance:export"; readonly REPORTS_AGENT_PERFORMANCE_MANAGE: "reports:agent_performance:manage"; readonly SUPERVISOR_MONITOR_LISTEN: "supervisor:monitor:listen"; readonly SUPERVISOR_MONITOR_WHISPER: "supervisor:monitor:whisper"; readonly SUPERVISOR_MONITOR_BARGE: "supervisor:monitor:barge"; readonly QUALITY_AUDIT_DASHBOARD_READ: "quality_audit_dashboard:read"; readonly CARO_VOICE_AI_DASHBOARD_READ: "caro_voice_ai_dashboard:read"; readonly REPORTS_CALL_HISTORY_READ: "reports:call_history:read"; readonly DASHBOARD_LIVE_STATUS_READ: "dashboard:live_status:read"; readonly DASHBOARD_LIVE_STATUS_MANAGE: "dashboard:live_status:manage"; readonly MANAGEMENT_DASHBOARD_READ: "management_dashboard:read"; readonly CARO_VOICE_AI_READ: "caro_voice_ai:read"; /** Role landing access codes β€” each grants its landing page on its own. */ readonly AGENT_ACCESS: "agent_access:access"; readonly SUPERVISOR_ACCESS: "supervisor_access:access"; }; // ─── Entitlement types ──────────────────────────────────────────────────────── interface SDKBit { code: string; enabled: boolean; } interface SDKEntitlement { enabled: boolean; items: SDKBit[]; } interface SDKEntitlements { calls?: SDKEntitlement; call_controls?: SDKEntitlement; call_transfer?: SDKEntitlement; call_conference?: SDKEntitlement; [key: string]: any; } interface SDKPermissionState { sdk: SDKEntitlements | null; isLoaded: boolean; error: Error | null; } interface ControlsFromPermissions { disabledDialButton: boolean; disableEndCallButton: boolean; disableCallTransferButton: boolean; disableBlindTransfer: boolean; disableAttendedTransfer: boolean; disableWarmTransfer: boolean; disableConferenceButton: boolean; disableHoldButton: boolean; disableMuteButton: boolean; disabledMoreOptionsButton: boolean; } interface SDKPermissionContextValue { state: SDKPermissionState; isBitEnabled: (category: keyof SDKEntitlements, bitCode: string) => boolean; getControlsConfig: () => ControlsFromPermissions; } // ─── useSDKPermissions hook ─────────────────────────────────────────────────── interface SDKPermissionsHook { permissions: string[]; menuEntitlements: Array<{ code: string; name: string; enabled: boolean }>; isLoaded: boolean; hasPermission: (permission: string) => boolean; hasAnyPermission: (permissions: string[]) => boolean; hasAllPermissions: (permissions: string[]) => boolean; hasMenuFeature: (code: string) => boolean; } declare function useSDKPermissions(): SDKPermissionsHook; // ─── Permission guard & access denied components ────────────────────────────── interface SDKPermissionGuardProps { children?: React.ReactNode; /** Single permission code (e.g. "calls:inbound") */ permission?: string; /** Multiple permission codes β€” ANY match grants access by default */ permissions?: string[]; /** When true, ALL permissions must be granted */ requireAll?: boolean; /** One or more menu feature codes β€” ANY match grants access by default */ menuFeature?: string | string[]; /** When true, ALL menu features must be enabled */ requireAllMenus?: boolean; /** * Permission codes that grant access on their own, short-circuiting both the * menu-entitlement and permission gates (which are otherwise ANDed). Used for * the role access codes ("agent_access:access", "supervisor_access:access") on * the page that login lands on right after signing in. */ accessOverride?: string | string[]; /** Custom fallback rendered when access is denied */ fallback?: React.ReactNode; /** Show the default Access Denied UI when denied. Defaults to true. */ showFallback?: boolean; /** Callback fired when the guard denies access */ onDenied?: () => void; } declare const SDKPermissionGuard: React.FC; interface SDKAccessDeniedProps { message?: string; } declare const SDKAccessDenied: React.FC; export type { APIResponse, AgentDetailReportProps, AgentStatus, AuditReportDialogProps, AuditReportUrlResolver, CallControlIframeProps, CallControlPanelProps, CallData, CallInitiationFunction, CallTerminationFunction, ChangeModePayload, CleanupOperation, ConferenceCallPayload, ConferenceLine, ControlsFromPermissions, DispositionType, EndCallData, EndCallPayLoadData, EndCallPayload, ErrorResponse, FollowUpType, HookStateTypes, InitSDKParams, LiveStatusPageProps, LogoutFunction, LogoutHookStateTypes, LogoutPayload, ProcessData, SDKAccessDeniedProps, SDKBit, SDKConfig, SDKEntitlement, SDKEntitlements, SDKInitResult, SDKPermissionContextValue, SDKPermissionGuardProps, SDKPermissionState, SDKPermissionsHook, SDKState, StartCallPayload, StartCalltData, StartCalltHookStateTypes, StartMonitoringPayload, StopMonitoringPayload, StorageType, SupervisorMonitorMode, URLConfig, UseCallMonitoringReturn, UseClickToCallReturn, UseClickToConferenceReturn, UseEndCallReturn, UseLogoutReturn } export { AgentDetailReport, AuditReportDialog, CallControlIframe, CallControlPanel, SDKAccessDenied, SDKPages, SDKPermissionGuard, SDKStateManager, SDK_MENU_CODES, SDK_PERMISSIONS, SDK_WILDCARD, changeMonitorMode, clickToCall, clickToConference, endCall, getSDKVersion, initSDK, isSDKInitialized, logout, sdkStateManager, setAuditReportUrlResolver, setTransferLeadData, startMonitoring, stopMonitoring, useCallMonitoring, useClickToCall, useClickToConference, useEndCall, useGetAuthorizationToken, useGetCallerData, useLogout, useSDKPermissions, useSDKState };