59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
const axios = require('axios');
|
|
const FormData = require('form-data');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
async function testStaxSimple() {
|
|
try {
|
|
console.log('🔍 Testing STAX processing with simple strategy...');
|
|
|
|
// First login to get a token
|
|
const loginResponse = await axios.post('http://localhost:5000/api/auth/login', {
|
|
email: 'test@stax-processing.com',
|
|
password: 'TestPass123!'
|
|
});
|
|
|
|
const accessToken = loginResponse.data.data.tokens.accessToken;
|
|
console.log('✅ Authenticated successfully');
|
|
|
|
// Upload STAX document with simple processing strategy
|
|
const form = new FormData();
|
|
const filePath = path.join(__dirname, 'stax-cim-test.pdf');
|
|
form.append('document', fs.createReadStream(filePath));
|
|
form.append('processImmediately', 'true');
|
|
form.append('processingStrategy', 'basic'); // Use basic instead of agentic_rag
|
|
|
|
console.log('📤 Uploading STAX document with basic processing...');
|
|
|
|
const uploadResponse = await axios.post('http://localhost:5000/api/documents/upload', form, {
|
|
headers: {
|
|
...form.getHeaders(),
|
|
'Authorization': `Bearer ${accessToken}`
|
|
},
|
|
timeout: 120000 // 2 minutes timeout
|
|
});
|
|
|
|
console.log('✅ Upload successful!');
|
|
console.log('📄 Document ID:', uploadResponse.data.id);
|
|
console.log('🔄 Status:', uploadResponse.data.status);
|
|
|
|
// Wait a bit and check status
|
|
console.log('⏳ Waiting for processing...');
|
|
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
|
|
|
|
// Check document status
|
|
const docResponse = await axios.get(`http://localhost:5000/api/documents/${uploadResponse.data.id}`, {
|
|
headers: {
|
|
'Authorization': `Bearer ${accessToken}`
|
|
}
|
|
});
|
|
|
|
console.log('📄 Final Document Status:');
|
|
console.log(JSON.stringify(docResponse.data, null, 2));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error:', error.response?.data || error.message);
|
|
}
|
|
}
|
|
|
|
testStaxSimple();
|