#!/usr/bin/env node require('dotenv').config(); const mongoose = require('mongoose'); const SubmissionTracking = require('../src/models/SubmissionTracking.model'); async function createPackage() { await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/tractatus_dev'); const BlogPost = mongoose.connection.db.collection('blog_posts'); // Get the main article blog post const mainArticle = await BlogPost.findOne({ slug: 'the-new-a-i-amoral-intelligence' }); // Get the letter (to extract content then delete) const letterPost = await BlogPost.findOne({ slug: 'letter-to-the-economist-amoral-intelligence' }); if (!mainArticle) { console.error('Main article not found'); process.exit(1); } console.log('Found main article:', mainArticle.title); if (letterPost) { console.log('Found letter post:', letterPost.title); } // Create submission package const submission = new SubmissionTracking({ blogPostId: mainArticle._id, publicationId: 'economist-letter', publicationName: 'The Economist', title: mainArticle.title, wordCount: letterPost ? letterPost.content.split(/\s+/).length : 216, contentType: 'letter', status: 'ready', createdBy: new mongoose.Types.ObjectId('000000000000000000000000'), lastUpdatedBy: new mongoose.Types.ObjectId('000000000000000000000000') }); // Store main article await submission.setDocumentVersion('mainArticle', 'en', mainArticle.content, { translatedBy: 'manual', approved: true }); // Store cover letter (the "SIR—" letter) if (letterPost) { await submission.setDocumentVersion('coverLetter', 'en', letterPost.content, { translatedBy: 'manual', approved: true }); } await submission.save(); console.log('\n✅ Economist package created!'); console.log('Submission ID:', submission._id); console.log('Linked to blog post:', mainArticle._id); // Remove letter from blog posts if (letterPost) { await BlogPost.updateOne( { _id: letterPost._id }, { $set: { status: 'archived' } } ); console.log('✅ Letter post archived'); } await mongoose.connection.close(); } createPackage().catch(console.error);