Skip to content
Draft
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
4 changes: 2 additions & 2 deletions apps/api/src/schema/ap-exams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "@hono/zod-openapi";
import type { APCoursesGrantedTree } from "@packages/db/schema";

import { geCategories } from "./lib";
import { inputGECategories } from "./lib";

export const apExamsQuerySchema = z.object({
fullName: z.string().optional().openapi({
Expand Down Expand Up @@ -55,7 +55,7 @@ export const apExamsRewardSchema = z.object({
description:
"The number of units granted as generic elective credit (but not from any course) for this reward",
}),
geGranted: z.record(z.enum(geCategories), z.number().int().nonnegative()).openapi({
geGranted: z.record(z.enum(inputGECategories), z.number().int().nonnegative()).openapi({
description:
"Courses in GE categories granted directly by this reward and not through any course",
}),
Expand Down
14 changes: 1 addition & 13 deletions apps/api/src/schema/courses.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
import { z } from "@hono/zod-openapi";
import type { PrerequisiteTree } from "@packages/db/schema";
import { instructorPreviewSchema } from "./instructors";
import { inputGECategories } from "./lib";

export const inputCourseLevels = ["LowerDiv", "UpperDiv", "Graduate"] as const;

export const inputCourseLevelSchema = z.enum(inputCourseLevels, {
message: "If provided, 'courseLevel' must be 'LowerDiv', 'UpperDiv', or 'Graduate'",
});

export const inputGECategories = [
"GE-1A",
"GE-1B",
"GE-2",
"GE-3",
"GE-4",
"GE-5A",
"GE-5B",
"GE-6",
"GE-7",
"GE-8",
] as const;

export const outputCourseLevels = [
"Lower Division (1-99)",
"Upper Division (100-199)",
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/schema/grades.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "@hono/zod-openapi";
import { courseLevels, terms } from "@packages/db/schema";
import { geCategories, yearSchema } from "./lib";
import { inputGECategories, yearSchema } from "./lib";

export const gradesQuerySchema = z.object({
year: yearSchema.optional(),
Expand Down Expand Up @@ -28,7 +28,7 @@ export const gradesQuerySchema = z.object({
.optional()
.transform((x) => (x === "ANY" ? undefined : x)),
ge: z
.enum(geCategories)
.enum(inputGECategories)
.optional()
.or(z.literal("ANY"))
.transform((x) => (x === "ANY" ? undefined : x)),
Expand All @@ -49,7 +49,7 @@ export const rawGradeSchema = z.object({
department: z.string(),
courseNumber: z.string(),
courseNumeric: z.number(),
geCategories: z.enum(geCategories).array(),
geCategories: z.enum(inputGECategories).array(),
instructors: z.string().array(),
gradeACount: z.number(),
gradeBCount: z.number(),
Expand Down Expand Up @@ -78,7 +78,7 @@ export const aggregateGradesSchema = z.object({
department: z.string(),
courseNumber: z.string(),
courseNumeric: z.number(),
geCategories: z.enum(geCategories).array(),
geCategories: z.enum(inputGECategories).array(),
instructors: z.string().array(),
})
.array(),
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export * from "./search";
export * from "./study-rooms";
export * from "./websoc";
export * from "./week";
export { geCategories } from "./lib";
export { inputGECategories } from "./lib";
2 changes: 1 addition & 1 deletion apps/api/src/schema/lib/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const courseNumberSchema = z.string().transform(courseNumberTransform).op
example: "46,6B,51-53",
});

export const geCategories = [
export const inputGECategories = [
"GE-1A",
"GE-1B",
"GE-2",
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/schema/search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "@hono/zod-openapi";
import { courseSchema, inputCourseLevelSchema, inputGECategories } from "./courses.ts";
import { courseSchema, inputCourseLevelSchema } from "./courses.ts";
import { instructorSchema } from "./instructors.ts";
import { inputGECategories } from "./lib";

export const searchQuerySchema = z.object({
query: z.string({ message: "Parameter 'query' is required" }),
Expand Down