@twilio/conversations 2.0.1-rc.3 → 2.0.1-rc.7

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 (97) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/{dist → builds}/browser.js +2 -2
  3. package/builds/browser.js.map +1 -0
  4. package/{dist → builds}/lib.d.ts +0 -0
  5. package/{dist → builds}/lib.js +2 -2
  6. package/builds/lib.js.map +1 -0
  7. package/{dist → builds}/twilio-conversations.js +5 -5
  8. package/{dist → builds}/twilio-conversations.min.js +2 -2
  9. package/dist/aggregated-delivery-receipt.js +227 -0
  10. package/dist/aggregated-delivery-receipt.js.map +1 -0
  11. package/dist/client.js +872 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/command-executor.js +203 -0
  14. package/dist/command-executor.js.map +1 -0
  15. package/dist/configuration.js +196 -0
  16. package/dist/configuration.js.map +1 -0
  17. package/dist/conversation.js +973 -0
  18. package/dist/conversation.js.map +1 -0
  19. package/dist/data/conversations.js +443 -0
  20. package/dist/data/conversations.js.map +1 -0
  21. package/dist/data/messages.js +341 -0
  22. package/dist/data/messages.js.map +1 -0
  23. package/dist/data/participants.js +313 -0
  24. package/dist/data/participants.js.map +1 -0
  25. package/dist/data/users.js +228 -0
  26. package/dist/data/users.js.map +1 -0
  27. package/dist/detailed-delivery-receipt.js +154 -0
  28. package/dist/detailed-delivery-receipt.js.map +1 -0
  29. package/dist/index.js +167 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/interfaces/notification-types.js +143 -0
  32. package/dist/interfaces/notification-types.js.map +1 -0
  33. package/dist/logger.js +190 -0
  34. package/dist/logger.js.map +1 -0
  35. package/dist/media.js +213 -0
  36. package/dist/media.js.map +1 -0
  37. package/dist/message-builder.js +209 -0
  38. package/dist/message-builder.js.map +1 -0
  39. package/dist/message.js +450 -0
  40. package/dist/message.js.map +1 -0
  41. package/dist/node_modules/tslib/tslib.es6.js +161 -0
  42. package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
  43. package/dist/packages/conversations/package.json.js +136 -0
  44. package/dist/packages/conversations/package.json.js.map +1 -0
  45. package/dist/participant.js +346 -0
  46. package/dist/participant.js.map +1 -0
  47. package/dist/push-notification.js +152 -0
  48. package/dist/push-notification.js.map +1 -0
  49. package/dist/rest-paginator.js +175 -0
  50. package/dist/rest-paginator.js.map +1 -0
  51. package/dist/services/network.js +205 -0
  52. package/dist/services/network.js.map +1 -0
  53. package/dist/services/typing-indicator.js +235 -0
  54. package/dist/services/typing-indicator.js.map +1 -0
  55. package/dist/unsent-message.js +159 -0
  56. package/dist/unsent-message.js.map +1 -0
  57. package/dist/user.js +392 -0
  58. package/dist/user.js.map +1 -0
  59. package/dist/util/deferred.js +154 -0
  60. package/dist/util/deferred.js.map +1 -0
  61. package/dist/util/index.js +206 -0
  62. package/dist/util/index.js.map +1 -0
  63. package/{dist/docs → docs}/assets/css/main.css +0 -0
  64. package/{dist/docs → docs}/assets/images/icons.png +0 -0
  65. package/{dist/docs → docs}/assets/images/icons@2x.png +0 -0
  66. package/{dist/docs → docs}/assets/images/widgets.png +0 -0
  67. package/{dist/docs → docs}/assets/images/widgets@2x.png +0 -0
  68. package/{dist/docs → docs}/assets/js/main.js +0 -0
  69. package/{dist/docs → docs}/assets/js/search.js +0 -0
  70. package/{dist/docs → docs}/classes/AggregatedDeliveryReceipt.html +0 -0
  71. package/{dist/docs → docs}/classes/Client.html +0 -0
  72. package/{dist/docs → docs}/classes/Conversation.html +0 -0
  73. package/{dist/docs → docs}/classes/DetailedDeliveryReceipt.html +0 -0
  74. package/{dist/docs → docs}/classes/Media.html +0 -0
  75. package/{dist/docs → docs}/classes/Message.html +0 -0
  76. package/{dist/docs → docs}/classes/MessageBuilder.html +0 -0
  77. package/{dist/docs → docs}/classes/Participant.html +0 -0
  78. package/{dist/docs → docs}/classes/PushNotification.html +0 -0
  79. package/{dist/docs → docs}/classes/RestPaginator.html +0 -0
  80. package/{dist/docs → docs}/classes/UnsentMessage.html +0 -0
  81. package/{dist/docs → docs}/classes/User.html +0 -0
  82. package/{dist/docs → docs}/index.html +0 -0
  83. package/{dist/docs → docs}/interfaces/ClientOptions.html +0 -0
  84. package/{dist/docs → docs}/interfaces/ConversationState.html +0 -0
  85. package/{dist/docs → docs}/interfaces/CreateConversationOptions.html +0 -0
  86. package/{dist/docs → docs}/interfaces/LastMessage.html +0 -0
  87. package/{dist/docs → docs}/interfaces/Paginator.html +0 -0
  88. package/{dist/docs → docs}/interfaces/PushNotificationData.html +0 -0
  89. package/{dist/docs → docs}/interfaces/SendEmailOptions.html +0 -0
  90. package/{dist/docs → docs}/interfaces/SendMediaOptions.html +0 -0
  91. package/{dist/docs → docs}/modules.html +0 -0
  92. package/package.json +23 -24
  93. package/dist/browser.js.map +0 -1
  94. package/dist/lib.js.map +0 -1
  95. package/dist/post-install.js +0 -29
  96. package/dist/react-native.js +0 -4035
  97. package/dist/react-native.js.map +0 -1
@@ -0,0 +1,973 @@
1
+ /*
2
+ @license
3
+ The following license applies to all parts of this software except as
4
+ documented below.
5
+
6
+ Copyright (c) 2019, Twilio, inc.
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are
11
+ met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in
18
+ the documentation and/or other materials provided with the
19
+ distribution.
20
+
21
+ 3. Neither the name of Twilio nor the names of its contributors may
22
+ be used to endorse or promote products derived from this software
23
+ without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ This software includes javascript-state-machine under the following license.
38
+
39
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ of this software and associated documentation files (the "Software"), to deal
43
+ in the Software without restriction, including without limitation the rights
44
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ copies of the Software, and to permit persons to whom the Software is
46
+ furnished to do so, subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in all
49
+ copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57
+
58
+ This software includes loglevel under the following license.
59
+
60
+ Copyright (c) 2013 Tim Perry
61
+
62
+ Permission is hereby granted, free of charge, to any person
63
+ obtaining a copy of this software and associated documentation
64
+ files (the "Software"), to deal in the Software without
65
+ restriction, including without limitation the rights to use,
66
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
67
+ copies of the Software, and to permit persons to whom the
68
+ Software is furnished to do so, subject to the following
69
+ conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
76
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
78
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
81
+ OTHER DEALINGS IN THE SOFTWARE.
82
+
83
+ This software includes q under the following license.
84
+
85
+ Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to
88
+ deal in the Software without restriction, including without limitation the
89
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
90
+ sell copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
101
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
102
+ IN THE SOFTWARE.
103
+
104
+ This software includes platform.js under the following license.
105
+
106
+ Copyright 2014 Benjamin Tan <https://d10.github.io/>
107
+ Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining
110
+ a copy of this software and associated documentation files (the
111
+ "Software"), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, sublicense, and/or sell copies of the Software, and to
114
+ permit persons to whom the Software is furnished to do so, subject to
115
+ the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be
118
+ included in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
123
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
124
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
125
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
126
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
+
128
+ */
129
+ 'use strict';
130
+
131
+ Object.defineProperty(exports, '__esModule', { value: true });
132
+
133
+ var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
134
+ var logger = require('./logger.js');
135
+ var participants = require('./data/participants.js');
136
+ var participant = require('./participant.js');
137
+ var messages = require('./data/messages.js');
138
+ var index = require('./util/index.js');
139
+ var declarativeTypeValidator = require('@twilio/declarative-type-validator');
140
+ var messageBuilder = require('./message-builder.js');
141
+ var replayEventEmitter = require('@twilio/replay-event-emitter');
142
+ var isEqual = require('lodash.isequal');
143
+
144
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
145
+
146
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
147
+
148
+ const log = logger.Logger.scope('Conversation');
149
+ const fieldMappings = {
150
+ lastMessage: 'lastMessage',
151
+ attributes: 'attributes',
152
+ createdBy: 'createdBy',
153
+ dateCreated: 'dateCreated',
154
+ dateUpdated: 'dateUpdated',
155
+ friendlyName: 'friendlyName',
156
+ lastConsumedMessageIndex: 'lastConsumedMessageIndex',
157
+ notificationLevel: 'notificationLevel',
158
+ sid: 'sid',
159
+ status: 'status',
160
+ uniqueName: 'uniqueName',
161
+ state: 'state'
162
+ };
163
+ function parseTime(timeString) {
164
+ try {
165
+ return new Date(timeString);
166
+ }
167
+ catch (e) {
168
+ return null;
169
+ }
170
+ }
171
+ /**
172
+ * A conversation represents communication between multiple Conversations clients
173
+ */
174
+ class Conversation extends replayEventEmitter.ReplayEventEmitter {
175
+ /**
176
+ * @internal
177
+ */
178
+ constructor(descriptor, sid, links, configuration, services) {
179
+ super();
180
+ this.sid = sid;
181
+ this.links = links;
182
+ this.configuration = configuration;
183
+ this.services = services;
184
+ let attributes = descriptor.attributes || {};
185
+ let createdBy = descriptor.createdBy;
186
+ let dateCreated = parseTime(descriptor.dateCreated);
187
+ let dateUpdated = parseTime(descriptor.dateUpdated);
188
+ let friendlyName = descriptor.friendlyName || null;
189
+ let lastReadMessageIndex = Number.isInteger(descriptor.lastConsumedMessageIndex) ? descriptor.lastConsumedMessageIndex : null;
190
+ let uniqueName = descriptor.uniqueName || null;
191
+ try {
192
+ JSON.stringify(attributes);
193
+ }
194
+ catch (e) {
195
+ throw new Error('Attributes must be a valid JSON object.');
196
+ }
197
+ this.entityName = descriptor.channel;
198
+ this.channelState = {
199
+ uniqueName,
200
+ status: 'notParticipating',
201
+ attributes,
202
+ createdBy,
203
+ dateCreated,
204
+ dateUpdated,
205
+ friendlyName,
206
+ lastReadMessageIndex: lastReadMessageIndex
207
+ };
208
+ if (descriptor.notificationLevel) {
209
+ this.channelState.notificationLevel = descriptor.notificationLevel;
210
+ }
211
+ const participantsLinks = {
212
+ participants: this.links.participants
213
+ };
214
+ this.participants = new Map();
215
+ this.participantsEntity = new participants.Participants(this, this.participants, participantsLinks, this.configuration, this.services);
216
+ this.participantsEntity.on('participantJoined', this.emit.bind(this, 'participantJoined'));
217
+ this.participantsEntity.on('participantLeft', this.emit.bind(this, 'participantLeft'));
218
+ this.participantsEntity.on('participantUpdated', (args) => this.emit('participantUpdated', args));
219
+ this.messagesEntity = new messages.Messages(this, configuration, services);
220
+ this.messagesEntity.on('messageAdded', message => this._onMessageAdded(message));
221
+ this.messagesEntity.on('messageUpdated', (args) => this.emit('messageUpdated', args));
222
+ this.messagesEntity.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
223
+ }
224
+ /**
225
+ * Unique name of the conversation.
226
+ */
227
+ get uniqueName() { return this.channelState.uniqueName; }
228
+ /**
229
+ * Status of the conversation.
230
+ */
231
+ get status() { return this.channelState.status; }
232
+ /**
233
+ * Name of the conversation.
234
+ */
235
+ get friendlyName() { return this.channelState.friendlyName; }
236
+ /**
237
+ * Date this conversation was last updated on.
238
+ */
239
+ get dateUpdated() { return this.channelState.dateUpdated; }
240
+ /**
241
+ * Date this conversation was created on.
242
+ */
243
+ get dateCreated() { return this.channelState.dateCreated; }
244
+ /**
245
+ * Identity of the user that created this conversation.
246
+ */
247
+ get createdBy() { return this.channelState.createdBy; }
248
+ /**
249
+ * Custom attributes of the conversation.
250
+ */
251
+ get attributes() { return this.channelState.attributes; }
252
+ /**
253
+ * Index of the last message the user has read in this conversation.
254
+ */
255
+ get lastReadMessageIndex() { return this.channelState.lastReadMessageIndex; }
256
+ /**
257
+ * Last message sent to this conversation.
258
+ */
259
+ get lastMessage() { return this.channelState.lastMessage; }
260
+ /**
261
+ * User notification level for this conversation.
262
+ */
263
+ get notificationLevel() { return this.channelState.notificationLevel; }
264
+ get limits() { return this.configuration.limits; }
265
+ /**
266
+ * State of the conversation.
267
+ */
268
+ get state() { return this.channelState.state; }
269
+ /**
270
+ * Load and subscribe to this conversation and do not subscribe to its participants and messages.
271
+ * This or _subscribeStreams will need to be called before any events on conversation will fire.
272
+ * @internal
273
+ */
274
+ _subscribe() {
275
+ var _a;
276
+ return this.entityPromise = (_a = this.entityPromise) !== null && _a !== void 0 ? _a : this.services.syncClient.document({ id: this.entityName, mode: 'open_existing' })
277
+ .then(entity => {
278
+ this.entity = entity;
279
+ this.entity.on('updated', args => { this._update(args.data); });
280
+ this.entity.on('removed', () => this.emit('removed', this));
281
+ this._update(this.entity.data);
282
+ return entity;
283
+ })
284
+ .catch(err => {
285
+ this.entity = null;
286
+ this.entityPromise = null;
287
+ if (this.services.syncClient.connectionState != 'disconnected') {
288
+ log.error('Failed to get conversation object', err);
289
+ }
290
+ log.debug('ERROR: Failed to get conversation object', err);
291
+ throw err;
292
+ });
293
+ }
294
+ /**
295
+ * Load the attributes of this conversation and instantiate its participants and messages.
296
+ * This or _subscribe will need to be called before any events on the conversation will fire.
297
+ * This will need to be called before any events on participants or messages will fire
298
+ * @internal
299
+ */
300
+ async _subscribeStreams() {
301
+ try {
302
+ await this._subscribe();
303
+ log.trace('_subscribeStreams, this.entity.data=', this.entity.data);
304
+ const messagesObjectName = this.entity.data.messages;
305
+ const rosterObjectName = this.entity.data.roster;
306
+ await Promise.all([
307
+ this.messagesEntity.subscribe(messagesObjectName),
308
+ this.participantsEntity.subscribe(rosterObjectName)
309
+ ]);
310
+ }
311
+ catch (err) {
312
+ if (this.services.syncClient.connectionState !== 'disconnected') {
313
+ log.error('Failed to subscribe on conversation objects', this.sid, err);
314
+ }
315
+ log.debug('ERROR: Failed to subscribe on conversation objects', this.sid, err);
316
+ throw err;
317
+ }
318
+ }
319
+ /**
320
+ * Stop listening for and firing events on this conversation.
321
+ * @internal
322
+ */
323
+ async _unsubscribe() {
324
+ if (this.entity) {
325
+ await this.entity.close();
326
+ this.entity = null;
327
+ this.entityPromise = null;
328
+ }
329
+ return Promise.all([
330
+ this.participantsEntity.unsubscribe(),
331
+ this.messagesEntity.unsubscribe()
332
+ ]);
333
+ }
334
+ /**
335
+ * Set conversation status.
336
+ * @internal
337
+ */
338
+ _setStatus(status, source) {
339
+ this.statusSource = source;
340
+ if (this.channelState.status === status) {
341
+ return;
342
+ }
343
+ this.channelState.status = status;
344
+ if (status === 'joined') {
345
+ this._subscribeStreams()
346
+ .catch(err => {
347
+ log.debug('ERROR while setting conversation status ' + status, err);
348
+ if (this.services.syncClient.connectionState !== 'disconnected') {
349
+ throw err;
350
+ }
351
+ });
352
+ }
353
+ else if (this.entityPromise) {
354
+ this._unsubscribe().catch(err => {
355
+ log.debug('ERROR while setting conversation status ' + status, err);
356
+ if (this.services.syncClient.connectionState !== 'disconnected') {
357
+ throw err;
358
+ }
359
+ });
360
+ }
361
+ }
362
+ /**
363
+ * Get the source of the conversation update.
364
+ * @internal
365
+ */
366
+ _statusSource() {
367
+ return this.statusSource;
368
+ }
369
+ static preprocessUpdate(update, conversationSid) {
370
+ try {
371
+ if (typeof update.attributes === 'string') {
372
+ update.attributes = JSON.parse(update.attributes);
373
+ }
374
+ else if (update.attributes) {
375
+ JSON.stringify(update.attributes);
376
+ }
377
+ }
378
+ catch (e) {
379
+ log.warn('Retrieved malformed attributes from the server for conversation: ' + conversationSid);
380
+ update.attributes = {};
381
+ }
382
+ try {
383
+ if (update.dateCreated) {
384
+ update.dateCreated = new Date(update.dateCreated);
385
+ }
386
+ }
387
+ catch (e) {
388
+ log.warn('Retrieved malformed dateCreated from the server for conversation: ' + conversationSid);
389
+ delete update.dateCreated;
390
+ }
391
+ try {
392
+ if (update.dateUpdated) {
393
+ update.dateUpdated = new Date(update.dateUpdated);
394
+ }
395
+ }
396
+ catch (e) {
397
+ log.warn('Retrieved malformed dateUpdated from the server for conversation: ' + conversationSid);
398
+ delete update.dateUpdated;
399
+ }
400
+ try {
401
+ if (update.lastMessage && update.lastMessage.timestamp) {
402
+ update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);
403
+ }
404
+ }
405
+ catch (e) {
406
+ log.warn('Retrieved malformed lastMessage.timestamp from the server for conversation: ' + conversationSid);
407
+ delete update.lastMessage.timestamp;
408
+ }
409
+ }
410
+ /**
411
+ * Update the local conversation object with new values.
412
+ * @internal
413
+ */
414
+ _update(update) {
415
+ var _a, _b, _c, _d, _e;
416
+ log.trace('_update', update);
417
+ Conversation.preprocessUpdate(update, this.sid);
418
+ const updateReasons = new Set();
419
+ for (const key of Object.keys(update)) {
420
+ const localKey = fieldMappings[key];
421
+ if (!localKey) {
422
+ continue;
423
+ }
424
+ switch (localKey) {
425
+ case fieldMappings.status:
426
+ if (!update.status || update.status === 'unknown'
427
+ || this.channelState.status === update.status) {
428
+ break;
429
+ }
430
+ this.channelState.status = update.status;
431
+ updateReasons.add(localKey);
432
+ break;
433
+ case fieldMappings.attributes:
434
+ if (isEqual__default['default'](this.channelState.attributes, update.attributes)) {
435
+ break;
436
+ }
437
+ this.channelState.attributes = update.attributes;
438
+ updateReasons.add(localKey);
439
+ break;
440
+ case fieldMappings.lastConsumedMessageIndex:
441
+ if (update.lastConsumedMessageIndex === undefined
442
+ || update.lastConsumedMessageIndex === this.channelState.lastReadMessageIndex) {
443
+ break;
444
+ }
445
+ this.channelState.lastReadMessageIndex = update.lastConsumedMessageIndex;
446
+ updateReasons.add('lastReadMessageIndex');
447
+ break;
448
+ case fieldMappings.lastMessage:
449
+ if (this.channelState.lastMessage && !update.lastMessage) {
450
+ delete this.channelState.lastMessage;
451
+ updateReasons.add(localKey);
452
+ break;
453
+ }
454
+ this.channelState.lastMessage = this.channelState.lastMessage || {};
455
+ if (((_a = update.lastMessage) === null || _a === void 0 ? void 0 : _a.index) !== undefined
456
+ && update.lastMessage.index !== this.channelState.lastMessage.index) {
457
+ this.channelState.lastMessage.index = update.lastMessage.index;
458
+ updateReasons.add(localKey);
459
+ }
460
+ if (((_b = update.lastMessage) === null || _b === void 0 ? void 0 : _b.timestamp) !== undefined
461
+ && ((_d = (_c = this.channelState.lastMessage) === null || _c === void 0 ? void 0 : _c.dateCreated) === null || _d === void 0 ? void 0 : _d.getTime()) !== update.lastMessage.timestamp.getTime()) {
462
+ this.channelState.lastMessage.dateCreated = update.lastMessage.timestamp;
463
+ updateReasons.add(localKey);
464
+ }
465
+ if (isEqual__default['default'](this.channelState.lastMessage, {})) {
466
+ delete this.channelState.lastMessage;
467
+ }
468
+ break;
469
+ case fieldMappings.state:
470
+ const state = update.state || undefined;
471
+ if (state !== undefined) {
472
+ state.dateUpdated = new Date(state.dateUpdated);
473
+ }
474
+ if (isEqual__default['default'](this.channelState.state, state)) {
475
+ break;
476
+ }
477
+ this.channelState.state = state;
478
+ updateReasons.add(localKey);
479
+ break;
480
+ default:
481
+ const isDate = update[key] instanceof Date;
482
+ const keysMatchAsDates = isDate && ((_e = this.channelState[localKey]) === null || _e === void 0 ? void 0 : _e.getTime()) === update[key].getTime();
483
+ const keysMatchAsNonDates = !isDate && this[localKey] === update[key];
484
+ if (keysMatchAsDates || keysMatchAsNonDates) {
485
+ break;
486
+ }
487
+ this.channelState[localKey] = update[key];
488
+ updateReasons.add(localKey);
489
+ }
490
+ }
491
+ if (updateReasons.size > 0) {
492
+ this.emit('updated', { conversation: this, updateReasons: [...updateReasons] });
493
+ }
494
+ }
495
+ /**
496
+ * @internal
497
+ */
498
+ _onMessageAdded(message) {
499
+ for (let participant of this.participants.values()) {
500
+ if (participant.identity === message.author) {
501
+ participant._endTyping();
502
+ break;
503
+ }
504
+ }
505
+ this.emit('messageAdded', message);
506
+ }
507
+ async _setLastReadMessageIndex(index) {
508
+ const result = await this.services.commandExecutor.mutateResource('post', `${this.configuration.links.myConversations}/${this.sid}`, {
509
+ last_read_message_index: index
510
+ });
511
+ return result.unread_messages_count;
512
+ }
513
+ /**
514
+ * Add a participant to the conversation by its identity.
515
+ * @param identity Identity of the Client to add.
516
+ * @param attributes Attributes to be attached to the participant.
517
+ */
518
+ async add(identity, attributes) {
519
+ return this.participantsEntity.add(identity, attributes);
520
+ }
521
+ /**
522
+ * Add a non-chat participant to the conversation.
523
+ * @param proxyAddress Proxy (Twilio) address of the participant.
524
+ * @param address User address of the participant.
525
+ * @param attributes Attributes to be attached to the participant.
526
+ */
527
+ async addNonChatParticipant(proxyAddress, address, attributes) {
528
+ return this.participantsEntity.addNonChatParticipant(proxyAddress, address, attributes);
529
+ }
530
+ /**
531
+ * Advance the conversation's last read message index to the current read horizon.
532
+ * Rejects if the user is not a participant of the conversation.
533
+ * Last read message index is updated only if the new index value is higher than the previous.
534
+ * @param index Message index to advance to.
535
+ * @return Resulting unread messages count in the conversation.
536
+ */
537
+ async advanceLastReadMessageIndex(index) {
538
+ await this._subscribeStreams();
539
+ if (index < this.lastReadMessageIndex) {
540
+ return await this._setLastReadMessageIndex(this.lastReadMessageIndex);
541
+ }
542
+ return await this._setLastReadMessageIndex(index);
543
+ }
544
+ /**
545
+ * Delete the conversation and unsubscribe from its events.
546
+ */
547
+ async delete() {
548
+ await this.services.commandExecutor.mutateResource('delete', this.links.self);
549
+ return this;
550
+ }
551
+ /**
552
+ * Get the custom attributes of this Conversation.
553
+ */
554
+ async getAttributes() {
555
+ await this._subscribe();
556
+ return this.attributes;
557
+ }
558
+ /**
559
+ * Returns messages from the conversation using the paginator interface.
560
+ * @param pageSize Number of messages to return in a single chunk. Default is 30.
561
+ * @param anchor Index of the newest message to fetch. Default is from the end.
562
+ * @param direction Query direction. By default it queries backwards
563
+ * from newer to older. The `"forward"` value will query in the opposite direction.
564
+ * @return A page of messages.
565
+ */
566
+ async getMessages(pageSize, anchor, direction) {
567
+ await this._subscribeStreams();
568
+ return this.messagesEntity.getMessages(pageSize, anchor, direction);
569
+ }
570
+ /**
571
+ * Get a list of all the participants who are joined to this conversation.
572
+ */
573
+ async getParticipants() {
574
+ await this._subscribeStreams();
575
+ return this.participantsEntity.getParticipants();
576
+ }
577
+ /**
578
+ * Get conversation participants count.
579
+ *
580
+ * This method is semi-realtime. This means that this data will be eventually correct,
581
+ * but will also be possibly incorrect for a few seconds. The Conversations system does not
582
+ * provide real time events for counter values changes.
583
+ *
584
+ * This is useful for any UI badges, but it is not recommended to build any core application
585
+ * logic based on these counters being accurate in real time.
586
+ */
587
+ async getParticipantsCount() {
588
+ const url = new index.UriBuilder(this.configuration.links.conversations)
589
+ .path(this.sid)
590
+ .build();
591
+ const response = await this.services.network.get(url);
592
+ return response.body.participants_count;
593
+ }
594
+ /**
595
+ * Get a participant by its SID.
596
+ * @param participantSid Participant SID.
597
+ */
598
+ async getParticipantBySid(participantSid) {
599
+ return this.participantsEntity.getParticipantBySid(participantSid);
600
+ }
601
+ /**
602
+ * Get a participant by its identity.
603
+ * @param identity Participant identity.
604
+ */
605
+ async getParticipantByIdentity(identity) {
606
+ return this.participantsEntity.getParticipantByIdentity(identity);
607
+ }
608
+ /**
609
+ * Get the total message count in the conversation.
610
+ *
611
+ * This method is semi-realtime. This means that this data will be eventually correct,
612
+ * but will also be possibly incorrect for a few seconds. The Conversations system does not
613
+ * provide real time events for counter values changes.
614
+ *
615
+ * This is useful for any UI badges, but it is not recommended to build any core application
616
+ * logic based on these counters being accurate in real time.
617
+ */
618
+ async getMessagesCount() {
619
+ const url = new index.UriBuilder(this.configuration.links.conversations)
620
+ .path(this.sid)
621
+ .build();
622
+ const response = await this.services.network.get(url);
623
+ return response.body.messages_count;
624
+ }
625
+ /**
626
+ * Get unread messages count for the user if they are a participant of this conversation.
627
+ * Rejects if the user is not a participant of the conversation.
628
+ *
629
+ * Use this method to obtain the number of unread messages together with
630
+ * {@link Conversation.updateLastReadMessageIndex} instead of relying on the
631
+ * message indices which may have gaps. See {@link Message.index} for details.
632
+ *
633
+ * This method is semi-realtime. This means that this data will be eventually correct,
634
+ * but will also be possibly incorrect for a few seconds. The Conversations system does not
635
+ * provide real time events for counter values changes.
636
+ *
637
+ * This is useful for any UI badges, but it is not recommended to build any core application
638
+ * logic based on these counters being accurate in real time.
639
+ */
640
+ async getUnreadMessagesCount() {
641
+ const url = new index.UriBuilder(this.configuration.links.myConversations)
642
+ .path(this.sid)
643
+ .build();
644
+ const response = await this.services.network.get(url);
645
+ if (response.body.conversation_sid !== this.sid) {
646
+ throw new Error('Conversation was not found in the user conversations list');
647
+ }
648
+ const unreadMessageCount = response.body.unread_messages_count;
649
+ if (typeof unreadMessageCount === 'number') {
650
+ return unreadMessageCount;
651
+ }
652
+ return null;
653
+ }
654
+ /**
655
+ * Join the conversation and subscribe to its events.
656
+ */
657
+ async join() {
658
+ await this.services.commandExecutor.mutateResource('post', this.links.participants, {
659
+ identity: this.configuration.userIdentity
660
+ });
661
+ return this;
662
+ }
663
+ /**
664
+ * Leave the conversation.
665
+ */
666
+ async leave() {
667
+ if (this.channelState.status === 'joined') {
668
+ await this.services.commandExecutor.mutateResource('delete', `${this.links.participants}/${this.configuration.userIdentity}`);
669
+ }
670
+ return this;
671
+ }
672
+ /**
673
+ * Remove a participant from the conversation. When a string is passed as the
674
+ * argument, it will assume that the string is an identity or SID.
675
+ * @param participant Identity, SID or the participant object to remove.
676
+ */
677
+ async removeParticipant(participant) {
678
+ await this.participantsEntity.remove(typeof participant === 'string'
679
+ ? participant
680
+ : participant.sid);
681
+ }
682
+ /**
683
+ * Send a message to the conversation.
684
+ * @param message Message body for the text message,
685
+ * `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.
686
+ * @param messageAttributes Attributes for the message.
687
+ * @param emailOptions Email options for the message.
688
+ * @return Index of the new message.
689
+ */
690
+ async sendMessage(message, messageAttributes, emailOptions) {
691
+ if (typeof message === 'string' || message === null) {
692
+ let response = await this.messagesEntity.send(message, messageAttributes, emailOptions);
693
+ return index.parseToNumber(response.index);
694
+ }
695
+ let response = await this.messagesEntity.sendMedia(message, messageAttributes, emailOptions);
696
+ return index.parseToNumber(response.index);
697
+ }
698
+ /**
699
+ * New interface to prepare for sending a message.
700
+ * Use instead of `sendMessage`.
701
+ */
702
+ prepareMessage() {
703
+ return new messageBuilder.MessageBuilder(this.limits, this.messagesEntity);
704
+ }
705
+ /**
706
+ * Set last read message index of the conversation to the index of the last known message.
707
+ * @return Resulting unread messages count in the conversation.
708
+ */
709
+ async setAllMessagesRead() {
710
+ await this._subscribeStreams();
711
+ let messagesPage = await this.getMessages(1);
712
+ if (messagesPage.items.length > 0) {
713
+ return this.advanceLastReadMessageIndex(messagesPage.items[0].index);
714
+ }
715
+ return Promise.resolve(0);
716
+ }
717
+ /**
718
+ * Set all messages in the conversation unread.
719
+ * @return Resulting unread messages count in the conversation.
720
+ */
721
+ async setAllMessagesUnread() {
722
+ await this._subscribeStreams();
723
+ return await this._setLastReadMessageIndex(null);
724
+ }
725
+ /**
726
+ * Set user notification level for this conversation.
727
+ * @param notificationLevel New user notification level.
728
+ */
729
+ async setUserNotificationLevel(notificationLevel) {
730
+ await this.services.commandExecutor.mutateResource('post', `${this.configuration.links.myConversations}/${this.sid}`, {
731
+ notification_level: notificationLevel
732
+ });
733
+ }
734
+ /**
735
+ * Send a notification to the server indicating that this client is currently typing in this conversation.
736
+ * Typing ended notification is sent after a while automatically, but by calling this method again you ensure that typing ended is not received.
737
+ */
738
+ typing() {
739
+ return this.services.typingIndicator.send(this.sid);
740
+ }
741
+ /**
742
+ * Update the attributes of the conversation.
743
+ * @param attributes New attributes.
744
+ */
745
+ async updateAttributes(attributes) {
746
+ await this.services.commandExecutor.mutateResource('post', this.links.self, {
747
+ attributes: attributes !== undefined ? JSON.stringify(attributes) : undefined
748
+ });
749
+ return this;
750
+ }
751
+ /**
752
+ * Update the friendly name of the conversation.
753
+ * @param friendlyName New friendly name.
754
+ */
755
+ async updateFriendlyName(friendlyName) {
756
+ if (this.channelState.friendlyName !== friendlyName) {
757
+ await this.services.commandExecutor.mutateResource('post', this.links.self, { friendly_name: friendlyName });
758
+ }
759
+ return this;
760
+ }
761
+ /**
762
+ * Set the last read message index to the current read horizon.
763
+ * @param index Message index to set as last read.
764
+ * If null is provided, then the behavior is identical to {@link Conversation.setAllMessagesUnread}.
765
+ * @returns Resulting unread messages count in the conversation.
766
+ */
767
+ async updateLastReadMessageIndex(index) {
768
+ await this._subscribeStreams();
769
+ return this._setLastReadMessageIndex(index);
770
+ }
771
+ /**
772
+ * Update the unique name of the conversation.
773
+ * @param uniqueName New unique name for the conversation. Setting unique name to null removes it.
774
+ */
775
+ async updateUniqueName(uniqueName) {
776
+ if (this.channelState.uniqueName !== uniqueName) {
777
+ if (!uniqueName) {
778
+ uniqueName = '';
779
+ }
780
+ await this.services.commandExecutor.mutateResource('post', this.links.self, {
781
+ unique_name: uniqueName
782
+ });
783
+ }
784
+ return this;
785
+ }
786
+ }
787
+ /**
788
+ * Fired when a participant has joined the conversation.
789
+ *
790
+ * Parameters:
791
+ * 1. {@link Participant} `participant` - participant that joined the conversation
792
+ * @event
793
+ */
794
+ Conversation.participantJoined = 'participantJoined';
795
+ /**
796
+ * Fired when a participant has left the conversation.
797
+ *
798
+ * Parameters:
799
+ * 1. {@link Participant} `participant` - participant that left the conversation
800
+ * @event
801
+ */
802
+ Conversation.participantLeft = 'participantLeft';
803
+ /**
804
+ * Fired when data of a participant has been updated.
805
+ *
806
+ * Parameters:
807
+ * 1. object `data` - info object provided with the event. It has the following properties:
808
+ * * {@link Participant} `participant` - participant that has received the update
809
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for update
810
+ * @event
811
+ */
812
+ Conversation.participantUpdated = 'participantUpdated';
813
+ /**
814
+ * Fired when a new message has been added to the conversation.
815
+ *
816
+ * Parameters:
817
+ * 1. {@link Message} `message` - message that has been added
818
+ * @event
819
+ */
820
+ Conversation.messageAdded = 'messageAdded';
821
+ /**
822
+ * Fired when message is removed from the conversation's message list.
823
+ *
824
+ * Parameters:
825
+ * 1. {@link Message} `message` - message that has been removed
826
+ * @event
827
+ */
828
+ Conversation.messageRemoved = 'messageRemoved';
829
+ /**
830
+ * Fired when data of a message has been updated.
831
+ *
832
+ * Parameters:
833
+ * 1. object `data` - info object provided with the event. It has the following properties:
834
+ * * {@link Message} `message` - message that has received the update
835
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for update
836
+ * @event
837
+ */
838
+ Conversation.messageUpdated = 'messageUpdated';
839
+ /**
840
+ * Fired when a participant has stopped typing.
841
+ *
842
+ * Parameters:
843
+ * 1. {@link Participant} `participant` - the participant that has stopped typing
844
+ * @event
845
+ */
846
+ Conversation.typingEnded = 'typingEnded';
847
+ /**
848
+ * Fired when a participant has started typing.
849
+ *
850
+ * Parameters:
851
+ * 1. {@link Participant} `participant` - the participant that has started typing
852
+ * @event
853
+ */
854
+ Conversation.typingStarted = 'typingStarted';
855
+ /**
856
+ * Fired when the data of the conversation has been updated.
857
+ *
858
+ * Parameters:
859
+ * 1. object `data` - info object provided with the event. It has the following properties:
860
+ * * {@link Conversation} `conversation` - conversation that has received the update
861
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for update
862
+ * @event
863
+ */
864
+ Conversation.updated = 'updated';
865
+ /**
866
+ * Fired when the conversation was destroyed or the currently-logged-in user has left private conversation.
867
+ *
868
+ * Parameters:
869
+ * 1. {@link Conversation} `conversation` - conversation that has been removed
870
+ * @event
871
+ */
872
+ Conversation.removed = 'removed';
873
+ tslib_es6.__decorate([
874
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, ['undefined', 'string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]),
875
+ tslib_es6.__metadata("design:type", Function),
876
+ tslib_es6.__metadata("design:paramtypes", [String, Object]),
877
+ tslib_es6.__metadata("design:returntype", Promise)
878
+ ], Conversation.prototype, "add", null);
879
+ tslib_es6.__decorate([
880
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, ['undefined', 'string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]),
881
+ tslib_es6.__metadata("design:type", Function),
882
+ tslib_es6.__metadata("design:paramtypes", [String, String, Object]),
883
+ tslib_es6.__metadata("design:returntype", Promise)
884
+ ], Conversation.prototype, "addNonChatParticipant", null);
885
+ tslib_es6.__decorate([
886
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger),
887
+ tslib_es6.__metadata("design:type", Function),
888
+ tslib_es6.__metadata("design:paramtypes", [Number]),
889
+ tslib_es6.__metadata("design:returntype", Promise)
890
+ ], Conversation.prototype, "advanceLastReadMessageIndex", null);
891
+ tslib_es6.__decorate([
892
+ declarativeTypeValidator.validateTypesAsync(['undefined', declarativeTypeValidator.nonNegativeInteger], ['undefined', declarativeTypeValidator.nonNegativeInteger], ['undefined', declarativeTypeValidator.literal('backwards', 'forward')]),
893
+ tslib_es6.__metadata("design:type", Function),
894
+ tslib_es6.__metadata("design:paramtypes", [Number, Number, String]),
895
+ tslib_es6.__metadata("design:returntype", Promise)
896
+ ], Conversation.prototype, "getMessages", null);
897
+ tslib_es6.__decorate([
898
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
899
+ tslib_es6.__metadata("design:type", Function),
900
+ tslib_es6.__metadata("design:paramtypes", [String]),
901
+ tslib_es6.__metadata("design:returntype", Promise)
902
+ ], Conversation.prototype, "getParticipantBySid", null);
903
+ tslib_es6.__decorate([
904
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
905
+ tslib_es6.__metadata("design:type", Function),
906
+ tslib_es6.__metadata("design:paramtypes", [String]),
907
+ tslib_es6.__metadata("design:returntype", Promise)
908
+ ], Conversation.prototype, "getParticipantByIdentity", null);
909
+ tslib_es6.__decorate([
910
+ declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, participant.Participant]),
911
+ tslib_es6.__metadata("design:type", Function),
912
+ tslib_es6.__metadata("design:paramtypes", [Object]),
913
+ tslib_es6.__metadata("design:returntype", Promise)
914
+ ], Conversation.prototype, "removeParticipant", null);
915
+ tslib_es6.__decorate([
916
+ declarativeTypeValidator.validateTypesAsync([
917
+ 'string',
918
+ declarativeTypeValidator.literal(null),
919
+ // Wrapping it into a custom rule is necessary because the FormData class is not available on initialization.
920
+ declarativeTypeValidator.custom((value) => [value instanceof FormData, 'an instance of FormData']),
921
+ declarativeTypeValidator.objectSchema('media options', {
922
+ contentType: declarativeTypeValidator.nonEmptyString,
923
+ media: declarativeTypeValidator.custom((value) => {
924
+ let isValid = (typeof value === 'string' && value.length > 0) || value instanceof Uint8Array || value instanceof ArrayBuffer;
925
+ if (typeof Blob === 'function') {
926
+ isValid = isValid || value instanceof Blob;
927
+ }
928
+ return [
929
+ isValid,
930
+ 'a non-empty string, an instance of Buffer or an instance of Blob'
931
+ ];
932
+ })
933
+ })
934
+ ], ['undefined', 'string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)], ['undefined', declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema('email attributes', {
935
+ subject: [declarativeTypeValidator.nonEmptyString, 'undefined']
936
+ })]),
937
+ tslib_es6.__metadata("design:type", Function),
938
+ tslib_es6.__metadata("design:paramtypes", [Object, Object, Object]),
939
+ tslib_es6.__metadata("design:returntype", Promise)
940
+ ], Conversation.prototype, "sendMessage", null);
941
+ tslib_es6.__decorate([
942
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('default', 'muted')),
943
+ tslib_es6.__metadata("design:type", Function),
944
+ tslib_es6.__metadata("design:paramtypes", [String]),
945
+ tslib_es6.__metadata("design:returntype", Promise)
946
+ ], Conversation.prototype, "setUserNotificationLevel", null);
947
+ tslib_es6.__decorate([
948
+ declarativeTypeValidator.validateTypesAsync(['string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]),
949
+ tslib_es6.__metadata("design:type", Function),
950
+ tslib_es6.__metadata("design:paramtypes", [Object]),
951
+ tslib_es6.__metadata("design:returntype", Promise)
952
+ ], Conversation.prototype, "updateAttributes", null);
953
+ tslib_es6.__decorate([
954
+ declarativeTypeValidator.validateTypesAsync(['string']),
955
+ tslib_es6.__metadata("design:type", Function),
956
+ tslib_es6.__metadata("design:paramtypes", [String]),
957
+ tslib_es6.__metadata("design:returntype", Promise)
958
+ ], Conversation.prototype, "updateFriendlyName", null);
959
+ tslib_es6.__decorate([
960
+ declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.literal(null), declarativeTypeValidator.nonNegativeInteger]),
961
+ tslib_es6.__metadata("design:type", Function),
962
+ tslib_es6.__metadata("design:paramtypes", [Number]),
963
+ tslib_es6.__metadata("design:returntype", Promise)
964
+ ], Conversation.prototype, "updateLastReadMessageIndex", null);
965
+ tslib_es6.__decorate([
966
+ declarativeTypeValidator.validateTypesAsync(['string', declarativeTypeValidator.literal(null)]),
967
+ tslib_es6.__metadata("design:type", Function),
968
+ tslib_es6.__metadata("design:paramtypes", [String]),
969
+ tslib_es6.__metadata("design:returntype", Promise)
970
+ ], Conversation.prototype, "updateUniqueName", null);
971
+
972
+ exports.Conversation = Conversation;
973
+ //# sourceMappingURL=conversation.js.map