@valkey/valkey-glide 1.3.4 → 1.3.5-rc2

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.
Files changed (29) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +36 -14
  3. package/build-ts/{src/BaseClient.d.ts → BaseClient.d.ts} +62 -118
  4. package/build-ts/BaseClient.js +6049 -0
  5. package/build-ts/{src/Transaction.d.ts → Batch.d.ts} +124 -67
  6. package/build-ts/Batch.js +3457 -0
  7. package/build-ts/{src/Commands.d.ts → Commands.d.ts} +171 -791
  8. package/build-ts/Commands.js +2708 -0
  9. package/build-ts/Errors.js +42 -0
  10. package/build-ts/{src/GlideClient.d.ts → GlideClient.d.ts} +55 -19
  11. package/build-ts/GlideClient.js +899 -0
  12. package/build-ts/{src/GlideClusterClient.d.ts → GlideClusterClient.d.ts} +78 -42
  13. package/build-ts/GlideClusterClient.js +1251 -0
  14. package/build-ts/Logger.js +67 -0
  15. package/build-ts/{src/ProtobufMessage.d.ts → ProtobufMessage.d.ts} +171 -634
  16. package/build-ts/ProtobufMessage.js +5265 -0
  17. package/build-ts/index.d.ts +16 -11
  18. package/build-ts/index.js +53 -216
  19. package/build-ts/native.d.ts +14 -0
  20. package/build-ts/native.js +342 -0
  21. package/build-ts/server-modules/GlideFt.js +628 -0
  22. package/build-ts/{src/server-modules → server-modules}/GlideFtOptions.d.ts +1 -1
  23. package/build-ts/server-modules/GlideFtOptions.js +5 -0
  24. package/build-ts/{src/server-modules → server-modules}/GlideJson.d.ts +65 -65
  25. package/build-ts/server-modules/GlideJson.js +1572 -0
  26. package/package.json +141 -64
  27. /package/build-ts/{src/Errors.d.ts → Errors.d.ts} +0 -0
  28. /package/build-ts/{src/Logger.d.ts → Logger.d.ts} +0 -0
  29. /package/build-ts/{src/server-modules → server-modules}/GlideFt.d.ts +0 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Logger = void 0;
7
+ const native_1 = require("./native");
8
+ const LEVEL = new Map([
9
+ ["error", 0 /* Level.Error */],
10
+ ["warn", 1 /* Level.Warn */],
11
+ ["info", 2 /* Level.Info */],
12
+ ["debug", 3 /* Level.Debug */],
13
+ ["trace", 4 /* Level.Trace */],
14
+ ["off", 5 /* Level.Off */],
15
+ [undefined, undefined],
16
+ ]);
17
+ /*
18
+ * A singleton class that allows logging which is consistent with logs from the internal rust core.
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.
23
+ */
24
+ class Logger {
25
+ constructor(level, fileName) {
26
+ Logger.logger_level = (0, native_1.InitInternalLogger)(LEVEL.get(level), fileName);
27
+ }
28
+ /**
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.
35
+ */
36
+ static log(logLevel, logIdentifier, message) {
37
+ if (!Logger._instance) {
38
+ new Logger();
39
+ }
40
+ const level = LEVEL.get(logLevel) || 0;
41
+ if (!(level <= Logger.logger_level))
42
+ return;
43
+ (0, native_1.log)(level, logIdentifier, message);
44
+ }
45
+ /**
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
+ */
51
+ static init(level, fileName) {
52
+ if (!this._instance) {
53
+ this._instance = new this(level, fileName);
54
+ }
55
+ }
56
+ /**
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".
61
+ */
62
+ static setLoggerConfig(level, fileName) {
63
+ this._instance = new this(level, fileName);
64
+ }
65
+ }
66
+ exports.Logger = Logger;
67
+ Logger.logger_level = 0;