@shopify/hydrogen 1.6.8 → 1.7.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 (25) hide show
  1. package/dist/esnext/components/CartProvider/CartActions.client.d.ts +4 -2
  2. package/dist/esnext/components/CartProvider/CartActions.client.js +20 -11
  3. package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +4 -2
  4. package/dist/esnext/components/CartProvider/CartProvider.client.js +6 -2
  5. package/dist/esnext/components/CartProvider/cart-queries.js +10 -9
  6. package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +2 -1
  7. package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +2 -1
  8. package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +2 -1
  9. package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +2 -1
  10. package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +1 -1
  11. package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +2 -1
  12. package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +2 -1
  13. package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +2 -1
  14. package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +2 -1
  15. package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +2 -1
  16. package/dist/esnext/components/CartProvider/useCartAPIStateMachine.client.d.ts +4 -2
  17. package/dist/esnext/components/CartProvider/useCartAPIStateMachine.client.js +2 -1
  18. package/dist/esnext/entry-server.js +1 -1
  19. package/dist/esnext/foundation/Cache/cache.js +4 -3
  20. package/dist/esnext/storefront-api-types.d.ts +114 -95
  21. package/dist/esnext/storefront-api-types.js +2 -0
  22. package/dist/esnext/utilities/hash.js +1 -1
  23. package/dist/esnext/version.d.ts +1 -1
  24. package/dist/esnext/version.js +1 -1
  25. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CountryCode } from '../../storefront-api-types.js';
1
+ import { AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CountryCode, LanguageCode } from '../../storefront-api-types.js';
2
2
  import { CartAttributesUpdateMutation } from './graphql/CartAttributesUpdateMutation.js';
3
3
  import { CartBuyerIdentityUpdateMutation } from './graphql/CartBuyerIdentityUpdateMutation.js';
4
4
  import { CartCreateMutation } from './graphql/CartCreateMutation.js';
@@ -13,13 +13,15 @@ import { CartQueryQuery } from './graphql/CartQuery.js';
13
13
  *
14
14
  * See [cart API graphql mutations](https://shopify.dev/api/storefront/2022-07/objects/Cart)
15
15
  */
16
- export declare function useCartActions({ numCartLines, cartFragment, countryCode, }: {
16
+ export declare function useCartActions({ numCartLines, cartFragment, countryCode, languageCode, }: {
17
17
  /** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
18
18
  numCartLines?: number;
19
19
  /** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
20
20
  cartFragment: string;
21
21
  /** The ISO country code for i18n. */
22
22
  countryCode?: CountryCode;
23
+ /** The ISO country code for i18n. */
24
+ languageCode?: LanguageCode;
23
25
  }): {
24
26
  cartFetch: (cartId: string) => Promise<{
25
27
  data: CartQueryQuery | undefined;
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useMemo } from 'react';
2
- import { CountryCode, } from '../../storefront-api-types.js';
2
+ import { CountryCode, LanguageCode, } from '../../storefront-api-types.js';
3
3
  import { CartAttributesUpdate, CartBuyerIdentityUpdate, CartCreate, CartDiscountCodesUpdate, CartLineAdd, CartLineRemove, CartLineUpdate, CartNoteUpdate, CartQuery, } from './cart-queries.js';
4
4
  import { useCartFetch } from './hooks.client.js';
5
5
  /**
@@ -7,7 +7,7 @@ import { useCartFetch } from './hooks.client.js';
7
7
  *
8
8
  * See [cart API graphql mutations](https://shopify.dev/api/storefront/2022-07/objects/Cart)
9
9
  */
10
- export function useCartActions({ numCartLines, cartFragment, countryCode = CountryCode.Us, }) {
10
+ export function useCartActions({ numCartLines, cartFragment, countryCode = CountryCode.Us, languageCode = LanguageCode.En, }) {
11
11
  const fetchCart = useCartFetch();
12
12
  const cartFetch = useCallback((cartId) => {
13
13
  return fetchCart({
@@ -16,9 +16,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
16
16
  id: cartId,
17
17
  numCartLines,
18
18
  country: countryCode,
19
+ language: languageCode,
19
20
  },
20
21
  });
21
- }, [fetchCart, cartFragment, numCartLines, countryCode]);
22
+ }, [fetchCart, cartFragment, numCartLines, countryCode, languageCode]);
22
23
  const cartCreate = useCallback((cart) => {
23
24
  return fetchCart({
24
25
  query: CartCreate(cartFragment),
@@ -26,9 +27,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
26
27
  input: cart,
27
28
  numCartLines,
28
29
  country: countryCode,
30
+ language: languageCode,
29
31
  },
30
32
  });
31
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
33
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
32
34
  const cartLineAdd = useCallback((cartId, lines) => {
33
35
  return fetchCart({
34
36
  query: CartLineAdd(cartFragment),
@@ -37,9 +39,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
37
39
  lines,
38
40
  numCartLines,
39
41
  country: countryCode,
42
+ language: languageCode,
40
43
  },
41
44
  });
42
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
45
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
43
46
  const cartLineUpdate = useCallback((cartId, lines) => {
44
47
  return fetchCart({
45
48
  query: CartLineUpdate(cartFragment),
@@ -48,9 +51,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
48
51
  lines,
49
52
  numCartLines,
50
53
  country: countryCode,
54
+ language: languageCode,
51
55
  },
52
56
  });
53
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
57
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
54
58
  const cartLineRemove = useCallback((cartId, lines) => {
55
59
  return fetchCart({
56
60
  query: CartLineRemove(cartFragment),
@@ -59,9 +63,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
59
63
  lines,
60
64
  numCartLines,
61
65
  country: countryCode,
66
+ language: languageCode,
62
67
  },
63
68
  });
64
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
69
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
65
70
  const noteUpdate = useCallback((cartId, note) => {
66
71
  return fetchCart({
67
72
  query: CartNoteUpdate(cartFragment),
@@ -70,9 +75,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
70
75
  note,
71
76
  numCartLines,
72
77
  country: countryCode,
78
+ language: languageCode,
73
79
  },
74
80
  });
75
- }, [fetchCart, cartFragment, numCartLines, countryCode]);
81
+ }, [fetchCart, cartFragment, numCartLines, countryCode, languageCode]);
76
82
  const buyerIdentityUpdate = useCallback((cartId, buyerIdentity) => {
77
83
  return fetchCart({
78
84
  query: CartBuyerIdentityUpdate(cartFragment),
@@ -81,9 +87,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
81
87
  buyerIdentity,
82
88
  numCartLines,
83
89
  country: countryCode,
90
+ language: languageCode,
84
91
  },
85
92
  });
86
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
93
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
87
94
  const cartAttributesUpdate = useCallback((cartId, attributes) => {
88
95
  return fetchCart({
89
96
  query: CartAttributesUpdate(cartFragment),
@@ -92,9 +99,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
92
99
  attributes,
93
100
  numCartLines,
94
101
  country: countryCode,
102
+ language: languageCode,
95
103
  },
96
104
  });
97
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
105
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
98
106
  const discountCodesUpdate = useCallback((cartId, discountCodes) => {
99
107
  return fetchCart({
100
108
  query: CartDiscountCodesUpdate(cartFragment),
@@ -103,9 +111,10 @@ export function useCartActions({ numCartLines, cartFragment, countryCode = Count
103
111
  discountCodes,
104
112
  numCartLines,
105
113
  country: countryCode,
114
+ language: languageCode,
106
115
  },
107
116
  });
108
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
117
+ }, [cartFragment, countryCode, fetchCart, numCartLines, languageCode]);
109
118
  return useMemo(() => ({
110
119
  cartFetch,
111
120
  cartCreate,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { CartFragmentFragment } from './graphql/CartFragment.js';
3
- import { CartBuyerIdentityInput, CountryCode } from '../../storefront-api-types.js';
4
- export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, onCreateComplete, onLineAddComplete, onLineRemoveComplete, onLineUpdateComplete, onNoteUpdateComplete, onBuyerIdentityUpdateComplete, onAttributesUpdateComplete, onDiscountCodesUpdateComplete, data: cart, cartFragment, customerAccessToken, countryCode, }: {
3
+ import { CartBuyerIdentityInput, CountryCode, LanguageCode } from '../../storefront-api-types.js';
4
+ export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, onCreateComplete, onLineAddComplete, onLineRemoveComplete, onLineUpdateComplete, onNoteUpdateComplete, onBuyerIdentityUpdateComplete, onAttributesUpdateComplete, onDiscountCodesUpdateComplete, data: cart, cartFragment, customerAccessToken, countryCode, languageCode, }: {
5
5
  /** Any `ReactNode` elements. */
6
6
  children: React.ReactNode;
7
7
  /** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
@@ -46,4 +46,6 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
46
46
  customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];
47
47
  /** The ISO country code for i18n. */
48
48
  countryCode?: CountryCode;
49
+ /** The ISO language code for i18n. */
50
+ languageCode?: LanguageCode;
49
51
  }): JSX.Element;
@@ -1,11 +1,14 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef, useState, useTransition, } from 'react';
2
- import { CountryCode, } from '../../storefront-api-types.js';
3
2
  import { defaultCartFragment } from './cart-queries.js';
4
3
  import { CartContext } from './context.js';
5
4
  import { useCartAPIStateMachine } from './useCartAPIStateMachine.client.js';
6
5
  import { CART_ID_STORAGE_KEY } from './constants.js';
7
6
  import { ClientAnalytics } from '../../foundation/Analytics/ClientAnalytics.js';
8
- export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, onCreateComplete, onLineAddComplete, onLineRemoveComplete, onLineUpdateComplete, onNoteUpdateComplete, onBuyerIdentityUpdateComplete, onAttributesUpdateComplete, onDiscountCodesUpdateComplete, data: cart, cartFragment = defaultCartFragment, customerAccessToken, countryCode = CountryCode.Us, }) {
7
+ import { useLocalization } from '../../hooks/useLocalization/useLocalization.js';
8
+ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, onCreateComplete, onLineAddComplete, onLineRemoveComplete, onLineUpdateComplete, onNoteUpdateComplete, onBuyerIdentityUpdateComplete, onAttributesUpdateComplete, onDiscountCodesUpdateComplete, data: cart, cartFragment = defaultCartFragment, customerAccessToken, countryCode, languageCode, }) {
9
+ const { country, language } = useLocalization();
10
+ countryCode = (countryCode ?? country.isoCode).toUpperCase();
11
+ languageCode = (languageCode ?? language.isoCode).toUpperCase();
9
12
  if (countryCode)
10
13
  countryCode = countryCode.toUpperCase();
11
14
  const [prevCountryCode, setPrevCountryCode] = useState(countryCode);
@@ -134,6 +137,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
134
137
  data: cart,
135
138
  cartFragment,
136
139
  countryCode,
140
+ languageCode,
137
141
  onCartActionEntry,
138
142
  onCartActionOptimisticUI,
139
143
  onCartActionComplete,
@@ -1,5 +1,5 @@
1
1
  export const CartLineAdd = (cartFragment) => `
2
- mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
2
+ mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
3
3
  cartLinesAdd(cartId: $cartId, lines: $lines) {
4
4
  cart {
5
5
  ...CartFragment
@@ -10,7 +10,7 @@ mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int
10
10
  ${cartFragment}
11
11
  `;
12
12
  export const CartCreate = (cartFragment) => `
13
- mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
13
+ mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
14
14
  cartCreate(input: $input) {
15
15
  cart {
16
16
  ...CartFragment
@@ -21,7 +21,7 @@ mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: Coun
21
21
  ${cartFragment}
22
22
  `;
23
23
  export const CartLineRemove = (cartFragment) => `
24
- mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
24
+ mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
25
25
  cartLinesRemove(cartId: $cartId, lineIds: $lines) {
26
26
  cart {
27
27
  ...CartFragment
@@ -32,7 +32,7 @@ mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250,
32
32
  ${cartFragment}
33
33
  `;
34
34
  export const CartLineUpdate = (cartFragment) => `
35
- mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
35
+ mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
36
36
  cartLinesUpdate(cartId: $cartId, lines: $lines) {
37
37
  cart {
38
38
  ...CartFragment
@@ -43,7 +43,7 @@ mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartL
43
43
  ${cartFragment}
44
44
  `;
45
45
  export const CartNoteUpdate = (cartFragment) => `
46
- mutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
46
+ mutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
47
47
  cartNoteUpdate(cartId: $cartId, note: $note) {
48
48
  cart {
49
49
  ...CartFragment
@@ -59,7 +59,8 @@ mutation CartBuyerIdentityUpdate(
59
59
  $buyerIdentity: CartBuyerIdentityInput!
60
60
  $numCartLines: Int = 250
61
61
  $country: CountryCode = ZZ
62
- ) @inContext(country: $country) {
62
+ $language: LanguageCode
63
+ ) @inContext(country: $country, language: $language) {
63
64
  cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
64
65
  cart {
65
66
  ...CartFragment
@@ -70,7 +71,7 @@ mutation CartBuyerIdentityUpdate(
70
71
  ${cartFragment}
71
72
  `;
72
73
  export const CartAttributesUpdate = (cartFragment) => `
73
- mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
74
+ mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
74
75
  cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
75
76
  cart {
76
77
  ...CartFragment
@@ -81,7 +82,7 @@ mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $nu
81
82
  ${cartFragment}
82
83
  `;
83
84
  export const CartDiscountCodesUpdate = (cartFragment) => `
84
- mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
85
+ mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
85
86
  cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
86
87
  cart {
87
88
  ...CartFragment
@@ -92,7 +93,7 @@ mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCa
92
93
  ${cartFragment}
93
94
  `;
94
95
  export const CartQuery = (cartFragment) => `
95
- query CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
96
+ query CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ, $language: LanguageCode) @inContext(country: $country, language: $language) {
96
97
  cart(id: $id) {
97
98
  ...CartFragment
98
99
  }
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartAttributesUpdateMutationVariables = Types.Exact<{
7
7
  attributes: Array<Types.AttributeInput> | Types.AttributeInput;
8
8
  cartId: Types.Scalars['ID'];
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartAttributesUpdateMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartBuyerIdentityUpdateMutationVariables = Types.Exact<{
7
7
  cartId: Types.Scalars['ID'];
8
8
  buyerIdentity: Types.CartBuyerIdentityInput;
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartBuyerIdentityUpdateMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,11 +2,12 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartCreateMutationVariables = Types.Exact<{
7
7
  input: Types.CartInput;
8
8
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
9
9
  country?: Types.InputMaybe<Types.CountryCode>;
10
+ language?: Types.InputMaybe<Types.LanguageCode>;
10
11
  }>;
11
12
  export declare type CartCreateMutation = {
12
13
  __typename?: 'Mutation';
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartDiscountCodesUpdateMutationVariables = Types.Exact<{
7
7
  cartId: Types.Scalars['ID'];
8
8
  discountCodes?: Types.InputMaybe<Array<Types.Scalars['String']> | Types.Scalars['String']>;
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartDiscountCodesUpdateMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,7 +2,7 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartFragmentFragment = {
7
7
  __typename?: 'Cart';
8
8
  } & Pick<Types.Cart, 'id' | 'checkoutUrl' | 'totalQuantity' | 'note'> & {
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartLineAddMutationVariables = Types.Exact<{
7
7
  cartId: Types.Scalars['ID'];
8
8
  lines: Array<Types.CartLineInput> | Types.CartLineInput;
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartLineAddMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartLineRemoveMutationVariables = Types.Exact<{
7
7
  cartId: Types.Scalars['ID'];
8
8
  lines: Array<Types.Scalars['ID']> | Types.Scalars['ID'];
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartLineRemoveMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartLineUpdateMutationVariables = Types.Exact<{
7
7
  cartId: Types.Scalars['ID'];
8
8
  lines: Array<Types.CartLineUpdateInput> | Types.CartLineUpdateInput;
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartLineUpdateMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,12 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartNoteUpdateMutationVariables = Types.Exact<{
7
7
  cartId: Types.Scalars['ID'];
8
8
  note?: Types.InputMaybe<Types.Scalars['String']>;
9
9
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
10
10
  country?: Types.InputMaybe<Types.CountryCode>;
11
+ language?: Types.InputMaybe<Types.LanguageCode>;
11
12
  }>;
12
13
  export declare type CartNoteUpdateMutation = {
13
14
  __typename?: 'Mutation';
@@ -2,11 +2,12 @@
2
2
  * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
3
  * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
4
  */
5
- import * as Types from '../../../storefront-api-types.js';
5
+ import * as Types from '../../../storefront-api-types';
6
6
  export declare type CartQueryQueryVariables = Types.Exact<{
7
7
  id: Types.Scalars['ID'];
8
8
  numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
9
9
  country?: Types.InputMaybe<Types.CountryCode>;
10
+ language?: Types.InputMaybe<Types.LanguageCode>;
10
11
  }>;
11
12
  export declare type CartQueryQuery = {
12
13
  __typename?: 'QueryRoot';
@@ -1,8 +1,8 @@
1
1
  import { StateMachine } from '@xstate/fsm';
2
2
  import { CartFragmentFragment } from './graphql/CartFragment.js';
3
3
  import { Cart, CartMachineActionEvent, CartMachineContext, CartMachineEvent, CartMachineFetchResultEvent, CartMachineTypeState } from './types.js';
4
- import { CountryCode } from '../../storefront-api-types.js';
5
- export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry, onCartActionOptimisticUI, onCartActionComplete, data: cart, cartFragment, countryCode, }: {
4
+ import { CountryCode, LanguageCode } from '../../storefront-api-types.js';
5
+ export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry, onCartActionOptimisticUI, onCartActionComplete, data: cart, cartFragment, countryCode, languageCode, }: {
6
6
  /** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
7
7
  numCartLines?: number;
8
8
  /** A callback that is invoked just before a Cart API action executes. */
@@ -17,5 +17,7 @@ export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry
17
17
  cartFragment: string;
18
18
  /** The ISO country code for i18n. */
19
19
  countryCode?: CountryCode;
20
+ /** The ISO country code for i18n. */
21
+ languageCode?: LanguageCode;
20
22
  }): readonly [StateMachine.State<CartMachineContext, CartMachineEvent, CartMachineTypeState>, (event: "CART_FETCH" | "CART_CREATE" | "CART_SET" | "CARTLINE_ADD" | "CARTLINE_REMOVE" | "CARTLINE_UPDATE" | "NOTE_UPDATE" | "BUYER_IDENTITY_UPDATE" | "CART_ATTRIBUTES_UPDATE" | "DISCOUNT_CODES_UPDATE" | "CART_COMPLETED" | "RESOLVE" | "ERROR" | CartMachineEvent) => void, StateMachine.Service<CartMachineContext, CartMachineEvent, CartMachineTypeState>];
21
23
  export declare function cartFromGraphQL(cart: CartFragmentFragment): Cart;
@@ -129,11 +129,12 @@ function createCartMachine(initialCart) {
129
129
  },
130
130
  });
131
131
  }
132
- export function useCartAPIStateMachine({ numCartLines, onCartActionEntry, onCartActionOptimisticUI, onCartActionComplete, data: cart, cartFragment, countryCode, }) {
132
+ export function useCartAPIStateMachine({ numCartLines, onCartActionEntry, onCartActionOptimisticUI, onCartActionComplete, data: cart, cartFragment, countryCode, languageCode, }) {
133
133
  const { cartFetch, cartCreate, cartLineAdd, cartLineUpdate, cartLineRemove, noteUpdate, buyerIdentityUpdate, cartAttributesUpdate, discountCodesUpdate, } = useCartActions({
134
134
  numCartLines,
135
135
  cartFragment,
136
136
  countryCode,
137
+ languageCode,
137
138
  });
138
139
  const cartMachine = useMemo(() => createCartMachine(cart), [cart]);
139
140
  const [state, send, service] = useMachine(cartMachine, {
@@ -71,7 +71,7 @@ export const renderHydrogen = (App) => {
71
71
  }
72
72
  if (hydrogenConfig.poweredByHeader ?? true) {
73
73
  // If undefined in the config, then always show the header
74
- response.headers.set('powered-by', 'Shopify-Hydrogen');
74
+ response.headers.set('powered-by', 'Shopify, Hydrogen');
75
75
  }
76
76
  sessionApi ??= hydrogenConfig.session?.(log);
77
77
  request.ctx.session = getSyncSessionApi(request, response, log, sessionApi);
@@ -81,13 +81,14 @@ export async function setItemInCache(request, response, userCacheOptions) {
81
81
  */
82
82
  const cacheControl = getCacheControlSetting(userCacheOptions);
83
83
  // The padded cache-control to mimic stale-while-revalidate
84
- request.headers.set('cache-control', generateDefaultCacheControlHeader(getCacheControlSetting(cacheControl, {
84
+ const paddedCacheControlString = generateDefaultCacheControlHeader(getCacheControlSetting(cacheControl, {
85
85
  maxAge: (cacheControl.maxAge || 0) + (cacheControl.staleWhileRevalidate || 0),
86
- })));
86
+ }));
87
87
  // The cache-control we want to set on response
88
- const cacheControlString = generateDefaultCacheControlHeader(getCacheControlSetting(cacheControl));
88
+ const cacheControlString = generateDefaultCacheControlHeader(cacheControl);
89
89
  // CF will override cache-control, so we need to keep a
90
90
  // non-modified real-cache-control
91
+ response.headers.set('cache-control', paddedCacheControlString);
91
92
  response.headers.set('real-cache-control', cacheControlString);
92
93
  response.headers.set('cache-put-date', new Date().toUTCString());
93
94
  logCacheApiStatus('PUT', request.url);