Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Danielings/Pasantia-Proyecto/llms.txt
Use this file to discover all available pages before exploring further.
The export module allows authorized users to download a point-in-time snapshot of the inventory in either a print-ready PDF or a machine-readable Excel spreadsheet. Both formats apply the same role-based data scoping as the rest of the API — Superadministrador users export the full inventory while all other roles receive only the assets assigned to their office. Filters can be combined freely to narrow the export to exactly the records needed.
Authentication
Both export endpoints require a valid session cookie. Pass acceso_token in the request cookie header. Unauthenticated requests receive 401 Unauthorized.
Endpoints
GET /api/export/tipos
Returns the list of all distinct asset types currently present in the inventory (from both equipos and perifericos collections). Use this to populate filter dropdowns in a UI before calling the download endpoint.
curl -b 'acceso_token=<token>' \
http://localhost:3001/api/export/tipos
["Corneta", "Impresora", "Laptop", "Monitor", "Mouse", "PC", "Switch", "Teclado"]
Types are deduplicated, normalized to their canonical casing (from CANONICAL_TIPOS), and sorted alphabetically using the es locale.
GET /api/export/descargar
Downloads the inventory file. The response Content-Type and filename are set automatically based on the formato parameter.
Query Parameters
| Parameter | Required | Values | Description |
|---|
formato | ✅ | pdf | excel | Output file format |
tipo | ❌ | Any type string, or completa / completo | Filter to a single asset type; omit or use completa for all types |
estados | ❌ | Comma-separated status values | e.g., Funcional,En Reparación |
modelos | ❌ | Comma-separated model strings | e.g., ThinkPad E15,OptiPlex 7090 |
sedes | ❌ | Comma-separated office names | e.g., Torre Norte,Torre Sur |
tipos | ❌ | Comma-separated type values | Multi-type filter; combined with tipo |
search | ❌ | Free text | Searches against marca and serial (normalized) |
tipo and tipos can be used together, but they are applied as independent AND filters — both must match for a record to be included. tipo is a single-value filter (e.g., ?tipo=PC) that skips items whose type does not match. tipos is a multi-value filter (e.g., ?tipos=PC,Laptop) that requires the item’s type to appear in the list. If you supply both, only items satisfying both conditions are exported. For a single-type export use tipo alone; for a multi-type export use tipos alone.
Role-Based Data Scoping
The fetchInventario(user) function enforces data boundaries before any filter is applied:
function userCanSeeItem(data, rol, sedeUsuarioNormalizada) {
if (rol === "Superadministrador") return true;
const sedeComponente = data.asignacion?.sede?.trim().toLowerCase() || null;
const torreComponente = data.sede?.trim().toLowerCase() || null;
return (
sedeComponente === sedeUsuarioNormalizada ||
torreComponente === sedeUsuarioNormalizada
);
}
- Superadministrador: Receives every record from
equipos and perifericos.
- All other roles: Receive only records where the asset’s
asignacion.sede (or legacy sede) matches their own office. Users with no sede receive an empty file.
PDF Output
PDF files are generated server-side using PDFKit. The output is A4 landscape orientation with 40-point margins.
Layout features:
- Title centered at the top with the type label and total record count.
- Generated timestamp (formatted for
es-VE locale) below the title.
- Table header row with blue background (
#1e40af) and white text.
- Alternating row colors: even rows use
#f8fafc, odd rows use #ffffff.
- Auto-pagination: when a row would exceed the bottom margin, a new landscape page is added and rendering continues at
y = 40.
- Long cell values are truncated with an ellipsis (
ellipsis: true) to prevent overflow.
Column widths (points):
| Column | Width |
|---|
| Tipo | 70 |
| Serial | 90 |
| Marca | 70 |
| Modelo | 70 |
| Ubicación | 80 |
| Estado | 60 |
| Observaciones | 100 |
Excel Output
Excel files are generated with SheetJS (xlsx). The workbook contains a single sheet named “Inventario” with the following column structure:
| Column | Field | Preset width (chars) |
|---|
| A — Tipo | tipo | 14 |
| B — Serial | serial | 18 |
| C — Marca | marca | 14 |
| D — Modelo | modelo | 14 |
| E — Ubicación | sede | 18 |
| F — Estado | estado | 12 |
| G — Observaciones | notas | 30 |
The first row is the header row with the column names. All subsequent rows contain data. Missing values are written as empty strings.
curl Examples
Download a PDF of all PCs
curl -b 'acceso_token=<token>' \
"http://localhost:3001/api/export/descargar?formato=pdf&tipo=PC" \
--output inventario-pc.pdf
The downloaded file will be named inventario-PC-<YYYY-MM-DD>.pdf and will contain only records with tipo: "PC" visible to the authenticated user’s role.
Download an Excel file of the full inventory
curl -b 'acceso_token=<token>' \
"http://localhost:3001/api/export/descargar?formato=excel&tipo=completa" \
--output inventario-completo.xlsx
Download a PDF filtered by status and office
curl -b 'acceso_token=<token>' \
"http://localhost:3001/api/export/descargar?formato=pdf&estados=En+Reparación&sedes=Torre+Norte,Torre+Sur" \
--output reparaciones.pdf
Download an Excel file for multiple asset types
curl -b 'acceso_token=<token>' \
"http://localhost:3001/api/export/descargar?formato=excel&tipos=Monitor,Teclado,Mouse" \
--output perifericos.xlsx
File Naming Convention
The downloaded filename is generated automatically by buildFileName(formato, tipo):
inventario-<tipo-label>-<YYYY-MM-DD>.<ext>
| Scenario | Example filename |
|---|
| Single type | inventario-pc-2024-11-03.pdf |
| Full inventory | inventario-informacion-completa-2024-11-03.xlsx |
| Multi-word type | inventario-en-reparacion-2024-11-03.pdf |
Spaces in the type label are replaced with hyphens, and the value is normalized to lowercase.
If the authenticated user has no sede and is not a Superadministrador, the export endpoint returns a valid but empty file (zero data rows) rather than an error. This is by design — it prevents information leakage while still returning a well-formed document.