# PXL Backend Excel I/O

The Excel I/O module uses a two-phase import flow:

1. `POST /excel-io/import/preview` (REST multipart upload)
returns only a `previewSessionId`.
2. `excelIo.getPreview` (tRPC query)
returns the fully typed preview for that `previewSessionId`.
3. `excelIo.execute` (tRPC mutation)
executes the reviewed import for that `previewSessionId`.

## Why this split exists

- File uploads are handled in REST because tRPC does not handle multipart uploads directly.
- All post-upload operations are handled via tRPC to keep type-safe request/response contracts.
- Preview data is stored server-side in an in-memory preview store with TTL.

## Session lifecycle

- Upload creates and stores preview data and returns `previewSessionId`.
- `getPreview` reads the stored preview by `previewSessionId`.
- `execute` validates flags (`ignoreErrors`, `confirmDeletes`) and applies changes.
- Successful execution removes the stored preview session.
- Expired preview sessions are cleaned up automatically.
