@valkey/valkey-glide 2.3.0-rc6 → 2.3.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.
@@ -95,6 +95,26 @@ export type StreamEntryDataType = Record<string, [GlideString, GlideString][]>;
95
95
  * Union type that can store either a number or positive/negative infinity.
96
96
  */
97
97
  export type Score = number | "+inf" | "-inf";
98
+ /**
99
+ * Constant representing "all channels" for unsubscribe operations.
100
+ * Use this to unsubscribe from all channel subscriptions at once.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * await client.unsubscribeLazy(ALL_CHANNELS);
105
+ * ```
106
+ */
107
+ export declare const ALL_CHANNELS: null;
108
+ /**
109
+ * Constant representing "all patterns" for punsubscribe operations.
110
+ * Use this to unsubscribe from all pattern subscriptions at once.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * await client.punsubscribeLazy(ALL_PATTERNS);
115
+ * ```
116
+ */
117
+ export declare const ALL_PATTERNS: null;
98
118
  /**
99
119
  * Data type which represents sorted sets data for input parameter of ZADD command,
100
120
  * including element and its respective score.
@@ -505,6 +525,32 @@ export interface AdvancedBaseClientConfiguration {
505
525
  * - If not explicitly set, a default value of `true` will be used by the Rust core.
506
526
  */
507
527
  tcpNoDelay?: boolean;
528
+ /**
529
+ * The interval in milliseconds between PubSub subscription reconciliation attempts.
530
+ *
531
+ * The reconciliation process ensures that the client's desired subscriptions match
532
+ * the actual subscriptions on the server. This is useful when subscriptions may have
533
+ * been lost due to network issues or server restarts.
534
+ *
535
+ * If not explicitly set, the Rust core will use its default reconciliation interval.
536
+ *
537
+ * @remarks
538
+ * - Must be a positive integer representing milliseconds.
539
+ * - The reconciliation process runs automatically in the background.
540
+ * - A lower interval provides faster recovery from subscription issues but increases overhead.
541
+ * - A higher interval reduces overhead but may delay recovery from subscription issues.
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * const config: GlideClientConfiguration = {
546
+ * addresses: [{ host: "localhost", port: 6379 }],
547
+ * advancedConfiguration: {
548
+ * pubsubReconciliationIntervalMs: 5000 // Reconcile every 5 seconds
549
+ * }
550
+ * };
551
+ * ```
552
+ */
553
+ pubsubReconciliationIntervalMs?: number;
508
554
  }
509
555
  /**
510
556
  * Enum of Valkey data types
@@ -6445,6 +6491,149 @@ export declare class BaseClient {
6445
6491
  * ```
6446
6492
  */
6447
6493
  refreshIamToken(): Promise<GlideString>;
6494
+ /**
6495
+ * Subscribes the client to the specified channels (non-blocking).
6496
+ * Returns immediately without waiting for subscription confirmation.
6497
+ *
6498
+ * @see {@link https://valkey.io/commands/subscribe/|valkey.io} for details.
6499
+ *
6500
+ * @param channels - A collection of channel names to subscribe to.
6501
+ * @param options - (Optional) See {@link DecoderOption}.
6502
+ * @returns A promise that resolves immediately.
6503
+ *
6504
+ * @example
6505
+ * ```typescript
6506
+ * await client.subscribeLazy(new Set(["news", "updates"]));
6507
+ * ```
6508
+ */
6509
+ subscribeLazy(channels: Iterable<GlideString>, options?: DecoderOption): Promise<void>;
6510
+ /**
6511
+ * Subscribes the client to the specified channels (blocking).
6512
+ * Waits for subscription confirmation or until timeout.
6513
+ *
6514
+ * @see {@link https://valkey.io/commands/subscribe/|valkey.io} for details.
6515
+ *
6516
+ * @param channels - A collection of channel names to subscribe to.
6517
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
6518
+ * @param options - (Optional) See {@link DecoderOption}.
6519
+ * @returns A promise that resolves when subscription is confirmed or timeout occurs.
6520
+ *
6521
+ * @example
6522
+ * ```typescript
6523
+ * // Wait up to 5 seconds
6524
+ * await client.subscribe(new Set(["news"]), 5000);
6525
+ * // Wait indefinitely
6526
+ * await client.subscribe(new Set(["news"]), 0);
6527
+ * ```
6528
+ */
6529
+ subscribe(channels: Iterable<GlideString>, timeoutMs: number, options?: DecoderOption): Promise<void>;
6530
+ /**
6531
+ * Subscribes the client to the specified patterns (non-blocking).
6532
+ * Returns immediately without waiting for subscription confirmation.
6533
+ *
6534
+ * @see {@link https://valkey.io/commands/psubscribe/|valkey.io} for details.
6535
+ *
6536
+ * @param patterns - An array of glob-style patterns to subscribe to.
6537
+ * @param options - (Optional) See {@link DecoderOption}.
6538
+ * @returns A promise that resolves immediately.
6539
+ *
6540
+ * @example
6541
+ * ```typescript
6542
+ * await client.psubscribeLazy(["news.*", "updates.*"]);
6543
+ * ```
6544
+ */
6545
+ psubscribeLazy(patterns: Iterable<GlideString>, options?: DecoderOption): Promise<void>;
6546
+ /**
6547
+ * Subscribes the client to the specified patterns (blocking).
6548
+ * Waits for subscription confirmation or until timeout.
6549
+ *
6550
+ * @see {@link https://valkey.io/commands/psubscribe/|valkey.io} for details.
6551
+ *
6552
+ * @param patterns - An array of glob-style patterns to subscribe to.
6553
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
6554
+ * @param options - (Optional) See {@link DecoderOption}.
6555
+ * @returns A promise that resolves when subscription is confirmed or timeout occurs.
6556
+ *
6557
+ * @example
6558
+ * ```typescript
6559
+ * await client.psubscribe(["news.*"], 5000);
6560
+ * ```
6561
+ */
6562
+ psubscribe(patterns: Iterable<GlideString>, timeoutMs: number, options?: DecoderOption): Promise<void>;
6563
+ /**
6564
+ * Unsubscribes the client from the specified channels (non-blocking).
6565
+ * Pass null or ALL_CHANNELS to unsubscribe from all exact channels.
6566
+ *
6567
+ * @see {@link https://valkey.io/commands/unsubscribe/|valkey.io} for details.
6568
+ *
6569
+ * @param channels - Channel names to unsubscribe from, or null for all channels.
6570
+ * @param options - (Optional) See {@link DecoderOption}.
6571
+ * @returns A promise that resolves immediately.
6572
+ *
6573
+ * @example
6574
+ * ```typescript
6575
+ * await client.unsubscribeLazy(new Set(["news"]));
6576
+ * // Unsubscribe from all channels
6577
+ * await client.unsubscribeLazy(ALL_CHANNELS);
6578
+ * ```
6579
+ */
6580
+ unsubscribeLazy(channels?: Iterable<GlideString> | null, options?: DecoderOption): Promise<void>;
6581
+ /**
6582
+ * Unsubscribes the client from the specified channels (blocking).
6583
+ * Pass null or ALL_CHANNELS to unsubscribe from all exact channels.
6584
+ *
6585
+ * @see {@link https://valkey.io/commands/unsubscribe/|valkey.io} for details.
6586
+ *
6587
+ * @param channels - Channel names to unsubscribe from, or null for all channels.
6588
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
6589
+ * @param options - (Optional) See {@link DecoderOption}.
6590
+ * @returns A promise that resolves when unsubscription is confirmed or timeout occurs.
6591
+ *
6592
+ * @example
6593
+ * ```typescript
6594
+ * await client.unsubscribe(new Set(["news"]), 5000);
6595
+ * // Unsubscribe from all channels with timeout
6596
+ * await client.unsubscribe(ALL_CHANNELS, 5000);
6597
+ * ```
6598
+ */
6599
+ unsubscribe(channels: Iterable<GlideString> | null, timeoutMs: number, options?: DecoderOption): Promise<void>;
6600
+ /**
6601
+ * Unsubscribes the client from the specified patterns (non-blocking).
6602
+ * Pass null or ALL_PATTERNS to unsubscribe from all patterns.
6603
+ *
6604
+ * @see {@link https://valkey.io/commands/punsubscribe/|valkey.io} for details.
6605
+ *
6606
+ * @param patterns - Pattern names to unsubscribe from, or null for all patterns.
6607
+ * @param options - (Optional) See {@link DecoderOption}.
6608
+ * @returns A promise that resolves immediately.
6609
+ *
6610
+ * @example
6611
+ * ```typescript
6612
+ * await client.punsubscribeLazy(new Set(["news.*"]));
6613
+ * // Unsubscribe from all patterns
6614
+ * await client.punsubscribeLazy(ALL_PATTERNS);
6615
+ * ```
6616
+ */
6617
+ punsubscribeLazy(patterns?: Iterable<GlideString> | null, options?: DecoderOption): Promise<void>;
6618
+ /**
6619
+ * Unsubscribes the client from the specified patterns (blocking).
6620
+ * Pass null or ALL_PATTERNS to unsubscribe from all patterns.
6621
+ *
6622
+ * @see {@link https://valkey.io/commands/punsubscribe/|valkey.io} for details.
6623
+ *
6624
+ * @param patterns - Pattern names to unsubscribe from, or null for all patterns.
6625
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
6626
+ * @param options - (Optional) See {@link DecoderOption}.
6627
+ * @returns A promise that resolves when unsubscription is confirmed or timeout occurs.
6628
+ *
6629
+ * @example
6630
+ * ```typescript
6631
+ * await client.punsubscribe(new Set(["news.*"]), 5000);
6632
+ * // Unsubscribe from all patterns with timeout
6633
+ * await client.punsubscribe(ALL_PATTERNS, 5000);
6634
+ * ```
6635
+ */
6636
+ punsubscribe(patterns: Iterable<GlideString> | null, timeoutMs: number, options?: DecoderOption): Promise<void>;
6448
6637
  /**
6449
6638
  * Return a statistics
6450
6639
  *
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.BaseClient = exports.ObjectType = exports.ServiceType = exports.Decoder = exports.ProtocolVersion = void 0;
42
+ exports.BaseClient = exports.ObjectType = exports.ServiceType = exports.ALL_PATTERNS = exports.ALL_CHANNELS = exports.Decoder = exports.ProtocolVersion = void 0;
43
43
  exports.convertGlideRecord = convertGlideRecord;
44
44
  exports.convertGlideRecordToRecord = convertGlideRecordToRecord;
45
45
  exports.isGlideRecord = isGlideRecord;
@@ -74,6 +74,26 @@ var Decoder;
74
74
  */
75
75
  Decoder[Decoder["String"] = 1] = "String";
76
76
  })(Decoder || (exports.Decoder = Decoder = {}));
77
+ /**
78
+ * Constant representing "all channels" for unsubscribe operations.
79
+ * Use this to unsubscribe from all channel subscriptions at once.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * await client.unsubscribeLazy(ALL_CHANNELS);
84
+ * ```
85
+ */
86
+ exports.ALL_CHANNELS = null;
87
+ /**
88
+ * Constant representing "all patterns" for punsubscribe operations.
89
+ * Use this to unsubscribe from all pattern subscriptions at once.
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * await client.punsubscribeLazy(ALL_PATTERNS);
94
+ * ```
95
+ */
96
+ exports.ALL_PATTERNS = null;
77
97
  /**
78
98
  * @internal
79
99
  * Convert `GlideRecord<number>` recevied after resolving the value pointer into `SortedSetDataType`.
@@ -644,10 +664,9 @@ class BaseClient {
644
664
  if (this.isClosed) {
645
665
  throw new _1.ClosingError("Unable to execute requests; the client is closed. Please create a new client.");
646
666
  }
647
- if (!this.isPubsubConfigured(this.config)) {
648
- throw new _1.ConfigurationError("The operation will never complete since there was no pubsbub subscriptions applied to the client.");
649
- }
650
- if (this.getPubsubCallbackAndContext(this.config)[0]) {
667
+ // only throw error if BOTH config exists AND callback exists
668
+ if (this.isPubsubConfigured(this.config) &&
669
+ this.getPubsubCallbackAndContext(this.config)[0]) {
651
670
  throw new _1.ConfigurationError("The operation will never complete since messages will be passed to the configured callback.");
652
671
  }
653
672
  return new Promise((resolve, reject) => {
@@ -659,10 +678,9 @@ class BaseClient {
659
678
  if (this.isClosed) {
660
679
  throw new _1.ClosingError("Unable to execute requests; the client is closed. Please create a new client.");
661
680
  }
662
- if (!this.isPubsubConfigured(this.config)) {
663
- throw new _1.ConfigurationError("The operation will never complete since there was no pubsbub subscriptions applied to the client.");
664
- }
665
- if (this.getPubsubCallbackAndContext(this.config)[0]) {
681
+ // only throw error if BOTH config exists AND callback exists
682
+ if (this.isPubsubConfigured(this.config) &&
683
+ this.getPubsubCallbackAndContext(this.config)[0]) {
666
684
  throw new _1.ConfigurationError("The operation will never complete since messages will be passed to the configured callback.");
667
685
  }
668
686
  let msg = null;
@@ -7037,6 +7055,11 @@ class BaseClient {
7037
7055
  if (options.tcpNoDelay !== undefined) {
7038
7056
  request.tcpNodelay = options.tcpNoDelay;
7039
7057
  }
7058
+ // Set PubSub reconciliation interval if explicitly configured
7059
+ if (options.pubsubReconciliationIntervalMs !== undefined) {
7060
+ request.pubsubReconciliationIntervalMs =
7061
+ options.pubsubReconciliationIntervalMs;
7062
+ }
7040
7063
  // Apply TLS configuration if present
7041
7064
  if (options.tlsAdvancedConfiguration) {
7042
7065
  // request.tlsMode is either SecureTls or InsecureTls here
@@ -7198,6 +7221,225 @@ class BaseClient {
7198
7221
  const response = await this.createRefreshIamTokenPromise(refresh);
7199
7222
  return response; // "OK"
7200
7223
  }
7224
+ /**
7225
+ * Subscribes the client to the specified channels (non-blocking).
7226
+ * Returns immediately without waiting for subscription confirmation.
7227
+ *
7228
+ * @see {@link https://valkey.io/commands/subscribe/|valkey.io} for details.
7229
+ *
7230
+ * @param channels - A collection of channel names to subscribe to.
7231
+ * @param options - (Optional) See {@link DecoderOption}.
7232
+ * @returns A promise that resolves immediately.
7233
+ *
7234
+ * @example
7235
+ * ```typescript
7236
+ * await client.subscribeLazy(new Set(["news", "updates"]));
7237
+ * ```
7238
+ */
7239
+ async subscribeLazy(channels, options) {
7240
+ const channelsArray = Array.from(channels);
7241
+ return this.createWritePromise((0, _1.createSubscribeLazy)(channelsArray), options);
7242
+ }
7243
+ /**
7244
+ * Subscribes the client to the specified channels (blocking).
7245
+ * Waits for subscription confirmation or until timeout.
7246
+ *
7247
+ * @see {@link https://valkey.io/commands/subscribe/|valkey.io} for details.
7248
+ *
7249
+ * @param channels - A collection of channel names to subscribe to.
7250
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
7251
+ * @param options - (Optional) See {@link DecoderOption}.
7252
+ * @returns A promise that resolves when subscription is confirmed or timeout occurs.
7253
+ *
7254
+ * @example
7255
+ * ```typescript
7256
+ * // Wait up to 5 seconds
7257
+ * await client.subscribe(new Set(["news"]), 5000);
7258
+ * // Wait indefinitely
7259
+ * await client.subscribe(new Set(["news"]), 0);
7260
+ * ```
7261
+ */
7262
+ async subscribe(channels, timeoutMs, options) {
7263
+ const channelsArray = Array.from(channels);
7264
+ return this.createWritePromise((0, _1.createSubscribe)(channelsArray, timeoutMs), options);
7265
+ }
7266
+ /**
7267
+ * Subscribes the client to the specified patterns (non-blocking).
7268
+ * Returns immediately without waiting for subscription confirmation.
7269
+ *
7270
+ * @see {@link https://valkey.io/commands/psubscribe/|valkey.io} for details.
7271
+ *
7272
+ * @param patterns - An array of glob-style patterns to subscribe to.
7273
+ * @param options - (Optional) See {@link DecoderOption}.
7274
+ * @returns A promise that resolves immediately.
7275
+ *
7276
+ * @example
7277
+ * ```typescript
7278
+ * await client.psubscribeLazy(["news.*", "updates.*"]);
7279
+ * ```
7280
+ */
7281
+ async psubscribeLazy(patterns, options) {
7282
+ const patternsArray = Array.from(patterns);
7283
+ return this.createWritePromise((0, _1.createPSubscribeLazy)(patternsArray), options);
7284
+ }
7285
+ /**
7286
+ * Subscribes the client to the specified patterns (blocking).
7287
+ * Waits for subscription confirmation or until timeout.
7288
+ *
7289
+ * @see {@link https://valkey.io/commands/psubscribe/|valkey.io} for details.
7290
+ *
7291
+ * @param patterns - An array of glob-style patterns to subscribe to.
7292
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
7293
+ * @param options - (Optional) See {@link DecoderOption}.
7294
+ * @returns A promise that resolves when subscription is confirmed or timeout occurs.
7295
+ *
7296
+ * @example
7297
+ * ```typescript
7298
+ * await client.psubscribe(["news.*"], 5000);
7299
+ * ```
7300
+ */
7301
+ async psubscribe(patterns, timeoutMs, options) {
7302
+ const patternsArray = Array.from(patterns);
7303
+ return this.createWritePromise((0, _1.createPSubscribe)(patternsArray, timeoutMs), options);
7304
+ }
7305
+ /**
7306
+ * Unsubscribes the client from the specified channels (non-blocking).
7307
+ * Pass null or ALL_CHANNELS to unsubscribe from all exact channels.
7308
+ *
7309
+ * @see {@link https://valkey.io/commands/unsubscribe/|valkey.io} for details.
7310
+ *
7311
+ * @param channels - Channel names to unsubscribe from, or null for all channels.
7312
+ * @param options - (Optional) See {@link DecoderOption}.
7313
+ * @returns A promise that resolves immediately.
7314
+ *
7315
+ * @example
7316
+ * ```typescript
7317
+ * await client.unsubscribeLazy(new Set(["news"]));
7318
+ * // Unsubscribe from all channels
7319
+ * await client.unsubscribeLazy(ALL_CHANNELS);
7320
+ * ```
7321
+ */
7322
+ async unsubscribeLazy(channels, options) {
7323
+ const channelsArray = channels ? Array.from(channels) : undefined;
7324
+ return this.createWritePromise((0, _1.createUnsubscribeLazy)(channelsArray), options);
7325
+ }
7326
+ /**
7327
+ * Unsubscribes the client from the specified channels (blocking).
7328
+ * Pass null or ALL_CHANNELS to unsubscribe from all exact channels.
7329
+ *
7330
+ * @see {@link https://valkey.io/commands/unsubscribe/|valkey.io} for details.
7331
+ *
7332
+ * @param channels - Channel names to unsubscribe from, or null for all channels.
7333
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
7334
+ * @param options - (Optional) See {@link DecoderOption}.
7335
+ * @returns A promise that resolves when unsubscription is confirmed or timeout occurs.
7336
+ *
7337
+ * @example
7338
+ * ```typescript
7339
+ * await client.unsubscribe(new Set(["news"]), 5000);
7340
+ * // Unsubscribe from all channels with timeout
7341
+ * await client.unsubscribe(ALL_CHANNELS, 5000);
7342
+ * ```
7343
+ */
7344
+ async unsubscribe(channels, timeoutMs, options) {
7345
+ const channelsArray = channels ? Array.from(channels) : [];
7346
+ return this.createWritePromise((0, _1.createUnsubscribe)(channelsArray, timeoutMs), options);
7347
+ }
7348
+ /**
7349
+ * Unsubscribes the client from the specified patterns (non-blocking).
7350
+ * Pass null or ALL_PATTERNS to unsubscribe from all patterns.
7351
+ *
7352
+ * @see {@link https://valkey.io/commands/punsubscribe/|valkey.io} for details.
7353
+ *
7354
+ * @param patterns - Pattern names to unsubscribe from, or null for all patterns.
7355
+ * @param options - (Optional) See {@link DecoderOption}.
7356
+ * @returns A promise that resolves immediately.
7357
+ *
7358
+ * @example
7359
+ * ```typescript
7360
+ * await client.punsubscribeLazy(new Set(["news.*"]));
7361
+ * // Unsubscribe from all patterns
7362
+ * await client.punsubscribeLazy(ALL_PATTERNS);
7363
+ * ```
7364
+ */
7365
+ async punsubscribeLazy(patterns, options) {
7366
+ const patternsArray = patterns ? Array.from(patterns) : undefined;
7367
+ return this.createWritePromise((0, _1.createPUnsubscribeLazy)(patternsArray), options);
7368
+ }
7369
+ /**
7370
+ * Unsubscribes the client from the specified patterns (blocking).
7371
+ * Pass null or ALL_PATTERNS to unsubscribe from all patterns.
7372
+ *
7373
+ * @see {@link https://valkey.io/commands/punsubscribe/|valkey.io} for details.
7374
+ *
7375
+ * @param patterns - Pattern names to unsubscribe from, or null for all patterns.
7376
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
7377
+ * @param options - (Optional) See {@link DecoderOption}.
7378
+ * @returns A promise that resolves when unsubscription is confirmed or timeout occurs.
7379
+ *
7380
+ * @example
7381
+ * ```typescript
7382
+ * await client.punsubscribe(new Set(["news.*"]), 5000);
7383
+ * // Unsubscribe from all patterns with timeout
7384
+ * await client.punsubscribe(ALL_PATTERNS, 5000);
7385
+ * ```
7386
+ */
7387
+ async punsubscribe(patterns, timeoutMs, options) {
7388
+ const patternsArray = patterns ? Array.from(patterns) : [];
7389
+ return this.createWritePromise((0, _1.createPUnsubscribe)(patternsArray, timeoutMs), options);
7390
+ }
7391
+ /**
7392
+ * @internal
7393
+ * Helper method to parse GetSubscriptions response from Rust core.
7394
+ * Converts array response to structured object with desired and actual subscriptions.
7395
+ *
7396
+ * The Rust core returns subscription data as a Value::Map with string keys ("Exact", "Pattern", "Sharded").
7397
+ * The NAPI layer converts this to GlideRecord format: [{key: "Exact", value: [...]}, ...]
7398
+ *
7399
+ * @param response - The response array from Rust core with format:
7400
+ * ["desired", GlideRecord, "actual", GlideRecord]
7401
+ * @returns Parsed subscription state with desired and actual subscriptions
7402
+ */
7403
+ parseGetSubscriptionsResponse(response) {
7404
+ // Response format: ["desired", GlideRecord, "actual", GlideRecord]
7405
+ if (!Array.isArray(response) || response.length !== 4) {
7406
+ throw new Error(`Invalid GetSubscriptions response format: expected array of length 4, got ${JSON.stringify(response)}`);
7407
+ }
7408
+ // Map string mode names to numeric enum values
7409
+ const modeNameToNumber = {
7410
+ Exact: 0,
7411
+ Pattern: 1,
7412
+ Sharded: 2,
7413
+ };
7414
+ const desiredSubscriptions = {};
7415
+ const actualSubscriptions = {};
7416
+ // Helper function to parse subscription data from GlideRecord format
7417
+ const parseSubscriptionData = (data, target) => {
7418
+ if (!Array.isArray(data)) {
7419
+ return;
7420
+ }
7421
+ for (const entry of data) {
7422
+ if (!entry ||
7423
+ typeof entry !== "object" ||
7424
+ !("key" in entry) ||
7425
+ !("value" in entry)) {
7426
+ continue;
7427
+ }
7428
+ // Key might be a Buffer, convert to string
7429
+ const modeName = entry.key instanceof Buffer
7430
+ ? entry.key.toString()
7431
+ : String(entry.key);
7432
+ const modeKey = modeNameToNumber[modeName];
7433
+ if (modeKey !== undefined && Array.isArray(entry.value)) {
7434
+ target[modeKey] = new Set(entry.value);
7435
+ }
7436
+ }
7437
+ };
7438
+ // Parse desired and actual subscriptions
7439
+ parseSubscriptionData(response[1], desiredSubscriptions);
7440
+ parseSubscriptionData(response[3], actualSubscriptions);
7441
+ return { desiredSubscriptions, actualSubscriptions };
7442
+ }
7201
7443
  /**
7202
7444
  * Return a statistics
7203
7445
  *
@@ -218,6 +218,19 @@ exports.createPubSubNumPat = createPubSubNumPat;
218
218
  exports.createPubSubNumSub = createPubSubNumSub;
219
219
  exports.createPubsubShardChannels = createPubsubShardChannels;
220
220
  exports.createPubSubShardNumSub = createPubSubShardNumSub;
221
+ exports.createSubscribeLazy = createSubscribeLazy;
222
+ exports.createSubscribe = createSubscribe;
223
+ exports.createPSubscribeLazy = createPSubscribeLazy;
224
+ exports.createPSubscribe = createPSubscribe;
225
+ exports.createUnsubscribeLazy = createUnsubscribeLazy;
226
+ exports.createUnsubscribe = createUnsubscribe;
227
+ exports.createPUnsubscribeLazy = createPUnsubscribeLazy;
228
+ exports.createPUnsubscribe = createPUnsubscribe;
229
+ exports.createSSubscribeLazy = createSSubscribeLazy;
230
+ exports.createSSubscribe = createSSubscribe;
231
+ exports.createSUnsubscribeLazy = createSUnsubscribeLazy;
232
+ exports.createSUnsubscribe = createSUnsubscribe;
233
+ exports.createGetSubscriptions = createGetSubscriptions;
221
234
  exports.createBZPopMax = createBZPopMax;
222
235
  exports.createBZPopMin = createBZPopMin;
223
236
  exports.createScriptShow = createScriptShow;
@@ -2849,6 +2862,102 @@ function createPubsubShardChannels(pattern) {
2849
2862
  function createPubSubShardNumSub(channels) {
2850
2863
  return createCommand(RequestType.PubSubShardNumSub, channels ? channels : []);
2851
2864
  }
2865
+ /**
2866
+ * @internal
2867
+ */
2868
+ function createSubscribeLazy(channels) {
2869
+ return createCommand(RequestType.Subscribe, channels);
2870
+ }
2871
+ /**
2872
+ * @internal
2873
+ */
2874
+ function createSubscribe(channels, timeout) {
2875
+ return createCommand(RequestType.SubscribeBlocking, [
2876
+ ...channels,
2877
+ timeout.toString(),
2878
+ ]);
2879
+ }
2880
+ /**
2881
+ * @internal
2882
+ */
2883
+ function createPSubscribeLazy(patterns) {
2884
+ return createCommand(RequestType.PSubscribe, patterns);
2885
+ }
2886
+ /**
2887
+ * @internal
2888
+ */
2889
+ function createPSubscribe(patterns, timeout) {
2890
+ return createCommand(RequestType.PSubscribeBlocking, [
2891
+ ...patterns,
2892
+ timeout.toString(),
2893
+ ]);
2894
+ }
2895
+ /**
2896
+ * @internal
2897
+ */
2898
+ function createUnsubscribeLazy(channels) {
2899
+ return createCommand(RequestType.Unsubscribe, channels ? channels : []);
2900
+ }
2901
+ /**
2902
+ * @internal
2903
+ */
2904
+ function createUnsubscribe(channels, timeout) {
2905
+ return createCommand(RequestType.UnsubscribeBlocking, [
2906
+ ...channels,
2907
+ timeout.toString(),
2908
+ ]);
2909
+ }
2910
+ /**
2911
+ * @internal
2912
+ */
2913
+ function createPUnsubscribeLazy(patterns) {
2914
+ return createCommand(RequestType.PUnsubscribe, patterns ?? []);
2915
+ }
2916
+ /**
2917
+ * @internal
2918
+ */
2919
+ function createPUnsubscribe(patterns, timeout) {
2920
+ return createCommand(RequestType.PUnsubscribeBlocking, [
2921
+ ...patterns,
2922
+ timeout.toString(),
2923
+ ]);
2924
+ }
2925
+ /**
2926
+ * @internal
2927
+ */
2928
+ function createSSubscribeLazy(channels) {
2929
+ return createCommand(RequestType.SSubscribe, channels);
2930
+ }
2931
+ /**
2932
+ * @internal
2933
+ */
2934
+ function createSSubscribe(channels, timeout) {
2935
+ return createCommand(RequestType.SSubscribeBlocking, [
2936
+ ...channels,
2937
+ timeout.toString(),
2938
+ ]);
2939
+ }
2940
+ /**
2941
+ * @internal
2942
+ */
2943
+ function createSUnsubscribeLazy(channels) {
2944
+ return createCommand(RequestType.SUnsubscribe, channels ? channels : []);
2945
+ }
2946
+ /**
2947
+ * @internal
2948
+ */
2949
+ function createSUnsubscribe(channels, timeout) {
2950
+ return createCommand(RequestType.SUnsubscribeBlocking, [
2951
+ ...channels,
2952
+ timeout.toString(),
2953
+ ]);
2954
+ }
2955
+ /**
2956
+ * @internal
2957
+ */
2958
+ function createGetSubscriptions() {
2959
+ return createCommand(RequestType.GetSubscriptions, []);
2960
+ }
2852
2961
  /**
2853
2962
  * @internal
2854
2963
  */
@@ -34,6 +34,37 @@ export declare namespace GlideClientConfiguration {
34
34
  context?: any;
35
35
  }
36
36
  }
37
+ /**
38
+ * Represents the subscription state for a standalone client.
39
+ *
40
+ * @remarks
41
+ * This interface provides information about the current PubSub subscriptions for a standalone client.
42
+ * It includes both the desired subscriptions (what the client wants to maintain) and the actual
43
+ * subscriptions (what is currently established on the server).
44
+ *
45
+ * The subscriptions are organized by channel mode:
46
+ * - {@link GlideClientConfiguration.PubSubChannelModes.Exact | Exact}: Exact channel names
47
+ * - {@link GlideClientConfiguration.PubSubChannelModes.Pattern | Pattern}: Channel patterns using glob-style matching
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const state = await client.getSubscriptions();
52
+ * console.log("Desired exact channels:", state.desiredSubscriptions[GlideClientConfiguration.PubSubChannelModes.Exact]);
53
+ * console.log("Actual exact channels:", state.actualSubscriptions[GlideClientConfiguration.PubSubChannelModes.Exact]);
54
+ * ```
55
+ */
56
+ export interface StandalonePubSubState {
57
+ /**
58
+ * Desired subscriptions organized by channel mode.
59
+ * These are the subscriptions the client wants to maintain.
60
+ */
61
+ desiredSubscriptions: Partial<Record<GlideClientConfiguration.PubSubChannelModes, Set<GlideString>>>;
62
+ /**
63
+ * Actual subscriptions currently active on the server.
64
+ * These are the subscriptions that are actually established.
65
+ */
66
+ actualSubscriptions: Partial<Record<GlideClientConfiguration.PubSubChannelModes, Set<GlideString>>>;
67
+ }
37
68
  /**
38
69
  * Configuration options for creating a {@link GlideClient | GlideClient}.
39
70
  *
@@ -789,4 +820,20 @@ export declare class GlideClient extends BaseClient {
789
820
  * ```
790
821
  */
791
822
  scan(cursor: GlideString, options?: ScanOptions & DecoderOption): Promise<[GlideString, GlideString[]]>;
823
+ /**
824
+ * Returns the current subscription state for the client.
825
+ *
826
+ * @see {@link https://valkey.io/commands/pubsub/|valkey.io} for details.
827
+ *
828
+ * @returns A promise that resolves to the subscription state containing
829
+ * desired and actual subscriptions organized by channel mode.
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * const state = await client.getSubscriptions();
834
+ * console.log("Desired exact channels:", state.desiredSubscriptions[GlideClientConfiguration.PubSubChannelModes.Exact]);
835
+ * console.log("Actual exact channels:", state.actualSubscriptions[GlideClientConfiguration.PubSubChannelModes.Exact]);
836
+ * ```
837
+ */
838
+ getSubscriptions(): Promise<StandalonePubSubState>;
792
839
  }
@@ -824,5 +824,24 @@ class GlideClient extends BaseClient_1.BaseClient {
824
824
  async scan(cursor, options) {
825
825
  return this.createWritePromise((0, Commands_1.createScan)(cursor, options), options);
826
826
  }
827
+ /**
828
+ * Returns the current subscription state for the client.
829
+ *
830
+ * @see {@link https://valkey.io/commands/pubsub/|valkey.io} for details.
831
+ *
832
+ * @returns A promise that resolves to the subscription state containing
833
+ * desired and actual subscriptions organized by channel mode.
834
+ *
835
+ * @example
836
+ * ```typescript
837
+ * const state = await client.getSubscriptions();
838
+ * console.log("Desired exact channels:", state.desiredSubscriptions[GlideClientConfiguration.PubSubChannelModes.Exact]);
839
+ * console.log("Actual exact channels:", state.actualSubscriptions[GlideClientConfiguration.PubSubChannelModes.Exact]);
840
+ * ```
841
+ */
842
+ async getSubscriptions() {
843
+ const response = await this.createWritePromise((0, Commands_1.createGetSubscriptions)());
844
+ return this.parseGetSubscriptionsResponse(response);
845
+ }
827
846
  }
828
847
  exports.GlideClient = GlideClient;
@@ -5,6 +5,16 @@ import { ClusterScanCursor, Script } from "../build-ts/native";
5
5
  import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
6
6
  import { ClusterBatch } from "./Batch";
7
7
  import { ClusterBatchOptions, ClusterScanOptions, FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsSingleResponse, InfoOptions, LolwutOptions } from "./Commands";
8
+ /**
9
+ * Constant representing all sharded channels.
10
+ * Use this to unsubscribe from all sharded channel subscriptions at once..
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * await client.sunsubscribeLazy(ALL_SHARDED_CHANNELS);
15
+ * ```
16
+ */
17
+ export declare const ALL_SHARDED_CHANNELS: null;
8
18
  /** An extension to command option types with {@link Routes}. */
9
19
  export interface RouteOption {
10
20
  /**
@@ -75,6 +85,38 @@ export declare namespace GlideClusterClientConfiguration {
75
85
  context?: any;
76
86
  }
77
87
  }
88
+ /**
89
+ * Represents the subscription state for a cluster client.
90
+ *
91
+ * @remarks
92
+ * This interface provides information about the current PubSub subscriptions for a cluster client.
93
+ * It includes both the desired subscriptions (what the client wants to maintain) and the actual
94
+ * subscriptions (what is currently established on the server).
95
+ *
96
+ * The subscriptions are organized by channel mode:
97
+ * - {@link GlideClusterClientConfiguration.PubSubChannelModes.Exact | Exact}: Exact channel names
98
+ * - {@link GlideClusterClientConfiguration.PubSubChannelModes.Pattern | Pattern}: Channel patterns using glob-style matching
99
+ * - {@link GlideClusterClientConfiguration.PubSubChannelModes.Sharded | Sharded}: Sharded channels (available since Valkey 7.0)
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const state = await clusterClient.getSubscriptions();
104
+ * console.log("Desired exact channels:", state.desiredSubscriptions[GlideClusterClientConfiguration.PubSubChannelModes.Exact]);
105
+ * console.log("Actual sharded channels:", state.actualSubscriptions[GlideClusterClientConfiguration.PubSubChannelModes.Sharded]);
106
+ * ```
107
+ */
108
+ export interface ClusterPubSubState {
109
+ /**
110
+ * Desired subscriptions organized by channel mode.
111
+ * These are the subscriptions the client wants to maintain.
112
+ */
113
+ desiredSubscriptions: Partial<Record<GlideClusterClientConfiguration.PubSubChannelModes, Set<GlideString>>>;
114
+ /**
115
+ * Actual subscriptions currently active on the server.
116
+ * These are the subscriptions that are actually established.
117
+ */
118
+ actualSubscriptions: Partial<Record<GlideClusterClientConfiguration.PubSubChannelModes, Set<GlideString>>>;
119
+ }
78
120
  /**
79
121
  * Configuration options for creating a {@link GlideClusterClient | GlideClusterClient}.
80
122
  *
@@ -1380,4 +1422,97 @@ export declare class GlideClusterClient extends BaseClient {
1380
1422
  * ```
1381
1423
  */
1382
1424
  scriptKill(options?: RouteOption): Promise<"OK">;
1425
+ /**
1426
+ * Subscribes the client to the specified sharded channels (non-blocking).
1427
+ * Returns immediately without waiting for subscription confirmation.
1428
+ * Available since Valkey 7.0.
1429
+ *
1430
+ * @see {@link https://valkey.io/commands/ssubscribe/|valkey.io} for details.
1431
+ *
1432
+ * @param channels - A collection of channel names to subscribe to.
1433
+ * @param options - (Optional) See {@link DecoderOption}.
1434
+ * @returns A promise that resolves immediately.
1435
+ *
1436
+ * @example
1437
+ * ```typescript
1438
+ * await clusterClient.ssubscribeLazy(new Set(["shard-channel-1"]));
1439
+ * ```
1440
+ */
1441
+ ssubscribeLazy(channels: Iterable<GlideString>, options?: DecoderOption): Promise<void>;
1442
+ /**
1443
+ * Subscribes the client to the specified sharded channels (blocking).
1444
+ * Waits for subscription confirmation or until timeout.
1445
+ * Available since Valkey 7.0.
1446
+ *
1447
+ * @see {@link https://valkey.io/commands/ssubscribe/|valkey.io} for details.
1448
+ *
1449
+ * @param channels - A collection of channel names to subscribe to.
1450
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
1451
+ * @param options - (Optional) See {@link DecoderOption}.
1452
+ * @returns A promise that resolves when subscription is confirmed or timeout occurs.
1453
+ *
1454
+ * @example
1455
+ * ```typescript
1456
+ * // Wait up to 5 seconds
1457
+ * await clusterClient.ssubscribe(new Set(["shard-channel-1"]), 5000);
1458
+ * // Wait indefinitely
1459
+ * await clusterClient.ssubscribe(new Set(["shard-channel-1"]), 0);
1460
+ * ```
1461
+ */
1462
+ ssubscribe(channels: Iterable<GlideString>, timeoutMs: number, options?: DecoderOption): Promise<void>;
1463
+ /**
1464
+ * Unsubscribes the client from the specified sharded channels (non-blocking).
1465
+ * Pass null or ALL_CHANNELS to unsubscribe from all sharded channels.
1466
+ * Available since Valkey 7.0.
1467
+ *
1468
+ * @see {@link https://valkey.io/commands/sunsubscribe/|valkey.io} for details.
1469
+ *
1470
+ * @param channels - Sharded channel names to unsubscribe from, or null for all channels.
1471
+ * @param options - (Optional) See {@link DecoderOption}.
1472
+ * @returns A promise that resolves immediately.
1473
+ *
1474
+ * @example
1475
+ * ```typescript
1476
+ * await clusterClient.sunsubscribeLazy(new Set(["shard-channel-1"]));
1477
+ * // Unsubscribe from all sharded channels
1478
+ * await clusterClient.sunsubscribeLazy(ALL_SHARDED_CHANNELS);
1479
+ * ```
1480
+ */
1481
+ sunsubscribeLazy(channels?: Iterable<GlideString> | null, options?: DecoderOption): Promise<void>;
1482
+ /**
1483
+ * Unsubscribes the client from the specified sharded channels (blocking).
1484
+ * Pass null or ALL_CHANNELS to unsubscribe from all sharded channels.
1485
+ * Available since Valkey 7.0.
1486
+ *
1487
+ * @see {@link https://valkey.io/commands/sunsubscribe/|valkey.io} for details.
1488
+ *
1489
+ * @param channels - Sharded channel names to unsubscribe from, or null for all channels.
1490
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
1491
+ * @param options - (Optional) See {@link DecoderOption}.
1492
+ * @returns A promise that resolves when unsubscription is confirmed or timeout occurs.
1493
+ *
1494
+ * @example
1495
+ * ```typescript
1496
+ * await clusterClient.sunsubscribe(new Set(["shard-channel-1"]), 5000);
1497
+ * // Unsubscribe from all sharded channels with timeout
1498
+ * await clusterClient.sunsubscribe(ALL_SHARDED_CHANNELS, 5000);
1499
+ * ```
1500
+ */
1501
+ sunsubscribe(channels: Iterable<GlideString> | null, timeoutMs: number, options?: DecoderOption): Promise<void>;
1502
+ /**
1503
+ * Returns the current subscription state for the cluster client.
1504
+ *
1505
+ * @see {@link https://valkey.io/commands/pubsub/|valkey.io} for details.
1506
+ *
1507
+ * @returns A promise that resolves to the subscription state containing
1508
+ * desired and actual subscriptions organized by channel mode.
1509
+ *
1510
+ * @example
1511
+ * ```typescript
1512
+ * const state = await clusterClient.getSubscriptions();
1513
+ * console.log("Desired exact channels:", state.desiredSubscriptions[GlideClusterClientConfiguration.PubSubChannelModes.Exact]);
1514
+ * console.log("Actual sharded channels:", state.actualSubscriptions[GlideClusterClientConfiguration.PubSubChannelModes.Sharded]);
1515
+ * ```
1516
+ */
1517
+ getSubscriptions(): Promise<ClusterPubSubState>;
1383
1518
  }
@@ -3,11 +3,21 @@
3
3
  * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GlideClusterClient = exports.GlideClusterClientConfiguration = void 0;
6
+ exports.GlideClusterClient = exports.GlideClusterClientConfiguration = exports.ALL_SHARDED_CHANNELS = void 0;
7
7
  const native_1 = require("../build-ts/native");
8
8
  const ProtobufMessage_1 = require("../build-ts/ProtobufMessage");
9
9
  const BaseClient_1 = require("./BaseClient");
10
10
  const Commands_1 = require("./Commands");
11
+ /**
12
+ * Constant representing all sharded channels.
13
+ * Use this to unsubscribe from all sharded channel subscriptions at once..
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * await client.sunsubscribeLazy(ALL_SHARDED_CHANNELS);
18
+ * ```
19
+ */
20
+ exports.ALL_SHARDED_CHANNELS = null;
11
21
  /* eslint-disable-next-line @typescript-eslint/no-namespace */
12
22
  var GlideClusterClientConfiguration;
13
23
  (function (GlideClusterClientConfiguration) {
@@ -1239,5 +1249,113 @@ class GlideClusterClient extends BaseClient_1.BaseClient {
1239
1249
  ...options,
1240
1250
  });
1241
1251
  }
1252
+ /**
1253
+ * Subscribes the client to the specified sharded channels (non-blocking).
1254
+ * Returns immediately without waiting for subscription confirmation.
1255
+ * Available since Valkey 7.0.
1256
+ *
1257
+ * @see {@link https://valkey.io/commands/ssubscribe/|valkey.io} for details.
1258
+ *
1259
+ * @param channels - A collection of channel names to subscribe to.
1260
+ * @param options - (Optional) See {@link DecoderOption}.
1261
+ * @returns A promise that resolves immediately.
1262
+ *
1263
+ * @example
1264
+ * ```typescript
1265
+ * await clusterClient.ssubscribeLazy(new Set(["shard-channel-1"]));
1266
+ * ```
1267
+ */
1268
+ async ssubscribeLazy(channels, options) {
1269
+ const channelsArray = Array.from(channels);
1270
+ return this.createWritePromise((0, Commands_1.createSSubscribeLazy)(channelsArray), options);
1271
+ }
1272
+ /**
1273
+ * Subscribes the client to the specified sharded channels (blocking).
1274
+ * Waits for subscription confirmation or until timeout.
1275
+ * Available since Valkey 7.0.
1276
+ *
1277
+ * @see {@link https://valkey.io/commands/ssubscribe/|valkey.io} for details.
1278
+ *
1279
+ * @param channels - A collection of channel names to subscribe to.
1280
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
1281
+ * @param options - (Optional) See {@link DecoderOption}.
1282
+ * @returns A promise that resolves when subscription is confirmed or timeout occurs.
1283
+ *
1284
+ * @example
1285
+ * ```typescript
1286
+ * // Wait up to 5 seconds
1287
+ * await clusterClient.ssubscribe(new Set(["shard-channel-1"]), 5000);
1288
+ * // Wait indefinitely
1289
+ * await clusterClient.ssubscribe(new Set(["shard-channel-1"]), 0);
1290
+ * ```
1291
+ */
1292
+ async ssubscribe(channels, timeoutMs, options) {
1293
+ const channelsArray = Array.from(channels);
1294
+ return this.createWritePromise((0, Commands_1.createSSubscribe)(channelsArray, timeoutMs), options);
1295
+ }
1296
+ /**
1297
+ * Unsubscribes the client from the specified sharded channels (non-blocking).
1298
+ * Pass null or ALL_CHANNELS to unsubscribe from all sharded channels.
1299
+ * Available since Valkey 7.0.
1300
+ *
1301
+ * @see {@link https://valkey.io/commands/sunsubscribe/|valkey.io} for details.
1302
+ *
1303
+ * @param channels - Sharded channel names to unsubscribe from, or null for all channels.
1304
+ * @param options - (Optional) See {@link DecoderOption}.
1305
+ * @returns A promise that resolves immediately.
1306
+ *
1307
+ * @example
1308
+ * ```typescript
1309
+ * await clusterClient.sunsubscribeLazy(new Set(["shard-channel-1"]));
1310
+ * // Unsubscribe from all sharded channels
1311
+ * await clusterClient.sunsubscribeLazy(ALL_SHARDED_CHANNELS);
1312
+ * ```
1313
+ */
1314
+ async sunsubscribeLazy(channels, options) {
1315
+ const channelsArray = channels ? Array.from(channels) : undefined;
1316
+ return this.createWritePromise((0, Commands_1.createSUnsubscribeLazy)(channelsArray), options);
1317
+ }
1318
+ /**
1319
+ * Unsubscribes the client from the specified sharded channels (blocking).
1320
+ * Pass null or ALL_CHANNELS to unsubscribe from all sharded channels.
1321
+ * Available since Valkey 7.0.
1322
+ *
1323
+ * @see {@link https://valkey.io/commands/sunsubscribe/|valkey.io} for details.
1324
+ *
1325
+ * @param channels - Sharded channel names to unsubscribe from, or null for all channels.
1326
+ * @param timeoutMs - Maximum time in milliseconds to wait. Use 0 for indefinite wait.
1327
+ * @param options - (Optional) See {@link DecoderOption}.
1328
+ * @returns A promise that resolves when unsubscription is confirmed or timeout occurs.
1329
+ *
1330
+ * @example
1331
+ * ```typescript
1332
+ * await clusterClient.sunsubscribe(new Set(["shard-channel-1"]), 5000);
1333
+ * // Unsubscribe from all sharded channels with timeout
1334
+ * await clusterClient.sunsubscribe(ALL_SHARDED_CHANNELS, 5000);
1335
+ * ```
1336
+ */
1337
+ async sunsubscribe(channels, timeoutMs, options) {
1338
+ const channelsArray = channels ? Array.from(channels) : [];
1339
+ return this.createWritePromise((0, Commands_1.createSUnsubscribe)(channelsArray, timeoutMs), options);
1340
+ }
1341
+ /**
1342
+ * Returns the current subscription state for the cluster client.
1343
+ *
1344
+ * @see {@link https://valkey.io/commands/pubsub/|valkey.io} for details.
1345
+ *
1346
+ * @returns A promise that resolves to the subscription state containing
1347
+ * desired and actual subscriptions organized by channel mode.
1348
+ *
1349
+ * @example
1350
+ * ```typescript
1351
+ * const state = await clusterClient.getSubscriptions();
1352
+ * console.log("Desired exact channels:", state.desiredSubscriptions[GlideClusterClientConfiguration.PubSubChannelModes.Exact]);
1353
+ * console.log("Actual sharded channels:", state.actualSubscriptions[GlideClusterClientConfiguration.PubSubChannelModes.Sharded]);
1354
+ * ```
1355
+ */
1356
+ async getSubscriptions() {
1357
+ const response = await this.createWritePromise((0, Commands_1.createGetSubscriptions)());
1358
+ return this.parseGetSubscriptionsResponse(response);
1359
+ }
1242
1360
  }
1243
1361
  exports.GlideClusterClient = GlideClusterClient;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "build-ts/index.js",
5
5
  "module": "build-ts/index.js",
6
6
  "types": "build-ts/index.d.ts",
7
- "version": "2.3.0-rc6",
7
+ "version": "2.3.0",
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": {
@@ -135,11 +135,11 @@
135
135
  }
136
136
  },
137
137
  "optionalDependencies": {
138
- "@valkey/valkey-glide-darwin-x64": "2.3.0-rc6",
139
- "@valkey/valkey-glide-darwin-arm64": "2.3.0-rc6",
140
- "@valkey/valkey-glide-linux-x64-gnu": "2.3.0-rc6",
141
- "@valkey/valkey-glide-linux-arm64-gnu": "2.3.0-rc6",
142
- "@valkey/valkey-glide-linux-x64-musl": "2.3.0-rc6",
143
- "@valkey/valkey-glide-linux-arm64-musl": "2.3.0-rc6"
138
+ "@valkey/valkey-glide-darwin-x64": "2.3.0",
139
+ "@valkey/valkey-glide-darwin-arm64": "2.3.0",
140
+ "@valkey/valkey-glide-linux-x64-gnu": "2.3.0",
141
+ "@valkey/valkey-glide-linux-arm64-gnu": "2.3.0",
142
+ "@valkey/valkey-glide-linux-x64-musl": "2.3.0",
143
+ "@valkey/valkey-glide-linux-arm64-musl": "2.3.0"
144
144
  }
145
145
  }