Add translation utility for formatting StaffLDB(Station) Data
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
d7d4768663
commit
edb33153ce
43
src/utils/translators/ldb/staffStation.ts
Normal file
43
src/utils/translators/ldb/staffStation.ts
Normal file
@ -0,0 +1,43 @@
|
||||
export type { StaffLdb, NrccMessage, TrainServices,
|
||||
ServiceLocation } from '@owlboard/ts-types'
|
||||
|
||||
/// I do not yet have a type defined for any of the input object
|
||||
export function transform(input: Object): StaffLdb {
|
||||
let output: StaffLdb
|
||||
return output
|
||||
}
|
||||
|
||||
function transformNrcc(input: any): NrccMessage[] {
|
||||
let output: NrccMessage[] = []
|
||||
if (!Array.isArray(input?.message)) {
|
||||
input.message = [input.message]
|
||||
}
|
||||
for (const item of input?.message) {
|
||||
let message = {
|
||||
severity: item?.severity,
|
||||
xhtmlMessage: item?.xhtmlMessage
|
||||
}
|
||||
output.push(message)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
function transformTrainServices(input: Object): TrainServices[] {
|
||||
let output: TrainServices[]
|
||||
return output
|
||||
}
|
||||
|
||||
function transformLocation(input: any): ServiceLocation {
|
||||
let output: ServiceLocation[] = []
|
||||
if (!Array.isArray(input)) {
|
||||
input = [input]
|
||||
}
|
||||
for (const item of input) {
|
||||
const location: ServiceLocation = {
|
||||
tiploc: item?.tiploc,
|
||||
name: item?.locationName
|
||||
}
|
||||
output.push(location)
|
||||
}
|
||||
return output
|
||||
}
|
Loading…
Reference in New Issue
Block a user