@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
|
@@ -77,18 +77,8 @@ function mergeHeaders(...headers) {
|
|
|
77
77
|
}
|
|
78
78
|
return merged;
|
|
79
79
|
}
|
|
80
|
-
function kvArrayToObject(v) {
|
|
81
|
-
if (typeof v === "object" && v !== null && !Array.isArray(v)) return v;
|
|
82
|
-
if (!Array.isArray(v)) return {};
|
|
83
|
-
const obj = {};
|
|
84
|
-
for (let i = 0; i < v.length; i += 2) {
|
|
85
|
-
if (typeof v[i] === "string") obj[v[i]] = v[i + 1];
|
|
86
|
-
}
|
|
87
|
-
return obj;
|
|
88
|
-
}
|
|
89
80
|
|
|
90
81
|
// pkg/http.ts
|
|
91
|
-
var MAX_BUFFER_SIZE = 1024 * 1024;
|
|
92
82
|
var HttpClient = class {
|
|
93
83
|
baseUrl;
|
|
94
84
|
headers;
|
|
@@ -212,16 +202,11 @@ var HttpClient = class {
|
|
|
212
202
|
const decoder = new TextDecoder();
|
|
213
203
|
(async () => {
|
|
214
204
|
try {
|
|
215
|
-
let buffer = "";
|
|
216
205
|
while (true) {
|
|
217
206
|
const { value, done } = await reader.read();
|
|
218
207
|
if (done) break;
|
|
219
|
-
|
|
220
|
-
const lines =
|
|
221
|
-
buffer = lines.pop() || "";
|
|
222
|
-
if (buffer.length > MAX_BUFFER_SIZE) {
|
|
223
|
-
throw new Error("Buffer size exceeded (1MB)");
|
|
224
|
-
}
|
|
208
|
+
const chunk = decoder.decode(value);
|
|
209
|
+
const lines = chunk.split("\n");
|
|
225
210
|
for (const line of lines) {
|
|
226
211
|
if (line.startsWith("data: ")) {
|
|
227
212
|
const data = line.slice(6);
|
|
@@ -600,23 +585,6 @@ var ExpireAtCommand = class extends Command {
|
|
|
600
585
|
}
|
|
601
586
|
};
|
|
602
587
|
|
|
603
|
-
// pkg/commands/fcall.ts
|
|
604
|
-
var FCallCommand = class extends Command {
|
|
605
|
-
constructor([functionName, keys, args], opts) {
|
|
606
|
-
super(["fcall", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []], opts);
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
// pkg/commands/fcall_ro.ts
|
|
611
|
-
var FCallRoCommand = class extends Command {
|
|
612
|
-
constructor([functionName, keys, args], opts) {
|
|
613
|
-
super(
|
|
614
|
-
["fcall_ro", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []],
|
|
615
|
-
opts
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
|
|
620
588
|
// pkg/commands/flushall.ts
|
|
621
589
|
var FlushAllCommand = class extends Command {
|
|
622
590
|
constructor(args, opts) {
|
|
@@ -639,85 +607,6 @@ var FlushDBCommand = class extends Command {
|
|
|
639
607
|
}
|
|
640
608
|
};
|
|
641
609
|
|
|
642
|
-
// pkg/commands/function_delete.ts
|
|
643
|
-
var FunctionDeleteCommand = class extends Command {
|
|
644
|
-
constructor([libraryName], opts) {
|
|
645
|
-
super(["function", "delete", libraryName], opts);
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
// pkg/commands/function_flush.ts
|
|
650
|
-
var FunctionFlushCommand = class extends Command {
|
|
651
|
-
constructor(opts) {
|
|
652
|
-
super(["function", "flush"], opts);
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
// pkg/commands/function_list.ts
|
|
657
|
-
var FunctionListCommand = class extends Command {
|
|
658
|
-
constructor([args], opts) {
|
|
659
|
-
const command = ["function", "list"];
|
|
660
|
-
if (args?.libraryName) {
|
|
661
|
-
command.push("libraryname", args.libraryName);
|
|
662
|
-
}
|
|
663
|
-
if (args?.withCode) {
|
|
664
|
-
command.push("withcode");
|
|
665
|
-
}
|
|
666
|
-
super(command, { deserialize: deserialize2, ...opts });
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
function deserialize2(result) {
|
|
670
|
-
if (!Array.isArray(result)) return [];
|
|
671
|
-
return result.map((libRaw) => {
|
|
672
|
-
const lib = kvArrayToObject(libRaw);
|
|
673
|
-
const functionsParsed = lib.functions.map(
|
|
674
|
-
(fnRaw) => kvArrayToObject(fnRaw)
|
|
675
|
-
);
|
|
676
|
-
return {
|
|
677
|
-
libraryName: lib.library_name,
|
|
678
|
-
engine: lib.engine,
|
|
679
|
-
functions: functionsParsed.map((fn) => ({
|
|
680
|
-
name: fn.name,
|
|
681
|
-
description: fn.description ?? void 0,
|
|
682
|
-
flags: fn.flags
|
|
683
|
-
})),
|
|
684
|
-
libraryCode: lib.library_code
|
|
685
|
-
};
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// pkg/commands/function_load.ts
|
|
690
|
-
var FunctionLoadCommand = class extends Command {
|
|
691
|
-
constructor([args], opts) {
|
|
692
|
-
super(["function", "load", ...args.replace ? ["replace"] : [], args.code], opts);
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
// pkg/commands/function_stats.ts
|
|
697
|
-
var FunctionStatsCommand = class extends Command {
|
|
698
|
-
constructor(opts) {
|
|
699
|
-
super(["function", "stats"], { deserialize: deserialize3, ...opts });
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
function deserialize3(result) {
|
|
703
|
-
const rawEngines = kvArrayToObject(kvArrayToObject(result).engines);
|
|
704
|
-
const parsedEngines = Object.fromEntries(
|
|
705
|
-
Object.entries(rawEngines).map(([key, value]) => [key, kvArrayToObject(value)])
|
|
706
|
-
);
|
|
707
|
-
const final = {
|
|
708
|
-
engines: Object.fromEntries(
|
|
709
|
-
Object.entries(parsedEngines).map(([key, value]) => [
|
|
710
|
-
key,
|
|
711
|
-
{
|
|
712
|
-
librariesCount: value.libraries_count,
|
|
713
|
-
functionsCount: value.functions_count
|
|
714
|
-
}
|
|
715
|
-
])
|
|
716
|
-
)
|
|
717
|
-
};
|
|
718
|
-
return final;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
610
|
// pkg/commands/geo_add.ts
|
|
722
611
|
var GeoAddCommand = class extends Command {
|
|
723
612
|
constructor([key, arg1, ...arg2], opts) {
|
|
@@ -1064,7 +953,7 @@ var HGetCommand = class extends Command {
|
|
|
1064
953
|
};
|
|
1065
954
|
|
|
1066
955
|
// pkg/commands/hgetall.ts
|
|
1067
|
-
function
|
|
956
|
+
function deserialize2(result) {
|
|
1068
957
|
if (result.length === 0) {
|
|
1069
958
|
return null;
|
|
1070
959
|
}
|
|
@@ -1084,7 +973,7 @@ function deserialize4(result) {
|
|
|
1084
973
|
var HGetAllCommand = class extends Command {
|
|
1085
974
|
constructor(cmd, opts) {
|
|
1086
975
|
super(["hgetall", ...cmd], {
|
|
1087
|
-
deserialize: (result) =>
|
|
976
|
+
deserialize: (result) => deserialize2(result),
|
|
1088
977
|
...opts
|
|
1089
978
|
});
|
|
1090
979
|
}
|
|
@@ -1119,7 +1008,7 @@ var HLenCommand = class extends Command {
|
|
|
1119
1008
|
};
|
|
1120
1009
|
|
|
1121
1010
|
// pkg/commands/hmget.ts
|
|
1122
|
-
function
|
|
1011
|
+
function deserialize3(fields, result) {
|
|
1123
1012
|
if (result.every((field) => field === null)) {
|
|
1124
1013
|
return null;
|
|
1125
1014
|
}
|
|
@@ -1136,7 +1025,7 @@ function deserialize5(fields, result) {
|
|
|
1136
1025
|
var HMGetCommand = class extends Command {
|
|
1137
1026
|
constructor([key, ...fields], opts) {
|
|
1138
1027
|
super(["hmget", key, ...fields], {
|
|
1139
|
-
deserialize: (result) =>
|
|
1028
|
+
deserialize: (result) => deserialize3(fields, result),
|
|
1140
1029
|
...opts
|
|
1141
1030
|
});
|
|
1142
1031
|
}
|
|
@@ -2113,7 +2002,7 @@ var XPendingCommand = class extends Command {
|
|
|
2113
2002
|
};
|
|
2114
2003
|
|
|
2115
2004
|
// pkg/commands/xrange.ts
|
|
2116
|
-
function
|
|
2005
|
+
function deserialize4(result) {
|
|
2117
2006
|
const obj = {};
|
|
2118
2007
|
for (const e of result) {
|
|
2119
2008
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2142,7 +2031,7 @@ var XRangeCommand = class extends Command {
|
|
|
2142
2031
|
command.push("COUNT", count);
|
|
2143
2032
|
}
|
|
2144
2033
|
super(command, {
|
|
2145
|
-
deserialize: (result) =>
|
|
2034
|
+
deserialize: (result) => deserialize4(result),
|
|
2146
2035
|
...opts
|
|
2147
2036
|
});
|
|
2148
2037
|
}
|
|
@@ -2205,12 +2094,12 @@ var XRevRangeCommand = class extends Command {
|
|
|
2205
2094
|
command.push("COUNT", count);
|
|
2206
2095
|
}
|
|
2207
2096
|
super(command, {
|
|
2208
|
-
deserialize: (result) =>
|
|
2097
|
+
deserialize: (result) => deserialize5(result),
|
|
2209
2098
|
...opts
|
|
2210
2099
|
});
|
|
2211
2100
|
}
|
|
2212
2101
|
};
|
|
2213
|
-
function
|
|
2102
|
+
function deserialize5(result) {
|
|
2214
2103
|
const obj = {};
|
|
2215
2104
|
for (const e of result) {
|
|
2216
2105
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -3319,38 +3208,6 @@ var Pipeline = class {
|
|
|
3319
3208
|
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
3320
3209
|
};
|
|
3321
3210
|
}
|
|
3322
|
-
get functions() {
|
|
3323
|
-
return {
|
|
3324
|
-
/**
|
|
3325
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3326
|
-
*/
|
|
3327
|
-
load: (...args) => this.chain(new FunctionLoadCommand(args, this.commandOptions)),
|
|
3328
|
-
/**
|
|
3329
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3330
|
-
*/
|
|
3331
|
-
list: (...args) => this.chain(new FunctionListCommand(args, this.commandOptions)),
|
|
3332
|
-
/**
|
|
3333
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3334
|
-
*/
|
|
3335
|
-
delete: (...args) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)),
|
|
3336
|
-
/**
|
|
3337
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3338
|
-
*/
|
|
3339
|
-
flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)),
|
|
3340
|
-
/**
|
|
3341
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3342
|
-
*/
|
|
3343
|
-
stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)),
|
|
3344
|
-
/**
|
|
3345
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3346
|
-
*/
|
|
3347
|
-
call: (...args) => this.chain(new FCallCommand(args, this.commandOptions)),
|
|
3348
|
-
/**
|
|
3349
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3350
|
-
*/
|
|
3351
|
-
callRo: (...args) => this.chain(new FCallRoCommand(args, this.commandOptions))
|
|
3352
|
-
};
|
|
3353
|
-
}
|
|
3354
3211
|
};
|
|
3355
3212
|
|
|
3356
3213
|
// pkg/auto-pipeline.ts
|
|
@@ -3372,7 +3229,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
3372
3229
|
"zrange",
|
|
3373
3230
|
"exec"
|
|
3374
3231
|
]);
|
|
3375
|
-
function createAutoPipelineProxy(_redis,
|
|
3232
|
+
function createAutoPipelineProxy(_redis, json) {
|
|
3376
3233
|
const redis = _redis;
|
|
3377
3234
|
if (!redis.autoPipelineExecutor) {
|
|
3378
3235
|
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
@@ -3382,31 +3239,29 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
|
|
|
3382
3239
|
if (command === "pipelineCounter") {
|
|
3383
3240
|
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
3384
3241
|
}
|
|
3385
|
-
if (
|
|
3386
|
-
return createAutoPipelineProxy(redis2,
|
|
3387
|
-
}
|
|
3388
|
-
if (namespace === "root" && command === "functions") {
|
|
3389
|
-
return createAutoPipelineProxy(redis2, "functions");
|
|
3242
|
+
if (command === "json") {
|
|
3243
|
+
return createAutoPipelineProxy(redis2, true);
|
|
3390
3244
|
}
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
return redis2[command];
|
|
3396
|
-
}
|
|
3245
|
+
const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
|
|
3246
|
+
const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
|
|
3247
|
+
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
3248
|
+
return redis2[command];
|
|
3397
3249
|
}
|
|
3398
|
-
const
|
|
3399
|
-
const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
|
|
3400
|
-
const isFunction = typeof targetFunction === "function";
|
|
3250
|
+
const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
|
|
3401
3251
|
if (isFunction) {
|
|
3402
3252
|
return (...args) => {
|
|
3403
|
-
return redis2.autoPipelineExecutor.withAutoPipeline((
|
|
3404
|
-
|
|
3405
|
-
|
|
3253
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
|
|
3254
|
+
if (json) {
|
|
3255
|
+
pipeline.json[command](
|
|
3256
|
+
...args
|
|
3257
|
+
);
|
|
3258
|
+
} else {
|
|
3259
|
+
pipeline[command](...args);
|
|
3260
|
+
}
|
|
3406
3261
|
});
|
|
3407
3262
|
};
|
|
3408
3263
|
}
|
|
3409
|
-
return
|
|
3264
|
+
return redis2.autoPipelineExecutor.pipeline[command];
|
|
3410
3265
|
}
|
|
3411
3266
|
});
|
|
3412
3267
|
}
|
|
@@ -3453,6 +3308,265 @@ var AutoPipelineExecutor = class {
|
|
|
3453
3308
|
}
|
|
3454
3309
|
};
|
|
3455
3310
|
|
|
3311
|
+
// pkg/commands/search/types.ts
|
|
3312
|
+
var FIELD_TYPES = ["TEXT", "U64", "I64", "F64", "BOOL", "DATE"];
|
|
3313
|
+
|
|
3314
|
+
// pkg/commands/search/utils.ts
|
|
3315
|
+
function isFieldType(value) {
|
|
3316
|
+
return typeof value === "string" && FIELD_TYPES.includes(value);
|
|
3317
|
+
}
|
|
3318
|
+
function isDetailedField(value) {
|
|
3319
|
+
return typeof value === "object" && value !== null && "type" in value && isFieldType(value.type);
|
|
3320
|
+
}
|
|
3321
|
+
function isNestedSchema(value) {
|
|
3322
|
+
return typeof value === "object" && value !== null && !isDetailedField(value);
|
|
3323
|
+
}
|
|
3324
|
+
function flattenSchema(schema, pathPrefix = []) {
|
|
3325
|
+
const fields = [];
|
|
3326
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
3327
|
+
const currentPath = [...pathPrefix, key];
|
|
3328
|
+
const pathString = currentPath.join(".");
|
|
3329
|
+
if (isFieldType(value)) {
|
|
3330
|
+
fields.push({
|
|
3331
|
+
path: pathString,
|
|
3332
|
+
type: value
|
|
3333
|
+
});
|
|
3334
|
+
} else if (isDetailedField(value)) {
|
|
3335
|
+
fields.push({
|
|
3336
|
+
path: pathString,
|
|
3337
|
+
type: value.type,
|
|
3338
|
+
fast: "fast" in value ? value.fast : void 0,
|
|
3339
|
+
noTokenize: "noTokenize" in value ? value.noTokenize : void 0,
|
|
3340
|
+
noStem: "noStem" in value ? value.noStem : void 0,
|
|
3341
|
+
from: "from" in value ? value.from : void 0
|
|
3342
|
+
});
|
|
3343
|
+
} else if (isNestedSchema(value)) {
|
|
3344
|
+
const nestedFields = flattenSchema(value, currentPath);
|
|
3345
|
+
fields.push(...nestedFields);
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
return fields;
|
|
3349
|
+
}
|
|
3350
|
+
function deserializeQueryResponse(rawResponse) {
|
|
3351
|
+
return rawResponse.map((itemRaw) => {
|
|
3352
|
+
const raw = itemRaw;
|
|
3353
|
+
const key = raw[0];
|
|
3354
|
+
const score = raw[1];
|
|
3355
|
+
const rawFields = raw[2];
|
|
3356
|
+
if (rawFields === void 0) {
|
|
3357
|
+
return { key, score };
|
|
3358
|
+
}
|
|
3359
|
+
if (!Array.isArray(rawFields) || rawFields.length === 0) {
|
|
3360
|
+
return { key, score, data: {} };
|
|
3361
|
+
}
|
|
3362
|
+
let data = {};
|
|
3363
|
+
for (const fieldRaw of rawFields) {
|
|
3364
|
+
const key2 = fieldRaw[0];
|
|
3365
|
+
const value = fieldRaw[1];
|
|
3366
|
+
const pathParts = key2.split(".");
|
|
3367
|
+
if (pathParts.length == 1) {
|
|
3368
|
+
data[key2] = value;
|
|
3369
|
+
} else {
|
|
3370
|
+
let currentObj = data;
|
|
3371
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
3372
|
+
const pathPart = pathParts[i];
|
|
3373
|
+
if (!(pathPart in currentObj)) {
|
|
3374
|
+
currentObj[pathPart] = {};
|
|
3375
|
+
}
|
|
3376
|
+
currentObj = currentObj[pathPart];
|
|
3377
|
+
}
|
|
3378
|
+
currentObj[pathParts.at(-1)] = value;
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
if ("$" in data) {
|
|
3382
|
+
data = data["$"];
|
|
3383
|
+
}
|
|
3384
|
+
return { key, score, data };
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
function deserializeDescribeResponse(rawResponse) {
|
|
3388
|
+
const description = {};
|
|
3389
|
+
for (let i = 0; i < rawResponse.length; i += 2) {
|
|
3390
|
+
const descriptor = rawResponse[i];
|
|
3391
|
+
switch (descriptor) {
|
|
3392
|
+
case "name": {
|
|
3393
|
+
description["name"] = rawResponse[i + 1];
|
|
3394
|
+
break;
|
|
3395
|
+
}
|
|
3396
|
+
case "type": {
|
|
3397
|
+
description["dataType"] = rawResponse[i + 1].toLowerCase();
|
|
3398
|
+
break;
|
|
3399
|
+
}
|
|
3400
|
+
case "prefixes": {
|
|
3401
|
+
description["prefixes"] = rawResponse[i + 1];
|
|
3402
|
+
break;
|
|
3403
|
+
}
|
|
3404
|
+
case "language": {
|
|
3405
|
+
description["language"] = rawResponse[i + 1];
|
|
3406
|
+
break;
|
|
3407
|
+
}
|
|
3408
|
+
case "schema": {
|
|
3409
|
+
const schema = {};
|
|
3410
|
+
for (const fieldDescription of rawResponse[i + 1]) {
|
|
3411
|
+
const fieldName = fieldDescription[0];
|
|
3412
|
+
const fieldInfo = { type: fieldDescription[1] };
|
|
3413
|
+
if (fieldDescription.length > 2) {
|
|
3414
|
+
for (let j = 2; j < fieldDescription.length; j++) {
|
|
3415
|
+
const fieldOption = fieldDescription[j];
|
|
3416
|
+
switch (fieldOption) {
|
|
3417
|
+
case "NOSTEM": {
|
|
3418
|
+
fieldInfo.noStem = true;
|
|
3419
|
+
break;
|
|
3420
|
+
}
|
|
3421
|
+
case "NOTOKENIZE": {
|
|
3422
|
+
fieldInfo.noTokenize = true;
|
|
3423
|
+
break;
|
|
3424
|
+
}
|
|
3425
|
+
case "FAST": {
|
|
3426
|
+
fieldInfo.fast = true;
|
|
3427
|
+
break;
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
schema[fieldName] = fieldInfo;
|
|
3433
|
+
}
|
|
3434
|
+
description["schema"] = schema;
|
|
3435
|
+
break;
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
return description;
|
|
3440
|
+
}
|
|
3441
|
+
function parseCountResponse(rawResponse) {
|
|
3442
|
+
return typeof rawResponse === "number" ? rawResponse : Number.parseInt(rawResponse, 10);
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
// pkg/commands/search/command-builder.ts
|
|
3446
|
+
function buildQueryCommand(redisCommand, name, options) {
|
|
3447
|
+
const query = JSON.stringify(options?.filter ?? {});
|
|
3448
|
+
const command = [redisCommand, name, query];
|
|
3449
|
+
if (options?.limit !== void 0) {
|
|
3450
|
+
command.push("LIMIT", options.limit.toString());
|
|
3451
|
+
}
|
|
3452
|
+
if (options?.offset !== void 0) {
|
|
3453
|
+
command.push("OFFSET", options.offset.toString());
|
|
3454
|
+
}
|
|
3455
|
+
if (options?.select && Object.keys(options.select).length === 0) {
|
|
3456
|
+
command.push("NOCONTENT");
|
|
3457
|
+
}
|
|
3458
|
+
if (options?.orderBy) {
|
|
3459
|
+
command.push("ORDERBY");
|
|
3460
|
+
for (const [field, direction] of Object.entries(options.orderBy)) {
|
|
3461
|
+
command.push(field, direction);
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
if (options?.highlight) {
|
|
3465
|
+
command.push(
|
|
3466
|
+
"HIGHLIGHT",
|
|
3467
|
+
"FIELDS",
|
|
3468
|
+
options.highlight.fields.length.toString(),
|
|
3469
|
+
...options.highlight.fields
|
|
3470
|
+
);
|
|
3471
|
+
if (options.highlight.preTag && options.highlight.postTag) {
|
|
3472
|
+
command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
if (options?.select && Object.keys(options.select).length > 0) {
|
|
3476
|
+
command.push(
|
|
3477
|
+
"SELECT",
|
|
3478
|
+
Object.keys(options.select).length.toString(),
|
|
3479
|
+
...Object.keys(options.select)
|
|
3480
|
+
);
|
|
3481
|
+
}
|
|
3482
|
+
return command;
|
|
3483
|
+
}
|
|
3484
|
+
function buildCreateIndexCommand(params) {
|
|
3485
|
+
const { name, schema, dataType, prefix, language, skipInitialScan, existsOk } = params;
|
|
3486
|
+
const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
|
|
3487
|
+
const payload = [
|
|
3488
|
+
name,
|
|
3489
|
+
...skipInitialScan ? ["SKIPINITIALSCAN"] : [],
|
|
3490
|
+
...existsOk ? ["EXISTSOK"] : [],
|
|
3491
|
+
"ON",
|
|
3492
|
+
dataType.toUpperCase(),
|
|
3493
|
+
"PREFIX",
|
|
3494
|
+
prefixArray.length.toString(),
|
|
3495
|
+
...prefixArray,
|
|
3496
|
+
...language ? ["LANGUAGE", language] : [],
|
|
3497
|
+
"SCHEMA"
|
|
3498
|
+
];
|
|
3499
|
+
const fields = flattenSchema(schema);
|
|
3500
|
+
for (const field of fields) {
|
|
3501
|
+
payload.push(field.path, field.type);
|
|
3502
|
+
if (field.fast) {
|
|
3503
|
+
payload.push("FAST");
|
|
3504
|
+
}
|
|
3505
|
+
if (field.noTokenize) {
|
|
3506
|
+
payload.push("NOTOKENIZE");
|
|
3507
|
+
}
|
|
3508
|
+
if (field.noStem) {
|
|
3509
|
+
payload.push("NOSTEM");
|
|
3510
|
+
}
|
|
3511
|
+
if (field.from) {
|
|
3512
|
+
payload.push("FROM", field.from);
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
return ["SEARCH.CREATE", ...payload];
|
|
3516
|
+
}
|
|
3517
|
+
|
|
3518
|
+
// pkg/commands/search/search.ts
|
|
3519
|
+
var SearchIndex = class {
|
|
3520
|
+
name;
|
|
3521
|
+
schema;
|
|
3522
|
+
client;
|
|
3523
|
+
constructor({ name, schema, client }) {
|
|
3524
|
+
this.name = name;
|
|
3525
|
+
this.schema = schema;
|
|
3526
|
+
this.client = client;
|
|
3527
|
+
}
|
|
3528
|
+
async waitIndexing() {
|
|
3529
|
+
const command = ["SEARCH.WAITINDEXING", this.name];
|
|
3530
|
+
await new ExecCommand(command).exec(this.client);
|
|
3531
|
+
}
|
|
3532
|
+
async describe() {
|
|
3533
|
+
const command = ["SEARCH.DESCRIBE", this.name];
|
|
3534
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
3535
|
+
this.client
|
|
3536
|
+
);
|
|
3537
|
+
return deserializeDescribeResponse(rawResult);
|
|
3538
|
+
}
|
|
3539
|
+
async query(options) {
|
|
3540
|
+
const command = buildQueryCommand("SEARCH.QUERY", this.name, options);
|
|
3541
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
3542
|
+
this.client
|
|
3543
|
+
);
|
|
3544
|
+
return deserializeQueryResponse(rawResult);
|
|
3545
|
+
}
|
|
3546
|
+
async count({ filter }) {
|
|
3547
|
+
const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
|
|
3548
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
3549
|
+
this.client
|
|
3550
|
+
);
|
|
3551
|
+
return { count: parseCountResponse(rawResult) };
|
|
3552
|
+
}
|
|
3553
|
+
async drop() {
|
|
3554
|
+
const command = ["SEARCH.DROP", this.name];
|
|
3555
|
+
const result = await new ExecCommand(command).exec(this.client);
|
|
3556
|
+
return result;
|
|
3557
|
+
}
|
|
3558
|
+
};
|
|
3559
|
+
async function createIndex(client, params) {
|
|
3560
|
+
const { name, schema } = params;
|
|
3561
|
+
const createIndexCommand = buildCreateIndexCommand(params);
|
|
3562
|
+
await new ExecCommand(createIndexCommand).exec(client);
|
|
3563
|
+
return initIndex(client, { name, schema });
|
|
3564
|
+
}
|
|
3565
|
+
function initIndex(client, params) {
|
|
3566
|
+
const { name, schema } = params;
|
|
3567
|
+
return new SearchIndex({ name, schema, client });
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3456
3570
|
// pkg/commands/psubscribe.ts
|
|
3457
3571
|
var PSubscribeCommand = class extends Command {
|
|
3458
3572
|
constructor(cmd, opts) {
|
|
@@ -3898,40 +4012,6 @@ var Redis = class {
|
|
|
3898
4012
|
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
3899
4013
|
};
|
|
3900
4014
|
}
|
|
3901
|
-
get functions() {
|
|
3902
|
-
return {
|
|
3903
|
-
/**
|
|
3904
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3905
|
-
*/
|
|
3906
|
-
load: (...args) => new FunctionLoadCommand(args, this.opts).exec(this.client),
|
|
3907
|
-
/**
|
|
3908
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3909
|
-
*/
|
|
3910
|
-
list: (...args) => new FunctionListCommand(args, this.opts).exec(this.client),
|
|
3911
|
-
/**
|
|
3912
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3913
|
-
*/
|
|
3914
|
-
delete: (...args) => new FunctionDeleteCommand(args, this.opts).exec(this.client),
|
|
3915
|
-
/**
|
|
3916
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3917
|
-
*/
|
|
3918
|
-
flush: () => new FunctionFlushCommand(this.opts).exec(this.client),
|
|
3919
|
-
/**
|
|
3920
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3921
|
-
*
|
|
3922
|
-
* Note: `running_script` field is not supported and therefore not included in the type.
|
|
3923
|
-
*/
|
|
3924
|
-
stats: () => new FunctionStatsCommand(this.opts).exec(this.client),
|
|
3925
|
-
/**
|
|
3926
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3927
|
-
*/
|
|
3928
|
-
call: (...args) => new FCallCommand(args, this.opts).exec(this.client),
|
|
3929
|
-
/**
|
|
3930
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3931
|
-
*/
|
|
3932
|
-
callRo: (...args) => new FCallRoCommand(args, this.opts).exec(this.client)
|
|
3933
|
-
};
|
|
3934
|
-
}
|
|
3935
4015
|
/**
|
|
3936
4016
|
* Wrap a new middleware around the HTTP client.
|
|
3937
4017
|
*/
|
|
@@ -3982,6 +4062,16 @@ var Redis = class {
|
|
|
3982
4062
|
createScript(script, opts) {
|
|
3983
4063
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
3984
4064
|
}
|
|
4065
|
+
get search() {
|
|
4066
|
+
return {
|
|
4067
|
+
createIndex: (params) => {
|
|
4068
|
+
return createIndex(this.client, params);
|
|
4069
|
+
},
|
|
4070
|
+
index: (params) => {
|
|
4071
|
+
return initIndex(this.client, params);
|
|
4072
|
+
}
|
|
4073
|
+
};
|
|
4074
|
+
}
|
|
3985
4075
|
/**
|
|
3986
4076
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
3987
4077
|
*
|
|
@@ -4689,7 +4779,7 @@ var Redis = class {
|
|
|
4689
4779
|
};
|
|
4690
4780
|
|
|
4691
4781
|
// version.ts
|
|
4692
|
-
var VERSION = "v1.
|
|
4782
|
+
var VERSION = "v1.37.0-rc.1";
|
|
4693
4783
|
|
|
4694
4784
|
export {
|
|
4695
4785
|
error_exports,
|
package/cloudflare.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HttpClientConfig, R as RedisOptions,
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand,
|
|
1
|
+
import { H as HttpClientConfig, R as RedisOptions, b as RequesterConfig, c as Redis$1 } from './zmscore-BpOSd5F5.mjs';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, g as BitOpCommand, h as BitPosCommand, C as CopyCommand, D as DBSizeCommand, j as DecrByCommand, i as DecrCommand, k as DelCommand, E as EchoCommand, m as EvalCommand, l as EvalROCommand, o as EvalshaCommand, n as EvalshaROCommand, p as ExistsCommand, s as ExpireAtCommand, q as ExpireCommand, r as ExpireOption, F as FlushAllCommand, t as FlushDBCommand, G as GeoAddCommand, u as GeoAddCommandOptions, w as GeoDistCommand, x as GeoHashCommand, v as GeoMember, y as GeoPosCommand, z as GeoSearchCommand, I as GeoSearchStoreCommand, K as GetBitCommand, J as GetCommand, L as GetDelCommand, M as GetExCommand, O as GetRangeCommand, Q as GetSetCommand, S as HDelCommand, T as HExistsCommand, W as HExpireAtCommand, V as HExpireCommand, X as HExpireTimeCommand, a3 as HGetAllCommand, a2 as HGetCommand, a4 as HIncrByCommand, a5 as HIncrByFloatCommand, a6 as HKeysCommand, a7 as HLenCommand, a8 as HMGetCommand, a9 as HMSetCommand, _ as HPExpireAtCommand, Z as HPExpireCommand, $ as HPExpireTimeCommand, a0 as HPTtlCommand, a1 as HPersistCommand, aa as HRandFieldCommand, ab as HScanCommand, ac as HSetCommand, ad as HSetNXCommand, ae as HStrLenCommand, Y as HTtlCommand, af as HValsCommand, ah as IncrByCommand, ai as IncrByFloatCommand, ag as IncrCommand, aj as JsonArrAppendCommand, ak as JsonArrIndexCommand, al as JsonArrInsertCommand, am as JsonArrLenCommand, an as JsonArrPopCommand, ao as JsonArrTrimCommand, ap as JsonClearCommand, aq as JsonDelCommand, ar as JsonForgetCommand, as as JsonGetCommand, au as JsonMGetCommand, at as JsonMergeCommand, av as JsonNumIncrByCommand, aw as JsonNumMultByCommand, ax as JsonObjKeysCommand, ay as JsonObjLenCommand, az as JsonRespCommand, aA as JsonSetCommand, aB as JsonStrAppendCommand, aC as JsonStrLenCommand, aD as JsonToggleCommand, aE as JsonTypeCommand, aF as KeysCommand, aG as LIndexCommand, aH as LInsertCommand, aI as LLenCommand, aJ as LMoveCommand, aK as LPopCommand, aL as LPushCommand, aM as LPushXCommand, aN as LRangeCommand, aO as LRemCommand, aP as LSetCommand, aQ as LTrimCommand, aR as MGetCommand, aS as MSetCommand, aT as MSetNXCommand, aW as PExpireAtCommand, aV as PExpireCommand, aY as PSetEXCommand, aZ as PTtlCommand, aU as PersistCommand, aX as PingCommand, P as Pipeline, a_ as PublishCommand, b2 as RPopCommand, b3 as RPushCommand, b4 as RPushXCommand, a$ as RandomKeyCommand, b0 as RenameCommand, b1 as RenameNXCommand, d as Requester, b5 as SAddCommand, b8 as SCardCommand, bc as SDiffCommand, bd as SDiffStoreCommand, bk as SInterCommand, bl as SInterStoreCommand, bm as SIsMemberCommand, bo as SMIsMemberCommand, bn as SMembersCommand, bp as SMoveCommand, bq as SPopCommand, br as SRandMemberCommand, bs as SRemCommand, bt as SScanCommand, bv as SUnionCommand, bw as SUnionStoreCommand, b6 as ScanCommand, b7 as ScanCommandOptions, bF as ScoreMember, b9 as ScriptExistsCommand, ba as ScriptFlushCommand, bb as ScriptLoadCommand, bg as SetBitCommand, be as SetCommand, bf as SetCommandOptions, bh as SetExCommand, bi as SetNxCommand, bj as SetRangeCommand, bu as StrLenCommand, bx as TimeCommand, by as TouchCommand, bz as TtlCommand, bA as Type, bB as TypeCommand, bC as UnlinkCommand, U as UpstashRequest, f as UpstashResponse, bD as XAddCommand, bE as XRangeCommand, bH as ZAddCommand, bG as ZAddCommandOptions, bI as ZCardCommand, bJ as ZCountCommand, bK as ZDiffStoreCommand, bL as ZIncrByCommand, bM as ZInterStoreCommand, bN as ZInterStoreCommandOptions, bO as ZLexCountCommand, bP as ZMScoreCommand, bQ as ZPopMaxCommand, bR as ZPopMinCommand, bS as ZRangeCommand, bT as ZRangeCommandOptions, bU as ZRankCommand, bV as ZRemCommand, bW as ZRemRangeByLexCommand, bX as ZRemRangeByRankCommand, bY as ZRemRangeByScoreCommand, bZ as ZRevRankCommand, b_ as ZScanCommand, b$ as ZScoreCommand, c0 as ZUnionCommand, c1 as ZUnionCommandOptions, c2 as ZUnionStoreCommand, c3 as ZUnionStoreCommandOptions, e as errors } from './zmscore-BpOSd5F5.mjs';
|
|
3
3
|
|
|
4
4
|
type Env = {
|
|
5
5
|
UPSTASH_DISABLE_TELEMETRY?: string;
|