Files
cim_summary/backend/test-supabase-connection.js
Jon 185c780486
Some checks failed
CI/CD Pipeline / Backend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Build Backend (push) Has been cancelled
CI/CD Pipeline / Build Frontend (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Performance Tests (push) Has been cancelled
CI/CD Pipeline / Dependency Updates (push) Has been cancelled
🚀 Update to Claude 3.7 latest and fix LLM processing issues
- Updated Anthropic API to latest version (2024-01-01)
- Set Claude 3.7 Sonnet Latest as primary model
- Removed deprecated Opus 3.5 references
- Fixed LLM response validation and JSON parsing
- Improved error handling and logging
- Updated model configurations and pricing
- Enhanced document processing reliability
- Fixed TypeScript type issues
- Updated environment configuration
2025-08-17 17:31:56 -04:00

119 lines
4.0 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { createClient } = require('@supabase/supabase-js');
const path = require('path');
// Load environment variables
require('dotenv').config({ path: path.join(__dirname, '.env') });
console.log('🔧 Testing Supabase connection...');
console.log(' SUPABASE_URL:', process.env.SUPABASE_URL ? 'Set' : 'Not set');
console.log(' SUPABASE_SERVICE_KEY:', process.env.SUPABASE_SERVICE_KEY ? 'Set' : 'Not set');
console.log(' NODE_ENV:', process.env.NODE_ENV || 'Not set');
async function testSupabaseConnection() {
try {
console.log('🔄 Creating Supabase client...');
// Create Supabase client
const supabase = createClient(
process.env.SUPABASE_URL,
process.env.SUPABASE_SERVICE_KEY,
{
auth: {
persistSession: false,
autoRefreshToken: false,
}
}
);
console.log('✅ Supabase client created!');
// Test connection by querying documents table
console.log('🔄 Testing documents table query...');
const { data: documents, error } = await supabase
.from('documents')
.select('id, original_file_name, status, analysis_data')
.limit(5);
if (error) {
console.error('❌ Query failed:', error);
return;
}
console.log('✅ Query successful!');
console.log(`📊 Found ${documents.length} documents`);
// Check analysis data
const docsWithAnalysis = documents.filter(doc => doc.analysis_data);
const docsWithoutAnalysis = documents.filter(doc => !doc.analysis_data);
console.log(` 📋 Documents with analysis_data: ${docsWithAnalysis.length}`);
console.log(` ❌ Documents without analysis_data: ${docsWithoutAnalysis.length}`);
if (docsWithAnalysis.length > 0) {
console.log('\n📄 Sample documents with analysis_data:');
docsWithAnalysis.forEach((doc, index) => {
console.log(` ${index + 1}. ${doc.original_file_name} (${doc.status})`);
if (doc.analysis_data) {
const keys = Object.keys(doc.analysis_data);
console.log(` Analysis keys: ${keys.join(', ')}`);
// Check if it has the expected structure
const expectedSections = [
'dealOverview',
'businessDescription',
'marketIndustryAnalysis',
'financialSummary',
'managementTeamOverview',
'preliminaryInvestmentThesis',
'keyQuestionsNextSteps'
];
const missingSections = expectedSections.filter(section => !doc.analysis_data[section]);
if (missingSections.length > 0) {
console.log(` ❌ Missing sections: ${missingSections.join(', ')}`);
} else {
console.log(` ✅ All expected sections present`);
}
}
});
}
if (docsWithoutAnalysis.length > 0) {
console.log('\n⚠ Documents without analysis_data:');
docsWithoutAnalysis.forEach((doc, index) => {
console.log(` ${index + 1}. ${doc.original_file_name} (${doc.status})`);
});
}
// Get total counts
console.log('\n🔄 Getting total counts...');
const { count: totalDocs } = await supabase
.from('documents')
.select('*', { count: 'exact', head: true });
const { count: docsWithAnalysisCount } = await supabase
.from('documents')
.select('*', { count: 'exact', head: true })
.not('analysis_data', 'is', null);
console.log('📈 Database Statistics:');
console.log(` Total Documents: ${totalDocs}`);
console.log(` With Analysis Data: ${docsWithAnalysisCount}`);
console.log(` Without Analysis Data: ${totalDocs - docsWithAnalysisCount}`);
console.log('\n✅ All tests completed successfully!');
} catch (error) {
console.error('❌ Test failed:', error.message);
console.error(' Error details:', error);
}
}
// Add timeout
setTimeout(() => {
console.log('⏰ Test timeout after 30 seconds');
process.exit(1);
}, 30000);
testSupabaseConnection();