@valkey/valkey-glide 1.2.1 → 1.3.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-ts/index.js +2 -1
- package/build-ts/src/BaseClient.d.ts +45 -56
- package/build-ts/src/Commands.d.ts +31 -13
- package/build-ts/src/GlideClient.d.ts +2 -0
- package/build-ts/src/GlideClusterClient.d.ts +4 -1
- package/build-ts/src/Transaction.d.ts +7 -31
- package/build-ts/src/server-modules/GlideJson.d.ts +518 -12
- package/package.json +6 -6
package/build-ts/index.js
CHANGED
|
@@ -62,7 +62,7 @@ function loadNativeBinding() {
|
|
|
62
62
|
}
|
|
63
63
|
function initialize() {
|
|
64
64
|
const nativeBinding = loadNativeBinding();
|
|
65
|
-
const { AggregationType, BaseScanOptions, ScanOptions, ZScanOptions, HScanOptions, BitEncoding, BitFieldGet, BitFieldIncrBy, BitFieldOffset, BitFieldOverflow, BitFieldSet, BitFieldSubCommands, BitOffset, BitOffsetMultiplier, BitOffsetOptions, BitOverflowControl, BitmapIndexType, BitwiseOperation, ConditionalChange, Decoder, DecoderOption, GeoAddOptions, CoordOrigin, MemberOrigin, SearchOrigin, GeoBoxShape, GeoCircleShape, GeoSearchShape, GeoSearchResultOptions, GeoSearchStoreResultOptions, SortOrder, GeoUnit, GeospatialData, GlideClient, GlideClusterClient, GlideClientConfiguration, GlideJson, GlideFt, Field, TextField, TagField, NumericField, VectorField, VectorFieldAttributesFlat, VectorFieldAttributesHnsw, FtCreateOptions, FtSearchOptions, FtInfoReturnType, FtAggregateOptions, FtAggregateLimit, FtAggregateFilter, FtAggregateGroupBy, FtAggregateReducer, FtAggregateSortBy, FtAggregateSortProperty, FtAggregateApply, FtAggregateReturnType, FtSearchReturnType, GlideRecord, GlideString, JsonGetOptions, JsonArrPopOptions, SortedSetDataType, StreamEntryDataType, HashDataType, FunctionListOptions, FunctionListResponse, FunctionStatsSingleResponse, FunctionStatsFullResponse, FunctionRestorePolicy, SlotIdTypes, SlotKeyTypes, TimeUnit, RouteByAddress, RouteOption, Routes, RestoreOptions, SingleNodeRoute, PeriodicChecksManualInterval, PeriodicChecks, Logger, Limit, LolwutOptions, LPosOptions, ListDirection, ExpireOptions, FlushMode, InfoOptions, InsertPosition, SetOptions, ZAddOptions, InfBoundary, KeyWeight, Boundary, ProtocolVersion, RangeByIndex, RangeByScore, RangeByLex, ReadFrom, ServerCredentials, SortOptions, StreamGroupOptions, StreamTrimOptions, StreamAddOptions, StreamReadGroupOptions, StreamReadOptions, StreamClaimOptions, StreamPendingOptions, ClosingError, ConfigurationError, ExecAbortError, ValkeyError, GlideReturnType, StreamEntries, ReturnTypeXinfoStream, RequestError, TimeoutError, ConnectionError, ClusterTransaction, Transaction, PubSubMsg, ScoreFilter, SignedEncoding, UnsignedEncoding, UpdateByScore, createLeakedArray, createLeakedAttribute, createLeakedBigint, createLeakedDouble, createLeakedMap, createLeakedString, Script, ObjectType, ClusterScanCursor, AdvancedGlideClientConfiguration, AdvancedGlideClusterClientConfiguration, BaseClientConfiguration, GlideClusterClientConfiguration, LevelOptions, ReturnTypeRecord, ReturnTypeMap, ClusterResponse, ReturnTypeAttribute, ReturnTypeJson, UniversalReturnTypeJson, } = nativeBinding;
|
|
65
|
+
const { AggregationType, BaseScanOptions, ScanOptions, ZScanOptions, HScanOptions, BitEncoding, BitFieldGet, BitFieldIncrBy, BitFieldOffset, BitFieldOverflow, BitFieldSet, BitFieldSubCommands, BitOffset, BitOffsetMultiplier, BitOffsetOptions, BitOverflowControl, BitmapIndexType, BitwiseOperation, ConditionalChange, Decoder, DecoderOption, GeoAddOptions, CoordOrigin, MemberOrigin, SearchOrigin, GeoBoxShape, GeoCircleShape, GeoSearchShape, GeoSearchResultOptions, GeoSearchStoreResultOptions, SortOrder, GeoUnit, GeospatialData, GlideClient, GlideClusterClient, GlideClientConfiguration, GlideJson, JsonBatch, GlideFt, Field, TextField, TagField, NumericField, VectorField, VectorFieldAttributesFlat, VectorFieldAttributesHnsw, FtCreateOptions, FtSearchOptions, FtInfoReturnType, FtAggregateOptions, FtAggregateLimit, FtAggregateFilter, FtAggregateGroupBy, FtAggregateReducer, FtAggregateSortBy, FtAggregateSortProperty, FtAggregateApply, FtAggregateReturnType, FtSearchReturnType, GlideRecord, GlideString, JsonGetOptions, JsonArrPopOptions, SortedSetDataType, StreamEntryDataType, HashDataType, FunctionListOptions, FunctionListResponse, FunctionStatsSingleResponse, FunctionStatsFullResponse, FunctionRestorePolicy, SlotIdTypes, SlotKeyTypes, TimeUnit, RouteByAddress, RouteOption, Routes, RestoreOptions, SingleNodeRoute, PeriodicChecksManualInterval, PeriodicChecks, Logger, Limit, LolwutOptions, LPosOptions, ListDirection, ExpireOptions, FlushMode, InfoOptions, InsertPosition, SetOptions, ZAddOptions, InfBoundary, KeyWeight, Boundary, ProtocolVersion, RangeByIndex, RangeByScore, RangeByLex, ReadFrom, ServerCredentials, SortOptions, StreamGroupOptions, StreamTrimOptions, StreamAddOptions, StreamReadGroupOptions, StreamReadOptions, StreamClaimOptions, StreamPendingOptions, ClosingError, ConfigurationError, ExecAbortError, ValkeyError, GlideReturnType, StreamEntries, ReturnTypeXinfoStream, RequestError, TimeoutError, ConnectionError, ClusterTransaction, Transaction, PubSubMsg, ScoreFilter, SignedEncoding, UnsignedEncoding, UpdateByScore, createLeakedArray, createLeakedAttribute, createLeakedBigint, createLeakedDouble, createLeakedMap, createLeakedString, Script, ObjectType, ClusterScanCursor, AdvancedGlideClientConfiguration, AdvancedGlideClusterClientConfiguration, BaseClientConfiguration, GlideClusterClientConfiguration, LevelOptions, ReturnTypeRecord, ReturnTypeMap, ClusterResponse, ReturnTypeAttribute, ReturnTypeJson, UniversalReturnTypeJson, } = nativeBinding;
|
|
66
66
|
module.exports = {
|
|
67
67
|
AggregationType,
|
|
68
68
|
BaseScanOptions,
|
|
@@ -109,6 +109,7 @@ function initialize() {
|
|
|
109
109
|
FtSearchReturnType,
|
|
110
110
|
GlideRecord,
|
|
111
111
|
GlideJson,
|
|
112
|
+
JsonBatch,
|
|
112
113
|
GlideString,
|
|
113
114
|
JsonGetOptions,
|
|
114
115
|
JsonArrPopOptions,
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Script } from "glide-rs";
|
|
5
5
|
import * as net from "net";
|
|
6
|
-
import { Buffer } from "protobufjs";
|
|
6
|
+
import { Buffer, Writer } from "protobufjs";
|
|
7
7
|
import { AggregationType, BaseScanOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8
8
|
BitFieldSubCommands, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
9
|
-
BitOffsetOptions,
|
|
9
|
+
BitOffsetOptions, BitwiseOperation, Boundary, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
10
10
|
ExpireOptions, GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
11
11
|
GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, HScanOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
12
12
|
RangeByIndex, RangeByLex, RangeByScore, RestoreOptions, ScoreFilter, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ZAddOptions, ZScanOptions } from "./Commands";
|
|
13
13
|
import { ConnectionError, ValkeyError } from "./Errors";
|
|
14
14
|
import { GlideClientConfiguration } from "./GlideClient";
|
|
15
|
-
import { GlideClusterClientConfiguration, RouteOption } from "./GlideClusterClient";
|
|
15
|
+
import { GlideClusterClientConfiguration, RouteOption, Routes } from "./GlideClusterClient";
|
|
16
16
|
import { command_request, connection_request, response } from "./ProtobufMessage";
|
|
17
17
|
type PromiseFunction = (value?: any) => void;
|
|
18
18
|
type ErrorFunction = (error: ValkeyError) => void;
|
|
@@ -139,7 +139,10 @@ export type ReadFrom =
|
|
|
139
139
|
| "preferReplica"
|
|
140
140
|
/** Spread the requests between replicas in the same client's Aviliablity zone in a round robin manner.
|
|
141
141
|
If no replica is available, route the requests to the primary.*/
|
|
142
|
-
| "AZAffinity"
|
|
142
|
+
| "AZAffinity"
|
|
143
|
+
/** Spread the read requests among all nodes within the client's Availability Zone (AZ) in a round robin manner,
|
|
144
|
+
prioritizing local replicas, then the local primary, and falling back to any replica or the primary if needed.*/
|
|
145
|
+
| "AZAffinityReplicasAndPrimary";
|
|
143
146
|
/**
|
|
144
147
|
* Configuration settings for creating a client. Shared settings for standalone and cluster clients.
|
|
145
148
|
*
|
|
@@ -168,11 +171,11 @@ export type ReadFrom =
|
|
|
168
171
|
*
|
|
169
172
|
* ### Read Strategy
|
|
170
173
|
*
|
|
171
|
-
* - Use `readFrom` to specify the client's read strategy (e.g., primary, preferReplica, AZAffinity).
|
|
174
|
+
* - Use `readFrom` to specify the client's read strategy (e.g., primary, preferReplica, AZAffinity, AZAffinityReplicasAndPrimary).
|
|
172
175
|
*
|
|
173
176
|
* ### Availability Zone
|
|
174
177
|
*
|
|
175
|
-
* - Use `clientAz` to specify the client's availability zone, which can influence read operations when using `readFrom: 'AZAffinity'`.
|
|
178
|
+
* - Use `clientAz` to specify the client's availability zone, which can influence read operations when using `readFrom: 'AZAffinity'or `readFrom: 'AZAffinityReplicasAndPrimary'`.
|
|
176
179
|
*
|
|
177
180
|
* ### Decoder Settings
|
|
178
181
|
*
|
|
@@ -247,12 +250,12 @@ export interface BaseClientConfiguration {
|
|
|
247
250
|
*/
|
|
248
251
|
requestTimeout?: number;
|
|
249
252
|
/**
|
|
250
|
-
*
|
|
253
|
+
* The client's read from strategy.
|
|
251
254
|
* If not set, `Primary` will be used.
|
|
252
255
|
*/
|
|
253
256
|
readFrom?: ReadFrom;
|
|
254
257
|
/**
|
|
255
|
-
*
|
|
258
|
+
* Serialization protocol to be used.
|
|
256
259
|
* If not set, `RESP3` will be used.
|
|
257
260
|
*/
|
|
258
261
|
protocol?: ProtocolVersion;
|
|
@@ -274,13 +277,15 @@ export interface BaseClientConfiguration {
|
|
|
274
277
|
inflightRequestsLimit?: number;
|
|
275
278
|
/**
|
|
276
279
|
* Availability Zone of the client.
|
|
277
|
-
* If ReadFrom strategy is AZAffinity, this setting ensures that readonly commands are directed to
|
|
280
|
+
* If ReadFrom strategy is AZAffinity or AZAffinityReplicasAndPrimary, this setting ensures that readonly commands are directed to nodes within the specified AZ if they exist.
|
|
278
281
|
*
|
|
279
282
|
* @example
|
|
280
283
|
* ```typescript
|
|
281
284
|
* // Example configuration for setting client availability zone and read strategy
|
|
282
285
|
* configuration.clientAz = 'us-east-1a'; // Sets the client's availability zone
|
|
283
286
|
* configuration.readFrom = 'AZAffinity'; // Directs read operations to nodes within the same AZ
|
|
287
|
+
* Or
|
|
288
|
+
* configuration.readFrom = 'AZAffinityReplicasAndPrimary'; // Directs read operations to any node (primary or replica) within the same AZ
|
|
284
289
|
* ```
|
|
285
290
|
*/
|
|
286
291
|
clientAz?: string;
|
|
@@ -341,10 +346,7 @@ export interface PubSubMsg {
|
|
|
341
346
|
export type WritePromiseOptions = RouteOption & DecoderOption;
|
|
342
347
|
export declare class BaseClient {
|
|
343
348
|
private socket;
|
|
344
|
-
protected readonly promiseCallbackFunctions: [
|
|
345
|
-
PromiseFunction,
|
|
346
|
-
ErrorFunction
|
|
347
|
-
][];
|
|
349
|
+
protected readonly promiseCallbackFunctions: [PromiseFunction, ErrorFunction, Decoder | undefined][] | [PromiseFunction, ErrorFunction][];
|
|
348
350
|
private readonly availableCallbackSlots;
|
|
349
351
|
private requestWriter;
|
|
350
352
|
private writeInProgress;
|
|
@@ -355,10 +357,10 @@ export declare class BaseClient {
|
|
|
355
357
|
private readonly pubsubFutures;
|
|
356
358
|
private pendingPushNotification;
|
|
357
359
|
private readonly inflightRequestsLimit;
|
|
358
|
-
private readonly clientAz;
|
|
359
360
|
private config;
|
|
360
361
|
protected configurePubsub(options: GlideClusterClientConfiguration | GlideClientConfiguration, configuration: connection_request.IConnectionRequest): void;
|
|
361
362
|
private handleReadData;
|
|
363
|
+
protected toProtobufRoute(route: Routes | undefined): command_request.Routes | undefined;
|
|
362
364
|
processResponse(message: response.Response): void;
|
|
363
365
|
processPush(response: response.Response): void;
|
|
364
366
|
/**
|
|
@@ -367,12 +369,18 @@ export declare class BaseClient {
|
|
|
367
369
|
protected constructor(socket: net.Socket, options?: BaseClientConfiguration);
|
|
368
370
|
protected getCallbackIndex(): number;
|
|
369
371
|
private writeBufferedRequestsToSocket;
|
|
372
|
+
protected ensureClientIsOpen(): void;
|
|
370
373
|
/**
|
|
371
374
|
* @internal
|
|
372
375
|
*/
|
|
373
|
-
protected createWritePromise<T>(command: command_request.Command | command_request.Command[]
|
|
374
|
-
protected
|
|
375
|
-
|
|
376
|
+
protected createWritePromise<T>(command: command_request.Command | command_request.Command[], options?: WritePromiseOptions): Promise<T>;
|
|
377
|
+
protected createUpdateConnectionPasswordPromise(command: command_request.UpdateConnectionPassword): Promise<GlideString>;
|
|
378
|
+
protected createScriptInvocationPromise<T = GlideString>(command: command_request.ScriptInvocation, options?: {
|
|
379
|
+
keys?: GlideString[];
|
|
380
|
+
args?: GlideString[];
|
|
381
|
+
} & DecoderOption): Promise<T>;
|
|
382
|
+
protected writeOrBufferCommandRequest(callbackIdx: number, command: command_request.Command | command_request.Command[], route?: command_request.Routes): void;
|
|
383
|
+
protected writeOrBufferRequest<TRequest>(message: TRequest, encodeDelimited: (message: TRequest, writer: Writer) => void): void;
|
|
376
384
|
/**
|
|
377
385
|
* @internal
|
|
378
386
|
*/
|
|
@@ -484,7 +492,8 @@ export declare class BaseClient {
|
|
|
484
492
|
* @param value - The value to store with the given key.
|
|
485
493
|
* @param options - (Optional) See {@link SetOptions} and {@link DecoderOption}.
|
|
486
494
|
* @returns - If the value is successfully set, return OK.
|
|
487
|
-
* If
|
|
495
|
+
* If `conditional` in `options` is not set, the value will be set regardless of prior value existence.
|
|
496
|
+
* If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` or `onlyIfEqual` conditions, return `null`.
|
|
488
497
|
* If `returnOldValue` is set, return the old value as a string.
|
|
489
498
|
*
|
|
490
499
|
* @example
|
|
@@ -504,6 +513,13 @@ export declare class BaseClient {
|
|
|
504
513
|
* // Example usage of get method to retrieve the value of a key
|
|
505
514
|
* const result4 = await client.get("key");
|
|
506
515
|
* console.log(result4); // Output: 'new_value' - Value wasn't modified back to being "value" because of "NX" flag.
|
|
516
|
+
*
|
|
517
|
+
* // Example usage of set method with conditional option IFEQ
|
|
518
|
+
* await client.set("key", "value we will compare to");
|
|
519
|
+
* const result5 = await client.set("key", "new_value", {conditionalSet: "onlyIfEqual", comparisonValue: "value we will compare to"});
|
|
520
|
+
* console.log(result5); // Output: 'OK' - Set "new_value" to "key" only if comparisonValue is equal to the current value of "key".
|
|
521
|
+
* const result6 = await client.set("key", "another_new_value", {conditionalSet: "onlyIfEqual", comparisonValue: "value we will compare to"});
|
|
522
|
+
* console.log(result6); // Output: `null` - Value wasn't set because the comparisonValue is not equal to the current value of "key". Value of "key" remains "new_value".
|
|
507
523
|
* ```
|
|
508
524
|
*/
|
|
509
525
|
set(key: GlideString, value: GlideString, options?: SetOptions & DecoderOption): Promise<"OK" | GlideString | null>;
|
|
@@ -829,11 +845,12 @@ export declare class BaseClient {
|
|
|
829
845
|
* The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being
|
|
830
846
|
* the last byte of the list, `-2` being the penultimate, and so on.
|
|
831
847
|
*
|
|
832
|
-
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for
|
|
848
|
+
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for details.
|
|
833
849
|
*
|
|
834
850
|
* @param key - The key of the string.
|
|
835
851
|
* @param bit - The bit value to match. Must be `0` or `1`.
|
|
836
|
-
* @param
|
|
852
|
+
* @param options - (Optional) The {@link BitOffsetOptions}.
|
|
853
|
+
*
|
|
837
854
|
* @returns The position of the first occurrence of `bit` in the binary value of the string held at `key`.
|
|
838
855
|
* If `start` was provided, the search begins at the offset indicated by `start`.
|
|
839
856
|
*
|
|
@@ -843,45 +860,18 @@ export declare class BaseClient {
|
|
|
843
860
|
* const result1 = await client.bitpos("key1", 1);
|
|
844
861
|
* console.log(result1); // Output: 1 - The first occurrence of bit value 1 in the string stored at "key1" is at the second position.
|
|
845
862
|
*
|
|
846
|
-
* const result2 = await client.bitpos("key1", 1, -1);
|
|
863
|
+
* const result2 = await client.bitpos("key1", 1, { start: -1 });
|
|
847
864
|
* console.log(result2); // Output: 10 - The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position.
|
|
848
|
-
* ```
|
|
849
|
-
*/
|
|
850
|
-
bitpos(key: GlideString, bit: number, start?: number): Promise<number>;
|
|
851
|
-
/**
|
|
852
|
-
* Returns the position of the first bit matching the given `bit` value. The offsets are zero-based indexes, with
|
|
853
|
-
* `0` being the first element of the list, `1` being the next, and so on. These offsets can also be negative
|
|
854
|
-
* numbers indicating offsets starting at the end of the list, with `-1` being the last element of the list, `-2`
|
|
855
|
-
* being the penultimate, and so on.
|
|
856
|
-
*
|
|
857
|
-
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
|
|
858
|
-
* `start` and `end` offsets specify BIT or BYTE offsets. If `indexType` is not provided, BYTE offsets
|
|
859
|
-
* are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
|
|
860
|
-
* specified, `start=0` and `end=2` means to look at the first three bytes.
|
|
861
865
|
*
|
|
862
|
-
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for more details.
|
|
863
|
-
*
|
|
864
|
-
* @param key - The key of the string.
|
|
865
|
-
* @param bit - The bit value to match. Must be `0` or `1`.
|
|
866
|
-
* @param start - The starting offset.
|
|
867
|
-
* @param end - The ending offset.
|
|
868
|
-
* @param indexType - (Optional) The index offset type. This option can only be specified if you are using Valkey
|
|
869
|
-
* version 7.0.0 or above. Could be either {@link BitmapIndexType.BYTE} or {@link BitmapIndexType.BIT}. If no
|
|
870
|
-
* index type is provided, the indexes will be assumed to be byte indexes.
|
|
871
|
-
* @returns The position of the first occurrence from the `start` to the `end` offsets of the `bit` in the binary
|
|
872
|
-
* value of the string held at `key`.
|
|
873
|
-
*
|
|
874
|
-
* @example
|
|
875
|
-
* ```typescript
|
|
876
866
|
* await client.set("key1", "A12"); // "A12" has binary value 01000001 00110001 00110010
|
|
877
|
-
* const
|
|
878
|
-
* console.log(
|
|
867
|
+
* const result3 = await client.bitpos("key1", 1, { start: 1, end: -1 });
|
|
868
|
+
* console.log(result3); // Output: 10 - The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1" is at the eleventh position.
|
|
879
869
|
*
|
|
880
|
-
* const
|
|
881
|
-
* console.log(
|
|
870
|
+
* const result4 = await client.bitpos("key1", 1, { start: 2, end: 9, indexType: BitmapIndexType.BIT });
|
|
871
|
+
* console.log(result4); // Output: 7 - The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position.
|
|
882
872
|
* ```
|
|
883
873
|
*/
|
|
884
|
-
|
|
874
|
+
bitpos(key: GlideString, bit: number, options?: BitOffsetOptions): Promise<number>;
|
|
885
875
|
/**
|
|
886
876
|
* Reads or modifies the array of bits representing the string that is held at `key` based on the specified
|
|
887
877
|
* `subcommands`.
|
|
@@ -2829,7 +2819,6 @@ export declare class BaseClient {
|
|
|
2829
2819
|
* @param key - The key of the sorted set.
|
|
2830
2820
|
* @param rangeQuery - The range query object representing the type of range query to perform.
|
|
2831
2821
|
* - For range queries by index (rank), use {@link RangeByIndex}.
|
|
2832
|
-
* - For range queries by lexicographical order, use {@link RangeByLex}.
|
|
2833
2822
|
* - For range queries by score, use {@link RangeByScore}.
|
|
2834
2823
|
* @param options - (Optional) Additional parameters:
|
|
2835
2824
|
* - (Optional) `reverse`: if `true`, reverses the sorted set, with index `0` as the element with the highest score.
|
|
@@ -2860,7 +2849,7 @@ export declare class BaseClient {
|
|
|
2860
2849
|
* // [{ element: 'member7', score: 1.5 }, { element: 'member4', score: -2.0 }]
|
|
2861
2850
|
* ```
|
|
2862
2851
|
*/
|
|
2863
|
-
zrangeWithScores(key: GlideString, rangeQuery: RangeByScore |
|
|
2852
|
+
zrangeWithScores(key: GlideString, rangeQuery: RangeByScore | RangeByIndex, options?: {
|
|
2864
2853
|
reverse?: boolean;
|
|
2865
2854
|
} & DecoderOption): Promise<SortedSetDataType>;
|
|
2866
2855
|
/**
|
|
@@ -4432,7 +4421,7 @@ export declare class BaseClient {
|
|
|
4432
4421
|
* @see {@link https://valkey.io/commands/bitcount/|valkey.io} for more details.
|
|
4433
4422
|
*
|
|
4434
4423
|
* @param key - The key for the string to count the set bits of.
|
|
4435
|
-
* @param options - The offset options.
|
|
4424
|
+
* @param options - The offset options - see {@link BitOffsetOptions}.
|
|
4436
4425
|
* @returns If `options` is provided, returns the number of set bits in the string interval specified by `options`.
|
|
4437
4426
|
* If `options` is not provided, returns the number of set bits in the string stored at `key`.
|
|
4438
4427
|
* Otherwise, if `key` is missing, returns `0` as it is treated as an empty string.
|
|
@@ -19,15 +19,26 @@ export declare function createGetDel(key: GlideString): command_request.Command;
|
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export declare function createGetRange(key: GlideString, start: number, end: number): command_request.Command;
|
|
22
|
-
export
|
|
22
|
+
export type SetOptions = ({
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* `onlyIfDoesNotExist` - Only set the key if it does not already exist.
|
|
25
|
+
* `NX` in the Valkey API.
|
|
26
|
+
*
|
|
27
|
+
* `onlyIfExists` - Only set the key if it already exists.
|
|
28
|
+
* `EX` in the Valkey API.
|
|
29
29
|
*/
|
|
30
30
|
conditionalSet?: "onlyIfExists" | "onlyIfDoesNotExist";
|
|
31
|
+
} | {
|
|
32
|
+
/**
|
|
33
|
+
* `onlyIfEqual` - Only set the key if the comparison value equals the current value of key.
|
|
34
|
+
* `IFEQ` in the Valkey API.
|
|
35
|
+
*/
|
|
36
|
+
conditionalSet: "onlyIfEqual";
|
|
37
|
+
/**
|
|
38
|
+
* The value to compare the existing value with.
|
|
39
|
+
*/
|
|
40
|
+
comparisonValue: GlideString;
|
|
41
|
+
}) & {
|
|
31
42
|
/**
|
|
32
43
|
* Return the old string stored at key, or nil if key did not exist. An error
|
|
33
44
|
* is returned and SET aborted if the value stored at key is not a string.
|
|
@@ -41,7 +52,7 @@ export interface SetOptions {
|
|
|
41
52
|
type: TimeUnit;
|
|
42
53
|
count: number;
|
|
43
54
|
};
|
|
44
|
-
}
|
|
55
|
+
};
|
|
45
56
|
/**
|
|
46
57
|
* @internal
|
|
47
58
|
*/
|
|
@@ -1074,18 +1085,25 @@ export declare enum FunctionRestorePolicy {
|
|
|
1074
1085
|
/** @internal */
|
|
1075
1086
|
export declare function createFunctionRestore(data: Buffer, policy?: FunctionRestorePolicy): command_request.Command;
|
|
1076
1087
|
/**
|
|
1077
|
-
* Represents offsets specifying a string interval to analyze in the {@link BaseClient.bitcount|bitcount}
|
|
1078
|
-
* zero-based indexes, with `0` being the first index of the string, `1` being the next index and so on.
|
|
1088
|
+
* Represents offsets specifying a string interval to analyze in the {@link BaseClient.bitcount | bitcount} and {@link BaseClient.bitpos | bitpos} commands.
|
|
1089
|
+
* The offsets are zero-based indexes, with `0` being the first index of the string, `1` being the next index and so on.
|
|
1079
1090
|
* The offsets can also be negative numbers indicating offsets starting at the end of the string, with `-1` being
|
|
1080
1091
|
* the last index of the string, `-2` being the penultimate, and so on.
|
|
1081
1092
|
*
|
|
1082
|
-
*
|
|
1093
|
+
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
|
|
1094
|
+
* `start` and `end` offsets specify `BIT` or `BYTE` offsets. If `indexType` is not provided, `BYTE` offsets
|
|
1095
|
+
* are assumed. If `BIT` is specified, `start=0` and `end=2` means to look at the first three bits. If `BYTE` is
|
|
1096
|
+
* specified, `start=0` and `end=2` means to look at the first three bytes.
|
|
1097
|
+
*
|
|
1098
|
+
* @see {@link https://valkey.io/commands/bitcount/ | bitcount} and {@link https://valkey.io/commands/bitpos/ | bitpos} for more details.
|
|
1083
1099
|
*/
|
|
1084
1100
|
export interface BitOffsetOptions {
|
|
1085
1101
|
/** The starting offset index. */
|
|
1086
1102
|
start: number;
|
|
1087
|
-
/**
|
|
1088
|
-
*
|
|
1103
|
+
/**
|
|
1104
|
+
* The ending offset index. Optional since Valkey version 8.0 and above for the BITCOUNT command.
|
|
1105
|
+
* If not provided, it will default to the end of the string.
|
|
1106
|
+
* Could be defined only if `start` is defined.
|
|
1089
1107
|
*/
|
|
1090
1108
|
end?: number;
|
|
1091
1109
|
/**
|
|
@@ -1115,7 +1133,7 @@ export declare enum BitmapIndexType {
|
|
|
1115
1133
|
/**
|
|
1116
1134
|
* @internal
|
|
1117
1135
|
*/
|
|
1118
|
-
export declare function createBitPos(key: GlideString, bit: number,
|
|
1136
|
+
export declare function createBitPos(key: GlideString, bit: number, options?: BitOffsetOptions): command_request.Command;
|
|
1119
1137
|
/**
|
|
1120
1138
|
* Defines flushing mode for {@link GlideClient.flushall}, {@link GlideClusterClient.flushall},
|
|
1121
1139
|
* {@link GlideClient.functionFlush}, {@link GlideClusterClient.functionFlush},
|
|
@@ -336,6 +336,7 @@ export declare class GlideClient extends BaseClient {
|
|
|
336
336
|
clientId(): Promise<number>;
|
|
337
337
|
/**
|
|
338
338
|
* Reads the configuration parameters of the running server.
|
|
339
|
+
* Starting from server version 7, command supports multiple parameters.
|
|
339
340
|
*
|
|
340
341
|
* @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
|
|
341
342
|
*
|
|
@@ -354,6 +355,7 @@ export declare class GlideClient extends BaseClient {
|
|
|
354
355
|
configGet(parameters: string[], options?: DecoderOption): Promise<Record<string, GlideString>>;
|
|
355
356
|
/**
|
|
356
357
|
* Sets configuration parameters to the specified values.
|
|
358
|
+
* Starting from server version 7, command supports multiple parameters.
|
|
357
359
|
*
|
|
358
360
|
* @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
|
|
359
361
|
* @param parameters - A map consisting of configuration parameters and their respective values to set.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { ClusterScanCursor, Script } from "glide-rs";
|
|
5
5
|
import * as net from "net";
|
|
6
6
|
import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
|
|
7
|
-
import { FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsSingleResponse, InfoOptions, LolwutOptions
|
|
7
|
+
import { ClusterScanOptions, FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsSingleResponse, InfoOptions, LolwutOptions } from "./Commands";
|
|
8
8
|
import { command_request, connection_request } from "./ProtobufMessage";
|
|
9
9
|
import { ClusterTransaction } from "./Transaction";
|
|
10
10
|
/** An extension to command option types with {@link Routes}. */
|
|
@@ -686,6 +686,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
686
686
|
clientId(options?: RouteOption): Promise<ClusterResponse<number>>;
|
|
687
687
|
/**
|
|
688
688
|
* Reads the configuration parameters of the running server.
|
|
689
|
+
* Starting from server version 7, command supports multiple parameters.
|
|
689
690
|
*
|
|
690
691
|
* The command will be routed to a random node, unless `route` is provided.
|
|
691
692
|
*
|
|
@@ -714,6 +715,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
714
715
|
configGet(parameters: string[], options?: RouteOption & DecoderOption): Promise<ClusterResponse<Record<string, GlideString>>>;
|
|
715
716
|
/**
|
|
716
717
|
* Sets configuration parameters to the specified values.
|
|
718
|
+
* Starting from server version 7, command supports multiple parameters.
|
|
717
719
|
*
|
|
718
720
|
* The command will be routed to all nodes, unless `route` is provided.
|
|
719
721
|
*
|
|
@@ -1284,6 +1286,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
1284
1286
|
invokeScriptWithRoute(script: Script, options?: {
|
|
1285
1287
|
args?: GlideString[];
|
|
1286
1288
|
} & DecoderOption & RouteOption): Promise<ClusterResponse<GlideReturnType>>;
|
|
1289
|
+
private createScriptInvocationWithRoutePromise;
|
|
1287
1290
|
/**
|
|
1288
1291
|
* Checks existence of scripts in the script cache by their SHA1 digest.
|
|
1289
1292
|
*
|
|
@@ -6,7 +6,7 @@ GlideRecord, GlideString, HashDataType, // eslint-disable-line @typescript-eslin
|
|
|
6
6
|
SortedSetDataType } from "./BaseClient";
|
|
7
7
|
import { AggregationType, BaseScanOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8
8
|
BitFieldSubCommands, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
9
|
-
BitOffsetOptions,
|
|
9
|
+
BitOffsetOptions, BitwiseOperation, Boundary, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
10
10
|
ExpireOptions, FlushMode, FunctionListOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
11
11
|
FunctionRestorePolicy, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
12
12
|
GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
@@ -327,37 +327,12 @@ export declare class BaseTransaction<T extends BaseTransaction<T>> {
|
|
|
327
327
|
*
|
|
328
328
|
* @param key - The key of the string.
|
|
329
329
|
* @param bit - The bit value to match. Must be `0` or `1`.
|
|
330
|
-
* @param
|
|
330
|
+
* @param options - (Optional) The {@link BitOffsetOptions}.
|
|
331
331
|
*
|
|
332
332
|
* Command Response - The position of the first occurrence of `bit` in the binary value of the string held at `key`.
|
|
333
333
|
* If `start` was provided, the search begins at the offset indicated by `start`.
|
|
334
334
|
*/
|
|
335
|
-
bitpos(key: GlideString, bit: number,
|
|
336
|
-
/**
|
|
337
|
-
* Returns the position of the first bit matching the given `bit` value. The offsets are zero-based indexes, with
|
|
338
|
-
* `0` being the first element of the list, `1` being the next, and so on. These offsets can also be negative
|
|
339
|
-
* numbers indicating offsets starting at the end of the list, with `-1` being the last element of the list, `-2`
|
|
340
|
-
* being the penultimate, and so on.
|
|
341
|
-
*
|
|
342
|
-
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
|
|
343
|
-
* `start` and `end` offsets specify BIT or BYTE offsets. If `indexType` is not provided, BYTE offsets
|
|
344
|
-
* are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
|
|
345
|
-
* specified, `start=0` and `end=2` means to look at the first three bytes.
|
|
346
|
-
*
|
|
347
|
-
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for details.
|
|
348
|
-
*
|
|
349
|
-
* @param key - The key of the string.
|
|
350
|
-
* @param bit - The bit value to match. Must be `0` or `1`.
|
|
351
|
-
* @param start - The starting offset.
|
|
352
|
-
* @param end - The ending offset.
|
|
353
|
-
* @param indexType - (Optional) The index offset type. This option can only be specified if you are using Valkey
|
|
354
|
-
* version 7.0.0 or above. Could be either {@link BitmapIndexType.BYTE} or {@link BitmapIndexType.BIT}. If no
|
|
355
|
-
* index type is provided, the indexes will be assumed to be byte indexes.
|
|
356
|
-
*
|
|
357
|
-
* Command Response - The position of the first occurrence from the `start` to the `end` offsets of the `bit` in the
|
|
358
|
-
* binary value of the string held at `key`.
|
|
359
|
-
*/
|
|
360
|
-
bitposInterval(key: GlideString, bit: number, start: number, end: number, indexType?: BitmapIndexType): T;
|
|
335
|
+
bitpos(key: GlideString, bit: number, options?: BitOffsetOptions): T;
|
|
361
336
|
/**
|
|
362
337
|
* Reads or modifies the array of bits representing the string that is held at `key` based on the specified
|
|
363
338
|
* `subcommands`.
|
|
@@ -398,6 +373,7 @@ export declare class BaseTransaction<T extends BaseTransaction<T>> {
|
|
|
398
373
|
bitfieldReadOnly(key: GlideString, subcommands: BitFieldGet[]): T;
|
|
399
374
|
/**
|
|
400
375
|
* Reads the configuration parameters of the running server.
|
|
376
|
+
* Starting from server version 7, command supports multiple parameters.
|
|
401
377
|
*
|
|
402
378
|
* @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
|
|
403
379
|
*
|
|
@@ -409,6 +385,7 @@ export declare class BaseTransaction<T extends BaseTransaction<T>> {
|
|
|
409
385
|
configGet(parameters: string[]): T;
|
|
410
386
|
/**
|
|
411
387
|
* Sets configuration parameters to the specified values.
|
|
388
|
+
* Starting from server version 7, command supports multiple parameters.
|
|
412
389
|
*
|
|
413
390
|
* @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
|
|
414
391
|
*
|
|
@@ -1337,7 +1314,6 @@ export declare class BaseTransaction<T extends BaseTransaction<T>> {
|
|
|
1337
1314
|
* @param key - The key of the sorted set.
|
|
1338
1315
|
* @param rangeQuery - The range query object representing the type of range query to perform.
|
|
1339
1316
|
* - For range queries by index (rank), use {@link RangeByIndex}.
|
|
1340
|
-
* - For range queries by lexicographical order, use {@link RangeByLex}.
|
|
1341
1317
|
* - For range queries by score, use {@link RangeByScore}.
|
|
1342
1318
|
* @param reverse - If `true`, reverses the sorted set, with index `0` as the element with the highest score.
|
|
1343
1319
|
*
|
|
@@ -1345,7 +1321,7 @@ export declare class BaseTransaction<T extends BaseTransaction<T>> {
|
|
|
1345
1321
|
* If `key` does not exist, it is treated as an empty sorted set, and the command returns an empty list.
|
|
1346
1322
|
* The response comes in format `GlideRecord<number>`, see {@link GlideRecord}.
|
|
1347
1323
|
*/
|
|
1348
|
-
zrangeWithScores(key: GlideString, rangeQuery: RangeByScore |
|
|
1324
|
+
zrangeWithScores(key: GlideString, rangeQuery: RangeByScore | RangeByIndex, reverse?: boolean): T;
|
|
1349
1325
|
/**
|
|
1350
1326
|
* Stores a specified range of elements from the sorted set at `source`, into a new
|
|
1351
1327
|
* sorted set at `destination`. If `destination` doesn't exist, a new sorted
|
|
@@ -2428,7 +2404,7 @@ export declare class BaseTransaction<T extends BaseTransaction<T>> {
|
|
|
2428
2404
|
* @see {@link https://valkey.io/commands/bitcount/|valkey.io} for more details.
|
|
2429
2405
|
*
|
|
2430
2406
|
* @param key - The key for the string to count the set bits of.
|
|
2431
|
-
* @param options - The offset options.
|
|
2407
|
+
* @param options - The offset options - see {@link BitOffsetOptions}.
|
|
2432
2408
|
*
|
|
2433
2409
|
* Command Response - If `options` is provided, returns the number of set bits in the string interval specified by `options`.
|
|
2434
2410
|
* If `options` is not provided, returns the number of set bits in the string stored at `key`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
3
3
|
*/
|
|
4
|
+
import { ClusterTransaction, Transaction } from "src/Transaction";
|
|
4
5
|
import { BaseClient, DecoderOption, GlideString } from "../BaseClient";
|
|
5
6
|
import { ConditionalChange } from "../Commands";
|
|
6
7
|
export type ReturnTypeJson<T> = T | (T | null)[];
|
|
@@ -49,7 +50,7 @@ export declare class GlideJson {
|
|
|
49
50
|
* ```typescript
|
|
50
51
|
* const value = {a: 1.0, b:2};
|
|
51
52
|
* const jsonStr = JSON.stringify(value);
|
|
52
|
-
* const result = await GlideJson.set("doc", "$", jsonStr);
|
|
53
|
+
* const result = await GlideJson.set(client, "doc", "$", jsonStr);
|
|
53
54
|
* console.log(result); // 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
|
|
54
55
|
*
|
|
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.
|
|
@@ -166,7 +167,7 @@ export declare class GlideJson {
|
|
|
166
167
|
* await GlideJson.set(client, "doc", "$", '[[], ["a"], ["a", "b"]]');
|
|
167
168
|
* const result = await GlideJson.arrinsert(client, "doc", "$[*]", 0, ['"c"', '{"key": "value"}', "true", "null", '["bar"]']);
|
|
168
169
|
* console.log(result); // Output: [5, 6, 7]
|
|
169
|
-
* const doc = await
|
|
170
|
+
* const doc = await GlideJson.get(client, "doc");
|
|
170
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"]]'
|
|
171
172
|
* ```
|
|
172
173
|
* @example
|
|
@@ -174,7 +175,7 @@ export declare class GlideJson {
|
|
|
174
175
|
* await GlideJson.set(client, "doc", "$", '[[], ["a"], ["a", "b"]]');
|
|
175
176
|
* const result = await GlideJson.arrinsert(client, "doc", ".", 0, ['"c"'])
|
|
176
177
|
* console.log(result); // Output: 4
|
|
177
|
-
* const doc = await
|
|
178
|
+
* const doc = await GlideJson.get(client, "doc");
|
|
178
179
|
* console.log(doc); // Output: '[\"c\",[],[\"a\"],[\"a\",\"b\"]]'
|
|
179
180
|
* ```
|
|
180
181
|
*/
|
|
@@ -349,7 +350,7 @@ export declare class GlideJson {
|
|
|
349
350
|
* ```typescript
|
|
350
351
|
* const value = {bool: true, nested: {bool: false, nested: {bool: 10}}};
|
|
351
352
|
* const jsonStr = JSON.stringify(value);
|
|
352
|
-
* const resultSet = await GlideJson.set("doc", "$", jsonStr);
|
|
353
|
+
* const resultSet = await GlideJson.set(client, "doc", "$", jsonStr);
|
|
353
354
|
* // Output: 'OK'
|
|
354
355
|
*
|
|
355
356
|
* const resultToggle = await.GlideJson.toggle(client, "doc", {path: "$.bool"});
|
|
@@ -501,13 +502,13 @@ export declare class GlideJson {
|
|
|
501
502
|
/**
|
|
502
503
|
* Retrieve the JSON value at the specified `path` within the JSON document stored at `key`.
|
|
503
504
|
* The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).
|
|
504
|
-
* JSON null is mapped to the RESP Null Bulk String.
|
|
505
|
-
* JSON Booleans are mapped to RESP Simple string.
|
|
506
|
-
* JSON integers are mapped to RESP Integers.
|
|
507
|
-
* JSON doubles are mapped to RESP Bulk Strings.
|
|
508
|
-
* JSON strings are mapped to RESP Bulk Strings.
|
|
509
|
-
* JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
|
|
510
|
-
* 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.
|
|
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.
|
|
511
512
|
*
|
|
512
513
|
* @param client - The client to execute the command.
|
|
513
514
|
* @param key - The key of the JSON document.
|
|
@@ -694,7 +695,7 @@ export declare class GlideJson {
|
|
|
694
695
|
* ```typescript
|
|
695
696
|
* console.log(await GlideJson.set(client, "doc", "$", '[1, 2.3, "foo", true, null, {}, [], {a:1, b:2}, [1, 2, 3]]'));
|
|
696
697
|
* // Output: 'OK' - Indicates successful setting of the value at path '$' in the key stored at `doc`.
|
|
697
|
-
* console.log(await GlideJson.
|
|
698
|
+
* console.log(await GlideJson.debugFields(client, "doc", {path: "$[*]"});
|
|
698
699
|
* // Output: [1, 1, 1, 1, 1, 0, 0, 2, 3]
|
|
699
700
|
* ```
|
|
700
701
|
*/
|
|
@@ -827,3 +828,508 @@ export declare class GlideJson {
|
|
|
827
828
|
path: GlideString;
|
|
828
829
|
} & DecoderOption): Promise<ReturnTypeJson<GlideString[]>>;
|
|
829
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valkey/valkey-glide",
|
|
3
3
|
"types": "build-ts/index.d.ts",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0-rc2",
|
|
5
5
|
"description": "General Language Independent Driver for the Enterprise (GLIDE) for Valkey",
|
|
6
6
|
"main": "build-ts/index.js",
|
|
7
7
|
"module": "build-ts/index.js",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"typescript": "^4.9.4"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@valkey/valkey-glide-darwin-arm64": "1.
|
|
44
|
-
"@valkey/valkey-glide-linux-arm64": "1.
|
|
45
|
-
"@valkey/valkey-glide-linux-x64": "1.
|
|
46
|
-
"@valkey/valkey-glide-linux-musl-arm64": "1.
|
|
47
|
-
"@valkey/valkey-glide-linux-musl-x64": "1.
|
|
43
|
+
"@valkey/valkey-glide-darwin-arm64": "1.3.0-rc2",
|
|
44
|
+
"@valkey/valkey-glide-linux-arm64": "1.3.0-rc2",
|
|
45
|
+
"@valkey/valkey-glide-linux-x64": "1.3.0-rc2",
|
|
46
|
+
"@valkey/valkey-glide-linux-musl-arm64": "1.3.0-rc2",
|
|
47
|
+
"@valkey/valkey-glide-linux-musl-x64": "1.3.0-rc2"
|
|
48
48
|
},
|
|
49
49
|
"eslintConfig": {
|
|
50
50
|
"extends": [
|