Skip to content

feat(api,domain): add batch commands endpoint and seed file tooling#10

Open
Wedvich wants to merge 1 commit intomainfrom
feat/batch-commands-and-seed
Open

feat(api,domain): add batch commands endpoint and seed file tooling#10
Wedvich wants to merge 1 commit intomainfrom
feat/batch-commands-and-seed

Conversation

@Wedvich
Copy link
Copy Markdown
Owner

@Wedvich Wedvich commented Mar 22, 2026

Summary

  • POST /api/sync/commands/batch — accepts a SeedFile (version + ordered command array) and processes each command through the existing dispatch pipeline within a single transaction. All-or-nothing atomicity: if any command fails, the entire batch rolls back with the index and reason.
  • snapshotsToSeedFile() in @heim/domain — converts bootstrap snapshots into a re-importable seed file. Built-in converters for ProductType and StockItem, extensible via registerSeedConverter(). Tenant/User always excluded. Output sorted by dependency priority (ProductType before StockItem).
  • Batch endpoint reuses existing loadStreamEvents, commandRegistry.handle(), appendEvents, and projectorRegistry.apply() — no new DB setup or duplicated wiring.

Test plan

  • Domain: 10 seed tests — conversion, ordering, filtering, exclusions, edge cases
  • API: 6 batch endpoint tests — auth, validation (empty/unsupported version), unknown stream type, success with multiple commands, rollback on rejection
  • yarn turbo typecheck — clean
  • yarn turbo test — 84 domain + 118 API tests pass
  • yarn turbo lint — clean

🤖 Generated with Claude Code

Add POST /api/sync/commands/batch for importing seed data through the
normal command pipeline, and snapshot-to-seed conversion utilities in
@heim/domain for exporting current state as re-importable seed files.

Co-Authored-By: Claude Opus 4.6 (1M context) <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