botframework-webchat-core 4.18.1 → 4.19.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/LICENSE +21 -0
- package/activity.js +3 -0
- package/boot/deprecated/activity.js +7 -0
- package/boot/deprecated/activity.mjs +5 -0
- package/boot/deprecated/graph.js +7 -0
- package/boot/deprecated/graph.mjs +5 -0
- package/boot/deprecated/internal.js +7 -0
- package/boot/deprecated/internal.mjs +5 -0
- package/dist/WebChatActivity-CYqxBG_4.d.mts +271 -0
- package/dist/WebChatActivity-CYqxBG_4.d.ts +271 -0
- package/dist/_dtsroll-chunks/B7Whm73Q-tagged.d.ts +71 -0
- package/dist/_dtsroll-chunks/C-MxR98A-botframework-webchat-core-debug-api.d.ts +135 -0
- package/dist/_dtsroll-chunks/CAquHfZK-botframework-webchat-base.utils.d.ts +17 -0
- package/dist/_dtsroll-chunks/CDVed0Q--botframework-webchat-core.org-schema.d.ts +601 -0
- package/dist/_dtsroll-chunks/vlDgTKWF-botframework-webchat-core-graph.d.ts +239 -0
- package/dist/botframework-webchat-core.activity.d.mts +23 -0
- package/dist/botframework-webchat-core.activity.d.ts +23 -0
- package/dist/botframework-webchat-core.activity.js +2 -0
- package/dist/botframework-webchat-core.activity.js.map +1 -0
- package/dist/botframework-webchat-core.activity.mjs +2 -0
- package/dist/botframework-webchat-core.activity.mjs.map +1 -0
- package/dist/botframework-webchat-core.d.mts +267 -662
- package/dist/botframework-webchat-core.d.ts +556 -0
- package/dist/botframework-webchat-core.graph.d.mts +9 -0
- package/dist/botframework-webchat-core.graph.d.ts +9 -0
- package/dist/botframework-webchat-core.graph.js +2 -0
- package/dist/botframework-webchat-core.graph.js.map +1 -0
- package/dist/botframework-webchat-core.graph.mjs +2 -0
- package/dist/botframework-webchat-core.graph.mjs.map +1 -0
- package/dist/botframework-webchat-core.internal.d.mts +61 -0
- package/dist/botframework-webchat-core.internal.d.ts +61 -0
- package/dist/botframework-webchat-core.internal.js +2 -0
- package/dist/botframework-webchat-core.internal.js.map +1 -0
- package/dist/botframework-webchat-core.internal.mjs +2 -0
- package/dist/botframework-webchat-core.internal.mjs.map +1 -0
- package/dist/botframework-webchat-core.js +2 -0
- package/dist/botframework-webchat-core.js.map +1 -0
- package/dist/botframework-webchat-core.json-ld.d.mts +2 -0
- package/dist/botframework-webchat-core.json-ld.d.ts +2 -0
- package/dist/botframework-webchat-core.json-ld.js +2 -0
- package/dist/botframework-webchat-core.json-ld.js.map +1 -0
- package/dist/botframework-webchat-core.json-ld.mjs +2 -0
- package/dist/botframework-webchat-core.json-ld.mjs.map +1 -0
- package/dist/botframework-webchat-core.mjs +1 -2
- package/dist/botframework-webchat-core.mjs.map +1 -1
- package/dist/botframework-webchat-core.org-schema.d.mts +2 -0
- package/dist/botframework-webchat-core.org-schema.d.ts +2 -0
- package/dist/botframework-webchat-core.org-schema.js +2 -0
- package/dist/botframework-webchat-core.org-schema.js.map +1 -0
- package/dist/botframework-webchat-core.org-schema.mjs +2 -0
- package/dist/botframework-webchat-core.org-schema.mjs.map +1 -0
- package/dist/chunk-A4GEFYZJ.mjs +2 -0
- package/dist/chunk-A4GEFYZJ.mjs.map +1 -0
- package/dist/chunk-HZWWJL43.mjs +2 -0
- package/dist/chunk-HZWWJL43.mjs.map +1 -0
- package/dist/chunk-ICNZKQJW.mjs +2 -0
- package/dist/chunk-ICNZKQJW.mjs.map +1 -0
- package/dist/chunk-K6E6QQMQ.js +2 -0
- package/dist/chunk-K6E6QQMQ.js.map +1 -0
- package/dist/chunk-KPT5FBH2.mjs +2 -0
- package/dist/chunk-KPT5FBH2.mjs.map +1 -0
- package/dist/chunk-LO5BZSVE.js +2 -0
- package/dist/chunk-LO5BZSVE.js.map +1 -0
- package/dist/chunk-LP2X2JTR.js +2 -0
- package/dist/chunk-LP2X2JTR.js.map +1 -0
- package/dist/chunk-RUERYYZO.js +2 -0
- package/dist/chunk-RUERYYZO.js.map +1 -0
- package/dist/chunk-XOE3AOSM.js +2 -0
- package/dist/chunk-XOE3AOSM.js.map +1 -0
- package/dist/chunk-Y6ZDNVRT.mjs +2 -0
- package/dist/chunk-Y6ZDNVRT.mjs.map +1 -0
- package/{lib/createStore.d.ts → dist/createStore-CcvouBrW.d.mts} +29 -7
- package/dist/createStore-CcvouBrW.d.ts +65 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -1
- package/graph.js +3 -0
- package/internal.js +3 -0
- package/json-ld.js +3 -0
- package/org-schema.js +3 -0
- package/package.json +147 -73
- package/src/__tests__/activityFromBot.spec.js +2 -0
- package/src/__tests__/addMetaTag.spec.js +8 -0
- package/src/__tests__/addMetaTag.spec.mjs +8 -0
- package/src/__tests__/connectSaga.spec.js +2 -0
- package/src/__tests__/deleteKey.spec.js +2 -0
- package/src/__tests__/detectSlowConnectionSaga.spec.js +3 -1
- package/src/__tests__/observeOnce.spec.js +2 -0
- package/src/__tests__/speakableActivity.spec.js +2 -0
- package/src/__tests__/uniqueID.spec.js +2 -0
- package/src/actions/clearSuggestedActions.ts +20 -0
- package/src/actions/{connect.js → connect.ts} +9 -1
- package/src/actions/muteVoiceRecording.ts +17 -0
- package/src/actions/postVoiceActivity.ts +21 -0
- package/src/actions/registerActionSink.ts +29 -0
- package/src/actions/registerVoiceHandler.ts +24 -0
- package/src/actions/{sendEvent.js → sendEvent.ts} +1 -1
- package/src/actions/{sendMessageBack.js → sendMessageBack.ts} +1 -1
- package/src/actions/{sendPostBack.js → sendPostBack.ts} +1 -1
- package/src/actions/{setDictateInterims.js → setDictateInterims.ts} +1 -1
- package/src/actions/{setDictateState.js → setDictateState.ts} +1 -1
- package/src/actions/{setLanguage.js → setLanguage.ts} +1 -1
- package/src/actions/{setSendBox.js → setSendBox.ts} +1 -1
- package/src/actions/{setSendTimeout.js → setSendTimeout.ts} +1 -1
- package/src/actions/setSendTypingIndicator.ts +1 -1
- package/src/actions/setSuggestedActions.ts +35 -0
- package/src/actions/setVoiceState.ts +21 -0
- package/src/actions/startVoiceRecording.ts +17 -0
- package/src/actions/stopVoiceRecording.ts +17 -0
- package/src/actions/{submitSendBox.js → submitSendBox.ts} +1 -1
- package/src/actions/unmuteVoiceRecording.ts +17 -0
- package/src/actions/unregisterActionSink.ts +29 -0
- package/src/actions/unregisterVoiceHandler.ts +19 -0
- package/src/boot/activity.ts +19 -0
- package/src/boot/graph.ts +18 -0
- package/src/boot/internal.ts +11 -0
- package/src/boot/json-ld.ts +6 -0
- package/src/boot/org-schema.ts +29 -0
- package/src/buildInfo.ts +9 -0
- package/src/constants/{ActivityClientState.js → ActivityClientState.ts} +3 -3
- package/src/constants/DictateState.ts +10 -0
- package/src/createPromiseQueue.js +8 -6
- package/src/createReducer.ts +28 -20
- package/src/createSagas.ts +6 -3
- package/src/createStore.ts +26 -10
- package/src/env.d.ts +12 -0
- package/src/graph/createGraphFromStore.ts +121 -0
- package/src/index.ts +62 -45
- package/src/internal/StoreDebugAPIRegistry.ts +4 -0
- package/src/internal/actions/setRawState.ts +48 -0
- package/src/internal/types/suggestedActions.ts +11 -0
- package/src/internal/types/suggestedActionsOriginActivity.ts +16 -0
- package/src/reducers/activities/combineActivitiesReducer.ts +58 -0
- package/src/reducers/activities/createGroupedActivitiesReducer.ts +297 -0
- package/src/reducers/activities/patchActivity.ts +37 -0
- package/src/reducers/activities/sort/deleteActivityByLocalId.activity.spec.ts +144 -0
- package/src/reducers/activities/sort/deleteActivityByLocalId.howTo.spec.ts +148 -0
- package/src/reducers/activities/sort/deleteActivityByLocalId.howToWithLivestream.spec.ts +248 -0
- package/src/reducers/activities/sort/deleteActivityByLocalId.livestream.spec.ts +156 -0
- package/src/reducers/activities/sort/deleteActivityByLocalId.ts +177 -0
- package/src/reducers/activities/sort/private/computePartListTimestamp.ts +9 -0
- package/src/reducers/activities/sort/private/computeSortedActivities.ts +51 -0
- package/src/reducers/activities/sort/private/getLogicalTimestamp.spec.ts +49 -0
- package/src/reducers/activities/sort/private/getLogicalTimestamp.ts +33 -0
- package/src/reducers/activities/sort/private/getPartGroupingMetadataMap.spec.ts +92 -0
- package/src/reducers/activities/sort/private/getPartGroupingMetadataMap.ts +37 -0
- package/src/reducers/activities/sort/private/insertSorted.spec.ts +106 -0
- package/src/reducers/activities/sort/private/insertSorted.ts +18 -0
- package/src/reducers/activities/sort/property/LocalId.ts +60 -0
- package/src/reducers/activities/sort/property/Position.ts +39 -0
- package/src/reducers/activities/sort/property/ReceivedAt.ts +45 -0
- package/src/reducers/activities/sort/property/SendStatus.ts +51 -0
- package/src/reducers/activities/sort/queryLocalIdByActivityId.ts +6 -0
- package/src/reducers/activities/sort/queryLocalIdByClientActivityId.ts +6 -0
- package/src/reducers/activities/sort/types.ts +80 -0
- package/src/reducers/activities/sort/updateActivityChannelData.ts +101 -0
- package/src/reducers/activities/sort/updateSendState.ts +22 -0
- package/src/reducers/activities/sort/upsert.activity.spec.ts +500 -0
- package/src/reducers/activities/sort/upsert.howTo.spec.ts +368 -0
- package/src/reducers/activities/sort/upsert.howToWithLivestream.spec.ts +384 -0
- package/src/reducers/activities/sort/upsert.livestream.spec.ts +418 -0
- package/src/reducers/activities/sort/upsert.ts +498 -0
- package/src/reducers/activities/tsconfig.json +4 -0
- package/src/reducers/createNotificationsReducer.ts +4 -4
- package/src/reducers/suggestedActions.ts +21 -0
- package/src/reducers/suggestedActionsOriginActivity.ts +24 -0
- package/src/reducers/voiceActivity.ts +102 -0
- package/src/sagas/actionSinkSaga.ts +39 -0
- package/src/sagas/observeActivitySaga.ts +51 -1
- package/src/sagas/postActivitySaga.ts +17 -10
- package/src/sagas/postVoiceActivitySaga.ts +76 -0
- package/src/sagas/queueIncomingActivitySaga.ts +10 -4
- package/src/sagas/sendMessageToPostActivitySaga.ts +4 -1
- package/src/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +10 -4
- package/src/sagas/startDictateOnSpeakCompleteSaga.js +3 -3
- package/src/sagas/startSpeakActivityOnPostActivitySaga.js +15 -5
- package/src/sagas/stopDictateOnCardActionSaga.js +11 -3
- package/src/sagas/stopSpeakingActivityOnInputSaga.js +22 -4
- package/src/selectors/combineSelectors.ts +1 -1
- package/src/tsconfig.json +3 -15
- package/src/types/StoreDebugAPI.ts +25 -0
- package/src/types/WebChatActivity.ts +31 -14
- package/src/types/external/DirectLineActivity.ts +1 -1
- package/src/types/external/Observable.ts +4 -1
- package/src/types/internal/GlobalScopeClock.ts +10 -10
- package/src/types/internal/ReduxState.ts +2 -0
- package/src/types/internal/WebChatOutgoingActivity.ts +1 -1
- package/src/utils/dateToLocaleISOString.chatham.spec.js +1 -2
- package/src/utils/dateToLocaleISOString.japan.spec.js +1 -2
- package/src/utils/dateToLocaleISOString.newfoundland.spec.js +1 -2
- package/src/utils/dateToLocaleISOString.pacific.spec.js +1 -2
- package/src/utils/dateToLocaleISOString.utc.spec.js +1 -3
- package/src/utils/deleteKey.ts +1 -1
- package/src/utils/getActivityLivestreamingMetadata.spec.ts +297 -0
- package/src/utils/getActivityLivestreamingMetadata.ts +197 -0
- package/src/utils/getOrgSchemaMessage.spec.ts +4 -1
- package/src/utils/getOrgSchemaMessage.ts +16 -16
- package/src/utils/onErrorResumeNext.ts +1 -1
- package/src/utils/voiceActivity/getVoiceActivityRole.spec.ts +150 -0
- package/src/utils/voiceActivity/getVoiceActivityRole.ts +16 -0
- package/src/utils/voiceActivity/getVoiceActivityText.spec.ts +100 -0
- package/src/utils/voiceActivity/getVoiceActivityText.ts +11 -0
- package/src/utils/voiceActivity/isVoiceActivity.spec.ts +202 -0
- package/src/utils/voiceActivity/isVoiceActivity.ts +21 -0
- package/src/utils/voiceActivity/isVoiceTranscriptActivity.spec.ts +224 -0
- package/src/utils/voiceActivity/isVoiceTranscriptActivity.ts +24 -0
- package/dist/botframework-webchat-core.mjs.LEGAL.txt +0 -0
- package/lib/actions/clearSuggestedActions.js +0 -15
- package/lib/actions/connect.js +0 -33
- package/lib/actions/connectionStatusUpdate.js +0 -20
- package/lib/actions/deleteActivity.d.ts +0 -13
- package/lib/actions/deleteActivity.d.ts.map +0 -1
- package/lib/actions/deleteActivity.js +0 -19
- package/lib/actions/disconnect.js +0 -21
- package/lib/actions/dismissNotification.d.ts +0 -12
- package/lib/actions/dismissNotification.d.ts.map +0 -1
- package/lib/actions/dismissNotification.js +0 -19
- package/lib/actions/emitTypingIndicator.js +0 -15
- package/lib/actions/incomingActivity.d.ts +0 -14
- package/lib/actions/incomingActivity.d.ts.map +0 -1
- package/lib/actions/incomingActivity.js +0 -19
- package/lib/actions/markActivity.d.ts +0 -17
- package/lib/actions/markActivity.d.ts.map +0 -1
- package/lib/actions/markActivity.js +0 -22
- package/lib/actions/postActivity.d.ts +0 -64
- package/lib/actions/postActivity.d.ts.map +0 -1
- package/lib/actions/postActivity.js +0 -31
- package/lib/actions/queueIncomingActivity.js +0 -18
- package/lib/actions/reconnect.js +0 -17
- package/lib/actions/sagaError.d.ts +0 -8
- package/lib/actions/sagaError.d.ts.map +0 -1
- package/lib/actions/sagaError.js +0 -15
- package/lib/actions/sendEvent.js +0 -19
- package/lib/actions/sendFiles.d.ts +0 -19
- package/lib/actions/sendFiles.d.ts.map +0 -1
- package/lib/actions/sendFiles.js +0 -20
- package/lib/actions/sendMessage.d.ts +0 -19
- package/lib/actions/sendMessage.d.ts.map +0 -1
- package/lib/actions/sendMessage.js +0 -24
- package/lib/actions/sendMessageBack.js +0 -20
- package/lib/actions/sendPostBack.js +0 -18
- package/lib/actions/setClockSkewAdjustment.js +0 -12
- package/lib/actions/setDictateInterims.js +0 -18
- package/lib/actions/setDictateState.js +0 -18
- package/lib/actions/setLanguage.js +0 -18
- package/lib/actions/setNotification.d.ts +0 -10
- package/lib/actions/setNotification.d.ts.map +0 -1
- package/lib/actions/setNotification.js +0 -37
- package/lib/actions/setReferenceGrammarID.js +0 -18
- package/lib/actions/setSendBox.js +0 -18
- package/lib/actions/setSendBoxAttachments.d.ts +0 -13
- package/lib/actions/setSendBoxAttachments.d.ts.map +0 -1
- package/lib/actions/setSendBoxAttachments.js +0 -18
- package/lib/actions/setSendTimeout.js +0 -18
- package/lib/actions/setSendTypingIndicator.d.ts +0 -11
- package/lib/actions/setSendTypingIndicator.d.ts.map +0 -1
- package/lib/actions/setSendTypingIndicator.js +0 -18
- package/lib/actions/setSuggestedActions.js +0 -20
- package/lib/actions/startDictate.js +0 -15
- package/lib/actions/startSpeakingActivity.js +0 -15
- package/lib/actions/stopDictate.js +0 -15
- package/lib/actions/stopSpeakingActivity.js +0 -15
- package/lib/actions/submitSendBox.js +0 -22
- package/lib/actions/updateConnectionStatus.js +0 -18
- package/lib/constants/ActivityClientState.js +0 -16
- package/lib/constants/DictateState.js +0 -17
- package/lib/createPromiseQueue.js +0 -30
- package/lib/createReducer.d.ts +0 -60
- package/lib/createReducer.d.ts.map +0 -1
- package/lib/createReducer.js +0 -45
- package/lib/createSagas.d.ts +0 -8
- package/lib/createSagas.d.ts.map +0 -1
- package/lib/createSagas.js +0 -112
- package/lib/createStore.d.ts.map +0 -1
- package/lib/createStore.js +0 -131
- package/lib/definitions/activityFromBot.js +0 -11
- package/lib/definitions/speakableActivity.js +0 -10
- package/lib/definitions/speakingActivity.js +0 -13
- package/lib/index.d.ts +0 -76
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -309
- package/lib/reducers/connectivityStatus.js +0 -49
- package/lib/reducers/createActivitiesReducer.d.ts +0 -12
- package/lib/reducers/createActivitiesReducer.d.ts.map +0 -1
- package/lib/reducers/createActivitiesReducer.js +0 -267
- package/lib/reducers/createInternalReducer.d.ts +0 -10
- package/lib/reducers/createInternalReducer.d.ts.map +0 -1
- package/lib/reducers/createInternalReducer.js +0 -19
- package/lib/reducers/createNotificationsReducer.d.ts +0 -11
- package/lib/reducers/createNotificationsReducer.d.ts.map +0 -1
- package/lib/reducers/createNotificationsReducer.js +0 -55
- package/lib/reducers/createTypingReducer.d.ts +0 -14
- package/lib/reducers/createTypingReducer.d.ts.map +0 -1
- package/lib/reducers/createTypingReducer.js +0 -50
- package/lib/reducers/dictateInterims.js +0 -23
- package/lib/reducers/dictateState.js +0 -38
- package/lib/reducers/language.js +0 -23
- package/lib/reducers/private/findBeforeAfter.d.ts +0 -4
- package/lib/reducers/private/findBeforeAfter.d.ts.map +0 -1
- package/lib/reducers/private/findBeforeAfter.js +0 -24
- package/lib/reducers/readyState.js +0 -23
- package/lib/reducers/referenceGrammarID.js +0 -23
- package/lib/reducers/sendBoxAttachments.d.ts +0 -9
- package/lib/reducers/sendBoxAttachments.d.ts.map +0 -1
- package/lib/reducers/sendBoxAttachments.js +0 -23
- package/lib/reducers/sendBoxValue.js +0 -23
- package/lib/reducers/sendTimeout.js +0 -23
- package/lib/reducers/sendTypingIndicator.js +0 -23
- package/lib/reducers/shouldSpeakIncomingActivity.js +0 -25
- package/lib/reducers/suggestedActions.js +0 -32
- package/lib/sagas/clearSuggestedActionsOnPostActivitySaga.js +0 -62
- package/lib/sagas/connectSaga.js +0 -445
- package/lib/sagas/connectionStatusToNotificationSaga.js +0 -107
- package/lib/sagas/connectionStatusUpdateSaga.js +0 -63
- package/lib/sagas/detectSlowConnectionSaga.d.ts +0 -5
- package/lib/sagas/detectSlowConnectionSaga.d.ts.map +0 -1
- package/lib/sagas/detectSlowConnectionSaga.js +0 -50
- package/lib/sagas/effects/forever.js +0 -19
- package/lib/sagas/effects/forkPut.js +0 -51
- package/lib/sagas/effects/observeEach.js +0 -45
- package/lib/sagas/effects/observeOnce.d.ts +0 -3
- package/lib/sagas/effects/observeOnce.d.ts.map +0 -1
- package/lib/sagas/effects/observeOnce.js +0 -42
- package/lib/sagas/effects/whileConnected.d.ts +0 -7
- package/lib/sagas/effects/whileConnected.d.ts.map +0 -1
- package/lib/sagas/effects/whileConnected.js +0 -55
- package/lib/sagas/emitTypingIndicatorToPostActivitySaga.js +0 -63
- package/lib/sagas/markAllAsSpokenOnStopSpeakActivitySaga.js +0 -78
- package/lib/sagas/observeActivitySaga.d.ts +0 -2
- package/lib/sagas/observeActivitySaga.d.ts.map +0 -1
- package/lib/sagas/observeActivitySaga.js +0 -117
- package/lib/sagas/postActivitySaga.d.ts +0 -3
- package/lib/sagas/postActivitySaga.d.ts.map +0 -1
- package/lib/sagas/postActivitySaga.js +0 -264
- package/lib/sagas/queueIncomingActivitySaga.d.ts +0 -3
- package/lib/sagas/queueIncomingActivitySaga.d.ts.map +0 -1
- package/lib/sagas/queueIncomingActivitySaga.js +0 -197
- package/lib/sagas/sendEventToPostActivitySaga.js +0 -68
- package/lib/sagas/sendFilesToPostActivitySaga.js +0 -85
- package/lib/sagas/sendMessageBackToPostActivitySaga.js +0 -70
- package/lib/sagas/sendMessageToPostActivitySaga.d.ts +0 -2
- package/lib/sagas/sendMessageToPostActivitySaga.d.ts.map +0 -1
- package/lib/sagas/sendMessageToPostActivitySaga.js +0 -91
- package/lib/sagas/sendPostBackToPostActivitySaga.js +0 -69
- package/lib/sagas/sendTypingIndicatorOnSetSendBoxSaga.d.ts +0 -3
- package/lib/sagas/sendTypingIndicatorOnSetSendBoxSaga.d.ts.map +0 -1
- package/lib/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +0 -145
- package/lib/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +0 -106
- package/lib/sagas/startDictateOnSpeakCompleteSaga.js +0 -65
- package/lib/sagas/startSpeakActivityOnPostActivitySaga.js +0 -62
- package/lib/sagas/stopDictateOnCardActionSaga.js +0 -65
- package/lib/sagas/stopSpeakingActivityOnInputSaga.js +0 -68
- package/lib/sagas/submitSendBoxSaga.js +0 -84
- package/lib/selectors/activities.d.ts +0 -9
- package/lib/selectors/activities.d.ts.map +0 -1
- package/lib/selectors/activities.js +0 -33
- package/lib/selectors/combineSelectors.js +0 -31
- package/lib/selectors/dictateState.js +0 -12
- package/lib/selectors/language.d.ts +0 -4
- package/lib/selectors/language.d.ts.map +0 -1
- package/lib/selectors/language.js +0 -12
- package/lib/selectors/notifications.js +0 -13
- package/lib/selectors/sendBoxAttachments.js +0 -11
- package/lib/selectors/sendBoxValue.js +0 -12
- package/lib/selectors/sendTimeout.d.ts +0 -4
- package/lib/selectors/sendTimeout.d.ts.map +0 -1
- package/lib/selectors/sendTimeout.js +0 -12
- package/lib/selectors/sendTypingIndicator.d.ts +0 -4
- package/lib/selectors/sendTypingIndicator.d.ts.map +0 -1
- package/lib/selectors/sendTypingIndicator.js +0 -12
- package/lib/selectors/shouldSpeakIncomingActivity.js +0 -12
- package/lib/types/AnyAnd.d.ts +0 -2
- package/lib/types/AnyAnd.d.ts.map +0 -1
- package/lib/types/AnyAnd.js +0 -6
- package/lib/types/GlobalScopePonyfill.d.ts +0 -8
- package/lib/types/GlobalScopePonyfill.d.ts.map +0 -1
- package/lib/types/GlobalScopePonyfill.js +0 -6
- package/lib/types/OneOrMany.d.ts +0 -3
- package/lib/types/OneOrMany.d.ts.map +0 -1
- package/lib/types/OneOrMany.js +0 -6
- package/lib/types/SendBoxAttachment.d.ts +0 -5
- package/lib/types/SendBoxAttachment.d.ts.map +0 -1
- package/lib/types/SendBoxAttachment.js +0 -6
- package/lib/types/WebChatActivity.d.ts +0 -128
- package/lib/types/WebChatActivity.d.ts.map +0 -1
- package/lib/types/WebChatActivity.js +0 -6
- package/lib/types/external/DirectLineActivity.d.ts +0 -3
- package/lib/types/external/DirectLineActivity.d.ts.map +0 -1
- package/lib/types/external/DirectLineActivity.js +0 -6
- package/lib/types/external/DirectLineAnimationCard.d.ts +0 -6
- package/lib/types/external/DirectLineAnimationCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineAnimationCard.js +0 -6
- package/lib/types/external/DirectLineAttachment.d.ts +0 -9
- package/lib/types/external/DirectLineAttachment.d.ts.map +0 -1
- package/lib/types/external/DirectLineAttachment.js +0 -6
- package/lib/types/external/DirectLineAudioCard.d.ts +0 -6
- package/lib/types/external/DirectLineAudioCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineAudioCard.js +0 -6
- package/lib/types/external/DirectLineBasicCardEssence.d.ts +0 -12
- package/lib/types/external/DirectLineBasicCardEssence.d.ts.map +0 -1
- package/lib/types/external/DirectLineBasicCardEssence.js +0 -6
- package/lib/types/external/DirectLineCardAction.d.ts +0 -110
- package/lib/types/external/DirectLineCardAction.d.ts.map +0 -1
- package/lib/types/external/DirectLineCardAction.js +0 -6
- package/lib/types/external/DirectLineCardImage.d.ts +0 -8
- package/lib/types/external/DirectLineCardImage.d.ts.map +0 -1
- package/lib/types/external/DirectLineCardImage.js +0 -6
- package/lib/types/external/DirectLineHeroCard.d.ts +0 -6
- package/lib/types/external/DirectLineHeroCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineHeroCard.js +0 -6
- package/lib/types/external/DirectLineJSBotConnection.d.ts +0 -3
- package/lib/types/external/DirectLineJSBotConnection.d.ts.map +0 -1
- package/lib/types/external/DirectLineJSBotConnection.js +0 -6
- package/lib/types/external/DirectLineMediaCardEssence.d.ts +0 -21
- package/lib/types/external/DirectLineMediaCardEssence.d.ts.map +0 -1
- package/lib/types/external/DirectLineMediaCardEssence.js +0 -6
- package/lib/types/external/DirectLineOAuthCard.d.ts +0 -8
- package/lib/types/external/DirectLineOAuthCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineOAuthCard.js +0 -6
- package/lib/types/external/DirectLineReceiptCard.d.ts +0 -28
- package/lib/types/external/DirectLineReceiptCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineReceiptCard.js +0 -6
- package/lib/types/external/DirectLineSignInCard.d.ts +0 -8
- package/lib/types/external/DirectLineSignInCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineSignInCard.js +0 -6
- package/lib/types/external/DirectLineSuggestedAction.d.ts +0 -7
- package/lib/types/external/DirectLineSuggestedAction.d.ts.map +0 -1
- package/lib/types/external/DirectLineSuggestedAction.js +0 -6
- package/lib/types/external/DirectLineThumbnailCard.d.ts +0 -6
- package/lib/types/external/DirectLineThumbnailCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineThumbnailCard.js +0 -6
- package/lib/types/external/DirectLineVideoCard.d.ts +0 -6
- package/lib/types/external/DirectLineVideoCard.d.ts.map +0 -1
- package/lib/types/external/DirectLineVideoCard.js +0 -6
- package/lib/types/external/Observable.d.ts +0 -49
- package/lib/types/external/Observable.d.ts.map +0 -1
- package/lib/types/external/Observable.js +0 -6
- package/lib/types/external/OrgSchema/Action.d.ts +0 -29
- package/lib/types/external/OrgSchema/Action.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/Action.js +0 -38
- package/lib/types/external/OrgSchema/Claim.d.ts +0 -35
- package/lib/types/external/OrgSchema/Claim.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/Claim.js +0 -41
- package/lib/types/external/OrgSchema/CreativeWork.d.ts +0 -57
- package/lib/types/external/OrgSchema/CreativeWork.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/CreativeWork.js +0 -52
- package/lib/types/external/OrgSchema/DefinedTerm.d.ts +0 -26
- package/lib/types/external/OrgSchema/DefinedTerm.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/DefinedTerm.js +0 -33
- package/lib/types/external/OrgSchema/Project.d.ts +0 -20
- package/lib/types/external/OrgSchema/Project.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/Project.js +0 -32
- package/lib/types/external/OrgSchema/Thing.d.ts +0 -53
- package/lib/types/external/OrgSchema/Thing.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/Thing.js +0 -54
- package/lib/types/external/OrgSchema/VoteAction.d.ts +0 -22
- package/lib/types/external/OrgSchema/VoteAction.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/VoteAction.js +0 -34
- package/lib/types/external/OrgSchema/private/orgSchemaProperties.d.ts +0 -3
- package/lib/types/external/OrgSchema/private/orgSchemaProperties.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/private/orgSchemaProperties.js +0 -22
- package/lib/types/external/OrgSchema/private/orgSchemaProperty.d.ts +0 -4
- package/lib/types/external/OrgSchema/private/orgSchemaProperty.d.ts.map +0 -1
- package/lib/types/external/OrgSchema/private/orgSchemaProperty.js +0 -15
- package/lib/types/internal/GlobalScopeClock.d.ts +0 -15
- package/lib/types/internal/GlobalScopeClock.d.ts.map +0 -1
- package/lib/types/internal/GlobalScopeClock.js +0 -6
- package/lib/types/internal/Notification.d.ts +0 -10
- package/lib/types/internal/Notification.d.ts.map +0 -1
- package/lib/types/internal/Notification.js +0 -6
- package/lib/types/internal/ReduxState.d.ts +0 -19
- package/lib/types/internal/ReduxState.d.ts.map +0 -1
- package/lib/types/internal/ReduxState.js +0 -6
- package/lib/types/internal/SendStatus.d.ts +0 -7
- package/lib/types/internal/SendStatus.d.ts.map +0 -1
- package/lib/types/internal/SendStatus.js +0 -19
- package/lib/types/internal/WebChatOutgoingActivity.d.ts +0 -49
- package/lib/types/internal/WebChatOutgoingActivity.d.ts.map +0 -1
- package/lib/types/internal/WebChatOutgoingActivity.js +0 -6
- package/lib/utils/dateToLocaleISOString.d.ts +0 -2
- package/lib/utils/dateToLocaleISOString.d.ts.map +0 -1
- package/lib/utils/dateToLocaleISOString.js +0 -52
- package/lib/utils/deleteKey.d.ts +0 -2
- package/lib/utils/deleteKey.d.ts.map +0 -1
- package/lib/utils/deleteKey.js +0 -30
- package/lib/utils/getOrgSchemaMessage.d.ts +0 -4
- package/lib/utils/getOrgSchemaMessage.d.ts.map +0 -1
- package/lib/utils/getOrgSchemaMessage.js +0 -21
- package/lib/utils/isForbiddenPropertyName.d.ts +0 -2
- package/lib/utils/isForbiddenPropertyName.d.ts.map +0 -1
- package/lib/utils/isForbiddenPropertyName.js +0 -16
- package/lib/utils/onErrorResumeNext.d.ts +0 -3
- package/lib/utils/onErrorResumeNext.d.ts.map +0 -1
- package/lib/utils/onErrorResumeNext.js +0 -19
- package/lib/utils/once.d.ts +0 -2
- package/lib/utils/once.d.ts.map +0 -1
- package/lib/utils/once.js +0 -16
- package/lib/utils/singleToArray.d.ts +0 -2
- package/lib/utils/singleToArray.d.ts.map +0 -1
- package/lib/utils/singleToArray.js +0 -10
- package/lib/utils/sleep.d.ts +0 -3
- package/lib/utils/sleep.d.ts.map +0 -1
- package/lib/utils/sleep.js +0 -12
- package/lib/utils/uniqueID.d.ts +0 -2
- package/lib/utils/uniqueID.d.ts.map +0 -1
- package/lib/utils/uniqueID.js +0 -14
- package/lib/utils/warnOnce.d.ts +0 -2
- package/lib/utils/warnOnce.d.ts.map +0 -1
- package/lib/utils/warnOnce.js +0 -14
- package/src/actions/clearSuggestedActions.js +0 -9
- package/src/actions/setSuggestedActions.js +0 -12
- package/src/constants/DictateState.js +0 -7
- package/src/reducers/createActivitiesReducer.ts +0 -304
- package/src/reducers/private/findBeforeAfter.spec.ts +0 -90
- package/src/reducers/private/findBeforeAfter.ts +0 -30
- package/src/reducers/suggestedActions.js +0 -23
- package/src/types/OneOrMany.ts +0 -3
- package/src/types/external/OrgSchema/Action.spec.ts +0 -35
- package/src/types/external/OrgSchema/Action.ts +0 -52
- package/src/types/external/OrgSchema/Claim.spec.ts +0 -45
- package/src/types/external/OrgSchema/Claim.ts +0 -48
- package/src/types/external/OrgSchema/CreativeWork.parseCreativeWork.spec.ts +0 -51
- package/src/types/external/OrgSchema/CreativeWork.ts +0 -83
- package/src/types/external/OrgSchema/DefinedTerm.ts +0 -37
- package/src/types/external/OrgSchema/Project.parseProject.spec.ts +0 -17
- package/src/types/external/OrgSchema/Project.ts +0 -29
- package/src/types/external/OrgSchema/Thing.parseThing.spec.ts +0 -54
- package/src/types/external/OrgSchema/Thing.ts +0 -94
- package/src/types/external/OrgSchema/VoteAction.spec.ts +0 -35
- package/src/types/external/OrgSchema/VoteAction.ts +0 -31
- package/src/types/external/OrgSchema/private/orgSchemaProperties.spec.ts +0 -41
- package/src/types/external/OrgSchema/private/orgSchemaProperties.ts +0 -23
- package/src/types/external/OrgSchema/private/orgSchemaProperty.spec.ts +0 -21
- package/src/types/external/OrgSchema/private/orgSchemaProperty.ts +0 -6
- package/src/utils/isForbiddenPropertyName.spec.js +0 -6
- package/src/utils/isForbiddenPropertyName.ts +0 -33
- package/src/utils/singleToArray.ts +0 -3
- package/src/utils/warnOnce.ts +0 -5
- /package/src/actions/{connectionStatusUpdate.js → connectionStatusUpdate.ts} +0 -0
- /package/src/actions/{disconnect.js → disconnect.ts} +0 -0
- /package/src/actions/{emitTypingIndicator.js → emitTypingIndicator.ts} +0 -0
- /package/src/actions/{queueIncomingActivity.js → queueIncomingActivity.ts} +0 -0
- /package/src/actions/{reconnect.js → reconnect.ts} +0 -0
- /package/src/actions/{startDictate.js → startDictate.ts} +0 -0
- /package/src/actions/{startSpeakingActivity.js → startSpeakingActivity.ts} +0 -0
- /package/src/actions/{stopDictate.js → stopDictate.ts} +0 -0
- /package/src/actions/{stopSpeakingActivity.js → stopSpeakingActivity.ts} +0 -0
- /package/src/actions/{updateConnectionStatus.js → updateConnectionStatus.ts} +0 -0
package/src/index.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import clearSuggestedActions from './actions/clearSuggestedActions';
|
|
2
1
|
import connect from './actions/connect';
|
|
3
2
|
import disconnect from './actions/disconnect';
|
|
4
3
|
import dismissNotification from './actions/dismissNotification';
|
|
5
4
|
import emitTypingIndicator from './actions/emitTypingIndicator';
|
|
6
5
|
import markActivity from './actions/markActivity';
|
|
6
|
+
import muteVoiceRecording from './actions/muteVoiceRecording';
|
|
7
7
|
import postActivity from './actions/postActivity';
|
|
8
|
+
import postVoiceActivity from './actions/postVoiceActivity';
|
|
9
|
+
import type { VoiceHandler } from './actions/registerVoiceHandler';
|
|
10
|
+
import registerVoiceHandler from './actions/registerVoiceHandler';
|
|
8
11
|
import sendEvent from './actions/sendEvent';
|
|
9
12
|
import sendFiles from './actions/sendFiles';
|
|
10
13
|
import sendMessage from './actions/sendMessage';
|
|
@@ -18,30 +21,50 @@ import setSendBox from './actions/setSendBox';
|
|
|
18
21
|
import setSendBoxAttachments from './actions/setSendBoxAttachments';
|
|
19
22
|
import setSendTimeout from './actions/setSendTimeout';
|
|
20
23
|
import setSendTypingIndicator from './actions/setSendTypingIndicator';
|
|
24
|
+
import type { VoiceState } from './actions/setVoiceState';
|
|
25
|
+
import setVoiceState from './actions/setVoiceState';
|
|
21
26
|
import startDictate from './actions/startDictate';
|
|
22
27
|
import startSpeakingActivity from './actions/startSpeakingActivity';
|
|
28
|
+
import startVoiceRecording from './actions/startVoiceRecording';
|
|
23
29
|
import stopDictate from './actions/stopDictate';
|
|
24
30
|
import stopSpeakingActivity from './actions/stopSpeakingActivity';
|
|
31
|
+
import stopVoiceRecording from './actions/stopVoiceRecording';
|
|
25
32
|
import submitSendBox from './actions/submitSendBox';
|
|
33
|
+
import unmuteVoiceRecording from './actions/unmuteVoiceRecording';
|
|
34
|
+
import unregisterVoiceHandler from './actions/unregisterVoiceHandler';
|
|
26
35
|
import * as ActivityClientState from './constants/ActivityClientState';
|
|
27
36
|
import * as DictateState from './constants/DictateState';
|
|
28
37
|
import createStore, {
|
|
29
38
|
withDevTools as createStoreWithDevTools,
|
|
30
39
|
withOptions as createStoreWithOptions
|
|
31
40
|
} from './createStore';
|
|
32
|
-
import
|
|
33
|
-
import { parseAction } from './types/external/OrgSchema/Action';
|
|
34
|
-
import { parseClaim } from './types/external/OrgSchema/Claim';
|
|
35
|
-
import { parseCreativeWork } from './types/external/OrgSchema/CreativeWork';
|
|
36
|
-
import { parseDefinedTerm } from './types/external/OrgSchema/DefinedTerm';
|
|
37
|
-
import { parseProject } from './types/external/OrgSchema/Project';
|
|
38
|
-
import { parseThing } from './types/external/OrgSchema/Thing';
|
|
39
|
-
import { parseVoteAction } from './types/external/OrgSchema/VoteAction';
|
|
41
|
+
import getActivityLivestreamingMetadata from './utils/getActivityLivestreamingMetadata';
|
|
40
42
|
import getOrgSchemaMessage from './utils/getOrgSchemaMessage';
|
|
41
|
-
import isForbiddenPropertyName from './utils/isForbiddenPropertyName';
|
|
42
43
|
import onErrorResumeNext from './utils/onErrorResumeNext';
|
|
43
|
-
import
|
|
44
|
-
import
|
|
44
|
+
import getVoiceActivityRole from './utils/voiceActivity/getVoiceActivityRole';
|
|
45
|
+
import getVoiceActivityText from './utils/voiceActivity/getVoiceActivityText';
|
|
46
|
+
import isVoiceActivity from './utils/voiceActivity/isVoiceActivity';
|
|
47
|
+
import isVoiceTranscriptActivity from './utils/voiceActivity/isVoiceTranscriptActivity';
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
isForbiddenPropertyName,
|
|
51
|
+
withResolvers,
|
|
52
|
+
type PromiseWithResolvers
|
|
53
|
+
} from '@msinternal/botframework-webchat-base/utils';
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
CLEAR_SUGGESTED_ACTIONS,
|
|
57
|
+
default as clearSuggestedActions,
|
|
58
|
+
clearSuggestedActionsActionSchema,
|
|
59
|
+
type ClearSuggestedActionsAction
|
|
60
|
+
} from './actions/clearSuggestedActions';
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
SET_SUGGESTED_ACTIONS,
|
|
64
|
+
default as setSuggestedActions,
|
|
65
|
+
setSuggestedActionsActionSchema,
|
|
66
|
+
type SetSuggestedActionsAction
|
|
67
|
+
} from './actions/setSuggestedActions';
|
|
45
68
|
|
|
46
69
|
import type { GlobalScopePonyfill } from './types/GlobalScopePonyfill';
|
|
47
70
|
import type { SendBoxAttachment } from './types/SendBoxAttachment';
|
|
@@ -60,44 +83,33 @@ import type { DirectLineSuggestedAction } from './types/external/DirectLineSugge
|
|
|
60
83
|
import type { DirectLineThumbnailCard } from './types/external/DirectLineThumbnailCard';
|
|
61
84
|
import type { DirectLineVideoCard } from './types/external/DirectLineVideoCard';
|
|
62
85
|
import type { Observable } from './types/external/Observable';
|
|
63
|
-
import type { Action as OrgSchemaAction } from './types/external/OrgSchema/Action';
|
|
64
|
-
import type { Claim as OrgSchemaClaim } from './types/external/OrgSchema/Claim';
|
|
65
|
-
import type { CreativeWork as OrgSchemaCreativeWork } from './types/external/OrgSchema/CreativeWork';
|
|
66
|
-
import type { DefinedTerm as OrgSchemaDefinedTerm } from './types/external/OrgSchema/DefinedTerm';
|
|
67
|
-
import type { Project as OrgSchemaProject } from './types/external/OrgSchema/Project';
|
|
68
|
-
import type { Thing as OrgSchemaThing } from './types/external/OrgSchema/Thing';
|
|
69
86
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const moduleFormat = process.env.module_format;
|
|
73
|
-
const version = process.env.npm_package_version;
|
|
87
|
+
/** @deprecated */
|
|
88
|
+
export { singleToArray, type OneOrMany } from '@msinternal/botframework-webchat-base/utils';
|
|
74
89
|
|
|
75
|
-
const
|
|
90
|
+
const Constants = { ActivityClientState, DictateState };
|
|
76
91
|
|
|
77
92
|
export {
|
|
78
|
-
Constants,
|
|
79
|
-
buildInfo,
|
|
80
|
-
clearSuggestedActions,
|
|
81
93
|
connect,
|
|
94
|
+
Constants,
|
|
82
95
|
createStore,
|
|
83
96
|
createStoreWithDevTools,
|
|
84
97
|
createStoreWithOptions,
|
|
85
98
|
disconnect,
|
|
86
99
|
dismissNotification,
|
|
87
100
|
emitTypingIndicator,
|
|
101
|
+
getActivityLivestreamingMetadata,
|
|
88
102
|
getOrgSchemaMessage,
|
|
89
|
-
|
|
103
|
+
getVoiceActivityRole,
|
|
104
|
+
getVoiceActivityText,
|
|
105
|
+
isVoiceActivity,
|
|
106
|
+
isVoiceTranscriptActivity,
|
|
90
107
|
markActivity,
|
|
91
|
-
|
|
108
|
+
muteVoiceRecording,
|
|
92
109
|
onErrorResumeNext,
|
|
93
|
-
parseAction,
|
|
94
|
-
parseClaim,
|
|
95
|
-
parseCreativeWork,
|
|
96
|
-
parseDefinedTerm,
|
|
97
|
-
parseProject,
|
|
98
|
-
parseThing,
|
|
99
|
-
parseVoteAction,
|
|
100
110
|
postActivity,
|
|
111
|
+
postVoiceActivity,
|
|
112
|
+
registerVoiceHandler,
|
|
101
113
|
sendEvent,
|
|
102
114
|
sendFiles,
|
|
103
115
|
sendMessage,
|
|
@@ -111,14 +123,16 @@ export {
|
|
|
111
123
|
setSendBoxAttachments,
|
|
112
124
|
setSendTimeout,
|
|
113
125
|
setSendTypingIndicator,
|
|
114
|
-
|
|
126
|
+
setVoiceState,
|
|
115
127
|
startDictate,
|
|
116
128
|
startSpeakingActivity,
|
|
129
|
+
startVoiceRecording,
|
|
117
130
|
stopDictate,
|
|
118
131
|
stopSpeakingActivity,
|
|
132
|
+
stopVoiceRecording,
|
|
119
133
|
submitSendBox,
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
unmuteVoiceRecording,
|
|
135
|
+
unregisterVoiceHandler
|
|
122
136
|
};
|
|
123
137
|
|
|
124
138
|
export type {
|
|
@@ -137,13 +151,16 @@ export type {
|
|
|
137
151
|
DirectLineVideoCard,
|
|
138
152
|
GlobalScopePonyfill,
|
|
139
153
|
Observable,
|
|
140
|
-
OneOrMany,
|
|
141
|
-
OrgSchemaAction,
|
|
142
|
-
OrgSchemaClaim,
|
|
143
|
-
OrgSchemaCreativeWork,
|
|
144
|
-
OrgSchemaDefinedTerm,
|
|
145
|
-
OrgSchemaProject,
|
|
146
|
-
OrgSchemaThing,
|
|
147
154
|
SendBoxAttachment,
|
|
155
|
+
VoiceHandler,
|
|
156
|
+
VoiceState,
|
|
148
157
|
WebChatActivity
|
|
149
158
|
};
|
|
159
|
+
|
|
160
|
+
// #region Build info
|
|
161
|
+
import buildInfo from './buildInfo';
|
|
162
|
+
|
|
163
|
+
const { object: buildInfoObject, version } = buildInfo;
|
|
164
|
+
|
|
165
|
+
export { buildInfoObject as buildInfo, version };
|
|
166
|
+
// #endregion
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { literal, object, pipe, readonly, union, type InferOutput } from 'valibot';
|
|
2
|
+
|
|
3
|
+
import { suggestedActionsStateSchema } from '../types/suggestedActions';
|
|
4
|
+
import { suggestedActionsOriginActivityStateSchema } from '../types/suggestedActionsOriginActivity';
|
|
5
|
+
|
|
6
|
+
const SET_RAW_STATE = 'WEB_CHAT_INTERNAL/SET_RAW_STATE' as const;
|
|
7
|
+
|
|
8
|
+
const setRawStateActionSchema = pipe(
|
|
9
|
+
object({
|
|
10
|
+
payload: union([
|
|
11
|
+
pipe(
|
|
12
|
+
object({
|
|
13
|
+
name: literal('suggestedActions'),
|
|
14
|
+
state: suggestedActionsStateSchema
|
|
15
|
+
}),
|
|
16
|
+
readonly()
|
|
17
|
+
),
|
|
18
|
+
pipe(
|
|
19
|
+
object({
|
|
20
|
+
name: literal('suggestedActionsOriginActivity'),
|
|
21
|
+
state: suggestedActionsOriginActivityStateSchema
|
|
22
|
+
}),
|
|
23
|
+
readonly()
|
|
24
|
+
)
|
|
25
|
+
]),
|
|
26
|
+
type: literal(SET_RAW_STATE)
|
|
27
|
+
}),
|
|
28
|
+
readonly()
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
type SetRawStateAction = InferOutput<typeof setRawStateActionSchema>;
|
|
32
|
+
|
|
33
|
+
// Due to limitation of TypeScript, we need to specify overloading functions.
|
|
34
|
+
export default function setRawState(
|
|
35
|
+
name: 'suggestedActions',
|
|
36
|
+
state: (SetRawStateAction['payload'] & { name: typeof name })['state']
|
|
37
|
+
): SetRawStateAction;
|
|
38
|
+
|
|
39
|
+
export default function setRawState(
|
|
40
|
+
name: 'suggestedActionsOriginActivity',
|
|
41
|
+
state: (SetRawStateAction['payload'] & { name: typeof name })['state']
|
|
42
|
+
): SetRawStateAction;
|
|
43
|
+
|
|
44
|
+
export default function setRawState(name: SetRawStateAction['payload']['name'], state: any): SetRawStateAction {
|
|
45
|
+
return { payload: { name, state }, type: SET_RAW_STATE };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { SET_RAW_STATE, setRawStateActionSchema, type SetRawStateAction };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { array, custom, pipe, readonly, type InferOutput } from 'valibot';
|
|
2
|
+
|
|
3
|
+
// TODO: Resolve possibly cyclic dependency by moving `types` into a separate package.
|
|
4
|
+
// import { type DirectLineCardAction } from '../../types/external/DirectLineCardAction';
|
|
5
|
+
|
|
6
|
+
// const suggestedActionsStateSchema = pipe(array(custom<DirectLineCardAction>(() => true)), readonly());
|
|
7
|
+
const suggestedActionsStateSchema = pipe(array(custom<any>(() => true)), readonly());
|
|
8
|
+
|
|
9
|
+
type SuggestedActionsState = InferOutput<typeof suggestedActionsStateSchema>;
|
|
10
|
+
|
|
11
|
+
export { suggestedActionsStateSchema, type SuggestedActionsState };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { custom, object, pipe, readonly, undefinedable, type InferOutput } from 'valibot';
|
|
2
|
+
|
|
3
|
+
// TODO: Resolve possibly cyclic dependency by moving `types` into a separate package.
|
|
4
|
+
// import { type WebChatActivity } from '../../types/WebChatActivity';
|
|
5
|
+
|
|
6
|
+
const suggestedActionsOriginActivityStateSchema = pipe(
|
|
7
|
+
object({
|
|
8
|
+
// activity: undefinedable(custom<WebChatActivity>(() => true))
|
|
9
|
+
activity: undefinedable(custom<any>(() => true))
|
|
10
|
+
}),
|
|
11
|
+
readonly()
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
type SuggestedActionsOriginActivityState = InferOutput<typeof suggestedActionsOriginActivityStateSchema>;
|
|
15
|
+
|
|
16
|
+
export { suggestedActionsOriginActivityStateSchema, type SuggestedActionsOriginActivityState };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isForbiddenPropertyName } from '@msinternal/botframework-webchat-base/utils';
|
|
2
|
+
import type { ActionFromReducersMapObject, combineReducers, Reducer, StateFromReducersMapObject } from 'redux';
|
|
3
|
+
import type { GlobalScopePonyfill } from '../../types/GlobalScopePonyfill';
|
|
4
|
+
import type { RestrictedStoreDebugAPI } from '../../types/StoreDebugAPI';
|
|
5
|
+
import type { WebChatActivity } from '../../types/WebChatActivity';
|
|
6
|
+
import createGroupedActivitiesReducer, {
|
|
7
|
+
type GroupedActivitiesAction,
|
|
8
|
+
type GroupedActivitiesState
|
|
9
|
+
} from './createGroupedActivitiesReducer';
|
|
10
|
+
|
|
11
|
+
type ActivitiesState = {
|
|
12
|
+
activities: readonly WebChatActivity[];
|
|
13
|
+
groupedActivities: GroupedActivitiesState;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a reducer by combining slice `activities` and `groupedActivities` to an existing sliced reducer.
|
|
18
|
+
*
|
|
19
|
+
* @param ponyfill
|
|
20
|
+
* @param existingSlicedReducer
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export default function combineActivitiesReducer<M>(
|
|
24
|
+
ponyfill: GlobalScopePonyfill,
|
|
25
|
+
restrictedStoreDebugAPI: RestrictedStoreDebugAPI,
|
|
26
|
+
existingSlicedReducer: ReturnType<typeof combineReducers<M>>
|
|
27
|
+
): Reducer<StateFromReducersMapObject<M> & ActivitiesState, ActionFromReducersMapObject<M> & GroupedActivitiesAction> {
|
|
28
|
+
type ExistingState = StateFromReducersMapObject<M>;
|
|
29
|
+
type ExistingAction = ActionFromReducersMapObject<M>;
|
|
30
|
+
|
|
31
|
+
const groupedActivitiesReducer = createGroupedActivitiesReducer(ponyfill, restrictedStoreDebugAPI);
|
|
32
|
+
|
|
33
|
+
return function (
|
|
34
|
+
state: (ExistingState & ActivitiesState) | undefined,
|
|
35
|
+
action: ExistingAction & GroupedActivitiesAction
|
|
36
|
+
): ExistingState & ActivitiesState {
|
|
37
|
+
const { activities: _activities, groupedActivities, ...existingState } = state ?? {};
|
|
38
|
+
const nextState = existingSlicedReducer(existingState as ExistingState, action);
|
|
39
|
+
const nextGroupedActivities = groupedActivitiesReducer(groupedActivities, action);
|
|
40
|
+
|
|
41
|
+
const existingStateEntries = Object.entries(existingState);
|
|
42
|
+
const nextStateEntries = Object.entries(nextState);
|
|
43
|
+
|
|
44
|
+
const hasChanged =
|
|
45
|
+
!state ||
|
|
46
|
+
!Object.is(state.groupedActivities, nextGroupedActivities) ||
|
|
47
|
+
existingStateEntries.length !== nextStateEntries.length ||
|
|
48
|
+
existingStateEntries.some(
|
|
49
|
+
// Denylisting forbidden property names.
|
|
50
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
51
|
+
([key, value]) => !Object.is(value, isForbiddenPropertyName(key) ? undefined : (nextState as any)[key])
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return hasChanged
|
|
55
|
+
? { ...nextState, activities: nextGroupedActivities.sortedActivities, groupedActivities: nextGroupedActivities }
|
|
56
|
+
: state;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
2
|
+
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, -1] }] */
|
|
3
|
+
|
|
4
|
+
// @ts-ignore No @types/simple-update-in
|
|
5
|
+
import updateIn from 'simple-update-in';
|
|
6
|
+
import { v4 } from 'uuid';
|
|
7
|
+
|
|
8
|
+
import { DELETE_ACTIVITY } from '../../actions/deleteActivity';
|
|
9
|
+
import { INCOMING_ACTIVITY } from '../../actions/incomingActivity';
|
|
10
|
+
import { MARK_ACTIVITY } from '../../actions/markActivity';
|
|
11
|
+
import {
|
|
12
|
+
POST_ACTIVITY_FULFILLED,
|
|
13
|
+
POST_ACTIVITY_IMPEDED,
|
|
14
|
+
POST_ACTIVITY_PENDING,
|
|
15
|
+
POST_ACTIVITY_REJECTED
|
|
16
|
+
} from '../../actions/postActivity';
|
|
17
|
+
import { SENDING, SEND_FAILED, SENT } from '../../types/internal/SendStatus';
|
|
18
|
+
|
|
19
|
+
import type { Reducer } from 'redux';
|
|
20
|
+
import type { DeleteActivityAction } from '../../actions/deleteActivity';
|
|
21
|
+
import type { IncomingActivityAction } from '../../actions/incomingActivity';
|
|
22
|
+
import type { MarkActivityAction } from '../../actions/markActivity';
|
|
23
|
+
import type {
|
|
24
|
+
PostActivityFulfilledAction,
|
|
25
|
+
PostActivityImpededAction,
|
|
26
|
+
PostActivityPendingAction,
|
|
27
|
+
PostActivityRejectedAction
|
|
28
|
+
} from '../../actions/postActivity';
|
|
29
|
+
import type { GlobalScopePonyfill } from '../../types/GlobalScopePonyfill';
|
|
30
|
+
import { type RestrictedStoreDebugAPI } from '../../types/StoreDebugAPI';
|
|
31
|
+
import type { WebChatActivity } from '../../types/WebChatActivity';
|
|
32
|
+
import patchActivity from './patchActivity';
|
|
33
|
+
import deleteActivityByLocalId from './sort/deleteActivityByLocalId';
|
|
34
|
+
import { generateLocalIdInActivity, getLocalIdFromActivity, setLocalIdInActivity } from './sort/property/LocalId';
|
|
35
|
+
import { getPositionFromActivity, setPositionInActivity } from './sort/property/Position';
|
|
36
|
+
import { setReceivedAtInActivity } from './sort/property/ReceivedAt';
|
|
37
|
+
import { querySendStatusFromOutgoingActivity, setSendStatusInOutgoingActivity } from './sort/property/SendStatus';
|
|
38
|
+
import queryLocalIdAByActivityId from './sort/queryLocalIdByActivityId';
|
|
39
|
+
import queryLocalIdAByClientActivityId from './sort/queryLocalIdByClientActivityId';
|
|
40
|
+
import type { State } from './sort/types';
|
|
41
|
+
import updateActivityChannelData, {
|
|
42
|
+
updateActivityChannelDataInternalSkipNameCheck
|
|
43
|
+
} from './sort/updateActivityChannelData';
|
|
44
|
+
import upsert, { INITIAL_STATE } from './sort/upsert';
|
|
45
|
+
|
|
46
|
+
type GroupedActivitiesAction =
|
|
47
|
+
| DeleteActivityAction
|
|
48
|
+
| IncomingActivityAction
|
|
49
|
+
| MarkActivityAction
|
|
50
|
+
| PostActivityFulfilledAction
|
|
51
|
+
| PostActivityImpededAction
|
|
52
|
+
| PostActivityPendingAction
|
|
53
|
+
| PostActivityRejectedAction;
|
|
54
|
+
|
|
55
|
+
type GroupedActivitiesState = State;
|
|
56
|
+
|
|
57
|
+
const DEFAULT_STATE: GroupedActivitiesState = INITIAL_STATE;
|
|
58
|
+
|
|
59
|
+
function getClientActivityID(activity: WebChatActivity): string | undefined {
|
|
60
|
+
return activity.channelData?.clientActivityID;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function createGroupedActivitiesReducer(
|
|
64
|
+
ponyfill: GlobalScopePonyfill,
|
|
65
|
+
restrictedStoreDebugAPI: RestrictedStoreDebugAPI
|
|
66
|
+
): Reducer<GroupedActivitiesState, GroupedActivitiesAction> {
|
|
67
|
+
return function activities(
|
|
68
|
+
state: GroupedActivitiesState = DEFAULT_STATE,
|
|
69
|
+
action: GroupedActivitiesAction
|
|
70
|
+
): GroupedActivitiesState {
|
|
71
|
+
switch (action.type) {
|
|
72
|
+
case DELETE_ACTIVITY: {
|
|
73
|
+
console.warn(
|
|
74
|
+
'botframework-webchat: Delete activity is being deprecated, please build your own chat adapter instead.'
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const localId = queryLocalIdAByActivityId(state, action.payload.activityID);
|
|
78
|
+
|
|
79
|
+
if (localId) {
|
|
80
|
+
state = deleteActivityByLocalId(state, localId);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case MARK_ACTIVITY: {
|
|
87
|
+
// We need to deprecate this, however, it is currently using by speech.
|
|
88
|
+
|
|
89
|
+
const localId = queryLocalIdAByActivityId(state, action.payload.activityID);
|
|
90
|
+
|
|
91
|
+
if (localId) {
|
|
92
|
+
state = updateActivityChannelData(state, localId, action.payload.name, action.payload.value);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case POST_ACTIVITY_PENDING: {
|
|
99
|
+
let {
|
|
100
|
+
payload: { activity }
|
|
101
|
+
} = action;
|
|
102
|
+
|
|
103
|
+
// Patch activity so the outgoing blob: URL is not re-downloadable.
|
|
104
|
+
// Related to /__tests__/html2/accessibility/liveRegion/attachment/file.
|
|
105
|
+
|
|
106
|
+
// Why not re-downloadable?
|
|
107
|
+
// - When the activity echo back, the URL will be dummy (not downloadable)
|
|
108
|
+
// - Outgoing -> echo back, the UI will be "downloadable" and flash to "not downloadable" in a short amount of time
|
|
109
|
+
|
|
110
|
+
// TODO: [P0] Consider modify attachment middleware so all outgoing activity is not downloadable.
|
|
111
|
+
|
|
112
|
+
activity = patchActivity(activity, ponyfill);
|
|
113
|
+
activity = setReceivedAtInActivity(activity, ponyfill.Date.now());
|
|
114
|
+
activity = generateLocalIdInActivity(activity);
|
|
115
|
+
// `channelData.state` is being deprecated in favor of `channelData['webchat:send-status']`.
|
|
116
|
+
// Please refer to #4362 for details. Remove on or after 2024-07-31.
|
|
117
|
+
activity = updateIn(activity, ['channelData', 'state'], () => SENDING);
|
|
118
|
+
activity = setSendStatusInOutgoingActivity(activity, SENDING);
|
|
119
|
+
|
|
120
|
+
state = upsert(ponyfill, state, activity);
|
|
121
|
+
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case POST_ACTIVITY_IMPEDED: {
|
|
126
|
+
const localId = queryLocalIdAByClientActivityId(state, action.meta.clientActivityID);
|
|
127
|
+
|
|
128
|
+
if (localId) {
|
|
129
|
+
state = updateActivityChannelDataInternalSkipNameCheck(
|
|
130
|
+
state,
|
|
131
|
+
localId,
|
|
132
|
+
// `channelData.state` is being deprecated in favor of `channelData['webchat:send-status']`.
|
|
133
|
+
// Please refer to #4362 for details. Remove on or after 2024-07-31.
|
|
134
|
+
'state',
|
|
135
|
+
SEND_FAILED
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
case POST_ACTIVITY_REJECTED: {
|
|
143
|
+
const localId = queryLocalIdAByClientActivityId(state, action.meta.clientActivityID);
|
|
144
|
+
|
|
145
|
+
if (localId) {
|
|
146
|
+
state = updateActivityChannelDataInternalSkipNameCheck(state, localId, 'state', SEND_FAILED);
|
|
147
|
+
state = updateActivityChannelDataInternalSkipNameCheck(state, localId, 'webchat:send-status', SEND_FAILED);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
case POST_ACTIVITY_FULFILLED: {
|
|
154
|
+
const localId = queryLocalIdAByClientActivityId(state, action.meta.clientActivityID);
|
|
155
|
+
|
|
156
|
+
const existingActivity = localId && state.activityMap.get(localId)?.activity;
|
|
157
|
+
|
|
158
|
+
if (!existingActivity) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
'botframework-webchat-internal: On POST_ACTIVITY_FULFILLED, there is no activities with same client activity ID'
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// We will replace the outgoing activity with the version from the server
|
|
165
|
+
let activity = patchActivity(action.payload.activity, ponyfill);
|
|
166
|
+
|
|
167
|
+
activity = updateIn(
|
|
168
|
+
activity,
|
|
169
|
+
// `channelData.state` is being deprecated in favor of `channelData['webchat:send-status']`.
|
|
170
|
+
// Please refer to #4362 for details. Remove on or after 2024-07-31.
|
|
171
|
+
['channelData', 'state'],
|
|
172
|
+
() => SENT
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
activity = setSendStatusInOutgoingActivity(activity, SENT);
|
|
176
|
+
activity = setLocalIdInActivity(activity, localId);
|
|
177
|
+
|
|
178
|
+
// Keep existing position.
|
|
179
|
+
activity = setPositionInActivity(activity, getPositionFromActivity(existingActivity));
|
|
180
|
+
|
|
181
|
+
// Compare the INCOMING_ACTIVITY below:
|
|
182
|
+
// - POST_ACTIVITY_FULFILLED will mark send status as SENT
|
|
183
|
+
// - INCOMING_ACTIVITY will not change send status and leave it as-is
|
|
184
|
+
state = upsert(ponyfill, state, activity);
|
|
185
|
+
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
case INCOMING_ACTIVITY: {
|
|
190
|
+
let {
|
|
191
|
+
payload: { activity }
|
|
192
|
+
} = action;
|
|
193
|
+
|
|
194
|
+
// We cannot call breakpoint inside Redux because DebugContext cannot call getState(), need setTimeout.
|
|
195
|
+
queueMicrotask(() => restrictedStoreDebugAPI.UNSAFE_callBreakpoint.incomingActivity({ activity }));
|
|
196
|
+
|
|
197
|
+
activity = patchActivity(activity, ponyfill);
|
|
198
|
+
|
|
199
|
+
// Clean internal properties if they were passed from chat adapter.
|
|
200
|
+
// These properties should not be passed from external systems.
|
|
201
|
+
activity = setLocalIdInActivity(activity, undefined);
|
|
202
|
+
activity = setPositionInActivity(activity, undefined);
|
|
203
|
+
activity = setSendStatusInOutgoingActivity(activity, undefined);
|
|
204
|
+
|
|
205
|
+
// If the incoming activity is an echo back, we should keep the existing `channelData['webchat:send-status']` field.
|
|
206
|
+
//
|
|
207
|
+
// Otherwise, it will fail following scenario:
|
|
208
|
+
//
|
|
209
|
+
// 1. Send an activity to the service
|
|
210
|
+
// 2. Service echoed back the activity
|
|
211
|
+
// 3. Service did NOT return `postActivity` call
|
|
212
|
+
// - EXPECT: `channelData['webchat:send-status']` should be "sending".
|
|
213
|
+
// - ACTUAL: `channelData['webchat:send-status']` is `undefined` because the activity get overwritten by the echo back activity.
|
|
214
|
+
// The echo back activity contains no `channelData['webchat:send-status']`.
|
|
215
|
+
//
|
|
216
|
+
// While we are looking out for the scenario above, we should also look at the following scenarios:
|
|
217
|
+
//
|
|
218
|
+
// 1. Service restore chat history, including activities sent from the user. These activities has the following characteristics:
|
|
219
|
+
// - They do not have `channelData['webchat:send-status']`;
|
|
220
|
+
// - They do not have an ongoing `postActivitySaga`;
|
|
221
|
+
// - They should not previously appear in the chat history.
|
|
222
|
+
// 2. We need to mark these activities as "sent".
|
|
223
|
+
//
|
|
224
|
+
// In the future, when we revamp our object model, we could use a different signal so we don't need the code below, for example:
|
|
225
|
+
//
|
|
226
|
+
// - If `activity.id` is set, it is "sent", because the chat service assigned an ID to the activity;
|
|
227
|
+
// - If `activity.id` is not set, it is either "sending" or "send failed";
|
|
228
|
+
// - If `activity.channelData['webchat:send-failed-reason']` is set, it is "send failed" with the reason, otherwise;
|
|
229
|
+
// - It is sending.
|
|
230
|
+
if (activity.from.role === 'user') {
|
|
231
|
+
const { id } = activity;
|
|
232
|
+
const clientActivityID = getClientActivityID(activity);
|
|
233
|
+
|
|
234
|
+
const existingLocalId = clientActivityID
|
|
235
|
+
? queryLocalIdAByClientActivityId(state, clientActivityID)
|
|
236
|
+
: id
|
|
237
|
+
? queryLocalIdAByActivityId(state, id)
|
|
238
|
+
: undefined;
|
|
239
|
+
const existingActivity = existingLocalId && state.activityMap.get(existingLocalId)?.activity;
|
|
240
|
+
|
|
241
|
+
if (existingActivity) {
|
|
242
|
+
activity = setLocalIdInActivity(activity, getLocalIdFromActivity(existingActivity));
|
|
243
|
+
|
|
244
|
+
const existingSendStatus = querySendStatusFromOutgoingActivity(existingActivity);
|
|
245
|
+
|
|
246
|
+
if (typeof existingSendStatus !== 'undefined') {
|
|
247
|
+
activity = setSendStatusInOutgoingActivity(activity, existingSendStatus);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
activity = generateLocalIdInActivity(activity);
|
|
251
|
+
|
|
252
|
+
// If there are no existing activity, probably this activity is restored from chat history.
|
|
253
|
+
// All outgoing activities restored from service means they arrived at the service successfully.
|
|
254
|
+
// Thus, we are marking them as "sent".
|
|
255
|
+
activity = setSendStatusInOutgoingActivity(activity, SENT);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
let { id } = activity;
|
|
259
|
+
|
|
260
|
+
if (!id) {
|
|
261
|
+
id = v4();
|
|
262
|
+
|
|
263
|
+
console.warn(
|
|
264
|
+
'botframework-webchat: Incoming activity must have "id" field set, assigning a random value as ID',
|
|
265
|
+
{
|
|
266
|
+
activity,
|
|
267
|
+
newActivityId: id
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
activity = updateIn(activity, ['id'], () => id);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const existingLocalId = queryLocalIdAByActivityId(state, id);
|
|
275
|
+
|
|
276
|
+
if (existingLocalId) {
|
|
277
|
+
activity = setLocalIdInActivity(activity, existingLocalId);
|
|
278
|
+
} else {
|
|
279
|
+
activity = generateLocalIdInActivity(activity);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
state = upsert(ponyfill, state, activity);
|
|
284
|
+
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
default:
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return state;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export default createGroupedActivitiesReducer;
|
|
297
|
+
export type { GroupedActivitiesAction, GroupedActivitiesState };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @ts-ignore No @types/simple-update-in
|
|
2
|
+
import updateIn from 'simple-update-in';
|
|
3
|
+
import type { GlobalScopePonyfill } from '../../types/GlobalScopePonyfill';
|
|
4
|
+
import type { WebChatActivity } from '../../types/WebChatActivity';
|
|
5
|
+
import { setReceivedAtInActivity } from './sort/property/ReceivedAt';
|
|
6
|
+
|
|
7
|
+
const DIRECT_LINE_PLACEHOLDER_URL =
|
|
8
|
+
'https://docs.botframework.com/static/devportal/client/images/bot-framework-default-placeholder.png';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Patches incoming activity.
|
|
12
|
+
*
|
|
13
|
+
* @returns A patched activity.
|
|
14
|
+
*/
|
|
15
|
+
export default function patchActivity(activity: WebChatActivity, { Date }: GlobalScopePonyfill): WebChatActivity {
|
|
16
|
+
// Direct Line channel will return a placeholder image for the user-uploaded image.
|
|
17
|
+
// As observed, the URL for the placeholder image is https://docs.botframework.com/static/devportal/client/images/bot-framework-default-placeholder.png.
|
|
18
|
+
// To make our code simpler, we are removing the value if "contentUrl" is pointing to a placeholder image.
|
|
19
|
+
|
|
20
|
+
// TODO: [P2] #2869 This "contentURL" removal code should be moved to DirectLineJS adapter.
|
|
21
|
+
|
|
22
|
+
// Also, if the "contentURL" starts with "blob:", this means the user is uploading a file (the URL is constructed by URL.createObjectURL)
|
|
23
|
+
// Although the copy/reference of the file is temporary in-memory, to make the UX consistent across page refresh, we do not allow the user to re-download the file either.
|
|
24
|
+
|
|
25
|
+
activity = updateIn(activity, ['attachments', () => true, 'contentUrl'], (contentUrl: string) => {
|
|
26
|
+
if (contentUrl !== DIRECT_LINE_PLACEHOLDER_URL && !/^blob:/iu.test(contentUrl)) {
|
|
27
|
+
return contentUrl;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return undefined;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
activity = updateIn(activity, ['channelData'], (channelData: any) => ({ ...channelData }));
|
|
34
|
+
activity = setReceivedAtInActivity(activity, Date.now());
|
|
35
|
+
|
|
36
|
+
return activity;
|
|
37
|
+
}
|