@valkey/valkey-glide 1.2.0-rc9 → 1.2.1-rc0

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/build-ts/index.js CHANGED
@@ -45,9 +45,6 @@ function loadNativeBinding() {
45
45
  break;
46
46
  case "darwin":
47
47
  switch (process_1.arch) {
48
- case "x64":
49
- nativeBinding = require("@valkey/valkey-glide-darwin-x64");
50
- break;
51
48
  case "arm64":
52
49
  nativeBinding = require("@valkey/valkey-glide-darwin-arm64");
53
50
  break;
@@ -65,10 +62,11 @@ function loadNativeBinding() {
65
62
  }
66
63
  function initialize() {
67
64
  const nativeBinding = loadNativeBinding();
68
- const { AggregationType, BaseScanOptions, ZScanOptions, HScanOptions, BitEncoding, BitFieldGet, BitFieldIncrBy, BitFieldOffset, BitFieldOverflow, BitFieldSet, BitFieldSubCommands, BitOffset, BitOffsetMultiplier, BitOffsetOptions, BitOverflowControl, BitmapIndexType, BitwiseOperation, ConditionalChange, Decoder, DecoderOption, GeoAddOptions, CoordOrigin, MemberOrigin, SearchOrigin, GeoBoxShape, GeoCircleShape, GeoSearchShape, GeoSearchResultOptions, GeoSearchStoreResultOptions, SortOrder, GeoUnit, GeospatialData, GlideClient, GlideClusterClient, GlideClientConfiguration, GlideJson, GlideFt, TextField, TagField, NumericField, VectorField, VectorFieldAttributesFlat, VectorFieldAttributesHnsw, FtCreateOptions, FtSearchOptions, FtInfoReturnType, FtAggregateOptions, FtAggregateLimit, FtAggregateFilter, FtAggregateGroupBy, FtAggregateReducer, FtAggregateSortBy, FtAggregateSortProperty, FtAggregateApply, FtAggregateReturnType, FtSearchReturnType, FtProfileOtions, GlideRecord, GlideString, JsonGetOptions, JsonArrPopOptions, SortedSetDataType, StreamEntryDataType, HashDataType, FunctionListOptions, FunctionListResponse, FunctionStatsSingleResponse, FunctionStatsFullResponse, FunctionRestorePolicy, SlotIdTypes, SlotKeyTypes, TimeUnit, RouteByAddress, RouteOption, Routes, RestoreOptions, SingleNodeRoute, PeriodicChecksManualInterval, PeriodicChecks, Logger, Limit, LolwutOptions, LPosOptions, ListDirection, ExpireOptions, FlushMode, InfoOptions, InsertPosition, SetOptions, ZAddOptions, InfBoundary, KeyWeight, Boundary, UpdateOptions, ProtocolVersion, RangeByIndex, RangeByScore, RangeByLex, ReadFrom, ServerCredentials, SortClusterOptions, SortOptions, SortedSetRange, StreamGroupOptions, StreamTrimOptions, StreamAddOptions, StreamReadGroupOptions, StreamReadOptions, StreamClaimOptions, StreamPendingOptions, ClosingError, ConfigurationError, ExecAbortError, ValkeyError, GlideReturnType, StreamEntries, ReturnTypeXinfoStream, RequestError, TimeoutError, ConnectionError, ClusterTransaction, Transaction, PubSubMsg, ScoreFilter, SignedEncoding, UnsignedEncoding, UpdateByScore, createLeakedArray, createLeakedAttribute, createLeakedBigint, createLeakedDouble, createLeakedMap, createLeakedString, parseInfoResponse, Script, ObjectType, ClusterScanCursor, BaseClientConfiguration, GlideClusterClientConfiguration, LevelOptions, ReturnTypeRecord, ReturnTypeMap, ClusterResponse, ReturnTypeAttribute, ReturnTypeJson, UniversalReturnTypeJson, } = nativeBinding;
65
+ const { AggregationType, BaseScanOptions, ScanOptions, ZScanOptions, HScanOptions, BitEncoding, BitFieldGet, BitFieldIncrBy, BitFieldOffset, BitFieldOverflow, BitFieldSet, BitFieldSubCommands, BitOffset, BitOffsetMultiplier, BitOffsetOptions, BitOverflowControl, BitmapIndexType, BitwiseOperation, ConditionalChange, Decoder, DecoderOption, GeoAddOptions, CoordOrigin, MemberOrigin, SearchOrigin, GeoBoxShape, GeoCircleShape, GeoSearchShape, GeoSearchResultOptions, GeoSearchStoreResultOptions, SortOrder, GeoUnit, GeospatialData, GlideClient, GlideClusterClient, GlideClientConfiguration, GlideJson, GlideFt, Field, TextField, TagField, NumericField, VectorField, VectorFieldAttributesFlat, VectorFieldAttributesHnsw, FtCreateOptions, FtSearchOptions, FtInfoReturnType, FtAggregateOptions, FtAggregateLimit, FtAggregateFilter, FtAggregateGroupBy, FtAggregateReducer, FtAggregateSortBy, FtAggregateSortProperty, FtAggregateApply, FtAggregateReturnType, FtSearchReturnType, GlideRecord, GlideString, JsonGetOptions, JsonArrPopOptions, SortedSetDataType, StreamEntryDataType, HashDataType, FunctionListOptions, FunctionListResponse, FunctionStatsSingleResponse, FunctionStatsFullResponse, FunctionRestorePolicy, SlotIdTypes, SlotKeyTypes, TimeUnit, RouteByAddress, RouteOption, Routes, RestoreOptions, SingleNodeRoute, PeriodicChecksManualInterval, PeriodicChecks, Logger, Limit, LolwutOptions, LPosOptions, ListDirection, ExpireOptions, FlushMode, InfoOptions, InsertPosition, SetOptions, ZAddOptions, InfBoundary, KeyWeight, Boundary, ProtocolVersion, RangeByIndex, RangeByScore, RangeByLex, ReadFrom, ServerCredentials, SortOptions, StreamGroupOptions, StreamTrimOptions, StreamAddOptions, StreamReadGroupOptions, StreamReadOptions, StreamClaimOptions, StreamPendingOptions, ClosingError, ConfigurationError, ExecAbortError, ValkeyError, GlideReturnType, StreamEntries, ReturnTypeXinfoStream, RequestError, TimeoutError, ConnectionError, ClusterTransaction, Transaction, PubSubMsg, ScoreFilter, SignedEncoding, UnsignedEncoding, UpdateByScore, createLeakedArray, createLeakedAttribute, createLeakedBigint, createLeakedDouble, createLeakedMap, createLeakedString, Script, ObjectType, ClusterScanCursor, AdvancedGlideClientConfiguration, AdvancedGlideClusterClientConfiguration, BaseClientConfiguration, GlideClusterClientConfiguration, LevelOptions, ReturnTypeRecord, ReturnTypeMap, ClusterResponse, ReturnTypeAttribute, ReturnTypeJson, UniversalReturnTypeJson, } = nativeBinding;
69
66
  module.exports = {
70
67
  AggregationType,
71
68
  BaseScanOptions,
69
+ ScanOptions,
72
70
  HScanOptions,
73
71
  ZScanOptions,
74
72
  BitEncoding,
@@ -89,6 +87,7 @@ function initialize() {
89
87
  DecoderOption,
90
88
  GeoAddOptions,
91
89
  GlideFt,
90
+ Field,
92
91
  TextField,
93
92
  TagField,
94
93
  NumericField,
@@ -108,7 +107,6 @@ function initialize() {
108
107
  FtAggregateApply,
109
108
  FtAggregateReturnType,
110
109
  FtSearchReturnType,
111
- FtProfileOtions,
112
110
  GlideRecord,
113
111
  GlideJson,
114
112
  GlideString,
@@ -131,6 +129,8 @@ function initialize() {
131
129
  GlideClient,
132
130
  GlideClusterClient,
133
131
  GlideClientConfiguration,
132
+ AdvancedGlideClientConfiguration,
133
+ AdvancedGlideClusterClientConfiguration,
134
134
  FunctionListOptions,
135
135
  FunctionListResponse,
136
136
  FunctionStatsSingleResponse,
@@ -162,16 +162,13 @@ function initialize() {
162
162
  InfBoundary,
163
163
  KeyWeight,
164
164
  Boundary,
165
- UpdateOptions,
166
165
  ProtocolVersion,
167
166
  RangeByIndex,
168
167
  RangeByScore,
169
168
  RangeByLex,
170
169
  ReadFrom,
171
170
  ServerCredentials,
172
- SortClusterOptions,
173
171
  SortOptions,
174
- SortedSetRange,
175
172
  StreamGroupOptions,
176
173
  StreamTrimOptions,
177
174
  StreamAddOptions,
@@ -200,7 +197,6 @@ function initialize() {
200
197
  createLeakedDouble,
201
198
  createLeakedMap,
202
199
  createLeakedString,
203
- parseInfoResponse,
204
200
  Script,
205
201
  ObjectType,
206
202
  ClusterScanCursor,
@@ -142,6 +142,67 @@ export type ReadFrom =
142
142
  | "AZAffinity";
143
143
  /**
144
144
  * Configuration settings for creating a client. Shared settings for standalone and cluster clients.
145
+ *
146
+ * @remarks
147
+ * The `BaseClientConfiguration` interface defines the foundational configuration options used when creating a client to connect to a Valkey server or cluster. It includes connection details, authentication, communication protocols, and various settings that influence the client's behavior and interaction with the server.
148
+ *
149
+ * ### Connection Details
150
+ *
151
+ * - **Addresses**: Use the `addresses` property to specify the hostnames and ports of the server(s) to connect to.
152
+ * - **Cluster Mode**: In cluster mode, the client will discover other nodes based on the provided addresses.
153
+ * - **Standalone Mode**: In standalone mode, only the provided nodes will be used.
154
+ *
155
+ * ### Security Settings
156
+ *
157
+ * - **TLS**: Enable secure communication using `useTLS`.
158
+ * - **Authentication**: Provide `credentials` to authenticate with the server.
159
+ *
160
+ * ### Communication Settings
161
+ *
162
+ * - **Request Timeout**: Set `requestTimeout` to specify how long the client should wait for a request to complete.
163
+ * - **Protocol Version**: Choose the serialization protocol using `protocol`.
164
+ *
165
+ * ### Client Identification
166
+ *
167
+ * - **Client Name**: Set `clientName` to identify the client connection.
168
+ *
169
+ * ### Read Strategy
170
+ *
171
+ * - Use `readFrom` to specify the client's read strategy (e.g., primary, preferReplica, AZAffinity).
172
+ *
173
+ * ### Availability Zone
174
+ *
175
+ * - Use `clientAz` to specify the client's availability zone, which can influence read operations when using `readFrom: 'AZAffinity'`.
176
+ *
177
+ * ### Decoder Settings
178
+ *
179
+ * - **Default Decoder**: Set `defaultDecoder` to specify how responses are decoded by default.
180
+ *
181
+ * ### Concurrency Control
182
+ *
183
+ * - **Inflight Requests Limit**: Control the number of concurrent requests using `inflightRequestsLimit`.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const config: BaseClientConfiguration = {
188
+ * addresses: [
189
+ * { host: 'redis-node-1.example.com', port: 6379 },
190
+ * { host: 'redis-node-2.example.com' }, // Defaults to port 6379
191
+ * ],
192
+ * useTLS: true,
193
+ * credentials: {
194
+ * username: 'myUser',
195
+ * password: 'myPassword',
196
+ * },
197
+ * requestTimeout: 5000, // 5 seconds
198
+ * protocol: ProtocolVersion.RESP3,
199
+ * clientName: 'myValkeyClient',
200
+ * readFrom: ReadFrom.AZAffinity,
201
+ * clientAz: 'us-east-1a',
202
+ * defaultDecoder: Decoder.String,
203
+ * inflightRequestsLimit: 1000,
204
+ * };
205
+ * ```
145
206
  */
146
207
  export interface BaseClientConfiguration {
147
208
  /**
@@ -181,7 +242,7 @@ export interface BaseClientConfiguration {
181
242
  * The duration in milliseconds that the client should wait for a request to complete.
182
243
  * This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries.
183
244
  * If the specified timeout is exceeded for a pending request, it will result in a timeout error.
184
- * If not set, a default value will be used.
245
+ * If not explicitly set, a default value of 250 milliseconds will be used.
185
246
  * Value must be an integer.
186
247
  */
187
248
  requestTimeout?: number;
@@ -224,6 +285,32 @@ export interface BaseClientConfiguration {
224
285
  */
225
286
  clientAz?: string;
226
287
  }
288
+ /**
289
+ * Represents advanced configuration settings for a client, including connection-related options.
290
+ *
291
+ * @remarks
292
+ * The `AdvancedBaseClientConfiguration` interface defines advanced configuration settings for managing the client's connection behavior.
293
+ *
294
+ * ### Connection Timeout
295
+ *
296
+ * - **Connection Timeout**: The `connectionTimeout` property specifies the duration (in milliseconds) the client should wait for a connection to be established.
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * const config: AdvancedBaseClientConfiguration = {
301
+ * connectionTimeout: 5000, // 5 seconds
302
+ * };
303
+ * ```
304
+ */
305
+ export interface AdvancedBaseClientConfiguration {
306
+ /**
307
+ * The duration in milliseconds to wait for a TCP/TLS connection to complete.
308
+ * This applies both during initial client creation and any reconnections that may occur during request processing.
309
+ * **Note**: A high connection timeout may lead to prolonged blocking of the entire command pipeline.
310
+ * If not explicitly set, a default value of 250 milliseconds will be used.
311
+ */
312
+ connectionTimeout?: number;
313
+ }
227
314
  /**
228
315
  * Enum of Valkey data types
229
316
  * `STRING`
@@ -5174,6 +5261,10 @@ export declare class BaseClient {
5174
5261
  * @internal
5175
5262
  */
5176
5263
  protected createClientRequest(options: BaseClientConfiguration): connection_request.IConnectionRequest;
5264
+ /**
5265
+ * @internal
5266
+ */
5267
+ protected configureAdvancedConfigurationBase(options: AdvancedBaseClientConfiguration, request: connection_request.IConnectionRequest): void;
5177
5268
  /**
5178
5269
  * @internal
5179
5270
  */
@@ -5216,5 +5307,11 @@ export declare class BaseClient {
5216
5307
  * ```
5217
5308
  */
5218
5309
  updateConnectionPassword(password: string | null, immediateAuth?: boolean): Promise<GlideString>;
5310
+ /**
5311
+ * Return a statistics
5312
+ *
5313
+ * @return Return an object that contains the statistics collected internally by GLIDE core
5314
+ */
5315
+ getStatistics(): object;
5219
5316
  }
5220
5317
  export {};
@@ -1679,6 +1679,18 @@ export interface BaseScanOptions {
1679
1679
  export interface ScanOptions extends BaseScanOptions {
1680
1680
  type?: ObjectType;
1681
1681
  }
1682
+ /**
1683
+ * Options for the SCAN command.
1684
+ * `match`: The match filter is applied to the result of the command and will only include keys that match the pattern specified.
1685
+ * `count`: `COUNT` is a just a hint for the command for how many elements to fetch from the server, the default is 10.
1686
+ * `type`: The type of the object to scan.
1687
+ * Types are the data types of Valkey: `string`, `list`, `set`, `zset`, `hash`, `stream`.
1688
+ * `allowNonCoveredSlots`: If true, the scan will keep scanning even if slots are not covered by the cluster.
1689
+ * By default, the scan will stop if slots are not covered by the cluster.
1690
+ */
1691
+ export interface ClusterScanOptions extends ScanOptions {
1692
+ allowNonCoveredSlots?: boolean;
1693
+ }
1682
1694
  /**
1683
1695
  * Options specific to the ZSCAN command, extending from the base scan options.
1684
1696
  */
@@ -2,7 +2,7 @@
2
2
  * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
3
  */
4
4
  import * as net from "net";
5
- import { BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
5
+ import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
6
6
  import { FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsFullResponse, InfoOptions, LolwutOptions, ScanOptions } from "./Commands";
7
7
  import { connection_request } from "./ProtobufMessage";
8
8
  import { Transaction } from "./Transaction";
@@ -36,6 +36,43 @@ export declare namespace GlideClientConfiguration {
36
36
  context?: any;
37
37
  }
38
38
  }
39
+ /**
40
+ * Configuration options for creating a {@link GlideClient | GlideClient}.
41
+ *
42
+ * Extends `BaseClientConfiguration` with properties specific to `GlideClient`, such as database selection,
43
+ * reconnection strategies, and Pub/Sub subscription settings.
44
+ *
45
+ * @remarks
46
+ * This configuration allows you to tailor the client's behavior when connecting to a standalone Valkey Glide server.
47
+ *
48
+ * - **Database Selection**: Use `databaseId` to specify which logical database to connect to.
49
+ * - **Reconnection Strategy**: Customize how the client should attempt reconnections using `connectionBackoff`.
50
+ * - `numberOfRetries`: The maximum number of retry attempts with increasing delays.
51
+ * - After this limit is reached, the retry interval becomes constant.
52
+ * - `factor`: A multiplier applied to the base delay between retries (e.g., `500` means a 500ms base delay).
53
+ * - `exponentBase`: The exponential growth factor for delays (e.g., `2` means the delay doubles with each retry).
54
+ * - **Pub/Sub Subscriptions**: Predefine Pub/Sub channels and patterns to subscribe to upon connection establishment.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const config: GlideClientConfiguration = {
59
+ * databaseId: 1,
60
+ * connectionBackoff: {
61
+ * numberOfRetries: 10, // Maximum retries before delay becomes constant
62
+ * factor: 500, // Base delay in milliseconds
63
+ * exponentBase: 2, // Delay doubles with each retry (2^N)
64
+ * },
65
+ * pubsubSubscriptions: {
66
+ * channelsAndPatterns: {
67
+ * [GlideClientConfiguration.PubSubChannelModes.Pattern]: new Set(['news.*']),
68
+ * },
69
+ * callback: (msg) => {
70
+ * console.log(`Received message on ${msg.channel}:`, msg.payload);
71
+ * },
72
+ * },
73
+ * };
74
+ * ```
75
+ */
39
76
  export type GlideClientConfiguration = BaseClientConfiguration & {
40
77
  /**
41
78
  * index of the logical database to connect to.
@@ -71,7 +108,23 @@ export type GlideClientConfiguration = BaseClientConfiguration & {
71
108
  * Will be applied via SUBSCRIBE/PSUBSCRIBE commands during connection establishment.
72
109
  */
73
110
  pubsubSubscriptions?: GlideClientConfiguration.PubSubSubscriptions;
111
+ /**
112
+ * Advanced configuration settings for the client.
113
+ */
114
+ advancedConfiguration?: AdvancedGlideClientConfiguration;
74
115
  };
116
+ /**
117
+ * Represents advanced configuration settings for creating a {@link GlideClient | GlideClient} used in {@link GlideClientConfiguration | GlideClientConfiguration}.
118
+ *
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const config: AdvancedGlideClientConfiguration = {
123
+ * connectionTimeout: 500, // Set the connection timeout to 500ms
124
+ * };
125
+ * ```
126
+ */
127
+ export type AdvancedGlideClientConfiguration = AdvancedBaseClientConfiguration & {};
75
128
  /**
76
129
  * Client used for connection to standalone servers.
77
130
  *
@@ -82,7 +135,57 @@ export declare class GlideClient extends BaseClient {
82
135
  * @internal
83
136
  */
84
137
  protected createClientRequest(options: GlideClientConfiguration): connection_request.IConnectionRequest;
138
+ /**
139
+ * Creates a new `GlideClient` instance and establishes a connection to a standalone Valkey Glide server.
140
+ *
141
+ * @param options - The configuration options for the client, including server addresses, authentication credentials, TLS settings, database selection, reconnection strategy, and Pub/Sub subscriptions.
142
+ * @returns A promise that resolves to a connected `GlideClient` instance.
143
+ *
144
+ * @remarks
145
+ * Use this static method to create and connect a `GlideClient` to a standalone Valkey Glide server. The client will automatically handle connection establishment, including any authentication and TLS configurations.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * // Connecting to a Standalone Server
150
+ * import { GlideClient, GlideClientConfiguration } from '@valkey/valkey-glide';
151
+ *
152
+ * const client = await GlideClient.createClient({
153
+ * addresses: [
154
+ * { host: 'primary.example.com', port: 6379 },
155
+ * { host: 'replica1.example.com', port: 6379 },
156
+ * ],
157
+ * databaseId: 1,
158
+ * credentials: {
159
+ * username: 'user1',
160
+ * password: 'passwordA',
161
+ * },
162
+ * useTLS: true,
163
+ * connectionBackoff: {
164
+ * numberOfRetries: 5,
165
+ * factor: 1000,
166
+ * exponentBase: 2,
167
+ * },
168
+ * pubsubSubscriptions: {
169
+ * channelsAndPatterns: {
170
+ * [GlideClientConfiguration.PubSubChannelModes.Exact]: new Set(['updates']),
171
+ * },
172
+ * callback: (msg) => {
173
+ * console.log(`Received message: ${msg.payload}`);
174
+ * },
175
+ * },
176
+ * });
177
+ * ```
178
+ *
179
+ * @remarks
180
+ * - **Authentication**: If `credentials` are provided, the client will attempt to authenticate using the specified username and password.
181
+ * - **TLS**: If `useTLS` is set to `true`, the client will establish a secure connection using TLS.
182
+ * - **Reconnection Strategy**: The `connectionBackoff` settings define how the client will attempt to reconnect in case of disconnections.
183
+ * - **Pub/Sub Subscriptions**: Any channels or patterns specified in `pubsubSubscriptions` will be subscribed to upon connection.
184
+ */
85
185
  static createClient(options: GlideClientConfiguration): Promise<GlideClient>;
186
+ /**
187
+ * @internal
188
+ */
86
189
  static __createClient(options: BaseClientConfiguration, connectedSocket: net.Socket): Promise<GlideClient>;
87
190
  /**
88
191
  * Execute a transaction by processing the queued commands.