@asteby/storefront 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -408,6 +408,32 @@ a rule that produces a `discard_fields` field. `qr_canonical` (top level) is a t
408
408
  (`fiscal_regime`, `invoice_use`). A text that does not match yields `missing` (required fields); only a spec that cannot
409
409
  run throws `IdentityRulesError`.
410
410
 
411
+ ## Buyer account: orders, shipments, invoices (Storefront API 1.8)
412
+
413
+ `customer.order(id)` carries `progress` (unified timeline), `next_action`, `shipments[]` (events, carrier, `https`
414
+ tracking link), `invoices[]` (invoices and credit notes), `payments[]`, `refunds[]` and `degraded[]` (sections the
415
+ server could not read: show a retry there, the rest is valid). `customer.orders()` returns the summary
416
+ (`shipments_summary`, no detail sections). Every enum is open: an unknown stage, status or kind type-checks and must
417
+ fall back safely in the UI.
418
+
419
+ ```ts
420
+ import { orderProgress, nextAction, sortTrackingEvents, isTestShipment, groupInvoiceDocs, invoiceFileBytes } from '@asteby/storefront'
421
+
422
+ const order = await sf.customer.order(id) // null when it is not the buyer's
423
+ const progress = orderProgress(order!) // the server's, or derived for an older OPS
424
+ const action = nextAction(order!) // { kind: 'track' | 'pay' | ..., href: https-only | null }
425
+ const pending = await sf.customer.pendingPayments() // cash vouchers (OXXO, SPEI) not paid yet: no order exists yet
426
+
427
+ // Invoice download: authenticated route, the answer is the FILE (base64), never a URL of the PAC.
428
+ const file = await sf.customer.invoiceFile(order.id, doc.id, 'pdf') // null when not found / not the buyer's
429
+ if (file) return new Response(invoiceFileBytes(file), { headers: { 'Content-Type': file.content_type, 'Cache-Control': 'no-store' } })
430
+ ```
431
+
432
+ Sandbox rules: a shipment or invoice with `test_mode: true` (`isTestShipment` / `isTestInvoice`) is never shown as real:
433
+ hide it or label it "test". `label_url` exists only on return shipments. The mock (`@asteby/storefront/mock`) serves
434
+ demo orders for every state (shipped with events, invoice + credit note + refund, sandbox shipment, pickup with a
435
+ degraded section) and two pending vouchers for the demo buyer.
436
+
411
437
  ## Connecting the store to OPS (`connect`, `diagnose`, token files)
412
438
 
413
439
  A server-side store (`sk_`) is connected to OPS with a one-time code, never by copying a secret around.
@@ -475,7 +501,7 @@ Errors: a `403 insufficient_scope` is a `StorefrontError` with `code: 'insuffici
475
501
  Resources: `shop.get`, `region`, `products.list/get/recommendations`,
476
502
  `collections.list/get`, `stock.get`,
477
503
  `carts.create/get/addLines/updateLines/removeLines/setDiscountCodes/setBuyer/setShippingAddress/deliveryOptions/setDelivery/setInvoice/checkout`,
478
- `customer.requestOtp/createSession/capabilities/register/verifyRegistration/loginWithPassword/setPassword/resetPassword/get/update/orders/order/requestReturn/requestInvoice/addresses.{list,create,update,delete}`,
504
+ `customer.requestOtp/createSession/capabilities/register/verifyRegistration/loginWithPassword/setPassword/resetPassword/get/update/orders/order/requestReturn/requestInvoice/pendingPayments/invoiceFile/addresses.{list,create,update,delete}`,
479
505
  `content.theme/page/menu/articles/article`. Every method takes a last
480
506
  `options` argument: `{ cache, signal, next, headers, timeoutMs, customerToken, clientIp }`
481
507
  (plus `idempotencyKey` on writes and `preview` on pages/articles); unknown keys