@upstash/redis 1.38.4 → 1.39.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-2JFYL2VL.mjs → chunk-4WQYU7T6.mjs} +614 -8
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +613 -8
- package/cloudflare.mjs +1 -1
- package/{error-8y4qG0W2.d.mts → error-DOszGRxg.d.mts} +703 -3
- package/{error-8y4qG0W2.d.ts → error-DOszGRxg.d.ts} +703 -3
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +613 -8
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +2 -2
- package/nodejs.d.ts +2 -2
- package/nodejs.js +615 -8
- package/nodejs.mjs +3 -1
- package/package.json +1 -1
package/cloudflare.js
CHANGED
|
@@ -352,6 +352,18 @@ function merge(obj, key, value) {
|
|
|
352
352
|
// pkg/auto-pipeline.ts
|
|
353
353
|
var MAX_PIPELINE_SIZE = 1e3;
|
|
354
354
|
var READ_COMMANDS = /* @__PURE__ */ new Set([
|
|
355
|
+
// Array
|
|
356
|
+
"arcount",
|
|
357
|
+
"arget",
|
|
358
|
+
"argetrange",
|
|
359
|
+
"argrep",
|
|
360
|
+
"arinfo",
|
|
361
|
+
"arlastitems",
|
|
362
|
+
"arlen",
|
|
363
|
+
"armget",
|
|
364
|
+
"arnext",
|
|
365
|
+
"arop",
|
|
366
|
+
"arscan",
|
|
355
367
|
// String
|
|
356
368
|
"get",
|
|
357
369
|
"getrange",
|
|
@@ -645,6 +657,225 @@ var AppendCommand = class extends Command {
|
|
|
645
657
|
}
|
|
646
658
|
};
|
|
647
659
|
|
|
660
|
+
// pkg/commands/arcount.ts
|
|
661
|
+
var ArCountCommand = class extends Command {
|
|
662
|
+
constructor(cmd, opts) {
|
|
663
|
+
super(["ARCOUNT", ...cmd], opts);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
// pkg/commands/ardel.ts
|
|
668
|
+
var ArDelCommand = class extends Command {
|
|
669
|
+
constructor(cmd, opts) {
|
|
670
|
+
super(["ARDEL", ...cmd], opts);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
// pkg/commands/ardelrange.ts
|
|
675
|
+
var ArDelRangeCommand = class extends Command {
|
|
676
|
+
constructor([key, ...ranges], opts) {
|
|
677
|
+
super(["ARDELRANGE", key, ...ranges.flat()], opts);
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
// pkg/commands/arget.ts
|
|
682
|
+
var ArGetCommand = class extends Command {
|
|
683
|
+
constructor(cmd, opts) {
|
|
684
|
+
super(["ARGET", ...cmd], opts);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
// pkg/commands/argetrange.ts
|
|
689
|
+
var ArGetRangeCommand = class extends Command {
|
|
690
|
+
constructor(cmd, opts) {
|
|
691
|
+
super(["ARGETRANGE", ...cmd], opts);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
// pkg/commands/argrep.ts
|
|
696
|
+
var ArGrepCommand = class extends Command {
|
|
697
|
+
constructor([key, start, end, opts], cmdOpts) {
|
|
698
|
+
const command = ["ARGREP", key, start, end];
|
|
699
|
+
for (const predicate of opts.predicates) {
|
|
700
|
+
if ("exact" in predicate) {
|
|
701
|
+
command.push("EXACT", predicate.exact);
|
|
702
|
+
} else if ("match" in predicate) {
|
|
703
|
+
command.push("MATCH", predicate.match);
|
|
704
|
+
} else if ("glob" in predicate) {
|
|
705
|
+
command.push("GLOB", predicate.glob);
|
|
706
|
+
} else {
|
|
707
|
+
command.push("RE", predicate.re);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
if (opts.combine) {
|
|
711
|
+
command.push(opts.combine.toUpperCase());
|
|
712
|
+
}
|
|
713
|
+
if (opts.noCase) {
|
|
714
|
+
command.push("NOCASE");
|
|
715
|
+
}
|
|
716
|
+
if (opts.withValues) {
|
|
717
|
+
command.push("WITHVALUES");
|
|
718
|
+
}
|
|
719
|
+
if (opts.limit !== void 0) {
|
|
720
|
+
command.push("LIMIT", opts.limit);
|
|
721
|
+
}
|
|
722
|
+
super(command, {
|
|
723
|
+
deserialize: (result) => parseResponse(result).map(
|
|
724
|
+
(item) => Array.isArray(item) ? [String(item[0]), item[1]] : String(item)
|
|
725
|
+
),
|
|
726
|
+
...cmdOpts
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// pkg/commands/arinfo.ts
|
|
732
|
+
function toCamelCase(field) {
|
|
733
|
+
return field.replaceAll(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
734
|
+
}
|
|
735
|
+
function deserializeArInfoResponse(result) {
|
|
736
|
+
const entries = Array.isArray(result) ? Array.from({ length: Math.floor(result.length / 2) }, (_, i) => [
|
|
737
|
+
result[i * 2],
|
|
738
|
+
result[i * 2 + 1]
|
|
739
|
+
]) : Object.entries(result);
|
|
740
|
+
const indexFields = /* @__PURE__ */ new Set(["len", "nextInsertIndex"]);
|
|
741
|
+
const info = {};
|
|
742
|
+
for (const [field, value] of entries) {
|
|
743
|
+
const name = toCamelCase(String(field));
|
|
744
|
+
if (indexFields.has(name)) {
|
|
745
|
+
info[name] = String(value);
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
749
|
+
info[name] = Number.isNaN(numeric) ? value : numeric;
|
|
750
|
+
}
|
|
751
|
+
return info;
|
|
752
|
+
}
|
|
753
|
+
var ArInfoCommand = class extends Command {
|
|
754
|
+
constructor([key, opts], cmdOpts) {
|
|
755
|
+
const command = ["ARINFO", key];
|
|
756
|
+
if (opts?.full) {
|
|
757
|
+
command.push("FULL");
|
|
758
|
+
}
|
|
759
|
+
super(command, {
|
|
760
|
+
deserialize: deserializeArInfoResponse,
|
|
761
|
+
...cmdOpts
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// pkg/commands/arinsert.ts
|
|
767
|
+
var ArInsertCommand = class extends Command {
|
|
768
|
+
constructor(cmd, opts) {
|
|
769
|
+
super(["ARINSERT", ...cmd], {
|
|
770
|
+
deserialize: String,
|
|
771
|
+
...opts
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
// pkg/commands/arlastitems.ts
|
|
777
|
+
var ArLastItemsCommand = class extends Command {
|
|
778
|
+
constructor([key, count, opts], cmdOpts) {
|
|
779
|
+
const command = ["ARLASTITEMS", key, count];
|
|
780
|
+
if (opts?.rev) {
|
|
781
|
+
command.push("REV");
|
|
782
|
+
}
|
|
783
|
+
super(command, cmdOpts);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
// pkg/commands/arlen.ts
|
|
788
|
+
var ArLenCommand = class extends Command {
|
|
789
|
+
constructor(cmd, opts) {
|
|
790
|
+
super(["ARLEN", ...cmd], {
|
|
791
|
+
deserialize: String,
|
|
792
|
+
...opts
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// pkg/commands/armget.ts
|
|
798
|
+
var ArMGetCommand = class extends Command {
|
|
799
|
+
constructor(cmd, opts) {
|
|
800
|
+
super(["ARMGET", ...cmd], opts);
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
// pkg/commands/armset.ts
|
|
805
|
+
var ArMSetCommand = class extends Command {
|
|
806
|
+
constructor([key, values], opts) {
|
|
807
|
+
const pairs = Array.isArray(values) ? values : Object.entries(values);
|
|
808
|
+
super(["ARMSET", key, ...pairs.flatMap(([index, value]) => [index, value])], opts);
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
// pkg/commands/arnext.ts
|
|
813
|
+
var ArNextCommand = class extends Command {
|
|
814
|
+
constructor(cmd, opts) {
|
|
815
|
+
super(["ARNEXT", ...cmd], {
|
|
816
|
+
deserialize: (result) => result === null ? null : String(result),
|
|
817
|
+
...opts
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
// pkg/commands/arop.ts
|
|
823
|
+
var ArOpCommand = class extends Command {
|
|
824
|
+
constructor([key, start, end, operation], opts) {
|
|
825
|
+
const command = ["AROP", key, start, end];
|
|
826
|
+
if (typeof operation === "string") {
|
|
827
|
+
command.push(operation.toUpperCase());
|
|
828
|
+
} else {
|
|
829
|
+
command.push("MATCH", operation.match);
|
|
830
|
+
}
|
|
831
|
+
super(command, {
|
|
832
|
+
deserialize: (result) => result === null ? null : Number(result),
|
|
833
|
+
...opts
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// pkg/commands/arring.ts
|
|
839
|
+
var ArRingCommand = class extends Command {
|
|
840
|
+
constructor(cmd, opts) {
|
|
841
|
+
super(["ARRING", ...cmd], {
|
|
842
|
+
deserialize: String,
|
|
843
|
+
...opts
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
// pkg/commands/arscan.ts
|
|
849
|
+
var ArScanCommand = class extends Command {
|
|
850
|
+
constructor([key, start, end, opts], cmdOpts) {
|
|
851
|
+
const command = ["ARSCAN", key, start, end];
|
|
852
|
+
if (opts?.limit !== void 0) {
|
|
853
|
+
command.push("LIMIT", opts.limit);
|
|
854
|
+
}
|
|
855
|
+
super(command, {
|
|
856
|
+
deserialize: (result) => parseResponse(result).map(([index, value]) => [
|
|
857
|
+
String(index),
|
|
858
|
+
value
|
|
859
|
+
]),
|
|
860
|
+
...cmdOpts
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
// pkg/commands/arseek.ts
|
|
866
|
+
var ArSeekCommand = class extends Command {
|
|
867
|
+
constructor(cmd, opts) {
|
|
868
|
+
super(["ARSEEK", ...cmd], opts);
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
// pkg/commands/arset.ts
|
|
873
|
+
var ArSetCommand = class extends Command {
|
|
874
|
+
constructor(cmd, opts) {
|
|
875
|
+
super(["ARSET", ...cmd], opts);
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
|
|
648
879
|
// pkg/commands/bitcount.ts
|
|
649
880
|
var BitCountCommand = class extends Command {
|
|
650
881
|
constructor([key, start, end], opts) {
|
|
@@ -2274,6 +2505,135 @@ var UnlinkCommand = class extends Command {
|
|
|
2274
2505
|
}
|
|
2275
2506
|
};
|
|
2276
2507
|
|
|
2508
|
+
// pkg/commands/vector/utils.ts
|
|
2509
|
+
function float32ToBase64(vector) {
|
|
2510
|
+
const bytes = new Uint8Array(vector.length * 4);
|
|
2511
|
+
const view = new DataView(bytes.buffer);
|
|
2512
|
+
for (const [i, value] of vector.entries()) {
|
|
2513
|
+
view.setFloat32(i * 4, value, true);
|
|
2514
|
+
}
|
|
2515
|
+
let binary = "";
|
|
2516
|
+
const chunkSize = 32768;
|
|
2517
|
+
for (let i = 0; i < bytes.length; i += chunkSize) {
|
|
2518
|
+
binary += String.fromCodePoint(...bytes.subarray(i, i + chunkSize));
|
|
2519
|
+
}
|
|
2520
|
+
return btoa(binary);
|
|
2521
|
+
}
|
|
2522
|
+
function serializeVector(vector) {
|
|
2523
|
+
if (Array.isArray(vector)) {
|
|
2524
|
+
return ["VALUES", vector.length, ...vector];
|
|
2525
|
+
}
|
|
2526
|
+
if (vector instanceof Float32Array) {
|
|
2527
|
+
return ["BASE64-FP32", float32ToBase64(vector)];
|
|
2528
|
+
}
|
|
2529
|
+
return ["BASE64-FP32", vector.base64];
|
|
2530
|
+
}
|
|
2531
|
+
function deserializeVectorValues(result) {
|
|
2532
|
+
if (result === null) {
|
|
2533
|
+
return null;
|
|
2534
|
+
}
|
|
2535
|
+
return result.map(Number);
|
|
2536
|
+
}
|
|
2537
|
+
function deserializeVectorQueryResponse(result) {
|
|
2538
|
+
return result.map(([id, score]) => ({ id: String(id), score: Number(score) }));
|
|
2539
|
+
}
|
|
2540
|
+
function deserializeVectorInfoResponse(result) {
|
|
2541
|
+
if (result === null) {
|
|
2542
|
+
return null;
|
|
2543
|
+
}
|
|
2544
|
+
const fields = Array.isArray(result) ? Object.fromEntries(
|
|
2545
|
+
Array.from({ length: Math.floor(result.length / 2) }, (_, i) => [
|
|
2546
|
+
String(result[i * 2]),
|
|
2547
|
+
result[i * 2 + 1]
|
|
2548
|
+
])
|
|
2549
|
+
) : result;
|
|
2550
|
+
return {
|
|
2551
|
+
dimension: Number(fields.dimension),
|
|
2552
|
+
metric: String(fields.metric).toUpperCase()
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
// pkg/commands/vector_add.ts
|
|
2557
|
+
var VectorAddCommand = class extends Command {
|
|
2558
|
+
constructor([index, id, vector], cmdOpts) {
|
|
2559
|
+
super(["VECTOR.ADD", index, id, ...serializeVector(vector)], cmdOpts);
|
|
2560
|
+
}
|
|
2561
|
+
};
|
|
2562
|
+
|
|
2563
|
+
// pkg/commands/vector_count.ts
|
|
2564
|
+
var VectorCountCommand = class extends Command {
|
|
2565
|
+
constructor([index], cmdOpts) {
|
|
2566
|
+
super(["VECTOR.COUNT", index], cmdOpts);
|
|
2567
|
+
}
|
|
2568
|
+
};
|
|
2569
|
+
|
|
2570
|
+
// pkg/commands/vector_create.ts
|
|
2571
|
+
var VectorCreateCommand = class extends Command {
|
|
2572
|
+
constructor([index, opts], cmdOpts) {
|
|
2573
|
+
const command = [
|
|
2574
|
+
"VECTOR.CREATE",
|
|
2575
|
+
index,
|
|
2576
|
+
"DIM",
|
|
2577
|
+
opts.dimension,
|
|
2578
|
+
"METRIC",
|
|
2579
|
+
opts.metric
|
|
2580
|
+
];
|
|
2581
|
+
if (opts.existsOk) {
|
|
2582
|
+
command.push("EXISTSOK");
|
|
2583
|
+
}
|
|
2584
|
+
super(command, cmdOpts);
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
// pkg/commands/vector_del.ts
|
|
2589
|
+
var VectorDelCommand = class extends Command {
|
|
2590
|
+
constructor([index, id], cmdOpts) {
|
|
2591
|
+
super(["VECTOR.DEL", index, id], cmdOpts);
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
|
|
2595
|
+
// pkg/commands/vector_drop.ts
|
|
2596
|
+
var VectorDropCommand = class extends Command {
|
|
2597
|
+
constructor([index], cmdOpts) {
|
|
2598
|
+
super(["VECTOR.DROP", index], cmdOpts);
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
|
|
2602
|
+
// pkg/commands/vector_get.ts
|
|
2603
|
+
var VectorGetCommand = class extends Command {
|
|
2604
|
+
constructor([index, id], cmdOpts) {
|
|
2605
|
+
super(["VECTOR.GET", index, id], {
|
|
2606
|
+
deserialize: deserializeVectorValues,
|
|
2607
|
+
...cmdOpts
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
|
|
2612
|
+
// pkg/commands/vector_info.ts
|
|
2613
|
+
var VectorInfoCommand = class extends Command {
|
|
2614
|
+
constructor([index], cmdOpts) {
|
|
2615
|
+
super(["VECTOR.INFO", index], {
|
|
2616
|
+
deserialize: deserializeVectorInfoResponse,
|
|
2617
|
+
...cmdOpts
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2621
|
+
|
|
2622
|
+
// pkg/commands/vector_query.ts
|
|
2623
|
+
var VectorQueryCommand = class extends Command {
|
|
2624
|
+
constructor([index, opts], cmdOpts) {
|
|
2625
|
+
const command = ["VECTOR.QUERY", index, "TOPK", opts.topK];
|
|
2626
|
+
if (opts.profile) {
|
|
2627
|
+
command.push("PROFILE", opts.profile);
|
|
2628
|
+
}
|
|
2629
|
+
command.push(...serializeVector(opts.vector));
|
|
2630
|
+
super(command, {
|
|
2631
|
+
deserialize: deserializeVectorQueryResponse,
|
|
2632
|
+
...cmdOpts
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
};
|
|
2636
|
+
|
|
2277
2637
|
// pkg/commands/xack.ts
|
|
2278
2638
|
var XAckCommand = class extends Command {
|
|
2279
2639
|
constructor([key, group, id], opts) {
|
|
@@ -3123,17 +3483,25 @@ function buildScoreFuncField(field) {
|
|
|
3123
3483
|
return result;
|
|
3124
3484
|
}
|
|
3125
3485
|
function buildCreateIndexCommand(params) {
|
|
3126
|
-
const { name, schema, dataType,
|
|
3127
|
-
|
|
3486
|
+
const { name, schema, dataType, language, skipInitialScan, existsOk } = params;
|
|
3487
|
+
let source;
|
|
3488
|
+
if (params.dataType === "stream") {
|
|
3489
|
+
source = ["ON", "STREAM", params.stream];
|
|
3490
|
+
} else {
|
|
3491
|
+
const prefixArray = Array.isArray(params.prefix) ? params.prefix : [params.prefix];
|
|
3492
|
+
source = [
|
|
3493
|
+
"ON",
|
|
3494
|
+
dataType.toUpperCase(),
|
|
3495
|
+
"PREFIX",
|
|
3496
|
+
prefixArray.length.toString(),
|
|
3497
|
+
...prefixArray
|
|
3498
|
+
];
|
|
3499
|
+
}
|
|
3128
3500
|
const payload = [
|
|
3129
3501
|
name,
|
|
3130
3502
|
...skipInitialScan ? ["SKIPINITIALSCAN"] : [],
|
|
3131
3503
|
...existsOk ? ["EXISTSOK"] : [],
|
|
3132
|
-
|
|
3133
|
-
dataType.toUpperCase(),
|
|
3134
|
-
"PREFIX",
|
|
3135
|
-
prefixArray.length.toString(),
|
|
3136
|
-
...prefixArray,
|
|
3504
|
+
...source,
|
|
3137
3505
|
...language ? ["LANGUAGE", language] : [],
|
|
3138
3506
|
"SCHEMA"
|
|
3139
3507
|
];
|
|
@@ -3255,6 +3623,73 @@ async function delAlias(client, { alias }) {
|
|
|
3255
3623
|
return result;
|
|
3256
3624
|
}
|
|
3257
3625
|
|
|
3626
|
+
// pkg/commands/vector/vector.ts
|
|
3627
|
+
var VectorIndex = class {
|
|
3628
|
+
name;
|
|
3629
|
+
client;
|
|
3630
|
+
commandOptions;
|
|
3631
|
+
constructor({ name, client, commandOptions }) {
|
|
3632
|
+
this.name = name;
|
|
3633
|
+
this.client = client;
|
|
3634
|
+
this.commandOptions = commandOptions;
|
|
3635
|
+
}
|
|
3636
|
+
/**
|
|
3637
|
+
* Adds a vector to the index, or overwrites the vector stored under `id`.
|
|
3638
|
+
*
|
|
3639
|
+
* @returns `1` if a new vector was inserted, `0` if an existing one was overwritten.
|
|
3640
|
+
*/
|
|
3641
|
+
add(id, vector) {
|
|
3642
|
+
return new VectorAddCommand([this.name, id, vector], this.commandOptions).exec(this.client);
|
|
3643
|
+
}
|
|
3644
|
+
/**
|
|
3645
|
+
* Returns the vector stored under `id`, or `null` if it does not exist.
|
|
3646
|
+
*/
|
|
3647
|
+
get(id) {
|
|
3648
|
+
return new VectorGetCommand([this.name, id], this.commandOptions).exec(this.client);
|
|
3649
|
+
}
|
|
3650
|
+
/**
|
|
3651
|
+
* Returns the `topK` nearest neighbours of the query vector.
|
|
3652
|
+
*/
|
|
3653
|
+
query(options) {
|
|
3654
|
+
return new VectorQueryCommand([this.name, options], this.commandOptions).exec(this.client);
|
|
3655
|
+
}
|
|
3656
|
+
/**
|
|
3657
|
+
* Deletes the vector stored under `id`.
|
|
3658
|
+
*
|
|
3659
|
+
* @returns `1` if the vector existed and was removed, `0` otherwise.
|
|
3660
|
+
*/
|
|
3661
|
+
delete(id) {
|
|
3662
|
+
return new VectorDelCommand([this.name, id], this.commandOptions).exec(this.client);
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Returns the number of vectors in the index.
|
|
3666
|
+
*/
|
|
3667
|
+
count() {
|
|
3668
|
+
return new VectorCountCommand([this.name], this.commandOptions).exec(this.client);
|
|
3669
|
+
}
|
|
3670
|
+
/**
|
|
3671
|
+
* Returns the dimension and metric of the index, or `null` if it does not exist.
|
|
3672
|
+
*/
|
|
3673
|
+
info() {
|
|
3674
|
+
return new VectorInfoCommand([this.name], this.commandOptions).exec(this.client);
|
|
3675
|
+
}
|
|
3676
|
+
/**
|
|
3677
|
+
* Drops the index and all vectors in it.
|
|
3678
|
+
*
|
|
3679
|
+
* @returns `1` if the index existed and was dropped, `0` otherwise.
|
|
3680
|
+
*/
|
|
3681
|
+
drop() {
|
|
3682
|
+
return new VectorDropCommand([this.name], this.commandOptions).exec(this.client);
|
|
3683
|
+
}
|
|
3684
|
+
};
|
|
3685
|
+
async function createVectorIndex(client, { name, ...opts }, commandOptions) {
|
|
3686
|
+
await new VectorCreateCommand([name, opts], commandOptions).exec(client);
|
|
3687
|
+
return new VectorIndex({ name, client, commandOptions });
|
|
3688
|
+
}
|
|
3689
|
+
function initVectorIndex(client, name, commandOptions) {
|
|
3690
|
+
return new VectorIndex({ name, client, commandOptions });
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3258
3693
|
// pkg/commands/psubscribe.ts
|
|
3259
3694
|
var PSubscribeCommand = class extends Command {
|
|
3260
3695
|
constructor(cmd, opts) {
|
|
@@ -3522,6 +3957,78 @@ var Pipeline = class {
|
|
|
3522
3957
|
* @see https://redis.io/commands/append
|
|
3523
3958
|
*/
|
|
3524
3959
|
append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
|
|
3960
|
+
/**
|
|
3961
|
+
* @see https://upstash.com/docs/redis/commands/array/arcount
|
|
3962
|
+
*/
|
|
3963
|
+
arcount = (...args) => this.chain(new ArCountCommand(args, this.commandOptions));
|
|
3964
|
+
/**
|
|
3965
|
+
* @see https://upstash.com/docs/redis/commands/array/ardel
|
|
3966
|
+
*/
|
|
3967
|
+
ardel = (...args) => this.chain(new ArDelCommand(args, this.commandOptions));
|
|
3968
|
+
/**
|
|
3969
|
+
* @see https://upstash.com/docs/redis/commands/array/ardelrange
|
|
3970
|
+
*/
|
|
3971
|
+
ardelrange = (...args) => this.chain(new ArDelRangeCommand(args, this.commandOptions));
|
|
3972
|
+
/**
|
|
3973
|
+
* @see https://upstash.com/docs/redis/commands/array/arget
|
|
3974
|
+
*/
|
|
3975
|
+
arget = (...args) => this.chain(new ArGetCommand(args, this.commandOptions));
|
|
3976
|
+
/**
|
|
3977
|
+
* @see https://upstash.com/docs/redis/commands/array/argetrange
|
|
3978
|
+
*/
|
|
3979
|
+
argetrange = (...args) => this.chain(new ArGetRangeCommand(args, this.commandOptions));
|
|
3980
|
+
/**
|
|
3981
|
+
* @see https://upstash.com/docs/redis/commands/array/argrep
|
|
3982
|
+
*/
|
|
3983
|
+
argrep = (key, start, end, opts) => this.chain(new ArGrepCommand([key, start, end, opts], this.commandOptions));
|
|
3984
|
+
/**
|
|
3985
|
+
* @see https://upstash.com/docs/redis/commands/array/arinfo
|
|
3986
|
+
*/
|
|
3987
|
+
arinfo = (...args) => this.chain(new ArInfoCommand(args, this.commandOptions));
|
|
3988
|
+
/**
|
|
3989
|
+
* @see https://upstash.com/docs/redis/commands/array/arinsert
|
|
3990
|
+
*/
|
|
3991
|
+
arinsert = (key, ...values) => this.chain(new ArInsertCommand([key, ...values], this.commandOptions));
|
|
3992
|
+
/**
|
|
3993
|
+
* @see https://upstash.com/docs/redis/commands/array/arlastitems
|
|
3994
|
+
*/
|
|
3995
|
+
arlastitems = (...args) => this.chain(new ArLastItemsCommand(args, this.commandOptions));
|
|
3996
|
+
/**
|
|
3997
|
+
* @see https://upstash.com/docs/redis/commands/array/arlen
|
|
3998
|
+
*/
|
|
3999
|
+
arlen = (...args) => this.chain(new ArLenCommand(args, this.commandOptions));
|
|
4000
|
+
/**
|
|
4001
|
+
* @see https://upstash.com/docs/redis/commands/array/armget
|
|
4002
|
+
*/
|
|
4003
|
+
armget = (...args) => this.chain(new ArMGetCommand(args, this.commandOptions));
|
|
4004
|
+
/**
|
|
4005
|
+
* @see https://upstash.com/docs/redis/commands/array/armset
|
|
4006
|
+
*/
|
|
4007
|
+
armset = (key, values) => this.chain(new ArMSetCommand([key, values], this.commandOptions));
|
|
4008
|
+
/**
|
|
4009
|
+
* @see https://upstash.com/docs/redis/commands/array/arnext
|
|
4010
|
+
*/
|
|
4011
|
+
arnext = (...args) => this.chain(new ArNextCommand(args, this.commandOptions));
|
|
4012
|
+
/**
|
|
4013
|
+
* @see https://upstash.com/docs/redis/commands/array/arop
|
|
4014
|
+
*/
|
|
4015
|
+
arop = (key, start, end, operation) => this.chain(new ArOpCommand([key, start, end, operation], this.commandOptions));
|
|
4016
|
+
/**
|
|
4017
|
+
* @see https://upstash.com/docs/redis/commands/array/arring
|
|
4018
|
+
*/
|
|
4019
|
+
arring = (key, size, ...values) => this.chain(new ArRingCommand([key, size, ...values], this.commandOptions));
|
|
4020
|
+
/**
|
|
4021
|
+
* @see https://upstash.com/docs/redis/commands/array/arscan
|
|
4022
|
+
*/
|
|
4023
|
+
arscan = (...args) => this.chain(new ArScanCommand(args, this.commandOptions));
|
|
4024
|
+
/**
|
|
4025
|
+
* @see https://upstash.com/docs/redis/commands/array/arseek
|
|
4026
|
+
*/
|
|
4027
|
+
arseek = (...args) => this.chain(new ArSeekCommand(args, this.commandOptions));
|
|
4028
|
+
/**
|
|
4029
|
+
* @see https://upstash.com/docs/redis/commands/array/arset
|
|
4030
|
+
*/
|
|
4031
|
+
arset = (key, index, ...values) => this.chain(new ArSetCommand([key, index, ...values], this.commandOptions));
|
|
3525
4032
|
/**
|
|
3526
4033
|
* @see https://redis.io/commands/bitcount
|
|
3527
4034
|
*/
|
|
@@ -4716,6 +5223,32 @@ var Redis = class {
|
|
|
4716
5223
|
}
|
|
4717
5224
|
};
|
|
4718
5225
|
}
|
|
5226
|
+
/**
|
|
5227
|
+
* Vector index commands.
|
|
5228
|
+
*
|
|
5229
|
+
* @example
|
|
5230
|
+
* ```typescript
|
|
5231
|
+
* const index = await redis.vector.createIndex({ name: "docs", dimension: 3, metric: "COSINE" });
|
|
5232
|
+
* await index.add("doc-1", [0.1, 0.2, 0.3]);
|
|
5233
|
+
* const hits = await index.query({ vector: [0.1, 0.2, 0.3], topK: 5 });
|
|
5234
|
+
* ```
|
|
5235
|
+
*/
|
|
5236
|
+
get vector() {
|
|
5237
|
+
return {
|
|
5238
|
+
/**
|
|
5239
|
+
* Creates a vector index and returns a handle to it.
|
|
5240
|
+
*/
|
|
5241
|
+
createIndex: (params) => {
|
|
5242
|
+
return createVectorIndex(this.client, params, this.opts);
|
|
5243
|
+
},
|
|
5244
|
+
/**
|
|
5245
|
+
* Returns a handle to an existing vector index without sending any command.
|
|
5246
|
+
*/
|
|
5247
|
+
index: (name) => {
|
|
5248
|
+
return initVectorIndex(this.client, name, this.opts);
|
|
5249
|
+
}
|
|
5250
|
+
};
|
|
5251
|
+
}
|
|
4719
5252
|
/**
|
|
4720
5253
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
4721
5254
|
*
|
|
@@ -4763,6 +5296,78 @@ var Redis = class {
|
|
|
4763
5296
|
* @see https://redis.io/commands/append
|
|
4764
5297
|
*/
|
|
4765
5298
|
append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
|
|
5299
|
+
/**
|
|
5300
|
+
* @see https://upstash.com/docs/redis/commands/array/arcount
|
|
5301
|
+
*/
|
|
5302
|
+
arcount = (...args) => new ArCountCommand(args, this.opts).exec(this.client);
|
|
5303
|
+
/**
|
|
5304
|
+
* @see https://upstash.com/docs/redis/commands/array/ardel
|
|
5305
|
+
*/
|
|
5306
|
+
ardel = (...args) => new ArDelCommand(args, this.opts).exec(this.client);
|
|
5307
|
+
/**
|
|
5308
|
+
* @see https://upstash.com/docs/redis/commands/array/ardelrange
|
|
5309
|
+
*/
|
|
5310
|
+
ardelrange = (...args) => new ArDelRangeCommand(args, this.opts).exec(this.client);
|
|
5311
|
+
/**
|
|
5312
|
+
* @see https://upstash.com/docs/redis/commands/array/arget
|
|
5313
|
+
*/
|
|
5314
|
+
arget = (...args) => new ArGetCommand(args, this.opts).exec(this.client);
|
|
5315
|
+
/**
|
|
5316
|
+
* @see https://upstash.com/docs/redis/commands/array/argetrange
|
|
5317
|
+
*/
|
|
5318
|
+
argetrange = (...args) => new ArGetRangeCommand(args, this.opts).exec(this.client);
|
|
5319
|
+
/**
|
|
5320
|
+
* @see https://upstash.com/docs/redis/commands/array/argrep
|
|
5321
|
+
*/
|
|
5322
|
+
argrep = (key, start, end, opts) => new ArGrepCommand([key, start, end, opts], this.opts).exec(this.client);
|
|
5323
|
+
/**
|
|
5324
|
+
* @see https://upstash.com/docs/redis/commands/array/arinfo
|
|
5325
|
+
*/
|
|
5326
|
+
arinfo = (...args) => new ArInfoCommand(args, this.opts).exec(this.client);
|
|
5327
|
+
/**
|
|
5328
|
+
* @see https://upstash.com/docs/redis/commands/array/arinsert
|
|
5329
|
+
*/
|
|
5330
|
+
arinsert = (key, ...values) => new ArInsertCommand([key, ...values], this.opts).exec(this.client);
|
|
5331
|
+
/**
|
|
5332
|
+
* @see https://upstash.com/docs/redis/commands/array/arlastitems
|
|
5333
|
+
*/
|
|
5334
|
+
arlastitems = (...args) => new ArLastItemsCommand(args, this.opts).exec(this.client);
|
|
5335
|
+
/**
|
|
5336
|
+
* @see https://upstash.com/docs/redis/commands/array/arlen
|
|
5337
|
+
*/
|
|
5338
|
+
arlen = (...args) => new ArLenCommand(args, this.opts).exec(this.client);
|
|
5339
|
+
/**
|
|
5340
|
+
* @see https://upstash.com/docs/redis/commands/array/armget
|
|
5341
|
+
*/
|
|
5342
|
+
armget = (...args) => new ArMGetCommand(args, this.opts).exec(this.client);
|
|
5343
|
+
/**
|
|
5344
|
+
* @see https://upstash.com/docs/redis/commands/array/armset
|
|
5345
|
+
*/
|
|
5346
|
+
armset = (key, values) => new ArMSetCommand([key, values], this.opts).exec(this.client);
|
|
5347
|
+
/**
|
|
5348
|
+
* @see https://upstash.com/docs/redis/commands/array/arnext
|
|
5349
|
+
*/
|
|
5350
|
+
arnext = (...args) => new ArNextCommand(args, this.opts).exec(this.client);
|
|
5351
|
+
/**
|
|
5352
|
+
* @see https://upstash.com/docs/redis/commands/array/arop
|
|
5353
|
+
*/
|
|
5354
|
+
arop = (key, start, end, operation) => new ArOpCommand([key, start, end, operation], this.opts).exec(this.client);
|
|
5355
|
+
/**
|
|
5356
|
+
* @see https://upstash.com/docs/redis/commands/array/arring
|
|
5357
|
+
*/
|
|
5358
|
+
arring = (key, size, ...values) => new ArRingCommand([key, size, ...values], this.opts).exec(this.client);
|
|
5359
|
+
/**
|
|
5360
|
+
* @see https://upstash.com/docs/redis/commands/array/arscan
|
|
5361
|
+
*/
|
|
5362
|
+
arscan = (...args) => new ArScanCommand(args, this.opts).exec(this.client);
|
|
5363
|
+
/**
|
|
5364
|
+
* @see https://upstash.com/docs/redis/commands/array/arseek
|
|
5365
|
+
*/
|
|
5366
|
+
arseek = (...args) => new ArSeekCommand(args, this.opts).exec(this.client);
|
|
5367
|
+
/**
|
|
5368
|
+
* @see https://upstash.com/docs/redis/commands/array/arset
|
|
5369
|
+
*/
|
|
5370
|
+
arset = (key, index, ...values) => new ArSetCommand([key, index, ...values], this.opts).exec(this.client);
|
|
4766
5371
|
/**
|
|
4767
5372
|
* @see https://redis.io/commands/bitcount
|
|
4768
5373
|
*/
|
|
@@ -5451,7 +6056,7 @@ var Redis = class {
|
|
|
5451
6056
|
};
|
|
5452
6057
|
|
|
5453
6058
|
// version.ts
|
|
5454
|
-
var VERSION = "v1.
|
|
6059
|
+
var VERSION = "v1.39.0";
|
|
5455
6060
|
|
|
5456
6061
|
// platforms/cloudflare.ts
|
|
5457
6062
|
var Redis2 = class _Redis extends Redis {
|