#!/usr/bin/env node require('dotenv').config(); const { connect, close } = require('../src/utils/db.util'); const Document = require('../src/models/Document.model'); async function main() { await connect(); // Query all documents with valid categories (including archived) const { MongoClient } = require('mongodb'); const client = new MongoClient(process.env.MONGO_URI || 'mongodb://localhost:27017'); try { await client.connect(); const db = client.db(process.env.MONGO_DB || 'tractatus_dev'); const collection = db.collection('documents'); const docs = await collection.find({ category: { $in: ['getting-started', 'technical-reference', 'research-theory', 'advanced-topics', 'case-studies', 'business-leadership', 'archives'] } }).sort({ category: 1, order: 1 }).toArray(); console.log(`\n${'='.repeat(70)}`); console.log(`COMPLETE VERIFICATION - All 34 Public Documents`); console.log(`${'='.repeat(70)}\n`); console.log(`Total documents: ${docs.length}\n`); const byCategory = {}; docs.forEach(doc => { const cat = doc.category; if (!byCategory[cat]) byCategory[cat] = []; byCategory[cat].push(doc); }); const categoryOrder = ['getting-started', 'technical-reference', 'research-theory', 'advanced-topics', 'case-studies', 'business-leadership', 'archives']; categoryOrder.forEach(cat => { if (byCategory[cat]) { const docsInCat = byCategory[cat].sort((a, b) => (a.order || 999) - (b.order || 999)); console.log(`\n${'━'.repeat(70)}`); console.log(`${cat.toUpperCase().replace(/-/g, ' ')} (${docsInCat.length} docs)`); console.log(`${'━'.repeat(70)}`); docsInCat.forEach(doc => { const sections = doc.sections ? doc.sections.length : 0; const sectionStatus = sections > 0 ? `✅ ${sections} sections` : `❌ No sections`; const visibility = doc.visibility || 'public'; const visLabel = visibility === 'archived' ? ' [ARCHIVED]' : ''; console.log(`${doc.order}. ${doc.title}${visLabel}`); console.log(` ${doc.slug} | ${sectionStatus}`); }); } }); console.log(`\n${'='.repeat(70)}`); console.log(`Total: ${docs.length} documents`); if (docs.length === 34) { console.log('✅ SUCCESS - All 34 expected documents present'); } else { console.log(`⚠️ MISMATCH - Expected 34, found ${docs.length}`); } console.log(`${'='.repeat(70)}\n`); await client.close(); await close(); } catch (error) { console.error('Error:', error); } } main();