@microsoft/omnichannel-chat-widget 0.1.0-main.eb80fb1 → 0.1.0-main.ebfc563
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 +35 -11
- package/lib/cjs/assets/Icons.js +4 -2
- package/lib/cjs/common/Constants.js +54 -153
- package/lib/cjs/common/KeyCodes.js +3 -4
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -5
- package/lib/cjs/common/storage/default/defaultCacheManager.js +26 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +111 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +78 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +85 -24
- package/lib/cjs/common/telemetry/TelemetryHelper.js +31 -56
- package/lib/cjs/common/telemetry/TelemetryManager.js +17 -35
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -3
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +49 -35
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -14
- package/lib/cjs/common/utils.js +80 -80
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +21 -45
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -26
- package/lib/cjs/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +13 -71
- package/lib/cjs/components/dimlayer/DimLayer.js +0 -4
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -37
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -8
- package/lib/cjs/components/footerstateful/FooterStateful.js +12 -44
- package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +0 -6
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -44
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -8
- package/lib/cjs/components/headerstateful/HeaderStateful.js +26 -35
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +2 -14
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +20 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +34 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +64 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +37 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +10 -9
- package/lib/cjs/components/livechatwidget/common/createFooter.js +4 -23
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -10
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +36 -44
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +14 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +132 -61
- package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
- package/lib/cjs/components/livechatwidget/common/endChat.js +167 -61
- package/lib/cjs/components/livechatwidget/common/getGeneralStylesForButton.js +0 -6
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +8 -17
- package/lib/cjs/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -8
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +50 -52
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +98 -66
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +9 -33
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -15
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +287 -90
- package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +0 -8
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -11
- package/lib/cjs/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +354 -170
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +19 -19
- package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +4 -17
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +9 -14
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -23
- package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +13 -0
- package/lib/cjs/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
- package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -45
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +21 -35
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +6 -24
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -19
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -7
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -6
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +12 -27
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +9 -16
- package/lib/cjs/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -24
- package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -15
- package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -8
- 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 +12 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -5
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +0 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -5
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +33 -80
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +10 -22
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -61
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +7 -15
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +82 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -9
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +89 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +7 -18
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +8 -42
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +4 -22
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +13 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -34
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +7 -18
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -19
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +1 -9
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -9
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -34
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +1 -10
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +7 -11
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +5 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -21
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +33 -0
- package/lib/cjs/contexts/ChatAdapterStore.js +0 -2
- package/lib/cjs/contexts/ChatContextStore.js +0 -2
- package/lib/cjs/contexts/ChatSDKStore.js +0 -2
- package/lib/cjs/contexts/common/ConversationState.js +4 -3
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +30 -26
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +18 -11
- package/lib/cjs/contexts/createReducer.js +169 -109
- package/lib/cjs/controller/componentController.js +5 -34
- package/lib/cjs/hooks/useChatAdapterStore.js +0 -6
- package/lib/cjs/hooks/useChatContextStore.js +0 -6
- package/lib/cjs/hooks/useChatSDKStore.js +0 -6
- package/lib/cjs/index.js +0 -5
- package/lib/cjs/plugins/newMessageEventHandler.js +82 -0
- package/lib/esm/assets/Icons.js +2 -1
- package/lib/esm/common/Constants.js +49 -141
- package/lib/esm/common/KeyCodes.js +3 -3
- package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -3
- package/lib/esm/common/storage/default/defaultCacheManager.js +18 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +104 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +70 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +84 -19
- package/lib/esm/common/telemetry/TelemetryHelper.js +32 -46
- package/lib/esm/common/telemetry/TelemetryManager.js +17 -24
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +49 -23
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -10
- package/lib/esm/common/utils.js +73 -45
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +21 -16
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +23 -13
- package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +14 -47
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -16
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +14 -25
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -37
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
- package/lib/esm/components/headerstateful/HeaderStateful.js +27 -21
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -2
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +13 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +27 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +57 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +30 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -4
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -16
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -5
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +38 -37
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +7 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +134 -49
- package/lib/esm/components/livechatwidget/common/endChat.js +171 -50
- package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +10 -12
- package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +52 -24
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +98 -58
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +9 -23
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -6
- package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +287 -71
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +4 -2
- package/lib/esm/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +357 -122
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +19 -7
- package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +4 -5
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +9 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -11
- package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +6 -0
- package/lib/esm/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
- package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +16 -30
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +24 -12
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -4
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +12 -19
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +9 -12
- package/lib/esm/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -16
- package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -5
- package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -6
- 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/WebChatStoreLoader.js +3 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +2 -5
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +34 -66
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -40
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +9 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +34 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +80 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +83 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +8 -9
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +9 -28
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +5 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +15 -19
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -29
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +9 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +3 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +15 -27
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +3 -5
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +9 -9
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +7 -9
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -13
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +27 -0
- package/lib/esm/contexts/ChatAdapterStore.js +2 -1
- package/lib/esm/contexts/ChatContextStore.js +2 -1
- package/lib/esm/contexts/ChatSDKStore.js +2 -1
- package/lib/esm/contexts/common/ConversationState.js +4 -3
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +30 -26
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -7
- package/lib/esm/contexts/createReducer.js +169 -105
- package/lib/esm/controller/componentController.js +6 -5
- package/lib/esm/hooks/useChatAdapterStore.js +0 -4
- package/lib/esm/hooks/useChatContextStore.js +0 -4
- package/lib/esm/hooks/useChatSDKStore.js +0 -4
- package/lib/esm/plugins/newMessageEventHandler.js +75 -0
- package/lib/types/assets/Icons.d.ts +1 -0
- package/lib/types/common/Constants.d.ts +41 -2
- package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +59 -6
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +4 -4
- package/lib/types/common/telemetry/definitions/Payload.d.ts +13 -9
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +7 -3
- package/lib/types/common/utils.d.ts +8 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +5 -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 +5 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultScrollBarProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +4 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +6 -3
- package/lib/types/components/livechatwidget/interfaces/IScrollBarProps.d.ts +22 -0
- package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
- package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
- package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +5 -0
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -2
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -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/IRenderingMiddlewareProps.d.ts +4 -1
- 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/activityMiddleware.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- 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/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/ConversationState.d.ts +4 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -3
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +30 -25
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +12 -13
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -3,27 +3,21 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
3
3
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
5
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
6
|
-
|
|
7
6
|
const processDisplayName = displayName => {
|
|
8
7
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
9
8
|
const displayNameRegex = ".+:.+";
|
|
10
9
|
const matchedTeamsDisplayName = displayName.match(displayNameRegex);
|
|
11
|
-
|
|
12
10
|
if (displayName.indexOf("teamsvisitor") >= 0 && matchedTeamsDisplayName && matchedTeamsDisplayName.length > 0) {
|
|
13
11
|
displayName = "Customer";
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
return displayName;
|
|
17
14
|
};
|
|
18
|
-
|
|
19
15
|
const constructIconName = displayName => {
|
|
20
16
|
if (!displayName) {
|
|
21
17
|
return "";
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
let iconName = "C";
|
|
25
20
|
const displayNameSplit = displayName.split(" ");
|
|
26
|
-
|
|
27
21
|
if (displayNameSplit.length > 1) {
|
|
28
22
|
// get the first letter of name and surname
|
|
29
23
|
iconName = displayNameSplit[0][0] + displayNameSplit[1][0];
|
|
@@ -31,55 +25,42 @@ const constructIconName = displayName => {
|
|
|
31
25
|
// get the first letter of name
|
|
32
26
|
iconName = displayNameSplit[0][0];
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
return iconName;
|
|
36
29
|
};
|
|
37
|
-
|
|
38
30
|
const processCreatedDateTime = (createdDateTime, chatCount) => {
|
|
39
|
-
const formattedDate = new Date(createdDateTime);
|
|
40
|
-
|
|
41
|
-
const formattedTimeString = formattedDate.toLocaleTimeString("en-us"
|
|
42
|
-
/* Bootstrapper.LiveChatConfiguration.chatWidgetLocale */
|
|
43
|
-
, {
|
|
31
|
+
const formattedDate = new Date(createdDateTime);
|
|
32
|
+
// TODO: Localization:
|
|
33
|
+
const formattedTimeString = formattedDate.toLocaleTimeString("en-us" /* Bootstrapper.LiveChatConfiguration.chatWidgetLocale */, {
|
|
44
34
|
hour: "2-digit",
|
|
45
35
|
minute: "2-digit"
|
|
46
36
|
});
|
|
47
37
|
const formattedSplitTimeString = formattedTimeString.split(" ");
|
|
48
38
|
let finalizedTimeString = "";
|
|
49
|
-
|
|
50
39
|
if (formattedSplitTimeString && formattedSplitTimeString.length > 1) {
|
|
51
40
|
finalizedTimeString = formattedSplitTimeString[0] + " " + formattedSplitTimeString[1];
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
if (chatCount == 0) {
|
|
55
43
|
return formattedDate.toLocaleDateString("en-us") + " " + finalizedTimeString;
|
|
56
44
|
}
|
|
57
|
-
|
|
58
45
|
return finalizedTimeString;
|
|
59
46
|
};
|
|
60
|
-
|
|
61
47
|
const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
62
48
|
if (transcriptContent.toString().toLowerCase().indexOf(TranscriptConstants.TranscriptMessageEmojiMessageType) >= 0) {
|
|
63
49
|
// eslint-disable-next-line no-useless-escape
|
|
64
50
|
const emojiRegex = "<img src=\"http.*:\/\/.+\/objects\/.+\/views.+\">";
|
|
65
51
|
const matchedEmojiImgTag = transcriptContent.match(emojiRegex);
|
|
66
|
-
|
|
67
52
|
if (matchedEmojiImgTag && matchedEmojiImgTag.length > 0 && transcriptContent.toString().toLowerCase().indexOf(matchedEmojiImgTag[0]) >= 0) {
|
|
68
53
|
transcriptContent = transcriptContent.replace(matchedEmojiImgTag[0], "");
|
|
69
54
|
}
|
|
70
55
|
}
|
|
71
|
-
|
|
72
56
|
if (!isAgentChat && transcriptContent.toString().toLowerCase().indexOf("a href") >= 0 && transcriptContent.toString().toLowerCase().indexOf("target") >= 0) {
|
|
73
57
|
transcriptContent = transcriptContent.slice(0, transcriptContent.toString().indexOf("target")) + " style='color:white' " + transcriptContent.slice(transcriptContent.toString().indexOf("target"));
|
|
74
58
|
}
|
|
75
|
-
|
|
76
59
|
if (renderMarkDown) {
|
|
77
60
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
78
61
|
}
|
|
79
|
-
|
|
80
62
|
return transcriptContent;
|
|
81
63
|
};
|
|
82
|
-
|
|
83
64
|
const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMessage) => {
|
|
84
65
|
const chats = JSON.parse(chatTranscripts).reverse();
|
|
85
66
|
const docTypeTag = "<!DOCTYPE html>";
|
|
@@ -94,8 +75,9 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
94
75
|
let tabIndex = 1;
|
|
95
76
|
const mainTranscriptSection = "<div class='allTranscripts' style='max-width:60%;min-width:30%;margin-left:20%;background-color:#FFFFFF;'>";
|
|
96
77
|
let previousDisplayName = "";
|
|
97
|
-
let chatCount = 0;
|
|
78
|
+
let chatCount = 0;
|
|
98
79
|
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
81
|
chats.forEach(value => {
|
|
100
82
|
let dialogNameMarginTop = "6px";
|
|
101
83
|
let dialogboxMarginleft = "40px";
|
|
@@ -105,8 +87,13 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
105
87
|
let fileAttachmentName = TranscriptConstants.DefaultFileAttachmentName;
|
|
106
88
|
let dialogColor = TranscriptConstants.CustomerDialogColor;
|
|
107
89
|
let fontColor = TranscriptConstants.CustomerFontColor;
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1;
|
|
91
|
+
const isControlMessage = value.isControlMessage && value.isControlMessage === true;
|
|
92
|
+
const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType;
|
|
93
|
+
const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode;
|
|
94
|
+
const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.hiddenTag.toLowerCase()) !== -1;
|
|
95
|
+
const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
|
|
96
|
+
if (shouldIgnoreMessage) {
|
|
110
97
|
return;
|
|
111
98
|
} else if (value.from) {
|
|
112
99
|
if (value.from.application) {
|
|
@@ -121,19 +108,15 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
121
108
|
displayName = value.from.user.displayName;
|
|
122
109
|
dialogColor = TranscriptConstants.CustomerDialogColor;
|
|
123
110
|
}
|
|
124
|
-
|
|
125
111
|
displayName = processDisplayName(displayName);
|
|
126
112
|
iconName = constructIconName(displayName);
|
|
127
|
-
|
|
128
113
|
if (value.attachments && value.attachments.length > 0 && value.attachments[0].name) {
|
|
129
114
|
fileAttachmentName = value.attachments[0].name;
|
|
130
|
-
value.content = attachmentMessage
|
|
115
|
+
value.content = attachmentMessage ? attachmentMessage + " " + fileAttachmentName : "The following attachment was uploaded during the conversation: " + fileAttachmentName;
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
|
-
|
|
134
118
|
let displayNamePlaceholder = processCreatedDateTime(value.createdDateTime, chatCount);
|
|
135
119
|
let iconPara = "";
|
|
136
|
-
|
|
137
120
|
if (displayName !== previousDisplayName) {
|
|
138
121
|
dialogboxMarginleft = "0px";
|
|
139
122
|
displayNamePlaceholder = "<b>" + displayName + " </b> " + processCreatedDateTime(value.createdDateTime, chatCount);
|
|
@@ -144,17 +127,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
144
127
|
</div>";
|
|
145
128
|
tabIndex++;
|
|
146
129
|
}
|
|
147
|
-
|
|
148
130
|
if (displayName !== previousDisplayName) {
|
|
149
131
|
if (previousDisplayName === "") {
|
|
150
132
|
dialogNameMarginTop = "0px";
|
|
151
133
|
}
|
|
152
|
-
|
|
153
134
|
if (previousDisplayName !== "") {
|
|
154
135
|
dialogNameMarginTop = "20px";
|
|
155
136
|
}
|
|
156
137
|
}
|
|
157
|
-
|
|
158
138
|
const displayNameDiv = "<div style='margin-right:-2px;margin-top:" + dialogNameMarginTop + ";margin-bottom:-2px;margin-left:42px;top:-2px;position:relative;'>\
|
|
159
139
|
<font tabindex ='" + tabIndex + "' size = '1px' color='#000000' style='font-family:Segoe UI,SegoeUI,Helvetica Neue,Helvetica,Arial,sans-serif;font-weight:500;'>\
|
|
160
140
|
" + displayNamePlaceholder + "\
|
|
@@ -168,16 +148,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
168
148
|
});
|
|
169
149
|
const str = docTypeTag + docStartTag + docMetaTag + bodyStartTag + mainTranscriptSection + beautifiedChats + divEndTag + bodyEndTag + docEndTag;
|
|
170
150
|
return str;
|
|
171
|
-
};
|
|
172
|
-
|
|
151
|
+
};
|
|
173
152
|
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
154
|
export const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage) => {
|
|
175
155
|
let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript());
|
|
176
|
-
|
|
177
156
|
if (typeof data === Constants.String) {
|
|
178
157
|
data = JSON.parse(data);
|
|
179
158
|
}
|
|
180
|
-
|
|
181
159
|
if (data[Constants.ChatMessagesJson] !== null && data[Constants.ChatMessagesJson] !== undefined) {
|
|
182
160
|
const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
|
|
183
161
|
const byteCharacters = decodeURIComponent(window.atob(chatTranscripts));
|
|
@@ -14,10 +14,10 @@ describe("DownloadTranscriptStateful unit test", () => {
|
|
|
14
14
|
};
|
|
15
15
|
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
16
16
|
jest.spyOn(chatSDK, "getLiveChatTranscript").mockResolvedValue(Promise.resolve());
|
|
17
|
-
|
|
18
17
|
try {
|
|
19
18
|
await chatSDK.getLiveChatTranscript();
|
|
20
|
-
expect(chatSDK.getLiveChatTranscript).toHaveBeenCalledTimes(1);
|
|
19
|
+
expect(chatSDK.getLiveChatTranscript).toHaveBeenCalledTimes(1);
|
|
20
|
+
// eslint-disable-next-line no-empty
|
|
21
21
|
} catch (ex) {}
|
|
22
22
|
});
|
|
23
23
|
it("Method getLiveChatTranscript throws exception", async () => {
|
|
@@ -29,9 +29,9 @@ describe("DownloadTranscriptStateful unit test", () => {
|
|
|
29
29
|
};
|
|
30
30
|
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
31
31
|
jest.spyOn(chatSDK, "getLiveChatTranscript").mockRejectedValue(new Error(errorMessage));
|
|
32
|
-
|
|
33
32
|
try {
|
|
34
|
-
await chatSDK.getLiveChatTranscript();
|
|
33
|
+
await chatSDK.getLiveChatTranscript();
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
35
|
} catch (ex) {
|
|
36
36
|
expect(ex.message).toEqual(errorMessage);
|
|
37
37
|
}
|
|
@@ -44,9 +44,9 @@ describe("DownloadTranscriptStateful unit test", () => {
|
|
|
44
44
|
widgetId: ""
|
|
45
45
|
};
|
|
46
46
|
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
47
|
-
|
|
48
47
|
try {
|
|
49
|
-
await chatSDK.getLiveChatTranscript();
|
|
48
|
+
await chatSDK.getLiveChatTranscript();
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
50
|
} catch (ex) {
|
|
51
51
|
expect(ex.message).toEqual(errorMessage);
|
|
52
52
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
4
4
|
import { Header } from "@microsoft/omnichannel-chat-components";
|
|
5
5
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -9,18 +9,19 @@ import useChatAdapterStore from "../../hooks/useChatAdapterStore";
|
|
|
9
9
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
10
10
|
export const HeaderStateful = props => {
|
|
11
11
|
var _state$domainStates$l, _state$domainStates$l2, _headerProps$controlP, _headerProps$controlP2, _headerProps$controlP3, _outOfOfficeHeaderPro;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const [state, dispatch] = useChatContextStore();
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
14
|
const [adapter] = useChatAdapterStore();
|
|
16
15
|
const {
|
|
17
16
|
headerProps,
|
|
18
17
|
outOfOfficeHeaderProps,
|
|
19
18
|
endChat
|
|
20
|
-
} = props;
|
|
21
|
-
|
|
19
|
+
} = props;
|
|
20
|
+
//Setting OutOfOperatingHours Flag
|
|
22
21
|
const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
|
|
23
22
|
const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
|
|
23
|
+
const conversationState = useRef(state.appStates.conversationState);
|
|
24
|
+
const conversationEndedByAgent = useRef(state.appStates.conversationEndedByAgent);
|
|
24
25
|
const controlProps = {
|
|
25
26
|
id: "oc-lcw-header",
|
|
26
27
|
dir: state.domainStates.globalDir,
|
|
@@ -35,33 +36,34 @@ export const HeaderStateful = props => {
|
|
|
35
36
|
});
|
|
36
37
|
},
|
|
37
38
|
onCloseClick: async () => {
|
|
39
|
+
var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
|
|
38
40
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
39
41
|
Event: TelemetryEvent.HeaderCloseButtonClicked,
|
|
40
42
|
Description: "Header Close button clicked."
|
|
41
43
|
});
|
|
42
|
-
|
|
43
|
-
if (state.appStates.conversationState === ConversationState.Active) {
|
|
44
|
+
if (conversationState.current === ConversationState.Active || conversationEndedByAgent.current) {
|
|
44
45
|
dispatch({
|
|
45
46
|
type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
46
47
|
payload: true
|
|
47
48
|
});
|
|
48
|
-
} else
|
|
49
|
+
} else {
|
|
50
|
+
const skipEndChatSDK = true;
|
|
51
|
+
const skipCloseChat = false;
|
|
52
|
+
const postMessageToOtherTabs = true;
|
|
53
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
54
|
+
}
|
|
55
|
+
const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
|
|
56
|
+
if (closeButtonId) {
|
|
49
57
|
dispatch({
|
|
50
|
-
type: LiveChatWidgetActionType.
|
|
51
|
-
payload:
|
|
58
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
59
|
+
payload: closeButtonId
|
|
52
60
|
});
|
|
53
|
-
await endChat(adapter);
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
dispatch({
|
|
57
|
-
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT,
|
|
58
|
-
payload: document.getElementById(`${controlProps.id}-closebutton`)
|
|
59
|
-
});
|
|
60
62
|
},
|
|
61
63
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
62
|
-
hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
63
|
-
hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
64
|
-
hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
64
|
+
hideTitle: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
65
|
+
hideIcon: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
66
|
+
hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
65
67
|
};
|
|
66
68
|
const outOfOfficeControlProps = {
|
|
67
69
|
id: "oc-lcw-header",
|
|
@@ -82,7 +84,11 @@ export const HeaderStateful = props => {
|
|
|
82
84
|
if (state.appStates.outsideOperatingHours) {
|
|
83
85
|
setOutOfOperatingHours(true);
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
if (state.appStates.conversationState) {
|
|
88
|
+
conversationState.current = state.appStates.conversationState;
|
|
89
|
+
}
|
|
90
|
+
conversationEndedByAgent.current = state.appStates.conversationEndedByAgent;
|
|
91
|
+
}, [state.appStates]);
|
|
86
92
|
return /*#__PURE__*/React.createElement(Header, {
|
|
87
93
|
componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
|
|
88
94
|
controlProps: outOfOperatingHours || state.appStates.conversationState === ConversationState.OutOfOffice ? outOfOfficeControlProps : controlProps,
|
|
@@ -7,8 +7,8 @@ import { createReducer } from "../../contexts/createReducer";
|
|
|
7
7
|
import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
|
|
8
8
|
export const LiveChatWidget = props => {
|
|
9
9
|
const reducer = createReducer();
|
|
10
|
-
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
11
|
-
|
|
10
|
+
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
const [adapter, setAdapter] = useState(undefined);
|
|
13
13
|
return /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
|
|
14
14
|
value: props.chatSDK
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { Deferred } from "./Deferred";
|
|
5
|
+
export class ActivityStreamHandler {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Use of a deferred pattern, to hold the execution of the activity.
|
|
12
|
+
*
|
|
13
|
+
* */
|
|
14
|
+
static cork() {
|
|
15
|
+
ActivityStreamHandler.restoreDeferred = new Deferred();
|
|
16
|
+
ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the promise, releasing it to continue with the execution of the activity.
|
|
21
|
+
*
|
|
22
|
+
* */
|
|
23
|
+
static uncork() {
|
|
24
|
+
ActivityStreamHandler.restoreDeferred.resolve();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
_defineProperty(ActivityStreamHandler, "restoreDeferred", {
|
|
28
|
+
resolve: () => {
|
|
29
|
+
return "initialState";
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(ActivityStreamHandler, "restorePromise", void 0);
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
export class DefaultActivitySubscriber {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "observer", void 0);
|
|
7
|
+
}
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
async next(activity) {
|
|
10
|
+
this.observer.next(activity);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { ActivityStreamHandler } from "../ActivityStreamHandler";
|
|
5
|
+
export class PauseActivitySubscriber {
|
|
6
|
+
constructor() {
|
|
7
|
+
_defineProperty(this, "observer", void 0);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
async apply(activity) {
|
|
11
|
+
await ActivityStreamHandler.restorePromise;
|
|
12
|
+
return activity;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
16
|
+
applicable(activity) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
async next(activity) {
|
|
22
|
+
if (this.applicable(activity)) {
|
|
23
|
+
return await this.apply(activity);
|
|
24
|
+
}
|
|
25
|
+
return activity;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { DefaultActivitySubscriber } from "./ActivitySubscriber/DefaultActivitySubscriber";
|
|
5
|
+
import { shareObservable } from "./shareObservable";
|
|
6
|
+
export class ChatAdapterShim {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
constructor(chatAdapter) {
|
|
15
|
+
_defineProperty(this, "chatAdapter", void 0);
|
|
16
|
+
_defineProperty(this, "activityObserver", void 0);
|
|
17
|
+
_defineProperty(this, "subscribers", void 0);
|
|
18
|
+
this.subscribers = [];
|
|
19
|
+
this.chatAdapter = {
|
|
20
|
+
...chatAdapter,
|
|
21
|
+
activity$: shareObservable(
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
new window.Observable(observer => {
|
|
24
|
+
this.activityObserver = observer;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
const abortController = new window.AbortController();
|
|
27
|
+
(async () => {
|
|
28
|
+
try {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
for await (let activity of chatAdapter.activities({
|
|
31
|
+
signal: abortController.signal
|
|
32
|
+
})) {
|
|
33
|
+
for (const subscriber of [...this.subscribers, new DefaultActivitySubscriber()]) {
|
|
34
|
+
subscriber.observer = this.activityObserver;
|
|
35
|
+
activity = await subscriber.next(activity);
|
|
36
|
+
if (!activity) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
observer.complete();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
observer.error(error);
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
return () => {
|
|
47
|
+
abortController.abort();
|
|
48
|
+
};
|
|
49
|
+
}))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
addSubscriber(subscriber) {
|
|
55
|
+
this.subscribers.push(subscriber);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
export class Deferred {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
_defineProperty(this, "_promise", void 0);
|
|
9
|
+
_defineProperty(this, "_resolve", void 0);
|
|
10
|
+
_defineProperty(this, "_reject", () => {
|
|
11
|
+
return;
|
|
12
|
+
});
|
|
13
|
+
_defineProperty(this, "resolve", value => {
|
|
14
|
+
this._resolve(value);
|
|
15
|
+
});
|
|
16
|
+
_defineProperty(this, "reject", value => {
|
|
17
|
+
this._reject(value);
|
|
18
|
+
});
|
|
19
|
+
this._promise = new Promise((resolve, reject) => {
|
|
20
|
+
this._resolve = resolve;
|
|
21
|
+
this._reject = reject;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
|
|
27
|
+
get promise() {
|
|
28
|
+
return this._promise;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
|
+
import { isNullOrEmptyString } from "../../../common/utils";
|
|
4
|
+
const getAuthClientFunction = chatConfig => {
|
|
5
|
+
let authClientFunction = undefined;
|
|
6
|
+
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
7
|
+
var _chatConfig$LiveChatC;
|
|
8
|
+
authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
|
|
9
|
+
}
|
|
10
|
+
return authClientFunction;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
15
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
16
|
+
if (getAuthToken && authClientFunction) {
|
|
17
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
18
|
+
Event: TelemetryEvent.GetAuthTokenCalled
|
|
19
|
+
});
|
|
20
|
+
const token = await getAuthToken(authClientFunction);
|
|
21
|
+
if (!isNullOrEmptyString(token)) {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
chatSDK.setAuthTokenProvider(async () => {
|
|
24
|
+
return token;
|
|
25
|
+
});
|
|
26
|
+
return true;
|
|
27
|
+
} else {
|
|
28
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
29
|
+
Event: TelemetryEvent.ReceivedNullOrEmptyToken
|
|
30
|
+
});
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
const removeAuthTokenProvider = chatSDK => {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
chatSDK.authenticatedUserToken = null;
|
|
41
|
+
};
|
|
42
|
+
export { getAuthClientFunction, handleAuthentication, removeAuthTokenProvider };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
2
2
|
import { NotificationLevel } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel";
|
|
3
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
4
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
+
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
|
+
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
|
|
5
7
|
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
9
|
export const createAdapter = async chatSDK => {
|
|
7
10
|
const chatAdapterOptionalParams = {
|
|
8
11
|
IC3Adapter: {
|
|
@@ -11,11 +14,9 @@ export const createAdapter = async chatSDK => {
|
|
|
11
14
|
if (notification.id === NotificationScenarios.InternetConnection && notification.level == NotificationLevel.Error) {
|
|
12
15
|
notification.message = defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
17
|
if (notification.id === NotificationScenarios.InternetConnection && notification.level == NotificationLevel.Success) {
|
|
16
18
|
notification.message = defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE;
|
|
17
19
|
}
|
|
18
|
-
|
|
19
20
|
if (notification.id && notification.message) {
|
|
20
21
|
NotificationHandler.notifyWithLevel(notification.id, notification.message, notification.level);
|
|
21
22
|
}
|
|
@@ -23,5 +24,12 @@ export const createAdapter = async chatSDK => {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
+
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
28
|
+
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
29
|
+
if (chatSDK.isMockModeOn !== true) {
|
|
30
|
+
adapter = new ChatAdapterShim(adapter);
|
|
31
|
+
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
32
|
+
return adapter.chatAdapter;
|
|
33
|
+
}
|
|
34
|
+
return adapter;
|
|
27
35
|
};
|
|
@@ -3,25 +3,13 @@ import React from "react";
|
|
|
3
3
|
import { decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { shouldShowFooter } from "../../../controller/componentController";
|
|
5
5
|
export const createFooter = (props, state) => {
|
|
6
|
-
var _props$
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
controlProps: { ...((_props$footerProps = props.footerProps) === null || _props$footerProps === void 0 ? void 0 : _props$footerProps.controlProps),
|
|
10
|
-
hideDownloadTranscriptButton: true,
|
|
11
|
-
hideEmailTranscriptButton: true,
|
|
12
|
-
hideAudioNotificationButton: true
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const footer = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && shouldShowFooter(state) ? decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
6
|
+
var _props$controlProps, _props$componentOverr;
|
|
7
|
+
const hideFooterDisplay = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && shouldShowFooter(state) ? false : true;
|
|
8
|
+
const footer = decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
16
9
|
footerProps: props.footerProps,
|
|
17
10
|
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
18
11
|
audioNotificationProps: props.audioNotificationProps,
|
|
19
|
-
hideFooterDisplay:
|
|
20
|
-
}) : decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
21
|
-
footerProps: footerPropsHidden,
|
|
22
|
-
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
23
|
-
audioNotificationProps: props.audioNotificationProps,
|
|
24
|
-
hideFooterDisplay: true
|
|
12
|
+
hideFooterDisplay: hideFooterDisplay
|
|
25
13
|
});
|
|
26
14
|
return footer;
|
|
27
15
|
};
|
|
@@ -2,7 +2,8 @@ import { Constants } from "../../../common/Constants";
|
|
|
2
2
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
3
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
4
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
-
|
|
5
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
6
7
|
const isInternetConnected = async () => {
|
|
7
8
|
try {
|
|
8
9
|
const response = await fetch(Constants.internetConnectionTestUrl);
|
|
@@ -12,19 +13,23 @@ const isInternetConnected = async () => {
|
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
15
|
};
|
|
15
|
-
|
|
16
16
|
export const createInternetConnectionChangeHandler = async () => {
|
|
17
17
|
const handler = async () => {
|
|
18
18
|
const connected = await isInternetConnected();
|
|
19
|
-
|
|
20
19
|
if (!connected) {
|
|
20
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
21
|
+
Event: TelemetryEvent.NetworkDisconnected
|
|
22
|
+
});
|
|
21
23
|
NotificationHandler.notifyError(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
22
24
|
} else {
|
|
25
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
26
|
+
Event: TelemetryEvent.NetworkReconnected
|
|
27
|
+
});
|
|
23
28
|
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
24
29
|
}
|
|
25
|
-
};
|
|
26
|
-
|
|
30
|
+
};
|
|
27
31
|
|
|
32
|
+
// Checking connection status on online & offline events due to possible false positives
|
|
28
33
|
window.addEventListener("online", () => handler(), false);
|
|
29
34
|
window.addEventListener("offline", () => handler(), false);
|
|
30
35
|
};
|