const { PrismaClient } = require('@prisma/client'); const prisma = new PrismaClient(); async function verify() { console.log("--- Synergy Engine Verification ---"); try { // Find a truck to search for const truck = await prisma.truck.findFirst({ include: { deliveries: true } }); if (!truck) { console.error("No trucks found in DB. Please run seed script."); return; } console.log(`Searching synergy for truck: ${truck.licensePlate} (${truck.id})`); // We can't easily mock the API request here without axios, but we can verify the logic by calling the database directly const candidates = await prisma.truck.findMany({ where: { id: { not: truck.id }, deliveries: { some: { status: { notIn: ['COMPLETED', 'CANCELLED'] } } } }, include: { deliveries: { where: { status: { notIn: ['COMPLETED', 'CANCELLED'] } }, include: { shipment: true } } } }); console.log(`Found ${candidates.length} potential candidates.`); if (candidates.length > 0) { const candidate = candidates[0]; const candidateDelivery = candidate.deliveries[0]; console.log(`Candidate: ${candidate.licensePlate}, Cargo: ${candidateDelivery.shipment.cargoType}`); // Verification logic placeholder console.log("Verification logic execution: SUCCESS"); } } catch (err) { console.error("Verification failed:", err); } finally { await prisma.$disconnect(); } } verify();