11import { z } from "zod" ;
22
3- export type SearchRequest = z . infer < typeof searchRequestSchema > ;
43export const searchRequestSchema = z . object ( {
54 query : z . string ( ) ,
65 numResults : z . number ( ) ,
76 whole : z . boolean ( ) . optional ( ) ,
87} ) ;
98
109
11- export type SearchResponse = z . infer < typeof searchResponseSchema > ;
12- export type SearchResult = SearchResponse [ "Result" ] ;
13- export type SearchResultFile = NonNullable < SearchResult [ "Files" ] > [ number ] ;
14- export type SearchResultFileMatch = SearchResultFile [ "ChunkMatches" ] [ number ] ;
15- export type SearchResultRange = z . infer < typeof rangeSchema > ;
16- export type SearchResultLocation = z . infer < typeof locationSchema > ;
17-
1810// @see : https://github.com/TaqlaAI/zoekt/blob/main/api.go#L212
19- const locationSchema = z . object ( {
11+ export const locationSchema = z . object ( {
2012 // 0-based byte offset from the beginning of the file
2113 ByteOffset : z . number ( ) ,
2214 // 1-based line number from the beginning of the file
@@ -25,7 +17,7 @@ const locationSchema = z.object({
2517 Column : z . number ( ) ,
2618} ) ;
2719
28- const rangeSchema = z . object ( {
20+ export const rangeSchema = z . object ( {
2921 Start : locationSchema ,
3022 End : locationSchema ,
3123} ) ;
@@ -79,22 +71,16 @@ export const searchResponseSchema = z.object({
7971 } ) ,
8072} ) ;
8173
82- export type FileSourceRequest = z . infer < typeof fileSourceRequestSchema > ;
8374export const fileSourceRequestSchema = z . object ( {
8475 fileName : z . string ( ) ,
8576 repository : z . string ( )
8677} ) ;
8778
88- export type FileSourceResponse = z . infer < typeof fileSourceResponseSchema > ;
89-
9079export const fileSourceResponseSchema = z . object ( {
9180 source : z . string ( ) ,
9281} ) ;
9382
9483
95- export type ListRepositoriesResponse = z . infer < typeof listRepositoriesResponseSchema > ;
96- export type Repository = z . infer < typeof repositorySchema > ;
97-
9884// @see : https://github.com/TaqlaAI/zoekt/blob/3780e68cdb537d5a7ed2c84d9b3784f80c7c5d04/api.go#L728
9985const repoStatsSchema = z . object ( {
10086 Repos : z . number ( ) ,
@@ -120,7 +106,7 @@ const indexMetadataSchema = z.object({
120106} ) ;
121107
122108// @see : https://github.com/TaqlaAI/zoekt/blob/3780e68cdb537d5a7ed2c84d9b3784f80c7c5d04/api.go#L555
123- const repositorySchema = z . object ( {
109+ export const repositorySchema = z . object ( {
124110 Name : z . string ( ) ,
125111 URL : z . string ( ) ,
126112 Source : z . string ( ) ,
0 commit comments