stream-chat 4.1.0 → 4.4.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/dist/index.es.js CHANGED
@@ -14,7 +14,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
14
14
  import FormData from 'form-data';
15
15
  import WebSocket from 'isomorphic-ws';
16
16
  import jwt from 'jsonwebtoken';
17
- import crypto from 'crypto';
17
+ import crypto$1 from 'crypto';
18
18
 
19
19
  function isString$1(arrayOrString) {
20
20
  return typeof arrayOrString === 'string';
@@ -89,9 +89,9 @@ var decodeBase64 = function decodeBase64(s) {
89
89
  return r;
90
90
  };
91
91
 
92
- function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
92
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
93
93
 
94
- function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
94
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
95
95
 
96
96
  /**
97
97
  * ChannelState - A container class for the channel state.
@@ -159,7 +159,7 @@ var ChannelState = /*#__PURE__*/function () {
159
159
  var m = messages[i];
160
160
 
161
161
  if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
162
- messages[i] = _objectSpread$4(_objectSpread$4({}, m), {}, {
162
+ messages[i] = _objectSpread$5(_objectSpread$5({}, m), {}, {
163
163
  user: user
164
164
  });
165
165
  }
@@ -212,7 +212,7 @@ var ChannelState = /*#__PURE__*/function () {
212
212
  user: m.user
213
213
  };
214
214
  } else {
215
- messages[i] = _objectSpread$4(_objectSpread$4({}, m), {}, {
215
+ messages[i] = _objectSpread$5(_objectSpread$5({}, m), {}, {
216
216
  type: 'deleted',
217
217
  deleted_at: user.deleted_at
218
218
  });
@@ -280,7 +280,7 @@ var ChannelState = /*#__PURE__*/function () {
280
280
  }, {
281
281
  key: "formatMessage",
282
282
  value: function formatMessage(message) {
283
- return _objectSpread$4(_objectSpread$4({}, message), {}, {
283
+ return _objectSpread$5(_objectSpread$5({}, message), {}, {
284
284
  /**
285
285
  * @deprecated please use `html`
286
286
  */
@@ -470,7 +470,7 @@ var ChannelState = /*#__PURE__*/function () {
470
470
  var parseMessage = function parseMessage(m) {
471
471
  var _m$pinned_at, _m$updated_at;
472
472
 
473
- return _objectSpread$4(_objectSpread$4({}, m), {}, {
473
+ return _objectSpread$5(_objectSpread$5({}, m), {}, {
474
474
  created_at: m.created_at.toString(),
475
475
  pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toString(),
476
476
  updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toString()
@@ -480,8 +480,8 @@ var ChannelState = /*#__PURE__*/function () {
480
480
  var updatedMessages = this.messages.filter(function (msg) {
481
481
  return msg.quoted_message_id === message.id;
482
482
  }).map(parseMessage).map(function (msg) {
483
- return _objectSpread$4(_objectSpread$4({}, msg), {}, {
484
- quoted_message: _objectSpread$4(_objectSpread$4({}, message), {}, {
483
+ return _objectSpread$5(_objectSpread$5({}, msg), {}, {
484
+ quoted_message: _objectSpread$5(_objectSpread$5({}, message), {}, {
485
485
  attachments: []
486
486
  })
487
487
  });
@@ -701,9 +701,9 @@ var ChannelState = /*#__PURE__*/function () {
701
701
  return ChannelState;
702
702
  }();
703
703
 
704
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
704
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
705
705
 
706
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
706
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
707
707
 
708
708
  var EVENT_MAP = {
709
709
  'channel.created': true,
@@ -750,7 +750,7 @@ var EVENT_MAP = {
750
750
  'connection.recovered': true
751
751
  };
752
752
 
753
- var IS_VALID_EVENT_MAP_TYPE = _objectSpread$3(_objectSpread$3({}, EVENT_MAP), {}, {
753
+ var IS_VALID_EVENT_MAP_TYPE = _objectSpread$4(_objectSpread$4({}, EVENT_MAP), {}, {
754
754
  all: true
755
755
  });
756
756
 
@@ -883,17 +883,52 @@ function retryInterval(numberOfFailures) {
883
883
  var min = Math.min(Math.max(250, (numberOfFailures - 1) * 2000), 25000);
884
884
  return Math.floor(Math.random() * (max - min) + min);
885
885
  }
886
- /** adopted from https://github.com/ai/nanoid/blob/master/non-secure/index.js */
887
-
888
- var alphabet = 'ModuleSymbhasOwnPr0123456789ABCDEFGHNRVfgctiUvzKqYTJkLxpZXIjQW';
889
886
  function randomId() {
890
- var id = '';
887
+ return generateUUIDv4();
888
+ }
889
+
890
+ function hex(bytes) {
891
+ var s = '';
892
+
893
+ for (var i = 0; i < bytes.length; i++) {
894
+ s += bytes[i].toString(16).padStart(2, '0');
895
+ }
896
+
897
+ return s;
898
+ } // https://tools.ietf.org/html/rfc4122
899
+
900
+
901
+ function generateUUIDv4() {
902
+ var bytes = getRandomBytes(16);
903
+ bytes[6] = bytes[6] & 0x0f | 0x40; // version
904
+
905
+ bytes[8] = bytes[8] & 0xbf | 0x80; // variant
906
+
907
+ return hex(bytes.subarray(0, 4)) + '-' + hex(bytes.subarray(4, 6)) + '-' + hex(bytes.subarray(6, 8)) + '-' + hex(bytes.subarray(8, 10)) + '-' + hex(bytes.subarray(10, 16));
908
+ }
909
+
910
+ function getRandomValuesWithMathRandom(bytes) {
911
+ var max = Math.pow(2, 8 * bytes.byteLength / bytes.length);
912
+
913
+ for (var i = 0; i < bytes.length; i++) {
914
+ bytes[i] = Math.random() * max;
915
+ }
916
+ }
891
917
 
892
- for (var i = 0; i < 21; i++) {
893
- id += alphabet[Math.random() * 64 | 0];
918
+ var getRandomValues = function () {
919
+ if (typeof crypto !== 'undefined') {
920
+ return crypto.getRandomValues.bind(crypto);
921
+ } else if (typeof msCrypto !== 'undefined') {
922
+ return msCrypto.getRandomValues.bind(msCrypto);
923
+ } else {
924
+ return getRandomValuesWithMathRandom;
894
925
  }
926
+ }();
895
927
 
896
- return id;
928
+ function getRandomBytes(length) {
929
+ var bytes = new Uint8Array(length);
930
+ getRandomValues(bytes);
931
+ return bytes;
897
932
  }
898
933
 
899
934
  function _createForOfIteratorHelper$2(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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 = o[Symbol.iterator](); }, 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; } } }; }
@@ -902,9 +937,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
902
937
 
903
938
  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; }
904
939
 
905
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
940
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
906
941
 
907
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
942
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
908
943
 
909
944
  /**
910
945
  * Channel - The Channel class manages it's own state.
@@ -1024,7 +1059,7 @@ var Channel = /*#__PURE__*/function () {
1024
1059
 
1025
1060
  this.data = data; // this._data is used for the requests...
1026
1061
 
1027
- this._data = _objectSpread$2({}, data);
1062
+ this._data = _objectSpread$3({}, data);
1028
1063
  this.cid = "".concat(type, ":").concat(id);
1029
1064
  this.listeners = {}; // perhaps the state variable should be private
1030
1065
 
@@ -1066,7 +1101,8 @@ var Channel = /*#__PURE__*/function () {
1066
1101
  * sendMessage - Send a message to this channel
1067
1102
  *
1068
1103
  * @param {Message<AttachmentType, MessageType, UserType>} message The Message object
1069
- * @param {{ skip_push?: boolean }} [options] Option object, {skip_push: true} to skip sending push notifications
1104
+ * @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
1105
+ * @param {boolean} [options.skip_push] Skip sending push notifications
1070
1106
  *
1071
1107
  * @return {Promise<SendMessageAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The Server Response
1072
1108
  */
@@ -1081,7 +1117,7 @@ var Channel = /*#__PURE__*/function () {
1081
1117
  switch (_context2.prev = _context2.next) {
1082
1118
  case 0:
1083
1119
  _context2.next = 2;
1084
- return this.getClient().post(this._channelURL() + '/message', _objectSpread$2({
1120
+ return this.getClient().post(this._channelURL() + '/message', _objectSpread$3({
1085
1121
  message: message
1086
1122
  }, options));
1087
1123
 
@@ -1200,7 +1236,7 @@ var Channel = /*#__PURE__*/function () {
1200
1236
 
1201
1237
  case 3:
1202
1238
  // Return a list of channels
1203
- payload = _objectSpread$2(_objectSpread$2({
1239
+ payload = _objectSpread$3(_objectSpread$3({
1204
1240
  filter_conditions: {
1205
1241
  cid: this.cid
1206
1242
  }
@@ -1261,8 +1297,8 @@ var Channel = /*#__PURE__*/function () {
1261
1297
  * queryMembers - Query Members
1262
1298
  *
1263
1299
  * @param {UserFilters<UserType>} filterConditions object MongoDB style filters
1264
- * @param {UserSort<UserType>} [sort] Sort options, for instance [{created_at: -1}].
1265
- * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{last_active: -1}, {created_at: 1}]
1300
+ * @param {MemberSort<UserType>} [sort] Sort options, for instance [{created_at: -1}].
1301
+ * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{name: -1}, {created_at: 1}]
1266
1302
  * @param {{ limit?: number; offset?: number }} [options] Option object, {limit: 10, offset:10}
1267
1303
  *
1268
1304
  * @return {Promise<ChannelMemberAPIResponse<UserType>>} Query Members response
@@ -1297,7 +1333,7 @@ var Channel = /*#__PURE__*/function () {
1297
1333
 
1298
1334
  _context5.next = 6;
1299
1335
  return this.getClient().get(this.getClient().baseURL + '/members', {
1300
- payload: _objectSpread$2({
1336
+ payload: _objectSpread$3({
1301
1337
  type: type,
1302
1338
  id: id,
1303
1339
  members: members,
@@ -1358,7 +1394,7 @@ var Channel = /*#__PURE__*/function () {
1358
1394
 
1359
1395
  case 4:
1360
1396
  _context6.next = 6;
1361
- return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$2({
1397
+ return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$3({
1362
1398
  reaction: reaction
1363
1399
  }, options));
1364
1400
 
@@ -1439,7 +1475,7 @@ var Channel = /*#__PURE__*/function () {
1439
1475
  delete channelData[key];
1440
1476
  });
1441
1477
  _context7.next = 7;
1442
- return this._update(_objectSpread$2({
1478
+ return this._update(_objectSpread$3({
1443
1479
  message: updateMessage,
1444
1480
  data: channelData
1445
1481
  }, options));
@@ -1664,7 +1700,7 @@ var Channel = /*#__PURE__*/function () {
1664
1700
  case 0:
1665
1701
  options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
1666
1702
  _context13.next = 3;
1667
- return this._update(_objectSpread$2({
1703
+ return this._update(_objectSpread$3({
1668
1704
  accept_invite: true
1669
1705
  }, options));
1670
1706
 
@@ -1705,7 +1741,7 @@ var Channel = /*#__PURE__*/function () {
1705
1741
  case 0:
1706
1742
  options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
1707
1743
  _context14.next = 3;
1708
- return this._update(_objectSpread$2({
1744
+ return this._update(_objectSpread$3({
1709
1745
  reject_invite: true
1710
1746
  }, options));
1711
1747
 
@@ -2023,7 +2059,7 @@ var Channel = /*#__PURE__*/function () {
2023
2059
  case 0:
2024
2060
  opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
2025
2061
  _context22.next = 3;
2026
- return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$2({
2062
+ return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$3({
2027
2063
  channel_cid: this.cid
2028
2064
  }, opts));
2029
2065
 
@@ -2065,7 +2101,7 @@ var Channel = /*#__PURE__*/function () {
2065
2101
  case 0:
2066
2102
  opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
2067
2103
  _context23.next = 3;
2068
- return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$2({
2104
+ return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$3({
2069
2105
  channel_cid: this.cid
2070
2106
  }, opts));
2071
2107
 
@@ -2274,7 +2310,7 @@ var Channel = /*#__PURE__*/function () {
2274
2310
 
2275
2311
  case 4:
2276
2312
  _context26.next = 6;
2277
- return this.getClient().post(this._channelURL() + '/read', _objectSpread$2({}, data));
2313
+ return this.getClient().post(this._channelURL() + '/read', _objectSpread$3({}, data));
2278
2314
 
2279
2315
  case 6:
2280
2316
  return _context26.abrupt("return", _context26.sent);
@@ -2342,7 +2378,7 @@ var Channel = /*#__PURE__*/function () {
2342
2378
  defaultOptions.watch = false;
2343
2379
  }
2344
2380
 
2345
- combined = _objectSpread$2(_objectSpread$2({}, defaultOptions), options);
2381
+ combined = _objectSpread$3(_objectSpread$3({}, defaultOptions), options);
2346
2382
  _context27.next = 7;
2347
2383
  return this.query(combined);
2348
2384
 
@@ -2433,7 +2469,7 @@ var Channel = /*#__PURE__*/function () {
2433
2469
  switch (_context29.prev = _context29.next) {
2434
2470
  case 0:
2435
2471
  _context29.next = 2;
2436
- return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$2({}, options));
2472
+ return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$3({}, options));
2437
2473
 
2438
2474
  case 2:
2439
2475
  data = _context29.sent;
@@ -2471,7 +2507,7 @@ var Channel = /*#__PURE__*/function () {
2471
2507
  }, {
2472
2508
  key: "getReactions",
2473
2509
  value: function getReactions(message_id, options) {
2474
- return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$2({}, options));
2510
+ return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$3({}, options));
2475
2511
  }
2476
2512
  /**
2477
2513
  * getMessagesById - Retrieves a list of messages by ID
@@ -2514,6 +2550,7 @@ var Channel = /*#__PURE__*/function () {
2514
2550
  if (message.silent) return false;
2515
2551
  if (((_message$user = message.user) === null || _message$user === void 0 ? void 0 : _message$user.id) === this.getClient().userID) return false;
2516
2552
  if ((_message$user2 = message.user) !== null && _message$user2 !== void 0 && _message$user2.id && this.getClient().userMuteStatus(message.user.id)) return false;
2553
+ if (message.type === 'system') return false;
2517
2554
  if (this.muteStatus().muted) return false;
2518
2555
  return true;
2519
2556
  }
@@ -2602,7 +2639,7 @@ var Channel = /*#__PURE__*/function () {
2602
2639
  }
2603
2640
 
2604
2641
  _context30.next = 6;
2605
- return this.getClient().post(queryURL + '/query', _objectSpread$2({
2642
+ return this.getClient().post(queryURL + '/query', _objectSpread$3({
2606
2643
  data: this._data,
2607
2644
  state: true
2608
2645
  }, options));
@@ -2673,7 +2710,7 @@ var Channel = /*#__PURE__*/function () {
2673
2710
  this._checkInitialized();
2674
2711
 
2675
2712
  _context31.next = 3;
2676
- return this.getClient().banUser(targetUserID, _objectSpread$2(_objectSpread$2({}, options), {}, {
2713
+ return this.getClient().banUser(targetUserID, _objectSpread$3(_objectSpread$3({}, options), {}, {
2677
2714
  type: this.type,
2678
2715
  id: this.id
2679
2716
  }));
@@ -2845,7 +2882,7 @@ var Channel = /*#__PURE__*/function () {
2845
2882
  this._checkInitialized();
2846
2883
 
2847
2884
  _context35.next = 3;
2848
- return this.getClient().shadowBan(targetUserID, _objectSpread$2(_objectSpread$2({}, options), {}, {
2885
+ return this.getClient().shadowBan(targetUserID, _objectSpread$3(_objectSpread$3({}, options), {}, {
2849
2886
  type: this.type,
2850
2887
  id: this.id
2851
2888
  }));
@@ -3258,7 +3295,7 @@ var Channel = /*#__PURE__*/function () {
3258
3295
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3259
3296
  var read = _step3.value;
3260
3297
 
3261
- var parsedRead = _objectSpread$2(_objectSpread$2({}, read), {}, {
3298
+ var parsedRead = _objectSpread$3(_objectSpread$3({}, read), {}, {
3262
3299
  last_read: new Date(read.last_read)
3263
3300
  });
3264
3301
 
@@ -3385,6 +3422,61 @@ var ClientState = /*#__PURE__*/function () {
3385
3422
  return ClientState;
3386
3423
  }();
3387
3424
 
3425
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
3426
+
3427
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
3428
+
3429
+ var InsightMetrics = function InsightMetrics() {
3430
+ _classCallCheck(this, InsightMetrics);
3431
+
3432
+ _defineProperty(this, "connectionStartTimestamp", void 0);
3433
+
3434
+ _defineProperty(this, "wsConsecutiveFailures", void 0);
3435
+
3436
+ _defineProperty(this, "wsTotalFailures", void 0);
3437
+
3438
+ this.connectionStartTimestamp = null;
3439
+ this.wsTotalFailures = 0;
3440
+ this.wsConsecutiveFailures = 0;
3441
+ };
3442
+ function buildWsFatalInsight(connection, event) {
3443
+ return _objectSpread$2({
3444
+ err: {
3445
+ wasClean: event.wasClean,
3446
+ code: event.code,
3447
+ reason: event.reason
3448
+ }
3449
+ }, buildWsBaseInsight(connection));
3450
+ }
3451
+
3452
+ function buildWsBaseInsight(connection) {
3453
+ var _connection$ws, _navigator, _navigator2;
3454
+
3455
+ return {
3456
+ ready_state: (_connection$ws = connection.ws) === null || _connection$ws === void 0 ? void 0 : _connection$ws.readyState,
3457
+ url: connection._buildUrl(connection.requestID),
3458
+ api_key: connection.apiKey,
3459
+ start_ts: connection.insightMetrics.connectionStartTimestamp,
3460
+ end_ts: new Date().getTime(),
3461
+ auth_type: connection.authType,
3462
+ token: connection.tokenManager.token,
3463
+ user_id: connection.userID,
3464
+ user_details: connection.user,
3465
+ device: connection.device,
3466
+ client_id: connection.connectionID,
3467
+ ws_details: connection.ws,
3468
+ ws_consecutive_failures: connection.insightMetrics.wsConsecutiveFailures,
3469
+ ws_total_failures: connection.insightMetrics.wsTotalFailures,
3470
+ request_id: connection.requestID,
3471
+ online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
3472
+ user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null
3473
+ };
3474
+ }
3475
+
3476
+ function buildWsSuccessAfterFailureInsight(connection) {
3477
+ return buildWsBaseInsight(connection);
3478
+ }
3479
+
3388
3480
  // Type guards to check WebSocket error type
3389
3481
  var isCloseEvent = function isCloseEvent(res) {
3390
3482
  return res.code !== undefined;
@@ -3427,7 +3519,9 @@ var StableWSConnection = /*#__PURE__*/function () {
3427
3519
  userAgent = _ref.userAgent,
3428
3520
  userID = _ref.userID,
3429
3521
  wsBaseURL = _ref.wsBaseURL,
3430
- device = _ref.device;
3522
+ device = _ref.device,
3523
+ postInsights = _ref.postInsights,
3524
+ insightMetrics = _ref.insightMetrics;
3431
3525
 
3432
3526
  _classCallCheck(this, StableWSConnection);
3433
3527
 
@@ -3481,6 +3575,10 @@ var StableWSConnection = /*#__PURE__*/function () {
3481
3575
 
3482
3576
  _defineProperty(this, "rejectPromise", void 0);
3483
3577
 
3578
+ _defineProperty(this, "requestID", void 0);
3579
+
3580
+ _defineProperty(this, "connectionStartTimestamp", void 0);
3581
+
3484
3582
  _defineProperty(this, "resolvePromise", void 0);
3485
3583
 
3486
3584
  _defineProperty(this, "totalFailures", void 0);
@@ -3489,13 +3587,18 @@ var StableWSConnection = /*#__PURE__*/function () {
3489
3587
 
3490
3588
  _defineProperty(this, "wsID", void 0);
3491
3589
 
3492
- _defineProperty(this, "_buildUrl", function () {
3590
+ _defineProperty(this, "postInsights", void 0);
3591
+
3592
+ _defineProperty(this, "insightMetrics", void 0);
3593
+
3594
+ _defineProperty(this, "_buildUrl", function (reqID) {
3493
3595
  var params = {
3494
3596
  user_id: _this.user.id,
3495
3597
  user_details: _this.user,
3496
3598
  user_token: _this.tokenManager.getToken(),
3497
3599
  server_determines_connection_id: true,
3498
- device: _this.device
3600
+ device: _this.device,
3601
+ request_id: reqID
3499
3602
  };
3500
3603
  var qs = encodeURIComponent(JSON.stringify(params));
3501
3604
 
@@ -3545,6 +3648,8 @@ var StableWSConnection = /*#__PURE__*/function () {
3545
3648
  // after that a ws.onclose..
3546
3649
 
3547
3650
  if (!_this.isResolved && data) {
3651
+ _this.isResolved = true;
3652
+
3548
3653
  if (data.error != null) {
3549
3654
  var _this$rejectPromise;
3550
3655
 
@@ -3553,7 +3658,7 @@ var StableWSConnection = /*#__PURE__*/function () {
3553
3658
  } else {
3554
3659
  var _this$resolvePromise;
3555
3660
 
3556
- (_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, event); // set healthy..
3661
+ (_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, event);
3557
3662
 
3558
3663
  _this._setHealth(true);
3559
3664
  }
@@ -3578,6 +3683,14 @@ var StableWSConnection = /*#__PURE__*/function () {
3578
3683
  });
3579
3684
 
3580
3685
  _defineProperty(this, "onclose", function (wsID, event) {
3686
+ if (event.code !== chatCodes.WS_CLOSED_SUCCESS) {
3687
+ var _this$postInsights;
3688
+
3689
+ _this.insightMetrics.wsConsecutiveFailures++;
3690
+ _this.insightMetrics.wsTotalFailures++;
3691
+ (_this$postInsights = _this.postInsights) === null || _this$postInsights === void 0 ? void 0 : _this$postInsights.call(_this, 'ws_fatal', buildWsFatalInsight(_this, event));
3692
+ }
3693
+
3581
3694
  _this.logger('info', 'connection:onclose() - onclose callback - ' + event.code, {
3582
3695
  tags: ['connection'],
3583
3696
  event: event,
@@ -3607,6 +3720,7 @@ var StableWSConnection = /*#__PURE__*/function () {
3607
3720
 
3608
3721
  _this._setHealth(false);
3609
3722
 
3723
+ _this.isConnecting = false;
3610
3724
  (_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
3611
3725
 
3612
3726
  _this.logger('info', "connection:onclose() - WS connection closed. Calling reconnect ...", {
@@ -3628,6 +3742,7 @@ var StableWSConnection = /*#__PURE__*/function () {
3628
3742
 
3629
3743
  _this._setHealth(false);
3630
3744
 
3745
+ _this.isConnecting = false;
3631
3746
  (_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
3632
3747
 
3633
3748
  _this.logger('info', "connection:onerror() - WS connection resulted into error", {
@@ -3700,14 +3815,22 @@ var StableWSConnection = /*#__PURE__*/function () {
3700
3815
  });
3701
3816
 
3702
3817
  _defineProperty(this, "_listenForConnectionChanges", function () {
3703
- if (typeof window !== 'undefined' && window != null && window.addEventListener != null) {
3818
+ var _window;
3819
+
3820
+ // (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
3821
+ // and thus (window === undefined) will result in ReferenceError.
3822
+ if (typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.addEventListener) {
3704
3823
  window.addEventListener('offline', _this.onlineStatusChanged);
3705
3824
  window.addEventListener('online', _this.onlineStatusChanged);
3706
3825
  }
3707
3826
  });
3708
3827
 
3709
3828
  _defineProperty(this, "_removeConnectionListeners", function () {
3710
- if (typeof window !== 'undefined' && window != null && window.addEventListener != null) {
3829
+ var _window2;
3830
+
3831
+ // (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
3832
+ // and thus (window === undefined) will result in ReferenceError.
3833
+ if (typeof window !== 'undefined' && (_window2 = window) !== null && _window2 !== void 0 && _window2.removeEventListener) {
3711
3834
  window.removeEventListener('offline', _this.onlineStatusChanged);
3712
3835
  window.removeEventListener('online', _this.onlineStatusChanged);
3713
3836
  }
@@ -3748,8 +3871,7 @@ var StableWSConnection = /*#__PURE__*/function () {
3748
3871
  // send the healthcheck.., server replies with a health check event
3749
3872
  var data = [{
3750
3873
  type: 'health.check',
3751
- client_id: _this.clientID,
3752
- user_id: _this.userID
3874
+ client_id: _this.clientID
3753
3875
  }]; // try to send on the connection
3754
3876
 
3755
3877
  try {
@@ -3799,6 +3921,9 @@ var StableWSConnection = /*#__PURE__*/function () {
3799
3921
  /** We only make 1 attempt to reconnect at the same time.. */
3800
3922
 
3801
3923
  this.isConnecting = false;
3924
+ /** Boolean that indicates if the connection promise is resolved */
3925
+
3926
+ this.isResolved = false;
3802
3927
  /** Boolean that indicates if we have a working connection to the server */
3803
3928
 
3804
3929
  this.isHealthy = false;
@@ -3820,6 +3945,9 @@ var StableWSConnection = /*#__PURE__*/function () {
3820
3945
  this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
3821
3946
 
3822
3947
  this._listenForConnectionChanges();
3948
+
3949
+ this.postInsights = postInsights;
3950
+ this.insightMetrics = insightMetrics;
3823
3951
  }
3824
3952
  /**
3825
3953
  * connect - Connect to the WS URL
@@ -3851,23 +3979,21 @@ var StableWSConnection = /*#__PURE__*/function () {
3851
3979
 
3852
3980
  case 5:
3853
3981
  healthCheck = _context.sent;
3854
- this.isConnecting = false;
3855
3982
  this.consecutiveFailures = 0;
3856
3983
  this.logger('info', "connection:connect() - Established ws connection with healthcheck: ".concat(healthCheck), {
3857
3984
  tags: ['connection']
3858
3985
  });
3859
- _context.next = 23;
3986
+ _context.next = 21;
3860
3987
  break;
3861
3988
 
3862
- case 11:
3863
- _context.prev = 11;
3989
+ case 10:
3990
+ _context.prev = 10;
3864
3991
  _context.t0 = _context["catch"](2);
3865
- this.isConnecting = false;
3866
3992
  this.isHealthy = false;
3867
3993
  this.consecutiveFailures += 1;
3868
3994
 
3869
3995
  if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
3870
- _context.next = 21;
3996
+ _context.next = 19;
3871
3997
  break;
3872
3998
  }
3873
3999
 
@@ -3879,12 +4005,12 @@ var StableWSConnection = /*#__PURE__*/function () {
3879
4005
  refreshToken: true
3880
4006
  });
3881
4007
 
3882
- _context.next = 23;
4008
+ _context.next = 21;
3883
4009
  break;
3884
4010
 
3885
- case 21:
4011
+ case 19:
3886
4012
  if (_context.t0.isWSFailure) {
3887
- _context.next = 23;
4013
+ _context.next = 21;
3888
4014
  break;
3889
4015
  }
3890
4016
 
@@ -3895,19 +4021,19 @@ var StableWSConnection = /*#__PURE__*/function () {
3895
4021
  isWSFailure: _context.t0.isWSFailure
3896
4022
  }));
3897
4023
 
3898
- case 23:
3899
- _context.next = 25;
4024
+ case 21:
4025
+ _context.next = 23;
3900
4026
  return this._waitForHealthy();
3901
4027
 
3902
- case 25:
4028
+ case 23:
3903
4029
  return _context.abrupt("return", _context.sent);
3904
4030
 
3905
- case 26:
4031
+ case 24:
3906
4032
  case "end":
3907
4033
  return _context.stop();
3908
4034
  }
3909
4035
  }
3910
- }, _callee, this, [[2, 11]]);
4036
+ }, _callee, this, [[2, 10]]);
3911
4037
  }));
3912
4038
 
3913
4039
  function connect() {
@@ -4027,6 +4153,12 @@ var StableWSConnection = /*#__PURE__*/function () {
4027
4153
 
4028
4154
  return _waitForHealthy;
4029
4155
  }()
4156
+ /**
4157
+ * Builds and returns the url for websocket.
4158
+ * @param reqID Unique identifier generated on client side, to help tracking apis on backend.
4159
+ * @returns url string
4160
+ */
4161
+
4030
4162
  }, {
4031
4163
  key: "disconnect",
4032
4164
  value:
@@ -4104,46 +4236,74 @@ var StableWSConnection = /*#__PURE__*/function () {
4104
4236
  key: "_connect",
4105
4237
  value: function () {
4106
4238
  var _connect3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
4107
- var wsURL, response;
4239
+ var wsURL, response, _this$postInsights2;
4240
+
4108
4241
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
4109
4242
  while (1) {
4110
4243
  switch (_context5.prev = _context5.next) {
4111
4244
  case 0:
4112
- _context5.next = 2;
4113
- return this.tokenManager.tokenReady();
4245
+ if (!this.isConnecting) {
4246
+ _context5.next = 2;
4247
+ break;
4248
+ }
4249
+
4250
+ return _context5.abrupt("return");
4114
4251
 
4115
4252
  case 2:
4253
+ // simply ignore _connect if it's currently trying to connect
4254
+ this.isConnecting = true;
4255
+ this.requestID = randomId();
4256
+ this.insightMetrics.connectionStartTimestamp = new Date().getTime();
4257
+ _context5.prev = 5;
4258
+ _context5.next = 8;
4259
+ return this.tokenManager.tokenReady();
4260
+
4261
+ case 8:
4116
4262
  this._setupConnectionPromise();
4117
4263
 
4118
- wsURL = this._buildUrl();
4264
+ wsURL = this._buildUrl(this.requestID);
4119
4265
  this.ws = new WebSocket(wsURL);
4120
4266
  this.ws.onopen = this.onopen.bind(this, this.wsID);
4121
4267
  this.ws.onclose = this.onclose.bind(this, this.wsID);
4122
4268
  this.ws.onerror = this.onerror.bind(this, this.wsID);
4123
4269
  this.ws.onmessage = this.onmessage.bind(this, this.wsID);
4124
- _context5.next = 11;
4270
+ _context5.next = 17;
4125
4271
  return this.connectionOpen;
4126
4272
 
4127
- case 11:
4273
+ case 17:
4128
4274
  response = _context5.sent;
4275
+ this.isConnecting = false;
4129
4276
 
4130
4277
  if (!response) {
4131
- _context5.next = 15;
4278
+ _context5.next = 23;
4132
4279
  break;
4133
4280
  }
4134
4281
 
4135
4282
  this.connectionID = response.connection_id;
4283
+
4284
+ if (this.insightMetrics.wsConsecutiveFailures > 0) {
4285
+ (_this$postInsights2 = this.postInsights) === null || _this$postInsights2 === void 0 ? void 0 : _this$postInsights2.call(this, 'ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
4286
+ this.insightMetrics.wsConsecutiveFailures = 0;
4287
+ }
4288
+
4136
4289
  return _context5.abrupt("return", response);
4137
4290
 
4138
- case 15:
4139
- return _context5.abrupt("return", undefined);
4291
+ case 23:
4292
+ _context5.next = 29;
4293
+ break;
4140
4294
 
4141
- case 16:
4295
+ case 25:
4296
+ _context5.prev = 25;
4297
+ _context5.t0 = _context5["catch"](5);
4298
+ this.isConnecting = false;
4299
+ throw _context5.t0;
4300
+
4301
+ case 29:
4142
4302
  case "end":
4143
4303
  return _context5.stop();
4144
4304
  }
4145
4305
  }
4146
- }, _callee5, this);
4306
+ }, _callee5, this, [[5, 25]]);
4147
4307
  }));
4148
4308
 
4149
4309
  function _connect() {
@@ -4214,8 +4374,7 @@ var StableWSConnection = /*#__PURE__*/function () {
4214
4374
  return _context6.abrupt("return");
4215
4375
 
4216
4376
  case 12:
4217
- this.isConnecting = true; // cleanup the old connection
4218
-
4377
+ // cleanup the old connection
4219
4378
  this.logger('info', 'connection:_reconnect() - Destroying current WS connection', {
4220
4379
  tags: ['connection']
4221
4380
  });
@@ -4223,52 +4382,50 @@ var StableWSConnection = /*#__PURE__*/function () {
4223
4382
  this._destroyCurrentWSConnection();
4224
4383
 
4225
4384
  if (!options.refreshToken) {
4226
- _context6.next = 18;
4385
+ _context6.next = 17;
4227
4386
  break;
4228
4387
  }
4229
4388
 
4230
- _context6.next = 18;
4389
+ _context6.next = 17;
4231
4390
  return this.tokenManager.loadToken();
4232
4391
 
4233
- case 18:
4234
- _context6.prev = 18;
4235
- _context6.next = 21;
4392
+ case 17:
4393
+ _context6.prev = 17;
4394
+ _context6.next = 20;
4236
4395
  return this._connect();
4237
4396
 
4238
- case 21:
4397
+ case 20:
4239
4398
  _open = _context6.sent;
4240
4399
 
4241
4400
  if (!this.recoverCallback) {
4242
- _context6.next = 27;
4401
+ _context6.next = 26;
4243
4402
  break;
4244
4403
  }
4245
4404
 
4246
4405
  this.logger('info', 'connection:_reconnect() - Waiting for recoverCallBack', {
4247
4406
  tags: ['connection']
4248
4407
  });
4249
- _context6.next = 26;
4408
+ _context6.next = 25;
4250
4409
  return this.recoverCallback(_open);
4251
4410
 
4252
- case 26:
4411
+ case 25:
4253
4412
  this.logger('info', 'connection:_reconnect() - Finished recoverCallBack', {
4254
4413
  tags: ['connection']
4255
4414
  });
4256
4415
 
4257
- case 27:
4258
- this.isConnecting = false;
4416
+ case 26:
4259
4417
  this.consecutiveFailures = 0;
4260
- _context6.next = 40;
4418
+ _context6.next = 37;
4261
4419
  break;
4262
4420
 
4263
- case 31:
4264
- _context6.prev = 31;
4265
- _context6.t0 = _context6["catch"](18);
4266
- this.isConnecting = false;
4421
+ case 29:
4422
+ _context6.prev = 29;
4423
+ _context6.t0 = _context6["catch"](17);
4267
4424
  this.isHealthy = false;
4268
4425
  this.consecutiveFailures += 1;
4269
4426
 
4270
4427
  if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
4271
- _context6.next = 39;
4428
+ _context6.next = 36;
4272
4429
  break;
4273
4430
  }
4274
4431
 
@@ -4279,7 +4436,7 @@ var StableWSConnection = /*#__PURE__*/function () {
4279
4436
  refreshToken: true
4280
4437
  }));
4281
4438
 
4282
- case 39:
4439
+ case 36:
4283
4440
  // reconnect on WS failures, don't reconnect if there is a code bug
4284
4441
  if (_context6.t0.isWSFailure) {
4285
4442
  this.logger('info', 'connection:_reconnect() - WS failure, so going to try to reconnect', {
@@ -4289,17 +4446,17 @@ var StableWSConnection = /*#__PURE__*/function () {
4289
4446
  this._reconnect();
4290
4447
  }
4291
4448
 
4292
- case 40:
4449
+ case 37:
4293
4450
  this.logger('info', 'connection:_reconnect() - == END ==', {
4294
4451
  tags: ['connection']
4295
4452
  });
4296
4453
 
4297
- case 41:
4454
+ case 38:
4298
4455
  case "end":
4299
4456
  return _context6.stop();
4300
4457
  }
4301
4458
  }
4302
- }, _callee6, this, [[18, 31]]);
4459
+ }, _callee6, this, [[17, 29]]);
4303
4460
  }));
4304
4461
 
4305
4462
  function _reconnect() {
@@ -4438,7 +4595,7 @@ function DevToken(userId) {
4438
4595
 
4439
4596
  function CheckSignature(body, secret, signature) {
4440
4597
  var key = Buffer.from(secret, 'ascii');
4441
- var hash = crypto.createHmac('sha256', key).update(body).digest('hex');
4598
+ var hash = crypto$1.createHmac('sha256', key).update(body).digest('hex');
4442
4599
  return hash === signature;
4443
4600
  }
4444
4601
 
@@ -4666,8 +4823,6 @@ var StreamChat = /*#__PURE__*/function () {
4666
4823
 
4667
4824
  _defineProperty(this, "configs", void 0);
4668
4825
 
4669
- _defineProperty(this, "connecting", void 0);
4670
-
4671
4826
  _defineProperty(this, "connectionID", void 0);
4672
4827
 
4673
4828
  _defineProperty(this, "failures", void 0);
@@ -4710,6 +4865,8 @@ var StreamChat = /*#__PURE__*/function () {
4710
4865
 
4711
4866
  _defineProperty(this, "consecutiveFailures", void 0);
4712
4867
 
4868
+ _defineProperty(this, "insightMetrics", void 0);
4869
+
4713
4870
  _defineProperty(this, "_hasConnectionID", function () {
4714
4871
  var _this$wsConnection;
4715
4872
 
@@ -5356,10 +5513,73 @@ var StreamChat = /*#__PURE__*/function () {
5356
5513
 
5357
5514
  _defineProperty(this, "updateUser", this.upsertUser);
5358
5515
 
5516
+ _defineProperty(this, "markAllRead", this.markChannelsRead);
5517
+
5359
5518
  _defineProperty(this, "_isUsingServerAuth", function () {
5360
5519
  return !!_this.secret;
5361
5520
  });
5362
5521
 
5522
+ _defineProperty(this, "postInsights", /*#__PURE__*/function () {
5523
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(insightType, insights) {
5524
+ var maxAttempts, i;
5525
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
5526
+ while (1) {
5527
+ switch (_context6.prev = _context6.next) {
5528
+ case 0:
5529
+ maxAttempts = 3;
5530
+ i = 0;
5531
+
5532
+ case 2:
5533
+ if (!(i < maxAttempts)) {
5534
+ _context6.next = 18;
5535
+ break;
5536
+ }
5537
+
5538
+ _context6.prev = 3;
5539
+ _context6.next = 6;
5540
+ return _this.axiosInstance.post("https://insights.stream-io-api.com/insights/".concat(insightType), insights);
5541
+
5542
+ case 6:
5543
+ _context6.next = 14;
5544
+ break;
5545
+
5546
+ case 8:
5547
+ _context6.prev = 8;
5548
+ _context6.t0 = _context6["catch"](3);
5549
+
5550
+ _this.logger('warn', "failed to send insights event ".concat(insightType), {
5551
+ tags: ['insights', 'connection'],
5552
+ error: _context6.t0,
5553
+ insights: insights
5554
+ });
5555
+
5556
+ _context6.next = 13;
5557
+ return sleep((i + 1) * 3000);
5558
+
5559
+ case 13:
5560
+ return _context6.abrupt("continue", 15);
5561
+
5562
+ case 14:
5563
+ return _context6.abrupt("break", 18);
5564
+
5565
+ case 15:
5566
+ i++;
5567
+ _context6.next = 2;
5568
+ break;
5569
+
5570
+ case 18:
5571
+ case "end":
5572
+ return _context6.stop();
5573
+ }
5574
+ }
5575
+ }, _callee6, null, [[3, 8]]);
5576
+ }));
5577
+
5578
+ return function (_x7, _x8) {
5579
+ return _ref6.apply(this, arguments);
5580
+ };
5581
+ }());
5582
+
5363
5583
  // set the key
5364
5584
  this.key = _key;
5365
5585
  this.listeners = {};
@@ -5415,6 +5635,7 @@ var StreamChat = /*#__PURE__*/function () {
5415
5635
 
5416
5636
  this.tokenManager = new TokenManager(this.secret);
5417
5637
  this.consecutiveFailures = 0;
5638
+ this.insightMetrics = new InsightMetrics();
5418
5639
  /**
5419
5640
  * logger function should accept 3 parameters:
5420
5641
  * @param logLevel string
@@ -5563,32 +5784,32 @@ var StreamChat = /*#__PURE__*/function () {
5563
5784
  }
5564
5785
  */
5565
5786
  function () {
5566
- var _updateAppSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
5787
+ var _updateAppSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(options) {
5567
5788
  var _options$apn_config;
5568
5789
 
5569
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
5790
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
5570
5791
  while (1) {
5571
- switch (_context6.prev = _context6.next) {
5792
+ switch (_context7.prev = _context7.next) {
5572
5793
  case 0:
5573
5794
  if ((_options$apn_config = options.apn_config) !== null && _options$apn_config !== void 0 && _options$apn_config.p12_cert) {
5574
5795
  options.apn_config.p12_cert = Buffer.from(options.apn_config.p12_cert).toString('base64');
5575
5796
  }
5576
5797
 
5577
- _context6.next = 3;
5798
+ _context7.next = 3;
5578
5799
  return this.patch(this.baseURL + '/app', options);
5579
5800
 
5580
5801
  case 3:
5581
- return _context6.abrupt("return", _context6.sent);
5802
+ return _context7.abrupt("return", _context7.sent);
5582
5803
 
5583
5804
  case 4:
5584
5805
  case "end":
5585
- return _context6.stop();
5806
+ return _context7.stop();
5586
5807
  }
5587
5808
  }
5588
- }, _callee6, this);
5809
+ }, _callee7, this);
5589
5810
  }));
5590
5811
 
5591
- function updateAppSettings(_x7) {
5812
+ function updateAppSettings(_x9) {
5592
5813
  return _updateAppSettings.apply(this, arguments);
5593
5814
  }
5594
5815
 
@@ -5601,28 +5822,28 @@ var StreamChat = /*#__PURE__*/function () {
5601
5822
  * Revokes all tokens on application level issued before given time
5602
5823
  */
5603
5824
  function () {
5604
- var _revokeTokens = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(before) {
5605
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
5825
+ var _revokeTokens = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(before) {
5826
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
5606
5827
  while (1) {
5607
- switch (_context7.prev = _context7.next) {
5828
+ switch (_context8.prev = _context8.next) {
5608
5829
  case 0:
5609
- _context7.next = 2;
5830
+ _context8.next = 2;
5610
5831
  return this.updateAppSettings({
5611
5832
  revoke_tokens_issued_before: this._normalizeDate(before)
5612
5833
  });
5613
5834
 
5614
5835
  case 2:
5615
- return _context7.abrupt("return", _context7.sent);
5836
+ return _context8.abrupt("return", _context8.sent);
5616
5837
 
5617
5838
  case 3:
5618
5839
  case "end":
5619
- return _context7.stop();
5840
+ return _context8.stop();
5620
5841
  }
5621
5842
  }
5622
- }, _callee7, this);
5843
+ }, _callee8, this);
5623
5844
  }));
5624
5845
 
5625
- function revokeTokens(_x8) {
5846
+ function revokeTokens(_x10) {
5626
5847
  return _revokeTokens.apply(this, arguments);
5627
5848
  }
5628
5849
 
@@ -5635,26 +5856,26 @@ var StreamChat = /*#__PURE__*/function () {
5635
5856
  }, {
5636
5857
  key: "revokeUserToken",
5637
5858
  value: function () {
5638
- var _revokeUserToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(userID, before) {
5639
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
5859
+ var _revokeUserToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(userID, before) {
5860
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
5640
5861
  while (1) {
5641
- switch (_context8.prev = _context8.next) {
5862
+ switch (_context9.prev = _context9.next) {
5642
5863
  case 0:
5643
- _context8.next = 2;
5864
+ _context9.next = 2;
5644
5865
  return this.revokeUsersToken([userID], before);
5645
5866
 
5646
5867
  case 2:
5647
- return _context8.abrupt("return", _context8.sent);
5868
+ return _context9.abrupt("return", _context9.sent);
5648
5869
 
5649
5870
  case 3:
5650
5871
  case "end":
5651
- return _context8.stop();
5872
+ return _context9.stop();
5652
5873
  }
5653
5874
  }
5654
- }, _callee8, this);
5875
+ }, _callee9, this);
5655
5876
  }));
5656
5877
 
5657
- function revokeUserToken(_x9, _x10) {
5878
+ function revokeUserToken(_x11, _x12) {
5658
5879
  return _revokeUserToken.apply(this, arguments);
5659
5880
  }
5660
5881
 
@@ -5667,12 +5888,12 @@ var StreamChat = /*#__PURE__*/function () {
5667
5888
  }, {
5668
5889
  key: "revokeUsersToken",
5669
5890
  value: function () {
5670
- var _revokeUsersToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(userIDs, before) {
5891
+ var _revokeUsersToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(userIDs, before) {
5671
5892
  var users, _iterator, _step, userID;
5672
5893
 
5673
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
5894
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
5674
5895
  while (1) {
5675
- switch (_context9.prev = _context9.next) {
5896
+ switch (_context10.prev = _context10.next) {
5676
5897
  case 0:
5677
5898
  if (before === undefined) {
5678
5899
  before = new Date().toISOString();
@@ -5699,21 +5920,21 @@ var StreamChat = /*#__PURE__*/function () {
5699
5920
  _iterator.f();
5700
5921
  }
5701
5922
 
5702
- _context9.next = 6;
5923
+ _context10.next = 6;
5703
5924
  return this.partialUpdateUsers(users);
5704
5925
 
5705
5926
  case 6:
5706
- return _context9.abrupt("return", _context9.sent);
5927
+ return _context10.abrupt("return", _context10.sent);
5707
5928
 
5708
5929
  case 7:
5709
5930
  case "end":
5710
- return _context9.stop();
5931
+ return _context10.stop();
5711
5932
  }
5712
5933
  }
5713
- }, _callee9, this);
5934
+ }, _callee10, this);
5714
5935
  }));
5715
5936
 
5716
- function revokeUsersToken(_x11, _x12) {
5937
+ function revokeUsersToken(_x13, _x14) {
5717
5938
  return _revokeUsersToken.apply(this, arguments);
5718
5939
  }
5719
5940
 
@@ -5726,23 +5947,23 @@ var StreamChat = /*#__PURE__*/function () {
5726
5947
  }, {
5727
5948
  key: "getAppSettings",
5728
5949
  value: function () {
5729
- var _getAppSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
5730
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
5950
+ var _getAppSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
5951
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
5731
5952
  while (1) {
5732
- switch (_context10.prev = _context10.next) {
5953
+ switch (_context11.prev = _context11.next) {
5733
5954
  case 0:
5734
- _context10.next = 2;
5955
+ _context11.next = 2;
5735
5956
  return this.get(this.baseURL + '/app');
5736
5957
 
5737
5958
  case 2:
5738
- return _context10.abrupt("return", _context10.sent);
5959
+ return _context11.abrupt("return", _context11.sent);
5739
5960
 
5740
5961
  case 3:
5741
5962
  case "end":
5742
- return _context10.stop();
5963
+ return _context11.stop();
5743
5964
  }
5744
5965
  }
5745
- }, _callee10, this);
5966
+ }, _callee11, this);
5746
5967
  }));
5747
5968
 
5748
5969
  function getAppSettings() {
@@ -5761,6 +5982,7 @@ var StreamChat = /*#__PURE__*/function () {
5761
5982
  apnTemplate: '{}', //if app doesn't have apn configured it will error
5762
5983
  firebaseTemplate: '{}', //if app doesn't have firebase configured it will error
5763
5984
  firebaseDataTemplate: '{}', //if app doesn't have firebase configured it will error
5985
+ huaweiDataTemplate: '{}' //if app doesn't have huawei configured it will error
5764
5986
  skipDevices: true, // skip config/device checks and sending to real devices
5765
5987
  }
5766
5988
  */
@@ -5768,16 +5990,16 @@ var StreamChat = /*#__PURE__*/function () {
5768
5990
  }, {
5769
5991
  key: "testPushSettings",
5770
5992
  value: function () {
5771
- var _testPushSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(userID) {
5993
+ var _testPushSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(userID) {
5772
5994
  var data,
5773
- _args11 = arguments;
5774
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
5995
+ _args12 = arguments;
5996
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
5775
5997
  while (1) {
5776
- switch (_context11.prev = _context11.next) {
5998
+ switch (_context12.prev = _context12.next) {
5777
5999
  case 0:
5778
- data = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
5779
- _context11.next = 3;
5780
- return this.post(this.baseURL + '/check_push', _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
6000
+ data = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
6001
+ _context12.next = 3;
6002
+ return this.post(this.baseURL + '/check_push', _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
5781
6003
  user_id: userID
5782
6004
  }, data.messageID ? {
5783
6005
  message_id: data.messageID
@@ -5787,22 +6009,24 @@ var StreamChat = /*#__PURE__*/function () {
5787
6009
  firebase_template: data.firebaseTemplate
5788
6010
  } : {}), data.firebaseDataTemplate ? {
5789
6011
  firebase_data_template: data.firebaseDataTemplate
6012
+ } : {}), data.huaweiDataTemplate ? {
6013
+ huawei_data_template: data.huaweiDataTemplate
5790
6014
  } : {}), data.skipDevices ? {
5791
6015
  skip_devices: true
5792
6016
  } : {}));
5793
6017
 
5794
6018
  case 3:
5795
- return _context11.abrupt("return", _context11.sent);
6019
+ return _context12.abrupt("return", _context12.sent);
5796
6020
 
5797
6021
  case 4:
5798
6022
  case "end":
5799
- return _context11.stop();
6023
+ return _context12.stop();
5800
6024
  }
5801
6025
  }
5802
- }, _callee11, this);
6026
+ }, _callee12, this);
5803
6027
  }));
5804
6028
 
5805
- function testPushSettings(_x13) {
6029
+ function testPushSettings(_x15) {
5806
6030
  return _testPushSettings.apply(this, arguments);
5807
6031
  }
5808
6032
 
@@ -5811,39 +6035,37 @@ var StreamChat = /*#__PURE__*/function () {
5811
6035
  /**
5812
6036
  * testSQSSettings - Tests that the given or configured SQS configuration is valid
5813
6037
  *
5814
- * @param {string} userID User ID. If user has no devices, it will error
5815
- * @param {TestPushDataInput} [data] Overrides for push templates/message used
6038
+ * @param {TestSQSDataInput} [data] Overrides SQS settings for testing if needed
5816
6039
  * IE: {
5817
- messageID: 'id-of-message',//will error if message does not exist
5818
- apnTemplate: '{}', //if app doesn't have apn configured it will error
5819
- firebaseTemplate: '{}', //if app doesn't have firebase configured it will error
5820
- firebaseDataTemplate: '{}', //if app doesn't have firebase configured it will error
6040
+ sqs_key: 'auth_key',
6041
+ sqs_secret: 'auth_secret',
6042
+ sqs_url: 'url_to_queue',
5821
6043
  }
5822
6044
  */
5823
6045
 
5824
6046
  }, {
5825
6047
  key: "testSQSSettings",
5826
6048
  value: function () {
5827
- var _testSQSSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
6049
+ var _testSQSSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
5828
6050
  var data,
5829
- _args12 = arguments;
5830
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
6051
+ _args13 = arguments;
6052
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
5831
6053
  while (1) {
5832
- switch (_context12.prev = _context12.next) {
6054
+ switch (_context13.prev = _context13.next) {
5833
6055
  case 0:
5834
- data = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
5835
- _context12.next = 3;
6056
+ data = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
6057
+ _context13.next = 3;
5836
6058
  return this.post(this.baseURL + '/check_sqs', data);
5837
6059
 
5838
6060
  case 3:
5839
- return _context12.abrupt("return", _context12.sent);
6061
+ return _context13.abrupt("return", _context13.sent);
5840
6062
 
5841
6063
  case 4:
5842
6064
  case "end":
5843
- return _context12.stop();
6065
+ return _context13.stop();
5844
6066
  }
5845
6067
  }
5846
- }, _callee12, this);
6068
+ }, _callee13, this);
5847
6069
  }));
5848
6070
 
5849
6071
  function testSQSSettings() {
@@ -5870,50 +6092,50 @@ var StreamChat = /*#__PURE__*/function () {
5870
6092
  * @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Returns a promise that resolves when the connection is setup
5871
6093
  */
5872
6094
  function () {
5873
- var _setGuestUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(user) {
6095
+ var _setGuestUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(user) {
5874
6096
  var response, _response$user, guestUser;
5875
6097
 
5876
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
6098
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
5877
6099
  while (1) {
5878
- switch (_context13.prev = _context13.next) {
6100
+ switch (_context14.prev = _context14.next) {
5879
6101
  case 0:
5880
6102
  this.anonymous = true;
5881
- _context13.prev = 1;
5882
- _context13.next = 4;
6103
+ _context14.prev = 1;
6104
+ _context14.next = 4;
5883
6105
  return this.post(this.baseURL + '/guest', {
5884
6106
  user: user
5885
6107
  });
5886
6108
 
5887
6109
  case 4:
5888
- response = _context13.sent;
5889
- _context13.next = 11;
6110
+ response = _context14.sent;
6111
+ _context14.next = 11;
5890
6112
  break;
5891
6113
 
5892
6114
  case 7:
5893
- _context13.prev = 7;
5894
- _context13.t0 = _context13["catch"](1);
6115
+ _context14.prev = 7;
6116
+ _context14.t0 = _context14["catch"](1);
5895
6117
  this.anonymous = false;
5896
- throw _context13.t0;
6118
+ throw _context14.t0;
5897
6119
 
5898
6120
  case 11:
5899
6121
  this.anonymous = false; // eslint-disable-next-line @typescript-eslint/no-unused-vars
5900
6122
 
5901
6123
  _response$user = response.user, _response$user.created_at, _response$user.updated_at, _response$user.last_active, _response$user.online, guestUser = _objectWithoutProperties(_response$user, ["created_at", "updated_at", "last_active", "online"]);
5902
- _context13.next = 15;
6124
+ _context14.next = 15;
5903
6125
  return this.connectUser(guestUser, response.access_token);
5904
6126
 
5905
6127
  case 15:
5906
- return _context13.abrupt("return", _context13.sent);
6128
+ return _context14.abrupt("return", _context14.sent);
5907
6129
 
5908
6130
  case 16:
5909
6131
  case "end":
5910
- return _context13.stop();
6132
+ return _context14.stop();
5911
6133
  }
5912
6134
  }
5913
- }, _callee13, this, [[1, 7]]);
6135
+ }, _callee14, this, [[1, 7]]);
5914
6136
  }));
5915
6137
 
5916
- function setGuestUser(_x14) {
6138
+ function setGuestUser(_x16) {
5917
6139
  return _setGuestUser.apply(this, arguments);
5918
6140
  }
5919
6141
 
@@ -6223,40 +6445,39 @@ var StreamChat = /*#__PURE__*/function () {
6223
6445
  * @private
6224
6446
  */
6225
6447
  function () {
6226
- var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
6448
+ var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
6227
6449
  var client, warmUpPromise, handshake;
6228
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
6450
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
6229
6451
  while (1) {
6230
- switch (_context14.prev = _context14.next) {
6452
+ switch (_context15.prev = _context15.next) {
6231
6453
  case 0:
6232
- this.connecting = true;
6233
6454
  client = this;
6234
6455
  this.failures = 0;
6235
6456
 
6236
6457
  if (!(client.userID == null || this._user == null)) {
6237
- _context14.next = 5;
6458
+ _context15.next = 4;
6238
6459
  break;
6239
6460
  }
6240
6461
 
6241
6462
  throw Error('Call connectUser or connectAnonymousUser before starting the connection');
6242
6463
 
6243
- case 5:
6464
+ case 4:
6244
6465
  if (!(client.wsBaseURL == null)) {
6245
- _context14.next = 7;
6466
+ _context15.next = 6;
6246
6467
  break;
6247
6468
  }
6248
6469
 
6249
6470
  throw Error('Websocket base url not set');
6250
6471
 
6251
- case 7:
6472
+ case 6:
6252
6473
  if (!(client.clientID == null)) {
6253
- _context14.next = 9;
6474
+ _context15.next = 8;
6254
6475
  break;
6255
6476
  }
6256
6477
 
6257
6478
  throw Error('clientID is not set');
6258
6479
 
6259
- case 9:
6480
+ case 8:
6260
6481
  // The StableWSConnection handles all the reconnection logic.
6261
6482
  this.wsConnection = new StableWSConnection({
6262
6483
  wsBaseURL: client.wsBaseURL,
@@ -6271,42 +6492,44 @@ var StreamChat = /*#__PURE__*/function () {
6271
6492
  messageCallback: this.handleEvent,
6272
6493
  eventCallback: this.dispatchEvent,
6273
6494
  logger: this.logger,
6274
- device: this.options.device
6495
+ device: this.options.device,
6496
+ postInsights: this.options.enableInsights ? this.postInsights : undefined,
6497
+ insightMetrics: this.insightMetrics
6275
6498
  });
6276
6499
 
6277
6500
  if (this.options.warmUp) {
6278
6501
  warmUpPromise = this.doAxiosRequest('options', this.baseURL + '/connect');
6279
6502
  }
6280
6503
 
6281
- _context14.next = 13;
6504
+ _context15.next = 12;
6282
6505
  return this.wsConnection.connect();
6283
6506
 
6284
- case 13:
6285
- handshake = _context14.sent;
6286
- _context14.prev = 14;
6287
- _context14.next = 17;
6507
+ case 12:
6508
+ handshake = _context15.sent;
6509
+ _context15.prev = 13;
6510
+ _context15.next = 16;
6288
6511
  return warmUpPromise;
6289
6512
 
6290
- case 17:
6291
- _context14.next = 22;
6513
+ case 16:
6514
+ _context15.next = 21;
6292
6515
  break;
6293
6516
 
6294
- case 19:
6295
- _context14.prev = 19;
6296
- _context14.t0 = _context14["catch"](14);
6517
+ case 18:
6518
+ _context15.prev = 18;
6519
+ _context15.t0 = _context15["catch"](13);
6297
6520
  this.logger('error', 'Warmup request failed', {
6298
- error: _context14.t0
6521
+ error: _context15.t0
6299
6522
  });
6300
6523
 
6301
- case 22:
6302
- return _context14.abrupt("return", handshake);
6524
+ case 21:
6525
+ return _context15.abrupt("return", handshake);
6303
6526
 
6304
- case 23:
6527
+ case 22:
6305
6528
  case "end":
6306
- return _context14.stop();
6529
+ return _context15.stop();
6307
6530
  }
6308
6531
  }
6309
- }, _callee14, this, [[14, 19]]);
6532
+ }, _callee15, this, [[13, 18]]);
6310
6533
  }));
6311
6534
 
6312
6535
  function connect() {
@@ -6329,23 +6552,23 @@ var StreamChat = /*#__PURE__*/function () {
6329
6552
  }, {
6330
6553
  key: "queryUsers",
6331
6554
  value: function () {
6332
- var _queryUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(filterConditions) {
6555
+ var _queryUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(filterConditions) {
6333
6556
  var sort,
6334
6557
  options,
6335
6558
  defaultOptions,
6336
6559
  data,
6337
- _args15 = arguments;
6338
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
6560
+ _args16 = arguments;
6561
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
6339
6562
  while (1) {
6340
- switch (_context15.prev = _context15.next) {
6563
+ switch (_context16.prev = _context16.next) {
6341
6564
  case 0:
6342
- sort = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : [];
6343
- options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
6565
+ sort = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : [];
6566
+ options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
6344
6567
  defaultOptions = {
6345
6568
  presence: false
6346
6569
  }; // Make sure we wait for the connect promise if there is a pending one
6347
6570
 
6348
- _context15.next = 5;
6571
+ _context16.next = 5;
6349
6572
  return this.setUserPromise;
6350
6573
 
6351
6574
  case 5:
@@ -6354,7 +6577,7 @@ var StreamChat = /*#__PURE__*/function () {
6354
6577
  } // Return a list of users
6355
6578
 
6356
6579
 
6357
- _context15.next = 8;
6580
+ _context16.next = 8;
6358
6581
  return this.get(this.baseURL + '/users', {
6359
6582
  payload: _objectSpread(_objectSpread({
6360
6583
  filter_conditions: filterConditions,
@@ -6363,19 +6586,19 @@ var StreamChat = /*#__PURE__*/function () {
6363
6586
  });
6364
6587
 
6365
6588
  case 8:
6366
- data = _context15.sent;
6589
+ data = _context16.sent;
6367
6590
  this.state.updateUsers(data.users);
6368
- return _context15.abrupt("return", data);
6591
+ return _context16.abrupt("return", data);
6369
6592
 
6370
6593
  case 11:
6371
6594
  case "end":
6372
- return _context15.stop();
6595
+ return _context16.stop();
6373
6596
  }
6374
6597
  }
6375
- }, _callee15, this);
6598
+ }, _callee16, this);
6376
6599
  }));
6377
6600
 
6378
- function queryUsers(_x15) {
6601
+ function queryUsers(_x17) {
6379
6602
  return _queryUsers.apply(this, arguments);
6380
6603
  }
6381
6604
 
@@ -6394,19 +6617,19 @@ var StreamChat = /*#__PURE__*/function () {
6394
6617
  }, {
6395
6618
  key: "queryBannedUsers",
6396
6619
  value: function () {
6397
- var _queryBannedUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
6620
+ var _queryBannedUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
6398
6621
  var filterConditions,
6399
6622
  sort,
6400
6623
  options,
6401
- _args16 = arguments;
6402
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
6624
+ _args17 = arguments;
6625
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
6403
6626
  while (1) {
6404
- switch (_context16.prev = _context16.next) {
6627
+ switch (_context17.prev = _context17.next) {
6405
6628
  case 0:
6406
- filterConditions = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
6407
- sort = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : [];
6408
- options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
6409
- _context16.next = 5;
6629
+ filterConditions = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
6630
+ sort = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : [];
6631
+ options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
6632
+ _context17.next = 5;
6410
6633
  return this.get(this.baseURL + '/query_banned_users', {
6411
6634
  payload: _objectSpread({
6412
6635
  filter_conditions: filterConditions,
@@ -6415,14 +6638,14 @@ var StreamChat = /*#__PURE__*/function () {
6415
6638
  });
6416
6639
 
6417
6640
  case 5:
6418
- return _context16.abrupt("return", _context16.sent);
6641
+ return _context17.abrupt("return", _context17.sent);
6419
6642
 
6420
6643
  case 6:
6421
6644
  case "end":
6422
- return _context16.stop();
6645
+ return _context17.stop();
6423
6646
  }
6424
6647
  }
6425
- }, _callee16, this);
6648
+ }, _callee17, this);
6426
6649
  }));
6427
6650
 
6428
6651
  function queryBannedUsers() {
@@ -6443,17 +6666,17 @@ var StreamChat = /*#__PURE__*/function () {
6443
6666
  }, {
6444
6667
  key: "queryMessageFlags",
6445
6668
  value: function () {
6446
- var _queryMessageFlags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
6669
+ var _queryMessageFlags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
6447
6670
  var filterConditions,
6448
6671
  options,
6449
- _args17 = arguments;
6450
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
6672
+ _args18 = arguments;
6673
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
6451
6674
  while (1) {
6452
- switch (_context17.prev = _context17.next) {
6675
+ switch (_context18.prev = _context18.next) {
6453
6676
  case 0:
6454
- filterConditions = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
6455
- options = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
6456
- _context17.next = 4;
6677
+ filterConditions = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
6678
+ options = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
6679
+ _context18.next = 4;
6457
6680
  return this.get(this.baseURL + '/moderation/flags/message', {
6458
6681
  payload: _objectSpread({
6459
6682
  filter_conditions: filterConditions
@@ -6461,14 +6684,14 @@ var StreamChat = /*#__PURE__*/function () {
6461
6684
  });
6462
6685
 
6463
6686
  case 4:
6464
- return _context17.abrupt("return", _context17.sent);
6687
+ return _context18.abrupt("return", _context18.sent);
6465
6688
 
6466
6689
  case 5:
6467
6690
  case "end":
6468
- return _context17.stop();
6691
+ return _context18.stop();
6469
6692
  }
6470
6693
  }
6471
- }, _callee17, this);
6694
+ }, _callee18, this);
6472
6695
  }));
6473
6696
 
6474
6697
  function queryMessageFlags() {
@@ -6493,7 +6716,7 @@ var StreamChat = /*#__PURE__*/function () {
6493
6716
  }, {
6494
6717
  key: "queryChannels",
6495
6718
  value: function () {
6496
- var _queryChannels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(filterConditions) {
6719
+ var _queryChannels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(filterConditions) {
6497
6720
  var sort,
6498
6721
  options,
6499
6722
  stateOptions,
@@ -6509,15 +6732,15 @@ var StreamChat = /*#__PURE__*/function () {
6509
6732
  _step3,
6510
6733
  _channelState,
6511
6734
  c,
6512
- _args18 = arguments;
6735
+ _args19 = arguments;
6513
6736
 
6514
- return _regeneratorRuntime.wrap(function _callee18$(_context18) {
6737
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
6515
6738
  while (1) {
6516
- switch (_context18.prev = _context18.next) {
6739
+ switch (_context19.prev = _context19.next) {
6517
6740
  case 0:
6518
- sort = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : [];
6519
- options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
6520
- stateOptions = _args18.length > 3 && _args18[3] !== undefined ? _args18[3] : {};
6741
+ sort = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : [];
6742
+ options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
6743
+ stateOptions = _args19.length > 3 && _args19[3] !== undefined ? _args19[3] : {};
6521
6744
  skipInitialization = stateOptions.skipInitialization;
6522
6745
  defaultOptions = {
6523
6746
  state: true,
@@ -6525,7 +6748,7 @@ var StreamChat = /*#__PURE__*/function () {
6525
6748
  presence: false
6526
6749
  }; // Make sure we wait for the connect promise if there is a pending one
6527
6750
 
6528
- _context18.next = 7;
6751
+ _context19.next = 7;
6529
6752
  return this.setUserPromise;
6530
6753
 
6531
6754
  case 7:
@@ -6538,11 +6761,11 @@ var StreamChat = /*#__PURE__*/function () {
6538
6761
  filter_conditions: filterConditions,
6539
6762
  sort: normalizeQuerySort(sort)
6540
6763
  }, defaultOptions), options);
6541
- _context18.next = 11;
6764
+ _context19.next = 11;
6542
6765
  return this.post(this.baseURL + '/channels', payload);
6543
6766
 
6544
6767
  case 11:
6545
- data = _context18.sent;
6768
+ data = _context19.sent;
6546
6769
  channels = []; // update our cache of the configs
6547
6770
 
6548
6771
  _iterator2 = _createForOfIteratorHelper(data.channels);
@@ -6584,17 +6807,17 @@ var StreamChat = /*#__PURE__*/function () {
6584
6807
  _iterator3.f();
6585
6808
  }
6586
6809
 
6587
- return _context18.abrupt("return", channels);
6810
+ return _context19.abrupt("return", channels);
6588
6811
 
6589
6812
  case 18:
6590
6813
  case "end":
6591
- return _context18.stop();
6814
+ return _context19.stop();
6592
6815
  }
6593
6816
  }
6594
- }, _callee18, this);
6817
+ }, _callee19, this);
6595
6818
  }));
6596
6819
 
6597
- function queryChannels(_x16) {
6820
+ function queryChannels(_x18) {
6598
6821
  return _queryChannels.apply(this, arguments);
6599
6822
  }
6600
6823
 
@@ -6613,18 +6836,18 @@ var StreamChat = /*#__PURE__*/function () {
6613
6836
  }, {
6614
6837
  key: "search",
6615
6838
  value: function () {
6616
- var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(filterConditions, query) {
6839
+ var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(filterConditions, query) {
6617
6840
  var options,
6618
6841
  payload,
6619
- _args19 = arguments;
6620
- return _regeneratorRuntime.wrap(function _callee19$(_context19) {
6842
+ _args20 = arguments;
6843
+ return _regeneratorRuntime.wrap(function _callee20$(_context20) {
6621
6844
  while (1) {
6622
- switch (_context19.prev = _context19.next) {
6845
+ switch (_context20.prev = _context20.next) {
6623
6846
  case 0:
6624
- options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
6847
+ options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
6625
6848
 
6626
6849
  if (!(options.offset && (options.sort || options.next))) {
6627
- _context19.next = 3;
6850
+ _context20.next = 3;
6628
6851
  break;
6629
6852
  }
6630
6853
 
@@ -6638,49 +6861,49 @@ var StreamChat = /*#__PURE__*/function () {
6638
6861
  });
6639
6862
 
6640
6863
  if (!(typeof query === 'string')) {
6641
- _context19.next = 8;
6864
+ _context20.next = 8;
6642
6865
  break;
6643
6866
  }
6644
6867
 
6645
6868
  payload.query = query;
6646
- _context19.next = 13;
6869
+ _context20.next = 13;
6647
6870
  break;
6648
6871
 
6649
6872
  case 8:
6650
6873
  if (!(_typeof(query) === 'object')) {
6651
- _context19.next = 12;
6874
+ _context20.next = 12;
6652
6875
  break;
6653
6876
  }
6654
6877
 
6655
6878
  payload.message_filter_conditions = query;
6656
- _context19.next = 13;
6879
+ _context20.next = 13;
6657
6880
  break;
6658
6881
 
6659
6882
  case 12:
6660
6883
  throw Error("Invalid type ".concat(_typeof(query), " for query parameter"));
6661
6884
 
6662
6885
  case 13:
6663
- _context19.next = 15;
6886
+ _context20.next = 15;
6664
6887
  return this.setUserPromise;
6665
6888
 
6666
6889
  case 15:
6667
- _context19.next = 17;
6890
+ _context20.next = 17;
6668
6891
  return this.get(this.baseURL + '/search', {
6669
6892
  payload: payload
6670
6893
  });
6671
6894
 
6672
6895
  case 17:
6673
- return _context19.abrupt("return", _context19.sent);
6896
+ return _context20.abrupt("return", _context20.sent);
6674
6897
 
6675
6898
  case 18:
6676
6899
  case "end":
6677
- return _context19.stop();
6900
+ return _context20.stop();
6678
6901
  }
6679
6902
  }
6680
- }, _callee19, this);
6903
+ }, _callee20, this);
6681
6904
  }));
6682
6905
 
6683
- function search(_x17, _x18) {
6906
+ function search(_x19, _x20) {
6684
6907
  return _search.apply(this, arguments);
6685
6908
  }
6686
6909
 
@@ -6691,7 +6914,7 @@ var StreamChat = /*#__PURE__*/function () {
6691
6914
  *
6692
6915
  * @param {BaseDeviceFields} device the device object
6693
6916
  * @param {string} device.id device id
6694
- * @param {string} device.push_provider the push provider (apn or firebase)
6917
+ * @param {string} device.push_provider the push provider
6695
6918
  *
6696
6919
  */
6697
6920
 
@@ -6708,7 +6931,7 @@ var StreamChat = /*#__PURE__*/function () {
6708
6931
  * addDevice - Adds a push device for a user.
6709
6932
  *
6710
6933
  * @param {string} id the device id
6711
- * @param {'apn' | 'firebase'} push_provider the push provider (apn or firebase)
6934
+ * @param {PushProvider} push_provider the push provider
6712
6935
  * @param {string} [userID] the user id (defaults to current user)
6713
6936
  *
6714
6937
  */
@@ -6716,12 +6939,12 @@ var StreamChat = /*#__PURE__*/function () {
6716
6939
  }, {
6717
6940
  key: "addDevice",
6718
6941
  value: function () {
6719
- var _addDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(id, push_provider, userID) {
6720
- return _regeneratorRuntime.wrap(function _callee20$(_context20) {
6942
+ var _addDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(id, push_provider, userID) {
6943
+ return _regeneratorRuntime.wrap(function _callee21$(_context21) {
6721
6944
  while (1) {
6722
- switch (_context20.prev = _context20.next) {
6945
+ switch (_context21.prev = _context21.next) {
6723
6946
  case 0:
6724
- _context20.next = 2;
6947
+ _context21.next = 2;
6725
6948
  return this.post(this.baseURL + '/devices', _objectSpread({
6726
6949
  id: id,
6727
6950
  push_provider: push_provider
@@ -6730,17 +6953,17 @@ var StreamChat = /*#__PURE__*/function () {
6730
6953
  } : {}));
6731
6954
 
6732
6955
  case 2:
6733
- return _context20.abrupt("return", _context20.sent);
6956
+ return _context21.abrupt("return", _context21.sent);
6734
6957
 
6735
6958
  case 3:
6736
6959
  case "end":
6737
- return _context20.stop();
6960
+ return _context21.stop();
6738
6961
  }
6739
6962
  }
6740
- }, _callee20, this);
6963
+ }, _callee21, this);
6741
6964
  }));
6742
6965
 
6743
- function addDevice(_x19, _x20, _x21) {
6966
+ function addDevice(_x21, _x22, _x23) {
6744
6967
  return _addDevice.apply(this, arguments);
6745
6968
  }
6746
6969
 
@@ -6757,28 +6980,28 @@ var StreamChat = /*#__PURE__*/function () {
6757
6980
  }, {
6758
6981
  key: "getDevices",
6759
6982
  value: function () {
6760
- var _getDevices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(userID) {
6761
- return _regeneratorRuntime.wrap(function _callee21$(_context21) {
6983
+ var _getDevices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(userID) {
6984
+ return _regeneratorRuntime.wrap(function _callee22$(_context22) {
6762
6985
  while (1) {
6763
- switch (_context21.prev = _context21.next) {
6986
+ switch (_context22.prev = _context22.next) {
6764
6987
  case 0:
6765
- _context21.next = 2;
6988
+ _context22.next = 2;
6766
6989
  return this.get(this.baseURL + '/devices', userID ? {
6767
6990
  user_id: userID
6768
6991
  } : {});
6769
6992
 
6770
6993
  case 2:
6771
- return _context21.abrupt("return", _context21.sent);
6994
+ return _context22.abrupt("return", _context22.sent);
6772
6995
 
6773
6996
  case 3:
6774
6997
  case "end":
6775
- return _context21.stop();
6998
+ return _context22.stop();
6776
6999
  }
6777
7000
  }
6778
- }, _callee21, this);
7001
+ }, _callee22, this);
6779
7002
  }));
6780
7003
 
6781
- function getDevices(_x22) {
7004
+ function getDevices(_x24) {
6782
7005
  return _getDevices.apply(this, arguments);
6783
7006
  }
6784
7007
 
@@ -6795,12 +7018,12 @@ var StreamChat = /*#__PURE__*/function () {
6795
7018
  }, {
6796
7019
  key: "removeDevice",
6797
7020
  value: function () {
6798
- var _removeDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(id, userID) {
6799
- return _regeneratorRuntime.wrap(function _callee22$(_context22) {
7021
+ var _removeDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(id, userID) {
7022
+ return _regeneratorRuntime.wrap(function _callee23$(_context23) {
6800
7023
  while (1) {
6801
- switch (_context22.prev = _context22.next) {
7024
+ switch (_context23.prev = _context23.next) {
6802
7025
  case 0:
6803
- _context22.next = 2;
7026
+ _context23.next = 2;
6804
7027
  return this.delete(this.baseURL + '/devices', _objectSpread({
6805
7028
  id: id
6806
7029
  }, userID ? {
@@ -6808,17 +7031,17 @@ var StreamChat = /*#__PURE__*/function () {
6808
7031
  } : {}));
6809
7032
 
6810
7033
  case 2:
6811
- return _context22.abrupt("return", _context22.sent);
7034
+ return _context23.abrupt("return", _context23.sent);
6812
7035
 
6813
7036
  case 3:
6814
7037
  case "end":
6815
- return _context22.stop();
7038
+ return _context23.stop();
6816
7039
  }
6817
7040
  }
6818
- }, _callee22, this);
7041
+ }, _callee23, this);
6819
7042
  }));
6820
7043
 
6821
- function removeDevice(_x23, _x24) {
7044
+ function removeDevice(_x25, _x26) {
6822
7045
  return _removeDevice.apply(this, arguments);
6823
7046
  }
6824
7047
 
@@ -6835,15 +7058,15 @@ var StreamChat = /*#__PURE__*/function () {
6835
7058
  }, {
6836
7059
  key: "getRateLimits",
6837
7060
  value: function () {
6838
- var _getRateLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(params) {
6839
- var _ref6, serverSide, web, android, ios, endpoints;
7061
+ var _getRateLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(params) {
7062
+ var _ref7, serverSide, web, android, ios, endpoints;
6840
7063
 
6841
- return _regeneratorRuntime.wrap(function _callee23$(_context23) {
7064
+ return _regeneratorRuntime.wrap(function _callee24$(_context24) {
6842
7065
  while (1) {
6843
- switch (_context23.prev = _context23.next) {
7066
+ switch (_context24.prev = _context24.next) {
6844
7067
  case 0:
6845
- _ref6 = params || {}, serverSide = _ref6.serverSide, web = _ref6.web, android = _ref6.android, ios = _ref6.ios, endpoints = _ref6.endpoints;
6846
- return _context23.abrupt("return", this.get(this.baseURL + '/rate_limits', {
7068
+ _ref7 = params || {}, serverSide = _ref7.serverSide, web = _ref7.web, android = _ref7.android, ios = _ref7.ios, endpoints = _ref7.endpoints;
7069
+ return _context24.abrupt("return", this.get(this.baseURL + '/rate_limits', {
6847
7070
  server_side: serverSide,
6848
7071
  web: web,
6849
7072
  android: android,
@@ -6853,13 +7076,13 @@ var StreamChat = /*#__PURE__*/function () {
6853
7076
 
6854
7077
  case 2:
6855
7078
  case "end":
6856
- return _context23.stop();
7079
+ return _context24.stop();
6857
7080
  }
6858
7081
  }
6859
- }, _callee23, this);
7082
+ }, _callee24, this);
6860
7083
  }));
6861
7084
 
6862
- function getRateLimits(_x25) {
7085
+ function getRateLimits(_x27) {
6863
7086
  return _getRateLimits.apply(this, arguments);
6864
7087
  }
6865
7088
 
@@ -6941,26 +7164,26 @@ var StreamChat = /*#__PURE__*/function () {
6941
7164
  * @return {Promise<APIResponse & { users: { [key: string]: UserResponse<UserType> } }>} list of updated users
6942
7165
  */
6943
7166
  function () {
6944
- var _partialUpdateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(partialUserObject) {
6945
- return _regeneratorRuntime.wrap(function _callee24$(_context24) {
7167
+ var _partialUpdateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(partialUserObject) {
7168
+ return _regeneratorRuntime.wrap(function _callee25$(_context25) {
6946
7169
  while (1) {
6947
- switch (_context24.prev = _context24.next) {
7170
+ switch (_context25.prev = _context25.next) {
6948
7171
  case 0:
6949
- _context24.next = 2;
7172
+ _context25.next = 2;
6950
7173
  return this.partialUpdateUsers([partialUserObject]);
6951
7174
 
6952
7175
  case 2:
6953
- return _context24.abrupt("return", _context24.sent);
7176
+ return _context25.abrupt("return", _context25.sent);
6954
7177
 
6955
7178
  case 3:
6956
7179
  case "end":
6957
- return _context24.stop();
7180
+ return _context25.stop();
6958
7181
  }
6959
7182
  }
6960
- }, _callee24, this);
7183
+ }, _callee25, this);
6961
7184
  }));
6962
7185
 
6963
- function partialUpdateUser(_x26) {
7186
+ function partialUpdateUser(_x28) {
6964
7187
  return _partialUpdateUser.apply(this, arguments);
6965
7188
  }
6966
7189
 
@@ -6977,29 +7200,29 @@ var StreamChat = /*#__PURE__*/function () {
6977
7200
  }, {
6978
7201
  key: "upsertUsers",
6979
7202
  value: function () {
6980
- var _upsertUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(users) {
7203
+ var _upsertUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(users) {
6981
7204
  var userMap, _iterator4, _step4, userObject;
6982
7205
 
6983
- return _regeneratorRuntime.wrap(function _callee25$(_context25) {
7206
+ return _regeneratorRuntime.wrap(function _callee26$(_context26) {
6984
7207
  while (1) {
6985
- switch (_context25.prev = _context25.next) {
7208
+ switch (_context26.prev = _context26.next) {
6986
7209
  case 0:
6987
7210
  userMap = {};
6988
7211
  _iterator4 = _createForOfIteratorHelper(users);
6989
- _context25.prev = 2;
7212
+ _context26.prev = 2;
6990
7213
 
6991
7214
  _iterator4.s();
6992
7215
 
6993
7216
  case 4:
6994
7217
  if ((_step4 = _iterator4.n()).done) {
6995
- _context25.next = 11;
7218
+ _context26.next = 11;
6996
7219
  break;
6997
7220
  }
6998
7221
 
6999
7222
  userObject = _step4.value;
7000
7223
 
7001
7224
  if (userObject.id) {
7002
- _context25.next = 8;
7225
+ _context26.next = 8;
7003
7226
  break;
7004
7227
  }
7005
7228
 
@@ -7009,44 +7232,44 @@ var StreamChat = /*#__PURE__*/function () {
7009
7232
  userMap[userObject.id] = userObject;
7010
7233
 
7011
7234
  case 9:
7012
- _context25.next = 4;
7235
+ _context26.next = 4;
7013
7236
  break;
7014
7237
 
7015
7238
  case 11:
7016
- _context25.next = 16;
7239
+ _context26.next = 16;
7017
7240
  break;
7018
7241
 
7019
7242
  case 13:
7020
- _context25.prev = 13;
7021
- _context25.t0 = _context25["catch"](2);
7243
+ _context26.prev = 13;
7244
+ _context26.t0 = _context26["catch"](2);
7022
7245
 
7023
- _iterator4.e(_context25.t0);
7246
+ _iterator4.e(_context26.t0);
7024
7247
 
7025
7248
  case 16:
7026
- _context25.prev = 16;
7249
+ _context26.prev = 16;
7027
7250
 
7028
7251
  _iterator4.f();
7029
7252
 
7030
- return _context25.finish(16);
7253
+ return _context26.finish(16);
7031
7254
 
7032
7255
  case 19:
7033
- _context25.next = 21;
7256
+ _context26.next = 21;
7034
7257
  return this.post(this.baseURL + '/users', {
7035
7258
  users: userMap
7036
7259
  });
7037
7260
 
7038
7261
  case 21:
7039
- return _context25.abrupt("return", _context25.sent);
7262
+ return _context26.abrupt("return", _context26.sent);
7040
7263
 
7041
7264
  case 22:
7042
7265
  case "end":
7043
- return _context25.stop();
7266
+ return _context26.stop();
7044
7267
  }
7045
7268
  }
7046
- }, _callee25, this, [[2, 13, 16, 19]]);
7269
+ }, _callee26, this, [[2, 13, 16, 19]]);
7047
7270
  }));
7048
7271
 
7049
- function upsertUsers(_x27) {
7272
+ function upsertUsers(_x29) {
7050
7273
  return _upsertUsers.apply(this, arguments);
7051
7274
  }
7052
7275
 
@@ -7094,72 +7317,72 @@ var StreamChat = /*#__PURE__*/function () {
7094
7317
  * @return {Promise<APIResponse & { users: { [key: string]: UserResponse<UserType> } }>}
7095
7318
  */
7096
7319
  function () {
7097
- var _partialUpdateUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(users) {
7320
+ var _partialUpdateUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(users) {
7098
7321
  var _iterator5, _step5, userObject;
7099
7322
 
7100
- return _regeneratorRuntime.wrap(function _callee26$(_context26) {
7323
+ return _regeneratorRuntime.wrap(function _callee27$(_context27) {
7101
7324
  while (1) {
7102
- switch (_context26.prev = _context26.next) {
7325
+ switch (_context27.prev = _context27.next) {
7103
7326
  case 0:
7104
7327
  _iterator5 = _createForOfIteratorHelper(users);
7105
- _context26.prev = 1;
7328
+ _context27.prev = 1;
7106
7329
 
7107
7330
  _iterator5.s();
7108
7331
 
7109
7332
  case 3:
7110
7333
  if ((_step5 = _iterator5.n()).done) {
7111
- _context26.next = 9;
7334
+ _context27.next = 9;
7112
7335
  break;
7113
7336
  }
7114
7337
 
7115
7338
  userObject = _step5.value;
7116
7339
 
7117
7340
  if (userObject.id) {
7118
- _context26.next = 7;
7341
+ _context27.next = 7;
7119
7342
  break;
7120
7343
  }
7121
7344
 
7122
7345
  throw Error('User ID is required when updating a user');
7123
7346
 
7124
7347
  case 7:
7125
- _context26.next = 3;
7348
+ _context27.next = 3;
7126
7349
  break;
7127
7350
 
7128
7351
  case 9:
7129
- _context26.next = 14;
7352
+ _context27.next = 14;
7130
7353
  break;
7131
7354
 
7132
7355
  case 11:
7133
- _context26.prev = 11;
7134
- _context26.t0 = _context26["catch"](1);
7356
+ _context27.prev = 11;
7357
+ _context27.t0 = _context27["catch"](1);
7135
7358
 
7136
- _iterator5.e(_context26.t0);
7359
+ _iterator5.e(_context27.t0);
7137
7360
 
7138
7361
  case 14:
7139
- _context26.prev = 14;
7362
+ _context27.prev = 14;
7140
7363
 
7141
7364
  _iterator5.f();
7142
7365
 
7143
- return _context26.finish(14);
7366
+ return _context27.finish(14);
7144
7367
 
7145
7368
  case 17:
7146
- _context26.next = 19;
7369
+ _context27.next = 19;
7147
7370
  return this.patch(this.baseURL + '/users', {
7148
7371
  users: users
7149
7372
  });
7150
7373
 
7151
7374
  case 19:
7152
- return _context26.abrupt("return", _context26.sent);
7375
+ return _context27.abrupt("return", _context27.sent);
7153
7376
 
7154
7377
  case 20:
7155
7378
  case "end":
7156
- return _context26.stop();
7379
+ return _context27.stop();
7157
7380
  }
7158
7381
  }
7159
- }, _callee26, this, [[1, 11, 14, 17]]);
7382
+ }, _callee27, this, [[1, 11, 14, 17]]);
7160
7383
  }));
7161
7384
 
7162
- function partialUpdateUsers(_x28) {
7385
+ function partialUpdateUsers(_x30) {
7163
7386
  return _partialUpdateUsers.apply(this, arguments);
7164
7387
  }
7165
7388
 
@@ -7168,26 +7391,26 @@ var StreamChat = /*#__PURE__*/function () {
7168
7391
  }, {
7169
7392
  key: "deleteUser",
7170
7393
  value: function () {
7171
- var _deleteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(userID, params) {
7172
- return _regeneratorRuntime.wrap(function _callee27$(_context27) {
7394
+ var _deleteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(userID, params) {
7395
+ return _regeneratorRuntime.wrap(function _callee28$(_context28) {
7173
7396
  while (1) {
7174
- switch (_context27.prev = _context27.next) {
7397
+ switch (_context28.prev = _context28.next) {
7175
7398
  case 0:
7176
- _context27.next = 2;
7399
+ _context28.next = 2;
7177
7400
  return this.delete(this.baseURL + "/users/".concat(userID), params);
7178
7401
 
7179
7402
  case 2:
7180
- return _context27.abrupt("return", _context27.sent);
7403
+ return _context28.abrupt("return", _context28.sent);
7181
7404
 
7182
7405
  case 3:
7183
7406
  case "end":
7184
- return _context27.stop();
7407
+ return _context28.stop();
7185
7408
  }
7186
7409
  }
7187
- }, _callee27, this);
7410
+ }, _callee28, this);
7188
7411
  }));
7189
7412
 
7190
- function deleteUser(_x29, _x30) {
7413
+ function deleteUser(_x31, _x32) {
7191
7414
  return _deleteUser.apply(this, arguments);
7192
7415
  }
7193
7416
 
@@ -7196,26 +7419,26 @@ var StreamChat = /*#__PURE__*/function () {
7196
7419
  }, {
7197
7420
  key: "reactivateUser",
7198
7421
  value: function () {
7199
- var _reactivateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(userID, options) {
7200
- return _regeneratorRuntime.wrap(function _callee28$(_context28) {
7422
+ var _reactivateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(userID, options) {
7423
+ return _regeneratorRuntime.wrap(function _callee29$(_context29) {
7201
7424
  while (1) {
7202
- switch (_context28.prev = _context28.next) {
7425
+ switch (_context29.prev = _context29.next) {
7203
7426
  case 0:
7204
- _context28.next = 2;
7427
+ _context29.next = 2;
7205
7428
  return this.post(this.baseURL + "/users/".concat(userID, "/reactivate"), _objectSpread({}, options));
7206
7429
 
7207
7430
  case 2:
7208
- return _context28.abrupt("return", _context28.sent);
7431
+ return _context29.abrupt("return", _context29.sent);
7209
7432
 
7210
7433
  case 3:
7211
7434
  case "end":
7212
- return _context28.stop();
7435
+ return _context29.stop();
7213
7436
  }
7214
7437
  }
7215
- }, _callee28, this);
7438
+ }, _callee29, this);
7216
7439
  }));
7217
7440
 
7218
- function reactivateUser(_x31, _x32) {
7441
+ function reactivateUser(_x33, _x34) {
7219
7442
  return _reactivateUser.apply(this, arguments);
7220
7443
  }
7221
7444
 
@@ -7224,26 +7447,26 @@ var StreamChat = /*#__PURE__*/function () {
7224
7447
  }, {
7225
7448
  key: "deactivateUser",
7226
7449
  value: function () {
7227
- var _deactivateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(userID, options) {
7228
- return _regeneratorRuntime.wrap(function _callee29$(_context29) {
7450
+ var _deactivateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(userID, options) {
7451
+ return _regeneratorRuntime.wrap(function _callee30$(_context30) {
7229
7452
  while (1) {
7230
- switch (_context29.prev = _context29.next) {
7453
+ switch (_context30.prev = _context30.next) {
7231
7454
  case 0:
7232
- _context29.next = 2;
7455
+ _context30.next = 2;
7233
7456
  return this.post(this.baseURL + "/users/".concat(userID, "/deactivate"), _objectSpread({}, options));
7234
7457
 
7235
7458
  case 2:
7236
- return _context29.abrupt("return", _context29.sent);
7459
+ return _context30.abrupt("return", _context30.sent);
7237
7460
 
7238
7461
  case 3:
7239
7462
  case "end":
7240
- return _context29.stop();
7463
+ return _context30.stop();
7241
7464
  }
7242
7465
  }
7243
- }, _callee29, this);
7466
+ }, _callee30, this);
7244
7467
  }));
7245
7468
 
7246
- function deactivateUser(_x33, _x34) {
7469
+ function deactivateUser(_x35, _x36) {
7247
7470
  return _deactivateUser.apply(this, arguments);
7248
7471
  }
7249
7472
 
@@ -7252,26 +7475,26 @@ var StreamChat = /*#__PURE__*/function () {
7252
7475
  }, {
7253
7476
  key: "exportUser",
7254
7477
  value: function () {
7255
- var _exportUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(userID, options) {
7256
- return _regeneratorRuntime.wrap(function _callee30$(_context30) {
7478
+ var _exportUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(userID, options) {
7479
+ return _regeneratorRuntime.wrap(function _callee31$(_context31) {
7257
7480
  while (1) {
7258
- switch (_context30.prev = _context30.next) {
7481
+ switch (_context31.prev = _context31.next) {
7259
7482
  case 0:
7260
- _context30.next = 2;
7483
+ _context31.next = 2;
7261
7484
  return this.get(this.baseURL + "/users/".concat(userID, "/export"), _objectSpread({}, options));
7262
7485
 
7263
7486
  case 2:
7264
- return _context30.abrupt("return", _context30.sent);
7487
+ return _context31.abrupt("return", _context31.sent);
7265
7488
 
7266
7489
  case 3:
7267
7490
  case "end":
7268
- return _context30.stop();
7491
+ return _context31.stop();
7269
7492
  }
7270
7493
  }
7271
- }, _callee30, this);
7494
+ }, _callee31, this);
7272
7495
  }));
7273
7496
 
7274
- function exportUser(_x35, _x36) {
7497
+ function exportUser(_x37, _x38) {
7275
7498
  return _exportUser.apply(this, arguments);
7276
7499
  }
7277
7500
 
@@ -7287,10 +7510,10 @@ var StreamChat = /*#__PURE__*/function () {
7287
7510
  }, {
7288
7511
  key: "banUser",
7289
7512
  value: function () {
7290
- var _banUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(targetUserID, options) {
7291
- return _regeneratorRuntime.wrap(function _callee31$(_context31) {
7513
+ var _banUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(targetUserID, options) {
7514
+ return _regeneratorRuntime.wrap(function _callee32$(_context32) {
7292
7515
  while (1) {
7293
- switch (_context31.prev = _context31.next) {
7516
+ switch (_context32.prev = _context32.next) {
7294
7517
  case 0:
7295
7518
  if ((options === null || options === void 0 ? void 0 : options.user_id) !== undefined) {
7296
7519
  options.banned_by_id = options.user_id;
@@ -7304,23 +7527,23 @@ var StreamChat = /*#__PURE__*/function () {
7304
7527
  console.warn("banUser: 'user' is deprecated, please consider switching to 'banned_by'");
7305
7528
  }
7306
7529
 
7307
- _context31.next = 4;
7530
+ _context32.next = 4;
7308
7531
  return this.post(this.baseURL + '/moderation/ban', _objectSpread({
7309
7532
  target_user_id: targetUserID
7310
7533
  }, options));
7311
7534
 
7312
7535
  case 4:
7313
- return _context31.abrupt("return", _context31.sent);
7536
+ return _context32.abrupt("return", _context32.sent);
7314
7537
 
7315
7538
  case 5:
7316
7539
  case "end":
7317
- return _context31.stop();
7540
+ return _context32.stop();
7318
7541
  }
7319
7542
  }
7320
- }, _callee31, this);
7543
+ }, _callee32, this);
7321
7544
  }));
7322
7545
 
7323
- function banUser(_x37, _x38) {
7546
+ function banUser(_x39, _x40) {
7324
7547
  return _banUser.apply(this, arguments);
7325
7548
  }
7326
7549
 
@@ -7336,28 +7559,28 @@ var StreamChat = /*#__PURE__*/function () {
7336
7559
  }, {
7337
7560
  key: "unbanUser",
7338
7561
  value: function () {
7339
- var _unbanUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(targetUserID, options) {
7340
- return _regeneratorRuntime.wrap(function _callee32$(_context32) {
7562
+ var _unbanUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(targetUserID, options) {
7563
+ return _regeneratorRuntime.wrap(function _callee33$(_context33) {
7341
7564
  while (1) {
7342
- switch (_context32.prev = _context32.next) {
7565
+ switch (_context33.prev = _context33.next) {
7343
7566
  case 0:
7344
- _context32.next = 2;
7567
+ _context33.next = 2;
7345
7568
  return this.delete(this.baseURL + '/moderation/ban', _objectSpread({
7346
7569
  target_user_id: targetUserID
7347
7570
  }, options));
7348
7571
 
7349
7572
  case 2:
7350
- return _context32.abrupt("return", _context32.sent);
7573
+ return _context33.abrupt("return", _context33.sent);
7351
7574
 
7352
7575
  case 3:
7353
7576
  case "end":
7354
- return _context32.stop();
7577
+ return _context33.stop();
7355
7578
  }
7356
7579
  }
7357
- }, _callee32, this);
7580
+ }, _callee33, this);
7358
7581
  }));
7359
7582
 
7360
- function unbanUser(_x39, _x40) {
7583
+ function unbanUser(_x41, _x42) {
7361
7584
  return _unbanUser.apply(this, arguments);
7362
7585
  }
7363
7586
 
@@ -7373,28 +7596,28 @@ var StreamChat = /*#__PURE__*/function () {
7373
7596
  }, {
7374
7597
  key: "shadowBan",
7375
7598
  value: function () {
7376
- var _shadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(targetUserID, options) {
7377
- return _regeneratorRuntime.wrap(function _callee33$(_context33) {
7599
+ var _shadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(targetUserID, options) {
7600
+ return _regeneratorRuntime.wrap(function _callee34$(_context34) {
7378
7601
  while (1) {
7379
- switch (_context33.prev = _context33.next) {
7602
+ switch (_context34.prev = _context34.next) {
7380
7603
  case 0:
7381
- _context33.next = 2;
7604
+ _context34.next = 2;
7382
7605
  return this.banUser(targetUserID, _objectSpread({
7383
7606
  shadow: true
7384
7607
  }, options));
7385
7608
 
7386
7609
  case 2:
7387
- return _context33.abrupt("return", _context33.sent);
7610
+ return _context34.abrupt("return", _context34.sent);
7388
7611
 
7389
7612
  case 3:
7390
7613
  case "end":
7391
- return _context33.stop();
7614
+ return _context34.stop();
7392
7615
  }
7393
7616
  }
7394
- }, _callee33, this);
7617
+ }, _callee34, this);
7395
7618
  }));
7396
7619
 
7397
- function shadowBan(_x41, _x42) {
7620
+ function shadowBan(_x43, _x44) {
7398
7621
  return _shadowBan.apply(this, arguments);
7399
7622
  }
7400
7623
 
@@ -7410,28 +7633,28 @@ var StreamChat = /*#__PURE__*/function () {
7410
7633
  }, {
7411
7634
  key: "removeShadowBan",
7412
7635
  value: function () {
7413
- var _removeShadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(targetUserID, options) {
7414
- return _regeneratorRuntime.wrap(function _callee34$(_context34) {
7636
+ var _removeShadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35(targetUserID, options) {
7637
+ return _regeneratorRuntime.wrap(function _callee35$(_context35) {
7415
7638
  while (1) {
7416
- switch (_context34.prev = _context34.next) {
7639
+ switch (_context35.prev = _context35.next) {
7417
7640
  case 0:
7418
- _context34.next = 2;
7641
+ _context35.next = 2;
7419
7642
  return this.unbanUser(targetUserID, _objectSpread({
7420
7643
  shadow: true
7421
7644
  }, options));
7422
7645
 
7423
7646
  case 2:
7424
- return _context34.abrupt("return", _context34.sent);
7647
+ return _context35.abrupt("return", _context35.sent);
7425
7648
 
7426
7649
  case 3:
7427
7650
  case "end":
7428
- return _context34.stop();
7651
+ return _context35.stop();
7429
7652
  }
7430
7653
  }
7431
- }, _callee34, this);
7654
+ }, _callee35, this);
7432
7655
  }));
7433
7656
 
7434
- function removeShadowBan(_x43, _x44) {
7657
+ function removeShadowBan(_x45, _x46) {
7435
7658
  return _removeShadowBan.apply(this, arguments);
7436
7659
  }
7437
7660
 
@@ -7448,15 +7671,15 @@ var StreamChat = /*#__PURE__*/function () {
7448
7671
  }, {
7449
7672
  key: "muteUser",
7450
7673
  value: function () {
7451
- var _muteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35(targetID, userID) {
7674
+ var _muteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36(targetID, userID) {
7452
7675
  var options,
7453
- _args35 = arguments;
7454
- return _regeneratorRuntime.wrap(function _callee35$(_context35) {
7676
+ _args36 = arguments;
7677
+ return _regeneratorRuntime.wrap(function _callee36$(_context36) {
7455
7678
  while (1) {
7456
- switch (_context35.prev = _context35.next) {
7679
+ switch (_context36.prev = _context36.next) {
7457
7680
  case 0:
7458
- options = _args35.length > 2 && _args35[2] !== undefined ? _args35[2] : {};
7459
- _context35.next = 3;
7681
+ options = _args36.length > 2 && _args36[2] !== undefined ? _args36[2] : {};
7682
+ _context36.next = 3;
7460
7683
  return this.post(this.baseURL + '/moderation/mute', _objectSpread(_objectSpread({
7461
7684
  target_id: targetID
7462
7685
  }, userID ? {
@@ -7464,17 +7687,17 @@ var StreamChat = /*#__PURE__*/function () {
7464
7687
  } : {}), options));
7465
7688
 
7466
7689
  case 3:
7467
- return _context35.abrupt("return", _context35.sent);
7690
+ return _context36.abrupt("return", _context36.sent);
7468
7691
 
7469
7692
  case 4:
7470
7693
  case "end":
7471
- return _context35.stop();
7694
+ return _context36.stop();
7472
7695
  }
7473
7696
  }
7474
- }, _callee35, this);
7697
+ }, _callee36, this);
7475
7698
  }));
7476
7699
 
7477
- function muteUser(_x45, _x46) {
7700
+ function muteUser(_x47, _x48) {
7478
7701
  return _muteUser.apply(this, arguments);
7479
7702
  }
7480
7703
 
@@ -7490,12 +7713,12 @@ var StreamChat = /*#__PURE__*/function () {
7490
7713
  }, {
7491
7714
  key: "unmuteUser",
7492
7715
  value: function () {
7493
- var _unmuteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36(targetID, currentUserID) {
7494
- return _regeneratorRuntime.wrap(function _callee36$(_context36) {
7716
+ var _unmuteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37(targetID, currentUserID) {
7717
+ return _regeneratorRuntime.wrap(function _callee37$(_context37) {
7495
7718
  while (1) {
7496
- switch (_context36.prev = _context36.next) {
7719
+ switch (_context37.prev = _context37.next) {
7497
7720
  case 0:
7498
- _context36.next = 2;
7721
+ _context37.next = 2;
7499
7722
  return this.post(this.baseURL + '/moderation/unmute', _objectSpread({
7500
7723
  target_id: targetID
7501
7724
  }, currentUserID ? {
@@ -7503,17 +7726,17 @@ var StreamChat = /*#__PURE__*/function () {
7503
7726
  } : {}));
7504
7727
 
7505
7728
  case 2:
7506
- return _context36.abrupt("return", _context36.sent);
7729
+ return _context37.abrupt("return", _context37.sent);
7507
7730
 
7508
7731
  case 3:
7509
7732
  case "end":
7510
- return _context36.stop();
7733
+ return _context37.stop();
7511
7734
  }
7512
7735
  }
7513
- }, _callee36, this);
7736
+ }, _callee37, this);
7514
7737
  }));
7515
7738
 
7516
- function unmuteUser(_x47, _x48) {
7739
+ function unmuteUser(_x49, _x50) {
7517
7740
  return _unmuteUser.apply(this, arguments);
7518
7741
  }
7519
7742
 
@@ -7548,31 +7771,31 @@ var StreamChat = /*#__PURE__*/function () {
7548
7771
  }, {
7549
7772
  key: "flagMessage",
7550
7773
  value: function () {
7551
- var _flagMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37(targetMessageID) {
7774
+ var _flagMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38(targetMessageID) {
7552
7775
  var options,
7553
- _args37 = arguments;
7554
- return _regeneratorRuntime.wrap(function _callee37$(_context37) {
7776
+ _args38 = arguments;
7777
+ return _regeneratorRuntime.wrap(function _callee38$(_context38) {
7555
7778
  while (1) {
7556
- switch (_context37.prev = _context37.next) {
7779
+ switch (_context38.prev = _context38.next) {
7557
7780
  case 0:
7558
- options = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : {};
7559
- _context37.next = 3;
7781
+ options = _args38.length > 1 && _args38[1] !== undefined ? _args38[1] : {};
7782
+ _context38.next = 3;
7560
7783
  return this.post(this.baseURL + '/moderation/flag', _objectSpread({
7561
7784
  target_message_id: targetMessageID
7562
7785
  }, options));
7563
7786
 
7564
7787
  case 3:
7565
- return _context37.abrupt("return", _context37.sent);
7788
+ return _context38.abrupt("return", _context38.sent);
7566
7789
 
7567
7790
  case 4:
7568
7791
  case "end":
7569
- return _context37.stop();
7792
+ return _context38.stop();
7570
7793
  }
7571
7794
  }
7572
- }, _callee37, this);
7795
+ }, _callee38, this);
7573
7796
  }));
7574
7797
 
7575
- function flagMessage(_x49) {
7798
+ function flagMessage(_x51) {
7576
7799
  return _flagMessage.apply(this, arguments);
7577
7800
  }
7578
7801
 
@@ -7588,31 +7811,31 @@ var StreamChat = /*#__PURE__*/function () {
7588
7811
  }, {
7589
7812
  key: "flagUser",
7590
7813
  value: function () {
7591
- var _flagUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38(targetID) {
7814
+ var _flagUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39(targetID) {
7592
7815
  var options,
7593
- _args38 = arguments;
7594
- return _regeneratorRuntime.wrap(function _callee38$(_context38) {
7816
+ _args39 = arguments;
7817
+ return _regeneratorRuntime.wrap(function _callee39$(_context39) {
7595
7818
  while (1) {
7596
- switch (_context38.prev = _context38.next) {
7819
+ switch (_context39.prev = _context39.next) {
7597
7820
  case 0:
7598
- options = _args38.length > 1 && _args38[1] !== undefined ? _args38[1] : {};
7599
- _context38.next = 3;
7821
+ options = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {};
7822
+ _context39.next = 3;
7600
7823
  return this.post(this.baseURL + '/moderation/flag', _objectSpread({
7601
7824
  target_user_id: targetID
7602
7825
  }, options));
7603
7826
 
7604
7827
  case 3:
7605
- return _context38.abrupt("return", _context38.sent);
7828
+ return _context39.abrupt("return", _context39.sent);
7606
7829
 
7607
7830
  case 4:
7608
7831
  case "end":
7609
- return _context38.stop();
7832
+ return _context39.stop();
7610
7833
  }
7611
7834
  }
7612
- }, _callee38, this);
7835
+ }, _callee39, this);
7613
7836
  }));
7614
7837
 
7615
- function flagUser(_x50) {
7838
+ function flagUser(_x52) {
7616
7839
  return _flagUser.apply(this, arguments);
7617
7840
  }
7618
7841
 
@@ -7628,31 +7851,31 @@ var StreamChat = /*#__PURE__*/function () {
7628
7851
  }, {
7629
7852
  key: "unflagMessage",
7630
7853
  value: function () {
7631
- var _unflagMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39(targetMessageID) {
7854
+ var _unflagMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40(targetMessageID) {
7632
7855
  var options,
7633
- _args39 = arguments;
7634
- return _regeneratorRuntime.wrap(function _callee39$(_context39) {
7856
+ _args40 = arguments;
7857
+ return _regeneratorRuntime.wrap(function _callee40$(_context40) {
7635
7858
  while (1) {
7636
- switch (_context39.prev = _context39.next) {
7859
+ switch (_context40.prev = _context40.next) {
7637
7860
  case 0:
7638
- options = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {};
7639
- _context39.next = 3;
7861
+ options = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {};
7862
+ _context40.next = 3;
7640
7863
  return this.post(this.baseURL + '/moderation/unflag', _objectSpread({
7641
7864
  target_message_id: targetMessageID
7642
7865
  }, options));
7643
7866
 
7644
7867
  case 3:
7645
- return _context39.abrupt("return", _context39.sent);
7868
+ return _context40.abrupt("return", _context40.sent);
7646
7869
 
7647
7870
  case 4:
7648
7871
  case "end":
7649
- return _context39.stop();
7872
+ return _context40.stop();
7650
7873
  }
7651
7874
  }
7652
- }, _callee39, this);
7875
+ }, _callee40, this);
7653
7876
  }));
7654
7877
 
7655
- function unflagMessage(_x51) {
7878
+ function unflagMessage(_x53) {
7656
7879
  return _unflagMessage.apply(this, arguments);
7657
7880
  }
7658
7881
 
@@ -7668,37 +7891,39 @@ var StreamChat = /*#__PURE__*/function () {
7668
7891
  }, {
7669
7892
  key: "unflagUser",
7670
7893
  value: function () {
7671
- var _unflagUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40(targetID) {
7894
+ var _unflagUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41(targetID) {
7672
7895
  var options,
7673
- _args40 = arguments;
7674
- return _regeneratorRuntime.wrap(function _callee40$(_context40) {
7896
+ _args41 = arguments;
7897
+ return _regeneratorRuntime.wrap(function _callee41$(_context41) {
7675
7898
  while (1) {
7676
- switch (_context40.prev = _context40.next) {
7899
+ switch (_context41.prev = _context41.next) {
7677
7900
  case 0:
7678
- options = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {};
7679
- _context40.next = 3;
7901
+ options = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {};
7902
+ _context41.next = 3;
7680
7903
  return this.post(this.baseURL + '/moderation/unflag', _objectSpread({
7681
7904
  target_user_id: targetID
7682
7905
  }, options));
7683
7906
 
7684
7907
  case 3:
7685
- return _context40.abrupt("return", _context40.sent);
7908
+ return _context41.abrupt("return", _context41.sent);
7686
7909
 
7687
7910
  case 4:
7688
7911
  case "end":
7689
- return _context40.stop();
7912
+ return _context41.stop();
7690
7913
  }
7691
7914
  }
7692
- }, _callee40, this);
7915
+ }, _callee41, this);
7693
7916
  }));
7694
7917
 
7695
- function unflagUser(_x52) {
7918
+ function unflagUser(_x54) {
7696
7919
  return _unflagUser.apply(this, arguments);
7697
7920
  }
7698
7921
 
7699
7922
  return unflagUser;
7700
7923
  }()
7701
7924
  /**
7925
+ * @deprecated use markChannelsRead instead
7926
+ *
7702
7927
  * markAllRead - marks all channels for this user as read
7703
7928
  * @param {MarkAllReadOptions<UserType>} [data]
7704
7929
  *
@@ -7706,32 +7931,41 @@ var StreamChat = /*#__PURE__*/function () {
7706
7931
  */
7707
7932
 
7708
7933
  }, {
7709
- key: "markAllRead",
7710
- value: function () {
7711
- var _markAllRead = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {
7934
+ key: "markChannelsRead",
7935
+ value:
7936
+ /**
7937
+ * markChannelsRead - marks channels read -
7938
+ * it accepts a map of cid:messageid pairs, if messageid is empty, the whole channel will be marked as read
7939
+ *
7940
+ * @param {MarkChannelsReadOptions <UserType>} [data]
7941
+ *
7942
+ * @return {Promise<APIResponse>}
7943
+ */
7944
+ function () {
7945
+ var _markChannelsRead = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42() {
7712
7946
  var data,
7713
- _args41 = arguments;
7714
- return _regeneratorRuntime.wrap(function _callee41$(_context41) {
7947
+ _args42 = arguments;
7948
+ return _regeneratorRuntime.wrap(function _callee42$(_context42) {
7715
7949
  while (1) {
7716
- switch (_context41.prev = _context41.next) {
7950
+ switch (_context42.prev = _context42.next) {
7717
7951
  case 0:
7718
- data = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : {};
7719
- _context41.next = 3;
7952
+ data = _args42.length > 0 && _args42[0] !== undefined ? _args42[0] : {};
7953
+ _context42.next = 3;
7720
7954
  return this.post(this.baseURL + '/channels/read', _objectSpread({}, data));
7721
7955
 
7722
7956
  case 3:
7723
7957
  case "end":
7724
- return _context41.stop();
7958
+ return _context42.stop();
7725
7959
  }
7726
7960
  }
7727
- }, _callee41, this);
7961
+ }, _callee42, this);
7728
7962
  }));
7729
7963
 
7730
- function markAllRead() {
7731
- return _markAllRead.apply(this, arguments);
7964
+ function markChannelsRead() {
7965
+ return _markChannelsRead.apply(this, arguments);
7732
7966
  }
7733
7967
 
7734
- return markAllRead;
7968
+ return markChannelsRead;
7735
7969
  }()
7736
7970
  }, {
7737
7971
  key: "createCommand",
@@ -7799,28 +8033,28 @@ var StreamChat = /*#__PURE__*/function () {
7799
8033
  }, {
7800
8034
  key: "translateMessage",
7801
8035
  value: function () {
7802
- var _translateMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42(messageId, language) {
7803
- return _regeneratorRuntime.wrap(function _callee42$(_context42) {
8036
+ var _translateMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(messageId, language) {
8037
+ return _regeneratorRuntime.wrap(function _callee43$(_context43) {
7804
8038
  while (1) {
7805
- switch (_context42.prev = _context42.next) {
8039
+ switch (_context43.prev = _context43.next) {
7806
8040
  case 0:
7807
- _context42.next = 2;
8041
+ _context43.next = 2;
7808
8042
  return this.post(this.baseURL + "/messages/".concat(messageId, "/translate"), {
7809
8043
  language: language
7810
8044
  });
7811
8045
 
7812
8046
  case 2:
7813
- return _context42.abrupt("return", _context42.sent);
8047
+ return _context43.abrupt("return", _context43.sent);
7814
8048
 
7815
8049
  case 3:
7816
8050
  case "end":
7817
- return _context42.stop();
8051
+ return _context43.stop();
7818
8052
  }
7819
8053
  }
7820
- }, _callee42, this);
8054
+ }, _callee43, this);
7821
8055
  }));
7822
8056
 
7823
- function translateMessage(_x53, _x54) {
8057
+ function translateMessage(_x55, _x56) {
7824
8058
  return _translateMessage.apply(this, arguments);
7825
8059
  }
7826
8060
 
@@ -7912,6 +8146,7 @@ var StreamChat = /*#__PURE__*/function () {
7912
8146
  *
7913
8147
  * @param {Omit<MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>, 'mentioned_users'> & { mentioned_users?: string[] }} message object, id needs to be specified
7914
8148
  * @param {string | { id: string }} [userId]
8149
+ * @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
7915
8150
  *
7916
8151
  * @return {APIResponse & { message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType> }} Response that includes the message
7917
8152
  */
@@ -7919,14 +8154,14 @@ var StreamChat = /*#__PURE__*/function () {
7919
8154
  }, {
7920
8155
  key: "updateMessage",
7921
8156
  value: function () {
7922
- var _updateMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(message, userId) {
8157
+ var _updateMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(message, userId, options) {
7923
8158
  var clonedMessage, reservedMessageFields;
7924
- return _regeneratorRuntime.wrap(function _callee43$(_context43) {
8159
+ return _regeneratorRuntime.wrap(function _callee44$(_context44) {
7925
8160
  while (1) {
7926
- switch (_context43.prev = _context43.next) {
8161
+ switch (_context44.prev = _context44.next) {
7927
8162
  case 0:
7928
8163
  if (message.id) {
7929
- _context43.next = 2;
8164
+ _context44.next = 2;
7930
8165
  break;
7931
8166
  }
7932
8167
 
@@ -7963,23 +8198,23 @@ var StreamChat = /*#__PURE__*/function () {
7963
8198
  });
7964
8199
  }
7965
8200
 
7966
- _context43.next = 10;
7967
- return this.post(this.baseURL + "/messages/".concat(message.id), {
8201
+ _context44.next = 10;
8202
+ return this.post(this.baseURL + "/messages/".concat(message.id), _objectSpread({
7968
8203
  message: clonedMessage
7969
- });
8204
+ }, options));
7970
8205
 
7971
8206
  case 10:
7972
- return _context43.abrupt("return", _context43.sent);
8207
+ return _context44.abrupt("return", _context44.sent);
7973
8208
 
7974
8209
  case 11:
7975
8210
  case "end":
7976
- return _context43.stop();
8211
+ return _context44.stop();
7977
8212
  }
7978
8213
  }
7979
- }, _callee43, this);
8214
+ }, _callee44, this);
7980
8215
  }));
7981
8216
 
7982
- function updateMessage(_x55, _x56) {
8217
+ function updateMessage(_x57, _x58, _x59) {
7983
8218
  return _updateMessage.apply(this, arguments);
7984
8219
  }
7985
8220
 
@@ -7994,20 +8229,22 @@ var StreamChat = /*#__PURE__*/function () {
7994
8229
  * example: {id: "user1", set:{text: "hi"}, unset:["color"]}
7995
8230
  * @param {string | { id: string }} [userId]
7996
8231
  *
8232
+ * @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
8233
+ *
7997
8234
  * @return {APIResponse & { message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType> }} Response that includes the updated message
7998
8235
  */
7999
8236
 
8000
8237
  }, {
8001
8238
  key: "partialUpdateMessage",
8002
8239
  value: function () {
8003
- var _partialUpdateMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(id, partialMessageObject, userId) {
8240
+ var _partialUpdateMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45(id, partialMessageObject, userId, options) {
8004
8241
  var user;
8005
- return _regeneratorRuntime.wrap(function _callee44$(_context44) {
8242
+ return _regeneratorRuntime.wrap(function _callee45$(_context45) {
8006
8243
  while (1) {
8007
- switch (_context44.prev = _context44.next) {
8244
+ switch (_context45.prev = _context45.next) {
8008
8245
  case 0:
8009
8246
  if (id) {
8010
- _context44.next = 2;
8247
+ _context45.next = 2;
8011
8248
  break;
8012
8249
  }
8013
8250
 
@@ -8022,23 +8259,23 @@ var StreamChat = /*#__PURE__*/function () {
8022
8259
  };
8023
8260
  }
8024
8261
 
8025
- _context44.next = 6;
8026
- return this.put(this.baseURL + "/messages/".concat(id), _objectSpread(_objectSpread({}, partialMessageObject), {}, {
8262
+ _context45.next = 6;
8263
+ return this.put(this.baseURL + "/messages/".concat(id), _objectSpread(_objectSpread(_objectSpread({}, partialMessageObject), options), {}, {
8027
8264
  user: user
8028
8265
  }));
8029
8266
 
8030
8267
  case 6:
8031
- return _context44.abrupt("return", _context44.sent);
8268
+ return _context45.abrupt("return", _context45.sent);
8032
8269
 
8033
8270
  case 7:
8034
8271
  case "end":
8035
- return _context44.stop();
8272
+ return _context45.stop();
8036
8273
  }
8037
8274
  }
8038
- }, _callee44, this);
8275
+ }, _callee45, this);
8039
8276
  }));
8040
8277
 
8041
- function partialUpdateMessage(_x57, _x58, _x59) {
8278
+ function partialUpdateMessage(_x60, _x61, _x62, _x63) {
8042
8279
  return _partialUpdateMessage.apply(this, arguments);
8043
8280
  }
8044
8281
 
@@ -8047,11 +8284,11 @@ var StreamChat = /*#__PURE__*/function () {
8047
8284
  }, {
8048
8285
  key: "deleteMessage",
8049
8286
  value: function () {
8050
- var _deleteMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45(messageID, hardDelete) {
8287
+ var _deleteMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46(messageID, hardDelete) {
8051
8288
  var params;
8052
- return _regeneratorRuntime.wrap(function _callee45$(_context45) {
8289
+ return _regeneratorRuntime.wrap(function _callee46$(_context46) {
8053
8290
  while (1) {
8054
- switch (_context45.prev = _context45.next) {
8291
+ switch (_context46.prev = _context46.next) {
8055
8292
  case 0:
8056
8293
  params = {};
8057
8294
 
@@ -8061,21 +8298,21 @@ var StreamChat = /*#__PURE__*/function () {
8061
8298
  };
8062
8299
  }
8063
8300
 
8064
- _context45.next = 4;
8301
+ _context46.next = 4;
8065
8302
  return this.delete(this.baseURL + "/messages/".concat(messageID), params);
8066
8303
 
8067
8304
  case 4:
8068
- return _context45.abrupt("return", _context45.sent);
8305
+ return _context46.abrupt("return", _context46.sent);
8069
8306
 
8070
8307
  case 5:
8071
8308
  case "end":
8072
- return _context45.stop();
8309
+ return _context46.stop();
8073
8310
  }
8074
8311
  }
8075
- }, _callee45, this);
8312
+ }, _callee46, this);
8076
8313
  }));
8077
8314
 
8078
- function deleteMessage(_x60, _x61) {
8315
+ function deleteMessage(_x64, _x65) {
8079
8316
  return _deleteMessage.apply(this, arguments);
8080
8317
  }
8081
8318
 
@@ -8084,26 +8321,26 @@ var StreamChat = /*#__PURE__*/function () {
8084
8321
  }, {
8085
8322
  key: "getMessage",
8086
8323
  value: function () {
8087
- var _getMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46(messageID) {
8088
- return _regeneratorRuntime.wrap(function _callee46$(_context46) {
8324
+ var _getMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee47(messageID) {
8325
+ return _regeneratorRuntime.wrap(function _callee47$(_context47) {
8089
8326
  while (1) {
8090
- switch (_context46.prev = _context46.next) {
8327
+ switch (_context47.prev = _context47.next) {
8091
8328
  case 0:
8092
- _context46.next = 2;
8329
+ _context47.next = 2;
8093
8330
  return this.get(this.baseURL + "/messages/".concat(messageID));
8094
8331
 
8095
8332
  case 2:
8096
- return _context46.abrupt("return", _context46.sent);
8333
+ return _context47.abrupt("return", _context47.sent);
8097
8334
 
8098
8335
  case 3:
8099
8336
  case "end":
8100
- return _context46.stop();
8337
+ return _context47.stop();
8101
8338
  }
8102
8339
  }
8103
- }, _callee46, this);
8340
+ }, _callee47, this);
8104
8341
  }));
8105
8342
 
8106
- function getMessage(_x62) {
8343
+ function getMessage(_x66) {
8107
8344
  return _getMessage.apply(this, arguments);
8108
8345
  }
8109
8346
 
@@ -8112,7 +8349,7 @@ var StreamChat = /*#__PURE__*/function () {
8112
8349
  }, {
8113
8350
  key: "getUserAgent",
8114
8351
  value: function getUserAgent() {
8115
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.1.0");
8352
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.4.0");
8116
8353
  }
8117
8354
  }, {
8118
8355
  key: "setUserAgent",
@@ -8293,28 +8530,28 @@ var StreamChat = /*#__PURE__*/function () {
8293
8530
  }, {
8294
8531
  key: "sendUserCustomEvent",
8295
8532
  value: function () {
8296
- var _sendUserCustomEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee47(targetUserID, event) {
8297
- return _regeneratorRuntime.wrap(function _callee47$(_context47) {
8533
+ var _sendUserCustomEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee48(targetUserID, event) {
8534
+ return _regeneratorRuntime.wrap(function _callee48$(_context48) {
8298
8535
  while (1) {
8299
- switch (_context47.prev = _context47.next) {
8536
+ switch (_context48.prev = _context48.next) {
8300
8537
  case 0:
8301
- _context47.next = 2;
8538
+ _context48.next = 2;
8302
8539
  return this.post("".concat(this.baseURL, "/users/").concat(targetUserID, "/event"), {
8303
8540
  event: event
8304
8541
  });
8305
8542
 
8306
8543
  case 2:
8307
- return _context47.abrupt("return", _context47.sent);
8544
+ return _context48.abrupt("return", _context48.sent);
8308
8545
 
8309
8546
  case 3:
8310
8547
  case "end":
8311
- return _context47.stop();
8548
+ return _context48.stop();
8312
8549
  }
8313
8550
  }
8314
- }, _callee47, this);
8551
+ }, _callee48, this);
8315
8552
  }));
8316
8553
 
8317
- function sendUserCustomEvent(_x63, _x64) {
8554
+ function sendUserCustomEvent(_x67, _x68) {
8318
8555
  return _sendUserCustomEvent.apply(this, arguments);
8319
8556
  }
8320
8557
 
@@ -8348,15 +8585,18 @@ var StreamChat = /*#__PURE__*/function () {
8348
8585
  }, {
8349
8586
  key: "exportChannels",
8350
8587
  value: function exportChannels(request) {
8351
- var payload = {
8588
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8589
+
8590
+ var payload = _objectSpread({
8352
8591
  channels: request
8353
- };
8592
+ }, options);
8593
+
8354
8594
  return this.post("".concat(this.baseURL, "/export_channels"), payload);
8355
8595
  }
8356
8596
  }, {
8357
8597
  key: "exportChannel",
8358
- value: function exportChannel(request) {
8359
- return this.exportChannels([request]);
8598
+ value: function exportChannel(request, options) {
8599
+ return this.exportChannels([request], options);
8360
8600
  }
8361
8601
  }, {
8362
8602
  key: "getExportChannelStatus",
@@ -8374,32 +8614,32 @@ var StreamChat = /*#__PURE__*/function () {
8374
8614
  }, {
8375
8615
  key: "createSegment",
8376
8616
  value: function () {
8377
- var _createSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee48(params) {
8617
+ var _createSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee49(params) {
8378
8618
  var _yield$this$post, segment;
8379
8619
 
8380
- return _regeneratorRuntime.wrap(function _callee48$(_context48) {
8620
+ return _regeneratorRuntime.wrap(function _callee49$(_context49) {
8381
8621
  while (1) {
8382
- switch (_context48.prev = _context48.next) {
8622
+ switch (_context49.prev = _context49.next) {
8383
8623
  case 0:
8384
- _context48.next = 2;
8624
+ _context49.next = 2;
8385
8625
  return this.post(this.baseURL + "/segments", {
8386
8626
  segment: params
8387
8627
  });
8388
8628
 
8389
8629
  case 2:
8390
- _yield$this$post = _context48.sent;
8630
+ _yield$this$post = _context49.sent;
8391
8631
  segment = _yield$this$post.segment;
8392
- return _context48.abrupt("return", segment);
8632
+ return _context49.abrupt("return", segment);
8393
8633
 
8394
8634
  case 5:
8395
8635
  case "end":
8396
- return _context48.stop();
8636
+ return _context49.stop();
8397
8637
  }
8398
8638
  }
8399
- }, _callee48, this);
8639
+ }, _callee49, this);
8400
8640
  }));
8401
8641
 
8402
- function createSegment(_x65) {
8642
+ function createSegment(_x69) {
8403
8643
  return _createSegment.apply(this, arguments);
8404
8644
  }
8405
8645
 
@@ -8416,30 +8656,30 @@ var StreamChat = /*#__PURE__*/function () {
8416
8656
  }, {
8417
8657
  key: "getSegment",
8418
8658
  value: function () {
8419
- var _getSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee49(id) {
8659
+ var _getSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee50(id) {
8420
8660
  var _yield$this$get, segment;
8421
8661
 
8422
- return _regeneratorRuntime.wrap(function _callee49$(_context49) {
8662
+ return _regeneratorRuntime.wrap(function _callee50$(_context50) {
8423
8663
  while (1) {
8424
- switch (_context49.prev = _context49.next) {
8664
+ switch (_context50.prev = _context50.next) {
8425
8665
  case 0:
8426
- _context49.next = 2;
8666
+ _context50.next = 2;
8427
8667
  return this.get(this.baseURL + "/segments/".concat(id));
8428
8668
 
8429
8669
  case 2:
8430
- _yield$this$get = _context49.sent;
8670
+ _yield$this$get = _context50.sent;
8431
8671
  segment = _yield$this$get.segment;
8432
- return _context49.abrupt("return", segment);
8672
+ return _context50.abrupt("return", segment);
8433
8673
 
8434
8674
  case 5:
8435
8675
  case "end":
8436
- return _context49.stop();
8676
+ return _context50.stop();
8437
8677
  }
8438
8678
  }
8439
- }, _callee49, this);
8679
+ }, _callee50, this);
8440
8680
  }));
8441
8681
 
8442
- function getSegment(_x66) {
8682
+ function getSegment(_x70) {
8443
8683
  return _getSegment.apply(this, arguments);
8444
8684
  }
8445
8685
 
@@ -8455,30 +8695,30 @@ var StreamChat = /*#__PURE__*/function () {
8455
8695
  }, {
8456
8696
  key: "listSegments",
8457
8697
  value: function () {
8458
- var _listSegments = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee50(options) {
8698
+ var _listSegments = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee51(options) {
8459
8699
  var _yield$this$get2, segments;
8460
8700
 
8461
- return _regeneratorRuntime.wrap(function _callee50$(_context50) {
8701
+ return _regeneratorRuntime.wrap(function _callee51$(_context51) {
8462
8702
  while (1) {
8463
- switch (_context50.prev = _context50.next) {
8703
+ switch (_context51.prev = _context51.next) {
8464
8704
  case 0:
8465
- _context50.next = 2;
8705
+ _context51.next = 2;
8466
8706
  return this.get(this.baseURL + "/segments", options);
8467
8707
 
8468
8708
  case 2:
8469
- _yield$this$get2 = _context50.sent;
8709
+ _yield$this$get2 = _context51.sent;
8470
8710
  segments = _yield$this$get2.segments;
8471
- return _context50.abrupt("return", segments);
8711
+ return _context51.abrupt("return", segments);
8472
8712
 
8473
8713
  case 5:
8474
8714
  case "end":
8475
- return _context50.stop();
8715
+ return _context51.stop();
8476
8716
  }
8477
8717
  }
8478
- }, _callee50, this);
8718
+ }, _callee51, this);
8479
8719
  }));
8480
8720
 
8481
- function listSegments(_x67) {
8721
+ function listSegments(_x71) {
8482
8722
  return _listSegments.apply(this, arguments);
8483
8723
  }
8484
8724
 
@@ -8496,32 +8736,32 @@ var StreamChat = /*#__PURE__*/function () {
8496
8736
  }, {
8497
8737
  key: "updateSegment",
8498
8738
  value: function () {
8499
- var _updateSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee51(id, params) {
8739
+ var _updateSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee52(id, params) {
8500
8740
  var _yield$this$put, segment;
8501
8741
 
8502
- return _regeneratorRuntime.wrap(function _callee51$(_context51) {
8742
+ return _regeneratorRuntime.wrap(function _callee52$(_context52) {
8503
8743
  while (1) {
8504
- switch (_context51.prev = _context51.next) {
8744
+ switch (_context52.prev = _context52.next) {
8505
8745
  case 0:
8506
- _context51.next = 2;
8746
+ _context52.next = 2;
8507
8747
  return this.put(this.baseURL + "/segments/".concat(id), {
8508
8748
  segment: params
8509
8749
  });
8510
8750
 
8511
8751
  case 2:
8512
- _yield$this$put = _context51.sent;
8752
+ _yield$this$put = _context52.sent;
8513
8753
  segment = _yield$this$put.segment;
8514
- return _context51.abrupt("return", segment);
8754
+ return _context52.abrupt("return", segment);
8515
8755
 
8516
8756
  case 5:
8517
8757
  case "end":
8518
- return _context51.stop();
8758
+ return _context52.stop();
8519
8759
  }
8520
8760
  }
8521
- }, _callee51, this);
8761
+ }, _callee52, this);
8522
8762
  }));
8523
8763
 
8524
- function updateSegment(_x68, _x69) {
8764
+ function updateSegment(_x72, _x73) {
8525
8765
  return _updateSegment.apply(this, arguments);
8526
8766
  }
8527
8767
 
@@ -8538,22 +8778,22 @@ var StreamChat = /*#__PURE__*/function () {
8538
8778
  }, {
8539
8779
  key: "deleteSegment",
8540
8780
  value: function () {
8541
- var _deleteSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee52(id) {
8542
- return _regeneratorRuntime.wrap(function _callee52$(_context52) {
8781
+ var _deleteSegment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee53(id) {
8782
+ return _regeneratorRuntime.wrap(function _callee53$(_context53) {
8543
8783
  while (1) {
8544
- switch (_context52.prev = _context52.next) {
8784
+ switch (_context53.prev = _context53.next) {
8545
8785
  case 0:
8546
- return _context52.abrupt("return", this.delete(this.baseURL + "/segments/".concat(id)));
8786
+ return _context53.abrupt("return", this.delete(this.baseURL + "/segments/".concat(id)));
8547
8787
 
8548
8788
  case 1:
8549
8789
  case "end":
8550
- return _context52.stop();
8790
+ return _context53.stop();
8551
8791
  }
8552
8792
  }
8553
- }, _callee52, this);
8793
+ }, _callee53, this);
8554
8794
  }));
8555
8795
 
8556
- function deleteSegment(_x70) {
8796
+ function deleteSegment(_x74) {
8557
8797
  return _deleteSegment.apply(this, arguments);
8558
8798
  }
8559
8799
 
@@ -8570,32 +8810,32 @@ var StreamChat = /*#__PURE__*/function () {
8570
8810
  }, {
8571
8811
  key: "createCampaign",
8572
8812
  value: function () {
8573
- var _createCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee53(params) {
8813
+ var _createCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee54(params) {
8574
8814
  var _yield$this$post2, campaign;
8575
8815
 
8576
- return _regeneratorRuntime.wrap(function _callee53$(_context53) {
8816
+ return _regeneratorRuntime.wrap(function _callee54$(_context54) {
8577
8817
  while (1) {
8578
- switch (_context53.prev = _context53.next) {
8818
+ switch (_context54.prev = _context54.next) {
8579
8819
  case 0:
8580
- _context53.next = 2;
8820
+ _context54.next = 2;
8581
8821
  return this.post(this.baseURL + "/campaigns", {
8582
8822
  campaign: params
8583
8823
  });
8584
8824
 
8585
8825
  case 2:
8586
- _yield$this$post2 = _context53.sent;
8826
+ _yield$this$post2 = _context54.sent;
8587
8827
  campaign = _yield$this$post2.campaign;
8588
- return _context53.abrupt("return", campaign);
8828
+ return _context54.abrupt("return", campaign);
8589
8829
 
8590
8830
  case 5:
8591
8831
  case "end":
8592
- return _context53.stop();
8832
+ return _context54.stop();
8593
8833
  }
8594
8834
  }
8595
- }, _callee53, this);
8835
+ }, _callee54, this);
8596
8836
  }));
8597
8837
 
8598
- function createCampaign(_x71) {
8838
+ function createCampaign(_x75) {
8599
8839
  return _createCampaign.apply(this, arguments);
8600
8840
  }
8601
8841
 
@@ -8612,30 +8852,30 @@ var StreamChat = /*#__PURE__*/function () {
8612
8852
  }, {
8613
8853
  key: "getCampaign",
8614
8854
  value: function () {
8615
- var _getCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee54(id) {
8855
+ var _getCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee55(id) {
8616
8856
  var _yield$this$get3, campaign;
8617
8857
 
8618
- return _regeneratorRuntime.wrap(function _callee54$(_context54) {
8858
+ return _regeneratorRuntime.wrap(function _callee55$(_context55) {
8619
8859
  while (1) {
8620
- switch (_context54.prev = _context54.next) {
8860
+ switch (_context55.prev = _context55.next) {
8621
8861
  case 0:
8622
- _context54.next = 2;
8862
+ _context55.next = 2;
8623
8863
  return this.get(this.baseURL + "/campaigns/".concat(id));
8624
8864
 
8625
8865
  case 2:
8626
- _yield$this$get3 = _context54.sent;
8866
+ _yield$this$get3 = _context55.sent;
8627
8867
  campaign = _yield$this$get3.campaign;
8628
- return _context54.abrupt("return", campaign);
8868
+ return _context55.abrupt("return", campaign);
8629
8869
 
8630
8870
  case 5:
8631
8871
  case "end":
8632
- return _context54.stop();
8872
+ return _context55.stop();
8633
8873
  }
8634
8874
  }
8635
- }, _callee54, this);
8875
+ }, _callee55, this);
8636
8876
  }));
8637
8877
 
8638
- function getCampaign(_x72) {
8878
+ function getCampaign(_x76) {
8639
8879
  return _getCampaign.apply(this, arguments);
8640
8880
  }
8641
8881
 
@@ -8651,30 +8891,30 @@ var StreamChat = /*#__PURE__*/function () {
8651
8891
  }, {
8652
8892
  key: "listCampaigns",
8653
8893
  value: function () {
8654
- var _listCampaigns = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee55(options) {
8894
+ var _listCampaigns = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee56(options) {
8655
8895
  var _yield$this$get4, campaigns;
8656
8896
 
8657
- return _regeneratorRuntime.wrap(function _callee55$(_context55) {
8897
+ return _regeneratorRuntime.wrap(function _callee56$(_context56) {
8658
8898
  while (1) {
8659
- switch (_context55.prev = _context55.next) {
8899
+ switch (_context56.prev = _context56.next) {
8660
8900
  case 0:
8661
- _context55.next = 2;
8901
+ _context56.next = 2;
8662
8902
  return this.get(this.baseURL + "/campaigns", options);
8663
8903
 
8664
8904
  case 2:
8665
- _yield$this$get4 = _context55.sent;
8905
+ _yield$this$get4 = _context56.sent;
8666
8906
  campaigns = _yield$this$get4.campaigns;
8667
- return _context55.abrupt("return", campaigns);
8907
+ return _context56.abrupt("return", campaigns);
8668
8908
 
8669
8909
  case 5:
8670
8910
  case "end":
8671
- return _context55.stop();
8911
+ return _context56.stop();
8672
8912
  }
8673
8913
  }
8674
- }, _callee55, this);
8914
+ }, _callee56, this);
8675
8915
  }));
8676
8916
 
8677
- function listCampaigns(_x73) {
8917
+ function listCampaigns(_x77) {
8678
8918
  return _listCampaigns.apply(this, arguments);
8679
8919
  }
8680
8920
 
@@ -8692,32 +8932,32 @@ var StreamChat = /*#__PURE__*/function () {
8692
8932
  }, {
8693
8933
  key: "updateCampaign",
8694
8934
  value: function () {
8695
- var _updateCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee56(id, params) {
8935
+ var _updateCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee57(id, params) {
8696
8936
  var _yield$this$put2, campaign;
8697
8937
 
8698
- return _regeneratorRuntime.wrap(function _callee56$(_context56) {
8938
+ return _regeneratorRuntime.wrap(function _callee57$(_context57) {
8699
8939
  while (1) {
8700
- switch (_context56.prev = _context56.next) {
8940
+ switch (_context57.prev = _context57.next) {
8701
8941
  case 0:
8702
- _context56.next = 2;
8942
+ _context57.next = 2;
8703
8943
  return this.put(this.baseURL + "/campaigns/".concat(id), {
8704
8944
  campaign: params
8705
8945
  });
8706
8946
 
8707
8947
  case 2:
8708
- _yield$this$put2 = _context56.sent;
8948
+ _yield$this$put2 = _context57.sent;
8709
8949
  campaign = _yield$this$put2.campaign;
8710
- return _context56.abrupt("return", campaign);
8950
+ return _context57.abrupt("return", campaign);
8711
8951
 
8712
8952
  case 5:
8713
8953
  case "end":
8714
- return _context56.stop();
8954
+ return _context57.stop();
8715
8955
  }
8716
8956
  }
8717
- }, _callee56, this);
8957
+ }, _callee57, this);
8718
8958
  }));
8719
8959
 
8720
- function updateCampaign(_x74, _x75) {
8960
+ function updateCampaign(_x78, _x79) {
8721
8961
  return _updateCampaign.apply(this, arguments);
8722
8962
  }
8723
8963
 
@@ -8734,22 +8974,22 @@ var StreamChat = /*#__PURE__*/function () {
8734
8974
  }, {
8735
8975
  key: "deleteCampaign",
8736
8976
  value: function () {
8737
- var _deleteCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee57(id) {
8738
- return _regeneratorRuntime.wrap(function _callee57$(_context57) {
8977
+ var _deleteCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee58(id) {
8978
+ return _regeneratorRuntime.wrap(function _callee58$(_context58) {
8739
8979
  while (1) {
8740
- switch (_context57.prev = _context57.next) {
8980
+ switch (_context58.prev = _context58.next) {
8741
8981
  case 0:
8742
- return _context57.abrupt("return", this.delete(this.baseURL + "/campaigns/".concat(id)));
8982
+ return _context58.abrupt("return", this.delete(this.baseURL + "/campaigns/".concat(id)));
8743
8983
 
8744
8984
  case 1:
8745
8985
  case "end":
8746
- return _context57.stop();
8986
+ return _context58.stop();
8747
8987
  }
8748
8988
  }
8749
- }, _callee57, this);
8989
+ }, _callee58, this);
8750
8990
  }));
8751
8991
 
8752
- function deleteCampaign(_x76) {
8992
+ function deleteCampaign(_x80) {
8753
8993
  return _deleteCampaign.apply(this, arguments);
8754
8994
  }
8755
8995
 
@@ -8767,33 +9007,33 @@ var StreamChat = /*#__PURE__*/function () {
8767
9007
  }, {
8768
9008
  key: "scheduleCampaign",
8769
9009
  value: function () {
8770
- var _scheduleCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee58(id, params) {
9010
+ var _scheduleCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee59(id, params) {
8771
9011
  var sendAt, _yield$this$patch, campaign;
8772
9012
 
8773
- return _regeneratorRuntime.wrap(function _callee58$(_context58) {
9013
+ return _regeneratorRuntime.wrap(function _callee59$(_context59) {
8774
9014
  while (1) {
8775
- switch (_context58.prev = _context58.next) {
9015
+ switch (_context59.prev = _context59.next) {
8776
9016
  case 0:
8777
9017
  sendAt = params.sendAt;
8778
- _context58.next = 3;
9018
+ _context59.next = 3;
8779
9019
  return this.patch(this.baseURL + "/campaigns/".concat(id, "/schedule"), {
8780
9020
  send_at: sendAt
8781
9021
  });
8782
9022
 
8783
9023
  case 3:
8784
- _yield$this$patch = _context58.sent;
9024
+ _yield$this$patch = _context59.sent;
8785
9025
  campaign = _yield$this$patch.campaign;
8786
- return _context58.abrupt("return", campaign);
9026
+ return _context59.abrupt("return", campaign);
8787
9027
 
8788
9028
  case 6:
8789
9029
  case "end":
8790
- return _context58.stop();
9030
+ return _context59.stop();
8791
9031
  }
8792
9032
  }
8793
- }, _callee58, this);
9033
+ }, _callee59, this);
8794
9034
  }));
8795
9035
 
8796
- function scheduleCampaign(_x77, _x78) {
9036
+ function scheduleCampaign(_x81, _x82) {
8797
9037
  return _scheduleCampaign.apply(this, arguments);
8798
9038
  }
8799
9039
 
@@ -8810,30 +9050,30 @@ var StreamChat = /*#__PURE__*/function () {
8810
9050
  }, {
8811
9051
  key: "stopCampaign",
8812
9052
  value: function () {
8813
- var _stopCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee59(id) {
9053
+ var _stopCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee60(id) {
8814
9054
  var _yield$this$patch2, campaign;
8815
9055
 
8816
- return _regeneratorRuntime.wrap(function _callee59$(_context59) {
9056
+ return _regeneratorRuntime.wrap(function _callee60$(_context60) {
8817
9057
  while (1) {
8818
- switch (_context59.prev = _context59.next) {
9058
+ switch (_context60.prev = _context60.next) {
8819
9059
  case 0:
8820
- _context59.next = 2;
9060
+ _context60.next = 2;
8821
9061
  return this.patch(this.baseURL + "/campaigns/".concat(id, "/stop"));
8822
9062
 
8823
9063
  case 2:
8824
- _yield$this$patch2 = _context59.sent;
9064
+ _yield$this$patch2 = _context60.sent;
8825
9065
  campaign = _yield$this$patch2.campaign;
8826
- return _context59.abrupt("return", campaign);
9066
+ return _context60.abrupt("return", campaign);
8827
9067
 
8828
9068
  case 5:
8829
9069
  case "end":
8830
- return _context59.stop();
9070
+ return _context60.stop();
8831
9071
  }
8832
9072
  }
8833
- }, _callee59, this);
9073
+ }, _callee60, this);
8834
9074
  }));
8835
9075
 
8836
- function stopCampaign(_x79) {
9076
+ function stopCampaign(_x83) {
8837
9077
  return _stopCampaign.apply(this, arguments);
8838
9078
  }
8839
9079
 
@@ -8850,30 +9090,30 @@ var StreamChat = /*#__PURE__*/function () {
8850
9090
  }, {
8851
9091
  key: "resumeCampaign",
8852
9092
  value: function () {
8853
- var _resumeCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee60(id) {
9093
+ var _resumeCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee61(id) {
8854
9094
  var _yield$this$patch3, campaign;
8855
9095
 
8856
- return _regeneratorRuntime.wrap(function _callee60$(_context60) {
9096
+ return _regeneratorRuntime.wrap(function _callee61$(_context61) {
8857
9097
  while (1) {
8858
- switch (_context60.prev = _context60.next) {
9098
+ switch (_context61.prev = _context61.next) {
8859
9099
  case 0:
8860
- _context60.next = 2;
9100
+ _context61.next = 2;
8861
9101
  return this.patch(this.baseURL + "/campaigns/".concat(id, "/resume"));
8862
9102
 
8863
9103
  case 2:
8864
- _yield$this$patch3 = _context60.sent;
9104
+ _yield$this$patch3 = _context61.sent;
8865
9105
  campaign = _yield$this$patch3.campaign;
8866
- return _context60.abrupt("return", campaign);
9106
+ return _context61.abrupt("return", campaign);
8867
9107
 
8868
9108
  case 5:
8869
9109
  case "end":
8870
- return _context60.stop();
9110
+ return _context61.stop();
8871
9111
  }
8872
9112
  }
8873
- }, _callee60, this);
9113
+ }, _callee61, this);
8874
9114
  }));
8875
9115
 
8876
- function resumeCampaign(_x80) {
9116
+ function resumeCampaign(_x84) {
8877
9117
  return _resumeCampaign.apply(this, arguments);
8878
9118
  }
8879
9119
 
@@ -8890,38 +9130,208 @@ var StreamChat = /*#__PURE__*/function () {
8890
9130
  }, {
8891
9131
  key: "testCampaign",
8892
9132
  value: function () {
8893
- var _testCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee61(id, params) {
9133
+ var _testCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee62(id, params) {
8894
9134
  var users, _yield$this$post3, campaign;
8895
9135
 
8896
- return _regeneratorRuntime.wrap(function _callee61$(_context61) {
9136
+ return _regeneratorRuntime.wrap(function _callee62$(_context62) {
8897
9137
  while (1) {
8898
- switch (_context61.prev = _context61.next) {
9138
+ switch (_context62.prev = _context62.next) {
8899
9139
  case 0:
8900
9140
  users = params.users;
8901
- _context61.next = 3;
9141
+ _context62.next = 3;
8902
9142
  return this.post(this.baseURL + "/campaigns/".concat(id, "/test"), {
8903
9143
  users: users
8904
9144
  });
8905
9145
 
8906
9146
  case 3:
8907
- _yield$this$post3 = _context61.sent;
9147
+ _yield$this$post3 = _context62.sent;
8908
9148
  campaign = _yield$this$post3.campaign;
8909
- return _context61.abrupt("return", campaign);
9149
+ return _context62.abrupt("return", campaign);
8910
9150
 
8911
9151
  case 6:
8912
9152
  case "end":
8913
- return _context61.stop();
9153
+ return _context62.stop();
8914
9154
  }
8915
9155
  }
8916
- }, _callee61, this);
9156
+ }, _callee62, this);
8917
9157
  }));
8918
9158
 
8919
- function testCampaign(_x81, _x82) {
9159
+ function testCampaign(_x85, _x86) {
8920
9160
  return _testCampaign.apply(this, arguments);
8921
9161
  }
8922
9162
 
8923
9163
  return testCampaign;
8924
9164
  }()
9165
+ /**
9166
+ * enrichURL - Get OpenGraph data of the given link
9167
+ *
9168
+ * @param {string} url link
9169
+ * @return {OGAttachment} OG Attachment
9170
+ */
9171
+
9172
+ }, {
9173
+ key: "enrichURL",
9174
+ value: function () {
9175
+ var _enrichURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee63(url) {
9176
+ return _regeneratorRuntime.wrap(function _callee63$(_context63) {
9177
+ while (1) {
9178
+ switch (_context63.prev = _context63.next) {
9179
+ case 0:
9180
+ return _context63.abrupt("return", this.get(this.baseURL + "/og", {
9181
+ url: url
9182
+ }));
9183
+
9184
+ case 1:
9185
+ case "end":
9186
+ return _context63.stop();
9187
+ }
9188
+ }
9189
+ }, _callee63, this);
9190
+ }));
9191
+
9192
+ function enrichURL(_x87) {
9193
+ return _enrichURL.apply(this, arguments);
9194
+ }
9195
+
9196
+ return enrichURL;
9197
+ }()
9198
+ /**
9199
+ * getTask - Gets status of a long running task
9200
+ *
9201
+ * @param {string} id Task ID
9202
+ *
9203
+ * @return {TaskStatus} The task status
9204
+ */
9205
+
9206
+ }, {
9207
+ key: "getTask",
9208
+ value: function () {
9209
+ var _getTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee64(id) {
9210
+ return _regeneratorRuntime.wrap(function _callee64$(_context64) {
9211
+ while (1) {
9212
+ switch (_context64.prev = _context64.next) {
9213
+ case 0:
9214
+ return _context64.abrupt("return", this.get("".concat(this.baseURL, "/tasks/").concat(id)));
9215
+
9216
+ case 1:
9217
+ case "end":
9218
+ return _context64.stop();
9219
+ }
9220
+ }
9221
+ }, _callee64, this);
9222
+ }));
9223
+
9224
+ function getTask(_x88) {
9225
+ return _getTask.apply(this, arguments);
9226
+ }
9227
+
9228
+ return getTask;
9229
+ }()
9230
+ /**
9231
+ * deleteChannels - Deletes a list of channel
9232
+ *
9233
+ * @param {string[]} cids Channel CIDs
9234
+ * @param {boolean} [options.hard_delete] Defines if the channel is hard deleted or not
9235
+ *
9236
+ * @return {DeleteChannelsResponse} Result of the soft deletion, if server-side, it holds the task ID as well
9237
+ */
9238
+
9239
+ }, {
9240
+ key: "deleteChannels",
9241
+ value: function () {
9242
+ var _deleteChannels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee65(cids) {
9243
+ var options,
9244
+ _args65 = arguments;
9245
+ return _regeneratorRuntime.wrap(function _callee65$(_context65) {
9246
+ while (1) {
9247
+ switch (_context65.prev = _context65.next) {
9248
+ case 0:
9249
+ options = _args65.length > 1 && _args65[1] !== undefined ? _args65[1] : {};
9250
+ _context65.next = 3;
9251
+ return this.post(this.baseURL + "/channels/delete", _objectSpread({
9252
+ cids: cids
9253
+ }, options));
9254
+
9255
+ case 3:
9256
+ return _context65.abrupt("return", _context65.sent);
9257
+
9258
+ case 4:
9259
+ case "end":
9260
+ return _context65.stop();
9261
+ }
9262
+ }
9263
+ }, _callee65, this);
9264
+ }));
9265
+
9266
+ function deleteChannels(_x89) {
9267
+ return _deleteChannels.apply(this, arguments);
9268
+ }
9269
+
9270
+ return deleteChannels;
9271
+ }()
9272
+ }, {
9273
+ key: "deleteUsers",
9274
+ value:
9275
+ /**
9276
+ * deleteUsers - Batch Delete Users
9277
+ *
9278
+ * @param {string[]} user_ids which users to delete
9279
+ * @param {DeleteUserOptions} options Configuration how to delete users
9280
+ *
9281
+ * @return {APIResponse} A task ID
9282
+ */
9283
+ function () {
9284
+ var _deleteUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(user_ids, options) {
9285
+ return _regeneratorRuntime.wrap(function _callee66$(_context66) {
9286
+ while (1) {
9287
+ switch (_context66.prev = _context66.next) {
9288
+ case 0:
9289
+ if (!((options === null || options === void 0 ? void 0 : options.user) !== 'soft' && (options === null || options === void 0 ? void 0 : options.user) !== 'hard')) {
9290
+ _context66.next = 2;
9291
+ break;
9292
+ }
9293
+
9294
+ throw new Error('Invalid delete user options. user must be one of [soft hard]');
9295
+
9296
+ case 2:
9297
+ if (!(options.messages !== undefined && options.messages !== 'soft' && options.messages !== 'hard')) {
9298
+ _context66.next = 4;
9299
+ break;
9300
+ }
9301
+
9302
+ throw new Error('Invalid delete user options. messages must be one of [soft hard]');
9303
+
9304
+ case 4:
9305
+ if (!(options.conversations !== undefined && options.conversations !== 'soft' && options.conversations !== 'hard')) {
9306
+ _context66.next = 6;
9307
+ break;
9308
+ }
9309
+
9310
+ throw new Error('Invalid delete user options. conversations must be one of [soft hard]');
9311
+
9312
+ case 6:
9313
+ _context66.next = 8;
9314
+ return this.post(this.baseURL + "/users/delete", _objectSpread({
9315
+ user_ids: user_ids
9316
+ }, options));
9317
+
9318
+ case 8:
9319
+ return _context66.abrupt("return", _context66.sent);
9320
+
9321
+ case 9:
9322
+ case "end":
9323
+ return _context66.stop();
9324
+ }
9325
+ }
9326
+ }, _callee66, this);
9327
+ }));
9328
+
9329
+ function deleteUsers(_x90, _x91) {
9330
+ return _deleteUsers.apply(this, arguments);
9331
+ }
9332
+
9333
+ return deleteUsers;
9334
+ }()
8925
9335
  }], [{
8926
9336
  key: "getInstance",
8927
9337
  value: function getInstance(key, secretOrOptions, options) {