import * as fs from 'fs';
import * as path from 'path';
/**
 * Loads and manages serverless platform data from the knowledge base
 */
export class PlatformDataLoader {
    constructor() {
        this.platforms = new Map();
        // Determine path to knowledge base (works from both src/ and dist/)
        const rootDir = path.join(__dirname, '../../..');
        this.platformsDir = path.join(rootDir, 'plugins/specweave/knowledge-base/serverless/platforms');
    }
    /**
     * Load all platform data files
     */
    async loadAll() {
        const platformFiles = [
            'aws-lambda.json',
            'azure-functions.json',
            'gcp-cloud-functions.json',
            'firebase.json',
            'supabase.json'
        ];
        const platforms = [];
        for (const file of platformFiles) {
            const filePath = path.join(this.platformsDir, file);
            const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
            platforms.push(data);
            this.platforms.set(data.id, data);
        }
        return platforms;
    }
    /**
     * Load a specific platform by ID
     */
    async loadById(id) {
        if (this.platforms.size === 0) {
            await this.loadAll();
        }
        return this.platforms.get(id);
    }
    /**
     * Get all loaded platforms
     */
    getAllPlatforms() {
        return Array.from(this.platforms.values());
    }
}
/**
 * Helper function to load all platforms (functional API)
 */
export async function loadAllPlatforms() {
    const loader = new PlatformDataLoader();
    return loader.loadAll();
}
/**
 * Helper function to load a specific platform by ID
 */
export async function loadPlatformById(id) {
    const loader = new PlatformDataLoader();
    return loader.loadById(id);
}
//# sourceMappingURL=platform-data-loader.js.map