02b51d7814
- Repository interfaces defined by domain (@landvex/domain) - 6 in-memory adapters: Session, Mission, DecisionCase, Artifact, EventStore, UnitOfWork - 9 tests verifying adapter contracts - Domain unchanged — infrastructure depends on domain, never reverse - ADR-006: In-Memory Adapters for Testing Definition of Done met: - All adapters compile against domain interfaces - Unit tests pass (9/9) - No PostgreSQL, S3, Express, AI in this PR - Ready for PR-003: PostgreSQL adapters
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
/**
|
|
* In-Memory DecisionCase Repository
|
|
*
|
|
* Adapter: Implements DecisionCaseRepository using a Map.
|
|
* Purpose: Testing, development, CI/CD pipelines.
|
|
* NOT for production.
|
|
*/
|
|
|
|
import {
|
|
DecisionCase,
|
|
DecisionCaseId,
|
|
ArtifactId,
|
|
EvidenceId,
|
|
} from '@landvex/domain';
|
|
import { DecisionCaseRepository } from '../repositories/repository-interfaces';
|
|
|
|
export class InMemoryDecisionCaseRepository implements DecisionCaseRepository {
|
|
private cases = new Map<string, DecisionCase>();
|
|
|
|
async save(decisionCase: DecisionCase): Promise<void> {
|
|
this.cases.set(decisionCase.id, decisionCase);
|
|
}
|
|
|
|
async findById(id: DecisionCaseId): Promise<DecisionCase | null> {
|
|
return this.cases.get(id) ?? null;
|
|
}
|
|
|
|
async findByArtifact(artifactId: ArtifactId): Promise<DecisionCase[]> {
|
|
return Array.from(this.cases.values())
|
|
.filter(c => c.evidenceIds.includes(artifactId as any));
|
|
}
|
|
|
|
async findByStatus(
|
|
status: 'pending' | 'under_review' | 'approved' | 'rejected'
|
|
): Promise<DecisionCase[]> {
|
|
return Array.from(this.cases.values())
|
|
.filter(c => c.status === status);
|
|
}
|
|
|
|
clear(): void {
|
|
this.cases.clear();
|
|
}
|
|
|
|
count(): number {
|
|
return this.cases.size;
|
|
}
|
|
}
|