call-control-sdk 6.1.2 → 6.2.1
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.
- package/dist/index.d.mts +1351 -33
- package/dist/index.d.ts +1351 -33
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -155,6 +155,10 @@ declare function isSDKInitialized(): boolean;
|
|
|
155
155
|
* @example
|
|
156
156
|
* ```tsx
|
|
157
157
|
* <CallControlPanel onDataChange={handleDataChange} />
|
|
158
|
+
*
|
|
159
|
+
* <CallControlPanel onDataChange={(data) => {
|
|
160
|
+
* console.log('Call Data:', data);
|
|
161
|
+
* }} />
|
|
158
162
|
* ```
|
|
159
163
|
*
|
|
160
164
|
* @since 1.0.0
|
|
@@ -174,15 +178,10 @@ declare const CallControlPanel: React.ComponentType<CallControlPanelProps>;
|
|
|
174
178
|
* Contains all necessary information about active calls, including metadata, status, and references.
|
|
175
179
|
*
|
|
176
180
|
* @properties
|
|
177
|
-
* - `mobileNumber?: string` - Mobile number of the caller or callee
|
|
178
181
|
* - `callReferenceId?: string` - Unique reference identifier for the call
|
|
179
|
-
* - `convoxId?: string` - Convox system identifier for the call
|
|
180
|
-
* - `type?: string` - Type of call (inbound, outbound, internal, etc.)
|
|
181
182
|
* - `status?: string` - Current status of the call (ONCALL, RINGING, WRAPUP, etc.)
|
|
182
183
|
* - `agent_id?: string` - Agent identifier associated with the call
|
|
183
184
|
* - `phone_number?: string` - Phone number involved in the call
|
|
184
|
-
* - `event_time?: string` - Timestamp when the call event occurred
|
|
185
|
-
* - `convox_id?: string` - Convox system call ID
|
|
186
185
|
* - `process_id?: string` - Process identifier for the call
|
|
187
186
|
* - `process_name?: string` - Name of the process handling the call
|
|
188
187
|
*
|
|
@@ -190,15 +189,10 @@ declare const CallControlPanel: React.ComponentType<CallControlPanelProps>;
|
|
|
190
189
|
* @author CTI SDK Team
|
|
191
190
|
*/
|
|
192
191
|
interface CallData {
|
|
193
|
-
mobileNumber?: string;
|
|
194
192
|
callReferenceId?: string;
|
|
195
|
-
convoxId?: string;
|
|
196
|
-
type?: string;
|
|
197
193
|
status?: string;
|
|
198
194
|
agent_id?: string;
|
|
199
195
|
phone_number?: string;
|
|
200
|
-
event_time?: string;
|
|
201
|
-
convox_id?: string;
|
|
202
196
|
process_id?: string;
|
|
203
197
|
process_name?: string;
|
|
204
198
|
}
|
|
@@ -258,63 +252,1387 @@ interface CallControlPanelProps {
|
|
|
258
252
|
// =============================================================================
|
|
259
253
|
|
|
260
254
|
/**
|
|
261
|
-
* 🚪 Logout Hook
|
|
262
255
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
256
|
+
* This file contains TypeScript type definitions for the useEndCall custom hook
|
|
257
|
+
* and its related interfaces. It provides comprehensive type safety and IntelliSense
|
|
258
|
+
* support for developers using the CTI SDK call termination functionality.
|
|
259
|
+
*
|
|
260
|
+
* 🎯 Key Type Definitions:
|
|
261
|
+
* - 📞 EndCallPayload interface for call termination API data
|
|
262
|
+
* - 📞 useEndCall hook return type
|
|
263
|
+
* - 🔄 Call termination function signature
|
|
264
|
+
* - 📊 State management types
|
|
265
|
+
* - 📅 Callback scheduling types
|
|
266
|
+
*
|
|
267
|
+
* @author CTI SDK Team
|
|
268
|
+
* @version 6.x.x
|
|
269
|
+
* @since 1.0.0
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 📞 End Call Payload Interface
|
|
274
|
+
*
|
|
275
|
+
* @interface EndCallPayload
|
|
276
|
+
* @description 📊 Defines the structure for call termination API payload data
|
|
277
|
+
* Contains all necessary information for ending a call with proper disposition
|
|
278
|
+
*
|
|
279
|
+
* @properties
|
|
280
|
+
* - `action: string` - 🎯 API action type ("ENDCALL")
|
|
281
|
+
* - `disposition: string` - 📝 Call outcome classification
|
|
282
|
+
* - `userId: string` - 👤 Agent identifier
|
|
283
|
+
* - `processid: string` - ⚙️ Process identifier
|
|
284
|
+
* - `mobile_number: string` - 📱 Customer phone number
|
|
285
|
+
* - `set_followUp: string` - 📅 Follow-up requirement ("Y" or "N")
|
|
286
|
+
* - `callback_date: string` - 📅 Scheduled callback date
|
|
287
|
+
* - `callback_hrs: string` - 🕐 Scheduled callback hour
|
|
288
|
+
* - `callback_mins: string` - 🕐 Scheduled callback minute
|
|
289
|
+
* - `refno?: string` - 🔗 Optional call reference number
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* // Basic end call payload
|
|
294
|
+
* const endCallPayload: EndCallPayload = {
|
|
295
|
+
* action: "ENDCALL",
|
|
296
|
+
* disposition: "RES",
|
|
297
|
+
* userId: "agent123",
|
|
298
|
+
* processid: "proc001",
|
|
299
|
+
* mobile_number: "1234567890",
|
|
300
|
+
* set_followUp: "N",
|
|
301
|
+
* callback_date: "",
|
|
302
|
+
* callback_hrs: "",
|
|
303
|
+
* callback_mins: ""
|
|
304
|
+
* };
|
|
305
|
+
*
|
|
306
|
+
* // With callback scheduling
|
|
307
|
+
* const endCallWithCallback: EndCallPayload = {
|
|
308
|
+
* action: "ENDCALL",
|
|
309
|
+
* disposition: "RES",
|
|
310
|
+
* userId: "agent123",
|
|
311
|
+
* processid: "proc001",
|
|
312
|
+
* mobile_number: "1234567890",
|
|
313
|
+
* set_followUp: "Y",
|
|
314
|
+
* callback_date: "2024-01-15",
|
|
315
|
+
* callback_hrs: "14",
|
|
316
|
+
* callback_mins: "30"
|
|
317
|
+
* };
|
|
318
|
+
* ```
|
|
319
|
+
*
|
|
320
|
+
* @since 1.0.0
|
|
321
|
+
* @author CTI SDK Team
|
|
322
|
+
*/
|
|
323
|
+
interface EndCallPayload {
|
|
324
|
+
/**
|
|
325
|
+
* 🎯 API action type
|
|
326
|
+
* @description The action type for the API call
|
|
327
|
+
* @type {string}
|
|
328
|
+
*/
|
|
329
|
+
action: string;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* 📝 Call outcome classification
|
|
333
|
+
* @description Classification of how the call ended
|
|
334
|
+
* @type {string}
|
|
335
|
+
*/
|
|
336
|
+
disposition: string;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* 👤 Agent identifier
|
|
340
|
+
* @description Unique identifier for the agent ending the call
|
|
341
|
+
* @type {string}
|
|
342
|
+
*/
|
|
343
|
+
userId: string;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* ⚙️ Process identifier
|
|
347
|
+
* @description Unique identifier for the process
|
|
348
|
+
* @type {string}
|
|
349
|
+
*/
|
|
350
|
+
processid: string;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* 📱 Customer phone number
|
|
354
|
+
* @description Phone number of the customer
|
|
355
|
+
* @type {string}
|
|
356
|
+
*/
|
|
357
|
+
mobile_number: string;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 📅 Follow-up requirement
|
|
361
|
+
* @description Whether a follow-up is required ("Y" or "N")
|
|
362
|
+
* @type {string}
|
|
363
|
+
*/
|
|
364
|
+
set_followUp: string;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 📅 Scheduled callback date
|
|
368
|
+
* @description Date for scheduled callback (YYYY-MM-DD format)
|
|
369
|
+
* @type {string}
|
|
370
|
+
*/
|
|
371
|
+
callback_date: string;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 🕐 Scheduled callback hour
|
|
375
|
+
* @description Hour for scheduled callback (0-23)
|
|
376
|
+
* @type {string}
|
|
377
|
+
*/
|
|
378
|
+
callback_hrs: string;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 🕐 Scheduled callback minute
|
|
382
|
+
* @description Minute for scheduled callback (0-59)
|
|
383
|
+
* @type {string}
|
|
384
|
+
*/
|
|
385
|
+
callback_mins: string;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 🔗 Optional call reference number
|
|
389
|
+
* @description Optional reference number for the call
|
|
390
|
+
* @type {string | undefined}
|
|
391
|
+
*/
|
|
392
|
+
refno?: string;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* 📅 End Call Data Interface
|
|
397
|
+
*
|
|
398
|
+
* @interface EndCallData
|
|
399
|
+
* @description 📊 Defines the structure for call termination input data
|
|
400
|
+
* Contains disposition and callback information for ending calls
|
|
266
401
|
*
|
|
267
|
-
* @
|
|
402
|
+
* @properties
|
|
403
|
+
* - `disposition?: string` - 📝 Call outcome classification (default: "RES")
|
|
404
|
+
* - `followUp?: string` - 📅 Follow-up requirement (default: "N")
|
|
405
|
+
* - `callbackDate?: string` - 📅 Scheduled callback date (default: "")
|
|
406
|
+
* - `callbackHrs?: string` - 🕐 Scheduled callback hour (default: "")
|
|
407
|
+
* - `callbackMins?: string` - 🕐 Scheduled callback minute (default: "")
|
|
268
408
|
*
|
|
269
409
|
* @example
|
|
270
410
|
* ```typescript
|
|
271
|
-
*
|
|
272
|
-
*
|
|
411
|
+
* // Basic end call data
|
|
412
|
+
* const endCallData: EndCallData = {
|
|
413
|
+
* disposition: "RES",
|
|
414
|
+
* followUp: "N"
|
|
415
|
+
* };
|
|
416
|
+
*
|
|
417
|
+
* // With callback scheduling
|
|
418
|
+
* const endCallWithCallback: EndCallData = {
|
|
419
|
+
* disposition: "RES",
|
|
420
|
+
* followUp: "Y",
|
|
421
|
+
* callbackDate: "2024-01-15",
|
|
422
|
+
* callbackHrs: "14",
|
|
423
|
+
* callbackMins: "30"
|
|
424
|
+
* };
|
|
273
425
|
* ```
|
|
274
426
|
*
|
|
275
427
|
* @since 1.0.0
|
|
276
428
|
* @author CTI SDK Team
|
|
277
429
|
*/
|
|
278
|
-
|
|
430
|
+
interface EndCallData {
|
|
431
|
+
/**
|
|
432
|
+
* 📝 Call outcome classification
|
|
433
|
+
* @description How the call ended (default: "RES" for Resolved)
|
|
434
|
+
* @type {string | undefined}
|
|
435
|
+
*/
|
|
436
|
+
disposition?: string;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* 📅 Follow-up requirement
|
|
440
|
+
* @description Whether follow-up is required (default: "N" for No)
|
|
441
|
+
* @type {string | undefined}
|
|
442
|
+
*/
|
|
443
|
+
followUp?: string;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* 📅 Scheduled callback date
|
|
447
|
+
* @description Date for callback scheduling (YYYY-MM-DD format)
|
|
448
|
+
* @type {string | undefined}
|
|
449
|
+
*/
|
|
450
|
+
callbackDate?: string;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* 🕐 Scheduled callback hour
|
|
454
|
+
* @description Hour for callback scheduling (0-23)
|
|
455
|
+
* @type {string | undefined}
|
|
456
|
+
*/
|
|
457
|
+
callbackHrs?: string;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* 🕐 Scheduled callback minute
|
|
461
|
+
* @description Minute for callback scheduling (0-59)
|
|
462
|
+
* @type {string | undefined}
|
|
463
|
+
*/
|
|
464
|
+
callbackMins?: string;
|
|
465
|
+
}
|
|
279
466
|
|
|
280
467
|
/**
|
|
281
|
-
*
|
|
468
|
+
* 📞 Call Termination Function Type
|
|
469
|
+
*
|
|
470
|
+
* @type CallTerminationFunction
|
|
471
|
+
* @description 🎯 Type definition for the call termination function
|
|
472
|
+
* Handles call termination with disposition tracking and callback scheduling
|
|
473
|
+
*
|
|
474
|
+
* @param {EndCallData} data - 📊 Call termination data containing disposition and callback info
|
|
475
|
+
* @returns {Promise<any>} Promise that resolves with API response data or rejects with error
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```typescript
|
|
479
|
+
* const handleEndCall: CallTerminationFunction = async (data) => {
|
|
480
|
+
* // Call termination logic
|
|
481
|
+
* return await apiCall(data);
|
|
482
|
+
* };
|
|
483
|
+
* ```
|
|
484
|
+
*
|
|
485
|
+
* @since 1.0.0
|
|
486
|
+
* @author CTI SDK Team
|
|
487
|
+
*/
|
|
488
|
+
type CallTerminationFunction = (data: EndCallData) => Promise<any>;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* 📊 Hook State Management Types
|
|
492
|
+
*
|
|
493
|
+
* @type HookStateTypes
|
|
494
|
+
* @description 🎛️ Type definitions for all hook state variables
|
|
495
|
+
* Provides type safety for loading, success, error, and data states
|
|
496
|
+
*
|
|
497
|
+
* @since 1.0.0
|
|
498
|
+
* @author CTI SDK Team
|
|
499
|
+
*/
|
|
500
|
+
type HookStateTypes = {
|
|
501
|
+
/**
|
|
502
|
+
* ⏳ Loading state indicator
|
|
503
|
+
* @description Boolean flag indicating if a call termination operation is in progress
|
|
504
|
+
* @type {boolean}
|
|
505
|
+
*/
|
|
506
|
+
isLoading: boolean;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* ✅ Success state indicator
|
|
510
|
+
* @description Boolean flag indicating if the last call termination was successful
|
|
511
|
+
* @type {boolean}
|
|
512
|
+
*/
|
|
513
|
+
isSuccess: boolean;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* ❌ Error state indicator
|
|
517
|
+
* @description Boolean flag indicating if the last call termination encountered an error
|
|
518
|
+
* @type {boolean}
|
|
519
|
+
*/
|
|
520
|
+
isError: boolean;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* 🛡️ Error object
|
|
524
|
+
* @description Contains the error object when a call termination fails
|
|
525
|
+
* @type {any}
|
|
526
|
+
*/
|
|
527
|
+
error: any;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* 📊 Response data
|
|
531
|
+
* @description Contains the response data from successful call terminations
|
|
532
|
+
* @type {any}
|
|
533
|
+
*/
|
|
534
|
+
data: any;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* 📞 useEndCall Hook Return Type
|
|
539
|
+
*
|
|
540
|
+
* @interface UseEndCallReturn
|
|
541
|
+
* @description 🎯 Complete return type for the useEndCall hook
|
|
542
|
+
* Contains all functions and state for call termination functionality
|
|
543
|
+
*
|
|
544
|
+
* @properties
|
|
545
|
+
* - `handleEndCall: CallTerminationFunction` - 📞 Call termination function
|
|
546
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
547
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
548
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
549
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
550
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```typescript
|
|
554
|
+
* const EndCallButton = () => {
|
|
555
|
+
* const hookReturn: UseEndCallReturn = useEndCall();
|
|
556
|
+
* const {
|
|
557
|
+
* handleEndCall,
|
|
558
|
+
* isLoading,
|
|
559
|
+
* isSuccess,
|
|
560
|
+
* isError,
|
|
561
|
+
* error
|
|
562
|
+
* } = hookReturn;
|
|
563
|
+
*
|
|
564
|
+
* // Use the hook functionality
|
|
565
|
+
* };
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @since 1.0.0
|
|
569
|
+
* @author CTI SDK Team
|
|
570
|
+
*/
|
|
571
|
+
interface UseEndCallReturn extends HookStateTypes {
|
|
572
|
+
/**
|
|
573
|
+
* 📞 Call termination function
|
|
574
|
+
* @description Handles call termination with disposition tracking and callback scheduling
|
|
575
|
+
* @type {CallTerminationFunction}
|
|
576
|
+
*/
|
|
577
|
+
handleEndCall: CallTerminationFunction;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* 📞 End Call Custom Hook
|
|
282
582
|
*
|
|
283
583
|
* @function useEndCall
|
|
284
|
-
* @description Custom hook
|
|
285
|
-
*
|
|
584
|
+
* @description 🎯 Custom hook that provides comprehensive call termination functionality
|
|
585
|
+
* for the CTI SDK. It handles call disposition capture, callback scheduling,
|
|
586
|
+
* and proper call cleanup with intelligent state management and error handling.
|
|
286
587
|
*
|
|
287
|
-
* @returns {
|
|
588
|
+
* @returns {UseEndCallReturn} Hook return object containing:
|
|
589
|
+
* - `handleEndCall: CallTerminationFunction` - 📞 Call termination function
|
|
590
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
591
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
592
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
593
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
594
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
288
595
|
*
|
|
289
596
|
* @example
|
|
290
597
|
* ```typescript
|
|
291
|
-
*
|
|
292
|
-
*
|
|
598
|
+
* // Basic usage in a component
|
|
599
|
+
* const EndCallButton = () => {
|
|
600
|
+
* const {
|
|
601
|
+
* handleEndCall,
|
|
602
|
+
* isLoading,
|
|
603
|
+
* isSuccess,
|
|
604
|
+
* isError,
|
|
605
|
+
* error
|
|
606
|
+
* } = useEndCall();
|
|
607
|
+
*
|
|
608
|
+
* const endCall = async () => {
|
|
609
|
+
* try {
|
|
610
|
+
* const result = await handleEndCall({
|
|
611
|
+
* disposition: "RES",
|
|
612
|
+
* followUp: "N"
|
|
613
|
+
* });
|
|
614
|
+
* console.log('📞 Call ended:', result);
|
|
615
|
+
* } catch (err) {
|
|
616
|
+
* console.error('❌ End call failed:', err);
|
|
617
|
+
* }
|
|
618
|
+
* };
|
|
619
|
+
*
|
|
620
|
+
* return (
|
|
621
|
+
* <button
|
|
622
|
+
* onClick={endCall}
|
|
623
|
+
* disabled={isLoading}
|
|
624
|
+
* >
|
|
625
|
+
* {isLoading ? 'Ending...' : 'End Call'}
|
|
626
|
+
* </button>
|
|
627
|
+
* );
|
|
628
|
+
* };
|
|
293
629
|
* ```
|
|
294
630
|
*
|
|
631
|
+
* @features
|
|
632
|
+
* - 🎯 Comprehensive call termination with disposition tracking
|
|
633
|
+
* - 📅 Callback scheduling and follow-up management
|
|
634
|
+
* - 🔄 Intelligent state cleanup and reset
|
|
635
|
+
* - ⏳ Comprehensive loading state management
|
|
636
|
+
* - 🛡️ Robust error handling and recovery
|
|
637
|
+
* - 📊 Real-time state updates via SDK manager
|
|
638
|
+
* - 🔄 Automatic call state management
|
|
639
|
+
*
|
|
640
|
+
* @since 1.0.0
|
|
641
|
+
* @author CTI SDK Team
|
|
642
|
+
*/
|
|
643
|
+
declare const useEndCall: () => UseEndCallReturn;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* 📝 Disposition Types
|
|
647
|
+
*
|
|
648
|
+
* @type DispositionType
|
|
649
|
+
* @description 🎯 Type definitions for call disposition values
|
|
650
|
+
* Used for call outcome classification
|
|
651
|
+
*
|
|
295
652
|
* @since 1.0.0
|
|
296
653
|
* @author CTI SDK Team
|
|
297
654
|
*/
|
|
298
|
-
|
|
655
|
+
type DispositionType = string;
|
|
299
656
|
|
|
300
657
|
/**
|
|
301
|
-
*
|
|
658
|
+
* 📅 Follow-up Types
|
|
659
|
+
*
|
|
660
|
+
* @type FollowUpType
|
|
661
|
+
* @description 🎯 Type definitions for follow-up requirement values
|
|
662
|
+
* Used for callback scheduling
|
|
663
|
+
*
|
|
664
|
+
* @since 1.0.0
|
|
665
|
+
* @author CTI SDK Team
|
|
666
|
+
*/
|
|
667
|
+
type FollowUpType = string;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* ⚙️ Process Data Interface
|
|
671
|
+
*
|
|
672
|
+
* @interface ProcessData
|
|
673
|
+
* @description 📊 Type definition for process data structure
|
|
674
|
+
* Contains information about the current process
|
|
675
|
+
*
|
|
676
|
+
* @properties
|
|
677
|
+
* - `process_id: number` - 🔢 Process identifier
|
|
678
|
+
* - `process_name: string` - 📝 Process name
|
|
679
|
+
*
|
|
680
|
+
* @since 1.0.0
|
|
681
|
+
* @author CTI SDK Team
|
|
682
|
+
*/
|
|
683
|
+
interface ProcessData {
|
|
684
|
+
/**
|
|
685
|
+
* 🔢 Process identifier
|
|
686
|
+
* @description Unique identifier for the process
|
|
687
|
+
* @type {number}
|
|
688
|
+
*/
|
|
689
|
+
process_id: number;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* 📝 Process name
|
|
693
|
+
* @description Human-readable name of the process
|
|
694
|
+
* @type {string}
|
|
695
|
+
*/
|
|
696
|
+
process_name: string;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* 📞 Call Data Interface
|
|
701
|
+
*
|
|
702
|
+
* @interface EndCallPayLoadData
|
|
703
|
+
* @description 📊 Type definition for call data structure
|
|
704
|
+
* Contains information about the current call
|
|
705
|
+
*
|
|
706
|
+
* @properties
|
|
707
|
+
* - `convox_id: string` - 🔗 Call reference identifier
|
|
708
|
+
* - `phone_number: string` - 📱 Customer phone number
|
|
709
|
+
*
|
|
710
|
+
* @since 1.0.0
|
|
711
|
+
* @author CTI SDK Team
|
|
712
|
+
*/
|
|
713
|
+
interface EndCallPayLoadData {
|
|
714
|
+
/**
|
|
715
|
+
* 🔗 Call reference identifier
|
|
716
|
+
* @description Unique identifier for the call
|
|
717
|
+
* @type {string}
|
|
718
|
+
*/
|
|
719
|
+
convox_id: string;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* 📱 Customer phone number
|
|
723
|
+
* @description Phone number of the customer
|
|
724
|
+
* @type {string}
|
|
725
|
+
*/
|
|
726
|
+
phone_number: string;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* 📋 Comprehensive Type Exports
|
|
731
|
+
*
|
|
732
|
+
* @description 📦 Re-exports all types for easy importing
|
|
733
|
+
* Provides a single import point for all hook-related types
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```typescript
|
|
737
|
+
* import {
|
|
738
|
+
* EndCallPayload,
|
|
739
|
+
* UseEndCallReturn,
|
|
740
|
+
* CallTerminationFunction,
|
|
741
|
+
* EndCallData
|
|
742
|
+
* } from './useEndCall';
|
|
743
|
+
* ```
|
|
744
|
+
*
|
|
745
|
+
* @since 1.0.0
|
|
746
|
+
* @author CTI SDK Team
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
*
|
|
751
|
+
* This file contains TypeScript type definitions for the useLogout custom hook
|
|
752
|
+
* and its related interfaces. It provides comprehensive type safety and IntelliSense
|
|
753
|
+
* support for developers using the CTI SDK logout functionality.
|
|
754
|
+
*
|
|
755
|
+
* 🎯 Key Type Definitions:
|
|
756
|
+
* - 🚪 LogoutPayload interface for logout API data
|
|
757
|
+
* - 🚪 useLogout hook return type
|
|
758
|
+
* - 🔄 Logout function signature
|
|
759
|
+
* - 📊 State management types
|
|
760
|
+
* - 🗑️ Cleanup and storage management types
|
|
761
|
+
*
|
|
762
|
+
* @author CTI SDK Team
|
|
763
|
+
* @version 6.x.x
|
|
764
|
+
* @since 1.0.0
|
|
765
|
+
*/
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* 🚪 Logout Payload Interface
|
|
769
|
+
*
|
|
770
|
+
* @interface LogoutPayload
|
|
771
|
+
* @description 📊 Defines the structure for agent logout API payload data
|
|
772
|
+
* Contains all necessary information for secure agent logout
|
|
773
|
+
*
|
|
774
|
+
* @properties
|
|
775
|
+
* - `action: string` - 🎯 API action type ("LOGOUTUSER")
|
|
776
|
+
* - `userId: string` - 👤 Agent identifier for logout
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```typescript
|
|
780
|
+
* // Basic logout payload
|
|
781
|
+
* const logoutPayload: LogoutPayload = {
|
|
782
|
+
* action: "LOGOUTUSER",
|
|
783
|
+
* userId: "agent123"
|
|
784
|
+
* };
|
|
785
|
+
*
|
|
786
|
+
* // Usage in component
|
|
787
|
+
* const { logout } = useLogout();
|
|
788
|
+
* await logout();
|
|
789
|
+
* ```
|
|
790
|
+
*
|
|
791
|
+
* @since 1.0.0
|
|
792
|
+
* @author CTI SDK Team
|
|
793
|
+
*/
|
|
794
|
+
interface LogoutPayload {
|
|
795
|
+
/**
|
|
796
|
+
* 🎯 API action type
|
|
797
|
+
* @description The action type for the logout API call
|
|
798
|
+
* @type {string}
|
|
799
|
+
*/
|
|
800
|
+
action: string;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* 👤 Agent identifier
|
|
804
|
+
* @description Unique identifier for the agent being logged out
|
|
805
|
+
* @type {string}
|
|
806
|
+
*/
|
|
807
|
+
userId: string;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* 🚪 Logout Function Type
|
|
812
|
+
*
|
|
813
|
+
* @type LogoutFunction
|
|
814
|
+
* @description 🎯 Type definition for the logout function
|
|
815
|
+
* Handles secure agent logout with comprehensive cleanup procedures
|
|
816
|
+
*
|
|
817
|
+
* @returns {Promise<any>} Promise that resolves with API response data or rejects with error
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
* ```typescript
|
|
821
|
+
* const logout();
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @since 1.0.0
|
|
825
|
+
* @author CTI SDK Team
|
|
826
|
+
*/
|
|
827
|
+
type LogoutFunction = () => Promise<any>;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* 📊 Hook State Management Types
|
|
831
|
+
*
|
|
832
|
+
* @type LogoutHookStateTypes
|
|
833
|
+
* @description 🎛️ Type definitions for all hook state variables
|
|
834
|
+
* Provides type safety for loading, success, error, and data states
|
|
835
|
+
*
|
|
836
|
+
* @since 1.0.0
|
|
837
|
+
* @author CTI SDK Team
|
|
838
|
+
*/
|
|
839
|
+
type LogoutHookStateTypes = {
|
|
840
|
+
/**
|
|
841
|
+
* ⏳ Loading state indicator
|
|
842
|
+
* @description Boolean flag indicating if a logout operation is in progress
|
|
843
|
+
* @type {boolean}
|
|
844
|
+
*/
|
|
845
|
+
isLoading: boolean;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* ✅ Success state indicator
|
|
849
|
+
* @description Boolean flag indicating if the last logout was successful
|
|
850
|
+
* @type {boolean}
|
|
851
|
+
*/
|
|
852
|
+
isSuccess: boolean;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* ❌ Error state indicator
|
|
856
|
+
* @description Boolean flag indicating if the last logout encountered an error
|
|
857
|
+
* @type {boolean}
|
|
858
|
+
*/
|
|
859
|
+
isError: boolean;
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* 🛡️ Error object
|
|
863
|
+
* @description Contains the error object when a logout fails
|
|
864
|
+
* @type {any}
|
|
865
|
+
*/
|
|
866
|
+
error: any;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* 📊 Response data
|
|
870
|
+
* @description Contains the response data from successful logout
|
|
871
|
+
* @type {any}
|
|
872
|
+
*/
|
|
873
|
+
data: any;
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* 🚪 useLogout Hook Return Type
|
|
878
|
+
*
|
|
879
|
+
* @interface UseLogoutReturn
|
|
880
|
+
* @description 🎯 Complete return type for the useLogout hook
|
|
881
|
+
* Contains all functions and state for logout functionality
|
|
882
|
+
*
|
|
883
|
+
* @properties
|
|
884
|
+
* - `logout: LogoutFunction` - 🚪 Logout function
|
|
885
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
886
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
887
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
888
|
+
* - `error: any` - 🛡️ Error object when logout fails
|
|
889
|
+
* - `data: any` - 📊 Response data from successful logout
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* const LogoutButton = () => {
|
|
894
|
+
* const hookReturn: UseLogoutReturn = useLogout();
|
|
895
|
+
* const {
|
|
896
|
+
* logout,
|
|
897
|
+
* isLoading,
|
|
898
|
+
* isSuccess,
|
|
899
|
+
* isError,
|
|
900
|
+
* error
|
|
901
|
+
* } = hookReturn;
|
|
902
|
+
*
|
|
903
|
+
* // Use the hook functionality
|
|
904
|
+
* };
|
|
905
|
+
* ```
|
|
906
|
+
*
|
|
907
|
+
* @since 1.0.0
|
|
908
|
+
* @author CTI SDK Team
|
|
909
|
+
*/
|
|
910
|
+
interface UseLogoutReturn extends LogoutHookStateTypes {
|
|
911
|
+
/**
|
|
912
|
+
* 🚪 Logout function
|
|
913
|
+
* @description Handles secure agent logout with comprehensive cleanup procedures
|
|
914
|
+
* @type {LogoutFunction}
|
|
915
|
+
*/
|
|
916
|
+
logout: LogoutFunction;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* 🚪 Logout Custom Hook
|
|
921
|
+
*
|
|
922
|
+
* @function useLogout
|
|
923
|
+
* @description 🎯 Custom hook that provides comprehensive agent logout functionality
|
|
924
|
+
* for the CTI SDK. It handles secure logout procedures, complete state cleanup,
|
|
925
|
+
* and storage management with intelligent error handling and proper cleanup.
|
|
926
|
+
*
|
|
927
|
+
* @returns {UseLogoutReturn} Hook return object containing:
|
|
928
|
+
* - `logout: LogoutFunction` - 🚪 Logout function
|
|
929
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
930
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
931
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
932
|
+
* - `error: any` - 🛡️ Error object when logout fails
|
|
933
|
+
* - `data: any` - 📊 Response data from successful logout
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* ```typescript
|
|
937
|
+
* // Basic usage in a component
|
|
938
|
+
* const LogoutButton = () => {
|
|
939
|
+
* const {
|
|
940
|
+
* logout,
|
|
941
|
+
* isLoading,
|
|
942
|
+
* isSuccess,
|
|
943
|
+
* isError,
|
|
944
|
+
* error
|
|
945
|
+
* } = useLogout();
|
|
946
|
+
*
|
|
947
|
+
* const handleLogout = async () => {
|
|
948
|
+
* try {
|
|
949
|
+
* const result = await logout();
|
|
950
|
+
* console.log('🚪 Logout successful:', result);
|
|
951
|
+
* // Redirect to login page or handle success
|
|
952
|
+
* } catch (err) {
|
|
953
|
+
* console.error('❌ Logout failed:', err);
|
|
954
|
+
* }
|
|
955
|
+
* };
|
|
956
|
+
*
|
|
957
|
+
* return (
|
|
958
|
+
* <button
|
|
959
|
+
* onClick={handleLogout}
|
|
960
|
+
* disabled={isLoading}
|
|
961
|
+
* >
|
|
962
|
+
* {isLoading ? 'Logging out...' : 'Logout'}
|
|
963
|
+
* </button>
|
|
964
|
+
* );
|
|
965
|
+
* };
|
|
966
|
+
* ```
|
|
967
|
+
*
|
|
968
|
+
* @features
|
|
969
|
+
* - 🚪 Secure agent logout with API validation
|
|
970
|
+
* - 🗑️ Complete state cleanup and reset
|
|
971
|
+
* - 💾 Storage management (localStorage & sessionStorage)
|
|
972
|
+
* - ⏳ Comprehensive loading state management
|
|
973
|
+
* - 🛡️ Robust error handling and recovery
|
|
974
|
+
* - 📊 Real-time state updates via SDK manager
|
|
975
|
+
* - 🔄 Automatic storage cleanup
|
|
976
|
+
*
|
|
977
|
+
* @since 1.0.0
|
|
978
|
+
* @author CTI SDK Team
|
|
979
|
+
*/
|
|
980
|
+
declare const useLogout: () => UseLogoutReturn;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* 🗃️ SDK State Interface
|
|
984
|
+
*
|
|
985
|
+
* @interface SDKState
|
|
986
|
+
* @description 📊 Type definition for the SDK state structure
|
|
987
|
+
* Used internally by the hook to access agent and call data
|
|
988
|
+
*
|
|
989
|
+
* @properties
|
|
990
|
+
* - `agentId: string` - 👤 Agent identifier
|
|
991
|
+
* - `process: ProcessData` - ⚙️ Process information
|
|
992
|
+
* - `callData: EndCallData` - 📞 Current call data
|
|
993
|
+
*
|
|
994
|
+
* @since 1.0.0
|
|
995
|
+
* @author CTI SDK Team
|
|
996
|
+
*/
|
|
997
|
+
interface SDKState {
|
|
998
|
+
/**
|
|
999
|
+
* 👤 Agent identifier
|
|
1000
|
+
* @description Unique identifier for the current agent
|
|
1001
|
+
* @type {string}
|
|
1002
|
+
*/
|
|
1003
|
+
agentId: string;
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* ⚙️ Process information
|
|
1007
|
+
* @description Information about the current process
|
|
1008
|
+
* @type {ProcessData}
|
|
1009
|
+
*/
|
|
1010
|
+
process: ProcessData;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* 📞 Current call data
|
|
1014
|
+
* @description Data about the current call
|
|
1015
|
+
* @type {EndCallData}
|
|
1016
|
+
*/
|
|
1017
|
+
callData: EndCallData;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* 🗃️ SDK State Interface
|
|
1022
|
+
*
|
|
1023
|
+
* @interface SDKState
|
|
1024
|
+
* @description 📊 Type definition for the SDK state structure
|
|
1025
|
+
* Used internally by the hook to access agent data
|
|
1026
|
+
*
|
|
1027
|
+
* @properties
|
|
1028
|
+
* - `agentId: string` - 👤 Agent identifier
|
|
1029
|
+
*
|
|
1030
|
+
* @since 1.0.0
|
|
1031
|
+
* @author CTI SDK Team
|
|
1032
|
+
*/
|
|
1033
|
+
interface SDKState {
|
|
1034
|
+
/**
|
|
1035
|
+
* 👤 Agent identifier
|
|
1036
|
+
* @description Unique identifier for the current agent
|
|
1037
|
+
* @type {string}
|
|
1038
|
+
*/
|
|
1039
|
+
agentId: string;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* 🗑️ Storage Management Types
|
|
1044
|
+
*
|
|
1045
|
+
* @type StorageType
|
|
1046
|
+
* @description 🎯 Type definitions for storage management
|
|
1047
|
+
* Used for localStorage and sessionStorage operations
|
|
1048
|
+
*
|
|
1049
|
+
* @since 1.0.0
|
|
1050
|
+
* @author CTI SDK Team
|
|
1051
|
+
*/
|
|
1052
|
+
type StorageType = "localStorage" | "sessionStorage";
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* 🔄 Cleanup Operation Types
|
|
1056
|
+
*
|
|
1057
|
+
* @type CleanupOperation
|
|
1058
|
+
* @description 🎯 Type definitions for cleanup operations
|
|
1059
|
+
* Used for state and storage cleanup procedures
|
|
1060
|
+
*
|
|
1061
|
+
* @since 1.0.0
|
|
1062
|
+
* @author CTI SDK Team
|
|
1063
|
+
*/
|
|
1064
|
+
type CleanupOperation = "clearStorage" | "resetState" | "clearAll";
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* 📋 Comprehensive Type Exports
|
|
1068
|
+
*
|
|
1069
|
+
* @description 📦 Re-exports all types for easy importing
|
|
1070
|
+
* Provides a single import point for all hook-related types
|
|
1071
|
+
*
|
|
1072
|
+
* @example
|
|
1073
|
+
* ```typescript
|
|
1074
|
+
* import {
|
|
1075
|
+
* LogoutPayload,
|
|
1076
|
+
* UseLogoutReturn,
|
|
1077
|
+
* LogoutFunction,
|
|
1078
|
+
* SDKState
|
|
1079
|
+
* } from './useLogout';
|
|
1080
|
+
* ```
|
|
1081
|
+
*
|
|
1082
|
+
* @since 1.0.0
|
|
1083
|
+
* @author CTI SDK Team
|
|
1084
|
+
*/
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* @fileoverview 📞 TypeScript Declaration File for useClickToCall Hook
|
|
1088
|
+
*
|
|
1089
|
+
* This file contains TypeScript type definitions for the useClickToCall custom hook
|
|
1090
|
+
* and its related interfaces. It provides comprehensive type safety and IntelliSense
|
|
1091
|
+
* support for developers using the CTI SDK.
|
|
1092
|
+
*
|
|
1093
|
+
* 🎯 Key Type Definitions:
|
|
1094
|
+
* - 📱 StartCallPayload interface for call initiation data
|
|
1095
|
+
* - 📞 useClickToCall hook return type
|
|
1096
|
+
* - 🔄 Call initiation function signature
|
|
1097
|
+
* - 📊 State management types
|
|
1098
|
+
*
|
|
1099
|
+
* @author CTI SDK Team
|
|
1100
|
+
* @version 6.x.x
|
|
1101
|
+
* @since 1.0.0
|
|
1102
|
+
*/
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* 📱 Start Call Payload Interface
|
|
1106
|
+
*
|
|
1107
|
+
* @interface StartCallPayload
|
|
1108
|
+
* @description 📊 Defines the structure for call initiation payload data
|
|
1109
|
+
* Contains the mobile number required to initiate a call
|
|
1110
|
+
*
|
|
1111
|
+
* @properties
|
|
1112
|
+
* - `mobileNumber: string` - 📱 The phone number to call (required)
|
|
1113
|
+
*
|
|
1114
|
+
* @example
|
|
1115
|
+
* ```typescript
|
|
1116
|
+
* // Basic call initiation payload
|
|
1117
|
+
* const callPayload: StartCallPayload = {
|
|
1118
|
+
* mobileNumber: "1234567890"
|
|
1119
|
+
* };
|
|
1120
|
+
*
|
|
1121
|
+
* // Usage in component
|
|
1122
|
+
* const { handleStartCall } = useClickToCall();
|
|
1123
|
+
* await handleStartCall({ mobileNumber: "9876543210" });
|
|
1124
|
+
* ```
|
|
1125
|
+
*
|
|
1126
|
+
* @since 1.0.0
|
|
1127
|
+
* @author CTI SDK Team
|
|
1128
|
+
*/
|
|
1129
|
+
interface StartCallPayload {
|
|
1130
|
+
/**
|
|
1131
|
+
* 📱 Phone number to call
|
|
1132
|
+
* @description The mobile number that will be called
|
|
1133
|
+
* @type {string}
|
|
1134
|
+
*/
|
|
1135
|
+
mobileNumber: string;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* 📞 Call Initiation Function Type
|
|
1140
|
+
*
|
|
1141
|
+
* @type CallInitiationFunction
|
|
1142
|
+
* @description 🎯 Type definition for the call initiation function
|
|
1143
|
+
* Handles both regular calls and conference calls based on agent state
|
|
1144
|
+
*
|
|
1145
|
+
* @param {StartCallPayload} data - 📊 Call initiation data containing mobile number
|
|
1146
|
+
* @returns {Promise<any>} Promise that resolves with API response data or rejects with error
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```typescript
|
|
1150
|
+
* const handleStartCall({
|
|
1151
|
+
* mobileNumber: "1234567890"
|
|
1152
|
+
* })
|
|
1153
|
+
* ```
|
|
1154
|
+
*
|
|
1155
|
+
* @since 1.0.0
|
|
1156
|
+
* @author CTI SDK Team
|
|
1157
|
+
*/
|
|
1158
|
+
type CallInitiationFunction = (data: StartCallPayload) => Promise<any>;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* 📊 Hook State Management Types
|
|
1162
|
+
*
|
|
1163
|
+
* @type StartCalltHookStateTypes
|
|
1164
|
+
* @description 🎛️ Type definitions for all hook state variables
|
|
1165
|
+
* Provides type safety for loading, success, error, and data states
|
|
1166
|
+
*
|
|
1167
|
+
* @since 1.0.0
|
|
1168
|
+
* @author CTI SDK Team
|
|
1169
|
+
*/
|
|
1170
|
+
type StartCalltHookStateTypes = {
|
|
1171
|
+
/**
|
|
1172
|
+
* ⏳ Loading state indicator
|
|
1173
|
+
* @description Boolean flag indicating if a call operation is currently in progress
|
|
1174
|
+
* @type {boolean}
|
|
1175
|
+
*/
|
|
1176
|
+
isLoading: boolean;
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* ✅ Success state indicator
|
|
1180
|
+
* @description Boolean flag indicating if the last call operation was successful
|
|
1181
|
+
* @type {boolean}
|
|
1182
|
+
*/
|
|
1183
|
+
isSuccess: boolean;
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* ❌ Error state indicator
|
|
1187
|
+
* @description Boolean flag indicating if the last call operation encountered an error
|
|
1188
|
+
* @type {boolean}
|
|
1189
|
+
*/
|
|
1190
|
+
isError: boolean;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* 🛡️ Error object
|
|
1194
|
+
* @description Contains the error object when a call operation fails
|
|
1195
|
+
* @type {any}
|
|
1196
|
+
*/
|
|
1197
|
+
error: any;
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* 📊 Response data
|
|
1201
|
+
* @description Contains the response data from successful call operations
|
|
1202
|
+
* @type {any}
|
|
1203
|
+
*/
|
|
1204
|
+
data: any;
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* 📞 useClickToCall Hook Return Type
|
|
1209
|
+
*
|
|
1210
|
+
* @interface UseClickToCallReturn
|
|
1211
|
+
* @description 🎯 Complete return type for the useClickToCall hook
|
|
1212
|
+
* Contains all functions and state for call initiation functionality
|
|
1213
|
+
*
|
|
1214
|
+
* @properties
|
|
1215
|
+
* - `handleStartCall: CallInitiationFunction` - 📞 Call initiation function
|
|
1216
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
1217
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
1218
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
1219
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
1220
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* ```typescript
|
|
1224
|
+
* const CallButton = () => {
|
|
1225
|
+
* const hookReturn: UseClickToCallReturn = useClickToCall();
|
|
1226
|
+
* const {
|
|
1227
|
+
* handleStartCall,
|
|
1228
|
+
* isLoading,
|
|
1229
|
+
* isSuccess,
|
|
1230
|
+
* isError,
|
|
1231
|
+
* error
|
|
1232
|
+
* } = hookReturn;
|
|
1233
|
+
*
|
|
1234
|
+
* // Use the hook functionality
|
|
1235
|
+
* };
|
|
1236
|
+
* ```
|
|
1237
|
+
*
|
|
1238
|
+
* @since 1.0.0
|
|
1239
|
+
* @author CTI SDK Team
|
|
1240
|
+
*/
|
|
1241
|
+
interface UseClickToCallReturn extends StartCalltHookStateTypes {
|
|
1242
|
+
/**
|
|
1243
|
+
* 📞 Call initiation function
|
|
1244
|
+
* @description Handles call initiation with intelligent routing based on agent state
|
|
1245
|
+
* @type {CallInitiationFunction}
|
|
1246
|
+
*/
|
|
1247
|
+
handleStartCall: CallInitiationFunction;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* 📞 Click-to-Call Custom Hook
|
|
302
1252
|
*
|
|
303
1253
|
* @function useClickToCall
|
|
304
|
-
* @description Custom hook
|
|
305
|
-
*
|
|
1254
|
+
* @description 🎯 Custom hook that provides comprehensive call initiation functionality
|
|
1255
|
+
* for the CTI SDK. It intelligently handles both regular calls and conference calls
|
|
1256
|
+
* based on the current agent state, with proper loading states and error handling.
|
|
306
1257
|
*
|
|
307
|
-
* @returns {
|
|
1258
|
+
* @returns {UseClickToCallReturn} Hook return object containing:
|
|
1259
|
+
* - `handleStartCall: CallInitiationFunction` - 📞 Call initiation function
|
|
1260
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
1261
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
1262
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
1263
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
1264
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
308
1265
|
*
|
|
309
1266
|
* @example
|
|
310
1267
|
* ```typescript
|
|
311
|
-
*
|
|
312
|
-
*
|
|
1268
|
+
* // Basic usage in a component
|
|
1269
|
+
* const CallButton = () => {
|
|
1270
|
+
* const {
|
|
1271
|
+
* handleStartCall,
|
|
1272
|
+
* isLoading,
|
|
1273
|
+
* isSuccess,
|
|
1274
|
+
* isError,
|
|
1275
|
+
* error
|
|
1276
|
+
* } = useClickToCall();
|
|
1277
|
+
*
|
|
1278
|
+
* const makeCall = async () => {
|
|
1279
|
+
* try {
|
|
1280
|
+
* const result = await handleStartCall({
|
|
1281
|
+
* mobileNumber: "1234567890"
|
|
1282
|
+
* });
|
|
1283
|
+
* console.log('📞 Call initiated:', result);
|
|
1284
|
+
* } catch (err) {
|
|
1285
|
+
* console.error('❌ Call failed:', err);
|
|
1286
|
+
* }
|
|
1287
|
+
* };
|
|
1288
|
+
*
|
|
1289
|
+
* return (
|
|
1290
|
+
* <button
|
|
1291
|
+
* onClick={makeCall}
|
|
1292
|
+
* disabled={isLoading}
|
|
1293
|
+
* >
|
|
1294
|
+
* {isLoading ? 'Calling...' : 'Make Call'}
|
|
1295
|
+
* </button>
|
|
1296
|
+
* );
|
|
1297
|
+
* };
|
|
313
1298
|
* ```
|
|
314
1299
|
*
|
|
1300
|
+
* @features
|
|
1301
|
+
* - 🎯 Intelligent call routing based on agent state
|
|
1302
|
+
* - 📱 Regular call initiation for idle agents
|
|
1303
|
+
* - 👥 Conference call initiation for busy agents
|
|
1304
|
+
* - ⏳ Comprehensive loading state management
|
|
1305
|
+
* - 🛡️ Robust error handling and recovery
|
|
1306
|
+
* - 📊 Real-time state updates via SDK manager
|
|
1307
|
+
* - 🔄 Automatic conference dialog management
|
|
1308
|
+
*
|
|
1309
|
+
* @since 1.0.0
|
|
1310
|
+
* @author CTI SDK Team
|
|
1311
|
+
*/
|
|
1312
|
+
declare const useClickToCall: () => UseClickToCallReturn;
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* 📊 Agent State Types
|
|
1316
|
+
*
|
|
1317
|
+
* @type AgentStatus
|
|
1318
|
+
* @description 🎯 Type definitions for agent status values
|
|
1319
|
+
* Used internally by the hook to determine call routing logic
|
|
1320
|
+
*
|
|
1321
|
+
* @since 1.0.0
|
|
1322
|
+
* @author CTI SDK Team
|
|
1323
|
+
*/
|
|
1324
|
+
type AgentStatus = string;
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* 📞 Conference Line Interface
|
|
1328
|
+
*
|
|
1329
|
+
* @interface ConferenceLine
|
|
1330
|
+
* @description 📊 Type definition for conference line data structure
|
|
1331
|
+
* Used internally by the hook for conference call management
|
|
1332
|
+
*
|
|
1333
|
+
* @properties
|
|
1334
|
+
* - `line: number` - 📞 Line number identifier
|
|
1335
|
+
* - `status: AgentStatus` - 📊 Current line status
|
|
1336
|
+
* - `isCallStart: boolean` - ✅ Whether call is active on this line
|
|
1337
|
+
* - `phone?: string` - 📱 Phone number for this line (optional)
|
|
1338
|
+
*
|
|
1339
|
+
* @since 1.0.0
|
|
1340
|
+
* @author CTI SDK Team
|
|
1341
|
+
*/
|
|
1342
|
+
interface ConferenceLine {
|
|
1343
|
+
/**
|
|
1344
|
+
* 📞 Line number identifier
|
|
1345
|
+
* @description Unique identifier for the conference line
|
|
1346
|
+
* @type {number}
|
|
1347
|
+
*/
|
|
1348
|
+
line: number;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* 📊 Current line status
|
|
1352
|
+
* @description Status of the conference line
|
|
1353
|
+
* @type {AgentStatus}
|
|
1354
|
+
*/
|
|
1355
|
+
status: AgentStatus;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* ✅ Whether call is active on this line
|
|
1359
|
+
* @description Flag indicating if a call is currently active
|
|
1360
|
+
* @type {boolean}
|
|
1361
|
+
*/
|
|
1362
|
+
isCallStart: boolean;
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* 📱 Phone number for this line
|
|
1366
|
+
* @description Phone number associated with this line (optional)
|
|
1367
|
+
* @type {string | undefined}
|
|
1368
|
+
*/
|
|
1369
|
+
phone?: string;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* 📞 Call Data Interface
|
|
1374
|
+
*
|
|
1375
|
+
* @interface StartCalltData
|
|
1376
|
+
* @description 📊 Type definition for call data structure
|
|
1377
|
+
* Contains information about the current call
|
|
1378
|
+
*
|
|
1379
|
+
* @properties
|
|
1380
|
+
* - `status: AgentStatus` - 📊 Current call status
|
|
1381
|
+
* - `agent_id: string` - 👤 Agent identifier
|
|
1382
|
+
* - `process_name: string` - ⚙️ Process name
|
|
1383
|
+
*
|
|
1384
|
+
* @since 1.0.0
|
|
1385
|
+
* @author CTI SDK Team
|
|
1386
|
+
*/
|
|
1387
|
+
interface StartCalltData {
|
|
1388
|
+
/**
|
|
1389
|
+
* 📊 Current call status
|
|
1390
|
+
* @description Status of the current call
|
|
1391
|
+
* @type {AgentStatus}
|
|
1392
|
+
*/
|
|
1393
|
+
status: AgentStatus;
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* 👤 Agent identifier
|
|
1397
|
+
* @description Unique identifier for the agent
|
|
1398
|
+
* @type {string}
|
|
1399
|
+
*/
|
|
1400
|
+
agent_id: string;
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* ⚙️ Process name
|
|
1404
|
+
* @description Name of the current process
|
|
1405
|
+
* @type {string}
|
|
1406
|
+
*/
|
|
1407
|
+
process_name: string;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* 📡 API Response Interface
|
|
1412
|
+
*
|
|
1413
|
+
* @interface APIResponse
|
|
1414
|
+
* @description 📊 Type definition for API response structure
|
|
1415
|
+
* Used for type safety in API call responses
|
|
1416
|
+
*
|
|
1417
|
+
* @properties
|
|
1418
|
+
* - `data: any` - 📊 Response data
|
|
1419
|
+
* - `status: number` - 📊 HTTP status code
|
|
1420
|
+
* - `message?: string` - 📝 Optional response message
|
|
1421
|
+
*
|
|
1422
|
+
* @since 1.0.0
|
|
1423
|
+
* @author CTI SDK Team
|
|
1424
|
+
*/
|
|
1425
|
+
interface APIResponse {
|
|
1426
|
+
/**
|
|
1427
|
+
* 📊 Response data
|
|
1428
|
+
* @description The main response data from the API
|
|
1429
|
+
* @type {any}
|
|
1430
|
+
*/
|
|
1431
|
+
data: any;
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* 📊 HTTP status code
|
|
1435
|
+
* @description HTTP status code of the response
|
|
1436
|
+
* @type {number}
|
|
1437
|
+
*/
|
|
1438
|
+
status: number;
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* 📝 Optional response message
|
|
1442
|
+
* @description Optional message from the API response
|
|
1443
|
+
* @type {string | undefined}
|
|
1444
|
+
*/
|
|
1445
|
+
message?: string;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* 📡 API Response Interface
|
|
1450
|
+
*
|
|
1451
|
+
* @interface APIResponse
|
|
1452
|
+
* @description 📊 Type definition for API response structure
|
|
1453
|
+
* Used for type safety in API call responses
|
|
1454
|
+
*
|
|
1455
|
+
* @properties
|
|
1456
|
+
* - `data: any` - 📊 Response data
|
|
1457
|
+
* - `status: number` - 📊 HTTP status code
|
|
1458
|
+
* - `message?: string` - 📝 Optional response message
|
|
1459
|
+
*
|
|
1460
|
+
* @since 1.0.0
|
|
1461
|
+
* @author CTI SDK Team
|
|
1462
|
+
*/
|
|
1463
|
+
interface APIResponse {
|
|
1464
|
+
/**
|
|
1465
|
+
* 📊 Response data
|
|
1466
|
+
* @description The main response data from the API
|
|
1467
|
+
* @type {any}
|
|
1468
|
+
*/
|
|
1469
|
+
data: any;
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* 📊 HTTP status code
|
|
1473
|
+
* @description HTTP status code of the response
|
|
1474
|
+
* @type {number}
|
|
1475
|
+
*/
|
|
1476
|
+
status: number;
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* 📝 Optional response message
|
|
1480
|
+
* @description Optional message from the API response
|
|
1481
|
+
* @type {string | undefined}
|
|
1482
|
+
*/
|
|
1483
|
+
message?: string;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* 📡 API Response Interface
|
|
1488
|
+
*
|
|
1489
|
+
* @interface APIResponse
|
|
1490
|
+
* @description 📊 Type definition for API response structure
|
|
1491
|
+
* Used for type safety in API call responses
|
|
1492
|
+
*
|
|
1493
|
+
* @properties
|
|
1494
|
+
* - `data: any` - 📊 Response data
|
|
1495
|
+
* - `status: number` - 📊 HTTP status code
|
|
1496
|
+
* - `message?: string` - 📝 Optional response message
|
|
1497
|
+
*
|
|
315
1498
|
* @since 1.0.0
|
|
316
1499
|
* @author CTI SDK Team
|
|
317
1500
|
*/
|
|
318
|
-
|
|
1501
|
+
interface APIResponse {
|
|
1502
|
+
/**
|
|
1503
|
+
* 📊 Response data
|
|
1504
|
+
* @description The main response data from the API
|
|
1505
|
+
* @type {any}
|
|
1506
|
+
*/
|
|
1507
|
+
data: any;
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* 📊 HTTP status code
|
|
1511
|
+
* @description HTTP status code of the response
|
|
1512
|
+
* @type {number}
|
|
1513
|
+
*/
|
|
1514
|
+
status: number;
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* 📝 Optional response message
|
|
1518
|
+
* @description Optional message from the API response
|
|
1519
|
+
* @type {string | undefined}
|
|
1520
|
+
*/
|
|
1521
|
+
message?: string;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* 🛡️ Error Response Interface
|
|
1526
|
+
*
|
|
1527
|
+
* @interface ErrorResponse
|
|
1528
|
+
* @description 📊 Type definition for error response structure
|
|
1529
|
+
* Used for type safety in error handling
|
|
1530
|
+
*
|
|
1531
|
+
* @properties
|
|
1532
|
+
* - `message: string` - 📝 Error message
|
|
1533
|
+
* - `code?: string` - 🔢 Optional error code
|
|
1534
|
+
* - `details?: any` - 📊 Optional error details
|
|
1535
|
+
*
|
|
1536
|
+
* @since 1.0.0
|
|
1537
|
+
* @author CTI SDK Team
|
|
1538
|
+
*/
|
|
1539
|
+
interface ErrorResponse {
|
|
1540
|
+
/**
|
|
1541
|
+
* 📝 Error message
|
|
1542
|
+
* @description Human-readable error message
|
|
1543
|
+
* @type {string}
|
|
1544
|
+
*/
|
|
1545
|
+
message: string;
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* 🔢 Optional error code
|
|
1549
|
+
* @description Optional error code for programmatic handling
|
|
1550
|
+
* @type {string | undefined}
|
|
1551
|
+
*/
|
|
1552
|
+
code?: string;
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* 📊 Optional error details
|
|
1556
|
+
* @description Optional additional error details
|
|
1557
|
+
* @type {any}
|
|
1558
|
+
*/
|
|
1559
|
+
details?: any;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* 🛡️ Error Response Interface
|
|
1564
|
+
*
|
|
1565
|
+
* @interface ErrorResponse
|
|
1566
|
+
* @description 📊 Type definition for error response structure
|
|
1567
|
+
* Used for type safety in error handling
|
|
1568
|
+
*
|
|
1569
|
+
* @properties
|
|
1570
|
+
* - `message: string` - 📝 Error message
|
|
1571
|
+
* - `code?: string` - 🔢 Optional error code
|
|
1572
|
+
* - `details?: any` - 📊 Optional error details
|
|
1573
|
+
*
|
|
1574
|
+
* @since 1.0.0
|
|
1575
|
+
* @author CTI SDK Team
|
|
1576
|
+
*/
|
|
1577
|
+
interface ErrorResponse {
|
|
1578
|
+
/**
|
|
1579
|
+
* 📝 Error message
|
|
1580
|
+
* @description Human-readable error message
|
|
1581
|
+
* @type {string}
|
|
1582
|
+
*/
|
|
1583
|
+
message: string;
|
|
1584
|
+
|
|
1585
|
+
/**
|
|
1586
|
+
* 🔢 Optional error code
|
|
1587
|
+
* @description Optional error code for programmatic handling
|
|
1588
|
+
* @type {string | undefined}
|
|
1589
|
+
*/
|
|
1590
|
+
code?: string;
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* 📊 Optional error details
|
|
1594
|
+
* @description Optional additional error details
|
|
1595
|
+
* @type {any}
|
|
1596
|
+
*/
|
|
1597
|
+
details?: any;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* 🛡️ Error Response Interface
|
|
1602
|
+
*
|
|
1603
|
+
* @interface ErrorResponse
|
|
1604
|
+
* @description 📊 Type definition for error response structure
|
|
1605
|
+
* Used for type safety in error handling
|
|
1606
|
+
*
|
|
1607
|
+
* @properties
|
|
1608
|
+
* - `message: string` - 📝 Error message
|
|
1609
|
+
* - `code?: string` - 🔢 Optional error code
|
|
1610
|
+
* - `details?: any` - 📊 Optional error details
|
|
1611
|
+
*
|
|
1612
|
+
* @since 1.0.0
|
|
1613
|
+
* @author CTI SDK Team
|
|
1614
|
+
*/
|
|
1615
|
+
interface ErrorResponse {
|
|
1616
|
+
/**
|
|
1617
|
+
* 📝 Error message
|
|
1618
|
+
* @description Human-readable error message
|
|
1619
|
+
* @type {string}
|
|
1620
|
+
*/
|
|
1621
|
+
message: string;
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* 🔢 Optional error code
|
|
1625
|
+
* @description Optional error code for programmatic handling
|
|
1626
|
+
* @type {string | undefined}
|
|
1627
|
+
*/
|
|
1628
|
+
code?: string;
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* 📊 Optional error details
|
|
1632
|
+
* @description Optional additional error details
|
|
1633
|
+
* @type {any}
|
|
1634
|
+
*/
|
|
1635
|
+
details?: any;
|
|
1636
|
+
}
|
|
319
1637
|
|
|
320
|
-
export { CallControlPanel, type CallControlPanelProps, type CallData, type InitSDKParams, type SDKConfig, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useLogout };
|
|
1638
|
+
export { type APIResponse, type AgentStatus, CallControlPanel, type CallControlPanelProps, type CallData, type CallInitiationFunction, type CallTerminationFunction, type CleanupOperation, type ConferenceLine, type DispositionType, type EndCallData, type EndCallPayLoadData, type EndCallPayload, type ErrorResponse, type FollowUpType, type HookStateTypes, type InitSDKParams, type LogoutFunction, type LogoutHookStateTypes, type LogoutPayload, type ProcessData, type SDKConfig, type SDKState, type StartCallPayload, type StartCalltData, type StartCalltHookStateTypes, type StorageType, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useLogout };
|