stream-chat 10.0.0 → 10.0.2
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/cjs/index.browser.js +60 -9
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +61 -9
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +60 -9
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/client.d.ts +6 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +3 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/version.d.ts +60 -0
- package/package.json +1 -1
- package/src/client.ts +26 -8
- package/src/index.ts +2 -0
- package/src/pagination/paginators/MessagePaginator.ts +7 -2
- package/src/types.ts +2 -2
- package/src/version.ts +98 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -1375,6 +1375,38 @@ var errorIsApiError = (error) => {
|
|
|
1375
1375
|
};
|
|
1376
1376
|
var isTokenExpiredError = (error) => errorIsApiError(error) && error.response?.data.code === chatCodes.TOKEN_EXPIRED;
|
|
1377
1377
|
|
|
1378
|
+
// src/version.ts
|
|
1379
|
+
var SEMVER_PATTERN = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+?)(?:\.(\d+))?)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1380
|
+
var parseVersion = (raw) => {
|
|
1381
|
+
const input = raw || "0.0.0-development";
|
|
1382
|
+
const [, major = 0, minor = 0, patch = 0, prerelease = null, prereleaseNumber] = SEMVER_PATTERN.exec(input) ?? [];
|
|
1383
|
+
return Object.freeze({
|
|
1384
|
+
major: Number(major),
|
|
1385
|
+
minor: Number(minor),
|
|
1386
|
+
patch: Number(patch),
|
|
1387
|
+
prerelease,
|
|
1388
|
+
prereleaseNumber: prereleaseNumber ? Number(prereleaseNumber) : null,
|
|
1389
|
+
raw: input
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
var readInjectedVersion = () => {
|
|
1393
|
+
try {
|
|
1394
|
+
return "10.0.2";
|
|
1395
|
+
} catch {
|
|
1396
|
+
return void 0;
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
var readInjectedClientBundle = () => {
|
|
1400
|
+
try {
|
|
1401
|
+
return "browser-esm";
|
|
1402
|
+
} catch {
|
|
1403
|
+
return void 0;
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
var version = /* @__PURE__ */ parseVersion(
|
|
1407
|
+
/* @__PURE__ */ readInjectedVersion()
|
|
1408
|
+
);
|
|
1409
|
+
|
|
1378
1410
|
// src/errors.ts
|
|
1379
1411
|
import { isAxiosError as isAxiosError2, isCancel } from "axios";
|
|
1380
1412
|
|
|
@@ -9743,13 +9775,18 @@ var MessagePaginator = class extends MessageIntervalPaginator {
|
|
|
9743
9775
|
/**
|
|
9744
9776
|
* A message the paginator does not hold yet, at or after {@link latestMessageAt} (as known before
|
|
9745
9777
|
* it arrives), while no loaded interval reaches the newest message. It is then the newest message,
|
|
9746
|
-
* so it starts the newest interval, as a page holding it would (see {@link pageReachesHead}).
|
|
9778
|
+
* so it starts the newest interval, as a page holding it would (see {@link pageReachesHead}). In a
|
|
9779
|
+
* channel whose newest page was loaded empty, with no newest message time known, any message is
|
|
9780
|
+
* the newest.
|
|
9747
9781
|
*/
|
|
9748
9782
|
isNewNewestMessage(message) {
|
|
9749
9783
|
if (this.anchoredHeadItem !== void 0 || this.getItem(message.id)) return false;
|
|
9750
9784
|
const latestMessageAt = this.latestMessageAt;
|
|
9785
|
+
if (latestMessageAt === null) {
|
|
9786
|
+
return this.items?.length === 0 && !this.hasMoreHead;
|
|
9787
|
+
}
|
|
9751
9788
|
const createdAt = getMessageCreatedAtTimestamp(message);
|
|
9752
|
-
return
|
|
9789
|
+
return createdAt !== null && createdAt >= latestMessageAt;
|
|
9753
9790
|
}
|
|
9754
9791
|
/**
|
|
9755
9792
|
* The logical-head items (ingested one by one, usually from events, rather than as part of a
|
|
@@ -25041,11 +25078,11 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
25041
25078
|
return this.userAgent;
|
|
25042
25079
|
}
|
|
25043
25080
|
if (!this.cachedUserAgent) {
|
|
25044
|
-
const
|
|
25081
|
+
const version2 = readInjectedVersion();
|
|
25045
25082
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
25046
25083
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
25047
25084
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
25048
|
-
const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${
|
|
25085
|
+
const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version2}` : `stream-chat-js-v${version2}-${this.node ? "node" : "browser"}`;
|
|
25049
25086
|
this.cachedUserAgent = [
|
|
25050
25087
|
head,
|
|
25051
25088
|
// Each only when a value is present.
|
|
@@ -25054,7 +25091,7 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
25054
25091
|
app_version: appVersion,
|
|
25055
25092
|
os,
|
|
25056
25093
|
device_model: deviceModel,
|
|
25057
|
-
client_bundle:
|
|
25094
|
+
client_bundle: readInjectedClientBundle()
|
|
25058
25095
|
}).filter(([, value]) => value && value.length > 0).map(([key, value]) => `${key}=${value}`)
|
|
25059
25096
|
].join("|");
|
|
25060
25097
|
}
|
|
@@ -25717,16 +25754,29 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
25717
25754
|
};
|
|
25718
25755
|
}
|
|
25719
25756
|
/**
|
|
25720
|
-
* Revokes a global ban.
|
|
25757
|
+
* Revokes a global ban, or a channel ban when `options.type` and `options.id` name a channel.
|
|
25758
|
+
*
|
|
25759
|
+
* Goes through V2 `client.moderation.unban()`. The one exception is
|
|
25760
|
+
* `remove_future_channels_ban`, which that endpoint does not accept, so a call with it set still
|
|
25761
|
+
* goes to v1 `DELETE /moderation/ban`. `shadow` is accepted for compatibility but ignored: the
|
|
25762
|
+
* server lifts whichever ban is in place, shadow or not, on both endpoints.
|
|
25721
25763
|
*
|
|
25722
25764
|
* @param targetUserId - The user to unban.
|
|
25723
25765
|
* @param options - Unban options (optional).
|
|
25724
25766
|
* @returns The server response.
|
|
25725
25767
|
*/
|
|
25726
25768
|
async unbanUser(targetUserId, options) {
|
|
25727
|
-
|
|
25728
|
-
|
|
25729
|
-
|
|
25769
|
+
const { id, remove_future_channels_ban, type } = options ?? {};
|
|
25770
|
+
const target_user_id = options?.target_user_id ?? targetUserId;
|
|
25771
|
+
if (remove_future_channels_ban) {
|
|
25772
|
+
return await this.api.delete(this.baseURL + "/moderation/ban", {
|
|
25773
|
+
...options,
|
|
25774
|
+
target_user_id
|
|
25775
|
+
});
|
|
25776
|
+
}
|
|
25777
|
+
return await this.moderation.unban({
|
|
25778
|
+
target_user_id,
|
|
25779
|
+
channel_cid: type && id ? `${type}:${id}` : void 0
|
|
25730
25780
|
});
|
|
25731
25781
|
}
|
|
25732
25782
|
async blockUser(blockedUserId, requestOptions) {
|
|
@@ -28102,6 +28152,7 @@ export {
|
|
|
28102
28152
|
textIsEmpty,
|
|
28103
28153
|
textStartsWithCommand,
|
|
28104
28154
|
timeLeftMs,
|
|
28155
|
+
version,
|
|
28105
28156
|
withCancellation,
|
|
28106
28157
|
withoutConcurrency
|
|
28107
28158
|
};
|