@doswiftly/cli 0.2.6 → 1.0.1

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +650 -0
  2. package/dist/commands/deploy.d.ts.map +1 -1
  3. package/dist/commands/deploy.js +6 -1
  4. package/dist/commands/deploy.js.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/storefront-nextjs-shadcn/.github/workflows/build-template.yml +2 -1
  7. package/templates/storefront-nextjs-shadcn/.github/workflows/deploy.yml +5 -1
  8. package/templates/storefront-nextjs-shadcn/.github/workflows/preview.yml +3 -1
  9. package/templates/storefront-nextjs-shadcn/app/[locale]/account/addresses/page.tsx +10 -10
  10. package/templates/storefront-nextjs-shadcn/app/[locale]/account/loyalty/page.tsx +1 -1
  11. package/templates/storefront-nextjs-shadcn/app/[locale]/account/orders/[id]/page.tsx +9 -9
  12. package/templates/storefront-nextjs-shadcn/app/[locale]/account/orders/[id]/tracking/page.tsx +1 -1
  13. package/templates/storefront-nextjs-shadcn/app/[locale]/account/orders/page.tsx +2 -2
  14. package/templates/storefront-nextjs-shadcn/app/[locale]/account/settings/page.tsx +3 -3
  15. package/templates/storefront-nextjs-shadcn/app/[locale]/categories/page.tsx +1 -1
  16. package/templates/storefront-nextjs-shadcn/app/[locale]/checkout/page.tsx +74 -74
  17. package/templates/storefront-nextjs-shadcn/app/[locale]/products/[slug]/product-client.tsx +1 -1
  18. package/templates/storefront-nextjs-shadcn/app/[locale]/products/products-client.tsx +4 -4
  19. package/templates/storefront-nextjs-shadcn/app/api/auth/whoami/route.ts +6 -0
  20. package/templates/storefront-nextjs-shadcn/components/account/address-form.tsx +43 -43
  21. package/templates/storefront-nextjs-shadcn/components/account/address-list.tsx +9 -9
  22. package/templates/storefront-nextjs-shadcn/components/account/customer-info.fragment.graphql +5 -5
  23. package/templates/storefront-nextjs-shadcn/components/account/order-details.tsx +8 -8
  24. package/templates/storefront-nextjs-shadcn/components/account/order-history.tsx +2 -2
  25. package/templates/storefront-nextjs-shadcn/components/account/order-summary.fragment.graphql +15 -13
  26. package/templates/storefront-nextjs-shadcn/components/cart/cart-line.fragment.graphql +6 -6
  27. package/templates/storefront-nextjs-shadcn/components/discount/discount-code-input.tsx +10 -10
  28. package/templates/storefront-nextjs-shadcn/components/gift-card/gift-card-input.tsx +9 -9
  29. package/templates/storefront-nextjs-shadcn/components/order/delivery-estimate.tsx +2 -2
  30. package/templates/storefront-nextjs-shadcn/components/product/product-card.tsx +1 -1
  31. package/templates/storefront-nextjs-shadcn/components/seo/product-json-ld.ts +1 -1
  32. package/templates/storefront-nextjs-shadcn/hooks/use-auth-sync.ts +43 -25
  33. package/templates/storefront-nextjs-shadcn/hooks/use-cart-actions.ts +1 -1
  34. package/templates/storefront-nextjs-shadcn/hooks/use-cart-sync.ts +14 -14
  35. package/templates/storefront-nextjs-shadcn/lib/graphql/hooks.ts +101 -112
  36. package/templates/storefront-nextjs-shadcn/lib/graphql/query-keys.ts +2 -2
  37. package/templates/storefront-nextjs-shadcn/lib/graphql/server.ts +29 -12
  38. package/templates/storefront-nextjs-shadcn/lib/graphql/types.ts +1 -1
  39. package/templates/storefront-nextjs-shadcn/messages/en.json +6 -6
  40. package/templates/storefront-nextjs-shadcn/messages/pl.json +6 -6
  41. package/templates/storefront-nextjs-shadcn/package.json +4 -1
  42. package/templates/storefront-nextjs-shadcn/stores/checkout-store.ts +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,655 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f7cf33f: **Fixed**: deploy via GitHub Actions failed with `Wrangler requires at least Node.js v22.0.0` because workflow templates pinned `node-version: 20` while `wrangler@latest` (installed mid-deploy for worker re-bundling) requires Node ≥22.
8
+ - `deploy.yml`, `preview.yml`, `build-template.yml` now use `node-version: 22` (LTS since April 2024, cached on `ubuntu-latest` so no extra download)
9
+ - `wrangler@^4` is now pinned at the install site — previously installed as `latest`, which silently picked up newer majors that could bump the Node floor again
10
+ - Scaffolded `package.json` declares `engines.node: ">=22.0.0"` so local `npm install` warns developers running an unsupported Node version
11
+
12
+ Existing projects (scaffolded with a previous CLI release) keep their `node-version: 20` until they re-run `doswiftly init` or manually edit the workflow file. The CLI cannot upgrade workflows in-place; consider running `doswiftly init` in a fresh directory and copying the workflow file across, or simply replace `node-version: 20` with `22` and re-commit.
13
+
14
+ ## 1.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - d51eb03: Storefront API: cookie-first authentication + comprehensive typing fixes.
19
+
20
+ **⚠️ Breaking changes — migration required**
21
+
22
+ ### Authentication: cookie-first, drop `customerAccessToken` argument
23
+
24
+ The storefront API no longer accepts `customerAccessToken` as a query/mutation argument.
25
+ Authentication context is now resolved per-request from (in priority order):
26
+ 1. **httpOnly cookie `customerAccessToken`** — set automatically by the API after `customerAccessTokenCreate` / `customerCreate` / `customerAccessTokenRenew` / `customerActivateByUrl` / `customerResetByUrl` / `customerReset`. Browser-based storefronts gain XSS-safe auth out of the box.
27
+ 2. **`Authorization: Bearer <token>` header** — for non-browser clients (mobile native, server-to-server, OAuth integrations per RFC 6750).
28
+
29
+ `customerAccessTokenDelete` (logout) clears the cookie via `Set-Cookie: customerAccessToken=; Max-Age=0`.
30
+
31
+ **Affected operations** (drop `customerAccessToken: String!` arg + value pass-through):
32
+ - Queries: `customer`, `customerOrder`, `shipment`, `return`, `returnsByOrder`
33
+ - Mutations: `customerAccessTokenDelete`, `customerAccessTokenRenew`, `customerUpdate`, `customerAddressCreate`, `customerAddressUpdate`, `customerAddressDelete`, `customerDefaultAddressUpdate`, `returnCreate`, `returnCancel`
34
+
35
+ **Migration**:
36
+
37
+ ```graphql
38
+ # Before (4.x)
39
+ query Customer($customerAccessToken: String!) {
40
+ customer(customerAccessToken: $customerAccessToken) { ... }
41
+ }
42
+
43
+ # After (5.x)
44
+ query Customer {
45
+ customer { ... }
46
+ }
47
+ ```
48
+
49
+ For a browser, send the request with `credentials: 'include'` so the httpOnly cookie travels along. For non-browser clients, set `Authorization: Bearer <jwt>` on each request. The `accessToken` field in mutation responses (`customerAccessTokenCreate.customerAccessToken.accessToken`) is still present for non-browser clients that manage their own token storage.
50
+
51
+ ### `LANGUAGE_HEADER_NAME` constant renamed `X-Lang` → `X-Language`
52
+
53
+ Storefronts importing this constant from `@doswiftly/storefront-sdk` will pick up the new value at rebuild time. The previous value did not match the API reader and silently fell through to `Accept-Language` auto-detection — explicit per-request language switching now works as documented.
54
+
55
+ ### `@inContext` directive accepts new arguments
56
+
57
+ `@inContext` previously exposed only `preferredLocationId`. It now also accepts `country: String`, `language: String`, `currency: String`, and `buyer: BuyerInput { customerAccessToken, companyLocationId }`. Resolution priority: `directive > request header > cookie > Accept-Language auto-detect > shop default`. All five layers are independent — pick whichever matches your routing/SSR architecture.
58
+
59
+ ### `Shop.primaryDomain` is now a `Domain` object
60
+
61
+ ```graphql
62
+ # Before
63
+ type Shop {
64
+ primaryDomain: String # "https://example.com"
65
+ primaryDomainObject: Domain! # { host, url, sslEnabled }
66
+ }
67
+
68
+ # After
69
+ type Shop {
70
+ primaryDomain: Domain! # { host, url, sslEnabled }
71
+ }
72
+ ```
73
+
74
+ Update the `Shop` fragment to query the structured fields:
75
+
76
+ ```graphql
77
+ fragment Shop on Shop {
78
+ primaryDomain { host url sslEnabled }
79
+ ...
80
+ }
81
+ ```
82
+
83
+ ### Removed redundant fields
84
+ - `Menu.itemsCount` — drop. Use `items.length` in the client (the count was always equal to the array length).
85
+ - `GiftCard.lastCharacters` — drop. Compute from `maskedCode.slice(-4)` in the client.
86
+
87
+ ### Stronger types — `Date`, enums, structured errors
88
+
89
+ Several fields previously returned `String` (ISO 8601) or untyped error arrays — now properly typed:
90
+ - **DateTime**: `Order.processedAt`, `BlogPost.{publishedAt,createdAt,updatedAt}`, `ShopPage.{publishedAt,createdAt,updatedAt}`, `LoyaltyMember.{lastActivityAt,enrolledAt}`, `LoyaltyTransaction.{createdAt,expiresAt}`, `LoyaltyPointsSummary.nextExpiryDate`, `CustomerAccessToken.expiresAt`. Codegen now emits `Date | string` (or your codegen's date type).
91
+ - **Enums**: `Customer.emailMarketingState` is `EmailMarketingState!`, `ProductAttributeDefinition.fillingMode/billingMode` are typed enums, `ProductAttributeOption.surchargeType` is `AttributeOptionSurchargeType`, `Shop.currencyCode` / `paymentCurrencies` / `supportedCurrencies` use `CurrencyCode`, `Shop.defaultLanguage` / `supportedLanguages` use `LanguageCode`, `Currency.code` is `CurrencyCode`, `Currency.symbolPosition` is the new `CurrencySymbolPosition` enum (`BEFORE` / `AFTER`).
92
+ - **Structured errors**: `WishlistPayload.userErrors`, `RedeemRewardPayload.userErrors`, `GenerateReferralCodePayload.userErrors` are now `[UserError!]!` (`{ message, code, field }`) instead of `[String!]!`. Replace `userErrors[0]` with `userErrors[0].message` in your error handling.
93
+
94
+ ### New: `ProductReview.unhelpfulCount`
95
+
96
+ Storefronts can now render upvote/downvote counts side-by-side without computing one from the other.
97
+
98
+ ### Cross-domain cookie auth — `credentials: 'include'`
99
+
100
+ The SDK GraphQL transport now sends `credentials: 'include'` on every request. If your storefront runs on a domain different from the API and uses cookie auth, the API CORS configuration must allow your origin (with `Access-Control-Allow-Credentials: true`). Same-origin deployments are unaffected.
101
+
102
+ ### Auth store no longer persists `accessToken` to localStorage (XSS hardening)
103
+
104
+ `useAuthStore` only persists `customer` and `isAuthenticated` to localStorage. The token lives in the httpOnly cookie (browser auto-sent) plus in-memory store state (set by login flow). After a page refresh, browser-based storefronts call `GET /api/auth/whoami` (new BFF route shipped with the template) to rehydrate `customer` info — the cookie continues to authenticate every subsequent GraphQL request transparently.
105
+
106
+ The `auth-storage` localStorage version bumps from `v2` to `v3`; the migrate handler clears legacy persisted tokens on first load.
107
+
108
+ ### New: `createWhoamiHandler()` factory
109
+
110
+ Exports from `@doswiftly/storefront-sdk`. Pair with the `app/api/auth/whoami/route.ts` example shipped with the CLI template:
111
+
112
+ ```typescript
113
+ // app/api/auth/whoami/route.ts
114
+ import { createWhoamiHandler } from "@doswiftly/storefront-sdk";
115
+ export const GET = createWhoamiHandler({
116
+ apiUrl: process.env.NEXT_PUBLIC_API_URL,
117
+ shopSlug: process.env.NEXT_PUBLIC_SHOP_SLUG,
118
+ });
119
+ ```
120
+
121
+ ### `AuthClient` (low-level core API) — drop token argument
122
+
123
+ ```typescript
124
+ // Before
125
+ authClient.logout(token);
126
+ authClient.renewToken(token);
127
+ authClient.getCustomer(token);
128
+
129
+ // After
130
+ authClient.logout(); // auth via cookie/Bearer in middleware
131
+ authClient.renewToken();
132
+ authClient.getCustomer();
133
+ ```
134
+
135
+ ### Template (`@doswiftly/cli` scaffolded storefront)
136
+
137
+ The Next.js template now uses cookie-first auth end-to-end:
138
+ - `lib/graphql/hooks.ts` — query/mutation hooks no longer pass `customerAccessToken`
139
+ - `lib/graphql/server.ts` — server-side helper reads `customerAccessToken` cookie via `next/headers` and forwards as `Authorization: Bearer`
140
+ - `app/api/auth/whoami/route.ts` (new) — BFF route for `customer` rehydration after page refresh
141
+ - `hooks/use-auth-sync.ts` — rewritten to use the whoami endpoint instead of token desync detection
142
+ - Auth-gated React components/pages now check `isAuthenticated` instead of `accessToken`
143
+
144
+ ### Wishlist pagination + GiftCard read surface
145
+ - **`wishlists`** is now a paginated **`WishlistConnection`** (Relay pattern). Replace direct array selection with `nodes` (shortcut) or `edges { cursor node { ... } }`. Supports `first: Int = 20` and `after: String` cursor arguments.
146
+
147
+ ```graphql
148
+ # Before (4.x)
149
+ query Wishlists {
150
+ wishlists {
151
+ id
152
+ name
153
+ itemCount
154
+ items {
155
+ id
156
+ productId
157
+ }
158
+ }
159
+ }
160
+
161
+ # After (5.x)
162
+ query Wishlists($first: Int = 20, $after: String) {
163
+ wishlists(first: $first, after: $after) {
164
+ nodes {
165
+ id
166
+ name
167
+ itemCount
168
+ items {
169
+ id
170
+ productId
171
+ }
172
+ }
173
+ pageInfo {
174
+ hasNextPage
175
+ hasPreviousPage
176
+ startCursor
177
+ endCursor
178
+ }
179
+ totalCount
180
+ }
181
+ }
182
+ ```
183
+
184
+ - **`giftCard(code)`** read query no longer wraps result in `GiftCardPayload`. Returns nullable `GiftCard` directly (`null` = not found). The wrapper pattern `{ giftCard, userErrors }` is reserved for mutations only.
185
+
186
+ ```graphql
187
+ # Before (4.x)
188
+ query GiftCard($code: String!) {
189
+ giftCard(code: $code) {
190
+ giftCard {
191
+ id
192
+ maskedCode
193
+ balance {
194
+ amount
195
+ currencyCode
196
+ }
197
+ }
198
+ userErrors {
199
+ message
200
+ code
201
+ }
202
+ }
203
+ }
204
+
205
+ # After (5.x)
206
+ query GiftCard($code: String!) {
207
+ giftCard(code: $code) {
208
+ id
209
+ maskedCode
210
+ balance {
211
+ amount
212
+ currencyCode
213
+ }
214
+ }
215
+ }
216
+ ```
217
+
218
+ - **`GiftCard.transactions`** field removed from storefront API entirely. The field always returned `[]` (PII safety: transactions contain `orderId` / `customerId` not safe to expose at anonymous code-lookup endpoint). Schema now rejects the selection at validation time. Storefronts that selected this field will get a clear schema error instead of an always-empty array.
219
+
220
+ ### Filter scalars + structured Weight type
221
+ - **`Filter.id` and `FilterValue.id`** are now `ID!` (previously `String!`). Codegen treats `ID` identically to `String` in TypeScript, but downstream client tooling (Relay-style caches, normalized stores) gains proper identity semantics for entity deduplication.
222
+ - **`FilterValue.input`** changed from `String!` (JSON-stringified payload) to **`JSON!`** (new opaque structured scalar). Storefronts no longer need to `JSON.parse(filterValue.input)` before passing it to the `filters` argument — the value arrives as a structured object ready to use:
223
+
224
+ ```graphql
225
+ # Before (4.x) — client-side parsing required
226
+ filterValue.input # "{\"variantOption\":{\"name\":\"Color\",\"value\":\"Red\"}}"
227
+ JSON.parse(filterValue.input)
228
+
229
+ # After (5.x) — directly passable as filters arg element
230
+ filterValue.input # { variantOption: { name: "Color", value: "Red" } }
231
+ ```
232
+
233
+ - **`ProductVariant.weight`** changed from `Float` (raw grams, implicit unit per docs) to **`Weight { value: Float!, unit: WeightUnit! }`** structured type with the new `WeightUnit` enum (`GRAMS | KILOGRAMS | OUNCES | POUNDS`). The API always returns `unit: GRAMS` (canonical storage unit). Storefronts can convert to the preferred unit for shipping or checkout UI without hardcoding "grams" anywhere in the codebase:
234
+
235
+ ```graphql
236
+ # Before (4.x)
237
+ variant { weight } # 250 (Float, "grams" implicit per docs)
238
+
239
+ # After (5.x)
240
+ variant { weight { value unit } } # { value: 250, unit: GRAMS }
241
+ ```
242
+
243
+ ### Removed: legacy `x-customer-access-token` header
244
+
245
+ The legacy `x-customer-access-token` header reader (which never had a matching SDK middleware) is removed from the API. If a custom integration was relying on it, switch to `Authorization: Bearer <token>`.
246
+
247
+ ### Field & mutation naming sweep
248
+
249
+ Several renames have landed in this release. Update queries and variables accordingly:
250
+ - **Cart mutations**: `cartLinesAdd` → `cartAddLines`, `cartLinesUpdate` → `cartUpdateLines`, `cartLinesRemove` → `cartRemoveLines`, `cartNoteUpdate` → `cartUpdateNote`, `cartAttributesUpdate` → `cartUpdateAttributes`, `cartBuyerIdentityUpdate` → `cartUpdateBuyerIdentity`, `cartDiscountCodesUpdate` → `cartApplyDiscountCodes`. Resource-id arg renamed `cartId` → `id` on mutations (the foreign-key `CheckoutCreateInput.cartId` keeps its name).
251
+ - **Checkout mutations**: `checkoutId` → `id`. `checkoutSelectShippingRate` arg `shippingRateHandle` → `rateId`.
252
+ - **Wishlist mutations**: `wishlistId` → `id`.
253
+ - **Field renames on output types**:
254
+ - `Product.productType` → `Product.category` (free-text classification field; the `Product.type: ProductTypeEnum` enum field is unchanged)
255
+ - `ProductVariant.quantityAvailable` → `availableStock` (disambiguates effective availability from raw inventory)
256
+ - `ProductOption.position` / `ProductOptionValue.position` → `sortOrder`
257
+ - `Customer.numberOfOrders` → `orderCount`
258
+ - `WishlistItem.priceAtAdd` → `priceWhenAdded`
259
+ - `Shop.primaryDomain.sslEnabled` → `isSslEnabled` (boolean prefix convention)
260
+ - `Shipment.estimatedDeliveryDate` → `estimatedDeliveryAt`
261
+ - `StoreAvailability.pickUpTime` → `pickupTime`
262
+ - `Location.pickupEnabled` → `supportsPickup`
263
+ - `ShopPage.bodySummary` → `excerpt`
264
+ - **New field**: `ProductReview.unhelpfulCount` — render upvote/downvote counts side-by-side without computing one from the other.
265
+ - **`UserError`/payload selection set** is now required on `WishlistPayload.userErrors` (and other payloads switched to typed `[UserError!]!`). Bare `userErrors` selection without a sub-selection is rejected by schema validation.
266
+ - **Error code stability**: typed error codes (e.g. `CART_NOT_FOUND`, `CUSTOMER_TOKEN_INVALID`) are now locale-agnostic — they remain stable across language responses (in earlier versions the mapping silently regressed when a translated message lost a specific English keyword).
267
+
268
+ ### Unified `UserError` across all mutation payloads
269
+
270
+ Per-domain user-error types (`CartUserError`, `CheckoutUserError`, `CustomerUserError`) have been replaced by the single generic `UserError` type used everywhere. Error codes remain unique per domain (e.g. `CART_NOT_FOUND` vs `CUSTOMER_NOT_FOUND` vs `CHECKOUT_PAYMENT_FAILED`) — string comparison on the `code` field gives the same branching power without per-domain type proliferation.
271
+
272
+ Customer mutation payloads also rename the error field from `customerUserErrors` to `userErrors` for consistency with cart, checkout, wishlist, and other payloads:
273
+
274
+ ```graphql
275
+ # Before (4.x)
276
+ mutation CartCreate {
277
+ cartCreate {
278
+ userErrors {
279
+ ...CartUserError
280
+ }
281
+ }
282
+ }
283
+ mutation CustomerLogin {
284
+ customerLogin {
285
+ customerUserErrors {
286
+ ...CustomerUserError
287
+ }
288
+ }
289
+ }
290
+ mutation CheckoutCreate {
291
+ checkoutCreate {
292
+ userErrors {
293
+ ...CheckoutUserError
294
+ }
295
+ }
296
+ }
297
+
298
+ # After (5.x)
299
+ mutation CartCreate {
300
+ cartCreate {
301
+ userErrors {
302
+ ...UserError
303
+ }
304
+ }
305
+ }
306
+ mutation CustomerLogin {
307
+ customerLogin {
308
+ userErrors {
309
+ ...UserError
310
+ }
311
+ }
312
+ }
313
+ mutation CheckoutCreate {
314
+ checkoutCreate {
315
+ userErrors {
316
+ ...UserError
317
+ }
318
+ }
319
+ }
320
+ ```
321
+
322
+ Update the shared `UserError` fragment as the only error fragment you need:
323
+
324
+ ```graphql
325
+ fragment UserError on UserError {
326
+ message
327
+ code # namespaced string — e.g. "CART_NOT_FOUND", "CUSTOMER_TOKEN_INVALID"
328
+ field # path to the input field that caused the error
329
+ }
330
+ ```
331
+
332
+ Client TypeScript change after codegen: `userErrors[i].code` is now `string | null` instead of a strongly-typed enum (`CartErrorCode` / `CheckoutErrorCode` / `CustomerErrorCode`). Switch from `code === CartErrorCode.CART_NOT_FOUND` to `code === 'CART_NOT_FOUND'`. The full list of namespaced codes per domain is documented in the schema descriptions on each payload's `userErrors` field.
333
+
334
+ ### Address `country` field — `CountryCode` enum on inputs
335
+
336
+ Address input types (`MailingAddressInput`, `CheckoutAddressInput`, `ShippingAddressInput`) now use the `CountryCode` enum for the `country` field instead of `String` with regex validation. This matches the pattern already used by output types (`MailingAddress.countryCode: CountryCode`) and gives client codegen a strongly-typed enum value instead of a free-form string:
337
+
338
+ ```graphql
339
+ # Before (4.x)
340
+ input CheckoutAddressInput {
341
+ country: String! # validated server-side via @Matches(/^[A-Z]{2}$/)
342
+ }
343
+
344
+ # After (5.x)
345
+ input CheckoutAddressInput {
346
+ country: CountryCode! # GraphQL enum — invalid values rejected at validation
347
+ }
348
+ ```
349
+
350
+ Output types keep two distinct fields where applicable: `country` (display name, e.g. "Polska") + `countryCode` (typed enum, e.g. `PL`).
351
+
352
+ ### Address fields — international naming
353
+
354
+ `MailingAddress`, `LocationAddress`, `ShopAddress`, and the address inputs (`MailingAddressInput`, `CheckoutAddressInput`) now use international neutral terminology instead of US/Canadian-centric field names. The new names match common international postal conventions and the underlying database column names:
355
+
356
+ | Before (4.x) | After (5.x) |
357
+ | -------------- | ------------- |
358
+ | `address1` | `streetLine1` |
359
+ | `address2` | `streetLine2` |
360
+ | `province` | `state` |
361
+ | `provinceCode` | `stateCode` |
362
+ | `zip` | `postalCode` |
363
+
364
+ ```graphql
365
+ # Before (4.x)
366
+ fragment MailingAddress on MailingAddress {
367
+ address1
368
+ address2
369
+ province
370
+ zip
371
+ }
372
+
373
+ # After (5.x)
374
+ fragment MailingAddress on MailingAddress {
375
+ streetLine1
376
+ streetLine2
377
+ state
378
+ postalCode
379
+ }
380
+
381
+ # Mutation input
382
+ mutation AddAddress($input: MailingAddressInput!) {
383
+ customerAddAddress(input: $input) { ... }
384
+ }
385
+ # variables (4.x): { address1: "...", province: "...", zip: "..." }
386
+ # variables (5.x): { streetLine1: "...", state: "...", postalCode: "..." }
387
+ ```
388
+
389
+ **Backward-compat for existing orders**: `Order.shippingAddress` and `Order.billingAddress` are stored as JSONB snapshots at order placement time. Snapshots created under the previous API contain `address1` / `province` / `zip`; new snapshots use `streetLine1` / `state` / `postalCode`. The `MailingAddress` resolver reads new field names first and falls back to legacy names — historical orders continue to render correctly. Frontend codegen will emit the new field names; templates rendering historical orders gain the new schema without data migration. Backward-compat fallback is scheduled for removal once historical snapshots reach end-of-life (~2-3 years).
390
+
391
+ **`MailingAddress.formatted`** (country-aware ordered lines) continues to work — internal helper updated to use new field names. Storefronts rendering addresses via `formatted` need no changes.
392
+
393
+ ### Costs and totals — nested wrappers everywhere
394
+
395
+ Cart, Checkout, and Order now expose monetary breakdowns via dedicated wrapper types instead of flat fields on the parent. This adds a single hop in selections but makes adding new cost dimensions (duty, fees, surcharges) non-breaking, and brings symmetry across the three checkout-flow stages:
396
+
397
+ ```graphql
398
+ # CartCost — drop "Amount" suffix from field names (Money type implies amount)
399
+ fragment CartCost on CartCost {
400
+ subtotal {
401
+ ...Money
402
+ } # was: subtotalAmount
403
+ total {
404
+ ...Money
405
+ } # was: totalAmount
406
+ totalTax {
407
+ ...Money
408
+ } # was: totalTaxAmount
409
+ totalDuty {
410
+ ...Money
411
+ } # was: totalDutyAmount
412
+ checkoutCharge {
413
+ ...Money
414
+ } # was: checkoutChargeAmount
415
+ }
416
+
417
+ # CartLineCost — drop "Amount" suffix + "amountPerQuantity" → "pricePerUnit"
418
+ fragment CartLineCost on CartLineCost {
419
+ pricePerUnit {
420
+ ...Money
421
+ } # was: amountPerQuantity
422
+ subtotal {
423
+ ...Money
424
+ } # was: subtotalAmount
425
+ total {
426
+ ...Money
427
+ } # was: totalAmount
428
+ compareAtPricePerUnit {
429
+ ...Money
430
+ } # was: compareAtAmountPerQuantity
431
+ }
432
+
433
+ # CheckoutCost — NEW wrapper, replaces flat checkout fields
434
+ query Checkout {
435
+ checkout {
436
+ cost {
437
+ subtotal {
438
+ ...Money
439
+ } # was: Checkout.subtotalPrice
440
+ total {
441
+ ...Money
442
+ } # was: Checkout.totalPrice
443
+ totalTax {
444
+ ...Money
445
+ } # was: Checkout.totalTax (now nested)
446
+ totalShipping {
447
+ ...Money
448
+ } # was: Checkout.totalShippingPrice
449
+ totalDiscounts {
450
+ ...Money
451
+ } # was: Checkout.totalDiscounts (now nested)
452
+ }
453
+ }
454
+ }
455
+
456
+ # OrderTotals — NEW wrapper, replaces flat order fields
457
+ query CustomerOrder {
458
+ customerOrder {
459
+ totals {
460
+ subtotal {
461
+ ...Money
462
+ } # was: Order.subtotalPrice
463
+ total {
464
+ ...Money
465
+ } # was: Order.totalPrice
466
+ totalTax {
467
+ ...Money
468
+ } # was: Order.totalTax (now nested)
469
+ totalShipping {
470
+ ...Money
471
+ } # was: Order.totalShipping (now nested)
472
+ }
473
+ }
474
+ }
475
+
476
+ # CheckoutLineItem — line price field renames
477
+ fragment CheckoutLineItem on CheckoutLineItem {
478
+ pricePerUnit {
479
+ ...Money
480
+ } # was: unitPrice
481
+ total {
482
+ ...Money
483
+ } # was: totalPrice
484
+ }
485
+ ```
486
+
487
+ Conversion-transparency opt-in fields (`*WithConversion`) are renamed in lockstep:
488
+ - `subtotalAmountWithConversion` → `subtotalWithConversion`
489
+ - `totalAmountWithConversion` → `totalWithConversion`
490
+ - `amountPerQuantityWithConversion` → `pricePerUnitWithConversion`
491
+ - ...and so on.
492
+
493
+ ### Cart line: simplified shape — `variant` replaces `merchandise` union
494
+
495
+ `CartLine.merchandise: Merchandise!` (a union currently with only `ProductVariant` member) and the `BaseCartLine` interface have been removed. `CartLine` is now a concrete type with a direct `variant: ProductVariant!` field — no union wrapper, no inline fragments needed:
496
+
497
+ ```graphql
498
+ # Before (4.x)
499
+ fragment CartLine on CartLine {
500
+ id
501
+ quantity
502
+ merchandise {
503
+ ... on ProductVariant {
504
+ id
505
+ title
506
+ price { amount currencyCode }
507
+ }
508
+ }
509
+ cost { ... }
510
+ }
511
+
512
+ # After (5.x) — direct field, no union/inline fragment
513
+ fragment CartLine on CartLine {
514
+ id
515
+ quantity
516
+ variant {
517
+ id
518
+ title
519
+ price { amount currencyCode }
520
+ }
521
+ cost { ... }
522
+ }
523
+ ```
524
+
525
+ Cart connection types renamed for the same reason: `BaseCartLineConnection` / `BaseCartLineEdge` → `CartLineConnection` / `CartLineEdge`. Update fragment selections accordingly:
526
+
527
+ ```graphql
528
+ # Before (4.x)
529
+ query Cart($id: ID!) {
530
+ cart(id: $id) {
531
+ lines(first: 10) {
532
+ edges {
533
+ node {
534
+ ... on CartLine {
535
+ id
536
+ }
537
+ }
538
+ }
539
+ nodes {
540
+ ... on CartLine {
541
+ id
542
+ }
543
+ }
544
+ }
545
+ }
546
+ }
547
+
548
+ # After (5.x)
549
+ query Cart($id: ID!) {
550
+ cart(id: $id) {
551
+ lines(first: 10) {
552
+ edges {
553
+ node {
554
+ id
555
+ }
556
+ }
557
+ nodes {
558
+ id
559
+ }
560
+ }
561
+ }
562
+ }
563
+ ```
564
+
565
+ Cart line input renamed `merchandiseId` → `variantId` (consistent with the output field):
566
+
567
+ ```graphql
568
+ # Before (4.x)
569
+ mutation CartAddLines($id: ID!, $lines: [CartLineInput!]!) {
570
+ cartAddLines(id: $id, lines: $lines) { ... }
571
+ }
572
+ # variables: { lines: [{ merchandiseId: "uuid", quantity: 1 }] }
573
+
574
+ # After (5.x)
575
+ mutation CartAddLines($id: ID!, $lines: [CartLineInput!]!) {
576
+ cartAddLines(id: $id, lines: $lines) { ... }
577
+ }
578
+ # variables: { lines: [{ variantId: "uuid", quantity: 1 }] }
579
+ ```
580
+
581
+ The `variantId` name also matches the `userErrors[].field` path returned for input-related errors (e.g. `field: ["lines", "variantId"]`).
582
+
583
+ ### Recommendations: top-level queries replaced by field resolvers
584
+
585
+ Two top-level queries were removed. Use the field resolvers on the parent entity instead — they return identical payloads with automatic context inheritance, cleaner cache invalidation, and a clearer parent-not-found vs empty-recommendations distinction:
586
+
587
+ ```graphql
588
+ # Before (4.x)
589
+ query SimilarProducts($productId: String!, $first: Int) {
590
+ similarProducts(productId: $productId, first: $first) {
591
+ items {
592
+ product {
593
+ id
594
+ title
595
+ }
596
+ type
597
+ score
598
+ }
599
+ totalCount
600
+ }
601
+ }
602
+ query CartRecommendations($cartId: String!, $first: Int) {
603
+ cartRecommendations(cartId: $cartId, first: $first) {
604
+ frequentlyBoughtTogether {
605
+ product {
606
+ id
607
+ }
608
+ }
609
+ youMayAlsoLike {
610
+ product {
611
+ id
612
+ }
613
+ }
614
+ }
615
+ }
616
+
617
+ # After (5.x) — same payloads, parent-scoped
618
+ query Product($id: ID!, $first: Int) {
619
+ product(id: $id) {
620
+ recommendations(first: $first) {
621
+ items {
622
+ product {
623
+ id
624
+ title
625
+ }
626
+ type
627
+ score
628
+ }
629
+ totalCount
630
+ }
631
+ }
632
+ }
633
+ query Cart($id: ID!, $first: Int) {
634
+ cart(id: $id) {
635
+ recommendations(first: $first) {
636
+ frequentlyBoughtTogether {
637
+ product {
638
+ id
639
+ }
640
+ }
641
+ youMayAlsoLike {
642
+ product {
643
+ id
644
+ }
645
+ }
646
+ }
647
+ }
648
+ }
649
+ ```
650
+
651
+ For broader product-scoped recommendations driven by intent (`SIMILAR | COMPLEMENTARY | UPSELL`), use the existing top-level `productRecommendations(productId, intent, limit)` query, which returns a flat `[Product!]!` payload — separate surface from the rich `Product.recommendations` field (which carries metadata `type`, `score`, `reason` per item).
652
+
3
653
  ## 0.2.6
4
654
 
5
655
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AA4EA,KAAK,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAG3D,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA+cD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAkErE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,aAAkB,iBAua9D;AAGD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,kBA4B1C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,iBAkD9D;AAwDD;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,CAAC,EAAE,MAAM,iBAuDhE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,iBA4E3D"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AA4EA,KAAK,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAG3D,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA+cD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAkErE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,aAAkB,iBA4a9D;AAGD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,kBA4B1C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,iBAkD9D;AAwDD;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,CAAC,EAAE,MAAM,iBAuDhE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,iBA4E3D"}
@@ -677,7 +677,12 @@ export async function deployCommand(options = {}) {
677
677
  catch {
678
678
  console.log(chalk.cyan(' Installing wrangler...\n'));
679
679
  const addCmd = pm === 'pnpm' ? 'pnpm add -D' : pm === 'yarn' ? 'yarn add -D' : 'npm install -D';
680
- execSync(`${addCmd} wrangler`, { stdio: 'inherit', timeout: 120_000 });
680
+ // Pin to wrangler 4.x. Without explicit major range a new wrangler 5+ release
681
+ // could bump the Node version floor again (4.x already requires Node ≥22 —
682
+ // catching merchants on `node-version: 20` runners until they upgrade the
683
+ // generated workflow). Pinning keeps the CLI deterministic across runs;
684
+ // bump the range deliberately when CLI is tested on a new wrangler major.
685
+ execSync(`${addCmd} wrangler@^4`, { stdio: 'inherit', timeout: 120_000 });
681
686
  }
682
687
  console.log(chalk.cyan(' Re-bundling worker with Wrangler for CF Workers compatibility...\n'));
683
688
  const bundledDir = join('.open-next', '_wrangler_out');