@valkey/valkey-glide-darwin-arm64 1.2.0-rc3 → 1.2.0-rc4
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.
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BaseClient, DecoderOption, GlideString } from "../BaseClient";
|
|
5
5
|
import { ConditionalChange } from "../Commands";
|
|
6
|
-
|
|
7
|
-
import { GlideClusterClient } from "../GlideClusterClient";
|
|
8
|
-
export type ReturnTypeJson = GlideString | (GlideString | null)[];
|
|
6
|
+
export type ReturnTypeJson<T> = T | (T | null)[];
|
|
9
7
|
/**
|
|
10
8
|
* Represents options for formatting JSON data, to be used in the [JSON.GET](https://valkey.io/commands/json.get/) command.
|
|
11
9
|
*/
|
|
@@ -26,6 +24,7 @@ export declare class GlideJson {
|
|
|
26
24
|
/**
|
|
27
25
|
* Sets the JSON value at the specified `path` stored at `key`.
|
|
28
26
|
*
|
|
27
|
+
* @param client The client to execute the command.
|
|
29
28
|
* @param key - The key of the JSON document.
|
|
30
29
|
* @param path - Represents the path within the JSON document where the value will be set.
|
|
31
30
|
* The key will be modified only if `value` is added as the last child in the specified `path`, or if the specified `path` acts as the parent of a new child being added.
|
|
@@ -56,8 +55,11 @@ export declare class GlideJson {
|
|
|
56
55
|
/**
|
|
57
56
|
* Retrieves the JSON value at the specified `paths` stored at `key`.
|
|
58
57
|
*
|
|
58
|
+
* @param client The client to execute the command.
|
|
59
59
|
* @param key - The key of the JSON document.
|
|
60
|
-
* @param options -
|
|
60
|
+
* @param options - (Optional) Additional parameters:
|
|
61
|
+
* - (Optional) Options for formatting the byte representation of the JSON data. See {@link JsonGetOptions}.
|
|
62
|
+
* - (Optional) `decoder`: see {@link DecoderOption}.
|
|
61
63
|
* @returns ReturnTypeJson:
|
|
62
64
|
* - If one path is given:
|
|
63
65
|
* - For JSONPath (path starts with `$`):
|
|
@@ -96,5 +98,46 @@ export declare class GlideJson {
|
|
|
96
98
|
* // Output: "[]" - Empty array since the path does not exist in the JSON document.
|
|
97
99
|
* ```
|
|
98
100
|
*/
|
|
99
|
-
static get(client:
|
|
101
|
+
static get(client: BaseClient, key: GlideString, options?: JsonGetOptions & DecoderOption): Promise<ReturnTypeJson<GlideString>>;
|
|
102
|
+
/**
|
|
103
|
+
* Toggles a Boolean value stored at the specified `path` within the JSON document stored at `key`.
|
|
104
|
+
*
|
|
105
|
+
* @param client - The client to execute the command.
|
|
106
|
+
* @param key - The key of the JSON document.
|
|
107
|
+
* @param options - (Optional) Additional parameters:
|
|
108
|
+
* - (Optional) The JSONPath to specify. Defaults to the root if not specified.
|
|
109
|
+
* @returns - For JSONPath (`path` starts with `$`), returns a list of boolean replies for every possible path, with the toggled boolean value,
|
|
110
|
+
* or null for JSON values matching the path that are not boolean.
|
|
111
|
+
* - For legacy path (`path` doesn't starts with `$`), returns the value of the toggled boolean in `path`.
|
|
112
|
+
* - Note that when sending legacy path syntax, If `path` doesn't exist or the value at `path` isn't a boolean, an error is raised.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const value = {bool: true, nested: {bool: false, nested: {bool: 10}}};
|
|
117
|
+
* const jsonStr = JSON.stringify(value);
|
|
118
|
+
* const resultSet = await GlideJson.set("doc", "$", jsonStr);
|
|
119
|
+
* // Output: 'OK'
|
|
120
|
+
*
|
|
121
|
+
* const resultToggle = await.GlideJson.toggle(client, "doc", "$.bool")
|
|
122
|
+
* // Output: [false, true, null] - Indicates successful toggling of the Boolean values at path '$.bool' in the key stored at `doc`.
|
|
123
|
+
*
|
|
124
|
+
* const resultToggle = await.GlideJson.toggle(client, "doc", "bool")
|
|
125
|
+
* // Output: true - Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
|
|
126
|
+
*
|
|
127
|
+
* const resultToggle = await.GlideJson.toggle(client, "doc", "bool")
|
|
128
|
+
* // Output: true - Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
|
|
129
|
+
*
|
|
130
|
+
* const jsonGetStr = await GlideJson.get(client, "doc", "$");
|
|
131
|
+
* console.log(JSON.stringify(jsonGetStr));
|
|
132
|
+
* // Output: [{bool: true, nested: {bool: true, nested: {bool: 10}}}] - The updated JSON value in the key stored at `doc`.
|
|
133
|
+
*
|
|
134
|
+
* // Without specifying a path, the path defaults to root.
|
|
135
|
+
* console.log(await GlideJson.set(client, "doc2", ".", true)); // Output: "OK"
|
|
136
|
+
* console.log(await GlideJson.toggle(client,"doc2")); // Output: "false"
|
|
137
|
+
* console.log(await GlideJson.toggle(client, "doc2")); // Output: "true"
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
static toggle(client: BaseClient, key: GlideString, options?: {
|
|
141
|
+
path: GlideString;
|
|
142
|
+
}): Promise<ReturnTypeJson<boolean>>;
|
|
100
143
|
}
|
|
@@ -52,6 +52,7 @@ class GlideJson {
|
|
|
52
52
|
/**
|
|
53
53
|
* Sets the JSON value at the specified `path` stored at `key`.
|
|
54
54
|
*
|
|
55
|
+
* @param client The client to execute the command.
|
|
55
56
|
* @param key - The key of the JSON document.
|
|
56
57
|
* @param path - Represents the path within the JSON document where the value will be set.
|
|
57
58
|
* The key will be modified only if `value` is added as the last child in the specified `path`, or if the specified `path` acts as the parent of a new child being added.
|
|
@@ -88,8 +89,11 @@ class GlideJson {
|
|
|
88
89
|
/**
|
|
89
90
|
* Retrieves the JSON value at the specified `paths` stored at `key`.
|
|
90
91
|
*
|
|
92
|
+
* @param client The client to execute the command.
|
|
91
93
|
* @param key - The key of the JSON document.
|
|
92
|
-
* @param options -
|
|
94
|
+
* @param options - (Optional) Additional parameters:
|
|
95
|
+
* - (Optional) Options for formatting the byte representation of the JSON data. See {@link JsonGetOptions}.
|
|
96
|
+
* - (Optional) `decoder`: see {@link DecoderOption}.
|
|
93
97
|
* @returns ReturnTypeJson:
|
|
94
98
|
* - If one path is given:
|
|
95
99
|
* - For JSONPath (path starts with `$`):
|
|
@@ -138,6 +142,53 @@ class GlideJson {
|
|
|
138
142
|
return _executeCommand(client, args, options);
|
|
139
143
|
});
|
|
140
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Toggles a Boolean value stored at the specified `path` within the JSON document stored at `key`.
|
|
147
|
+
*
|
|
148
|
+
* @param client - The client to execute the command.
|
|
149
|
+
* @param key - The key of the JSON document.
|
|
150
|
+
* @param options - (Optional) Additional parameters:
|
|
151
|
+
* - (Optional) The JSONPath to specify. Defaults to the root if not specified.
|
|
152
|
+
* @returns - For JSONPath (`path` starts with `$`), returns a list of boolean replies for every possible path, with the toggled boolean value,
|
|
153
|
+
* or null for JSON values matching the path that are not boolean.
|
|
154
|
+
* - For legacy path (`path` doesn't starts with `$`), returns the value of the toggled boolean in `path`.
|
|
155
|
+
* - Note that when sending legacy path syntax, If `path` doesn't exist or the value at `path` isn't a boolean, an error is raised.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const value = {bool: true, nested: {bool: false, nested: {bool: 10}}};
|
|
160
|
+
* const jsonStr = JSON.stringify(value);
|
|
161
|
+
* const resultSet = await GlideJson.set("doc", "$", jsonStr);
|
|
162
|
+
* // Output: 'OK'
|
|
163
|
+
*
|
|
164
|
+
* const resultToggle = await.GlideJson.toggle(client, "doc", "$.bool")
|
|
165
|
+
* // Output: [false, true, null] - Indicates successful toggling of the Boolean values at path '$.bool' in the key stored at `doc`.
|
|
166
|
+
*
|
|
167
|
+
* const resultToggle = await.GlideJson.toggle(client, "doc", "bool")
|
|
168
|
+
* // Output: true - Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
|
|
169
|
+
*
|
|
170
|
+
* const resultToggle = await.GlideJson.toggle(client, "doc", "bool")
|
|
171
|
+
* // Output: true - Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
|
|
172
|
+
*
|
|
173
|
+
* const jsonGetStr = await GlideJson.get(client, "doc", "$");
|
|
174
|
+
* console.log(JSON.stringify(jsonGetStr));
|
|
175
|
+
* // Output: [{bool: true, nested: {bool: true, nested: {bool: 10}}}] - The updated JSON value in the key stored at `doc`.
|
|
176
|
+
*
|
|
177
|
+
* // Without specifying a path, the path defaults to root.
|
|
178
|
+
* console.log(await GlideJson.set(client, "doc2", ".", true)); // Output: "OK"
|
|
179
|
+
* console.log(await GlideJson.toggle(client,"doc2")); // Output: "false"
|
|
180
|
+
* console.log(await GlideJson.toggle(client, "doc2")); // Output: "true"
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
static toggle(client, key, options) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const args = ["JSON.TOGGLE", key];
|
|
186
|
+
if (options !== undefined) {
|
|
187
|
+
args.push(options.path);
|
|
188
|
+
}
|
|
189
|
+
return _executeCommand(client, args);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
141
192
|
}
|
|
142
193
|
exports.GlideJson = GlideJson;
|
|
143
194
|
//# sourceMappingURL=GlideJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlideJson.js","sourceRoot":"","sources":["../../../src/server-modules/GlideJson.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;AAIH,gDAA6C;AAqB7C;;GAEG;AACH,SAAS,qBAAqB,CAAC,OAAuB;IAClD,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,SAA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