Repository navigation
[Alertas] Motor de alertas: filtros por campos, destinatarios, permisos y API - #90
Merged
Merged
Conversation
…ons and API (#79) - alerts module: AlertEntity, repository + in-memory fake, AlertService validating against the event catalog (fields, operators, typed values, references and recipients inside the location, anti-escalation on the event readPermission) - pure condition evaluator (all/any, nested paths, derive, absent fields, list values) - AlertEngine on the bus ('*'): fixed system notifications (access changes, personal API keys), cached enabled alerts per event type, per-alert throttle, recipients filtered by cancan most-specific-wins, one email per recipient - API: /api/events/catalog, /api/alerts CRUD, /api/alerts/[id]/test and /api/alerts/test dry runs; project API keys confined to their project - organization:alerts:* and project:alerts:* permissions; default org/project admin get :all, project developer and viewer get read; layout flags for the sidebar - registerAlertEngine() in hooks.server.ts (HMR-safe) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #79 · Parte de #76
Qué incluye
Módulo
alerts(src/modules/alerts/):AlertEntityen GitDB, con su repositorio y un fake en memoria.AlertServicehace el CRUD y valida cada alerta contra el catálogo. Los errores se devuelven por campo, p. ej.conditions.0.operator: invalid_operator.Evaluador puro (
condition-evaluator.ts):all/any, rutas anidadas y camposderive. Un campo ausente dafalse, salvo conexists. Los campos de lista (changedFields) admitenin/not_in;containsystarts_withno distinguen mayúsculas; las fechas se comparan en ISO.Motor (
alert-engine.ts), suscrito a'*'y registrado una vez por proceso enhooks.server.ts(a prueba de HMR):cancanService.can(readPermission)en el ámbito del evento, con most-specific-wins.Sin SMTP configurado el motor no hace nada, en lugar de registrar un error por cada evento.
API:
GET /api/events/catalog?scope=&projectId=|organizationId=alertablecuyoreadPermissiontiene el usuarioGET/POST /api/alertsinheritedde la org) y altaGET/PATCH/DELETE /api/alerts/[id]POST /api/alerts/[id]/testyPOST /api/alerts/testLa lógica HTTP está en
#lib/server/alerts, para reutilizarla en las form actions de [Alertas] UI: gestión de alertas y constructor de filtros desde el catálogo #80. Las API keys de proyecto solo pueden gestionar alertas de su proyecto.Permisos:
organization:alerts:*yproject:alerts:*. Org Admin y Project Admin tienen:all; Project Developer y Viewer,read. Los flagscanReadOrganizationAlertsycanReadProjectAlertsestán en el layout.Anti-escalada: el autor debe tener el
readPermissiondel evento en ese ámbito. En una alerta de organización sobre un evento de proyecto también valeorganization:projects:read, que es lo que baja en cascada a los proyectos.Alertas de organización sobre eventos de proyecto: tienen un campo extra
projectId(de tipo referenceproject) para limitarlas a ciertos proyectos.Decisiones a revisar
organization:events. El permiso nuevo aparece en el editor de roles para activarlo a mano.alerts.email.*) y se envían en el idioma base (es). La plantilla es mínima; las definitivas llegan en [Alertas] Canal email: plantillas, cola de envío y reintentos #81.payloadpara sobrescribirlo ysampleProjectIdpara alertas de organización.UserAccessRow: expone ahoradisabledpara poder excluir a esos usuarios.Tests
bun run check: 0 errores.bun run test:CanCanServicereal; desactivados; un email por destinatario; fallo aislado; caché; SMTP desactivado.bun run test:e2e: 55/55. El e2e propio de alertas llega con [Alertas] UI: gestión de alertas y constructor de filtros desde el catálogo #80.🤖 Generated with Claude Code