@twilio/conversations 3.0.1-rc.102 → 3.0.1-rc.103

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.
package/builds/lib.js CHANGED
@@ -405,9 +405,11 @@ var MINIMUM_RETRY_DELAY = 1000;
405
405
  var MAXIMUM_RETRY_DELAY = 4000;
406
406
  var MAXIMUM_ATTEMPTS_COUNT = 3;
407
407
  var RETRY_WHEN_THROTTLED = true;
408
+ var CHANNEL_METADATA_CACHE_CAPACITY = 100;
409
+ var MESSAGE_RECIPIENTS_CACHE_CAPACITY = 1000;
408
410
 
409
411
  var Configuration = /*#__PURE__*/_createClass__default["default"](function Configuration() {
410
- var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad;
412
+ var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad, _options$messageRecip;
411
413
 
412
414
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
413
415
  var configurationResponse = arguments.length > 1 ? arguments[1] : undefined;
@@ -466,7 +468,8 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
466
468
  this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(CONSUMPTION_HORIZON_SENDING_INTERVAL));
467
469
  }
468
470
 
469
- this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : 100;
471
+ this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : CHANNEL_METADATA_CACHE_CAPACITY;
472
+ this.messageRecipientsCacheCapacity = (_options$messageRecip = options.messageRecipientsCacheCapacity) !== null && _options$messageRecip !== void 0 ? _options$messageRecip : MESSAGE_RECIPIENTS_CACHE_CAPACITY;
470
473
  });
471
474
 
472
475
  /**
@@ -1084,11 +1087,11 @@ __decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("desig
1084
1087
 
1085
1088
  __decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
1086
1089
 
1087
- function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(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; } } }; }
1090
+ function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(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; } } }; }
1088
1091
 
1089
- function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
1092
+ function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
1090
1093
 
1091
- function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1094
+ function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1092
1095
 
1093
1096
  var Network = /*#__PURE__*/function () {
1094
1097
  function Network(configuration, services) {
@@ -1109,7 +1112,7 @@ var Network = /*#__PURE__*/function () {
1109
1112
  }, {
1110
1113
  key: "cleanupCache",
1111
1114
  value: function cleanupCache() {
1112
- var _iterator = _createForOfIteratorHelper$4(this.cache),
1115
+ var _iterator = _createForOfIteratorHelper$5(this.cache),
1113
1116
  _step;
1114
1117
 
1115
1118
  try {
@@ -3753,6 +3756,38 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3753
3756
 
3754
3757
  return getChannelMetadata;
3755
3758
  }()
3759
+ /**
3760
+ * Get recipients of the message.
3761
+ */
3762
+
3763
+ }, {
3764
+ key: "getMessageRecipients",
3765
+ value: function () {
3766
+ var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11() {
3767
+ return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context11) {
3768
+ while (1) {
3769
+ switch (_context11.prev = _context11.next) {
3770
+ case 0:
3771
+ _context11.next = 2;
3772
+ return this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid, this.sid);
3773
+
3774
+ case 2:
3775
+ return _context11.abrupt("return", _context11.sent);
3776
+
3777
+ case 3:
3778
+ case "end":
3779
+ return _context11.stop();
3780
+ }
3781
+ }
3782
+ }, _callee11, this);
3783
+ }));
3784
+
3785
+ function getMessageRecipients() {
3786
+ return _getMessageRecipients.apply(this, arguments);
3787
+ }
3788
+
3789
+ return getMessageRecipients;
3790
+ }()
3756
3791
  }]);
3757
3792
 
3758
3793
  return Message;
@@ -3780,11 +3815,11 @@ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if
3780
3815
 
3781
3816
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3782
3817
 
3783
- 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; } } }; }
3818
+ function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(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; } } }; }
3784
3819
 
3785
- function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
3820
+ function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
3786
3821
 
3787
- function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3822
+ function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3788
3823
 
3789
3824
  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); }; }
3790
3825
 
@@ -3992,7 +4027,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
3992
4027
  return request.cancel();
3993
4028
  });
3994
4029
  });
3995
- _iterator = _createForOfIteratorHelper$3(message.mediaContent);
4030
+ _iterator = _createForOfIteratorHelper$4(message.mediaContent);
3996
4031
  _context3.prev = 4;
3997
4032
 
3998
4033
  _iterator.s();
@@ -4645,11 +4680,11 @@ __decorate([declarativeTypeValidator.validateTypes("string", [declarativeTypeVal
4645
4680
 
4646
4681
  __decorate([declarativeTypeValidator.validateTypes([FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "addMedia", null);
4647
4682
 
4648
- 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; } } }; }
4683
+ 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; } } }; }
4649
4684
 
4650
- function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
4685
+ function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
4651
4686
 
4652
- function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4687
+ function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4653
4688
 
4654
4689
  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); }; }
4655
4690
 
@@ -5935,6 +5970,38 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5935
5970
 
5936
5971
  return updateUniqueName;
5937
5972
  }()
5973
+ /**
5974
+ * Get recipients of all messages in the conversation.
5975
+ */
5976
+
5977
+ }, {
5978
+ key: "getMessageRecipients",
5979
+ value: function () {
5980
+ var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24() {
5981
+ return _regeneratorRuntime__default["default"].wrap(function _callee24$(_context24) {
5982
+ while (1) {
5983
+ switch (_context24.prev = _context24.next) {
5984
+ case 0:
5985
+ _context24.next = 2;
5986
+ return this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid);
5987
+
5988
+ case 2:
5989
+ return _context24.abrupt("return", _context24.sent);
5990
+
5991
+ case 3:
5992
+ case "end":
5993
+ return _context24.stop();
5994
+ }
5995
+ }
5996
+ }, _callee24, this);
5997
+ }));
5998
+
5999
+ function getMessageRecipients() {
6000
+ return _getMessageRecipients.apply(this, arguments);
6001
+ }
6002
+
6003
+ return getMessageRecipients;
6004
+ }()
5938
6005
  /**
5939
6006
  * Load and subscribe to this conversation and do not subscribe to its
5940
6007
  * participants and messages. This or _subscribeStreams will need to be called
@@ -5945,31 +6012,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5945
6012
  }, {
5946
6013
  key: "_subscribe",
5947
6014
  value: function () {
5948
- var _subscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24() {
6015
+ var _subscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
5949
6016
  var _this2 = this;
5950
6017
 
5951
- return _regeneratorRuntime__default["default"].wrap(function _callee24$(_context24) {
6018
+ return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
5952
6019
  while (1) {
5953
- switch (_context24.prev = _context24.next) {
6020
+ switch (_context25.prev = _context25.next) {
5954
6021
  case 0:
5955
6022
  if (!this._entityPromise) {
5956
- _context24.next = 2;
6023
+ _context25.next = 2;
5957
6024
  break;
5958
6025
  }
5959
6026
 
5960
- return _context24.abrupt("return", this._entityPromise);
6027
+ return _context25.abrupt("return", this._entityPromise);
5961
6028
 
5962
6029
  case 2:
5963
6030
  this._entityPromise = this._services.syncClient.document({
5964
6031
  id: this._entityName,
5965
6032
  mode: "open_existing"
5966
6033
  });
5967
- _context24.prev = 3;
5968
- _context24.next = 6;
6034
+ _context25.prev = 3;
6035
+ _context25.next = 6;
5969
6036
  return this._entityPromise;
5970
6037
 
5971
6038
  case 6:
5972
- this._entity = _context24.sent;
6039
+ this._entity = _context25.sent;
5973
6040
 
5974
6041
  this._entity.on("updated", function (args) {
5975
6042
  return _this2._update(args.data);
@@ -5981,28 +6048,28 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5981
6048
 
5982
6049
  this._update(this._entity.data);
5983
6050
 
5984
- return _context24.abrupt("return", this._entity);
6051
+ return _context25.abrupt("return", this._entity);
5985
6052
 
5986
6053
  case 13:
5987
- _context24.prev = 13;
5988
- _context24.t0 = _context24["catch"](3);
6054
+ _context25.prev = 13;
6055
+ _context25.t0 = _context25["catch"](3);
5989
6056
  this._entity = null;
5990
6057
  this._entityPromise = null;
5991
6058
 
5992
6059
  if (this._services.syncClient.connectionState != "disconnected") {
5993
- Conversation._logger.error("Failed to get conversation object", _context24.t0);
6060
+ Conversation._logger.error("Failed to get conversation object", _context25.t0);
5994
6061
  }
5995
6062
 
5996
- Conversation._logger.debug("ERROR: Failed to get conversation object", _context24.t0);
6063
+ Conversation._logger.debug("ERROR: Failed to get conversation object", _context25.t0);
5997
6064
 
5998
- throw _context24.t0;
6065
+ throw _context25.t0;
5999
6066
 
6000
6067
  case 20:
6001
6068
  case "end":
6002
- return _context24.stop();
6069
+ return _context25.stop();
6003
6070
  }
6004
6071
  }
6005
- }, _callee24, this, [[3, 13]]);
6072
+ }, _callee25, this, [[3, 13]]);
6006
6073
  }));
6007
6074
 
6008
6075
  function _subscribe() {
@@ -6024,44 +6091,44 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6024
6091
  }, {
6025
6092
  key: "_fetchStreams",
6026
6093
  value: function () {
6027
- var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
6094
+ var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26() {
6028
6095
  var _this$_entity, _this$_entity2;
6029
6096
 
6030
6097
  var data;
6031
- return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
6098
+ return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
6032
6099
  while (1) {
6033
- switch (_context25.prev = _context25.next) {
6100
+ switch (_context26.prev = _context26.next) {
6034
6101
  case 0:
6035
- _context25.next = 2;
6102
+ _context26.next = 2;
6036
6103
  return this._subscribe();
6037
6104
 
6038
6105
  case 2:
6039
6106
  Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
6040
6107
 
6041
6108
  data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
6042
- _context25.next = 6;
6109
+ _context26.next = 6;
6043
6110
  return this._services.syncClient.list({
6044
6111
  id: data.messages,
6045
6112
  mode: "open_existing"
6046
6113
  });
6047
6114
 
6048
6115
  case 6:
6049
- this._messagesList = _context25.sent;
6050
- _context25.next = 9;
6116
+ this._messagesList = _context26.sent;
6117
+ _context26.next = 9;
6051
6118
  return this._services.syncClient.map({
6052
6119
  id: data.roster,
6053
6120
  mode: "open_existing"
6054
6121
  });
6055
6122
 
6056
6123
  case 9:
6057
- this._participantsMap = _context25.sent;
6124
+ this._participantsMap = _context26.sent;
6058
6125
 
6059
6126
  case 10:
6060
6127
  case "end":
6061
- return _context25.stop();
6128
+ return _context26.stop();
6062
6129
  }
6063
6130
  }
6064
- }, _callee25, this);
6131
+ }, _callee26, this);
6065
6132
  }));
6066
6133
 
6067
6134
  function _fetchStreams() {
@@ -6081,15 +6148,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6081
6148
  }, {
6082
6149
  key: "_subscribeStreams",
6083
6150
  value: function () {
6084
- var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26() {
6151
+ var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
6085
6152
  var _this$_entity3, _this$_entity4, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
6086
6153
 
6087
- return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
6154
+ return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
6088
6155
  while (1) {
6089
- switch (_context26.prev = _context26.next) {
6156
+ switch (_context27.prev = _context27.next) {
6090
6157
  case 0:
6091
- _context26.prev = 0;
6092
- _context26.next = 3;
6158
+ _context27.prev = 0;
6159
+ _context27.next = 3;
6093
6160
  return this._subscribe();
6094
6161
 
6095
6162
  case 3:
@@ -6098,31 +6165,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6098
6165
  data = (_this$_entity4 = this._entity) === null || _this$_entity4 === void 0 ? void 0 : _this$_entity4.data;
6099
6166
  messagesObjectName = data.messages;
6100
6167
  rosterObjectName = data.roster;
6101
- _context26.next = 9;
6168
+ _context27.next = 9;
6102
6169
  return Promise.all([this._messagesEntity.subscribe((_this$_messagesList = this._messagesList) !== null && _this$_messagesList !== void 0 ? _this$_messagesList : messagesObjectName), this._participantsEntity.subscribe((_this$_participantsMa = this._participantsMap) !== null && _this$_participantsMa !== void 0 ? _this$_participantsMa : rosterObjectName)]);
6103
6170
 
6104
6171
  case 9:
6105
- _context26.next = 16;
6172
+ _context27.next = 16;
6106
6173
  break;
6107
6174
 
6108
6175
  case 11:
6109
- _context26.prev = 11;
6110
- _context26.t0 = _context26["catch"](0);
6176
+ _context27.prev = 11;
6177
+ _context27.t0 = _context27["catch"](0);
6111
6178
 
6112
6179
  if (this._services.syncClient.connectionState !== "disconnected") {
6113
- Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context26.t0);
6180
+ Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context27.t0);
6114
6181
  }
6115
6182
 
6116
- Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context26.t0);
6183
+ Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context27.t0);
6117
6184
 
6118
- throw _context26.t0;
6185
+ throw _context27.t0;
6119
6186
 
6120
6187
  case 16:
6121
6188
  case "end":
6122
- return _context26.stop();
6189
+ return _context27.stop();
6123
6190
  }
6124
6191
  }
6125
- }, _callee26, this, [[0, 11]]);
6192
+ }, _callee27, this, [[0, 11]]);
6126
6193
  }));
6127
6194
 
6128
6195
  function _subscribeStreams() {
@@ -6139,17 +6206,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6139
6206
  }, {
6140
6207
  key: "_unsubscribe",
6141
6208
  value: function () {
6142
- var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
6143
- return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
6209
+ var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28() {
6210
+ return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
6144
6211
  while (1) {
6145
- switch (_context27.prev = _context27.next) {
6212
+ switch (_context28.prev = _context28.next) {
6146
6213
  case 0:
6147
6214
  if (!this._entity) {
6148
- _context27.next = 5;
6215
+ _context28.next = 5;
6149
6216
  break;
6150
6217
  }
6151
6218
 
6152
- _context27.next = 3;
6219
+ _context28.next = 3;
6153
6220
  return this._entity.close();
6154
6221
 
6155
6222
  case 3:
@@ -6157,14 +6224,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6157
6224
  this._entityPromise = null;
6158
6225
 
6159
6226
  case 5:
6160
- return _context27.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
6227
+ return _context28.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
6161
6228
 
6162
6229
  case 6:
6163
6230
  case "end":
6164
- return _context27.stop();
6231
+ return _context28.stop();
6165
6232
  }
6166
6233
  }
6167
- }, _callee27, this);
6234
+ }, _callee28, this);
6168
6235
  }));
6169
6236
 
6170
6237
  function _unsubscribe() {
@@ -6341,7 +6408,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6341
6408
  }, {
6342
6409
  key: "_onMessageAdded",
6343
6410
  value: function _onMessageAdded(message) {
6344
- var _iterator = _createForOfIteratorHelper$2(this._participants.values()),
6411
+ var _iterator = _createForOfIteratorHelper$3(this._participants.values()),
6345
6412
  _step;
6346
6413
 
6347
6414
  try {
@@ -6370,27 +6437,27 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6370
6437
  }, {
6371
6438
  key: "_setLastReadMessageIndex",
6372
6439
  value: function () {
6373
- var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28(index) {
6440
+ var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee29(index) {
6374
6441
  var result;
6375
- return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
6442
+ return _regeneratorRuntime__default["default"].wrap(function _callee29$(_context29) {
6376
6443
  while (1) {
6377
- switch (_context28.prev = _context28.next) {
6444
+ switch (_context29.prev = _context29.next) {
6378
6445
  case 0:
6379
- _context28.next = 2;
6446
+ _context29.next = 2;
6380
6447
  return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
6381
6448
  last_read_message_index: index
6382
6449
  });
6383
6450
 
6384
6451
  case 2:
6385
- result = _context28.sent;
6386
- return _context28.abrupt("return", result.unread_messages_count);
6452
+ result = _context29.sent;
6453
+ return _context29.abrupt("return", result.unread_messages_count);
6387
6454
 
6388
6455
  case 4:
6389
6456
  case "end":
6390
- return _context28.stop();
6457
+ return _context29.stop();
6391
6458
  }
6392
6459
  }
6393
- }, _callee28, this);
6460
+ }, _callee29, this);
6394
6461
  }));
6395
6462
 
6396
6463
  function _setLastReadMessageIndex(_x19) {
@@ -6549,11 +6616,11 @@ var Deferred = /*#__PURE__*/function () {
6549
6616
  return Deferred;
6550
6617
  }();
6551
6618
 
6552
- function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(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; } } }; }
6619
+ 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; } } }; }
6553
6620
 
6554
- function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
6621
+ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
6555
6622
 
6556
- function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6623
+ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6557
6624
 
6558
6625
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6559
6626
 
@@ -6733,7 +6800,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6733
6800
  case 9:
6734
6801
  myConversations = _context2.sent;
6735
6802
  upserts = [];
6736
- _iterator = _createForOfIteratorHelper$1(myConversations);
6803
+ _iterator = _createForOfIteratorHelper$2(myConversations);
6737
6804
 
6738
6805
  try {
6739
6806
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -7815,7 +7882,7 @@ function PushNotification(data) {
7815
7882
  this.data = data.data || {};
7816
7883
  });
7817
7884
 
7818
- var version = "3.0.1-rc.102";
7885
+ var version = "3.0.1-rc.103";
7819
7886
 
7820
7887
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7821
7888
 
@@ -8216,11 +8283,11 @@ var ContentClient = /*#__PURE__*/function () {
8216
8283
  return ContentClient;
8217
8284
  }();
8218
8285
 
8219
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(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; } } }; }
8286
+ function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(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; } } }; }
8220
8287
 
8221
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8288
+ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
8222
8289
 
8223
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8290
+ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8224
8291
 
8225
8292
  var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8226
8293
  function QuickLRU() {
@@ -8249,7 +8316,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8249
8316
  this._size = 0;
8250
8317
 
8251
8318
  if (typeof this.onEviction === 'function') {
8252
- var _iterator = _createForOfIteratorHelper(this.oldCache.entries()),
8319
+ var _iterator = _createForOfIteratorHelper$1(this.oldCache.entries()),
8253
8320
  _step;
8254
8321
 
8255
8322
  try {
@@ -8341,7 +8408,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8341
8408
  while (1) {
8342
8409
  switch (_context.prev = _context.next) {
8343
8410
  case 0:
8344
- _iterator2 = _createForOfIteratorHelper(this);
8411
+ _iterator2 = _createForOfIteratorHelper$1(this);
8345
8412
  _context.prev = 1;
8346
8413
 
8347
8414
  _iterator2.s();
@@ -8393,7 +8460,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8393
8460
  while (1) {
8394
8461
  switch (_context2.prev = _context2.next) {
8395
8462
  case 0:
8396
- _iterator3 = _createForOfIteratorHelper(this);
8463
+ _iterator3 = _createForOfIteratorHelper$1(this);
8397
8464
  _context2.prev = 1;
8398
8465
 
8399
8466
  _iterator3.s();
@@ -8445,7 +8512,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8445
8512
  while (1) {
8446
8513
  switch (_context3.prev = _context3.next) {
8447
8514
  case 0:
8448
- _iterator4 = _createForOfIteratorHelper(this.cache);
8515
+ _iterator4 = _createForOfIteratorHelper$1(this.cache);
8449
8516
  _context3.prev = 1;
8450
8517
 
8451
8518
  _iterator4.s();
@@ -8482,7 +8549,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8482
8549
  return _context3.finish(14);
8483
8550
 
8484
8551
  case 17:
8485
- _iterator5 = _createForOfIteratorHelper(this.oldCache);
8552
+ _iterator5 = _createForOfIteratorHelper$1(this.oldCache);
8486
8553
  _context3.prev = 18;
8487
8554
 
8488
8555
  _iterator5.s();
@@ -8537,7 +8604,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8537
8604
  get: function get() {
8538
8605
  var oldCacheSize = 0;
8539
8606
 
8540
- var _iterator6 = _createForOfIteratorHelper(this.oldCache.keys()),
8607
+ var _iterator6 = _createForOfIteratorHelper$1(this.oldCache.keys()),
8541
8608
  _step6;
8542
8609
 
8543
8610
  try {
@@ -8674,6 +8741,206 @@ var ChannelMetadataClient = /*#__PURE__*/function () {
8674
8741
  return ChannelMetadataClient;
8675
8742
  }();
8676
8743
 
8744
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(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; } } }; }
8745
+
8746
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8747
+
8748
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8749
+ /**
8750
+ * Email recipient descriptor.
8751
+ */
8752
+
8753
+ var EmailRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
8754
+ /**
8755
+ * Type of recipient.
8756
+ */
8757
+
8758
+ /**
8759
+ * @internal
8760
+ */
8761
+ function EmailRecipientDescriptor(recipient) {
8762
+ _classCallCheck__default["default"](this, EmailRecipientDescriptor);
8763
+
8764
+ _defineProperty__default["default"](this, "type", "email");
8765
+
8766
+ this.messageSid = recipient.message_sid;
8767
+ this.level = recipient.level;
8768
+ this.name = recipient.name;
8769
+ this.address = recipient.address;
8770
+ });
8771
+ /**
8772
+ * Unknown recipient descriptor. Used to be able to handle recipient types that
8773
+ * are not supported by the current version of the SDK.
8774
+ */
8775
+
8776
+
8777
+ var UnknownRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
8778
+ /**
8779
+ * Type of recipient.
8780
+ */
8781
+
8782
+ /**
8783
+ * Sid of the message that this recipient belongs to.
8784
+ */
8785
+
8786
+ /**
8787
+ * Recipient data as a JSON string.
8788
+ */
8789
+
8790
+ /**
8791
+ * @internal
8792
+ */
8793
+ function UnknownRecipientDescriptor(recipient) {
8794
+ _classCallCheck__default["default"](this, UnknownRecipientDescriptor);
8795
+
8796
+ this.type = recipient.type;
8797
+ this.messageSid = recipient.message_sid;
8798
+ this.rawData = JSON.stringify(recipient);
8799
+ });
8800
+
8801
+ var MessageRecipientsClient = /*#__PURE__*/function () {
8802
+ function MessageRecipientsClient(services, configuration) {
8803
+ _classCallCheck__default["default"](this, MessageRecipientsClient);
8804
+
8805
+ this._services = services;
8806
+ this._configuration = configuration;
8807
+ this._cache = new quickLru({
8808
+ maxSize: configuration.messageRecipientsCacheCapacity
8809
+ });
8810
+ }
8811
+
8812
+ _createClass__default["default"](MessageRecipientsClient, [{
8813
+ key: "getRecipientsFromMessage",
8814
+ value: function () {
8815
+ var _getRecipientsFromMessage = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(conversationSid, messageSid) {
8816
+ var _this = this;
8817
+
8818
+ var key, cachedItem, url, recipientsResponse, recipients;
8819
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
8820
+ while (1) {
8821
+ switch (_context.prev = _context.next) {
8822
+ case 0:
8823
+ key = "".concat(conversationSid, ",").concat(messageSid);
8824
+ cachedItem = this._cache.get(key);
8825
+
8826
+ if (!cachedItem) {
8827
+ _context.next = 4;
8828
+ break;
8829
+ }
8830
+
8831
+ return _context.abrupt("return", cachedItem.item);
8832
+
8833
+ case 4:
8834
+ url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("MessageSid", messageSid).build();
8835
+ _context.next = 7;
8836
+ return this._services.commandExecutor.fetchResource(url);
8837
+
8838
+ case 7:
8839
+ recipientsResponse = _context.sent;
8840
+ recipients = recipientsResponse.message_recipients.map(function (recipient) {
8841
+ return _this._wrapResponse(recipient);
8842
+ });
8843
+
8844
+ if (recipients.length > 0) {
8845
+ this._cache.set(key, {
8846
+ item: recipients
8847
+ });
8848
+ }
8849
+
8850
+ return _context.abrupt("return", recipients);
8851
+
8852
+ case 11:
8853
+ case "end":
8854
+ return _context.stop();
8855
+ }
8856
+ }
8857
+ }, _callee, this);
8858
+ }));
8859
+
8860
+ function getRecipientsFromMessage(_x, _x2) {
8861
+ return _getRecipientsFromMessage.apply(this, arguments);
8862
+ }
8863
+
8864
+ return getRecipientsFromMessage;
8865
+ }()
8866
+ }, {
8867
+ key: "getRecipientsFromConversation",
8868
+ value: function () {
8869
+ var _getRecipientsFromConversation = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(conversationSid, paginatorOptions) {
8870
+ var _paginatorOptions$pag,
8871
+ _paginatorOptions$pag2,
8872
+ _this2 = this;
8873
+
8874
+ var url, recipientsResponse, allRecipients, _iterator, _step, _this$_cache$get$item, _this$_cache$get, recipient, key, existingMessageRecipients;
8875
+
8876
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
8877
+ while (1) {
8878
+ switch (_context2.prev = _context2.next) {
8879
+ case 0:
8880
+ url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("PageToken", (_paginatorOptions$pag = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageToken) !== null && _paginatorOptions$pag !== void 0 ? _paginatorOptions$pag : "").arg("PageSize", (_paginatorOptions$pag2 = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageSize) !== null && _paginatorOptions$pag2 !== void 0 ? _paginatorOptions$pag2 : "").build();
8881
+ _context2.next = 3;
8882
+ return this._services.commandExecutor.fetchResource(url);
8883
+
8884
+ case 3:
8885
+ recipientsResponse = _context2.sent;
8886
+ allRecipients = recipientsResponse.message_recipients.map(function (recipient) {
8887
+ return _this2._wrapResponse(recipient);
8888
+ });
8889
+ _iterator = _createForOfIteratorHelper(allRecipients);
8890
+
8891
+ try {
8892
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
8893
+ recipient = _step.value;
8894
+ key = "".concat(conversationSid, ",").concat(recipient.messageSid);
8895
+ existingMessageRecipients = (_this$_cache$get$item = (_this$_cache$get = this._cache.get(key)) === null || _this$_cache$get === void 0 ? void 0 : _this$_cache$get.item) !== null && _this$_cache$get$item !== void 0 ? _this$_cache$get$item : [];
8896
+
8897
+ this._cache.set(key, {
8898
+ item: [].concat(_toConsumableArray__default["default"](existingMessageRecipients), [recipient])
8899
+ });
8900
+ }
8901
+ } catch (err) {
8902
+ _iterator.e(err);
8903
+ } finally {
8904
+ _iterator.f();
8905
+ }
8906
+
8907
+ return _context2.abrupt("return", new RestPaginator(allRecipients, function (pageToken, pageSize) {
8908
+ return _this2.getRecipientsFromConversation(conversationSid, {
8909
+ pageToken: pageToken,
8910
+ pageSize: pageSize
8911
+ });
8912
+ }, recipientsResponse.meta.previous_token, recipientsResponse.meta.next_token));
8913
+
8914
+ case 8:
8915
+ case "end":
8916
+ return _context2.stop();
8917
+ }
8918
+ }
8919
+ }, _callee2, this);
8920
+ }));
8921
+
8922
+ function getRecipientsFromConversation(_x3, _x4) {
8923
+ return _getRecipientsFromConversation.apply(this, arguments);
8924
+ }
8925
+
8926
+ return getRecipientsFromConversation;
8927
+ }()
8928
+ }, {
8929
+ key: "_wrapResponse",
8930
+ value: function _wrapResponse(recipient) {
8931
+ switch (recipient.type) {
8932
+ case "email":
8933
+ return new EmailRecipientDescriptor(recipient);
8934
+
8935
+ default:
8936
+ return new UnknownRecipientDescriptor(recipient);
8937
+ }
8938
+ }
8939
+ }]);
8940
+
8941
+ return MessageRecipientsClient;
8942
+ }();
8943
+
8677
8944
  var _class;
8678
8945
 
8679
8946
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -9895,6 +10162,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9895
10162
  configurationResponse = _context17.sent;
9896
10163
  this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
9897
10164
  this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
10165
+ this._services.messageRecipientsClient = new MessageRecipientsClient(this._services, this._configuration);
9898
10166
 
9899
10167
  this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
9900
10168
 
@@ -9973,10 +10241,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9973
10241
  }).catch(function (error) {
9974
10242
  throw error;
9975
10243
  });
9976
- _context17.next = 29;
10244
+ _context17.next = 30;
9977
10245
  return this._services.users.myself._ensureFetched();
9978
10246
 
9979
- case 29:
10247
+ case 30:
9980
10248
  Client_1._supportedPushChannels.forEach(function (channelType) {
9981
10249
  return _this3._subscribeToPushNotifications(channelType);
9982
10250
  });
@@ -9992,7 +10260,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9992
10260
  this.emit("stateChanged", "initialized");
9993
10261
  this.emit("initialized");
9994
10262
 
9995
- case 35:
10263
+ case 36:
9996
10264
  case "end":
9997
10265
  return _context17.stop();
9998
10266
  }
@@ -10252,6 +10520,7 @@ exports.ContentTemplate = ContentTemplate;
10252
10520
  exports.ContentTemplateVariable = ContentTemplateVariable;
10253
10521
  exports.Conversation = Conversation;
10254
10522
  exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
10523
+ exports.EmailRecipientDescriptor = EmailRecipientDescriptor;
10255
10524
  exports.Media = Media;
10256
10525
  exports.Message = Message;
10257
10526
  exports.MessageBuilder = MessageBuilder;
@@ -10259,6 +10528,7 @@ exports.NotificationTypes = NotificationTypes;
10259
10528
  exports.Participant = Participant;
10260
10529
  exports.PushNotification = PushNotification;
10261
10530
  exports.RestPaginator = RestPaginator;
10531
+ exports.UnknownRecipientDescriptor = UnknownRecipientDescriptor;
10262
10532
  exports.UnsentMessage = UnsentMessage;
10263
10533
  exports.User = User;
10264
10534
  //# sourceMappingURL=lib.js.map