@microsoft/omnichannel-chat-widget 0.1.0-main.fb426ed → 1.0.0
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 +7 -2
- package/lib/cjs/assets/Icons.js +4 -2
- package/lib/cjs/common/Constants.js +40 -164
- 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 +84 -30
- package/lib/cjs/common/telemetry/TelemetryHelper.js +21 -59
- package/lib/cjs/common/telemetry/TelemetryManager.js +3 -32
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +0 -2
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +30 -36
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +0 -9
- package/lib/cjs/common/utils.js +92 -85
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +8 -46
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -25
- package/lib/cjs/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +18 -50
- 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 +11 -42
- package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +0 -6
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -43
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -8
- package/lib/cjs/components/headerstateful/HeaderStateful.js +21 -32
- 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/BotAuthActivitySubscriber.js +139 -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/agentEndConversationHelper.js +36 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +12 -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 -43
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +14 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +139 -51
- package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
- package/lib/cjs/components/livechatwidget/common/endChat.js +98 -57
- package/lib/cjs/components/livechatwidget/common/getGeneralStylesForButton.js +0 -6
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +7 -16
- package/lib/cjs/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -8
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +29 -88
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +79 -128
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +4 -17
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -14
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +257 -117
- 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 +368 -197
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +37 -25
- package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
- package/lib/cjs/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/cjs/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +4 -17
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -17
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +35 -24
- 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 +11 -42
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +19 -33
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +8 -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 +6 -17
- 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 +27 -37
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +10 -22
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -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 +20 -33
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +81 -45
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +1 -12
- 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 +0 -12
- 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/ConversationEndEntity.js +12 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -3
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +34 -26
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +20 -14
- package/lib/cjs/contexts/createReducer.js +200 -104
- package/lib/cjs/controller/componentController.js +4 -33
- 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/hooks/useDebounce.js +28 -0
- package/lib/cjs/hooks/useWindowDimensions.js +30 -0
- package/lib/cjs/index.js +0 -5
- package/lib/cjs/plugins/newMessageEventHandler.js +29 -36
- package/lib/esm/assets/Icons.js +2 -1
- package/lib/esm/common/Constants.js +36 -151
- 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 +88 -27
- package/lib/esm/common/telemetry/TelemetryHelper.js +21 -47
- package/lib/esm/common/telemetry/TelemetryManager.js +3 -19
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +28 -24
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +0 -5
- package/lib/esm/common/utils.js +84 -47
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +8 -17
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -12
- package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +20 -31
- 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 +13 -23
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -36
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
- package/lib/esm/components/headerstateful/HeaderStateful.js +21 -17
- 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/BotAuthActivitySubscriber.js +134 -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/agentEndConversationHelper.js +30 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -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 +140 -37
- package/lib/esm/components/livechatwidget/common/endChat.js +98 -43
- package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +9 -11
- package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +32 -57
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +80 -110
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -9
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +257 -8
- package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +256 -96
- 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 +372 -144
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +38 -13
- package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
- package/lib/esm/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/esm/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +4 -5
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -5
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +35 -12
- 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 +15 -27
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +21 -9
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +8 -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 +6 -13
- 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 +27 -22
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -39
- 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 +20 -22
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +81 -40
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +3 -8
- 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 +0 -5
- 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/ConversationEndEntity.js +5 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -3
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +34 -26
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +20 -10
- package/lib/esm/contexts/createReducer.js +200 -101
- package/lib/esm/controller/componentController.js +5 -4
- 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/hooks/useDebounce.js +22 -0
- package/lib/esm/hooks/useWindowDimensions.js +23 -0
- package/lib/esm/plugins/newMessageEventHandler.js +29 -26
- package/lib/types/assets/Icons.d.ts +1 -0
- package/lib/types/common/Constants.d.ts +30 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- 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 +65 -12
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +4 -4
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
- package/lib/types/common/utils.d.ts +8 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -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/agentEndConversationHelper.d.ts +6 -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 +1 -1
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -7
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
- 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/ILiveChatWidgetControlProps.d.ts +4 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +7 -2
- package/lib/types/components/livechatwidget/interfaces/IScrollBarProps.d.ts +22 -0
- package/lib/types/components/loadingpanestateful/LoadingPaneStateful.d.ts +1 -2
- package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +4 -0
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +4 -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 +0 -2
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/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/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/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +11 -4
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +34 -25
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +5 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
2
|
+
import { Constants } from "../../../../../common/Constants";
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
5
|
+
const createMessageTimeStampMiddleware = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
dispatch
|
|
8
|
+
} = _ref;
|
|
9
|
+
return next => action => {
|
|
10
|
+
if (isApplicable(action)) {
|
|
11
|
+
return next(evaluateTagsAndOverrideTimeStamp(action));
|
|
12
|
+
}
|
|
13
|
+
return next(action);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const isApplicable = action => {
|
|
17
|
+
return action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && isPVAConversation(action) && isPayloadValid(action) && isValidChannel(action);
|
|
18
|
+
};
|
|
19
|
+
const isPayloadValid = action => {
|
|
20
|
+
var _action$payload;
|
|
21
|
+
return action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
|
|
22
|
+
};
|
|
23
|
+
const isValidChannel = action => {
|
|
24
|
+
var _action$payload2, _action$payload2$acti;
|
|
25
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.channelId) === Constants.acsChannel;
|
|
26
|
+
};
|
|
27
|
+
const isPVAConversation = action => {
|
|
28
|
+
return !isTagIncluded(action, Constants.systemMessageTag) && !isTagIncluded(action, Constants.publicMessageTag) && !isRoleUserOn(action);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
const isTagIncluded = (action, tag) => {
|
|
33
|
+
return isDataTagsPresent(action) && action.payload.activity.channelData.tags.includes(tag);
|
|
34
|
+
};
|
|
35
|
+
const isRoleUserOn = action => {
|
|
36
|
+
var _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
37
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.from) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.role) === Constants.userMessageTag;
|
|
38
|
+
};
|
|
39
|
+
const overrideTimeStamp = (timestampOriginal, timeStampNew) => {
|
|
40
|
+
return isTimestampValid(timeStampNew) ? timeStampNew : timestampOriginal;
|
|
41
|
+
};
|
|
42
|
+
const isTimestampValid = timeStamp => {
|
|
43
|
+
const regex = /(\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(T)(\d{2})(:{1})(\d{2})(:{1})(\d{2})(.\d+)([Z]{1}))/;
|
|
44
|
+
return regex.test(timeStamp);
|
|
45
|
+
};
|
|
46
|
+
const isDataTagsPresent = action => {
|
|
47
|
+
var _action$payload4, _action$payload4$acti, _action$payload4$acti2;
|
|
48
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : (_action$payload4$acti2 = _action$payload4$acti.channelData) === null || _action$payload4$acti2 === void 0 ? void 0 : _action$payload4$acti2.tags) && action.payload.activity.channelData.tags.length > 0;
|
|
49
|
+
};
|
|
50
|
+
const evaluateTagsAndOverrideTimeStamp = action => {
|
|
51
|
+
const tagValue = tagLookup(action, Constants.prefixTimestampTag);
|
|
52
|
+
if (tagValue) {
|
|
53
|
+
const newTimestamp = extractTimeStamp(tagValue);
|
|
54
|
+
action.payload.activity.timestamp = overrideTimeStamp(action.payload.activity.timestamp, newTimestamp);
|
|
55
|
+
}
|
|
56
|
+
return action;
|
|
57
|
+
};
|
|
58
|
+
const extractTimeStamp = timeStamp => {
|
|
59
|
+
if (timeStamp && timeStamp.length > 0) {
|
|
60
|
+
const ts = timeStamp.split(Constants.prefixTimestampTag);
|
|
61
|
+
if (ts && ts.length > 1) {
|
|
62
|
+
return ts[1];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return timeStamp;
|
|
66
|
+
};
|
|
67
|
+
const tagLookup = (action, tag) => {
|
|
68
|
+
if (!isDataTagsPresent(action)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const tags = action.payload.activity.channelData.tags;
|
|
72
|
+
let value;
|
|
73
|
+
if (tags && tags.length > 0) {
|
|
74
|
+
for (let i = 0; i < tags.length; i++) {
|
|
75
|
+
value = tags[i];
|
|
76
|
+
if (value && value.indexOf(tag) > -1) {
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
export default createMessageTimeStampMiddleware;
|
|
@@ -5,11 +5,10 @@ import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps
|
|
|
5
5
|
import { defaultTimestampContentStyles } from "../defaultStyles/defaultTimestampContentStyles";
|
|
6
6
|
import { getTimestampHourMinute } from "../../../../../../common/utils";
|
|
7
7
|
import { useChatContextStore } from "../../../../../..";
|
|
8
|
-
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
9
8
|
|
|
9
|
+
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
10
10
|
export const DeliveredTimestamp = _ref => {
|
|
11
11
|
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$m;
|
|
12
|
-
|
|
13
12
|
let {
|
|
14
13
|
args,
|
|
15
14
|
role,
|
|
@@ -17,7 +16,8 @@ export const DeliveredTimestamp = _ref => {
|
|
|
17
16
|
} = _ref;
|
|
18
17
|
const [state] = useChatContextStore();
|
|
19
18
|
const dir = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.timestampDir) ?? state.domainStates.globalDir;
|
|
20
|
-
const contentStyles = {
|
|
19
|
+
const contentStyles = {
|
|
20
|
+
...defaultTimestampContentStyles,
|
|
21
21
|
...((_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.timestampContentStyleProps)
|
|
22
22
|
};
|
|
23
23
|
const {
|
|
@@ -27,13 +27,12 @@ export const DeliveredTimestamp = _ref => {
|
|
|
27
27
|
} = args;
|
|
28
28
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
29
29
|
style: contentStyles,
|
|
30
|
+
dir: dir
|
|
31
|
+
}, role === DirectLineSenderRole.Bot && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
30
32
|
dir: dir,
|
|
31
|
-
horizontal: true
|
|
32
|
-
}, role === DirectLineSenderRole.Bot && /*#__PURE__*/React.createElement("span", {
|
|
33
33
|
"aria-hidden": "false"
|
|
34
|
-
}, name), role === DirectLineSenderRole.
|
|
34
|
+
}, name, " - ", getTimestampHourMinute(timestamp))), role === DirectLineSenderRole.User && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
35
|
+
"aria-hidden": "false",
|
|
35
36
|
dir: dir
|
|
36
|
-
}, " ", getTimestampHourMinute(timestamp)
|
|
37
|
-
"aria-hidden": "false"
|
|
38
|
-
}, ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_DELIVERED) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_DELIVERED));
|
|
37
|
+
}, " ", getTimestampHourMinute(timestamp), " - ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_DELIVERED) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_DELIVERED)));
|
|
39
38
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from "react";
|
|
2
|
-
import { HtmlAttributeNames } from "../../../../../../common/Constants";
|
|
3
2
|
import { KeyCodes } from "../../../../../../common/KeyCodes";
|
|
4
3
|
import { Stack } from "@fluentui/react";
|
|
5
4
|
import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
@@ -9,11 +8,10 @@ import { defaultTimestampRetryStyles } from "../defaultStyles/defaultTimestampRe
|
|
|
9
8
|
import { getTimestampHourMinute } from "../../../../../../common/utils";
|
|
10
9
|
import { hooks } from "botframework-webchat";
|
|
11
10
|
import { useChatContextStore } from "../../../../../..";
|
|
12
|
-
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
13
11
|
|
|
12
|
+
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
14
13
|
export const NotDeliveredTimestamp = _ref => {
|
|
15
14
|
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3, _state$domainStates$r4, _state$domainStates$m, _state$domainStates$m2;
|
|
16
|
-
|
|
17
15
|
let {
|
|
18
16
|
args
|
|
19
17
|
} = _ref;
|
|
@@ -32,54 +30,37 @@ export const NotDeliveredTimestamp = _ref => {
|
|
|
32
30
|
} = activity;
|
|
33
31
|
const [state] = useChatContextStore();
|
|
34
32
|
const dir = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.timestampDir) ?? state.domainStates.globalDir;
|
|
35
|
-
const contentStyles = {
|
|
33
|
+
const contentStyles = {
|
|
34
|
+
...defaultTimestampContentStyles,
|
|
36
35
|
...((_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.timestampContentStyleProps)
|
|
37
36
|
};
|
|
38
|
-
const failedTextStyles = {
|
|
37
|
+
const failedTextStyles = {
|
|
38
|
+
...defaultTimestampFailedStyles,
|
|
39
39
|
...((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : _state$domainStates$r3.timestampFailedTextStyleProps)
|
|
40
40
|
};
|
|
41
|
-
const retryTextStyles = {
|
|
41
|
+
const retryTextStyles = {
|
|
42
|
+
...defaultTimestampRetryStyles,
|
|
42
43
|
...((_state$domainStates$r4 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.timestampRetryTextStyleProps)
|
|
43
44
|
};
|
|
44
45
|
useEffect(() => {
|
|
45
46
|
var _timestampRef$current;
|
|
46
|
-
|
|
47
47
|
const timestampWebChatNodes = timestampRef === null || timestampRef === void 0 ? void 0 : (_timestampRef$current = timestampRef.current) === null || _timestampRef$current === void 0 ? void 0 : _timestampRef$current.childNodes;
|
|
48
|
-
|
|
49
48
|
if ((timestampWebChatNodes === null || timestampWebChatNodes === void 0 ? void 0 : timestampWebChatNodes.length) > 1) {
|
|
50
49
|
timestampWebChatNodes[1].innerText = getTimestampHourMinute(timestamp);
|
|
51
50
|
}
|
|
52
51
|
}, [timestampRef]);
|
|
53
|
-
const onRetryClick = useCallback(async
|
|
52
|
+
const onRetryClick = useCallback(async () => {
|
|
54
53
|
var _activity$channelData;
|
|
55
|
-
|
|
56
|
-
removeNotDeliveredTimestamp(event);
|
|
57
54
|
activity.previousClientActivityID = (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.clientActivityID;
|
|
58
55
|
await postActivity(activity);
|
|
59
56
|
focus("sendBox");
|
|
60
57
|
}, [activity, focus, postActivity]);
|
|
61
|
-
|
|
62
58
|
const onRetryKeyEnter = event => {
|
|
63
59
|
if (event.code === KeyCodes.ENTER) {
|
|
64
60
|
event.preventDefault();
|
|
65
|
-
onRetryClick(
|
|
61
|
+
onRetryClick();
|
|
66
62
|
}
|
|
67
63
|
};
|
|
68
|
-
|
|
69
|
-
const removeNotDeliveredTimestamp = event => {
|
|
70
|
-
let parent = event.target.parentElement;
|
|
71
|
-
|
|
72
|
-
while (parent.tagName !== HtmlAttributeNames.listItem) {
|
|
73
|
-
parent = parent.parentElement;
|
|
74
|
-
|
|
75
|
-
if (parent.tagName === HtmlAttributeNames.unorderedList) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
parent.parentNode.removeChild(parent);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
64
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
84
65
|
style: contentStyles,
|
|
85
66
|
dir: dir,
|
|
@@ -2,29 +2,20 @@ import React from "react";
|
|
|
2
2
|
import { Stack } from "@fluentui/react";
|
|
3
3
|
import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
4
4
|
import { defaultTimestampContentStyles } from "../defaultStyles/defaultTimestampContentStyles";
|
|
5
|
-
import { getTimestampHourMinute } from "../../../../../../common/utils";
|
|
6
5
|
import { useChatContextStore } from "../../../../../..";
|
|
7
|
-
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
8
|
+
export const SendingTimestamp = () => {
|
|
10
9
|
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$m;
|
|
11
|
-
|
|
12
|
-
let {
|
|
13
|
-
args
|
|
14
|
-
} = _ref;
|
|
15
10
|
const [state] = useChatContextStore();
|
|
16
11
|
const dir = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.timestampDir) ?? state.domainStates.globalDir;
|
|
17
|
-
const contentStyles = {
|
|
12
|
+
const contentStyles = {
|
|
13
|
+
...defaultTimestampContentStyles,
|
|
18
14
|
...((_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.timestampContentStyleProps)
|
|
19
15
|
};
|
|
20
|
-
const {
|
|
21
|
-
activity: {
|
|
22
|
-
timestamp
|
|
23
|
-
}
|
|
24
|
-
} = args;
|
|
25
16
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
26
17
|
style: contentStyles,
|
|
27
18
|
dir: dir,
|
|
28
19
|
horizontal: true
|
|
29
|
-
}, /*#__PURE__*/React.createElement("span", null, " ",
|
|
20
|
+
}, /*#__PURE__*/React.createElement("span", null, " ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_SENDING) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_SENDING, " "));
|
|
30
21
|
};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/******
|
|
2
2
|
* TypingIndicatorMiddleware
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This middleware changes the component that shows who's actively typing. It uses the default Microsoft LiveChatWidget styles.
|
|
5
5
|
******/
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import React, { useCallback } from "react";
|
|
7
8
|
import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
|
|
9
|
+
import { debounceLeading } from "../../../../../common/utils";
|
|
8
10
|
import { defaultMiddlewareLocalizedTexts } from "../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
9
11
|
import { defaultTypingIndicatorBubbleStyles } from "./defaultStyles/defaultTypingIndicatorBubbleStyles";
|
|
10
12
|
import { defaultTypingIndicatorContainerStyles } from "./defaultStyles/defaultTypingIndicatorContainerStyles";
|
|
11
13
|
import { defaultTypingIndicatorMessageStyles } from "./defaultStyles/defaultTypingIndicatorMessageStyles";
|
|
12
14
|
import { useChatContextStore } from "../../../../..";
|
|
13
|
-
import useChatSDKStore from "../../../../../hooks/useChatSDKStore";
|
|
15
|
+
import useChatSDKStore from "../../../../../hooks/useChatSDKStore";
|
|
14
16
|
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
18
|
const TypingIndicator = _ref => {
|
|
16
19
|
var _state$domainStates$l, _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3;
|
|
17
|
-
|
|
18
20
|
let {
|
|
19
21
|
activeTyping,
|
|
20
22
|
visible
|
|
@@ -22,39 +24,38 @@ const TypingIndicator = _ref => {
|
|
|
22
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
25
|
const chatSDK = useChatSDKStore();
|
|
24
26
|
const [state] = useChatContextStore();
|
|
25
|
-
|
|
27
|
+
const debounceTyping = useCallback(debounceLeading(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
|
|
26
28
|
if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
|
|
27
29
|
return null;
|
|
28
30
|
}
|
|
29
|
-
|
|
30
31
|
activeTyping = Object.keys(activeTyping).map(key => activeTyping[key]);
|
|
31
|
-
|
|
32
32
|
for (let i = 0; i < activeTyping.length; i++) {
|
|
33
33
|
if (activeTyping[i].role && activeTyping[i].role === DirectLineSenderRole.User) {
|
|
34
34
|
var _state$domainStates$l2;
|
|
35
|
-
|
|
36
35
|
//visible is set to false if the current user is typing, in which case, we just send typing indicator to OC
|
|
37
36
|
if (((_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.LiveChatVersion) === 2 && !visible) {
|
|
38
|
-
|
|
37
|
+
debounceTyping();
|
|
39
38
|
return null;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
activeTyping.splice(i, 1);
|
|
43
41
|
i--;
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const localizedTexts = {
|
|
45
|
+
...defaultMiddlewareLocalizedTexts,
|
|
48
46
|
...state.domainStates.middlewareLocalizedTexts
|
|
49
47
|
};
|
|
50
48
|
const message = getTypingIndicatorMessage(activeTyping, localizedTexts);
|
|
51
|
-
const typingIndicatorStyles = {
|
|
49
|
+
const typingIndicatorStyles = {
|
|
50
|
+
...defaultTypingIndicatorContainerStyles,
|
|
52
51
|
...((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.typingIndicatorStyleProps)
|
|
53
52
|
};
|
|
54
|
-
const typingIndicatorBubbleStyles = {
|
|
53
|
+
const typingIndicatorBubbleStyles = {
|
|
54
|
+
...defaultTypingIndicatorBubbleStyles,
|
|
55
55
|
...((_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.typingIndicatorBubbleStyleProps)
|
|
56
56
|
};
|
|
57
|
-
const typingIndicatorMessageStyles = {
|
|
57
|
+
const typingIndicatorMessageStyles = {
|
|
58
|
+
...defaultTypingIndicatorMessageStyles,
|
|
58
59
|
...((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : _state$domainStates$r3.typingIndicatorMessageStyleProps)
|
|
59
60
|
};
|
|
60
61
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
@@ -96,9 +97,9 @@ const TypingIndicator = _ref => {
|
|
|
96
97
|
}), /*#__PURE__*/React.createElement("div", {
|
|
97
98
|
style: typingIndicatorMessageStyles
|
|
98
99
|
}, " ", message, " ")));
|
|
99
|
-
};
|
|
100
|
-
|
|
100
|
+
};
|
|
101
101
|
|
|
102
|
+
// eslint-disable-next-line react/display-name, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
102
103
|
export const typingIndicatorMiddleware = () => next => args => {
|
|
103
104
|
const {
|
|
104
105
|
activeTyping,
|
|
@@ -108,8 +109,9 @@ export const typingIndicatorMiddleware = () => next => args => {
|
|
|
108
109
|
activeTyping: activeTyping,
|
|
109
110
|
visible: visible
|
|
110
111
|
});
|
|
111
|
-
};
|
|
112
|
+
};
|
|
112
113
|
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
115
|
const getTypingIndicatorMessage = (activeTyping, localizedTexts) => {
|
|
114
116
|
if (!activeTyping || activeTyping.length === 0) {
|
|
115
117
|
return "";
|
|
@@ -120,19 +122,15 @@ const getTypingIndicatorMessage = (activeTyping, localizedTexts) => {
|
|
|
120
122
|
const firstMember = activeTyping[0].name;
|
|
121
123
|
const lastMember = activeTyping[1].name;
|
|
122
124
|
let message = localizedTexts.MIDDLEWARE_TYPING_INDICATOR_TWO;
|
|
123
|
-
|
|
124
125
|
if (!message) {
|
|
125
126
|
return "";
|
|
126
127
|
}
|
|
127
|
-
|
|
128
128
|
if (message.includes("{0}")) {
|
|
129
129
|
message = message.replace("{0}", firstMember);
|
|
130
130
|
}
|
|
131
|
-
|
|
132
131
|
if (message.includes("{1}")) {
|
|
133
132
|
message = message.replace("{1}", lastMember);
|
|
134
133
|
}
|
|
135
|
-
|
|
136
134
|
return message;
|
|
137
135
|
} else {
|
|
138
136
|
const message = localizedTexts.MIDDLEWARE_TYPING_INDICATOR_MULTIPLE;
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Handles attachment sending.
|
|
5
5
|
******/
|
|
6
|
-
import { WebChatActionType } from "../../enums/WebChatActionType"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
6
|
|
|
7
|
+
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
10
|
const createSendFileAction = files => {
|
|
9
11
|
return {
|
|
10
12
|
payload: {
|
|
@@ -12,31 +14,26 @@ const createSendFileAction = files => {
|
|
|
12
14
|
},
|
|
13
15
|
type: WebChatActionType.WEB_CHAT_SEND_FILES
|
|
14
16
|
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
+
};
|
|
17
18
|
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
20
|
const attachmentProcessingMiddleware = _ref => {
|
|
19
21
|
let {
|
|
20
22
|
dispatch
|
|
21
23
|
} = _ref;
|
|
22
24
|
return next => async action => {
|
|
23
25
|
var _action$payload, _action$payload$files;
|
|
24
|
-
|
|
25
26
|
if ((action === null || action === void 0 ? void 0 : action.type) === WebChatActionType.WEB_CHAT_SEND_FILES && (action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$files = _action$payload.files) === null || _action$payload$files === void 0 ? void 0 : _action$payload$files.length) > 0) {
|
|
26
27
|
const files = action.payload.files;
|
|
27
|
-
|
|
28
28
|
if (files.length === 1) {
|
|
29
29
|
return next(action);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
const dispatchAction = createSendFileAction(files.slice(0, files.length - 1));
|
|
33
32
|
const nextAction = createSendFileAction([files[files.length - 1]]);
|
|
34
33
|
await dispatch(dispatchAction);
|
|
35
34
|
return next(nextAction);
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
return next(action);
|
|
39
37
|
};
|
|
40
38
|
};
|
|
41
|
-
|
|
42
39
|
export default attachmentProcessingMiddleware;
|
|
@@ -3,36 +3,37 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Checks if the attachment being uploaded satisfies Omnichannel's requirement on file extensions and file size.
|
|
5
5
|
******/
|
|
6
|
+
|
|
7
|
+
import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
|
|
6
8
|
import { NotificationHandler } from "../../notification/NotificationHandler";
|
|
7
9
|
import { NotificationScenarios } from "../../enums/NotificationScenarios";
|
|
8
10
|
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
11
|
+
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
12
|
+
import { AMSConstants } from "../../../../../common/Constants";
|
|
9
13
|
const MBtoBRatio = 1000000;
|
|
14
|
+
|
|
10
15
|
/*
|
|
11
16
|
* If an attachment is invalid, delete this attachment from the attachments list
|
|
12
17
|
* If the result attachment list is empty, return a dummy action
|
|
13
18
|
*/
|
|
14
|
-
|
|
15
|
-
const validateAttachment = (action, allowedFileExtensions, maxUploadFileSize, localizedTexts) => {
|
|
19
|
+
const validateAttachment = (action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
16
20
|
var _action$payload, _action$payload$activ, _action$payload2, _action$payload2$acti, _action$payload2$acti2, _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
17
|
-
|
|
18
21
|
const attachments = action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.attachments;
|
|
19
22
|
const attachmentSizes = action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : (_action$payload2$acti2 = _action$payload2$acti.channelData) === null || _action$payload2$acti2 === void 0 ? void 0 : _action$payload2$acti2.attachmentSizes;
|
|
20
|
-
|
|
21
23
|
if (attachments) {
|
|
22
24
|
for (let i = 0; i < attachments.length; i++) {
|
|
25
|
+
const maxUploadFileSize = getMaxUploadFileSize(maxFileSizeSupportedByDynamics, attachments[i].contentType);
|
|
23
26
|
const fileExtensionValid = validateFileExtension(attachments[i], allowedFileExtensions);
|
|
24
27
|
const fileSizeValid = validateFileSize(attachmentSizes[i], maxUploadFileSize);
|
|
25
28
|
const fileIsEmpty = parseInt(attachmentSizes[i]) == 0;
|
|
26
|
-
|
|
27
29
|
if (!fileExtensionValid || !fileSizeValid || fileIsEmpty) {
|
|
28
|
-
NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize, localizedTexts));
|
|
30
|
+
NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize.toString(), maxFileSizeSupportedByDynamics, localizedTexts));
|
|
29
31
|
attachments.splice(i, 1);
|
|
30
32
|
attachmentSizes.splice(i, 1);
|
|
31
33
|
i--;
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
|
-
|
|
36
37
|
if ((action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.attachments) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.length) > 0) {
|
|
37
38
|
return action;
|
|
38
39
|
} else {
|
|
@@ -41,109 +42,149 @@ const validateAttachment = (action, allowedFileExtensions, maxUploadFileSize, lo
|
|
|
41
42
|
payload: null
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
|
-
};
|
|
45
|
-
|
|
45
|
+
};
|
|
46
46
|
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
48
|
const validateFileExtension = (attachment, allowedFileExtensions) => {
|
|
48
49
|
if (!allowedFileExtensions) {
|
|
49
50
|
return true;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
const fileName = attachment.name.toLowerCase();
|
|
53
53
|
const index = fileName.lastIndexOf(".");
|
|
54
|
-
|
|
55
54
|
if (!index) {
|
|
56
55
|
return false;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
57
|
const fileExtension = fileName.substring(index);
|
|
60
58
|
const allExtensions = allowedFileExtensions === null || allowedFileExtensions === void 0 ? void 0 : allowedFileExtensions.toLowerCase().split(",");
|
|
61
59
|
return allExtensions.indexOf(fileExtension) > -1;
|
|
62
60
|
};
|
|
63
|
-
|
|
64
61
|
const validateFileSize = (attachmentSize, maxUploadFileSize) => {
|
|
65
|
-
return
|
|
62
|
+
return maxUploadFileSize * MBtoBRatio > parseInt(attachmentSize);
|
|
66
63
|
};
|
|
67
|
-
|
|
68
|
-
const
|
|
64
|
+
const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) => {
|
|
65
|
+
const maxFileSizeSupportedByDynamics = maxFileSizeSupportedByDynamicsStr && parseInt(maxFileSizeSupportedByDynamicsStr) ? parseInt(maxFileSizeSupportedByDynamicsStr) : AMSConstants.maxSupportedFileSize;
|
|
66
|
+
const amsAttachmentSizeLimit = isImage(contentType) ? AMSConstants.maxSupportedImageSize : AMSConstants.maxSupportedFileSize;
|
|
67
|
+
// Takes the smallest max file size configure betteween AMS and Dynamics Config
|
|
68
|
+
return maxFileSizeSupportedByDynamics < amsAttachmentSizeLimit ? maxFileSizeSupportedByDynamics : amsAttachmentSizeLimit;
|
|
69
|
+
};
|
|
70
|
+
const isImage = contentType => {
|
|
71
|
+
return AMSConstants.supportedImagesMimeTypes.includes(contentType);
|
|
72
|
+
};
|
|
73
|
+
const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
69
74
|
let errorMessage = "";
|
|
70
|
-
|
|
71
75
|
if (!fileName || !maxUploadFileSize) {
|
|
76
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
77
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
78
|
+
Description: "Attachment validation failed",
|
|
79
|
+
ExceptionDetails: {
|
|
80
|
+
ErrorDetails: "File provided is null"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
72
83
|
return localizedTexts.MIDDLEWARE_BANNER_FILE_NULL_ERROR ?? "";
|
|
73
84
|
}
|
|
74
|
-
|
|
75
85
|
if (!supportedFileExtension && !supportedFileSize) {
|
|
76
|
-
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, localizedTexts);
|
|
86
|
+
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
77
87
|
} else if (!supportedFileSize) {
|
|
78
|
-
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, localizedTexts);
|
|
88
|
+
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
79
89
|
} else if (!supportedFileExtension) {
|
|
80
90
|
errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
|
|
81
91
|
} else if (fileIsEmpty) {
|
|
92
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
93
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
94
|
+
Description: "Attachment validation failed",
|
|
95
|
+
ExceptionDetails: {
|
|
96
|
+
ErrorDetails: "File provided is empty"
|
|
97
|
+
}
|
|
98
|
+
});
|
|
82
99
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
|
|
83
100
|
} else {
|
|
101
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
102
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
103
|
+
Description: "Attachment validation failed",
|
|
104
|
+
ExceptionDetails: {
|
|
105
|
+
ErrorDetails: `Unexpected error: supportedFileExtension=${supportedFileExtension} supportedFileSize=${supportedFileSize} fileIsEmpty=${!fileIsEmpty}`
|
|
106
|
+
}
|
|
107
|
+
});
|
|
84
108
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_ERROR_MESSAGE ?? "";
|
|
85
109
|
}
|
|
86
|
-
|
|
87
110
|
return errorMessage;
|
|
88
111
|
};
|
|
89
|
-
|
|
90
|
-
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, localizedTexts) => {
|
|
112
|
+
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
91
113
|
const index = fileName.lastIndexOf(".");
|
|
92
|
-
let errorMessage;
|
|
93
|
-
|
|
114
|
+
let errorMessage, exceptionDetails;
|
|
94
115
|
if (index < 0) {
|
|
95
116
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
|
|
117
|
+
exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
|
|
96
118
|
} else {
|
|
97
119
|
var _errorMessage;
|
|
98
|
-
|
|
99
120
|
const fileExtension = fileName.substring(index);
|
|
100
121
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
|
|
101
|
-
|
|
122
|
+
exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
|
|
102
123
|
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
|
|
103
124
|
errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
|
-
|
|
127
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
128
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
129
|
+
Description: "Attachment validation failed",
|
|
130
|
+
ExceptionDetails: {
|
|
131
|
+
ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
|
|
132
|
+
}
|
|
133
|
+
});
|
|
107
134
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
|
|
108
135
|
};
|
|
109
|
-
|
|
110
136
|
const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
111
137
|
const index = fileName.lastIndexOf(".");
|
|
112
|
-
|
|
113
138
|
if (index < 0) {
|
|
139
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
140
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
141
|
+
Description: "Attachment validation failed",
|
|
142
|
+
ExceptionDetails: {
|
|
143
|
+
ErrorDetails: "File provided without file extension"
|
|
144
|
+
}
|
|
145
|
+
});
|
|
114
146
|
return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
|
|
115
147
|
} else {
|
|
116
148
|
const fileExtension = fileName.substring(index);
|
|
149
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
150
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
151
|
+
Description: "Attachment validation failed",
|
|
152
|
+
ExceptionDetails: {
|
|
153
|
+
ErrorDetails: `${fileExtension} files extension is not supported.`
|
|
154
|
+
}
|
|
155
|
+
});
|
|
117
156
|
const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
|
|
118
157
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
|
|
119
158
|
}
|
|
120
159
|
};
|
|
121
|
-
|
|
122
|
-
|
|
160
|
+
const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
161
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
162
|
+
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
163
|
+
Description: "Attachment validation failed",
|
|
164
|
+
ExceptionDetails: {
|
|
165
|
+
ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
|
|
166
|
+
}
|
|
167
|
+
});
|
|
123
168
|
const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
|
|
124
169
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
|
|
125
|
-
};
|
|
126
|
-
|
|
170
|
+
};
|
|
127
171
|
|
|
128
|
-
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
173
|
+
const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => _ref => {
|
|
129
174
|
let {
|
|
130
175
|
dispatch
|
|
131
176
|
} = _ref;
|
|
132
177
|
return next => action => {
|
|
133
178
|
if (action.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
|
|
134
179
|
var _payload$activity, _payload$activity2, _payload$activity2$ch, _payload$activity3, _payload$activity3$at, _payload$activity4, _payload$activity4$ch, _payload$activity4$ch2;
|
|
135
|
-
|
|
136
180
|
const {
|
|
137
181
|
payload
|
|
138
182
|
} = action;
|
|
139
|
-
|
|
140
183
|
if (payload !== null && payload !== void 0 && (_payload$activity = payload.activity) !== null && _payload$activity !== void 0 && _payload$activity.attachments && payload !== null && payload !== void 0 && (_payload$activity2 = payload.activity) !== null && _payload$activity2 !== void 0 && (_payload$activity2$ch = _payload$activity2.channelData) !== null && _payload$activity2$ch !== void 0 && _payload$activity2$ch.attachmentSizes && (payload === null || payload === void 0 ? void 0 : (_payload$activity3 = payload.activity) === null || _payload$activity3 === void 0 ? void 0 : (_payload$activity3$at = _payload$activity3.attachments) === null || _payload$activity3$at === void 0 ? void 0 : _payload$activity3$at.length) === (payload === null || payload === void 0 ? void 0 : (_payload$activity4 = payload.activity) === null || _payload$activity4 === void 0 ? void 0 : (_payload$activity4$ch = _payload$activity4.channelData) === null || _payload$activity4$ch === void 0 ? void 0 : (_payload$activity4$ch2 = _payload$activity4$ch.attachmentSizes) === null || _payload$activity4$ch2 === void 0 ? void 0 : _payload$activity4$ch2.length)) {
|
|
141
|
-
return next(validateAttachment(action, allowedFileExtensions,
|
|
184
|
+
return next(validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts));
|
|
142
185
|
}
|
|
143
186
|
}
|
|
144
|
-
|
|
145
187
|
return next(action);
|
|
146
188
|
};
|
|
147
189
|
};
|
|
148
|
-
|
|
149
190
|
export default createAttachmentUploadValidatorMiddleware;
|