#!/usr/bin/env node /** * Schema probe for the live PB instance. * * node scripts/probe-pb-schema.mjs * * Connects as admin and prints the field names for the collections we use * through the MCP server. Useful when a filter 400s or a collection 404s. */ import PocketBase from "pocketbase"; const PB_URL = process.env.POCKETBASE_URL || "https://pb.jeistk.apphub.co.za"; const PB_EMAIL = process.env.POCKETBASE_ADMIN_EMAIL || "david@wfsales.co.za"; const PB_PASSWORD = process.env.POCKETBASE_ADMIN_PASSWORD || "1234567890"; const pb = new PocketBase(PB_URL); pb.autoCancellation(false); await pb.admins.authWithPassword(PB_EMAIL, PB_PASSWORD); const wanted = [ "customers", "suppliers", "stock_items", "purchase_orders", "customer_pos", "customer_po_lines", "workflow_runs", ]; const all = await pb.collections.getFullList(); const byName = new Map(all.map((c) => [c.name, c])); for (const name of wanted) { const col = byName.get(name); if (!col) { console.log(`\n[probe] ${name}: ❌ NOT FOUND on this PB instance`); continue; } console.log(`\n[probe] ${name} (${col.id})`); for (const f of col.fields) { const extra = []; if (f.required) extra.push("required"); if (f.type === "relation") extra.push(`→ ${f.collectionName ?? "?"}`); if (f.type === "select") extra.push(`values=${(f.values || []).join("|")}`); console.log(` - ${f.name} [${f.type}${extra.length ? " — " + extra.join(", ") : ""}]`); } }