@valkey/valkey-glide 1.3.4 → 1.3.5-rc10
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/LICENSE +201 -0
- package/README.md +53 -18
- package/build-ts/{src/BaseClient.d.ts → BaseClient.d.ts} +62 -118
- package/build-ts/BaseClient.js +6049 -0
- package/build-ts/{src/Transaction.d.ts → Batch.d.ts} +124 -67
- package/build-ts/Batch.js +3457 -0
- package/build-ts/{src/Commands.d.ts → Commands.d.ts} +171 -791
- package/build-ts/Commands.js +2708 -0
- package/build-ts/Errors.js +42 -0
- package/build-ts/{src/GlideClient.d.ts → GlideClient.d.ts} +55 -19
- package/build-ts/GlideClient.js +899 -0
- package/build-ts/{src/GlideClusterClient.d.ts → GlideClusterClient.d.ts} +78 -42
- package/build-ts/GlideClusterClient.js +1251 -0
- package/build-ts/Logger.d.ts +47 -0
- package/build-ts/Logger.js +78 -0
- package/build-ts/{src/ProtobufMessage.d.ts → ProtobufMessage.d.ts} +135 -634
- package/build-ts/ProtobufMessage.js +5159 -0
- package/build-ts/index.d.ts +16 -11
- package/build-ts/index.js +53 -216
- package/build-ts/native.d.ts +92 -0
- package/build-ts/native.js +365 -0
- package/build-ts/server-modules/GlideFt.js +628 -0
- package/build-ts/{src/server-modules → server-modules}/GlideFtOptions.d.ts +1 -1
- package/build-ts/server-modules/GlideFtOptions.js +5 -0
- package/build-ts/{src/server-modules → server-modules}/GlideJson.d.ts +65 -65
- package/build-ts/server-modules/GlideJson.js +1572 -0
- package/package.json +140 -64
- package/build-ts/src/Logger.d.ts +0 -32
- /package/build-ts/{src/Errors.d.ts → Errors.d.ts} +0 -0
- /package/build-ts/{src/server-modules → server-modules}/GlideFt.d.ts +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
3
|
+
*/
|
|
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
|
+
*/
|
|
13
|
+
export declare class Logger {
|
|
14
|
+
private static _instance;
|
|
15
|
+
private static logger_level;
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
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.
|
|
24
|
+
*/
|
|
25
|
+
static log(logLevel: LevelOptions, logIdentifier: string, message: string, err?: Error): void;
|
|
26
|
+
/**
|
|
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.
|
|
38
|
+
*/
|
|
39
|
+
static init(level?: LevelOptions, fileName?: string): void;
|
|
40
|
+
/**
|
|
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.
|
|
45
|
+
*/
|
|
46
|
+
static setLoggerConfig(level: LevelOptions, fileName?: string): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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("../build-ts/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 GLIDE core.
|
|
19
|
+
* The logger can be set up in 2 ways -
|
|
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.
|
|
24
|
+
*/
|
|
25
|
+
class Logger {
|
|
26
|
+
constructor(level, fileName) {
|
|
27
|
+
Logger.logger_level = (0, native_1.InitInternalLogger)(LEVEL.get(level), fileName);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
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.
|
|
36
|
+
*/
|
|
37
|
+
static log(logLevel, logIdentifier, message, err) {
|
|
38
|
+
if (!Logger._instance) {
|
|
39
|
+
new Logger();
|
|
40
|
+
}
|
|
41
|
+
if (err) {
|
|
42
|
+
message += `: ${err.stack}`;
|
|
43
|
+
}
|
|
44
|
+
const level = LEVEL.get(logLevel) || 0;
|
|
45
|
+
if (!(level <= Logger.logger_level))
|
|
46
|
+
return;
|
|
47
|
+
(0, native_1.log)(level, logIdentifier, message);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
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.
|
|
61
|
+
*/
|
|
62
|
+
static init(level, fileName) {
|
|
63
|
+
if (!this._instance) {
|
|
64
|
+
this._instance = new this(level, fileName);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
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.
|
|
72
|
+
*/
|
|
73
|
+
static setLoggerConfig(level, fileName) {
|
|
74
|
+
this._instance = new this(level, fileName);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.Logger = Logger;
|
|
78
|
+
Logger.logger_level = 0;
|