ahs-cti 0.0.2-beta.6 → 0.0.2-beta.7
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +58 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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);
|
|
@@ -3485,7 +3473,7 @@ function CallControls({ onDataChange }) {
|
|
|
3485
3473
|
}
|
|
3486
3474
|
}, [state.agentId]);
|
|
3487
3475
|
const connectWebSocket = () => {
|
|
3488
|
-
var _a3, _b2;
|
|
3476
|
+
var _a3, _b2, _c2;
|
|
3489
3477
|
if (!state.agentId) {
|
|
3490
3478
|
return;
|
|
3491
3479
|
}
|
|
@@ -3494,7 +3482,7 @@ function CallControls({ onDataChange }) {
|
|
|
3494
3482
|
reconnectTimeoutRef.current = null;
|
|
3495
3483
|
}
|
|
3496
3484
|
try {
|
|
3497
|
-
webSocketRef.current = new WebSocket(`${(_a3 = state.urlConfig) == null ? void 0 : _a3.webSocketURL}?agent_id=${state.
|
|
3485
|
+
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
3486
|
webSocketRef.current.onopen = () => {
|
|
3499
3487
|
console.log("\u{1F310} WebSocket connection established");
|
|
3500
3488
|
reconnectAttemptsRef.current = 0;
|
|
@@ -3512,7 +3500,7 @@ function CallControls({ onDataChange }) {
|
|
|
3512
3500
|
}, 3e4);
|
|
3513
3501
|
};
|
|
3514
3502
|
webSocketRef.current.onmessage = (event) => {
|
|
3515
|
-
var _a4, _b3,
|
|
3503
|
+
var _a4, _b3, _c3, _d2, _e2;
|
|
3516
3504
|
try {
|
|
3517
3505
|
const data = JSON.parse(event.data);
|
|
3518
3506
|
if (data.type === "pong") {
|
|
@@ -3591,7 +3579,7 @@ function CallControls({ onDataChange }) {
|
|
|
3591
3579
|
isMergeCall: false
|
|
3592
3580
|
}
|
|
3593
3581
|
]);
|
|
3594
|
-
if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current && ((
|
|
3582
|
+
if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current && ((_c3 = state == null ? void 0 : state.sdkConfig) == null ? void 0 : _c3.enableRingtone)) {
|
|
3595
3583
|
audioRef.current.play().catch((error) => {
|
|
3596
3584
|
console.error("Failed to play ringtone:", error);
|
|
3597
3585
|
});
|
|
@@ -4530,8 +4518,9 @@ async function initSDK({
|
|
|
4530
4518
|
apiKey.trim(),
|
|
4531
4519
|
tenantId.trim(),
|
|
4532
4520
|
agentId.trim(),
|
|
4533
|
-
|
|
4534
|
-
res
|
|
4521
|
+
urlConfig,
|
|
4522
|
+
res,
|
|
4523
|
+
__spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig)
|
|
4535
4524
|
);
|
|
4536
4525
|
} else {
|
|
4537
4526
|
sdkStateManager.setInitCheck();
|