Cars: create a car from a manufacturer service, with a per-car data tab
A car can now be imported straight from the account its owner already has
with the manufacturer, and every reading that service exposes shows up on
the car's own tab. MyToyota is the first provider.
API Server — internal/api/vehicleproviders.go adds a generic layer over a
plugin that can enumerate vehicles and read data about them. Adding the
next manufacturer is one vehicleSource adapter plus a line in
vehicleSources(): no new endpoints, no Web App changes.
GET /api/vehicle-providers providers + connect state
GET /api/vehicle-providers/{p}/vehicles the caller's vehicles
POST /api/vehicle-providers/{p}/import create a car from one
GET /api/cars/{id}/provider live snapshot for the tab
POST /api/cars/{id}/provider link / unlink a car
POST /api/cars/{id}/provider/sync re-apply provider data
Two properties shape it. Credentials are always the caller's own, resolved
through the same global -> org -> user cascade as the integration settings,
so a shared car shows provider data only when that vehicle is on the
viewer's account — the owner's credentials are never borrowed. And upstream
shapes are not modelled: these are unofficial APIs, so the layer searches
payloads by key name for the readings worth promoting (odometer, fuel,
battery, range) and flattens the rest to dotted key/value pairs alongside
the raw JSON. A renamed field costs one blank value, not a broken page.
The Toyota gate and its wording now live in toyotaSource, so the older
/api/integrations/toyota/vehicles endpoint and the new ones cannot drift.
Manager.InvokeBatchWith shares one transient plugin instance across a batch
of actions. The tab pulls seven capabilities, and InvokeWith builds a fresh
instance per call — which for a connector that authenticates lazily means a
fresh OAuth login per call. Batching logs in once.
cars gains provider + provider_vehicle_id (schema.go and
setup-pocketbase.mjs both). carPayload deliberately omits them, so an
ordinary car edit can neither reassign the car nor break its link;
carProviderPayload writes the link on its own.
Web App — Dashboard grows an "import from service" button beside "add car",
shown only once an account is connected, opening CarImportModal: pick the
vehicle, choose what to pull (identity / fuel type / dates / odometer, all
on by default), import. ProviderPanel becomes the car's first tab, ahead of
Information, labelled with the service: headline readings, the vehicle
record, one card per capability with its raw response, and an offer to take
the provider's odometer when it is ahead of the stored one. On an unlinked
car the tab instead offers to link it, VIN-matched. Info stays the default
selection — landing on the provider tab would fire a login on every car
page view. Full en/pl/da translations.
Tests cover the payload walking, Toyota normalization, import-selection
defaults, and — through the real handler chain against a stand-in
PocketBase — that every route is registered and that a closed gate is soft
on a listing (200 + a reason the UI can show) but hard on a write (4xx, so
a caller cannot read the reply as a created car).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
47a9aef466
commit
358ee68f94
23 files changed
+2983
-43
No files matched your search
@@ -11,6 +11,7 @@
|
||||
"saved": "Gemt ✓",
|
||||
"loading": "Indlæser…",
|
||||
"edit": "Rediger",
|
||||
"open": "Åbn",
|
||||
"remove": "Fjern",
|
||||
"delete": "Slet",
|
||||
"done": "Færdig",
|
||||
@@ -87,6 +88,7 @@
|
||||
"title": "Dine biler",
|
||||
"subtitle": "Serviceoverblik og servicehistorik.",
|
||||
"addCar": "Tilføj bil",
|
||||
"importCar": "Importér fra tjeneste",
|
||||
"empty": "Ingen biler endnu. Klik på {action} for at komme i gang.",
|
||||
"shared": "Delt",
|
||||
"sharedReadOnly": "Delt · skrivebeskyttet",
|
||||
@@ -242,6 +244,7 @@
|
||||
"sharedReadOnly": "Delt · skrivebeskyttet",
|
||||
|
||||
"tabs": {
|
||||
"connected": "Tilsluttet tjeneste",
|
||||
"info": "Oplysninger",
|
||||
"services": "Servicehistorik",
|
||||
"technical": "Synshistorik",
|
||||
@@ -252,6 +255,50 @@
|
||||
"reminders": "Påmindelser"
|
||||
},
|
||||
|
||||
"provider": {
|
||||
"subtitle": "Live-data fra din {label}-konto.",
|
||||
"refresh": "Opdater",
|
||||
"refreshing": "Opdaterer…",
|
||||
"updated": "Opdateret {time}",
|
||||
"vehicle": "Køretøj",
|
||||
"readings": "Aktuelle målinger",
|
||||
"noData": "{label} returnerede ingen data for denne bil.",
|
||||
"raw": "Rå svar",
|
||||
"allFields": "Alle oplyste felter",
|
||||
"truncated": "Kun de første {n} felter er vist — resten findes i det rå svar nedenfor.",
|
||||
"sectionEmpty": "Intet oplyst.",
|
||||
"own": "Kun din egen konto bruges, så loginoplysninger deles aldrig sammen med en bil.",
|
||||
"odometerSuggest": "{label} oplyser {km}, altså mere end bilens gemte kilometerstand.",
|
||||
"updateOdometer": "Opdater kilometerstand",
|
||||
"updatingOdometer": "Opdaterer…",
|
||||
"unlink": "Afbryd",
|
||||
"unlinkConfirm": "Afbryd denne bil fra {label}? Intet gemt slettes.",
|
||||
"connectTitle": "Forbind denne bil til en tjeneste",
|
||||
"connectHint": "Vælg det køretøj på din konto, der svarer til denne bil. Dens data vises så her.",
|
||||
"connectSubmit": "Forbind køretøj",
|
||||
"connecting": "Forbinder…",
|
||||
"noProviders": "Ingen producentkonto er tilsluttet. Tilføj en under Indstillinger › Integrationer.",
|
||||
"settingsLink": "Åbn Indstillinger",
|
||||
"sections": {
|
||||
"telemetry": "Kilometerstand og rækkevidde",
|
||||
"electric": "Batteri og opladning",
|
||||
"status": "Døre, ruder og lys",
|
||||
"health": "Køretøjets tilstand",
|
||||
"location": "Sidst kendte position",
|
||||
"serviceHistory": "Servicehistorik hos forhandler",
|
||||
"notifications": "Notifikationer"
|
||||
},
|
||||
"metrics": {
|
||||
"odometer": "Kilometerstand",
|
||||
"fuelLevel": "Brændstofniveau",
|
||||
"fuelRange": "Rækkevidde",
|
||||
"batteryLevel": "Batteri",
|
||||
"evRange": "Elektrisk rækkevidde",
|
||||
"chargingStatus": "Opladning",
|
||||
"location": "Position"
|
||||
}
|
||||
},
|
||||
|
||||
"info": {
|
||||
"oilSpec": "Motorolie-specifikation",
|
||||
"transmissionOil": "Gearolie",
|
||||
@@ -454,6 +501,29 @@
|
||||
"submit": "Tilføj bil"
|
||||
},
|
||||
|
||||
"import": {
|
||||
"title": "Importér en bil",
|
||||
"subtitle": "Opret en bil ud fra et køretøj på din producentkonto. Alt, hvad der kan læses, udfyldes for dig.",
|
||||
"service": "Tjeneste",
|
||||
"loadingVehicles": "Indlæser dine køretøjer…",
|
||||
"noVehicles": "Ingen køretøjer på denne konto.",
|
||||
"notConnected": "Ikke tilsluttet",
|
||||
"noProviders": "Ingen producentkonto er tilsluttet. Tilføj en under Indstillinger › Integrationer.",
|
||||
"alreadyInGarage": "Allerede i din garage",
|
||||
"selectVehicle": "Køretøj",
|
||||
"dataTitle": "Hvad skal importeres",
|
||||
"dataHint": "Fjern fluebenet ved det, du helst selv vil udfylde.",
|
||||
"includeIdentity": "Mærke, model, årgang, nummerplade og VIN",
|
||||
"includeFuelType": "Brændstoftype",
|
||||
"includeDates": "Produktions- og første registreringsdato",
|
||||
"includeOdometer": "Aktuel kilometerstand",
|
||||
"name": "Bilens navn",
|
||||
"submit": "Importér bil",
|
||||
"importing": "Importerer…",
|
||||
"warningOdometer": "Tjenesten oplyste ingen kilometerstand — indtast den selv på bilen.",
|
||||
"moreData": "Resten af det, tjenesten oplyser, er fortsat tilgængeligt på bilens {label}-fane."
|
||||
},
|
||||
|
||||
"service": {
|
||||
"addTitle": "Tilføj servicepost",
|
||||
"editTitle": "Rediger servicepost",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"saved": "Saved ✓",
|
||||
"loading": "Loading…",
|
||||
"edit": "Edit",
|
||||
"open": "Open",
|
||||
"remove": "Remove",
|
||||
"delete": "Delete",
|
||||
"done": "Done",
|
||||
@@ -105,6 +106,7 @@
|
||||
"title": "Your cars",
|
||||
"subtitle": "Maintenance overview and service history.",
|
||||
"addCar": "Add car",
|
||||
"importCar": "Import from service",
|
||||
"empty": "No cars yet. Click {action} to get started.",
|
||||
"shared": "Shared",
|
||||
"sharedReadOnly": "Shared · read-only",
|
||||
@@ -317,6 +319,7 @@
|
||||
"sharedReadOnly": "Shared · read-only",
|
||||
|
||||
"tabs": {
|
||||
"connected": "Connected service",
|
||||
"info": "Information",
|
||||
"services": "Service history",
|
||||
"technical": "Technical check history",
|
||||
@@ -327,6 +330,50 @@
|
||||
"reminders": "Reminders"
|
||||
},
|
||||
|
||||
"provider": {
|
||||
"subtitle": "Live data from your {label} account.",
|
||||
"refresh": "Refresh",
|
||||
"refreshing": "Refreshing…",
|
||||
"updated": "Updated {time}",
|
||||
"vehicle": "Vehicle",
|
||||
"readings": "Current readings",
|
||||
"noData": "{label} returned no data for this car.",
|
||||
"raw": "Raw response",
|
||||
"allFields": "All reported fields",
|
||||
"truncated": "Only the first {n} fields are listed — the raw response below has the rest.",
|
||||
"sectionEmpty": "Nothing reported.",
|
||||
"own": "Only your own account is used, so credentials are never shared with a car.",
|
||||
"odometerSuggest": "{label} reports {km}, ahead of this car's stored reading.",
|
||||
"updateOdometer": "Update odometer",
|
||||
"updatingOdometer": "Updating…",
|
||||
"unlink": "Disconnect",
|
||||
"unlinkConfirm": "Disconnect this car from {label}? Nothing already saved is deleted.",
|
||||
"connectTitle": "Connect this car to a service",
|
||||
"connectHint": "Pick the vehicle on your account that matches this car. Its data then appears here.",
|
||||
"connectSubmit": "Connect vehicle",
|
||||
"connecting": "Connecting…",
|
||||
"noProviders": "No manufacturer account is connected. Add one in Settings › Integrations.",
|
||||
"settingsLink": "Open Settings",
|
||||
"sections": {
|
||||
"telemetry": "Odometer & range",
|
||||
"electric": "Battery & charging",
|
||||
"status": "Doors, windows & lights",
|
||||
"health": "Vehicle health",
|
||||
"location": "Last known location",
|
||||
"serviceHistory": "Dealer service history",
|
||||
"notifications": "Notifications"
|
||||
},
|
||||
"metrics": {
|
||||
"odometer": "Odometer",
|
||||
"fuelLevel": "Fuel level",
|
||||
"fuelRange": "Range",
|
||||
"batteryLevel": "Battery",
|
||||
"evRange": "Electric range",
|
||||
"chargingStatus": "Charging",
|
||||
"location": "Position"
|
||||
}
|
||||
},
|
||||
|
||||
"info": {
|
||||
"oilSpec": "Engine oil spec",
|
||||
"transmissionOil": "Transmission oil",
|
||||
@@ -529,6 +576,29 @@
|
||||
"submit": "Add car"
|
||||
},
|
||||
|
||||
"import": {
|
||||
"title": "Import a car",
|
||||
"subtitle": "Create a car from a vehicle on your manufacturer account. Everything it can read is filled in for you.",
|
||||
"service": "Service",
|
||||
"loadingVehicles": "Loading your vehicles…",
|
||||
"noVehicles": "No vehicles on this account.",
|
||||
"notConnected": "Not connected",
|
||||
"noProviders": "No manufacturer account is connected. Add one in Settings › Integrations.",
|
||||
"alreadyInGarage": "Already in your garage",
|
||||
"selectVehicle": "Vehicle",
|
||||
"dataTitle": "What to import",
|
||||
"dataHint": "Uncheck anything you would rather fill in yourself.",
|
||||
"includeIdentity": "Make, model, year, registration and VIN",
|
||||
"includeFuelType": "Fuel type",
|
||||
"includeDates": "Build and first-registration dates",
|
||||
"includeOdometer": "Current odometer",
|
||||
"name": "Car name",
|
||||
"submit": "Import car",
|
||||
"importing": "Importing…",
|
||||
"warningOdometer": "The service did not report an odometer reading — enter it yourself on the car.",
|
||||
"moreData": "The rest of what this service reports stays available on the car's {label} tab."
|
||||
},
|
||||
|
||||
"service": {
|
||||
"addTitle": "Add service record",
|
||||
"editTitle": "Edit service record",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"saved": "Zapisano ✓",
|
||||
"loading": "Ładowanie…",
|
||||
"edit": "Edytuj",
|
||||
"open": "Otwórz",
|
||||
"remove": "Usuń",
|
||||
"delete": "Usuń",
|
||||
"done": "Gotowe",
|
||||
@@ -89,6 +90,7 @@
|
||||
"title": "Twoje samochody",
|
||||
"subtitle": "Przegląd serwisowy i historia napraw.",
|
||||
"addCar": "Dodaj samochód",
|
||||
"importCar": "Importuj z serwisu",
|
||||
"empty": "Nie masz jeszcze samochodów. Kliknij {action}, aby zacząć.",
|
||||
"shared": "Udostępniony",
|
||||
"sharedReadOnly": "Udostępniony · tylko do odczytu",
|
||||
@@ -246,6 +248,7 @@
|
||||
"sharedReadOnly": "Udostępniony · tylko do odczytu",
|
||||
|
||||
"tabs": {
|
||||
"connected": "Połączona usługa",
|
||||
"info": "Informacje",
|
||||
"services": "Historia serwisowa",
|
||||
"technical": "Historia przeglądów",
|
||||
@@ -256,6 +259,50 @@
|
||||
"reminders": "Przypomnienia"
|
||||
},
|
||||
|
||||
"provider": {
|
||||
"subtitle": "Dane na żywo z Twojego konta {label}.",
|
||||
"refresh": "Odśwież",
|
||||
"refreshing": "Odświeżanie…",
|
||||
"updated": "Zaktualizowano {time}",
|
||||
"vehicle": "Pojazd",
|
||||
"readings": "Aktualne odczyty",
|
||||
"noData": "{label} nie zwróciło żadnych danych dla tego samochodu.",
|
||||
"raw": "Surowa odpowiedź",
|
||||
"allFields": "Wszystkie zgłoszone pola",
|
||||
"truncated": "Wypisano tylko pierwsze {n} pól — pozostałe znajdziesz w surowej odpowiedzi poniżej.",
|
||||
"sectionEmpty": "Brak danych.",
|
||||
"own": "Używane jest wyłącznie Twoje własne konto, więc dane logowania nigdy nie są udostępniane wraz z samochodem.",
|
||||
"odometerSuggest": "{label} podaje {km}, czyli więcej niż zapisany przebieg tego samochodu.",
|
||||
"updateOdometer": "Zaktualizuj przebieg",
|
||||
"updatingOdometer": "Aktualizowanie…",
|
||||
"unlink": "Odłącz",
|
||||
"unlinkConfirm": "Odłączyć ten samochód od {label}? Żadne zapisane dane nie zostaną usunięte.",
|
||||
"connectTitle": "Połącz ten samochód z usługą",
|
||||
"connectHint": "Wybierz pojazd ze swojego konta, który odpowiada temu samochodowi. Jego dane pojawią się tutaj.",
|
||||
"connectSubmit": "Połącz pojazd",
|
||||
"connecting": "Łączenie…",
|
||||
"noProviders": "Nie połączono żadnego konta producenta. Dodaj je w Ustawieniach › Integracje.",
|
||||
"settingsLink": "Otwórz Ustawienia",
|
||||
"sections": {
|
||||
"telemetry": "Przebieg i zasięg",
|
||||
"electric": "Akumulator i ładowanie",
|
||||
"status": "Drzwi, szyby i światła",
|
||||
"health": "Stan pojazdu",
|
||||
"location": "Ostatnia znana lokalizacja",
|
||||
"serviceHistory": "Historia serwisowa u dealera",
|
||||
"notifications": "Powiadomienia"
|
||||
},
|
||||
"metrics": {
|
||||
"odometer": "Przebieg",
|
||||
"fuelLevel": "Poziom paliwa",
|
||||
"fuelRange": "Zasięg",
|
||||
"batteryLevel": "Akumulator",
|
||||
"evRange": "Zasięg elektryczny",
|
||||
"chargingStatus": "Ładowanie",
|
||||
"location": "Pozycja"
|
||||
}
|
||||
},
|
||||
|
||||
"info": {
|
||||
"oilSpec": "Specyfikacja oleju silnikowego",
|
||||
"transmissionOil": "Olej przekładniowy",
|
||||
@@ -468,6 +515,29 @@
|
||||
"submit": "Dodaj samochód"
|
||||
},
|
||||
|
||||
"import": {
|
||||
"title": "Importuj samochód",
|
||||
"subtitle": "Utwórz samochód na podstawie pojazdu z Twojego konta u producenta. Wszystko, co da się odczytać, zostanie wypełnione automatycznie.",
|
||||
"service": "Usługa",
|
||||
"loadingVehicles": "Wczytywanie Twoich pojazdów…",
|
||||
"noVehicles": "Brak pojazdów na tym koncie.",
|
||||
"notConnected": "Nie połączono",
|
||||
"noProviders": "Nie połączono żadnego konta producenta. Dodaj je w Ustawieniach › Integracje.",
|
||||
"alreadyInGarage": "Już w Twoim garażu",
|
||||
"selectVehicle": "Pojazd",
|
||||
"dataTitle": "Co zaimportować",
|
||||
"dataHint": "Odznacz to, co wolisz wpisać samodzielnie.",
|
||||
"includeIdentity": "Marka, model, rok, rejestracja i VIN",
|
||||
"includeFuelType": "Rodzaj paliwa",
|
||||
"includeDates": "Data produkcji i pierwszej rejestracji",
|
||||
"includeOdometer": "Aktualny przebieg",
|
||||
"name": "Nazwa samochodu",
|
||||
"submit": "Importuj samochód",
|
||||
"importing": "Importowanie…",
|
||||
"warningOdometer": "Usługa nie podała przebiegu — wpisz go samodzielnie w samochodzie.",
|
||||
"moreData": "Pozostałe dane z tej usługi pozostają dostępne w karcie {label} samochodu."
|
||||
},
|
||||
|
||||
"service": {
|
||||
"addTitle": "Dodaj wpis serwisowy",
|
||||
"editTitle": "Edytuj wpis serwisowy",
|
||||
|
||||
Reference in new issue
Block a user