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,139 @@
|
|
|
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 AuditDataSubscriber_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AuditDataSubscriber = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const typeorm_1 = require("typeorm");
|
|
16
|
+
const auditContext_1 = require("../../../core/context/auditContext");
|
|
17
|
+
const auditDataChange_schema_1 = require("./schema/auditDataChange.schema");
|
|
18
|
+
function entityIdOf(source) {
|
|
19
|
+
if (source && typeof source === "object" && "id" in source) {
|
|
20
|
+
const id = source.id;
|
|
21
|
+
return typeof id === "string" ? id : null;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const EXCLUDED_ENTITIES = new Set([
|
|
26
|
+
"AuditChange",
|
|
27
|
+
"ErrorLog",
|
|
28
|
+
"AuditDataChange",
|
|
29
|
+
"AuthToken",
|
|
30
|
+
"PasswordHistory",
|
|
31
|
+
]);
|
|
32
|
+
const BASE_FIELDS = new Set(["id", "createdAt", "updatedAt", "deletedAt"]);
|
|
33
|
+
const SENSITIVE_FIELDS = {
|
|
34
|
+
User: new Set(["password", "twoFactorSecret", "backupCodes"]),
|
|
35
|
+
};
|
|
36
|
+
let AuditDataSubscriber = AuditDataSubscriber_1 = class AuditDataSubscriber {
|
|
37
|
+
constructor(dataSource) {
|
|
38
|
+
this.logger = new common_1.Logger(AuditDataSubscriber_1.name);
|
|
39
|
+
dataSource.subscribers.push(this);
|
|
40
|
+
}
|
|
41
|
+
async afterInsert(event) {
|
|
42
|
+
if (EXCLUDED_ENTITIES.has(event.metadata.name)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
await this.persist(event.metadata, event.manager, {
|
|
46
|
+
action: auditDataChange_schema_1.AuditDataAction.CREATE,
|
|
47
|
+
entityId: entityIdOf(event.entity),
|
|
48
|
+
oldData: null,
|
|
49
|
+
newData: this.snapshot(event.entity, event.metadata),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async afterUpdate(event) {
|
|
53
|
+
if (EXCLUDED_ENTITIES.has(event.metadata.name)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!event.updatedColumns.length) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const excluded = SENSITIVE_FIELDS[event.metadata.name] ?? new Set();
|
|
60
|
+
const oldData = {};
|
|
61
|
+
const newData = {};
|
|
62
|
+
for (const col of event.updatedColumns) {
|
|
63
|
+
const prop = col.propertyName;
|
|
64
|
+
if (BASE_FIELDS.has(prop) || excluded.has(prop)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
oldData[prop] = this.serialize(event.databaseEntity?.[prop]);
|
|
68
|
+
newData[prop] = this.serialize(event.entity?.[prop]);
|
|
69
|
+
}
|
|
70
|
+
if (!Object.keys(newData).length) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await this.persist(event.metadata, event.manager, {
|
|
74
|
+
action: auditDataChange_schema_1.AuditDataAction.UPDATE,
|
|
75
|
+
entityId: entityIdOf(event.databaseEntity) ?? entityIdOf(event.entity),
|
|
76
|
+
oldData,
|
|
77
|
+
newData,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async afterRemove(event) {
|
|
81
|
+
await this.recordRemoval(event);
|
|
82
|
+
}
|
|
83
|
+
async afterSoftRemove(event) {
|
|
84
|
+
await this.recordRemoval(event);
|
|
85
|
+
}
|
|
86
|
+
async recordRemoval(event) {
|
|
87
|
+
if (EXCLUDED_ENTITIES.has(event.metadata.name)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
await this.persist(event.metadata, event.manager, {
|
|
91
|
+
action: auditDataChange_schema_1.AuditDataAction.DELETE,
|
|
92
|
+
entityId: entityIdOf(event.databaseEntity) ?? entityIdOf(event.entityId),
|
|
93
|
+
oldData: this.snapshot(event.databaseEntity, event.metadata),
|
|
94
|
+
newData: null,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
snapshot(source, metadata) {
|
|
98
|
+
const excluded = SENSITIVE_FIELDS[metadata.name] ?? new Set();
|
|
99
|
+
const result = {};
|
|
100
|
+
for (const col of metadata.columns) {
|
|
101
|
+
const prop = col.propertyName;
|
|
102
|
+
if (BASE_FIELDS.has(prop) || excluded.has(prop)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const value = source?.[prop];
|
|
106
|
+
if (value === undefined) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
result[prop] = this.serialize(value);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
serialize(value) {
|
|
114
|
+
return value instanceof Date ? value.toISOString() : value;
|
|
115
|
+
}
|
|
116
|
+
async persist(metadata, manager, data) {
|
|
117
|
+
try {
|
|
118
|
+
const ctx = auditContext_1.auditContext.getStore();
|
|
119
|
+
const repo = manager.getRepository(auditDataChange_schema_1.AuditDataChange);
|
|
120
|
+
await repo.save(repo.create({
|
|
121
|
+
entity: metadata.name,
|
|
122
|
+
entityId: data.entityId,
|
|
123
|
+
action: data.action,
|
|
124
|
+
oldData: data.oldData,
|
|
125
|
+
newData: data.newData,
|
|
126
|
+
userId: ctx?.userId ?? null,
|
|
127
|
+
ipAddress: ctx?.ipAddress ?? null,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
this.logger.warn(`Falha ao gravar AuditDataChange (${metadata.name}): ${err.message}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports.AuditDataSubscriber = AuditDataSubscriber;
|
|
136
|
+
exports.AuditDataSubscriber = AuditDataSubscriber = AuditDataSubscriber_1 = __decorate([
|
|
137
|
+
(0, common_1.Injectable)(),
|
|
138
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
139
|
+
], AuditDataSubscriber);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./auditData.subscriber";
|
|
2
|
+
export * from "./repositories/auditChange.repository";
|
|
3
|
+
export * from "./repositories/auditDataChange.repository";
|
|
4
|
+
export * from "./repositories/errorLog.repository";
|
|
5
|
+
export * from "./schema/auditChange.schema";
|
|
6
|
+
export * from "./schema/auditDataChange.schema";
|
|
7
|
+
export * from "./schema/errorLog.schema";
|
|
@@ -0,0 +1,23 @@
|
|
|
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("./auditData.subscriber"), exports);
|
|
18
|
+
__exportStar(require("./repositories/auditChange.repository"), exports);
|
|
19
|
+
__exportStar(require("./repositories/auditDataChange.repository"), exports);
|
|
20
|
+
__exportStar(require("./repositories/errorLog.repository"), exports);
|
|
21
|
+
__exportStar(require("./schema/auditChange.schema"), exports);
|
|
22
|
+
__exportStar(require("./schema/auditDataChange.schema"), exports);
|
|
23
|
+
__exportStar(require("./schema/errorLog.schema"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataSource, Repository } from "typeorm";
|
|
2
|
+
import { PaginationQuery } from "../../../../core/utils/pagination.util";
|
|
3
|
+
import { AuditChange } from "../schema/auditChange.schema";
|
|
4
|
+
export declare class AuditChangeRepository extends Repository<AuditChange> {
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
findPaginated(query: PaginationQuery): Promise<[AuditChange[], number]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.AuditChangeRepository = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const paginateWithFilter_util_1 = require("../../../../core/query/paginateWithFilter.util");
|
|
16
|
+
const auditChange_schema_1 = require("../schema/auditChange.schema");
|
|
17
|
+
const audit_filters_1 = require("../../presentation/filters/audit.filters");
|
|
18
|
+
let AuditChangeRepository = class AuditChangeRepository extends typeorm_1.Repository {
|
|
19
|
+
constructor(dataSource) {
|
|
20
|
+
super(auditChange_schema_1.AuditChange, dataSource.createEntityManager());
|
|
21
|
+
}
|
|
22
|
+
findPaginated(query) {
|
|
23
|
+
return (0, paginateWithFilter_util_1.paginateWithFilter)(this.createQueryBuilder("auditChange"), {
|
|
24
|
+
query,
|
|
25
|
+
catalog: audit_filters_1.AUDIT_CHANGES_FILTER_CATALOG,
|
|
26
|
+
defaultSort: "createdAt",
|
|
27
|
+
searchFields: ["path", "action"],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.AuditChangeRepository = AuditChangeRepository;
|
|
32
|
+
exports.AuditChangeRepository = AuditChangeRepository = __decorate([
|
|
33
|
+
(0, common_1.Injectable)(),
|
|
34
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
35
|
+
], AuditChangeRepository);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataSource, Repository } from "typeorm";
|
|
2
|
+
import { PaginationQuery } from "../../../../core/utils/pagination.util";
|
|
3
|
+
import { AuditDataChange } from "../schema/auditDataChange.schema";
|
|
4
|
+
export declare class AuditDataChangeRepository extends Repository<AuditDataChange> {
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
findPaginated(query: PaginationQuery): Promise<[AuditDataChange[], number]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.AuditDataChangeRepository = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const paginateWithFilter_util_1 = require("../../../../core/query/paginateWithFilter.util");
|
|
16
|
+
const auditDataChange_schema_1 = require("../schema/auditDataChange.schema");
|
|
17
|
+
const audit_filters_1 = require("../../presentation/filters/audit.filters");
|
|
18
|
+
let AuditDataChangeRepository = class AuditDataChangeRepository extends typeorm_1.Repository {
|
|
19
|
+
constructor(dataSource) {
|
|
20
|
+
super(auditDataChange_schema_1.AuditDataChange, dataSource.createEntityManager());
|
|
21
|
+
}
|
|
22
|
+
findPaginated(query) {
|
|
23
|
+
return (0, paginateWithFilter_util_1.paginateWithFilter)(this.createQueryBuilder("auditDataChange"), {
|
|
24
|
+
query,
|
|
25
|
+
catalog: audit_filters_1.AUDIT_DATA_CHANGES_FILTER_CATALOG,
|
|
26
|
+
defaultSort: "createdAt",
|
|
27
|
+
searchFields: ["entity"],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.AuditDataChangeRepository = AuditDataChangeRepository;
|
|
32
|
+
exports.AuditDataChangeRepository = AuditDataChangeRepository = __decorate([
|
|
33
|
+
(0, common_1.Injectable)(),
|
|
34
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
35
|
+
], AuditDataChangeRepository);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataSource, Repository } from "typeorm";
|
|
2
|
+
import { PaginationQuery } from "../../../../core/utils/pagination.util";
|
|
3
|
+
import { ErrorLog } from "../schema/errorLog.schema";
|
|
4
|
+
export declare class ErrorLogRepository extends Repository<ErrorLog> {
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
findPaginated(query: PaginationQuery): Promise<[ErrorLog[], number]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.ErrorLogRepository = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const paginateWithFilter_util_1 = require("../../../../core/query/paginateWithFilter.util");
|
|
16
|
+
const errorLog_schema_1 = require("../schema/errorLog.schema");
|
|
17
|
+
const audit_filters_1 = require("../../presentation/filters/audit.filters");
|
|
18
|
+
let ErrorLogRepository = class ErrorLogRepository extends typeorm_1.Repository {
|
|
19
|
+
constructor(dataSource) {
|
|
20
|
+
super(errorLog_schema_1.ErrorLog, dataSource.createEntityManager());
|
|
21
|
+
}
|
|
22
|
+
findPaginated(query) {
|
|
23
|
+
return (0, paginateWithFilter_util_1.paginateWithFilter)(this.createQueryBuilder("errorLog"), {
|
|
24
|
+
query,
|
|
25
|
+
catalog: audit_filters_1.ERROR_LOGS_FILTER_CATALOG,
|
|
26
|
+
defaultSort: "createdAt",
|
|
27
|
+
searchFields: ["message", "path"],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.ErrorLogRepository = ErrorLogRepository;
|
|
32
|
+
exports.ErrorLogRepository = ErrorLogRepository = __decorate([
|
|
33
|
+
(0, common_1.Injectable)(),
|
|
34
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
35
|
+
], ErrorLogRepository);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseEntity } from "../../../../core/database/base.schema";
|
|
2
|
+
export declare class AuditChange extends BaseEntity {
|
|
3
|
+
userId?: string | null;
|
|
4
|
+
action: string;
|
|
5
|
+
entity?: string | null;
|
|
6
|
+
entityId?: string | null;
|
|
7
|
+
method?: string | null;
|
|
8
|
+
path?: string | null;
|
|
9
|
+
ipAddress?: string | null;
|
|
10
|
+
statusCode?: number | null;
|
|
11
|
+
durationMs?: number | null;
|
|
12
|
+
requestId?: string | null;
|
|
13
|
+
metadata?: Record<string, unknown> | null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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.AuditChange = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_schema_1 = require("../../../../core/database/base.schema");
|
|
15
|
+
let AuditChange = class AuditChange extends base_schema_1.BaseEntity {
|
|
16
|
+
};
|
|
17
|
+
exports.AuditChange = AuditChange;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.Column)({ name: "user_id", type: "char", length: 36, nullable: true }),
|
|
20
|
+
__metadata("design:type", Object)
|
|
21
|
+
], AuditChange.prototype, "userId", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 100 }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], AuditChange.prototype, "action", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 100, nullable: true }),
|
|
28
|
+
__metadata("design:type", Object)
|
|
29
|
+
], AuditChange.prototype, "entity", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: "entity_id", type: "varchar", length: 36, nullable: true }),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], AuditChange.prototype, "entityId", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 10, nullable: true }),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], AuditChange.prototype, "method", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 255, nullable: true }),
|
|
40
|
+
__metadata("design:type", Object)
|
|
41
|
+
], AuditChange.prototype, "path", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: "ip_address", type: "varchar", length: 45, nullable: true }),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], AuditChange.prototype, "ipAddress", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ name: "status_code", type: "int", nullable: true }),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], AuditChange.prototype, "statusCode", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ name: "duration_ms", type: "int", nullable: true }),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], AuditChange.prototype, "durationMs", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ name: "request_id", type: "char", length: 36, nullable: true }),
|
|
56
|
+
__metadata("design:type", Object)
|
|
57
|
+
], AuditChange.prototype, "requestId", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ type: "json", nullable: true }),
|
|
60
|
+
__metadata("design:type", Object)
|
|
61
|
+
], AuditChange.prototype, "metadata", void 0);
|
|
62
|
+
exports.AuditChange = AuditChange = __decorate([
|
|
63
|
+
(0, typeorm_1.Entity)("audit_changes"),
|
|
64
|
+
(0, typeorm_1.Index)(["userId"]),
|
|
65
|
+
(0, typeorm_1.Index)(["entity"]),
|
|
66
|
+
(0, typeorm_1.Index)(["requestId"]),
|
|
67
|
+
(0, typeorm_1.Index)(["statusCode"])
|
|
68
|
+
], AuditChange);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseEntity } from "../../../../core/database/base.schema";
|
|
2
|
+
export declare enum AuditDataAction {
|
|
3
|
+
CREATE = "CREATE",
|
|
4
|
+
UPDATE = "UPDATE",
|
|
5
|
+
DELETE = "DELETE"
|
|
6
|
+
}
|
|
7
|
+
export declare class AuditDataChange extends BaseEntity {
|
|
8
|
+
entity: string;
|
|
9
|
+
entityId?: string | null;
|
|
10
|
+
action: AuditDataAction;
|
|
11
|
+
oldData?: Record<string, unknown> | null;
|
|
12
|
+
newData?: Record<string, unknown> | null;
|
|
13
|
+
userId?: string | null;
|
|
14
|
+
ipAddress?: string | null;
|
|
15
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.AuditDataChange = exports.AuditDataAction = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_schema_1 = require("../../../../core/database/base.schema");
|
|
15
|
+
var AuditDataAction;
|
|
16
|
+
(function (AuditDataAction) {
|
|
17
|
+
AuditDataAction["CREATE"] = "CREATE";
|
|
18
|
+
AuditDataAction["UPDATE"] = "UPDATE";
|
|
19
|
+
AuditDataAction["DELETE"] = "DELETE";
|
|
20
|
+
})(AuditDataAction || (exports.AuditDataAction = AuditDataAction = {}));
|
|
21
|
+
let AuditDataChange = class AuditDataChange extends base_schema_1.BaseEntity {
|
|
22
|
+
};
|
|
23
|
+
exports.AuditDataChange = AuditDataChange;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 100 }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], AuditDataChange.prototype, "entity", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ name: "entity_id", type: "varchar", length: 36, nullable: true }),
|
|
30
|
+
__metadata("design:type", Object)
|
|
31
|
+
], AuditDataChange.prototype, "entityId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({ type: "enum", enum: AuditDataAction }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], AuditDataChange.prototype, "action", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ name: "old_data", type: "json", nullable: true }),
|
|
38
|
+
__metadata("design:type", Object)
|
|
39
|
+
], AuditDataChange.prototype, "oldData", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ name: "new_data", type: "json", nullable: true }),
|
|
42
|
+
__metadata("design:type", Object)
|
|
43
|
+
], AuditDataChange.prototype, "newData", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ name: "user_id", type: "char", length: 36, nullable: true }),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], AuditDataChange.prototype, "userId", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ name: "ip_address", type: "varchar", length: 45, nullable: true }),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], AuditDataChange.prototype, "ipAddress", void 0);
|
|
52
|
+
exports.AuditDataChange = AuditDataChange = __decorate([
|
|
53
|
+
(0, typeorm_1.Entity)("audit_data_changes"),
|
|
54
|
+
(0, typeorm_1.Index)(["entity", "entityId"]),
|
|
55
|
+
(0, typeorm_1.Index)(["userId"])
|
|
56
|
+
], AuditDataChange);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseEntity } from "../../../../core/database/base.schema";
|
|
2
|
+
export declare enum ErrorType {
|
|
3
|
+
VALIDATION = "VALIDATION",
|
|
4
|
+
AUTH = "AUTH",
|
|
5
|
+
NOT_FOUND = "NOT_FOUND",
|
|
6
|
+
RATE_LIMIT = "RATE_LIMIT",
|
|
7
|
+
DATABASE = "DATABASE",
|
|
8
|
+
INTEGRATION = "INTEGRATION",
|
|
9
|
+
INTERNAL = "INTERNAL"
|
|
10
|
+
}
|
|
11
|
+
export declare class ErrorLog extends BaseEntity {
|
|
12
|
+
statusCode?: number | null;
|
|
13
|
+
type: ErrorType;
|
|
14
|
+
message: string;
|
|
15
|
+
stack?: string | null;
|
|
16
|
+
method?: string | null;
|
|
17
|
+
path?: string | null;
|
|
18
|
+
userId?: string | null;
|
|
19
|
+
ipAddress?: string | null;
|
|
20
|
+
requestId?: string | null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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.ErrorLog = exports.ErrorType = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_schema_1 = require("../../../../core/database/base.schema");
|
|
15
|
+
var ErrorType;
|
|
16
|
+
(function (ErrorType) {
|
|
17
|
+
ErrorType["VALIDATION"] = "VALIDATION";
|
|
18
|
+
ErrorType["AUTH"] = "AUTH";
|
|
19
|
+
ErrorType["NOT_FOUND"] = "NOT_FOUND";
|
|
20
|
+
ErrorType["RATE_LIMIT"] = "RATE_LIMIT";
|
|
21
|
+
ErrorType["DATABASE"] = "DATABASE";
|
|
22
|
+
ErrorType["INTEGRATION"] = "INTEGRATION";
|
|
23
|
+
ErrorType["INTERNAL"] = "INTERNAL";
|
|
24
|
+
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
|
25
|
+
let ErrorLog = class ErrorLog extends base_schema_1.BaseEntity {
|
|
26
|
+
};
|
|
27
|
+
exports.ErrorLog = ErrorLog;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ name: "status_code", type: "int", nullable: true }),
|
|
30
|
+
__metadata("design:type", Object)
|
|
31
|
+
], ErrorLog.prototype, "statusCode", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({ type: "enum", enum: ErrorType, default: ErrorType.INTERNAL }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], ErrorLog.prototype, "type", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 255 }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], ErrorLog.prototype, "message", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ type: "text", nullable: true }),
|
|
42
|
+
__metadata("design:type", Object)
|
|
43
|
+
], ErrorLog.prototype, "stack", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 10, nullable: true }),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], ErrorLog.prototype, "method", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 255, nullable: true }),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], ErrorLog.prototype, "path", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ name: "user_id", type: "char", length: 36, nullable: true }),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], ErrorLog.prototype, "userId", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.Column)({ name: "ip_address", type: "varchar", length: 45, nullable: true }),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], ErrorLog.prototype, "ipAddress", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.Column)({ name: "request_id", type: "char", length: 36, nullable: true }),
|
|
62
|
+
__metadata("design:type", Object)
|
|
63
|
+
], ErrorLog.prototype, "requestId", void 0);
|
|
64
|
+
exports.ErrorLog = ErrorLog = __decorate([
|
|
65
|
+
(0, typeorm_1.Entity)("error_logs"),
|
|
66
|
+
(0, typeorm_1.Index)(["statusCode"]),
|
|
67
|
+
(0, typeorm_1.Index)(["type"]),
|
|
68
|
+
(0, typeorm_1.Index)(["requestId"])
|
|
69
|
+
], ErrorLog);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FilterFieldResponse } from "../../../core/query/filterSchema.response";
|
|
2
|
+
import { Paginated, PaginationQuery } from "../../../core/utils/pagination.util";
|
|
3
|
+
import { AuditService } from "../domain/audit.service";
|
|
4
|
+
import { AuditDataChangeWithUser, WithUserRef } from "../domain/audit.service";
|
|
5
|
+
import { AuditChange } from "../infra/schema/auditChange.schema";
|
|
6
|
+
import { ErrorLog } from "../infra/schema/errorLog.schema";
|
|
7
|
+
export declare class AuditController {
|
|
8
|
+
private readonly audit;
|
|
9
|
+
constructor(audit: AuditService);
|
|
10
|
+
changes(query: PaginationQuery): Promise<Paginated<WithUserRef<AuditChange>>>;
|
|
11
|
+
changesFilterSchema(): FilterFieldResponse[];
|
|
12
|
+
errors(query: PaginationQuery): Promise<Paginated<WithUserRef<ErrorLog>>>;
|
|
13
|
+
errorsFilterSchema(): FilterFieldResponse[];
|
|
14
|
+
dataChanges(query: PaginationQuery): Promise<Paginated<AuditDataChangeWithUser>>;
|
|
15
|
+
dataChangesFilterSchema(): FilterFieldResponse[];
|
|
16
|
+
}
|