@valkey/valkey-glide-darwin-arm64 1.3.4 → 255.255.255

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 (45) hide show
  1. package/package.json +31 -95
  2. package/README.md +0 -106
  3. package/build-ts/index.d.ts +0 -14
  4. package/build-ts/index.js +0 -34
  5. package/build-ts/index.js.map +0 -1
  6. package/build-ts/src/BaseClient.d.ts +0 -5254
  7. package/build-ts/src/BaseClient.js +0 -6391
  8. package/build-ts/src/BaseClient.js.map +0 -1
  9. package/build-ts/src/Commands.d.ts +0 -1034
  10. package/build-ts/src/Commands.js +0 -2710
  11. package/build-ts/src/Commands.js.map +0 -1
  12. package/build-ts/src/Errors.d.ts +0 -21
  13. package/build-ts/src/Errors.js +0 -43
  14. package/build-ts/src/Errors.js.map +0 -1
  15. package/build-ts/src/GlideClient.d.ts +0 -832
  16. package/build-ts/src/GlideClient.js +0 -940
  17. package/build-ts/src/GlideClient.js.map +0 -1
  18. package/build-ts/src/GlideClusterClient.d.ts +0 -1323
  19. package/build-ts/src/GlideClusterClient.js +0 -1276
  20. package/build-ts/src/GlideClusterClient.js.map +0 -1
  21. package/build-ts/src/Logger.d.ts +0 -32
  22. package/build-ts/src/Logger.js +0 -68
  23. package/build-ts/src/Logger.js.map +0 -1
  24. package/build-ts/src/ProtobufMessage.d.ts +0 -2889
  25. package/build-ts/src/ProtobufMessage.js +0 -8785
  26. package/build-ts/src/ProtobufMessage.js.map +0 -1
  27. package/build-ts/src/Transaction.d.ts +0 -2963
  28. package/build-ts/src/Transaction.js +0 -3388
  29. package/build-ts/src/Transaction.js.map +0 -1
  30. package/build-ts/src/server-modules/GlideFt.d.ts +0 -412
  31. package/build-ts/src/server-modules/GlideFt.js +0 -664
  32. package/build-ts/src/server-modules/GlideFt.js.map +0 -1
  33. package/build-ts/src/server-modules/GlideFtOptions.d.ts +0 -244
  34. package/build-ts/src/server-modules/GlideFtOptions.js +0 -6
  35. package/build-ts/src/server-modules/GlideFtOptions.js.map +0 -1
  36. package/build-ts/src/server-modules/GlideJson.d.ts +0 -1335
  37. package/build-ts/src/server-modules/GlideJson.js +0 -1628
  38. package/build-ts/src/server-modules/GlideJson.js.map +0 -1
  39. package/index.ts +0 -15
  40. package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
  41. package/node_modules/glide-rs/index.d.ts +0 -71
  42. package/node_modules/glide-rs/index.js +0 -317
  43. package/node_modules/glide-rs/package.json +0 -65
  44. package/npm/glide/index.ts +0 -391
  45. package/npm/glide/package.json +0 -67
@@ -1,1335 +0,0 @@
1
- /**
2
- * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
- */
4
- import { BaseClient, DecoderOption, GlideString } from "../BaseClient";
5
- import { ConditionalChange } from "../Commands";
6
- import { ClusterTransaction, Transaction } from "../Transaction";
7
- export type ReturnTypeJson<T> = T | (T | null)[];
8
- export type UniversalReturnTypeJson<T> = T | T[];
9
- /**
10
- * Represents options for formatting JSON data, to be used in the {@link GlideJson.get | JSON.GET} command.
11
- */
12
- export interface JsonGetOptions {
13
- /** The path or list of paths within the JSON document. Default is root `$`. */
14
- path?: GlideString | GlideString[];
15
- /** Sets an indentation string for nested levels. */
16
- indent?: GlideString;
17
- /** Sets a string that's printed at the end of each line. */
18
- newline?: GlideString;
19
- /** Sets a string that's put between a key and a value. */
20
- space?: GlideString;
21
- /** Optional, allowed to be present for legacy compatibility and has no other effect */
22
- noescape?: boolean;
23
- }
24
- /** Additional options for {@link GlideJson.arrpop | JSON.ARRPOP} command. */
25
- export interface JsonArrPopOptions {
26
- /** The path within the JSON document. */
27
- path: GlideString;
28
- /** The index of the element to pop. Out of boundary indexes are rounded to their respective array boundaries. */
29
- index?: number;
30
- }
31
- /** Module for JSON commands. */
32
- export declare class GlideJson {
33
- /**
34
- * Sets the JSON value at the specified `path` stored at `key`.
35
- *
36
- * @param client The client to execute the command.
37
- * @param key - The key of the JSON document.
38
- * @param path - Represents the path within the JSON document where the value will be set.
39
- * 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.
40
- * @param value - The value to set at the specific path, in JSON formatted bytes or str.
41
- * @param options - (Optional) Additional parameters:
42
- * - (Optional) `conditionalChange` - Set the value only if the given condition is met (within the key or path).
43
- * Equivalent to [`XX` | `NX`] in the module API.
44
- * - (Optional) `decoder`: see {@link DecoderOption}.
45
- *
46
- * @returns If the value is successfully set, returns `"OK"`.
47
- * If `value` isn't set because of `conditionalChange`, returns `null`.
48
- *
49
- * @example
50
- * ```typescript
51
- * const value = {a: 1.0, b:2};
52
- * const jsonStr = JSON.stringify(value);
53
- * const result = await GlideJson.set(client, "doc", "$", jsonStr);
54
- * console.log(result); // 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
55
- *
56
- * const jsonGetStr = await GlideJson.get(client, "doc", {path: "$"}); // Returns the value at path '$' in the JSON document stored at `doc` as JSON string.
57
- * console.log(jsonGetStr); // '[{"a":1.0,"b":2}]'
58
- * console.log(JSON.stringify(jsonGetStr)); // [{"a": 1.0, "b": 2}] # JSON object retrieved from the key `doc`
59
- * ```
60
- */
61
- static set(client: BaseClient, key: GlideString, path: GlideString, value: GlideString, options?: {
62
- conditionalChange: ConditionalChange;
63
- } & DecoderOption): Promise<"OK" | null>;
64
- /**
65
- * Retrieves the JSON value at the specified `paths` stored at `key`.
66
- *
67
- * @param client The client to execute the command.
68
- * @param key - The key of the JSON document.
69
- * @param options - (Optional) Additional parameters:
70
- * - (Optional) Options for formatting the byte representation of the JSON data. See {@link JsonGetOptions}.
71
- * - (Optional) `decoder`: see {@link DecoderOption}.
72
- * @returns
73
- * - If one path is given:
74
- * - For JSONPath (path starts with `$`):
75
- * - Returns a stringified JSON list of bytes replies for every possible path,
76
- * or a byte string representation of an empty array, if path doesn't exist.
77
- * If `key` doesn't exist, returns `null`.
78
- * - For legacy path (path doesn't start with `$`):
79
- * Returns a byte string representation of the value in `path`.
80
- * If `path` doesn't exist, an error is raised.
81
- * If `key` doesn't exist, returns `null`.
82
- * - If multiple paths are given:
83
- * Returns a stringified JSON object in bytes, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
84
- * In case of multiple paths, and `paths` are a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.
85
- *
86
- * @example
87
- * ```typescript
88
- * const jsonStr = await GlideJson.get(client, 'doc', {path: '$'});
89
- * console.log(JSON.parse(jsonStr as string));
90
- * // Output: [{"a": 1.0, "b" :2}] - JSON object retrieved from the key `doc`.
91
- *
92
- * const jsonData = await GlideJson.get(client, 'doc', {path: '$'});
93
- * console.log(jsonData);
94
- * // Output: '[{"a":1.0,"b":2}]' - Returns the value at path '$' in the JSON document stored at `doc`.
95
- *
96
- * const formattedJson = await GlideJson.get(client, 'doc', {
97
- * ['$.a', '$.b']
98
- * indent: " ",
99
- * newline: "\n",
100
- * space: " "
101
- * });
102
- * console.log(formattedJson);
103
- * // Output: "{\n \"$.a\": [\n 1.0\n ],\n \"$.b\": [\n 2\n ]\n}" - Returns values at paths '$.a' and '$.b' with custom format.
104
- *
105
- * const nonExistingPath = await GlideJson.get(client, 'doc', {path: '$.non_existing_path'});
106
- * console.log(nonExistingPath);
107
- * // Output: "[]" - Empty array since the path does not exist in the JSON document.
108
- * ```
109
- */
110
- static get(client: BaseClient, key: GlideString, options?: JsonGetOptions & DecoderOption): Promise<ReturnTypeJson<GlideString>>;
111
- /**
112
- * Retrieves the JSON values at the specified `path` stored at multiple `keys`.
113
- *
114
- * @remarks When in cluster mode, if keys in `keyValueMap` map to different hash slots, the command
115
- * will be split across these slots and executed separately for each. This means the command
116
- * is atomic only at the slot level. If one or more slot-specific requests fail, the entire
117
- * call will return the first encountered error, even though some requests may have succeeded
118
- * while others did not. If this behavior impacts your application logic, consider splitting
119
- * the request into sub-requests per slot to ensure atomicity.
120
- *
121
- * @param client - The client to execute the command.
122
- * @param keys - The keys of the JSON documents.
123
- * @param path - The path within the JSON documents.
124
- * @param options - (Optional) See {@link DecoderOption}.
125
- * @returns
126
- * - For JSONPath (path starts with `$`):
127
- * Returns a stringified JSON list replies for every possible path, or a string representation
128
- * of an empty array, if path doesn't exist.
129
- * - For legacy path (path doesn't start with `$`):
130
- * Returns a string representation of the value in `path`. If `path` doesn't exist,
131
- * the corresponding array element will be `null`.
132
- * - If a `key` doesn't exist, the corresponding array element will be `null`.
133
- *
134
- * @example
135
- * ```typescript
136
- * await GlideJson.set(client, "doc1", "$", '{"a": 1, "b": ["one", "two"]}');
137
- * await GlideJson.set(client, "doc2", "$", '{"a": 1, "c": false}');
138
- * const res = await GlideJson.mget(client, [ "doc1", "doc2", "doc3" ], "$.c");
139
- * console.log(res); // Output: ["[]", "[false]", null]
140
- * ```
141
- */
142
- static mget(client: BaseClient, keys: GlideString[], path: GlideString, options?: DecoderOption): Promise<GlideString[]>;
143
- /**
144
- * Inserts one or more values into the array at the specified `path` within the JSON
145
- * document stored at `key`, before the given `index`.
146
- *
147
- * @param client - The client to execute the command.
148
- * @param key - The key of the JSON document.
149
- * @param path - The path within the JSON document.
150
- * @param index - The array index before which values are inserted.
151
- * @param values - The JSON values to be inserted into the array.
152
- * JSON string values must be wrapped with quotes. For example, to insert `"foo"`, pass `"\"foo\""`.
153
- * @returns
154
- * - For JSONPath (path starts with `$`):
155
- * Returns an array with a list of integers for every possible path,
156
- * indicating the new length of the array, or `null` for JSON values matching
157
- * the path that are not an array. If `path` does not exist, an empty array
158
- * will be returned.
159
- * - For legacy path (path doesn't start with `$`):
160
- * Returns an integer representing the new length of the array. If multiple paths are
161
- * matched, returns the length of the first modified array. If `path` doesn't
162
- * exist or the value at `path` is not an array, an error is raised.
163
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
164
- *
165
- * @example
166
- * ```typescript
167
- * await GlideJson.set(client, "doc", "$", '[[], ["a"], ["a", "b"]]');
168
- * const result = await GlideJson.arrinsert(client, "doc", "$[*]", 0, ['"c"', '{"key": "value"}', "true", "null", '["bar"]']);
169
- * console.log(result); // Output: [5, 6, 7]
170
- * const doc = await GlideJson.get(client, "doc");
171
- * console.log(doc); // Output: '[["c",{"key":"value"},true,null,["bar"]],["c",{"key":"value"},true,null,["bar"],"a"],["c",{"key":"value"},true,null,["bar"],"a","b"]]'
172
- * ```
173
- * @example
174
- * ```typescript
175
- * await GlideJson.set(client, "doc", "$", '[[], ["a"], ["a", "b"]]');
176
- * const result = await GlideJson.arrinsert(client, "doc", ".", 0, ['"c"'])
177
- * console.log(result); // Output: 4
178
- * const doc = await GlideJson.get(client, "doc");
179
- * console.log(doc); // Output: '[\"c\",[],[\"a\"],[\"a\",\"b\"]]'
180
- * ```
181
- */
182
- static arrinsert(client: BaseClient, key: GlideString, path: GlideString, index: number, values: GlideString[]): Promise<ReturnTypeJson<number>>;
183
- /**
184
- * Pops an element from the array located at `path` in the JSON document stored at `key`.
185
- *
186
- * @param client - The client to execute the command.
187
- * @param key - The key of the JSON document.
188
- * @param options - (Optional) See {@link JsonArrPopOptions} and {@link DecoderOption}.
189
- * @returns
190
- * - For JSONPath (path starts with `$`):
191
- * Returns an array with a strings for every possible path, representing the popped JSON
192
- * values, or `null` for JSON values matching the path that are not an array
193
- * or an empty array.
194
- * - For legacy path (path doesn't start with `$`):
195
- * Returns a string representing the popped JSON value, or `null` if the
196
- * array at `path` is empty. If multiple paths are matched, the value from
197
- * the first matching array that is not empty is returned. If `path` doesn't
198
- * exist or the value at `path` is not an array, an error is raised.
199
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
200
- *
201
- * @example
202
- * ```typescript
203
- * await GlideJson.set(client, "doc", "$", '{"a": [1, 2, true], "b": {"a": [3, 4, ["value", 3, false], 5], "c": {"a": 42}}}');
204
- * let result = await GlideJson.arrpop(client, "doc", { path: "$.a", index: 1 });
205
- * console.log(result); // Output: ['2'] - Popped second element from array at path `$.a`
206
- * result = await GlideJson.arrpop(client, "doc", { path: "$..a" });
207
- * console.log(result); // Output: ['true', '5', null] - Popped last elements from all arrays matching path `$..a`
208
- *
209
- * result = await GlideJson.arrpop(client, "doc", { path: "..a" });
210
- * console.log(result); // Output: "1" - First match popped (from array at path ..a)
211
- * // Even though only one value is returned from `..a`, subsequent arrays are also affected
212
- * console.log(await GlideJson.get(client, "doc", "$..a")); // Output: "[[], [3, 4], 42]"
213
- * ```
214
- * @example
215
- * ```typescript
216
- * await GlideJson.set(client, "doc", "$", '[[], ["a"], ["a", "b", "c"]]');
217
- * let result = await GlideJson.arrpop(client, "doc", { path: ".", index: -1 });
218
- * console.log(result); // Output: '["a","b","c"]' - Popped last elements at path `.`
219
- * ```
220
- */
221
- static arrpop(client: BaseClient, key: GlideString, options?: JsonArrPopOptions & DecoderOption): Promise<ReturnTypeJson<GlideString>>;
222
- /**
223
- * Retrieves the length of the array at the specified `path` within the JSON document stored at `key`.
224
- *
225
- * @param client - The client to execute the command.
226
- * @param key - The key of the JSON document.
227
- * @param options - (Optional) Additional parameters:
228
- * - (Optional) `path`: The path within the JSON document. Defaults to the root (`"."`) if not specified.
229
- * @returns
230
- * - For JSONPath (path starts with `$`):
231
- * Returns an array with a list of integers for every possible path,
232
- * indicating the length of the array, or `null` for JSON values matching
233
- * the path that are not an array. If `path` does not exist, an empty array
234
- * will be returned.
235
- * - For legacy path (path doesn't start with `$`):
236
- * Returns an integer representing the length of the array. If multiple paths are
237
- * matched, returns the length of the first matching array. If `path` doesn't
238
- * exist or the value at `path` is not an array, an error is raised.
239
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
240
- *
241
- * @example
242
- * ```typescript
243
- * await GlideJson.set(client, "doc", "$", '{"a": [1, 2, 3], "b": {"a": [1, 2], "c": {"a": 42}}}');
244
- * console.log(await GlideJson.arrlen(client, "doc", { path: "$" })); // Output: [null] - No array at the root path.
245
- * console.log(await GlideJson.arrlen(client, "doc", { path: "$.a" })); // Output: [3] - Retrieves the length of the array at path $.a.
246
- * console.log(await GlideJson.arrlen(client, "doc", { path: "$..a" })); // Output: [3, 2, null] - Retrieves lengths of arrays found at all levels of the path `$..a`.
247
- * console.log(await GlideJson.arrlen(client, "doc", { path: "..a" })); // Output: 3 - Legacy path retrieves the first array match at path `..a`.
248
- * ```
249
- * @example
250
- * ```typescript
251
- * await GlideJson.set(client, "doc", "$", '[1, 2, 3, 4]');
252
- * console.log(await GlideJson.arrlen(client, "doc")); // Output: 4 - the length of array at root.
253
- * ```
254
- */
255
- static arrlen(client: BaseClient, key: GlideString, options?: {
256
- path: GlideString;
257
- }): Promise<ReturnTypeJson<number>>;
258
- /**
259
- * Trims an array at the specified `path` within the JSON document stored at `key` so that it becomes a subarray [start, end], both inclusive.
260
- * If `start` < 0, it is treated as 0.
261
- * If `end` >= size (size of the array), it is treated as size-1.
262
- * If `start` >= size or `start` > `end`, the array is emptied and 0 is returned.
263
- *
264
- * @param client - The client to execute the command.
265
- * @param key - The key of the JSON document.
266
- * @param path - The path within the JSON document.
267
- * @param start - The start index, inclusive.
268
- * @param end - The end index, inclusive.
269
- * @returns
270
- * - For JSONPath (`path` starts with `$`):
271
- * - Returns a list of integer replies for every possible path, indicating the new length of the array,
272
- * or `null` for JSON values matching the path that are not an array.
273
- * - If the array is empty, its corresponding return value is 0.
274
- * - If `path` doesn't exist, an empty array will be returned.
275
- * - If an index argument is out of bounds, an error is raised.
276
- * - For legacy path (`path` doesn't start with `$`):
277
- * - Returns an integer representing the new length of the array.
278
- * - If the array is empty, its corresponding return value is 0.
279
- * - If multiple paths match, the length of the first trimmed array match is returned.
280
- * - If `path` doesn't exist, or the value at `path` is not an array, an error is raised.
281
- * - If an index argument is out of bounds, an error is raised.
282
- *
283
- * @example
284
- * ```typescript
285
- * console.log(await GlideJson.set(client, "doc", "$", '[[], ["a"], ["a", "b"], ["a", "b", "c"]]');
286
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
287
- * const result = await GlideJson.arrtrim(client, "doc", "$[*]", 0, 1);
288
- * console.log(result);
289
- * // Output: [0, 1, 2, 2]
290
- * console.log(await GlideJson.get(client, "doc", "$"));
291
- * // Output: '[[],["a"],["a","b"],["a","b"]]' - Returns the value at path '$' in the JSON document stored at `doc`.
292
- * ```
293
- * @example
294
- * ```typescript
295
- * console.log(await GlideJson.set(client, "doc", "$", '{"children": ["John", "Jack", "Tom", "Bob", "Mike"]}');
296
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
297
- * result = await GlideJson.arrtrim(client, "doc", ".children", 0, 1);
298
- * console.log(result);
299
- * // Output: 2
300
- * console.log(await GlideJson.get(client, "doc", ".children"));
301
- * // Output: '["John", "Jack"]' - Returns the value at path '$' in the JSON document stored at `doc`.
302
- * ```
303
- */
304
- static arrtrim(client: BaseClient, key: GlideString, path: GlideString, start: number, end: number): Promise<ReturnTypeJson<number>>;
305
- /**
306
- * Searches for the first occurrence of a `scalar` JSON value in the arrays at the `path`.
307
- * Out of range errors are treated by rounding the index to the array's `start` and `end.
308
- * If `start` > `end`, return `-1` (not found).
309
- *
310
- * @param client - The client to execute the command.
311
- * @param key - The key of the JSON document.
312
- * @param path - The path within the JSON document.
313
- * @param scalar - The scalar value to search for.
314
- * @param options - (Optional) Additional parameters:
315
- * - (Optional) `start`: The start index, inclusive. Default to 0 if not provided.
316
- * - (Optional) `end`: The end index, exclusive. Default to 0 if not provided.
317
- * 0 or -1 means the last element is included.
318
- * @returns
319
- * - For JSONPath (path starts with `$`):
320
- * Returns an array with a list of integers for every possible path,
321
- * indicating the index of the matching element. The value is `-1` if not found.
322
- * If a value is not an array, its corresponding return value is `null`.
323
- * - For legacy path (path doesn't start with `$`):
324
- * Returns an integer representing the index of matching element, or `-1` if
325
- * not found. If the value at the `path` is not an array, an error is raised.
326
- *
327
- * @example
328
- * ```typescript
329
- * await GlideJson.set(client, "doc", "$", '{"a": ["value", 3], "b": {"a": [3, ["value", false], 5]}}');
330
- * console.log(await GlideJson.arrindex(client, "doc", "$..a", 3, { start: 3, end: 3 }); // Output: [2, -1]
331
- * ```
332
- */
333
- static arrindex(client: BaseClient, key: GlideString, path: GlideString, scalar: GlideString | number | boolean | null, options?: {
334
- start: number;
335
- end?: number;
336
- }): Promise<ReturnTypeJson<number>>;
337
- /**
338
- * Toggles a Boolean value stored at the specified `path` within the JSON document stored at `key`.
339
- *
340
- * @param client - The client to execute the command.
341
- * @param key - The key of the JSON document.
342
- * @param options - (Optional) Additional parameters:
343
- * - (Optional) `path`: The path within the JSON document. Defaults to the root (`"."`) if not specified.
344
- * @returns - For JSONPath (`path` starts with `$`), returns a list of boolean replies for every possible path, with the toggled boolean value,
345
- * or `null` for JSON values matching the path that are not boolean.
346
- * - For legacy path (`path` doesn't starts with `$`), returns the value of the toggled boolean in `path`.
347
- * - 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.
348
- *
349
- * @example
350
- * ```typescript
351
- * const value = {bool: true, nested: {bool: false, nested: {bool: 10}}};
352
- * const jsonStr = JSON.stringify(value);
353
- * const resultSet = await GlideJson.set(client, "doc", "$", jsonStr);
354
- * // Output: 'OK'
355
- *
356
- * const resultToggle = await.GlideJson.toggle(client, "doc", {path: "$.bool"});
357
- * // Output: [false, true, null] - Indicates successful toggling of the Boolean values at path '$.bool' in the key stored at `doc`.
358
- *
359
- * const resultToggle = await.GlideJson.toggle(client, "doc", {path: "bool"});
360
- * // Output: true - Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
361
- *
362
- * const resultToggle = await.GlideJson.toggle(client, "doc", {path: "bool"});
363
- * // Output: true - Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
364
- *
365
- * const jsonGetStr = await GlideJson.get(client, "doc", {path: "$"});
366
- * console.log(JSON.stringify(jsonGetStr));
367
- * // Output: [{bool: true, nested: {bool: true, nested: {bool: 10}}}] - The updated JSON value in the key stored at `doc`.
368
- *
369
- * // Without specifying a path, the path defaults to root.
370
- * console.log(await GlideJson.set(client, "doc2", ".", true)); // Output: "OK"
371
- * console.log(await GlideJson.toggle(client, {path: "doc2"})); // Output: "false"
372
- * console.log(await GlideJson.toggle(client, {path: "doc2"})); // Output: "true"
373
- * ```
374
- */
375
- static toggle(client: BaseClient, key: GlideString, options?: {
376
- path: GlideString;
377
- }): Promise<ReturnTypeJson<boolean>>;
378
- /**
379
- * Deletes the JSON value at the specified `path` within the JSON document stored at `key`.
380
- *
381
- * @param client - The client to execute the command.
382
- * @param key - The key of the JSON document.
383
- * @param options - (Optional) Additional parameters:
384
- * - (Optional) `path`: If `null`, deletes the entire JSON document at `key`.
385
- * @returns - The number of elements removed. If `key` or `path` doesn't exist, returns 0.
386
- *
387
- * @example
388
- * ```typescript
389
- * console.log(await GlideJson.set(client, "doc", "$", '{a: 1, nested: {a:2, b:3}}'));
390
- * // Output: "OK" - Indicates successful setting of the value at path '$' in the key stored at `doc`.
391
- * console.log(await GlideJson.del(client, "doc", {path: "$..a"}));
392
- * // Output: 2 - Indicates successful deletion of the specific values in the key stored at `doc`.
393
- * console.log(await GlideJson.get(client, "doc", {path: "$"}));
394
- * // Output: "[{nested: {b: 3}}]" - Returns the value at path '$' in the JSON document stored at `doc`.
395
- * console.log(await GlideJson.del(client, "doc"));
396
- * // Output: 1 - Deletes the entire JSON document stored at `doc`.
397
- * ```
398
- */
399
- static del(client: BaseClient, key: GlideString, options?: {
400
- path: GlideString;
401
- }): Promise<number>;
402
- /**
403
- * Deletes the JSON value at the specified `path` within the JSON document stored at `key`. This command is
404
- * an alias of {@link del}.
405
- *
406
- * @param client - The client to execute the command.
407
- * @param key - The key of the JSON document.
408
- * @param options - (Optional) Additional parameters:
409
- * - (Optional) `path`: If `null`, deletes the entire JSON document at `key`.
410
- * @returns - The number of elements removed. If `key` or `path` doesn't exist, returns 0.
411
- *
412
- * @example
413
- * ```typescript
414
- * console.log(await GlideJson.set(client, "doc", "$", '{a: 1, nested: {a:2, b:3}}'));
415
- * // Output: "OK" - Indicates successful setting of the value at path '$' in the key stored at `doc`.
416
- * console.log(await GlideJson.forget(client, "doc", {path: "$..a"}));
417
- * // Output: 2 - Indicates successful deletion of the specific values in the key stored at `doc`.
418
- * console.log(await GlideJson.get(client, "doc", {path: "$"}));
419
- * // Output: "[{nested: {b: 3}}]" - Returns the value at path '$' in the JSON document stored at `doc`.
420
- * console.log(await GlideJson.forget(client, "doc"));
421
- * // Output: 1 - Deletes the entire JSON document stored at `doc`.
422
- * ```
423
- */
424
- static forget(client: BaseClient, key: GlideString, options?: {
425
- path: GlideString;
426
- }): Promise<number>;
427
- /**
428
- * Reports the type of values at the given path.
429
- *
430
- * @param client - The client to execute the command.
431
- * @param key - The key of the JSON document.
432
- * @param options - (Optional) Additional parameters:
433
- * - (Optional) `path`: Defaults to root (`"."`) if not provided.
434
- * @returns
435
- * - For JSONPath (path starts with `$`):
436
- * - Returns an array of strings that represents the type of value at each path.
437
- * The type is one of "null", "boolean", "string", "number", "integer", "object" and "array".
438
- * - If a path does not exist, its corresponding return value is `null`.
439
- * - Empty array if the document key does not exist.
440
- * - For legacy path (path doesn't start with `$`):
441
- * - String that represents the type of the value.
442
- * - `null` if the document key does not exist.
443
- * - `null` if the JSON path is invalid or does not exist.
444
- *
445
- * @example
446
- * ```typescript
447
- * console.log(await GlideJson.set(client, "doc", "$", '[1, 2.3, "foo", true, null, {}, []]'));
448
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
449
- * const result = await GlideJson.type(client, "doc", {path: "$[*]"});
450
- * console.log(result);
451
- * // Output: ["integer", "number", "string", "boolean", null, "object", "array"];
452
- * console.log(await GlideJson.set(client, "doc2", ".", "{Name: 'John', Age: 27}"));
453
- * console.log(await GlideJson.type(client, "doc2")); // Output: "object"
454
- * console.log(await GlideJson.type(client, "doc2", {path: ".Age"})); // Output: "integer"
455
- * ```
456
- */
457
- static type(client: BaseClient, key: GlideString, options?: {
458
- path: GlideString;
459
- }): Promise<ReturnTypeJson<GlideString>>;
460
- /**
461
- * Clears arrays or objects at the specified JSON path in the document stored at `key`.
462
- * Numeric values are set to `0`, boolean values are set to `false`, and string values are converted to empty strings.
463
- *
464
- * @param client - The client to execute the command.
465
- * @param key - The key of the JSON document.
466
- * @param options - (Optional) Additional parameters:
467
- * - (Optional) `path`: The JSON path to the arrays or objects to be cleared. Defaults to root if not provided.
468
- * @returns The number of containers cleared, numeric values zeroed, and booleans toggled to `false`,
469
- * and string values converted to empty strings.
470
- * If `path` doesn't exist, or the value at `path` is already empty (e.g., an empty array, object, or string), `0` is returned.
471
- * If `key doesn't exist, an error is raised.
472
- *
473
- * @example
474
- * ```typescript
475
- * console.log(await GlideJson.set(client, "doc", "$", '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14, "nullVal": null}'));
476
- * // Output: 'OK' - JSON document is successfully set.
477
- * console.log(await GlideJson.clear(client, "doc", {path: "$.*"}));
478
- * // Output: 6 - 6 values are cleared (arrays/objects/strings/numbers/booleans), but `null` remains as is.
479
- * console.log(await GlideJson.get(client, "doc", "$"));
480
- * // Output: '[{"obj":{},"arr":[],"str":"","bool":false,"int":0,"float":0.0,"nullVal":null}]'
481
- * console.log(await GlideJson.clear(client, "doc", {path: "$.*"}));
482
- * // Output: 0 - No further clearing needed since the containers are already empty and the values are defaults.
483
- *
484
- * console.log(await GlideJson.set(client, "doc", "$", '{"a": 1, "b": {"a": [5, 6, 7], "b": {"a": true}}, "c": {"a": "value", "b": {"a": 3.5}}, "d": {"a": {"foo": "foo"}}, "nullVal": null}'));
485
- * // Output: 'OK'
486
- * console.log(await GlideJson.clear(client, "doc", {path: "b.a[1:3]"}));
487
- * // Output: 2 - 2 elements (`6` and `7`) are cleared.
488
- * console.log(await GlideJson.clear(client, "doc", {path: "b.a[1:3]"}));
489
- * // Output: 0 - No elements cleared since specified slice has already been cleared.
490
- * console.log(await GlideJson.get(client, "doc", {path: "$..a"}));
491
- * // Output: '[1,[5,0,0],true,"value",3.5,{"foo":"foo"}]'
492
- *
493
- * console.log(await GlideJson.clear(client, "doc", {path: "$..a"}));
494
- * // Output: 6 - All numeric, boolean, and string values across paths are cleared.
495
- * console.log(await GlideJson.get(client, "doc", {path: "$..a"}));
496
- * // Output: '[0,[],false,"",0.0,{}]'
497
- * ```
498
- */
499
- static clear(client: BaseClient, key: GlideString, options?: {
500
- path: GlideString;
501
- }): Promise<ReturnTypeJson<number>>;
502
- /**
503
- * Retrieve the JSON value at the specified `path` within the JSON document stored at `key`.
504
- * The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).
505
- * - JSON null is mapped to the RESP Null Bulk String.
506
- * - JSON Booleans are mapped to RESP Simple string.
507
- * - JSON integers are mapped to RESP Integers.
508
- * - JSON doubles are mapped to RESP Bulk Strings.
509
- * - JSON strings are mapped to RESP Bulk Strings.
510
- * - JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
511
- * - JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.
512
- *
513
- * @param client - The client to execute the command.
514
- * @param key - The key of the JSON document.
515
- * @param options - (Optional) Additional parameters:
516
- * - (Optional) `path`: The path within the JSON document, defaults to root (`"."`) if not provided.
517
- * - (Optional) `decoder`: see {@link DecoderOption}.
518
- * @returns
519
- * - For JSONPath (path starts with `$`):
520
- * - Returns an array of replies for every possible path, indicating the RESP form of the JSON value.
521
- * If `path` doesn't exist, returns an empty array.
522
- * - For legacy path (path doesn't start with `$`):
523
- * - Returns a single reply for the JSON value at the specified `path`, in its RESP form.
524
- * If multiple paths match, the value of the first JSON value match is returned. If `path` doesn't exist, an error is raised.
525
- * - If `key` doesn't exist, `null` is returned.
526
- *
527
- * @example
528
- * ```typescript
529
- * console.log(await GlideJson.set(client, "doc", ".", '{a: [1, 2, 3], b: {a: [1, 2], c: {a: 42}}}'));
530
- * // Output: 'OK' - Indicates successful setting of the value at path '.' in the key stored at `doc`.
531
- * const result = await GlideJson.resp(client, "doc", {path: "$..a"});
532
- * console.log(result);
533
- * // Output: [ ["[", 1, 2, 3], ["[", 1, 2], [42]];
534
- * console.log(await GlideJson.type(client, "doc", {path: "..a"})); // Output: ["[", 1, 2, 3]
535
- * ```
536
- */
537
- static resp(client: BaseClient, key: GlideString, options?: {
538
- path: GlideString;
539
- } & DecoderOption): Promise<UniversalReturnTypeJson<(number | GlideString) | (number | GlideString | null) | null>>;
540
- /**
541
- * Returns the length of the JSON string value stored at the specified `path` within
542
- * the JSON document stored at `key`.
543
- *
544
- * @param client - The client to execute the command.
545
- * @param key - The key of the JSON document.
546
- * @param options - (Optional) Additional parameters:
547
- * - (Optional) `path`: The path within the JSON document, Defaults to root (`"."`) if not provided.
548
- * @returns
549
- * - For JSONPath (path starts with `$`):
550
- * - Returns a list of integer replies for every possible path, indicating the length of
551
- * the JSON string value, or `null` for JSON values matching the path that
552
- * are not string.
553
- * - For legacy path (path doesn't start with `$`):
554
- * - Returns the length of the JSON value at `path` or `null` if `key` doesn't exist.
555
- * - If multiple paths match, the length of the first matched string is returned.
556
- * - If the JSON value at`path` is not a string or if `path` doesn't exist, an error is raised.
557
- * - If `key` doesn't exist, `null` is returned.
558
- *
559
- * @example
560
- * ```typescript
561
- * console.log(await GlideJson.set(client, "doc", "$", '{a:"foo", nested: {a: "hello"}, nested2: {a: 31}}'));
562
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
563
- * console.log(await GlideJson.strlen(client, "doc", {path: "$..a"}));
564
- * // Output: [3, 5, null] - The length of the string values at path '$..a' in the key stored at `doc`.
565
- *
566
- * console.log(await GlideJson.strlen(client, "doc", {path: "nested.a"}));
567
- * // Output: 5 - The length of the JSON value at path 'nested.a' in the key stored at `doc`.
568
- *
569
- * console.log(await GlideJson.strlen(client, "doc", {path: "$"}));
570
- * // Output: [null] - Returns an array with null since the value at root path does in the JSON document stored at `doc` is not a string.
571
- *
572
- * console.log(await GlideJson.strlen(client, "non_existent_key", {path: "."}));
573
- * // Output: null - return null if key does not exist.
574
- * ```
575
- */
576
- static strlen(client: BaseClient, key: GlideString, options?: {
577
- path: GlideString;
578
- }): Promise<ReturnTypeJson<number>>;
579
- /**
580
- * Appends the specified `value` to the string stored at the specified `path` within the JSON document stored at `key`.
581
- *
582
- * @param client - The client to execute the command.
583
- * @param key - The key of the JSON document.
584
- * @param value - The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
585
- * @param options - (Optional) Additional parameters:
586
- * - (Optional) `path`: The path within the JSON document, defaults to root (`"."`) if not provided.
587
- * @returns
588
- * - For JSONPath (path starts with `$`):
589
- * - Returns a list of integer replies for every possible path, indicating the length of the resulting string after appending `value`,
590
- * or None for JSON values matching the path that are not string.
591
- * - If `key` doesn't exist, an error is raised.
592
- * - For legacy path (path doesn't start with `$`):
593
- * - Returns the length of the resulting string after appending `value` to the string at `path`.
594
- * - If multiple paths match, the length of the last updated string is returned.
595
- * - If the JSON value at `path` is not a string of if `path` doesn't exist, an error is raised.
596
- * - If `key` doesn't exist, an error is raised.
597
- *
598
- * @example
599
- * ```typescript
600
- * console.log(await GlideJson.set(client, "doc", "$", '{a:"foo", nested: {a: "hello"}, nested2: {a: 31}}'));
601
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
602
- * console.log(await GlideJson.strappend(client, "doc", jsonpy.dumps("baz"), {path: "$..a"}))
603
- * // Output: [6, 8, null] - The new length of the string values at path '$..a' in the key stored at `doc` after the append operation.
604
- *
605
- * console.log(await GlideJson.strappend(client, "doc", '"foo"', {path: "nested.a"}));
606
- * // Output: 11 - The length of the string value after appending "foo" to the string at path 'nested.array' in the key stored at `doc`.
607
- *
608
- * const result = JSON.parse(await GlideJson.get(client, "doc", {path: "$"}));
609
- * console.log(result);
610
- * // Output: [{"a":"foobaz", "nested": {"a": "hellobazfoo"}, "nested2": {"a": 31}}] - The updated JSON value in the key stored at `doc`.
611
- * ```
612
- */
613
- static strappend(client: BaseClient, key: GlideString, value: GlideString, options?: {
614
- path: GlideString;
615
- }): Promise<ReturnTypeJson<number>>;
616
- /**
617
- * Appends one or more `values` to the JSON array at the specified `path` within the JSON
618
- * document stored at `key`.
619
- *
620
- * @param client - The client to execute the command.
621
- * @param key - The key of the JSON document.
622
- * @param path - The path within the JSON document.
623
- * @param values - The JSON values to be appended to the array.
624
- * JSON string values must be wrapped with quotes. For example, to append `"foo"`, pass `"\"foo\""`.
625
- * @returns
626
- * - For JSONPath (path starts with `$`):
627
- * Returns an array with a list of integers for every possible path,
628
- * indicating the new length of the array, or `null` for JSON values matching
629
- * the path that are not an array. If `path` does not exist, an empty array
630
- * will be returned.
631
- * - For legacy path (path doesn't start with `$`):
632
- * Returns an integer representing the new length of the array. If multiple paths are
633
- * matched, returns the length of the first modified array. If `path` doesn't
634
- * exist or the value at `path` is not an array, an error is raised.
635
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
636
- *
637
- * @example
638
- * ```typescript
639
- * await GlideJson.set(client, "doc", "$", '{"a": 1, "b": ["one", "two"]}');
640
- * const result = await GlideJson.arrappend(client, "doc", "$.b", ["three"]);
641
- * console.log(result); // Output: [3] - the new length of the array at path '$.b' after appending the value.
642
- * const result = await GlideJson.arrappend(client, "doc", ".b", ["four"]);
643
- * console.log(result); // Output: 4 - the new length of the array at path '.b' after appending the value.
644
- * const doc = await json.get(client, "doc");
645
- * console.log(doc); // Output: '{"a": 1, "b": ["one", "two", "three", "four"]}'
646
- * ```
647
- */
648
- static arrappend(client: BaseClient, key: GlideString, path: GlideString, values: GlideString[]): Promise<ReturnTypeJson<number>>;
649
- /**
650
- * Reports memory usage in bytes of a JSON object at the specified `path` within the JSON document stored at `key`.
651
- *
652
- * @param client - The client to execute the command.
653
- * @param key - The key of the JSON document.
654
- * @param value - The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
655
- * @param options - (Optional) Additional parameters:
656
- * - (Optional) `path`: The path within the JSON document, returns total memory usage if no path is given.
657
- * @returns
658
- * - For JSONPath (path starts with `$`):
659
- * - Returns an array of numbers for every possible path, indicating the memory usage.
660
- * If `path` does not exist, an empty array will be returned.
661
- * - For legacy path (path doesn't start with `$`):
662
- * - Returns an integer representing the memory usage. If multiple paths are matched,
663
- * returns the data of the first matching object. If `path` doesn't exist, an error is raised.
664
- * - If `key` doesn't exist, returns `null`.
665
- *
666
- * @example
667
- * ```typescript
668
- * console.log(await GlideJson.set(client, "doc", "$", '[1, 2.3, "foo", true, null, {}, [], {a:1, b:2}, [1, 2, 3]]'));
669
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
670
- * console.log(await GlideJson.debugMemory(client, "doc", {path: ".."});
671
- * // Output: 258
672
- * ```
673
- */
674
- static debugMemory(client: BaseClient, key: GlideString, options?: {
675
- path: GlideString;
676
- }): Promise<ReturnTypeJson<number>>;
677
- /**
678
- * Reports the number of fields at the specified `path` within the JSON document stored at `key`.
679
- *
680
- * @param client - The client to execute the command.
681
- * @param key - The key of the JSON document.
682
- * @param value - The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
683
- * @param options - (Optional) Additional parameters:
684
- * - (Optional) `path`: The path within the JSON document, returns total number of fields if no path is given.
685
- * @returns
686
- * - For JSONPath (path starts with `$`):
687
- * - Returns an array of numbers for every possible path, indicating the number of fields.
688
- * If `path` does not exist, an empty array will be returned.
689
- * - For legacy path (path doesn't start with `$`):
690
- * - Returns an integer representing the memory usage. If multiple paths are matched,
691
- * returns the data of the first matching object. If `path` doesn't exist, an error is raised.
692
- * - If `key` doesn't exist, returns `null`.
693
- *
694
- * @example
695
- * ```typescript
696
- * console.log(await GlideJson.set(client, "doc", "$", '[1, 2.3, "foo", true, null, {}, [], {a:1, b:2}, [1, 2, 3]]'));
697
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
698
- * console.log(await GlideJson.debugFields(client, "doc", {path: "$[*]"});
699
- * // Output: [1, 1, 1, 1, 1, 0, 0, 2, 3]
700
- * ```
701
- */
702
- static debugFields(client: BaseClient, key: GlideString, options?: {
703
- path: GlideString;
704
- }): Promise<ReturnTypeJson<number>>;
705
- /**
706
- * Increments or decrements the JSON value(s) at the specified `path` by `number` within the JSON document stored at `key`.
707
- *
708
- * @param client - The client to execute the command.
709
- * @param key - The key of the JSON document.
710
- * @param path - The path within the JSON document.
711
- * @param num - The number to increment or decrement by.
712
- * @returns
713
- * - For JSONPath (path starts with `$`):
714
- * - Returns a string representation of an array of strings, indicating the new values after incrementing for each matched `path`.
715
- * If a value is not a number, its corresponding return value will be `null`.
716
- * If `path` doesn't exist, a byte string representation of an empty array will be returned.
717
- * - For legacy path (path doesn't start with `$`):
718
- * - Returns a string representation of the resulting value after the increment or decrement.
719
- * If multiple paths match, the result of the last updated value is returned.
720
- * If the value at the `path` is not a number or `path` doesn't exist, an error is raised.
721
- * - If `key` does not exist, an error is raised.
722
- * - If the result is out of the range of 64-bit IEEE double, an error is raised.
723
- *
724
- * @example
725
- * ```typescript
726
- * console.log(await GlideJson.set(client, "doc", "$", '{"a": [], "b": [1], "c": [1, 2], "d": [1, 2, 3]}'));
727
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
728
- * console.log(await GlideJson.numincrby(client, "doc", "$.d[*]", 10))
729
- * // Output: '[11,12,13]' - Increment each element in `d` array by 10.
730
- *
731
- * console.log(await GlideJson.numincrby(client, "doc", ".c[1]", 10));
732
- * // Output: '12' - Increment the second element in the `c` array by 10.
733
- * ```
734
- */
735
- static numincrby(client: BaseClient, key: GlideString, path: GlideString, num: number): Promise<GlideString>;
736
- /**
737
- * Multiplies the JSON value(s) at the specified `path` by `number` within the JSON document stored at `key`.
738
- *
739
- * @param client - The client to execute the command.
740
- * @param key - The key of the JSON document.
741
- * @param path - The path within the JSON document.
742
- * @param num - The number to multiply by.
743
- * @returns
744
- * - For JSONPath (path starts with `$`):
745
- * - Returns a GlideString representation of an array of strings, indicating the new values after multiplication for each matched `path`.
746
- * If a value is not a number, its corresponding return value will be `null`.
747
- * If `path` doesn't exist, a byte string representation of an empty array will be returned.
748
- * - For legacy path (path doesn't start with `$`):
749
- * - Returns a GlideString representation of the resulting value after multiplication.
750
- * If multiple paths match, the result of the last updated value is returned.
751
- * If the value at the `path` is not a number or `path` doesn't exist, an error is raised.
752
- * - If `key` does not exist, an error is raised.
753
- * - If the result is out of the range of 64-bit IEEE double, an error is raised.
754
- *
755
- * @example
756
- * ```typescript
757
- * console.log(await GlideJson.set(client, "doc", "$", '{"a": [], "b": [1], "c": [1, 2], "d": [1, 2, 3]}'));
758
- * // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
759
- * console.log(await GlideJson.nummultby(client, "doc", "$.d[*]", 2))
760
- * // Output: '[2,4,6]' - Multiplies each element in the `d` array by 2.
761
- *
762
- * console.log(await GlideJson.nummultby(client, "doc", ".c[1]", 2));
763
- * // Output: '4' - Multiplies the second element in the `c` array by 2.
764
- * ```
765
- */
766
- static nummultby(client: BaseClient, key: GlideString, path: GlideString, num: number): Promise<GlideString>;
767
- /**
768
- * Retrieves the number of key-value pairs in the object stored at the specified `path` within the JSON document stored at `key`.
769
- *
770
- * @param client - The client to execute the command.
771
- * @param key - The key of the JSON document.
772
- * @param options - (Optional) Additional parameters:
773
- * - (Optional) `path`: The path within the JSON document, Defaults to root (`"."`) if not provided.
774
- * @returns ReturnTypeJson<number>:
775
- * - For JSONPath (`path` starts with `$`):
776
- * - Returns a list of integer replies for every possible path, indicating the length of the object,
777
- * or `null` for JSON values matching the path that are not an object.
778
- * - If `path` doesn't exist, an empty array will be returned.
779
- * - For legacy path (`path` doesn't starts with `$`):
780
- * - Returns the length of the object at `path`.
781
- * - If multiple paths match, the length of the first object match is returned.
782
- * - If the JSON value at `path` is not an object or if `path` doesn't exist, an error is raised.
783
- * - If `key` doesn't exist, `null` is returned.
784
- *
785
- * @example
786
- * ```typescript
787
- * console.log(await GlideJson.set(client, "doc", "$", '{"a": 1.0, "b": {"a": {"x": 1, "y": 2}, "b": 2.5, "c": true}}'));
788
- * // Output: 'OK' - Indicates successful setting of the value at the root path '$' in the key `doc`.
789
- * console.log(await GlideJson.objlen(client, "doc", { path: "$" }));
790
- * // Output: [2] - Returns the number of key-value pairs at the root object, which has 2 keys: 'a' and 'b'.
791
- * console.log(await GlideJson.objlen(client, "doc", { path: "." }));
792
- * // Output: 2 - Returns the number of key-value pairs for the object matching the path '.', which has 2 keys: 'a' and 'b'.
793
- * ```
794
- */
795
- static objlen(client: BaseClient, key: GlideString, options?: {
796
- path: GlideString;
797
- }): Promise<ReturnTypeJson<number>>;
798
- /**
799
- * Retrieves key names in the object values at the specified `path` within the JSON document stored at `key`.
800
- *
801
- * @param client - The client to execute the command.
802
- * @param key - The key of the JSON document.
803
- * @param options - (Optional) Additional parameters:
804
- * - (Optional) `path`: The path within the JSON document where the key names will be retrieved. Defaults to root (`"."`) if not provided.
805
- * @returns ReturnTypeJson<GlideString[]>:
806
- * - For JSONPath (`path` starts with `$`):
807
- * - Returns a list of arrays containing key names for each matching object.
808
- * - If a value matching the path is not an object, an empty array is returned.
809
- * - If `path` doesn't exist, an empty array is returned.
810
- * - For legacy path (`path` starts with `.`):
811
- * - Returns a list of key names for the object value matching the path.
812
- * - If multiple objects match the path, the key names of the first object is returned.
813
- * - If a value matching the path is not an object, an error is raised.
814
- * - If `path` doesn't exist, `null` is returned.
815
- * - If `key` doesn't exist, `null` is returned.
816
- *
817
- * @example
818
- * ```typescript
819
- * console.log(await GlideJson.set(client, "doc", "$", '{"a": 1.0, "b": {"a": {"x": 1, "y": 2}, "b": 2.5, "c": true}}'));
820
- * // Output: 'OK' - Indicates successful setting of the value at the root path '$' in the key `doc`.
821
- * console.log(await GlideJson.objkeys(client, "doc", { path: "$" }));
822
- * // Output: [["a", "b"]] - Returns a list of arrays containing the key names for objects matching the path '$'.
823
- * console.log(await GlideJson.objkeys(client, "doc", { path: "." }));
824
- * // Output: ["a", "b"] - Returns key names for the object matching the path '.' as it is the only match.
825
- * ```
826
- */
827
- static objkeys(client: BaseClient, key: GlideString, options?: {
828
- path: GlideString;
829
- } & DecoderOption): Promise<ReturnTypeJson<GlideString[]>>;
830
- }
831
- /**
832
- * Transaction implementation for JSON module. Transactions allow the execution of a group of
833
- * commands in a single step. See {@link Transaction} and {@link ClusterTransaction}.
834
- *
835
- * @example
836
- * ```typescript
837
- * const transaction = new Transaction();
838
- * JsonBatch.set(transaction, "doc", ".", '{"a": 1.0, "b": 2}');
839
- * JsonBatch.get(transaction, "doc");
840
- * const result = await client.exec(transaction);
841
- *
842
- * console.log(result[0]); // Output: 'OK' - result of JsonBatch.set()
843
- * console.log(result[1]); // Output: '{"a": 1.0, "b": 2}' - result of JsonBatch.get()
844
- * ```
845
- */
846
- export declare class JsonBatch {
847
- /**
848
- * Sets the JSON value at the specified `path` stored at `key`.
849
- *
850
- * @param transaction - A transaction to add commands to.
851
- * @param key - The key of the JSON document.
852
- * @param path - Represents the path within the JSON document where the value will be set.
853
- * 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.
854
- * @param value - The value to set at the specific path, in JSON formatted bytes or str.
855
- * @param options - (Optional) Additional parameters:
856
- * - (Optional) `conditionalChange` - Set the value only if the given condition is met (within the key or path).
857
- * Equivalent to [`XX` | `NX`] in the module API.
858
- *
859
- * Command Response - If the value is successfully set, returns `"OK"`.
860
- * If `value` isn't set because of `conditionalChange`, returns `null`.
861
- */
862
- static set(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, value: GlideString, options?: {
863
- conditionalChange: ConditionalChange;
864
- }): Transaction | ClusterTransaction;
865
- /**
866
- * Retrieves the JSON value at the specified `paths` stored at `key`.
867
- *
868
- * @param transaction - A transaction to add commands to.
869
- * @param key - The key of the JSON document.
870
- * @param options - (Optional) Additional parameters:
871
- * - (Optional) Options for formatting the byte representation of the JSON data. See {@link JsonGetOptions}.
872
- *
873
- * Command Response -
874
- * - If one path is given:
875
- * - For JSONPath (path starts with `$`):
876
- * - Returns a stringified JSON list of bytes replies for every possible path,
877
- * or a byte string representation of an empty array, if path doesn't exist.
878
- * If `key` doesn't exist, returns `null`.
879
- * - For legacy path (path doesn't start with `$`):
880
- * Returns a byte string representation of the value in `path`.
881
- * If `path` doesn't exist, an error is raised.
882
- * If `key` doesn't exist, returns `null`.
883
- * - If multiple paths are given:
884
- * Returns a stringified JSON object in bytes, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
885
- * In case of multiple paths, and `paths` are a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.
886
- */
887
- static get(transaction: Transaction | ClusterTransaction, key: GlideString, options?: JsonGetOptions): Transaction | ClusterTransaction;
888
- /**
889
- * Retrieves the JSON values at the specified `path` stored at multiple `keys`.
890
- *
891
- * @remarks When in cluster mode, all keys in the transaction must be mapped to the same slot.
892
- *
893
- * @param client - The client to execute the command.
894
- * @param keys - The keys of the JSON documents.
895
- * @param path - The path within the JSON documents.
896
- *
897
- * Command Response -
898
- * - For JSONPath (path starts with `$`):
899
- * Returns a stringified JSON list replies for every possible path, or a string representation
900
- * of an empty array, if path doesn't exist.
901
- * - For legacy path (path doesn't start with `$`):
902
- * Returns a string representation of the value in `path`. If `path` doesn't exist,
903
- * the corresponding array element will be `null`.
904
- * - If a `key` doesn't exist, the corresponding array element will be `null`.
905
- */
906
- static mget(transaction: Transaction | ClusterTransaction, keys: GlideString[], path: GlideString): Transaction | ClusterTransaction;
907
- /**
908
- * Inserts one or more values into the array at the specified `path` within the JSON
909
- * document stored at `key`, before the given `index`.
910
- *
911
- * @param transaction - A transaction to add commands to.
912
- * @param key - The key of the JSON document.
913
- * @param path - The path within the JSON document.
914
- * @param index - The array index before which values are inserted.
915
- * @param values - The JSON values to be inserted into the array.
916
- * JSON string values must be wrapped with quotes. For example, to insert `"foo"`, pass `"\"foo\""`.
917
- *
918
- * Command Response -
919
- * - For JSONPath (path starts with `$`):
920
- * Returns an array with a list of integers for every possible path,
921
- * indicating the new length of the array, or `null` for JSON values matching
922
- * the path that are not an array. If `path` does not exist, an empty array
923
- * will be returned.
924
- * - For legacy path (path doesn't start with `$`):
925
- * Returns an integer representing the new length of the array. If multiple paths are
926
- * matched, returns the length of the first modified array. If `path` doesn't
927
- * exist or the value at `path` is not an array, an error is raised.
928
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
929
- */
930
- static arrinsert(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, index: number, values: GlideString[]): Transaction | ClusterTransaction;
931
- /**
932
- * Pops an element from the array located at `path` in the JSON document stored at `key`.
933
- *
934
- * @param transaction - A transaction to add commands to.
935
- * @param key - The key of the JSON document.
936
- * @param options - (Optional) See {@link JsonArrPopOptions}.
937
- *
938
- * Command Response -
939
- * - For JSONPath (path starts with `$`):
940
- * Returns an array with a strings for every possible path, representing the popped JSON
941
- * values, or `null` for JSON values matching the path that are not an array
942
- * or an empty array.
943
- * - For legacy path (path doesn't start with `$`):
944
- * Returns a string representing the popped JSON value, or `null` if the
945
- * array at `path` is empty. If multiple paths are matched, the value from
946
- * the first matching array that is not empty is returned. If `path` doesn't
947
- * exist or the value at `path` is not an array, an error is raised.
948
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
949
- */
950
- static arrpop(transaction: Transaction | ClusterTransaction, key: GlideString, options?: JsonArrPopOptions): Transaction | ClusterTransaction;
951
- /**
952
- * Retrieves the length of the array at the specified `path` within the JSON document stored at `key`.
953
- *
954
- * @param transaction - A transaction to add commands to.
955
- * @param key - The key of the JSON document.
956
- * @param options - (Optional) Additional parameters:
957
- * - (Optional) `path`: The path within the JSON document. Defaults to the root (`"."`) if not specified.
958
- *
959
- * Command Response -
960
- * - For JSONPath (path starts with `$`):
961
- * Returns an array with a list of integers for every possible path,
962
- * indicating the length of the array, or `null` for JSON values matching
963
- * the path that are not an array. If `path` does not exist, an empty array
964
- * will be returned.
965
- * - For legacy path (path doesn't start with `$`):
966
- * Returns an integer representing the length of the array. If multiple paths are
967
- * matched, returns the length of the first matching array. If `path` doesn't
968
- * exist or the value at `path` is not an array, an error is raised.
969
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
970
- */
971
- static arrlen(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
972
- path: GlideString;
973
- }): Transaction | ClusterTransaction;
974
- /**
975
- * Trims an array at the specified `path` within the JSON document stored at `key` so that it becomes a subarray [start, end], both inclusive.
976
- * If `start` < 0, it is treated as 0.
977
- * If `end` >= size (size of the array), it is treated as size-1.
978
- * If `start` >= size or `start` > `end`, the array is emptied and 0 is returned.
979
- *
980
- * @param transaction - A transaction to add commands to.
981
- * @param key - The key of the JSON document.
982
- * @param path - The path within the JSON document.
983
- * @param start - The start index, inclusive.
984
- * @param end - The end index, inclusive.
985
- *
986
- * Command Response -
987
- * - For JSONPath (`path` starts with `$`):
988
- * - Returns a list of integer replies for every possible path, indicating the new length of the array,
989
- * or `null` for JSON values matching the path that are not an array.
990
- * - If the array is empty, its corresponding return value is 0.
991
- * - If `path` doesn't exist, an empty array will be returned.
992
- * - If an index argument is out of bounds, an error is raised.
993
- * - For legacy path (`path` doesn't start with `$`):
994
- * - Returns an integer representing the new length of the array.
995
- * - If the array is empty, its corresponding return value is 0.
996
- * - If multiple paths match, the length of the first trimmed array match is returned.
997
- * - If `path` doesn't exist, or the value at `path` is not an array, an error is raised.
998
- * - If an index argument is out of bounds, an error is raised.
999
- */
1000
- static arrtrim(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, start: number, end: number): Transaction | ClusterTransaction;
1001
- /**
1002
- * Searches for the first occurrence of a `scalar` JSON value in the arrays at the `path`.
1003
- * Out of range errors are treated by rounding the index to the array's `start` and `end.
1004
- * If `start` > `end`, return `-1` (not found).
1005
- *
1006
- * @param transaction - A transaction to add commands to.
1007
- * @param key - The key of the JSON document.
1008
- * @param path - The path within the JSON document.
1009
- * @param scalar - The scalar value to search for.
1010
- * @param options - (Optional) Additional parameters:
1011
- * - (Optional) `start`: The start index, inclusive. Default to 0 if not provided.
1012
- * - (Optional) `end`: The end index, exclusive. Default to 0 if not provided.
1013
- * 0 or -1 means the last element is included.
1014
- * Command Response -
1015
- * - For JSONPath (path starts with `$`):
1016
- * Returns an array with a list of integers for every possible path,
1017
- * indicating the index of the matching element. The value is `-1` if not found.
1018
- * If a value is not an array, its corresponding return value is `null`.
1019
- * - For legacy path (path doesn't start with `$`):
1020
- * Returns an integer representing the index of matching element, or `-1` if
1021
- * not found. If the value at the `path` is not an array, an error is raised.
1022
- */
1023
- static arrindex(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, scalar: GlideString | number | boolean | null, options?: {
1024
- start: number;
1025
- end?: number;
1026
- }): Transaction | ClusterTransaction;
1027
- /**
1028
- * Toggles a Boolean value stored at the specified `path` within the JSON document stored at `key`.
1029
- *
1030
- * @param transaction - A transaction to add commands to.
1031
- * @param key - The key of the JSON document.
1032
- * @param options - (Optional) Additional parameters:
1033
- * - (Optional) `path`: The path within the JSON document. Defaults to the root (`"."`) if not specified.
1034
- *
1035
- * Command Response - For JSONPath (`path` starts with `$`), returns a list of boolean replies for every possible path, with the toggled boolean value,
1036
- * or `null` for JSON values matching the path that are not boolean.
1037
- * - For legacy path (`path` doesn't starts with `$`), returns the value of the toggled boolean in `path`.
1038
- * - 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.
1039
- */
1040
- static toggle(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1041
- path: GlideString;
1042
- }): Transaction | ClusterTransaction;
1043
- /**
1044
- * Deletes the JSON value at the specified `path` within the JSON document stored at `key`.
1045
- *
1046
- * @param transaction - A transaction to add commands to.
1047
- * @param key - The key of the JSON document.
1048
- * @param options - (Optional) Additional parameters:
1049
- * - (Optional) `path`: If `null`, deletes the entire JSON document at `key`.
1050
- *
1051
- * Command Response - The number of elements removed. If `key` or `path` doesn't exist, returns 0.
1052
- */
1053
- static del(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1054
- path: GlideString;
1055
- }): Transaction | ClusterTransaction;
1056
- /**
1057
- * Deletes the JSON value at the specified `path` within the JSON document stored at `key`. This command is
1058
- * an alias of {@link del}.
1059
- *
1060
- * @param transaction - A transaction to add commands to.
1061
- * @param key - The key of the JSON document.
1062
- * @param options - (Optional) Additional parameters:
1063
- * - (Optional) `path`: If `null`, deletes the entire JSON document at `key`.
1064
- *
1065
- * Command Response - The number of elements removed. If `key` or `path` doesn't exist, returns 0.
1066
- */
1067
- static forget(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1068
- path: GlideString;
1069
- }): Transaction | ClusterTransaction;
1070
- /**
1071
- * Reports the type of values at the given path.
1072
- *
1073
- * @param transaction - A transaction to add commands to.
1074
- * @param key - The key of the JSON document.
1075
- * @param options - (Optional) Additional parameters:
1076
- * - (Optional) `path`: Defaults to root (`"."`) if not provided.
1077
- *
1078
- * Command Response -
1079
- * - For JSONPath (path starts with `$`):
1080
- * - Returns an array of strings that represents the type of value at each path.
1081
- * The type is one of "null", "boolean", "string", "number", "integer", "object" and "array".
1082
- * - If a path does not exist, its corresponding return value is `null`.
1083
- * - Empty array if the document key does not exist.
1084
- * - For legacy path (path doesn't start with `$`):
1085
- * - String that represents the type of the value.
1086
- * - `null` if the document key does not exist.
1087
- * - `null` if the JSON path is invalid or does not exist.
1088
- */
1089
- static type(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1090
- path: GlideString;
1091
- }): Transaction | ClusterTransaction;
1092
- /**
1093
- * Clears arrays or objects at the specified JSON path in the document stored at `key`.
1094
- * Numeric values are set to `0`, boolean values are set to `false`, and string values are converted to empty strings.
1095
- *
1096
- * @param transaction - A transaction to add commands to.
1097
- * @param key - The key of the JSON document.
1098
- * @param options - (Optional) Additional parameters:
1099
- * - (Optional) `path`: The JSON path to the arrays or objects to be cleared. Defaults to root if not provided.
1100
- *
1101
- * Command Response - The number of containers cleared, numeric values zeroed, and booleans toggled to `false`,
1102
- * and string values converted to empty strings.
1103
- * If `path` doesn't exist, or the value at `path` is already empty (e.g., an empty array, object, or string), `0` is returned.
1104
- * If `key doesn't exist, an error is raised.
1105
- */
1106
- static clear(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1107
- path: GlideString;
1108
- }): Transaction | ClusterTransaction;
1109
- /**
1110
- * Retrieve the JSON value at the specified `path` within the JSON document stored at `key`.
1111
- * The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).
1112
- * - JSON null is mapped to the RESP Null Bulk String.
1113
- * - JSON Booleans are mapped to RESP Simple string.
1114
- * - JSON integers are mapped to RESP Integers.
1115
- * - JSON doubles are mapped to RESP Bulk Strings.
1116
- * - JSON strings are mapped to RESP Bulk Strings.
1117
- * - JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
1118
- * - JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.
1119
- *
1120
- * @param transaction - A transaction to add commands to.
1121
- * @param key - The key of the JSON document.
1122
- * @param options - (Optional) Additional parameters:
1123
- * - (Optional) `path`: The path within the JSON document, defaults to root (`"."`) if not provided.
1124
- *
1125
- * Command Response -
1126
- * - For JSONPath (path starts with `$`):
1127
- * - Returns an array of replies for every possible path, indicating the RESP form of the JSON value.
1128
- * If `path` doesn't exist, returns an empty array.
1129
- * - For legacy path (path doesn't start with `$`):
1130
- * - Returns a single reply for the JSON value at the specified `path`, in its RESP form.
1131
- * If multiple paths match, the value of the first JSON value match is returned. If `path` doesn't exist, an error is raised.
1132
- * - If `key` doesn't exist, `null` is returned.
1133
- */
1134
- static resp(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1135
- path: GlideString;
1136
- }): Transaction | ClusterTransaction;
1137
- /**
1138
- * Returns the length of the JSON string value stored at the specified `path` within
1139
- * the JSON document stored at `key`.
1140
- *
1141
- * @param transaction - A transaction to add commands to.
1142
- * @param key - The key of the JSON document.
1143
- * @param options - (Optional) Additional parameters:
1144
- * - (Optional) `path`: The path within the JSON document, Defaults to root (`"."`) if not provided.
1145
- *
1146
- * Command Response -
1147
- * - For JSONPath (path starts with `$`):
1148
- * - Returns a list of integer replies for every possible path, indicating the length of
1149
- * the JSON string value, or <code>null</code> for JSON values matching the path that
1150
- * are not string.
1151
- * - For legacy path (path doesn't start with `$`):
1152
- * - Returns the length of the JSON value at `path` or `null` if `key` doesn't exist.
1153
- * - If multiple paths match, the length of the first matched string is returned.
1154
- * - If the JSON value at`path` is not a string or if `path` doesn't exist, an error is raised.
1155
- * - If `key` doesn't exist, `null` is returned.
1156
- */
1157
- static strlen(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1158
- path: GlideString;
1159
- }): Transaction | ClusterTransaction;
1160
- /**
1161
- * Appends the specified `value` to the string stored at the specified `path` within the JSON document stored at `key`.
1162
- *
1163
- * @param transaction - A transaction to add commands to.
1164
- * @param key - The key of the JSON document.
1165
- * @param value - The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
1166
- * @param options - (Optional) Additional parameters:
1167
- * - (Optional) `path`: The path within the JSON document, defaults to root (`"."`) if not provided.
1168
- *
1169
- * Command Response -
1170
- * - For JSONPath (path starts with `$`):
1171
- * - Returns a list of integer replies for every possible path, indicating the length of the resulting string after appending `value`,
1172
- * or None for JSON values matching the path that are not string.
1173
- * - If `key` doesn't exist, an error is raised.
1174
- * - For legacy path (path doesn't start with `$`):
1175
- * - Returns the length of the resulting string after appending `value` to the string at `path`.
1176
- * - If multiple paths match, the length of the last updated string is returned.
1177
- * - If the JSON value at `path` is not a string of if `path` doesn't exist, an error is raised.
1178
- * - If `key` doesn't exist, an error is raised.
1179
- */
1180
- static strappend(transaction: Transaction | ClusterTransaction, key: GlideString, value: GlideString, options?: {
1181
- path: GlideString;
1182
- }): Transaction | ClusterTransaction;
1183
- /**
1184
- * Appends one or more `values` to the JSON array at the specified `path` within the JSON
1185
- * document stored at `key`.
1186
- *
1187
- * @param transaction - A transaction to add commands to.
1188
- * @param key - The key of the JSON document.
1189
- * @param path - The path within the JSON document.
1190
- * @param values - The JSON values to be appended to the array.
1191
- * JSON string values must be wrapped with quotes. For example, to append `"foo"`, pass `"\"foo\""`.
1192
- *
1193
- * Command Response -
1194
- * - For JSONPath (path starts with `$`):
1195
- * Returns an array with a list of integers for every possible path,
1196
- * indicating the new length of the array, or `null` for JSON values matching
1197
- * the path that are not an array. If `path` does not exist, an empty array
1198
- * will be returned.
1199
- * - For legacy path (path doesn't start with `$`):
1200
- * Returns an integer representing the new length of the array. If multiple paths are
1201
- * matched, returns the length of the first modified array. If `path` doesn't
1202
- * exist or the value at `path` is not an array, an error is raised.
1203
- * - If the index is out of bounds or `key` doesn't exist, an error is raised.
1204
- */
1205
- static arrappend(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, values: GlideString[]): Transaction | ClusterTransaction;
1206
- /**
1207
- * Reports memory usage in bytes of a JSON object at the specified `path` within the JSON document stored at `key`.
1208
- *
1209
- * @param transaction - A transaction to add commands to.
1210
- * @param key - The key of the JSON document.
1211
- * @param value - The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
1212
- * @param options - (Optional) Additional parameters:
1213
- * - (Optional) `path`: The path within the JSON document, returns total memory usage if no path is given.
1214
- *
1215
- * Command Response -
1216
- * - For JSONPath (path starts with `$`):
1217
- * - Returns an array of numbers for every possible path, indicating the memory usage.
1218
- * If `path` does not exist, an empty array will be returned.
1219
- * - For legacy path (path doesn't start with `$`):
1220
- * - Returns an integer representing the memory usage. If multiple paths are matched,
1221
- * returns the data of the first matching object. If `path` doesn't exist, an error is raised.
1222
- * - If `key` doesn't exist, returns `null`.
1223
- */
1224
- static debugMemory(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1225
- path: GlideString;
1226
- }): Transaction | ClusterTransaction;
1227
- /**
1228
- * Reports the number of fields at the specified `path` within the JSON document stored at `key`.
1229
- *
1230
- * @param transaction - A transaction to add commands to.
1231
- * @param key - The key of the JSON document.
1232
- * @param value - The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
1233
- * @param options - (Optional) Additional parameters:
1234
- * - (Optional) `path`: The path within the JSON document, returns total number of fields if no path is given.
1235
- *
1236
- * Command Response -
1237
- * - For JSONPath (path starts with `$`):
1238
- * - Returns an array of numbers for every possible path, indicating the number of fields.
1239
- * If `path` does not exist, an empty array will be returned.
1240
- * - For legacy path (path doesn't start with `$`):
1241
- * - Returns an integer representing the memory usage. If multiple paths are matched,
1242
- * returns the data of the first matching object. If `path` doesn't exist, an error is raised.
1243
- * - If `key` doesn't exist, returns `null`.
1244
- */
1245
- static debugFields(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1246
- path: GlideString;
1247
- }): Transaction | ClusterTransaction;
1248
- /**
1249
- * Increments or decrements the JSON value(s) at the specified `path` by `number` within the JSON document stored at `key`.
1250
- *
1251
- * @param transaction - A transaction to add commands to.
1252
- * @param key - The key of the JSON document.
1253
- * @param path - The path within the JSON document.
1254
- * @param num - The number to increment or decrement by.
1255
- *
1256
- * Command Response -
1257
- * - For JSONPath (path starts with `$`):
1258
- * - Returns a string representation of an array of strings, indicating the new values after incrementing for each matched `path`.
1259
- * If a value is not a number, its corresponding return value will be `null`.
1260
- * If `path` doesn't exist, a byte string representation of an empty array will be returned.
1261
- * - For legacy path (path doesn't start with `$`):
1262
- * - Returns a string representation of the resulting value after the increment or decrement.
1263
- * If multiple paths match, the result of the last updated value is returned.
1264
- * If the value at the `path` is not a number or `path` doesn't exist, an error is raised.
1265
- * - If `key` does not exist, an error is raised.
1266
- * - If the result is out of the range of 64-bit IEEE double, an error is raised.
1267
- */
1268
- static numincrby(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, num: number): Transaction | ClusterTransaction;
1269
- /**
1270
- * Multiplies the JSON value(s) at the specified `path` by `number` within the JSON document stored at `key`.
1271
- *
1272
- * @param transaction - A transaction to add commands to.
1273
- * @param key - The key of the JSON document.
1274
- * @param path - The path within the JSON document.
1275
- * @param num - The number to multiply by.
1276
- *
1277
- * Command Response -
1278
- * - For JSONPath (path starts with `$`):
1279
- * - Returns a GlideString representation of an array of strings, indicating the new values after multiplication for each matched `path`.
1280
- * If a value is not a number, its corresponding return value will be `null`.
1281
- * If `path` doesn't exist, a byte string representation of an empty array will be returned.
1282
- * - For legacy path (path doesn't start with `$`):
1283
- * - Returns a GlideString representation of the resulting value after multiplication.
1284
- * If multiple paths match, the result of the last updated value is returned.
1285
- * If the value at the `path` is not a number or `path` doesn't exist, an error is raised.
1286
- * - If `key` does not exist, an error is raised.
1287
- * - If the result is out of the range of 64-bit IEEE double, an error is raised.
1288
- */
1289
- static nummultby(transaction: Transaction | ClusterTransaction, key: GlideString, path: GlideString, num: number): Transaction | ClusterTransaction;
1290
- /**
1291
- * Retrieves the number of key-value pairs in the object stored at the specified `path` within the JSON document stored at `key`.
1292
- *
1293
- * @param transaction - A transaction to add commands to.
1294
- * @param key - The key of the JSON document.
1295
- * @param options - (Optional) Additional parameters:
1296
- * - (Optional) `path`: The path within the JSON document, Defaults to root (`"."`) if not provided.
1297
- *
1298
- * Command Response - ReturnTypeJson<number>:
1299
- * - For JSONPath (`path` starts with `$`):
1300
- * - Returns a list of integer replies for every possible path, indicating the length of the object,
1301
- * or `null` for JSON values matching the path that are not an object.
1302
- * - If `path` doesn't exist, an empty array will be returned.
1303
- * - For legacy path (`path` doesn't starts with `$`):
1304
- * - Returns the length of the object at `path`.
1305
- * - If multiple paths match, the length of the first object match is returned.
1306
- * - If the JSON value at `path` is not an object or if `path` doesn't exist, an error is raised.
1307
- * - If `key` doesn't exist, `null` is returned.
1308
- */
1309
- static objlen(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1310
- path: GlideString;
1311
- }): Transaction | ClusterTransaction;
1312
- /**
1313
- * Retrieves key names in the object values at the specified `path` within the JSON document stored at `key`.
1314
- *
1315
- * @param transaction - A transaction to add commands to.
1316
- * @param key - The key of the JSON document.
1317
- * @param options - (Optional) Additional parameters:
1318
- * - (Optional) `path`: The path within the JSON document where the key names will be retrieved. Defaults to root (`"."`) if not provided.
1319
- *
1320
- * Command Response - ReturnTypeJson<GlideString[]>:
1321
- * - For JSONPath (`path` starts with `$`):
1322
- * - Returns a list of arrays containing key names for each matching object.
1323
- * - If a value matching the path is not an object, an empty array is returned.
1324
- * - If `path` doesn't exist, an empty array is returned.
1325
- * - For legacy path (`path` starts with `.`):
1326
- * - Returns a list of key names for the object value matching the path.
1327
- * - If multiple objects match the path, the key names of the first object is returned.
1328
- * - If a value matching the path is not an object, an error is raised.
1329
- * - If `path` doesn't exist, `null` is returned.
1330
- * - If `key` doesn't exist, `null` is returned.
1331
- */
1332
- static objkeys(transaction: Transaction | ClusterTransaction, key: GlideString, options?: {
1333
- path: GlideString;
1334
- }): Transaction | ClusterTransaction;
1335
- }