@twilio/conversations 2.0.1-rc.9 → 2.1.0-rc.5

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 (88) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/NOTICE.txt +679 -0
  3. package/builds/browser.js +892 -619
  4. package/builds/browser.js.map +1 -1
  5. package/builds/lib.d.ts +371 -124
  6. package/builds/lib.js +892 -619
  7. package/builds/lib.js.map +1 -1
  8. package/builds/twilio-conversations.js +1067 -939
  9. package/builds/twilio-conversations.min.js +2 -14
  10. package/dist/aggregated-delivery-receipt.js +6 -1
  11. package/dist/aggregated-delivery-receipt.js.map +1 -1
  12. package/dist/client.js +165 -142
  13. package/dist/client.js.map +1 -1
  14. package/dist/command-executor.js +16 -14
  15. package/dist/command-executor.js.map +1 -1
  16. package/dist/configuration.js +14 -10
  17. package/dist/configuration.js.map +1 -1
  18. package/dist/conversation.js +232 -159
  19. package/dist/conversation.js.map +1 -1
  20. package/dist/data/conversations.js +82 -78
  21. package/dist/data/conversations.js.map +1 -1
  22. package/dist/data/messages.js +43 -39
  23. package/dist/data/messages.js.map +1 -1
  24. package/dist/data/participants.js +100 -78
  25. package/dist/data/participants.js.map +1 -1
  26. package/dist/data/users.js +24 -22
  27. package/dist/data/users.js.map +1 -1
  28. package/dist/detailed-delivery-receipt.js +1 -1
  29. package/dist/detailed-delivery-receipt.js.map +1 -1
  30. package/dist/index.js +1 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/interfaces/attributes.js +147 -0
  33. package/dist/interfaces/attributes.js.map +1 -0
  34. package/dist/interfaces/notification-types.js +5 -5
  35. package/dist/interfaces/notification-types.js.map +1 -1
  36. package/dist/logger.js +36 -15
  37. package/dist/logger.js.map +1 -1
  38. package/dist/media.js +21 -9
  39. package/dist/media.js.map +1 -1
  40. package/dist/message-builder.js +56 -3
  41. package/dist/message-builder.js.map +1 -1
  42. package/dist/message.js +158 -78
  43. package/dist/message.js.map +1 -1
  44. package/dist/packages/conversations/package.json.js +1 -1
  45. package/dist/participant.js +101 -50
  46. package/dist/participant.js.map +1 -1
  47. package/dist/push-notification.js.map +1 -1
  48. package/dist/rest-paginator.js +16 -6
  49. package/dist/rest-paginator.js.map +1 -1
  50. package/dist/services/network.js +18 -14
  51. package/dist/services/network.js.map +1 -1
  52. package/dist/services/typing-indicator.js +20 -17
  53. package/dist/services/typing-indicator.js.map +1 -1
  54. package/dist/unsent-message.js.map +1 -1
  55. package/dist/user.js +87 -60
  56. package/dist/user.js.map +1 -1
  57. package/dist/util/deferred.js +3 -1
  58. package/dist/util/deferred.js.map +1 -1
  59. package/dist/util/index.js +6 -6
  60. package/dist/util/index.js.map +1 -1
  61. package/docs/assets/js/search.js +1 -1
  62. package/docs/classes/AggregatedDeliveryReceipt.html +15 -0
  63. package/docs/classes/Client.html +39 -30
  64. package/docs/classes/Conversation.html +52 -30
  65. package/docs/classes/DetailedDeliveryReceipt.html +16 -1
  66. package/docs/classes/Media.html +15 -0
  67. package/docs/classes/Message.html +88 -7
  68. package/docs/classes/MessageBuilder.html +93 -2
  69. package/docs/classes/Participant.html +52 -8
  70. package/docs/classes/PushNotification.html +15 -0
  71. package/docs/classes/RestPaginator.html +15 -0
  72. package/docs/classes/UnsentMessage.html +15 -0
  73. package/docs/classes/User.html +22 -7
  74. package/docs/index.html +37 -3
  75. package/docs/interfaces/ClientOptions.html +15 -0
  76. package/docs/interfaces/ConversationBindings.html +3118 -0
  77. package/docs/interfaces/ConversationEmailBinding.html +3118 -0
  78. package/docs/interfaces/ConversationState.html +15 -0
  79. package/docs/interfaces/CreateConversationOptions.html +16 -1
  80. package/docs/interfaces/LastMessage.html +15 -0
  81. package/docs/interfaces/Paginator.html +15 -0
  82. package/docs/interfaces/ParticipantBindings.html +3118 -0
  83. package/docs/interfaces/ParticipantEmailBinding.html +3118 -0
  84. package/docs/interfaces/PushNotificationData.html +15 -0
  85. package/docs/interfaces/SendEmailOptions.html +15 -0
  86. package/docs/interfaces/SendMediaOptions.html +15 -0
  87. package/docs/modules.html +37 -3
  88. package/package.json +24 -18
package/builds/lib.js CHANGED
@@ -130,6 +130,7 @@ This software includes platform.js under the following license.
130
130
 
131
131
  Object.defineProperty(exports, '__esModule', { value: true });
132
132
 
133
+ require('isomorphic-form-data');
133
134
  require('core-js/modules/es.reflect.construct.js');
134
135
  require('core-js/modules/es.object.keys.js');
135
136
  require('core-js/modules/es.symbol.js');
@@ -162,6 +163,7 @@ require('core-js/modules/es.regexp.exec.js');
162
163
  require('core-js/modules/es.string.replace.js');
163
164
  require('core-js/modules/es.array.join.js');
164
165
  var declarativeTypeValidator = require('@twilio/declarative-type-validator');
166
+ require('core-js/modules/es.array.includes.js');
165
167
  var replayEventEmitter = require('@twilio/replay-event-emitter');
166
168
  var isEqual = require('lodash.isequal');
167
169
  require('core-js/modules/es.array.slice.js');
@@ -177,7 +179,6 @@ var twilioSync = require('twilio-sync');
177
179
  var mcsClient = require('@twilio/mcs-client');
178
180
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
179
181
  require('core-js/modules/es.set.js');
180
- require('core-js/modules/es.array.includes.js');
181
182
  require('core-js/modules/es.number.is-integer.js');
182
183
  require('core-js/modules/es.typed-array.uint8-array.js');
183
184
  require('core-js/modules/es.typed-array.copy-within.js');
@@ -265,15 +266,15 @@ function prepareLine(prefix, args) {
265
266
  return ["".concat(new Date().toISOString(), " Conversations ").concat(prefix, ":")].concat(Array.from(args));
266
267
  }
267
268
 
268
- var log$9 = loglevelLog__namespace.getLogger('twilio-conversations'); // twilio-conversations is used by Flex SDK. Please DO NOT change
269
+ var log$9 = loglevelLog__namespace.getLogger("twilio-conversations"); // twilio-conversations is used by Flex SDK. Please DO NOT change
269
270
 
270
271
  var Logger = /*#__PURE__*/function () {
271
272
  function Logger(prefix) {
272
273
  _classCallCheck__default['default'](this, Logger);
273
274
 
274
- _defineProperty__default['default'](this, "prefix", '');
275
+ _defineProperty__default['default'](this, "prefix", "");
275
276
 
276
- this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0 ? prefix + ' ' : '';
277
+ this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0 ? prefix + " " : "";
277
278
  }
278
279
 
279
280
  _createClass__default['default'](Logger, [{
@@ -288,7 +289,7 @@ var Logger = /*#__PURE__*/function () {
288
289
  args[_key] = arguments[_key];
289
290
  }
290
291
 
291
- log$9.trace.apply(null, prepareLine(this.prefix + 'T', args));
292
+ log$9.trace.apply(null, prepareLine(this.prefix + "T", args));
292
293
  }
293
294
  }, {
294
295
  key: "debug",
@@ -297,7 +298,7 @@ var Logger = /*#__PURE__*/function () {
297
298
  args[_key2] = arguments[_key2];
298
299
  }
299
300
 
300
- log$9.debug.apply(null, prepareLine(this.prefix + 'D', args));
301
+ log$9.debug.apply(null, prepareLine(this.prefix + "D", args));
301
302
  }
302
303
  }, {
303
304
  key: "info",
@@ -306,7 +307,7 @@ var Logger = /*#__PURE__*/function () {
306
307
  args[_key3] = arguments[_key3];
307
308
  }
308
309
 
309
- log$9.info.apply(null, prepareLine(this.prefix + 'I', args));
310
+ log$9.info.apply(null, prepareLine(this.prefix + "I", args));
310
311
  }
311
312
  }, {
312
313
  key: "warn",
@@ -315,7 +316,7 @@ var Logger = /*#__PURE__*/function () {
315
316
  args[_key4] = arguments[_key4];
316
317
  }
317
318
 
318
- log$9.warn.apply(null, prepareLine(this.prefix + 'W', args));
319
+ log$9.warn.apply(null, prepareLine(this.prefix + "W", args));
319
320
  }
320
321
  }, {
321
322
  key: "error",
@@ -324,7 +325,7 @@ var Logger = /*#__PURE__*/function () {
324
325
  args[_key5] = arguments[_key5];
325
326
  }
326
327
 
327
- log$9.error.apply(null, prepareLine(this.prefix + 'E', args));
328
+ log$9.error.apply(null, prepareLine(this.prefix + "E", args));
328
329
  }
329
330
  }], [{
330
331
  key: "scope",
@@ -343,7 +344,7 @@ var Logger = /*#__PURE__*/function () {
343
344
  args[_key6] = arguments[_key6];
344
345
  }
345
346
 
346
- log$9.trace.apply(null, prepareLine('T', args));
347
+ log$9.trace.apply(null, prepareLine("T", args));
347
348
  }
348
349
  }, {
349
350
  key: "debug",
@@ -352,7 +353,7 @@ var Logger = /*#__PURE__*/function () {
352
353
  args[_key7] = arguments[_key7];
353
354
  }
354
355
 
355
- log$9.debug.apply(null, prepareLine('D', args));
356
+ log$9.debug.apply(null, prepareLine("D", args));
356
357
  }
357
358
  }, {
358
359
  key: "info",
@@ -361,7 +362,7 @@ var Logger = /*#__PURE__*/function () {
361
362
  args[_key8] = arguments[_key8];
362
363
  }
363
364
 
364
- log$9.info.apply(null, prepareLine('I', args));
365
+ log$9.info.apply(null, prepareLine("I", args));
365
366
  }
366
367
  }, {
367
368
  key: "warn",
@@ -370,7 +371,7 @@ var Logger = /*#__PURE__*/function () {
370
371
  args[_key9] = arguments[_key9];
371
372
  }
372
373
 
373
- log$9.warn.apply(null, prepareLine('W', args));
374
+ log$9.warn.apply(null, prepareLine("W", args));
374
375
  }
375
376
  }, {
376
377
  key: "error",
@@ -379,7 +380,7 @@ var Logger = /*#__PURE__*/function () {
379
380
  args[_key10] = arguments[_key10];
380
381
  }
381
382
 
382
- log$9.error.apply(null, prepareLine('E', args));
383
+ log$9.error.apply(null, prepareLine("E", args));
383
384
  }
384
385
  }]);
385
386
 
@@ -390,8 +391,8 @@ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if
390
391
 
391
392
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
392
393
  var TYPING_TIMEOUT = 5;
393
- var HTTP_CACHE_LIFETIME = 'PT5S';
394
- var CONSUMPTION_HORIZON_SENDING_INTERVAL = 'PT5S';
394
+ var HTTP_CACHE_LIFETIME = "PT5S";
395
+ var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
395
396
  var USER_INFOS_TO_SUBSCRIBE = 100;
396
397
  var MINIMUM_RETRY_DELAY = 1000;
397
398
  var MAXIMUM_RETRY_DELAY = 4000;
@@ -470,7 +471,7 @@ function deepClone(obj) {
470
471
  }
471
472
 
472
473
  function parseToNumber(value) {
473
- if (typeof value !== 'undefined' && !isNaN(Number(value))) {
474
+ if (typeof value !== "undefined" && !isNaN(Number(value))) {
474
475
  return Number(value);
475
476
  }
476
477
 
@@ -509,7 +510,7 @@ var UriBuilder = /*#__PURE__*/function () {
509
510
  function UriBuilder(base) {
510
511
  _classCallCheck__default['default'](this, UriBuilder);
511
512
 
512
- this.base = base.replace(/\/$/, '');
513
+ this.base = base.replace(/\/$/, "");
513
514
  this.args = [];
514
515
  this.paths = [];
515
516
  }
@@ -517,8 +518,8 @@ var UriBuilder = /*#__PURE__*/function () {
517
518
  _createClass__default['default'](UriBuilder, [{
518
519
  key: "arg",
519
520
  value: function arg(name, value) {
520
- if (typeof value !== 'undefined') {
521
- this.args.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
521
+ if (typeof value !== "undefined") {
522
+ this.args.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
522
523
  }
523
524
 
524
525
  return this;
@@ -535,11 +536,11 @@ var UriBuilder = /*#__PURE__*/function () {
535
536
  var result = this.base;
536
537
 
537
538
  if (this.paths.length) {
538
- result += '/' + this.paths.join('/');
539
+ result += "/" + this.paths.join("/");
539
540
  }
540
541
 
541
542
  if (this.args.length) {
542
- result += '?' + this.args.join('&');
543
+ result += "?" + this.args.join("&");
543
544
  }
544
545
 
545
546
  return result;
@@ -549,10 +550,17 @@ var UriBuilder = /*#__PURE__*/function () {
549
550
  return UriBuilder;
550
551
  }();
551
552
 
553
+ var attributesValidator = declarativeTypeValidator.custom(function (value) {
554
+ return [["string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "a JSON type"];
555
+ });
556
+ var optionalAttributesValidator = declarativeTypeValidator.custom(function (value) {
557
+ return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "an optional JSON type"];
558
+ });
559
+
552
560
  function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
553
561
 
554
562
  function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
555
- var log$8 = Logger.scope('User');
563
+ var log$8 = Logger.scope("User");
556
564
  /**
557
565
  * Extended user information.
558
566
  * Note that `isOnline` and `isNotifiable` properties are eligible
@@ -577,14 +585,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
577
585
 
578
586
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "promiseToFetch", null);
579
587
 
580
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated", 'updated');
588
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated", "updated");
581
589
 
582
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed", 'userSubscribed');
590
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed", "userSubscribed");
583
591
 
584
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed", 'userUnsubscribed');
592
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed", "userUnsubscribed");
585
593
 
586
594
  _this.services = services;
587
- _this.subscribed = 'initializing';
595
+ _this.subscribed = "initializing";
588
596
 
589
597
  _this.setMaxListeners(0);
590
598
 
@@ -677,7 +685,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
677
685
  }, {
678
686
  key: "isSubscribed",
679
687
  get: function get() {
680
- return this.subscribed == 'subscribed';
688
+ return this.subscribed == "subscribed";
681
689
  } // Handles service updates
682
690
 
683
691
  }, {
@@ -694,14 +702,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
694
702
 
695
703
  case 2:
696
704
  updateReasons = [];
697
- log$8.debug('User for', this.state.identity, 'updated:', key, value);
705
+ log$8.debug("User for", this.state.identity, "updated:", key, value);
698
706
  _context.t0 = key;
699
- _context.next = _context.t0 === 'friendlyName' ? 7 : _context.t0 === 'attributes' ? 9 : _context.t0 === 'reachability' ? 12 : 15;
707
+ _context.next = _context.t0 === "friendlyName" ? 7 : _context.t0 === "attributes" ? 9 : _context.t0 === "reachability" ? 12 : 15;
700
708
  break;
701
709
 
702
710
  case 7:
703
711
  if (this.state.friendlyName !== value.value) {
704
- updateReasons.push('friendlyName');
712
+ updateReasons.push("friendlyName");
705
713
  this.state.friendlyName = value.value;
706
714
  }
707
715
 
@@ -712,7 +720,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
712
720
 
713
721
  if (!isEqual__default['default'](this.state.attributes, updateAttributes)) {
714
722
  this.state.attributes = updateAttributes;
715
- updateReasons.push('attributes');
723
+ updateReasons.push("attributes");
716
724
  }
717
725
 
718
726
  return _context.abrupt("break", 16);
@@ -720,12 +728,12 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
720
728
  case 12:
721
729
  if (this.state.online !== value.online) {
722
730
  this.state.online = value.online;
723
- updateReasons.push('reachabilityOnline');
731
+ updateReasons.push("reachabilityOnline");
724
732
  }
725
733
 
726
734
  if (this.state.notifiable !== value.notifiable) {
727
735
  this.state.notifiable = value.notifiable;
728
- updateReasons.push('reachabilityNotifiable');
736
+ updateReasons.push("reachabilityNotifiable");
729
737
  }
730
738
 
731
739
  return _context.abrupt("break", 16);
@@ -735,7 +743,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
735
743
 
736
744
  case 16:
737
745
  if (updateReasons.length > 0) {
738
- this.emit('updated', {
746
+ this.emit("updated", {
739
747
  user: this,
740
748
  updateReasons: updateReasons
741
749
  });
@@ -778,8 +786,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
778
786
  return _context2.abrupt("return", Promise.resolve());
779
787
 
780
788
  case 4:
781
- return _context2.abrupt("return", map.get('reachability').then(update).catch(function (err) {
782
- log$8.warn('Failed to get reachability info for ', _this2.state.identity, err);
789
+ return _context2.abrupt("return", map.get("reachability").then(update).catch(function (err) {
790
+ log$8.warn("Failed to get reachability info for ", _this2.state.identity, err);
783
791
  }));
784
792
 
785
793
  case 5:
@@ -821,26 +829,26 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
821
829
  case 4:
822
830
  this.promiseToFetch = this.services.syncClient.map({
823
831
  id: this.state.entityName,
824
- mode: 'open_existing',
832
+ mode: "open_existing",
825
833
  includeItems: true
826
834
  }).then(function (map) {
827
835
  _this3.entity = map;
828
- map.on('itemUpdated', function (args) {
829
- log$8.debug(_this3.state.entityName + ' (' + _this3.state.identity + ') itemUpdated: ' + args.item.key);
836
+ map.on("itemUpdated", function (args) {
837
+ log$8.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemUpdated: " + args.item.key);
830
838
  return _this3._update(args.item.key, args.item.data);
831
839
  });
832
- return Promise.all([map.get('friendlyName').then(function (item) {
840
+ return Promise.all([map.get("friendlyName").then(function (item) {
833
841
  return _this3._update(item.key, item.data);
834
- }), map.get('attributes').then(function (item) {
842
+ }), map.get("attributes").then(function (item) {
835
843
  return _this3._update(item.key, item.data);
836
844
  }), _this3._updateReachabilityInfo(map, function (item) {
837
845
  return _this3._update(item.key, item.data);
838
846
  })]);
839
847
  }).then(function () {
840
- log$8.debug('Fetched for', _this3.identity);
841
- _this3.subscribed = 'subscribed';
848
+ log$8.debug("Fetched for", _this3.identity);
849
+ _this3.subscribed = "subscribed";
842
850
 
843
- _this3.emit('userSubscribed', _this3);
851
+ _this3.emit("userSubscribed", _this3);
844
852
 
845
853
  return _this3;
846
854
  }).catch(function (err) {
@@ -908,16 +916,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
908
916
  return this._initializationPromise;
909
917
 
910
918
  case 2:
911
- if (!(this.subscribed == 'unsubscribed')) {
919
+ if (!(this.subscribed == "unsubscribed")) {
912
920
  _context5.next = 4;
913
921
  break;
914
922
  }
915
923
 
916
- throw new Error('Can\'t modify unsubscribed object');
924
+ throw new Error("Can't modify unsubscribed object");
917
925
 
918
926
  case 4:
919
927
  _context5.next = 6;
920
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
928
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
921
929
  attributes: JSON.stringify(attributes)
922
930
  });
923
931
 
@@ -955,16 +963,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
955
963
  return this._initializationPromise;
956
964
 
957
965
  case 2:
958
- if (!(this.subscribed == 'unsubscribed')) {
966
+ if (!(this.subscribed == "unsubscribed")) {
959
967
  _context6.next = 4;
960
968
  break;
961
969
  }
962
970
 
963
- throw new Error('Can\'t modify unsubscribed object');
971
+ throw new Error("Can't modify unsubscribed object");
964
972
 
965
973
  case 4:
966
974
  _context6.next = 6;
967
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
975
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
968
976
  friendly_name: friendlyName
969
977
  });
970
978
 
@@ -1013,8 +1021,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
1013
1021
  case 5:
1014
1022
  this.entity.close();
1015
1023
  this.promiseToFetch = null;
1016
- this.subscribed = 'unsubscribed';
1017
- this.emit('userUnsubscribed', this);
1024
+ this.subscribed = "unsubscribed";
1025
+ this.emit("userUnsubscribed", this);
1018
1026
 
1019
1027
  case 9:
1020
1028
  case "end":
@@ -1043,9 +1051,9 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
1043
1051
  this._resolveInitializationPromise();
1044
1052
 
1045
1053
  if (emitUpdated) {
1046
- this.emit('updated', {
1054
+ this.emit("updated", {
1047
1055
  user: this,
1048
- updateReasons: ['friendlyName', 'attributes', 'reachabilityOnline', 'reachabilityNotifiable']
1056
+ updateReasons: ["friendlyName", "attributes", "reachabilityOnline", "reachabilityNotifiable"]
1049
1057
  });
1050
1058
  }
1051
1059
  }
@@ -1054,9 +1062,9 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
1054
1062
  return User;
1055
1063
  }(replayEventEmitter.ReplayEventEmitter);
1056
1064
 
1057
- __decorate([declarativeTypeValidator.validateTypesAsync(['string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
1065
+ __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
1058
1066
 
1059
- __decorate([declarativeTypeValidator.validateTypesAsync(['string']), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
1067
+ __decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
1060
1068
 
1061
1069
  function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
1062
1070
 
@@ -1129,13 +1137,13 @@ var Network = /*#__PURE__*/function () {
1129
1137
  }
1130
1138
 
1131
1139
  var retrier = new operationRetrier.Retrier(_this2.configuration.backoffConfiguration);
1132
- retrier.on('attempt', function () {
1140
+ retrier.on("attempt", function () {
1133
1141
  request().then(function (result) {
1134
1142
  return retrier.succeeded(result);
1135
1143
  }).catch(function (err) {
1136
1144
  if (codesToRetryOn.indexOf(err.status) > -1) {
1137
1145
  retrier.failed(err);
1138
- } else if (err.message === 'Twilsock disconnected') {
1146
+ } else if (err.message === "Twilsock disconnected") {
1139
1147
  // Ugly hack. We must make a proper exceptions for twilsock
1140
1148
  retrier.failed(err);
1141
1149
  } else {
@@ -1146,13 +1154,13 @@ var Network = /*#__PURE__*/function () {
1146
1154
  }
1147
1155
  });
1148
1156
  });
1149
- retrier.on('succeeded', function (result) {
1157
+ retrier.on("succeeded", function (result) {
1150
1158
  resolve(result);
1151
1159
  });
1152
- retrier.on('cancelled', function (err) {
1160
+ retrier.on("cancelled", function (err) {
1153
1161
  return reject(err);
1154
1162
  });
1155
- retrier.on('failed', function (err) {
1163
+ retrier.on("failed", function (err) {
1156
1164
  return reject(err);
1157
1165
  });
1158
1166
  retrier.start();
@@ -1217,20 +1225,20 @@ var NotificationTypes = function NotificationTypes() {
1217
1225
  _classCallCheck__default['default'](this, NotificationTypes);
1218
1226
  };
1219
1227
 
1220
- _defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR", 'twilio.ipmsg.typing_indicator');
1228
+ _defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR", "twilio.ipmsg.typing_indicator");
1221
1229
 
1222
- _defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE", 'twilio.conversations.new_message');
1230
+ _defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE", "twilio.conversations.new_message");
1223
1231
 
1224
- _defineProperty__default['default'](NotificationTypes, "ADDED_TO_CONVERSATION", 'twilio.conversations.added_to_conversation');
1232
+ _defineProperty__default['default'](NotificationTypes, "ADDED_TO_CONVERSATION", "twilio.conversations.added_to_conversation");
1225
1233
 
1226
- _defineProperty__default['default'](NotificationTypes, "REMOVED_FROM_CONVERSATION", 'twilio.conversations.removed_from_conversation');
1234
+ _defineProperty__default['default'](NotificationTypes, "REMOVED_FROM_CONVERSATION", "twilio.conversations.removed_from_conversation");
1227
1235
 
1228
- _defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE", 'twilio.channel.consumption_update');
1236
+ _defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
1229
1237
 
1230
1238
  function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
1231
1239
 
1232
1240
  function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1233
- var log$7 = Logger.scope('Participant');
1241
+ var log$7 = Logger.scope("Participant");
1234
1242
  /**
1235
1243
  * A participant represents a remote client in a conversation.
1236
1244
  */
@@ -1244,6 +1252,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1244
1252
  * @internal
1245
1253
  */
1246
1254
  function Participant(data, sid, conversation, links, services) {
1255
+ var _data$roleSid, _data$bindings;
1256
+
1247
1257
  var _this;
1248
1258
 
1249
1259
  _classCallCheck__default['default'](this, Participant);
@@ -1253,22 +1263,23 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1253
1263
  _this.links = links;
1254
1264
  _this.services = services;
1255
1265
  _this.state = {
1256
- attributes: parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + sid, log$7),
1266
+ attributes: parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + sid, log$7),
1257
1267
  dateCreated: data.dateCreated ? parseTime$1(data.dateCreated) : null,
1258
1268
  dateUpdated: data.dateCreated ? parseTime$1(data.dateUpdated) : null,
1259
1269
  sid: sid,
1260
1270
  typingTimeout: null,
1261
1271
  isTyping: false,
1262
- identity: data.identity || null,
1263
- roleSid: data.roleSid || null,
1272
+ identity: data.identity,
1273
+ roleSid: (_data$roleSid = data.roleSid) !== null && _data$roleSid !== void 0 ? _data$roleSid : "",
1264
1274
  lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
1265
1275
  lastReadTimestamp: data.lastConsumptionTimestamp ? parseTime$1(data.lastConsumptionTimestamp) : null,
1266
- type: data.type || 'chat',
1267
- userInfo: data.userInfo
1276
+ type: data.type || "chat",
1277
+ userInfo: data.userInfo,
1278
+ bindings: (_data$bindings = data.bindings) !== null && _data$bindings !== void 0 ? _data$bindings : {}
1268
1279
  };
1269
1280
 
1270
1281
  if (!data.identity && !data.type) {
1271
- throw new Error('Received invalid Participant object from server: Missing identity or type of Participant.');
1282
+ throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");
1272
1283
  }
1273
1284
 
1274
1285
  return _this;
@@ -1367,7 +1378,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1367
1378
  return this.state.roleSid;
1368
1379
  }
1369
1380
  /**
1370
- * Message type of the participant.
1381
+ * Type of the participant.
1371
1382
  */
1372
1383
 
1373
1384
  }, {
@@ -1375,6 +1386,23 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1375
1386
  get: function get() {
1376
1387
  return this.state.type;
1377
1388
  }
1389
+ /**
1390
+ * Get the bindings mapping for the current participant.
1391
+ * Available binding depends on the participant type.
1392
+ * You could access it as `participant.bindings.sms?.address` or
1393
+ * using the type dynamically `participant.bindings[participant.type]`
1394
+ * just be aware that the binding information has different structure for
1395
+ * each participant type.
1396
+ * See also {ParticipantEmailBinding}, the only available currently binding descriptor.
1397
+ */
1398
+
1399
+ }, {
1400
+ key: "bindings",
1401
+ get: function get() {
1402
+ var _this$state$bindings;
1403
+
1404
+ return (_this$state$bindings = this.state.bindings) !== null && _this$state$bindings !== void 0 ? _this$state$bindings : {};
1405
+ }
1378
1406
  }, {
1379
1407
  key: "_startTyping",
1380
1408
  value:
@@ -1385,13 +1413,16 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1385
1413
  function _startTyping(timeout) {
1386
1414
  var _this2 = this;
1387
1415
 
1388
- clearTimeout(this.state.typingTimeout);
1416
+ if (this.state.typingTimeout) {
1417
+ clearTimeout(this.state.typingTimeout);
1418
+ }
1419
+
1389
1420
  this.state.isTyping = true;
1390
- this.emit('typingStarted', this);
1391
- this.conversation.emit('typingStarted', this);
1392
- this.state.typingTimeout = setTimeout(function () {
1421
+ this.emit("typingStarted", this);
1422
+ this.conversation.emit("typingStarted", this);
1423
+ this.state.typingTimeout = Number(setTimeout(function () {
1393
1424
  return _this2._endTyping();
1394
- }, timeout);
1425
+ }, timeout));
1395
1426
  return this;
1396
1427
  }
1397
1428
  /**
@@ -1407,8 +1438,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1407
1438
  }
1408
1439
 
1409
1440
  this.state.isTyping = false;
1410
- this.emit('typingEnded', this);
1411
- this.conversation.emit('typingEnded', this);
1441
+ this.emit("typingEnded", this);
1442
+ this.conversation.emit("typingEnded", this);
1412
1443
  clearInterval(this.state.typingTimeout);
1413
1444
  this.state.typingTimeout = null;
1414
1445
  }
@@ -1421,35 +1452,35 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1421
1452
  key: "_update",
1422
1453
  value: function _update(data) {
1423
1454
  var updateReasons = [];
1424
- var updateAttributes = parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + this.state.sid, log$7);
1455
+ var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$7);
1425
1456
 
1426
1457
  if (data.attributes && !isEqual__default['default'](this.state.attributes, updateAttributes)) {
1427
1458
  this.state.attributes = updateAttributes;
1428
- updateReasons.push('attributes');
1459
+ updateReasons.push("attributes");
1429
1460
  }
1430
1461
 
1431
1462
  var updatedDateUpdated = parseTime$1(data.dateUpdated);
1432
1463
 
1433
- if (data.dateUpdated && updatedDateUpdated.getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
1464
+ if (data.dateUpdated && (updatedDateUpdated === null || updatedDateUpdated === void 0 ? void 0 : updatedDateUpdated.getTime()) !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
1434
1465
  this.state.dateUpdated = updatedDateUpdated;
1435
- updateReasons.push('dateUpdated');
1466
+ updateReasons.push("dateUpdated");
1436
1467
  }
1437
1468
 
1438
1469
  var updatedDateCreated = parseTime$1(data.dateCreated);
1439
1470
 
1440
- if (data.dateCreated && updatedDateCreated.getTime() !== (this.state.dateCreated && this.state.dateCreated.getTime())) {
1471
+ if (data.dateCreated && (updatedDateCreated === null || updatedDateCreated === void 0 ? void 0 : updatedDateCreated.getTime()) !== (this.state.dateCreated && this.state.dateCreated.getTime())) {
1441
1472
  this.state.dateCreated = updatedDateCreated;
1442
- updateReasons.push('dateCreated');
1473
+ updateReasons.push("dateCreated");
1443
1474
  }
1444
1475
 
1445
1476
  if (data.roleSid && this.state.roleSid !== data.roleSid) {
1446
1477
  this.state.roleSid = data.roleSid;
1447
- updateReasons.push('roleSid');
1478
+ updateReasons.push("roleSid");
1448
1479
  }
1449
1480
 
1450
1481
  if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null) && this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {
1451
1482
  this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;
1452
- updateReasons.push('lastReadMessageIndex');
1483
+ updateReasons.push("lastReadMessageIndex");
1453
1484
  }
1454
1485
 
1455
1486
  if (data.lastConsumptionTimestamp) {
@@ -1457,12 +1488,17 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1457
1488
 
1458
1489
  if (!this.state.lastReadTimestamp || this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {
1459
1490
  this.state.lastReadTimestamp = lastReadTimestamp;
1460
- updateReasons.push('lastReadTimestamp');
1491
+ updateReasons.push("lastReadTimestamp");
1461
1492
  }
1462
1493
  }
1463
1494
 
1495
+ if (data.bindings && !isEqual__default['default'](this.state.bindings, data.bindings)) {
1496
+ this.state.bindings = data.bindings;
1497
+ updateReasons.push("bindings");
1498
+ }
1499
+
1464
1500
  if (updateReasons.length > 0) {
1465
- this.emit('updated', {
1501
+ this.emit("updated", {
1466
1502
  participant: this,
1467
1503
  updateReasons: updateReasons
1468
1504
  });
@@ -1482,12 +1518,12 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1482
1518
  while (1) {
1483
1519
  switch (_context.prev = _context.next) {
1484
1520
  case 0:
1485
- if (!(this.type != 'chat')) {
1521
+ if (!(this.type != "chat")) {
1486
1522
  _context.next = 2;
1487
1523
  break;
1488
1524
  }
1489
1525
 
1490
- throw new Error('Getting User is not supported for this Participant type: ' + this.type);
1526
+ throw new Error("Getting User is not supported for this Participant type: " + this.type);
1491
1527
 
1492
1528
  case 2:
1493
1529
  return _context.abrupt("return", this.services.users.getUser(this.state.identity, this.state.userInfo));
@@ -1548,7 +1584,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1548
1584
  switch (_context3.prev = _context3.next) {
1549
1585
  case 0:
1550
1586
  _context3.next = 2;
1551
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
1587
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
1552
1588
  attributes: JSON.stringify(attributes)
1553
1589
  });
1554
1590
 
@@ -1574,18 +1610,18 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1574
1610
  return Participant;
1575
1611
  }(replayEventEmitter.ReplayEventEmitter);
1576
1612
 
1577
- _defineProperty__default['default'](Participant, "typingStarted", 'typingStarted');
1613
+ _defineProperty__default['default'](Participant, "typingStarted", "typingStarted");
1578
1614
 
1579
- _defineProperty__default['default'](Participant, "typingEnded", 'typingEnded');
1615
+ _defineProperty__default['default'](Participant, "typingEnded", "typingEnded");
1580
1616
 
1581
- _defineProperty__default['default'](Participant, "updated", 'updated');
1617
+ _defineProperty__default['default'](Participant, "updated", "updated");
1582
1618
 
1583
- __decorate([declarativeTypeValidator.validateTypesAsync(['string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
1619
+ __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
1584
1620
 
1585
1621
  function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
1586
1622
 
1587
1623
  function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1588
- var log$6 = Logger.scope('Participants');
1624
+ var log$6 = Logger.scope("Participants");
1589
1625
  /**
1590
1626
  * @classdesc Represents the collection of participants for the conversation
1591
1627
  * @fires Participants#participantJoined
@@ -1604,6 +1640,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1604
1640
  _classCallCheck__default['default'](this, Participants);
1605
1641
 
1606
1642
  _this = _super.call(this);
1643
+
1644
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "rosterEntityPromise", null);
1645
+
1607
1646
  _this.conversation = conversation;
1608
1647
  _this.participants = participants;
1609
1648
  _this.links = links;
@@ -1655,17 +1694,17 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1655
1694
 
1656
1695
  return this.rosterEntityPromise = this.rosterEntityPromise || this.services.syncClient.map({
1657
1696
  id: rosterObjectName,
1658
- mode: 'open_existing'
1697
+ mode: "open_existing"
1659
1698
  }).then(function (rosterMap) {
1660
- rosterMap.on('itemAdded', function (args) {
1661
- log$6.debug(_this2.conversation.sid + ' itemAdded: ' + args.item.key);
1699
+ rosterMap.on("itemAdded", function (args) {
1700
+ log$6.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
1662
1701
 
1663
1702
  _this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
1664
- _this2.emit('participantJoined', participant);
1703
+ _this2.emit("participantJoined", participant);
1665
1704
  });
1666
1705
  });
1667
- rosterMap.on('itemRemoved', function (args) {
1668
- log$6.debug(_this2.conversation.sid + ' itemRemoved: ' + args.key);
1706
+ rosterMap.on("itemRemoved", function (args) {
1707
+ log$6.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
1669
1708
  var participantSid = args.key;
1670
1709
 
1671
1710
  if (!_this2.participants.has(participantSid)) {
@@ -1676,19 +1715,22 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1676
1715
 
1677
1716
  _this2.participants.delete(participantSid);
1678
1717
 
1679
- _this2.emit('participantLeft', leftParticipant);
1718
+ if (!leftParticipant) {
1719
+ return;
1720
+ }
1721
+
1722
+ _this2.emit("participantLeft", leftParticipant);
1680
1723
  });
1681
- rosterMap.on('itemUpdated', function (args) {
1682
- log$6.debug(_this2.conversation.sid + ' itemUpdated: ' + args.item.key);
1724
+ rosterMap.on("itemUpdated", function (args) {
1725
+ log$6.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
1683
1726
 
1684
1727
  _this2.upsertParticipant(args.item.key, args.item.data);
1685
1728
  });
1686
1729
  var participantsPromises = [];
1687
- var that = _this2;
1688
1730
 
1689
1731
  var rosterMapHandler = function rosterMapHandler(paginator) {
1690
1732
  paginator.items.forEach(function (item) {
1691
- participantsPromises.push(that.upsertParticipant(item.key, item.data));
1733
+ participantsPromises.push(_this2.upsertParticipant(item.key, item.data));
1692
1734
  });
1693
1735
  return paginator.hasNextPage ? paginator.nextPage().then(rosterMapHandler) : null;
1694
1736
  };
@@ -1701,11 +1743,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1701
1743
  }).catch(function (err) {
1702
1744
  _this2.rosterEntityPromise = null;
1703
1745
 
1704
- if (_this2.services.syncClient.connectionState != 'disconnected') {
1705
- log$6.error('Failed to get roster object for conversation', _this2.conversation.sid, err);
1746
+ if (_this2.services.syncClient.connectionState != "disconnected") {
1747
+ log$6.error("Failed to get roster object for conversation", _this2.conversation.sid, err);
1706
1748
  }
1707
1749
 
1708
- log$6.debug('ERROR: Failed to get roster object for conversation', _this2.conversation.sid, err);
1750
+ log$6.debug("ERROR: Failed to get roster object for conversation", _this2.conversation.sid, err);
1709
1751
  throw err;
1710
1752
  });
1711
1753
  }
@@ -1735,8 +1777,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1735
1777
  };
1736
1778
  participant = new Participant(data, participantSid, this.conversation, links, this.services);
1737
1779
  this.participants.set(participantSid, participant);
1738
- participant.on('updated', function (args) {
1739
- return _this3.emit('participantUpdated', args);
1780
+ participant.on("updated", function (args) {
1781
+ return _this3.emit("participantUpdated", args);
1740
1782
  });
1741
1783
  return _context2.abrupt("return", participant);
1742
1784
 
@@ -1760,19 +1802,38 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1760
1802
 
1761
1803
  }, {
1762
1804
  key: "getParticipants",
1763
- value: function getParticipants() {
1764
- var _this4 = this;
1805
+ value: function () {
1806
+ var _getParticipants = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
1807
+ var _this4 = this;
1765
1808
 
1766
- return this.rosterEntityPromise.then(function () {
1767
- var participants = [];
1809
+ return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
1810
+ while (1) {
1811
+ switch (_context3.prev = _context3.next) {
1812
+ case 0:
1813
+ return _context3.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
1814
+ var participants = [];
1768
1815
 
1769
- _this4.participants.forEach(function (participant) {
1770
- return participants.push(participant);
1771
- });
1816
+ _this4.participants.forEach(function (participant) {
1817
+ return participants.push(participant);
1818
+ });
1772
1819
 
1773
- return participants;
1774
- });
1775
- }
1820
+ return participants;
1821
+ }) : []);
1822
+
1823
+ case 1:
1824
+ case "end":
1825
+ return _context3.stop();
1826
+ }
1827
+ }
1828
+ }, _callee3, this);
1829
+ }));
1830
+
1831
+ function getParticipants() {
1832
+ return _getParticipants.apply(this, arguments);
1833
+ }
1834
+
1835
+ return getParticipants;
1836
+ }()
1776
1837
  /**
1777
1838
  * Get participant by SID from conversation
1778
1839
  * @returns {Promise<Participant>}
@@ -1781,29 +1842,29 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1781
1842
  }, {
1782
1843
  key: "getParticipantBySid",
1783
1844
  value: function () {
1784
- var _getParticipantBySid = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(participantSid) {
1845
+ var _getParticipantBySid = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(participantSid) {
1785
1846
  var _this5 = this;
1786
1847
 
1787
- return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
1848
+ return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
1788
1849
  while (1) {
1789
- switch (_context3.prev = _context3.next) {
1850
+ switch (_context4.prev = _context4.next) {
1790
1851
  case 0:
1791
- return _context3.abrupt("return", this.rosterEntityPromise.then(function () {
1852
+ return _context4.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
1792
1853
  var participant = _this5.participants.get(participantSid);
1793
1854
 
1794
1855
  if (!participant) {
1795
- throw new Error('Participant with SID ' + participantSid + ' was not found');
1856
+ throw new Error("Participant with SID " + participantSid + " was not found");
1796
1857
  }
1797
1858
 
1798
1859
  return participant;
1799
- }));
1860
+ }) : null);
1800
1861
 
1801
1862
  case 1:
1802
1863
  case "end":
1803
- return _context3.stop();
1864
+ return _context4.stop();
1804
1865
  }
1805
1866
  }
1806
- }, _callee3, this);
1867
+ }, _callee4, this);
1807
1868
  }));
1808
1869
 
1809
1870
  function getParticipantBySid(_x3) {
@@ -1820,16 +1881,16 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1820
1881
  }, {
1821
1882
  key: "getParticipantByIdentity",
1822
1883
  value: function () {
1823
- var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(identity) {
1884
+ var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(identity) {
1824
1885
  var _this6 = this;
1825
1886
 
1826
1887
  var foundParticipant;
1827
- return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
1888
+ return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
1828
1889
  while (1) {
1829
- switch (_context4.prev = _context4.next) {
1890
+ switch (_context5.prev = _context5.next) {
1830
1891
  case 0:
1831
1892
  foundParticipant = null;
1832
- return _context4.abrupt("return", this.rosterEntityPromise.then(function () {
1893
+ return _context5.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
1833
1894
  _this6.participants.forEach(function (participant) {
1834
1895
  if (participant.identity === identity) {
1835
1896
  foundParticipant = participant;
@@ -1837,18 +1898,18 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1837
1898
  });
1838
1899
 
1839
1900
  if (!foundParticipant) {
1840
- throw new Error('Participant with identity ' + identity + ' was not found');
1901
+ throw new Error("Participant with identity " + identity + " was not found");
1841
1902
  }
1842
1903
 
1843
1904
  return foundParticipant;
1844
- }));
1905
+ }) : null);
1845
1906
 
1846
1907
  case 2:
1847
1908
  case "end":
1848
- return _context4.stop();
1909
+ return _context5.stop();
1849
1910
  }
1850
1911
  }
1851
- }, _callee4, this);
1912
+ }, _callee5, this);
1852
1913
  }));
1853
1914
 
1854
1915
  function getParticipantByIdentity(_x4) {
@@ -1859,32 +1920,32 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1859
1920
  }()
1860
1921
  /**
1861
1922
  * Add a chat participant to the conversation
1862
- * @returns {Promise<any>}
1923
+ * @returns {Promise<ParticipantResponse>}
1863
1924
  */
1864
1925
 
1865
1926
  }, {
1866
1927
  key: "add",
1867
1928
  value: function () {
1868
- var _add = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(identity, attributes) {
1869
- return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
1929
+ var _add = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6(identity, attributes) {
1930
+ return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
1870
1931
  while (1) {
1871
- switch (_context5.prev = _context5.next) {
1932
+ switch (_context6.prev = _context6.next) {
1872
1933
  case 0:
1873
- _context5.next = 2;
1874
- return this.services.commandExecutor.mutateResource('post', this.links.participants, {
1934
+ _context6.next = 2;
1935
+ return this.services.commandExecutor.mutateResource("post", this.links.participants, {
1875
1936
  identity: identity,
1876
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
1937
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
1877
1938
  });
1878
1939
 
1879
1940
  case 2:
1880
- return _context5.abrupt("return", _context5.sent);
1941
+ return _context6.abrupt("return", _context6.sent);
1881
1942
 
1882
1943
  case 3:
1883
1944
  case "end":
1884
- return _context5.stop();
1945
+ return _context6.stop();
1885
1946
  }
1886
1947
  }
1887
- }, _callee5, this);
1948
+ }, _callee6, this);
1888
1949
  }));
1889
1950
 
1890
1951
  function add(_x5, _x6) {
@@ -1899,17 +1960,24 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1899
1960
  * @param proxyAddress
1900
1961
  * @param address
1901
1962
  * @param attributes
1963
+ * @param bindingOptions
1902
1964
  * @returns {Promise<any>}
1903
1965
  */
1904
1966
 
1905
1967
  }, {
1906
1968
  key: "addNonChatParticipant",
1907
- value: function addNonChatParticipant(proxyAddress, address, attributes) {
1908
- return this.services.commandExecutor.mutateResource('post', this.links.participants, {
1909
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined,
1969
+ value: function addNonChatParticipant(proxyAddress, address) {
1970
+ var _bindingOptions$email, _bindingOptions$email2;
1971
+
1972
+ var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1973
+ var bindingOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1974
+ return this.services.commandExecutor.mutateResource("post", this.links.participants, {
1975
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
1910
1976
  messaging_binding: {
1911
1977
  address: address,
1912
- proxy_address: proxyAddress
1978
+ proxy_address: proxyAddress,
1979
+ name: bindingOptions === null || bindingOptions === void 0 ? void 0 : (_bindingOptions$email = bindingOptions.email) === null || _bindingOptions$email === void 0 ? void 0 : _bindingOptions$email.name,
1980
+ level: bindingOptions === null || bindingOptions === void 0 ? void 0 : (_bindingOptions$email2 = bindingOptions.email) === null || _bindingOptions$email2 === void 0 ? void 0 : _bindingOptions$email2.level
1913
1981
  }
1914
1982
  });
1915
1983
  }
@@ -1920,7 +1988,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1920
1988
  }, {
1921
1989
  key: "remove",
1922
1990
  value: function remove(identity) {
1923
- return this.services.commandExecutor.mutateResource('delete', "".concat(this.links.participants, "/").concat(identity));
1991
+ return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(identity));
1924
1992
  }
1925
1993
  }]);
1926
1994
 
@@ -2031,6 +2099,8 @@ var Media = /*#__PURE__*/function () {
2031
2099
  key: "getContentTemporaryUrl",
2032
2100
  value: function () {
2033
2101
  var _getContentTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
2102
+ var _this$mcsMedia$getCon, _this$mcsMedia;
2103
+
2034
2104
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
2035
2105
  while (1) {
2036
2106
  switch (_context.prev = _context.next) {
@@ -2039,7 +2109,7 @@ var Media = /*#__PURE__*/function () {
2039
2109
  return this._fetchMcsMedia();
2040
2110
 
2041
2111
  case 2:
2042
- return _context.abrupt("return", this.mcsMedia.getContentUrl());
2112
+ return _context.abrupt("return", (_this$mcsMedia$getCon = (_this$mcsMedia = this.mcsMedia) === null || _this$mcsMedia === void 0 ? void 0 : _this$mcsMedia.getContentUrl()) !== null && _this$mcsMedia$getCon !== void 0 ? _this$mcsMedia$getCon : null);
2043
2113
 
2044
2114
  case 3:
2045
2115
  case "end":
@@ -2069,6 +2139,8 @@ var Media = /*#__PURE__*/function () {
2069
2139
  key: "getCachedTemporaryUrl",
2070
2140
  value: function () {
2071
2141
  var _getCachedTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
2142
+ var _this$mcsMedia$getCac, _this$mcsMedia2;
2143
+
2072
2144
  return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
2073
2145
  while (1) {
2074
2146
  switch (_context2.prev = _context2.next) {
@@ -2077,7 +2149,7 @@ var Media = /*#__PURE__*/function () {
2077
2149
  return this._fetchMcsMedia();
2078
2150
 
2079
2151
  case 2:
2080
- return _context2.abrupt("return", this.mcsMedia.getCachedContentUrl());
2152
+ return _context2.abrupt("return", (_this$mcsMedia$getCac = (_this$mcsMedia2 = this.mcsMedia) === null || _this$mcsMedia2 === void 0 ? void 0 : _this$mcsMedia2.getCachedContentUrl()) !== null && _this$mcsMedia$getCac !== void 0 ? _this$mcsMedia$getCac : null);
2081
2153
 
2082
2154
  case 3:
2083
2155
  case "end":
@@ -2120,7 +2192,7 @@ var Media = /*#__PURE__*/function () {
2120
2192
  break;
2121
2193
 
2122
2194
  case 7:
2123
- throw new Error('Media Content Service is unavailable');
2195
+ throw new Error("Media Content Service is unavailable");
2124
2196
 
2125
2197
  case 8:
2126
2198
  case "end":
@@ -2314,7 +2386,7 @@ var RestPaginator = /*#__PURE__*/function () {
2314
2386
  }, {
2315
2387
  key: "nextPage",
2316
2388
  value: function nextPage() {
2317
- return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error('No next page'));
2389
+ return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error("No next page"));
2318
2390
  }
2319
2391
  /**
2320
2392
  * Request the previous page. Does not modify the existing object.
@@ -2323,7 +2395,7 @@ var RestPaginator = /*#__PURE__*/function () {
2323
2395
  }, {
2324
2396
  key: "prevPage",
2325
2397
  value: function prevPage() {
2326
- return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error('No previous page'));
2398
+ return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error("No previous page"));
2327
2399
  }
2328
2400
  }]);
2329
2401
 
@@ -2382,7 +2454,7 @@ function DetailedDeliveryReceipt(descriptor) {
2382
2454
  this.conversationSid = descriptor.conversation_sid;
2383
2455
  this.channelMessageSid = descriptor.channel_message_sid;
2384
2456
  this.participantSid = descriptor.participant_sid;
2385
- this.status = descriptor.status || 'queued';
2457
+ this.status = descriptor.status || "queued";
2386
2458
  this.errorCode = descriptor.error_code || 0;
2387
2459
  this.dateCreated = descriptor.date_created;
2388
2460
  this.dateUpdated = descriptor.date_updated;
@@ -2391,7 +2463,7 @@ function DetailedDeliveryReceipt(descriptor) {
2391
2463
  function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
2392
2464
 
2393
2465
  function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2394
- var log$5 = Logger.scope('Message');
2466
+ var log$5 = Logger.scope("Message");
2395
2467
  /**
2396
2468
  * A message in a conversation.
2397
2469
  */
@@ -2409,7 +2481,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2409
2481
  * @internal
2410
2482
  */
2411
2483
  function Message(index, data, conversation, links, configuration, services) {
2412
- var _data$author, _data$subject, _data$lastUpdatedBy, _data$type, _data$memberSid;
2484
+ var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
2413
2485
 
2414
2486
  var _this;
2415
2487
 
@@ -2423,16 +2495,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2423
2495
  _this.state = {
2424
2496
  sid: data.sid,
2425
2497
  index: index,
2426
- author: (_data$author = data.author) !== null && _data$author !== void 0 ? _data$author : null,
2427
- subject: (_data$subject = data.subject) !== null && _data$subject !== void 0 ? _data$subject : null,
2428
- body: data.text,
2498
+ author: data.author,
2499
+ subject: data.subject,
2500
+ body: (_data$text = data.text) !== null && _data$text !== void 0 ? _data$text : null,
2429
2501
  timestamp: data.timestamp ? new Date(data.timestamp) : null,
2430
2502
  dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
2431
2503
  lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
2432
2504
  attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$5),
2433
- type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : 'text',
2434
- media: data.type && data.type === 'media' && data.media ? new Media(data.media, _this.services) : null,
2435
- medias: data.type && data.type === 'media' && data.medias ? data.medias.map(function (m) {
2505
+ type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : "text",
2506
+ media: data.type && data.type === "media" && data.media ? new Media(data.media, _this.services) : null,
2507
+ medias: data.type && data.type === "media" && data.medias ? data.medias.map(function (m) {
2436
2508
  return new Media(m, _this.services);
2437
2509
  }) : null,
2438
2510
  participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
@@ -2540,7 +2612,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2540
2612
  return this.state.attributes;
2541
2613
  }
2542
2614
  /**
2543
- * Push notification type of the message.
2615
+ * Type of the message.
2544
2616
  */
2545
2617
 
2546
2618
  }, {
@@ -2549,7 +2621,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2549
2621
  return this.state.type;
2550
2622
  }
2551
2623
  /**
2552
- * One of the attached media.
2624
+ * One of the attached media (if present).
2553
2625
  * @deprecated Use attachedMedia instead. Note that the latter is now an array.
2554
2626
  */
2555
2627
 
@@ -2565,7 +2637,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2565
2637
  }, {
2566
2638
  key: "attachedMedia",
2567
2639
  get: function get() {
2568
- return this.getMediaByCategory(['media']);
2640
+ return this.getMediaByCategory(["media"]);
2569
2641
  }
2570
2642
  /**
2571
2643
  * The server-assigned unique identifier of the authoring participant.
@@ -2574,7 +2646,9 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2574
2646
  }, {
2575
2647
  key: "participantSid",
2576
2648
  get: function get() {
2577
- return this.state.participantSid;
2649
+ var _this$state$participa;
2650
+
2651
+ return (_this$state$participa = this.state.participantSid) !== null && _this$state$participa !== void 0 ? _this$state$participa : "";
2578
2652
  }
2579
2653
  /**
2580
2654
  * Aggregated information about the message delivery statuses across all participants of a conversation..
@@ -2597,50 +2671,82 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2597
2671
  value: function getMediaByCategory(categories) {
2598
2672
  var _this$state$medias;
2599
2673
 
2600
- return (_this$state$medias = this.state.medias) === null || _this$state$medias === void 0 ? void 0 : _this$state$medias.filter(function (m) {
2674
+ return ((_this$state$medias = this.state.medias) !== null && _this$state$medias !== void 0 ? _this$state$medias : []).filter(function (m) {
2601
2675
  return categories.includes(m.category);
2602
2676
  });
2603
2677
  }
2678
+ /**
2679
+ * Get a media descriptor for an email body attachment of a provided type.
2680
+ * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedMimeTypes array.
2681
+ * @param type Type of email body to request, defaults to `text/plain`.
2682
+ */
2683
+
2684
+ }, {
2685
+ key: "getEmailBody",
2686
+ value: function getEmailBody() {
2687
+ var _this$getMediaByCateg, _this$getMediaByCateg2;
2688
+
2689
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "text/plain";
2690
+ return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.getMediaByCategory(["body"])) === null || _this$getMediaByCateg2 === void 0 ? void 0 : _this$getMediaByCateg2.filter(function (m) {
2691
+ return m.contentType == type;
2692
+ }).shift()) !== null && _this$getMediaByCateg !== void 0 ? _this$getMediaByCateg : null;
2693
+ }
2694
+ /**
2695
+ * Get a media descriptor for an email history attachment of a provided type.
2696
+ * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedMimeTypes array.
2697
+ * @param type Type of email history to request, defaults to `text/plain`.
2698
+ */
2699
+
2700
+ }, {
2701
+ key: "getEmailHistory",
2702
+ value: function getEmailHistory() {
2703
+ var _this$getMediaByCateg3, _this$getMediaByCateg4;
2704
+
2705
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "text/plain";
2706
+ return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.getMediaByCategory(["history"])) === null || _this$getMediaByCateg4 === void 0 ? void 0 : _this$getMediaByCateg4.filter(function (m) {
2707
+ return m.contentType == type;
2708
+ }).shift()) !== null && _this$getMediaByCateg3 !== void 0 ? _this$getMediaByCateg3 : null;
2709
+ }
2604
2710
  }, {
2605
2711
  key: "_update",
2606
2712
  value: function _update(data) {
2607
2713
  var updateReasons = [];
2608
2714
 
2609
- if ((data.text || typeof data.text === 'string') && data.text !== this.state.body) {
2715
+ if ((data.text || typeof data.text === "string") && data.text !== this.state.body) {
2610
2716
  this.state.body = data.text;
2611
- updateReasons.push('body');
2717
+ updateReasons.push("body");
2612
2718
  }
2613
2719
 
2614
2720
  if (data.subject && data.subject !== this.state.subject) {
2615
2721
  this.state.subject = data.subject;
2616
- updateReasons.push('subject');
2722
+ updateReasons.push("subject");
2617
2723
  }
2618
2724
 
2619
2725
  if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {
2620
2726
  this.state.lastUpdatedBy = data.lastUpdatedBy;
2621
- updateReasons.push('lastUpdatedBy');
2727
+ updateReasons.push("lastUpdatedBy");
2622
2728
  }
2623
2729
 
2624
2730
  if (data.author && data.author !== this.state.author) {
2625
2731
  this.state.author = data.author;
2626
- updateReasons.push('author');
2732
+ updateReasons.push("author");
2627
2733
  }
2628
2734
 
2629
2735
  if (data.dateUpdated && new Date(data.dateUpdated).getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
2630
2736
  this.state.dateUpdated = new Date(data.dateUpdated);
2631
- updateReasons.push('dateUpdated');
2737
+ updateReasons.push("dateUpdated");
2632
2738
  }
2633
2739
 
2634
2740
  if (data.timestamp && new Date(data.timestamp).getTime() !== (this.state.timestamp && this.state.timestamp.getTime())) {
2635
2741
  this.state.timestamp = new Date(data.timestamp);
2636
- updateReasons.push('dateCreated');
2742
+ updateReasons.push("dateCreated");
2637
2743
  }
2638
2744
 
2639
2745
  var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$5);
2640
2746
 
2641
2747
  if (!isEqual__default['default'](this.state.attributes, updatedAttributes)) {
2642
2748
  this.state.attributes = updatedAttributes;
2643
- updateReasons.push('attributes');
2749
+ updateReasons.push("attributes");
2644
2750
  }
2645
2751
 
2646
2752
  var updatedAggregatedDelivery = data.delivery;
@@ -2650,16 +2756,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2650
2756
  if (isUpdatedAggregateDeliveryValid) {
2651
2757
  if (!currentAggregatedDelivery) {
2652
2758
  this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(updatedAggregatedDelivery);
2653
- updateReasons.push('deliveryReceipt');
2759
+ updateReasons.push("deliveryReceipt");
2654
2760
  } else if (!currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)) {
2655
2761
  currentAggregatedDelivery._update(updatedAggregatedDelivery);
2656
2762
 
2657
- updateReasons.push('deliveryReceipt');
2763
+ updateReasons.push("deliveryReceipt");
2658
2764
  }
2659
2765
  }
2660
2766
 
2661
2767
  if (updateReasons.length > 0) {
2662
- this.emit('updated', {
2768
+ this.emit("updated", {
2663
2769
  message: this,
2664
2770
  updateReasons: updateReasons
2665
2771
  });
@@ -2720,25 +2826,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2720
2826
  return _context.abrupt("return", participant);
2721
2827
 
2722
2828
  case 11:
2723
- errorMesage = 'Participant with ';
2829
+ errorMesage = "Participant with ";
2724
2830
 
2725
2831
  if (this.state.participantSid) {
2726
- errorMesage += 'SID \'' + this.state.participantSid + '\' ';
2832
+ errorMesage += "SID '" + this.state.participantSid + "' ";
2727
2833
  }
2728
2834
 
2729
2835
  if (this.state.author) {
2730
2836
  if (this.state.participantSid) {
2731
- errorMesage += 'or ';
2837
+ errorMesage += "or ";
2732
2838
  }
2733
2839
 
2734
- errorMesage += 'identity \'' + this.state.author + '\' ';
2840
+ errorMesage += "identity '" + this.state.author + "' ";
2735
2841
  }
2736
2842
 
2737
- if (errorMesage === 'Participant with ') {
2738
- errorMesage = 'Participant ';
2843
+ if (errorMesage === "Participant with ") {
2844
+ errorMesage = "Participant ";
2739
2845
  }
2740
2846
 
2741
- errorMesage += 'was not found';
2847
+ errorMesage += "was not found";
2742
2848
  throw new Error(errorMesage);
2743
2849
 
2744
2850
  case 17:
@@ -2825,7 +2931,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2825
2931
  switch (_context3.prev = _context3.next) {
2826
2932
  case 0:
2827
2933
  _context3.next = 2;
2828
- return this.services.commandExecutor.mutateResource('delete', this.links.self);
2934
+ return this.services.commandExecutor.mutateResource("delete", this.links.self);
2829
2935
 
2830
2936
  case 2:
2831
2937
  return _context3.abrupt("return", this);
@@ -2858,7 +2964,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2858
2964
  switch (_context4.prev = _context4.next) {
2859
2965
  case 0:
2860
2966
  _context4.next = 2;
2861
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
2967
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
2862
2968
  body: body
2863
2969
  });
2864
2970
 
@@ -2893,8 +2999,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2893
2999
  switch (_context5.prev = _context5.next) {
2894
3000
  case 0:
2895
3001
  _context5.next = 2;
2896
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
2897
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
3002
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
3003
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
2898
3004
  });
2899
3005
 
2900
3006
  case 2:
@@ -2932,11 +3038,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2932
3038
  case 0:
2933
3039
  // We ignore existing mcsMedia members of each of the media entries.
2934
3040
  // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
2935
- sids = contentSet.map(function (m) {
3041
+ sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
2936
3042
  return m.sid;
2937
3043
  });
2938
3044
 
2939
- if (!this.services.mcsClient) {
3045
+ if (!(this.services.mcsClient && sids)) {
2940
3046
  _context6.next = 7;
2941
3047
  break;
2942
3048
  }
@@ -2950,7 +3056,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2950
3056
  }));
2951
3057
 
2952
3058
  case 7:
2953
- throw new Error('Media Content Service is unavailable');
3059
+ throw new Error("Media Content Service is unavailable");
2954
3060
 
2955
3061
  case 8:
2956
3062
  case "end":
@@ -2977,8 +3083,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2977
3083
  while (1) {
2978
3084
  switch (_context7.prev = _context7.next) {
2979
3085
  case 0:
2980
- messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace('%s', this.conversation.sid).replace('%s', this.sid);
2981
- url = new UriBuilder(messagesReceiptsUrl).arg('PageToken', options === null || options === void 0 ? void 0 : options.pageToken).arg('PageSize', options === null || options === void 0 ? void 0 : options.pageSize).build();
3086
+ messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace("%s", this.conversation.sid).replace("%s", this.sid);
3087
+ url = new UriBuilder(messagesReceiptsUrl).arg("PageToken", options === null || options === void 0 ? void 0 : options.pageToken).arg("PageSize", options === null || options === void 0 ? void 0 : options.pageSize).build();
2982
3088
  _context7.next = 4;
2983
3089
  return this.services.network.get(url);
2984
3090
 
@@ -3012,16 +3118,20 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3012
3118
  return Message;
3013
3119
  }(replayEventEmitter.ReplayEventEmitter);
3014
3120
 
3015
- _defineProperty__default['default'](Message, "updated", 'updated');
3121
+ _defineProperty__default['default'](Message, "updated", "updated");
3122
+
3123
+ __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
3016
3124
 
3017
- __decorate([declarativeTypeValidator.validateTypesAsync('string'), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
3125
+ __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
3018
3126
 
3019
- __decorate([declarativeTypeValidator.validateTypesAsync(['string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
3127
+ __decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
3128
+
3129
+ __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
3020
3130
 
3021
3131
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.custom(function (value) {
3022
3132
  return [value instanceof Array && value.length > 0 && value.reduce(function (a, c) {
3023
3133
  return a && c instanceof Media;
3024
- }), 'a non-empty array of Media'];
3134
+ }, true), "a non-empty array of Media"];
3025
3135
  })), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
3026
3136
 
3027
3137
  function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -3033,7 +3143,7 @@ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) le
3033
3143
  function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
3034
3144
 
3035
3145
  function _isNativeReflectConstruct$4() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
3036
- var log$4 = Logger.scope('Messages');
3146
+ var log$4 = Logger.scope("Messages");
3037
3147
  /**
3038
3148
  * Represents the collection of messages in a conversation
3039
3149
  */
@@ -3083,7 +3193,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3083
3193
  case 2:
3084
3194
  this.messagesListPromise = this.services.syncClient.list({
3085
3195
  id: name,
3086
- mode: 'open_existing'
3196
+ mode: "open_existing"
3087
3197
  });
3088
3198
  _context.prev = 3;
3089
3199
  _context.next = 6;
@@ -3091,7 +3201,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3091
3201
 
3092
3202
  case 6:
3093
3203
  list = _context.sent;
3094
- list.on('itemAdded', function (args) {
3204
+ list.on("itemAdded", function (args) {
3095
3205
  log$4.debug("".concat(_this2.conversation.sid, " itemAdded: ").concat(args.item.index));
3096
3206
  var links = {
3097
3207
  self: "".concat(_this2.conversation.links.messages, "/").concat(args.item.data.sid),
@@ -3101,33 +3211,37 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3101
3211
  var message = new Message(args.item.index, args.item.data, _this2.conversation, links, _this2.configuration, _this2.services);
3102
3212
 
3103
3213
  if (_this2.messagesByIndex.has(message.index)) {
3104
- log$4.debug('Message arrived, but is already known and ignored', _this2.conversation.sid, message.index);
3214
+ log$4.debug("Message arrived, but is already known and ignored", _this2.conversation.sid, message.index);
3105
3215
  return;
3106
3216
  }
3107
3217
 
3108
3218
  _this2.messagesByIndex.set(message.index, message);
3109
3219
 
3110
- message.on('updated', function (args) {
3111
- return _this2.emit('messageUpdated', args);
3220
+ message.on("updated", function (args) {
3221
+ return _this2.emit("messageUpdated", args);
3112
3222
  });
3113
3223
 
3114
- _this2.emit('messageAdded', message);
3224
+ _this2.emit("messageAdded", message);
3115
3225
  });
3116
- list.on('itemRemoved', function (args) {
3226
+ list.on("itemRemoved", function (args) {
3117
3227
  log$4.debug("#{this.conversation.sid} itemRemoved: ".concat(args.index));
3118
3228
  var index = args.index;
3119
3229
 
3120
3230
  if (_this2.messagesByIndex.has(index)) {
3121
3231
  var message = _this2.messagesByIndex.get(index);
3122
3232
 
3233
+ if (!message) {
3234
+ return;
3235
+ }
3236
+
3123
3237
  _this2.messagesByIndex.delete(message.index);
3124
3238
 
3125
- message.removeAllListeners('updated');
3239
+ message.removeAllListeners("updated");
3126
3240
 
3127
- _this2.emit('messageRemoved', message);
3241
+ _this2.emit("messageRemoved", message);
3128
3242
  }
3129
3243
  });
3130
- list.on('itemUpdated', function (args) {
3244
+ list.on("itemUpdated", function (args) {
3131
3245
  log$4.debug("".concat(_this2.conversation.sid, " itemUpdated: ").concat(args.item.index));
3132
3246
 
3133
3247
  var message = _this2.messagesByIndex.get(args.item.index);
@@ -3143,11 +3257,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3143
3257
  _context.t0 = _context["catch"](3);
3144
3258
  this.messagesListPromise = null;
3145
3259
 
3146
- if (this.services.syncClient.connectionState !== 'disconnected') {
3147
- log$4.error('Failed to get messages object for conversation', this.conversation.sid, _context.t0);
3260
+ if (this.services.syncClient.connectionState !== "disconnected") {
3261
+ log$4.error("Failed to get messages object for conversation", this.conversation.sid, _context.t0);
3148
3262
  }
3149
3263
 
3150
- log$4.debug('ERROR: Failed to get messages object for conversation', this.conversation.sid, _context.t0);
3264
+ log$4.debug("ERROR: Failed to get messages object for conversation", this.conversation.sid, _context.t0);
3151
3265
  throw _context.t0;
3152
3266
 
3153
3267
  case 19:
@@ -3206,7 +3320,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3206
3320
  /**
3207
3321
  * Send Message to the conversation, message could include both text and multiple media attachments.
3208
3322
  * @param message Message to post
3209
- * @returns Returns promise which can fail
3323
+ * @returns Returns a promise which can fail
3210
3324
  */
3211
3325
 
3212
3326
  }, {
@@ -3215,13 +3329,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3215
3329
  var _sendV = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(message) {
3216
3330
  var _message$emailOptions;
3217
3331
 
3218
- var media, _iterator, _step, _step$value, category, mediaContent;
3332
+ var media, _iterator, _step, _mediaContent$content, _mediaContent$media, _step$value, category, mediaContent;
3219
3333
 
3220
3334
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
3221
3335
  while (1) {
3222
3336
  switch (_context3.prev = _context3.next) {
3223
3337
  case 0:
3224
- log$4.debug('Sending message V2', message.mediaContent, message.attributes, message.emailOptions);
3338
+ log$4.debug("Sending message V2", message.mediaContent, message.attributes, message.emailOptions);
3225
3339
  media = [];
3226
3340
  _iterator = _createForOfIteratorHelper$2(message.mediaContent);
3227
3341
  _context3.prev = 3;
@@ -3235,7 +3349,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3235
3349
  }
3236
3350
 
3237
3351
  _step$value = _slicedToArray__default['default'](_step.value, 2), category = _step$value[0], mediaContent = _step$value[1];
3238
- log$4.debug("Adding media to a message as ".concat(mediaContent instanceof FormData ? 'FormData' : 'SendMediaOptions'), mediaContent);
3352
+ log$4.debug("Adding media to a message as ".concat(mediaContent instanceof FormData ? "FormData" : "SendMediaOptions"), mediaContent);
3239
3353
  _context3.t0 = media;
3240
3354
 
3241
3355
  if (!(mediaContent instanceof FormData)) {
@@ -3253,7 +3367,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3253
3367
 
3254
3368
  case 15:
3255
3369
  _context3.next = 17;
3256
- return this.services.mcsClient.post(mediaContent.contentType, mediaContent.media, category, mediaContent.filename);
3370
+ return this.services.mcsClient.post((_mediaContent$content = mediaContent.contentType) !== null && _mediaContent$content !== void 0 ? _mediaContent$content : "", (_mediaContent$media = mediaContent.media) !== null && _mediaContent$media !== void 0 ? _mediaContent$media : "", category, mediaContent.filename);
3257
3371
 
3258
3372
  case 17:
3259
3373
  _context3.t1 = _context3.sent;
@@ -3286,13 +3400,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3286
3400
 
3287
3401
  case 30:
3288
3402
  _context3.next = 32;
3289
- return this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
3403
+ return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
3290
3404
  body: message.text,
3291
3405
  subject: (_message$emailOptions = message.emailOptions) === null || _message$emailOptions === void 0 ? void 0 : _message$emailOptions.subject,
3292
3406
  media_sids: media.map(function (m) {
3293
3407
  return m.sid;
3294
3408
  }),
3295
- attributes: typeof message.attributes !== 'undefined' ? JSON.stringify(message.attributes) : undefined
3409
+ attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
3296
3410
  });
3297
3411
 
3298
3412
  case 32:
@@ -3333,11 +3447,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3333
3447
  case 0:
3334
3448
  attributes = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
3335
3449
  emailOptions = _args4.length > 2 ? _args4[2] : undefined;
3336
- log$4.debug('Sending text message', message, attributes, emailOptions);
3450
+ log$4.debug("Sending text message", message, attributes, emailOptions);
3337
3451
  _context4.next = 5;
3338
- return this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
3339
- body: message !== null && message !== void 0 ? message : '',
3340
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined,
3452
+ return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
3453
+ body: message !== null && message !== void 0 ? message : "",
3454
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
3341
3455
  subject: emailOptions === null || emailOptions === void 0 ? void 0 : emailOptions.subject
3342
3456
  });
3343
3457
 
@@ -3370,6 +3484,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3370
3484
  key: "sendMedia",
3371
3485
  value: function () {
3372
3486
  var _sendMedia = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(mediaContent) {
3487
+ var _mediaContent$content2, _mediaContent$media2;
3488
+
3373
3489
  var attributes,
3374
3490
  emailOptions,
3375
3491
  media,
@@ -3380,8 +3496,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3380
3496
  case 0:
3381
3497
  attributes = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
3382
3498
  emailOptions = _args5.length > 2 ? _args5[2] : undefined;
3383
- log$4.debug('Sending media message', mediaContent, attributes, emailOptions);
3384
- log$4.debug("Sending media message as ".concat(mediaContent instanceof FormData ? 'FormData' : 'SendMediaOptions'), mediaContent, attributes);
3499
+ log$4.debug("Sending media message", mediaContent, attributes, emailOptions);
3500
+ log$4.debug("Sending media message as ".concat(mediaContent instanceof FormData ? "FormData" : "SendMediaOptions"), mediaContent, attributes);
3385
3501
 
3386
3502
  if (!(mediaContent instanceof FormData)) {
3387
3503
  _context5.next = 10;
@@ -3398,7 +3514,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3398
3514
 
3399
3515
  case 10:
3400
3516
  _context5.next = 12;
3401
- return this.services.mcsClient.post(mediaContent.contentType, mediaContent.media, 'media', mediaContent.filename);
3517
+ return this.services.mcsClient.post((_mediaContent$content2 = mediaContent.contentType) !== null && _mediaContent$content2 !== void 0 ? _mediaContent$content2 : "", (_mediaContent$media2 = mediaContent.media) !== null && _mediaContent$media2 !== void 0 ? _mediaContent$media2 : "", "media", mediaContent.filename);
3402
3518
 
3403
3519
  case 12:
3404
3520
  _context5.t0 = _context5.sent;
@@ -3406,9 +3522,9 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3406
3522
  case 13:
3407
3523
  media = _context5.t0;
3408
3524
  _context5.next = 16;
3409
- return this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
3525
+ return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
3410
3526
  media_sids: [media.sid],
3411
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
3527
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
3412
3528
  });
3413
3529
 
3414
3530
  case 16:
@@ -3446,7 +3562,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3446
3562
  while (1) {
3447
3563
  switch (_context6.prev = _context6.next) {
3448
3564
  case 0:
3449
- direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : 'backwards';
3565
+ direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : "backwards";
3450
3566
  return _context6.abrupt("return", this._getMessages(pageSize, anchor, direction));
3451
3567
 
3452
3568
  case 2:
@@ -3470,7 +3586,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3470
3586
 
3471
3587
  // Due to an inconsistency between Sync and Chat conventions, next and
3472
3588
  // previous pages should be swapped.
3473
- var shouldReverse = order === 'desc';
3589
+ var shouldReverse = order === "desc";
3474
3590
 
3475
3591
  var nextPage = function nextPage() {
3476
3592
  return page.nextPage().then(function (page) {
@@ -3514,8 +3630,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3514
3630
  };
3515
3631
  var message = new Message(index, value, this.conversation, links, this.configuration, this.services);
3516
3632
  this.messagesByIndex.set(message.index, message);
3517
- message.on('updated', function (args) {
3518
- return _this4.emit('messageUpdated', args);
3633
+ message.on("updated", function (args) {
3634
+ return _this4.emit("messageUpdated", args);
3519
3635
  });
3520
3636
  return message;
3521
3637
  }
@@ -3546,17 +3662,17 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3546
3662
  switch (_context7.prev = _context7.next) {
3547
3663
  case 0:
3548
3664
  pageSize = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : 30;
3549
- anchor = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : 'end';
3550
- direction = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : 'forward';
3551
- order = direction === 'backwards' ? 'desc' : 'asc';
3665
+ anchor = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : "end";
3666
+ direction = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : "forward";
3667
+ order = direction === "backwards" ? "desc" : "asc";
3552
3668
  _context7.next = 6;
3553
3669
  return this.messagesListPromise;
3554
3670
 
3555
3671
  case 6:
3556
3672
  list = _context7.sent;
3557
3673
  _context7.next = 9;
3558
- return list.getItems({
3559
- from: anchor !== 'end' ? anchor : void 0,
3674
+ return list === null || list === void 0 ? void 0 : list.getItems({
3675
+ from: anchor !== "end" ? anchor : void 0,
3560
3676
  pageSize: pageSize,
3561
3677
  order: order,
3562
3678
  limit: pageSize // @todo Limit equals pageSize by default in Sync. This is probably not ideal.
@@ -3679,6 +3795,8 @@ var MessageBuilder = /*#__PURE__*/function () {
3679
3795
 
3680
3796
  this.limits = limits;
3681
3797
  this.message = new UnsentMessage(messagesEntity);
3798
+ this.emailBodies = new Map();
3799
+ this.emailHistories = new Map();
3682
3800
  }
3683
3801
  /**
3684
3802
  * Sets the message body.
@@ -3714,6 +3832,30 @@ var MessageBuilder = /*#__PURE__*/function () {
3714
3832
  this.message.attributes = attributes;
3715
3833
  return this;
3716
3834
  }
3835
+ /**
3836
+ * Set email body with given MIME-type.
3837
+ * @param mimeType Format of the body to set (text/plain or text/html).
3838
+ * @param body Body payload in selected format.
3839
+ */
3840
+
3841
+ }, {
3842
+ key: "setEmailBody",
3843
+ value: function setEmailBody(mimeType, body) {
3844
+ this.emailBodies.set(mimeType, body);
3845
+ return this;
3846
+ }
3847
+ /**
3848
+ * Set email history with given MIME-type.
3849
+ * @param mimeType Format of the history to set (text/plain or text/html).
3850
+ * @param history History payload in selected format.
3851
+ */
3852
+
3853
+ }, {
3854
+ key: "setEmailHistory",
3855
+ value: function setEmailHistory(mimeType, history) {
3856
+ this.emailHistories.set(mimeType, history);
3857
+ return this;
3858
+ }
3717
3859
  /**
3718
3860
  * Adds media to the message.
3719
3861
  * @param payload Media to add.
@@ -3722,7 +3864,19 @@ var MessageBuilder = /*#__PURE__*/function () {
3722
3864
  }, {
3723
3865
  key: "addMedia",
3724
3866
  value: function addMedia(payload) {
3725
- this.message.mediaContent.push(['media', payload]);
3867
+ if (typeof FormData === "undefined" && payload instanceof FormData) {
3868
+ throw new Error("Could not add FormData content whilst not in a browser");
3869
+ }
3870
+
3871
+ if (!(payload instanceof FormData)) {
3872
+ var mediaOptions = payload;
3873
+
3874
+ if (!mediaOptions.contentType || !mediaOptions.media) {
3875
+ throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media");
3876
+ }
3877
+ }
3878
+
3879
+ this.message.mediaContent.push(["media", payload]);
3726
3880
  return this;
3727
3881
  }
3728
3882
  /**
@@ -3732,18 +3886,46 @@ var MessageBuilder = /*#__PURE__*/function () {
3732
3886
  }, {
3733
3887
  key: "build",
3734
3888
  value: function build() {
3889
+ var _this = this;
3890
+
3891
+ this.emailBodies.forEach(function (_, key) {
3892
+ if (!_this.limits.emailBodiesAllowedMimeTypes.includes(key)) {
3893
+ throw new Error("Unsupported email body MIME type ".concat(key));
3894
+ }
3895
+ });
3896
+ this.emailHistories.forEach(function (_, key) {
3897
+ if (!_this.limits.emailHistoriesAllowedMimeTypes.includes(key)) {
3898
+ throw new Error("Unsupported email history MIME type ".concat(key));
3899
+ }
3900
+ });
3901
+
3902
+ if (this.emailBodies.size > this.limits.emailBodiesAllowedMimeTypes.length) {
3903
+ throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size, " > ").concat(this.limits.emailBodiesAllowedMimeTypes.length, ")"));
3904
+ }
3905
+
3906
+ if (this.emailHistories.size > this.limits.emailHistoriesAllowedMimeTypes.length) {
3907
+ throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size, " > ").concat(this.limits.emailHistoriesAllowedMimeTypes.length, ")"));
3908
+ }
3909
+
3735
3910
  if (this.message.mediaContent.length > this.limits.mediaAttachmentsCountLimit) {
3736
3911
  throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length, " > ").concat(this.limits.mediaAttachmentsCountLimit, ")"));
3737
3912
  } // @todo we don't know the sizes of the attachments in FormData
3913
+ // @todo insertion below makes build() method non-repeatable - probably move to UnsentMessage.send() or even sendV2()?
3738
3914
 
3739
3915
 
3916
+ this.emailBodies.forEach(function (body) {
3917
+ _this.message.mediaContent.push(["body", body]);
3918
+ });
3919
+ this.emailHistories.forEach(function (history) {
3920
+ _this.message.mediaContent.push(["history", history]);
3921
+ });
3740
3922
  return this.message;
3741
3923
  }
3742
3924
  }, {
3743
3925
  key: "getPayloadContentType",
3744
3926
  value: function getPayloadContentType(payload) {
3745
- if (typeof FormData !== 'undefined' && payload instanceof FormData) {
3746
- return payload.get('Content-Type');
3927
+ if (typeof FormData !== "undefined" && payload instanceof FormData) {
3928
+ return payload.get("Content-Type");
3747
3929
  }
3748
3930
 
3749
3931
  return payload.contentType;
@@ -3762,20 +3944,21 @@ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) le
3762
3944
  function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
3763
3945
 
3764
3946
  function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
3765
- var log$3 = Logger.scope('Conversation');
3947
+ var log$3 = Logger.scope("Conversation");
3766
3948
  var fieldMappings = {
3767
- lastMessage: 'lastMessage',
3768
- attributes: 'attributes',
3769
- createdBy: 'createdBy',
3770
- dateCreated: 'dateCreated',
3771
- dateUpdated: 'dateUpdated',
3772
- friendlyName: 'friendlyName',
3773
- lastConsumedMessageIndex: 'lastConsumedMessageIndex',
3774
- notificationLevel: 'notificationLevel',
3775
- sid: 'sid',
3776
- status: 'status',
3777
- uniqueName: 'uniqueName',
3778
- state: 'state'
3949
+ lastMessage: "lastMessage",
3950
+ attributes: "attributes",
3951
+ createdBy: "createdBy",
3952
+ dateCreated: "dateCreated",
3953
+ dateUpdated: "dateUpdated",
3954
+ friendlyName: "friendlyName",
3955
+ lastConsumedMessageIndex: "lastConsumedMessageIndex",
3956
+ notificationLevel: "notificationLevel",
3957
+ sid: "sid",
3958
+ status: "status",
3959
+ uniqueName: "uniqueName",
3960
+ state: "state",
3961
+ bindings: "bindings"
3779
3962
  };
3780
3963
 
3781
3964
  function parseTime(timeString) {
@@ -3803,6 +3986,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3803
3986
  * @internal
3804
3987
  */
3805
3988
  function Conversation(descriptor, sid, links, configuration, services) {
3989
+ var _descriptor$bindings;
3990
+
3806
3991
  var _this;
3807
3992
 
3808
3993
  _classCallCheck__default['default'](this, Conversation);
@@ -3823,19 +4008,20 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3823
4008
  try {
3824
4009
  JSON.stringify(attributes);
3825
4010
  } catch (e) {
3826
- throw new Error('Attributes must be a valid JSON object.');
4011
+ throw new Error("Attributes must be a valid JSON object.");
3827
4012
  }
3828
4013
 
3829
4014
  _this.entityName = descriptor.channel;
3830
4015
  _this.channelState = {
3831
4016
  uniqueName: uniqueName,
3832
- status: 'notParticipating',
4017
+ status: "notParticipating",
3833
4018
  attributes: attributes,
3834
4019
  createdBy: createdBy,
3835
4020
  dateCreated: dateCreated,
3836
4021
  dateUpdated: dateUpdated,
3837
4022
  friendlyName: friendlyName,
3838
- lastReadMessageIndex: lastReadMessageIndex
4023
+ lastReadMessageIndex: lastReadMessageIndex,
4024
+ bindings: (_descriptor$bindings = descriptor.bindings) !== null && _descriptor$bindings !== void 0 ? _descriptor$bindings : {}
3839
4025
  };
3840
4026
 
3841
4027
  if (descriptor.notificationLevel) {
@@ -3848,25 +4034,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3848
4034
  _this.participants = new Map();
3849
4035
  _this.participantsEntity = new Participants(_assertThisInitialized__default['default'](_this), _this.participants, participantsLinks, _this.configuration, _this.services);
3850
4036
 
3851
- _this.participantsEntity.on('participantJoined', _this.emit.bind(_assertThisInitialized__default['default'](_this), 'participantJoined'));
4037
+ _this.participantsEntity.on("participantJoined", function (participant) {
4038
+ return _this.emit("participantJoined", participant);
4039
+ });
3852
4040
 
3853
- _this.participantsEntity.on('participantLeft', _this.emit.bind(_assertThisInitialized__default['default'](_this), 'participantLeft'));
4041
+ _this.participantsEntity.on("participantLeft", function (participant) {
4042
+ return _this.emit("participantLeft", participant);
4043
+ });
3854
4044
 
3855
- _this.participantsEntity.on('participantUpdated', function (args) {
3856
- return _this.emit('participantUpdated', args);
4045
+ _this.participantsEntity.on("participantUpdated", function (args) {
4046
+ return _this.emit("participantUpdated", args);
3857
4047
  });
3858
4048
 
3859
4049
  _this.messagesEntity = new Messages(_assertThisInitialized__default['default'](_this), configuration, services);
3860
4050
 
3861
- _this.messagesEntity.on('messageAdded', function (message) {
4051
+ _this.messagesEntity.on("messageAdded", function (message) {
3862
4052
  return _this._onMessageAdded(message);
3863
4053
  });
3864
4054
 
3865
- _this.messagesEntity.on('messageUpdated', function (args) {
3866
- return _this.emit('messageUpdated', args);
4055
+ _this.messagesEntity.on("messageUpdated", function (args) {
4056
+ return _this.emit("messageUpdated", args);
3867
4057
  });
3868
4058
 
3869
- _this.messagesEntity.on('messageRemoved', _this.emit.bind(_assertThisInitialized__default['default'](_this), 'messageRemoved'));
4059
+ _this.messagesEntity.on("messageRemoved", function (message) {
4060
+ return _this.emit("messageRemoved", message);
4061
+ });
3870
4062
 
3871
4063
  return _this;
3872
4064
  }
@@ -3931,7 +4123,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3931
4123
  }, {
3932
4124
  key: "createdBy",
3933
4125
  get: function get() {
3934
- return this.channelState.createdBy;
4126
+ var _this$channelState$cr;
4127
+
4128
+ return (_this$channelState$cr = this.channelState.createdBy) !== null && _this$channelState$cr !== void 0 ? _this$channelState$cr : "";
3935
4129
  }
3936
4130
  /**
3937
4131
  * Custom attributes of the conversation.
@@ -3958,7 +4152,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3958
4152
  }, {
3959
4153
  key: "lastMessage",
3960
4154
  get: function get() {
3961
- return this.channelState.lastMessage;
4155
+ var _this$channelState$la;
4156
+
4157
+ return (_this$channelState$la = this.channelState.lastMessage) !== null && _this$channelState$la !== void 0 ? _this$channelState$la : undefined;
3962
4158
  }
3963
4159
  /**
3964
4160
  * User notification level for this conversation.
@@ -3967,7 +4163,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3967
4163
  }, {
3968
4164
  key: "notificationLevel",
3969
4165
  get: function get() {
3970
- return this.channelState.notificationLevel;
4166
+ var _this$channelState$no;
4167
+
4168
+ return (_this$channelState$no = this.channelState.notificationLevel) !== null && _this$channelState$no !== void 0 ? _this$channelState$no : "default";
4169
+ }
4170
+ }, {
4171
+ key: "bindings",
4172
+ get: function get() {
4173
+ return this.channelState.bindings;
3971
4174
  }
3972
4175
  }, {
3973
4176
  key: "limits",
@@ -3997,16 +4200,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3997
4200
 
3998
4201
  return this.entityPromise = (_this$entityPromise = this.entityPromise) !== null && _this$entityPromise !== void 0 ? _this$entityPromise : this.services.syncClient.document({
3999
4202
  id: this.entityName,
4000
- mode: 'open_existing'
4203
+ mode: "open_existing"
4001
4204
  }).then(function (entity) {
4002
4205
  _this2.entity = entity;
4003
4206
 
4004
- _this2.entity.on('updated', function (args) {
4207
+ _this2.entity.on("updated", function (args) {
4005
4208
  _this2._update(args.data);
4006
4209
  });
4007
4210
 
4008
- _this2.entity.on('removed', function () {
4009
- return _this2.emit('removed', _this2);
4211
+ _this2.entity.on("removed", function () {
4212
+ return _this2.emit("removed", _this2);
4010
4213
  });
4011
4214
 
4012
4215
  _this2._update(_this2.entity.data);
@@ -4016,11 +4219,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4016
4219
  _this2.entity = null;
4017
4220
  _this2.entityPromise = null;
4018
4221
 
4019
- if (_this2.services.syncClient.connectionState != 'disconnected') {
4020
- log$3.error('Failed to get conversation object', err);
4222
+ if (_this2.services.syncClient.connectionState != "disconnected") {
4223
+ log$3.error("Failed to get conversation object", err);
4021
4224
  }
4022
4225
 
4023
- log$3.debug('ERROR: Failed to get conversation object', err);
4226
+ log$3.debug("ERROR: Failed to get conversation object", err);
4024
4227
  throw err;
4025
4228
  });
4026
4229
  }
@@ -4035,7 +4238,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4035
4238
  key: "_subscribeStreams",
4036
4239
  value: function () {
4037
4240
  var _subscribeStreams2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
4038
- var messagesObjectName, rosterObjectName;
4241
+ var _this$entity, _this$entity2, _this$entity3, messagesObjectName, rosterObjectName;
4242
+
4039
4243
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
4040
4244
  while (1) {
4041
4245
  switch (_context.prev = _context.next) {
@@ -4045,9 +4249,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4045
4249
  return this._subscribe();
4046
4250
 
4047
4251
  case 3:
4048
- log$3.trace('_subscribeStreams, this.entity.data=', this.entity.data);
4049
- messagesObjectName = this.entity.data.messages;
4050
- rosterObjectName = this.entity.data.roster;
4252
+ log$3.trace("_subscribeStreams, this.entity.data=", (_this$entity = this.entity) === null || _this$entity === void 0 ? void 0 : _this$entity.data);
4253
+ messagesObjectName = (_this$entity2 = this.entity) === null || _this$entity2 === void 0 ? void 0 : _this$entity2.data.messages;
4254
+ rosterObjectName = (_this$entity3 = this.entity) === null || _this$entity3 === void 0 ? void 0 : _this$entity3.data.roster;
4051
4255
  _context.next = 8;
4052
4256
  return Promise.all([this.messagesEntity.subscribe(messagesObjectName), this.participantsEntity.subscribe(rosterObjectName)]);
4053
4257
 
@@ -4059,11 +4263,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4059
4263
  _context.prev = 10;
4060
4264
  _context.t0 = _context["catch"](0);
4061
4265
 
4062
- if (this.services.syncClient.connectionState !== 'disconnected') {
4063
- log$3.error('Failed to subscribe on conversation objects', this.sid, _context.t0);
4266
+ if (this.services.syncClient.connectionState !== "disconnected") {
4267
+ log$3.error("Failed to subscribe on conversation objects", this.sid, _context.t0);
4064
4268
  }
4065
4269
 
4066
- log$3.debug('ERROR: Failed to subscribe on conversation objects', this.sid, _context.t0);
4270
+ log$3.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context.t0);
4067
4271
  throw _context.t0;
4068
4272
 
4069
4273
  case 15:
@@ -4140,19 +4344,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4140
4344
 
4141
4345
  this.channelState.status = status;
4142
4346
 
4143
- if (status === 'joined') {
4347
+ if (status === "joined") {
4144
4348
  this._subscribeStreams().catch(function (err) {
4145
- log$3.debug('ERROR while setting conversation status ' + status, err);
4349
+ log$3.debug("ERROR while setting conversation status " + status, err);
4146
4350
 
4147
- if (_this3.services.syncClient.connectionState !== 'disconnected') {
4351
+ if (_this3.services.syncClient.connectionState !== "disconnected") {
4148
4352
  throw err;
4149
4353
  }
4150
4354
  });
4151
4355
  } else if (this.entityPromise) {
4152
4356
  this._unsubscribe().catch(function (err) {
4153
- log$3.debug('ERROR while setting conversation status ' + status, err);
4357
+ log$3.debug("ERROR while setting conversation status " + status, err);
4154
4358
 
4155
- if (_this3.services.syncClient.connectionState !== 'disconnected') {
4359
+ if (_this3.services.syncClient.connectionState !== "disconnected") {
4156
4360
  throw err;
4157
4361
  }
4158
4362
  });
@@ -4176,9 +4380,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4176
4380
  * @internal
4177
4381
  */
4178
4382
  function _update(update) {
4179
- var _update$lastMessage, _update$lastMessage2, _this$channelState$la, _this$channelState$la2, _this$channelState$lo;
4383
+ var _update$lastMessage, _update$lastMessage2, _this$channelState$la2, _this$channelState$la3, _this$channelState$lo;
4180
4384
 
4181
- log$3.trace('_update', update);
4385
+ log$3.trace("_update", update);
4182
4386
  Conversation.preprocessUpdate(update, this.sid);
4183
4387
  var updateReasons = new Set();
4184
4388
 
@@ -4192,7 +4396,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4192
4396
 
4193
4397
  switch (localKey) {
4194
4398
  case fieldMappings.status:
4195
- if (!update.status || update.status === 'unknown' || this.channelState.status === update.status) {
4399
+ if (!update.status || update.status === "unknown" || this.channelState.status === update.status) {
4196
4400
  break;
4197
4401
  }
4198
4402
 
@@ -4215,7 +4419,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4215
4419
  }
4216
4420
 
4217
4421
  this.channelState.lastReadMessageIndex = update.lastConsumedMessageIndex;
4218
- updateReasons.add('lastReadMessageIndex');
4422
+ updateReasons.add("lastReadMessageIndex");
4219
4423
  break;
4220
4424
 
4221
4425
  case fieldMappings.lastMessage:
@@ -4232,7 +4436,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4232
4436
  updateReasons.add(localKey);
4233
4437
  }
4234
4438
 
4235
- if (((_update$lastMessage2 = update.lastMessage) === null || _update$lastMessage2 === void 0 ? void 0 : _update$lastMessage2.timestamp) !== undefined && ((_this$channelState$la = this.channelState.lastMessage) === null || _this$channelState$la === void 0 ? void 0 : (_this$channelState$la2 = _this$channelState$la.dateCreated) === null || _this$channelState$la2 === void 0 ? void 0 : _this$channelState$la2.getTime()) !== update.lastMessage.timestamp.getTime()) {
4439
+ if (((_update$lastMessage2 = update.lastMessage) === null || _update$lastMessage2 === void 0 ? void 0 : _update$lastMessage2.timestamp) !== undefined && ((_this$channelState$la2 = this.channelState.lastMessage) === null || _this$channelState$la2 === void 0 ? void 0 : (_this$channelState$la3 = _this$channelState$la2.dateCreated) === null || _this$channelState$la3 === void 0 ? void 0 : _this$channelState$la3.getTime()) !== update.lastMessage.timestamp.getTime()) {
4236
4440
  this.channelState.lastMessage.dateCreated = update.lastMessage.timestamp;
4237
4441
  updateReasons.add(localKey);
4238
4442
  }
@@ -4258,6 +4462,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4258
4462
  updateReasons.add(localKey);
4259
4463
  break;
4260
4464
 
4465
+ case fieldMappings.bindings:
4466
+ if (isEqual__default['default'](this.channelState.bindings, update.bindings)) {
4467
+ break;
4468
+ }
4469
+
4470
+ this.channelState.bindings = update.bindings;
4471
+ updateReasons.add(localKey);
4472
+ break;
4473
+
4261
4474
  default:
4262
4475
  var isDate = update[key] instanceof Date;
4263
4476
  var keysMatchAsDates = isDate && ((_this$channelState$lo = this.channelState[localKey]) === null || _this$channelState$lo === void 0 ? void 0 : _this$channelState$lo.getTime()) === update[key].getTime();
@@ -4273,7 +4486,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4273
4486
  }
4274
4487
 
4275
4488
  if (updateReasons.size > 0) {
4276
- this.emit('updated', {
4489
+ this.emit("updated", {
4277
4490
  conversation: this,
4278
4491
  updateReasons: _toConsumableArray__default['default'](updateReasons)
4279
4492
  });
@@ -4305,7 +4518,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4305
4518
  _iterator.f();
4306
4519
  }
4307
4520
 
4308
- this.emit('messageAdded', message);
4521
+ this.emit("messageAdded", message);
4309
4522
  }
4310
4523
  }, {
4311
4524
  key: "_setLastReadMessageIndex",
@@ -4317,7 +4530,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4317
4530
  switch (_context3.prev = _context3.next) {
4318
4531
  case 0:
4319
4532
  _context3.next = 2;
4320
- return this.services.commandExecutor.mutateResource('post', "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
4533
+ return this.services.commandExecutor.mutateResource("post", "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
4321
4534
  last_read_message_index: index
4322
4535
  });
4323
4536
 
@@ -4353,7 +4566,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4353
4566
  while (1) {
4354
4567
  switch (_context4.prev = _context4.next) {
4355
4568
  case 0:
4356
- return _context4.abrupt("return", this.participantsEntity.add(identity, attributes));
4569
+ return _context4.abrupt("return", this.participantsEntity.add(identity, attributes !== null && attributes !== void 0 ? attributes : {}));
4357
4570
 
4358
4571
  case 1:
4359
4572
  case "end":
@@ -4374,19 +4587,25 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4374
4587
  * @param proxyAddress Proxy (Twilio) address of the participant.
4375
4588
  * @param address User address of the participant.
4376
4589
  * @param attributes Attributes to be attached to the participant.
4590
+ * @param bindingOptions Options for adding email participants - name and CC/To level.
4377
4591
  */
4378
4592
 
4379
4593
  }, {
4380
4594
  key: "addNonChatParticipant",
4381
4595
  value: function () {
4382
- var _addNonChatParticipant = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(proxyAddress, address, attributes) {
4596
+ var _addNonChatParticipant = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(proxyAddress, address) {
4597
+ var attributes,
4598
+ bindingOptions,
4599
+ _args5 = arguments;
4383
4600
  return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
4384
4601
  while (1) {
4385
4602
  switch (_context5.prev = _context5.next) {
4386
4603
  case 0:
4387
- return _context5.abrupt("return", this.participantsEntity.addNonChatParticipant(proxyAddress, address, attributes));
4604
+ attributes = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
4605
+ bindingOptions = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
4606
+ return _context5.abrupt("return", this.participantsEntity.addNonChatParticipant(proxyAddress, address, attributes !== null && attributes !== void 0 ? attributes : {}, bindingOptions !== null && bindingOptions !== void 0 ? bindingOptions : {}));
4388
4607
 
4389
- case 1:
4608
+ case 3:
4390
4609
  case "end":
4391
4610
  return _context5.stop();
4392
4611
  }
@@ -4394,7 +4613,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4394
4613
  }, _callee5, this);
4395
4614
  }));
4396
4615
 
4397
- function addNonChatParticipant(_x4, _x5, _x6) {
4616
+ function addNonChatParticipant(_x4, _x5) {
4398
4617
  return _addNonChatParticipant.apply(this, arguments);
4399
4618
  }
4400
4619
 
@@ -4420,7 +4639,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4420
4639
  return this._subscribeStreams();
4421
4640
 
4422
4641
  case 2:
4423
- if (!(index < this.lastReadMessageIndex)) {
4642
+ if (!(index < (this.lastReadMessageIndex || 0))) {
4424
4643
  _context6.next = 6;
4425
4644
  break;
4426
4645
  }
@@ -4446,7 +4665,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4446
4665
  }, _callee6, this);
4447
4666
  }));
4448
4667
 
4449
- function advanceLastReadMessageIndex(_x7) {
4668
+ function advanceLastReadMessageIndex(_x6) {
4450
4669
  return _advanceLastReadMessageIndex.apply(this, arguments);
4451
4670
  }
4452
4671
 
@@ -4465,7 +4684,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4465
4684
  switch (_context7.prev = _context7.next) {
4466
4685
  case 0:
4467
4686
  _context7.next = 2;
4468
- return this.services.commandExecutor.mutateResource('delete', this.links.self);
4687
+ return this.services.commandExecutor.mutateResource("delete", this.links.self);
4469
4688
 
4470
4689
  case 2:
4471
4690
  return _context7.abrupt("return", this);
@@ -4547,7 +4766,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4547
4766
  }, _callee9, this);
4548
4767
  }));
4549
4768
 
4550
- function getMessages(_x8, _x9, _x10) {
4769
+ function getMessages(_x7, _x8, _x9) {
4551
4770
  return _getMessages.apply(this, arguments);
4552
4771
  }
4553
4772
 
@@ -4600,6 +4819,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4600
4819
  key: "getParticipantsCount",
4601
4820
  value: function () {
4602
4821
  var _getParticipantsCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
4822
+ var _response$body$partic;
4823
+
4603
4824
  var url, response;
4604
4825
  return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
4605
4826
  while (1) {
@@ -4611,7 +4832,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4611
4832
 
4612
4833
  case 3:
4613
4834
  response = _context11.sent;
4614
- return _context11.abrupt("return", response.body.participants_count);
4835
+ return _context11.abrupt("return", (_response$body$partic = response.body.participants_count) !== null && _response$body$partic !== void 0 ? _response$body$partic : 0);
4615
4836
 
4616
4837
  case 5:
4617
4838
  case "end":
@@ -4650,7 +4871,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4650
4871
  }, _callee12, this);
4651
4872
  }));
4652
4873
 
4653
- function getParticipantBySid(_x11) {
4874
+ function getParticipantBySid(_x10) {
4654
4875
  return _getParticipantBySid.apply(this, arguments);
4655
4876
  }
4656
4877
 
@@ -4664,14 +4885,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4664
4885
  }, {
4665
4886
  key: "getParticipantByIdentity",
4666
4887
  value: function () {
4667
- var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee13(identity) {
4888
+ var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee13() {
4889
+ var identity,
4890
+ _args13 = arguments;
4668
4891
  return _regeneratorRuntime__default['default'].wrap(function _callee13$(_context13) {
4669
4892
  while (1) {
4670
4893
  switch (_context13.prev = _context13.next) {
4671
4894
  case 0:
4672
- return _context13.abrupt("return", this.participantsEntity.getParticipantByIdentity(identity));
4895
+ identity = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "";
4896
+ return _context13.abrupt("return", this.participantsEntity.getParticipantByIdentity(identity !== null && identity !== void 0 ? identity : ""));
4673
4897
 
4674
- case 1:
4898
+ case 2:
4675
4899
  case "end":
4676
4900
  return _context13.stop();
4677
4901
  }
@@ -4679,7 +4903,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4679
4903
  }, _callee13, this);
4680
4904
  }));
4681
4905
 
4682
- function getParticipantByIdentity(_x12) {
4906
+ function getParticipantByIdentity() {
4683
4907
  return _getParticipantByIdentity.apply(this, arguments);
4684
4908
  }
4685
4909
 
@@ -4700,6 +4924,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4700
4924
  key: "getMessagesCount",
4701
4925
  value: function () {
4702
4926
  var _getMessagesCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee14() {
4927
+ var _response$body$messag;
4928
+
4703
4929
  var url, response;
4704
4930
  return _regeneratorRuntime__default['default'].wrap(function _callee14$(_context14) {
4705
4931
  while (1) {
@@ -4711,7 +4937,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4711
4937
 
4712
4938
  case 3:
4713
4939
  response = _context14.sent;
4714
- return _context14.abrupt("return", response.body.messages_count);
4940
+ return _context14.abrupt("return", (_response$body$messag = response.body.messages_count) !== null && _response$body$messag !== void 0 ? _response$body$messag : 0);
4715
4941
 
4716
4942
  case 5:
4717
4943
  case "end":
@@ -4764,12 +4990,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4764
4990
  break;
4765
4991
  }
4766
4992
 
4767
- throw new Error('Conversation was not found in the user conversations list');
4993
+ throw new Error("Conversation was not found in the user conversations list");
4768
4994
 
4769
4995
  case 6:
4770
4996
  unreadMessageCount = response.body.unread_messages_count;
4771
4997
 
4772
- if (!(typeof unreadMessageCount === 'number')) {
4998
+ if (!(typeof unreadMessageCount === "number")) {
4773
4999
  _context15.next = 9;
4774
5000
  break;
4775
5001
  }
@@ -4806,7 +5032,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4806
5032
  switch (_context16.prev = _context16.next) {
4807
5033
  case 0:
4808
5034
  _context16.next = 2;
4809
- return this.services.commandExecutor.mutateResource('post', this.links.participants, {
5035
+ return this.services.commandExecutor.mutateResource("post", this.links.participants, {
4810
5036
  identity: this.configuration.userIdentity
4811
5037
  });
4812
5038
 
@@ -4839,13 +5065,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4839
5065
  while (1) {
4840
5066
  switch (_context17.prev = _context17.next) {
4841
5067
  case 0:
4842
- if (!(this.channelState.status === 'joined')) {
5068
+ if (!(this.channelState.status === "joined")) {
4843
5069
  _context17.next = 3;
4844
5070
  break;
4845
5071
  }
4846
5072
 
4847
5073
  _context17.next = 3;
4848
- return this.services.commandExecutor.mutateResource('delete', "".concat(this.links.participants, "/").concat(this.configuration.userIdentity));
5074
+ return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(this.configuration.userIdentity));
4849
5075
 
4850
5076
  case 3:
4851
5077
  return _context17.abrupt("return", this);
@@ -4870,6 +5096,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4870
5096
  * @param participant Identity, SID or the participant object to remove.
4871
5097
  */
4872
5098
 
5099
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
5100
+ // @ts-ignore TODO: fix validateTypesAsync typing
5101
+
4873
5102
  }, {
4874
5103
  key: "removeParticipant",
4875
5104
  value: function () {
@@ -4879,7 +5108,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4879
5108
  switch (_context18.prev = _context18.next) {
4880
5109
  case 0:
4881
5110
  _context18.next = 2;
4882
- return this.participantsEntity.remove(typeof participant === 'string' ? participant : participant.sid);
5111
+ return this.participantsEntity.remove(typeof participant === "string" ? participant : participant.sid);
4883
5112
 
4884
5113
  case 2:
4885
5114
  case "end":
@@ -4889,7 +5118,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4889
5118
  }, _callee18, this);
4890
5119
  }));
4891
5120
 
4892
- function removeParticipant(_x13) {
5121
+ function removeParticipant(_x11) {
4893
5122
  return _removeParticipant.apply(this, arguments);
4894
5123
  }
4895
5124
 
@@ -4908,13 +5137,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4908
5137
  key: "sendMessage",
4909
5138
  value: function () {
4910
5139
  var _sendMessage = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(message, messageAttributes, emailOptions) {
4911
- var _response, response;
5140
+ var _parseToNumber2;
5141
+
5142
+ var _parseToNumber, _response, response;
4912
5143
 
4913
5144
  return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
4914
5145
  while (1) {
4915
5146
  switch (_context19.prev = _context19.next) {
4916
5147
  case 0:
4917
- if (!(typeof message === 'string' || message === null)) {
5148
+ if (!(typeof message === "string" || message === null)) {
4918
5149
  _context19.next = 5;
4919
5150
  break;
4920
5151
  }
@@ -4924,7 +5155,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4924
5155
 
4925
5156
  case 3:
4926
5157
  _response = _context19.sent;
4927
- return _context19.abrupt("return", parseToNumber(_response.index));
5158
+ return _context19.abrupt("return", (_parseToNumber = parseToNumber(_response.index)) !== null && _parseToNumber !== void 0 ? _parseToNumber : 0);
4928
5159
 
4929
5160
  case 5:
4930
5161
  _context19.next = 7;
@@ -4932,7 +5163,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4932
5163
 
4933
5164
  case 7:
4934
5165
  response = _context19.sent;
4935
- return _context19.abrupt("return", parseToNumber(response.index));
5166
+ return _context19.abrupt("return", (_parseToNumber2 = parseToNumber(response.index)) !== null && _parseToNumber2 !== void 0 ? _parseToNumber2 : 0);
4936
5167
 
4937
5168
  case 9:
4938
5169
  case "end":
@@ -4942,7 +5173,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4942
5173
  }, _callee19, this);
4943
5174
  }));
4944
5175
 
4945
- function sendMessage(_x14, _x15, _x16) {
5176
+ function sendMessage(_x12, _x13, _x14) {
4946
5177
  return _sendMessage.apply(this, arguments);
4947
5178
  }
4948
5179
 
@@ -4951,6 +5182,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4951
5182
  /**
4952
5183
  * New interface to prepare for sending a message.
4953
5184
  * Use instead of `sendMessage`.
5185
+ * @return A MessageBuilder to help set all message sending options.
4954
5186
  */
4955
5187
 
4956
5188
  }, {
@@ -5057,7 +5289,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5057
5289
  switch (_context22.prev = _context22.next) {
5058
5290
  case 0:
5059
5291
  _context22.next = 2;
5060
- return this.services.commandExecutor.mutateResource('post', "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
5292
+ return this.services.commandExecutor.mutateResource("post", "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
5061
5293
  notification_level: notificationLevel
5062
5294
  });
5063
5295
 
@@ -5069,7 +5301,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5069
5301
  }, _callee22, this);
5070
5302
  }));
5071
5303
 
5072
- function setUserNotificationLevel(_x17) {
5304
+ function setUserNotificationLevel(_x15) {
5073
5305
  return _setUserNotificationLevel.apply(this, arguments);
5074
5306
  }
5075
5307
 
@@ -5099,7 +5331,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5099
5331
  switch (_context23.prev = _context23.next) {
5100
5332
  case 0:
5101
5333
  _context23.next = 2;
5102
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
5334
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
5103
5335
  attributes: attributes !== undefined ? JSON.stringify(attributes) : undefined
5104
5336
  });
5105
5337
 
@@ -5114,7 +5346,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5114
5346
  }, _callee23, this);
5115
5347
  }));
5116
5348
 
5117
- function updateAttributes(_x18) {
5349
+ function updateAttributes(_x16) {
5118
5350
  return _updateAttributes.apply(this, arguments);
5119
5351
  }
5120
5352
 
@@ -5139,7 +5371,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5139
5371
  }
5140
5372
 
5141
5373
  _context24.next = 3;
5142
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
5374
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
5143
5375
  friendly_name: friendlyName
5144
5376
  });
5145
5377
 
@@ -5154,7 +5386,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5154
5386
  }, _callee24, this);
5155
5387
  }));
5156
5388
 
5157
- function updateFriendlyName(_x19) {
5389
+ function updateFriendlyName(_x17) {
5158
5390
  return _updateFriendlyName.apply(this, arguments);
5159
5391
  }
5160
5392
 
@@ -5189,7 +5421,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5189
5421
  }, _callee25, this);
5190
5422
  }));
5191
5423
 
5192
- function updateLastReadMessageIndex(_x20) {
5424
+ function updateLastReadMessageIndex(_x18) {
5193
5425
  return _updateLastReadMessageIndex.apply(this, arguments);
5194
5426
  }
5195
5427
 
@@ -5214,11 +5446,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5214
5446
  }
5215
5447
 
5216
5448
  if (!uniqueName) {
5217
- uniqueName = '';
5449
+ uniqueName = "";
5218
5450
  }
5219
5451
 
5220
5452
  _context26.next = 4;
5221
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
5453
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
5222
5454
  unique_name: uniqueName
5223
5455
  });
5224
5456
 
@@ -5233,7 +5465,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5233
5465
  }, _callee26, this);
5234
5466
  }));
5235
5467
 
5236
- function updateUniqueName(_x21) {
5468
+ function updateUniqueName(_x19) {
5237
5469
  return _updateUniqueName.apply(this, arguments);
5238
5470
  }
5239
5471
 
@@ -5243,13 +5475,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5243
5475
  key: "preprocessUpdate",
5244
5476
  value: function preprocessUpdate(update, conversationSid) {
5245
5477
  try {
5246
- if (typeof update.attributes === 'string') {
5478
+ if (typeof update.attributes === "string") {
5247
5479
  update.attributes = JSON.parse(update.attributes);
5248
5480
  } else if (update.attributes) {
5249
5481
  JSON.stringify(update.attributes);
5250
5482
  }
5251
5483
  } catch (e) {
5252
- log$3.warn('Retrieved malformed attributes from the server for conversation: ' + conversationSid);
5484
+ log$3.warn("Retrieved malformed attributes from the server for conversation: " + conversationSid);
5253
5485
  update.attributes = {};
5254
5486
  }
5255
5487
 
@@ -5258,7 +5490,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5258
5490
  update.dateCreated = new Date(update.dateCreated);
5259
5491
  }
5260
5492
  } catch (e) {
5261
- log$3.warn('Retrieved malformed dateCreated from the server for conversation: ' + conversationSid);
5493
+ log$3.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
5262
5494
  delete update.dateCreated;
5263
5495
  }
5264
5496
 
@@ -5267,7 +5499,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5267
5499
  update.dateUpdated = new Date(update.dateUpdated);
5268
5500
  }
5269
5501
  } catch (e) {
5270
- log$3.warn('Retrieved malformed dateUpdated from the server for conversation: ' + conversationSid);
5502
+ log$3.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
5271
5503
  delete update.dateUpdated;
5272
5504
  }
5273
5505
 
@@ -5276,7 +5508,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5276
5508
  update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);
5277
5509
  }
5278
5510
  } catch (e) {
5279
- log$3.warn('Retrieved malformed lastMessage.timestamp from the server for conversation: ' + conversationSid);
5511
+ log$3.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: " + conversationSid);
5280
5512
  delete update.lastMessage.timestamp;
5281
5513
  }
5282
5514
  }
@@ -5285,33 +5517,33 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5285
5517
  return Conversation;
5286
5518
  }(replayEventEmitter.ReplayEventEmitter);
5287
5519
 
5288
- _defineProperty__default['default'](Conversation, "participantJoined", 'participantJoined');
5520
+ _defineProperty__default['default'](Conversation, "participantJoined", "participantJoined");
5289
5521
 
5290
- _defineProperty__default['default'](Conversation, "participantLeft", 'participantLeft');
5522
+ _defineProperty__default['default'](Conversation, "participantLeft", "participantLeft");
5291
5523
 
5292
- _defineProperty__default['default'](Conversation, "participantUpdated", 'participantUpdated');
5524
+ _defineProperty__default['default'](Conversation, "participantUpdated", "participantUpdated");
5293
5525
 
5294
- _defineProperty__default['default'](Conversation, "messageAdded", 'messageAdded');
5526
+ _defineProperty__default['default'](Conversation, "messageAdded", "messageAdded");
5295
5527
 
5296
- _defineProperty__default['default'](Conversation, "messageRemoved", 'messageRemoved');
5528
+ _defineProperty__default['default'](Conversation, "messageRemoved", "messageRemoved");
5297
5529
 
5298
- _defineProperty__default['default'](Conversation, "messageUpdated", 'messageUpdated');
5530
+ _defineProperty__default['default'](Conversation, "messageUpdated", "messageUpdated");
5299
5531
 
5300
- _defineProperty__default['default'](Conversation, "typingEnded", 'typingEnded');
5532
+ _defineProperty__default['default'](Conversation, "typingEnded", "typingEnded");
5301
5533
 
5302
- _defineProperty__default['default'](Conversation, "typingStarted", 'typingStarted');
5534
+ _defineProperty__default['default'](Conversation, "typingStarted", "typingStarted");
5303
5535
 
5304
- _defineProperty__default['default'](Conversation, "updated", 'updated');
5536
+ _defineProperty__default['default'](Conversation, "updated", "updated");
5305
5537
 
5306
- _defineProperty__default['default'](Conversation, "removed", 'removed');
5538
+ _defineProperty__default['default'](Conversation, "removed", "removed");
5307
5539
 
5308
- __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, ['undefined', 'string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
5540
+ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalAttributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
5309
5541
 
5310
- __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, ['undefined', 'string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
5542
+ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, optionalAttributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
5311
5543
 
5312
5544
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
5313
5545
 
5314
- __decorate([declarativeTypeValidator.validateTypesAsync(['undefined', declarativeTypeValidator.nonNegativeInteger], ['undefined', declarativeTypeValidator.nonNegativeInteger], ['undefined', declarativeTypeValidator.literal('backwards', 'forward')]), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Number, String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getMessages", null);
5546
+ __decorate([declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.literal("backwards", "forward")]), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Number, String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getMessages", null);
5315
5547
 
5316
5548
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getParticipantBySid", null);
5317
5549
 
@@ -5319,33 +5551,33 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
5319
5551
 
5320
5552
  __decorate([declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, Participant]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "removeParticipant", null);
5321
5553
 
5322
- __decorate([declarativeTypeValidator.validateTypesAsync(['string', declarativeTypeValidator.literal(null), // Wrapping it into a custom rule is necessary because the FormData class is not available on initialization.
5554
+ __decorate([declarativeTypeValidator.validateTypesAsync(["string", declarativeTypeValidator.literal(null), // Wrapping it into a custom rule is necessary because the FormData class is not available on initialization.
5323
5555
  declarativeTypeValidator.custom(function (value) {
5324
- return [value instanceof FormData, 'an instance of FormData'];
5325
- }), declarativeTypeValidator.objectSchema('media options', {
5556
+ return [value instanceof FormData, "an instance of FormData"];
5557
+ }), declarativeTypeValidator.objectSchema("media options", {
5326
5558
  contentType: declarativeTypeValidator.nonEmptyString,
5327
5559
  media: declarativeTypeValidator.custom(function (value) {
5328
- var isValid = typeof value === 'string' && value.length > 0 || value instanceof Uint8Array || value instanceof ArrayBuffer;
5560
+ var isValid = typeof value === "string" && value.length > 0 || value instanceof Uint8Array || value instanceof ArrayBuffer;
5329
5561
 
5330
- if (typeof Blob === 'function') {
5562
+ if (typeof Blob === "function") {
5331
5563
  isValid = isValid || value instanceof Blob;
5332
5564
  }
5333
5565
 
5334
- return [isValid, 'a non-empty string, an instance of Buffer or an instance of Blob'];
5566
+ return [isValid, "a non-empty string, an instance of Buffer or an instance of Blob"];
5335
5567
  })
5336
- })], ['undefined', 'string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)], ['undefined', declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema('email attributes', {
5337
- subject: [declarativeTypeValidator.nonEmptyString, 'undefined']
5568
+ })], optionalAttributesValidator, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
5569
+ subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
5338
5570
  })]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
5339
5571
 
5340
- __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('default', 'muted')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
5572
+ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
5341
5573
 
5342
- __decorate([declarativeTypeValidator.validateTypesAsync(['string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
5574
+ __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
5343
5575
 
5344
- __decorate([declarativeTypeValidator.validateTypesAsync(['string']), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
5576
+ __decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
5345
5577
 
5346
5578
  __decorate([declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.literal(null), declarativeTypeValidator.nonNegativeInteger]), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateLastReadMessageIndex", null);
5347
5579
 
5348
- __decorate([declarativeTypeValidator.validateTypesAsync(['string', declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateUniqueName", null);
5580
+ __decorate([declarativeTypeValidator.validateTypesAsync(["string", declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateUniqueName", null);
5349
5581
 
5350
5582
  var Deferred = /*#__PURE__*/function () {
5351
5583
  function Deferred() {
@@ -5399,7 +5631,7 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
5399
5631
  function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
5400
5632
 
5401
5633
  function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
5402
- var log$2 = Logger.scope('Conversations');
5634
+ var log$2 = Logger.scope("Conversations");
5403
5635
  /**
5404
5636
  * Represents conversations collection
5405
5637
  * {@see Conversation}
@@ -5441,12 +5673,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5441
5673
  while (1) {
5442
5674
  switch (_context.prev = _context.next) {
5443
5675
  case 0:
5444
- attributes = typeof (options === null || options === void 0 ? void 0 : options.attributes) !== 'undefined' ? options.attributes : {};
5676
+ attributes = typeof (options === null || options === void 0 ? void 0 : options.attributes) !== "undefined" ? options.attributes : {};
5445
5677
  _context.next = 3;
5446
- return this.services.commandExecutor.mutateResource('post', this.configuration.links.conversations, {
5678
+ return this.services.commandExecutor.mutateResource("post", this.configuration.links.conversations, {
5447
5679
  friendly_name: options.friendlyName,
5448
5680
  unique_name: options.uniqueName,
5449
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
5681
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
5450
5682
  });
5451
5683
 
5452
5684
  case 3:
@@ -5472,12 +5704,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5472
5704
  case 12:
5473
5705
  conversation = new Conversation({
5474
5706
  channel: conversationDocument,
5475
- entityName: null,
5476
- uniqueName: null,
5707
+ entityName: "",
5708
+ uniqueName: "",
5477
5709
  attributes: null,
5478
- createdBy: null,
5479
- friendlyName: null,
5480
- lastConsumedMessageIndex: null,
5710
+ createdBy: "",
5711
+ friendlyName: "",
5712
+ lastConsumedMessageIndex: 0,
5481
5713
  dateCreated: null,
5482
5714
  dateUpdated: null
5483
5715
  }, conversationSid, links, this.configuration, this.services);
@@ -5489,7 +5721,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5489
5721
  return conversation._subscribe();
5490
5722
 
5491
5723
  case 17:
5492
- this.emit('conversationAdded', conversation);
5724
+ this.emit("conversationAdded", conversation);
5493
5725
  return _context.abrupt("return", conversation);
5494
5726
 
5495
5727
  case 19:
@@ -5528,12 +5760,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5528
5760
 
5529
5761
  case 3:
5530
5762
  map = _context2.sent;
5531
- map.on('itemAdded', function (args) {
5763
+ map.on("itemAdded", function (args) {
5532
5764
  log$2.debug("itemAdded: ".concat(args.item.key));
5533
5765
 
5534
- _this2._upsertConversation('sync', args.item.key, args.item.data);
5766
+ _this2._upsertConversation("sync", args.item.key, args.item.data);
5535
5767
  });
5536
- map.on('itemRemoved', function (args) {
5768
+ map.on("itemRemoved", function (args) {
5537
5769
  log$2.debug("itemRemoved: ".concat(args.key));
5538
5770
  var sid = args.key;
5539
5771
 
@@ -5547,22 +5779,22 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5547
5779
  return;
5548
5780
  }
5549
5781
 
5550
- if (conversation.status === 'joined') {
5551
- conversation._setStatus('notParticipating', 'sync');
5782
+ if (conversation.status === "joined") {
5783
+ conversation._setStatus("notParticipating", "sync");
5552
5784
 
5553
- _this2.emit('conversationLeft', conversation);
5785
+ _this2.emit("conversationLeft", conversation);
5554
5786
  }
5555
5787
 
5556
5788
  _this2.conversations.delete(sid);
5557
5789
 
5558
- _this2.emit('conversationRemoved', conversation);
5790
+ _this2.emit("conversationRemoved", conversation);
5559
5791
 
5560
- conversation.emit('removed', conversation);
5792
+ conversation.emit("removed", conversation);
5561
5793
  });
5562
- map.on('itemUpdated', function (args) {
5794
+ map.on("itemUpdated", function (args) {
5563
5795
  log$2.debug("itemUpdated: ".concat(args.item.key));
5564
5796
 
5565
- _this2._upsertConversation('sync', args.item.key, args.item.data);
5797
+ _this2._upsertConversation("sync", args.item.key, args.item.data);
5566
5798
  });
5567
5799
  _context2.next = 9;
5568
5800
  return this._fetchMyConversations();
@@ -5575,7 +5807,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5575
5807
  try {
5576
5808
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
5577
5809
  conversation = _step.value;
5578
- upserts.push(this._upsertConversation('rest', conversation.channel_sid, conversation));
5810
+ upserts.push(this._upsertConversation("rest", conversation["channel_sid"], conversation));
5579
5811
  }
5580
5812
  } catch (err) {
5581
5813
  _iterator.e(err);
@@ -5590,15 +5822,15 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5590
5822
  case 16:
5591
5823
  this.myConversationsFetched = true;
5592
5824
  this.tombstones.clear();
5593
- log$2.debug('The conversations list has been successfully fetched');
5825
+ log$2.debug("The conversations list has been successfully fetched");
5594
5826
  return _context2.abrupt("return", this);
5595
5827
 
5596
5828
  case 22:
5597
5829
  _context2.prev = 22;
5598
5830
  _context2.t0 = _context2["catch"](0);
5599
- errorMessage = 'Failed to fetch the conversations list';
5831
+ errorMessage = "Failed to fetch the conversations list";
5600
5832
 
5601
- if (this.services.syncClient.connectionState !== 'disconnected') {
5833
+ if (this.services.syncClient.connectionState !== "disconnected") {
5602
5834
  log$2.error(errorMessage, _context2.t0);
5603
5835
  }
5604
5836
 
@@ -5622,7 +5854,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5622
5854
  }, {
5623
5855
  key: "getConversations",
5624
5856
  value: function () {
5625
- var _getConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(args) {
5857
+ var _getConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
5626
5858
  var _this3 = this;
5627
5859
 
5628
5860
  var conversationsMap, page;
@@ -5642,7 +5874,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5642
5874
  page = _context3.sent;
5643
5875
  return _context3.abrupt("return", this._wrapPaginator(page, function (items) {
5644
5876
  return Promise.all(items.map(function (item) {
5645
- return _this3._upsertConversation('sync', item.key, item.data);
5877
+ return _this3._upsertConversation("sync", item.key, item.data);
5646
5878
  }));
5647
5879
  }));
5648
5880
 
@@ -5654,7 +5886,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5654
5886
  }, _callee3, this);
5655
5887
  }));
5656
5888
 
5657
- function getConversations(_x2) {
5889
+ function getConversations() {
5658
5890
  return _getConversations.apply(this, arguments);
5659
5891
  }
5660
5892
 
@@ -5684,7 +5916,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5684
5916
  case 5:
5685
5917
  page = _context4.sent;
5686
5918
  items = page.items.map(function (item) {
5687
- return _this4._upsertConversation('sync', item.key, item.data);
5919
+ return _this4._upsertConversation("sync", item.key, item.data);
5688
5920
  });
5689
5921
  return _context4.abrupt("return", items.length > 0 ? items[0] : null);
5690
5922
 
@@ -5696,7 +5928,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5696
5928
  }, _callee4, this);
5697
5929
  }));
5698
5930
 
5699
- function getConversation(_x3) {
5931
+ function getConversation(_x2) {
5700
5932
  return _getConversation.apply(this, arguments);
5701
5933
  }
5702
5934
 
@@ -5722,7 +5954,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5722
5954
  data = {
5723
5955
  entityName: null,
5724
5956
  lastConsumedMessageIndex: body.last_read_message_index,
5725
- status: (body === null || body === void 0 ? void 0 : body.status) || 'unknown',
5957
+ status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
5726
5958
  friendlyName: body.friendly_name,
5727
5959
  dateUpdated: body.date_updated,
5728
5960
  dateCreated: body.date_created,
@@ -5733,7 +5965,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5733
5965
  notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
5734
5966
  sid: sid
5735
5967
  };
5736
- return _context5.abrupt("return", this._upsertConversation('sync', sid, data));
5968
+ return _context5.abrupt("return", sid ? this._upsertConversation("sync", sid, data) : null);
5737
5969
 
5738
5970
  case 8:
5739
5971
  case "end":
@@ -5743,7 +5975,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5743
5975
  }, _callee5, this);
5744
5976
  }));
5745
5977
 
5746
- function getConversationByUniqueName(_x4) {
5978
+ function getConversationByUniqueName(_x3) {
5747
5979
  return _getConversationByUniqueName.apply(this, arguments);
5748
5980
  }
5749
5981
 
@@ -5768,7 +6000,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5768
6000
  data = {
5769
6001
  entityName: null,
5770
6002
  // lastConsumedMessageIndex: body.last_read_message_index,
5771
- status: (body === null || body === void 0 ? void 0 : body.status) || 'unknown',
6003
+ status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
5772
6004
  friendlyName: body.friendly_name,
5773
6005
  dateUpdated: body.date_updated,
5774
6006
  dateCreated: body.date_created,
@@ -5779,7 +6011,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5779
6011
  // notificationLevel: body?.notification_level,
5780
6012
  sid: sid
5781
6013
  };
5782
- return _context6.abrupt("return", this._upsertConversation('sync', sid, data));
6014
+ return _context6.abrupt("return", this._upsertConversation("sync", sid, data));
5783
6015
 
5784
6016
  case 7:
5785
6017
  case "end":
@@ -5789,7 +6021,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5789
6021
  }, _callee6, this);
5790
6022
  }));
5791
6023
 
5792
- function peekConversation(_x5) {
6024
+ function peekConversation(_x4) {
5793
6025
  return _peekConversation.apply(this, arguments);
5794
6026
  }
5795
6027
 
@@ -5806,7 +6038,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5806
6038
  _context7.next = 2;
5807
6039
  return this.services.syncClient.map({
5808
6040
  id: this.configuration.myConversations,
5809
- mode: 'open_existing'
6041
+ mode: "open_existing"
5810
6042
  });
5811
6043
 
5812
6044
  case 2:
@@ -5866,7 +6098,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5866
6098
  }, _callee8);
5867
6099
  }));
5868
6100
 
5869
- function _wrapPaginator(_x6, _x7) {
6101
+ function _wrapPaginator(_x5, _x6) {
5870
6102
  return _wrapPaginator2.apply(this, arguments);
5871
6103
  }
5872
6104
 
@@ -5884,14 +6116,14 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5884
6116
  switch (_context9.prev = _context9.next) {
5885
6117
  case 0:
5886
6118
  areSourcesDifferent = conversation._statusSource() !== undefined && source !== conversation._statusSource();
5887
- isChannelSourceSync = source !== 'rest' || conversation._statusSource() === 'sync';
6119
+ isChannelSourceSync = source !== "rest" || conversation._statusSource() === "sync";
5888
6120
 
5889
- if (!(areSourcesDifferent && isChannelSourceSync && source !== 'sync')) {
6121
+ if (!(areSourcesDifferent && isChannelSourceSync && source !== "sync")) {
5890
6122
  _context9.next = 5;
5891
6123
  break;
5892
6124
  }
5893
6125
 
5894
- log$2.trace('upsertConversation: conversation is known from sync and came from chat, ignoring', {
6126
+ log$2.trace("upsertConversation: conversation is known from sync and came from chat, ignoring", {
5895
6127
  sid: conversation.sid,
5896
6128
  data: data.status,
5897
6129
  conversation: conversation.status
@@ -5899,20 +6131,20 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5899
6131
  return _context9.abrupt("return");
5900
6132
 
5901
6133
  case 5:
5902
- if (!(data.status === 'joined' && conversation.status !== 'joined')) {
6134
+ if (!(data.status === "joined" && conversation.status !== "joined")) {
5903
6135
  _context9.next = 13;
5904
6136
  break;
5905
6137
  }
5906
6138
 
5907
- conversation._setStatus('joined', source);
6139
+ conversation._setStatus("joined", source);
5908
6140
 
5909
6141
  updateData = {};
5910
6142
 
5911
- if (typeof data.notificationLevel !== 'undefined') {
6143
+ if (typeof data.notificationLevel !== "undefined") {
5912
6144
  updateData.notificationLevel = data.notificationLevel;
5913
6145
  }
5914
6146
 
5915
- if (typeof data.lastConsumedMessageIndex !== 'undefined') {
6147
+ if (typeof data.lastConsumedMessageIndex !== "undefined") {
5916
6148
  updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
5917
6149
  }
5918
6150
 
@@ -5921,18 +6153,18 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5921
6153
  }
5922
6154
 
5923
6155
  conversation._subscribe().then(function () {
5924
- _this6.emit('conversationJoined', conversation);
6156
+ _this6.emit("conversationJoined", conversation);
5925
6157
  });
5926
6158
 
5927
6159
  return _context9.abrupt("return");
5928
6160
 
5929
6161
  case 13:
5930
- if (!(data.status === 'notParticipating' && conversation.status === 'joined')) {
6162
+ if (!(data.status === "notParticipating" && conversation.status === "joined")) {
5931
6163
  _context9.next = 20;
5932
6164
  break;
5933
6165
  }
5934
6166
 
5935
- conversation._setStatus('notParticipating', source);
6167
+ conversation._setStatus("notParticipating", source);
5936
6168
 
5937
6169
  conversation._update(data);
5938
6170
 
@@ -5940,11 +6172,11 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5940
6172
  return conversation._subscribe();
5941
6173
 
5942
6174
  case 18:
5943
- this.emit('conversationLeft', conversation);
6175
+ this.emit("conversationLeft", conversation);
5944
6176
  return _context9.abrupt("return");
5945
6177
 
5946
6178
  case 20:
5947
- if (!(data.status === 'notParticipating')) {
6179
+ if (!(data.status === "notParticipating")) {
5948
6180
  _context9.next = 24;
5949
6181
  break;
5950
6182
  }
@@ -5966,7 +6198,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5966
6198
  }, _callee9, this);
5967
6199
  }));
5968
6200
 
5969
- function _updateConversation(_x8, _x9, _x10) {
6201
+ function _updateConversation(_x7, _x8, _x9) {
5970
6202
  return _updateConversation2.apply(this, arguments);
5971
6203
  }
5972
6204
 
@@ -6001,17 +6233,17 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6001
6233
  return _context10.abrupt("return", conversation);
6002
6234
 
6003
6235
  case 9:
6004
- if (!(['chat', 'rest'].includes(source) && this.tombstones.has(sid))) {
6236
+ if (!(["chat", "rest"].includes(source) && this.tombstones.has(sid))) {
6005
6237
  _context10.next = 12;
6006
6238
  break;
6007
6239
  }
6008
6240
 
6009
- log$2.trace('upsertChannel: the channel is deleted but reappeared again from chat, ignoring', sid);
6010
- return _context10.abrupt("return");
6241
+ log$2.trace("upsertChannel: the channel is deleted but reappeared again from chat, ignoring", sid);
6242
+ return _context10.abrupt("return", null);
6011
6243
 
6012
6244
  case 12:
6013
6245
  // If the conversation is unknown, fetch it
6014
- log$2.trace('upsertConversation: creating a local conversation object with sid ' + sid, data);
6246
+ log$2.trace("upsertConversation: creating a local conversation object with sid " + sid, data);
6015
6247
  baseLink = "".concat(this.configuration.links.conversations, "/").concat(sid);
6016
6248
  links = {
6017
6249
  self: baseLink,
@@ -6026,12 +6258,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6026
6258
  case 19:
6027
6259
  this._registerForEvents(newConversation);
6028
6260
 
6029
- this.emit('conversationAdded', newConversation);
6261
+ this.emit("conversationAdded", newConversation);
6030
6262
 
6031
- if (data.status === 'joined') {
6032
- newConversation._setStatus('joined', source);
6263
+ if (data.status === "joined") {
6264
+ newConversation._setStatus("joined", source);
6033
6265
 
6034
- this.emit('conversationJoined', newConversation);
6266
+ this.emit("conversationJoined", newConversation);
6035
6267
  }
6036
6268
 
6037
6269
  return _context10.abrupt("return", newConversation);
@@ -6044,7 +6276,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6044
6276
  }, _callee10, this);
6045
6277
  }));
6046
6278
 
6047
- function _upsertConversation(_x11, _x12, _x13) {
6279
+ function _upsertConversation(_x10, _x11, _x12) {
6048
6280
  return _upsertConversation2.apply(this, arguments);
6049
6281
  }
6050
6282
 
@@ -6054,7 +6286,8 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6054
6286
  key: "_fetchMyConversations",
6055
6287
  value: function () {
6056
6288
  var _fetchMyConversations2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
6057
- var conversations, pageToken, url, response, receivedConversations;
6289
+ var conversations, pageToken, _response$body, url, response, receivedConversations;
6290
+
6058
6291
  return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
6059
6292
  while (1) {
6060
6293
  switch (_context11.prev = _context11.next) {
@@ -6066,7 +6299,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6066
6299
  url = new UriBuilder(this.configuration.links.myConversations);
6067
6300
 
6068
6301
  if (pageToken) {
6069
- url.arg('PageToken', pageToken);
6302
+ url.arg("PageToken", pageToken);
6070
6303
  }
6071
6304
 
6072
6305
  _context11.next = 6;
@@ -6074,7 +6307,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6074
6307
 
6075
6308
  case 6:
6076
6309
  response = _context11.sent;
6077
- receivedConversations = response.body.conversations.map(function (conversationDescriptor) {
6310
+ receivedConversations = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.conversations.map(function (conversationDescriptor) {
6078
6311
  return {
6079
6312
  descriptor: conversationDescriptor,
6080
6313
  channel_sid: conversationDescriptor.conversation_sid,
@@ -6082,7 +6315,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6082
6315
  channel: conversationDescriptor.sync_objects.conversation,
6083
6316
  messages: conversationDescriptor.sync_objects.messages,
6084
6317
  roster: "".concat(conversationDescriptor.conversation_sid, ".roster"),
6085
- lastConsumedMessageIndex: conversationDescriptor.last_consumed_message_index,
6318
+ lastConsumedMessageIndex: conversationDescriptor.last_read_message_index,
6086
6319
  notificationLevel: conversationDescriptor.notification_level
6087
6320
  };
6088
6321
  });
@@ -6119,7 +6352,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6119
6352
 
6120
6353
  if (conversation) {
6121
6354
  this.conversations.delete(sid);
6122
- this.emit('conversationRemoved', conversation);
6355
+ this.emit("conversationRemoved", conversation);
6123
6356
  }
6124
6357
  }
6125
6358
  }, {
@@ -6127,24 +6360,36 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6127
6360
  value: function _registerForEvents(conversation) {
6128
6361
  var _this7 = this;
6129
6362
 
6130
- conversation.on('removed', function () {
6363
+ conversation.on("removed", function () {
6131
6364
  return _this7._onConversationRemoved(conversation.sid);
6132
6365
  });
6133
- conversation.on('updated', function (args) {
6134
- return _this7.emit('conversationUpdated', args);
6366
+ conversation.on("updated", function (args) {
6367
+ return _this7.emit("conversationUpdated", args);
6368
+ });
6369
+ conversation.on("participantJoined", function (participant) {
6370
+ return _this7.emit("participantJoined", participant);
6371
+ });
6372
+ conversation.on("participantLeft", function (participant) {
6373
+ return _this7.emit("participantLeft", participant);
6374
+ });
6375
+ conversation.on("participantUpdated", function (args) {
6376
+ return _this7.emit("participantUpdated", args);
6377
+ });
6378
+ conversation.on("messageAdded", function (message) {
6379
+ return _this7.emit("messageAdded", message);
6135
6380
  });
6136
- conversation.on('participantJoined', this.emit.bind(this, 'participantJoined'));
6137
- conversation.on('participantLeft', this.emit.bind(this, 'participantLeft'));
6138
- conversation.on('participantUpdated', function (args) {
6139
- return _this7.emit('participantUpdated', args);
6381
+ conversation.on("messageUpdated", function (args) {
6382
+ return _this7.emit("messageUpdated", args);
6140
6383
  });
6141
- conversation.on('messageAdded', this.emit.bind(this, 'messageAdded'));
6142
- conversation.on('messageUpdated', function (args) {
6143
- return _this7.emit('messageUpdated', args);
6384
+ conversation.on("messageRemoved", function (message) {
6385
+ return _this7.emit("messageRemoved", message);
6386
+ });
6387
+ conversation.on("typingStarted", function (participant) {
6388
+ return _this7.emit("typingStarted", participant);
6389
+ });
6390
+ conversation.on("typingEnded", function (participant) {
6391
+ return _this7.emit("typingEnded", participant);
6144
6392
  });
6145
- conversation.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
6146
- conversation.on('typingStarted', this.emit.bind(this, 'typingStarted'));
6147
- conversation.on('typingEnded', this.emit.bind(this, 'typingEnded'));
6148
6393
  }
6149
6394
  }]);
6150
6395
 
@@ -6174,16 +6419,16 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6174
6419
  _this.fifoStack = [];
6175
6420
  _this.myself = myself;
6176
6421
 
6177
- _this.myself.on('updated', function (args) {
6178
- return _this.emit('userUpdated', args);
6422
+ _this.myself.on("updated", function (args) {
6423
+ return _this.emit("userUpdated", args);
6179
6424
  });
6180
6425
 
6181
- _this.myself.on('userSubscribed', function () {
6182
- return _this.emit('userSubscribed', _this.myself);
6426
+ _this.myself.on("userSubscribed", function () {
6427
+ return _this.emit("userSubscribed", _this.myself);
6183
6428
  });
6184
6429
 
6185
- _this.myself.on('userUnsubscribed', function () {
6186
- _this.emit('userUnsubscribed', _this.myself);
6430
+ _this.myself.on("userUnsubscribed", function () {
6431
+ _this.emit("userUnsubscribed", _this.myself);
6187
6432
 
6188
6433
  _this.myself._ensureFetched();
6189
6434
  });
@@ -6199,7 +6444,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6199
6444
  this.subscribedUsers.delete(user.identity);
6200
6445
  }
6201
6446
 
6202
- var foundItemIndex = -1;
6447
+ var foundItemIndex = 0;
6203
6448
  var foundItem = this.fifoStack.find(function (item, index) {
6204
6449
  if (item == user.identity) {
6205
6450
  foundItemIndex = index;
@@ -6213,7 +6458,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6213
6458
  this.fifoStack.splice(foundItemIndex, 1);
6214
6459
  }
6215
6460
 
6216
- this.emit('userUnsubscribed', user);
6461
+ this.emit("userUnsubscribed", user);
6217
6462
  }
6218
6463
  }, {
6219
6464
  key: "handleSubscribeUser",
@@ -6223,12 +6468,15 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6223
6468
  }
6224
6469
 
6225
6470
  if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {
6226
- this.subscribedUsers.get(this.fifoStack.shift()).unsubscribe();
6471
+ var _this$subscribedUsers, _this$subscribedUsers2;
6472
+
6473
+ var item = this.fifoStack.shift();
6474
+ (_this$subscribedUsers = this.subscribedUsers) === null || _this$subscribedUsers === void 0 ? void 0 : (_this$subscribedUsers2 = _this$subscribedUsers.get(item)) === null || _this$subscribedUsers2 === void 0 ? void 0 : _this$subscribedUsers2.unsubscribe();
6227
6475
  }
6228
6476
 
6229
6477
  this.fifoStack.push(user.identity);
6230
6478
  this.subscribedUsers.set(user.identity, user);
6231
- this.emit('userSubscribed', user);
6479
+ this.emit("userSubscribed", user);
6232
6480
  }
6233
6481
  /**
6234
6482
  * Gets user, if it's in subscribed list - then return the user object from it,
@@ -6239,65 +6487,74 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6239
6487
  }, {
6240
6488
  key: "getUser",
6241
6489
  value: function () {
6242
- var _getUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(identity) {
6490
+ var _getUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
6243
6491
  var _this2 = this;
6244
6492
 
6245
- var entityName,
6493
+ var identity,
6494
+ entityName,
6246
6495
  user,
6496
+ newUser,
6247
6497
  _args = arguments;
6248
6498
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
6249
6499
  while (1) {
6250
6500
  switch (_context.prev = _context.next) {
6251
6501
  case 0:
6252
- entityName = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
6253
- _context.next = 3;
6502
+ identity = _args.length > 0 && _args[0] !== undefined ? _args[0] : "";
6503
+ entityName = _args.length > 1 && _args[1] !== undefined ? _args[1] : "";
6504
+ _context.next = 4;
6254
6505
  return this.myself._ensureFetched();
6255
6506
 
6256
- case 3:
6507
+ case 4:
6257
6508
  if (!(identity == this.myself.identity)) {
6258
- _context.next = 5;
6509
+ _context.next = 6;
6259
6510
  break;
6260
6511
  }
6261
6512
 
6262
6513
  return _context.abrupt("return", this.myself);
6263
6514
 
6264
- case 5:
6515
+ case 6:
6265
6516
  user = this.subscribedUsers.get(identity);
6266
6517
 
6267
- if (user) {
6268
- _context.next = 17;
6518
+ if (!user) {
6519
+ _context.next = 9;
6269
6520
  break;
6270
6521
  }
6271
6522
 
6272
- if (entityName) {
6273
- _context.next = 11;
6523
+ return _context.abrupt("return", user);
6524
+
6525
+ case 9:
6526
+ _context.t0 = entityName;
6527
+
6528
+ if (_context.t0) {
6529
+ _context.next = 14;
6274
6530
  break;
6275
6531
  }
6276
6532
 
6277
- _context.next = 10;
6533
+ _context.next = 13;
6278
6534
  return this.getSyncUniqueName(identity);
6279
6535
 
6280
- case 10:
6281
- entityName = _context.sent;
6536
+ case 13:
6537
+ _context.t0 = _context.sent;
6282
6538
 
6283
- case 11:
6284
- user = new User(identity, entityName, this.configuration, this.services);
6285
- user.on('updated', function (args) {
6286
- return _this2.emit('userUpdated', args);
6539
+ case 14:
6540
+ entityName = _context.t0;
6541
+ newUser = new User(identity, entityName, this.configuration, this.services);
6542
+ newUser.on("updated", function (args) {
6543
+ return _this2.emit("userUpdated", args);
6287
6544
  });
6288
- user.on('userSubscribed', function () {
6289
- return _this2.handleSubscribeUser(user);
6545
+ newUser.on("userSubscribed", function () {
6546
+ return _this2.handleSubscribeUser(newUser);
6290
6547
  });
6291
- user.on('userUnsubscribed', function () {
6292
- return _this2.handleUnsubscribeUser(user);
6548
+ newUser.on("userUnsubscribed", function () {
6549
+ return _this2.handleUnsubscribeUser(newUser);
6293
6550
  });
6294
- _context.next = 17;
6295
- return user._ensureFetched();
6551
+ _context.next = 21;
6552
+ return newUser._ensureFetched();
6296
6553
 
6297
- case 17:
6298
- return _context.abrupt("return", user);
6554
+ case 21:
6555
+ return _context.abrupt("return", newUser);
6299
6556
 
6300
- case 18:
6557
+ case 22:
6301
6558
  case "end":
6302
6559
  return _context.stop();
6303
6560
  }
@@ -6305,7 +6562,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6305
6562
  }, _callee, this);
6306
6563
  }));
6307
6564
 
6308
- function getUser(_x) {
6565
+ function getUser() {
6309
6566
  return _getUser.apply(this, arguments);
6310
6567
  }
6311
6568
 
@@ -6356,6 +6613,8 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6356
6613
  key: "getSyncUniqueName",
6357
6614
  value: function () {
6358
6615
  var _getSyncUniqueName = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(identity) {
6616
+ var _response$body$sync_o, _response$body;
6617
+
6359
6618
  var url, response;
6360
6619
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
6361
6620
  while (1) {
@@ -6367,7 +6626,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6367
6626
 
6368
6627
  case 3:
6369
6628
  response = _context3.sent;
6370
- return _context3.abrupt("return", response.body.sync_objects.user_info_map);
6629
+ return _context3.abrupt("return", (_response$body$sync_o = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.sync_objects.user_info_map) !== null && _response$body$sync_o !== void 0 ? _response$body$sync_o : "");
6371
6630
 
6372
6631
  case 5:
6373
6632
  case "end":
@@ -6377,7 +6636,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6377
6636
  }, _callee3, this);
6378
6637
  }));
6379
6638
 
6380
- function getSyncUniqueName(_x2) {
6639
+ function getSyncUniqueName(_x) {
6381
6640
  return _getSyncUniqueName.apply(this, arguments);
6382
6641
  }
6383
6642
 
@@ -6388,7 +6647,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6388
6647
  return Users;
6389
6648
  }(replayEventEmitter.ReplayEventEmitter);
6390
6649
 
6391
- var log$1 = Logger.scope('TypingIndicator');
6650
+ var log$1 = Logger.scope("TypingIndicator");
6392
6651
  /**
6393
6652
  * An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
6394
6653
  * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
@@ -6435,7 +6694,7 @@ var TypingIndicator = /*#__PURE__*/function () {
6435
6694
  var _this = this;
6436
6695
 
6437
6696
  // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');
6438
- this.services.notificationClient.on('message', /*#__PURE__*/function () {
6697
+ this.services.notificationClient.on("message", /*#__PURE__*/function () {
6439
6698
  var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(type, message) {
6440
6699
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
6441
6700
  while (1) {
@@ -6476,7 +6735,7 @@ var TypingIndicator = /*#__PURE__*/function () {
6476
6735
  while (1) {
6477
6736
  switch (_context2.prev = _context2.next) {
6478
6737
  case 0:
6479
- log$1.trace('Got new typing indicator ', message);
6738
+ log$1.trace("Got new typing indicator ", message);
6480
6739
  this.getConversation(message.channel_sid).then(function (conversation) {
6481
6740
  if (!conversation) {
6482
6741
  return;
@@ -6487,7 +6746,7 @@ var TypingIndicator = /*#__PURE__*/function () {
6487
6746
  return;
6488
6747
  }
6489
6748
 
6490
- var timeout = _this2.configuration.typingIndicatorTimeoutOverride + 1000 || message.typing_timeout * 1000;
6749
+ var timeout = _this2.configuration.typingIndicatorTimeoutOverride ? _this2.configuration.typingIndicatorTimeoutOverride + 1000 : message.typing_timeout * 1000;
6491
6750
 
6492
6751
  participant._startTyping(timeout);
6493
6752
  });
@@ -6532,18 +6791,18 @@ var TypingIndicator = /*#__PURE__*/function () {
6532
6791
  value: function _send(conversationSid) {
6533
6792
  var _this3 = this;
6534
6793
 
6535
- log$1.trace('Sending typing indicator');
6794
+ log$1.trace("Sending typing indicator");
6536
6795
  var url = this.configuration.links.typing;
6537
6796
  var headers = {
6538
- 'Content-Type': 'application/x-www-form-urlencoded'
6797
+ "Content-Type": "application/x-www-form-urlencoded"
6539
6798
  };
6540
6799
  var body = "ChannelSid=".concat(conversationSid);
6541
6800
  return this.services.twilsockClient.post(url, headers, body, this.configuration.productId).then(function (response) {
6542
- if (response.body.hasOwnProperty('typing_timeout')) {
6801
+ if (response.body.hasOwnProperty("typing_timeout")) {
6543
6802
  _this3.serviceTypingTimeout = response.body.typing_timeout * 1000;
6544
6803
  }
6545
6804
  }).catch(function (err) {
6546
- log$1.error('Failed to send typing indicator:', err);
6805
+ log$1.error("Failed to send typing indicator:", err);
6547
6806
  throw err;
6548
6807
  });
6549
6808
  }
@@ -6599,14 +6858,14 @@ function PushNotification(data) {
6599
6858
  this.data = data.data || {};
6600
6859
  };
6601
6860
 
6602
- var version = "2.0.1-rc.9";
6861
+ var version = "2.1.0-rc.5";
6603
6862
 
6604
6863
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6605
6864
 
6606
6865
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6607
6866
 
6608
6867
  var trimSlashes = function trimSlashes(url) {
6609
- return url.replace(/(^\/+|\/+$)/g, '');
6868
+ return url.replace(/(^\/+|\/+$)/g, "");
6610
6869
  };
6611
6870
 
6612
6871
  var isMutationConflictResponse = function isMutationConflictResponse(response) {
@@ -6644,19 +6903,19 @@ var CommandExecutor = /*#__PURE__*/function () {
6644
6903
  case 0:
6645
6904
  preProcessedUrl = this._preProcessUrl(url);
6646
6905
  finalHeaders = _objectSpread$1({
6647
- 'Content-Type': 'application/json; charset=utf-8'
6906
+ "Content-Type": "application/json; charset=utf-8"
6648
6907
  }, headers || {});
6649
6908
  _context.t0 = method;
6650
- _context.next = _context.t0 === 'get' ? 5 : _context.t0 === 'post' ? 11 : _context.t0 === 'delete' ? 15 : 19;
6909
+ _context.next = _context.t0 === "get" ? 5 : _context.t0 === "post" ? 11 : _context.t0 === "delete" ? 15 : 19;
6651
6910
  break;
6652
6911
 
6653
6912
  case 5:
6654
6913
  getUrl = preProcessedUrl;
6655
6914
 
6656
6915
  if (requestBody) {
6657
- getUrl += '?' + Object.entries(requestBody).map(function (entry) {
6658
- return entry.map(encodeURIComponent).join('=');
6659
- }).join('&');
6916
+ getUrl += "?" + Object.entries(requestBody).map(function (entry) {
6917
+ return entry.map(encodeURIComponent).join("=");
6918
+ }).join("&");
6660
6919
  }
6661
6920
 
6662
6921
  _context.next = 9;
@@ -6676,7 +6935,7 @@ var CommandExecutor = /*#__PURE__*/function () {
6676
6935
 
6677
6936
  case 15:
6678
6937
  _context.next = 17;
6679
- return this._services.transport.delete(preProcessedUrl, finalHeaders, null, this._productId);
6938
+ return this._services.transport.delete(preProcessedUrl, finalHeaders, {}, this._productId);
6680
6939
 
6681
6940
  case 17:
6682
6941
  response = _context.sent;
@@ -6726,28 +6985,24 @@ var CommandExecutor = /*#__PURE__*/function () {
6726
6985
  max: 1600,
6727
6986
  maxAttemptsCount: maxAttemptsCount
6728
6987
  }).run(function () {
6729
- return _this._makeRequest('get', url, requestBody);
6988
+ return _this._makeRequest("get", url, requestBody);
6730
6989
  });
6731
6990
 
6732
6991
  case 4:
6733
6992
  result = _context2.sent;
6734
- _context2.next = 10;
6735
- break;
6993
+ return _context2.abrupt("return", result.body);
6736
6994
 
6737
- case 7:
6738
- _context2.prev = 7;
6995
+ case 8:
6996
+ _context2.prev = 8;
6739
6997
  _context2.t0 = _context2["catch"](1);
6740
6998
  throw new Error("Fetch resource from \"".concat(url, "\" failed."));
6741
6999
 
6742
- case 10:
6743
- return _context2.abrupt("return", result.body);
6744
-
6745
7000
  case 11:
6746
7001
  case "end":
6747
7002
  return _context2.stop();
6748
7003
  }
6749
7004
  }
6750
- }, _callee2, null, [[1, 7]]);
7005
+ }, _callee2, null, [[1, 8]]);
6751
7006
  }));
6752
7007
 
6753
7008
  function fetchResource(_x5, _x6) {
@@ -6767,7 +7022,7 @@ var CommandExecutor = /*#__PURE__*/function () {
6767
7022
  case 0:
6768
7023
  _context3.next = 2;
6769
7024
  return this._makeRequest(method, url, requestBody, {
6770
- 'X-Twilio-Mutation-Id': uuid.v4()
7025
+ "X-Twilio-Mutation-Id": uuid.v4()
6771
7026
  });
6772
7027
 
6773
7028
  case 2:
@@ -6817,7 +7072,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
6817
7072
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
6818
7073
 
6819
7074
  var Client_1;
6820
- var log = Logger.scope('Client');
7075
+ var log = Logger.scope("Client");
6821
7076
  var SDK_VERSION = version;
6822
7077
 
6823
7078
  var ClientServices = function ClientServices() {
@@ -6865,22 +7120,14 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
6865
7120
 
6866
7121
  _this = _super.call(this);
6867
7122
 
6868
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState", 'unknown');
6869
-
6870
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "conversationsPromise", null);
6871
-
6872
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_ensureReady", null);
6873
-
6874
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_resolveEnsureReady", null);
6875
-
6876
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_rejectEnsureReady", null);
7123
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState", "unknown");
6877
7124
 
6878
7125
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "version", SDK_VERSION);
6879
7126
 
6880
7127
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "parsePushNotification", Client_1.parsePushNotification);
6881
7128
 
6882
- _this.fpaToken = fpaToken;
6883
- _this.options = options;
7129
+ _this.fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
7130
+ _this.options = options !== null && options !== void 0 ? options : {};
6884
7131
 
6885
7132
  if (!_this.options.disableDeepClone) {
6886
7133
  var _options = _objectSpread(_objectSpread({}, _this.options), {}, {
@@ -6894,25 +7141,25 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
6894
7141
  _this.options = _options;
6895
7142
  }
6896
7143
 
6897
- _this.options.logLevel = (_this$options$logLeve = _this.options.logLevel) !== null && _this$options$logLeve !== void 0 ? _this$options$logLeve : 'silent';
7144
+ _this.options.logLevel = (_this$options$logLeve = _this.options.logLevel) !== null && _this$options$logLeve !== void 0 ? _this$options$logLeve : "silent";
6898
7145
  log.setLevel(_this.options.logLevel);
6899
- var productId = _this.options.productId = 'ip_messaging'; // Filling ClientMetadata
7146
+ var productId = _this.options.productId = "ip_messaging"; // Filling ClientMetadata
6900
7147
 
6901
7148
  _this.options.clientMetadata = _this.options.clientMetadata || {};
6902
7149
 
6903
- if (!_this.options.clientMetadata.hasOwnProperty('type')) {
6904
- _this.options.clientMetadata.type = 'conversations';
7150
+ if (!_this.options.clientMetadata.hasOwnProperty("type")) {
7151
+ _this.options.clientMetadata.type = "conversations";
6905
7152
  }
6906
7153
 
6907
- if (!_this.options.clientMetadata.hasOwnProperty('sdk')) {
6908
- _this.options.clientMetadata.sdk = 'JS';
7154
+ if (!_this.options.clientMetadata.hasOwnProperty("sdk")) {
7155
+ _this.options.clientMetadata.sdk = "JS";
6909
7156
  _this.options.clientMetadata.sdkv = SDK_VERSION;
6910
7157
  } // Enable session local storage for Sync
6911
7158
 
6912
7159
 
6913
7160
  _this.options.Sync = _this.options.Sync || {};
6914
7161
 
6915
- if (typeof _this.options.Sync.enableSessionStorage === 'undefined') {
7162
+ if (typeof _this.options.Sync.enableSessionStorage === "undefined") {
6916
7163
  _this.options.Sync.enableSessionStorage = true;
6917
7164
  }
6918
7165
 
@@ -6921,11 +7168,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
6921
7168
  }
6922
7169
 
6923
7170
  if (!fpaToken) {
6924
- throw new Error('A valid Twilio token should be provided');
7171
+ throw new Error("A valid Twilio token should be provided");
6925
7172
  }
6926
7173
 
6927
7174
  _this.services = new ClientServices();
6928
- _this._myself = new User('', '', null, _this.services);
7175
+ _this._myself = new User("", "", null, _this.services);
6929
7176
  var startTwilsock = !_this.options.twilsockClient; // Create default init registrations if none were provided.
6930
7177
  // Otherwise, the outside party have to list all the init registrations they
6931
7178
  // need.
@@ -6940,34 +7187,34 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
6940
7187
 
6941
7188
  _this.services.twilsockClient = _this.options.twilsockClient = (_this$options$twilsoc = _this.options.twilsockClient) !== null && _this$options$twilsoc !== void 0 ? _this$options$twilsoc : new twilsock.TwilsockClient(fpaToken, productId, _this.options);
6942
7189
 
6943
- _this.services.twilsockClient.on('tokenAboutToExpire', function (ttl) {
6944
- return _this.emit('tokenAboutToExpire', ttl);
7190
+ _this.services.twilsockClient.on("tokenAboutToExpire", function (ttl) {
7191
+ return _this.emit("tokenAboutToExpire", ttl);
6945
7192
  });
6946
7193
 
6947
- _this.services.twilsockClient.on('tokenExpired', function () {
6948
- return _this.emit('tokenExpired');
7194
+ _this.services.twilsockClient.on("tokenExpired", function () {
7195
+ return _this.emit("tokenExpired");
6949
7196
  });
6950
7197
 
6951
- _this.services.twilsockClient.on('connectionError', function (error) {
6952
- return _this.emit('connectionError', error);
7198
+ _this.services.twilsockClient.on("connectionError", function (error) {
7199
+ return _this.emit("connectionError", error);
6953
7200
  });
6954
7201
 
6955
- _this.services.twilsockClient.on('stateChanged', function (state) {
7202
+ _this.services.twilsockClient.on("stateChanged", function (state) {
6956
7203
  log.debug("Handling stateChanged for ConversationsClient: new state ".concat(state));
6957
7204
 
6958
7205
  if (state !== _this.connectionState) {
6959
7206
  _this.connectionState = state;
6960
7207
 
6961
- _this.emit('connectionStateChanged', _this.connectionState);
7208
+ _this.emit("connectionStateChanged", _this.connectionState);
6962
7209
  }
6963
7210
  });
6964
7211
 
6965
7212
  _this.services.transport = _this.options.transport = (_this$options$transpo = _this.options.transport) !== null && _this$options$transpo !== void 0 ? _this$options$transpo : _this.options.twilsockClient;
6966
7213
  _this.services.notificationClient = _this.options.notificationsClient = (_this$options$notific = _this.options.notificationsClient) !== null && _this$options$notific !== void 0 ? _this$options$notific : new notifications.Notifications(fpaToken, _this.options);
6967
7214
  _this.services.syncClient = _this.options.syncClient = (_this$options$syncCli = _this.options.syncClient) !== null && _this$options$syncCli !== void 0 ? _this$options$syncCli : new twilioSync.SyncClient(fpaToken, _this.options);
6968
- var configurationOptions = options.Chat || options.IPMessaging || options || {};
6969
- var region = configurationOptions.region || options.region;
6970
- var baseUrl = configurationOptions.apiUri || configurationOptions.typingUri || "https://aim.".concat(region || 'us1', ".twilio.com");
7215
+ var configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
7216
+ var region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
7217
+ var baseUrl = configurationOptions.apiUri || configurationOptions.typingUri || "https://aim.".concat(region || "us1", ".twilio.com");
6971
7218
  _this.services.commandExecutor = new CommandExecutor(baseUrl, {
6972
7219
  transport: _this.options.transport
6973
7220
  }, productId);
@@ -6975,15 +7222,15 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
6975
7222
  var emitFailed = function emitFailed(err) {
6976
7223
  _this._rejectEnsureReady(err);
6977
7224
 
6978
- _this.emit('stateChanged', 'failed');
7225
+ _this.emit("stateChanged", "failed");
6979
7226
  };
6980
7227
 
6981
- _this.services.twilsockClient.once('connectionError', emitFailed);
7228
+ _this.services.twilsockClient.once("connectionError", emitFailed);
6982
7229
 
6983
- _this.services.twilsockClient.once('disconnected', emitFailed); // ConversationsClient will be able to initialize only after twilsock is connected
7230
+ _this.services.twilsockClient.once("disconnected", emitFailed); // ConversationsClient will be able to initialize only after twilsock is connected
6984
7231
 
6985
7232
 
6986
- _this.services.twilsockClient.once('connected', /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
7233
+ _this.services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
6987
7234
  var startupEvent;
6988
7235
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
6989
7236
  while (1) {
@@ -6991,20 +7238,20 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
6991
7238
  case 0:
6992
7239
  log.debug("ConversationsClient started INITIALIZING");
6993
7240
 
6994
- _this.services.twilsockClient.off('connectionError', emitFailed);
7241
+ _this.services.twilsockClient.off("connectionError", emitFailed);
6995
7242
 
6996
- _this.services.twilsockClient.off('disconnected', emitFailed);
7243
+ _this.services.twilsockClient.off("disconnected", emitFailed);
6997
7244
 
6998
7245
  _context.prev = 3;
6999
- startupEvent = 'conversations.client.startup';
7246
+ startupEvent = "conversations.client.startup";
7000
7247
 
7001
- _this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, 'Conversations client startup', new Date()), startupEvent, twilsock.TelemetryPoint.Start);
7248
+ _this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, twilsock.TelemetryPoint.Start);
7002
7249
 
7003
7250
  _context.next = 8;
7004
7251
  return _this._initialize();
7005
7252
 
7006
7253
  case 8:
7007
- _this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription('', '', new Date()), startupEvent, twilsock.TelemetryPoint.End);
7254
+ _this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
7008
7255
 
7009
7256
  _context.next = 15;
7010
7257
  break;
@@ -7016,7 +7263,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7016
7263
  // Fail ChatClient if initialization is incomplete
7017
7264
  _this._rejectEnsureReady(_context.t0);
7018
7265
 
7019
- _this.emit('stateChanged', 'failed');
7266
+ _this.emit("stateChanged", "failed");
7020
7267
 
7021
7268
  case 15:
7022
7269
  case "end":
@@ -7029,7 +7276,9 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7029
7276
  _this._ensureReady = new Promise(function (resolve, reject) {
7030
7277
  _this._resolveEnsureReady = resolve;
7031
7278
  _this._rejectEnsureReady = reject;
7032
- }).catch(function (err) {}); // @todo How to process unhandled rejection here?
7279
+ }).catch(function () {
7280
+ return void 0;
7281
+ }); // @todo How to process unhandled rejection here?
7033
7282
 
7034
7283
  if (startTwilsock) {
7035
7284
  _this.services.twilsockClient.connect();
@@ -7058,7 +7307,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7058
7307
  key: "reachabilityEnabled",
7059
7308
  get: function get() {
7060
7309
  if (!this.configuration) {
7061
- throw new Error('Reachability information could not yet be accessed as the client ' + "has not yet been initialized. Subscribe to the 'stateChanged' event " + 'to properly react to the client initialization.');
7310
+ throw new Error("Reachability information could not yet be accessed as the client " + "has not yet been initialized. Subscribe to the 'stateChanged' event " + "to properly react to the client initialization.");
7062
7311
  }
7063
7312
 
7064
7313
  return this.configuration.reachabilityEnabled;
@@ -7098,7 +7347,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7098
7347
  switch (_context2.prev = _context2.next) {
7099
7348
  case 0:
7100
7349
  _context2.next = 2;
7101
- return this.services.commandExecutor.fetchResource('Client/v2/Configuration');
7350
+ return this.services.commandExecutor.fetchResource("Client/v2/Configuration");
7102
7351
 
7103
7352
  case 2:
7104
7353
  configurationResponse = _context2.sent;
@@ -7109,31 +7358,55 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7109
7358
  this.services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
7110
7359
  this.services.network = new Network(this.configuration, this.services);
7111
7360
  this.services.users = new Users(this._myself, this.configuration, this.services);
7112
- this.services.users.on('userSubscribed', this.emit.bind(this, 'userSubscribed'));
7113
- this.services.users.on('userUpdated', function (args) {
7114
- return _this4.emit('userUpdated', args);
7361
+ this.services.users.on("userSubscribed", function (user) {
7362
+ _this4.emit("userSubscribed", user);
7363
+ });
7364
+ this.services.users.on("userUpdated", function (args) {
7365
+ return _this4.emit("userUpdated", args);
7366
+ });
7367
+ this.services.users.on("userUnsubscribed", function (user) {
7368
+ _this4.emit("userUnsubscribed", user);
7115
7369
  });
7116
- this.services.users.on('userUnsubscribed', this.emit.bind(this, 'userUnsubscribed'));
7117
7370
  this.conversations = new Conversations(this.configuration, this.services);
7118
- this.conversations.on('conversationAdded', this.emit.bind(this, 'conversationAdded'));
7119
- this.conversations.on('conversationRemoved', this.emit.bind(this, 'conversationRemoved'));
7120
- this.conversations.on('conversationJoined', this.emit.bind(this, 'conversationJoined'));
7121
- this.conversations.on('conversationLeft', this.emit.bind(this, 'conversationLeft'));
7122
- this.conversations.on('conversationUpdated', function (args) {
7123
- return _this4.emit('conversationUpdated', args);
7371
+ this.conversations.on("conversationAdded", function (conversation) {
7372
+ _this4.emit("conversationAdded", conversation);
7373
+ });
7374
+ this.conversations.on("conversationRemoved", function (conversation) {
7375
+ _this4.emit("conversationRemoved", conversation);
7376
+ });
7377
+ this.conversations.on("conversationJoined", function (conversation) {
7378
+ _this4.emit("conversationJoined", conversation);
7379
+ });
7380
+ this.conversations.on("conversationLeft", function (conversation) {
7381
+ _this4.emit("conversationLeft", conversation);
7382
+ });
7383
+ this.conversations.on("conversationUpdated", function (args) {
7384
+ return _this4.emit("conversationUpdated", args);
7385
+ });
7386
+ this.conversations.on("participantJoined", function (participant) {
7387
+ _this4.emit("participantJoined", participant);
7388
+ });
7389
+ this.conversations.on("participantLeft", function (participant) {
7390
+ _this4.emit("participantLeft", participant);
7391
+ });
7392
+ this.conversations.on("participantUpdated", function (args) {
7393
+ return _this4.emit("participantUpdated", args);
7394
+ });
7395
+ this.conversations.on("messageAdded", function (message) {
7396
+ return _this4.emit("messageAdded", message);
7397
+ });
7398
+ this.conversations.on("messageUpdated", function (args) {
7399
+ return _this4.emit("messageUpdated", args);
7400
+ });
7401
+ this.conversations.on("messageRemoved", function (message) {
7402
+ return _this4.emit("messageRemoved", message);
7124
7403
  });
7125
- this.conversations.on('participantJoined', this.emit.bind(this, 'participantJoined'));
7126
- this.conversations.on('participantLeft', this.emit.bind(this, 'participantLeft'));
7127
- this.conversations.on('participantUpdated', function (args) {
7128
- return _this4.emit('participantUpdated', args);
7404
+ this.conversations.on("typingStarted", function (participant) {
7405
+ return _this4.emit("typingStarted", participant);
7129
7406
  });
7130
- this.conversations.on('messageAdded', this.emit.bind(this, 'messageAdded'));
7131
- this.conversations.on('messageUpdated', function (args) {
7132
- return _this4.emit('messageUpdated', args);
7407
+ this.conversations.on("typingEnded", function (participant) {
7408
+ return _this4.emit("typingEnded", participant);
7133
7409
  });
7134
- this.conversations.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
7135
- this.conversations.on('typingStarted', this.emit.bind(this, 'typingStarted'));
7136
- this.conversations.on('typingEnded', this.emit.bind(this, 'typingEnded'));
7137
7410
  this.conversationsPromise = this.conversations.fetchConversations().then(function () {
7138
7411
  return _this4.conversations;
7139
7412
  }).catch(function (error) {
@@ -7148,12 +7421,12 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7148
7421
  });
7149
7422
  this.services.typingIndicator.initialize();
7150
7423
  this.services.mcsClient = new mcsClient.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, _objectSpread(_objectSpread({}, this.options), {}, {
7151
- transport: null
7424
+ transport: undefined
7152
7425
  }));
7153
7426
 
7154
7427
  this._resolveEnsureReady();
7155
7428
 
7156
- this.emit('stateChanged', 'initialized');
7429
+ this.emit("stateChanged", "initialized");
7157
7430
 
7158
7431
  case 33:
7159
7432
  case "end":
@@ -7219,7 +7492,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7219
7492
  return this._ensureReady;
7220
7493
 
7221
7494
  case 2:
7222
- log.info('updateToken');
7495
+ log.info("updateToken");
7223
7496
 
7224
7497
  if (!(this.fpaToken === token)) {
7225
7498
  _context4.next = 5;
@@ -7381,7 +7654,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7381
7654
  }, {
7382
7655
  key: "getSubscribedConversations",
7383
7656
  value: function () {
7384
- var _getSubscribedConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7(args) {
7657
+ var _getSubscribedConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7() {
7385
7658
  return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
7386
7659
  while (1) {
7387
7660
  switch (_context7.prev = _context7.next) {
@@ -7391,7 +7664,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7391
7664
 
7392
7665
  case 2:
7393
7666
  return _context7.abrupt("return", this.conversationsPromise.then(function (conversations) {
7394
- return conversations.getConversations(args);
7667
+ return conversations.getConversations();
7395
7668
  }));
7396
7669
 
7397
7670
  case 3:
@@ -7402,7 +7675,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7402
7675
  }, _callee7, this);
7403
7676
  }));
7404
7677
 
7405
- function getSubscribedConversations(_x4) {
7678
+ function getSubscribedConversations() {
7406
7679
  return _getSubscribedConversations.apply(this, arguments);
7407
7680
  }
7408
7681
 
@@ -7439,7 +7712,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7439
7712
  }, _callee8, this);
7440
7713
  }));
7441
7714
 
7442
- function createConversation(_x5) {
7715
+ function createConversation(_x4) {
7443
7716
  return _createConversation.apply(this, arguments);
7444
7717
  }
7445
7718
 
@@ -7477,7 +7750,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7477
7750
  }, _callee9, this);
7478
7751
  }));
7479
7752
 
7480
- function setPushRegistrationId(_x6, _x7) {
7753
+ function setPushRegistrationId(_x5, _x6) {
7481
7754
  return _setPushRegistrationId.apply(this, arguments);
7482
7755
  }
7483
7756
 
@@ -7514,7 +7787,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7514
7787
  }, _callee10, this);
7515
7788
  }));
7516
7789
 
7517
- function unsetPushRegistrationId(_x8) {
7790
+ function unsetPushRegistrationId(_x7) {
7518
7791
  return _unsetPushRegistrationId.apply(this, arguments);
7519
7792
  }
7520
7793
 
@@ -7550,7 +7823,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7550
7823
  }, _callee11, this);
7551
7824
  }));
7552
7825
 
7553
- function removePushRegistrations(_x9, _x10) {
7826
+ function removePushRegistrations(_x8, _x9) {
7554
7827
  return _removePushRegistrations.apply(this, arguments);
7555
7828
  }
7556
7829
 
@@ -7573,8 +7846,8 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7573
7846
  return this._ensureReady;
7574
7847
 
7575
7848
  case 2:
7576
- log.debug('handlePushNotification, notificationPayload=', notificationPayload);
7577
- this.emit('pushNotification', Client_1.parsePushNotification(notificationPayload));
7849
+ log.debug("handlePushNotification, notificationPayload=", notificationPayload);
7850
+ this.emit("pushNotification", Client_1.parsePushNotification(notificationPayload));
7578
7851
 
7579
7852
  case 4:
7580
7853
  case "end":
@@ -7584,7 +7857,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7584
7857
  }, _callee12, this);
7585
7858
  }));
7586
7859
 
7587
- function handlePushNotification(_x11) {
7860
+ function handlePushNotification(_x10) {
7588
7861
  return _handlePushNotification.apply(this, arguments);
7589
7862
  }
7590
7863
 
@@ -7619,7 +7892,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7619
7892
  }, _callee13, this);
7620
7893
  }));
7621
7894
 
7622
- function getUser(_x12) {
7895
+ function getUser(_x11) {
7623
7896
  return _getUser.apply(this, arguments);
7624
7897
  }
7625
7898
 
@@ -7706,7 +7979,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7706
7979
  break;
7707
7980
  }
7708
7981
 
7709
- throw new Error('Obsolete usage of ConversationsClient.create() ' + 'factory method: if you pass twilsock from the outside then you must ' + 'use ConversationsClient constructor and be prepared to work with ' + 'uninitialized client.');
7982
+ throw new Error("Obsolete usage of ConversationsClient.create() " + "factory method: if you pass twilsock from the outside then you must " + "use ConversationsClient constructor and be prepared to work with " + "uninitialized client.");
7710
7983
 
7711
7984
  case 2:
7712
7985
  client = new Client_1(token, options);
@@ -7724,7 +7997,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7724
7997
  }, _callee15);
7725
7998
  }));
7726
7999
 
7727
- function create(_x13, _x14) {
8000
+ function create(_x12, _x13) {
7728
8001
  return _create.apply(this, arguments);
7729
8002
  }
7730
8003
 
@@ -7736,11 +8009,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7736
8009
  var result = {};
7737
8010
 
7738
8011
  for (var key in Client_1.supportedPushDataFields) {
7739
- if (typeof data[key] === 'undefined' || data[key] === null) {
8012
+ if (typeof data[key] === "undefined" || data[key] === null) {
7740
8013
  continue;
7741
8014
  }
7742
8015
 
7743
- if (key !== 'message_index') {
8016
+ if (key !== "message_index") {
7744
8017
  result[Client_1.supportedPushDataFields[key]] = data[key];
7745
8018
  continue;
7746
8019
  }
@@ -7760,19 +8033,19 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7760
8033
  }, {
7761
8034
  key: "parsePushNotification",
7762
8035
  value: function parsePushNotification(notificationPayload) {
7763
- log.debug('parsePushNotification, notificationPayload=', notificationPayload); // APNS specifics
8036
+ log.debug("parsePushNotification, notificationPayload=", notificationPayload); // APNS specifics
7764
8037
 
7765
- if (typeof notificationPayload.aps !== 'undefined') {
8038
+ if (typeof notificationPayload.aps !== "undefined") {
7766
8039
  if (!notificationPayload.twi_message_type) {
7767
- throw new Error('Provided push notification payload does not contain Programmable Chat push notification type');
8040
+ throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
7768
8041
  }
7769
8042
 
7770
8043
  var data = Client_1.parsePushNotificationChatData(notificationPayload);
7771
8044
  var apsPayload = notificationPayload.aps;
7772
- var body = null;
8045
+ var body;
7773
8046
  var title = null;
7774
8047
 
7775
- if (typeof apsPayload.alert === 'string') {
8048
+ if (typeof apsPayload.alert === "string") {
7776
8049
  body = apsPayload.alert || null;
7777
8050
  } else {
7778
8051
  body = apsPayload.alert.body || null;
@@ -7791,11 +8064,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7791
8064
  } // FCM specifics
7792
8065
 
7793
8066
 
7794
- if (typeof notificationPayload.data !== 'undefined') {
8067
+ if (typeof notificationPayload.data !== "undefined") {
7795
8068
  var dataPayload = notificationPayload.data;
7796
8069
 
7797
8070
  if (!dataPayload.twi_message_type) {
7798
- throw new Error('Provided push notification payload does not contain Programmable Chat push notification type');
8071
+ throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
7799
8072
  }
7800
8073
 
7801
8074
  var _data = Client_1.parsePushNotificationChatData(notificationPayload.data);
@@ -7811,16 +8084,16 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7811
8084
  });
7812
8085
  }
7813
8086
 
7814
- throw new Error('Provided push notification payload is not Programmable Chat notification');
8087
+ throw new Error("Provided push notification payload is not Programmable Chat notification");
7815
8088
  }
7816
8089
  }]);
7817
8090
 
7818
8091
  return Client;
7819
- }(replayEventEmitter.ReplayEventEmitter), _defineProperty__default['default'](_class, "version", SDK_VERSION), _defineProperty__default['default'](_class, "supportedPushChannels", ['fcm', 'apn']), _defineProperty__default['default'](_class, "supportedPushDataFields", {
7820
- 'conversation_sid': 'conversationSid',
7821
- 'message_sid': 'messageSid',
7822
- 'message_index': 'messageIndex'
7823
- }), _defineProperty__default['default'](_class, "conversationAdded", 'conversationAdded'), _defineProperty__default['default'](_class, "conversationJoined", 'conversationJoined'), _defineProperty__default['default'](_class, "conversationLeft", 'conversationLeft'), _defineProperty__default['default'](_class, "conversationRemoved", 'conversationRemoved'), _defineProperty__default['default'](_class, "conversationUpdated", 'conversationUpdated'), _defineProperty__default['default'](_class, "participantJoined", 'participantJoined'), _defineProperty__default['default'](_class, "participantLeft", 'participantLeft'), _defineProperty__default['default'](_class, "participantUpdated", 'participantUpdated'), _defineProperty__default['default'](_class, "messageAdded", 'messageAdded'), _defineProperty__default['default'](_class, "messageRemoved", 'messageRemoved'), _defineProperty__default['default'](_class, "messageUpdated", 'messageUpdated'), _defineProperty__default['default'](_class, "tokenAboutToExpire", 'tokenAboutToExpire'), _defineProperty__default['default'](_class, "tokenExpired", 'tokenExpired'), _defineProperty__default['default'](_class, "typingEnded", 'typingEnded'), _defineProperty__default['default'](_class, "typingStarted", 'typingStarted'), _defineProperty__default['default'](_class, "pushNotification", 'pushNotification'), _defineProperty__default['default'](_class, "userSubscribed", 'userSubscribed'), _defineProperty__default['default'](_class, "userUnsubscribed", 'userUnsubscribed'), _defineProperty__default['default'](_class, "userUpdated", 'userUpdated'), _defineProperty__default['default'](_class, "stateChanged", 'stateChanged'), _defineProperty__default['default'](_class, "connectionStateChanged", 'connectionStateChanged'), _defineProperty__default['default'](_class, "connectionError", 'connectionError'), _temp);
8092
+ }(replayEventEmitter.ReplayEventEmitter), _defineProperty__default['default'](_class, "version", SDK_VERSION), _defineProperty__default['default'](_class, "supportedPushChannels", ["fcm", "apn"]), _defineProperty__default['default'](_class, "supportedPushDataFields", {
8093
+ conversation_sid: "conversationSid",
8094
+ message_sid: "messageSid",
8095
+ message_index: "messageIndex"
8096
+ }), _defineProperty__default['default'](_class, "conversationAdded", "conversationAdded"), _defineProperty__default['default'](_class, "conversationJoined", "conversationJoined"), _defineProperty__default['default'](_class, "conversationLeft", "conversationLeft"), _defineProperty__default['default'](_class, "conversationRemoved", "conversationRemoved"), _defineProperty__default['default'](_class, "conversationUpdated", "conversationUpdated"), _defineProperty__default['default'](_class, "participantJoined", "participantJoined"), _defineProperty__default['default'](_class, "participantLeft", "participantLeft"), _defineProperty__default['default'](_class, "participantUpdated", "participantUpdated"), _defineProperty__default['default'](_class, "messageAdded", "messageAdded"), _defineProperty__default['default'](_class, "messageRemoved", "messageRemoved"), _defineProperty__default['default'](_class, "messageUpdated", "messageUpdated"), _defineProperty__default['default'](_class, "tokenAboutToExpire", "tokenAboutToExpire"), _defineProperty__default['default'](_class, "tokenExpired", "tokenExpired"), _defineProperty__default['default'](_class, "typingEnded", "typingEnded"), _defineProperty__default['default'](_class, "typingStarted", "typingStarted"), _defineProperty__default['default'](_class, "pushNotification", "pushNotification"), _defineProperty__default['default'](_class, "userSubscribed", "userSubscribed"), _defineProperty__default['default'](_class, "userUnsubscribed", "userUnsubscribed"), _defineProperty__default['default'](_class, "userUpdated", "userUpdated"), _defineProperty__default['default'](_class, "stateChanged", "stateChanged"), _defineProperty__default['default'](_class, "connectionStateChanged", "connectionStateChanged"), _defineProperty__default['default'](_class, "connectionError", "connectionError"), _temp);
7824
8097
 
7825
8098
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
7826
8099
 
@@ -7828,27 +8101,27 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
7828
8101
 
7829
8102
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationByUniqueName", null);
7830
8103
 
7831
- __decorate([declarativeTypeValidator.validateTypesAsync(['undefined', declarativeTypeValidator.objectSchema('conversation options', {
7832
- friendlyName: ['string', 'undefined'],
7833
- isPrivate: ['boolean', 'undefined'],
7834
- uniqueName: ['string', 'undefined']
8104
+ __decorate([declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.objectSchema("conversation options", {
8105
+ friendlyName: ["string", "undefined"],
8106
+ isPrivate: ["boolean", "undefined"],
8107
+ uniqueName: ["string", "undefined"]
7835
8108
  })]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "createConversation", null);
7836
8109
 
7837
- __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('fcm', 'apn'), 'string'), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "setPushRegistrationId", null);
8110
+ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn"), "string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "setPushRegistrationId", null);
7838
8111
 
7839
- __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('fcm', 'apn')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "unsetPushRegistrationId", null);
8112
+ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "unsetPushRegistrationId", null);
7840
8113
 
7841
- __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('fcm', 'apn'), declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "removePushRegistrations", null);
8114
+ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn"), declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "removePushRegistrations", null);
7842
8115
 
7843
8116
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "handlePushNotification", null);
7844
8117
 
7845
8118
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getUser", null);
7846
8119
 
7847
- __decorate([declarativeTypeValidator.validateTypesAsync('string', ['undefined', declarativeTypeValidator.pureObject]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], exports.Client, "create", null);
8120
+ __decorate([declarativeTypeValidator.validateTypesAsync("string", ["undefined", declarativeTypeValidator.pureObject]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], exports.Client, "create", null);
7848
8121
 
7849
8122
  __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
7850
8123
 
7851
- exports.Client = Client_1 = __decorate([declarativeTypeValidator.validateConstructorTypes(declarativeTypeValidator.nonEmptyString, [declarativeTypeValidator.pureObject, 'undefined']), __metadata("design:paramtypes", [String, Object])], exports.Client);
8124
+ exports.Client = Client_1 = __decorate([declarativeTypeValidator.validateConstructorTypes(declarativeTypeValidator.nonEmptyString, [declarativeTypeValidator.pureObject, "undefined"]), __metadata("design:paramtypes", [String, Object])], exports.Client);
7852
8125
 
7853
8126
  exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
7854
8127
  exports.Conversation = Conversation;