Security: - Add authentication to /api/documents/archived endpoint (admin-only) - Prevent public exposure of 108 archived/internal documents Documentation UI: - Remove duplicate hardcoded Resources section from docs.html - Add Resources category to docs-app.js for implementation guides - Move 3 implementation guides from Getting Started to Resources - Move Glossary from Technical Reference to Getting Started - Set Research & Theory section to collapsed by default - Update service worker cache version to 0.1.4 Migration Scripts: - Add scripts for document category reorganization - Add scripts for research document migration to production - Add scripts for glossary verification and comparison Files changed: - public/docs.html: Remove duplicate Resources section - public/js/docs-app.js: Add Resources category, collapse Research - public/service-worker.js: Bump cache to v0.1.4 - src/routes/documents.routes.js: Secure /archived endpoint - scripts/*: Add 10 migration/diagnostic scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
102 lines
3.7 KiB
JavaScript
102 lines
3.7 KiB
JavaScript
/**
|
||
* Reorganize document categories as requested:
|
||
* 1. Move implementation guides from getting-started to resources category
|
||
* 2. Move Glossary from technical-reference to getting-started
|
||
* 3. Ensure Research & Theory section is collapsed by default
|
||
*/
|
||
const { MongoClient } = require('mongodb');
|
||
require('dotenv').config({ path: '/var/www/tractatus/.env' });
|
||
|
||
async function run() {
|
||
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017';
|
||
const DB_NAME = process.env.MONGODB_DB || 'tractatus_prod';
|
||
|
||
const client = new MongoClient(MONGODB_URI);
|
||
await client.connect();
|
||
|
||
console.log('═══════════════════════════════════════════════════════════');
|
||
console.log(' REORGANIZING DOCUMENT CATEGORIES');
|
||
console.log('═══════════════════════════════════════════════════════════\n');
|
||
|
||
const db = client.db(DB_NAME);
|
||
const collection = db.collection('documents');
|
||
|
||
// 1. Find guides in Getting Started
|
||
console.log('1️⃣ Finding implementation guides in Getting Started...\n');
|
||
|
||
const guides = await collection.find({
|
||
category: 'getting-started',
|
||
slug: { $in: [
|
||
'implementation-guide-v1.1',
|
||
'implementation-guide',
|
||
'implementation-guide-python-examples'
|
||
]}
|
||
}).project({ slug: 1, title: 1 }).toArray();
|
||
|
||
console.log(`Found ${guides.length} guides:`);
|
||
guides.forEach(g => console.log(` - ${g.slug}`));
|
||
|
||
// 2. Move guides to resources category
|
||
if (guides.length > 0) {
|
||
console.log('\n📝 Moving guides to resources category...\n');
|
||
|
||
const result = await collection.updateMany(
|
||
{ slug: { $in: guides.map(g => g.slug) } },
|
||
{
|
||
$set: {
|
||
category: 'resources',
|
||
updated_at: new Date()
|
||
}
|
||
}
|
||
);
|
||
|
||
console.log(`✅ Moved ${result.modifiedCount} guides to resources`);
|
||
}
|
||
|
||
// 3. Move Glossary to getting-started
|
||
console.log('\n2️⃣ Moving Glossary to Getting Started...\n');
|
||
|
||
const glossaryResult = await collection.updateOne(
|
||
{ slug: 'GLOSSARY' },
|
||
{
|
||
$set: {
|
||
category: 'getting-started',
|
||
order: 10,
|
||
updated_at: new Date()
|
||
}
|
||
}
|
||
);
|
||
|
||
if (glossaryResult.modifiedCount > 0) {
|
||
console.log('✅ Glossary moved to getting-started (order: 10)');
|
||
} else {
|
||
console.log('⚠️ Glossary not found or already in getting-started');
|
||
}
|
||
|
||
// 4. Verify final state
|
||
console.log('\n3️⃣ Verifying final categories...\n');
|
||
|
||
const gettingStarted = await collection.find({ category: 'getting-started', visibility: 'public' })
|
||
.project({ slug: 1, title: 1, order: 1 })
|
||
.sort({ order: 1 })
|
||
.toArray();
|
||
|
||
console.log(`Getting Started (${gettingStarted.length} documents):`);
|
||
gettingStarted.forEach(d => console.log(` [${d.order}] ${d.slug}`));
|
||
|
||
const resources = await collection.find({ category: 'resources', visibility: 'public' })
|
||
.project({ slug: 1, title: 1, order: 1 })
|
||
.sort({ order: 1 })
|
||
.toArray();
|
||
|
||
console.log(`\nResources (${resources.length} documents):`);
|
||
resources.forEach(d => console.log(` [${d.order || 'none'}] ${d.slug}`));
|
||
|
||
await client.close();
|
||
|
||
console.log('\n═══════════════════════════════════════════════════════════');
|
||
console.log(' REORGANIZATION COMPLETE');
|
||
console.log('═══════════════════════════════════════════════════════════\n');
|
||
}
|
||
|
||
run().catch(console.error);
|