@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
|
@@ -77,15 +77,6 @@ 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
82
|
var HttpClient = class {
|
|
@@ -594,23 +585,6 @@ var ExpireAtCommand = class extends Command {
|
|
|
594
585
|
}
|
|
595
586
|
};
|
|
596
587
|
|
|
597
|
-
// pkg/commands/fcall.ts
|
|
598
|
-
var FCallCommand = class extends Command {
|
|
599
|
-
constructor([functionName, keys, args], opts) {
|
|
600
|
-
super(["fcall", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []], opts);
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
// pkg/commands/fcall_ro.ts
|
|
605
|
-
var FCallRoCommand = class extends Command {
|
|
606
|
-
constructor([functionName, keys, args], opts) {
|
|
607
|
-
super(
|
|
608
|
-
["fcall_ro", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []],
|
|
609
|
-
opts
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
|
|
614
588
|
// pkg/commands/flushall.ts
|
|
615
589
|
var FlushAllCommand = class extends Command {
|
|
616
590
|
constructor(args, opts) {
|
|
@@ -633,85 +607,6 @@ var FlushDBCommand = class extends Command {
|
|
|
633
607
|
}
|
|
634
608
|
};
|
|
635
609
|
|
|
636
|
-
// pkg/commands/function_delete.ts
|
|
637
|
-
var FunctionDeleteCommand = class extends Command {
|
|
638
|
-
constructor([libraryName], opts) {
|
|
639
|
-
super(["function", "delete", libraryName], opts);
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
// pkg/commands/function_flush.ts
|
|
644
|
-
var FunctionFlushCommand = class extends Command {
|
|
645
|
-
constructor(opts) {
|
|
646
|
-
super(["function", "flush"], opts);
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
// pkg/commands/function_list.ts
|
|
651
|
-
var FunctionListCommand = class extends Command {
|
|
652
|
-
constructor([args], opts) {
|
|
653
|
-
const command = ["function", "list"];
|
|
654
|
-
if (args?.libraryName) {
|
|
655
|
-
command.push("libraryname", args.libraryName);
|
|
656
|
-
}
|
|
657
|
-
if (args?.withCode) {
|
|
658
|
-
command.push("withcode");
|
|
659
|
-
}
|
|
660
|
-
super(command, { deserialize: deserialize2, ...opts });
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
function deserialize2(result) {
|
|
664
|
-
if (!Array.isArray(result)) return [];
|
|
665
|
-
return result.map((libRaw) => {
|
|
666
|
-
const lib = kvArrayToObject(libRaw);
|
|
667
|
-
const functionsParsed = lib.functions.map(
|
|
668
|
-
(fnRaw) => kvArrayToObject(fnRaw)
|
|
669
|
-
);
|
|
670
|
-
return {
|
|
671
|
-
libraryName: lib.library_name,
|
|
672
|
-
engine: lib.engine,
|
|
673
|
-
functions: functionsParsed.map((fn) => ({
|
|
674
|
-
name: fn.name,
|
|
675
|
-
description: fn.description ?? void 0,
|
|
676
|
-
flags: fn.flags
|
|
677
|
-
})),
|
|
678
|
-
libraryCode: lib.library_code
|
|
679
|
-
};
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
// pkg/commands/function_load.ts
|
|
684
|
-
var FunctionLoadCommand = class extends Command {
|
|
685
|
-
constructor([args], opts) {
|
|
686
|
-
super(["function", "load", ...args.replace ? ["replace"] : [], args.code], opts);
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
// pkg/commands/function_stats.ts
|
|
691
|
-
var FunctionStatsCommand = class extends Command {
|
|
692
|
-
constructor(opts) {
|
|
693
|
-
super(["function", "stats"], { deserialize: deserialize3, ...opts });
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
function deserialize3(result) {
|
|
697
|
-
const rawEngines = kvArrayToObject(kvArrayToObject(result).engines);
|
|
698
|
-
const parsedEngines = Object.fromEntries(
|
|
699
|
-
Object.entries(rawEngines).map(([key, value]) => [key, kvArrayToObject(value)])
|
|
700
|
-
);
|
|
701
|
-
const final = {
|
|
702
|
-
engines: Object.fromEntries(
|
|
703
|
-
Object.entries(parsedEngines).map(([key, value]) => [
|
|
704
|
-
key,
|
|
705
|
-
{
|
|
706
|
-
librariesCount: value.libraries_count,
|
|
707
|
-
functionsCount: value.functions_count
|
|
708
|
-
}
|
|
709
|
-
])
|
|
710
|
-
)
|
|
711
|
-
};
|
|
712
|
-
return final;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
610
|
// pkg/commands/geo_add.ts
|
|
716
611
|
var GeoAddCommand = class extends Command {
|
|
717
612
|
constructor([key, arg1, ...arg2], opts) {
|
|
@@ -1058,7 +953,7 @@ var HGetCommand = class extends Command {
|
|
|
1058
953
|
};
|
|
1059
954
|
|
|
1060
955
|
// pkg/commands/hgetall.ts
|
|
1061
|
-
function
|
|
956
|
+
function deserialize2(result) {
|
|
1062
957
|
if (result.length === 0) {
|
|
1063
958
|
return null;
|
|
1064
959
|
}
|
|
@@ -1078,7 +973,7 @@ function deserialize4(result) {
|
|
|
1078
973
|
var HGetAllCommand = class extends Command {
|
|
1079
974
|
constructor(cmd, opts) {
|
|
1080
975
|
super(["hgetall", ...cmd], {
|
|
1081
|
-
deserialize: (result) =>
|
|
976
|
+
deserialize: (result) => deserialize2(result),
|
|
1082
977
|
...opts
|
|
1083
978
|
});
|
|
1084
979
|
}
|
|
@@ -1113,7 +1008,7 @@ var HLenCommand = class extends Command {
|
|
|
1113
1008
|
};
|
|
1114
1009
|
|
|
1115
1010
|
// pkg/commands/hmget.ts
|
|
1116
|
-
function
|
|
1011
|
+
function deserialize3(fields, result) {
|
|
1117
1012
|
if (result.every((field) => field === null)) {
|
|
1118
1013
|
return null;
|
|
1119
1014
|
}
|
|
@@ -1130,7 +1025,7 @@ function deserialize5(fields, result) {
|
|
|
1130
1025
|
var HMGetCommand = class extends Command {
|
|
1131
1026
|
constructor([key, ...fields], opts) {
|
|
1132
1027
|
super(["hmget", key, ...fields], {
|
|
1133
|
-
deserialize: (result) =>
|
|
1028
|
+
deserialize: (result) => deserialize3(fields, result),
|
|
1134
1029
|
...opts
|
|
1135
1030
|
});
|
|
1136
1031
|
}
|
|
@@ -2107,7 +2002,7 @@ var XPendingCommand = class extends Command {
|
|
|
2107
2002
|
};
|
|
2108
2003
|
|
|
2109
2004
|
// pkg/commands/xrange.ts
|
|
2110
|
-
function
|
|
2005
|
+
function deserialize4(result) {
|
|
2111
2006
|
const obj = {};
|
|
2112
2007
|
for (const e of result) {
|
|
2113
2008
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2136,7 +2031,7 @@ var XRangeCommand = class extends Command {
|
|
|
2136
2031
|
command.push("COUNT", count);
|
|
2137
2032
|
}
|
|
2138
2033
|
super(command, {
|
|
2139
|
-
deserialize: (result) =>
|
|
2034
|
+
deserialize: (result) => deserialize4(result),
|
|
2140
2035
|
...opts
|
|
2141
2036
|
});
|
|
2142
2037
|
}
|
|
@@ -2199,12 +2094,12 @@ var XRevRangeCommand = class extends Command {
|
|
|
2199
2094
|
command.push("COUNT", count);
|
|
2200
2095
|
}
|
|
2201
2096
|
super(command, {
|
|
2202
|
-
deserialize: (result) =>
|
|
2097
|
+
deserialize: (result) => deserialize5(result),
|
|
2203
2098
|
...opts
|
|
2204
2099
|
});
|
|
2205
2100
|
}
|
|
2206
2101
|
};
|
|
2207
|
-
function
|
|
2102
|
+
function deserialize5(result) {
|
|
2208
2103
|
const obj = {};
|
|
2209
2104
|
for (const e of result) {
|
|
2210
2105
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -3313,38 +3208,6 @@ var Pipeline = class {
|
|
|
3313
3208
|
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
3314
3209
|
};
|
|
3315
3210
|
}
|
|
3316
|
-
get functions() {
|
|
3317
|
-
return {
|
|
3318
|
-
/**
|
|
3319
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3320
|
-
*/
|
|
3321
|
-
load: (...args) => this.chain(new FunctionLoadCommand(args, this.commandOptions)),
|
|
3322
|
-
/**
|
|
3323
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3324
|
-
*/
|
|
3325
|
-
list: (...args) => this.chain(new FunctionListCommand(args, this.commandOptions)),
|
|
3326
|
-
/**
|
|
3327
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3328
|
-
*/
|
|
3329
|
-
delete: (...args) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)),
|
|
3330
|
-
/**
|
|
3331
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3332
|
-
*/
|
|
3333
|
-
flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)),
|
|
3334
|
-
/**
|
|
3335
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3336
|
-
*/
|
|
3337
|
-
stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)),
|
|
3338
|
-
/**
|
|
3339
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3340
|
-
*/
|
|
3341
|
-
call: (...args) => this.chain(new FCallCommand(args, this.commandOptions)),
|
|
3342
|
-
/**
|
|
3343
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3344
|
-
*/
|
|
3345
|
-
callRo: (...args) => this.chain(new FCallRoCommand(args, this.commandOptions))
|
|
3346
|
-
};
|
|
3347
|
-
}
|
|
3348
3211
|
};
|
|
3349
3212
|
|
|
3350
3213
|
// pkg/auto-pipeline.ts
|
|
@@ -3366,7 +3229,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
3366
3229
|
"zrange",
|
|
3367
3230
|
"exec"
|
|
3368
3231
|
]);
|
|
3369
|
-
function createAutoPipelineProxy(_redis,
|
|
3232
|
+
function createAutoPipelineProxy(_redis, json) {
|
|
3370
3233
|
const redis = _redis;
|
|
3371
3234
|
if (!redis.autoPipelineExecutor) {
|
|
3372
3235
|
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
@@ -3376,31 +3239,29 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
|
|
|
3376
3239
|
if (command === "pipelineCounter") {
|
|
3377
3240
|
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
3378
3241
|
}
|
|
3379
|
-
if (
|
|
3380
|
-
return createAutoPipelineProxy(redis2,
|
|
3381
|
-
}
|
|
3382
|
-
if (namespace === "root" && command === "functions") {
|
|
3383
|
-
return createAutoPipelineProxy(redis2, "functions");
|
|
3242
|
+
if (command === "json") {
|
|
3243
|
+
return createAutoPipelineProxy(redis2, true);
|
|
3384
3244
|
}
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
return redis2[command];
|
|
3390
|
-
}
|
|
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];
|
|
3391
3249
|
}
|
|
3392
|
-
const
|
|
3393
|
-
const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
|
|
3394
|
-
const isFunction = typeof targetFunction === "function";
|
|
3250
|
+
const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
|
|
3395
3251
|
if (isFunction) {
|
|
3396
3252
|
return (...args) => {
|
|
3397
|
-
return redis2.autoPipelineExecutor.withAutoPipeline((
|
|
3398
|
-
|
|
3399
|
-
|
|
3253
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
|
|
3254
|
+
if (json) {
|
|
3255
|
+
pipeline.json[command](
|
|
3256
|
+
...args
|
|
3257
|
+
);
|
|
3258
|
+
} else {
|
|
3259
|
+
pipeline[command](...args);
|
|
3260
|
+
}
|
|
3400
3261
|
});
|
|
3401
3262
|
};
|
|
3402
3263
|
}
|
|
3403
|
-
return
|
|
3264
|
+
return redis2.autoPipelineExecutor.pipeline[command];
|
|
3404
3265
|
}
|
|
3405
3266
|
});
|
|
3406
3267
|
}
|
|
@@ -3447,6 +3308,265 @@ var AutoPipelineExecutor = class {
|
|
|
3447
3308
|
}
|
|
3448
3309
|
};
|
|
3449
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("SORTBY");
|
|
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
|
+
"RETURN",
|
|
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
|
+
|
|
3450
3570
|
// pkg/commands/psubscribe.ts
|
|
3451
3571
|
var PSubscribeCommand = class extends Command {
|
|
3452
3572
|
constructor(cmd, opts) {
|
|
@@ -3892,40 +4012,6 @@ var Redis = class {
|
|
|
3892
4012
|
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
3893
4013
|
};
|
|
3894
4014
|
}
|
|
3895
|
-
get functions() {
|
|
3896
|
-
return {
|
|
3897
|
-
/**
|
|
3898
|
-
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3899
|
-
*/
|
|
3900
|
-
load: (...args) => new FunctionLoadCommand(args, this.opts).exec(this.client),
|
|
3901
|
-
/**
|
|
3902
|
-
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3903
|
-
*/
|
|
3904
|
-
list: (...args) => new FunctionListCommand(args, this.opts).exec(this.client),
|
|
3905
|
-
/**
|
|
3906
|
-
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3907
|
-
*/
|
|
3908
|
-
delete: (...args) => new FunctionDeleteCommand(args, this.opts).exec(this.client),
|
|
3909
|
-
/**
|
|
3910
|
-
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3911
|
-
*/
|
|
3912
|
-
flush: () => new FunctionFlushCommand(this.opts).exec(this.client),
|
|
3913
|
-
/**
|
|
3914
|
-
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3915
|
-
*
|
|
3916
|
-
* Note: `running_script` field is not supported and therefore not included in the type.
|
|
3917
|
-
*/
|
|
3918
|
-
stats: () => new FunctionStatsCommand(this.opts).exec(this.client),
|
|
3919
|
-
/**
|
|
3920
|
-
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3921
|
-
*/
|
|
3922
|
-
call: (...args) => new FCallCommand(args, this.opts).exec(this.client),
|
|
3923
|
-
/**
|
|
3924
|
-
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3925
|
-
*/
|
|
3926
|
-
callRo: (...args) => new FCallRoCommand(args, this.opts).exec(this.client)
|
|
3927
|
-
};
|
|
3928
|
-
}
|
|
3929
4015
|
/**
|
|
3930
4016
|
* Wrap a new middleware around the HTTP client.
|
|
3931
4017
|
*/
|
|
@@ -3976,6 +4062,16 @@ var Redis = class {
|
|
|
3976
4062
|
createScript(script, opts) {
|
|
3977
4063
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
3978
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
|
+
}
|
|
3979
4075
|
/**
|
|
3980
4076
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
3981
4077
|
*
|
|
@@ -4683,7 +4779,7 @@ var Redis = class {
|
|
|
4683
4779
|
};
|
|
4684
4780
|
|
|
4685
4781
|
// version.ts
|
|
4686
|
-
var VERSION = "v1.
|
|
4782
|
+
var VERSION = "v1.37.0-rc";
|
|
4687
4783
|
|
|
4688
4784
|
export {
|
|
4689
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;
|
package/cloudflare.d.ts
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.js';
|
|
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.js';
|
|
3
3
|
|
|
4
4
|
type Env = {
|
|
5
5
|
UPSTASH_DISABLE_TELEMETRY?: string;
|