@twilio/conversations 1.3.0-rc8 → 2.0.0-rc.4

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 (282) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +22 -17
  3. package/dist/browser.js +7873 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/docs/assets/css/main.css +2660 -0
  6. package/dist/docs/assets/images/icons.png +0 -0
  7. package/dist/docs/assets/images/icons@2x.png +0 -0
  8. package/dist/docs/assets/images/widgets.png +0 -0
  9. package/dist/docs/assets/images/widgets@2x.png +0 -0
  10. package/dist/docs/assets/js/main.js +248 -0
  11. package/dist/docs/assets/js/search.js +1 -0
  12. package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
  13. package/dist/docs/classes/Client.html +4181 -0
  14. package/dist/docs/classes/Conversation.html +4397 -0
  15. package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
  16. package/dist/docs/classes/Media.html +3295 -0
  17. package/dist/docs/classes/Message.html +3713 -0
  18. package/dist/docs/classes/MessageBuilder.html +3280 -0
  19. package/dist/docs/classes/Participant.html +3517 -0
  20. package/dist/docs/classes/PushNotification.html +3232 -0
  21. package/dist/docs/classes/RestPaginator.html +3262 -0
  22. package/dist/docs/classes/UnsentMessage.html +3144 -0
  23. package/dist/docs/classes/User.html +3451 -0
  24. package/dist/docs/index.html +3394 -212
  25. package/dist/docs/interfaces/ClientOptions.html +3136 -0
  26. package/dist/docs/interfaces/ConversationState.html +3152 -0
  27. package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
  28. package/dist/docs/interfaces/LastMessage.html +3152 -0
  29. package/dist/docs/interfaces/Paginator.html +3243 -0
  30. package/dist/docs/interfaces/PushNotificationData.html +3168 -0
  31. package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
  32. package/dist/docs/interfaces/SendMediaOptions.html +3170 -0
  33. package/dist/docs/modules.html +3425 -0
  34. package/dist/lib.d.ts +1952 -0
  35. package/dist/lib.js +7873 -0
  36. package/dist/lib.js.map +1 -0
  37. package/dist/post-install.js +29 -0
  38. package/dist/react-native.js +4038 -0
  39. package/dist/react-native.js.map +1 -0
  40. package/dist/twilio-conversations.js +40912 -0
  41. package/dist/twilio-conversations.min.js +156 -0
  42. package/package.json +59 -48
  43. package/.circleci/config.yml +0 -650
  44. package/.deepsource.toml +0 -6
  45. package/.env.example +0 -13
  46. package/browser/aggregateddeliveryreceipt.js +0 -152
  47. package/browser/client.js +0 -991
  48. package/browser/configuration.js +0 -80
  49. package/browser/conversation.js +0 -1826
  50. package/browser/data/conversations.js +0 -632
  51. package/browser/data/messages.js +0 -522
  52. package/browser/data/participants.js +0 -411
  53. package/browser/data/users.js +0 -281
  54. package/browser/detaileddeliveryreceipt.js +0 -44
  55. package/browser/index.js +0 -4
  56. package/browser/interfaces/limits.js +0 -3
  57. package/browser/interfaces/notificationtypes.js +0 -21
  58. package/browser/interfaces/paginator.js +0 -53
  59. package/browser/interfaces/responsecodes.js +0 -20
  60. package/browser/interfaces/transport.js +0 -3
  61. package/browser/logger.js +0 -141
  62. package/browser/media.js +0 -198
  63. package/browser/message.js +0 -685
  64. package/browser/participant.js +0 -415
  65. package/browser/pushnotification.js +0 -49
  66. package/browser/restpaginator.js +0 -74
  67. package/browser/services/network.js +0 -223
  68. package/browser/services/readhorizon.js +0 -181
  69. package/browser/services/typingindicator.js +0 -142
  70. package/browser/session.js +0 -505
  71. package/browser/sessionerror.js +0 -93
  72. package/browser/sri.json +0 -1
  73. package/browser/synclist.js +0 -90
  74. package/browser/synclistdescriptor.js +0 -29
  75. package/browser/syncpaginator.js +0 -63
  76. package/browser/user.js +0 -431
  77. package/browser/util/deferred.js +0 -56
  78. package/browser/util/index.js +0 -108
  79. package/dist/@twilio/conversations.js +0 -35533
  80. package/dist/@twilio/conversations.min.js +0 -204
  81. package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
  82. package/dist/docs/Client.html +0 -5075
  83. package/dist/docs/Conversation.html +0 -6018
  84. package/dist/docs/DetailedDeliveryReceipt.html +0 -641
  85. package/dist/docs/Media.html +0 -694
  86. package/dist/docs/Message.html +0 -1934
  87. package/dist/docs/Paginator.html +0 -605
  88. package/dist/docs/Participant.html +0 -1510
  89. package/dist/docs/PushNotification.html +0 -836
  90. package/dist/docs/SessionError.html +0 -379
  91. package/dist/docs/User.html +0 -1315
  92. package/dist/docs/classes.list.html +0 -4431
  93. package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  94. package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
  95. package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  96. package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  97. package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  98. package/dist/docs/img/glyphicons-halflings-white.png +0 -0
  99. package/dist/docs/img/glyphicons-halflings.png +0 -0
  100. package/dist/docs/quicksearch.html +0 -31
  101. package/dist/docs/scripts/docstrap.lib.js +0 -11
  102. package/dist/docs/scripts/fulltext-search-ui.js +0 -89
  103. package/dist/docs/scripts/fulltext-search.js +0 -36
  104. package/dist/docs/scripts/lunr.min.js +0 -6
  105. package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  106. package/dist/docs/scripts/prettify/jquery.min.js +0 -6
  107. package/dist/docs/scripts/prettify/lang-css.js +0 -21
  108. package/dist/docs/scripts/prettify/prettify.js +0 -496
  109. package/dist/docs/scripts/sunlight.js +0 -1157
  110. package/dist/docs/scripts/toc.js +0 -203
  111. package/dist/docs/styles/darkstrap.css +0 -960
  112. package/dist/docs/styles/prettify-tomorrow.css +0 -132
  113. package/dist/docs/styles/site.cerulean.css +0 -7008
  114. package/dist/docs/styles/site.cosmo.css +0 -7061
  115. package/dist/docs/styles/site.cyborg.css +0 -7048
  116. package/dist/docs/styles/site.darkly.css +0 -7171
  117. package/dist/docs/styles/site.darkstrap.css +0 -5638
  118. package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
  119. package/dist/docs/styles/site.flatly.css +0 -7147
  120. package/dist/docs/styles/site.journal.css +0 -6973
  121. package/dist/docs/styles/site.lumen.css +0 -7298
  122. package/dist/docs/styles/site.paper.css +0 -7623
  123. package/dist/docs/styles/site.readable.css +0 -6997
  124. package/dist/docs/styles/site.sandstone.css +0 -7035
  125. package/dist/docs/styles/site.simplex.css +0 -7023
  126. package/dist/docs/styles/site.slate.css +0 -7343
  127. package/dist/docs/styles/site.spacelab.css +0 -7055
  128. package/dist/docs/styles/site.superhero.css +0 -7131
  129. package/dist/docs/styles/site.united.css +0 -6895
  130. package/dist/docs/styles/site.yeti.css +0 -7195
  131. package/dist/docs/styles/sunlight.dark.css +0 -345
  132. package/dist/docs/styles/sunlight.default.css +0 -344
  133. package/dist/sri.json +0 -1
  134. package/lib/aggregateddeliveryreceipt.d.ts +0 -98
  135. package/lib/aggregateddeliveryreceipt.js +0 -112
  136. package/lib/client.d.ts +0 -317
  137. package/lib/client.js +0 -633
  138. package/lib/configuration.d.ts +0 -21
  139. package/lib/configuration.js +0 -41
  140. package/lib/conversation.d.ts +0 -460
  141. package/lib/conversation.js +0 -940
  142. package/lib/data/conversations.d.ts +0 -57
  143. package/lib/data/conversations.js +0 -296
  144. package/lib/data/messages.d.ts +0 -75
  145. package/lib/data/messages.js +0 -208
  146. package/lib/data/participants.d.ts +0 -94
  147. package/lib/data/participants.js +0 -204
  148. package/lib/data/users.d.ts +0 -42
  149. package/lib/data/users.js +0 -113
  150. package/lib/detaileddeliveryreceipt.d.ts +0 -45
  151. package/lib/detaileddeliveryreceipt.js +0 -34
  152. package/lib/index.d.ts +0 -1
  153. package/lib/index.js +0 -3
  154. package/lib/interfaces/limits.d.ts +0 -8
  155. package/lib/interfaces/limits.js +0 -2
  156. package/lib/interfaces/notificationtypes.d.ts +0 -8
  157. package/lib/interfaces/notificationtypes.js +0 -11
  158. package/lib/interfaces/paginator.d.ts +0 -52
  159. package/lib/interfaces/paginator.js +0 -28
  160. package/lib/interfaces/responsecodes.d.ts +0 -8
  161. package/lib/interfaces/responsecodes.js +0 -10
  162. package/lib/interfaces/transport.d.ts +0 -13
  163. package/lib/interfaces/transport.js +0 -2
  164. package/lib/logger.d.ts +0 -18
  165. package/lib/logger.js +0 -35
  166. package/lib/media.d.ts +0 -52
  167. package/lib/media.js +0 -69
  168. package/lib/message.d.ts +0 -136
  169. package/lib/message.js +0 -305
  170. package/lib/participant.d.ts +0 -142
  171. package/lib/participant.js +0 -219
  172. package/lib/pushnotification.d.ts +0 -48
  173. package/lib/pushnotification.js +0 -39
  174. package/lib/restpaginator.d.ts +0 -19
  175. package/lib/restpaginator.js +0 -36
  176. package/lib/services/network.d.ts +0 -22
  177. package/lib/services/network.js +0 -87
  178. package/lib/services/readhorizon.d.ts +0 -28
  179. package/lib/services/readhorizon.js +0 -112
  180. package/lib/services/typingindicator.d.ts +0 -50
  181. package/lib/services/typingindicator.js +0 -102
  182. package/lib/session.d.ts +0 -63
  183. package/lib/session.js +0 -213
  184. package/lib/sessionerror.d.ts +0 -12
  185. package/lib/sessionerror.js +0 -24
  186. package/lib/sri.json +0 -1
  187. package/lib/synclist.d.ts +0 -24
  188. package/lib/synclist.js +0 -28
  189. package/lib/synclistdescriptor.d.ts +0 -27
  190. package/lib/synclistdescriptor.js +0 -19
  191. package/lib/syncpaginator.d.ts +0 -22
  192. package/lib/syncpaginator.js +0 -37
  193. package/lib/user.d.ts +0 -98
  194. package/lib/user.js +0 -219
  195. package/lib/util/deferred.d.ts +0 -12
  196. package/lib/util/deferred.js +0 -22
  197. package/lib/util/index.d.ts +0 -28
  198. package/lib/util/index.js +0 -82
  199. package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
  200. package/tools/rtd-sdk-cdn-pin/README.md +0 -54
  201. package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
  202. package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
  203. package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
  204. package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
  205. package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
  206. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
  207. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
  208. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
  209. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
  210. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
  211. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
  212. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
  213. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
  214. package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
  215. package/tools/sdk-release-tool/.gitrepo +0 -12
  216. package/tools/sdk-release-tool/Makefile +0 -49
  217. package/tools/sdk-release-tool/README.md +0 -275
  218. package/tools/sdk-release-tool/delete +0 -3
  219. package/tools/sdk-release-tool/download +0 -3
  220. package/tools/sdk-release-tool/get-cors +0 -3
  221. package/tools/sdk-release-tool/list +0 -3
  222. package/tools/sdk-release-tool/pin +0 -3
  223. package/tools/sdk-release-tool/pin-latest +0 -3
  224. package/tools/sdk-release-tool/requirements.txt +0 -4
  225. package/tools/sdk-release-tool/sdk-release-tool +0 -3
  226. package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
  227. package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
  228. package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
  229. package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
  230. package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
  231. package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
  232. package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
  233. package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
  234. package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
  235. package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
  236. package/tools/sdk-release-tool/tests/test_versions.py +0 -94
  237. package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
  238. package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
  239. package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
  240. package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
  241. package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
  242. package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
  243. package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
  244. package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
  245. package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
  246. package/tools/sdk-release-tool/twilio-client-android.json +0 -22
  247. package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
  248. package/tools/sdk-release-tool/twilio-client-js.json +0 -17
  249. package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
  250. package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
  251. package/tools/sdk-release-tool/twilio-common-android.json +0 -22
  252. package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
  253. package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
  254. package/tools/sdk-release-tool/twilio-common-js.json +0 -19
  255. package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
  256. package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
  257. package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
  258. package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
  259. package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
  260. package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
  261. package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
  262. package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
  263. package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
  264. package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
  265. package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
  266. package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
  267. package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
  268. package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
  269. package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
  270. package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
  271. package/tools/sdk-release-tool/twilio-video-android.json +0 -22
  272. package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
  273. package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
  274. package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
  275. package/tools/sdk-release-tool/twilio-video-js.json +0 -19
  276. package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
  277. package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
  278. package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
  279. package/tools/sdk-release-tool/unpin +0 -3
  280. package/tools/sdk-release-tool/unpin-latest +0 -3
  281. package/tools/sdk-release-tool/upload +0 -3
  282. package/twilio-chat.js.iml +0 -9
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ResponseCodes {
4
- }
5
- exports.ResponseCodes = ResponseCodes;
6
- ResponseCodes.HTTP_200_OK = 200;
7
- ResponseCodes.HTTP_400_BAD_REQUEST = 400;
8
- ResponseCodes.HTTP_404_NOT_FOUND = 404;
9
- ResponseCodes.ACCESS_FORBIDDEN_FOR_IDENTITY = 54007;
10
- ResponseCodes.LIST_NOT_FOUND = 54150;
@@ -1,13 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- interface Result {
4
- }
5
- interface Transport extends EventEmitter {
6
- readonly isConnected: boolean;
7
- readonly state: string;
8
- get(url: string, headers: any, grant?: string): Promise<Result>;
9
- post(url: string, headers: any, body: any, grant?: string): Promise<Result>;
10
- put(url: string, headers: any, body: any, grant?: string): Promise<Result>;
11
- delete(url: string, headers: any, grant?: string): Promise<Result>;
12
- }
13
- export { Result, Transport };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/lib/logger.d.ts DELETED
@@ -1,18 +0,0 @@
1
- declare class Logger {
2
- private prefix;
3
- private constructor();
4
- static scope(prefix: string): Logger;
5
- setLevel(level: any): void;
6
- static setLevel(level: any): void;
7
- trace(...args: any[]): void;
8
- debug(...args: any[]): void;
9
- info(...args: any[]): void;
10
- warn(...args: any[]): void;
11
- error(...args: any[]): void;
12
- static trace(...args: any[]): void;
13
- static debug(...args: any[]): void;
14
- static info(...args: any[]): void;
15
- static warn(...args: any[]): void;
16
- static error(...args: any[]): void;
17
- }
18
- export { Logger };
package/lib/logger.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loglevelLog = require("loglevel");
4
- function prepareLine(prefix, args) {
5
- return [`${new Date().toISOString()} Conversations ${prefix}:`].concat(Array.from(args));
6
- }
7
- const log = loglevelLog.getLogger('twilio-conversations'); // twilio-conversations is used by Flex SDK. Please DO NOT change
8
- class Logger {
9
- constructor(prefix) {
10
- this.prefix = '';
11
- this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0
12
- ? prefix + ' '
13
- : '';
14
- }
15
- static scope(prefix) {
16
- return new Logger(prefix);
17
- }
18
- setLevel(level) {
19
- log.setLevel(level);
20
- }
21
- static setLevel(level) {
22
- log.setLevel(level);
23
- }
24
- trace(...args) { log.trace.apply(null, prepareLine(this.prefix + 'T', args)); }
25
- debug(...args) { log.debug.apply(null, prepareLine(this.prefix + 'D', args)); }
26
- info(...args) { log.info.apply(null, prepareLine(this.prefix + 'I', args)); }
27
- warn(...args) { log.warn.apply(null, prepareLine(this.prefix + 'W', args)); }
28
- error(...args) { log.error.apply(null, prepareLine(this.prefix + 'E', args)); }
29
- static trace(...args) { log.trace.apply(null, prepareLine('T', args)); }
30
- static debug(...args) { log.debug.apply(null, prepareLine('D', args)); }
31
- static info(...args) { log.info.apply(null, prepareLine('I', args)); }
32
- static warn(...args) { log.warn.apply(null, prepareLine('W', args)); }
33
- static error(...args) { log.error.apply(null, prepareLine('E', args)); }
34
- }
35
- exports.Logger = Logger;
package/lib/media.d.ts DELETED
@@ -1,52 +0,0 @@
1
- import { McsClient, McsMedia, MediaCategory } from 'twilio-mcs-client';
2
- export interface MediaState {
3
- sid: string;
4
- category: MediaCategory;
5
- filename?: string;
6
- contentType: string;
7
- size: number;
8
- }
9
- export interface MediaServices {
10
- mcsClient: McsClient;
11
- }
12
- /**
13
- * @classdesc A Media represents media information of a Message in a Conversation.
14
- * @property {String} sid - The server-assigned unique identifier for Media
15
- * @property {String} category - media category, can be one of the {MediaCategory} values.
16
- * @property {String} [filename] - file name if present, null otherwise
17
- * @property {String} contentType - content type of media
18
- * @property {Number} size - Size of media, bytes
19
- s */
20
- declare class Media {
21
- private state;
22
- private services;
23
- private mcsMedia;
24
- constructor(data: MediaState | McsMedia, services: MediaServices);
25
- get sid(): string;
26
- get filename(): string;
27
- get contentType(): string;
28
- get category(): string;
29
- get size(): number;
30
- /**
31
- * Returns direct content URL for the media.
32
- *
33
- * This URL is impermanent, it will expire in several minutes and cannot be cached.
34
- * If the URL becomes expired, you need to request a new one.
35
- * Each call to this function produces a new temporary URL.
36
- *
37
- * @returns {Promise<String>}
38
- */
39
- getContentTemporaryUrl(): Promise<string>;
40
- /**
41
- * Returns cached direct content URL for the media.
42
- *
43
- * This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
44
- * without causing network traffic.
45
- * If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
46
- *
47
- * @returns {Promise<String>}
48
- */
49
- getCachedTemporaryUrl(): Promise<string>;
50
- private _fetchMcsMedia;
51
- }
52
- export { Media };
package/lib/media.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const twilio_mcs_client_1 = require("twilio-mcs-client");
4
- /**
5
- * @classdesc A Media represents media information of a Message in a Conversation.
6
- * @property {String} sid - The server-assigned unique identifier for Media
7
- * @property {String} category - media category, can be one of the {MediaCategory} values.
8
- * @property {String} [filename] - file name if present, null otherwise
9
- * @property {String} contentType - content type of media
10
- * @property {Number} size - Size of media, bytes
11
- s */
12
- class Media {
13
- constructor(data, services) {
14
- this.mcsMedia = null;
15
- this.services = services;
16
- if (data instanceof twilio_mcs_client_1.McsMedia) {
17
- this.mcsMedia = data;
18
- }
19
- this.state = {
20
- sid: data.sid,
21
- category: data.category,
22
- filename: data.filename,
23
- contentType: data.contentType,
24
- size: data.size
25
- };
26
- }
27
- get sid() { return this.state.sid; }
28
- get filename() { return this.state.filename; }
29
- get contentType() { return this.state.contentType; }
30
- get category() { return this.state.category; }
31
- get size() { return this.state.size; }
32
- /**
33
- * Returns direct content URL for the media.
34
- *
35
- * This URL is impermanent, it will expire in several minutes and cannot be cached.
36
- * If the URL becomes expired, you need to request a new one.
37
- * Each call to this function produces a new temporary URL.
38
- *
39
- * @returns {Promise<String>}
40
- */
41
- async getContentTemporaryUrl() {
42
- await this._fetchMcsMedia();
43
- return this.mcsMedia.getContentUrl();
44
- }
45
- /**
46
- * Returns cached direct content URL for the media.
47
- *
48
- * This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
49
- * without causing network traffic.
50
- * If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
51
- *
52
- * @returns {Promise<String>}
53
- */
54
- async getCachedTemporaryUrl() {
55
- await this._fetchMcsMedia();
56
- return this.mcsMedia.getCachedContentUrl();
57
- }
58
- async _fetchMcsMedia() {
59
- if (!this.mcsMedia) {
60
- if (this.services.mcsClient) {
61
- this.mcsMedia = await this.services.mcsClient.get(this.state.sid);
62
- }
63
- else {
64
- throw new Error('Media Content Service is unavailable');
65
- }
66
- }
67
- }
68
- }
69
- exports.Media = Media;
package/lib/message.d.ts DELETED
@@ -1,136 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { Conversation } from './conversation';
4
- import { Session } from './session';
5
- import { McsClient } from 'twilio-mcs-client';
6
- import { Media } from './media';
7
- import { Participant } from './participant';
8
- import { AggregatedDeliveryReceipt } from './aggregateddeliveryreceipt';
9
- import { Network } from './services/network';
10
- import { DetailedDeliveryReceipt } from './detaileddeliveryreceipt';
11
- declare namespace Message {
12
- type Type = 'text' | 'media';
13
- }
14
- export interface MessageServices {
15
- session: Session;
16
- mcsClient: McsClient;
17
- network: Network;
18
- }
19
- declare namespace Message {
20
- type UpdateReason = 'body' | 'lastUpdatedBy' | 'dateCreated' | 'dateUpdated' | 'attributes' | 'author' | 'deliveryReceipt' | 'subject';
21
- interface UpdatedEventArgs {
22
- message: Message;
23
- updateReasons: Message.UpdateReason[];
24
- }
25
- }
26
- /**
27
- * @classdesc A Message represents a Message in a Conversation.
28
- * @property {String} author - The name of the user that sent Message
29
- * @property {String|null} subject - Message subject. Used only in email conversations
30
- * @property {String} body - The body of the Message. Is null if Message is Media Message
31
- * @property {any} attributes - Message custom attributes
32
- * @property {Conversation} conversation - Conversation Message belongs to
33
- * @property {Date} dateCreated - When Message was created
34
- * @property {Date} dateUpdated - When Message was updated
35
- * @property {Number} index - Index of Message in the Conversation's messages list
36
- * By design of the conversations system the message indices may have arbitrary gaps between them,
37
- * that does not necessarily mean they were deleted or otherwise modified - just that
38
- * messages may have non-contiguous indices even if they are sent immediately one after another.
39
- *
40
- * Trying to use indices for some calculations is going to be unreliable.
41
- *
42
- * To calculate the number of unread messages it is better to use the read horizon API.
43
- * See {@link Conversation#getUnreadMessagesCount} for details.
44
- *
45
- * @property {String} lastUpdatedBy - Identity of the last user that updated Message
46
- * @property {Media} media - Contains Media information (if present)
47
- * @property {String} participantSid - Authoring Participant's server-assigned unique identifier
48
- * @property {String} sid - The server-assigned unique identifier for Message
49
- * @property {'text' | 'media'} type - Type of message: 'text' or 'media'
50
- * @property {AggregatedDeliveryReceipt | null} aggregatedDeliveryReceipt - Aggregated information about
51
- * Message delivery statuses across all {@link Participant}s of a {@link Conversation}.
52
- * @fires Message#updated
53
- */
54
- declare class Message extends EventEmitter {
55
- readonly conversation: Conversation;
56
- private services;
57
- private state;
58
- constructor(conversation: Conversation, services: MessageServices, index: number, data: any);
59
- /**
60
- * The update reason for <code>updated</code> event emitted on Message
61
- * @typedef {('body' | 'lastUpdatedBy' | 'dateCreated' | 'dateUpdated' | 'attributes' | 'author' |
62
- * 'deliveryReceipt' | 'subject')} Message#UpdateReason
63
- */
64
- get sid(): string;
65
- get author(): string;
66
- get subject(): string | null;
67
- get body(): string;
68
- get dateUpdated(): Date;
69
- get index(): number;
70
- get lastUpdatedBy(): string;
71
- get dateCreated(): Date;
72
- get attributes(): Object;
73
- get type(): Message.Type;
74
- /**
75
- * One of the attached media.
76
- * @deprecated Use attachedMedia instead. Note that the latter is now an array.
77
- */
78
- get media(): Media;
79
- /**
80
- * Return all media attachments, except email body/history attachments, without temporary urls.
81
- */
82
- get attachedMedia(): Array<Media>;
83
- get participantSid(): string;
84
- get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null;
85
- /**
86
- * Return a (possibly empty) array of media matching a specific set of categories.
87
- * Allowed categories are 'media', 'body' and 'history'.
88
- * @param categories Array of categories to match.
89
- * @returns Array of media descriptors matching given categories.
90
- */
91
- getMediaByCategory(categories: Array<String>): Array<Media> | null;
92
- getEmailBody(type?: string): Media | null;
93
- getEmailHistory(type?: string): Media | null;
94
- _update(data: any): void;
95
- /**
96
- * Get Participant who is author of the Message
97
- * @returns {Promise<Participant>}
98
- */
99
- getParticipant(): Promise<Participant>;
100
- /**
101
- * Get delivery receipts of the message
102
- * @returns {Promise<DetailedDeliveryReceipt[]>}
103
- */
104
- getDetailedDeliveryReceipts(): Promise<DetailedDeliveryReceipt[]>;
105
- /**
106
- * Remove the Message.
107
- * @returns {Promise<Message>}
108
- */
109
- remove(): Promise<Message>;
110
- /**
111
- * Edit message body.
112
- * @param {String} body - new body of Message.
113
- * @returns {Promise<Message>}
114
- */
115
- updateBody(body: string): Promise<Message>;
116
- /**
117
- * Edit message attributes.
118
- * @param {any} attributes new attributes for Message.
119
- * @returns {Promise<Message>}
120
- */
121
- updateAttributes(attributes: any): Promise<Message>;
122
- /**
123
- * Get content URLs for all media attachments in the given set using single operation.
124
- * @param contentSet Set of media attachments to query for content URL.
125
- */
126
- attachTemporaryUrlsFor(contentSet: Media[]): Promise<Media[]>;
127
- private _getDetailedDeliveryReceiptsPaginator;
128
- }
129
- export { Message };
130
- /**
131
- * Fired when the Message's properties or body has been updated.
132
- * @event Message#updated
133
- * @type {Object}
134
- * @property {Message} message - Updated Message
135
- * @property {Message#UpdateReason[]} updateReasons - Array of Message's updated event reasons
136
- */
package/lib/message.js DELETED
@@ -1,305 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const events_1 = require("events");
13
- const util_1 = require("./util");
14
- const logger_1 = require("./logger");
15
- const media_1 = require("./media");
16
- const aggregateddeliveryreceipt_1 = require("./aggregateddeliveryreceipt");
17
- const twilio_sdk_type_validator_1 = require("twilio-sdk-type-validator");
18
- const restpaginator_1 = require("./restpaginator");
19
- const detaileddeliveryreceipt_1 = require("./detaileddeliveryreceipt");
20
- const log = logger_1.Logger.scope('Message');
21
- /**
22
- * @classdesc A Message represents a Message in a Conversation.
23
- * @property {String} author - The name of the user that sent Message
24
- * @property {String|null} subject - Message subject. Used only in email conversations
25
- * @property {String} body - The body of the Message. Is null if Message is Media Message
26
- * @property {any} attributes - Message custom attributes
27
- * @property {Conversation} conversation - Conversation Message belongs to
28
- * @property {Date} dateCreated - When Message was created
29
- * @property {Date} dateUpdated - When Message was updated
30
- * @property {Number} index - Index of Message in the Conversation's messages list
31
- * By design of the conversations system the message indices may have arbitrary gaps between them,
32
- * that does not necessarily mean they were deleted or otherwise modified - just that
33
- * messages may have non-contiguous indices even if they are sent immediately one after another.
34
- *
35
- * Trying to use indices for some calculations is going to be unreliable.
36
- *
37
- * To calculate the number of unread messages it is better to use the read horizon API.
38
- * See {@link Conversation#getUnreadMessagesCount} for details.
39
- *
40
- * @property {String} lastUpdatedBy - Identity of the last user that updated Message
41
- * @property {Media} media - Contains Media information (if present)
42
- * @property {String} participantSid - Authoring Participant's server-assigned unique identifier
43
- * @property {String} sid - The server-assigned unique identifier for Message
44
- * @property {'text' | 'media'} type - Type of message: 'text' or 'media'
45
- * @property {AggregatedDeliveryReceipt | null} aggregatedDeliveryReceipt - Aggregated information about
46
- * Message delivery statuses across all {@link Participant}s of a {@link Conversation}.
47
- * @fires Message#updated
48
- */
49
- class Message extends events_1.EventEmitter {
50
- constructor(conversation, services, index, data) {
51
- var _a, _b, _c, _d, _e;
52
- super();
53
- this.conversation = conversation;
54
- this.services = services;
55
- this.state = {
56
- sid: data.sid,
57
- index: index,
58
- author: (_a = data.author, (_a !== null && _a !== void 0 ? _a : null)),
59
- subject: (_b = data.subject, (_b !== null && _b !== void 0 ? _b : null)),
60
- body: data.text,
61
- timestamp: data.timestamp ? new Date(data.timestamp) : null,
62
- dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
63
- lastUpdatedBy: (_c = data.lastUpdatedBy, (_c !== null && _c !== void 0 ? _c : null)),
64
- attributes: util_1.parseAttributes(data.attributes, `Got malformed attributes for the message ${data.sid}`, log),
65
- type: (_d = data.type, (_d !== null && _d !== void 0 ? _d : 'text')),
66
- media: (data.type && data.type === 'media' && data.media)
67
- ? new media_1.Media(data.media, this.services) : null,
68
- medias: (data.type && data.type === 'media' && data.medias)
69
- ? data.medias.map((m) => new media_1.Media(m, this.services)) : null,
70
- participantSid: (_e = data.memberSid, (_e !== null && _e !== void 0 ? _e : null)),
71
- aggregatedDeliveryReceipt: data.delivery ? new aggregateddeliveryreceipt_1.AggregatedDeliveryReceipt(data.delivery) : null
72
- };
73
- }
74
- /**
75
- * The update reason for <code>updated</code> event emitted on Message
76
- * @typedef {('body' | 'lastUpdatedBy' | 'dateCreated' | 'dateUpdated' | 'attributes' | 'author' |
77
- * 'deliveryReceipt' | 'subject')} Message#UpdateReason
78
- */
79
- get sid() { return this.state.sid; }
80
- get author() { return this.state.author; }
81
- get subject() { return this.state.subject; }
82
- get body() { return this.state.body; }
83
- get dateUpdated() { return this.state.dateUpdated; }
84
- get index() { return this.state.index; }
85
- get lastUpdatedBy() { return this.state.lastUpdatedBy; }
86
- get dateCreated() { return this.state.timestamp; }
87
- get attributes() { return this.state.attributes; }
88
- get type() { return this.state.type; }
89
- /**
90
- * One of the attached media.
91
- * @deprecated Use attachedMedia instead. Note that the latter is now an array.
92
- */
93
- get media() { return this.state.media; }
94
- /**
95
- * Return all media attachments, except email body/history attachments, without temporary urls.
96
- */
97
- get attachedMedia() { return this.getMediaByCategory(['media']); }
98
- get participantSid() { return this.state.participantSid; }
99
- get aggregatedDeliveryReceipt() { return this.state.aggregatedDeliveryReceipt; }
100
- /**
101
- * Return a (possibly empty) array of media matching a specific set of categories.
102
- * Allowed categories are 'media', 'body' and 'history'.
103
- * @param categories Array of categories to match.
104
- * @returns Array of media descriptors matching given categories.
105
- */
106
- getMediaByCategory(categories) {
107
- var _a;
108
- return (_a = this.state.medias) === null || _a === void 0 ? void 0 : _a.filter((m) => categories.includes(m.category));
109
- }
110
- getEmailBody(type = 'text/plain') {
111
- var _a, _b;
112
- return _b = (_a = this.getMediaByCategory(['body'])) === null || _a === void 0 ? void 0 : _a.filter((m) => m.contentType == type).shift(), (_b !== null && _b !== void 0 ? _b : null);
113
- }
114
- getEmailHistory(type = 'text/plain') {
115
- var _a, _b;
116
- return _b = (_a = this.getMediaByCategory(['history'])) === null || _a === void 0 ? void 0 : _a.filter((m) => m.contentType == type).shift(), (_b !== null && _b !== void 0 ? _b : null);
117
- }
118
- _update(data) {
119
- let updateReasons = [];
120
- if ((data.text || ((typeof data.text) === 'string')) && data.text !== this.state.body) {
121
- this.state.body = data.text;
122
- updateReasons.push('body');
123
- }
124
- if (data.subject && data.subject !== this.state.subject) {
125
- this.state.subject = data.subject;
126
- updateReasons.push('subject');
127
- }
128
- if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {
129
- this.state.lastUpdatedBy = data.lastUpdatedBy;
130
- updateReasons.push('lastUpdatedBy');
131
- }
132
- if (data.author && data.author !== this.state.author) {
133
- this.state.author = data.author;
134
- updateReasons.push('author');
135
- }
136
- if (data.dateUpdated &&
137
- new Date(data.dateUpdated).getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
138
- this.state.dateUpdated = new Date(data.dateUpdated);
139
- updateReasons.push('dateUpdated');
140
- }
141
- if (data.timestamp &&
142
- new Date(data.timestamp).getTime() !== (this.state.timestamp && this.state.timestamp.getTime())) {
143
- this.state.timestamp = new Date(data.timestamp);
144
- updateReasons.push('dateCreated');
145
- }
146
- let updatedAttributes = util_1.parseAttributes(data.attributes, `Got malformed attributes for the message ${this.sid}`, log);
147
- if (!util_1.isDeepEqual(this.state.attributes, updatedAttributes)) {
148
- this.state.attributes = updatedAttributes;
149
- updateReasons.push('attributes');
150
- }
151
- let updatedAggregatedDelivery = data.delivery;
152
- let currentAggregatedDelivery = this.state.aggregatedDeliveryReceipt;
153
- let isUpdatedAggregateDeliveryValid = !!updatedAggregatedDelivery && !!updatedAggregatedDelivery.total &&
154
- !!updatedAggregatedDelivery.delivered && !!updatedAggregatedDelivery.failed && !!updatedAggregatedDelivery.read &&
155
- !!updatedAggregatedDelivery.sent && !!updatedAggregatedDelivery.undelivered;
156
- if (isUpdatedAggregateDeliveryValid) {
157
- if (!currentAggregatedDelivery) {
158
- this.state.aggregatedDeliveryReceipt = new aggregateddeliveryreceipt_1.AggregatedDeliveryReceipt(updatedAggregatedDelivery);
159
- updateReasons.push('deliveryReceipt');
160
- }
161
- else if (!currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)) {
162
- currentAggregatedDelivery._update(updatedAggregatedDelivery);
163
- updateReasons.push('deliveryReceipt');
164
- }
165
- }
166
- if (updateReasons.length > 0) {
167
- this.emit('updated', { message: this, updateReasons: updateReasons });
168
- }
169
- }
170
- /**
171
- * Get Participant who is author of the Message
172
- * @returns {Promise<Participant>}
173
- */
174
- async getParticipant() {
175
- let participant = null;
176
- if (this.state.participantSid) {
177
- participant = await this.conversation.getParticipantBySid(this.participantSid)
178
- .catch(() => {
179
- log.debug('Participant with sid "' + this.participantSid + '" not found for message ' + this.sid);
180
- return null;
181
- });
182
- }
183
- if (!participant && this.state.author) {
184
- participant = await this.conversation.getParticipantByIdentity(this.state.author)
185
- .catch(() => {
186
- log.debug('Participant with identity "' + this.author + '" not found for message ' + this.sid);
187
- return null;
188
- });
189
- }
190
- if (participant) {
191
- return participant;
192
- }
193
- let errorMesage = 'Participant with ';
194
- if (this.state.participantSid) {
195
- errorMesage += 'SID \'' + this.state.participantSid + '\' ';
196
- }
197
- if (this.state.author) {
198
- if (this.state.participantSid) {
199
- errorMesage += 'or ';
200
- }
201
- errorMesage += 'identity \'' + this.state.author + '\' ';
202
- }
203
- if (errorMesage === 'Participant with ') {
204
- errorMesage = 'Participant ';
205
- }
206
- errorMesage += 'was not found';
207
- throw new Error(errorMesage);
208
- }
209
- /**
210
- * Get delivery receipts of the message
211
- * @returns {Promise<DetailedDeliveryReceipt[]>}
212
- */
213
- async getDetailedDeliveryReceipts() {
214
- let paginator = await this._getDetailedDeliveryReceiptsPaginator();
215
- let detailedDeliveryReceipts = [];
216
- while (true) {
217
- detailedDeliveryReceipts = [...detailedDeliveryReceipts, ...paginator.items];
218
- if (!paginator.hasNextPage) {
219
- break;
220
- }
221
- paginator = await paginator.nextPage();
222
- }
223
- return detailedDeliveryReceipts;
224
- }
225
- /**
226
- * Remove the Message.
227
- * @returns {Promise<Message>}
228
- */
229
- async remove() {
230
- await this.services.session.addCommand('deleteMessage', {
231
- channelSid: this.conversation.sid,
232
- messageIdx: this.index.toString()
233
- });
234
- return this;
235
- }
236
- /**
237
- * Edit message body.
238
- * @param {String} body - new body of Message.
239
- * @returns {Promise<Message>}
240
- */
241
- async updateBody(body) {
242
- await this.services.session.addCommand('editMessage', {
243
- channelSid: this.conversation.sid,
244
- messageIdx: this.index.toString(),
245
- text: body
246
- });
247
- return this;
248
- }
249
- /**
250
- * Edit message attributes.
251
- * @param {any} attributes new attributes for Message.
252
- * @returns {Promise<Message>}
253
- */
254
- async updateAttributes(attributes) {
255
- await this.services.session.addCommand('editMessageAttributes', {
256
- channelSid: this.conversation.sid,
257
- messageIdx: this.index,
258
- attributes: JSON.stringify(attributes)
259
- });
260
- return this;
261
- }
262
- /**
263
- * Get content URLs for all media attachments in the given set using single operation.
264
- * @param contentSet Set of media attachments to query for content URL.
265
- */
266
- async attachTemporaryUrlsFor(contentSet) {
267
- // We ignore existing mcsMedia members of each of the media entries.
268
- // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
269
- const sids = contentSet.map((m) => m.sid);
270
- if (this.services.mcsClient) {
271
- return (await this.services.mcsClient.mediaSetGet(sids)).map((item) => { return new media_1.Media(item, this.services); });
272
- }
273
- else {
274
- throw new Error('Media Content Service is unavailable');
275
- }
276
- }
277
- async _getDetailedDeliveryReceiptsPaginator(options) {
278
- var _a, _b;
279
- let links = await this.services.session.getSessionLinks();
280
- let messagesReceiptsUrl = links.messagesReceiptsUrl.replace('%s', this.conversation.sid).replace('%s', this.sid);
281
- let url = new util_1.UriBuilder(messagesReceiptsUrl).arg('PageToken', (_a = options) === null || _a === void 0 ? void 0 : _a.pageToken).arg('PageSize', (_b = options) === null || _b === void 0 ? void 0 : _b.pageSize).build();
282
- let response = await this.services.network.get(url);
283
- return new restpaginator_1.RestPaginator(response.body.delivery_receipts.map(x => new detaileddeliveryreceipt_1.DetailedDeliveryReceipt(x)), (pageToken, pageSize) => this._getDetailedDeliveryReceiptsPaginator({ pageToken, pageSize }), response.body.meta.previous_token, response.body.meta.next_token);
284
- }
285
- }
286
- __decorate([
287
- twilio_sdk_type_validator_1.validateTypesAsync('string'),
288
- __metadata("design:type", Function),
289
- __metadata("design:paramtypes", [String]),
290
- __metadata("design:returntype", Promise)
291
- ], Message.prototype, "updateBody", null);
292
- __decorate([
293
- twilio_sdk_type_validator_1.validateTypesAsync(['string', 'number', 'boolean', 'object', twilio_sdk_type_validator_1.literal(null)]),
294
- __metadata("design:type", Function),
295
- __metadata("design:paramtypes", [Object]),
296
- __metadata("design:returntype", Promise)
297
- ], Message.prototype, "updateAttributes", null);
298
- exports.Message = Message;
299
- /**
300
- * Fired when the Message's properties or body has been updated.
301
- * @event Message#updated
302
- * @type {Object}
303
- * @property {Message} message - Updated Message
304
- * @property {Message#UpdateReason[]} updateReasons - Array of Message's updated event reasons
305
- */