stream-chat 6.4.0 → 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.
- package/dist/browser.es.js +137 -41
- 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 +142 -40
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +137 -41
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +142 -40
- package/dist/index.js.map +1 -1
- package/dist/types/client.d.ts +38 -35
- 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 +30 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/client.ts +50 -38
- package/src/errors.ts +7 -0
- package/src/events.ts +1 -0
- package/src/types.ts +71 -4
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,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; } } }; }
|
|
@@ -5962,7 +6047,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5962
6047
|
}());
|
|
5963
6048
|
|
|
5964
6049
|
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5965
|
-
var _this$wsConnection3, _this$wsFallback3;
|
|
6050
|
+
var _this$wsConnection3, _this$wsConnection4, _this$wsFallback3;
|
|
5966
6051
|
|
|
5967
6052
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
5968
6053
|
while (1) {
|
|
@@ -5976,18 +6061,30 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5976
6061
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5977
6062
|
|
|
5978
6063
|
case 2:
|
|
5979
|
-
if (!((
|
|
6064
|
+
if (!((_this$wsConnection3 = _this.wsConnection) !== null && _this$wsConnection3 !== void 0 && _this$wsConnection3.isConnecting)) {
|
|
5980
6065
|
_context3.next = 5;
|
|
5981
6066
|
break;
|
|
5982
6067
|
}
|
|
5983
6068
|
|
|
5984
|
-
_this.logger('info', 'client:openConnection() -
|
|
6069
|
+
_this.logger('info', 'client:openConnection() - connection already in progress', {
|
|
5985
6070
|
tags: ['connection', 'client']
|
|
5986
6071
|
});
|
|
5987
6072
|
|
|
5988
6073
|
return _context3.abrupt("return", Promise.resolve());
|
|
5989
6074
|
|
|
5990
6075
|
case 5:
|
|
6076
|
+
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())) {
|
|
6077
|
+
_context3.next = 8;
|
|
6078
|
+
break;
|
|
6079
|
+
}
|
|
6080
|
+
|
|
6081
|
+
_this.logger('info', 'client:openConnection() - openConnection called twice, healthy connection already exists', {
|
|
6082
|
+
tags: ['connection', 'client']
|
|
6083
|
+
});
|
|
6084
|
+
|
|
6085
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
6086
|
+
|
|
6087
|
+
case 8:
|
|
5991
6088
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
5992
6089
|
_this.wsPromise = _this.connect();
|
|
5993
6090
|
|
|
@@ -5995,7 +6092,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5995
6092
|
|
|
5996
6093
|
return _context3.abrupt("return", _this.wsPromise);
|
|
5997
6094
|
|
|
5998
|
-
case
|
|
6095
|
+
case 12:
|
|
5999
6096
|
case "end":
|
|
6000
6097
|
return _context3.stop();
|
|
6001
6098
|
}
|
|
@@ -6705,26 +6802,27 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6705
6802
|
* updateAppSettings - updates application settings
|
|
6706
6803
|
*
|
|
6707
6804
|
* @param {AppSettings} options App settings.
|
|
6708
|
-
*
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6805
|
+
* IE: {
|
|
6806
|
+
'apn_config': {
|
|
6807
|
+
'auth_type': 'token',
|
|
6808
|
+
'auth_key": fs.readFileSync(
|
|
6809
|
+
'./apn-push-auth-key.p8',
|
|
6810
|
+
'utf-8',
|
|
6811
|
+
),
|
|
6812
|
+
'key_id': 'keyid',
|
|
6813
|
+
'team_id': 'teamid',
|
|
6814
|
+
'notification_template": 'notification handlebars template',
|
|
6815
|
+
'bundle_id': 'com.apple.your.app',
|
|
6816
|
+
'development': true
|
|
6817
|
+
},
|
|
6818
|
+
'firebase_config': {
|
|
6819
|
+
'server_key': 'server key from fcm',
|
|
6820
|
+
'notification_template': 'notification handlebars template',
|
|
6821
|
+
'data_template': 'data handlebars template',
|
|
6822
|
+
'apn_template': 'apn notification handlebars template under v2'
|
|
6823
|
+
},
|
|
6824
|
+
'webhook_url': 'https://acme.com/my/awesome/webhook/'
|
|
6825
|
+
}
|
|
6728
6826
|
*/
|
|
6729
6827
|
function () {
|
|
6730
6828
|
var _updateAppSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(options) {
|
|
@@ -7089,7 +7187,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7089
7187
|
}()
|
|
7090
7188
|
/**
|
|
7091
7189
|
* createToken - Creates a token to authenticate this user. This function is used server side.
|
|
7092
|
-
* The resulting token should be passed to the client side when the users registers or logs in
|
|
7190
|
+
* The resulting token should be passed to the client side when the users registers or logs in.
|
|
7093
7191
|
*
|
|
7094
7192
|
* @param {string} userID The User ID
|
|
7095
7193
|
* @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
|
|
@@ -7267,7 +7365,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7267
7365
|
key: "errorFromResponse",
|
|
7268
7366
|
value: function errorFromResponse(response) {
|
|
7269
7367
|
var err;
|
|
7270
|
-
err = new
|
|
7368
|
+
err = new ErrorFromResponse("StreamChat error HTTP code: ".concat(response.status));
|
|
7271
7369
|
|
|
7272
7370
|
if (response.data && response.data.code) {
|
|
7273
7371
|
err = new Error("StreamChat error code ".concat(response.data.code, ": ").concat(response.data.message));
|
|
@@ -7283,7 +7381,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7283
7381
|
value: function handleResponse(response) {
|
|
7284
7382
|
var data = response.data;
|
|
7285
7383
|
|
|
7286
|
-
if ((response
|
|
7384
|
+
if (isErrorResponse(response)) {
|
|
7287
7385
|
throw this.errorFromResponse(response);
|
|
7288
7386
|
}
|
|
7289
7387
|
|
|
@@ -7341,7 +7439,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7341
7439
|
this.mutedUsers = event.me.mutes;
|
|
7342
7440
|
}
|
|
7343
7441
|
|
|
7344
|
-
if (event.type === 'notification.mark_read') {
|
|
7442
|
+
if (event.type === 'notification.mark_read' && event.unread_channels === 0) {
|
|
7345
7443
|
var activeChannelKeys = Object.keys(this.activeChannels);
|
|
7346
7444
|
activeChannelKeys.forEach(function (activeChannelKey) {
|
|
7347
7445
|
return _this3.activeChannels[activeChannelKey].state.unreadCount = 0;
|
|
@@ -9525,7 +9623,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9525
9623
|
}, {
|
|
9526
9624
|
key: "getUserAgent",
|
|
9527
9625
|
value: function getUserAgent() {
|
|
9528
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "6.
|
|
9626
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "6.6.0");
|
|
9529
9627
|
}
|
|
9530
9628
|
}, {
|
|
9531
9629
|
key: "setUserAgent",
|
|
@@ -10194,7 +10292,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10194
10292
|
* scheduleCampaign - Schedule a Campaign
|
|
10195
10293
|
*
|
|
10196
10294
|
* @param {string} id Campaign ID
|
|
10197
|
-
* @param {{
|
|
10295
|
+
* @param {{scheduledFor: number}} params Schedule params
|
|
10198
10296
|
*
|
|
10199
10297
|
* @return {Campaign} Scheduled Campaign
|
|
10200
10298
|
*/
|
|
@@ -10203,16 +10301,16 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10203
10301
|
key: "scheduleCampaign",
|
|
10204
10302
|
value: function () {
|
|
10205
10303
|
var _scheduleCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee63(id, params) {
|
|
10206
|
-
var
|
|
10304
|
+
var scheduledFor, _yield$this$patch, campaign;
|
|
10207
10305
|
|
|
10208
10306
|
return _regeneratorRuntime.wrap(function _callee63$(_context63) {
|
|
10209
10307
|
while (1) {
|
|
10210
10308
|
switch (_context63.prev = _context63.next) {
|
|
10211
10309
|
case 0:
|
|
10212
|
-
|
|
10310
|
+
scheduledFor = params.scheduledFor;
|
|
10213
10311
|
_context63.next = 3;
|
|
10214
10312
|
return this.patch(this.baseURL + "/campaigns/".concat(id, "/schedule"), {
|
|
10215
|
-
|
|
10313
|
+
scheduled_for: scheduledFor
|
|
10216
10314
|
});
|
|
10217
10315
|
|
|
10218
10316
|
case 3:
|
|
@@ -10319,15 +10417,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10319
10417
|
*
|
|
10320
10418
|
* @param {string} id Campaign ID
|
|
10321
10419
|
* @param {{users: string[]}} params Test params
|
|
10322
|
-
*
|
|
10420
|
+
*
|
|
10421
|
+
* @return {TestCampaignResponse} Test campaign response
|
|
10323
10422
|
*/
|
|
10324
10423
|
|
|
10325
10424
|
}, {
|
|
10326
10425
|
key: "testCampaign",
|
|
10327
10426
|
value: function () {
|
|
10328
10427
|
var _testCampaign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(id, params) {
|
|
10329
|
-
var users
|
|
10330
|
-
|
|
10428
|
+
var users;
|
|
10331
10429
|
return _regeneratorRuntime.wrap(function _callee66$(_context66) {
|
|
10332
10430
|
while (1) {
|
|
10333
10431
|
switch (_context66.prev = _context66.next) {
|
|
@@ -10339,11 +10437,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10339
10437
|
});
|
|
10340
10438
|
|
|
10341
10439
|
case 3:
|
|
10342
|
-
|
|
10343
|
-
campaign = _yield$this$post3.campaign;
|
|
10344
|
-
return _context66.abrupt("return", campaign);
|
|
10440
|
+
return _context66.abrupt("return", _context66.sent);
|
|
10345
10441
|
|
|
10346
|
-
case
|
|
10442
|
+
case 4:
|
|
10347
10443
|
case "end":
|
|
10348
10444
|
return _context66.stop();
|
|
10349
10445
|
}
|
|
@@ -10909,5 +11005,5 @@ var BuiltinPermissions = {
|
|
|
10909
11005
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
10910
11006
|
};
|
|
10911
11007
|
|
|
10912
|
-
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 };
|
|
10913
11009
|
//# sourceMappingURL=browser.es.js.map
|