-
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 ro…
…ute (#1787)
- Loading branch information
1 parent
fa51064
commit 8fbb944
Showing
9 changed files
with
293 additions
and
132 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
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,10 @@ | ||
import { unique } from "../../../util"; | ||
import { IFilter } from "../../types/IHubCatalog"; | ||
import { getPredicateValuesByKey } from "./getPredicateValuesByKey"; | ||
|
||
export const getUniquePredicateValuesByKey = <T>( | ||
filters: IFilter[], | ||
predicateKey: string | ||
): T[] => { | ||
return getPredicateValuesByKey<T>(filters, predicateKey).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
22 changes: 22 additions & 0 deletions
22
packages/common/src/search/_internal/hubEventsHelpers/toEnumConverters.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,22 @@ | ||
/** | ||
* Converts a string to an enum value | ||
* | ||
* strings not in the enum will be returned as the original string | ||
*/ | ||
export function toEnum<T>(value: string, enumType: T): T[keyof T] { | ||
return ( | ||
(enumType as any)[value] || | ||
(enumType as any)[value.toUpperCase()] || | ||
(enumType as any)[value.toLowerCase()] || | ||
value | ||
); | ||
} | ||
|
||
/** | ||
* Converts an array of strings to an array of enum values | ||
* | ||
* strings not in the enum will be returned as the original string | ||
*/ | ||
export function toEnums<T>(values: string[], enumType: T): Array<T[keyof T]> { | ||
return values.map((value) => toEnum<T>(value, enumType)); | ||
} |
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.