feat(config): modulo Configuraciones admin + permisos por rol

- Tablas ConfiguracionSistema (7 configs) + RolConfiguracion (6 roles)
- Endpoints: config/sistema GET/PATCH, config/roles GET/PATCH,
  config/usuarios GET/PATCH, config/reset-roles POST, config/acciones GET
- modulosDeRol() async con fallback a MATRIZ estatica
- auth/me devuelve acciones[] segun rol del usuario
- saludMonday.estaDisponible() lee modo_local_forzado de DB (cache 30s)
- Landing: vista Configuraciones con 4 tabs (Modo, Roles, Usuarios, Sistema)
- Mi-dia: boton Descartar se deshabilita si !descartar_lead
- 630 API tests + 24 landing tests + 20 mi-dia tests verdes

Seed: npm run seed:config
This commit is contained in:
2026-09-06 09:46:19 +00:00
parent 50e6eca7da
commit b2634f97ab
35 changed files with 2572 additions and 33 deletions

View File

@@ -0,0 +1,17 @@
-- Tablas de configuración del sistema y permisos por rol.
-- Patrón manual: db execute + migrate resolve. NUNCA migrate dev.
-- CreateTable ConfiguracionSistema
CREATE TABLE IF NOT EXISTS "ConfiguracionSistema" (
"clave" TEXT NOT NULL PRIMARY KEY,
"valor" TEXT NOT NULL,
"updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- CreateTable RolConfiguracion
CREATE TABLE IF NOT EXISTS "RolConfiguracion" (
"rol" TEXT NOT NULL PRIMARY KEY,
"modulos" TEXT NOT NULL,
"acciones" TEXT NOT NULL,
"updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

View File

@@ -307,6 +307,19 @@ model AIDocumento {
chunks AIChunk[]
}
model ConfiguracionSistema {
clave String @id
valor String
updatedAt DateTime @updatedAt @default(now())
}
model RolConfiguracion {
rol String @id
modulos String // JSON array
acciones String // JSON object
updatedAt DateTime @updatedAt @default(now())
}
model AIChunk {
id String @id @default(uuid())
documentoId String