mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
feat(flight-live): follow booked flights live from keyless ADS-B feeds
A new flight-live domain polls the open feeds adsb.lol and adsb.fi (no key, no cost; adsb.fi only on self-hosted installs, its terms are non-commercial) for every booked flight leg in its watch window, derives phase, take-off, landing, delay and an arrival estimate, and pushes changes as flight:live. GET /api/trips/:tripId/flights/live, the MCP tool get_trip_flight_status, notifications for take-off, landing and delays, and the admin switch flight_live_enabled (FLIGHT_LIVE_ENABLED wins) come with it.
This commit is contained in:
@@ -69,6 +69,44 @@ const FIXTURES: Record<TrekWsEventName, Record<string, unknown>> = {
|
||||
'reservation:deleted': { reservationId: 6 },
|
||||
'reservation:positions': { positions: [{ id: 6, position: 0 }], day_id: 2 },
|
||||
'reservation:travelers-updated': { reservationId: 6, travelers: [{ user_id: 1 }] },
|
||||
'flight:live': {
|
||||
flights: [
|
||||
{
|
||||
reservation_id: 6,
|
||||
leg_index: 0,
|
||||
callsign: 'DLH400',
|
||||
flight_number: 'LH 400',
|
||||
service_date: '2026-06-11',
|
||||
origin: { code: 'FRA', name: 'Frankfurt', lat: 50.03, lng: 8.57, timezone: 'Europe/Berlin' },
|
||||
destination: { code: 'JFK', name: 'New York JFK', lat: 40.64, lng: -73.78, timezone: 'America/New_York' },
|
||||
phase: 'airborne',
|
||||
scheduled_departure: '2026-06-11T11:50:00.000Z',
|
||||
scheduled_arrival: '2026-06-11T20:35:00.000Z',
|
||||
departed_at: '2026-06-11T12:14:00.000Z',
|
||||
landed_at: null,
|
||||
estimated_arrival: '2026-06-11T20:51:00.000Z',
|
||||
departure_delay_min: 24,
|
||||
arrival_delay_min: 16,
|
||||
progress: 0.42,
|
||||
distance_total_km: 6200,
|
||||
distance_remaining_km: 3596,
|
||||
position: {
|
||||
lat: 55.1,
|
||||
lng: -20.4,
|
||||
altitude_ft: 37000,
|
||||
ground_speed_kt: 470,
|
||||
track_deg: 285,
|
||||
vertical_rate_fpm: 0,
|
||||
on_ground: false,
|
||||
},
|
||||
aircraft: { registration: 'D-AIXA', type: 'A359' },
|
||||
last_seen_at: '2026-06-11T15:40:00.000Z',
|
||||
fetched_at: '2026-06-11T15:40:10.000Z',
|
||||
stale: false,
|
||||
source: 'adsb.lol',
|
||||
},
|
||||
],
|
||||
},
|
||||
'accommodation:created': { accommodation: { id: 8 } },
|
||||
'accommodation:updated': { accommodation: { id: 8 } },
|
||||
'accommodation:deleted': { accommodationId: 8 },
|
||||
@@ -177,9 +215,9 @@ describe('@trek/shared realtime event registry', () => {
|
||||
// notification:read-all, trips:changed, settings:updated, tags:changed,
|
||||
// atlas:changed, journey:updated, journey:deleted). Registered first, the
|
||||
// writes that send them follow.
|
||||
expect(TREK_WS_TRIP_EVENT_NAMES).toHaveLength(79);
|
||||
expect(TREK_WS_TRIP_EVENT_NAMES).toHaveLength(80);
|
||||
expect(TREK_WS_USER_EVENT_NAMES).toHaveLength(41);
|
||||
expect(TREK_WS_EVENT_NAMES).toHaveLength(120);
|
||||
expect(TREK_WS_EVENT_NAMES).toHaveLength(121);
|
||||
});
|
||||
|
||||
it('WSEVT-REG-002: every name is domain:action shaped and outside the reserved plugin: namespace', () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { flightLiveLegSchema } from '../flight-live/flight-live.schema';
|
||||
import { roadtripDayBoundaryListSchema } from '../roadtrip/day-boundary.schema';
|
||||
import { roadtripPreferencesSchema } from '../roadtrip/preferences.schema';
|
||||
|
||||
@@ -215,6 +216,8 @@ export const TREK_WS_EVENTS = {
|
||||
scope: 'trip',
|
||||
payload: z.object({ reservationId: id, travelers: z.array(z.unknown()) }),
|
||||
},
|
||||
// Live flight states of the trip that changed in the last poll (flight-live job).
|
||||
'flight:live': { scope: 'trip', payload: z.object({ flights: z.array(flightLiveLegSchema) }) },
|
||||
|
||||
// ── Accommodations ───────────────────────────────────────────────────────
|
||||
// DRIFT: `{ accommodation }` vs empty refetch ping `{}` (reservation cascade
|
||||
|
||||
Reference in New Issue
Block a user