stream-chat 10.0.1 → 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 "browser-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
 
@@ -25323,11 +25356,11 @@ var StreamChat = class _StreamChat extends ChatApi {
25323
25356
  return this.userAgent;
25324
25357
  }
25325
25358
  if (!this.cachedUserAgent) {
25326
- const version = "10.0.1";
25359
+ const version2 = readInjectedVersion();
25327
25360
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
25328
25361
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
25329
25362
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
25330
- 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"}`;
25331
25364
  this.cachedUserAgent = [
25332
25365
  head,
25333
25366
  // Each only when a value is present.
@@ -25336,7 +25369,7 @@ var StreamChat = class _StreamChat extends ChatApi {
25336
25369
  app_version: appVersion,
25337
25370
  os,
25338
25371
  device_model: deviceModel,
25339
- client_bundle: "browser-cjs"
25372
+ client_bundle: readInjectedClientBundle()
25340
25373
  }).filter(([, value]) => value && value.length > 0).map(([key, value]) => `${key}=${value}`)
25341
25374
  ].join("|");
25342
25375
  }
@@ -25999,16 +26032,29 @@ var StreamChat = class _StreamChat extends ChatApi {
25999
26032
  };
26000
26033
  }
26001
26034
  /**
26002
- * 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.
26003
26041
  *
26004
26042
  * @param targetUserId - The user to unban.
26005
26043
  * @param options - Unban options (optional).
26006
26044
  * @returns The server response.
26007
26045
  */
26008
26046
  async unbanUser(targetUserId, options) {
26009
- return await this.api.delete(this.baseURL + "/moderation/ban", {
26010
- target_user_id: targetUserId,
26011
- ...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
26012
26058
  });
26013
26059
  }
26014
26060
  async blockUser(blockedUserId, requestOptions) {