@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,94 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { ParticipantDescriptor, Participant } from '../participant';
4
- import { Conversation } from '../conversation';
5
- import { SyncMap, SyncClient } from 'twilio-sync';
6
- import { Users } from './users';
7
- import { Session } from '../session';
8
- export interface ParticipantsServices {
9
- session: Session;
10
- syncClient: SyncClient;
11
- users: Users;
12
- }
13
- export interface ParticipantBindingOptions {
14
- email?: Participant.EmailBinding;
15
- }
16
- /**
17
- * @classdesc Represents the collection of participants for the conversation
18
- * @fires Participants#participantJoined
19
- * @fires Participants#participantLeft
20
- * @fires Participants#participantUpdated
21
- */
22
- declare class Participants extends EventEmitter {
23
- services: ParticipantsServices;
24
- rosterEntityPromise: Promise<SyncMap>;
25
- readonly conversation: Conversation;
26
- readonly participants: Map<string, Participant>;
27
- constructor(conversation: Conversation, services: ParticipantsServices, participants: Map<string, Participant>);
28
- unsubscribe(): Promise<void>;
29
- subscribe(rosterObjectName: string): Promise<SyncMap>;
30
- upsertParticipant(participantSid: string, data: ParticipantDescriptor): Promise<Participant>;
31
- /**
32
- * @returns {Promise<Array<Participant>>} returns list of participants {@see Participant}
33
- */
34
- getParticipants(): Promise<Array<Participant>>;
35
- /**
36
- * Get participant by SID from conversation
37
- * @returns {Promise<Participant>}
38
- */
39
- getParticipantBySid(participantSid: string): Promise<Participant>;
40
- /**
41
- * Get participant by identity from conversation
42
- * @returns {Promise<Participant>}
43
- */
44
- getParticipantByIdentity(identity: string): Promise<Participant>;
45
- /**
46
- * Add a chat participant to the conversation
47
- * @returns {Promise<any>}
48
- */
49
- add(identity: string, attributes: any): Promise<any>;
50
- /**
51
- * Add a non-chat participant to the conversation.
52
- *
53
- * @param proxyAddress
54
- * @param address
55
- * @param attributes
56
- * @param bindingOptions
57
- * @returns {Promise<any>}
58
- */
59
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: Record<string, any>, bindingOptions?: ParticipantBindingOptions): Promise<any>;
60
- /**
61
- * Invites user to the conversation
62
- * User can choose either to join or not
63
- * @returns {Promise<any>}
64
- */
65
- invite(identity: string): Promise<any>;
66
- /**
67
- * Remove participant from conversation by Identity
68
- * @returns {Promise<any>}
69
- */
70
- removeByIdentity(identity: string): Promise<any>;
71
- /**
72
- * Remove participant from conversation by sid
73
- * @returns {Promise<any>}
74
- */
75
- removeBySid(sid: string): Promise<any>;
76
- }
77
- export { Participants };
78
- /**
79
- * Fired when participant joined conversation
80
- * @event Participants#participantJoined
81
- * @type {Participant}
82
- */
83
- /**
84
- * Fired when participant left conversation
85
- * @event Participants#participantLeft
86
- * @type {Participant}
87
- */
88
- /**
89
- * Fired when participant updated
90
- * @event Participants#participantUpdated
91
- * @type {Object}
92
- * @property {Participant} participant - Updated Participant
93
- * @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons
94
- */
@@ -1,204 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const events_1 = require("events");
4
- const participant_1 = require("../participant");
5
- const logger_1 = require("../logger");
6
- const log = logger_1.Logger.scope('Participants');
7
- /**
8
- * @classdesc Represents the collection of participants for the conversation
9
- * @fires Participants#participantJoined
10
- * @fires Participants#participantLeft
11
- * @fires Participants#participantUpdated
12
- */
13
- class Participants extends events_1.EventEmitter {
14
- constructor(conversation, services, participants) {
15
- super();
16
- this.services = services;
17
- this.conversation = conversation;
18
- this.participants = participants;
19
- }
20
- async unsubscribe() {
21
- if (this.rosterEntityPromise) {
22
- let entity = await this.rosterEntityPromise;
23
- entity.close();
24
- this.rosterEntityPromise = null;
25
- }
26
- }
27
- subscribe(rosterObjectName) {
28
- return this.rosterEntityPromise = this.rosterEntityPromise
29
- || this.services.syncClient.map({ id: rosterObjectName, mode: 'open_existing' })
30
- .then(rosterMap => {
31
- rosterMap.on('itemAdded', args => {
32
- log.debug(this.conversation.sid + ' itemAdded: ' + args.item.key);
33
- this.upsertParticipant(args.item.key, args.item.data)
34
- .then(participant => {
35
- this.emit('participantJoined', participant);
36
- });
37
- });
38
- rosterMap.on('itemRemoved', args => {
39
- log.debug(this.conversation.sid + ' itemRemoved: ' + args.key);
40
- let participantSid = args.key;
41
- if (!this.participants.has(participantSid)) {
42
- return;
43
- }
44
- let leftParticipant = this.participants.get(participantSid);
45
- this.participants.delete(participantSid);
46
- this.emit('participantLeft', leftParticipant);
47
- });
48
- rosterMap.on('itemUpdated', args => {
49
- log.debug(this.conversation.sid + ' itemUpdated: ' + args.item.key);
50
- this.upsertParticipant(args.item.key, args.item.data);
51
- });
52
- let participantsPromises = [];
53
- let that = this;
54
- const rosterMapHandler = function (paginator) {
55
- paginator.items.forEach(item => { participantsPromises.push(that.upsertParticipant(item.key, item.data)); });
56
- return paginator.hasNextPage ? paginator.nextPage().then(rosterMapHandler) : null;
57
- };
58
- return rosterMap
59
- .getItems()
60
- .then(rosterMapHandler)
61
- .then(() => Promise.all(participantsPromises))
62
- .then(() => rosterMap);
63
- })
64
- .catch(err => {
65
- this.rosterEntityPromise = null;
66
- if (this.services.syncClient.connectionState != 'disconnected') {
67
- log.error('Failed to get roster object for conversation', this.conversation.sid, err);
68
- }
69
- log.debug('ERROR: Failed to get roster object for conversation', this.conversation.sid, err);
70
- throw err;
71
- });
72
- }
73
- async upsertParticipant(participantSid, data) {
74
- let participant = this.participants.get(participantSid);
75
- if (participant) {
76
- return participant._update(data);
77
- }
78
- participant = new participant_1.Participant(this.services, this.conversation, data, participantSid);
79
- this.participants.set(participantSid, participant);
80
- participant.on('updated', (args) => this.emit('participantUpdated', args));
81
- return participant;
82
- }
83
- /**
84
- * @returns {Promise<Array<Participant>>} returns list of participants {@see Participant}
85
- */
86
- async getParticipants() {
87
- return this.rosterEntityPromise.then(() => {
88
- let participants = [];
89
- this.participants.forEach(participant => participants.push(participant));
90
- return participants;
91
- });
92
- }
93
- /**
94
- * Get participant by SID from conversation
95
- * @returns {Promise<Participant>}
96
- */
97
- async getParticipantBySid(participantSid) {
98
- return this.rosterEntityPromise.then(() => {
99
- let participant = this.participants.get(participantSid);
100
- if (!participant) {
101
- throw new Error('Participant with SID ' + participantSid + ' was not found');
102
- }
103
- return participant;
104
- });
105
- }
106
- /**
107
- * Get participant by identity from conversation
108
- * @returns {Promise<Participant>}
109
- */
110
- async getParticipantByIdentity(identity) {
111
- let foundParticipant = null;
112
- return this.rosterEntityPromise.then(() => {
113
- this.participants.forEach(participant => {
114
- if (participant.identity === identity) {
115
- foundParticipant = participant;
116
- }
117
- });
118
- if (!foundParticipant) {
119
- throw new Error('Participant with identity ' + identity + ' was not found');
120
- }
121
- return foundParticipant;
122
- });
123
- }
124
- /**
125
- * Add a chat participant to the conversation
126
- * @returns {Promise<any>}
127
- */
128
- add(identity, attributes) {
129
- return this.services.session.addCommand('addMemberV2', {
130
- channelSid: this.conversation.sid,
131
- attributes: JSON.stringify(attributes),
132
- username: identity
133
- });
134
- }
135
- /**
136
- * Add a non-chat participant to the conversation.
137
- *
138
- * @param proxyAddress
139
- * @param address
140
- * @param attributes
141
- * @param bindingOptions
142
- * @returns {Promise<any>}
143
- */
144
- addNonChatParticipant(proxyAddress, address, attributes = {}, bindingOptions = {}) {
145
- var _a, _b, _c, _d;
146
- return this.services.session.addCommand('addNonChatParticipant', {
147
- conversationSid: this.conversation.sid,
148
- proxyAddress,
149
- attributes: JSON.stringify(attributes),
150
- address,
151
- name: (_b = (_a = bindingOptions) === null || _a === void 0 ? void 0 : _a.email) === null || _b === void 0 ? void 0 : _b.name,
152
- level: (_d = (_c = bindingOptions) === null || _c === void 0 ? void 0 : _c.email) === null || _d === void 0 ? void 0 : _d.level,
153
- });
154
- }
155
- /**
156
- * Invites user to the conversation
157
- * User can choose either to join or not
158
- * @returns {Promise<any>}
159
- */
160
- invite(identity) {
161
- return this.services.session.addCommand('inviteMember', {
162
- channelSid: this.conversation.sid,
163
- username: identity
164
- });
165
- }
166
- /**
167
- * Remove participant from conversation by Identity
168
- * @returns {Promise<any>}
169
- */
170
- removeByIdentity(identity) {
171
- return this.services.session.addCommand('removeMember', {
172
- channelSid: this.conversation.sid,
173
- username: identity
174
- });
175
- }
176
- /**
177
- * Remove participant from conversation by sid
178
- * @returns {Promise<any>}
179
- */
180
- removeBySid(sid) {
181
- return this.services.session.addCommand('removeMember', {
182
- channelSid: this.conversation.sid,
183
- memberSid: sid
184
- });
185
- }
186
- }
187
- exports.Participants = Participants;
188
- /**
189
- * Fired when participant joined conversation
190
- * @event Participants#participantJoined
191
- * @type {Participant}
192
- */
193
- /**
194
- * Fired when participant left conversation
195
- * @event Participants#participantLeft
196
- * @type {Participant}
197
- */
198
- /**
199
- * Fired when participant updated
200
- * @event Participants#participantUpdated
201
- * @type {Object}
202
- * @property {Participant} participant - Updated Participant
203
- * @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons
204
- */
@@ -1,42 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { User } from '../user';
4
- import { Network } from '../services/network';
5
- import { Session } from '../session';
6
- import { SyncClient } from 'twilio-sync';
7
- export interface UsersServices {
8
- session: Session;
9
- network: Network;
10
- syncClient: SyncClient;
11
- }
12
- /**
13
- * @classdesc Container for known users
14
- * @fires Users#userUpdated
15
- */
16
- declare class Users extends EventEmitter {
17
- private services;
18
- private subscribedUsers;
19
- private fifoStack;
20
- private fifoStackMaxLength;
21
- private userUrlPromise;
22
- private userUrl;
23
- readonly myself: User;
24
- constructor(services: UsersServices);
25
- private handleUnsubscribeUser;
26
- private handleSubscribeUser;
27
- /**
28
- * Gets user, if it's in subscribed list - then return the user object from it,
29
- * if not - then subscribes and adds user to the FIFO stack
30
- * @returns {Promise<User>} Fully initialized user
31
- */
32
- getUser(identity: string, entityName?: string): Promise<User>;
33
- /**
34
- * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
35
- */
36
- getSubscribedUsers(): Promise<Array<User>>;
37
- /**
38
- * @returns {Promise<string>} User's sync unique name
39
- */
40
- private getSyncUniqueName;
41
- }
42
- export { Users };
package/lib/data/users.js DELETED
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const events_1 = require("events");
4
- const user_1 = require("../user");
5
- const util_1 = require("../util");
6
- /**
7
- * @classdesc Container for known users
8
- * @fires Users#userUpdated
9
- */
10
- class Users extends events_1.EventEmitter {
11
- constructor(services) {
12
- super();
13
- this.services = services;
14
- this.fifoStack = [];
15
- this.fifoStackMaxLength = 100;
16
- this.myself = new user_1.User(null, null, this.services);
17
- this.myself.on('updated', (args) => this.emit('userUpdated', args));
18
- this.myself.on('userSubscribed', () => this.emit('userSubscribed', this.myself));
19
- this.myself.on('userUnsubscribed', () => {
20
- this.emit('userUnsubscribed', this.myself);
21
- this.myself._ensureFetched();
22
- });
23
- this.services = services;
24
- this.subscribedUsers = new Map();
25
- this.userUrlPromise =
26
- this.services.session.getSessionLinks()
27
- .then((links) => {
28
- this.userUrl = links.usersUrl;
29
- return this.userUrl;
30
- });
31
- this.services.session.getMaxUserInfosToSubscribe()
32
- .then(maxUserInfosToSubscribe => {
33
- this.fifoStackMaxLength = maxUserInfosToSubscribe;
34
- });
35
- this.services.session.getUsersData()
36
- .then(data => {
37
- this.myself.identity = data.identity;
38
- this.myself.entityName = data.user;
39
- return this.myself._ensureFetched();
40
- });
41
- }
42
- handleUnsubscribeUser(user) {
43
- if (this.subscribedUsers.has(user.identity)) {
44
- this.subscribedUsers.delete(user.identity);
45
- }
46
- let foundItemIndex = -1;
47
- let foundItem = this.fifoStack.find((item, index) => {
48
- if (item == user.identity) {
49
- foundItemIndex = index;
50
- return true;
51
- }
52
- return false;
53
- });
54
- if (foundItem) {
55
- this.fifoStack.splice(foundItemIndex, 1);
56
- }
57
- this.emit('userUnsubscribed', user);
58
- }
59
- handleSubscribeUser(user) {
60
- if (this.subscribedUsers.has(user.identity)) {
61
- return;
62
- }
63
- if (this.fifoStack.length >= this.fifoStackMaxLength) {
64
- this.subscribedUsers.get(this.fifoStack.shift()).unsubscribe();
65
- }
66
- this.fifoStack.push(user.identity);
67
- this.subscribedUsers.set(user.identity, user);
68
- this.emit('userSubscribed', user);
69
- }
70
- /**
71
- * Gets user, if it's in subscribed list - then return the user object from it,
72
- * if not - then subscribes and adds user to the FIFO stack
73
- * @returns {Promise<User>} Fully initialized user
74
- */
75
- async getUser(identity, entityName = null) {
76
- await this.services.session.getUsersData();
77
- await this.myself._ensureFetched();
78
- if (identity == this.myself.identity) {
79
- return this.myself;
80
- }
81
- let user = this.subscribedUsers.get(identity);
82
- if (!user) {
83
- if (!entityName) {
84
- entityName = await this.getSyncUniqueName(identity);
85
- }
86
- user = new user_1.User(identity, entityName, this.services);
87
- user.on('updated', (args) => this.emit('userUpdated', args));
88
- user.on('userSubscribed', () => this.handleSubscribeUser(user));
89
- user.on('userUnsubscribed', () => this.handleUnsubscribeUser(user));
90
- await user._ensureFetched();
91
- }
92
- return user;
93
- }
94
- /**
95
- * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
96
- */
97
- async getSubscribedUsers() {
98
- await this.services.session.getUsersData();
99
- await this.myself._ensureFetched();
100
- let users = [this.myself];
101
- this.subscribedUsers.forEach((user) => users.push(user));
102
- return users;
103
- }
104
- /**
105
- * @returns {Promise<string>} User's sync unique name
106
- */
107
- async getSyncUniqueName(identity) {
108
- const url = new util_1.UriBuilder(this.userUrl).path(identity).build();
109
- let response = await this.services.network.get(url);
110
- return response.body.sync_unique_name;
111
- }
112
- }
113
- exports.Users = Users;
@@ -1,45 +0,0 @@
1
- declare namespace DetailedDeliveryReceipt {
2
- type Status = 'sent' | 'delivered' | 'failed' | 'read' | 'undelivered' | 'queued';
3
- interface Descriptor {
4
- sid: string;
5
- message_sid: string;
6
- conversation_sid: string;
7
- channel_message_sid: string;
8
- participant_sid: string;
9
- status: Status;
10
- error_code: number | null;
11
- date_created: string;
12
- date_updated: string;
13
- }
14
- }
15
- /**
16
- * @classdesc Represents a delivery receipt of a {@link Message}.
17
- *
18
- * @property {String} sid - The unique identifier for Delivery Receipt
19
- * @property {String} messageSid - The unique identifier for Conversation Message
20
- * @property {String} conversationSid - The unique identifier for Conversation
21
- * @property {String} channelMessageSid - The unique identifier for the ‘channel’ message e.g WAxx for Whatsapp, SMxx for SMS
22
- * @property {String} participantSid - Participant's unique identifier
23
- * @property {DetailedDeliveryReceipt#Status} status - Message delivery status
24
- * @property {number | null} errorCode - Numeric error code mapped from Status callback code. Information about the error codes can be found
25
- * <a href="https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors">here</a>.
26
- * @property {String} dateCreated - When Delivery Receipt was created
27
- * @property {String} dateUpdated - When Delivery Receipt was updated
28
- */
29
- export declare class DetailedDeliveryReceipt {
30
- sid: string;
31
- messageSid: string;
32
- conversationSid: string;
33
- channelMessageSid: string;
34
- participantSid: string;
35
- status: DetailedDeliveryReceipt.Status;
36
- errorCode: number | null;
37
- dateCreated: string;
38
- dateUpdated: string;
39
- /**
40
- * Signifies the message delivery status.
41
- * @typedef {('sent'|'delivered'|'failed'|'read'|'undelivered'|'queued')} DetailedDeliveryReceipt#Status
42
- */
43
- constructor(descriptor: DetailedDeliveryReceipt.Descriptor);
44
- }
45
- export {};
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @classdesc Represents a delivery receipt of a {@link Message}.
5
- *
6
- * @property {String} sid - The unique identifier for Delivery Receipt
7
- * @property {String} messageSid - The unique identifier for Conversation Message
8
- * @property {String} conversationSid - The unique identifier for Conversation
9
- * @property {String} channelMessageSid - The unique identifier for the ‘channel’ message e.g WAxx for Whatsapp, SMxx for SMS
10
- * @property {String} participantSid - Participant's unique identifier
11
- * @property {DetailedDeliveryReceipt#Status} status - Message delivery status
12
- * @property {number | null} errorCode - Numeric error code mapped from Status callback code. Information about the error codes can be found
13
- * <a href="https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors">here</a>.
14
- * @property {String} dateCreated - When Delivery Receipt was created
15
- * @property {String} dateUpdated - When Delivery Receipt was updated
16
- */
17
- class DetailedDeliveryReceipt {
18
- /**
19
- * Signifies the message delivery status.
20
- * @typedef {('sent'|'delivered'|'failed'|'read'|'undelivered'|'queued')} DetailedDeliveryReceipt#Status
21
- */
22
- constructor(descriptor) {
23
- this.sid = descriptor.sid;
24
- this.messageSid = descriptor.message_sid;
25
- this.conversationSid = descriptor.conversation_sid;
26
- this.channelMessageSid = descriptor.channel_message_sid;
27
- this.participantSid = descriptor.participant_sid;
28
- this.status = descriptor.status || 'queued';
29
- this.errorCode = descriptor.error_code || 0;
30
- this.dateCreated = descriptor.date_created;
31
- this.dateUpdated = descriptor.date_updated;
32
- }
33
- }
34
- exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- declare const chat: any;
package/lib/index.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
- const chat = require('./client');
3
- module.exports = chat;
@@ -1,8 +0,0 @@
1
- interface MediaLimits {
2
- mediaAttachmentsCountLimit: number;
3
- mediaAttachmentSizeLimitInMb: number;
4
- mediaAttachmentsTotalSizeLimitInMb: number;
5
- emailHistoriesAllowedMimeTypes: Array<String>;
6
- emailBodiesAllowedMimeTypes: Array<String>;
7
- }
8
- export { MediaLimits };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- declare class NotificationTypes {
2
- static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
3
- static readonly NEW_MESSAGE = "twilio.conversations.new_message";
4
- static readonly ADDED_TO_CONVERSATION = "twilio.conversations.added_to_conversation";
5
- static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
6
- static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
7
- }
8
- export { NotificationTypes };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class NotificationTypes {
4
- }
5
- exports.NotificationTypes = NotificationTypes;
6
- NotificationTypes.TYPING_INDICATOR = 'twilio.ipmsg.typing_indicator';
7
- NotificationTypes.NEW_MESSAGE = 'twilio.conversations.new_message';
8
- NotificationTypes.ADDED_TO_CONVERSATION = 'twilio.conversations.added_to_conversation';
9
- // static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';
10
- NotificationTypes.REMOVED_FROM_CONVERSATION = 'twilio.conversations.removed_from_conversation';
11
- NotificationTypes.CONSUMPTION_UPDATE = 'twilio.channel.consumption_update';
@@ -1,52 +0,0 @@
1
- /**
2
- * Pagination helper class.
3
- *
4
- * @interface
5
- * @property {Array} items Elements on current page
6
- * @property {boolean} hasNextPage Indicates the existence of next page
7
- * @property {boolean} hasPrevPage Indicates the existence of previous page
8
- * @function {Promise<Paginator>} nextPage() Request next page. Does not modify existing object
9
- * @function {Promise<Paginator>} prevPage() Request previous page. Does not modify existing object
10
- */
11
- interface Paginator<T> {
12
- hasNextPage: boolean;
13
- hasPrevPage: boolean;
14
- items: Array<T>;
15
- /**
16
- * Request next page.
17
- * Does not modify existing object.
18
- * @return {Promise<Paginator<T>>}
19
- */
20
- nextPage(): Promise<Paginator<T>>;
21
- /**
22
- * Request previous page.
23
- * Does not modify existing object.
24
- * @return {Promise<Paginator<T>>}
25
- */
26
- prevPage(): Promise<Paginator<T>>;
27
- }
28
- /**
29
- * @classdesc Pagination helper class.
30
- * @alias Paginator
31
- * @property {Array} items Array of elements of type T on current page
32
- * @property {boolean} hasNextPage Indicates the existence of next page
33
- * @property {boolean} hasPrevPage Indicates the existence of previous page
34
- */
35
- declare class SamplePaginator<T> implements Paginator<T> {
36
- hasNextPage: boolean;
37
- hasPrevPage: boolean;
38
- items: T[];
39
- /**
40
- * Request next page.
41
- * Does not modify existing object.
42
- * @return {Promise<Paginator<T>>}
43
- */
44
- nextPage(): Promise<Paginator<T>>;
45
- /**
46
- * Request previous page.
47
- * Does not modify existing object.
48
- * @return {Promise<Paginator<T>>}
49
- */
50
- prevPage(): Promise<Paginator<T>>;
51
- }
52
- export { Paginator, SamplePaginator };
@@ -1,28 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @classdesc Pagination helper class.
5
- * @alias Paginator
6
- * @property {Array} items Array of elements of type T on current page
7
- * @property {boolean} hasNextPage Indicates the existence of next page
8
- * @property {boolean} hasPrevPage Indicates the existence of previous page
9
- */
10
- class SamplePaginator {
11
- /**
12
- * Request next page.
13
- * Does not modify existing object.
14
- * @return {Promise<Paginator<T>>}
15
- */
16
- nextPage() {
17
- throw new Error('Method not implemented.');
18
- }
19
- /**
20
- * Request previous page.
21
- * Does not modify existing object.
22
- * @return {Promise<Paginator<T>>}
23
- */
24
- prevPage() {
25
- throw new Error('Method not implemented.');
26
- }
27
- }
28
- exports.SamplePaginator = SamplePaginator;
@@ -1,8 +0,0 @@
1
- declare class ResponseCodes {
2
- static readonly HTTP_200_OK = 200;
3
- static readonly HTTP_400_BAD_REQUEST = 400;
4
- static readonly HTTP_404_NOT_FOUND = 404;
5
- static readonly ACCESS_FORBIDDEN_FOR_IDENTITY = 54007;
6
- static readonly LIST_NOT_FOUND = 54150;
7
- }
8
- export { ResponseCodes };