-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hub-common): hubSearchEvents switch to new POST events search route
affects: @esri/hub-common
- Loading branch information
1 parent
eab454b
commit fa81971
Showing
7 changed files
with
216 additions
and
117 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/common/src/search/_internal/hubEventsHelpers/getUniquePredicateValuesByKey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { unique } from "../../../util"; | ||
import { IFilter } from "../../types/IHubCatalog"; | ||
|
||
export const getUniquePredicateValuesByKey = <T>( | ||
filters: IFilter[], | ||
predicateKey: string | ||
): T[] => { | ||
const toPredicateValuesByKey = (a1: T[], filter: IFilter): T[] => | ||
filter.predicates.reduce<T[]>( | ||
(a2, predicate) => | ||
Object.entries(predicate).reduce( | ||
(a3, [key, val]) => | ||
key === predicateKey | ||
? [...a3, ...(Array.isArray(val) ? val : [val])] | ||
: a3, | ||
a2 | ||
), | ||
a1 | ||
); | ||
return filters.reduce<T[]>(toPredicateValuesByKey, []).filter(unique); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
packages/common/src/search/_internal/hubEventsHelpers/processOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.