botframework-webchat-core 4.13.0 → 4.14.2
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/lib/createPromiseQueue.js +1 -1
- package/lib/createStore.d.ts +3 -2
- package/lib/createStore.d.ts.map +1 -0
- package/lib/createStore.js +1 -1
- package/lib/index.d.ts +49 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -6
- package/lib/reducer.d.ts +1 -0
- package/lib/reducer.d.ts.map +1 -0
- package/lib/reducers/activities.js +1 -1
- package/lib/reducers/clockSkewAdjustment.js +1 -1
- package/lib/reducers/lastTypingAt.js +1 -1
- package/lib/reducers/notifications.js +1 -1
- package/lib/reducers/typing.js +1 -1
- package/lib/sagas/connectSaga.js +14 -8
- package/lib/sagas/connectionStatusToNotificationSaga.js +1 -1
- package/lib/sagas/effects/forkPut.js +1 -1
- package/lib/sagas/markAllAsSpokenOnStopSpeakActivitySaga.js +1 -1
- package/lib/sagas/observeActivitySaga.js +1 -1
- package/lib/sagas/postActivitySaga.js +39 -32
- package/lib/sagas/queueIncomingActivitySaga.js +7 -3
- package/lib/sagas/sendMessageBackToPostActivitySaga.js +4 -4
- package/lib/sagas/sendPostBackToPostActivitySaga.js +4 -4
- package/lib/selectors/combineSelectors.js +1 -1
- package/lib/types/OneOrMany.d.ts +3 -0
- package/lib/types/OneOrMany.d.ts.map +1 -0
- package/lib/types/OneOrMany.js +2 -0
- package/lib/types/external/DirectLineActivity.d.ts +3 -0
- package/lib/types/external/DirectLineActivity.d.ts.map +1 -0
- package/lib/types/external/DirectLineActivity.js +2 -0
- package/lib/types/external/DirectLineAnimationCard.d.ts +3 -0
- package/lib/types/external/DirectLineAnimationCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineAnimationCard.js +2 -0
- package/lib/types/external/DirectLineAttachment.d.ts +3 -0
- package/lib/types/external/DirectLineAttachment.d.ts.map +1 -0
- package/lib/types/external/DirectLineAttachment.js +2 -0
- package/lib/types/external/DirectLineAudioCard.d.ts +3 -0
- package/lib/types/external/DirectLineAudioCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineAudioCard.js +2 -0
- package/lib/types/external/DirectLineCardAction.d.ts +110 -0
- package/lib/types/external/DirectLineCardAction.d.ts.map +1 -0
- package/lib/types/external/DirectLineCardAction.js +2 -0
- package/lib/types/external/DirectLineHeroCard.d.ts +3 -0
- package/lib/types/external/DirectLineHeroCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineHeroCard.js +2 -0
- package/lib/types/external/DirectLineJSBotConnection.d.ts +3 -0
- package/lib/types/external/DirectLineJSBotConnection.d.ts.map +1 -0
- package/lib/types/external/DirectLineJSBotConnection.js +2 -0
- package/lib/types/external/DirectLineOAuthCard.d.ts +3 -0
- package/lib/types/external/DirectLineOAuthCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineOAuthCard.js +2 -0
- package/lib/types/external/DirectLineReceiptCard.d.ts +3 -0
- package/lib/types/external/DirectLineReceiptCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineReceiptCard.js +2 -0
- package/lib/types/external/DirectLineSignInCard.d.ts +3 -0
- package/lib/types/external/DirectLineSignInCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineSignInCard.js +2 -0
- package/lib/types/external/DirectLineSuggestedAction.d.ts +3 -0
- package/lib/types/external/DirectLineSuggestedAction.d.ts.map +1 -0
- package/lib/types/external/DirectLineSuggestedAction.js +2 -0
- package/lib/types/external/DirectLineThumbnailCard.d.ts +3 -0
- package/lib/types/external/DirectLineThumbnailCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineThumbnailCard.js +2 -0
- package/lib/types/external/DirectLineVideoCard.d.ts +3 -0
- package/lib/types/external/DirectLineVideoCard.d.ts.map +1 -0
- package/lib/types/external/DirectLineVideoCard.js +2 -0
- package/lib/utils/dateToLocaleISOString.js +37 -0
- package/lib/utils/deleteKey.js +1 -1
- package/lib/utils/once.d.ts +2 -0
- package/lib/utils/once.d.ts.map +1 -0
- package/lib/utils/once.js +17 -0
- package/lib/utils/singleToArray.d.ts +2 -0
- package/lib/utils/singleToArray.d.ts.map +1 -0
- package/lib/utils/singleToArray.js +11 -0
- package/lib/utils/warnOnce.d.ts +2 -0
- package/lib/utils/warnOnce.d.ts.map +1 -0
- package/lib/utils/warnOnce.js +17 -0
- package/package.json +25 -21
- package/src/createStore.ts +2 -2
- package/src/{index.js → index.ts} +38 -4
- package/src/sagas/connectSaga.js +9 -2
- package/src/sagas/postActivitySaga.js +11 -4
- package/src/sagas/sendMessageBackToPostActivitySaga.js +3 -3
- package/src/sagas/sendPostBackToPostActivitySaga.js +2 -3
- package/src/tsconfig.json +7 -3
- package/src/types/OneOrMany.ts +3 -0
- package/src/types/external/DirectLineActivity.ts +6 -0
- package/src/types/external/DirectLineAnimationCard.ts +6 -0
- package/src/types/external/DirectLineAttachment.ts +6 -0
- package/src/types/external/DirectLineAudioCard.ts +6 -0
- package/src/types/external/DirectLineCardAction.ts +128 -0
- package/src/types/external/DirectLineHeroCard.ts +6 -0
- package/src/types/external/DirectLineJSBotConnection.ts +6 -0
- package/src/types/external/DirectLineOAuthCard.ts +6 -0
- package/src/types/external/DirectLineReceiptCard.ts +6 -0
- package/src/types/external/DirectLineSignInCard.ts +6 -0
- package/src/types/external/DirectLineSuggestedAction.ts +6 -0
- package/src/types/external/DirectLineThumbnailCard.ts +6 -0
- package/src/types/external/DirectLineVideoCard.ts +6 -0
- package/src/utils/dateToLocaleISOString.chatham.spec.js +13 -0
- package/src/utils/dateToLocaleISOString.japan.spec.js +13 -0
- package/src/utils/dateToLocaleISOString.js +34 -0
- package/src/utils/dateToLocaleISOString.pacific.spec.js +13 -0
- package/src/utils/dateToLocaleISOString.utc.spec.js +20 -0
- package/src/utils/once.ts +10 -0
- package/src/utils/singleToArray.ts +3 -0
- package/src/utils/warnOnce.ts +5 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
type CardActionWithImageAndTitle =
|
|
2
|
+
| { image: string }
|
|
3
|
+
| { title: string }
|
|
4
|
+
| {
|
|
5
|
+
image: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A `call` action represents a telephone number that may be called.
|
|
11
|
+
*
|
|
12
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#call
|
|
13
|
+
*/
|
|
14
|
+
type CallCardAction = CardActionWithImageAndTitle & {
|
|
15
|
+
type: 'call';
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A `downloadFile` action represents a hyperlink to be downloaded.
|
|
21
|
+
*
|
|
22
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#download-file-actions
|
|
23
|
+
*/
|
|
24
|
+
type DownloadFileCardAction = CardActionWithImageAndTitle & {
|
|
25
|
+
type: 'downloadFile';
|
|
26
|
+
value: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An `imBack` action represents a text response that is added to the chat feed.
|
|
31
|
+
*
|
|
32
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#im-back
|
|
33
|
+
*/
|
|
34
|
+
type IMBackCardAction = CardActionWithImageAndTitle & {
|
|
35
|
+
type: 'imBack';
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A `messageBack` action represents a text response to be sent via the chat system.
|
|
41
|
+
*
|
|
42
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#message-back
|
|
43
|
+
*/
|
|
44
|
+
type MessageBackCardAction = CardActionWithImageAndTitle & {
|
|
45
|
+
displayText?: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
type: 'messageBack';
|
|
48
|
+
value?: { [key: string]: any };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An `openUrl` action represents a hyperlink to be handled by the client.
|
|
53
|
+
*
|
|
54
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#open-url-actions
|
|
55
|
+
*/
|
|
56
|
+
type OpenURLCardAction = CardActionWithImageAndTitle & {
|
|
57
|
+
type: 'openUrl';
|
|
58
|
+
value: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A `playAudio` action represents audio media that may be played.
|
|
63
|
+
*
|
|
64
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#play-audio
|
|
65
|
+
*/
|
|
66
|
+
type PlayAudioCardAction = CardActionWithImageAndTitle & {
|
|
67
|
+
type: 'playAudio';
|
|
68
|
+
value: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A `playVideo` action represents video media that may be played.
|
|
73
|
+
*
|
|
74
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#play-video
|
|
75
|
+
*/
|
|
76
|
+
type PlayVideoCardAction = CardActionWithImageAndTitle & {
|
|
77
|
+
type: 'playVideo';
|
|
78
|
+
value: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A `postBack` action represents a text response that is not added to the chat feed.
|
|
83
|
+
*
|
|
84
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#post-back
|
|
85
|
+
*/
|
|
86
|
+
type PostBackCardAction = CardActionWithImageAndTitle & {
|
|
87
|
+
type: 'postBack';
|
|
88
|
+
value: any; // For legacy reason, postBack support any.
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A `showImage` action represents an image that may be displayed.
|
|
93
|
+
*
|
|
94
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#show-image-file-actions
|
|
95
|
+
*/
|
|
96
|
+
type ShowImageCardAction = CardActionWithImageAndTitle & {
|
|
97
|
+
type: 'showImage';
|
|
98
|
+
value: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A `signin` action represents a hyperlink to be handled by the client's signin system.
|
|
103
|
+
*
|
|
104
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#signin
|
|
105
|
+
*/
|
|
106
|
+
type SignInCardAction = CardActionWithImageAndTitle & {
|
|
107
|
+
type: 'signin';
|
|
108
|
+
value: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A card action represents a clickable or interactive button for use within cards or as suggested actions. They are used to solicit input from users. Despite their name, card actions are not limited to use solely on cards.
|
|
113
|
+
*
|
|
114
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#card-action
|
|
115
|
+
*/
|
|
116
|
+
type DirectLineCardAction =
|
|
117
|
+
| CallCardAction
|
|
118
|
+
| DownloadFileCardAction
|
|
119
|
+
| IMBackCardAction
|
|
120
|
+
| MessageBackCardAction
|
|
121
|
+
| OpenURLCardAction
|
|
122
|
+
| PlayAudioCardAction
|
|
123
|
+
| PlayVideoCardAction
|
|
124
|
+
| PostBackCardAction
|
|
125
|
+
| ShowImageCardAction
|
|
126
|
+
| SignInCardAction;
|
|
127
|
+
|
|
128
|
+
export default DirectLineCardAction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment ../../../__tests__/setup/jestNodeEnvironmentWithTimezone.js
|
|
3
|
+
* @timezone Pacific/Chatham
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
|
+
|
|
8
|
+
test('formatting a time in Chatham Islands timezone', () => {
|
|
9
|
+
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
10
|
+
const actual = dateToLocaleISOString(date);
|
|
11
|
+
|
|
12
|
+
expect(actual).toMatchInlineSnapshot(`"2000-01-01T13:57:34.567+13:45"`);
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment ../../../__tests__/setup/jestNodeEnvironmentWithTimezone.js
|
|
3
|
+
* @timezone Asia/Tokyo
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
|
+
|
|
8
|
+
test('formatting a time in Japan timezone', () => {
|
|
9
|
+
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
10
|
+
const actual = dateToLocaleISOString(date);
|
|
11
|
+
|
|
12
|
+
expect(actual).toMatchInlineSnapshot(`"2000-01-01T09:12:34.567+09:00"`);
|
|
13
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint no-magic-numbers: ["off", { "ignore": [1, 2, 3, 60] }] */
|
|
2
|
+
|
|
3
|
+
function pad(value, count = 2) {
|
|
4
|
+
if (typeof value !== 'number') {
|
|
5
|
+
throw new Error('First argument must be a number');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
value += '';
|
|
9
|
+
|
|
10
|
+
while (value.length < count) {
|
|
11
|
+
value = '0' + value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Adopted from https://stackoverflow.com/questions/17415579/how-to-iso-8601-format-a-date-with-timezone-offset-in-javascript.
|
|
18
|
+
export default function dateToLocaleISOString(date) {
|
|
19
|
+
if (!(date instanceof Date)) {
|
|
20
|
+
throw new Error('First argument must be a Date object');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const timezoneOffset = -date.getTimezoneOffset();
|
|
24
|
+
const timezoneSign = timezoneOffset < 0 ? '-' : '+';
|
|
25
|
+
|
|
26
|
+
// "yyyy-MM-DDTHH:mm:ss.fff+08:00" for GMT+08
|
|
27
|
+
// "yyyy-MM-DDTHH:mm:ss.fffZ" for UTC
|
|
28
|
+
|
|
29
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(
|
|
30
|
+
date.getMinutes()
|
|
31
|
+
)}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${
|
|
32
|
+
timezoneOffset ? `${timezoneSign}${pad(~~(Math.abs(timezoneOffset) / 60))}:${pad(timezoneOffset % 60)}` : 'Z'
|
|
33
|
+
}`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment ../../../__tests__/setup/jestNodeEnvironmentWithTimezone.js
|
|
3
|
+
* @timezone America/Los_Angeles
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
|
+
|
|
8
|
+
test('formatting a time in Pacific Standard Time timezone', () => {
|
|
9
|
+
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
10
|
+
const actual = dateToLocaleISOString(date);
|
|
11
|
+
|
|
12
|
+
expect(actual).toMatchInlineSnapshot(`"1999-12-31T16:12:34.567-08:00"`);
|
|
13
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment ../../../__tests__/setup/jestNodeEnvironmentWithTimezone.js
|
|
3
|
+
* @timezone Etc/UTC
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import dateToLocaleISOString from './dateToLocaleISOString';
|
|
7
|
+
|
|
8
|
+
test('formatting a time in UTC timezone', () => {
|
|
9
|
+
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
|
|
10
|
+
const actual = dateToLocaleISOString(date);
|
|
11
|
+
|
|
12
|
+
expect(actual).toMatchInlineSnapshot(`"2000-01-01T00:12:34.567Z"`);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('formatting a time in UTC timezone with zero milliseconds', () => {
|
|
16
|
+
const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 0));
|
|
17
|
+
const actual = dateToLocaleISOString(date);
|
|
18
|
+
|
|
19
|
+
expect(actual).toMatchInlineSnapshot(`"2000-01-01T00:12:34.000Z"`);
|
|
20
|
+
});
|