@asteby/storefront 0.23.0 → 0.25.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
@@ -432,6 +432,24 @@ await sf.products.list({ tags_any: fitTagsAny(item.fit_key) }) // ?tags_a
432
432
  - `products.list({ tags_any })`: at most 5 tags of 120 characters, comma-separated on the wire (a tag with a comma is refused by the client); a hard filter, so facets count inside it.
433
433
  - Mock: `createMockStorefront({ subjectKinds: MOCK_SUBJECT_KINDS })` serves the kinds and the whole CRUD with the same rules (default: none, like a store that declares nothing).
434
434
 
435
+ ## Long histories: cursor-paged account lists (Storefront API 1.19)
436
+
437
+ `customer.orders.list`, `customer.invoices.list` and `customer.shipments.list` page by **cursor** (a keyset on the
438
+ order's date and id, stable while new orders arrive), `first` (10 by default; a page has at most 50), `after` for older, `before` for
439
+ newer. Orders also take `status`, `delivery_method`, `has_invoice`, `from`, `to` and `q` (an exact order number); a
440
+ derived filter may answer a short page with `has_next_page: true` (keep following `end_cursor`). `total_count` is there
441
+ when it is cheap. Invoices and shipments come as one node per order (`{ order, invoices }`, `{ order, stage, service,
442
+ shipments }`): no lines, payments, events or map, and no per-order detail call.
443
+
444
+ ```ts
445
+ import { listApiParams, nextPageQuery, readListQuery, listHref } from '@asteby/storefront'
446
+
447
+ const query = readListQuery(new URL(request.url).searchParams) // ?despues=…&estado=…: validated, never throws
448
+ const page = await me.customer.orders.list(listApiParams(query, 10))
449
+ const next = nextPageQuery({ query, pageInfo: page.page_info, count: page.nodes.length, first: 10 })
450
+ next && listHref('/cuenta/pedidos', next) // a real link: shareable, back/forward, no JavaScript
451
+ ```
452
+
435
453
  ## Buyer account: orders, shipments, invoices (Storefront API 1.8)
436
454
 
437
455
  `customer.order(id)` carries `progress` (unified timeline), `next_action`, `shipments[]` (events, carrier, `https`
@@ -24,6 +24,10 @@ type SEO = {
24
24
  type PageInfo = {
25
25
  has_next_page: boolean;
26
26
  end_cursor: string | null;
27
+ /** Contract 1.19, account lists: there is a page before this one (use `before` with `start_cursor`). */
28
+ has_previous_page?: boolean;
29
+ /** Contract 1.19, account lists: the cursor of the first node, for `before`. */
30
+ start_cursor?: string | null;
27
31
  };
28
32
  type Connection<T> = {
29
33
  nodes: T[];
@@ -1273,6 +1277,23 @@ type InvoiceSummary = {
1273
1277
  * after the XML: a missing kind is "still being prepared", not an error. Absent/null = the server does not say.
1274
1278
  */
1275
1279
  available_files?: ('pdf' | 'xml')[] | null;
1280
+ /**
1281
+ * Plain-words reason the invoice could not be issued, ready to show (contract 1.18): "No pudimos emitir tu factura: el nombre o
1282
+ * razón social no coincide con el SAT. Revisa tus datos y vuelve a intentarlo." Never the provider's text.
1283
+ */
1284
+ reason_message?: string | null;
1285
+ /** Form field the authority refused (`tax_id`, `legal_name`, `tax_regime`, `postal_code`, `invoice_use`), to mark it. */
1286
+ reason_field?: 'tax_id' | 'legal_name' | 'tax_regime' | 'postal_code' | 'invoice_use' | (string & {}) | null;
1287
+ /** The data the buyer sent in the refused attempt, to prefill the form for the correction. */
1288
+ submitted?: {
1289
+ tax_id?: string;
1290
+ legal_name?: string;
1291
+ tax_regime?: string;
1292
+ postal_code?: string;
1293
+ invoice_use?: string;
1294
+ } | null;
1295
+ /** Attempts left today for this order (0: `needs_review` until tomorrow). */
1296
+ retries_left?: number | null;
1276
1297
  };
1277
1298
  /** The invoice request of a cart (`Cart.invoice`). The tax id is masked: the full value is never echoed back. */
1278
1299
  type CartInvoice = {
@@ -1671,6 +1692,26 @@ type IdentityRulesV1 = {
1671
1692
  qr_canonical?: string;
1672
1693
  fields: IdentityFieldRule[];
1673
1694
  };
1695
+ /** The order a listed invoice or shipment belongs to. */
1696
+ type OrderRef = {
1697
+ id: string;
1698
+ number: string;
1699
+ created_at: string;
1700
+ };
1701
+ /** One order with its invoices and credit notes (the same `InvoiceDoc` as the order detail, nothing else). */
1702
+ type InvoiceListNode = {
1703
+ order: OrderRef;
1704
+ invoices: InvoiceDoc[];
1705
+ };
1706
+ /** One delivered order with the service the buyer chose and its parcels (no tracking events, no map: those are in the detail). */
1707
+ type ShipmentListNode = {
1708
+ order: OrderRef;
1709
+ stage: string;
1710
+ service: OrderShippingService | null;
1711
+ shipments: Shipment[];
1712
+ };
1713
+ type InvoiceConnection = Connection<InvoiceListNode>;
1714
+ type ShipmentConnection = Connection<ShipmentListNode>;
1674
1715
 
1675
1716
  type StorefrontErrorInit = {
1676
1717
  status: number;
@@ -1799,4 +1840,4 @@ declare function dataExportBytes(file: Pick<DataExportFile, 'content_base64'>):
1799
1840
  /** A download filename that is safe in a `Content-Disposition` header: no path, quotes, control characters or spaces. */
1800
1841
  declare function safeExportFilename(name: unknown, fallback?: string): string;
1801
1842
 
1802
- export { type Facet as $, type AccountDeleteInput as A, type Collection as B, type Cart as C, type Connection as D, type Customer as E, type CustomerCapabilities as F, type CustomerEmailChangeConfirmInput as G, type CustomerEmailChangeInput as H, type CustomerEmailChangeRequested as I, type CustomerEmailCodeInput as J, type CustomerIdentifier as K, type CustomerPasswordLoginInput as L, type CustomerPreferences as M, type CustomerRegisterInput as N, type CustomerRegisterResult as O, type CustomerResetPasswordInput as P, type CustomerSession as Q, type CustomerSessionInfo as R, type CustomerSessionInput as S, type CustomerSetPasswordInput as T, type CustomerUpdateInput as U, type CustomerVerifyRegistrationInput as V, type DataExportFile as W, type DeclineCode as X, type DeliveryInput as Y, type DeliveryMethod as Z, type DeliveryOptions as _, type Address as a, type PaymentOption as a$, type FacetValue as a0, type FiscalDocumentEvidence as a1, type FiscalDocumentSource as a2, type FiscalIdentity as a3, type FiscalIdentityInput as a4, type FiscalProfile as a5, type FiscalProfileInput as a6, type FiscalVerification as a7, type GeoHint as a8, type IdentityCapture as a9, type NearestLocation as aA, type NextAction as aB, type NextActionKind as aC, type Order as aD, type OrderLine as aE, type OrderPickup as aF, type OrderProblem as aG, type OrderProgress as aH, type OrderProgressStep as aI, type OrderSection as aJ, type OrderShippingService as aK, type OrderStage as aL, type OrderStepKey as aM, type OrderStepState as aN, type Page as aO, type PageInfo as aP, type PaymentAction as aQ, type PaymentAttemptResult as aR, type PaymentAttemptStatus as aS, type PaymentClient as aT, type PaymentClientCsp as aU, type PaymentConfig as aV, type PaymentFlow as aW, type PaymentInfo as aX, type PaymentMethod as aY, type PaymentMethods as aZ, type PaymentNextStep as a_, type IdentityDocumentSpec as aa, type IdentityFieldRule as ab, type IdentityRulesV1 as ac, type IdentityStrategy as ad, type Image as ae, type InsufficientStockDetails as af, type InsufficientStockLine as ag, type InvoiceAction as ah, type InvoiceDoc as ai, type InvoiceFile as aj, type InvoiceFileKind as ak, type InvoiceReceiver as al, type InvoiceRequest as am, type InvoiceResult as an, type InvoiceStage as ao, type InvoiceSummary as ap, type InvoicingCapabilities as aq, type Location as ar, type LocationContacts as as, type LocationKind as at, type LocationListParams as au, type LocationPickup as av, type Menu as aw, type MenuItem as ax, type Money as ay, type MoneyRange as az, type AddressInput as b, isAccountDeleteBlocked as b$, type PaymentOptionKey as b0, type PaymentPoint as b1, type PaymentSubmitInput as b2, type PaymentVoucher as b3, type PendingPayment as b4, type PendingPaymentVoucher as b5, type PickupOption as b6, type Product as b7, type ProductAttributeValue as b8, type ProductCategory as b9, type ShipmentKind as bA, type ShipmentMap as bB, type ShipmentStatus as bC, type ShipmentsSummary as bD, type ShippingRate as bE, type Shop as bF, type ShopBranch as bG, type ShopContact as bH, type ShopPolicies as bI, type StockLevel as bJ, StorefrontError as bK, type StorefrontErrorBody as bL, type StorefrontErrorCode as bM, type StorefrontErrorInit as bN, type Subject as bO, type SubjectCatalog as bP, type SubjectCatalogNode as bQ, type SubjectField as bR, type SubjectFieldType as bS, type SubjectInput as bT, type SubjectKind as bU, type SubjectPatch as bV, type SubjectRef as bW, type Theme as bX, type TokenIntrospection as bY, type UnavailableRateProvider as bZ, dataExportBytes as b_, type ProductConnection as ba, type ProductOption as bb, type ProductSort as bc, type ProductVariant as bd, type PromotionAnnouncement as be, type PromotionReward as bf, type PromotionTier as bg, type PromotionsList as bh, type ReauthInput as bi, type ReauthResult as bj, type RecommendationPlacement as bk, type Refund as bl, type Region as bm, type RegionFiscalEntry as bn, type RegionFiscalId as bo, type RegionPaymentMethod as bp, type RegionPostalCode as bq, type RestockSubscriptionInput as br, type RestockSubscriptionResult as bs, type ReturnRequest as bt, type ReturnRequestInput as bu, type SEO as bv, type Section as bw, type SelectedOption as bx, type Shipment as by, type ShipmentEvent as bz, type AddressSuggestion as c, isReauthRequired as c0, isStorefrontError as c1, safeExportFilename as c2, type AddressSuggestions as d, type Article as e, type Availability as f, type AvailabilityStatus as g, type CartBuyer as h, type CartBuyerInput as i, type CartCost as j, type CartDelivery as k, type CartDiscountCode as l, type CartDiscountLine as m, type CartInvoice as n, type CartLine as o, type CartLineInput as p, type CartLineMerchandise as q, type CartLineProblem as r, type CartLineUpdateInput as s, type CartPromotions as t, type CartRecommendation as u, type CartRecommendations as v, type CheckoutInfo as w, type CheckoutInput as x, type CheckoutPayment as y, type CheckoutResult as z };
1843
+ export { type Facet as $, type AccountDeleteInput as A, type Collection as B, type Cart as C, type Connection as D, type Customer as E, type CustomerCapabilities as F, type CustomerEmailChangeConfirmInput as G, type CustomerEmailChangeInput as H, type CustomerEmailChangeRequested as I, type CustomerEmailCodeInput as J, type CustomerIdentifier as K, type CustomerPasswordLoginInput as L, type CustomerPreferences as M, type CustomerRegisterInput as N, type CustomerRegisterResult as O, type CustomerResetPasswordInput as P, type CustomerSession as Q, type CustomerSessionInfo as R, type CustomerSessionInput as S, type CustomerSetPasswordInput as T, type CustomerUpdateInput as U, type CustomerVerifyRegistrationInput as V, type DataExportFile as W, type DeclineCode as X, type DeliveryInput as Y, type DeliveryMethod as Z, type DeliveryOptions as _, type Address as a, type PaymentMethod as a$, type FacetValue as a0, type FiscalDocumentEvidence as a1, type FiscalDocumentSource as a2, type FiscalIdentity as a3, type FiscalIdentityInput as a4, type FiscalProfile as a5, type FiscalProfileInput as a6, type FiscalVerification as a7, type GeoHint as a8, type IdentityCapture as a9, type Money as aA, type MoneyRange as aB, type NearestLocation as aC, type NextAction as aD, type NextActionKind as aE, type Order as aF, type OrderLine as aG, type OrderPickup as aH, type OrderProblem as aI, type OrderProgress as aJ, type OrderProgressStep as aK, type OrderRef as aL, type OrderSection as aM, type OrderShippingService as aN, type OrderStage as aO, type OrderStepKey as aP, type OrderStepState as aQ, type Page as aR, type PageInfo as aS, type PaymentAction as aT, type PaymentAttemptResult as aU, type PaymentAttemptStatus as aV, type PaymentClient as aW, type PaymentClientCsp as aX, type PaymentConfig as aY, type PaymentFlow as aZ, type PaymentInfo as a_, type IdentityDocumentSpec as aa, type IdentityFieldRule as ab, type IdentityRulesV1 as ac, type IdentityStrategy as ad, type Image as ae, type InsufficientStockDetails as af, type InsufficientStockLine as ag, type InvoiceAction as ah, type InvoiceConnection as ai, type InvoiceDoc as aj, type InvoiceFile as ak, type InvoiceFileKind as al, type InvoiceListNode as am, type InvoiceReceiver as an, type InvoiceRequest as ao, type InvoiceResult as ap, type InvoiceStage as aq, type InvoiceSummary as ar, type InvoicingCapabilities as as, type Location as at, type LocationContacts as au, type LocationKind as av, type LocationListParams as aw, type LocationPickup as ax, type Menu as ay, type MenuItem as az, type AddressInput as b, type SubjectRef as b$, type PaymentMethods as b0, type PaymentNextStep as b1, type PaymentOption as b2, type PaymentOptionKey as b3, type PaymentPoint as b4, type PaymentSubmitInput as b5, type PaymentVoucher as b6, type PendingPayment as b7, type PendingPaymentVoucher as b8, type PickupOption as b9, type SelectedOption as bA, type Shipment as bB, type ShipmentConnection as bC, type ShipmentEvent as bD, type ShipmentKind as bE, type ShipmentListNode as bF, type ShipmentMap as bG, type ShipmentStatus as bH, type ShipmentsSummary as bI, type ShippingRate as bJ, type Shop as bK, type ShopBranch as bL, type ShopContact as bM, type ShopPolicies as bN, type StockLevel as bO, StorefrontError as bP, type StorefrontErrorBody as bQ, type StorefrontErrorCode as bR, type StorefrontErrorInit as bS, type Subject as bT, type SubjectCatalog as bU, type SubjectCatalogNode as bV, type SubjectField as bW, type SubjectFieldType as bX, type SubjectInput as bY, type SubjectKind as bZ, type SubjectPatch as b_, type Product as ba, type ProductAttributeValue as bb, type ProductCategory as bc, type ProductConnection as bd, type ProductOption as be, type ProductSort as bf, type ProductVariant as bg, type PromotionAnnouncement as bh, type PromotionReward as bi, type PromotionTier as bj, type PromotionsList as bk, type ReauthInput as bl, type ReauthResult as bm, type RecommendationPlacement as bn, type Refund as bo, type Region as bp, type RegionFiscalEntry as bq, type RegionFiscalId as br, type RegionPaymentMethod as bs, type RegionPostalCode as bt, type RestockSubscriptionInput as bu, type RestockSubscriptionResult as bv, type ReturnRequest as bw, type ReturnRequestInput as bx, type SEO as by, type Section as bz, type AddressSuggestion as c, type Theme as c0, type TokenIntrospection as c1, type UnavailableRateProvider as c2, dataExportBytes as c3, isAccountDeleteBlocked as c4, isReauthRequired as c5, isStorefrontError as c6, safeExportFilename as c7, type AddressSuggestions as d, type Article as e, type Availability as f, type AvailabilityStatus as g, type CartBuyer as h, type CartBuyerInput as i, type CartCost as j, type CartDelivery as k, type CartDiscountCode as l, type CartDiscountLine as m, type CartInvoice as n, type CartLine as o, type CartLineInput as p, type CartLineMerchandise as q, type CartLineProblem as r, type CartLineUpdateInput as s, type CartPromotions as t, type CartRecommendation as u, type CartRecommendations as v, type CheckoutInfo as w, type CheckoutInput as x, type CheckoutPayment as y, type CheckoutResult as z };
@@ -24,6 +24,10 @@ type SEO = {
24
24
  type PageInfo = {
25
25
  has_next_page: boolean;
26
26
  end_cursor: string | null;
27
+ /** Contract 1.19, account lists: there is a page before this one (use `before` with `start_cursor`). */
28
+ has_previous_page?: boolean;
29
+ /** Contract 1.19, account lists: the cursor of the first node, for `before`. */
30
+ start_cursor?: string | null;
27
31
  };
28
32
  type Connection<T> = {
29
33
  nodes: T[];
@@ -1273,6 +1277,23 @@ type InvoiceSummary = {
1273
1277
  * after the XML: a missing kind is "still being prepared", not an error. Absent/null = the server does not say.
1274
1278
  */
1275
1279
  available_files?: ('pdf' | 'xml')[] | null;
1280
+ /**
1281
+ * Plain-words reason the invoice could not be issued, ready to show (contract 1.18): "No pudimos emitir tu factura: el nombre o
1282
+ * razón social no coincide con el SAT. Revisa tus datos y vuelve a intentarlo." Never the provider's text.
1283
+ */
1284
+ reason_message?: string | null;
1285
+ /** Form field the authority refused (`tax_id`, `legal_name`, `tax_regime`, `postal_code`, `invoice_use`), to mark it. */
1286
+ reason_field?: 'tax_id' | 'legal_name' | 'tax_regime' | 'postal_code' | 'invoice_use' | (string & {}) | null;
1287
+ /** The data the buyer sent in the refused attempt, to prefill the form for the correction. */
1288
+ submitted?: {
1289
+ tax_id?: string;
1290
+ legal_name?: string;
1291
+ tax_regime?: string;
1292
+ postal_code?: string;
1293
+ invoice_use?: string;
1294
+ } | null;
1295
+ /** Attempts left today for this order (0: `needs_review` until tomorrow). */
1296
+ retries_left?: number | null;
1276
1297
  };
1277
1298
  /** The invoice request of a cart (`Cart.invoice`). The tax id is masked: the full value is never echoed back. */
1278
1299
  type CartInvoice = {
@@ -1671,6 +1692,26 @@ type IdentityRulesV1 = {
1671
1692
  qr_canonical?: string;
1672
1693
  fields: IdentityFieldRule[];
1673
1694
  };
1695
+ /** The order a listed invoice or shipment belongs to. */
1696
+ type OrderRef = {
1697
+ id: string;
1698
+ number: string;
1699
+ created_at: string;
1700
+ };
1701
+ /** One order with its invoices and credit notes (the same `InvoiceDoc` as the order detail, nothing else). */
1702
+ type InvoiceListNode = {
1703
+ order: OrderRef;
1704
+ invoices: InvoiceDoc[];
1705
+ };
1706
+ /** One delivered order with the service the buyer chose and its parcels (no tracking events, no map: those are in the detail). */
1707
+ type ShipmentListNode = {
1708
+ order: OrderRef;
1709
+ stage: string;
1710
+ service: OrderShippingService | null;
1711
+ shipments: Shipment[];
1712
+ };
1713
+ type InvoiceConnection = Connection<InvoiceListNode>;
1714
+ type ShipmentConnection = Connection<ShipmentListNode>;
1674
1715
 
1675
1716
  type StorefrontErrorInit = {
1676
1717
  status: number;
@@ -1799,4 +1840,4 @@ declare function dataExportBytes(file: Pick<DataExportFile, 'content_base64'>):
1799
1840
  /** A download filename that is safe in a `Content-Disposition` header: no path, quotes, control characters or spaces. */
1800
1841
  declare function safeExportFilename(name: unknown, fallback?: string): string;
1801
1842
 
1802
- export { type Facet as $, type AccountDeleteInput as A, type Collection as B, type Cart as C, type Connection as D, type Customer as E, type CustomerCapabilities as F, type CustomerEmailChangeConfirmInput as G, type CustomerEmailChangeInput as H, type CustomerEmailChangeRequested as I, type CustomerEmailCodeInput as J, type CustomerIdentifier as K, type CustomerPasswordLoginInput as L, type CustomerPreferences as M, type CustomerRegisterInput as N, type CustomerRegisterResult as O, type CustomerResetPasswordInput as P, type CustomerSession as Q, type CustomerSessionInfo as R, type CustomerSessionInput as S, type CustomerSetPasswordInput as T, type CustomerUpdateInput as U, type CustomerVerifyRegistrationInput as V, type DataExportFile as W, type DeclineCode as X, type DeliveryInput as Y, type DeliveryMethod as Z, type DeliveryOptions as _, type Address as a, type PaymentOption as a$, type FacetValue as a0, type FiscalDocumentEvidence as a1, type FiscalDocumentSource as a2, type FiscalIdentity as a3, type FiscalIdentityInput as a4, type FiscalProfile as a5, type FiscalProfileInput as a6, type FiscalVerification as a7, type GeoHint as a8, type IdentityCapture as a9, type NearestLocation as aA, type NextAction as aB, type NextActionKind as aC, type Order as aD, type OrderLine as aE, type OrderPickup as aF, type OrderProblem as aG, type OrderProgress as aH, type OrderProgressStep as aI, type OrderSection as aJ, type OrderShippingService as aK, type OrderStage as aL, type OrderStepKey as aM, type OrderStepState as aN, type Page as aO, type PageInfo as aP, type PaymentAction as aQ, type PaymentAttemptResult as aR, type PaymentAttemptStatus as aS, type PaymentClient as aT, type PaymentClientCsp as aU, type PaymentConfig as aV, type PaymentFlow as aW, type PaymentInfo as aX, type PaymentMethod as aY, type PaymentMethods as aZ, type PaymentNextStep as a_, type IdentityDocumentSpec as aa, type IdentityFieldRule as ab, type IdentityRulesV1 as ac, type IdentityStrategy as ad, type Image as ae, type InsufficientStockDetails as af, type InsufficientStockLine as ag, type InvoiceAction as ah, type InvoiceDoc as ai, type InvoiceFile as aj, type InvoiceFileKind as ak, type InvoiceReceiver as al, type InvoiceRequest as am, type InvoiceResult as an, type InvoiceStage as ao, type InvoiceSummary as ap, type InvoicingCapabilities as aq, type Location as ar, type LocationContacts as as, type LocationKind as at, type LocationListParams as au, type LocationPickup as av, type Menu as aw, type MenuItem as ax, type Money as ay, type MoneyRange as az, type AddressInput as b, isAccountDeleteBlocked as b$, type PaymentOptionKey as b0, type PaymentPoint as b1, type PaymentSubmitInput as b2, type PaymentVoucher as b3, type PendingPayment as b4, type PendingPaymentVoucher as b5, type PickupOption as b6, type Product as b7, type ProductAttributeValue as b8, type ProductCategory as b9, type ShipmentKind as bA, type ShipmentMap as bB, type ShipmentStatus as bC, type ShipmentsSummary as bD, type ShippingRate as bE, type Shop as bF, type ShopBranch as bG, type ShopContact as bH, type ShopPolicies as bI, type StockLevel as bJ, StorefrontError as bK, type StorefrontErrorBody as bL, type StorefrontErrorCode as bM, type StorefrontErrorInit as bN, type Subject as bO, type SubjectCatalog as bP, type SubjectCatalogNode as bQ, type SubjectField as bR, type SubjectFieldType as bS, type SubjectInput as bT, type SubjectKind as bU, type SubjectPatch as bV, type SubjectRef as bW, type Theme as bX, type TokenIntrospection as bY, type UnavailableRateProvider as bZ, dataExportBytes as b_, type ProductConnection as ba, type ProductOption as bb, type ProductSort as bc, type ProductVariant as bd, type PromotionAnnouncement as be, type PromotionReward as bf, type PromotionTier as bg, type PromotionsList as bh, type ReauthInput as bi, type ReauthResult as bj, type RecommendationPlacement as bk, type Refund as bl, type Region as bm, type RegionFiscalEntry as bn, type RegionFiscalId as bo, type RegionPaymentMethod as bp, type RegionPostalCode as bq, type RestockSubscriptionInput as br, type RestockSubscriptionResult as bs, type ReturnRequest as bt, type ReturnRequestInput as bu, type SEO as bv, type Section as bw, type SelectedOption as bx, type Shipment as by, type ShipmentEvent as bz, type AddressSuggestion as c, isReauthRequired as c0, isStorefrontError as c1, safeExportFilename as c2, type AddressSuggestions as d, type Article as e, type Availability as f, type AvailabilityStatus as g, type CartBuyer as h, type CartBuyerInput as i, type CartCost as j, type CartDelivery as k, type CartDiscountCode as l, type CartDiscountLine as m, type CartInvoice as n, type CartLine as o, type CartLineInput as p, type CartLineMerchandise as q, type CartLineProblem as r, type CartLineUpdateInput as s, type CartPromotions as t, type CartRecommendation as u, type CartRecommendations as v, type CheckoutInfo as w, type CheckoutInput as x, type CheckoutPayment as y, type CheckoutResult as z };
1843
+ export { type Facet as $, type AccountDeleteInput as A, type Collection as B, type Cart as C, type Connection as D, type Customer as E, type CustomerCapabilities as F, type CustomerEmailChangeConfirmInput as G, type CustomerEmailChangeInput as H, type CustomerEmailChangeRequested as I, type CustomerEmailCodeInput as J, type CustomerIdentifier as K, type CustomerPasswordLoginInput as L, type CustomerPreferences as M, type CustomerRegisterInput as N, type CustomerRegisterResult as O, type CustomerResetPasswordInput as P, type CustomerSession as Q, type CustomerSessionInfo as R, type CustomerSessionInput as S, type CustomerSetPasswordInput as T, type CustomerUpdateInput as U, type CustomerVerifyRegistrationInput as V, type DataExportFile as W, type DeclineCode as X, type DeliveryInput as Y, type DeliveryMethod as Z, type DeliveryOptions as _, type Address as a, type PaymentMethod as a$, type FacetValue as a0, type FiscalDocumentEvidence as a1, type FiscalDocumentSource as a2, type FiscalIdentity as a3, type FiscalIdentityInput as a4, type FiscalProfile as a5, type FiscalProfileInput as a6, type FiscalVerification as a7, type GeoHint as a8, type IdentityCapture as a9, type Money as aA, type MoneyRange as aB, type NearestLocation as aC, type NextAction as aD, type NextActionKind as aE, type Order as aF, type OrderLine as aG, type OrderPickup as aH, type OrderProblem as aI, type OrderProgress as aJ, type OrderProgressStep as aK, type OrderRef as aL, type OrderSection as aM, type OrderShippingService as aN, type OrderStage as aO, type OrderStepKey as aP, type OrderStepState as aQ, type Page as aR, type PageInfo as aS, type PaymentAction as aT, type PaymentAttemptResult as aU, type PaymentAttemptStatus as aV, type PaymentClient as aW, type PaymentClientCsp as aX, type PaymentConfig as aY, type PaymentFlow as aZ, type PaymentInfo as a_, type IdentityDocumentSpec as aa, type IdentityFieldRule as ab, type IdentityRulesV1 as ac, type IdentityStrategy as ad, type Image as ae, type InsufficientStockDetails as af, type InsufficientStockLine as ag, type InvoiceAction as ah, type InvoiceConnection as ai, type InvoiceDoc as aj, type InvoiceFile as ak, type InvoiceFileKind as al, type InvoiceListNode as am, type InvoiceReceiver as an, type InvoiceRequest as ao, type InvoiceResult as ap, type InvoiceStage as aq, type InvoiceSummary as ar, type InvoicingCapabilities as as, type Location as at, type LocationContacts as au, type LocationKind as av, type LocationListParams as aw, type LocationPickup as ax, type Menu as ay, type MenuItem as az, type AddressInput as b, type SubjectRef as b$, type PaymentMethods as b0, type PaymentNextStep as b1, type PaymentOption as b2, type PaymentOptionKey as b3, type PaymentPoint as b4, type PaymentSubmitInput as b5, type PaymentVoucher as b6, type PendingPayment as b7, type PendingPaymentVoucher as b8, type PickupOption as b9, type SelectedOption as bA, type Shipment as bB, type ShipmentConnection as bC, type ShipmentEvent as bD, type ShipmentKind as bE, type ShipmentListNode as bF, type ShipmentMap as bG, type ShipmentStatus as bH, type ShipmentsSummary as bI, type ShippingRate as bJ, type Shop as bK, type ShopBranch as bL, type ShopContact as bM, type ShopPolicies as bN, type StockLevel as bO, StorefrontError as bP, type StorefrontErrorBody as bQ, type StorefrontErrorCode as bR, type StorefrontErrorInit as bS, type Subject as bT, type SubjectCatalog as bU, type SubjectCatalogNode as bV, type SubjectField as bW, type SubjectFieldType as bX, type SubjectInput as bY, type SubjectKind as bZ, type SubjectPatch as b_, type Product as ba, type ProductAttributeValue as bb, type ProductCategory as bc, type ProductConnection as bd, type ProductOption as be, type ProductSort as bf, type ProductVariant as bg, type PromotionAnnouncement as bh, type PromotionReward as bi, type PromotionTier as bj, type PromotionsList as bk, type ReauthInput as bl, type ReauthResult as bm, type RecommendationPlacement as bn, type Refund as bo, type Region as bp, type RegionFiscalEntry as bq, type RegionFiscalId as br, type RegionPaymentMethod as bs, type RegionPostalCode as bt, type RestockSubscriptionInput as bu, type RestockSubscriptionResult as bv, type ReturnRequest as bw, type ReturnRequestInput as bx, type SEO as by, type Section as bz, type AddressSuggestion as c, type Theme as c0, type TokenIntrospection as c1, type UnavailableRateProvider as c2, dataExportBytes as c3, isAccountDeleteBlocked as c4, isReauthRequired as c5, isStorefrontError as c6, safeExportFilename as c7, type AddressSuggestions as d, type Article as e, type Availability as f, type AvailabilityStatus as g, type CartBuyer as h, type CartBuyerInput as i, type CartCost as j, type CartDelivery as k, type CartDiscountCode as l, type CartDiscountLine as m, type CartInvoice as n, type CartLine as o, type CartLineInput as p, type CartLineMerchandise as q, type CartLineProblem as r, type CartLineUpdateInput as s, type CartPromotions as t, type CartRecommendation as u, type CartRecommendations as v, type CheckoutInfo as w, type CheckoutInput as x, type CheckoutPayment as y, type CheckoutResult as z };
package/dist/cli.js CHANGED
@@ -89,6 +89,15 @@ function isTokenPublishable(token) {
89
89
  }
90
90
 
91
91
  // src/query.ts
92
+ function accountListQuery(params) {
93
+ if (!params) return void 0;
94
+ const out = {};
95
+ for (const [key, value] of Object.entries(params)) {
96
+ if (value === void 0 || value === null || value === "") continue;
97
+ out[key] = value;
98
+ }
99
+ return out;
100
+ }
92
101
  function appendParams(search, params) {
93
102
  if (!params) return search;
94
103
  for (const [key, raw] of Object.entries(params)) {
@@ -537,7 +546,50 @@ function createStorefrontClient(config) {
537
546
  * repeat after success is also fine. Afterwards the token is dead: drop it.
538
547
  */
539
548
  deleteAccount: (input, options) => write("DELETE", "/storefront/customer", input, options),
540
- orders: (params, options) => get("/storefront/customer/orders", params, options),
549
+ /**
550
+ * The buyer's orders, newest first. Callable as before (`orders({ first })`) and, since contract 1.19, with
551
+ * `orders.list({ first, after, before, status, delivery_method, has_invoice, from, to, q })`: cursor paging
552
+ * (keyset, stable while new orders arrive), `page_info.start_cursor` / `has_previous_page` to go back, and
553
+ * `total_count` when it is cheap to know. An OPS older than 1.19 ignores the new parameters.
554
+ */
555
+ orders: Object.assign(
556
+ (params, options) => get("/storefront/customer/orders", params, options),
557
+ {
558
+ list: (params, options) => get("/storefront/customer/orders", accountListQuery(params), { ...options, cache: "no-store" })
559
+ }
560
+ ),
561
+ /**
562
+ * The buyer's invoices, one node per order that has them (`{ order, invoices }`), cursor-paged like `orders.list`.
563
+ * It replaces opening the detail of every order. An OPS older than 1.19 (no such route) is served from one page of
564
+ * orders and their details, so the account keeps working until the addon is updated.
565
+ */
566
+ invoices: {
567
+ list: async (params, options) => {
568
+ const page = await getOrNull("/storefront/customer/invoices", accountListQuery(params), { ...options, cache: "no-store" });
569
+ return page ?? legacyAccountList(client, params, options, (o) => o.invoice ? !["not_requested", "awaiting_payment", "window_closed"].includes(o.invoice.stage ?? "not_requested") : true, (o) => (o.invoices ?? []).length ? { order: orderRef(o), invoices: o.invoices ?? [] } : null);
570
+ }
571
+ },
572
+ /**
573
+ * The buyer's shipments, one node per delivered order with its service and parcels (`{ order, stage, service,
574
+ * shipments }`), cursor-paged like `orders.list`, without tracking events or map (those come with `order(id)`).
575
+ * An OPS older than 1.19 is served from one page of orders and their details.
576
+ */
577
+ shipments: {
578
+ list: async (params, options) => {
579
+ const page = await getOrNull("/storefront/customer/shipments", accountListQuery(params), { ...options, cache: "no-store" });
580
+ return page ?? legacyAccountList(
581
+ client,
582
+ params,
583
+ options,
584
+ (o) => o.delivery_method !== "pickup" && !["cancelled", "refunded", "pending_payment"].includes(o.status),
585
+ (o) => {
586
+ const service = o.shipping_service ?? null;
587
+ const shipments = o.shipments ?? [];
588
+ return service || shipments.length ? { order: orderRef(o), stage: o.progress?.stage ?? o.status, service, shipments } : null;
589
+ }
590
+ );
591
+ }
592
+ },
541
593
  /** `null` when the order does not exist or belongs to someone else. */
542
594
  order: (id, options) => getOrNull(`/storefront/customer/orders/${enc(id)}`, void 0, options),
543
595
  requestReturn: (orderId, input, options) => write("POST", `/storefront/customer/orders/${enc(orderId)}/returns`, input, options),
@@ -625,6 +677,20 @@ function createStorefrontClient(config) {
625
677
  };
626
678
  return client;
627
679
  }
680
+ var orderRef = (o) => ({ id: o.id, number: o.number, created_at: o.created_at });
681
+ async function legacyAccountList(client, params, options, keep, toNode) {
682
+ const page = await client.customer.orders.list({ ...params?.first ? { first: params.first } : {}, ...params?.after ? { after: params.after } : {}, ...params?.from ? { from: params.from } : {}, ...params?.to ? { to: params.to } : {}, ...params?.q ? { q: params.q } : {} }, options);
683
+ const details = await Promise.all(
684
+ page.nodes.filter(keep).map(
685
+ (o) => client.customer.order(o.id, options).catch((err) => {
686
+ if (err instanceof StorefrontError && err.status === 401) throw err;
687
+ return null;
688
+ })
689
+ )
690
+ );
691
+ const nodes = details.map((d) => d ? toNode(d) : null).filter((n) => n !== null);
692
+ return { nodes, page_info: { has_next_page: page.page_info.has_next_page, end_cursor: page.page_info.end_cursor } };
693
+ }
628
694
  function storefrontDomainHeader(domain, market) {
629
695
  const host = domain.trim();
630
696
  const code = (market ?? "").trim().toLowerCase();
@@ -645,7 +711,7 @@ function repairPath(connectionName) {
645
711
  import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeSync } from "fs";
646
712
  import { dirname, join, resolve } from "path";
647
713
  import { hostname } from "os";
648
- var SDK_VERSION = true ? "0.23.0" : "dev";
714
+ var SDK_VERSION = true ? "0.25.0" : "dev";
649
715
  function writeFileAtomic(file, content, mode = 384) {
650
716
  const dir = dirname(file);
651
717
  mkdirSync(dir, { recursive: true });
@@ -1,5 +1,5 @@
1
- import { a2 as FiscalDocumentSource, bn as RegionFiscalEntry, aa as IdentityDocumentSpec, a1 as FiscalDocumentEvidence, bo as RegionFiscalId, ac as IdentityRulesV1 } from './account-settings-BdKj3jWb.cjs';
2
- export { a9 as IdentityCapture, ab as IdentityFieldRule, ad as IdentityStrategy } from './account-settings-BdKj3jWb.cjs';
1
+ import { a2 as FiscalDocumentSource, bq as RegionFiscalEntry, aa as IdentityDocumentSpec, a1 as FiscalDocumentEvidence, br as RegionFiscalId, ac as IdentityRulesV1 } from './account-settings-DOAM5mTk.cjs';
2
+ export { a9 as IdentityCapture, ab as IdentityFieldRule, ad as IdentityStrategy } from './account-settings-DOAM5mTk.cjs';
3
3
  import './geo.cjs';
4
4
 
5
5
  /** A value read from a document: text, or the codes of a catalog (`multiple` fields). */
@@ -1,5 +1,5 @@
1
- import { a2 as FiscalDocumentSource, bn as RegionFiscalEntry, aa as IdentityDocumentSpec, a1 as FiscalDocumentEvidence, bo as RegionFiscalId, ac as IdentityRulesV1 } from './account-settings-DHg2RUOH.js';
2
- export { a9 as IdentityCapture, ab as IdentityFieldRule, ad as IdentityStrategy } from './account-settings-DHg2RUOH.js';
1
+ import { a2 as FiscalDocumentSource, bq as RegionFiscalEntry, aa as IdentityDocumentSpec, a1 as FiscalDocumentEvidence, br as RegionFiscalId, ac as IdentityRulesV1 } from './account-settings-mTEXvtfz.js';
2
+ export { a9 as IdentityCapture, ab as IdentityFieldRule, ad as IdentityStrategy } from './account-settings-mTEXvtfz.js';
3
3
  import './geo.js';
4
4
 
5
5
  /** A value read from a document: text, or the codes of a catalog (`multiple` fields). */
package/dist/index.cjs CHANGED
@@ -112,6 +112,15 @@ function isTokenPublishable(token) {
112
112
  }
113
113
 
114
114
  // src/query.ts
115
+ function accountListQuery(params) {
116
+ if (!params) return void 0;
117
+ const out = {};
118
+ for (const [key, value] of Object.entries(params)) {
119
+ if (value === void 0 || value === null || value === "") continue;
120
+ out[key] = value;
121
+ }
122
+ return out;
123
+ }
115
124
  function appendParams(search, params) {
116
125
  if (!params) return search;
117
126
  for (const [key, raw] of Object.entries(params)) {
@@ -569,7 +578,50 @@ function createStorefrontClient(config) {
569
578
  * repeat after success is also fine. Afterwards the token is dead: drop it.
570
579
  */
571
580
  deleteAccount: (input, options) => write("DELETE", "/storefront/customer", input, options),
572
- orders: (params, options) => get("/storefront/customer/orders", params, options),
581
+ /**
582
+ * The buyer's orders, newest first. Callable as before (`orders({ first })`) and, since contract 1.19, with
583
+ * `orders.list({ first, after, before, status, delivery_method, has_invoice, from, to, q })`: cursor paging
584
+ * (keyset, stable while new orders arrive), `page_info.start_cursor` / `has_previous_page` to go back, and
585
+ * `total_count` when it is cheap to know. An OPS older than 1.19 ignores the new parameters.
586
+ */
587
+ orders: Object.assign(
588
+ (params, options) => get("/storefront/customer/orders", params, options),
589
+ {
590
+ list: (params, options) => get("/storefront/customer/orders", accountListQuery(params), { ...options, cache: "no-store" })
591
+ }
592
+ ),
593
+ /**
594
+ * The buyer's invoices, one node per order that has them (`{ order, invoices }`), cursor-paged like `orders.list`.
595
+ * It replaces opening the detail of every order. An OPS older than 1.19 (no such route) is served from one page of
596
+ * orders and their details, so the account keeps working until the addon is updated.
597
+ */
598
+ invoices: {
599
+ list: async (params, options) => {
600
+ const page = await getOrNull("/storefront/customer/invoices", accountListQuery(params), { ...options, cache: "no-store" });
601
+ return page ?? legacyAccountList(client, params, options, (o) => o.invoice ? !["not_requested", "awaiting_payment", "window_closed"].includes(o.invoice.stage ?? "not_requested") : true, (o) => (o.invoices ?? []).length ? { order: orderRef(o), invoices: o.invoices ?? [] } : null);
602
+ }
603
+ },
604
+ /**
605
+ * The buyer's shipments, one node per delivered order with its service and parcels (`{ order, stage, service,
606
+ * shipments }`), cursor-paged like `orders.list`, without tracking events or map (those come with `order(id)`).
607
+ * An OPS older than 1.19 is served from one page of orders and their details.
608
+ */
609
+ shipments: {
610
+ list: async (params, options) => {
611
+ const page = await getOrNull("/storefront/customer/shipments", accountListQuery(params), { ...options, cache: "no-store" });
612
+ return page ?? legacyAccountList(
613
+ client,
614
+ params,
615
+ options,
616
+ (o) => o.delivery_method !== "pickup" && !["cancelled", "refunded", "pending_payment"].includes(o.status),
617
+ (o) => {
618
+ const service = o.shipping_service ?? null;
619
+ const shipments = o.shipments ?? [];
620
+ return service || shipments.length ? { order: orderRef(o), stage: o.progress?.stage ?? o.status, service, shipments } : null;
621
+ }
622
+ );
623
+ }
624
+ },
573
625
  /** `null` when the order does not exist or belongs to someone else. */
574
626
  order: (id, options) => getOrNull(`/storefront/customer/orders/${enc(id)}`, void 0, options),
575
627
  requestReturn: (orderId, input, options) => write("POST", `/storefront/customer/orders/${enc(orderId)}/returns`, input, options),
@@ -657,6 +709,20 @@ function createStorefrontClient(config) {
657
709
  };
658
710
  return client;
659
711
  }
712
+ var orderRef = (o) => ({ id: o.id, number: o.number, created_at: o.created_at });
713
+ async function legacyAccountList(client, params, options, keep, toNode) {
714
+ const page = await client.customer.orders.list({ ...params?.first ? { first: params.first } : {}, ...params?.after ? { after: params.after } : {}, ...params?.from ? { from: params.from } : {}, ...params?.to ? { to: params.to } : {}, ...params?.q ? { q: params.q } : {} }, options);
715
+ const details = await Promise.all(
716
+ page.nodes.filter(keep).map(
717
+ (o) => client.customer.order(o.id, options).catch((err) => {
718
+ if (err instanceof StorefrontError && err.status === 401) throw err;
719
+ return null;
720
+ })
721
+ )
722
+ );
723
+ const nodes = details.map((d) => d ? toNode(d) : null).filter((n) => n !== null);
724
+ return { nodes, page_info: { has_next_page: page.page_info.has_next_page, end_cursor: page.page_info.end_cursor } };
725
+ }
660
726
  function storefrontDomainHeader(domain, market) {
661
727
  const host = domain.trim();
662
728
  const code = (market ?? "").trim().toLowerCase();
@@ -1821,9 +1887,136 @@ function deliveryNotices(delivery) {
1821
1887
  };
1822
1888
  }
1823
1889
 
1890
+ // src/account-lists.ts
1891
+ var LIST_URL_ES = {
1892
+ after: "despues",
1893
+ before: "antes",
1894
+ pos: "pos",
1895
+ status: "estado",
1896
+ delivery: "entrega",
1897
+ invoice: "factura",
1898
+ from: "desde",
1899
+ to: "hasta",
1900
+ q: "q",
1901
+ deliveryValues: { shipping: "envio", pickup: "recoger" },
1902
+ invoiceValues: { yes: "si", no: "no" }
1903
+ };
1904
+ var LIST_URL_EN = {
1905
+ after: "after",
1906
+ before: "before",
1907
+ pos: "pos",
1908
+ status: "status",
1909
+ delivery: "delivery",
1910
+ invoice: "invoice",
1911
+ from: "from",
1912
+ to: "to",
1913
+ q: "q",
1914
+ deliveryValues: { shipping: "shipping", pickup: "pickup" },
1915
+ invoiceValues: { yes: "yes", no: "no" }
1916
+ };
1917
+ var CURSOR = /^[A-Za-z0-9_-]{1,300}$/;
1918
+ var DAY = /^\d{4}-\d{2}-\d{2}$/;
1919
+ var STATUS = /^[a-z_]{1,32}$/;
1920
+ var MAX_Q = 64;
1921
+ var MAX_POS = 1e6;
1922
+ var asParams = (search) => search instanceof URLSearchParams ? search : new URLSearchParams(typeof search === "string" ? search : "");
1923
+ var validDay = (v) => {
1924
+ if (!v || !DAY.test(v)) return void 0;
1925
+ const d = /* @__PURE__ */ new Date(`${v}T00:00:00Z`);
1926
+ return Number.isNaN(d.getTime()) || d.toISOString().slice(0, 10) !== v ? void 0 : v;
1927
+ };
1928
+ function readListQuery(search, names = LIST_URL_ES) {
1929
+ const p = asParams(search);
1930
+ const out = {};
1931
+ const after = p.get(names.after);
1932
+ const before = p.get(names.before);
1933
+ if (after && CURSOR.test(after)) out.after = after;
1934
+ else if (before && CURSOR.test(before)) out.before = before;
1935
+ const pos = Number(p.get(names.pos));
1936
+ if (Number.isInteger(pos) && pos >= 1 && pos <= MAX_POS) out.pos = pos;
1937
+ const status = p.get(names.status);
1938
+ if (status && STATUS.test(status)) out.status = status;
1939
+ const delivery = p.get(names.delivery);
1940
+ if (delivery === names.deliveryValues.shipping) out.delivery = "shipping";
1941
+ else if (delivery === names.deliveryValues.pickup) out.delivery = "pickup";
1942
+ const invoice = p.get(names.invoice);
1943
+ if (invoice === names.invoiceValues.yes) out.invoice = true;
1944
+ else if (invoice === names.invoiceValues.no) out.invoice = false;
1945
+ const from = validDay(p.get(names.from));
1946
+ const to = validDay(p.get(names.to));
1947
+ if (from) out.from = from;
1948
+ if (to && (!from || to >= from)) out.to = to;
1949
+ const q = (p.get(names.q) ?? "").trim().replace(/^#/, "").trim();
1950
+ if (q && q.length <= MAX_Q) out.q = q;
1951
+ return out;
1952
+ }
1953
+ function isFiltered(query) {
1954
+ return !!(query.status || query.delivery || query.invoice !== void 0 || query.from || query.to || query.q);
1955
+ }
1956
+ function firstPageQuery(query) {
1957
+ const { after: _a, before: _b, pos: _p, ...filters } = query;
1958
+ return filters;
1959
+ }
1960
+ function listApiParams(query, first) {
1961
+ const params = { first };
1962
+ if (query.after) params.after = query.after;
1963
+ else if (query.before) params.before = query.before;
1964
+ if (query.status) params.status = query.status;
1965
+ if (query.delivery) params.delivery_method = query.delivery;
1966
+ if (query.invoice !== void 0) params.has_invoice = query.invoice;
1967
+ if (query.from) params.from = query.from;
1968
+ if (query.to) params.to = query.to;
1969
+ if (query.q) params.q = query.q;
1970
+ return params;
1971
+ }
1972
+ function listQueryString(query, names = LIST_URL_ES) {
1973
+ const p = new URLSearchParams();
1974
+ if (query.after) p.set(names.after, query.after);
1975
+ else if (query.before) p.set(names.before, query.before);
1976
+ if (query.pos && query.pos > 1) p.set(names.pos, String(query.pos));
1977
+ if (query.status) p.set(names.status, query.status);
1978
+ if (query.delivery) p.set(names.delivery, names.deliveryValues[query.delivery]);
1979
+ if (query.invoice !== void 0) p.set(names.invoice, query.invoice ? names.invoiceValues.yes : names.invoiceValues.no);
1980
+ if (query.from) p.set(names.from, query.from);
1981
+ if (query.to) p.set(names.to, query.to);
1982
+ if (query.q) p.set(names.q, query.q);
1983
+ const s = p.toString();
1984
+ return s ? `?${s}` : "";
1985
+ }
1986
+ var listHref = (path, query, names = LIST_URL_ES) => `${path}${listQueryString(query, names)}`;
1987
+ function pagePosition({ query, pageInfo, count }) {
1988
+ if (count === 0) return void 0;
1989
+ if (!query.after && !query.before) return 1;
1990
+ if (pageInfo && pageInfo.has_previous_page === false) return 1;
1991
+ return query.pos;
1992
+ }
1993
+ function nextPageQuery(state) {
1994
+ const { query, pageInfo, count } = state;
1995
+ if (!pageInfo?.has_next_page || !pageInfo.end_cursor) return null;
1996
+ const here = pagePosition(state);
1997
+ return { ...firstPageQuery(query), after: pageInfo.end_cursor, ...here ? { pos: here + count } : {} };
1998
+ }
1999
+ function previousPageQuery(state) {
2000
+ const { query, pageInfo, first } = state;
2001
+ if (!query.after && !query.before) return null;
2002
+ if (pageInfo?.has_previous_page === false) return firstPageQuery(query);
2003
+ const cursor = pageInfo?.start_cursor;
2004
+ if (!cursor) return query.after || query.before ? firstPageQuery(query) : null;
2005
+ const here = pagePosition(state);
2006
+ if (here !== void 0 && here - first <= 1) return firstPageQuery(query);
2007
+ return { ...firstPageQuery(query), before: cursor, ...here ? { pos: Math.max(1, here - first) } : {} };
2008
+ }
2009
+ function pageRange(state) {
2010
+ const from = pagePosition(state);
2011
+ if (!from || state.count === 0) return null;
2012
+ return { from, to: from + state.count - 1, total: typeof state.total === "number" && state.total >= 0 ? state.total : null };
2013
+ }
2014
+
1824
2015
  exports.CLIENT_IP_HEADER = CLIENT_IP_HEADER;
1825
2016
  exports.COUNTRY_HEADERS = COUNTRY_HEADERS;
1826
2017
  exports.DEFAULT_FIT_TAG_PREFIX = DEFAULT_FIT_TAG_PREFIX;
2018
+ exports.LIST_URL_EN = LIST_URL_EN;
2019
+ exports.LIST_URL_ES = LIST_URL_ES;
1827
2020
  exports.MAX_SUBJECT_YEAR = MAX_SUBJECT_YEAR;
1828
2021
  exports.MIN_SUBJECT_YEAR = MIN_SUBJECT_YEAR;
1829
2022
  exports.MISSING_WEIGHT = MISSING_WEIGHT;
@@ -1834,6 +2027,7 @@ exports.PRIVATE_MASK = PRIVATE_MASK;
1834
2027
  exports.SHIPPING_STEPS = SHIPPING_STEPS;
1835
2028
  exports.SUBJECT_CATALOG_PAGE_BYTES = SUBJECT_CATALOG_PAGE_BYTES;
1836
2029
  exports.StorefrontError = StorefrontError;
2030
+ exports.accountListQuery = accountListQuery;
1837
2031
  exports.appendParams = appendParams;
1838
2032
  exports.availabilityLocale = availabilityLocale;
1839
2033
  exports.availabilityMessages = availabilityMessages;
@@ -1849,6 +2043,7 @@ exports.declineMessageKey = declineMessageKey;
1849
2043
  exports.deliveryInput = deliveryInput;
1850
2044
  exports.deliveryNotices = deliveryNotices;
1851
2045
  exports.diagnose = diagnose;
2046
+ exports.firstPageQuery = firstPageQuery;
1852
2047
  exports.fitTag = fitTag;
1853
2048
  exports.fitTagsAny = fitTagsAny;
1854
2049
  exports.formatAvailabilityMessage = formatAvailabilityMessage;
@@ -1859,20 +2054,27 @@ exports.groupInvoiceDocs = groupInvoiceDocs;
1859
2054
  exports.hreflangLinks = hreflangLinks;
1860
2055
  exports.invoiceFileBytes = invoiceFileBytes;
1861
2056
  exports.isAccountDeleteBlocked = isAccountDeleteBlocked;
2057
+ exports.isFiltered = isFiltered;
1862
2058
  exports.isMasked = isMasked;
1863
2059
  exports.isReauthRequired = isReauthRequired;
1864
2060
  exports.isStorefrontError = isStorefrontError;
1865
2061
  exports.isTestInvoice = isTestInvoice;
1866
2062
  exports.isTestShipment = isTestShipment;
1867
2063
  exports.isTokenPublishable = isTokenPublishable;
2064
+ exports.listApiParams = listApiParams;
2065
+ exports.listHref = listHref;
2066
+ exports.listQueryString = listQueryString;
1868
2067
  exports.maskToken = maskToken;
1869
2068
  exports.negotiateLocale = negotiateLocale;
1870
2069
  exports.nextAction = nextAction;
2070
+ exports.nextPageQuery = nextPageQuery;
1871
2071
  exports.normalizeClientIp = normalizeClientIp;
1872
2072
  exports.normalizeNote = normalizeNote;
1873
2073
  exports.opsSaysNotRetryable = opsSaysNotRetryable;
1874
2074
  exports.orderProgress = orderProgress;
1875
2075
  exports.orderShipments = orderShipments;
2076
+ exports.pagePosition = pagePosition;
2077
+ exports.pageRange = pageRange;
1876
2078
  exports.parseDelivery = parseDelivery;
1877
2079
  exports.parseMoney = parseMoney;
1878
2080
  exports.parseProductFilters = parseProductFilters;
@@ -1881,10 +2083,12 @@ exports.paymentIdempotencyKey = paymentIdempotencyKey;
1881
2083
  exports.paymentMessages = paymentMessages;
1882
2084
  exports.paymentOutcome = paymentOutcome;
1883
2085
  exports.preferredLanguages = preferredLanguages;
2086
+ exports.previousPageQuery = previousPageQuery;
1884
2087
  exports.productAvailability = productAvailability;
1885
2088
  exports.productListQuery = productListQuery;
1886
2089
  exports.promoProgressView = promoProgressView;
1887
2090
  exports.promotionMessages = promotionMessages;
2091
+ exports.readListQuery = readListQuery;
1888
2092
  exports.reconcileSubjectValues = reconcileSubjectValues;
1889
2093
  exports.repairPath = repairPath;
1890
2094
  exports.resolveAvailability = resolveAvailability;