feat(seed): admin import/export API for seed data (PSA-52 part 1) #344
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PSA-52-admin-import-export"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The API layer of the in-app import/export capability (David's convergence: seeding is the same mechanism as importing a customer's data). Makes the canonical seed format round-trippable and exposes admin-gated import + export endpoints. The web admin UI and Yousif's first-run setup choices land in part 2.
What's here
Serialize+PartialEq, so aSeedFilecan be written back out.canonical_format_round_tripsproves parse -> serialize -> parse reproduces it - the guarantee behind "export then import reproduces state".seed::exportserializes current seed-owned data back into aSeedFile: users + feedback under the reserved domain (newUserRepository::list_seed_users/FeedbackRepository::list_seed_by_domain, the same suffix scope reset uses), plus the full catalog of groups/applications. Password hashes are never emitted (no schema field for them), so a re-import assignsdefault_password; exported accounts should be treated as needing a reset.GET /v1/admin/seed/export- JSON file download (read-only, admin-gated).POST /v1/admin/seed/import- loads a posted file through the shared loader (admin-gated). Additionally runsseed_guard, so demo data can never be written into a production/unset environment even by an admin.Scope
Scoped to seed-owned data (reserved domain) so a round trip re-imports cleanly. General customer-data import/export (arbitrary domains, password sourcing) depends on the PSA-56
owns/password_envgeneralizations.Part 2 (follow-up): the web admin import/export page (upload + download) and first-run setup choices (start empty / load template / custom), with
demo-msp+minimaltemplates.Acceptance criteria (this PR)
GET /v1/admin/seed/export.POST /v1/admin/seed/import.canonical_format_round_tripsat the format level; DB round-trip runs against a dev database.Still open (part 2): the admin UI and first-run setup choices.
Verification
just check-containergreen (fmt + clippy-D warnings+cargo test --workspace --all-targets; seed lib 54 tests incl. the round-trip). Endpoints + export mapper are compile- and clippy-checked; DB behavior runs against a dev Postgres (the container check has none).#PSA-52