Skip to content

Migrate household handling to API v2 alpha structures#622

Draft
anth-volk wants to merge 3 commits intomove-to-api-v2from
feat/migrate-households-to-v2
Draft

Migrate household handling to API v2 alpha structures#622
anth-volk wants to merge 3 commits intomove-to-api-v2from
feat/migrate-households-to-v2

Conversation

@anth-volk
Copy link
Collaborator

Fixes #621

Summary

  • Migrates the app's internal household representation from API v1 format to API v2 Alpha format
  • Introduces legacyConversion.ts as an anti-corruption layer at the API boundary (v1↔v2 conversion) so all code below the API layer is pure v2
  • Rewrites types, adapter, utilities, hooks, components, tests, and fixtures for array-based entities with flat values and numeric IDs
  • Cleans up all dead deprecated types, fixes broken type guards, removes vestigial _year parameter threading

What changed

Layer Changes
Types New Household interface with tax_benefit_model_name, year, people: HouseholdPerson[], array-based entity groups
Anti-corruption legacyConversion.ts — 4 call sites in src/api/ and hooks; to be deleted when API v2 endpoints ship
Adapter HouseholdAdapter updated for v2 format
Utilities HouseholdBuilder, HouseholdQueries, HouseholdValidation, householdValues, VariableResolver, and others rewritten for arrays
Hooks useCreateHousehold, useUserHousehold, useHouseholdVariation updated
Components HouseholdBuilderForm, VariableInput, VariableRow, entity display components updated
Cleanup Deleted 8 dead deprecated types, fixed isHousehold/isGeography type guards, removed _year prop threading, deleted dead v1 test fixtures and mock JSON

Requires API v2 alpha changes

This PR introduces a legacyConversion.ts anti-corruption layer because the API v1 endpoints are still live. New endpoints must be created in policyengine-api-v2-alpha to accept and return the v2 household format. Once those endpoints are available, legacyConversion.ts and its 4 call sites can be deleted entirely.

Test plan

  • TypeScript: 0 type errors (npx tsc --noEmit)
  • Tests: 2713 passed, 0 failures (npx vitest run)
  • Manual: verify household builder form creates/edits households correctly
  • Manual: verify report output pages render household data correctly

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment Feb 2, 2026 7:01pm
policyengine-calculator Ready Ready Preview, Comment Feb 2, 2026 7:01pm
policyengine-website Ready Ready Preview, Comment Feb 2, 2026 7:01pm

Request Review

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