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
Order Items Naming Standard (PocketBase)
Goal
Use one consistent, driver-oriented naming convention in order_items with drv_* prefixes.
Recommended Canonical Fields
item_status(global item lifecycle)drv_status(driver/collection lifecycle)drv_id(relation to driver/user table)drv_assigned_atdrv_collected_atdrv_problem_flagdrv_problem_typedrv_problem_notes
Transition Mapping
During migration, support these aliases in API:
driver_status->drv_statusdriver->drv_idproblem_flag->drv_problem_flagproblem_type->drv_problem_typeproblem_notes->drv_problem_notes
Safe Migration Plan
- Add new
drv_*fields (keep old fields temporarily). - Backfill new fields from existing values.
- Update UI and automation writes to new fields only.
- Keep read-compat for old fields for 1-2 release cycles.
- Remove deprecated fields once no writers remain.
Minimal State Model
item_status:pending,processing,po_generated,ready_delivery,delivered,cancelleddrv_status:unassigned,assigned,en_route,collected,failed
Keep item lifecycle and driver lifecycle separate to avoid status collisions.