@@ -10,9 +10,9 @@ interface ConfigRecord {
1010class Config {
1111 private static instance : Config ;
1212
13- protected ini : Record < string , any > ;
13+ protected ini : ConfigRecord ;
1414
15- constructor ( ini : Record < string , any > ) {
15+ constructor ( ini : ConfigRecord ) {
1616 this . ini = ini ;
1717 }
1818
@@ -37,117 +37,117 @@ class Config {
3737 }
3838
3939 get backendUrl ( ) : string {
40- return this . ini [ "backend_url" ] ?? "http://localhost:9000" ;
40+ return ( this . ini [ "backend_url" ] as string ) ?? "http://localhost:9000" ;
4141 }
4242
4343 get clientUrl ( ) : string {
44- return this . ini [ "client_url" ] ;
44+ return this . ini [ "client_url" ] as string ;
4545 }
4646
4747 get fedoraUsername ( ) : string {
48- return this . ini [ "fedora_username" ] ;
48+ return this . ini [ "fedora_username" ] as string ;
4949 }
5050
5151 get fedoraPassword ( ) : string {
52- return this . ini [ "fedora_password" ] ;
52+ return this . ini [ "fedora_password" ] as string ;
5353 }
5454
5555 get fedoraPidNameSpace ( ) : string {
56- return this . ini [ "fedora_pid_namespace" ] ;
56+ return this . ini [ "fedora_pid_namespace" ] as string ;
5757 }
5858
5959 get ffmpegPath ( ) : string {
60- return this . ini [ "ffmpeg_path" ] ;
60+ return this . ini [ "ffmpeg_path" ] as string ;
6161 }
6262
6363 get fitsCommand ( ) : string {
64- return this . ini [ "fits_command" ] ;
64+ return this . ini [ "fits_command" ] as string ;
6565 }
6666
6767 get sessionKey ( ) : string {
68- return this . ini [ "session_key" ] ?? "vanilla hot cocoa" ;
68+ return ( this . ini [ "session_key" ] as string ) ?? "vanilla hot cocoa" ;
6969 }
7070
7171 get tesseractPath ( ) : string {
72- return this . ini [ "tesseract_path" ] ;
72+ return this . ini [ "tesseract_path" ] as string ;
7373 }
7474
7575 get tesseractAllowedChars ( ) : string {
76- return this . ini [ "tesseract_allowed_characters" ] ;
76+ return this . ini [ "tesseract_allowed_characters" ] as string ;
7777 }
7878
7979 get vufindUrl ( ) : string {
80- return this . ini [ "vufind_url" ] ?? "" ;
80+ return ( this . ini [ "vufind_url" ] as string ) ?? "" ;
8181 }
8282
8383 get pdfDirectory ( ) : string {
84- return this . ini [ "pdf_directory" ] ;
84+ return this . ini [ "pdf_directory" ] as string ;
8585 }
8686
8787 get textcleanerPath ( ) : string {
88- return this . ini [ "textcleaner_path" ] ;
88+ return this . ini [ "textcleaner_path" ] as string ;
8989 }
9090
9191 get textcleanerSwitches ( ) : string {
92- return this . ini [ "textcleaner_switches" ] ;
92+ return this . ini [ "textcleaner_switches" ] as string ;
9393 }
9494
9595 get holdingArea ( ) : string {
96- const holdingArea = this . ini [ "holding_area_path" ] ;
96+ const holdingArea = this . ini [ "holding_area_path" ] as string ;
9797 return holdingArea . endsWith ( "/" ) ? holdingArea : holdingArea + "/" ;
9898 }
9999
100100 get ocrmypdfPath ( ) : string {
101- return this . ini [ "ocrmypdf_path" ] ;
101+ return this . ini [ "ocrmypdf_path" ] as string ;
102102 }
103103
104104 get processedAreaPath ( ) : string {
105- return this . ini [ "processed_area_path" ] ;
105+ return this . ini [ "processed_area_path" ] as string ;
106106 }
107107
108108 get restBaseUrl ( ) : string {
109- return this . ini [ "base_url" ] ;
109+ return this . ini [ "base_url" ] as string ;
110110 }
111111
112112 get javaPath ( ) : string {
113- return this . ini [ "java_path" ] ?? "java" ;
113+ return ( this . ini [ "java_path" ] as string ) ?? "java" ;
114114 }
115115
116- get tikaConfigFile ( ) : string {
117- return this . ini [ "tika_config_file" ] ?? null ;
116+ get tikaConfigFile ( ) : string | null {
117+ return ( this . ini [ "tika_config_file" ] as string ) ?? null ;
118118 }
119119
120120 get tikaPath ( ) : string {
121- return this . ini [ "tika_path" ] ;
121+ return this . ini [ "tika_path" ] as string ;
122122 }
123123
124124 get solrCore ( ) : string {
125- return this . ini [ "solr_core" ] ?? "biblio" ;
125+ return ( this . ini [ "solr_core" ] as string ) ?? "biblio" ;
126126 }
127127
128128 get solrUrl ( ) : string {
129- return this . ini [ "solr_url" ] ?? "http://localhost:8983/solr" ;
129+ return ( this . ini [ "solr_url" ] as string ) ?? "http://localhost:8983/solr" ;
130130 }
131131
132132 get solrDocumentCacheDir ( ) : boolean | string {
133- return this . ini [ "solr_document_cache_dir" ] ?? false ;
133+ return ( this . ini [ "solr_document_cache_dir" ] as string ) ?? false ;
134134 }
135135
136136 get allowedOrigins ( ) : string [ ] {
137- return this . ini [ "allowed_origins" ] ?? [ ] ;
137+ return ( this . ini [ "allowed_origins" ] as string [ ] ) ?? [ ] ;
138138 }
139139
140140 get pidNamespace ( ) : string {
141- return this . ini [ "fedora_pid_namespace" ] ?? "vudl" ;
141+ return ( this . ini [ "fedora_pid_namespace" ] as string ) ?? "vudl" ;
142142 }
143143
144144 get initialPidValue ( ) : number {
145- return parseInt ( this . ini [ "fedora_initial_pid" ] ?? "0" ) ;
145+ return parseInt ( ( this . ini [ "fedora_initial_pid" ] as string ) ?? "0" ) ;
146146 }
147147
148148 get dataModels ( ) : Record < string , string > {
149149 return (
150- this . ini [ "data_models" ] ?? {
150+ ( this . ini [ "data_models" ] as Record < string , string > ) ?? {
151151 Image : "vudl-system:ImageData" ,
152152 PDF : "vudl-system:PDFData" ,
153153 DOC : "vudl-system:DOCData" ,
@@ -161,7 +161,7 @@ class Config {
161161
162162 get collectionModels ( ) : Record < string , string > {
163163 return (
164- this . ini [ "collection_models" ] ?? {
164+ ( this . ini [ "collection_models" ] as Record < string , string > ) ?? {
165165 List : "vudl-system:ListCollection" ,
166166 Resource : "vudl-system:ResourceCollection" ,
167167 Folder : "vudl-system:FolderCollection" ,
@@ -170,27 +170,27 @@ class Config {
170170 }
171171
172172 get institution ( ) : string {
173- return this . ini [ "institution" ] ?? "My University" ;
173+ return ( this . ini [ "institution" ] as string ) ?? "My University" ;
174174 }
175175
176176 get collection ( ) : string {
177- return this . ini [ "collection" ] ?? "Digital Library" ;
177+ return ( this . ini [ "collection" ] as string ) ?? "Digital Library" ;
178178 }
179179
180180 get topLevelPids ( ) : Array < string > {
181- return this . ini [ "top_level_pids" ] ?? [ ] ;
181+ return ( this . ini [ "top_level_pids" ] as string [ ] ) ?? [ ] ;
182182 }
183183
184184 get articlesToStrip ( ) : Array < string > {
185- return this . ini [ "articles_to_strip" ] ?? [ ] ;
185+ return ( this . ini [ "articles_to_strip" ] as string [ ] ) ?? [ ] ;
186186 }
187187
188188 get trashPid ( ) : string | null {
189- return this . ini [ "trash_pid" ] ?? null ;
189+ return ( this . ini [ "trash_pid" ] as string ) ?? null ;
190190 }
191191
192192 get favoritePids ( ) : Array < string > {
193- const favorites = this . ini [ "favorite_pids" ] ?? [ ] ;
193+ const favorites = ( this . ini [ "favorite_pids" ] as string [ ] ) ?? [ ] ;
194194 const trash = this . trashPid ;
195195 if ( trash && ! favorites . includes ( trash ) ) {
196196 favorites . push ( trash ) ;
@@ -199,19 +199,19 @@ class Config {
199199 }
200200
201201 get languageMap ( ) : Record < string , string > {
202- return this . ini [ "LanguageMap" ] ?? { } ;
202+ return ( this . ini [ "LanguageMap" ] as Record < string , string > ) ?? { } ;
203203 }
204204
205205 get minimumValidYear ( ) : number {
206- return parseInt ( this . ini [ "minimum_valid_year" ] ?? 1000 ) ;
206+ return parseInt ( ( this . ini [ "minimum_valid_year" ] as string ) ?? " 1000" ) ;
207207 }
208208
209209 get models ( ) : Record < string , FedoraModel > {
210- return this . ini [ "models" ] || { } ;
210+ return ( this . ini [ "models" ] as unknown as Record < string , FedoraModel > ) || { } ;
211211 }
212212
213213 get databaseSettings ( ) : ConfigRecord {
214- return this . ini [ "Database" ] ?? { } ;
214+ return ( this . ini [ "Database" ] as ConfigRecord ) ?? { } ;
215215 }
216216
217217 get databaseClient ( ) : string {
@@ -223,7 +223,7 @@ class Config {
223223 }
224224
225225 get authenticationSettings ( ) : ConfigRecord {
226- return this . ini [ "Authentication" ] ?? [ ] ;
226+ return ( this . ini [ "Authentication" ] as ConfigRecord ) ?? { } ;
227227 }
228228
229229 get authenticationStrategy ( ) : string {
@@ -263,88 +263,88 @@ class Config {
263263 }
264264
265265 get licenses ( ) : Record < string , License > {
266- return this . ini [ "licenses" ] ?? { } ;
266+ return ( this . ini [ "licenses" ] as unknown as Record < string , License > ) ?? { } ;
267267 }
268268
269269 get agentDefaults ( ) : Record < string , string > {
270- return this . ini ?. [ "agent" ] ?. [ "defaults" ] ?? { } ;
270+ return ( ( this . ini [ "agent" ] as ConfigRecord ) ?. [ "defaults" ] as Record < string , string > ) ?? { } ;
271271 }
272272
273273 get agentRoles ( ) : Array < string > {
274- return this . ini ?. [ "agent" ] ?. [ "roles" ] ?? [ ] ;
274+ return ( ( this . ini [ "agent" ] as ConfigRecord ) ?. [ "roles" ] as string [ ] ) ?? [ ] ;
275275 }
276276
277277 get agentTypes ( ) : Array < string > {
278- return this . ini ?. [ "agent" ] ?. [ "types" ] ?? [ ] ;
278+ return ( ( this . ini [ "agent" ] as ConfigRecord ) ?. [ "types" ] as string [ ] ) ?? [ ] ;
279279 }
280280
281281 get dublinCoreFields ( ) : Record < string , Record < string , string | Array < string > > > {
282- return this . ini ?. [ "dublin_core" ] ?? { } ;
282+ return ( this . ini [ "dublin_core" ] as Record < string , Record < string , string | Array < string > > > ) ?? { } ;
283283 }
284284
285285 get redisConnectionSettings ( ) : Record < string , string > {
286- return this . ini ?. [ "queue" ] ?. [ "connection" ] ?? { } ;
286+ return ( ( this . ini [ "queue" ] as ConfigRecord ) ?. [ "connection" ] as Record < string , string > ) ?? { } ;
287287 }
288288
289289 get redisDefaultQueueName ( ) : string {
290- return this . ini ?. [ "queue" ] ?. [ "defaultQueueName" ] ?? "vudl" ;
290+ return ( ( this . ini [ "queue" ] as ConfigRecord ) ?. [ "defaultQueueName" ] as string ) ?? "vudl" ;
291291 }
292292
293293 get redisQueueJobMap ( ) : Record < string , string > {
294- return this . ini ?. [ "queue" ] ?. [ "jobMap" ] ?? { } ;
294+ return ( ( this . ini [ "queue" ] as ConfigRecord ) ?. [ "jobMap" ] as Record < string , string > ) ?? { } ;
295295 }
296296
297297 get redisLockDuration ( ) : number {
298- return parseInt ( this . ini ?. [ "queue" ] ?. [ "lockDuration" ] ?? "30000" ) ;
298+ return parseInt ( ( ( this . ini [ "queue" ] as ConfigRecord ) ?. [ "lockDuration" ] as string ) ?? "30000" ) ;
299299 }
300300
301301 get processMetadataDefaults ( ) : Record < string , string > {
302- return this . ini ?. [ "process_metadata_defaults" ] ?? { } ;
302+ return ( this . ini [ "process_metadata_defaults" ] as Record < string , string > ) ?? { } ;
303303 }
304304
305305 get toolPresets ( ) : Array < Record < string , string > > {
306- return this . ini ?. [ "tool_presets" ] ?? [ ] ;
306+ return ( this . ini [ "tool_presets" ] as unknown as Array < Record < string , string > > ) ?? [ ] ;
307307 }
308308
309309 get sharpOptions ( ) : Record < string , unknown > {
310- const pixelLimit = this . ini ?. [ "sharp" ] ?. [ "limitInputPixels" ] ?? "268402689" ;
310+ const pixelLimit = ( ( this . ini [ "sharp" ] as ConfigRecord ) ?. [ "limitInputPixels" ] as string ) ?? "268402689" ;
311311 return {
312312 limitInputPixels : parseInt ( pixelLimit ) ,
313313 } ;
314314 }
315315
316316 get max409Retries ( ) : number {
317- return this . ini [ "max_409_retries" ] ?? 3 ;
317+ return ( this . ini [ "max_409_retries" ] as unknown as number ) ?? 3 ;
318318 }
319319
320320 get maxUploadSize ( ) : number {
321- return this . ini ?. [ "upload" ] ?. [ "sizeLimit" ] ?? 200 * 1024 * 1024 ;
321+ return ( ( this . ini [ "upload" ] as ConfigRecord ) ?. [ "sizeLimit" ] as unknown as number ) ?? 200 * 1024 * 1024 ;
322322 }
323323
324324 get notifyMethod ( ) : string {
325- return this . ini ?. [ "notify" ] ?. [ "method" ] ?? "ntfy" ;
325+ return ( ( this . ini [ "notify" ] as ConfigRecord ) ?. [ "method" ] as string ) ?? "ntfy" ;
326326 }
327327
328328 get ntfyConfig ( ) : Record < string , string > {
329329 return {
330- defaultChannel : this . ini ?. [ "notify" ] ?. [ "ntfy_defaultChannel" ] ?? "vudl-ntfy" ,
330+ defaultChannel : ( ( this . ini [ "notify" ] as ConfigRecord ) ?. [ "ntfy_defaultChannel" ] as string ) ?? "vudl-ntfy" ,
331331 } ;
332332 }
333333
334334 get indexerLockRetries ( ) : number {
335- return parseInt ( this . ini ?. [ "indexer" ] ?. [ "lockRetries" ] ?? 60 ) ;
335+ return parseInt ( ( ( this . ini [ "indexer" ] as ConfigRecord ) ?. [ "lockRetries" ] as string ) ?? "60" ) ;
336336 }
337337
338338 get indexerLockWaitMs ( ) : number {
339- return parseInt ( this . ini ?. [ "indexer" ] ?. [ "lockWaitMs" ] ?? 1000 ) ;
339+ return parseInt ( ( ( this . ini [ "indexer" ] as ConfigRecord ) ?. [ "lockWaitMs" ] as string ) ?? " 1000" ) ;
340340 }
341341
342342 get indexerExceptionRetries ( ) : number {
343- return parseInt ( this . ini ?. [ "indexer" ] ?. [ "exceptionRetries" ] ?? 10 ) ;
343+ return parseInt ( ( ( this . ini [ "indexer" ] as ConfigRecord ) ?. [ "exceptionRetries" ] as string ) ?? "10" ) ;
344344 }
345345
346346 get indexerExceptionWaitMs ( ) : number {
347- return parseInt ( this . ini ?. [ "indexer" ] ?. [ "exceptionWaitMs" ] ?? 500 ) ;
347+ return parseInt ( ( ( this . ini [ "indexer" ] as ConfigRecord ) ?. [ "exceptionWaitMs" ] as string ) ?? " 500" ) ;
348348 }
349349}
350350
0 commit comments