La Oficina Nítida includes a proactive alerts engine that surfaces two categories of risk: contracts that are approaching expiration, and employees who have active contracts but no registered contract document in their expediente. Alerts are created as internal platform records scoped to the authenticated tenant. They do not trigger external notifications (email or WhatsApp) in the current phase, but they power the dashboard indicators that operations teams check daily.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Glemynart/SaaS/llms.txt
Use this file to discover all available pages before exploring further.
Alert Types
Contract expiration (CONTRATO_POR_VENCER / CONTRATO_VENCIDO)
Generated by POST /alerts/generate-contract-alerts. The engine scans all contracts in VIGENTE or RENOVADO state whose fechaFin falls within the next 30 calendar days. For each qualifying contract it creates up to three alerts — one per threshold — based on how many days remain:
| Days remaining | Severity | Label |
|---|---|---|
| ≤ 30 days | INFO | ”Contrato próximo a vencer (30 días)” |
| ≤ 15 days | WARNING | ”Contrato próximo a vencer (15 días)” |
| ≤ 7 days | CRITICAL | ”Contrato próximo a vencer (7 días)” |
descripcion that names the employee (via formatNombreCompleto() from @saas/types) and the exact expiration date formatted for the es-CO locale.
Missing document alerts
Generated byPOST /alerts/generate-missing-doc-alerts. The engine checks every ACTIVO employee who does not have any contract in VIGENTE or RENOVADO state. For each such employee it creates a WARNING-severity alert titled "Empleado sin contrato registrado".
Alert Severity and Status
Severity levels
| Value | Meaning |
|---|---|
INFO | Informational notice — action advisable but not urgent |
WARNING | Action recommended soon |
CRITICAL | Immediate action required |
Alert status lifecycle
| Value | Meaning |
|---|---|
OPEN | Active alert — not yet acknowledged or resolved |
RESOLVED | Alert has been acknowledged and closed by an operator |
The Prisma schema also defines a legacy
Alerta model with AlertaEstado
values (PENDIENTE, ENVIADA, FALLIDA) and AlertaTipo values
(CONTRATO_POR_VENCER, CONTRATO_VENCIDO). The active alerts system
described on this page uses the Alert model with AlertStatus (OPEN,
RESOLVED) and AlertSeverity (INFO, WARNING, CRITICAL). All new
development must target the Alert model exclusively.Generating Alerts
Contract expiration alerts
ADMIN role.
The engine:
- Finds all
VIGENTE/RENOVADOcontracts withfechaFinbetweennowandnow + 30 days. - For each contract, calculates
diasRestantes = floor((fechaFin - now) / ms_per_day). - Iterates the three severity thresholds (30, 15, 7 days) and skips any for which
diasRestantes > threshold. - For each qualifying threshold, checks for an existing
OPENalert with the same(expedienteDocId, severity)or(employeeId, severity, titulo)combination to avoid duplicates. - Creates the alert only if no duplicate exists.
Missing document alerts
ADMIN role.
The engine:
- Finds all
ACTIVOemployees for the tenant (excluding soft-deleted records). - For each employee, checks whether any contract exists in
VIGENTEorRENOVADOstate. - If no active contract is found and no open
"Empleado sin contrato registrado"alert already exists for that employee, creates a newWARNINGalert.
Querying Alerts
List all alerts
AlertQueryDto):
| Parameter | Type | Description |
|---|---|---|
severity | INFO | WARNING | CRITICAL | Filter by severity level |
status | OPEN | RESOLVED | Filter by alert status |
page | number | Page number (default 1) |
limit | number | Page size (default 20) |
stats object alongside the paginated data:
- The linked
employeeobject with all four name fields (primerNombre,segundoNombre,primerApellido,segundoApellido),cedula, andcargo. - The linked
expedienteDocobject (id,nombre,categoria) when the alert was created with anexpedienteDocIdreference.
Get a single alert
404 if the alert does not exist within the authenticated tenant.
Resolving Alerts
ADMIN or OPERADOR role. Sets the alert’s status to RESOLVED and records a resolvedAt timestamp. Resolved alerts remain in the system for audit and historical reporting — they are never deleted.
Deduplication
The alerts engine never creates duplicate alerts for the same risk. Before inserting a new alert, it checks for an existingOPEN record using one of two strategies:
When an expedienteDocId is available (the contract has a linked document in the expediente):
expedienteDocId is available (the contract has no expediente document yet):
The
dueDate field on a contract alert is set to the contract’s actual
fechaFin — not to a calculated offset from today. This means the dueDate
remains stable across repeated generation runs for the same contract: it always
reflects the real expiration date regardless of when the alert was created.