MEGAINFRA-WEBAPP/scripts/dn-snapshot.mts
DEls 1031a103c0 chore(dn): add two read-only checks for the staged rollout
dn-snapshot prints row counts across the delivery-note collections. The
two that matter are delivery_notes and delivery_note_items: the staged
pipeline must never move them on its own, so a reading before and after a
test says plainly whether anything reached the ledger.

dn-board renders the inbox board as text, which is how the pipeline can
be read over SSH or while the app is mid-deploy.

Both are read-only. The other scripts written while diagnosing this work
were one-off probes and are not kept.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 01:00:44 +02:00

29 lines
922 B
TypeScript

// Row counts across the delivery-note collections. Read-only.
//
// The two that matter during rollout are delivery_notes and
// delivery_note_items: the staged pipeline must never move them on its
// own, so take a reading before a test and compare it afterwards.
//
// npx tsx --env-file=.env.local scripts/dn-snapshot.mts
//
// .mts, not .ts: top-level await, and the package has no "type": "module".
import { pbAdmin } from "../src/lib/pb";
const COLLECTIONS = [
"dn_batches",
"dn_batch_sources",
"dn_batch_pages",
"dn_batch_notes",
"dn_pipeline_locks",
"dn_review_events",
"delivery_notes",
"delivery_note_items",
];
const pb = await pbAdmin();
const counts: Record<string, number> = {};
for (const collection of COLLECTIONS) {
const page = await pb.collection(collection).getList(1, 1, { fields: "id" });
counts[collection] = page.totalItems;
}
console.log(JSON.stringify(counts, null, 2));