@doswiftly/storefront-sdk 13.0.0 → 13.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  # Changelog
2
2
 
3
+ ## 13.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2e137ad: Added cart-aware shipping methods discovery: `Cart.requiresShipping`, `CartLine.requiresShipping`, and `cart.availableShippingMethods(address)`.
8
+
9
+ **What's new for the storefront**
10
+ - **`cart.requiresShipping: Boolean!`** — single signal whether the cart needs physical shipping at all. `false` for carts that contain only digital goods (downloads, gift cards, services, subscriptions). Use it to skip the shipping picker step in checkout entirely.
11
+ - **`cart.lines.nodes[].requiresShipping: Boolean!`** — per-line classification. Useful in cart drawer UI to flag physical vs digital lines independently.
12
+ - **`cart.availableShippingMethods(address: ShippingAddressInput!): AvailableShippingMethodsPayload!`** — field on `Cart` that returns shipping methods for the cart's contents at the given destination. The backend pulls subtotal and weight from the cart aggregate — you no longer need to compute them on the client. For digital-only carts the response is `{ methods: [], userErrors: [{ code: 'DIGITAL_ONLY_NO_SHIPPING' }] }`.
13
+ - **`CartAvailableShippingMethods` query** — new named operation ready to drop into your storefront codegen pipeline.
14
+
15
+ **Recommended checkout flow**
16
+
17
+ ```graphql
18
+ query CartAvailableShippingMethods(
19
+ $cartId: ID!
20
+ $address: ShippingAddressInput!
21
+ ) {
22
+ cart(id: $cartId) {
23
+ id
24
+ requiresShipping
25
+ availableShippingMethods(address: $address) {
26
+ methods {
27
+ id
28
+ name
29
+ price {
30
+ amount
31
+ currencyCode
32
+ }
33
+ }
34
+ userErrors {
35
+ code
36
+ message
37
+ field
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ If `cart.requiresShipping === false`, skip rendering the shipping picker and proceed straight to payment. Calling `cartSelectShippingMethod` on a digital-only cart returns `userErrors[{ code: 'FORBIDDEN_SHIPPING_METHOD' }]`, matching the readiness check that `cartComplete` already enforces.
45
+
46
+ **Backward compatibility**
47
+ - The existing standalone `availableShippingMethods(address, cart: CartShippingInput)` query is **unchanged**. Keep using it for pre-cart shipping calculators on product detail pages (when the customer has not created a cart yet).
48
+ - The new field and new query are purely additive. No existing operations change shape.
49
+
50
+ **Free-shipping progress + delivery estimates are now localized**
51
+
52
+ The `freeShippingProgress.message` field and `estimatedDelivery.description` field used to be hardcoded in English. They now respect the `Accept-Language` header (defaults to Polish — `pl`). If your storefront previously parsed these strings, switch to the structured fields (`qualifies`, `progressPercent`, `remaining.amount`, `minDays`, `maxDays`) instead.
53
+
54
+ **Reason codes on shipping `userErrors`**
55
+
56
+ | Code | When | UI reaction |
57
+ | -------------------------- | -------------------------------- | -------------------------------------------- |
58
+ | `DIGITAL_ONLY_NO_SHIPPING` | Cart contains only digital items | Skip shipping picker, go straight to payment |
59
+ | `NO_SHIPPING_METHODS` | Address has no matching zone | Show "no delivery to your country" |
60
+ | `SHIPPING_ERROR` | Internal service error (rare) | Retry or fall back to pre-cart preview query |
61
+
62
+ **Why both packages bump together**
63
+
64
+ `@doswiftly/storefront-sdk` ships local copies of the cart fragments that this update extends with `requiresShipping`, so the SDK release pairs with the schema/operations release. `@doswiftly/commerce-policy` exports `NON_PHYSICAL_TYPES` for downstream tooling that wants to mirror the same classification on the client side.
65
+
3
66
  ## 13.0.0
4
67
 
5
68
  ### Major Changes
@@ -1 +1 @@
1
- {"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoSH,eAAO,MAAM,UAAU,QAOrB,CAAC;AAMH,eAAO,MAAM,WAAW,QAWtB,CAAC;AAEH,eAAO,MAAM,cAAc,QAWzB,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAEH,eAAO,MAAM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MAAM,aAAa,QAWxB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QASzB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,QAoBtC,CAAC"}
@@ -113,6 +113,7 @@ const CART_LINE_FRAGMENT = `
113
113
  productTitle
114
114
  productHandle
115
115
  productType
116
+ requiresShipping
116
117
  }
117
118
  ${CART_LINE_COST_FRAGMENT}
118
119
  ${PRODUCT_VARIANT_FRAGMENT}
@@ -207,6 +208,7 @@ const CART_FRAGMENT = `
207
208
  selectedShippingMethod { ...CartShippingMethod }
208
209
  selectedPaymentMethod { ...CartSelectedPaymentMethod }
209
210
  appliedGiftCards { ...CartAppliedGiftCard }
211
+ requiresShipping
210
212
  createdAt
211
213
  updatedAt
212
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doswiftly/storefront-sdk",
3
- "version": "13.0.0",
3
+ "version": "13.1.0",
4
4
  "description": "Storefront runtime SDK for DoSwiftly Commerce — layered transport, middleware pipeline, React providers, Zustand stores, cache strategies. 0 runtime dependencies in core.",
5
5
  "type": "module",
6
6
  "sideEffects": false,