Add explicit typing for view search filter config

This commit is contained in:
Dean 2024-10-02 09:51:13 +01:00
parent 2884ac4638
commit 61a0db0984
1 changed files with 6 additions and 3 deletions

View File

@ -3,6 +3,8 @@ import {
LogicalOperator,
Row,
RowSearchParams,
SearchFilter,
SearchFilterGroup,
SearchFilterKey,
SearchFilters,
SearchResponse,
@ -91,11 +93,12 @@ export async function search(
if (!isExternalTable && !(await features.flags.isEnabled("SQS"))) {
// Lucene does not accept conditional filters, so we need to keep the old logic
const query: SearchFilters = viewQuery
const query: SearchFilters = viewQuery || {}
const viewFilters = view.query as SearchFilter[]
// Extract existing fields
const existingFields =
view.query
viewFilters
?.filter(filter => filter.field)
.map(filter => db.removeKeyNumbering(filter.field)) || []
@ -112,7 +115,7 @@ export async function search(
} else {
options.query = {
$and: {
conditions: [viewQuery, options.query],
conditions: [viewQuery as SearchFilterGroup, options.query],
},
}
}