stream-chat 6.5.0 → 6.7.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/browser.es.js +117 -21
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +122 -20
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +117 -21
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +122 -20
- package/dist/index.js.map +1 -1
- package/dist/types/client.d.ts +11 -15
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/errors.d.ts +3 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/types.d.ts +26 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +29 -18
- package/src/errors.ts +7 -0
- package/src/events.ts +1 -0
- package/src/types.ts +32 -2
package/dist/browser.es.js
CHANGED
|
@@ -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,83 @@ 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
|
+
// Thumb URL(thumb_url) is added considering video attachments as the backend will return the thumbnail in the response.
|
|
5777
|
+
|
|
5778
|
+
/**
|
|
5779
|
+
* Option Types
|
|
5780
|
+
*/
|
|
5781
|
+
// TODO: rename to UpdateChannelOptions in the next major update and use it in channel._update and/or channel.update
|
|
5782
|
+
|
|
5783
|
+
/** @deprecated use MarkChannelsReadOptions instead */
|
|
5784
|
+
// TODO: rename to UpdateChannelTypeOptions in the next major update
|
|
5785
|
+
|
|
5786
|
+
/**
|
|
5787
|
+
* Event Types
|
|
5788
|
+
*/
|
|
5789
|
+
|
|
5790
|
+
/**
|
|
5791
|
+
* Filter Types
|
|
5792
|
+
*/
|
|
5793
|
+
|
|
5794
|
+
/**
|
|
5795
|
+
* Sort Types
|
|
5796
|
+
*/
|
|
5797
|
+
|
|
5798
|
+
/**
|
|
5799
|
+
* Base Types
|
|
5800
|
+
*/
|
|
5801
|
+
|
|
5802
|
+
/*
|
|
5803
|
+
DeleteUserOptions specifies a collection of one or more `user_ids` to be deleted.
|
|
5804
|
+
|
|
5805
|
+
`user` soft|hard determines if the user needs to be hard- or soft-deleted, where hard-delete
|
|
5806
|
+
implies that all related objects (messages, flags, etc) will be hard-deleted as well.
|
|
5807
|
+
`conversations` soft|hard will delete any 1to1 channels that the user was a member of.
|
|
5808
|
+
`messages` soft-hard will delete any messages that the user has sent.
|
|
5809
|
+
`new_channel_owner_id` any channels owned by the hard-deleted user will be transferred to this user ID
|
|
5810
|
+
*/
|
|
5811
|
+
var ErrorFromResponse = /*#__PURE__*/function (_Error) {
|
|
5812
|
+
_inherits(ErrorFromResponse, _Error);
|
|
5813
|
+
|
|
5814
|
+
var _super = _createSuper(ErrorFromResponse);
|
|
5815
|
+
|
|
5816
|
+
function ErrorFromResponse() {
|
|
5817
|
+
var _this;
|
|
5818
|
+
|
|
5819
|
+
_classCallCheck(this, ErrorFromResponse);
|
|
5820
|
+
|
|
5821
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5822
|
+
args[_key] = arguments[_key];
|
|
5823
|
+
}
|
|
5824
|
+
|
|
5825
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
5826
|
+
|
|
5827
|
+
_defineProperty(_assertThisInitialized(_this), "code", void 0);
|
|
5828
|
+
|
|
5829
|
+
_defineProperty(_assertThisInitialized(_this), "response", void 0);
|
|
5830
|
+
|
|
5831
|
+
_defineProperty(_assertThisInitialized(_this), "status", void 0);
|
|
5832
|
+
|
|
5833
|
+
return _this;
|
|
5834
|
+
}
|
|
5835
|
+
|
|
5836
|
+
return ErrorFromResponse;
|
|
5837
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
5838
|
+
|
|
5753
5839
|
var _excluded = ["created_at", "updated_at", "last_active", "online"];
|
|
5754
5840
|
|
|
5755
5841
|
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; } } }; }
|
|
@@ -5962,7 +6048,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5962
6048
|
}());
|
|
5963
6049
|
|
|
5964
6050
|
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5965
|
-
var _this$wsConnection3, _this$wsFallback3;
|
|
6051
|
+
var _this$wsConnection3, _this$wsConnection4, _this$wsFallback3;
|
|
5966
6052
|
|
|
5967
6053
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
5968
6054
|
while (1) {
|
|
@@ -5976,18 +6062,30 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5976
6062
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5977
6063
|
|
|
5978
6064
|
case 2:
|
|
5979
|
-
if (!((
|
|
6065
|
+
if (!((_this$wsConnection3 = _this.wsConnection) !== null && _this$wsConnection3 !== void 0 && _this$wsConnection3.isConnecting)) {
|
|
5980
6066
|
_context3.next = 5;
|
|
5981
6067
|
break;
|
|
5982
6068
|
}
|
|
5983
6069
|
|
|
5984
|
-
_this.logger('info', 'client:openConnection() -
|
|
6070
|
+
_this.logger('info', 'client:openConnection() - connection already in progress', {
|
|
5985
6071
|
tags: ['connection', 'client']
|
|
5986
6072
|
});
|
|
5987
6073
|
|
|
5988
6074
|
return _context3.abrupt("return", Promise.resolve());
|
|
5989
6075
|
|
|
5990
6076
|
case 5:
|
|
6077
|
+
if (!(((_this$wsConnection4 = _this.wsConnection) !== null && _this$wsConnection4 !== void 0 && _this$wsConnection4.isHealthy || (_this$wsFallback3 = _this.wsFallback) !== null && _this$wsFallback3 !== void 0 && _this$wsFallback3.isHealthy()) && _this._hasConnectionID())) {
|
|
6078
|
+
_context3.next = 8;
|
|
6079
|
+
break;
|
|
6080
|
+
}
|
|
6081
|
+
|
|
6082
|
+
_this.logger('info', 'client:openConnection() - openConnection called twice, healthy connection already exists', {
|
|
6083
|
+
tags: ['connection', 'client']
|
|
6084
|
+
});
|
|
6085
|
+
|
|
6086
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
6087
|
+
|
|
6088
|
+
case 8:
|
|
5991
6089
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
5992
6090
|
_this.wsPromise = _this.connect();
|
|
5993
6091
|
|
|
@@ -5995,7 +6093,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5995
6093
|
|
|
5996
6094
|
return _context3.abrupt("return", _this.wsPromise);
|
|
5997
6095
|
|
|
5998
|
-
case
|
|
6096
|
+
case 12:
|
|
5999
6097
|
case "end":
|
|
6000
6098
|
return _context3.stop();
|
|
6001
6099
|
}
|
|
@@ -6717,7 +6815,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6717
6815
|
'notification_template": 'notification handlebars template',
|
|
6718
6816
|
'bundle_id': 'com.apple.your.app',
|
|
6719
6817
|
'development': true
|
|
6720
|
-
|
|
6818
|
+
},
|
|
6721
6819
|
'firebase_config': {
|
|
6722
6820
|
'server_key': 'server key from fcm',
|
|
6723
6821
|
'notification_template': 'notification handlebars template',
|
|
@@ -7090,7 +7188,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7090
7188
|
}()
|
|
7091
7189
|
/**
|
|
7092
7190
|
* createToken - Creates a token to authenticate this user. This function is used server side.
|
|
7093
|
-
* The resulting token should be passed to the client side when the users registers or logs in
|
|
7191
|
+
* The resulting token should be passed to the client side when the users registers or logs in.
|
|
7094
7192
|
*
|
|
7095
7193
|
* @param {string} userID The User ID
|
|
7096
7194
|
* @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
|
|
@@ -7268,7 +7366,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7268
7366
|
key: "errorFromResponse",
|
|
7269
7367
|
value: function errorFromResponse(response) {
|
|
7270
7368
|
var err;
|
|
7271
|
-
err = new
|
|
7369
|
+
err = new ErrorFromResponse("StreamChat error HTTP code: ".concat(response.status));
|
|
7272
7370
|
|
|
7273
7371
|
if (response.data && response.data.code) {
|
|
7274
7372
|
err = new Error("StreamChat error code ".concat(response.data.code, ": ").concat(response.data.message));
|
|
@@ -7284,7 +7382,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7284
7382
|
value: function handleResponse(response) {
|
|
7285
7383
|
var data = response.data;
|
|
7286
7384
|
|
|
7287
|
-
if ((response
|
|
7385
|
+
if (isErrorResponse(response)) {
|
|
7288
7386
|
throw this.errorFromResponse(response);
|
|
7289
7387
|
}
|
|
7290
7388
|
|
|
@@ -9526,7 +9624,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9526
9624
|
}, {
|
|
9527
9625
|
key: "getUserAgent",
|
|
9528
9626
|
value: function getUserAgent() {
|
|
9529
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "6.
|
|
9627
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "6.7.0");
|
|
9530
9628
|
}
|
|
9531
9629
|
}, {
|
|
9532
9630
|
key: "setUserAgent",
|
|
@@ -10195,7 +10293,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10195
10293
|
* scheduleCampaign - Schedule a Campaign
|
|
10196
10294
|
*
|
|
10197
10295
|
* @param {string} id Campaign ID
|
|
10198
|
-
* @param {{
|
|
10296
|
+
* @param {{scheduledFor: number}} params Schedule params
|
|
10199
10297
|
*
|
|
10200
10298
|
* @return {Campaign} Scheduled Campaign
|
|
10201
10299
|
*/
|
|
@@ -10204,16 +10302,16 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10204
10302
|
key: "scheduleCampaign",
|
|
10205
10303
|
value: function () {
|
|
10206
10304
|
var _scheduleCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee63(id, params) {
|
|
10207
|
-
var
|
|
10305
|
+
var scheduledFor, _yield$this$patch, campaign;
|
|
10208
10306
|
|
|
10209
10307
|
return _regeneratorRuntime.wrap(function _callee63$(_context63) {
|
|
10210
10308
|
while (1) {
|
|
10211
10309
|
switch (_context63.prev = _context63.next) {
|
|
10212
10310
|
case 0:
|
|
10213
|
-
|
|
10311
|
+
scheduledFor = params.scheduledFor;
|
|
10214
10312
|
_context63.next = 3;
|
|
10215
10313
|
return this.patch(this.baseURL + "/campaigns/".concat(id, "/schedule"), {
|
|
10216
|
-
|
|
10314
|
+
scheduled_for: scheduledFor
|
|
10217
10315
|
});
|
|
10218
10316
|
|
|
10219
10317
|
case 3:
|
|
@@ -10320,15 +10418,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10320
10418
|
*
|
|
10321
10419
|
* @param {string} id Campaign ID
|
|
10322
10420
|
* @param {{users: string[]}} params Test params
|
|
10323
|
-
*
|
|
10421
|
+
*
|
|
10422
|
+
* @return {TestCampaignResponse} Test campaign response
|
|
10324
10423
|
*/
|
|
10325
10424
|
|
|
10326
10425
|
}, {
|
|
10327
10426
|
key: "testCampaign",
|
|
10328
10427
|
value: function () {
|
|
10329
10428
|
var _testCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(id, params) {
|
|
10330
|
-
var users
|
|
10331
|
-
|
|
10429
|
+
var users;
|
|
10332
10430
|
return _regeneratorRuntime.wrap(function _callee66$(_context66) {
|
|
10333
10431
|
while (1) {
|
|
10334
10432
|
switch (_context66.prev = _context66.next) {
|
|
@@ -10340,11 +10438,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10340
10438
|
});
|
|
10341
10439
|
|
|
10342
10440
|
case 3:
|
|
10343
|
-
|
|
10344
|
-
campaign = _yield$this$post3.campaign;
|
|
10345
|
-
return _context66.abrupt("return", campaign);
|
|
10441
|
+
return _context66.abrupt("return", _context66.sent);
|
|
10346
10442
|
|
|
10347
|
-
case
|
|
10443
|
+
case 4:
|
|
10348
10444
|
case "end":
|
|
10349
10445
|
return _context66.stop();
|
|
10350
10446
|
}
|
|
@@ -10910,5 +11006,5 @@ var BuiltinPermissions = {
|
|
|
10910
11006
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
10911
11007
|
};
|
|
10912
11008
|
|
|
10913
|
-
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 };
|
|
11009
|
+
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 };
|
|
10914
11010
|
//# sourceMappingURL=browser.es.js.map
|