Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to node 22 #44

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.10.0
22.11.0
1 change: 0 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"devDependencies": {
"@packages/key-types": "workspace:*",
"@types/node": "20.8.3",
"wrangler": "3.85.0"
}
}
11 changes: 6 additions & 5 deletions apps/api/src/services/enrollment-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class EnrollmentHistoryService {
const enrollmentRows = await this.db
.select()
.from(websocSectionEnrollment)
.where(inArray(websocSectionEnrollment.sectionId, Array.from(transformedSectionRows.keys())))
.where(inArray(websocSectionEnrollment.sectionId, transformedSectionRows.keys().toArray()))
.orderBy(websocSectionEnrollment.createdAt);
for (const row of enrollmentRows) {
const section = transformedSectionRows.get(row.sectionId);
Expand All @@ -159,12 +159,13 @@ export class EnrollmentHistoryService {
section.statusHistory.push(row.status ?? "");
}
}
return Array.from(transformedSectionRows.values()).map(
({ instructors, meetings, ...rest }) => ({
return transformedSectionRows
.values()
.map(({ instructors, meetings, ...rest }) => ({
instructors: Array.from(instructors),
meetings: meetings.map(({ bldg, ...rest }) => ({ bldg: Array.from(bldg), ...rest })),
...rest,
}),
);
}))
.toArray();
}
}
6 changes: 3 additions & 3 deletions apps/api/src/services/grades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class GradesService {
});
}, new Map<string, z.infer<typeof rawGradeSchema>>()),
);
return Array.from(data.values());
return data.values().toArray();
}

async getGradesOptions(input: GradesServiceInput) {
Expand Down Expand Up @@ -298,9 +298,9 @@ export class GradesService {
averageGPA: avg(websocSectionGrade.averageGPA).mapWith(Number),
})
.from(websocSectionGrade)
.where(inArray(websocSectionGrade.sectionId, Array.from(sectionMapping.keys())));
.where(inArray(websocSectionGrade.sectionId, sectionMapping.keys().toArray()));
return {
sectionList: Array.from(sectionMapping.values()),
sectionList: sectionMapping.values().toArray(),
gradeDistribution,
};
}
Expand Down
20 changes: 14 additions & 6 deletions apps/api/src/services/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ const INSTRUCTORS_WEIGHTS = sql`(
)`;

function splitAtLastNumber(s: string): string {
const i = Array.from(s.matchAll(/\d+/g))
const i = s
.matchAll(/\d+/g)
.map((x) => x.index)
.toArray()
.slice(-1)[0];
return i === undefined ? s : `${s.slice(0, i)} ${s.slice(i)}`;
}
Expand All @@ -58,7 +60,7 @@ export class SearchService {

private async courseMappingFromResults(results: Map<string, number>) {
return await this.coursesService
.batchGetCourses(Array.from(results.keys()))
.batchGetCourses(results.keys().toArray())
.then((courses) =>
courses.reduce(
(acc, course) => acc.set(course.id, course),
Expand All @@ -69,7 +71,7 @@ export class SearchService {

private async instructorMappingFromResults(results: Map<string, number>) {
return await this.instructorsService
.batchGetInstructors(Array.from(results.keys()))
.batchGetInstructors(results.keys().toArray())
.then((instructors) =>
instructors.reduce(
(acc, instructor) => acc.set(instructor.ucinetid, instructor),
Expand All @@ -96,12 +98,14 @@ export class SearchService {
const courses = await this.courseMappingFromResults(results);
return {
count: results.size,
results: Array.from(results.entries())
results: results
.entries()
.map(([key, rank]) => ({
type: "course" as const,
result: getFromMapOrThrow(courses, key),
rank,
}))
.toArray()
.slice(input.skip, input.skip + input.take),
};
}
Expand All @@ -126,12 +130,14 @@ export class SearchService {
const instructors = await this.instructorMappingFromResults(results);
return {
count: results.size,
results: Array.from(results.entries())
results: results
.entries()
.map(([key, rank]) => ({
type: "instructor" as const,
result: getFromMapOrThrow(instructors, key),
rank,
}))
.toArray()
.slice(input.skip, input.skip + input.take),
};
}
Expand Down Expand Up @@ -166,7 +172,8 @@ export class SearchService {
const instructors = await this.instructorMappingFromResults(results);
return {
count: results.size,
results: Array.from(results.entries())
results: results
.entries()
.map(([key, rank]) =>
courses.has(key)
? {
Expand All @@ -182,6 +189,7 @@ export class SearchService {
rank,
},
)
.toArray()
.toSorted((a, b) => {
const rankDiff = b.rank - a.rank;
return Math.abs(rankDiff) < Number.EPSILON
Expand Down
25 changes: 15 additions & 10 deletions apps/api/src/services/websoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,19 @@ function transformRows(rows: Row[]): z.infer<typeof websocResponseSchema> {
schools.get(department.schoolId)?.departments.push(department);
}
return {
schools: Array.from(schools.values()).map((school) => ({
...school,
departments: school.departments.map((department) => ({
...department,
courses: department.courses.map((course) => ({
...course,
sections: course.sections.map(transformSection),
schools: schools
.values()
.map((school) => ({
...school,
departments: school.departments.map((department) => ({
...department,
courses: department.courses.map((course) => ({
...course,
sections: course.sections.map(transformSection),
})),
})),
})),
})),
}))
.toArray(),
};
}

Expand Down Expand Up @@ -415,7 +418,9 @@ export class WebsocService {
.select({ year: websocSchool.year, quarter: websocSchool.quarter })
.from(websocSchool)
.then((rows) =>
Array.from(new Map(rows.map((row) => [`${row.year} ${row.quarter}`, row])).values())
new Map(rows.map((row) => [`${row.year} ${row.quarter}`, row]))
.values()
.toArray()
.sort(({ year: y1, quarter: q1 }, { year: y2, quarter: q2 }) =>
y1 === y2
? termOrder[q1] - termOrder[q2]
Expand Down
1 change: 0 additions & 1 deletion apps/data-pipeline/calendar-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
},
"devDependencies": {
"@types/json-diff": "1.0.3",
"@types/node": "20.8.3",
"@types/readline-sync": "1.4.8"
}
}
1 change: 0 additions & 1 deletion apps/data-pipeline/course-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
},
"devDependencies": {
"@types/json-diff": "1.0.3",
"@types/node": "20.8.3",
"@types/readline-sync": "1.4.8"
}
}
5 changes: 1 addition & 4 deletions apps/data-pipeline/course-scraper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,7 @@ async function main() {
"./prerequisites.json",
JSON.stringify(
Object.fromEntries(
Array.from(prerequisites.entries()).map(([k, v]) => [
k,
Object.fromEntries(Array.from(v.entries())),
]),
prerequisites.entries().map(([k, v]) => [k, Object.fromEntries(v.entries())]),
),
),
);
Expand Down
4 changes: 1 addition & 3 deletions apps/data-pipeline/degreeworks-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
"cross-fetch": "4.0.0",
"jwt-decode": "4.0.0"
},
"devDependencies": {
"@types/node": "20.8.3"
}
"devDependencies": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export class AuditParser {
lexOrd = new Intl.Collator().compare;

parseSpecs = (block: Block): string[] =>
Array.from(JSON.stringify(block).matchAll(AuditParser.specOrOtherMatcher))
JSON.stringify(block)
.matchAll(AuditParser.specOrOtherMatcher)
.map((x) => JSON.parse(`{${x[0]}}`).value)
.toArray()
.sort();

flattenIfStmt(ruleArray: Rule[]): Rule[] {
Expand Down
44 changes: 24 additions & 20 deletions apps/data-pipeline/degreeworks-scraper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,36 @@ async function main() {
parsedMinorPrograms,
parsedUgradPrograms,
} = scraper.get();
const degreeData = Array.from(degreesAwarded.entries()).map(([id, name]) => ({
id,
name,
division: (id.startsWith("B") ? "Undergraduate" : "Graduate") as Division,
}));
const majorData = [
...Array.from(parsedUgradPrograms.values()),
...Array.from(parsedGradPrograms.values()),
].map(({ name, degreeType, code, requirements }) => ({
id: `${degreeType}-${code}`,
degreeId: degreeType ?? "",
code,
name,
requirements,
}));
const minorData = Array.from(parsedMinorPrograms.values()).map(
({ name, code: id, requirements }) => ({ id, name, requirements }),
);
const specData = Array.from(parsedSpecializations.values()).map(
const degreeData = degreesAwarded
.entries()
.map(([id, name]) => ({
id,
name,
division: (id.startsWith("B") ? "Undergraduate" : "Graduate") as Division,
}))
.toArray();
const majorData = [...parsedUgradPrograms.values(), ...parsedGradPrograms.values()].map(
({ name, degreeType, code, requirements }) => ({
id: `${degreeType}-${code}`,
majorId: `${degreeType}-${code.slice(0, code.length - 1)}`,
degreeId: degreeType ?? "",
code,
name,
requirements,
}),
);
const minorData = parsedMinorPrograms
.values()
.map(({ name, code: id, requirements }) => ({ id, name, requirements }))
.toArray();
const specData = parsedSpecializations
.values()
.map(({ name, degreeType, code, requirements }) => ({
id: `${degreeType}-${code}`,
majorId: `${degreeType}-${code.slice(0, code.length - 1)}`,
name,
requirements,
}))
.toArray();
await db.transaction(async (tx) => {
await tx
.insert(degree)
Expand Down
4 changes: 1 addition & 3 deletions apps/data-pipeline/grades-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@
"@packages/stdlib": "workspace:*",
"node-xlsx": "0.24.0"
},
"devDependencies": {
"@types/node": "20.8.3"
}
"devDependencies": {}
}
1 change: 0 additions & 1 deletion apps/data-pipeline/instructor-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"devDependencies": {
"@types/he": "1.2.3",
"@types/json-diff": "1.0.3",
"@types/node": "20.8.3",
"@types/readline-sync": "1.4.8"
}
}
2 changes: 1 addition & 1 deletion apps/data-pipeline/instructor-scraper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ async function main() {
await db.transaction(async (tx) => {
await tx
.insert(instructor)
.values(Array.from(ucinetidToInstructorObject.values()))
.values(ucinetidToInstructorObject.values().toArray())
.onConflictDoUpdate({
target: instructor.ucinetid,
set: conflictUpdateSetAllCols(instructor),
Expand Down
1 change: 0 additions & 1 deletion apps/data-pipeline/larc-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"cross-fetch": "4.0.0"
},
"devDependencies": {
"@types/node": "20.8.3",
"wrangler": "3.85.0"
}
}
1 change: 0 additions & 1 deletion apps/data-pipeline/study-location-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"cross-fetch": "4.0.0"
},
"devDependencies": {
"@types/node": "20.8.3",
"domhandler": "5.0.3",
"wrangler": "3.85.0"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/data-pipeline/study-location-scraper/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async function scrapeStudyLocations(): Promise<StudyLocation[]> {
}
locations.push({
...studyLocation,
rooms: Array.from(studyLocation.rooms.values()),
rooms: studyLocation.rooms.values().toArray(),
});
}
return locations;
Expand Down
1 change: 0 additions & 1 deletion apps/data-pipeline/websoc-scraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"cross-fetch": "4.0.0"
},
"devDependencies": {
"@types/node": "20.8.3",
"wrangler": "3.85.0"
}
}
18 changes: 12 additions & 6 deletions apps/data-pipeline/websoc-scraper/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,16 @@ const doDepartmentUpsert = async (
await tx.delete(websocSectionToInstructor).where(
inArray(
websocSectionToInstructor.sectionId,
Array.from(sectionsToInstructors.keys())
sectionsToInstructors
.keys()
.map((key) => sections.get(key))
.filter(notNull),
.filter(notNull)
.toArray(),
),
);
const instructorAssociationsToInsert = Array.from(sectionsToInstructors.entries())
const instructorAssociationsToInsert = sectionsToInstructors
.entries()
.toArray()
.flatMap(([k, names]) =>
names.map((instructorName) => {
const sectionId = sections.get(k);
Expand All @@ -554,7 +558,7 @@ const doDepartmentUpsert = async (
}
await tx
.delete(websocSectionMeeting)
.where(inArray(websocSectionMeeting.sectionId, Array.from(sections.values())));
.where(inArray(websocSectionMeeting.sectionId, sections.values().toArray()));
const meetings = await tx
.insert(websocSectionMeeting)
.values(
Expand Down Expand Up @@ -637,7 +641,9 @@ const doDepartmentUpsert = async (
await tx
.insert(websocSectionMeetingToLocation)
.values(
Array.from(meetingsToLocations.entries())
meetingsToLocations
.entries()
.toArray()
.map(([meetingId, v]) => {
const locationId = locations.get(v);
return locationId ? { meetingId, locationId } : undefined;
Expand Down Expand Up @@ -698,7 +704,7 @@ function normalizeResponse(json: WebsocResponse): WebsocResponse {
courseMapping.get(courseKey)?.sections.push(...course.sections);
}
}
dept.courses = Array.from(courseMapping.values());
dept.courses = courseMapping.values().toArray();
}
}
return json;
Expand Down
Loading