@asteby/storefront 0.13.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 +27 -1
- package/dist/chunk-IPUAZ3LQ.js +646 -0
- package/dist/chunk-IPUAZ3LQ.js.map +1 -0
- package/dist/cli.js +40 -1
- package/dist/fiscal-document.d.cts +2 -2
- package/dist/fiscal-document.d.ts +2 -2
- package/dist/index.cjs +196 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -3
- package/dist/index.d.ts +67 -3
- package/dist/index.js +73 -316
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +417 -39
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +3 -1
- package/dist/mock.d.ts +3 -1
- package/dist/mock.js +272 -23
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/{types-C_rsJRCl.d.ts → types-BeTemDg6.d.ts} +209 -1
- package/dist/{types-BQ3S6VjF.d.cts → types-BuKb-zbi.d.cts} +209 -1
- package/package.json +1 -1
- package/dist/chunk-HBSB7XS2.js +0 -220
- package/dist/chunk-HBSB7XS2.js.map +0 -1
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
|