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.
@@ -270,6 +270,7 @@ __export(src_exports, {
270
270
  textIsEmpty: () => textIsEmpty,
271
271
  textStartsWithCommand: () => textStartsWithCommand,
272
272
  timeLeftMs: () => timeLeftMs,
273
+ version: () => version,
273
274
  withCancellation: () => withCancellation,
274
275
  withoutConcurrency: () => withoutConcurrency
275
276
  });
@@ -1652,6 +1653,38 @@ var errorIsApiError = (error) => {
1652
1653
  };
1653
1654
  var isTokenExpiredError = (error) => errorIsApiError(error) && error.response?.data.code === chatCodes.TOKEN_EXPIRED;
1654
1655
 
1656
+ // src/version.ts
1657
+ var SEMVER_PATTERN = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+?)(?:\.(\d+))?)?(?:\+[0-9A-Za-z.-]+)?$/;
1658
+ var parseVersion = (raw) => {
1659
+ const input = raw || "0.0.0-development";
1660
+ const [, major = 0, minor = 0, patch = 0, prerelease = null, prereleaseNumber] = SEMVER_PATTERN.exec(input) ?? [];
1661
+ return Object.freeze({
1662
+ major: Number(major),
1663
+ minor: Number(minor),
1664
+ patch: Number(patch),
1665
+ prerelease,
1666
+ prereleaseNumber: prereleaseNumber ? Number(prereleaseNumber) : null,
1667
+ raw: input
1668
+ });
1669
+ };
1670
+ var readInjectedVersion = () => {
1671
+ try {
1672
+ return "10.0.2";
1673
+ } catch {
1674
+ return void 0;
1675
+ }
1676
+ };
1677
+ var readInjectedClientBundle = () => {
1678
+ try {
1679
+ return "node-cjs";
1680
+ } catch {
1681
+ return void 0;
1682
+ }
1683
+ };
1684
+ var version = /* @__PURE__ */ parseVersion(
1685
+ /* @__PURE__ */ readInjectedVersion()
1686
+ );
1687
+
1655
1688
  // src/errors.ts
1656
1689
  var import_axios3 = require("axios");
1657
1690
 
@@ -10020,13 +10053,18 @@ var MessagePaginator = class extends MessageIntervalPaginator {
10020
10053
  /**
10021
10054
  * A message the paginator does not hold yet, at or after {@link latestMessageAt} (as known before
10022
10055
  * it arrives), while no loaded interval reaches the newest message. It is then the newest message,
10023
- * so it starts the newest interval, as a page holding it would (see {@link pageReachesHead}).
10056
+ * so it starts the newest interval, as a page holding it would (see {@link pageReachesHead}). In a
10057
+ * channel whose newest page was loaded empty, with no newest message time known, any message is
10058
+ * the newest.
10024
10059
  */
10025
10060
  isNewNewestMessage(message) {
10026
10061
  if (this.anchoredHeadItem !== void 0 || this.getItem(message.id)) return false;
10027
10062
  const latestMessageAt = this.latestMessageAt;
10063
+ if (latestMessageAt === null) {
10064
+ return this.items?.length === 0 && !this.hasMoreHead;
10065
+ }
10028
10066
  const createdAt = getMessageCreatedAtTimestamp(message);
10029
- return latestMessageAt !== null && createdAt !== null && createdAt >= latestMessageAt;
10067
+ return createdAt !== null && createdAt >= latestMessageAt;
10030
10068
  }
10031
10069
  /**
10032
10070
  * The logical-head items (ingested one by one, usually from events, rather than as part of a
@@ -25318,11 +25356,11 @@ var StreamChat = class _StreamChat extends ChatApi {
25318
25356
  return this.userAgent;
25319
25357
  }
25320
25358
  if (!this.cachedUserAgent) {
25321
- const version = "10.0.0";
25359
+ const version2 = readInjectedVersion();
25322
25360
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
25323
25361
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
25324
25362
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
25325
- const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version}` : `stream-chat-js-v${version}-${this.node ? "node" : "browser"}`;
25363
+ const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version2}` : `stream-chat-js-v${version2}-${this.node ? "node" : "browser"}`;
25326
25364
  this.cachedUserAgent = [
25327
25365
  head,
25328
25366
  // Each only when a value is present.
@@ -25331,7 +25369,7 @@ var StreamChat = class _StreamChat extends ChatApi {
25331
25369
  app_version: appVersion,
25332
25370
  os,
25333
25371
  device_model: deviceModel,
25334
- client_bundle: "node-cjs"
25372
+ client_bundle: readInjectedClientBundle()
25335
25373
  }).filter(([, value]) => value && value.length > 0).map(([key, value]) => `${key}=${value}`)
25336
25374
  ].join("|");
25337
25375
  }
@@ -25994,16 +26032,29 @@ var StreamChat = class _StreamChat extends ChatApi {
25994
26032
  };
25995
26033
  }
25996
26034
  /**
25997
- * Revokes a global ban.
26035
+ * Revokes a global ban, or a channel ban when `options.type` and `options.id` name a channel.
26036
+ *
26037
+ * Goes through V2 `client.moderation.unban()`. The one exception is
26038
+ * `remove_future_channels_ban`, which that endpoint does not accept, so a call with it set still
26039
+ * goes to v1 `DELETE /moderation/ban`. `shadow` is accepted for compatibility but ignored: the
26040
+ * server lifts whichever ban is in place, shadow or not, on both endpoints.
25998
26041
  *
25999
26042
  * @param targetUserId - The user to unban.
26000
26043
  * @param options - Unban options (optional).
26001
26044
  * @returns The server response.
26002
26045
  */
26003
26046
  async unbanUser(targetUserId, options) {
26004
- return await this.api.delete(this.baseURL + "/moderation/ban", {
26005
- target_user_id: targetUserId,
26006
- ...options
26047
+ const { id, remove_future_channels_ban, type } = options ?? {};
26048
+ const target_user_id = options?.target_user_id ?? targetUserId;
26049
+ if (remove_future_channels_ban) {
26050
+ return await this.api.delete(this.baseURL + "/moderation/ban", {
26051
+ ...options,
26052
+ target_user_id
26053
+ });
26054
+ }
26055
+ return await this.moderation.unban({
26056
+ target_user_id,
26057
+ channel_cid: type && id ? `${type}:${id}` : void 0
26007
26058
  });
26008
26059
  }
26009
26060
  async blockUser(blockedUserId, requestOptions) {
@@ -28380,6 +28431,7 @@ var LiveLocationManager = _LiveLocationManager;
28380
28431
  textIsEmpty,
28381
28432
  textStartsWithCommand,
28382
28433
  timeLeftMs,
28434
+ version,
28383
28435
  withCancellation,
28384
28436
  withoutConcurrency
28385
28437
  });