feat(airtrail): use the AirTrail /api/v1 routes, and keep the legacy routes

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.
This commit is contained in:
aaronspruit
2026-11-16 18:52:57 -08:00
committed by Maurice
parent 3e0a2ef8ed
commit 76ff6e15b1
61 changed files with 1442 additions and 74 deletions
+1 -1
View File
@@ -4568,7 +4568,7 @@ const help: TranslationStrings = {
'help.guide.web-push-device.result':
'Karta ukazuje „Zapnuto pro toto zařízení“ a události zapnuté ve sloupci Push vám přijdou, i když je TREK zavřený.',
'help.guide.connect-airtrail.step.1':
'V části „Integrace“ najděte AirTrail a zadejte jeho „URL instance“ a API klíč. Klíč vytvoříte v AirTrail v části Nastavení, Zabezpečení.',
'V části „Integrace“ najděte AirTrail a zadejte jeho „URL instance“ a API klíč. Klíč vytvoříte v AirTrail v části Nastavení, Zabezpečení. Pokud klíč vytvoříte v AirTrail 3.13 nebo novějším, potřebuje oprávnění flight.read.own pro čtení. Pro zápis změn zpět potřebuje také flight.update.own, flight.passengers.manage.own, reference_data.read a profile.read.',
'help.guide.connect-dawarich.step.1':
'V části „Integrace“ najděte Dawarich a zadejte jeho „Adresa instance“ a API klíč, který najdete v Dawarich v části Účet, API klíč.',
'help.guide.tour-connect-wanderer.step.1':
+2 -1
View File
@@ -417,7 +417,8 @@ const settings: TranslationStrings = {
'settings.airtrail.url': 'URL instance',
'settings.airtrail.apiKey': 'API klíč',
'settings.airtrail.apiKeyPlaceholder': 'API klíč Bearer',
'settings.airtrail.apiKeyHint': 'Vygenerován v AirTrail v Nastavení → Zabezpečení. Uložen šifrovaně.',
'settings.airtrail.apiKeyHint':
'Vygenerován v AirTrail v Nastavení → Zabezpečení. Uložen šifrovaně. Pokud klíč vytvoříte v AirTrail 3.13 nebo novějším, potřebuje oprávnění flight.read.own pro čtení. Pro zápis změn zpět potřebuje také flight.update.own, flight.passengers.manage.own, reference_data.read a profile.read.',
'settings.airtrail.allowInsecureTls': 'Povolit certifikáty podepsané sebou samým',
'settings.airtrail.allowInsecureTlsHint': 'Povolte pouze pro důvěryhodnou instanci ve vlastní síti.',
'settings.airtrail.writeBack': 'Zapisovat změny zpět do AirTrail',