import type { WithRev } from '@/api/type'; import type { FdoPurchaseOrderRequest } from '@feedmepos/zod-inventory'; export type WithToInventoryLocation = { toInventoryLocation: FdoInventoryLocation; }; /** One page of the multi-location bulk browse: standard cursor pagination — * follow hasNext/cursor until drained. Rows are FdtoPurchaseOrderListItem * (zod-inventory DTO): exactly the table's fields plus server-computed * itemCount and partial/over-received flags — heavy arrays never ship. * `failed` lists locations the server dropped this page. */ export type PurchaseOrderBrowsePage = { data: FdtoPurchaseOrderListItem[]; hasNext: boolean; cursor?: string; /** Failed locations are carried inside the cursor (with their resume * bookmarks) — pass the cursor back with retryFailed to retry them. * retryable: false once a location exhausted its attempts. */ failed: Array<{ dbName: string; error: string; retryable: boolean; }>; /** Locations still queued after this page — fetch progress denominator: * done = requested - pending. */ pendingLocations: number; }; export declare const usePurchaseOrderApi: () => { readRequests(dbName?: string, start?: string, end?: string): Promise[]>; readRequestById(_id: string, dbName?: string): Promise; readRequestByIds(requestIds: string[], dbName?: string): Promise<(FdoPurchaseOrderRequest & WithToInventoryLocation)[]>; getPurchaseOrders({ start, end, dbName: overrideDbName }: { start: string; end: string; dbName?: string | undefined; }): Promise[]>; getLatestPurchaseOrderRequest(purchaseOrderId: FdoPurchaseOrder['_id']): Promise; getPurchaseOrderById(id: FdoPurchaseOrder['_id'], dbName?: string, signal?: AbortSignal): Promise>; /** One request fetches a page of PO summaries across many locations * (business-scoped). Standard cursor pagination: pass the returned cursor * back until hasNext is false — the server owns the multi-db crawl and * returns early when its per-request doc/time budget is reached. */ getBulkPaginatedPurchaseOrders({ locations, start, end, pageSize, status, supplierId, cursor, retryFailed }: { locations: Array<{ dbName: string; }>; start: string; end: string; pageSize?: number | undefined; status?: string[] | undefined; supplierId?: string | undefined; cursor?: string | undefined; /** With a cursor: re-queue its failed locations from their bookmarks. */ retryFailed?: boolean | undefined; }, signal?: AbortSignal): Promise; /** * @deprecated Use `processPurchaseOrderV2` instead. */ processPurchaseOrder(dto: FdtoPurchaseOrderOperation, db?: string): Promise>; createPurchaseOrder(purchase: FdtoCreatePurchaseOrder): Promise>; updatePurchaseOrder(purchase: FdtoUpdatePurchaseOrder): Promise>; importFromXilnex(payload: FdtoXilnexTransferNote): Promise; processPurchaseOrderV2(dto: FdtoPurchaseOrderOperateV2Request, db?: string): Promise>; getWorkflowConfig(): Promise; updateDeliveryOrder(payload: FdtoDeliveryOrderUpdateRequest): Promise; createDeliveryOrder(payload: FdtoDeliveryOrderCreateRequest): Promise; getDeliveryOrderTrails(purchaseOrderId: string, deliveryOrderId: string): Promise; enqueueBulkEmail(dbName: string, payload: { senderEmail: string; senderName: string; /** One entry per recipient email — all POs for the same recipient are sent as a * single email, zipped into one attachment when there's more than one PO. */ items: { subject: string; recipientName: string; recipientEmail: string; /** Optional freeform text prepended to the generated email body. */ message?: string | undefined; pos: { poId: string; dbName: string; filename: string; }[]; }[]; }): Promise<{ jobId: string; }>; enqueueBulkDownload(dbName: string, payload: { items: { poId: string; dbName: string; filename: string; rev?: string | undefined; }[]; }): Promise<{ jobId: string; fromCache?: boolean; }>; cancelBulkJob(dbName: string, jobId: string): Promise; getBulkJobStatus(dbName: string, jobId: string): Promise | null>; downloadBulkJob(dbName: string, jobId: string): Promise; /** * Fetches (or generates via Lambda) the PDF for a single purchase order. * * The backend checks S3 cache first: * - Cache hit → 200 with the PDF stream (returned as Blob) * - Cache miss → 202 with `{ jobId }` — Lambda generation was queued. * The caller should subscribe to the SSE job for `jobId`, wait for * `downloadReady`, then call this function again (second call is always * a cache hit since Lambda writes to the stable S3 cache key). */ getPurchaseOrderPdf(poId: string, dbName: string, rev?: string): Promise; }; export declare const purchaseOrderApi: {};