@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,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class SyncListDescriptor {
4
- /**
5
- * @param {Object} descriptor - sync list descriptor data object
6
- * @private
7
- */
8
- constructor(descriptor) {
9
- this.channel_sid = descriptor.channel_sid;
10
- this.status = descriptor.status;
11
- this.channel = descriptor.channel;
12
- this.messages = descriptor.messages;
13
- this.roster = descriptor.roster;
14
- this.lastConsumedMessageIndex = descriptor.last_consumed_message_index;
15
- this.notificationLevel = descriptor.notification_level;
16
- this.descriptor = descriptor;
17
- }
18
- }
19
- exports.SyncListDescriptor = SyncListDescriptor;
@@ -1,22 +0,0 @@
1
- import { Paginator } from './interfaces/paginator';
2
- /**
3
- * @classdesc Pagination helper class for Sync
4
- *
5
- * @property {Array} items Array of elements on current page
6
- * @property {boolean} hasNextPage
7
- * @property {boolean} hasPrevPage
8
- */
9
- declare class SyncPaginator<T> implements Paginator<T> {
10
- private state;
11
- hasNextPage: boolean;
12
- hasPrevPage: boolean;
13
- get items(): Array<T>;
14
- /**
15
- * @param {Array} items Array of element for current page
16
- * @param {Object} params
17
- */
18
- constructor(items: any, pageSize: any, anchor: any, direction: any, source: any);
19
- nextPage(): Promise<SyncPaginator<T>>;
20
- prevPage(): Promise<SyncPaginator<T>>;
21
- }
22
- export { SyncPaginator };
@@ -1,37 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @classdesc Pagination helper class for Sync
5
- *
6
- * @property {Array} items Array of elements on current page
7
- * @property {boolean} hasNextPage
8
- * @property {boolean} hasPrevPage
9
- */
10
- class SyncPaginator {
11
- /**
12
- * @param {Array} items Array of element for current page
13
- * @param {Object} params
14
- */
15
- constructor(items, pageSize, anchor, direction, source) {
16
- this.hasNextPage = direction === 'backwards' ? anchor !== 'end' : items.length === pageSize;
17
- this.hasPrevPage = direction === 'backwards'
18
- ? items.length === pageSize && (items.length > 0 && items[0].index !== 0)
19
- : anchor !== 'end';
20
- this.state = {
21
- source,
22
- nextPageArgs: this.hasNextPage ? [pageSize, items[items.length - 1].index, 'forward'] : null,
23
- prevPageArgs: this.hasPrevPage ? [pageSize, (items.length > 0 ? items[0].index : 'end'), 'backwards'] : null,
24
- items
25
- };
26
- }
27
- get items() { return this.state.items; }
28
- nextPage() {
29
- return this.hasNextPage ? this.state.source.apply(null, this.state.nextPageArgs)
30
- : Promise.reject(new Error('No next page for query'));
31
- }
32
- prevPage() {
33
- return this.hasPrevPage ? this.state.source.apply(null, this.state.prevPageArgs)
34
- : Promise.reject(new Error('No prev page for query'));
35
- }
36
- }
37
- exports.SyncPaginator = SyncPaginator;
package/lib/user.d.ts DELETED
@@ -1,98 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { Session } from './session';
4
- import { SyncClient } from 'twilio-sync';
5
- export interface UserServices {
6
- session: Session;
7
- syncClient: SyncClient;
8
- }
9
- declare namespace User {
10
- type SubscriptionState = 'initializing' | 'subscribed' | 'unsubscribed';
11
- type UpdateReason = 'friendlyName' | 'attributes' | 'reachabilityOnline' | 'reachabilityNotifiable';
12
- interface UpdatedEventArgs {
13
- user: User;
14
- updateReasons: User.UpdateReason[];
15
- }
16
- }
17
- /**
18
- * @classdesc Extended user information.
19
- * Note that <code>isOnline</code> and <code>isNotifiable</code> properties are eligible
20
- * to use only if reachability function is enabled.
21
- * You may check if it is enabled by reading value of {@link Client}'s <code>reachabilityEnabled</code> property.
22
- *
23
- * @property {String} identity - User identity
24
- * @property {String} friendlyName - User friendly name, null if not set
25
- * @property {any} attributes - Object with custom attributes for user
26
- * @property {Boolean} isOnline - User real-time conversation connection status
27
- * @property {Boolean} isNotifiable - User push notification registration status
28
- * @property {Boolean} isSubscribed - Check if this user receives real-time status updates
29
- *
30
- * @fires User#updated
31
- * @fires User#userSubscribed
32
- * @fires User#userUnsubscribed
33
- *
34
- * @constructor
35
- * @param {String} identity - Identity of user
36
- * @param {String} entityId - id of user's object
37
- * @param {Object} datasync - datasync service
38
- * @param {Object} session - session service
39
- */
40
- declare class User extends EventEmitter {
41
- private entity;
42
- private services;
43
- private state;
44
- private promiseToFetch;
45
- private subscribed;
46
- /**
47
- * The update reason for <code>updated</code> event emitted on User
48
- * @typedef {('friendlyName' | 'attributes' | 'reachabilityOnline' | 'reachabilityNotifiable')} User#UpdateReason
49
- */
50
- constructor(identity: string, entityName: string, services: UserServices);
51
- get identity(): string;
52
- set identity(identity: string);
53
- set entityName(name: string);
54
- get attributes(): any;
55
- get friendlyName(): string;
56
- get isOnline(): boolean;
57
- get isNotifiable(): boolean;
58
- get isSubscribed(): boolean;
59
- _update(key: string, value: any): void;
60
- _updateReachabilityInfo(map: any, update: any): any;
61
- _fetch(): Promise<User>;
62
- _ensureFetched(): Promise<User>;
63
- /**
64
- * Updates user attributes.
65
- * @param {any} attributes new attributes for User.
66
- * @returns {Promise<User>}
67
- */
68
- updateAttributes(attributes: any): Promise<User>;
69
- /**
70
- * Update Users friendlyName.
71
- * @param {String|null} friendlyName - Updated friendlyName
72
- * @returns {Promise<User>}
73
- */
74
- updateFriendlyName(friendlyName: string | null): Promise<User>;
75
- /**
76
- * Removes User from subscription list.
77
- * @returns {Promise<void>} Promise of completion
78
- */
79
- unsubscribe(): Promise<void>;
80
- }
81
- export { User };
82
- /**
83
- * Fired when User's properties or reachability status have been updated.
84
- * @event User#updated
85
- * @type {Object}
86
- * @property {User} user - Updated User
87
- * @property {User#UpdateReason[]} updateReasons - Array of User's updated event reasons
88
- */
89
- /**
90
- * Fired when Client is subscribed to User.
91
- * @event User#userSubscribed
92
- * @type {User}
93
- */
94
- /**
95
- * Fired when Client is unsubscribed from this User.
96
- * @event User#userUnsubscribed
97
- * @type {User}
98
- */
package/lib/user.js DELETED
@@ -1,219 +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 logger_1 = require("./logger");
14
- const util_1 = require("./util");
15
- const twilio_sdk_type_validator_1 = require("twilio-sdk-type-validator");
16
- const log = logger_1.Logger.scope('User');
17
- /**
18
- * @classdesc Extended user information.
19
- * Note that <code>isOnline</code> and <code>isNotifiable</code> properties are eligible
20
- * to use only if reachability function is enabled.
21
- * You may check if it is enabled by reading value of {@link Client}'s <code>reachabilityEnabled</code> property.
22
- *
23
- * @property {String} identity - User identity
24
- * @property {String} friendlyName - User friendly name, null if not set
25
- * @property {any} attributes - Object with custom attributes for user
26
- * @property {Boolean} isOnline - User real-time conversation connection status
27
- * @property {Boolean} isNotifiable - User push notification registration status
28
- * @property {Boolean} isSubscribed - Check if this user receives real-time status updates
29
- *
30
- * @fires User#updated
31
- * @fires User#userSubscribed
32
- * @fires User#userUnsubscribed
33
- *
34
- * @constructor
35
- * @param {String} identity - Identity of user
36
- * @param {String} entityId - id of user's object
37
- * @param {Object} datasync - datasync service
38
- * @param {Object} session - session service
39
- */
40
- class User extends events_1.EventEmitter {
41
- /**
42
- * The update reason for <code>updated</code> event emitted on User
43
- * @typedef {('friendlyName' | 'attributes' | 'reachabilityOnline' | 'reachabilityNotifiable')} User#UpdateReason
44
- */
45
- constructor(identity, entityName, services) {
46
- super();
47
- this.subscribed = 'initializing';
48
- this.setMaxListeners(0);
49
- this.services = services;
50
- this.state = {
51
- identity: identity,
52
- entityName: entityName,
53
- friendlyName: null,
54
- attributes: {},
55
- online: null,
56
- notifiable: null
57
- };
58
- }
59
- get identity() { return this.state.identity; }
60
- set identity(identity) { this.state.identity = identity; }
61
- set entityName(name) { this.state.entityName = name; }
62
- get attributes() { return this.state.attributes; }
63
- get friendlyName() { return this.state.friendlyName; }
64
- get isOnline() { return this.state.online; }
65
- get isNotifiable() { return this.state.notifiable; }
66
- get isSubscribed() { return this.subscribed == 'subscribed'; }
67
- // Handles service updates
68
- _update(key, value) {
69
- let updateReasons = [];
70
- log.debug('User for', this.state.identity, 'updated:', key, value);
71
- switch (key) {
72
- case 'friendlyName':
73
- if (this.state.friendlyName !== value.value) {
74
- updateReasons.push('friendlyName');
75
- this.state.friendlyName = value.value;
76
- }
77
- break;
78
- case 'attributes':
79
- const updateAttributes = util_1.parseAttributes(value.value, `Retrieved malformed attributes from the server for user: ${this.state.identity}`, log);
80
- if (!util_1.isDeepEqual(this.state.attributes, updateAttributes)) {
81
- this.state.attributes = updateAttributes;
82
- updateReasons.push('attributes');
83
- }
84
- break;
85
- case 'reachability':
86
- if (this.state.online !== value.online) {
87
- this.state.online = value.online;
88
- updateReasons.push('reachabilityOnline');
89
- }
90
- if (this.state.notifiable !== value.notifiable) {
91
- this.state.notifiable = value.notifiable;
92
- updateReasons.push('reachabilityNotifiable');
93
- }
94
- break;
95
- default:
96
- return;
97
- }
98
- if (updateReasons.length > 0) {
99
- this.emit('updated', { user: this, updateReasons: updateReasons });
100
- }
101
- }
102
- // Fetch reachability info
103
- _updateReachabilityInfo(map, update) {
104
- if (!this.services.session.reachabilityEnabled) {
105
- return Promise.resolve();
106
- }
107
- return map.get('reachability')
108
- .then(update)
109
- .catch(err => { log.warn('Failed to get reachability info for ', this.state.identity, err); });
110
- }
111
- // Fetch user
112
- async _fetch() {
113
- if (!this.state.entityName) {
114
- return this;
115
- }
116
- this.promiseToFetch = this.services.syncClient.map({ id: this.state.entityName, mode: 'open_existing', includeItems: true })
117
- .then(map => {
118
- this.entity = map;
119
- map.on('itemUpdated', args => {
120
- log.debug(this.state.entityName + ' (' + this.state.identity + ') itemUpdated: ' + args.item.key);
121
- return this._update(args.item.key, args.item.data);
122
- });
123
- return Promise.all([
124
- map.get('friendlyName')
125
- .then(item => this._update(item.key, item.data)),
126
- map.get('attributes')
127
- .then(item => this._update(item.key, item.data)),
128
- this._updateReachabilityInfo(map, item => this._update(item.key, item.data))
129
- ]);
130
- })
131
- .then(() => {
132
- log.debug('Fetched for', this.identity);
133
- this.subscribed = 'subscribed';
134
- this.emit('userSubscribed', this);
135
- return this;
136
- })
137
- .catch(err => {
138
- this.promiseToFetch = null;
139
- throw err;
140
- });
141
- return this.promiseToFetch;
142
- }
143
- _ensureFetched() {
144
- return this.promiseToFetch || this._fetch();
145
- }
146
- /**
147
- * Updates user attributes.
148
- * @param {any} attributes new attributes for User.
149
- * @returns {Promise<User>}
150
- */
151
- async updateAttributes(attributes) {
152
- if (this.subscribed == 'unsubscribed') {
153
- throw new Error('Can\'t modify unsubscribed object');
154
- }
155
- await this.services.session.addCommand('editUserAttributes', {
156
- username: this.state.identity,
157
- attributes: JSON.stringify(attributes)
158
- });
159
- return this;
160
- }
161
- /**
162
- * Update Users friendlyName.
163
- * @param {String|null} friendlyName - Updated friendlyName
164
- * @returns {Promise<User>}
165
- */
166
- async updateFriendlyName(friendlyName) {
167
- if (this.subscribed == 'unsubscribed') {
168
- throw new Error('Can\'t modify unsubscribed object');
169
- }
170
- await this.services.session.addCommand('editUserFriendlyName', {
171
- username: this.state.identity,
172
- friendlyName: friendlyName
173
- });
174
- return this;
175
- }
176
- /**
177
- * Removes User from subscription list.
178
- * @returns {Promise<void>} Promise of completion
179
- */
180
- async unsubscribe() {
181
- if (this.promiseToFetch) {
182
- await this.promiseToFetch;
183
- this.entity.close();
184
- this.promiseToFetch = null;
185
- this.subscribed = 'unsubscribed';
186
- this.emit('userUnsubscribed', this);
187
- }
188
- }
189
- }
190
- __decorate([
191
- twilio_sdk_type_validator_1.validateTypesAsync(['string', 'number', 'boolean', 'object', twilio_sdk_type_validator_1.literal(null)]),
192
- __metadata("design:type", Function),
193
- __metadata("design:paramtypes", [Object]),
194
- __metadata("design:returntype", Promise)
195
- ], User.prototype, "updateAttributes", null);
196
- __decorate([
197
- twilio_sdk_type_validator_1.validateTypesAsync(['string', twilio_sdk_type_validator_1.literal(null)]),
198
- __metadata("design:type", Function),
199
- __metadata("design:paramtypes", [String]),
200
- __metadata("design:returntype", Promise)
201
- ], User.prototype, "updateFriendlyName", null);
202
- exports.User = User;
203
- /**
204
- * Fired when User's properties or reachability status have been updated.
205
- * @event User#updated
206
- * @type {Object}
207
- * @property {User} user - Updated User
208
- * @property {User#UpdateReason[]} updateReasons - Array of User's updated event reasons
209
- */
210
- /**
211
- * Fired when Client is subscribed to User.
212
- * @event User#userSubscribed
213
- * @type {User}
214
- */
215
- /**
216
- * Fired when Client is unsubscribed from this User.
217
- * @event User#userUnsubscribed
218
- * @type {User}
219
- */
@@ -1,12 +0,0 @@
1
- declare class Deferred<T> {
2
- private _promise;
3
- private _resolve;
4
- private _reject;
5
- current: T;
6
- constructor();
7
- get promise(): Promise<T>;
8
- update(value: T): void;
9
- set(value: T): void;
10
- fail(e: any): void;
11
- }
12
- export { Deferred };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Deferred {
4
- constructor() {
5
- this._promise = new Promise((resolve, reject) => {
6
- this._resolve = resolve;
7
- this._reject = reject;
8
- });
9
- }
10
- get promise() { return this._promise; }
11
- update(value) {
12
- this._resolve(value);
13
- }
14
- set(value) {
15
- this.current = value;
16
- this._resolve(value);
17
- }
18
- fail(e) {
19
- this._reject(e);
20
- }
21
- }
22
- exports.Deferred = Deferred;
@@ -1,28 +0,0 @@
1
- import { Logger } from '../logger';
2
- /**
3
- * Checks if objects are equal
4
- */
5
- declare function isDeepEqual(o1: Object, o2: Object): boolean;
6
- /**
7
- * Deep-clone an object. Note that this does not work on object containing
8
- * functions.
9
- * @param {object} obj - the object to deep-clone
10
- * @returns {object}
11
- */
12
- declare function deepClone<T>(obj: T): T;
13
- declare function parseToNumber(value: any): number;
14
- declare function parseTime(timeString: any): Date;
15
- declare function parseAttributes(rawAttributes: any, warningMessage: string, log: Logger): Object;
16
- /**
17
- * Construct URI with query parameters
18
- */
19
- declare class UriBuilder {
20
- private base;
21
- private args;
22
- private paths;
23
- constructor(base: string);
24
- arg(name: string, value: any): UriBuilder;
25
- path(name: string): UriBuilder;
26
- build(): string;
27
- }
28
- export { isDeepEqual, deepClone, UriBuilder, parseToNumber, parseTime, parseAttributes };
package/lib/util/index.js DELETED
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const JsonDiff = require("rfc6902");
4
- /**
5
- * Checks if objects are equal
6
- */
7
- function isDeepEqual(o1, o2) {
8
- return JsonDiff.createPatch(o1, o2).length === 0;
9
- }
10
- exports.isDeepEqual = isDeepEqual;
11
- /**
12
- * Deep-clone an object. Note that this does not work on object containing
13
- * functions.
14
- * @param {object} obj - the object to deep-clone
15
- * @returns {object}
16
- */
17
- function deepClone(obj) {
18
- return JSON.parse(JSON.stringify(obj));
19
- }
20
- exports.deepClone = deepClone;
21
- function parseToNumber(value) {
22
- if (typeof value !== 'undefined' && !isNaN(Number(value))) {
23
- return Number(value);
24
- }
25
- return null;
26
- }
27
- exports.parseToNumber = parseToNumber;
28
- // timeString cannot be typed `string` because in member.ts
29
- // call to parseTime(data.lastReadTimestamp) uses number not a string for timestamp.
30
- function parseTime(timeString) {
31
- try {
32
- return new Date(timeString);
33
- }
34
- catch (e) {
35
- return null;
36
- }
37
- }
38
- exports.parseTime = parseTime;
39
- function parseAttributes(rawAttributes, warningMessage, log) {
40
- let attributes = {};
41
- if (rawAttributes) {
42
- try {
43
- attributes = JSON.parse(rawAttributes);
44
- }
45
- catch (e) {
46
- log.warn(warningMessage, e);
47
- }
48
- }
49
- return attributes;
50
- }
51
- exports.parseAttributes = parseAttributes;
52
- /**
53
- * Construct URI with query parameters
54
- */
55
- class UriBuilder {
56
- constructor(base) {
57
- this.base = base.replace(/\/$/, '');
58
- this.args = [];
59
- this.paths = [];
60
- }
61
- arg(name, value) {
62
- if (typeof value !== 'undefined') {
63
- this.args.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
64
- }
65
- return this;
66
- }
67
- path(name) {
68
- this.paths.push(encodeURIComponent(name));
69
- return this;
70
- }
71
- build() {
72
- let result = this.base;
73
- if (this.paths.length) {
74
- result += '/' + this.paths.join('/');
75
- }
76
- if (this.args.length) {
77
- result += '?' + this.args.join('&');
78
- }
79
- return result;
80
- }
81
- }
82
- exports.UriBuilder = UriBuilder;
@@ -1,12 +0,0 @@
1
- ; DO NOT EDIT (unless you know what you are doing)
2
- ;
3
- ; This subdirectory is a git "subrepo", and this file is maintained by the
4
- ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
5
- ;
6
- [subrepo]
7
- remote = git@github.com:twilio/rtd-sdk-cdn-pin.git
8
- branch = master
9
- commit = be676abe2c634426ca410d25a95eeaf0afdc3430
10
- parent = 5e75275aa2f795042f27357eddacadb826442a70
11
- method = merge
12
- cmdver = 0.4.0
@@ -1,54 +0,0 @@
1
- # rtd-sdk-cdn-pin
2
- Scripts to fetch Messaging SDKs and then upload and pin to CDN.
3
- Usecase is fetch the artifact from distribution system and then with help of `sdk-release-tool` put it to Twilio CDN (dev/stage/prod).
4
-
5
- ## Supported Messaging SDKs:
6
- * twilio-sync-js
7
- * twilio-sync-android
8
- * twilio-chat-js
9
- * twilio-chat-android
10
- * twilio-conversations-js
11
- * twilio-conversations-android
12
-
13
- ## Fetching artifacts
14
- Fetching is made with `fetch-artifact.sh` script.
15
- The script takes the artifact and docs from respective distribution system (npmjs or bintray) and then places it in `artifacts/<sdk-name>/<release-version>` folder preseving structure needed for further upload to cdn with `sdk-release-tool`.
16
-
17
- To fetch Android or iOS artifacts `mvn` should be installed and the `bintray-settings.xml` file should be present at root of workspace to access `internal-release` repo on Bintray.
18
-
19
- **Usage:** `SDK_NAME=<sdk-name> RELEASE_VERSION=<release-version> ./fetch-artifact.sh` where `RELEASE_VERSION` can be `x.y.z` or `x.y.z-rcN`
20
-
21
- **Examples:**
22
- * `SDK_NAME=twilio-chat-js RELEASE_VERSION=3.3.0 ./fetch-artifact.sh`
23
- * `SDK_NAME=twilio-chat-android RELEASE_VERSION=4.1.1-rc1 ./fetch-artifact.sh`
24
-
25
- ## Uploading to CDN
26
- Uploading is made with `cdn-upload.sh` script.
27
- Script assumes that the version of artifact is fetched to `artifacts/<sdk-name>/<release-version>` with directory structure required for `sdk-release-tool`.
28
- Default behavior of script is dry run, no forced upload/pinning.
29
-
30
- **Usage:** `SDK_NAME=<sdk-name> RELEASE_VERSION=<release-version> SDK_RELEASE_TOOL_HOME=<absolute-path-to-sdk-release-tool> DEPLOY_REALM=<realm> FORCE_OVERWRITE=<force-upload-and-pin?> DRY_RUN=<dry-run?> ./cdn-upload.sh`, where:
31
- * `release-version` can be `x.y.z` or `x.y.z-rcN`
32
- * `realm` can be `dev`, `stage`, `prod`
33
- * `force-upload-and-pin?` is `true` or `false`, indicating should script overwrite (if already exists) files on CDN
34
- * `dry-run?` is `true` or `false`, indicating should script actually perform actions or it should simply print out what it's going to do (dry-run)
35
-
36
- **Examples:**
37
- * `SDK_NAME=twilio-chat-js RELEASE_VERSION=3.3.0 SDK_RELEASE_TOOL_HOME=/home/jenkins/sdk-release-tool DEPLOY_REALM=dev DRY_RUN=true ./cdn-upload.sh`
38
- * `SDK_NAME=twilio-chat-android RELEASE_VERSION=4.1.1-rc1 SDK_RELEASE_TOOL_HOME=/home/jenkins/sdk-release-tool DEPLOY_REALM=stage DRY_RUN=false FORCE_OVERWRITE=true ./cdn-upload.sh`
39
-
40
- ## Pinning to CDN
41
- Pinning is made with `cd-pin.sh` script.
42
- Default behavior of script is dry run, no forced upload/pinning.
43
-
44
- **Usage:** `SDK_NAME=<sdk-name> RELEASE_VERSION=<release-version> SDK_RELEASE_TOOL_HOME=<absolute-path-to-sdk-release-tool> DEPLOY_REALM=<realm> PIN_RELEASE=<pin-release?> PIN_LATEST=<pin-latest?> FORCE_OVERWRITE=<force-upload-and-pin?> DRY_RUN=<dry-run?> ./cdn-pin.sh`, where:
45
- * `release-version` can be `x.y.z` or `x.y.z-rcN`
46
- * `realm` can be `dev`, `stage`, `prod`
47
- * `pin-release?` is `true` or `false`, indicating should script pin release or not, i.e. pin `x.y.z` to `x.y` on CDN
48
- * `pin-latest?` is `true` or `false`, indicating should script pin uploaded release to `latest` version code on CDN or not
49
- * `force-upload-and-pin?` is `true` or `false`, indicating should script overwrite (if already exists) files on CDN
50
- * `dry-run?` is `true` or `false`, indicating should script actually perform actions or it should simply print out what it's going to do (dry-run)
51
-
52
- **Examples:**
53
- * `SDK_NAME=twilio-chat-js RELEASE_VERSION=3.3.0 SDK_RELEASE_TOOL_HOME=/home/jenkins/sdk-release-tool DEPLOY_REALM=dev PIN_RELEASE=false PIN_LATEST=false DRY_RUN=true ./cdn-pin.sh`
54
- * `SDK_NAME=twilio-chat-android RELEASE_VERSION=4.1.1-rc1 SDK_RELEASE_TOOL_HOME=/home/jenkins/sdk-release-tool DEPLOY_REALM=stage PIN_RELEASE=false PIN_LATEST=false DRY_RUN=false FORCE_OVERWRITE=true ./cdn-pin.sh`
@@ -1,16 +0,0 @@
1
- <?xml version='1.0' encoding='UTF-8'?>
2
- <settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
3
- xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
4
- <servers>
5
- <server>
6
- <id>bintray-twilio-internal-releases</id>
7
- <username>${BINTRAY_USERNAME}</username>
8
- <password>${BINTRAY_PASSWORD}</password>
9
- </server>
10
- <server>
11
- <id>bintray-twilio-snapshots</id>
12
- <username>${BINTRAY_USERNAME}</username>
13
- <password>${BINTRAY_PASSWORD}</password>
14
- </server>
15
- </servers>
16
- </settings>