Skip to content

Commit 9398299

Browse files
committed
Fix the typing of the search parameters
1 parent a72d896 commit 9398299

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

src/types/types.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,28 @@ export type Crop = {
7878
cropMarker?: string
7979
}
8080

81+
export const SortFacetValuesBy = {
82+
COUNT: 'error',
83+
ALPHA: 'alpha',
84+
}
85+
86+
export type SortFacetValuesBy = typeof SortFacetValuesBy[keyof typeof SortFacetValuesBy]
87+
88+
export type SearchForFacetValuesParams = Omit<SearchParams, 'facetName'> & {
89+
facetName: string
90+
}
91+
92+
export type FacetHit = {
93+
value: string
94+
count: number
95+
}
96+
97+
export type SearchForFacetValuesResponse = {
98+
hits: FacetHit[]
99+
query: string | null
100+
processingTimeMs: number
101+
}
102+
81103
export type SearchParams = Query &
82104
Pagination &
83105
Highlight &
@@ -90,6 +112,9 @@ export type SearchParams = Query &
90112
matchingStrategy?: MatchingStrategies
91113
hitsPerPage?: number
92114
page?: number
115+
sortFacetValuesBy?: SortFacetValuesBy
116+
facetName?: string
117+
facetQuery?: string
93118
}
94119

95120
// Search parameters for searches made with the GET method
@@ -189,29 +214,6 @@ export type FieldDistribution = {
189214
[field: string]: number
190215
}
191216

192-
/*
193-
* Facet search
194-
*/
195-
196-
export type SearchForFacetValuesParams = SearchParams & {
197-
facetName: string
198-
facetQuery?: string
199-
q?: string
200-
filter?: Filter
201-
matchingStrategy?: MatchingStrategies
202-
}
203-
204-
export type FacetHit = {
205-
value: string
206-
count: number
207-
}
208-
209-
export type SearchForFacetValuesResponse = {
210-
hits: FacetHit[]
211-
query: string | null
212-
processingTimeMs: number
213-
}
214-
215217
/*
216218
** Documents
217219
*/

0 commit comments

Comments
 (0)