- server/pb-mcp.mjs: 15-tool MCP server for purchase-order workflow (CRUD, suppliers, stock, customers, customer POs, validate_draft, generate_order_number) - src/lib/api/purchaseOrders.ts: typed helpers shared by UI + MCP + n8n - src/components/purchase-orders/pdf.ts: jsPDF PO generator - src/components/purchase-orders/ViewOrderDialog.tsx: read-only dialog - src/components/purchase-orders/AttachmentsDialog.tsx: attachment mgmt - src/components/purchase-orders/NumberInput.tsx: numeric input - scripts/mcp-create-po.mjs: end-to-end driver (MCP stdio smoke test) - pocketbase/pb_migrations/1786200007_*: schema migration - docs/MCP_AND_N8N.md: MCP + n8n integration guide Verified end-to-end via MCP: generate_order_number → create_purchase_order with snapshot_items for an actual quote (DRILL-19042 / 161053).
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
#!/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(", ") : ""}]`);
|
|
}
|
|
}
|