@valkey/valkey-glide-darwin-arm64 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/src/BaseClient.d.ts +44 -55
- package/build-ts/src/BaseClient.js +151 -170
- package/build-ts/src/BaseClient.js.map +1 -1
- package/build-ts/src/Commands.d.ts +30 -12
- package/build-ts/src/Commands.js +27 -17
- package/build-ts/src/Commands.js.map +1 -1
- package/build-ts/src/GlideClient.d.ts +2 -0
- package/build-ts/src/GlideClient.js +2 -0
- package/build-ts/src/GlideClient.js.map +1 -1
- package/build-ts/src/GlideClusterClient.d.ts +4 -1
- package/build-ts/src/GlideClusterClient.js +50 -3
- package/build-ts/src/GlideClusterClient.js.map +1 -1
- package/build-ts/src/ProtobufMessage.js +7 -0
- package/build-ts/src/ProtobufMessage.js.map +1 -1
- package/build-ts/src/Transaction.d.ts +7 -31
- package/build-ts/src/Transaction.js +6 -32
- package/build-ts/src/Transaction.js.map +1 -1
- package/build-ts/src/server-modules/GlideJson.d.ts +518 -12
- package/build-ts/src/server-modules/GlideJson.js +629 -13
- package/build-ts/src/server-modules/GlideJson.js.map +1 -1
- package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
- package/npm/glide/index.ts +2 -0
- package/package.json +6 -3
- package/rust-client/node_modules/mingo/dist/cjs/index.js +5 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/_predicates.js +8 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/slice.js +0 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/setField.js +4 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucketAuto.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/util.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/index.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/_predicates.js +8 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/slice.js +0 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/setField.js +4 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucketAuto.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/util.js +1 -1
- package/rust-client/node_modules/mingo/package.json +1 -1
|
@@ -191,77 +191,6 @@ function getRequestErrorClass(type) {
|
|
|
191
191
|
}
|
|
192
192
|
return Errors_1.RequestError;
|
|
193
193
|
}
|
|
194
|
-
/**
|
|
195
|
-
* @internal
|
|
196
|
-
*/
|
|
197
|
-
function toProtobufRoute(route) {
|
|
198
|
-
if (!route) {
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
if (route === "allPrimaries") {
|
|
202
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
203
|
-
simpleRoutes: ProtobufMessage_1.command_request.SimpleRoutes.AllPrimaries,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
else if (route === "allNodes") {
|
|
207
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
208
|
-
simpleRoutes: ProtobufMessage_1.command_request.SimpleRoutes.AllNodes,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
else if (route === "randomNode") {
|
|
212
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
213
|
-
simpleRoutes: ProtobufMessage_1.command_request.SimpleRoutes.Random,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
else if (route.type === "primarySlotKey") {
|
|
217
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
218
|
-
slotKeyRoute: ProtobufMessage_1.command_request.SlotKeyRoute.create({
|
|
219
|
-
slotType: ProtobufMessage_1.command_request.SlotTypes.Primary,
|
|
220
|
-
slotKey: route.key,
|
|
221
|
-
}),
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
else if (route.type === "replicaSlotKey") {
|
|
225
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
226
|
-
slotKeyRoute: ProtobufMessage_1.command_request.SlotKeyRoute.create({
|
|
227
|
-
slotType: ProtobufMessage_1.command_request.SlotTypes.Replica,
|
|
228
|
-
slotKey: route.key,
|
|
229
|
-
}),
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
else if (route.type === "primarySlotId") {
|
|
233
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
234
|
-
slotKeyRoute: ProtobufMessage_1.command_request.SlotIdRoute.create({
|
|
235
|
-
slotType: ProtobufMessage_1.command_request.SlotTypes.Primary,
|
|
236
|
-
slotId: route.id,
|
|
237
|
-
}),
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
else if (route.type === "replicaSlotId") {
|
|
241
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
242
|
-
slotKeyRoute: ProtobufMessage_1.command_request.SlotIdRoute.create({
|
|
243
|
-
slotType: ProtobufMessage_1.command_request.SlotTypes.Replica,
|
|
244
|
-
slotId: route.id,
|
|
245
|
-
}),
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
else if (route.type === "routeByAddress") {
|
|
249
|
-
let port = route.port;
|
|
250
|
-
let host = route.host;
|
|
251
|
-
if (port === undefined) {
|
|
252
|
-
const split = host.split(":");
|
|
253
|
-
if (split.length !== 2) {
|
|
254
|
-
throw new Errors_1.RequestError("No port provided, expected host to be formatted as `{hostname}:{port}`. Received " +
|
|
255
|
-
host);
|
|
256
|
-
}
|
|
257
|
-
host = split[0];
|
|
258
|
-
port = Number(split[1]);
|
|
259
|
-
}
|
|
260
|
-
return ProtobufMessage_1.command_request.Routes.create({
|
|
261
|
-
byAddressRoute: { host, port },
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
194
|
class BaseClient {
|
|
266
195
|
configurePubsub(options, configuration) {
|
|
267
196
|
if (options.pubsubSubscriptions) {
|
|
@@ -324,13 +253,81 @@ class BaseClient {
|
|
|
324
253
|
}
|
|
325
254
|
this.remainingReadData = undefined;
|
|
326
255
|
}
|
|
256
|
+
toProtobufRoute(route) {
|
|
257
|
+
if (!route) {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
if (route === "allPrimaries") {
|
|
261
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
262
|
+
simpleRoutes: ProtobufMessage_1.command_request.SimpleRoutes.AllPrimaries,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
else if (route === "allNodes") {
|
|
266
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
267
|
+
simpleRoutes: ProtobufMessage_1.command_request.SimpleRoutes.AllNodes,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
else if (route === "randomNode") {
|
|
271
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
272
|
+
simpleRoutes: ProtobufMessage_1.command_request.SimpleRoutes.Random,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
else if (route.type === "primarySlotKey") {
|
|
276
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
277
|
+
slotKeyRoute: ProtobufMessage_1.command_request.SlotKeyRoute.create({
|
|
278
|
+
slotType: ProtobufMessage_1.command_request.SlotTypes.Primary,
|
|
279
|
+
slotKey: route.key,
|
|
280
|
+
}),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
else if (route.type === "replicaSlotKey") {
|
|
284
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
285
|
+
slotKeyRoute: ProtobufMessage_1.command_request.SlotKeyRoute.create({
|
|
286
|
+
slotType: ProtobufMessage_1.command_request.SlotTypes.Replica,
|
|
287
|
+
slotKey: route.key,
|
|
288
|
+
}),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
else if (route.type === "primarySlotId") {
|
|
292
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
293
|
+
slotKeyRoute: ProtobufMessage_1.command_request.SlotIdRoute.create({
|
|
294
|
+
slotType: ProtobufMessage_1.command_request.SlotTypes.Primary,
|
|
295
|
+
slotId: route.id,
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
else if (route.type === "replicaSlotId") {
|
|
300
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
301
|
+
slotKeyRoute: ProtobufMessage_1.command_request.SlotIdRoute.create({
|
|
302
|
+
slotType: ProtobufMessage_1.command_request.SlotTypes.Replica,
|
|
303
|
+
slotId: route.id,
|
|
304
|
+
}),
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
else if (route.type === "routeByAddress") {
|
|
308
|
+
let port = route.port;
|
|
309
|
+
let host = route.host;
|
|
310
|
+
if (port === undefined) {
|
|
311
|
+
const split = host.split(":");
|
|
312
|
+
if (split.length !== 2) {
|
|
313
|
+
throw new Errors_1.RequestError("No port provided, expected host to be formatted as `{hostname}:{port}`. Received " +
|
|
314
|
+
host);
|
|
315
|
+
}
|
|
316
|
+
host = split[0];
|
|
317
|
+
port = Number(split[1]);
|
|
318
|
+
}
|
|
319
|
+
return ProtobufMessage_1.command_request.Routes.create({
|
|
320
|
+
byAddressRoute: { host, port },
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
327
324
|
processResponse(message) {
|
|
328
325
|
var _a;
|
|
329
326
|
if (message.closingError != null) {
|
|
330
327
|
this.close(message.closingError);
|
|
331
328
|
return;
|
|
332
329
|
}
|
|
333
|
-
const [resolve, reject] = this.promiseCallbackFunctions[message.callbackIdx];
|
|
330
|
+
const [resolve, reject, decoder = this.defaultDecoder] = this.promiseCallbackFunctions[message.callbackIdx];
|
|
334
331
|
this.availableCallbackSlots.push(message.callbackIdx);
|
|
335
332
|
if (message.requestError != null) {
|
|
336
333
|
const errorType = getRequestErrorClass(message.requestError.type);
|
|
@@ -346,7 +343,15 @@ class BaseClient {
|
|
|
346
343
|
// Response from type long
|
|
347
344
|
pointer = new PointerResponse(message.respPointer, message.respPointer.high, message.respPointer.low);
|
|
348
345
|
}
|
|
349
|
-
|
|
346
|
+
try {
|
|
347
|
+
resolve((0, glide_rs_1.valueFromSplitPointer)(pointer.high, pointer.low, decoder === Decoder.String));
|
|
348
|
+
}
|
|
349
|
+
catch (err) {
|
|
350
|
+
Logger_1.Logger.log("error", "Decoder", `Decoding error: '${err}'`);
|
|
351
|
+
reject(err instanceof Errors_1.ValkeyError
|
|
352
|
+
? err
|
|
353
|
+
: new Error(`Decoding error: '${err}'`));
|
|
354
|
+
}
|
|
350
355
|
}
|
|
351
356
|
else if (message.constantResponse === ProtobufMessage_1.response.ConstantResponse.OK) {
|
|
352
357
|
resolve("OK");
|
|
@@ -392,6 +397,7 @@ class BaseClient {
|
|
|
392
397
|
primary: ProtobufMessage_1.connection_request.ReadFrom.Primary,
|
|
393
398
|
preferReplica: ProtobufMessage_1.connection_request.ReadFrom.PreferReplica,
|
|
394
399
|
AZAffinity: ProtobufMessage_1.connection_request.ReadFrom.AZAffinity,
|
|
400
|
+
AZAffinityReplicasAndPrimary: ProtobufMessage_1.connection_request.ReadFrom.AZAffinityReplicasAndPrimary,
|
|
395
401
|
};
|
|
396
402
|
// if logger has been initialized by the external-user on info level this log will be shown
|
|
397
403
|
Logger_1.Logger.log("info", "Client lifetime", `construct client`);
|
|
@@ -426,49 +432,57 @@ class BaseClient {
|
|
|
426
432
|
}
|
|
427
433
|
});
|
|
428
434
|
}
|
|
435
|
+
ensureClientIsOpen() {
|
|
436
|
+
if (this.isClosed) {
|
|
437
|
+
throw new Errors_1.ClosingError("Unable to execute requests; the client is closed. Please create a new client.");
|
|
438
|
+
}
|
|
439
|
+
}
|
|
429
440
|
/**
|
|
430
441
|
* @internal
|
|
431
442
|
*/
|
|
432
443
|
createWritePromise(command, options = {}) {
|
|
433
|
-
|
|
434
|
-
const route = toProtobufRoute(options === null || options === void 0 ? void 0 : options.route);
|
|
435
|
-
const stringDecoder = ((_a = options === null || options === void 0 ? void 0 : options.decoder) !== null && _a !== void 0 ? _a : this.defaultDecoder) === Decoder.String;
|
|
436
|
-
if (this.isClosed) {
|
|
437
|
-
throw new Errors_1.ClosingError("Unable to execute requests; the client is closed. Please create a new client.");
|
|
438
|
-
}
|
|
444
|
+
this.ensureClientIsOpen();
|
|
445
|
+
const route = this.toProtobufRoute(options === null || options === void 0 ? void 0 : options.route);
|
|
439
446
|
return new Promise((resolve, reject) => {
|
|
440
447
|
const callbackIndex = this.getCallbackIndex();
|
|
441
448
|
this.promiseCallbackFunctions[callbackIndex] = [
|
|
442
|
-
|
|
443
|
-
try {
|
|
444
|
-
if (resolveAns instanceof PointerResponse) {
|
|
445
|
-
// valueFromSplitPointer method is used to convert a pointer from a protobuf response into a TypeScript object.
|
|
446
|
-
// The protobuf response is received on a socket and the value in the response is a pointer to a Rust object.
|
|
447
|
-
// The pointer is a split pointer because JavaScript doesn't support `u64` and pointers in Rust can be `u64`,
|
|
448
|
-
// so we represent it with two`u32`(`high` and`low`).
|
|
449
|
-
if (typeof resolveAns === "number") {
|
|
450
|
-
resolveAns = (0, glide_rs_1.valueFromSplitPointer)(0, resolveAns, stringDecoder);
|
|
451
|
-
}
|
|
452
|
-
else {
|
|
453
|
-
resolveAns = (0, glide_rs_1.valueFromSplitPointer)(resolveAns.high, resolveAns.low, stringDecoder);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (command instanceof ProtobufMessage_1.command_request.ClusterScan) {
|
|
457
|
-
const resolveAnsArray = resolveAns;
|
|
458
|
-
resolveAnsArray[0] = new glide_rs_1.ClusterScanCursor(resolveAnsArray[0].toString());
|
|
459
|
-
}
|
|
460
|
-
resolve(resolveAns);
|
|
461
|
-
}
|
|
462
|
-
catch (err) {
|
|
463
|
-
Logger_1.Logger.log("error", "Decoder", `Decoding error: '${err}'`);
|
|
464
|
-
reject(err);
|
|
465
|
-
}
|
|
466
|
-
},
|
|
449
|
+
resolve,
|
|
467
450
|
reject,
|
|
451
|
+
options === null || options === void 0 ? void 0 : options.decoder,
|
|
468
452
|
];
|
|
469
453
|
this.writeOrBufferCommandRequest(callbackIndex, command, route);
|
|
470
454
|
});
|
|
471
455
|
}
|
|
456
|
+
createUpdateConnectionPasswordPromise(command) {
|
|
457
|
+
this.ensureClientIsOpen();
|
|
458
|
+
return new Promise((resolve, reject) => {
|
|
459
|
+
const callbackIdx = this.getCallbackIndex();
|
|
460
|
+
this.promiseCallbackFunctions[callbackIdx] = [resolve, reject];
|
|
461
|
+
this.writeOrBufferRequest(new ProtobufMessage_1.command_request.CommandRequest({
|
|
462
|
+
callbackIdx,
|
|
463
|
+
updateConnectionPassword: command,
|
|
464
|
+
}), (message, writer) => {
|
|
465
|
+
ProtobufMessage_1.command_request.CommandRequest.encodeDelimited(message, writer);
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
createScriptInvocationPromise(command, options = {}) {
|
|
470
|
+
this.ensureClientIsOpen();
|
|
471
|
+
return new Promise((resolve, reject) => {
|
|
472
|
+
const callbackIdx = this.getCallbackIndex();
|
|
473
|
+
this.promiseCallbackFunctions[callbackIdx] = [
|
|
474
|
+
resolve,
|
|
475
|
+
reject,
|
|
476
|
+
options === null || options === void 0 ? void 0 : options.decoder,
|
|
477
|
+
];
|
|
478
|
+
this.writeOrBufferRequest(new ProtobufMessage_1.command_request.CommandRequest({
|
|
479
|
+
callbackIdx,
|
|
480
|
+
scriptInvocation: command,
|
|
481
|
+
}), (message, writer) => {
|
|
482
|
+
ProtobufMessage_1.command_request.CommandRequest.encodeDelimited(message, writer);
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
}
|
|
472
486
|
writeOrBufferCommandRequest(callbackIdx, command, route) {
|
|
473
487
|
const message = Array.isArray(command)
|
|
474
488
|
? ProtobufMessage_1.command_request.CommandRequest.create({
|
|
@@ -476,27 +490,13 @@ class BaseClient {
|
|
|
476
490
|
transaction: ProtobufMessage_1.command_request.Transaction.create({
|
|
477
491
|
commands: command,
|
|
478
492
|
}),
|
|
493
|
+
route,
|
|
479
494
|
})
|
|
480
|
-
:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
: command instanceof ProtobufMessage_1.command_request.ClusterScan
|
|
486
|
-
? ProtobufMessage_1.command_request.CommandRequest.create({
|
|
487
|
-
callbackIdx,
|
|
488
|
-
clusterScan: command,
|
|
489
|
-
})
|
|
490
|
-
: command instanceof ProtobufMessage_1.command_request.UpdateConnectionPassword
|
|
491
|
-
? ProtobufMessage_1.command_request.CommandRequest.create({
|
|
492
|
-
callbackIdx,
|
|
493
|
-
updateConnectionPassword: command,
|
|
494
|
-
})
|
|
495
|
-
: ProtobufMessage_1.command_request.CommandRequest.create({
|
|
496
|
-
callbackIdx,
|
|
497
|
-
scriptInvocation: command,
|
|
498
|
-
});
|
|
499
|
-
message.route = route;
|
|
495
|
+
: ProtobufMessage_1.command_request.CommandRequest.create({
|
|
496
|
+
callbackIdx,
|
|
497
|
+
singleCommand: command,
|
|
498
|
+
route,
|
|
499
|
+
});
|
|
500
500
|
this.writeOrBufferRequest(message, (message, writer) => {
|
|
501
501
|
ProtobufMessage_1.command_request.CommandRequest.encodeDelimited(message, writer);
|
|
502
502
|
});
|
|
@@ -748,7 +748,8 @@ class BaseClient {
|
|
|
748
748
|
* @param value - The value to store with the given key.
|
|
749
749
|
* @param options - (Optional) See {@link SetOptions} and {@link DecoderOption}.
|
|
750
750
|
* @returns - If the value is successfully set, return OK.
|
|
751
|
-
* If
|
|
751
|
+
* If `conditional` in `options` is not set, the value will be set regardless of prior value existence.
|
|
752
|
+
* If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` or `onlyIfEqual` conditions, return `null`.
|
|
752
753
|
* If `returnOldValue` is set, return the old value as a string.
|
|
753
754
|
*
|
|
754
755
|
* @example
|
|
@@ -768,6 +769,13 @@ class BaseClient {
|
|
|
768
769
|
* // Example usage of get method to retrieve the value of a key
|
|
769
770
|
* const result4 = await client.get("key");
|
|
770
771
|
* console.log(result4); // Output: 'new_value' - Value wasn't modified back to being "value" because of "NX" flag.
|
|
772
|
+
*
|
|
773
|
+
* // Example usage of set method with conditional option IFEQ
|
|
774
|
+
* await client.set("key", "value we will compare to");
|
|
775
|
+
* const result5 = await client.set("key", "new_value", {conditionalSet: "onlyIfEqual", comparisonValue: "value we will compare to"});
|
|
776
|
+
* console.log(result5); // Output: 'OK' - Set "new_value" to "key" only if comparisonValue is equal to the current value of "key".
|
|
777
|
+
* const result6 = await client.set("key", "another_new_value", {conditionalSet: "onlyIfEqual", comparisonValue: "value we will compare to"});
|
|
778
|
+
* 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".
|
|
771
779
|
* ```
|
|
772
780
|
*/
|
|
773
781
|
set(key, value, options) {
|
|
@@ -1155,11 +1163,12 @@ class BaseClient {
|
|
|
1155
1163
|
* The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being
|
|
1156
1164
|
* the last byte of the list, `-2` being the penultimate, and so on.
|
|
1157
1165
|
*
|
|
1158
|
-
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for
|
|
1166
|
+
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for details.
|
|
1159
1167
|
*
|
|
1160
1168
|
* @param key - The key of the string.
|
|
1161
1169
|
* @param bit - The bit value to match. Must be `0` or `1`.
|
|
1162
|
-
* @param
|
|
1170
|
+
* @param options - (Optional) The {@link BitOffsetOptions}.
|
|
1171
|
+
*
|
|
1163
1172
|
* @returns The position of the first occurrence of `bit` in the binary value of the string held at `key`.
|
|
1164
1173
|
* If `start` was provided, the search begins at the offset indicated by `start`.
|
|
1165
1174
|
*
|
|
@@ -1169,51 +1178,20 @@ class BaseClient {
|
|
|
1169
1178
|
* const result1 = await client.bitpos("key1", 1);
|
|
1170
1179
|
* console.log(result1); // Output: 1 - The first occurrence of bit value 1 in the string stored at "key1" is at the second position.
|
|
1171
1180
|
*
|
|
1172
|
-
* const result2 = await client.bitpos("key1", 1, -1);
|
|
1181
|
+
* const result2 = await client.bitpos("key1", 1, { start: -1 });
|
|
1173
1182
|
* 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.
|
|
1174
|
-
* ```
|
|
1175
|
-
*/
|
|
1176
|
-
bitpos(key, bit, start) {
|
|
1177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1178
|
-
return this.createWritePromise((0, Commands_1.createBitPos)(key, bit, start));
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
/**
|
|
1182
|
-
* Returns the position of the first bit matching the given `bit` value. The offsets are zero-based indexes, with
|
|
1183
|
-
* `0` being the first element of the list, `1` being the next, and so on. These offsets can also be negative
|
|
1184
|
-
* numbers indicating offsets starting at the end of the list, with `-1` being the last element of the list, `-2`
|
|
1185
|
-
* being the penultimate, and so on.
|
|
1186
|
-
*
|
|
1187
|
-
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
|
|
1188
|
-
* `start` and `end` offsets specify BIT or BYTE offsets. If `indexType` is not provided, BYTE offsets
|
|
1189
|
-
* are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
|
|
1190
|
-
* specified, `start=0` and `end=2` means to look at the first three bytes.
|
|
1191
|
-
*
|
|
1192
|
-
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for more details.
|
|
1193
|
-
*
|
|
1194
|
-
* @param key - The key of the string.
|
|
1195
|
-
* @param bit - The bit value to match. Must be `0` or `1`.
|
|
1196
|
-
* @param start - The starting offset.
|
|
1197
|
-
* @param end - The ending offset.
|
|
1198
|
-
* @param indexType - (Optional) The index offset type. This option can only be specified if you are using Valkey
|
|
1199
|
-
* version 7.0.0 or above. Could be either {@link BitmapIndexType.BYTE} or {@link BitmapIndexType.BIT}. If no
|
|
1200
|
-
* index type is provided, the indexes will be assumed to be byte indexes.
|
|
1201
|
-
* @returns The position of the first occurrence from the `start` to the `end` offsets of the `bit` in the binary
|
|
1202
|
-
* value of the string held at `key`.
|
|
1203
1183
|
*
|
|
1204
|
-
* @example
|
|
1205
|
-
* ```typescript
|
|
1206
1184
|
* await client.set("key1", "A12"); // "A12" has binary value 01000001 00110001 00110010
|
|
1207
|
-
* const
|
|
1208
|
-
* console.log(
|
|
1185
|
+
* const result3 = await client.bitpos("key1", 1, { start: 1, end: -1 });
|
|
1186
|
+
* 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.
|
|
1209
1187
|
*
|
|
1210
|
-
* const
|
|
1211
|
-
* console.log(
|
|
1188
|
+
* const result4 = await client.bitpos("key1", 1, { start: 2, end: 9, indexType: BitmapIndexType.BIT });
|
|
1189
|
+
* 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.
|
|
1212
1190
|
* ```
|
|
1213
1191
|
*/
|
|
1214
|
-
|
|
1192
|
+
bitpos(key, bit, options) {
|
|
1215
1193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1216
|
-
return this.createWritePromise((0, Commands_1.createBitPos)(key, bit,
|
|
1194
|
+
return this.createWritePromise((0, Commands_1.createBitPos)(key, bit, options));
|
|
1217
1195
|
});
|
|
1218
1196
|
}
|
|
1219
1197
|
/**
|
|
@@ -2944,7 +2922,7 @@ class BaseClient {
|
|
|
2944
2922
|
keys: (_a = options === null || options === void 0 ? void 0 : options.keys) === null || _a === void 0 ? void 0 : _a.map(Buffer.from),
|
|
2945
2923
|
args: (_b = options === null || options === void 0 ? void 0 : options.args) === null || _b === void 0 ? void 0 : _b.map(Buffer.from),
|
|
2946
2924
|
});
|
|
2947
|
-
return this.
|
|
2925
|
+
return this.createScriptInvocationPromise(scriptInvocation, options);
|
|
2948
2926
|
});
|
|
2949
2927
|
}
|
|
2950
2928
|
/**
|
|
@@ -3468,7 +3446,6 @@ class BaseClient {
|
|
|
3468
3446
|
* @param key - The key of the sorted set.
|
|
3469
3447
|
* @param rangeQuery - The range query object representing the type of range query to perform.
|
|
3470
3448
|
* - For range queries by index (rank), use {@link RangeByIndex}.
|
|
3471
|
-
* - For range queries by lexicographical order, use {@link RangeByLex}.
|
|
3472
3449
|
* - For range queries by score, use {@link RangeByScore}.
|
|
3473
3450
|
* @param options - (Optional) Additional parameters:
|
|
3474
3451
|
* - (Optional) `reverse`: if `true`, reverses the sorted set, with index `0` as the element with the highest score.
|
|
@@ -5329,7 +5306,7 @@ class BaseClient {
|
|
|
5329
5306
|
* @see {@link https://valkey.io/commands/bitcount/|valkey.io} for more details.
|
|
5330
5307
|
*
|
|
5331
5308
|
* @param key - The key for the string to count the set bits of.
|
|
5332
|
-
* @param options - The offset options.
|
|
5309
|
+
* @param options - The offset options - see {@link BitOffsetOptions}.
|
|
5333
5310
|
* @returns If `options` is provided, returns the number of set bits in the string interval specified by `options`.
|
|
5334
5311
|
* If `options` is not provided, returns the number of set bits in the string stored at `key`.
|
|
5335
5312
|
* Otherwise, if `key` is missing, returns `0` as it is treated as an empty string.
|
|
@@ -6300,7 +6277,11 @@ class BaseClient {
|
|
|
6300
6277
|
*/
|
|
6301
6278
|
connectToServer(options) {
|
|
6302
6279
|
return new Promise((resolve, reject) => {
|
|
6303
|
-
this.promiseCallbackFunctions[0] = [
|
|
6280
|
+
this.promiseCallbackFunctions[0] = [
|
|
6281
|
+
resolve,
|
|
6282
|
+
reject,
|
|
6283
|
+
options === null || options === void 0 ? void 0 : options.defaultDecoder,
|
|
6284
|
+
];
|
|
6304
6285
|
const message = ProtobufMessage_1.connection_request.ConnectionRequest.create(this.createClientRequest(options));
|
|
6305
6286
|
this.writeOrBufferRequest(message, (message, writer) => {
|
|
6306
6287
|
ProtobufMessage_1.connection_request.ConnectionRequest.encodeDelimited(message, writer);
|
|
@@ -6390,7 +6371,7 @@ class BaseClient {
|
|
|
6390
6371
|
password,
|
|
6391
6372
|
immediateAuth,
|
|
6392
6373
|
});
|
|
6393
|
-
const response = yield this.
|
|
6374
|
+
const response = yield this.createUpdateConnectionPasswordPromise(updateConnectionPassword);
|
|
6394
6375
|
if (response === "OK" && !((_a = this.config) === null || _a === void 0 ? void 0 : _a.credentials)) {
|
|
6395
6376
|
this.config = Object.assign(Object.assign({}, this.config), { credentials: Object.assign(Object.assign({}, this.config.credentials), { password: password ? password : "" }) });
|
|
6396
6377
|
}
|