ahs-cti 0.0.2-beta.1 → 0.0.2-beta.10
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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +59 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -52,6 +52,8 @@ interface InitSDKParams {
|
|
|
52
52
|
agentId: string;
|
|
53
53
|
/** Optional SDK configuration for customizing behavior */
|
|
54
54
|
sdkConfig?: SDKConfig;
|
|
55
|
+
/** Optional URL configuration for SDK endpoints */
|
|
56
|
+
urlConfig?: URLConfig;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/**
|
|
@@ -232,6 +234,15 @@ interface SDKConfig {
|
|
|
232
234
|
outlined?: any;
|
|
233
235
|
}
|
|
234
236
|
|
|
237
|
+
interface URLConfig {
|
|
238
|
+
id: string;
|
|
239
|
+
baseURL: string;
|
|
240
|
+
iframeURL: string;
|
|
241
|
+
iframeAPIURL: string;
|
|
242
|
+
password: string;
|
|
243
|
+
webSocketURL: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
235
246
|
/**
|
|
236
247
|
* 🎭 Call Control Panel Props Interface
|
|
237
248
|
*
|
|
@@ -1779,4 +1790,4 @@ interface ErrorResponse {
|
|
|
1779
1790
|
details?: any;
|
|
1780
1791
|
}
|
|
1781
1792
|
|
|
1782
|
-
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, useGetAuthorizationToken, useGetCallerData, useLogout };
|
|
1793
|
+
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 URLConfig, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useGetAuthorizationToken, useGetCallerData, useLogout };
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ interface InitSDKParams {
|
|
|
52
52
|
agentId: string;
|
|
53
53
|
/** Optional SDK configuration for customizing behavior */
|
|
54
54
|
sdkConfig?: SDKConfig;
|
|
55
|
+
/** Optional URL configuration for SDK endpoints */
|
|
56
|
+
urlConfig?: URLConfig;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/**
|
|
@@ -232,6 +234,15 @@ interface SDKConfig {
|
|
|
232
234
|
outlined?: any;
|
|
233
235
|
}
|
|
234
236
|
|
|
237
|
+
interface URLConfig {
|
|
238
|
+
id: string;
|
|
239
|
+
baseURL: string;
|
|
240
|
+
iframeURL: string;
|
|
241
|
+
iframeAPIURL: string;
|
|
242
|
+
password: string;
|
|
243
|
+
webSocketURL: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
235
246
|
/**
|
|
236
247
|
* 🎭 Call Control Panel Props Interface
|
|
237
248
|
*
|
|
@@ -1779,4 +1790,4 @@ interface ErrorResponse {
|
|
|
1779
1790
|
details?: any;
|
|
1780
1791
|
}
|
|
1781
1792
|
|
|
1782
|
-
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, useGetAuthorizationToken, useGetCallerData, useLogout };
|
|
1793
|
+
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 URLConfig, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useGetAuthorizationToken, useGetCallerData, useLogout };
|
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: "",
|
|
@@ -385,7 +387,7 @@ var SDKStateManager = class {
|
|
|
385
387
|
this.apiKey = apiKey.trim();
|
|
386
388
|
this.tenantId = tenantId.trim();
|
|
387
389
|
}
|
|
388
|
-
initialize(apiKey, tenantId, agentId,
|
|
390
|
+
initialize(apiKey, tenantId, agentId, urlConfig, initResult, sdkConfig) {
|
|
389
391
|
this.validateCredentials(apiKey, tenantId);
|
|
390
392
|
if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
|
|
391
393
|
throw new Error("Agent ID not available");
|
|
@@ -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);
|
|
@@ -3163,7 +3151,7 @@ var formatDuration = (seconds) => {
|
|
|
3163
3151
|
return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
|
|
3164
3152
|
};
|
|
3165
3153
|
function CallControls({ onDataChange }) {
|
|
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;
|
|
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, _Aa;
|
|
3167
3155
|
const theme = (0, import_material4.useTheme)();
|
|
3168
3156
|
const state = useSDKState();
|
|
3169
3157
|
const { showToast } = useToast();
|
|
@@ -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");
|
|
@@ -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}?
|
|
3486
|
+
webSocketRef.current = new WebSocket(`${(_a3 = state.urlConfig) == null ? void 0 : _a3.webSocketURL}/api/v1/ws/agent/events?token=${(_b2 = state.authorization) == null ? void 0 : _b2.accessToken}`);
|
|
3498
3487
|
webSocketRef.current.onopen = () => {
|
|
3499
3488
|
console.log("\u{1F310} WebSocket connection established");
|
|
3500
3489
|
reconnectAttemptsRef.current = 0;
|
|
@@ -4147,7 +4136,7 @@ function CallControls({ onDataChange }) {
|
|
|
4147
4136
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4148
4137
|
"iframe",
|
|
4149
4138
|
{
|
|
4150
|
-
src: `${(_ya = state.urlConfig) == null ? void 0 : _ya.iframeURL}/static/phone/cti_index.html?user_id=${state.
|
|
4139
|
+
src: `${(_ya = state.urlConfig) == null ? void 0 : _ya.iframeURL}/static/phone/cti_index.html?user_id=${(_za = state.urlConfig) == null ? void 0 : _za.id}&api_url=${(_Aa = state.urlConfig) == null ? void 0 : _Aa.iframeAPIURL}`,
|
|
4151
4140
|
height: 380,
|
|
4152
4141
|
width: 420,
|
|
4153
4142
|
allow: "camera; microphone; autoplay",
|
|
@@ -4530,8 +4519,9 @@ async function initSDK({
|
|
|
4530
4519
|
apiKey.trim(),
|
|
4531
4520
|
tenantId.trim(),
|
|
4532
4521
|
agentId.trim(),
|
|
4533
|
-
|
|
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();
|