-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
147 lines (131 loc) · 3.16 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
export const campuses = ["nu", "cps", "law"] as const;
export type Campus = (typeof campuses)[number];
export interface Term {
code: string;
description: string;
}
export interface Subject {
code: string;
description?: string;
}
export interface SubjectWithCourseCount extends Subject {
numCourses: number;
}
export interface Course {
// No term for courses. Terms are only required for sections
subject: string;
number: string;
scheduleType: string;
title: string;
credits: number;
nuPath: NUPath[];
description?: string;
coreqs?: Requisite[];
prereqs?: PrerequisiteItem[];
// This can change during the semester if a section is added
sections: {
term: string;
crn: string; //description: string
}[];
}
export type Requisite = Pick<Course, "subject" | "number">;
export type PrerequisiteItem = "Or" | "And" | "(" | ")" | Requisite | string;
// To be used in combine courses, only containing required data
export type MinimizedCourse = Pick<Course, "subject" | "number">;
export const nuPath = [
"ND",
"EI",
"IC",
"FQ",
"SI",
"AD",
"DD",
"ER",
"WF",
"WD",
"WI",
"EX",
"CE",
] as const;
export type NUPath = (typeof nuPath)[number];
export const nuPathMap: Record<NUPath, string> = {
ND: "Natural/Designed World",
EI: "Creative Express/Innov",
IC: "Interpreting Culture",
FQ: "Formal/Quant Reasoning",
SI: "Societies/Institutions",
AD: "Analyzing/Using Data",
DD: "Difference/Diversity",
ER: "Ethical Reasoning",
WF: "1st Yr Writing",
WD: "Adv Writ Dscpl ",
WI: "Writing Intensive",
EX: "Integration Experience",
CE: "Capstone Experience",
};
export interface SectionInfo {
term: string;
crn: string;
}
// Contains professor and meeting times for a particular section
export interface FacultyMeetingTime extends MeetingTime {
faculty: Professor[];
}
export interface Professor {
name: string;
}
export const daysOfWeek = [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
] as const;
export type DayOfWeek = (typeof daysOfWeek)[number];
export interface MeetingTime {
startTime: string;
endTime: string;
campus: {
code: string;
description: string;
};
building: {
code: string;
description: string;
room: string;
};
online: boolean;
days: DayOfWeek[];
}
export interface Seats {
total: number;
available: number;
waitlist: {
capacity: number;
available: number;
};
}
export interface Section extends SectionInfo {
meetingTimes: FacultyMeetingTime[];
seats: Seats;
}
// Mapping types
export interface TermSubjectCourseMapping {
[subjectCode: string]: { number: string; crns: string[] }[];
}
// Search
type SubjectGroup = { type: "subject"; subjectCode: string };
type SubjectQueryGroup = { type: "subject-query"; subjectCode: string; query: string };
type CourseGroup = { type: "course"; subjectCode: string; courseNumber: string };
type NumberGroup = { type: "number"; courseNumber: string };
type CRNGroup = { type: "crn"; crn: string };
type QueryGroup = { type: "query"; query: string };
export type SearchGroup =
| SubjectGroup
| SubjectQueryGroup
| CourseGroup
| NumberGroup
| CRNGroup
| QueryGroup;