- Create TASK-2026-01-25-NOTIFICACIONES-COMPLETAS with full CAPVED docs - Update DATABASE_INVENTORY with auth.notifications, auth.user_push_tokens, investment.distribution_history, investment.distribution_runs tables - Update BACKEND_INVENTORY with push-token endpoints, firebase.client, and unit tests - Update FRONTEND_INVENTORY with notification components, store, service - Update MASTER_INVENTORY with updated totals - Update _INDEX.yml with new task entry Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.3 KiB
2.3 KiB
03-PLANEACION - Phase 1 MVP Implementation
Plan de Implementación
Task 10: Servicio de Notificaciones
Archivos a Crear
-
notification.service.ts (~500 líneas)
- Clase
NotificationService - Métodos: sendNotification, sendBulkNotification, broadcastNotification
- Canales: in_app (WebSocket), email, push
- Preferencias de usuario (quiet hours, disabled types)
- Templates de email por tipo
- Clase
-
notification.controller.ts (~180 líneas)
- getNotifications, getUnreadCount
- markAsRead, markAllAsRead
- deleteNotification
- getPreferences, updatePreferences
-
notification.routes.ts (~50 líneas)
- GET /notifications
- GET /notifications/unread-count
- GET /notifications/preferences
- PATCH /notifications/preferences
- POST /notifications/read-all
- PATCH /notifications/:id/read
- DELETE /notifications/:id
-
index.ts (exports)
Modificaciones
- alerts.service.ts: Integrar con notificationService en triggerAlert()
- index.ts: Agregar notificationRouter a API routes
Task 11: Distribution Job
Archivos a Crear
-
distribution.job.ts (~300 líneas)
- Clase
DistributionJob - Scheduler: setInterval para 00:00 UTC
- Métodos: run, getActiveAccounts, distributeReturns
- Cálculo de retornos diarios basado en producto
- Aplicación de performance fees
- Registro en distribution_history
- Notificación a usuarios
- Clase
-
index.ts (exports)
Modificaciones
- index.ts: Inicializar distributionJob.start() al arrancar servidor
Orden de Implementación
1. notification.service.ts [Core]
2. notification.controller.ts [API]
3. notification.routes.ts [Routing]
4. notifications/index.ts [Exports]
5. Modificar alerts.service.ts [Integración]
6. distribution.job.ts [Core]
7. investment/jobs/index.ts [Exports]
8. Modificar main index.ts [Startup]
Criterios de Aceptación
- Notificaciones en tiempo real via WebSocket
- Emails enviados con templates correctos
- API REST funcional para gestión de notificaciones
- Alertas de precio envían notificaciones automáticamente
- Distribution job programado para 00:00 UTC
- Cálculo correcto de rendimientos por producto
- Historial de distribuciones registrado
- TypeScript compila sin errores