Skip to content

Add first-class Trailer data models - #75

Open
roncodes wants to merge 3 commits into
release/v0.2.0from
feature/first-class-trailers
Open

Add first-class Trailer data models#75
roncodes wants to merge 3 commits into
release/v0.2.0from
feature/first-class-trailers

Conversation

@roncodes

@roncodes roncodes commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

Trailer data contracts for the Fleet-Ops console, completing the first-class Trailer feature (fleetbase/fleetops#309).

  • trailer model: first-class towed asset extending asset, with towing (current_vehicle, current_connection, connections), capacity, running-gear, reefer, ownership and telemetry attributes. Declares attachment_state and vehicle_id (previously missing, so the console never saw the attachment state) and derives displayName, isAttached, isOnline, lastOnlineAt, lastOnlineAgo and attachedAt.
  • asset-connection model: effective-dated towing connection with isActive, formatted connectedAt/disconnectedAt and a human duration.
  • attachable-trailer, attachable-driver and maintenance-subject-trailer polymorphic models. attachable-driver was missing, so equipment issued to a driver failed to normalize once the equipment serializer started embedding equipable.
  • Serializers: trailer embeds category, vendor, warranty, photo, custom field values and the read-only towing/device/equipment projections; asset-connection embeds vehicle and trailer; device and equipment resolve fleet-ops:trailer/fleet-ops:driver polymorphic types.
  • vehicle gains trailers, trailer_connections and equipments relationships with explicit inverses.

Contract

The console API answers { "trailers": [...], "meta": {...} } for collections and { "trailer": {...} } for records; embedded relationships are always present (empty arrays when not loaded). Tests cover both envelopes, the empty collection, embedded towing state, the derived projections and the polymorphic driver mapping.

Live map popover

The live vehicles feed now embeds each vehicle's currently coupled trailers next to its devices, so the vehicle serializer declares trailers as an embedded relationship. A normalizeResponse test covers the embedded trailers and devices.

Validation

  • eslint on the changed files passes.
  • Unit tests were added for the model projections, serializer normalization (query and single-record envelopes) and the driver mapping. They were not executed locally: ember test in this workspace launches Chrome through testem and was stopped at the user's request; CI is the authoritative run.

Related PRs

- Declare attachment_state and vehicle_id on the Trailer model; the console
  never received the attachment state because the attribute was missing.
- Add displayName, isAttached, isOnline, and formatted last-online/attached-at
  projections to Trailer, and formatted timing plus duration to AssetConnection.
- Add the attachable-driver model so equipment issued to a driver normalizes
  instead of failing on an unknown model.
- Set explicit inverses on the vehicle trailer/equipment relationships and
  embed the trailer category.
- Cover query and single-record envelope normalization, the new projections,
  and the driver mapping.
The live map feed now sends each vehicle's currently coupled trailers alongside
its devices so map popovers can list both. Declare the relationship as embedded
so normalization pushes the trailer records instead of treating the objects as
ids, and cover it with a normalizeResponse test.
@roncodes roncodes mentioned this pull request Sep 8, 2026
@roncodes
roncodes changed the base branch from main to release/v0.2.0 September 8, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant