-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify sort types between query parsing and data transformations
- Loading branch information
1 parent
3599809
commit 5ff954f
Showing
6 changed files
with
32 additions
and
28 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
export const sortingOptions = [ | ||
export type Sort = | ||
"priority" | "priorityAscending" | ||
| "priorityDescending" | ||
| "date" | "dateAscending" | ||
| "dateDescending" | ||
| "order"; | ||
|
||
// This should be kept in sync with the above, not sure how to enforce | ||
// exhaustiveness. | ||
export const sortingVariants: Sort[] = [ | ||
"priority", | ||
"priorityAscending", | ||
"priorityDescending", | ||
"date", | ||
"dateAscending", | ||
"dateDescending", | ||
"priority", | ||
"order", | ||
]; | ||
|
||
export type SortingOption = typeof sortingOptions[number]; | ||
|
||
export function isSortingOption(value: string): value is SortingOption; | ||
export function isSortingOption(value: string): value is Sort; | ||
export function isSortingOption(value: any) { | ||
return sortingOptions.includes(value); | ||
return sortingVariants.includes(value); | ||
} | ||
|
||
export type Query = { | ||
name: string; | ||
filter: string; | ||
autorefresh?: number; | ||
sorting?: SortingOption[]; | ||
sorting?: Sort[]; | ||
group: boolean; | ||
}; |
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