From dad91020445712eb7963d8a6eb3ea433f500409e Mon Sep 17 00:00:00 2001 From: Ali Nawaz Date: Thu, 23 Jul 2026 22:34:47 +0500 Subject: [PATCH 1/3] Add department 21T (Theater Arts) to DEPARTMENTS Add the 21T -> Theater Arts mapping so the department facet label renders for the new department. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01AWziwfKikfpbH3DpfZUABM --- src/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/constants.ts b/src/constants.ts index ab1035af..d9aee04d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -22,6 +22,7 @@ export const DEPARTMENTS = { "21H": "History", "21L": "Literature", "21M": "Music and Theater Arts", + "21T": "Theater Arts", 22: "Nuclear Science and Engineering", 24: "Linguistics and Philosophy", CC: "Concourse", From 7439b49fb8e7c787811fc90ca445e979ba439cd1 Mon Sep 17 00:00:00 2001 From: Ali Nawaz Date: Fri, 31 Jul 2026 15:42:59 +0500 Subject: [PATCH 2/3] Temporarily allow the 21T (Theater Arts) department facet The department validator checks against DepartmentEnum from the published @mitodl/mit-learn-api-axios, which does not include 21T yet (the mit-learn release that publishes it is blocked on this package - a circular dependency). Allow 21T via PATCHED_DEPARTMENT_VALUES, cast to the expected validator type. A cast is used rather than @ts-expect-error: a suppressed error inside this object literal disables TypeScript's excess-property check and would break the existing resource_category directive. Revert once mit-learn-api-axios is published with the 21T department. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Ktaufxca3bmtQ3L4qVwmsU --- src/hooks/validation.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hooks/validation.ts b/src/hooks/validation.ts index bc01be79..9820f7cc 100644 --- a/src/hooks/validation.ts +++ b/src/hooks/validation.ts @@ -45,9 +45,18 @@ type QueryParamValidators = { [k in keyof Required]: (v: string[]) => ReqParams[k] } +const PATCHED_DEPARTMENT_VALUES = [ + ...Object.values(DepartmentEnum), + "21T" +] as const + const resourceSearchValidators: QueryParamValidators = { resource_type: withinEnum(Object.values(ResourceTypeEnum)), - department: withinEnum(Object.values(DepartmentEnum)), + // "21T" (Theater Arts) isn't in the published mit-learn-api-axios DepartmentEnum yet, + // so cast to the expected validator type. Remove once the openapi release ships. + department: withinEnum( + Object.values(PATCHED_DEPARTMENT_VALUES) + ) as QueryParamValidators["department"], level: withinEnum(Object.values(LevelEnum)), platform: withinEnum(Object.values(PlatformEnum)), offered_by: withinEnum(Object.values(OfferedByEnum)), From f75060db9010d3ab108bfb9968382bdca3bef514 Mon Sep 17 00:00:00 2001 From: Ali Nawaz Date: Fri, 31 Jul 2026 16:52:50 +0500 Subject: [PATCH 3/3] Move the 21T cast onto PATCHED_DEPARTMENT_VALUES The per-line cast made the department validator a multi-line value, which broke key-spacing alignment (eslint) and fmt:check. Cast the const to the DepartmentEnum value type instead, so the department entry stays a normal single-line validator and passes lint / fmt:check / build. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Ktaufxca3bmtQ3L4qVwmsU --- src/hooks/validation.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hooks/validation.ts b/src/hooks/validation.ts index 9820f7cc..29a9d4fa 100644 --- a/src/hooks/validation.ts +++ b/src/hooks/validation.ts @@ -45,18 +45,16 @@ type QueryParamValidators = { [k in keyof Required]: (v: string[]) => ReqParams[k] } +// "21T" (Theater Arts) isn't in the published mit-learn-api-axios DepartmentEnum yet, +// so it's added here and cast to the enum value type. Remove once the openapi release ships. const PATCHED_DEPARTMENT_VALUES = [ ...Object.values(DepartmentEnum), "21T" -] as const +] as (typeof DepartmentEnum)[keyof typeof DepartmentEnum][] const resourceSearchValidators: QueryParamValidators = { resource_type: withinEnum(Object.values(ResourceTypeEnum)), - // "21T" (Theater Arts) isn't in the published mit-learn-api-axios DepartmentEnum yet, - // so cast to the expected validator type. Remove once the openapi release ships. - department: withinEnum( - Object.values(PATCHED_DEPARTMENT_VALUES) - ) as QueryParamValidators["department"], + department: withinEnum(Object.values(PATCHED_DEPARTMENT_VALUES)), level: withinEnum(Object.values(LevelEnum)), platform: withinEnum(Object.values(PlatformEnum)), offered_by: withinEnum(Object.values(OfferedByEnum)),