1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

fix types

This commit is contained in:
Peter Clement 2024-03-04 09:55:28 +00:00
parent e3c514e45a
commit 5679acb868

View file

@ -391,7 +391,8 @@ export const runLuceneQuery = (docs: any[], query?: SearchQuery) => {
) )
const docMatch = (doc: any) => { const docMatch = (doc: any) => {
const filterFunctions = { const filterFunctions: Record<SearchQueryOperators, (doc: any) => boolean> =
{
string: stringMatch, string: stringMatch,
fuzzy: fuzzyMatch, fuzzy: fuzzyMatch,
range: rangeMatch, range: rangeMatch,
@ -404,15 +405,14 @@ export const runLuceneQuery = (docs: any[], query?: SearchQuery) => {
containsAny: containsAny, containsAny: containsAny,
notContains: notContains, notContains: notContains,
} }
const activeFilterKeys: (keyof typeof filterFunctions)[] = Object.entries(
query const activeFilterKeys: SearchQueryOperators[] = Object.entries(query)
)
.filter( .filter(
([key, value]: [string, any]) => ([key, value]: [string, any]) =>
!["allOr", "onEmptyFilter"].includes(key) && !["allOr", "onEmptyFilter"].includes(key) &&
Object.keys(value as Record<string, any>).length > 0 Object.keys(value as Record<string, any>).length > 0
) )
.map(([key]) => key as keyof typeof filterFunctions) .map(([key]) => key as any)
const results: boolean[] = activeFilterKeys.map(filterKey => { const results: boolean[] = activeFilterKeys.map(filterKey => {
const filterFunction = filterFunctions[filterKey] const filterFunction = filterFunctions[filterKey]