import type { Persist } from '../../types/persist' ; import type { Aliases , Module , ModuleCode , ModuleCondensed , ModuleInformation , RawLesson , Semester , SemesterData , } from '../../types/modules' ; import type { MPEModule } from '../../types/mpe' ; import type { Venue , VenueInfo } from '../../types/venues' ; import { getFileSystemWriter } from './fs' ; import ElasticPersist from './elastic' ; export { getCacheFactory } from './fs' ; export { getFileSystemWriter } ; /**
 * Call both file system and ElasticSearch persist backends
 */ export class CombinedPersist implements Persist { private readonly writers : Persist [ ] = [ ] ; constructor ( acadYear ) { this . writers . push ( getFileSystemWriter ( acadYear ) ) ; this . writers . push ( new ElasticPersist ( ) ) ; } async moduleList ( data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . moduleList ( data ) ) ) ; } async moduleInfo ( data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . moduleInfo ( data ) ) ) ; } async mpeModules ( data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . mpeModules ( data ) ) ) ; } async moduleInformation ( data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . moduleInformation ( data ) ) ) ; } async moduleAliases ( data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . moduleAliases ( data ) ) ) ; } async facultyDepartments ( data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . facultyDepartments ( data ) ) ) ; } async module ( moduleCode , data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . module ( moduleCode , data ) ) ) ; } async getModuleCodes ( ) { const moduleCodes = await Promise . all ( this . writers . map ( ( writer ) => writer . getModuleCodes ( ) ) ) ; return Array . from ( new Set ( moduleCodes . flat ( ) ) ) ; } async deleteModule ( moduleCode ) { await Promise . all ( this . writers . map ( ( writer ) => writer . deleteModule ( moduleCode ) ) ) ; } async venueList ( semester , data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . venueList ( semester , data ) ) ) ; } async venueInformation ( semester , data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . venueInformation ( semester , data ) ) ) ; } async timetable ( semester , moduleCode , data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . timetable ( semester , moduleCode , data ) ) ) ; } async semesterData ( semester , moduleCode , data ) { await Promise . all ( this . writers . map ( ( writer ) => writer . semesterData ( semester , moduleCode , data ) ) ) ; } }