@upstash/redis 1.36.1 → 1.37.0-rc.1
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/{chunk-LLI2WIYN.mjs → chunk-PDHDP2I5.mjs} +297 -207
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +308 -222
- package/cloudflare.mjs +10 -14
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +299 -209
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +144 -3
- package/nodejs.d.ts +144 -3
- package/nodejs.js +464 -221
- package/nodejs.mjs +160 -8
- package/package.json +1 -1
- package/{zmscore-0SAuWM0q.d.mts → zmscore-BpOSd5F5.d.mts} +347 -126
- package/{zmscore-0SAuWM0q.d.ts → zmscore-BpOSd5F5.d.ts} +347 -126
package/cloudflare.js
CHANGED
|
@@ -98,18 +98,8 @@ function mergeHeaders(...headers) {
|
|
|
98
98
|
}
|
|
99
99
|
return merged;
|
|
100
100
|
}
|
|
101
|
-
function kvArrayToObject(v) {
|
|
102
|
-
if (typeof v === "object" && v !== null && !Array.isArray(v)) return v;
|
|
103
|
-
if (!Array.isArray(v)) return {};
|
|
104
|
-
const obj = {};
|
|
105
|
-
for (let i = 0; i < v.length; i += 2) {
|
|
106
|
-
if (typeof v[i] === "string") obj[v[i]] = v[i + 1];
|
|
107
|
-
}
|
|
108
|
-
return obj;
|
|
109
|
-
}
|
|
110
101
|
|
|
111
102
|
// pkg/http.ts
|
|
112
|
-
var MAX_BUFFER_SIZE = 1024 * 1024;
|
|
113
103
|
var HttpClient = class {
|
|
114
104
|
baseUrl;
|
|
115
105
|
headers;
|
|
@@ -233,16 +223,11 @@ var HttpClient = class {
|
|
|
233
223
|
const decoder = new TextDecoder();
|
|
234
224
|
(async () => {
|
|
235
225
|
try {
|
|
236
|
-
let buffer = "";
|
|
237
226
|
while (true) {
|
|
238
227
|
const { value, done } = await reader.read();
|
|
239
228
|
if (done) break;
|
|
240
|
-
|
|
241
|
-
const lines =
|
|
242
|
-
buffer = lines.pop() || "";
|
|
243
|
-
if (buffer.length > MAX_BUFFER_SIZE) {
|
|
244
|
-
throw new Error("Buffer size exceeded (1MB)");
|
|
245
|
-
}
|
|
229
|
+
const chunk = decoder.decode(value);
|
|
230
|
+
const lines = chunk.split("\n");
|
|
246
231
|
for (const line of lines) {
|
|
247
232
|
if (line.startsWith("data: ")) {
|
|
248
233
|
const data = line.slice(6);
|
|
@@ -360,7 +345,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
360
345
|
"zrange",
|
|
361
346
|
"exec"
|
|
362
347
|
]);
|
|
363
|
-
function createAutoPipelineProxy(_redis,
|
|
348
|
+
function createAutoPipelineProxy(_redis, json) {
|
|
364
349
|
const redis = _redis;
|
|
365
350
|
if (!redis.autoPipelineExecutor) {
|
|
366
351
|
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
@@ -370,31 +355,29 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
|
|
|
370
355
|
if (command === "pipelineCounter") {
|
|
371
356
|
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
372
357
|
}
|
|
373
|
-
if (
|
|
374
|
-
return createAutoPipelineProxy(redis2,
|
|
358
|
+
if (command === "json") {
|
|
359
|
+
return createAutoPipelineProxy(redis2, true);
|
|
375
360
|
}
|
|
376
|
-
|
|
377
|
-
|
|
361
|
+
const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
|
|
362
|
+
const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
|
|
363
|
+
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
364
|
+
return redis2[command];
|
|
378
365
|
}
|
|
379
|
-
|
|
380
|
-
const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
|
|
381
|
-
const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
|
|
382
|
-
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
383
|
-
return redis2[command];
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
const pipeline = redis2.autoPipelineExecutor.pipeline;
|
|
387
|
-
const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
|
|
388
|
-
const isFunction = typeof targetFunction === "function";
|
|
366
|
+
const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
|
|
389
367
|
if (isFunction) {
|
|
390
368
|
return (...args) => {
|
|
391
|
-
return redis2.autoPipelineExecutor.withAutoPipeline((
|
|
392
|
-
|
|
393
|
-
|
|
369
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
|
|
370
|
+
if (json) {
|
|
371
|
+
pipeline.json[command](
|
|
372
|
+
...args
|
|
373
|
+
);
|
|
374
|
+
} else {
|
|
375
|
+
pipeline[command](...args);
|
|
376
|
+
}
|
|
394
377
|
});
|
|
395
378
|
};
|
|
396
379
|
}
|
|
397
|
-
return
|
|
380
|
+
return redis2.autoPipelineExecutor.pipeline[command];
|
|
398
381
|
}
|
|
399
382
|
});
|
|
400
383
|
}
|
|
@@ -687,23 +670,6 @@ var ExpireAtCommand = class extends Command {
|
|
|
687
670
|
}
|
|
688
671
|
};
|
|
689
672
|
|
|
690
|
-
// pkg/commands/fcall.ts
|
|
691
|
-
var FCallCommand = class extends Command {
|
|
692
|
-
constructor([functionName, keys, args], opts) {
|
|
693
|
-
super(["fcall", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []], opts);
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
// pkg/commands/fcall_ro.ts
|
|
698
|
-
var FCallRoCommand = class extends Command {
|
|
699
|
-
constructor([functionName, keys, args], opts) {
|
|
700
|
-
super(
|
|
701
|
-
["fcall_ro", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []],
|
|
702
|
-
opts
|
|
703
|
-
);
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
|
|
707
673
|
// pkg/commands/flushall.ts
|
|
708
674
|
var FlushAllCommand = class extends Command {
|
|
709
675
|
constructor(args, opts) {
|
|
@@ -726,85 +692,6 @@ var FlushDBCommand = class extends Command {
|
|
|
726
692
|
}
|
|
727
693
|
};
|
|
728
694
|
|
|
729
|
-
// pkg/commands/function_delete.ts
|
|
730
|
-
var FunctionDeleteCommand = class extends Command {
|
|
731
|
-
constructor([libraryName], opts) {
|
|
732
|
-
super(["function", "delete", libraryName], opts);
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// pkg/commands/function_flush.ts
|
|
737
|
-
var FunctionFlushCommand = class extends Command {
|
|
738
|
-
constructor(opts) {
|
|
739
|
-
super(["function", "flush"], opts);
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
// pkg/commands/function_list.ts
|
|
744
|
-
var FunctionListCommand = class extends Command {
|
|
745
|
-
constructor([args], opts) {
|
|
746
|
-
const command = ["function", "list"];
|
|
747
|
-
if (args?.libraryName) {
|
|
748
|
-
command.push("libraryname", args.libraryName);
|
|
749
|
-
}
|
|
750
|
-
if (args?.withCode) {
|
|
751
|
-
command.push("withcode");
|
|
752
|
-
}
|
|
753
|
-
super(command, { deserialize, ...opts });
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
function deserialize(result) {
|
|
757
|
-
if (!Array.isArray(result)) return [];
|
|
758
|
-
return result.map((libRaw) => {
|
|
759
|
-
const lib = kvArrayToObject(libRaw);
|
|
760
|
-
const functionsParsed = lib.functions.map(
|
|
761
|
-
(fnRaw) => kvArrayToObject(fnRaw)
|
|
762
|
-
);
|
|
763
|
-
return {
|
|
764
|
-
libraryName: lib.library_name,
|
|
765
|
-
engine: lib.engine,
|
|
766
|
-
functions: functionsParsed.map((fn) => ({
|
|
767
|
-
name: fn.name,
|
|
768
|
-
description: fn.description ?? void 0,
|
|
769
|
-
flags: fn.flags
|
|
770
|
-
})),
|
|
771
|
-
libraryCode: lib.library_code
|
|
772
|
-
};
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// pkg/commands/function_load.ts
|
|
777
|
-
var FunctionLoadCommand = class extends Command {
|
|
778
|
-
constructor([args], opts) {
|
|
779
|
-
super(["function", "load", ...args.replace ? ["replace"] : [], args.code], opts);
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
// pkg/commands/function_stats.ts
|
|
784
|
-
var FunctionStatsCommand = class extends Command {
|
|
785
|
-
constructor(opts) {
|
|
786
|
-
super(["function", "stats"], { deserialize: deserialize2, ...opts });
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
function deserialize2(result) {
|
|
790
|
-
const rawEngines = kvArrayToObject(kvArrayToObject(result).engines);
|
|
791
|
-
const parsedEngines = Object.fromEntries(
|
|
792
|
-
Object.entries(rawEngines).map(([key, value]) => [key, kvArrayToObject(value)])
|
|
793
|
-
);
|
|
794
|
-
const final = {
|
|
795
|
-
engines: Object.fromEntries(
|
|
796
|
-
Object.entries(parsedEngines).map(([key, value]) => [
|
|
797
|
-
key,
|
|
798
|
-
{
|
|
799
|
-
librariesCount: value.libraries_count,
|
|
800
|
-
functionsCount: value.functions_count
|
|
801
|
-
}
|
|
802
|
-
])
|
|
803
|
-
)
|
|
804
|
-
};
|
|
805
|
-
return final;
|
|
806
|
-
}
|
|
807
|
-
|
|
808
695
|
// pkg/commands/geo_add.ts
|
|
809
696
|
var GeoAddCommand = class extends Command {
|
|
810
697
|
constructor([key, arg1, ...arg2], opts) {
|
|
@@ -1151,7 +1038,7 @@ var HGetCommand = class extends Command {
|
|
|
1151
1038
|
};
|
|
1152
1039
|
|
|
1153
1040
|
// pkg/commands/hgetall.ts
|
|
1154
|
-
function
|
|
1041
|
+
function deserialize(result) {
|
|
1155
1042
|
if (result.length === 0) {
|
|
1156
1043
|
return null;
|
|
1157
1044
|
}
|
|
@@ -1171,7 +1058,7 @@ function deserialize3(result) {
|
|
|
1171
1058
|
var HGetAllCommand = class extends Command {
|
|
1172
1059
|
constructor(cmd, opts) {
|
|
1173
1060
|
super(["hgetall", ...cmd], {
|
|
1174
|
-
deserialize: (result) =>
|
|
1061
|
+
deserialize: (result) => deserialize(result),
|
|
1175
1062
|
...opts
|
|
1176
1063
|
});
|
|
1177
1064
|
}
|
|
@@ -1206,7 +1093,7 @@ var HLenCommand = class extends Command {
|
|
|
1206
1093
|
};
|
|
1207
1094
|
|
|
1208
1095
|
// pkg/commands/hmget.ts
|
|
1209
|
-
function
|
|
1096
|
+
function deserialize2(fields, result) {
|
|
1210
1097
|
if (result.every((field) => field === null)) {
|
|
1211
1098
|
return null;
|
|
1212
1099
|
}
|
|
@@ -1223,7 +1110,7 @@ function deserialize4(fields, result) {
|
|
|
1223
1110
|
var HMGetCommand = class extends Command {
|
|
1224
1111
|
constructor([key, ...fields], opts) {
|
|
1225
1112
|
super(["hmget", key, ...fields], {
|
|
1226
|
-
deserialize: (result) =>
|
|
1113
|
+
deserialize: (result) => deserialize2(fields, result),
|
|
1227
1114
|
...opts
|
|
1228
1115
|
});
|
|
1229
1116
|
}
|
|
@@ -1237,7 +1124,7 @@ var HMSetCommand = class extends Command {
|
|
|
1237
1124
|
};
|
|
1238
1125
|
|
|
1239
1126
|
// pkg/commands/hrandfield.ts
|
|
1240
|
-
function
|
|
1127
|
+
function deserialize3(result) {
|
|
1241
1128
|
if (result.length === 0) {
|
|
1242
1129
|
return null;
|
|
1243
1130
|
}
|
|
@@ -1264,7 +1151,7 @@ var HRandFieldCommand = class extends Command {
|
|
|
1264
1151
|
}
|
|
1265
1152
|
super(command, {
|
|
1266
1153
|
// @ts-expect-error to silence compiler
|
|
1267
|
-
deserialize: cmd[2] ? (result) =>
|
|
1154
|
+
deserialize: cmd[2] ? (result) => deserialize3(result) : opts?.deserialize,
|
|
1268
1155
|
...opts
|
|
1269
1156
|
});
|
|
1270
1157
|
}
|
|
@@ -2234,7 +2121,7 @@ var XPendingCommand = class extends Command {
|
|
|
2234
2121
|
};
|
|
2235
2122
|
|
|
2236
2123
|
// pkg/commands/xrange.ts
|
|
2237
|
-
function
|
|
2124
|
+
function deserialize4(result) {
|
|
2238
2125
|
const obj = {};
|
|
2239
2126
|
for (const e of result) {
|
|
2240
2127
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2263,7 +2150,7 @@ var XRangeCommand = class extends Command {
|
|
|
2263
2150
|
command.push("COUNT", count);
|
|
2264
2151
|
}
|
|
2265
2152
|
super(command, {
|
|
2266
|
-
deserialize: (result) =>
|
|
2153
|
+
deserialize: (result) => deserialize4(result),
|
|
2267
2154
|
...opts
|
|
2268
2155
|
});
|
|
2269
2156
|
}
|
|
@@ -2326,12 +2213,12 @@ var XRevRangeCommand = class extends Command {
|
|
|
2326
2213
|
command.push("COUNT", count);
|
|
2327
2214
|
}
|
|
2328
2215
|
super(command, {
|
|
2329
|
-
deserialize: (result) =>
|
|
2216
|
+
deserialize: (result) => deserialize5(result),
|
|
2330
2217
|
...opts
|
|
2331
2218
|
});
|
|
2332
2219
|
}
|
|
2333
2220
|
};
|
|
2334
|
-
function
|
|
2221
|
+
function deserialize5(result) {
|
|
2335
2222
|
const obj = {};
|
|
2336
2223
|
for (const e of result) {
|
|
2337
2224
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2601,6 +2488,265 @@ var ZUnionStoreCommand = class extends Command {
|
|
|
2601
2488
|
}
|
|
2602
2489
|
};
|
|
2603
2490
|
|
|
2491
|
+
// pkg/commands/search/types.ts
|
|
2492
|
+
var FIELD_TYPES = ["TEXT", "U64", "I64", "F64", "BOOL", "DATE"];
|
|
2493
|
+
|
|
2494
|
+
// pkg/commands/search/utils.ts
|
|
2495
|
+
function isFieldType(value) {
|
|
2496
|
+
return typeof value === "string" && FIELD_TYPES.includes(value);
|
|
2497
|
+
}
|
|
2498
|
+
function isDetailedField(value) {
|
|
2499
|
+
return typeof value === "object" && value !== null && "type" in value && isFieldType(value.type);
|
|
2500
|
+
}
|
|
2501
|
+
function isNestedSchema(value) {
|
|
2502
|
+
return typeof value === "object" && value !== null && !isDetailedField(value);
|
|
2503
|
+
}
|
|
2504
|
+
function flattenSchema(schema, pathPrefix = []) {
|
|
2505
|
+
const fields = [];
|
|
2506
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
2507
|
+
const currentPath = [...pathPrefix, key];
|
|
2508
|
+
const pathString = currentPath.join(".");
|
|
2509
|
+
if (isFieldType(value)) {
|
|
2510
|
+
fields.push({
|
|
2511
|
+
path: pathString,
|
|
2512
|
+
type: value
|
|
2513
|
+
});
|
|
2514
|
+
} else if (isDetailedField(value)) {
|
|
2515
|
+
fields.push({
|
|
2516
|
+
path: pathString,
|
|
2517
|
+
type: value.type,
|
|
2518
|
+
fast: "fast" in value ? value.fast : void 0,
|
|
2519
|
+
noTokenize: "noTokenize" in value ? value.noTokenize : void 0,
|
|
2520
|
+
noStem: "noStem" in value ? value.noStem : void 0,
|
|
2521
|
+
from: "from" in value ? value.from : void 0
|
|
2522
|
+
});
|
|
2523
|
+
} else if (isNestedSchema(value)) {
|
|
2524
|
+
const nestedFields = flattenSchema(value, currentPath);
|
|
2525
|
+
fields.push(...nestedFields);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
return fields;
|
|
2529
|
+
}
|
|
2530
|
+
function deserializeQueryResponse(rawResponse) {
|
|
2531
|
+
return rawResponse.map((itemRaw) => {
|
|
2532
|
+
const raw = itemRaw;
|
|
2533
|
+
const key = raw[0];
|
|
2534
|
+
const score = raw[1];
|
|
2535
|
+
const rawFields = raw[2];
|
|
2536
|
+
if (rawFields === void 0) {
|
|
2537
|
+
return { key, score };
|
|
2538
|
+
}
|
|
2539
|
+
if (!Array.isArray(rawFields) || rawFields.length === 0) {
|
|
2540
|
+
return { key, score, data: {} };
|
|
2541
|
+
}
|
|
2542
|
+
let data = {};
|
|
2543
|
+
for (const fieldRaw of rawFields) {
|
|
2544
|
+
const key2 = fieldRaw[0];
|
|
2545
|
+
const value = fieldRaw[1];
|
|
2546
|
+
const pathParts = key2.split(".");
|
|
2547
|
+
if (pathParts.length == 1) {
|
|
2548
|
+
data[key2] = value;
|
|
2549
|
+
} else {
|
|
2550
|
+
let currentObj = data;
|
|
2551
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
2552
|
+
const pathPart = pathParts[i];
|
|
2553
|
+
if (!(pathPart in currentObj)) {
|
|
2554
|
+
currentObj[pathPart] = {};
|
|
2555
|
+
}
|
|
2556
|
+
currentObj = currentObj[pathPart];
|
|
2557
|
+
}
|
|
2558
|
+
currentObj[pathParts.at(-1)] = value;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
if ("$" in data) {
|
|
2562
|
+
data = data["$"];
|
|
2563
|
+
}
|
|
2564
|
+
return { key, score, data };
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
function deserializeDescribeResponse(rawResponse) {
|
|
2568
|
+
const description = {};
|
|
2569
|
+
for (let i = 0; i < rawResponse.length; i += 2) {
|
|
2570
|
+
const descriptor = rawResponse[i];
|
|
2571
|
+
switch (descriptor) {
|
|
2572
|
+
case "name": {
|
|
2573
|
+
description["name"] = rawResponse[i + 1];
|
|
2574
|
+
break;
|
|
2575
|
+
}
|
|
2576
|
+
case "type": {
|
|
2577
|
+
description["dataType"] = rawResponse[i + 1].toLowerCase();
|
|
2578
|
+
break;
|
|
2579
|
+
}
|
|
2580
|
+
case "prefixes": {
|
|
2581
|
+
description["prefixes"] = rawResponse[i + 1];
|
|
2582
|
+
break;
|
|
2583
|
+
}
|
|
2584
|
+
case "language": {
|
|
2585
|
+
description["language"] = rawResponse[i + 1];
|
|
2586
|
+
break;
|
|
2587
|
+
}
|
|
2588
|
+
case "schema": {
|
|
2589
|
+
const schema = {};
|
|
2590
|
+
for (const fieldDescription of rawResponse[i + 1]) {
|
|
2591
|
+
const fieldName = fieldDescription[0];
|
|
2592
|
+
const fieldInfo = { type: fieldDescription[1] };
|
|
2593
|
+
if (fieldDescription.length > 2) {
|
|
2594
|
+
for (let j = 2; j < fieldDescription.length; j++) {
|
|
2595
|
+
const fieldOption = fieldDescription[j];
|
|
2596
|
+
switch (fieldOption) {
|
|
2597
|
+
case "NOSTEM": {
|
|
2598
|
+
fieldInfo.noStem = true;
|
|
2599
|
+
break;
|
|
2600
|
+
}
|
|
2601
|
+
case "NOTOKENIZE": {
|
|
2602
|
+
fieldInfo.noTokenize = true;
|
|
2603
|
+
break;
|
|
2604
|
+
}
|
|
2605
|
+
case "FAST": {
|
|
2606
|
+
fieldInfo.fast = true;
|
|
2607
|
+
break;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
schema[fieldName] = fieldInfo;
|
|
2613
|
+
}
|
|
2614
|
+
description["schema"] = schema;
|
|
2615
|
+
break;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
return description;
|
|
2620
|
+
}
|
|
2621
|
+
function parseCountResponse(rawResponse) {
|
|
2622
|
+
return typeof rawResponse === "number" ? rawResponse : Number.parseInt(rawResponse, 10);
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
// pkg/commands/search/command-builder.ts
|
|
2626
|
+
function buildQueryCommand(redisCommand, name, options) {
|
|
2627
|
+
const query = JSON.stringify(options?.filter ?? {});
|
|
2628
|
+
const command = [redisCommand, name, query];
|
|
2629
|
+
if (options?.limit !== void 0) {
|
|
2630
|
+
command.push("LIMIT", options.limit.toString());
|
|
2631
|
+
}
|
|
2632
|
+
if (options?.offset !== void 0) {
|
|
2633
|
+
command.push("OFFSET", options.offset.toString());
|
|
2634
|
+
}
|
|
2635
|
+
if (options?.select && Object.keys(options.select).length === 0) {
|
|
2636
|
+
command.push("NOCONTENT");
|
|
2637
|
+
}
|
|
2638
|
+
if (options?.orderBy) {
|
|
2639
|
+
command.push("ORDERBY");
|
|
2640
|
+
for (const [field, direction] of Object.entries(options.orderBy)) {
|
|
2641
|
+
command.push(field, direction);
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
if (options?.highlight) {
|
|
2645
|
+
command.push(
|
|
2646
|
+
"HIGHLIGHT",
|
|
2647
|
+
"FIELDS",
|
|
2648
|
+
options.highlight.fields.length.toString(),
|
|
2649
|
+
...options.highlight.fields
|
|
2650
|
+
);
|
|
2651
|
+
if (options.highlight.preTag && options.highlight.postTag) {
|
|
2652
|
+
command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (options?.select && Object.keys(options.select).length > 0) {
|
|
2656
|
+
command.push(
|
|
2657
|
+
"SELECT",
|
|
2658
|
+
Object.keys(options.select).length.toString(),
|
|
2659
|
+
...Object.keys(options.select)
|
|
2660
|
+
);
|
|
2661
|
+
}
|
|
2662
|
+
return command;
|
|
2663
|
+
}
|
|
2664
|
+
function buildCreateIndexCommand(params) {
|
|
2665
|
+
const { name, schema, dataType, prefix, language, skipInitialScan, existsOk } = params;
|
|
2666
|
+
const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
|
|
2667
|
+
const payload = [
|
|
2668
|
+
name,
|
|
2669
|
+
...skipInitialScan ? ["SKIPINITIALSCAN"] : [],
|
|
2670
|
+
...existsOk ? ["EXISTSOK"] : [],
|
|
2671
|
+
"ON",
|
|
2672
|
+
dataType.toUpperCase(),
|
|
2673
|
+
"PREFIX",
|
|
2674
|
+
prefixArray.length.toString(),
|
|
2675
|
+
...prefixArray,
|
|
2676
|
+
...language ? ["LANGUAGE", language] : [],
|
|
2677
|
+
"SCHEMA"
|
|
2678
|
+
];
|
|
2679
|
+
const fields = flattenSchema(schema);
|
|
2680
|
+
for (const field of fields) {
|
|
2681
|
+
payload.push(field.path, field.type);
|
|
2682
|
+
if (field.fast) {
|
|
2683
|
+
payload.push("FAST");
|
|
2684
|
+
}
|
|
2685
|
+
if (field.noTokenize) {
|
|
2686
|
+
payload.push("NOTOKENIZE");
|
|
2687
|
+
}
|
|
2688
|
+
if (field.noStem) {
|
|
2689
|
+
payload.push("NOSTEM");
|
|
2690
|
+
}
|
|
2691
|
+
if (field.from) {
|
|
2692
|
+
payload.push("FROM", field.from);
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
return ["SEARCH.CREATE", ...payload];
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
// pkg/commands/search/search.ts
|
|
2699
|
+
var SearchIndex = class {
|
|
2700
|
+
name;
|
|
2701
|
+
schema;
|
|
2702
|
+
client;
|
|
2703
|
+
constructor({ name, schema, client }) {
|
|
2704
|
+
this.name = name;
|
|
2705
|
+
this.schema = schema;
|
|
2706
|
+
this.client = client;
|
|
2707
|
+
}
|
|
2708
|
+
async waitIndexing() {
|
|
2709
|
+
const command = ["SEARCH.WAITINDEXING", this.name];
|
|
2710
|
+
await new ExecCommand(command).exec(this.client);
|
|
2711
|
+
}
|
|
2712
|
+
async describe() {
|
|
2713
|
+
const command = ["SEARCH.DESCRIBE", this.name];
|
|
2714
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
2715
|
+
this.client
|
|
2716
|
+
);
|
|
2717
|
+
return deserializeDescribeResponse(rawResult);
|
|
2718
|
+
}
|
|
2719
|
+
async query(options) {
|
|
2720
|
+
const command = buildQueryCommand("SEARCH.QUERY", this.name, options);
|
|
2721
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
2722
|
+
this.client
|
|
2723
|
+
);
|
|
2724
|
+
return deserializeQueryResponse(rawResult);
|
|
2725
|
+
}
|
|
2726
|
+
async count({ filter }) {
|
|
2727
|
+
const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
|
|
2728
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
2729
|
+
this.client
|
|
2730
|
+
);
|
|
2731
|
+
return { count: parseCountResponse(rawResult) };
|
|
2732
|
+
}
|
|
2733
|
+
async drop() {
|
|
2734
|
+
const command = ["SEARCH.DROP", this.name];
|
|
2735
|
+
const result = await new ExecCommand(command).exec(this.client);
|
|
2736
|
+
return result;
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
async function createIndex(client, params) {
|
|
2740
|
+
const { name, schema } = params;
|
|
2741
|
+
const createIndexCommand = buildCreateIndexCommand(params);
|
|
2742
|
+
await new ExecCommand(createIndexCommand).exec(client);
|
|
2743
|
+
return initIndex(client, { name, schema });
|
|
2744
|
+
}
|
|
2745
|
+
function initIndex(client, params) {
|
|
2746
|
+
const { name, schema } = params;
|
|
2747
|
+
return new SearchIndex({ name, schema, client });
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2604
2750
|
// pkg/commands/psubscribe.ts
|
|
2605
2751
|
var PSubscribeCommand = class extends Command {
|
|
2606
2752
|
constructor(cmd, opts) {
|
|
@@ -3626,38 +3772,6 @@ var Pipeline = class {
|
|
|
3626
3772
|
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
3627
3773
|
};
|
|
3628
3774
|
}
|
|
3629
|
-
get functions() {
|
|
3630
|
-
return {
|
|
3631
|
-
/**
|
|
3632
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3633
|
-
*/
|
|
3634
|
-
load: (...args) => this.chain(new FunctionLoadCommand(args, this.commandOptions)),
|
|
3635
|
-
/**
|
|
3636
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3637
|
-
*/
|
|
3638
|
-
list: (...args) => this.chain(new FunctionListCommand(args, this.commandOptions)),
|
|
3639
|
-
/**
|
|
3640
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3641
|
-
*/
|
|
3642
|
-
delete: (...args) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)),
|
|
3643
|
-
/**
|
|
3644
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3645
|
-
*/
|
|
3646
|
-
flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)),
|
|
3647
|
-
/**
|
|
3648
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3649
|
-
*/
|
|
3650
|
-
stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)),
|
|
3651
|
-
/**
|
|
3652
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3653
|
-
*/
|
|
3654
|
-
call: (...args) => this.chain(new FCallCommand(args, this.commandOptions)),
|
|
3655
|
-
/**
|
|
3656
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3657
|
-
*/
|
|
3658
|
-
callRo: (...args) => this.chain(new FCallRoCommand(args, this.commandOptions))
|
|
3659
|
-
};
|
|
3660
|
-
}
|
|
3661
3775
|
};
|
|
3662
3776
|
|
|
3663
3777
|
// pkg/script.ts
|
|
@@ -3919,40 +4033,6 @@ var Redis = class {
|
|
|
3919
4033
|
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
3920
4034
|
};
|
|
3921
4035
|
}
|
|
3922
|
-
get functions() {
|
|
3923
|
-
return {
|
|
3924
|
-
/**
|
|
3925
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3926
|
-
*/
|
|
3927
|
-
load: (...args) => new FunctionLoadCommand(args, this.opts).exec(this.client),
|
|
3928
|
-
/**
|
|
3929
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3930
|
-
*/
|
|
3931
|
-
list: (...args) => new FunctionListCommand(args, this.opts).exec(this.client),
|
|
3932
|
-
/**
|
|
3933
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3934
|
-
*/
|
|
3935
|
-
delete: (...args) => new FunctionDeleteCommand(args, this.opts).exec(this.client),
|
|
3936
|
-
/**
|
|
3937
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3938
|
-
*/
|
|
3939
|
-
flush: () => new FunctionFlushCommand(this.opts).exec(this.client),
|
|
3940
|
-
/**
|
|
3941
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3942
|
-
*
|
|
3943
|
-
* Note: `running_script` field is not supported and therefore not included in the type.
|
|
3944
|
-
*/
|
|
3945
|
-
stats: () => new FunctionStatsCommand(this.opts).exec(this.client),
|
|
3946
|
-
/**
|
|
3947
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3948
|
-
*/
|
|
3949
|
-
call: (...args) => new FCallCommand(args, this.opts).exec(this.client),
|
|
3950
|
-
/**
|
|
3951
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3952
|
-
*/
|
|
3953
|
-
callRo: (...args) => new FCallRoCommand(args, this.opts).exec(this.client)
|
|
3954
|
-
};
|
|
3955
|
-
}
|
|
3956
4036
|
/**
|
|
3957
4037
|
* Wrap a new middleware around the HTTP client.
|
|
3958
4038
|
*/
|
|
@@ -4003,6 +4083,16 @@ var Redis = class {
|
|
|
4003
4083
|
createScript(script, opts) {
|
|
4004
4084
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
4005
4085
|
}
|
|
4086
|
+
get search() {
|
|
4087
|
+
return {
|
|
4088
|
+
createIndex: (params) => {
|
|
4089
|
+
return createIndex(this.client, params);
|
|
4090
|
+
},
|
|
4091
|
+
index: (params) => {
|
|
4092
|
+
return initIndex(this.client, params);
|
|
4093
|
+
}
|
|
4094
|
+
};
|
|
4095
|
+
}
|
|
4006
4096
|
/**
|
|
4007
4097
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
4008
4098
|
*
|
|
@@ -4710,7 +4800,7 @@ var Redis = class {
|
|
|
4710
4800
|
};
|
|
4711
4801
|
|
|
4712
4802
|
// version.ts
|
|
4713
|
-
var VERSION = "v1.
|
|
4803
|
+
var VERSION = "v1.37.0-rc.1";
|
|
4714
4804
|
|
|
4715
4805
|
// platforms/cloudflare.ts
|
|
4716
4806
|
var Redis2 = class _Redis extends Redis {
|
|
@@ -4779,20 +4869,16 @@ var Redis2 = class _Redis extends Redis {
|
|
|
4779
4869
|
* ```
|
|
4780
4870
|
*/
|
|
4781
4871
|
static fromEnv(env, opts) {
|
|
4782
|
-
const url = env?.UPSTASH_REDIS_REST_URL ??
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
UPSTASH_REDIS_REST_TOKEN
|
|
4791
|
-
) : void 0);
|
|
4792
|
-
const messageInfo = !url && !token ? "Unable to find environment variables: `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`" : url ? token ? void 0 : "Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`" : "Unable to find environment variable: `UPSTASH_REDIS_REST_URL`";
|
|
4793
|
-
if (messageInfo) {
|
|
4872
|
+
const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
|
|
4873
|
+
const token = env?.UPSTASH_REDIS_REST_TOKEN ?? UPSTASH_REDIS_REST_TOKEN;
|
|
4874
|
+
if (!url) {
|
|
4875
|
+
console.warn(
|
|
4876
|
+
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
|
|
4877
|
+
);
|
|
4878
|
+
}
|
|
4879
|
+
if (!token) {
|
|
4794
4880
|
console.warn(
|
|
4795
|
-
|
|
4881
|
+
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
|
|
4796
4882
|
);
|
|
4797
4883
|
}
|
|
4798
4884
|
return new _Redis({ ...opts, url, token }, env);
|