@doswiftly/storefront-sdk 4.4.0 → 4.5.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.
Files changed (89) hide show
  1. package/dist/core/cart/types.d.ts +53 -20
  2. package/dist/core/cart/types.d.ts.map +1 -1
  3. package/dist/core/cart/types.js +3 -0
  4. package/dist/core/operations/cart.d.ts +15 -9
  5. package/dist/core/operations/cart.d.ts.map +1 -1
  6. package/dist/core/operations/cart.js +130 -58
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +1 -1
  9. package/package.json +9 -4
  10. package/src/__tests__/contract/storefront-api.contract.test.ts +0 -450
  11. package/src/__tests__/unit/auth-client.test.ts +0 -210
  12. package/src/__tests__/unit/bot-protection.test.ts +0 -461
  13. package/src/__tests__/unit/cart-client.test.ts +0 -233
  14. package/src/__tests__/unit/cart-store.test.ts +0 -349
  15. package/src/__tests__/unit/create-client.test.ts +0 -356
  16. package/src/__tests__/unit/helpers.test.ts +0 -377
  17. package/src/__tests__/unit/middleware.test.ts +0 -374
  18. package/src/__tests__/unit/test-helpers.ts +0 -103
  19. package/src/core/auth/auth-client.ts +0 -123
  20. package/src/core/auth/cookie-config.ts +0 -23
  21. package/src/core/auth/handlers.ts +0 -168
  22. package/src/core/auth/routes.ts +0 -26
  23. package/src/core/auth/token-client.ts +0 -51
  24. package/src/core/auth/types.ts +0 -54
  25. package/src/core/bot-protection/abstract-manager.ts +0 -185
  26. package/src/core/bot-protection/create-manager.ts +0 -37
  27. package/src/core/bot-protection/eucaptcha-manager.ts +0 -88
  28. package/src/core/bot-protection/fallback-manager.ts +0 -43
  29. package/src/core/bot-protection/turnstile-manager.ts +0 -92
  30. package/src/core/bot-protection/types/eucaptcha.d.ts +0 -28
  31. package/src/core/bot-protection/types/turnstile.d.ts +0 -33
  32. package/src/core/cache.ts +0 -102
  33. package/src/core/cart/cart-client.ts +0 -150
  34. package/src/core/cart/cookie-config.ts +0 -13
  35. package/src/core/cart/types.ts +0 -104
  36. package/src/core/client/compose.ts +0 -15
  37. package/src/core/client/create-client.ts +0 -129
  38. package/src/core/client/dedupe.ts +0 -19
  39. package/src/core/client/execute.ts +0 -70
  40. package/src/core/client/hash.ts +0 -21
  41. package/src/core/client/operation-name.ts +0 -12
  42. package/src/core/client/types.ts +0 -171
  43. package/src/core/currency/cookie-config.ts +0 -13
  44. package/src/core/errors.ts +0 -67
  45. package/src/core/format.ts +0 -254
  46. package/src/core/helpers/assert-no-user-errors.ts +0 -21
  47. package/src/core/helpers/normalize-connection.ts +0 -48
  48. package/src/core/helpers/sanitize-html.ts +0 -42
  49. package/src/core/image.ts +0 -22
  50. package/src/core/index.ts +0 -174
  51. package/src/core/language/cookie-config.ts +0 -13
  52. package/src/core/middleware/auth.ts +0 -27
  53. package/src/core/middleware/bot-protection.ts +0 -140
  54. package/src/core/middleware/currency.ts +0 -27
  55. package/src/core/middleware/errors.ts +0 -86
  56. package/src/core/middleware/language.ts +0 -30
  57. package/src/core/middleware/retry.ts +0 -75
  58. package/src/core/middleware/timeout.ts +0 -61
  59. package/src/core/operations/auth.ts +0 -123
  60. package/src/core/operations/cart.ts +0 -185
  61. package/src/index.ts +0 -25
  62. package/src/react/bot-protection/bot-protection-context.ts +0 -17
  63. package/src/react/bot-protection/bot-protection-widget.tsx +0 -46
  64. package/src/react/cookies.ts +0 -89
  65. package/src/react/helpers/create-store-context.ts +0 -56
  66. package/src/react/hooks/use-auth.ts +0 -218
  67. package/src/react/hooks/use-bot-protection.ts +0 -31
  68. package/src/react/hooks/use-cart-manager.ts +0 -236
  69. package/src/react/hooks/use-currency.ts +0 -23
  70. package/src/react/hooks/use-debounced-value.ts +0 -30
  71. package/src/react/hooks/use-hydrated.ts +0 -20
  72. package/src/react/hooks/use-storefront-client.ts +0 -12
  73. package/src/react/index.ts +0 -71
  74. package/src/react/providers/currency-provider.tsx +0 -30
  75. package/src/react/providers/language-provider.tsx +0 -34
  76. package/src/react/providers/storefront-client-provider.tsx +0 -107
  77. package/src/react/providers/storefront-provider.tsx +0 -99
  78. package/src/react/server/get-storefront-client.ts +0 -60
  79. package/src/react/server/index.ts +0 -1
  80. package/src/react/stores/auth.store.ts +0 -112
  81. package/src/react/stores/cart.context.ts +0 -10
  82. package/src/react/stores/cart.store.ts +0 -254
  83. package/src/react/stores/currency.store.ts +0 -93
  84. package/src/react/stores/index.ts +0 -17
  85. package/src/react/stores/language.store.ts +0 -90
  86. package/src/react/stores/store-context.tsx +0 -103
  87. package/src/react/types/shop-config.ts +0 -22
  88. package/tsconfig.json +0 -20
  89. package/vitest.config.ts +0 -14
@@ -2,32 +2,67 @@
2
2
  * Cart types — manual (no codegen).
3
3
  *
4
4
  * These match the backend storefront-graphql Cart type.
5
+ * Keep in sync with SSOT: backend/storefront-graphql/types/cart.types.ts
6
+ *
7
+ * Validate with: pnpm test:contract (cart-operations-drift test)
5
8
  */
6
9
  export interface Money {
7
10
  amount: string;
8
11
  currencyCode: string;
9
12
  }
13
+ /**
14
+ * Price with full currency-conversion transparency.
15
+ *
16
+ * Used for all cart/checkout prices where the customer may be viewing
17
+ * prices converted from the shop's base currency.
18
+ */
19
+ export interface PriceMoney {
20
+ amount: string;
21
+ currencyCode: string;
22
+ baseAmount: string;
23
+ baseCurrencyCode: string;
24
+ exchangeRate: number | null;
25
+ marginApplied: number | null;
26
+ rateTimestamp: string | null;
27
+ isConverted: boolean;
28
+ }
10
29
  export interface CartCost {
11
- totalAmount: Money;
12
- subtotalAmount: Money;
13
- totalTaxAmount: Money | null;
14
- totalDutyAmount: Money | null;
30
+ totalAmount: PriceMoney;
31
+ subtotalAmount: PriceMoney;
32
+ totalTaxAmount: PriceMoney | null;
33
+ totalDutyAmount: PriceMoney | null;
15
34
  }
16
35
  export interface CartLineCost {
17
- totalAmount: Money;
18
- amountPerQuantity: Money;
19
- compareAtAmountPerQuantity: Money | null;
36
+ amountPerQuantity: PriceMoney;
37
+ subtotalAmount: PriceMoney;
38
+ totalAmount: PriceMoney;
39
+ compareAtAmountPerQuantity: PriceMoney | null;
40
+ }
41
+ export interface SelectedOption {
42
+ name: string;
43
+ value: string;
20
44
  }
21
45
  export interface CartLineMerchandise {
22
46
  id: string;
23
47
  title: string;
24
48
  sku: string | null;
49
+ price: PriceMoney;
50
+ originalPrice: Money | null;
51
+ compareAtPrice: PriceMoney | null;
52
+ originalCompareAtPrice: Money | null;
53
+ available: boolean;
54
+ quantityAvailable: number | null;
25
55
  image: {
56
+ id: string | null;
26
57
  url: string;
27
58
  altText: string | null;
59
+ width: number | null;
60
+ height: number | null;
28
61
  } | null;
29
- price: Money;
30
- compareAtPrice: Money | null;
62
+ selectedOptions: SelectedOption[];
63
+ barcode: string | null;
64
+ weight: number | null;
65
+ position: number | null;
31
66
  }
32
67
  export interface CartLine {
33
68
  id: string;
@@ -36,18 +71,20 @@ export interface CartLine {
36
71
  cost: CartLineCost;
37
72
  attributes: Array<{
38
73
  key: string;
39
- value: string;
74
+ value: string | null;
40
75
  }>;
41
- productId: string;
42
- productTitle: string;
43
- productHandle: string;
76
+ productId: string | null;
77
+ productTitle: string | null;
78
+ productHandle: string | null;
79
+ productType: string | null;
44
80
  }
45
81
  export interface CartDiscountCode {
46
82
  code: string;
47
83
  applicable: boolean;
48
84
  }
49
85
  export interface CartDiscountAllocation {
50
- discountedAmount: Money;
86
+ discountCode: string;
87
+ amount: Money;
51
88
  }
52
89
  export interface CartBuyerIdentity {
53
90
  email: string | null;
@@ -62,17 +99,13 @@ export interface Cart {
62
99
  createdAt: string;
63
100
  updatedAt: string;
64
101
  cost: CartCost;
65
- lines: {
66
- edges: Array<{
67
- node: CartLine;
68
- }>;
69
- };
102
+ lines: CartLine[];
70
103
  buyerIdentity: CartBuyerIdentity | null;
71
104
  discountCodes: CartDiscountCode[];
72
105
  discountAllocations: CartDiscountAllocation[];
73
106
  attributes: Array<{
74
107
  key: string;
75
- value: string;
108
+ value: string | null;
76
109
  }>;
77
110
  }
78
111
  export interface CartLineInput {
@@ -1 +1 @@
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AAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -2,5 +2,8 @@
2
2
  * Cart types — manual (no codegen).
3
3
  *
4
4
  * These match the backend storefront-graphql Cart type.
5
+ * Keep in sync with SSOT: backend/storefront-graphql/types/cart.types.ts
6
+ *
7
+ * Validate with: pnpm test:contract (cart-operations-drift test)
5
8
  */
6
9
  export {};
@@ -1,15 +1,21 @@
1
1
  /**
2
2
  * Cart GraphQL operations — manual query strings (no codegen).
3
3
  *
4
- * These match the backend storefront-graphql schema exactly.
4
+ * SSOT: packages/backend/src/commerce/storefront-graphql/operations/
5
+ * - fragments.graphql (CartCost, CartLineCost, CartLine, Cart, etc.)
6
+ * - queries.graphql (Cart query)
7
+ * - mutations.graphql (cartCreate, cartLinesAdd, etc.)
8
+ *
9
+ * Validate drift: pnpm test:contract (cart-operations-drift test)
10
+ *
5
11
  * Cart mutations always return full Cart + userErrors.
6
12
  */
7
- export declare const CART_QUERY = "\n query Cart($id: ID!) {\n cart(id: $id) {\n ...CartFields\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n";
8
- export declare const CART_CREATE = "\n mutation CartCreate($input: CartCreateInput) {\n cartCreate(input: $input) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
9
- export declare const CART_LINES_ADD = "\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
10
- export declare const CART_LINES_UPDATE = "\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
11
- export declare const CART_LINES_REMOVE = "\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
12
- export declare const CART_DISCOUNT_CODES_UPDATE = "\n mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
13
- export declare const CART_NOTE_UPDATE = "\n mutation CartNoteUpdate($cartId: ID!, $note: String!) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
14
- export declare const CART_BUYER_IDENTITY_UPDATE = "\n mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart { ...CartFields }\n userErrors { ...UserErrorFields }\n }\n }\n \n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n note\n createdAt\n updatedAt\n cost { ...CartCost }\n lines(first: 100) {\n edges {\n node { ...CartLineFields }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n discountCodes {\n code\n applicable\n }\n discountAllocations {\n discountedAmount { ...Money }\n }\n attributes { key value }\n }\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment CartCost on CartCost {\n totalAmount { ...Money }\n subtotalAmount { ...Money }\n totalTaxAmount { ...Money }\n totalDutyAmount { ...Money }\n }\n\n \n fragment CartLineFields on CartLine {\n id\n quantity\n merchandise {\n id\n title\n sku\n image { url altText }\n price { ...Money }\n compareAtPrice { ...Money }\n }\n cost {\n totalAmount { ...Money }\n amountPerQuantity { ...Money }\n compareAtAmountPerQuantity { ...Money }\n }\n attributes { key value }\n productId\n productTitle\n productHandle\n }\n\n\n \n fragment UserErrorFields on UserError {\n message\n field\n code\n }\n\n";
13
+ export declare const CART_QUERY = "\n query Cart($id: ID!) {\n cart(id: $id) {\n ...Cart\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n";
14
+ export declare const CART_CREATE = "\n mutation CartCreate($input: CartCreateInput) {\n cartCreate(input: $input) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
15
+ export declare const CART_LINES_ADD = "\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
16
+ export declare const CART_LINES_UPDATE = "\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
17
+ export declare const CART_LINES_REMOVE = "\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
18
+ export declare const CART_DISCOUNT_CODES_UPDATE = "\n mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
19
+ export declare const CART_NOTE_UPDATE = "\n mutation CartNoteUpdate($cartId: ID!, $note: String!) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
20
+ export declare const CART_BUYER_IDENTITY_UPDATE = "\n mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart { ...Cart }\n userErrors { ...UserError }\n }\n }\n \n fragment Cart on Cart {\n id\n checkoutUrl\n totalQuantity\n cost { ...CartCost }\n lines(first: 100) { ...CartLine }\n buyerIdentity { ...CartBuyerIdentity }\n discountCodes { ...CartDiscountCode }\n discountAllocations { ...CartDiscountAllocation }\n note\n attributes { key value }\n createdAt\n updatedAt\n }\n \n fragment CartCost on CartCost {\n totalAmount { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalTaxAmount { ...PriceMoney }\n totalDutyAmount { ...PriceMoney }\n }\n\n \n fragment CartLine on CartLine {\n id\n quantity\n merchandise { ...ProductVariant }\n cost { ...CartLineCost }\n attributes { key value }\n productId\n productTitle\n productHandle\n productType\n }\n \n fragment CartLineCost on CartLineCost {\n amountPerQuantity { ...PriceMoney }\n subtotalAmount { ...PriceMoney }\n totalAmount { ...PriceMoney }\n compareAtAmountPerQuantity { ...PriceMoney }\n }\n\n \n fragment ProductVariant on ProductVariant {\n id\n title\n sku\n price { ...PriceMoney }\n originalPrice { ...Money }\n compareAtPrice { ...PriceMoney }\n originalCompareAtPrice { ...Money }\n available\n quantityAvailable\n image { ...Image }\n selectedOptions { ...SelectedOption }\n barcode\n weight\n position\n }\n \n fragment PriceMoney on PriceMoney {\n ...Price\n baseAmount\n baseCurrencyCode\n exchangeRate\n marginApplied\n rateTimestamp\n isConverted\n }\n \n fragment Price on PriceMoney {\n amount\n currencyCode\n }\n\n\n \n fragment Money on Money {\n amount\n currencyCode\n }\n\n \n fragment Image on Image {\n id\n url\n altText\n width\n height\n }\n\n \n fragment SelectedOption on SelectedOption {\n name\n value\n }\n\n\n\n \n fragment CartBuyerIdentity on CartBuyerIdentity {\n email\n phone\n countryCode\n }\n\n \n fragment CartDiscountCode on CartDiscountCode {\n code\n applicable\n }\n\n \n fragment CartDiscountAllocation on CartDiscountAllocation {\n discountCode\n amount { ...Money }\n }\n\n\n \n fragment UserError on UserError {\n message\n code\n field\n }\n\n";
15
21
  //# sourceMappingURL=cart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2FH,eAAO,MAAM,UAAU,quCAOtB,CAAC;AAMF,eAAO,MAAM,WAAW,m5CASvB,CAAC;AAEF,eAAO,MAAM,cAAc,w7CAS1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,o8CAS7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,y7CAS7B,CAAC;AAEF,eAAO,MAAM,0BAA0B,+9CAStC,CAAC;AAEF,eAAO,MAAM,gBAAgB,+6CAS5B,CAAC;AAEF,eAAO,MAAM,0BAA0B,4+CAStC,CAAC"}
1
+ {"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuKH,eAAO,MAAM,UAAU,otEAOtB,CAAC;AAMF,eAAO,MAAM,WAAW,s3EASvB,CAAC;AAEF,eAAO,MAAM,cAAc,25EAS1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,u6EAS7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,45EAS7B,CAAC;AAEF,eAAO,MAAM,0BAA0B,k8EAStC,CAAC;AAEF,eAAO,MAAM,gBAAgB,k5EAS5B,CAAC;AAEF,eAAO,MAAM,0BAA0B,+8EAStC,CAAC"}
@@ -1,11 +1,17 @@
1
1
  /**
2
2
  * Cart GraphQL operations — manual query strings (no codegen).
3
3
  *
4
- * These match the backend storefront-graphql schema exactly.
4
+ * SSOT: packages/backend/src/commerce/storefront-graphql/operations/
5
+ * - fragments.graphql (CartCost, CartLineCost, CartLine, Cart, etc.)
6
+ * - queries.graphql (Cart query)
7
+ * - mutations.graphql (cartCreate, cartLinesAdd, etc.)
8
+ *
9
+ * Validate drift: pnpm test:contract (cart-operations-drift test)
10
+ *
5
11
  * Cart mutations always return full Cart + userErrors.
6
12
  */
7
13
  // ---------------------------------------------------------------------------
8
- // Fragments
14
+ // Shared fragments (matching SSOT fragments.graphql)
9
15
  // ---------------------------------------------------------------------------
10
16
  const MONEY_FRAGMENT = `
11
17
  fragment Money on Money {
@@ -13,74 +19,140 @@ const MONEY_FRAGMENT = `
13
19
  currencyCode
14
20
  }
15
21
  `;
22
+ const PRICE_FRAGMENT = `
23
+ fragment Price on PriceMoney {
24
+ amount
25
+ currencyCode
26
+ }
27
+ `;
28
+ const PRICE_MONEY_FRAGMENT = `
29
+ fragment PriceMoney on PriceMoney {
30
+ ...Price
31
+ baseAmount
32
+ baseCurrencyCode
33
+ exchangeRate
34
+ marginApplied
35
+ rateTimestamp
36
+ isConverted
37
+ }
38
+ ${PRICE_FRAGMENT}
39
+ `;
40
+ const IMAGE_FRAGMENT = `
41
+ fragment Image on Image {
42
+ id
43
+ url
44
+ altText
45
+ width
46
+ height
47
+ }
48
+ `;
49
+ const SELECTED_OPTION_FRAGMENT = `
50
+ fragment SelectedOption on SelectedOption {
51
+ name
52
+ value
53
+ }
54
+ `;
55
+ // ---------------------------------------------------------------------------
56
+ // Cart-specific fragments (matching SSOT fragments.graphql)
57
+ // ---------------------------------------------------------------------------
58
+ const PRODUCT_VARIANT_FRAGMENT = `
59
+ fragment ProductVariant on ProductVariant {
60
+ id
61
+ title
62
+ sku
63
+ price { ...PriceMoney }
64
+ originalPrice { ...Money }
65
+ compareAtPrice { ...PriceMoney }
66
+ originalCompareAtPrice { ...Money }
67
+ available
68
+ quantityAvailable
69
+ image { ...Image }
70
+ selectedOptions { ...SelectedOption }
71
+ barcode
72
+ weight
73
+ position
74
+ }
75
+ ${PRICE_MONEY_FRAGMENT}
76
+ ${MONEY_FRAGMENT}
77
+ ${IMAGE_FRAGMENT}
78
+ ${SELECTED_OPTION_FRAGMENT}
79
+ `;
16
80
  const CART_COST_FRAGMENT = `
17
81
  fragment CartCost on CartCost {
18
- totalAmount { ...Money }
19
- subtotalAmount { ...Money }
20
- totalTaxAmount { ...Money }
21
- totalDutyAmount { ...Money }
82
+ totalAmount { ...PriceMoney }
83
+ subtotalAmount { ...PriceMoney }
84
+ totalTaxAmount { ...PriceMoney }
85
+ totalDutyAmount { ...PriceMoney }
86
+ }
87
+ `;
88
+ const CART_LINE_COST_FRAGMENT = `
89
+ fragment CartLineCost on CartLineCost {
90
+ amountPerQuantity { ...PriceMoney }
91
+ subtotalAmount { ...PriceMoney }
92
+ totalAmount { ...PriceMoney }
93
+ compareAtAmountPerQuantity { ...PriceMoney }
22
94
  }
23
95
  `;
24
96
  const CART_LINE_FRAGMENT = `
25
- fragment CartLineFields on CartLine {
97
+ fragment CartLine on CartLine {
26
98
  id
27
99
  quantity
28
- merchandise {
29
- id
30
- title
31
- sku
32
- image { url altText }
33
- price { ...Money }
34
- compareAtPrice { ...Money }
35
- }
36
- cost {
37
- totalAmount { ...Money }
38
- amountPerQuantity { ...Money }
39
- compareAtAmountPerQuantity { ...Money }
40
- }
100
+ merchandise { ...ProductVariant }
101
+ cost { ...CartLineCost }
41
102
  attributes { key value }
42
103
  productId
43
104
  productTitle
44
105
  productHandle
106
+ productType
107
+ }
108
+ ${CART_LINE_COST_FRAGMENT}
109
+ ${PRODUCT_VARIANT_FRAGMENT}
110
+ `;
111
+ const CART_BUYER_IDENTITY_FRAGMENT = `
112
+ fragment CartBuyerIdentity on CartBuyerIdentity {
113
+ email
114
+ phone
115
+ countryCode
116
+ }
117
+ `;
118
+ const CART_DISCOUNT_CODE_FRAGMENT = `
119
+ fragment CartDiscountCode on CartDiscountCode {
120
+ code
121
+ applicable
122
+ }
123
+ `;
124
+ const CART_DISCOUNT_ALLOCATION_FRAGMENT = `
125
+ fragment CartDiscountAllocation on CartDiscountAllocation {
126
+ discountCode
127
+ amount { ...Money }
45
128
  }
46
129
  `;
47
130
  const CART_FRAGMENT = `
48
- fragment CartFields on Cart {
131
+ fragment Cart on Cart {
49
132
  id
50
133
  checkoutUrl
51
134
  totalQuantity
135
+ cost { ...CartCost }
136
+ lines(first: 100) { ...CartLine }
137
+ buyerIdentity { ...CartBuyerIdentity }
138
+ discountCodes { ...CartDiscountCode }
139
+ discountAllocations { ...CartDiscountAllocation }
52
140
  note
141
+ attributes { key value }
53
142
  createdAt
54
143
  updatedAt
55
- cost { ...CartCost }
56
- lines(first: 100) {
57
- edges {
58
- node { ...CartLineFields }
59
- }
60
- }
61
- buyerIdentity {
62
- email
63
- phone
64
- countryCode
65
- }
66
- discountCodes {
67
- code
68
- applicable
69
- }
70
- discountAllocations {
71
- discountedAmount { ...Money }
72
- }
73
- attributes { key value }
74
144
  }
75
- ${MONEY_FRAGMENT}
76
145
  ${CART_COST_FRAGMENT}
77
146
  ${CART_LINE_FRAGMENT}
147
+ ${CART_BUYER_IDENTITY_FRAGMENT}
148
+ ${CART_DISCOUNT_CODE_FRAGMENT}
149
+ ${CART_DISCOUNT_ALLOCATION_FRAGMENT}
78
150
  `;
79
151
  const USER_ERROR_FRAGMENT = `
80
- fragment UserErrorFields on UserError {
152
+ fragment UserError on UserError {
81
153
  message
82
- field
83
154
  code
155
+ field
84
156
  }
85
157
  `;
86
158
  // ---------------------------------------------------------------------------
@@ -89,7 +161,7 @@ const USER_ERROR_FRAGMENT = `
89
161
  export const CART_QUERY = `
90
162
  query Cart($id: ID!) {
91
163
  cart(id: $id) {
92
- ...CartFields
164
+ ...Cart
93
165
  }
94
166
  }
95
167
  ${CART_FRAGMENT}
@@ -100,8 +172,8 @@ export const CART_QUERY = `
100
172
  export const CART_CREATE = `
101
173
  mutation CartCreate($input: CartCreateInput) {
102
174
  cartCreate(input: $input) {
103
- cart { ...CartFields }
104
- userErrors { ...UserErrorFields }
175
+ cart { ...Cart }
176
+ userErrors { ...UserError }
105
177
  }
106
178
  }
107
179
  ${CART_FRAGMENT}
@@ -110,8 +182,8 @@ export const CART_CREATE = `
110
182
  export const CART_LINES_ADD = `
111
183
  mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
112
184
  cartLinesAdd(cartId: $cartId, lines: $lines) {
113
- cart { ...CartFields }
114
- userErrors { ...UserErrorFields }
185
+ cart { ...Cart }
186
+ userErrors { ...UserError }
115
187
  }
116
188
  }
117
189
  ${CART_FRAGMENT}
@@ -120,8 +192,8 @@ export const CART_LINES_ADD = `
120
192
  export const CART_LINES_UPDATE = `
121
193
  mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
122
194
  cartLinesUpdate(cartId: $cartId, lines: $lines) {
123
- cart { ...CartFields }
124
- userErrors { ...UserErrorFields }
195
+ cart { ...Cart }
196
+ userErrors { ...UserError }
125
197
  }
126
198
  }
127
199
  ${CART_FRAGMENT}
@@ -130,8 +202,8 @@ export const CART_LINES_UPDATE = `
130
202
  export const CART_LINES_REMOVE = `
131
203
  mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {
132
204
  cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
133
- cart { ...CartFields }
134
- userErrors { ...UserErrorFields }
205
+ cart { ...Cart }
206
+ userErrors { ...UserError }
135
207
  }
136
208
  }
137
209
  ${CART_FRAGMENT}
@@ -140,8 +212,8 @@ export const CART_LINES_REMOVE = `
140
212
  export const CART_DISCOUNT_CODES_UPDATE = `
141
213
  mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {
142
214
  cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
143
- cart { ...CartFields }
144
- userErrors { ...UserErrorFields }
215
+ cart { ...Cart }
216
+ userErrors { ...UserError }
145
217
  }
146
218
  }
147
219
  ${CART_FRAGMENT}
@@ -150,8 +222,8 @@ export const CART_DISCOUNT_CODES_UPDATE = `
150
222
  export const CART_NOTE_UPDATE = `
151
223
  mutation CartNoteUpdate($cartId: ID!, $note: String!) {
152
224
  cartNoteUpdate(cartId: $cartId, note: $note) {
153
- cart { ...CartFields }
154
- userErrors { ...UserErrorFields }
225
+ cart { ...Cart }
226
+ userErrors { ...UserError }
155
227
  }
156
228
  }
157
229
  ${CART_FRAGMENT}
@@ -160,8 +232,8 @@ export const CART_NOTE_UPDATE = `
160
232
  export const CART_BUYER_IDENTITY_UPDATE = `
161
233
  mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {
162
234
  cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
163
- cart { ...CartFields }
164
- userErrors { ...UserErrorFields }
235
+ cart { ...Cart }
236
+ userErrors { ...UserError }
165
237
  }
166
238
  }
167
239
  ${CART_FRAGMENT}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @doswiftly/storefront-sdk v4.0.0
2
+ * @doswiftly/storefront-sdk v4.4.0
3
3
  *
4
4
  * Layered SDK — Hydrogen-aligned architecture.
5
5
  *
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @doswiftly/storefront-sdk v4.0.0
2
+ * @doswiftly/storefront-sdk v4.4.0
3
3
  *
4
4
  * Layered SDK — Hydrogen-aligned architecture.
5
5
  *
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@doswiftly/storefront-sdk",
3
- "version": "4.4.0",
3
+ "version": "4.5.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
+ "files": [
7
+ "dist",
8
+ "README.md"
9
+ ],
6
10
  "types": "dist/core/index.d.ts",
7
11
  "exports": {
8
12
  ".": {
@@ -30,7 +34,8 @@
30
34
  "test": "vitest run",
31
35
  "test:watch": "vitest",
32
36
  "test:unit": "vitest run src/__tests__/unit/",
33
- "test:contract": "vitest run src/__tests__/contract/"
37
+ "test:contract": "vitest run src/__tests__/contract/",
38
+ "validate:cart": "node scripts/validate-cart-operations.cjs --strict"
34
39
  },
35
40
  "keywords": [
36
41
  "sdk",
@@ -50,9 +55,9 @@
50
55
  "@types/node": "^22.10.2",
51
56
  "@types/react": "^18.3.0 || ^19.0.0",
52
57
  "fast-check": "^3.23.2",
53
- "next": "^15.0.0",
58
+ "next": "^16.0.0",
54
59
  "typescript": "^5.7.2",
55
- "vitest": "^2.1.8",
60
+ "vitest": "^4.1.0",
56
61
  "zustand": "^5.0.2",
57
62
  "react": "^19.0.0"
58
63
  },