ChicoryTV SPA: typed API client + auth #81

Closed
opened 2026-07-02 01:07:17 +02:00 by timothy · 1 comment
Owner

Generate a typed client for the ErsatzTV REST API and wire authentication so screens can pull live data.

Do

  • Generate a TypeScript client from the OpenAPI doc (ErsatzTV/wwwroot/openapi); wire into CI so it stays in sync.
  • Data-fetching layer (e.g. TanStack Query) with error/loading conventions.
  • Auth: API-key / session handling per the REST API design (docs/rest-api.md, #2).

Acceptance: SPA can call the API with a typed client and auth; a smoke screen renders live data (e.g. channel list).

Generate a typed client for the ErsatzTV REST API and wire authentication so screens can pull live data. **Do** - Generate a TypeScript client from the OpenAPI doc (`ErsatzTV/wwwroot/openapi`); wire into CI so it stays in sync. - Data-fetching layer (e.g. TanStack Query) with error/loading conventions. - Auth: API-key / session handling per the REST API design (`docs/rest-api.md`, #2). **Acceptance:** SPA can call the API with a typed client and auth; a smoke screen renders live data (e.g. channel list).
timothy added the frontend label 2026-07-02 01:07:17 +02:00
timothy added a new dependency 2026-07-02 01:08:41 +02:00
timothy added a new dependency 2026-07-02 01:08:41 +02:00
timothy added this to the Design system (Claude Design ↔ prod) milestone 2026-07-02 01:08:44 +02:00
Author
Owner

Done

What was done: Added the ChicoryTV SPA typed API client/auth foundation in commit d1cc12e0 (feat(web): add typed API client auth, pushed to docs/59-ui-redesign-brief).

  • Generated TypeScript API schema types from ErsatzTV/wwwroot/openapi/v1.json into web/src/api/generated/v1.d.ts using a repo-local generator script.
  • Added npm run generate:api and npm run check:api, and wired check:api into the existing Gitea SPA CI workflow so OpenAPI type drift fails CI.
  • Added API-key storage helpers for ctv-api-key and an auth-aware typed request wrapper that sends X-Api-Key for mutating requests only.
  • Added typed channel API access plus a useChannelsQuery data-fetching hook with loading/error/success conventions.
  • Added a live channel-list smoke panel to the SPA that renders loading, error, empty, and live data states from /api/channels.

Root cause: n/a; this was feature delivery.

Files changed: .gitea/workflows/docker-build.yml, web/package.json, web/scripts/generate-openapi-types.mjs, web/src/api/*, web/src/App.tsx, web/src/App.test.tsx, web/src/setupTests.ts, web/src/shell.css, and docs/superpowers/plans/2026-07-02-chicorytv-spa-typed-api-client-auth.md.

Verification:

  • cd web && npm run check:api — passed.
  • cd web && npm test -- --run — passed, 3 files / 17 tests.
  • cd web && npm run lint — passed.
  • cd web && npm run typecheck — passed.
  • cd web && npm run build — passed.
  • git status --short --branch — clean on docs/59-ui-redesign-brief...origin/docs/59-ui-redesign-brief.

Deferred: Did not add TanStack Query. The issue allowed an example data-fetching layer, and the current SPA has no query dependency; a focused typed hook covers the smoke screen and keeps dependency surface small. Also did not add an external OpenAPI generator dependency because openapi-typescript@7.13.0 conflicts with the repo's TypeScript 6 prerelease peer range, so the implementation uses a local generator script instead.

Follow-up issues: none required.

Docs updated: Added the implementation plan under docs/superpowers/plans/; REST API docs did not need changes because the API/auth contract itself did not change.

## Done **What was done**: Added the ChicoryTV SPA typed API client/auth foundation in commit `d1cc12e0` (`feat(web): add typed API client auth`, pushed to `docs/59-ui-redesign-brief`). - Generated TypeScript API schema types from `ErsatzTV/wwwroot/openapi/v1.json` into `web/src/api/generated/v1.d.ts` using a repo-local generator script. - Added `npm run generate:api` and `npm run check:api`, and wired `check:api` into the existing Gitea SPA CI workflow so OpenAPI type drift fails CI. - Added API-key storage helpers for `ctv-api-key` and an auth-aware typed `request` wrapper that sends `X-Api-Key` for mutating requests only. - Added typed channel API access plus a `useChannelsQuery` data-fetching hook with loading/error/success conventions. - Added a live channel-list smoke panel to the SPA that renders loading, error, empty, and live data states from `/api/channels`. **Root cause**: n/a; this was feature delivery. **Files changed**: `.gitea/workflows/docker-build.yml`, `web/package.json`, `web/scripts/generate-openapi-types.mjs`, `web/src/api/*`, `web/src/App.tsx`, `web/src/App.test.tsx`, `web/src/setupTests.ts`, `web/src/shell.css`, and `docs/superpowers/plans/2026-07-02-chicorytv-spa-typed-api-client-auth.md`. **Verification**: - `cd web && npm run check:api` — passed. - `cd web && npm test -- --run` — passed, 3 files / 17 tests. - `cd web && npm run lint` — passed. - `cd web && npm run typecheck` — passed. - `cd web && npm run build` — passed. - `git status --short --branch` — clean on `docs/59-ui-redesign-brief...origin/docs/59-ui-redesign-brief`. **Deferred**: Did not add TanStack Query. The issue allowed an example data-fetching layer, and the current SPA has no query dependency; a focused typed hook covers the smoke screen and keeps dependency surface small. Also did not add an external OpenAPI generator dependency because `openapi-typescript@7.13.0` conflicts with the repo's TypeScript 6 prerelease peer range, so the implementation uses a local generator script instead. **Follow-up issues**: none required. **Docs updated**: Added the implementation plan under `docs/superpowers/plans/`; REST API docs did not need changes because the API/auth contract itself did not change.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: timothy/ersatztv#81