@valkey/valkey-glide-darwin-x64 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.
- package/package.json +31 -95
- package/README.md +0 -106
- package/build-ts/index.d.ts +0 -14
- package/build-ts/index.js +0 -34
- package/build-ts/index.js.map +0 -1
- package/build-ts/src/BaseClient.d.ts +0 -5254
- package/build-ts/src/BaseClient.js +0 -6391
- package/build-ts/src/BaseClient.js.map +0 -1
- package/build-ts/src/Commands.d.ts +0 -1034
- package/build-ts/src/Commands.js +0 -2710
- package/build-ts/src/Commands.js.map +0 -1
- package/build-ts/src/Errors.d.ts +0 -21
- package/build-ts/src/Errors.js +0 -43
- package/build-ts/src/Errors.js.map +0 -1
- package/build-ts/src/GlideClient.d.ts +0 -832
- package/build-ts/src/GlideClient.js +0 -940
- package/build-ts/src/GlideClient.js.map +0 -1
- package/build-ts/src/GlideClusterClient.d.ts +0 -1323
- package/build-ts/src/GlideClusterClient.js +0 -1276
- package/build-ts/src/GlideClusterClient.js.map +0 -1
- package/build-ts/src/Logger.d.ts +0 -32
- package/build-ts/src/Logger.js +0 -68
- package/build-ts/src/Logger.js.map +0 -1
- package/build-ts/src/ProtobufMessage.d.ts +0 -2889
- package/build-ts/src/ProtobufMessage.js +0 -8785
- package/build-ts/src/ProtobufMessage.js.map +0 -1
- package/build-ts/src/Transaction.d.ts +0 -2963
- package/build-ts/src/Transaction.js +0 -3388
- package/build-ts/src/Transaction.js.map +0 -1
- package/build-ts/src/server-modules/GlideFt.d.ts +0 -412
- package/build-ts/src/server-modules/GlideFt.js +0 -664
- package/build-ts/src/server-modules/GlideFt.js.map +0 -1
- package/build-ts/src/server-modules/GlideFtOptions.d.ts +0 -244
- package/build-ts/src/server-modules/GlideFtOptions.js +0 -6
- package/build-ts/src/server-modules/GlideFtOptions.js.map +0 -1
- package/build-ts/src/server-modules/GlideJson.d.ts +0 -1335
- package/build-ts/src/server-modules/GlideJson.js +0 -1628
- package/build-ts/src/server-modules/GlideJson.js.map +0 -1
- package/index.ts +0 -15
- package/node_modules/glide-rs/glide-rs.darwin-x64.node +0 -0
- package/node_modules/glide-rs/index.d.ts +0 -71
- package/node_modules/glide-rs/index.js +0 -317
- package/node_modules/glide-rs/package.json +0 -65
- package/npm/glide/index.ts +0 -391
- package/npm/glide/package.json +0 -67
package/build-ts/src/Commands.js
DELETED
|
@@ -1,2710 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.TimeUnit = exports.ScoreFilter = exports.SortOrder = exports.GeoUnit = exports.ConditionalChange = exports.FlushMode = exports.BitmapIndexType = exports.FunctionRestorePolicy = exports.InsertPosition = exports.InfBoundary = exports.UpdateByScore = exports.ExpireOptions = exports.ListDirection = exports.BitFieldOverflow = exports.BitOverflowControl = exports.BitFieldIncrBy = exports.BitFieldSet = exports.BitFieldGet = exports.BitOffsetMultiplier = exports.BitOffset = exports.UnsignedEncoding = exports.SignedEncoding = exports.BitwiseOperation = exports.InfoOptions = void 0;
|
|
10
|
-
exports.parseInfoResponse = parseInfoResponse;
|
|
11
|
-
exports.createGet = createGet;
|
|
12
|
-
exports.createGetDel = createGetDel;
|
|
13
|
-
exports.createGetRange = createGetRange;
|
|
14
|
-
exports.createSet = createSet;
|
|
15
|
-
exports.createPing = createPing;
|
|
16
|
-
exports.createInfo = createInfo;
|
|
17
|
-
exports.createDel = createDel;
|
|
18
|
-
exports.createSelect = createSelect;
|
|
19
|
-
exports.createClientGetName = createClientGetName;
|
|
20
|
-
exports.createConfigRewrite = createConfigRewrite;
|
|
21
|
-
exports.createConfigResetStat = createConfigResetStat;
|
|
22
|
-
exports.createMGet = createMGet;
|
|
23
|
-
exports.createMSet = createMSet;
|
|
24
|
-
exports.createMSetNX = createMSetNX;
|
|
25
|
-
exports.createIncr = createIncr;
|
|
26
|
-
exports.createIncrBy = createIncrBy;
|
|
27
|
-
exports.createIncrByFloat = createIncrByFloat;
|
|
28
|
-
exports.createClientId = createClientId;
|
|
29
|
-
exports.createConfigGet = createConfigGet;
|
|
30
|
-
exports.createConfigSet = createConfigSet;
|
|
31
|
-
exports.createHGet = createHGet;
|
|
32
|
-
exports.convertFieldsAndValuesToHashDataType = convertFieldsAndValuesToHashDataType;
|
|
33
|
-
exports.createHSet = createHSet;
|
|
34
|
-
exports.createHKeys = createHKeys;
|
|
35
|
-
exports.createHSetNX = createHSetNX;
|
|
36
|
-
exports.createDecr = createDecr;
|
|
37
|
-
exports.createDecrBy = createDecrBy;
|
|
38
|
-
exports.createBitOp = createBitOp;
|
|
39
|
-
exports.createGetBit = createGetBit;
|
|
40
|
-
exports.createSetBit = createSetBit;
|
|
41
|
-
exports.createBitField = createBitField;
|
|
42
|
-
exports.createHDel = createHDel;
|
|
43
|
-
exports.createHMGet = createHMGet;
|
|
44
|
-
exports.createHExists = createHExists;
|
|
45
|
-
exports.createHGetAll = createHGetAll;
|
|
46
|
-
exports.createLPush = createLPush;
|
|
47
|
-
exports.createLPushX = createLPushX;
|
|
48
|
-
exports.createLPop = createLPop;
|
|
49
|
-
exports.createLRange = createLRange;
|
|
50
|
-
exports.createLLen = createLLen;
|
|
51
|
-
exports.createLMove = createLMove;
|
|
52
|
-
exports.createBLMove = createBLMove;
|
|
53
|
-
exports.createLSet = createLSet;
|
|
54
|
-
exports.createLTrim = createLTrim;
|
|
55
|
-
exports.createLRem = createLRem;
|
|
56
|
-
exports.createRPush = createRPush;
|
|
57
|
-
exports.createRPushX = createRPushX;
|
|
58
|
-
exports.createRPop = createRPop;
|
|
59
|
-
exports.createSAdd = createSAdd;
|
|
60
|
-
exports.createSRem = createSRem;
|
|
61
|
-
exports.createSScan = createSScan;
|
|
62
|
-
exports.createSMembers = createSMembers;
|
|
63
|
-
exports.createSMove = createSMove;
|
|
64
|
-
exports.createSCard = createSCard;
|
|
65
|
-
exports.createSInter = createSInter;
|
|
66
|
-
exports.createSInterCard = createSInterCard;
|
|
67
|
-
exports.createSInterStore = createSInterStore;
|
|
68
|
-
exports.createSDiff = createSDiff;
|
|
69
|
-
exports.createSDiffStore = createSDiffStore;
|
|
70
|
-
exports.createSUnion = createSUnion;
|
|
71
|
-
exports.createSUnionStore = createSUnionStore;
|
|
72
|
-
exports.createSIsMember = createSIsMember;
|
|
73
|
-
exports.createSMIsMember = createSMIsMember;
|
|
74
|
-
exports.createSPop = createSPop;
|
|
75
|
-
exports.createSRandMember = createSRandMember;
|
|
76
|
-
exports.createCustomCommand = createCustomCommand;
|
|
77
|
-
exports.createHIncrBy = createHIncrBy;
|
|
78
|
-
exports.createHIncrByFloat = createHIncrByFloat;
|
|
79
|
-
exports.createHLen = createHLen;
|
|
80
|
-
exports.createHVals = createHVals;
|
|
81
|
-
exports.createExists = createExists;
|
|
82
|
-
exports.createUnlink = createUnlink;
|
|
83
|
-
exports.createExpire = createExpire;
|
|
84
|
-
exports.createExpireAt = createExpireAt;
|
|
85
|
-
exports.createExpireTime = createExpireTime;
|
|
86
|
-
exports.createPExpire = createPExpire;
|
|
87
|
-
exports.createPExpireAt = createPExpireAt;
|
|
88
|
-
exports.createPExpireTime = createPExpireTime;
|
|
89
|
-
exports.createTTL = createTTL;
|
|
90
|
-
exports.convertElementsAndScores = convertElementsAndScores;
|
|
91
|
-
exports.createZAdd = createZAdd;
|
|
92
|
-
exports.createZInterstore = createZInterstore;
|
|
93
|
-
exports.createZInter = createZInter;
|
|
94
|
-
exports.createZUnion = createZUnion;
|
|
95
|
-
exports.createZRem = createZRem;
|
|
96
|
-
exports.createZCard = createZCard;
|
|
97
|
-
exports.createZInterCard = createZInterCard;
|
|
98
|
-
exports.createZDiff = createZDiff;
|
|
99
|
-
exports.createZDiffWithScores = createZDiffWithScores;
|
|
100
|
-
exports.createZDiffStore = createZDiffStore;
|
|
101
|
-
exports.createZScore = createZScore;
|
|
102
|
-
exports.createZUnionStore = createZUnionStore;
|
|
103
|
-
exports.createZMScore = createZMScore;
|
|
104
|
-
exports.createScan = createScan;
|
|
105
|
-
exports.createZCount = createZCount;
|
|
106
|
-
exports.createZRange = createZRange;
|
|
107
|
-
exports.createZRangeWithScores = createZRangeWithScores;
|
|
108
|
-
exports.createZRangeStore = createZRangeStore;
|
|
109
|
-
exports.createType = createType;
|
|
110
|
-
exports.createStrlen = createStrlen;
|
|
111
|
-
exports.createLIndex = createLIndex;
|
|
112
|
-
exports.createLInsert = createLInsert;
|
|
113
|
-
exports.createZPopMin = createZPopMin;
|
|
114
|
-
exports.createZPopMax = createZPopMax;
|
|
115
|
-
exports.createEcho = createEcho;
|
|
116
|
-
exports.createPTTL = createPTTL;
|
|
117
|
-
exports.createZRemRangeByRank = createZRemRangeByRank;
|
|
118
|
-
exports.createZRemRangeByLex = createZRemRangeByLex;
|
|
119
|
-
exports.createZRemRangeByScore = createZRemRangeByScore;
|
|
120
|
-
exports.createPersist = createPersist;
|
|
121
|
-
exports.createZLexCount = createZLexCount;
|
|
122
|
-
exports.createZRank = createZRank;
|
|
123
|
-
exports.createXAdd = createXAdd;
|
|
124
|
-
exports.createXDel = createXDel;
|
|
125
|
-
exports.createXTrim = createXTrim;
|
|
126
|
-
exports.createXRange = createXRange;
|
|
127
|
-
exports.createXRevRange = createXRevRange;
|
|
128
|
-
exports.createXGroupCreateConsumer = createXGroupCreateConsumer;
|
|
129
|
-
exports.createXGroupDelConsumer = createXGroupDelConsumer;
|
|
130
|
-
exports.createTime = createTime;
|
|
131
|
-
exports.createPublish = createPublish;
|
|
132
|
-
exports.createBRPop = createBRPop;
|
|
133
|
-
exports.createBLPop = createBLPop;
|
|
134
|
-
exports.createFCall = createFCall;
|
|
135
|
-
exports.createFCallReadOnly = createFCallReadOnly;
|
|
136
|
-
exports.createFunctionDelete = createFunctionDelete;
|
|
137
|
-
exports.createFunctionFlush = createFunctionFlush;
|
|
138
|
-
exports.createFunctionLoad = createFunctionLoad;
|
|
139
|
-
exports.createFunctionList = createFunctionList;
|
|
140
|
-
exports.createFunctionStats = createFunctionStats;
|
|
141
|
-
exports.createFunctionKill = createFunctionKill;
|
|
142
|
-
exports.createFunctionDump = createFunctionDump;
|
|
143
|
-
exports.createFunctionRestore = createFunctionRestore;
|
|
144
|
-
exports.createBitCount = createBitCount;
|
|
145
|
-
exports.createBitPos = createBitPos;
|
|
146
|
-
exports.convertKeysAndEntries = convertKeysAndEntries;
|
|
147
|
-
exports.createXRead = createXRead;
|
|
148
|
-
exports.createXReadGroup = createXReadGroup;
|
|
149
|
-
exports.createXInfoStream = createXInfoStream;
|
|
150
|
-
exports.createXInfoGroups = createXInfoGroups;
|
|
151
|
-
exports.createXLen = createXLen;
|
|
152
|
-
exports.createXPending = createXPending;
|
|
153
|
-
exports.createXInfoConsumers = createXInfoConsumers;
|
|
154
|
-
exports.createXClaim = createXClaim;
|
|
155
|
-
exports.createXAutoClaim = createXAutoClaim;
|
|
156
|
-
exports.createXGroupCreate = createXGroupCreate;
|
|
157
|
-
exports.createXGroupDestroy = createXGroupDestroy;
|
|
158
|
-
exports.createRename = createRename;
|
|
159
|
-
exports.createRenameNX = createRenameNX;
|
|
160
|
-
exports.createPfAdd = createPfAdd;
|
|
161
|
-
exports.createPfCount = createPfCount;
|
|
162
|
-
exports.createPfMerge = createPfMerge;
|
|
163
|
-
exports.createObjectEncoding = createObjectEncoding;
|
|
164
|
-
exports.createObjectFreq = createObjectFreq;
|
|
165
|
-
exports.createObjectIdletime = createObjectIdletime;
|
|
166
|
-
exports.createObjectRefcount = createObjectRefcount;
|
|
167
|
-
exports.createLolwut = createLolwut;
|
|
168
|
-
exports.createFlushAll = createFlushAll;
|
|
169
|
-
exports.createFlushDB = createFlushDB;
|
|
170
|
-
exports.createCopy = createCopy;
|
|
171
|
-
exports.createMove = createMove;
|
|
172
|
-
exports.createDump = createDump;
|
|
173
|
-
exports.createRestore = createRestore;
|
|
174
|
-
exports.createLPos = createLPos;
|
|
175
|
-
exports.createDBSize = createDBSize;
|
|
176
|
-
exports.createGeoAdd = createGeoAdd;
|
|
177
|
-
exports.createGeoPos = createGeoPos;
|
|
178
|
-
exports.createGeoDist = createGeoDist;
|
|
179
|
-
exports.createGeoHash = createGeoHash;
|
|
180
|
-
exports.createGeoSearch = createGeoSearch;
|
|
181
|
-
exports.createGeoSearchStore = createGeoSearchStore;
|
|
182
|
-
exports.createZRevRank = createZRevRank;
|
|
183
|
-
exports.createZRevRankWithScore = createZRevRankWithScore;
|
|
184
|
-
exports.createZMPop = createZMPop;
|
|
185
|
-
exports.createBZMPop = createBZMPop;
|
|
186
|
-
exports.createZIncrBy = createZIncrBy;
|
|
187
|
-
exports.createSort = createSort;
|
|
188
|
-
exports.createSortReadOnly = createSortReadOnly;
|
|
189
|
-
exports.createHStrlen = createHStrlen;
|
|
190
|
-
exports.createHRandField = createHRandField;
|
|
191
|
-
exports.createHScan = createHScan;
|
|
192
|
-
exports.createZRandMember = createZRandMember;
|
|
193
|
-
exports.createLastSave = createLastSave;
|
|
194
|
-
exports.createLCS = createLCS;
|
|
195
|
-
exports.createTouch = createTouch;
|
|
196
|
-
exports.createRandomKey = createRandomKey;
|
|
197
|
-
exports.createWatch = createWatch;
|
|
198
|
-
exports.createUnWatch = createUnWatch;
|
|
199
|
-
exports.createWait = createWait;
|
|
200
|
-
exports.createZScan = createZScan;
|
|
201
|
-
exports.createSetRange = createSetRange;
|
|
202
|
-
exports.createAppend = createAppend;
|
|
203
|
-
exports.createLMPop = createLMPop;
|
|
204
|
-
exports.createBLMPop = createBLMPop;
|
|
205
|
-
exports.createPubSubChannels = createPubSubChannels;
|
|
206
|
-
exports.createPubSubNumPat = createPubSubNumPat;
|
|
207
|
-
exports.createPubSubNumSub = createPubSubNumSub;
|
|
208
|
-
exports.createPubsubShardChannels = createPubsubShardChannels;
|
|
209
|
-
exports.createPubSubShardNumSub = createPubSubShardNumSub;
|
|
210
|
-
exports.createBZPopMax = createBZPopMax;
|
|
211
|
-
exports.createBZPopMin = createBZPopMin;
|
|
212
|
-
exports.createScriptShow = createScriptShow;
|
|
213
|
-
exports.createGetEx = createGetEx;
|
|
214
|
-
exports.createXAck = createXAck;
|
|
215
|
-
exports.createXGroupSetid = createXGroupSetid;
|
|
216
|
-
exports.createScriptExists = createScriptExists;
|
|
217
|
-
exports.createScriptFlush = createScriptFlush;
|
|
218
|
-
exports.createScriptKill = createScriptKill;
|
|
219
|
-
const glide_rs_1 = require("glide-rs");
|
|
220
|
-
const long_1 = __importDefault(require("long"));
|
|
221
|
-
const BaseClient_1 = require("./BaseClient");
|
|
222
|
-
const ProtobufMessage_1 = require("./ProtobufMessage");
|
|
223
|
-
var RequestType = ProtobufMessage_1.command_request.RequestType;
|
|
224
|
-
function isLargeCommand(args) {
|
|
225
|
-
let lenSum = 0;
|
|
226
|
-
for (const arg of args) {
|
|
227
|
-
lenSum += arg.length;
|
|
228
|
-
if (lenSum >= glide_rs_1.MAX_REQUEST_ARGS_LEN) {
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Convert a string array into Uint8Array[]
|
|
236
|
-
*/
|
|
237
|
-
function toBuffersArray(args) {
|
|
238
|
-
const argsBytes = [];
|
|
239
|
-
for (const arg of args) {
|
|
240
|
-
if (typeof arg == "string") {
|
|
241
|
-
argsBytes.push(Buffer.from(arg));
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
argsBytes.push(arg);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return argsBytes;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
252
|
-
function parseInfoResponse(response) {
|
|
253
|
-
const lines = response.split("\n");
|
|
254
|
-
const parsedResponse = {};
|
|
255
|
-
for (const line of lines) {
|
|
256
|
-
// Ignore lines that start with '#'
|
|
257
|
-
if (!line.startsWith("#")) {
|
|
258
|
-
const [key, value] = line.trim().split(":");
|
|
259
|
-
parsedResponse[key] = value;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return parsedResponse;
|
|
263
|
-
}
|
|
264
|
-
function createCommand(requestType, args) {
|
|
265
|
-
const singleCommand = ProtobufMessage_1.command_request.Command.create({
|
|
266
|
-
requestType,
|
|
267
|
-
});
|
|
268
|
-
const argsBytes = toBuffersArray(args);
|
|
269
|
-
if (isLargeCommand(args)) {
|
|
270
|
-
// pass as a pointer
|
|
271
|
-
const pointerArr = (0, glide_rs_1.createLeakedStringVec)(argsBytes);
|
|
272
|
-
const pointer = new long_1.default(pointerArr[0], pointerArr[1]);
|
|
273
|
-
singleCommand.argsVecPointer = pointer;
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
singleCommand.argsArray = ProtobufMessage_1.command_request.Command.ArgsArray.create({
|
|
277
|
-
args: argsBytes,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
return singleCommand;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* @internal
|
|
284
|
-
*/
|
|
285
|
-
function createGet(key) {
|
|
286
|
-
return createCommand(RequestType.Get, [key]);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* @internal
|
|
290
|
-
*/
|
|
291
|
-
function createGetDel(key) {
|
|
292
|
-
return createCommand(RequestType.GetDel, [key]);
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* @internal
|
|
296
|
-
*/
|
|
297
|
-
function createGetRange(key, start, end) {
|
|
298
|
-
return createCommand(RequestType.GetRange, [
|
|
299
|
-
key,
|
|
300
|
-
start.toString(),
|
|
301
|
-
end.toString(),
|
|
302
|
-
]);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* @internal
|
|
306
|
-
*/
|
|
307
|
-
function createSet(key, value, options) {
|
|
308
|
-
const args = [key, value];
|
|
309
|
-
if (options) {
|
|
310
|
-
if (options.conditionalSet === "onlyIfExists") {
|
|
311
|
-
args.push("XX");
|
|
312
|
-
}
|
|
313
|
-
else if (options.conditionalSet === "onlyIfDoesNotExist") {
|
|
314
|
-
args.push("NX");
|
|
315
|
-
}
|
|
316
|
-
else if (options.conditionalSet === "onlyIfEqual") {
|
|
317
|
-
args.push("IFEQ", options.comparisonValue);
|
|
318
|
-
}
|
|
319
|
-
if (options.returnOldValue) {
|
|
320
|
-
args.push("GET");
|
|
321
|
-
}
|
|
322
|
-
if (options.expiry) {
|
|
323
|
-
if (options.expiry !== "keepExisting" &&
|
|
324
|
-
!Number.isInteger(options.expiry.count)) {
|
|
325
|
-
throw new Error(`Received expiry '${JSON.stringify(options.expiry)}'. Count must be an integer`);
|
|
326
|
-
}
|
|
327
|
-
if (options.expiry === "keepExisting") {
|
|
328
|
-
args.push("KEEPTTL");
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
args.push(options.expiry.type, options.expiry.count.toString());
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return createCommand(RequestType.Set, args);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* INFO option: a specific section of information:
|
|
339
|
-
* When no parameter is provided, the default option is assumed.
|
|
340
|
-
*/
|
|
341
|
-
var InfoOptions;
|
|
342
|
-
(function (InfoOptions) {
|
|
343
|
-
/**
|
|
344
|
-
* SERVER: General information about the server
|
|
345
|
-
*/
|
|
346
|
-
InfoOptions["Server"] = "server";
|
|
347
|
-
/**
|
|
348
|
-
* CLIENTS: Client connections section
|
|
349
|
-
*/
|
|
350
|
-
InfoOptions["Clients"] = "clients";
|
|
351
|
-
/**
|
|
352
|
-
* MEMORY: Memory consumption related information
|
|
353
|
-
*/
|
|
354
|
-
InfoOptions["Memory"] = "memory";
|
|
355
|
-
/**
|
|
356
|
-
* PERSISTENCE: RDB and AOF related information
|
|
357
|
-
*/
|
|
358
|
-
InfoOptions["Persistence"] = "persistence";
|
|
359
|
-
/**
|
|
360
|
-
* STATS: General statistics
|
|
361
|
-
*/
|
|
362
|
-
InfoOptions["Stats"] = "stats";
|
|
363
|
-
/**
|
|
364
|
-
* REPLICATION: Master/replica replication information
|
|
365
|
-
*/
|
|
366
|
-
InfoOptions["Replication"] = "replication";
|
|
367
|
-
/**
|
|
368
|
-
* CPU: CPU consumption statistics
|
|
369
|
-
*/
|
|
370
|
-
InfoOptions["Cpu"] = "cpu";
|
|
371
|
-
/**
|
|
372
|
-
* COMMANDSTATS: Valkey command statistics
|
|
373
|
-
*/
|
|
374
|
-
InfoOptions["Commandstats"] = "commandstats";
|
|
375
|
-
/**
|
|
376
|
-
* LATENCYSTATS: Valkey command latency percentile distribution statistics
|
|
377
|
-
*/
|
|
378
|
-
InfoOptions["Latencystats"] = "latencystats";
|
|
379
|
-
/**
|
|
380
|
-
* SENTINEL: Valkey Sentinel section (only applicable to Sentinel instances)
|
|
381
|
-
*/
|
|
382
|
-
InfoOptions["Sentinel"] = "sentinel";
|
|
383
|
-
/**
|
|
384
|
-
* CLUSTER: Valkey Cluster section
|
|
385
|
-
*/
|
|
386
|
-
InfoOptions["Cluster"] = "cluster";
|
|
387
|
-
/**
|
|
388
|
-
* MODULES: Modules section
|
|
389
|
-
*/
|
|
390
|
-
InfoOptions["Modules"] = "modules";
|
|
391
|
-
/**
|
|
392
|
-
* KEYSPACE: Database related statistics
|
|
393
|
-
*/
|
|
394
|
-
InfoOptions["Keyspace"] = "keyspace";
|
|
395
|
-
/**
|
|
396
|
-
* ERRORSTATS: Valkey error statistics
|
|
397
|
-
*/
|
|
398
|
-
InfoOptions["Errorstats"] = "errorstats";
|
|
399
|
-
/**
|
|
400
|
-
* ALL: Return all sections (excluding module generated ones)
|
|
401
|
-
*/
|
|
402
|
-
InfoOptions["All"] = "all";
|
|
403
|
-
/**
|
|
404
|
-
* DEFAULT: Return only the default set of sections
|
|
405
|
-
*/
|
|
406
|
-
InfoOptions["Default"] = "default";
|
|
407
|
-
/**
|
|
408
|
-
* EVERYTHING: Includes all and modules
|
|
409
|
-
*/
|
|
410
|
-
InfoOptions["Everything"] = "everything";
|
|
411
|
-
})(InfoOptions || (exports.InfoOptions = InfoOptions = {}));
|
|
412
|
-
/**
|
|
413
|
-
* @internal
|
|
414
|
-
*/
|
|
415
|
-
function createPing(str) {
|
|
416
|
-
const args = str == undefined ? [] : [str];
|
|
417
|
-
return createCommand(RequestType.Ping, args);
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* @internal
|
|
421
|
-
*/
|
|
422
|
-
function createInfo(options) {
|
|
423
|
-
const args = options == undefined ? [] : options;
|
|
424
|
-
return createCommand(RequestType.Info, args);
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* @internal
|
|
428
|
-
*/
|
|
429
|
-
function createDel(keys) {
|
|
430
|
-
return createCommand(RequestType.Del, keys);
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* @internal
|
|
434
|
-
*/
|
|
435
|
-
function createSelect(index) {
|
|
436
|
-
return createCommand(RequestType.Select, [index.toString()]);
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* @internal
|
|
440
|
-
*/
|
|
441
|
-
function createClientGetName() {
|
|
442
|
-
return createCommand(RequestType.ClientGetName, []);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* @internal
|
|
446
|
-
*/
|
|
447
|
-
function createConfigRewrite() {
|
|
448
|
-
return createCommand(RequestType.ConfigRewrite, []);
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* @internal
|
|
452
|
-
*/
|
|
453
|
-
function createConfigResetStat() {
|
|
454
|
-
return createCommand(RequestType.ConfigResetStat, []);
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* @internal
|
|
458
|
-
*/
|
|
459
|
-
function createMGet(keys) {
|
|
460
|
-
return createCommand(RequestType.MGet, keys);
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* @internal
|
|
464
|
-
*/
|
|
465
|
-
function createMSet(keysAndValues) {
|
|
466
|
-
return createCommand(RequestType.MSet, keysAndValues.flatMap((e) => [e.key, e.value]));
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* @internal
|
|
470
|
-
*/
|
|
471
|
-
function createMSetNX(keysAndValues) {
|
|
472
|
-
return createCommand(RequestType.MSetNX, keysAndValues.flatMap((e) => [e.key, e.value]));
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* @internal
|
|
476
|
-
*/
|
|
477
|
-
function createIncr(key) {
|
|
478
|
-
return createCommand(RequestType.Incr, [key]);
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* @internal
|
|
482
|
-
*/
|
|
483
|
-
function createIncrBy(key, amount) {
|
|
484
|
-
return createCommand(RequestType.IncrBy, [key, amount.toString()]);
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* @internal
|
|
488
|
-
*/
|
|
489
|
-
function createIncrByFloat(key, amount) {
|
|
490
|
-
return createCommand(RequestType.IncrByFloat, [key, amount.toString()]);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* @internal
|
|
494
|
-
*/
|
|
495
|
-
function createClientId() {
|
|
496
|
-
return createCommand(RequestType.ClientId, []);
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* @internal
|
|
500
|
-
*/
|
|
501
|
-
function createConfigGet(parameters) {
|
|
502
|
-
return createCommand(RequestType.ConfigGet, parameters);
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* @internal
|
|
506
|
-
*/
|
|
507
|
-
function createConfigSet(parameters) {
|
|
508
|
-
return createCommand(RequestType.ConfigSet, Object.entries(parameters).flat());
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* @internal
|
|
512
|
-
*/
|
|
513
|
-
function createHGet(key, field) {
|
|
514
|
-
return createCommand(RequestType.HGet, [key, field]);
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* This function converts an input from {@link HashDataType} or `Record` types to `HashDataType`.
|
|
518
|
-
*
|
|
519
|
-
* @param fieldsAndValues - field names and their values.
|
|
520
|
-
* @returns HashDataType array containing field names and their values.
|
|
521
|
-
*/
|
|
522
|
-
function convertFieldsAndValuesToHashDataType(fieldsAndValues) {
|
|
523
|
-
if (!Array.isArray(fieldsAndValues)) {
|
|
524
|
-
return Object.entries(fieldsAndValues).map(([field, value]) => {
|
|
525
|
-
return { field, value };
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
return fieldsAndValues;
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* @internal
|
|
532
|
-
*/
|
|
533
|
-
function createHSet(key, fieldValueList) {
|
|
534
|
-
return createCommand(RequestType.HSet, [key].concat(fieldValueList
|
|
535
|
-
.map((fieldValueObject) => [
|
|
536
|
-
fieldValueObject.field,
|
|
537
|
-
fieldValueObject.value,
|
|
538
|
-
])
|
|
539
|
-
.flat()));
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* @internal
|
|
543
|
-
*/
|
|
544
|
-
function createHKeys(key) {
|
|
545
|
-
return createCommand(RequestType.HKeys, [key]);
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* @internal
|
|
549
|
-
*/
|
|
550
|
-
function createHSetNX(key, field, value) {
|
|
551
|
-
return createCommand(RequestType.HSetNX, [key, field, value]);
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* @internal
|
|
555
|
-
*/
|
|
556
|
-
function createDecr(key) {
|
|
557
|
-
return createCommand(RequestType.Decr, [key]);
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* @internal
|
|
561
|
-
*/
|
|
562
|
-
function createDecrBy(key, amount) {
|
|
563
|
-
return createCommand(RequestType.DecrBy, [key, amount.toString()]);
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* Enumeration defining the bitwise operation to use in the {@link BaseClient.bitop|bitop} command. Specifies the
|
|
567
|
-
* bitwise operation to perform between the passed in keys.
|
|
568
|
-
*/
|
|
569
|
-
var BitwiseOperation;
|
|
570
|
-
(function (BitwiseOperation) {
|
|
571
|
-
BitwiseOperation["AND"] = "AND";
|
|
572
|
-
BitwiseOperation["OR"] = "OR";
|
|
573
|
-
BitwiseOperation["XOR"] = "XOR";
|
|
574
|
-
BitwiseOperation["NOT"] = "NOT";
|
|
575
|
-
})(BitwiseOperation || (exports.BitwiseOperation = BitwiseOperation = {}));
|
|
576
|
-
/**
|
|
577
|
-
* @internal
|
|
578
|
-
*/
|
|
579
|
-
function createBitOp(operation, destination, keys) {
|
|
580
|
-
return createCommand(RequestType.BitOp, [operation, destination, ...keys]);
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* @internal
|
|
584
|
-
*/
|
|
585
|
-
function createGetBit(key, offset) {
|
|
586
|
-
return createCommand(RequestType.GetBit, [key, offset.toString()]);
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* @internal
|
|
590
|
-
*/
|
|
591
|
-
function createSetBit(key, offset, value) {
|
|
592
|
-
return createCommand(RequestType.SetBit, [
|
|
593
|
-
key,
|
|
594
|
-
offset.toString(),
|
|
595
|
-
value.toString(),
|
|
596
|
-
]);
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* Represents a signed argument encoding.
|
|
600
|
-
*/
|
|
601
|
-
class SignedEncoding {
|
|
602
|
-
/**
|
|
603
|
-
* Creates an instance of SignedEncoding.
|
|
604
|
-
*
|
|
605
|
-
* @param encodingLength - The bit size of the encoding. Must be less than 65 bits long.
|
|
606
|
-
*/
|
|
607
|
-
constructor(encodingLength) {
|
|
608
|
-
this.encoding = `${SignedEncoding.SIGNED_ENCODING_PREFIX}${encodingLength.toString()}`;
|
|
609
|
-
}
|
|
610
|
-
toArg() {
|
|
611
|
-
return this.encoding;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
exports.SignedEncoding = SignedEncoding;
|
|
615
|
-
SignedEncoding.SIGNED_ENCODING_PREFIX = "i";
|
|
616
|
-
/**
|
|
617
|
-
* Represents an unsigned argument encoding.
|
|
618
|
-
*/
|
|
619
|
-
class UnsignedEncoding {
|
|
620
|
-
/**
|
|
621
|
-
* Creates an instance of UnsignedEncoding.
|
|
622
|
-
*
|
|
623
|
-
* @param encodingLength - The bit size of the encoding. Must be less than 64 bits long.
|
|
624
|
-
*/
|
|
625
|
-
constructor(encodingLength) {
|
|
626
|
-
this.encoding = `${UnsignedEncoding.UNSIGNED_ENCODING_PREFIX}${encodingLength.toString()}`;
|
|
627
|
-
}
|
|
628
|
-
toArg() {
|
|
629
|
-
return this.encoding;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
exports.UnsignedEncoding = UnsignedEncoding;
|
|
633
|
-
UnsignedEncoding.UNSIGNED_ENCODING_PREFIX = "u";
|
|
634
|
-
/**
|
|
635
|
-
* Represents an offset in an array of bits for the {@link BaseClient.bitfield|bitfield} or
|
|
636
|
-
* {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands.
|
|
637
|
-
*
|
|
638
|
-
* For example, if we have the binary `01101001` with offset of 1 for an unsigned encoding of size 4, then the value
|
|
639
|
-
* is 13 from `0(1101)001`.
|
|
640
|
-
*/
|
|
641
|
-
class BitOffset {
|
|
642
|
-
/**
|
|
643
|
-
* Creates an instance of BitOffset.
|
|
644
|
-
*
|
|
645
|
-
* @param offset - The bit index offset in the array of bits. Must be greater than or equal to 0.
|
|
646
|
-
*/
|
|
647
|
-
constructor(offset) {
|
|
648
|
-
this.offset = offset.toString();
|
|
649
|
-
}
|
|
650
|
-
toArg() {
|
|
651
|
-
return this.offset;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
exports.BitOffset = BitOffset;
|
|
655
|
-
/**
|
|
656
|
-
* Represents an offset in an array of bits for the {@link BaseClient.bitfield|bitfield} or
|
|
657
|
-
* {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. The bit offset index is calculated as the numerical
|
|
658
|
-
* value of the offset multiplied by the encoding value.
|
|
659
|
-
*
|
|
660
|
-
* For example, if we have the binary 01101001 with offset multiplier of 1 for an unsigned encoding of size 4, then the
|
|
661
|
-
* value is 9 from `0110(1001)`.
|
|
662
|
-
*/
|
|
663
|
-
class BitOffsetMultiplier {
|
|
664
|
-
/**
|
|
665
|
-
* Creates an instance of BitOffsetMultiplier.
|
|
666
|
-
*
|
|
667
|
-
* @param offset - The offset in the array of bits, which will be multiplied by the encoding value to get the final
|
|
668
|
-
* bit index offset.
|
|
669
|
-
*/
|
|
670
|
-
constructor(offset) {
|
|
671
|
-
this.offset = `${BitOffsetMultiplier.OFFSET_MULTIPLIER_PREFIX}${offset.toString()}`;
|
|
672
|
-
}
|
|
673
|
-
toArg() {
|
|
674
|
-
return this.offset;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
exports.BitOffsetMultiplier = BitOffsetMultiplier;
|
|
678
|
-
BitOffsetMultiplier.OFFSET_MULTIPLIER_PREFIX = "#";
|
|
679
|
-
/**
|
|
680
|
-
* Represents the "GET" subcommand for getting a value in the binary representation of the string stored in `key`.
|
|
681
|
-
*/
|
|
682
|
-
class BitFieldGet {
|
|
683
|
-
/**
|
|
684
|
-
* Creates an instance of BitFieldGet.
|
|
685
|
-
*
|
|
686
|
-
* @param encoding - The bit encoding for the subcommand.
|
|
687
|
-
* @param offset - The offset in the array of bits from which to get the value.
|
|
688
|
-
*/
|
|
689
|
-
constructor(encoding, offset) {
|
|
690
|
-
this.encoding = encoding;
|
|
691
|
-
this.offset = offset;
|
|
692
|
-
}
|
|
693
|
-
toArgs() {
|
|
694
|
-
return [
|
|
695
|
-
BitFieldGet.GET_COMMAND_STRING,
|
|
696
|
-
this.encoding.toArg(),
|
|
697
|
-
this.offset.toArg(),
|
|
698
|
-
];
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
exports.BitFieldGet = BitFieldGet;
|
|
702
|
-
BitFieldGet.GET_COMMAND_STRING = "GET";
|
|
703
|
-
/**
|
|
704
|
-
* Represents the "SET" subcommand for setting bits in the binary representation of the string stored in `key`.
|
|
705
|
-
*/
|
|
706
|
-
class BitFieldSet {
|
|
707
|
-
/**
|
|
708
|
-
* Creates an instance of BitFieldSet
|
|
709
|
-
*
|
|
710
|
-
* @param encoding - The bit encoding for the subcommand.
|
|
711
|
-
* @param offset - The offset in the array of bits where the value will be set.
|
|
712
|
-
* @param value - The value to set the bits in the binary value to.
|
|
713
|
-
*/
|
|
714
|
-
constructor(encoding, offset, value) {
|
|
715
|
-
this.encoding = encoding;
|
|
716
|
-
this.offset = offset;
|
|
717
|
-
this.value = value;
|
|
718
|
-
}
|
|
719
|
-
toArgs() {
|
|
720
|
-
return [
|
|
721
|
-
BitFieldSet.SET_COMMAND_STRING,
|
|
722
|
-
this.encoding.toArg(),
|
|
723
|
-
this.offset.toArg(),
|
|
724
|
-
this.value.toString(),
|
|
725
|
-
];
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
exports.BitFieldSet = BitFieldSet;
|
|
729
|
-
BitFieldSet.SET_COMMAND_STRING = "SET";
|
|
730
|
-
/**
|
|
731
|
-
* Represents the "INCRBY" subcommand for increasing or decreasing bits in the binary representation of the string
|
|
732
|
-
* stored in `key`.
|
|
733
|
-
*/
|
|
734
|
-
class BitFieldIncrBy {
|
|
735
|
-
/**
|
|
736
|
-
* Creates an instance of BitFieldIncrBy
|
|
737
|
-
*
|
|
738
|
-
* @param encoding - The bit encoding for the subcommand.
|
|
739
|
-
* @param offset - The offset in the array of bits where the value will be incremented.
|
|
740
|
-
* @param increment - The value to increment the bits in the binary value by.
|
|
741
|
-
*/
|
|
742
|
-
constructor(encoding, offset, increment) {
|
|
743
|
-
this.encoding = encoding;
|
|
744
|
-
this.offset = offset;
|
|
745
|
-
this.increment = increment;
|
|
746
|
-
}
|
|
747
|
-
toArgs() {
|
|
748
|
-
return [
|
|
749
|
-
BitFieldIncrBy.INCRBY_COMMAND_STRING,
|
|
750
|
-
this.encoding.toArg(),
|
|
751
|
-
this.offset.toArg(),
|
|
752
|
-
this.increment.toString(),
|
|
753
|
-
];
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
exports.BitFieldIncrBy = BitFieldIncrBy;
|
|
757
|
-
BitFieldIncrBy.INCRBY_COMMAND_STRING = "INCRBY";
|
|
758
|
-
/**
|
|
759
|
-
* Enumeration specifying bit overflow controls for the {@link BaseClient.bitfield|bitfield} command.
|
|
760
|
-
*/
|
|
761
|
-
var BitOverflowControl;
|
|
762
|
-
(function (BitOverflowControl) {
|
|
763
|
-
/**
|
|
764
|
-
* Performs modulo when overflows occur with unsigned encoding. When overflows occur with signed encoding, the value
|
|
765
|
-
* restarts at the most negative value. When underflows occur with signed encoding, the value restarts at the most
|
|
766
|
-
* positive value.
|
|
767
|
-
*/
|
|
768
|
-
BitOverflowControl["WRAP"] = "WRAP";
|
|
769
|
-
/**
|
|
770
|
-
* Underflows remain set to the minimum value, and overflows remain set to the maximum value.
|
|
771
|
-
*/
|
|
772
|
-
BitOverflowControl["SAT"] = "SAT";
|
|
773
|
-
/**
|
|
774
|
-
* Returns `None` when overflows occur.
|
|
775
|
-
*/
|
|
776
|
-
BitOverflowControl["FAIL"] = "FAIL";
|
|
777
|
-
})(BitOverflowControl || (exports.BitOverflowControl = BitOverflowControl = {}));
|
|
778
|
-
/**
|
|
779
|
-
* Represents the "OVERFLOW" subcommand that determines the result of the "SET" or "INCRBY"
|
|
780
|
-
* {@link BaseClient.bitfield|bitfield} subcommands when an underflow or overflow occurs.
|
|
781
|
-
*/
|
|
782
|
-
class BitFieldOverflow {
|
|
783
|
-
/**
|
|
784
|
-
* Creates an instance of BitFieldOverflow.
|
|
785
|
-
*
|
|
786
|
-
* @param overflowControl - The desired overflow behavior.
|
|
787
|
-
*/
|
|
788
|
-
constructor(overflowControl) {
|
|
789
|
-
this.overflowControl = overflowControl;
|
|
790
|
-
}
|
|
791
|
-
toArgs() {
|
|
792
|
-
return [BitFieldOverflow.OVERFLOW_COMMAND_STRING, this.overflowControl];
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
exports.BitFieldOverflow = BitFieldOverflow;
|
|
796
|
-
BitFieldOverflow.OVERFLOW_COMMAND_STRING = "OVERFLOW";
|
|
797
|
-
/**
|
|
798
|
-
* @internal
|
|
799
|
-
*/
|
|
800
|
-
function createBitField(key, subcommands, readOnly = false) {
|
|
801
|
-
const requestType = readOnly
|
|
802
|
-
? RequestType.BitFieldReadOnly
|
|
803
|
-
: RequestType.BitField;
|
|
804
|
-
let args = [key];
|
|
805
|
-
for (const subcommand of subcommands) {
|
|
806
|
-
args = args.concat(subcommand.toArgs());
|
|
807
|
-
}
|
|
808
|
-
return createCommand(requestType, args);
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* @internal
|
|
812
|
-
*/
|
|
813
|
-
function createHDel(key, fields) {
|
|
814
|
-
return createCommand(RequestType.HDel, [key].concat(fields));
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
* @internal
|
|
818
|
-
*/
|
|
819
|
-
function createHMGet(key, fields) {
|
|
820
|
-
return createCommand(RequestType.HMGet, [key].concat(fields));
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* @internal
|
|
824
|
-
*/
|
|
825
|
-
function createHExists(key, field) {
|
|
826
|
-
return createCommand(RequestType.HExists, [key, field]);
|
|
827
|
-
}
|
|
828
|
-
/**
|
|
829
|
-
* @internal
|
|
830
|
-
*/
|
|
831
|
-
function createHGetAll(key) {
|
|
832
|
-
return createCommand(RequestType.HGetAll, [key]);
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* @internal
|
|
836
|
-
*/
|
|
837
|
-
function createLPush(key, elements) {
|
|
838
|
-
return createCommand(RequestType.LPush, [key].concat(elements));
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* @internal
|
|
842
|
-
*/
|
|
843
|
-
function createLPushX(key, elements) {
|
|
844
|
-
return createCommand(RequestType.LPushX, [key].concat(elements));
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* @internal
|
|
848
|
-
*/
|
|
849
|
-
function createLPop(key, count) {
|
|
850
|
-
const args = count == undefined ? [key] : [key, count.toString()];
|
|
851
|
-
return createCommand(RequestType.LPop, args);
|
|
852
|
-
}
|
|
853
|
-
/**
|
|
854
|
-
* @internal
|
|
855
|
-
*/
|
|
856
|
-
function createLRange(key, start, end) {
|
|
857
|
-
return createCommand(RequestType.LRange, [
|
|
858
|
-
key,
|
|
859
|
-
start.toString(),
|
|
860
|
-
end.toString(),
|
|
861
|
-
]);
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* @internal
|
|
865
|
-
*/
|
|
866
|
-
function createLLen(key) {
|
|
867
|
-
return createCommand(RequestType.LLen, [key]);
|
|
868
|
-
}
|
|
869
|
-
/**
|
|
870
|
-
* Enumeration representing element popping or adding direction for the List Based Commands.
|
|
871
|
-
*/
|
|
872
|
-
var ListDirection;
|
|
873
|
-
(function (ListDirection) {
|
|
874
|
-
/**
|
|
875
|
-
* Represents the option that elements should be popped from or added to the left side of a list.
|
|
876
|
-
*/
|
|
877
|
-
ListDirection["LEFT"] = "LEFT";
|
|
878
|
-
/**
|
|
879
|
-
* Represents the option that elements should be popped from or added to the right side of a list.
|
|
880
|
-
*/
|
|
881
|
-
ListDirection["RIGHT"] = "RIGHT";
|
|
882
|
-
})(ListDirection || (exports.ListDirection = ListDirection = {}));
|
|
883
|
-
/**
|
|
884
|
-
* @internal
|
|
885
|
-
*/
|
|
886
|
-
function createLMove(source, destination, whereFrom, whereTo) {
|
|
887
|
-
return createCommand(RequestType.LMove, [
|
|
888
|
-
source,
|
|
889
|
-
destination,
|
|
890
|
-
whereFrom,
|
|
891
|
-
whereTo,
|
|
892
|
-
]);
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* @internal
|
|
896
|
-
*/
|
|
897
|
-
function createBLMove(source, destination, whereFrom, whereTo, timeout) {
|
|
898
|
-
return createCommand(RequestType.BLMove, [
|
|
899
|
-
source,
|
|
900
|
-
destination,
|
|
901
|
-
whereFrom,
|
|
902
|
-
whereTo,
|
|
903
|
-
timeout.toString(),
|
|
904
|
-
]);
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* @internal
|
|
908
|
-
*/
|
|
909
|
-
function createLSet(key, index, element) {
|
|
910
|
-
return createCommand(RequestType.LSet, [key, index.toString(), element]);
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* @internal
|
|
914
|
-
*/
|
|
915
|
-
function createLTrim(key, start, end) {
|
|
916
|
-
return createCommand(RequestType.LTrim, [
|
|
917
|
-
key,
|
|
918
|
-
start.toString(),
|
|
919
|
-
end.toString(),
|
|
920
|
-
]);
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* @internal
|
|
924
|
-
*/
|
|
925
|
-
function createLRem(key, count, element) {
|
|
926
|
-
return createCommand(RequestType.LRem, [key, count.toString(), element]);
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* @internal
|
|
930
|
-
*/
|
|
931
|
-
function createRPush(key, elements) {
|
|
932
|
-
return createCommand(RequestType.RPush, [key].concat(elements));
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* @internal
|
|
936
|
-
*/
|
|
937
|
-
function createRPushX(key, elements) {
|
|
938
|
-
return createCommand(RequestType.RPushX, [key].concat(elements));
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* @internal
|
|
942
|
-
*/
|
|
943
|
-
function createRPop(key, count) {
|
|
944
|
-
const args = count == undefined ? [key] : [key, count.toString()];
|
|
945
|
-
return createCommand(RequestType.RPop, args);
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* @internal
|
|
949
|
-
*/
|
|
950
|
-
function createSAdd(key, members) {
|
|
951
|
-
return createCommand(RequestType.SAdd, [key].concat(members));
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* @internal
|
|
955
|
-
*/
|
|
956
|
-
function createSRem(key, members) {
|
|
957
|
-
return createCommand(RequestType.SRem, [key].concat(members));
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* @internal
|
|
961
|
-
*/
|
|
962
|
-
function createSScan(key, cursor, options) {
|
|
963
|
-
let args = [key, cursor];
|
|
964
|
-
if (options) {
|
|
965
|
-
args = args.concat(convertBaseScanOptionsToArgsArray(options));
|
|
966
|
-
}
|
|
967
|
-
return createCommand(RequestType.SScan, args);
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* @internal
|
|
971
|
-
*/
|
|
972
|
-
function createSMembers(key) {
|
|
973
|
-
return createCommand(RequestType.SMembers, [key]);
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
*
|
|
977
|
-
* @internal
|
|
978
|
-
*/
|
|
979
|
-
function createSMove(source, destination, member) {
|
|
980
|
-
return createCommand(RequestType.SMove, [source, destination, member]);
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* @internal
|
|
984
|
-
*/
|
|
985
|
-
function createSCard(key) {
|
|
986
|
-
return createCommand(RequestType.SCard, [key]);
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* @internal
|
|
990
|
-
*/
|
|
991
|
-
function createSInter(keys) {
|
|
992
|
-
return createCommand(RequestType.SInter, keys);
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* @internal
|
|
996
|
-
*/
|
|
997
|
-
function createSInterCard(keys, limit) {
|
|
998
|
-
let args = keys;
|
|
999
|
-
args.unshift(keys.length.toString());
|
|
1000
|
-
if (limit != undefined) {
|
|
1001
|
-
args = args.concat(["LIMIT", limit.toString()]);
|
|
1002
|
-
}
|
|
1003
|
-
return createCommand(RequestType.SInterCard, args);
|
|
1004
|
-
}
|
|
1005
|
-
/**
|
|
1006
|
-
* @internal
|
|
1007
|
-
*/
|
|
1008
|
-
function createSInterStore(destination, keys) {
|
|
1009
|
-
return createCommand(RequestType.SInterStore, [destination].concat(keys));
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* @internal
|
|
1013
|
-
*/
|
|
1014
|
-
function createSDiff(keys) {
|
|
1015
|
-
return createCommand(RequestType.SDiff, keys);
|
|
1016
|
-
}
|
|
1017
|
-
/**
|
|
1018
|
-
* @internal
|
|
1019
|
-
*/
|
|
1020
|
-
function createSDiffStore(destination, keys) {
|
|
1021
|
-
return createCommand(RequestType.SDiffStore, [destination].concat(keys));
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* @internal
|
|
1025
|
-
*/
|
|
1026
|
-
function createSUnion(keys) {
|
|
1027
|
-
return createCommand(RequestType.SUnion, keys);
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* @internal
|
|
1031
|
-
*/
|
|
1032
|
-
function createSUnionStore(destination, keys) {
|
|
1033
|
-
return createCommand(RequestType.SUnionStore, [destination].concat(keys));
|
|
1034
|
-
}
|
|
1035
|
-
/**
|
|
1036
|
-
* @internal
|
|
1037
|
-
*/
|
|
1038
|
-
function createSIsMember(key, member) {
|
|
1039
|
-
return createCommand(RequestType.SIsMember, [key, member]);
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
|
-
* @internal
|
|
1043
|
-
*/
|
|
1044
|
-
function createSMIsMember(key, members) {
|
|
1045
|
-
return createCommand(RequestType.SMIsMember, [key].concat(members));
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* @internal
|
|
1049
|
-
*/
|
|
1050
|
-
function createSPop(key, count) {
|
|
1051
|
-
const args = count == undefined ? [key] : [key, count.toString()];
|
|
1052
|
-
return createCommand(RequestType.SPop, args);
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* @internal
|
|
1056
|
-
*/
|
|
1057
|
-
function createSRandMember(key, count) {
|
|
1058
|
-
const args = count == undefined ? [key] : [key, count.toString()];
|
|
1059
|
-
return createCommand(RequestType.SRandMember, args);
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* @internal
|
|
1063
|
-
*/
|
|
1064
|
-
function createCustomCommand(args) {
|
|
1065
|
-
return createCommand(RequestType.CustomCommand, args);
|
|
1066
|
-
}
|
|
1067
|
-
/**
|
|
1068
|
-
* @internal
|
|
1069
|
-
*/
|
|
1070
|
-
function createHIncrBy(key, field, amount) {
|
|
1071
|
-
return createCommand(RequestType.HIncrBy, [key, field, amount.toString()]);
|
|
1072
|
-
}
|
|
1073
|
-
/**
|
|
1074
|
-
* @internal
|
|
1075
|
-
*/
|
|
1076
|
-
function createHIncrByFloat(key, field, amount) {
|
|
1077
|
-
return createCommand(RequestType.HIncrByFloat, [
|
|
1078
|
-
key,
|
|
1079
|
-
field,
|
|
1080
|
-
amount.toString(),
|
|
1081
|
-
]);
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* @internal
|
|
1085
|
-
*/
|
|
1086
|
-
function createHLen(key) {
|
|
1087
|
-
return createCommand(RequestType.HLen, [key]);
|
|
1088
|
-
}
|
|
1089
|
-
/**
|
|
1090
|
-
* @internal
|
|
1091
|
-
*/
|
|
1092
|
-
function createHVals(key) {
|
|
1093
|
-
return createCommand(RequestType.HVals, [key]);
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
* @internal
|
|
1097
|
-
*/
|
|
1098
|
-
function createExists(keys) {
|
|
1099
|
-
return createCommand(RequestType.Exists, keys);
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* @internal
|
|
1103
|
-
*/
|
|
1104
|
-
function createUnlink(keys) {
|
|
1105
|
-
return createCommand(RequestType.Unlink, keys);
|
|
1106
|
-
}
|
|
1107
|
-
var ExpireOptions;
|
|
1108
|
-
(function (ExpireOptions) {
|
|
1109
|
-
/**
|
|
1110
|
-
* `HasNoExpiry` - Sets expiry only when the key has no expiry.
|
|
1111
|
-
*/
|
|
1112
|
-
ExpireOptions["HasNoExpiry"] = "NX";
|
|
1113
|
-
/**
|
|
1114
|
-
* `HasExistingExpiry` - Sets expiry only when the key has an existing expiry.
|
|
1115
|
-
*/
|
|
1116
|
-
ExpireOptions["HasExistingExpiry"] = "XX";
|
|
1117
|
-
/**
|
|
1118
|
-
* `NewExpiryGreaterThanCurrent` - Sets expiry only when the new expiry is
|
|
1119
|
-
* greater than current one.
|
|
1120
|
-
*/
|
|
1121
|
-
ExpireOptions["NewExpiryGreaterThanCurrent"] = "GT";
|
|
1122
|
-
/**
|
|
1123
|
-
* `NewExpiryLessThanCurrent` - Sets expiry only when the new expiry is less
|
|
1124
|
-
* than current one.
|
|
1125
|
-
*/
|
|
1126
|
-
ExpireOptions["NewExpiryLessThanCurrent"] = "LT";
|
|
1127
|
-
})(ExpireOptions || (exports.ExpireOptions = ExpireOptions = {}));
|
|
1128
|
-
/**
|
|
1129
|
-
* @internal
|
|
1130
|
-
*/
|
|
1131
|
-
function createExpire(key, seconds, option) {
|
|
1132
|
-
const args = option == undefined
|
|
1133
|
-
? [key, seconds.toString()]
|
|
1134
|
-
: [key, seconds.toString(), option];
|
|
1135
|
-
return createCommand(RequestType.Expire, args);
|
|
1136
|
-
}
|
|
1137
|
-
/**
|
|
1138
|
-
* @internal
|
|
1139
|
-
*/
|
|
1140
|
-
function createExpireAt(key, unixSeconds, option) {
|
|
1141
|
-
const args = option == undefined
|
|
1142
|
-
? [key, unixSeconds.toString()]
|
|
1143
|
-
: [key, unixSeconds.toString(), option];
|
|
1144
|
-
return createCommand(RequestType.ExpireAt, args);
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* @internal
|
|
1148
|
-
*/
|
|
1149
|
-
function createExpireTime(key) {
|
|
1150
|
-
return createCommand(RequestType.ExpireTime, [key]);
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* @internal
|
|
1154
|
-
*/
|
|
1155
|
-
function createPExpire(key, milliseconds, option) {
|
|
1156
|
-
const args = option == undefined
|
|
1157
|
-
? [key, milliseconds.toString()]
|
|
1158
|
-
: [key, milliseconds.toString(), option];
|
|
1159
|
-
return createCommand(RequestType.PExpire, args);
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* @internal
|
|
1163
|
-
*/
|
|
1164
|
-
function createPExpireAt(key, unixMilliseconds, option) {
|
|
1165
|
-
const args = option == undefined
|
|
1166
|
-
? [key, unixMilliseconds.toString()]
|
|
1167
|
-
: [key, unixMilliseconds.toString(), option];
|
|
1168
|
-
return createCommand(RequestType.PExpireAt, args);
|
|
1169
|
-
}
|
|
1170
|
-
/**
|
|
1171
|
-
* @internal
|
|
1172
|
-
*/
|
|
1173
|
-
function createPExpireTime(key) {
|
|
1174
|
-
return createCommand(RequestType.PExpireTime, [key]);
|
|
1175
|
-
}
|
|
1176
|
-
/**
|
|
1177
|
-
* @internal
|
|
1178
|
-
*/
|
|
1179
|
-
function createTTL(key) {
|
|
1180
|
-
return createCommand(RequestType.TTL, [key]);
|
|
1181
|
-
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Options for updating elements of a sorted set key.
|
|
1184
|
-
*/
|
|
1185
|
-
var UpdateByScore;
|
|
1186
|
-
(function (UpdateByScore) {
|
|
1187
|
-
/** Only update existing elements if the new score is less than the current score. */
|
|
1188
|
-
UpdateByScore["LESS_THAN"] = "LT";
|
|
1189
|
-
/** Only update existing elements if the new score is greater than the current score. */
|
|
1190
|
-
UpdateByScore["GREATER_THAN"] = "GT";
|
|
1191
|
-
})(UpdateByScore || (exports.UpdateByScore = UpdateByScore = {}));
|
|
1192
|
-
/**
|
|
1193
|
-
* @internal
|
|
1194
|
-
* Convert input from `Record` to `SortedSetDataType` to ensure the only one type.
|
|
1195
|
-
*/
|
|
1196
|
-
function convertElementsAndScores(membersAndScores) {
|
|
1197
|
-
if (!Array.isArray(membersAndScores)) {
|
|
1198
|
-
// convert Record<string, number> to SortedSetDataType
|
|
1199
|
-
return Object.entries(membersAndScores).map((element) => {
|
|
1200
|
-
return { element: element[0], score: element[1] };
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
return membersAndScores;
|
|
1204
|
-
}
|
|
1205
|
-
/**
|
|
1206
|
-
* @internal
|
|
1207
|
-
*/
|
|
1208
|
-
function createZAdd(key, membersAndScores, options, incr = false) {
|
|
1209
|
-
const args = [key];
|
|
1210
|
-
if (options) {
|
|
1211
|
-
if (options.conditionalChange) {
|
|
1212
|
-
if (options.conditionalChange ===
|
|
1213
|
-
ConditionalChange.ONLY_IF_DOES_NOT_EXIST &&
|
|
1214
|
-
options.updateOptions) {
|
|
1215
|
-
throw new Error(`The GT, LT, and NX options are mutually exclusive. Cannot choose both ${options.updateOptions} and NX.`);
|
|
1216
|
-
}
|
|
1217
|
-
args.push(options.conditionalChange);
|
|
1218
|
-
}
|
|
1219
|
-
if (options.updateOptions) {
|
|
1220
|
-
args.push(options.updateOptions);
|
|
1221
|
-
}
|
|
1222
|
-
if (options.changed) {
|
|
1223
|
-
args.push("CH");
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
if (incr) {
|
|
1227
|
-
args.push("INCR");
|
|
1228
|
-
}
|
|
1229
|
-
if (Array.isArray(membersAndScores)) {
|
|
1230
|
-
for (let i = 0, len = membersAndScores.length; i < len; i++) {
|
|
1231
|
-
const item = membersAndScores[i];
|
|
1232
|
-
args.push(item.score.toString(), item.element);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
else {
|
|
1236
|
-
const members = Object.keys(membersAndScores);
|
|
1237
|
-
for (let i = 0, len = members.length; i < len; i++) {
|
|
1238
|
-
const member = members[i];
|
|
1239
|
-
args.push(membersAndScores[member].toString(), member);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
return createCommand(RequestType.ZAdd, args);
|
|
1243
|
-
}
|
|
1244
|
-
/**
|
|
1245
|
-
* @internal
|
|
1246
|
-
*/
|
|
1247
|
-
function createZInterstore(destination, keys, aggregationType) {
|
|
1248
|
-
const args = createZCmdArgs(keys, {
|
|
1249
|
-
aggregationType,
|
|
1250
|
-
withScores: false,
|
|
1251
|
-
destination,
|
|
1252
|
-
});
|
|
1253
|
-
return createCommand(RequestType.ZInterStore, args);
|
|
1254
|
-
}
|
|
1255
|
-
/**
|
|
1256
|
-
* @internal
|
|
1257
|
-
*/
|
|
1258
|
-
function createZInter(keys, aggregationType, withScores) {
|
|
1259
|
-
const args = createZCmdArgs(keys, { aggregationType, withScores });
|
|
1260
|
-
return createCommand(RequestType.ZInter, args);
|
|
1261
|
-
}
|
|
1262
|
-
/**
|
|
1263
|
-
* @internal
|
|
1264
|
-
*/
|
|
1265
|
-
function createZUnion(keys, aggregationType, withScores) {
|
|
1266
|
-
const args = createZCmdArgs(keys, { aggregationType, withScores });
|
|
1267
|
-
return createCommand(RequestType.ZUnion, args);
|
|
1268
|
-
}
|
|
1269
|
-
/**
|
|
1270
|
-
* @internal
|
|
1271
|
-
* Helper function for Zcommands (ZInter, ZinterStore, ZUnion..) that arranges arguments in the server's required order.
|
|
1272
|
-
*/
|
|
1273
|
-
function createZCmdArgs(keys, options) {
|
|
1274
|
-
const args = [];
|
|
1275
|
-
const destination = options.destination;
|
|
1276
|
-
if (destination) {
|
|
1277
|
-
args.push(destination);
|
|
1278
|
-
}
|
|
1279
|
-
args.push(keys.length.toString());
|
|
1280
|
-
if (!Array.isArray(keys[0])) {
|
|
1281
|
-
// KeyWeight is an array
|
|
1282
|
-
args.push(...keys);
|
|
1283
|
-
}
|
|
1284
|
-
else {
|
|
1285
|
-
const weightsKeys = keys.map(([key]) => key);
|
|
1286
|
-
args.push(...weightsKeys);
|
|
1287
|
-
const weights = keys.map(([, weight]) => weight.toString());
|
|
1288
|
-
args.push("WEIGHTS", ...weights);
|
|
1289
|
-
}
|
|
1290
|
-
const aggregationType = options.aggregationType;
|
|
1291
|
-
if (aggregationType) {
|
|
1292
|
-
args.push("AGGREGATE", aggregationType);
|
|
1293
|
-
}
|
|
1294
|
-
if (options.withScores) {
|
|
1295
|
-
args.push("WITHSCORES");
|
|
1296
|
-
}
|
|
1297
|
-
return args;
|
|
1298
|
-
}
|
|
1299
|
-
/**
|
|
1300
|
-
* @internal
|
|
1301
|
-
*/
|
|
1302
|
-
function createZRem(key, members) {
|
|
1303
|
-
return createCommand(RequestType.ZRem, [key].concat(members));
|
|
1304
|
-
}
|
|
1305
|
-
/**
|
|
1306
|
-
* @internal
|
|
1307
|
-
*/
|
|
1308
|
-
function createZCard(key) {
|
|
1309
|
-
return createCommand(RequestType.ZCard, [key]);
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* @internal
|
|
1313
|
-
*/
|
|
1314
|
-
function createZInterCard(keys, limit) {
|
|
1315
|
-
const args = keys;
|
|
1316
|
-
args.unshift(keys.length.toString());
|
|
1317
|
-
if (limit != undefined) {
|
|
1318
|
-
args.push("LIMIT", limit.toString());
|
|
1319
|
-
}
|
|
1320
|
-
return createCommand(RequestType.ZInterCard, args);
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* @internal
|
|
1324
|
-
*/
|
|
1325
|
-
function createZDiff(keys) {
|
|
1326
|
-
const args = keys;
|
|
1327
|
-
args.unshift(keys.length.toString());
|
|
1328
|
-
return createCommand(RequestType.ZDiff, args);
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* @internal
|
|
1332
|
-
*/
|
|
1333
|
-
function createZDiffWithScores(keys) {
|
|
1334
|
-
const args = keys;
|
|
1335
|
-
args.unshift(keys.length.toString());
|
|
1336
|
-
args.push("WITHSCORES");
|
|
1337
|
-
return createCommand(RequestType.ZDiff, args);
|
|
1338
|
-
}
|
|
1339
|
-
/**
|
|
1340
|
-
* @internal
|
|
1341
|
-
*/
|
|
1342
|
-
function createZDiffStore(destination, keys) {
|
|
1343
|
-
const args = [destination, keys.length.toString(), ...keys];
|
|
1344
|
-
return createCommand(RequestType.ZDiffStore, args);
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* @internal
|
|
1348
|
-
*/
|
|
1349
|
-
function createZScore(key, member) {
|
|
1350
|
-
return createCommand(RequestType.ZScore, [key, member]);
|
|
1351
|
-
}
|
|
1352
|
-
/**
|
|
1353
|
-
* @internal
|
|
1354
|
-
*/
|
|
1355
|
-
function createZUnionStore(destination, keys, aggregationType) {
|
|
1356
|
-
const args = createZCmdArgs(keys, { destination, aggregationType });
|
|
1357
|
-
return createCommand(RequestType.ZUnionStore, args);
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* @internal
|
|
1361
|
-
*/
|
|
1362
|
-
function createZMScore(key, members) {
|
|
1363
|
-
return createCommand(RequestType.ZMScore, [key, ...members]);
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* @internal
|
|
1367
|
-
*/
|
|
1368
|
-
function createScan(cursor, options) {
|
|
1369
|
-
let args = [cursor];
|
|
1370
|
-
if (options) {
|
|
1371
|
-
args = args.concat(convertBaseScanOptionsToArgsArray(options));
|
|
1372
|
-
}
|
|
1373
|
-
if (options === null || options === void 0 ? void 0 : options.type) {
|
|
1374
|
-
args.push("TYPE", options.type);
|
|
1375
|
-
}
|
|
1376
|
-
return createCommand(RequestType.Scan, args);
|
|
1377
|
-
}
|
|
1378
|
-
var InfBoundary;
|
|
1379
|
-
(function (InfBoundary) {
|
|
1380
|
-
/**
|
|
1381
|
-
* Positive infinity bound.
|
|
1382
|
-
*/
|
|
1383
|
-
InfBoundary["PositiveInfinity"] = "+";
|
|
1384
|
-
/**
|
|
1385
|
-
* Negative infinity bound.
|
|
1386
|
-
*/
|
|
1387
|
-
InfBoundary["NegativeInfinity"] = "-";
|
|
1388
|
-
})(InfBoundary || (exports.InfBoundary = InfBoundary = {}));
|
|
1389
|
-
/** Returns a string representation of a score boundary as a command argument. */
|
|
1390
|
-
function getScoreBoundaryArg(score) {
|
|
1391
|
-
if (typeof score === "string") {
|
|
1392
|
-
// InfBoundary
|
|
1393
|
-
return score + "inf";
|
|
1394
|
-
}
|
|
1395
|
-
if (score.isInclusive == false) {
|
|
1396
|
-
return "(" + score.value.toString();
|
|
1397
|
-
}
|
|
1398
|
-
return score.value.toString();
|
|
1399
|
-
}
|
|
1400
|
-
/** Returns a string representation of a lex boundary as a command argument. */
|
|
1401
|
-
function getLexBoundaryArg(score) {
|
|
1402
|
-
if (typeof score === "string") {
|
|
1403
|
-
// InfBoundary
|
|
1404
|
-
return score;
|
|
1405
|
-
}
|
|
1406
|
-
if (score.isInclusive == false) {
|
|
1407
|
-
return typeof score.value === "string"
|
|
1408
|
-
? "(" + score.value
|
|
1409
|
-
: Buffer.concat([Buffer.from("("), score.value]);
|
|
1410
|
-
}
|
|
1411
|
-
return typeof score.value === "string"
|
|
1412
|
-
? "[" + score.value
|
|
1413
|
-
: Buffer.concat([Buffer.from("["), score.value]);
|
|
1414
|
-
}
|
|
1415
|
-
/** Returns a string representation of a stream boundary as a command argument. */
|
|
1416
|
-
function getStreamBoundaryArg(boundary) {
|
|
1417
|
-
if (typeof boundary === "string") {
|
|
1418
|
-
// InfBoundary
|
|
1419
|
-
return boundary;
|
|
1420
|
-
}
|
|
1421
|
-
if (boundary.isInclusive == false) {
|
|
1422
|
-
return "(" + boundary.value.toString();
|
|
1423
|
-
}
|
|
1424
|
-
return boundary.value.toString();
|
|
1425
|
-
}
|
|
1426
|
-
function createZRangeArgs(key, rangeQuery, reverse, withScores) {
|
|
1427
|
-
const args = [key];
|
|
1428
|
-
if (typeof rangeQuery.start != "number") {
|
|
1429
|
-
rangeQuery = rangeQuery;
|
|
1430
|
-
if (rangeQuery.type == "byLex") {
|
|
1431
|
-
args.push(getLexBoundaryArg(rangeQuery.start), getLexBoundaryArg(rangeQuery.end), "BYLEX");
|
|
1432
|
-
}
|
|
1433
|
-
else {
|
|
1434
|
-
args.push(getScoreBoundaryArg(rangeQuery.start), getScoreBoundaryArg(rangeQuery.end), "BYSCORE");
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
else {
|
|
1438
|
-
args.push(rangeQuery.start.toString());
|
|
1439
|
-
args.push(rangeQuery.end.toString());
|
|
1440
|
-
}
|
|
1441
|
-
if (reverse) {
|
|
1442
|
-
args.push("REV");
|
|
1443
|
-
}
|
|
1444
|
-
if ("limit" in rangeQuery && rangeQuery.limit !== undefined) {
|
|
1445
|
-
args.push("LIMIT", String(rangeQuery.limit.offset), String(rangeQuery.limit.count));
|
|
1446
|
-
}
|
|
1447
|
-
if (withScores) {
|
|
1448
|
-
args.push("WITHSCORES");
|
|
1449
|
-
}
|
|
1450
|
-
return args;
|
|
1451
|
-
}
|
|
1452
|
-
/**
|
|
1453
|
-
* @internal
|
|
1454
|
-
*/
|
|
1455
|
-
function createZCount(key, minScore, maxScore) {
|
|
1456
|
-
const args = [
|
|
1457
|
-
key,
|
|
1458
|
-
getScoreBoundaryArg(minScore),
|
|
1459
|
-
getScoreBoundaryArg(maxScore),
|
|
1460
|
-
];
|
|
1461
|
-
return createCommand(RequestType.ZCount, args);
|
|
1462
|
-
}
|
|
1463
|
-
/**
|
|
1464
|
-
* @internal
|
|
1465
|
-
*/
|
|
1466
|
-
function createZRange(key, rangeQuery, reverse = false) {
|
|
1467
|
-
const args = createZRangeArgs(key, rangeQuery, reverse, false);
|
|
1468
|
-
return createCommand(RequestType.ZRange, args);
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* @internal
|
|
1472
|
-
*/
|
|
1473
|
-
function createZRangeWithScores(key, rangeQuery, reverse = false) {
|
|
1474
|
-
const args = createZRangeArgs(key, rangeQuery, reverse, true);
|
|
1475
|
-
return createCommand(RequestType.ZRange, args);
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* @internal
|
|
1479
|
-
*/
|
|
1480
|
-
function createZRangeStore(destination, source, rangeQuery, reverse = false) {
|
|
1481
|
-
const args = [
|
|
1482
|
-
destination,
|
|
1483
|
-
...createZRangeArgs(source, rangeQuery, reverse, false),
|
|
1484
|
-
];
|
|
1485
|
-
return createCommand(RequestType.ZRangeStore, args);
|
|
1486
|
-
}
|
|
1487
|
-
/**
|
|
1488
|
-
* @internal
|
|
1489
|
-
*/
|
|
1490
|
-
function createType(key) {
|
|
1491
|
-
return createCommand(RequestType.Type, [key]);
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* @internal
|
|
1495
|
-
*/
|
|
1496
|
-
function createStrlen(key) {
|
|
1497
|
-
return createCommand(RequestType.Strlen, [key]);
|
|
1498
|
-
}
|
|
1499
|
-
/**
|
|
1500
|
-
* @internal
|
|
1501
|
-
*/
|
|
1502
|
-
function createLIndex(key, index) {
|
|
1503
|
-
return createCommand(RequestType.LIndex, [key, index.toString()]);
|
|
1504
|
-
}
|
|
1505
|
-
/**
|
|
1506
|
-
* Defines where to insert new elements into a list.
|
|
1507
|
-
*/
|
|
1508
|
-
var InsertPosition;
|
|
1509
|
-
(function (InsertPosition) {
|
|
1510
|
-
/**
|
|
1511
|
-
* Insert new element before the pivot.
|
|
1512
|
-
*/
|
|
1513
|
-
InsertPosition["Before"] = "before";
|
|
1514
|
-
/**
|
|
1515
|
-
* Insert new element after the pivot.
|
|
1516
|
-
*/
|
|
1517
|
-
InsertPosition["After"] = "after";
|
|
1518
|
-
})(InsertPosition || (exports.InsertPosition = InsertPosition = {}));
|
|
1519
|
-
/**
|
|
1520
|
-
* @internal
|
|
1521
|
-
*/
|
|
1522
|
-
function createLInsert(key, position, pivot, element) {
|
|
1523
|
-
return createCommand(RequestType.LInsert, [key, position, pivot, element]);
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* @internal
|
|
1527
|
-
*/
|
|
1528
|
-
function createZPopMin(key, count) {
|
|
1529
|
-
const args = count == undefined ? [key] : [key, count.toString()];
|
|
1530
|
-
return createCommand(RequestType.ZPopMin, args);
|
|
1531
|
-
}
|
|
1532
|
-
/**
|
|
1533
|
-
* @internal
|
|
1534
|
-
*/
|
|
1535
|
-
function createZPopMax(key, count) {
|
|
1536
|
-
const args = count == undefined ? [key] : [key, count.toString()];
|
|
1537
|
-
return createCommand(RequestType.ZPopMax, args);
|
|
1538
|
-
}
|
|
1539
|
-
/**
|
|
1540
|
-
* @internal
|
|
1541
|
-
*/
|
|
1542
|
-
function createEcho(message) {
|
|
1543
|
-
return createCommand(RequestType.Echo, [message]);
|
|
1544
|
-
}
|
|
1545
|
-
/**
|
|
1546
|
-
* @internal
|
|
1547
|
-
*/
|
|
1548
|
-
function createPTTL(key) {
|
|
1549
|
-
return createCommand(RequestType.PTTL, [key]);
|
|
1550
|
-
}
|
|
1551
|
-
/**
|
|
1552
|
-
* @internal
|
|
1553
|
-
*/
|
|
1554
|
-
function createZRemRangeByRank(key, start, end) {
|
|
1555
|
-
return createCommand(RequestType.ZRemRangeByRank, [
|
|
1556
|
-
key,
|
|
1557
|
-
start.toString(),
|
|
1558
|
-
end.toString(),
|
|
1559
|
-
]);
|
|
1560
|
-
}
|
|
1561
|
-
/**
|
|
1562
|
-
* @internal
|
|
1563
|
-
*/
|
|
1564
|
-
function createZRemRangeByLex(key, minLex, maxLex) {
|
|
1565
|
-
const args = [key, getLexBoundaryArg(minLex), getLexBoundaryArg(maxLex)];
|
|
1566
|
-
return createCommand(RequestType.ZRemRangeByLex, args);
|
|
1567
|
-
}
|
|
1568
|
-
/**
|
|
1569
|
-
* @internal
|
|
1570
|
-
*/
|
|
1571
|
-
function createZRemRangeByScore(key, minScore, maxScore) {
|
|
1572
|
-
const args = [
|
|
1573
|
-
key,
|
|
1574
|
-
getScoreBoundaryArg(minScore),
|
|
1575
|
-
getScoreBoundaryArg(maxScore),
|
|
1576
|
-
];
|
|
1577
|
-
return createCommand(RequestType.ZRemRangeByScore, args);
|
|
1578
|
-
}
|
|
1579
|
-
/** @internal */
|
|
1580
|
-
function createPersist(key) {
|
|
1581
|
-
return createCommand(RequestType.Persist, [key]);
|
|
1582
|
-
}
|
|
1583
|
-
/**
|
|
1584
|
-
* @internal
|
|
1585
|
-
*/
|
|
1586
|
-
function createZLexCount(key, minLex, maxLex) {
|
|
1587
|
-
const args = [key, getLexBoundaryArg(minLex), getLexBoundaryArg(maxLex)];
|
|
1588
|
-
return createCommand(RequestType.ZLexCount, args);
|
|
1589
|
-
}
|
|
1590
|
-
/** @internal */
|
|
1591
|
-
function createZRank(key, member, withScores) {
|
|
1592
|
-
const args = [key, member];
|
|
1593
|
-
if (withScores) {
|
|
1594
|
-
args.push("WITHSCORE");
|
|
1595
|
-
}
|
|
1596
|
-
return createCommand(RequestType.ZRank, args);
|
|
1597
|
-
}
|
|
1598
|
-
function addTrimOptions(options, args) {
|
|
1599
|
-
if (options.method === "maxlen") {
|
|
1600
|
-
args.push("MAXLEN");
|
|
1601
|
-
}
|
|
1602
|
-
else if (options.method === "minid") {
|
|
1603
|
-
args.push("MINID");
|
|
1604
|
-
}
|
|
1605
|
-
if (options.exact) {
|
|
1606
|
-
args.push("=");
|
|
1607
|
-
}
|
|
1608
|
-
else {
|
|
1609
|
-
args.push("~");
|
|
1610
|
-
}
|
|
1611
|
-
if (options.method === "maxlen") {
|
|
1612
|
-
args.push(options.threshold.toString());
|
|
1613
|
-
}
|
|
1614
|
-
else if (options.method === "minid") {
|
|
1615
|
-
args.push(options.threshold);
|
|
1616
|
-
}
|
|
1617
|
-
if (options.limit) {
|
|
1618
|
-
args.push("LIMIT");
|
|
1619
|
-
args.push(options.limit.toString());
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
/**
|
|
1623
|
-
* @internal
|
|
1624
|
-
*/
|
|
1625
|
-
function createXAdd(key, values, options) {
|
|
1626
|
-
const args = [key];
|
|
1627
|
-
if ((options === null || options === void 0 ? void 0 : options.makeStream) === false) {
|
|
1628
|
-
args.push("NOMKSTREAM");
|
|
1629
|
-
}
|
|
1630
|
-
if (options === null || options === void 0 ? void 0 : options.trim) {
|
|
1631
|
-
addTrimOptions(options.trim, args);
|
|
1632
|
-
}
|
|
1633
|
-
if (options === null || options === void 0 ? void 0 : options.id) {
|
|
1634
|
-
args.push(options.id);
|
|
1635
|
-
}
|
|
1636
|
-
else {
|
|
1637
|
-
args.push("*");
|
|
1638
|
-
}
|
|
1639
|
-
values.forEach(([field, value]) => {
|
|
1640
|
-
args.push(field);
|
|
1641
|
-
args.push(value);
|
|
1642
|
-
});
|
|
1643
|
-
return createCommand(RequestType.XAdd, args);
|
|
1644
|
-
}
|
|
1645
|
-
/**
|
|
1646
|
-
* @internal
|
|
1647
|
-
*/
|
|
1648
|
-
function createXDel(key, ids) {
|
|
1649
|
-
return createCommand(RequestType.XDel, [key, ...ids]);
|
|
1650
|
-
}
|
|
1651
|
-
/**
|
|
1652
|
-
* @internal
|
|
1653
|
-
*/
|
|
1654
|
-
function createXTrim(key, options) {
|
|
1655
|
-
const args = [key];
|
|
1656
|
-
addTrimOptions(options, args);
|
|
1657
|
-
return createCommand(RequestType.XTrim, args);
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* @internal
|
|
1661
|
-
*/
|
|
1662
|
-
function createXRange(key, start, end, count) {
|
|
1663
|
-
const args = [key, getStreamBoundaryArg(start), getStreamBoundaryArg(end)];
|
|
1664
|
-
if (count !== undefined) {
|
|
1665
|
-
args.push("COUNT");
|
|
1666
|
-
args.push(count.toString());
|
|
1667
|
-
}
|
|
1668
|
-
return createCommand(RequestType.XRange, args);
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* @internal
|
|
1672
|
-
*/
|
|
1673
|
-
function createXRevRange(key, start, end, count) {
|
|
1674
|
-
const args = [key, getStreamBoundaryArg(start), getStreamBoundaryArg(end)];
|
|
1675
|
-
if (count !== undefined) {
|
|
1676
|
-
args.push("COUNT");
|
|
1677
|
-
args.push(count.toString());
|
|
1678
|
-
}
|
|
1679
|
-
return createCommand(RequestType.XRevRange, args);
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* @internal
|
|
1683
|
-
*/
|
|
1684
|
-
function createXGroupCreateConsumer(key, groupName, consumerName) {
|
|
1685
|
-
return createCommand(RequestType.XGroupCreateConsumer, [
|
|
1686
|
-
key,
|
|
1687
|
-
groupName,
|
|
1688
|
-
consumerName,
|
|
1689
|
-
]);
|
|
1690
|
-
}
|
|
1691
|
-
/**
|
|
1692
|
-
* @internal
|
|
1693
|
-
*/
|
|
1694
|
-
function createXGroupDelConsumer(key, groupName, consumerName) {
|
|
1695
|
-
return createCommand(RequestType.XGroupDelConsumer, [
|
|
1696
|
-
key,
|
|
1697
|
-
groupName,
|
|
1698
|
-
consumerName,
|
|
1699
|
-
]);
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* @internal
|
|
1703
|
-
*/
|
|
1704
|
-
function createTime() {
|
|
1705
|
-
return createCommand(RequestType.Time, []);
|
|
1706
|
-
}
|
|
1707
|
-
/**
|
|
1708
|
-
* @internal
|
|
1709
|
-
*/
|
|
1710
|
-
function createPublish(message, channel, sharded = false) {
|
|
1711
|
-
const request = sharded ? RequestType.SPublish : RequestType.Publish;
|
|
1712
|
-
return createCommand(request, [channel, message]);
|
|
1713
|
-
}
|
|
1714
|
-
/**
|
|
1715
|
-
* @internal
|
|
1716
|
-
*/
|
|
1717
|
-
function createBRPop(keys, timeout) {
|
|
1718
|
-
const args = [...keys, timeout.toString()];
|
|
1719
|
-
return createCommand(RequestType.BRPop, args);
|
|
1720
|
-
}
|
|
1721
|
-
/**
|
|
1722
|
-
* @internal
|
|
1723
|
-
*/
|
|
1724
|
-
function createBLPop(keys, timeout) {
|
|
1725
|
-
const args = [...keys, timeout.toString()];
|
|
1726
|
-
return createCommand(RequestType.BLPop, args);
|
|
1727
|
-
}
|
|
1728
|
-
/**
|
|
1729
|
-
* @internal
|
|
1730
|
-
*/
|
|
1731
|
-
function createFCall(func, keys, args) {
|
|
1732
|
-
const params = [
|
|
1733
|
-
func,
|
|
1734
|
-
keys.length.toString(),
|
|
1735
|
-
...keys,
|
|
1736
|
-
...args,
|
|
1737
|
-
];
|
|
1738
|
-
return createCommand(RequestType.FCall, params);
|
|
1739
|
-
}
|
|
1740
|
-
/**
|
|
1741
|
-
* @internal
|
|
1742
|
-
*/
|
|
1743
|
-
function createFCallReadOnly(func, keys, args) {
|
|
1744
|
-
const params = [
|
|
1745
|
-
func,
|
|
1746
|
-
keys.length.toString(),
|
|
1747
|
-
...keys,
|
|
1748
|
-
...args,
|
|
1749
|
-
];
|
|
1750
|
-
return createCommand(RequestType.FCallReadOnly, params);
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* @internal
|
|
1754
|
-
*/
|
|
1755
|
-
function createFunctionDelete(libraryCode) {
|
|
1756
|
-
return createCommand(RequestType.FunctionDelete, [libraryCode]);
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* @internal
|
|
1760
|
-
*/
|
|
1761
|
-
function createFunctionFlush(mode) {
|
|
1762
|
-
if (mode) {
|
|
1763
|
-
return createCommand(RequestType.FunctionFlush, [mode.toString()]);
|
|
1764
|
-
}
|
|
1765
|
-
else {
|
|
1766
|
-
return createCommand(RequestType.FunctionFlush, []);
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
/**
|
|
1770
|
-
* @internal
|
|
1771
|
-
*/
|
|
1772
|
-
function createFunctionLoad(libraryCode, replace) {
|
|
1773
|
-
const args = replace ? ["REPLACE", libraryCode] : [libraryCode];
|
|
1774
|
-
return createCommand(RequestType.FunctionLoad, args);
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
* @internal
|
|
1778
|
-
*/
|
|
1779
|
-
function createFunctionList(options) {
|
|
1780
|
-
const args = [];
|
|
1781
|
-
if (options) {
|
|
1782
|
-
if (options.libNamePattern) {
|
|
1783
|
-
args.push("LIBRARYNAME", options.libNamePattern);
|
|
1784
|
-
}
|
|
1785
|
-
if (options.withCode) {
|
|
1786
|
-
args.push("WITHCODE");
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
return createCommand(RequestType.FunctionList, args);
|
|
1790
|
-
}
|
|
1791
|
-
/** @internal */
|
|
1792
|
-
function createFunctionStats() {
|
|
1793
|
-
return createCommand(RequestType.FunctionStats, []);
|
|
1794
|
-
}
|
|
1795
|
-
/** @internal */
|
|
1796
|
-
function createFunctionKill() {
|
|
1797
|
-
return createCommand(RequestType.FunctionKill, []);
|
|
1798
|
-
}
|
|
1799
|
-
/** @internal */
|
|
1800
|
-
function createFunctionDump() {
|
|
1801
|
-
return createCommand(RequestType.FunctionDump, []);
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Option for `FUNCTION RESTORE` command: {@link GlideClient.functionRestore} and
|
|
1805
|
-
* {@link GlideClusterClient.functionRestore}.
|
|
1806
|
-
*
|
|
1807
|
-
* @see {@link https://valkey.io/commands/function-restore/"|valkey.io} for more details.
|
|
1808
|
-
*/
|
|
1809
|
-
var FunctionRestorePolicy;
|
|
1810
|
-
(function (FunctionRestorePolicy) {
|
|
1811
|
-
/**
|
|
1812
|
-
* Appends the restored libraries to the existing libraries and aborts on collision. This is the
|
|
1813
|
-
* default policy.
|
|
1814
|
-
*/
|
|
1815
|
-
FunctionRestorePolicy["APPEND"] = "APPEND";
|
|
1816
|
-
/** Deletes all existing libraries before restoring the payload. */
|
|
1817
|
-
FunctionRestorePolicy["FLUSH"] = "FLUSH";
|
|
1818
|
-
/**
|
|
1819
|
-
* Appends the restored libraries to the existing libraries, replacing any existing ones in case
|
|
1820
|
-
* of name collisions. Note that this policy doesn't prevent function name collisions, only
|
|
1821
|
-
* libraries.
|
|
1822
|
-
*/
|
|
1823
|
-
FunctionRestorePolicy["REPLACE"] = "REPLACE";
|
|
1824
|
-
})(FunctionRestorePolicy || (exports.FunctionRestorePolicy = FunctionRestorePolicy = {}));
|
|
1825
|
-
/** @internal */
|
|
1826
|
-
function createFunctionRestore(data, policy) {
|
|
1827
|
-
return createCommand(RequestType.FunctionRestore, policy ? [data, policy] : [data]);
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* @internal
|
|
1831
|
-
*/
|
|
1832
|
-
function convertBitOptionsToArgs(options) {
|
|
1833
|
-
const args = [];
|
|
1834
|
-
if (!options)
|
|
1835
|
-
return args;
|
|
1836
|
-
args.push(options.start.toString());
|
|
1837
|
-
if (options.end !== undefined) {
|
|
1838
|
-
args.push(options.end.toString());
|
|
1839
|
-
if (options.indexType)
|
|
1840
|
-
args.push(options.indexType);
|
|
1841
|
-
}
|
|
1842
|
-
return args;
|
|
1843
|
-
}
|
|
1844
|
-
/**
|
|
1845
|
-
* @internal
|
|
1846
|
-
*/
|
|
1847
|
-
function createBitCount(key, options) {
|
|
1848
|
-
let args = [key];
|
|
1849
|
-
if (options) {
|
|
1850
|
-
const optionResults = convertBitOptionsToArgs(options);
|
|
1851
|
-
args = args.concat(optionResults);
|
|
1852
|
-
}
|
|
1853
|
-
return createCommand(RequestType.BitCount, args);
|
|
1854
|
-
}
|
|
1855
|
-
/**
|
|
1856
|
-
* Enumeration specifying if index arguments are BYTE indexes or BIT indexes.
|
|
1857
|
-
* Can be specified in {@link BitOffsetOptions}, which is an optional argument to the {@link BaseClient.bitcount|bitcount} command.
|
|
1858
|
-
* Can also be specified as an optional argument to the {@link BaseClient.bitposInverval|bitposInterval} command.
|
|
1859
|
-
*
|
|
1860
|
-
* since - Valkey version 7.0.0.
|
|
1861
|
-
*/
|
|
1862
|
-
var BitmapIndexType;
|
|
1863
|
-
(function (BitmapIndexType) {
|
|
1864
|
-
/** Specifies that provided indexes are byte indexes. */
|
|
1865
|
-
BitmapIndexType["BYTE"] = "BYTE";
|
|
1866
|
-
/** Specifies that provided indexes are bit indexes. */
|
|
1867
|
-
BitmapIndexType["BIT"] = "BIT";
|
|
1868
|
-
})(BitmapIndexType || (exports.BitmapIndexType = BitmapIndexType = {}));
|
|
1869
|
-
/**
|
|
1870
|
-
* @internal
|
|
1871
|
-
*/
|
|
1872
|
-
function createBitPos(key, bit, options) {
|
|
1873
|
-
const args = [
|
|
1874
|
-
key,
|
|
1875
|
-
bit.toString(),
|
|
1876
|
-
...convertBitOptionsToArgs(options),
|
|
1877
|
-
];
|
|
1878
|
-
return createCommand(RequestType.BitPos, args);
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* Defines flushing mode for {@link GlideClient.flushall}, {@link GlideClusterClient.flushall},
|
|
1882
|
-
* {@link GlideClient.functionFlush}, {@link GlideClusterClient.functionFlush},
|
|
1883
|
-
* {@link GlideClient.flushdb} and {@link GlideClusterClient.flushdb} commands.
|
|
1884
|
-
*
|
|
1885
|
-
* See https://valkey.io/commands/flushall/ and https://valkey.io/commands/flushdb/ for details.
|
|
1886
|
-
*/
|
|
1887
|
-
var FlushMode;
|
|
1888
|
-
(function (FlushMode) {
|
|
1889
|
-
/**
|
|
1890
|
-
* Flushes synchronously.
|
|
1891
|
-
*
|
|
1892
|
-
* since Valkey version 6.2.0.
|
|
1893
|
-
*/
|
|
1894
|
-
FlushMode["SYNC"] = "SYNC";
|
|
1895
|
-
/** Flushes asynchronously. */
|
|
1896
|
-
FlushMode["ASYNC"] = "ASYNC";
|
|
1897
|
-
})(FlushMode || (exports.FlushMode = FlushMode = {}));
|
|
1898
|
-
/**
|
|
1899
|
-
* @internal
|
|
1900
|
-
* This function converts an input from Record or GlideRecord types to GlideRecord.
|
|
1901
|
-
*
|
|
1902
|
-
* @param record - input record in either Record or GlideRecord types.
|
|
1903
|
-
* @returns same data in GlideRecord type.
|
|
1904
|
-
*/
|
|
1905
|
-
function convertKeysAndEntries(record) {
|
|
1906
|
-
if (!Array.isArray(record)) {
|
|
1907
|
-
return (0, BaseClient_1.convertRecordToGlideRecord)(record);
|
|
1908
|
-
}
|
|
1909
|
-
return record;
|
|
1910
|
-
}
|
|
1911
|
-
/** @internal */
|
|
1912
|
-
function addReadOptions(options) {
|
|
1913
|
-
const args = [];
|
|
1914
|
-
if ((options === null || options === void 0 ? void 0 : options.count) !== undefined) {
|
|
1915
|
-
args.push("COUNT");
|
|
1916
|
-
args.push(options.count.toString());
|
|
1917
|
-
}
|
|
1918
|
-
if ((options === null || options === void 0 ? void 0 : options.block) !== undefined) {
|
|
1919
|
-
args.push("BLOCK");
|
|
1920
|
-
args.push(options.block.toString());
|
|
1921
|
-
}
|
|
1922
|
-
return args;
|
|
1923
|
-
}
|
|
1924
|
-
/** @internal */
|
|
1925
|
-
function addStreamsArgs(keys_and_ids) {
|
|
1926
|
-
return [
|
|
1927
|
-
"STREAMS",
|
|
1928
|
-
...keys_and_ids.map((e) => e.key),
|
|
1929
|
-
...keys_and_ids.map((e) => e.value),
|
|
1930
|
-
];
|
|
1931
|
-
}
|
|
1932
|
-
/**
|
|
1933
|
-
* @internal
|
|
1934
|
-
*/
|
|
1935
|
-
function createXRead(keys_and_ids, options) {
|
|
1936
|
-
const args = addReadOptions(options);
|
|
1937
|
-
args.push(...addStreamsArgs(keys_and_ids));
|
|
1938
|
-
return createCommand(RequestType.XRead, args);
|
|
1939
|
-
}
|
|
1940
|
-
/** @internal */
|
|
1941
|
-
function createXReadGroup(group, consumer, keys_and_ids, options) {
|
|
1942
|
-
const args = ["GROUP", group, consumer];
|
|
1943
|
-
if (options) {
|
|
1944
|
-
args.push(...addReadOptions(options));
|
|
1945
|
-
if (options.noAck)
|
|
1946
|
-
args.push("NOACK");
|
|
1947
|
-
}
|
|
1948
|
-
args.push(...addStreamsArgs(keys_and_ids));
|
|
1949
|
-
return createCommand(RequestType.XReadGroup, args);
|
|
1950
|
-
}
|
|
1951
|
-
/**
|
|
1952
|
-
* @internal
|
|
1953
|
-
*/
|
|
1954
|
-
function createXInfoStream(key, options) {
|
|
1955
|
-
const args = [key];
|
|
1956
|
-
if (options != false) {
|
|
1957
|
-
args.push("FULL");
|
|
1958
|
-
if (typeof options === "number") {
|
|
1959
|
-
args.push("COUNT");
|
|
1960
|
-
args.push(options.toString());
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
return createCommand(RequestType.XInfoStream, args);
|
|
1964
|
-
}
|
|
1965
|
-
/** @internal */
|
|
1966
|
-
function createXInfoGroups(key) {
|
|
1967
|
-
return createCommand(RequestType.XInfoGroups, [key]);
|
|
1968
|
-
}
|
|
1969
|
-
/**
|
|
1970
|
-
* @internal
|
|
1971
|
-
*/
|
|
1972
|
-
function createXLen(key) {
|
|
1973
|
-
return createCommand(RequestType.XLen, [key]);
|
|
1974
|
-
}
|
|
1975
|
-
/** @internal */
|
|
1976
|
-
function createXPending(key, group, options) {
|
|
1977
|
-
const args = [key, group];
|
|
1978
|
-
if (options) {
|
|
1979
|
-
if (options.minIdleTime !== undefined)
|
|
1980
|
-
args.push("IDLE", options.minIdleTime.toString());
|
|
1981
|
-
args.push(getStreamBoundaryArg(options.start), getStreamBoundaryArg(options.end), options.count.toString());
|
|
1982
|
-
if (options.consumer)
|
|
1983
|
-
args.push(options.consumer);
|
|
1984
|
-
}
|
|
1985
|
-
return createCommand(RequestType.XPending, args);
|
|
1986
|
-
}
|
|
1987
|
-
/** @internal */
|
|
1988
|
-
function createXInfoConsumers(key, group) {
|
|
1989
|
-
return createCommand(RequestType.XInfoConsumers, [key, group]);
|
|
1990
|
-
}
|
|
1991
|
-
/** @internal */
|
|
1992
|
-
function createXClaim(key, group, consumer, minIdleTime, ids, options, justId) {
|
|
1993
|
-
const args = [key, group, consumer, minIdleTime.toString(), ...ids];
|
|
1994
|
-
if (options) {
|
|
1995
|
-
if (options.idle !== undefined)
|
|
1996
|
-
args.push("IDLE", options.idle.toString());
|
|
1997
|
-
if (options.idleUnixTime !== undefined)
|
|
1998
|
-
args.push("TIME", options.idleUnixTime.toString());
|
|
1999
|
-
if (options.retryCount !== undefined)
|
|
2000
|
-
args.push("RETRYCOUNT", options.retryCount.toString());
|
|
2001
|
-
if (options.isForce)
|
|
2002
|
-
args.push("FORCE");
|
|
2003
|
-
}
|
|
2004
|
-
if (justId)
|
|
2005
|
-
args.push("JUSTID");
|
|
2006
|
-
return createCommand(RequestType.XClaim, args);
|
|
2007
|
-
}
|
|
2008
|
-
/** @internal */
|
|
2009
|
-
function createXAutoClaim(key, group, consumer, minIdleTime, start, count, justId) {
|
|
2010
|
-
const args = [
|
|
2011
|
-
key,
|
|
2012
|
-
group,
|
|
2013
|
-
consumer,
|
|
2014
|
-
minIdleTime.toString(),
|
|
2015
|
-
start.toString(),
|
|
2016
|
-
];
|
|
2017
|
-
if (count !== undefined)
|
|
2018
|
-
args.push("COUNT", count.toString());
|
|
2019
|
-
if (justId)
|
|
2020
|
-
args.push("JUSTID");
|
|
2021
|
-
return createCommand(RequestType.XAutoClaim, args);
|
|
2022
|
-
}
|
|
2023
|
-
/**
|
|
2024
|
-
* @internal
|
|
2025
|
-
*/
|
|
2026
|
-
function createXGroupCreate(key, groupName, id, options) {
|
|
2027
|
-
const args = [key, groupName, id];
|
|
2028
|
-
if (options) {
|
|
2029
|
-
if (options.mkStream) {
|
|
2030
|
-
args.push("MKSTREAM");
|
|
2031
|
-
}
|
|
2032
|
-
if (options.entriesRead) {
|
|
2033
|
-
args.push("ENTRIESREAD");
|
|
2034
|
-
args.push(options.entriesRead);
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
return createCommand(RequestType.XGroupCreate, args);
|
|
2038
|
-
}
|
|
2039
|
-
/**
|
|
2040
|
-
* @internal
|
|
2041
|
-
*/
|
|
2042
|
-
function createXGroupDestroy(key, groupName) {
|
|
2043
|
-
return createCommand(RequestType.XGroupDestroy, [key, groupName]);
|
|
2044
|
-
}
|
|
2045
|
-
/**
|
|
2046
|
-
* @internal
|
|
2047
|
-
*/
|
|
2048
|
-
function createRename(key, newKey) {
|
|
2049
|
-
return createCommand(RequestType.Rename, [key, newKey]);
|
|
2050
|
-
}
|
|
2051
|
-
/**
|
|
2052
|
-
* @internal
|
|
2053
|
-
*/
|
|
2054
|
-
function createRenameNX(key, newKey) {
|
|
2055
|
-
return createCommand(RequestType.RenameNX, [key, newKey]);
|
|
2056
|
-
}
|
|
2057
|
-
/**
|
|
2058
|
-
* @internal
|
|
2059
|
-
*/
|
|
2060
|
-
function createPfAdd(key, elements) {
|
|
2061
|
-
const args = [key, ...elements];
|
|
2062
|
-
return createCommand(RequestType.PfAdd, args);
|
|
2063
|
-
}
|
|
2064
|
-
/**
|
|
2065
|
-
* @internal
|
|
2066
|
-
*/
|
|
2067
|
-
function createPfCount(keys) {
|
|
2068
|
-
return createCommand(RequestType.PfCount, keys);
|
|
2069
|
-
}
|
|
2070
|
-
/**
|
|
2071
|
-
* @internal
|
|
2072
|
-
*/
|
|
2073
|
-
function createPfMerge(destination, sourceKey) {
|
|
2074
|
-
return createCommand(RequestType.PfMerge, [destination, ...sourceKey]);
|
|
2075
|
-
}
|
|
2076
|
-
/**
|
|
2077
|
-
* @internal
|
|
2078
|
-
*/
|
|
2079
|
-
function createObjectEncoding(key) {
|
|
2080
|
-
return createCommand(RequestType.ObjectEncoding, [key]);
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* @internal
|
|
2084
|
-
*/
|
|
2085
|
-
function createObjectFreq(key) {
|
|
2086
|
-
return createCommand(RequestType.ObjectFreq, [key]);
|
|
2087
|
-
}
|
|
2088
|
-
/**
|
|
2089
|
-
* @internal
|
|
2090
|
-
*/
|
|
2091
|
-
function createObjectIdletime(key) {
|
|
2092
|
-
return createCommand(RequestType.ObjectIdleTime, [key]);
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
* @internal
|
|
2096
|
-
*/
|
|
2097
|
-
function createObjectRefcount(key) {
|
|
2098
|
-
return createCommand(RequestType.ObjectRefCount, [key]);
|
|
2099
|
-
}
|
|
2100
|
-
/**
|
|
2101
|
-
* @internal
|
|
2102
|
-
*/
|
|
2103
|
-
function createLolwut(options) {
|
|
2104
|
-
const args = [];
|
|
2105
|
-
if (options) {
|
|
2106
|
-
if (options.version !== undefined) {
|
|
2107
|
-
args.push("VERSION", options.version.toString());
|
|
2108
|
-
}
|
|
2109
|
-
if (options.parameters !== undefined) {
|
|
2110
|
-
args.push(...options.parameters.map((param) => param.toString()));
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
return createCommand(RequestType.Lolwut, args);
|
|
2114
|
-
}
|
|
2115
|
-
/**
|
|
2116
|
-
* @internal
|
|
2117
|
-
*/
|
|
2118
|
-
function createFlushAll(mode) {
|
|
2119
|
-
if (mode) {
|
|
2120
|
-
return createCommand(RequestType.FlushAll, [mode.toString()]);
|
|
2121
|
-
}
|
|
2122
|
-
else {
|
|
2123
|
-
return createCommand(RequestType.FlushAll, []);
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
/**
|
|
2127
|
-
* @internal
|
|
2128
|
-
*/
|
|
2129
|
-
function createFlushDB(mode) {
|
|
2130
|
-
if (mode) {
|
|
2131
|
-
return createCommand(RequestType.FlushDB, [mode.toString()]);
|
|
2132
|
-
}
|
|
2133
|
-
else {
|
|
2134
|
-
return createCommand(RequestType.FlushDB, []);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
/**
|
|
2138
|
-
* @internal
|
|
2139
|
-
*/
|
|
2140
|
-
function createCopy(source, destination, options) {
|
|
2141
|
-
let args = [source, destination];
|
|
2142
|
-
if (options) {
|
|
2143
|
-
if (options.destinationDB !== undefined) {
|
|
2144
|
-
args = args.concat("DB", options.destinationDB.toString());
|
|
2145
|
-
}
|
|
2146
|
-
if (options.replace) {
|
|
2147
|
-
args.push("REPLACE");
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
return createCommand(RequestType.Copy, args);
|
|
2151
|
-
}
|
|
2152
|
-
/**
|
|
2153
|
-
* @internal
|
|
2154
|
-
*/
|
|
2155
|
-
function createMove(key, dbIndex) {
|
|
2156
|
-
return createCommand(RequestType.Move, [key, dbIndex.toString()]);
|
|
2157
|
-
}
|
|
2158
|
-
/**
|
|
2159
|
-
* @internal
|
|
2160
|
-
*/
|
|
2161
|
-
function createDump(key) {
|
|
2162
|
-
return createCommand(RequestType.Dump, [key]);
|
|
2163
|
-
}
|
|
2164
|
-
/**
|
|
2165
|
-
* @internal
|
|
2166
|
-
*/
|
|
2167
|
-
function createRestore(key, ttl, value, options) {
|
|
2168
|
-
const args = [key, ttl.toString(), value];
|
|
2169
|
-
if (options) {
|
|
2170
|
-
if (options.idletime !== undefined && options.frequency !== undefined) {
|
|
2171
|
-
throw new Error(`syntax error: both IDLETIME and FREQ cannot be set at the same time.`);
|
|
2172
|
-
}
|
|
2173
|
-
if (options.replace) {
|
|
2174
|
-
args.push("REPLACE");
|
|
2175
|
-
}
|
|
2176
|
-
if (options.absttl) {
|
|
2177
|
-
args.push("ABSTTL");
|
|
2178
|
-
}
|
|
2179
|
-
if (options.idletime !== undefined) {
|
|
2180
|
-
args.push("IDLETIME", options.idletime.toString());
|
|
2181
|
-
}
|
|
2182
|
-
if (options.frequency !== undefined) {
|
|
2183
|
-
args.push("FREQ", options.frequency.toString());
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
return createCommand(RequestType.Restore, args);
|
|
2187
|
-
}
|
|
2188
|
-
/**
|
|
2189
|
-
* @internal
|
|
2190
|
-
*/
|
|
2191
|
-
function createLPos(key, element, options) {
|
|
2192
|
-
const args = [key, element];
|
|
2193
|
-
if (options) {
|
|
2194
|
-
if (options.rank !== undefined) {
|
|
2195
|
-
args.push("RANK");
|
|
2196
|
-
args.push(options.rank.toString());
|
|
2197
|
-
}
|
|
2198
|
-
if (options.count !== undefined) {
|
|
2199
|
-
args.push("COUNT");
|
|
2200
|
-
args.push(options.count.toString());
|
|
2201
|
-
}
|
|
2202
|
-
if (options.maxLength !== undefined) {
|
|
2203
|
-
args.push("MAXLEN");
|
|
2204
|
-
args.push(options.maxLength.toString());
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
return createCommand(RequestType.LPos, args);
|
|
2208
|
-
}
|
|
2209
|
-
/**
|
|
2210
|
-
* @internal
|
|
2211
|
-
*/
|
|
2212
|
-
function createDBSize() {
|
|
2213
|
-
return createCommand(RequestType.DBSize, []);
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* An optional condition to the {@link BaseClient.geoadd | geoadd},
|
|
2217
|
-
* {@link BaseClient.zadd | zadd} and {@link BaseClient.set | set} commands.
|
|
2218
|
-
*/
|
|
2219
|
-
var ConditionalChange;
|
|
2220
|
-
(function (ConditionalChange) {
|
|
2221
|
-
/**
|
|
2222
|
-
* Only update elements that already exist. Don't add new elements. Equivalent to `XX` in the Valkey API.
|
|
2223
|
-
*/
|
|
2224
|
-
ConditionalChange["ONLY_IF_EXISTS"] = "XX";
|
|
2225
|
-
/**
|
|
2226
|
-
* Only add new elements. Don't update already existing elements. Equivalent to `NX` in the Valkey API.
|
|
2227
|
-
*/
|
|
2228
|
-
ConditionalChange["ONLY_IF_DOES_NOT_EXIST"] = "NX";
|
|
2229
|
-
})(ConditionalChange || (exports.ConditionalChange = ConditionalChange = {}));
|
|
2230
|
-
/**
|
|
2231
|
-
* @internal
|
|
2232
|
-
*/
|
|
2233
|
-
function createGeoAdd(key, membersToGeospatialData, options) {
|
|
2234
|
-
let args = [key];
|
|
2235
|
-
if (options) {
|
|
2236
|
-
if (options.updateMode) {
|
|
2237
|
-
args.push(options.updateMode);
|
|
2238
|
-
}
|
|
2239
|
-
if (options.changed) {
|
|
2240
|
-
args.push("CH");
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
membersToGeospatialData.forEach((coord, member) => {
|
|
2244
|
-
args = args.concat(coord.longitude.toString(), coord.latitude.toString(), member);
|
|
2245
|
-
});
|
|
2246
|
-
return createCommand(RequestType.GeoAdd, args);
|
|
2247
|
-
}
|
|
2248
|
-
/** Enumeration representing distance units options. */
|
|
2249
|
-
var GeoUnit;
|
|
2250
|
-
(function (GeoUnit) {
|
|
2251
|
-
/** Represents distance in meters. */
|
|
2252
|
-
GeoUnit["METERS"] = "m";
|
|
2253
|
-
/** Represents distance in kilometers. */
|
|
2254
|
-
GeoUnit["KILOMETERS"] = "km";
|
|
2255
|
-
/** Represents distance in miles. */
|
|
2256
|
-
GeoUnit["MILES"] = "mi";
|
|
2257
|
-
/** Represents distance in feet. */
|
|
2258
|
-
GeoUnit["FEET"] = "ft";
|
|
2259
|
-
})(GeoUnit || (exports.GeoUnit = GeoUnit = {}));
|
|
2260
|
-
/**
|
|
2261
|
-
* @internal
|
|
2262
|
-
*/
|
|
2263
|
-
function createGeoPos(key, members) {
|
|
2264
|
-
return createCommand(RequestType.GeoPos, [key].concat(members));
|
|
2265
|
-
}
|
|
2266
|
-
/**
|
|
2267
|
-
* @internal
|
|
2268
|
-
*/
|
|
2269
|
-
function createGeoDist(key, member1, member2, geoUnit) {
|
|
2270
|
-
const args = [key, member1, member2];
|
|
2271
|
-
if (geoUnit) {
|
|
2272
|
-
args.push(geoUnit);
|
|
2273
|
-
}
|
|
2274
|
-
return createCommand(RequestType.GeoDist, args);
|
|
2275
|
-
}
|
|
2276
|
-
/**
|
|
2277
|
-
* @internal
|
|
2278
|
-
*/
|
|
2279
|
-
function createGeoHash(key, members) {
|
|
2280
|
-
const args = [key].concat(members);
|
|
2281
|
-
return createCommand(RequestType.GeoHash, args);
|
|
2282
|
-
}
|
|
2283
|
-
/** Defines the sort order for nested results. */
|
|
2284
|
-
var SortOrder;
|
|
2285
|
-
(function (SortOrder) {
|
|
2286
|
-
/** Sort by ascending order. */
|
|
2287
|
-
SortOrder["ASC"] = "ASC";
|
|
2288
|
-
/** Sort by descending order. */
|
|
2289
|
-
SortOrder["DESC"] = "DESC";
|
|
2290
|
-
})(SortOrder || (exports.SortOrder = SortOrder = {}));
|
|
2291
|
-
/** @internal */
|
|
2292
|
-
function createGeoSearch(key, searchFrom, searchBy, resultOptions) {
|
|
2293
|
-
const args = [key].concat(convertGeoSearchOptionsToArgs(searchFrom, searchBy, resultOptions));
|
|
2294
|
-
return createCommand(RequestType.GeoSearch, args);
|
|
2295
|
-
}
|
|
2296
|
-
/** @internal */
|
|
2297
|
-
function createGeoSearchStore(destination, source, searchFrom, searchBy, resultOptions) {
|
|
2298
|
-
const args = [destination, source].concat(convertGeoSearchOptionsToArgs(searchFrom, searchBy, resultOptions));
|
|
2299
|
-
return createCommand(RequestType.GeoSearchStore, args);
|
|
2300
|
-
}
|
|
2301
|
-
function convertGeoSearchOptionsToArgs(searchFrom, searchBy, resultOptions) {
|
|
2302
|
-
var _a;
|
|
2303
|
-
let args = [];
|
|
2304
|
-
if ("position" in searchFrom) {
|
|
2305
|
-
args = args.concat("FROMLONLAT", searchFrom.position.longitude.toString(), searchFrom.position.latitude.toString());
|
|
2306
|
-
}
|
|
2307
|
-
else {
|
|
2308
|
-
args = args.concat("FROMMEMBER", searchFrom.member);
|
|
2309
|
-
}
|
|
2310
|
-
if ("radius" in searchBy) {
|
|
2311
|
-
args = args.concat("BYRADIUS", searchBy.radius.toString(), searchBy.unit);
|
|
2312
|
-
}
|
|
2313
|
-
else {
|
|
2314
|
-
args = args.concat("BYBOX", searchBy.width.toString(), searchBy.height.toString(), searchBy.unit);
|
|
2315
|
-
}
|
|
2316
|
-
if (resultOptions) {
|
|
2317
|
-
if ("withCoord" in resultOptions &&
|
|
2318
|
-
resultOptions.withCoord)
|
|
2319
|
-
args.push("WITHCOORD");
|
|
2320
|
-
if ("withDist" in resultOptions &&
|
|
2321
|
-
resultOptions.withDist)
|
|
2322
|
-
args.push("WITHDIST");
|
|
2323
|
-
if ("withHash" in resultOptions &&
|
|
2324
|
-
resultOptions.withHash)
|
|
2325
|
-
args.push("WITHHASH");
|
|
2326
|
-
if ("storeDist" in resultOptions &&
|
|
2327
|
-
resultOptions.storeDist)
|
|
2328
|
-
args.push("STOREDIST");
|
|
2329
|
-
if (resultOptions.count) {
|
|
2330
|
-
args.push("COUNT", (_a = resultOptions.count) === null || _a === void 0 ? void 0 : _a.toString());
|
|
2331
|
-
if (resultOptions.isAny)
|
|
2332
|
-
args.push("ANY");
|
|
2333
|
-
}
|
|
2334
|
-
if (resultOptions.sortOrder)
|
|
2335
|
-
args.push(resultOptions.sortOrder);
|
|
2336
|
-
}
|
|
2337
|
-
return args;
|
|
2338
|
-
}
|
|
2339
|
-
/**
|
|
2340
|
-
* @internal
|
|
2341
|
-
*/
|
|
2342
|
-
function createZRevRank(key, member) {
|
|
2343
|
-
return createCommand(RequestType.ZRevRank, [key, member]);
|
|
2344
|
-
}
|
|
2345
|
-
/**
|
|
2346
|
-
* @internal
|
|
2347
|
-
*/
|
|
2348
|
-
function createZRevRankWithScore(key, member) {
|
|
2349
|
-
return createCommand(RequestType.ZRevRank, [key, member, "WITHSCORE"]);
|
|
2350
|
-
}
|
|
2351
|
-
/**
|
|
2352
|
-
* Mandatory option for zmpop.
|
|
2353
|
-
* Defines which elements to pop from the sorted set.
|
|
2354
|
-
*/
|
|
2355
|
-
var ScoreFilter;
|
|
2356
|
-
(function (ScoreFilter) {
|
|
2357
|
-
/** Pop elements with the highest scores. */
|
|
2358
|
-
ScoreFilter["MAX"] = "MAX";
|
|
2359
|
-
/** Pop elements with the lowest scores. */
|
|
2360
|
-
ScoreFilter["MIN"] = "MIN";
|
|
2361
|
-
})(ScoreFilter || (exports.ScoreFilter = ScoreFilter = {}));
|
|
2362
|
-
/**
|
|
2363
|
-
* @internal
|
|
2364
|
-
*/
|
|
2365
|
-
function createZMPop(keys, modifier, count) {
|
|
2366
|
-
const args = keys;
|
|
2367
|
-
args.unshift(keys.length.toString());
|
|
2368
|
-
args.push(modifier);
|
|
2369
|
-
if (count !== undefined) {
|
|
2370
|
-
args.push("COUNT");
|
|
2371
|
-
args.push(count.toString());
|
|
2372
|
-
}
|
|
2373
|
-
return createCommand(RequestType.ZMPop, args);
|
|
2374
|
-
}
|
|
2375
|
-
/**
|
|
2376
|
-
* @internal
|
|
2377
|
-
*/
|
|
2378
|
-
function createBZMPop(keys, modifier, timeout, count) {
|
|
2379
|
-
const args = [
|
|
2380
|
-
timeout.toString(),
|
|
2381
|
-
keys.length.toString(),
|
|
2382
|
-
...keys,
|
|
2383
|
-
modifier,
|
|
2384
|
-
];
|
|
2385
|
-
if (count !== undefined) {
|
|
2386
|
-
args.push("COUNT");
|
|
2387
|
-
args.push(count.toString());
|
|
2388
|
-
}
|
|
2389
|
-
return createCommand(RequestType.BZMPop, args);
|
|
2390
|
-
}
|
|
2391
|
-
/**
|
|
2392
|
-
* @internal
|
|
2393
|
-
*/
|
|
2394
|
-
function createZIncrBy(key, increment, member) {
|
|
2395
|
-
return createCommand(RequestType.ZIncrBy, [
|
|
2396
|
-
key,
|
|
2397
|
-
increment.toString(),
|
|
2398
|
-
member,
|
|
2399
|
-
]);
|
|
2400
|
-
}
|
|
2401
|
-
/** @internal */
|
|
2402
|
-
function createSort(key, options, destination) {
|
|
2403
|
-
return createSortImpl(RequestType.Sort, key, options, destination);
|
|
2404
|
-
}
|
|
2405
|
-
/** @internal */
|
|
2406
|
-
function createSortReadOnly(key, options) {
|
|
2407
|
-
return createSortImpl(RequestType.SortReadOnly, key, options);
|
|
2408
|
-
}
|
|
2409
|
-
/** @internal */
|
|
2410
|
-
function createSortImpl(cmd, key, options, destination) {
|
|
2411
|
-
const args = [key];
|
|
2412
|
-
if (options) {
|
|
2413
|
-
if (options.limit) {
|
|
2414
|
-
args.push("LIMIT", options.limit.offset.toString(), options.limit.count.toString());
|
|
2415
|
-
}
|
|
2416
|
-
if (options.orderBy) {
|
|
2417
|
-
args.push(options.orderBy);
|
|
2418
|
-
}
|
|
2419
|
-
if (options.isAlpha) {
|
|
2420
|
-
args.push("ALPHA");
|
|
2421
|
-
}
|
|
2422
|
-
if (options.byPattern) {
|
|
2423
|
-
args.push("BY", options.byPattern);
|
|
2424
|
-
}
|
|
2425
|
-
if (options.getPatterns) {
|
|
2426
|
-
options.getPatterns.forEach((p) => args.push("GET", p));
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
if (destination)
|
|
2430
|
-
args.push("STORE", destination);
|
|
2431
|
-
return createCommand(cmd, args);
|
|
2432
|
-
}
|
|
2433
|
-
/**
|
|
2434
|
-
* @internal
|
|
2435
|
-
*/
|
|
2436
|
-
function createHStrlen(key, field) {
|
|
2437
|
-
return createCommand(RequestType.HStrlen, [key, field]);
|
|
2438
|
-
}
|
|
2439
|
-
/** @internal */
|
|
2440
|
-
function createHRandField(key, count, withValues) {
|
|
2441
|
-
const args = [key];
|
|
2442
|
-
if (count !== undefined)
|
|
2443
|
-
args.push(count.toString());
|
|
2444
|
-
if (withValues)
|
|
2445
|
-
args.push("WITHVALUES");
|
|
2446
|
-
return createCommand(RequestType.HRandField, args);
|
|
2447
|
-
}
|
|
2448
|
-
/**
|
|
2449
|
-
* @internal
|
|
2450
|
-
*/
|
|
2451
|
-
function createHScan(key, cursor, options) {
|
|
2452
|
-
let args = [key, cursor];
|
|
2453
|
-
if (options) {
|
|
2454
|
-
args = args.concat(convertBaseScanOptionsToArgsArray(options));
|
|
2455
|
-
if (options.noValues) {
|
|
2456
|
-
args.push("NOVALUES");
|
|
2457
|
-
}
|
|
2458
|
-
}
|
|
2459
|
-
return createCommand(RequestType.HScan, args);
|
|
2460
|
-
}
|
|
2461
|
-
/**
|
|
2462
|
-
* @internal
|
|
2463
|
-
*/
|
|
2464
|
-
function createZRandMember(key, count, withscores) {
|
|
2465
|
-
const args = [key];
|
|
2466
|
-
if (count !== undefined) {
|
|
2467
|
-
args.push(count.toString());
|
|
2468
|
-
}
|
|
2469
|
-
if (withscores) {
|
|
2470
|
-
args.push("WITHSCORES");
|
|
2471
|
-
}
|
|
2472
|
-
return createCommand(RequestType.ZRandMember, args);
|
|
2473
|
-
}
|
|
2474
|
-
/** @internal */
|
|
2475
|
-
function createLastSave() {
|
|
2476
|
-
return createCommand(RequestType.LastSave, []);
|
|
2477
|
-
}
|
|
2478
|
-
/** @internal */
|
|
2479
|
-
function createLCS(key1, key2, options) {
|
|
2480
|
-
const args = [key1, key2];
|
|
2481
|
-
if (options) {
|
|
2482
|
-
if (options.len)
|
|
2483
|
-
args.push("LEN");
|
|
2484
|
-
else if (options.idx) {
|
|
2485
|
-
args.push("IDX");
|
|
2486
|
-
if (options.idx.withMatchLen)
|
|
2487
|
-
args.push("WITHMATCHLEN");
|
|
2488
|
-
if (options.idx.minMatchLen !== undefined)
|
|
2489
|
-
args.push("MINMATCHLEN", options.idx.minMatchLen.toString());
|
|
2490
|
-
}
|
|
2491
|
-
}
|
|
2492
|
-
return createCommand(RequestType.LCS, args);
|
|
2493
|
-
}
|
|
2494
|
-
/**
|
|
2495
|
-
* @internal
|
|
2496
|
-
*/
|
|
2497
|
-
function createTouch(keys) {
|
|
2498
|
-
return createCommand(RequestType.Touch, keys);
|
|
2499
|
-
}
|
|
2500
|
-
/** @internal */
|
|
2501
|
-
function createRandomKey() {
|
|
2502
|
-
return createCommand(RequestType.RandomKey, []);
|
|
2503
|
-
}
|
|
2504
|
-
/** @internal */
|
|
2505
|
-
function createWatch(keys) {
|
|
2506
|
-
return createCommand(RequestType.Watch, keys);
|
|
2507
|
-
}
|
|
2508
|
-
/** @internal */
|
|
2509
|
-
function createUnWatch() {
|
|
2510
|
-
return createCommand(RequestType.UnWatch, []);
|
|
2511
|
-
}
|
|
2512
|
-
/** @internal */
|
|
2513
|
-
function createWait(numreplicas, timeout) {
|
|
2514
|
-
return createCommand(RequestType.Wait, [
|
|
2515
|
-
numreplicas.toString(),
|
|
2516
|
-
timeout.toString(),
|
|
2517
|
-
]);
|
|
2518
|
-
}
|
|
2519
|
-
/**
|
|
2520
|
-
* @internal
|
|
2521
|
-
*/
|
|
2522
|
-
function convertBaseScanOptionsToArgsArray(options) {
|
|
2523
|
-
const args = [];
|
|
2524
|
-
if (options.match) {
|
|
2525
|
-
args.push("MATCH", options.match);
|
|
2526
|
-
}
|
|
2527
|
-
if (options.count !== undefined) {
|
|
2528
|
-
args.push("COUNT", options.count.toString());
|
|
2529
|
-
}
|
|
2530
|
-
return args;
|
|
2531
|
-
}
|
|
2532
|
-
/**
|
|
2533
|
-
* @internal
|
|
2534
|
-
*/
|
|
2535
|
-
function createZScan(key, cursor, options) {
|
|
2536
|
-
let args = [key, cursor];
|
|
2537
|
-
if (options) {
|
|
2538
|
-
args = args.concat(convertBaseScanOptionsToArgsArray(options));
|
|
2539
|
-
if (options.noScores) {
|
|
2540
|
-
args.push("NOSCORES");
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
return createCommand(RequestType.ZScan, args);
|
|
2544
|
-
}
|
|
2545
|
-
/** @internal */
|
|
2546
|
-
function createSetRange(key, offset, value) {
|
|
2547
|
-
return createCommand(RequestType.SetRange, [key, offset.toString(), value]);
|
|
2548
|
-
}
|
|
2549
|
-
/** @internal */
|
|
2550
|
-
function createAppend(key, value) {
|
|
2551
|
-
return createCommand(RequestType.Append, [key, value]);
|
|
2552
|
-
}
|
|
2553
|
-
/**
|
|
2554
|
-
* @internal
|
|
2555
|
-
*/
|
|
2556
|
-
function createLMPop(keys, direction, count) {
|
|
2557
|
-
const args = [keys.length.toString(), ...keys, direction];
|
|
2558
|
-
if (count !== undefined) {
|
|
2559
|
-
args.push("COUNT");
|
|
2560
|
-
args.push(count.toString());
|
|
2561
|
-
}
|
|
2562
|
-
return createCommand(RequestType.LMPop, args);
|
|
2563
|
-
}
|
|
2564
|
-
/**
|
|
2565
|
-
* @internal
|
|
2566
|
-
*/
|
|
2567
|
-
function createBLMPop(keys, direction, timeout, count) {
|
|
2568
|
-
const args = [
|
|
2569
|
-
timeout.toString(),
|
|
2570
|
-
keys.length.toString(),
|
|
2571
|
-
...keys,
|
|
2572
|
-
direction,
|
|
2573
|
-
];
|
|
2574
|
-
if (count !== undefined) {
|
|
2575
|
-
args.push("COUNT");
|
|
2576
|
-
args.push(count.toString());
|
|
2577
|
-
}
|
|
2578
|
-
return createCommand(RequestType.BLMPop, args);
|
|
2579
|
-
}
|
|
2580
|
-
/**
|
|
2581
|
-
* @internal
|
|
2582
|
-
*/
|
|
2583
|
-
function createPubSubChannels(pattern) {
|
|
2584
|
-
return createCommand(RequestType.PubSubChannels, pattern ? [pattern] : []);
|
|
2585
|
-
}
|
|
2586
|
-
/**
|
|
2587
|
-
* @internal
|
|
2588
|
-
*/
|
|
2589
|
-
function createPubSubNumPat() {
|
|
2590
|
-
return createCommand(RequestType.PubSubNumPat, []);
|
|
2591
|
-
}
|
|
2592
|
-
/**
|
|
2593
|
-
* @internal
|
|
2594
|
-
*/
|
|
2595
|
-
function createPubSubNumSub(channels) {
|
|
2596
|
-
return createCommand(RequestType.PubSubNumSub, channels ? channels : []);
|
|
2597
|
-
}
|
|
2598
|
-
/**
|
|
2599
|
-
* @internal
|
|
2600
|
-
*/
|
|
2601
|
-
function createPubsubShardChannels(pattern) {
|
|
2602
|
-
return createCommand(RequestType.PubSubShardChannels, pattern ? [pattern] : []);
|
|
2603
|
-
}
|
|
2604
|
-
/**
|
|
2605
|
-
* @internal
|
|
2606
|
-
*/
|
|
2607
|
-
function createPubSubShardNumSub(channels) {
|
|
2608
|
-
return createCommand(RequestType.PubSubShardNumSub, channels ? channels : []);
|
|
2609
|
-
}
|
|
2610
|
-
/**
|
|
2611
|
-
* @internal
|
|
2612
|
-
*/
|
|
2613
|
-
function createBZPopMax(keys, timeout) {
|
|
2614
|
-
return createCommand(RequestType.BZPopMax, [...keys, timeout.toString()]);
|
|
2615
|
-
}
|
|
2616
|
-
/**
|
|
2617
|
-
* @internal
|
|
2618
|
-
*/
|
|
2619
|
-
function createBZPopMin(keys, timeout) {
|
|
2620
|
-
return createCommand(RequestType.BZPopMin, [...keys, timeout.toString()]);
|
|
2621
|
-
}
|
|
2622
|
-
/**
|
|
2623
|
-
* @internal
|
|
2624
|
-
*/
|
|
2625
|
-
function createScriptShow(sha1) {
|
|
2626
|
-
return createCommand(RequestType.ScriptShow, [sha1]);
|
|
2627
|
-
}
|
|
2628
|
-
/**
|
|
2629
|
-
* Time unit representation which is used in optional arguments for {@link BaseClient.getex|getex} and {@link BaseClient.set|set} command.
|
|
2630
|
-
*/
|
|
2631
|
-
var TimeUnit;
|
|
2632
|
-
(function (TimeUnit) {
|
|
2633
|
-
/**
|
|
2634
|
-
* Set the specified expire time, in seconds. Equivalent to
|
|
2635
|
-
* `EX` in the VALKEY API.
|
|
2636
|
-
*/
|
|
2637
|
-
TimeUnit["Seconds"] = "EX";
|
|
2638
|
-
/**
|
|
2639
|
-
* Set the specified expire time, in milliseconds. Equivalent
|
|
2640
|
-
* to `PX` in the VALKEY API.
|
|
2641
|
-
*/
|
|
2642
|
-
TimeUnit["Milliseconds"] = "PX";
|
|
2643
|
-
/**
|
|
2644
|
-
* Set the specified Unix time at which the key will expire,
|
|
2645
|
-
* in seconds. Equivalent to `EXAT` in the VALKEY API.
|
|
2646
|
-
*/
|
|
2647
|
-
TimeUnit["UnixSeconds"] = "EXAT";
|
|
2648
|
-
/**
|
|
2649
|
-
* Set the specified Unix time at which the key will expire,
|
|
2650
|
-
* in milliseconds. Equivalent to `PXAT` in the VALKEY API.
|
|
2651
|
-
*/
|
|
2652
|
-
TimeUnit["UnixMilliseconds"] = "PXAT";
|
|
2653
|
-
})(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
|
|
2654
|
-
/**
|
|
2655
|
-
* @internal
|
|
2656
|
-
*/
|
|
2657
|
-
function createGetEx(key, options) {
|
|
2658
|
-
const args = [key];
|
|
2659
|
-
if (options) {
|
|
2660
|
-
if (options !== "persist" && !Number.isInteger(options.duration)) {
|
|
2661
|
-
throw new Error(`Received expiry '${JSON.stringify(options.duration)}'. Count must be an integer`);
|
|
2662
|
-
}
|
|
2663
|
-
if (options === "persist") {
|
|
2664
|
-
args.push("PERSIST");
|
|
2665
|
-
}
|
|
2666
|
-
else {
|
|
2667
|
-
args.push(options.type, options.duration.toString());
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
return createCommand(RequestType.GetEx, args);
|
|
2671
|
-
}
|
|
2672
|
-
/**
|
|
2673
|
-
* @internal
|
|
2674
|
-
*/
|
|
2675
|
-
function createXAck(key, group, ids) {
|
|
2676
|
-
return createCommand(RequestType.XAck, [key, group, ...ids]);
|
|
2677
|
-
}
|
|
2678
|
-
/**
|
|
2679
|
-
* @internal
|
|
2680
|
-
*/
|
|
2681
|
-
function createXGroupSetid(key, groupName, id, entriesRead) {
|
|
2682
|
-
const args = [key, groupName, id];
|
|
2683
|
-
if (entriesRead !== undefined) {
|
|
2684
|
-
args.push("ENTRIESREAD");
|
|
2685
|
-
args.push(entriesRead.toString());
|
|
2686
|
-
}
|
|
2687
|
-
return createCommand(RequestType.XGroupSetId, args);
|
|
2688
|
-
}
|
|
2689
|
-
/**
|
|
2690
|
-
* @internal
|
|
2691
|
-
*/
|
|
2692
|
-
function createScriptExists(sha1s) {
|
|
2693
|
-
return createCommand(RequestType.ScriptExists, sha1s);
|
|
2694
|
-
}
|
|
2695
|
-
/**
|
|
2696
|
-
* @internal
|
|
2697
|
-
*/
|
|
2698
|
-
function createScriptFlush(mode) {
|
|
2699
|
-
if (mode) {
|
|
2700
|
-
return createCommand(RequestType.ScriptFlush, [mode.toString()]);
|
|
2701
|
-
}
|
|
2702
|
-
else {
|
|
2703
|
-
return createCommand(RequestType.ScriptFlush, []);
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
/** @internal */
|
|
2707
|
-
function createScriptKill() {
|
|
2708
|
-
return createCommand(RequestType.ScriptKill, []);
|
|
2709
|
-
}
|
|
2710
|
-
//# sourceMappingURL=Commands.js.map
|