@twilio/conversations 2.1.0-rc.1 → 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 (67) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/NOTICE.txt +679 -0
  3. package/builds/browser.js +676 -587
  4. package/builds/browser.js.map +1 -1
  5. package/builds/lib.d.ts +287 -117
  6. package/builds/lib.js +676 -587
  7. package/builds/lib.js.map +1 -1
  8. package/builds/twilio-conversations.js +854 -909
  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 +212 -153
  19. package/dist/conversation.js.map +1 -1
  20. package/dist/data/conversations.js +81 -77
  21. package/dist/data/conversations.js.map +1 -1
  22. package/dist/data/messages.js +42 -38
  23. package/dist/data/messages.js.map +1 -1
  24. package/dist/data/participants.js +93 -75
  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/interfaces/attributes.js +4 -4
  31. package/dist/interfaces/attributes.js.map +1 -1
  32. package/dist/interfaces/notification-types.js +5 -5
  33. package/dist/interfaces/notification-types.js.map +1 -1
  34. package/dist/logger.js +36 -15
  35. package/dist/logger.js.map +1 -1
  36. package/dist/media.js +21 -9
  37. package/dist/media.js.map +1 -1
  38. package/dist/message-builder.js +10 -9
  39. package/dist/message-builder.js.map +1 -1
  40. package/dist/message.js +130 -81
  41. package/dist/message.js.map +1 -1
  42. package/dist/packages/conversations/package.json.js +1 -1
  43. package/dist/participant.js +85 -51
  44. package/dist/participant.js.map +1 -1
  45. package/dist/push-notification.js.map +1 -1
  46. package/dist/rest-paginator.js +16 -6
  47. package/dist/rest-paginator.js.map +1 -1
  48. package/dist/services/network.js +18 -14
  49. package/dist/services/network.js.map +1 -1
  50. package/dist/services/typing-indicator.js +20 -17
  51. package/dist/services/typing-indicator.js.map +1 -1
  52. package/dist/unsent-message.js.map +1 -1
  53. package/dist/user.js +85 -59
  54. package/dist/user.js.map +1 -1
  55. package/dist/util/deferred.js +3 -1
  56. package/dist/util/deferred.js.map +1 -1
  57. package/dist/util/index.js +6 -6
  58. package/dist/util/index.js.map +1 -1
  59. package/docs/classes/Client.html +24 -30
  60. package/docs/classes/Conversation.html +30 -30
  61. package/docs/classes/DetailedDeliveryReceipt.html +1 -1
  62. package/docs/classes/Message.html +7 -7
  63. package/docs/classes/MessageBuilder.html +2 -2
  64. package/docs/classes/Participant.html +7 -7
  65. package/docs/classes/User.html +7 -7
  66. package/docs/interfaces/CreateConversationOptions.html +1 -1
  67. package/package.json +23 -17
package/builds/lib.js CHANGED
@@ -266,15 +266,15 @@ function prepareLine(prefix, args) {
266
266
  return ["".concat(new Date().toISOString(), " Conversations ").concat(prefix, ":")].concat(Array.from(args));
267
267
  }
268
268
 
269
- 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
270
270
 
271
271
  var Logger = /*#__PURE__*/function () {
272
272
  function Logger(prefix) {
273
273
  _classCallCheck__default['default'](this, Logger);
274
274
 
275
- _defineProperty__default['default'](this, "prefix", '');
275
+ _defineProperty__default['default'](this, "prefix", "");
276
276
 
277
- this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0 ? prefix + ' ' : '';
277
+ this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0 ? prefix + " " : "";
278
278
  }
279
279
 
280
280
  _createClass__default['default'](Logger, [{
@@ -289,7 +289,7 @@ var Logger = /*#__PURE__*/function () {
289
289
  args[_key] = arguments[_key];
290
290
  }
291
291
 
292
- log$9.trace.apply(null, prepareLine(this.prefix + 'T', args));
292
+ log$9.trace.apply(null, prepareLine(this.prefix + "T", args));
293
293
  }
294
294
  }, {
295
295
  key: "debug",
@@ -298,7 +298,7 @@ var Logger = /*#__PURE__*/function () {
298
298
  args[_key2] = arguments[_key2];
299
299
  }
300
300
 
301
- log$9.debug.apply(null, prepareLine(this.prefix + 'D', args));
301
+ log$9.debug.apply(null, prepareLine(this.prefix + "D", args));
302
302
  }
303
303
  }, {
304
304
  key: "info",
@@ -307,7 +307,7 @@ var Logger = /*#__PURE__*/function () {
307
307
  args[_key3] = arguments[_key3];
308
308
  }
309
309
 
310
- log$9.info.apply(null, prepareLine(this.prefix + 'I', args));
310
+ log$9.info.apply(null, prepareLine(this.prefix + "I", args));
311
311
  }
312
312
  }, {
313
313
  key: "warn",
@@ -316,7 +316,7 @@ var Logger = /*#__PURE__*/function () {
316
316
  args[_key4] = arguments[_key4];
317
317
  }
318
318
 
319
- log$9.warn.apply(null, prepareLine(this.prefix + 'W', args));
319
+ log$9.warn.apply(null, prepareLine(this.prefix + "W", args));
320
320
  }
321
321
  }, {
322
322
  key: "error",
@@ -325,7 +325,7 @@ var Logger = /*#__PURE__*/function () {
325
325
  args[_key5] = arguments[_key5];
326
326
  }
327
327
 
328
- log$9.error.apply(null, prepareLine(this.prefix + 'E', args));
328
+ log$9.error.apply(null, prepareLine(this.prefix + "E", args));
329
329
  }
330
330
  }], [{
331
331
  key: "scope",
@@ -344,7 +344,7 @@ var Logger = /*#__PURE__*/function () {
344
344
  args[_key6] = arguments[_key6];
345
345
  }
346
346
 
347
- log$9.trace.apply(null, prepareLine('T', args));
347
+ log$9.trace.apply(null, prepareLine("T", args));
348
348
  }
349
349
  }, {
350
350
  key: "debug",
@@ -353,7 +353,7 @@ var Logger = /*#__PURE__*/function () {
353
353
  args[_key7] = arguments[_key7];
354
354
  }
355
355
 
356
- log$9.debug.apply(null, prepareLine('D', args));
356
+ log$9.debug.apply(null, prepareLine("D", args));
357
357
  }
358
358
  }, {
359
359
  key: "info",
@@ -362,7 +362,7 @@ var Logger = /*#__PURE__*/function () {
362
362
  args[_key8] = arguments[_key8];
363
363
  }
364
364
 
365
- log$9.info.apply(null, prepareLine('I', args));
365
+ log$9.info.apply(null, prepareLine("I", args));
366
366
  }
367
367
  }, {
368
368
  key: "warn",
@@ -371,7 +371,7 @@ var Logger = /*#__PURE__*/function () {
371
371
  args[_key9] = arguments[_key9];
372
372
  }
373
373
 
374
- log$9.warn.apply(null, prepareLine('W', args));
374
+ log$9.warn.apply(null, prepareLine("W", args));
375
375
  }
376
376
  }, {
377
377
  key: "error",
@@ -380,7 +380,7 @@ var Logger = /*#__PURE__*/function () {
380
380
  args[_key10] = arguments[_key10];
381
381
  }
382
382
 
383
- log$9.error.apply(null, prepareLine('E', args));
383
+ log$9.error.apply(null, prepareLine("E", args));
384
384
  }
385
385
  }]);
386
386
 
@@ -391,8 +391,8 @@ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if
391
391
 
392
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; }
393
393
  var TYPING_TIMEOUT = 5;
394
- var HTTP_CACHE_LIFETIME = 'PT5S';
395
- var CONSUMPTION_HORIZON_SENDING_INTERVAL = 'PT5S';
394
+ var HTTP_CACHE_LIFETIME = "PT5S";
395
+ var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
396
396
  var USER_INFOS_TO_SUBSCRIBE = 100;
397
397
  var MINIMUM_RETRY_DELAY = 1000;
398
398
  var MAXIMUM_RETRY_DELAY = 4000;
@@ -471,7 +471,7 @@ function deepClone(obj) {
471
471
  }
472
472
 
473
473
  function parseToNumber(value) {
474
- if (typeof value !== 'undefined' && !isNaN(Number(value))) {
474
+ if (typeof value !== "undefined" && !isNaN(Number(value))) {
475
475
  return Number(value);
476
476
  }
477
477
 
@@ -510,7 +510,7 @@ var UriBuilder = /*#__PURE__*/function () {
510
510
  function UriBuilder(base) {
511
511
  _classCallCheck__default['default'](this, UriBuilder);
512
512
 
513
- this.base = base.replace(/\/$/, '');
513
+ this.base = base.replace(/\/$/, "");
514
514
  this.args = [];
515
515
  this.paths = [];
516
516
  }
@@ -518,8 +518,8 @@ var UriBuilder = /*#__PURE__*/function () {
518
518
  _createClass__default['default'](UriBuilder, [{
519
519
  key: "arg",
520
520
  value: function arg(name, value) {
521
- if (typeof value !== 'undefined') {
522
- this.args.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
521
+ if (typeof value !== "undefined") {
522
+ this.args.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
523
523
  }
524
524
 
525
525
  return this;
@@ -536,11 +536,11 @@ var UriBuilder = /*#__PURE__*/function () {
536
536
  var result = this.base;
537
537
 
538
538
  if (this.paths.length) {
539
- result += '/' + this.paths.join('/');
539
+ result += "/" + this.paths.join("/");
540
540
  }
541
541
 
542
542
  if (this.args.length) {
543
- result += '?' + this.args.join('&');
543
+ result += "?" + this.args.join("&");
544
544
  }
545
545
 
546
546
  return result;
@@ -551,16 +551,16 @@ var UriBuilder = /*#__PURE__*/function () {
551
551
  }();
552
552
 
553
553
  var attributesValidator = declarativeTypeValidator.custom(function (value) {
554
- return [['string', 'number', 'boolean', 'object'].includes(_typeof__default['default'](value)), 'a JSON type'];
554
+ return [["string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "a JSON type"];
555
555
  });
556
556
  var optionalAttributesValidator = declarativeTypeValidator.custom(function (value) {
557
- return [['undefined', 'string', 'number', 'boolean', 'object'].includes(_typeof__default['default'](value)), 'an optional JSON type'];
557
+ return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "an optional JSON type"];
558
558
  });
559
559
 
560
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); }; }
561
561
 
562
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; } }
563
- var log$8 = Logger.scope('User');
563
+ var log$8 = Logger.scope("User");
564
564
  /**
565
565
  * Extended user information.
566
566
  * Note that `isOnline` and `isNotifiable` properties are eligible
@@ -585,14 +585,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
585
585
 
586
586
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "promiseToFetch", null);
587
587
 
588
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated", 'updated');
588
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated", "updated");
589
589
 
590
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed", 'userSubscribed');
590
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed", "userSubscribed");
591
591
 
592
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed", 'userUnsubscribed');
592
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed", "userUnsubscribed");
593
593
 
594
594
  _this.services = services;
595
- _this.subscribed = 'initializing';
595
+ _this.subscribed = "initializing";
596
596
 
597
597
  _this.setMaxListeners(0);
598
598
 
@@ -685,7 +685,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
685
685
  }, {
686
686
  key: "isSubscribed",
687
687
  get: function get() {
688
- return this.subscribed == 'subscribed';
688
+ return this.subscribed == "subscribed";
689
689
  } // Handles service updates
690
690
 
691
691
  }, {
@@ -702,14 +702,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
702
702
 
703
703
  case 2:
704
704
  updateReasons = [];
705
- log$8.debug('User for', this.state.identity, 'updated:', key, value);
705
+ log$8.debug("User for", this.state.identity, "updated:", key, value);
706
706
  _context.t0 = key;
707
- _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;
708
708
  break;
709
709
 
710
710
  case 7:
711
711
  if (this.state.friendlyName !== value.value) {
712
- updateReasons.push('friendlyName');
712
+ updateReasons.push("friendlyName");
713
713
  this.state.friendlyName = value.value;
714
714
  }
715
715
 
@@ -720,7 +720,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
720
720
 
721
721
  if (!isEqual__default['default'](this.state.attributes, updateAttributes)) {
722
722
  this.state.attributes = updateAttributes;
723
- updateReasons.push('attributes');
723
+ updateReasons.push("attributes");
724
724
  }
725
725
 
726
726
  return _context.abrupt("break", 16);
@@ -728,12 +728,12 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
728
728
  case 12:
729
729
  if (this.state.online !== value.online) {
730
730
  this.state.online = value.online;
731
- updateReasons.push('reachabilityOnline');
731
+ updateReasons.push("reachabilityOnline");
732
732
  }
733
733
 
734
734
  if (this.state.notifiable !== value.notifiable) {
735
735
  this.state.notifiable = value.notifiable;
736
- updateReasons.push('reachabilityNotifiable');
736
+ updateReasons.push("reachabilityNotifiable");
737
737
  }
738
738
 
739
739
  return _context.abrupt("break", 16);
@@ -743,7 +743,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
743
743
 
744
744
  case 16:
745
745
  if (updateReasons.length > 0) {
746
- this.emit('updated', {
746
+ this.emit("updated", {
747
747
  user: this,
748
748
  updateReasons: updateReasons
749
749
  });
@@ -786,8 +786,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
786
786
  return _context2.abrupt("return", Promise.resolve());
787
787
 
788
788
  case 4:
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);
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);
791
791
  }));
792
792
 
793
793
  case 5:
@@ -829,26 +829,26 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
829
829
  case 4:
830
830
  this.promiseToFetch = this.services.syncClient.map({
831
831
  id: this.state.entityName,
832
- mode: 'open_existing',
832
+ mode: "open_existing",
833
833
  includeItems: true
834
834
  }).then(function (map) {
835
835
  _this3.entity = map;
836
- map.on('itemUpdated', function (args) {
837
- 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);
838
838
  return _this3._update(args.item.key, args.item.data);
839
839
  });
840
- return Promise.all([map.get('friendlyName').then(function (item) {
840
+ return Promise.all([map.get("friendlyName").then(function (item) {
841
841
  return _this3._update(item.key, item.data);
842
- }), map.get('attributes').then(function (item) {
842
+ }), map.get("attributes").then(function (item) {
843
843
  return _this3._update(item.key, item.data);
844
844
  }), _this3._updateReachabilityInfo(map, function (item) {
845
845
  return _this3._update(item.key, item.data);
846
846
  })]);
847
847
  }).then(function () {
848
- log$8.debug('Fetched for', _this3.identity);
849
- _this3.subscribed = 'subscribed';
848
+ log$8.debug("Fetched for", _this3.identity);
849
+ _this3.subscribed = "subscribed";
850
850
 
851
- _this3.emit('userSubscribed', _this3);
851
+ _this3.emit("userSubscribed", _this3);
852
852
 
853
853
  return _this3;
854
854
  }).catch(function (err) {
@@ -916,16 +916,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
916
916
  return this._initializationPromise;
917
917
 
918
918
  case 2:
919
- if (!(this.subscribed == 'unsubscribed')) {
919
+ if (!(this.subscribed == "unsubscribed")) {
920
920
  _context5.next = 4;
921
921
  break;
922
922
  }
923
923
 
924
- throw new Error('Can\'t modify unsubscribed object');
924
+ throw new Error("Can't modify unsubscribed object");
925
925
 
926
926
  case 4:
927
927
  _context5.next = 6;
928
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
928
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
929
929
  attributes: JSON.stringify(attributes)
930
930
  });
931
931
 
@@ -963,16 +963,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
963
963
  return this._initializationPromise;
964
964
 
965
965
  case 2:
966
- if (!(this.subscribed == 'unsubscribed')) {
966
+ if (!(this.subscribed == "unsubscribed")) {
967
967
  _context6.next = 4;
968
968
  break;
969
969
  }
970
970
 
971
- throw new Error('Can\'t modify unsubscribed object');
971
+ throw new Error("Can't modify unsubscribed object");
972
972
 
973
973
  case 4:
974
974
  _context6.next = 6;
975
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
975
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
976
976
  friendly_name: friendlyName
977
977
  });
978
978
 
@@ -1021,8 +1021,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
1021
1021
  case 5:
1022
1022
  this.entity.close();
1023
1023
  this.promiseToFetch = null;
1024
- this.subscribed = 'unsubscribed';
1025
- this.emit('userUnsubscribed', this);
1024
+ this.subscribed = "unsubscribed";
1025
+ this.emit("userUnsubscribed", this);
1026
1026
 
1027
1027
  case 9:
1028
1028
  case "end":
@@ -1051,9 +1051,9 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
1051
1051
  this._resolveInitializationPromise();
1052
1052
 
1053
1053
  if (emitUpdated) {
1054
- this.emit('updated', {
1054
+ this.emit("updated", {
1055
1055
  user: this,
1056
- updateReasons: ['friendlyName', 'attributes', 'reachabilityOnline', 'reachabilityNotifiable']
1056
+ updateReasons: ["friendlyName", "attributes", "reachabilityOnline", "reachabilityNotifiable"]
1057
1057
  });
1058
1058
  }
1059
1059
  }
@@ -1064,7 +1064,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
1064
1064
 
1065
1065
  __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
1066
1066
 
1067
- __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);
1068
1068
 
1069
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; } } }; }
1070
1070
 
@@ -1137,13 +1137,13 @@ var Network = /*#__PURE__*/function () {
1137
1137
  }
1138
1138
 
1139
1139
  var retrier = new operationRetrier.Retrier(_this2.configuration.backoffConfiguration);
1140
- retrier.on('attempt', function () {
1140
+ retrier.on("attempt", function () {
1141
1141
  request().then(function (result) {
1142
1142
  return retrier.succeeded(result);
1143
1143
  }).catch(function (err) {
1144
1144
  if (codesToRetryOn.indexOf(err.status) > -1) {
1145
1145
  retrier.failed(err);
1146
- } else if (err.message === 'Twilsock disconnected') {
1146
+ } else if (err.message === "Twilsock disconnected") {
1147
1147
  // Ugly hack. We must make a proper exceptions for twilsock
1148
1148
  retrier.failed(err);
1149
1149
  } else {
@@ -1154,13 +1154,13 @@ var Network = /*#__PURE__*/function () {
1154
1154
  }
1155
1155
  });
1156
1156
  });
1157
- retrier.on('succeeded', function (result) {
1157
+ retrier.on("succeeded", function (result) {
1158
1158
  resolve(result);
1159
1159
  });
1160
- retrier.on('cancelled', function (err) {
1160
+ retrier.on("cancelled", function (err) {
1161
1161
  return reject(err);
1162
1162
  });
1163
- retrier.on('failed', function (err) {
1163
+ retrier.on("failed", function (err) {
1164
1164
  return reject(err);
1165
1165
  });
1166
1166
  retrier.start();
@@ -1225,20 +1225,20 @@ var NotificationTypes = function NotificationTypes() {
1225
1225
  _classCallCheck__default['default'](this, NotificationTypes);
1226
1226
  };
1227
1227
 
1228
- _defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR", 'twilio.ipmsg.typing_indicator');
1228
+ _defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR", "twilio.ipmsg.typing_indicator");
1229
1229
 
1230
- _defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE", 'twilio.conversations.new_message');
1230
+ _defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE", "twilio.conversations.new_message");
1231
1231
 
1232
- _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");
1233
1233
 
1234
- _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");
1235
1235
 
1236
- _defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE", 'twilio.channel.consumption_update');
1236
+ _defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
1237
1237
 
1238
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); }; }
1239
1239
 
1240
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; } }
1241
- var log$7 = Logger.scope('Participant');
1241
+ var log$7 = Logger.scope("Participant");
1242
1242
  /**
1243
1243
  * A participant represents a remote client in a conversation.
1244
1244
  */
@@ -1252,7 +1252,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1252
1252
  * @internal
1253
1253
  */
1254
1254
  function Participant(data, sid, conversation, links, services) {
1255
- var _data$bindings;
1255
+ var _data$roleSid, _data$bindings;
1256
1256
 
1257
1257
  var _this;
1258
1258
 
@@ -1263,23 +1263,23 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1263
1263
  _this.links = links;
1264
1264
  _this.services = services;
1265
1265
  _this.state = {
1266
- 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),
1267
1267
  dateCreated: data.dateCreated ? parseTime$1(data.dateCreated) : null,
1268
1268
  dateUpdated: data.dateCreated ? parseTime$1(data.dateUpdated) : null,
1269
1269
  sid: sid,
1270
1270
  typingTimeout: null,
1271
1271
  isTyping: false,
1272
- identity: data.identity || null,
1273
- roleSid: data.roleSid || null,
1272
+ identity: data.identity,
1273
+ roleSid: (_data$roleSid = data.roleSid) !== null && _data$roleSid !== void 0 ? _data$roleSid : "",
1274
1274
  lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
1275
1275
  lastReadTimestamp: data.lastConsumptionTimestamp ? parseTime$1(data.lastConsumptionTimestamp) : null,
1276
- type: data.type || 'chat',
1276
+ type: data.type || "chat",
1277
1277
  userInfo: data.userInfo,
1278
1278
  bindings: (_data$bindings = data.bindings) !== null && _data$bindings !== void 0 ? _data$bindings : {}
1279
1279
  };
1280
1280
 
1281
1281
  if (!data.identity && !data.type) {
1282
- 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.");
1283
1283
  }
1284
1284
 
1285
1285
  return _this;
@@ -1399,7 +1399,9 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1399
1399
  }, {
1400
1400
  key: "bindings",
1401
1401
  get: function get() {
1402
- return this.state.bindings;
1402
+ var _this$state$bindings;
1403
+
1404
+ return (_this$state$bindings = this.state.bindings) !== null && _this$state$bindings !== void 0 ? _this$state$bindings : {};
1403
1405
  }
1404
1406
  }, {
1405
1407
  key: "_startTyping",
@@ -1411,13 +1413,16 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1411
1413
  function _startTyping(timeout) {
1412
1414
  var _this2 = this;
1413
1415
 
1414
- clearTimeout(this.state.typingTimeout);
1416
+ if (this.state.typingTimeout) {
1417
+ clearTimeout(this.state.typingTimeout);
1418
+ }
1419
+
1415
1420
  this.state.isTyping = true;
1416
- this.emit('typingStarted', this);
1417
- this.conversation.emit('typingStarted', this);
1418
- this.state.typingTimeout = setTimeout(function () {
1421
+ this.emit("typingStarted", this);
1422
+ this.conversation.emit("typingStarted", this);
1423
+ this.state.typingTimeout = Number(setTimeout(function () {
1419
1424
  return _this2._endTyping();
1420
- }, timeout);
1425
+ }, timeout));
1421
1426
  return this;
1422
1427
  }
1423
1428
  /**
@@ -1433,8 +1438,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1433
1438
  }
1434
1439
 
1435
1440
  this.state.isTyping = false;
1436
- this.emit('typingEnded', this);
1437
- this.conversation.emit('typingEnded', this);
1441
+ this.emit("typingEnded", this);
1442
+ this.conversation.emit("typingEnded", this);
1438
1443
  clearInterval(this.state.typingTimeout);
1439
1444
  this.state.typingTimeout = null;
1440
1445
  }
@@ -1447,35 +1452,35 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1447
1452
  key: "_update",
1448
1453
  value: function _update(data) {
1449
1454
  var updateReasons = [];
1450
- 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);
1451
1456
 
1452
1457
  if (data.attributes && !isEqual__default['default'](this.state.attributes, updateAttributes)) {
1453
1458
  this.state.attributes = updateAttributes;
1454
- updateReasons.push('attributes');
1459
+ updateReasons.push("attributes");
1455
1460
  }
1456
1461
 
1457
1462
  var updatedDateUpdated = parseTime$1(data.dateUpdated);
1458
1463
 
1459
- 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())) {
1460
1465
  this.state.dateUpdated = updatedDateUpdated;
1461
- updateReasons.push('dateUpdated');
1466
+ updateReasons.push("dateUpdated");
1462
1467
  }
1463
1468
 
1464
1469
  var updatedDateCreated = parseTime$1(data.dateCreated);
1465
1470
 
1466
- 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())) {
1467
1472
  this.state.dateCreated = updatedDateCreated;
1468
- updateReasons.push('dateCreated');
1473
+ updateReasons.push("dateCreated");
1469
1474
  }
1470
1475
 
1471
1476
  if (data.roleSid && this.state.roleSid !== data.roleSid) {
1472
1477
  this.state.roleSid = data.roleSid;
1473
- updateReasons.push('roleSid');
1478
+ updateReasons.push("roleSid");
1474
1479
  }
1475
1480
 
1476
1481
  if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null) && this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {
1477
1482
  this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;
1478
- updateReasons.push('lastReadMessageIndex');
1483
+ updateReasons.push("lastReadMessageIndex");
1479
1484
  }
1480
1485
 
1481
1486
  if (data.lastConsumptionTimestamp) {
@@ -1483,17 +1488,17 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1483
1488
 
1484
1489
  if (!this.state.lastReadTimestamp || this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {
1485
1490
  this.state.lastReadTimestamp = lastReadTimestamp;
1486
- updateReasons.push('lastReadTimestamp');
1491
+ updateReasons.push("lastReadTimestamp");
1487
1492
  }
1488
1493
  }
1489
1494
 
1490
1495
  if (data.bindings && !isEqual__default['default'](this.state.bindings, data.bindings)) {
1491
1496
  this.state.bindings = data.bindings;
1492
- updateReasons.push('bindings');
1497
+ updateReasons.push("bindings");
1493
1498
  }
1494
1499
 
1495
1500
  if (updateReasons.length > 0) {
1496
- this.emit('updated', {
1501
+ this.emit("updated", {
1497
1502
  participant: this,
1498
1503
  updateReasons: updateReasons
1499
1504
  });
@@ -1513,12 +1518,12 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1513
1518
  while (1) {
1514
1519
  switch (_context.prev = _context.next) {
1515
1520
  case 0:
1516
- if (!(this.type != 'chat')) {
1521
+ if (!(this.type != "chat")) {
1517
1522
  _context.next = 2;
1518
1523
  break;
1519
1524
  }
1520
1525
 
1521
- 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);
1522
1527
 
1523
1528
  case 2:
1524
1529
  return _context.abrupt("return", this.services.users.getUser(this.state.identity, this.state.userInfo));
@@ -1579,7 +1584,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1579
1584
  switch (_context3.prev = _context3.next) {
1580
1585
  case 0:
1581
1586
  _context3.next = 2;
1582
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
1587
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
1583
1588
  attributes: JSON.stringify(attributes)
1584
1589
  });
1585
1590
 
@@ -1605,18 +1610,18 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1605
1610
  return Participant;
1606
1611
  }(replayEventEmitter.ReplayEventEmitter);
1607
1612
 
1608
- _defineProperty__default['default'](Participant, "typingStarted", 'typingStarted');
1613
+ _defineProperty__default['default'](Participant, "typingStarted", "typingStarted");
1609
1614
 
1610
- _defineProperty__default['default'](Participant, "typingEnded", 'typingEnded');
1615
+ _defineProperty__default['default'](Participant, "typingEnded", "typingEnded");
1611
1616
 
1612
- _defineProperty__default['default'](Participant, "updated", 'updated');
1617
+ _defineProperty__default['default'](Participant, "updated", "updated");
1613
1618
 
1614
1619
  __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
1615
1620
 
1616
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); }; }
1617
1622
 
1618
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; } }
1619
- var log$6 = Logger.scope('Participants');
1624
+ var log$6 = Logger.scope("Participants");
1620
1625
  /**
1621
1626
  * @classdesc Represents the collection of participants for the conversation
1622
1627
  * @fires Participants#participantJoined
@@ -1635,6 +1640,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1635
1640
  _classCallCheck__default['default'](this, Participants);
1636
1641
 
1637
1642
  _this = _super.call(this);
1643
+
1644
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "rosterEntityPromise", null);
1645
+
1638
1646
  _this.conversation = conversation;
1639
1647
  _this.participants = participants;
1640
1648
  _this.links = links;
@@ -1686,17 +1694,17 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1686
1694
 
1687
1695
  return this.rosterEntityPromise = this.rosterEntityPromise || this.services.syncClient.map({
1688
1696
  id: rosterObjectName,
1689
- mode: 'open_existing'
1697
+ mode: "open_existing"
1690
1698
  }).then(function (rosterMap) {
1691
- rosterMap.on('itemAdded', function (args) {
1692
- 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);
1693
1701
 
1694
1702
  _this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
1695
- _this2.emit('participantJoined', participant);
1703
+ _this2.emit("participantJoined", participant);
1696
1704
  });
1697
1705
  });
1698
- rosterMap.on('itemRemoved', function (args) {
1699
- 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);
1700
1708
  var participantSid = args.key;
1701
1709
 
1702
1710
  if (!_this2.participants.has(participantSid)) {
@@ -1707,19 +1715,22 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1707
1715
 
1708
1716
  _this2.participants.delete(participantSid);
1709
1717
 
1710
- _this2.emit('participantLeft', leftParticipant);
1718
+ if (!leftParticipant) {
1719
+ return;
1720
+ }
1721
+
1722
+ _this2.emit("participantLeft", leftParticipant);
1711
1723
  });
1712
- rosterMap.on('itemUpdated', function (args) {
1713
- 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);
1714
1726
 
1715
1727
  _this2.upsertParticipant(args.item.key, args.item.data);
1716
1728
  });
1717
1729
  var participantsPromises = [];
1718
- var that = _this2;
1719
1730
 
1720
1731
  var rosterMapHandler = function rosterMapHandler(paginator) {
1721
1732
  paginator.items.forEach(function (item) {
1722
- participantsPromises.push(that.upsertParticipant(item.key, item.data));
1733
+ participantsPromises.push(_this2.upsertParticipant(item.key, item.data));
1723
1734
  });
1724
1735
  return paginator.hasNextPage ? paginator.nextPage().then(rosterMapHandler) : null;
1725
1736
  };
@@ -1732,11 +1743,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1732
1743
  }).catch(function (err) {
1733
1744
  _this2.rosterEntityPromise = null;
1734
1745
 
1735
- if (_this2.services.syncClient.connectionState != 'disconnected') {
1736
- 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);
1737
1748
  }
1738
1749
 
1739
- 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);
1740
1751
  throw err;
1741
1752
  });
1742
1753
  }
@@ -1766,8 +1777,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1766
1777
  };
1767
1778
  participant = new Participant(data, participantSid, this.conversation, links, this.services);
1768
1779
  this.participants.set(participantSid, participant);
1769
- participant.on('updated', function (args) {
1770
- return _this3.emit('participantUpdated', args);
1780
+ participant.on("updated", function (args) {
1781
+ return _this3.emit("participantUpdated", args);
1771
1782
  });
1772
1783
  return _context2.abrupt("return", participant);
1773
1784
 
@@ -1799,7 +1810,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1799
1810
  while (1) {
1800
1811
  switch (_context3.prev = _context3.next) {
1801
1812
  case 0:
1802
- return _context3.abrupt("return", this.rosterEntityPromise.then(function () {
1813
+ return _context3.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
1803
1814
  var participants = [];
1804
1815
 
1805
1816
  _this4.participants.forEach(function (participant) {
@@ -1807,7 +1818,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1807
1818
  });
1808
1819
 
1809
1820
  return participants;
1810
- }));
1821
+ }) : []);
1811
1822
 
1812
1823
  case 1:
1813
1824
  case "end":
@@ -1838,15 +1849,15 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1838
1849
  while (1) {
1839
1850
  switch (_context4.prev = _context4.next) {
1840
1851
  case 0:
1841
- return _context4.abrupt("return", this.rosterEntityPromise.then(function () {
1852
+ return _context4.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
1842
1853
  var participant = _this5.participants.get(participantSid);
1843
1854
 
1844
1855
  if (!participant) {
1845
- throw new Error('Participant with SID ' + participantSid + ' was not found');
1856
+ throw new Error("Participant with SID " + participantSid + " was not found");
1846
1857
  }
1847
1858
 
1848
1859
  return participant;
1849
- }));
1860
+ }) : null);
1850
1861
 
1851
1862
  case 1:
1852
1863
  case "end":
@@ -1879,7 +1890,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1879
1890
  switch (_context5.prev = _context5.next) {
1880
1891
  case 0:
1881
1892
  foundParticipant = null;
1882
- return _context5.abrupt("return", this.rosterEntityPromise.then(function () {
1893
+ return _context5.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
1883
1894
  _this6.participants.forEach(function (participant) {
1884
1895
  if (participant.identity === identity) {
1885
1896
  foundParticipant = participant;
@@ -1887,11 +1898,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1887
1898
  });
1888
1899
 
1889
1900
  if (!foundParticipant) {
1890
- throw new Error('Participant with identity ' + identity + ' was not found');
1901
+ throw new Error("Participant with identity " + identity + " was not found");
1891
1902
  }
1892
1903
 
1893
1904
  return foundParticipant;
1894
- }));
1905
+ }) : null);
1895
1906
 
1896
1907
  case 2:
1897
1908
  case "end":
@@ -1909,7 +1920,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1909
1920
  }()
1910
1921
  /**
1911
1922
  * Add a chat participant to the conversation
1912
- * @returns {Promise<any>}
1923
+ * @returns {Promise<ParticipantResponse>}
1913
1924
  */
1914
1925
 
1915
1926
  }, {
@@ -1921,9 +1932,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1921
1932
  switch (_context6.prev = _context6.next) {
1922
1933
  case 0:
1923
1934
  _context6.next = 2;
1924
- return this.services.commandExecutor.mutateResource('post', this.links.participants, {
1935
+ return this.services.commandExecutor.mutateResource("post", this.links.participants, {
1925
1936
  identity: identity,
1926
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
1937
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
1927
1938
  });
1928
1939
 
1929
1940
  case 2:
@@ -1960,8 +1971,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1960
1971
 
1961
1972
  var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1962
1973
  var bindingOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1963
- return this.services.commandExecutor.mutateResource('post', this.links.participants, {
1964
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined,
1974
+ return this.services.commandExecutor.mutateResource("post", this.links.participants, {
1975
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
1965
1976
  messaging_binding: {
1966
1977
  address: address,
1967
1978
  proxy_address: proxyAddress,
@@ -1977,7 +1988,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1977
1988
  }, {
1978
1989
  key: "remove",
1979
1990
  value: function remove(identity) {
1980
- 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));
1981
1992
  }
1982
1993
  }]);
1983
1994
 
@@ -2088,6 +2099,8 @@ var Media = /*#__PURE__*/function () {
2088
2099
  key: "getContentTemporaryUrl",
2089
2100
  value: function () {
2090
2101
  var _getContentTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
2102
+ var _this$mcsMedia$getCon, _this$mcsMedia;
2103
+
2091
2104
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
2092
2105
  while (1) {
2093
2106
  switch (_context.prev = _context.next) {
@@ -2096,7 +2109,7 @@ var Media = /*#__PURE__*/function () {
2096
2109
  return this._fetchMcsMedia();
2097
2110
 
2098
2111
  case 2:
2099
- 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);
2100
2113
 
2101
2114
  case 3:
2102
2115
  case "end":
@@ -2126,6 +2139,8 @@ var Media = /*#__PURE__*/function () {
2126
2139
  key: "getCachedTemporaryUrl",
2127
2140
  value: function () {
2128
2141
  var _getCachedTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
2142
+ var _this$mcsMedia$getCac, _this$mcsMedia2;
2143
+
2129
2144
  return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
2130
2145
  while (1) {
2131
2146
  switch (_context2.prev = _context2.next) {
@@ -2134,7 +2149,7 @@ var Media = /*#__PURE__*/function () {
2134
2149
  return this._fetchMcsMedia();
2135
2150
 
2136
2151
  case 2:
2137
- 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);
2138
2153
 
2139
2154
  case 3:
2140
2155
  case "end":
@@ -2177,7 +2192,7 @@ var Media = /*#__PURE__*/function () {
2177
2192
  break;
2178
2193
 
2179
2194
  case 7:
2180
- throw new Error('Media Content Service is unavailable');
2195
+ throw new Error("Media Content Service is unavailable");
2181
2196
 
2182
2197
  case 8:
2183
2198
  case "end":
@@ -2371,7 +2386,7 @@ var RestPaginator = /*#__PURE__*/function () {
2371
2386
  }, {
2372
2387
  key: "nextPage",
2373
2388
  value: function nextPage() {
2374
- 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"));
2375
2390
  }
2376
2391
  /**
2377
2392
  * Request the previous page. Does not modify the existing object.
@@ -2380,7 +2395,7 @@ var RestPaginator = /*#__PURE__*/function () {
2380
2395
  }, {
2381
2396
  key: "prevPage",
2382
2397
  value: function prevPage() {
2383
- 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"));
2384
2399
  }
2385
2400
  }]);
2386
2401
 
@@ -2439,7 +2454,7 @@ function DetailedDeliveryReceipt(descriptor) {
2439
2454
  this.conversationSid = descriptor.conversation_sid;
2440
2455
  this.channelMessageSid = descriptor.channel_message_sid;
2441
2456
  this.participantSid = descriptor.participant_sid;
2442
- this.status = descriptor.status || 'queued';
2457
+ this.status = descriptor.status || "queued";
2443
2458
  this.errorCode = descriptor.error_code || 0;
2444
2459
  this.dateCreated = descriptor.date_created;
2445
2460
  this.dateUpdated = descriptor.date_updated;
@@ -2448,7 +2463,7 @@ function DetailedDeliveryReceipt(descriptor) {
2448
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); }; }
2449
2464
 
2450
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; } }
2451
- var log$5 = Logger.scope('Message');
2466
+ var log$5 = Logger.scope("Message");
2452
2467
  /**
2453
2468
  * A message in a conversation.
2454
2469
  */
@@ -2466,7 +2481,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2466
2481
  * @internal
2467
2482
  */
2468
2483
  function Message(index, data, conversation, links, configuration, services) {
2469
- var _data$author, _data$subject, _data$lastUpdatedBy, _data$type, _data$memberSid;
2484
+ var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
2470
2485
 
2471
2486
  var _this;
2472
2487
 
@@ -2480,16 +2495,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2480
2495
  _this.state = {
2481
2496
  sid: data.sid,
2482
2497
  index: index,
2483
- author: (_data$author = data.author) !== null && _data$author !== void 0 ? _data$author : null,
2484
- subject: (_data$subject = data.subject) !== null && _data$subject !== void 0 ? _data$subject : null,
2485
- 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,
2486
2501
  timestamp: data.timestamp ? new Date(data.timestamp) : null,
2487
2502
  dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
2488
2503
  lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
2489
2504
  attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$5),
2490
- type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : 'text',
2491
- media: data.type && data.type === 'media' && data.media ? new Media(data.media, _this.services) : null,
2492
- 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) {
2493
2508
  return new Media(m, _this.services);
2494
2509
  }) : null,
2495
2510
  participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
@@ -2622,7 +2637,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2622
2637
  }, {
2623
2638
  key: "attachedMedia",
2624
2639
  get: function get() {
2625
- return this.getMediaByCategory(['media']);
2640
+ return this.getMediaByCategory(["media"]);
2626
2641
  }
2627
2642
  /**
2628
2643
  * The server-assigned unique identifier of the authoring participant.
@@ -2631,7 +2646,9 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2631
2646
  }, {
2632
2647
  key: "participantSid",
2633
2648
  get: function get() {
2634
- 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 : "";
2635
2652
  }
2636
2653
  /**
2637
2654
  * Aggregated information about the message delivery statuses across all participants of a conversation..
@@ -2654,7 +2671,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2654
2671
  value: function getMediaByCategory(categories) {
2655
2672
  var _this$state$medias;
2656
2673
 
2657
- 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) {
2658
2675
  return categories.includes(m.category);
2659
2676
  });
2660
2677
  }
@@ -2669,8 +2686,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2669
2686
  value: function getEmailBody() {
2670
2687
  var _this$getMediaByCateg, _this$getMediaByCateg2;
2671
2688
 
2672
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text/plain';
2673
- return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.getMediaByCategory(['body'])) === null || _this$getMediaByCateg2 === void 0 ? void 0 : _this$getMediaByCateg2.filter(function (m) {
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) {
2674
2691
  return m.contentType == type;
2675
2692
  }).shift()) !== null && _this$getMediaByCateg !== void 0 ? _this$getMediaByCateg : null;
2676
2693
  }
@@ -2685,8 +2702,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2685
2702
  value: function getEmailHistory() {
2686
2703
  var _this$getMediaByCateg3, _this$getMediaByCateg4;
2687
2704
 
2688
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text/plain';
2689
- return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.getMediaByCategory(['history'])) === null || _this$getMediaByCateg4 === void 0 ? void 0 : _this$getMediaByCateg4.filter(function (m) {
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) {
2690
2707
  return m.contentType == type;
2691
2708
  }).shift()) !== null && _this$getMediaByCateg3 !== void 0 ? _this$getMediaByCateg3 : null;
2692
2709
  }
@@ -2695,41 +2712,41 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2695
2712
  value: function _update(data) {
2696
2713
  var updateReasons = [];
2697
2714
 
2698
- 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) {
2699
2716
  this.state.body = data.text;
2700
- updateReasons.push('body');
2717
+ updateReasons.push("body");
2701
2718
  }
2702
2719
 
2703
2720
  if (data.subject && data.subject !== this.state.subject) {
2704
2721
  this.state.subject = data.subject;
2705
- updateReasons.push('subject');
2722
+ updateReasons.push("subject");
2706
2723
  }
2707
2724
 
2708
2725
  if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {
2709
2726
  this.state.lastUpdatedBy = data.lastUpdatedBy;
2710
- updateReasons.push('lastUpdatedBy');
2727
+ updateReasons.push("lastUpdatedBy");
2711
2728
  }
2712
2729
 
2713
2730
  if (data.author && data.author !== this.state.author) {
2714
2731
  this.state.author = data.author;
2715
- updateReasons.push('author');
2732
+ updateReasons.push("author");
2716
2733
  }
2717
2734
 
2718
2735
  if (data.dateUpdated && new Date(data.dateUpdated).getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
2719
2736
  this.state.dateUpdated = new Date(data.dateUpdated);
2720
- updateReasons.push('dateUpdated');
2737
+ updateReasons.push("dateUpdated");
2721
2738
  }
2722
2739
 
2723
2740
  if (data.timestamp && new Date(data.timestamp).getTime() !== (this.state.timestamp && this.state.timestamp.getTime())) {
2724
2741
  this.state.timestamp = new Date(data.timestamp);
2725
- updateReasons.push('dateCreated');
2742
+ updateReasons.push("dateCreated");
2726
2743
  }
2727
2744
 
2728
2745
  var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$5);
2729
2746
 
2730
2747
  if (!isEqual__default['default'](this.state.attributes, updatedAttributes)) {
2731
2748
  this.state.attributes = updatedAttributes;
2732
- updateReasons.push('attributes');
2749
+ updateReasons.push("attributes");
2733
2750
  }
2734
2751
 
2735
2752
  var updatedAggregatedDelivery = data.delivery;
@@ -2739,16 +2756,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2739
2756
  if (isUpdatedAggregateDeliveryValid) {
2740
2757
  if (!currentAggregatedDelivery) {
2741
2758
  this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(updatedAggregatedDelivery);
2742
- updateReasons.push('deliveryReceipt');
2759
+ updateReasons.push("deliveryReceipt");
2743
2760
  } else if (!currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)) {
2744
2761
  currentAggregatedDelivery._update(updatedAggregatedDelivery);
2745
2762
 
2746
- updateReasons.push('deliveryReceipt');
2763
+ updateReasons.push("deliveryReceipt");
2747
2764
  }
2748
2765
  }
2749
2766
 
2750
2767
  if (updateReasons.length > 0) {
2751
- this.emit('updated', {
2768
+ this.emit("updated", {
2752
2769
  message: this,
2753
2770
  updateReasons: updateReasons
2754
2771
  });
@@ -2809,25 +2826,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2809
2826
  return _context.abrupt("return", participant);
2810
2827
 
2811
2828
  case 11:
2812
- errorMesage = 'Participant with ';
2829
+ errorMesage = "Participant with ";
2813
2830
 
2814
2831
  if (this.state.participantSid) {
2815
- errorMesage += 'SID \'' + this.state.participantSid + '\' ';
2832
+ errorMesage += "SID '" + this.state.participantSid + "' ";
2816
2833
  }
2817
2834
 
2818
2835
  if (this.state.author) {
2819
2836
  if (this.state.participantSid) {
2820
- errorMesage += 'or ';
2837
+ errorMesage += "or ";
2821
2838
  }
2822
2839
 
2823
- errorMesage += 'identity \'' + this.state.author + '\' ';
2840
+ errorMesage += "identity '" + this.state.author + "' ";
2824
2841
  }
2825
2842
 
2826
- if (errorMesage === 'Participant with ') {
2827
- errorMesage = 'Participant ';
2843
+ if (errorMesage === "Participant with ") {
2844
+ errorMesage = "Participant ";
2828
2845
  }
2829
2846
 
2830
- errorMesage += 'was not found';
2847
+ errorMesage += "was not found";
2831
2848
  throw new Error(errorMesage);
2832
2849
 
2833
2850
  case 17:
@@ -2914,7 +2931,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2914
2931
  switch (_context3.prev = _context3.next) {
2915
2932
  case 0:
2916
2933
  _context3.next = 2;
2917
- return this.services.commandExecutor.mutateResource('delete', this.links.self);
2934
+ return this.services.commandExecutor.mutateResource("delete", this.links.self);
2918
2935
 
2919
2936
  case 2:
2920
2937
  return _context3.abrupt("return", this);
@@ -2947,7 +2964,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2947
2964
  switch (_context4.prev = _context4.next) {
2948
2965
  case 0:
2949
2966
  _context4.next = 2;
2950
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
2967
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
2951
2968
  body: body
2952
2969
  });
2953
2970
 
@@ -2982,8 +2999,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
2982
2999
  switch (_context5.prev = _context5.next) {
2983
3000
  case 0:
2984
3001
  _context5.next = 2;
2985
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
2986
- 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
2987
3004
  });
2988
3005
 
2989
3006
  case 2:
@@ -3021,11 +3038,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3021
3038
  case 0:
3022
3039
  // We ignore existing mcsMedia members of each of the media entries.
3023
3040
  // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
3024
- sids = contentSet.map(function (m) {
3041
+ sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
3025
3042
  return m.sid;
3026
3043
  });
3027
3044
 
3028
- if (!this.services.mcsClient) {
3045
+ if (!(this.services.mcsClient && sids)) {
3029
3046
  _context6.next = 7;
3030
3047
  break;
3031
3048
  }
@@ -3039,7 +3056,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3039
3056
  }));
3040
3057
 
3041
3058
  case 7:
3042
- throw new Error('Media Content Service is unavailable');
3059
+ throw new Error("Media Content Service is unavailable");
3043
3060
 
3044
3061
  case 8:
3045
3062
  case "end":
@@ -3066,8 +3083,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3066
3083
  while (1) {
3067
3084
  switch (_context7.prev = _context7.next) {
3068
3085
  case 0:
3069
- messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace('%s', this.conversation.sid).replace('%s', this.sid);
3070
- 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();
3071
3088
  _context7.next = 4;
3072
3089
  return this.services.network.get(url);
3073
3090
 
@@ -3101,20 +3118,20 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3101
3118
  return Message;
3102
3119
  }(replayEventEmitter.ReplayEventEmitter);
3103
3120
 
3104
- _defineProperty__default['default'](Message, "updated", 'updated');
3121
+ _defineProperty__default['default'](Message, "updated", "updated");
3105
3122
 
3106
- __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
3123
+ __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
3107
3124
 
3108
- __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
3125
+ __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
3109
3126
 
3110
- __decorate([declarativeTypeValidator.validateTypesAsync('string'), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
3127
+ __decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
3111
3128
 
3112
3129
  __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
3113
3130
 
3114
3131
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.custom(function (value) {
3115
3132
  return [value instanceof Array && value.length > 0 && value.reduce(function (a, c) {
3116
3133
  return a && c instanceof Media;
3117
- }, true), 'a non-empty array of Media'];
3134
+ }, true), "a non-empty array of Media"];
3118
3135
  })), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
3119
3136
 
3120
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; } } }; }
@@ -3126,7 +3143,7 @@ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) le
3126
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); }; }
3127
3144
 
3128
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; } }
3129
- var log$4 = Logger.scope('Messages');
3146
+ var log$4 = Logger.scope("Messages");
3130
3147
  /**
3131
3148
  * Represents the collection of messages in a conversation
3132
3149
  */
@@ -3176,7 +3193,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3176
3193
  case 2:
3177
3194
  this.messagesListPromise = this.services.syncClient.list({
3178
3195
  id: name,
3179
- mode: 'open_existing'
3196
+ mode: "open_existing"
3180
3197
  });
3181
3198
  _context.prev = 3;
3182
3199
  _context.next = 6;
@@ -3184,7 +3201,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3184
3201
 
3185
3202
  case 6:
3186
3203
  list = _context.sent;
3187
- list.on('itemAdded', function (args) {
3204
+ list.on("itemAdded", function (args) {
3188
3205
  log$4.debug("".concat(_this2.conversation.sid, " itemAdded: ").concat(args.item.index));
3189
3206
  var links = {
3190
3207
  self: "".concat(_this2.conversation.links.messages, "/").concat(args.item.data.sid),
@@ -3194,33 +3211,37 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3194
3211
  var message = new Message(args.item.index, args.item.data, _this2.conversation, links, _this2.configuration, _this2.services);
3195
3212
 
3196
3213
  if (_this2.messagesByIndex.has(message.index)) {
3197
- 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);
3198
3215
  return;
3199
3216
  }
3200
3217
 
3201
3218
  _this2.messagesByIndex.set(message.index, message);
3202
3219
 
3203
- message.on('updated', function (args) {
3204
- return _this2.emit('messageUpdated', args);
3220
+ message.on("updated", function (args) {
3221
+ return _this2.emit("messageUpdated", args);
3205
3222
  });
3206
3223
 
3207
- _this2.emit('messageAdded', message);
3224
+ _this2.emit("messageAdded", message);
3208
3225
  });
3209
- list.on('itemRemoved', function (args) {
3226
+ list.on("itemRemoved", function (args) {
3210
3227
  log$4.debug("#{this.conversation.sid} itemRemoved: ".concat(args.index));
3211
3228
  var index = args.index;
3212
3229
 
3213
3230
  if (_this2.messagesByIndex.has(index)) {
3214
3231
  var message = _this2.messagesByIndex.get(index);
3215
3232
 
3233
+ if (!message) {
3234
+ return;
3235
+ }
3236
+
3216
3237
  _this2.messagesByIndex.delete(message.index);
3217
3238
 
3218
- message.removeAllListeners('updated');
3239
+ message.removeAllListeners("updated");
3219
3240
 
3220
- _this2.emit('messageRemoved', message);
3241
+ _this2.emit("messageRemoved", message);
3221
3242
  }
3222
3243
  });
3223
- list.on('itemUpdated', function (args) {
3244
+ list.on("itemUpdated", function (args) {
3224
3245
  log$4.debug("".concat(_this2.conversation.sid, " itemUpdated: ").concat(args.item.index));
3225
3246
 
3226
3247
  var message = _this2.messagesByIndex.get(args.item.index);
@@ -3236,11 +3257,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3236
3257
  _context.t0 = _context["catch"](3);
3237
3258
  this.messagesListPromise = null;
3238
3259
 
3239
- if (this.services.syncClient.connectionState !== 'disconnected') {
3240
- 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);
3241
3262
  }
3242
3263
 
3243
- 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);
3244
3265
  throw _context.t0;
3245
3266
 
3246
3267
  case 19:
@@ -3308,13 +3329,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3308
3329
  var _sendV = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(message) {
3309
3330
  var _message$emailOptions;
3310
3331
 
3311
- var media, _iterator, _step, _step$value, category, mediaContent;
3332
+ var media, _iterator, _step, _mediaContent$content, _mediaContent$media, _step$value, category, mediaContent;
3312
3333
 
3313
3334
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
3314
3335
  while (1) {
3315
3336
  switch (_context3.prev = _context3.next) {
3316
3337
  case 0:
3317
- 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);
3318
3339
  media = [];
3319
3340
  _iterator = _createForOfIteratorHelper$2(message.mediaContent);
3320
3341
  _context3.prev = 3;
@@ -3328,7 +3349,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3328
3349
  }
3329
3350
 
3330
3351
  _step$value = _slicedToArray__default['default'](_step.value, 2), category = _step$value[0], mediaContent = _step$value[1];
3331
- 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);
3332
3353
  _context3.t0 = media;
3333
3354
 
3334
3355
  if (!(mediaContent instanceof FormData)) {
@@ -3346,7 +3367,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3346
3367
 
3347
3368
  case 15:
3348
3369
  _context3.next = 17;
3349
- 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);
3350
3371
 
3351
3372
  case 17:
3352
3373
  _context3.t1 = _context3.sent;
@@ -3379,13 +3400,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3379
3400
 
3380
3401
  case 30:
3381
3402
  _context3.next = 32;
3382
- return this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
3403
+ return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
3383
3404
  body: message.text,
3384
3405
  subject: (_message$emailOptions = message.emailOptions) === null || _message$emailOptions === void 0 ? void 0 : _message$emailOptions.subject,
3385
3406
  media_sids: media.map(function (m) {
3386
3407
  return m.sid;
3387
3408
  }),
3388
- attributes: typeof message.attributes !== 'undefined' ? JSON.stringify(message.attributes) : undefined
3409
+ attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
3389
3410
  });
3390
3411
 
3391
3412
  case 32:
@@ -3426,11 +3447,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3426
3447
  case 0:
3427
3448
  attributes = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
3428
3449
  emailOptions = _args4.length > 2 ? _args4[2] : undefined;
3429
- log$4.debug('Sending text message', message, attributes, emailOptions);
3450
+ log$4.debug("Sending text message", message, attributes, emailOptions);
3430
3451
  _context4.next = 5;
3431
- return this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
3432
- body: message !== null && message !== void 0 ? message : '',
3433
- 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,
3434
3455
  subject: emailOptions === null || emailOptions === void 0 ? void 0 : emailOptions.subject
3435
3456
  });
3436
3457
 
@@ -3463,6 +3484,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3463
3484
  key: "sendMedia",
3464
3485
  value: function () {
3465
3486
  var _sendMedia = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(mediaContent) {
3487
+ var _mediaContent$content2, _mediaContent$media2;
3488
+
3466
3489
  var attributes,
3467
3490
  emailOptions,
3468
3491
  media,
@@ -3473,8 +3496,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3473
3496
  case 0:
3474
3497
  attributes = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
3475
3498
  emailOptions = _args5.length > 2 ? _args5[2] : undefined;
3476
- log$4.debug('Sending media message', mediaContent, attributes, emailOptions);
3477
- 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);
3478
3501
 
3479
3502
  if (!(mediaContent instanceof FormData)) {
3480
3503
  _context5.next = 10;
@@ -3491,7 +3514,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3491
3514
 
3492
3515
  case 10:
3493
3516
  _context5.next = 12;
3494
- 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);
3495
3518
 
3496
3519
  case 12:
3497
3520
  _context5.t0 = _context5.sent;
@@ -3499,9 +3522,9 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3499
3522
  case 13:
3500
3523
  media = _context5.t0;
3501
3524
  _context5.next = 16;
3502
- return this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
3525
+ return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
3503
3526
  media_sids: [media.sid],
3504
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
3527
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
3505
3528
  });
3506
3529
 
3507
3530
  case 16:
@@ -3539,7 +3562,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3539
3562
  while (1) {
3540
3563
  switch (_context6.prev = _context6.next) {
3541
3564
  case 0:
3542
- direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : 'backwards';
3565
+ direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : "backwards";
3543
3566
  return _context6.abrupt("return", this._getMessages(pageSize, anchor, direction));
3544
3567
 
3545
3568
  case 2:
@@ -3563,7 +3586,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3563
3586
 
3564
3587
  // Due to an inconsistency between Sync and Chat conventions, next and
3565
3588
  // previous pages should be swapped.
3566
- var shouldReverse = order === 'desc';
3589
+ var shouldReverse = order === "desc";
3567
3590
 
3568
3591
  var nextPage = function nextPage() {
3569
3592
  return page.nextPage().then(function (page) {
@@ -3607,8 +3630,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3607
3630
  };
3608
3631
  var message = new Message(index, value, this.conversation, links, this.configuration, this.services);
3609
3632
  this.messagesByIndex.set(message.index, message);
3610
- message.on('updated', function (args) {
3611
- return _this4.emit('messageUpdated', args);
3633
+ message.on("updated", function (args) {
3634
+ return _this4.emit("messageUpdated", args);
3612
3635
  });
3613
3636
  return message;
3614
3637
  }
@@ -3639,17 +3662,17 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3639
3662
  switch (_context7.prev = _context7.next) {
3640
3663
  case 0:
3641
3664
  pageSize = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : 30;
3642
- anchor = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : 'end';
3643
- direction = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : 'forward';
3644
- 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";
3645
3668
  _context7.next = 6;
3646
3669
  return this.messagesListPromise;
3647
3670
 
3648
3671
  case 6:
3649
3672
  list = _context7.sent;
3650
3673
  _context7.next = 9;
3651
- return list.getItems({
3652
- from: anchor !== 'end' ? anchor : void 0,
3674
+ return list === null || list === void 0 ? void 0 : list.getItems({
3675
+ from: anchor !== "end" ? anchor : void 0,
3653
3676
  pageSize: pageSize,
3654
3677
  order: order,
3655
3678
  limit: pageSize // @todo Limit equals pageSize by default in Sync. This is probably not ideal.
@@ -3841,19 +3864,19 @@ var MessageBuilder = /*#__PURE__*/function () {
3841
3864
  }, {
3842
3865
  key: "addMedia",
3843
3866
  value: function addMedia(payload) {
3844
- if (typeof FormData === 'undefined' && payload instanceof FormData) {
3845
- throw new Error('Could not add FormData content whilst not in a browser');
3867
+ if (typeof FormData === "undefined" && payload instanceof FormData) {
3868
+ throw new Error("Could not add FormData content whilst not in a browser");
3846
3869
  }
3847
3870
 
3848
3871
  if (!(payload instanceof FormData)) {
3849
3872
  var mediaOptions = payload;
3850
3873
 
3851
3874
  if (!mediaOptions.contentType || !mediaOptions.media) {
3852
- throw new Error('Media content in SendMediaOptions must contain non-empty contentType and media');
3875
+ throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media");
3853
3876
  }
3854
3877
  }
3855
3878
 
3856
- this.message.mediaContent.push(['media', payload]);
3879
+ this.message.mediaContent.push(["media", payload]);
3857
3880
  return this;
3858
3881
  }
3859
3882
  /**
@@ -3891,18 +3914,18 @@ var MessageBuilder = /*#__PURE__*/function () {
3891
3914
 
3892
3915
 
3893
3916
  this.emailBodies.forEach(function (body) {
3894
- _this.message.mediaContent.push(['body', body]);
3917
+ _this.message.mediaContent.push(["body", body]);
3895
3918
  });
3896
3919
  this.emailHistories.forEach(function (history) {
3897
- _this.message.mediaContent.push(['history', history]);
3920
+ _this.message.mediaContent.push(["history", history]);
3898
3921
  });
3899
3922
  return this.message;
3900
3923
  }
3901
3924
  }, {
3902
3925
  key: "getPayloadContentType",
3903
3926
  value: function getPayloadContentType(payload) {
3904
- if (typeof FormData !== 'undefined' && payload instanceof FormData) {
3905
- return payload.get('Content-Type');
3927
+ if (typeof FormData !== "undefined" && payload instanceof FormData) {
3928
+ return payload.get("Content-Type");
3906
3929
  }
3907
3930
 
3908
3931
  return payload.contentType;
@@ -3921,21 +3944,21 @@ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) le
3921
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); }; }
3922
3945
 
3923
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; } }
3924
- var log$3 = Logger.scope('Conversation');
3947
+ var log$3 = Logger.scope("Conversation");
3925
3948
  var fieldMappings = {
3926
- lastMessage: 'lastMessage',
3927
- attributes: 'attributes',
3928
- createdBy: 'createdBy',
3929
- dateCreated: 'dateCreated',
3930
- dateUpdated: 'dateUpdated',
3931
- friendlyName: 'friendlyName',
3932
- lastConsumedMessageIndex: 'lastConsumedMessageIndex',
3933
- notificationLevel: 'notificationLevel',
3934
- sid: 'sid',
3935
- status: 'status',
3936
- uniqueName: 'uniqueName',
3937
- state: 'state',
3938
- bindings: 'bindings'
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"
3939
3962
  };
3940
3963
 
3941
3964
  function parseTime(timeString) {
@@ -3985,13 +4008,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
3985
4008
  try {
3986
4009
  JSON.stringify(attributes);
3987
4010
  } catch (e) {
3988
- throw new Error('Attributes must be a valid JSON object.');
4011
+ throw new Error("Attributes must be a valid JSON object.");
3989
4012
  }
3990
4013
 
3991
4014
  _this.entityName = descriptor.channel;
3992
4015
  _this.channelState = {
3993
4016
  uniqueName: uniqueName,
3994
- status: 'notParticipating',
4017
+ status: "notParticipating",
3995
4018
  attributes: attributes,
3996
4019
  createdBy: createdBy,
3997
4020
  dateCreated: dateCreated,
@@ -4011,25 +4034,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4011
4034
  _this.participants = new Map();
4012
4035
  _this.participantsEntity = new Participants(_assertThisInitialized__default['default'](_this), _this.participants, participantsLinks, _this.configuration, _this.services);
4013
4036
 
4014
- _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
+ });
4015
4040
 
4016
- _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
+ });
4017
4044
 
4018
- _this.participantsEntity.on('participantUpdated', function (args) {
4019
- return _this.emit('participantUpdated', args);
4045
+ _this.participantsEntity.on("participantUpdated", function (args) {
4046
+ return _this.emit("participantUpdated", args);
4020
4047
  });
4021
4048
 
4022
4049
  _this.messagesEntity = new Messages(_assertThisInitialized__default['default'](_this), configuration, services);
4023
4050
 
4024
- _this.messagesEntity.on('messageAdded', function (message) {
4051
+ _this.messagesEntity.on("messageAdded", function (message) {
4025
4052
  return _this._onMessageAdded(message);
4026
4053
  });
4027
4054
 
4028
- _this.messagesEntity.on('messageUpdated', function (args) {
4029
- return _this.emit('messageUpdated', args);
4055
+ _this.messagesEntity.on("messageUpdated", function (args) {
4056
+ return _this.emit("messageUpdated", args);
4030
4057
  });
4031
4058
 
4032
- _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
+ });
4033
4062
 
4034
4063
  return _this;
4035
4064
  }
@@ -4094,7 +4123,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4094
4123
  }, {
4095
4124
  key: "createdBy",
4096
4125
  get: function get() {
4097
- 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 : "";
4098
4129
  }
4099
4130
  /**
4100
4131
  * Custom attributes of the conversation.
@@ -4121,7 +4152,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4121
4152
  }, {
4122
4153
  key: "lastMessage",
4123
4154
  get: function get() {
4124
- 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;
4125
4158
  }
4126
4159
  /**
4127
4160
  * User notification level for this conversation.
@@ -4130,7 +4163,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4130
4163
  }, {
4131
4164
  key: "notificationLevel",
4132
4165
  get: function get() {
4133
- 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";
4134
4169
  }
4135
4170
  }, {
4136
4171
  key: "bindings",
@@ -4165,16 +4200,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4165
4200
 
4166
4201
  return this.entityPromise = (_this$entityPromise = this.entityPromise) !== null && _this$entityPromise !== void 0 ? _this$entityPromise : this.services.syncClient.document({
4167
4202
  id: this.entityName,
4168
- mode: 'open_existing'
4203
+ mode: "open_existing"
4169
4204
  }).then(function (entity) {
4170
4205
  _this2.entity = entity;
4171
4206
 
4172
- _this2.entity.on('updated', function (args) {
4207
+ _this2.entity.on("updated", function (args) {
4173
4208
  _this2._update(args.data);
4174
4209
  });
4175
4210
 
4176
- _this2.entity.on('removed', function () {
4177
- return _this2.emit('removed', _this2);
4211
+ _this2.entity.on("removed", function () {
4212
+ return _this2.emit("removed", _this2);
4178
4213
  });
4179
4214
 
4180
4215
  _this2._update(_this2.entity.data);
@@ -4184,11 +4219,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4184
4219
  _this2.entity = null;
4185
4220
  _this2.entityPromise = null;
4186
4221
 
4187
- if (_this2.services.syncClient.connectionState != 'disconnected') {
4188
- 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);
4189
4224
  }
4190
4225
 
4191
- log$3.debug('ERROR: Failed to get conversation object', err);
4226
+ log$3.debug("ERROR: Failed to get conversation object", err);
4192
4227
  throw err;
4193
4228
  });
4194
4229
  }
@@ -4203,7 +4238,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4203
4238
  key: "_subscribeStreams",
4204
4239
  value: function () {
4205
4240
  var _subscribeStreams2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
4206
- var messagesObjectName, rosterObjectName;
4241
+ var _this$entity, _this$entity2, _this$entity3, messagesObjectName, rosterObjectName;
4242
+
4207
4243
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
4208
4244
  while (1) {
4209
4245
  switch (_context.prev = _context.next) {
@@ -4213,9 +4249,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4213
4249
  return this._subscribe();
4214
4250
 
4215
4251
  case 3:
4216
- log$3.trace('_subscribeStreams, this.entity.data=', this.entity.data);
4217
- messagesObjectName = this.entity.data.messages;
4218
- 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;
4219
4255
  _context.next = 8;
4220
4256
  return Promise.all([this.messagesEntity.subscribe(messagesObjectName), this.participantsEntity.subscribe(rosterObjectName)]);
4221
4257
 
@@ -4227,11 +4263,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4227
4263
  _context.prev = 10;
4228
4264
  _context.t0 = _context["catch"](0);
4229
4265
 
4230
- if (this.services.syncClient.connectionState !== 'disconnected') {
4231
- 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);
4232
4268
  }
4233
4269
 
4234
- 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);
4235
4271
  throw _context.t0;
4236
4272
 
4237
4273
  case 15:
@@ -4308,19 +4344,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4308
4344
 
4309
4345
  this.channelState.status = status;
4310
4346
 
4311
- if (status === 'joined') {
4347
+ if (status === "joined") {
4312
4348
  this._subscribeStreams().catch(function (err) {
4313
- log$3.debug('ERROR while setting conversation status ' + status, err);
4349
+ log$3.debug("ERROR while setting conversation status " + status, err);
4314
4350
 
4315
- if (_this3.services.syncClient.connectionState !== 'disconnected') {
4351
+ if (_this3.services.syncClient.connectionState !== "disconnected") {
4316
4352
  throw err;
4317
4353
  }
4318
4354
  });
4319
4355
  } else if (this.entityPromise) {
4320
4356
  this._unsubscribe().catch(function (err) {
4321
- log$3.debug('ERROR while setting conversation status ' + status, err);
4357
+ log$3.debug("ERROR while setting conversation status " + status, err);
4322
4358
 
4323
- if (_this3.services.syncClient.connectionState !== 'disconnected') {
4359
+ if (_this3.services.syncClient.connectionState !== "disconnected") {
4324
4360
  throw err;
4325
4361
  }
4326
4362
  });
@@ -4344,9 +4380,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4344
4380
  * @internal
4345
4381
  */
4346
4382
  function _update(update) {
4347
- 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;
4348
4384
 
4349
- log$3.trace('_update', update);
4385
+ log$3.trace("_update", update);
4350
4386
  Conversation.preprocessUpdate(update, this.sid);
4351
4387
  var updateReasons = new Set();
4352
4388
 
@@ -4360,7 +4396,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4360
4396
 
4361
4397
  switch (localKey) {
4362
4398
  case fieldMappings.status:
4363
- if (!update.status || update.status === 'unknown' || this.channelState.status === update.status) {
4399
+ if (!update.status || update.status === "unknown" || this.channelState.status === update.status) {
4364
4400
  break;
4365
4401
  }
4366
4402
 
@@ -4383,7 +4419,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4383
4419
  }
4384
4420
 
4385
4421
  this.channelState.lastReadMessageIndex = update.lastConsumedMessageIndex;
4386
- updateReasons.add('lastReadMessageIndex');
4422
+ updateReasons.add("lastReadMessageIndex");
4387
4423
  break;
4388
4424
 
4389
4425
  case fieldMappings.lastMessage:
@@ -4400,7 +4436,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4400
4436
  updateReasons.add(localKey);
4401
4437
  }
4402
4438
 
4403
- 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()) {
4404
4440
  this.channelState.lastMessage.dateCreated = update.lastMessage.timestamp;
4405
4441
  updateReasons.add(localKey);
4406
4442
  }
@@ -4450,7 +4486,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4450
4486
  }
4451
4487
 
4452
4488
  if (updateReasons.size > 0) {
4453
- this.emit('updated', {
4489
+ this.emit("updated", {
4454
4490
  conversation: this,
4455
4491
  updateReasons: _toConsumableArray__default['default'](updateReasons)
4456
4492
  });
@@ -4482,7 +4518,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4482
4518
  _iterator.f();
4483
4519
  }
4484
4520
 
4485
- this.emit('messageAdded', message);
4521
+ this.emit("messageAdded", message);
4486
4522
  }
4487
4523
  }, {
4488
4524
  key: "_setLastReadMessageIndex",
@@ -4494,7 +4530,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4494
4530
  switch (_context3.prev = _context3.next) {
4495
4531
  case 0:
4496
4532
  _context3.next = 2;
4497
- 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), {
4498
4534
  last_read_message_index: index
4499
4535
  });
4500
4536
 
@@ -4603,7 +4639,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4603
4639
  return this._subscribeStreams();
4604
4640
 
4605
4641
  case 2:
4606
- if (!(index < this.lastReadMessageIndex)) {
4642
+ if (!(index < (this.lastReadMessageIndex || 0))) {
4607
4643
  _context6.next = 6;
4608
4644
  break;
4609
4645
  }
@@ -4648,7 +4684,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4648
4684
  switch (_context7.prev = _context7.next) {
4649
4685
  case 0:
4650
4686
  _context7.next = 2;
4651
- return this.services.commandExecutor.mutateResource('delete', this.links.self);
4687
+ return this.services.commandExecutor.mutateResource("delete", this.links.self);
4652
4688
 
4653
4689
  case 2:
4654
4690
  return _context7.abrupt("return", this);
@@ -4783,6 +4819,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4783
4819
  key: "getParticipantsCount",
4784
4820
  value: function () {
4785
4821
  var _getParticipantsCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
4822
+ var _response$body$partic;
4823
+
4786
4824
  var url, response;
4787
4825
  return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
4788
4826
  while (1) {
@@ -4794,7 +4832,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4794
4832
 
4795
4833
  case 3:
4796
4834
  response = _context11.sent;
4797
- 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);
4798
4836
 
4799
4837
  case 5:
4800
4838
  case "end":
@@ -4847,14 +4885,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4847
4885
  }, {
4848
4886
  key: "getParticipantByIdentity",
4849
4887
  value: function () {
4850
- 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;
4851
4891
  return _regeneratorRuntime__default['default'].wrap(function _callee13$(_context13) {
4852
4892
  while (1) {
4853
4893
  switch (_context13.prev = _context13.next) {
4854
4894
  case 0:
4855
- 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 : ""));
4856
4897
 
4857
- case 1:
4898
+ case 2:
4858
4899
  case "end":
4859
4900
  return _context13.stop();
4860
4901
  }
@@ -4862,7 +4903,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4862
4903
  }, _callee13, this);
4863
4904
  }));
4864
4905
 
4865
- function getParticipantByIdentity(_x11) {
4906
+ function getParticipantByIdentity() {
4866
4907
  return _getParticipantByIdentity.apply(this, arguments);
4867
4908
  }
4868
4909
 
@@ -4883,6 +4924,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4883
4924
  key: "getMessagesCount",
4884
4925
  value: function () {
4885
4926
  var _getMessagesCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee14() {
4927
+ var _response$body$messag;
4928
+
4886
4929
  var url, response;
4887
4930
  return _regeneratorRuntime__default['default'].wrap(function _callee14$(_context14) {
4888
4931
  while (1) {
@@ -4894,7 +4937,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4894
4937
 
4895
4938
  case 3:
4896
4939
  response = _context14.sent;
4897
- 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);
4898
4941
 
4899
4942
  case 5:
4900
4943
  case "end":
@@ -4947,12 +4990,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4947
4990
  break;
4948
4991
  }
4949
4992
 
4950
- 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");
4951
4994
 
4952
4995
  case 6:
4953
4996
  unreadMessageCount = response.body.unread_messages_count;
4954
4997
 
4955
- if (!(typeof unreadMessageCount === 'number')) {
4998
+ if (!(typeof unreadMessageCount === "number")) {
4956
4999
  _context15.next = 9;
4957
5000
  break;
4958
5001
  }
@@ -4989,7 +5032,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4989
5032
  switch (_context16.prev = _context16.next) {
4990
5033
  case 0:
4991
5034
  _context16.next = 2;
4992
- return this.services.commandExecutor.mutateResource('post', this.links.participants, {
5035
+ return this.services.commandExecutor.mutateResource("post", this.links.participants, {
4993
5036
  identity: this.configuration.userIdentity
4994
5037
  });
4995
5038
 
@@ -5022,13 +5065,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5022
5065
  while (1) {
5023
5066
  switch (_context17.prev = _context17.next) {
5024
5067
  case 0:
5025
- if (!(this.channelState.status === 'joined')) {
5068
+ if (!(this.channelState.status === "joined")) {
5026
5069
  _context17.next = 3;
5027
5070
  break;
5028
5071
  }
5029
5072
 
5030
5073
  _context17.next = 3;
5031
- 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));
5032
5075
 
5033
5076
  case 3:
5034
5077
  return _context17.abrupt("return", this);
@@ -5053,6 +5096,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5053
5096
  * @param participant Identity, SID or the participant object to remove.
5054
5097
  */
5055
5098
 
5099
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
5100
+ // @ts-ignore TODO: fix validateTypesAsync typing
5101
+
5056
5102
  }, {
5057
5103
  key: "removeParticipant",
5058
5104
  value: function () {
@@ -5062,7 +5108,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5062
5108
  switch (_context18.prev = _context18.next) {
5063
5109
  case 0:
5064
5110
  _context18.next = 2;
5065
- return this.participantsEntity.remove(typeof participant === 'string' ? participant : participant.sid);
5111
+ return this.participantsEntity.remove(typeof participant === "string" ? participant : participant.sid);
5066
5112
 
5067
5113
  case 2:
5068
5114
  case "end":
@@ -5072,7 +5118,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5072
5118
  }, _callee18, this);
5073
5119
  }));
5074
5120
 
5075
- function removeParticipant(_x12) {
5121
+ function removeParticipant(_x11) {
5076
5122
  return _removeParticipant.apply(this, arguments);
5077
5123
  }
5078
5124
 
@@ -5091,13 +5137,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5091
5137
  key: "sendMessage",
5092
5138
  value: function () {
5093
5139
  var _sendMessage = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(message, messageAttributes, emailOptions) {
5094
- var _response, response;
5140
+ var _parseToNumber2;
5141
+
5142
+ var _parseToNumber, _response, response;
5095
5143
 
5096
5144
  return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
5097
5145
  while (1) {
5098
5146
  switch (_context19.prev = _context19.next) {
5099
5147
  case 0:
5100
- if (!(typeof message === 'string' || message === null)) {
5148
+ if (!(typeof message === "string" || message === null)) {
5101
5149
  _context19.next = 5;
5102
5150
  break;
5103
5151
  }
@@ -5107,7 +5155,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5107
5155
 
5108
5156
  case 3:
5109
5157
  _response = _context19.sent;
5110
- return _context19.abrupt("return", parseToNumber(_response.index));
5158
+ return _context19.abrupt("return", (_parseToNumber = parseToNumber(_response.index)) !== null && _parseToNumber !== void 0 ? _parseToNumber : 0);
5111
5159
 
5112
5160
  case 5:
5113
5161
  _context19.next = 7;
@@ -5115,7 +5163,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5115
5163
 
5116
5164
  case 7:
5117
5165
  response = _context19.sent;
5118
- return _context19.abrupt("return", parseToNumber(response.index));
5166
+ return _context19.abrupt("return", (_parseToNumber2 = parseToNumber(response.index)) !== null && _parseToNumber2 !== void 0 ? _parseToNumber2 : 0);
5119
5167
 
5120
5168
  case 9:
5121
5169
  case "end":
@@ -5125,7 +5173,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5125
5173
  }, _callee19, this);
5126
5174
  }));
5127
5175
 
5128
- function sendMessage(_x13, _x14, _x15) {
5176
+ function sendMessage(_x12, _x13, _x14) {
5129
5177
  return _sendMessage.apply(this, arguments);
5130
5178
  }
5131
5179
 
@@ -5241,7 +5289,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5241
5289
  switch (_context22.prev = _context22.next) {
5242
5290
  case 0:
5243
5291
  _context22.next = 2;
5244
- 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), {
5245
5293
  notification_level: notificationLevel
5246
5294
  });
5247
5295
 
@@ -5253,7 +5301,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5253
5301
  }, _callee22, this);
5254
5302
  }));
5255
5303
 
5256
- function setUserNotificationLevel(_x16) {
5304
+ function setUserNotificationLevel(_x15) {
5257
5305
  return _setUserNotificationLevel.apply(this, arguments);
5258
5306
  }
5259
5307
 
@@ -5283,7 +5331,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5283
5331
  switch (_context23.prev = _context23.next) {
5284
5332
  case 0:
5285
5333
  _context23.next = 2;
5286
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
5334
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
5287
5335
  attributes: attributes !== undefined ? JSON.stringify(attributes) : undefined
5288
5336
  });
5289
5337
 
@@ -5298,7 +5346,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5298
5346
  }, _callee23, this);
5299
5347
  }));
5300
5348
 
5301
- function updateAttributes(_x17) {
5349
+ function updateAttributes(_x16) {
5302
5350
  return _updateAttributes.apply(this, arguments);
5303
5351
  }
5304
5352
 
@@ -5323,7 +5371,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5323
5371
  }
5324
5372
 
5325
5373
  _context24.next = 3;
5326
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
5374
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
5327
5375
  friendly_name: friendlyName
5328
5376
  });
5329
5377
 
@@ -5338,7 +5386,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5338
5386
  }, _callee24, this);
5339
5387
  }));
5340
5388
 
5341
- function updateFriendlyName(_x18) {
5389
+ function updateFriendlyName(_x17) {
5342
5390
  return _updateFriendlyName.apply(this, arguments);
5343
5391
  }
5344
5392
 
@@ -5373,7 +5421,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5373
5421
  }, _callee25, this);
5374
5422
  }));
5375
5423
 
5376
- function updateLastReadMessageIndex(_x19) {
5424
+ function updateLastReadMessageIndex(_x18) {
5377
5425
  return _updateLastReadMessageIndex.apply(this, arguments);
5378
5426
  }
5379
5427
 
@@ -5398,11 +5446,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5398
5446
  }
5399
5447
 
5400
5448
  if (!uniqueName) {
5401
- uniqueName = '';
5449
+ uniqueName = "";
5402
5450
  }
5403
5451
 
5404
5452
  _context26.next = 4;
5405
- return this.services.commandExecutor.mutateResource('post', this.links.self, {
5453
+ return this.services.commandExecutor.mutateResource("post", this.links.self, {
5406
5454
  unique_name: uniqueName
5407
5455
  });
5408
5456
 
@@ -5417,7 +5465,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5417
5465
  }, _callee26, this);
5418
5466
  }));
5419
5467
 
5420
- function updateUniqueName(_x20) {
5468
+ function updateUniqueName(_x19) {
5421
5469
  return _updateUniqueName.apply(this, arguments);
5422
5470
  }
5423
5471
 
@@ -5427,13 +5475,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5427
5475
  key: "preprocessUpdate",
5428
5476
  value: function preprocessUpdate(update, conversationSid) {
5429
5477
  try {
5430
- if (typeof update.attributes === 'string') {
5478
+ if (typeof update.attributes === "string") {
5431
5479
  update.attributes = JSON.parse(update.attributes);
5432
5480
  } else if (update.attributes) {
5433
5481
  JSON.stringify(update.attributes);
5434
5482
  }
5435
5483
  } catch (e) {
5436
- 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);
5437
5485
  update.attributes = {};
5438
5486
  }
5439
5487
 
@@ -5442,7 +5490,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5442
5490
  update.dateCreated = new Date(update.dateCreated);
5443
5491
  }
5444
5492
  } catch (e) {
5445
- 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);
5446
5494
  delete update.dateCreated;
5447
5495
  }
5448
5496
 
@@ -5451,7 +5499,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5451
5499
  update.dateUpdated = new Date(update.dateUpdated);
5452
5500
  }
5453
5501
  } catch (e) {
5454
- 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);
5455
5503
  delete update.dateUpdated;
5456
5504
  }
5457
5505
 
@@ -5460,7 +5508,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5460
5508
  update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);
5461
5509
  }
5462
5510
  } catch (e) {
5463
- 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);
5464
5512
  delete update.lastMessage.timestamp;
5465
5513
  }
5466
5514
  }
@@ -5469,25 +5517,25 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5469
5517
  return Conversation;
5470
5518
  }(replayEventEmitter.ReplayEventEmitter);
5471
5519
 
5472
- _defineProperty__default['default'](Conversation, "participantJoined", 'participantJoined');
5520
+ _defineProperty__default['default'](Conversation, "participantJoined", "participantJoined");
5473
5521
 
5474
- _defineProperty__default['default'](Conversation, "participantLeft", 'participantLeft');
5522
+ _defineProperty__default['default'](Conversation, "participantLeft", "participantLeft");
5475
5523
 
5476
- _defineProperty__default['default'](Conversation, "participantUpdated", 'participantUpdated');
5524
+ _defineProperty__default['default'](Conversation, "participantUpdated", "participantUpdated");
5477
5525
 
5478
- _defineProperty__default['default'](Conversation, "messageAdded", 'messageAdded');
5526
+ _defineProperty__default['default'](Conversation, "messageAdded", "messageAdded");
5479
5527
 
5480
- _defineProperty__default['default'](Conversation, "messageRemoved", 'messageRemoved');
5528
+ _defineProperty__default['default'](Conversation, "messageRemoved", "messageRemoved");
5481
5529
 
5482
- _defineProperty__default['default'](Conversation, "messageUpdated", 'messageUpdated');
5530
+ _defineProperty__default['default'](Conversation, "messageUpdated", "messageUpdated");
5483
5531
 
5484
- _defineProperty__default['default'](Conversation, "typingEnded", 'typingEnded');
5532
+ _defineProperty__default['default'](Conversation, "typingEnded", "typingEnded");
5485
5533
 
5486
- _defineProperty__default['default'](Conversation, "typingStarted", 'typingStarted');
5534
+ _defineProperty__default['default'](Conversation, "typingStarted", "typingStarted");
5487
5535
 
5488
- _defineProperty__default['default'](Conversation, "updated", 'updated');
5536
+ _defineProperty__default['default'](Conversation, "updated", "updated");
5489
5537
 
5490
- _defineProperty__default['default'](Conversation, "removed", 'removed');
5538
+ _defineProperty__default['default'](Conversation, "removed", "removed");
5491
5539
 
5492
5540
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalAttributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
5493
5541
 
@@ -5495,7 +5543,7 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
5495
5543
 
5496
5544
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
5497
5545
 
5498
- __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);
5499
5547
 
5500
5548
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getParticipantBySid", null);
5501
5549
 
@@ -5503,33 +5551,33 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
5503
5551
 
5504
5552
  __decorate([declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, Participant]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "removeParticipant", null);
5505
5553
 
5506
- __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.
5507
5555
  declarativeTypeValidator.custom(function (value) {
5508
- return [value instanceof FormData, 'an instance of FormData'];
5509
- }), declarativeTypeValidator.objectSchema('media options', {
5556
+ return [value instanceof FormData, "an instance of FormData"];
5557
+ }), declarativeTypeValidator.objectSchema("media options", {
5510
5558
  contentType: declarativeTypeValidator.nonEmptyString,
5511
5559
  media: declarativeTypeValidator.custom(function (value) {
5512
- 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;
5513
5561
 
5514
- if (typeof Blob === 'function') {
5562
+ if (typeof Blob === "function") {
5515
5563
  isValid = isValid || value instanceof Blob;
5516
5564
  }
5517
5565
 
5518
- 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"];
5519
5567
  })
5520
- })], optionalAttributesValidator, ['undefined', declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema('email attributes', {
5521
- subject: [declarativeTypeValidator.nonEmptyString, 'undefined']
5568
+ })], optionalAttributesValidator, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
5569
+ subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
5522
5570
  })]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
5523
5571
 
5524
- __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);
5525
5573
 
5526
5574
  __decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
5527
5575
 
5528
- __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);
5529
5577
 
5530
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);
5531
5579
 
5532
- __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);
5533
5581
 
5534
5582
  var Deferred = /*#__PURE__*/function () {
5535
5583
  function Deferred() {
@@ -5583,7 +5631,7 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
5583
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); }; }
5584
5632
 
5585
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; } }
5586
- var log$2 = Logger.scope('Conversations');
5634
+ var log$2 = Logger.scope("Conversations");
5587
5635
  /**
5588
5636
  * Represents conversations collection
5589
5637
  * {@see Conversation}
@@ -5625,12 +5673,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5625
5673
  while (1) {
5626
5674
  switch (_context.prev = _context.next) {
5627
5675
  case 0:
5628
- 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 : {};
5629
5677
  _context.next = 3;
5630
- return this.services.commandExecutor.mutateResource('post', this.configuration.links.conversations, {
5678
+ return this.services.commandExecutor.mutateResource("post", this.configuration.links.conversations, {
5631
5679
  friendly_name: options.friendlyName,
5632
5680
  unique_name: options.uniqueName,
5633
- attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
5681
+ attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
5634
5682
  });
5635
5683
 
5636
5684
  case 3:
@@ -5656,12 +5704,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5656
5704
  case 12:
5657
5705
  conversation = new Conversation({
5658
5706
  channel: conversationDocument,
5659
- entityName: null,
5660
- uniqueName: null,
5707
+ entityName: "",
5708
+ uniqueName: "",
5661
5709
  attributes: null,
5662
- createdBy: null,
5663
- friendlyName: null,
5664
- lastConsumedMessageIndex: null,
5710
+ createdBy: "",
5711
+ friendlyName: "",
5712
+ lastConsumedMessageIndex: 0,
5665
5713
  dateCreated: null,
5666
5714
  dateUpdated: null
5667
5715
  }, conversationSid, links, this.configuration, this.services);
@@ -5673,7 +5721,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5673
5721
  return conversation._subscribe();
5674
5722
 
5675
5723
  case 17:
5676
- this.emit('conversationAdded', conversation);
5724
+ this.emit("conversationAdded", conversation);
5677
5725
  return _context.abrupt("return", conversation);
5678
5726
 
5679
5727
  case 19:
@@ -5712,12 +5760,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5712
5760
 
5713
5761
  case 3:
5714
5762
  map = _context2.sent;
5715
- map.on('itemAdded', function (args) {
5763
+ map.on("itemAdded", function (args) {
5716
5764
  log$2.debug("itemAdded: ".concat(args.item.key));
5717
5765
 
5718
- _this2._upsertConversation('sync', args.item.key, args.item.data);
5766
+ _this2._upsertConversation("sync", args.item.key, args.item.data);
5719
5767
  });
5720
- map.on('itemRemoved', function (args) {
5768
+ map.on("itemRemoved", function (args) {
5721
5769
  log$2.debug("itemRemoved: ".concat(args.key));
5722
5770
  var sid = args.key;
5723
5771
 
@@ -5731,22 +5779,22 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5731
5779
  return;
5732
5780
  }
5733
5781
 
5734
- if (conversation.status === 'joined') {
5735
- conversation._setStatus('notParticipating', 'sync');
5782
+ if (conversation.status === "joined") {
5783
+ conversation._setStatus("notParticipating", "sync");
5736
5784
 
5737
- _this2.emit('conversationLeft', conversation);
5785
+ _this2.emit("conversationLeft", conversation);
5738
5786
  }
5739
5787
 
5740
5788
  _this2.conversations.delete(sid);
5741
5789
 
5742
- _this2.emit('conversationRemoved', conversation);
5790
+ _this2.emit("conversationRemoved", conversation);
5743
5791
 
5744
- conversation.emit('removed', conversation);
5792
+ conversation.emit("removed", conversation);
5745
5793
  });
5746
- map.on('itemUpdated', function (args) {
5794
+ map.on("itemUpdated", function (args) {
5747
5795
  log$2.debug("itemUpdated: ".concat(args.item.key));
5748
5796
 
5749
- _this2._upsertConversation('sync', args.item.key, args.item.data);
5797
+ _this2._upsertConversation("sync", args.item.key, args.item.data);
5750
5798
  });
5751
5799
  _context2.next = 9;
5752
5800
  return this._fetchMyConversations();
@@ -5759,7 +5807,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5759
5807
  try {
5760
5808
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
5761
5809
  conversation = _step.value;
5762
- upserts.push(this._upsertConversation('rest', conversation.channel_sid, conversation));
5810
+ upserts.push(this._upsertConversation("rest", conversation["channel_sid"], conversation));
5763
5811
  }
5764
5812
  } catch (err) {
5765
5813
  _iterator.e(err);
@@ -5774,15 +5822,15 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5774
5822
  case 16:
5775
5823
  this.myConversationsFetched = true;
5776
5824
  this.tombstones.clear();
5777
- log$2.debug('The conversations list has been successfully fetched');
5825
+ log$2.debug("The conversations list has been successfully fetched");
5778
5826
  return _context2.abrupt("return", this);
5779
5827
 
5780
5828
  case 22:
5781
5829
  _context2.prev = 22;
5782
5830
  _context2.t0 = _context2["catch"](0);
5783
- errorMessage = 'Failed to fetch the conversations list';
5831
+ errorMessage = "Failed to fetch the conversations list";
5784
5832
 
5785
- if (this.services.syncClient.connectionState !== 'disconnected') {
5833
+ if (this.services.syncClient.connectionState !== "disconnected") {
5786
5834
  log$2.error(errorMessage, _context2.t0);
5787
5835
  }
5788
5836
 
@@ -5806,7 +5854,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5806
5854
  }, {
5807
5855
  key: "getConversations",
5808
5856
  value: function () {
5809
- 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() {
5810
5858
  var _this3 = this;
5811
5859
 
5812
5860
  var conversationsMap, page;
@@ -5826,7 +5874,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5826
5874
  page = _context3.sent;
5827
5875
  return _context3.abrupt("return", this._wrapPaginator(page, function (items) {
5828
5876
  return Promise.all(items.map(function (item) {
5829
- return _this3._upsertConversation('sync', item.key, item.data);
5877
+ return _this3._upsertConversation("sync", item.key, item.data);
5830
5878
  }));
5831
5879
  }));
5832
5880
 
@@ -5838,7 +5886,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5838
5886
  }, _callee3, this);
5839
5887
  }));
5840
5888
 
5841
- function getConversations(_x2) {
5889
+ function getConversations() {
5842
5890
  return _getConversations.apply(this, arguments);
5843
5891
  }
5844
5892
 
@@ -5868,7 +5916,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5868
5916
  case 5:
5869
5917
  page = _context4.sent;
5870
5918
  items = page.items.map(function (item) {
5871
- return _this4._upsertConversation('sync', item.key, item.data);
5919
+ return _this4._upsertConversation("sync", item.key, item.data);
5872
5920
  });
5873
5921
  return _context4.abrupt("return", items.length > 0 ? items[0] : null);
5874
5922
 
@@ -5880,7 +5928,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5880
5928
  }, _callee4, this);
5881
5929
  }));
5882
5930
 
5883
- function getConversation(_x3) {
5931
+ function getConversation(_x2) {
5884
5932
  return _getConversation.apply(this, arguments);
5885
5933
  }
5886
5934
 
@@ -5906,7 +5954,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5906
5954
  data = {
5907
5955
  entityName: null,
5908
5956
  lastConsumedMessageIndex: body.last_read_message_index,
5909
- status: (body === null || body === void 0 ? void 0 : body.status) || 'unknown',
5957
+ status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
5910
5958
  friendlyName: body.friendly_name,
5911
5959
  dateUpdated: body.date_updated,
5912
5960
  dateCreated: body.date_created,
@@ -5917,7 +5965,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5917
5965
  notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
5918
5966
  sid: sid
5919
5967
  };
5920
- return _context5.abrupt("return", this._upsertConversation('sync', sid, data));
5968
+ return _context5.abrupt("return", sid ? this._upsertConversation("sync", sid, data) : null);
5921
5969
 
5922
5970
  case 8:
5923
5971
  case "end":
@@ -5927,7 +5975,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5927
5975
  }, _callee5, this);
5928
5976
  }));
5929
5977
 
5930
- function getConversationByUniqueName(_x4) {
5978
+ function getConversationByUniqueName(_x3) {
5931
5979
  return _getConversationByUniqueName.apply(this, arguments);
5932
5980
  }
5933
5981
 
@@ -5952,7 +6000,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5952
6000
  data = {
5953
6001
  entityName: null,
5954
6002
  // lastConsumedMessageIndex: body.last_read_message_index,
5955
- status: (body === null || body === void 0 ? void 0 : body.status) || 'unknown',
6003
+ status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
5956
6004
  friendlyName: body.friendly_name,
5957
6005
  dateUpdated: body.date_updated,
5958
6006
  dateCreated: body.date_created,
@@ -5963,7 +6011,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5963
6011
  // notificationLevel: body?.notification_level,
5964
6012
  sid: sid
5965
6013
  };
5966
- return _context6.abrupt("return", this._upsertConversation('sync', sid, data));
6014
+ return _context6.abrupt("return", this._upsertConversation("sync", sid, data));
5967
6015
 
5968
6016
  case 7:
5969
6017
  case "end":
@@ -5973,7 +6021,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5973
6021
  }, _callee6, this);
5974
6022
  }));
5975
6023
 
5976
- function peekConversation(_x5) {
6024
+ function peekConversation(_x4) {
5977
6025
  return _peekConversation.apply(this, arguments);
5978
6026
  }
5979
6027
 
@@ -5990,7 +6038,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
5990
6038
  _context7.next = 2;
5991
6039
  return this.services.syncClient.map({
5992
6040
  id: this.configuration.myConversations,
5993
- mode: 'open_existing'
6041
+ mode: "open_existing"
5994
6042
  });
5995
6043
 
5996
6044
  case 2:
@@ -6050,7 +6098,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6050
6098
  }, _callee8);
6051
6099
  }));
6052
6100
 
6053
- function _wrapPaginator(_x6, _x7) {
6101
+ function _wrapPaginator(_x5, _x6) {
6054
6102
  return _wrapPaginator2.apply(this, arguments);
6055
6103
  }
6056
6104
 
@@ -6068,14 +6116,14 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6068
6116
  switch (_context9.prev = _context9.next) {
6069
6117
  case 0:
6070
6118
  areSourcesDifferent = conversation._statusSource() !== undefined && source !== conversation._statusSource();
6071
- isChannelSourceSync = source !== 'rest' || conversation._statusSource() === 'sync';
6119
+ isChannelSourceSync = source !== "rest" || conversation._statusSource() === "sync";
6072
6120
 
6073
- if (!(areSourcesDifferent && isChannelSourceSync && source !== 'sync')) {
6121
+ if (!(areSourcesDifferent && isChannelSourceSync && source !== "sync")) {
6074
6122
  _context9.next = 5;
6075
6123
  break;
6076
6124
  }
6077
6125
 
6078
- 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", {
6079
6127
  sid: conversation.sid,
6080
6128
  data: data.status,
6081
6129
  conversation: conversation.status
@@ -6083,20 +6131,20 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6083
6131
  return _context9.abrupt("return");
6084
6132
 
6085
6133
  case 5:
6086
- if (!(data.status === 'joined' && conversation.status !== 'joined')) {
6134
+ if (!(data.status === "joined" && conversation.status !== "joined")) {
6087
6135
  _context9.next = 13;
6088
6136
  break;
6089
6137
  }
6090
6138
 
6091
- conversation._setStatus('joined', source);
6139
+ conversation._setStatus("joined", source);
6092
6140
 
6093
6141
  updateData = {};
6094
6142
 
6095
- if (typeof data.notificationLevel !== 'undefined') {
6143
+ if (typeof data.notificationLevel !== "undefined") {
6096
6144
  updateData.notificationLevel = data.notificationLevel;
6097
6145
  }
6098
6146
 
6099
- if (typeof data.lastConsumedMessageIndex !== 'undefined') {
6147
+ if (typeof data.lastConsumedMessageIndex !== "undefined") {
6100
6148
  updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
6101
6149
  }
6102
6150
 
@@ -6105,18 +6153,18 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6105
6153
  }
6106
6154
 
6107
6155
  conversation._subscribe().then(function () {
6108
- _this6.emit('conversationJoined', conversation);
6156
+ _this6.emit("conversationJoined", conversation);
6109
6157
  });
6110
6158
 
6111
6159
  return _context9.abrupt("return");
6112
6160
 
6113
6161
  case 13:
6114
- if (!(data.status === 'notParticipating' && conversation.status === 'joined')) {
6162
+ if (!(data.status === "notParticipating" && conversation.status === "joined")) {
6115
6163
  _context9.next = 20;
6116
6164
  break;
6117
6165
  }
6118
6166
 
6119
- conversation._setStatus('notParticipating', source);
6167
+ conversation._setStatus("notParticipating", source);
6120
6168
 
6121
6169
  conversation._update(data);
6122
6170
 
@@ -6124,11 +6172,11 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6124
6172
  return conversation._subscribe();
6125
6173
 
6126
6174
  case 18:
6127
- this.emit('conversationLeft', conversation);
6175
+ this.emit("conversationLeft", conversation);
6128
6176
  return _context9.abrupt("return");
6129
6177
 
6130
6178
  case 20:
6131
- if (!(data.status === 'notParticipating')) {
6179
+ if (!(data.status === "notParticipating")) {
6132
6180
  _context9.next = 24;
6133
6181
  break;
6134
6182
  }
@@ -6150,7 +6198,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6150
6198
  }, _callee9, this);
6151
6199
  }));
6152
6200
 
6153
- function _updateConversation(_x8, _x9, _x10) {
6201
+ function _updateConversation(_x7, _x8, _x9) {
6154
6202
  return _updateConversation2.apply(this, arguments);
6155
6203
  }
6156
6204
 
@@ -6185,17 +6233,17 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6185
6233
  return _context10.abrupt("return", conversation);
6186
6234
 
6187
6235
  case 9:
6188
- if (!(['chat', 'rest'].includes(source) && this.tombstones.has(sid))) {
6236
+ if (!(["chat", "rest"].includes(source) && this.tombstones.has(sid))) {
6189
6237
  _context10.next = 12;
6190
6238
  break;
6191
6239
  }
6192
6240
 
6193
- log$2.trace('upsertChannel: the channel is deleted but reappeared again from chat, ignoring', sid);
6194
- 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);
6195
6243
 
6196
6244
  case 12:
6197
6245
  // If the conversation is unknown, fetch it
6198
- 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);
6199
6247
  baseLink = "".concat(this.configuration.links.conversations, "/").concat(sid);
6200
6248
  links = {
6201
6249
  self: baseLink,
@@ -6210,12 +6258,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6210
6258
  case 19:
6211
6259
  this._registerForEvents(newConversation);
6212
6260
 
6213
- this.emit('conversationAdded', newConversation);
6261
+ this.emit("conversationAdded", newConversation);
6214
6262
 
6215
- if (data.status === 'joined') {
6216
- newConversation._setStatus('joined', source);
6263
+ if (data.status === "joined") {
6264
+ newConversation._setStatus("joined", source);
6217
6265
 
6218
- this.emit('conversationJoined', newConversation);
6266
+ this.emit("conversationJoined", newConversation);
6219
6267
  }
6220
6268
 
6221
6269
  return _context10.abrupt("return", newConversation);
@@ -6228,7 +6276,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6228
6276
  }, _callee10, this);
6229
6277
  }));
6230
6278
 
6231
- function _upsertConversation(_x11, _x12, _x13) {
6279
+ function _upsertConversation(_x10, _x11, _x12) {
6232
6280
  return _upsertConversation2.apply(this, arguments);
6233
6281
  }
6234
6282
 
@@ -6238,7 +6286,8 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6238
6286
  key: "_fetchMyConversations",
6239
6287
  value: function () {
6240
6288
  var _fetchMyConversations2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
6241
- var conversations, pageToken, url, response, receivedConversations;
6289
+ var conversations, pageToken, _response$body, url, response, receivedConversations;
6290
+
6242
6291
  return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
6243
6292
  while (1) {
6244
6293
  switch (_context11.prev = _context11.next) {
@@ -6250,7 +6299,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6250
6299
  url = new UriBuilder(this.configuration.links.myConversations);
6251
6300
 
6252
6301
  if (pageToken) {
6253
- url.arg('PageToken', pageToken);
6302
+ url.arg("PageToken", pageToken);
6254
6303
  }
6255
6304
 
6256
6305
  _context11.next = 6;
@@ -6258,7 +6307,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6258
6307
 
6259
6308
  case 6:
6260
6309
  response = _context11.sent;
6261
- 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) {
6262
6311
  return {
6263
6312
  descriptor: conversationDescriptor,
6264
6313
  channel_sid: conversationDescriptor.conversation_sid,
@@ -6303,7 +6352,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6303
6352
 
6304
6353
  if (conversation) {
6305
6354
  this.conversations.delete(sid);
6306
- this.emit('conversationRemoved', conversation);
6355
+ this.emit("conversationRemoved", conversation);
6307
6356
  }
6308
6357
  }
6309
6358
  }, {
@@ -6311,24 +6360,36 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6311
6360
  value: function _registerForEvents(conversation) {
6312
6361
  var _this7 = this;
6313
6362
 
6314
- conversation.on('removed', function () {
6363
+ conversation.on("removed", function () {
6315
6364
  return _this7._onConversationRemoved(conversation.sid);
6316
6365
  });
6317
- conversation.on('updated', function (args) {
6318
- return _this7.emit('conversationUpdated', args);
6366
+ conversation.on("updated", function (args) {
6367
+ return _this7.emit("conversationUpdated", args);
6319
6368
  });
6320
- conversation.on('participantJoined', this.emit.bind(this, 'participantJoined'));
6321
- conversation.on('participantLeft', this.emit.bind(this, 'participantLeft'));
6322
- conversation.on('participantUpdated', function (args) {
6323
- return _this7.emit('participantUpdated', args);
6369
+ conversation.on("participantJoined", function (participant) {
6370
+ return _this7.emit("participantJoined", participant);
6324
6371
  });
6325
- conversation.on('messageAdded', this.emit.bind(this, 'messageAdded'));
6326
- conversation.on('messageUpdated', function (args) {
6327
- return _this7.emit('messageUpdated', args);
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);
6380
+ });
6381
+ conversation.on("messageUpdated", function (args) {
6382
+ return _this7.emit("messageUpdated", args);
6383
+ });
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);
6328
6392
  });
6329
- conversation.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
6330
- conversation.on('typingStarted', this.emit.bind(this, 'typingStarted'));
6331
- conversation.on('typingEnded', this.emit.bind(this, 'typingEnded'));
6332
6393
  }
6333
6394
  }]);
6334
6395
 
@@ -6358,16 +6419,16 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6358
6419
  _this.fifoStack = [];
6359
6420
  _this.myself = myself;
6360
6421
 
6361
- _this.myself.on('updated', function (args) {
6362
- return _this.emit('userUpdated', args);
6422
+ _this.myself.on("updated", function (args) {
6423
+ return _this.emit("userUpdated", args);
6363
6424
  });
6364
6425
 
6365
- _this.myself.on('userSubscribed', function () {
6366
- return _this.emit('userSubscribed', _this.myself);
6426
+ _this.myself.on("userSubscribed", function () {
6427
+ return _this.emit("userSubscribed", _this.myself);
6367
6428
  });
6368
6429
 
6369
- _this.myself.on('userUnsubscribed', function () {
6370
- _this.emit('userUnsubscribed', _this.myself);
6430
+ _this.myself.on("userUnsubscribed", function () {
6431
+ _this.emit("userUnsubscribed", _this.myself);
6371
6432
 
6372
6433
  _this.myself._ensureFetched();
6373
6434
  });
@@ -6383,7 +6444,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6383
6444
  this.subscribedUsers.delete(user.identity);
6384
6445
  }
6385
6446
 
6386
- var foundItemIndex = -1;
6447
+ var foundItemIndex = 0;
6387
6448
  var foundItem = this.fifoStack.find(function (item, index) {
6388
6449
  if (item == user.identity) {
6389
6450
  foundItemIndex = index;
@@ -6397,7 +6458,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6397
6458
  this.fifoStack.splice(foundItemIndex, 1);
6398
6459
  }
6399
6460
 
6400
- this.emit('userUnsubscribed', user);
6461
+ this.emit("userUnsubscribed", user);
6401
6462
  }
6402
6463
  }, {
6403
6464
  key: "handleSubscribeUser",
@@ -6407,12 +6468,15 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6407
6468
  }
6408
6469
 
6409
6470
  if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {
6410
- 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();
6411
6475
  }
6412
6476
 
6413
6477
  this.fifoStack.push(user.identity);
6414
6478
  this.subscribedUsers.set(user.identity, user);
6415
- this.emit('userSubscribed', user);
6479
+ this.emit("userSubscribed", user);
6416
6480
  }
6417
6481
  /**
6418
6482
  * Gets user, if it's in subscribed list - then return the user object from it,
@@ -6423,65 +6487,74 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6423
6487
  }, {
6424
6488
  key: "getUser",
6425
6489
  value: function () {
6426
- 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() {
6427
6491
  var _this2 = this;
6428
6492
 
6429
- var entityName,
6493
+ var identity,
6494
+ entityName,
6430
6495
  user,
6496
+ newUser,
6431
6497
  _args = arguments;
6432
6498
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
6433
6499
  while (1) {
6434
6500
  switch (_context.prev = _context.next) {
6435
6501
  case 0:
6436
- entityName = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
6437
- _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;
6438
6505
  return this.myself._ensureFetched();
6439
6506
 
6440
- case 3:
6507
+ case 4:
6441
6508
  if (!(identity == this.myself.identity)) {
6442
- _context.next = 5;
6509
+ _context.next = 6;
6443
6510
  break;
6444
6511
  }
6445
6512
 
6446
6513
  return _context.abrupt("return", this.myself);
6447
6514
 
6448
- case 5:
6515
+ case 6:
6449
6516
  user = this.subscribedUsers.get(identity);
6450
6517
 
6451
- if (user) {
6452
- _context.next = 17;
6518
+ if (!user) {
6519
+ _context.next = 9;
6453
6520
  break;
6454
6521
  }
6455
6522
 
6456
- if (entityName) {
6457
- _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;
6458
6530
  break;
6459
6531
  }
6460
6532
 
6461
- _context.next = 10;
6533
+ _context.next = 13;
6462
6534
  return this.getSyncUniqueName(identity);
6463
6535
 
6464
- case 10:
6465
- entityName = _context.sent;
6536
+ case 13:
6537
+ _context.t0 = _context.sent;
6466
6538
 
6467
- case 11:
6468
- user = new User(identity, entityName, this.configuration, this.services);
6469
- user.on('updated', function (args) {
6470
- 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);
6471
6544
  });
6472
- user.on('userSubscribed', function () {
6473
- return _this2.handleSubscribeUser(user);
6545
+ newUser.on("userSubscribed", function () {
6546
+ return _this2.handleSubscribeUser(newUser);
6474
6547
  });
6475
- user.on('userUnsubscribed', function () {
6476
- return _this2.handleUnsubscribeUser(user);
6548
+ newUser.on("userUnsubscribed", function () {
6549
+ return _this2.handleUnsubscribeUser(newUser);
6477
6550
  });
6478
- _context.next = 17;
6479
- return user._ensureFetched();
6551
+ _context.next = 21;
6552
+ return newUser._ensureFetched();
6480
6553
 
6481
- case 17:
6482
- return _context.abrupt("return", user);
6554
+ case 21:
6555
+ return _context.abrupt("return", newUser);
6483
6556
 
6484
- case 18:
6557
+ case 22:
6485
6558
  case "end":
6486
6559
  return _context.stop();
6487
6560
  }
@@ -6489,7 +6562,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6489
6562
  }, _callee, this);
6490
6563
  }));
6491
6564
 
6492
- function getUser(_x) {
6565
+ function getUser() {
6493
6566
  return _getUser.apply(this, arguments);
6494
6567
  }
6495
6568
 
@@ -6540,6 +6613,8 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6540
6613
  key: "getSyncUniqueName",
6541
6614
  value: function () {
6542
6615
  var _getSyncUniqueName = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(identity) {
6616
+ var _response$body$sync_o, _response$body;
6617
+
6543
6618
  var url, response;
6544
6619
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
6545
6620
  while (1) {
@@ -6551,7 +6626,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6551
6626
 
6552
6627
  case 3:
6553
6628
  response = _context3.sent;
6554
- 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 : "");
6555
6630
 
6556
6631
  case 5:
6557
6632
  case "end":
@@ -6561,7 +6636,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6561
6636
  }, _callee3, this);
6562
6637
  }));
6563
6638
 
6564
- function getSyncUniqueName(_x2) {
6639
+ function getSyncUniqueName(_x) {
6565
6640
  return _getSyncUniqueName.apply(this, arguments);
6566
6641
  }
6567
6642
 
@@ -6572,7 +6647,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
6572
6647
  return Users;
6573
6648
  }(replayEventEmitter.ReplayEventEmitter);
6574
6649
 
6575
- var log$1 = Logger.scope('TypingIndicator');
6650
+ var log$1 = Logger.scope("TypingIndicator");
6576
6651
  /**
6577
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
6578
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
@@ -6619,7 +6694,7 @@ var TypingIndicator = /*#__PURE__*/function () {
6619
6694
  var _this = this;
6620
6695
 
6621
6696
  // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');
6622
- this.services.notificationClient.on('message', /*#__PURE__*/function () {
6697
+ this.services.notificationClient.on("message", /*#__PURE__*/function () {
6623
6698
  var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(type, message) {
6624
6699
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
6625
6700
  while (1) {
@@ -6660,7 +6735,7 @@ var TypingIndicator = /*#__PURE__*/function () {
6660
6735
  while (1) {
6661
6736
  switch (_context2.prev = _context2.next) {
6662
6737
  case 0:
6663
- log$1.trace('Got new typing indicator ', message);
6738
+ log$1.trace("Got new typing indicator ", message);
6664
6739
  this.getConversation(message.channel_sid).then(function (conversation) {
6665
6740
  if (!conversation) {
6666
6741
  return;
@@ -6671,7 +6746,7 @@ var TypingIndicator = /*#__PURE__*/function () {
6671
6746
  return;
6672
6747
  }
6673
6748
 
6674
- var timeout = _this2.configuration.typingIndicatorTimeoutOverride + 1000 || message.typing_timeout * 1000;
6749
+ var timeout = _this2.configuration.typingIndicatorTimeoutOverride ? _this2.configuration.typingIndicatorTimeoutOverride + 1000 : message.typing_timeout * 1000;
6675
6750
 
6676
6751
  participant._startTyping(timeout);
6677
6752
  });
@@ -6716,18 +6791,18 @@ var TypingIndicator = /*#__PURE__*/function () {
6716
6791
  value: function _send(conversationSid) {
6717
6792
  var _this3 = this;
6718
6793
 
6719
- log$1.trace('Sending typing indicator');
6794
+ log$1.trace("Sending typing indicator");
6720
6795
  var url = this.configuration.links.typing;
6721
6796
  var headers = {
6722
- 'Content-Type': 'application/x-www-form-urlencoded'
6797
+ "Content-Type": "application/x-www-form-urlencoded"
6723
6798
  };
6724
6799
  var body = "ChannelSid=".concat(conversationSid);
6725
6800
  return this.services.twilsockClient.post(url, headers, body, this.configuration.productId).then(function (response) {
6726
- if (response.body.hasOwnProperty('typing_timeout')) {
6801
+ if (response.body.hasOwnProperty("typing_timeout")) {
6727
6802
  _this3.serviceTypingTimeout = response.body.typing_timeout * 1000;
6728
6803
  }
6729
6804
  }).catch(function (err) {
6730
- log$1.error('Failed to send typing indicator:', err);
6805
+ log$1.error("Failed to send typing indicator:", err);
6731
6806
  throw err;
6732
6807
  });
6733
6808
  }
@@ -6783,14 +6858,14 @@ function PushNotification(data) {
6783
6858
  this.data = data.data || {};
6784
6859
  };
6785
6860
 
6786
- var version = "2.1.0-rc.1";
6861
+ var version = "2.1.0-rc.5";
6787
6862
 
6788
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; }
6789
6864
 
6790
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; }
6791
6866
 
6792
6867
  var trimSlashes = function trimSlashes(url) {
6793
- return url.replace(/(^\/+|\/+$)/g, '');
6868
+ return url.replace(/(^\/+|\/+$)/g, "");
6794
6869
  };
6795
6870
 
6796
6871
  var isMutationConflictResponse = function isMutationConflictResponse(response) {
@@ -6828,19 +6903,19 @@ var CommandExecutor = /*#__PURE__*/function () {
6828
6903
  case 0:
6829
6904
  preProcessedUrl = this._preProcessUrl(url);
6830
6905
  finalHeaders = _objectSpread$1({
6831
- 'Content-Type': 'application/json; charset=utf-8'
6906
+ "Content-Type": "application/json; charset=utf-8"
6832
6907
  }, headers || {});
6833
6908
  _context.t0 = method;
6834
- _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;
6835
6910
  break;
6836
6911
 
6837
6912
  case 5:
6838
6913
  getUrl = preProcessedUrl;
6839
6914
 
6840
6915
  if (requestBody) {
6841
- getUrl += '?' + Object.entries(requestBody).map(function (entry) {
6842
- return entry.map(encodeURIComponent).join('=');
6843
- }).join('&');
6916
+ getUrl += "?" + Object.entries(requestBody).map(function (entry) {
6917
+ return entry.map(encodeURIComponent).join("=");
6918
+ }).join("&");
6844
6919
  }
6845
6920
 
6846
6921
  _context.next = 9;
@@ -6860,7 +6935,7 @@ var CommandExecutor = /*#__PURE__*/function () {
6860
6935
 
6861
6936
  case 15:
6862
6937
  _context.next = 17;
6863
- return this._services.transport.delete(preProcessedUrl, finalHeaders, null, this._productId);
6938
+ return this._services.transport.delete(preProcessedUrl, finalHeaders, {}, this._productId);
6864
6939
 
6865
6940
  case 17:
6866
6941
  response = _context.sent;
@@ -6910,28 +6985,24 @@ var CommandExecutor = /*#__PURE__*/function () {
6910
6985
  max: 1600,
6911
6986
  maxAttemptsCount: maxAttemptsCount
6912
6987
  }).run(function () {
6913
- return _this._makeRequest('get', url, requestBody);
6988
+ return _this._makeRequest("get", url, requestBody);
6914
6989
  });
6915
6990
 
6916
6991
  case 4:
6917
6992
  result = _context2.sent;
6918
- _context2.next = 10;
6919
- break;
6993
+ return _context2.abrupt("return", result.body);
6920
6994
 
6921
- case 7:
6922
- _context2.prev = 7;
6995
+ case 8:
6996
+ _context2.prev = 8;
6923
6997
  _context2.t0 = _context2["catch"](1);
6924
6998
  throw new Error("Fetch resource from \"".concat(url, "\" failed."));
6925
6999
 
6926
- case 10:
6927
- return _context2.abrupt("return", result.body);
6928
-
6929
7000
  case 11:
6930
7001
  case "end":
6931
7002
  return _context2.stop();
6932
7003
  }
6933
7004
  }
6934
- }, _callee2, null, [[1, 7]]);
7005
+ }, _callee2, null, [[1, 8]]);
6935
7006
  }));
6936
7007
 
6937
7008
  function fetchResource(_x5, _x6) {
@@ -6951,7 +7022,7 @@ var CommandExecutor = /*#__PURE__*/function () {
6951
7022
  case 0:
6952
7023
  _context3.next = 2;
6953
7024
  return this._makeRequest(method, url, requestBody, {
6954
- 'X-Twilio-Mutation-Id': uuid.v4()
7025
+ "X-Twilio-Mutation-Id": uuid.v4()
6955
7026
  });
6956
7027
 
6957
7028
  case 2:
@@ -7001,7 +7072,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
7001
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; } }
7002
7073
 
7003
7074
  var Client_1;
7004
- var log = Logger.scope('Client');
7075
+ var log = Logger.scope("Client");
7005
7076
  var SDK_VERSION = version;
7006
7077
 
7007
7078
  var ClientServices = function ClientServices() {
@@ -7049,22 +7120,14 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7049
7120
 
7050
7121
  _this = _super.call(this);
7051
7122
 
7052
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState", 'unknown');
7053
-
7054
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "conversationsPromise", null);
7055
-
7056
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_ensureReady", null);
7057
-
7058
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_resolveEnsureReady", null);
7059
-
7060
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_rejectEnsureReady", null);
7123
+ _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState", "unknown");
7061
7124
 
7062
7125
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "version", SDK_VERSION);
7063
7126
 
7064
7127
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "parsePushNotification", Client_1.parsePushNotification);
7065
7128
 
7066
- _this.fpaToken = fpaToken;
7067
- _this.options = options;
7129
+ _this.fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
7130
+ _this.options = options !== null && options !== void 0 ? options : {};
7068
7131
 
7069
7132
  if (!_this.options.disableDeepClone) {
7070
7133
  var _options = _objectSpread(_objectSpread({}, _this.options), {}, {
@@ -7078,25 +7141,25 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7078
7141
  _this.options = _options;
7079
7142
  }
7080
7143
 
7081
- _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";
7082
7145
  log.setLevel(_this.options.logLevel);
7083
- var productId = _this.options.productId = 'ip_messaging'; // Filling ClientMetadata
7146
+ var productId = _this.options.productId = "ip_messaging"; // Filling ClientMetadata
7084
7147
 
7085
7148
  _this.options.clientMetadata = _this.options.clientMetadata || {};
7086
7149
 
7087
- if (!_this.options.clientMetadata.hasOwnProperty('type')) {
7088
- _this.options.clientMetadata.type = 'conversations';
7150
+ if (!_this.options.clientMetadata.hasOwnProperty("type")) {
7151
+ _this.options.clientMetadata.type = "conversations";
7089
7152
  }
7090
7153
 
7091
- if (!_this.options.clientMetadata.hasOwnProperty('sdk')) {
7092
- _this.options.clientMetadata.sdk = 'JS';
7154
+ if (!_this.options.clientMetadata.hasOwnProperty("sdk")) {
7155
+ _this.options.clientMetadata.sdk = "JS";
7093
7156
  _this.options.clientMetadata.sdkv = SDK_VERSION;
7094
7157
  } // Enable session local storage for Sync
7095
7158
 
7096
7159
 
7097
7160
  _this.options.Sync = _this.options.Sync || {};
7098
7161
 
7099
- if (typeof _this.options.Sync.enableSessionStorage === 'undefined') {
7162
+ if (typeof _this.options.Sync.enableSessionStorage === "undefined") {
7100
7163
  _this.options.Sync.enableSessionStorage = true;
7101
7164
  }
7102
7165
 
@@ -7105,11 +7168,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7105
7168
  }
7106
7169
 
7107
7170
  if (!fpaToken) {
7108
- throw new Error('A valid Twilio token should be provided');
7171
+ throw new Error("A valid Twilio token should be provided");
7109
7172
  }
7110
7173
 
7111
7174
  _this.services = new ClientServices();
7112
- _this._myself = new User('', '', null, _this.services);
7175
+ _this._myself = new User("", "", null, _this.services);
7113
7176
  var startTwilsock = !_this.options.twilsockClient; // Create default init registrations if none were provided.
7114
7177
  // Otherwise, the outside party have to list all the init registrations they
7115
7178
  // need.
@@ -7124,34 +7187,34 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7124
7187
 
7125
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);
7126
7189
 
7127
- _this.services.twilsockClient.on('tokenAboutToExpire', function (ttl) {
7128
- return _this.emit('tokenAboutToExpire', ttl);
7190
+ _this.services.twilsockClient.on("tokenAboutToExpire", function (ttl) {
7191
+ return _this.emit("tokenAboutToExpire", ttl);
7129
7192
  });
7130
7193
 
7131
- _this.services.twilsockClient.on('tokenExpired', function () {
7132
- return _this.emit('tokenExpired');
7194
+ _this.services.twilsockClient.on("tokenExpired", function () {
7195
+ return _this.emit("tokenExpired");
7133
7196
  });
7134
7197
 
7135
- _this.services.twilsockClient.on('connectionError', function (error) {
7136
- return _this.emit('connectionError', error);
7198
+ _this.services.twilsockClient.on("connectionError", function (error) {
7199
+ return _this.emit("connectionError", error);
7137
7200
  });
7138
7201
 
7139
- _this.services.twilsockClient.on('stateChanged', function (state) {
7202
+ _this.services.twilsockClient.on("stateChanged", function (state) {
7140
7203
  log.debug("Handling stateChanged for ConversationsClient: new state ".concat(state));
7141
7204
 
7142
7205
  if (state !== _this.connectionState) {
7143
7206
  _this.connectionState = state;
7144
7207
 
7145
- _this.emit('connectionStateChanged', _this.connectionState);
7208
+ _this.emit("connectionStateChanged", _this.connectionState);
7146
7209
  }
7147
7210
  });
7148
7211
 
7149
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;
7150
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);
7151
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);
7152
- var configurationOptions = options.Chat || options.IPMessaging || options || {};
7153
- var region = configurationOptions.region || options.region;
7154
- 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");
7155
7218
  _this.services.commandExecutor = new CommandExecutor(baseUrl, {
7156
7219
  transport: _this.options.transport
7157
7220
  }, productId);
@@ -7159,15 +7222,15 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7159
7222
  var emitFailed = function emitFailed(err) {
7160
7223
  _this._rejectEnsureReady(err);
7161
7224
 
7162
- _this.emit('stateChanged', 'failed');
7225
+ _this.emit("stateChanged", "failed");
7163
7226
  };
7164
7227
 
7165
- _this.services.twilsockClient.once('connectionError', emitFailed);
7228
+ _this.services.twilsockClient.once("connectionError", emitFailed);
7166
7229
 
7167
- _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
7168
7231
 
7169
7232
 
7170
- _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() {
7171
7234
  var startupEvent;
7172
7235
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
7173
7236
  while (1) {
@@ -7175,20 +7238,20 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7175
7238
  case 0:
7176
7239
  log.debug("ConversationsClient started INITIALIZING");
7177
7240
 
7178
- _this.services.twilsockClient.off('connectionError', emitFailed);
7241
+ _this.services.twilsockClient.off("connectionError", emitFailed);
7179
7242
 
7180
- _this.services.twilsockClient.off('disconnected', emitFailed);
7243
+ _this.services.twilsockClient.off("disconnected", emitFailed);
7181
7244
 
7182
7245
  _context.prev = 3;
7183
- startupEvent = 'conversations.client.startup';
7246
+ startupEvent = "conversations.client.startup";
7184
7247
 
7185
- _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);
7186
7249
 
7187
7250
  _context.next = 8;
7188
7251
  return _this._initialize();
7189
7252
 
7190
7253
  case 8:
7191
- _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);
7192
7255
 
7193
7256
  _context.next = 15;
7194
7257
  break;
@@ -7200,7 +7263,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7200
7263
  // Fail ChatClient if initialization is incomplete
7201
7264
  _this._rejectEnsureReady(_context.t0);
7202
7265
 
7203
- _this.emit('stateChanged', 'failed');
7266
+ _this.emit("stateChanged", "failed");
7204
7267
 
7205
7268
  case 15:
7206
7269
  case "end":
@@ -7213,7 +7276,9 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7213
7276
  _this._ensureReady = new Promise(function (resolve, reject) {
7214
7277
  _this._resolveEnsureReady = resolve;
7215
7278
  _this._rejectEnsureReady = reject;
7216
- }).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?
7217
7282
 
7218
7283
  if (startTwilsock) {
7219
7284
  _this.services.twilsockClient.connect();
@@ -7242,7 +7307,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7242
7307
  key: "reachabilityEnabled",
7243
7308
  get: function get() {
7244
7309
  if (!this.configuration) {
7245
- 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.");
7246
7311
  }
7247
7312
 
7248
7313
  return this.configuration.reachabilityEnabled;
@@ -7282,7 +7347,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7282
7347
  switch (_context2.prev = _context2.next) {
7283
7348
  case 0:
7284
7349
  _context2.next = 2;
7285
- return this.services.commandExecutor.fetchResource('Client/v2/Configuration');
7350
+ return this.services.commandExecutor.fetchResource("Client/v2/Configuration");
7286
7351
 
7287
7352
  case 2:
7288
7353
  configurationResponse = _context2.sent;
@@ -7293,31 +7358,55 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7293
7358
  this.services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
7294
7359
  this.services.network = new Network(this.configuration, this.services);
7295
7360
  this.services.users = new Users(this._myself, this.configuration, this.services);
7296
- this.services.users.on('userSubscribed', this.emit.bind(this, 'userSubscribed'));
7297
- this.services.users.on('userUpdated', function (args) {
7298
- 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);
7299
7369
  });
7300
- this.services.users.on('userUnsubscribed', this.emit.bind(this, 'userUnsubscribed'));
7301
7370
  this.conversations = new Conversations(this.configuration, this.services);
7302
- this.conversations.on('conversationAdded', this.emit.bind(this, 'conversationAdded'));
7303
- this.conversations.on('conversationRemoved', this.emit.bind(this, 'conversationRemoved'));
7304
- this.conversations.on('conversationJoined', this.emit.bind(this, 'conversationJoined'));
7305
- this.conversations.on('conversationLeft', this.emit.bind(this, 'conversationLeft'));
7306
- this.conversations.on('conversationUpdated', function (args) {
7307
- 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);
7308
7403
  });
7309
- this.conversations.on('participantJoined', this.emit.bind(this, 'participantJoined'));
7310
- this.conversations.on('participantLeft', this.emit.bind(this, 'participantLeft'));
7311
- this.conversations.on('participantUpdated', function (args) {
7312
- return _this4.emit('participantUpdated', args);
7404
+ this.conversations.on("typingStarted", function (participant) {
7405
+ return _this4.emit("typingStarted", participant);
7313
7406
  });
7314
- this.conversations.on('messageAdded', this.emit.bind(this, 'messageAdded'));
7315
- this.conversations.on('messageUpdated', function (args) {
7316
- return _this4.emit('messageUpdated', args);
7407
+ this.conversations.on("typingEnded", function (participant) {
7408
+ return _this4.emit("typingEnded", participant);
7317
7409
  });
7318
- this.conversations.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
7319
- this.conversations.on('typingStarted', this.emit.bind(this, 'typingStarted'));
7320
- this.conversations.on('typingEnded', this.emit.bind(this, 'typingEnded'));
7321
7410
  this.conversationsPromise = this.conversations.fetchConversations().then(function () {
7322
7411
  return _this4.conversations;
7323
7412
  }).catch(function (error) {
@@ -7332,12 +7421,12 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7332
7421
  });
7333
7422
  this.services.typingIndicator.initialize();
7334
7423
  this.services.mcsClient = new mcsClient.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, _objectSpread(_objectSpread({}, this.options), {}, {
7335
- transport: null
7424
+ transport: undefined
7336
7425
  }));
7337
7426
 
7338
7427
  this._resolveEnsureReady();
7339
7428
 
7340
- this.emit('stateChanged', 'initialized');
7429
+ this.emit("stateChanged", "initialized");
7341
7430
 
7342
7431
  case 33:
7343
7432
  case "end":
@@ -7403,7 +7492,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7403
7492
  return this._ensureReady;
7404
7493
 
7405
7494
  case 2:
7406
- log.info('updateToken');
7495
+ log.info("updateToken");
7407
7496
 
7408
7497
  if (!(this.fpaToken === token)) {
7409
7498
  _context4.next = 5;
@@ -7565,7 +7654,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7565
7654
  }, {
7566
7655
  key: "getSubscribedConversations",
7567
7656
  value: function () {
7568
- 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() {
7569
7658
  return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
7570
7659
  while (1) {
7571
7660
  switch (_context7.prev = _context7.next) {
@@ -7575,7 +7664,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7575
7664
 
7576
7665
  case 2:
7577
7666
  return _context7.abrupt("return", this.conversationsPromise.then(function (conversations) {
7578
- return conversations.getConversations(args);
7667
+ return conversations.getConversations();
7579
7668
  }));
7580
7669
 
7581
7670
  case 3:
@@ -7586,7 +7675,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7586
7675
  }, _callee7, this);
7587
7676
  }));
7588
7677
 
7589
- function getSubscribedConversations(_x4) {
7678
+ function getSubscribedConversations() {
7590
7679
  return _getSubscribedConversations.apply(this, arguments);
7591
7680
  }
7592
7681
 
@@ -7623,7 +7712,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7623
7712
  }, _callee8, this);
7624
7713
  }));
7625
7714
 
7626
- function createConversation(_x5) {
7715
+ function createConversation(_x4) {
7627
7716
  return _createConversation.apply(this, arguments);
7628
7717
  }
7629
7718
 
@@ -7661,7 +7750,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7661
7750
  }, _callee9, this);
7662
7751
  }));
7663
7752
 
7664
- function setPushRegistrationId(_x6, _x7) {
7753
+ function setPushRegistrationId(_x5, _x6) {
7665
7754
  return _setPushRegistrationId.apply(this, arguments);
7666
7755
  }
7667
7756
 
@@ -7698,7 +7787,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7698
7787
  }, _callee10, this);
7699
7788
  }));
7700
7789
 
7701
- function unsetPushRegistrationId(_x8) {
7790
+ function unsetPushRegistrationId(_x7) {
7702
7791
  return _unsetPushRegistrationId.apply(this, arguments);
7703
7792
  }
7704
7793
 
@@ -7734,7 +7823,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7734
7823
  }, _callee11, this);
7735
7824
  }));
7736
7825
 
7737
- function removePushRegistrations(_x9, _x10) {
7826
+ function removePushRegistrations(_x8, _x9) {
7738
7827
  return _removePushRegistrations.apply(this, arguments);
7739
7828
  }
7740
7829
 
@@ -7757,8 +7846,8 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7757
7846
  return this._ensureReady;
7758
7847
 
7759
7848
  case 2:
7760
- log.debug('handlePushNotification, notificationPayload=', notificationPayload);
7761
- this.emit('pushNotification', Client_1.parsePushNotification(notificationPayload));
7849
+ log.debug("handlePushNotification, notificationPayload=", notificationPayload);
7850
+ this.emit("pushNotification", Client_1.parsePushNotification(notificationPayload));
7762
7851
 
7763
7852
  case 4:
7764
7853
  case "end":
@@ -7768,7 +7857,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7768
7857
  }, _callee12, this);
7769
7858
  }));
7770
7859
 
7771
- function handlePushNotification(_x11) {
7860
+ function handlePushNotification(_x10) {
7772
7861
  return _handlePushNotification.apply(this, arguments);
7773
7862
  }
7774
7863
 
@@ -7803,7 +7892,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7803
7892
  }, _callee13, this);
7804
7893
  }));
7805
7894
 
7806
- function getUser(_x12) {
7895
+ function getUser(_x11) {
7807
7896
  return _getUser.apply(this, arguments);
7808
7897
  }
7809
7898
 
@@ -7890,7 +7979,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7890
7979
  break;
7891
7980
  }
7892
7981
 
7893
- 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.");
7894
7983
 
7895
7984
  case 2:
7896
7985
  client = new Client_1(token, options);
@@ -7908,7 +7997,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7908
7997
  }, _callee15);
7909
7998
  }));
7910
7999
 
7911
- function create(_x13, _x14) {
8000
+ function create(_x12, _x13) {
7912
8001
  return _create.apply(this, arguments);
7913
8002
  }
7914
8003
 
@@ -7920,11 +8009,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7920
8009
  var result = {};
7921
8010
 
7922
8011
  for (var key in Client_1.supportedPushDataFields) {
7923
- if (typeof data[key] === 'undefined' || data[key] === null) {
8012
+ if (typeof data[key] === "undefined" || data[key] === null) {
7924
8013
  continue;
7925
8014
  }
7926
8015
 
7927
- if (key !== 'message_index') {
8016
+ if (key !== "message_index") {
7928
8017
  result[Client_1.supportedPushDataFields[key]] = data[key];
7929
8018
  continue;
7930
8019
  }
@@ -7944,19 +8033,19 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7944
8033
  }, {
7945
8034
  key: "parsePushNotification",
7946
8035
  value: function parsePushNotification(notificationPayload) {
7947
- log.debug('parsePushNotification, notificationPayload=', notificationPayload); // APNS specifics
8036
+ log.debug("parsePushNotification, notificationPayload=", notificationPayload); // APNS specifics
7948
8037
 
7949
- if (typeof notificationPayload.aps !== 'undefined') {
8038
+ if (typeof notificationPayload.aps !== "undefined") {
7950
8039
  if (!notificationPayload.twi_message_type) {
7951
- 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");
7952
8041
  }
7953
8042
 
7954
8043
  var data = Client_1.parsePushNotificationChatData(notificationPayload);
7955
8044
  var apsPayload = notificationPayload.aps;
7956
- var body = null;
8045
+ var body;
7957
8046
  var title = null;
7958
8047
 
7959
- if (typeof apsPayload.alert === 'string') {
8048
+ if (typeof apsPayload.alert === "string") {
7960
8049
  body = apsPayload.alert || null;
7961
8050
  } else {
7962
8051
  body = apsPayload.alert.body || null;
@@ -7975,11 +8064,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7975
8064
  } // FCM specifics
7976
8065
 
7977
8066
 
7978
- if (typeof notificationPayload.data !== 'undefined') {
8067
+ if (typeof notificationPayload.data !== "undefined") {
7979
8068
  var dataPayload = notificationPayload.data;
7980
8069
 
7981
8070
  if (!dataPayload.twi_message_type) {
7982
- 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");
7983
8072
  }
7984
8073
 
7985
8074
  var _data = Client_1.parsePushNotificationChatData(notificationPayload.data);
@@ -7995,16 +8084,16 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
7995
8084
  });
7996
8085
  }
7997
8086
 
7998
- 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");
7999
8088
  }
8000
8089
  }]);
8001
8090
 
8002
8091
  return Client;
8003
- }(replayEventEmitter.ReplayEventEmitter), _defineProperty__default['default'](_class, "version", SDK_VERSION), _defineProperty__default['default'](_class, "supportedPushChannels", ['fcm', 'apn']), _defineProperty__default['default'](_class, "supportedPushDataFields", {
8004
- 'conversation_sid': 'conversationSid',
8005
- 'message_sid': 'messageSid',
8006
- 'message_index': 'messageIndex'
8007
- }), _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);
8008
8097
 
8009
8098
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
8010
8099
 
@@ -8012,27 +8101,27 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
8012
8101
 
8013
8102
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationByUniqueName", null);
8014
8103
 
8015
- __decorate([declarativeTypeValidator.validateTypesAsync(['undefined', declarativeTypeValidator.objectSchema('conversation options', {
8016
- friendlyName: ['string', 'undefined'],
8017
- isPrivate: ['boolean', 'undefined'],
8018
- uniqueName: ['string', 'undefined']
8104
+ __decorate([declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.objectSchema("conversation options", {
8105
+ friendlyName: ["string", "undefined"],
8106
+ isPrivate: ["boolean", "undefined"],
8107
+ uniqueName: ["string", "undefined"]
8019
8108
  })]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "createConversation", null);
8020
8109
 
8021
- __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);
8022
8111
 
8023
- __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);
8024
8113
 
8025
- __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);
8026
8115
 
8027
8116
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "handlePushNotification", null);
8028
8117
 
8029
8118
  __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getUser", null);
8030
8119
 
8031
- __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);
8032
8121
 
8033
8122
  __decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
8034
8123
 
8035
- 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);
8036
8125
 
8037
8126
  exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
8038
8127
  exports.Conversation = Conversation;