rl-core-api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +19 -0
- package/dist/core/auth/authenticatedUser.interface.d.ts +16 -0
- package/dist/core/auth/authenticatedUser.interface.js +2 -0
- package/dist/core/auth/cookie.util.d.ts +9 -0
- package/dist/core/auth/cookie.util.js +28 -0
- package/dist/core/auth/decorators/currentUser.decorator.d.ts +2 -0
- package/dist/core/auth/decorators/currentUser.decorator.js +9 -0
- package/dist/core/auth/decorators/public.decorator.d.ts +3 -0
- package/dist/core/auth/decorators/public.decorator.js +7 -0
- package/dist/core/auth/decorators/requirePermission.decorator.d.ts +5 -0
- package/dist/core/auth/decorators/requirePermission.decorator.js +10 -0
- package/dist/core/auth/guards/appThrottler.guard.d.ts +5 -0
- package/dist/core/auth/guards/appThrottler.guard.js +23 -0
- package/dist/core/auth/guards/csrf.guard.d.ts +8 -0
- package/dist/core/auth/guards/csrf.guard.js +55 -0
- package/dist/core/auth/guards/jwtAuth.guard.d.ts +10 -0
- package/dist/core/auth/guards/jwtAuth.guard.js +37 -0
- package/dist/core/auth/guards/permissions.guard.d.ts +7 -0
- package/dist/core/auth/guards/permissions.guard.js +42 -0
- package/dist/core/bootstrap/bootstrapCore.util.d.ts +9 -0
- package/dist/core/bootstrap/bootstrapCore.util.js +67 -0
- package/dist/core/config/config.module.d.ts +8 -0
- package/dist/core/config/config.module.js +34 -0
- package/dist/core/config/env.schema.d.ts +65 -0
- package/dist/core/config/env.schema.js +94 -0
- package/dist/core/config/env.service.d.ts +7 -0
- package/dist/core/config/env.service.js +27 -0
- package/dist/core/context/auditContext.d.ts +7 -0
- package/dist/core/context/auditContext.js +5 -0
- package/dist/core/core.module.d.ts +11 -0
- package/dist/core/core.module.js +73 -0
- package/dist/core/database/base.schema.d.ts +7 -0
- package/dist/core/database/base.schema.js +49 -0
- package/dist/core/database/createDataSource.util.d.ts +8 -0
- package/dist/core/database/createDataSource.util.js +27 -0
- package/dist/core/database/migrations/1710000000000-InitialSchema.d.ts +6 -0
- package/dist/core/database/migrations/1710000000000-InitialSchema.js +272 -0
- package/dist/core/database/migrations/1786060800000-FirstAccessTokenType.d.ts +6 -0
- package/dist/core/database/migrations/1786060800000-FirstAccessTokenType.js +19 -0
- package/dist/core/database/migrations/1786147200000-PermanentAccountLock.d.ts +6 -0
- package/dist/core/database/migrations/1786147200000-PermanentAccountLock.js +15 -0
- package/dist/core/database/migrations/1786233600000-Notifications.d.ts +6 -0
- package/dist/core/database/migrations/1786233600000-Notifications.js +59 -0
- package/dist/core/database/migrations/index.d.ts +3 -0
- package/dist/core/database/migrations/index.js +13 -0
- package/dist/core/database/seeds/runSeeds.d.ts +1 -0
- package/dist/core/database/seeds/runSeeds.js +20 -0
- package/dist/core/database/seeds/seedAdmin.d.ts +2 -0
- package/dist/core/database/seeds/seedAdmin.js +44 -0
- package/dist/core/database/seeds/seedPermissions.d.ts +2 -0
- package/dist/core/database/seeds/seedPermissions.js +93 -0
- package/dist/core/events/appEvent.enum.d.ts +31 -0
- package/dist/core/events/appEvent.enum.js +12 -0
- package/dist/core/filters/allExceptions.filter.d.ts +5 -0
- package/dist/core/filters/allExceptions.filter.js +61 -0
- package/dist/core/filters/appErrorCode.enum.d.ts +9 -0
- package/dist/core/filters/appErrorCode.enum.js +13 -0
- package/dist/core/health/health.controller.d.ts +11 -0
- package/dist/core/health/health.controller.js +56 -0
- package/dist/core/logger/winston.config.d.ts +2 -0
- package/dist/core/logger/winston.config.js +74 -0
- package/dist/core/mailer/mailer.module.d.ts +2 -0
- package/dist/core/mailer/mailer.module.js +21 -0
- package/dist/core/mailer/mailer.service.d.ts +14 -0
- package/dist/core/mailer/mailer.service.js +148 -0
- package/dist/core/openapi/exportOpenapi.d.ts +1 -0
- package/dist/core/openapi/exportOpenapi.js +25 -0
- package/dist/core/query/applyFilter.util.d.ts +11 -0
- package/dist/core/query/applyFilter.util.js +122 -0
- package/dist/core/query/filter.constants.d.ts +7 -0
- package/dist/core/query/filter.constants.js +64 -0
- package/dist/core/query/filterField.interface.d.ts +35 -0
- package/dist/core/query/filterField.interface.js +2 -0
- package/dist/core/query/filterFieldType.enum.d.ts +10 -0
- package/dist/core/query/filterFieldType.enum.js +14 -0
- package/dist/core/query/filterOperator.enum.d.ts +23 -0
- package/dist/core/query/filterOperator.enum.js +28 -0
- package/dist/core/query/filterSchema.response.d.ts +17 -0
- package/dist/core/query/filterSchema.response.js +82 -0
- package/dist/core/query/filterSort.util.d.ts +7 -0
- package/dist/core/query/filterSort.util.js +11 -0
- package/dist/core/query/paginateWithFilter.util.d.ts +11 -0
- package/dist/core/query/paginateWithFilter.util.js +37 -0
- package/dist/core/query/parseFilter.util.d.ts +2 -0
- package/dist/core/query/parseFilter.util.js +220 -0
- package/dist/core/utils/codedError.util.d.ts +5 -0
- package/dist/core/utils/codedError.util.js +23 -0
- package/dist/core/utils/crypto.util.d.ts +2 -0
- package/dist/core/utils/crypto.util.js +39 -0
- package/dist/core/utils/hash.util.d.ts +6 -0
- package/dist/core/utils/hash.util.js +67 -0
- package/dist/core/utils/ip.util.d.ts +1 -0
- package/dist/core/utils/ip.util.js +15 -0
- package/dist/core/utils/pagination.util.d.ts +21 -0
- package/dist/core/utils/pagination.util.js +98 -0
- package/dist/core/utils/paginationMeta.response.d.ts +7 -0
- package/dist/core/utils/paginationMeta.response.js +32 -0
- package/dist/core/utils/password.constants.d.ts +2 -0
- package/dist/core/utils/password.constants.js +5 -0
- package/dist/core/websocket/baseGateway.d.ts +21 -0
- package/dist/core/websocket/baseGateway.js +63 -0
- package/dist/core/websocket/socket.constants.d.ts +4 -0
- package/dist/core/websocket/socket.constants.js +9 -0
- package/dist/core/websocket/socketEvent.envelope.d.ts +8 -0
- package/dist/core/websocket/socketEvent.envelope.js +11 -0
- package/dist/core/websocket/socketOrigin.util.d.ts +2 -0
- package/dist/core/websocket/socketOrigin.util.js +15 -0
- package/dist/core/websocket/wsAuth.service.d.ts +20 -0
- package/dist/core/websocket/wsAuth.service.js +97 -0
- package/dist/core/websocket/wsUserResolver.interface.d.ts +5 -0
- package/dist/core/websocket/wsUserResolver.interface.js +4 -0
- package/dist/coreEntities.d.ts +12 -0
- package/dist/coreEntities.js +35 -0
- package/dist/dataSource.d.ts +3 -0
- package/dist/dataSource.js +13 -0
- package/dist/features/audit/audit.module.d.ts +2 -0
- package/dist/features/audit/audit.module.js +44 -0
- package/dist/features/audit/domain/audit.service.d.ts +34 -0
- package/dist/features/audit/domain/audit.service.js +93 -0
- package/dist/features/audit/domain/classifyError.util.d.ts +2 -0
- package/dist/features/audit/domain/classifyError.util.js +24 -0
- package/dist/features/audit/domain/index.d.ts +2 -0
- package/dist/features/audit/domain/index.js +18 -0
- package/dist/features/audit/infra/auditData.subscriber.d.ts +17 -0
- package/dist/features/audit/infra/auditData.subscriber.js +139 -0
- package/dist/features/audit/infra/index.d.ts +7 -0
- package/dist/features/audit/infra/index.js +23 -0
- package/dist/features/audit/infra/repositories/auditChange.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/auditChange.repository.js +35 -0
- package/dist/features/audit/infra/repositories/auditDataChange.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/auditDataChange.repository.js +35 -0
- package/dist/features/audit/infra/repositories/errorLog.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/errorLog.repository.js +35 -0
- package/dist/features/audit/infra/schema/auditChange.schema.d.ts +14 -0
- package/dist/features/audit/infra/schema/auditChange.schema.js +68 -0
- package/dist/features/audit/infra/schema/auditDataChange.schema.d.ts +15 -0
- package/dist/features/audit/infra/schema/auditDataChange.schema.js +56 -0
- package/dist/features/audit/infra/schema/errorLog.schema.d.ts +21 -0
- package/dist/features/audit/infra/schema/errorLog.schema.js +69 -0
- package/dist/features/audit/presentation/audit.controller.d.ts +16 -0
- package/dist/features/audit/presentation/audit.controller.js +107 -0
- package/dist/features/audit/presentation/audit.interceptor.d.ts +8 -0
- package/dist/features/audit/presentation/audit.interceptor.js +78 -0
- package/dist/features/audit/presentation/filters/audit.filters.d.ts +4 -0
- package/dist/features/audit/presentation/filters/audit.filters.js +154 -0
- package/dist/features/audit/presentation/index.d.ts +2 -0
- package/dist/features/audit/presentation/index.js +18 -0
- package/dist/features/audit/presentation/responses/auditDataChange.response.d.ts +25 -0
- package/dist/features/audit/presentation/responses/auditDataChange.response.js +96 -0
- package/dist/features/audit/presentation/responses/log.response.d.ts +45 -0
- package/dist/features/audit/presentation/responses/log.response.js +164 -0
- package/dist/features/auth/auth.module.d.ts +2 -0
- package/dist/features/auth/auth.module.js +55 -0
- package/dist/features/auth/domain/auth.service.d.ts +66 -0
- package/dist/features/auth/domain/auth.service.js +289 -0
- package/dist/features/auth/domain/index.d.ts +5 -0
- package/dist/features/auth/domain/index.js +21 -0
- package/dist/features/auth/domain/jwtPayload.interface.d.ts +11 -0
- package/dist/features/auth/domain/jwtPayload.interface.js +2 -0
- package/dist/features/auth/domain/token.service.d.ts +56 -0
- package/dist/features/auth/domain/token.service.js +205 -0
- package/dist/features/auth/domain/twoFactor.service.d.ts +19 -0
- package/dist/features/auth/domain/twoFactor.service.js +103 -0
- package/dist/features/auth/domain/wsUserResolver.service.d.ts +10 -0
- package/dist/features/auth/domain/wsUserResolver.service.js +34 -0
- package/dist/features/auth/infra/index.d.ts +2 -0
- package/dist/features/auth/infra/index.js +18 -0
- package/dist/features/auth/infra/repositories/authToken.repository.d.ts +5 -0
- package/dist/features/auth/infra/repositories/authToken.repository.js +25 -0
- package/dist/features/auth/infra/schema/authToken.schema.d.ts +21 -0
- package/dist/features/auth/infra/schema/authToken.schema.js +73 -0
- package/dist/features/auth/presentation/auth.controller.d.ts +56 -0
- package/dist/features/auth/presentation/auth.controller.js +242 -0
- package/dist/features/auth/presentation/commands/clientType.enum.d.ts +4 -0
- package/dist/features/auth/presentation/commands/clientType.enum.js +8 -0
- package/dist/features/auth/presentation/commands/login.command.d.ts +4 -0
- package/dist/features/auth/presentation/commands/login.command.js +28 -0
- package/dist/features/auth/presentation/commands/password.command.d.ts +7 -0
- package/dist/features/auth/presentation/commands/password.command.js +37 -0
- package/dist/features/auth/presentation/commands/refreshToken.command.d.ts +3 -0
- package/dist/features/auth/presentation/commands/refreshToken.command.js +26 -0
- package/dist/features/auth/presentation/commands/twoFactor.command.d.ts +12 -0
- package/dist/features/auth/presentation/commands/twoFactor.command.js +68 -0
- package/dist/features/auth/presentation/index.d.ts +7 -0
- package/dist/features/auth/presentation/index.js +23 -0
- package/dist/features/auth/presentation/responses/sessionUser.response.d.ts +19 -0
- package/dist/features/auth/presentation/responses/sessionUser.response.js +90 -0
- package/dist/features/auth/presentation/strategies/jwt.strategy.d.ts +18 -0
- package/dist/features/auth/presentation/strategies/jwt.strategy.js +59 -0
- package/dist/features/auth/token.module.d.ts +2 -0
- package/dist/features/auth/token.module.js +23 -0
- package/dist/features/maintenance/domain/cleanup.service.d.ts +22 -0
- package/dist/features/maintenance/domain/cleanup.service.js +142 -0
- package/dist/features/maintenance/maintenance.module.d.ts +2 -0
- package/dist/features/maintenance/maintenance.module.js +24 -0
- package/dist/features/notifications/domain/enums/channelType.enum.d.ts +7 -0
- package/dist/features/notifications/domain/enums/channelType.enum.js +11 -0
- package/dist/features/notifications/domain/enums/deliveryStatus.enum.d.ts +8 -0
- package/dist/features/notifications/domain/enums/deliveryStatus.enum.js +12 -0
- package/dist/features/notifications/domain/enums/notificationType.enum.d.ts +6 -0
- package/dist/features/notifications/domain/enums/notificationType.enum.js +10 -0
- package/dist/features/notifications/domain/enums/scopeType.enum.d.ts +5 -0
- package/dist/features/notifications/domain/enums/scopeType.enum.js +9 -0
- package/dist/features/notifications/domain/notifications.service.d.ts +45 -0
- package/dist/features/notifications/domain/notifications.service.js +101 -0
- package/dist/features/notifications/infra/repositories/notification.repository.d.ts +14 -0
- package/dist/features/notifications/infra/repositories/notification.repository.js +74 -0
- package/dist/features/notifications/infra/repositories/notificationRead.repository.d.ts +6 -0
- package/dist/features/notifications/infra/repositories/notificationRead.repository.js +40 -0
- package/dist/features/notifications/infra/repositories/notificationScope.repository.d.ts +5 -0
- package/dist/features/notifications/infra/repositories/notificationScope.repository.js +25 -0
- package/dist/features/notifications/infra/schema/notification.schema.d.ts +13 -0
- package/dist/features/notifications/infra/schema/notification.schema.js +52 -0
- package/dist/features/notifications/infra/schema/notificationRead.schema.d.ts +7 -0
- package/dist/features/notifications/infra/schema/notificationRead.schema.js +38 -0
- package/dist/features/notifications/infra/schema/notificationScope.schema.d.ts +9 -0
- package/dist/features/notifications/infra/schema/notificationScope.schema.js +43 -0
- package/dist/features/notifications/notifications.module.d.ts +2 -0
- package/dist/features/notifications/notifications.module.js +45 -0
- package/dist/features/notifications/presentation/commands/createNotification.command.d.ts +13 -0
- package/dist/features/notifications/presentation/commands/createNotification.command.js +72 -0
- package/dist/features/notifications/presentation/domainEvents.listener.d.ts +13 -0
- package/dist/features/notifications/presentation/domainEvents.listener.js +121 -0
- package/dist/features/notifications/presentation/notifications.controller.d.ts +16 -0
- package/dist/features/notifications/presentation/notifications.controller.js +108 -0
- package/dist/features/notifications/presentation/notifications.gateway.d.ts +13 -0
- package/dist/features/notifications/presentation/notifications.gateway.js +58 -0
- package/dist/features/notifications/presentation/notifications.publisher.d.ts +9 -0
- package/dist/features/notifications/presentation/notifications.publisher.js +42 -0
- package/dist/features/notifications/presentation/responses/notification.response.d.ts +18 -0
- package/dist/features/notifications/presentation/responses/notification.response.js +72 -0
- package/dist/features/rbac/domain/index.d.ts +2 -0
- package/dist/features/rbac/domain/index.js +18 -0
- package/dist/features/rbac/domain/rbac.catalog.d.ts +21 -0
- package/dist/features/rbac/domain/rbac.catalog.js +153 -0
- package/dist/features/rbac/domain/rbac.service.d.ts +68 -0
- package/dist/features/rbac/domain/rbac.service.js +436 -0
- package/dist/features/rbac/infra/index.d.ts +12 -0
- package/dist/features/rbac/infra/index.js +28 -0
- package/dist/features/rbac/infra/repositories/action.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/action.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/group.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/group.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/permission.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/permission.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/resource.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/resource.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/role.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/role.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/scope.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/scope.repository.js +25 -0
- package/dist/features/rbac/infra/schema/action.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/action.schema.js +36 -0
- package/dist/features/rbac/infra/schema/group.schema.d.ts +12 -0
- package/dist/features/rbac/infra/schema/group.schema.js +60 -0
- package/dist/features/rbac/infra/schema/permission.schema.d.ts +15 -0
- package/dist/features/rbac/infra/schema/permission.schema.js +66 -0
- package/dist/features/rbac/infra/schema/resource.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/resource.schema.js +36 -0
- package/dist/features/rbac/infra/schema/role.schema.d.ts +8 -0
- package/dist/features/rbac/infra/schema/role.schema.js +46 -0
- package/dist/features/rbac/infra/schema/scope.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/scope.schema.js +36 -0
- package/dist/features/rbac/presentation/commands/createAction.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createAction.command.js +32 -0
- package/dist/features/rbac/presentation/commands/createGroup.command.d.ts +7 -0
- package/dist/features/rbac/presentation/commands/createGroup.command.js +54 -0
- package/dist/features/rbac/presentation/commands/createPermission.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createPermission.command.js +35 -0
- package/dist/features/rbac/presentation/commands/createResource.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createResource.command.js +32 -0
- package/dist/features/rbac/presentation/commands/createRole.command.d.ts +5 -0
- package/dist/features/rbac/presentation/commands/createRole.command.js +38 -0
- package/dist/features/rbac/presentation/commands/createScope.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createScope.command.js +32 -0
- package/dist/features/rbac/presentation/commands/updateAction.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateAction.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateGroup.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateGroup.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updatePermission.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updatePermission.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateResource.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateResource.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateRole.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateRole.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateScope.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateScope.command.js +24 -0
- package/dist/features/rbac/presentation/index.d.ts +13 -0
- package/dist/features/rbac/presentation/index.js +29 -0
- package/dist/features/rbac/presentation/rbac.controller.d.ts +54 -0
- package/dist/features/rbac/presentation/rbac.controller.js +413 -0
- package/dist/features/rbac/presentation/responses/rbac.response.d.ts +47 -0
- package/dist/features/rbac/presentation/responses/rbac.response.js +161 -0
- package/dist/features/rbac/rbac.module.d.ts +2 -0
- package/dist/features/rbac/rbac.module.js +55 -0
- package/dist/features/users/domain/avatar.service.d.ts +4 -0
- package/dist/features/users/domain/avatar.service.js +61 -0
- package/dist/features/users/domain/index.d.ts +2 -0
- package/dist/features/users/domain/index.js +18 -0
- package/dist/features/users/domain/users.service.d.ts +46 -0
- package/dist/features/users/domain/users.service.js +291 -0
- package/dist/features/users/infra/index.d.ts +4 -0
- package/dist/features/users/infra/index.js +20 -0
- package/dist/features/users/infra/repositories/passwordHistory.repository.d.ts +5 -0
- package/dist/features/users/infra/repositories/passwordHistory.repository.js +25 -0
- package/dist/features/users/infra/repositories/user.repository.d.ts +8 -0
- package/dist/features/users/infra/repositories/user.repository.js +56 -0
- package/dist/features/users/infra/schema/passwordHistory.schema.d.ts +5 -0
- package/dist/features/users/infra/schema/passwordHistory.schema.js +29 -0
- package/dist/features/users/infra/schema/user.schema.d.ts +28 -0
- package/dist/features/users/infra/schema/user.schema.js +153 -0
- package/dist/features/users/presentation/commands/changePassword.command.d.ts +4 -0
- package/dist/features/users/presentation/commands/changePassword.command.js +29 -0
- package/dist/features/users/presentation/commands/createUser.command.d.ts +8 -0
- package/dist/features/users/presentation/commands/createUser.command.js +56 -0
- package/dist/features/users/presentation/commands/updateProfile.command.d.ts +5 -0
- package/dist/features/users/presentation/commands/updateProfile.command.js +38 -0
- package/dist/features/users/presentation/commands/updateUser.command.d.ts +5 -0
- package/dist/features/users/presentation/commands/updateUser.command.js +8 -0
- package/dist/features/users/presentation/filters/users.filters.d.ts +3 -0
- package/dist/features/users/presentation/filters/users.filters.js +62 -0
- package/dist/features/users/presentation/index.d.ts +5 -0
- package/dist/features/users/presentation/index.js +21 -0
- package/dist/features/users/presentation/responses/user.response.d.ts +25 -0
- package/dist/features/users/presentation/responses/user.response.js +95 -0
- package/dist/features/users/presentation/users.controller.d.ts +30 -0
- package/dist/features/users/presentation/users.controller.js +247 -0
- package/dist/features/users/users.module.d.ts +2 -0
- package/dist/features/users/users.module.js +42 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +149 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +5 -0
- package/dist/rlCore.module.d.ts +10 -0
- package/dist/rlCore.module.js +42 -0
- package/package.json +139 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NotificationScopeRepository = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const notificationScope_schema_1 = require("../schema/notificationScope.schema");
|
|
16
|
+
let NotificationScopeRepository = class NotificationScopeRepository extends typeorm_1.Repository {
|
|
17
|
+
constructor(dataSource) {
|
|
18
|
+
super(notificationScope_schema_1.NotificationScope, dataSource.createEntityManager());
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.NotificationScopeRepository = NotificationScopeRepository;
|
|
22
|
+
exports.NotificationScopeRepository = NotificationScopeRepository = __decorate([
|
|
23
|
+
(0, common_1.Injectable)(),
|
|
24
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
25
|
+
], NotificationScopeRepository);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseEntity } from "../../../../core/database/base.schema";
|
|
2
|
+
import { NotificationType } from "../../domain/enums/notificationType.enum";
|
|
3
|
+
import { NotificationRead } from "./notificationRead.schema";
|
|
4
|
+
import { NotificationScope } from "./notificationScope.schema";
|
|
5
|
+
export declare class Notification extends BaseEntity {
|
|
6
|
+
title: string;
|
|
7
|
+
body: string;
|
|
8
|
+
payload?: Record<string, unknown> | null;
|
|
9
|
+
type: NotificationType;
|
|
10
|
+
createdBy?: string | null;
|
|
11
|
+
scopes: NotificationScope[];
|
|
12
|
+
reads: NotificationRead[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Notification = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_schema_1 = require("../../../../core/database/base.schema");
|
|
15
|
+
const notificationType_enum_1 = require("../../domain/enums/notificationType.enum");
|
|
16
|
+
const notificationRead_schema_1 = require("./notificationRead.schema");
|
|
17
|
+
const notificationScope_schema_1 = require("./notificationScope.schema");
|
|
18
|
+
let Notification = class Notification extends base_schema_1.BaseEntity {
|
|
19
|
+
};
|
|
20
|
+
exports.Notification = Notification;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 255 }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], Notification.prototype, "title", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ type: "text" }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], Notification.prototype, "body", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: "json", nullable: true }),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], Notification.prototype, "payload", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: "enum", enum: notificationType_enum_1.NotificationType }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], Notification.prototype, "type", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ name: "created_by", type: "char", length: 36, nullable: true }),
|
|
39
|
+
__metadata("design:type", Object)
|
|
40
|
+
], Notification.prototype, "createdBy", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.OneToMany)(() => notificationScope_schema_1.NotificationScope, (scope) => scope.notification),
|
|
43
|
+
__metadata("design:type", Array)
|
|
44
|
+
], Notification.prototype, "scopes", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.OneToMany)(() => notificationRead_schema_1.NotificationRead, (read) => read.notification),
|
|
47
|
+
__metadata("design:type", Array)
|
|
48
|
+
], Notification.prototype, "reads", void 0);
|
|
49
|
+
exports.Notification = Notification = __decorate([
|
|
50
|
+
(0, typeorm_1.Entity)("notifications"),
|
|
51
|
+
(0, typeorm_1.Index)(["createdAt"])
|
|
52
|
+
], Notification);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NotificationRead = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const notification_schema_1 = require("./notification.schema");
|
|
15
|
+
let NotificationRead = class NotificationRead {
|
|
16
|
+
};
|
|
17
|
+
exports.NotificationRead = NotificationRead;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryColumn)({ name: "notification_id", type: "char", length: 36 }),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], NotificationRead.prototype, "notificationId", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.PrimaryColumn)({ name: "user_id", type: "char", length: 36 }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], NotificationRead.prototype, "userId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: "read_at", type: "datetime" }),
|
|
28
|
+
__metadata("design:type", Date)
|
|
29
|
+
], NotificationRead.prototype, "readAt", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.ManyToOne)(() => notification_schema_1.Notification, { onDelete: "CASCADE" }),
|
|
32
|
+
(0, typeorm_1.JoinColumn)({ name: "notification_id" }),
|
|
33
|
+
__metadata("design:type", notification_schema_1.Notification)
|
|
34
|
+
], NotificationRead.prototype, "notification", void 0);
|
|
35
|
+
exports.NotificationRead = NotificationRead = __decorate([
|
|
36
|
+
(0, typeorm_1.Entity)("notification_reads"),
|
|
37
|
+
(0, typeorm_1.Index)(["userId"])
|
|
38
|
+
], NotificationRead);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseEntity } from "../../../../core/database/base.schema";
|
|
2
|
+
import { ScopeType } from "../../domain/enums/scopeType.enum";
|
|
3
|
+
import { Notification } from "./notification.schema";
|
|
4
|
+
export declare class NotificationScope extends BaseEntity {
|
|
5
|
+
notificationId: string;
|
|
6
|
+
scopeType: ScopeType;
|
|
7
|
+
scopeKey?: string | null;
|
|
8
|
+
notification: Notification;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NotificationScope = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_schema_1 = require("../../../../core/database/base.schema");
|
|
15
|
+
const scopeType_enum_1 = require("../../domain/enums/scopeType.enum");
|
|
16
|
+
const notification_schema_1 = require("./notification.schema");
|
|
17
|
+
let NotificationScope = class NotificationScope extends base_schema_1.BaseEntity {
|
|
18
|
+
};
|
|
19
|
+
exports.NotificationScope = NotificationScope;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, typeorm_1.Column)({ name: "notification_id", type: "char", length: 36 }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], NotificationScope.prototype, "notificationId", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ name: "scope_type", type: "enum", enum: scopeType_enum_1.ScopeType }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], NotificationScope.prototype, "scopeType", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ name: "scope_key", type: "varchar", length: 100, nullable: true }),
|
|
30
|
+
__metadata("design:type", Object)
|
|
31
|
+
], NotificationScope.prototype, "scopeKey", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.ManyToOne)(() => notification_schema_1.Notification, (notification) => notification.scopes, {
|
|
34
|
+
onDelete: "CASCADE",
|
|
35
|
+
}),
|
|
36
|
+
(0, typeorm_1.JoinColumn)({ name: "notification_id" }),
|
|
37
|
+
__metadata("design:type", notification_schema_1.Notification)
|
|
38
|
+
], NotificationScope.prototype, "notification", void 0);
|
|
39
|
+
exports.NotificationScope = NotificationScope = __decorate([
|
|
40
|
+
(0, typeorm_1.Entity)("notification_scopes"),
|
|
41
|
+
(0, typeorm_1.Index)(["notificationId"]),
|
|
42
|
+
(0, typeorm_1.Index)(["scopeType", "scopeKey"])
|
|
43
|
+
], NotificationScope);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.NotificationsModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const auth_module_1 = require("../auth/auth.module");
|
|
13
|
+
const notifications_service_1 = require("./domain/notifications.service");
|
|
14
|
+
const notification_repository_1 = require("./infra/repositories/notification.repository");
|
|
15
|
+
const notificationRead_repository_1 = require("./infra/repositories/notificationRead.repository");
|
|
16
|
+
const notificationScope_repository_1 = require("./infra/repositories/notificationScope.repository");
|
|
17
|
+
const notification_schema_1 = require("./infra/schema/notification.schema");
|
|
18
|
+
const notificationRead_schema_1 = require("./infra/schema/notificationRead.schema");
|
|
19
|
+
const notificationScope_schema_1 = require("./infra/schema/notificationScope.schema");
|
|
20
|
+
const domainEvents_listener_1 = require("./presentation/domainEvents.listener");
|
|
21
|
+
const notifications_controller_1 = require("./presentation/notifications.controller");
|
|
22
|
+
const notifications_gateway_1 = require("./presentation/notifications.gateway");
|
|
23
|
+
const notifications_publisher_1 = require("./presentation/notifications.publisher");
|
|
24
|
+
let NotificationsModule = class NotificationsModule {
|
|
25
|
+
};
|
|
26
|
+
exports.NotificationsModule = NotificationsModule;
|
|
27
|
+
exports.NotificationsModule = NotificationsModule = __decorate([
|
|
28
|
+
(0, common_1.Module)({
|
|
29
|
+
imports: [
|
|
30
|
+
typeorm_1.TypeOrmModule.forFeature([notification_schema_1.Notification, notificationScope_schema_1.NotificationScope, notificationRead_schema_1.NotificationRead]),
|
|
31
|
+
auth_module_1.AuthModule,
|
|
32
|
+
],
|
|
33
|
+
controllers: [notifications_controller_1.NotificationsController],
|
|
34
|
+
providers: [
|
|
35
|
+
notifications_service_1.NotificationsService,
|
|
36
|
+
notification_repository_1.NotificationRepository,
|
|
37
|
+
notificationScope_repository_1.NotificationScopeRepository,
|
|
38
|
+
notificationRead_repository_1.NotificationReadRepository,
|
|
39
|
+
notifications_gateway_1.NotificationsGateway,
|
|
40
|
+
notifications_publisher_1.NotificationsPublisher,
|
|
41
|
+
domainEvents_listener_1.DomainEventsListener,
|
|
42
|
+
],
|
|
43
|
+
exports: [notifications_service_1.NotificationsService],
|
|
44
|
+
})
|
|
45
|
+
], NotificationsModule);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NotificationType } from "../../domain/enums/notificationType.enum";
|
|
2
|
+
import { ScopeType } from "../../domain/enums/scopeType.enum";
|
|
3
|
+
export declare class NotificationTargetCommand {
|
|
4
|
+
type: ScopeType;
|
|
5
|
+
key?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class CreateNotificationCommand {
|
|
8
|
+
title: string;
|
|
9
|
+
body: string;
|
|
10
|
+
type: NotificationType;
|
|
11
|
+
targets: NotificationTargetCommand[];
|
|
12
|
+
payload?: Record<string, unknown>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreateNotificationCommand = exports.NotificationTargetCommand = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
const notificationType_enum_1 = require("../../domain/enums/notificationType.enum");
|
|
17
|
+
const scopeType_enum_1 = require("../../domain/enums/scopeType.enum");
|
|
18
|
+
class NotificationTargetCommand {
|
|
19
|
+
}
|
|
20
|
+
exports.NotificationTargetCommand = NotificationTargetCommand;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, swagger_1.ApiProperty)({ enum: scopeType_enum_1.ScopeType, enumName: "ScopeType" }),
|
|
23
|
+
(0, class_validator_1.IsEnum)(scopeType_enum_1.ScopeType),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], NotificationTargetCommand.prototype, "type", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, swagger_1.ApiProperty)({
|
|
28
|
+
required: false,
|
|
29
|
+
description: "Id do usuário quando type=USER, nome do papel quando type=ROLE. Ignorado em ALL.",
|
|
30
|
+
}),
|
|
31
|
+
(0, class_validator_1.IsOptional)(),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.MaxLength)(100),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], NotificationTargetCommand.prototype, "key", void 0);
|
|
36
|
+
class CreateNotificationCommand {
|
|
37
|
+
}
|
|
38
|
+
exports.CreateNotificationCommand = CreateNotificationCommand;
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)({ maxLength: 255 }),
|
|
41
|
+
(0, class_validator_1.IsString)(),
|
|
42
|
+
(0, class_validator_1.MaxLength)(255),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], CreateNotificationCommand.prototype, "title", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, swagger_1.ApiProperty)(),
|
|
47
|
+
(0, class_validator_1.IsString)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], CreateNotificationCommand.prototype, "body", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, swagger_1.ApiProperty)({ enum: notificationType_enum_1.NotificationType, enumName: "NotificationType" }),
|
|
52
|
+
(0, class_validator_1.IsEnum)(notificationType_enum_1.NotificationType),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], CreateNotificationCommand.prototype, "type", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiProperty)({ type: [NotificationTargetCommand] }),
|
|
57
|
+
(0, class_validator_1.IsArray)(),
|
|
58
|
+
(0, class_validator_1.ArrayNotEmpty)(),
|
|
59
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
60
|
+
(0, class_transformer_1.Type)(() => NotificationTargetCommand),
|
|
61
|
+
__metadata("design:type", Array)
|
|
62
|
+
], CreateNotificationCommand.prototype, "targets", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, swagger_1.ApiProperty)({
|
|
65
|
+
required: false,
|
|
66
|
+
type: Object,
|
|
67
|
+
description: "Dado extra. `route` é usado pelo cliente para navegar.",
|
|
68
|
+
}),
|
|
69
|
+
(0, class_validator_1.IsOptional)(),
|
|
70
|
+
(0, class_validator_1.IsObject)(),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], CreateNotificationCommand.prototype, "payload", void 0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SystemCleanupFailedEvent, UserLockedEvent, UserPasswordExpiringEvent, UserPasswordResetRequestedEvent, UserTwoFactorResetEvent } from "../../../core/events/appEvent.enum";
|
|
2
|
+
import { NotificationsPublisher } from "./notifications.publisher";
|
|
3
|
+
export declare class DomainEventsListener {
|
|
4
|
+
private readonly publisher;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(publisher: NotificationsPublisher);
|
|
7
|
+
onUserLocked(event: UserLockedEvent): Promise<void>;
|
|
8
|
+
onTwoFactorReset(event: UserTwoFactorResetEvent): Promise<void>;
|
|
9
|
+
onPasswordResetRequested(event: UserPasswordResetRequestedEvent): Promise<void>;
|
|
10
|
+
onPasswordExpiring(event: UserPasswordExpiringEvent): Promise<void>;
|
|
11
|
+
onCleanupFailed(event: SystemCleanupFailedEvent): Promise<void>;
|
|
12
|
+
private safePublish;
|
|
13
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var DomainEventsListener_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.DomainEventsListener = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
16
|
+
const appEvent_enum_1 = require("../../../core/events/appEvent.enum");
|
|
17
|
+
const notificationType_enum_1 = require("../domain/enums/notificationType.enum");
|
|
18
|
+
const scopeType_enum_1 = require("../domain/enums/scopeType.enum");
|
|
19
|
+
const notifications_publisher_1 = require("./notifications.publisher");
|
|
20
|
+
const ADMIN_ROLE = "Super Admin";
|
|
21
|
+
let DomainEventsListener = DomainEventsListener_1 = class DomainEventsListener {
|
|
22
|
+
constructor(publisher) {
|
|
23
|
+
this.publisher = publisher;
|
|
24
|
+
this.logger = new common_1.Logger(DomainEventsListener_1.name);
|
|
25
|
+
}
|
|
26
|
+
async onUserLocked(event) {
|
|
27
|
+
await this.safePublish(appEvent_enum_1.AppEvent.USER_LOCKED, async () => {
|
|
28
|
+
await this.publisher.publishAndPush({
|
|
29
|
+
title: "Sua conta foi bloqueada",
|
|
30
|
+
body: "Sua conta foi bloqueada por tentativas de acesso sem sucesso. Procure um administrador para reabri-la.",
|
|
31
|
+
type: notificationType_enum_1.NotificationType.ERROR,
|
|
32
|
+
targets: [{ type: scopeType_enum_1.ScopeType.USER, key: event.userId }],
|
|
33
|
+
});
|
|
34
|
+
await this.publisher.publishAndPush({
|
|
35
|
+
title: "Usuário bloqueado",
|
|
36
|
+
body: `${event.userName} (${event.userEmail}) foi bloqueado por tentativas de acesso e aguarda reabertura.`,
|
|
37
|
+
type: notificationType_enum_1.NotificationType.WARNING,
|
|
38
|
+
targets: [{ type: scopeType_enum_1.ScopeType.ROLE, key: ADMIN_ROLE }],
|
|
39
|
+
payload: { route: "/usuarios" },
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async onTwoFactorReset(event) {
|
|
44
|
+
await this.safePublish(appEvent_enum_1.AppEvent.USER_TWO_FACTOR_RESET, () => this.publisher.publishAndPush({
|
|
45
|
+
title: "Seu segundo fator foi redefinido",
|
|
46
|
+
body: "Um administrador redefiniu seu segundo fator de autenticação. Você vai configurá-lo novamente no próximo acesso.",
|
|
47
|
+
type: notificationType_enum_1.NotificationType.WARNING,
|
|
48
|
+
targets: [{ type: scopeType_enum_1.ScopeType.USER, key: event.userId }],
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
async onPasswordResetRequested(event) {
|
|
52
|
+
await this.safePublish(appEvent_enum_1.AppEvent.USER_PASSWORD_RESET_REQUESTED, () => this.publisher.publishAndPush({
|
|
53
|
+
title: "Redefinição de senha solicitada",
|
|
54
|
+
body: "Um administrador enviou um link de redefinição de senha para o seu email.",
|
|
55
|
+
type: notificationType_enum_1.NotificationType.INFO,
|
|
56
|
+
targets: [{ type: scopeType_enum_1.ScopeType.USER, key: event.userId }],
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
async onPasswordExpiring(event) {
|
|
60
|
+
await this.safePublish(appEvent_enum_1.AppEvent.USER_PASSWORD_EXPIRING, () => this.publisher.publishAndPush({
|
|
61
|
+
title: "Sua senha está para vencer",
|
|
62
|
+
body: event.daysLeft === 1
|
|
63
|
+
? "Sua senha vence amanhã. Troque agora para não perder o acesso."
|
|
64
|
+
: `Sua senha vence em ${event.daysLeft} dias. Troque antes disso para não perder o acesso.`,
|
|
65
|
+
type: notificationType_enum_1.NotificationType.WARNING,
|
|
66
|
+
targets: [{ type: scopeType_enum_1.ScopeType.USER, key: event.userId }],
|
|
67
|
+
payload: { route: "/perfil" },
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
async onCleanupFailed(event) {
|
|
71
|
+
await this.safePublish(appEvent_enum_1.AppEvent.SYSTEM_CLEANUP_FAILED, () => this.publisher.publishAndPush({
|
|
72
|
+
title: "Falha em rotina automática",
|
|
73
|
+
body: `A rotina "${event.routine}" falhou: ${event.reason}`,
|
|
74
|
+
type: notificationType_enum_1.NotificationType.ERROR,
|
|
75
|
+
targets: [{ type: scopeType_enum_1.ScopeType.ROLE, key: ADMIN_ROLE }],
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
async safePublish(event, run) {
|
|
79
|
+
try {
|
|
80
|
+
await run();
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
this.logger.error(`Falha ao notificar ${event}: ${err instanceof Error ? err.message : String(err)}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.DomainEventsListener = DomainEventsListener;
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, event_emitter_1.OnEvent)(appEvent_enum_1.AppEvent.USER_LOCKED),
|
|
90
|
+
__metadata("design:type", Function),
|
|
91
|
+
__metadata("design:paramtypes", [Object]),
|
|
92
|
+
__metadata("design:returntype", Promise)
|
|
93
|
+
], DomainEventsListener.prototype, "onUserLocked", null);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, event_emitter_1.OnEvent)(appEvent_enum_1.AppEvent.USER_TWO_FACTOR_RESET),
|
|
96
|
+
__metadata("design:type", Function),
|
|
97
|
+
__metadata("design:paramtypes", [Object]),
|
|
98
|
+
__metadata("design:returntype", Promise)
|
|
99
|
+
], DomainEventsListener.prototype, "onTwoFactorReset", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, event_emitter_1.OnEvent)(appEvent_enum_1.AppEvent.USER_PASSWORD_RESET_REQUESTED),
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", [Object]),
|
|
104
|
+
__metadata("design:returntype", Promise)
|
|
105
|
+
], DomainEventsListener.prototype, "onPasswordResetRequested", null);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, event_emitter_1.OnEvent)(appEvent_enum_1.AppEvent.USER_PASSWORD_EXPIRING),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", [Object]),
|
|
110
|
+
__metadata("design:returntype", Promise)
|
|
111
|
+
], DomainEventsListener.prototype, "onPasswordExpiring", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, event_emitter_1.OnEvent)(appEvent_enum_1.AppEvent.SYSTEM_CLEANUP_FAILED),
|
|
114
|
+
__metadata("design:type", Function),
|
|
115
|
+
__metadata("design:paramtypes", [Object]),
|
|
116
|
+
__metadata("design:returntype", Promise)
|
|
117
|
+
], DomainEventsListener.prototype, "onCleanupFailed", null);
|
|
118
|
+
exports.DomainEventsListener = DomainEventsListener = DomainEventsListener_1 = __decorate([
|
|
119
|
+
(0, common_1.Injectable)(),
|
|
120
|
+
__metadata("design:paramtypes", [notifications_publisher_1.NotificationsPublisher])
|
|
121
|
+
], DomainEventsListener);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthenticatedUser } from "../../../core/auth/authenticatedUser.interface";
|
|
2
|
+
import { Paginated, PaginationQuery } from "../../../core/utils/pagination.util";
|
|
3
|
+
import { NotificationsService, UserNotification } from "../domain/notifications.service";
|
|
4
|
+
import { CreateNotificationCommand } from "./commands/createNotification.command";
|
|
5
|
+
import { NotificationsPublisher } from "./notifications.publisher";
|
|
6
|
+
import { UnreadCountResponse, UserNotificationResponse } from "./responses/notification.response";
|
|
7
|
+
export declare class NotificationsController {
|
|
8
|
+
private readonly notifications;
|
|
9
|
+
private readonly publisher;
|
|
10
|
+
constructor(notifications: NotificationsService, publisher: NotificationsPublisher);
|
|
11
|
+
list(user: AuthenticatedUser, query: PaginationQuery): Promise<Paginated<UserNotification>>;
|
|
12
|
+
unreadCount(user: AuthenticatedUser): Promise<UnreadCountResponse>;
|
|
13
|
+
markAllAsRead(user: AuthenticatedUser): Promise<void>;
|
|
14
|
+
markAsRead(id: string, user: AuthenticatedUser): Promise<void>;
|
|
15
|
+
create(command: CreateNotificationCommand, user: AuthenticatedUser): Promise<UserNotificationResponse>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.NotificationsController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const currentUser_decorator_1 = require("../../../core/auth/decorators/currentUser.decorator");
|
|
19
|
+
const requirePermission_decorator_1 = require("../../../core/auth/decorators/requirePermission.decorator");
|
|
20
|
+
const permissions_guard_1 = require("../../../core/auth/guards/permissions.guard");
|
|
21
|
+
const pagination_util_1 = require("../../../core/utils/pagination.util");
|
|
22
|
+
const notifications_service_1 = require("../domain/notifications.service");
|
|
23
|
+
const createNotification_command_1 = require("./commands/createNotification.command");
|
|
24
|
+
const notifications_publisher_1 = require("./notifications.publisher");
|
|
25
|
+
const notification_response_1 = require("./responses/notification.response");
|
|
26
|
+
let NotificationsController = class NotificationsController {
|
|
27
|
+
constructor(notifications, publisher) {
|
|
28
|
+
this.notifications = notifications;
|
|
29
|
+
this.publisher = publisher;
|
|
30
|
+
}
|
|
31
|
+
list(user, query) {
|
|
32
|
+
return this.notifications.findByUser(user, query);
|
|
33
|
+
}
|
|
34
|
+
async unreadCount(user) {
|
|
35
|
+
return { unread: await this.notifications.countUnread(user) };
|
|
36
|
+
}
|
|
37
|
+
async markAllAsRead(user) {
|
|
38
|
+
await this.notifications.markAllAsRead(user);
|
|
39
|
+
}
|
|
40
|
+
async markAsRead(id, user) {
|
|
41
|
+
await this.notifications.markAsRead(id, user);
|
|
42
|
+
}
|
|
43
|
+
create(command, user) {
|
|
44
|
+
return this.publisher.publishAndPush({
|
|
45
|
+
title: command.title,
|
|
46
|
+
body: command.body,
|
|
47
|
+
type: command.type,
|
|
48
|
+
payload: command.payload ?? null,
|
|
49
|
+
targets: command.targets,
|
|
50
|
+
createdBy: user.id,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.NotificationsController = NotificationsController;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, common_1.Get)(),
|
|
57
|
+
(0, requirePermission_decorator_1.RequirePermission)("notifications:read:own"),
|
|
58
|
+
(0, swagger_1.ApiOkResponse)({ type: notification_response_1.PaginatedNotificationsResponse }),
|
|
59
|
+
__param(0, (0, currentUser_decorator_1.CurrentUser)()),
|
|
60
|
+
__param(1, (0, common_1.Query)()),
|
|
61
|
+
__metadata("design:type", Function),
|
|
62
|
+
__metadata("design:paramtypes", [Object, pagination_util_1.PaginationQuery]),
|
|
63
|
+
__metadata("design:returntype", Promise)
|
|
64
|
+
], NotificationsController.prototype, "list", null);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, common_1.Get)("unread-count"),
|
|
67
|
+
(0, requirePermission_decorator_1.RequirePermission)("notifications:read:own"),
|
|
68
|
+
(0, swagger_1.ApiOkResponse)({ type: notification_response_1.UnreadCountResponse }),
|
|
69
|
+
__param(0, (0, currentUser_decorator_1.CurrentUser)()),
|
|
70
|
+
__metadata("design:type", Function),
|
|
71
|
+
__metadata("design:paramtypes", [Object]),
|
|
72
|
+
__metadata("design:returntype", Promise)
|
|
73
|
+
], NotificationsController.prototype, "unreadCount", null);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, common_1.Patch)("read-all"),
|
|
76
|
+
(0, requirePermission_decorator_1.RequirePermission)("notifications:read:own"),
|
|
77
|
+
__param(0, (0, currentUser_decorator_1.CurrentUser)()),
|
|
78
|
+
__metadata("design:type", Function),
|
|
79
|
+
__metadata("design:paramtypes", [Object]),
|
|
80
|
+
__metadata("design:returntype", Promise)
|
|
81
|
+
], NotificationsController.prototype, "markAllAsRead", null);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, common_1.Patch)(":id/read"),
|
|
84
|
+
(0, requirePermission_decorator_1.RequirePermission)("notifications:read:own"),
|
|
85
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
86
|
+
__param(1, (0, currentUser_decorator_1.CurrentUser)()),
|
|
87
|
+
__metadata("design:type", Function),
|
|
88
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
89
|
+
__metadata("design:returntype", Promise)
|
|
90
|
+
], NotificationsController.prototype, "markAsRead", null);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, common_1.Post)(),
|
|
93
|
+
(0, requirePermission_decorator_1.RequirePermission)("notifications:create:any"),
|
|
94
|
+
(0, swagger_1.ApiCreatedResponse)({ type: notification_response_1.UserNotificationResponse }),
|
|
95
|
+
__param(0, (0, common_1.Body)()),
|
|
96
|
+
__param(1, (0, currentUser_decorator_1.CurrentUser)()),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", [createNotification_command_1.CreateNotificationCommand, Object]),
|
|
99
|
+
__metadata("design:returntype", Promise)
|
|
100
|
+
], NotificationsController.prototype, "create", null);
|
|
101
|
+
exports.NotificationsController = NotificationsController = __decorate([
|
|
102
|
+
(0, swagger_1.ApiTags)("Notifications"),
|
|
103
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
104
|
+
(0, common_1.UseGuards)(permissions_guard_1.PermissionsGuard),
|
|
105
|
+
(0, common_1.Controller)({ path: "notifications", version: "1" }),
|
|
106
|
+
__metadata("design:paramtypes", [notifications_service_1.NotificationsService,
|
|
107
|
+
notifications_publisher_1.NotificationsPublisher])
|
|
108
|
+
], NotificationsController);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Server } from "socket.io";
|
|
2
|
+
import { EnvService } from "../../../core/config/env.service";
|
|
3
|
+
import { BaseGateway } from "../../../core/websocket/baseGateway";
|
|
4
|
+
import { WsAuthService } from "../../../core/websocket/wsAuth.service";
|
|
5
|
+
import { NotificationTarget } from "../domain/notifications.service";
|
|
6
|
+
import { UserNotificationResponse } from "./responses/notification.response";
|
|
7
|
+
export declare const NOTIFICATION_CREATED_EVENT = "notification:created";
|
|
8
|
+
export declare class NotificationsGateway extends BaseGateway {
|
|
9
|
+
protected server: Server;
|
|
10
|
+
constructor(wsAuth: WsAuthService, env: EnvService);
|
|
11
|
+
notify(targets: NotificationTarget[], notification: UserNotificationResponse): void;
|
|
12
|
+
private roomOf;
|
|
13
|
+
}
|