/** * EDR run-number pairs, keyed by the odd EXPORT run (Ethiopia → Djibouti). The * even IMPORT run (Djibouti → Ethiopia) is fixed by the export run. * * Run numbers are always 4 digits (8401, never 84001). Pairs are listed out * rather than computed from the 8001/+100/+1 pattern, so a run that ever breaks * the convention stays correct here. * * SeedWagonRunNumbers2280000000000 carries its own frozen copy on purpose: a * migration must keep doing what it did when it was applied, whereas this list * is live config for the update script. Add or retire runs HERE. */ export const TRAIN_RUN_PAIRS: Record = { '8001': '8002', '8101': '8102', '8201': '8202', '8301': '8302', '8401': '8402', '8501': '8502', '8601': '8602', '8701': '8702', '8801': '8802', '8901': '8902', '9001': '9002', }; /** Even IMPORT run -> its odd EXPORT run. Derived so the two cannot drift. */ export const EXPORT_BY_IMPORT: Record = Object.fromEntries( Object.entries(TRAIN_RUN_PAIRS).map(([exportRun, importRun]) => [importRun, exportRun]), ); /** * Normalise any run number to its EXPORT run. Accepts either half of a pair, so * a sheet listing "8002" and one listing "8001" both resolve to the same train. * Returns null when the number belongs to no known run. */ export const toExportRun = (run: string): string | null => { const value = run.trim(); if (TRAIN_RUN_PAIRS[value]) return value; return EXPORT_BY_IMPORT[value] ?? null; };