📌 Description
AnchorService.registerBulk already validates an entire batch (duplicate ids, conflicts with the existing registry) before persisting any of it. Integrators building an onboarding UI would benefit from being able to run that same validation as a preflight check — e.g. to show inline errors before committing — without actually registering the anchors.
🧩 Requirements and context
- Accept an optional
?dryRun=true query param on POST /api/v1/anchors/bulk.
- When set, run the exact same validation
registerBulk already performs, but return the would-be-registered anchors (or a success indicator) without calling this.repo.upsert for any of them.
- Validation errors (duplicate/conflicting ids) must behave identically in dry-run and real mode.
🛠️ Suggested execution
- Refactor
src/services/anchorService.ts's registerBulk to separate the "validate" and "persist" phases internally (it likely already does this via its parsed intermediate array), then add a dryRun boolean parameter that skips the persist phase.
- Modify
src/routes/anchors.ts's POST /bulk handler to read req.query.dryRun and pass it through.
- Update
src/openapi.ts with the new parameter.
- Add tests in
src/services/anchorService.test.ts and src/routes/anchors.test.ts asserting dry-run mode reports the same validation outcome but leaves the repository unchanged.
✅ Acceptance criteria
🔒 Security notes
N/A — read-only preflight validation; no new data exposure, and explicitly prevents any persistence side effect when requested.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
AnchorService.registerBulkalready validates an entire batch (duplicate ids, conflicts with the existing registry) before persisting any of it. Integrators building an onboarding UI would benefit from being able to run that same validation as a preflight check — e.g. to show inline errors before committing — without actually registering the anchors.🧩 Requirements and context
?dryRun=truequery param onPOST /api/v1/anchors/bulk.registerBulkalready performs, but return the would-be-registered anchors (or a success indicator) without callingthis.repo.upsertfor any of them.🛠️ Suggested execution
src/services/anchorService.ts'sregisterBulkto separate the "validate" and "persist" phases internally (it likely already does this via itsparsedintermediate array), then add adryRunboolean parameter that skips the persist phase.src/routes/anchors.ts'sPOST /bulkhandler to readreq.query.dryRunand pass it through.src/openapi.tswith the new parameter.src/services/anchorService.test.tsandsrc/routes/anchors.test.tsasserting dry-run mode reports the same validation outcome but leaves the repository unchanged.✅ Acceptance criteria
POST /api/v1/anchors/bulk?dryRun=truereturns the same success/error outcome as a real call would, but registers nothing.AnchorRepository.count()/all()before and after.🔒 Security notes
N/A — read-only preflight validation; no new data exposure, and explicitly prevents any persistence side effect when requested.
📋 Guidelines