Add PocketBase collections, APIs & migration docs
Introduce PocketBase workflow support, migration tooling, server APIs and documentation. Adds a set of PocketBase collection JSONs (order_items, order_items_v2, collection_pool, delivery_notes, delivery_note_items, repairs) and a large import manifest for workflow collections; includes docs describing MCP/API layer, migration audit, order-item schema and rollout plans. Adds server-side agent/MCP endpoints and services (api/mcp, api/v1/orders, collection-pool, order-items status, health) plus helper modules (pocketbase-admin, orders-service, order-item-status, agent-auth) and a migration script to create order_items_v2/collection_pool. UI: new pages for collection-pool, delivery-notes, repairs and several updates to orders/quotes pages, sidebar, tooltip and pb helpers/types. Also updates package.json (migration script and related changes) and global styles. Required env vars and suggested migration command are documented (e.g. NEXT_PUBLIC_POCKETBASE_URL, PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD, ORDER_ITEMS_COLLECTION; run npm run pb:migrate:orders-v2).
2026-05-25 16:39:33 +00:00
|
|
|
import PocketBase from "pocketbase";
|
|
|
|
|
|
|
|
|
|
const url = process.env.NEXT_PUBLIC_POCKETBASE_URL || "http://127.0.0.1:8090";
|
|
|
|
|
|
|
|
|
|
export async function getAdminPocketBase() {
|
|
|
|
|
const email = process.env.PB_ADMIN_EMAIL;
|
|
|
|
|
const password = process.env.PB_ADMIN_PASSWORD;
|
|
|
|
|
|
|
|
|
|
if (!email || !password) {
|
|
|
|
|
throw new Error("PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD are required for server API operations.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const pb = new PocketBase(url);
|
|
|
|
|
await pb.collection("_superusers").authWithPassword(email, password);
|
|
|
|
|
return pb;
|
2026-06-11 18:30:02 +00:00
|
|
|
}
|