@@ -28,6 +28,7 @@ describe("vectorize help", () => {
28
28
wrangler vectorize delete <name> Delete a Vectorize index
29
29
wrangler vectorize get <name> Get a Vectorize index by name
30
30
wrangler vectorize list List your Vectorize indexes
31
+ wrangler vectorize list-vectors <name> List vector identifiers in a Vectorize index
31
32
wrangler vectorize query <name> Query a Vectorize index
32
33
wrangler vectorize insert <name> Insert vectors into a Vectorize index
33
34
wrangler vectorize upsert <name> Upsert vectors into a Vectorize index
@@ -69,6 +70,7 @@ describe("vectorize help", () => {
69
70
wrangler vectorize delete <name> Delete a Vectorize index
70
71
wrangler vectorize get <name> Get a Vectorize index by name
71
72
wrangler vectorize list List your Vectorize indexes
73
+ wrangler vectorize list-vectors <name> List vector identifiers in a Vectorize index
72
74
wrangler vectorize query <name> Query a Vectorize index
73
75
wrangler vectorize insert <name> Insert vectors into a Vectorize index
74
76
wrangler vectorize upsert <name> Upsert vectors into a Vectorize index
@@ -677,6 +679,146 @@ describe("vectorize commands", () => {
677
679
✅ Successfully enqueued metadata index deletion request. Mutation changeset identifier: xxxxxx-xxxx-xxxx-xxxx-xxxxxx."
678
680
` ) ;
679
681
} ) ;
682
+
683
+ it ( "should show help when the list-vectors command is passed without an index" , async ( ) => {
684
+ await expect ( ( ) => runWrangler ( "vectorize list-vectors" ) ) . rejects . toThrow (
685
+ "Not enough non-option arguments: got 0, need at least 1"
686
+ ) ;
687
+
688
+ expect ( std . err ) . toMatchInlineSnapshot ( `
689
+ "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough non-option arguments: got 0, need at least 1[0m
690
+
691
+ "
692
+ ` ) ;
693
+ expect ( std . out ) . toMatchInlineSnapshot ( `
694
+ "
695
+ wrangler vectorize list-vectors <name>
696
+
697
+ List vector identifiers in a Vectorize index
698
+
699
+ POSITIONALS
700
+ name The name of the Vectorize index [string] [required]
701
+
702
+ GLOBAL FLAGS
703
+ -c, --config Path to Wrangler configuration file [string]
704
+ --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
705
+ -e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
706
+ --env-file Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files [array]
707
+ -h, --help Show help [boolean]
708
+ -v, --version Show version number [boolean]
709
+
710
+ OPTIONS
711
+ --count Maximum number of vectors to return (1-1000) [number]
712
+ --cursor Cursor for pagination to get the next page of results [string]
713
+ --json Return output as clean JSON [boolean] [default: false]
714
+
715
+ EXAMPLES
716
+ wrangler vectorize list-vectors my-index List vector identifiers in the index 'my-index'
717
+ wrangler vectorize list-vectors my-index --count 50 List up to 50 vector identifiers
718
+ wrangler vectorize list-vectors my-index --cursor abc123 Continue listing from a specific cursor position"
719
+ ` ) ;
720
+ } ) ;
721
+
722
+ it ( "should handle list-vectors on a vectorize index" , async ( ) => {
723
+ mockVectorizeV2Request ( ) ;
724
+ await runWrangler ( "vectorize list-vectors test-index" ) ;
725
+ expect ( std . out ) . toMatchInlineSnapshot ( `
726
+ "📋 Listing vectors in index 'test-index'...
727
+ ┌─┬─┐
728
+ │ # │ Vector ID │
729
+ ├─┼─┤
730
+ │ 1 │ vector-1 │
731
+ ├─┼─┤
732
+ │ 2 │ vector-2 │
733
+ ├─┼─┤
734
+ │ 3 │ vector-3 │
735
+ └─┴─┘
736
+
737
+ Showing 3 of 5 total vectors
738
+
739
+ 💡 To get the next page, run:
740
+ wrangler vectorize list-vectors test-index --cursor next-page-cursor"
741
+ ` ) ;
742
+ } ) ;
743
+
744
+ it ( "should handle list-vectors with custom count parameter" , async ( ) => {
745
+ mockVectorizeV2Request ( ) ;
746
+ await runWrangler ( "vectorize list-vectors test-index --count 2" ) ;
747
+ expect ( std . out ) . toMatchInlineSnapshot ( `
748
+ "📋 Listing vectors in index 'test-index'...
749
+ ┌─┬─┐
750
+ │ # │ Vector ID │
751
+ ├─┼─┤
752
+ │ 1 │ vector-1 │
753
+ ├─┼─┤
754
+ │ 2 │ vector-2 │
755
+ └─┴─┘
756
+
757
+ Showing 2 of 5 total vectors
758
+
759
+ 💡 To get the next page, run:
760
+ wrangler vectorize list-vectors test-index --cursor next-page-cursor"
761
+ ` ) ;
762
+ } ) ;
763
+
764
+ it ( "should handle list-vectors with cursor pagination" , async ( ) => {
765
+ mockVectorizeV2Request ( ) ;
766
+ await runWrangler (
767
+ "vectorize list-vectors test-index --cursor next-page-cursor"
768
+ ) ;
769
+ expect ( std . out ) . toMatchInlineSnapshot ( `
770
+ "📋 Listing vectors in index 'test-index'...
771
+ ┌─┬─┐
772
+ │ # │ Vector ID │
773
+ ├─┼─┤
774
+ │ 1 │ vector-4 │
775
+ ├─┼─┤
776
+ │ 2 │ vector-5 │
777
+ └─┴─┘
778
+
779
+ Showing 2 of 5 total vectors"
780
+ ` ) ;
781
+ } ) ;
782
+
783
+ it ( "should handle list-vectors with JSON output" , async ( ) => {
784
+ mockVectorizeV2Request ( ) ;
785
+ await runWrangler ( "vectorize list-vectors test-index --json" ) ;
786
+ expect ( std . out ) . toMatchInlineSnapshot ( `
787
+ "📋 Listing vectors in index 'test-index'...
788
+ {
789
+ \\"count\\": 3,
790
+ \\"totalCount\\": 5,
791
+ \\"isTruncated\\": true,
792
+ \\"nextCursor\\": \\"next-page-cursor\\",
793
+ \\"cursorExpirationTimestamp\\": \\"2025-08-13T20:32:52.469144957+00:00\\",
794
+ \\"vectors\\": [
795
+ {
796
+ \\"id\\": \\"vector-1\\"
797
+ },
798
+ {
799
+ \\"id\\": \\"vector-2\\"
800
+ },
801
+ {
802
+ \\"id\\": \\"vector-3\\"
803
+ }
804
+ ]
805
+ }"
806
+ ` ) ;
807
+ } ) ;
808
+
809
+ it ( "should warn when list-vectors returns no vectors" , async ( ) => {
810
+ mockVectorizeV2RequestError ( ) ;
811
+ await runWrangler ( "vectorize list-vectors test-index" ) ;
812
+ expect ( std . out ) . toMatchInlineSnapshot ( `
813
+ "📋 Listing vectors in index 'test-index'..."
814
+ ` ) ;
815
+
816
+ expect ( std . warn ) . toMatchInlineSnapshot ( `
817
+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mNo vectors found in this index.[0m
818
+
819
+ "
820
+ ` ) ;
821
+ } ) ;
680
822
} ) ;
681
823
682
824
describe ( "vectorize query filter" , ( ) => {
@@ -1120,6 +1262,58 @@ function mockVectorizeV2Request() {
1120
1262
) ;
1121
1263
} ,
1122
1264
{ once : true }
1265
+ ) ,
1266
+ http . get (
1267
+ "*/accounts/:accountId/vectorize/v2/indexes/test-index/list" ,
1268
+ ( { request } ) => {
1269
+ const url = new URL ( request . url ) ;
1270
+ const count = url . searchParams . get ( "count" ) ;
1271
+ const cursor = url . searchParams . get ( "cursor" ) ;
1272
+
1273
+ // Mock pagination logic
1274
+ if ( cursor === "next-page-cursor" ) {
1275
+ const vectors = [ { id : "vector-4" } , { id : "vector-5" } ] ;
1276
+ return HttpResponse . json (
1277
+ createFetchResult (
1278
+ {
1279
+ count : vectors . length ,
1280
+ totalCount : 5 ,
1281
+ isTruncated : false ,
1282
+ nextCursor : null ,
1283
+ cursorExpirationTimestamp : null ,
1284
+ vectors,
1285
+ } ,
1286
+ true
1287
+ )
1288
+ ) ;
1289
+ }
1290
+
1291
+ // Default first page response
1292
+ const pageSize = count ? parseInt ( count ) : 3 ;
1293
+ const mockVectors = [
1294
+ { id : "vector-1" } ,
1295
+ { id : "vector-2" } ,
1296
+ { id : "vector-3" } ,
1297
+ ] ;
1298
+
1299
+ const returnedVectors = mockVectors . slice ( 0 , pageSize ) ;
1300
+
1301
+ return HttpResponse . json (
1302
+ createFetchResult (
1303
+ {
1304
+ count : returnedVectors . length ,
1305
+ totalCount : 5 ,
1306
+ isTruncated : returnedVectors . length < 5 ,
1307
+ nextCursor :
1308
+ returnedVectors . length < 5 ? "next-page-cursor" : null ,
1309
+ cursorExpirationTimestamp : "2025-08-13T20:32:52.469144957+00:00" ,
1310
+ vectors : returnedVectors ,
1311
+ } ,
1312
+ true
1313
+ )
1314
+ ) ;
1315
+ } ,
1316
+ { once : true }
1123
1317
)
1124
1318
) ;
1125
1319
}
@@ -1168,6 +1362,25 @@ function mockVectorizeV2RequestError() {
1168
1362
) ;
1169
1363
} ,
1170
1364
{ once : true }
1365
+ ) ,
1366
+ http . get (
1367
+ "*/accounts/:accountId/vectorize/v2/indexes/test-index/list" ,
1368
+ ( ) => {
1369
+ return HttpResponse . json (
1370
+ createFetchResult (
1371
+ {
1372
+ count : 0 ,
1373
+ totalCount : 0 ,
1374
+ isTruncated : false ,
1375
+ nextCursor : null ,
1376
+ cursorExpirationTimestamp : null ,
1377
+ vectors : [ ] ,
1378
+ } ,
1379
+ true
1380
+ )
1381
+ ) ;
1382
+ } ,
1383
+ { once : true }
1171
1384
)
1172
1385
) ;
1173
1386
}
0 commit comments