Skip to content

Add draft dataset JSON import mapper#1029

Open
eleven-smg wants to merge 3 commits into
Stellar-Mail:mainfrom
eleven-smg:feat/dataset-json-import-272
Open

Add draft dataset JSON import mapper#1029
eleven-smg wants to merge 3 commits into
Stellar-Mail:mainfrom
eleven-smg:feat/dataset-json-import-272

Conversation

@eleven-smg

Copy link
Copy Markdown
Contributor

Closes #272

Adds a campaign/draft dataset JSON import mapper for the demo admin dashboard. It is the inverse of the existing dataset JSON export (#190): it takes an imported JSON payload and maps it into review-safe drafts that can be loaded into the draft dataset store.

What's included (all under src/features/demo-admin-dashboard/):

  • types/datasetImport.ts — DatasetImportResult and DatasetImportIssue types
  • helpers/datasetImport.ts — mapImportedDataset() and parseDatasetImport()
  • tests/datasetImport.test.ts — 8 unit tests
  • docs/DATASET_JSON_IMPORT.md — usage and validation rules

Behaviour:

  • Validates the envelope shape and schema version (DATASET_EXPORT_SCHEMA_VERSION)
  • Validates each draft (non-empty id, string subject/body, recipients array)
  • Enforces safe demo recipient addresses (example.com / example.org / *stealth.demo)
  • Rejects duplicate draft ids and mismatched count
  • Strips unknown fields from imported drafts
  • Atomic import: if any issue is found, no drafts are returned, with a list of human-readable errors
  • All data stays fake, deterministic, and safe for public review; no files outside the feature folder were changed

Checks run locally: prettier, tsc --noEmit, eslint (0 errors), vitest (8 passed), and build all pass.

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.

Build campaign import mapper

1 participant