index.ts (1129B)
1 import type { 2 CLASSES, 3 GRADES, 4 SCHOOL_TIMES, 5 DAY_PERIOD_JA, 6 GRADE_CLASSES, 7 DAY_PERIOD_EN, 8 } from 'common/constant'; 9 import type { ZodType } from 'zod'; 10 11 type MaybeReadonly<T> = Readonly<T> | T; 12 13 type ArrayToUnion<T extends MaybeReadonly<Array<unknown>>> = T[number]; 14 15 export type ToZod<T extends Record<string, unknown>> = { 16 [K in keyof T]-?: ZodType<T[K]>; 17 }; 18 19 export type Grade = ArrayToUnion<typeof GRADES>; 20 export type Class = ArrayToUnion<typeof CLASSES>; 21 export type GradeClass = ArrayToUnion<typeof GRADE_CLASSES>; 22 23 export type SchoolTime = ArrayToUnion<typeof SCHOOL_TIMES>; 24 export type SchoolPeriod = `period${SchoolTime}`; 25 26 export type DayPeriodEn = ArrayToUnion<typeof DAY_PERIOD_EN>; 27 export type DayPeriodJa = ArrayToUnion<typeof DAY_PERIOD_JA>; 28 29 export type Course = { 30 name?: string; 31 shortName: string; 32 room?: string; 33 instructorID?: string; 34 note?: string; 35 }; 36 37 export type ClassStandardTimetable = Record<DayPeriodJa, Course[]>; 38 39 export type DaySchedule = Partial< 40 Record<SchoolPeriod, DayPeriodJa> & { event: string } 41 >; 42 43 export type DaySchedulesByGrade = Partial<Record<`grade${Grade}`, DaySchedule>>;