@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,223 +0,0 @@
1
- "use strict";
2
-
3
- var _regenerator = require("babel-runtime/regenerator");
4
-
5
- var _regenerator2 = _interopRequireDefault(_regenerator);
6
-
7
- var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
8
-
9
- var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
10
-
11
- var _promise = require("babel-runtime/core-js/promise");
12
-
13
- var _promise2 = _interopRequireDefault(_promise);
14
-
15
- var _getIterator2 = require("babel-runtime/core-js/get-iterator");
16
-
17
- var _getIterator3 = _interopRequireDefault(_getIterator2);
18
-
19
- var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray");
20
-
21
- var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
22
-
23
- var _assign = require("babel-runtime/core-js/object/assign");
24
-
25
- var _assign2 = _interopRequireDefault(_assign);
26
-
27
- var _map = require("babel-runtime/core-js/map");
28
-
29
- var _map2 = _interopRequireDefault(_map);
30
-
31
- var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
32
-
33
- var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
34
-
35
- var _createClass2 = require("babel-runtime/helpers/createClass");
36
-
37
- var _createClass3 = _interopRequireDefault(_createClass2);
38
-
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
-
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var operation_retrier_1 = require("operation-retrier");
43
-
44
- var Network = function () {
45
- function Network(config, services) {
46
- var _this = this;
47
-
48
- (0, _classCallCheck3.default)(this, Network);
49
-
50
- this.config = config;
51
- this.services = services;
52
- this.cache = new _map2.default();
53
- this.cacheLifetime = 0;
54
- this.services.session.getHttpCacheInterval().then(function (seconds) {
55
- _this.cacheLifetime = seconds * 1000;
56
- _this.cleanupCache();
57
- });
58
- }
59
-
60
- (0, _createClass3.default)(Network, [{
61
- key: "backoffConfig",
62
- value: function backoffConfig() {
63
- return (0, _assign2.default)(this.config.backoffConfigDefault, this.config.backoffConfigOverride);
64
- }
65
- }, {
66
- key: "retryWhenThrottled",
67
- value: function retryWhenThrottled() {
68
- if (typeof this.config.retryWhenThrottledOverride !== 'undefined') {
69
- return this.config.retryWhenThrottledOverride;
70
- }
71
- if (typeof this.config.retryWhenThrottledDefault !== 'undefined') {
72
- return this.config.retryWhenThrottledDefault;
73
- }
74
- return false;
75
- }
76
- }, {
77
- key: "isExpired",
78
- value: function isExpired(timestamp) {
79
- return !this.cacheLifetime || Date.now() - timestamp > this.cacheLifetime;
80
- }
81
- }, {
82
- key: "cleanupCache",
83
- value: function cleanupCache() {
84
- var _iteratorNormalCompletion = true;
85
- var _didIteratorError = false;
86
- var _iteratorError = undefined;
87
-
88
- try {
89
- for (var _iterator = (0, _getIterator3.default)(this.cache), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
90
- var _ref = _step.value;
91
-
92
- var _ref2 = (0, _slicedToArray3.default)(_ref, 2);
93
-
94
- var k = _ref2[0];
95
- var v = _ref2[1];
96
-
97
- if (this.isExpired(v.timestamp)) {
98
- this.cache.delete(k);
99
- }
100
- }
101
- } catch (err) {
102
- _didIteratorError = true;
103
- _iteratorError = err;
104
- } finally {
105
- try {
106
- if (!_iteratorNormalCompletion && _iterator.return) {
107
- _iterator.return();
108
- }
109
- } finally {
110
- if (_didIteratorError) {
111
- throw _iteratorError;
112
- }
113
- }
114
- }
115
-
116
- if (this.cache.size === 0) {
117
- clearInterval(this.timer);
118
- }
119
- }
120
- }, {
121
- key: "pokeTimer",
122
- value: function pokeTimer() {
123
- var _this2 = this;
124
-
125
- this.timer = this.timer || setInterval(function () {
126
- return _this2.cleanupCache();
127
- }, this.cacheLifetime * 2);
128
- }
129
- }, {
130
- key: "executeWithRetry",
131
- value: function executeWithRetry(request) {
132
- var _this3 = this;
133
-
134
- var retryWhenThrottled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
135
-
136
- return new _promise2.default(function (resolve, reject) {
137
- var codesToRetryOn = [502, 503, 504];
138
- if (retryWhenThrottled) {
139
- codesToRetryOn.push(429);
140
- }
141
- var retrier = new operation_retrier_1.Retrier(_this3.backoffConfig());
142
- retrier.on('attempt', function () {
143
- request().then(function (result) {
144
- return retrier.succeeded(result);
145
- }).catch(function (err) {
146
- if (codesToRetryOn.indexOf(err.status) > -1) {
147
- retrier.failed(err);
148
- } else if (err.message === 'Twilsock disconnected') {
149
- // Ugly hack. We must make a proper exceptions for twilsock
150
- retrier.failed(err);
151
- } else {
152
- // Fatal error
153
- retrier.removeAllListeners();
154
- retrier.cancel();
155
- reject(err);
156
- }
157
- });
158
- });
159
- retrier.on('succeeded', function (result) {
160
- resolve(result);
161
- });
162
- retrier.on('cancelled', function (err) {
163
- return reject(err);
164
- });
165
- retrier.on('failed', function (err) {
166
- return reject(err);
167
- });
168
- retrier.start();
169
- });
170
- }
171
- }, {
172
- key: "get",
173
- value: function () {
174
- var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(url) {
175
- var _this4 = this;
176
-
177
- var cacheEntry, headers, response;
178
- return _regenerator2.default.wrap(function _callee$(_context) {
179
- while (1) {
180
- switch (_context.prev = _context.next) {
181
- case 0:
182
- cacheEntry = this.cache.get(url);
183
-
184
- if (!(cacheEntry && !this.isExpired(cacheEntry.timestamp))) {
185
- _context.next = 3;
186
- break;
187
- }
188
-
189
- return _context.abrupt("return", cacheEntry.response);
190
-
191
- case 3:
192
- headers = {};
193
- _context.next = 6;
194
- return this.executeWithRetry(function () {
195
- return _this4.services.transport.get(url, headers, _this4.config.productId);
196
- }, this.retryWhenThrottled());
197
-
198
- case 6:
199
- response = _context.sent;
200
-
201
- this.cache.set(url, { response: response, timestamp: Date.now() });
202
- this.pokeTimer();
203
- return _context.abrupt("return", response);
204
-
205
- case 10:
206
- case "end":
207
- return _context.stop();
208
- }
209
- }
210
- }, _callee, this);
211
- }));
212
-
213
- function get(_x2) {
214
- return _ref3.apply(this, arguments);
215
- }
216
-
217
- return get;
218
- }()
219
- }]);
220
- return Network;
221
- }();
222
-
223
- exports.Network = Network;
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- var _promise = require("babel-runtime/core-js/promise");
4
-
5
- var _promise2 = _interopRequireDefault(_promise);
6
-
7
- var _map = require("babel-runtime/core-js/map");
8
-
9
- var _map2 = _interopRequireDefault(_map);
10
-
11
- var _createClass2 = require("babel-runtime/helpers/createClass");
12
-
13
- var _createClass3 = _interopRequireDefault(_createClass2);
14
-
15
- var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
16
-
17
- var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- var sessionerror_1 = require("../sessionerror");
23
-
24
- var ConsumptionReportRequest = function ConsumptionReportRequest() {
25
- (0, _classCallCheck3.default)(this, ConsumptionReportRequest);
26
- };
27
-
28
- var ConsumptionReportEntry = function ConsumptionReportEntry() {
29
- (0, _classCallCheck3.default)(this, ConsumptionReportEntry);
30
- };
31
-
32
- var ReadHorizonPromise = function ReadHorizonPromise() {
33
- (0, _classCallCheck3.default)(this, ReadHorizonPromise);
34
- };
35
- /**
36
- * @classdesc Provides read horizon management functionality
37
- */
38
-
39
-
40
- var ReadHorizon = function () {
41
- function ReadHorizon(services) {
42
- (0, _classCallCheck3.default)(this, ReadHorizon);
43
-
44
- this.services = services;
45
- this.readHorizonRequests = new _map2.default();
46
- this.readHorizonUpdateTimer = null;
47
- }
48
-
49
- (0, _createClass3.default)(ReadHorizon, [{
50
- key: "getReportInterval",
51
- value: function getReportInterval() {
52
- return this.services.session.getConsumptionReportInterval().then(function (seconds) {
53
- return seconds * 1000;
54
- });
55
- }
56
- }, {
57
- key: "delayedSendReadHorizon",
58
- value: function delayedSendReadHorizon(delay) {
59
- var _this = this;
60
-
61
- if (this.readHorizonUpdateTimer !== null) {
62
- return;
63
- }
64
- this.sendConsumptionReport(true);
65
- this.readHorizonUpdateTimer = setTimeout(function () {
66
- _this.sendConsumptionReport(false);
67
- }, delay);
68
- }
69
- }, {
70
- key: "sendConsumptionReport",
71
- value: function sendConsumptionReport(keepTimer) {
72
- var _this2 = this;
73
-
74
- var reports = [];
75
- var promises = new _map2.default();
76
- this.readHorizonRequests.forEach(function (request, conversationSid) {
77
- reports.push(request.entry);
78
- promises.set(conversationSid, request.promises);
79
- });
80
- if (reports.length > 0) {
81
- this.services.session.addCommand('consumptionReportV2', { report: reports }).then(function (response) {
82
- return _this2.processConsumptionReportResponse(response, promises);
83
- }).catch(function (err) {
84
- return _this2.processConsumptionReportError(err, promises);
85
- });
86
- }
87
- if (!keepTimer) {
88
- this.readHorizonUpdateTimer = null;
89
- }
90
- this.readHorizonRequests.clear();
91
- }
92
- }, {
93
- key: "processConsumptionReportResponse",
94
- value: function processConsumptionReportResponse(response, promises) {
95
- if (response && response.report && Array.isArray(response.report) && response.report.length > 0) {
96
- response.report.forEach(function (entry) {
97
- var responseEntry = entry;
98
- if (promises.has(responseEntry.channelSid)) {
99
- var unreadMessagesCount = null;
100
- if (typeof responseEntry.unreadMessagesCount !== 'undefined' && responseEntry.unreadMessagesCount != null) {
101
- unreadMessagesCount = responseEntry.unreadMessagesCount;
102
- }
103
- promises.get(responseEntry.channelSid).forEach(function (promise) {
104
- return promise.resolve(unreadMessagesCount);
105
- });
106
- promises.delete(responseEntry.channelSid);
107
- }
108
- });
109
- }
110
- this.processConsumptionReportError(new sessionerror_1.SessionError('Error while setting LastReadMessageIndex', null), promises);
111
- }
112
- }, {
113
- key: "processConsumptionReportError",
114
- value: function processConsumptionReportError(err, promises) {
115
- promises.forEach(function (conversationPromises) {
116
- return conversationPromises.forEach(function (promise) {
117
- return promise.reject(err);
118
- });
119
- });
120
- }
121
- /**
122
- * Updates read horizon value without any checks
123
- */
124
-
125
- }, {
126
- key: "updateLastReadMessageIndexForConversation",
127
- value: function updateLastReadMessageIndexForConversation(conversationSid, messageIdx) {
128
- var _this3 = this;
129
-
130
- return new _promise2.default(function (resolve, reject) {
131
- _this3.addPendingConsumptionHorizonRequest(conversationSid, { channelSid: conversationSid, messageIdx: messageIdx }, { resolve: resolve, reject: reject });
132
- _this3.getReportInterval().then(function (delay) {
133
- return _this3.delayedSendReadHorizon(delay);
134
- });
135
- });
136
- }
137
- /**
138
- * Move read horizon forward
139
- */
140
-
141
- }, {
142
- key: "advanceLastReadMessageIndexForConversation",
143
- value: function advanceLastReadMessageIndexForConversation(conversationSid, messageIdx, currentConversationLastReadIndex) {
144
- var _this4 = this;
145
-
146
- var currentHorizon = this.readHorizonRequests.get(conversationSid);
147
- return new _promise2.default(function (resolve, reject) {
148
- if (currentHorizon && currentHorizon.entry) {
149
- if (currentHorizon.entry.messageIdx >= messageIdx) {
150
- _this4.addPendingConsumptionHorizonRequest(conversationSid, currentHorizon.entry, { resolve: resolve, reject: reject });
151
- } else {
152
- _this4.addPendingConsumptionHorizonRequest(conversationSid, { channelSid: conversationSid, messageIdx: messageIdx }, { resolve: resolve, reject: reject });
153
- }
154
- } else {
155
- if (currentConversationLastReadIndex !== null && messageIdx < currentConversationLastReadIndex) {
156
- _this4.addPendingConsumptionHorizonRequest(conversationSid, { channelSid: conversationSid, messageIdx: currentConversationLastReadIndex }, { resolve: resolve, reject: reject });
157
- } else {
158
- _this4.addPendingConsumptionHorizonRequest(conversationSid, { channelSid: conversationSid, messageIdx: messageIdx }, { resolve: resolve, reject: reject });
159
- }
160
- }
161
- _this4.getReportInterval().then(function (delay) {
162
- return _this4.delayedSendReadHorizon(delay);
163
- });
164
- });
165
- }
166
- }, {
167
- key: "addPendingConsumptionHorizonRequest",
168
- value: function addPendingConsumptionHorizonRequest(conversationSid, entry, promise) {
169
- if (this.readHorizonRequests.has(conversationSid)) {
170
- var request = this.readHorizonRequests.get(conversationSid);
171
- request.entry = entry;
172
- request.promises.push(promise);
173
- } else {
174
- this.readHorizonRequests.set(conversationSid, { entry: entry, promises: [promise] });
175
- }
176
- }
177
- }]);
178
- return ReadHorizon;
179
- }();
180
-
181
- exports.ReadHorizon = ReadHorizon;
@@ -1,142 +0,0 @@
1
- "use strict";
2
-
3
- var _promise = require("babel-runtime/core-js/promise");
4
-
5
- var _promise2 = _interopRequireDefault(_promise);
6
-
7
- var _map = require("babel-runtime/core-js/map");
8
-
9
- var _map2 = _interopRequireDefault(_map);
10
-
11
- var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
12
-
13
- var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
14
-
15
- var _createClass2 = require("babel-runtime/helpers/createClass");
16
-
17
- var _createClass3 = _interopRequireDefault(_createClass2);
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- var logger_1 = require("../logger");
23
- var notificationtypes_1 = require("../interfaces/notificationtypes");
24
- var log = logger_1.Logger.scope('TypingIndicator');
25
- /**
26
- * An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
27
- * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
28
- * "typing_timeout" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a
29
- * notification of type "twilio.ipmsg.typing_indicator". In this case, the "typing_timeout" value will be +1 of that in the console. This
30
- * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,
31
- * the timeout returned from the notification should be used as the timeout for the "typingEnded" event, +1 is to account for latency.
32
- *
33
- * @private
34
- */
35
- /**
36
- * @class TypingIndicator
37
- *
38
- * @constructor
39
- * @private
40
- */
41
-
42
- var TypingIndicator = function () {
43
- function TypingIndicator(config, services, getConversation) {
44
- (0, _classCallCheck3.default)(this, TypingIndicator);
45
-
46
- this.config = config;
47
- this.services = services;
48
- this.getConversation = getConversation;
49
- this.serviceTypingTimeout = null;
50
- this.sentUpdates = new _map2.default();
51
- }
52
-
53
- (0, _createClass3.default)(TypingIndicator, [{
54
- key: "initialize",
55
-
56
- /**
57
- * Initialize TypingIndicator controller
58
- * Registers for needed message types and sets listeners
59
- * @private
60
- */
61
- value: function initialize() {
62
- var _this = this;
63
-
64
- this.services.notificationClient.subscribe(notificationtypes_1.NotificationTypes.TYPING_INDICATOR, 'twilsock');
65
- this.services.notificationClient.on('message', function (type, message) {
66
- if (type === notificationtypes_1.NotificationTypes.TYPING_INDICATOR) {
67
- _this.handleRemoteTyping(message);
68
- }
69
- });
70
- }
71
- /**
72
- * Remote participants typing events handler
73
- * @private
74
- */
75
-
76
- }, {
77
- key: "handleRemoteTyping",
78
- value: function handleRemoteTyping(message) {
79
- var _this2 = this;
80
-
81
- log.trace('Got new typing indicator ', message);
82
- this.getConversation(message.channel_sid).then(function (conversation) {
83
- if (!conversation) {
84
- return;
85
- }
86
- conversation.participants.forEach(function (participant) {
87
- if (participant.identity !== message.identity) {
88
- return;
89
- }
90
- var timeout = _this2.config.typingIndicatorTimeoutOverride + 1000 || message.typing_timeout * 1000;
91
- participant._startTyping(timeout);
92
- });
93
- }).catch(function (err) {
94
- log.error(err);
95
- throw err;
96
- });
97
- }
98
- /**
99
- * Send typing event for the given conversation sid
100
- * @param {String} conversationSid
101
- */
102
-
103
- }, {
104
- key: "send",
105
- value: function send(conversationSid) {
106
- var lastUpdate = this.sentUpdates.get(conversationSid);
107
- if (lastUpdate && lastUpdate > Date.now() - this.typingTimeout) {
108
- return _promise2.default.resolve();
109
- }
110
- this.sentUpdates.set(conversationSid, Date.now());
111
- return this._send(conversationSid);
112
- }
113
- }, {
114
- key: "_send",
115
- value: function _send(conversationSid) {
116
- var _this3 = this;
117
-
118
- log.trace('Sending typing indicator');
119
- var url = this.config.typingIndicatorUri;
120
- var headers = {
121
- 'Content-Type': 'application/x-www-form-urlencoded'
122
- };
123
- var body = 'ChannelSid=' + conversationSid;
124
- return this.services.transport.post(url, headers, body, this.config.productId).then(function (response) {
125
- if (response.body.hasOwnProperty('typing_timeout')) {
126
- _this3.serviceTypingTimeout = response.body.typing_timeout * 1000;
127
- }
128
- }).catch(function (err) {
129
- log.error('Failed to send typing indicator:', err);
130
- throw err;
131
- });
132
- }
133
- }, {
134
- key: "typingTimeout",
135
- get: function get() {
136
- return this.config.typingIndicatorTimeoutOverride || this.serviceTypingTimeout || this.config.typingIndicatorTimeoutDefault;
137
- }
138
- }]);
139
- return TypingIndicator;
140
- }();
141
-
142
- exports.TypingIndicator = TypingIndicator;