Make type of `SearchResponse` more correct regarding pagination
fehnomenal opened this issue · comments
Description
Currently SearchResponse
contains all pagination related properties (totalHits
, hitsPerPage
, page
, totalPages
, offset
, limit
and estimatedTotalHits
) and each of them is optional. If I understand the documentation at https://docs.meilisearch.com/learn/advanced/pagination.html correctly it is clear from the request which of those properties are returned and which not. And indeed this is the case in my tests.
Basic example
I would like to extend the signature of the type to SearchResponse<T = Record<string, any>, Finite extends boolean | undefined = undefined>
. Depending on Finite
the properties for the finite or the infinite pagination are added.
I included undefined
to be somewhat backwards compatible. I.e. when using as an intermediate variable without specifying the finiteness (const result: SearchResponse<{ id: number }>
) it would have all pagination properties optional.
I have this ready locally and will open a PR soon unless you absolutely not want this.