/** * Prepare Public Documents * 1. Verify all public docs have sections (cards) * 2. Generate missing PDFs * 3. Report status */ const { MongoClient } = require('mongodb'); // Documents that should be public (from audit) const PUBLIC_DOCS = [ // Getting Started (6) 'introduction-to-tractatus', 'core-concepts-tractatus', 'executive-summary-tractatus-inflection-point', 'implementation-guide-tractatus', 'implementation-guide', 'implementation-guide-python-examples', // Research & Theory (7 including working paper) 'tractatus-framework-research', // Working Paper v0.1 'pluralistic-values-research-foundations', 'case-study-27027-pattern-recognition-bias', 'case-study-framework-failure-and-recovery', 'llm-integration-feasibility-research-scope', 'research-topic-concurrent-session-architecture', 'research-topic-rule-proliferation-transactional-overhead', // Technical Reference (5) 'technical-architecture', 'api-reference-complete', 'api-javascript-examples', 'api-python-examples', 'openapi-specification', // Advanced Topics (3) 'value-pluralism-faq', 'tractatus-framework-core-values', 'organizational-theory-foundations', // Business Leadership (1) 'business-case-tractatus-framework' ]; async function run() { const client = new MongoClient('mongodb://localhost:27017'); try { await client.connect(); const db = client.db('tractatus_dev'); const collection = db.collection('documents'); console.log('═══════════════════════════════════════════════════════════'); console.log(' PUBLIC DOCUMENTS PREPARATION'); console.log('═══════════════════════════════════════════════════════════\n'); const needsSections = []; const needsPDF = []; const ready = []; const notFound = []; for (const slug of PUBLIC_DOCS) { const doc = await collection.findOne({ slug }); if (!doc) { notFound.push(slug); continue; } const hasSections = doc.sections && doc.sections.length > 0; const hasPDF = doc.download_formats && doc.download_formats.pdf; if (hasSections && hasPDF) { ready.push({ slug, title: doc.title, sections: doc.sections.length }); } else if (!hasSections && !hasPDF) { needsSections.push({ slug, title: doc.title }); needsPDF.push({ slug, title: doc.title }); } else if (!hasSections) { needsSections.push({ slug, title: doc.title }); } else if (!hasPDF) { needsPDF.push({ slug, title: doc.title }); } } console.log('SUMMARY:'); console.log(` ✅ Ready (sections + PDF): ${ready.length}`); console.log(` ⚠️ Needs sections: ${needsSections.length}`); console.log(` ⚠️ Needs PDF: ${needsPDF.length}`); console.log(` ❌ Not found: ${notFound.length}\n`); if (ready.length > 0) { console.log('═══════════════════════════════════════════════════════════'); console.log(' ✅ READY FOR PUBLIC'); console.log('═══════════════════════════════════════════════════════════\n'); ready.forEach(d => { console.log(` ✓ ${d.title}`); console.log(` Slug: ${d.slug} | Sections: ${d.sections}`); }); console.log(''); } if (needsSections.length > 0) { console.log('═══════════════════════════════════════════════════════════'); console.log(' ⚠️ NEEDS SECTIONS (CARDS)'); console.log('═══════════════════════════════════════════════════════════\n'); needsSections.forEach(d => { console.log(` ⚠️ ${d.title}`); console.log(` Slug: ${d.slug}`); }); console.log(''); } if (needsPDF.length > 0) { console.log('═══════════════════════════════════════════════════════════'); console.log(' ⚠️ NEEDS PDF GENERATION'); console.log('═══════════════════════════════════════════════════════════\n'); needsPDF.forEach(d => { console.log(` ⚠️ ${d.title}`); console.log(` Slug: ${d.slug}`); }); console.log(''); } if (notFound.length > 0) { console.log('═══════════════════════════════════════════════════════════'); console.log(' ❌ NOT FOUND IN DATABASE'); console.log('═══════════════════════════════════════════════════════════\n'); notFound.forEach(slug => { console.log(` ❌ ${slug}`); }); console.log(''); } await client.close(); process.exit(0); } catch (error) { console.error('Error:', error); await client.close(); process.exit(1); } } run();