ahs-cti 0.0.2-beta.6 → 0.0.2-beta.8

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
@@ -235,6 +235,7 @@ interface SDKConfig {
235
235
  }
236
236
 
237
237
  interface URLConfig {
238
+ id: string;
238
239
  baseURL: string;
239
240
  iframeURL: string;
240
241
  iframeAPIURL: string;
package/dist/index.d.ts CHANGED
@@ -235,6 +235,7 @@ interface SDKConfig {
235
235
  }
236
236
 
237
237
  interface URLConfig {
238
+ id: string;
238
239
  baseURL: string;
239
240
  iframeURL: string;
240
241
  iframeAPIURL: string;
package/dist/index.js CHANGED
@@ -217,6 +217,7 @@ var SDKStateManager = class {
217
217
  iframeURL: "",
218
218
  iframeAPIURL: "",
219
219
  webSocketURL: "",
220
+ id: "",
220
221
  password: ""
221
222
  },
222
223
  callStartTime: null,
@@ -317,6 +318,7 @@ var SDKStateManager = class {
317
318
  outlined: {}
318
319
  },
319
320
  urlConfig: parsedState.urlConfig || {
321
+ id: "",
320
322
  baseURL: "",
321
323
  iframeURL: "",
322
324
  iframeAPIURL: "",
@@ -413,6 +415,7 @@ var SDKStateManager = class {
413
415
  iframeURL: (urlConfig == null ? void 0 : urlConfig.iframeURL) || "",
414
416
  iframeAPIURL: (urlConfig == null ? void 0 : urlConfig.iframeAPIURL) || "",
415
417
  webSocketURL: (urlConfig == null ? void 0 : urlConfig.webSocketURL) || "",
418
+ id: (urlConfig == null ? void 0 : urlConfig.id) || "",
416
419
  password: (urlConfig == null ? void 0 : urlConfig.password) || ""
417
420
  };
418
421
  this.state.isInitialized = true;
@@ -592,6 +595,54 @@ var sdkStateManager = new SDKStateManager();
592
595
 
593
596
  // call-control-sdk/lib/hooks/useLogout.ts
594
597
  var import_react = require("react");
598
+ var import_vault2 = require("@react-solutions/vault");
599
+
600
+ // call-control-sdk/lib/services/usbLight.ts
601
+ var USB_LIGHT_BASE_URL = `http://localhost:5000`;
602
+ var USB_LIGHT_ON = (color) => {
603
+ return `${USB_LIGHT_BASE_URL}/light/${color}/on`;
604
+ };
605
+ var USB_LIGHT_FLASH = (color, number) => {
606
+ return `${USB_LIGHT_BASE_URL}/light/${color}/flash${number}`;
607
+ };
608
+ var USB_LIGHT_ALL_OFF = () => {
609
+ return `${USB_LIGHT_BASE_URL}/all/off`;
610
+ };
611
+ var USB_LIGHT_REQUEST = (url, init) => {
612
+ return fetch(url, init);
613
+ };
614
+
615
+ // call-control-sdk/lib/hooks/useLogout.ts
616
+ var useLogout = () => {
617
+ const [loading, setLoading] = (0, import_react.useState)(false);
618
+ const [success, setSuccess] = (0, import_react.useState)(false);
619
+ const [isError, setIsError] = (0, import_react.useState)(false);
620
+ const [error, setError] = (0, import_react.useState)(null);
621
+ const [data, setData] = (0, import_react.useState)(null);
622
+ const handleLogout = (0, import_react.useCallback)(async () => {
623
+ USB_LIGHT_REQUEST(USB_LIGHT_ALL_OFF());
624
+ const state = (0, import_vault2.getItem)(STORAGE_KEY);
625
+ setLoading(true);
626
+ const payload = {
627
+ action: "LOGOUTUSER",
628
+ userId: state.agentId || ""
629
+ };
630
+ sdkStateManager.clearStorageAndReset();
631
+ (0, import_vault2.removeItem)(STORAGE_KEY);
632
+ setSuccess(true);
633
+ }, []);
634
+ return {
635
+ logout: handleLogout,
636
+ isLoading: loading,
637
+ isSuccess: success,
638
+ isError,
639
+ error,
640
+ data
641
+ };
642
+ };
643
+
644
+ // call-control-sdk/lib/hooks/useEndCall.ts
645
+ var import_react2 = require("react");
595
646
 
596
647
  // call-control-sdk/lib/services/axios.ts
597
648
  var import_axios = __toESM(require("axios"));
@@ -657,70 +708,7 @@ function createAxiosInstance() {
657
708
  var axiosInstance = createAxiosInstance();
658
709
  var axios_default = axiosInstance;
659
710
 
660
- // call-control-sdk/lib/hooks/useLogout.ts
661
- var import_vault2 = require("@react-solutions/vault");
662
-
663
- // call-control-sdk/lib/services/usbLight.ts
664
- var USB_LIGHT_BASE_URL = `http://localhost:5000`;
665
- var USB_LIGHT_ON = (color) => {
666
- return `${USB_LIGHT_BASE_URL}/light/${color}/on`;
667
- };
668
- var USB_LIGHT_FLASH = (color, number) => {
669
- return `${USB_LIGHT_BASE_URL}/light/${color}/flash${number}`;
670
- };
671
- var USB_LIGHT_ALL_OFF = () => {
672
- return `${USB_LIGHT_BASE_URL}/all/off`;
673
- };
674
- var USB_LIGHT_REQUEST = (url, init) => {
675
- return fetch(url, init);
676
- };
677
-
678
- // call-control-sdk/lib/hooks/useLogout.ts
679
- var useLogout = () => {
680
- const [loading, setLoading] = (0, import_react.useState)(false);
681
- const [success, setSuccess] = (0, import_react.useState)(false);
682
- const [isError, setIsError] = (0, import_react.useState)(false);
683
- const [error, setError] = (0, import_react.useState)(null);
684
- const [data, setData] = (0, import_react.useState)(null);
685
- const handleLogout = (0, import_react.useCallback)(async () => {
686
- USB_LIGHT_REQUEST(USB_LIGHT_ALL_OFF());
687
- const state = (0, import_vault2.getItem)(STORAGE_KEY);
688
- setLoading(true);
689
- const payload = {
690
- action: "LOGOUTUSER",
691
- userId: state.agentId || ""
692
- };
693
- return axios_default.post(END_POINT.LOGOUT, payload).then((res) => {
694
- sdkStateManager.clearStorageAndReset();
695
- (0, import_vault2.removeItem)(STORAGE_KEY);
696
- setData(res == null ? void 0 : res.data);
697
- setSuccess(true);
698
- return res == null ? void 0 : res.data;
699
- }).catch((err) => {
700
- var _a2, _b, _c, _d;
701
- setIsError(true);
702
- setError(err);
703
- if ((_c = (_b = (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.data) == null ? void 0 : _c.clearAgentData) {
704
- sdkStateManager.clearStorageAndReset();
705
- (0, import_vault2.removeItem)(STORAGE_KEY);
706
- }
707
- return (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.data;
708
- }).finally(() => {
709
- setLoading(false);
710
- });
711
- }, []);
712
- return {
713
- logout: handleLogout,
714
- isLoading: loading,
715
- isSuccess: success,
716
- isError,
717
- error,
718
- data
719
- };
720
- };
721
-
722
711
  // call-control-sdk/lib/hooks/useEndCall.ts
723
- var import_react2 = require("react");
724
712
  var import_vault3 = require("@react-solutions/vault");
725
713
  var useEndCall = () => {
726
714
  const [loading, setLoading] = (0, import_react2.useState)(false);
@@ -3470,6 +3458,7 @@ function CallControls({ onDataChange }) {
3470
3458
  "process_id": 101,
3471
3459
  "process_name": "ConVoxProcess"
3472
3460
  };
3461
+ setProcessList([data]);
3473
3462
  sdkStateManager.setProcess(data);
3474
3463
  }).catch((err) => {
3475
3464
  showToast(err.response.data.message, "error");
@@ -3485,7 +3474,7 @@ function CallControls({ onDataChange }) {
3485
3474
  }
3486
3475
  }, [state.agentId]);
3487
3476
  const connectWebSocket = () => {
3488
- var _a3, _b2;
3477
+ var _a3, _b2, _c2;
3489
3478
  if (!state.agentId) {
3490
3479
  return;
3491
3480
  }
@@ -3494,7 +3483,7 @@ function CallControls({ onDataChange }) {
3494
3483
  reconnectTimeoutRef.current = null;
3495
3484
  }
3496
3485
  try {
3497
- webSocketRef.current = new WebSocket(`${(_a3 = state.urlConfig) == null ? void 0 : _a3.webSocketURL}?agent_id=${state.agentId}&accessToken=${(_b2 = state.authorization) == null ? void 0 : _b2.accessToken}`);
3486
+ webSocketRef.current = new WebSocket(`${(_a3 = state.urlConfig) == null ? void 0 : _a3.webSocketURL}?agent_id=${(_b2 = state.urlConfig) == null ? void 0 : _b2.id}&token=${(_c2 = state.authorization) == null ? void 0 : _c2.accessToken}`);
3498
3487
  webSocketRef.current.onopen = () => {
3499
3488
  console.log("\u{1F310} WebSocket connection established");
3500
3489
  reconnectAttemptsRef.current = 0;
@@ -3512,7 +3501,7 @@ function CallControls({ onDataChange }) {
3512
3501
  }, 3e4);
3513
3502
  };
3514
3503
  webSocketRef.current.onmessage = (event) => {
3515
- var _a4, _b3, _c2, _d2, _e2;
3504
+ var _a4, _b3, _c3, _d2, _e2;
3516
3505
  try {
3517
3506
  const data = JSON.parse(event.data);
3518
3507
  if (data.type === "pong") {
@@ -3591,7 +3580,7 @@ function CallControls({ onDataChange }) {
3591
3580
  isMergeCall: false
3592
3581
  }
3593
3582
  ]);
3594
- if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current && ((_c2 = state == null ? void 0 : state.sdkConfig) == null ? void 0 : _c2.enableRingtone)) {
3583
+ if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current && ((_c3 = state == null ? void 0 : state.sdkConfig) == null ? void 0 : _c3.enableRingtone)) {
3595
3584
  audioRef.current.play().catch((error) => {
3596
3585
  console.error("Failed to play ringtone:", error);
3597
3586
  });
@@ -4530,8 +4519,9 @@ async function initSDK({
4530
4519
  apiKey.trim(),
4531
4520
  tenantId.trim(),
4532
4521
  agentId.trim(),
4533
- __spreadValues(__spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig), urlConfig),
4534
- res
4522
+ urlConfig,
4523
+ res,
4524
+ __spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig)
4535
4525
  );
4536
4526
  } else {
4537
4527
  sdkStateManager.setInitCheck();