Skip to content

Migrate household handling to API v2 alpha structures#622

Merged
anth-volk merged 18 commits intomove-to-api-v2from
feat/migrate-households-to-v2
Feb 17, 2026
Merged

Migrate household handling to API v2 alpha structures#622
anth-volk merged 18 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 17, 2026 10:43pm
policyengine-calculator Ready Ready Preview, Comment Feb 17, 2026 10:43pm
policyengine-website Ready Ready Preview, Comment Feb 17, 2026 10:43pm

Request Review

anth-volk and others added 17 commits February 17, 2026 23:11
- Fix VariableResolver.getVariableInfo() to read variable.default_value
  (snake_case) instead of variable.defaultValue (camelCase)
- Update test fixtures to use default_value to match API response format

The API returns default_value in snake_case, and MetadataAdapter preserves
this naming. The VariableInfo interface still uses camelCase defaultValue
for consistency with the rest of the frontend code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add test fixtures for variable input mocking in fixtures/components/household/
- Add VariableInput tests for hideLabel prop, data type rendering, disabled state
- Add VariableRow tests for label display, remove button, disabled state

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete migrationService.ts and its tests entirely. Remove migration
functions (isMigrationComplete, markMigrationComplete, clearMigrationFlag)
and MIGRATION_COMPLETE storage key from userIdentity. Migration
functionality will be built separately once all ingredient APIs are
properly set up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ebase

Remove unused imports (useRegionsList, CURRENT_YEAR, useMemo, useEntities),
add missing Household type import, fix jsx-boolean-value lint errors, and
format 30 files with Prettier.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anth-volk anth-volk marked this pull request as ready for review February 17, 2026 22:55
@anth-volk anth-volk merged commit 6279d05 into move-to-api-v2 Feb 17, 2026
7 checks passed
@anth-volk anth-volk deleted the feat/migrate-households-to-v2 branch February 17, 2026 22:55
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

Comments