
import { supabaseService } from '../src/services/SupabaseService.js';
import logger from '../src/utils/logger.js';

async function auditProfileData() {
    logger.info('🔍 AUDITING PROFILE DATA STRUCTURE...');

    const profiles = await supabaseService.getActiveProfiles();
    const highRisk = profiles.find(p => p.name.includes('Scalp') || p.name.includes('High'));

    if (!highRisk) {
        logger.error('❌ High Risk Profile not found.');
        return;
    }

    logger.info(`👤 Profile: ${highRisk.name}`);
    logger.info(`📂 Strategy Config Type: ${typeof highRisk.strategy_config}`);

    if (highRisk.strategy_config) {
        logger.info(`📂 Rules Array Type: ${Array.isArray(highRisk.strategy_config.rules) ? 'Array' : typeof highRisk.strategy_config.rules}`);

        logger.info('📋 RAW RULES DATA:');
        // print full json structure
        console.log(JSON.stringify(highRisk.strategy_config.rules, null, 2));
    } else {
        logger.warn('⚠️ strategy_config is missing or null');
    }

    logger.info('------------------------------------------------');
    logger.info('Expected IDs by Dashboard:');
    const expected = ['TrendBiasRule', 'MomentumRule', 'ZoneRule', 'SessionRule', 'EntryTriggerRule', 'RiskManagementRule', 'AIAnalysisRule'];
    logger.info(expected.join(', '));
}

auditProfileData().catch(console.error);
