|
| 1 | +import { t } from "elysia"; |
| 2 | + |
| 3 | +// Stream って何? 教えて有識者 |
| 4 | +// Course.importance に使われているよう? |
| 5 | +export type Stream = typeof Stream.static; |
| 6 | +export const Stream = t.UnionEnum(["s1", "s2", "s3", "l1", "l2", "l3"]); |
| 7 | + |
| 8 | +/** |
| 9 | + * 授業コード |
| 10 | + * 例: 30003 |
| 11 | + */ |
| 12 | +export type CourseCode = typeof CourseCode.static; |
| 13 | +export const CourseCode = t.RegExp("^\\d{5}$"); |
| 14 | + |
| 15 | +/** |
| 16 | + * 共通科目コード |
| 17 | + * 例: |
| 18 | + * - XAB-CD1001L2 |
| 19 | + * - CAS-FC1871L1 |
| 20 | + * - CAS-GC1L37S4 |
| 21 | + * - CASPG1F40L3 // 絶対入力ミスだが、データにあるので対応しなければならない |
| 22 | + * 仕様: https://www.u-tokyo.ac.jp/ja/students/classes/course-numbering.html |
| 23 | + * 本当は CommonSubjectCode になるはずだが、公式が勝手に CommonCourseCode と読んでいる |
| 24 | + */ |
| 25 | +export type CommonCourseCode = typeof CommonCourseCode.static; |
| 26 | +export const CommonCourseCode = t.RegExp( |
| 27 | + ` |
| 28 | + ^[CFG] ${/* [1] 課程コード */ ""} |
| 29 | + (?:LA|ME|EN|LE|SC|AG|EC|AS|ED|PH|GL) ${/* [2] 開講学部・研究科(教育部)コード */ ""} |
| 30 | + -? |
| 31 | + [A-Z]{2} ${/* [3] 開講学科・専攻等コード */ ""} |
| 32 | + [1-7] ${/* [4] レベルコード */ ""} |
| 33 | + [0-9a-zA-Z]{3} ${/* [5] 整理番号 */ ""} |
| 34 | + [LSEPTZ] ${/* [6] 授業形態コード */ ""} |
| 35 | + [123459] ${/* [7] 使用言語コード */ ""} |
| 36 | + $`.replaceAll(/\s/g, ""), |
| 37 | +); |
| 38 | + |
| 39 | +/** |
| 40 | + * 曜日。 |
| 41 | + */ |
| 42 | +export type Day = typeof Day.static; |
| 43 | +export const Day = t.UnionEnum(["mon", "tue", "wed", "thu", "fri", "sat"]); |
| 44 | + |
| 45 | +export type Period = typeof Period.static; |
| 46 | +export const Period = t.UnionEnum([1, 2, 3, 4, 5, 6]); |
| 47 | + |
| 48 | +/** |
| 49 | + * 曜限。 |
| 50 | + */ |
| 51 | +export type DayPeriod = typeof DayPeriod.static; |
| 52 | +export const DayPeriod = t.Object({ |
| 53 | + day: Day, |
| 54 | + period: Period, |
| 55 | +}); |
| 56 | + |
| 57 | +/** |
| 58 | + * セメスターまたはターム。 |
| 59 | + */ |
| 60 | +export type Semester = typeof Semester.static; |
| 61 | +export const Semester = t.UnionEnum(["S", "S1", "S2", "A", "A1", "A2"]); |
| 62 | + |
| 63 | +// 使われていない。 |
| 64 | +/** |
| 65 | + * 評価方法。 |
| 66 | + */ |
| 67 | +export type Evaluation = typeof Evaluation.static; |
| 68 | +export const Evaluation = t.UnionEnum(["試験", "レポート", "出席", "平常"]); |
| 69 | + |
| 70 | +/** |
| 71 | + * 単位の種類。 |
| 72 | + */ |
| 73 | +export type ClassType = typeof ClassType.static; |
| 74 | +export const ClassType = t.UnionEnum(["基礎", "要求", "主題", "総合", "展開"]); |
| 75 | + |
| 76 | +export type ClassSeries = typeof ClassSeries.static; |
| 77 | +export const ClassSeries = t.UnionEnum([ |
| 78 | + "基礎", |
| 79 | + "要求", |
| 80 | + "主題", |
| 81 | + "展開", |
| 82 | + "総合L", |
| 83 | + "総合A", |
| 84 | + "総合B", |
| 85 | + "総合C", |
| 86 | + "総合D", |
| 87 | + "総合E", |
| 88 | + "総合F", |
| 89 | +]); |
0 commit comments