1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12: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 filterFunctions = {
const filterFunctions: Record<SearchQueryOperators, (doc: any) => boolean> =
{
string: stringMatch,
fuzzy: fuzzyMatch,
range: rangeMatch,
@ -404,15 +405,14 @@ export const runLuceneQuery = (docs: any[], query?: SearchQuery) => {
containsAny: containsAny,
notContains: notContains,
}
const activeFilterKeys: (keyof typeof filterFunctions)[] = Object.entries(
query
)
const activeFilterKeys: SearchQueryOperators[] = Object.entries(query)
.filter(
([key, value]: [string, any]) =>
!["allOr", "onEmptyFilter"].includes(key) &&
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 filterFunction = filterFunctions[filterKey]