Skip to main content

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.

Every employee in La Oficina Nítida has a digital file — an expediente — that aggregates all documents related to their employment lifecycle. Documents are organized into well-defined categories, stored in Cloudflare R2, and tracked in the ExpedienteDoc model. The expediente is the single source of truth for an employee’s document history, and it integrates directly with contract generation and the alerts engine. ExpedienteDoc is the only active model for digital files; the legacy EmployeeFile model was retired in PR6B and must not be referenced.

Document Categories

Each document in the expediente is assigned to exactly one ExpedienteCategoria:
CategoryWhat belongs here
CONTRATOSigned employment contracts and contract renewals generated by the platform
AFILIACIONSocial security affiliation forms: EPS, ARL, pension fund, caja de compensación
CERTIFICADOEmployment certificates, income certificates, and other formal certifications
DOCUMENTO_PERSONALPersonal identity documents: cédula scans, birth certificates, academic titles
PREAVISOPre-notice letters (preaviso de terminación)
TERMINACIONEmployment termination documents, settlement agreements (actas de liquidación)
OTROAny document that does not fit the categories above
The category determines the logical folder in which the document appears in the UI and drives the byCategory statistics returned by the expediente endpoint.

Storage Key Convention

All files in the expediente follow a deterministic path pattern in Cloudflare R2:

Manually uploaded documents

{tenantId}/expediente/{empleadoId}/{categoria}/{id}_v{version}.{ext}
  • {id} is the ExpedienteDoc UUID.
  • {version} starts at 1 and increments each time a new version of the same document is uploaded.
  • {ext} is the file extension derived from the MIME type (pdf, jpg, png, etc.).

Auto-generated documents

When the platform generates a PDF contract or certificate, it creates the ExpedienteDoc record with a predictable key:
{tenantId}/expediente/{empleadoId}/{categoria}/gen_{generatedDocId}_v1.pdf
  • gen_ prefix identifies this as a platform-generated file.
  • {generatedDocId} is the UUID of the GeneratedDocument record.
  • Version is always v1 for generated files; retries overwrite the same path.
This convention makes storage keys fully deterministic and auditable without any additional metadata lookups.

Accessing an Employee’s Expediente

Get the full expediente

GET /employees/:id/expediente
Returns all ExpedienteDoc records for the employee, ordered by createdAt descending, along with an aggregate statistics object:
{
  "docs": [
    {
      "id": "d1e2f3...",
      "categoria": "CONTRATO",
      "nombre": "Contrato Término Fijo 2024.pdf",
      "storageKey": "tenant-uuid/expediente/emp-uuid/CONTRATO/gen_doc-uuid_v1.pdf",
      "mimeType": "application/pdf",
      "version": 1,
      "createdAt": "2024-02-01T10:30:00.000Z",
      "generatedDocument": {
        "id": "doc-uuid",
        "nombre": "Contrato - Carlos Pérez",
        "tipo": "CONTRACT"
      }
    }
  ],
  "stats": {
    "total": 4,
    "byCategory": {
      "CONTRATO": 1,
      "CERTIFICADO": 2,
      "DOCUMENTO_PERSONAL": 1
    },
    "ultimoDocumento": "2024-02-01T10:30:00.000Z"
  }
}
Returns 404 if the employee does not exist within the authenticated tenant.

Get a single document

GET /expediente-docs/:id
Returns the full document record including the employee name fields and the linked GeneratedDocument summary (if applicable).

Deleting Documents

DELETE /expediente-docs/:id
Requires ADMIN role. Permanently removes the ExpedienteDoc row from the database. Note: this does not automatically delete the underlying file from Cloudflare R2 — storage cleanup is handled separately.

Auto-Population from Document Generation

When the platform generates a PDF (via POST /contracts/:id/generate-document or POST /generated-documents/:id/generate-pdf), it automatically creates a corresponding ExpedienteDoc record in the same database transaction. The category is derived from the template type:
Template tipoExpediente categoria
CONTRACTCONTRATO
CERTIFICATIONCERTIFICADO
LETTEROTRO
MEMOOTRO
The storageKey is set to the gen_{generatedDocId}_v1.pdf pattern, and tamanoBytes is set to 0 until real Cloudflare R2 storage integration is active in production. This auto-population means that generating a contract PDF is a single operation that simultaneously produces the PDF, creates the GeneratedDocument record, and adds the file to the employee’s digital file — all within one atomic database transaction, with no risk of a half-committed state.
The Alerts module uses expediente documents as a deduplication anchor for contract expiration alerts. When POST /alerts/generate-contract-alerts runs, it looks up the most recent ExpedienteDoc of category CONTRATO for each expiring contract and links the alert to that document via expedienteDocId. Employees with fully populated expedientes therefore produce more precise, deduplicated alerts. See the Alerts module for the full deduplication logic.

Build docs developers (and LLMs) love