@twilio/conversations 1.3.0-rc7 → 2.0.0-rc.3

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 +201 -0
  2. package/README.md +5 -5
  3. package/dist/browser.js +7866 -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 +3387 -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 +3169 -0
  33. package/dist/docs/modules.html +3418 -0
  34. package/dist/lib.d.ts +1944 -0
  35. package/dist/lib.js +7866 -0
  36. package/dist/lib.js.map +1 -0
  37. package/dist/post-install.js +29 -0
  38. package/dist/react-native.js +4031 -0
  39. package/dist/react-native.js.map +1 -0
  40. package/dist/twilio-conversations.js +40905 -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 -665
  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 -35565
  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 -318
  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,685 +0,0 @@
1
- "use strict";
2
-
3
- var _promise = require("babel-runtime/core-js/promise");
4
-
5
- var _promise2 = _interopRequireDefault(_promise);
6
-
7
- var _stringify = require("babel-runtime/core-js/json/stringify");
8
-
9
- var _stringify2 = _interopRequireDefault(_stringify);
10
-
11
- var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray");
12
-
13
- var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
14
-
15
- var _regenerator = require("babel-runtime/regenerator");
16
-
17
- var _regenerator2 = _interopRequireDefault(_regenerator);
18
-
19
- var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
20
-
21
- var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
22
-
23
- var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
24
-
25
- var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
26
-
27
- var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
28
-
29
- var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
30
-
31
- var _createClass2 = require("babel-runtime/helpers/createClass");
32
-
33
- var _createClass3 = _interopRequireDefault(_createClass2);
34
-
35
- var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
36
-
37
- var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
38
-
39
- var _inherits2 = require("babel-runtime/helpers/inherits");
40
-
41
- var _inherits3 = _interopRequireDefault(_inherits2);
42
-
43
- var _metadata = require("babel-runtime/core-js/reflect/metadata");
44
-
45
- var _metadata2 = _interopRequireDefault(_metadata);
46
-
47
- var _defineProperty = require("babel-runtime/core-js/object/define-property");
48
-
49
- var _defineProperty2 = _interopRequireDefault(_defineProperty);
50
-
51
- var _typeof2 = require("babel-runtime/helpers/typeof");
52
-
53
- var _typeof3 = _interopRequireDefault(_typeof2);
54
-
55
- var _getOwnPropertyDescriptor = require("babel-runtime/core-js/object/get-own-property-descriptor");
56
-
57
- var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
58
-
59
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
60
-
61
- var __decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
62
- var c = arguments.length,
63
- r = c < 3 ? target : desc === null ? desc = (0, _getOwnPropertyDescriptor2.default)(target, key) : desc,
64
- d;
65
- if ((typeof Reflect === "undefined" ? "undefined" : (0, _typeof3.default)(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
66
- if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67
- }return c > 3 && r && (0, _defineProperty2.default)(target, key, r), r;
68
- };
69
- var __metadata = undefined && undefined.__metadata || function (k, v) {
70
- if ((typeof Reflect === "undefined" ? "undefined" : (0, _typeof3.default)(Reflect)) === "object" && typeof _metadata2.default === "function") return (0, _metadata2.default)(k, v);
71
- };
72
- Object.defineProperty(exports, "__esModule", { value: true });
73
- var events_1 = require("events");
74
- var util_1 = require("./util");
75
- var logger_1 = require("./logger");
76
- var media_1 = require("./media");
77
- var aggregateddeliveryreceipt_1 = require("./aggregateddeliveryreceipt");
78
- var twilio_sdk_type_validator_1 = require("twilio-sdk-type-validator");
79
- var restpaginator_1 = require("./restpaginator");
80
- var detaileddeliveryreceipt_1 = require("./detaileddeliveryreceipt");
81
- var log = logger_1.Logger.scope('Message');
82
- /**
83
- * @classdesc A Message represents a Message in a Conversation.
84
- * @property {String} author - The name of the user that sent Message
85
- * @property {String|null} subject - Message subject. Used only in email conversations
86
- * @property {String} body - The body of the Message. Is null if Message is Media Message
87
- * @property {any} attributes - Message custom attributes
88
- * @property {Conversation} conversation - Conversation Message belongs to
89
- * @property {Date} dateCreated - When Message was created
90
- * @property {Date} dateUpdated - When Message was updated
91
- * @property {Number} index - Index of Message in the Conversation's messages list
92
- * By design of the conversations system the message indices may have arbitrary gaps between them,
93
- * that does not necessarily mean they were deleted or otherwise modified - just that
94
- * messages may have non-contiguous indices even if they are sent immediately one after another.
95
- *
96
- * Trying to use indices for some calculations is going to be unreliable.
97
- *
98
- * To calculate the number of unread messages it is better to use the read horizon API.
99
- * See {@link Conversation#getUnreadMessagesCount} for details.
100
- *
101
- * @property {String} lastUpdatedBy - Identity of the last user that updated Message
102
- * @property {Media} media - Contains Media information (if present)
103
- * @property {String} participantSid - Authoring Participant's server-assigned unique identifier
104
- * @property {String} sid - The server-assigned unique identifier for Message
105
- * @property {'text' | 'media'} type - Type of message: 'text' or 'media'
106
- * @property {AggregatedDeliveryReceipt | null} aggregatedDeliveryReceipt - Aggregated information about
107
- * Message delivery statuses across all {@link Participant}s of a {@link Conversation}.
108
- * @fires Message#updated
109
- */
110
-
111
- var Message = function (_events_1$EventEmitte) {
112
- (0, _inherits3.default)(Message, _events_1$EventEmitte);
113
-
114
- function Message(conversation, services, index, data) {
115
- (0, _classCallCheck3.default)(this, Message);
116
-
117
- var _a, _b, _c, _d, _e;
118
-
119
- var _this = (0, _possibleConstructorReturn3.default)(this, (Message.__proto__ || (0, _getPrototypeOf2.default)(Message)).call(this));
120
-
121
- _this.conversation = conversation;
122
- _this.services = services;
123
- _this.state = {
124
- sid: data.sid,
125
- index: index,
126
- author: (_a = data.author, _a !== null && _a !== void 0 ? _a : null),
127
- subject: (_b = data.subject, _b !== null && _b !== void 0 ? _b : null),
128
- body: data.text,
129
- timestamp: data.timestamp ? new Date(data.timestamp) : null,
130
- dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
131
- lastUpdatedBy: (_c = data.lastUpdatedBy, _c !== null && _c !== void 0 ? _c : null),
132
- attributes: util_1.parseAttributes(data.attributes, "Got malformed attributes for the message " + data.sid, log),
133
- type: (_d = data.type, _d !== null && _d !== void 0 ? _d : 'text'),
134
- media: data.type && data.type === 'media' && data.media ? new media_1.Media(data.media, _this.services) : null,
135
- medias: data.type && data.type === 'media' && data.medias ? data.medias.map(function (m) {
136
- return new media_1.Media(m, _this.services);
137
- }) : null,
138
- participantSid: (_e = data.memberSid, _e !== null && _e !== void 0 ? _e : null),
139
- aggregatedDeliveryReceipt: data.delivery ? new aggregateddeliveryreceipt_1.AggregatedDeliveryReceipt(data.delivery) : null
140
- };
141
- return _this;
142
- }
143
- /**
144
- * The update reason for <code>updated</code> event emitted on Message
145
- * @typedef {('body' | 'lastUpdatedBy' | 'dateCreated' | 'dateUpdated' | 'attributes' | 'author' |
146
- * 'deliveryReceipt' | 'subject')} Message#UpdateReason
147
- */
148
-
149
-
150
- (0, _createClass3.default)(Message, [{
151
- key: "getMediaByCategory",
152
-
153
- /**
154
- * Return a (possibly empty) array of media matching a specific set of categories.
155
- * Allowed categories are 'media', 'body' and 'history'.
156
- * @param categories Array of categories to match.
157
- * @returns Array of media descriptors matching given categories.
158
- */
159
- value: function getMediaByCategory(categories) {
160
- var _a;
161
- return (_a = this.state.medias) === null || _a === void 0 ? void 0 : _a.filter(function (m) {
162
- return categories.includes(m.category);
163
- });
164
- }
165
- }, {
166
- key: "getEmailBody",
167
- value: function getEmailBody() {
168
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text/plain';
169
-
170
- var _a, _b;
171
- return _b = (_a = this.getMediaByCategory(['body'])) === null || _a === void 0 ? void 0 : _a.filter(function (m) {
172
- return m.contentType == type;
173
- }).shift(), _b !== null && _b !== void 0 ? _b : null;
174
- }
175
- }, {
176
- key: "getEmailHistory",
177
- value: function getEmailHistory() {
178
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text/plain';
179
-
180
- var _a, _b;
181
- return _b = (_a = this.getMediaByCategory(['history'])) === null || _a === void 0 ? void 0 : _a.filter(function (m) {
182
- return m.contentType == type;
183
- }).shift(), _b !== null && _b !== void 0 ? _b : null;
184
- }
185
- }, {
186
- key: "_update",
187
- value: function _update(data) {
188
- var updateReasons = [];
189
- if ((data.text || typeof data.text === 'string') && data.text !== this.state.body) {
190
- this.state.body = data.text;
191
- updateReasons.push('body');
192
- }
193
- if (data.subject && data.subject !== this.state.subject) {
194
- this.state.subject = data.subject;
195
- updateReasons.push('subject');
196
- }
197
- if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {
198
- this.state.lastUpdatedBy = data.lastUpdatedBy;
199
- updateReasons.push('lastUpdatedBy');
200
- }
201
- if (data.author && data.author !== this.state.author) {
202
- this.state.author = data.author;
203
- updateReasons.push('author');
204
- }
205
- if (data.dateUpdated && new Date(data.dateUpdated).getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
206
- this.state.dateUpdated = new Date(data.dateUpdated);
207
- updateReasons.push('dateUpdated');
208
- }
209
- if (data.timestamp && new Date(data.timestamp).getTime() !== (this.state.timestamp && this.state.timestamp.getTime())) {
210
- this.state.timestamp = new Date(data.timestamp);
211
- updateReasons.push('dateCreated');
212
- }
213
- var updatedAttributes = util_1.parseAttributes(data.attributes, "Got malformed attributes for the message " + this.sid, log);
214
- if (!util_1.isDeepEqual(this.state.attributes, updatedAttributes)) {
215
- this.state.attributes = updatedAttributes;
216
- updateReasons.push('attributes');
217
- }
218
- var updatedAggregatedDelivery = data.delivery;
219
- var currentAggregatedDelivery = this.state.aggregatedDeliveryReceipt;
220
- var isUpdatedAggregateDeliveryValid = !!updatedAggregatedDelivery && !!updatedAggregatedDelivery.total && !!updatedAggregatedDelivery.delivered && !!updatedAggregatedDelivery.failed && !!updatedAggregatedDelivery.read && !!updatedAggregatedDelivery.sent && !!updatedAggregatedDelivery.undelivered;
221
- if (isUpdatedAggregateDeliveryValid) {
222
- if (!currentAggregatedDelivery) {
223
- this.state.aggregatedDeliveryReceipt = new aggregateddeliveryreceipt_1.AggregatedDeliveryReceipt(updatedAggregatedDelivery);
224
- updateReasons.push('deliveryReceipt');
225
- } else if (!currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)) {
226
- currentAggregatedDelivery._update(updatedAggregatedDelivery);
227
- updateReasons.push('deliveryReceipt');
228
- }
229
- }
230
- if (updateReasons.length > 0) {
231
- this.emit('updated', { message: this, updateReasons: updateReasons });
232
- }
233
- }
234
- /**
235
- * Get Participant who is author of the Message
236
- * @returns {Promise<Participant>}
237
- */
238
-
239
- }, {
240
- key: "getParticipant",
241
- value: function () {
242
- var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
243
- var _this2 = this;
244
-
245
- var participant, errorMesage;
246
- return _regenerator2.default.wrap(function _callee$(_context) {
247
- while (1) {
248
- switch (_context.prev = _context.next) {
249
- case 0:
250
- participant = null;
251
-
252
- if (!this.state.participantSid) {
253
- _context.next = 5;
254
- break;
255
- }
256
-
257
- _context.next = 4;
258
- return this.conversation.getParticipantBySid(this.participantSid).catch(function () {
259
- log.debug('Participant with sid "' + _this2.participantSid + '" not found for message ' + _this2.sid);
260
- return null;
261
- });
262
-
263
- case 4:
264
- participant = _context.sent;
265
-
266
- case 5:
267
- if (!(!participant && this.state.author)) {
268
- _context.next = 9;
269
- break;
270
- }
271
-
272
- _context.next = 8;
273
- return this.conversation.getParticipantByIdentity(this.state.author).catch(function () {
274
- log.debug('Participant with identity "' + _this2.author + '" not found for message ' + _this2.sid);
275
- return null;
276
- });
277
-
278
- case 8:
279
- participant = _context.sent;
280
-
281
- case 9:
282
- if (!participant) {
283
- _context.next = 11;
284
- break;
285
- }
286
-
287
- return _context.abrupt("return", participant);
288
-
289
- case 11:
290
- errorMesage = 'Participant with ';
291
-
292
- if (this.state.participantSid) {
293
- errorMesage += 'SID \'' + this.state.participantSid + '\' ';
294
- }
295
- if (this.state.author) {
296
- if (this.state.participantSid) {
297
- errorMesage += 'or ';
298
- }
299
- errorMesage += 'identity \'' + this.state.author + '\' ';
300
- }
301
- if (errorMesage === 'Participant with ') {
302
- errorMesage = 'Participant ';
303
- }
304
- errorMesage += 'was not found';
305
- throw new Error(errorMesage);
306
-
307
- case 17:
308
- case "end":
309
- return _context.stop();
310
- }
311
- }
312
- }, _callee, this);
313
- }));
314
-
315
- function getParticipant() {
316
- return _ref.apply(this, arguments);
317
- }
318
-
319
- return getParticipant;
320
- }()
321
- /**
322
- * Get delivery receipts of the message
323
- * @returns {Promise<DetailedDeliveryReceipt[]>}
324
- */
325
-
326
- }, {
327
- key: "getDetailedDeliveryReceipts",
328
- value: function () {
329
- var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
330
- var paginator, detailedDeliveryReceipts;
331
- return _regenerator2.default.wrap(function _callee2$(_context2) {
332
- while (1) {
333
- switch (_context2.prev = _context2.next) {
334
- case 0:
335
- _context2.next = 2;
336
- return this._getDetailedDeliveryReceiptsPaginator();
337
-
338
- case 2:
339
- paginator = _context2.sent;
340
- detailedDeliveryReceipts = [];
341
-
342
- case 4:
343
- if (!true) {
344
- _context2.next = 13;
345
- break;
346
- }
347
-
348
- detailedDeliveryReceipts = [].concat((0, _toConsumableArray3.default)(detailedDeliveryReceipts), (0, _toConsumableArray3.default)(paginator.items));
349
-
350
- if (paginator.hasNextPage) {
351
- _context2.next = 8;
352
- break;
353
- }
354
-
355
- return _context2.abrupt("break", 13);
356
-
357
- case 8:
358
- _context2.next = 10;
359
- return paginator.nextPage();
360
-
361
- case 10:
362
- paginator = _context2.sent;
363
- _context2.next = 4;
364
- break;
365
-
366
- case 13:
367
- return _context2.abrupt("return", detailedDeliveryReceipts);
368
-
369
- case 14:
370
- case "end":
371
- return _context2.stop();
372
- }
373
- }
374
- }, _callee2, this);
375
- }));
376
-
377
- function getDetailedDeliveryReceipts() {
378
- return _ref2.apply(this, arguments);
379
- }
380
-
381
- return getDetailedDeliveryReceipts;
382
- }()
383
- /**
384
- * Remove the Message.
385
- * @returns {Promise<Message>}
386
- */
387
-
388
- }, {
389
- key: "remove",
390
- value: function () {
391
- var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
392
- return _regenerator2.default.wrap(function _callee3$(_context3) {
393
- while (1) {
394
- switch (_context3.prev = _context3.next) {
395
- case 0:
396
- _context3.next = 2;
397
- return this.services.session.addCommand('deleteMessage', {
398
- channelSid: this.conversation.sid,
399
- messageIdx: this.index.toString()
400
- });
401
-
402
- case 2:
403
- return _context3.abrupt("return", this);
404
-
405
- case 3:
406
- case "end":
407
- return _context3.stop();
408
- }
409
- }
410
- }, _callee3, this);
411
- }));
412
-
413
- function remove() {
414
- return _ref3.apply(this, arguments);
415
- }
416
-
417
- return remove;
418
- }()
419
- /**
420
- * Edit message body.
421
- * @param {String} body - new body of Message.
422
- * @returns {Promise<Message>}
423
- */
424
-
425
- }, {
426
- key: "updateBody",
427
- value: function () {
428
- var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(body) {
429
- return _regenerator2.default.wrap(function _callee4$(_context4) {
430
- while (1) {
431
- switch (_context4.prev = _context4.next) {
432
- case 0:
433
- _context4.next = 2;
434
- return this.services.session.addCommand('editMessage', {
435
- channelSid: this.conversation.sid,
436
- messageIdx: this.index.toString(),
437
- text: body
438
- });
439
-
440
- case 2:
441
- return _context4.abrupt("return", this);
442
-
443
- case 3:
444
- case "end":
445
- return _context4.stop();
446
- }
447
- }
448
- }, _callee4, this);
449
- }));
450
-
451
- function updateBody(_x3) {
452
- return _ref4.apply(this, arguments);
453
- }
454
-
455
- return updateBody;
456
- }()
457
- /**
458
- * Edit message attributes.
459
- * @param {any} attributes new attributes for Message.
460
- * @returns {Promise<Message>}
461
- */
462
-
463
- }, {
464
- key: "updateAttributes",
465
- value: function () {
466
- var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(attributes) {
467
- return _regenerator2.default.wrap(function _callee5$(_context5) {
468
- while (1) {
469
- switch (_context5.prev = _context5.next) {
470
- case 0:
471
- _context5.next = 2;
472
- return this.services.session.addCommand('editMessageAttributes', {
473
- channelSid: this.conversation.sid,
474
- messageIdx: this.index,
475
- attributes: (0, _stringify2.default)(attributes)
476
- });
477
-
478
- case 2:
479
- return _context5.abrupt("return", this);
480
-
481
- case 3:
482
- case "end":
483
- return _context5.stop();
484
- }
485
- }
486
- }, _callee5, this);
487
- }));
488
-
489
- function updateAttributes(_x4) {
490
- return _ref5.apply(this, arguments);
491
- }
492
-
493
- return updateAttributes;
494
- }()
495
- /**
496
- * Get content URLs for all media attachments in the given set using single operation.
497
- * @param contentSet Set of media attachments to query for content URL.
498
- */
499
-
500
- }, {
501
- key: "attachTemporaryUrlsFor",
502
- value: function () {
503
- var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(contentSet) {
504
- var _this3 = this;
505
-
506
- var sids;
507
- return _regenerator2.default.wrap(function _callee6$(_context6) {
508
- while (1) {
509
- switch (_context6.prev = _context6.next) {
510
- case 0:
511
- // We ignore existing mcsMedia members of each of the media entries.
512
- // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
513
- sids = contentSet.map(function (m) {
514
- return m.sid;
515
- });
516
-
517
- if (!this.services.mcsClient) {
518
- _context6.next = 8;
519
- break;
520
- }
521
-
522
- _context6.next = 4;
523
- return this.services.mcsClient.mediaSetGet(sids);
524
-
525
- case 4:
526
- _context6.t0 = function (item) {
527
- return new media_1.Media(item, _this3.services);
528
- };
529
-
530
- return _context6.abrupt("return", _context6.sent.map(_context6.t0));
531
-
532
- case 8:
533
- throw new Error('Media Content Service is unavailable');
534
-
535
- case 9:
536
- case "end":
537
- return _context6.stop();
538
- }
539
- }
540
- }, _callee6, this);
541
- }));
542
-
543
- function attachTemporaryUrlsFor(_x5) {
544
- return _ref6.apply(this, arguments);
545
- }
546
-
547
- return attachTemporaryUrlsFor;
548
- }()
549
- }, {
550
- key: "_getDetailedDeliveryReceiptsPaginator",
551
- value: function () {
552
- var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(options) {
553
- var _this4 = this;
554
-
555
- var _a, _b, links, messagesReceiptsUrl, url, response;
556
-
557
- return _regenerator2.default.wrap(function _callee7$(_context7) {
558
- while (1) {
559
- switch (_context7.prev = _context7.next) {
560
- case 0:
561
- _context7.next = 2;
562
- return this.services.session.getSessionLinks();
563
-
564
- case 2:
565
- links = _context7.sent;
566
- messagesReceiptsUrl = links.messagesReceiptsUrl.replace('%s', this.conversation.sid).replace('%s', this.sid);
567
- 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();
568
- _context7.next = 7;
569
- return this.services.network.get(url);
570
-
571
- case 7:
572
- response = _context7.sent;
573
- return _context7.abrupt("return", new restpaginator_1.RestPaginator(response.body.delivery_receipts.map(function (x) {
574
- return new detaileddeliveryreceipt_1.DetailedDeliveryReceipt(x);
575
- }), function (pageToken, pageSize) {
576
- return _this4._getDetailedDeliveryReceiptsPaginator({ pageToken: pageToken, pageSize: pageSize });
577
- }, response.body.meta.previous_token, response.body.meta.next_token));
578
-
579
- case 9:
580
- case "end":
581
- return _context7.stop();
582
- }
583
- }
584
- }, _callee7, this);
585
- }));
586
-
587
- function _getDetailedDeliveryReceiptsPaginator(_x6) {
588
- return _ref7.apply(this, arguments);
589
- }
590
-
591
- return _getDetailedDeliveryReceiptsPaginator;
592
- }()
593
- }, {
594
- key: "sid",
595
- get: function get() {
596
- return this.state.sid;
597
- }
598
- }, {
599
- key: "author",
600
- get: function get() {
601
- return this.state.author;
602
- }
603
- }, {
604
- key: "subject",
605
- get: function get() {
606
- return this.state.subject;
607
- }
608
- }, {
609
- key: "body",
610
- get: function get() {
611
- return this.state.body;
612
- }
613
- }, {
614
- key: "dateUpdated",
615
- get: function get() {
616
- return this.state.dateUpdated;
617
- }
618
- }, {
619
- key: "index",
620
- get: function get() {
621
- return this.state.index;
622
- }
623
- }, {
624
- key: "lastUpdatedBy",
625
- get: function get() {
626
- return this.state.lastUpdatedBy;
627
- }
628
- }, {
629
- key: "dateCreated",
630
- get: function get() {
631
- return this.state.timestamp;
632
- }
633
- }, {
634
- key: "attributes",
635
- get: function get() {
636
- return this.state.attributes;
637
- }
638
- }, {
639
- key: "type",
640
- get: function get() {
641
- return this.state.type;
642
- }
643
- /**
644
- * One of the attached media.
645
- * @deprecated Use attachedMedia instead. Note that the latter is now an array.
646
- */
647
-
648
- }, {
649
- key: "media",
650
- get: function get() {
651
- return this.state.media;
652
- }
653
- /**
654
- * Return all media attachments, except email body/history attachments, without temporary urls.
655
- */
656
-
657
- }, {
658
- key: "attachedMedia",
659
- get: function get() {
660
- return this.getMediaByCategory(['media']);
661
- }
662
- }, {
663
- key: "participantSid",
664
- get: function get() {
665
- return this.state.participantSid;
666
- }
667
- }, {
668
- key: "aggregatedDeliveryReceipt",
669
- get: function get() {
670
- return this.state.aggregatedDeliveryReceipt;
671
- }
672
- }]);
673
- return Message;
674
- }(events_1.EventEmitter);
675
-
676
- __decorate([twilio_sdk_type_validator_1.validateTypesAsync('string'), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", _promise2.default)], Message.prototype, "updateBody", null);
677
- __decorate([twilio_sdk_type_validator_1.validateTypesAsync(['string', 'number', 'boolean', 'object', twilio_sdk_type_validator_1.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", _promise2.default)], Message.prototype, "updateAttributes", null);
678
- exports.Message = Message;
679
- /**
680
- * Fired when the Message's properties or body has been updated.
681
- * @event Message#updated
682
- * @type {Object}
683
- * @property {Message} message - Updated Message
684
- * @property {Message#UpdateReason[]} updateReasons - Array of Message's updated event reasons
685
- */