@microsoft/omnichannel-chat-widget 0.1.0-main.50fdaaa → 0.1.0-main.52fa2fc
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/Constants.js +8 -1
- package/lib/cjs/common/telemetry/TelemetryConstants.js +22 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +38 -64
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +10 -61
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +6 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +14 -6
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +65 -25
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
- package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +6 -2
- package/lib/cjs/contexts/createReducer.js +36 -2
- package/lib/esm/common/Constants.js +6 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +22 -4
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +40 -66
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +12 -63
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +6 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +14 -6
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +65 -25
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
- package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +6 -2
- package/lib/esm/contexts/createReducer.js +36 -2
- package/lib/types/common/Constants.d.ts +7 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +18 -6
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
- package/package.json +1 -1
|
@@ -46,8 +46,11 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
46
46
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
47
47
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
48
48
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
49
|
+
import { ConversationEndEntity } from "../../../contexts/common/ConversationEndEntity";
|
|
50
|
+
import { handleAgentEndConversation } from "../common/agentEndConversationHelper";
|
|
51
|
+
import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
49
52
|
export const LiveChatWidgetStateful = props => {
|
|
50
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
53
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps15, _props$controlProps16, _props$componentOverr, _props$controlProps17, _props$componentOverr2, _props$controlProps18, _props$componentOverr3, _props$controlProps19, _props$componentOverr4, _props$controlProps20, _props$componentOverr5, _props$controlProps21, _props$componentOverr6, _props$controlProps22, _props$componentOverr7, _props$controlProps23, _props$controlProps24, _props$componentOverr8, _props$controlProps25, _props$componentOverr9, _props$controlProps26, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
51
54
|
const [state, dispatch] = useChatContextStore();
|
|
52
55
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
56
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -105,7 +108,6 @@ export const LiveChatWidgetStateful = props => {
|
|
|
105
108
|
|
|
106
109
|
//Start a chat from cache/reconnectid
|
|
107
110
|
if (activeCachedChatExist === true) {
|
|
108
|
-
var _state$domainStates3, _state$domainStates3$;
|
|
109
111
|
dispatch({
|
|
110
112
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
111
113
|
payload: ConversationState.Loading
|
|
@@ -115,8 +117,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
//Check if conversation state is not in wrapup or closed state
|
|
118
|
-
isChatValid = await checkIfConversationStillValid(chatSDK,
|
|
120
|
+
isChatValid = await checkIfConversationStillValid(chatSDK, dispatch, state);
|
|
119
121
|
if (isChatValid === true) {
|
|
122
|
+
//Check if reconnect enabled
|
|
123
|
+
if (isReconnectEnabled(props.chatConfig) === true) {
|
|
124
|
+
await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
125
|
+
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
126
|
+
if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
120
130
|
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
121
131
|
return;
|
|
122
132
|
}
|
|
@@ -206,7 +216,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
206
216
|
|
|
207
217
|
// useEffect for custom context
|
|
208
218
|
useEffect(() => {
|
|
209
|
-
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$
|
|
219
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps13;
|
|
210
220
|
// Add the custom context on receiving the SetCustomContext event
|
|
211
221
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
212
222
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -234,14 +244,33 @@ export const LiveChatWidgetStateful = props => {
|
|
|
234
244
|
}
|
|
235
245
|
});
|
|
236
246
|
|
|
247
|
+
// Toggle chat visibility
|
|
248
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(event => {
|
|
249
|
+
var _event$payload;
|
|
250
|
+
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
251
|
+
var _event$payload2, _props$controlProps10;
|
|
252
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
253
|
+
Event: TelemetryEvent.ChatVisibilityChanged,
|
|
254
|
+
Description: "Chat visibility changed to " + (event === null || event === void 0 ? void 0 : (_event$payload2 = event.payload) === null || _event$payload2 === void 0 ? void 0 : _event$payload2.isChatHidden)
|
|
255
|
+
});
|
|
256
|
+
if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
|
|
257
|
+
var _event$payload3;
|
|
258
|
+
dispatch({
|
|
259
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
260
|
+
payload: event === null || event === void 0 ? void 0 : (_event$payload3 = event.payload) === null || _event$payload3 === void 0 ? void 0 : _event$payload3.isChatHidden
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
237
266
|
// Start chat from SDK Event
|
|
238
267
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
239
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$
|
|
268
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
|
|
240
269
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
241
270
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
242
271
|
Description: "Start chat event received."
|
|
243
272
|
});
|
|
244
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
273
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
245
274
|
|
|
246
275
|
// Chat not found in cache
|
|
247
276
|
if (persistedState === undefined) {
|
|
@@ -282,9 +311,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
282
311
|
// End chat
|
|
283
312
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
284
313
|
if (state.appStates.hideStartChatButton === false) {
|
|
285
|
-
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$
|
|
314
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps12;
|
|
286
315
|
// This is to ensure to get latest state from cache in multitab
|
|
287
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
316
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
288
317
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
289
318
|
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
290
319
|
} else {
|
|
@@ -304,14 +333,14 @@ export const LiveChatWidgetStateful = props => {
|
|
|
304
333
|
});
|
|
305
334
|
|
|
306
335
|
// Listen to end chat event from other tabs
|
|
307
|
-
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$
|
|
336
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
308
337
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
309
338
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
310
339
|
return;
|
|
311
340
|
});
|
|
312
341
|
|
|
313
342
|
// When conversation ended by agent
|
|
314
|
-
if (state.appStates.
|
|
343
|
+
if (state.appStates.conversationEndedBy === ConversationEndEntity.Agent) {
|
|
315
344
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
316
345
|
}
|
|
317
346
|
|
|
@@ -409,7 +438,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
409
438
|
|
|
410
439
|
// Publish chat widget state
|
|
411
440
|
useEffect(() => {
|
|
412
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$
|
|
441
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
|
|
413
442
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
414
443
|
// Ghost chat scenarios
|
|
415
444
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -427,7 +456,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
427
456
|
};
|
|
428
457
|
}*/
|
|
429
458
|
|
|
430
|
-
widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
459
|
+
widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps14 = props.controlProps) === null || _props$controlProps14 === void 0 ? void 0 : _props$controlProps14.widgetInstanceId) ?? "");
|
|
431
460
|
const chatWidgetStateChangeEvent = {
|
|
432
461
|
eventName: widgetStateEventName,
|
|
433
462
|
payload: {
|
|
@@ -436,6 +465,20 @@ export const LiveChatWidgetStateful = props => {
|
|
|
436
465
|
};
|
|
437
466
|
BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
438
467
|
}, [state]);
|
|
468
|
+
|
|
469
|
+
// Initiate End chat from a single point
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
if (state.appStates.conversationEndedBy !== undefined) {
|
|
472
|
+
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
473
|
+
}
|
|
474
|
+
}, [state.appStates.conversationEndedBy]);
|
|
475
|
+
|
|
476
|
+
// Handle Agent end conversation cases
|
|
477
|
+
useEffect(() => {
|
|
478
|
+
if (state.appStates.conversationEndedByAgentEventReceived) {
|
|
479
|
+
handleAgentEndConversation(props, state, dispatch);
|
|
480
|
+
}
|
|
481
|
+
}, [state.appStates.conversationEndedByAgentEventReceived]);
|
|
439
482
|
const initiateEndChatOnBrowserUnload = () => {
|
|
440
483
|
var _DataStoreManager$cli;
|
|
441
484
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -455,12 +498,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
455
498
|
eventName: BroadcastEvent.ClosePopoutWindow
|
|
456
499
|
});
|
|
457
500
|
};
|
|
458
|
-
const webChatProps = initWebChatComposer(props, chatSDK, state, dispatch, setWebChatStyles);
|
|
501
|
+
const webChatProps = initWebChatComposer(props, chatSDK, setAdapter, state, dispatch, adapter, setWebChatStyles);
|
|
459
502
|
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
460
503
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
461
504
|
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
|
|
462
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
463
|
-
const prepareEndChatRelay = (adapter, state) => prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
464
505
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
465
506
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
466
507
|
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
@@ -489,28 +530,27 @@ export const LiveChatWidgetStateful = props => {
|
|
|
489
530
|
id: widgetElementId,
|
|
490
531
|
styles: generalStyles,
|
|
491
532
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
492
|
-
}, !((_props$
|
|
533
|
+
}, !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideChatButton) && !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideStartChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
493
534
|
buttonProps: props.chatButtonProps,
|
|
494
535
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
495
536
|
startChat: prepareStartChatRelay
|
|
496
|
-
})), !((_props$
|
|
537
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
497
538
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
498
539
|
startChat: prepareStartChatRelay
|
|
499
|
-
})), !((_props$
|
|
540
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
500
541
|
headerProps: props.headerProps,
|
|
501
542
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
502
543
|
endChat: endChatRelay
|
|
503
|
-
})), !((_props$
|
|
544
|
+
})), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
504
545
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
505
546
|
initStartChat: initStartChatRelay
|
|
506
|
-
})), !((_props$
|
|
547
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
507
548
|
surveyProps: props.preChatSurveyPaneProps,
|
|
508
549
|
initStartChat: initStartChatRelay
|
|
509
|
-
})), !((_props$
|
|
550
|
+
})), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
510
551
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
511
|
-
}, props.callingContainerProps)), !((_props$
|
|
512
|
-
setPostChatContext: setPostChatContextRelay
|
|
513
|
-
|
|
514
|
-
}))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane)))));
|
|
552
|
+
}, props.callingContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
553
|
+
setPostChatContext: setPostChatContextRelay
|
|
554
|
+
}))), !((_props$controlProps26 = props.controlProps) !== null && _props$controlProps26 !== void 0 && _props$controlProps26.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane)))));
|
|
515
555
|
};
|
|
516
556
|
export default LiveChatWidgetStateful;
|
|
@@ -15,7 +15,9 @@ export const PostChatSurveyPaneStateful = props => {
|
|
|
15
15
|
display: state.appStates.isMinimized ? "none" : ""
|
|
16
16
|
});
|
|
17
17
|
let surveyInviteLink = "";
|
|
18
|
-
if (state.domainStates.postChatContext.
|
|
18
|
+
if (state.appStates.shouldUseBotSurvey && state.domainStates.postChatContext.botSurveyInviteLink) {
|
|
19
|
+
surveyInviteLink = state.domainStates.postChatContext.botSurveyInviteLink + "&embed=" + (postChatSurveyMode === PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
|
|
20
|
+
} else {
|
|
19
21
|
surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink + "&embed=" + (postChatSurveyMode === PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
|
|
20
22
|
}
|
|
21
23
|
const styleProps = {
|
|
@@ -26,10 +26,12 @@ export const ReconnectChatPaneStateful = props => {
|
|
|
26
26
|
};
|
|
27
27
|
await initStartChat(optionalParams);
|
|
28
28
|
} else {
|
|
29
|
+
var _state$domainStates;
|
|
29
30
|
dispatch({
|
|
30
31
|
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
31
32
|
payload: undefined
|
|
32
33
|
});
|
|
34
|
+
chatSDK.requestId = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.initialChatSdkRequestId;
|
|
33
35
|
const parseToJson = false;
|
|
34
36
|
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
35
37
|
if (preChatSurveyResponse) {
|
|
@@ -13,6 +13,8 @@ import { defaultTypingIndicatorMessageStyles } from "./defaultStyles/defaultTypi
|
|
|
13
13
|
import { useChatContextStore } from "../../../../..";
|
|
14
14
|
import { debounceLeading } from "../../../../../common/utils";
|
|
15
15
|
import useChatSDKStore from "../../../../../hooks/useChatSDKStore";
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
18
|
const TypingIndicator = _ref => {
|
|
17
19
|
var _state$domainStates$l, _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3;
|
|
18
20
|
let {
|
|
@@ -4,26 +4,30 @@
|
|
|
4
4
|
* Checks if the attachment being uploaded satisfies Omnichannel's requirement on file extensions and file size.
|
|
5
5
|
******/
|
|
6
6
|
|
|
7
|
+
import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
|
|
7
8
|
import { NotificationHandler } from "../../notification/NotificationHandler";
|
|
8
9
|
import { NotificationScenarios } from "../../enums/NotificationScenarios";
|
|
9
10
|
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
11
|
+
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
12
|
+
import { AMSConstants } from "../../../../../common/Constants";
|
|
10
13
|
const MBtoBRatio = 1000000;
|
|
11
14
|
|
|
12
15
|
/*
|
|
13
16
|
* If an attachment is invalid, delete this attachment from the attachments list
|
|
14
17
|
* If the result attachment list is empty, return a dummy action
|
|
15
18
|
*/
|
|
16
|
-
const validateAttachment = (action, allowedFileExtensions,
|
|
19
|
+
const validateAttachment = (action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
17
20
|
var _action$payload, _action$payload$activ, _action$payload2, _action$payload2$acti, _action$payload2$acti2, _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
18
21
|
const attachments = action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.attachments;
|
|
19
22
|
const attachmentSizes = action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : (_action$payload2$acti2 = _action$payload2$acti.channelData) === null || _action$payload2$acti2 === void 0 ? void 0 : _action$payload2$acti2.attachmentSizes;
|
|
20
23
|
if (attachments) {
|
|
21
24
|
for (let i = 0; i < attachments.length; i++) {
|
|
25
|
+
const maxUploadFileSize = getMaxUploadFileSize(maxFileSizeSupportedByDynamics, attachments[i].contentType);
|
|
22
26
|
const fileExtensionValid = validateFileExtension(attachments[i], allowedFileExtensions);
|
|
23
27
|
const fileSizeValid = validateFileSize(attachmentSizes[i], maxUploadFileSize);
|
|
24
28
|
const fileIsEmpty = parseInt(attachmentSizes[i]) == 0;
|
|
25
29
|
if (!fileExtensionValid || !fileSizeValid || fileIsEmpty) {
|
|
26
|
-
NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize, localizedTexts));
|
|
30
|
+
NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize.toString(), maxFileSizeSupportedByDynamics, localizedTexts));
|
|
27
31
|
attachments.splice(i, 1);
|
|
28
32
|
attachmentSizes.splice(i, 1);
|
|
29
33
|
i--;
|
|
@@ -55,58 +59,118 @@ const validateFileExtension = (attachment, allowedFileExtensions) => {
|
|
|
55
59
|
return allExtensions.indexOf(fileExtension) > -1;
|
|
56
60
|
};
|
|
57
61
|
const validateFileSize = (attachmentSize, maxUploadFileSize) => {
|
|
58
|
-
return
|
|
62
|
+
return maxUploadFileSize * MBtoBRatio > parseInt(attachmentSize);
|
|
59
63
|
};
|
|
60
|
-
const
|
|
64
|
+
const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) => {
|
|
65
|
+
const maxFileSizeSupportedByDynamics = maxFileSizeSupportedByDynamicsStr && parseInt(maxFileSizeSupportedByDynamicsStr) ? parseInt(maxFileSizeSupportedByDynamicsStr) : AMSConstants.maxSupportedFileSize;
|
|
66
|
+
const amsAttachmentSizeLimit = isImage(contentType) ? AMSConstants.maxSupportedImageSize : AMSConstants.maxSupportedFileSize;
|
|
67
|
+
// Takes the smallest max file size configure betteween AMS and Dynamics Config
|
|
68
|
+
return maxFileSizeSupportedByDynamics < amsAttachmentSizeLimit ? maxFileSizeSupportedByDynamics : amsAttachmentSizeLimit;
|
|
69
|
+
};
|
|
70
|
+
const isImage = contentType => {
|
|
71
|
+
return AMSConstants.supportedImagesMimeTypes.includes(contentType);
|
|
72
|
+
};
|
|
73
|
+
const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
61
74
|
let errorMessage = "";
|
|
62
75
|
if (!fileName || !maxUploadFileSize) {
|
|
76
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
77
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
78
|
+
Description: "Attachment validation failed",
|
|
79
|
+
ExceptionDetails: {
|
|
80
|
+
ErrorDetails: "File provided is null"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
63
83
|
return localizedTexts.MIDDLEWARE_BANNER_FILE_NULL_ERROR ?? "";
|
|
64
84
|
}
|
|
65
85
|
if (!supportedFileExtension && !supportedFileSize) {
|
|
66
|
-
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, localizedTexts);
|
|
86
|
+
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
67
87
|
} else if (!supportedFileSize) {
|
|
68
|
-
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, localizedTexts);
|
|
88
|
+
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
69
89
|
} else if (!supportedFileExtension) {
|
|
70
90
|
errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
|
|
71
91
|
} else if (fileIsEmpty) {
|
|
92
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
93
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
94
|
+
Description: "Attachment validation failed",
|
|
95
|
+
ExceptionDetails: {
|
|
96
|
+
ErrorDetails: "File provided is empty"
|
|
97
|
+
}
|
|
98
|
+
});
|
|
72
99
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
|
|
73
100
|
} else {
|
|
101
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
102
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
103
|
+
Description: "Attachment validation failed",
|
|
104
|
+
ExceptionDetails: {
|
|
105
|
+
ErrorDetails: `Unexpected error: supportedFileExtension=${supportedFileExtension} supportedFileSize=${supportedFileSize} fileIsEmpty=${!fileIsEmpty}`
|
|
106
|
+
}
|
|
107
|
+
});
|
|
74
108
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_ERROR_MESSAGE ?? "";
|
|
75
109
|
}
|
|
76
110
|
return errorMessage;
|
|
77
111
|
};
|
|
78
|
-
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, localizedTexts) => {
|
|
112
|
+
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
79
113
|
const index = fileName.lastIndexOf(".");
|
|
80
|
-
let errorMessage;
|
|
114
|
+
let errorMessage, exceptionDetails;
|
|
81
115
|
if (index < 0) {
|
|
82
116
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
|
|
117
|
+
exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
|
|
83
118
|
} else {
|
|
84
119
|
var _errorMessage;
|
|
85
120
|
const fileExtension = fileName.substring(index);
|
|
86
121
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
|
|
122
|
+
exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
|
|
87
123
|
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
|
|
88
124
|
errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
89
125
|
}
|
|
90
126
|
}
|
|
127
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
128
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
129
|
+
Description: "Attachment validation failed",
|
|
130
|
+
ExceptionDetails: {
|
|
131
|
+
ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
|
|
132
|
+
}
|
|
133
|
+
});
|
|
91
134
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
|
|
92
135
|
};
|
|
93
136
|
const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
94
137
|
const index = fileName.lastIndexOf(".");
|
|
95
138
|
if (index < 0) {
|
|
139
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
140
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
141
|
+
Description: "Attachment validation failed",
|
|
142
|
+
ExceptionDetails: {
|
|
143
|
+
ErrorDetails: "File provided without file extension"
|
|
144
|
+
}
|
|
145
|
+
});
|
|
96
146
|
return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
|
|
97
147
|
} else {
|
|
98
148
|
const fileExtension = fileName.substring(index);
|
|
149
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
150
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
151
|
+
Description: "Attachment validation failed",
|
|
152
|
+
ExceptionDetails: {
|
|
153
|
+
ErrorDetails: `${fileExtension} files extension is not supported.`
|
|
154
|
+
}
|
|
155
|
+
});
|
|
99
156
|
const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
|
|
100
157
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
|
|
101
158
|
}
|
|
102
159
|
};
|
|
103
|
-
const getFileSizeErrorMessage = (maxUploadFileSize, localizedTexts) => {
|
|
160
|
+
const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
161
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
162
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
163
|
+
Description: "Attachment validation failed",
|
|
164
|
+
ExceptionDetails: {
|
|
165
|
+
ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
|
|
166
|
+
}
|
|
167
|
+
});
|
|
104
168
|
const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
|
|
105
169
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
|
|
106
170
|
};
|
|
107
171
|
|
|
108
172
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
109
|
-
const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions,
|
|
173
|
+
const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => _ref => {
|
|
110
174
|
let {
|
|
111
175
|
dispatch
|
|
112
176
|
} = _ref;
|
|
@@ -117,7 +181,7 @@ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxUpl
|
|
|
117
181
|
payload
|
|
118
182
|
} = action;
|
|
119
183
|
if (payload !== null && payload !== void 0 && (_payload$activity = payload.activity) !== null && _payload$activity !== void 0 && _payload$activity.attachments && payload !== null && payload !== void 0 && (_payload$activity2 = payload.activity) !== null && _payload$activity2 !== void 0 && (_payload$activity2$ch = _payload$activity2.channelData) !== null && _payload$activity2$ch !== void 0 && _payload$activity2$ch.attachmentSizes && (payload === null || payload === void 0 ? void 0 : (_payload$activity3 = payload.activity) === null || _payload$activity3 === void 0 ? void 0 : (_payload$activity3$at = _payload$activity3.attachments) === null || _payload$activity3$at === void 0 ? void 0 : _payload$activity3$at.length) === (payload === null || payload === void 0 ? void 0 : (_payload$activity4 = payload.activity) === null || _payload$activity4 === void 0 ? void 0 : (_payload$activity4$ch = _payload$activity4.channelData) === null || _payload$activity4$ch === void 0 ? void 0 : (_payload$activity4$ch2 = _payload$activity4$ch.attachmentSizes) === null || _payload$activity4$ch2 === void 0 ? void 0 : _payload$activity4$ch2.length)) {
|
|
120
|
-
return next(validateAttachment(action, allowedFileExtensions,
|
|
184
|
+
return next(validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts));
|
|
121
185
|
}
|
|
122
186
|
}
|
|
123
187
|
return next(action);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export let ConversationEndEntity;
|
|
2
|
+
(function (ConversationEndEntity) {
|
|
3
|
+
ConversationEndEntity[ConversationEndEntity["Customer"] = 0] = "Customer";
|
|
4
|
+
ConversationEndEntity[ConversationEndEntity["Agent"] = 1] = "Agent";
|
|
5
|
+
})(ConversationEndEntity || (ConversationEndEntity = {}));
|
|
@@ -29,11 +29,15 @@ export let LiveChatWidgetActionType;
|
|
|
29
29
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 26] = "SET_RECONNECT_ID";
|
|
30
30
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 27] = "SET_UNREAD_MESSAGE_COUNT";
|
|
31
31
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 28] = "SET_FOCUS_CHAT_BUTTON";
|
|
32
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
33
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
34
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
35
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
36
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
37
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
38
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
32
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED"] = 29] = "SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED";
|
|
33
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY"] = 30] = "SET_CONVERSATION_ENDED_BY";
|
|
34
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 31] = "SET_WIDGET_STATE";
|
|
35
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 32] = "SET_LIVE_CHAT_CONTEXT";
|
|
36
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 33] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
37
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 34] = "SET_WIDGET_SIZE";
|
|
38
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 35] = "SET_WIDGET_INSTANCE_ID";
|
|
39
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 36] = "SET_LIVE_CHAT_CONFIG";
|
|
40
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_WORKFLOW_IN_PROGRESS"] = 37] = "SET_POST_CHAT_WORKFLOW_IN_PROGRESS";
|
|
41
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INITIAL_CHAT_SDK_REQUEST_ID"] = 38] = "SET_INITIAL_CHAT_SDK_REQUEST_ID";
|
|
42
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 39] = "SET_SHOULD_USE_BOT_SURVEY";
|
|
39
43
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|
|
@@ -25,7 +25,8 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
25
25
|
liveChatContext: undefined,
|
|
26
26
|
customContext: undefined,
|
|
27
27
|
widgetSize: undefined,
|
|
28
|
-
widgetInstanceId: ""
|
|
28
|
+
widgetInstanceId: "",
|
|
29
|
+
initialChatSdkRequestId: ""
|
|
29
30
|
},
|
|
30
31
|
appStates: {
|
|
31
32
|
conversationState: ConversationState.Closed,
|
|
@@ -45,7 +46,10 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
45
46
|
},
|
|
46
47
|
e2vvEnabled: false,
|
|
47
48
|
unreadMessageCount: 0,
|
|
48
|
-
|
|
49
|
+
conversationEndedByAgentEventReceived: false,
|
|
50
|
+
conversationEndedBy: undefined,
|
|
51
|
+
postChatWorkflowInProgress: false,
|
|
52
|
+
shouldUseBotSurvey: false
|
|
49
53
|
},
|
|
50
54
|
uiStates: {
|
|
51
55
|
showConfirmationPane: false,
|
|
@@ -258,12 +258,20 @@ export const createReducer = () => {
|
|
|
258
258
|
return {
|
|
259
259
|
...action.payload
|
|
260
260
|
};
|
|
261
|
-
case LiveChatWidgetActionType.
|
|
261
|
+
case LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED:
|
|
262
262
|
return {
|
|
263
263
|
...state,
|
|
264
264
|
appStates: {
|
|
265
265
|
...state.appStates,
|
|
266
|
-
|
|
266
|
+
conversationEndedByAgentEventReceived: action.payload
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
case LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY:
|
|
270
|
+
return {
|
|
271
|
+
...state,
|
|
272
|
+
appStates: {
|
|
273
|
+
...state.appStates,
|
|
274
|
+
conversationEndedBy: action.payload
|
|
267
275
|
}
|
|
268
276
|
};
|
|
269
277
|
case LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
@@ -293,6 +301,32 @@ export const createReducer = () => {
|
|
|
293
301
|
liveChatConfig: action.payload
|
|
294
302
|
}
|
|
295
303
|
};
|
|
304
|
+
case LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS:
|
|
305
|
+
return {
|
|
306
|
+
...state,
|
|
307
|
+
appStates: {
|
|
308
|
+
...state.appStates,
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
310
|
+
postChatWorkflowInProgress: action.payload
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
case LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID:
|
|
314
|
+
return {
|
|
315
|
+
...state,
|
|
316
|
+
domainStates: {
|
|
317
|
+
...state.domainStates,
|
|
318
|
+
initialChatSdkRequestId: action.payload
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
case LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY:
|
|
322
|
+
return {
|
|
323
|
+
...state,
|
|
324
|
+
appStates: {
|
|
325
|
+
...state.appStates,
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
327
|
+
shouldUseBotSurvey: action.payload
|
|
328
|
+
}
|
|
329
|
+
};
|
|
296
330
|
default:
|
|
297
331
|
return state;
|
|
298
332
|
}
|
|
@@ -17,6 +17,8 @@ export declare class Constants {
|
|
|
17
17
|
static readonly true = "true";
|
|
18
18
|
static readonly false = "false";
|
|
19
19
|
static readonly maximumUnreadMessageCount = 99;
|
|
20
|
+
static readonly userParticipantTypeTag = "User";
|
|
21
|
+
static readonly botParticipantTypeTag = "Bot";
|
|
20
22
|
static readonly channelIdKey = "ChannelId-";
|
|
21
23
|
static readonly ChannelId = "lcw";
|
|
22
24
|
static readonly CustomerTag = "FromCustomer";
|
|
@@ -134,6 +136,11 @@ export declare class WebChatMiddlewareConstants {
|
|
|
134
136
|
static readonly maxTextLength = 6000;
|
|
135
137
|
static readonly adaptiveCard = "AdaptiveCard";
|
|
136
138
|
}
|
|
139
|
+
export declare class AMSConstants {
|
|
140
|
+
static readonly supportedImagesMimeTypes: string[];
|
|
141
|
+
static readonly maxSupportedImageSize = 20;
|
|
142
|
+
static readonly maxSupportedFileSize = 300;
|
|
143
|
+
}
|
|
137
144
|
export declare class MimeTypes {
|
|
138
145
|
static readonly UnknownFileType = "application/octet-stream";
|
|
139
146
|
}
|