Every equipment and peripheral record in the inventory carries location data. Rather than storing free-text addresses, the system uses a structured six-level geographic hierarchy that maps assets to exact physical positions within your organization. Location documents live in theDocumentation 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.
ubicaciones Firestore collection and are referenced by both the procedencia (origin) and asignacion (deployment) fields on asset records.
Location Hierarchy
| Level | Field | Required | Description |
|---|---|---|---|
| 1 | region | ✅ | Geographic macro-region (e.g., “Capital”) |
| 2 | estado | ✅ | State or province (e.g., “Distrito Capital”) |
| 3 | ciudad | ✅ | City (e.g., “Caracas”) |
| 4 | sede | ✅ | Office building or campus name |
| 5 | piso | ✅ | Floor number (must be a positive integer) |
| 6 | ala | ❌ | Wing within the floor: Este, Oeste, Norte, or Sur |
inventory.constants.js:
Deterministic Document IDs
Location document IDs are derived deterministically from the field values usinglocationIdFromData(). The same combination of region + estado + ciudad + sede + piso + ala always produces the same Firestore document ID, which prevents duplicate location records from being created even if two users attempt to register the same office simultaneously.
This also means the PUT /api/ubicaciones/:id endpoint may trigger a document migration — if the updated fields produce a different ID, the handler opens a transaction that deletes the old document and creates a new one under the new ID:
Geographic Reference Collections
Regions, states, and cities are seeded into three separate Firestore collections. These collections power the cascading select menus in the frontend forms:| Collection | Key field | Parent link |
|---|---|---|
regiones | nombre | — |
estados | nombre, id_region | → regiones |
ciudades | nombre, id_estado | → estados |
API Reference
Geographic Data
GET /api/region — List all regions
GET /api/region — List all regions
Returns all documents from the
regiones collection ordered alphabetically.GET /api/region/:id/estados — List states in a region
GET /api/region/:id/estados — List states in a region
Queries the
estados collection filtered by id_region.GET /api/estados/:id/ciudades — List cities in a state
GET /api/estados/:id/ciudades — List cities in a state
Queries the
ciudades collection filtered by id_estado.Locations CRUD
GET /api/ubicaciones — List active locations
GET /api/ubicaciones — List active locations
Returns all locations with
status: "Activo", deduplicated by their six-level key, sorted by sede + piso.POST /api/ubicaciones — Create a new location
POST /api/ubicaciones — Create a new location
Requires Success response:Returns
Administrador or Superadministrador role (enforced by verificarToken + permitirEscritura middleware).409 Conflict if a location with the same normalized ID already exists.PUT /api/ubicaciones/:id — Update a location
PUT /api/ubicaciones/:id — Update a location
Requires write permissions. If the updated fields produce a different document ID, the old document is deleted and a new one is created atomically in a transaction. The
createdAt timestamp is preserved.DELETE /api/ubicaciones/:id — Hard delete
DELETE /api/ubicaciones/:id — Hard delete
Permanently removes the location document. Requires write permissions.Returns
404 if the document does not exist.PUT /api/ubicaciones/eliminadas/:id — Soft delete
PUT /api/ubicaciones/eliminadas/:id — Soft delete
Sets The resulting bitácora entry will have:
status: "inactivo" on the document rather than deleting it. The location is excluded from GET /api/ubicaciones results. This operation is logged to the bitacora collection.accion:"Eliminar ubicación"detalles:["Se inactivó la ubicación: <nombre>"]usuario: the authenticated user’s usernamesede: the authenticated user’s office
Frontend Validation Schema
The frontend usesubicacionSchema.ts (Zod) to validate location forms before submission:
The
ala field is a union of an empty string (meaning “no wing”) and the four cardinal direction values. This allows the form to leave ala blank while still maintaining type safety — Zod rejects any string that is not one of the four allowed values or an empty string.