Skip to content

Add JSON import feature with four-phase validation#269

Open
rburman-tech wants to merge 1 commit into
mpigsley:masterfrom
rburman-tech:master
Open

Add JSON import feature with four-phase validation#269
rburman-tech wants to merge 1 commit into
mpigsley:masterfrom
rburman-tech:master

Conversation

@rburman-tech
Copy link
Copy Markdown
Contributor

Closes the round-trip gap opened by #268 (export now includes routes, layers, factions).

What this adds

  • Import button in the sector sidebar (owners only, not shared views)
  • "Download for Import" button in the import modal that exports raw JSON (unlocalized keys, required for reimport)
  • Four-phase validator that runs before any Firestore write:
    • Phase 1: top-level structure
    • Phase 2: per-entity schema and attribute enum values
    • Phase 3: ID-reference graph (parent chains, orphan detection, cycle detection, faction asset locations)
    • Phase 4: coordinate bounds and hex collision detection
  • Scrollable error list in the UI so users see all problems at once
  • 40 unit tests covering every phase and failure mode

Design notes

The validator is a pure function (no Firestore reads) so it can be tested exhaustively and fails cleanly before touching any data. Raw JSON format is required for import because translateEntities localizes attribute values — reimporting a translated export would corrupt the app.

- Pure validateImport() function (4 phases: structure, schema, ID references, coordinates) with 40 passing tests
- Import modal with raw JSON download (no translateEntities), file picker, per-field error display, and upload flow
- Import thunk remaps faction homeworld/asset location IDs after Cloud Function returns mapping
- Import button added to ActionLayout sidebar (saved, non-shared sectors only)
- Redux state for isImportOpen + i18n keys added to 6 language files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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