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