"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RepositoryManager = void 0;
const SessionRepository_js_1 = require("./SessionRepository.js");
const ContextRepository_js_1 = require("./ContextRepository.js");
const FileRepository_js_1 = require("./FileRepository.js");
const CheckpointRepository_js_1 = require("./CheckpointRepository.js");
const WatcherRepository_js_1 = require("./WatcherRepository.js");
class RepositoryManager {
    dbManager;
    sessions;
    contexts;
    files;
    checkpoints;
    watchers;
    constructor(dbManager) {
        this.dbManager = dbManager;
        // Initialize all repositories
        this.sessions = new SessionRepository_js_1.SessionRepository(dbManager);
        this.contexts = new ContextRepository_js_1.ContextRepository(dbManager);
        this.files = new FileRepository_js_1.FileRepository(dbManager);
        this.checkpoints = new CheckpointRepository_js_1.CheckpointRepository(dbManager);
        this.watchers = new WatcherRepository_js_1.WatcherRepository(dbManager);
    }
    /**
     * Get the underlying database manager
     */
    getDatabaseManager() {
        return this.dbManager;
    }
    /**
     * Close all database connections
     */
    close() {
        this.dbManager.close();
    }
    /**
     * Get session statistics across all repositories
     */
    getSessionStats(sessionId) {
        const contextStats = this.contexts.getStatsBySession(sessionId);
        const fileStats = this.files.getStatsBySession(sessionId);
        const checkpointStats = this.checkpoints.getStatsBySession(sessionId);
        return {
            session: this.sessions.getById(sessionId),
            contexts: contextStats,
            files: fileStats,
            checkpoints: checkpointStats,
            totalSize: contextStats.totalSize + fileStats.totalSize,
        };
    }
    /**
     * Clean up old data across all repositories
     */
    cleanup(olderThanDays) {
        const filesDeleted = this.files.cleanup(olderThanDays);
        return {
            filesDeleted,
        };
    }
}
exports.RepositoryManager = RepositoryManager;
