stream-chat 6.5.1 → 6.6.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.
@@ -12,6 +12,11 @@ import axios from 'axios';
12
12
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
13
13
  import FormData from 'form-data';
14
14
  import WebSocket from 'isomorphic-ws';
15
+ import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
16
+ import _inherits from '@babel/runtime/helpers/inherits';
17
+ import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
18
+ import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
19
+ import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper';
15
20
 
16
21
  function isString$1(arrayOrString) {
17
22
  return typeof arrayOrString === 'string';
@@ -1065,6 +1070,7 @@ var EVENT_MAP = {
1065
1070
  'user.deleted': true,
1066
1071
  'user.presence.changed': true,
1067
1072
  'user.unbanned': true,
1073
+ 'user.unread_message_reminder': true,
1068
1074
  'user.updated': true,
1069
1075
  'user.watching.start': true,
1070
1076
  'user.watching.stop': true,
@@ -5373,6 +5379,9 @@ function isWSFailure(err) {
5373
5379
  return false;
5374
5380
  }
5375
5381
  }
5382
+ function isErrorResponse(res) {
5383
+ return !res.status || res.status < 200 || 300 <= res.status;
5384
+ }
5376
5385
 
5377
5386
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5378
5387
 
@@ -5750,6 +5759,82 @@ var WSConnectionFallback = /*#__PURE__*/function () {
5750
5759
  return WSConnectionFallback;
5751
5760
  }();
5752
5761
 
5762
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
5763
+
5764
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
5765
+
5766
+ /**
5767
+ * Utility Types
5768
+ */
5769
+
5770
+ /* Unknown Record */
5771
+ //alias to avoid breaking change
5772
+
5773
+ /**
5774
+ * Response Types
5775
+ */
5776
+
5777
+ /**
5778
+ * Option Types
5779
+ */
5780
+ // TODO: rename to UpdateChannelOptions in the next major update and use it in channel._update and/or channel.update
5781
+
5782
+ /** @deprecated use MarkChannelsReadOptions instead */
5783
+ // TODO: rename to UpdateChannelTypeOptions in the next major update
5784
+
5785
+ /**
5786
+ * Event Types
5787
+ */
5788
+
5789
+ /**
5790
+ * Filter Types
5791
+ */
5792
+
5793
+ /**
5794
+ * Sort Types
5795
+ */
5796
+
5797
+ /**
5798
+ * Base Types
5799
+ */
5800
+
5801
+ /*
5802
+ DeleteUserOptions specifies a collection of one or more `user_ids` to be deleted.
5803
+
5804
+ `user` soft|hard determines if the user needs to be hard- or soft-deleted, where hard-delete
5805
+ implies that all related objects (messages, flags, etc) will be hard-deleted as well.
5806
+ `conversations` soft|hard will delete any 1to1 channels that the user was a member of.
5807
+ `messages` soft-hard will delete any messages that the user has sent.
5808
+ `new_channel_owner_id` any channels owned by the hard-deleted user will be transferred to this user ID
5809
+ */
5810
+ var ErrorFromResponse = /*#__PURE__*/function (_Error) {
5811
+ _inherits(ErrorFromResponse, _Error);
5812
+
5813
+ var _super = _createSuper(ErrorFromResponse);
5814
+
5815
+ function ErrorFromResponse() {
5816
+ var _this;
5817
+
5818
+ _classCallCheck(this, ErrorFromResponse);
5819
+
5820
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5821
+ args[_key] = arguments[_key];
5822
+ }
5823
+
5824
+ _this = _super.call.apply(_super, [this].concat(args));
5825
+
5826
+ _defineProperty(_assertThisInitialized(_this), "code", void 0);
5827
+
5828
+ _defineProperty(_assertThisInitialized(_this), "response", void 0);
5829
+
5830
+ _defineProperty(_assertThisInitialized(_this), "status", void 0);
5831
+
5832
+ return _this;
5833
+ }
5834
+
5835
+ return ErrorFromResponse;
5836
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
5837
+
5753
5838
  var _excluded = ["created_at", "updated_at", "last_active", "online"];
5754
5839
 
5755
5840
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -6729,7 +6814,7 @@ var StreamChat = /*#__PURE__*/function () {
6729
6814
  'notification_template": 'notification handlebars template',
6730
6815
  'bundle_id': 'com.apple.your.app',
6731
6816
  'development': true
6732
- },
6817
+ },
6733
6818
  'firebase_config': {
6734
6819
  'server_key': 'server key from fcm',
6735
6820
  'notification_template': 'notification handlebars template',
@@ -7280,7 +7365,7 @@ var StreamChat = /*#__PURE__*/function () {
7280
7365
  key: "errorFromResponse",
7281
7366
  value: function errorFromResponse(response) {
7282
7367
  var err;
7283
- err = new Error("StreamChat error HTTP code: ".concat(response.status));
7368
+ err = new ErrorFromResponse("StreamChat error HTTP code: ".concat(response.status));
7284
7369
 
7285
7370
  if (response.data && response.data.code) {
7286
7371
  err = new Error("StreamChat error code ".concat(response.data.code, ": ").concat(response.data.message));
@@ -7296,7 +7381,7 @@ var StreamChat = /*#__PURE__*/function () {
7296
7381
  value: function handleResponse(response) {
7297
7382
  var data = response.data;
7298
7383
 
7299
- if ((response.status + '')[0] !== '2') {
7384
+ if (isErrorResponse(response)) {
7300
7385
  throw this.errorFromResponse(response);
7301
7386
  }
7302
7387
 
@@ -9538,7 +9623,7 @@ var StreamChat = /*#__PURE__*/function () {
9538
9623
  }, {
9539
9624
  key: "getUserAgent",
9540
9625
  value: function getUserAgent() {
9541
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "6.5.1");
9626
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "6.6.0");
9542
9627
  }
9543
9628
  }, {
9544
9629
  key: "setUserAgent",
@@ -10207,7 +10292,7 @@ var StreamChat = /*#__PURE__*/function () {
10207
10292
  * scheduleCampaign - Schedule a Campaign
10208
10293
  *
10209
10294
  * @param {string} id Campaign ID
10210
- * @param {{sendAt: number}} params Schedule params
10295
+ * @param {{scheduledFor: number}} params Schedule params
10211
10296
  *
10212
10297
  * @return {Campaign} Scheduled Campaign
10213
10298
  */
@@ -10216,16 +10301,16 @@ var StreamChat = /*#__PURE__*/function () {
10216
10301
  key: "scheduleCampaign",
10217
10302
  value: function () {
10218
10303
  var _scheduleCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee63(id, params) {
10219
- var sendAt, _yield$this$patch, campaign;
10304
+ var scheduledFor, _yield$this$patch, campaign;
10220
10305
 
10221
10306
  return _regeneratorRuntime.wrap(function _callee63$(_context63) {
10222
10307
  while (1) {
10223
10308
  switch (_context63.prev = _context63.next) {
10224
10309
  case 0:
10225
- sendAt = params.sendAt;
10310
+ scheduledFor = params.scheduledFor;
10226
10311
  _context63.next = 3;
10227
10312
  return this.patch(this.baseURL + "/campaigns/".concat(id, "/schedule"), {
10228
- send_at: sendAt
10313
+ scheduled_for: scheduledFor
10229
10314
  });
10230
10315
 
10231
10316
  case 3:
@@ -10332,15 +10417,15 @@ var StreamChat = /*#__PURE__*/function () {
10332
10417
  *
10333
10418
  * @param {string} id Campaign ID
10334
10419
  * @param {{users: string[]}} params Test params
10335
- * @return {Campaign} Test Campaign
10420
+ *
10421
+ * @return {TestCampaignResponse} Test campaign response
10336
10422
  */
10337
10423
 
10338
10424
  }, {
10339
10425
  key: "testCampaign",
10340
10426
  value: function () {
10341
10427
  var _testCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(id, params) {
10342
- var users, _yield$this$post3, campaign;
10343
-
10428
+ var users;
10344
10429
  return _regeneratorRuntime.wrap(function _callee66$(_context66) {
10345
10430
  while (1) {
10346
10431
  switch (_context66.prev = _context66.next) {
@@ -10352,11 +10437,9 @@ var StreamChat = /*#__PURE__*/function () {
10352
10437
  });
10353
10438
 
10354
10439
  case 3:
10355
- _yield$this$post3 = _context66.sent;
10356
- campaign = _yield$this$post3.campaign;
10357
- return _context66.abrupt("return", campaign);
10440
+ return _context66.abrupt("return", _context66.sent);
10358
10441
 
10359
- case 6:
10442
+ case 4:
10360
10443
  case "end":
10361
10444
  return _context66.stop();
10362
10445
  }
@@ -10922,5 +11005,5 @@ var BuiltinPermissions = {
10922
11005
  UseFrozenChannel: 'Send messages and reactions to frozen channels'
10923
11006
  };
10924
11007
 
10925
- export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, InsightMetrics, JWTServerToken, JWTUserToken, MaxPriority, MinPriority, Permission, StableWSConnection, StreamChat, TokenManager, UserFromToken, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, isOwnUser, isValidEventType, logChatPromiseExecution, postInsights };
11008
+ export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MaxPriority, MinPriority, Permission, StableWSConnection, StreamChat, TokenManager, UserFromToken, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, isOwnUser, isValidEventType, logChatPromiseExecution, postInsights };
10926
11009
  //# sourceMappingURL=browser.es.js.map