2.5 KiB
2.5 KiB
Task D.7.5 CSV Commit Import Engine
Date: 2026-07-03 Status: implemented
Scope Delivered
- Added protected commit API:
POST /api/setup/import/commit
- Added setup CSV commit service:
src/features/setup/server/csv-commit.service.tssrc/features/setup/server/csv/commit-builder.tssrc/features/setup/server/csv/upsert-executor.tssrc/features/setup/server/csv/import-report.ts
Behavior
- Commit requires
previewHash. - Commit re-runs D.7.4 preview on the submitted files.
- Commit rejects mismatched
previewHash. - Commit rejects preview results with blocking errors.
- Commit follows dependency order from
setup/templates/templates.jsonthrough the D.7.4 preview ordering. dryRun=truereturns planned actions and does not start transaction writes.- Non-dry-run commits execute in a single database transaction.
- Supported rows use idempotent business-key upsert behavior.
- Password updates only run for existing users when
passwordis supplied andreset_password=true; otherwise password input is ignored with a report warning. - Import reports never return password hashes.
Supported Templates
The commit executor supports the templates registered by D.7.3/D.7.4:
users.csvorganizations.csvmemberships.csvcrm-role-assignments.csvmaster-options.csvbranches.csvproduct-types.csvdocument-sequences.csvapproval-workflows.csvapproval-steps.csvapproval-matrix.csvcustomers.csvcontacts.csvcontact-shares.csvleads.csvopportunities.csvopportunity-parties.csvquotations.csvquotation-items.csvquotation-parties.csvquotation-topics.csvquotation-topic-items.csv
Safety Notes
- D.7.5 reuses D.7.4 parsing, template detection, validation, dependency resolution, preview actions, and
previewHash. - Setup import writes directly with Drizzle for this slice because no safe setup import service contract exists for every supported template.
- The import report includes
AUDIT_GAPwarnings for direct Drizzle writes; a future service wrapper can add per-row audit semantics without changing the preview contract. - Storage, attachments, approval execution, PDFs, setup state persistence, seed manifest persistence, and destructive reset remain out of scope.
Verification
npm run typecheckpassed.npx oxlint src/features/setup/server/csv src/features/setup/server/csv-commit.service.ts src/app/api/setup/import/commit/route.tspassed.