feat(db): mesh data model — meshes, members, invites, audit log

- pgSchema "mesh" with 4 tables isolating the peer mesh domain
- Enums: visibility, transport, tier, role
- audit_log is metadata-only (E2E encryption enforced at broker/client)
- Cascade on mesh delete, soft-delete via archivedAt/revokedAt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-04 21:19:32 +01:00
commit d3163a5bff
1384 changed files with 314925 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
/**
* List recent documents and their embedding counts
* Run: pnpm with-env npx tsx packages/api/tests/list-documents.ts
*/
import { sql } from "@turbostarter/db";
import { db } from "@turbostarter/db/server";
async function list() {
const docs = await db.execute<{
id: string;
name: string | null;
path: string;
embedding_count: number;
created_at: Date;
}>(sql`
SELECT d.id, d.name, d.path, d.created_at,
(SELECT COUNT(*)::int FROM pdf.embedding e WHERE e.document_id = d.id) as embedding_count
FROM pdf.document d
ORDER BY d.created_at DESC
LIMIT 10
`);
console.log("\nRecent documents:\n");
for (const doc of docs as { id: string; name: string | null; path: string; embedding_count: number; created_at: Date }[]) {
console.log(` 📄 ${doc.name ?? "unnamed"}`);
console.log(` ID: ${doc.id}`);
console.log(` Path: ${doc.path}`);
console.log(` Embeddings: ${doc.embedding_count}`);
console.log(` Created: ${String(doc.created_at)}`);
console.log("");
}
process.exit(0);
}
list().catch((e) => {
console.error("Error:", e);
process.exit(1);
});