ahs-cti 0.0.2-beta.10 → 0.0.2-beta.4
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 +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +68 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -58
- 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,7 +217,6 @@ var SDKStateManager = class {
|
|
|
217
217
|
iframeURL: "",
|
|
218
218
|
iframeAPIURL: "",
|
|
219
219
|
webSocketURL: "",
|
|
220
|
-
id: "",
|
|
221
220
|
password: ""
|
|
222
221
|
},
|
|
223
222
|
callStartTime: null,
|
|
@@ -318,7 +317,6 @@ var SDKStateManager = class {
|
|
|
318
317
|
outlined: {}
|
|
319
318
|
},
|
|
320
319
|
urlConfig: parsedState.urlConfig || {
|
|
321
|
-
id: "",
|
|
322
320
|
baseURL: "",
|
|
323
321
|
iframeURL: "",
|
|
324
322
|
iframeAPIURL: "",
|
|
@@ -415,7 +413,6 @@ var SDKStateManager = class {
|
|
|
415
413
|
iframeURL: (urlConfig == null ? void 0 : urlConfig.iframeURL) || "",
|
|
416
414
|
iframeAPIURL: (urlConfig == null ? void 0 : urlConfig.iframeAPIURL) || "",
|
|
417
415
|
webSocketURL: (urlConfig == null ? void 0 : urlConfig.webSocketURL) || "",
|
|
418
|
-
id: (urlConfig == null ? void 0 : urlConfig.id) || "",
|
|
419
416
|
password: (urlConfig == null ? void 0 : urlConfig.password) || ""
|
|
420
417
|
};
|
|
421
418
|
this.state.isInitialized = true;
|
|
@@ -595,54 +592,6 @@ var sdkStateManager = new SDKStateManager();
|
|
|
595
592
|
|
|
596
593
|
// call-control-sdk/lib/hooks/useLogout.ts
|
|
597
594
|
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");
|
|
646
595
|
|
|
647
596
|
// call-control-sdk/lib/services/axios.ts
|
|
648
597
|
var import_axios = __toESM(require("axios"));
|
|
@@ -708,7 +657,70 @@ function createAxiosInstance() {
|
|
|
708
657
|
var axiosInstance = createAxiosInstance();
|
|
709
658
|
var axios_default = axiosInstance;
|
|
710
659
|
|
|
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
|
+
|
|
711
722
|
// call-control-sdk/lib/hooks/useEndCall.ts
|
|
723
|
+
var import_react2 = require("react");
|
|
712
724
|
var import_vault3 = require("@react-solutions/vault");
|
|
713
725
|
var useEndCall = () => {
|
|
714
726
|
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
@@ -3151,7 +3163,7 @@ var formatDuration = (seconds) => {
|
|
|
3151
3163
|
return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
|
|
3152
3164
|
};
|
|
3153
3165
|
function CallControls({ onDataChange }) {
|
|
3154
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za
|
|
3166
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za;
|
|
3155
3167
|
const theme = (0, import_material4.useTheme)();
|
|
3156
3168
|
const state = useSDKState();
|
|
3157
3169
|
const { showToast } = useToast();
|
|
@@ -3458,7 +3470,6 @@ function CallControls({ onDataChange }) {
|
|
|
3458
3470
|
"process_id": 101,
|
|
3459
3471
|
"process_name": "ConVoxProcess"
|
|
3460
3472
|
};
|
|
3461
|
-
setProcessList([data]);
|
|
3462
3473
|
sdkStateManager.setProcess(data);
|
|
3463
3474
|
}).catch((err) => {
|
|
3464
3475
|
showToast(err.response.data.message, "error");
|
|
@@ -3483,7 +3494,7 @@ function CallControls({ onDataChange }) {
|
|
|
3483
3494
|
reconnectTimeoutRef.current = null;
|
|
3484
3495
|
}
|
|
3485
3496
|
try {
|
|
3486
|
-
webSocketRef.current = new WebSocket(`${(_a3 = state.urlConfig) == null ? void 0 : _a3.webSocketURL}
|
|
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}`);
|
|
3487
3498
|
webSocketRef.current.onopen = () => {
|
|
3488
3499
|
console.log("\u{1F310} WebSocket connection established");
|
|
3489
3500
|
reconnectAttemptsRef.current = 0;
|
|
@@ -4136,7 +4147,7 @@ function CallControls({ onDataChange }) {
|
|
|
4136
4147
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4137
4148
|
"iframe",
|
|
4138
4149
|
{
|
|
4139
|
-
src: `${(_ya = state.urlConfig) == null ? void 0 : _ya.iframeURL}/static/phone/cti_index.html?user_id=${
|
|
4150
|
+
src: `${(_ya = state.urlConfig) == null ? void 0 : _ya.iframeURL}/static/phone/cti_index.html?user_id=${state.agentId}&api_url=${(_za = state.urlConfig) == null ? void 0 : _za.iframeAPIURL}`,
|
|
4140
4151
|
height: 380,
|
|
4141
4152
|
width: 420,
|
|
4142
4153
|
allow: "camera; microphone; autoplay",
|
|
@@ -4519,9 +4530,8 @@ async function initSDK({
|
|
|
4519
4530
|
apiKey.trim(),
|
|
4520
4531
|
tenantId.trim(),
|
|
4521
4532
|
agentId.trim(),
|
|
4522
|
-
|
|
4523
|
-
res
|
|
4524
|
-
__spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig)
|
|
4533
|
+
__spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig),
|
|
4534
|
+
res
|
|
4525
4535
|
);
|
|
4526
4536
|
} else {
|
|
4527
4537
|
sdkStateManager.setInitCheck();
|