@microsoft/omnichannel-chat-widget 1.7.4-main.0574a04 → 1.7.4-main.1f61ac6
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/lib/cjs/common/facades/FacadeChatSDK.js +298 -0
- package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +12 -0
- package/lib/cjs/common/utils.js +2 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
- package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
- package/lib/cjs/components/livechatwidget/common/endChat.js +21 -22
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +3 -3
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +48 -39
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
- package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
- package/lib/cjs/index.js +9 -2
- package/lib/cjs/plugins/createChatTranscript.js +2 -2
- package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
- package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +12 -0
- package/lib/esm/common/utils.js +2 -2
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
- package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
- package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
- package/lib/esm/components/livechatwidget/common/endChat.js +21 -22
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +3 -3
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +49 -40
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
- package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
- package/lib/esm/index.js +5 -4
- package/lib/esm/plugins/createChatTranscript.js +2 -2
- package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +7 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +7 -0
- package/lib/types/common/utils.d.ts +2 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
- package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
- package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
- package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
- package/lib/types/index.d.ts +4 -3
- package/lib/types/plugins/createChatTranscript.d.ts +2 -1
- package/package.json +2 -2
|
@@ -53,7 +53,7 @@ import { setPostChatContextAndLoadSurvey } from "../common/setPostChatContextAnd
|
|
|
53
53
|
import { startProactiveChat } from "../common/startProactiveChat";
|
|
54
54
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
55
55
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
56
|
-
import
|
|
56
|
+
import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
|
|
57
57
|
export const LiveChatWidgetStateful = props => {
|
|
58
58
|
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
59
59
|
const [state, dispatch] = useChatContextStore();
|
|
@@ -64,7 +64,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
64
64
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
|
|
65
65
|
});
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
-
const
|
|
67
|
+
const [facadeChatSDK] = useFacadeSDKStore();
|
|
68
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
69
|
const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = useState(undefined);
|
|
70
70
|
const {
|
|
@@ -82,8 +82,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
82
82
|
|
|
83
83
|
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
84
84
|
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
85
|
-
var
|
|
86
|
-
const broadcastServiceChannelName = getBroadcastChannelName(
|
|
85
|
+
var _facadeChatSDK$getCha, _facadeChatSDK$getCha2, _props$controlProps2;
|
|
86
|
+
const broadcastServiceChannelName = getBroadcastChannelName((_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha === void 0 ? void 0 : (_facadeChatSDK$getCha2 = _facadeChatSDK$getCha.omnichannelConfig) === null || _facadeChatSDK$getCha2 === void 0 ? void 0 : _facadeChatSDK$getCha2.widgetId, ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
|
|
87
87
|
BroadcastServiceInitialize(broadcastServiceChannelName);
|
|
88
88
|
}
|
|
89
89
|
TelemetryTimers.LcwLoadToChatButtonTimer = createTimer();
|
|
@@ -118,7 +118,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
118
118
|
const startChat = async (props, localState) => {
|
|
119
119
|
const isReconnectTriggered = async () => {
|
|
120
120
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
121
|
-
const noValidReconnectId = await handleChatReconnect(
|
|
121
|
+
const noValidReconnectId = await handleChatReconnect(facadeChatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
122
122
|
const inMemoryState = executeReducer(state, {
|
|
123
123
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
124
124
|
payload: null
|
|
@@ -139,11 +139,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
//Check if conversation state is not in wrapup or closed state
|
|
142
|
-
isChatValid = await checkIfConversationStillValid(
|
|
142
|
+
isChatValid = await checkIfConversationStillValid(facadeChatSDK, dispatch, state);
|
|
143
143
|
if (isChatValid === true) {
|
|
144
144
|
const reconnectTriggered = await isReconnectTriggered();
|
|
145
145
|
if (!reconnectTriggered) {
|
|
146
|
-
await initStartChat(
|
|
146
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
147
147
|
}
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
@@ -163,7 +163,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
163
163
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
164
164
|
payload: null
|
|
165
165
|
});
|
|
166
|
-
await setPreChatAndInitiateChat(
|
|
166
|
+
await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, undefined, undefined, inMemoryState, props);
|
|
167
167
|
}
|
|
168
168
|
return;
|
|
169
169
|
} else {
|
|
@@ -233,7 +233,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== E2VVOptions.NoCalling) {
|
|
236
|
-
initCallingSdk(
|
|
236
|
+
initCallingSdk(facadeChatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
237
237
|
sdkCreated && dispatch({
|
|
238
238
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
239
239
|
payload: true
|
|
@@ -265,9 +265,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
265
265
|
useEffect(() => {
|
|
266
266
|
var _state$appStates6;
|
|
267
267
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
|
|
268
|
-
var _props$chatConfig3, _props$chatConfig3$Li;
|
|
268
|
+
var _props$chatConfig3, _props$chatConfig3$Li, _props$chatConfig4, _props$chatConfig4$Li;
|
|
269
269
|
//handle OOH pane
|
|
270
|
-
if ((props === null || props === void 0 ? void 0 : (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
270
|
+
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
271
271
|
dispatch({
|
|
272
272
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
273
273
|
payload: ConversationState.OutOfOffice
|
|
@@ -290,7 +290,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
290
290
|
|
|
291
291
|
// useEffect for custom context
|
|
292
292
|
useEffect(() => {
|
|
293
|
-
var
|
|
293
|
+
var _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _facadeChatSDK$getCha6, _props$controlProps11;
|
|
294
294
|
// Add the custom context on receiving the SetCustomContext event
|
|
295
295
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
296
296
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -343,7 +343,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
343
343
|
if (callInProgress.current === false && dateNow - lastLWICheckTimeRef.current > Constants.LWICheckOnVisibilityTimeout) {
|
|
344
344
|
lastLWICheckTimeRef.current = dateNow;
|
|
345
345
|
callInProgress.current = true;
|
|
346
|
-
const conversationDetails = await getConversationDetailsCall(
|
|
346
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
347
347
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
|
|
348
348
|
dispatch({
|
|
349
349
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -359,11 +359,15 @@ export const LiveChatWidgetStateful = props => {
|
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
BroadcastService.getMessageByEventName(BroadcastEvent.NetworkReconnected).subscribe(async () => {
|
|
362
|
-
var _window2, _window2$location;
|
|
363
|
-
|
|
362
|
+
var _window2, _window2$location, _inMemoryState$appSta;
|
|
363
|
+
const inMemoryState = executeReducer(state, {
|
|
364
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
365
|
+
payload: null
|
|
366
|
+
});
|
|
367
|
+
if (isThisSessionPopout((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$location = _window2.location) === null || _window2$location === void 0 ? void 0 : _window2$location.href) || (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) !== ConversationState.Active) {
|
|
364
368
|
return;
|
|
365
369
|
}
|
|
366
|
-
const conversationDetails = await getConversationDetailsCall(
|
|
370
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
367
371
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
|
|
368
372
|
dispatch({
|
|
369
373
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -397,9 +401,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
397
401
|
|
|
398
402
|
// Start chat from SDK Event
|
|
399
403
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
400
|
-
var _props$
|
|
404
|
+
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4, _inMemoryState$appSta5;
|
|
401
405
|
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
402
|
-
if ((props === null || props === void 0 ? void 0 : (_props$
|
|
406
|
+
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig6 = props.chatConfig) === null || _props$chatConfig6 === void 0 ? void 0 : (_props$chatConfig6$Li = _props$chatConfig6.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig6$Li === void 0 ? void 0 : _props$chatConfig6$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
403
407
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
404
408
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
405
409
|
payload: false
|
|
@@ -436,16 +440,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
436
440
|
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
437
441
|
|
|
438
442
|
// Only initiate new chat if widget runtime state is one of the followings
|
|
439
|
-
if (((_inMemoryState$
|
|
443
|
+
if (((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.Closed || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === ConversationState.InActive || ((_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.conversationState) === ConversationState.Postchat) {
|
|
440
444
|
BroadcastService.postMessage({
|
|
441
445
|
eventName: BroadcastEvent.ChatInitiated
|
|
442
446
|
});
|
|
443
|
-
prepareStartChat(props,
|
|
447
|
+
prepareStartChat(props, facadeChatSDK, inMemoryState, dispatch, setAdapter);
|
|
444
448
|
return;
|
|
445
449
|
}
|
|
446
450
|
|
|
447
451
|
// If minimized, maximize the chat
|
|
448
|
-
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
452
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.isMinimized) === true) {
|
|
449
453
|
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
450
454
|
dispatch({
|
|
451
455
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -492,7 +496,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
492
496
|
Event: TelemetryEvent.PrepareEndChat,
|
|
493
497
|
Description: PrepareEndChatDescriptionConstants.InitiateEndChatReceived
|
|
494
498
|
});
|
|
495
|
-
endChat(props,
|
|
499
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
496
500
|
}
|
|
497
501
|
BroadcastService.postMessage({
|
|
498
502
|
eventName: BroadcastEvent.CloseChat
|
|
@@ -505,7 +509,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
505
509
|
});
|
|
506
510
|
|
|
507
511
|
// Listen to end chat event from other tabs
|
|
508
|
-
const endChatEventName = getWidgetEndChatEventName(
|
|
512
|
+
const endChatEventName = getWidgetEndChatEventName((_facadeChatSDK$getCha3 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : (_facadeChatSDK$getCha4 = _facadeChatSDK$getCha3.omnichannelConfig) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : _facadeChatSDK$getCha4.orgId, (_facadeChatSDK$getCha5 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : (_facadeChatSDK$getCha6 = _facadeChatSDK$getCha5.omnichannelConfig) === null || _facadeChatSDK$getCha6 === void 0 ? void 0 : _facadeChatSDK$getCha6.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
509
513
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
510
514
|
var _msg$payload10;
|
|
511
515
|
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
@@ -513,9 +517,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
513
517
|
Event: TelemetryEvent.PrepareEndChat,
|
|
514
518
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
515
519
|
});
|
|
516
|
-
endChat(props,
|
|
520
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
517
521
|
endChatStateCleanUp(dispatch);
|
|
518
|
-
chatSDKStateCleanUp(
|
|
522
|
+
chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
|
|
519
523
|
return;
|
|
520
524
|
}
|
|
521
525
|
});
|
|
@@ -557,7 +561,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
557
561
|
useEffect(() => {
|
|
558
562
|
// On new message
|
|
559
563
|
if (state.appStates.conversationState === ConversationState.Active) {
|
|
560
|
-
|
|
564
|
+
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onNewMessage(() => {
|
|
561
565
|
// Track the message count
|
|
562
566
|
currentMessageCountRef.current++;
|
|
563
567
|
dispatch({
|
|
@@ -645,7 +649,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
645
649
|
Event: TelemetryEvent.PrepareEndChat,
|
|
646
650
|
Description: PrepareEndChatDescriptionConstants.CustomerCloseChatOnFailureOrPostChat
|
|
647
651
|
});
|
|
648
|
-
endChat(props,
|
|
652
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
|
|
649
653
|
return;
|
|
650
654
|
}
|
|
651
655
|
|
|
@@ -655,7 +659,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
655
659
|
Event: TelemetryEvent.PrepareEndChat,
|
|
656
660
|
Description: PrepareEndChatDescriptionConstants.CustomerCloseInactiveChat
|
|
657
661
|
});
|
|
658
|
-
endChat(props,
|
|
662
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
659
663
|
return;
|
|
660
664
|
}
|
|
661
665
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
@@ -666,7 +670,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
666
670
|
}
|
|
667
671
|
|
|
668
672
|
// All other cases
|
|
669
|
-
prepareEndChat(props,
|
|
673
|
+
prepareEndChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
670
674
|
}, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
|
|
671
675
|
|
|
672
676
|
// Publish chat widget state
|
|
@@ -699,13 +703,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
699
703
|
|
|
700
704
|
// Handle Chat disconnect cases
|
|
701
705
|
useEffect(() => {
|
|
702
|
-
var _inMemoryState$
|
|
706
|
+
var _inMemoryState$appSta6;
|
|
703
707
|
const inMemoryState = executeReducer(state, {
|
|
704
708
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
705
709
|
payload: null
|
|
706
710
|
});
|
|
707
711
|
handleChatDisconnect(props, inMemoryState, setWebChatStyles);
|
|
708
|
-
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
712
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta6 = inMemoryState.appStates) === null || _inMemoryState$appSta6 === void 0 ? void 0 : _inMemoryState$appSta6.chatDisconnectEventReceived;
|
|
709
713
|
if (chatDisconnectState && adapter) {
|
|
710
714
|
try {
|
|
711
715
|
adapter.end();
|
|
@@ -737,7 +741,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
737
741
|
Event: TelemetryEvent.PrepareEndChat,
|
|
738
742
|
Description: PrepareEndChatDescriptionConstants.BrowserUnload
|
|
739
743
|
});
|
|
740
|
-
endChat(props,
|
|
744
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
|
|
741
745
|
// Clean local storage
|
|
742
746
|
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventId);
|
|
743
747
|
|
|
@@ -750,16 +754,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
750
754
|
eventName: BroadcastEvent.ClosePopoutWindow
|
|
751
755
|
});
|
|
752
756
|
};
|
|
753
|
-
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(
|
|
757
|
+
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(facadeChatSDK, dispatch);
|
|
754
758
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
755
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props,
|
|
756
|
-
const prepareStartChatRelay = () => prepareStartChat(props,
|
|
759
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
|
|
760
|
+
const prepareStartChatRelay = () => prepareStartChat(props, facadeChatSDK, state, dispatch, setAdapter);
|
|
757
761
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
758
|
-
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(
|
|
762
|
+
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
|
|
759
763
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
760
764
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
761
|
-
const prepareEndChatRelay = () => prepareEndChat(props,
|
|
762
|
-
const webChatProps = initWebChatComposer(props, state, dispatch,
|
|
765
|
+
const prepareEndChatRelay = () => prepareEndChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
766
|
+
const webChatProps = initWebChatComposer(props, state, dispatch, facadeChatSDK, endChatRelay);
|
|
763
767
|
const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
|
|
764
768
|
...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
|
|
765
769
|
...((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatStyles)
|
|
@@ -785,7 +789,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
785
789
|
};
|
|
786
790
|
|
|
787
791
|
// Add 'omnichannel-chat-widget' OC User Agent if not already set
|
|
788
|
-
setOcUserAgent(
|
|
792
|
+
setOcUserAgent(facadeChatSDK.getChatSDK());
|
|
789
793
|
const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine;
|
|
790
794
|
const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
|
|
791
795
|
|
|
@@ -33,6 +33,9 @@ export const PostChatSurveyPaneStateful = props => {
|
|
|
33
33
|
} else {
|
|
34
34
|
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
35
35
|
}
|
|
36
|
+
if (props.copilotSurveyContext) {
|
|
37
|
+
surveyInviteLink = `${surveyInviteLink}&mcs_additionalcontext=${JSON.stringify(props.copilotSurveyContext)}`;
|
|
38
|
+
}
|
|
36
39
|
const styleProps = {
|
|
37
40
|
...props.styleProps,
|
|
38
41
|
generalStyleProps: generalStyleProps
|
|
@@ -2,9 +2,9 @@ import { HtmlAttributeNames, Regex } from "../../common/Constants";
|
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
4
|
import { extractPreChatSurveyResponseValues, findAllFocusableElement, getStateFromCache, getWidgetCacheId, isUndefinedOrEmpty, parseAdaptiveCardPayload } from "../../common/utils";
|
|
5
|
-
import MarkdownIt from "markdown-it";
|
|
6
5
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
7
6
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
7
|
+
import MarkdownIt from "markdown-it";
|
|
8
8
|
import { PreChatSurveyPane } from "@microsoft/omnichannel-chat-components";
|
|
9
9
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
10
10
|
import { defaultGeneralPreChatSurveyPaneStyleProps } from "./common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps";
|
|
@@ -6,11 +6,13 @@ import { ReconnectChatPane } from "@microsoft/omnichannel-chat-components";
|
|
|
6
6
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
7
7
|
import { setFocusOnElement } from "../../common/utils";
|
|
8
8
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
9
|
-
import
|
|
9
|
+
import useFacadeChatSDKStore from "../../hooks/useFacadeChatSDKStore";
|
|
10
10
|
export const ReconnectChatPaneStateful = props => {
|
|
11
11
|
const [state, dispatch] = useChatContextStore();
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
const chatSDK = useChatSDKStore();
|
|
13
|
+
//const chatSDK: any = useChatSDKStore();
|
|
14
|
+
const [facadeChatSDK] = useFacadeChatSDKStore();
|
|
15
|
+
const chatSDK = facadeChatSDK.getChatSDK();
|
|
14
16
|
const {
|
|
15
17
|
reconnectChatProps,
|
|
16
18
|
initStartChat
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
3
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
-
import { ParticipantType } from "../../../common/Constants";
|
|
5
4
|
import MockAdapter from "./mockadapter";
|
|
5
|
+
import { ParticipantType } from "../../../common/Constants";
|
|
6
6
|
export class MockChatSDK {
|
|
7
7
|
constructor() {
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -59,6 +59,9 @@ export class MockChatSDK {
|
|
|
59
59
|
getVoiceVideoCalling() {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
+
setAuthTokenProvider() {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
62
65
|
getLiveChatConfig() {
|
|
63
66
|
return {
|
|
64
67
|
LiveWSAndLiveChatEngJoin: {
|
|
@@ -12,7 +12,7 @@ import { defaultTypingIndicatorBubbleStyles } from "./defaultStyles/defaultTypin
|
|
|
12
12
|
import { defaultTypingIndicatorContainerStyles } from "./defaultStyles/defaultTypingIndicatorContainerStyles";
|
|
13
13
|
import { defaultTypingIndicatorMessageStyles } from "./defaultStyles/defaultTypingIndicatorMessageStyles";
|
|
14
14
|
import { useChatContextStore } from "../../../../..";
|
|
15
|
-
import
|
|
15
|
+
import useFacadeSDKStore from "../../../../../hooks/useFacadeChatSDKStore";
|
|
16
16
|
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
const TypingIndicator = _ref => {
|
|
@@ -21,10 +21,10 @@ const TypingIndicator = _ref => {
|
|
|
21
21
|
activeTyping,
|
|
22
22
|
visible
|
|
23
23
|
} = _ref;
|
|
24
|
-
|
|
25
|
-
const chatSDK = useChatSDKStore();
|
|
24
|
+
const [facadeChatSDK] = useFacadeSDKStore();
|
|
26
25
|
const [state] = useChatContextStore();
|
|
27
|
-
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const debounceTyping = useCallback(debounceLeading(() => facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.sendTypingEvent()), []);
|
|
28
28
|
if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
|
4
|
+
export const FacadeChatSDKStore = /*#__PURE__*/createContext([undefined, facadeChatSDK => {}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FacadeChatSDKStore } from "../contexts/FacadeChatSDKStore";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
const useFacadeChatSDKStore = () => {
|
|
4
|
+
const facadeChatSDK = useContext(FacadeChatSDKStore);
|
|
5
|
+
if (!facadeChatSDK) {
|
|
6
|
+
throw new Error("This hook is not called on component that is descendants of <FacadeSDKStore.Provider>, or FacadeSDKStore is not passed into LiveChatWidget component.");
|
|
7
|
+
}
|
|
8
|
+
return facadeChatSDK;
|
|
9
|
+
};
|
|
10
|
+
export default useFacadeChatSDKStore;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BroadcastService, decodeComponentString, encodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
2
|
-
import useChatContextStore from "./hooks/useChatContextStore";
|
|
3
|
-
import useChatSDKStore from "./hooks/useChatSDKStore";
|
|
4
2
|
import { getWidgetCacheId, getWidgetEndChatEventName } from "./common/utils";
|
|
5
3
|
import { ConversationState } from "./contexts/common/ConversationState";
|
|
4
|
+
import useChatContextStore from "./hooks/useChatContextStore";
|
|
5
|
+
import useChatSDKStore from "./hooks/useChatSDKStore";
|
|
6
|
+
import useFacadeChatSDKStore from "./hooks/useFacadeChatSDKStore";
|
|
6
7
|
export { default as LiveChatWidget } from "./components/livechatwidget/LiveChatWidget";
|
|
7
8
|
export { getMockChatSDKIfApplicable } from "./components/livechatwidget/common/getMockChatSDKIfApplicable";
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
9
|
+
export { getWidgetCacheId, getWidgetEndChatEventName, ConversationState };
|
|
10
|
+
export { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore, useFacadeChatSDKStore };
|
|
@@ -648,7 +648,7 @@ class TranscriptHTMLBuilder {
|
|
|
648
648
|
return htmlData;
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
const createChatTranscript = async function (transcript,
|
|
651
|
+
const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
652
652
|
let renderAttachments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
653
653
|
let transcriptOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
654
654
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -675,7 +675,7 @@ const createChatTranscript = async function (transcript, chatSDK) {
|
|
|
675
675
|
id: references[0],
|
|
676
676
|
type: metadata[0].contentType
|
|
677
677
|
};
|
|
678
|
-
const blob = await
|
|
678
|
+
const blob = await facadeChatSDK.downloadFileAttachment(fileMetadata);
|
|
679
679
|
const base64 = await convertBlobToBase64(blob);
|
|
680
680
|
message.contentUrl = base64;
|
|
681
681
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ChatAdapter, ChatSDKMessage, GetAgentAvailabilityResponse, GetLiveChatTranscriptResponse, GetVoiceVideoCallingResponse, IFileInfo, IRawMessage, MaskingRules, OmnichannelChatSDK, VoiceVideoCallingOptionalParams } from "@microsoft/omnichannel-chat-sdk";
|
|
2
|
+
import { IFacadeChatSDKInput } from "./types/IFacadeChatSDKInput";
|
|
3
|
+
import ChatAdapterOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/messaging/ChatAdapterOptionalParams";
|
|
4
|
+
import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
|
|
5
|
+
import ChatReconnectContext from "@microsoft/omnichannel-chat-sdk/lib/core/ChatReconnectContext";
|
|
6
|
+
import ChatReconnectOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/ChatReconnectOptionalParams";
|
|
7
|
+
import ChatTranscriptBody from "@microsoft/omnichannel-chat-sdk/lib/core/ChatTranscriptBody";
|
|
8
|
+
import EmailLiveChatTranscriptOptionaParams from "@microsoft/omnichannel-chat-sdk/lib/core/EmailLiveChatTranscriptOptionalParams";
|
|
9
|
+
import EndChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/EndChatOptionalParams";
|
|
10
|
+
import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
|
|
11
|
+
import GetAgentAvailabilityOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetAgentAvailabilityOptionalParams";
|
|
12
|
+
import GetChatTokenOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetChatTokenOptionalParams";
|
|
13
|
+
import GetConversationDetailsOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetConversationDetailsOptionalParams";
|
|
14
|
+
import GetLiveChatConfigOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetLiveChatConfigOptionalParams";
|
|
15
|
+
import GetLiveChatTranscriptOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetLiveChatTranscriptOptionalParams";
|
|
16
|
+
import IChatToken from "@microsoft/omnichannel-chat-sdk/lib/external/IC3Adapter/IChatToken";
|
|
17
|
+
import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
|
|
18
|
+
import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
|
|
19
|
+
import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
|
|
20
|
+
import InitializeOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/InitializeOptionalParams";
|
|
21
|
+
import LiveWorkItemDetails from "@microsoft/omnichannel-chat-sdk/lib/core/LiveWorkItemDetails";
|
|
22
|
+
import OmnichannelMessage from "@microsoft/omnichannel-chat-sdk/lib/core/messaging/OmnichannelMessage";
|
|
23
|
+
import OnNewMessageOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/messaging/OnNewMessageOptionalParams";
|
|
24
|
+
import { ParticipantsRemovedEvent } from "@azure/communication-signaling";
|
|
25
|
+
import PostChatContext from "@microsoft/omnichannel-chat-sdk/lib/core/PostChatContext";
|
|
26
|
+
import StartChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/StartChatOptionalParams";
|
|
27
|
+
export declare class FacadeChatSDK {
|
|
28
|
+
private chatSDK;
|
|
29
|
+
private chatConfig;
|
|
30
|
+
private token;
|
|
31
|
+
private expiration;
|
|
32
|
+
private isAuthenticated;
|
|
33
|
+
private getAuthToken?;
|
|
34
|
+
private sdkMocked;
|
|
35
|
+
isSDKMocked(): boolean;
|
|
36
|
+
getChatSDK(): OmnichannelChatSDK;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
isTokenSet(): boolean;
|
|
39
|
+
constructor(input: IFacadeChatSDKInput);
|
|
40
|
+
private convertExpiration;
|
|
41
|
+
private isTokenExpired;
|
|
42
|
+
private setToken;
|
|
43
|
+
private tokenRing;
|
|
44
|
+
private validateAndExecuteCall;
|
|
45
|
+
initialize(optionalParams?: InitializeOptionalParams): Promise<ChatConfig>;
|
|
46
|
+
getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
|
|
47
|
+
startChat(optionalParams?: StartChatOptionalParams): Promise<void>;
|
|
48
|
+
endChat(optionalParams?: EndChatOptionalParams): Promise<void>;
|
|
49
|
+
getCurrentLiveChatContext(): Promise<object>;
|
|
50
|
+
getConversationDetails(optionalParams?: GetConversationDetailsOptionalParams): Promise<LiveWorkItemDetails>;
|
|
51
|
+
getPreChatSurvey(parse?: boolean): Promise<any>;
|
|
52
|
+
getLiveChatConfig(optionalParams?: GetLiveChatConfigOptionalParams): Promise<ChatConfig>;
|
|
53
|
+
getChatToken(cached?: boolean, optionalParams?: GetChatTokenOptionalParams): Promise<IChatToken>;
|
|
54
|
+
getCallingToken(): Promise<string>;
|
|
55
|
+
getMessages(): Promise<IMessage[] | OmnichannelMessage[] | undefined>;
|
|
56
|
+
getDataMaskingRules(): Promise<MaskingRules>;
|
|
57
|
+
sendMessage(message: ChatSDKMessage): Promise<void>;
|
|
58
|
+
onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams | unknown): Promise<void>;
|
|
59
|
+
sendTypingEvent(): Promise<void>;
|
|
60
|
+
onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>;
|
|
61
|
+
onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread | ParticipantsRemovedEvent) => void): Promise<void>;
|
|
62
|
+
uploadFileAttachment(fileInfo: IFileInfo | File): Promise<IRawMessage | OmnichannelMessage>;
|
|
63
|
+
downloadFileAttachment(fileMetadata: FileMetadata | IFileMetadata): Promise<Blob>;
|
|
64
|
+
emailLiveChatTranscript(body: ChatTranscriptBody, optionalParams?: EmailLiveChatTranscriptOptionaParams): Promise<void>;
|
|
65
|
+
getLiveChatTranscript(optionalParams?: GetLiveChatTranscriptOptionalParams): Promise<GetLiveChatTranscriptResponse>;
|
|
66
|
+
createChatAdapter(optionalParams?: ChatAdapterOptionalParams): Promise<ChatAdapter>;
|
|
67
|
+
isVoiceVideoCallingEnabled(): Promise<boolean>;
|
|
68
|
+
getVoiceVideoCalling(params?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
|
|
69
|
+
getPostChatSurveyContext(): Promise<PostChatContext>;
|
|
70
|
+
getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<GetAgentAvailabilityResponse>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
|
|
2
|
+
import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
|
|
3
|
+
export interface IFacadeChatSDKInput {
|
|
4
|
+
chatSDK: OmnichannelChatSDK;
|
|
5
|
+
chatConfig: ChatConfig;
|
|
6
|
+
isAuthenticated: boolean;
|
|
7
|
+
isSDKMocked: boolean;
|
|
8
|
+
getAuthToken?: (authClientFunction?: string) => Promise<string | null>;
|
|
9
|
+
}
|
|
10
|
+
export interface PingResponse {
|
|
11
|
+
result: boolean;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
@@ -109,6 +109,7 @@ export declare enum TelemetryEvent {
|
|
|
109
109
|
CloseChatCall = "CloseChatCall",
|
|
110
110
|
CloseChatMethodException = "CloseChatMethodException",
|
|
111
111
|
PrechatSurveyLoaded = "PrechatSurveyLoaded",
|
|
112
|
+
PrechatSurveyExpected = "PrechatSurveyExpected",
|
|
112
113
|
PrechatSubmitted = "PrechatSubmitted",
|
|
113
114
|
StartChatSDKCall = "StartChatCall",
|
|
114
115
|
StartChatEventRecevied = "StartChatEventReceived",
|
|
@@ -175,6 +176,7 @@ export declare enum TelemetryEvent {
|
|
|
175
176
|
SendTypingIndicatorSucceeded = "SendTypingIndicatorSucceeded",
|
|
176
177
|
SendTypingIndicatorFailed = "SendTypingIndicatorFailed",
|
|
177
178
|
WebChatEvent = "WebChatEvent",
|
|
179
|
+
FacadeChatSDKEvent = "FacadeChatSDKEvent",
|
|
178
180
|
PreChatSurveyStartChatMethodFailed = "PreChatSurveyStartChatMethodFailed",
|
|
179
181
|
ChatAlreadyTriggered = "ChatAlreadyTriggered",
|
|
180
182
|
StartProactiveChatEventReceived = "StartProactiveChatEventReceived",
|
|
@@ -204,7 +206,11 @@ export declare enum TelemetryEvent {
|
|
|
204
206
|
PostChatSurveyLoaded = "PostChatSurveyLoaded",
|
|
205
207
|
ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived",
|
|
206
208
|
HiddenAdaptiveCardMessageReceived = "HiddenAdaptiveCardMessageReceived",
|
|
207
|
-
EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError"
|
|
209
|
+
EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError",
|
|
210
|
+
NewTokenSuccess = "NewTokenSuccess",
|
|
211
|
+
NewTokenFailed = "NewTokenFailed",
|
|
212
|
+
NewTokenExpired = "NewTokenExpired",
|
|
213
|
+
TokenEmptyOrSame = "TokenEmptyOrSame"
|
|
208
214
|
}
|
|
209
215
|
export interface TelemetryInput {
|
|
210
216
|
scenarioType: ScenarioType;
|
|
@@ -37,4 +37,5 @@ export declare class TelemetryHelper {
|
|
|
37
37
|
static logSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
38
38
|
static logConfigDataEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
39
39
|
static logWebChatEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
40
|
+
static logFacadeChatSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
40
41
|
}
|
|
@@ -34,6 +34,7 @@ export interface OCChatSDKTelemetryData extends BaseTelemetryData {
|
|
|
34
34
|
ElapsedTimeInMilliseconds?: number;
|
|
35
35
|
TransactionId: string;
|
|
36
36
|
ExceptionDetails?: object;
|
|
37
|
+
Description?: string;
|
|
37
38
|
}
|
|
38
39
|
export interface IC3ClientTelemetryData extends BaseTelemetryData {
|
|
39
40
|
SubscriptionId?: string;
|
|
@@ -82,4 +83,10 @@ export interface CallingTelemetryData extends BaseTelemetryData {
|
|
|
82
83
|
ExceptionDetails?: object;
|
|
83
84
|
Description?: string;
|
|
84
85
|
}
|
|
86
|
+
export interface FacadeChatSDKTelemetryData extends BaseTelemetryData {
|
|
87
|
+
Event?: string;
|
|
88
|
+
ElapsedTimeInMilliseconds?: number;
|
|
89
|
+
ExceptionDetails?: object;
|
|
90
|
+
Description?: string;
|
|
91
|
+
}
|
|
85
92
|
export declare type TelemetryData = ConfigValidationTelemetryData | OCChatSDKTelemetryData | IC3ClientTelemetryData | LoadTelemetryData | ActionTelemetryData | WebChatTelemetryData | CallingTelemetryData | MessageProcessingErrorData;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FacadeChatSDK } from "./facades/FacadeChatSDK";
|
|
1
2
|
import { ITimer } from "./interfaces/ITimer";
|
|
2
3
|
export declare const setTabIndices: (elements: HTMLElement[] | null, tabIndexMap: Map<string, number>, shouldBeFocusable: boolean) => void;
|
|
3
4
|
export declare const findParentFocusableElementsWithoutChildContainer: (elementId: string) => HTMLElement[] | null;
|
|
@@ -31,7 +32,7 @@ export declare const getBroadcastChannelName: (widgetId: string, widgetInstanceI
|
|
|
31
32
|
export declare const getWidgetCacheIdfromProps: (props: any, popoutChat?: boolean) => string;
|
|
32
33
|
export declare const debounceLeading: (fn: any, ms?: number) => (...args: any[]) => void;
|
|
33
34
|
export declare const isThisSessionPopout: (href: string) => boolean;
|
|
34
|
-
export declare const getConversationDetailsCall: (
|
|
35
|
+
export declare const getConversationDetailsCall: (facadeChatSDK: FacadeChatSDK, liveChatContext?: any) => Promise<any>;
|
|
35
36
|
export declare const checkContactIdError: (e: any) => void;
|
|
36
37
|
export declare const createFileAndDownload: (fileName: string, blobData: string, mimeType: string) => void;
|
|
37
38
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
2
|
import { IDownloadTranscriptProps } from "./interfaces/IDownloadTranscriptProps";
|
|
3
|
-
|
|
3
|
+
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
4
|
+
export declare const downloadTranscript: (facadeChatSDK: FacadeChatSDK, downloadTranscriptProps: IDownloadTranscriptProps, state?: ILiveChatWidgetContext | undefined) => Promise<void>;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
|
|
2
|
+
import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
|
|
2
3
|
declare const getAuthClientFunction: (chatConfig: ChatConfig | undefined) => string | undefined;
|
|
3
|
-
declare const handleAuthentication: (chatSDK:
|
|
4
|
+
declare const handleAuthentication: (chatSDK: OmnichannelChatSDK, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string | undefined) => Promise<string | null>) | undefined) => Promise<{
|
|
5
|
+
result: boolean;
|
|
6
|
+
token: string | null;
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
result: boolean;
|
|
10
|
+
token: null;
|
|
11
|
+
error: {
|
|
12
|
+
message: string;
|
|
13
|
+
getAuthTokenPresent: boolean;
|
|
14
|
+
authClientFunctionPresent: boolean;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
4
17
|
declare const removeAuthTokenProvider: (chatSDK: any) => void;
|
|
5
18
|
export { getAuthClientFunction, handleAuthentication, removeAuthTokenProvider };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
1
2
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
2
|
-
export declare const createAdapter: (
|
|
3
|
+
export declare const createAdapter: (facadeChatSDK: FacadeChatSDK, props?: ILiveChatWidgetProps | undefined) => Promise<any>;
|