Skip to content

Commit eebfe04

Browse files
authored
Remove min max being optional in facetStats results (#1470)
1 parent 84bd433 commit eebfe04

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/types/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ export type Hit<T = Record<string, any>> = T & {
129129

130130
export type Hits<T = Record<string, any>> = Array<Hit<T>>
131131

132+
export type FacetStat = { min: number; max: number }
133+
export type FacetStats = Record<string, FacetStat>
134+
132135
export type SearchResponse<
133136
T = Record<string, any>,
134137
S extends SearchParams | undefined = undefined
@@ -137,7 +140,7 @@ export type SearchResponse<
137140
processingTimeMs: number
138141
facetDistribution?: FacetDistribution
139142
query: string
140-
facetStats?: Record<string, { min?: number; max?: number }>
143+
facetStats?: FacetStats
141144
} & (undefined extends S
142145
? Partial<FinitePagination & InfinitePagination>
143146
: true extends IsFinitePagination<NonNullable<S>>

tests/search.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ describe.each([
515515
id: { '123': 1, '2': 1 },
516516
})
517517

518-
expect(response).toHaveProperty('facetStats', { id: { min: 2, max: 123 } })
519-
expect(response.facetStats?.['id']?.min).toBe(2)
518+
expect(response.facetStats).toEqual({ id: { min: 2, max: 123 } })
520519
expect(response.facetStats?.['id']?.max).toBe(123)
521520
expect(response).toHaveProperty('hits', expect.any(Array))
522521
expect(response.hits.length).toEqual(2)

0 commit comments

Comments
 (0)