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
- 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
119 lines
4.0 KiB
JavaScript
119 lines
4.0 KiB
JavaScript
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();
|