@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.0

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 (121) hide show
  1. package/README.md +39 -29
  2. package/builds/browser.esm.js +10846 -0
  3. package/builds/browser.esm.js.map +1 -0
  4. package/builds/browser.js +2505 -479
  5. package/builds/browser.js.map +1 -1
  6. package/builds/lib.d.ts +805 -70
  7. package/builds/lib.esm.d.ts +3178 -0
  8. package/builds/lib.esm.js +10845 -0
  9. package/builds/lib.js +2505 -479
  10. package/builds/lib.js.map +1 -1
  11. package/builds/twilio-conversations.js +25853 -24412
  12. package/builds/twilio-conversations.js.map +1 -0
  13. package/builds/twilio-conversations.min.js +2 -1
  14. package/builds/twilio-conversations.min.js.map +1 -0
  15. package/dist/aggregated-delivery-receipt.js +10 -5
  16. package/dist/aggregated-delivery-receipt.js.map +1 -1
  17. package/dist/channel-metadata-client.js +187 -0
  18. package/dist/channel-metadata-client.js.map +1 -0
  19. package/dist/client.js +266 -192
  20. package/dist/client.js.map +1 -1
  21. package/dist/command-executor.js +53 -15
  22. package/dist/command-executor.js.map +1 -1
  23. package/dist/configuration.js +23 -12
  24. package/dist/configuration.js.map +1 -1
  25. package/dist/content-client.js +180 -0
  26. package/dist/content-client.js.map +1 -0
  27. package/dist/content-template.js +304 -0
  28. package/dist/content-template.js.map +1 -0
  29. package/dist/conversation.js +213 -134
  30. package/dist/conversation.js.map +1 -1
  31. package/dist/data/conversations.js +70 -50
  32. package/dist/data/conversations.js.map +1 -1
  33. package/dist/data/messages.js +40 -27
  34. package/dist/data/messages.js.map +1 -1
  35. package/dist/data/participants.js +38 -32
  36. package/dist/data/participants.js.map +1 -1
  37. package/dist/data/users.js +19 -14
  38. package/dist/data/users.js.map +1 -1
  39. package/dist/detailed-delivery-receipt.js +9 -4
  40. package/dist/detailed-delivery-receipt.js.map +1 -1
  41. package/dist/index.js +26 -41
  42. package/dist/index.js.map +1 -1
  43. package/dist/interfaces/notification-types.js +9 -4
  44. package/dist/interfaces/notification-types.js.map +1 -1
  45. package/dist/interfaces/rules.js +160 -0
  46. package/dist/interfaces/rules.js.map +1 -0
  47. package/dist/logger.js +17 -28
  48. package/dist/logger.js.map +1 -1
  49. package/dist/media.js +40 -24
  50. package/dist/media.js.map +1 -1
  51. package/dist/message-builder.js +79 -12
  52. package/dist/message-builder.js.map +1 -1
  53. package/dist/message-recipients-client.js +231 -0
  54. package/dist/message-recipients-client.js.map +1 -0
  55. package/dist/message.js +258 -92
  56. package/dist/message.js.map +1 -1
  57. package/dist/node_modules/quick-lru/index.js +261 -0
  58. package/dist/node_modules/quick-lru/index.js.map +1 -0
  59. package/dist/node_modules/tslib/tslib.es6.js +15 -5
  60. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  61. package/dist/packages/conversations/package.json.js +12 -7
  62. package/dist/packages/conversations/package.json.js.map +1 -1
  63. package/dist/participant.js +42 -38
  64. package/dist/participant.js.map +1 -1
  65. package/dist/push-notification.js +9 -4
  66. package/dist/push-notification.js.map +1 -1
  67. package/dist/rest-paginator.js +9 -4
  68. package/dist/rest-paginator.js.map +1 -1
  69. package/dist/services/network.js +11 -6
  70. package/dist/services/network.js.map +1 -1
  71. package/dist/services/typing-indicator.js +17 -11
  72. package/dist/services/typing-indicator.js.map +1 -1
  73. package/dist/unsent-message.js +14 -9
  74. package/dist/unsent-message.js.map +1 -1
  75. package/dist/user.js +40 -32
  76. package/dist/user.js.map +1 -1
  77. package/dist/util/deferred.js +9 -4
  78. package/dist/util/deferred.js.map +1 -1
  79. package/dist/util/index.js +44 -8
  80. package/dist/util/index.js.map +1 -1
  81. package/dist/{interfaces/attributes.js → utils/uuid.js} +17 -19
  82. package/dist/utils/uuid.js.map +1 -0
  83. package/package.json +21 -20
  84. package/CHANGELOG.md +0 -509
  85. package/dist/interfaces/attributes.js.map +0 -1
  86. package/docs/assets/css/main.css +0 -2660
  87. package/docs/assets/images/icons.png +0 -0
  88. package/docs/assets/images/icons@2x.png +0 -0
  89. package/docs/assets/images/widgets.png +0 -0
  90. package/docs/assets/images/widgets@2x.png +0 -0
  91. package/docs/assets/js/main.js +0 -248
  92. package/docs/assets/js/search.js +0 -1
  93. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  94. package/docs/classes/CancellablePromise.html +0 -3213
  95. package/docs/classes/Client.html +0 -4239
  96. package/docs/classes/Conversation.html +0 -4354
  97. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  98. package/docs/classes/Media.html +0 -3167
  99. package/docs/classes/Message.html +0 -3732
  100. package/docs/classes/MessageBuilder.html +0 -3277
  101. package/docs/classes/Participant.html +0 -3444
  102. package/docs/classes/PushNotification.html +0 -3130
  103. package/docs/classes/RestPaginator.html +0 -3160
  104. package/docs/classes/UnsentMessage.html +0 -3042
  105. package/docs/classes/User.html +0 -3349
  106. package/docs/index.html +0 -3509
  107. package/docs/interfaces/ClientOptions.html +0 -3034
  108. package/docs/interfaces/ConversationBindings.html +0 -3001
  109. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  110. package/docs/interfaces/ConversationLimits.html +0 -3098
  111. package/docs/interfaces/ConversationState.html +0 -3050
  112. package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
  113. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  114. package/docs/interfaces/LastMessage.html +0 -3050
  115. package/docs/interfaces/Paginator.html +0 -3141
  116. package/docs/interfaces/ParticipantBindings.html +0 -3001
  117. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  118. package/docs/interfaces/PushNotificationData.html +0 -3114
  119. package/docs/interfaces/SendEmailOptions.html +0 -3034
  120. package/docs/interfaces/SendMediaOptions.html +0 -3068
  121. package/docs/modules.html +0 -3510
@@ -126,26 +126,26 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
130
137
 
131
- Object.defineProperty(exports, '__esModule', { value: true });
132
-
133
- var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
134
- require('isomorphic-form-data');
135
- var logger = require('./logger.js');
136
- var participants = require('./data/participants.js');
137
- var participant = require('./participant.js');
138
- var messages = require('./data/messages.js');
139
- var index = require('./util/index.js');
140
- var declarativeTypeValidator = require('@twilio/declarative-type-validator');
141
- var attributes = require('./interfaces/attributes.js');
142
- var messageBuilder = require('./message-builder.js');
143
- var replayEventEmitter = require('@twilio/replay-event-emitter');
144
- var isEqual = require('lodash.isequal');
145
-
146
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
147
-
148
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
138
+ import { __decorate, __metadata } from './node_modules/tslib/tslib.es6.js';
139
+ import { Logger } from './logger.js';
140
+ import { Participants } from './data/participants.js';
141
+ import { Participant } from './participant.js';
142
+ import { Messages } from './data/messages.js';
143
+ import { parseTime, UriBuilder, parseToNumber, isEqual } from './util/index.js';
144
+ import { SyncDocument } from 'twilio-sync';
145
+ import { validateTypesAsync, nonEmptyString, nonNegativeInteger, literal, objectSchema, custom } from '@twilio/declarative-type-validator';
146
+ import { optionalJson, json } from './interfaces/rules.js';
147
+ import { MessageBuilder } from './message-builder.js';
148
+ import { ReplayEventEmitter } from '@twilio/replay-event-emitter';
149
149
 
150
150
  /**
151
151
  * Map of the fields that will be processed with update messages.
@@ -169,7 +169,7 @@ const fieldMappings = {
169
169
  * A conversation represents communication between multiple Conversations
170
170
  * clients.
171
171
  */
172
- class Conversation extends replayEventEmitter.ReplayEventEmitter {
172
+ class Conversation extends ReplayEventEmitter {
173
173
  /**
174
174
  * @param descriptor Conversation descriptor.
175
175
  * @param sid Conversation SID.
@@ -191,8 +191,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
191
191
  status: "notParticipating",
192
192
  attributes: (_a = descriptor.attributes) !== null && _a !== void 0 ? _a : {},
193
193
  createdBy: descriptor.createdBy,
194
- dateCreated: index.parseTime(descriptor.dateCreated),
195
- dateUpdated: index.parseTime(descriptor.dateUpdated),
194
+ dateCreated: parseTime(descriptor.dateCreated),
195
+ dateUpdated: parseTime(descriptor.dateUpdated),
196
196
  friendlyName: descriptor.friendlyName || null,
197
197
  lastReadMessageIndex: Number.isInteger(descriptor.lastConsumedMessageIndex)
198
198
  ? descriptor.lastConsumedMessageIndex
@@ -206,14 +206,21 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
206
206
  participants: this._links.participants,
207
207
  };
208
208
  this._participants = new Map();
209
- this._participantsEntity = new participants.Participants(this, this._participants, participantsLinks, this._configuration, this._services);
210
- this._participantsEntity.on("participantJoined", (participant) => this.emit("participantJoined", participant));
211
- this._participantsEntity.on("participantLeft", (participant) => this.emit("participantLeft", participant));
212
- this._participantsEntity.on("participantUpdated", (args) => this.emit("participantUpdated", args));
213
- this._messagesEntity = new messages.Messages(this, configuration, services);
214
- this._messagesEntity.on("messageAdded", (message) => this._onMessageAdded(message));
215
- this._messagesEntity.on("messageUpdated", (args) => this.emit("messageUpdated", args));
216
- this._messagesEntity.on("messageRemoved", (message) => this.emit("messageRemoved", message));
209
+ this._participantsEntity = new Participants(this, this._participants, // state leak
210
+ participantsLinks, this._services);
211
+ this._participantsEntity.on(Conversation.participantJoined, (participant) =>
212
+ // @todo update participants map here??
213
+ this.emit(Conversation.participantJoined, participant));
214
+ this._participantsEntity.on(Conversation.participantLeft, (participant) =>
215
+ // @todo update participants map here??
216
+ this.emit(Conversation.participantLeft, participant));
217
+ this._participantsEntity.on(Conversation.participantUpdated, (args) =>
218
+ // @todo update participants map here??
219
+ this.emit(Conversation.participantUpdated, args));
220
+ this._messagesEntity = new Messages(this, configuration, services);
221
+ this._messagesEntity.on(Conversation.messageAdded, (message) => this._onMessageAdded(message));
222
+ this._messagesEntity.on(Conversation.messageUpdated, (args) => this.emit(Conversation.messageUpdated, args));
223
+ this._messagesEntity.on(Conversation.messageRemoved, (message) => this.emit(Conversation.messageRemoved, message));
217
224
  }
218
225
  /**
219
226
  * Unique name of the conversation.
@@ -279,7 +286,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
279
286
  return (_a = this._internalState.notificationLevel) !== null && _a !== void 0 ? _a : "default";
280
287
  }
281
288
  /**
282
- * Conversation bindings. Undocumented feature (for now).
289
+ * Conversation bindings. An undocumented feature (for now).
283
290
  * @internal
284
291
  */
285
292
  get bindings() {
@@ -324,7 +331,9 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
324
331
  update.attributes = {};
325
332
  }
326
333
  try {
327
- update.dateCreated && (update.dateCreated = new Date(update.dateCreated));
334
+ if (update.dateCreated) {
335
+ update.dateCreated = new Date(update.dateCreated);
336
+ }
328
337
  }
329
338
  catch (e) {
330
339
  Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: " +
@@ -332,7 +341,9 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
332
341
  delete update.dateCreated;
333
342
  }
334
343
  try {
335
- update.dateUpdated && (update.dateUpdated = new Date(update.dateUpdated));
344
+ if (update.dateUpdated) {
345
+ update.dateUpdated = new Date(update.dateUpdated);
346
+ }
336
347
  }
337
348
  catch (e) {
338
349
  Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: " +
@@ -436,7 +447,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
436
447
  */
437
448
  async getParticipantsCount() {
438
449
  var _a;
439
- const url = new index.UriBuilder(this._configuration.links.conversations)
450
+ const url = new UriBuilder(this._configuration.links.conversations)
440
451
  .path(this.sid)
441
452
  .build();
442
453
  const response = await this._services.network.get(url);
@@ -469,14 +480,14 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
469
480
  */
470
481
  async getMessagesCount() {
471
482
  var _a;
472
- const url = new index.UriBuilder(this._configuration.links.conversations)
483
+ const url = new UriBuilder(this._configuration.links.conversations)
473
484
  .path(this.sid)
474
485
  .build();
475
486
  const response = await this._services.network.get(url);
476
487
  return (_a = response.body.messages_count) !== null && _a !== void 0 ? _a : 0;
477
488
  }
478
489
  /**
479
- * Get unread messages count for the user if they are a participant of this
490
+ * Get count of unread messages for the user if they are a participant of this
480
491
  * conversation. Rejects if the user is not a participant of the conversation.
481
492
  *
482
493
  * Use this method to obtain the number of unread messages together with
@@ -484,15 +495,22 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
484
495
  * message indices which may have gaps. See {@link Message.index} for details.
485
496
  *
486
497
  * This method is semi-realtime. This means that this data will be eventually
487
- * correct, but will also be possibly incorrect for a few seconds. The
498
+ * correct, but it will also be possibly incorrect for a few seconds. The
488
499
  * Conversations system does not provide real time events for counter values
489
500
  * changes.
490
501
  *
491
502
  * This is useful for any UI badges, but it is not recommended to build any
492
503
  * core application logic based on these counters being accurate in real time.
504
+ *
505
+ * If the read horizon is not set, this function will return null. This could mean
506
+ * that all messages in the conversation are unread, or that the read horizon system
507
+ * is not being used. How to interpret this `null` value is up to the customer application.
508
+ *
509
+ * @return Number of unread messages based on the current read horizon set for
510
+ * the user or `null` if the read horizon is not set.
493
511
  */
494
512
  async getUnreadMessagesCount() {
495
- const url = new index.UriBuilder(this._configuration.links.myConversations)
513
+ const url = new UriBuilder(this._configuration.links.myConversations)
496
514
  .path(this.sid)
497
515
  .build();
498
516
  const response = await this._services.network.get(url);
@@ -519,7 +537,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
519
537
  */
520
538
  async leave() {
521
539
  if (this._internalState.status === "joined") {
522
- await this._services.commandExecutor.mutateResource("delete", `${this._links.participants}/${this._configuration.userIdentity}`);
540
+ await this._services.commandExecutor.mutateResource("delete", `${this._links.participants}/${encodeURIComponent(this._configuration.userIdentity)}`);
523
541
  }
524
542
  return this;
525
543
  }
@@ -544,18 +562,18 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
544
562
  var _a, _b;
545
563
  if (typeof message === "string" || message === null) {
546
564
  const response = await this._messagesEntity.send(message, messageAttributes, emailOptions);
547
- return (_a = index.parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
565
+ return (_a = parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
548
566
  }
549
567
  const response = await this._messagesEntity.sendMedia(message, messageAttributes, emailOptions);
550
- return (_b = index.parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
568
+ return (_b = parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
551
569
  }
552
570
  /**
553
571
  * New interface to prepare for sending a message.
554
- * Use this instead of {@link Message.sendMessage}.
572
+ * Use this instead of {@link Conversation.sendMessage}.
555
573
  * @return A MessageBuilder to help set all message sending options.
556
574
  */
557
575
  prepareMessage() {
558
- return new messageBuilder.MessageBuilder(this.limits, this._messagesEntity);
576
+ return new MessageBuilder(this.limits, this._messagesEntity);
559
577
  }
560
578
  /**
561
579
  * Set last read message index of the conversation to the index of the last
@@ -572,7 +590,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
572
590
  }
573
591
  /**
574
592
  * Set all messages in the conversation unread.
575
- * @return Resulting unread messages count in the conversation.
593
+ * @returns New count of unread messages after this update.
576
594
  */
577
595
  async setAllMessagesUnread() {
578
596
  await this._subscribeStreams();
@@ -620,7 +638,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
620
638
  * Set the last read message index to the current read horizon.
621
639
  * @param index Message index to set as last read. If null is provided, then
622
640
  * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
623
- * @returns Resulting unread messages count in the conversation.
641
+ * @returns New count of unread messages after this update.
624
642
  */
625
643
  async updateLastReadMessageIndex(index) {
626
644
  await this._subscribeStreams();
@@ -640,10 +658,17 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
640
658
  }
641
659
  return this;
642
660
  }
661
+ /**
662
+ * Get recipients of all messages in the conversation.
663
+ * @param options Optional configuration, set pageSize to request a specific pagination page size. Page size specifies a number of messages to include in a single batch. Each message may include multiple recipients.
664
+ */
665
+ async getMessageRecipients(options) {
666
+ return await this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid, options);
667
+ }
643
668
  /**
644
669
  * Load and subscribe to this conversation and do not subscribe to its
645
670
  * participants and messages. This or _subscribeStreams will need to be called
646
- * before any events on conversation will fire.
671
+ * before any events in the conversation will fire.
647
672
  * @internal
648
673
  */
649
674
  async _subscribe() {
@@ -656,8 +681,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
656
681
  });
657
682
  try {
658
683
  this._entity = await this._entityPromise;
659
- this._entity.on("updated", (args) => this._update(args.data));
660
- this._entity.on("removed", () => this.emit("removed", this));
684
+ this._entity.on(SyncDocument.updated, (args) => this._update(args.data));
685
+ this._entity.on(SyncDocument.removed, () => this.emit(Conversation.removed, this));
661
686
  this._update(this._entity.data);
662
687
  return this._entity;
663
688
  }
@@ -671,6 +696,60 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
671
696
  throw err;
672
697
  }
673
698
  }
699
+ /**
700
+ * Fetch participants and messages of the conversation. This method needs to
701
+ * be called during conversation initialization to catch broken conversations
702
+ * (broken conversations are conversations that have essential Sync entities
703
+ * missing, i.e. the conversation document, the messages list or the
704
+ * participant map). In case of this conversation being broken, the method
705
+ * will throw an exception that will be caught and handled gracefully.
706
+ * @internal
707
+ */
708
+ async _fetchStreams() {
709
+ if (this._streamsPromise) {
710
+ return this._streamsPromise;
711
+ }
712
+ this._streamsPromise = new Promise(async (resolve, reject) => {
713
+ var _a, _b;
714
+ try {
715
+ await this._subscribe();
716
+ }
717
+ catch (err) {
718
+ Conversation._logger.trace("Failed to subscribe to conversation", err);
719
+ return reject(err);
720
+ }
721
+ Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_a = this._entity) === null || _a === void 0 ? void 0 : _a.data);
722
+ const data = (_b = this._entity) === null || _b === void 0 ? void 0 : _b.data;
723
+ const messagesPromise = this._services.syncClient
724
+ .list({
725
+ id: data.messages,
726
+ mode: "open_existing",
727
+ })
728
+ .then((list) => {
729
+ this._messagesList = list;
730
+ return list;
731
+ });
732
+ const participantsPromise = this._services.syncClient
733
+ .map({
734
+ id: data.roster,
735
+ mode: "open_existing",
736
+ })
737
+ .then((map) => {
738
+ this._participantsMap = map;
739
+ return map;
740
+ });
741
+ Promise.all([messagesPromise, participantsPromise])
742
+ .then(() => resolve(true))
743
+ .catch((err) => {
744
+ Conversation._logger.trace("Failed to fetch conversation streams for conversation", this.sid, err);
745
+ reject(err);
746
+ });
747
+ });
748
+ return this._streamsPromise.catch((err) => {
749
+ this._streamsPromise = null;
750
+ throw err;
751
+ });
752
+ }
674
753
  /**
675
754
  * Load the attributes of this conversation and instantiate its participants
676
755
  * and messages. This or _subscribe will need to be called before any events
@@ -679,16 +758,16 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
679
758
  * @internal
680
759
  */
681
760
  async _subscribeStreams() {
682
- var _a, _b;
761
+ var _a, _b, _c, _d;
683
762
  try {
684
- await this._subscribe();
763
+ await this._fetchStreams();
685
764
  Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_a = this._entity) === null || _a === void 0 ? void 0 : _a.data);
686
765
  const data = (_b = this._entity) === null || _b === void 0 ? void 0 : _b.data;
687
766
  const messagesObjectName = data.messages;
688
767
  const rosterObjectName = data.roster;
689
768
  await Promise.all([
690
- this._messagesEntity.subscribe(messagesObjectName),
691
- this._participantsEntity.subscribe(rosterObjectName),
769
+ this._messagesEntity.subscribe((_c = this._messagesList) !== null && _c !== void 0 ? _c : messagesObjectName),
770
+ this._participantsEntity.subscribe((_d = this._participantsMap) !== null && _d !== void 0 ? _d : rosterObjectName),
692
771
  ]);
693
772
  }
694
773
  catch (err) {
@@ -705,7 +784,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
705
784
  */
706
785
  async _unsubscribe() {
707
786
  if (this._entity) {
708
- await this._entity.close();
787
+ this._entity.close();
709
788
  this._entity = null;
710
789
  this._entityPromise = null;
711
790
  }
@@ -767,7 +846,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
767
846
  updateReasons.add(localKey);
768
847
  break;
769
848
  case fieldMappings.attributes:
770
- if (isEqual__default["default"](this._internalState.attributes, update.attributes)) {
849
+ if (isEqual(this._internalState.attributes, update.attributes)) {
771
850
  break;
772
851
  }
773
852
  this._internalState.attributes = update.attributes;
@@ -803,7 +882,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
803
882
  update.lastMessage.timestamp;
804
883
  updateReasons.add(localKey);
805
884
  }
806
- if (isEqual__default["default"](this._internalState.lastMessage, {})) {
885
+ if (isEqual(this._internalState.lastMessage, {})) {
807
886
  delete this._internalState.lastMessage;
808
887
  }
809
888
  break;
@@ -812,14 +891,14 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
812
891
  if (state !== undefined) {
813
892
  state.dateUpdated = new Date(state.dateUpdated);
814
893
  }
815
- if (isEqual__default["default"](this._internalState.state, state)) {
894
+ if (isEqual(this._internalState.state, state)) {
816
895
  break;
817
896
  }
818
897
  this._internalState.state = state;
819
898
  updateReasons.add(localKey);
820
899
  break;
821
900
  case fieldMappings.bindings:
822
- if (isEqual__default["default"](this._internalState.bindings, update.bindings)) {
901
+ if (isEqual(this._internalState.bindings, update.bindings)) {
823
902
  break;
824
903
  }
825
904
  this._internalState.bindings = update.bindings;
@@ -838,7 +917,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
838
917
  }
839
918
  }
840
919
  if (updateReasons.size > 0) {
841
- this.emit("updated", {
920
+ this.emit(Conversation.updated, {
842
921
  conversation: this,
843
922
  updateReasons: [...updateReasons],
844
923
  });
@@ -854,7 +933,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
854
933
  break;
855
934
  }
856
935
  }
857
- this.emit("messageAdded", message);
936
+ this.emit(Conversation.messageAdded, message);
858
937
  }
859
938
  /**
860
939
  * Set last read message index.
@@ -969,57 +1048,57 @@ Conversation.removed = "removed";
969
1048
  /**
970
1049
  * Logger instance.
971
1050
  */
972
- Conversation._logger = logger.Logger.scope("Conversation");
973
- tslib_es6.__decorate([
974
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, attributes.optionalAttributesValidator),
975
- tslib_es6.__metadata("design:type", Function),
976
- tslib_es6.__metadata("design:paramtypes", [String, Object]),
977
- tslib_es6.__metadata("design:returntype", Promise)
1051
+ Conversation._logger = Logger.scope("Conversation");
1052
+ __decorate([
1053
+ validateTypesAsync(nonEmptyString, optionalJson),
1054
+ __metadata("design:type", Function),
1055
+ __metadata("design:paramtypes", [String, Object]),
1056
+ __metadata("design:returntype", Promise)
978
1057
  ], Conversation.prototype, "add", null);
979
- tslib_es6.__decorate([
980
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, attributes.optionalAttributesValidator),
981
- tslib_es6.__metadata("design:type", Function),
982
- tslib_es6.__metadata("design:paramtypes", [String, String, Object, Object]),
983
- tslib_es6.__metadata("design:returntype", Promise)
1058
+ __decorate([
1059
+ validateTypesAsync(nonEmptyString, nonEmptyString, optionalJson, optionalJson),
1060
+ __metadata("design:type", Function),
1061
+ __metadata("design:paramtypes", [String, String, Object, Object]),
1062
+ __metadata("design:returntype", Promise)
984
1063
  ], Conversation.prototype, "addNonChatParticipant", null);
985
- tslib_es6.__decorate([
986
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger),
987
- tslib_es6.__metadata("design:type", Function),
988
- tslib_es6.__metadata("design:paramtypes", [Number]),
989
- tslib_es6.__metadata("design:returntype", Promise)
1064
+ __decorate([
1065
+ validateTypesAsync(nonNegativeInteger),
1066
+ __metadata("design:type", Function),
1067
+ __metadata("design:paramtypes", [Number]),
1068
+ __metadata("design:returntype", Promise)
990
1069
  ], Conversation.prototype, "advanceLastReadMessageIndex", null);
991
- tslib_es6.__decorate([
992
- declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.literal("backwards", "forward")]),
993
- tslib_es6.__metadata("design:type", Function),
994
- tslib_es6.__metadata("design:paramtypes", [Number, Number, String]),
995
- tslib_es6.__metadata("design:returntype", Promise)
1070
+ __decorate([
1071
+ validateTypesAsync(["undefined", nonNegativeInteger], ["undefined", nonNegativeInteger], ["undefined", literal("backwards", "forward")]),
1072
+ __metadata("design:type", Function),
1073
+ __metadata("design:paramtypes", [Number, Number, String]),
1074
+ __metadata("design:returntype", Promise)
996
1075
  ], Conversation.prototype, "getMessages", null);
997
- tslib_es6.__decorate([
998
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
999
- tslib_es6.__metadata("design:type", Function),
1000
- tslib_es6.__metadata("design:paramtypes", [String]),
1001
- tslib_es6.__metadata("design:returntype", Promise)
1076
+ __decorate([
1077
+ validateTypesAsync(nonEmptyString),
1078
+ __metadata("design:type", Function),
1079
+ __metadata("design:paramtypes", [String]),
1080
+ __metadata("design:returntype", Promise)
1002
1081
  ], Conversation.prototype, "getParticipantBySid", null);
1003
- tslib_es6.__decorate([
1004
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1005
- tslib_es6.__metadata("design:type", Function),
1006
- tslib_es6.__metadata("design:paramtypes", [String]),
1007
- tslib_es6.__metadata("design:returntype", Promise)
1082
+ __decorate([
1083
+ validateTypesAsync(nonEmptyString),
1084
+ __metadata("design:type", Function),
1085
+ __metadata("design:paramtypes", [String]),
1086
+ __metadata("design:returntype", Promise)
1008
1087
  ], Conversation.prototype, "getParticipantByIdentity", null);
1009
- tslib_es6.__decorate([
1010
- declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, participant.Participant]),
1011
- tslib_es6.__metadata("design:type", Function),
1012
- tslib_es6.__metadata("design:paramtypes", [Object]),
1013
- tslib_es6.__metadata("design:returntype", Promise)
1088
+ __decorate([
1089
+ validateTypesAsync([nonEmptyString, Participant]),
1090
+ __metadata("design:type", Function),
1091
+ __metadata("design:paramtypes", [Object]),
1092
+ __metadata("design:returntype", Promise)
1014
1093
  ], Conversation.prototype, "removeParticipant", null);
1015
- tslib_es6.__decorate([
1016
- declarativeTypeValidator.validateTypesAsync([
1094
+ __decorate([
1095
+ validateTypesAsync([
1017
1096
  "string",
1018
1097
  FormData,
1019
- declarativeTypeValidator.literal(null),
1020
- declarativeTypeValidator.objectSchema("media options", {
1021
- contentType: declarativeTypeValidator.nonEmptyString,
1022
- media: declarativeTypeValidator.custom((value) => {
1098
+ literal(null),
1099
+ objectSchema("media options", {
1100
+ contentType: nonEmptyString,
1101
+ media: custom((value) => {
1023
1102
  let isValid = (typeof value === "string" && value.length > 0) ||
1024
1103
  value instanceof Uint8Array ||
1025
1104
  value instanceof ArrayBuffer;
@@ -1032,47 +1111,47 @@ tslib_es6.__decorate([
1032
1111
  ];
1033
1112
  }),
1034
1113
  }),
1035
- ], attributes.optionalAttributesValidator, [
1114
+ ], optionalJson, [
1036
1115
  "undefined",
1037
- declarativeTypeValidator.literal(null),
1038
- declarativeTypeValidator.objectSchema("email attributes", {
1039
- subject: [declarativeTypeValidator.nonEmptyString, "undefined"],
1116
+ literal(null),
1117
+ objectSchema("email attributes", {
1118
+ subject: [nonEmptyString, "undefined"],
1040
1119
  }),
1041
1120
  ]),
1042
- tslib_es6.__metadata("design:type", Function),
1043
- tslib_es6.__metadata("design:paramtypes", [Object, Object, Object]),
1044
- tslib_es6.__metadata("design:returntype", Promise)
1121
+ __metadata("design:type", Function),
1122
+ __metadata("design:paramtypes", [Object, Object, Object]),
1123
+ __metadata("design:returntype", Promise)
1045
1124
  ], Conversation.prototype, "sendMessage", null);
1046
- tslib_es6.__decorate([
1047
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")),
1048
- tslib_es6.__metadata("design:type", Function),
1049
- tslib_es6.__metadata("design:paramtypes", [String]),
1050
- tslib_es6.__metadata("design:returntype", Promise)
1125
+ __decorate([
1126
+ validateTypesAsync(literal("default", "muted")),
1127
+ __metadata("design:type", Function),
1128
+ __metadata("design:paramtypes", [String]),
1129
+ __metadata("design:returntype", Promise)
1051
1130
  ], Conversation.prototype, "setUserNotificationLevel", null);
1052
- tslib_es6.__decorate([
1053
- declarativeTypeValidator.validateTypesAsync(attributes.attributesValidator),
1054
- tslib_es6.__metadata("design:type", Function),
1055
- tslib_es6.__metadata("design:paramtypes", [Object]),
1056
- tslib_es6.__metadata("design:returntype", Promise)
1131
+ __decorate([
1132
+ validateTypesAsync(json),
1133
+ __metadata("design:type", Function),
1134
+ __metadata("design:paramtypes", [Object]),
1135
+ __metadata("design:returntype", Promise)
1057
1136
  ], Conversation.prototype, "updateAttributes", null);
1058
- tslib_es6.__decorate([
1059
- declarativeTypeValidator.validateTypesAsync("string"),
1060
- tslib_es6.__metadata("design:type", Function),
1061
- tslib_es6.__metadata("design:paramtypes", [String]),
1062
- tslib_es6.__metadata("design:returntype", Promise)
1137
+ __decorate([
1138
+ validateTypesAsync("string"),
1139
+ __metadata("design:type", Function),
1140
+ __metadata("design:paramtypes", [String]),
1141
+ __metadata("design:returntype", Promise)
1063
1142
  ], Conversation.prototype, "updateFriendlyName", null);
1064
- tslib_es6.__decorate([
1065
- declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.literal(null), declarativeTypeValidator.nonNegativeInteger]),
1066
- tslib_es6.__metadata("design:type", Function),
1067
- tslib_es6.__metadata("design:paramtypes", [Number]),
1068
- tslib_es6.__metadata("design:returntype", Promise)
1143
+ __decorate([
1144
+ validateTypesAsync([literal(null), nonNegativeInteger]),
1145
+ __metadata("design:type", Function),
1146
+ __metadata("design:paramtypes", [Number]),
1147
+ __metadata("design:returntype", Promise)
1069
1148
  ], Conversation.prototype, "updateLastReadMessageIndex", null);
1070
- tslib_es6.__decorate([
1071
- declarativeTypeValidator.validateTypesAsync(["string", declarativeTypeValidator.literal(null)]),
1072
- tslib_es6.__metadata("design:type", Function),
1073
- tslib_es6.__metadata("design:paramtypes", [String]),
1074
- tslib_es6.__metadata("design:returntype", Promise)
1149
+ __decorate([
1150
+ validateTypesAsync(["string", literal(null)]),
1151
+ __metadata("design:type", Function),
1152
+ __metadata("design:paramtypes", [String]),
1153
+ __metadata("design:returntype", Promise)
1075
1154
  ], Conversation.prototype, "updateUniqueName", null);
1076
1155
 
1077
- exports.Conversation = Conversation;
1156
+ export { Conversation };
1078
1157
  //# sourceMappingURL=conversation.js.map