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,413 @@
|
|
|
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.RbacController = 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 rbac_service_1 = require("../domain/rbac.service");
|
|
22
|
+
const createAction_command_1 = require("./commands/createAction.command");
|
|
23
|
+
const createGroup_command_1 = require("./commands/createGroup.command");
|
|
24
|
+
const createPermission_command_1 = require("./commands/createPermission.command");
|
|
25
|
+
const createResource_command_1 = require("./commands/createResource.command");
|
|
26
|
+
const createRole_command_1 = require("./commands/createRole.command");
|
|
27
|
+
const createScope_command_1 = require("./commands/createScope.command");
|
|
28
|
+
const updateAction_command_1 = require("./commands/updateAction.command");
|
|
29
|
+
const updateGroup_command_1 = require("./commands/updateGroup.command");
|
|
30
|
+
const updatePermission_command_1 = require("./commands/updatePermission.command");
|
|
31
|
+
const updateResource_command_1 = require("./commands/updateResource.command");
|
|
32
|
+
const updateRole_command_1 = require("./commands/updateRole.command");
|
|
33
|
+
const updateScope_command_1 = require("./commands/updateScope.command");
|
|
34
|
+
const rbac_response_1 = require("./responses/rbac.response");
|
|
35
|
+
let RbacController = class RbacController {
|
|
36
|
+
constructor(rbac) {
|
|
37
|
+
this.rbac = rbac;
|
|
38
|
+
}
|
|
39
|
+
resources() {
|
|
40
|
+
return this.rbac.listResources();
|
|
41
|
+
}
|
|
42
|
+
createResource(dto) {
|
|
43
|
+
return this.rbac.createResource(dto);
|
|
44
|
+
}
|
|
45
|
+
updateResource(id, dto) {
|
|
46
|
+
return this.rbac.updateResource(id, dto);
|
|
47
|
+
}
|
|
48
|
+
deleteResource(id) {
|
|
49
|
+
return this.rbac.deleteResource(id);
|
|
50
|
+
}
|
|
51
|
+
actions() {
|
|
52
|
+
return this.rbac.listActions();
|
|
53
|
+
}
|
|
54
|
+
createAction(dto) {
|
|
55
|
+
return this.rbac.createAction(dto);
|
|
56
|
+
}
|
|
57
|
+
updateAction(id, dto) {
|
|
58
|
+
return this.rbac.updateAction(id, dto);
|
|
59
|
+
}
|
|
60
|
+
deleteAction(id) {
|
|
61
|
+
return this.rbac.deleteAction(id);
|
|
62
|
+
}
|
|
63
|
+
scopes() {
|
|
64
|
+
return this.rbac.listScopes();
|
|
65
|
+
}
|
|
66
|
+
createScope(dto) {
|
|
67
|
+
return this.rbac.createScope(dto);
|
|
68
|
+
}
|
|
69
|
+
updateScope(id, dto) {
|
|
70
|
+
return this.rbac.updateScope(id, dto);
|
|
71
|
+
}
|
|
72
|
+
deleteScope(id) {
|
|
73
|
+
return this.rbac.deleteScope(id);
|
|
74
|
+
}
|
|
75
|
+
permissions() {
|
|
76
|
+
return this.rbac.listPermissions();
|
|
77
|
+
}
|
|
78
|
+
createPermission(dto) {
|
|
79
|
+
return this.rbac.createPermission(dto);
|
|
80
|
+
}
|
|
81
|
+
updatePermission(id, dto) {
|
|
82
|
+
return this.rbac.updatePermission(id, dto);
|
|
83
|
+
}
|
|
84
|
+
deletePermission(id) {
|
|
85
|
+
return this.rbac.deletePermission(id);
|
|
86
|
+
}
|
|
87
|
+
groups() {
|
|
88
|
+
return this.rbac.listGroups();
|
|
89
|
+
}
|
|
90
|
+
group(id) {
|
|
91
|
+
return this.rbac.getGroup(id);
|
|
92
|
+
}
|
|
93
|
+
createGroup(dto) {
|
|
94
|
+
return this.rbac.createGroup(dto);
|
|
95
|
+
}
|
|
96
|
+
updateGroup(id, dto) {
|
|
97
|
+
return this.rbac.updateGroup(id, dto);
|
|
98
|
+
}
|
|
99
|
+
deleteGroup(id) {
|
|
100
|
+
return this.rbac.deleteGroup(id);
|
|
101
|
+
}
|
|
102
|
+
addUserToGroup(id, userId) {
|
|
103
|
+
return this.rbac.addUserToGroup(id, userId);
|
|
104
|
+
}
|
|
105
|
+
removeUserFromGroup(id, userId) {
|
|
106
|
+
return this.rbac.removeUserFromGroup(id, userId);
|
|
107
|
+
}
|
|
108
|
+
roles() {
|
|
109
|
+
return this.rbac.listRoles();
|
|
110
|
+
}
|
|
111
|
+
role(id) {
|
|
112
|
+
return this.rbac.getRole(id);
|
|
113
|
+
}
|
|
114
|
+
createRole(dto) {
|
|
115
|
+
return this.rbac.createRole(dto);
|
|
116
|
+
}
|
|
117
|
+
updateRole(id, dto, actor) {
|
|
118
|
+
return this.rbac.updateRole(id, dto, actor.permissions);
|
|
119
|
+
}
|
|
120
|
+
deleteRole(id) {
|
|
121
|
+
return this.rbac.deleteRole(id);
|
|
122
|
+
}
|
|
123
|
+
addPermissionToRole(id, permissionId, actor) {
|
|
124
|
+
return this.rbac.addPermissionToRole(id, permissionId, actor.permissions);
|
|
125
|
+
}
|
|
126
|
+
removePermissionFromRole(id, permissionId) {
|
|
127
|
+
return this.rbac.removePermissionFromRole(id, permissionId);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.RbacController = RbacController;
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, common_1.Get)("resources"),
|
|
133
|
+
(0, requirePermission_decorator_1.RequirePermission)("resources:read:any"),
|
|
134
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ResourceResponse, isArray: true }),
|
|
135
|
+
__metadata("design:type", Function),
|
|
136
|
+
__metadata("design:paramtypes", []),
|
|
137
|
+
__metadata("design:returntype", Promise)
|
|
138
|
+
], RbacController.prototype, "resources", null);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, common_1.Post)("resources"),
|
|
141
|
+
(0, requirePermission_decorator_1.RequirePermission)("resources:create:any"),
|
|
142
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ResourceResponse }),
|
|
143
|
+
__param(0, (0, common_1.Body)()),
|
|
144
|
+
__metadata("design:type", Function),
|
|
145
|
+
__metadata("design:paramtypes", [createResource_command_1.CreateResourceCommand]),
|
|
146
|
+
__metadata("design:returntype", Promise)
|
|
147
|
+
], RbacController.prototype, "createResource", null);
|
|
148
|
+
__decorate([
|
|
149
|
+
(0, common_1.Patch)("resources/:id"),
|
|
150
|
+
(0, requirePermission_decorator_1.RequirePermission)("resources:update:any"),
|
|
151
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ResourceResponse }),
|
|
152
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
153
|
+
__param(1, (0, common_1.Body)()),
|
|
154
|
+
__metadata("design:type", Function),
|
|
155
|
+
__metadata("design:paramtypes", [String, updateResource_command_1.UpdateResourceCommand]),
|
|
156
|
+
__metadata("design:returntype", Promise)
|
|
157
|
+
], RbacController.prototype, "updateResource", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, common_1.Delete)("resources/:id"),
|
|
160
|
+
(0, common_1.HttpCode)(204),
|
|
161
|
+
(0, requirePermission_decorator_1.RequirePermission)("resources:delete:any"),
|
|
162
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
163
|
+
__metadata("design:type", Function),
|
|
164
|
+
__metadata("design:paramtypes", [String]),
|
|
165
|
+
__metadata("design:returntype", Promise)
|
|
166
|
+
], RbacController.prototype, "deleteResource", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, common_1.Get)("actions"),
|
|
169
|
+
(0, requirePermission_decorator_1.RequirePermission)("actions:read:any"),
|
|
170
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ActionResponse, isArray: true }),
|
|
171
|
+
__metadata("design:type", Function),
|
|
172
|
+
__metadata("design:paramtypes", []),
|
|
173
|
+
__metadata("design:returntype", Promise)
|
|
174
|
+
], RbacController.prototype, "actions", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, common_1.Post)("actions"),
|
|
177
|
+
(0, requirePermission_decorator_1.RequirePermission)("actions:create:any"),
|
|
178
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ActionResponse }),
|
|
179
|
+
__param(0, (0, common_1.Body)()),
|
|
180
|
+
__metadata("design:type", Function),
|
|
181
|
+
__metadata("design:paramtypes", [createAction_command_1.CreateActionCommand]),
|
|
182
|
+
__metadata("design:returntype", Promise)
|
|
183
|
+
], RbacController.prototype, "createAction", null);
|
|
184
|
+
__decorate([
|
|
185
|
+
(0, common_1.Patch)("actions/:id"),
|
|
186
|
+
(0, requirePermission_decorator_1.RequirePermission)("actions:update:any"),
|
|
187
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ActionResponse }),
|
|
188
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
189
|
+
__param(1, (0, common_1.Body)()),
|
|
190
|
+
__metadata("design:type", Function),
|
|
191
|
+
__metadata("design:paramtypes", [String, updateAction_command_1.UpdateActionCommand]),
|
|
192
|
+
__metadata("design:returntype", Promise)
|
|
193
|
+
], RbacController.prototype, "updateAction", null);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, common_1.Delete)("actions/:id"),
|
|
196
|
+
(0, common_1.HttpCode)(204),
|
|
197
|
+
(0, requirePermission_decorator_1.RequirePermission)("actions:delete:any"),
|
|
198
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
199
|
+
__metadata("design:type", Function),
|
|
200
|
+
__metadata("design:paramtypes", [String]),
|
|
201
|
+
__metadata("design:returntype", Promise)
|
|
202
|
+
], RbacController.prototype, "deleteAction", null);
|
|
203
|
+
__decorate([
|
|
204
|
+
(0, common_1.Get)("scopes"),
|
|
205
|
+
(0, requirePermission_decorator_1.RequirePermission)("scopes:read:any"),
|
|
206
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ScopeResponse, isArray: true }),
|
|
207
|
+
__metadata("design:type", Function),
|
|
208
|
+
__metadata("design:paramtypes", []),
|
|
209
|
+
__metadata("design:returntype", Promise)
|
|
210
|
+
], RbacController.prototype, "scopes", null);
|
|
211
|
+
__decorate([
|
|
212
|
+
(0, common_1.Post)("scopes"),
|
|
213
|
+
(0, requirePermission_decorator_1.RequirePermission)("scopes:create:any"),
|
|
214
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ScopeResponse }),
|
|
215
|
+
__param(0, (0, common_1.Body)()),
|
|
216
|
+
__metadata("design:type", Function),
|
|
217
|
+
__metadata("design:paramtypes", [createScope_command_1.CreateScopeCommand]),
|
|
218
|
+
__metadata("design:returntype", Promise)
|
|
219
|
+
], RbacController.prototype, "createScope", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, common_1.Patch)("scopes/:id"),
|
|
222
|
+
(0, requirePermission_decorator_1.RequirePermission)("scopes:update:any"),
|
|
223
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.ScopeResponse }),
|
|
224
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
225
|
+
__param(1, (0, common_1.Body)()),
|
|
226
|
+
__metadata("design:type", Function),
|
|
227
|
+
__metadata("design:paramtypes", [String, updateScope_command_1.UpdateScopeCommand]),
|
|
228
|
+
__metadata("design:returntype", Promise)
|
|
229
|
+
], RbacController.prototype, "updateScope", null);
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, common_1.Delete)("scopes/:id"),
|
|
232
|
+
(0, common_1.HttpCode)(204),
|
|
233
|
+
(0, requirePermission_decorator_1.RequirePermission)("scopes:delete:any"),
|
|
234
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
235
|
+
__metadata("design:type", Function),
|
|
236
|
+
__metadata("design:paramtypes", [String]),
|
|
237
|
+
__metadata("design:returntype", Promise)
|
|
238
|
+
], RbacController.prototype, "deleteScope", null);
|
|
239
|
+
__decorate([
|
|
240
|
+
(0, common_1.Get)("permissions"),
|
|
241
|
+
(0, requirePermission_decorator_1.RequirePermission)("permissions:read:any"),
|
|
242
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.PermissionResponse, isArray: true }),
|
|
243
|
+
__metadata("design:type", Function),
|
|
244
|
+
__metadata("design:paramtypes", []),
|
|
245
|
+
__metadata("design:returntype", Promise)
|
|
246
|
+
], RbacController.prototype, "permissions", null);
|
|
247
|
+
__decorate([
|
|
248
|
+
(0, common_1.Post)("permissions"),
|
|
249
|
+
(0, requirePermission_decorator_1.RequirePermission)("permissions:create:any"),
|
|
250
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.PermissionResponse }),
|
|
251
|
+
__param(0, (0, common_1.Body)()),
|
|
252
|
+
__metadata("design:type", Function),
|
|
253
|
+
__metadata("design:paramtypes", [createPermission_command_1.CreatePermissionCommand]),
|
|
254
|
+
__metadata("design:returntype", Promise)
|
|
255
|
+
], RbacController.prototype, "createPermission", null);
|
|
256
|
+
__decorate([
|
|
257
|
+
(0, common_1.Patch)("permissions/:id"),
|
|
258
|
+
(0, requirePermission_decorator_1.RequirePermission)("permissions:update:any"),
|
|
259
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.PermissionResponse }),
|
|
260
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
261
|
+
__param(1, (0, common_1.Body)()),
|
|
262
|
+
__metadata("design:type", Function),
|
|
263
|
+
__metadata("design:paramtypes", [String, updatePermission_command_1.UpdatePermissionCommand]),
|
|
264
|
+
__metadata("design:returntype", Promise)
|
|
265
|
+
], RbacController.prototype, "updatePermission", null);
|
|
266
|
+
__decorate([
|
|
267
|
+
(0, common_1.Delete)("permissions/:id"),
|
|
268
|
+
(0, common_1.HttpCode)(204),
|
|
269
|
+
(0, requirePermission_decorator_1.RequirePermission)("permissions:delete:any"),
|
|
270
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
271
|
+
__metadata("design:type", Function),
|
|
272
|
+
__metadata("design:paramtypes", [String]),
|
|
273
|
+
__metadata("design:returntype", Promise)
|
|
274
|
+
], RbacController.prototype, "deletePermission", null);
|
|
275
|
+
__decorate([
|
|
276
|
+
(0, common_1.Get)("groups"),
|
|
277
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:read:any"),
|
|
278
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.GroupResponse, isArray: true }),
|
|
279
|
+
__metadata("design:type", Function),
|
|
280
|
+
__metadata("design:paramtypes", []),
|
|
281
|
+
__metadata("design:returntype", Promise)
|
|
282
|
+
], RbacController.prototype, "groups", null);
|
|
283
|
+
__decorate([
|
|
284
|
+
(0, common_1.Get)("groups/:id"),
|
|
285
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:read:any"),
|
|
286
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.GroupResponse }),
|
|
287
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
288
|
+
__metadata("design:type", Function),
|
|
289
|
+
__metadata("design:paramtypes", [String]),
|
|
290
|
+
__metadata("design:returntype", Promise)
|
|
291
|
+
], RbacController.prototype, "group", null);
|
|
292
|
+
__decorate([
|
|
293
|
+
(0, common_1.Post)("groups"),
|
|
294
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:create:any"),
|
|
295
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.GroupResponse }),
|
|
296
|
+
__param(0, (0, common_1.Body)()),
|
|
297
|
+
__metadata("design:type", Function),
|
|
298
|
+
__metadata("design:paramtypes", [createGroup_command_1.CreateGroupCommand]),
|
|
299
|
+
__metadata("design:returntype", Promise)
|
|
300
|
+
], RbacController.prototype, "createGroup", null);
|
|
301
|
+
__decorate([
|
|
302
|
+
(0, common_1.Patch)("groups/:id"),
|
|
303
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:update:any"),
|
|
304
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.GroupResponse }),
|
|
305
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
306
|
+
__param(1, (0, common_1.Body)()),
|
|
307
|
+
__metadata("design:type", Function),
|
|
308
|
+
__metadata("design:paramtypes", [String, updateGroup_command_1.UpdateGroupCommand]),
|
|
309
|
+
__metadata("design:returntype", Promise)
|
|
310
|
+
], RbacController.prototype, "updateGroup", null);
|
|
311
|
+
__decorate([
|
|
312
|
+
(0, common_1.Delete)("groups/:id"),
|
|
313
|
+
(0, common_1.HttpCode)(204),
|
|
314
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:delete:any"),
|
|
315
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
316
|
+
__metadata("design:type", Function),
|
|
317
|
+
__metadata("design:paramtypes", [String]),
|
|
318
|
+
__metadata("design:returntype", Promise)
|
|
319
|
+
], RbacController.prototype, "deleteGroup", null);
|
|
320
|
+
__decorate([
|
|
321
|
+
(0, common_1.Post)("groups/:id/users/:userId"),
|
|
322
|
+
(0, common_1.HttpCode)(204),
|
|
323
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:update:any"),
|
|
324
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
325
|
+
__param(1, (0, common_1.Param)("userId", common_1.ParseUUIDPipe)),
|
|
326
|
+
__metadata("design:type", Function),
|
|
327
|
+
__metadata("design:paramtypes", [String, String]),
|
|
328
|
+
__metadata("design:returntype", Promise)
|
|
329
|
+
], RbacController.prototype, "addUserToGroup", null);
|
|
330
|
+
__decorate([
|
|
331
|
+
(0, common_1.Delete)("groups/:id/users/:userId"),
|
|
332
|
+
(0, common_1.HttpCode)(204),
|
|
333
|
+
(0, requirePermission_decorator_1.RequirePermission)("groups:update:any"),
|
|
334
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
335
|
+
__param(1, (0, common_1.Param)("userId", common_1.ParseUUIDPipe)),
|
|
336
|
+
__metadata("design:type", Function),
|
|
337
|
+
__metadata("design:paramtypes", [String, String]),
|
|
338
|
+
__metadata("design:returntype", Promise)
|
|
339
|
+
], RbacController.prototype, "removeUserFromGroup", null);
|
|
340
|
+
__decorate([
|
|
341
|
+
(0, common_1.Get)("roles"),
|
|
342
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:read:any"),
|
|
343
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.RoleResponse, isArray: true }),
|
|
344
|
+
__metadata("design:type", Function),
|
|
345
|
+
__metadata("design:paramtypes", []),
|
|
346
|
+
__metadata("design:returntype", Promise)
|
|
347
|
+
], RbacController.prototype, "roles", null);
|
|
348
|
+
__decorate([
|
|
349
|
+
(0, common_1.Get)("roles/:id"),
|
|
350
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:read:any"),
|
|
351
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.RoleResponse }),
|
|
352
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
353
|
+
__metadata("design:type", Function),
|
|
354
|
+
__metadata("design:paramtypes", [String]),
|
|
355
|
+
__metadata("design:returntype", Promise)
|
|
356
|
+
], RbacController.prototype, "role", null);
|
|
357
|
+
__decorate([
|
|
358
|
+
(0, common_1.Post)("roles"),
|
|
359
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:create:any"),
|
|
360
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.RoleResponse }),
|
|
361
|
+
__param(0, (0, common_1.Body)()),
|
|
362
|
+
__metadata("design:type", Function),
|
|
363
|
+
__metadata("design:paramtypes", [createRole_command_1.CreateRoleCommand]),
|
|
364
|
+
__metadata("design:returntype", Promise)
|
|
365
|
+
], RbacController.prototype, "createRole", null);
|
|
366
|
+
__decorate([
|
|
367
|
+
(0, common_1.Patch)("roles/:id"),
|
|
368
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:update:any"),
|
|
369
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.RoleResponse }),
|
|
370
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
371
|
+
__param(1, (0, common_1.Body)()),
|
|
372
|
+
__param(2, (0, currentUser_decorator_1.CurrentUser)()),
|
|
373
|
+
__metadata("design:type", Function),
|
|
374
|
+
__metadata("design:paramtypes", [String, updateRole_command_1.UpdateRoleCommand, Object]),
|
|
375
|
+
__metadata("design:returntype", Promise)
|
|
376
|
+
], RbacController.prototype, "updateRole", null);
|
|
377
|
+
__decorate([
|
|
378
|
+
(0, common_1.Delete)("roles/:id"),
|
|
379
|
+
(0, common_1.HttpCode)(204),
|
|
380
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:delete:any"),
|
|
381
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
382
|
+
__metadata("design:type", Function),
|
|
383
|
+
__metadata("design:paramtypes", [String]),
|
|
384
|
+
__metadata("design:returntype", Promise)
|
|
385
|
+
], RbacController.prototype, "deleteRole", null);
|
|
386
|
+
__decorate([
|
|
387
|
+
(0, common_1.Post)("roles/:id/permissions/:permissionId"),
|
|
388
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:update:any"),
|
|
389
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.RoleResponse }),
|
|
390
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
391
|
+
__param(1, (0, common_1.Param)("permissionId", common_1.ParseUUIDPipe)),
|
|
392
|
+
__param(2, (0, currentUser_decorator_1.CurrentUser)()),
|
|
393
|
+
__metadata("design:type", Function),
|
|
394
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
395
|
+
__metadata("design:returntype", Promise)
|
|
396
|
+
], RbacController.prototype, "addPermissionToRole", null);
|
|
397
|
+
__decorate([
|
|
398
|
+
(0, common_1.Delete)("roles/:id/permissions/:permissionId"),
|
|
399
|
+
(0, requirePermission_decorator_1.RequirePermission)("roles:update:any"),
|
|
400
|
+
(0, swagger_1.ApiOkResponse)({ type: rbac_response_1.RoleResponse }),
|
|
401
|
+
__param(0, (0, common_1.Param)("id", common_1.ParseUUIDPipe)),
|
|
402
|
+
__param(1, (0, common_1.Param)("permissionId", common_1.ParseUUIDPipe)),
|
|
403
|
+
__metadata("design:type", Function),
|
|
404
|
+
__metadata("design:paramtypes", [String, String]),
|
|
405
|
+
__metadata("design:returntype", Promise)
|
|
406
|
+
], RbacController.prototype, "removePermissionFromRole", null);
|
|
407
|
+
exports.RbacController = RbacController = __decorate([
|
|
408
|
+
(0, swagger_1.ApiTags)("RBAC"),
|
|
409
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
410
|
+
(0, common_1.UseGuards)(permissions_guard_1.PermissionsGuard),
|
|
411
|
+
(0, common_1.Controller)({ path: "rbac", version: "1" }),
|
|
412
|
+
__metadata("design:paramtypes", [rbac_service_1.RbacService])
|
|
413
|
+
], RbacController);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare class RbacTimestampsResponse {
|
|
2
|
+
id: string;
|
|
3
|
+
createdAt: Date;
|
|
4
|
+
updatedAt: Date;
|
|
5
|
+
deletedAt?: Date | null;
|
|
6
|
+
}
|
|
7
|
+
export declare class ResourceResponse extends RbacTimestampsResponse {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string | null;
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class ActionResponse extends RbacTimestampsResponse {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string | null;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class ScopeResponse extends RbacTimestampsResponse {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string | null;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class PermissionResponse extends RbacTimestampsResponse {
|
|
23
|
+
code: string;
|
|
24
|
+
description?: string | null;
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
resourceId: string;
|
|
27
|
+
actionId: string;
|
|
28
|
+
scopeId: string;
|
|
29
|
+
resource: ResourceResponse;
|
|
30
|
+
action: ActionResponse;
|
|
31
|
+
scope: ScopeResponse;
|
|
32
|
+
}
|
|
33
|
+
export declare class RoleResponse extends RbacTimestampsResponse {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string | null;
|
|
36
|
+
isActive: boolean;
|
|
37
|
+
permissions?: PermissionResponse[];
|
|
38
|
+
}
|
|
39
|
+
export declare class GroupResponse extends RbacTimestampsResponse {
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string | null;
|
|
42
|
+
type: string;
|
|
43
|
+
parentId?: string | null;
|
|
44
|
+
isActive: boolean;
|
|
45
|
+
roles?: RoleResponse[];
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
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.GroupResponse = exports.RoleResponse = exports.PermissionResponse = exports.ScopeResponse = exports.ActionResponse = exports.ResourceResponse = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class RbacTimestampsResponse {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, swagger_1.ApiProperty)({ format: "uuid" }),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], RbacTimestampsResponse.prototype, "id", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiProperty)({ format: "date-time" }),
|
|
22
|
+
__metadata("design:type", Date)
|
|
23
|
+
], RbacTimestampsResponse.prototype, "createdAt", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({ format: "date-time" }),
|
|
26
|
+
__metadata("design:type", Date)
|
|
27
|
+
], RbacTimestampsResponse.prototype, "updatedAt", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, swagger_1.ApiProperty)({ type: String, format: "date-time", required: false, nullable: true }),
|
|
30
|
+
__metadata("design:type", Object)
|
|
31
|
+
], RbacTimestampsResponse.prototype, "deletedAt", void 0);
|
|
32
|
+
class ResourceResponse extends RbacTimestampsResponse {
|
|
33
|
+
}
|
|
34
|
+
exports.ResourceResponse = ResourceResponse;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, swagger_1.ApiProperty)({ example: "users" }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], ResourceResponse.prototype, "name", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
41
|
+
__metadata("design:type", Object)
|
|
42
|
+
], ResourceResponse.prototype, "description", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, swagger_1.ApiProperty)(),
|
|
45
|
+
__metadata("design:type", Boolean)
|
|
46
|
+
], ResourceResponse.prototype, "isActive", void 0);
|
|
47
|
+
class ActionResponse extends RbacTimestampsResponse {
|
|
48
|
+
}
|
|
49
|
+
exports.ActionResponse = ActionResponse;
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, swagger_1.ApiProperty)({ example: "read" }),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], ActionResponse.prototype, "name", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
56
|
+
__metadata("design:type", Object)
|
|
57
|
+
], ActionResponse.prototype, "description", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, swagger_1.ApiProperty)(),
|
|
60
|
+
__metadata("design:type", Boolean)
|
|
61
|
+
], ActionResponse.prototype, "isActive", void 0);
|
|
62
|
+
class ScopeResponse extends RbacTimestampsResponse {
|
|
63
|
+
}
|
|
64
|
+
exports.ScopeResponse = ScopeResponse;
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({ example: "any" }),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], ScopeResponse.prototype, "name", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], ScopeResponse.prototype, "description", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, swagger_1.ApiProperty)(),
|
|
75
|
+
__metadata("design:type", Boolean)
|
|
76
|
+
], ScopeResponse.prototype, "isActive", void 0);
|
|
77
|
+
class PermissionResponse extends RbacTimestampsResponse {
|
|
78
|
+
}
|
|
79
|
+
exports.PermissionResponse = PermissionResponse;
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, swagger_1.ApiProperty)({ example: "users:read:any" }),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], PermissionResponse.prototype, "code", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
86
|
+
__metadata("design:type", Object)
|
|
87
|
+
], PermissionResponse.prototype, "description", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, swagger_1.ApiProperty)(),
|
|
90
|
+
__metadata("design:type", Boolean)
|
|
91
|
+
], PermissionResponse.prototype, "isActive", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, swagger_1.ApiProperty)({ format: "uuid" }),
|
|
94
|
+
__metadata("design:type", String)
|
|
95
|
+
], PermissionResponse.prototype, "resourceId", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, swagger_1.ApiProperty)({ format: "uuid" }),
|
|
98
|
+
__metadata("design:type", String)
|
|
99
|
+
], PermissionResponse.prototype, "actionId", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, swagger_1.ApiProperty)({ format: "uuid" }),
|
|
102
|
+
__metadata("design:type", String)
|
|
103
|
+
], PermissionResponse.prototype, "scopeId", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, swagger_1.ApiProperty)({ type: ResourceResponse }),
|
|
106
|
+
__metadata("design:type", ResourceResponse)
|
|
107
|
+
], PermissionResponse.prototype, "resource", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, swagger_1.ApiProperty)({ type: ActionResponse }),
|
|
110
|
+
__metadata("design:type", ActionResponse)
|
|
111
|
+
], PermissionResponse.prototype, "action", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, swagger_1.ApiProperty)({ type: ScopeResponse }),
|
|
114
|
+
__metadata("design:type", ScopeResponse)
|
|
115
|
+
], PermissionResponse.prototype, "scope", void 0);
|
|
116
|
+
class RoleResponse extends RbacTimestampsResponse {
|
|
117
|
+
}
|
|
118
|
+
exports.RoleResponse = RoleResponse;
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, swagger_1.ApiProperty)({ example: "admin" }),
|
|
121
|
+
__metadata("design:type", String)
|
|
122
|
+
], RoleResponse.prototype, "name", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
125
|
+
__metadata("design:type", Object)
|
|
126
|
+
], RoleResponse.prototype, "description", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, swagger_1.ApiProperty)(),
|
|
129
|
+
__metadata("design:type", Boolean)
|
|
130
|
+
], RoleResponse.prototype, "isActive", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, swagger_1.ApiProperty)({ type: [PermissionResponse], required: false }),
|
|
133
|
+
__metadata("design:type", Array)
|
|
134
|
+
], RoleResponse.prototype, "permissions", void 0);
|
|
135
|
+
class GroupResponse extends RbacTimestampsResponse {
|
|
136
|
+
}
|
|
137
|
+
exports.GroupResponse = GroupResponse;
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, swagger_1.ApiProperty)(),
|
|
140
|
+
__metadata("design:type", String)
|
|
141
|
+
], GroupResponse.prototype, "name", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
144
|
+
__metadata("design:type", Object)
|
|
145
|
+
], GroupResponse.prototype, "description", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, swagger_1.ApiProperty)({ enum: ["company", "department", "team"], enumName: "GroupType" }),
|
|
148
|
+
__metadata("design:type", String)
|
|
149
|
+
], GroupResponse.prototype, "type", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true, format: "uuid" }),
|
|
152
|
+
__metadata("design:type", Object)
|
|
153
|
+
], GroupResponse.prototype, "parentId", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
(0, swagger_1.ApiProperty)(),
|
|
156
|
+
__metadata("design:type", Boolean)
|
|
157
|
+
], GroupResponse.prototype, "isActive", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, swagger_1.ApiProperty)({ type: [RoleResponse], required: false }),
|
|
160
|
+
__metadata("design:type", Array)
|
|
161
|
+
], GroupResponse.prototype, "roles", void 0);
|
|
@@ -0,0 +1,55 @@
|
|
|
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.RbacModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const domain_1 = require("./domain");
|
|
13
|
+
const infra_1 = require("./infra");
|
|
14
|
+
const presentation_1 = require("./presentation");
|
|
15
|
+
const user_repository_1 = require("../users/infra/repositories/user.repository");
|
|
16
|
+
const user_schema_1 = require("../users/infra/schema/user.schema");
|
|
17
|
+
let RbacModule = class RbacModule {
|
|
18
|
+
};
|
|
19
|
+
exports.RbacModule = RbacModule;
|
|
20
|
+
exports.RbacModule = RbacModule = __decorate([
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
imports: [
|
|
23
|
+
typeorm_1.TypeOrmModule.forFeature([
|
|
24
|
+
infra_1.Resource,
|
|
25
|
+
infra_1.Action,
|
|
26
|
+
infra_1.Scope,
|
|
27
|
+
infra_1.Permission,
|
|
28
|
+
infra_1.Role,
|
|
29
|
+
infra_1.Group,
|
|
30
|
+
user_schema_1.User,
|
|
31
|
+
]),
|
|
32
|
+
],
|
|
33
|
+
controllers: [presentation_1.RbacController],
|
|
34
|
+
providers: [
|
|
35
|
+
infra_1.ResourceRepository,
|
|
36
|
+
infra_1.ActionRepository,
|
|
37
|
+
infra_1.ScopeRepository,
|
|
38
|
+
infra_1.PermissionRepository,
|
|
39
|
+
infra_1.RoleRepository,
|
|
40
|
+
infra_1.GroupRepository,
|
|
41
|
+
user_repository_1.UserRepository,
|
|
42
|
+
domain_1.RbacService,
|
|
43
|
+
],
|
|
44
|
+
exports: [
|
|
45
|
+
infra_1.ResourceRepository,
|
|
46
|
+
infra_1.ActionRepository,
|
|
47
|
+
infra_1.ScopeRepository,
|
|
48
|
+
infra_1.PermissionRepository,
|
|
49
|
+
infra_1.RoleRepository,
|
|
50
|
+
infra_1.GroupRepository,
|
|
51
|
+
user_repository_1.UserRepository,
|
|
52
|
+
domain_1.RbacService,
|
|
53
|
+
],
|
|
54
|
+
})
|
|
55
|
+
], RbacModule);
|