botframework-webchat-core 4.14.1 → 4.15.2-main.20220413.af6e8a3
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/.eslintrc.yml +4 -198
- package/.prettierrc.yml +1 -1
- package/babel.config.json +1 -1
- package/lib/actions/clearSuggestedActions.js +1 -1
- package/lib/actions/connect.js +1 -1
- package/lib/actions/connectionStatusUpdate.js +1 -1
- package/lib/actions/deleteActivity.d.ts +13 -0
- package/lib/actions/deleteActivity.d.ts.map +1 -0
- package/lib/actions/deleteActivity.js +5 -3
- package/lib/actions/disconnect.js +1 -1
- package/lib/actions/dismissNotification.js +1 -1
- package/lib/actions/emitTypingIndicator.js +1 -1
- package/lib/actions/incomingActivity.d.ts +14 -0
- package/lib/actions/incomingActivity.d.ts.map +1 -0
- package/lib/actions/incomingActivity.js +5 -3
- package/lib/actions/markActivity.d.ts +17 -0
- package/lib/actions/markActivity.d.ts.map +1 -0
- package/lib/actions/markActivity.js +5 -3
- package/lib/actions/postActivity.d.ts +52 -0
- package/lib/actions/postActivity.d.ts.map +1 -0
- package/lib/actions/postActivity.js +5 -3
- package/lib/actions/queueIncomingActivity.js +1 -1
- package/lib/actions/sagaError.js +1 -1
- package/lib/actions/sendEvent.js +1 -1
- package/lib/actions/sendFiles.js +1 -1
- package/lib/actions/sendMessage.js +1 -1
- package/lib/actions/sendMessageBack.js +1 -1
- package/lib/actions/sendPostBack.js +1 -1
- package/lib/actions/setDictateInterims.js +1 -1
- package/lib/actions/setDictateState.js +1 -1
- package/lib/actions/setLanguage.js +1 -1
- package/lib/actions/setNotification.js +2 -2
- package/lib/actions/setReferenceGrammarID.js +1 -1
- package/lib/actions/setSendBox.js +1 -1
- package/lib/actions/setSendTimeout.js +1 -1
- package/lib/actions/setSendTypingIndicator.js +1 -1
- package/lib/actions/setSuggestedActions.js +1 -1
- package/lib/actions/startDictate.js +1 -1
- package/lib/actions/startSpeakingActivity.js +1 -1
- package/lib/actions/stopDictate.js +1 -1
- package/lib/actions/stopSpeakingActivity.js +1 -1
- package/lib/actions/submitSendBox.js +1 -1
- package/lib/actions/updateConnectionStatus.js +1 -1
- package/lib/constants/ActivityClientState.js +1 -1
- package/lib/createStore.d.ts.map +1 -1
- package/lib/createStore.js +5 -5
- package/lib/definitions/speakingActivity.js +4 -2
- package/lib/index.d.ts +17 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12 -3
- package/lib/reducer.d.ts +1 -2
- package/lib/reducer.d.ts.map +1 -1
- package/lib/reducer.js +1 -4
- package/lib/reducers/activities.d.ts +10 -0
- package/lib/reducers/activities.d.ts.map +1 -0
- package/lib/reducers/activities.js +65 -45
- package/lib/reducers/notifications.js +21 -14
- package/lib/reducers/typing.js +13 -7
- package/lib/sagas/connectionStatusToNotificationSaga.js +1 -1
- package/lib/sagas/effects/observeOnce.js +1 -1
- package/lib/sagas/effects/whileConnected.js +1 -1
- package/lib/sagas/observeActivitySaga.js +21 -3
- package/lib/sagas/postActivitySaga.js +51 -72
- package/lib/sagas/queueIncomingActivitySaga.js +1 -1
- package/lib/sagas/sendFilesToPostActivitySaga.js +4 -4
- package/lib/sagas/sendMessageBackToPostActivitySaga.js +1 -1
- package/lib/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +1 -1
- package/lib/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +1 -1
- package/lib/sagas/startSpeakActivityOnPostActivitySaga.js +1 -1
- package/lib/sagas/stopSpeakingActivityOnInputSaga.js +1 -1
- package/lib/sagas/submitSendBoxSaga.js +1 -1
- package/lib/selectors/activities.js +1 -1
- package/lib/selectors/combineSelectors.js +9 -4
- package/lib/selectors/dictateState.js +1 -1
- package/lib/selectors/language.js +1 -1
- package/lib/selectors/notifications.js +1 -1
- package/lib/selectors/sendBoxValue.js +1 -1
- package/lib/selectors/sendTimeout.js +1 -1
- package/lib/selectors/sendTypingIndicator.js +1 -1
- package/lib/selectors/shouldSpeakIncomingActivity.js +1 -1
- package/lib/types/AnyAnd.d.ts +2 -0
- package/lib/types/AnyAnd.d.ts.map +1 -0
- package/lib/types/AnyAnd.js +6 -0
- package/lib/types/OneOrMany.js +4 -0
- package/lib/types/WebChatActivity.d.ts +81 -0
- package/lib/types/WebChatActivity.d.ts.map +1 -0
- package/lib/types/WebChatActivity.js +6 -0
- package/lib/types/external/DirectLineActivity.d.ts +2 -2
- package/lib/types/external/DirectLineActivity.d.ts.map +1 -1
- package/lib/types/external/DirectLineActivity.js +4 -0
- package/lib/types/external/DirectLineAnimationCard.d.ts +5 -2
- package/lib/types/external/DirectLineAnimationCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineAnimationCard.js +4 -0
- package/lib/types/external/DirectLineAttachment.d.ts +8 -2
- package/lib/types/external/DirectLineAttachment.d.ts.map +1 -1
- package/lib/types/external/DirectLineAttachment.js +4 -0
- package/lib/types/external/DirectLineAudioCard.d.ts +5 -2
- package/lib/types/external/DirectLineAudioCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineAudioCard.js +4 -0
- package/lib/types/external/DirectLineBasicCardEssence.d.ts +12 -0
- package/lib/types/external/DirectLineBasicCardEssence.d.ts.map +1 -0
- package/lib/types/external/DirectLineBasicCardEssence.js +6 -0
- package/lib/types/external/DirectLineCardAction.d.ts +1 -1
- package/lib/types/external/DirectLineCardAction.d.ts.map +1 -1
- package/lib/types/external/DirectLineCardAction.js +4 -0
- package/lib/types/external/DirectLineCardImage.d.ts +8 -0
- package/lib/types/external/DirectLineCardImage.d.ts.map +1 -0
- package/lib/types/external/DirectLineCardImage.js +6 -0
- package/lib/types/external/DirectLineHeroCard.d.ts +5 -2
- package/lib/types/external/DirectLineHeroCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineHeroCard.js +4 -0
- package/lib/types/external/DirectLineJSBotConnection.d.ts +1 -1
- package/lib/types/external/DirectLineJSBotConnection.d.ts.map +1 -1
- package/lib/types/external/DirectLineJSBotConnection.js +4 -0
- package/lib/types/external/DirectLineMediaCardEssence.d.ts +21 -0
- package/lib/types/external/DirectLineMediaCardEssence.d.ts.map +1 -0
- package/lib/types/external/DirectLineMediaCardEssence.js +6 -0
- package/lib/types/external/DirectLineOAuthCard.d.ts +7 -2
- package/lib/types/external/DirectLineOAuthCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineOAuthCard.js +4 -0
- package/lib/types/external/DirectLineReceiptCard.d.ts +27 -2
- package/lib/types/external/DirectLineReceiptCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineReceiptCard.js +4 -0
- package/lib/types/external/DirectLineSignInCard.d.ts +7 -2
- package/lib/types/external/DirectLineSignInCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineSignInCard.js +4 -0
- package/lib/types/external/DirectLineSuggestedAction.d.ts +6 -2
- package/lib/types/external/DirectLineSuggestedAction.d.ts.map +1 -1
- package/lib/types/external/DirectLineSuggestedAction.js +4 -0
- package/lib/types/external/DirectLineThumbnailCard.d.ts +5 -2
- package/lib/types/external/DirectLineThumbnailCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineThumbnailCard.js +4 -0
- package/lib/types/external/DirectLineVideoCard.d.ts +5 -2
- package/lib/types/external/DirectLineVideoCard.d.ts.map +1 -1
- package/lib/types/external/DirectLineVideoCard.js +4 -0
- package/lib/types/external/Observable.js +6 -0
- package/lib/types/internal/Notification.js +6 -0
- package/lib/types/internal/ReduxState.js +6 -0
- package/lib/utils/dateToLocaleISOString.js +5 -5
- package/lib/utils/deleteKey.js +2 -3
- package/lib/utils/isForbiddenPropertyName.d.ts +2 -0
- package/lib/utils/isForbiddenPropertyName.d.ts.map +1 -0
- package/lib/utils/isForbiddenPropertyName.js +21 -0
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/uniqueID.js +1 -1
- package/package.json +20 -23
- package/src/__tests__/detectSlowConnectionSaga.spec.js +1 -1
- package/src/__tests__/observeOnce.spec.js +3 -3
- package/src/actions/deleteActivity.ts +19 -0
- package/src/actions/incomingActivity.ts +21 -0
- package/src/actions/markActivity.ts +23 -0
- package/src/actions/postActivity.ts +48 -0
- package/src/actions/setNotification.js +8 -2
- package/src/createStore.ts +4 -4
- package/src/definitions/speakingActivity.js +1 -1
- package/src/index.ts +19 -14
- package/src/reducer.ts +0 -2
- package/src/reducers/activities.ts +172 -0
- package/src/reducers/notifications.js +22 -16
- package/src/reducers/typing.js +6 -5
- package/src/sagas/connectionStatusToNotificationSaga.js +1 -1
- package/src/sagas/effects/{observeOnce.js → observeOnce.ts} +6 -4
- package/src/sagas/effects/{whileConnected.js → whileConnected.ts} +20 -1
- package/src/sagas/{observeActivitySaga.js → observeActivitySaga.ts} +25 -6
- package/src/sagas/{postActivitySaga.js → postActivitySaga.ts} +57 -48
- package/src/sagas/queueIncomingActivitySaga.js +40 -39
- package/src/sagas/sendFilesToPostActivitySaga.js +1 -1
- package/src/sagas/sendMessageBackToPostActivitySaga.js +0 -1
- package/src/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +1 -1
- package/src/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +1 -1
- package/src/sagas/startSpeakActivityOnPostActivitySaga.js +1 -1
- package/src/sagas/stopSpeakingActivityOnInputSaga.js +1 -1
- package/src/sagas/submitSendBoxSaga.js +1 -1
- package/src/selectors/activities.ts +12 -0
- package/src/selectors/combineSelectors.ts +21 -0
- package/src/selectors/dictateState.ts +3 -0
- package/src/selectors/language.ts +3 -0
- package/src/selectors/notifications.ts +6 -0
- package/src/selectors/sendBoxValue.ts +3 -0
- package/src/selectors/sendTimeout.ts +3 -0
- package/src/selectors/sendTypingIndicator.ts +3 -0
- package/src/selectors/shouldSpeakIncomingActivity.ts +3 -0
- package/src/types/AnyAnd.ts +1 -0
- package/src/types/WebChatActivity.ts +154 -0
- package/src/types/external/DirectLineActivity.ts +4 -3
- package/src/types/external/DirectLineAnimationCard.ts +6 -4
- package/src/types/external/DirectLineAttachment.ts +10 -5
- package/src/types/external/DirectLineAudioCard.ts +6 -4
- package/src/types/external/DirectLineBasicCardEssence.ts +14 -0
- package/src/types/external/DirectLineCardAction.ts +1 -1
- package/src/types/external/DirectLineCardImage.ts +9 -0
- package/src/types/external/DirectLineHeroCard.ts +6 -4
- package/src/types/external/DirectLineJSBotConnection.ts +1 -2
- package/src/types/external/DirectLineMediaCardEssence.ts +19 -0
- package/src/types/external/DirectLineOAuthCard.ts +7 -4
- package/src/types/external/DirectLineReceiptCard.ts +30 -4
- package/src/types/external/DirectLineSignInCard.ts +8 -4
- package/src/types/external/DirectLineSuggestedAction.ts +6 -4
- package/src/types/external/DirectLineThumbnailCard.ts +6 -4
- package/src/types/external/DirectLineVideoCard.ts +6 -4
- package/src/types/external/Observable.ts +69 -0
- package/src/types/internal/Notification.ts +10 -0
- package/src/types/internal/ReduxState.ts +16 -0
- package/src/utils/dateToLocaleISOString.chatham.spec.js +1 -0
- package/src/utils/dateToLocaleISOString.japan.spec.js +1 -0
- package/src/utils/dateToLocaleISOString.pacific.spec.js +1 -0
- package/src/utils/{dateToLocaleISOString.js → dateToLocaleISOString.ts} +6 -6
- package/src/utils/dateToLocaleISOString.utc.spec.js +2 -0
- package/src/utils/deleteKey.ts +9 -0
- package/src/utils/isForbiddenPropertyName.spec.js +6 -0
- package/src/utils/isForbiddenPropertyName.ts +33 -0
- package/src/utils/{sleep.js → sleep.ts} +1 -1
- package/src/utils/uniqueID.ts +7 -0
- package/.eslintignore +0 -9
- package/lib/reducers/clockSkewAdjustment.js +0 -44
- package/lib/sagas/effects/callUntil.js +0 -48
- package/lib/selectors/clockSkewAdjustment.js +0 -14
- package/lib/utils/mime-wrapper.js +0 -49
- package/src/actions/deleteActivity.js +0 -8
- package/src/actions/incomingActivity.js +0 -10
- package/src/actions/markActivity.js +0 -14
- package/src/actions/postActivity.js +0 -14
- package/src/reducers/activities.js +0 -116
- package/src/reducers/clockSkewAdjustment.js +0 -29
- package/src/sagas/effects/callUntil.js +0 -13
- package/src/selectors/activities.js +0 -8
- package/src/selectors/clockSkewAdjustment.js +0 -1
- package/src/selectors/combineSelectors.js +0 -8
- package/src/selectors/dictateState.js +0 -1
- package/src/selectors/language.js +0 -1
- package/src/selectors/notifications.js +0 -3
- package/src/selectors/sendBoxValue.js +0 -1
- package/src/selectors/sendTimeout.js +0 -1
- package/src/selectors/sendTypingIndicator.js +0 -1
- package/src/selectors/shouldSpeakIncomingActivity.js +0 -1
- package/src/utils/deleteKey.js +0 -11
- package/src/utils/mime-wrapper.js +0 -40
- package/src/utils/uniqueID.js +0 -12
|
@@ -34,7 +34,7 @@ function* sendTypingIndicatorOnSetSendBox() {
|
|
|
34
34
|
// When the user type, and then post the activity at t = 1500, we still have a pending typing indicator at t = 3000.
|
|
35
35
|
// This code is to cancel the typing indicator at t = 3000.
|
|
36
36
|
(type === POST_ACTIVITY && payload.activity.type !== 'typing'),
|
|
37
|
-
function*({ payload, type }) {
|
|
37
|
+
function* ({ payload, type }) {
|
|
38
38
|
if (type === SET_SEND_BOX) {
|
|
39
39
|
const interval = SEND_INTERVAL - Date.now() + lastSend;
|
|
40
40
|
|
|
@@ -16,7 +16,7 @@ function* speakActivityAndStartDictateOnIncomingActivityFromOthers({ userID }) {
|
|
|
16
16
|
// In Direct Line Speech, we do not know the user ID, but "role" is filled with "bot" or "user".
|
|
17
17
|
// Here, we do two checks: the speakable activity must not have user ID, and must not have role === 'user'
|
|
18
18
|
type === INCOMING_ACTIVITY && payload.activity.from.id !== userID && payload.activity.from.role !== 'user',
|
|
19
|
-
function*({ payload: { activity } }) {
|
|
19
|
+
function* ({ payload: { activity } }) {
|
|
20
20
|
const shouldSpeakIncomingActivity = yield select(shouldSpeakIncomingActivitySelector);
|
|
21
21
|
const shouldSpeak = speakableActivity(activity) && shouldSpeakIncomingActivity;
|
|
22
22
|
|
|
@@ -8,7 +8,7 @@ function* startSpeakActivityOnPostActivity() {
|
|
|
8
8
|
yield takeEvery(
|
|
9
9
|
({ meta, payload, type }) =>
|
|
10
10
|
type === POST_ACTIVITY_PENDING && meta.method === 'speech' && payload.activity.type === 'message',
|
|
11
|
-
function*() {
|
|
11
|
+
function* () {
|
|
12
12
|
yield put(startSpeakingActivity());
|
|
13
13
|
}
|
|
14
14
|
);
|
|
@@ -14,7 +14,7 @@ function* stopSpeakingActivityOnInput() {
|
|
|
14
14
|
// So, right now, we are using best-effort by listening to POST_ACTIVITY_PENDING with a "message" event
|
|
15
15
|
// We filter out speech because we will call startSpeakingActivity() for POST_ACTIVITY_PENDING dispatched by speech
|
|
16
16
|
(type === POST_ACTIVITY_PENDING && meta.method !== 'speech' && payload.activity.type === 'message'),
|
|
17
|
-
function*() {
|
|
17
|
+
function* () {
|
|
18
18
|
yield put(stopSpeakingActivity());
|
|
19
19
|
}
|
|
20
20
|
);
|
|
@@ -7,7 +7,7 @@ import setSendBox from '../actions/setSendBox';
|
|
|
7
7
|
import whileConnected from './effects/whileConnected';
|
|
8
8
|
|
|
9
9
|
function* submitSendBox() {
|
|
10
|
-
yield takeEvery(SUBMIT_SEND_BOX, function*({ payload: { channelData, method } }) {
|
|
10
|
+
yield takeEvery(SUBMIT_SEND_BOX, function* ({ payload: { channelData, method } }) {
|
|
11
11
|
const sendBoxValue = yield select(sendBoxValueSelector);
|
|
12
12
|
|
|
13
13
|
if (sendBoxValue) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReduxState } from '../types/internal/ReduxState';
|
|
2
|
+
import type { WebChatActivity } from '../types/WebChatActivity';
|
|
3
|
+
|
|
4
|
+
const activities = ({ activities }: ReduxState) => activities;
|
|
5
|
+
|
|
6
|
+
const of = (predicate: (activity: WebChatActivity) => boolean) => (state: ReduxState) =>
|
|
7
|
+
activities(state).filter(predicate);
|
|
8
|
+
const ofID = (targetID: string) => of(({ id }) => id === targetID);
|
|
9
|
+
const ofType = (targetType: string) => of(({ type }) => type === targetType);
|
|
10
|
+
|
|
11
|
+
export default activities;
|
|
12
|
+
export { of, ofID, ofType };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import isForbiddenPropertyName from '../utils/isForbiddenPropertyName';
|
|
2
|
+
|
|
3
|
+
export default function combineSelectors<
|
|
4
|
+
TState extends { [key: string]: unknown },
|
|
5
|
+
TResult extends { [key: string]: unknown }
|
|
6
|
+
>(selectors: { [P in keyof TResult]: (state: TState) => TResult[P] }): (state: TState) => {
|
|
7
|
+
[P in keyof TResult]?: TResult[P];
|
|
8
|
+
} {
|
|
9
|
+
if (Array.isArray(selectors)) {
|
|
10
|
+
return state => selectors.reduce((combinedState, selector) => [...combinedState, selector(state)], []);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return state =>
|
|
14
|
+
Object.keys(selectors).reduce(
|
|
15
|
+
(combinedState, key) =>
|
|
16
|
+
// Mitigated through denylisting.
|
|
17
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
18
|
+
isForbiddenPropertyName(key) ? combinedState : { ...combinedState, [key]: selectors[key](state) },
|
|
19
|
+
{} as TResult
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Notification } from '../types/internal/Notification';
|
|
2
|
+
import type { ReduxState } from '../types/internal/ReduxState';
|
|
3
|
+
|
|
4
|
+
const notifications = ({ notifications }: ReduxState): { [key: string]: Notification } => notifications;
|
|
5
|
+
|
|
6
|
+
export default notifications;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type AnyAnd<T> = Omit<any, keyof T> & T;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// This is Web Chat view of Direct Line Activity, which is defined at https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md.
|
|
2
|
+
// It is not a direct port of Direct Line version of Activity.
|
|
3
|
+
|
|
4
|
+
// For example:
|
|
5
|
+
// - "channelId" is not needed by Web Chat, thus, it is optional
|
|
6
|
+
// - "localTimestamp" is a must when sending out activities to the server
|
|
7
|
+
// - However, we do not expect the server to return "localTimestamp" as they may not have capability to store this information
|
|
8
|
+
// - "conversationUpdate" activity is never sent to Web Chat, thus, it is not defined
|
|
9
|
+
|
|
10
|
+
import type { AnyAnd } from './AnyAnd';
|
|
11
|
+
import type { DirectLineAttachment } from './external/DirectLineAttachment';
|
|
12
|
+
import type { DirectLineSuggestedAction } from './external/DirectLineSuggestedAction';
|
|
13
|
+
|
|
14
|
+
type ChannelData<SendState extends string | undefined, Type extends string> = AnyAnd<
|
|
15
|
+
{
|
|
16
|
+
// TODO: [P2] #3953 Rename to "webchat:attachment-sizes".
|
|
17
|
+
attachmentSizes?: number[];
|
|
18
|
+
|
|
19
|
+
// TODO: [P2] #3953 Rename to "webchat:client-activity-id".
|
|
20
|
+
clientActivityID?: string;
|
|
21
|
+
|
|
22
|
+
// Sequence ID must be available when chat adapter send it to Web Chat.
|
|
23
|
+
'webchat:sequence-id': number;
|
|
24
|
+
} & (SendState extends string
|
|
25
|
+
? {
|
|
26
|
+
// TODO: [P2] #3953 Rename to "webchat:send-state".
|
|
27
|
+
state: SendState;
|
|
28
|
+
}
|
|
29
|
+
: {}) &
|
|
30
|
+
(Type extends 'message'
|
|
31
|
+
? {
|
|
32
|
+
// TODO: [P2] #3953 Rename to "webchat:message-back".
|
|
33
|
+
messageBack?: {
|
|
34
|
+
displayText: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// TODO: [P2] #3953 Rename to "webchat:post-back".
|
|
38
|
+
postBack?: boolean;
|
|
39
|
+
|
|
40
|
+
// TODO: [P2] #3953 Rename to "webchat:speak-state".
|
|
41
|
+
speak?: boolean;
|
|
42
|
+
|
|
43
|
+
// TODO: [P2] #3953 Rename to "webchat:speech-synthesis-utterance".
|
|
44
|
+
speechSynthesisUtterance?: SpeechSynthesisUtterance;
|
|
45
|
+
|
|
46
|
+
// TODO: [P2] #3953 It seems Direct Line added a new "summary" field to cater this case.
|
|
47
|
+
'webchat:fallback-text'?: string;
|
|
48
|
+
}
|
|
49
|
+
: {})
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
// Entity - https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#entity
|
|
53
|
+
|
|
54
|
+
type ClientCapabilitiesEntity = {
|
|
55
|
+
requiresBotState?: boolean;
|
|
56
|
+
supportsListening?: boolean;
|
|
57
|
+
supportsTts?: boolean;
|
|
58
|
+
type: 'ClientCapabilities';
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type Entity = ClientCapabilitiesEntity | AnyAnd<{ type: Exclude<string, 'ClientCapabilities'> }>;
|
|
62
|
+
|
|
63
|
+
// Channel account - https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#channel-account
|
|
64
|
+
type ChannelAcount<Role = 'bot' | 'channel' | 'user'> = {
|
|
65
|
+
id: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
role: Role;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Abstract - content of different activity types
|
|
71
|
+
|
|
72
|
+
// https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#event-activity
|
|
73
|
+
type EventActivityEssence = {
|
|
74
|
+
name: string;
|
|
75
|
+
type: 'event';
|
|
76
|
+
value?: any;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#message-activity
|
|
80
|
+
type MessageActivityEssence = {
|
|
81
|
+
attachmentLayout?: 'carousel' | 'stacked';
|
|
82
|
+
attachments?: DirectLineAttachment[];
|
|
83
|
+
inputHint?: 'accepting' | 'expecting' | 'ignoring';
|
|
84
|
+
locale?: string;
|
|
85
|
+
speak?: string;
|
|
86
|
+
suggestedActions?: DirectLineSuggestedAction;
|
|
87
|
+
text: string | undefined;
|
|
88
|
+
textFormat?: 'markdown' | 'plain' | 'xml';
|
|
89
|
+
type: 'message';
|
|
90
|
+
value?: any;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#typing-activity
|
|
94
|
+
type TypingActivityEssence = {
|
|
95
|
+
type: 'typing';
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Abstract - timestamps
|
|
99
|
+
|
|
100
|
+
type TimestampFromServerEssence = {
|
|
101
|
+
id: string;
|
|
102
|
+
localTimestamp?: string;
|
|
103
|
+
timestamp: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type TimestampInTransitEssence = {
|
|
107
|
+
id?: string;
|
|
108
|
+
localTimestamp: string;
|
|
109
|
+
timestamp?: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
type TimestampEssence<Role extends string, SendState extends string | undefined> = Role extends 'user'
|
|
113
|
+
? SendState extends 'sending' | 'send failed'
|
|
114
|
+
? TimestampInTransitEssence
|
|
115
|
+
: TimestampFromServerEssence
|
|
116
|
+
: TimestampFromServerEssence;
|
|
117
|
+
|
|
118
|
+
// Abstract - core
|
|
119
|
+
|
|
120
|
+
type CoreActivityEssence<
|
|
121
|
+
Role extends 'bot' | 'channel' | 'user',
|
|
122
|
+
SendState extends string | undefined,
|
|
123
|
+
Type extends string = 'conversationUpdate' | 'event' | 'invoke' | 'message' | 'typing'
|
|
124
|
+
> = {
|
|
125
|
+
channelData: ChannelData<SendState, Type>;
|
|
126
|
+
channelId?: string;
|
|
127
|
+
entities?: Entity[];
|
|
128
|
+
from: ChannelAcount<Role>;
|
|
129
|
+
localTimezone?: string;
|
|
130
|
+
replyToId?: string;
|
|
131
|
+
type: string;
|
|
132
|
+
} & TimestampEssence<Role, SendState> &
|
|
133
|
+
(Type extends 'event'
|
|
134
|
+
? EventActivityEssence
|
|
135
|
+
: Type extends 'message'
|
|
136
|
+
? MessageActivityEssence
|
|
137
|
+
: Type extends 'typing'
|
|
138
|
+
? TypingActivityEssence
|
|
139
|
+
: { type: Type });
|
|
140
|
+
|
|
141
|
+
// Concrete
|
|
142
|
+
|
|
143
|
+
type SelfActivityInTransit = CoreActivityEssence<'user', 'sending' | 'send failed'>;
|
|
144
|
+
type SelfActivityFromServer = CoreActivityEssence<'user', 'sent'>;
|
|
145
|
+
|
|
146
|
+
type SelfActivity = SelfActivityInTransit | SelfActivityFromServer;
|
|
147
|
+
|
|
148
|
+
type OthersActivity = CoreActivityEssence<'bot' | 'channel', undefined>;
|
|
149
|
+
|
|
150
|
+
// Exported
|
|
151
|
+
|
|
152
|
+
type WebChatActivity = SelfActivity | OthersActivity;
|
|
153
|
+
|
|
154
|
+
export type { WebChatActivity };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// TODO: [P1] #3953 We should fully type it out.
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
// Until we fully typed out DirectLineActivity, we need to use "any" here.
|
|
4
|
+
// We only know the DirectLineActivity must be a map, and not other primitive types.
|
|
5
|
+
type DirectLineActivity = Exclude<any, [] | boolean | Function | number | string>;
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export type { DirectLineActivity };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineMediaCardEssence } from './DirectLineMediaCardEssence';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
type DirectLineAnimationCard =
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#Animation-card
|
|
4
|
+
type DirectLineAnimationCard = DirectLineMediaCardEssence & {
|
|
5
|
+
contentType: 'application/vnd.microsoft.card.animation';
|
|
6
|
+
};
|
|
5
7
|
|
|
6
|
-
export
|
|
8
|
+
export type { DirectLineAnimationCard };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
//
|
|
1
|
+
// https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#attachment
|
|
2
|
+
type DirectLineAttachment = {
|
|
3
|
+
// Currently, we allow "text/plain" with "content" field of type string. Under the spec, "content" must not contains primitive types.
|
|
4
|
+
content?: any;
|
|
5
|
+
contentType: string;
|
|
6
|
+
contentUrl?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
thumbnailUrl?: string;
|
|
9
|
+
};
|
|
2
10
|
|
|
3
|
-
|
|
4
|
-
type DirectLineAttachment = any;
|
|
5
|
-
|
|
6
|
-
export default DirectLineAttachment;
|
|
11
|
+
export type { DirectLineAttachment };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineMediaCardEssence } from './DirectLineMediaCardEssence';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
type DirectLineAudioCard =
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#audio-card
|
|
4
|
+
type DirectLineAudioCard = DirectLineMediaCardEssence & {
|
|
5
|
+
contentType: 'application/vnd.microsoft.card.audio';
|
|
6
|
+
};
|
|
5
7
|
|
|
6
|
-
export
|
|
8
|
+
export type { DirectLineAudioCard };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DirectLineCardImage } from './DirectLineCardImage';
|
|
2
|
+
import type { DirectLineCardAction } from './DirectLineCardAction';
|
|
3
|
+
|
|
4
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#basic-cards
|
|
5
|
+
type DirectLineBasicCardEssence = {
|
|
6
|
+
buttons?: DirectLineCardAction[];
|
|
7
|
+
images?: DirectLineCardImage[];
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
tap?: DirectLineCardAction;
|
|
10
|
+
text?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type { DirectLineBasicCardEssence };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineBasicCardEssence } from './DirectLineBasicCardEssence';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
type DirectLineHeroCard =
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#Hero-cards
|
|
4
|
+
type DirectLineHeroCard = DirectLineBasicCardEssence & {
|
|
5
|
+
contentType: 'application/vnd.microsoft.card.hero';
|
|
6
|
+
};
|
|
5
7
|
|
|
6
|
-
export
|
|
8
|
+
export type { DirectLineHeroCard };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DirectLineCardAction } from './DirectLineCardAction';
|
|
2
|
+
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#media-cards
|
|
4
|
+
type DirectLineMediaCardEssence = {
|
|
5
|
+
aspect?: '4:3' | '16:9';
|
|
6
|
+
autoloop?: boolean;
|
|
7
|
+
autostart?: boolean;
|
|
8
|
+
buttons?: DirectLineCardAction[];
|
|
9
|
+
duration?: string;
|
|
10
|
+
// In the spec, "image" is of type "thumbnailUrl", which is simply a string.
|
|
11
|
+
image?: { url: string };
|
|
12
|
+
media: { profile?: string; url: string }[];
|
|
13
|
+
shareable?: boolean;
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
value?: any;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type { DirectLineMediaCardEssence };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineCardAction } from './DirectLineCardAction';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type DirectLineOAuthCard = {
|
|
4
|
+
buttons?: DirectLineCardAction[];
|
|
5
|
+
contentType: 'application/vnd.microsoft.card.oauth';
|
|
6
|
+
text?: string;
|
|
7
|
+
};
|
|
5
8
|
|
|
6
|
-
export
|
|
9
|
+
export type { DirectLineOAuthCard };
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineCardAction } from './DirectLineCardAction';
|
|
2
|
+
import type { DirectLineCardImage } from './DirectLineCardImage';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
type Fact = {
|
|
5
|
+
key?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
};
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
type ReceiptItem = {
|
|
10
|
+
image?: DirectLineCardImage;
|
|
11
|
+
price?: string;
|
|
12
|
+
quantity?: string;
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
tap?: DirectLineCardAction;
|
|
15
|
+
text?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#receipt-card
|
|
20
|
+
type DirectLineReceiptCard = {
|
|
21
|
+
buttons?: DirectLineCardAction[];
|
|
22
|
+
contentType: 'application/vnd.microsoft.card.receipt';
|
|
23
|
+
facts?: Fact[];
|
|
24
|
+
items?: ReceiptItem[];
|
|
25
|
+
tap?: DirectLineCardAction;
|
|
26
|
+
tax?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
total?: string;
|
|
29
|
+
vat?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type { DirectLineReceiptCard };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineCardAction } from './DirectLineCardAction';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
type DirectLineSignInCard =
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#Signin-card
|
|
4
|
+
type DirectLineSignInCard = {
|
|
5
|
+
buttons?: DirectLineCardAction[];
|
|
6
|
+
contentType: 'application/vnd.microsoft.card.signin';
|
|
7
|
+
text?: string;
|
|
8
|
+
};
|
|
5
9
|
|
|
6
|
-
export
|
|
10
|
+
export type { DirectLineSignInCard };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineCardAction } from './DirectLineCardAction';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type DirectLineSuggestedAction = {
|
|
4
|
+
actions?: DirectLineCardAction[];
|
|
5
|
+
to?: string[];
|
|
6
|
+
};
|
|
5
7
|
|
|
6
|
-
export
|
|
8
|
+
export type { DirectLineSuggestedAction };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineBasicCardEssence } from './DirectLineBasicCardEssence';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
type DirectLineThumbnailCard =
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#Thumbnail-cards
|
|
4
|
+
type DirectLineThumbnailCard = DirectLineBasicCardEssence & {
|
|
5
|
+
contentType: 'application/vnd.microsoft.card.thumbnail';
|
|
6
|
+
};
|
|
5
7
|
|
|
6
|
-
export
|
|
8
|
+
export type { DirectLineThumbnailCard };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DirectLineMediaCardEssence } from './DirectLineMediaCardEssence';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
type DirectLineVideoCard =
|
|
3
|
+
// https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-cards.md#video-card
|
|
4
|
+
type DirectLineVideoCard = DirectLineMediaCardEssence & {
|
|
5
|
+
contentType: 'application/vnd.microsoft.card.video';
|
|
6
|
+
};
|
|
5
7
|
|
|
6
|
-
export
|
|
8
|
+
export type { DirectLineVideoCard };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// This is a declaration file for a single ES feature. Could contains multiple classes definitions.
|
|
2
|
+
/* eslint-disable max-classes-per-file */
|
|
3
|
+
|
|
4
|
+
// Adopted from https://github.com/tc39/proposal-observable.
|
|
5
|
+
|
|
6
|
+
/** Receives a completion notification */
|
|
7
|
+
type CompleteFunction = () => void;
|
|
8
|
+
|
|
9
|
+
/** Receives the sequence error */
|
|
10
|
+
type ErrorFunction = (error: Error) => void;
|
|
11
|
+
|
|
12
|
+
/** Receives the next value in the sequence */
|
|
13
|
+
type NextFunction<T> = (value: T) => void;
|
|
14
|
+
type SubscriberFunction<T> = (observer: SubscriptionObserver<T>) => Subscription;
|
|
15
|
+
|
|
16
|
+
/** An `Observable` represents a sequence of values which may be observed. */
|
|
17
|
+
declare class Observable<T> {
|
|
18
|
+
constructor(subscriber: SubscriberFunction<T>);
|
|
19
|
+
|
|
20
|
+
/** Subscribes to the sequence with an observer */
|
|
21
|
+
subscribe(observer: Observer<T>): Subscription;
|
|
22
|
+
|
|
23
|
+
/** Subscribes to the sequence with callbacks */
|
|
24
|
+
subscribe(onNext: NextFunction<T>, onError?: ErrorFunction, onComplete?: CompleteFunction): Subscription;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class Subscription {
|
|
28
|
+
/** Cancels the subscription */
|
|
29
|
+
unsubscribe(): void;
|
|
30
|
+
|
|
31
|
+
/** A boolean value indicating whether the subscription is closed */
|
|
32
|
+
get closed(): boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An `Observer` is used to receive data from an `Observable`, and is supplied as an argument to `subscribe`.
|
|
37
|
+
*
|
|
38
|
+
* All methods are optional.
|
|
39
|
+
*/
|
|
40
|
+
declare class Observer<T> {
|
|
41
|
+
/** Receives the subscription object when `subscribe` is called */
|
|
42
|
+
start(subscription: Subscription);
|
|
43
|
+
|
|
44
|
+
/** Receives the next value in the sequence */
|
|
45
|
+
next: NextFunction<T>;
|
|
46
|
+
|
|
47
|
+
/** Receives the sequence error */
|
|
48
|
+
error: ErrorFunction;
|
|
49
|
+
|
|
50
|
+
/** Receives a completion notification */
|
|
51
|
+
complete: CompleteFunction;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** A `SubscriptionObserver` is a normalized `Observer` which wraps the observer object supplied to `subscribe`. */
|
|
55
|
+
declare class SubscriptionObserver<T> {
|
|
56
|
+
/** Sends the next value in the sequence */
|
|
57
|
+
next: NextFunction<T>;
|
|
58
|
+
|
|
59
|
+
/** Sends the sequence error */
|
|
60
|
+
error: ErrorFunction;
|
|
61
|
+
|
|
62
|
+
/** Sends the completion notification */
|
|
63
|
+
complete: CompleteFunction;
|
|
64
|
+
|
|
65
|
+
/** A boolean value indicating whether the subscription is closed */
|
|
66
|
+
get closed(): boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type { Observable, Observer, Subscription, SubscriptionObserver };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Notification } from './Notification';
|
|
2
|
+
import type { WebChatActivity } from '../external/WebChatActivity';
|
|
3
|
+
|
|
4
|
+
type ReduxState = {
|
|
5
|
+
activities: WebChatActivity[];
|
|
6
|
+
clockSkewAdjustment: number;
|
|
7
|
+
dictateState: string;
|
|
8
|
+
language: string;
|
|
9
|
+
notifications: { [key: string]: Notification };
|
|
10
|
+
sendBoxValue: string;
|
|
11
|
+
sendTimeout: number;
|
|
12
|
+
sendTypingIndicator: boolean;
|
|
13
|
+
shouldSpeakIncomingActivity: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { ReduxState };
|
|
@@ -6,6 +6,7 @@
|
|
|
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
|
|
9
10
|
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
10
11
|
const actual = dateToLocaleISOString(date);
|
|
11
12
|
|