tractatus/scripts/export-research-doc.js
TheFlow b199a3e265 fix(security): secure archived documents endpoint and reorganize docs UI
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>
2025-10-26 00:03:13 +13:00

40 lines
1,022 B
JavaScript

/**
* Export tractatus-framework-research document to JSON file
*/
const { MongoClient } = require('mongodb');
const fs = require('fs');
async function run() {
const devClient = new MongoClient('mongodb://localhost:27017');
await devClient.connect();
const devDoc = await devClient.db('tractatus_dev').collection('documents').findOne({
slug: 'tractatus-framework-research'
});
await devClient.close();
if (!devDoc) {
console.log('❌ Document not found in dev');
process.exit(1);
}
// Prep for production
delete devDoc._id;
devDoc.category = 'research-theory';
devDoc.order = 2;
devDoc.visibility = 'public';
devDoc.updated_at = new Date();
// Write to file
fs.writeFileSync(
'/tmp/tractatus-framework-research.json',
JSON.stringify(devDoc, null, 2)
);
console.log(`✅ Exported: ${devDoc.title}`);
console.log(` Sections: ${devDoc.sections?.length || 0}`);
console.log(` File: /tmp/tractatus-framework-research.json`);
}
run().catch(console.error);