@twilio/conversations 2.5.0-rc.8 → 2.5.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/browser.js CHANGED
@@ -1453,8 +1453,9 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1453
1453
  }
1454
1454
 
1455
1455
  this.state.isTyping = true;
1456
- this.emit("typingStarted", this);
1457
- this.conversation.emit("typingStarted", this);
1456
+ this.emit(Participant.typingStarted, this);
1457
+ this.conversation.emit(Conversation.typingStarted, this); // @fixme layering violation
1458
+
1458
1459
  this.state.typingTimeout = Number(setTimeout(function () {
1459
1460
  return _this2._endTyping();
1460
1461
  }, timeout));
@@ -1473,8 +1474,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1473
1474
  }
1474
1475
 
1475
1476
  this.state.isTyping = false;
1476
- this.emit("typingEnded", this);
1477
- this.conversation.emit("typingEnded", this);
1477
+ this.emit(Participant.typingEnded, this);
1478
+ this.conversation.emit(Conversation.typingEnded, this);
1478
1479
  clearInterval(this.state.typingTimeout);
1479
1480
  this.state.typingTimeout = null;
1480
1481
  }
@@ -1533,7 +1534,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
1533
1534
  }
1534
1535
 
1535
1536
  if (updateReasons.length > 0) {
1536
- this.emit("updated", {
1537
+ this.emit(Participant.updated, {
1537
1538
  participant: this,
1538
1539
  updateReasons: updateReasons
1539
1540
  });
@@ -1669,7 +1670,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1669
1670
 
1670
1671
  var _super = _createSuper$7(Participants);
1671
1672
 
1672
- function Participants(conversation, participants, links, configuration, services) {
1673
+ // passed in from Conversation
1674
+ function Participants(conversation, participants, links, services) {
1673
1675
  var _this;
1674
1676
 
1675
1677
  _classCallCheck__default["default"](this, Participants);
@@ -1681,7 +1683,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1681
1683
  _this.conversation = conversation;
1682
1684
  _this.participants = participants;
1683
1685
  _this.links = links;
1684
- _this.configuration = configuration;
1685
1686
  _this.services = services;
1686
1687
  return _this;
1687
1688
  }
@@ -1732,14 +1733,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1732
1733
  mode: "open_existing"
1733
1734
  }) : Promise.resolve(arg);
1734
1735
  return this.rosterEntityPromise = this.rosterEntityPromise || participantsMapPromise.then(function (rosterMap) {
1735
- rosterMap.on("itemAdded", function (args) {
1736
+ rosterMap.on(twilioSync.SyncMap.itemAdded, function (args) {
1736
1737
  log$4.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
1737
1738
 
1738
1739
  _this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
1739
- _this2.emit("participantJoined", participant);
1740
+ _this2.emit(Conversation.participantJoined, participant);
1740
1741
  });
1741
1742
  });
1742
- rosterMap.on("itemRemoved", function (args) {
1743
+ rosterMap.on(twilioSync.SyncMap.itemRemoved, function (args) {
1743
1744
  log$4.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
1744
1745
  var participantSid = args.key;
1745
1746
 
@@ -1755,12 +1756,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1755
1756
  return;
1756
1757
  }
1757
1758
 
1758
- _this2.emit("participantLeft", leftParticipant);
1759
+ _this2.emit(Conversation.participantLeft, leftParticipant);
1759
1760
  });
1760
- rosterMap.on("itemUpdated", function (args) {
1761
+ rosterMap.on(twilioSync.SyncMap.itemUpdated, function (args) {
1761
1762
  log$4.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
1762
1763
 
1763
- _this2.upsertParticipant(args.item.key, args.item.data);
1764
+ _this2.upsertParticipant(args.item.key, args.item.data).catch(function (e) {
1765
+ return log$4.error(e);
1766
+ });
1764
1767
  });
1765
1768
  var participantsPromises = [];
1766
1769
 
@@ -1854,8 +1857,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
1854
1857
  };
1855
1858
  participant = new Participant(data, participantSid, this.conversation, links, this.services);
1856
1859
  this.participants.set(participantSid, participant);
1857
- participant.on("updated", function (args) {
1858
- return _this3.emit("participantUpdated", args);
1860
+ participant.on(Participant.updated, function (args) {
1861
+ return _this3.emit(Conversation.participantUpdated, args);
1859
1862
  });
1860
1863
  return _context3.abrupt("return", participant);
1861
1864
 
@@ -2466,15 +2469,14 @@ var RestPaginator = /*#__PURE__*/function () {
2466
2469
  /**
2467
2470
  * @internal
2468
2471
  */
2469
- function RestPaginator(items, source, prevToken, nextToken, pageSize) {
2472
+ function RestPaginator(items, source, prevToken, nextToken) {
2470
2473
  _classCallCheck__default["default"](this, RestPaginator);
2471
2474
 
2472
2475
  this.state = {
2473
2476
  prevToken: prevToken,
2474
2477
  nextToken: nextToken,
2475
2478
  source: source,
2476
- items: items,
2477
- pageSize: pageSize
2479
+ items: items
2478
2480
  };
2479
2481
  }
2480
2482
  /**
@@ -2512,7 +2514,7 @@ var RestPaginator = /*#__PURE__*/function () {
2512
2514
  }, {
2513
2515
  key: "nextPage",
2514
2516
  value: function nextPage() {
2515
- return this.hasNextPage ? this.state.source(this.state.nextToken, this.state.pageSize) : Promise.reject(new Error("No next page"));
2517
+ return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error("No next page"));
2516
2518
  }
2517
2519
  /**
2518
2520
  * Request the previous page. Does not modify the existing object.
@@ -2521,7 +2523,7 @@ var RestPaginator = /*#__PURE__*/function () {
2521
2523
  }, {
2522
2524
  key: "prevPage",
2523
2525
  value: function prevPage() {
2524
- return this.hasPrevPage ? this.state.source(this.state.prevToken, this.state.pageSize) : Promise.reject(new Error("No previous page"));
2526
+ return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error("No previous page"));
2525
2527
  }
2526
2528
  }]);
2527
2529
 
@@ -3212,7 +3214,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3212
3214
  var _getParticipant = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
3213
3215
  var _this3 = this;
3214
3216
 
3215
- var participant, errorMesage;
3217
+ var participant, errorMessage;
3216
3218
  return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
3217
3219
  while (1) {
3218
3220
  switch (_context.prev = _context.next) {
@@ -3257,26 +3259,26 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3257
3259
  return _context.abrupt("return", participant);
3258
3260
 
3259
3261
  case 11:
3260
- errorMesage = "Participant with ";
3262
+ errorMessage = "Participant with ";
3261
3263
 
3262
3264
  if (this.state.participantSid) {
3263
- errorMesage += "SID '" + this.state.participantSid + "' ";
3265
+ errorMessage += "SID '" + this.state.participantSid + "' ";
3264
3266
  }
3265
3267
 
3266
3268
  if (this.state.author) {
3267
3269
  if (this.state.participantSid) {
3268
- errorMesage += "or ";
3270
+ errorMessage += "or ";
3269
3271
  }
3270
3272
 
3271
- errorMesage += "identity '" + this.state.author + "' ";
3273
+ errorMessage += "identity '" + this.state.author + "' ";
3272
3274
  }
3273
3275
 
3274
- if (errorMesage === "Participant with ") {
3275
- errorMesage = "Participant ";
3276
+ if (errorMessage === "Participant with ") {
3277
+ errorMessage = "Participant ";
3276
3278
  }
3277
3279
 
3278
- errorMesage += "was not found";
3279
- throw new Error(errorMesage);
3280
+ errorMessage += "was not found";
3281
+ throw new Error(errorMessage);
3280
3282
 
3281
3283
  case 17:
3282
3284
  case "end":
@@ -3613,7 +3615,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
3613
3615
  pageToken: pageToken,
3614
3616
  pageSize: pageSize
3615
3617
  });
3616
- }, response.body.meta.previous_token, response.body.meta.next_token, options === null || options === void 0 ? void 0 : options.pageSize));
3618
+ }, response.body.meta.previous_token, response.body.meta.next_token));
3617
3619
 
3618
3620
  case 6:
3619
3621
  case "end":
@@ -4939,32 +4941,39 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
4939
4941
  participants: _this._links.participants
4940
4942
  };
4941
4943
  _this._participants = new Map();
4942
- _this._participantsEntity = new Participants(_assertThisInitialized__default["default"](_this), _this._participants, participantsLinks, _this._configuration, _this._services);
4944
+ _this._participantsEntity = new Participants(_assertThisInitialized__default["default"](_this), _this._participants, // state leak
4945
+ participantsLinks, _this._services);
4943
4946
 
4944
- _this._participantsEntity.on("participantJoined", function (participant) {
4945
- return _this.emit("participantJoined", participant);
4947
+ _this._participantsEntity.on(Conversation.participantJoined, function (participant) {
4948
+ return (// @todo update participants map here??
4949
+ _this.emit(Conversation.participantJoined, participant)
4950
+ );
4946
4951
  });
4947
4952
 
4948
- _this._participantsEntity.on("participantLeft", function (participant) {
4949
- return _this.emit("participantLeft", participant);
4953
+ _this._participantsEntity.on(Conversation.participantLeft, function (participant) {
4954
+ return (// @todo update participants map here??
4955
+ _this.emit(Conversation.participantLeft, participant)
4956
+ );
4950
4957
  });
4951
4958
 
4952
- _this._participantsEntity.on("participantUpdated", function (args) {
4953
- return _this.emit("participantUpdated", args);
4959
+ _this._participantsEntity.on(Conversation.participantUpdated, function (args) {
4960
+ return (// @todo update participants map here??
4961
+ _this.emit(Conversation.participantUpdated, args)
4962
+ );
4954
4963
  });
4955
4964
 
4956
4965
  _this._messagesEntity = new Messages(_assertThisInitialized__default["default"](_this), configuration, services);
4957
4966
 
4958
- _this._messagesEntity.on("messageAdded", function (message) {
4967
+ _this._messagesEntity.on(Conversation.messageAdded, function (message) {
4959
4968
  return _this._onMessageAdded(message);
4960
4969
  });
4961
4970
 
4962
- _this._messagesEntity.on("messageUpdated", function (args) {
4963
- return _this.emit("messageUpdated", args);
4971
+ _this._messagesEntity.on(Conversation.messageUpdated, function (args) {
4972
+ return _this.emit(Conversation.messageUpdated, args);
4964
4973
  });
4965
4974
 
4966
- _this._messagesEntity.on("messageRemoved", function (message) {
4967
- return _this.emit("messageRemoved", message);
4975
+ _this._messagesEntity.on(Conversation.messageRemoved, function (message) {
4976
+ return _this.emit(Conversation.messageRemoved, message);
4968
4977
  });
4969
4978
 
4970
4979
  return _this;
@@ -5067,7 +5076,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
5067
5076
  return (_this$_internalState$3 = this._internalState.notificationLevel) !== null && _this$_internalState$3 !== void 0 ? _this$_internalState$3 : "default";
5068
5077
  }
5069
5078
  /**
5070
- * Conversation bindings. Undocumented feature (for now).
5079
+ * Conversation bindings. An undocumented feature (for now).
5071
5080
  * @internal
5072
5081
  */
5073
5082
 
@@ -6116,12 +6125,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6116
6125
  case 6:
6117
6126
  this._entity = _context25.sent;
6118
6127
 
6119
- this._entity.on("updated", function (args) {
6128
+ this._entity.on(twilioSync.SyncDocument.updated, function (args) {
6120
6129
  return _this2._update(args.data);
6121
6130
  });
6122
6131
 
6123
- this._entity.on("removed", function () {
6124
- return _this2.emit("removed", _this2);
6132
+ this._entity.on(twilioSync.SyncDocument.removed, function () {
6133
+ return _this2.emit(Conversation.removed, _this2);
6125
6134
  });
6126
6135
 
6127
6136
  this._update(this._entity.data);
@@ -6289,22 +6298,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6289
6298
  while (1) {
6290
6299
  switch (_context28.prev = _context28.next) {
6291
6300
  case 0:
6292
- if (!this._entity) {
6293
- _context28.next = 5;
6294
- break;
6295
- }
6296
-
6297
- _context28.next = 3;
6298
- return this._entity.close();
6301
+ if (this._entity) {
6302
+ this._entity.close();
6299
6303
 
6300
- case 3:
6301
- this._entity = null;
6302
- this._entityPromise = null;
6304
+ this._entity = null;
6305
+ this._entityPromise = null;
6306
+ }
6303
6307
 
6304
- case 5:
6305
6308
  return _context28.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
6306
6309
 
6307
- case 6:
6310
+ case 2:
6308
6311
  case "end":
6309
6312
  return _context28.stop();
6310
6313
  }
@@ -6473,7 +6476,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6473
6476
  }
6474
6477
 
6475
6478
  if (updateReasons.size > 0) {
6476
- this.emit("updated", {
6479
+ this.emit(Conversation.updated, {
6477
6480
  conversation: this,
6478
6481
  updateReasons: _toConsumableArray__default["default"](updateReasons)
6479
6482
  });
@@ -6505,7 +6508,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
6505
6508
  _iterator.f();
6506
6509
  }
6507
6510
 
6508
- this.emit("messageAdded", message);
6511
+ this.emit(Conversation.messageAdded, message);
6509
6512
  }
6510
6513
  /**
6511
6514
  * Set last read message index.
@@ -6815,7 +6818,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6815
6818
  return addConversation;
6816
6819
  }()
6817
6820
  /**
6818
- * Fetch conversations list and instantiate all necessary objects
6821
+ * Fetch conversations' list and instantiate all necessary objects
6819
6822
  */
6820
6823
 
6821
6824
  }, {
@@ -6836,12 +6839,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6836
6839
 
6837
6840
  case 3:
6838
6841
  map = _context2.sent;
6839
- map.on("itemAdded", function (args) {
6842
+ map.on(twilioSync.SyncMap.itemAdded, function (args) {
6840
6843
  log$1.debug("itemAdded: ".concat(args.item.key));
6841
6844
 
6842
6845
  _this2._upsertConversation("sync", args.item.key, args.item.data);
6843
6846
  });
6844
- map.on("itemRemoved", function (args) {
6847
+ map.on(twilioSync.SyncMap.itemRemoved, function (args) {
6845
6848
  log$1.debug("itemRemoved: ".concat(args.key));
6846
6849
  var sid = args.key;
6847
6850
 
@@ -6867,7 +6870,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
6867
6870
 
6868
6871
  conversation.emit("removed", conversation);
6869
6872
  });
6870
- map.on("itemUpdated", function (args) {
6873
+ map.on(twilioSync.SyncMap.itemUpdated, function (args) {
6871
6874
  log$1.debug("itemUpdated: ".concat(args.item.key));
6872
6875
 
6873
6876
  _this2._upsertConversation("sync", args.item.key, args.item.data);
@@ -7960,7 +7963,7 @@ function PushNotification(data) {
7960
7963
  this.data = data.data || {};
7961
7964
  });
7962
7965
 
7963
- var version = "2.5.0-rc.8";
7966
+ var version = "2.5.0";
7964
7967
 
7965
7968
  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; }
7966
7969
 
@@ -8987,7 +8990,7 @@ var MessageRecipientsClient = /*#__PURE__*/function () {
8987
8990
  pageToken: pageToken,
8988
8991
  pageSize: pageSize
8989
8992
  });
8990
- }, recipientsResponse.meta.previous_token, recipientsResponse.meta.next_token, paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageSize));
8993
+ }, recipientsResponse.meta.previous_token, recipientsResponse.meta.next_token));
8991
8994
 
8992
8995
  case 8:
8993
8996
  case "end":
@@ -9287,7 +9290,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9287
9290
  */
9288
9291
 
9289
9292
  /**
9290
- * Returned Conversations instance is not yet fully initialized. Calling any
9293
+ * Returned Conversations Client instance is not yet fully initialized. Calling any
9291
9294
  * operations will block until it is. Use connection events to monitor when
9292
9295
  * client becomes fully available (connectionStateChanged with state
9293
9296
  * 'connected') or not available (connectionStateChange with state 'denied',
@@ -9377,16 +9380,16 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9377
9380
 
9378
9381
  _this._services.twilsockClient = _this._options.twilsockClient = (_this$_options$twilso = _this._options.twilsockClient) !== null && _this$_options$twilso !== void 0 ? _this$_options$twilso : new twilsock.TwilsockClient(fpaToken, productId, _this._options);
9379
9382
 
9380
- _this._services.twilsockClient.on("tokenAboutToExpire", function () {
9381
- return _this.emit("tokenAboutToExpire");
9383
+ _this._services.twilsockClient.on(Client_1.tokenAboutToExpire, function () {
9384
+ return _this.emit(Client_1.tokenAboutToExpire);
9382
9385
  });
9383
9386
 
9384
- _this._services.twilsockClient.on("tokenExpired", function () {
9385
- return _this.emit("tokenExpired");
9387
+ _this._services.twilsockClient.on(Client_1.tokenExpired, function () {
9388
+ return _this.emit(Client_1.tokenExpired);
9386
9389
  });
9387
9390
 
9388
- _this._services.twilsockClient.on("connectionError", function (error) {
9389
- return _this.emit("connectionError", error);
9391
+ _this._services.twilsockClient.on(Client_1.connectionError, function (error) {
9392
+ return _this.emit(Client_1.connectionError, error);
9390
9393
  });
9391
9394
 
9392
9395
  _this._services.twilsockClient.on("stateChanged", function (state) {
@@ -9395,7 +9398,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9395
9398
  if (state !== _this.connectionState) {
9396
9399
  _this.connectionState = state;
9397
9400
 
9398
- _this.emit("connectionStateChanged", _this.connectionState);
9401
+ _this.emit(Client_1.connectionStateChanged, _this.connectionState);
9399
9402
  }
9400
9403
  });
9401
9404
 
@@ -9413,9 +9416,9 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9413
9416
  var emitFailed = function emitFailed(error) {
9414
9417
  _this._rejectEnsureReady(error);
9415
9418
 
9416
- _this.emit("stateChanged", "failed");
9419
+ _this.emit(Client_1.stateChanged, "failed");
9417
9420
 
9418
- _this.emit("initFailed", {
9421
+ _this.emit(Client_1.initFailed, {
9419
9422
  error: error
9420
9423
  });
9421
9424
  };
@@ -9468,9 +9471,9 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9468
9471
 
9469
9472
  _this._rejectEnsureReady(connectionError);
9470
9473
 
9471
- _this.emit("stateChanged", "failed");
9474
+ _this.emit(Client_1.stateChanged, "failed");
9472
9475
 
9473
- _this.emit("initFailed", {
9476
+ _this.emit(Client_1.initFailed, {
9474
9477
  error: connectionError
9475
9478
  });
9476
9479
 
@@ -9998,7 +10001,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
9998
10001
  return removePushRegistrations;
9999
10002
  }()
10000
10003
  /**
10001
- * Current version of the Conversations client.
10004
+ * Parse a push notification payload.
10002
10005
  */
10003
10006
 
10004
10007
  }, {
@@ -10335,8 +10338,8 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
10335
10338
 
10336
10339
  this._resolveEnsureReady();
10337
10340
 
10338
- this.emit("stateChanged", "initialized");
10339
- this.emit("initialized");
10341
+ this.emit(Client_1.stateChanged, "initialized");
10342
+ this.emit(Client_1.initialized);
10340
10343
 
10341
10344
  case 36:
10342
10345
  case "end":