@upstash/redis 1.36.0-rc.4 → 1.36.0
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-P45C5Z47.mjs → chunk-4AG3JMXU.mjs} +215 -404
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +222 -379
- package/cloudflare.mjs +14 -10
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +209 -370
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +3 -94
- package/nodejs.d.ts +3 -94
- package/nodejs.js +217 -407
- package/nodejs.mjs +9 -13
- package/package.json +1 -1
- package/{zmscore-BfRVhSFL.d.mts → zmscore-0SAuWM0q.d.mts} +125 -319
- package/{zmscore-BfRVhSFL.d.ts → zmscore-0SAuWM0q.d.ts} +125 -319
package/fastly.js
CHANGED
|
@@ -98,6 +98,15 @@ 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
|
+
}
|
|
101
110
|
|
|
102
111
|
// pkg/http.ts
|
|
103
112
|
var HttpClient = class {
|
|
@@ -345,7 +354,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
345
354
|
"zrange",
|
|
346
355
|
"exec"
|
|
347
356
|
]);
|
|
348
|
-
function createAutoPipelineProxy(_redis,
|
|
357
|
+
function createAutoPipelineProxy(_redis, namespace = "root") {
|
|
349
358
|
const redis = _redis;
|
|
350
359
|
if (!redis.autoPipelineExecutor) {
|
|
351
360
|
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
@@ -355,29 +364,31 @@ function createAutoPipelineProxy(_redis, json) {
|
|
|
355
364
|
if (command === "pipelineCounter") {
|
|
356
365
|
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
357
366
|
}
|
|
358
|
-
if (command === "json") {
|
|
359
|
-
return createAutoPipelineProxy(redis2,
|
|
367
|
+
if (namespace === "root" && command === "json") {
|
|
368
|
+
return createAutoPipelineProxy(redis2, "json");
|
|
360
369
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
364
|
-
return redis2[command];
|
|
370
|
+
if (namespace === "root" && command === "functions") {
|
|
371
|
+
return createAutoPipelineProxy(redis2, "functions");
|
|
365
372
|
}
|
|
366
|
-
|
|
373
|
+
if (namespace === "root") {
|
|
374
|
+
const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
|
|
375
|
+
const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
|
|
376
|
+
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
377
|
+
return redis2[command];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const pipeline = redis2.autoPipelineExecutor.pipeline;
|
|
381
|
+
const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
|
|
382
|
+
const isFunction = typeof targetFunction === "function";
|
|
367
383
|
if (isFunction) {
|
|
368
384
|
return (...args) => {
|
|
369
|
-
return redis2.autoPipelineExecutor.withAutoPipeline((
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
...args
|
|
373
|
-
);
|
|
374
|
-
} else {
|
|
375
|
-
pipeline[command](...args);
|
|
376
|
-
}
|
|
385
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
|
|
386
|
+
const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
|
|
387
|
+
targetFunction2(...args);
|
|
377
388
|
});
|
|
378
389
|
};
|
|
379
390
|
}
|
|
380
|
-
return
|
|
391
|
+
return targetFunction;
|
|
381
392
|
}
|
|
382
393
|
});
|
|
383
394
|
}
|
|
@@ -400,7 +411,7 @@ var AutoPipelineExecutor = class {
|
|
|
400
411
|
this.activePipeline = pipeline;
|
|
401
412
|
this.indexInCurrentPipeline = 0;
|
|
402
413
|
}
|
|
403
|
-
const
|
|
414
|
+
const index = this.indexInCurrentPipeline++;
|
|
404
415
|
executeWithPipeline(pipeline);
|
|
405
416
|
const pipelineDone = this.deferExecution().then(() => {
|
|
406
417
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
@@ -412,7 +423,7 @@ var AutoPipelineExecutor = class {
|
|
|
412
423
|
return this.pipelinePromises.get(pipeline);
|
|
413
424
|
});
|
|
414
425
|
const results = await pipelineDone;
|
|
415
|
-
const commandResult = results[
|
|
426
|
+
const commandResult = results[index];
|
|
416
427
|
if (commandResult.error) {
|
|
417
428
|
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
418
429
|
}
|
|
@@ -670,6 +681,23 @@ var ExpireAtCommand = class extends Command {
|
|
|
670
681
|
}
|
|
671
682
|
};
|
|
672
683
|
|
|
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
|
+
|
|
673
701
|
// pkg/commands/flushall.ts
|
|
674
702
|
var FlushAllCommand = class extends Command {
|
|
675
703
|
constructor(args, opts) {
|
|
@@ -692,6 +720,85 @@ var FlushDBCommand = class extends Command {
|
|
|
692
720
|
}
|
|
693
721
|
};
|
|
694
722
|
|
|
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
|
+
|
|
695
802
|
// pkg/commands/geo_add.ts
|
|
696
803
|
var GeoAddCommand = class extends Command {
|
|
697
804
|
constructor([key, arg1, ...arg2], opts) {
|
|
@@ -1038,7 +1145,7 @@ var HGetCommand = class extends Command {
|
|
|
1038
1145
|
};
|
|
1039
1146
|
|
|
1040
1147
|
// pkg/commands/hgetall.ts
|
|
1041
|
-
function
|
|
1148
|
+
function deserialize3(result) {
|
|
1042
1149
|
if (result.length === 0) {
|
|
1043
1150
|
return null;
|
|
1044
1151
|
}
|
|
@@ -1058,7 +1165,7 @@ function deserialize(result) {
|
|
|
1058
1165
|
var HGetAllCommand = class extends Command {
|
|
1059
1166
|
constructor(cmd, opts) {
|
|
1060
1167
|
super(["hgetall", ...cmd], {
|
|
1061
|
-
deserialize: (result) =>
|
|
1168
|
+
deserialize: (result) => deserialize3(result),
|
|
1062
1169
|
...opts
|
|
1063
1170
|
});
|
|
1064
1171
|
}
|
|
@@ -1093,7 +1200,7 @@ var HLenCommand = class extends Command {
|
|
|
1093
1200
|
};
|
|
1094
1201
|
|
|
1095
1202
|
// pkg/commands/hmget.ts
|
|
1096
|
-
function
|
|
1203
|
+
function deserialize4(fields, result) {
|
|
1097
1204
|
if (result.every((field) => field === null)) {
|
|
1098
1205
|
return null;
|
|
1099
1206
|
}
|
|
@@ -1110,7 +1217,7 @@ function deserialize2(fields, result) {
|
|
|
1110
1217
|
var HMGetCommand = class extends Command {
|
|
1111
1218
|
constructor([key, ...fields], opts) {
|
|
1112
1219
|
super(["hmget", key, ...fields], {
|
|
1113
|
-
deserialize: (result) =>
|
|
1220
|
+
deserialize: (result) => deserialize4(fields, result),
|
|
1114
1221
|
...opts
|
|
1115
1222
|
});
|
|
1116
1223
|
}
|
|
@@ -1124,7 +1231,7 @@ var HMSetCommand = class extends Command {
|
|
|
1124
1231
|
};
|
|
1125
1232
|
|
|
1126
1233
|
// pkg/commands/hrandfield.ts
|
|
1127
|
-
function
|
|
1234
|
+
function deserialize5(result) {
|
|
1128
1235
|
if (result.length === 0) {
|
|
1129
1236
|
return null;
|
|
1130
1237
|
}
|
|
@@ -1151,7 +1258,7 @@ var HRandFieldCommand = class extends Command {
|
|
|
1151
1258
|
}
|
|
1152
1259
|
super(command, {
|
|
1153
1260
|
// @ts-expect-error to silence compiler
|
|
1154
|
-
deserialize: cmd[2] ? (result) =>
|
|
1261
|
+
deserialize: cmd[2] ? (result) => deserialize5(result) : opts?.deserialize,
|
|
1155
1262
|
...opts
|
|
1156
1263
|
});
|
|
1157
1264
|
}
|
|
@@ -2121,7 +2228,7 @@ var XPendingCommand = class extends Command {
|
|
|
2121
2228
|
};
|
|
2122
2229
|
|
|
2123
2230
|
// pkg/commands/xrange.ts
|
|
2124
|
-
function
|
|
2231
|
+
function deserialize6(result) {
|
|
2125
2232
|
const obj = {};
|
|
2126
2233
|
for (const e of result) {
|
|
2127
2234
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2150,7 +2257,7 @@ var XRangeCommand = class extends Command {
|
|
|
2150
2257
|
command.push("COUNT", count);
|
|
2151
2258
|
}
|
|
2152
2259
|
super(command, {
|
|
2153
|
-
deserialize: (result) =>
|
|
2260
|
+
deserialize: (result) => deserialize6(result),
|
|
2154
2261
|
...opts
|
|
2155
2262
|
});
|
|
2156
2263
|
}
|
|
@@ -2213,12 +2320,12 @@ var XRevRangeCommand = class extends Command {
|
|
|
2213
2320
|
command.push("COUNT", count);
|
|
2214
2321
|
}
|
|
2215
2322
|
super(command, {
|
|
2216
|
-
deserialize: (result) =>
|
|
2323
|
+
deserialize: (result) => deserialize7(result),
|
|
2217
2324
|
...opts
|
|
2218
2325
|
});
|
|
2219
2326
|
}
|
|
2220
2327
|
};
|
|
2221
|
-
function
|
|
2328
|
+
function deserialize7(result) {
|
|
2222
2329
|
const obj = {};
|
|
2223
2330
|
for (const e of result) {
|
|
2224
2331
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2488,327 +2595,6 @@ var ZUnionStoreCommand = class extends Command {
|
|
|
2488
2595
|
}
|
|
2489
2596
|
};
|
|
2490
2597
|
|
|
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
|
-
});
|
|
2522
|
-
} else if (isNestedSchema(value)) {
|
|
2523
|
-
const nestedFields = flattenSchema(value, currentPath);
|
|
2524
|
-
fields.push(...nestedFields);
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
return fields;
|
|
2528
|
-
}
|
|
2529
|
-
function deserializeQueryResponse(rawResponse, options) {
|
|
2530
|
-
const hasEmptySelect = options?.select && Object.keys(options.select).length === 0;
|
|
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 (hasEmptySelect) {
|
|
2537
|
-
return { key, score };
|
|
2538
|
-
}
|
|
2539
|
-
if (!Array.isArray(rawFields) || rawFields.length === 0) {
|
|
2540
|
-
return { key, score, data: {} };
|
|
2541
|
-
}
|
|
2542
|
-
const mergedFields = {};
|
|
2543
|
-
for (const fieldRaw of rawFields) {
|
|
2544
|
-
const fieldObj = kvArrayToObject(fieldRaw);
|
|
2545
|
-
Object.assign(mergedFields, fieldObj);
|
|
2546
|
-
}
|
|
2547
|
-
if ("$" in mergedFields) {
|
|
2548
|
-
const data2 = mergedFields["$"];
|
|
2549
|
-
return { key, score, data: data2 };
|
|
2550
|
-
}
|
|
2551
|
-
const data = dotNotationToNested(mergedFields);
|
|
2552
|
-
return { key, score, data };
|
|
2553
|
-
});
|
|
2554
|
-
}
|
|
2555
|
-
function parseFieldInfo(fieldRaw) {
|
|
2556
|
-
const fieldType = fieldRaw[1];
|
|
2557
|
-
const options = fieldRaw.slice(2);
|
|
2558
|
-
const fieldInfo = { type: fieldType };
|
|
2559
|
-
for (const option of options) {
|
|
2560
|
-
switch (option.toUpperCase()) {
|
|
2561
|
-
case "NOTOKENIZE":
|
|
2562
|
-
fieldInfo.noTokenize = true;
|
|
2563
|
-
break;
|
|
2564
|
-
case "NOSTEM":
|
|
2565
|
-
fieldInfo.noStem = true;
|
|
2566
|
-
break;
|
|
2567
|
-
case "FAST":
|
|
2568
|
-
fieldInfo.fast = true;
|
|
2569
|
-
break;
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
return fieldInfo;
|
|
2573
|
-
}
|
|
2574
|
-
function deserializeDescribeResponse(rawResponse) {
|
|
2575
|
-
const raw = kvArrayToObject(rawResponse);
|
|
2576
|
-
const schema = {};
|
|
2577
|
-
if (Array.isArray(raw.schema)) {
|
|
2578
|
-
for (const fieldRaw of raw.schema) {
|
|
2579
|
-
if (Array.isArray(fieldRaw) && fieldRaw.length >= 2) {
|
|
2580
|
-
const fieldName = fieldRaw[0];
|
|
2581
|
-
schema[fieldName] = parseFieldInfo(fieldRaw);
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
return {
|
|
2586
|
-
name: raw.name,
|
|
2587
|
-
dataType: raw.type.toLowerCase(),
|
|
2588
|
-
prefixes: raw.prefixes,
|
|
2589
|
-
...raw.language && { language: raw.language },
|
|
2590
|
-
schema
|
|
2591
|
-
};
|
|
2592
|
-
}
|
|
2593
|
-
function parseCountResponse(rawResponse) {
|
|
2594
|
-
return typeof rawResponse === "number" ? rawResponse : parseInt(rawResponse, 10);
|
|
2595
|
-
}
|
|
2596
|
-
function kvArrayToObject(v) {
|
|
2597
|
-
if (typeof v === "object" && v !== null && !Array.isArray(v)) return v;
|
|
2598
|
-
if (!Array.isArray(v)) return {};
|
|
2599
|
-
const obj = {};
|
|
2600
|
-
for (let i = 0; i < v.length; i += 2) {
|
|
2601
|
-
if (typeof v[i] === "string") obj[v[i]] = v[i + 1];
|
|
2602
|
-
}
|
|
2603
|
-
return obj;
|
|
2604
|
-
}
|
|
2605
|
-
function dotNotationToNested(obj) {
|
|
2606
|
-
const result = {};
|
|
2607
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
2608
|
-
const parts = key.split(".");
|
|
2609
|
-
let current = result;
|
|
2610
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
2611
|
-
const part = parts[i];
|
|
2612
|
-
if (!(part in current)) {
|
|
2613
|
-
current[part] = {};
|
|
2614
|
-
}
|
|
2615
|
-
current = current[part];
|
|
2616
|
-
}
|
|
2617
|
-
current[parts[parts.length - 1]] = value;
|
|
2618
|
-
}
|
|
2619
|
-
return result;
|
|
2620
|
-
}
|
|
2621
|
-
|
|
2622
|
-
// pkg/commands/search/command-builder.ts
|
|
2623
|
-
function buildQueryCommand(redisCommand, name, options) {
|
|
2624
|
-
const query = JSON.stringify(options?.filter);
|
|
2625
|
-
const command = [redisCommand, name, query];
|
|
2626
|
-
if (options?.limit !== void 0) {
|
|
2627
|
-
command.push("LIMIT", options.limit.toString());
|
|
2628
|
-
}
|
|
2629
|
-
if (options?.offset !== void 0) {
|
|
2630
|
-
command.push("OFFSET", options.offset.toString());
|
|
2631
|
-
}
|
|
2632
|
-
if (options?.select && Object.keys(options.select).length === 0) {
|
|
2633
|
-
command.push("NOCONTENT");
|
|
2634
|
-
}
|
|
2635
|
-
if (options?.orderBy) {
|
|
2636
|
-
command.push("SORTBY");
|
|
2637
|
-
Object.entries(options.orderBy).forEach(([field, direction]) => {
|
|
2638
|
-
command.push(field, direction);
|
|
2639
|
-
});
|
|
2640
|
-
}
|
|
2641
|
-
if (options?.highlight) {
|
|
2642
|
-
command.push(
|
|
2643
|
-
"HIGHLIGHT",
|
|
2644
|
-
"FIELDS",
|
|
2645
|
-
options.highlight.fields.length.toString(),
|
|
2646
|
-
...options.highlight.fields
|
|
2647
|
-
);
|
|
2648
|
-
if (options.highlight.preTag && options.highlight.postTag) {
|
|
2649
|
-
command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
if (options?.select && Object.keys(options.select).length > 0) {
|
|
2653
|
-
command.push(
|
|
2654
|
-
"RETURN",
|
|
2655
|
-
Object.keys(options.select).length.toString(),
|
|
2656
|
-
...Object.keys(options.select)
|
|
2657
|
-
);
|
|
2658
|
-
}
|
|
2659
|
-
return command;
|
|
2660
|
-
}
|
|
2661
|
-
function buildCreateIndexCommand(props) {
|
|
2662
|
-
const { name, schema, dataType, prefix, language } = props;
|
|
2663
|
-
const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
|
|
2664
|
-
const payload = [
|
|
2665
|
-
name,
|
|
2666
|
-
"ON",
|
|
2667
|
-
dataType.toUpperCase(),
|
|
2668
|
-
"PREFIX",
|
|
2669
|
-
prefixArray.length.toString(),
|
|
2670
|
-
...prefixArray,
|
|
2671
|
-
...language ? ["LANGUAGE", language] : [],
|
|
2672
|
-
"SCHEMA"
|
|
2673
|
-
];
|
|
2674
|
-
const fields = flattenSchema(schema);
|
|
2675
|
-
for (const field of fields) {
|
|
2676
|
-
payload.push(field.path, field.type);
|
|
2677
|
-
if (field.fast) {
|
|
2678
|
-
payload.push("FAST");
|
|
2679
|
-
}
|
|
2680
|
-
if (field.noTokenize) {
|
|
2681
|
-
payload.push("NOTOKENIZE");
|
|
2682
|
-
}
|
|
2683
|
-
if (field.noStem) {
|
|
2684
|
-
payload.push("NOSTEM");
|
|
2685
|
-
}
|
|
2686
|
-
}
|
|
2687
|
-
return ["SEARCH.CREATE", ...payload];
|
|
2688
|
-
}
|
|
2689
|
-
|
|
2690
|
-
// pkg/commands/search/search.ts
|
|
2691
|
-
var SearchIndex = class {
|
|
2692
|
-
name;
|
|
2693
|
-
schema;
|
|
2694
|
-
client;
|
|
2695
|
-
constructor({ name, schema, client }) {
|
|
2696
|
-
this.name = name;
|
|
2697
|
-
this.schema = schema;
|
|
2698
|
-
this.client = client;
|
|
2699
|
-
}
|
|
2700
|
-
async waitIndexing() {
|
|
2701
|
-
const command = ["SEARCH.COMMIT", this.name];
|
|
2702
|
-
const result = await new ExecCommand(command).exec(
|
|
2703
|
-
this.client
|
|
2704
|
-
);
|
|
2705
|
-
return result;
|
|
2706
|
-
}
|
|
2707
|
-
async describe() {
|
|
2708
|
-
const command = ["SEARCH.DESCRIBE", this.name];
|
|
2709
|
-
const rawResult = await new ExecCommand(command).exec(
|
|
2710
|
-
this.client
|
|
2711
|
-
);
|
|
2712
|
-
return deserializeDescribeResponse(rawResult);
|
|
2713
|
-
}
|
|
2714
|
-
async query(options) {
|
|
2715
|
-
const command = buildQueryCommand("SEARCH.QUERY", this.name, options);
|
|
2716
|
-
const rawResult = await new ExecCommand(command).exec(
|
|
2717
|
-
this.client
|
|
2718
|
-
);
|
|
2719
|
-
return deserializeQueryResponse(rawResult, options);
|
|
2720
|
-
}
|
|
2721
|
-
async count({ filter }) {
|
|
2722
|
-
const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
|
|
2723
|
-
const rawResult = await new ExecCommand(command).exec(
|
|
2724
|
-
this.client
|
|
2725
|
-
);
|
|
2726
|
-
return { count: parseCountResponse(rawResult) };
|
|
2727
|
-
}
|
|
2728
|
-
async drop() {
|
|
2729
|
-
const command = ["SEARCH.DROP", this.name];
|
|
2730
|
-
const result = await new ExecCommand(command).exec(
|
|
2731
|
-
this.client
|
|
2732
|
-
);
|
|
2733
|
-
return result;
|
|
2734
|
-
}
|
|
2735
|
-
};
|
|
2736
|
-
async function createIndex(props) {
|
|
2737
|
-
const { name, schema, client } = props;
|
|
2738
|
-
const createIndexCommand = buildCreateIndexCommand(props);
|
|
2739
|
-
await new ExecCommand(createIndexCommand).exec(client);
|
|
2740
|
-
return index(client, name, schema);
|
|
2741
|
-
}
|
|
2742
|
-
function index(client, name, schema) {
|
|
2743
|
-
return new SearchIndex({ name, schema, client });
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
|
-
// pkg/commands/search/schema-builder.ts
|
|
2747
|
-
var BUILD = Symbol("build");
|
|
2748
|
-
var TextFieldBuilder = class _TextFieldBuilder {
|
|
2749
|
-
_noTokenize;
|
|
2750
|
-
_noStem;
|
|
2751
|
-
constructor(noTokenize = { noTokenize: false }, noStem = { noStem: false }) {
|
|
2752
|
-
this._noTokenize = noTokenize;
|
|
2753
|
-
this._noStem = noStem;
|
|
2754
|
-
}
|
|
2755
|
-
noTokenize() {
|
|
2756
|
-
return new _TextFieldBuilder({ noTokenize: true }, this._noStem);
|
|
2757
|
-
}
|
|
2758
|
-
noStem() {
|
|
2759
|
-
return new _TextFieldBuilder(this._noTokenize, { noStem: true });
|
|
2760
|
-
}
|
|
2761
|
-
[BUILD]() {
|
|
2762
|
-
return this._noTokenize.noTokenize || this._noStem.noStem ? {
|
|
2763
|
-
type: "TEXT",
|
|
2764
|
-
...this._noTokenize.noTokenize ? { noTokenize: true } : {},
|
|
2765
|
-
...this._noStem.noStem ? { noStem: true } : {}
|
|
2766
|
-
} : "TEXT";
|
|
2767
|
-
}
|
|
2768
|
-
};
|
|
2769
|
-
var NumericFieldBuilder = class {
|
|
2770
|
-
type;
|
|
2771
|
-
constructor(type) {
|
|
2772
|
-
this.type = type;
|
|
2773
|
-
}
|
|
2774
|
-
[BUILD]() {
|
|
2775
|
-
return {
|
|
2776
|
-
type: this.type,
|
|
2777
|
-
fast: true
|
|
2778
|
-
};
|
|
2779
|
-
}
|
|
2780
|
-
};
|
|
2781
|
-
var BoolFieldBuilder = class _BoolFieldBuilder {
|
|
2782
|
-
_fast;
|
|
2783
|
-
constructor(fast = { fast: false }) {
|
|
2784
|
-
this._fast = fast;
|
|
2785
|
-
}
|
|
2786
|
-
fast() {
|
|
2787
|
-
return new _BoolFieldBuilder({ fast: true });
|
|
2788
|
-
}
|
|
2789
|
-
[BUILD]() {
|
|
2790
|
-
return this._fast.fast ? {
|
|
2791
|
-
type: "BOOL",
|
|
2792
|
-
fast: true
|
|
2793
|
-
} : "BOOL";
|
|
2794
|
-
}
|
|
2795
|
-
};
|
|
2796
|
-
var DateFieldBuilder = class _DateFieldBuilder {
|
|
2797
|
-
_fast;
|
|
2798
|
-
constructor(fast = { fast: false }) {
|
|
2799
|
-
this._fast = fast;
|
|
2800
|
-
}
|
|
2801
|
-
fast() {
|
|
2802
|
-
return new _DateFieldBuilder({ fast: true });
|
|
2803
|
-
}
|
|
2804
|
-
[BUILD]() {
|
|
2805
|
-
return this._fast.fast ? {
|
|
2806
|
-
type: "DATE",
|
|
2807
|
-
fast: true
|
|
2808
|
-
} : "DATE";
|
|
2809
|
-
}
|
|
2810
|
-
};
|
|
2811
|
-
|
|
2812
2598
|
// pkg/commands/psubscribe.ts
|
|
2813
2599
|
var PSubscribeCommand = class extends Command {
|
|
2814
2600
|
constructor(cmd, opts) {
|
|
@@ -3382,7 +3168,7 @@ var Pipeline = class {
|
|
|
3382
3168
|
/**
|
|
3383
3169
|
* @see https://redis.io/commands/lset
|
|
3384
3170
|
*/
|
|
3385
|
-
lset = (key,
|
|
3171
|
+
lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
|
|
3386
3172
|
/**
|
|
3387
3173
|
* @see https://redis.io/commands/ltrim
|
|
3388
3174
|
*/
|
|
@@ -3834,6 +3620,38 @@ var Pipeline = class {
|
|
|
3834
3620
|
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
3835
3621
|
};
|
|
3836
3622
|
}
|
|
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
|
+
}
|
|
3837
3655
|
};
|
|
3838
3656
|
|
|
3839
3657
|
// pkg/script.ts
|
|
@@ -3895,8 +3713,8 @@ var Script = class {
|
|
|
3895
3713
|
/**
|
|
3896
3714
|
* Compute the sha1 hash of the script and return its hex representation.
|
|
3897
3715
|
*/
|
|
3898
|
-
async digest(
|
|
3899
|
-
const data = new TextEncoder().encode(
|
|
3716
|
+
async digest(s) {
|
|
3717
|
+
const data = new TextEncoder().encode(s);
|
|
3900
3718
|
const hashBuffer = await import_uncrypto.subtle.digest("SHA-1", data);
|
|
3901
3719
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
3902
3720
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -3959,8 +3777,8 @@ var ScriptRO = class {
|
|
|
3959
3777
|
/**
|
|
3960
3778
|
* Compute the sha1 hash of the script and return its hex representation.
|
|
3961
3779
|
*/
|
|
3962
|
-
async digest(
|
|
3963
|
-
const data = new TextEncoder().encode(
|
|
3780
|
+
async digest(s) {
|
|
3781
|
+
const data = new TextEncoder().encode(s);
|
|
3964
3782
|
const hashBuffer = await import_uncrypto2.subtle.digest("SHA-1", data);
|
|
3965
3783
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
3966
3784
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -4095,6 +3913,40 @@ var Redis = class {
|
|
|
4095
3913
|
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
4096
3914
|
};
|
|
4097
3915
|
}
|
|
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
|
+
}
|
|
4098
3950
|
/**
|
|
4099
3951
|
* Wrap a new middleware around the HTTP client.
|
|
4100
3952
|
*/
|
|
@@ -4145,19 +3997,6 @@ var Redis = class {
|
|
|
4145
3997
|
createScript(script, opts) {
|
|
4146
3998
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
4147
3999
|
}
|
|
4148
|
-
get search() {
|
|
4149
|
-
return {
|
|
4150
|
-
createIndex: (props) => {
|
|
4151
|
-
return createIndex({
|
|
4152
|
-
...props,
|
|
4153
|
-
client: this.client
|
|
4154
|
-
});
|
|
4155
|
-
},
|
|
4156
|
-
index: (name, schema) => {
|
|
4157
|
-
return index(this.client, name, schema);
|
|
4158
|
-
}
|
|
4159
|
-
};
|
|
4160
|
-
}
|
|
4161
4000
|
/**
|
|
4162
4001
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
4163
4002
|
*
|
|
@@ -4494,7 +4333,7 @@ var Redis = class {
|
|
|
4494
4333
|
/**
|
|
4495
4334
|
* @see https://redis.io/commands/lset
|
|
4496
4335
|
*/
|
|
4497
|
-
lset = (key,
|
|
4336
|
+
lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
|
|
4498
4337
|
/**
|
|
4499
4338
|
* @see https://redis.io/commands/ltrim
|
|
4500
4339
|
*/
|
|
@@ -4865,7 +4704,7 @@ var Redis = class {
|
|
|
4865
4704
|
};
|
|
4866
4705
|
|
|
4867
4706
|
// version.ts
|
|
4868
|
-
var VERSION = "v1.36.0
|
|
4707
|
+
var VERSION = "v1.36.0";
|
|
4869
4708
|
|
|
4870
4709
|
// platforms/fastly.ts
|
|
4871
4710
|
var Redis2 = class extends Redis {
|