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
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
export type GlobalScopeClock = {
|
|
2
2
|
// eslint-disable-next-line no-restricted-globals
|
|
3
|
-
cancelAnimationFrame?: typeof cancelAnimationFrame;
|
|
3
|
+
cancelAnimationFrame?: typeof cancelAnimationFrame | undefined;
|
|
4
4
|
// eslint-disable-next-line no-restricted-globals
|
|
5
|
-
cancelIdleCallback?: typeof cancelIdleCallback;
|
|
5
|
+
cancelIdleCallback?: typeof cancelIdleCallback | undefined;
|
|
6
6
|
// eslint-disable-next-line no-restricted-globals
|
|
7
|
-
clearImmediate?: typeof clearImmediate;
|
|
7
|
+
clearImmediate?: typeof clearImmediate | undefined;
|
|
8
8
|
// eslint-disable-next-line no-restricted-globals
|
|
9
|
-
clearInterval
|
|
9
|
+
clearInterval?: typeof clearInterval | undefined;
|
|
10
10
|
// eslint-disable-next-line no-restricted-globals
|
|
11
|
-
clearTimeout
|
|
11
|
+
clearTimeout?: typeof clearTimeout | undefined;
|
|
12
12
|
// eslint-disable-next-line no-restricted-globals
|
|
13
13
|
Date: typeof Date;
|
|
14
14
|
// eslint-disable-next-line no-restricted-globals
|
|
15
|
-
requestAnimationFrame?: typeof requestAnimationFrame;
|
|
15
|
+
requestAnimationFrame?: typeof requestAnimationFrame | undefined;
|
|
16
16
|
// eslint-disable-next-line no-restricted-globals
|
|
17
|
-
requestIdleCallback?: typeof requestIdleCallback;
|
|
17
|
+
requestIdleCallback?: typeof requestIdleCallback | undefined;
|
|
18
18
|
// eslint-disable-next-line no-restricted-globals
|
|
19
|
-
setImmediate?: typeof setImmediate;
|
|
19
|
+
setImmediate?: typeof setImmediate | undefined;
|
|
20
20
|
// eslint-disable-next-line no-restricted-globals
|
|
21
|
-
setInterval
|
|
21
|
+
setInterval?: typeof setInterval | undefined;
|
|
22
22
|
// eslint-disable-next-line no-restricted-globals
|
|
23
|
-
setTimeout
|
|
23
|
+
setTimeout?: typeof setTimeout | undefined;
|
|
24
24
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type sendBoxAttachments from '../../reducers/sendBoxAttachments';
|
|
2
|
+
import type { State } from '../../reducers/activities/sort/types';
|
|
2
3
|
import type { WebChatActivity } from '../WebChatActivity';
|
|
3
4
|
import type { Notification } from './Notification';
|
|
4
5
|
|
|
@@ -7,6 +8,7 @@ type ReduxState = {
|
|
|
7
8
|
activities: WebChatActivity[];
|
|
8
9
|
clockSkewAdjustment: number;
|
|
9
10
|
dictateState: string;
|
|
11
|
+
groupedActivities: State;
|
|
10
12
|
language: string;
|
|
11
13
|
notifications: { [key: string]: Notification };
|
|
12
14
|
sendBoxAttachments: ReturnType<typeof sendBoxAttachments>;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @jest-environment ../../../__tests__/setup/
|
|
2
|
+
* @jest-environment ../../../__tests__/unit.setup/JestNodeEnvironmentWithTimeZone.js
|
|
3
3
|
* @timezone Pacific/Chatham
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
7
|
|
|
8
8
|
test('formatting a time in Chatham Islands timezone', () => {
|
|
9
|
-
// eslint-disable-next-line no-magic-numbers
|
|
10
9
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
11
10
|
const actual = dateToLocaleISOString(date);
|
|
12
11
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @jest-environment ../../../__tests__/setup/
|
|
2
|
+
* @jest-environment ../../../__tests__/unit.setup/JestNodeEnvironmentWithTimeZone.js
|
|
3
3
|
* @timezone Asia/Tokyo
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
7
|
|
|
8
8
|
test('formatting a time in Japan timezone', () => {
|
|
9
|
-
// eslint-disable-next-line no-magic-numbers
|
|
10
9
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
11
10
|
const actual = dateToLocaleISOString(date);
|
|
12
11
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @jest-environment ../../../__tests__/setup/
|
|
2
|
+
* @jest-environment ../../../__tests__/unit.setup/JestNodeEnvironmentWithTimeZone.js
|
|
3
3
|
* @timezone America/St_Johns
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
7
|
|
|
8
8
|
test('formatting a time in Cananda, Newfoundland timezone', () => {
|
|
9
|
-
// eslint-disable-next-line no-magic-numbers
|
|
10
9
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
11
10
|
const actual = dateToLocaleISOString(date);
|
|
12
11
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @jest-environment ../../../__tests__/setup/
|
|
2
|
+
* @jest-environment ../../../__tests__/unit.setup/JestNodeEnvironmentWithTimeZone.js
|
|
3
3
|
* @timezone America/Los_Angeles
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
7
|
|
|
8
8
|
test('formatting a time in Pacific Standard Time timezone', () => {
|
|
9
|
-
// eslint-disable-next-line no-magic-numbers
|
|
10
9
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
11
10
|
const actual = dateToLocaleISOString(date);
|
|
12
11
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @jest-environment ../../../__tests__/setup/
|
|
2
|
+
* @jest-environment ../../../__tests__/unit.setup/JestNodeEnvironmentWithTimeZone.js
|
|
3
3
|
* @timezone Etc/UTC
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
7
|
|
|
8
8
|
test('formatting a time in UTC timezone', () => {
|
|
9
|
-
// eslint-disable-next-line no-magic-numbers
|
|
10
9
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
11
10
|
const actual = dateToLocaleISOString(date);
|
|
12
11
|
|
|
@@ -14,7 +13,6 @@ test('formatting a time in UTC timezone', () => {
|
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
test('formatting a time in UTC timezone with zero milliseconds', () => {
|
|
17
|
-
// eslint-disable-next-line no-magic-numbers
|
|
18
16
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 0));
|
|
19
17
|
const actual = dateToLocaleISOString(date);
|
|
20
18
|
|
package/src/utils/deleteKey.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import isForbiddenPropertyName from '
|
|
1
|
+
import { isForbiddenPropertyName } from '@msinternal/botframework-webchat-base/utils';
|
|
2
2
|
|
|
3
3
|
export default function deleteKey<TMap, TKey extends keyof TMap>(map: TMap, ...keys: TKey[]): Omit<TMap, TKey> {
|
|
4
4
|
if (!map) {
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { type ArraySlice } from 'type-fest';
|
|
2
|
+
|
|
3
|
+
import { type WebChatActivity } from '../types/WebChatActivity';
|
|
4
|
+
import getActivityLivestreamingMetadata from './getActivityLivestreamingMetadata';
|
|
5
|
+
|
|
6
|
+
function injectInto<T>(
|
|
7
|
+
where: 'channelData' | 'entities',
|
|
8
|
+
metadata: T,
|
|
9
|
+
activity: Partial<WebChatActivity>
|
|
10
|
+
): WebChatActivity {
|
|
11
|
+
return {
|
|
12
|
+
...(where === 'entities' ? { entities: [{ ...metadata, type: 'streaminfo' }] } : { channelData: metadata }),
|
|
13
|
+
...activity
|
|
14
|
+
} as WebChatActivity;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe.each([['channelData' as const], ['entities' as const]])('using %s', where => {
|
|
18
|
+
let inject: (...args: ArraySlice<Parameters<typeof injectInto>, 1>) => ReturnType<typeof injectInto>;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
inject = injectInto.bind(undefined, where);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe.each([['with "streamId"' as const], ['without "streamId"' as const]])('activity %s', variant => {
|
|
25
|
+
describe('activity with "streamType" of "streaming"', () => {
|
|
26
|
+
let activity: WebChatActivity;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
activity = inject(
|
|
30
|
+
{
|
|
31
|
+
...(variant === 'with "streamId"' ? { streamId: 'a-00001' } : {}),
|
|
32
|
+
streamSequence: 1,
|
|
33
|
+
streamType: 'streaming'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'a-00002',
|
|
37
|
+
text: 'Hello, World!',
|
|
38
|
+
type: 'typing'
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('should return type of "interim activity"', () =>
|
|
44
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('type', 'interim activity'));
|
|
45
|
+
test('should return sequence number', () =>
|
|
46
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sequenceNumber', 1));
|
|
47
|
+
|
|
48
|
+
if (variant === 'with "streamId"') {
|
|
49
|
+
test('should return session ID with value from "channelData.streamId"', () =>
|
|
50
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sessionId', 'a-00001'));
|
|
51
|
+
} else {
|
|
52
|
+
test('should return session ID with value of "activity.id"', () =>
|
|
53
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sessionId', 'a-00002'));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('activity with "streamType" of "informative message"', () => {
|
|
58
|
+
let activity: WebChatActivity;
|
|
59
|
+
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
activity = inject(
|
|
62
|
+
{
|
|
63
|
+
...(variant === 'with "streamId"' ? { streamId: 'a-00001' } : {}),
|
|
64
|
+
streamSequence: 1,
|
|
65
|
+
streamType: 'informative'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'a-00002',
|
|
69
|
+
text: 'Hello, World!',
|
|
70
|
+
type: 'typing'
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('should return type of "informative message"', () =>
|
|
76
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('type', 'informative message'));
|
|
77
|
+
test('should return sequence number', () =>
|
|
78
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sequenceNumber', 1));
|
|
79
|
+
|
|
80
|
+
if (variant === 'with "streamId"') {
|
|
81
|
+
test('should return session ID with value from "channelData.streamId"', () =>
|
|
82
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sessionId', 'a-00001'));
|
|
83
|
+
} else {
|
|
84
|
+
test('should return session ID with value of "activity.id"', () =>
|
|
85
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sessionId', 'a-00002'));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('activity with "streamType" of "final"', () => {
|
|
90
|
+
let activity: WebChatActivity;
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
activity = inject(
|
|
94
|
+
{
|
|
95
|
+
...(variant === 'with "streamId"' ? { streamId: 'a-00001' } : {}),
|
|
96
|
+
streamType: 'final'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'a-00002',
|
|
100
|
+
text: 'Hello, World!',
|
|
101
|
+
type: 'message'
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (variant === 'with "streamId"') {
|
|
107
|
+
test('should return type of "final activity"', () =>
|
|
108
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('type', 'final activity'));
|
|
109
|
+
test('should return sequence number of Infinity', () =>
|
|
110
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sequenceNumber', Infinity));
|
|
111
|
+
test('should return session ID', () =>
|
|
112
|
+
expect(getActivityLivestreamingMetadata(activity)).toHaveProperty('sessionId', 'a-00001'));
|
|
113
|
+
} else {
|
|
114
|
+
// Final activity must have "streamId". Final activity without "streamId" is not a valid livestream activity.
|
|
115
|
+
test('should return undefined', () => expect(getActivityLivestreamingMetadata(activity)).toBeUndefined());
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('activity with "streamType" of "streaming" without critical fields should return undefined', () =>
|
|
121
|
+
expect(
|
|
122
|
+
getActivityLivestreamingMetadata(
|
|
123
|
+
inject(
|
|
124
|
+
{
|
|
125
|
+
streamType: 'streaming'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: 'typing'
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
).toBeUndefined());
|
|
133
|
+
|
|
134
|
+
test.each([
|
|
135
|
+
['integer', 1, true],
|
|
136
|
+
['zero', 0, false],
|
|
137
|
+
['decimal', 1.234, false]
|
|
138
|
+
])('activity with %s "streamSequence" should return undefined', (_, streamSequence, isValid) => {
|
|
139
|
+
const activity = inject(
|
|
140
|
+
{
|
|
141
|
+
streamId: 'a-00001',
|
|
142
|
+
streamSequence,
|
|
143
|
+
streamType: 'streaming'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: 'a-00002',
|
|
147
|
+
text: '',
|
|
148
|
+
type: 'typing'
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (isValid) {
|
|
153
|
+
expect(getActivityLivestreamingMetadata(activity)).toBeTruthy();
|
|
154
|
+
} else {
|
|
155
|
+
expect(getActivityLivestreamingMetadata(activity)).toBeUndefined();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe('"typing" activity with "streamType" of "final"', () => {
|
|
160
|
+
test('should return undefined if "text" field is defined', () =>
|
|
161
|
+
expect(
|
|
162
|
+
getActivityLivestreamingMetadata(
|
|
163
|
+
inject(
|
|
164
|
+
{
|
|
165
|
+
streamId: 'a-00001',
|
|
166
|
+
streamType: 'final'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'a-00002',
|
|
170
|
+
text: 'Final "typing" activity, must not have "text".',
|
|
171
|
+
type: 'typing'
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
).toBeUndefined());
|
|
176
|
+
|
|
177
|
+
test('should return truthy if "text" field is not defined', () =>
|
|
178
|
+
expect(
|
|
179
|
+
getActivityLivestreamingMetadata(
|
|
180
|
+
inject(
|
|
181
|
+
{
|
|
182
|
+
streamId: 'a-00001',
|
|
183
|
+
streamType: 'final'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: 'a-00002',
|
|
187
|
+
// Final activity can be "typing" if it does not have "text".
|
|
188
|
+
type: 'typing'
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
).toHaveProperty('type', 'final activity'));
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('activity with "streamType" of "streaming" without "content" should return type of "contentless"', () =>
|
|
196
|
+
expect(
|
|
197
|
+
getActivityLivestreamingMetadata(
|
|
198
|
+
inject(
|
|
199
|
+
{
|
|
200
|
+
streamSequence: 1,
|
|
201
|
+
streamType: 'streaming'
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: 'a-00001',
|
|
205
|
+
type: 'typing'
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
).toHaveProperty('type', 'contentless'));
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('invalid activity should return undefined', () =>
|
|
213
|
+
expect(getActivityLivestreamingMetadata('invalid' as any)).toBeUndefined());
|
|
214
|
+
|
|
215
|
+
test('should prefer channelData over entities', () =>
|
|
216
|
+
expect(
|
|
217
|
+
getActivityLivestreamingMetadata({
|
|
218
|
+
channelData: {
|
|
219
|
+
streamId: 'a-channelData',
|
|
220
|
+
streamSequence: 2,
|
|
221
|
+
streamType: 'streaming'
|
|
222
|
+
},
|
|
223
|
+
entities: [
|
|
224
|
+
{
|
|
225
|
+
streamId: 'a-entities',
|
|
226
|
+
streamSequence: 2,
|
|
227
|
+
streamType: 'streaming',
|
|
228
|
+
type: 'streaminfo'
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
id: 'a-00002',
|
|
232
|
+
type: 'typing'
|
|
233
|
+
} as any)
|
|
234
|
+
).toHaveProperty('sessionId', 'a-channelData'));
|
|
235
|
+
|
|
236
|
+
test('should prefer first entity', () =>
|
|
237
|
+
expect(
|
|
238
|
+
getActivityLivestreamingMetadata({
|
|
239
|
+
entities: [
|
|
240
|
+
{
|
|
241
|
+
streamId: 'a-first',
|
|
242
|
+
streamSequence: 2,
|
|
243
|
+
streamType: 'streaming',
|
|
244
|
+
type: 'streaminfo'
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
streamId: 'a-second',
|
|
248
|
+
streamSequence: 2,
|
|
249
|
+
streamType: 'streaming',
|
|
250
|
+
type: 'streaminfo'
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
id: 'a-00002',
|
|
254
|
+
type: 'typing'
|
|
255
|
+
} as any)
|
|
256
|
+
).toHaveProperty('sessionId', 'a-first'));
|
|
257
|
+
|
|
258
|
+
test('channelData-based livestreaming metadata should be harmony with other entities', () =>
|
|
259
|
+
expect(
|
|
260
|
+
getActivityLivestreamingMetadata({
|
|
261
|
+
channelData: {
|
|
262
|
+
streamSequence: 1,
|
|
263
|
+
streamType: 'streaming'
|
|
264
|
+
},
|
|
265
|
+
entities: [
|
|
266
|
+
{
|
|
267
|
+
'@context': 'https://schema.org',
|
|
268
|
+
'@id': '',
|
|
269
|
+
'@type': 'Message',
|
|
270
|
+
type: 'https://schema.org/Message'
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
id: 'a-00001',
|
|
274
|
+
type: 'typing'
|
|
275
|
+
} as any)
|
|
276
|
+
).toHaveProperty('sequenceNumber', 1));
|
|
277
|
+
|
|
278
|
+
test('entity-based livestreaming metadata should be harmony with other entities', () =>
|
|
279
|
+
expect(
|
|
280
|
+
getActivityLivestreamingMetadata({
|
|
281
|
+
entities: [
|
|
282
|
+
{
|
|
283
|
+
'@context': 'https://schema.org',
|
|
284
|
+
'@id': '',
|
|
285
|
+
'@type': 'Message',
|
|
286
|
+
type: 'https://schema.org/Message'
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
streamSequence: 1,
|
|
290
|
+
streamType: 'streaming',
|
|
291
|
+
type: 'streaminfo'
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
id: 'a-00001',
|
|
295
|
+
type: 'typing'
|
|
296
|
+
} as any)
|
|
297
|
+
).toHaveProperty('sequenceNumber', 1));
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
any,
|
|
3
|
+
array,
|
|
4
|
+
check,
|
|
5
|
+
findItem,
|
|
6
|
+
integer,
|
|
7
|
+
is,
|
|
8
|
+
literal,
|
|
9
|
+
minValue,
|
|
10
|
+
nonEmpty,
|
|
11
|
+
number,
|
|
12
|
+
object,
|
|
13
|
+
optional,
|
|
14
|
+
pipe,
|
|
15
|
+
safeParse,
|
|
16
|
+
string,
|
|
17
|
+
transform,
|
|
18
|
+
undefinedable,
|
|
19
|
+
union,
|
|
20
|
+
type ErrorMessage,
|
|
21
|
+
type ObjectEntries,
|
|
22
|
+
type ObjectIssue,
|
|
23
|
+
type ObjectSchema
|
|
24
|
+
} from 'valibot';
|
|
25
|
+
|
|
26
|
+
import { type WebChatActivity } from '../types/WebChatActivity';
|
|
27
|
+
import getOrgSchemaMessage from './getOrgSchemaMessage';
|
|
28
|
+
|
|
29
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
30
|
+
|
|
31
|
+
const streamSequenceSchema = pipe(number(), integer(), minValue(1));
|
|
32
|
+
|
|
33
|
+
function eitherChannelDataOrEntities<
|
|
34
|
+
TActivityEntries extends ObjectEntries,
|
|
35
|
+
TActivityMessage extends ErrorMessage<ObjectIssue> | undefined,
|
|
36
|
+
TMetadataEntries extends ObjectEntries,
|
|
37
|
+
TMetadataMessage extends ErrorMessage<ObjectIssue> | undefined
|
|
38
|
+
>(
|
|
39
|
+
activitySchema: ObjectSchema<TActivityEntries, TActivityMessage>,
|
|
40
|
+
metadataSchema: ObjectSchema<TMetadataEntries, TMetadataMessage>
|
|
41
|
+
) {
|
|
42
|
+
const metadataInEntitiesSchema = object({
|
|
43
|
+
...metadataSchema.entries,
|
|
44
|
+
type: literal('streaminfo')
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return union([
|
|
48
|
+
object({
|
|
49
|
+
...activitySchema.entries,
|
|
50
|
+
channelData: metadataSchema
|
|
51
|
+
}),
|
|
52
|
+
pipe(
|
|
53
|
+
object({
|
|
54
|
+
...activitySchema.entries,
|
|
55
|
+
// We use `findItem`/`filterItem` than `variant`/`someItem` because the output of the latter is an union type.
|
|
56
|
+
// Consider `{ type: string } | { streamId: string; type: 'streaminfo' }`, it turns into `{ type: string }` immediately.
|
|
57
|
+
|
|
58
|
+
// TODO: [P2] valibot@1.1.0 did not infer output type for `filterItem()`, only infer for `findItem()`.
|
|
59
|
+
// Bump valibot@latest and see if they solved the issue.
|
|
60
|
+
entities: pipe(
|
|
61
|
+
array(any()),
|
|
62
|
+
findItem(value => is(metadataInEntitiesSchema, value)),
|
|
63
|
+
check(value => !!value)
|
|
64
|
+
)
|
|
65
|
+
}),
|
|
66
|
+
// This is quite hacky, we should not mutate the parse output to ease metadata extractions.
|
|
67
|
+
transform(({ entities, ...value }) => ({ ...value, streamInfoEntity: entities! }))
|
|
68
|
+
)
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const livestreamingActivitySchema = union([
|
|
73
|
+
// Interim.
|
|
74
|
+
eitherChannelDataOrEntities(
|
|
75
|
+
object({
|
|
76
|
+
attachments: optional(array(any()), EMPTY_ARRAY),
|
|
77
|
+
id: string(),
|
|
78
|
+
// "text" is optional. If not set or empty, it presents a contentless activity.
|
|
79
|
+
text: optional(undefinedable(string())),
|
|
80
|
+
type: literal('typing')
|
|
81
|
+
}),
|
|
82
|
+
object({
|
|
83
|
+
// "streamId" is optional for the very first activity in the session.
|
|
84
|
+
streamId: optional(undefinedable(string())),
|
|
85
|
+
streamSequence: streamSequenceSchema,
|
|
86
|
+
streamType: literal('streaming')
|
|
87
|
+
})
|
|
88
|
+
),
|
|
89
|
+
// Informative message.
|
|
90
|
+
eitherChannelDataOrEntities(
|
|
91
|
+
object({
|
|
92
|
+
attachments: optional(array(any()), EMPTY_ARRAY),
|
|
93
|
+
id: string(),
|
|
94
|
+
// Informative may not have "text", but should have abstract instead (checked later)
|
|
95
|
+
text: optional(undefinedable(string())),
|
|
96
|
+
type: literal('typing'),
|
|
97
|
+
entities: optional(array(any()), EMPTY_ARRAY)
|
|
98
|
+
}),
|
|
99
|
+
object({
|
|
100
|
+
// "streamId" is optional for the very first activity in the session.
|
|
101
|
+
streamId: optional(undefinedable(string())),
|
|
102
|
+
streamSequence: streamSequenceSchema,
|
|
103
|
+
streamType: literal('informative')
|
|
104
|
+
})
|
|
105
|
+
),
|
|
106
|
+
// Conclude with a message.
|
|
107
|
+
eitherChannelDataOrEntities(
|
|
108
|
+
object({
|
|
109
|
+
attachments: optional(array(any()), EMPTY_ARRAY),
|
|
110
|
+
id: string(),
|
|
111
|
+
// If "text" is empty, it represents "regretting" the livestream.
|
|
112
|
+
text: optional(undefinedable(string())),
|
|
113
|
+
type: literal('message')
|
|
114
|
+
}),
|
|
115
|
+
object({
|
|
116
|
+
// "streamId" is required for the final activity in the session.
|
|
117
|
+
// The final activity must not be the sole activity in the session.
|
|
118
|
+
streamId: pipe(string(), nonEmpty()),
|
|
119
|
+
streamType: literal('final')
|
|
120
|
+
})
|
|
121
|
+
),
|
|
122
|
+
// Conclude without a message.
|
|
123
|
+
eitherChannelDataOrEntities(
|
|
124
|
+
object({
|
|
125
|
+
attachments: optional(array(any()), EMPTY_ARRAY),
|
|
126
|
+
id: string(),
|
|
127
|
+
// If "text" is not set or empty, it represents "regretting" the livestream.
|
|
128
|
+
text: optional(undefinedable(literal(''))),
|
|
129
|
+
type: literal('typing')
|
|
130
|
+
}),
|
|
131
|
+
object({
|
|
132
|
+
// "streamId" is required for the final activity in the session.
|
|
133
|
+
// The final activity must not be the sole activity in the session.
|
|
134
|
+
streamId: pipe(string(), nonEmpty()),
|
|
135
|
+
streamType: literal('final')
|
|
136
|
+
})
|
|
137
|
+
)
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Gets the livestreaming metadata of the activity, or `undefined` if the activity is not participating in a livestreaming session.
|
|
142
|
+
*
|
|
143
|
+
* - `sessionId` - ID of the livestreaming session
|
|
144
|
+
* - `sequenceNumber` - sequence number of the activity
|
|
145
|
+
* - `type`
|
|
146
|
+
* - `"contentless"` - ongoing but no content, should show indicator
|
|
147
|
+
* - `"interim activity"` - current response, could be partial-from-start, or complete response.
|
|
148
|
+
* More activities are expected. Future interim activities always replace past interim activities, enable erasing or backtracking response.
|
|
149
|
+
* - `"informative message"` - optional side-channel informative message describing the current response, e.g. "Searching your document library".
|
|
150
|
+
* Always replace past informative messages. May interleave with interim activities.
|
|
151
|
+
* - `"final activity"` - complete-and-final response, always replace past interim activities and remove all informative messages.
|
|
152
|
+
* This activity indicates end of the session, all future activities must be ignored.
|
|
153
|
+
* - `undefined` - not part of a livestream session or the activity is not valid
|
|
154
|
+
*
|
|
155
|
+
* @returns {object} Livestreaming metadata of the activity, or `undefined` if the activity is not participating in a livestreaming session.
|
|
156
|
+
*/
|
|
157
|
+
export default function getActivityLivestreamingMetadata(activity: WebChatActivity):
|
|
158
|
+
| Readonly<{
|
|
159
|
+
sessionId: string;
|
|
160
|
+
sequenceNumber: number;
|
|
161
|
+
type: 'contentless' | 'final activity' | 'informative message' | 'interim activity';
|
|
162
|
+
}>
|
|
163
|
+
| undefined {
|
|
164
|
+
const result = safeParse(livestreamingActivitySchema, activity);
|
|
165
|
+
|
|
166
|
+
if (result.success) {
|
|
167
|
+
const { output } = result;
|
|
168
|
+
const livestreamMetadata = 'channelData' in output ? output.channelData : output.streamInfoEntity;
|
|
169
|
+
|
|
170
|
+
// If the activity is the first in the session, session ID should be the activity ID.
|
|
171
|
+
const sessionId = livestreamMetadata.streamId || output.id;
|
|
172
|
+
|
|
173
|
+
return Object.freeze(
|
|
174
|
+
livestreamMetadata.streamType === 'final'
|
|
175
|
+
? {
|
|
176
|
+
sequenceNumber: Infinity,
|
|
177
|
+
sessionId,
|
|
178
|
+
type: 'final activity'
|
|
179
|
+
}
|
|
180
|
+
: {
|
|
181
|
+
sequenceNumber: livestreamMetadata.streamSequence,
|
|
182
|
+
sessionId,
|
|
183
|
+
type: !(
|
|
184
|
+
output.text ||
|
|
185
|
+
output.attachments?.length ||
|
|
186
|
+
('entities' in output && getOrgSchemaMessage(output.entities)?.abstract[0])
|
|
187
|
+
)
|
|
188
|
+
? 'contentless'
|
|
189
|
+
: livestreamMetadata.streamType === 'informative'
|
|
190
|
+
? 'informative message'
|
|
191
|
+
: 'interim activity'
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { expect, test } from '@jest/globals';
|
|
2
|
+
import { parse } from 'valibot';
|
|
3
|
+
import { orgSchemaCreativeWorkSchema } from '@msinternal/botframework-webchat-core-json-ld';
|
|
1
4
|
import getOrgSchemaMessage from './getOrgSchemaMessage';
|
|
2
5
|
|
|
3
6
|
test('should get message', () => {
|
|
@@ -8,7 +11,7 @@ test('should get message', () => {
|
|
|
8
11
|
type: 'https://schema.org/Message'
|
|
9
12
|
};
|
|
10
13
|
|
|
11
|
-
expect(getOrgSchemaMessage([expected])).toEqual(expected);
|
|
14
|
+
expect(getOrgSchemaMessage([expected])).toEqual(parse(orgSchemaCreativeWorkSchema, expected));
|
|
12
15
|
});
|
|
13
16
|
|
|
14
17
|
test('should not get message without @id of empty string', () => {
|