@twilio/conversations 2.4.1 → 2.5.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/builds/lib.js CHANGED
@@ -406,9 +406,11 @@ var MINIMUM_RETRY_DELAY = 1000;
406
406
  var MAXIMUM_RETRY_DELAY = 4000;
407
407
  var MAXIMUM_ATTEMPTS_COUNT = 3;
408
408
  var RETRY_WHEN_THROTTLED = true;
409
+ var CHANNEL_METADATA_CACHE_CAPACITY = 100;
410
+ var MESSAGE_RECIPIENTS_CACHE_CAPACITY = 1000;
409
411
 
410
412
  var Configuration = /*#__PURE__*/_createClass__default["default"](function Configuration() {
411
- var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad;
413
+ var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad, _options$messageRecip;
412
414
 
413
415
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
414
416
  var configurationResponse = arguments.length > 1 ? arguments[1] : undefined;
@@ -467,7 +469,8 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
467
469
  this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(CONSUMPTION_HORIZON_SENDING_INTERVAL));
468
470
  }
469
471
 
470
- this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : 100;
472
+ this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : CHANNEL_METADATA_CACHE_CAPACITY;
473
+ this.messageRecipientsCacheCapacity = (_options$messageRecip = options.messageRecipientsCacheCapacity) !== null && _options$messageRecip !== void 0 ? _options$messageRecip : MESSAGE_RECIPIENTS_CACHE_CAPACITY;
471
474
  });
472
475
 
473
476
  /**
@@ -1085,11 +1088,11 @@ __decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("desig
1085
1088
 
1086
1089
  __decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
1087
1090
 
1088
- 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; } } }; }
1091
+ 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; } } }; }
1089
1092
 
1090
- 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); }
1093
+ 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); }
1091
1094
 
1092
- 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; }
1095
+ 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; }
1093
1096
 
1094
1097
  var Network = /*#__PURE__*/function () {
1095
1098
  function Network(configuration, services) {
@@ -1110,7 +1113,7 @@ var Network = /*#__PURE__*/function () {
1110
1113
  }, {
1111
1114
  key: "cleanupCache",
1112
1115
  value: function cleanupCache() {
1113
- var _iterator = _createForOfIteratorHelper$4(this.cache),
1116
+ var _iterator = _createForOfIteratorHelper$5(this.cache),
1114
1117
  _step;
1115
1118
 
1116
1119
  try {
@@ -3794,6 +3797,38 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3794
3797
 
3795
3798
  return getChannelMetadata;
3796
3799
  }()
3800
+ /**
3801
+ * Get recipients of the message.
3802
+ */
3803
+
3804
+ }, {
3805
+ key: "getMessageRecipients",
3806
+ value: function () {
3807
+ var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11() {
3808
+ return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context11) {
3809
+ while (1) {
3810
+ switch (_context11.prev = _context11.next) {
3811
+ case 0:
3812
+ _context11.next = 2;
3813
+ return this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid, this.sid);
3814
+
3815
+ case 2:
3816
+ return _context11.abrupt("return", _context11.sent);
3817
+
3818
+ case 3:
3819
+ case "end":
3820
+ return _context11.stop();
3821
+ }
3822
+ }
3823
+ }, _callee11, this);
3824
+ }));
3825
+
3826
+ function getMessageRecipients() {
3827
+ return _getMessageRecipients.apply(this, arguments);
3828
+ }
3829
+
3830
+ return getMessageRecipients;
3831
+ }()
3797
3832
  }]);
3798
3833
 
3799
3834
  return Message;
@@ -3843,11 +3878,11 @@ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if
3843
3878
 
3844
3879
  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; }
3845
3880
 
3846
- 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; } } }; }
3881
+ 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; } } }; }
3847
3882
 
3848
- 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); }
3883
+ 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); }
3849
3884
 
3850
- 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; }
3885
+ 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; }
3851
3886
 
3852
3887
  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); }; }
3853
3888
 
@@ -4055,7 +4090,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
4055
4090
  return request.cancel();
4056
4091
  });
4057
4092
  });
4058
- _iterator = _createForOfIteratorHelper$3(message.mediaContent);
4093
+ _iterator = _createForOfIteratorHelper$4(message.mediaContent);
4059
4094
  _context3.prev = 4;
4060
4095
 
4061
4096
  _iterator.s();
@@ -4708,11 +4743,11 @@ __decorate([declarativeTypeValidator.validateTypes("string", [declarativeTypeVal
4708
4743
 
4709
4744
  __decorate([declarativeTypeValidator.validateTypes([FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "addMedia", null);
4710
4745
 
4711
- 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; } } }; }
4746
+ 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; } } }; }
4712
4747
 
4713
- 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); }
4748
+ 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); }
4714
4749
 
4715
- 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; }
4750
+ 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; }
4716
4751
 
4717
4752
  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); }; }
4718
4753
 
@@ -5998,6 +6033,38 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5998
6033
 
5999
6034
  return updateUniqueName;
6000
6035
  }()
6036
+ /**
6037
+ * Get recipients of all messages in the conversation.
6038
+ */
6039
+
6040
+ }, {
6041
+ key: "getMessageRecipients",
6042
+ value: function () {
6043
+ var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24() {
6044
+ return _regeneratorRuntime__default["default"].wrap(function _callee24$(_context24) {
6045
+ while (1) {
6046
+ switch (_context24.prev = _context24.next) {
6047
+ case 0:
6048
+ _context24.next = 2;
6049
+ return this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid);
6050
+
6051
+ case 2:
6052
+ return _context24.abrupt("return", _context24.sent);
6053
+
6054
+ case 3:
6055
+ case "end":
6056
+ return _context24.stop();
6057
+ }
6058
+ }
6059
+ }, _callee24, this);
6060
+ }));
6061
+
6062
+ function getMessageRecipients() {
6063
+ return _getMessageRecipients.apply(this, arguments);
6064
+ }
6065
+
6066
+ return getMessageRecipients;
6067
+ }()
6001
6068
  /**
6002
6069
  * Load and subscribe to this conversation and do not subscribe to its
6003
6070
  * participants and messages. This or _subscribeStreams will need to be called
@@ -6008,31 +6075,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6008
6075
  }, {
6009
6076
  key: "_subscribe",
6010
6077
  value: function () {
6011
- var _subscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24() {
6078
+ var _subscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
6012
6079
  var _this2 = this;
6013
6080
 
6014
- return _regeneratorRuntime__default["default"].wrap(function _callee24$(_context24) {
6081
+ return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
6015
6082
  while (1) {
6016
- switch (_context24.prev = _context24.next) {
6083
+ switch (_context25.prev = _context25.next) {
6017
6084
  case 0:
6018
6085
  if (!this._entityPromise) {
6019
- _context24.next = 2;
6086
+ _context25.next = 2;
6020
6087
  break;
6021
6088
  }
6022
6089
 
6023
- return _context24.abrupt("return", this._entityPromise);
6090
+ return _context25.abrupt("return", this._entityPromise);
6024
6091
 
6025
6092
  case 2:
6026
6093
  this._entityPromise = this._services.syncClient.document({
6027
6094
  id: this._entityName,
6028
6095
  mode: "open_existing"
6029
6096
  });
6030
- _context24.prev = 3;
6031
- _context24.next = 6;
6097
+ _context25.prev = 3;
6098
+ _context25.next = 6;
6032
6099
  return this._entityPromise;
6033
6100
 
6034
6101
  case 6:
6035
- this._entity = _context24.sent;
6102
+ this._entity = _context25.sent;
6036
6103
 
6037
6104
  this._entity.on("updated", function (args) {
6038
6105
  return _this2._update(args.data);
@@ -6044,28 +6111,28 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6044
6111
 
6045
6112
  this._update(this._entity.data);
6046
6113
 
6047
- return _context24.abrupt("return", this._entity);
6114
+ return _context25.abrupt("return", this._entity);
6048
6115
 
6049
6116
  case 13:
6050
- _context24.prev = 13;
6051
- _context24.t0 = _context24["catch"](3);
6117
+ _context25.prev = 13;
6118
+ _context25.t0 = _context25["catch"](3);
6052
6119
  this._entity = null;
6053
6120
  this._entityPromise = null;
6054
6121
 
6055
6122
  if (this._services.syncClient.connectionState != "disconnected") {
6056
- Conversation._logger.error("Failed to get conversation object", _context24.t0);
6123
+ Conversation._logger.error("Failed to get conversation object", _context25.t0);
6057
6124
  }
6058
6125
 
6059
- Conversation._logger.debug("ERROR: Failed to get conversation object", _context24.t0);
6126
+ Conversation._logger.debug("ERROR: Failed to get conversation object", _context25.t0);
6060
6127
 
6061
- throw _context24.t0;
6128
+ throw _context25.t0;
6062
6129
 
6063
6130
  case 20:
6064
6131
  case "end":
6065
- return _context24.stop();
6132
+ return _context25.stop();
6066
6133
  }
6067
6134
  }
6068
- }, _callee24, this, [[3, 13]]);
6135
+ }, _callee25, this, [[3, 13]]);
6069
6136
  }));
6070
6137
 
6071
6138
  function _subscribe() {
@@ -6087,44 +6154,44 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6087
6154
  }, {
6088
6155
  key: "_fetchStreams",
6089
6156
  value: function () {
6090
- var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
6157
+ var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26() {
6091
6158
  var _this$_entity, _this$_entity2;
6092
6159
 
6093
6160
  var data;
6094
- return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
6161
+ return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
6095
6162
  while (1) {
6096
- switch (_context25.prev = _context25.next) {
6163
+ switch (_context26.prev = _context26.next) {
6097
6164
  case 0:
6098
- _context25.next = 2;
6165
+ _context26.next = 2;
6099
6166
  return this._subscribe();
6100
6167
 
6101
6168
  case 2:
6102
6169
  Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
6103
6170
 
6104
6171
  data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
6105
- _context25.next = 6;
6172
+ _context26.next = 6;
6106
6173
  return this._services.syncClient.list({
6107
6174
  id: data.messages,
6108
6175
  mode: "open_existing"
6109
6176
  });
6110
6177
 
6111
6178
  case 6:
6112
- this._messagesList = _context25.sent;
6113
- _context25.next = 9;
6179
+ this._messagesList = _context26.sent;
6180
+ _context26.next = 9;
6114
6181
  return this._services.syncClient.map({
6115
6182
  id: data.roster,
6116
6183
  mode: "open_existing"
6117
6184
  });
6118
6185
 
6119
6186
  case 9:
6120
- this._participantsMap = _context25.sent;
6187
+ this._participantsMap = _context26.sent;
6121
6188
 
6122
6189
  case 10:
6123
6190
  case "end":
6124
- return _context25.stop();
6191
+ return _context26.stop();
6125
6192
  }
6126
6193
  }
6127
- }, _callee25, this);
6194
+ }, _callee26, this);
6128
6195
  }));
6129
6196
 
6130
6197
  function _fetchStreams() {
@@ -6144,15 +6211,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6144
6211
  }, {
6145
6212
  key: "_subscribeStreams",
6146
6213
  value: function () {
6147
- var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26() {
6214
+ var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
6148
6215
  var _this$_entity3, _this$_entity4, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
6149
6216
 
6150
- return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
6217
+ return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
6151
6218
  while (1) {
6152
- switch (_context26.prev = _context26.next) {
6219
+ switch (_context27.prev = _context27.next) {
6153
6220
  case 0:
6154
- _context26.prev = 0;
6155
- _context26.next = 3;
6221
+ _context27.prev = 0;
6222
+ _context27.next = 3;
6156
6223
  return this._subscribe();
6157
6224
 
6158
6225
  case 3:
@@ -6161,31 +6228,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6161
6228
  data = (_this$_entity4 = this._entity) === null || _this$_entity4 === void 0 ? void 0 : _this$_entity4.data;
6162
6229
  messagesObjectName = data.messages;
6163
6230
  rosterObjectName = data.roster;
6164
- _context26.next = 9;
6231
+ _context27.next = 9;
6165
6232
  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)]);
6166
6233
 
6167
6234
  case 9:
6168
- _context26.next = 16;
6235
+ _context27.next = 16;
6169
6236
  break;
6170
6237
 
6171
6238
  case 11:
6172
- _context26.prev = 11;
6173
- _context26.t0 = _context26["catch"](0);
6239
+ _context27.prev = 11;
6240
+ _context27.t0 = _context27["catch"](0);
6174
6241
 
6175
6242
  if (this._services.syncClient.connectionState !== "disconnected") {
6176
- Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context26.t0);
6243
+ Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context27.t0);
6177
6244
  }
6178
6245
 
6179
- Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context26.t0);
6246
+ Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context27.t0);
6180
6247
 
6181
- throw _context26.t0;
6248
+ throw _context27.t0;
6182
6249
 
6183
6250
  case 16:
6184
6251
  case "end":
6185
- return _context26.stop();
6252
+ return _context27.stop();
6186
6253
  }
6187
6254
  }
6188
- }, _callee26, this, [[0, 11]]);
6255
+ }, _callee27, this, [[0, 11]]);
6189
6256
  }));
6190
6257
 
6191
6258
  function _subscribeStreams() {
@@ -6202,17 +6269,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6202
6269
  }, {
6203
6270
  key: "_unsubscribe",
6204
6271
  value: function () {
6205
- var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
6206
- return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
6272
+ var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28() {
6273
+ return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
6207
6274
  while (1) {
6208
- switch (_context27.prev = _context27.next) {
6275
+ switch (_context28.prev = _context28.next) {
6209
6276
  case 0:
6210
6277
  if (!this._entity) {
6211
- _context27.next = 5;
6278
+ _context28.next = 5;
6212
6279
  break;
6213
6280
  }
6214
6281
 
6215
- _context27.next = 3;
6282
+ _context28.next = 3;
6216
6283
  return this._entity.close();
6217
6284
 
6218
6285
  case 3:
@@ -6220,14 +6287,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6220
6287
  this._entityPromise = null;
6221
6288
 
6222
6289
  case 5:
6223
- return _context27.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
6290
+ return _context28.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
6224
6291
 
6225
6292
  case 6:
6226
6293
  case "end":
6227
- return _context27.stop();
6294
+ return _context28.stop();
6228
6295
  }
6229
6296
  }
6230
- }, _callee27, this);
6297
+ }, _callee28, this);
6231
6298
  }));
6232
6299
 
6233
6300
  function _unsubscribe() {
@@ -6404,7 +6471,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6404
6471
  }, {
6405
6472
  key: "_onMessageAdded",
6406
6473
  value: function _onMessageAdded(message) {
6407
- var _iterator = _createForOfIteratorHelper$2(this._participants.values()),
6474
+ var _iterator = _createForOfIteratorHelper$3(this._participants.values()),
6408
6475
  _step;
6409
6476
 
6410
6477
  try {
@@ -6433,27 +6500,27 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6433
6500
  }, {
6434
6501
  key: "_setLastReadMessageIndex",
6435
6502
  value: function () {
6436
- var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28(index) {
6503
+ var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee29(index) {
6437
6504
  var result;
6438
- return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
6505
+ return _regeneratorRuntime__default["default"].wrap(function _callee29$(_context29) {
6439
6506
  while (1) {
6440
- switch (_context28.prev = _context28.next) {
6507
+ switch (_context29.prev = _context29.next) {
6441
6508
  case 0:
6442
- _context28.next = 2;
6509
+ _context29.next = 2;
6443
6510
  return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
6444
6511
  last_read_message_index: index
6445
6512
  });
6446
6513
 
6447
6514
  case 2:
6448
- result = _context28.sent;
6449
- return _context28.abrupt("return", result.unread_messages_count);
6515
+ result = _context29.sent;
6516
+ return _context29.abrupt("return", result.unread_messages_count);
6450
6517
 
6451
6518
  case 4:
6452
6519
  case "end":
6453
- return _context28.stop();
6520
+ return _context29.stop();
6454
6521
  }
6455
6522
  }
6456
- }, _callee28, this);
6523
+ }, _callee29, this);
6457
6524
  }));
6458
6525
 
6459
6526
  function _setLastReadMessageIndex(_x19) {
@@ -6612,11 +6679,11 @@ var Deferred = /*#__PURE__*/function () {
6612
6679
  return Deferred;
6613
6680
  }();
6614
6681
 
6615
- 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; } } }; }
6682
+ 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; } } }; }
6616
6683
 
6617
- 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); }
6684
+ 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); }
6618
6685
 
6619
- 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; }
6686
+ 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; }
6620
6687
 
6621
6688
  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; }
6622
6689
 
@@ -6796,7 +6863,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6796
6863
  case 9:
6797
6864
  myConversations = _context2.sent;
6798
6865
  upserts = [];
6799
- _iterator = _createForOfIteratorHelper$1(myConversations);
6866
+ _iterator = _createForOfIteratorHelper$2(myConversations);
6800
6867
 
6801
6868
  try {
6802
6869
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -7878,7 +7945,7 @@ function PushNotification(data) {
7878
7945
  this.data = data.data || {};
7879
7946
  });
7880
7947
 
7881
- var version = "2.4.1";
7948
+ var version = "2.5.0-rc.0";
7882
7949
 
7883
7950
  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; }
7884
7951
 
@@ -8279,11 +8346,11 @@ var ContentClient = /*#__PURE__*/function () {
8279
8346
  return ContentClient;
8280
8347
  }();
8281
8348
 
8282
- 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; } } }; }
8349
+ 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; } } }; }
8283
8350
 
8284
- 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); }
8351
+ 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); }
8285
8352
 
8286
- 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; }
8353
+ 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; }
8287
8354
 
8288
8355
  var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8289
8356
  function QuickLRU() {
@@ -8312,7 +8379,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8312
8379
  this._size = 0;
8313
8380
 
8314
8381
  if (typeof this.onEviction === 'function') {
8315
- var _iterator = _createForOfIteratorHelper(this.oldCache.entries()),
8382
+ var _iterator = _createForOfIteratorHelper$1(this.oldCache.entries()),
8316
8383
  _step;
8317
8384
 
8318
8385
  try {
@@ -8404,7 +8471,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8404
8471
  while (1) {
8405
8472
  switch (_context.prev = _context.next) {
8406
8473
  case 0:
8407
- _iterator2 = _createForOfIteratorHelper(this);
8474
+ _iterator2 = _createForOfIteratorHelper$1(this);
8408
8475
  _context.prev = 1;
8409
8476
 
8410
8477
  _iterator2.s();
@@ -8456,7 +8523,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8456
8523
  while (1) {
8457
8524
  switch (_context2.prev = _context2.next) {
8458
8525
  case 0:
8459
- _iterator3 = _createForOfIteratorHelper(this);
8526
+ _iterator3 = _createForOfIteratorHelper$1(this);
8460
8527
  _context2.prev = 1;
8461
8528
 
8462
8529
  _iterator3.s();
@@ -8508,7 +8575,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8508
8575
  while (1) {
8509
8576
  switch (_context3.prev = _context3.next) {
8510
8577
  case 0:
8511
- _iterator4 = _createForOfIteratorHelper(this.cache);
8578
+ _iterator4 = _createForOfIteratorHelper$1(this.cache);
8512
8579
  _context3.prev = 1;
8513
8580
 
8514
8581
  _iterator4.s();
@@ -8545,7 +8612,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8545
8612
  return _context3.finish(14);
8546
8613
 
8547
8614
  case 17:
8548
- _iterator5 = _createForOfIteratorHelper(this.oldCache);
8615
+ _iterator5 = _createForOfIteratorHelper$1(this.oldCache);
8549
8616
  _context3.prev = 18;
8550
8617
 
8551
8618
  _iterator5.s();
@@ -8600,7 +8667,7 @@ var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
8600
8667
  get: function get() {
8601
8668
  var oldCacheSize = 0;
8602
8669
 
8603
- var _iterator6 = _createForOfIteratorHelper(this.oldCache.keys()),
8670
+ var _iterator6 = _createForOfIteratorHelper$1(this.oldCache.keys()),
8604
8671
  _step6;
8605
8672
 
8606
8673
  try {
@@ -8737,6 +8804,206 @@ var ChannelMetadataClient = /*#__PURE__*/function () {
8737
8804
  return ChannelMetadataClient;
8738
8805
  }();
8739
8806
 
8807
+ 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; } } }; }
8808
+
8809
+ 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); }
8810
+
8811
+ 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; }
8812
+ /**
8813
+ * Email recipient descriptor.
8814
+ */
8815
+
8816
+ var EmailRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
8817
+ /**
8818
+ * Type of recipient.
8819
+ */
8820
+
8821
+ /**
8822
+ * @internal
8823
+ */
8824
+ function EmailRecipientDescriptor(recipient) {
8825
+ _classCallCheck__default["default"](this, EmailRecipientDescriptor);
8826
+
8827
+ _defineProperty__default["default"](this, "type", "email");
8828
+
8829
+ this.messageSid = recipient.message_sid;
8830
+ this.level = recipient.level;
8831
+ this.name = recipient.name;
8832
+ this.address = recipient.address;
8833
+ });
8834
+ /**
8835
+ * Unknown recipient descriptor. Used to be able to handle recipient types that
8836
+ * are not supported by the current version of the SDK.
8837
+ */
8838
+
8839
+
8840
+ var UnknownRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
8841
+ /**
8842
+ * Type of recipient.
8843
+ */
8844
+
8845
+ /**
8846
+ * Sid of the message that this recipient belongs to.
8847
+ */
8848
+
8849
+ /**
8850
+ * Recipient data as a JSON string.
8851
+ */
8852
+
8853
+ /**
8854
+ * @internal
8855
+ */
8856
+ function UnknownRecipientDescriptor(recipient) {
8857
+ _classCallCheck__default["default"](this, UnknownRecipientDescriptor);
8858
+
8859
+ this.type = recipient.type;
8860
+ this.messageSid = recipient.message_sid;
8861
+ this.rawData = JSON.stringify(recipient);
8862
+ });
8863
+
8864
+ var MessageRecipientsClient = /*#__PURE__*/function () {
8865
+ function MessageRecipientsClient(services, configuration) {
8866
+ _classCallCheck__default["default"](this, MessageRecipientsClient);
8867
+
8868
+ this._services = services;
8869
+ this._configuration = configuration;
8870
+ this._cache = new quickLru({
8871
+ maxSize: configuration.messageRecipientsCacheCapacity
8872
+ });
8873
+ }
8874
+
8875
+ _createClass__default["default"](MessageRecipientsClient, [{
8876
+ key: "getRecipientsFromMessage",
8877
+ value: function () {
8878
+ var _getRecipientsFromMessage = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(conversationSid, messageSid) {
8879
+ var _this = this;
8880
+
8881
+ var key, cachedItem, url, recipientsResponse, recipients;
8882
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
8883
+ while (1) {
8884
+ switch (_context.prev = _context.next) {
8885
+ case 0:
8886
+ key = "".concat(conversationSid, ",").concat(messageSid);
8887
+ cachedItem = this._cache.get(key);
8888
+
8889
+ if (!cachedItem) {
8890
+ _context.next = 4;
8891
+ break;
8892
+ }
8893
+
8894
+ return _context.abrupt("return", cachedItem.item);
8895
+
8896
+ case 4:
8897
+ url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("MessageSid", messageSid).build();
8898
+ _context.next = 7;
8899
+ return this._services.commandExecutor.fetchResource(url);
8900
+
8901
+ case 7:
8902
+ recipientsResponse = _context.sent;
8903
+ recipients = recipientsResponse.message_recipients.map(function (recipient) {
8904
+ return _this._wrapResponse(recipient);
8905
+ });
8906
+
8907
+ if (recipients.length > 0) {
8908
+ this._cache.set(key, {
8909
+ item: recipients
8910
+ });
8911
+ }
8912
+
8913
+ return _context.abrupt("return", recipients);
8914
+
8915
+ case 11:
8916
+ case "end":
8917
+ return _context.stop();
8918
+ }
8919
+ }
8920
+ }, _callee, this);
8921
+ }));
8922
+
8923
+ function getRecipientsFromMessage(_x, _x2) {
8924
+ return _getRecipientsFromMessage.apply(this, arguments);
8925
+ }
8926
+
8927
+ return getRecipientsFromMessage;
8928
+ }()
8929
+ }, {
8930
+ key: "getRecipientsFromConversation",
8931
+ value: function () {
8932
+ var _getRecipientsFromConversation = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(conversationSid, paginatorOptions) {
8933
+ var _paginatorOptions$pag,
8934
+ _paginatorOptions$pag2,
8935
+ _this2 = this;
8936
+
8937
+ var url, recipientsResponse, allRecipients, _iterator, _step, _this$_cache$get$item, _this$_cache$get, recipient, key, existingMessageRecipients;
8938
+
8939
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
8940
+ while (1) {
8941
+ switch (_context2.prev = _context2.next) {
8942
+ case 0:
8943
+ 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();
8944
+ _context2.next = 3;
8945
+ return this._services.commandExecutor.fetchResource(url);
8946
+
8947
+ case 3:
8948
+ recipientsResponse = _context2.sent;
8949
+ allRecipients = recipientsResponse.message_recipients.map(function (recipient) {
8950
+ return _this2._wrapResponse(recipient);
8951
+ });
8952
+ _iterator = _createForOfIteratorHelper(allRecipients);
8953
+
8954
+ try {
8955
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
8956
+ recipient = _step.value;
8957
+ key = "".concat(conversationSid, ",").concat(recipient.messageSid);
8958
+ 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 : [];
8959
+
8960
+ this._cache.set(key, {
8961
+ item: [].concat(_toConsumableArray__default["default"](existingMessageRecipients), [recipient])
8962
+ });
8963
+ }
8964
+ } catch (err) {
8965
+ _iterator.e(err);
8966
+ } finally {
8967
+ _iterator.f();
8968
+ }
8969
+
8970
+ return _context2.abrupt("return", new RestPaginator(allRecipients, function (pageToken, pageSize) {
8971
+ return _this2.getRecipientsFromConversation(conversationSid, {
8972
+ pageToken: pageToken,
8973
+ pageSize: pageSize
8974
+ });
8975
+ }, recipientsResponse.meta.previous_token, recipientsResponse.meta.next_token));
8976
+
8977
+ case 8:
8978
+ case "end":
8979
+ return _context2.stop();
8980
+ }
8981
+ }
8982
+ }, _callee2, this);
8983
+ }));
8984
+
8985
+ function getRecipientsFromConversation(_x3, _x4) {
8986
+ return _getRecipientsFromConversation.apply(this, arguments);
8987
+ }
8988
+
8989
+ return getRecipientsFromConversation;
8990
+ }()
8991
+ }, {
8992
+ key: "_wrapResponse",
8993
+ value: function _wrapResponse(recipient) {
8994
+ switch (recipient.type) {
8995
+ case "email":
8996
+ return new EmailRecipientDescriptor(recipient);
8997
+
8998
+ default:
8999
+ return new UnknownRecipientDescriptor(recipient);
9000
+ }
9001
+ }
9002
+ }]);
9003
+
9004
+ return MessageRecipientsClient;
9005
+ }();
9006
+
8740
9007
  var _class;
8741
9008
 
8742
9009
  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; }
@@ -9958,6 +10225,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9958
10225
  configurationResponse = _context17.sent;
9959
10226
  this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
9960
10227
  this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
10228
+ this._services.messageRecipientsClient = new MessageRecipientsClient(this._services, this._configuration);
9961
10229
 
9962
10230
  this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
9963
10231
 
@@ -10036,10 +10304,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
10036
10304
  }).catch(function (error) {
10037
10305
  throw error;
10038
10306
  });
10039
- _context17.next = 29;
10307
+ _context17.next = 30;
10040
10308
  return this._services.users.myself._ensureFetched();
10041
10309
 
10042
- case 29:
10310
+ case 30:
10043
10311
  Client_1._supportedPushChannels.forEach(function (channelType) {
10044
10312
  return _this3._subscribeToPushNotifications(channelType);
10045
10313
  });
@@ -10055,7 +10323,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
10055
10323
  this.emit("stateChanged", "initialized");
10056
10324
  this.emit("initialized");
10057
10325
 
10058
- case 35:
10326
+ case 36:
10059
10327
  case "end":
10060
10328
  return _context17.stop();
10061
10329
  }
@@ -10315,6 +10583,7 @@ exports.ContentTemplate = ContentTemplate;
10315
10583
  exports.ContentTemplateVariable = ContentTemplateVariable;
10316
10584
  exports.Conversation = Conversation;
10317
10585
  exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
10586
+ exports.EmailRecipientDescriptor = EmailRecipientDescriptor;
10318
10587
  exports.Media = Media;
10319
10588
  exports.Message = Message;
10320
10589
  exports.MessageBuilder = MessageBuilder;
@@ -10322,6 +10591,7 @@ exports.NotificationTypes = NotificationTypes;
10322
10591
  exports.Participant = Participant;
10323
10592
  exports.PushNotification = PushNotification;
10324
10593
  exports.RestPaginator = RestPaginator;
10594
+ exports.UnknownRecipientDescriptor = UnknownRecipientDescriptor;
10325
10595
  exports.UnsentMessage = UnsentMessage;
10326
10596
  exports.User = User;
10327
10597
  //# sourceMappingURL=lib.js.map