fase(15): reporting module with pdf generation

This commit is contained in:
debian
2026-03-06 05:57:05 -05:00
parent 3ff36f0b6a
commit cffa1aeea9
64 changed files with 3462 additions and 87 deletions

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenerateReportCommand = void 0;
const Result_1 = require("../../../../shared/domain/Result");
const Report_1 = require("../../domain/entities/Report");
const ReportFormat_1 = require("../../domain/value-objects/ReportFormat");
class GenerateReportCommand {
constructor(reportRepository, eventBus) {
this.reportRepository = reportRepository;
this.eventBus = eventBus;
}
async execute(request) {
let format;
try {
format = ReportFormat_1.ReportFormat.fromString(request.format);
}
catch {
return (0, Result_1.Err)(`Invalid format: ${request.format}`);
}
const report = Report_1.Report.create({
title: request.title,
format,
filters: request.filters ?? {},
});
await this.reportRepository.save(report);
const events = report.clearEvents();
for (const event of events) {
await this.eventBus.publish(event);
}
return (0, Result_1.Ok)({ reportId: report.id.toString(), status: report.status.value });
}
}
exports.GenerateReportCommand = GenerateReportCommand;