@campxdev/campx-web-utils 2.0.13 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/types/src/components/Exotel/CallButton.d.ts +10 -0
  3. package/dist/cjs/types/src/components/Exotel/CallDispositionForm.d.ts +29 -0
  4. package/dist/cjs/types/src/components/Exotel/ExotelPhone.d.ts +10 -0
  5. package/dist/cjs/types/src/components/Exotel/ExotelWrapper.d.ts +14 -0
  6. package/dist/cjs/types/src/components/Exotel/MicrophonePermission.d.ts +6 -0
  7. package/dist/cjs/types/src/components/Exotel/index.d.ts +6 -0
  8. package/dist/cjs/types/src/config/index.d.ts +1 -0
  9. package/dist/cjs/types/src/config/voip.config.d.ts +18 -0
  10. package/dist/cjs/types/src/constants/exotel.constants.d.ts +7 -0
  11. package/dist/cjs/types/src/providers/ExotelProvider.d.ts +79 -0
  12. package/dist/cjs/types/src/providers/VoIPProvider.d.ts +33 -0
  13. package/dist/cjs/types/src/providers/index.d.ts +2 -0
  14. package/dist/cjs/types/src/services/crypto/CryptoService.d.ts +23 -0
  15. package/dist/cjs/types/src/services/exotel/ExotelService.d.ts +47 -0
  16. package/dist/cjs/types/src/services/exotel/api.d.ts +158 -0
  17. package/dist/cjs/types/src/services/exotel/index.d.ts +2 -0
  18. package/dist/cjs/types/src/utils/exotel/formatters.d.ts +8 -0
  19. package/dist/cjs/types/src/utils/exotel/index.d.ts +1 -0
  20. package/dist/esm/index.js +2 -2
  21. package/dist/esm/types/src/components/Exotel/CallButton.d.ts +10 -0
  22. package/dist/esm/types/src/components/Exotel/CallDispositionForm.d.ts +29 -0
  23. package/dist/esm/types/src/components/Exotel/ExotelPhone.d.ts +10 -0
  24. package/dist/esm/types/src/components/Exotel/ExotelWrapper.d.ts +14 -0
  25. package/dist/esm/types/src/components/Exotel/MicrophonePermission.d.ts +6 -0
  26. package/dist/esm/types/src/components/Exotel/index.d.ts +6 -0
  27. package/dist/esm/types/src/config/index.d.ts +1 -0
  28. package/dist/esm/types/src/config/voip.config.d.ts +18 -0
  29. package/dist/esm/types/src/constants/exotel.constants.d.ts +7 -0
  30. package/dist/esm/types/src/providers/ExotelProvider.d.ts +79 -0
  31. package/dist/esm/types/src/providers/VoIPProvider.d.ts +33 -0
  32. package/dist/esm/types/src/providers/index.d.ts +2 -0
  33. package/dist/esm/types/src/services/crypto/CryptoService.d.ts +23 -0
  34. package/dist/esm/types/src/services/exotel/ExotelService.d.ts +47 -0
  35. package/dist/esm/types/src/services/exotel/api.d.ts +158 -0
  36. package/dist/esm/types/src/services/exotel/index.d.ts +2 -0
  37. package/dist/esm/types/src/utils/exotel/formatters.d.ts +8 -0
  38. package/dist/esm/types/src/utils/exotel/index.d.ts +1 -0
  39. package/dist/index.d.ts +357 -3
  40. package/dist/styles.css +337 -47
  41. package/dist/types/exotel-crm-websdk.d.ts +46 -0
  42. package/export.ts +6 -0
  43. package/package.json +4 -1
  44. package/src/components/Exotel/CallButton.tsx +164 -0
  45. package/src/components/Exotel/CallDispositionForm.tsx +213 -0
  46. package/src/components/Exotel/ExotelPhone.tsx +482 -0
  47. package/src/components/Exotel/ExotelWrapper.tsx +80 -0
  48. package/src/components/Exotel/MicrophonePermission.tsx +97 -0
  49. package/src/components/Exotel/index.ts +10 -0
  50. package/src/config/index.ts +1 -0
  51. package/src/config/voip.config.ts +26 -0
  52. package/src/constants/exotel.constants.ts +7 -0
  53. package/src/providers/ExotelProvider.tsx +526 -0
  54. package/src/providers/VoIPProvider.tsx +143 -0
  55. package/src/providers/index.ts +2 -0
  56. package/src/selectors/ResearchStageSelector.tsx +1 -0
  57. package/src/services/crypto/CryptoService.ts +112 -0
  58. package/src/services/exotel/ExotelService.ts +238 -0
  59. package/src/services/exotel/api.ts +319 -0
  60. package/src/services/exotel/index.ts +2 -0
  61. package/src/utils/exotel/formatters.ts +17 -0
  62. package/src/utils/exotel/index.ts +1 -0
  63. package/types/exotel-crm-websdk.d.ts +46 -0
@@ -0,0 +1,47 @@
1
+ import { CallEventData } from '@exotel-npm-dev/exotel-ip-calling-crm-websdk';
2
+ export type PermissionStatus = 'granted' | 'denied' | 'prompt' | 'unknown';
3
+ declare class ExotelService {
4
+ private static instance;
5
+ private exotelSDK;
6
+ private webPhone;
7
+ private callListeners;
8
+ private registerListeners;
9
+ private sessionListeners;
10
+ private permissionStatus;
11
+ static getInstance(): ExotelService;
12
+ /**
13
+ * Initialize the Exotel SDK
14
+ * @param accessToken - The access token for authentication
15
+ * @param agentUserId - The user ID of the agent
16
+ * @param autoConnectVOIP - Whether to automatically connect VOIP (default: true)
17
+ * @returns boolean indicating success
18
+ */
19
+ initialize(accessToken: string, agentUserId: string, autoConnectVOIP?: boolean): Promise<boolean>;
20
+ checkAudioPermissions(): Promise<boolean>;
21
+ requestMicrophoneAccess(): Promise<boolean>;
22
+ makeCall(phoneNumber: string): Promise<any>;
23
+ acceptCall(): Promise<void>;
24
+ hangupCall(): void;
25
+ /**
26
+ * Reject an incoming call before accepting it.
27
+ * Note: Exotel SDK only has HangupCall - no separate RejectCall method.
28
+ * HangupCall internally calls webrtcSIPPhone.rejectCall() -> phone.sipHangUp()
29
+ */
30
+ rejectCall(): void;
31
+ toggleHold(): void;
32
+ toggleMute(): void;
33
+ sendDTMF(digit: string): void;
34
+ registerDevice(): Promise<void>;
35
+ unregisterDevice(): void;
36
+ getPermissionStatus(): PermissionStatus;
37
+ private handleCallEvent;
38
+ private handleRegisterEvent;
39
+ private handleSessionEvent;
40
+ addCallListener(listener: (event: string, data: CallEventData) => void): void;
41
+ removeCallListener(listener: (event: string, data: CallEventData) => void): void;
42
+ addRegisterListener(listener: (state: string) => void): void;
43
+ removeRegisterListener(listener: (state: string) => void): void;
44
+ addSessionListener(listener: (state: string, data: any) => void): void;
45
+ removeSessionListener(listener: (state: string, data: any) => void): void;
46
+ }
47
+ export default ExotelService;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Voice config from notification-configs API
3
+ */
4
+ export interface VoiceConfig {
5
+ id: string;
6
+ isEnabled: boolean;
7
+ name: string;
8
+ channelType: string;
9
+ EXOTEL?: {
10
+ appId: string;
11
+ appSecret: string;
12
+ token?: string;
13
+ tokenExpiresAt?: string;
14
+ };
15
+ }
16
+ /**
17
+ * Notification config response structure
18
+ */
19
+ export interface NotificationConfigResponse {
20
+ config: {
21
+ id: string;
22
+ tenantId: string;
23
+ institutionUniqueId: number;
24
+ enableVoice?: boolean;
25
+ voiceConfigs?: VoiceConfig[];
26
+ };
27
+ options: {
28
+ voiceChannels?: string[];
29
+ };
30
+ }
31
+ /**
32
+ * Check if VoIP is enabled for the current tenant by fetching notification config.
33
+ * Returns true only if:
34
+ * - enableVoice is true
35
+ * - voiceConfigs has at least one enabled config
36
+ */
37
+ export declare const checkVoIPEnabled: () => Promise<{
38
+ enabled: boolean;
39
+ hasValidToken: boolean;
40
+ }>;
41
+ /**
42
+ * Get the active Exotel voice token from the backend.
43
+ * The backend manages credentials securely and auto-refreshes tokens.
44
+ */
45
+ export declare const getActiveVoiceToken: () => Promise<{
46
+ token: string;
47
+ expiresAt: string;
48
+ } | null>;
49
+ /**
50
+ * @deprecated Use getActiveVoiceToken instead.
51
+ * This function is kept for backwards compatibility but will be removed.
52
+ */
53
+ export declare const createExotelAppToken: () => Promise<{
54
+ Data: string;
55
+ }>;
56
+ export interface CallActivity {
57
+ id: string;
58
+ callSid: string;
59
+ prospectId: string;
60
+ direction: 'inbound' | 'outbound';
61
+ status: string;
62
+ durationSeconds?: number;
63
+ createdAt: string;
64
+ startTime?: string;
65
+ endTime?: string;
66
+ fromNumber?: string;
67
+ toNumber?: string;
68
+ userId?: number;
69
+ dispositionCategory?: string;
70
+ dispositionReason?: string;
71
+ dispositionNotes?: string;
72
+ callStatusDisposition?: 'connected' | 'not_connected';
73
+ recordingUrl?: string;
74
+ }
75
+ export interface InitiateCallInput {
76
+ prospectId: string;
77
+ toNumber: string;
78
+ fromNumber?: string;
79
+ userId?: number;
80
+ callSid?: string;
81
+ }
82
+ export interface SaveDispositionInput {
83
+ callId: string;
84
+ prospectId?: string;
85
+ callStatusDisposition?: 'connected' | 'not_connected';
86
+ dispositionCategory: string;
87
+ dispositionReason?: string;
88
+ dispositionNotes?: string;
89
+ callbackScheduledAt?: string;
90
+ }
91
+ export interface CancelCallInput {
92
+ callSid: string;
93
+ reason?: string;
94
+ }
95
+ export interface CallActivityResponse {
96
+ success: boolean;
97
+ message: string;
98
+ data: CallActivity;
99
+ }
100
+ export interface RegisterIncomingCallInput {
101
+ callSid: string;
102
+ fromNumber: string;
103
+ toNumber?: string;
104
+ prospectId?: string;
105
+ userId?: number;
106
+ }
107
+ export interface RegisterIncomingCallResponse {
108
+ success: boolean;
109
+ message: string;
110
+ data: CallActivity;
111
+ prospect?: {
112
+ id: string;
113
+ uniqueId?: number;
114
+ prospectId?: string;
115
+ name: string;
116
+ mobile: string;
117
+ };
118
+ }
119
+ /**
120
+ * Initiate an outbound call - creates call activity record
121
+ */
122
+ export declare const initiateCallActivity: (input: InitiateCallInput) => Promise<{
123
+ success: boolean;
124
+ message: string;
125
+ data: CallActivity;
126
+ }>;
127
+ /**
128
+ * Register an incoming call - creates call activity record
129
+ */
130
+ export declare const registerIncomingCall: (input: RegisterIncomingCallInput) => Promise<RegisterIncomingCallResponse>;
131
+ /**
132
+ * Fetch call history for a prospect
133
+ */
134
+ export declare const fetchCallHistory: (prospectId: string) => Promise<CallActivity[]>;
135
+ /**
136
+ * Get call activity by ID
137
+ */
138
+ export declare const getCallActivityById: (id: string) => Promise<CallActivity>;
139
+ /**
140
+ * Get call activity by CallSid
141
+ */
142
+ export declare const getCallActivityByCallSid: (callSid: string) => Promise<CallActivity>;
143
+ /**
144
+ * Get call count for a prospect
145
+ */
146
+ export declare const getCallCountByProspect: (prospectId: string) => Promise<number>;
147
+ /**
148
+ * Save call disposition
149
+ */
150
+ export declare const saveCallDisposition: (input: SaveDispositionInput) => Promise<CallActivity>;
151
+ /**
152
+ * Cancel/decline a call before it was connected
153
+ * Updates the call activity status to CANCELED
154
+ */
155
+ export declare const cancelCall: (input: CancelCallInput) => Promise<{
156
+ success: boolean;
157
+ message: string;
158
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './ExotelService';
2
+ export * from './api';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Format duration in MM:SS format (e.g., "02:30")
3
+ */
4
+ export declare const formatDurationTimer: (seconds: number) => string;
5
+ /**
6
+ * Format duration in verbose format (e.g., "2m 30s")
7
+ */
8
+ export declare const formatDurationVerbose: (seconds: number) => string;
@@ -0,0 +1 @@
1
+ export * from './formatters';