Merge pull request #14669 from Budibase/better-types-on-removeInvalidFilters
Remove an implicit any from removeInvalidFilters.
This commit is contained in:
commit
6b3867faee
|
@ -16,11 +16,11 @@ export const removeInvalidFilters = (
|
||||||
|
|
||||||
validFields = validFields.map(f => f.toLowerCase())
|
validFields = validFields.map(f => f.toLowerCase())
|
||||||
for (const filterKey of Object.keys(result) as (keyof SearchFilters)[]) {
|
for (const filterKey of Object.keys(result) as (keyof SearchFilters)[]) {
|
||||||
const filter = result[filterKey]
|
|
||||||
if (!filter || typeof filter !== "object") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (isLogicalSearchOperator(filterKey)) {
|
if (isLogicalSearchOperator(filterKey)) {
|
||||||
|
const filter = result[filterKey]
|
||||||
|
if (!filter || typeof filter !== "object") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
const resultingConditions: SearchFilters[] = []
|
const resultingConditions: SearchFilters[] = []
|
||||||
for (const condition of filter.conditions) {
|
for (const condition of filter.conditions) {
|
||||||
const resultingCondition = removeInvalidFilters(condition, validFields)
|
const resultingCondition = removeInvalidFilters(condition, validFields)
|
||||||
|
@ -36,6 +36,11 @@ export const removeInvalidFilters = (
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filter = result[filterKey]
|
||||||
|
if (!filter || typeof filter !== "object") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for (const columnKey of Object.keys(filter)) {
|
for (const columnKey of Object.keys(filter)) {
|
||||||
const possibleKeys = [columnKey, db.removeKeyNumbering(columnKey)].map(
|
const possibleKeys = [columnKey, db.removeKeyNumbering(columnKey)].map(
|
||||||
c => c.toLowerCase()
|
c => c.toLowerCase()
|
||||||
|
|
|
@ -68,6 +68,8 @@ type RangeFilter = Record<
|
||||||
[InternalSearchFilterOperator.COMPLEX_ID_OPERATOR]?: never
|
[InternalSearchFilterOperator.COMPLEX_ID_OPERATOR]?: never
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LogicalFilter = { conditions: SearchFilters[] }
|
||||||
|
|
||||||
export type AnySearchFilter = BasicFilter | ArrayFilter | RangeFilter
|
export type AnySearchFilter = BasicFilter | ArrayFilter | RangeFilter
|
||||||
|
|
||||||
export interface SearchFilters {
|
export interface SearchFilters {
|
||||||
|
@ -92,12 +94,8 @@ export interface SearchFilters {
|
||||||
// specific document type (such as just rows)
|
// specific document type (such as just rows)
|
||||||
documentType?: DocumentType
|
documentType?: DocumentType
|
||||||
|
|
||||||
[LogicalOperator.AND]?: {
|
[LogicalOperator.AND]?: LogicalFilter
|
||||||
conditions: SearchFilters[]
|
[LogicalOperator.OR]?: LogicalFilter
|
||||||
}
|
|
||||||
[LogicalOperator.OR]?: {
|
|
||||||
conditions: SearchFilters[]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SearchFilterKey = keyof Omit<
|
export type SearchFilterKey = keyof Omit<
|
||||||
|
|
Loading…
Reference in New Issue