WFDASH-WEBAPP/scripts
Dave 6fd11f4af0 feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection
Groundwork for the rep visit check-in feature: a rep taps "I'm on site",
the vehicle's tracker position surfaces which customers are there, and
the visit is logged against them.

Pure/unit-testable layers only — no PocketBase writes and no UI yet,
both of which are blocked on schema that has to be added in the PB
admin first. Design doc: docs/superpowers/specs/2026-09-05-rep-visit-check-in-design.md

- lib/visit-matching.ts   rankNearbyCustomers: radius match around a
                          point, rep's own customers first
- lib/visit-stops.ts      detectStops: breadcrumb trail -> stops.
                          Anchor-based clustering rather than a running
                          centroid, which would let a slow crawl chain
                          into one bogus stationary stop
- lib/tracker-parsing.ts  Netstar FleetAI response decoding
- lib/server/tracker-service.ts
                          FleetAiAdapter + FakeTrackerAdapter behind a
                          TrackerAdapter seam. The fake is auto-selected
                          when no credentials are configured, so the rest
                          of the feature builds and tests without vendor
                          access.
- lib/geo.ts              isRealGeoPoint, lifting the Null-Island guard
                          that was inlined identically in customers/[id]
                          and companies/[id]

Three FleetAI conventions drive real code here and are each pinned by a
test: errors arrive as HTTP 200 with a failure envelope; "--" means
"unavailable" and is not null (and for IGN, not false); timestamps are
platform-local UTC+2 with no offset marker, so parsing them naively puts
every fresh fix two hours in the past.

FleetAI has no position-history endpoint, so the design polls
getTokenBaseLiveData (whole fleet in one call) and keeps its own trail.
scripts/fleetai-probe.mjs is a throwaway read-only probe to confirm the
three account-shaped assumptions before more is built on top.

102 tests pass. The 9 pre-existing failing test files elsewhere in the
suite were verified identical on a stashed tree and are unrelated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 14:22:28 +02:00
..
__pycache__ feat(mcp): enhance API documentation and add new tools 2026-08-15 00:06:40 +02:00
dev
migrations chore(pos): add pos_slip_layouts PB collection for the slip layout editor 2026-09-04 12:46:17 +02:00
perf feat: add new order, invoice, and dashboard management tools 2026-08-05 23:00:54 +02:00
smoke feat(item-intel): add new item intel popover and backend workflows 2026-08-11 02:57:57 +02:00
utils
2026-08-03-load-husqvarna-cart.ts
2026-08-03-load-yg1-quote-soq078608.ts
2026-08-03-merge-yg1-drafts.ts
2026-08-13-heal-item-intel.ts feat(tv): add TV dashboard + refine workflows 2026-08-13 20:55:22 +02:00
2026-08-21-backfill-order-duplicates.ts feat(orders): enhance order handling with email_message_id deduplication and displayContactName utility 2026-08-21 19:18:02 +02:00
_env.ts feat(tv): add TV dashboard + refine workflows 2026-08-13 20:55:22 +02:00
audit-pb-fields.py
backfill-item-intel.ts feat(item-intel): add new item intel popover and backend workflows 2026-08-11 02:57:57 +02:00
backfill-po-items.mjs
build_v5_workflow.py
deploy_v5_to_n8n.py
fleetai-probe.mjs feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection 2026-09-06 14:22:28 +02:00
import-data.ts
mcp-doc-gen.py feat(mcp): enhance API documentation and add new tools 2026-08-15 00:06:40 +02:00
mrbxnim4-telegram-cloud-photo-size-4-6016860144018328845-y.jpg
n8n-v2-error.ts
n8n-v2-main.ts
quotes.pb.js
regenerate-delivery-note-pdfs.ts feat: add driverless collection confirm and new order tooling 2026-08-12 01:13:46 +02:00
seed-gielie-quotes.py
setup-pocketbase.ts
verify_v5.py