Skip to content

Latest commit

 

History

History
130 lines (98 loc) · 5.24 KB

File metadata and controls

130 lines (98 loc) · 5.24 KB

Milestone 5 Result — First Read-Only API Endpoints + React Pages

Date: 2026-05-19 Branch: main Result: Complete — 0 build errors, 914/914 tests pass.


1. What Was Done

Backend — three endpoint groups added

LSPDFRManager.LocalApi/Dtos/ — three new DTO files:

  • HistoryDtos.csChangeHistoryEntryDto, HistoryResponse
  • LogDtos.csLogFileInfoDto, LogsAvailableResponse, LogLinesResponse
  • CompatibilityDtos.csComponentVersionDto, CompatibilityResponse

LSPDFRManager.LocalApi/Endpoints/ — three new endpoint extension classes:

HistoryEndpoints.csGET /api/v1/history?limit=50&offset=0

  • Reads change_history.json directly (no WPF service singleton dependency)
  • Paginates: limit clamped 1–500, offset ≥ 0
  • Converts ChangeHistoryAction enum to string via .ToString()
  • Returns HistoryResponse(entries, total)

LogEndpoints.csGET /api/v1/logs + GET /api/v1/logs/{name}?tail=200

  • Safe name mapping server-side: manager, browse-api, rph, scripthookv, scripthookvdotnet
  • Actual file paths never exposed in responses
  • /logs returns only files that currently exist on disk
  • /logs/{name} slices last N lines; tail clamped 1–1000; returns LogLinesResponse(name, label, lines, totalLines)

CompatibilityEndpoints.csGET /api/v1/compatibility

  • Calls VersionDetectorService.DetectAsync(AppConfig.Instance.GtaPath)
  • Returns 5 components: GTA5, LSPDFR, RagePluginHook, ScriptHookV, ScriptHookVDotNet
  • Handles unconfigured/missing GTA path gracefully — returns all present: false, gtaPathConfigured: false

Program.cs — added app.MapHistory(), app.MapLogs(), app.MapCompatibility()

LocalApiHost.cs — same three endpoint registrations wired into the in-process host

Frontend — types, API clients, real pages

frontend/src/types/ — three new type files:

  • history.tsChangeHistoryEntryDto, HistoryResponse
  • logs.tsLogFileInfoDto, LogsAvailableResponse, LogLinesResponse
  • compatibility.tsComponentVersionDto, CompatibilityResponse

frontend/src/lib/api/ — three new API client modules:

  • history.tsfetchHistory(limit, offset)
  • logs.tsfetchAvailableLogs(), fetchLogLines(name, tail)
  • compatibility.tsfetchCompatibility()

Stub pages replaced with real pages (useQuery-driven):

  • HistoryPage.tsx — paginated list with action badge, affected file, timestamp
  • LogsPage.tsx — sidebar log selector, tail-count dropdown, scrollable pre block
  • DashboardPage.tsx — component version cards (green Present / grey Not found), GTA path warning

routeConfig.ts/, /history, /logsstatus: 'in-progress'


2. Safety Constraints Honored

  • No write, install, uninstall, restore, backup, or filesystem mutation endpoints added
  • PathSafety not bypassed — log endpoints use a hard-coded name→path mapping; no user-supplied paths reach the filesystem
  • GtaBaselineService not used (WPF-bound via ModLibraryService) — compatibility endpoint uses VersionDetectorService only
  • No WPF-bound services exposed through LocalApi
  • No WPF files deleted or weakened
  • No tests removed or weakened

3. Commands Run and Results

Command Result
npm run typecheck Pass — 0 errors
npm run lint Pass — 0 errors
npm run build Pass — 97 modules, wwwroot updated
dotnet build LSPDFRManager.sln --no-incremental Pass — 0 errors
dotnet test Pass — 914/914

4. Files Created or Modified

New files

  • LSPDFRManager.LocalApi/Dtos/HistoryDtos.cs
  • LSPDFRManager.LocalApi/Dtos/LogDtos.cs
  • LSPDFRManager.LocalApi/Dtos/CompatibilityDtos.cs
  • LSPDFRManager.LocalApi/Endpoints/HistoryEndpoints.cs
  • LSPDFRManager.LocalApi/Endpoints/LogEndpoints.cs
  • LSPDFRManager.LocalApi/Endpoints/CompatibilityEndpoints.cs
  • frontend/src/types/history.ts
  • frontend/src/types/logs.ts
  • frontend/src/types/compatibility.ts
  • frontend/src/lib/api/history.ts
  • frontend/src/lib/api/logs.ts
  • frontend/src/lib/api/compatibility.ts
  • MILESTONE5_RESULT.md

Modified files

  • LSPDFRManager.LocalApi/Program.cs — endpoint registrations
  • LSPDFRManager.LocalApi/LocalApiHost.cs — endpoint registrations
  • frontend/src/pages/HistoryPage.tsx — replaced stub
  • frontend/src/pages/LogsPage.tsx — replaced stub
  • frontend/src/pages/DashboardPage.tsx — replaced stub
  • frontend/src/routes/routeConfig.ts/, /history, /logs → in-progress

5. API Surface Added

Method Path Response
GET /api/v1/history?limit=50&offset=0 HistoryResponse
GET /api/v1/logs LogsAvailableResponse
GET /api/v1/logs/{name}?tail=200 LogLinesResponse
GET /api/v1/compatibility CompatibilityResponse

6. Remaining Work

  • Vite dev proxy (/api → LocalApi port) for npm run dev workflow
  • Pagination UI on HistoryPage (next/previous buttons)
  • Log auto-refresh / polling option
  • IDE Roslyn type-conflict hints (double Shared reference) — deferred to Milestone 14+
  • Session token for DNS rebinding protection (Milestone 9)
  • Remaining 14 stub pages (Milestones 6–13)