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.
@@ -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
 
@@ -25046,11 +25078,11 @@ var StreamChat = class _StreamChat extends ChatApi {
25046
25078
  return this.userAgent;
25047
25079
  }
25048
25080
  if (!this.cachedUserAgent) {
25049
- const version = "10.0.1";
25081
+ const version2 = readInjectedVersion();
25050
25082
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
25051
25083
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
25052
25084
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
25053
- const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version}` : `stream-chat-js-v${version}-${this.node ? "node" : "browser"}`;
25085
+ const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version2}` : `stream-chat-js-v${version2}-${this.node ? "node" : "browser"}`;
25054
25086
  this.cachedUserAgent = [
25055
25087
  head,
25056
25088
  // Each only when a value is present.
@@ -25059,7 +25091,7 @@ var StreamChat = class _StreamChat extends ChatApi {
25059
25091
  app_version: appVersion,
25060
25092
  os,
25061
25093
  device_model: deviceModel,
25062
- client_bundle: "browser-esm"
25094
+ client_bundle: readInjectedClientBundle()
25063
25095
  }).filter(([, value]) => value && value.length > 0).map(([key, value]) => `${key}=${value}`)
25064
25096
  ].join("|");
25065
25097
  }
@@ -25722,16 +25754,29 @@ var StreamChat = class _StreamChat extends ChatApi {
25722
25754
  };
25723
25755
  }
25724
25756
  /**
25725
- * 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.
25726
25763
  *
25727
25764
  * @param targetUserId - The user to unban.
25728
25765
  * @param options - Unban options (optional).
25729
25766
  * @returns The server response.
25730
25767
  */
25731
25768
  async unbanUser(targetUserId, options) {
25732
- return await this.api.delete(this.baseURL + "/moderation/ban", {
25733
- target_user_id: targetUserId,
25734
- ...options
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
25735
25780
  });
25736
25781
  }
25737
25782
  async blockUser(blockedUserId, requestOptions) {
@@ -28107,6 +28152,7 @@ export {
28107
28152
  textIsEmpty,
28108
28153
  textStartsWithCommand,
28109
28154
  timeLeftMs,
28155
+ version,
28110
28156
  withCancellation,
28111
28157
  withoutConcurrency
28112
28158
  };