mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
76ff6e15b1
AirTrail 3.13 adds /api/v1 and marks the /api/flight/* routes as deprecated. TREK now asks the public discovery document GET /api/v1 and uses v1 when the instance has it. It uses the legacy routes for an older instance. The client methods keep their signatures, and the sync hash stays the same, so a linked flight does not sync again when an instance changes to v1. The probe cache holds only a clear answer: 200 with the discovery document gives v1, and 404 gives legacy. The cache is per AirTrail URL, for 10 minutes. A timeout, a 5xx or a network error fails that call only. A 401, a 403 or a page that is not the discovery document uses legacy for that call only. A 404 for one flight makes the client ask the probe again before it reports the flight as deleted. A missing scope gives AirtrailScopeError, which names the scope. It does not unlink a flight. The API key hint and the help step list the scopes for read and for write-back, in all languages. Each new request goes through safeFetch, with the SSRF guard, the timeout and the size cap. The flight list reads pages of 100 and fails above 50 pages. A failed list unlinks nothing. airtrail-v1.ts translates between the v1 shapes and the legacy shapes. A write-back looks up the airport, airline and aircraft ids, and changes each local time to a UTC instant in the zone of its own airport. It writes each instant in the +00:00 form of the legacy save, because AirTrail stores the string as it gets it and the sync hash reads that string. The tests cover both APIs over HTTP, the probe cache rules, the sync hash on a switch and on a save, the page limit, the scope error, and the UTC conversion across midnight, the date line and daylight-saving changes.