Spaces:
Running
Running
Download apps/api/dist/admin/admin-audit.service.js from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 4 kB
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/dist/admin/admin-audit.service.js
- Command line
-
hf download hf://spaces/Benaah/MicProtocol/apps/api/dist/admin/admin-audit.service.js
-
curl -L -o admin-audit.service.js https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/dist/admin/admin-audit.service.js
4 kB
| ; | |
| var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | |
| var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | |
| if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | |
| 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; | |
| return c > 3 && r && Object.defineProperty(target, key, r), r; | |
| }; | |
| var __metadata = (this && this.__metadata) || function (k, v) { | |
| if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | |
| }; | |
| var AdminAuditService_1; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.AdminAuditService = void 0; | |
| const common_1 = require("@nestjs/common"); | |
| const prisma_service_1 = require("../prisma/prisma.service"); | |
| const audit_service_1 = require("../audit/audit.service"); | |
| const shared_types_1 = require("@micprotocol/shared-types"); | |
| const admin_permission_decorator_1 = require("../common/decorators/admin-permission.decorator"); | |
| let AdminAuditService = AdminAuditService_1 = class AdminAuditService { | |
| prisma; | |
| audit; | |
| logger = new common_1.Logger(AdminAuditService_1.name); | |
| constructor(prisma, audit) { | |
| this.prisma = prisma; | |
| this.audit = audit; | |
| } | |
| async list(input = {}) { | |
| return this.audit.listAuditLogs(input); | |
| } | |
| async verify() { | |
| return this.audit.verifyIntegrity(); | |
| } | |
| async stats() { | |
| return this.audit.getAuditStats(); | |
| } | |
| async export(input, exportedBy) { | |
| const { items, total } = await this.audit.listAuditLogs({ | |
| startDate: input.startDate, | |
| endDate: input.endDate, | |
| limit: 10_000, | |
| }); | |
| const integrity = await this.audit.verifyIntegrity(); | |
| await this.audit.log({ | |
| userId: exportedBy, | |
| action: "admin.audit.export", | |
| entityType: "AuditLog", | |
| entityId: "export", | |
| metadata: { | |
| exportedBy, | |
| total, | |
| startDate: input.startDate, | |
| endDate: input.endDate, | |
| chainValid: integrity.valid, | |
| chainBrokenAt: integrity.brokenAt, | |
| }, | |
| }); | |
| return { | |
| exportedAt: new Date().toISOString(), | |
| exportedBy, | |
| total, | |
| chainValid: integrity.valid, | |
| chainBrokenAt: integrity.brokenAt, | |
| items, | |
| }; | |
| } | |
| async getEntry(entryId) { | |
| const entry = await this.prisma.auditLog.findUnique({ | |
| where: { id: entryId }, | |
| select: { | |
| id: true, | |
| userId: true, | |
| workspaceId: true, | |
| action: true, | |
| entityType: true, | |
| entityId: true, | |
| metadata: true, | |
| ipAddress: true, | |
| userAgent: true, | |
| entryHash: true, | |
| previousHash: true, | |
| createdAt: true, | |
| }, | |
| }); | |
| if (!entry) | |
| throw new common_1.NotFoundException(`Audit entry ${entryId} not found`); | |
| return entry; | |
| } | |
| }; | |
| exports.AdminAuditService = AdminAuditService; | |
| __decorate([ | |
| (0, admin_permission_decorator_1.requireAdminPermission)(shared_types_1.AdminPermission.AUDIT_EXPORT), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String]), | |
| __metadata("design:returntype", Promise) | |
| ], AdminAuditService.prototype, "export", null); | |
| exports.AdminAuditService = AdminAuditService = AdminAuditService_1 = __decorate([ | |
| (0, common_1.Injectable)(), | |
| __metadata("design:paramtypes", [prisma_service_1.PrismaService, audit_service_1.AuditService]) | |
| ], AdminAuditService); | |
| //# sourceMappingURL=admin-audit.service.js.map |