Repository navigation
DistrictVolumeProcessor
Type: Component (Service) —
FileProcessor<TableData>implementation Domain: District Volume Import Status: Complete (Issue #905) Last updated: 2026-06-17
DistrictVolumeProcessor is the top-level orchestrator of the spreadsheet import pipeline. It implements FileProcessor<TableData> and coordinates the full processing chain: file loading, format detection (Interior vs Coast), matrix parsing, and domain mapping.
It is consumed by FileUploadInput which calls processor.load(file) when a user drops or selects a file.
No constructor parameters.
Processes a district volume spreadsheet file.
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
File |
yes | Browser File (.xlsx) |
Returns: ProcessorResult<TableData>
-
Success:
{ success: true, data: [InteriorData | CoastData] } -
Failure:
{ success: false, errors: string[] }
file
│
▼
1. detectVariant(reader, file)
└─ listSheets → check for "Interior" or "Coast" (case-insensitive)
└─ on failure → return { success: false, errors: [...] }
│
▼
2. reader.read(file, config.sheetName)
└─ on failure → return { success: false, errors: [...] }
│
▼
3. MatrixParser.parse(worksheet, config)
└─ errors found → return { success: false, errors: [...] }
└─ no data rows → return { success: false, errors: [...] }
│
▼
4. mapInteriorSpreadsheet(data) OR mapCoastSpreadsheet(data)
│
▼
{ success: true, data: [TableData] }
Uses ExcelReader.listSheets() to check if any sheet name starts with "Interior" or "Coast" (case-insensitive, trimmed). The first match determines the variant and selects the corresponding MatrixConfig (interiorMatrixConfig or coastMatrixConfig).
Rather than two separate processors, a single processor auto-detects the format. This simplifies the FileUploadInput contract — it only needs one processor instance.
Each pipeline step catches its own errors and returns a user-friendly message. The processor never throws — it always returns a ProcessorResult, satisfying the FileProcessor contract.
No React, Zod, or Carbon imports. The processor works with browser File objects and returns plain domain data.
| Dependency | Purpose |
|---|---|
| ExcelReader | File loading and sheet access |
| MatrixParser | Two-row merged-header parsing |
| interiorMatrixConfig / coastMatrixConfig | Layout configuration |
| mapInteriorSpreadsheet / mapCoastSpreadsheet | Domain object mapping |
| FileProcessor / ProcessorResult | Contract types |
| Artifact | Path |
|---|---|
| Service | frontend/src/services/districtvolumes/processors/districtVolumeProcessor.ts |
| Tests | frontend/src/services/districtvolumes/processors/districtVolumeProcessor.unit.test.ts |
4 integration tests covering: valid Interior spreadsheet, valid Coast spreadsheet, corrupt file, and unsupported format.
| Consumer | Location |
|---|---|
| DistrictVolumeUploadPage | src/pages/DistrictVolumeUpload/ |
import { DistrictVolumeProcessor } from '@/services/districtvolumes/processors/districtVolumeProcessor';
const processor = new DistrictVolumeProcessor();
const result = await processor.load(file);
if (result.success) {
const [data] = result.data;
// data.type === 'INTERIOR' | 'COASTAL'
}| Reference | Link |
|---|---|
| GitHub Issue | #905 |
| Related page | ExcelReader |
| Related page | MatrixParser |
| Related page | SpreadsheetValidator |
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository