diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 3c6901e195..28f0b28425 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -310,16 +310,12 @@ export const buildQuery = (filter: SearchFilter[]) => { query.equal = query.equal || {} query.equal[field] = true } else { - query[queryOperator] = { - ...query[queryOperator], - [field]: value, - } + query[queryOperator] ??= {} + query[queryOperator]![field] = value } } else { - query[queryOperator] = { - ...query[queryOperator], - [field]: value, - } + query[queryOperator] ??= {} + query[queryOperator]![field] = value } } }) diff --git a/packages/types/src/sdk/search.ts b/packages/types/src/sdk/search.ts index 856011284f..713b33ff54 100644 --- a/packages/types/src/sdk/search.ts +++ b/packages/types/src/sdk/search.ts @@ -21,7 +21,7 @@ export enum InternalSearchFilterOperator { COMPLEX_ID_OPERATOR = "_complexIdOperator", } -type BasicFilter = Record & { +type BasicFilter = Record & { [InternalSearchFilterOperator.COMPLEX_ID_OPERATOR]?: never } @@ -52,8 +52,8 @@ export interface SearchFilters { // allows just fuzzy to be or - all the fuzzy/like parameters fuzzyOr?: boolean onEmptyFilter?: EmptyFilterOption - [SearchFilterOperator.STRING]?: BasicFilter - [SearchFilterOperator.FUZZY]?: BasicFilter + [SearchFilterOperator.STRING]?: BasicFilter + [SearchFilterOperator.FUZZY]?: BasicFilter [SearchFilterOperator.RANGE]?: RangeFilter [SearchFilterOperator.EQUAL]?: BasicFilter [SearchFilterOperator.NOT_EQUAL]?: BasicFilter