// No response bodies or credentials are logged by rollout acceptance. async function accept(base) { const r = await fetch(`${base}/api/products?limit=1`, {signal: AbortSignal.timeout(5000), redirect: 'error'}); if (r.status !== 200) throw new Error('catalog status'); const b = await r.json(); if (!Array.isArray(b.data) || !Number.isInteger(b.meta?.total) || b.meta.total < 0) throw new Error('catalog shape'); } async function main() { const {PrismaClient} = require('@prisma/client'); const db = new PrismaClient(); try { const names = ['tasks','runs','artifacts','attestations','dependencies','approval_decisions','events','budget_ledger','kill_switches']; for (const name of names) await db.$queryRawUnsafe(`SELECT * FROM orchestration_${name} LIMIT 0`); const rows = await db.$queryRawUnsafe("SELECT 1 FROM _prisma_migrations WHERE migration_name = '20261022000000_add_orchestration_v4_core' AND finished_at IS NOT NULL AND rolled_back_at IS NULL"); if (rows.length !== 1) throw new Error('migration receipt'); for (let n=0; n<30; n++) { try { await accept('http://127.0.0.1:3000'); console.log('Backend schema/catalog acceptance passed'); return; } catch { if(n===29) throw new Error('catalog acceptance'); await new Promise(r=>setTimeout(r,2000)); } } } finally { await db.$disconnect(); } } module.exports = {accept}; // node -e is used inside the built backend; imports in tests do not execute main. if (!module.parent) main().catch(()=>{console.error('Backend acceptance failed (schema, migration receipt or catalog)');process.exitCode=1;});