From 61a0db0984ee4bd59094c214ebd55c43e763ce45 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 2 Oct 2024 09:51:13 +0100 Subject: [PATCH] Add explicit typing for view search filter config --- packages/server/src/sdk/app/rows/search.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search.ts b/packages/server/src/sdk/app/rows/search.ts index 8de5818805..dae24c6bc0 100644 --- a/packages/server/src/sdk/app/rows/search.ts +++ b/packages/server/src/sdk/app/rows/search.ts @@ -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], }, } }