@microsoft/omnichannel-chat-widget 0.1.0-main.e170704 → 0.1.0-main.e67738e
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/README.md +32 -0
- package/lib/cjs/common/Constants.js +18 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +25 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +8 -9
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +76 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +52 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -15
- package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +24 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +170 -72
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +256 -93
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +91 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/cjs/contexts/createReducer.js +17 -0
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +18 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +25 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +8 -6
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +53 -0
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +39 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -15
- package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +23 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +165 -75
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +248 -96
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +82 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/esm/contexts/createReducer.js +17 -0
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +9 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +25 -5
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +7 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +4 -1
- package/package.json +4 -3
|
@@ -8,11 +8,48 @@ import { defaultMiddlewareLocalizedTexts } from "./common/defaultProps/defaultMi
|
|
|
8
8
|
import { defaultWebChatContainerStatefulProps } from "./common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
9
9
|
import { setFocusOnSendBox } from "../../common/utils";
|
|
10
10
|
import { useChatContextStore } from "../..";
|
|
11
|
+
import { WebChatActionType } from "./webchatcontroller/enums/WebChatActionType";
|
|
12
|
+
import { WebChatStoreLoader } from "./webchatcontroller/WebChatStoreLoader";
|
|
13
|
+
import { Constants } from "../../common/Constants";
|
|
14
|
+
import { BotMagicCodeStore } from "./webchatcontroller/BotMagicCodeStore";
|
|
15
|
+
import { defaultAdaptiveCardStyles } from "./common/defaultStyles/defaultAdaptiveCardStyles";
|
|
16
|
+
const broadcastChannelMessageEvent = "message";
|
|
17
|
+
|
|
18
|
+
const postActivity = activity => {
|
|
19
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
20
|
+
return {
|
|
21
|
+
type: WebChatActionType.DIRECT_LINE_POST_ACTIVITY,
|
|
22
|
+
meta: {
|
|
23
|
+
method: "keyboard"
|
|
24
|
+
},
|
|
25
|
+
payload: {
|
|
26
|
+
activity: {
|
|
27
|
+
channelData: undefined,
|
|
28
|
+
text: "",
|
|
29
|
+
textFormat: "plain",
|
|
30
|
+
type: Constants.message,
|
|
31
|
+
...activity
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const createMagicCodeSuccessResponse = signin => {
|
|
38
|
+
return {
|
|
39
|
+
signin,
|
|
40
|
+
result: "Success"
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
11
44
|
export const WebChatContainerStateful = props => {
|
|
45
|
+
var _props$adaptiveCardSt, _props$adaptiveCardSt2;
|
|
46
|
+
|
|
12
47
|
const {
|
|
13
48
|
BasicWebChat
|
|
14
49
|
} = Components;
|
|
15
50
|
const [state, dispatch] = useChatContextStore();
|
|
51
|
+
const magicCodeBroadcastChannel = new BroadcastChannel(Constants.magicCodeBroadcastChannel);
|
|
52
|
+
const magicCodeResponseBroadcastChannel = new BroadcastChannel(Constants.magicCodeResponseBroadcastChannel);
|
|
16
53
|
const containerStyles = {
|
|
17
54
|
root: Object.assign({}, defaultWebChatContainerStatefulProps.containerStyles, props === null || props === void 0 ? void 0 : props.containerStyles, {
|
|
18
55
|
display: state.appStates.isMinimized ? "none" : ""
|
|
@@ -36,7 +73,52 @@ export const WebChatContainerStateful = props => {
|
|
|
36
73
|
Event: TelemetryEvent.WebChatLoaded
|
|
37
74
|
});
|
|
38
75
|
}, []);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const eventListener = event => {
|
|
78
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
|
|
79
|
+
const {
|
|
80
|
+
data
|
|
81
|
+
} = event;
|
|
82
|
+
|
|
83
|
+
if (BotMagicCodeStore.botOAuthSignInId === data.signin) {
|
|
84
|
+
const {
|
|
85
|
+
signin,
|
|
86
|
+
code
|
|
87
|
+
} = data;
|
|
88
|
+
const text = `${code}`;
|
|
89
|
+
const action = postActivity({
|
|
90
|
+
text,
|
|
91
|
+
channelData: {
|
|
92
|
+
tags: [Constants.hiddenTag]
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
WebChatStoreLoader.store.dispatch(action);
|
|
96
|
+
const response = createMagicCodeSuccessResponse(signin);
|
|
97
|
+
magicCodeResponseBroadcastChannel.postMessage(response);
|
|
98
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
99
|
+
Event: TelemetryEvent.SuppressBotMagicCodeSucceeded
|
|
100
|
+
});
|
|
101
|
+
BotMagicCodeStore.botOAuthSignInId = "";
|
|
102
|
+
magicCodeBroadcastChannel.close();
|
|
103
|
+
magicCodeResponseBroadcastChannel.close();
|
|
104
|
+
} else {
|
|
105
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
106
|
+
Event: TelemetryEvent.SuppressBotMagicCodeFailed,
|
|
107
|
+
Description: "Signin does not match"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
magicCodeBroadcastChannel.addEventListener(broadcastChannelMessageEvent, eventListener);
|
|
113
|
+
}, []);
|
|
39
114
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
115
|
+
|
|
116
|
+
.webchat__bubble__content>div#ms_lcw_webchat_adaptive_card {
|
|
117
|
+
background: ${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt = props.adaptiveCardStyles) === null || _props$adaptiveCardSt === void 0 ? void 0 : _props$adaptiveCardSt.background) ?? defaultAdaptiveCardStyles.background};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
div[class="ac-textBlock"]>p{color:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt2 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt2 === void 0 ? void 0 : _props$adaptiveCardSt2.color) ?? defaultAdaptiveCardStyles.color};}
|
|
121
|
+
|
|
40
122
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
41
123
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
42
124
|
height: '.75em';
|
|
@@ -2,11 +2,13 @@ import MockAdapter from "../mockadapter";
|
|
|
2
2
|
import { defaultWebChatStatefulContainerStyles } from "../defaultStyles/defaultWebChatStatefulContainerStyles";
|
|
3
3
|
import { defaultWebChatStatefulProps } from "./defaultWebChatStatefulProps";
|
|
4
4
|
import { defaultWebChatStatefulStyles } from "../defaultStyles/defaultWebChatContainerStatefulStyles";
|
|
5
|
+
import { defaultAdaptiveCardStyles } from "../defaultStyles/defaultAdaptiveCardStyles";
|
|
5
6
|
export const defaultWebChatContainerStatefulProps = {
|
|
6
7
|
webChatStyles: defaultWebChatStatefulStyles,
|
|
7
8
|
webChatProps: defaultWebChatStatefulProps,
|
|
8
9
|
containerStyles: defaultWebChatStatefulContainerStyles,
|
|
9
10
|
disableNewLineMarkdownSupport: false,
|
|
10
11
|
disableMarkdownMessageFormatting: false,
|
|
11
|
-
directLine: new MockAdapter()
|
|
12
|
+
directLine: new MockAdapter(),
|
|
13
|
+
adaptiveCardStyles: defaultAdaptiveCardStyles
|
|
12
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
export class BotMagicCodeStore {}
|
|
4
|
+
|
|
5
|
+
_defineProperty(BotMagicCodeStore, "botOAuthSignInId", "");
|
|
@@ -54,6 +54,16 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
54
54
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
const isTagIncluded = (card, tag) => {
|
|
58
|
+
return isDataTagsPresent(card) && card.activity.channelData.tags.includes(tag);
|
|
59
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const isDataTagsPresent = card => {
|
|
63
|
+
return card && card.activity && card.activity.channelData && card.activity.channelData.tags && card.activity.channelData.tags.length > 0;
|
|
64
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
|
|
66
|
+
|
|
57
67
|
export const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
58
68
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
69
|
args[_key] = arguments[_key];
|
|
@@ -62,7 +72,7 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
|
|
|
62
72
|
const [card] = args;
|
|
63
73
|
|
|
64
74
|
if (card.activity) {
|
|
65
|
-
var _card$activity$from
|
|
75
|
+
var _card$activity$from;
|
|
66
76
|
|
|
67
77
|
if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === DirectLineSenderRole.Channel) {
|
|
68
78
|
var _card$activity$channe3;
|
|
@@ -77,7 +87,11 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
|
|
|
77
87
|
return () => false;
|
|
78
88
|
}
|
|
79
89
|
|
|
80
|
-
if ((
|
|
90
|
+
if (isTagIncluded(card, Constants.hiddenTag)) {
|
|
91
|
+
return () => false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isTagIncluded(card, Constants.systemMessageTag)) {
|
|
81
95
|
return handleSystemMessage(next, args, card, systemMessageStyleProps);
|
|
82
96
|
} else if (card.activity.text && card.activity.type === DirectLineActivityType.Message) {
|
|
83
97
|
if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === Constants.webchatChannelId) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BotMagicCodeStore } from "../../BotMagicCodeStore";
|
|
2
|
+
var CardActionType;
|
|
3
|
+
|
|
4
|
+
(function (CardActionType) {
|
|
5
|
+
CardActionType["OpenUrl"] = "openUrl";
|
|
6
|
+
CardActionType["SignIn"] = "signin";
|
|
7
|
+
})(CardActionType || (CardActionType = {}));
|
|
8
|
+
|
|
9
|
+
const validCardActionTypes = [CardActionType.OpenUrl, CardActionType.SignIn];
|
|
10
|
+
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
11
|
+
export const createCardActionMiddleware = botMagicCodeConfig => {
|
|
12
|
+
const cardActionMiddleware = () => next => function () {
|
|
13
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
|
+
args[_key] = arguments[_key];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const [card] = args;
|
|
19
|
+
|
|
20
|
+
if (card.cardAction && validCardActionTypes.indexOf(card.cardAction.type) >= 0 && card.cardAction.value) {
|
|
21
|
+
// Override signin url only if fwdUrl is valid & feature is enabled
|
|
22
|
+
if ((botMagicCodeConfig === null || botMagicCodeConfig === void 0 ? void 0 : botMagicCodeConfig.disabled) === true && botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl) {
|
|
23
|
+
const baseUrl = window.location.origin;
|
|
24
|
+
const result = botOauthUrlRegex.exec(card.cardAction.value);
|
|
25
|
+
|
|
26
|
+
if (result) {
|
|
27
|
+
BotMagicCodeStore.botOAuthSignInId = `${result[1]}`;
|
|
28
|
+
} // fwdUrl must be on the same domain as the chat widget
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if (botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl.startsWith(baseUrl)) {
|
|
32
|
+
card.cardAction.value += `&fwdUrl=${botMagicCodeConfig.fwdUrl}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return next(...args);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return cardActionMiddleware;
|
|
41
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/extend-expect";
|
|
2
|
+
import { createCardActionMiddleware } from "./cardActionMiddleware";
|
|
3
|
+
describe("cardActionMiddleware test", () => {
|
|
4
|
+
it("createCardActionMiddleware() with undefined botMagicCodeConfig should not change the sign in card url", () => {
|
|
5
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
9
|
+
const args = {
|
|
10
|
+
cardAction: {
|
|
11
|
+
type: "signin",
|
|
12
|
+
value: signInUrl
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const results = createCardActionMiddleware(undefined)()(next)(args);
|
|
16
|
+
expect(signInUrl).toEqual(results.cardAction.value);
|
|
17
|
+
});
|
|
18
|
+
it("createCardActionMiddleware() with botMagicCode enabled should not change the sign in card url", () => {
|
|
19
|
+
const botMagicCodeConfig = {
|
|
20
|
+
disabled: false
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
27
|
+
const args = {
|
|
28
|
+
cardAction: {
|
|
29
|
+
type: "signin",
|
|
30
|
+
value: signInUrl
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
|
|
34
|
+
expect(args.cardAction.value).toEqual(results.cardAction.value);
|
|
35
|
+
});
|
|
36
|
+
it("createCardActionMiddleware() with botMagicCode disabled & no fwdUrl should not change the sign in card url", () => {
|
|
37
|
+
const botMagicCodeConfig = {
|
|
38
|
+
disabled: true
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
45
|
+
const args = {
|
|
46
|
+
cardAction: {
|
|
47
|
+
type: "signin",
|
|
48
|
+
value: signInUrl
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
|
|
52
|
+
expect(args.cardAction.value).toEqual(results.cardAction.value);
|
|
53
|
+
});
|
|
54
|
+
it("createCardActionMiddleware() with botMagicCode disabled & fwdUrl should append the fwdUrl in the sign in card url", () => {
|
|
55
|
+
const botMagicCodeConfig = {
|
|
56
|
+
disabled: true,
|
|
57
|
+
fwdUrl: "http://localhost/forwarder.html"
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
64
|
+
const args = {
|
|
65
|
+
cardAction: {
|
|
66
|
+
type: "signin",
|
|
67
|
+
value: signInUrl
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
|
|
71
|
+
expect(signInUrl === results.cardAction.value).toBe(false);
|
|
72
|
+
expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
it("createCardActionMiddleware() should not append fwdUrl if fwdUrl & sign in card url are not in the same domain", () => {
|
|
75
|
+
const botMagicCodeConfig = {
|
|
76
|
+
disabled: true,
|
|
77
|
+
fwdUrl: "https://localhost/forwarder.html"
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
84
|
+
const args = {
|
|
85
|
+
cardAction: {
|
|
86
|
+
type: "signin",
|
|
87
|
+
value: signInUrl
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
|
|
91
|
+
expect(signInUrl === results.cardAction.value).toBe(true);
|
|
92
|
+
expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
2
|
+
import { Constants } from "../../../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
3
|
+
|
|
4
|
+
const createMessageTimeStampMiddleware = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
dispatch
|
|
7
|
+
} = _ref;
|
|
8
|
+
return next => action => {
|
|
9
|
+
if (isApplicable(action)) {
|
|
10
|
+
return next(evaluateTagsAndOverrideTimeStamp(action));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return next(action);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const isApplicable = action => {
|
|
18
|
+
return action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && isPVAConversation(action) && isPayloadValid(action) && isValidChannel(action);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const isPayloadValid = action => {
|
|
22
|
+
var _action$payload;
|
|
23
|
+
|
|
24
|
+
return action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const isValidChannel = action => {
|
|
28
|
+
var _action$payload2, _action$payload2$acti;
|
|
29
|
+
|
|
30
|
+
return (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$acti.channelId) === Constants.acsChannel;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const isPVAConversation = action => {
|
|
34
|
+
return !isTagIncluded(action, Constants.systemMessageTag) && !isTagIncluded(action, Constants.publicMessageTag) && !isRoleUserOn(action);
|
|
35
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const isTagIncluded = (action, tag) => {
|
|
39
|
+
return isDataTagsPresent(action) && action.payload.activity.channelData.tags.includes(tag);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isRoleUserOn = action => {
|
|
43
|
+
var _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
44
|
+
|
|
45
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.from) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.role) === Constants.userMessageTag;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const overrideTimeStamp = (timestampOriginal, timeStampNew) => {
|
|
49
|
+
return isTimestampValid(timeStampNew) ? timeStampNew : timestampOriginal;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const isTimestampValid = timeStamp => {
|
|
53
|
+
const regex = /(\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(T)(\d{2})(:{1})(\d{2})(:{1})(\d{2})(.\d+)([Z]{1}))/;
|
|
54
|
+
return regex.test(timeStamp);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const isDataTagsPresent = action => {
|
|
58
|
+
var _action$payload4, _action$payload4$acti, _action$payload4$acti2;
|
|
59
|
+
|
|
60
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : (_action$payload4$acti2 = _action$payload4$acti.channelData) === null || _action$payload4$acti2 === void 0 ? void 0 : _action$payload4$acti2.tags) && action.payload.activity.channelData.tags.length > 0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const evaluateTagsAndOverrideTimeStamp = action => {
|
|
64
|
+
const tagValue = tagLookup(action, Constants.prefixTimestampTag);
|
|
65
|
+
|
|
66
|
+
if (tagValue) {
|
|
67
|
+
const newTimestamp = extractTimeStamp(tagValue);
|
|
68
|
+
action.payload.activity.timestamp = overrideTimeStamp(action.payload.activity.timestamp, newTimestamp);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return action;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const extractTimeStamp = timeStamp => {
|
|
75
|
+
if (timeStamp && timeStamp.length > 0) {
|
|
76
|
+
const ts = timeStamp.split(Constants.prefixTimestampTag);
|
|
77
|
+
|
|
78
|
+
if (ts && ts.length > 1) {
|
|
79
|
+
return ts[1];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return timeStamp;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const tagLookup = (action, tag) => {
|
|
87
|
+
if (!isDataTagsPresent(action)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const tags = action.payload.activity.channelData.tags;
|
|
92
|
+
let value;
|
|
93
|
+
|
|
94
|
+
if (tags && tags.length > 0) {
|
|
95
|
+
for (let i = 0; i < tags.length; i++) {
|
|
96
|
+
value = tags[i];
|
|
97
|
+
|
|
98
|
+
if (value && value.indexOf(tag) > -1) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default createMessageTimeStampMiddleware;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LogLevel } from "../../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
3
3
|
export function createWebChatTelemetry() {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
5
|
const handleTelemetry = event => {
|
|
5
6
|
const {
|
|
6
7
|
level
|
|
@@ -8,6 +8,7 @@ export let ConversationState;
|
|
|
8
8
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
9
9
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
10
10
|
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
11
|
-
ConversationState[ConversationState["
|
|
12
|
-
ConversationState[ConversationState["
|
|
11
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
12
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
13
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
13
14
|
})(ConversationState || (ConversationState = {}));
|
|
@@ -32,4 +32,7 @@ export let LiveChatWidgetActionType;
|
|
|
32
32
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
|
|
33
33
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
|
|
34
34
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
35
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
36
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
|
|
37
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 33] = "SET_WIDGET_INSTANCE_ID";
|
|
35
38
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|
|
@@ -19,14 +19,15 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
19
19
|
telemetryInternalData: {},
|
|
20
20
|
globalDir: "ltr",
|
|
21
21
|
liveChatContext: undefined,
|
|
22
|
-
customContext: undefined
|
|
22
|
+
customContext: undefined,
|
|
23
|
+
widgetSize: undefined,
|
|
24
|
+
widgetInstanceId: ""
|
|
23
25
|
},
|
|
24
26
|
appStates: {
|
|
25
27
|
conversationState: ConversationState.Closed,
|
|
26
28
|
isMinimized: false,
|
|
27
29
|
previousElementOnFocusBeforeModalOpen: null,
|
|
28
30
|
outsideOperatingHours: false,
|
|
29
|
-
shouldShowPostChat: false,
|
|
30
31
|
preChatResponseEmail: "",
|
|
31
32
|
isAudioMuted: null,
|
|
32
33
|
newMessage: false,
|
|
@@ -64,6 +64,7 @@ export const createReducer = () => {
|
|
|
64
64
|
case LiveChatWidgetActionType.SET_CUSTOM_CONTEXT:
|
|
65
65
|
return { ...state,
|
|
66
66
|
domainStates: { ...state.domainStates,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
68
|
customContext: action.payload
|
|
68
69
|
}
|
|
69
70
|
};
|
|
@@ -226,6 +227,22 @@ export const createReducer = () => {
|
|
|
226
227
|
}
|
|
227
228
|
};
|
|
228
229
|
|
|
230
|
+
case LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
231
|
+
return { ...state,
|
|
232
|
+
domainStates: { ...state.domainStates,
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
widgetSize: action.payload
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
case LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
|
|
239
|
+
return { ...state,
|
|
240
|
+
domainStates: { ...state.domainStates,
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
+
widgetInstanceId: action.payload
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
229
246
|
default:
|
|
230
247
|
return state;
|
|
231
248
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConversationState } from "../contexts/common/ConversationState";
|
|
2
2
|
export const shouldShowChatButton = state => {
|
|
3
|
-
return state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed;
|
|
3
|
+
return (state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
|
|
4
4
|
};
|
|
5
5
|
export const shouldShowProactiveChatPane = state => {
|
|
6
6
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
@@ -18,13 +18,13 @@ export const shouldShowWebChatContainer = state => {
|
|
|
18
18
|
return state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
|
|
19
19
|
};
|
|
20
20
|
export const shouldShowLoadingPane = state => {
|
|
21
|
-
return !state.appStates.isMinimized &&
|
|
21
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
|
|
22
22
|
};
|
|
23
23
|
export const shouldShowReconnectChatPane = state => {
|
|
24
24
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ReconnectChat;
|
|
25
25
|
};
|
|
26
26
|
export const shouldShowPostChatLoadingPane = state => {
|
|
27
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
27
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.PostchatLoading;
|
|
28
28
|
};
|
|
29
29
|
export const shouldShowOutOfOfficeHoursPane = state => {
|
|
30
30
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.OutOfOffice;
|
|
@@ -2,7 +2,6 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/Te
|
|
|
2
2
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
3
|
import { Constants } from "../common/Constants";
|
|
4
4
|
import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
|
|
5
|
-
import { TelemetryManager } from "../common/telemetry/TelemetryManager";
|
|
6
5
|
export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
7
6
|
const onNewAdapterActivityHandler = activity => {
|
|
8
7
|
var _activity$channelData, _activity$channelData2, _activity$channelData3;
|
|
@@ -17,18 +16,16 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
17
16
|
|
|
18
17
|
const raiseMessageEvent = activity => {
|
|
19
18
|
if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
|
|
20
|
-
var
|
|
19
|
+
var _text, _text2, _activity$channelData4, _activity$from;
|
|
21
20
|
|
|
22
21
|
const payload = {
|
|
22
|
+
// To identify hidden contents vs empty content
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
text: activity === null || activity === void 0 ? void 0 : activity.text,
|
|
25
|
-
id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
24
|
+
text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
|
|
26
25
|
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
27
26
|
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
28
|
-
chatId: chatId,
|
|
29
27
|
userId: userId,
|
|
30
|
-
|
|
31
|
-
channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
|
|
28
|
+
tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
|
|
32
29
|
messageType: ""
|
|
33
30
|
};
|
|
34
31
|
|
|
@@ -45,18 +42,18 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
45
42
|
Description: "New message sent"
|
|
46
43
|
});
|
|
47
44
|
} else {
|
|
48
|
-
var _activity$
|
|
45
|
+
var _activity$channelData5, _activity$channelData6;
|
|
49
46
|
|
|
50
|
-
if (activity !== null && activity !== void 0 && (_activity$
|
|
47
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(Constants.systemMessageTag)) {
|
|
51
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
49
|
payload.messageType = Constants.systemMessageTag;
|
|
53
50
|
} else {
|
|
54
|
-
var _activity$
|
|
51
|
+
var _activity$channelData7, _activity$channelData8, _activity$channelData9;
|
|
55
52
|
|
|
56
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
54
|
const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
55
|
|
|
59
|
-
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$
|
|
56
|
+
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && _activity$channelData7.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.tags) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
57
|
|
|
61
58
|
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
62
59
|
|
|
@@ -74,7 +71,8 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
74
71
|
BroadcastService.postMessage(newMessageReceivedEvent);
|
|
75
72
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
76
73
|
Event: TelemetryEvent.MessageReceived,
|
|
77
|
-
Description: "New message received"
|
|
74
|
+
Description: "New message received",
|
|
75
|
+
Data: payload
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare class Constants {
|
|
2
|
+
static readonly magicCodeBroadcastChannel = "MagicCodeChannel";
|
|
3
|
+
static readonly magicCodeResponseBroadcastChannel = "MagicCodeResponseChannel";
|
|
2
4
|
static readonly systemMessageTag = "system";
|
|
3
5
|
static readonly userMessageTag = "user";
|
|
4
6
|
static readonly historyMessageTag = "history";
|
|
@@ -15,7 +17,6 @@ export declare class Constants {
|
|
|
15
17
|
static readonly true = "true";
|
|
16
18
|
static readonly false = "false";
|
|
17
19
|
static readonly maximumUnreadMessageCount = 99;
|
|
18
|
-
static readonly widgetStateDataKey = "LcwChatWidgetState";
|
|
19
20
|
static readonly channelIdKey = "ChannelId-";
|
|
20
21
|
static readonly ChannelId = "lcw";
|
|
21
22
|
static readonly CustomerTag = "FromCustomer";
|
|
@@ -33,6 +34,10 @@ export declare class Constants {
|
|
|
33
34
|
static readonly queuePositionMessageTag = "queueposition";
|
|
34
35
|
static readonly averageWaitTimeMessageTag = "averagewaittime";
|
|
35
36
|
static readonly message = "message";
|
|
37
|
+
static readonly hiddenTag = "Hidden";
|
|
38
|
+
static readonly prefixTimestampTag = "ServerMessageTimestamp_";
|
|
39
|
+
static readonly acsChannel = "ACS_CHANNEL";
|
|
40
|
+
static readonly publicMessageTag = "public";
|
|
36
41
|
static readonly supportedAdaptiveCardContentTypes: Array<string>;
|
|
37
42
|
static readonly maxUploadFileSize = "500000";
|
|
38
43
|
static readonly imageRegex: RegExp;
|
|
@@ -70,6 +75,9 @@ export declare class Constants {
|
|
|
70
75
|
static readonly OpenLinkIconCssClass = "webchat__markdown__external-link-icon";
|
|
71
76
|
static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
|
|
72
77
|
static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
|
|
78
|
+
static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
|
|
79
|
+
static readonly PostChatLoadingDurationInMs = 2000;
|
|
80
|
+
static readonly BrowserUnloadConfirmationMessage = "Do you want to leave chat?";
|
|
73
81
|
}
|
|
74
82
|
export declare const Regex: {
|
|
75
83
|
new (): {};
|