chore(web): swap flowsApi mock for real NF-7 endpoints #366

Closed
opened 2026-04-24 16:45:31 +00:00 by code-lead · 0 comments
Collaborator

Switch apps/web/src/features/flows/flowsApi.ts from the seed-fixture mocks to real server endpoints, now that NF-7 (#363) landed the POST /flows / PATCH /flows/:id / POST /flows/:id/dry-run / POST /flows/:id/enable|disable / DELETE /flows/:id / POST /flows/:id/revert / GET /flows/:id/versions surface.

Scope

Mechanical swap — the existing function signatures (list, getFlow, setEnabled, remove, updateFlow, getMode, listRuns, getRun) are already shaped like the server routes. Replace each mock body with a fetch call, keep the signatures identical.

Endpoints to wire

  • list()GET /flows
  • getFlow(id, version?)GET /flows/:id (current) or GET /flows/:id/versions/:version when version is set
  • updateFlow(id, body)PATCH /flows/:id (POST when the flow is new — branch on a local isNew bit or fall back to POST→404→PATCH)
  • setEnabled(id, enabled)POST /flows/:id/enable or /disable
  • remove(id)DELETE /flows/:id
  • getMode()GET /flows/mode (endpoint ships with NF-7; verify)
  • listRuns(opts)GET /flows/runs?limit&before&flowId
  • getRun(runId)GET /flows/runs/:id

What to keep

  • FlowValidationError / FlowsApiError — already parallel the server's 422/403/404 responses.
  • Type shapes (FlowSummary, FlowRunSummary, FlowNodeRun, etc.) — server mirror is already in sync.
  • All the tests that mock flowsApi via dependency injection continue to work — they bypass fetch.

What to drop

  • Seed fixtures (apps/web/src/fixtures/flows.json, flow-graphs.json, flow-runs.json, flow-config.json) — keep them as test fixtures but stop importing them from production flowsApi.
  • The mock in-memory stores (graphStore, flowRunsStore, etc.) — gone entirely once fetch replaces them.
  • Tests that assert the mock behaviour directly (list ordering, optimistic rollback against 403) — rewrite to inject a fetch mock instead.

Acceptance

  • flowsApi.ts fetches every endpoint against /flows/* on the same host.
  • Tests pass: every existing flowsApi test refactored to mock fetch instead of the in-memory store.
  • bun x turbo run typecheck + bun x biome check clean.
  • Swap does not regress any UI flow: list page loads, editor saves, runs drawer populates, replay enters mode.
  • Auth header handling: the real server auth-gates mutations. Wire the operator token / forward-auth header through.

Out of scope

  • Real-time SSE subscription for the runs drawer — separate story.
  • Version-diff visualisation (NF-UI-9) — waits for GET /flows/:id/versions which already ships.

References

  • NF-7 #363 server surface.
  • NF-6 #360 executor wiring.
  • Spec: specs/node-flows.md + specs/node-flows-ui.md.

Dependencies

Switch `apps/web/src/features/flows/flowsApi.ts` from the seed-fixture mocks to real server endpoints, now that NF-7 (#363) landed the `POST /flows` / `PATCH /flows/:id` / `POST /flows/:id/dry-run` / `POST /flows/:id/enable|disable` / `DELETE /flows/:id` / `POST /flows/:id/revert` / `GET /flows/:id/versions` surface. ## Scope Mechanical swap — the existing function signatures (`list`, `getFlow`, `setEnabled`, `remove`, `updateFlow`, `getMode`, `listRuns`, `getRun`) are already shaped like the server routes. Replace each mock body with a `fetch` call, keep the signatures identical. ### Endpoints to wire - `list()` → `GET /flows` - `getFlow(id, version?)` → `GET /flows/:id` (current) or `GET /flows/:id/versions/:version` when `version` is set - `updateFlow(id, body)` → `PATCH /flows/:id` (POST when the flow is new — branch on a local `isNew` bit or fall back to POST→404→PATCH) - `setEnabled(id, enabled)` → `POST /flows/:id/enable` or `/disable` - `remove(id)` → `DELETE /flows/:id` - `getMode()` → `GET /flows/mode` (endpoint ships with NF-7; verify) - `listRuns(opts)` → `GET /flows/runs?limit&before&flowId` - `getRun(runId)` → `GET /flows/runs/:id` ### What to keep - `FlowValidationError` / `FlowsApiError` — already parallel the server's 422/403/404 responses. - Type shapes (`FlowSummary`, `FlowRunSummary`, `FlowNodeRun`, etc.) — server mirror is already in sync. - All the tests that mock `flowsApi` via dependency injection continue to work — they bypass fetch. ### What to drop - Seed fixtures (`apps/web/src/fixtures/flows.json`, `flow-graphs.json`, `flow-runs.json`, `flow-config.json`) — keep them as test fixtures but stop importing them from production `flowsApi`. - The mock in-memory stores (`graphStore`, `flowRunsStore`, etc.) — gone entirely once fetch replaces them. - Tests that assert the mock behaviour directly (list ordering, optimistic rollback against 403) — rewrite to inject a fetch mock instead. ## Acceptance - [ ] `flowsApi.ts` fetches every endpoint against `/flows/*` on the same host. - [ ] Tests pass: every existing flowsApi test refactored to mock `fetch` instead of the in-memory store. - [ ] `bun x turbo run typecheck` + `bun x biome check` clean. - [ ] Swap does not regress any UI flow: list page loads, editor saves, runs drawer populates, replay enters mode. - [ ] Auth header handling: the real server auth-gates mutations. Wire the operator token / forward-auth header through. ## Out of scope - Real-time SSE subscription for the runs drawer — separate story. - Version-diff visualisation (NF-UI-9) — waits for `GET /flows/:id/versions` which already ships. ## References - NF-7 #363 server surface. - NF-6 #360 executor wiring. - Spec: `specs/node-flows.md` + `specs/node-flows-ui.md`. ## Dependencies - NF-7 (#328, merged via #363).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#366
No description provided.