@valkey/valkey-glide 1.3.5-rc0 → 1.3.5-rc11

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/README.md CHANGED
@@ -27,23 +27,36 @@ Refer to the [Supported Engine Versions table](https://github.com/valkey-io/valk
27
27
 
28
28
  The release of Valkey GLIDE was tested on the following platforms:
29
29
 
30
- Linux:
30
+ ### Linux GNU
31
31
 
32
- - Ubuntu 22.04.5 (x86_64/amd64 and arm64/aarch64)
33
- - Amazon Linux 2023 (AL2023) (x86_64/amd64 and arm64/aarch64)
32
+ Tests are actively running on **Ubuntu 24**, but the package is being build for any linux using **glibc 2.17** or higher.
33
+ Manual tests have been done on:
34
34
 
35
- macOS:
35
+ - Fedora 39
36
+ - Ubuntu 22.04
37
+ - Amazon Linux 2
38
+ - Debian 12.
36
39
 
37
- - macOS 14.7 (Apple silicon/aarch_64)
38
- - macOS 13.7 (x86_64/amd64)
40
+ ### MacOS (Darwin)
39
41
 
40
- Alpine:
42
+ MacOS Apple Silicon/aarch_64 and x86_64/amd64.
43
+
44
+ - Full tests are running on MacOS 15.0 arm64/aarch64
45
+ - Minimal tests are running on: MacOS 13.5 x86*64/amd64 *(We do not recommend using MacOS Intel for production, It is supported for development purposes)\_
46
+
47
+ ### Alpine
48
+
49
+ All alpine versions that are using _musl libc_ 1.2.3 (All Alpine non deprecated alpine versions) or higher should be supported.
50
+ Tests are running on:
41
51
 
42
52
  - node:alpine (x86_64/amd64 and arm64/aarch64)
43
53
 
44
54
  ## NodeJS supported version
45
55
 
46
56
  Node.js 16 or higher.
57
+ **For npm users on linux it is recommended to use npm >=11 since it support optional download base on libc, yarn users should not be concerned**
58
+
59
+ - Note: The library is dependent on the [protobufjs library](https://protobufjs.github.io/protobuf.js/#installation), which add a size to the package. The package is using the protobufjs/minimal version, hence, if size matter, bundlers should be able to strip the unused code. It should reduce the size of the dependency from 19kb gzipped to 6.5kb gzipped.
47
60
 
48
61
  ### Building & Testing
49
62
 
@@ -59,7 +72,7 @@ npm i @valkey/valkey-glide
59
72
 
60
73
  ## Basic Examples
61
74
 
62
- #### Standalone Mode:
75
+ #### Standalone Mode
63
76
 
64
77
  ```typescript
65
78
  import { GlideClient, GlideClusterClient, Logger } from "@valkey/valkey-glide";
@@ -86,7 +99,7 @@ const get_response = await client.get("foo");
86
99
  console.log(`Get response is = ${get_response}`);
87
100
  ```
88
101
 
89
- #### Cluster Mode:
102
+ #### Cluster Mode
90
103
 
91
104
  ```typescript
92
105
  import { GlideClient, GlideClusterClient, Logger } from "@valkey/valkey-glide";
@@ -1,15 +1,15 @@
1
1
  import { Buffer, Writer } from "protobufjs/minimal";
2
- import { AggregationType, BaseScanOptions, BatchOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import { Script } from "../build-ts/native";
3
+ import { command_request, connection_request, response } from "../build-ts/ProtobufMessage";
4
+ import { AggregationType, BaseScanOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
3
5
  BitFieldSubCommands, // eslint-disable-line @typescript-eslint/no-unused-vars
4
- BitOffsetOptions, BitwiseOperation, Boundary, ClusterBatchOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
6
+ BitOffsetOptions, BitwiseOperation, Boundary, // eslint-disable-line @typescript-eslint/no-unused-vars
5
7
  ExpireOptions, GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
6
8
  GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, HScanOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, // eslint-disable-line @typescript-eslint/no-unused-vars
7
9
  RangeByIndex, RangeByLex, RangeByScore, RestoreOptions, ScoreFilter, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ZAddOptions, ZScanOptions } from "./Commands";
8
10
  import { ConnectionError, RequestError, ValkeyError } from "./Errors";
9
11
  import { GlideClientConfiguration } from "./GlideClient";
10
12
  import { GlideClusterClientConfiguration, Routes } from "./GlideClusterClient";
11
- import { Script } from "./native";
12
- import { command_request, connection_request, response } from "../build-ts/ProtobufMessage";
13
13
  type PromiseFunction = (value?: any) => void;
14
14
  type ErrorFunction = (error: ValkeyError) => void;
15
15
  export type ReturnTypeRecord = {
@@ -334,7 +334,6 @@ export interface PubSubMsg {
334
334
  channel: GlideString;
335
335
  pattern?: GlideString | null;
336
336
  }
337
- export type WritePromiseOptions = BaseOptions | (BaseOptions & (ClusterBatchOptions | BatchOptions));
338
337
  /**
339
338
  * Base client interface for GLIDE
340
339
  */
@@ -43,11 +43,11 @@ exports.convertRecordToGlideRecord = convertRecordToGlideRecord;
43
43
  */
44
44
  const net = __importStar(require("net"));
45
45
  const minimal_1 = require("protobufjs/minimal");
46
+ const native_1 = require("../build-ts/native");
47
+ const ProtobufMessage_1 = require("../build-ts/ProtobufMessage");
46
48
  const Commands_1 = require("./Commands");
47
49
  const Errors_1 = require("./Errors");
48
50
  const Logger_1 = require("./Logger");
49
- const native_1 = require("./native");
50
- const ProtobufMessage_1 = require("../build-ts/ProtobufMessage");
51
51
  var ProtocolVersion;
52
52
  (function (ProtocolVersion) {
53
53
  /** Use RESP2 to communicate with the server nodes. */
@@ -6047,4 +6047,3 @@ class BaseClient {
6047
6047
  }
6048
6048
  }
6049
6049
  exports.BaseClient = BaseClient;
6050
- //# sourceMappingURL=BaseClient.js.map
package/build-ts/Batch.js CHANGED
@@ -3455,4 +3455,3 @@ class Transaction extends Batch {
3455
3455
  }
3456
3456
  }
3457
3457
  exports.Transaction = Transaction;
3458
- //# sourceMappingURL=Batch.js.map
@@ -216,8 +216,8 @@ exports.createXGroupSetid = createXGroupSetid;
216
216
  exports.createScriptExists = createScriptExists;
217
217
  exports.createScriptFlush = createScriptFlush;
218
218
  exports.createScriptKill = createScriptKill;
219
- const native_1 = require("./native");
220
219
  const long_1 = __importDefault(require("long"));
220
+ const native_1 = require("../build-ts/native");
221
221
  const BaseClient_1 = require("./BaseClient");
222
222
  const ProtobufMessage_1 = require("../build-ts/ProtobufMessage");
223
223
  var RequestType = ProtobufMessage_1.command_request.RequestType;
@@ -2706,4 +2706,3 @@ function createScriptFlush(mode) {
2706
2706
  function createScriptKill() {
2707
2707
  return createCommand(RequestType.ScriptKill, []);
2708
2708
  }
2709
- //# sourceMappingURL=Commands.js.map
@@ -40,4 +40,3 @@ exports.ConnectionError = ConnectionError;
40
40
  class ConfigurationError extends RequestError {
41
41
  }
42
42
  exports.ConfigurationError = ConfigurationError;
43
- //# sourceMappingURL=Errors.js.map
@@ -897,4 +897,3 @@ class GlideClient extends BaseClient_1.BaseClient {
897
897
  }
898
898
  }
899
899
  exports.GlideClient = GlideClient;
900
- //# sourceMappingURL=GlideClient.js.map
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
3
  */
4
+ import { ClusterScanCursor, Script } from "../build-ts/native";
4
5
  import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
5
6
  import { ClusterBatch } from "./Batch";
6
7
  import { ClusterBatchOptions, ClusterScanOptions, FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsSingleResponse, InfoOptions, LolwutOptions } from "./Commands";
7
- import { ClusterScanCursor, Script } from "./native";
8
8
  /** An extension to command option types with {@link Routes}. */
9
9
  export interface RouteOption {
10
10
  /**
@@ -4,10 +4,10 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GlideClusterClient = exports.GlideClusterClientConfiguration = void 0;
7
+ const native_1 = require("../build-ts/native");
8
+ const ProtobufMessage_1 = require("../build-ts/ProtobufMessage");
7
9
  const BaseClient_1 = require("./BaseClient");
8
10
  const Commands_1 = require("./Commands");
9
- const native_1 = require("./native");
10
- const ProtobufMessage_1 = require("../build-ts/ProtobufMessage");
11
11
  /* eslint-disable-next-line @typescript-eslint/no-namespace */
12
12
  var GlideClusterClientConfiguration;
13
13
  (function (GlideClusterClientConfiguration) {
@@ -1249,4 +1249,3 @@ class GlideClusterClient extends BaseClient_1.BaseClient {
1249
1249
  }
1250
1250
  }
1251
1251
  exports.GlideClusterClient = GlideClusterClient;
1252
- //# sourceMappingURL=GlideClusterClient.js.map
@@ -2,31 +2,46 @@
2
2
  * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
3
  */
4
4
  export type LevelOptions = "error" | "warn" | "info" | "debug" | "trace" | "off";
5
+ /**
6
+ * A singleton class that allows logging which is consistent with logs from the internal GLIDE core.
7
+ * The logger can be set up in 2 ways -
8
+ * 1. By calling {@link init}, which configures the logger only if it wasn't previously configured.
9
+ * 2. By calling {@link setLoggerConfig}, which replaces the existing configuration, and means that new logs
10
+ * will not be saved with the logs that were sent before the call. The previous logs will remain unchanged.
11
+ * If none of these functions are called, the first log attempt will initialize a new logger with default configuration.
12
+ */
5
13
  export declare class Logger {
6
14
  private static _instance;
7
15
  private static logger_level;
8
16
  private constructor();
9
17
  /**
10
- * take the arguments from the user and provide to the core-logger (see ../logger-core)
11
- * if the level is higher then the logger level (error is 0, warn 1, etc.) simply return without operation
12
- * if a logger instance doesn't exist, create new one with default mode (decided by rust core, normally - level: error, target: console)
13
- * logIdentifier arg is a string contain data that suppose to give the log a context and make it easier to find certain type of logs.
14
- * when the log is connect to certain task the identifier should be the task id, when the log is not part of specific task the identifier should give a context to the log - for example, "socket connection".
15
- * External users shouldn't use this function.
18
+ * Logs the provided message if the provided log level is lower then the logger level.
19
+ *
20
+ * @param logLevel - The log level of the provided message.
21
+ * @param logIdentifier - The log identifier should give the log a context.
22
+ * @param message - The message to log.
23
+ * @param err - The exception or error to log.
16
24
  */
17
- static log(logLevel: LevelOptions, logIdentifier: string, message: string): void;
25
+ static log(logLevel: LevelOptions, logIdentifier: string, message: string, err?: Error): void;
18
26
  /**
19
- * Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger.
20
- * The logger will filter all logs with a level lower than the given level,
21
- * If given a fileName argument, will write the logs to files postfixed with fileName. If fileName isn't provided, the logs will be written to the console.
22
- * To turn off the logger, provide the level "off".
27
+ * Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to
28
+ * replace an existing logger.
29
+ * The logger will filter all logs with a level lower than the given level.
30
+ * If given a fileName argument, will write the logs to files postfixed with fileName. If fileName isn't provided,
31
+ * the logs will be written to the console.
32
+ *
33
+ * @param level - Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF].
34
+ * If log level isn't provided, the logger will be configured with default configuration.
35
+ * To turn off logging completely, set the level to level "off".
36
+ * @param fileName - If provided the target of the logs will be the file mentioned.
37
+ * Otherwise, logs will be printed to the console.
23
38
  */
24
39
  static init(level?: LevelOptions, fileName?: string): void;
25
40
  /**
26
- * configure the logger.
27
- * the level argument is the level of the logs you want the system to provide (error logs, warn logs, etc.)
28
- * the filename argument is optional - if provided the target of the logs will be the file mentioned, else will be the console
29
- * To turn off the logger, provide the level "off".
41
+ * Creates a new logger instance and configure it with the provided log level and file name.
42
+ *
43
+ * @param level - Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF].
44
+ * @param fileName - The target of the logs will be the file mentioned.
30
45
  */
31
46
  static setLoggerConfig(level: LevelOptions, fileName?: string): void;
32
47
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Logger = void 0;
7
- const native_1 = require("./native");
7
+ const native_1 = require("../build-ts/native");
8
8
  const LEVEL = new Map([
9
9
  ["error", 0 /* Level.Error */],
10
10
  ["warn", 1 /* Level.Warn */],
@@ -14,39 +14,50 @@ const LEVEL = new Map([
14
14
  ["off", 5 /* Level.Off */],
15
15
  [undefined, undefined],
16
16
  ]);
17
- /*
18
- * A singleton class that allows logging which is consistent with logs from the internal rust core.
17
+ /**
18
+ * A singleton class that allows logging which is consistent with logs from the internal GLIDE core.
19
19
  * The logger can be set up in 2 ways -
20
- * 1. By calling init, which configures the logger only if it wasn't previously configured.
21
- * 2. By calling Logger.setLoggerConfig, which replaces the existing configuration, and means that new logs will not be saved with the logs that were sent before the call. The previous logs will remain unchanged.
22
- * If no call to any of these function is received, the first log attempt will configure the logger with default configuration decided by rust core.
20
+ * 1. By calling {@link init}, which configures the logger only if it wasn't previously configured.
21
+ * 2. By calling {@link setLoggerConfig}, which replaces the existing configuration, and means that new logs
22
+ * will not be saved with the logs that were sent before the call. The previous logs will remain unchanged.
23
+ * If none of these functions are called, the first log attempt will initialize a new logger with default configuration.
23
24
  */
24
25
  class Logger {
25
26
  constructor(level, fileName) {
26
27
  Logger.logger_level = (0, native_1.InitInternalLogger)(LEVEL.get(level), fileName);
27
28
  }
28
29
  /**
29
- * take the arguments from the user and provide to the core-logger (see ../logger-core)
30
- * if the level is higher then the logger level (error is 0, warn 1, etc.) simply return without operation
31
- * if a logger instance doesn't exist, create new one with default mode (decided by rust core, normally - level: error, target: console)
32
- * logIdentifier arg is a string contain data that suppose to give the log a context and make it easier to find certain type of logs.
33
- * when the log is connect to certain task the identifier should be the task id, when the log is not part of specific task the identifier should give a context to the log - for example, "socket connection".
34
- * External users shouldn't use this function.
30
+ * Logs the provided message if the provided log level is lower then the logger level.
31
+ *
32
+ * @param logLevel - The log level of the provided message.
33
+ * @param logIdentifier - The log identifier should give the log a context.
34
+ * @param message - The message to log.
35
+ * @param err - The exception or error to log.
35
36
  */
36
- static log(logLevel, logIdentifier, message) {
37
+ static log(logLevel, logIdentifier, message, err) {
37
38
  if (!Logger._instance) {
38
39
  new Logger();
39
40
  }
41
+ if (err) {
42
+ message += `: ${err.stack}`;
43
+ }
40
44
  const level = LEVEL.get(logLevel) || 0;
41
45
  if (!(level <= Logger.logger_level))
42
46
  return;
43
47
  (0, native_1.log)(level, logIdentifier, message);
44
48
  }
45
49
  /**
46
- * Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger.
47
- * The logger will filter all logs with a level lower than the given level,
48
- * If given a fileName argument, will write the logs to files postfixed with fileName. If fileName isn't provided, the logs will be written to the console.
49
- * To turn off the logger, provide the level "off".
50
+ * Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to
51
+ * replace an existing logger.
52
+ * The logger will filter all logs with a level lower than the given level.
53
+ * If given a fileName argument, will write the logs to files postfixed with fileName. If fileName isn't provided,
54
+ * the logs will be written to the console.
55
+ *
56
+ * @param level - Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF].
57
+ * If log level isn't provided, the logger will be configured with default configuration.
58
+ * To turn off logging completely, set the level to level "off".
59
+ * @param fileName - If provided the target of the logs will be the file mentioned.
60
+ * Otherwise, logs will be printed to the console.
50
61
  */
51
62
  static init(level, fileName) {
52
63
  if (!this._instance) {
@@ -54,10 +65,10 @@ class Logger {
54
65
  }
55
66
  }
56
67
  /**
57
- * configure the logger.
58
- * the level argument is the level of the logs you want the system to provide (error logs, warn logs, etc.)
59
- * the filename argument is optional - if provided the target of the logs will be the file mentioned, else will be the console
60
- * To turn off the logger, provide the level "off".
68
+ * Creates a new logger instance and configure it with the provided log level and file name.
69
+ *
70
+ * @param level - Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF].
71
+ * @param fileName - The target of the logs will be the file mentioned.
61
72
  */
62
73
  static setLoggerConfig(level, fileName) {
63
74
  this._instance = new this(level, fileName);
@@ -65,4 +76,3 @@ class Logger {
65
76
  }
66
77
  exports.Logger = Logger;
67
78
  Logger.logger_level = 0;
68
- //# sourceMappingURL=Logger.js.map