@@ -19,7 +19,11 @@ type Module =
1919 | "springVacation" ;
2020type ModuleTimeTable = Record < Module , readonly TimeTable [ ] > ;
2121
22- type Hierarchy = readonly { value : string | null ; text : string } [ ] ;
22+ type Requisite = {
23+ id : string ;
24+ name : string ;
25+ hasLower : boolean ;
26+ } | null ;
2327
2428type InstructionalType = {
2529 text : string ;
@@ -33,56 +37,67 @@ type InstructionalType = {
3337} ;
3438
3539type MergedSubject = {
36- code : string ;
37- name : string ;
40+ code : string ; // 科目番号
41+ name : string ; // 科目名
42+ syllabusLatestLink : string | null ; // シラバス最新リンク
3843 instructionalType : {
3944 value : InstructionalType | null ;
4045 kdbRaw : string | null ;
41- } ;
46+ } ; // 授業方法
4247 credits : {
4348 value :
4449 | {
45- type : "number " ;
50+ type : "normal " ;
4651 value : number ;
4752 }
4853 | {
4954 type : "none" ;
5055 }
56+ | {
57+ type : "unknown" ;
58+ }
5159 | null ;
5260 kdbRaw : string | null ;
53- } ;
61+ } ; // 単位数
5462 year : {
55- value : number [ ] ;
63+ value :
64+ | {
65+ type : "normal" ;
66+ value : readonly number [ ] ;
67+ }
68+ | {
69+ type : "unknown" ;
70+ } ;
5671 kdbRaw : string | null ;
5772 twinsRaw : string | null ;
58- } ;
73+ } ; // 標準履修年次
5974 terms : {
60- term : Terms | null ;
61- module : string | null ;
62- weekdayAndPeriod : string | null ;
63- moduleTimeTable : ModuleTimeTable | null ;
75+ term : Terms | null ; // 学期
76+ module : string | null ; // 実施学期
77+ weekdayAndPeriod : string | null ; // 曜時限
78+ moduleTimeTable : ModuleTimeTable | null ; // モジュール時間割
6479
6580 twinsRaw : {
6681 term : string ;
6782 module : string ;
6883 } | null ;
6984 } ;
70- classroom : null ;
85+ classroom : null ; // 教室
7186 instructor : {
7287 value : string [ ] ;
7388
7489 kdbRaw : string | null ;
7590 twinsRaw : string | null ;
76- } ;
77- overview : string | null ;
78- remarks : string | null ;
79- auditor : string | null ;
80- conditionsForAuditors : string | null ;
91+ } ; // 担当教員
92+ overview : string | null ; // 授業概要
93+ remarks : string | null ; // 備考
94+ auditor : string | null ; // 科目等履修生申請可否
95+ conditionsForAuditors : string | null ; // 申請条件
8196 exchangeStudent : string | null ;
82- conditionsForExchangeStudents : string | null ;
83- JaEnCourseName : string | null ;
84- parentNumber : string | null ;
85- parentCourseName : string | null ;
97+ conditionsForExchangeStudents : string | null ; // 申請条件
98+ JaEnCourseName : string | null ; // 英語(日本語)科目名
99+ parentNumber : string | null ; // 科目コード
100+ parentCourseName : string | null ; // 要件科目名
86101
87102 affiliation : {
88103 name : string | null ;
@@ -94,9 +109,7 @@ type MergedSubject = {
94109 } | null ;
95110 } ;
96111
97- kdbDataUpdateDate : string | null ;
98-
99- hierarchy : Hierarchy [ ] ;
112+ requisite : Requisite [ ] ;
100113} ;
101114
102115const TermsSchema = z . union ( [
@@ -139,9 +152,13 @@ const ModuleTimeTableSchema = z.object({
139152 fallC : z . array ( TimeTableSchema ) ,
140153 springVacation : z . array ( TimeTableSchema ) ,
141154} ) ;
142- const HierarchySchema = z . array (
143- z . object ( { value : z . string ( ) . nullable ( ) , text : z . string ( ) } ) ,
144- ) ;
155+ const RequisiteSchema = z
156+ . object ( {
157+ id : z . string ( ) ,
158+ name : z . string ( ) ,
159+ hasLower : z . boolean ( ) ,
160+ } )
161+ . nullable ( ) ;
145162const InstructionalTypeSchema = z . object ( {
146163 text : z . string ( ) ,
147164 flags : z . object ( {
@@ -155,6 +172,7 @@ const InstructionalTypeSchema = z.object({
155172const MergedSubjectSchema = z . object ( {
156173 code : z . string ( ) ,
157174 name : z . string ( ) ,
175+ syllabusLatestLink : z . string ( ) . nullable ( ) ,
158176 instructionalType : z . object ( {
159177 value : InstructionalTypeSchema . nullable ( ) ,
160178 kdbRaw : z . string ( ) . nullable ( ) ,
@@ -163,16 +181,23 @@ const MergedSubjectSchema = z.object({
163181 value : z
164182 . union ( [
165183 z . object ( {
166- type : z . literal ( "number " ) ,
184+ type : z . literal ( "normal " ) ,
167185 value : z . number ( ) ,
168186 } ) ,
169187 z . object ( { type : z . literal ( "none" ) } ) ,
188+ z . object ( { type : z . literal ( "unknown" ) } ) ,
170189 ] )
171190 . nullable ( ) ,
172191 kdbRaw : z . string ( ) . nullable ( ) ,
173192 } ) ,
174193 year : z . object ( {
175- value : z . array ( z . number ( ) ) ,
194+ value : z . union ( [
195+ z . object ( {
196+ type : z . literal ( "normal" ) ,
197+ value : z . array ( z . number ( ) ) ,
198+ } ) ,
199+ z . object ( { type : z . literal ( "unknown" ) } ) ,
200+ ] ) ,
176201 kdbRaw : z . string ( ) . nullable ( ) ,
177202 twinsRaw : z . string ( ) . nullable ( ) ,
178203 } ) ,
@@ -220,7 +245,7 @@ const MergedSubjectSchema = z.object({
220245
221246 kdbDataUpdateDate : z . string ( ) . nullable ( ) ,
222247
223- hierarchy : z . array ( HierarchySchema ) ,
248+ requisite : z . array ( RequisiteSchema ) ,
224249} ) ;
225250
226251const SubjectsSchema = z . array ( MergedSubjectSchema ) ;
@@ -229,8 +254,8 @@ const parsedSubjects: readonly MergedSubject[] = (() => {
229254 try {
230255 return SubjectsSchema . parse ( subjectsMergedJson ) ;
231256 } catch ( error ) {
232- console . error ( "Failed to parse subjects:" , JSON . stringify ( error , null , 4 ) ) ;
233- throw new Error ( "Failed to parse subjects" ) ;
257+ // console.error("Failed to parse subjects:", JSON.stringify(error, null, 4));
258+ throw new Error ( "Failed to parse subjects" , { cause : error } ) ;
234259 }
235260} ) ( ) ;
236261
0 commit comments