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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +31 -95
  2. package/README.md +0 -106
  3. package/build-ts/index.d.ts +0 -14
  4. package/build-ts/index.js +0 -34
  5. package/build-ts/index.js.map +0 -1
  6. package/build-ts/src/BaseClient.d.ts +0 -5254
  7. package/build-ts/src/BaseClient.js +0 -6391
  8. package/build-ts/src/BaseClient.js.map +0 -1
  9. package/build-ts/src/Commands.d.ts +0 -1034
  10. package/build-ts/src/Commands.js +0 -2710
  11. package/build-ts/src/Commands.js.map +0 -1
  12. package/build-ts/src/Errors.d.ts +0 -21
  13. package/build-ts/src/Errors.js +0 -43
  14. package/build-ts/src/Errors.js.map +0 -1
  15. package/build-ts/src/GlideClient.d.ts +0 -832
  16. package/build-ts/src/GlideClient.js +0 -940
  17. package/build-ts/src/GlideClient.js.map +0 -1
  18. package/build-ts/src/GlideClusterClient.d.ts +0 -1323
  19. package/build-ts/src/GlideClusterClient.js +0 -1276
  20. package/build-ts/src/GlideClusterClient.js.map +0 -1
  21. package/build-ts/src/Logger.d.ts +0 -32
  22. package/build-ts/src/Logger.js +0 -68
  23. package/build-ts/src/Logger.js.map +0 -1
  24. package/build-ts/src/ProtobufMessage.d.ts +0 -2889
  25. package/build-ts/src/ProtobufMessage.js +0 -8785
  26. package/build-ts/src/ProtobufMessage.js.map +0 -1
  27. package/build-ts/src/Transaction.d.ts +0 -2963
  28. package/build-ts/src/Transaction.js +0 -3388
  29. package/build-ts/src/Transaction.js.map +0 -1
  30. package/build-ts/src/server-modules/GlideFt.d.ts +0 -412
  31. package/build-ts/src/server-modules/GlideFt.js +0 -664
  32. package/build-ts/src/server-modules/GlideFt.js.map +0 -1
  33. package/build-ts/src/server-modules/GlideFtOptions.d.ts +0 -244
  34. package/build-ts/src/server-modules/GlideFtOptions.js +0 -6
  35. package/build-ts/src/server-modules/GlideFtOptions.js.map +0 -1
  36. package/build-ts/src/server-modules/GlideJson.d.ts +0 -1335
  37. package/build-ts/src/server-modules/GlideJson.js +0 -1628
  38. package/build-ts/src/server-modules/GlideJson.js.map +0 -1
  39. package/index.ts +0 -15
  40. package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
  41. package/node_modules/glide-rs/index.d.ts +0 -71
  42. package/node_modules/glide-rs/index.js +0 -317
  43. package/node_modules/glide-rs/package.json +0 -65
  44. package/npm/glide/index.ts +0 -391
  45. package/npm/glide/package.json +0 -67
@@ -1,940 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
4
- */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.GlideClient = exports.GlideClientConfiguration = void 0;
16
- const BaseClient_1 = require("./BaseClient");
17
- const Commands_1 = require("./Commands");
18
- /* eslint-disable-next-line @typescript-eslint/no-namespace */
19
- var GlideClientConfiguration;
20
- (function (GlideClientConfiguration) {
21
- /**
22
- * Enum representing pubsub subscription modes.
23
- * @see {@link https://valkey.io/docs/topics/pubsub/|Valkey PubSub Documentation} for more details.
24
- */
25
- let PubSubChannelModes;
26
- (function (PubSubChannelModes) {
27
- /**
28
- * Use exact channel names.
29
- */
30
- PubSubChannelModes[PubSubChannelModes["Exact"] = 0] = "Exact";
31
- /**
32
- * Use channel name patterns.
33
- */
34
- PubSubChannelModes[PubSubChannelModes["Pattern"] = 1] = "Pattern";
35
- })(PubSubChannelModes = GlideClientConfiguration.PubSubChannelModes || (GlideClientConfiguration.PubSubChannelModes = {}));
36
- })(GlideClientConfiguration || (exports.GlideClientConfiguration = GlideClientConfiguration = {}));
37
- /**
38
- * Client used for connection to standalone servers.
39
- *
40
- * @see For full documentation refer to {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#standalone|Valkey Glide Wiki}.
41
- */
42
- class GlideClient extends BaseClient_1.BaseClient {
43
- /**
44
- * @internal
45
- */
46
- createClientRequest(options) {
47
- const configuration = super.createClientRequest(options);
48
- configuration.databaseId = options.databaseId;
49
- configuration.connectionRetryStrategy = options.connectionBackoff;
50
- this.configurePubsub(options, configuration);
51
- if (options.advancedConfiguration) {
52
- this.configureAdvancedConfigurationBase(options.advancedConfiguration, configuration);
53
- }
54
- return configuration;
55
- }
56
- /**
57
- * Creates a new `GlideClient` instance and establishes a connection to a standalone Valkey Glide server.
58
- *
59
- * @param options - The configuration options for the client, including server addresses, authentication credentials, TLS settings, database selection, reconnection strategy, and Pub/Sub subscriptions.
60
- * @returns A promise that resolves to a connected `GlideClient` instance.
61
- *
62
- * @remarks
63
- * Use this static method to create and connect a `GlideClient` to a standalone Valkey Glide server. The client will automatically handle connection establishment, including any authentication and TLS configurations.
64
- *
65
- * @example
66
- * ```typescript
67
- * // Connecting to a Standalone Server
68
- * import { GlideClient, GlideClientConfiguration } from '@valkey/valkey-glide';
69
- *
70
- * const client = await GlideClient.createClient({
71
- * addresses: [
72
- * { host: 'primary.example.com', port: 6379 },
73
- * { host: 'replica1.example.com', port: 6379 },
74
- * ],
75
- * databaseId: 1,
76
- * credentials: {
77
- * username: 'user1',
78
- * password: 'passwordA',
79
- * },
80
- * useTLS: true,
81
- * connectionBackoff: {
82
- * numberOfRetries: 5,
83
- * factor: 1000,
84
- * exponentBase: 2,
85
- * },
86
- * pubsubSubscriptions: {
87
- * channelsAndPatterns: {
88
- * [GlideClientConfiguration.PubSubChannelModes.Exact]: new Set(['updates']),
89
- * },
90
- * callback: (msg) => {
91
- * console.log(`Received message: ${msg.payload}`);
92
- * },
93
- * },
94
- * });
95
- * ```
96
- *
97
- * @remarks
98
- * - **Authentication**: If `credentials` are provided, the client will attempt to authenticate using the specified username and password.
99
- * - **TLS**: If `useTLS` is set to `true`, the client will establish a secure connection using TLS.
100
- * - **Reconnection Strategy**: The `connectionBackoff` settings define how the client will attempt to reconnect in case of disconnections.
101
- * - **Pub/Sub Subscriptions**: Any channels or patterns specified in `pubsubSubscriptions` will be subscribed to upon connection.
102
- */
103
- static createClient(options) {
104
- const _super = Object.create(null, {
105
- createClientInternal: { get: () => super.createClientInternal }
106
- });
107
- return __awaiter(this, void 0, void 0, function* () {
108
- return _super.createClientInternal.call(this, options, (socket, options) => new GlideClient(socket, options));
109
- });
110
- }
111
- /**
112
- * @internal
113
- */
114
- static __createClient(options, connectedSocket) {
115
- return __awaiter(this, void 0, void 0, function* () {
116
- return this.__createClientInternal(options, connectedSocket, (socket, options) => new GlideClient(socket, options));
117
- });
118
- }
119
- /**
120
- * Execute a transaction by processing the queued commands.
121
- *
122
- * @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey Glide Wiki} for details on Valkey Transactions.
123
- *
124
- * @param transaction - A {@link Transaction} object containing a list of commands to be executed.
125
- * @param options - (Optional) See {@link DecoderOption}.
126
- * @returns A list of results corresponding to the execution of each command in the transaction.
127
- * If a command returns a value, it will be included in the list. If a command doesn't return a value,
128
- * the list entry will be `null`.
129
- * If the transaction failed due to a `WATCH` command, `exec` will return `null`.
130
- */
131
- exec(transaction, options) {
132
- return __awaiter(this, void 0, void 0, function* () {
133
- return this.createWritePromise(transaction.commands, options).then((result) => this.processResultWithSetCommands(result, transaction.setCommandsIndexes));
134
- });
135
- }
136
- /** Executes a single command, without checking inputs. Every part of the command, including subcommands,
137
- * should be added as a separate value in args.
138
- *
139
- * Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
140
- *
141
- * @see {@link https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command|Valkey Glide Wiki} for details on the restrictions and limitations of the custom command API.
142
- *
143
- * @param args - A list including the command name and arguments for the custom command.
144
- * @param options - (Optional) See {@link DecoderOption}.
145
- * @returns The executed custom command return value.
146
- *
147
- * @example
148
- * ```typescript
149
- * // Example usage of customCommand method to retrieve pub/sub clients
150
- * const result = await client.customCommand(["CLIENT", "LIST", "TYPE", "PUBSUB"]);
151
- * console.log(result); // Output: Returns a list of all pub/sub clients
152
- * ```
153
- */
154
- customCommand(args, options) {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- return this.createWritePromise((0, Commands_1.createCustomCommand)(args), options);
157
- });
158
- }
159
- /**
160
- * Pings the server.
161
- *
162
- * @see {@link https://valkey.io/commands/ping/|valkey.io} for details.
163
- *
164
- * @param options - (Optional) Additional parameters:
165
- * - (Optional) `message` : a message to include in the `PING` command.
166
- * + If not provided, the server will respond with `"PONG"`.
167
- * + If provided, the server will respond with a copy of the message.
168
- * - (Optional) `decoder`: see {@link DecoderOption}.
169
- * @returns `"PONG"` if `message` is not provided, otherwise return a copy of `message`.
170
- *
171
- * @example
172
- * ```typescript
173
- * // Example usage of ping method without any message
174
- * const result = await client.ping();
175
- * console.log(result); // Output: 'PONG'
176
- * ```
177
- *
178
- * @example
179
- * ```typescript
180
- * // Example usage of ping method with a message
181
- * const result = await client.ping("Hello");
182
- * console.log(result); // Output: 'Hello'
183
- * ```
184
- */
185
- ping(options) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- return this.createWritePromise((0, Commands_1.createPing)(options === null || options === void 0 ? void 0 : options.message), options);
188
- });
189
- }
190
- /**
191
- * Gets information and statistics about the server.
192
- *
193
- * @see {@link https://valkey.io/commands/info/|valkey.io} for details.
194
- *
195
- * @param sections - (Optional) A list of {@link InfoOptions} values specifying which sections of information to retrieve.
196
- * When no parameter is provided, {@link InfoOptions.Default|Default} is assumed.
197
- * @returns A string containing the information for the sections requested.
198
- */
199
- info(sections) {
200
- return __awaiter(this, void 0, void 0, function* () {
201
- return this.createWritePromise((0, Commands_1.createInfo)(sections), {
202
- decoder: BaseClient_1.Decoder.String,
203
- });
204
- });
205
- }
206
- /**
207
- * Changes the currently selected database.
208
- *
209
- * @see {@link https://valkey.io/commands/select/|valkey.io} for details.
210
- *
211
- * @param index - The index of the database to select.
212
- * @returns A simple `"OK"` response.
213
- *
214
- * @example
215
- * ```typescript
216
- * // Example usage of select method
217
- * const result = await client.select(2);
218
- * console.log(result); // Output: 'OK'
219
- * ```
220
- */
221
- select(index) {
222
- return __awaiter(this, void 0, void 0, function* () {
223
- return this.createWritePromise((0, Commands_1.createSelect)(index), {
224
- decoder: BaseClient_1.Decoder.String,
225
- });
226
- });
227
- }
228
- /**
229
- * Gets the name of the primary's connection.
230
- *
231
- * @see {@link https://valkey.io/commands/client-getname/|valkey.io} for more details.
232
- *
233
- * @param options - (Optional) See {@link DecoderOption}.
234
- * @returns The name of the client connection as a string if a name is set, or `null` if no name is assigned.
235
- *
236
- * @example
237
- * ```typescript
238
- * // Example usage of client_getname method
239
- * const result = await client.client_getname();
240
- * console.log(result); // Output: 'Client Name'
241
- * ```
242
- */
243
- clientGetName(options) {
244
- return __awaiter(this, void 0, void 0, function* () {
245
- return this.createWritePromise((0, Commands_1.createClientGetName)(), options);
246
- });
247
- }
248
- /**
249
- * Rewrites the configuration file with the current configuration.
250
- *
251
- * @see {@link https://valkey.io/commands/config-rewrite/|valkey.io} for details.
252
- *
253
- * @returns "OK" when the configuration was rewritten properly. Otherwise, an error is thrown.
254
- *
255
- * @example
256
- * ```typescript
257
- * // Example usage of configRewrite command
258
- * const result = await client.configRewrite();
259
- * console.log(result); // Output: 'OK'
260
- * ```
261
- */
262
- configRewrite() {
263
- return __awaiter(this, void 0, void 0, function* () {
264
- return this.createWritePromise((0, Commands_1.createConfigRewrite)(), {
265
- decoder: BaseClient_1.Decoder.String,
266
- });
267
- });
268
- }
269
- /**
270
- * Resets the statistics reported by the server using the `INFO` and `LATENCY HISTOGRAM` commands.
271
- *
272
- * @see {@link https://valkey.io/commands/config-resetstat/|valkey.io} for details.
273
- *
274
- * @returns always "OK".
275
- *
276
- * @example
277
- * ```typescript
278
- * // Example usage of configResetStat command
279
- * const result = await client.configResetStat();
280
- * console.log(result); // Output: 'OK'
281
- * ```
282
- */
283
- configResetStat() {
284
- return __awaiter(this, void 0, void 0, function* () {
285
- return this.createWritePromise((0, Commands_1.createConfigResetStat)(), {
286
- decoder: BaseClient_1.Decoder.String,
287
- });
288
- });
289
- }
290
- /**
291
- * Returns the current connection ID.
292
- *
293
- * @see {@link https://valkey.io/commands/client-id/|valkey.io} for details.
294
- *
295
- * @returns The ID of the connection.
296
- *
297
- * @example
298
- * ```typescript
299
- * const result = await client.clientId();
300
- * console.log("Connection id: " + result);
301
- * ```
302
- */
303
- clientId() {
304
- return __awaiter(this, void 0, void 0, function* () {
305
- return this.createWritePromise((0, Commands_1.createClientId)());
306
- });
307
- }
308
- /**
309
- * Reads the configuration parameters of the running server.
310
- * Starting from server version 7, command supports multiple parameters.
311
- *
312
- * @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
313
- *
314
- * @param parameters - A list of configuration parameter names to retrieve values for.
315
- * @param options - (Optional) See {@link DecoderOption}.
316
- *
317
- * @returns A map of values corresponding to the configuration parameters.
318
- *
319
- * @example
320
- * ```typescript
321
- * // Example usage of configGet method with multiple configuration parameters
322
- * const result = await client.configGet(["timeout", "maxmemory"]);
323
- * console.log(result); // Output: {'timeout': '1000', 'maxmemory': '1GB'}
324
- * ```
325
- */
326
- configGet(parameters, options) {
327
- return __awaiter(this, void 0, void 0, function* () {
328
- return this.createWritePromise((0, Commands_1.createConfigGet)(parameters), options).then(BaseClient_1.convertGlideRecordToRecord);
329
- });
330
- }
331
- /**
332
- * Sets configuration parameters to the specified values.
333
- * Starting from server version 7, command supports multiple parameters.
334
- *
335
- * @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
336
- * @param parameters - A map consisting of configuration parameters and their respective values to set.
337
- * @returns `"OK"` when the configuration was set properly. Otherwise an error is thrown.
338
- *
339
- * @example
340
- * ```typescript
341
- * // Example usage of configSet method to set multiple configuration parameters
342
- * const result = await client.configSet({ timeout: "1000", maxmemory, "1GB" });
343
- * console.log(result); // Output: 'OK'
344
- * ```
345
- */
346
- configSet(parameters) {
347
- return __awaiter(this, void 0, void 0, function* () {
348
- return this.createWritePromise((0, Commands_1.createConfigSet)(parameters), {
349
- decoder: BaseClient_1.Decoder.String,
350
- });
351
- });
352
- }
353
- /**
354
- * Echoes the provided `message` back.
355
- *
356
- * @see {@link https://valkey.io/commands/echo|valkey.io} for more details.
357
- *
358
- * @param message - The message to be echoed back.
359
- * @param options - (Optional) See {@link DecoderOption}.
360
- * @returns The provided `message`.
361
- *
362
- * @example
363
- * ```typescript
364
- * // Example usage of the echo command
365
- * const echoedMessage = await client.echo("valkey-glide");
366
- * console.log(echoedMessage); // Output: 'valkey-glide'
367
- * ```
368
- */
369
- echo(message, options) {
370
- return __awaiter(this, void 0, void 0, function* () {
371
- return this.createWritePromise((0, Commands_1.createEcho)(message), options);
372
- });
373
- }
374
- /**
375
- * Returns the server time.
376
- *
377
- * @see {@link https://valkey.io/commands/time/|valkey.io} for details.
378
- *
379
- * @returns The current server time as an `array` with two items:
380
- * - A Unix timestamp,
381
- * - The amount of microseconds already elapsed in the current second.
382
- *
383
- * @example
384
- * ```typescript
385
- * console.log(await client.time()); // Output: ['1710925775', '913580']
386
- * ```
387
- */
388
- time() {
389
- return __awaiter(this, void 0, void 0, function* () {
390
- return this.createWritePromise((0, Commands_1.createTime)(), {
391
- decoder: BaseClient_1.Decoder.String,
392
- });
393
- });
394
- }
395
- /**
396
- * Copies the value stored at the `source` to the `destination` key. If `destinationDB` is specified,
397
- * the value will be copied to the database specified, otherwise the current database will be used.
398
- * When `replace` is true, removes the `destination` key first if it already exists, otherwise performs
399
- * no action.
400
- *
401
- * @see {@link https://valkey.io/commands/copy/|valkey.io} for more details.
402
- * @remarks Since Valkey version 6.2.0.
403
- *
404
- * @param source - The key to the source value.
405
- * @param destination - The key where the value should be copied to.
406
- * @param options - (Optional) Additional parameters:
407
- * - (Optional) `destinationDB`: the alternative logical database index for the destination key.
408
- * If not provided, the current database will be used.
409
- * - (Optional) `replace`: if `true`, the `destination` key should be removed before copying the
410
- * value to it. If not provided, no action will be performed if the key already exists.
411
- * @returns `true` if `source` was copied, `false` if the `source` was not copied.
412
- *
413
- * @example
414
- * ```typescript
415
- * const result = await client.copy("set1", "set2");
416
- * console.log(result); // Output: true - "set1" was copied to "set2".
417
- * ```
418
- * ```typescript
419
- * const result = await client.copy("set1", "set2", { replace: true });
420
- * console.log(result); // Output: true - "set1" was copied to "set2".
421
- * ```
422
- * ```typescript
423
- * const result = await client.copy("set1", "set2", { destinationDB: 1, replace: false });
424
- * console.log(result); // Output: true - "set1" was copied to "set2".
425
- * ```
426
- */
427
- copy(source, destination, options) {
428
- return __awaiter(this, void 0, void 0, function* () {
429
- return this.createWritePromise((0, Commands_1.createCopy)(source, destination, options));
430
- });
431
- }
432
- /**
433
- * Move `key` from the currently selected database to the database specified by `dbIndex`.
434
- *
435
- * @see {@link https://valkey.io/commands/move/|valkey.io} for more details.
436
- *
437
- * @param key - The key to move.
438
- * @param dbIndex - The index of the database to move `key` to.
439
- * @returns `true` if `key` was moved, or `false` if the `key` already exists in the destination
440
- * database or does not exist in the source database.
441
- *
442
- * @example
443
- * ```typescript
444
- * const result = await client.move("key", 1);
445
- * console.log(result); // Output: true
446
- * ```
447
- */
448
- move(key, dbIndex) {
449
- return __awaiter(this, void 0, void 0, function* () {
450
- return this.createWritePromise((0, Commands_1.createMove)(key, dbIndex));
451
- });
452
- }
453
- /**
454
- * Displays a piece of generative computer art and the server version.
455
- *
456
- * @see {@link https://valkey.io/commands/lolwut/|valkey.io} for more details.
457
- *
458
- * @param options - (Optional) The LOLWUT options - see {@link LolwutOptions}.
459
- * @returns A piece of generative computer art along with the current server version.
460
- *
461
- * @example
462
- * ```typescript
463
- * const response = await client.lolwut({ version: 6, parameters: [40, 20] });
464
- * console.log(response); // Output: "Valkey ver. 7.2.3" - Indicates the current server version.
465
- * ```
466
- */
467
- lolwut(options) {
468
- return __awaiter(this, void 0, void 0, function* () {
469
- return this.createWritePromise((0, Commands_1.createLolwut)(options), {
470
- decoder: BaseClient_1.Decoder.String,
471
- });
472
- });
473
- }
474
- /**
475
- * Deletes a library and all its functions.
476
- *
477
- * @see {@link https://valkey.io/commands/function-delete/|valkey.io} for details.
478
- * @remarks Since Valkey version 7.0.0.
479
- *
480
- * @param libraryCode - The library name to delete.
481
- * @returns A simple `"OK"` response.
482
- *
483
- * @example
484
- * ```typescript
485
- * const result = await client.functionDelete("libName");
486
- * console.log(result); // Output: 'OK'
487
- * ```
488
- */
489
- functionDelete(libraryCode) {
490
- return __awaiter(this, void 0, void 0, function* () {
491
- return this.createWritePromise((0, Commands_1.createFunctionDelete)(libraryCode), {
492
- decoder: BaseClient_1.Decoder.String,
493
- });
494
- });
495
- }
496
- /**
497
- * Loads a library to Valkey.
498
- *
499
- * @see {@link https://valkey.io/commands/function-load/|valkey.io} for details.
500
- * @remarks Since Valkey version 7.0.0.
501
- *
502
- * @param libraryCode - The source code that implements the library.
503
- * @param options - (Optional) Additional parameters:
504
- * - (Optional) `replace`: Whether the given library should overwrite a library with the same name if it
505
- * already exists.
506
- * - (Optional) `decoder`: see {@link DecoderOption}.
507
- * @returns The library name that was loaded.
508
- *
509
- * @example
510
- * ```typescript
511
- * const code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)";
512
- * const result = await client.functionLoad(code, { replace: true });
513
- * console.log(result); // Output: 'mylib'
514
- * ```
515
- */
516
- functionLoad(libraryCode, options) {
517
- return __awaiter(this, void 0, void 0, function* () {
518
- return this.createWritePromise((0, Commands_1.createFunctionLoad)(libraryCode, options === null || options === void 0 ? void 0 : options.replace), options);
519
- });
520
- }
521
- /**
522
- * Deletes all function libraries.
523
- *
524
- * @see {@link https://valkey.io/commands/function-flush/|valkey.io} for details.
525
- * @remarks Since Valkey version 7.0.0.
526
- *
527
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
528
- * @returns A simple `"OK"` response.
529
- *
530
- * @example
531
- * ```typescript
532
- * const result = await client.functionFlush(FlushMode.SYNC);
533
- * console.log(result); // Output: 'OK'
534
- * ```
535
- */
536
- functionFlush(mode) {
537
- return __awaiter(this, void 0, void 0, function* () {
538
- return this.createWritePromise((0, Commands_1.createFunctionFlush)(mode), {
539
- decoder: BaseClient_1.Decoder.String,
540
- });
541
- });
542
- }
543
- /**
544
- * Returns information about the functions and libraries.
545
- *
546
- * @see {@link https://valkey.io/commands/function-list/|valkey.io} for details.
547
- * @remarks Since Valkey version 7.0.0.
548
- *
549
- * @param options - (Optional) See {@link FunctionListOptions} and {@link DecoderOption}.
550
- * @returns Info about all or selected libraries and their functions in {@link FunctionListResponse} format.
551
- *
552
- * @example
553
- * ```typescript
554
- * // Request info for specific library including the source code
555
- * const result1 = await client.functionList({ libNamePattern: "myLib*", withCode: true });
556
- * // Request info for all libraries
557
- * const result2 = await client.functionList();
558
- * console.log(result2); // Output:
559
- * // [{
560
- * // "library_name": "myLib5_backup",
561
- * // "engine": "LUA",
562
- * // "functions": [{
563
- * // "name": "myfunc",
564
- * // "description": null,
565
- * // "flags": [ "no-writes" ],
566
- * // }],
567
- * // "library_code": "#!lua name=myLib5_backup \n redis.register_function('myfunc', function(keys, args) return args[1] end)"
568
- * // }]
569
- * ```
570
- */
571
- functionList(options) {
572
- return __awaiter(this, void 0, void 0, function* () {
573
- return this.createWritePromise((0, Commands_1.createFunctionList)(options), options).then((res) => res.map(BaseClient_1.convertGlideRecordToRecord));
574
- });
575
- }
576
- /**
577
- * Returns information about the function that's currently running and information about the
578
- * available execution engines.
579
- *
580
- * FUNCTION STATS runs on all nodes of the server, including primary and replicas.
581
- * The response includes a mapping from node address to the command response for that node.
582
- *
583
- * @see {@link https://valkey.io/commands/function-stats/|valkey.io} for details.
584
- * @remarks Since Valkey version 7.0.0.
585
- *
586
- * @param options - (Optional) See {@link DecoderOption}.
587
- * @returns A Record where the key is the node address and the value is a Record with two keys:
588
- * - `"running_script"`: Information about the running script, or `null` if no script is running.
589
- * - `"engines"`: Information about available engines and their stats.
590
- * - see example for more details.
591
- * @example
592
- * ```typescript
593
- * const response = await client.functionStats();
594
- * console.log(response); // Example output:
595
- * // {
596
- * // "127.0.0.1:6379": { // Response from the primary node
597
- * // "running_script": {
598
- * // "name": "foo",
599
- * // "command": ["FCALL", "foo", "0", "hello"],
600
- * // "duration_ms": 7758
601
- * // },
602
- * // "engines": {
603
- * // "LUA": {
604
- * // "libraries_count": 1,
605
- * // "functions_count": 1
606
- * // }
607
- * // }
608
- * // },
609
- * // "127.0.0.1:6380": { // Response from a replica node
610
- * // "running_script": null,
611
- * // "engines": {
612
- * // "LUA": {
613
- * // "libraries_count": 1,
614
- * // "functions_count": 1
615
- * // }
616
- * // }
617
- * // }
618
- * // }
619
- * ```
620
- */
621
- functionStats(options) {
622
- return __awaiter(this, void 0, void 0, function* () {
623
- return this.createWritePromise((0, Commands_1.createFunctionStats)(), options).then((res) => (0, BaseClient_1.convertGlideRecordToRecord)(res));
624
- });
625
- }
626
- /**
627
- * Kills a function that is currently executing.
628
- * `FUNCTION KILL` terminates read-only functions only.
629
- * `FUNCTION KILL` runs on all nodes of the server, including primary and replicas.
630
- *
631
- * @see {@link https://valkey.io/commands/function-kill/|valkey.io} for details.
632
- * @remarks Since Valkey version 7.0.0.
633
- *
634
- * @returns `"OK"` if function is terminated. Otherwise, throws an error.
635
- * @example
636
- * ```typescript
637
- * await client.functionKill();
638
- * ```
639
- */
640
- functionKill() {
641
- return __awaiter(this, void 0, void 0, function* () {
642
- return this.createWritePromise((0, Commands_1.createFunctionKill)(), {
643
- decoder: BaseClient_1.Decoder.String,
644
- });
645
- });
646
- }
647
- /**
648
- * Returns the serialized payload of all loaded libraries.
649
- *
650
- * @see {@link https://valkey.io/commands/function-dump/|valkey.io} for details.
651
- * @remarks Since Valkey version 7.0.0.
652
- *
653
- * @returns The serialized payload of all loaded libraries.
654
- *
655
- * @example
656
- * ```typescript
657
- * const data = await client.functionDump();
658
- * // data can be used to restore loaded functions on any Valkey instance
659
- * ```
660
- */
661
- functionDump() {
662
- return __awaiter(this, void 0, void 0, function* () {
663
- return this.createWritePromise((0, Commands_1.createFunctionDump)(), {
664
- decoder: BaseClient_1.Decoder.Bytes,
665
- });
666
- });
667
- }
668
- /**
669
- * Restores libraries from the serialized payload returned by {@link functionDump}.
670
- *
671
- * @see {@link https://valkey.io/commands/function-restore/|valkey.io} for details.
672
- * @remarks Since Valkey version 7.0.0.
673
- *
674
- * @param payload - The serialized data from {@link functionDump}.
675
- * @param policy - (Optional) A policy for handling existing libraries, see {@link FunctionRestorePolicy}.
676
- * {@link FunctionRestorePolicy.APPEND} is used by default.
677
- * @returns `"OK"`.
678
- *
679
- * @example
680
- * ```typescript
681
- * await client.functionRestore(data, FunctionRestorePolicy.FLUSH);
682
- * ```
683
- */
684
- functionRestore(payload, policy) {
685
- return __awaiter(this, void 0, void 0, function* () {
686
- return this.createWritePromise((0, Commands_1.createFunctionRestore)(payload, policy), {
687
- decoder: BaseClient_1.Decoder.String,
688
- });
689
- });
690
- }
691
- /**
692
- * Deletes all the keys of all the existing databases. This command never fails.
693
- *
694
- * @see {@link https://valkey.io/commands/flushall/|valkey.io} for more details.
695
- *
696
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
697
- * @returns `"OK"`.
698
- *
699
- * @example
700
- * ```typescript
701
- * const result = await client.flushall(FlushMode.SYNC);
702
- * console.log(result); // Output: 'OK'
703
- * ```
704
- */
705
- flushall(mode) {
706
- return __awaiter(this, void 0, void 0, function* () {
707
- return this.createWritePromise((0, Commands_1.createFlushAll)(mode), {
708
- decoder: BaseClient_1.Decoder.String,
709
- });
710
- });
711
- }
712
- /**
713
- * Deletes all the keys of the currently selected database. This command never fails.
714
- *
715
- * @see {@link https://valkey.io/commands/flushdb/|valkey.io} for more details.
716
- *
717
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
718
- * @returns `"OK"`.
719
- *
720
- * @example
721
- * ```typescript
722
- * const result = await client.flushdb(FlushMode.SYNC);
723
- * console.log(result); // Output: 'OK'
724
- * ```
725
- */
726
- flushdb(mode) {
727
- return __awaiter(this, void 0, void 0, function* () {
728
- return this.createWritePromise((0, Commands_1.createFlushDB)(mode), {
729
- decoder: BaseClient_1.Decoder.String,
730
- });
731
- });
732
- }
733
- /**
734
- * Returns the number of keys in the currently selected database.
735
- *
736
- * @see {@link https://valkey.io/commands/dbsize/|valkey.io} for more details.
737
- *
738
- * @returns The number of keys in the currently selected database.
739
- *
740
- * @example
741
- * ```typescript
742
- * const numKeys = await client.dbsize();
743
- * console.log("Number of keys in the current database: ", numKeys);
744
- * ```
745
- */
746
- dbsize() {
747
- return __awaiter(this, void 0, void 0, function* () {
748
- return this.createWritePromise((0, Commands_1.createDBSize)());
749
- });
750
- }
751
- /** Publish a message on pubsub channel.
752
- *
753
- * @see {@link https://valkey.io/commands/publish/|valkey.io} for more details.
754
- *
755
- * @param message - Message to publish.
756
- * @param channel - Channel to publish the message on.
757
- * @returns - Number of subscriptions in primary node that received the message.
758
- * Note that this value does not include subscriptions that configured on replicas.
759
- *
760
- * @example
761
- * ```typescript
762
- * // Example usage of publish command
763
- * const result = await client.publish("Hi all!", "global-channel");
764
- * console.log(result); // Output: 1 - This message was posted to 1 subscription which is configured on primary node
765
- * ```
766
- */
767
- publish(message, channel) {
768
- return __awaiter(this, void 0, void 0, function* () {
769
- return this.createWritePromise((0, Commands_1.createPublish)(message, channel));
770
- });
771
- }
772
- /**
773
- * Returns `UNIX TIME` of the last DB save timestamp or startup timestamp if no save
774
- * was made since then.
775
- *
776
- * @see {@link https://valkey.io/commands/lastsave/|valkey.io} for more details.
777
- *
778
- * @returns `UNIX TIME` of the last DB save executed with success.
779
- *
780
- * @example
781
- * ```typescript
782
- * const timestamp = await client.lastsave();
783
- * console.log("Last DB save was done at " + timestamp);
784
- * ```
785
- */
786
- lastsave() {
787
- return __awaiter(this, void 0, void 0, function* () {
788
- return this.createWritePromise((0, Commands_1.createLastSave)());
789
- });
790
- }
791
- /**
792
- * Returns a random existing key name from the currently selected database.
793
- *
794
- * @see {@link https://valkey.io/commands/randomkey/|valkey.io} for more details.
795
- * @param options - (Optional) See {@link DecoderOption}.
796
- * @returns A random existing key name from the currently selected database.
797
- *
798
- * @example
799
- * ```typescript
800
- * const result = await client.randomKey();
801
- * console.log(result); // Output: "key12" - "key12" is a random existing key name from the currently selected database.
802
- * ```
803
- */
804
- randomKey(options) {
805
- return __awaiter(this, void 0, void 0, function* () {
806
- return this.createWritePromise((0, Commands_1.createRandomKey)(), options);
807
- });
808
- }
809
- /**
810
- * Flushes all the previously watched keys for a transaction. Executing a transaction will
811
- * automatically flush all previously watched keys.
812
- *
813
- * @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey Glide Wiki} for more details.
814
- *
815
- * @returns A simple `"OK"` response.
816
- *
817
- * @example
818
- * ```typescript
819
- * let response = await client.watch(["sampleKey"]);
820
- * console.log(response); // Output: "OK"
821
- * response = await client.unwatch();
822
- * console.log(response); // Output: "OK"
823
- * ```
824
- */
825
- unwatch() {
826
- return __awaiter(this, void 0, void 0, function* () {
827
- return this.createWritePromise((0, Commands_1.createUnWatch)(), {
828
- decoder: BaseClient_1.Decoder.String,
829
- });
830
- });
831
- }
832
- /**
833
- * Checks existence of scripts in the script cache by their SHA1 digest.
834
- *
835
- * @see {@link https://valkey.io/commands/script-exists/|valkey.io} for more details.
836
- *
837
- * @param sha1s - List of SHA1 digests of the scripts to check.
838
- * @returns A list of boolean values indicating the existence of each script.
839
- *
840
- * @example
841
- * ```typescript
842
- * console result = await client.scriptExists(["sha1_digest1", "sha1_digest2"]);
843
- * console.log(result); // Output: [true, false]
844
- * ```
845
- */
846
- scriptExists(sha1s) {
847
- return __awaiter(this, void 0, void 0, function* () {
848
- return this.createWritePromise((0, Commands_1.createScriptExists)(sha1s));
849
- });
850
- }
851
- /**
852
- * Flushes the Lua scripts cache.
853
- *
854
- * @see {@link https://valkey.io/commands/script-flush/|valkey.io} for more details.
855
- *
856
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
857
- * @returns A simple `"OK"` response.
858
- *
859
- * @example
860
- * ```typescript
861
- * console result = await client.scriptFlush(FlushMode.SYNC);
862
- * console.log(result); // Output: "OK"
863
- * ```
864
- */
865
- scriptFlush(mode) {
866
- return __awaiter(this, void 0, void 0, function* () {
867
- return this.createWritePromise((0, Commands_1.createScriptFlush)(mode), {
868
- decoder: BaseClient_1.Decoder.String,
869
- });
870
- });
871
- }
872
- /**
873
- * Kills the currently executing Lua script, assuming no write operation was yet performed by the script.
874
- *
875
- * @see {@link https://valkey.io/commands/script-kill/|valkey.io} for more details.
876
- *
877
- * @returns A simple `"OK"` response.
878
- *
879
- * @example
880
- * ```typescript
881
- * console result = await client.scriptKill();
882
- * console.log(result); // Output: "OK"
883
- * ```
884
- */
885
- scriptKill() {
886
- return __awaiter(this, void 0, void 0, function* () {
887
- return this.createWritePromise((0, Commands_1.createScriptKill)(), {
888
- decoder: BaseClient_1.Decoder.String,
889
- });
890
- });
891
- }
892
- /**
893
- * Incrementally iterate over a collection of keys.
894
- * `SCAN` is a cursor based iterator. This means that at every call of the method,
895
- * the server returns an updated cursor that the user needs to use as the cursor argument in the next call.
896
- * An iteration starts when the cursor is set to "0", and terminates when the cursor returned by the server is "0".
897
- *
898
- * A full iteration always retrieves all the elements that were present
899
- * in the collection from the start to the end of a full iteration.
900
- * Elements that were not constantly present in the collection during a full iteration, may be returned or not.
901
- *
902
- * @see {@link https://valkey.io/commands/scan|valkey.io} for more details.
903
- *
904
- * @param cursor - The `cursor` used for iteration. For the first iteration, the cursor should be set to "0".
905
- * Using a non-zero cursor in the first iteration,
906
- * or an invalid cursor at any iteration, will lead to undefined results.
907
- * Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
908
- * return the same elements multiple times.
909
- * If the the db has changed, it may result in undefined behavior.
910
- * @param options - (Optional) The options to use for the scan operation, see {@link ScanOptions} and {@link DecoderOption}.
911
- * @returns A List containing the next cursor value and a list of keys,
912
- * formatted as [cursor, [key1, key2, ...]]
913
- *
914
- * @example
915
- * ```typescript
916
- * // Example usage of scan method
917
- * let result = await client.scan('0');
918
- * console.log(result); // Output: ['17', ['key1', 'key2', 'key3', 'key4', 'key5', 'set1', 'set2', 'set3']]
919
- * let firstCursorResult = result[0];
920
- * result = await client.scan(firstCursorResult);
921
- * console.log(result); // Output: ['349', ['key4', 'key5', 'set1', 'hash1', 'zset1', 'list1', 'list2',
922
- * // 'list3', 'zset2', 'zset3', 'zset4', 'zset5', 'zset6']]
923
- * result = await client.scan(result[0]);
924
- * console.log(result); // Output: ['0', ['key6', 'key7']]
925
- *
926
- * result = await client.scan(firstCursorResult, {match: 'key*', count: 2});
927
- * console.log(result); // Output: ['6', ['key4', 'key5']]
928
- *
929
- * result = await client.scan("0", {type: ObjectType.Set});
930
- * console.log(result); // Output: ['362', ['set1', 'set2', 'set3']]
931
- * ```
932
- */
933
- scan(cursor, options) {
934
- return __awaiter(this, void 0, void 0, function* () {
935
- return this.createWritePromise((0, Commands_1.createScan)(cursor, options), options);
936
- });
937
- }
938
- }
939
- exports.GlideClient = GlideClient;
940
- //# sourceMappingURL=GlideClient.js.map