@upstash/redis 1.36.0 → 1.37.0-rc
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-4AG3JMXU.mjs → chunk-D4C7KXWT.mjs} +295 -199
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +306 -214
- package/cloudflare.mjs +10 -14
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +297 -201
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +144 -3
- package/nodejs.d.ts +144 -3
- package/nodejs.js +462 -213
- 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,15 +98,6 @@ 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
103
|
var HttpClient = class {
|
|
@@ -354,7 +345,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
354
345
|
"zrange",
|
|
355
346
|
"exec"
|
|
356
347
|
]);
|
|
357
|
-
function createAutoPipelineProxy(_redis,
|
|
348
|
+
function createAutoPipelineProxy(_redis, json) {
|
|
358
349
|
const redis = _redis;
|
|
359
350
|
if (!redis.autoPipelineExecutor) {
|
|
360
351
|
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
@@ -364,31 +355,29 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
|
|
|
364
355
|
if (command === "pipelineCounter") {
|
|
365
356
|
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
366
357
|
}
|
|
367
|
-
if (
|
|
368
|
-
return createAutoPipelineProxy(redis2,
|
|
369
|
-
}
|
|
370
|
-
if (namespace === "root" && command === "functions") {
|
|
371
|
-
return createAutoPipelineProxy(redis2, "functions");
|
|
358
|
+
if (command === "json") {
|
|
359
|
+
return createAutoPipelineProxy(redis2, true);
|
|
372
360
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
return redis2[command];
|
|
378
|
-
}
|
|
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];
|
|
379
365
|
}
|
|
380
|
-
const
|
|
381
|
-
const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
|
|
382
|
-
const isFunction = typeof targetFunction === "function";
|
|
366
|
+
const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
|
|
383
367
|
if (isFunction) {
|
|
384
368
|
return (...args) => {
|
|
385
|
-
return redis2.autoPipelineExecutor.withAutoPipeline((
|
|
386
|
-
|
|
387
|
-
|
|
369
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
|
|
370
|
+
if (json) {
|
|
371
|
+
pipeline.json[command](
|
|
372
|
+
...args
|
|
373
|
+
);
|
|
374
|
+
} else {
|
|
375
|
+
pipeline[command](...args);
|
|
376
|
+
}
|
|
388
377
|
});
|
|
389
378
|
};
|
|
390
379
|
}
|
|
391
|
-
return
|
|
380
|
+
return redis2.autoPipelineExecutor.pipeline[command];
|
|
392
381
|
}
|
|
393
382
|
});
|
|
394
383
|
}
|
|
@@ -681,23 +670,6 @@ var ExpireAtCommand = class extends Command {
|
|
|
681
670
|
}
|
|
682
671
|
};
|
|
683
672
|
|
|
684
|
-
// pkg/commands/fcall.ts
|
|
685
|
-
var FCallCommand = class extends Command {
|
|
686
|
-
constructor([functionName, keys, args], opts) {
|
|
687
|
-
super(["fcall", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []], opts);
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
// pkg/commands/fcall_ro.ts
|
|
692
|
-
var FCallRoCommand = class extends Command {
|
|
693
|
-
constructor([functionName, keys, args], opts) {
|
|
694
|
-
super(
|
|
695
|
-
["fcall_ro", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []],
|
|
696
|
-
opts
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
|
|
701
673
|
// pkg/commands/flushall.ts
|
|
702
674
|
var FlushAllCommand = class extends Command {
|
|
703
675
|
constructor(args, opts) {
|
|
@@ -720,85 +692,6 @@ var FlushDBCommand = class extends Command {
|
|
|
720
692
|
}
|
|
721
693
|
};
|
|
722
694
|
|
|
723
|
-
// pkg/commands/function_delete.ts
|
|
724
|
-
var FunctionDeleteCommand = class extends Command {
|
|
725
|
-
constructor([libraryName], opts) {
|
|
726
|
-
super(["function", "delete", libraryName], opts);
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
// pkg/commands/function_flush.ts
|
|
731
|
-
var FunctionFlushCommand = class extends Command {
|
|
732
|
-
constructor(opts) {
|
|
733
|
-
super(["function", "flush"], opts);
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// pkg/commands/function_list.ts
|
|
738
|
-
var FunctionListCommand = class extends Command {
|
|
739
|
-
constructor([args], opts) {
|
|
740
|
-
const command = ["function", "list"];
|
|
741
|
-
if (args?.libraryName) {
|
|
742
|
-
command.push("libraryname", args.libraryName);
|
|
743
|
-
}
|
|
744
|
-
if (args?.withCode) {
|
|
745
|
-
command.push("withcode");
|
|
746
|
-
}
|
|
747
|
-
super(command, { deserialize, ...opts });
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
function deserialize(result) {
|
|
751
|
-
if (!Array.isArray(result)) return [];
|
|
752
|
-
return result.map((libRaw) => {
|
|
753
|
-
const lib = kvArrayToObject(libRaw);
|
|
754
|
-
const functionsParsed = lib.functions.map(
|
|
755
|
-
(fnRaw) => kvArrayToObject(fnRaw)
|
|
756
|
-
);
|
|
757
|
-
return {
|
|
758
|
-
libraryName: lib.library_name,
|
|
759
|
-
engine: lib.engine,
|
|
760
|
-
functions: functionsParsed.map((fn) => ({
|
|
761
|
-
name: fn.name,
|
|
762
|
-
description: fn.description ?? void 0,
|
|
763
|
-
flags: fn.flags
|
|
764
|
-
})),
|
|
765
|
-
libraryCode: lib.library_code
|
|
766
|
-
};
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
// pkg/commands/function_load.ts
|
|
771
|
-
var FunctionLoadCommand = class extends Command {
|
|
772
|
-
constructor([args], opts) {
|
|
773
|
-
super(["function", "load", ...args.replace ? ["replace"] : [], args.code], opts);
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
// pkg/commands/function_stats.ts
|
|
778
|
-
var FunctionStatsCommand = class extends Command {
|
|
779
|
-
constructor(opts) {
|
|
780
|
-
super(["function", "stats"], { deserialize: deserialize2, ...opts });
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
function deserialize2(result) {
|
|
784
|
-
const rawEngines = kvArrayToObject(kvArrayToObject(result).engines);
|
|
785
|
-
const parsedEngines = Object.fromEntries(
|
|
786
|
-
Object.entries(rawEngines).map(([key, value]) => [key, kvArrayToObject(value)])
|
|
787
|
-
);
|
|
788
|
-
const final = {
|
|
789
|
-
engines: Object.fromEntries(
|
|
790
|
-
Object.entries(parsedEngines).map(([key, value]) => [
|
|
791
|
-
key,
|
|
792
|
-
{
|
|
793
|
-
librariesCount: value.libraries_count,
|
|
794
|
-
functionsCount: value.functions_count
|
|
795
|
-
}
|
|
796
|
-
])
|
|
797
|
-
)
|
|
798
|
-
};
|
|
799
|
-
return final;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
695
|
// pkg/commands/geo_add.ts
|
|
803
696
|
var GeoAddCommand = class extends Command {
|
|
804
697
|
constructor([key, arg1, ...arg2], opts) {
|
|
@@ -1145,7 +1038,7 @@ var HGetCommand = class extends Command {
|
|
|
1145
1038
|
};
|
|
1146
1039
|
|
|
1147
1040
|
// pkg/commands/hgetall.ts
|
|
1148
|
-
function
|
|
1041
|
+
function deserialize(result) {
|
|
1149
1042
|
if (result.length === 0) {
|
|
1150
1043
|
return null;
|
|
1151
1044
|
}
|
|
@@ -1165,7 +1058,7 @@ function deserialize3(result) {
|
|
|
1165
1058
|
var HGetAllCommand = class extends Command {
|
|
1166
1059
|
constructor(cmd, opts) {
|
|
1167
1060
|
super(["hgetall", ...cmd], {
|
|
1168
|
-
deserialize: (result) =>
|
|
1061
|
+
deserialize: (result) => deserialize(result),
|
|
1169
1062
|
...opts
|
|
1170
1063
|
});
|
|
1171
1064
|
}
|
|
@@ -1200,7 +1093,7 @@ var HLenCommand = class extends Command {
|
|
|
1200
1093
|
};
|
|
1201
1094
|
|
|
1202
1095
|
// pkg/commands/hmget.ts
|
|
1203
|
-
function
|
|
1096
|
+
function deserialize2(fields, result) {
|
|
1204
1097
|
if (result.every((field) => field === null)) {
|
|
1205
1098
|
return null;
|
|
1206
1099
|
}
|
|
@@ -1217,7 +1110,7 @@ function deserialize4(fields, result) {
|
|
|
1217
1110
|
var HMGetCommand = class extends Command {
|
|
1218
1111
|
constructor([key, ...fields], opts) {
|
|
1219
1112
|
super(["hmget", key, ...fields], {
|
|
1220
|
-
deserialize: (result) =>
|
|
1113
|
+
deserialize: (result) => deserialize2(fields, result),
|
|
1221
1114
|
...opts
|
|
1222
1115
|
});
|
|
1223
1116
|
}
|
|
@@ -1231,7 +1124,7 @@ var HMSetCommand = class extends Command {
|
|
|
1231
1124
|
};
|
|
1232
1125
|
|
|
1233
1126
|
// pkg/commands/hrandfield.ts
|
|
1234
|
-
function
|
|
1127
|
+
function deserialize3(result) {
|
|
1235
1128
|
if (result.length === 0) {
|
|
1236
1129
|
return null;
|
|
1237
1130
|
}
|
|
@@ -1258,7 +1151,7 @@ var HRandFieldCommand = class extends Command {
|
|
|
1258
1151
|
}
|
|
1259
1152
|
super(command, {
|
|
1260
1153
|
// @ts-expect-error to silence compiler
|
|
1261
|
-
deserialize: cmd[2] ? (result) =>
|
|
1154
|
+
deserialize: cmd[2] ? (result) => deserialize3(result) : opts?.deserialize,
|
|
1262
1155
|
...opts
|
|
1263
1156
|
});
|
|
1264
1157
|
}
|
|
@@ -2228,7 +2121,7 @@ var XPendingCommand = class extends Command {
|
|
|
2228
2121
|
};
|
|
2229
2122
|
|
|
2230
2123
|
// pkg/commands/xrange.ts
|
|
2231
|
-
function
|
|
2124
|
+
function deserialize4(result) {
|
|
2232
2125
|
const obj = {};
|
|
2233
2126
|
for (const e of result) {
|
|
2234
2127
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2257,7 +2150,7 @@ var XRangeCommand = class extends Command {
|
|
|
2257
2150
|
command.push("COUNT", count);
|
|
2258
2151
|
}
|
|
2259
2152
|
super(command, {
|
|
2260
|
-
deserialize: (result) =>
|
|
2153
|
+
deserialize: (result) => deserialize4(result),
|
|
2261
2154
|
...opts
|
|
2262
2155
|
});
|
|
2263
2156
|
}
|
|
@@ -2320,12 +2213,12 @@ var XRevRangeCommand = class extends Command {
|
|
|
2320
2213
|
command.push("COUNT", count);
|
|
2321
2214
|
}
|
|
2322
2215
|
super(command, {
|
|
2323
|
-
deserialize: (result) =>
|
|
2216
|
+
deserialize: (result) => deserialize5(result),
|
|
2324
2217
|
...opts
|
|
2325
2218
|
});
|
|
2326
2219
|
}
|
|
2327
2220
|
};
|
|
2328
|
-
function
|
|
2221
|
+
function deserialize5(result) {
|
|
2329
2222
|
const obj = {};
|
|
2330
2223
|
for (const e of result) {
|
|
2331
2224
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2595,6 +2488,265 @@ var ZUnionStoreCommand = class extends Command {
|
|
|
2595
2488
|
}
|
|
2596
2489
|
};
|
|
2597
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("SORTBY");
|
|
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
|
+
"RETURN",
|
|
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
|
+
|
|
2598
2750
|
// pkg/commands/psubscribe.ts
|
|
2599
2751
|
var PSubscribeCommand = class extends Command {
|
|
2600
2752
|
constructor(cmd, opts) {
|
|
@@ -3620,38 +3772,6 @@ var Pipeline = class {
|
|
|
3620
3772
|
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
3621
3773
|
};
|
|
3622
3774
|
}
|
|
3623
|
-
get functions() {
|
|
3624
|
-
return {
|
|
3625
|
-
/**
|
|
3626
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3627
|
-
*/
|
|
3628
|
-
load: (...args) => this.chain(new FunctionLoadCommand(args, this.commandOptions)),
|
|
3629
|
-
/**
|
|
3630
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3631
|
-
*/
|
|
3632
|
-
list: (...args) => this.chain(new FunctionListCommand(args, this.commandOptions)),
|
|
3633
|
-
/**
|
|
3634
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3635
|
-
*/
|
|
3636
|
-
delete: (...args) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)),
|
|
3637
|
-
/**
|
|
3638
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3639
|
-
*/
|
|
3640
|
-
flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)),
|
|
3641
|
-
/**
|
|
3642
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3643
|
-
*/
|
|
3644
|
-
stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)),
|
|
3645
|
-
/**
|
|
3646
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3647
|
-
*/
|
|
3648
|
-
call: (...args) => this.chain(new FCallCommand(args, this.commandOptions)),
|
|
3649
|
-
/**
|
|
3650
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3651
|
-
*/
|
|
3652
|
-
callRo: (...args) => this.chain(new FCallRoCommand(args, this.commandOptions))
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
3775
|
};
|
|
3656
3776
|
|
|
3657
3777
|
// pkg/script.ts
|
|
@@ -3913,40 +4033,6 @@ var Redis = class {
|
|
|
3913
4033
|
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
3914
4034
|
};
|
|
3915
4035
|
}
|
|
3916
|
-
get functions() {
|
|
3917
|
-
return {
|
|
3918
|
-
/**
|
|
3919
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3920
|
-
*/
|
|
3921
|
-
load: (...args) => new FunctionLoadCommand(args, this.opts).exec(this.client),
|
|
3922
|
-
/**
|
|
3923
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3924
|
-
*/
|
|
3925
|
-
list: (...args) => new FunctionListCommand(args, this.opts).exec(this.client),
|
|
3926
|
-
/**
|
|
3927
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3928
|
-
*/
|
|
3929
|
-
delete: (...args) => new FunctionDeleteCommand(args, this.opts).exec(this.client),
|
|
3930
|
-
/**
|
|
3931
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3932
|
-
*/
|
|
3933
|
-
flush: () => new FunctionFlushCommand(this.opts).exec(this.client),
|
|
3934
|
-
/**
|
|
3935
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3936
|
-
*
|
|
3937
|
-
* Note: `running_script` field is not supported and therefore not included in the type.
|
|
3938
|
-
*/
|
|
3939
|
-
stats: () => new FunctionStatsCommand(this.opts).exec(this.client),
|
|
3940
|
-
/**
|
|
3941
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3942
|
-
*/
|
|
3943
|
-
call: (...args) => new FCallCommand(args, this.opts).exec(this.client),
|
|
3944
|
-
/**
|
|
3945
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3946
|
-
*/
|
|
3947
|
-
callRo: (...args) => new FCallRoCommand(args, this.opts).exec(this.client)
|
|
3948
|
-
};
|
|
3949
|
-
}
|
|
3950
4036
|
/**
|
|
3951
4037
|
* Wrap a new middleware around the HTTP client.
|
|
3952
4038
|
*/
|
|
@@ -3997,6 +4083,16 @@ var Redis = class {
|
|
|
3997
4083
|
createScript(script, opts) {
|
|
3998
4084
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
3999
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
|
+
}
|
|
4000
4096
|
/**
|
|
4001
4097
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
4002
4098
|
*
|
|
@@ -4704,7 +4800,7 @@ var Redis = class {
|
|
|
4704
4800
|
};
|
|
4705
4801
|
|
|
4706
4802
|
// version.ts
|
|
4707
|
-
var VERSION = "v1.
|
|
4803
|
+
var VERSION = "v1.37.0-rc";
|
|
4708
4804
|
|
|
4709
4805
|
// platforms/cloudflare.ts
|
|
4710
4806
|
var Redis2 = class _Redis extends Redis {
|
|
@@ -4773,20 +4869,16 @@ var Redis2 = class _Redis extends Redis {
|
|
|
4773
4869
|
* ```
|
|
4774
4870
|
*/
|
|
4775
4871
|
static fromEnv(env, opts) {
|
|
4776
|
-
const url = env?.UPSTASH_REDIS_REST_URL ??
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
UPSTASH_REDIS_REST_TOKEN
|
|
4785
|
-
) : void 0);
|
|
4786
|
-
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`";
|
|
4787
|
-
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) {
|
|
4788
4880
|
console.warn(
|
|
4789
|
-
|
|
4881
|
+
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
|
|
4790
4882
|
);
|
|
4791
4883
|
}
|
|
4792
4884
|
return new _Redis({ ...opts, url, token }, env);
|