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,58 @@
|
|
|
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.NotificationsGateway = exports.NOTIFICATION_CREATED_EVENT = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const websockets_1 = require("@nestjs/websockets");
|
|
15
|
+
const socket_io_1 = require("socket.io");
|
|
16
|
+
const env_service_1 = require("../../../core/config/env.service");
|
|
17
|
+
const baseGateway_1 = require("../../../core/websocket/baseGateway");
|
|
18
|
+
const socket_constants_1 = require("../../../core/websocket/socket.constants");
|
|
19
|
+
const socketEvent_envelope_1 = require("../../../core/websocket/socketEvent.envelope");
|
|
20
|
+
const socketOrigin_util_1 = require("../../../core/websocket/socketOrigin.util");
|
|
21
|
+
const wsAuth_service_1 = require("../../../core/websocket/wsAuth.service");
|
|
22
|
+
const scopeType_enum_1 = require("../domain/enums/scopeType.enum");
|
|
23
|
+
exports.NOTIFICATION_CREATED_EVENT = "notification:created";
|
|
24
|
+
const gatewayOrigins = (0, socketOrigin_util_1.parseAllowedOrigins)(process.env.CORS_ORIGIN ?? "http://localhost:4000");
|
|
25
|
+
let NotificationsGateway = class NotificationsGateway extends baseGateway_1.BaseGateway {
|
|
26
|
+
constructor(wsAuth, env) {
|
|
27
|
+
super(wsAuth, env);
|
|
28
|
+
}
|
|
29
|
+
notify(targets, notification) {
|
|
30
|
+
if (targets.some((target) => target.type === scopeType_enum_1.ScopeType.ALL)) {
|
|
31
|
+
this.server.emit(exports.NOTIFICATION_CREATED_EVENT, (0, socketEvent_envelope_1.wrapSocketEvent)(exports.NOTIFICATION_CREATED_EVENT, notification));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.emitTo(targets.map((target) => this.roomOf(target)), exports.NOTIFICATION_CREATED_EVENT, notification);
|
|
35
|
+
}
|
|
36
|
+
roomOf(target) {
|
|
37
|
+
if (target.type === scopeType_enum_1.ScopeType.USER && target.key) {
|
|
38
|
+
return (0, socket_constants_1.userRoom)(target.key);
|
|
39
|
+
}
|
|
40
|
+
if (target.type === scopeType_enum_1.ScopeType.ROLE && target.key) {
|
|
41
|
+
return (0, socket_constants_1.roleRoom)(target.key);
|
|
42
|
+
}
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.NotificationsGateway = NotificationsGateway;
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, websockets_1.WebSocketServer)(),
|
|
49
|
+
__metadata("design:type", socket_io_1.Server)
|
|
50
|
+
], NotificationsGateway.prototype, "server", void 0);
|
|
51
|
+
exports.NotificationsGateway = NotificationsGateway = __decorate([
|
|
52
|
+
(0, common_1.Injectable)(),
|
|
53
|
+
(0, websockets_1.WebSocketGateway)({
|
|
54
|
+
namespace: socket_constants_1.NOTIFICATIONS_NAMESPACE,
|
|
55
|
+
cors: { origin: gatewayOrigins, credentials: true },
|
|
56
|
+
}),
|
|
57
|
+
__metadata("design:paramtypes", [wsAuth_service_1.WsAuthService, env_service_1.EnvService])
|
|
58
|
+
], NotificationsGateway);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NotificationsService, PublishNotificationParams } from "../domain/notifications.service";
|
|
2
|
+
import { NotificationsGateway } from "./notifications.gateway";
|
|
3
|
+
import { UserNotificationResponse } from "./responses/notification.response";
|
|
4
|
+
export declare class NotificationsPublisher {
|
|
5
|
+
private readonly notifications;
|
|
6
|
+
private readonly gateway;
|
|
7
|
+
constructor(notifications: NotificationsService, gateway: NotificationsGateway);
|
|
8
|
+
publishAndPush(params: PublishNotificationParams): Promise<UserNotificationResponse>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.NotificationsPublisher = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const notifications_service_1 = require("../domain/notifications.service");
|
|
15
|
+
const notifications_gateway_1 = require("./notifications.gateway");
|
|
16
|
+
let NotificationsPublisher = class NotificationsPublisher {
|
|
17
|
+
constructor(notifications, gateway) {
|
|
18
|
+
this.notifications = notifications;
|
|
19
|
+
this.gateway = gateway;
|
|
20
|
+
}
|
|
21
|
+
async publishAndPush(params) {
|
|
22
|
+
const saved = await this.notifications.publish(params);
|
|
23
|
+
const payload = params.payload;
|
|
24
|
+
const response = {
|
|
25
|
+
id: saved.id,
|
|
26
|
+
title: saved.title,
|
|
27
|
+
body: saved.body,
|
|
28
|
+
type: saved.type,
|
|
29
|
+
route: payload?.route ?? null,
|
|
30
|
+
read: false,
|
|
31
|
+
createdAt: saved.createdAt,
|
|
32
|
+
};
|
|
33
|
+
this.gateway.notify(params.targets, response);
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.NotificationsPublisher = NotificationsPublisher;
|
|
38
|
+
exports.NotificationsPublisher = NotificationsPublisher = __decorate([
|
|
39
|
+
(0, common_1.Injectable)(),
|
|
40
|
+
__metadata("design:paramtypes", [notifications_service_1.NotificationsService,
|
|
41
|
+
notifications_gateway_1.NotificationsGateway])
|
|
42
|
+
], NotificationsPublisher);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PaginationMetaResponse } from "../../../../core/utils/paginationMeta.response";
|
|
2
|
+
import { NotificationType } from "../../domain/enums/notificationType.enum";
|
|
3
|
+
export declare class UserNotificationResponse {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
body: string;
|
|
7
|
+
type: NotificationType;
|
|
8
|
+
route: string | null;
|
|
9
|
+
read: boolean;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
}
|
|
12
|
+
export declare class PaginatedNotificationsResponse {
|
|
13
|
+
items: UserNotificationResponse[];
|
|
14
|
+
meta: PaginationMetaResponse;
|
|
15
|
+
}
|
|
16
|
+
export declare class UnreadCountResponse {
|
|
17
|
+
unread: number;
|
|
18
|
+
}
|
|
@@ -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.UnreadCountResponse = exports.PaginatedNotificationsResponse = exports.UserNotificationResponse = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const paginationMeta_response_1 = require("../../../../core/utils/paginationMeta.response");
|
|
15
|
+
const notificationType_enum_1 = require("../../domain/enums/notificationType.enum");
|
|
16
|
+
class UserNotificationResponse {
|
|
17
|
+
}
|
|
18
|
+
exports.UserNotificationResponse = UserNotificationResponse;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, swagger_1.ApiProperty)({ format: "uuid" }),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], UserNotificationResponse.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, swagger_1.ApiProperty)({ example: "Sua conta foi bloqueada" }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], UserNotificationResponse.prototype, "title", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, swagger_1.ApiProperty)({
|
|
29
|
+
example: "Foram feitas 10 tentativas de acesso sem sucesso.",
|
|
30
|
+
}),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], UserNotificationResponse.prototype, "body", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, swagger_1.ApiProperty)({ enum: notificationType_enum_1.NotificationType, enumName: "NotificationType" }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], UserNotificationResponse.prototype, "type", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiProperty)({
|
|
39
|
+
type: String,
|
|
40
|
+
required: false,
|
|
41
|
+
nullable: true,
|
|
42
|
+
example: "/usuarios",
|
|
43
|
+
description: "Rota do cliente para abrir ao clicar. Nulo quando não há.",
|
|
44
|
+
}),
|
|
45
|
+
__metadata("design:type", Object)
|
|
46
|
+
], UserNotificationResponse.prototype, "route", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)(),
|
|
49
|
+
__metadata("design:type", Boolean)
|
|
50
|
+
], UserNotificationResponse.prototype, "read", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiProperty)({ format: "date-time" }),
|
|
53
|
+
__metadata("design:type", Date)
|
|
54
|
+
], UserNotificationResponse.prototype, "createdAt", void 0);
|
|
55
|
+
class PaginatedNotificationsResponse {
|
|
56
|
+
}
|
|
57
|
+
exports.PaginatedNotificationsResponse = PaginatedNotificationsResponse;
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, swagger_1.ApiProperty)({ type: [UserNotificationResponse] }),
|
|
60
|
+
__metadata("design:type", Array)
|
|
61
|
+
], PaginatedNotificationsResponse.prototype, "items", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, swagger_1.ApiProperty)({ type: paginationMeta_response_1.PaginationMetaResponse }),
|
|
64
|
+
__metadata("design:type", paginationMeta_response_1.PaginationMetaResponse)
|
|
65
|
+
], PaginatedNotificationsResponse.prototype, "meta", void 0);
|
|
66
|
+
class UnreadCountResponse {
|
|
67
|
+
}
|
|
68
|
+
exports.UnreadCountResponse = UnreadCountResponse;
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, swagger_1.ApiProperty)({ example: 3 }),
|
|
71
|
+
__metadata("design:type", Number)
|
|
72
|
+
], UnreadCountResponse.prototype, "unread", void 0);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./rbac.catalog"), exports);
|
|
18
|
+
__exportStar(require("./rbac.service"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const RESOURCES: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
}[];
|
|
5
|
+
export declare const ACTIONS: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const SCOPES: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const PERMISSIONS: {
|
|
14
|
+
code: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}[];
|
|
17
|
+
export declare const ROLES: {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
permissions: string[] | "*";
|
|
21
|
+
}[];
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROLES = exports.PERMISSIONS = exports.SCOPES = exports.ACTIONS = exports.RESOURCES = void 0;
|
|
4
|
+
exports.RESOURCES = [
|
|
5
|
+
{ name: "users", description: "Gestão de usuários" },
|
|
6
|
+
{ name: "roles", description: "Gestão de papéis" },
|
|
7
|
+
{ name: "permissions", description: "Gestão de permissões" },
|
|
8
|
+
{ name: "groups", description: "Gestão de grupos" },
|
|
9
|
+
{ name: "audit", description: "Logs e auditoria" },
|
|
10
|
+
{ name: "notifications", description: "Notificações" },
|
|
11
|
+
{ name: "reports", description: "Relatórios" },
|
|
12
|
+
{ name: "resources", description: "Catálogo RBAC — resources" },
|
|
13
|
+
{ name: "actions", description: "Catálogo RBAC — actions" },
|
|
14
|
+
{ name: "scopes", description: "Catálogo RBAC — scopes" },
|
|
15
|
+
];
|
|
16
|
+
exports.ACTIONS = [
|
|
17
|
+
{ name: "create", description: "Criar" },
|
|
18
|
+
{ name: "read", description: "Ler/visualizar" },
|
|
19
|
+
{ name: "update", description: "Atualizar" },
|
|
20
|
+
{ name: "delete", description: "Remover" },
|
|
21
|
+
{ name: "export", description: "Exportar" },
|
|
22
|
+
{ name: "promote", description: "Alterar papel/promover" },
|
|
23
|
+
{ name: "deactivate", description: "Ativar/desativar" },
|
|
24
|
+
{ name: "reset-password", description: "Resetar senha de usuário" },
|
|
25
|
+
{ name: "invite", description: "Enviar link de primeiro acesso" },
|
|
26
|
+
{ name: "update-email", description: "Alterar email de usuário" },
|
|
27
|
+
{
|
|
28
|
+
name: "read-trail",
|
|
29
|
+
description: "Ler trilha de auditoria de dados (old/new data)",
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
exports.SCOPES = [
|
|
33
|
+
{ name: "own", description: "Apenas recursos próprios" },
|
|
34
|
+
{ name: "team", description: "Recursos da equipe" },
|
|
35
|
+
{ name: "department", description: "Recursos do departamento" },
|
|
36
|
+
{ name: "any", description: "Todos os recursos" },
|
|
37
|
+
];
|
|
38
|
+
exports.PERMISSIONS = [
|
|
39
|
+
{ code: "users:create:any", description: "Criar qualquer usuário" },
|
|
40
|
+
{ code: "users:read:any", description: "Ler qualquer usuário" },
|
|
41
|
+
{ code: "users:read:own", description: "Ler o próprio perfil" },
|
|
42
|
+
{ code: "users:update:any", description: "Atualizar qualquer usuário" },
|
|
43
|
+
{
|
|
44
|
+
code: "users:update-email:any",
|
|
45
|
+
description: "Alterar o email de qualquer usuário — restrito a administradores (risco de sequestro de conta)",
|
|
46
|
+
},
|
|
47
|
+
{ code: "users:update:own", description: "Atualizar o próprio perfil" },
|
|
48
|
+
{ code: "users:delete:any", description: "Remover qualquer usuário" },
|
|
49
|
+
{
|
|
50
|
+
code: "users:promote:any",
|
|
51
|
+
description: "Alterar papéis de qualquer usuário",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
code: "users:deactivate:any",
|
|
55
|
+
description: "Ativar/desativar qualquer usuário",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
code: "users:reset-password:any",
|
|
59
|
+
description: "Resetar senha de qualquer usuário",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
code: "users:invite:any",
|
|
63
|
+
description: "Enviar link de primeiro acesso a qualquer usuário",
|
|
64
|
+
},
|
|
65
|
+
{ code: "roles:create:any", description: "Criar papéis" },
|
|
66
|
+
{ code: "roles:read:any", description: "Ler papéis" },
|
|
67
|
+
{ code: "roles:update:any", description: "Atualizar papéis" },
|
|
68
|
+
{ code: "roles:delete:any", description: "Remover papéis" },
|
|
69
|
+
{ code: "permissions:create:any", description: "Criar permissões" },
|
|
70
|
+
{ code: "permissions:read:any", description: "Ler permissões" },
|
|
71
|
+
{ code: "permissions:update:any", description: "Atualizar permissões" },
|
|
72
|
+
{ code: "permissions:delete:any", description: "Remover permissões" },
|
|
73
|
+
{ code: "groups:create:any", description: "Criar grupos" },
|
|
74
|
+
{ code: "groups:read:any", description: "Ler grupos" },
|
|
75
|
+
{ code: "groups:update:any", description: "Atualizar grupos" },
|
|
76
|
+
{ code: "groups:delete:any", description: "Remover grupos" },
|
|
77
|
+
{ code: "audit:read:any", description: "Ler logs de auditoria" },
|
|
78
|
+
{
|
|
79
|
+
code: "audit:read-trail:any",
|
|
80
|
+
description: "Ler trilha de auditoria de dados (old/new data) — restrito a administradores",
|
|
81
|
+
},
|
|
82
|
+
{ code: "reports:read:any", description: "Ler todos os relatórios" },
|
|
83
|
+
{
|
|
84
|
+
code: "reports:read:department",
|
|
85
|
+
description: "Ler relatórios do departamento",
|
|
86
|
+
},
|
|
87
|
+
{ code: "reports:export:any", description: "Exportar todos os relatórios" },
|
|
88
|
+
{
|
|
89
|
+
code: "notifications:read:own",
|
|
90
|
+
description: "Ler e marcar como lidas as próprias notificações",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
code: "notifications:create:any",
|
|
94
|
+
description: "Criar notificação para qualquer usuário ou papel",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
code: "resources:create:any",
|
|
98
|
+
description: "Criar resources do catálogo RBAC",
|
|
99
|
+
},
|
|
100
|
+
{ code: "resources:read:any", description: "Ler resources do catálogo RBAC" },
|
|
101
|
+
{
|
|
102
|
+
code: "resources:update:any",
|
|
103
|
+
description: "Atualizar resources do catálogo RBAC",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
code: "resources:delete:any",
|
|
107
|
+
description: "Remover resources do catálogo RBAC",
|
|
108
|
+
},
|
|
109
|
+
{ code: "actions:create:any", description: "Criar actions do catálogo RBAC" },
|
|
110
|
+
{ code: "actions:read:any", description: "Ler actions do catálogo RBAC" },
|
|
111
|
+
{
|
|
112
|
+
code: "actions:update:any",
|
|
113
|
+
description: "Atualizar actions do catálogo RBAC",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
code: "actions:delete:any",
|
|
117
|
+
description: "Remover actions do catálogo RBAC",
|
|
118
|
+
},
|
|
119
|
+
{ code: "scopes:create:any", description: "Criar scopes do catálogo RBAC" },
|
|
120
|
+
{ code: "scopes:read:any", description: "Ler scopes do catálogo RBAC" },
|
|
121
|
+
{
|
|
122
|
+
code: "scopes:update:any",
|
|
123
|
+
description: "Atualizar scopes do catálogo RBAC",
|
|
124
|
+
},
|
|
125
|
+
{ code: "scopes:delete:any", description: "Remover scopes do catálogo RBAC" },
|
|
126
|
+
];
|
|
127
|
+
exports.ROLES = [
|
|
128
|
+
{
|
|
129
|
+
name: "Super Admin",
|
|
130
|
+
description: "Acesso total ao sistema",
|
|
131
|
+
permissions: "*",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "Manager",
|
|
135
|
+
description: "Gestor de departamento",
|
|
136
|
+
permissions: [
|
|
137
|
+
"users:read:any",
|
|
138
|
+
"reports:read:department",
|
|
139
|
+
"reports:read:any",
|
|
140
|
+
"audit:read:any",
|
|
141
|
+
"notifications:read:own",
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "Viewer",
|
|
146
|
+
description: "Somente leitura",
|
|
147
|
+
permissions: [
|
|
148
|
+
"users:read:own",
|
|
149
|
+
"reports:read:department",
|
|
150
|
+
"notifications:read:own",
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ActionRepository } from "../infra/repositories/action.repository";
|
|
2
|
+
import { GroupRepository } from "../infra/repositories/group.repository";
|
|
3
|
+
import { PermissionRepository } from "../infra/repositories/permission.repository";
|
|
4
|
+
import { ResourceRepository } from "../infra/repositories/resource.repository";
|
|
5
|
+
import { RoleRepository } from "../infra/repositories/role.repository";
|
|
6
|
+
import { ScopeRepository } from "../infra/repositories/scope.repository";
|
|
7
|
+
import { Action } from "../infra/schema/action.schema";
|
|
8
|
+
import { Group } from "../infra/schema/group.schema";
|
|
9
|
+
import { Permission } from "../infra/schema/permission.schema";
|
|
10
|
+
import { Resource } from "../infra/schema/resource.schema";
|
|
11
|
+
import { Role } from "../infra/schema/role.schema";
|
|
12
|
+
import { Scope } from "../infra/schema/scope.schema";
|
|
13
|
+
import { CreateActionCommand } from "../presentation/commands/createAction.command";
|
|
14
|
+
import { CreateGroupCommand } from "../presentation/commands/createGroup.command";
|
|
15
|
+
import { CreatePermissionCommand } from "../presentation/commands/createPermission.command";
|
|
16
|
+
import { CreateResourceCommand } from "../presentation/commands/createResource.command";
|
|
17
|
+
import { CreateRoleCommand } from "../presentation/commands/createRole.command";
|
|
18
|
+
import { CreateScopeCommand } from "../presentation/commands/createScope.command";
|
|
19
|
+
import { UpdateActionCommand } from "../presentation/commands/updateAction.command";
|
|
20
|
+
import { UpdateGroupCommand } from "../presentation/commands/updateGroup.command";
|
|
21
|
+
import { UpdatePermissionCommand } from "../presentation/commands/updatePermission.command";
|
|
22
|
+
import { UpdateResourceCommand } from "../presentation/commands/updateResource.command";
|
|
23
|
+
import { UpdateRoleCommand } from "../presentation/commands/updateRole.command";
|
|
24
|
+
import { UpdateScopeCommand } from "../presentation/commands/updateScope.command";
|
|
25
|
+
import { UserRepository } from "../../users/infra/repositories/user.repository";
|
|
26
|
+
export declare class RbacService {
|
|
27
|
+
private readonly resourceRepo;
|
|
28
|
+
private readonly actionRepo;
|
|
29
|
+
private readonly scopeRepo;
|
|
30
|
+
private readonly permissionRepo;
|
|
31
|
+
private readonly roleRepo;
|
|
32
|
+
private readonly groupRepo;
|
|
33
|
+
private readonly userRepo;
|
|
34
|
+
constructor(resourceRepo: ResourceRepository, actionRepo: ActionRepository, scopeRepo: ScopeRepository, permissionRepo: PermissionRepository, roleRepo: RoleRepository, groupRepo: GroupRepository, userRepo: UserRepository);
|
|
35
|
+
getUserPermissionCodes(userId: string): Promise<string[]>;
|
|
36
|
+
getUserRoleNames(userId: string): Promise<string[]>;
|
|
37
|
+
listResources(): Promise<Resource[]>;
|
|
38
|
+
createResource(dto: CreateResourceCommand): Promise<Resource>;
|
|
39
|
+
updateResource(id: string, dto: UpdateResourceCommand): Promise<Resource>;
|
|
40
|
+
deleteResource(id: string): Promise<void>;
|
|
41
|
+
listActions(): Promise<Action[]>;
|
|
42
|
+
createAction(dto: CreateActionCommand): Promise<Action>;
|
|
43
|
+
updateAction(id: string, dto: UpdateActionCommand): Promise<Action>;
|
|
44
|
+
deleteAction(id: string): Promise<void>;
|
|
45
|
+
listScopes(): Promise<Scope[]>;
|
|
46
|
+
createScope(dto: CreateScopeCommand): Promise<Scope>;
|
|
47
|
+
updateScope(id: string, dto: UpdateScopeCommand): Promise<Scope>;
|
|
48
|
+
deleteScope(id: string): Promise<void>;
|
|
49
|
+
listPermissions(): Promise<Permission[]>;
|
|
50
|
+
createPermission(dto: CreatePermissionCommand): Promise<Permission>;
|
|
51
|
+
updatePermission(id: string, dto: UpdatePermissionCommand): Promise<Permission>;
|
|
52
|
+
deletePermission(id: string): Promise<void>;
|
|
53
|
+
listRoles(): Promise<Role[]>;
|
|
54
|
+
getRole(id: string): Promise<Role>;
|
|
55
|
+
createRole(dto: CreateRoleCommand): Promise<Role>;
|
|
56
|
+
updateRole(id: string, dto: UpdateRoleCommand, actorPermissions?: string[]): Promise<Role>;
|
|
57
|
+
private assertGrantableByActor;
|
|
58
|
+
deleteRole(id: string): Promise<void>;
|
|
59
|
+
addPermissionToRole(roleId: string, permissionId: string, actorPermissions?: string[]): Promise<Role>;
|
|
60
|
+
removePermissionFromRole(roleId: string, permissionId: string): Promise<Role>;
|
|
61
|
+
listGroups(): Promise<Group[]>;
|
|
62
|
+
getGroup(id: string): Promise<Group>;
|
|
63
|
+
createGroup(dto: CreateGroupCommand): Promise<Group>;
|
|
64
|
+
updateGroup(id: string, dto: UpdateGroupCommand): Promise<Group>;
|
|
65
|
+
deleteGroup(id: string): Promise<void>;
|
|
66
|
+
addUserToGroup(groupId: string, userId: string): Promise<void>;
|
|
67
|
+
removeUserFromGroup(groupId: string, userId: string): Promise<void>;
|
|
68
|
+
}
|