Background
server/_shared/airline-codes.ts contains a hand-curated static map of ~100 airline ICAO→IATA mappings used to resolve Wingbits callsigns (e.g. UAE528→EK528 Emirates). The map was seeded from OpenFlights airlines.dat and is sufficient for current traffic.
To keep it current without full manual curation, we need a generator script.
Task
Write scripts/generate-airline-codes.mjs that:
- Fetches
https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat (public domain CSV)
- Parses each row:
ID, Name, Alias, IATA, ICAO, Callsign, Country, Active
- Filters to:
Active == "Y", 2-char IATA, 3-char ICAO, both non-null/non-\N
- Emits all strings via
JSON.stringify to prevent quote/newline injection
- Re-writes only the
GENERATED block inside server/_shared/airline-codes.ts, leaving the OVERRIDE table intact
- Prints a summary: N entries written, N removed, N added vs. previous run
Maintenance cadence
Run quarterly (or when a gap is reported in prod via missing IATA header in popup):
node scripts/generate-airline-codes.mjs
# Review diff in server/_shared/airline-codes.ts
# Commit as chore(deps): refresh airline ICAO-IATA lookup table
For immediate corrections (wrong mapping, rebranded airline): add to the OVERRIDE table directly — no script needed.
Notes
- The
OVERRIDE table must always survive a re-run (script should not touch it)
- Strings must be
JSON.stringify-escaped to avoid TS syntax errors from airline names with quotes
- Consider pinning the source commit SHA or checksum in the script header for auditability
Background
server/_shared/airline-codes.tscontains a hand-curated static map of ~100 airline ICAO→IATA mappings used to resolve Wingbits callsigns (e.g. UAE528→EK528 Emirates). The map was seeded from OpenFlightsairlines.datand is sufficient for current traffic.To keep it current without full manual curation, we need a generator script.
Task
Write
scripts/generate-airline-codes.mjsthat:https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat(public domain CSV)ID, Name, Alias, IATA, ICAO, Callsign, Country, ActiveActive == "Y", 2-char IATA, 3-char ICAO, both non-null/non-\NJSON.stringifyto prevent quote/newline injectionGENERATEDblock insideserver/_shared/airline-codes.ts, leaving theOVERRIDEtable intactMaintenance cadence
Run quarterly (or when a gap is reported in prod via missing IATA header in popup):
For immediate corrections (wrong mapping, rebranded airline): add to the
OVERRIDEtable directly — no script needed.Notes
OVERRIDEtable must always survive a re-run (script should not touch it)JSON.stringify-escaped to avoid TS syntax errors from airline names with quotes