Dashboard (content library, publishing queue with approvals, inbox, team management, AI runs), Meta connector, branded PDF reports, agent skills, and Docker packaging (Dockerfile, docker-compose with Caddy HTTPS, backup and path-relocation scripts). Client data, live data and secrets are excluded via .gitignore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.5 KiB
JavaScript
30 lines
1.5 KiB
JavaScript
// Export a full snapshot of every connected account for audits.
|
|
// Usage (from connector folder): node scripts/export-all.js
|
|
// Writes ../data/snapshot-YYYY-MM-DD.json (no tokens included).
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { PROJECT_ROOT } from "../src/env.js";
|
|
import * as meta from "../src/meta.js";
|
|
|
|
const out = { generated_at: new Date().toISOString(), accounts: [] };
|
|
const accts = await meta.listAccounts();
|
|
for (const a of accts) {
|
|
const rec = { ...meta.publicAccount(a), errors: {} };
|
|
process.stdout.write(`• ${a.page_name} ... `);
|
|
const tryit = async (key, fn) => { try { rec[key] = await fn(); } catch (e) { rec.errors[key] = e.message; } };
|
|
await tryit("facebook_28d", () => meta.pageInsights(a, { sinceDays: 28 }));
|
|
await tryit("facebook_90d", () => meta.pageInsights(a, { sinceDays: 90 }));
|
|
await tryit("facebook_posts", () => meta.pageRecentPosts(a, { limit: 25 }));
|
|
if (a.instagram) {
|
|
await tryit("instagram_28d", () => meta.igAccountInsights(a.instagram.id, { sinceDays: 28 }));
|
|
await tryit("instagram_posts", () => meta.igRecentMedia(a.instagram.id, { limit: 30 }));
|
|
}
|
|
out.accounts.push(rec);
|
|
console.log(Object.keys(rec.errors).length ? `done (${Object.keys(rec.errors).length} errors)` : "done");
|
|
}
|
|
const dir = path.join(PROJECT_ROOT, "data");
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
const file = path.join(dir, `snapshot-${new Date().toISOString().slice(0, 10)}.json`);
|
|
fs.writeFileSync(file, JSON.stringify(out, null, 2));
|
|
console.log(`\nSaved ${file}`);
|