botframework-webchat-core 4.15.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.
Files changed (200) hide show
  1. package/babel.config.json +1 -1
  2. package/lib/actions/clearSuggestedActions.js +1 -1
  3. package/lib/actions/connect.js +1 -1
  4. package/lib/actions/connectionStatusUpdate.js +1 -1
  5. package/lib/actions/deleteActivity.d.ts +13 -0
  6. package/lib/actions/deleteActivity.d.ts.map +1 -0
  7. package/lib/actions/deleteActivity.js +5 -3
  8. package/lib/actions/disconnect.js +1 -1
  9. package/lib/actions/dismissNotification.js +1 -1
  10. package/lib/actions/emitTypingIndicator.js +1 -1
  11. package/lib/actions/incomingActivity.d.ts +14 -0
  12. package/lib/actions/incomingActivity.d.ts.map +1 -0
  13. package/lib/actions/incomingActivity.js +5 -3
  14. package/lib/actions/markActivity.d.ts +17 -0
  15. package/lib/actions/markActivity.d.ts.map +1 -0
  16. package/lib/actions/markActivity.js +5 -3
  17. package/lib/actions/postActivity.d.ts +52 -0
  18. package/lib/actions/postActivity.d.ts.map +1 -0
  19. package/lib/actions/postActivity.js +5 -3
  20. package/lib/actions/queueIncomingActivity.js +1 -1
  21. package/lib/actions/sagaError.js +1 -1
  22. package/lib/actions/sendEvent.js +1 -1
  23. package/lib/actions/sendFiles.js +1 -1
  24. package/lib/actions/sendMessage.js +1 -1
  25. package/lib/actions/sendMessageBack.js +1 -1
  26. package/lib/actions/sendPostBack.js +1 -1
  27. package/lib/actions/setDictateInterims.js +1 -1
  28. package/lib/actions/setDictateState.js +1 -1
  29. package/lib/actions/setLanguage.js +1 -1
  30. package/lib/actions/setNotification.js +1 -1
  31. package/lib/actions/setReferenceGrammarID.js +1 -1
  32. package/lib/actions/setSendBox.js +1 -1
  33. package/lib/actions/setSendTimeout.js +1 -1
  34. package/lib/actions/setSendTypingIndicator.js +1 -1
  35. package/lib/actions/setSuggestedActions.js +1 -1
  36. package/lib/actions/startDictate.js +1 -1
  37. package/lib/actions/startSpeakingActivity.js +1 -1
  38. package/lib/actions/stopDictate.js +1 -1
  39. package/lib/actions/stopSpeakingActivity.js +1 -1
  40. package/lib/actions/submitSendBox.js +1 -1
  41. package/lib/actions/updateConnectionStatus.js +1 -1
  42. package/lib/constants/ActivityClientState.js +1 -1
  43. package/lib/definitions/speakingActivity.js +4 -2
  44. package/lib/index.d.ts +15 -14
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +4 -3
  47. package/lib/reducer.d.ts +1 -2
  48. package/lib/reducer.d.ts.map +1 -1
  49. package/lib/reducer.js +1 -4
  50. package/lib/reducers/activities.d.ts +10 -0
  51. package/lib/reducers/activities.d.ts.map +1 -0
  52. package/lib/reducers/activities.js +65 -45
  53. package/lib/reducers/typing.js +13 -7
  54. package/lib/sagas/effects/observeOnce.js +1 -1
  55. package/lib/sagas/effects/whileConnected.js +1 -1
  56. package/lib/sagas/observeActivitySaga.js +21 -3
  57. package/lib/sagas/postActivitySaga.js +51 -72
  58. package/lib/sagas/sendFilesToPostActivitySaga.js +4 -4
  59. package/lib/selectors/activities.js +1 -1
  60. package/lib/selectors/combineSelectors.js +3 -3
  61. package/lib/selectors/dictateState.js +1 -1
  62. package/lib/selectors/language.js +1 -1
  63. package/lib/selectors/notifications.js +1 -1
  64. package/lib/selectors/sendBoxValue.js +1 -1
  65. package/lib/selectors/sendTimeout.js +1 -1
  66. package/lib/selectors/sendTypingIndicator.js +1 -1
  67. package/lib/selectors/shouldSpeakIncomingActivity.js +1 -1
  68. package/lib/types/AnyAnd.d.ts +2 -0
  69. package/lib/types/AnyAnd.d.ts.map +1 -0
  70. package/lib/types/AnyAnd.js +6 -0
  71. package/lib/types/OneOrMany.js +4 -0
  72. package/lib/types/WebChatActivity.d.ts +81 -0
  73. package/lib/types/WebChatActivity.d.ts.map +1 -0
  74. package/lib/types/WebChatActivity.js +6 -0
  75. package/lib/types/external/DirectLineActivity.d.ts +1 -1
  76. package/lib/types/external/DirectLineActivity.d.ts.map +1 -1
  77. package/lib/types/external/DirectLineActivity.js +4 -0
  78. package/lib/types/external/DirectLineAnimationCard.d.ts +5 -2
  79. package/lib/types/external/DirectLineAnimationCard.d.ts.map +1 -1
  80. package/lib/types/external/DirectLineAnimationCard.js +4 -0
  81. package/lib/types/external/DirectLineAttachment.d.ts +8 -2
  82. package/lib/types/external/DirectLineAttachment.d.ts.map +1 -1
  83. package/lib/types/external/DirectLineAttachment.js +4 -0
  84. package/lib/types/external/DirectLineAudioCard.d.ts +5 -2
  85. package/lib/types/external/DirectLineAudioCard.d.ts.map +1 -1
  86. package/lib/types/external/DirectLineAudioCard.js +4 -0
  87. package/lib/types/external/DirectLineBasicCardEssence.d.ts +12 -0
  88. package/lib/types/external/DirectLineBasicCardEssence.d.ts.map +1 -0
  89. package/lib/types/external/DirectLineBasicCardEssence.js +6 -0
  90. package/lib/types/external/DirectLineCardAction.d.ts +1 -1
  91. package/lib/types/external/DirectLineCardAction.d.ts.map +1 -1
  92. package/lib/types/external/DirectLineCardAction.js +4 -0
  93. package/lib/types/external/DirectLineCardImage.d.ts +8 -0
  94. package/lib/types/external/DirectLineCardImage.d.ts.map +1 -0
  95. package/lib/types/external/DirectLineCardImage.js +6 -0
  96. package/lib/types/external/DirectLineHeroCard.d.ts +5 -2
  97. package/lib/types/external/DirectLineHeroCard.d.ts.map +1 -1
  98. package/lib/types/external/DirectLineHeroCard.js +4 -0
  99. package/lib/types/external/DirectLineJSBotConnection.d.ts +1 -1
  100. package/lib/types/external/DirectLineJSBotConnection.d.ts.map +1 -1
  101. package/lib/types/external/DirectLineJSBotConnection.js +4 -0
  102. package/lib/types/external/DirectLineMediaCardEssence.d.ts +21 -0
  103. package/lib/types/external/DirectLineMediaCardEssence.d.ts.map +1 -0
  104. package/lib/types/external/DirectLineMediaCardEssence.js +6 -0
  105. package/lib/types/external/DirectLineOAuthCard.d.ts +7 -2
  106. package/lib/types/external/DirectLineOAuthCard.d.ts.map +1 -1
  107. package/lib/types/external/DirectLineOAuthCard.js +4 -0
  108. package/lib/types/external/DirectLineReceiptCard.d.ts +27 -2
  109. package/lib/types/external/DirectLineReceiptCard.d.ts.map +1 -1
  110. package/lib/types/external/DirectLineReceiptCard.js +4 -0
  111. package/lib/types/external/DirectLineSignInCard.d.ts +7 -2
  112. package/lib/types/external/DirectLineSignInCard.d.ts.map +1 -1
  113. package/lib/types/external/DirectLineSignInCard.js +4 -0
  114. package/lib/types/external/DirectLineSuggestedAction.d.ts +6 -2
  115. package/lib/types/external/DirectLineSuggestedAction.d.ts.map +1 -1
  116. package/lib/types/external/DirectLineSuggestedAction.js +4 -0
  117. package/lib/types/external/DirectLineThumbnailCard.d.ts +5 -2
  118. package/lib/types/external/DirectLineThumbnailCard.d.ts.map +1 -1
  119. package/lib/types/external/DirectLineThumbnailCard.js +4 -0
  120. package/lib/types/external/DirectLineVideoCard.d.ts +5 -2
  121. package/lib/types/external/DirectLineVideoCard.d.ts.map +1 -1
  122. package/lib/types/external/DirectLineVideoCard.js +4 -0
  123. package/lib/types/external/Observable.js +6 -0
  124. package/lib/types/internal/Notification.js +6 -0
  125. package/lib/types/internal/ReduxState.js +6 -0
  126. package/lib/utils/dateToLocaleISOString.js +5 -5
  127. package/lib/utils/deleteKey.js +1 -1
  128. package/lib/utils/sleep.js +1 -1
  129. package/lib/utils/uniqueID.js +1 -1
  130. package/package.json +18 -14
  131. package/src/actions/deleteActivity.ts +19 -0
  132. package/src/actions/incomingActivity.ts +21 -0
  133. package/src/actions/markActivity.ts +23 -0
  134. package/src/actions/postActivity.ts +48 -0
  135. package/src/definitions/speakingActivity.js +1 -1
  136. package/src/index.ts +17 -14
  137. package/src/reducer.ts +0 -2
  138. package/src/reducers/activities.ts +172 -0
  139. package/src/reducers/typing.js +6 -5
  140. package/src/sagas/effects/{observeOnce.js → observeOnce.ts} +6 -4
  141. package/src/sagas/effects/{whileConnected.js → whileConnected.ts} +20 -1
  142. package/src/sagas/{observeActivitySaga.js → observeActivitySaga.ts} +25 -6
  143. package/src/sagas/{postActivitySaga.js → postActivitySaga.ts} +57 -48
  144. package/src/sagas/sendFilesToPostActivitySaga.js +1 -1
  145. package/src/selectors/activities.ts +12 -0
  146. package/src/selectors/{combineSelectors.js → combineSelectors.ts} +7 -2
  147. package/src/selectors/dictateState.ts +3 -0
  148. package/src/selectors/language.ts +3 -0
  149. package/src/selectors/notifications.ts +6 -0
  150. package/src/selectors/sendBoxValue.ts +3 -0
  151. package/src/selectors/sendTimeout.ts +3 -0
  152. package/src/selectors/sendTypingIndicator.ts +3 -0
  153. package/src/selectors/shouldSpeakIncomingActivity.ts +3 -0
  154. package/src/types/AnyAnd.ts +1 -0
  155. package/src/types/WebChatActivity.ts +154 -0
  156. package/src/types/external/DirectLineActivity.ts +1 -1
  157. package/src/types/external/DirectLineAnimationCard.ts +6 -3
  158. package/src/types/external/DirectLineAttachment.ts +10 -4
  159. package/src/types/external/DirectLineAudioCard.ts +6 -3
  160. package/src/types/external/DirectLineBasicCardEssence.ts +14 -0
  161. package/src/types/external/DirectLineCardAction.ts +1 -1
  162. package/src/types/external/DirectLineCardImage.ts +9 -0
  163. package/src/types/external/DirectLineHeroCard.ts +6 -3
  164. package/src/types/external/DirectLineJSBotConnection.ts +1 -1
  165. package/src/types/external/DirectLineMediaCardEssence.ts +19 -0
  166. package/src/types/external/DirectLineOAuthCard.ts +7 -3
  167. package/src/types/external/DirectLineReceiptCard.ts +30 -3
  168. package/src/types/external/DirectLineSignInCard.ts +8 -3
  169. package/src/types/external/DirectLineSuggestedAction.ts +6 -3
  170. package/src/types/external/DirectLineThumbnailCard.ts +6 -3
  171. package/src/types/external/DirectLineVideoCard.ts +6 -3
  172. package/src/types/external/Observable.ts +69 -0
  173. package/src/types/internal/Notification.ts +10 -0
  174. package/src/types/internal/ReduxState.ts +16 -0
  175. package/src/utils/{dateToLocaleISOString.js → dateToLocaleISOString.ts} +6 -6
  176. package/src/utils/deleteKey.ts +9 -0
  177. package/src/utils/{sleep.js → sleep.ts} +1 -1
  178. package/src/utils/{uniqueID.js → uniqueID.ts} +1 -1
  179. package/lib/reducers/clockSkewAdjustment.js +0 -44
  180. package/lib/sagas/effects/callUntil.js +0 -48
  181. package/lib/selectors/clockSkewAdjustment.js +0 -14
  182. package/lib/utils/mime-wrapper.js +0 -47
  183. package/src/actions/deleteActivity.js +0 -8
  184. package/src/actions/incomingActivity.js +0 -10
  185. package/src/actions/markActivity.js +0 -14
  186. package/src/actions/postActivity.js +0 -14
  187. package/src/reducers/activities.js +0 -116
  188. package/src/reducers/clockSkewAdjustment.js +0 -29
  189. package/src/sagas/effects/callUntil.js +0 -13
  190. package/src/selectors/activities.js +0 -8
  191. package/src/selectors/clockSkewAdjustment.js +0 -1
  192. package/src/selectors/dictateState.js +0 -1
  193. package/src/selectors/language.js +0 -1
  194. package/src/selectors/notifications.js +0 -3
  195. package/src/selectors/sendBoxValue.js +0 -1
  196. package/src/selectors/sendTimeout.js +0 -1
  197. package/src/selectors/sendTypingIndicator.js +0 -1
  198. package/src/selectors/shouldSpeakIncomingActivity.js +0 -1
  199. package/src/utils/deleteKey.js +0 -9
  200. package/src/utils/mime-wrapper.js +0 -39
@@ -1,6 +1,11 @@
1
1
  import isForbiddenPropertyName from '../utils/isForbiddenPropertyName';
2
2
 
3
- export default function combineSelectors(selectors) {
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
+ } {
4
9
  if (Array.isArray(selectors)) {
5
10
  return state => selectors.reduce((combinedState, selector) => [...combinedState, selector(state)], []);
6
11
  }
@@ -11,6 +16,6 @@ export default function combineSelectors(selectors) {
11
16
  // Mitigated through denylisting.
12
17
  // eslint-disable-next-line security/detect-object-injection
13
18
  isForbiddenPropertyName(key) ? combinedState : { ...combinedState, [key]: selectors[key](state) },
14
- {}
19
+ {} as TResult
15
20
  );
16
21
  }
@@ -0,0 +1,3 @@
1
+ import type { ReduxState } from '../types/internal/ReduxState';
2
+
3
+ export default ({ dictateState }: ReduxState) => dictateState;
@@ -0,0 +1,3 @@
1
+ import type { ReduxState } from '../types/internal/ReduxState';
2
+
3
+ export default ({ language }: ReduxState): string => language;
@@ -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,3 @@
1
+ import type { ReduxState } from '../types/internal/ReduxState';
2
+
3
+ export default ({ sendBoxValue }: ReduxState): string => sendBoxValue;
@@ -0,0 +1,3 @@
1
+ import type { ReduxState } from '../types/internal/ReduxState';
2
+
3
+ export default ({ sendTimeout }: ReduxState): number => sendTimeout;
@@ -0,0 +1,3 @@
1
+ import type { ReduxState } from '../types/internal/ReduxState';
2
+
3
+ export default ({ sendTypingIndicator }: ReduxState): boolean => sendTypingIndicator;
@@ -0,0 +1,3 @@
1
+ import type { ReduxState } from '../types/internal/ReduxState';
2
+
3
+ export default ({ shouldSpeakIncomingActivity }: ReduxState): boolean => shouldSpeakIncomingActivity;
@@ -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 };
@@ -4,4 +4,4 @@
4
4
  // We only know the DirectLineActivity must be a map, and not other primitive types.
5
5
  type DirectLineActivity = Exclude<any, [] | boolean | Function | number | string>;
6
6
 
7
- export default DirectLineActivity;
7
+ export type { DirectLineActivity };
@@ -1,5 +1,8 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineMediaCardEssence } from './DirectLineMediaCardEssence';
2
2
 
3
- type DirectLineAnimationCard = any;
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
+ };
4
7
 
5
- export default DirectLineAnimationCard;
8
+ export type { DirectLineAnimationCard };
@@ -1,5 +1,11 @@
1
- // TODO: [P1] #3953 We should fully type it out.
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
- type DirectLineAttachment = any;
4
-
5
- export default DirectLineAttachment;
11
+ export type { DirectLineAttachment };
@@ -1,5 +1,8 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineMediaCardEssence } from './DirectLineMediaCardEssence';
2
2
 
3
- type DirectLineAudioCard = any;
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
+ };
4
7
 
5
- export default DirectLineAudioCard;
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 };
@@ -125,4 +125,4 @@ type DirectLineCardAction =
125
125
  | ShowImageCardAction
126
126
  | SignInCardAction;
127
127
 
128
- export default DirectLineCardAction;
128
+ export type { DirectLineCardAction };
@@ -0,0 +1,9 @@
1
+ import type { DirectLineCardAction } from './DirectLineCardAction';
2
+
3
+ type DirectLineCardImage = {
4
+ alt: string;
5
+ tap?: DirectLineCardAction;
6
+ url: string;
7
+ };
8
+
9
+ export type { DirectLineCardImage };
@@ -1,5 +1,8 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineBasicCardEssence } from './DirectLineBasicCardEssence';
2
2
 
3
- type DirectLineHeroCard = any;
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
+ };
4
7
 
5
- export default DirectLineHeroCard;
8
+ export type { DirectLineHeroCard };
@@ -2,4 +2,4 @@
2
2
 
3
3
  type DirectLineJSBotConnection = any;
4
4
 
5
- export default DirectLineJSBotConnection;
5
+ export type { DirectLineJSBotConnection };
@@ -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,5 +1,9 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineCardAction } from './DirectLineCardAction';
2
2
 
3
- type DirectLineOAuthCard = any;
3
+ type DirectLineOAuthCard = {
4
+ buttons?: DirectLineCardAction[];
5
+ contentType: 'application/vnd.microsoft.card.oauth';
6
+ text?: string;
7
+ };
4
8
 
5
- export default DirectLineOAuthCard;
9
+ export type { DirectLineOAuthCard };
@@ -1,5 +1,32 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineCardAction } from './DirectLineCardAction';
2
+ import type { DirectLineCardImage } from './DirectLineCardImage';
2
3
 
3
- type DirectLineReceiptCard = any;
4
+ type Fact = {
5
+ key?: string;
6
+ value?: string;
7
+ };
4
8
 
5
- export default DirectLineReceiptCard;
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,5 +1,10 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineCardAction } from './DirectLineCardAction';
2
2
 
3
- type DirectLineSignInCard = any;
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
+ };
4
9
 
5
- export default DirectLineSignInCard;
10
+ export type { DirectLineSignInCard };
@@ -1,5 +1,8 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineCardAction } from './DirectLineCardAction';
2
2
 
3
- type DirectLineSuggestedAction = any;
3
+ type DirectLineSuggestedAction = {
4
+ actions?: DirectLineCardAction[];
5
+ to?: string[];
6
+ };
4
7
 
5
- export default DirectLineSuggestedAction;
8
+ export type { DirectLineSuggestedAction };
@@ -1,5 +1,8 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineBasicCardEssence } from './DirectLineBasicCardEssence';
2
2
 
3
- type DirectLineThumbnailCard = any;
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
+ };
4
7
 
5
- export default DirectLineThumbnailCard;
8
+ export type { DirectLineThumbnailCard };
@@ -1,5 +1,8 @@
1
- // TODO: [P1] #3953 We should fully type it out.
1
+ import type { DirectLineMediaCardEssence } from './DirectLineMediaCardEssence';
2
2
 
3
- type DirectLineVideoCard = any;
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
+ };
4
7
 
5
- export default DirectLineVideoCard;
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,10 @@
1
+ type Notification = {
2
+ alt: string;
3
+ data: any;
4
+ id: string;
5
+ level: string;
6
+ message: string;
7
+ timestamp: number;
8
+ };
9
+
10
+ export type { Notification };
@@ -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 };
@@ -1,21 +1,21 @@
1
1
  /* eslint no-magic-numbers: ["off", { "ignore": [1, 2, 3, 60] }] */
2
2
 
3
- function pad(value, count = 2) {
3
+ function pad(value: number, count = 2): string {
4
4
  if (typeof value !== 'number') {
5
5
  throw new Error('First argument must be a number');
6
6
  }
7
7
 
8
- value += '';
8
+ let stringValue = value + '';
9
9
 
10
- while (value.length < count) {
11
- value = '0' + value;
10
+ while (stringValue.length < count) {
11
+ stringValue = '0' + stringValue;
12
12
  }
13
13
 
14
- return value;
14
+ return stringValue;
15
15
  }
16
16
 
17
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) {
18
+ export default function dateToLocaleISOString(date: Date): string {
19
19
  if (!(date instanceof Date)) {
20
20
  throw new Error('First argument must be a Date object');
21
21
  }
@@ -0,0 +1,9 @@
1
+ export default function deleteKey<TMap, TKey extends keyof TMap>(map: TMap, key: TKey): Omit<TMap, TKey> {
2
+ if (!map) {
3
+ return map;
4
+ }
5
+
6
+ const { [key]: _deleted, ...nextMap } = map;
7
+
8
+ return nextMap;
9
+ }
@@ -1,3 +1,3 @@
1
- export default function sleep(interval) {
1
+ export default function sleep(interval: number): Promise<void> {
2
2
  return new Promise(resolve => setTimeout(resolve, interval));
3
3
  }
@@ -2,6 +2,6 @@
2
2
 
3
3
  import random from 'math-random';
4
4
 
5
- export default function uniqueID() {
5
+ export default function uniqueID(): string {
6
6
  return Date.now() + random().toString(36).substr(2);
7
7
  }
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = clockSkewAdjustment;
7
-
8
- var _incomingActivity = require("../actions/incomingActivity");
9
-
10
- var _setClockSkewAdjustment = require("../actions/setClockSkewAdjustment");
11
-
12
- function clockSkewAdjustment() {
13
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
14
-
15
- var _ref = arguments.length > 1 ? arguments[1] : undefined,
16
- payload = _ref.payload,
17
- type = _ref.type;
18
-
19
- if (type === _incomingActivity.INCOMING_ACTIVITY) {
20
- var _payload$activity = payload.activity,
21
- _payload$activity$cha = _payload$activity.channelData;
22
- _payload$activity$cha = _payload$activity$cha === void 0 ? {} : _payload$activity$cha;
23
- var clientTimestamp = _payload$activity$cha.clientTimestamp,
24
- timestamp = _payload$activity.timestamp;
25
- var clientSendTime = Date.parse(clientTimestamp);
26
- var serverTime = Date.parse(timestamp);
27
-
28
- if (!isNaN(clientSendTime) && !isNaN(serverTime)) {
29
- // The adjustment include the latency between the client and the server.
30
- // This means, the adjustment is always larger than the actual value.
31
- // And it means, after adjustment, client time will be ahead of server time.
32
- // And it also means, the user-originated message has higher probability to appear below bot-originated message.
33
- // Although it has higher probability, if the user-originated message is still sending (i.e. did not echoback with server timestamp yet),
34
- // the insertion-sort logic will put the bot-originated below the user-originated message.
35
- state = serverTime - clientSendTime;
36
- }
37
- } else if (type === _setClockSkewAdjustment.SET_CLOCK_SKEW_ADJUSTMENT) {
38
- // Currently, this action is for testing purpose only.
39
- state = payload.value;
40
- }
41
-
42
- return state;
43
- }
44
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9yZWR1Y2Vycy9jbG9ja1NrZXdBZGp1c3RtZW50LmpzIl0sIm5hbWVzIjpbImNsb2NrU2tld0FkanVzdG1lbnQiLCJzdGF0ZSIsInBheWxvYWQiLCJ0eXBlIiwiSU5DT01JTkdfQUNUSVZJVFkiLCJhY3Rpdml0eSIsImNoYW5uZWxEYXRhIiwiY2xpZW50VGltZXN0YW1wIiwidGltZXN0YW1wIiwiY2xpZW50U2VuZFRpbWUiLCJEYXRlIiwicGFyc2UiLCJzZXJ2ZXJUaW1lIiwiaXNOYU4iLCJTRVRfQ0xPQ0tfU0tFV19BREpVU1RNRU5UIiwidmFsdWUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7QUFDQTs7QUFFZSxTQUFTQSxtQkFBVCxHQUEyRDtBQUFBLE1BQTlCQyxLQUE4Qix1RUFBdEIsQ0FBc0I7O0FBQUE7QUFBQSxNQUFqQkMsT0FBaUIsUUFBakJBLE9BQWlCO0FBQUEsTUFBUkMsSUFBUSxRQUFSQSxJQUFROztBQUN4RSxNQUFJQSxJQUFJLEtBQUtDLG1DQUFiLEVBQWdDO0FBQzlCLDRCQUVJRixPQUZKLENBQ0VHLFFBREY7QUFBQSxrREFDY0MsV0FEZDtBQUFBLCtEQUNpRCxFQURqRDtBQUFBLFFBQzZCQyxlQUQ3Qix5QkFDNkJBLGVBRDdCO0FBQUEsUUFDcURDLFNBRHJELHFCQUNxREEsU0FEckQ7QUFJQSxRQUFNQyxjQUFjLEdBQUdDLElBQU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