@microsoft/omnichannel-chat-widget 1.7.8-main.2e1cc2b → 1.7.8-main.50111af
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 +57 -18
- package/lib/cjs/common/KeyCodes.js +6 -1
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +6 -1
- package/lib/cjs/common/facades/FacadeChatSDK.js +385 -291
- package/lib/cjs/common/storage/default/defaultCacheManager.js +6 -3
- package/lib/cjs/common/telemetry/TelemetryConstants.js +139 -116
- package/lib/cjs/common/telemetry/TelemetryHelper.js +219 -181
- package/lib/cjs/common/telemetry/TelemetryManager.js +9 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -5
- package/lib/cjs/components/headerstateful/HeaderStateful.js +3 -5
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +14 -6
- package/lib/cjs/components/livechatwidget/common/Deferred.js +14 -6
- package/lib/cjs/components/livechatwidget/common/authHelper.js +15 -0
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +4 -18
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +0 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +2 -23
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +17 -11
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +9 -3
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +22 -6
- package/lib/cjs/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +28 -0
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
- package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +62 -52
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
- package/lib/cjs/firstresponselatency/Constants.js +13 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +118 -0
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +201 -0
- package/lib/cjs/firstresponselatency/util.js +98 -0
- package/lib/cjs/plugins/createChatTranscript.js +92 -62
- package/lib/cjs/plugins/newMessageEventHandler.js +102 -88
- package/lib/esm/common/Constants.js +57 -18
- package/lib/esm/common/KeyCodes.js +6 -1
- package/lib/esm/common/contextDataStore/DataStoreManager.js +6 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +385 -291
- package/lib/esm/common/storage/default/defaultCacheManager.js +6 -1
- package/lib/esm/common/telemetry/TelemetryConstants.js +139 -116
- package/lib/esm/common/telemetry/TelemetryHelper.js +219 -181
- package/lib/esm/common/telemetry/TelemetryManager.js +9 -2
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -5
- package/lib/esm/components/headerstateful/HeaderStateful.js +3 -5
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +14 -6
- package/lib/esm/components/livechatwidget/common/Deferred.js +14 -6
- package/lib/esm/components/livechatwidget/common/authHelper.js +15 -0
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +4 -18
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +1 -6
- package/lib/esm/components/livechatwidget/common/startChat.js +3 -24
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +17 -11
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +9 -3
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +22 -6
- package/lib/esm/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +21 -0
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
- package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +63 -52
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
- package/lib/esm/firstresponselatency/Constants.js +6 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +112 -0
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +194 -0
- package/lib/esm/firstresponselatency/util.js +87 -0
- package/lib/esm/plugins/createChatTranscript.js +92 -62
- package/lib/esm/plugins/newMessageEventHandler.js +100 -86
- package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +10 -1
- package/lib/types/components/postchatsurveypanestateful/common/isValidSurveyUrl.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatProps.d.ts +2 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/firstresponselatency/Constants.d.ts +30 -0
- package/lib/types/firstresponselatency/FirstMessageTrackerFromBot.d.ts +1 -0
- package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +22 -0
- package/lib/types/firstresponselatency/util.d.ts +7 -0
- package/package.json +18 -6
|
@@ -7,7 +7,6 @@ exports.setPreChatAndInitiateChat = exports.prepareStartChat = exports.initStart
|
|
|
7
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _Constants = require("../../../common/Constants");
|
|
9
9
|
var _utils = require("../../../common/utils");
|
|
10
|
-
var _authHelper = require("./authHelper");
|
|
11
10
|
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
12
11
|
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
13
12
|
var _ActivityStreamHandler = require("./ActivityStreamHandler");
|
|
@@ -19,6 +18,7 @@ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
|
19
18
|
var _endChat = require("./endChat");
|
|
20
19
|
var _createAdapter = require("./createAdapter");
|
|
21
20
|
var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler");
|
|
21
|
+
var _FirstMessageTrackerFromBot = require("../../../firstresponselatency/FirstMessageTrackerFromBot");
|
|
22
22
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
23
23
|
var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
|
|
24
24
|
var _persistentChatHelper = require("./persistentChatHelper");
|
|
@@ -30,20 +30,6 @@ let widgetInstanceId;
|
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
31
|
let popoutWidgetInstanceId;
|
|
32
32
|
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
const setAuthenticationIfApplicable = async (props, facadeChatSDK) => {
|
|
35
|
-
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
36
|
-
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
37
|
-
const authClientFunction = (0, _authHelper.getAuthClientFunction)(chatConfig);
|
|
38
|
-
if (getAuthToken && authClientFunction) {
|
|
39
|
-
// set auth token to chat sdk before start chat
|
|
40
|
-
const authSuccess = await (0, _authHelper.handleAuthentication)(facadeChatSDK.getChatSDK(), chatConfig, getAuthToken);
|
|
41
|
-
if (!authSuccess.result) {
|
|
42
|
-
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
34
|
const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
49
35
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
@@ -71,11 +57,6 @@ const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapte
|
|
|
71
57
|
const isProactiveChat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat;
|
|
72
58
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
73
59
|
|
|
74
|
-
// Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
|
|
75
|
-
if ((0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
|
|
76
|
-
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
60
|
//Setting PreChat and intiate chat
|
|
80
61
|
await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
81
62
|
};
|
|
@@ -151,6 +132,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
151
132
|
const optionalParams = {
|
|
152
133
|
isProactiveChat
|
|
153
134
|
};
|
|
135
|
+
(0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
|
|
154
136
|
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
155
137
|
};
|
|
156
138
|
|
|
@@ -179,9 +161,6 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
179
161
|
Description: "Widget loading started"
|
|
180
162
|
});
|
|
181
163
|
|
|
182
|
-
// Auth token retrieval needs to happen during start chat to support pop-out chat
|
|
183
|
-
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
184
|
-
|
|
185
164
|
//Check if chat retrieved from cache
|
|
186
165
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
187
166
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
@@ -64,7 +64,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
64
64
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
65
65
|
let uiTimer;
|
|
66
66
|
const LiveChatWidgetStateful = props => {
|
|
67
|
-
var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
67
|
+
var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
68
68
|
(0, _react2.useEffect)(() => {
|
|
69
69
|
uiTimer = (0, _utils.createTimer)();
|
|
70
70
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -417,7 +417,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
417
417
|
|
|
418
418
|
// Start chat from SDK Event
|
|
419
419
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
420
|
-
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3
|
|
420
|
+
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3;
|
|
421
421
|
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
422
422
|
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig6 = props.chatConfig) === null || _props$chatConfig6 === void 0 ? void 0 : (_props$chatConfig6$Li = _props$chatConfig6.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig6$Li === void 0 ? void 0 : _props$chatConfig6$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
423
423
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
@@ -455,8 +455,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
455
455
|
});
|
|
456
456
|
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
457
457
|
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
/*
|
|
459
|
+
* If the conversation is in closed state then we start a new chat,
|
|
460
|
+
* else if the conversation is in active state then we maximize the chat
|
|
461
|
+
* If the conversation is in inactive or postchat state then we maximize the chat.
|
|
462
|
+
*
|
|
463
|
+
* To start a new chat, it needs to be called via the close button or close chat via SDK.
|
|
464
|
+
**/
|
|
465
|
+
if (((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
460
466
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
461
467
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
462
468
|
});
|
|
@@ -465,7 +471,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
465
471
|
}
|
|
466
472
|
|
|
467
473
|
// If minimized, maximize the chat
|
|
468
|
-
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
474
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.isMinimized) === true) {
|
|
469
475
|
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
470
476
|
dispatch({
|
|
471
477
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -593,12 +599,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
593
599
|
disablePolling: true
|
|
594
600
|
});
|
|
595
601
|
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onAgentEndSession(event => {
|
|
596
|
-
var _inMemoryState$
|
|
602
|
+
var _inMemoryState$appSta4;
|
|
597
603
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
598
604
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
599
605
|
payload: null
|
|
600
606
|
});
|
|
601
|
-
if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
607
|
+
if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.conversationState) === _ConversationState.ConversationState.Active) {
|
|
602
608
|
setWebChatStyles(styles => {
|
|
603
609
|
return {
|
|
604
610
|
...styles,
|
|
@@ -741,13 +747,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
741
747
|
|
|
742
748
|
// Handle Chat disconnect cases
|
|
743
749
|
(0, _react2.useEffect)(() => {
|
|
744
|
-
var _inMemoryState$
|
|
750
|
+
var _inMemoryState$appSta5;
|
|
745
751
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
746
752
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
747
753
|
payload: null
|
|
748
754
|
});
|
|
749
755
|
(0, _chatDisconnectHelper.handleChatDisconnect)(props, inMemoryState, setWebChatStyles);
|
|
750
|
-
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
756
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
|
|
751
757
|
if (chatDisconnectState && adapter) {
|
|
752
758
|
try {
|
|
753
759
|
adapter.end();
|
|
@@ -876,8 +882,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
876
882
|
userID: userID,
|
|
877
883
|
styleOptions: {
|
|
878
884
|
...webChatStyles,
|
|
879
|
-
bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.
|
|
880
|
-
bubbleTextColor: ((_props$
|
|
885
|
+
bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.webChatStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.bubbleBackground) ?? ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background,
|
|
886
|
+
bubbleTextColor: ((_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : (_props$webChatContain16 = _props$webChatContain15.webChatStyles) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.bubbleTextColor) ?? ((_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : (_props$webChatContain18 = _props$webChatContain17.adaptiveCardStyles) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color
|
|
881
887
|
},
|
|
882
888
|
directLine: directLine
|
|
883
889
|
}), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
@@ -7,6 +7,7 @@ exports.default = exports.OutOfOfficeHoursPaneStateful = void 0;
|
|
|
7
7
|
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _utils = require("../../common/utils");
|
|
10
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
10
11
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
11
12
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
12
13
|
var _defaultgeneralOOOHPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps");
|
|
@@ -37,9 +38,11 @@ const OutOfOfficeHoursPaneStateful = props => {
|
|
|
37
38
|
|
|
38
39
|
// Move focus to the first button
|
|
39
40
|
(0, _react.useEffect)(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
firstElement[0]
|
|
41
|
+
if (state.domainStates.widgetElementId !== null && state.domainStates.widgetElementId !== undefined && state.domainStates.widgetElementId.trim() !== "") {
|
|
42
|
+
const firstElement = (0, _utils.findAllFocusableElement)(`#${state.domainStates.widgetElementId}`);
|
|
43
|
+
if (firstElement && firstElement[0]) {
|
|
44
|
+
firstElement[0].focus();
|
|
45
|
+
}
|
|
43
46
|
}
|
|
44
47
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
45
48
|
Event: _TelemetryConstants.TelemetryEvent.OutOfOfficePaneLoaded
|
|
@@ -49,6 +52,9 @@ const OutOfOfficeHoursPaneStateful = props => {
|
|
|
49
52
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
50
53
|
});
|
|
51
54
|
}, []);
|
|
55
|
+
if (controlProps !== null && controlProps !== void 0 && controlProps.titleText) {
|
|
56
|
+
controlProps.titleText = _dompurify.default.sanitize(controlProps.titleText);
|
|
57
|
+
}
|
|
52
58
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.OutOfOfficeHoursPane, {
|
|
53
59
|
componentOverrides: props.componentOverrides,
|
|
54
60
|
controlProps: controlProps,
|
|
@@ -14,17 +14,19 @@ var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
|
14
14
|
var _defaultgeneralPostChatSurveyPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps");
|
|
15
15
|
var _utils = require("../../common/utils");
|
|
16
16
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
17
|
+
var _isValidSurveyUrl = _interopRequireDefault(require("./common/isValidSurveyUrl"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
21
|
const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
|
|
21
22
|
let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const surveyLinkParams = new URLSearchParams({
|
|
24
|
+
embed: isEmbed.toString(),
|
|
25
|
+
compact: (compact ?? true).toString(),
|
|
26
|
+
lang: locale ?? "en-us",
|
|
27
|
+
showmultilingual: (showMultiLingual ?? false).toString()
|
|
28
|
+
});
|
|
29
|
+
return `${surveyInviteLink}&${surveyLinkParams.toString()}`;
|
|
28
30
|
};
|
|
29
31
|
const PostChatSurveyPaneStateful = props => {
|
|
30
32
|
var _props$styleProps, _state$appStates, _props$controlProps;
|
|
@@ -54,6 +56,20 @@ const PostChatSurveyPaneStateful = props => {
|
|
|
54
56
|
surveyURL: ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.surveyURL) ?? surveyInviteLink,
|
|
55
57
|
...props.controlProps
|
|
56
58
|
};
|
|
59
|
+
if (controlProps.surveyURL) {
|
|
60
|
+
if (!(0, _isValidSurveyUrl.default)(controlProps.surveyURL)) {
|
|
61
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
62
|
+
Event: _TelemetryConstants.TelemetryEvent.PostChatSurveyUrlValidationFailed,
|
|
63
|
+
Description: `${controlProps.surveyURL} is not a valid Survey URL`
|
|
64
|
+
});
|
|
65
|
+
controlProps.surveyURL = "";
|
|
66
|
+
} else {
|
|
67
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
68
|
+
Event: _TelemetryConstants.TelemetryEvent.PostChatSurveyUrlValidationCompleted,
|
|
69
|
+
Description: `${controlProps.surveyURL} is a valid Survey URL`
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
57
73
|
|
|
58
74
|
// Move focus to the first button
|
|
59
75
|
(0, _react.useEffect)(() => {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _utils = require("../../../common/utils");
|
|
8
|
+
const validRootDomains = ["microsoft.com", "microsoft.us", "appsplatform.us", "powervirtualagents.cn"];
|
|
9
|
+
const isValidSurveyUrl = url => {
|
|
10
|
+
if ((0, _utils.isNullOrEmptyString)(url)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const objectUrl = new URL(url);
|
|
15
|
+
if (!objectUrl.origin || objectUrl.origin === "null") {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const validDomain = validRootDomains.find(domain => objectUrl.origin.endsWith(domain));
|
|
19
|
+
if (validDomain) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
var _default = isValidSurveyUrl;
|
|
28
|
+
exports.default = _default;
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WebChatContainerStateful = void 0;
|
|
7
|
+
var _Constants = require("../../common/Constants");
|
|
7
8
|
var _react = require("@fluentui/react");
|
|
8
9
|
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
9
10
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _utils = require("../../common/utils");
|
|
11
12
|
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
12
13
|
var _botframeworkWebchat = require("botframework-webchat");
|
|
13
|
-
var _Constants = require("../../common/Constants");
|
|
14
14
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
15
15
|
var _NotificationHandler = require("./webchatcontroller/notification/NotificationHandler");
|
|
16
16
|
var _NotificationScenarios = require("./webchatcontroller/enums/NotificationScenarios");
|
|
@@ -56,7 +56,7 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
const WebChatContainerStateful = props => {
|
|
59
|
-
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _props$webChatContain9, _props$webChatContain10;
|
|
59
|
+
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _props$webChatContain9, _props$webChatContain10;
|
|
60
60
|
(0, _react2.useEffect)(() => {
|
|
61
61
|
uiTimer = (0, _utils.createTimer)();
|
|
62
62
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -241,8 +241,9 @@ const WebChatContainerStateful = props => {
|
|
|
241
241
|
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp14 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp14 === void 0 ? void 0 : (_webChatContainerProp15 = _webChatContainerProp14.sentMessageAnchorStyles) === null || _webChatContainerProp15 === void 0 ? void 0 : _webChatContainerProp15.color) ?? (_defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === null || _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === void 0 ? void 0 : _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles.color)};
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
// we had a nasty bug long time ago with crashing borders messing with the sendbox, so if customer adds this value, they need to deal with that
|
|
244
245
|
.webchat__bubble:not(.webchat__bubble--from-user) .webchat__bubble__content {
|
|
245
|
-
border-radius: 0 !important; /* Override border-radius */
|
|
246
|
+
border-radius: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp16 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp16 === void 0 ? void 0 : _webChatContainerProp16.bubbleBorderRadius) ?? 0} !important; /* Override border-radius */
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
.webchat__stacked-layout_container>div {
|
|
@@ -13,75 +13,98 @@ var _attachmentActivityUtils = require("./utils/attachmentActivityUtils");
|
|
|
13
13
|
var _MockBotCommand = _interopRequireDefault(require("./MockBotCommand"));
|
|
14
14
|
var _MockBotCardCommandType = _interopRequireDefault(require("./MockBotCardCommandType"));
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
class
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
21
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
24
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
25
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
let DemoChatAdapter = /*#__PURE__*/function (_MockAdapter) {
|
|
29
|
+
_inherits(DemoChatAdapter, _MockAdapter);
|
|
30
|
+
var _super = _createSuper(DemoChatAdapter);
|
|
31
|
+
function DemoChatAdapter() {
|
|
32
|
+
var _this;
|
|
33
|
+
_classCallCheck(this, DemoChatAdapter);
|
|
34
|
+
_this = _super.call(this);
|
|
19
35
|
setTimeout(() => {
|
|
20
|
-
(0, _chatAdapterUtils.postSystemMessageActivity)(
|
|
21
|
-
(0, _chatAdapterUtils.postBotMessageActivity)(
|
|
36
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(_this.activityObserver, "You're currently using a demo.", 0);
|
|
37
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Type `/help` to learn more", undefined, 0); // send init message from bot
|
|
22
38
|
}, 1000);
|
|
39
|
+
return _this;
|
|
23
40
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
41
|
+
_createClass(DemoChatAdapter, [{
|
|
42
|
+
key: "postBotCommandsActivity",
|
|
43
|
+
value: function postBotCommandsActivity() {
|
|
44
|
+
let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
45
|
+
(0, _chatAdapterUtils.postBotAttachmentActivity)(this.activityObserver, [{
|
|
46
|
+
contentType: "application/vnd.microsoft.card.thumbnail",
|
|
47
|
+
content: {
|
|
48
|
+
buttons: [{
|
|
49
|
+
title: "Send system message",
|
|
50
|
+
type: "imBack",
|
|
51
|
+
value: "send system message"
|
|
52
|
+
}, {
|
|
53
|
+
title: "Send typing",
|
|
54
|
+
type: "imBack",
|
|
55
|
+
value: "send typing"
|
|
56
|
+
}, {
|
|
57
|
+
title: "Send bot message",
|
|
58
|
+
type: "imBack",
|
|
59
|
+
value: "send bot message"
|
|
60
|
+
}],
|
|
61
|
+
title: "Commands"
|
|
62
|
+
}
|
|
63
|
+
}], delay);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "postActivity",
|
|
67
|
+
value: function postActivity(activity) {
|
|
68
|
+
if (activity) {
|
|
69
|
+
(0, _chatAdapterUtils.postEchoActivity)(this.activityObserver, activity, _chatAdapterUtils.customerUser);
|
|
70
|
+
if (activity.text) {
|
|
71
|
+
switch (true) {
|
|
72
|
+
case activity.text === _MockBotCommand.default.Help:
|
|
73
|
+
this.postBotCommandsActivity();
|
|
74
|
+
break;
|
|
75
|
+
case activity.text === _MockBotCommand.default.SendSystemMessage:
|
|
76
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(this.activityObserver, "Contoso has joined the chat.");
|
|
77
|
+
break;
|
|
78
|
+
case activity.text === _MockBotCommand.default.SendTyping:
|
|
79
|
+
(0, _chatAdapterUtils.postBotTypingActivity)(this.activityObserver);
|
|
80
|
+
break;
|
|
81
|
+
case activity.text === _MockBotCommand.default.SendAttachment:
|
|
82
|
+
(0, _chatAdapterUtils.postBotAttachmentActivity)(this.activityObserver, [(0, _attachmentActivityUtils.createJpgFileAttachment)()]);
|
|
83
|
+
break;
|
|
84
|
+
case activity.text === _MockBotCommand.default.SendBotMessage:
|
|
85
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(this.activityObserver, "Hi, how can I help you?");
|
|
86
|
+
break;
|
|
87
|
+
case activity.text === `${_MockBotCommand.default.Card} ${_MockBotCardCommandType.default.Signin}`:
|
|
88
|
+
(0, _chatAdapterUtils.postBotAttachmentActivity)(this.activityObserver, [(0, _attachmentActivityUtils.createSigninCardAttachment)()]);
|
|
89
|
+
break;
|
|
90
|
+
case activity.text === `${_MockBotCommand.default.Card} ${_MockBotCardCommandType.default.Hero}`:
|
|
91
|
+
(0, _chatAdapterUtils.postBotAttachmentActivity)(this.activityObserver, [(0, _attachmentActivityUtils.createHeroCardAttachment)()]);
|
|
92
|
+
break;
|
|
93
|
+
case activity.text === `${_MockBotCommand.default.Card} ${_MockBotCardCommandType.default.Thumbnail}`:
|
|
94
|
+
(0, _chatAdapterUtils.postBotAttachmentActivity)(this.activityObserver, [(0, _attachmentActivityUtils.createThumbnailCardAttachment)()]);
|
|
95
|
+
break;
|
|
96
|
+
case activity.text.startsWith(`${_MockBotCommand.default.Bot} `):
|
|
97
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(this.activityObserver, activity.text.substring(5));
|
|
98
|
+
break;
|
|
99
|
+
case activity.text.startsWith(`${_MockBotCommand.default.System} `):
|
|
100
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(this.activityObserver, activity.text.substring(8));
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
81
103
|
}
|
|
82
104
|
}
|
|
105
|
+
return _Observable.Observable.of(activity.id || "");
|
|
83
106
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
107
|
+
}]);
|
|
108
|
+
return DemoChatAdapter;
|
|
109
|
+
}(_mockadapter.default);
|
|
87
110
|
exports.DemoChatAdapter = DemoChatAdapter;
|
|
@@ -6,12 +6,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DemoChatSDK = void 0;
|
|
7
7
|
var _DemoChatAdapter = require("./DemoChatAdapter");
|
|
8
8
|
var _mockchatsdk = require("./mockchatsdk");
|
|
9
|
-
class
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
17
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
let DemoChatSDK = /*#__PURE__*/function (_MockChatSDK) {
|
|
22
|
+
_inherits(DemoChatSDK, _MockChatSDK);
|
|
23
|
+
var _super = _createSuper(DemoChatSDK);
|
|
24
|
+
function DemoChatSDK() {
|
|
25
|
+
_classCallCheck(this, DemoChatSDK);
|
|
26
|
+
return _super.call(this);
|
|
12
27
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
_createClass(DemoChatSDK, [{
|
|
29
|
+
key: "createChatAdapter",
|
|
30
|
+
value: function createChatAdapter() {
|
|
31
|
+
return new _DemoChatAdapter.DemoChatAdapter();
|
|
32
|
+
}
|
|
33
|
+
}]);
|
|
34
|
+
return DemoChatSDK;
|
|
35
|
+
}(_mockchatsdk.MockChatSDK);
|
|
17
36
|
exports.DemoChatSDK = DemoChatSDK;
|
|
@@ -8,34 +8,57 @@ var _Observable = require("rxjs/Observable");
|
|
|
8
8
|
var _mockadapter = _interopRequireDefault(require("./mockadapter"));
|
|
9
9
|
var _chatAdapterUtils = require("./utils/chatAdapterUtils");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
class
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
20
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
+
let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
|
|
24
|
+
_inherits(DesignerChatAdapter, _MockAdapter);
|
|
25
|
+
var _super = _createSuper(DesignerChatAdapter);
|
|
26
|
+
function DesignerChatAdapter() {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, DesignerChatAdapter);
|
|
29
|
+
_this = _super.call(this);
|
|
14
30
|
setTimeout(() => {
|
|
15
|
-
(0, _chatAdapterUtils.postBotMessageActivity)(
|
|
16
|
-
|
|
17
|
-
(0, _chatAdapterUtils.postBotMessageActivity)(
|
|
18
|
-
(0, _chatAdapterUtils.postSystemMessageActivity)(
|
|
19
|
-
(0, _chatAdapterUtils.postBotMessageActivity)(
|
|
31
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
|
|
32
|
+
_this.postUserActivity("I need to change my address.", 0);
|
|
33
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
|
|
34
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(_this.activityObserver, "John has joined the chat", 100);
|
|
35
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
|
|
20
36
|
}, 1000);
|
|
37
|
+
return _this;
|
|
21
38
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (activity) {
|
|
36
|
-
(0, _chatAdapterUtils.postEchoActivity)(this.activityObserver, activity, _chatAdapterUtils.customerUser);
|
|
39
|
+
_createClass(DesignerChatAdapter, [{
|
|
40
|
+
key: "postUserActivity",
|
|
41
|
+
value: function postUserActivity(text) {
|
|
42
|
+
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
(0, _chatAdapterUtils.postEchoActivity)(this.activityObserver, {
|
|
45
|
+
text,
|
|
46
|
+
from: {
|
|
47
|
+
..._chatAdapterUtils.customerUser
|
|
48
|
+
},
|
|
49
|
+
type: "message"
|
|
50
|
+
}, _chatAdapterUtils.customerUser, 0);
|
|
51
|
+
}, delay);
|
|
37
52
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
}, {
|
|
54
|
+
key: "postActivity",
|
|
55
|
+
value: function postActivity(activity) {
|
|
56
|
+
if (activity) {
|
|
57
|
+
(0, _chatAdapterUtils.postEchoActivity)(this.activityObserver, activity, _chatAdapterUtils.customerUser);
|
|
58
|
+
}
|
|
59
|
+
return _Observable.Observable.of(activity.id || "");
|
|
60
|
+
}
|
|
61
|
+
}]);
|
|
62
|
+
return DesignerChatAdapter;
|
|
63
|
+
}(_mockadapter.default);
|
|
41
64
|
exports.DesignerChatAdapter = DesignerChatAdapter;
|