Servicios
Todos son providedIn: 'root'. Se dividen en core/services/api (clientes HTTP) y core/services/ui (estado de UI, sesión, sockets). Las rutas HTTP se construyen con environment.apiUrl más una ruta base de API_URLS (core/helpers/global/global.constant.ts) y los sufijos de API_ENDPOINTS (/get-all, /create, /update, /remove, /toggle-active).
Las respuestas siguen el envoltorio ApiResponse<T> (interfaces/api/api-response.interface.ts): data.results + data.meta para listas paginadas.
Servicios de API (core/services/api)
| Servicio | Ruta base | Notas |
|---|---|---|
AuthService | /auth | login, frameLogin (ambos con header skip), logout, isLoggedIn, getExpiration (lee exp del JWT) |
UserService | /users | get-me, me/signature, me/avatar |
CrmUserService | /users | CRUD de usuarios del CRM |
TicketService | /tickets | get-all, get-one, resolve, resolve-no-farewell, return, unassign, transfer, postpone, cancel-postpone, lock, unlock, force-unlock, mark-unread, status, remove, filter-agents, contact-reason |
MessageService | /messages | get-all, mensajes por contacto, unread-count, recent-unread, remove, notas |
ContactService | /contacts | CRUD + assign-labels |
ConnectionService | /connections y /meta/oauth/instagram | Ver Conexiones Meta |
DepartmentService | /departments | CRUD |
LabelService | /labels | CRUD |
QuickResponseService | /quick-responses | CRUD |
SettingsService | /settings | get-all, general, attention/schedule, attention/auto-resolution, attention/csat |
ScheduledMessageService | /scheduled-messages | create, mine, by-ticket, update, cancel |
StarredMessageService | /starred-messages | toggle, ids, by-contact, by-internal-conversation, listado y ventana de contexto |
InternalChatService | /internal-conversations | Conversaciones directas/grupales, mensajes, miembros, leave, read |
FileApiService | /files/upload | Subida de archivos |
CrmRoleService, PermissionService, CrmRolePermissionService, SystemModuleService | /roles, /permissions, /role-permissions, /modules | Administración de RBAC (catálogo, no confundir con MyPermissionsService) |
LanguageService (api) | /language | get-all paginado de idiomas |
Servicios con rutas de un backoffice anterior y poco o ningún uso en el CRM: RoleService (/role, sin consumidores fuera de su archivo), ReportService (/report, /tickets-mts), PageManagerService (/page-manager).
Servicios de UI (core/services/ui)
| Grupo | Servicios |
|---|---|
| Sesión y permisos | StorageService (almacenamiento cifrado), GlobalService (perfil actual en un ReplaySubject), MyPermissionsService, EncryptionService, DeviceTokenService |
| Tiempo real | ChatSocketService, InternalChatSocketService, AudioNotificationService, NotificationCenterService, InternalChatNotificationService |
| Iframe | IframeDetectionService, FrameBridgeService |
| Chat | ChatMessageBuilderService, ChatStateManagerService, ChatScrollManagerService, ChatDateFormatterService, ChatUserHelperService, MediaDownloadService, ImageCompressionService, ImageLoadService |
| Presentación | LayoutService, NavService, LanguageService (ui), ToastrNotificationService, ConfirmDialogService, BootstrapModalService, SanitizationService, ClipboardService, UserAvatarsService |
| Tablas y filtros | NgxDatatableService, NgxDatatableMobileService, ColumnStorageService, TableColumnStorageService, FilterService, SearchNgSelectService, TabChangeService |
| Otros | DateUtilsService, RouteHelperService, ValidationService, UserLocationService, ReportDownloadService, PageManagementFormSelectorService |
StorageService
Envuelve SecureWebStorage sobre localStorage: las claves se hashean con SHA-256 y los valores se cifran con AES (crypto-js). La clave de cifrado es una constante definida en storage.service.ts (hardcodeada en el bundle, por lo que el cifrado solo ofusca; no es un secreto real frente a quien tenga acceso al navegador). La sesión se guarda bajo USER_SESSION. Expone parseJwt para leer el payload del token.
EncryptionService
Descarga la clave pública RSA de GET <apiUrl>/auth/public-key, valida su huella SHA-256 contra environment.PUBLIC_KEY_FINGERPRINT, y la cachea en localStorage (aes-gcm-encryption-pub-key) hasta 24 h. Cifra con RSA-OAEP la clave AES del envoltorio (ENVELOPE_VERSION = '1.0') y usa environment.AES_GCM_AAD como AAD cuando está definido. Solo lo importa ReportService (heredado). Ver Entornos.
GlobalService
Se suscribe a selectUser y reemite el usuario en profile. Lo consumen el layout (para conectar sockets), AdminGuard y MyPermissionsService.
Servicios de chat
ChatMessageBuilderService (buildMessagePayload), ChatStateManagerService (estado de carga/paginación de la conversación: startLoading, canLoadMore, shouldScrollToBottom), ChatScrollManagerService, ChatDateFormatterService y ChatUserHelperService se inyectan en ChatConversationComponent (y algunos en el chat interno); ver Chat.