"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Finding = void 0; const AggregateRoot_1 = require("../../../../shared/domain/AggregateRoot"); const UniqueId_1 = require("../../../../shared/domain/UniqueId"); const FindingStatus_1 = require("../value-objects/FindingStatus"); const FindingCreated_1 = require("../events/FindingCreated"); const FindingResolved_1 = require("../events/FindingResolved"); const FindingEnriched_1 = require("../events/FindingEnriched"); class Finding extends AggregateRoot_1.AggregateRoot { static create(props, id) { const findingId = id ?? UniqueId_1.UniqueId.create(); const finding = new Finding({ ...props, status: FindingStatus_1.FindingStatus.open(), createdAt: new Date(), }, findingId); finding.addDomainEvent(new FindingCreated_1.FindingCreated(findingId.toString(), { sessionId: props.sessionId, severity: props.severity.value, type: props.type.value, description: props.description, })); return finding; } static reconstitute(props, id) { return new Finding(props, id); } get sessionId() { return this.props.sessionId; } get severity() { return this.props.severity; } get type() { return this.props.type; } get description() { return this.props.description; } get evidence() { return this.props.evidence; } get status() { return this.props.status; } get actionTrace() { return this.props.actionTrace; } get browser() { return this.props.browser; } get browserVersion() { return this.props.browserVersion; } get aiEnrichment() { return this.props.aiEnrichment; } get createdAt() { return this.props.createdAt; } get resolvedAt() { return this.props.resolvedAt; } resolve() { this.props.status = FindingStatus_1.FindingStatus.resolved(); this.props.resolvedAt = new Date(); this.addDomainEvent(new FindingResolved_1.FindingResolved(this.id.toString(), { sessionId: this.props.sessionId, resolvedAt: this.props.resolvedAt.toISOString(), })); } close() { this.props.status = FindingStatus_1.FindingStatus.closed(); } investigate() { this.props.status = FindingStatus_1.FindingStatus.investigating(); } enrich(enrichment) { this.props.aiEnrichment = enrichment; this.addDomainEvent(new FindingEnriched_1.FindingEnriched(this.id.toString(), { provider: enrichment.provider, model: enrichment.model, confidence: enrichment.confidence, })); } } exports.Finding = Finding;