call-control-sdk 6.1.2 → 6.2.0

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