import {
  JsonArtifactStoreRepository,
  JsonSnapshotRepository,
  ReviewSamplesRepository,
  ScannerLearningRepository,
  type ArtifactStoreRepositoryPort,
  type ReviewSamplesRepositoryPort,
  type ScannerLearningRepositoryPort,
  type SnapshotRepositoryPort,
} from "../repositories/index.js";

import path from "node:path";
export interface RepositoryContext {
  artifactStorePath: string;
  reviewSamplesPath: string;
  scannerLearningPath: string;
  snapshotPath: string;
  artifactStoreRepository: ArtifactStoreRepositoryPort;
  reviewSamplesRepository: ReviewSamplesRepositoryPort;
  scannerLearningRepository: ScannerLearningRepositoryPort;
  snapshotRepository: SnapshotRepositoryPort;
}

export function createRepositoryContext(userDataPath: string): RepositoryContext {
  const artifactStorePath = path.join(userDataPath, "artifact-store.json");
  const reviewSamplesPath = path.join(userDataPath, "review-samples.jsonl");
  const scannerLearningPath = path.join(userDataPath, "scanner-learning.json");
  const snapshotPath = path.join(userDataPath, "snapshot.json");

  return {
    artifactStorePath,
    reviewSamplesPath,
    scannerLearningPath,
    snapshotPath,
    artifactStoreRepository: new JsonArtifactStoreRepository(userDataPath),
    reviewSamplesRepository: new ReviewSamplesRepository(userDataPath),
    scannerLearningRepository: new ScannerLearningRepository(userDataPath),
    snapshotRepository: new JsonSnapshotRepository(userDataPath),
  };
}
