-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
46 lines (44 loc) · 1.51 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export type CourseLevel = 0 | 1 | 2;
export type GECategory = 'GE-1A' | 'GE-1B' | 'GE-2' | 'GE-3' | 'GE-4' | 'GE-5A' | 'GE-5B' | 'GE-6' | 'GE-7' | 'GE-8';
export type ResultType = 'GE_CATEGORY' | 'DEPARTMENT' | 'COURSE' | 'INSTRUCTOR';
export interface FilterOptions {
readonly courseLevel?: CourseLevel[];
readonly geList?: GECategory[];
readonly department?: string[];
readonly school?: string[];
}
export interface SearchParams {
readonly query?: string;
readonly numResults?: number;
readonly resultType?: ResultType;
readonly filterOptions?: FilterOptions;
}
export interface SearchResult {
readonly type: ResultType;
readonly name: string;
readonly metadata?: any;
}
export interface CourseMetadata {
readonly department: string;
readonly number: string;
readonly geList: GECategory[];
readonly courseLevel: CourseLevel;
readonly school: string;
}
export interface InstructorMetadata {
readonly ucinetid: string;
readonly school: string[];
readonly department: string;
}
export interface CourseSearchResult extends SearchResult {
readonly metadata: CourseMetadata;
}
export interface InstructorSearchResult extends SearchResult {
readonly metadata: InstructorMetadata;
}
export function isCourseSearchResult(sr: SearchResult): sr is CourseSearchResult {
return typeof sr?.metadata?.number === 'string';
}
export function isInstructorSearchResult(sr: SearchResult): sr is InstructorSearchResult {
return typeof sr?.metadata?.ucinetid === 'string';
}