@microsoft/omnichannel-chat-widget 1.7.4-main.c3fef22 → 1.7.4-main.e66bbe9

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.
Files changed (85) hide show
  1. package/lib/cjs/common/facades/FacadeChatSDK.js +298 -0
  2. package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -0
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +10 -0
  5. package/lib/cjs/common/utils.js +2 -2
  6. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  7. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  8. package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
  9. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  10. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
  11. package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
  12. package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
  13. package/lib/cjs/components/livechatwidget/common/endChat.js +21 -22
  14. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
  15. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +2 -2
  16. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
  17. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  18. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  19. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  20. package/lib/cjs/components/livechatwidget/common/startChat.js +41 -35
  21. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  22. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  23. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
  24. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  25. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  26. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  27. package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
  28. package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
  29. package/lib/cjs/index.js +9 -2
  30. package/lib/cjs/plugins/createChatTranscript.js +2 -2
  31. package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
  32. package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
  33. package/lib/esm/common/telemetry/TelemetryConstants.js +5 -0
  34. package/lib/esm/common/telemetry/TelemetryHelper.js +10 -0
  35. package/lib/esm/common/utils.js +2 -2
  36. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  37. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  38. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  39. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  40. package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
  41. package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
  42. package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
  43. package/lib/esm/components/livechatwidget/common/endChat.js +21 -22
  44. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
  45. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +2 -2
  46. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
  47. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  48. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  49. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  50. package/lib/esm/components/livechatwidget/common/startChat.js +41 -35
  51. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  52. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  53. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
  54. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  55. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  56. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  57. package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
  58. package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
  59. package/lib/esm/index.js +5 -4
  60. package/lib/esm/plugins/createChatTranscript.js +2 -2
  61. package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
  62. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
  63. package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -1
  64. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  65. package/lib/types/common/telemetry/definitions/Payload.d.ts +6 -0
  66. package/lib/types/common/utils.d.ts +2 -1
  67. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
  68. package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
  69. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  70. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  71. package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
  72. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
  73. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
  74. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
  75. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
  76. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
  77. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
  78. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
  79. package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
  80. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
  81. package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
  82. package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
  83. package/lib/types/index.d.ts +4 -3
  84. package/lib/types/plugins/createChatTranscript.d.ts +2 -1
  85. package/package.json +1 -1
@@ -11,7 +11,7 @@ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
11
11
  import { getWidgetCacheIdfromProps } from "../../../common/utils";
12
12
 
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
14
+ export const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuccessful) => {
15
15
  var _props$controlProps;
16
16
  if (!ex) {
17
17
  logWidgetLoadFailed();
@@ -59,7 +59,7 @@ export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSu
59
59
  break;
60
60
  case ChatSDKErrorName.InvalidConversation:
61
61
  case ChatSDKErrorName.ClosedConversation:
62
- handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
62
+ handleInvalidOrClosedConversation(dispatch, facadeChatSDK, props, ex);
63
63
  return;
64
64
  default:
65
65
  logWidgetLoadFailed(ex);
@@ -94,7 +94,7 @@ export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSu
94
94
  // If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
95
95
  // we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
96
96
  if (isStartChatSuccessful === true) {
97
- forceEndChat(chatSDK);
97
+ forceEndChat(facadeChatSDK);
98
98
  }
99
99
  };
100
100
  const logWidgetLoadFailed = ex => {
@@ -142,7 +142,7 @@ const logWidgetLoadCompleteWithError = ex => {
142
142
  };
143
143
 
144
144
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
- const forceEndChat = chatSDK => {
145
+ const forceEndChat = facadeChatSDK => {
146
146
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
147
147
  Event: TelemetryEvent.PrepareEndChat,
148
148
  Description: PrepareEndChatDescriptionConstants.WidgetLoadFailedAfterSessionInit
@@ -150,7 +150,7 @@ const forceEndChat = chatSDK => {
150
150
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
151
151
  Event: TelemetryEvent.EndChatSDKCall
152
152
  });
153
- chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
153
+ facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatSDK().endChat();
154
154
  };
155
155
  const handleWidgetUseOutsideOperatingHour = dispatch => {
156
156
  dispatch({
@@ -203,7 +203,7 @@ const handleUninitializedChatSDK = ex => {
203
203
  };
204
204
 
205
205
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
- const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
206
+ const handleInvalidOrClosedConversation = (dispatch, facadeChatSDK, props, ex) => {
207
207
  var _DataStoreManager$cli;
208
208
  logWidgetLoadCompleteWithError(ex);
209
209
 
@@ -211,7 +211,7 @@ const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
211
211
  callingStateCleanUp(dispatch);
212
212
  endChatStateCleanUp(dispatch);
213
213
  closeChatStateCleanUp(dispatch);
214
- chatSDKStateCleanUp(chatSDK);
214
+ chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
215
215
  (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(getWidgetCacheIdfromProps(props));
216
216
 
217
217
  // Starts new chat
@@ -6,16 +6,16 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
6
6
  import { getConversationDetailsCall } from "../../../common/utils";
7
7
 
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- export const updateTelemetryData = async (chatSDK, dispatch) => {
9
+ export const updateTelemetryData = async (facadeChatSDK, dispatch) => {
10
10
  // load it concurrently, this will reduce the load time
11
- await Promise.all([updateSessionDataForTelemetry(chatSDK, dispatch), updateConversationDataForTelemetry(chatSDK, dispatch)]);
11
+ await Promise.all([updateSessionDataForTelemetry(facadeChatSDK, dispatch), updateConversationDataForTelemetry(facadeChatSDK, dispatch)]);
12
12
  };
13
13
 
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
16
- if (chatSDK) {
15
+ const updateSessionDataForTelemetry = async (facadeChatSDK, dispatch) => {
16
+ if (facadeChatSDK && facadeChatSDK.getChatSDK()) {
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- const chatSession = await chatSDK.getCurrentLiveChatContext();
18
+ const chatSession = await facadeChatSDK.getCurrentLiveChatContext();
19
19
  const telemetryData = TelemetryHelper.addSessionDataToTelemetry(chatSession, TelemetryManager.InternalTelemetryData);
20
20
  dispatch({
21
21
  type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
@@ -31,10 +31,10 @@ const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
31
31
  };
32
32
 
33
33
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- const updateConversationDataForTelemetry = async (chatSDK, dispatch) => {
35
- if (chatSDK) {
34
+ const updateConversationDataForTelemetry = async (facadeChatSDK, dispatch) => {
35
+ if (facadeChatSDK && facadeChatSDK.getChatSDK()) {
36
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- const liveWorkItem = await getConversationDetailsCall(chatSDK);
37
+ const liveWorkItem = await getConversationDetailsCall(facadeChatSDK);
38
38
  const telemetryData = TelemetryHelper.addConversationDataToTelemetry(liveWorkItem, TelemetryManager.InternalTelemetryData);
39
39
  dispatch({
40
40
  type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
@@ -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 useChatSDKStore from "../../../hooks/useChatSDKStore";
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 chatSDK = useChatSDKStore();
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 _chatSDK$omnichannelC, _props$controlProps2;
86
- const broadcastServiceChannelName = getBroadcastChannelName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.widgetId, ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
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(chatSDK, props, dispatch, setAdapter, initStartChat, state);
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(chatSDK, dispatch, state);
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(chatSDK, dispatch, setAdapter, state, props, optionalParams);
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(chatSDK, dispatch, setAdapter, undefined, undefined, inMemoryState, props);
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(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
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 _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps11;
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(chatSDK);
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
- if (isThisSessionPopout((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$location = _window2.location) === null || _window2$location === void 0 ? void 0 : _window2$location.href)) {
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(chatSDK);
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$chatConfig4, _props$chatConfig4$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
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$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") {
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$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === ConversationState.Postchat) {
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, chatSDK, inMemoryState, dispatch, setAdapter);
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$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
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(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
520
+ endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
517
521
  endChatStateCleanUp(dispatch);
518
- chatSDKStateCleanUp(chatSDK);
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
- chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
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$appSta5;
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$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
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(chatSDK, dispatch);
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
756
- const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
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(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
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, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
762
- const webChatProps = initWebChatComposer(props, state, dispatch, chatSDK, endChatRelay);
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(chatSDK);
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
 
@@ -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 useChatSDKStore from "../../hooks/useChatSDKStore";
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 useChatSDKStore from "../../../../../hooks/useChatSDKStore";
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- const chatSDK = useChatSDKStore();
24
+ const [facadeChatSDK] = useFacadeSDKStore();
26
25
  const [state] = useChatContextStore();
27
- const debounceTyping = useCallback(debounceLeading(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
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 { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore };
9
- export { getWidgetCacheId, getWidgetEndChatEventName, ConversationState };
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, chatSDK) {
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 chatSDK.downloadFileAttachment(fileMetadata);
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
+ }
@@ -175,6 +175,7 @@ export declare enum TelemetryEvent {
175
175
  SendTypingIndicatorSucceeded = "SendTypingIndicatorSucceeded",
176
176
  SendTypingIndicatorFailed = "SendTypingIndicatorFailed",
177
177
  WebChatEvent = "WebChatEvent",
178
+ FacadeChatSDKEvent = "FacadeChatSDKEvent",
178
179
  PreChatSurveyStartChatMethodFailed = "PreChatSurveyStartChatMethodFailed",
179
180
  ChatAlreadyTriggered = "ChatAlreadyTriggered",
180
181
  StartProactiveChatEventReceived = "StartProactiveChatEventReceived",
@@ -204,7 +205,11 @@ export declare enum TelemetryEvent {
204
205
  PostChatSurveyLoaded = "PostChatSurveyLoaded",
205
206
  ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived",
206
207
  HiddenAdaptiveCardMessageReceived = "HiddenAdaptiveCardMessageReceived",
207
- EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError"
208
+ EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError",
209
+ NewTokenSuccess = "NewTokenSuccess",
210
+ NewTokenFailed = "NewTokenFailed",
211
+ NewTokenExpired = "NewTokenExpired",
212
+ TokenEmptyOrSame = "TokenEmptyOrSame"
208
213
  }
209
214
  export interface TelemetryInput {
210
215
  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
  }
@@ -83,4 +83,10 @@ export interface CallingTelemetryData extends BaseTelemetryData {
83
83
  ExceptionDetails?: object;
84
84
  Description?: string;
85
85
  }
86
+ export interface FacadeChatSDKTelemetryData extends BaseTelemetryData {
87
+ Event?: string;
88
+ ElapsedTimeInMilliseconds?: number;
89
+ ExceptionDetails?: object;
90
+ Description?: string;
91
+ }
86
92
  export declare type TelemetryData = ConfigValidationTelemetryData | OCChatSDKTelemetryData | IC3ClientTelemetryData | LoadTelemetryData | ActionTelemetryData | WebChatTelemetryData | CallingTelemetryData | MessageProcessingErrorData;