"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.seedPluginPresets = seedPluginPresets;
const uuid_1 = require("uuid");
const constants_1 = require("../../redteam/constants");
const constants_2 = require("../../redteam/constants");
const index_1 = require("../index");
const tables_1 = require("../tables");
const presets = [
    {
        name: 'Recommended',
        plugins: constants_2.DEFAULT_PLUGINS,
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Recommended'] || '',
    },
    {
        name: 'Custom',
        plugins: new Set(),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Custom'] || '',
    },
    {
        name: 'Minimal Test',
        plugins: new Set(['harmful:hate', 'harmful:self-harm']),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Minimal Test'] || '',
    },
    {
        name: 'RBI’s Responsible AI Principles',
        plugins: new Set([...constants_2.RBI_RESPONSIBLE_PRINCIPLE]),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['RBIPrinciples'] || '',
    },
    {
        name: 'RAG',
        plugins: new Set([...constants_2.DEFAULT_PLUGINS, 'bola', 'bfla', 'rbac']),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['RAG'] || '',
    },
    {
        name: 'HIPAA',
        plugins: new Set([...constants_2.HIPAA_CONTROL_PLUGINS, ...constants_2.HIPAA_RISK_PLUGINS, ...constants_2.HIPAA_RELEVANCE_PLUGINS, ...constants_2.HIPAA_MAPPING_PLUGINS, ...constants_2.HIPAA_REQUIREMENT_PLUGINS]),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['HIPAA Control'] || '',
    },
    {
        name: 'Governance Risk',
        plugins: new Set([...constants_2.GOVERNANCE_RISK_PLUGINS]),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Governance Risk'] || '',
    },
    {
        name: 'Breach Risk',
        plugins: new Set([...constants_2.BREACH_RISK_PLUGINS]),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Breach Risk'] || '',
    },
    {
        name: 'Foundation',
        plugins: new Set(constants_2.FOUNDATION_PLUGINS),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Foundation'] || '',
    },
    {
        name: 'Harmful',
        plugins: new Set(Object.keys(constants_2.HARM_PLUGINS)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['Harmful'] || '',
    },
    {
        name: 'NIST',
        plugins: new Set(Object.values(constants_2.NIST_AI_RMF_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['NIST'] || '',
    },
    {
        name: 'OWASP LLM Top 10',
        plugins: new Set(Object.values(constants_2.OWASP_LLM_TOP_10_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['OWASP LLM Top 10'] || '',
    },
    {
        name: 'OWASP Gen AI Red Team',
        plugins: new Set(Object.values(constants_2.OWASP_LLM_RED_TEAM_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['OWASP Gen AI Red Team'] || '',
    },
    {
        name: 'EU AI Act Top 10',
        plugins: new Set(Object.values(constants_2.OWASP_API_TOP_10_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['EU AI Act Top 10'] || '',
    },
    {
        name: 'MITRE',
        plugins: new Set(Object.values(constants_2.MITRE_ATLAS_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['MITRE'] || '',
    },
    {
        name: 'EU AI Act',
        plugins: new Set(Object.values(constants_2.EU_AI_ACT_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['EU AI Act'] || '',
    },
    {
        name: 'OWASP Agentic AI Top 10',
        plugins: new Set(Object.values(constants_2.OWASP_AGENTIC_REDTEAM_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['OWASP Agentic AI Top 10'] || '',
    },
    {
        name: 'ISO 42001',
        plugins: new Set(Object.values(constants_2.ISO_42001_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['ISO 42001'] || '',
    },
    {
        name: 'GDPR',
        plugins: new Set(Object.values(constants_2.GDPR_MAPPING).flatMap((v) => v.plugins)),
        description: constants_1.PLUGIN_PRESET_DESCRIPTIONS['GDPR'] || '',
    },
];
async function seedPluginPresets() {
    try {
        const db = await (0, index_1.getDb)();
        // Clear existing presets to avoid duplicates / drift, then insert canonical list
        await db.delete(tables_1.pluginsPresetsTable);
        for (const preset of presets) {
            await db.insert(tables_1.pluginsPresetsTable).values({
                id: (0, uuid_1.v4)(),
                name: preset.name,
                description: preset.description,
                plugins: Array.from(preset.plugins),
            });
        }
        console.log('Plugin Presets seeded successfully');
    }
    catch (error) {
        console.error('Failed to seed plugin presets:', error);
        throw error;
    }
}
//# sourceMappingURL=pluginPresets.js.map