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).
1.2 KiB
1.2 KiB
API + MCP Layer
Environment
Add to .env.local:
NEXT_PUBLIC_POCKETBASE_URL=http://127.0.0.1:8090
PB_ADMIN_EMAIL=your_admin_email
PB_ADMIN_PASSWORD=your_admin_password
AGENT_API_KEY=replace_with_secure_token
ORDER_ITEMS_COLLECTION=order_items
REST Endpoints
GET /api/v1/healthGET /api/v1/orders?page=1&perPage=50&status=newPOST /api/v1/orders/from-quoteGET /api/v1/collection-pool?page=1&perPage=50&status=queuedPATCH /api/v1/order-items/{id}/status
Auth for agent routes:
- Header:
Authorization: Bearer <AGENT_API_KEY>
POST /orders/from-quote body:
{ "quote_id": "QUOTE_RECORD_ID" }
PATCH /order-items/{id}/status body supports:
{
"item_status": "processed",
"drv_status": "assigned",
"notes": "Assigned to route 2"
}
MCP Endpoint
POST /api/mcp
Supported methods:
tools/listtools/call
Available tools:
orders.listorders.create_from_quotecollection_pool.listorder_items.update_status
Notes
ORDER_ITEMS_COLLECTIONcontrols where order-item writes/updates go.- Set
ORDER_ITEMS_COLLECTION=order_itemsonce new collection is created/imported. - Status endpoint accepts
driver_statusinput and normalizes todrv_status.