From 1e99d23e8be0c5667811e0ee005daf3804b67c0d Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Thu, 9 Jul 2026 22:17:21 +0200 Subject: [PATCH] feat(po-pdf): add token field to PurchaseOrderDocumentEntry --- src/app/api/v1/purchase-orders/[id]/pdf/route.ts | 5 +++++ src/lib/types.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/app/api/v1/purchase-orders/[id]/pdf/route.ts b/src/app/api/v1/purchase-orders/[id]/pdf/route.ts index 2cd1ee5..1e9e424 100644 --- a/src/app/api/v1/purchase-orders/[id]/pdf/route.ts +++ b/src/app/api/v1/purchase-orders/[id]/pdf/route.ts @@ -215,6 +215,11 @@ export async function POST( const newHistoryEntry: PurchaseOrderDocumentEntry = { version: nextVersion, file: filename, + // Task 2 will swap this for the real PB token returned from + // the upload response. For now we persist an empty string so + // the schema compiles; the GET handler falls back to + // `documents[idx]` when token is empty (legacy rows). + token: "", generatedAt: generatedAtIso, generatedBy: body.generatedBy || "", reason: (body.notes || "").slice(0, 500), diff --git a/src/lib/types.ts b/src/lib/types.ts index 632e946..6062780 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -60,6 +60,8 @@ export interface Company extends BaseRecord { company: string; address: string; vendor: string; + company_email: string; + company_tel: string; /** * Geographic location for future routing / delivery features. * @@ -674,6 +676,14 @@ export interface PurchaseOrderDocumentEntry { version: number; /** PB-generated filename for the file in `purchase_orders.documents`. */ file: string; + /** + * PB-side file token (the slugged-on-disk name) for the file in + * `purchase_orders.documents`. Distinct from `file` (the + * human-readable name we asked PB to store). New entries always + * populate this; legacy rows may be empty — the GET handler + * falls back to `documents[idx]` for those. + */ + token: string; /** ISO 8601 timestamp the PDF was generated. */ generatedAt: string; /** User id of the operator who triggered the regen (empty string if automated). */